libpurple/protocols/jabber/google/google_roster.c

Wed, 07 May 2014 13:21:45 +0200

author
Tomasz Wasilczyk <twasilczyk@pidgin.im>
date
Wed, 07 May 2014 13:21:45 +0200
changeset 36011
d8df27a1ebdc
parent 35960
407e0fa6f7d1
parent 36009
4db2936dd842
child 37144
8b63b9948107
permissions
-rw-r--r--

Merge release-2.x.y

29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
1 /**
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
2 * Purple is the legal property of its developers, whose names are too numerous
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
3 * to list here. Please refer to the COPYRIGHT file distributed with this
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
4 * source distribution.
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
5 *
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
9 * (at your option) any later version.
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
10 *
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
14 * GNU General Public License for more details.
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
15 *
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
19 */
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
20
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
21 #include "internal.h"
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
22 #include "google_roster.h"
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
23 #include "jabber.h"
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
24 #include "presence.h"
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
25 #include "debug.h"
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
26 #include "xmlnode.h"
36009
4db2936dd842 Backport 407e0fa6f7d1: don't split contacts on default group (xmpp)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 29914
diff changeset
27 #include "roster.h"
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
28
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
29 void jabber_google_roster_outgoing(JabberStream *js, PurpleXmlNode *query, PurpleXmlNode *item)
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
30 {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
31 PurpleAccount *account = purple_connection_get_account(js->gc);
34578
cfb2f856a5d0 Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents: 33764
diff changeset
32 GSList *list = purple_account_privacy_get_denied(account);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
33 const char *jid = purple_xmlnode_get_attrib(item, "jid");
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
34 char *jid_norm = (char *)jabber_normalize(account, jid);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
35
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
36 while (list) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
37 if (!strcmp(jid_norm, (char*)list->data)) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
38 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: 34728
diff changeset
39 purple_xmlnode_set_attrib(query, "gr:ext", "2");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
40 purple_xmlnode_set_attrib(item, "gr:t", "B");
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
41 return;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
42 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
43 list = list->next;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
44 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
45 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
46
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
47 gboolean jabber_google_roster_incoming(JabberStream *js, PurpleXmlNode *item)
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
48 {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
49 PurpleAccount *account = purple_connection_get_account(js->gc);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
50 const char *jid = purple_xmlnode_get_attrib(item, "jid");
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
51 gboolean on_block_list = FALSE;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
52
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
53 char *jid_norm;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
54
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
55 const char *grt = purple_xmlnode_get_attrib_with_namespace(item, "t", NS_GOOGLE_ROSTER);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
56 const char *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: 34728
diff changeset
57 const char *ask = purple_xmlnode_get_attrib(item, "ask");
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
58
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
59 if ((!subscription || !strcmp(subscription, "none")) && !ask) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
60 /* The Google Talk servers will automatically add people from your Gmail address book
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
61 * with subscription=none. If we see someone with subscription=none, ignore them.
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
62 */
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
63 return FALSE;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
64 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
65
33764
7e7432c7b0aa Fix minor memleaks and hopefully make this logic more sane. We can use
Mark Doliner <mark@kingant.net>
parents: 29914
diff changeset
66 jid_norm = g_strdup(jabber_normalize(account, jid));
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
67
34578
cfb2f856a5d0 Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents: 33764
diff changeset
68 on_block_list = NULL != g_slist_find_custom(purple_account_privacy_get_denied(account),
cfb2f856a5d0 Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents: 33764
diff changeset
69 jid_norm, (GCompareFunc)strcmp);
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
70
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
71 if (grt && (*grt == 'H' || *grt == 'h')) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
72 /* Hidden; don't show this buddy. */
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34717
diff changeset
73 GSList *buddies = purple_blist_find_buddies(account, jid_norm);
33764
7e7432c7b0aa Fix minor memleaks and hopefully make this logic more sane. We can use
Mark Doliner <mark@kingant.net>
parents: 29914
diff changeset
74 if (buddies) {
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
75 purple_debug_info("jabber", "Removing %s from local buddy list\n",
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
76 jid_norm);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
77
33764
7e7432c7b0aa Fix minor memleaks and hopefully make this logic more sane. We can use
Mark Doliner <mark@kingant.net>
parents: 29914
diff changeset
78 do {
7e7432c7b0aa Fix minor memleaks and hopefully make this logic more sane. We can use
Mark Doliner <mark@kingant.net>
parents: 29914
diff changeset
79 purple_blist_remove_buddy(buddies->data);
7e7432c7b0aa Fix minor memleaks and hopefully make this logic more sane. We can use
Mark Doliner <mark@kingant.net>
parents: 29914
diff changeset
80 buddies = g_slist_delete_link(buddies, buddies);
7e7432c7b0aa Fix minor memleaks and hopefully make this logic more sane. We can use
Mark Doliner <mark@kingant.net>
parents: 29914
diff changeset
81 } while (buddies);
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
82 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
83
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
84 g_free(jid_norm);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
85 return FALSE;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
86 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
87
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
88 if (!on_block_list && (grt && (*grt == 'B' || *grt == 'b'))) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
89 purple_debug_info("jabber", "Blocking %s\n", jid_norm);
34578
cfb2f856a5d0 Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents: 33764
diff changeset
90 purple_account_privacy_deny_add(account, jid_norm, TRUE);
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
91 } else if (on_block_list && (!grt || (*grt != 'B' && *grt != 'b' ))){
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
92 purple_debug_info("jabber", "Unblocking %s\n", jid_norm);
34578
cfb2f856a5d0 Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents: 33764
diff changeset
93 purple_account_privacy_deny_remove(account, jid_norm, TRUE);
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
94 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
95
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
96 g_free(jid_norm);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
97 return TRUE;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
98 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
99
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
100 void jabber_google_roster_add_deny(JabberStream *js, const char *who)
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
101 {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
102 PurpleAccount *account;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
103 GSList *buddies;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
104 JabberIq *iq;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
105 PurpleXmlNode *query;
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
106 PurpleXmlNode *item;
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
107 PurpleXmlNode *group;
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
108 PurpleBuddy *b;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
109 JabberBuddy *jb;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
110 const char *balias;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
111
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
112 jb = jabber_buddy_find(js, who, TRUE);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
113
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
114 account = purple_connection_get_account(js->gc);
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34717
diff changeset
115 buddies = purple_blist_find_buddies(account, who);
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
116 if(!buddies)
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
117 return;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
118
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
119 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:roster");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
120
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
121 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: 34728
diff changeset
122 item = purple_xmlnode_new_child(query, "item");
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
123
33764
7e7432c7b0aa Fix minor memleaks and hopefully make this logic more sane. We can use
Mark Doliner <mark@kingant.net>
parents: 29914
diff changeset
124 do {
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
125 PurpleGroup *g;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
126
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
127 b = buddies->data;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
128 g = purple_buddy_get_group(b);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
129
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
130 group = purple_xmlnode_new_child(item, "group");
35960
407e0fa6f7d1 blist: don't localize roster group name to avoid contact splitting
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34935
diff changeset
131 purple_xmlnode_insert_data(group,
36009
4db2936dd842 Backport 407e0fa6f7d1: don't split contacts on default group (xmpp)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 29914
diff changeset
132 jabber_roster_group_get_global_name(g), -1);
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
133
33764
7e7432c7b0aa Fix minor memleaks and hopefully make this logic more sane. We can use
Mark Doliner <mark@kingant.net>
parents: 29914
diff changeset
134 buddies = g_slist_delete_link(buddies, buddies);
7e7432c7b0aa Fix minor memleaks and hopefully make this logic more sane. We can use
Mark Doliner <mark@kingant.net>
parents: 29914
diff changeset
135 } while (buddies);
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
136
34717
b3e588adef5a Global replace purple_buddy_get_local_buddy_alias() with purple_buddy_get_local_alias()
Ankit Vani <a@nevitus.org>
parents: 34578
diff changeset
137 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: 34728
diff changeset
138 purple_xmlnode_set_attrib(item, "jid", who);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
139 purple_xmlnode_set_attrib(item, "name", balias ? balias : "");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
140 purple_xmlnode_set_attrib(item, "gr:t", "B");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
141 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: 34728
diff changeset
142 purple_xmlnode_set_attrib(query, "gr:ext", "2");
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
143
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
144 jabber_iq_send(iq);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
145
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
146 /* Synthesize a sign-off */
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
147 if (jb) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
148 JabberBuddyResource *jbr;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
149 GList *l = jb->resources;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
150 while (l) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
151 jbr = l->data;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
152 if (jbr && jbr->name)
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
153 {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
154 purple_debug_misc("jabber", "Removing resource %s\n", jbr->name);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
155 jabber_buddy_remove_resource(jb, jbr->name);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
156 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
157 l = l->next;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
158 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
159 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
160
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
161 purple_prpl_got_user_status(account, who, "offline", NULL);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
162 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
163
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
164 void jabber_google_roster_rem_deny(JabberStream *js, const char *who)
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
165 {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
166 GSList *buddies;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
167 JabberIq *iq;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
168 PurpleXmlNode *query;
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
169 PurpleXmlNode *item;
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
170 PurpleXmlNode *group;
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
171 PurpleBuddy *b;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
172 const char *balias;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
173
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34717
diff changeset
174 buddies = purple_blist_find_buddies(purple_connection_get_account(js->gc), who);
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
175 if(!buddies)
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
176 return;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
177
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
178 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:roster");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
179
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
180 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: 34728
diff changeset
181 item = purple_xmlnode_new_child(query, "item");
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
182
33764
7e7432c7b0aa Fix minor memleaks and hopefully make this logic more sane. We can use
Mark Doliner <mark@kingant.net>
parents: 29914
diff changeset
183 do {
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
184 PurpleGroup *g;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
185
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
186 b = buddies->data;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
187 g = purple_buddy_get_group(b);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
188
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
189 group = purple_xmlnode_new_child(item, "group");
35960
407e0fa6f7d1 blist: don't localize roster group name to avoid contact splitting
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34935
diff changeset
190 purple_xmlnode_insert_data(group,
36009
4db2936dd842 Backport 407e0fa6f7d1: don't split contacts on default group (xmpp)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 29914
diff changeset
191 jabber_roster_group_get_global_name(g), -1);
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
192
33764
7e7432c7b0aa Fix minor memleaks and hopefully make this logic more sane. We can use
Mark Doliner <mark@kingant.net>
parents: 29914
diff changeset
193 buddies = g_slist_delete_link(buddies, buddies);
7e7432c7b0aa Fix minor memleaks and hopefully make this logic more sane. We can use
Mark Doliner <mark@kingant.net>
parents: 29914
diff changeset
194 } while (buddies);
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
195
34717
b3e588adef5a Global replace purple_buddy_get_local_buddy_alias() with purple_buddy_get_local_alias()
Ankit Vani <a@nevitus.org>
parents: 34578
diff changeset
196 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: 34728
diff changeset
197 purple_xmlnode_set_attrib(item, "jid", who);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
198 purple_xmlnode_set_attrib(item, "name", balias ? balias : "");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
199 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: 34728
diff changeset
200 purple_xmlnode_set_attrib(query, "gr:ext", "2");
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
201
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
202 jabber_iq_send(iq);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
203
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
204 /* See if he's online */
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
205 jabber_presence_subscription_set(js, who, "probe");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
206 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
207

mercurial