annotate libpurple/protocols/jabber/roster.c @ 29795:c138390bada8

It broke a bit during merge. And the _reserved in the ui ops struct ran out...
author Marcus Lundblad <ml@update.uu.se>
date Thu, 13 Aug 2009 17:40:00 +0000
parents eb2d17945ce3
children c585572e80dd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /*
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15785
diff changeset
2 * purple - Jabber Protocol Plugin
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * (at your option) any later version.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * GNU General Public License for more details.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
19681
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19455
diff changeset
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 #include "internal.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 #include "debug.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 #include "server.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24 #include "util.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26 #include "buddy.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 #include "google.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 #include "presence.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 #include "roster.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 #include "iq.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 #include <string.h>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33
27499
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27498
diff changeset
34 /* Take a list of strings and join them with a ", " separator */
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27498
diff changeset
35 static gchar *roster_groups_join(GSList *list)
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27498
diff changeset
36 {
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27498
diff changeset
37 GString *out = g_string_new(NULL);
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27498
diff changeset
38 for ( ; list; list = list->next) {
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27498
diff changeset
39 out = g_string_append(out, (const char *)list->data);
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27498
diff changeset
40 if (list->next)
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27498
diff changeset
41 out = g_string_append(out, ", ");
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27498
diff changeset
42 }
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27498
diff changeset
43
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27498
diff changeset
44 return g_string_free(out, FALSE);
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27498
diff changeset
45 }
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27498
diff changeset
46
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47 void jabber_roster_request(JabberStream *js)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:roster");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15785
diff changeset
56 static void remove_purple_buddies(JabberStream *js, const char *jid)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58 GSList *buddies, *l;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15785
diff changeset
60 buddies = purple_find_buddies(js->gc->account, jid);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62 for(l = buddies; l; l = l->next)
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15785
diff changeset
63 purple_blist_remove_buddy(l->data);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65 g_slist_free(buddies);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67
27494
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27493
diff changeset
68 static void add_purple_buddy_to_groups(JabberStream *js, const char *jid,
27794
eb2d17945ce3 jabber: Store the "own JabberBuddy" in the JabberStream* struct.
Paul Aurich <paul@darkrain42.org>
parents: 27505
diff changeset
69 const char *alias, GSList *groups)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70 {
27494
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27493
diff changeset
71 GSList *buddies, *l;
27499
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27498
diff changeset
72 GSList *pool = NULL;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15785
diff changeset
74 buddies = purple_find_buddies(js->gc->account, jid);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76 if(!groups) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77 if(!buddies)
27494
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27493
diff changeset
78 groups = g_slist_append(groups, g_strdup(_("Buddies")));
20329
24ce4fcce5b0 applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents: 19681
diff changeset
79 else {
27494
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27493
diff changeset
80 /* TODO: What should we do here? Removing the local buddies
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27493
diff changeset
81 * is wrong, but so is letting the group state get out of sync with
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27493
diff changeset
82 * the server.
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27493
diff changeset
83 */
20329
24ce4fcce5b0 applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents: 19681
diff changeset
84 g_slist_free(buddies);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85 return;
20329
24ce4fcce5b0 applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents: 19681
diff changeset
86 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 while(buddies) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15785
diff changeset
90 PurpleBuddy *b = buddies->data;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15785
diff changeset
91 PurpleGroup *g = purple_buddy_get_group(b);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92
27494
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27493
diff changeset
93 buddies = g_slist_delete_link(buddies, buddies);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94
27494
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27493
diff changeset
95 /* XMPP groups are case-sensitive, but libpurple groups are
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27493
diff changeset
96 * case-insensitive. We treat a buddy in both "Friends" and "friends"
27505
1638786071af Clarify a comment a little.
Paul Aurich <paul@darkrain42.org>
parents: 27504
diff changeset
97 * as only being in one group, but if we push changes about the buddy
27494
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27493
diff changeset
98 * to the server, the buddy will be dropped from one of the groups.
27505
1638786071af Clarify a comment a little.
Paul Aurich <paul@darkrain42.org>
parents: 27504
diff changeset
99 * Not optimal, but better than the alternative, I think.
27494
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27493
diff changeset
100 */
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27493
diff changeset
101 if((l = g_slist_find_custom(groups, purple_group_get_name(g), (GCompareFunc)purple_utf8_strcasecmp))) {
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27493
diff changeset
102 /* The buddy is already on the local list. Update info. */
25803
8aa7d8bcbc7d Alias foo. I think blist.h structs are now completely hidden.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25130
diff changeset
103 const char *servernick, *balias;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104
24002
5e51360bb22c 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 <evan.s@dreskin.net>
parents: 23648
diff changeset
105 /* Previously stored serverside / buddy-supplied alias */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15785
diff changeset
106 if((servernick = purple_blist_node_get_string((PurpleBlistNode*)b, "servernick")))
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107 serv_got_alias(js->gc, jid, servernick);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108
24002
5e51360bb22c 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 <evan.s@dreskin.net>
parents: 23648
diff changeset
109 /* Alias from our roster retrieval */
25803
8aa7d8bcbc7d Alias foo. I think blist.h structs are now completely hidden.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25130
diff changeset
110 balias = purple_buddy_get_local_buddy_alias(b);
27494
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27493
diff changeset
111 if(alias && !purple_strequal(alias, balias))
24002
5e51360bb22c 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 <evan.s@dreskin.net>
parents: 23648
diff changeset
112 purple_serv_got_private_alias(js->gc, jid, alias);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113 g_free(l->data);
27494
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27493
diff changeset
114 groups = g_slist_delete_link(groups, l);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115 } else {
27494
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27493
diff changeset
116 /* This buddy isn't in the group on the server anymore */
27499
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27498
diff changeset
117 pool = g_slist_prepend(pool, b);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120
27499
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27498
diff changeset
121 if (pool) {
27504
72cf7e73a869 Properly print pool, a list of PurpleBuddies, not strings.
Paul Aurich <paul@darkrain42.org>
parents: 27500
diff changeset
122 GString *tmp = g_string_new(NULL);
72cf7e73a869 Properly print pool, a list of PurpleBuddies, not strings.
Paul Aurich <paul@darkrain42.org>
parents: 27500
diff changeset
123 GSList *list = pool;
72cf7e73a869 Properly print pool, a list of PurpleBuddies, not strings.
Paul Aurich <paul@darkrain42.org>
parents: 27500
diff changeset
124 for ( ; list; list = list->next) {
72cf7e73a869 Properly print pool, a list of PurpleBuddies, not strings.
Paul Aurich <paul@darkrain42.org>
parents: 27500
diff changeset
125 tmp = g_string_append(tmp,
72cf7e73a869 Properly print pool, a list of PurpleBuddies, not strings.
Paul Aurich <paul@darkrain42.org>
parents: 27500
diff changeset
126 purple_group_get_name(purple_buddy_get_group(list->data)));
72cf7e73a869 Properly print pool, a list of PurpleBuddies, not strings.
Paul Aurich <paul@darkrain42.org>
parents: 27500
diff changeset
127 if (list->next)
72cf7e73a869 Properly print pool, a list of PurpleBuddies, not strings.
Paul Aurich <paul@darkrain42.org>
parents: 27500
diff changeset
128 tmp = g_string_append(tmp, ", ");
72cf7e73a869 Properly print pool, a list of PurpleBuddies, not strings.
Paul Aurich <paul@darkrain42.org>
parents: 27500
diff changeset
129 }
72cf7e73a869 Properly print pool, a list of PurpleBuddies, not strings.
Paul Aurich <paul@darkrain42.org>
parents: 27500
diff changeset
130
27499
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27498
diff changeset
131 purple_debug_info("jabber", "jabber_roster_parse(): Removing %s from "
27504
72cf7e73a869 Properly print pool, a list of PurpleBuddies, not strings.
Paul Aurich <paul@darkrain42.org>
parents: 27500
diff changeset
132 "groups: %s\n", jid, tmp->str);
72cf7e73a869 Properly print pool, a list of PurpleBuddies, not strings.
Paul Aurich <paul@darkrain42.org>
parents: 27500
diff changeset
133 g_string_free(tmp, TRUE);
27499
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27498
diff changeset
134 }
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27498
diff changeset
135
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27498
diff changeset
136 if (groups) {
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27498
diff changeset
137 char *tmp = roster_groups_join(groups);
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27498
diff changeset
138 purple_debug_info("jabber", "jabber_roster_parse(): Adding %s to "
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27498
diff changeset
139 "groups: %s\n", jid, tmp);
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27498
diff changeset
140 g_free(tmp);
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27498
diff changeset
141 }
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27498
diff changeset
142
27494
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27493
diff changeset
143 while(groups) {
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27493
diff changeset
144 PurpleGroup *g = purple_find_group(groups->data);
19455
6950ffd2291f Update the buddylist if a buddy is moved to another group from a different
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18124
diff changeset
145 PurpleBuddy *b = NULL;
6950ffd2291f Update the buddylist if a buddy is moved to another group from a different
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18124
diff changeset
146
27494
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27493
diff changeset
147 /* If there are buddies we would otherwise delete, move them to
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27493
diff changeset
148 * the new group (instead of deleting them below)
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27493
diff changeset
149 */
19455
6950ffd2291f Update the buddylist if a buddy is moved to another group from a different
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18124
diff changeset
150 if (pool) {
6950ffd2291f Update the buddylist if a buddy is moved to another group from a different
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18124
diff changeset
151 b = pool->data;
27499
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27498
diff changeset
152 pool = g_slist_delete_link(pool, pool);
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25836
diff changeset
153 } else {
19455
6950ffd2291f Update the buddylist if a buddy is moved to another group from a different
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18124
diff changeset
154 b = purple_buddy_new(js->gc->account, jid, alias);
6950ffd2291f Update the buddylist if a buddy is moved to another group from a different
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18124
diff changeset
155 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157 if(!g) {
27494
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27493
diff changeset
158 g = purple_group_new(groups->data);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15785
diff changeset
159 purple_blist_add_group(g, NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
161
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15785
diff changeset
162 purple_blist_add_buddy(b, NULL, g, NULL);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15785
diff changeset
163 purple_blist_alias_buddy(b, alias);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164
27494
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27493
diff changeset
165 g_free(groups->data);
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27493
diff changeset
166 groups = g_slist_delete_link(groups, groups);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168
27494
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27493
diff changeset
169 /* Remove this person from all the groups they're no longer in on the
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27493
diff changeset
170 * server */
19455
6950ffd2291f Update the buddylist if a buddy is moved to another group from a different
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18124
diff changeset
171 while (pool) {
6950ffd2291f Update the buddylist if a buddy is moved to another group from a different
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18124
diff changeset
172 PurpleBuddy *b = pool->data;
6950ffd2291f Update the buddylist if a buddy is moved to another group from a different
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18124
diff changeset
173 purple_blist_remove_buddy(b);
27499
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27498
diff changeset
174 pool = g_slist_delete_link(pool, pool);
19455
6950ffd2291f Update the buddylist if a buddy is moved to another group from a different
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18124
diff changeset
175 }
6950ffd2291f Update the buddylist if a buddy is moved to another group from a different
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18124
diff changeset
176
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177 g_slist_free(buddies);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
178 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179
25648
050052891c55 Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents: 24451
diff changeset
180 void jabber_roster_parse(JabberStream *js, const char *from,
050052891c55 Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents: 24451
diff changeset
181 JabberIqType type, const char *id, xmlnode *query)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182 {
25648
050052891c55 Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents: 24451
diff changeset
183 xmlnode *item, *group;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184
27492
ff099a916d6b Use jabber_is_own_account and perform way fewer normalizations per iteration
Paul Aurich <paul@darkrain42.org>
parents: 27023
diff changeset
185 if (!jabber_is_own_account(js, from)) {
ff099a916d6b Use jabber_is_own_account and perform way fewer normalizations per iteration
Paul Aurich <paul@darkrain42.org>
parents: 27023
diff changeset
186 purple_debug_warning("jabber", "Received bogon roster push from %s\n",
ff099a916d6b Use jabber_is_own_account and perform way fewer normalizations per iteration
Paul Aurich <paul@darkrain42.org>
parents: 27023
diff changeset
187 from);
ff099a916d6b Use jabber_is_own_account and perform way fewer normalizations per iteration
Paul Aurich <paul@darkrain42.org>
parents: 27023
diff changeset
188 return;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
189 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
190
23648
9bf36aad8735 We talked about this and decided it was probably cleaner to not use
Mark Doliner <mark@kingant.net>
parents: 23646
diff changeset
191 js->currently_parsing_roster_push = TRUE;
23646
c31dfae66134 Hopefully fix the XMPP contact flipping/swapping between groups bug
Mark Doliner <mark@kingant.net>
parents: 23423
diff changeset
192
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193 for(item = xmlnode_get_child(query, "item"); item; item = xmlnode_get_next_twin(item))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
194 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
195 const char *jid, *name, *subscription, *ask;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
196 JabberBuddy *jb;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
197
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
198 subscription = xmlnode_get_attrib(item, "subscription");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
199 jid = xmlnode_get_attrib(item, "jid");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
200 name = xmlnode_get_attrib(item, "name");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
201 ask = xmlnode_get_attrib(item, "ask");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
202
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
203 if(!jid)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206 if(!(jb = jabber_buddy_find(js, jid, TRUE)))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209 if(subscription) {
27794
eb2d17945ce3 jabber: Store the "own JabberBuddy" in the JabberStream* struct.
Paul Aurich <paul@darkrain42.org>
parents: 27505
diff changeset
210 if (jb == js->user_jb)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211 jb->subscription = JABBER_SUB_BOTH;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212 else if(!strcmp(subscription, "none"))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213 jb->subscription = JABBER_SUB_NONE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214 else if(!strcmp(subscription, "to"))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215 jb->subscription = JABBER_SUB_TO;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216 else if(!strcmp(subscription, "from"))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217 jb->subscription = JABBER_SUB_FROM;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
218 else if(!strcmp(subscription, "both"))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
219 jb->subscription = JABBER_SUB_BOTH;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
220 else if(!strcmp(subscription, "remove"))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221 jb->subscription = JABBER_SUB_REMOVE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
222 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
223
27493
65b5bc543214 Remove this; it's been commented out for about 3.5 years.
Paul Aurich <paul@darkrain42.org>
parents: 27492
diff changeset
224 if(purple_strequal(ask, "subscribe"))
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225 jb->subscription |= JABBER_SUB_PENDING;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227 jb->subscription &= ~JABBER_SUB_PENDING;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 if(jb->subscription == JABBER_SUB_REMOVE) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15785
diff changeset
230 remove_purple_buddies(js, jid);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232 GSList *groups = NULL;
27494
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27493
diff changeset
233 gboolean seen_empty = FALSE;
20329
24ce4fcce5b0 applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents: 19681
diff changeset
234
24ce4fcce5b0 applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents: 19681
diff changeset
235 if (js->server_caps & JABBER_CAP_GOOGLE_ROSTER)
24ce4fcce5b0 applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents: 19681
diff changeset
236 if (!jabber_google_roster_incoming(js, item))
24ce4fcce5b0 applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents: 19681
diff changeset
237 continue;
24ce4fcce5b0 applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents: 19681
diff changeset
238
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
239 for(group = xmlnode_get_child(item, "group"); group; group = xmlnode_get_next_twin(group)) {
27494
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27493
diff changeset
240 char *group_name = xmlnode_get_data(group);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
241
27494
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27493
diff changeset
242 if (!group_name && !seen_empty) {
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27493
diff changeset
243 group_name = g_strdup("");
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27493
diff changeset
244 seen_empty = TRUE;
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27493
diff changeset
245 }
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27493
diff changeset
246
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27493
diff changeset
247 groups = g_slist_prepend(groups, group_name);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
248 }
27494
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27493
diff changeset
249
27794
eb2d17945ce3 jabber: Store the "own JabberBuddy" in the JabberStream* struct.
Paul Aurich <paul@darkrain42.org>
parents: 27505
diff changeset
250 add_purple_buddy_to_groups(js, jid, name, groups);
eb2d17945ce3 jabber: Store the "own JabberBuddy" in the JabberStream* struct.
Paul Aurich <paul@darkrain42.org>
parents: 27505
diff changeset
251 if (jb == js->user_jb)
eb2d17945ce3 jabber: Store the "own JabberBuddy" in the JabberStream* struct.
Paul Aurich <paul@darkrain42.org>
parents: 27505
diff changeset
252 jabber_presence_fake_to_self(js, NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
254 }
18124
f88c2a41200d fix inital presence (fixes #1395)
Nathan Walp <nwalp@pidgin.im>
parents: 15822
diff changeset
255
23648
9bf36aad8735 We talked about this and decided it was probably cleaner to not use
Mark Doliner <mark@kingant.net>
parents: 23646
diff changeset
256 js->currently_parsing_roster_push = FALSE;
23646
c31dfae66134 Hopefully fix the XMPP contact flipping/swapping between groups bug
Mark Doliner <mark@kingant.net>
parents: 23423
diff changeset
257
18124
f88c2a41200d fix inital presence (fixes #1395)
Nathan Walp <nwalp@pidgin.im>
parents: 15822
diff changeset
258 /* if we're just now parsing the roster for the first time,
27495
c8390dc125c1 Use js->state to track whether the roster has been retrieved.
Paul Aurich <paul@darkrain42.org>
parents: 27494
diff changeset
259 * then now would be the time to declare ourselves connected.
c8390dc125c1 Use js->state to track whether the roster has been retrieved.
Paul Aurich <paul@darkrain42.org>
parents: 27494
diff changeset
260 */
c8390dc125c1 Use js->state to track whether the roster has been retrieved.
Paul Aurich <paul@darkrain42.org>
parents: 27494
diff changeset
261 if (js->state != JABBER_STREAM_CONNECTED)
25673
af2b883df9a3 Wait until receiving the roster to tell the core we're logged in
Paul Aurich <paul@darkrain42.org>
parents: 25147
diff changeset
262 jabber_stream_set_state(js, JABBER_STREAM_CONNECTED);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
263 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
264
27500
b9da56683499 Operate on the passed-in GSList.
Paul Aurich <paul@darkrain42.org>
parents: 27499
diff changeset
265 /* jabber_roster_update frees the GSList* passed in */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
266 static void jabber_roster_update(JabberStream *js, const char *name,
27500
b9da56683499 Operate on the passed-in GSList.
Paul Aurich <paul@darkrain42.org>
parents: 27499
diff changeset
267 GSList *groups)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
268 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15785
diff changeset
269 PurpleBuddy *b;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15785
diff changeset
270 PurpleGroup *g;
27500
b9da56683499 Operate on the passed-in GSList.
Paul Aurich <paul@darkrain42.org>
parents: 27499
diff changeset
271 GSList *l;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
272 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
273 xmlnode *query, *item, *group;
25803
8aa7d8bcbc7d Alias foo. I think blist.h structs are now completely hidden.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25130
diff changeset
274 const char *balias;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
275
23648
9bf36aad8735 We talked about this and decided it was probably cleaner to not use
Mark Doliner <mark@kingant.net>
parents: 23646
diff changeset
276 if (js->currently_parsing_roster_push)
23646
c31dfae66134 Hopefully fix the XMPP contact flipping/swapping between groups bug
Mark Doliner <mark@kingant.net>
parents: 23423
diff changeset
277 return;
c31dfae66134 Hopefully fix the XMPP contact flipping/swapping between groups bug
Mark Doliner <mark@kingant.net>
parents: 23423
diff changeset
278
20329
24ce4fcce5b0 applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents: 19681
diff changeset
279 if(!(b = purple_find_buddy(js->gc->account, name)))
24ce4fcce5b0 applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents: 19681
diff changeset
280 return;
24ce4fcce5b0 applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents: 19681
diff changeset
281
27500
b9da56683499 Operate on the passed-in GSList.
Paul Aurich <paul@darkrain42.org>
parents: 27499
diff changeset
282 if (groups) {
27499
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27498
diff changeset
283 char *tmp = roster_groups_join(groups);
27011
f2ca52166a0d Add a few more roster debug messages and improve.
Paul Aurich <paul@darkrain42.org>
parents: 27010
diff changeset
284
27500
b9da56683499 Operate on the passed-in GSList.
Paul Aurich <paul@darkrain42.org>
parents: 27499
diff changeset
285 purple_debug_info("jabber", "jabber_roster_update(%s): [Source: "
b9da56683499 Operate on the passed-in GSList.
Paul Aurich <paul@darkrain42.org>
parents: 27499
diff changeset
286 "groups]: groups: %s\n", name, tmp);
27499
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27498
diff changeset
287 g_free(tmp);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
288 } else {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15785
diff changeset
289 GSList *buddies = purple_find_buddies(js->gc->account, name);
27499
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27498
diff changeset
290 char *tmp;
27011
f2ca52166a0d Add a few more roster debug messages and improve.
Paul Aurich <paul@darkrain42.org>
parents: 27010
diff changeset
291
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
292 if(!buddies)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
293 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
294 while(buddies) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
295 b = buddies->data;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15785
diff changeset
296 g = purple_buddy_get_group(b);
25130
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24002
diff changeset
297 groups = g_slist_append(groups, (char *)purple_group_get_name(g));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
298 buddies = g_slist_remove(buddies, b);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
299 }
27011
f2ca52166a0d Add a few more roster debug messages and improve.
Paul Aurich <paul@darkrain42.org>
parents: 27010
diff changeset
300
27499
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27498
diff changeset
301 tmp = roster_groups_join(groups);
27011
f2ca52166a0d Add a few more roster debug messages and improve.
Paul Aurich <paul@darkrain42.org>
parents: 27010
diff changeset
302 purple_debug_info("jabber", "jabber_roster_update(%s): [Source: local blist]: groups: %s\n",
27499
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27498
diff changeset
303 name, tmp);
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27498
diff changeset
304 g_free(tmp);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
305 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
306
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
307 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:roster");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
308
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
309 query = xmlnode_get_child(iq->node, "query");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
310 item = xmlnode_new_child(query, "item");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
311
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
312 xmlnode_set_attrib(item, "jid", name);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
313
25803
8aa7d8bcbc7d Alias foo. I think blist.h structs are now completely hidden.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25130
diff changeset
314 balias = purple_buddy_get_local_buddy_alias(b);
8aa7d8bcbc7d Alias foo. I think blist.h structs are now completely hidden.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25130
diff changeset
315 xmlnode_set_attrib(item, "name", balias ? balias : "");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
316
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
317 for(l = groups; l; l = l->next) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
318 group = xmlnode_new_child(item, "group");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
319 xmlnode_insert_data(group, l->data, -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
320 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
321
27500
b9da56683499 Operate on the passed-in GSList.
Paul Aurich <paul@darkrain42.org>
parents: 27499
diff changeset
322 g_slist_free(groups);
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25836
diff changeset
323
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
324 if (js->server_caps & JABBER_CAP_GOOGLE_ROSTER) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
325 jabber_google_roster_outgoing(js, query, item);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
326 xmlnode_set_attrib(query, "xmlns:gr", "google:roster");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
327 xmlnode_set_attrib(query, "gr:ext", "2");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
328 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
329 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
330 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
331
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15785
diff changeset
332 void jabber_roster_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15785
diff changeset
333 PurpleGroup *group)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
334 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
335 JabberStream *js = gc->proto_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
336 char *who;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
337 JabberBuddy *jb;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
338 JabberBuddyResource *jbr;
25130
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24002
diff changeset
339 const char *name;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
340
27495
c8390dc125c1 Use js->state to track whether the roster has been retrieved.
Paul Aurich <paul@darkrain42.org>
parents: 27494
diff changeset
341 /* If we haven't received the roster yet, ignore any adds */
c8390dc125c1 Use js->state to track whether the roster has been retrieved.
Paul Aurich <paul@darkrain42.org>
parents: 27494
diff changeset
342 if (js->state != JABBER_STREAM_CONNECTED)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
343 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
344
25130
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24002
diff changeset
345 name = purple_buddy_get_name(buddy);
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24002
diff changeset
346 if(!(who = jabber_get_bare_jid(name)))
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
347 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
348
25130
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24002
diff changeset
349 jb = jabber_buddy_find(js, name, FALSE);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
350
27011
f2ca52166a0d Add a few more roster debug messages and improve.
Paul Aurich <paul@darkrain42.org>
parents: 27010
diff changeset
351 purple_debug_info("jabber", "jabber_roster_add_buddy(): Adding %s\n",
f2ca52166a0d Add a few more roster debug messages and improve.
Paul Aurich <paul@darkrain42.org>
parents: 27010
diff changeset
352 name);
f2ca52166a0d Add a few more roster debug messages and improve.
Paul Aurich <paul@darkrain42.org>
parents: 27010
diff changeset
353
23423
a2f63b74fe31 Alright, I'm getting rid of this "groups" thing for the reason listed
Mark Doliner <mark@kingant.net>
parents: 22845
diff changeset
354 jabber_roster_update(js, who, NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
355
27794
eb2d17945ce3 jabber: Store the "own JabberBuddy" in the JabberStream* struct.
Paul Aurich <paul@darkrain42.org>
parents: 27505
diff changeset
356 if (jb == js->user_jb) {
27497
9a5a9a4e7626 Simplify the fake_to_self function.
Paul Aurich <paul@darkrain42.org>
parents: 27495
diff changeset
357 jabber_presence_fake_to_self(js, NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
358 } else if(!jb || !(jb->subscription & JABBER_SUB_TO)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
359 jabber_presence_subscription_set(js, who, "subscribe");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
360 } else if((jbr =jabber_buddy_find_resource(jb, NULL))) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15785
diff changeset
361 purple_prpl_got_user_status(gc->account, who,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
362 jabber_buddy_state_get_status_id(jbr->state),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
363 "priority", jbr->priority, jbr->status ? "message" : NULL, jbr->status, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
364 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
365
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
366 g_free(who);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
367 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
368
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15785
diff changeset
369 void jabber_roster_alias_change(PurpleConnection *gc, const char *name, const char *alias)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
370 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15785
diff changeset
371 PurpleBuddy *b = purple_find_buddy(gc->account, name);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
372
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
373 if(b != NULL) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15785
diff changeset
374 purple_blist_alias_buddy(b, alias);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
375
27011
f2ca52166a0d Add a few more roster debug messages and improve.
Paul Aurich <paul@darkrain42.org>
parents: 27010
diff changeset
376 purple_debug_info("jabber", "jabber_roster_alias_change(): Aliased %s to %s\n",
27023
7c864f388c96 Ladedah I dislike the need to explicitly check for NULL strings.
Paul Aurich <paul@darkrain42.org>
parents: 27011
diff changeset
377 name, alias ? alias : "(null)");
27010
a500f65bd077 Pluck Adium's roster debugging from 86720de21a854aa
Paul Aurich <paul@darkrain42.org>
parents: 26487
diff changeset
378
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
379 jabber_roster_update(gc->proto_data, name, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
380 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
381 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
382
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15785
diff changeset
383 void jabber_roster_group_change(PurpleConnection *gc, const char *name,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
384 const char *old_group, const char *new_group)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
385 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
386 GSList *buddies, *groups = NULL;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15785
diff changeset
387 PurpleBuddy *b;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15785
diff changeset
388 PurpleGroup *g;
25130
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24002
diff changeset
389 const char *gname;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
390
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
391 if(!old_group || !new_group || !strcmp(old_group, new_group))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
392 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
393
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15785
diff changeset
394 buddies = purple_find_buddies(gc->account, name);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
395 while(buddies) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
396 b = buddies->data;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15785
diff changeset
397 g = purple_buddy_get_group(b);
25130
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24002
diff changeset
398 gname = purple_group_get_name(g);
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24002
diff changeset
399 if(!strcmp(gname, old_group))
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
400 groups = g_slist_append(groups, (char*)new_group); /* ick */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
401 else
25130
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24002
diff changeset
402 groups = g_slist_append(groups, (char*)gname);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
403 buddies = g_slist_remove(buddies, b);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
404 }
27010
a500f65bd077 Pluck Adium's roster debugging from 86720de21a854aa
Paul Aurich <paul@darkrain42.org>
parents: 26487
diff changeset
405
27011
f2ca52166a0d Add a few more roster debug messages and improve.
Paul Aurich <paul@darkrain42.org>
parents: 27010
diff changeset
406 purple_debug_info("jabber", "jabber_roster_group_change(): Moving %s from %s to %s\n",
f2ca52166a0d Add a few more roster debug messages and improve.
Paul Aurich <paul@darkrain42.org>
parents: 27010
diff changeset
407 name, old_group, new_group);
27010
a500f65bd077 Pluck Adium's roster debugging from 86720de21a854aa
Paul Aurich <paul@darkrain42.org>
parents: 26487
diff changeset
408
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
409 jabber_roster_update(gc->proto_data, name, groups);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
410 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
411
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15785
diff changeset
412 void jabber_roster_group_rename(PurpleConnection *gc, const char *old_name,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15785
diff changeset
413 PurpleGroup *group, GList *moved_buddies)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
414 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
415 GList *l;
25130
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24002
diff changeset
416 const char *gname = purple_group_get_name(group);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
417 for(l = moved_buddies; l; l = l->next) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15785
diff changeset
418 PurpleBuddy *buddy = l->data;
25130
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24002
diff changeset
419 jabber_roster_group_change(gc, purple_buddy_get_name(buddy), old_name, gname);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
420 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
421 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
422
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15785
diff changeset
423 void jabber_roster_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15785
diff changeset
424 PurpleGroup *group) {
25130
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24002
diff changeset
425 const char *name = purple_buddy_get_name(buddy);
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24002
diff changeset
426 GSList *buddies = purple_find_buddies(purple_connection_get_account(gc), name);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
427
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
428 buddies = g_slist_remove(buddies, buddy);
15785
e926951e61fe Don't use g_list_length() and g_slist_length() when all you want to
Mark Doliner <mark@kingant.net>
parents: 15633
diff changeset
429 if(buddies != NULL) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15785
diff changeset
430 PurpleBuddy *tmpbuddy;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15785
diff changeset
431 PurpleGroup *tmpgroup;
20333
53afc5cce143 applied changes from d4b316d73ebaf93803ca2642e78b8821c3b5d5c7
Luke Schierer <lschiere@pidgin.im>
parents: 20329
diff changeset
432 GSList *groups = NULL;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
433
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
434 while(buddies) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
435 tmpbuddy = buddies->data;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15785
diff changeset
436 tmpgroup = purple_buddy_get_group(tmpbuddy);
25130
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24002
diff changeset
437 groups = g_slist_append(groups, (char *)purple_group_get_name(tmpgroup));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
438 buddies = g_slist_remove(buddies, tmpbuddy);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
439 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
440
27011
f2ca52166a0d Add a few more roster debug messages and improve.
Paul Aurich <paul@darkrain42.org>
parents: 27010
diff changeset
441 purple_debug_info("jabber", "jabber_roster_remove_buddy(): Removing %s from %s\n",
f2ca52166a0d Add a few more roster debug messages and improve.
Paul Aurich <paul@darkrain42.org>
parents: 27010
diff changeset
442 purple_buddy_get_name(buddy), purple_group_get_name(group));
27010
a500f65bd077 Pluck Adium's roster debugging from 86720de21a854aa
Paul Aurich <paul@darkrain42.org>
parents: 26487
diff changeset
443
25130
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24002
diff changeset
444 jabber_roster_update(gc->proto_data, name, groups);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
445 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
446 JabberIq *iq = jabber_iq_new_query(gc->proto_data, JABBER_IQ_SET,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
447 "jabber:iq:roster");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
448 xmlnode *query = xmlnode_get_child(iq->node, "query");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
449 xmlnode *item = xmlnode_new_child(query, "item");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
450
25130
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24002
diff changeset
451 xmlnode_set_attrib(item, "jid", name);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
452 xmlnode_set_attrib(item, "subscription", "remove");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
453
27011
f2ca52166a0d Add a few more roster debug messages and improve.
Paul Aurich <paul@darkrain42.org>
parents: 27010
diff changeset
454 purple_debug_info("jabber", "jabber_roster_remove_buddy(): Removing %s\n",
f2ca52166a0d Add a few more roster debug messages and improve.
Paul Aurich <paul@darkrain42.org>
parents: 27010
diff changeset
455 purple_buddy_get_name(buddy));
f2ca52166a0d Add a few more roster debug messages and improve.
Paul Aurich <paul@darkrain42.org>
parents: 27010
diff changeset
456
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
457 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
458 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
459 }