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