libpurple/protocols/jabber/google/google_roster.c

Sun, 16 Aug 2020 18:58:39 -0500

author
Elliott Sales de Andrade <quantum.analyst@gmail.com>
date
Sun, 16 Aug 2020 18:58:39 -0500
changeset 40514
30d9cbf04922
parent 40439
e9838d634d5e
permissions
-rw-r--r--

Fix some leaks.

Also, expand `g_ascii_dtostr` buffers to `G_ASCII_DTOSTR_BUF_SIZE`.

This is the size it's guaranteed to be under, so might as well have it be that size. It not too much bigger than the existing choice anyway.

Testing Done:
Compile only.

Reviewed at https://reviews.imfreedom.org/r/71/

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
40358
e6fe6fc1f516 move all protocols, purple plugins, and purple tests to use purple.h instead of including files individually
Gary Kramlich <grim@reaperworld.com>
parents: 40054
diff changeset
21 #include <purple.h>
e6fe6fc1f516 move all protocols, purple plugins, and purple tests to use purple.h instead of including files individually
Gary Kramlich <grim@reaperworld.com>
parents: 40054
diff changeset
22
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
23 #include "google_roster.h"
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
24 #include "jabber.h"
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
25 #include "presence.h"
36009
4db2936dd842 Backport 407e0fa6f7d1: don't split contacts on default group (xmpp)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 29914
diff changeset
26 #include "roster.h"
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
27
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
28 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
29 {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
30 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
31 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
32 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
33 char *jid_norm = (char *)jabber_normalize(account, jid);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
34
40052
cc03b5af25ea Use GSList functions instead of manual iterations
qarkai <qarkai@gmail.com>
parents: 38358
diff changeset
35 if (g_slist_find_custom(list, jid_norm, (GCompareFunc)g_strcmp0)) {
cc03b5af25ea Use GSList functions instead of manual iterations
qarkai <qarkai@gmail.com>
parents: 38358
diff changeset
36 purple_xmlnode_set_attrib(query, "xmlns:gr", NS_GOOGLE_ROSTER);
cc03b5af25ea Use GSList functions instead of manual iterations
qarkai <qarkai@gmail.com>
parents: 38358
diff changeset
37 purple_xmlnode_set_attrib(query, "gr:ext", "2");
cc03b5af25ea Use GSList functions instead of manual iterations
qarkai <qarkai@gmail.com>
parents: 38358
diff changeset
38 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
39 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
40 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
41
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
42 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
43 {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
44 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
45 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
46 gboolean on_block_list = FALSE;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
47
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
48 char *jid_norm;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
49
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 *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
51 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
52 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
53
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 36009
diff changeset
54 if ((!subscription || purple_strequal(subscription, "none")) && !ask) {
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
55 /* 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
56 * 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
57 */
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
58 return FALSE;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
59 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
60
33764
7e7432c7b0aa Fix minor memleaks and hopefully make this logic more sane. We can use
Mark Doliner <mark@kingant.net>
parents: 29914
diff changeset
61 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
62
34578
cfb2f856a5d0 Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents: 33764
diff changeset
63 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
64 jid_norm, (GCompareFunc)strcmp);
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
65
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
66 if (grt && (*grt == 'H' || *grt == 'h')) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
67 /* 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
68 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
69 if (buddies) {
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
70 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
71 jid_norm);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
72
40052
cc03b5af25ea Use GSList functions instead of manual iterations
qarkai <qarkai@gmail.com>
parents: 38358
diff changeset
73 g_slist_free_full(buddies, (GDestroyNotify)purple_blist_remove_buddy);
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
74 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
75
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
76 g_free(jid_norm);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
77 return FALSE;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
78 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
79
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
80 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
81 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
82 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
83 } 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
84 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
85 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
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 g_free(jid_norm);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
89 return TRUE;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
90 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
91
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
92 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
93 {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
94 PurpleAccount *account;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
95 GSList *buddies;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
96 JabberIq *iq;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
97 PurpleXmlNode *query;
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
98 PurpleXmlNode *item;
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
99 PurpleXmlNode *group;
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
100 PurpleBuddy *b;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
101 JabberBuddy *jb;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
102 const char *balias;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
103
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
104 jb = jabber_buddy_find(js, who, TRUE);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
105
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
106 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
107 buddies = purple_blist_find_buddies(account, who);
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
108 if(!buddies)
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
109 return;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
110
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
111 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
112
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
113 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
114 item = purple_xmlnode_new_child(query, "item");
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
115
33764
7e7432c7b0aa Fix minor memleaks and hopefully make this logic more sane. We can use
Mark Doliner <mark@kingant.net>
parents: 29914
diff changeset
116 do {
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
117 PurpleGroup *g;
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 b = buddies->data;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
120 g = purple_buddy_get_group(b);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
121
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
122 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
123 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
124 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
125
33764
7e7432c7b0aa Fix minor memleaks and hopefully make this logic more sane. We can use
Mark Doliner <mark@kingant.net>
parents: 29914
diff changeset
126 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
127 } while (buddies);
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
128
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
129 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
130 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
131 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
132 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
133 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
134 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
135
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
136 jabber_iq_send(iq);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
137
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
138 /* Synthesize a sign-off */
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
139 if (jb) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
140 JabberBuddyResource *jbr;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
141 GList *l = jb->resources;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
142 while (l) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
143 jbr = l->data;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
144 if (jbr && jbr->name)
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 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
147 jabber_buddy_remove_resource(jb, jbr->name);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
148 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
149 l = l->next;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
150 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
151 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
152
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
153 purple_protocol_got_user_status(account, who, "offline", NULL);
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
154 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
155
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
156 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
157 {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
158 GSList *buddies;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
159 JabberIq *iq;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
160 PurpleXmlNode *query;
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
161 PurpleXmlNode *item;
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
162 PurpleXmlNode *group;
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
163 PurpleBuddy *b;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
164 const char *balias;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
165
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34717
diff changeset
166 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
167 if(!buddies)
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
168 return;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
169
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
170 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
171
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
172 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
173 item = purple_xmlnode_new_child(query, "item");
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
174
33764
7e7432c7b0aa Fix minor memleaks and hopefully make this logic more sane. We can use
Mark Doliner <mark@kingant.net>
parents: 29914
diff changeset
175 do {
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
176 PurpleGroup *g;
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 b = buddies->data;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
179 g = purple_buddy_get_group(b);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
180
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
181 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
182 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
183 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
184
33764
7e7432c7b0aa Fix minor memleaks and hopefully make this logic more sane. We can use
Mark Doliner <mark@kingant.net>
parents: 29914
diff changeset
185 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
186 } while (buddies);
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
187
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
188 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
189 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
190 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
191 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
192 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
193
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
194 jabber_iq_send(iq);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
195
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
196 /* See if he's online */
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
197 jabber_presence_subscription_set(js, who, "probe");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
198 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
199

mercurial