Mercurial > pidgin.yaz
comparison src/gaimrc.c @ 774:b61607d6c2af
[gaim-migrate @ 784]
save buddy chats, and better display of them (though they flash now, but they don't cause errors)
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Mon, 28 Aug 2000 18:49:17 +0000 |
parents | c7c0d2590681 |
children | 9b8b83592bb6 |
comparison
equal
deleted
inserted
replaced
773:267ed2b889ee | 774:b61607d6c2af |
---|---|
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")) { | 149 } else if (!strcmp(tag, "pounce")) { |
150 return 4; | 150 return 4; |
151 } else if (!strcmp(tag, "chat")) { | |
152 return 5; | |
151 } | 153 } |
152 | 154 |
153 return -1; | 155 return -1; |
154 } | 156 } |
155 | 157 |
303 fprintf(f, "\tentry { %s } { %s } { %d } { %d }\n", str1, str2, popup, sendim); | 305 fprintf(f, "\tentry { %s } { %s } { %d } { %d }\n", str1, str2, popup, sendim); |
304 | 306 |
305 /* escape_text2 uses malloc(), so we don't want to g_free these */ | 307 /* escape_text2 uses malloc(), so we don't want to g_free these */ |
306 free(str1); | 308 free(str1); |
307 free(str2); | 309 free(str2); |
310 | |
311 pnc = pnc->next; | |
312 } | |
313 } | |
314 | |
315 fprintf(f, "}\n"); | |
316 } | |
317 | |
318 static void gaimrc_read_chat(FILE *f) | |
319 { | |
320 struct parse *p; | |
321 char buf[4096]; | |
322 struct chat_room *b; | |
323 | |
324 buf[0] = 0; | |
325 | |
326 while (buf[0] != '}') | |
327 { | |
328 if (!fgets(buf, sizeof(buf), f)) | |
329 return; | |
330 | |
331 if (buf[0] == '}') | |
332 return; | |
333 | |
334 p = parse_line(buf); | |
335 if (!strcmp(p->option, "entry")) | |
336 { | |
337 b = g_new0(struct chat_room, 1); | |
338 | |
339 g_snprintf(b->name, sizeof(b->name), "%s", p->value[0]); | |
340 | |
341 b->exchange = atoi(p->value[1]); | |
342 | |
343 chat_rooms = g_list_append(chat_rooms, b); | |
344 } | |
345 } | |
346 } | |
347 | |
348 static void gaimrc_write_chat(FILE *f) | |
349 { | |
350 GList *pnc = chat_rooms; | |
351 struct chat_room *b; | |
352 | |
353 fprintf(f, "chat {\n"); | |
354 | |
355 if (pnc) | |
356 { | |
357 while (pnc) { | |
358 char *str1; | |
359 | |
360 b = (struct chat_room *)pnc->data; | |
361 | |
362 str1 = escape_text2(b->name); | |
363 | |
364 fprintf(f, "\tentry { %s } { %d }\n", str1, b->exchange); | |
365 | |
366 /* escape_text2 uses malloc(), so we don't want to g_free these */ | |
367 free(str1); | |
308 | 368 |
309 pnc = pnc->next; | 369 pnc = pnc->next; |
310 } | 370 } |
311 } | 371 } |
312 | 372 |
685 break; | 745 break; |
686 #endif | 746 #endif |
687 case 4: | 747 case 4: |
688 gaimrc_read_pounce(f); | 748 gaimrc_read_pounce(f); |
689 break; | 749 break; |
750 case 5: | |
751 gaimrc_read_chat(f); | |
752 break; | |
690 default: | 753 default: |
691 /* NOOP */ | 754 /* NOOP */ |
692 break; | 755 break; |
693 } | 756 } |
694 } | 757 } |
712 gaimrc_write_away(f); | 775 gaimrc_write_away(f); |
713 #ifdef GAIM_PLUGINS | 776 #ifdef GAIM_PLUGINS |
714 gaimrc_write_plugins(f); | 777 gaimrc_write_plugins(f); |
715 #endif | 778 #endif |
716 gaimrc_write_pounce(f); | 779 gaimrc_write_pounce(f); |
780 gaimrc_write_chat(f); | |
717 fclose(f); | 781 fclose(f); |
718 chmod(buf, S_IRUSR | S_IWUSR); | 782 chmod(buf, S_IRUSR | S_IWUSR); |
719 } | 783 } |
720 } | 784 } |
721 } | 785 } |