src/protocols/jabber/jabber.c

changeset 4687
91ad36873636
parent 4675
8e0a7b537ca2
child 4690
e30dbd5b361f
equal deleted inserted replaced
4686:73697fa39752 4687:91ad36873636
962 */ 962 */
963 static void jabber_remove_gaim_buddy(struct gaim_connection *gc, const char *buddyname) 963 static void jabber_remove_gaim_buddy(struct gaim_connection *gc, const char *buddyname)
964 { 964 {
965 struct buddy *b; 965 struct buddy *b;
966 966
967 if ((b = find_buddy(gc->account, buddyname)) != NULL) { 967 if ((b = gaim_find_buddy(gc->account, buddyname)) != NULL) {
968 debug_printf("removing buddy [1]: %s\n", buddyname); 968 debug_printf("removing buddy [1]: %s\n", buddyname);
969 remove_buddy(b); 969 gaim_blist_remove_buddy(b);
970 gaim_blist_save(); 970 gaim_blist_save();
971 } 971 }
972 } 972 }
973 973
974 static void jabber_change_passwd(struct gaim_connection *gc, const char *old, const char *new) 974 static void jabber_change_passwd(struct gaim_connection *gc, const char *old, const char *new)
1517 static int i = 0x70; 1517 static int i = 0x70;
1518 if ((jc = find_pending_chat(GJ_GC(gjc), gjid)) != NULL) { 1518 if ((jc = find_pending_chat(GJ_GC(gjc), gjid)) != NULL) {
1519 jc->b = cnv = serv_got_joined_chat(GJ_GC(gjc), i++, gjid->user); 1519 jc->b = cnv = serv_got_joined_chat(GJ_GC(gjc), i++, gjid->user);
1520 jc->id = gaim_chat_get_id(GAIM_CHAT(jc->b)); 1520 jc->id = gaim_chat_get_id(GAIM_CHAT(jc->b));
1521 jc->state = JCS_ACTIVE; 1521 jc->state = JCS_ACTIVE;
1522 } else if ((b = find_buddy(GJ_GC(gjc)->account, buddy)) == NULL) { 1522 } else if ((b = gaim_find_buddy(GJ_GC(gjc)->account, buddy)) == NULL) {
1523 g_free(buddy); 1523 g_free(buddy);
1524 gaim_jid_free(gjid); 1524 gaim_jid_free(gjid);
1525 return; 1525 return;
1526 } 1526 }
1527 } 1527 }
1622 jabber_accept_deny_add(jap, "subscribed"); 1622 jabber_accept_deny_add(jap, "subscribed");
1623 /* 1623 /*
1624 * If we don't already have the buddy on *our* buddylist, 1624 * If we don't already have the buddy on *our* buddylist,
1625 * ask if we want him or her added. 1625 * ask if we want him or her added.
1626 */ 1626 */
1627 if(find_buddy(jap->gc->account, jap->user) == NULL) { 1627 if(gaim_find_buddy(jap->gc->account, jap->user) == NULL) {
1628 show_got_added(jap->gc, NULL, jap->user, NULL, NULL); 1628 show_got_added(jap->gc, NULL, jap->user, NULL, NULL);
1629 } 1629 }
1630 } 1630 }
1631 1631
1632 g_free(jap->user); 1632 g_free(jap->user);
1769 1769
1770 /* 1770 /*
1771 * Add or remove a buddy? Change buddy's alias or group? 1771 * Add or remove a buddy? Change buddy's alias or group?
1772 */ 1772 */
1773 if (BUD_SUB_TO_PEND(sub, ask) || BUD_SUBD_TO(sub, ask)) { 1773 if (BUD_SUB_TO_PEND(sub, ask) || BUD_SUBD_TO(sub, ask)) {
1774 if ((b = find_buddy(GJ_GC(gjc)->account, buddyname)) == NULL) { 1774 if ((b = gaim_find_buddy(GJ_GC(gjc)->account, buddyname)) == NULL) {
1775 struct buddy *b = gaim_buddy_new(GJ_GC(gjc)->account, buddyname, name ? name : NULL);
1776 struct group *g;
1777 if (groupname) {
1778 if (!(g = gaim_find_group(groupname)))
1779 g = gaim_group_new(groupname);
1780 } else
1781 g = gaim_group_new(_("Buddies"));
1775 debug_printf("adding buddy [4]: %s\n", buddyname); 1782 debug_printf("adding buddy [4]: %s\n", buddyname);
1776 b = add_buddy(GJ_GC(gjc)->account, 1783 gaim_blist_add_buddy(b, g, NULL);
1777 groupname ? groupname : _("Buddies"), buddyname,
1778 name ? name : buddyname);
1779 gaim_blist_save(); 1784 gaim_blist_save();
1780 } else { 1785 } else {
1781 struct group *c_grp = find_group_by_buddy(b); 1786 struct group *c_grp = gaim_find_buddys_group(b);
1782 1787
1783 /* 1788 /*
1784 * If the buddy's in a new group or his/her alias is changed... 1789 * If the buddy's in a new group or his/her alias is changed...
1785 */ 1790 */
1786 if(groupname && c_grp && strcmp(c_grp->name, groupname)) { 1791 if(groupname && c_grp && strcmp(c_grp->name, groupname)) {
1790 int signon = b->signon; 1795 int signon = b->signon;
1791 1796
1792 /* 1797 /*
1793 * seems rude, but it seems to be the only way... 1798 * seems rude, but it seems to be the only way...
1794 */ 1799 */
1795 remove_buddy(b); 1800 gaim_blist_remove_buddy(b);
1796 b = add_buddy(GJ_GC(gjc)->account, groupname, buddyname, 1801 b = gaim_buddy_new(GJ_GC(gjc)->account, buddyname, name ? name : NULL);
1797 name ? name : buddyname); 1802 gaim_blist_add_buddy(b, gaim_find_group(groupname), NULL);
1798 gaim_blist_save(); 1803 gaim_blist_save();
1799 if(present) { 1804 if(present) {
1800 serv_got_update(GJ_GC(gjc), buddyname, 1, 0, signon, idle, 1805 serv_got_update(GJ_GC(gjc), buddyname, 1, 0, signon, idle,
1801 uc, 0); 1806 uc, 0);
1802 } 1807 }
1803 } else if(name != NULL && strcmp(b->alias, name)) { 1808 } else if(name != NULL && strcmp(b->alias, name)) {
1804 g_snprintf(b->alias, sizeof(b->alias), "%s", name); 1809 g_snprintf(b->alias, sizeof(b->alias), "%s", name);
1805 handle_buddy_rename(b, buddyname); 1810 gaim_blist_rename_buddy(b, buddyname);
1806 gaim_blist_save(); 1811 gaim_blist_save();
1807 } 1812 }
1808 } 1813 }
1809 } else if (BUD_USUB_TO_PEND(sub, ask) || BUD_USUBD_TO(sub, ask) || !strcasecmp(sub, "remove")) { 1814 } else if (BUD_USUB_TO_PEND(sub, ask) || BUD_USUBD_TO(sub, ask) || !strcasecmp(sub, "remove")) {
1810 jabber_remove_gaim_buddy(GJ_GC(gjc), buddyname); 1815 jabber_remove_gaim_buddy(GJ_GC(gjc), buddyname);
2492 2497
2493 x = jutil_iqnew(JPACKET__SET, NS_ROSTER); 2498 x = jutil_iqnew(JPACKET__SET, NS_ROSTER);
2494 y = xmlnode_insert_tag(xmlnode_get_tag(x, "query"), "item"); 2499 y = xmlnode_insert_tag(xmlnode_get_tag(x, "query"), "item");
2495 xmlnode_put_attrib(y, "jid", realwho); 2500 xmlnode_put_attrib(y, "jid", realwho);
2496 2501
2497 buddy = find_buddy(gc->account, realwho); 2502 buddy = gaim_find_buddy(gc->account, realwho);
2498 2503
2499 /* 2504 /*
2500 * See if there's an explict (new?) alias for the buddy or we can pull 2505 * See if there's an explict (new?) alias for the buddy or we can pull
2501 * one out of current Gaim buddylist data for him. 2506 * one out of current Gaim buddylist data for him.
2502 */ 2507 */
2518 * See if there's an explict (new?) group for the buddy or pull 2523 * See if there's an explict (new?) group for the buddy or pull
2519 * one out of current Gaim buddylist data for him. 2524 * one out of current Gaim buddylist data for him.
2520 */ 2525 */
2521 if(group && group[0] != '\0') { 2526 if(group && group[0] != '\0') {
2522 my_group = group; 2527 my_group = group;
2523 } else if((buddy_group = find_group_by_buddy(buddy)) != NULL) { 2528 } else if((buddy_group = gaim_find_buddys_group(buddy)) != NULL) {
2524 my_group = buddy_group->name; 2529 my_group = buddy_group->name;
2525 } 2530 }
2526 2531
2527 /* 2532 /*
2528 * Send what group the buddy's in along with the roster item. 2533 * Send what group the buddy's in along with the roster item.
2760 2765
2761 if(jd->buddies != NULL) 2766 if(jd->buddies != NULL)
2762 g_hash_table_foreach(jd->buddies, set_invisible_to_buddy_status, (gpointer) invisible); 2767 g_hash_table_foreach(jd->buddies, set_invisible_to_buddy_status, (gpointer) invisible);
2763 } 2768 }
2764 2769
2765 static char **jabber_list_icon(int uc) 2770 static const char *jabber_list_icon(struct gaim_account *a, struct buddy *b)
2766 { 2771 {
2772 return "jabber";
2773 }
2774 /*
2767 switch (uc) { 2775 switch (uc) {
2768 case UC_AWAY: 2776 case UC_AWAY:
2769 return available_away_xpm; 2777 return available_away_xpm;
2770 case UC_CHAT: 2778 case UC_CHAT:
2771 return available_chat_xpm; 2779 return available_chat_xpm;
2776 case UC_ERROR: 2784 case UC_ERROR:
2777 return available_error_xpm; 2785 return available_error_xpm;
2778 default: 2786 default:
2779 return available_xpm; 2787 return available_xpm;
2780 } 2788 }
2781 } 2789 }*/
2782 2790
2783 static GList *jabber_chat_info(struct gaim_connection *gc) 2791 static GList *jabber_chat_info(struct gaim_connection *gc)
2784 { 2792 {
2785 gjconn gjc = ((struct jabber_data *)gc->proto_data)->gjc; 2793 gjconn gjc = ((struct jabber_data *)gc->proto_data)->gjc;
2786 2794
2895 debug_printf("joining completely new Jabber chat\n"); 2903 debug_printf("joining completely new Jabber chat\n");
2896 jc = g_new0(struct jabber_chat, 1); 2904 jc = g_new0(struct jabber_chat, 1);
2897 jc->gjid = gjid; 2905 jc->gjid = gjid;
2898 jc->gc = gc; 2906 jc->gc = gc;
2899 ((struct jabber_data *)gc->proto_data)->chats = g_slist_append(jcs, jc); 2907 ((struct jabber_data *)gc->proto_data)->chats = g_slist_append(jcs, jc);
2900 add_buddy(gc->account, _("Chats"), realwho, realwho); 2908 // add_buddy(gc->account, _("Chats"), realwho, realwho);
2901 } 2909 }
2902 2910
2903 jc->state = JCS_PENDING; 2911 jc->state = JCS_PENDING;
2904 2912
2905 x = jutil_presnew(0, realwho, NULL); 2913 x = jutil_presnew(0, realwho, NULL);
3200 } 3208 }
3201 3209
3202 static GList *jabber_buddy_menu(struct gaim_connection *gc, char *who) { 3210 static GList *jabber_buddy_menu(struct gaim_connection *gc, char *who) {
3203 GList *m = NULL; 3211 GList *m = NULL;
3204 struct proto_buddy_menu *pbm; 3212 struct proto_buddy_menu *pbm;
3205 struct buddy *b = find_buddy(gc->account, who); 3213 struct buddy *b = gaim_find_buddy(gc->account, who);
3206 3214
3207 if(b->uc == UC_ERROR) 3215 if(b->uc == UC_ERROR)
3208 { 3216 {
3209 pbm = g_new0(struct proto_buddy_menu, 1); 3217 pbm = g_new0(struct proto_buddy_menu, 1);
3210 pbm->label = _("View Error Msg"); 3218 pbm->label = _("View Error Msg");

mercurial