Fri, 10 Mar 2017 20:36:55 -0600
Merge 2.12.0 into default
| 7014 | 1 | /* |
| 15884 | 2 | * purple - Jabber Protocol Plugin |
| 7014 | 3 | * |
|
28322
ac8fec1d2234
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents:
28071
diff
changeset
|
4 | * Purple is the legal property of its developers, whose names are too numerous |
|
ac8fec1d2234
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents:
28071
diff
changeset
|
5 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
ac8fec1d2234
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents:
28071
diff
changeset
|
6 | * source distribution. |
| 7014 | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify | |
| 9 | * it under the terms of the GNU General Public License as published by | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 19 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19630
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 7014 | 21 | * |
| 22 | */ | |
| 23 | #include "internal.h" | |
| 24 | #include "debug.h" | |
| 25 | #include "server.h" | |
| 13809 | 26 | #include "util.h" |
| 7014 | 27 | |
| 28 | #include "buddy.h" | |
|
28431
8450418b5abd
jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <darkrain42@pidgin.im>
parents:
28322
diff
changeset
|
29 | #include "chat.h" |
|
29913
58f5122fbcd3
First shot at refactoring the Google-specific XMPP code.
Marcus Lundblad <malu@pidgin.im>
parents:
29373
diff
changeset
|
30 | #include "google/google.h" |
|
58f5122fbcd3
First shot at refactoring the Google-specific XMPP code.
Marcus Lundblad <malu@pidgin.im>
parents:
29373
diff
changeset
|
31 | #include "google/google_roster.h" |
| 7014 | 32 | #include "presence.h" |
| 33 | #include "roster.h" | |
| 34 | #include "iq.h" | |
| 35 | ||
| 36 | #include <string.h> | |
| 37 | ||
|
27282
791c6a965694
Debug output when changing group memberships.
Paul Aurich <darkrain42@pidgin.im>
parents:
27281
diff
changeset
|
38 | /* Take a list of strings and join them with a ", " separator */ |
|
791c6a965694
Debug output when changing group memberships.
Paul Aurich <darkrain42@pidgin.im>
parents:
27281
diff
changeset
|
39 | static gchar *roster_groups_join(GSList *list) |
|
791c6a965694
Debug output when changing group memberships.
Paul Aurich <darkrain42@pidgin.im>
parents:
27281
diff
changeset
|
40 | { |
|
791c6a965694
Debug output when changing group memberships.
Paul Aurich <darkrain42@pidgin.im>
parents:
27281
diff
changeset
|
41 | GString *out = g_string_new(NULL); |
|
791c6a965694
Debug output when changing group memberships.
Paul Aurich <darkrain42@pidgin.im>
parents:
27281
diff
changeset
|
42 | for ( ; list; list = list->next) { |
|
791c6a965694
Debug output when changing group memberships.
Paul Aurich <darkrain42@pidgin.im>
parents:
27281
diff
changeset
|
43 | out = g_string_append(out, (const char *)list->data); |
|
791c6a965694
Debug output when changing group memberships.
Paul Aurich <darkrain42@pidgin.im>
parents:
27281
diff
changeset
|
44 | if (list->next) |
|
791c6a965694
Debug output when changing group memberships.
Paul Aurich <darkrain42@pidgin.im>
parents:
27281
diff
changeset
|
45 | out = g_string_append(out, ", "); |
|
791c6a965694
Debug output when changing group memberships.
Paul Aurich <darkrain42@pidgin.im>
parents:
27281
diff
changeset
|
46 | } |
|
791c6a965694
Debug output when changing group memberships.
Paul Aurich <darkrain42@pidgin.im>
parents:
27281
diff
changeset
|
47 | |
|
791c6a965694
Debug output when changing group memberships.
Paul Aurich <darkrain42@pidgin.im>
parents:
27281
diff
changeset
|
48 | return g_string_free(out, FALSE); |
|
791c6a965694
Debug output when changing group memberships.
Paul Aurich <darkrain42@pidgin.im>
parents:
27281
diff
changeset
|
49 | } |
|
791c6a965694
Debug output when changing group memberships.
Paul Aurich <darkrain42@pidgin.im>
parents:
27281
diff
changeset
|
50 | |
|
29096
362b96f6f3da
jabber: Roster Versioning support.
Paul Aurich <darkrain42@pidgin.im>
parents:
28758
diff
changeset
|
51 | static void roster_request_cb(JabberStream *js, const char *from, |
|
362b96f6f3da
jabber: Roster Versioning support.
Paul Aurich <darkrain42@pidgin.im>
parents:
28758
diff
changeset
|
52 | JabberIqType type, const char *id, |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
53 | PurpleXmlNode *packet, gpointer data) |
|
29096
362b96f6f3da
jabber: Roster Versioning support.
Paul Aurich <darkrain42@pidgin.im>
parents:
28758
diff
changeset
|
54 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
55 | PurpleXmlNode *query; |
|
29096
362b96f6f3da
jabber: Roster Versioning support.
Paul Aurich <darkrain42@pidgin.im>
parents:
28758
diff
changeset
|
56 | |
|
362b96f6f3da
jabber: Roster Versioning support.
Paul Aurich <darkrain42@pidgin.im>
parents:
28758
diff
changeset
|
57 | if (type == JABBER_IQ_ERROR) { |
|
362b96f6f3da
jabber: Roster Versioning support.
Paul Aurich <darkrain42@pidgin.im>
parents:
28758
diff
changeset
|
58 | /* |
|
362b96f6f3da
jabber: Roster Versioning support.
Paul Aurich <darkrain42@pidgin.im>
parents:
28758
diff
changeset
|
59 | * This shouldn't happen in any real circumstances and |
|
362b96f6f3da
jabber: Roster Versioning support.
Paul Aurich <darkrain42@pidgin.im>
parents:
28758
diff
changeset
|
60 | * likely constitutes a server-side misconfiguration (i.e. |
|
362b96f6f3da
jabber: Roster Versioning support.
Paul Aurich <darkrain42@pidgin.im>
parents:
28758
diff
changeset
|
61 | * explicitly not loading mod_roster...) |
|
362b96f6f3da
jabber: Roster Versioning support.
Paul Aurich <darkrain42@pidgin.im>
parents:
28758
diff
changeset
|
62 | */ |
|
362b96f6f3da
jabber: Roster Versioning support.
Paul Aurich <darkrain42@pidgin.im>
parents:
28758
diff
changeset
|
63 | purple_debug_error("jabber", "Error retrieving roster!?\n"); |
|
362b96f6f3da
jabber: Roster Versioning support.
Paul Aurich <darkrain42@pidgin.im>
parents:
28758
diff
changeset
|
64 | jabber_stream_set_state(js, JABBER_STREAM_CONNECTED); |
|
362b96f6f3da
jabber: Roster Versioning support.
Paul Aurich <darkrain42@pidgin.im>
parents:
28758
diff
changeset
|
65 | return; |
|
362b96f6f3da
jabber: Roster Versioning support.
Paul Aurich <darkrain42@pidgin.im>
parents:
28758
diff
changeset
|
66 | } |
|
362b96f6f3da
jabber: Roster Versioning support.
Paul Aurich <darkrain42@pidgin.im>
parents:
28758
diff
changeset
|
67 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
68 | query = purple_xmlnode_get_child(packet, "query"); |
|
29096
362b96f6f3da
jabber: Roster Versioning support.
Paul Aurich <darkrain42@pidgin.im>
parents:
28758
diff
changeset
|
69 | if (query == NULL) { |
|
362b96f6f3da
jabber: Roster Versioning support.
Paul Aurich <darkrain42@pidgin.im>
parents:
28758
diff
changeset
|
70 | jabber_stream_set_state(js, JABBER_STREAM_CONNECTED); |
|
362b96f6f3da
jabber: Roster Versioning support.
Paul Aurich <darkrain42@pidgin.im>
parents:
28758
diff
changeset
|
71 | return; |
|
362b96f6f3da
jabber: Roster Versioning support.
Paul Aurich <darkrain42@pidgin.im>
parents:
28758
diff
changeset
|
72 | } |
|
362b96f6f3da
jabber: Roster Versioning support.
Paul Aurich <darkrain42@pidgin.im>
parents:
28758
diff
changeset
|
73 | |
|
362b96f6f3da
jabber: Roster Versioning support.
Paul Aurich <darkrain42@pidgin.im>
parents:
28758
diff
changeset
|
74 | jabber_roster_parse(js, from, type, id, query); |
|
362b96f6f3da
jabber: Roster Versioning support.
Paul Aurich <darkrain42@pidgin.im>
parents:
28758
diff
changeset
|
75 | jabber_stream_set_state(js, JABBER_STREAM_CONNECTED); |
|
362b96f6f3da
jabber: Roster Versioning support.
Paul Aurich <darkrain42@pidgin.im>
parents:
28758
diff
changeset
|
76 | } |
|
362b96f6f3da
jabber: Roster Versioning support.
Paul Aurich <darkrain42@pidgin.im>
parents:
28758
diff
changeset
|
77 | |
| 7014 | 78 | void jabber_roster_request(JabberStream *js) |
| 79 | { | |
| 80 | JabberIq *iq; | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
81 | PurpleXmlNode *query; |
|
29096
362b96f6f3da
jabber: Roster Versioning support.
Paul Aurich <darkrain42@pidgin.im>
parents:
28758
diff
changeset
|
82 | |
| 7014 | 83 | iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:roster"); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
84 | query = purple_xmlnode_get_child(iq->node, "query"); |
|
29103
aefa3f414775
jabber: The google roster request code was so lonely, so let's just drop-kick it and add the little custom logic to roster.c
Paul Aurich <darkrain42@pidgin.im>
parents:
29096
diff
changeset
|
85 | |
|
aefa3f414775
jabber: The google roster request code was so lonely, so let's just drop-kick it and add the little custom logic to roster.c
Paul Aurich <darkrain42@pidgin.im>
parents:
29096
diff
changeset
|
86 | if (js->server_caps & JABBER_CAP_GOOGLE_ROSTER) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
87 | purple_xmlnode_set_attrib(query, "xmlns:gr", NS_GOOGLE_ROSTER); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
88 | purple_xmlnode_set_attrib(query, "gr:ext", "2"); |
|
29103
aefa3f414775
jabber: The google roster request code was so lonely, so let's just drop-kick it and add the little custom logic to roster.c
Paul Aurich <darkrain42@pidgin.im>
parents:
29096
diff
changeset
|
89 | } |
|
aefa3f414775
jabber: The google roster request code was so lonely, so let's just drop-kick it and add the little custom logic to roster.c
Paul Aurich <darkrain42@pidgin.im>
parents:
29096
diff
changeset
|
90 | |
|
29096
362b96f6f3da
jabber: Roster Versioning support.
Paul Aurich <darkrain42@pidgin.im>
parents:
28758
diff
changeset
|
91 | jabber_iq_set_callback(iq, roster_request_cb, NULL); |
| 7014 | 92 | jabber_iq_send(iq); |
| 93 | } | |
| 94 | ||
| 15884 | 95 | static void remove_purple_buddies(JabberStream *js, const char *jid) |
| 7014 | 96 | { |
| 97 | GSList *buddies, *l; | |
| 98 | ||
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34717
diff
changeset
|
99 | buddies = purple_blist_find_buddies(purple_connection_get_account(js->gc), jid); |
| 7014 | 100 | |
| 101 | for(l = buddies; l; l = l->next) | |
| 15884 | 102 | purple_blist_remove_buddy(l->data); |
| 7014 | 103 | |
| 104 | g_slist_free(buddies); | |
| 105 | } | |
| 106 | ||
|
27277
8a2ecbdd70e4
Various roster cleanups. Refs #7008.
Paul Aurich <darkrain42@pidgin.im>
parents:
27276
diff
changeset
|
107 | static void add_purple_buddy_to_groups(JabberStream *js, const char *jid, |
|
28071
a0706162fefd
jabber: Store the "own JabberBuddy" in the JabberStream* struct.
Paul Aurich <darkrain42@pidgin.im>
parents:
27743
diff
changeset
|
108 | const char *alias, GSList *groups) |
| 7014 | 109 | { |
|
27277
8a2ecbdd70e4
Various roster cleanups. Refs #7008.
Paul Aurich <darkrain42@pidgin.im>
parents:
27276
diff
changeset
|
110 | GSList *buddies, *l; |
|
28758
6fb73f2ab8e2
jabber: Remove the roster pool stuff.
Paul Aurich <darkrain42@pidgin.im>
parents:
28622
diff
changeset
|
111 | PurpleAccount *account = purple_connection_get_account(js->gc); |
| 7014 | 112 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34717
diff
changeset
|
113 | buddies = purple_blist_find_buddies(purple_connection_get_account(js->gc), jid); |
| 7014 | 114 | |
| 115 | if(!groups) { | |
|
35958
1d8446f396b6
blist: define default group better
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
116 | if(!buddies) { |
|
36009
4db2936dd842
Backport 407e0fa6f7d1: don't split contacts on default group (xmpp)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31794
diff
changeset
|
117 | groups = g_slist_append(groups, g_strdup(JABBER_ROSTER_DEFAULT_GROUP)); |
|
35958
1d8446f396b6
blist: define default group better
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
118 | } else { |
|
27277
8a2ecbdd70e4
Various roster cleanups. Refs #7008.
Paul Aurich <darkrain42@pidgin.im>
parents:
27276
diff
changeset
|
119 | /* TODO: What should we do here? Removing the local buddies |
|
8a2ecbdd70e4
Various roster cleanups. Refs #7008.
Paul Aurich <darkrain42@pidgin.im>
parents:
27276
diff
changeset
|
120 | * is wrong, but so is letting the group state get out of sync with |
|
8a2ecbdd70e4
Various roster cleanups. Refs #7008.
Paul Aurich <darkrain42@pidgin.im>
parents:
27276
diff
changeset
|
121 | * the server. |
|
8a2ecbdd70e4
Various roster cleanups. Refs #7008.
Paul Aurich <darkrain42@pidgin.im>
parents:
27276
diff
changeset
|
122 | */ |
|
20221
28e31ee832cd
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
123 | g_slist_free(buddies); |
| 7014 | 124 | return; |
|
20221
28e31ee832cd
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
125 | } |
| 7014 | 126 | } |
| 127 | ||
| 128 | while(buddies) { | |
| 15884 | 129 | PurpleBuddy *b = buddies->data; |
| 130 | PurpleGroup *g = purple_buddy_get_group(b); | |
| 7014 | 131 | |
|
27277
8a2ecbdd70e4
Various roster cleanups. Refs #7008.
Paul Aurich <darkrain42@pidgin.im>
parents:
27276
diff
changeset
|
132 | buddies = g_slist_delete_link(buddies, buddies); |
| 7014 | 133 | |
|
27277
8a2ecbdd70e4
Various roster cleanups. Refs #7008.
Paul Aurich <darkrain42@pidgin.im>
parents:
27276
diff
changeset
|
134 | /* XMPP groups are case-sensitive, but libpurple groups are |
|
8a2ecbdd70e4
Various roster cleanups. Refs #7008.
Paul Aurich <darkrain42@pidgin.im>
parents:
27276
diff
changeset
|
135 | * case-insensitive. We treat a buddy in both "Friends" and "friends" |
|
27743
ce49b08a7990
Clarify a comment a little.
Paul Aurich <darkrain42@pidgin.im>
parents:
27742
diff
changeset
|
136 | * as only being in one group, but if we push changes about the buddy |
|
27277
8a2ecbdd70e4
Various roster cleanups. Refs #7008.
Paul Aurich <darkrain42@pidgin.im>
parents:
27276
diff
changeset
|
137 | * to the server, the buddy will be dropped from one of the groups. |
|
27743
ce49b08a7990
Clarify a comment a little.
Paul Aurich <darkrain42@pidgin.im>
parents:
27742
diff
changeset
|
138 | * Not optimal, but better than the alternative, I think. |
|
27277
8a2ecbdd70e4
Various roster cleanups. Refs #7008.
Paul Aurich <darkrain42@pidgin.im>
parents:
27276
diff
changeset
|
139 | */ |
|
36009
4db2936dd842
Backport 407e0fa6f7d1: don't split contacts on default group (xmpp)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31794
diff
changeset
|
140 | l = g_slist_find_custom(groups, purple_group_get_name(g), |
|
4db2936dd842
Backport 407e0fa6f7d1: don't split contacts on default group (xmpp)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31794
diff
changeset
|
141 | (GCompareFunc)purple_utf8_strcasecmp); |
|
35960
407e0fa6f7d1
blist: don't localize roster group name to avoid contact splitting
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35958
diff
changeset
|
142 | if (!l && g == purple_blist_get_default_group()) { |
|
36009
4db2936dd842
Backport 407e0fa6f7d1: don't split contacts on default group (xmpp)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31794
diff
changeset
|
143 | l = g_slist_find_custom(groups, JABBER_ROSTER_DEFAULT_GROUP, |
|
4db2936dd842
Backport 407e0fa6f7d1: don't split contacts on default group (xmpp)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31794
diff
changeset
|
144 | (GCompareFunc)purple_utf8_strcasecmp); |
|
4db2936dd842
Backport 407e0fa6f7d1: don't split contacts on default group (xmpp)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31794
diff
changeset
|
145 | } |
|
35961
87fd9126902a
blist: store localized name of default group to avoid contact splitting
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35960
diff
changeset
|
146 | if (!l && g == purple_blist_get_default_group()) { |
|
87fd9126902a
blist: store localized name of default group to avoid contact splitting
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35960
diff
changeset
|
147 | l = g_slist_find_custom(groups, |
|
87fd9126902a
blist: store localized name of default group to avoid contact splitting
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35960
diff
changeset
|
148 | _purple_blist_get_localized_default_group_name(), |
|
87fd9126902a
blist: store localized name of default group to avoid contact splitting
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35960
diff
changeset
|
149 | (GCompareFunc)purple_utf8_strcasecmp); |
|
87fd9126902a
blist: store localized name of default group to avoid contact splitting
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35960
diff
changeset
|
150 | } |
|
36009
4db2936dd842
Backport 407e0fa6f7d1: don't split contacts on default group (xmpp)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31794
diff
changeset
|
151 | |
|
4db2936dd842
Backport 407e0fa6f7d1: don't split contacts on default group (xmpp)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31794
diff
changeset
|
152 | if (l) { |
|
27277
8a2ecbdd70e4
Various roster cleanups. Refs #7008.
Paul Aurich <darkrain42@pidgin.im>
parents:
27276
diff
changeset
|
153 | /* The buddy is already on the local list. Update info. */ |
|
24950
143f594f0cd0
Alias foo. I think blist.h structs are now completely hidden.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
154 | const char *servernick, *balias; |
| 7955 | 155 | |
|
24199
8606cb4e94f5
The alias we retrieve from the roster is a private alias; use purple_serv_got_private_alias() to tell the core about it
Evan Schoenberg <evands@pidgin.im>
parents:
23975
diff
changeset
|
156 | /* Previously stored serverside / buddy-supplied alias */ |
| 15884 | 157 | if((servernick = purple_blist_node_get_string((PurpleBlistNode*)b, "servernick"))) |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
34935
diff
changeset
|
158 | purple_serv_got_alias(js->gc, jid, servernick); |
| 7955 | 159 | |
|
24199
8606cb4e94f5
The alias we retrieve from the roster is a private alias; use purple_serv_got_private_alias() to tell the core about it
Evan Schoenberg <evands@pidgin.im>
parents:
23975
diff
changeset
|
160 | /* Alias from our roster retrieval */ |
|
34717
b3e588adef5a
Global replace purple_buddy_get_local_buddy_alias() with purple_buddy_get_local_alias()
Ankit Vani <a@nevitus.org>
parents:
34699
diff
changeset
|
161 | balias = purple_buddy_get_local_alias(b); |
|
27277
8a2ecbdd70e4
Various roster cleanups. Refs #7008.
Paul Aurich <darkrain42@pidgin.im>
parents:
27276
diff
changeset
|
162 | if(alias && !purple_strequal(alias, balias)) |
|
24199
8606cb4e94f5
The alias we retrieve from the roster is a private alias; use purple_serv_got_private_alias() to tell the core about it
Evan Schoenberg <evands@pidgin.im>
parents:
23975
diff
changeset
|
163 | purple_serv_got_private_alias(js->gc, jid, alias); |
| 7014 | 164 | g_free(l->data); |
|
27277
8a2ecbdd70e4
Various roster cleanups. Refs #7008.
Paul Aurich <darkrain42@pidgin.im>
parents:
27276
diff
changeset
|
165 | groups = g_slist_delete_link(groups, l); |
| 7014 | 166 | } else { |
|
27277
8a2ecbdd70e4
Various roster cleanups. Refs #7008.
Paul Aurich <darkrain42@pidgin.im>
parents:
27276
diff
changeset
|
167 | /* This buddy isn't in the group on the server anymore */ |
|
35960
407e0fa6f7d1
blist: don't localize roster group name to avoid contact splitting
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35958
diff
changeset
|
168 | purple_debug_info("jabber", "jabber_roster_parse(): " |
|
407e0fa6f7d1
blist: don't localize roster group name to avoid contact splitting
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35958
diff
changeset
|
169 | "Removing %s from group '%s' on the local list", |
|
407e0fa6f7d1
blist: don't localize roster group name to avoid contact splitting
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35958
diff
changeset
|
170 | purple_buddy_get_name(b), |
|
407e0fa6f7d1
blist: don't localize roster group name to avoid contact splitting
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35958
diff
changeset
|
171 | jabber_roster_group_get_global_name(g)); |
|
28758
6fb73f2ab8e2
jabber: Remove the roster pool stuff.
Paul Aurich <darkrain42@pidgin.im>
parents:
28622
diff
changeset
|
172 | purple_blist_remove_buddy(b); |
| 7014 | 173 | } |
| 174 | } | |
| 175 | ||
|
27282
791c6a965694
Debug output when changing group memberships.
Paul Aurich <darkrain42@pidgin.im>
parents:
27281
diff
changeset
|
176 | if (groups) { |
|
791c6a965694
Debug output when changing group memberships.
Paul Aurich <darkrain42@pidgin.im>
parents:
27281
diff
changeset
|
177 | char *tmp = roster_groups_join(groups); |
|
791c6a965694
Debug output when changing group memberships.
Paul Aurich <darkrain42@pidgin.im>
parents:
27281
diff
changeset
|
178 | purple_debug_info("jabber", "jabber_roster_parse(): Adding %s to " |
|
791c6a965694
Debug output when changing group memberships.
Paul Aurich <darkrain42@pidgin.im>
parents:
27281
diff
changeset
|
179 | "groups: %s\n", jid, tmp); |
|
791c6a965694
Debug output when changing group memberships.
Paul Aurich <darkrain42@pidgin.im>
parents:
27281
diff
changeset
|
180 | g_free(tmp); |
|
791c6a965694
Debug output when changing group memberships.
Paul Aurich <darkrain42@pidgin.im>
parents:
27281
diff
changeset
|
181 | } |
|
791c6a965694
Debug output when changing group memberships.
Paul Aurich <darkrain42@pidgin.im>
parents:
27281
diff
changeset
|
182 | |
|
27277
8a2ecbdd70e4
Various roster cleanups. Refs #7008.
Paul Aurich <darkrain42@pidgin.im>
parents:
27276
diff
changeset
|
183 | while(groups) { |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34717
diff
changeset
|
184 | PurpleGroup *g = purple_blist_find_group(groups->data); |
|
28758
6fb73f2ab8e2
jabber: Remove the roster pool stuff.
Paul Aurich <darkrain42@pidgin.im>
parents:
28622
diff
changeset
|
185 | PurpleBuddy *b = purple_buddy_new(account, jid, alias); |
| 7014 | 186 | |
| 187 | if(!g) { | |
|
27277
8a2ecbdd70e4
Various roster cleanups. Refs #7008.
Paul Aurich <darkrain42@pidgin.im>
parents:
27276
diff
changeset
|
188 | g = purple_group_new(groups->data); |
| 15884 | 189 | purple_blist_add_group(g, NULL); |
| 7014 | 190 | } |
| 191 | ||
| 15884 | 192 | purple_blist_add_buddy(b, NULL, g, NULL); |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34717
diff
changeset
|
193 | purple_buddy_set_local_alias(b, alias); |
|
13987
b5b1db6007b0
[gaim-migrate @ 16442]
Mark Doliner <markdoliner@pidgin.im>
parents:
13809
diff
changeset
|
194 | |
|
27277
8a2ecbdd70e4
Various roster cleanups. Refs #7008.
Paul Aurich <darkrain42@pidgin.im>
parents:
27276
diff
changeset
|
195 | g_free(groups->data); |
|
8a2ecbdd70e4
Various roster cleanups. Refs #7008.
Paul Aurich <darkrain42@pidgin.im>
parents:
27276
diff
changeset
|
196 | groups = g_slist_delete_link(groups, groups); |
| 7014 | 197 | } |
| 198 | ||
| 199 | g_slist_free(buddies); | |
| 200 | } | |
| 201 | ||
|
25817
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
24672
diff
changeset
|
202 | void jabber_roster_parse(JabberStream *js, const char *from, |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
203 | JabberIqType type, const char *id, PurpleXmlNode *query) |
| 7014 | 204 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
205 | PurpleXmlNode *item, *group; |
|
29185
e30a3705166b
Disable this part of roster versioning, too (for now). Refs #10935.
Paul Aurich <darkrain42@pidgin.im>
parents:
29116
diff
changeset
|
206 | #if 0 |
|
29096
362b96f6f3da
jabber: Roster Versioning support.
Paul Aurich <darkrain42@pidgin.im>
parents:
28758
diff
changeset
|
207 | const char *ver; |
|
29185
e30a3705166b
Disable this part of roster versioning, too (for now). Refs #10935.
Paul Aurich <darkrain42@pidgin.im>
parents:
29116
diff
changeset
|
208 | #endif |
| 7445 | 209 | |
|
27275
a7836fbdcfa2
Use jabber_is_own_account and perform way fewer normalizations per iteration
Paul Aurich <darkrain42@pidgin.im>
parents:
27242
diff
changeset
|
210 | if (!jabber_is_own_account(js, from)) { |
|
a7836fbdcfa2
Use jabber_is_own_account and perform way fewer normalizations per iteration
Paul Aurich <darkrain42@pidgin.im>
parents:
27242
diff
changeset
|
211 | purple_debug_warning("jabber", "Received bogon roster push from %s\n", |
|
a7836fbdcfa2
Use jabber_is_own_account and perform way fewer normalizations per iteration
Paul Aurich <darkrain42@pidgin.im>
parents:
27242
diff
changeset
|
212 | from); |
|
a7836fbdcfa2
Use jabber_is_own_account and perform way fewer normalizations per iteration
Paul Aurich <darkrain42@pidgin.im>
parents:
27242
diff
changeset
|
213 | return; |
| 7175 | 214 | } |
| 215 | ||
|
23975
8ee397f04ca9
We talked about this and decided it was probably cleaner to not use
Mark Doliner <markdoliner@pidgin.im>
parents:
23961
diff
changeset
|
216 | js->currently_parsing_roster_push = TRUE; |
|
23961
0a9e9676f7b5
Hopefully fix the XMPP contact flipping/swapping between groups bug
Mark Doliner <markdoliner@pidgin.im>
parents:
23566
diff
changeset
|
217 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
218 | for(item = purple_xmlnode_get_child(query, "item"); item; item = purple_xmlnode_get_next_twin(item)) |
| 7014 | 219 | { |
| 220 | const char *jid, *name, *subscription, *ask; | |
| 221 | JabberBuddy *jb; | |
| 222 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
223 | subscription = purple_xmlnode_get_attrib(item, "subscription"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
224 | jid = purple_xmlnode_get_attrib(item, "jid"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
225 | name = purple_xmlnode_get_attrib(item, "name"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
226 | ask = purple_xmlnode_get_attrib(item, "ask"); |
| 7014 | 227 | |
| 8347 | 228 | if(!jid) |
| 229 | continue; | |
| 230 | ||
| 231 | if(!(jb = jabber_buddy_find(js, jid, TRUE))) | |
| 232 | continue; | |
| 7014 | 233 | |
| 10289 | 234 | if(subscription) { |
|
29114
b3876f83a46c
jabber: Fix removing a self-contact.
Paul Aurich <darkrain42@pidgin.im>
parents:
29103
diff
changeset
|
235 | if (g_str_equal(subscription, "remove")) |
|
b3876f83a46c
jabber: Fix removing a self-contact.
Paul Aurich <darkrain42@pidgin.im>
parents:
29103
diff
changeset
|
236 | jb->subscription = JABBER_SUB_REMOVE; |
|
b3876f83a46c
jabber: Fix removing a self-contact.
Paul Aurich <darkrain42@pidgin.im>
parents:
29103
diff
changeset
|
237 | else if (jb == js->user_jb) |
| 12285 | 238 | jb->subscription = JABBER_SUB_BOTH; |
|
29114
b3876f83a46c
jabber: Fix removing a self-contact.
Paul Aurich <darkrain42@pidgin.im>
parents:
29103
diff
changeset
|
239 | else if (g_str_equal(subscription, "none")) |
| 12285 | 240 | jb->subscription = JABBER_SUB_NONE; |
|
29114
b3876f83a46c
jabber: Fix removing a self-contact.
Paul Aurich <darkrain42@pidgin.im>
parents:
29103
diff
changeset
|
241 | else if (g_str_equal(subscription, "to")) |
| 10289 | 242 | jb->subscription = JABBER_SUB_TO; |
|
29114
b3876f83a46c
jabber: Fix removing a self-contact.
Paul Aurich <darkrain42@pidgin.im>
parents:
29103
diff
changeset
|
243 | else if (g_str_equal(subscription, "from")) |
| 10289 | 244 | jb->subscription = JABBER_SUB_FROM; |
|
29114
b3876f83a46c
jabber: Fix removing a self-contact.
Paul Aurich <darkrain42@pidgin.im>
parents:
29103
diff
changeset
|
245 | else if (g_str_equal(subscription, "both")) |
| 10289 | 246 | jb->subscription = JABBER_SUB_BOTH; |
| 247 | } | |
| 7014 | 248 | |
|
27276
d3c4ec6e0b2f
Remove this; it's been commented out for about 3.5 years.
Paul Aurich <darkrain42@pidgin.im>
parents:
27275
diff
changeset
|
249 | if(purple_strequal(ask, "subscribe")) |
| 7014 | 250 | jb->subscription |= JABBER_SUB_PENDING; |
| 251 | else | |
| 252 | jb->subscription &= ~JABBER_SUB_PENDING; | |
| 253 | ||
|
28622
5d971bd4b001
jabber: Fix removing a buddy with a pending subscription.
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
254 | if(jb->subscription & JABBER_SUB_REMOVE) { |
| 15884 | 255 | remove_purple_buddies(js, jid); |
| 7014 | 256 | } else { |
| 257 | GSList *groups = NULL; | |
|
20221
28e31ee832cd
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
258 | |
|
28e31ee832cd
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
259 | if (js->server_caps & JABBER_CAP_GOOGLE_ROSTER) |
|
28e31ee832cd
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
260 | if (!jabber_google_roster_incoming(js, item)) |
|
28e31ee832cd
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
261 | continue; |
|
28e31ee832cd
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
262 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
263 | for(group = purple_xmlnode_get_child(item, "group"); group; group = purple_xmlnode_get_next_twin(group)) { |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
264 | char *group_name = purple_xmlnode_get_data(group); |
| 13809 | 265 | |
|
31794
9725839f5a19
jabber: Treat empty <group/> elements as "Buddies", not ""
Paul Aurich <darkrain42@pidgin.im>
parents:
30744
diff
changeset
|
266 | if (group_name == NULL || *group_name == '\0') |
|
9725839f5a19
jabber: Treat empty <group/> elements as "Buddies", not ""
Paul Aurich <darkrain42@pidgin.im>
parents:
30744
diff
changeset
|
267 | /* Changing this string? Look in add_purple_buddy_to_groups */ |
|
36009
4db2936dd842
Backport 407e0fa6f7d1: don't split contacts on default group (xmpp)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31794
diff
changeset
|
268 | group_name = g_strdup(JABBER_ROSTER_DEFAULT_GROUP); |
|
27277
8a2ecbdd70e4
Various roster cleanups. Refs #7008.
Paul Aurich <darkrain42@pidgin.im>
parents:
27276
diff
changeset
|
269 | |
|
29373
481ec7d852d7
jabber: Fix another corner case that introduced duplicates to the list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29358
diff
changeset
|
270 | /* |
|
481ec7d852d7
jabber: Fix another corner case that introduced duplicates to the list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29358
diff
changeset
|
271 | * See the note in add_purple_buddy_to_groups; the core handles |
|
481ec7d852d7
jabber: Fix another corner case that introduced duplicates to the list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29358
diff
changeset
|
272 | * names case-insensitively and this is required to not |
|
481ec7d852d7
jabber: Fix another corner case that introduced duplicates to the list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29358
diff
changeset
|
273 | * end up with duplicates if a buddy is in, e.g., |
|
481ec7d852d7
jabber: Fix another corner case that introduced duplicates to the list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29358
diff
changeset
|
274 | * 'XMPP' and 'xmpp' |
|
481ec7d852d7
jabber: Fix another corner case that introduced duplicates to the list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29358
diff
changeset
|
275 | */ |
|
481ec7d852d7
jabber: Fix another corner case that introduced duplicates to the list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29358
diff
changeset
|
276 | if (g_slist_find_custom(groups, group_name, (GCompareFunc)purple_utf8_strcasecmp)) |
|
481ec7d852d7
jabber: Fix another corner case that introduced duplicates to the list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29358
diff
changeset
|
277 | g_free(group_name); |
|
481ec7d852d7
jabber: Fix another corner case that introduced duplicates to the list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29358
diff
changeset
|
278 | else |
|
481ec7d852d7
jabber: Fix another corner case that introduced duplicates to the list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29358
diff
changeset
|
279 | groups = g_slist_prepend(groups, group_name); |
| 7014 | 280 | } |
|
27277
8a2ecbdd70e4
Various roster cleanups. Refs #7008.
Paul Aurich <darkrain42@pidgin.im>
parents:
27276
diff
changeset
|
281 | |
|
28071
a0706162fefd
jabber: Store the "own JabberBuddy" in the JabberStream* struct.
Paul Aurich <darkrain42@pidgin.im>
parents:
27743
diff
changeset
|
282 | add_purple_buddy_to_groups(js, jid, name, groups); |
|
a0706162fefd
jabber: Store the "own JabberBuddy" in the JabberStream* struct.
Paul Aurich <darkrain42@pidgin.im>
parents:
27743
diff
changeset
|
283 | if (jb == js->user_jb) |
|
a0706162fefd
jabber: Store the "own JabberBuddy" in the JabberStream* struct.
Paul Aurich <darkrain42@pidgin.im>
parents:
27743
diff
changeset
|
284 | jabber_presence_fake_to_self(js, NULL); |
| 7014 | 285 | } |
| 286 | } | |
|
18196
a7992a42dc3d
fix inital presence (fixes #1395)
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
287 | |
|
29185
e30a3705166b
Disable this part of roster versioning, too (for now). Refs #10935.
Paul Aurich <darkrain42@pidgin.im>
parents:
29116
diff
changeset
|
288 | #if 0 |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
289 | ver = purple_xmlnode_get_attrib(query, "ver"); |
|
29096
362b96f6f3da
jabber: Roster Versioning support.
Paul Aurich <darkrain42@pidgin.im>
parents:
28758
diff
changeset
|
290 | if (ver) { |
|
362b96f6f3da
jabber: Roster Versioning support.
Paul Aurich <darkrain42@pidgin.im>
parents:
28758
diff
changeset
|
291 | PurpleAccount *account = purple_connection_get_account(js->gc); |
|
362b96f6f3da
jabber: Roster Versioning support.
Paul Aurich <darkrain42@pidgin.im>
parents:
28758
diff
changeset
|
292 | purple_account_set_string(account, "roster_ver", ver); |
|
362b96f6f3da
jabber: Roster Versioning support.
Paul Aurich <darkrain42@pidgin.im>
parents:
28758
diff
changeset
|
293 | } |
|
29185
e30a3705166b
Disable this part of roster versioning, too (for now). Refs #10935.
Paul Aurich <darkrain42@pidgin.im>
parents:
29116
diff
changeset
|
294 | #endif |
|
23961
0a9e9676f7b5
Hopefully fix the XMPP contact flipping/swapping between groups bug
Mark Doliner <markdoliner@pidgin.im>
parents:
23566
diff
changeset
|
295 | |
|
29358
27de2111e8a1
jabber: Send the RFC-mandated ack IQ
Paul Aurich <darkrain42@pidgin.im>
parents:
29185
diff
changeset
|
296 | if (type == JABBER_IQ_SET) { |
|
27de2111e8a1
jabber: Send the RFC-mandated ack IQ
Paul Aurich <darkrain42@pidgin.im>
parents:
29185
diff
changeset
|
297 | JabberIq *ack = jabber_iq_new(js, JABBER_IQ_RESULT); |
|
27de2111e8a1
jabber: Send the RFC-mandated ack IQ
Paul Aurich <darkrain42@pidgin.im>
parents:
29185
diff
changeset
|
298 | jabber_iq_set_id(ack, id); |
|
27de2111e8a1
jabber: Send the RFC-mandated ack IQ
Paul Aurich <darkrain42@pidgin.im>
parents:
29185
diff
changeset
|
299 | jabber_iq_send(ack); |
|
27de2111e8a1
jabber: Send the RFC-mandated ack IQ
Paul Aurich <darkrain42@pidgin.im>
parents:
29185
diff
changeset
|
300 | } |
|
27de2111e8a1
jabber: Send the RFC-mandated ack IQ
Paul Aurich <darkrain42@pidgin.im>
parents:
29185
diff
changeset
|
301 | |
|
29096
362b96f6f3da
jabber: Roster Versioning support.
Paul Aurich <darkrain42@pidgin.im>
parents:
28758
diff
changeset
|
302 | js->currently_parsing_roster_push = FALSE; |
| 7014 | 303 | } |
| 304 | ||
|
27283
9a69f682a3ca
Operate on the passed-in GSList.
Paul Aurich <darkrain42@pidgin.im>
parents:
27282
diff
changeset
|
305 | /* jabber_roster_update frees the GSList* passed in */ |
| 7014 | 306 | static void jabber_roster_update(JabberStream *js, const char *name, |
|
27283
9a69f682a3ca
Operate on the passed-in GSList.
Paul Aurich <darkrain42@pidgin.im>
parents:
27282
diff
changeset
|
307 | GSList *groups) |
| 7014 | 308 | { |
| 15884 | 309 | PurpleBuddy *b; |
| 310 | PurpleGroup *g; | |
|
27283
9a69f682a3ca
Operate on the passed-in GSList.
Paul Aurich <darkrain42@pidgin.im>
parents:
27282
diff
changeset
|
311 | GSList *l; |
| 7014 | 312 | JabberIq *iq; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
313 | PurpleXmlNode *query, *item, *group; |
|
24950
143f594f0cd0
Alias foo. I think blist.h structs are now completely hidden.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
314 | const char *balias; |
| 7014 | 315 | |
|
23975
8ee397f04ca9
We talked about this and decided it was probably cleaner to not use
Mark Doliner <markdoliner@pidgin.im>
parents:
23961
diff
changeset
|
316 | if (js->currently_parsing_roster_push) |
|
23961
0a9e9676f7b5
Hopefully fix the XMPP contact flipping/swapping between groups bug
Mark Doliner <markdoliner@pidgin.im>
parents:
23566
diff
changeset
|
317 | return; |
|
0a9e9676f7b5
Hopefully fix the XMPP contact flipping/swapping between groups bug
Mark Doliner <markdoliner@pidgin.im>
parents:
23566
diff
changeset
|
318 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34717
diff
changeset
|
319 | if(!(b = purple_blist_find_buddy(purple_connection_get_account(js->gc), name))) |
|
20221
28e31ee832cd
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
320 | return; |
|
28e31ee832cd
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
321 | |
|
27283
9a69f682a3ca
Operate on the passed-in GSList.
Paul Aurich <darkrain42@pidgin.im>
parents:
27282
diff
changeset
|
322 | if (groups) { |
|
27282
791c6a965694
Debug output when changing group memberships.
Paul Aurich <darkrain42@pidgin.im>
parents:
27281
diff
changeset
|
323 | char *tmp = roster_groups_join(groups); |
|
27230
17f893b060d7
Add a few more roster debug messages and improve.
Paul Aurich <darkrain42@pidgin.im>
parents:
27229
diff
changeset
|
324 | |
|
27283
9a69f682a3ca
Operate on the passed-in GSList.
Paul Aurich <darkrain42@pidgin.im>
parents:
27282
diff
changeset
|
325 | purple_debug_info("jabber", "jabber_roster_update(%s): [Source: " |
|
9a69f682a3ca
Operate on the passed-in GSList.
Paul Aurich <darkrain42@pidgin.im>
parents:
27282
diff
changeset
|
326 | "groups]: groups: %s\n", name, tmp); |
|
27282
791c6a965694
Debug output when changing group memberships.
Paul Aurich <darkrain42@pidgin.im>
parents:
27281
diff
changeset
|
327 | g_free(tmp); |
| 7014 | 328 | } else { |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34717
diff
changeset
|
329 | GSList *buddies = purple_blist_find_buddies(purple_connection_get_account(js->gc), name); |
|
27282
791c6a965694
Debug output when changing group memberships.
Paul Aurich <darkrain42@pidgin.im>
parents:
27281
diff
changeset
|
330 | char *tmp; |
|
27230
17f893b060d7
Add a few more roster debug messages and improve.
Paul Aurich <darkrain42@pidgin.im>
parents:
27229
diff
changeset
|
331 | |
| 7014 | 332 | if(!buddies) |
| 333 | return; | |
| 334 | while(buddies) { | |
| 335 | b = buddies->data; | |
| 15884 | 336 | g = purple_buddy_get_group(b); |
|
36009
4db2936dd842
Backport 407e0fa6f7d1: don't split contacts on default group (xmpp)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31794
diff
changeset
|
337 | groups = g_slist_append(groups, |
|
4db2936dd842
Backport 407e0fa6f7d1: don't split contacts on default group (xmpp)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31794
diff
changeset
|
338 | (char *)jabber_roster_group_get_global_name(g)); |
| 7014 | 339 | buddies = g_slist_remove(buddies, b); |
| 340 | } | |
|
27230
17f893b060d7
Add a few more roster debug messages and improve.
Paul Aurich <darkrain42@pidgin.im>
parents:
27229
diff
changeset
|
341 | |
|
27282
791c6a965694
Debug output when changing group memberships.
Paul Aurich <darkrain42@pidgin.im>
parents:
27281
diff
changeset
|
342 | tmp = roster_groups_join(groups); |
|
27230
17f893b060d7
Add a few more roster debug messages and improve.
Paul Aurich <darkrain42@pidgin.im>
parents:
27229
diff
changeset
|
343 | purple_debug_info("jabber", "jabber_roster_update(%s): [Source: local blist]: groups: %s\n", |
|
27282
791c6a965694
Debug output when changing group memberships.
Paul Aurich <darkrain42@pidgin.im>
parents:
27281
diff
changeset
|
344 | name, tmp); |
|
791c6a965694
Debug output when changing group memberships.
Paul Aurich <darkrain42@pidgin.im>
parents:
27281
diff
changeset
|
345 | g_free(tmp); |
| 7014 | 346 | } |
| 347 | ||
| 348 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:roster"); | |
| 349 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
350 | query = purple_xmlnode_get_child(iq->node, "query"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
351 | item = purple_xmlnode_new_child(query, "item"); |
| 7014 | 352 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
353 | purple_xmlnode_set_attrib(item, "jid", name); |
| 7014 | 354 | |
|
34717
b3e588adef5a
Global replace purple_buddy_get_local_buddy_alias() with purple_buddy_get_local_alias()
Ankit Vani <a@nevitus.org>
parents:
34699
diff
changeset
|
355 | balias = purple_buddy_get_local_alias(b); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
356 | purple_xmlnode_set_attrib(item, "name", balias ? balias : ""); |
| 7014 | 357 | |
| 358 | for(l = groups; l; l = l->next) { | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
359 | group = purple_xmlnode_new_child(item, "group"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
360 | purple_xmlnode_insert_data(group, l->data, -1); |
| 7014 | 361 | } |
| 362 | ||
|
27283
9a69f682a3ca
Operate on the passed-in GSList.
Paul Aurich <darkrain42@pidgin.im>
parents:
27282
diff
changeset
|
363 | g_slist_free(groups); |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24983
diff
changeset
|
364 | |
| 15265 | 365 | if (js->server_caps & JABBER_CAP_GOOGLE_ROSTER) { |
| 366 | jabber_google_roster_outgoing(js, query, item); | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
367 | purple_xmlnode_set_attrib(query, "xmlns:gr", NS_GOOGLE_ROSTER); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
368 | purple_xmlnode_set_attrib(query, "gr:ext", "2"); |
| 15265 | 369 | } |
| 7014 | 370 | jabber_iq_send(iq); |
| 371 | } | |
| 372 | ||
| 15884 | 373 | void jabber_roster_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, |
|
32315
2550a39e0285
Rename the _with_invite functions to their counterparts.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32277
diff
changeset
|
374 | PurpleGroup *group, const char *message) |
| 7014 | 375 | { |
|
32277
97f16af01a05
Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
31794
diff
changeset
|
376 | JabberStream *js = purple_connection_get_protocol_data(gc); |
| 7014 | 377 | char *who; |
|
28431
8450418b5abd
jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <darkrain42@pidgin.im>
parents:
28322
diff
changeset
|
378 | JabberID *jid; |
| 7014 | 379 | JabberBuddy *jb; |
| 7488 | 380 | JabberBuddyResource *jbr; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24199
diff
changeset
|
381 | const char *name; |
| 7014 | 382 | |
|
27278
b34a1cea4872
Use js->state to track whether the roster has been retrieved.
Paul Aurich <darkrain42@pidgin.im>
parents:
27277
diff
changeset
|
383 | /* If we haven't received the roster yet, ignore any adds */ |
|
b34a1cea4872
Use js->state to track whether the roster has been retrieved.
Paul Aurich <darkrain42@pidgin.im>
parents:
27277
diff
changeset
|
384 | if (js->state != JABBER_STREAM_CONNECTED) |
| 7014 | 385 | return; |
| 386 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24199
diff
changeset
|
387 | name = purple_buddy_get_name(buddy); |
|
28431
8450418b5abd
jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <darkrain42@pidgin.im>
parents:
28322
diff
changeset
|
388 | jid = jabber_id_new(name); |
|
8450418b5abd
jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <darkrain42@pidgin.im>
parents:
28322
diff
changeset
|
389 | if (jid == NULL) { |
|
8450418b5abd
jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <darkrain42@pidgin.im>
parents:
28322
diff
changeset
|
390 | /* TODO: Remove the buddy from the list? */ |
| 7425 | 391 | return; |
|
28431
8450418b5abd
jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <darkrain42@pidgin.im>
parents:
28322
diff
changeset
|
392 | } |
| 7014 | 393 | |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
32678
diff
changeset
|
394 | /* Adding a chat room or a chat user to the roster is *not* supported. */ |
|
28584
1226297d1ba9
jabber: Don't crash when adding a buddy without a node (no '@'). Closes #10261.
Paul Aurich <darkrain42@pidgin.im>
parents:
28431
diff
changeset
|
395 | if (jid->node && jabber_chat_find(js, jid->node, jid->domain) != NULL) { |
|
28431
8450418b5abd
jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <darkrain42@pidgin.im>
parents:
28322
diff
changeset
|
396 | /* |
|
8450418b5abd
jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <darkrain42@pidgin.im>
parents:
28322
diff
changeset
|
397 | * This is the same thing Bonjour does. If it causes problems, move |
|
8450418b5abd
jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <darkrain42@pidgin.im>
parents:
28322
diff
changeset
|
398 | * it to an idle callback. |
|
8450418b5abd
jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <darkrain42@pidgin.im>
parents:
28322
diff
changeset
|
399 | */ |
|
8450418b5abd
jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <darkrain42@pidgin.im>
parents:
28322
diff
changeset
|
400 | purple_debug_warning("jabber", "Cowardly refusing to add a MUC user " |
|
8450418b5abd
jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <darkrain42@pidgin.im>
parents:
28322
diff
changeset
|
401 | "to your buddy list and removing the buddy. " |
|
8450418b5abd
jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <darkrain42@pidgin.im>
parents:
28322
diff
changeset
|
402 | "Buddies can only be added by real (non-MUC) " |
|
8450418b5abd
jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <darkrain42@pidgin.im>
parents:
28322
diff
changeset
|
403 | "JID\n"); |
|
8450418b5abd
jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <darkrain42@pidgin.im>
parents:
28322
diff
changeset
|
404 | purple_blist_remove_buddy(buddy); |
|
8450418b5abd
jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <darkrain42@pidgin.im>
parents:
28322
diff
changeset
|
405 | jabber_id_free(jid); |
|
8450418b5abd
jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <darkrain42@pidgin.im>
parents:
28322
diff
changeset
|
406 | return; |
|
8450418b5abd
jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <darkrain42@pidgin.im>
parents:
28322
diff
changeset
|
407 | } |
| 7425 | 408 | |
|
28431
8450418b5abd
jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <darkrain42@pidgin.im>
parents:
28322
diff
changeset
|
409 | who = jabber_id_get_bare_jid(jid); |
|
8450418b5abd
jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <darkrain42@pidgin.im>
parents:
28322
diff
changeset
|
410 | if (jid->resource != NULL) { |
|
8450418b5abd
jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <darkrain42@pidgin.im>
parents:
28322
diff
changeset
|
411 | /* |
|
8450418b5abd
jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <darkrain42@pidgin.im>
parents:
28322
diff
changeset
|
412 | * If the buddy name added contains a resource, strip that off and |
|
8450418b5abd
jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <darkrain42@pidgin.im>
parents:
28322
diff
changeset
|
413 | * rename the buddy. |
|
8450418b5abd
jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <darkrain42@pidgin.im>
parents:
28322
diff
changeset
|
414 | */ |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34717
diff
changeset
|
415 | purple_buddy_set_name(buddy, who); |
|
28431
8450418b5abd
jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <darkrain42@pidgin.im>
parents:
28322
diff
changeset
|
416 | } |
|
8450418b5abd
jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <darkrain42@pidgin.im>
parents:
28322
diff
changeset
|
417 | |
|
8450418b5abd
jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <darkrain42@pidgin.im>
parents:
28322
diff
changeset
|
418 | jb = jabber_buddy_find(js, who, FALSE); |
|
8450418b5abd
jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <darkrain42@pidgin.im>
parents:
28322
diff
changeset
|
419 | |
|
8450418b5abd
jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <darkrain42@pidgin.im>
parents:
28322
diff
changeset
|
420 | purple_debug_info("jabber", "jabber_roster_add_buddy(): Adding %s\n", who); |
|
27230
17f893b060d7
Add a few more roster debug messages and improve.
Paul Aurich <darkrain42@pidgin.im>
parents:
27229
diff
changeset
|
421 | |
|
23566
fabe91dee1e1
Alright, I'm getting rid of this "groups" thing for the reason listed
Mark Doliner <markdoliner@pidgin.im>
parents:
22993
diff
changeset
|
422 | jabber_roster_update(js, who, NULL); |
| 7014 | 423 | |
|
28071
a0706162fefd
jabber: Store the "own JabberBuddy" in the JabberStream* struct.
Paul Aurich <darkrain42@pidgin.im>
parents:
27743
diff
changeset
|
424 | if (jb == js->user_jb) { |
|
27280
55a39efcf7b8
Simplify the fake_to_self function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27278
diff
changeset
|
425 | jabber_presence_fake_to_self(js, NULL); |
| 9954 | 426 | } else if(!jb || !(jb->subscription & JABBER_SUB_TO)) { |
| 7014 | 427 | jabber_presence_subscription_set(js, who, "subscribe"); |
| 9954 | 428 | } else if((jbr =jabber_buddy_find_resource(jb, NULL))) { |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
429 | purple_protocol_got_user_status(purple_connection_get_account(gc), who, |
| 9954 | 430 | jabber_buddy_state_get_status_id(jbr->state), |
| 9990 | 431 | "priority", jbr->priority, jbr->status ? "message" : NULL, jbr->status, NULL); |
| 9954 | 432 | } |
| 7425 | 433 | |
| 7014 | 434 | g_free(who); |
| 435 | } | |
| 436 | ||
| 15884 | 437 | void jabber_roster_alias_change(PurpleConnection *gc, const char *name, const char *alias) |
| 7014 | 438 | { |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34717
diff
changeset
|
439 | PurpleBuddy *b = purple_blist_find_buddy(purple_connection_get_account(gc), name); |
| 7449 | 440 | |
| 15321 | 441 | if(b != NULL) { |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34717
diff
changeset
|
442 | purple_buddy_set_local_alias(b, alias); |
| 7449 | 443 | |
|
27230
17f893b060d7
Add a few more roster debug messages and improve.
Paul Aurich <darkrain42@pidgin.im>
parents:
27229
diff
changeset
|
444 | purple_debug_info("jabber", "jabber_roster_alias_change(): Aliased %s to %s\n", |
|
27242
05618d46ac91
Ladedah I dislike the need to explicitly check for NULL strings.
Paul Aurich <darkrain42@pidgin.im>
parents:
27230
diff
changeset
|
445 | name, alias ? alias : "(null)"); |
|
27229
3a0922120d87
Pluck Adium's roster debugging from 86720de21a854aa
Paul Aurich <darkrain42@pidgin.im>
parents:
26707
diff
changeset
|
446 | |
|
32277
97f16af01a05
Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
31794
diff
changeset
|
447 | jabber_roster_update(purple_connection_get_protocol_data(gc), name, NULL); |
| 15321 | 448 | } |
| 7014 | 449 | } |
| 450 | ||
| 15884 | 451 | void jabber_roster_group_change(PurpleConnection *gc, const char *name, |
| 7014 | 452 | const char *old_group, const char *new_group) |
| 453 | { | |
| 454 | GSList *buddies, *groups = NULL; | |
| 15884 | 455 | PurpleBuddy *b; |
| 7014 | 456 | |
| 457 | if(!old_group || !new_group || !strcmp(old_group, new_group)) | |
| 458 | return; | |
| 459 | ||
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34717
diff
changeset
|
460 | buddies = purple_blist_find_buddies(purple_connection_get_account(gc), name); |
| 7014 | 461 | while(buddies) { |
| 462 | b = buddies->data; | |
|
36022
256604cbbe34
Make it possible to move buddies out of default group
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36013
diff
changeset
|
463 | groups = g_slist_append(groups, (char*)new_group); |
| 7014 | 464 | buddies = g_slist_remove(buddies, b); |
| 465 | } | |
|
27229
3a0922120d87
Pluck Adium's roster debugging from 86720de21a854aa
Paul Aurich <darkrain42@pidgin.im>
parents:
26707
diff
changeset
|
466 | |
|
27230
17f893b060d7
Add a few more roster debug messages and improve.
Paul Aurich <darkrain42@pidgin.im>
parents:
27229
diff
changeset
|
467 | purple_debug_info("jabber", "jabber_roster_group_change(): Moving %s from %s to %s\n", |
|
17f893b060d7
Add a few more roster debug messages and improve.
Paul Aurich <darkrain42@pidgin.im>
parents:
27229
diff
changeset
|
468 | name, old_group, new_group); |
|
27229
3a0922120d87
Pluck Adium's roster debugging from 86720de21a854aa
Paul Aurich <darkrain42@pidgin.im>
parents:
26707
diff
changeset
|
469 | |
|
32277
97f16af01a05
Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
31794
diff
changeset
|
470 | jabber_roster_update(purple_connection_get_protocol_data(gc), name, groups); |
| 7014 | 471 | } |
| 472 | ||
| 15884 | 473 | void jabber_roster_group_rename(PurpleConnection *gc, const char *old_name, |
| 474 | PurpleGroup *group, GList *moved_buddies) | |
| 7014 | 475 | { |
| 476 | GList *l; | |
|
36009
4db2936dd842
Backport 407e0fa6f7d1: don't split contacts on default group (xmpp)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31794
diff
changeset
|
477 | const char *gname = jabber_roster_group_get_global_name(group); |
|
9285
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
8347
diff
changeset
|
478 | for(l = moved_buddies; l; l = l->next) { |
| 15884 | 479 | PurpleBuddy *buddy = l->data; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24199
diff
changeset
|
480 | jabber_roster_group_change(gc, purple_buddy_get_name(buddy), old_name, gname); |
| 7014 | 481 | } |
| 482 | } | |
| 483 | ||
| 15884 | 484 | void jabber_roster_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, |
| 485 | PurpleGroup *group) { | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24199
diff
changeset
|
486 | const char *name = purple_buddy_get_name(buddy); |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34717
diff
changeset
|
487 | GSList *buddies = purple_blist_find_buddies(purple_connection_get_account(gc), name); |
| 7014 | 488 | |
|
9285
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
8347
diff
changeset
|
489 | buddies = g_slist_remove(buddies, buddy); |
|
15847
da522f9a7743
Don't use g_list_length() and g_slist_length() when all you want to
Mark Doliner <markdoliner@pidgin.im>
parents:
15695
diff
changeset
|
490 | if(buddies != NULL) { |
| 15884 | 491 | PurpleBuddy *tmpbuddy; |
| 492 | PurpleGroup *tmpgroup; | |
|
20225
684334efdc19
applied changes from d4b316d73ebaf93803ca2642e78b8821c3b5d5c7
Luke Schierer <lschiere@pidgin.im>
parents:
20221
diff
changeset
|
493 | GSList *groups = NULL; |
|
9285
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
8347
diff
changeset
|
494 | |
| 7014 | 495 | while(buddies) { |
|
9285
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
8347
diff
changeset
|
496 | tmpbuddy = buddies->data; |
| 15884 | 497 | tmpgroup = purple_buddy_get_group(tmpbuddy); |
|
36009
4db2936dd842
Backport 407e0fa6f7d1: don't split contacts on default group (xmpp)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31794
diff
changeset
|
498 | groups = g_slist_append(groups, |
|
4db2936dd842
Backport 407e0fa6f7d1: don't split contacts on default group (xmpp)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31794
diff
changeset
|
499 | (char *)jabber_roster_group_get_global_name(tmpgroup)); |
|
9285
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
8347
diff
changeset
|
500 | buddies = g_slist_remove(buddies, tmpbuddy); |
| 7014 | 501 | } |
|
9285
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
8347
diff
changeset
|
502 | |
|
36009
4db2936dd842
Backport 407e0fa6f7d1: don't split contacts on default group (xmpp)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31794
diff
changeset
|
503 | purple_debug_info("jabber", "jabber_roster_remove_buddy(): " |
|
35960
407e0fa6f7d1
blist: don't localize roster group name to avoid contact splitting
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35958
diff
changeset
|
504 | "Removing %s from %s", purple_buddy_get_name(buddy), |
|
36009
4db2936dd842
Backport 407e0fa6f7d1: don't split contacts on default group (xmpp)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31794
diff
changeset
|
505 | jabber_roster_group_get_global_name(group)); |
|
27229
3a0922120d87
Pluck Adium's roster debugging from 86720de21a854aa
Paul Aurich <darkrain42@pidgin.im>
parents:
26707
diff
changeset
|
506 | |
|
32277
97f16af01a05
Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
31794
diff
changeset
|
507 | jabber_roster_update(purple_connection_get_protocol_data(gc), name, groups); |
| 7014 | 508 | } else { |
|
32277
97f16af01a05
Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
31794
diff
changeset
|
509 | JabberIq *iq = jabber_iq_new_query(purple_connection_get_protocol_data(gc), JABBER_IQ_SET, |
| 7171 | 510 | "jabber:iq:roster"); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
511 | PurpleXmlNode *query = purple_xmlnode_get_child(iq->node, "query"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
512 | PurpleXmlNode *item = purple_xmlnode_new_child(query, "item"); |
| 7171 | 513 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
514 | purple_xmlnode_set_attrib(item, "jid", name); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
515 | purple_xmlnode_set_attrib(item, "subscription", "remove"); |
| 7171 | 516 | |
|
27230
17f893b060d7
Add a few more roster debug messages and improve.
Paul Aurich <darkrain42@pidgin.im>
parents:
27229
diff
changeset
|
517 | purple_debug_info("jabber", "jabber_roster_remove_buddy(): Removing %s\n", |
|
17f893b060d7
Add a few more roster debug messages and improve.
Paul Aurich <darkrain42@pidgin.im>
parents:
27229
diff
changeset
|
518 | purple_buddy_get_name(buddy)); |
|
17f893b060d7
Add a few more roster debug messages and improve.
Paul Aurich <darkrain42@pidgin.im>
parents:
27229
diff
changeset
|
519 | |
| 7171 | 520 | jabber_iq_send(iq); |
| 7014 | 521 | } |
| 522 | } | |
|
36009
4db2936dd842
Backport 407e0fa6f7d1: don't split contacts on default group (xmpp)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31794
diff
changeset
|
523 | |
|
4db2936dd842
Backport 407e0fa6f7d1: don't split contacts on default group (xmpp)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31794
diff
changeset
|
524 | const gchar * |
|
4db2936dd842
Backport 407e0fa6f7d1: don't split contacts on default group (xmpp)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31794
diff
changeset
|
525 | jabber_roster_group_get_global_name(PurpleGroup *group) |
|
4db2936dd842
Backport 407e0fa6f7d1: don't split contacts on default group (xmpp)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31794
diff
changeset
|
526 | { |
|
4db2936dd842
Backport 407e0fa6f7d1: don't split contacts on default group (xmpp)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31794
diff
changeset
|
527 | const gchar *name = NULL; |
|
4db2936dd842
Backport 407e0fa6f7d1: don't split contacts on default group (xmpp)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31794
diff
changeset
|
528 | |
|
4db2936dd842
Backport 407e0fa6f7d1: don't split contacts on default group (xmpp)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31794
diff
changeset
|
529 | if (group) |
|
4db2936dd842
Backport 407e0fa6f7d1: don't split contacts on default group (xmpp)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31794
diff
changeset
|
530 | name = purple_group_get_name(group); |
|
4db2936dd842
Backport 407e0fa6f7d1: don't split contacts on default group (xmpp)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31794
diff
changeset
|
531 | |
|
4db2936dd842
Backport 407e0fa6f7d1: don't split contacts on default group (xmpp)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31794
diff
changeset
|
532 | if (name == NULL) |
|
4db2936dd842
Backport 407e0fa6f7d1: don't split contacts on default group (xmpp)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31794
diff
changeset
|
533 | name = JABBER_ROSTER_DEFAULT_GROUP; |
|
35960
407e0fa6f7d1
blist: don't localize roster group name to avoid contact splitting
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35958
diff
changeset
|
534 | else if (g_strcmp0(name, PURPLE_BLIST_DEFAULT_GROUP_NAME) == 0) |
|
36009
4db2936dd842
Backport 407e0fa6f7d1: don't split contacts on default group (xmpp)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31794
diff
changeset
|
535 | name = JABBER_ROSTER_DEFAULT_GROUP; |
|
35961
87fd9126902a
blist: store localized name of default group to avoid contact splitting
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35960
diff
changeset
|
536 | else if (g_strcmp0(name, _purple_blist_get_localized_default_group_name()) == 0) |
|
87fd9126902a
blist: store localized name of default group to avoid contact splitting
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35960
diff
changeset
|
537 | name = JABBER_ROSTER_DEFAULT_GROUP; |
|
36009
4db2936dd842
Backport 407e0fa6f7d1: don't split contacts on default group (xmpp)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31794
diff
changeset
|
538 | |
|
4db2936dd842
Backport 407e0fa6f7d1: don't split contacts on default group (xmpp)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31794
diff
changeset
|
539 | return name; |
|
4db2936dd842
Backport 407e0fa6f7d1: don't split contacts on default group (xmpp)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31794
diff
changeset
|
540 | } |