Mercurial > pidgin
annotate src/gaimrc.c @ 1108:cb338aa38e78
[gaim-migrate @ 1118]
finally fixed a shitload of problems plaguing the buddy list
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Mon, 20 Nov 2000 08:35:25 +0000 |
parents | 18a14e6dd0af |
children | c73736fa0b7c |
rev | line source |
---|---|
1 | 1 /* |
2 * gaim | |
3 * | |
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 * | |
20 */ | |
21 | |
349
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
340
diff
changeset
|
22 #ifdef HAVE_CONFIG_H |
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
340
diff
changeset
|
23 #include "../config.h" |
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
340
diff
changeset
|
24 #endif |
1 | 25 #include <string.h> |
26 #include <sys/time.h> | |
27 | |
28 #include <sys/types.h> | |
29 #include <sys/stat.h> | |
30 | |
31 #include <unistd.h> | |
32 #include <stdio.h> | |
33 #include <stdlib.h> | |
34 #include <gtk/gtk.h> | |
35 #include "gaim.h" | |
36 | |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
37 /* for people like myself, who are too lazy to add an away msg :) */ |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
38 #define BORING_DEFAULT_AWAY_MSG "sorry, i ran out for a while. bbl" |
1 | 39 |
40 GList *aim_users = NULL; | |
41 int general_options; | |
42 int display_options; | |
43 int sound_options; | |
44 int font_options; | |
45 | |
46 int report_idle, web_browser; | |
47 struct save_pos blist_pos; | |
48 char web_command[2048]; | |
180 | 49 char latest_ver[25]; |
1006
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
50 char *sound_file[NUM_SOUNDS]; |
1 | 51 |
52 struct parse { | |
53 char option[256]; | |
54 char value[6][256]; | |
55 }; | |
56 | |
57 static struct parse *parse_line(char *line) | |
58 { | |
59 char *c = line; | |
60 int inopt = 1, inval = 0, curval = -1; | |
61 int optlen = 0, vallen = 0; | |
62 static struct parse p; | |
63 | |
64 | |
65 while(*c) { | |
66 if (*c == '\t') { | |
67 c++; | |
68 continue; | |
69 } | |
70 if (inopt) { | |
71 // if ((*c < 'a' || *c > 'z') && *c != '_') { | |
72 if ((*c < 'a' || *c > 'z') && *c != '_' && (*c < 'A' || *c > 'Z')) { | |
73 inopt = 0; | |
74 p.option[optlen] = 0; | |
75 c++; | |
76 continue; | |
77 } | |
78 | |
79 p.option[optlen] = *c; | |
80 optlen++; | |
81 c++; | |
82 continue; | |
83 } else if (inval) { | |
84 if ( (*c == '}') ) { | |
85 if (*(c-1) == '\\') { | |
86 p.value[curval][vallen - 1] = *c; | |
87 c++; | |
88 continue; | |
89 } else { | |
90 p.value[curval][vallen - 1] = 0; | |
91 inval = 0; | |
92 c++; | |
93 continue; | |
94 } | |
95 } else { | |
96 p.value[curval][vallen] = *c; | |
97 vallen++; | |
98 c++; | |
99 continue; } | |
100 } else if (*c == '{') { | |
101 if (*(c-1) == '\\') { | |
102 p.value[curval][vallen-1] = *c; | |
103 c++; | |
104 continue; | |
105 } | |
106 else | |
107 { | |
108 curval++; | |
109 vallen = 0; | |
110 inval = 1; | |
111 c++; | |
112 c++; | |
113 continue; | |
114 } | |
115 } | |
116 c++; | |
117 } | |
118 return &p; | |
119 } | |
120 | |
121 | |
122 static int gaimrc_parse_tag(FILE *f) | |
123 { | |
124 char buf[2048]; | |
125 char tag[256]; | |
126 buf[0] = '#'; | |
127 | |
128 while (buf[0] == '#' && !feof(f)) | |
129 fgets(buf, sizeof(buf), f); | |
130 | |
131 if (feof(f)) | |
132 return -1; | |
133 | |
134 sscanf(buf, "%s {", tag); | |
135 | |
136 if (!strcmp(tag, "users")) { | |
137 return 0; | |
138 } else if (!strcmp(tag, "options")) { | |
139 return 1; | |
140 } else if (!strcmp(tag, "away")) { | |
141 return 2; | |
142
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
142 } else if (!strcmp(tag, "plugins")) { |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
143 return 3; |
673 | 144 } else if (!strcmp(tag, "pounce")) { |
145 return 4; | |
774
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
146 } else if (!strcmp(tag, "chat")) { |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
147 return 5; |
1006
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
148 } else if (!strcmp(tag, "sound_files")) { |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
149 return 6; |
1 | 150 } |
151 | |
152 return -1; | |
153 } | |
154 | |
155 void filter_break(char *msg) | |
156 { | |
44 | 157 char *c; |
158 int mc; | |
159 int cc; | |
160 | |
161 c = g_malloc(strlen(msg)+1); | |
162 strcpy(c, msg); | |
1 | 163 |
44 | 164 mc = 0; |
165 cc = 0; | |
166 while (c[cc] != '\0') | |
167 { | |
168 if (c[cc] == '\\') { | |
169 cc++; | |
170 msg[mc] = c[cc]; | |
171 } | |
172 else { | |
173 msg[mc] = c[cc]; | |
174 } | |
175 mc++; | |
176 cc++; | |
177 } | |
178 msg[mc] = 0; | |
179 g_free(c); | |
1 | 180 } |
181 | |
44 | 182 |
1 | 183 static void gaimrc_read_away(FILE *f) |
184 { | |
185 struct parse *p; | |
186 char buf[4096]; | |
187 struct away_message *a; | |
188 | |
189 buf[0] = 0; | |
190 | |
191 while (buf[0] != '}') | |
192 { | |
193 if (!fgets(buf, sizeof(buf), f)) | |
194 return; | |
195 | |
196 if (buf[0] == '}') | |
197 return; | |
198 | |
199 p = parse_line(buf); | |
15 | 200 if (!strcmp(p->option, "message")) |
201 { | |
202 a = g_new0(struct away_message, 1); | |
1 | 203 |
15 | 204 g_snprintf(a->name, sizeof(a->name), "%s", p->value[0]); |
205 g_snprintf(a->message, sizeof(a->message), "%s", p->value[1]); | |
206 filter_break(a->message); | |
940 | 207 away_messages = g_slist_append(away_messages, a); |
15 | 208 } |
1 | 209 } |
210 } | |
211 | |
212 static void gaimrc_write_away(FILE *f) | |
213 { | |
940 | 214 GSList *awy = away_messages; |
1 | 215 struct away_message *a; |
216 | |
217 fprintf(f, "away {\n"); | |
218 | |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
219 if (awy) |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
220 { |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
221 while (awy) { |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
222 char *str1, *str2; |
26 | 223 |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
224 a = (struct away_message *)awy->data; |
26 | 225 |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
226 str1 = escape_text2(a->name); |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
227 str2 = escape_text2(a->message); |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
228 |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
229 fprintf(f, "\tmessage { %s } { %s }\n", str1, str2); |
26 | 230 |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
231 /* escape_text2 uses malloc(), so we don't want to g_free these */ |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
232 free(str1); |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
233 free(str2); |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
234 |
940 | 235 awy = g_slist_next(awy); |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
236 } |
1 | 237 } |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
238 else |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
239 fprintf(f, "\tmessage { boring default } { %s }\n", BORING_DEFAULT_AWAY_MSG); |
1 | 240 |
241 fprintf(f, "}\n"); | |
242 } | |
243 | |
673 | 244 static void gaimrc_read_pounce(FILE *f) |
245 { | |
246 struct parse *p; | |
247 char buf[4096]; | |
248 struct buddy_pounce *b; | |
249 | |
250 buf[0] = 0; | |
251 | |
252 while (buf[0] != '}') | |
253 { | |
254 if (!fgets(buf, sizeof(buf), f)) | |
255 return; | |
256 | |
257 if (buf[0] == '}') | |
258 return; | |
259 | |
260 p = parse_line(buf); | |
261 if (!strcmp(p->option, "entry")) | |
262 { | |
263 b = g_new0(struct buddy_pounce, 1); | |
264 | |
265 g_snprintf(b->name, sizeof(b->name), "%s", p->value[0]); | |
266 g_snprintf(b->message, sizeof(b->message), "%s", p->value[1]); | |
267 | |
268 b->popup = atoi(p->value[2]); | |
269 b->sendim = atoi(p->value[3]); | |
270 | |
271 filter_break(b->message); | |
272 buddy_pounces = g_list_append(buddy_pounces, b); | |
273 } | |
274 } | |
275 } | |
276 | |
277 static void gaimrc_write_pounce(FILE *f) | |
278 { | |
279 GList *pnc = buddy_pounces; | |
280 struct buddy_pounce *b; | |
281 | |
282 fprintf(f, "pounce {\n"); | |
283 | |
284 if (pnc) | |
285 { | |
286 while (pnc) { | |
287 char *str1, *str2; | |
288 int popup, sendim; | |
289 | |
290 b = (struct buddy_pounce *)pnc->data; | |
291 | |
292 str1 = escape_text2(b->name); | |
690
16831576f242
[gaim-migrate @ 700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
673
diff
changeset
|
293 if (strlen(b->message)) |
16831576f242
[gaim-migrate @ 700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
673
diff
changeset
|
294 str2 = escape_text2(b->message); |
16831576f242
[gaim-migrate @ 700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
673
diff
changeset
|
295 else { |
16831576f242
[gaim-migrate @ 700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
673
diff
changeset
|
296 str2 = malloc(1); |
16831576f242
[gaim-migrate @ 700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
673
diff
changeset
|
297 str2[0] = 0; |
16831576f242
[gaim-migrate @ 700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
673
diff
changeset
|
298 } |
673 | 299 popup = b->popup; |
300 sendim = b->sendim; | |
301 | |
302 fprintf(f, "\tentry { %s } { %s } { %d } { %d }\n", str1, str2, popup, sendim); | |
303 | |
304 /* escape_text2 uses malloc(), so we don't want to g_free these */ | |
305 free(str1); | |
306 free(str2); | |
307 | |
308 pnc = pnc->next; | |
309 } | |
310 } | |
311 | |
312 fprintf(f, "}\n"); | |
313 } | |
314 | |
774
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
315 static void gaimrc_read_chat(FILE *f) |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
316 { |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
317 struct parse *p; |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
318 char buf[4096]; |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
319 struct chat_room *b; |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
320 |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
321 buf[0] = 0; |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
322 |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
323 while (buf[0] != '}') |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
324 { |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
325 if (!fgets(buf, sizeof(buf), f)) |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
326 return; |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
327 |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
328 if (buf[0] == '}') |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
329 return; |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
330 |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
331 p = parse_line(buf); |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
332 if (!strcmp(p->option, "entry")) |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
333 { |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
334 b = g_new0(struct chat_room, 1); |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
335 |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
336 g_snprintf(b->name, sizeof(b->name), "%s", p->value[0]); |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
337 |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
338 b->exchange = atoi(p->value[1]); |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
339 |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
340 chat_rooms = g_list_append(chat_rooms, b); |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
341 } |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
342 } |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
343 } |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
344 |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
345 static void gaimrc_write_chat(FILE *f) |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
346 { |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
347 GList *pnc = chat_rooms; |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
348 struct chat_room *b; |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
349 |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
350 fprintf(f, "chat {\n"); |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
351 |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
352 if (pnc) |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
353 { |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
354 while (pnc) { |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
355 char *str1; |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
356 |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
357 b = (struct chat_room *)pnc->data; |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
358 |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
359 str1 = escape_text2(b->name); |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
360 |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
361 fprintf(f, "\tentry { %s } { %d }\n", str1, b->exchange); |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
362 |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
363 /* escape_text2 uses malloc(), so we don't want to g_free these */ |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
364 free(str1); |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
365 |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
366 pnc = pnc->next; |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
367 } |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
368 } |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
369 |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
370 fprintf(f, "}\n"); |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
371 } |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
372 |
142
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
373 #ifdef GAIM_PLUGINS |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
374 static void gaimrc_write_plugins(FILE *f) |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
375 { |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
376 GList *pl = plugins; |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
377 struct gaim_plugin *p; |
1 | 378 |
142
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
379 fprintf(f, "plugins {\n"); |
1 | 380 |
142
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
381 while (pl) { |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
382 char *path; |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
383 |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
384 p = (struct gaim_plugin *)pl->data; |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
385 |
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1026
diff
changeset
|
386 path = escape_text2(g_module_name(p->handle)); |
142
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
387 |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
388 fprintf(f, "\tplugin { %s }\n", path); |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
389 |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
390 free(path); |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
391 |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
392 pl = pl->next; |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
393 } |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
394 |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
395 fprintf(f, "}\n"); |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
396 } |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
397 |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
398 static void gaimrc_read_plugins(FILE *f) |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
399 { |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
400 struct parse *p; |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
401 char buf[4096]; |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
402 |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
403 buf[0] = 0; |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
404 |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
405 while (buf[0] != '}') |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
406 { |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
407 if (!fgets(buf, sizeof(buf), f)) |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
408 return; |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
409 |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
410 if (buf[0] == '}') |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
411 return; |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
412 |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
413 p = parse_line(buf); |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
414 if (!strcmp(p->option, "plugin")) |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
415 { |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
416 load_plugin(p->value[0]); |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
417 } |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
418 } |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
419 } |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
420 #endif /* GAIM_PLUGINS */ |
1 | 421 |
422 static struct aim_user *gaimrc_read_user(FILE *f) | |
423 { | |
424 struct parse *p; | |
425 struct aim_user *u; | |
1051
713b0e14e0a9
[gaim-migrate @ 1061]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1047
diff
changeset
|
426 int i; |
1 | 427 char buf[4096]; |
428 | |
429 if (!fgets(buf, sizeof(buf), f)) | |
430 return NULL; | |
431 | |
432 p = parse_line(buf); | |
433 | |
434 if (strcmp(p->option, "ident")) | |
435 return NULL; | |
436 | |
437 u = g_new0(struct aim_user, 1); | |
438 | |
439 strcpy(u->username, p->value[0]); | |
440 strcpy(u->password, p->value[1]); | |
441 | |
442 u->user_info[0] = 0; | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
443 u->options = OPT_USR_REM_PASS; |
1002
1d8f05ea6bdf
[gaim-migrate @ 1012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
960
diff
changeset
|
444 u->protocol = 0; /* PROTO_TOC */ |
1 | 445 |
446 if (!fgets(buf, sizeof(buf), f)) | |
447 return u; | |
448 | |
449 if (strcmp(buf, "\t\tuser_info {\n")) { | |
450 return u; | |
451 } | |
452 | |
453 if (!fgets(buf, sizeof(buf), f)) | |
454 return u; | |
455 | |
456 while (strncmp(buf, "\t\t}", 3)) { | |
457 if (strlen(buf) > 3) | |
458 strcat(u->user_info, &buf[3]); | |
459 | |
460 if (!fgets(buf, sizeof(buf), f)) { | |
461 return u; | |
462 } | |
463 } | |
464 | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
465 if (!fgets(buf, sizeof(buf), f)) { |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
466 return u; |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
467 } |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
468 |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
469 if (!strcmp(buf, "\t}")) { |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
470 return u; |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
471 } |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
472 |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
473 p = parse_line(buf); |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
474 |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
475 if (strcmp(p->option, "user_opts")) |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
476 return u; |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
477 |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
478 u->options = atoi(p->value[0]); |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
479 u->protocol = atoi(p->value[1]); |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
480 |
1051
713b0e14e0a9
[gaim-migrate @ 1061]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1047
diff
changeset
|
481 if (!fgets(buf, sizeof(buf), f)) |
713b0e14e0a9
[gaim-migrate @ 1061]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1047
diff
changeset
|
482 return u; |
713b0e14e0a9
[gaim-migrate @ 1061]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1047
diff
changeset
|
483 |
713b0e14e0a9
[gaim-migrate @ 1061]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1047
diff
changeset
|
484 if (!strcmp(buf, "\t}")) |
713b0e14e0a9
[gaim-migrate @ 1061]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1047
diff
changeset
|
485 return u; |
713b0e14e0a9
[gaim-migrate @ 1061]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1047
diff
changeset
|
486 |
713b0e14e0a9
[gaim-migrate @ 1061]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1047
diff
changeset
|
487 p = parse_line(buf); |
713b0e14e0a9
[gaim-migrate @ 1061]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1047
diff
changeset
|
488 |
713b0e14e0a9
[gaim-migrate @ 1061]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1047
diff
changeset
|
489 if (strcmp(p->option, "proto_opts")) |
713b0e14e0a9
[gaim-migrate @ 1061]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1047
diff
changeset
|
490 return u; |
713b0e14e0a9
[gaim-migrate @ 1061]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1047
diff
changeset
|
491 |
713b0e14e0a9
[gaim-migrate @ 1061]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1047
diff
changeset
|
492 for (i = 0; i < 6; i++) |
713b0e14e0a9
[gaim-migrate @ 1061]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1047
diff
changeset
|
493 g_snprintf(u->proto_opt[i], sizeof u->proto_opt[i], "%s", p->value[i]); |
713b0e14e0a9
[gaim-migrate @ 1061]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1047
diff
changeset
|
494 |
1 | 495 return u; |
496 | |
497 } | |
498 | |
499 static void gaimrc_write_user(FILE *f, struct aim_user *u) | |
500 { | |
501 char *c; | |
1051
713b0e14e0a9
[gaim-migrate @ 1061]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1047
diff
changeset
|
502 int nl = 1, i; |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
503 if (u->options & OPT_USR_REM_PASS) |
131
350d88f043b6
[gaim-migrate @ 141]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
84
diff
changeset
|
504 fprintf(f, "\t\tident { %s } { %s }\n", u->username, u->password); |
350d88f043b6
[gaim-migrate @ 141]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
84
diff
changeset
|
505 else |
350d88f043b6
[gaim-migrate @ 141]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
84
diff
changeset
|
506 fprintf(f, "\t\tident { %s } { }\n", u->username); |
1 | 507 fprintf(f, "\t\tuser_info {"); |
508 c = u->user_info; | |
509 while(*c) { | |
510 /* This is not as silly as it looks. */ | |
511 if (*c == '\n') { | |
512 nl++; | |
513 } else { | |
514 if (nl) { | |
515 while(nl) { | |
516 fprintf(f, "\n\t\t\t"); | |
517 nl--; | |
518 } | |
519 } | |
520 fprintf(f, "%c", *c); | |
521 } | |
522 c++; | |
523 } | |
524 fprintf(f, "\n\t\t}\n"); | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
525 fprintf(f, "\t\tuser_opts { %d } { %d }\n", u->options, u->protocol); |
1051
713b0e14e0a9
[gaim-migrate @ 1061]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1047
diff
changeset
|
526 fprintf(f, "\t\tproto_opts"); |
713b0e14e0a9
[gaim-migrate @ 1061]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1047
diff
changeset
|
527 for (i = 0; i < 6; i++) |
713b0e14e0a9
[gaim-migrate @ 1061]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1047
diff
changeset
|
528 fprintf(f, " { %s }", u->proto_opt[i]); |
713b0e14e0a9
[gaim-migrate @ 1061]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1047
diff
changeset
|
529 fprintf(f, "\n"); |
1 | 530 } |
531 | |
532 | |
533 static void gaimrc_read_users(FILE *f) | |
534 { | |
535 char buf[2048]; | |
536 struct aim_user *u; | |
537 struct parse *p; | |
538 | |
539 buf[0] = 0; | |
540 | |
541 while (buf[0] != '}') { | |
542 if (buf[0] == '#') | |
543 continue; | |
544 | |
545 if (!fgets(buf, sizeof(buf), f)) | |
546 return; | |
547 | |
548 | |
549 | |
550 p = parse_line(buf); | |
551 | |
552 if (!strcmp(p->option, "current_user")) { | |
553 } else if (strcmp(p->option, "user")) { | |
554 continue; | |
159
d56878f647fb
[gaim-migrate @ 169]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
158
diff
changeset
|
555 } else { |
d56878f647fb
[gaim-migrate @ 169]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
158
diff
changeset
|
556 } |
1 | 557 |
558 u = gaimrc_read_user(f); | |
559 | |
560 aim_users = g_list_append(aim_users, u); | |
561 } | |
562 } | |
563 | |
564 static void gaimrc_write_users(FILE *f) | |
565 { | |
566 GList *usr = aim_users; | |
567 struct aim_user *u; | |
568 | |
569 fprintf(f, "users {\n"); | |
570 | |
571 while(usr) { | |
572 u = (struct aim_user *)usr->data; | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
573 fprintf(f, "\tuser {\n"); |
1 | 574 gaimrc_write_user(f, u); |
575 | |
576 fprintf(f, "\t}\n"); | |
577 | |
578 usr = usr->next; | |
579 } | |
580 | |
581 fprintf(f, "}\n"); | |
582 } | |
583 | |
584 | |
585 | |
586 | |
587 static void gaimrc_read_options(FILE *f) | |
588 { | |
589 char buf[2048]; | |
590 struct parse *p; | |
591 | |
592 buf[0] = 0; | |
593 | |
594 while (buf[0] != '}') { | |
595 if (buf[0] == '#') | |
596 continue; | |
597 | |
598 if (!fgets(buf, sizeof(buf), f)) | |
599 return; | |
600 | |
601 p = parse_line(buf); | |
602 | |
603 if (!strcmp(p->option, "general_options")) { | |
604 general_options = atoi(p->value[0]); | |
605 } else if (!strcmp(p->option, "display_options")) { | |
606 display_options = atoi(p->value[0]); | |
607 } else if (!strcmp(p->option, "sound_options")) { | |
608 sound_options = atoi(p->value[0]); | |
666
71ea550c22ac
[gaim-migrate @ 676]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
570
diff
changeset
|
609 } else if (!strcmp(p->option, "font_options")) { |
71ea550c22ac
[gaim-migrate @ 676]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
570
diff
changeset
|
610 font_options = atoi(p->value[0]); |
71ea550c22ac
[gaim-migrate @ 676]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
570
diff
changeset
|
611 } else if (!strcmp(p->option, "font_face")) { |
71ea550c22ac
[gaim-migrate @ 676]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
570
diff
changeset
|
612 if (p->value[0] != NULL) |
71ea550c22ac
[gaim-migrate @ 676]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
570
diff
changeset
|
613 g_snprintf(fontface, sizeof(fontface), "%s", p->value[0]); |
71ea550c22ac
[gaim-migrate @ 676]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
570
diff
changeset
|
614 } else if (!strcmp(p->option, "foreground")) { |
697 | 615 fgcolor.red = atoi(p->value[0]); |
616 fgcolor.green = atoi(p->value[1]); | |
617 fgcolor.blue = atoi(p->value[2]); | |
666
71ea550c22ac
[gaim-migrate @ 676]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
570
diff
changeset
|
618 } else if (!strcmp(p->option, "background")) { |
697 | 619 bgcolor.red = atoi(p->value[0]); |
620 bgcolor.green = atoi(p->value[1]); | |
621 bgcolor.blue = atoi(p->value[2]); | |
1 | 622 } else if (!strcmp(p->option, "report_idle")) { |
623 report_idle = atoi(p->value[0]); | |
624 } else if (!strcmp(p->option, "web_browser")) { | |
625 web_browser = atoi(p->value[0]); | |
626 } else if (!strcmp(p->option, "web_command")) { | |
627 strcpy(web_command, p->value[0]); | |
628 } else if (!strcmp(p->option, "blist_pos")) { | |
629 blist_pos.x = atoi(p->value[0]); | |
630 blist_pos.y = atoi(p->value[1]); | |
631 blist_pos.width = atoi(p->value[2]); | |
632 blist_pos.height = atoi(p->value[3]); | |
633 blist_pos.xoff = atoi(p->value[4]); | |
634 blist_pos.yoff = atoi(p->value[5]); | |
82 | 635 } |
1 | 636 |
637 } | |
638 | |
639 } | |
640 | |
641 static void gaimrc_write_options(FILE *f) | |
642 { | |
643 | |
644 fprintf(f, "options {\n"); | |
645 fprintf(f, "\tgeneral_options { %d }\n", general_options); | |
646 fprintf(f, "\tdisplay_options { %d }\n", display_options); | |
647 fprintf(f, "\tsound_options { %d }\n", sound_options); | |
666
71ea550c22ac
[gaim-migrate @ 676]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
570
diff
changeset
|
648 fprintf(f, "\tfont_options { %d }\n", font_options); |
232 | 649 if (fontface) |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
650 fprintf(f, "\tfont_face { %s }\n", fontface); |
697 | 651 fprintf(f, "\tforeground { %d } { %d } { %d }\n", fgcolor.red, fgcolor.green, fgcolor.blue); |
652 fprintf(f, "\tbackground { %d } { %d } { %d }\n", bgcolor.red, bgcolor.green, bgcolor.blue); | |
1 | 653 fprintf(f, "\treport_idle { %d }\n", report_idle); |
654 fprintf(f, "\tweb_browser { %d }\n", web_browser); | |
655 fprintf(f, "\tweb_command { %s }\n", web_command); | |
656 fprintf(f, "\tblist_pos { %d } { %d } { %d } { %d } { %d } { %d }\n", | |
657 blist_pos.x, blist_pos.y, blist_pos.width, blist_pos.height, | |
658 blist_pos.xoff, blist_pos.yoff); | |
180 | 659 fprintf(f, "\tlatest_ver { %s }\n", latest_ver); |
1 | 660 fprintf(f, "}\n"); |
661 } | |
662 | |
663 | |
1006
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
664 static void gaimrc_read_sounds(FILE *f) |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
665 { |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
666 int i; |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
667 char buf[2048]; |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
668 struct parse *p; |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
669 |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
670 buf[0] = 0; |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
671 |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
672 for (i = 0; i < NUM_SOUNDS; i++) |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
673 sound_file[i] = NULL; |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
674 |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
675 while (buf[0] != '}') { |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
676 if (buf[0] == '#') |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
677 continue; |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
678 |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
679 if (!fgets(buf, sizeof(buf), f)) |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
680 return; |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
681 |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
682 p = parse_line(buf); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
683 |
1057
d50d3abb9eb7
[gaim-migrate @ 1067]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1051
diff
changeset
|
684 sscanf(p->option, "sound%c", (char *)&i); |
1006
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
685 i -= 'A'; |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
686 |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
687 if (p->value[0][0]) |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
688 sound_file[i] = g_strdup(p->value[0]); |
1010 | 689 /* else |
1006
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
690 sound_file[i] = NULL; |
1010 | 691 Removed by Rob. Kill me if this is retarded. |
692 Tis was causing segfaults on PPC machines, though. | |
693 */ | |
1006
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
694 } |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
695 } |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
696 |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
697 static void gaimrc_write_sounds(FILE *f) |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
698 { |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
699 int i; |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
700 fprintf(f, "sound_files {\n"); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
701 for (i = 0; i < NUM_SOUNDS; i++) |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
702 if (sound_file[i]) |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
703 fprintf(f, "\tsound%c { %s }\n", i + 'A', sound_file[i]); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
704 else |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
705 fprintf(f, "\tsound%c { }\n", i + 'A'); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
706 fprintf(f, "}\n"); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
707 } |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
708 |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
709 |
917 | 710 void set_defaults(int saveinfo) |
1 | 711 { |
917 | 712 if (!saveinfo) |
713 { | |
714 if (aim_users) | |
715 { | |
716 g_list_free(aim_users); | |
717 aim_users = NULL; | |
718 } | |
719 if (away_messages) | |
720 { | |
940 | 721 g_slist_free(away_messages); |
917 | 722 away_messages = NULL; |
723 } | |
724 } | |
725 | |
1 | 726 general_options = |
727 OPT_GEN_SEND_LINKS | | |
728 OPT_GEN_ENTER_SENDS | | |
729 OPT_GEN_SAVED_WINDOWS | | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
730 /* OPT_GEN_REMEMBER_PASS | */ |
340
0d9cfc3579a5
[gaim-migrate @ 350]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
731 OPT_GEN_REGISTERED | |
870 | 732 OPT_GEN_NEAR_APPLET | |
733 OPT_GEN_CTL_SMILEYS | | |
734 OPT_GEN_CTL_CHARS; | |
735 | |
1 | 736 display_options = |
737 OPT_DISP_SHOW_IDLETIME | | |
738 OPT_DISP_SHOW_TIME | | |
739 OPT_DISP_SHOW_PIXMAPS | | |
453 | 740 OPT_DISP_SHOW_BUDDYTICKER | |
870 | 741 OPT_DISP_SHOW_BUTTON_XPM | |
742 OPT_DISP_SHOW_SMILEY | | |
743 OPT_DISP_COOL_LOOK | | |
744 OPT_DISP_CONV_BIG_ENTRY | | |
915
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
870
diff
changeset
|
745 OPT_DISP_CHAT_BIG_ENTRY | |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
870
diff
changeset
|
746 OPT_DISP_CONV_BUTTON_XPM | |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
870
diff
changeset
|
747 OPT_DISP_CONV_BUTTON_TEXT | |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
870
diff
changeset
|
748 OPT_DISP_CHAT_BUTTON_XPM | |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
870
diff
changeset
|
749 OPT_DISP_CHAT_BUTTON_TEXT; |
870 | 750 |
917 | 751 if (!saveinfo) |
752 { | |
1006
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
753 int i; |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
754 for (i = 0; i < 7; i++) |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
755 sound_file[i] = NULL; |
917 | 756 font_options = 0; |
757 sound_options = OPT_SOUND_LOGIN | OPT_SOUND_LOGOUT | OPT_SOUND_RECV | OPT_SOUND_SEND | OPT_SOUND_SILENT_SIGNON; | |
1026 | 758 report_idle = IDLE_SCREENSAVER; |
917 | 759 web_browser = BROWSER_NETSCAPE; |
1 | 760 |
917 | 761 g_snprintf(web_command, sizeof(web_command), "xterm -e lynx %%s"); |
762 blist_pos.width = 0; | |
763 blist_pos.height = 0; | |
764 blist_pos.x = 0; | |
765 blist_pos.y = 0; | |
766 blist_pos.xoff = 0; | |
767 blist_pos.yoff = 0; | |
768 g_snprintf(latest_ver, BUF_LONG, "%s", VERSION); | |
769 } | |
1 | 770 } |
771 | |
772 | |
773 void load_prefs() | |
774 { | |
775 FILE *f; | |
776 char buf[1024]; | |
777 int ver = 0; | |
570 | 778 |
1 | 779 if (getenv("HOME")) { |
780 g_snprintf(buf, sizeof(buf), "%s/.gaimrc", getenv("HOME")); | |
781 if ((f = fopen(buf,"r"))) { | |
782 fgets(buf, sizeof(buf), f); | |
783 sscanf(buf, "# .gaimrc v%d", &ver); | |
15 | 784 if ( (ver <= 1) || (buf[0] != '#')) { |
1 | 785 fclose(f); |
917 | 786 set_defaults(FALSE); |
1 | 787 save_prefs(); |
788 load_prefs(); | |
789 return; | |
790 } | |
917 | 791 |
1 | 792 while(!feof(f)) { |
793 switch(gaimrc_parse_tag(f)) { | |
794 case -1: | |
795 /* Let the loop end, EOF*/ | |
796 break; | |
797 case 0: | |
798 gaimrc_read_users(f); | |
799 break; | |
800 case 1: | |
801 gaimrc_read_options(f); | |
802 break; | |
803 case 2: | |
804 gaimrc_read_away(f); | |
805 break; | |
142
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
806 #ifdef GAIM_PLUGINS |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
807 case 3: |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
808 gaimrc_read_plugins(f); |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
809 break; |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
810 #endif |
673 | 811 case 4: |
812 gaimrc_read_pounce(f); | |
813 break; | |
774
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
814 case 5: |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
815 gaimrc_read_chat(f); |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
816 break; |
1006
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
817 case 6: |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
818 gaimrc_read_sounds(f); |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
819 break; |
1 | 820 default: |
821 /* NOOP */ | |
822 break; | |
823 } | |
824 } | |
825 fclose(f); | |
826 } | |
827 } | |
917 | 828 |
829 if ( (ver == 2) || (buf[0] != '#')) { | |
830 set_defaults(TRUE); | |
831 } | |
1 | 832 |
833 } | |
834 | |
835 void save_prefs() | |
836 { | |
837 FILE *f; | |
838 char buf[BUF_LONG]; | |
839 | |
840 if (getenv("HOME")) { | |
841 g_snprintf(buf, sizeof(buf), "%s/.gaimrc", getenv("HOME")); | |
842 if ((f = fopen(buf,"w"))) { | |
917 | 843 fprintf(f, "# .gaimrc v%d\n", 3); |
1 | 844 gaimrc_write_users(f); |
673 | 845 gaimrc_write_options(f); |
1006
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
846 gaimrc_write_sounds(f); |
673 | 847 gaimrc_write_away(f); |
142
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
848 #ifdef GAIM_PLUGINS |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
849 gaimrc_write_plugins(f); |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
850 #endif |
673 | 851 gaimrc_write_pounce(f); |
774
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
852 gaimrc_write_chat(f); |
673 | 853 fclose(f); |
854 chmod(buf, S_IRUSR | S_IWUSR); | |
855 } | |
1 | 856 } |
857 } | |
858 |