libpurple/protocols/jabber/presence.c

Wed, 09 Dec 2009 03:52:00 +0000

author
Paul Aurich <darkrain42@pidgin.im>
date
Wed, 09 Dec 2009 03:52:00 +0000
branch
next.minor
changeset 29665
ddf17c6b7fed
parent 29664
3df88daabac7
parent 29095
f2260f873535
child 29686
f9dee36112d0
permissions
-rw-r--r--

propagate from branch 'im.pidgin.pidgin' (head 4a511c01e0a6a5334bc9b22472aa99a8607f0455)
to branch 'im.pidgin.pidgin.next.minor' (head 3df88daabac7f762524f1f581666d72047deabac)

7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1 /*
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15810
diff changeset
2 * purple - Jabber Protocol Plugin
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
3 *
28322
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 28138
diff changeset
4 * Purple is the legal property of its developers, whose names are too numerous
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 28138
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 28138
diff changeset
6 * source distribution.
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
7 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
11 * (at your option) any later version.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
12 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
16 * GNU General Public License for more details.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
17 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19335
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
21 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
22 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
23 #include "internal.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
24
15952
c087855dc551 Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15884
diff changeset
25 #include "account.h"
c087855dc551 Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15884
diff changeset
26 #include "conversation.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
27 #include "debug.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
28 #include "notify.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
29 #include "request.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
30 #include "server.h"
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9931
diff changeset
31 #include "status.h"
7095
17d2b54254f8 [gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
32 #include "util.h"
15952
c087855dc551 Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15884
diff changeset
33 #include "xmlnode.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
34
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
35 #include "buddy.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
36 #include "chat.h"
21195
fd63ef5027d7 Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents: 21193
diff changeset
37 #include "google.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
38 #include "presence.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
39 #include "iq.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
40 #include "jutil.h"
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17812
diff changeset
41 #include "adhoccommands.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
42
17800
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
43 #include "usertune.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
44
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
45
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
46 static void chats_send_presence_foreach(gpointer key, gpointer val,
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
47 gpointer user_data)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
48 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
49 JabberChat *chat = val;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
50 xmlnode *presence = user_data;
8577
64f25a17f8e4 [gaim-migrate @ 9326]
Nathan Walp <nwalp@pidgin.im>
parents: 8462
diff changeset
51 char *chat_full_jid;
64f25a17f8e4 [gaim-migrate @ 9326]
Nathan Walp <nwalp@pidgin.im>
parents: 8462
diff changeset
52
23403
a8704d47889f Fix the chat-room rejoining bug where the list appears empty.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23270
diff changeset
53 if(!chat->conv || chat->left)
8577
64f25a17f8e4 [gaim-migrate @ 9326]
Nathan Walp <nwalp@pidgin.im>
parents: 8462
diff changeset
54 return;
64f25a17f8e4 [gaim-migrate @ 9326]
Nathan Walp <nwalp@pidgin.im>
parents: 8462
diff changeset
55
64f25a17f8e4 [gaim-migrate @ 9326]
Nathan Walp <nwalp@pidgin.im>
parents: 8462
diff changeset
56 chat_full_jid = g_strdup_printf("%s@%s/%s", chat->room, chat->server,
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8396
diff changeset
57 chat->handle);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
58
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8396
diff changeset
59 xmlnode_set_attrib(presence, "to", chat_full_jid);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
60 jabber_send(chat->js, presence);
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8396
diff changeset
61 g_free(chat_full_jid);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
62 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
63
27280
55a39efcf7b8 Simplify the fake_to_self function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27278
diff changeset
64 void jabber_presence_fake_to_self(JabberStream *js, PurpleStatus *status)
55a39efcf7b8 Simplify the fake_to_self function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27278
diff changeset
65 {
55a39efcf7b8 Simplify the fake_to_self function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27278
diff changeset
66 PurpleAccount *account;
27964
752edad344b3 jabber: Properly track own idle time in fake_to_self.
Paul Aurich <darkrain42@pidgin.im>
parents: 27860
diff changeset
67 PurplePresence *presence;
27280
55a39efcf7b8 Simplify the fake_to_self function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27278
diff changeset
68 const char *username;
10286
04732ee468cc [gaim-migrate @ 11460]
Nathan Walp <nwalp@pidgin.im>
parents: 10216
diff changeset
69
27280
55a39efcf7b8 Simplify the fake_to_self function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27278
diff changeset
70 g_return_if_fail(js->user != NULL);
10286
04732ee468cc [gaim-migrate @ 11460]
Nathan Walp <nwalp@pidgin.im>
parents: 10216
diff changeset
71
27280
55a39efcf7b8 Simplify the fake_to_self function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27278
diff changeset
72 account = purple_connection_get_account(js->gc);
27860
2b75b87699c8 Support connecting to IDNA XMPP domains.
Paul Aurich <darkrain42@pidgin.im>
parents: 27847
diff changeset
73 username = purple_connection_get_display_name(js->gc);
27964
752edad344b3 jabber: Properly track own idle time in fake_to_self.
Paul Aurich <darkrain42@pidgin.im>
parents: 27860
diff changeset
74 presence = purple_account_get_presence(account);
27280
55a39efcf7b8 Simplify the fake_to_self function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27278
diff changeset
75 if (status == NULL)
27964
752edad344b3 jabber: Properly track own idle time in fake_to_self.
Paul Aurich <darkrain42@pidgin.im>
parents: 27860
diff changeset
76 status = purple_presence_get_active_status(presence);
27280
55a39efcf7b8 Simplify the fake_to_self function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27278
diff changeset
77
55a39efcf7b8 Simplify the fake_to_self function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27278
diff changeset
78 if (purple_find_buddy(account, username)) {
55a39efcf7b8 Simplify the fake_to_self function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27278
diff changeset
79 JabberBuddy *jb = jabber_buddy_find(js, username, TRUE);
8185
3a1d79a4e55a [gaim-migrate @ 8906]
Nathan Walp <nwalp@pidgin.im>
parents: 8182
diff changeset
80 JabberBuddyResource *jbr;
27280
55a39efcf7b8 Simplify the fake_to_self function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27278
diff changeset
81 JabberBuddyState state;
55a39efcf7b8 Simplify the fake_to_self function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27278
diff changeset
82 char *msg;
55a39efcf7b8 Simplify the fake_to_self function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27278
diff changeset
83 int priority;
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9931
diff changeset
84
27280
55a39efcf7b8 Simplify the fake_to_self function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27278
diff changeset
85 g_return_if_fail(jb != NULL);
55a39efcf7b8 Simplify the fake_to_self function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27278
diff changeset
86
55a39efcf7b8 Simplify the fake_to_self function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27278
diff changeset
87 purple_status_to_jabber(status, &state, &msg, &priority);
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9931
diff changeset
88
27280
55a39efcf7b8 Simplify the fake_to_self function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27278
diff changeset
89 if (state == JABBER_BUDDY_STATE_UNAVAILABLE ||
55a39efcf7b8 Simplify the fake_to_self function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27278
diff changeset
90 state == JABBER_BUDDY_STATE_UNKNOWN) {
55a39efcf7b8 Simplify the fake_to_self function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27278
diff changeset
91 jabber_buddy_remove_resource(jb, js->user->resource);
55a39efcf7b8 Simplify the fake_to_self function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27278
diff changeset
92 } else {
27964
752edad344b3 jabber: Properly track own idle time in fake_to_self.
Paul Aurich <darkrain42@pidgin.im>
parents: 27860
diff changeset
93 jbr = jabber_buddy_track_resource(jb, js->user->resource, priority,
752edad344b3 jabber: Properly track own idle time in fake_to_self.
Paul Aurich <darkrain42@pidgin.im>
parents: 27860
diff changeset
94 state, msg);
752edad344b3 jabber: Properly track own idle time in fake_to_self.
Paul Aurich <darkrain42@pidgin.im>
parents: 27860
diff changeset
95 jbr->idle = purple_presence_is_idle(presence) ?
752edad344b3 jabber: Properly track own idle time in fake_to_self.
Paul Aurich <darkrain42@pidgin.im>
parents: 27860
diff changeset
96 purple_presence_get_idle_time(presence) : 0;
27280
55a39efcf7b8 Simplify the fake_to_self function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27278
diff changeset
97 }
14525
b278a2724686 [gaim-migrate @ 17177]
Nathan Walp <nwalp@pidgin.im>
parents: 14254
diff changeset
98
27280
55a39efcf7b8 Simplify the fake_to_self function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27278
diff changeset
99 if ((jbr = jabber_buddy_find_resource(jb, NULL))) {
27964
752edad344b3 jabber: Properly track own idle time in fake_to_self.
Paul Aurich <darkrain42@pidgin.im>
parents: 27860
diff changeset
100 purple_prpl_got_user_status(account, username,
752edad344b3 jabber: Properly track own idle time in fake_to_self.
Paul Aurich <darkrain42@pidgin.im>
parents: 27860
diff changeset
101 jabber_buddy_state_get_status_id(jbr->state),
752edad344b3 jabber: Properly track own idle time in fake_to_self.
Paul Aurich <darkrain42@pidgin.im>
parents: 27860
diff changeset
102 "priority", jbr->priority,
752edad344b3 jabber: Properly track own idle time in fake_to_self.
Paul Aurich <darkrain42@pidgin.im>
parents: 27860
diff changeset
103 jbr->status ? "message" : NULL, jbr->status,
752edad344b3 jabber: Properly track own idle time in fake_to_self.
Paul Aurich <darkrain42@pidgin.im>
parents: 27860
diff changeset
104 NULL);
752edad344b3 jabber: Properly track own idle time in fake_to_self.
Paul Aurich <darkrain42@pidgin.im>
parents: 27860
diff changeset
105 purple_prpl_got_user_idle(account, username, jbr->idle, jbr->idle);
27280
55a39efcf7b8 Simplify the fake_to_self function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27278
diff changeset
106 } else {
27964
752edad344b3 jabber: Properly track own idle time in fake_to_self.
Paul Aurich <darkrain42@pidgin.im>
parents: 27860
diff changeset
107 purple_prpl_got_user_status(account, username, "offline",
752edad344b3 jabber: Properly track own idle time in fake_to_self.
Paul Aurich <darkrain42@pidgin.im>
parents: 27860
diff changeset
108 msg ? "message" : NULL, msg,
752edad344b3 jabber: Properly track own idle time in fake_to_self.
Paul Aurich <darkrain42@pidgin.im>
parents: 27860
diff changeset
109 NULL);
8185
3a1d79a4e55a [gaim-migrate @ 8906]
Nathan Walp <nwalp@pidgin.im>
parents: 8182
diff changeset
110 }
27280
55a39efcf7b8 Simplify the fake_to_self function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27278
diff changeset
111 g_free(msg);
8185
3a1d79a4e55a [gaim-migrate @ 8906]
Nathan Walp <nwalp@pidgin.im>
parents: 8182
diff changeset
112 }
3a1d79a4e55a [gaim-migrate @ 8906]
Nathan Walp <nwalp@pidgin.im>
parents: 8182
diff changeset
113 }
3a1d79a4e55a [gaim-migrate @ 8906]
Nathan Walp <nwalp@pidgin.im>
parents: 8182
diff changeset
114
24717
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
115 void jabber_set_status(PurpleAccount *account, PurpleStatus *status)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
116 {
24717
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
117 PurpleConnection *gc;
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
118 JabberStream *js;
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
119
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
120 if (!purple_account_is_connected(account))
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
121 return;
27155
53502d71efdd Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents: 27145
diff changeset
122
24717
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
123 if (purple_status_is_exclusive(status) && !purple_status_is_active(status)) {
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
124 /* An exclusive status can't be deactivated. You should just
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
125 * activate some other exclusive status. */
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
126 return;
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
127 }
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
128
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
129 gc = purple_account_get_connection(account);
26072
e8fce2b2b9fe propagate from branch 'im.pidgin.pidgin' (head b4bbfacd7f2050d87deeda12ea7bb3adc3608cb7)
Paul Aurich <darkrain42@pidgin.im>
parents: 26042 25482
diff changeset
130 js = purple_connection_get_protocol_data(gc);
24717
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
131 jabber_presence_send(js, FALSE);
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
132 }
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
133
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
134 void jabber_presence_send(JabberStream *js, gboolean force)
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
135 {
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
136 PurpleAccount *account;
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 10116
diff changeset
137 xmlnode *presence, *x, *photo;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
138 char *stripped = NULL;
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9931
diff changeset
139 JabberBuddyState state;
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9931
diff changeset
140 int priority;
21193
e918a1846d03 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20169
diff changeset
141 const char *artist = NULL, *title = NULL, *source = NULL, *uri = NULL, *track = NULL;
e918a1846d03 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20169
diff changeset
142 int length = -1;
17824
52683dfc1f7d Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <am@adiumx.com>
parents: 17816
diff changeset
143 gboolean allowBuzz;
21758
e70c407c994b We need to work with the exclusive status.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21687
diff changeset
144 PurplePresence *p;
24717
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
145 PurpleStatus *status, *tune;
18195
9cd0565f856e kill some code duplication when sending current presence
Nathan Walp <nwalp@pidgin.im>
parents: 17703
diff changeset
146
24717
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
147 account = purple_connection_get_account(js->gc);
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
148 p = purple_account_get_presence(account);
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
149 status = purple_presence_get_active_status(p);
10755
a336a5d3102d [gaim-migrate @ 12358]
Mark Doliner <markdoliner@pidgin.im>
parents: 10738
diff changeset
150
18226
adf83935e838 really and truly enforce the no-presence-before-roster thing
Nathan Walp <nwalp@pidgin.im>
parents: 18195
diff changeset
151 /* we don't want to send presence before we've gotten our roster */
27278
b34a1cea4872 Use js->state to track whether the roster has been retrieved.
Paul Aurich <darkrain42@pidgin.im>
parents: 27202
diff changeset
152 if (js->state != JABBER_STREAM_CONNECTED) {
29095
f2260f873535 jabber: Lower the prio of this message; it's not very important.
Paul Aurich <darkrain42@pidgin.im>
parents: 29059
diff changeset
153 purple_debug_misc("jabber", "attempt to send presence before roster retrieved\n");
18226
adf83935e838 really and truly enforce the no-presence-before-roster thing
Nathan Walp <nwalp@pidgin.im>
parents: 18195
diff changeset
154 return;
adf83935e838 really and truly enforce the no-presence-before-roster thing
Nathan Walp <nwalp@pidgin.im>
parents: 18195
diff changeset
155 }
adf83935e838 really and truly enforce the no-presence-before-roster thing
Nathan Walp <nwalp@pidgin.im>
parents: 18195
diff changeset
156
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15810
diff changeset
157 purple_status_to_jabber(status, &state, &stripped, &priority);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25154
diff changeset
158
17824
52683dfc1f7d Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <am@adiumx.com>
parents: 17816
diff changeset
159 /* check for buzz support */
52683dfc1f7d Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <am@adiumx.com>
parents: 17816
diff changeset
160 allowBuzz = purple_status_get_attr_boolean(status,"buzz");
52683dfc1f7d Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <am@adiumx.com>
parents: 17816
diff changeset
161 /* changing the buzz state has to trigger a re-broadcasting of the presence for caps */
23574
5c7073191c5a make googletalk tune hack work, previously it's not doing anything unless
Ka-Hing Cheung <khc@pidgin.im>
parents: 23403
diff changeset
162
24717
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
163 tune = purple_presence_get_status(p, "tune");
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
164 if (js->googletalk && !stripped && purple_status_is_active(tune)) {
23574
5c7073191c5a make googletalk tune hack work, previously it's not doing anything unless
Ka-Hing Cheung <khc@pidgin.im>
parents: 23403
diff changeset
165 stripped = jabber_google_presence_outgoing(tune);
5c7073191c5a make googletalk tune hack work, previously it's not doing anything unless
Ka-Hing Cheung <khc@pidgin.im>
parents: 23403
diff changeset
166 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25154
diff changeset
167
17800
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
168 #define CHANGED(a,b) ((!a && b) || (a && a[0] == '\0' && b && b[0] != '\0') || \
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
169 (a && !b) || (a && a[0] != '\0' && b && b[0] == '\0') || (a && b && strcmp(a,b)))
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
170 /* check if there are any differences to the <presence> and send them in that case */
24717
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
171 if (force || allowBuzz != js->allowBuzz || js->old_state != state ||
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
172 CHANGED(js->old_msg, stripped) || js->old_priority != priority ||
26958
a955bd42f529 propagate from branch 'im.pidgin.pidgin' (head 36f75a1d52a6af5574bf847d60054a1392dcbc67)
Paul Aurich <darkrain42@pidgin.im>
parents: 26707 26948
diff changeset
173 CHANGED(js->old_avatarhash, js->avatar_hash) || js->old_idle != js->idle) {
24717
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
174 /* Need to update allowBuzz before creating the presence (with caps) */
17824
52683dfc1f7d Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <am@adiumx.com>
parents: 17816
diff changeset
175 js->allowBuzz = allowBuzz;
21195
fd63ef5027d7 Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents: 21193
diff changeset
176
17800
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
177 presence = jabber_presence_create_js(js, state, stripped, priority);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
178
25810
5cf3c22e52df Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents: 25154
diff changeset
179 /* Per XEP-0153 4.1, we must always send the <x> */
5cf3c22e52df Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents: 25154
diff changeset
180 x = xmlnode_new_child(presence, "x");
5cf3c22e52df Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents: 25154
diff changeset
181 xmlnode_set_namespace(x, "vcard-temp:x:update");
5cf3c22e52df Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents: 25154
diff changeset
182 /*
5cf3c22e52df Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents: 25154
diff changeset
183 * FIXME: Per XEP-0153 4.3.2 bullet 2, we must not publish our
5cf3c22e52df Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents: 25154
diff changeset
184 * image hash if another resource has logged in and updated the
5cf3c22e52df Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents: 25154
diff changeset
185 * vcard avatar. Requires changes in jabber_presence_parse.
5cf3c22e52df Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents: 25154
diff changeset
186 */
5cf3c22e52df Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents: 25154
diff changeset
187 if (js->vcard_fetched) {
5cf3c22e52df Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents: 25154
diff changeset
188 /* Always publish a <photo>; it's empty if we have no image. */
17800
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
189 photo = xmlnode_new_child(x, "photo");
25810
5cf3c22e52df Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents: 25154
diff changeset
190 if (js->avatar_hash)
5cf3c22e52df Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents: 25154
diff changeset
191 xmlnode_insert_data(photo, js->avatar_hash, -1);
17800
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
192 }
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
193
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
194 jabber_send(js, presence);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
195
17800
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
196 g_hash_table_foreach(js->chats, chats_send_presence_foreach, presence);
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
197 xmlnode_free(presence);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25154
diff changeset
198
17800
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
199 /* update old values */
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25154
diff changeset
200
17800
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
201 if(js->old_msg)
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
202 g_free(js->old_msg);
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
203 if(js->old_avatarhash)
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
204 g_free(js->old_avatarhash);
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
205 js->old_msg = g_strdup(stripped);
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
206 js->old_avatarhash = g_strdup(js->avatar_hash);
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
207 js->old_state = state;
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
208 js->old_priority = priority;
25229
d89db7b7fb94 Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 25228
diff changeset
209 js->old_idle = js->idle;
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 10116
diff changeset
210 }
23575
7a22a015d694 let's not leak if nothing is changed
Ka-Hing Cheung <khc@pidgin.im>
parents: 23574
diff changeset
211 g_free(stripped);
7a22a015d694 let's not leak if nothing is changed
Ka-Hing Cheung <khc@pidgin.im>
parents: 23574
diff changeset
212
17800
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
213 /* next, check if there are any changes to the tune values */
24717
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
214 if (purple_status_is_active(tune)) {
21193
e918a1846d03 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20169
diff changeset
215 artist = purple_status_get_attr_string(tune, PURPLE_TUNE_ARTIST);
e918a1846d03 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20169
diff changeset
216 title = purple_status_get_attr_string(tune, PURPLE_TUNE_TITLE);
e918a1846d03 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20169
diff changeset
217 source = purple_status_get_attr_string(tune, PURPLE_TUNE_ALBUM);
e918a1846d03 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20169
diff changeset
218 uri = purple_status_get_attr_string(tune, PURPLE_TUNE_URL);
e918a1846d03 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20169
diff changeset
219 track = purple_status_get_attr_string(tune, PURPLE_TUNE_TRACK);
e918a1846d03 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20169
diff changeset
220 length = (!purple_status_get_attr_value(tune, PURPLE_TUNE_TIME)) ? -1 :
e918a1846d03 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20169
diff changeset
221 purple_status_get_attr_int(tune, PURPLE_TUNE_TIME);
e918a1846d03 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20169
diff changeset
222 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25154
diff changeset
223
17800
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
224 if(CHANGED(artist, js->old_artist) || CHANGED(title, js->old_title) || CHANGED(source, js->old_source) ||
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
225 CHANGED(uri, js->old_uri) || CHANGED(track, js->old_track) || (length != js->old_length)) {
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
226 PurpleJabberTuneInfo tuneinfo = {
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
227 (char*)artist,
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
228 (char*)title,
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
229 (char*)source,
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
230 (char*)track,
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
231 length,
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
232 (char*)uri
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
233 };
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
234 jabber_tune_set(js->gc, &tuneinfo);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25154
diff changeset
235
17800
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
236 /* update old values */
20169
497e1cd1e059 Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents: 19899
diff changeset
237 g_free(js->old_artist);
497e1cd1e059 Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents: 19899
diff changeset
238 g_free(js->old_title);
497e1cd1e059 Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents: 19899
diff changeset
239 g_free(js->old_source);
497e1cd1e059 Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents: 19899
diff changeset
240 g_free(js->old_uri);
497e1cd1e059 Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents: 19899
diff changeset
241 g_free(js->old_track);
17800
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
242 js->old_artist = g_strdup(artist);
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
243 js->old_title = g_strdup(title);
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
244 js->old_source = g_strdup(source);
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
245 js->old_uri = g_strdup(uri);
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
246 js->old_length = length;
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
247 js->old_track = g_strdup(track);
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 10116
diff changeset
248 }
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 10116
diff changeset
249
19899
483c4f495a6c Various warning fixes for the xmpp prpl.
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
250 #undef CHANGED
8185
3a1d79a4e55a [gaim-migrate @ 8906]
Nathan Walp <nwalp@pidgin.im>
parents: 8182
diff changeset
251
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9931
diff changeset
252 jabber_presence_fake_to_self(js, status);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
253 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
254
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9931
diff changeset
255 xmlnode *jabber_presence_create(JabberBuddyState state, const char *msg, int priority)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
256 {
17770
e67998927a3c Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents: 17422
diff changeset
257 return jabber_presence_create_js(NULL, state, msg, priority);
e67998927a3c Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents: 17422
diff changeset
258 }
e67998927a3c Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents: 17422
diff changeset
259
e67998927a3c Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents: 17422
diff changeset
260 xmlnode *jabber_presence_create_js(JabberStream *js, JabberBuddyState state, const char *msg, int priority)
e67998927a3c Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents: 17422
diff changeset
261 {
13385
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 13214
diff changeset
262 xmlnode *show, *status, *presence, *pri, *c;
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9931
diff changeset
263 const char *show_string = NULL;
27323
731aa4742263 Fix compile warning for non-VV.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27202
diff changeset
264 #ifdef USE_VV
27202
5244a5510e0e Add Gmail video support.
Michael Ruprecht <maiku@pidgin.im>
parents: 27155
diff changeset
265 gboolean audio_enabled, video_enabled;
27323
731aa4742263 Fix compile warning for non-VV.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27202
diff changeset
266 #endif
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
267
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
268 presence = xmlnode_new("presence");
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
269
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9931
diff changeset
270 if(state == JABBER_BUDDY_STATE_UNAVAILABLE)
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9931
diff changeset
271 xmlnode_set_attrib(presence, "type", "unavailable");
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9931
diff changeset
272 else if(state != JABBER_BUDDY_STATE_ONLINE &&
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9931
diff changeset
273 state != JABBER_BUDDY_STATE_UNKNOWN &&
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9931
diff changeset
274 state != JABBER_BUDDY_STATE_ERROR)
12683
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12603
diff changeset
275 show_string = jabber_buddy_state_get_show(state);
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9931
diff changeset
276
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9931
diff changeset
277 if(show_string) {
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9931
diff changeset
278 show = xmlnode_new_child(presence, "show");
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9931
diff changeset
279 xmlnode_insert_data(show, show_string, -1);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
280 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
281
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9931
diff changeset
282 if(msg) {
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
283 status = xmlnode_new_child(presence, "status");
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
284 xmlnode_insert_data(status, msg, -1);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
285 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
286
11568
ea479b2a8808 [gaim-migrate @ 13835]
Nathan Walp <nwalp@pidgin.im>
parents: 11361
diff changeset
287 if(priority) {
ea479b2a8808 [gaim-migrate @ 13835]
Nathan Walp <nwalp@pidgin.im>
parents: 11361
diff changeset
288 char *pstr = g_strdup_printf("%d", priority);
ea479b2a8808 [gaim-migrate @ 13835]
Nathan Walp <nwalp@pidgin.im>
parents: 11361
diff changeset
289 pri = xmlnode_new_child(presence, "priority");
ea479b2a8808 [gaim-migrate @ 13835]
Nathan Walp <nwalp@pidgin.im>
parents: 11361
diff changeset
290 xmlnode_insert_data(pri, pstr, -1);
ea479b2a8808 [gaim-migrate @ 13835]
Nathan Walp <nwalp@pidgin.im>
parents: 11361
diff changeset
291 g_free(pstr);
ea479b2a8808 [gaim-migrate @ 13835]
Nathan Walp <nwalp@pidgin.im>
parents: 11361
diff changeset
292 }
ea479b2a8808 [gaim-migrate @ 13835]
Nathan Walp <nwalp@pidgin.im>
parents: 11361
diff changeset
293
25229
d89db7b7fb94 Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 25228
diff changeset
294 /* if we are idle and not offline, include idle */
d89db7b7fb94 Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 25228
diff changeset
295 if (js->idle && state != JABBER_BUDDY_STATE_UNAVAILABLE) {
d89db7b7fb94 Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 25228
diff changeset
296 xmlnode *query = xmlnode_new_child(presence, "query");
d89db7b7fb94 Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 25228
diff changeset
297 gchar seconds[10];
d89db7b7fb94 Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 25228
diff changeset
298 g_snprintf(seconds, 10, "%d", (int) (time(NULL) - js->idle));
27155
53502d71efdd Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents: 27145
diff changeset
299
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28832
diff changeset
300 xmlnode_set_namespace(query, NS_LAST_ACTIVITY);
25229
d89db7b7fb94 Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 25228
diff changeset
301 xmlnode_set_attrib(query, "seconds", seconds);
d89db7b7fb94 Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 25228
diff changeset
302 }
26958
a955bd42f529 propagate from branch 'im.pidgin.pidgin' (head 36f75a1d52a6af5574bf847d60054a1392dcbc67)
Paul Aurich <darkrain42@pidgin.im>
parents: 26707 26948
diff changeset
303
13385
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 13214
diff changeset
304 /* JEP-0115 */
23595
728a8a576f11 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23591
diff changeset
305 /* calculate hash */
728a8a576f11 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23591
diff changeset
306 jabber_caps_calculate_own_hash(js);
728a8a576f11 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23591
diff changeset
307 /* create xml */
13385
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 13214
diff changeset
308 c = xmlnode_new_child(presence, "c");
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 13497
diff changeset
309 xmlnode_set_namespace(c, "http://jabber.org/protocol/caps");
13385
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 13214
diff changeset
310 xmlnode_set_attrib(c, "node", CAPS0115_NODE);
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23403
diff changeset
311 xmlnode_set_attrib(c, "hash", "sha-1");
24716
047f5075ca58 Entity Capabilities must be per-JabberStream
Paul Aurich <darkrain42@pidgin.im>
parents: 23954
diff changeset
312 xmlnode_set_attrib(c, "ver", jabber_caps_get_own_hash(js));
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25154
diff changeset
313
26668
ef06285f3b64 Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <darkrain42@pidgin.im>
parents: 26658
diff changeset
314 #ifdef USE_VV
ef06285f3b64 Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <darkrain42@pidgin.im>
parents: 26658
diff changeset
315 /*
ef06285f3b64 Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <darkrain42@pidgin.im>
parents: 26658
diff changeset
316 * MASSIVE HUGE DISGUSTING HACK
ef06285f3b64 Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <darkrain42@pidgin.im>
parents: 26658
diff changeset
317 * This is a huge hack. As far as I can tell, Google Talk's gmail client
ef06285f3b64 Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <darkrain42@pidgin.im>
parents: 26658
diff changeset
318 * doesn't bother to check the actual features we advertise; they
26674
133392eaf4b8 Make my comment parse correctly.
Paul Aurich <darkrain42@pidgin.im>
parents: 26668
diff changeset
319 * just assume that if we specify a 'voice-v1' ext (ignoring that
133392eaf4b8 Make my comment parse correctly.
Paul Aurich <darkrain42@pidgin.im>
parents: 26668
diff changeset
320 * these are to be assigned no semantic value), we support receiving voice
133392eaf4b8 Make my comment parse correctly.
Paul Aurich <darkrain42@pidgin.im>
parents: 26668
diff changeset
321 * calls.
27202
5244a5510e0e Add Gmail video support.
Michael Ruprecht <maiku@pidgin.im>
parents: 27155
diff changeset
322 *
5244a5510e0e Add Gmail video support.
Michael Ruprecht <maiku@pidgin.im>
parents: 27155
diff changeset
323 * Ditto for 'video-v1'.
26668
ef06285f3b64 Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <darkrain42@pidgin.im>
parents: 26658
diff changeset
324 */
27202
5244a5510e0e Add Gmail video support.
Michael Ruprecht <maiku@pidgin.im>
parents: 27155
diff changeset
325 audio_enabled = jabber_audio_enabled(js, NULL /* unused */);
5244a5510e0e Add Gmail video support.
Michael Ruprecht <maiku@pidgin.im>
parents: 27155
diff changeset
326 video_enabled = jabber_video_enabled(js, NULL /* unused */);
5244a5510e0e Add Gmail video support.
Michael Ruprecht <maiku@pidgin.im>
parents: 27155
diff changeset
327
5244a5510e0e Add Gmail video support.
Michael Ruprecht <maiku@pidgin.im>
parents: 27155
diff changeset
328 if (audio_enabled && video_enabled)
28028
774400bac46f Add the camera-v1 cap or else Gmail refuses to accept we're video enabled.
Michael Ruprecht <maiku@pidgin.im>
parents: 27964
diff changeset
329 xmlnode_set_attrib(c, "ext", "voice-v1 camera-v1 video-v1");
27202
5244a5510e0e Add Gmail video support.
Michael Ruprecht <maiku@pidgin.im>
parents: 27155
diff changeset
330 else if (audio_enabled)
26668
ef06285f3b64 Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <darkrain42@pidgin.im>
parents: 26658
diff changeset
331 xmlnode_set_attrib(c, "ext", "voice-v1");
27202
5244a5510e0e Add Gmail video support.
Michael Ruprecht <maiku@pidgin.im>
parents: 27155
diff changeset
332 else if (video_enabled)
28028
774400bac46f Add the camera-v1 cap or else Gmail refuses to accept we're video enabled.
Michael Ruprecht <maiku@pidgin.im>
parents: 27964
diff changeset
333 xmlnode_set_attrib(c, "ext", "camera-v1 video-v1");
26668
ef06285f3b64 Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <darkrain42@pidgin.im>
parents: 26658
diff changeset
334 #endif
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25154
diff changeset
335
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
336 return presence;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
337 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
338
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
339 struct _jabber_add_permit {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15810
diff changeset
340 PurpleConnection *gc;
12285
5a0f4619b0c5 [gaim-migrate @ 14589]
Etan Reisner <deryni@pidgin.im>
parents: 12265
diff changeset
341 JabberStream *js;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
342 char *who;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
343 };
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
344
19335
4613b53d5741 Warning fixes in the aftermath of resiak's authorize_cb and deny_cb type fixing.
Daniel Atallah <datallah@pidgin.im>
parents: 18991
diff changeset
345 static void authorize_add_cb(gpointer data)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
346 {
19335
4613b53d5741 Warning fixes in the aftermath of resiak's authorize_cb and deny_cb type fixing.
Daniel Atallah <datallah@pidgin.im>
parents: 18991
diff changeset
347 struct _jabber_add_permit *jap = data;
21687
a191b234bf75 Prevent crashing when authorizing or denying after the account is disconnected.
Daniel Atallah <datallah@pidgin.im>
parents: 21630
diff changeset
348 if(PURPLE_CONNECTION_IS_VALID(jap->gc))
a191b234bf75 Prevent crashing when authorizing or denying after the account is disconnected.
Daniel Atallah <datallah@pidgin.im>
parents: 21630
diff changeset
349 jabber_presence_subscription_set(jap->gc->proto_data,
a191b234bf75 Prevent crashing when authorizing or denying after the account is disconnected.
Daniel Atallah <datallah@pidgin.im>
parents: 21630
diff changeset
350 jap->who, "subscribed");
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
351 g_free(jap->who);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
352 g_free(jap);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
353 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
354
19335
4613b53d5741 Warning fixes in the aftermath of resiak's authorize_cb and deny_cb type fixing.
Daniel Atallah <datallah@pidgin.im>
parents: 18991
diff changeset
355 static void deny_add_cb(gpointer data)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
356 {
19335
4613b53d5741 Warning fixes in the aftermath of resiak's authorize_cb and deny_cb type fixing.
Daniel Atallah <datallah@pidgin.im>
parents: 18991
diff changeset
357 struct _jabber_add_permit *jap = data;
21687
a191b234bf75 Prevent crashing when authorizing or denying after the account is disconnected.
Daniel Atallah <datallah@pidgin.im>
parents: 21630
diff changeset
358 if(PURPLE_CONNECTION_IS_VALID(jap->gc))
a191b234bf75 Prevent crashing when authorizing or denying after the account is disconnected.
Daniel Atallah <datallah@pidgin.im>
parents: 21630
diff changeset
359 jabber_presence_subscription_set(jap->gc->proto_data,
a191b234bf75 Prevent crashing when authorizing or denying after the account is disconnected.
Daniel Atallah <datallah@pidgin.im>
parents: 21630
diff changeset
360 jap->who, "unsubscribed");
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
361 g_free(jap->who);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
362 g_free(jap);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
363 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
364
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
365 static void
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
366 jabber_vcard_parse_avatar(JabberStream *js, const char *from,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
367 JabberIqType type, const char *id,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
368 xmlnode *packet, gpointer blah)
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 10116
diff changeset
369 {
10941
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10755
diff changeset
370 JabberBuddy *jb = NULL;
27006
34ced9e04b08 When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents: 26998
diff changeset
371 xmlnode *vcard, *photo, *binval, *fn, *nick;
11127
5e539d9d26a4 [gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents: 11013
diff changeset
372 char *text;
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 10116
diff changeset
373
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 10116
diff changeset
374 if(!from)
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 10116
diff changeset
375 return;
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 10116
diff changeset
376
10941
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10755
diff changeset
377 jb = jabber_buddy_find(js, from, TRUE);
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10755
diff changeset
378
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10755
diff changeset
379 js->pending_avatar_requests = g_slist_remove(js->pending_avatar_requests, jb);
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10755
diff changeset
380
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 10116
diff changeset
381 if((vcard = xmlnode_get_child(packet, "vCard")) ||
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 10116
diff changeset
382 (vcard = xmlnode_get_child_with_namespace(packet, "query", "vcard-temp"))) {
27006
34ced9e04b08 When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents: 26998
diff changeset
383 /* The logic here regarding the nickname and full name is copied from
34ced9e04b08 When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents: 26998
diff changeset
384 * buddy.c:jabber_vcard_parse. */
34ced9e04b08 When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents: 26998
diff changeset
385 gchar *nickname = NULL;
34ced9e04b08 When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents: 26998
diff changeset
386 if ((fn = xmlnode_get_child(vcard, "FN")))
34ced9e04b08 When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents: 26998
diff changeset
387 nickname = xmlnode_get_data(fn);
34ced9e04b08 When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents: 26998
diff changeset
388
34ced9e04b08 When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents: 26998
diff changeset
389 if ((nick = xmlnode_get_child(vcard, "NICKNAME"))) {
34ced9e04b08 When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents: 26998
diff changeset
390 char *tmp = xmlnode_get_data(nick);
34ced9e04b08 When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents: 26998
diff changeset
391 char *bare_jid = jabber_get_bare_jid(from);
27145
f34175723f73 Fix a crash when <NICKNAME/> is present in a vcard, but has no data.
Paul Aurich <darkrain42@pidgin.im>
parents: 27103
diff changeset
392 if (tmp && strstr(bare_jid, tmp) == NULL) {
27006
34ced9e04b08 When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents: 26998
diff changeset
393 g_free(nickname);
34ced9e04b08 When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents: 26998
diff changeset
394 nickname = tmp;
27145
f34175723f73 Fix a crash when <NICKNAME/> is present in a vcard, but has no data.
Paul Aurich <darkrain42@pidgin.im>
parents: 27103
diff changeset
395 } else if (tmp)
27006
34ced9e04b08 When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents: 26998
diff changeset
396 g_free(tmp);
34ced9e04b08 When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents: 26998
diff changeset
397
34ced9e04b08 When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents: 26998
diff changeset
398 g_free(bare_jid);
34ced9e04b08 When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents: 26998
diff changeset
399 }
34ced9e04b08 When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents: 26998
diff changeset
400
34ced9e04b08 When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents: 26998
diff changeset
401 if (nickname) {
34ced9e04b08 When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents: 26998
diff changeset
402 serv_got_alias(js->gc, from, nickname);
34ced9e04b08 When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents: 26998
diff changeset
403 g_free(nickname);
34ced9e04b08 When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents: 26998
diff changeset
404 }
34ced9e04b08 When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents: 26998
diff changeset
405
28611
156e0b180d48 jabber: Don't try to pull a photo out of the <PHOTO/> cdata.
Paul Aurich <darkrain42@pidgin.im>
parents: 28341
diff changeset
406 if ((photo = xmlnode_get_child(vcard, "PHOTO")) &&
156e0b180d48 jabber: Don't try to pull a photo out of the <PHOTO/> cdata.
Paul Aurich <darkrain42@pidgin.im>
parents: 28341
diff changeset
407 (binval = xmlnode_get_child(photo, "BINVAL")) &&
156e0b180d48 jabber: Don't try to pull a photo out of the <PHOTO/> cdata.
Paul Aurich <darkrain42@pidgin.im>
parents: 28341
diff changeset
408 (text = xmlnode_get_data(binval))) {
26948
19be50c7fbff Use jabber_calculate_data_sha1sum in one more place.
Paul Aurich <darkrain42@pidgin.im>
parents: 26946
diff changeset
409 guchar *data;
19be50c7fbff Use jabber_calculate_data_sha1sum in one more place.
Paul Aurich <darkrain42@pidgin.im>
parents: 26946
diff changeset
410 gsize size;
16534
2ab9e23f99d9 Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents: 16018
diff changeset
411
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15810
diff changeset
412 data = purple_base64_decode(text, &size);
28611
156e0b180d48 jabber: Don't try to pull a photo out of the <PHOTO/> cdata.
Paul Aurich <darkrain42@pidgin.im>
parents: 28341
diff changeset
413 if (data) {
156e0b180d48 jabber: Don't try to pull a photo out of the <PHOTO/> cdata.
Paul Aurich <darkrain42@pidgin.im>
parents: 28341
diff changeset
414 gchar *hash = jabber_calculate_data_sha1sum(data, size);
156e0b180d48 jabber: Don't try to pull a photo out of the <PHOTO/> cdata.
Paul Aurich <darkrain42@pidgin.im>
parents: 28341
diff changeset
415 purple_buddy_icons_set_for_user(js->gc->account, from, data,
156e0b180d48 jabber: Don't try to pull a photo out of the <PHOTO/> cdata.
Paul Aurich <darkrain42@pidgin.im>
parents: 28341
diff changeset
416 size, hash);
156e0b180d48 jabber: Don't try to pull a photo out of the <PHOTO/> cdata.
Paul Aurich <darkrain42@pidgin.im>
parents: 28341
diff changeset
417 g_free(hash);
156e0b180d48 jabber: Don't try to pull a photo out of the <PHOTO/> cdata.
Paul Aurich <darkrain42@pidgin.im>
parents: 28341
diff changeset
418 }
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 10116
diff changeset
419
10941
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10755
diff changeset
420 g_free(text);
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 10116
diff changeset
421 }
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 10116
diff changeset
422 }
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 10116
diff changeset
423 }
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 10116
diff changeset
424
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17812
diff changeset
425 typedef struct _JabberPresenceCapabilities {
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17812
diff changeset
426 JabberStream *js;
22929
f1860f6e1344 Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents: 22622
diff changeset
427 JabberBuddy *jb;
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17812
diff changeset
428 char *from;
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17812
diff changeset
429 } JabberPresenceCapabilities;
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17812
diff changeset
430
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
431 static void
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
432 jabber_presence_set_capabilities(JabberCapsClientInfo *info, GList *exts,
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
433 JabberPresenceCapabilities *userdata)
24719
80121be525d4 Rewrite jabber_presence_set_capabilities a little
Paul Aurich <darkrain42@pidgin.im>
parents: 24717
diff changeset
434 {
22929
f1860f6e1344 Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents: 22622
diff changeset
435 JabberBuddyResource *jbr;
29059
8225f2507058 strchr() is safe when searching for an ASCII character in UTF8 strings.
Paul Aurich <darkrain42@pidgin.im>
parents: 29018
diff changeset
436 char *resource = strchr(userdata->from, '/');
21801
6d92632a6424 Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <datallah@pidgin.im>
parents: 21758
diff changeset
437
27066
6c1375ed1e59 Don't crash when resource is NULL. Thanks, Marcus!
Paul Aurich <darkrain42@pidgin.im>
parents: 27007
diff changeset
438 if (resource)
6c1375ed1e59 Don't crash when resource is NULL. Thanks, Marcus!
Paul Aurich <darkrain42@pidgin.im>
parents: 27007
diff changeset
439 resource += 1;
22929
f1860f6e1344 Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents: 22622
diff changeset
440
24719
80121be525d4 Rewrite jabber_presence_set_capabilities a little
Paul Aurich <darkrain42@pidgin.im>
parents: 24717
diff changeset
441 jbr = jabber_buddy_find_resource(userdata->jb, resource);
80121be525d4 Rewrite jabber_presence_set_capabilities a little
Paul Aurich <darkrain42@pidgin.im>
parents: 24717
diff changeset
442 if (!jbr) {
22929
f1860f6e1344 Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents: 22622
diff changeset
443 g_free(userdata->from);
f1860f6e1344 Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents: 22622
diff changeset
444 g_free(userdata);
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
445 if (exts) {
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
446 g_list_foreach(exts, (GFunc)g_free, NULL);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
447 g_list_free(exts);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
448 }
22929
f1860f6e1344 Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents: 22622
diff changeset
449 return;
f1860f6e1344 Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents: 22622
diff changeset
450 }
f1860f6e1344 Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents: 22622
diff changeset
451
24882
7e842d8123e8 Partial disapproval of 19969457944c4807924bcde3090063b23d35ba17
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
452 /* Any old jbr->caps.info is owned by the caps code */
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
453 if (jbr->caps.exts) {
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
454 g_list_foreach(jbr->caps.exts, (GFunc)g_free, NULL);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
455 g_list_free(jbr->caps.exts);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
456 }
21801
6d92632a6424 Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <datallah@pidgin.im>
parents: 21758
diff changeset
457
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
458 jbr->caps.info = info;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
459 jbr->caps.exts = exts;
21801
6d92632a6424 Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <datallah@pidgin.im>
parents: 21758
diff changeset
460
29548
e861ed14c1e1 Declare XMPP got media caps in the correct place.
Michael Ruprecht <maiku@pidgin.im>
parents: 29545
diff changeset
461 purple_prpl_got_media_caps(
e861ed14c1e1 Declare XMPP got media caps in the correct place.
Michael Ruprecht <maiku@pidgin.im>
parents: 29545
diff changeset
462 purple_connection_get_account(userdata->js->gc),
e861ed14c1e1 Declare XMPP got media caps in the correct place.
Michael Ruprecht <maiku@pidgin.im>
parents: 29545
diff changeset
463 userdata->from);
e861ed14c1e1 Declare XMPP got media caps in the correct place.
Michael Ruprecht <maiku@pidgin.im>
parents: 29545
diff changeset
464
27750
f25b6a565494 Use Entity Capabilities to pick up Chat States support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents: 27747
diff changeset
465 if (info == NULL)
f25b6a565494 Use Entity Capabilities to pick up Chat States support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents: 27747
diff changeset
466 goto out;
f25b6a565494 Use Entity Capabilities to pick up Chat States support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents: 27747
diff changeset
467
27073
09bf5e6921e4 Only try to fetch adhoc commands from buddies once. Pushed updates (which we support now) are far superior.
Paul Aurich <darkrain42@pidgin.im>
parents: 27068
diff changeset
468 if (!jbr->commands_fetched && jabber_resource_has_capability(jbr, "http://jabber.org/protocol/commands")) {
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28832
diff changeset
469 JabberIq *iq = jabber_iq_new_query(userdata->js, JABBER_IQ_GET, NS_DISCO_ITEMS);
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28832
diff changeset
470 xmlnode *query = xmlnode_get_child_with_namespace(iq->node, "query", NS_DISCO_ITEMS);
24802
eb481e98ac6a Sprinkle jabber_resource_has_capability in places
Paul Aurich <darkrain42@pidgin.im>
parents: 24741
diff changeset
471 xmlnode_set_attrib(iq->node, "to", userdata->from);
eb481e98ac6a Sprinkle jabber_resource_has_capability in places
Paul Aurich <darkrain42@pidgin.im>
parents: 24741
diff changeset
472 xmlnode_set_attrib(query, "node", "http://jabber.org/protocol/commands");
eb481e98ac6a Sprinkle jabber_resource_has_capability in places
Paul Aurich <darkrain42@pidgin.im>
parents: 24741
diff changeset
473 jabber_iq_set_callback(iq, jabber_adhoc_disco_result_cb, NULL);
eb481e98ac6a Sprinkle jabber_resource_has_capability in places
Paul Aurich <darkrain42@pidgin.im>
parents: 24741
diff changeset
474 jabber_iq_send(iq);
21801
6d92632a6424 Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <datallah@pidgin.im>
parents: 21758
diff changeset
475
27073
09bf5e6921e4 Only try to fetch adhoc commands from buddies once. Pushed updates (which we support now) are far superior.
Paul Aurich <darkrain42@pidgin.im>
parents: 27068
diff changeset
476 jbr->commands_fetched = TRUE;
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17812
diff changeset
477 }
21801
6d92632a6424 Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <datallah@pidgin.im>
parents: 21758
diff changeset
478
28341
491467d3da13 jabber: Fix typing notifications between 2.6.0 and <= 2.5.9.
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
479 #if 0
491467d3da13 jabber: Fix typing notifications between 2.6.0 and <= 2.5.9.
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
480 /*
491467d3da13 jabber: Fix typing notifications between 2.6.0 and <= 2.5.9.
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
481 * Versions of libpurple before 2.6.0 didn't advertise this capability, so
491467d3da13 jabber: Fix typing notifications between 2.6.0 and <= 2.5.9.
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
482 * we can't yet use Entity Capabilities to determine whether or not the
28714
d14fe5e97aa7 jabber: Fix a comment.
Paul Aurich <darkrain42@pidgin.im>
parents: 28611
diff changeset
483 * other client supports Chat States.
28341
491467d3da13 jabber: Fix typing notifications between 2.6.0 and <= 2.5.9.
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
484 */
27750
f25b6a565494 Use Entity Capabilities to pick up Chat States support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents: 27747
diff changeset
485 if (jabber_resource_has_capability(jbr, "http://jabber.org/protocol/chatstates"))
f25b6a565494 Use Entity Capabilities to pick up Chat States support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents: 27747
diff changeset
486 jbr->chat_states = JABBER_CHAT_STATES_SUPPORTED;
f25b6a565494 Use Entity Capabilities to pick up Chat States support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents: 27747
diff changeset
487 else
f25b6a565494 Use Entity Capabilities to pick up Chat States support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents: 27747
diff changeset
488 jbr->chat_states = JABBER_CHAT_STATES_UNSUPPORTED;
28341
491467d3da13 jabber: Fix typing notifications between 2.6.0 and <= 2.5.9.
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
489 #endif
27750
f25b6a565494 Use Entity Capabilities to pick up Chat States support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents: 27747
diff changeset
490
f25b6a565494 Use Entity Capabilities to pick up Chat States support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents: 27747
diff changeset
491 out:
20210
d3336754b1a9 applied changes from d50ecf4dc52f25cbd219d6c19846436dec5a8853
Luke Schierer <lschiere@pidgin.im>
parents: 20169
diff changeset
492 g_free(userdata->from);
d3336754b1a9 applied changes from d50ecf4dc52f25cbd219d6c19846436dec5a8853
Luke Schierer <lschiere@pidgin.im>
parents: 20169
diff changeset
493 g_free(userdata);
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17812
diff changeset
494 }
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17812
diff changeset
495
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
496 void jabber_presence_parse(JabberStream *js, xmlnode *packet)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
497 {
27103
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 27073
diff changeset
498 const char *from;
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 27073
diff changeset
499 const char *type;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
500 char *status = NULL;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
501 int priority = 0;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
502 JabberID *jid;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
503 JabberChat *chat;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
504 JabberBuddy *jb;
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9931
diff changeset
505 JabberBuddyResource *jbr = NULL, *found_jbr = NULL;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15810
diff changeset
506 PurpleConvChatBuddyFlags flags = PURPLE_CBFLAGS_NONE;
9846
61f7349c153a [gaim-migrate @ 10724]
Nathan Fredrickson <nathan@silverorange.com>
parents: 9745
diff changeset
507 gboolean delayed = FALSE;
25229
d89db7b7fb94 Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 25228
diff changeset
508 const gchar *stamp = NULL; /* from <delayed/> element */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15810
diff changeset
509 PurpleBuddy *b = NULL;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
510 char *buddy_name;
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9931
diff changeset
511 JabberBuddyState state = JABBER_BUDDY_STATE_UNKNOWN;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
512 xmlnode *y;
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 10116
diff changeset
513 char *avatar_hash = NULL;
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17812
diff changeset
514 xmlnode *caps = NULL;
25229
d89db7b7fb94 Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 25228
diff changeset
515 int idle = 0;
26998
5d912b08679d A little bit better (free memory and support receiving the nick in subscriptions) and Changelog.
Paul Aurich <darkrain42@pidgin.im>
parents: 26997
diff changeset
516 gchar *nickname = NULL;
27103
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 27073
diff changeset
517 gboolean signal_return;
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 27073
diff changeset
518
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 27073
diff changeset
519 from = xmlnode_get_attrib(packet, "from");
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 27073
diff changeset
520 type = xmlnode_get_attrib(packet, "type");
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
521
27619
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
522 jb = jabber_buddy_find(js, from, TRUE);
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
523 g_return_if_fail(jb != NULL);
8043
86a087e9624c [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
524
28832
4e4b609b85e4 jabber: Use purple_connection_get_prpl() instead of jabber_plugin.
Paul Aurich <darkrain42@pidgin.im>
parents: 28714
diff changeset
525 signal_return = GPOINTER_TO_INT(purple_signal_emit_return_1(purple_connection_get_prpl(js->gc),
27103
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 27073
diff changeset
526 "jabber-receiving-presence", js->gc, type, from, packet));
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 27073
diff changeset
527 if (signal_return)
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 27073
diff changeset
528 return;
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 27073
diff changeset
529
27619
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
530 jid = jabber_id_new(from);
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
531 if (jid == NULL) {
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
532 purple_debug_error("jabber", "Ignoring presence with malformed 'from' "
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
533 "JID: %s\n", from);
7280
f00e23f50698 [gaim-migrate @ 7859]
Nathan Walp <nwalp@pidgin.im>
parents: 7273
diff changeset
534 return;
27619
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
535 }
7280
f00e23f50698 [gaim-migrate @ 7859]
Nathan Walp <nwalp@pidgin.im>
parents: 7273
diff changeset
536
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
537 if(jb->error_msg) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
538 g_free(jb->error_msg);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
539 jb->error_msg = NULL;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
540 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
541
27619
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
542 if (type == NULL) {
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
543 xmlnode *show;
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
544 char *show_data = NULL;
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
545
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
546 state = JABBER_BUDDY_STATE_ONLINE;
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
547
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
548 show = xmlnode_get_child(packet, "show");
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
549 if (show) {
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
550 show_data = xmlnode_get_data(show);
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
551 if (show_data) {
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
552 state = jabber_buddy_show_get_state(show_data);
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
553 g_free(show_data);
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
554 } else
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
555 purple_debug_warning("jabber", "<show/> present on presence, "
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
556 "but no contents!\n");
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
557 }
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
558 } else if (g_str_equal(type, "error")) {
21150
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20210
diff changeset
559 char *msg = jabber_parse_error(js, packet, NULL);
7644
9c1af0d50941 [gaim-migrate @ 8287]
Nathan Walp <nwalp@pidgin.im>
parents: 7630
diff changeset
560
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9931
diff changeset
561 state = JABBER_BUDDY_STATE_ERROR;
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8396
diff changeset
562 jb->error_msg = msg ? msg : g_strdup(_("Unknown Error in presence"));
27619
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
563 } else if (g_str_equal(type, "subscribe")) {
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
564 struct _jabber_add_permit *jap = g_new0(struct _jabber_add_permit, 1);
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 15119
diff changeset
565 gboolean onlist = FALSE;
27619
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
566 PurpleAccount *account;
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
567 PurpleBuddy *buddy;
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 15119
diff changeset
568 JabberBuddy *jb = NULL;
26998
5d912b08679d A little bit better (free memory and support receiving the nick in subscriptions) and Changelog.
Paul Aurich <darkrain42@pidgin.im>
parents: 26997
diff changeset
569 xmlnode *nick;
5d912b08679d A little bit better (free memory and support receiving the nick in subscriptions) and Changelog.
Paul Aurich <darkrain42@pidgin.im>
parents: 26997
diff changeset
570
27619
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
571 account = purple_connection_get_account(js->gc);
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
572 buddy = purple_find_buddy(account, from);
26998
5d912b08679d A little bit better (free memory and support receiving the nick in subscriptions) and Changelog.
Paul Aurich <darkrain42@pidgin.im>
parents: 26997
diff changeset
573 nick = xmlnode_get_child_with_namespace(packet, "nick", "http://jabber.org/protocol/nick");
5d912b08679d A little bit better (free memory and support receiving the nick in subscriptions) and Changelog.
Paul Aurich <darkrain42@pidgin.im>
parents: 26997
diff changeset
574 if (nick)
5d912b08679d A little bit better (free memory and support receiving the nick in subscriptions) and Changelog.
Paul Aurich <darkrain42@pidgin.im>
parents: 26997
diff changeset
575 nickname = xmlnode_get_data(nick);
10949
b2949f5fc512 [gaim-migrate @ 12749]
Evan Schoenberg <evands@pidgin.im>
parents: 10941
diff changeset
576
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 15119
diff changeset
577 if (buddy) {
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 15119
diff changeset
578 jb = jabber_buddy_find(js, from, TRUE);
24740
3842816fc042 A fix from Paul Aurich for a long-standing XMPP issue with duplicate buddies. Fixes #479.
Daniel Atallah <datallah@pidgin.im>
parents: 23575
diff changeset
579 if ((jb->subscription & (JABBER_SUB_TO | JABBER_SUB_PENDING)))
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 15119
diff changeset
580 onlist = TRUE;
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 15119
diff changeset
581 }
16018
0cbbb5b642ce fix prompting to add a buddy after authorization if they're already on our list
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
582
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
583 jap->gc = js->gc;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
584 jap->who = g_strdup(from);
12285
5a0f4619b0c5 [gaim-migrate @ 14589]
Etan Reisner <deryni@pidgin.im>
parents: 12265
diff changeset
585 jap->js = js;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
586
27619
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
587 purple_account_request_authorization(account, from, NULL, nickname,
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
588 NULL, onlist, authorize_add_cb, deny_add_cb, jap);
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
589
26998
5d912b08679d A little bit better (free memory and support receiving the nick in subscriptions) and Changelog.
Paul Aurich <darkrain42@pidgin.im>
parents: 26997
diff changeset
590 g_free(nickname);
8043
86a087e9624c [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
591 jabber_id_free(jid);
7145
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7124
diff changeset
592 return;
27619
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
593 } else if (g_str_equal(type, "subscribed")) {
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
594 /* we've been allowed to see their presence, but we don't care */
8043
86a087e9624c [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
595 jabber_id_free(jid);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
596 return;
27619
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
597 } else if (g_str_equal(type, "unsubscribe")) {
12285
5a0f4619b0c5 [gaim-migrate @ 14589]
Etan Reisner <deryni@pidgin.im>
parents: 12265
diff changeset
598 /* XXX I'm not sure this is the right way to handle this, it
5a0f4619b0c5 [gaim-migrate @ 14589]
Etan Reisner <deryni@pidgin.im>
parents: 12265
diff changeset
599 * might be better to add "unsubscribe" to the presence status
5a0f4619b0c5 [gaim-migrate @ 14589]
Etan Reisner <deryni@pidgin.im>
parents: 12265
diff changeset
600 * if lower down, but I'm not sure. */
5a0f4619b0c5 [gaim-migrate @ 14589]
Etan Reisner <deryni@pidgin.im>
parents: 12265
diff changeset
601 /* they are unsubscribing from our presence, we don't care */
5a0f4619b0c5 [gaim-migrate @ 14589]
Etan Reisner <deryni@pidgin.im>
parents: 12265
diff changeset
602 /* Well, maybe just a little, we might want/need to start
5a0f4619b0c5 [gaim-migrate @ 14589]
Etan Reisner <deryni@pidgin.im>
parents: 12265
diff changeset
603 * acknowledging this (and the others) at some point. */
5a0f4619b0c5 [gaim-migrate @ 14589]
Etan Reisner <deryni@pidgin.im>
parents: 12265
diff changeset
604 jabber_id_free(jid);
5a0f4619b0c5 [gaim-migrate @ 14589]
Etan Reisner <deryni@pidgin.im>
parents: 12265
diff changeset
605 return;
27622
b0ea939829a3 I missed a few presence types.
Paul Aurich <darkrain42@pidgin.im>
parents: 27621
diff changeset
606 } else if (g_str_equal(type, "probe")) {
b0ea939829a3 I missed a few presence types.
Paul Aurich <darkrain42@pidgin.im>
parents: 27621
diff changeset
607 purple_debug_warning("jabber", "Ignoring presence probe\n");
b0ea939829a3 I missed a few presence types.
Paul Aurich <darkrain42@pidgin.im>
parents: 27621
diff changeset
608 jabber_id_free(jid);
b0ea939829a3 I missed a few presence types.
Paul Aurich <darkrain42@pidgin.im>
parents: 27621
diff changeset
609 return;
b0ea939829a3 I missed a few presence types.
Paul Aurich <darkrain42@pidgin.im>
parents: 27621
diff changeset
610 } else if (g_str_equal(type, "unavailable")) {
b0ea939829a3 I missed a few presence types.
Paul Aurich <darkrain42@pidgin.im>
parents: 27621
diff changeset
611 state = JABBER_BUDDY_STATE_UNAVAILABLE;
b0ea939829a3 I missed a few presence types.
Paul Aurich <darkrain42@pidgin.im>
parents: 27621
diff changeset
612 } else if (g_str_equal(type, "unsubscribed")) {
b0ea939829a3 I missed a few presence types.
Paul Aurich <darkrain42@pidgin.im>
parents: 27621
diff changeset
613 state = JABBER_BUDDY_STATE_UNKNOWN;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
614 } else {
27619
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
615 purple_debug_warning("jabber", "Ignoring presence with invalid type "
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
616 "'%s'\n", type);
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
617 jabber_id_free(jid);
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
618 return;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
619 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
620
7310
1346a99cba40 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7280
diff changeset
621
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
622 for(y = packet->child; y; y = y->next) {
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17812
diff changeset
623 const char *xmlns;
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
624 if(y->type != XMLNODE_TYPE_TAG)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
625 continue;
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17812
diff changeset
626 xmlns = xmlnode_get_namespace(y);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
627
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
628 if(!strcmp(y->name, "status")) {
7615
6bf94a91db1c [gaim-migrate @ 8239]
Nathan Walp <nwalp@pidgin.im>
parents: 7425
diff changeset
629 g_free(status);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
630 status = xmlnode_get_data(y);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
631 } else if(!strcmp(y->name, "priority")) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
632 char *p = xmlnode_get_data(y);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
633 if(p) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
634 priority = atoi(p);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
635 g_free(p);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
636 }
25154
492b9d6b48a5 Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25110
diff changeset
637 } else if(xmlns == NULL) {
492b9d6b48a5 Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25110
diff changeset
638 /* The rest of the cases used to check xmlns individually. */
492b9d6b48a5 Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25110
diff changeset
639 continue;
28996
8296bccbfd50 jabber: Delayed Delivery namespaces
Paul Aurich <darkrain42@pidgin.im>
parents: 28984
diff changeset
640 } else if(!strcmp(y->name, "delay") && !strcmp(xmlns, NS_DELAYED_DELIVERY)) {
27434
7d8b32345d10 disapproval of revision '0c1545afc98299c6d7004554eb7443091d42e8ca'
Paul Aurich <darkrain42@pidgin.im>
parents: 27431
diff changeset
641 /* XXX: compare the time. jabber:x:delay can happen on presence packets that aren't really and truly delayed */
17812
be440f0a0acf Forgot to implement XEP-0203 for presence packets, too.
Andreas Monitzer <am@adiumx.com>
parents: 17801
diff changeset
642 delayed = TRUE;
25229
d89db7b7fb94 Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 25228
diff changeset
643 stamp = xmlnode_get_attrib(y, "stamp");
25154
492b9d6b48a5 Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25110
diff changeset
644 } else if(!strcmp(y->name, "c") && !strcmp(xmlns, "http://jabber.org/protocol/caps")) {
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17812
diff changeset
645 caps = y; /* store for later, when creating buddy resource */
26997
e30b31076fcb Handle User Nick notifications via <presence/> stanzas (receive-only). Refs #864.
Paul Aurich <darkrain42@pidgin.im>
parents: 26976
diff changeset
646 } else if (g_str_equal(y->name, "nick") && g_str_equal(xmlns, "http://jabber.org/protocol/nick")) {
26998
5d912b08679d A little bit better (free memory and support receiving the nick in subscriptions) and Changelog.
Paul Aurich <darkrain42@pidgin.im>
parents: 26997
diff changeset
647 nickname = xmlnode_get_data(y);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
648 } else if(!strcmp(y->name, "x")) {
28996
8296bccbfd50 jabber: Delayed Delivery namespaces
Paul Aurich <darkrain42@pidgin.im>
parents: 28984
diff changeset
649 if(!strcmp(xmlns, NS_DELAYED_DELIVERY_LEGACY)) {
27434
7d8b32345d10 disapproval of revision '0c1545afc98299c6d7004554eb7443091d42e8ca'
Paul Aurich <darkrain42@pidgin.im>
parents: 27431
diff changeset
650 /* XXX: compare the time. jabber:x:delay can happen on presence packets that aren't really and truly delayed */
7d8b32345d10 disapproval of revision '0c1545afc98299c6d7004554eb7443091d42e8ca'
Paul Aurich <darkrain42@pidgin.im>
parents: 27431
diff changeset
651 delayed = TRUE;
7d8b32345d10 disapproval of revision '0c1545afc98299c6d7004554eb7443091d42e8ca'
Paul Aurich <darkrain42@pidgin.im>
parents: 27431
diff changeset
652 stamp = xmlnode_get_attrib(y, "stamp");
7d8b32345d10 disapproval of revision '0c1545afc98299c6d7004554eb7443091d42e8ca'
Paul Aurich <darkrain42@pidgin.im>
parents: 27431
diff changeset
653 } else if(!strcmp(xmlns, "http://jabber.org/protocol/muc#user")) {
25154
492b9d6b48a5 Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25110
diff changeset
654 } else if(!strcmp(xmlns, "vcard-temp:x:update")) {
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 10116
diff changeset
655 xmlnode *photo = xmlnode_get_child(y, "photo");
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 10116
diff changeset
656 if(photo) {
17702
15af85f94634 Don't check for null before calling free. I can't help but get rid
Mark Doliner <markdoliner@pidgin.im>
parents: 17683
diff changeset
657 g_free(avatar_hash);
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 10116
diff changeset
658 avatar_hash = xmlnode_get_data(photo);
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 10116
diff changeset
659 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
660 }
27155
53502d71efdd Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents: 27145
diff changeset
661 } else if (!strcmp(y->name, "query") &&
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28832
diff changeset
662 !strcmp(xmlnode_get_namespace(y), NS_LAST_ACTIVITY)) {
25229
d89db7b7fb94 Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 25228
diff changeset
663 /* resource has specified idle */
d89db7b7fb94 Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 25228
diff changeset
664 const gchar *seconds = xmlnode_get_attrib(y, "seconds");
d89db7b7fb94 Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 25228
diff changeset
665 if (seconds) {
d89db7b7fb94 Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 25228
diff changeset
666 /* we may need to take "delayed" into account here */
d89db7b7fb94 Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 25228
diff changeset
667 idle = atoi(seconds);
d89db7b7fb94 Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 25228
diff changeset
668 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
669 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
670 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
671
25229
d89db7b7fb94 Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 25228
diff changeset
672 if (idle && delayed && stamp) {
d89db7b7fb94 Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 25228
diff changeset
673 /* if we have a delayed presence, we need to add the delay to the idle
d89db7b7fb94 Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 25228
diff changeset
674 value */
d89db7b7fb94 Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 25228
diff changeset
675 time_t offset = time(NULL) - purple_str_to_time(stamp, TRUE, NULL, NULL,
d89db7b7fb94 Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 25228
diff changeset
676 NULL);
d89db7b7fb94 Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 25228
diff changeset
677 purple_debug_info("jabber", "got delay %s yielding %ld s offset\n",
d89db7b7fb94 Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 25228
diff changeset
678 stamp, offset);
27155
53502d71efdd Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents: 27145
diff changeset
679 idle += offset;
25229
d89db7b7fb94 Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 25228
diff changeset
680 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
681
7322
de15a9314c04 [gaim-migrate @ 7908]
Nathan Walp <nwalp@pidgin.im>
parents: 7321
diff changeset
682 if(jid->node && (chat = jabber_chat_find(js, jid->node, jid->domain))) {
8462
7afffaf5997b [gaim-migrate @ 9192]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
683 static int i = 1;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
684
17049
fe85f1b2d70b chat error fix from sadrul
Nathan Walp <nwalp@pidgin.im>
parents: 16545
diff changeset
685 if(state == JABBER_BUDDY_STATE_ERROR) {
21150
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20210
diff changeset
686 char *title, *msg = jabber_parse_error(js, packet, NULL);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
687
23403
a8704d47889f Fix the chat-room rejoining bug where the list appears empty.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23270
diff changeset
688 if (!chat->conv) {
a8704d47889f Fix the chat-room rejoining bug where the list appears empty.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23270
diff changeset
689 title = g_strdup_printf(_("Error joining chat %s"), from);
a8704d47889f Fix the chat-room rejoining bug where the list appears empty.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23270
diff changeset
690 purple_serv_got_join_chat_failed(js->gc, chat->components);
a8704d47889f Fix the chat-room rejoining bug where the list appears empty.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23270
diff changeset
691 } else {
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8396
diff changeset
692 title = g_strdup_printf(_("Error in chat %s"), from);
18991
aa6a1feb874a applied changes from 5542a465de12fedee4ebe7c124a754f9992d0d62
Mark Doliner <markdoliner@pidgin.im>
parents: 18989
diff changeset
693 if (g_hash_table_size(chat->members) == 0)
aa6a1feb874a applied changes from 5542a465de12fedee4ebe7c124a754f9992d0d62
Mark Doliner <markdoliner@pidgin.im>
parents: 18989
diff changeset
694 serv_got_chat_left(js->gc, chat->id);
7321
432276dbb354 [gaim-migrate @ 7907]
Nathan Walp <nwalp@pidgin.im>
parents: 7320
diff changeset
695 }
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15810
diff changeset
696 purple_notify_error(js->gc, title, title, msg);
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8396
diff changeset
697 g_free(title);
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8396
diff changeset
698 g_free(msg);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
699
18991
aa6a1feb874a applied changes from 5542a465de12fedee4ebe7c124a754f9992d0d62
Mark Doliner <markdoliner@pidgin.im>
parents: 18989
diff changeset
700 if (g_hash_table_size(chat->members) == 0)
aa6a1feb874a applied changes from 5542a465de12fedee4ebe7c124a754f9992d0d62
Mark Doliner <markdoliner@pidgin.im>
parents: 18989
diff changeset
701 /* Only destroy the chat if the error happened while joining */
aa6a1feb874a applied changes from 5542a465de12fedee4ebe7c124a754f9992d0d62
Mark Doliner <markdoliner@pidgin.im>
parents: 18989
diff changeset
702 jabber_chat_destroy(chat);
7310
1346a99cba40 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7280
diff changeset
703 jabber_id_free(jid);
7615
6bf94a91db1c [gaim-migrate @ 8239]
Nathan Walp <nwalp@pidgin.im>
parents: 7425
diff changeset
704 g_free(status);
17702
15af85f94634 Don't check for null before calling free. I can't help but get rid
Mark Doliner <markdoliner@pidgin.im>
parents: 17683
diff changeset
705 g_free(avatar_hash);
26998
5d912b08679d A little bit better (free memory and support receiving the nick in subscriptions) and Changelog.
Paul Aurich <darkrain42@pidgin.im>
parents: 26997
diff changeset
706 g_free(nickname);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
707 return;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
708 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
709
27620
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
710 if (type == NULL) {
27621
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
711 xmlnode *x;
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
712 const char *real_jid = NULL;
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
713 const char *affiliation = NULL;
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
714 const char *role = NULL;
28138
8ca385ecc991 jabber: Read all MUC status codes in a presence. Fixes #6651.
Paul Aurich <darkrain42@pidgin.im>
parents: 28028
diff changeset
715 gboolean is_our_resource = FALSE; /* Is the presence about us? */
27621
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
716
27620
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
717 /*
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
718 * XEP-0045 mandates the presence to include a resource (which is
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
719 * treated as the chat nick). Some non-compliant servers allow
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
720 * joining without a nick.
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
721 */
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
722 if (!jid->resource) {
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
723 jabber_id_free(jid);
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
724 g_free(avatar_hash);
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
725 g_free(nickname);
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
726 g_free(status);
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
727 return;
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
728 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
729
27621
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
730 x = xmlnode_get_child_with_namespace(packet, "x",
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
731 "http://jabber.org/protocol/muc#user");
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
732 if (x) {
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
733 xmlnode *status_node;
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
734 xmlnode *item_node;
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
735
28138
8ca385ecc991 jabber: Read all MUC status codes in a presence. Fixes #6651.
Paul Aurich <darkrain42@pidgin.im>
parents: 28028
diff changeset
736 for (status_node = xmlnode_get_child(x, "status"); status_node;
8ca385ecc991 jabber: Read all MUC status codes in a presence. Fixes #6651.
Paul Aurich <darkrain42@pidgin.im>
parents: 28028
diff changeset
737 status_node = xmlnode_get_next_twin(status_node)) {
27621
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
738 const char *code = xmlnode_get_attrib(status_node, "code");
28138
8ca385ecc991 jabber: Read all MUC status codes in a presence. Fixes #6651.
Paul Aurich <darkrain42@pidgin.im>
parents: 28028
diff changeset
739 if (!code)
8ca385ecc991 jabber: Read all MUC status codes in a presence. Fixes #6651.
Paul Aurich <darkrain42@pidgin.im>
parents: 28028
diff changeset
740 continue;
8ca385ecc991 jabber: Read all MUC status codes in a presence. Fixes #6651.
Paul Aurich <darkrain42@pidgin.im>
parents: 28028
diff changeset
741
8ca385ecc991 jabber: Read all MUC status codes in a presence. Fixes #6651.
Paul Aurich <darkrain42@pidgin.im>
parents: 28028
diff changeset
742 if (g_str_equal(code, "110")) {
8ca385ecc991 jabber: Read all MUC status codes in a presence. Fixes #6651.
Paul Aurich <darkrain42@pidgin.im>
parents: 28028
diff changeset
743 is_our_resource = TRUE;
8ca385ecc991 jabber: Read all MUC status codes in a presence. Fixes #6651.
Paul Aurich <darkrain42@pidgin.im>
parents: 28028
diff changeset
744 } else if (g_str_equal(code, "201")) {
27621
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
745 if ((chat = jabber_chat_find(js, jid->node, jid->domain))) {
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
746 chat->config_dialog_type = PURPLE_REQUEST_ACTION;
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
747 chat->config_dialog_handle =
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
748 purple_request_action(js->gc,
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
749 _("Create New Room"),
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
750 _("Create New Room"),
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
751 _("You are creating a new room. Would"
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
752 " you like to configure it, or"
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
753 " accept the default settings?"),
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
754 /* Default Action */ 1,
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
755 purple_connection_get_account(js->gc), NULL, chat->conv,
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
756 chat, 2,
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
757 _("_Configure Room"), G_CALLBACK(jabber_chat_request_room_configure),
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
758 _("_Accept Defaults"), G_CALLBACK(jabber_chat_create_instant_room));
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
759 }
28138
8ca385ecc991 jabber: Read all MUC status codes in a presence. Fixes #6651.
Paul Aurich <darkrain42@pidgin.im>
parents: 28028
diff changeset
760 } else if (g_str_equal(code, "210")) {
27621
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
761 /* server rewrote room-nick */
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
762 if((chat = jabber_chat_find(js, jid->node, jid->domain))) {
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
763 g_free(chat->handle);
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
764 chat->handle = g_strdup(jid->resource);
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
765 }
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
766 }
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
767 }
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
768
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
769 item_node = xmlnode_get_child(x, "item");
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
770 if (item_node) {
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
771 real_jid = xmlnode_get_attrib(item_node, "jid");
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
772 affiliation = xmlnode_get_attrib(item_node, "affiliation");
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
773 role = xmlnode_get_attrib(item_node, "role");
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
774
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
775 if (purple_strequal(affiliation, "owner"))
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
776 flags |= PURPLE_CBFLAGS_FOUNDER;
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
777 if (role) {
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
778 if (g_str_equal(role, "moderator"))
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
779 flags |= PURPLE_CBFLAGS_OP;
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
780 else if (g_str_equal(role, "participant"))
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
781 flags |= PURPLE_CBFLAGS_VOICE;
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
782 }
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
783 }
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
784 }
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
785
27620
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
786 if(!chat->conv) {
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
787 char *room_jid = g_strdup_printf("%s@%s", jid->node, jid->domain);
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
788 chat->id = i++;
27621
5676c9a7bbf5 Rearrange all the MUC code to be together.
Paul Aurich <darkrain42@pidgin.im>
parents: 27620
diff changeset
789 chat->muc = (x != NULL);
27620
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
790 chat->conv = serv_got_joined_chat(js->gc, chat->id, room_jid);
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
791 purple_conv_chat_set_nick(PURPLE_CONV_CHAT(chat->conv), chat->handle);
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
792
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
793 jabber_chat_disco_traffic(chat);
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
794 g_free(room_jid);
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
795 }
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
796
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
797 jabber_buddy_track_resource(jb, jid->resource, priority, state,
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
798 status);
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
799
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
800 jabber_chat_track_handle(chat, jid->resource, real_jid, affiliation, role);
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
801
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
802 if(!jabber_chat_find_buddy(chat->conv, jid->resource))
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
803 purple_conv_chat_add_user(PURPLE_CONV_CHAT(chat->conv), jid->resource,
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
804 real_jid, flags, !delayed);
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
805 else
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
806 purple_conv_chat_user_set_flags(PURPLE_CONV_CHAT(chat->conv), jid->resource,
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
807 flags);
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
808 } else if (g_str_equal(type, "unavailable")) {
27698
e19d3ab2ce67 Notice when the MUC item JID on unavailable presence references another resource. Refs #8319.
Paul Aurich <darkrain42@pidgin.im>
parents: 27622
diff changeset
809 xmlnode *x;
7972
f8538961a159 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7965
diff changeset
810 gboolean nick_change = FALSE;
27618
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
811 gboolean kick = FALSE;
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
812 gboolean is_our_resource = FALSE; /* Is the presence about us? */
7973
f1d1001702be [gaim-migrate @ 8650]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
813
25737
7f6a23aa9e8e *** Plucked rev 3993504a (darkrain42@pidgin.im):
Paul Aurich <darkrain42@pidgin.im>
parents: 25154
diff changeset
814 /* If the chat nick is invalid, we haven't yet joined, or we've
7f6a23aa9e8e *** Plucked rev 3993504a (darkrain42@pidgin.im):
Paul Aurich <darkrain42@pidgin.im>
parents: 25154
diff changeset
815 * already left (it was probably us leaving after we closed the
7f6a23aa9e8e *** Plucked rev 3993504a (darkrain42@pidgin.im):
Paul Aurich <darkrain42@pidgin.im>
parents: 25154
diff changeset
816 * chat), we don't care.
7f6a23aa9e8e *** Plucked rev 3993504a (darkrain42@pidgin.im):
Paul Aurich <darkrain42@pidgin.im>
parents: 25154
diff changeset
817 */
7f6a23aa9e8e *** Plucked rev 3993504a (darkrain42@pidgin.im):
Paul Aurich <darkrain42@pidgin.im>
parents: 25154
diff changeset
818 if (!jid->resource || !chat->conv || chat->left) {
23403
a8704d47889f Fix the chat-room rejoining bug where the list appears empty.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23270
diff changeset
819 if (chat->left &&
a8704d47889f Fix the chat-room rejoining bug where the list appears empty.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23270
diff changeset
820 jid->resource && chat->handle && !strcmp(jid->resource, chat->handle))
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 8577
diff changeset
821 jabber_chat_destroy(chat);
8182
a024bf275ba2 [gaim-migrate @ 8901]
Nathan Walp <nwalp@pidgin.im>
parents: 8158
diff changeset
822 jabber_id_free(jid);
a024bf275ba2 [gaim-migrate @ 8901]
Nathan Walp <nwalp@pidgin.im>
parents: 8158
diff changeset
823 g_free(status);
17702
15af85f94634 Don't check for null before calling free. I can't help but get rid
Mark Doliner <markdoliner@pidgin.im>
parents: 17683
diff changeset
824 g_free(avatar_hash);
26998
5d912b08679d A little bit better (free memory and support receiving the nick in subscriptions) and Changelog.
Paul Aurich <darkrain42@pidgin.im>
parents: 26997
diff changeset
825 g_free(nickname);
8182
a024bf275ba2 [gaim-migrate @ 8901]
Nathan Walp <nwalp@pidgin.im>
parents: 8158
diff changeset
826 return;
a024bf275ba2 [gaim-migrate @ 8901]
Nathan Walp <nwalp@pidgin.im>
parents: 8158
diff changeset
827 }
a024bf275ba2 [gaim-migrate @ 8901]
Nathan Walp <nwalp@pidgin.im>
parents: 8158
diff changeset
828
27618
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
829 is_our_resource = (0 == g_utf8_collate(jid->resource, chat->handle));
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
830
7973
f1d1001702be [gaim-migrate @ 8650]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
831 jabber_buddy_remove_resource(jb, jid->resource);
27698
e19d3ab2ce67 Notice when the MUC item JID on unavailable presence references another resource. Refs #8319.
Paul Aurich <darkrain42@pidgin.im>
parents: 27622
diff changeset
832
e19d3ab2ce67 Notice when the MUC item JID on unavailable presence references another resource. Refs #8319.
Paul Aurich <darkrain42@pidgin.im>
parents: 27622
diff changeset
833 x = xmlnode_get_child_with_namespace(packet, "x",
e19d3ab2ce67 Notice when the MUC item JID on unavailable presence references another resource. Refs #8319.
Paul Aurich <darkrain42@pidgin.im>
parents: 27622
diff changeset
834 "http://jabber.org/protocol/muc#user");
e19d3ab2ce67 Notice when the MUC item JID on unavailable presence references another resource. Refs #8319.
Paul Aurich <darkrain42@pidgin.im>
parents: 27622
diff changeset
835 if (chat->muc && x) {
e19d3ab2ce67 Notice when the MUC item JID on unavailable presence references another resource. Refs #8319.
Paul Aurich <darkrain42@pidgin.im>
parents: 27622
diff changeset
836 const char *nick;
e19d3ab2ce67 Notice when the MUC item JID on unavailable presence references another resource. Refs #8319.
Paul Aurich <darkrain42@pidgin.im>
parents: 27622
diff changeset
837 const char *item_jid = NULL;
27847
043b5d249732 The item JID will match the 'to' JID, not the from.
Paul Aurich <darkrain42@pidgin.im>
parents: 27844
diff changeset
838 const char *to;
27698
e19d3ab2ce67 Notice when the MUC item JID on unavailable presence references another resource. Refs #8319.
Paul Aurich <darkrain42@pidgin.im>
parents: 27622
diff changeset
839 xmlnode *stat;
e19d3ab2ce67 Notice when the MUC item JID on unavailable presence references another resource. Refs #8319.
Paul Aurich <darkrain42@pidgin.im>
parents: 27622
diff changeset
840 xmlnode *item;
27618
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
841
27698
e19d3ab2ce67 Notice when the MUC item JID on unavailable presence references another resource. Refs #8319.
Paul Aurich <darkrain42@pidgin.im>
parents: 27622
diff changeset
842 item = xmlnode_get_child(x, "item");
e19d3ab2ce67 Notice when the MUC item JID on unavailable presence references another resource. Refs #8319.
Paul Aurich <darkrain42@pidgin.im>
parents: 27622
diff changeset
843 if (item)
e19d3ab2ce67 Notice when the MUC item JID on unavailable presence references another resource. Refs #8319.
Paul Aurich <darkrain42@pidgin.im>
parents: 27622
diff changeset
844 item_jid = xmlnode_get_attrib(item, "jid");
e19d3ab2ce67 Notice when the MUC item JID on unavailable presence references another resource. Refs #8319.
Paul Aurich <darkrain42@pidgin.im>
parents: 27622
diff changeset
845
28138
8ca385ecc991 jabber: Read all MUC status codes in a presence. Fixes #6651.
Paul Aurich <darkrain42@pidgin.im>
parents: 28028
diff changeset
846 for (stat = xmlnode_get_child(x, "status"); stat;
8ca385ecc991 jabber: Read all MUC status codes in a presence. Fixes #6651.
Paul Aurich <darkrain42@pidgin.im>
parents: 28028
diff changeset
847 stat = xmlnode_get_next_twin(stat)) {
8ca385ecc991 jabber: Read all MUC status codes in a presence. Fixes #6651.
Paul Aurich <darkrain42@pidgin.im>
parents: 28028
diff changeset
848 const char *code = xmlnode_get_attrib(stat, "code");
27698
e19d3ab2ce67 Notice when the MUC item JID on unavailable presence references another resource. Refs #8319.
Paul Aurich <darkrain42@pidgin.im>
parents: 27622
diff changeset
849
28138
8ca385ecc991 jabber: Read all MUC status codes in a presence. Fixes #6651.
Paul Aurich <darkrain42@pidgin.im>
parents: 28028
diff changeset
850 if (!code)
8ca385ecc991 jabber: Read all MUC status codes in a presence. Fixes #6651.
Paul Aurich <darkrain42@pidgin.im>
parents: 28028
diff changeset
851 continue;
27698
e19d3ab2ce67 Notice when the MUC item JID on unavailable presence references another resource. Refs #8319.
Paul Aurich <darkrain42@pidgin.im>
parents: 27622
diff changeset
852
28138
8ca385ecc991 jabber: Read all MUC status codes in a presence. Fixes #6651.
Paul Aurich <darkrain42@pidgin.im>
parents: 28028
diff changeset
853 if (g_str_equal(code, "110")) {
8ca385ecc991 jabber: Read all MUC status codes in a presence. Fixes #6651.
Paul Aurich <darkrain42@pidgin.im>
parents: 28028
diff changeset
854 is_our_resource = TRUE;
8ca385ecc991 jabber: Read all MUC status codes in a presence. Fixes #6651.
Paul Aurich <darkrain42@pidgin.im>
parents: 28028
diff changeset
855 } else if(!strcmp(code, "301")) {
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 8577
diff changeset
856 /* XXX: we got banned */
27698
e19d3ab2ce67 Notice when the MUC item JID on unavailable presence references another resource. Refs #8319.
Paul Aurich <darkrain42@pidgin.im>
parents: 27622
diff changeset
857 } else if(!strcmp(code, "303") && item &&
e19d3ab2ce67 Notice when the MUC item JID on unavailable presence references another resource. Refs #8319.
Paul Aurich <darkrain42@pidgin.im>
parents: 27622
diff changeset
858 (nick = xmlnode_get_attrib(item, "nick"))) {
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 8577
diff changeset
859 nick_change = TRUE;
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 8577
diff changeset
860 if(!strcmp(jid->resource, chat->handle)) {
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 8577
diff changeset
861 g_free(chat->handle);
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 8577
diff changeset
862 chat->handle = g_strdup(nick);
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 8577
diff changeset
863 }
28138
8ca385ecc991 jabber: Read all MUC status codes in a presence. Fixes #6651.
Paul Aurich <darkrain42@pidgin.im>
parents: 28028
diff changeset
864
8ca385ecc991 jabber: Read all MUC status codes in a presence. Fixes #6651.
Paul Aurich <darkrain42@pidgin.im>
parents: 28028
diff changeset
865 /* TODO: This should probably be moved out of the loop */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15810
diff changeset
866 purple_conv_chat_rename_user(PURPLE_CONV_CHAT(chat->conv), jid->resource, nick);
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 8577
diff changeset
867 jabber_chat_remove_handle(chat, jid->resource);
28138
8ca385ecc991 jabber: Read all MUC status codes in a presence. Fixes #6651.
Paul Aurich <darkrain42@pidgin.im>
parents: 28028
diff changeset
868 continue;
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 8577
diff changeset
869 } else if(!strcmp(code, "307")) {
27618
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
870 /* Someone was kicked from the room */
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
871 xmlnode *reason = NULL, *actor = NULL;
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
872 const char *actor_name = NULL;
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
873 char *reason_text = NULL;
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
874 char *tmp;
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
875
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
876 kick = TRUE;
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
877
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
878 if (item) {
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
879 reason = xmlnode_get_child(item, "reason");
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
880 actor = xmlnode_get_child(item, "actor");
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
881
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
882 if (reason != NULL)
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
883 reason_text = xmlnode_get_data(reason);
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
884 if (actor != NULL)
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
885 actor_name = xmlnode_get_attrib(actor, "jid");
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
886 }
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
887
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
888 if (reason_text == NULL)
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
889 reason_text = g_strdup(_("No reason"));
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
890
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
891 if (is_our_resource) {
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
892 if (actor_name != NULL)
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
893 tmp = g_strdup_printf(_("You have been kicked by %s: (%s)"),
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
894 actor_name, reason_text);
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
895 else
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
896 tmp = g_strdup_printf(_("You have been kicked: (%s)"),
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
897 reason_text);
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
898 } else {
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
899 if (actor_name != NULL)
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
900 tmp = g_strdup_printf(_("Kicked by %s (%s)"),
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
901 actor_name, reason_text);
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
902 else
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
903 tmp = g_strdup_printf(_("Kicked (%s)"),
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
904 reason_text);
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
905 }
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
906
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
907 g_free(reason_text);
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
908 g_free(status);
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
909 status = tmp;
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 8577
diff changeset
910 } else if(!strcmp(code, "321")) {
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 8577
diff changeset
911 /* XXX: removed due to an affiliation change */
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 8577
diff changeset
912 } else if(!strcmp(code, "322")) {
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 8577
diff changeset
913 /* XXX: removed because room is now members-only */
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 8577
diff changeset
914 } else if(!strcmp(code, "332")) {
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 8577
diff changeset
915 /* XXX: removed due to system shutdown */
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8396
diff changeset
916 }
7972
f8538961a159 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7965
diff changeset
917 }
27698
e19d3ab2ce67 Notice when the MUC item JID on unavailable presence references another resource. Refs #8319.
Paul Aurich <darkrain42@pidgin.im>
parents: 27622
diff changeset
918
e19d3ab2ce67 Notice when the MUC item JID on unavailable presence references another resource. Refs #8319.
Paul Aurich <darkrain42@pidgin.im>
parents: 27622
diff changeset
919 /*
e19d3ab2ce67 Notice when the MUC item JID on unavailable presence references another resource. Refs #8319.
Paul Aurich <darkrain42@pidgin.im>
parents: 27622
diff changeset
920 * Possibly another connected resource of our JID (see XEP-0045
e19d3ab2ce67 Notice when the MUC item JID on unavailable presence references another resource. Refs #8319.
Paul Aurich <darkrain42@pidgin.im>
parents: 27622
diff changeset
921 * v1.24 section 7.1.10) being disconnected. Should be
e19d3ab2ce67 Notice when the MUC item JID on unavailable presence references another resource. Refs #8319.
Paul Aurich <darkrain42@pidgin.im>
parents: 27622
diff changeset
922 * distinguished by the item_jid.
e19d3ab2ce67 Notice when the MUC item JID on unavailable presence references another resource. Refs #8319.
Paul Aurich <darkrain42@pidgin.im>
parents: 27622
diff changeset
923 * Also possibly works around bits of an Openfire bug. See
e19d3ab2ce67 Notice when the MUC item JID on unavailable presence references another resource. Refs #8319.
Paul Aurich <darkrain42@pidgin.im>
parents: 27622
diff changeset
924 * #8319.
e19d3ab2ce67 Notice when the MUC item JID on unavailable presence references another resource. Refs #8319.
Paul Aurich <darkrain42@pidgin.im>
parents: 27622
diff changeset
925 */
27847
043b5d249732 The item JID will match the 'to' JID, not the from.
Paul Aurich <darkrain42@pidgin.im>
parents: 27844
diff changeset
926 to = xmlnode_get_attrib(packet, "to");
043b5d249732 The item JID will match the 'to' JID, not the from.
Paul Aurich <darkrain42@pidgin.im>
parents: 27844
diff changeset
927 if (is_our_resource && item_jid && !purple_strequal(to, item_jid)) {
27698
e19d3ab2ce67 Notice when the MUC item JID on unavailable presence references another resource. Refs #8319.
Paul Aurich <darkrain42@pidgin.im>
parents: 27622
diff changeset
928 /* TODO: When the above is a loop, this needs to still act
e19d3ab2ce67 Notice when the MUC item JID on unavailable presence references another resource. Refs #8319.
Paul Aurich <darkrain42@pidgin.im>
parents: 27622
diff changeset
929 * sanely for all cases (this code is a little fragile). */
e19d3ab2ce67 Notice when the MUC item JID on unavailable presence references another resource. Refs #8319.
Paul Aurich <darkrain42@pidgin.im>
parents: 27622
diff changeset
930 if (!kick && !nick_change)
e19d3ab2ce67 Notice when the MUC item JID on unavailable presence references another resource. Refs #8319.
Paul Aurich <darkrain42@pidgin.im>
parents: 27622
diff changeset
931 /* Presumably, kicks and nick changes also affect us. */
e19d3ab2ce67 Notice when the MUC item JID on unavailable presence references another resource. Refs #8319.
Paul Aurich <darkrain42@pidgin.im>
parents: 27622
diff changeset
932 is_our_resource = FALSE;
e19d3ab2ce67 Notice when the MUC item JID on unavailable presence references another resource. Refs #8319.
Paul Aurich <darkrain42@pidgin.im>
parents: 27622
diff changeset
933 }
7972
f8538961a159 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7965
diff changeset
934 }
f8538961a159 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7965
diff changeset
935 if(!nick_change) {
27618
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
936 if (is_our_resource) {
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
937 if (kick)
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
938 purple_conv_chat_write(PURPLE_CONV_CHAT(chat->conv), jid->resource,
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
939 status, PURPLE_MESSAGE_SYSTEM, time(NULL));
3362f6ddafe6 Add support for XEP-0045 code 307 (a.k.a. kicks).
Paul Aurich <darkrain42@pidgin.im>
parents: 27616
diff changeset
940
7972
f8538961a159 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7965
diff changeset
941 serv_got_chat_left(js->gc, chat->id);
f8538961a159 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7965
diff changeset
942 jabber_chat_destroy(chat);
f8538961a159 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7965
diff changeset
943 } else {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15810
diff changeset
944 purple_conv_chat_remove_user(PURPLE_CONV_CHAT(chat->conv), jid->resource,
7974
08ec901d48fb [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7973
diff changeset
945 status);
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 8577
diff changeset
946 jabber_chat_remove_handle(chat, jid->resource);
7972
f8538961a159 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7965
diff changeset
947 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
948 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
949 } else {
27620
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
950 /* A type that isn't available or unavailable */
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
951 purple_debug_error("jabber", "MUC presence with bad type: %s\n",
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
952 type);
25737
7f6a23aa9e8e *** Plucked rev 3993504a (darkrain42@pidgin.im):
Paul Aurich <darkrain42@pidgin.im>
parents: 25154
diff changeset
953
27620
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
954 jabber_id_free(jid);
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
955 g_free(avatar_hash);
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
956 g_free(status);
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
957 g_free(nickname);
d2a59ec05381 Rearranging this section and adding a catch for stuff that can't happen
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
958 g_return_if_reached();
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
959 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
960 } else {
7322
de15a9314c04 [gaim-migrate @ 7908]
Nathan Walp <nwalp@pidgin.im>
parents: 7321
diff changeset
961 buddy_name = g_strdup_printf("%s%s%s", jid->node ? jid->node : "",
18725
a3ab5c711de7 Now showing ad-hoc commands of other clients connected to the same account in the account menu (per XEP-0146). Since it is becoming messy in that menu, I also prefixed all ad-hoc commands with the node this command belongs to in [], which is the resource name for clients and the domain name for the server. Examples: "[home] Set status" for clients and "[jabber.org] Send message to all connected users" for servers.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
962 jid->node ? "@" : "", jid->domain);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15810
diff changeset
963 if((b = purple_find_buddy(js->gc->account, buddy_name)) == NULL) {
28985
e1763baccffc jabber: This is more clear.
Paul Aurich <darkrain42@pidgin.im>
parents: 28984
diff changeset
964 if (jb != js->user_jb) {
22622
1ecb840b5101 Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <markdoliner@pidgin.im>
parents: 21801
diff changeset
965 purple_debug_warning("jabber", "Got presence for unknown buddy %s on account %s (%p)\n",
18725
a3ab5c711de7 Now showing ad-hoc commands of other clients connected to the same account in the account menu (per XEP-0146). Since it is becoming messy in that menu, I also prefixed all ad-hoc commands with the node this command belongs to in [], which is the resource name for clients and the domain name for the server. Examples: "[home] Set status" for clients and "[jabber.org] Send message to all connected users" for servers.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
966 buddy_name, purple_account_get_username(js->gc->account), js->gc->account);
a3ab5c711de7 Now showing ad-hoc commands of other clients connected to the same account in the account menu (per XEP-0146). Since it is becoming messy in that menu, I also prefixed all ad-hoc commands with the node this command belongs to in [], which is the resource name for clients and the domain name for the server. Examples: "[home] Set status" for clients and "[jabber.org] Send message to all connected users" for servers.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
967 jabber_id_free(jid);
a3ab5c711de7 Now showing ad-hoc commands of other clients connected to the same account in the account menu (per XEP-0146). Since it is becoming messy in that menu, I also prefixed all ad-hoc commands with the node this command belongs to in [], which is the resource name for clients and the domain name for the server. Examples: "[home] Set status" for clients and "[jabber.org] Send message to all connected users" for servers.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
968 g_free(avatar_hash);
a3ab5c711de7 Now showing ad-hoc commands of other clients connected to the same account in the account menu (per XEP-0146). Since it is becoming messy in that menu, I also prefixed all ad-hoc commands with the node this command belongs to in [], which is the resource name for clients and the domain name for the server. Examples: "[home] Set status" for clients and "[jabber.org] Send message to all connected users" for servers.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
969 g_free(buddy_name);
26998
5d912b08679d A little bit better (free memory and support receiving the nick in subscriptions) and Changelog.
Paul Aurich <darkrain42@pidgin.im>
parents: 26997
diff changeset
970 g_free(nickname);
18725
a3ab5c711de7 Now showing ad-hoc commands of other clients connected to the same account in the account menu (per XEP-0146). Since it is becoming messy in that menu, I also prefixed all ad-hoc commands with the node this command belongs to in [], which is the resource name for clients and the domain name for the server. Examples: "[home] Set status" for clients and "[jabber.org] Send message to all connected users" for servers.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
971 g_free(status);
a3ab5c711de7 Now showing ad-hoc commands of other clients connected to the same account in the account menu (per XEP-0146). Since it is becoming messy in that menu, I also prefixed all ad-hoc commands with the node this command belongs to in [], which is the resource name for clients and the domain name for the server. Examples: "[home] Set status" for clients and "[jabber.org] Send message to all connected users" for servers.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
972 return;
a3ab5c711de7 Now showing ad-hoc commands of other clients connected to the same account in the account menu (per XEP-0146). Since it is becoming messy in that menu, I also prefixed all ad-hoc commands with the node this command belongs to in [], which is the resource name for clients and the domain name for the server. Examples: "[home] Set status" for clients and "[jabber.org] Send message to all connected users" for servers.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
973 } else {
a3ab5c711de7 Now showing ad-hoc commands of other clients connected to the same account in the account menu (per XEP-0146). Since it is becoming messy in that menu, I also prefixed all ad-hoc commands with the node this command belongs to in [], which is the resource name for clients and the domain name for the server. Examples: "[home] Set status" for clients and "[jabber.org] Send message to all connected users" for servers.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
974 /* this is a different resource of our own account. Resume even when this account isn't on our blist */
a3ab5c711de7 Now showing ad-hoc commands of other clients connected to the same account in the account menu (per XEP-0146). Since it is becoming messy in that menu, I also prefixed all ad-hoc commands with the node this command belongs to in [], which is the resource name for clients and the domain name for the server. Examples: "[home] Set status" for clients and "[jabber.org] Send message to all connected users" for servers.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
975 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
976 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
977
18725
a3ab5c711de7 Now showing ad-hoc commands of other clients connected to the same account in the account menu (per XEP-0146). Since it is becoming messy in that menu, I also prefixed all ad-hoc commands with the node this command belongs to in [], which is the resource name for clients and the domain name for the server. Examples: "[home] Set status" for clients and "[jabber.org] Send message to all connected users" for servers.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
978 if(b && avatar_hash) {
16534
2ab9e23f99d9 Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents: 16018
diff changeset
979 const char *avatar_hash2 = purple_buddy_icons_get_checksum_for_user(b);
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 10116
diff changeset
980 if(!avatar_hash2 || strcmp(avatar_hash, avatar_hash2)) {
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 10116
diff changeset
981 JabberIq *iq;
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 10116
diff changeset
982 xmlnode *vcard;
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 10116
diff changeset
983
10941
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10755
diff changeset
984 /* XXX this is a crappy way of trying to prevent
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10755
diff changeset
985 * someone from spamming us with presence packets
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10755
diff changeset
986 * and causing us to DoS ourselves...what we really
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10755
diff changeset
987 * need is a queue system that can throttle itself,
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10755
diff changeset
988 * but i'm too tired to write that right now */
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10755
diff changeset
989 if(!g_slist_find(js->pending_avatar_requests, jb)) {
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10755
diff changeset
990
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10755
diff changeset
991 js->pending_avatar_requests = g_slist_prepend(js->pending_avatar_requests, jb);
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 10116
diff changeset
992
10941
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10755
diff changeset
993 iq = jabber_iq_new(js, JABBER_IQ_GET);
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10755
diff changeset
994 xmlnode_set_attrib(iq->node, "to", buddy_name);
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10755
diff changeset
995 vcard = xmlnode_new_child(iq->node, "vCard");
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 13497
diff changeset
996 xmlnode_set_namespace(vcard, "vcard-temp");
10941
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10755
diff changeset
997
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10755
diff changeset
998 jabber_iq_set_callback(iq, jabber_vcard_parse_avatar, NULL);
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10755
diff changeset
999 jabber_iq_send(iq);
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10755
diff changeset
1000 }
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 10116
diff changeset
1001 }
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 10116
diff changeset
1002 }
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 10116
diff changeset
1003
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9931
diff changeset
1004 if(state == JABBER_BUDDY_STATE_ERROR ||
27619
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
1005 (type && (g_str_equal(type, "unavailable") ||
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
1006 g_str_equal(type, "unsubscribed")))) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15810
diff changeset
1007 PurpleConversation *conv;
8043
86a087e9624c [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
1008
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1009 jabber_buddy_remove_resource(jb, jid->resource);
8043
86a087e9624c [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
1010 if((conv = jabber_find_unnormalized_conv(from, js->gc->account)))
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15810
diff changeset
1011 purple_conversation_set_name(conv, buddy_name);
8043
86a087e9624c [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
1012
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
1013 } else {
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9931
diff changeset
1014 jbr = jabber_buddy_track_resource(jb, jid->resource, priority,
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9931
diff changeset
1015 state, status);
25229
d89db7b7fb94 Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 25228
diff changeset
1016 if (idle) {
d89db7b7fb94 Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 25228
diff changeset
1017 jbr->idle = time(NULL) - idle;
d89db7b7fb94 Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 25228
diff changeset
1018 } else {
d89db7b7fb94 Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 25228
diff changeset
1019 jbr->idle = 0;
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17812
diff changeset
1020 }
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
1021 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1022
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9931
diff changeset
1023 if((found_jbr = jabber_buddy_find_resource(jb, NULL))) {
21195
fd63ef5027d7 Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents: 21193
diff changeset
1024 jabber_google_presence_incoming(js, buddy_name, found_jbr);
fd63ef5027d7 Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents: 21193
diff changeset
1025 purple_prpl_got_user_status(js->gc->account, buddy_name, jabber_buddy_state_get_status_id(found_jbr->state), "priority", found_jbr->priority, "message", found_jbr->status, NULL);
25229
d89db7b7fb94 Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 25228
diff changeset
1026 purple_prpl_got_user_idle(js->gc->account, buddy_name, found_jbr->idle, found_jbr->idle);
26998
5d912b08679d A little bit better (free memory and support receiving the nick in subscriptions) and Changelog.
Paul Aurich <darkrain42@pidgin.im>
parents: 26997
diff changeset
1027 if (nickname)
5d912b08679d A little bit better (free memory and support receiving the nick in subscriptions) and Changelog.
Paul Aurich <darkrain42@pidgin.im>
parents: 26997
diff changeset
1028 serv_got_alias(js->gc, buddy_name, nickname);
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9931
diff changeset
1029 } else {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15810
diff changeset
1030 purple_prpl_got_user_status(js->gc->account, buddy_name, "offline", status ? "message" : NULL, status, NULL);
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9931
diff changeset
1031 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1032 g_free(buddy_name);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1033 }
26976
5173897818ed Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <darkrain42@pidgin.im>
parents: 26975
diff changeset
1034
27619
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27618
diff changeset
1035 if (caps && !type) {
26976
5173897818ed Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <darkrain42@pidgin.im>
parents: 26975
diff changeset
1036 /* handle Entity Capabilities (XEP-0115) */
5173897818ed Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <darkrain42@pidgin.im>
parents: 26975
diff changeset
1037 const char *node = xmlnode_get_attrib(caps, "node");
5173897818ed Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <darkrain42@pidgin.im>
parents: 26975
diff changeset
1038 const char *ver = xmlnode_get_attrib(caps, "ver");
5173897818ed Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <darkrain42@pidgin.im>
parents: 26975
diff changeset
1039 const char *hash = xmlnode_get_attrib(caps, "hash");
5173897818ed Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <darkrain42@pidgin.im>
parents: 26975
diff changeset
1040 const char *ext = xmlnode_get_attrib(caps, "ext");
5173897818ed Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <darkrain42@pidgin.im>
parents: 26975
diff changeset
1041
5173897818ed Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <darkrain42@pidgin.im>
parents: 26975
diff changeset
1042 /* v1.3 uses: node, ver, and optionally ext.
5173897818ed Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <darkrain42@pidgin.im>
parents: 26975
diff changeset
1043 * v1.5 uses: node, ver, and hash. */
5173897818ed Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <darkrain42@pidgin.im>
parents: 26975
diff changeset
1044 if (node && *node && ver && *ver) {
27068
3353c0f46a1a Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents: 27066
diff changeset
1045 gchar **exts = ext && *ext ? g_strsplit(ext, " ", -1) : NULL;
3353c0f46a1a Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents: 27066
diff changeset
1046 jbr = jabber_buddy_find_resource(jb, jid->resource);
3353c0f46a1a Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents: 27066
diff changeset
1047
3353c0f46a1a Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents: 27066
diff changeset
1048 /* Look it up if we don't already have all this information */
3353c0f46a1a Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents: 27066
diff changeset
1049 if (!jbr || !jbr->caps.info ||
3353c0f46a1a Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents: 27066
diff changeset
1050 !g_str_equal(node, jbr->caps.info->tuple.node) ||
3353c0f46a1a Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents: 27066
diff changeset
1051 !g_str_equal(ver, jbr->caps.info->tuple.ver) ||
3353c0f46a1a Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents: 27066
diff changeset
1052 !purple_strequal(hash, jbr->caps.info->tuple.hash) ||
3353c0f46a1a Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents: 27066
diff changeset
1053 !jabber_caps_exts_known(jbr->caps.info, (gchar **)exts)) {
3353c0f46a1a Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents: 27066
diff changeset
1054 JabberPresenceCapabilities *userdata = g_new0(JabberPresenceCapabilities, 1);
3353c0f46a1a Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents: 27066
diff changeset
1055 userdata->js = js;
3353c0f46a1a Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents: 27066
diff changeset
1056 userdata->jb = jb;
3353c0f46a1a Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents: 27066
diff changeset
1057 userdata->from = g_strdup(from);
3353c0f46a1a Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents: 27066
diff changeset
1058 jabber_caps_get_info(js, from, node, ver, hash, exts,
3353c0f46a1a Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents: 27066
diff changeset
1059 (jabber_caps_get_info_cb)jabber_presence_set_capabilities,
3353c0f46a1a Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents: 27066
diff changeset
1060 userdata);
3353c0f46a1a Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents: 27066
diff changeset
1061 } else {
3353c0f46a1a Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents: 27066
diff changeset
1062 if (exts)
3353c0f46a1a Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents: 27066
diff changeset
1063 g_strfreev(exts);
3353c0f46a1a Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents: 27066
diff changeset
1064 }
26976
5173897818ed Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <darkrain42@pidgin.im>
parents: 26975
diff changeset
1065 }
5173897818ed Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <darkrain42@pidgin.im>
parents: 26975
diff changeset
1066 }
5173897818ed Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <darkrain42@pidgin.im>
parents: 26975
diff changeset
1067
26998
5d912b08679d A little bit better (free memory and support receiving the nick in subscriptions) and Changelog.
Paul Aurich <darkrain42@pidgin.im>
parents: 26997
diff changeset
1068 g_free(nickname);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1069 g_free(status);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1070 jabber_id_free(jid);
17702
15af85f94634 Don't check for null before calling free. I can't help but get rid
Mark Doliner <markdoliner@pidgin.im>
parents: 17683
diff changeset
1071 g_free(avatar_hash);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1072 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1073
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1074 void jabber_presence_subscription_set(JabberStream *js, const char *who, const char *type)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1075 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1076 xmlnode *presence = xmlnode_new("presence");
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1077
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1078 xmlnode_set_attrib(presence, "to", who);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1079 xmlnode_set_attrib(presence, "type", type);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1080
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1081 jabber_send(js, presence);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1082 xmlnode_free(presence);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1083 }
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9931
diff changeset
1084
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15810
diff changeset
1085 void purple_status_to_jabber(const PurpleStatus *status, JabberBuddyState *state, char **msg, int *priority)
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9931
diff changeset
1086 {
10216
37091349650c [gaim-migrate @ 11343]
Nathan Walp <nwalp@pidgin.im>
parents: 10189
diff changeset
1087 const char *status_id = NULL;
14525
b278a2724686 [gaim-migrate @ 17177]
Nathan Walp <nwalp@pidgin.im>
parents: 14254
diff changeset
1088 const char *formatted_msg = NULL;
10216
37091349650c [gaim-migrate @ 11343]
Nathan Walp <nwalp@pidgin.im>
parents: 10189
diff changeset
1089
13443
e27e92c22036 [gaim-migrate @ 15817]
Nathan Walp <nwalp@pidgin.im>
parents: 13385
diff changeset
1090 if(state) *state = JABBER_BUDDY_STATE_UNKNOWN;
e27e92c22036 [gaim-migrate @ 15817]
Nathan Walp <nwalp@pidgin.im>
parents: 13385
diff changeset
1091 if(msg) *msg = NULL;
e27e92c22036 [gaim-migrate @ 15817]
Nathan Walp <nwalp@pidgin.im>
parents: 13385
diff changeset
1092 if(priority) *priority = 0;
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9931
diff changeset
1093
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9931
diff changeset
1094 if(!status) {
13443
e27e92c22036 [gaim-migrate @ 15817]
Nathan Walp <nwalp@pidgin.im>
parents: 13385
diff changeset
1095 if(state) *state = JABBER_BUDDY_STATE_UNAVAILABLE;
10216
37091349650c [gaim-migrate @ 11343]
Nathan Walp <nwalp@pidgin.im>
parents: 10189
diff changeset
1096 } else {
37091349650c [gaim-migrate @ 11343]
Nathan Walp <nwalp@pidgin.im>
parents: 10189
diff changeset
1097 if(state) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15810
diff changeset
1098 status_id = purple_status_get_id(status);
10216
37091349650c [gaim-migrate @ 11343]
Nathan Walp <nwalp@pidgin.im>
parents: 10189
diff changeset
1099 *state = jabber_buddy_status_id_get_state(status_id);
37091349650c [gaim-migrate @ 11343]
Nathan Walp <nwalp@pidgin.im>
parents: 10189
diff changeset
1100 }
37091349650c [gaim-migrate @ 11343]
Nathan Walp <nwalp@pidgin.im>
parents: 10189
diff changeset
1101
13497
07fc0a9826b8 [gaim-migrate @ 15872]
Richard Laager <rlaager@pidgin.im>
parents: 13445
diff changeset
1102 if(msg) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15810
diff changeset
1103 formatted_msg = purple_status_get_attr_string(status, "message");
10216
37091349650c [gaim-migrate @ 11343]
Nathan Walp <nwalp@pidgin.im>
parents: 10189
diff changeset
1104
13497
07fc0a9826b8 [gaim-migrate @ 15872]
Richard Laager <rlaager@pidgin.im>
parents: 13445
diff changeset
1105 /* if the message is blank, then there really isn't a message */
27775
b8569a76e02e Don't pre-escape jbr->status. Almost every place required it in unescaped
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27698
diff changeset
1106 if(formatted_msg && *formatted_msg)
17683
cc7e7a1d5d8c Two questions:
Mark Doliner <markdoliner@pidgin.im>
parents: 17422
diff changeset
1107 *msg = purple_markup_strip_html(formatted_msg);
13497
07fc0a9826b8 [gaim-migrate @ 15872]
Richard Laager <rlaager@pidgin.im>
parents: 13445
diff changeset
1108 }
11872
05cdcbf6f145 [gaim-migrate @ 14163]
Nathan Walp <nwalp@pidgin.im>
parents: 11718
diff changeset
1109
10216
37091349650c [gaim-migrate @ 11343]
Nathan Walp <nwalp@pidgin.im>
parents: 10189
diff changeset
1110 if(priority)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15810
diff changeset
1111 *priority = purple_status_get_attr_int(status, "priority");
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9931
diff changeset
1112 }
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9931
diff changeset
1113 }

mercurial