comparison src/gaimrc.c @ 673:ddc3fd0dcd51

[gaim-migrate @ 683] Made the necessary modifications to allow gaim to save buddy pounces. I just noticed that you cant _delete_ (remove) a buddy pounce. Woops. I'll take a look at that. I'll do saving of buddy chats when I get back from dinner. Adios. committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Sun, 13 Aug 2000 03:15:06 +0000
parents 71ea550c22ac
children 16831576f242
comparison
equal deleted inserted replaced
672:84987d2e4bd4 673:ddc3fd0dcd51
144 return 1; 144 return 1;
145 } else if (!strcmp(tag, "away")) { 145 } else if (!strcmp(tag, "away")) {
146 return 2; 146 return 2;
147 } else if (!strcmp(tag, "plugins")) { 147 } else if (!strcmp(tag, "plugins")) {
148 return 3; 148 return 3;
149 } else if (!strcmp(tag, "pounce")) {
150 return 4;
149 } 151 }
150 152
151 return -1; 153 return -1;
152 } 154 }
153 155
234 awy = awy->next; 236 awy = awy->next;
235 } 237 }
236 } 238 }
237 else 239 else
238 fprintf(f, "\tmessage { boring default } { %s }\n", BORING_DEFAULT_AWAY_MSG); 240 fprintf(f, "\tmessage { boring default } { %s }\n", BORING_DEFAULT_AWAY_MSG);
241
242 fprintf(f, "}\n");
243 }
244
245 static void gaimrc_read_pounce(FILE *f)
246 {
247 struct parse *p;
248 char buf[4096];
249 struct buddy_pounce *b;
250
251 buf[0] = 0;
252
253 while (buf[0] != '}')
254 {
255 if (!fgets(buf, sizeof(buf), f))
256 return;
257
258 if (buf[0] == '}')
259 return;
260
261 p = parse_line(buf);
262 if (!strcmp(p->option, "entry"))
263 {
264 b = g_new0(struct buddy_pounce, 1);
265
266 g_snprintf(b->name, sizeof(b->name), "%s", p->value[0]);
267 g_snprintf(b->message, sizeof(b->message), "%s", p->value[1]);
268
269 b->popup = atoi(p->value[2]);
270 b->sendim = atoi(p->value[3]);
271
272 filter_break(b->message);
273 buddy_pounces = g_list_append(buddy_pounces, b);
274 }
275 }
276 }
277
278 static void gaimrc_write_pounce(FILE *f)
279 {
280 GList *pnc = buddy_pounces;
281 struct buddy_pounce *b;
282
283 fprintf(f, "pounce {\n");
284
285 if (pnc)
286 {
287 while (pnc) {
288 char *str1, *str2;
289 int popup, sendim;
290
291 b = (struct buddy_pounce *)pnc->data;
292
293 str1 = escape_text2(b->name);
294 str2 = escape_text2(b->message);
295 popup = b->popup;
296 sendim = b->sendim;
297
298 fprintf(f, "\tentry { %s } { %s } { %d } { %d }\n", str1, str2, popup, sendim);
299
300 /* escape_text2 uses malloc(), so we don't want to g_free these */
301 free(str1);
302 free(str2);
303
304 pnc = pnc->next;
305 }
306 }
239 307
240 fprintf(f, "}\n"); 308 fprintf(f, "}\n");
241 } 309 }
242 310
243 #ifdef GAIM_PLUGINS 311 #ifdef GAIM_PLUGINS
605 #ifdef GAIM_PLUGINS 673 #ifdef GAIM_PLUGINS
606 case 3: 674 case 3:
607 gaimrc_read_plugins(f); 675 gaimrc_read_plugins(f);
608 break; 676 break;
609 #endif 677 #endif
678 case 4:
679 gaimrc_read_pounce(f);
680 break;
610 default: 681 default:
611 /* NOOP */ 682 /* NOOP */
612 break; 683 break;
613 } 684 }
614 } 685 }
626 if (getenv("HOME")) { 697 if (getenv("HOME")) {
627 g_snprintf(buf, sizeof(buf), "%s/.gaimrc", getenv("HOME")); 698 g_snprintf(buf, sizeof(buf), "%s/.gaimrc", getenv("HOME"));
628 if ((f = fopen(buf,"w"))) { 699 if ((f = fopen(buf,"w"))) {
629 fprintf(f, "# .gaimrc v%d\n", 2); 700 fprintf(f, "# .gaimrc v%d\n", 2);
630 gaimrc_write_users(f); 701 gaimrc_write_users(f);
631 gaimrc_write_options(f); 702 gaimrc_write_options(f);
632 gaimrc_write_away(f); 703 gaimrc_write_away(f);
633 #ifdef GAIM_PLUGINS 704 #ifdef GAIM_PLUGINS
634 gaimrc_write_plugins(f); 705 gaimrc_write_plugins(f);
635 #endif 706 #endif
636 fclose(f); 707 gaimrc_write_pounce(f);
637 chmod(buf, S_IRUSR | S_IWUSR); 708 fclose(f);
638 } 709 chmod(buf, S_IRUSR | S_IWUSR);
639 710 }
640 } 711 }
641 } 712 }
642 713