Mercurial > pidgin
diff 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 |
line wrap: on
line diff
--- a/src/gaimrc.c Sun Aug 13 02:06:09 2000 +0000 +++ b/src/gaimrc.c Sun Aug 13 03:15:06 2000 +0000 @@ -146,6 +146,8 @@ return 2; } else if (!strcmp(tag, "plugins")) { return 3; + } else if (!strcmp(tag, "pounce")) { + return 4; } return -1; @@ -240,6 +242,72 @@ fprintf(f, "}\n"); } +static void gaimrc_read_pounce(FILE *f) +{ + struct parse *p; + char buf[4096]; + struct buddy_pounce *b; + + buf[0] = 0; + + while (buf[0] != '}') + { + if (!fgets(buf, sizeof(buf), f)) + return; + + if (buf[0] == '}') + return; + + p = parse_line(buf); + if (!strcmp(p->option, "entry")) + { + b = g_new0(struct buddy_pounce, 1); + + g_snprintf(b->name, sizeof(b->name), "%s", p->value[0]); + g_snprintf(b->message, sizeof(b->message), "%s", p->value[1]); + + b->popup = atoi(p->value[2]); + b->sendim = atoi(p->value[3]); + + filter_break(b->message); + buddy_pounces = g_list_append(buddy_pounces, b); + } + } +} + +static void gaimrc_write_pounce(FILE *f) +{ + GList *pnc = buddy_pounces; + struct buddy_pounce *b; + + fprintf(f, "pounce {\n"); + + if (pnc) + { + while (pnc) { + char *str1, *str2; + int popup, sendim; + + b = (struct buddy_pounce *)pnc->data; + + str1 = escape_text2(b->name); + str2 = escape_text2(b->message); + popup = b->popup; + sendim = b->sendim; + + fprintf(f, "\tentry { %s } { %s } { %d } { %d }\n", str1, str2, popup, sendim); + + /* escape_text2 uses malloc(), so we don't want to g_free these */ + free(str1); + free(str2); + + pnc = pnc->next; + } + } + + fprintf(f, "}\n"); +} + #ifdef GAIM_PLUGINS static void gaimrc_write_plugins(FILE *f) { @@ -607,6 +675,9 @@ gaimrc_read_plugins(f); break; #endif + case 4: + gaimrc_read_pounce(f); + break; default: /* NOOP */ break; @@ -628,15 +699,15 @@ if ((f = fopen(buf,"w"))) { fprintf(f, "# .gaimrc v%d\n", 2); gaimrc_write_users(f); - gaimrc_write_options(f); - gaimrc_write_away(f); + gaimrc_write_options(f); + gaimrc_write_away(f); #ifdef GAIM_PLUGINS gaimrc_write_plugins(f); #endif - fclose(f); - chmod(buf, S_IRUSR | S_IWUSR); - } - + gaimrc_write_pounce(f); + fclose(f); + chmod(buf, S_IRUSR | S_IWUSR); + } } }