annotate libpurple/protocols/jabber/roster.c @ 29592:0b54934f2742

Remove a couple more unnecessary headers from media.c
author maiku@pidgin.im
date Tue, 27 Oct 2009 21:50:19 +0000
parents 5c61429ea529
children 05867b153f03
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /*
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
2 * purple - Jabber Protocol Plugin
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
28398
c585572e80dd Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents: 28132
diff changeset
4 * Purple is the legal property of its developers, whose names are too numerous
c585572e80dd Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents: 28132
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
c585572e80dd Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents: 28132
diff changeset
6 * source distribution.
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * 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
9 * 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
10 * 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
11 * (at your option) any later version.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * 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
14 * 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
15 * 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
16 * GNU General Public License for more details.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * 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
19 * along with this program; if not, write to the Free Software
19680
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19455
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 #include "internal.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24 #include "debug.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25 #include "server.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26 #include "util.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 #include "buddy.h"
28506
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28398
diff changeset
29 #include "chat.h"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 #include "google.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 #include "presence.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 #include "roster.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 #include "iq.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 #include <string.h>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36
27575
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27574
diff changeset
37 /* Take a list of strings and join them with a ", " separator */
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27574
diff changeset
38 static gchar *roster_groups_join(GSList *list)
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27574
diff changeset
39 {
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27574
diff changeset
40 GString *out = g_string_new(NULL);
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27574
diff changeset
41 for ( ; list; list = list->next) {
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27574
diff changeset
42 out = g_string_append(out, (const char *)list->data);
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27574
diff changeset
43 if (list->next)
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27574
diff changeset
44 out = g_string_append(out, ", ");
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27574
diff changeset
45 }
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27574
diff changeset
46
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27574
diff changeset
47 return g_string_free(out, FALSE);
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27574
diff changeset
48 }
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27574
diff changeset
49
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 void jabber_roster_request(JabberStream *js)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 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
55
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 jabber_iq_send(iq);
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
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
59 static void remove_purple_buddies(JabberStream *js, const char *jid)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61 GSList *buddies, *l;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
63 buddies = purple_find_buddies(js->gc->account, jid);
15374
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 for(l = buddies; l; l = l->next)
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
66 purple_blist_remove_buddy(l->data);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68 g_slist_free(buddies);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70
27570
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27569
diff changeset
71 static void add_purple_buddy_to_groups(JabberStream *js, const char *jid,
28132
eb2d17945ce3 jabber: Store the "own JabberBuddy" in the JabberStream* struct.
Paul Aurich <paul@darkrain42.org>
parents: 27581
diff changeset
72 const char *alias, GSList *groups)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73 {
27570
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27569
diff changeset
74 GSList *buddies, *l;
27575
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27574
diff changeset
75 GSList *pool = NULL;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
77 buddies = purple_find_buddies(js->gc->account, jid);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 if(!groups) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 if(!buddies)
27570
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27569
diff changeset
81 groups = g_slist_append(groups, g_strdup(_("Buddies")));
20329
24ce4fcce5b0 applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents: 19680
diff changeset
82 else {
27570
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27569
diff changeset
83 /* TODO: What should we do here? Removing the local buddies
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27569
diff changeset
84 * 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: 27569
diff changeset
85 * the server.
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27569
diff changeset
86 */
20329
24ce4fcce5b0 applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents: 19680
diff changeset
87 g_slist_free(buddies);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88 return;
20329
24ce4fcce5b0 applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents: 19680
diff changeset
89 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
90 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92 while(buddies) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
93 PurpleBuddy *b = buddies->data;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
94 PurpleGroup *g = purple_buddy_get_group(b);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95
27570
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27569
diff changeset
96 buddies = g_slist_delete_link(buddies, buddies);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97
27570
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27569
diff changeset
98 /* XMPP groups are case-sensitive, but libpurple groups are
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27569
diff changeset
99 * case-insensitive. We treat a buddy in both "Friends" and "friends"
27581
1638786071af Clarify a comment a little.
Paul Aurich <paul@darkrain42.org>
parents: 27580
diff changeset
100 * as only being in one group, but if we push changes about the buddy
27570
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27569
diff changeset
101 * to the server, the buddy will be dropped from one of the groups.
27581
1638786071af Clarify a comment a little.
Paul Aurich <paul@darkrain42.org>
parents: 27580
diff changeset
102 * Not optimal, but better than the alternative, I think.
27570
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27569
diff changeset
103 */
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27569
diff changeset
104 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: 27569
diff changeset
105 /* The buddy is already on the local list. Update info. */
25294
8aa7d8bcbc7d Alias foo. I think blist.h structs are now completely hidden.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24120
diff changeset
106 const char *servernick, *balias;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107
23932
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: 23705
diff changeset
108 /* Previously stored serverside / buddy-supplied alias */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
109 if((servernick = purple_blist_node_get_string((PurpleBlistNode*)b, "servernick")))
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 serv_got_alias(js->gc, jid, servernick);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111
23932
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: 23705
diff changeset
112 /* Alias from our roster retrieval */
25294
8aa7d8bcbc7d Alias foo. I think blist.h structs are now completely hidden.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24120
diff changeset
113 balias = purple_buddy_get_local_buddy_alias(b);
27570
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27569
diff changeset
114 if(alias && !purple_strequal(alias, balias))
23932
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: 23705
diff changeset
115 purple_serv_got_private_alias(js->gc, jid, alias);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116 g_free(l->data);
27570
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27569
diff changeset
117 groups = g_slist_delete_link(groups, l);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118 } else {
27570
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27569
diff changeset
119 /* This buddy isn't in the group on the server anymore */
27575
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27574
diff changeset
120 pool = g_slist_prepend(pool, b);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123
27575
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27574
diff changeset
124 if (pool) {
27580
72cf7e73a869 Properly print pool, a list of PurpleBuddies, not strings.
Paul Aurich <paul@darkrain42.org>
parents: 27576
diff changeset
125 GString *tmp = g_string_new(NULL);
72cf7e73a869 Properly print pool, a list of PurpleBuddies, not strings.
Paul Aurich <paul@darkrain42.org>
parents: 27576
diff changeset
126 GSList *list = pool;
72cf7e73a869 Properly print pool, a list of PurpleBuddies, not strings.
Paul Aurich <paul@darkrain42.org>
parents: 27576
diff changeset
127 for ( ; list; list = list->next) {
72cf7e73a869 Properly print pool, a list of PurpleBuddies, not strings.
Paul Aurich <paul@darkrain42.org>
parents: 27576
diff changeset
128 tmp = g_string_append(tmp,
72cf7e73a869 Properly print pool, a list of PurpleBuddies, not strings.
Paul Aurich <paul@darkrain42.org>
parents: 27576
diff changeset
129 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: 27576
diff changeset
130 if (list->next)
72cf7e73a869 Properly print pool, a list of PurpleBuddies, not strings.
Paul Aurich <paul@darkrain42.org>
parents: 27576
diff changeset
131 tmp = g_string_append(tmp, ", ");
72cf7e73a869 Properly print pool, a list of PurpleBuddies, not strings.
Paul Aurich <paul@darkrain42.org>
parents: 27576
diff changeset
132 }
72cf7e73a869 Properly print pool, a list of PurpleBuddies, not strings.
Paul Aurich <paul@darkrain42.org>
parents: 27576
diff changeset
133
27575
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27574
diff changeset
134 purple_debug_info("jabber", "jabber_roster_parse(): Removing %s from "
27580
72cf7e73a869 Properly print pool, a list of PurpleBuddies, not strings.
Paul Aurich <paul@darkrain42.org>
parents: 27576
diff changeset
135 "groups: %s\n", jid, tmp->str);
72cf7e73a869 Properly print pool, a list of PurpleBuddies, not strings.
Paul Aurich <paul@darkrain42.org>
parents: 27576
diff changeset
136 g_string_free(tmp, TRUE);
27575
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27574
diff changeset
137 }
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27574
diff changeset
138
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27574
diff changeset
139 if (groups) {
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27574
diff changeset
140 char *tmp = roster_groups_join(groups);
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27574
diff changeset
141 purple_debug_info("jabber", "jabber_roster_parse(): Adding %s to "
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27574
diff changeset
142 "groups: %s\n", jid, tmp);
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27574
diff changeset
143 g_free(tmp);
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27574
diff changeset
144 }
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27574
diff changeset
145
27570
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27569
diff changeset
146 while(groups) {
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27569
diff changeset
147 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
148 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
149
27570
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27569
diff changeset
150 /* If there are buddies we would otherwise delete, move them to
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27569
diff changeset
151 * the new group (instead of deleting them below)
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27569
diff changeset
152 */
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
153 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
154 b = pool->data;
27575
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27574
diff changeset
155 pool = g_slist_delete_link(pool, pool);
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25327
diff changeset
156 } 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
157 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
158 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160 if(!g) {
27570
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27569
diff changeset
161 g = purple_group_new(groups->data);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
162 purple_blist_add_group(g, NULL);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
165 purple_blist_add_buddy(b, NULL, g, NULL);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
166 purple_blist_alias_buddy(b, alias);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167
27570
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27569
diff changeset
168 g_free(groups->data);
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27569
diff changeset
169 groups = g_slist_delete_link(groups, groups);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171
27570
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27569
diff changeset
172 /* 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: 27569
diff changeset
173 * 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
174 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
175 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
176 purple_blist_remove_buddy(b);
27575
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27574
diff changeset
177 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
178 }
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
179
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180 g_slist_free(buddies);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182
25933
050052891c55 Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents: 24394
diff changeset
183 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: 24394
diff changeset
184 JabberIqType type, const char *id, xmlnode *query)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185 {
25933
050052891c55 Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents: 24394
diff changeset
186 xmlnode *item, *group;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
187
27568
ff099a916d6b Use jabber_is_own_account and perform way fewer normalizations per iteration
Paul Aurich <paul@darkrain42.org>
parents: 27105
diff changeset
188 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: 27105
diff changeset
189 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: 27105
diff changeset
190 from);
ff099a916d6b Use jabber_is_own_account and perform way fewer normalizations per iteration
Paul Aurich <paul@darkrain42.org>
parents: 27105
diff changeset
191 return;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
192 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193
23705
9bf36aad8735 We talked about this and decided it was probably cleaner to not use
Mark Doliner <mark@kingant.net>
parents: 23691
diff changeset
194 js->currently_parsing_roster_push = TRUE;
23691
c31dfae66134 Hopefully fix the XMPP contact flipping/swapping between groups bug
Mark Doliner <mark@kingant.net>
parents: 23425
diff changeset
195
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
196 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
197 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
198 const char *jid, *name, *subscription, *ask;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
199 JabberBuddy *jb;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
200
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
201 subscription = xmlnode_get_attrib(item, "subscription");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
202 jid = xmlnode_get_attrib(item, "jid");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
203 name = xmlnode_get_attrib(item, "name");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204 ask = xmlnode_get_attrib(item, "ask");
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(!jid)
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(!(jb = jabber_buddy_find(js, jid, TRUE)))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
210 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212 if(subscription) {
28132
eb2d17945ce3 jabber: Store the "own JabberBuddy" in the JabberStream* struct.
Paul Aurich <paul@darkrain42.org>
parents: 27581
diff changeset
213 if (jb == js->user_jb)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214 jb->subscription = JABBER_SUB_BOTH;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215 else if(!strcmp(subscription, "none"))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216 jb->subscription = JABBER_SUB_NONE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217 else if(!strcmp(subscription, "to"))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
218 jb->subscription = JABBER_SUB_TO;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
219 else if(!strcmp(subscription, "from"))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
220 jb->subscription = JABBER_SUB_FROM;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221 else if(!strcmp(subscription, "both"))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
222 jb->subscription = JABBER_SUB_BOTH;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
223 else if(!strcmp(subscription, "remove"))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
224 jb->subscription = JABBER_SUB_REMOVE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226
27569
65b5bc543214 Remove this; it's been commented out for about 3.5 years.
Paul Aurich <paul@darkrain42.org>
parents: 27568
diff changeset
227 if(purple_strequal(ask, "subscribe"))
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228 jb->subscription |= JABBER_SUB_PENDING;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230 jb->subscription &= ~JABBER_SUB_PENDING;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231
28693
5c61429ea529 jabber: Fix removing a buddy with a pending subscription.
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
232 if(jb->subscription & JABBER_SUB_REMOVE) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
233 remove_purple_buddies(js, jid);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235 GSList *groups = NULL;
27570
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27569
diff changeset
236 gboolean seen_empty = FALSE;
20329
24ce4fcce5b0 applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents: 19680
diff changeset
237
24ce4fcce5b0 applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents: 19680
diff changeset
238 if (js->server_caps & JABBER_CAP_GOOGLE_ROSTER)
24ce4fcce5b0 applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents: 19680
diff changeset
239 if (!jabber_google_roster_incoming(js, item))
24ce4fcce5b0 applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents: 19680
diff changeset
240 continue;
24ce4fcce5b0 applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents: 19680
diff changeset
241
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
242 for(group = xmlnode_get_child(item, "group"); group; group = xmlnode_get_next_twin(group)) {
27570
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27569
diff changeset
243 char *group_name = xmlnode_get_data(group);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
244
27570
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27569
diff changeset
245 if (!group_name && !seen_empty) {
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27569
diff changeset
246 group_name = g_strdup("");
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27569
diff changeset
247 seen_empty = TRUE;
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27569
diff changeset
248 }
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27569
diff changeset
249
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27569
diff changeset
250 groups = g_slist_prepend(groups, group_name);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
251 }
27570
93a41017dca9 Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents: 27569
diff changeset
252
28132
eb2d17945ce3 jabber: Store the "own JabberBuddy" in the JabberStream* struct.
Paul Aurich <paul@darkrain42.org>
parents: 27581
diff changeset
253 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: 27581
diff changeset
254 if (jb == js->user_jb)
eb2d17945ce3 jabber: Store the "own JabberBuddy" in the JabberStream* struct.
Paul Aurich <paul@darkrain42.org>
parents: 27581
diff changeset
255 jabber_presence_fake_to_self(js, NULL);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
256 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
257 }
18124
f88c2a41200d fix inital presence (fixes #1395)
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
258
23705
9bf36aad8735 We talked about this and decided it was probably cleaner to not use
Mark Doliner <mark@kingant.net>
parents: 23691
diff changeset
259 js->currently_parsing_roster_push = FALSE;
23691
c31dfae66134 Hopefully fix the XMPP contact flipping/swapping between groups bug
Mark Doliner <mark@kingant.net>
parents: 23425
diff changeset
260
18124
f88c2a41200d fix inital presence (fixes #1395)
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
261 /* if we're just now parsing the roster for the first time,
27571
c8390dc125c1 Use js->state to track whether the roster has been retrieved.
Paul Aurich <paul@darkrain42.org>
parents: 27570
diff changeset
262 * 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: 27570
diff changeset
263 */
c8390dc125c1 Use js->state to track whether the roster has been retrieved.
Paul Aurich <paul@darkrain42.org>
parents: 27570
diff changeset
264 if (js->state != JABBER_STREAM_CONNECTED)
25826
af2b883df9a3 Wait until receiving the roster to tell the core we're logged in
Paul Aurich <paul@darkrain42.org>
parents: 25743
diff changeset
265 jabber_stream_set_state(js, JABBER_STREAM_CONNECTED);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
266 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
267
27576
b9da56683499 Operate on the passed-in GSList.
Paul Aurich <paul@darkrain42.org>
parents: 27575
diff changeset
268 /* jabber_roster_update frees the GSList* passed in */
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
269 static void jabber_roster_update(JabberStream *js, const char *name,
27576
b9da56683499 Operate on the passed-in GSList.
Paul Aurich <paul@darkrain42.org>
parents: 27575
diff changeset
270 GSList *groups)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
271 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
272 PurpleBuddy *b;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
273 PurpleGroup *g;
27576
b9da56683499 Operate on the passed-in GSList.
Paul Aurich <paul@darkrain42.org>
parents: 27575
diff changeset
274 GSList *l;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
275 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
276 xmlnode *query, *item, *group;
25294
8aa7d8bcbc7d Alias foo. I think blist.h structs are now completely hidden.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24120
diff changeset
277 const char *balias;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278
23705
9bf36aad8735 We talked about this and decided it was probably cleaner to not use
Mark Doliner <mark@kingant.net>
parents: 23691
diff changeset
279 if (js->currently_parsing_roster_push)
23691
c31dfae66134 Hopefully fix the XMPP contact flipping/swapping between groups bug
Mark Doliner <mark@kingant.net>
parents: 23425
diff changeset
280 return;
c31dfae66134 Hopefully fix the XMPP contact flipping/swapping between groups bug
Mark Doliner <mark@kingant.net>
parents: 23425
diff changeset
281
20329
24ce4fcce5b0 applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents: 19680
diff changeset
282 if(!(b = purple_find_buddy(js->gc->account, name)))
24ce4fcce5b0 applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents: 19680
diff changeset
283 return;
24ce4fcce5b0 applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents: 19680
diff changeset
284
27576
b9da56683499 Operate on the passed-in GSList.
Paul Aurich <paul@darkrain42.org>
parents: 27575
diff changeset
285 if (groups) {
27575
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27574
diff changeset
286 char *tmp = roster_groups_join(groups);
27093
f2ca52166a0d Add a few more roster debug messages and improve.
Paul Aurich <paul@darkrain42.org>
parents: 27092
diff changeset
287
27576
b9da56683499 Operate on the passed-in GSList.
Paul Aurich <paul@darkrain42.org>
parents: 27575
diff changeset
288 purple_debug_info("jabber", "jabber_roster_update(%s): [Source: "
b9da56683499 Operate on the passed-in GSList.
Paul Aurich <paul@darkrain42.org>
parents: 27575
diff changeset
289 "groups]: groups: %s\n", name, tmp);
27575
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27574
diff changeset
290 g_free(tmp);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
291 } else {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
292 GSList *buddies = purple_find_buddies(js->gc->account, name);
27575
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27574
diff changeset
293 char *tmp;
27093
f2ca52166a0d Add a few more roster debug messages and improve.
Paul Aurich <paul@darkrain42.org>
parents: 27092
diff changeset
294
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
295 if(!buddies)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
296 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
297 while(buddies) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
298 b = buddies->data;
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
299 g = purple_buddy_get_group(b);
24120
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23932
diff changeset
300 groups = g_slist_append(groups, (char *)purple_group_get_name(g));
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
301 buddies = g_slist_remove(buddies, b);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
302 }
27093
f2ca52166a0d Add a few more roster debug messages and improve.
Paul Aurich <paul@darkrain42.org>
parents: 27092
diff changeset
303
27575
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27574
diff changeset
304 tmp = roster_groups_join(groups);
27093
f2ca52166a0d Add a few more roster debug messages and improve.
Paul Aurich <paul@darkrain42.org>
parents: 27092
diff changeset
305 purple_debug_info("jabber", "jabber_roster_update(%s): [Source: local blist]: groups: %s\n",
27575
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27574
diff changeset
306 name, tmp);
efb40ca43589 Debug output when changing group memberships.
Paul Aurich <paul@darkrain42.org>
parents: 27574
diff changeset
307 g_free(tmp);
15374
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
310 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
311
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
312 query = xmlnode_get_child(iq->node, "query");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
313 item = xmlnode_new_child(query, "item");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
314
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
315 xmlnode_set_attrib(item, "jid", name);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
316
25294
8aa7d8bcbc7d Alias foo. I think blist.h structs are now completely hidden.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24120
diff changeset
317 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: 24120
diff changeset
318 xmlnode_set_attrib(item, "name", balias ? balias : "");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
319
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
320 for(l = groups; l; l = l->next) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
321 group = xmlnode_new_child(item, "group");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
322 xmlnode_insert_data(group, l->data, -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
323 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
324
27576
b9da56683499 Operate on the passed-in GSList.
Paul Aurich <paul@darkrain42.org>
parents: 27575
diff changeset
325 g_slist_free(groups);
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25327
diff changeset
326
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
327 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
328 jabber_google_roster_outgoing(js, query, item);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
329 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
330 xmlnode_set_attrib(query, "gr:ext", "2");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
331 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
332 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
333 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
334
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
335 void jabber_roster_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
336 PurpleGroup *group)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
337 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
338 JabberStream *js = gc->proto_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
339 char *who;
28506
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28398
diff changeset
340 JabberID *jid;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
341 JabberBuddy *jb;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
342 JabberBuddyResource *jbr;
24120
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23932
diff changeset
343 const char *name;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
344
27571
c8390dc125c1 Use js->state to track whether the roster has been retrieved.
Paul Aurich <paul@darkrain42.org>
parents: 27570
diff changeset
345 /* 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: 27570
diff changeset
346 if (js->state != JABBER_STREAM_CONNECTED)
15374
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
24120
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23932
diff changeset
349 name = purple_buddy_get_name(buddy);
28506
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28398
diff changeset
350 jid = jabber_id_new(name);
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28398
diff changeset
351 if (jid == NULL) {
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28398
diff changeset
352 /* TODO: Remove the buddy from the list? */
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
353 return;
28506
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28398
diff changeset
354 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
355
28506
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28398
diff changeset
356 /* Adding a chat room or a chat buddy to the roster is *not* supported. */
28659
c42d5c23a9e8 jabber: Don't crash when adding a buddy without a node (no '@'). Closes #10261.
Paul Aurich <paul@darkrain42.org>
parents: 28506
diff changeset
357 if (jid->node && jabber_chat_find(js, jid->node, jid->domain) != NULL) {
28506
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28398
diff changeset
358 /*
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28398
diff changeset
359 * This is the same thing Bonjour does. If it causes problems, move
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28398
diff changeset
360 * it to an idle callback.
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28398
diff changeset
361 */
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28398
diff changeset
362 purple_debug_warning("jabber", "Cowardly refusing to add a MUC user "
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28398
diff changeset
363 "to your buddy list and removing the buddy. "
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28398
diff changeset
364 "Buddies can only be added by real (non-MUC) "
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28398
diff changeset
365 "JID\n");
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28398
diff changeset
366 purple_blist_remove_buddy(buddy);
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28398
diff changeset
367 jabber_id_free(jid);
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28398
diff changeset
368 return;
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28398
diff changeset
369 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
370
28506
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28398
diff changeset
371 who = jabber_id_get_bare_jid(jid);
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28398
diff changeset
372 if (jid->resource != NULL) {
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28398
diff changeset
373 /*
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28398
diff changeset
374 * If the buddy name added contains a resource, strip that off and
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28398
diff changeset
375 * rename the buddy.
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28398
diff changeset
376 */
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28398
diff changeset
377 purple_blist_rename_buddy(buddy, who);
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28398
diff changeset
378 }
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28398
diff changeset
379
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28398
diff changeset
380 jb = jabber_buddy_find(js, who, FALSE);
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28398
diff changeset
381
2e3678cd33a0 jabber: Properly handle adding buddies that contain a resource. Closes #10151.
Paul Aurich <paul@darkrain42.org>
parents: 28398
diff changeset
382 purple_debug_info("jabber", "jabber_roster_add_buddy(): Adding %s\n", who);
27093
f2ca52166a0d Add a few more roster debug messages and improve.
Paul Aurich <paul@darkrain42.org>
parents: 27092
diff changeset
383
23425
a2f63b74fe31 Alright, I'm getting rid of this "groups" thing for the reason listed
Mark Doliner <mark@kingant.net>
parents: 22821
diff changeset
384 jabber_roster_update(js, who, NULL);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
385
28132
eb2d17945ce3 jabber: Store the "own JabberBuddy" in the JabberStream* struct.
Paul Aurich <paul@darkrain42.org>
parents: 27581
diff changeset
386 if (jb == js->user_jb) {
27573
9a5a9a4e7626 Simplify the fake_to_self function.
Paul Aurich <paul@darkrain42.org>
parents: 27571
diff changeset
387 jabber_presence_fake_to_self(js, NULL);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
388 } 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
389 jabber_presence_subscription_set(js, who, "subscribe");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
390 } else if((jbr =jabber_buddy_find_resource(jb, NULL))) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
391 purple_prpl_got_user_status(gc->account, who,
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
392 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
393 "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
394 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
395
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
396 g_free(who);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
397 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
398
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
399 void jabber_roster_alias_change(PurpleConnection *gc, const char *name, const char *alias)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
400 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
401 PurpleBuddy *b = purple_find_buddy(gc->account, name);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
402
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
403 if(b != NULL) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
404 purple_blist_alias_buddy(b, alias);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
405
27093
f2ca52166a0d Add a few more roster debug messages and improve.
Paul Aurich <paul@darkrain42.org>
parents: 27092
diff changeset
406 purple_debug_info("jabber", "jabber_roster_alias_change(): Aliased %s to %s\n",
27105
7c864f388c96 Ladedah I dislike the need to explicitly check for NULL strings.
Paul Aurich <paul@darkrain42.org>
parents: 27093
diff changeset
407 name, alias ? alias : "(null)");
27092
a500f65bd077 Pluck Adium's roster debugging from 86720de21a854aa
Paul Aurich <paul@darkrain42.org>
parents: 26569
diff changeset
408
15374
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, NULL);
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 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
412
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
413 void jabber_roster_group_change(PurpleConnection *gc, const char *name,
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
414 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
415 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
416 GSList *buddies, *groups = NULL;
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
417 PurpleBuddy *b;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
418 PurpleGroup *g;
24120
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23932
diff changeset
419 const char *gname;
15374
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 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
422 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
423
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
424 buddies = purple_find_buddies(gc->account, name);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
425 while(buddies) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
426 b = buddies->data;
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
427 g = purple_buddy_get_group(b);
24120
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23932
diff changeset
428 gname = purple_group_get_name(g);
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23932
diff changeset
429 if(!strcmp(gname, old_group))
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
430 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
431 else
24120
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23932
diff changeset
432 groups = g_slist_append(groups, (char*)gname);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
433 buddies = g_slist_remove(buddies, b);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
434 }
27092
a500f65bd077 Pluck Adium's roster debugging from 86720de21a854aa
Paul Aurich <paul@darkrain42.org>
parents: 26569
diff changeset
435
27093
f2ca52166a0d Add a few more roster debug messages and improve.
Paul Aurich <paul@darkrain42.org>
parents: 27092
diff changeset
436 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: 27092
diff changeset
437 name, old_group, new_group);
27092
a500f65bd077 Pluck Adium's roster debugging from 86720de21a854aa
Paul Aurich <paul@darkrain42.org>
parents: 26569
diff changeset
438
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
439 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
440 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
441
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
442 void jabber_roster_group_rename(PurpleConnection *gc, const char *old_name,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
443 PurpleGroup *group, GList *moved_buddies)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
444 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
445 GList *l;
24120
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23932
diff changeset
446 const char *gname = purple_group_get_name(group);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
447 for(l = moved_buddies; l; l = l->next) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
448 PurpleBuddy *buddy = l->data;
24120
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23932
diff changeset
449 jabber_roster_group_change(gc, purple_buddy_get_name(buddy), old_name, gname);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
450 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
451 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
452
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
453 void jabber_roster_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
454 PurpleGroup *group) {
24120
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23932
diff changeset
455 const char *name = purple_buddy_get_name(buddy);
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23932
diff changeset
456 GSList *buddies = purple_find_buddies(purple_connection_get_account(gc), name);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
457
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
458 buddies = g_slist_remove(buddies, buddy);
15786
e926951e61fe Don't use g_list_length() and g_slist_length() when all you want to
Mark Doliner <mark@kingant.net>
parents: 15634
diff changeset
459 if(buddies != NULL) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
460 PurpleBuddy *tmpbuddy;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
461 PurpleGroup *tmpgroup;
20333
53afc5cce143 applied changes from d4b316d73ebaf93803ca2642e78b8821c3b5d5c7
Luke Schierer <lschiere@pidgin.im>
parents: 20329
diff changeset
462 GSList *groups = NULL;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
463
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
464 while(buddies) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
465 tmpbuddy = buddies->data;
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
466 tmpgroup = purple_buddy_get_group(tmpbuddy);
24120
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23932
diff changeset
467 groups = g_slist_append(groups, (char *)purple_group_get_name(tmpgroup));
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
468 buddies = g_slist_remove(buddies, tmpbuddy);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
469 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
470
27093
f2ca52166a0d Add a few more roster debug messages and improve.
Paul Aurich <paul@darkrain42.org>
parents: 27092
diff changeset
471 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: 27092
diff changeset
472 purple_buddy_get_name(buddy), purple_group_get_name(group));
27092
a500f65bd077 Pluck Adium's roster debugging from 86720de21a854aa
Paul Aurich <paul@darkrain42.org>
parents: 26569
diff changeset
473
24120
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23932
diff changeset
474 jabber_roster_update(gc->proto_data, name, groups);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
475 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
476 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
477 "jabber:iq:roster");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
478 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
479 xmlnode *item = xmlnode_new_child(query, "item");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
480
24120
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23932
diff changeset
481 xmlnode_set_attrib(item, "jid", name);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
482 xmlnode_set_attrib(item, "subscription", "remove");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
483
27093
f2ca52166a0d Add a few more roster debug messages and improve.
Paul Aurich <paul@darkrain42.org>
parents: 27092
diff changeset
484 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: 27092
diff changeset
485 purple_buddy_get_name(buddy));
f2ca52166a0d Add a few more roster debug messages and improve.
Paul Aurich <paul@darkrain42.org>
parents: 27092
diff changeset
486
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
487 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
488 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
489 }