Mercurial > pidgin
comparison src/protocols/jabber/jabber.c @ 4349:0c68d402f59f
[gaim-migrate @ 4614]
XML Blist
Gaim stores all the buddy lists in one big happy file now. You can order
the buddies however you want, and they'll stay ordered that way.
We can also store some per-buddy information now, which will be cool.
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Sun, 19 Jan 2003 22:16:52 +0000 |
parents | cc2f780c0505 |
children | 367fc70fe4f7 |
comparison
equal
deleted
inserted
replaced
4348:922b66840a51 | 4349:0c68d402f59f |
---|---|
955 */ | 955 */ |
956 static void jabber_remove_gaim_buddy(struct gaim_connection *gc, const char *buddyname) | 956 static void jabber_remove_gaim_buddy(struct gaim_connection *gc, const char *buddyname) |
957 { | 957 { |
958 struct buddy *b; | 958 struct buddy *b; |
959 | 959 |
960 if ((b = find_buddy(gc, buddyname)) != NULL) { | 960 if ((b = find_buddy(gc->user, buddyname)) != NULL) { |
961 struct group *group; | 961 debug_printf("removing buddy [1]: %s\n", buddyname); |
962 | 962 remove_buddy(b); |
963 group = find_group_by_buddy(gc, buddyname); | 963 gaim_blist_save(); |
964 debug_printf("removing buddy [1]: %s, from group: %s\n", buddyname, group->name); | |
965 remove_buddy(gc, group, b); | |
966 do_export(gc); | |
967 } | 964 } |
968 } | 965 } |
969 | 966 |
970 static void jabber_change_passwd(struct gaim_connection *gc, const char *old, const char *new) | 967 static void jabber_change_passwd(struct gaim_connection *gc, const char *old, const char *new) |
971 { | 968 { |
1509 static int i = 0x70; | 1506 static int i = 0x70; |
1510 if ((jc = find_pending_chat(GJ_GC(gjc), gjid)) != NULL) { | 1507 if ((jc = find_pending_chat(GJ_GC(gjc), gjid)) != NULL) { |
1511 jc->b = cnv = serv_got_joined_chat(GJ_GC(gjc), i++, gjid->user); | 1508 jc->b = cnv = serv_got_joined_chat(GJ_GC(gjc), i++, gjid->user); |
1512 jc->id = jc->b->id; | 1509 jc->id = jc->b->id; |
1513 jc->state = JCS_ACTIVE; | 1510 jc->state = JCS_ACTIVE; |
1514 } else if ((b = find_buddy(GJ_GC(gjc), buddy)) == NULL) { | 1511 } else if ((b = find_buddy(GJ_GC(gjc)->user, buddy)) == NULL) { |
1515 g_free(buddy); | 1512 g_free(buddy); |
1516 gaim_jid_free(gjid); | 1513 gaim_jid_free(gjid); |
1517 return; | 1514 return; |
1518 } | 1515 } |
1519 } | 1516 } |
1613 jabber_accept_deny_add(jap, "subscribed"); | 1610 jabber_accept_deny_add(jap, "subscribed"); |
1614 /* | 1611 /* |
1615 * If we don't already have the buddy on *our* buddylist, | 1612 * If we don't already have the buddy on *our* buddylist, |
1616 * ask if we want him or her added. | 1613 * ask if we want him or her added. |
1617 */ | 1614 */ |
1618 if(find_buddy(jap->gc, jap->user) == NULL) { | 1615 if(find_buddy(jap->gc->user, jap->user) == NULL) { |
1619 show_got_added(jap->gc, NULL, jap->user, NULL, NULL); | 1616 show_got_added(jap->gc, NULL, jap->user, NULL, NULL); |
1620 } | 1617 } |
1621 } | 1618 } |
1622 | 1619 |
1623 g_free(jap->user); | 1620 g_free(jap->user); |
1760 | 1757 |
1761 /* | 1758 /* |
1762 * Add or remove a buddy? Change buddy's alias or group? | 1759 * Add or remove a buddy? Change buddy's alias or group? |
1763 */ | 1760 */ |
1764 if (BUD_SUB_TO_PEND(sub, ask) || BUD_SUBD_TO(sub, ask)) { | 1761 if (BUD_SUB_TO_PEND(sub, ask) || BUD_SUBD_TO(sub, ask)) { |
1765 if ((b = find_buddy(GJ_GC(gjc), buddyname)) == NULL) { | 1762 if ((b = find_buddy(GJ_GC(gjc)->user, buddyname)) == NULL) { |
1766 debug_printf("adding buddy [4]: %s\n", buddyname); | 1763 debug_printf("adding buddy [4]: %s\n", buddyname); |
1767 b = add_buddy(GJ_GC(gjc), groupname ? groupname : _("Buddies"), buddyname, | 1764 b = add_buddy(GJ_GC(gjc)->user, groupname ? groupname : _("Buddies"), buddyname, |
1768 name ? name : buddyname); | 1765 name ? name : buddyname); |
1769 do_export(GJ_GC(gjc)); | 1766 gaim_blist_save(); |
1770 } else { | 1767 } else { |
1771 struct group *c_grp = find_group_by_buddy(GJ_GC(gjc), buddyname); | 1768 struct group *c_grp = find_group_by_buddy(b); |
1772 | 1769 |
1773 /* | 1770 /* |
1774 * If the buddy's in a new group or his/her alias is changed... | 1771 * If the buddy's in a new group or his/her alias is changed... |
1775 */ | 1772 */ |
1776 if(groupname && c_grp && strcmp(c_grp->name, groupname)) { | 1773 if(groupname && c_grp && strcmp(c_grp->name, groupname)) { |
1780 int signon = b->signon; | 1777 int signon = b->signon; |
1781 | 1778 |
1782 /* | 1779 /* |
1783 * seems rude, but it seems to be the only way... | 1780 * seems rude, but it seems to be the only way... |
1784 */ | 1781 */ |
1785 remove_buddy(GJ_GC(gjc), c_grp, b); | 1782 remove_buddy(b); |
1786 b = add_buddy(GJ_GC(gjc), groupname, buddyname, | 1783 b = add_buddy(GJ_GC(gjc)->user, groupname, buddyname, |
1787 name ? name : buddyname); | 1784 name ? name : buddyname); |
1788 do_export(GJ_GC(gjc)); | 1785 gaim_blist_save(); |
1789 if(present) { | 1786 if(present) { |
1790 serv_got_update(GJ_GC(gjc), buddyname, 1, 0, signon, idle, | 1787 serv_got_update(GJ_GC(gjc), buddyname, 1, 0, signon, idle, |
1791 uc, 0); | 1788 uc, 0); |
1792 } | 1789 } |
1793 } else if(name != NULL && strcmp(b->alias, name)) { | 1790 } else if(name != NULL && strcmp(b->alias, name)) { |
1794 g_snprintf(b->alias, sizeof(b->alias), "%s", name); | 1791 g_snprintf(b->alias, sizeof(b->alias), "%s", name); |
1795 handle_buddy_rename(b, buddyname); | 1792 handle_buddy_rename(b, buddyname); |
1796 do_export(GJ_GC(gjc)); | 1793 gaim_blist_save(); |
1797 } | 1794 } |
1798 } | 1795 } |
1799 } else if (BUD_USUB_TO_PEND(sub, ask) || BUD_USUBD_TO(sub, ask) || !strcasecmp(sub, "remove")) { | 1796 } else if (BUD_USUB_TO_PEND(sub, ask) || BUD_USUBD_TO(sub, ask) || !strcasecmp(sub, "remove")) { |
1800 jabber_remove_gaim_buddy(GJ_GC(gjc), buddyname); | 1797 jabber_remove_gaim_buddy(GJ_GC(gjc), buddyname); |
1801 } | 1798 } |
1833 } else { | 1830 } else { |
1834 debug_printf("auth success\n"); | 1831 debug_printf("auth success\n"); |
1835 | 1832 |
1836 account_online(GJ_GC(gjc)); | 1833 account_online(GJ_GC(gjc)); |
1837 serv_finish_login(GJ_GC(gjc)); | 1834 serv_finish_login(GJ_GC(gjc)); |
1838 | |
1839 if (bud_list_cache_exists(GJ_GC(gjc))) | |
1840 do_import(GJ_GC(gjc), NULL); | |
1841 | 1835 |
1842 ((struct jabber_data *)GJ_GC(gjc)->proto_data)->did_import = TRUE; | 1836 ((struct jabber_data *)GJ_GC(gjc)->proto_data)->did_import = TRUE; |
1843 | 1837 |
1844 gjab_reqroster(gjc); | 1838 gjab_reqroster(gjc); |
1845 } | 1839 } |
2526 | 2520 |
2527 x = jutil_iqnew(JPACKET__SET, NS_ROSTER); | 2521 x = jutil_iqnew(JPACKET__SET, NS_ROSTER); |
2528 y = xmlnode_insert_tag(xmlnode_get_tag(x, "query"), "item"); | 2522 y = xmlnode_insert_tag(xmlnode_get_tag(x, "query"), "item"); |
2529 xmlnode_put_attrib(y, "jid", realwho); | 2523 xmlnode_put_attrib(y, "jid", realwho); |
2530 | 2524 |
2525 buddy = find_buddy(gc->user, realwho); | |
2526 | |
2531 /* | 2527 /* |
2532 * See if there's an explict (new?) alias for the buddy or we can pull | 2528 * See if there's an explict (new?) alias for the buddy or we can pull |
2533 * one out of current Gaim buddylist data for him. | 2529 * one out of current Gaim buddylist data for him. |
2534 */ | 2530 */ |
2535 if(alias && alias[0] != '\0') { | 2531 if(alias && alias[0] != '\0') { |
2536 my_alias = alias; | 2532 my_alias = alias; |
2537 } else if((buddy = find_buddy(gc, realwho)) != NULL && buddy->alias[0]) { | 2533 } else if(buddy && buddy->alias[0]) { |
2538 my_alias = buddy->alias; | 2534 my_alias = buddy->alias; |
2539 } | 2535 } |
2540 | 2536 |
2541 /* If there's an alias for the buddy, it's not 0-length | 2537 /* If there's an alias for the buddy, it's not 0-length |
2542 * and it doesn't match his JID, add the "name" attribute. | 2538 * and it doesn't match his JID, add the "name" attribute. |
2550 * See if there's an explict (new?) group for the buddy or pull | 2546 * See if there's an explict (new?) group for the buddy or pull |
2551 * one out of current Gaim buddylist data for him. | 2547 * one out of current Gaim buddylist data for him. |
2552 */ | 2548 */ |
2553 if(group && group[0] != '\0') { | 2549 if(group && group[0] != '\0') { |
2554 my_group = group; | 2550 my_group = group; |
2555 } else if((buddy_group = find_group_by_buddy(gc, realwho)) != NULL) { | 2551 } else if((buddy_group = find_group_by_buddy(buddy)) != NULL) { |
2556 my_group = buddy_group->name; | 2552 my_group = buddy_group->name; |
2557 } | 2553 } |
2558 | 2554 |
2559 /* | 2555 /* |
2560 * Send what group the buddy's in along with the roster item. | 2556 * Send what group the buddy's in along with the roster item. |
2927 debug_printf("joining completely new Jabber chat\n"); | 2923 debug_printf("joining completely new Jabber chat\n"); |
2928 jc = g_new0(struct jabber_chat, 1); | 2924 jc = g_new0(struct jabber_chat, 1); |
2929 jc->gjid = gjid; | 2925 jc->gjid = gjid; |
2930 jc->gc = gc; | 2926 jc->gc = gc; |
2931 ((struct jabber_data *)gc->proto_data)->chats = g_slist_append(jcs, jc); | 2927 ((struct jabber_data *)gc->proto_data)->chats = g_slist_append(jcs, jc); |
2932 add_buddy(gc, _("Chats"), realwho, realwho); | 2928 add_buddy(gc->user, _("Chats"), realwho, realwho); |
2933 } | 2929 } |
2934 | 2930 |
2935 jc->state = JCS_PENDING; | 2931 jc->state = JCS_PENDING; |
2936 | 2932 |
2937 x = jutil_presnew(0, realwho, NULL); | 2933 x = jutil_presnew(0, realwho, NULL); |
3229 } | 3225 } |
3230 | 3226 |
3231 static GList *jabber_buddy_menu(struct gaim_connection *gc, char *who) { | 3227 static GList *jabber_buddy_menu(struct gaim_connection *gc, char *who) { |
3232 GList *m = NULL; | 3228 GList *m = NULL; |
3233 struct proto_buddy_menu *pbm; | 3229 struct proto_buddy_menu *pbm; |
3234 struct buddy *b = find_buddy(gc, who); | 3230 struct buddy *b = find_buddy(gc->user, who); |
3235 | 3231 |
3236 if(b->uc == UC_ERROR) | 3232 if(b->uc == UC_ERROR) |
3237 { | 3233 { |
3238 pbm = g_new0(struct proto_buddy_menu, 1); | 3234 pbm = g_new0(struct proto_buddy_menu, 1); |
3239 pbm->label = _("View Error Msg"); | 3235 pbm->label = _("View Error Msg"); |