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