Mercurial > pidgin
annotate src/gaimrc.c @ 921:d2e865d64dd8
[gaim-migrate @ 931]
bah. maybe i'll get this working for the next release, but i don't think it's possible to get it working.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sat, 16 Sep 2000 00:54:29 +0000 |
parents | f3c23b3c1ed7 |
children | 9fca1293f871 |
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 struct aim_user *current_user = NULL; | |
42 GList *aim_users = NULL; | |
43 int general_options; | |
44 int display_options; | |
45 int sound_options; | |
46 int font_options; | |
47 | |
48 int report_idle, web_browser; | |
49 struct save_pos blist_pos; | |
50 char web_command[2048]; | |
51 char aim_host[512]; | |
52 int aim_port; | |
53 char login_host[512]; | |
54 int login_port; | |
180 | 55 char latest_ver[25]; |
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; |
1 | 153 } |
154 | |
155 return -1; | |
156 } | |
157 | |
158 void filter_break(char *msg) | |
159 { | |
44 | 160 char *c; |
161 int mc; | |
162 int cc; | |
163 | |
164 c = g_malloc(strlen(msg)+1); | |
165 strcpy(c, msg); | |
1 | 166 |
44 | 167 mc = 0; |
168 cc = 0; | |
169 while (c[cc] != '\0') | |
170 { | |
171 if (c[cc] == '\\') { | |
172 cc++; | |
173 msg[mc] = c[cc]; | |
174 } | |
175 else { | |
176 msg[mc] = c[cc]; | |
177 } | |
178 mc++; | |
179 cc++; | |
180 } | |
181 msg[mc] = 0; | |
182 g_free(c); | |
1 | 183 } |
184 | |
44 | 185 |
1 | 186 static void gaimrc_read_away(FILE *f) |
187 { | |
188 struct parse *p; | |
189 char buf[4096]; | |
190 struct away_message *a; | |
191 | |
192 buf[0] = 0; | |
193 | |
194 while (buf[0] != '}') | |
195 { | |
196 if (!fgets(buf, sizeof(buf), f)) | |
197 return; | |
198 | |
199 if (buf[0] == '}') | |
200 return; | |
201 | |
202 p = parse_line(buf); | |
15 | 203 if (!strcmp(p->option, "message")) |
204 { | |
205 a = g_new0(struct away_message, 1); | |
1 | 206 |
15 | 207 g_snprintf(a->name, sizeof(a->name), "%s", p->value[0]); |
208 g_snprintf(a->message, sizeof(a->message), "%s", p->value[1]); | |
209 filter_break(a->message); | |
210 away_messages = g_list_append(away_messages, a); | |
211 } | |
1 | 212 } |
213 } | |
214 | |
215 static void gaimrc_write_away(FILE *f) | |
216 { | |
217 GList *awy = away_messages; | |
218 struct away_message *a; | |
219 | |
220 fprintf(f, "away {\n"); | |
221 | |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
222 if (awy) |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
223 { |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
224 while (awy) { |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
225 char *str1, *str2; |
26 | 226 |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
227 a = (struct away_message *)awy->data; |
26 | 228 |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
229 str1 = escape_text2(a->name); |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
230 str2 = escape_text2(a->message); |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
231 |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
232 fprintf(f, "\tmessage { %s } { %s }\n", str1, str2); |
26 | 233 |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
234 /* 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
|
235 free(str1); |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
236 free(str2); |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
237 |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
238 awy = awy->next; |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
239 } |
1 | 240 } |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
241 else |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
242 fprintf(f, "\tmessage { boring default } { %s }\n", BORING_DEFAULT_AWAY_MSG); |
1 | 243 |
244 fprintf(f, "}\n"); | |
245 } | |
246 | |
673 | 247 static void gaimrc_read_pounce(FILE *f) |
248 { | |
249 struct parse *p; | |
250 char buf[4096]; | |
251 struct buddy_pounce *b; | |
252 | |
253 buf[0] = 0; | |
254 | |
255 while (buf[0] != '}') | |
256 { | |
257 if (!fgets(buf, sizeof(buf), f)) | |
258 return; | |
259 | |
260 if (buf[0] == '}') | |
261 return; | |
262 | |
263 p = parse_line(buf); | |
264 if (!strcmp(p->option, "entry")) | |
265 { | |
266 b = g_new0(struct buddy_pounce, 1); | |
267 | |
268 g_snprintf(b->name, sizeof(b->name), "%s", p->value[0]); | |
269 g_snprintf(b->message, sizeof(b->message), "%s", p->value[1]); | |
270 | |
271 b->popup = atoi(p->value[2]); | |
272 b->sendim = atoi(p->value[3]); | |
273 | |
274 filter_break(b->message); | |
275 buddy_pounces = g_list_append(buddy_pounces, b); | |
276 } | |
277 } | |
278 } | |
279 | |
280 static void gaimrc_write_pounce(FILE *f) | |
281 { | |
282 GList *pnc = buddy_pounces; | |
283 struct buddy_pounce *b; | |
284 | |
285 fprintf(f, "pounce {\n"); | |
286 | |
287 if (pnc) | |
288 { | |
289 while (pnc) { | |
290 char *str1, *str2; | |
291 int popup, sendim; | |
292 | |
293 b = (struct buddy_pounce *)pnc->data; | |
294 | |
295 str1 = escape_text2(b->name); | |
690
16831576f242
[gaim-migrate @ 700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
673
diff
changeset
|
296 if (strlen(b->message)) |
16831576f242
[gaim-migrate @ 700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
673
diff
changeset
|
297 str2 = escape_text2(b->message); |
16831576f242
[gaim-migrate @ 700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
673
diff
changeset
|
298 else { |
16831576f242
[gaim-migrate @ 700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
673
diff
changeset
|
299 str2 = malloc(1); |
16831576f242
[gaim-migrate @ 700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
673
diff
changeset
|
300 str2[0] = 0; |
16831576f242
[gaim-migrate @ 700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
673
diff
changeset
|
301 } |
673 | 302 popup = b->popup; |
303 sendim = b->sendim; | |
304 | |
305 fprintf(f, "\tentry { %s } { %s } { %d } { %d }\n", str1, str2, popup, sendim); | |
306 | |
307 /* escape_text2 uses malloc(), so we don't want to g_free these */ | |
308 free(str1); | |
309 free(str2); | |
310 | |
311 pnc = pnc->next; | |
312 } | |
313 } | |
314 | |
315 fprintf(f, "}\n"); | |
316 } | |
317 | |
774
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
318 static void gaimrc_read_chat(FILE *f) |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
319 { |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
320 struct parse *p; |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
321 char buf[4096]; |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
322 struct chat_room *b; |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
323 |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
324 buf[0] = 0; |
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 while (buf[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 if (!fgets(buf, sizeof(buf), f)) |
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 if (buf[0] == '}') |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
332 return; |
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 p = parse_line(buf); |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
335 if (!strcmp(p->option, "entry")) |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
336 { |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
337 b = g_new0(struct chat_room, 1); |
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 g_snprintf(b->name, sizeof(b->name), "%s", p->value[0]); |
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 b->exchange = atoi(p->value[1]); |
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 chat_rooms = g_list_append(chat_rooms, b); |
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 } |
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 static void gaimrc_write_chat(FILE *f) |
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 GList *pnc = chat_rooms; |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
351 struct chat_room *b; |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
352 |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
353 fprintf(f, "chat {\n"); |
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 if (pnc) |
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 while (pnc) { |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
358 char *str1; |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
359 |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
360 b = (struct chat_room *)pnc->data; |
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 str1 = escape_text2(b->name); |
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 fprintf(f, "\tentry { %s } { %d }\n", str1, b->exchange); |
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 /* 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
|
367 free(str1); |
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 pnc = pnc->next; |
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 } |
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 fprintf(f, "}\n"); |
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 |
142
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
376 #ifdef GAIM_PLUGINS |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
377 static void gaimrc_write_plugins(FILE *f) |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
378 { |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
379 GList *pl = plugins; |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
380 struct gaim_plugin *p; |
1 | 381 |
142
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
382 fprintf(f, "plugins {\n"); |
1 | 383 |
142
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
384 while (pl) { |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
385 char *path; |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
386 |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
387 p = (struct gaim_plugin *)pl->data; |
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 path = escape_text2(p->filename); |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
390 |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
391 fprintf(f, "\tplugin { %s }\n", path); |
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 free(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 pl = pl->next; |
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 fprintf(f, "}\n"); |
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 |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
401 static void gaimrc_read_plugins(FILE *f) |
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 struct parse *p; |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
404 char buf[4096]; |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
405 |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
406 buf[0] = 0; |
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 while (buf[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 if (!fgets(buf, sizeof(buf), f)) |
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 if (buf[0] == '}') |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
414 return; |
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 p = parse_line(buf); |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
417 if (!strcmp(p->option, "plugin")) |
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 load_plugin(p->value[0]); |
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 } |
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 #endif /* GAIM_PLUGINS */ |
1 | 424 |
425 static struct aim_user *gaimrc_read_user(FILE *f) | |
426 { | |
427 struct parse *p; | |
428 struct aim_user *u; | |
429 char buf[4096]; | |
430 | |
431 if (!fgets(buf, sizeof(buf), f)) | |
432 return NULL; | |
433 | |
434 p = parse_line(buf); | |
435 | |
436 if (strcmp(p->option, "ident")) | |
437 return NULL; | |
438 | |
439 u = g_new0(struct aim_user, 1); | |
440 | |
441 strcpy(u->username, p->value[0]); | |
442 strcpy(u->password, p->value[1]); | |
443 | |
444 u->user_info[0] = 0; | |
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 | |
465 return u; | |
466 | |
467 } | |
468 | |
469 static void gaimrc_write_user(FILE *f, struct aim_user *u) | |
470 { | |
471 char *c; | |
472 int nl = 1;; | |
131
350d88f043b6
[gaim-migrate @ 141]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
84
diff
changeset
|
473 if (general_options & OPT_GEN_REMEMBER_PASS) |
350d88f043b6
[gaim-migrate @ 141]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
84
diff
changeset
|
474 fprintf(f, "\t\tident { %s } { %s }\n", u->username, u->password); |
350d88f043b6
[gaim-migrate @ 141]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
84
diff
changeset
|
475 else |
350d88f043b6
[gaim-migrate @ 141]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
84
diff
changeset
|
476 fprintf(f, "\t\tident { %s } { }\n", u->username); |
1 | 477 fprintf(f, "\t\tuser_info {"); |
478 c = u->user_info; | |
479 while(*c) { | |
480 /* This is not as silly as it looks. */ | |
481 if (*c == '\n') { | |
482 nl++; | |
483 } else { | |
484 if (nl) { | |
485 while(nl) { | |
486 fprintf(f, "\n\t\t\t"); | |
487 nl--; | |
488 } | |
489 } | |
490 fprintf(f, "%c", *c); | |
491 } | |
492 c++; | |
493 } | |
494 fprintf(f, "\n\t\t}\n"); | |
495 | |
496 } | |
497 | |
498 | |
499 static void gaimrc_read_users(FILE *f) | |
500 { | |
501 char buf[2048]; | |
502 struct aim_user *u; | |
503 struct parse *p; | |
504 int cur = 0; | |
505 | |
506 buf[0] = 0; | |
507 | |
508 while (buf[0] != '}') { | |
509 if (buf[0] == '#') | |
510 continue; | |
511 | |
512 if (!fgets(buf, sizeof(buf), f)) | |
513 return; | |
514 | |
515 | |
516 | |
517 p = parse_line(buf); | |
518 | |
519 if (!strcmp(p->option, "current_user")) { | |
158
e9414f13d8b7
[gaim-migrate @ 168]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
156
diff
changeset
|
520 cur = 1; |
1 | 521 } else if (strcmp(p->option, "user")) { |
158
e9414f13d8b7
[gaim-migrate @ 168]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
156
diff
changeset
|
522 cur = 0; |
1 | 523 continue; |
159
d56878f647fb
[gaim-migrate @ 169]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
158
diff
changeset
|
524 } else { |
d56878f647fb
[gaim-migrate @ 169]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
158
diff
changeset
|
525 cur = 0; |
d56878f647fb
[gaim-migrate @ 169]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
158
diff
changeset
|
526 } |
1 | 527 |
528 u = gaimrc_read_user(f); | |
529 | |
530 if (cur) | |
531 current_user = u; | |
532 | |
533 aim_users = g_list_append(aim_users, u); | |
534 } | |
535 } | |
536 | |
537 static void gaimrc_write_users(FILE *f) | |
538 { | |
539 GList *usr = aim_users; | |
540 struct aim_user *u; | |
541 | |
542 fprintf(f, "users {\n"); | |
543 | |
544 while(usr) { | |
545 u = (struct aim_user *)usr->data; | |
546 if (current_user == u) { | |
547 fprintf(f, "\tcurrent_user {\n"); | |
548 } else { | |
549 fprintf(f, "\tuser {\n"); | |
550 } | |
551 gaimrc_write_user(f, u); | |
552 | |
553 fprintf(f, "\t}\n"); | |
554 | |
555 usr = usr->next; | |
556 } | |
557 | |
558 fprintf(f, "}\n"); | |
559 } | |
560 | |
561 | |
562 | |
563 | |
564 static void gaimrc_read_options(FILE *f) | |
565 { | |
566 char buf[2048]; | |
567 struct parse *p; | |
568 | |
569 buf[0] = 0; | |
570 | |
571 while (buf[0] != '}') { | |
572 if (buf[0] == '#') | |
573 continue; | |
574 | |
575 if (!fgets(buf, sizeof(buf), f)) | |
576 return; | |
577 | |
578 p = parse_line(buf); | |
579 | |
580 if (!strcmp(p->option, "general_options")) { | |
581 general_options = atoi(p->value[0]); | |
582 } else if (!strcmp(p->option, "display_options")) { | |
583 display_options = atoi(p->value[0]); | |
584 } else if (!strcmp(p->option, "sound_options")) { | |
585 sound_options = atoi(p->value[0]); | |
666
71ea550c22ac
[gaim-migrate @ 676]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
570
diff
changeset
|
586 } else if (!strcmp(p->option, "font_options")) { |
71ea550c22ac
[gaim-migrate @ 676]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
570
diff
changeset
|
587 font_options = atoi(p->value[0]); |
71ea550c22ac
[gaim-migrate @ 676]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
570
diff
changeset
|
588 } else if (!strcmp(p->option, "font_face")) { |
71ea550c22ac
[gaim-migrate @ 676]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
570
diff
changeset
|
589 if (p->value[0] != NULL) |
71ea550c22ac
[gaim-migrate @ 676]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
570
diff
changeset
|
590 g_snprintf(fontface, sizeof(fontface), "%s", p->value[0]); |
71ea550c22ac
[gaim-migrate @ 676]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
570
diff
changeset
|
591 } else if (!strcmp(p->option, "foreground")) { |
697 | 592 fgcolor.red = atoi(p->value[0]); |
593 fgcolor.green = atoi(p->value[1]); | |
594 fgcolor.blue = atoi(p->value[2]); | |
666
71ea550c22ac
[gaim-migrate @ 676]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
570
diff
changeset
|
595 } else if (!strcmp(p->option, "background")) { |
697 | 596 bgcolor.red = atoi(p->value[0]); |
597 bgcolor.green = atoi(p->value[1]); | |
598 bgcolor.blue = atoi(p->value[2]); | |
1 | 599 } else if (!strcmp(p->option, "report_idle")) { |
600 report_idle = atoi(p->value[0]); | |
601 } else if (!strcmp(p->option, "web_browser")) { | |
602 web_browser = atoi(p->value[0]); | |
603 } else if (!strcmp(p->option, "web_command")) { | |
604 strcpy(web_command, p->value[0]); | |
605 } else if (!strcmp(p->option, "proxy_type")) { | |
606 proxy_type = atoi(p->value[0]); | |
607 } else if (!strcmp(p->option, "proxy_host")) { | |
608 strcpy(proxy_host, p->value[0]); | |
609 } else if (!strcmp(p->option, "proxy_port")) { | |
610 proxy_port = atoi(p->value[0]); | |
611 } else if (!strcmp(p->option, "aim_host")) { | |
612 strcpy(aim_host, p->value[0]); | |
613 } else if (!strcmp(p->option, "aim_port")) { | |
614 aim_port = atoi(p->value[0]); | |
615 } else if (!strcmp(p->option, "login_host")) { | |
616 strcpy(login_host, p->value[0]); | |
617 } else if (!strcmp(p->option, "login_port")) { | |
618 login_port = atoi(p->value[0]); | |
619 } else if (!strcmp(p->option, "blist_pos")) { | |
620 blist_pos.x = atoi(p->value[0]); | |
621 blist_pos.y = atoi(p->value[1]); | |
622 blist_pos.width = atoi(p->value[2]); | |
623 blist_pos.height = atoi(p->value[3]); | |
624 blist_pos.xoff = atoi(p->value[4]); | |
625 blist_pos.yoff = atoi(p->value[5]); | |
82 | 626 } |
1 | 627 |
628 } | |
629 | |
630 } | |
631 | |
632 static void gaimrc_write_options(FILE *f) | |
633 { | |
634 | |
635 fprintf(f, "options {\n"); | |
636 fprintf(f, "\tgeneral_options { %d }\n", general_options); | |
637 fprintf(f, "\tdisplay_options { %d }\n", display_options); | |
638 fprintf(f, "\tsound_options { %d }\n", sound_options); | |
666
71ea550c22ac
[gaim-migrate @ 676]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
570
diff
changeset
|
639 fprintf(f, "\tfont_options { %d }\n", font_options); |
232 | 640 if (fontface) |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
641 fprintf(f, "\tfont_face { %s }\n", fontface); |
697 | 642 fprintf(f, "\tforeground { %d } { %d } { %d }\n", fgcolor.red, fgcolor.green, fgcolor.blue); |
643 fprintf(f, "\tbackground { %d } { %d } { %d }\n", bgcolor.red, bgcolor.green, bgcolor.blue); | |
1 | 644 fprintf(f, "\treport_idle { %d }\n", report_idle); |
645 fprintf(f, "\tweb_browser { %d }\n", web_browser); | |
646 fprintf(f, "\tweb_command { %s }\n", web_command); | |
647 fprintf(f, "\tproxy_type { %d }\n", proxy_type); | |
648 fprintf(f, "\tproxy_host { %s }\n", proxy_host); | |
649 fprintf(f, "\tproxy_port { %d }\n", proxy_port); | |
650 fprintf(f, "\taim_host { %s }\n", aim_host); | |
651 fprintf(f, "\taim_port { %d }\n", aim_port); | |
652 fprintf(f, "\tlogin_host { %s }\n", login_host); | |
653 fprintf(f, "\tlogin_port { %d }\n", login_port); | |
654 fprintf(f, "\tblist_pos { %d } { %d } { %d } { %d } { %d } { %d }\n", | |
655 blist_pos.x, blist_pos.y, blist_pos.width, blist_pos.height, | |
656 blist_pos.xoff, blist_pos.yoff); | |
180 | 657 fprintf(f, "\tlatest_ver { %s }\n", latest_ver); |
1 | 658 fprintf(f, "}\n"); |
659 } | |
660 | |
661 | |
917 | 662 void set_defaults(int saveinfo) |
1 | 663 { |
917 | 664 if (!saveinfo) |
665 { | |
666 if (aim_users) | |
667 { | |
668 g_list_free(aim_users); | |
669 aim_users = NULL; | |
670 } | |
671 if (away_messages) | |
672 { | |
673 g_list_free(away_messages); | |
674 away_messages = NULL; | |
675 } | |
676 } | |
677 | |
1 | 678 general_options = |
679 OPT_GEN_SEND_LINKS | | |
680 OPT_GEN_ENTER_SENDS | | |
681 OPT_GEN_SAVED_WINDOWS | | |
682 OPT_GEN_REMEMBER_PASS | | |
340
0d9cfc3579a5
[gaim-migrate @ 350]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
683 OPT_GEN_REGISTERED | |
870 | 684 OPT_GEN_NEAR_APPLET | |
685 OPT_GEN_CTL_SMILEYS | | |
686 OPT_GEN_CTL_CHARS; | |
687 | |
1 | 688 display_options = |
689 OPT_DISP_SHOW_IDLETIME | | |
690 OPT_DISP_SHOW_TIME | | |
691 OPT_DISP_SHOW_PIXMAPS | | |
453 | 692 OPT_DISP_SHOW_BUDDYTICKER | |
870 | 693 OPT_DISP_SHOW_BUTTON_XPM | |
694 OPT_DISP_SHOW_SMILEY | | |
695 OPT_DISP_COOL_LOOK | | |
696 OPT_DISP_CONV_BIG_ENTRY | | |
915
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
870
diff
changeset
|
697 OPT_DISP_CHAT_BIG_ENTRY | |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
870
diff
changeset
|
698 OPT_DISP_CONV_BUTTON_XPM | |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
870
diff
changeset
|
699 OPT_DISP_CONV_BUTTON_TEXT | |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
870
diff
changeset
|
700 OPT_DISP_CHAT_BUTTON_XPM | |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
870
diff
changeset
|
701 OPT_DISP_CHAT_BUTTON_TEXT; |
870 | 702 |
917 | 703 if (!saveinfo) |
704 { | |
705 font_options = 0; | |
706 sound_options = OPT_SOUND_LOGIN | OPT_SOUND_LOGOUT | OPT_SOUND_RECV | OPT_SOUND_SEND | OPT_SOUND_SILENT_SIGNON; | |
707 report_idle = IDLE_GAIM; | |
708 web_browser = BROWSER_NETSCAPE; | |
709 proxy_type = PROXY_NONE; | |
1 | 710 |
917 | 711 aim_port = TOC_PORT; |
712 login_port = AUTH_PORT; | |
713 g_snprintf(aim_host, sizeof(aim_host), "%s", TOC_HOST); | |
714 g_snprintf(login_host, sizeof(login_host), "%s", AUTH_HOST); | |
715 proxy_host[0] = 0; | |
716 proxy_port = 0; | |
717 g_snprintf(web_command, sizeof(web_command), "xterm -e lynx %%s"); | |
718 blist_pos.width = 0; | |
719 blist_pos.height = 0; | |
720 blist_pos.x = 0; | |
721 blist_pos.y = 0; | |
722 blist_pos.xoff = 0; | |
723 blist_pos.yoff = 0; | |
724 g_snprintf(latest_ver, BUF_LONG, "%s", VERSION); | |
725 } | |
1 | 726 } |
727 | |
728 | |
729 void load_prefs() | |
730 { | |
731 FILE *f; | |
732 char buf[1024]; | |
733 int ver = 0; | |
570 | 734 |
1 | 735 if (getenv("HOME")) { |
736 g_snprintf(buf, sizeof(buf), "%s/.gaimrc", getenv("HOME")); | |
737 if ((f = fopen(buf,"r"))) { | |
738 fgets(buf, sizeof(buf), f); | |
739 sscanf(buf, "# .gaimrc v%d", &ver); | |
15 | 740 if ( (ver <= 1) || (buf[0] != '#')) { |
1 | 741 fclose(f); |
917 | 742 set_defaults(FALSE); |
1 | 743 save_prefs(); |
744 load_prefs(); | |
745 return; | |
746 } | |
917 | 747 |
1 | 748 while(!feof(f)) { |
749 switch(gaimrc_parse_tag(f)) { | |
750 case -1: | |
751 /* Let the loop end, EOF*/ | |
752 break; | |
753 case 0: | |
754 gaimrc_read_users(f); | |
755 break; | |
756 case 1: | |
757 gaimrc_read_options(f); | |
758 break; | |
759 case 2: | |
760 gaimrc_read_away(f); | |
761 break; | |
142
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
762 #ifdef GAIM_PLUGINS |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
763 case 3: |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
764 gaimrc_read_plugins(f); |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
765 break; |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
766 #endif |
673 | 767 case 4: |
768 gaimrc_read_pounce(f); | |
769 break; | |
774
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
770 case 5: |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
771 gaimrc_read_chat(f); |
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
772 break; |
1 | 773 default: |
774 /* NOOP */ | |
775 break; | |
776 } | |
777 } | |
778 fclose(f); | |
779 } | |
780 } | |
917 | 781 |
782 if ( (ver == 2) || (buf[0] != '#')) { | |
783 set_defaults(TRUE); | |
784 } | |
1 | 785 |
786 } | |
787 | |
788 void save_prefs() | |
789 { | |
790 FILE *f; | |
791 char buf[BUF_LONG]; | |
792 | |
793 if (getenv("HOME")) { | |
794 g_snprintf(buf, sizeof(buf), "%s/.gaimrc", getenv("HOME")); | |
795 if ((f = fopen(buf,"w"))) { | |
917 | 796 fprintf(f, "# .gaimrc v%d\n", 3); |
1 | 797 gaimrc_write_users(f); |
673 | 798 gaimrc_write_options(f); |
799 gaimrc_write_away(f); | |
142
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
800 #ifdef GAIM_PLUGINS |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
801 gaimrc_write_plugins(f); |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
131
diff
changeset
|
802 #endif |
673 | 803 gaimrc_write_pounce(f); |
774
b61607d6c2af
[gaim-migrate @ 784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
697
diff
changeset
|
804 gaimrc_write_chat(f); |
673 | 805 fclose(f); |
806 chmod(buf, S_IRUSR | S_IWUSR); | |
807 } | |
1 | 808 } |
809 } | |
810 |