Mercurial > pidgin
comparison src/blist.c @ 5563:9eb5b13fd412
[gaim-migrate @ 5965]
Just a taste of what's coming.
Standard "This won't compile" thing. Plugin authors, you're going to hate
me, but that's okay, because I have friends too!
It's really late. My brain resembles that of fish swimming in jello pudding
with neon lights flying around chanting musicals. I'm not on drugs. I'm
just that tired.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Fri, 30 May 2003 09:38:29 +0000 |
parents | 7a64114641c3 |
children | 86456ec3ca25 |
comparison
equal
deleted
inserted
replaced
5562:3c8d34574601 | 5563:9eb5b13fd412 |
---|---|
67 return gaim_blist_get_last_sibling(node->child); | 67 return gaim_blist_get_last_sibling(node->child); |
68 } | 68 } |
69 | 69 |
70 struct _gaim_hbuddy { | 70 struct _gaim_hbuddy { |
71 char *name; | 71 char *name; |
72 struct gaim_account *account; | 72 GaimAccount *account; |
73 }; | 73 }; |
74 | 74 |
75 static guint _gaim_blist_hbuddy_hash (struct _gaim_hbuddy *hb) | 75 static guint _gaim_blist_hbuddy_hash (struct _gaim_hbuddy *hb) |
76 { | 76 { |
77 return g_str_hash(hb->name); | 77 return g_str_hash(hb->name); |
293 "Unknown child type in group %s\n", group->name); | 293 "Unknown child type in group %s\n", group->name); |
294 } | 294 } |
295 child = next; | 295 child = next; |
296 } | 296 } |
297 for (accts = gaim_group_get_accounts(group); accts; accts = g_slist_remove(accts, accts->data)) { | 297 for (accts = gaim_group_get_accounts(group); accts; accts = g_slist_remove(accts, accts->data)) { |
298 struct gaim_account *account = accts->data; | 298 GaimAccount *account = accts->data; |
299 serv_rename_group(account->gc, group, name); | 299 serv_rename_group(account->gc, group, name); |
300 } | 300 } |
301 gaim_blist_remove_group(group); | 301 gaim_blist_remove_group(group); |
302 } else { | 302 } else { |
303 /* a simple rename */ | 303 /* a simple rename */ |
304 for (accts = gaim_group_get_accounts(group); accts; accts = g_slist_remove(accts, accts->data)) { | 304 for (accts = gaim_group_get_accounts(group); accts; accts = g_slist_remove(accts, accts->data)) { |
305 struct gaim_account *account = accts->data; | 305 GaimAccount *account = accts->data; |
306 serv_rename_group(account->gc, group, name); | 306 serv_rename_group(account->gc, group, name); |
307 } | 307 } |
308 g_free(group->name); | 308 g_free(group->name); |
309 group->name = g_strdup(name); | 309 group->name = g_strdup(name); |
310 if (ops) | 310 if (ops) |
311 ops->update(gaimbuddylist, (GaimBlistNode*)group); | 311 ops->update(gaimbuddylist, (GaimBlistNode*)group); |
312 } | 312 } |
313 } | 313 } |
314 | 314 |
315 struct chat *gaim_chat_new(struct gaim_account *account, const char *alias, GHashTable *components) | 315 struct chat *gaim_chat_new(GaimAccount *account, const char *alias, GHashTable *components) |
316 { | 316 { |
317 struct chat *chat; | 317 struct chat *chat; |
318 struct gaim_blist_ui_ops *ops; | 318 struct gaim_blist_ui_ops *ops; |
319 | 319 |
320 if(!components) | 320 if(!components) |
334 ops->new_node((GaimBlistNode *)chat); | 334 ops->new_node((GaimBlistNode *)chat); |
335 | 335 |
336 return chat; | 336 return chat; |
337 } | 337 } |
338 | 338 |
339 struct buddy *gaim_buddy_new(struct gaim_account *account, const char *screenname, const char *alias) | 339 struct buddy *gaim_buddy_new(GaimAccount *account, const char *screenname, const char *alias) |
340 { | 340 { |
341 struct buddy *b; | 341 struct buddy *b; |
342 struct gaim_blist_ui_ops *ops; | 342 struct gaim_blist_ui_ops *ops; |
343 | 343 |
344 b = g_new0(struct buddy, 1); | 344 b = g_new0(struct buddy, 1); |
721 return buddy ? buddy->name : _("Unknown"); | 721 return buddy ? buddy->name : _("Unknown"); |
722 return ret; | 722 return ret; |
723 | 723 |
724 } | 724 } |
725 | 725 |
726 struct buddy *gaim_find_buddy(struct gaim_account *account, const char *name) | 726 struct buddy *gaim_find_buddy(GaimAccount *account, const char *name) |
727 { | 727 { |
728 struct buddy *buddy; | 728 struct buddy *buddy; |
729 struct _gaim_hbuddy hb; | 729 struct _gaim_hbuddy hb; |
730 | 730 |
731 if (!gaimbuddylist) | 731 if (!gaimbuddylist) |
769 child = child->next; | 769 child = child->next; |
770 } | 770 } |
771 return l; | 771 return l; |
772 } | 772 } |
773 | 773 |
774 void gaim_blist_add_account(struct gaim_account *account) | 774 void gaim_blist_add_account(GaimAccount *account) |
775 { | 775 { |
776 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | 776 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; |
777 GaimBlistNode *group, *buddy; | 777 GaimBlistNode *group, *buddy; |
778 | 778 |
779 if(!gaimbuddylist) | 779 if(!gaimbuddylist) |
799 } | 799 } |
800 } | 800 } |
801 } | 801 } |
802 } | 802 } |
803 | 803 |
804 void gaim_blist_remove_account(struct gaim_account *account) | 804 void gaim_blist_remove_account(GaimAccount *account) |
805 { | 805 { |
806 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | 806 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; |
807 GaimBlistNode *group, *buddy; | 807 GaimBlistNode *group, *buddy; |
808 | 808 |
809 if (!gaimbuddylist) | 809 if (!gaimbuddylist) |
832 } | 832 } |
833 } | 833 } |
834 } | 834 } |
835 } | 835 } |
836 | 836 |
837 void parse_toc_buddy_list(struct gaim_account *account, char *config) | 837 void parse_toc_buddy_list(GaimAccount *account, char *config) |
838 { | 838 { |
839 char *c; | 839 char *c; |
840 char current[256]; | 840 char current[256]; |
841 GList *bud = NULL; | 841 GList *bud = NULL; |
842 | 842 |
897 } else if (*c == 'p') { | 897 } else if (*c == 'p') { |
898 gaim_privacy_permit_add(account, c + 2); | 898 gaim_privacy_permit_add(account, c + 2); |
899 } else if (*c == 'd') { | 899 } else if (*c == 'd') { |
900 gaim_privacy_deny_add(account, c + 2); | 900 gaim_privacy_deny_add(account, c + 2); |
901 } else if (!strncmp("toc", c, 3)) { | 901 } else if (!strncmp("toc", c, 3)) { |
902 sscanf(c + strlen(c) - 1, "%d", &account->permdeny); | 902 sscanf(c + strlen(c) - 1, "%d", &account->perm_deny); |
903 gaim_debug(GAIM_DEBUG_MISC, "toc blist", | 903 gaim_debug(GAIM_DEBUG_MISC, "toc blist", |
904 "permdeny: %d\n", account->permdeny); | 904 "permdeny: %d\n", account->perm_deny); |
905 if (account->permdeny == 0) | 905 if (account->perm_deny == 0) |
906 account->permdeny = 1; | 906 account->perm_deny = 1; |
907 } else if (*c == 'm') { | 907 } else if (*c == 'm') { |
908 sscanf(c + 2, "%d", &account->permdeny); | 908 sscanf(c + 2, "%d", &account->perm_deny); |
909 gaim_debug(GAIM_DEBUG_MISC, "toc blist", | 909 gaim_debug(GAIM_DEBUG_MISC, "toc blist", |
910 "permdeny: %d\n", account->permdeny); | 910 "permdeny: %d\n", account->perm_deny); |
911 if (account->permdeny == 0) | 911 if (account->perm_deny == 0) |
912 account->permdeny = 1; | 912 account->perm_deny = 1; |
913 } | 913 } |
914 } while ((c = strtok(NULL, "\n"))); | 914 } while ((c = strtok(NULL, "\n"))); |
915 | 915 |
916 if(account->gc) { | 916 if(account->gc) { |
917 if(bud) { | 917 if(bud) { |
1103 } | 1103 } |
1104 | 1104 |
1105 static gboolean gaim_blist_read(const char *filename); | 1105 static gboolean gaim_blist_read(const char *filename); |
1106 | 1106 |
1107 | 1107 |
1108 static void do_import(struct gaim_account *account, const char *filename) | 1108 static void do_import(GaimAccount *account, const char *filename) |
1109 { | 1109 { |
1110 GString *buf = NULL; | 1110 GString *buf = NULL; |
1111 char first[64]; | 1111 char first[64]; |
1112 char path[PATHSIZE]; | 1112 char path[PATHSIZE]; |
1113 int len; | 1113 int len; |
1196 parse_toc_buddy_list(account, buf->str); | 1196 parse_toc_buddy_list(account, buf->str); |
1197 g_string_free(buf, TRUE); | 1197 g_string_free(buf, TRUE); |
1198 } | 1198 } |
1199 } | 1199 } |
1200 | 1200 |
1201 gboolean gaim_group_on_account(struct group *g, struct gaim_account *account) { | 1201 gboolean gaim_group_on_account(struct group *g, GaimAccount *account) { |
1202 GaimBlistNode *bnode; | 1202 GaimBlistNode *bnode; |
1203 for(bnode = g->node.child; bnode; bnode = bnode->next) { | 1203 for(bnode = g->node.child; bnode; bnode = bnode->next) { |
1204 struct buddy *b = (struct buddy *)bnode; | 1204 struct buddy *b = (struct buddy *)bnode; |
1205 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | 1205 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) |
1206 continue; | 1206 continue; |
1356 g->settings = blist_parser_group_settings; | 1356 g->settings = blist_parser_group_settings; |
1357 } | 1357 } |
1358 tag_stack = g_list_delete_link(tag_stack, tag_stack); | 1358 tag_stack = g_list_delete_link(tag_stack, tag_stack); |
1359 blist_parser_group_settings = NULL; | 1359 blist_parser_group_settings = NULL; |
1360 } else if(!strcmp(element_name, "chat")) { | 1360 } else if(!strcmp(element_name, "chat")) { |
1361 struct gaim_account *account = gaim_account_find(blist_parser_account_name, | 1361 GaimAccount *account = gaim_account_find(blist_parser_account_name, |
1362 blist_parser_account_protocol); | 1362 blist_parser_account_protocol); |
1363 if(account) { | 1363 if(account) { |
1364 struct chat *chat = gaim_chat_new(account, blist_parser_chat_alias, blist_parser_chat_components); | 1364 struct chat *chat = gaim_chat_new(account, blist_parser_chat_alias, blist_parser_chat_components); |
1365 struct group *g = gaim_find_group(blist_parser_group_name); | 1365 struct group *g = gaim_find_group(blist_parser_group_name); |
1366 gaim_blist_add_chat(chat,g,NULL); | 1366 gaim_blist_add_chat(chat,g,NULL); |
1374 } else if(!strcmp(element_name, "person")) { | 1374 } else if(!strcmp(element_name, "person")) { |
1375 g_free(blist_parser_person_name); | 1375 g_free(blist_parser_person_name); |
1376 blist_parser_person_name = NULL; | 1376 blist_parser_person_name = NULL; |
1377 tag_stack = g_list_delete_link(tag_stack, tag_stack); | 1377 tag_stack = g_list_delete_link(tag_stack, tag_stack); |
1378 } else if(!strcmp(element_name, "buddy")) { | 1378 } else if(!strcmp(element_name, "buddy")) { |
1379 struct gaim_account *account = gaim_account_find(blist_parser_account_name, | 1379 GaimAccount *account = gaim_account_find(blist_parser_account_name, |
1380 blist_parser_account_protocol); | 1380 blist_parser_account_protocol); |
1381 if(account) { | 1381 if(account) { |
1382 struct buddy *b = gaim_buddy_new(account, blist_parser_buddy_name, blist_parser_buddy_alias); | 1382 struct buddy *b = gaim_buddy_new(account, blist_parser_buddy_name, blist_parser_buddy_alias); |
1383 struct group *g = gaim_find_group(blist_parser_group_name); | 1383 struct group *g = gaim_find_group(blist_parser_group_name); |
1384 gaim_blist_add_buddy(b,g,NULL); | 1384 gaim_blist_add_buddy(b,g,NULL); |
1439 blist_parser_setting_value = NULL; | 1439 blist_parser_setting_value = NULL; |
1440 tag_stack = g_list_delete_link(tag_stack, tag_stack); | 1440 tag_stack = g_list_delete_link(tag_stack, tag_stack); |
1441 } else if(!strcmp(element_name, "privacy")) { | 1441 } else if(!strcmp(element_name, "privacy")) { |
1442 tag_stack = g_list_delete_link(tag_stack, tag_stack); | 1442 tag_stack = g_list_delete_link(tag_stack, tag_stack); |
1443 } else if(!strcmp(element_name, "account")) { | 1443 } else if(!strcmp(element_name, "account")) { |
1444 struct gaim_account *account = gaim_account_find(blist_parser_account_name, | 1444 GaimAccount *account = gaim_account_find(blist_parser_account_name, |
1445 blist_parser_account_protocol); | 1445 blist_parser_account_protocol); |
1446 if(account) { | 1446 if(account) { |
1447 account->permdeny = blist_parser_privacy_mode; | 1447 account->perm_deny = blist_parser_privacy_mode; |
1448 } | 1448 } |
1449 g_free(blist_parser_account_name); | 1449 g_free(blist_parser_account_name); |
1450 blist_parser_account_name = NULL; | 1450 blist_parser_account_name = NULL; |
1451 tag_stack = g_list_delete_link(tag_stack, tag_stack); | 1451 tag_stack = g_list_delete_link(tag_stack, tag_stack); |
1452 } else if(!strcmp(element_name, "permit")) { | 1452 } else if(!strcmp(element_name, "permit")) { |
1453 struct gaim_account *account = gaim_account_find(blist_parser_account_name, | 1453 GaimAccount *account = gaim_account_find(blist_parser_account_name, |
1454 blist_parser_account_protocol); | 1454 blist_parser_account_protocol); |
1455 if(account) { | 1455 if(account) { |
1456 gaim_privacy_permit_add(account, blist_parser_buddy_name); | 1456 gaim_privacy_permit_add(account, blist_parser_buddy_name); |
1457 } | 1457 } |
1458 g_free(blist_parser_buddy_name); | 1458 g_free(blist_parser_buddy_name); |
1459 blist_parser_buddy_name = NULL; | 1459 blist_parser_buddy_name = NULL; |
1460 tag_stack = g_list_delete_link(tag_stack, tag_stack); | 1460 tag_stack = g_list_delete_link(tag_stack, tag_stack); |
1461 } else if(!strcmp(element_name, "block")) { | 1461 } else if(!strcmp(element_name, "block")) { |
1462 struct gaim_account *account = gaim_account_find(blist_parser_account_name, | 1462 GaimAccount *account = gaim_account_find(blist_parser_account_name, |
1463 blist_parser_account_protocol); | 1463 blist_parser_account_protocol); |
1464 if(account) { | 1464 if(account) { |
1465 gaim_privacy_deny_add(account, blist_parser_buddy_name); | 1465 gaim_privacy_deny_add(account, blist_parser_buddy_name); |
1466 } | 1466 } |
1467 g_free(blist_parser_buddy_name); | 1467 g_free(blist_parser_buddy_name); |
1656 data_val); | 1656 data_val); |
1657 g_free(key_val); | 1657 g_free(key_val); |
1658 g_free(data_val); | 1658 g_free(data_val); |
1659 } | 1659 } |
1660 | 1660 |
1661 static void gaim_blist_write(FILE *file, struct gaim_account *exp_acct) { | 1661 static void gaim_blist_write(FILE *file, GaimAccount *exp_acct) { |
1662 GSList *accounts, *buds; | 1662 GSList *accounts, *buds; |
1663 GaimBlistNode *gnode,*bnode; | 1663 GaimBlistNode *gnode,*bnode; |
1664 struct group *group; | 1664 struct group *group; |
1665 struct buddy *bud; | 1665 struct buddy *bud; |
1666 fprintf(file, "<?xml version='1.0' encoding='UTF-8' ?>\n"); | 1666 fprintf(file, "<?xml version='1.0' encoding='UTF-8' ?>\n"); |
1726 | 1726 |
1727 fprintf(file, "\t</blist>\n"); | 1727 fprintf(file, "\t</blist>\n"); |
1728 fprintf(file, "\t<privacy>\n"); | 1728 fprintf(file, "\t<privacy>\n"); |
1729 | 1729 |
1730 for(accounts = gaim_accounts; accounts; accounts = accounts->next) { | 1730 for(accounts = gaim_accounts; accounts; accounts = accounts->next) { |
1731 struct gaim_account *account = accounts->data; | 1731 GaimAccount *account = accounts->data; |
1732 char *acct_name = g_markup_escape_text(account->username, -1); | 1732 char *acct_name = g_markup_escape_text(account->username, -1); |
1733 if(!exp_acct || account == exp_acct) { | 1733 if(!exp_acct || account == exp_acct) { |
1734 fprintf(file, "\t\t<account protocol=\"%d\" name=\"%s\" " | 1734 fprintf(file, "\t\t<account protocol=\"%d\" name=\"%s\" " |
1735 "mode=\"%d\">\n", account->protocol, acct_name, account->permdeny); | 1735 "mode=\"%d\">\n", account->protocol, acct_name, account->perm_deny); |
1736 for(buds = account->permit; buds; buds = buds->next) { | 1736 for(buds = account->permit; buds; buds = buds->next) { |
1737 char *bud_name = g_markup_escape_text(buds->data, -1); | 1737 char *bud_name = g_markup_escape_text(buds->data, -1); |
1738 fprintf(file, "\t\t\t<permit>%s</permit>\n", bud_name); | 1738 fprintf(file, "\t\t\t<permit>%s</permit>\n", bud_name); |
1739 g_free(bud_name); | 1739 g_free(bud_name); |
1740 } | 1740 } |
1792 | 1792 |
1793 g_free(filename); | 1793 g_free(filename); |
1794 g_free(filename_real); | 1794 g_free(filename_real); |
1795 } | 1795 } |
1796 | 1796 |
1797 gboolean gaim_privacy_permit_add(struct gaim_account *account, const char *who) { | 1797 gboolean gaim_privacy_permit_add(GaimAccount *account, const char *who) { |
1798 GSList *d = account->permit; | 1798 GSList *d = account->permit; |
1799 char *n = g_strdup(normalize(who)); | 1799 char *n = g_strdup(normalize(who)); |
1800 while(d) { | 1800 while(d) { |
1801 if(!gaim_utf8_strcasecmp(n, normalize(d->data))) | 1801 if(!gaim_utf8_strcasecmp(n, normalize(d->data))) |
1802 break; | 1802 break; |
1809 } | 1809 } |
1810 | 1810 |
1811 return FALSE; | 1811 return FALSE; |
1812 } | 1812 } |
1813 | 1813 |
1814 gboolean gaim_privacy_permit_remove(struct gaim_account *account, const char *who) { | 1814 gboolean gaim_privacy_permit_remove(GaimAccount *account, const char *who) { |
1815 GSList *d = account->permit; | 1815 GSList *d = account->permit; |
1816 char *n = g_strdup(normalize(who)); | 1816 char *n = g_strdup(normalize(who)); |
1817 while(d) { | 1817 while(d) { |
1818 if(!gaim_utf8_strcasecmp(n, normalize(d->data))) | 1818 if(!gaim_utf8_strcasecmp(n, normalize(d->data))) |
1819 break; | 1819 break; |
1826 return TRUE; | 1826 return TRUE; |
1827 } | 1827 } |
1828 return FALSE; | 1828 return FALSE; |
1829 } | 1829 } |
1830 | 1830 |
1831 gboolean gaim_privacy_deny_add(struct gaim_account *account, const char *who) { | 1831 gboolean gaim_privacy_deny_add(GaimAccount *account, const char *who) { |
1832 GSList *d = account->deny; | 1832 GSList *d = account->deny; |
1833 char *n = g_strdup(normalize(who)); | 1833 char *n = g_strdup(normalize(who)); |
1834 while(d) { | 1834 while(d) { |
1835 if(!gaim_utf8_strcasecmp(n, normalize(d->data))) | 1835 if(!gaim_utf8_strcasecmp(n, normalize(d->data))) |
1836 break; | 1836 break; |
1843 } | 1843 } |
1844 | 1844 |
1845 return FALSE; | 1845 return FALSE; |
1846 } | 1846 } |
1847 | 1847 |
1848 gboolean gaim_privacy_deny_remove(struct gaim_account *account, const char *who) { | 1848 gboolean gaim_privacy_deny_remove(GaimAccount *account, const char *who) { |
1849 GSList *d = account->deny; | 1849 GSList *d = account->deny; |
1850 char *n = g_strdup(normalize(who)); | 1850 char *n = g_strdup(normalize(who)); |
1851 while(d) { | 1851 while(d) { |
1852 if(!gaim_utf8_strcasecmp(n, normalize(d->data))) | 1852 if(!gaim_utf8_strcasecmp(n, normalize(d->data))) |
1853 break; | 1853 break; |