Mercurial > pidgin
annotate libpurple/protocols/jabber/presence.c @ 32807:fb8263d936e5
Add a conversation theme with no timestamps.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Mon, 28 May 2012 22:34:59 +0000 |
parents | 2ec94166be43 |
children |
rev | line source |
---|---|
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1 /* |
15822 | 2 * purple - Jabber Protocol Plugin |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3 * |
28048
c585572e80dd
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents:
27862
diff
changeset
|
4 * Purple is the legal property of its developers, whose names are too numerous |
c585572e80dd
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents:
27862
diff
changeset
|
5 * to list here. Please refer to the COPYRIGHT file distributed with this |
c585572e80dd
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents:
27862
diff
changeset
|
6 * source distribution. |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
7 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
8 * This program is free software; you can redistribute it and/or modify |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
9 * it under the terms of the GNU General Public License as published by |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
10 * the Free Software Foundation; either version 2 of the License, or |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
11 * (at your option) any later version. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
12 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
16 * GNU General Public License for more details. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
17 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
19 * along with this program; if not, write to the Free Software |
19681
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19195
diff
changeset
|
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
21 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
22 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
23 #include "internal.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
24 |
15889
87ea711b9781
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <stu@nosnilmot.com>
parents:
15822
diff
changeset
|
25 #include "account.h" |
87ea711b9781
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <stu@nosnilmot.com>
parents:
15822
diff
changeset
|
26 #include "conversation.h" |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
27 #include "debug.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
28 #include "notify.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
29 #include "request.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
30 #include "server.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
31 #include "status.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
32 #include "util.h" |
15889
87ea711b9781
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <stu@nosnilmot.com>
parents:
15822
diff
changeset
|
33 #include "xmlnode.h" |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
34 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
35 #include "buddy.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
36 #include "chat.h" |
30472
ae615b3d3e47
First shot at refactoring the Google-specific XMPP code.
Marcus Lundblad <ml@update.uu.se>
parents:
29630
diff
changeset
|
37 #include "google/google.h" |
ae615b3d3e47
First shot at refactoring the Google-specific XMPP code.
Marcus Lundblad <ml@update.uu.se>
parents:
29630
diff
changeset
|
38 #include "google/google_presence.h" |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
39 #include "presence.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
40 #include "iq.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
41 #include "jutil.h" |
17882
f88b3a093cba
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 <pidgin@monitzer.com>
parents:
17878
diff
changeset
|
42 #include "adhoccommands.h" |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
43 |
29469
5d56c0dd2810
jabber: Actually send a mood update when setting a mood status (using the generic mood selector).
Marcus Lundblad <ml@update.uu.se>
parents:
28902
diff
changeset
|
44 #include "usermood.h" |
17866
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
45 #include "usertune.h" |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
46 |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
47 static GHashTable *presence_handlers = NULL; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
48 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
49 static const struct { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
50 const char *name; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
51 JabberPresenceType type; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
52 } jabber_presence_types[] = { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
53 { "error", JABBER_PRESENCE_ERROR }, |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
54 { "probe", JABBER_PRESENCE_PROBE }, |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
55 { "unavailable", JABBER_PRESENCE_UNAVAILABLE }, |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
56 { "subscribe", JABBER_PRESENCE_SUBSCRIBE }, |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
57 { "subscribed", JABBER_PRESENCE_SUBSCRIBED }, |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
58 { "unsubscribe", JABBER_PRESENCE_UNSUBSCRIBE }, |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
59 { "unsubscribed", JABBER_PRESENCE_UNSUBSCRIBED } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
60 /* { NULL, JABBER_PRESENCE_AVAILABLE } the default */ |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
61 }; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
62 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
63 static JabberPresenceType |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
64 str_to_presence_type(const char *type) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
65 { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
66 int i; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
67 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
68 if (type == NULL) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
69 return JABBER_PRESENCE_AVAILABLE; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
70 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
71 for (i = 0; i < G_N_ELEMENTS(jabber_presence_types); ++i) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
72 if (g_str_equal(type, jabber_presence_types[i].name)) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
73 return jabber_presence_types[i].type; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
74 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
75 purple_debug_warning("jabber", "Unknown presence type '%s'\n", type); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
76 return JABBER_PRESENCE_AVAILABLE; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
77 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
78 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
79 static void chats_send_presence_foreach(gpointer key, gpointer val, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
80 gpointer user_data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
81 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
82 JabberChat *chat = val; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
83 xmlnode *presence = user_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
84 char *chat_full_jid; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
85 |
23260
5793bcea224c
Fix the chat-room rejoining bug where the list appears empty.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23103
diff
changeset
|
86 if(!chat->conv || chat->left) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
87 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
88 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
89 chat_full_jid = g_strdup_printf("%s@%s/%s", chat->room, chat->server, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
90 chat->handle); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
91 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
92 xmlnode_set_attrib(presence, "to", chat_full_jid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
93 jabber_send(chat->js, presence); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
94 g_free(chat_full_jid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
95 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
96 |
27497
9a5a9a4e7626
Simplify the fake_to_self function.
Paul Aurich <paul@darkrain42.org>
parents:
27495
diff
changeset
|
97 void jabber_presence_fake_to_self(JabberStream *js, PurpleStatus *status) |
9a5a9a4e7626
Simplify the fake_to_self function.
Paul Aurich <paul@darkrain42.org>
parents:
27495
diff
changeset
|
98 { |
9a5a9a4e7626
Simplify the fake_to_self function.
Paul Aurich <paul@darkrain42.org>
parents:
27495
diff
changeset
|
99 PurpleAccount *account; |
27699
735040819c16
jabber: Properly track own idle time in fake_to_self.
Paul Aurich <paul@darkrain42.org>
parents:
27607
diff
changeset
|
100 PurplePresence *presence; |
29046
1c035c869344
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <paul@darkrain42.org>
parents:
29016
diff
changeset
|
101 JabberBuddy *jb; |
1c035c869344
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <paul@darkrain42.org>
parents:
29016
diff
changeset
|
102 JabberBuddyResource *jbr; |
27497
9a5a9a4e7626
Simplify the fake_to_self function.
Paul Aurich <paul@darkrain42.org>
parents:
27495
diff
changeset
|
103 const char *username; |
29046
1c035c869344
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <paul@darkrain42.org>
parents:
29016
diff
changeset
|
104 JabberBuddyState state; |
1c035c869344
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <paul@darkrain42.org>
parents:
29016
diff
changeset
|
105 char *msg; |
1c035c869344
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <paul@darkrain42.org>
parents:
29016
diff
changeset
|
106 int priority; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
107 |
27497
9a5a9a4e7626
Simplify the fake_to_self function.
Paul Aurich <paul@darkrain42.org>
parents:
27495
diff
changeset
|
108 g_return_if_fail(js->user != NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
109 |
27497
9a5a9a4e7626
Simplify the fake_to_self function.
Paul Aurich <paul@darkrain42.org>
parents:
27495
diff
changeset
|
110 account = purple_connection_get_account(js->gc); |
27607
f95bcb5eb047
Support connecting to IDNA XMPP domains.
Paul Aurich <paul@darkrain42.org>
parents:
27594
diff
changeset
|
111 username = purple_connection_get_display_name(js->gc); |
27699
735040819c16
jabber: Properly track own idle time in fake_to_self.
Paul Aurich <paul@darkrain42.org>
parents:
27607
diff
changeset
|
112 presence = purple_account_get_presence(account); |
27497
9a5a9a4e7626
Simplify the fake_to_self function.
Paul Aurich <paul@darkrain42.org>
parents:
27495
diff
changeset
|
113 if (status == NULL) |
27699
735040819c16
jabber: Properly track own idle time in fake_to_self.
Paul Aurich <paul@darkrain42.org>
parents:
27607
diff
changeset
|
114 status = purple_presence_get_active_status(presence); |
29046
1c035c869344
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <paul@darkrain42.org>
parents:
29016
diff
changeset
|
115 purple_status_to_jabber(status, &state, &msg, &priority); |
27497
9a5a9a4e7626
Simplify the fake_to_self function.
Paul Aurich <paul@darkrain42.org>
parents:
27495
diff
changeset
|
116 |
29046
1c035c869344
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <paul@darkrain42.org>
parents:
29016
diff
changeset
|
117 jb = js->user_jb; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
118 |
29046
1c035c869344
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <paul@darkrain42.org>
parents:
29016
diff
changeset
|
119 if (state == JABBER_BUDDY_STATE_UNAVAILABLE || |
1c035c869344
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <paul@darkrain42.org>
parents:
29016
diff
changeset
|
120 state == JABBER_BUDDY_STATE_UNKNOWN) { |
1c035c869344
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <paul@darkrain42.org>
parents:
29016
diff
changeset
|
121 jabber_buddy_remove_resource(jb, js->user->resource); |
1c035c869344
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <paul@darkrain42.org>
parents:
29016
diff
changeset
|
122 } else { |
1c035c869344
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <paul@darkrain42.org>
parents:
29016
diff
changeset
|
123 jbr = jabber_buddy_track_resource(jb, js->user->resource, priority, |
1c035c869344
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <paul@darkrain42.org>
parents:
29016
diff
changeset
|
124 state, msg); |
1c035c869344
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <paul@darkrain42.org>
parents:
29016
diff
changeset
|
125 jbr->idle = purple_presence_is_idle(presence) ? |
1c035c869344
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <paul@darkrain42.org>
parents:
29016
diff
changeset
|
126 purple_presence_get_idle_time(presence) : 0; |
1c035c869344
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <paul@darkrain42.org>
parents:
29016
diff
changeset
|
127 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
128 |
29046
1c035c869344
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <paul@darkrain42.org>
parents:
29016
diff
changeset
|
129 /* |
1c035c869344
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <paul@darkrain42.org>
parents:
29016
diff
changeset
|
130 * While we need to track the status of this resource, the core |
1c035c869344
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <paul@darkrain42.org>
parents:
29016
diff
changeset
|
131 * only cares if we're on our own buddy list. |
1c035c869344
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <paul@darkrain42.org>
parents:
29016
diff
changeset
|
132 */ |
1c035c869344
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <paul@darkrain42.org>
parents:
29016
diff
changeset
|
133 if (purple_find_buddy(account, username)) { |
1c035c869344
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <paul@darkrain42.org>
parents:
29016
diff
changeset
|
134 jbr = jabber_buddy_find_resource(jb, NULL); |
1c035c869344
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <paul@darkrain42.org>
parents:
29016
diff
changeset
|
135 if (jbr) { |
27699
735040819c16
jabber: Properly track own idle time in fake_to_self.
Paul Aurich <paul@darkrain42.org>
parents:
27607
diff
changeset
|
136 purple_prpl_got_user_status(account, username, |
735040819c16
jabber: Properly track own idle time in fake_to_self.
Paul Aurich <paul@darkrain42.org>
parents:
27607
diff
changeset
|
137 jabber_buddy_state_get_status_id(jbr->state), |
735040819c16
jabber: Properly track own idle time in fake_to_self.
Paul Aurich <paul@darkrain42.org>
parents:
27607
diff
changeset
|
138 "priority", jbr->priority, |
735040819c16
jabber: Properly track own idle time in fake_to_self.
Paul Aurich <paul@darkrain42.org>
parents:
27607
diff
changeset
|
139 jbr->status ? "message" : NULL, jbr->status, |
735040819c16
jabber: Properly track own idle time in fake_to_self.
Paul Aurich <paul@darkrain42.org>
parents:
27607
diff
changeset
|
140 NULL); |
735040819c16
jabber: Properly track own idle time in fake_to_self.
Paul Aurich <paul@darkrain42.org>
parents:
27607
diff
changeset
|
141 purple_prpl_got_user_idle(account, username, jbr->idle, jbr->idle); |
27497
9a5a9a4e7626
Simplify the fake_to_self function.
Paul Aurich <paul@darkrain42.org>
parents:
27495
diff
changeset
|
142 } else { |
27699
735040819c16
jabber: Properly track own idle time in fake_to_self.
Paul Aurich <paul@darkrain42.org>
parents:
27607
diff
changeset
|
143 purple_prpl_got_user_status(account, username, "offline", |
735040819c16
jabber: Properly track own idle time in fake_to_self.
Paul Aurich <paul@darkrain42.org>
parents:
27607
diff
changeset
|
144 msg ? "message" : NULL, msg, |
735040819c16
jabber: Properly track own idle time in fake_to_self.
Paul Aurich <paul@darkrain42.org>
parents:
27607
diff
changeset
|
145 NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
146 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
147 } |
29046
1c035c869344
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <paul@darkrain42.org>
parents:
29016
diff
changeset
|
148 g_free(msg); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
149 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
150 |
25147
6d6e10476c52
Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents:
25146
diff
changeset
|
151 void jabber_set_status(PurpleAccount *account, PurpleStatus *status) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
152 { |
25147
6d6e10476c52
Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents:
25146
diff
changeset
|
153 PurpleConnection *gc; |
6d6e10476c52
Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents:
25146
diff
changeset
|
154 JabberStream *js; |
6d6e10476c52
Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents:
25146
diff
changeset
|
155 |
6d6e10476c52
Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents:
25146
diff
changeset
|
156 if (!purple_account_is_connected(account)) |
6d6e10476c52
Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents:
25146
diff
changeset
|
157 return; |
26932
a8537bbcfb79
Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents:
26920
diff
changeset
|
158 |
25147
6d6e10476c52
Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents:
25146
diff
changeset
|
159 if (purple_status_is_exclusive(status) && !purple_status_is_active(status)) { |
6d6e10476c52
Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents:
25146
diff
changeset
|
160 /* An exclusive status can't be deactivated. You should just |
6d6e10476c52
Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents:
25146
diff
changeset
|
161 * activate some other exclusive status. */ |
6d6e10476c52
Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents:
25146
diff
changeset
|
162 return; |
6d6e10476c52
Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents:
25146
diff
changeset
|
163 } |
6d6e10476c52
Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents:
25146
diff
changeset
|
164 |
6d6e10476c52
Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents:
25146
diff
changeset
|
165 gc = purple_account_get_connection(account); |
25985
c4fd9222dda1
propagate from branch 'im.pidgin.pidgin' (head 303af74a38e7b313d4fb0be4d4054a16cb13d819)
Paul Aurich <paul@darkrain42.org>
diff
changeset
|
166 js = purple_connection_get_protocol_data(gc); |
29469
5d56c0dd2810
jabber: Actually send a mood update when setting a mood status (using the generic mood selector).
Marcus Lundblad <ml@update.uu.se>
parents:
28902
diff
changeset
|
167 |
5d56c0dd2810
jabber: Actually send a mood update when setting a mood status (using the generic mood selector).
Marcus Lundblad <ml@update.uu.se>
parents:
28902
diff
changeset
|
168 /* it's a mood update */ |
5d56c0dd2810
jabber: Actually send a mood update when setting a mood status (using the generic mood selector).
Marcus Lundblad <ml@update.uu.se>
parents:
28902
diff
changeset
|
169 if (purple_status_type_get_primitive(purple_status_get_type(status)) == PURPLE_STATUS_MOOD) { |
5d56c0dd2810
jabber: Actually send a mood update when setting a mood status (using the generic mood selector).
Marcus Lundblad <ml@update.uu.se>
parents:
28902
diff
changeset
|
170 const char *mood = |
5d56c0dd2810
jabber: Actually send a mood update when setting a mood status (using the generic mood selector).
Marcus Lundblad <ml@update.uu.se>
parents:
28902
diff
changeset
|
171 purple_status_get_attr_string(status, PURPLE_MOOD_NAME); |
29531
b0cb194dc139
Enable setting mood message with the global mood selection UI, when the
Marcus Lundblad <ml@update.uu.se>
parents:
29473
diff
changeset
|
172 const char *mood_text = |
b0cb194dc139
Enable setting mood message with the global mood selection UI, when the
Marcus Lundblad <ml@update.uu.se>
parents:
29473
diff
changeset
|
173 purple_status_get_attr_string(status, PURPLE_MOOD_COMMENT); |
b0cb194dc139
Enable setting mood message with the global mood selection UI, when the
Marcus Lundblad <ml@update.uu.se>
parents:
29473
diff
changeset
|
174 jabber_mood_set(js, mood, mood_text); |
29469
5d56c0dd2810
jabber: Actually send a mood update when setting a mood status (using the generic mood selector).
Marcus Lundblad <ml@update.uu.se>
parents:
28902
diff
changeset
|
175 return; |
5d56c0dd2810
jabber: Actually send a mood update when setting a mood status (using the generic mood selector).
Marcus Lundblad <ml@update.uu.se>
parents:
28902
diff
changeset
|
176 } |
5d56c0dd2810
jabber: Actually send a mood update when setting a mood status (using the generic mood selector).
Marcus Lundblad <ml@update.uu.se>
parents:
28902
diff
changeset
|
177 |
25147
6d6e10476c52
Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents:
25146
diff
changeset
|
178 jabber_presence_send(js, FALSE); |
6d6e10476c52
Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents:
25146
diff
changeset
|
179 } |
6d6e10476c52
Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents:
25146
diff
changeset
|
180 |
6d6e10476c52
Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents:
25146
diff
changeset
|
181 void jabber_presence_send(JabberStream *js, gboolean force) |
6d6e10476c52
Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents:
25146
diff
changeset
|
182 { |
6d6e10476c52
Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents:
25146
diff
changeset
|
183 PurpleAccount *account; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
184 xmlnode *presence, *x, *photo; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
185 char *stripped = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
186 JabberBuddyState state; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
187 int priority; |
20570
5913725cbcd6
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20058
diff
changeset
|
188 const char *artist = NULL, *title = NULL, *source = NULL, *uri = NULL, *track = NULL; |
5913725cbcd6
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20058
diff
changeset
|
189 int length = -1; |
17890
935005186312
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17882
diff
changeset
|
190 gboolean allowBuzz; |
21629
6636546aeacf
We need to work with the exclusive status.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21602
diff
changeset
|
191 PurplePresence *p; |
25147
6d6e10476c52
Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents:
25146
diff
changeset
|
192 PurpleStatus *status, *tune; |
18123
ca965dfd3875
kill some code duplication when sending current presence
Nathan Walp <nwalp@pidgin.im>
parents:
17603
diff
changeset
|
193 |
25147
6d6e10476c52
Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents:
25146
diff
changeset
|
194 account = purple_connection_get_account(js->gc); |
6d6e10476c52
Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents:
25146
diff
changeset
|
195 p = purple_account_get_presence(account); |
6d6e10476c52
Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents:
25146
diff
changeset
|
196 status = purple_presence_get_active_status(p); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
197 |
18154
08e639dbac99
really and truly enforce the no-presence-before-roster thing
Nathan Walp <nwalp@pidgin.im>
parents:
18123
diff
changeset
|
198 /* we don't want to send presence before we've gotten our roster */ |
27495
c8390dc125c1
Use js->state to track whether the roster has been retrieved.
Paul Aurich <paul@darkrain42.org>
parents:
26997
diff
changeset
|
199 if (js->state != JABBER_STREAM_CONNECTED) { |
28759
f267c1608102
jabber: Lower the prio of this message; it's not very important.
Paul Aurich <paul@darkrain42.org>
parents:
28729
diff
changeset
|
200 purple_debug_misc("jabber", "attempt to send presence before roster retrieved\n"); |
18154
08e639dbac99
really and truly enforce the no-presence-before-roster thing
Nathan Walp <nwalp@pidgin.im>
parents:
18123
diff
changeset
|
201 return; |
08e639dbac99
really and truly enforce the no-presence-before-roster thing
Nathan Walp <nwalp@pidgin.im>
parents:
18123
diff
changeset
|
202 } |
08e639dbac99
really and truly enforce the no-presence-before-roster thing
Nathan Walp <nwalp@pidgin.im>
parents:
18123
diff
changeset
|
203 |
15822 | 204 purple_status_to_jabber(status, &state, &stripped, &priority); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24721
diff
changeset
|
205 |
17890
935005186312
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17882
diff
changeset
|
206 /* check for buzz support */ |
935005186312
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17882
diff
changeset
|
207 allowBuzz = purple_status_get_attr_boolean(status,"buzz"); |
935005186312
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17882
diff
changeset
|
208 /* changing the buzz state has to trigger a re-broadcasting of the presence for caps */ |
23429
146d16459cda
make googletalk tune hack work, previously it's not doing anything unless
Ka-Hing Cheung <khc@hxbc.us>
parents:
23260
diff
changeset
|
209 |
25147
6d6e10476c52
Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents:
25146
diff
changeset
|
210 tune = purple_presence_get_status(p, "tune"); |
6d6e10476c52
Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents:
25146
diff
changeset
|
211 if (js->googletalk && !stripped && purple_status_is_active(tune)) { |
23429
146d16459cda
make googletalk tune hack work, previously it's not doing anything unless
Ka-Hing Cheung <khc@hxbc.us>
parents:
23260
diff
changeset
|
212 stripped = jabber_google_presence_outgoing(tune); |
146d16459cda
make googletalk tune hack work, previously it's not doing anything unless
Ka-Hing Cheung <khc@hxbc.us>
parents:
23260
diff
changeset
|
213 } |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24721
diff
changeset
|
214 |
17866
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
215 #define CHANGED(a,b) ((!a && b) || (a && a[0] == '\0' && b && b[0] != '\0') || \ |
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
216 (a && !b) || (a && a[0] != '\0' && b && b[0] == '\0') || (a && b && strcmp(a,b))) |
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
217 /* check if there are any differences to the <presence> and send them in that case */ |
25147
6d6e10476c52
Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents:
25146
diff
changeset
|
218 if (force || allowBuzz != js->allowBuzz || js->old_state != state || |
6d6e10476c52
Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents:
25146
diff
changeset
|
219 CHANGED(js->old_msg, stripped) || js->old_priority != priority || |
26735
3912f55a1633
propagate from branch 'im.pidgin.pidgin' (head fbb4fe5da444943eecc76bdcd6c8ba967790b6c8)
Paul Aurich <paul@darkrain42.org>
diff
changeset
|
220 CHANGED(js->old_avatarhash, js->avatar_hash) || js->old_idle != js->idle) { |
25147
6d6e10476c52
Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents:
25146
diff
changeset
|
221 /* Need to update allowBuzz before creating the presence (with caps) */ |
17890
935005186312
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17882
diff
changeset
|
222 js->allowBuzz = allowBuzz; |
20571
c97e3ab9ef11
Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents:
20570
diff
changeset
|
223 |
17866
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
224 presence = jabber_presence_create_js(js, state, stripped, priority); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
225 |
25425
0fa91206cf5a
Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <paul@darkrain42.org>
parents:
24721
diff
changeset
|
226 /* Per XEP-0153 4.1, we must always send the <x> */ |
0fa91206cf5a
Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <paul@darkrain42.org>
parents:
24721
diff
changeset
|
227 x = xmlnode_new_child(presence, "x"); |
0fa91206cf5a
Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <paul@darkrain42.org>
parents:
24721
diff
changeset
|
228 xmlnode_set_namespace(x, "vcard-temp:x:update"); |
0fa91206cf5a
Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <paul@darkrain42.org>
parents:
24721
diff
changeset
|
229 /* |
0fa91206cf5a
Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <paul@darkrain42.org>
parents:
24721
diff
changeset
|
230 * FIXME: Per XEP-0153 4.3.2 bullet 2, we must not publish our |
0fa91206cf5a
Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <paul@darkrain42.org>
parents:
24721
diff
changeset
|
231 * image hash if another resource has logged in and updated the |
0fa91206cf5a
Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <paul@darkrain42.org>
parents:
24721
diff
changeset
|
232 * vcard avatar. Requires changes in jabber_presence_parse. |
0fa91206cf5a
Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <paul@darkrain42.org>
parents:
24721
diff
changeset
|
233 */ |
0fa91206cf5a
Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <paul@darkrain42.org>
parents:
24721
diff
changeset
|
234 if (js->vcard_fetched) { |
0fa91206cf5a
Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <paul@darkrain42.org>
parents:
24721
diff
changeset
|
235 /* Always publish a <photo>; it's empty if we have no image. */ |
17866
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
236 photo = xmlnode_new_child(x, "photo"); |
25425
0fa91206cf5a
Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <paul@darkrain42.org>
parents:
24721
diff
changeset
|
237 if (js->avatar_hash) |
0fa91206cf5a
Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <paul@darkrain42.org>
parents:
24721
diff
changeset
|
238 xmlnode_insert_data(photo, js->avatar_hash, -1); |
17866
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
239 } |
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
240 |
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
241 jabber_send(js, presence); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
242 |
17866
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
243 g_hash_table_foreach(js->chats, chats_send_presence_foreach, presence); |
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
244 xmlnode_free(presence); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24721
diff
changeset
|
245 |
17866
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
246 /* update old values */ |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24721
diff
changeset
|
247 |
17866
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
248 if(js->old_msg) |
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
249 g_free(js->old_msg); |
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
250 if(js->old_avatarhash) |
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
251 g_free(js->old_avatarhash); |
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
252 js->old_msg = g_strdup(stripped); |
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
253 js->old_avatarhash = g_strdup(js->avatar_hash); |
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
254 js->old_state = state; |
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
255 js->old_priority = priority; |
25228 | 256 js->old_idle = js->idle; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
257 } |
23430
74960bf43dae
let's not leak if nothing is changed
Ka-Hing Cheung <khc@hxbc.us>
parents:
23429
diff
changeset
|
258 g_free(stripped); |
74960bf43dae
let's not leak if nothing is changed
Ka-Hing Cheung <khc@hxbc.us>
parents:
23429
diff
changeset
|
259 |
17866
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
260 /* next, check if there are any changes to the tune values */ |
25147
6d6e10476c52
Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents:
25146
diff
changeset
|
261 if (purple_status_is_active(tune)) { |
20570
5913725cbcd6
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20058
diff
changeset
|
262 artist = purple_status_get_attr_string(tune, PURPLE_TUNE_ARTIST); |
5913725cbcd6
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20058
diff
changeset
|
263 title = purple_status_get_attr_string(tune, PURPLE_TUNE_TITLE); |
5913725cbcd6
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20058
diff
changeset
|
264 source = purple_status_get_attr_string(tune, PURPLE_TUNE_ALBUM); |
5913725cbcd6
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20058
diff
changeset
|
265 uri = purple_status_get_attr_string(tune, PURPLE_TUNE_URL); |
5913725cbcd6
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20058
diff
changeset
|
266 track = purple_status_get_attr_string(tune, PURPLE_TUNE_TRACK); |
5913725cbcd6
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20058
diff
changeset
|
267 length = (!purple_status_get_attr_value(tune, PURPLE_TUNE_TIME)) ? -1 : |
5913725cbcd6
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20058
diff
changeset
|
268 purple_status_get_attr_int(tune, PURPLE_TUNE_TIME); |
5913725cbcd6
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20058
diff
changeset
|
269 } |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24721
diff
changeset
|
270 |
17866
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
271 if(CHANGED(artist, js->old_artist) || CHANGED(title, js->old_title) || CHANGED(source, js->old_source) || |
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
272 CHANGED(uri, js->old_uri) || CHANGED(track, js->old_track) || (length != js->old_length)) { |
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
273 PurpleJabberTuneInfo tuneinfo = { |
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
274 (char*)artist, |
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
275 (char*)title, |
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
276 (char*)source, |
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
277 (char*)track, |
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
278 length, |
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
279 (char*)uri |
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
280 }; |
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
281 jabber_tune_set(js->gc, &tuneinfo); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24721
diff
changeset
|
282 |
17866
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
283 /* update old values */ |
20058
5103485b4b26
Plug some memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19699
diff
changeset
|
284 g_free(js->old_artist); |
5103485b4b26
Plug some memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19699
diff
changeset
|
285 g_free(js->old_title); |
5103485b4b26
Plug some memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19699
diff
changeset
|
286 g_free(js->old_source); |
5103485b4b26
Plug some memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19699
diff
changeset
|
287 g_free(js->old_uri); |
5103485b4b26
Plug some memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19699
diff
changeset
|
288 g_free(js->old_track); |
17866
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
289 js->old_artist = g_strdup(artist); |
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
290 js->old_title = g_strdup(title); |
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
291 js->old_source = g_strdup(source); |
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
292 js->old_uri = g_strdup(uri); |
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
293 js->old_length = length; |
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
294 js->old_track = g_strdup(track); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
295 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
296 |
19699
680a3aea5eb6
Various warning fixes for the xmpp prpl.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19697
diff
changeset
|
297 #undef CHANGED |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
298 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
299 jabber_presence_fake_to_self(js, status); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
300 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
301 |
17836
95affacf6f82
Added the ability to define extensions to caps
Andreas Monitzer <pidgin@monitzer.com>
parents:
17363
diff
changeset
|
302 xmlnode *jabber_presence_create_js(JabberStream *js, JabberBuddyState state, const char *msg, int priority) |
95affacf6f82
Added the ability to define extensions to caps
Andreas Monitzer <pidgin@monitzer.com>
parents:
17363
diff
changeset
|
303 { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
304 xmlnode *show, *status, *presence, *pri, *c; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
305 const char *show_string = NULL; |
27088
5330ffe6ca86
Fix compile warning for non-VV.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26997
diff
changeset
|
306 #ifdef USE_VV |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26932
diff
changeset
|
307 gboolean audio_enabled, video_enabled; |
27088
5330ffe6ca86
Fix compile warning for non-VV.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26997
diff
changeset
|
308 #endif |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
309 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
310 presence = xmlnode_new("presence"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
311 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
312 if(state == JABBER_BUDDY_STATE_UNAVAILABLE) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
313 xmlnode_set_attrib(presence, "type", "unavailable"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
314 else if(state != JABBER_BUDDY_STATE_ONLINE && |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
315 state != JABBER_BUDDY_STATE_UNKNOWN && |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
316 state != JABBER_BUDDY_STATE_ERROR) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
317 show_string = jabber_buddy_state_get_show(state); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
318 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
319 if(show_string) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
320 show = xmlnode_new_child(presence, "show"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
321 xmlnode_insert_data(show, show_string, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
322 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
323 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
324 if(msg) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
325 status = xmlnode_new_child(presence, "status"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
326 xmlnode_insert_data(status, msg, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
327 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
328 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
329 if(priority) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
330 char *pstr = g_strdup_printf("%d", priority); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
331 pri = xmlnode_new_child(presence, "priority"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
332 xmlnode_insert_data(pri, pstr, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
333 g_free(pstr); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
334 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
335 |
25228 | 336 /* if we are idle and not offline, include idle */ |
337 if (js->idle && state != JABBER_BUDDY_STATE_UNAVAILABLE) { | |
338 xmlnode *query = xmlnode_new_child(presence, "query"); | |
339 gchar seconds[10]; | |
340 g_snprintf(seconds, 10, "%d", (int) (time(NULL) - js->idle)); | |
26932
a8537bbcfb79
Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents:
26920
diff
changeset
|
341 |
28650
9ae3e70a327b
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents:
28517
diff
changeset
|
342 xmlnode_set_namespace(query, NS_LAST_ACTIVITY); |
25228 | 343 xmlnode_set_attrib(query, "seconds", seconds); |
344 } | |
26735
3912f55a1633
propagate from branch 'im.pidgin.pidgin' (head fbb4fe5da444943eecc76bdcd6c8ba967790b6c8)
Paul Aurich <paul@darkrain42.org>
diff
changeset
|
345 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
346 /* JEP-0115 */ |
25026
e61603ab10c6
* correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents:
25022
diff
changeset
|
347 /* calculate hash */ |
e61603ab10c6
* correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents:
25022
diff
changeset
|
348 jabber_caps_calculate_own_hash(js); |
e61603ab10c6
* correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents:
25022
diff
changeset
|
349 /* create xml */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
350 c = xmlnode_new_child(presence, "c"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
351 xmlnode_set_namespace(c, "http://jabber.org/protocol/caps"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
352 xmlnode_set_attrib(c, "node", CAPS0115_NODE); |
25017
26eabe8e739b
Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23260
diff
changeset
|
353 xmlnode_set_attrib(c, "hash", "sha-1"); |
25146
4040da08a733
Entity Capabilities must be per-JabberStream
Paul Aurich <paul@darkrain42.org>
parents:
25124
diff
changeset
|
354 xmlnode_set_attrib(c, "ver", jabber_caps_get_own_hash(js)); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24721
diff
changeset
|
355 |
26457
20743d9bd62d
Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <paul@darkrain42.org>
parents:
26446
diff
changeset
|
356 #ifdef USE_VV |
20743d9bd62d
Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <paul@darkrain42.org>
parents:
26446
diff
changeset
|
357 /* |
20743d9bd62d
Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <paul@darkrain42.org>
parents:
26446
diff
changeset
|
358 * MASSIVE HUGE DISGUSTING HACK |
20743d9bd62d
Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <paul@darkrain42.org>
parents:
26446
diff
changeset
|
359 * This is a huge hack. As far as I can tell, Google Talk's gmail client |
20743d9bd62d
Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <paul@darkrain42.org>
parents:
26446
diff
changeset
|
360 * doesn't bother to check the actual features we advertise; they |
26463
b01e8e76c59d
Make my comment parse correctly.
Paul Aurich <paul@darkrain42.org>
parents:
26457
diff
changeset
|
361 * just assume that if we specify a 'voice-v1' ext (ignoring that |
b01e8e76c59d
Make my comment parse correctly.
Paul Aurich <paul@darkrain42.org>
parents:
26457
diff
changeset
|
362 * these are to be assigned no semantic value), we support receiving voice |
b01e8e76c59d
Make my comment parse correctly.
Paul Aurich <paul@darkrain42.org>
parents:
26457
diff
changeset
|
363 * calls. |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26932
diff
changeset
|
364 * |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26932
diff
changeset
|
365 * Ditto for 'video-v1'. |
26457
20743d9bd62d
Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <paul@darkrain42.org>
parents:
26446
diff
changeset
|
366 */ |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26932
diff
changeset
|
367 audio_enabled = jabber_audio_enabled(js, NULL /* unused */); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26932
diff
changeset
|
368 video_enabled = jabber_video_enabled(js, NULL /* unused */); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26932
diff
changeset
|
369 |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26932
diff
changeset
|
370 if (audio_enabled && video_enabled) |
27742
49cb3fc2c01a
Add the camera-v1 cap or else Gmail refuses to accept we're video enabled.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
27699
diff
changeset
|
371 xmlnode_set_attrib(c, "ext", "voice-v1 camera-v1 video-v1"); |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26932
diff
changeset
|
372 else if (audio_enabled) |
26457
20743d9bd62d
Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <paul@darkrain42.org>
parents:
26446
diff
changeset
|
373 xmlnode_set_attrib(c, "ext", "voice-v1"); |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26932
diff
changeset
|
374 else if (video_enabled) |
27742
49cb3fc2c01a
Add the camera-v1 cap or else Gmail refuses to accept we're video enabled.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
27699
diff
changeset
|
375 xmlnode_set_attrib(c, "ext", "camera-v1 video-v1"); |
26457
20743d9bd62d
Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <paul@darkrain42.org>
parents:
26446
diff
changeset
|
376 #endif |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24721
diff
changeset
|
377 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
378 return presence; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
379 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
380 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
381 struct _jabber_add_permit { |
15822 | 382 PurpleConnection *gc; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
383 JabberStream *js; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
384 char *who; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
385 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
386 |
19195
1ca6c4b234ab
Warning fixes in the aftermath of resiak's authorize_cb and deny_cb type fixing.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18739
diff
changeset
|
387 static void authorize_add_cb(gpointer data) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
388 { |
19195
1ca6c4b234ab
Warning fixes in the aftermath of resiak's authorize_cb and deny_cb type fixing.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18739
diff
changeset
|
389 struct _jabber_add_permit *jap = data; |
21602
53fee49ce1c5
Prevent crashing when authorizing or denying after the account is disconnected.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21560
diff
changeset
|
390 if(PURPLE_CONNECTION_IS_VALID(jap->gc)) |
31995
3caef255ad47
Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
andrew.victor@mxit.com
parents:
31542
diff
changeset
|
391 jabber_presence_subscription_set(purple_connection_get_protocol_data(jap->gc), |
21602
53fee49ce1c5
Prevent crashing when authorizing or denying after the account is disconnected.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21560
diff
changeset
|
392 jap->who, "subscribed"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
393 g_free(jap->who); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
394 g_free(jap); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
395 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
396 |
19195
1ca6c4b234ab
Warning fixes in the aftermath of resiak's authorize_cb and deny_cb type fixing.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18739
diff
changeset
|
397 static void deny_add_cb(gpointer data) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
398 { |
19195
1ca6c4b234ab
Warning fixes in the aftermath of resiak's authorize_cb and deny_cb type fixing.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18739
diff
changeset
|
399 struct _jabber_add_permit *jap = data; |
21602
53fee49ce1c5
Prevent crashing when authorizing or denying after the account is disconnected.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21560
diff
changeset
|
400 if(PURPLE_CONNECTION_IS_VALID(jap->gc)) |
31995
3caef255ad47
Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
andrew.victor@mxit.com
parents:
31542
diff
changeset
|
401 jabber_presence_subscription_set(purple_connection_get_protocol_data(jap->gc), |
21602
53fee49ce1c5
Prevent crashing when authorizing or denying after the account is disconnected.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21560
diff
changeset
|
402 jap->who, "unsubscribed"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
403 g_free(jap->who); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
404 g_free(jap); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
405 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
406 |
26465
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25952
diff
changeset
|
407 static void |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25952
diff
changeset
|
408 jabber_vcard_parse_avatar(JabberStream *js, const char *from, |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25952
diff
changeset
|
409 JabberIqType type, const char *id, |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25952
diff
changeset
|
410 xmlnode *packet, gpointer blah) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
411 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
412 JabberBuddy *jb = NULL; |
26780
5c4a4a0f5929
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <paul@darkrain42.org>
parents:
26774
diff
changeset
|
413 xmlnode *vcard, *photo, *binval, *fn, *nick; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
414 char *text; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
415 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
416 if(!from) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
417 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
418 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
419 jb = jabber_buddy_find(js, from, TRUE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
420 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
421 js->pending_avatar_requests = g_slist_remove(js->pending_avatar_requests, jb); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
422 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
423 if((vcard = xmlnode_get_child(packet, "vCard")) || |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
424 (vcard = xmlnode_get_child_with_namespace(packet, "query", "vcard-temp"))) { |
26780
5c4a4a0f5929
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <paul@darkrain42.org>
parents:
26774
diff
changeset
|
425 /* The logic here regarding the nickname and full name is copied from |
5c4a4a0f5929
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <paul@darkrain42.org>
parents:
26774
diff
changeset
|
426 * buddy.c:jabber_vcard_parse. */ |
5c4a4a0f5929
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <paul@darkrain42.org>
parents:
26774
diff
changeset
|
427 gchar *nickname = NULL; |
5c4a4a0f5929
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <paul@darkrain42.org>
parents:
26774
diff
changeset
|
428 if ((fn = xmlnode_get_child(vcard, "FN"))) |
5c4a4a0f5929
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <paul@darkrain42.org>
parents:
26774
diff
changeset
|
429 nickname = xmlnode_get_data(fn); |
5c4a4a0f5929
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <paul@darkrain42.org>
parents:
26774
diff
changeset
|
430 |
5c4a4a0f5929
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <paul@darkrain42.org>
parents:
26774
diff
changeset
|
431 if ((nick = xmlnode_get_child(vcard, "NICKNAME"))) { |
5c4a4a0f5929
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <paul@darkrain42.org>
parents:
26774
diff
changeset
|
432 char *tmp = xmlnode_get_data(nick); |
5c4a4a0f5929
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <paul@darkrain42.org>
parents:
26774
diff
changeset
|
433 char *bare_jid = jabber_get_bare_jid(from); |
26920
c9ac5cc1e46c
Fix a crash when <NICKNAME/> is present in a vcard, but has no data.
Paul Aurich <paul@darkrain42.org>
parents:
26870
diff
changeset
|
434 if (tmp && strstr(bare_jid, tmp) == NULL) { |
26780
5c4a4a0f5929
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <paul@darkrain42.org>
parents:
26774
diff
changeset
|
435 g_free(nickname); |
5c4a4a0f5929
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <paul@darkrain42.org>
parents:
26774
diff
changeset
|
436 nickname = tmp; |
26920
c9ac5cc1e46c
Fix a crash when <NICKNAME/> is present in a vcard, but has no data.
Paul Aurich <paul@darkrain42.org>
parents:
26870
diff
changeset
|
437 } else if (tmp) |
26780
5c4a4a0f5929
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <paul@darkrain42.org>
parents:
26774
diff
changeset
|
438 g_free(tmp); |
5c4a4a0f5929
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <paul@darkrain42.org>
parents:
26774
diff
changeset
|
439 |
5c4a4a0f5929
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <paul@darkrain42.org>
parents:
26774
diff
changeset
|
440 g_free(bare_jid); |
5c4a4a0f5929
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <paul@darkrain42.org>
parents:
26774
diff
changeset
|
441 } |
5c4a4a0f5929
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <paul@darkrain42.org>
parents:
26774
diff
changeset
|
442 |
5c4a4a0f5929
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <paul@darkrain42.org>
parents:
26774
diff
changeset
|
443 if (nickname) { |
5c4a4a0f5929
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <paul@darkrain42.org>
parents:
26774
diff
changeset
|
444 serv_got_alias(js->gc, from, nickname); |
5c4a4a0f5929
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <paul@darkrain42.org>
parents:
26774
diff
changeset
|
445 g_free(nickname); |
5c4a4a0f5929
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <paul@darkrain42.org>
parents:
26774
diff
changeset
|
446 } |
5c4a4a0f5929
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <paul@darkrain42.org>
parents:
26774
diff
changeset
|
447 |
31526
b2f6fec7b98e
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
matthew@bells23.org.uk
parents:
31233
diff
changeset
|
448 if ((photo = xmlnode_get_child(vcard, "PHOTO"))) { |
b2f6fec7b98e
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
matthew@bells23.org.uk
parents:
31233
diff
changeset
|
449 guchar *data = NULL; |
b2f6fec7b98e
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
matthew@bells23.org.uk
parents:
31233
diff
changeset
|
450 gchar *hash = NULL; |
b2f6fec7b98e
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
matthew@bells23.org.uk
parents:
31233
diff
changeset
|
451 gsize size = 0; |
16386
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
15957
diff
changeset
|
452 |
31526
b2f6fec7b98e
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
matthew@bells23.org.uk
parents:
31233
diff
changeset
|
453 if ((binval = xmlnode_get_child(photo, "BINVAL")) && |
b2f6fec7b98e
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
matthew@bells23.org.uk
parents:
31233
diff
changeset
|
454 (text = xmlnode_get_data(binval))) { |
b2f6fec7b98e
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
matthew@bells23.org.uk
parents:
31233
diff
changeset
|
455 data = purple_base64_decode(text, &size); |
b2f6fec7b98e
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
matthew@bells23.org.uk
parents:
31233
diff
changeset
|
456 g_free(text); |
b2f6fec7b98e
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
matthew@bells23.org.uk
parents:
31233
diff
changeset
|
457 |
b2f6fec7b98e
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
matthew@bells23.org.uk
parents:
31233
diff
changeset
|
458 if (data) |
b2f6fec7b98e
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
matthew@bells23.org.uk
parents:
31233
diff
changeset
|
459 hash = jabber_calculate_data_hash(data, size, "sha1"); |
28315
d9eb51a3a3a2
jabber: Don't try to pull a photo out of the <PHOTO/> cdata.
Paul Aurich <paul@darkrain42.org>
parents:
28060
diff
changeset
|
460 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
461 |
32305
2ec94166be43
On the way to hiding the PurpleConnection struct.
andrew.victor@mxit.com
parents:
32217
diff
changeset
|
462 purple_buddy_icons_set_for_user(purple_connection_get_account(js->gc), from, data, size, hash); |
31526
b2f6fec7b98e
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
matthew@bells23.org.uk
parents:
31233
diff
changeset
|
463 |
b2f6fec7b98e
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
matthew@bells23.org.uk
parents:
31233
diff
changeset
|
464 g_free(hash); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
465 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
466 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
467 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
468 |
17882
f88b3a093cba
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 <pidgin@monitzer.com>
parents:
17878
diff
changeset
|
469 typedef struct _JabberPresenceCapabilities { |
f88b3a093cba
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 <pidgin@monitzer.com>
parents:
17878
diff
changeset
|
470 JabberStream *js; |
22781
2404b13940e9
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <mark@kingant.net>
parents:
22486
diff
changeset
|
471 JabberBuddy *jb; |
17882
f88b3a093cba
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 <pidgin@monitzer.com>
parents:
17878
diff
changeset
|
472 char *from; |
f88b3a093cba
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 <pidgin@monitzer.com>
parents:
17878
diff
changeset
|
473 } JabberPresenceCapabilities; |
f88b3a093cba
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 <pidgin@monitzer.com>
parents:
17878
diff
changeset
|
474 |
25189
05693f6885a4
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents:
25187
diff
changeset
|
475 static void |
05693f6885a4
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents:
25187
diff
changeset
|
476 jabber_presence_set_capabilities(JabberCapsClientInfo *info, GList *exts, |
05693f6885a4
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents:
25187
diff
changeset
|
477 JabberPresenceCapabilities *userdata) |
25149
416ff3d65c16
Rewrite jabber_presence_set_capabilities a little
Paul Aurich <paul@darkrain42.org>
parents:
25147
diff
changeset
|
478 { |
22781
2404b13940e9
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <mark@kingant.net>
parents:
22486
diff
changeset
|
479 JabberBuddyResource *jbr; |
28729
4ab6f0479bc5
strchr() is safe when searching for an ASCII character in UTF8 strings.
Paul Aurich <paul@darkrain42.org>
parents:
28674
diff
changeset
|
480 char *resource = strchr(userdata->from, '/'); |
21688
6f4ffdc65230
Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21629
diff
changeset
|
481 |
26842
33f98d662db8
Don't crash when resource is NULL. Thanks, Marcus!
Paul Aurich <paul@darkrain42.org>
parents:
26781
diff
changeset
|
482 if (resource) |
33f98d662db8
Don't crash when resource is NULL. Thanks, Marcus!
Paul Aurich <paul@darkrain42.org>
parents:
26781
diff
changeset
|
483 resource += 1; |
22781
2404b13940e9
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <mark@kingant.net>
parents:
22486
diff
changeset
|
484 |
25149
416ff3d65c16
Rewrite jabber_presence_set_capabilities a little
Paul Aurich <paul@darkrain42.org>
parents:
25147
diff
changeset
|
485 jbr = jabber_buddy_find_resource(userdata->jb, resource); |
416ff3d65c16
Rewrite jabber_presence_set_capabilities a little
Paul Aurich <paul@darkrain42.org>
parents:
25147
diff
changeset
|
486 if (!jbr) { |
22781
2404b13940e9
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <mark@kingant.net>
parents:
22486
diff
changeset
|
487 g_free(userdata->from); |
2404b13940e9
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <mark@kingant.net>
parents:
22486
diff
changeset
|
488 g_free(userdata); |
25189
05693f6885a4
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents:
25187
diff
changeset
|
489 if (exts) { |
05693f6885a4
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents:
25187
diff
changeset
|
490 g_list_foreach(exts, (GFunc)g_free, NULL); |
05693f6885a4
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents:
25187
diff
changeset
|
491 g_list_free(exts); |
05693f6885a4
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents:
25187
diff
changeset
|
492 } |
22781
2404b13940e9
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <mark@kingant.net>
parents:
22486
diff
changeset
|
493 return; |
2404b13940e9
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <mark@kingant.net>
parents:
22486
diff
changeset
|
494 } |
2404b13940e9
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <mark@kingant.net>
parents:
22486
diff
changeset
|
495 |
25191
5ad14a53e266
Partial disapproval of b8fdbd255c614e7305f835b843a3414675a86a19
Paul Aurich <paul@darkrain42.org>
parents:
25189
diff
changeset
|
496 /* Any old jbr->caps.info is owned by the caps code */ |
25189
05693f6885a4
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents:
25187
diff
changeset
|
497 if (jbr->caps.exts) { |
05693f6885a4
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents:
25187
diff
changeset
|
498 g_list_foreach(jbr->caps.exts, (GFunc)g_free, NULL); |
05693f6885a4
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents:
25187
diff
changeset
|
499 g_list_free(jbr->caps.exts); |
05693f6885a4
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents:
25187
diff
changeset
|
500 } |
21688
6f4ffdc65230
Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21629
diff
changeset
|
501 |
25189
05693f6885a4
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents:
25187
diff
changeset
|
502 jbr->caps.info = info; |
05693f6885a4
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents:
25187
diff
changeset
|
503 jbr->caps.exts = exts; |
21688
6f4ffdc65230
Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21629
diff
changeset
|
504 |
29139
8a50c08c289d
Declare XMPP got media caps in the correct place.
maiku@pidgin.im
parents:
29136
diff
changeset
|
505 purple_prpl_got_media_caps( |
8a50c08c289d
Declare XMPP got media caps in the correct place.
maiku@pidgin.im
parents:
29136
diff
changeset
|
506 purple_connection_get_account(userdata->js->gc), |
8a50c08c289d
Declare XMPP got media caps in the correct place.
maiku@pidgin.im
parents:
29136
diff
changeset
|
507 userdata->from); |
27512
ed284238509b
Use Entity Capabilities to pick up Chat States support. Refs #4650.
Paul Aurich <paul@darkrain42.org>
parents:
27509
diff
changeset
|
508 if (info == NULL) |
ed284238509b
Use Entity Capabilities to pick up Chat States support. Refs #4650.
Paul Aurich <paul@darkrain42.org>
parents:
27509
diff
changeset
|
509 goto out; |
ed284238509b
Use Entity Capabilities to pick up Chat States support. Refs #4650.
Paul Aurich <paul@darkrain42.org>
parents:
27509
diff
changeset
|
510 |
26849
e7819fa37224
Only try to fetch adhoc commands from buddies once. Pushed updates (which we support now) are far superior.
Paul Aurich <paul@darkrain42.org>
parents:
26846
diff
changeset
|
511 if (!jbr->commands_fetched && jabber_resource_has_capability(jbr, "http://jabber.org/protocol/commands")) { |
28650
9ae3e70a327b
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents:
28517
diff
changeset
|
512 JabberIq *iq = jabber_iq_new_query(userdata->js, JABBER_IQ_GET, NS_DISCO_ITEMS); |
9ae3e70a327b
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents:
28517
diff
changeset
|
513 xmlnode *query = xmlnode_get_child_with_namespace(iq->node, "query", NS_DISCO_ITEMS); |
25175
b1b1b75a922e
Sprinkle jabber_resource_has_capability in places
Paul Aurich <paul@darkrain42.org>
parents:
25168
diff
changeset
|
514 xmlnode_set_attrib(iq->node, "to", userdata->from); |
b1b1b75a922e
Sprinkle jabber_resource_has_capability in places
Paul Aurich <paul@darkrain42.org>
parents:
25168
diff
changeset
|
515 xmlnode_set_attrib(query, "node", "http://jabber.org/protocol/commands"); |
b1b1b75a922e
Sprinkle jabber_resource_has_capability in places
Paul Aurich <paul@darkrain42.org>
parents:
25168
diff
changeset
|
516 jabber_iq_set_callback(iq, jabber_adhoc_disco_result_cb, NULL); |
b1b1b75a922e
Sprinkle jabber_resource_has_capability in places
Paul Aurich <paul@darkrain42.org>
parents:
25168
diff
changeset
|
517 jabber_iq_send(iq); |
21688
6f4ffdc65230
Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21629
diff
changeset
|
518 |
26849
e7819fa37224
Only try to fetch adhoc commands from buddies once. Pushed updates (which we support now) are far superior.
Paul Aurich <paul@darkrain42.org>
parents:
26846
diff
changeset
|
519 jbr->commands_fetched = TRUE; |
17882
f88b3a093cba
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 <pidgin@monitzer.com>
parents:
17878
diff
changeset
|
520 } |
21688
6f4ffdc65230
Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21629
diff
changeset
|
521 |
28060
faf98a4b27d8
jabber: Fix typing notifications between 2.6.0 and <= 2.5.9.
Paul Aurich <paul@darkrain42.org>
parents:
28048
diff
changeset
|
522 #if 0 |
faf98a4b27d8
jabber: Fix typing notifications between 2.6.0 and <= 2.5.9.
Paul Aurich <paul@darkrain42.org>
parents:
28048
diff
changeset
|
523 /* |
faf98a4b27d8
jabber: Fix typing notifications between 2.6.0 and <= 2.5.9.
Paul Aurich <paul@darkrain42.org>
parents:
28048
diff
changeset
|
524 * Versions of libpurple before 2.6.0 didn't advertise this capability, so |
faf98a4b27d8
jabber: Fix typing notifications between 2.6.0 and <= 2.5.9.
Paul Aurich <paul@darkrain42.org>
parents:
28048
diff
changeset
|
525 * we can't yet use Entity Capabilities to determine whether or not the |
28408 | 526 * other client supports Chat States. |
28060
faf98a4b27d8
jabber: Fix typing notifications between 2.6.0 and <= 2.5.9.
Paul Aurich <paul@darkrain42.org>
parents:
28048
diff
changeset
|
527 */ |
27512
ed284238509b
Use Entity Capabilities to pick up Chat States support. Refs #4650.
Paul Aurich <paul@darkrain42.org>
parents:
27509
diff
changeset
|
528 if (jabber_resource_has_capability(jbr, "http://jabber.org/protocol/chatstates")) |
ed284238509b
Use Entity Capabilities to pick up Chat States support. Refs #4650.
Paul Aurich <paul@darkrain42.org>
parents:
27509
diff
changeset
|
529 jbr->chat_states = JABBER_CHAT_STATES_SUPPORTED; |
ed284238509b
Use Entity Capabilities to pick up Chat States support. Refs #4650.
Paul Aurich <paul@darkrain42.org>
parents:
27509
diff
changeset
|
530 else |
ed284238509b
Use Entity Capabilities to pick up Chat States support. Refs #4650.
Paul Aurich <paul@darkrain42.org>
parents:
27509
diff
changeset
|
531 jbr->chat_states = JABBER_CHAT_STATES_UNSUPPORTED; |
28060
faf98a4b27d8
jabber: Fix typing notifications between 2.6.0 and <= 2.5.9.
Paul Aurich <paul@darkrain42.org>
parents:
28048
diff
changeset
|
532 #endif |
27512
ed284238509b
Use Entity Capabilities to pick up Chat States support. Refs #4650.
Paul Aurich <paul@darkrain42.org>
parents:
27509
diff
changeset
|
533 |
ed284238509b
Use Entity Capabilities to pick up Chat States support. Refs #4650.
Paul Aurich <paul@darkrain42.org>
parents:
27509
diff
changeset
|
534 out: |
20318
bbfe52e817cf
applied changes from d50ecf4dc52f25cbd219d6c19846436dec5a8853
Luke Schierer <lschiere@pidgin.im>
parents:
20058
diff
changeset
|
535 g_free(userdata->from); |
bbfe52e817cf
applied changes from d50ecf4dc52f25cbd219d6c19846436dec5a8853
Luke Schierer <lschiere@pidgin.im>
parents:
20058
diff
changeset
|
536 g_free(userdata); |
17882
f88b3a093cba
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 <pidgin@monitzer.com>
parents:
17878
diff
changeset
|
537 } |
f88b3a093cba
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 <pidgin@monitzer.com>
parents:
17878
diff
changeset
|
538 |
29605
ffc1f997cb91
jabber: Fix two warnings (which didn't occur on OS X, oddly)
Paul Aurich <paul@darkrain42.org>
parents:
29560
diff
changeset
|
539 static gboolean |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
540 handle_presence_chat(JabberStream *js, JabberPresence *presence, xmlnode *packet) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
541 { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
542 static int i = 1; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
543 PurpleConvChatBuddyFlags flags = PURPLE_CBFLAGS_NONE; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
544 JabberChat *chat = presence->chat; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
545 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
546 if (presence->state == JABBER_BUDDY_STATE_ERROR) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
547 char *title, *msg = jabber_parse_error(js, packet, NULL); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
548 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
549 if (!chat->conv) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
550 title = g_strdup_printf(_("Error joining chat %s"), presence->from); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
551 purple_serv_got_join_chat_failed(js->gc, chat->components); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
552 } else { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
553 title = g_strdup_printf(_("Error in chat %s"), presence->from); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
554 if (g_hash_table_size(chat->members) == 0) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
555 serv_got_chat_left(js->gc, chat->id); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
556 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
557 purple_notify_error(js->gc, title, title, msg); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
558 g_free(title); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
559 g_free(msg); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
560 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
561 if (g_hash_table_size(chat->members) == 0) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
562 /* Only destroy the chat if the error happened while joining */ |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
563 jabber_chat_destroy(chat); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
564 return FALSE; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
565 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
566 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
567 if (presence->type == JABBER_PRESENCE_AVAILABLE) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
568 const char *jid = NULL; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
569 const char *affiliation = NULL; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
570 const char *role = NULL; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
571 gboolean is_our_resource = FALSE; /* Is the presence about us? */ |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
572 JabberBuddyResource *jbr; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
573 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
574 /* |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
575 * XEP-0045 mandates the presence to include a resource (which is |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
576 * treated as the chat nick). Some non-compliant servers allow |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
577 * joining without a nick. |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
578 */ |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
579 if (!presence->jid_from->resource) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
580 return FALSE; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
581 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
582 if (presence->chat_info.item) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
583 jid = xmlnode_get_attrib(presence->chat_info.item, "jid"); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
584 affiliation = xmlnode_get_attrib(presence->chat_info.item, "affiliation"); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
585 role = xmlnode_get_attrib(presence->chat_info.item, "role"); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
586 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
587 |
31233
58d9bcd75866
jabber: Compatibility with older servers
Paul Aurich <paul@darkrain42.org>
parents:
31230
diff
changeset
|
588 if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(110)) || |
58d9bcd75866
jabber: Compatibility with older servers
Paul Aurich <paul@darkrain42.org>
parents:
31230
diff
changeset
|
589 g_str_equal(presence->jid_from->resource, chat->handle) || |
58d9bcd75866
jabber: Compatibility with older servers
Paul Aurich <paul@darkrain42.org>
parents:
31230
diff
changeset
|
590 purple_strequal(presence->to, jid)) |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
591 is_our_resource = TRUE; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
592 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
593 if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(201))) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
594 chat->config_dialog_type = PURPLE_REQUEST_ACTION; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
595 chat->config_dialog_handle = |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
596 purple_request_action(js->gc, |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
597 _("Create New Room"), |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
598 _("Create New Room"), |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
599 _("You are creating a new room. Would" |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
600 " you like to configure it, or" |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
601 " accept the default settings?"), |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
602 /* Default Action */ 1, |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
603 purple_connection_get_account(js->gc), NULL, chat->conv, |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
604 chat, 2, |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
605 _("_Configure Room"), G_CALLBACK(jabber_chat_request_room_configure), |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
606 _("_Accept Defaults"), G_CALLBACK(jabber_chat_create_instant_room)); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
607 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
608 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
609 if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(210))) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
610 /* server rewrote room-nick */ |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
611 g_free(chat->handle); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
612 chat->handle = g_strdup(presence->jid_from->resource); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
613 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
614 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
615 if (purple_strequal(affiliation, "owner")) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
616 flags |= PURPLE_CBFLAGS_FOUNDER; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
617 if (role) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
618 if (g_str_equal(role, "moderator")) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
619 flags |= PURPLE_CBFLAGS_OP; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
620 else if (g_str_equal(role, "participant")) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
621 flags |= PURPLE_CBFLAGS_VOICE; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
622 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
623 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
624 if(!chat->conv) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
625 char *room_jid = g_strdup_printf("%s@%s", presence->jid_from->node, presence->jid_from->domain); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
626 chat->id = i++; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
627 chat->conv = serv_got_joined_chat(js->gc, chat->id, room_jid); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
628 purple_conv_chat_set_nick(PURPLE_CONV_CHAT(chat->conv), chat->handle); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
629 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
630 jabber_chat_disco_traffic(chat); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
631 g_free(room_jid); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
632 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
633 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
634 jbr = jabber_buddy_track_resource(presence->jb, presence->jid_from->resource, presence->priority, presence->state, presence->status); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
635 jbr->commands_fetched = TRUE; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
636 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
637 jabber_chat_track_handle(chat, presence->jid_from->resource, jid, affiliation, role); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
638 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
639 if(!jabber_chat_find_buddy(chat->conv, presence->jid_from->resource)) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
640 purple_conv_chat_add_user(PURPLE_CONV_CHAT(chat->conv), presence->jid_from->resource, |
31230
ba6a4a0f8f50
jabber: Treat the presence storm on joining a room as not new arrivals.
thijs@adium.im
parents:
31229
diff
changeset
|
641 jid, flags, chat->joined > 0 && ((!presence->delayed) || (presence->sent > chat->joined))); |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
642 else |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
643 purple_conv_chat_user_set_flags(PURPLE_CONV_CHAT(chat->conv), presence->jid_from->resource, |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
644 flags); |
31230
ba6a4a0f8f50
jabber: Treat the presence storm on joining a room as not new arrivals.
thijs@adium.im
parents:
31229
diff
changeset
|
645 |
ba6a4a0f8f50
jabber: Treat the presence storm on joining a room as not new arrivals.
thijs@adium.im
parents:
31229
diff
changeset
|
646 if (is_our_resource && chat->joined == 0) |
ba6a4a0f8f50
jabber: Treat the presence storm on joining a room as not new arrivals.
thijs@adium.im
parents:
31229
diff
changeset
|
647 chat->joined = time(NULL); |
ba6a4a0f8f50
jabber: Treat the presence storm on joining a room as not new arrivals.
thijs@adium.im
parents:
31229
diff
changeset
|
648 |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
649 } else if (presence->type == JABBER_PRESENCE_UNAVAILABLE) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
650 gboolean nick_change = FALSE; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
651 gboolean kick = FALSE; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
652 gboolean is_our_resource = FALSE; /* Is the presence about us? */ |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
653 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
654 const char *jid = NULL; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
655 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
656 /* If the chat nick is invalid, we haven't yet joined, or we've |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
657 * already left (it was probably us leaving after we closed the |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
658 * chat), we don't care. |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
659 */ |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
660 if (!presence->jid_from->resource || !chat->conv || chat->left) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
661 if (chat->left && |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
662 presence->jid_from->resource && chat->handle && !strcmp(presence->jid_from->resource, chat->handle)) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
663 jabber_chat_destroy(chat); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
664 return FALSE; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
665 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
666 |
31229
05c45d8f2ce3
jabber: Use a straight equality check instead of collate
Paul Aurich <paul@darkrain42.org>
parents:
30897
diff
changeset
|
667 is_our_resource = g_str_equal(presence->jid_from->resource, chat->handle); |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
668 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
669 jabber_buddy_remove_resource(presence->jb, presence->jid_from->resource); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
670 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
671 if (presence->chat_info.item) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
672 jid = xmlnode_get_attrib(presence->chat_info.item, "jid"); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
673 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
674 if (chat->muc) { |
31230
ba6a4a0f8f50
jabber: Treat the presence storm on joining a room as not new arrivals.
thijs@adium.im
parents:
31229
diff
changeset
|
675 if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(110))) { |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
676 is_our_resource = TRUE; |
31230
ba6a4a0f8f50
jabber: Treat the presence storm on joining a room as not new arrivals.
thijs@adium.im
parents:
31229
diff
changeset
|
677 chat->joined = 0; |
ba6a4a0f8f50
jabber: Treat the presence storm on joining a room as not new arrivals.
thijs@adium.im
parents:
31229
diff
changeset
|
678 } |
29623
40fee5f86bf8
jabber: Proper memory management (and fix a segfault) and whitespace
Paul Aurich <paul@darkrain42.org>
parents:
29605
diff
changeset
|
679 |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
680 if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(301))) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
681 /* XXX: We got banned. YAY! (No GIR, that's bad) */ |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
682 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
683 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
684 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
685 if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(303))) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
686 const char *nick = NULL; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
687 if (presence->chat_info.item) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
688 nick = xmlnode_get_attrib(presence->chat_info.item, "nick"); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
689 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
690 /* nick change */ |
29661
b0f8dcab7b43
jabber: Whoops. Nick changes are supposed to actually work...
Paul Aurich <paul@darkrain42.org>
parents:
29630
diff
changeset
|
691 if (!nick) { |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
692 purple_debug_warning("jabber", "Chat presence indicating a nick change, but no new nickname!\n"); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
693 } else { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
694 nick_change = TRUE; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
695 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
696 if (g_str_equal(presence->jid_from->resource, chat->handle)) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
697 /* Changing our own nickname */ |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
698 g_free(chat->handle); |
31229
05c45d8f2ce3
jabber: Use a straight equality check instead of collate
Paul Aurich <paul@darkrain42.org>
parents:
30897
diff
changeset
|
699 /* TODO: This should be resourceprep'd */ |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
700 chat->handle = g_strdup(nick); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
701 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
702 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
703 purple_conv_chat_rename_user(PURPLE_CONV_CHAT(chat->conv), |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
704 presence->jid_from->resource, |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
705 nick); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
706 jabber_chat_remove_handle(chat, |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
707 presence->jid_from->resource); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
708 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
709 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
710 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
711 if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(307))) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
712 /* Someone was kicked from the room */ |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
713 const char *actor = NULL; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
714 char *reason = NULL; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
715 char *tmp; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
716 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
717 kick = TRUE; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
718 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
719 if (presence->chat_info.item) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
720 xmlnode *node; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
721 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
722 node = xmlnode_get_child(presence->chat_info.item, "actor"); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
723 if (node) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
724 actor = xmlnode_get_attrib(node, "jid"); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
725 node = xmlnode_get_child(presence->chat_info.item, "reason"); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
726 if (node) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
727 reason = xmlnode_get_data(node); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
728 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
729 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
730 if (reason == NULL) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
731 reason = g_strdup(_("No reason")); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
732 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
733 if (is_our_resource) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
734 if (actor) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
735 tmp = g_strdup_printf(_("You have been kicked by %s: (%s)"), |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
736 actor, reason); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
737 else |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
738 tmp = g_strdup_printf(_("You have been kicked: (%s)"), |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
739 reason); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
740 } else { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
741 if (actor) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
742 tmp = g_strdup_printf(_("Kicked by %s (%s)"), |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
743 actor, reason); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
744 else |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
745 tmp = g_strdup_printf(_("Kicked (%s)"), |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
746 reason); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
747 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
748 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
749 g_free(presence->status); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
750 presence->status = tmp; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
751 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
752 g_free(reason); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
753 } |
29623
40fee5f86bf8
jabber: Proper memory management (and fix a segfault) and whitespace
Paul Aurich <paul@darkrain42.org>
parents:
29605
diff
changeset
|
754 |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
755 if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(321))) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
756 /* XXX: removed due to an affiliation change */ |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
757 } |
29623
40fee5f86bf8
jabber: Proper memory management (and fix a segfault) and whitespace
Paul Aurich <paul@darkrain42.org>
parents:
29605
diff
changeset
|
758 |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
759 if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(322))) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
760 /* XXX: removed because room is now members-only */ |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
761 } |
29623
40fee5f86bf8
jabber: Proper memory management (and fix a segfault) and whitespace
Paul Aurich <paul@darkrain42.org>
parents:
29605
diff
changeset
|
762 |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
763 if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(332))) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
764 /* XXX: removed due to system shutdown */ |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
765 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
766 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
767 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
768 /* |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
769 * Possibly another connected resource of our JID (see XEP-0045 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
770 * v1.24 section 7.1.10) being disconnected. Should be |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
771 * distinguished by the item_jid. |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
772 * Also possibly works around bits of an Openfire bug. See |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
773 * #8319. |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
774 */ |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
775 if (is_our_resource && jid && !purple_strequal(presence->to, jid)) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
776 /* TODO: When the above is a loop, this needs to still act |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
777 * sanely for all cases (this code is a little fragile). */ |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
778 if (!kick && !nick_change) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
779 /* Presumably, kicks and nick changes also affect us. */ |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
780 is_our_resource = FALSE; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
781 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
782 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
783 if(!nick_change) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
784 if (is_our_resource) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
785 if (kick) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
786 purple_conv_chat_write(PURPLE_CONV_CHAT(chat->conv), presence->jid_from->resource, |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
787 presence->status, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
788 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
789 serv_got_chat_left(js->gc, chat->id); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
790 jabber_chat_destroy(chat); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
791 } else { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
792 purple_conv_chat_remove_user(PURPLE_CONV_CHAT(chat->conv), presence->jid_from->resource, |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
793 presence->status); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
794 jabber_chat_remove_handle(chat, presence->jid_from->resource); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
795 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
796 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
797 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
798 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
799 return TRUE; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
800 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
801 |
29605
ffc1f997cb91
jabber: Fix two warnings (which didn't occur on OS X, oddly)
Paul Aurich <paul@darkrain42.org>
parents:
29560
diff
changeset
|
802 static gboolean |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
803 handle_presence_contact(JabberStream *js, JabberPresence *presence) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
804 { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
805 JabberBuddyResource *jbr; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
806 PurpleAccount *account; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
807 PurpleBuddy *b; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
808 char *buddy_name; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
809 PurpleConversation *conv; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
810 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
811 buddy_name = jabber_id_get_bare_jid(presence->jid_from); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
812 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
813 account = purple_connection_get_account(js->gc); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
814 b = purple_find_buddy(account, buddy_name); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
815 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
816 /* |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
817 * Unbind/unlock from sending messages to a specific resource on |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
818 * presence changes. This is locked to a specific resource when |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
819 * receiving a message (in message.c). |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
820 */ |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
821 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
822 buddy_name, account); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
823 if (conv) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
824 purple_debug_info("jabber", "Changed conversation binding from %s to %s\n", |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
825 purple_conversation_get_name(conv), buddy_name); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
826 purple_conversation_set_name(conv, buddy_name); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
827 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
828 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
829 if (b == NULL) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
830 if (presence->jb != js->user_jb) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
831 purple_debug_warning("jabber", "Got presence for unknown buddy %s on account %s (%p)\n", |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
832 buddy_name, purple_account_get_username(account), account); |
29758
21285007d703
jabber: Don't leak the buddy_name on this error
Paul Aurich <paul@darkrain42.org>
parents:
29661
diff
changeset
|
833 g_free(buddy_name); |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
834 return FALSE; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
835 } else { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
836 /* this is a different resource of our own account. Resume even when this account isn't on our blist */ |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
837 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
838 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
839 |
31526
b2f6fec7b98e
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
matthew@bells23.org.uk
parents:
31233
diff
changeset
|
840 if (b && presence->vcard_avatar_hash) { |
b2f6fec7b98e
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
matthew@bells23.org.uk
parents:
31233
diff
changeset
|
841 const char *ah = presence->vcard_avatar_hash[0] != '\0' ? |
b2f6fec7b98e
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
matthew@bells23.org.uk
parents:
31233
diff
changeset
|
842 presence->vcard_avatar_hash : NULL; |
b2f6fec7b98e
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
matthew@bells23.org.uk
parents:
31233
diff
changeset
|
843 const char *ah2 = purple_buddy_icons_get_checksum_for_user(b); |
b2f6fec7b98e
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
matthew@bells23.org.uk
parents:
31233
diff
changeset
|
844 if (!purple_strequal(ah, ah2)) { |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
845 /* XXX this is a crappy way of trying to prevent |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
846 * someone from spamming us with presence packets |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
847 * and causing us to DoS ourselves...what we really |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
848 * need is a queue system that can throttle itself, |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
849 * but i'm too tired to write that right now */ |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
850 if(!g_slist_find(js->pending_avatar_requests, presence->jb)) { |
31526
b2f6fec7b98e
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
matthew@bells23.org.uk
parents:
31233
diff
changeset
|
851 JabberIq *iq; |
b2f6fec7b98e
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
matthew@bells23.org.uk
parents:
31233
diff
changeset
|
852 xmlnode *vcard; |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
853 |
31526
b2f6fec7b98e
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
matthew@bells23.org.uk
parents:
31233
diff
changeset
|
854 js->pending_avatar_requests = |
b2f6fec7b98e
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
matthew@bells23.org.uk
parents:
31233
diff
changeset
|
855 g_slist_prepend(js->pending_avatar_requests, presence->jb); |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
856 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
857 iq = jabber_iq_new(js, JABBER_IQ_GET); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
858 xmlnode_set_attrib(iq->node, "to", buddy_name); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
859 vcard = xmlnode_new_child(iq->node, "vCard"); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
860 xmlnode_set_namespace(vcard, "vcard-temp"); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
861 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
862 jabber_iq_set_callback(iq, jabber_vcard_parse_avatar, NULL); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
863 jabber_iq_send(iq); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
864 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
865 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
866 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
867 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
868 if (presence->state == JABBER_BUDDY_STATE_ERROR || |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
869 presence->type == JABBER_PRESENCE_UNAVAILABLE || |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
870 presence->type == JABBER_PRESENCE_UNSUBSCRIBED) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
871 jabber_buddy_remove_resource(presence->jb, presence->jid_from->resource); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
872 } else { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
873 jbr = jabber_buddy_track_resource(presence->jb, |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
874 presence->jid_from->resource, presence->priority, |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
875 presence->state, presence->status); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
876 jbr->idle = presence->idle ? time(NULL) - presence->idle : 0; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
877 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
878 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
879 jbr = jabber_buddy_find_resource(presence->jb, NULL); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
880 if (jbr) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
881 jabber_google_presence_incoming(js, buddy_name, jbr); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
882 purple_prpl_got_user_status(account, buddy_name, |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
883 jabber_buddy_state_get_status_id(jbr->state), |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
884 "priority", jbr->priority, |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
885 "message", jbr->status, |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
886 NULL); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
887 purple_prpl_got_user_idle(account, buddy_name, |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
888 jbr->idle, jbr->idle); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
889 if (presence->nickname) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
890 serv_got_alias(js->gc, buddy_name, presence->nickname); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
891 } else { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
892 purple_prpl_got_user_status(account, buddy_name, |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
893 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_UNAVAILABLE), |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
894 presence->status ? "message" : NULL, presence->status, |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
895 NULL); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
896 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
897 g_free(buddy_name); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
898 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
899 return TRUE; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
900 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
901 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
902 void jabber_presence_parse(JabberStream *js, xmlnode *packet) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
903 { |
26870
92565c8e1e3a
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 <paul@darkrain42.org>
parents:
26849
diff
changeset
|
904 const char *type; |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
905 JabberBuddyResource *jbr = NULL; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
906 gboolean signal_return, ret; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
907 JabberPresence presence; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
908 xmlnode *child; |
26870
92565c8e1e3a
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 <paul@darkrain42.org>
parents:
26849
diff
changeset
|
909 |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
910 memset(&presence, 0, sizeof(presence)); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
911 /* defaults */ |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
912 presence.state = JABBER_BUDDY_STATE_UNKNOWN; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
913 presence.sent = time(NULL); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
914 /* interesting values */ |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
915 presence.from = xmlnode_get_attrib(packet, "from"); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
916 presence.to = xmlnode_get_attrib(packet, "to"); |
26870
92565c8e1e3a
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 <paul@darkrain42.org>
parents:
26849
diff
changeset
|
917 type = xmlnode_get_attrib(packet, "type"); |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
918 presence.type = str_to_presence_type(type); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
919 |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
920 presence.jb = jabber_buddy_find(js, presence.from, TRUE); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
921 g_return_if_fail(presence.jb != NULL); |
26870
92565c8e1e3a
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 <paul@darkrain42.org>
parents:
26849
diff
changeset
|
922 |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
923 presence.jid_from = jabber_id_new(presence.from); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
924 if (presence.jid_from == NULL) { |
27363
eff7db4db632
Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <paul@darkrain42.org>
parents:
27362
diff
changeset
|
925 purple_debug_error("jabber", "Ignoring presence with malformed 'from' " |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
926 "JID: %s\n", presence.from); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
927 return; |
27363
eff7db4db632
Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <paul@darkrain42.org>
parents:
27362
diff
changeset
|
928 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
929 |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
930 signal_return = GPOINTER_TO_INT(purple_signal_emit_return_1(purple_connection_get_prpl(js->gc), |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
931 "jabber-receiving-presence", js->gc, type, presence.from, packet)); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
932 if (signal_return) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
933 goto out; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
934 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
935 |
29870
5286451c3d44
jabber: Avoid an assertion failure for presence from bare domains
Paul Aurich <paul@darkrain42.org>
parents:
29758
diff
changeset
|
936 if (presence.jid_from->node) |
5286451c3d44
jabber: Avoid an assertion failure for presence from bare domains
Paul Aurich <paul@darkrain42.org>
parents:
29758
diff
changeset
|
937 presence.chat = jabber_chat_find(js, presence.jid_from->node, |
5286451c3d44
jabber: Avoid an assertion failure for presence from bare domains
Paul Aurich <paul@darkrain42.org>
parents:
29758
diff
changeset
|
938 presence.jid_from->domain); |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
939 if(presence.jb->error_msg) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
940 g_free(presence.jb->error_msg); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
941 presence.jb->error_msg = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
942 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
943 |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
944 if (presence.type == JABBER_PRESENCE_AVAILABLE) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
945 presence.state = JABBER_BUDDY_STATE_ONLINE; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
946 } else if (presence.type == JABBER_PRESENCE_ERROR) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
947 /* TODO: Is this handled properly? Should it be treated as per-jbr? */ |
20814
bde477ec6a71
Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <will.thompson@collabora.co.uk>
parents:
20318
diff
changeset
|
948 char *msg = jabber_parse_error(js, packet, NULL); |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
949 presence.state = JABBER_BUDDY_STATE_ERROR; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
950 presence.jb->error_msg = msg ? msg : g_strdup(_("Unknown Error in presence")); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
951 } else if (presence.type == JABBER_PRESENCE_SUBSCRIBE) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
952 /* TODO: Move to handle_subscribe() (so nick is extracted by the |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
953 * PresenceHandler */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
954 struct _jabber_add_permit *jap = g_new0(struct _jabber_add_permit, 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
955 gboolean onlist = FALSE; |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
956 PurpleAccount *account; |
27363
eff7db4db632
Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <paul@darkrain42.org>
parents:
27362
diff
changeset
|
957 PurpleBuddy *buddy; |
26774
867e231bffbc
A little bit better (free memory and support receiving the nick in subscriptions) and Changelog.
Paul Aurich <paul@darkrain42.org>
parents:
26773
diff
changeset
|
958 xmlnode *nick; |
867e231bffbc
A little bit better (free memory and support receiving the nick in subscriptions) and Changelog.
Paul Aurich <paul@darkrain42.org>
parents:
26773
diff
changeset
|
959 |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
960 account = purple_connection_get_account(js->gc); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
961 buddy = purple_find_buddy(account, presence.from); |
26774
867e231bffbc
A little bit better (free memory and support receiving the nick in subscriptions) and Changelog.
Paul Aurich <paul@darkrain42.org>
parents:
26773
diff
changeset
|
962 nick = xmlnode_get_child_with_namespace(packet, "nick", "http://jabber.org/protocol/nick"); |
867e231bffbc
A little bit better (free memory and support receiving the nick in subscriptions) and Changelog.
Paul Aurich <paul@darkrain42.org>
parents:
26773
diff
changeset
|
963 if (nick) |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
964 presence.nickname = xmlnode_get_data(nick); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
965 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
966 if (buddy) { |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
967 if ((presence.jb->subscription & (JABBER_SUB_TO | JABBER_SUB_PENDING))) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
968 onlist = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
969 } |
15957
84bf0f949b0b
fix prompting to add a buddy after authorization if they're already on our list
Nathan Walp <nwalp@pidgin.im>
parents:
15889
diff
changeset
|
970 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
971 jap->gc = js->gc; |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
972 jap->who = g_strdup(presence.from); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
973 jap->js = js; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
974 |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
975 purple_account_request_authorization(account, presence.from, NULL, presence.nickname, |
27363
eff7db4db632
Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <paul@darkrain42.org>
parents:
27362
diff
changeset
|
976 NULL, onlist, authorize_add_cb, deny_add_cb, jap); |
eff7db4db632
Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <paul@darkrain42.org>
parents:
27362
diff
changeset
|
977 |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
978 goto out; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
979 } else if (presence.type == JABBER_PRESENCE_SUBSCRIBED) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
980 /* This case (someone has approved our subscribe request) is handled |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
981 * by the roster push the server sends along with this. |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
982 */ |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
983 goto out; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
984 } else if (presence.type == JABBER_PRESENCE_UNSUBSCRIBE) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
985 /* XXX I'm not sure this is the right way to handle this, it |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
986 * might be better to add "unsubscribe" to the presence status |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
987 * if lower down, but I'm not sure. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
988 /* they are unsubscribing from our presence, we don't care */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
989 /* Well, maybe just a little, we might want/need to start |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
990 * acknowledging this (and the others) at some point. */ |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
991 goto out; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
992 } else if (presence.type == JABBER_PRESENCE_PROBE) { |
27366
b41b69e8b341
I missed a few presence types.
Paul Aurich <paul@darkrain42.org>
parents:
27365
diff
changeset
|
993 purple_debug_warning("jabber", "Ignoring presence probe\n"); |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
994 goto out; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
995 } else if (presence.type == JABBER_PRESENCE_UNAVAILABLE) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
996 presence.state = JABBER_BUDDY_STATE_UNAVAILABLE; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
997 } else if (presence.type == JABBER_PRESENCE_UNSUBSCRIBED) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
998 presence.state = JABBER_BUDDY_STATE_UNKNOWN; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
999 } else { |
27363
eff7db4db632
Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <paul@darkrain42.org>
parents:
27362
diff
changeset
|
1000 purple_debug_warning("jabber", "Ignoring presence with invalid type " |
eff7db4db632
Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <paul@darkrain42.org>
parents:
27362
diff
changeset
|
1001 "'%s'\n", type); |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1002 goto out; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1003 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1004 |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1005 for (child = packet->child; child; child = child->next) { |
30897
2d029c5cd305
jabber: Protect against broken OSes and printf("%s", NULL) crashes
Paul Aurich <paul@darkrain42.org>
parents:
30476
diff
changeset
|
1006 const char *xmlns; |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1007 char *key; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1008 JabberPresenceHandler *pih; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1009 if (child->type != XMLNODE_TYPE_TAG) |
24721
bba38f03085d
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24693
diff
changeset
|
1010 continue; |
29623
40fee5f86bf8
jabber: Proper memory management (and fix a segfault) and whitespace
Paul Aurich <paul@darkrain42.org>
parents:
29605
diff
changeset
|
1011 |
30897
2d029c5cd305
jabber: Protect against broken OSes and printf("%s", NULL) crashes
Paul Aurich <paul@darkrain42.org>
parents:
30476
diff
changeset
|
1012 xmlns = xmlnode_get_namespace(child); |
2d029c5cd305
jabber: Protect against broken OSes and printf("%s", NULL) crashes
Paul Aurich <paul@darkrain42.org>
parents:
30476
diff
changeset
|
1013 key = g_strdup_printf("%s %s", child->name, xmlns ? xmlns : ""); |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1014 pih = g_hash_table_lookup(presence_handlers, key); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1015 g_free(key); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1016 if (pih) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1017 pih(js, &presence, child); |
25228 | 1018 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1019 |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1020 if (presence.delayed && presence.idle) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1021 /* Delayed and idle, so update idle time */ |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1022 presence.idle = presence.idle + (time(NULL) - presence.sent); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1023 } |
26753
09dc63a697e1
Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <paul@darkrain42.org>
parents:
26752
diff
changeset
|
1024 |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1025 /* TODO: Handle tracking jb(r) here? */ |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1026 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1027 if (presence.chat) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1028 ret = handle_presence_chat(js, &presence, packet); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1029 else |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1030 ret = handle_presence_contact(js, &presence); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1031 if (!ret) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1032 goto out; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1033 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1034 if (presence.caps && presence.type == JABBER_PRESENCE_AVAILABLE) { |
26753
09dc63a697e1
Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <paul@darkrain42.org>
parents:
26752
diff
changeset
|
1035 /* handle Entity Capabilities (XEP-0115) */ |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1036 const char *node = xmlnode_get_attrib(presence.caps, "node"); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1037 const char *ver = xmlnode_get_attrib(presence.caps, "ver"); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1038 const char *hash = xmlnode_get_attrib(presence.caps, "hash"); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1039 const char *ext = xmlnode_get_attrib(presence.caps, "ext"); |
26753
09dc63a697e1
Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <paul@darkrain42.org>
parents:
26752
diff
changeset
|
1040 |
09dc63a697e1
Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <paul@darkrain42.org>
parents:
26752
diff
changeset
|
1041 /* v1.3 uses: node, ver, and optionally ext. |
09dc63a697e1
Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <paul@darkrain42.org>
parents:
26752
diff
changeset
|
1042 * v1.5 uses: node, ver, and hash. */ |
09dc63a697e1
Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <paul@darkrain42.org>
parents:
26752
diff
changeset
|
1043 if (node && *node && ver && *ver) { |
26846
d0a049ede31e
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents:
26842
diff
changeset
|
1044 gchar **exts = ext && *ext ? g_strsplit(ext, " ", -1) : NULL; |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1045 jbr = jabber_buddy_find_resource(presence.jb, presence.jid_from->resource); |
26846
d0a049ede31e
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents:
26842
diff
changeset
|
1046 |
d0a049ede31e
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents:
26842
diff
changeset
|
1047 /* Look it up if we don't already have all this information */ |
d0a049ede31e
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents:
26842
diff
changeset
|
1048 if (!jbr || !jbr->caps.info || |
d0a049ede31e
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents:
26842
diff
changeset
|
1049 !g_str_equal(node, jbr->caps.info->tuple.node) || |
d0a049ede31e
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents:
26842
diff
changeset
|
1050 !g_str_equal(ver, jbr->caps.info->tuple.ver) || |
d0a049ede31e
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents:
26842
diff
changeset
|
1051 !purple_strequal(hash, jbr->caps.info->tuple.hash) || |
d0a049ede31e
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents:
26842
diff
changeset
|
1052 !jabber_caps_exts_known(jbr->caps.info, (gchar **)exts)) { |
d0a049ede31e
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents:
26842
diff
changeset
|
1053 JabberPresenceCapabilities *userdata = g_new0(JabberPresenceCapabilities, 1); |
d0a049ede31e
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents:
26842
diff
changeset
|
1054 userdata->js = js; |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1055 userdata->jb = presence.jb; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1056 userdata->from = g_strdup(presence.from); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1057 jabber_caps_get_info(js, presence.from, node, ver, hash, exts, |
26846
d0a049ede31e
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents:
26842
diff
changeset
|
1058 (jabber_caps_get_info_cb)jabber_presence_set_capabilities, |
d0a049ede31e
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents:
26842
diff
changeset
|
1059 userdata); |
d0a049ede31e
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents:
26842
diff
changeset
|
1060 } else { |
d0a049ede31e
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents:
26842
diff
changeset
|
1061 if (exts) |
d0a049ede31e
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents:
26842
diff
changeset
|
1062 g_strfreev(exts); |
d0a049ede31e
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents:
26842
diff
changeset
|
1063 } |
26753
09dc63a697e1
Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <paul@darkrain42.org>
parents:
26752
diff
changeset
|
1064 } |
09dc63a697e1
Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <paul@darkrain42.org>
parents:
26752
diff
changeset
|
1065 } |
09dc63a697e1
Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <paul@darkrain42.org>
parents:
26752
diff
changeset
|
1066 |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1067 out: |
29623
40fee5f86bf8
jabber: Proper memory management (and fix a segfault) and whitespace
Paul Aurich <paul@darkrain42.org>
parents:
29605
diff
changeset
|
1068 while (presence.chat_info.codes) |
40fee5f86bf8
jabber: Proper memory management (and fix a segfault) and whitespace
Paul Aurich <paul@darkrain42.org>
parents:
29605
diff
changeset
|
1069 presence.chat_info.codes = |
40fee5f86bf8
jabber: Proper memory management (and fix a segfault) and whitespace
Paul Aurich <paul@darkrain42.org>
parents:
29605
diff
changeset
|
1070 g_slist_delete_link(presence.chat_info.codes, |
40fee5f86bf8
jabber: Proper memory management (and fix a segfault) and whitespace
Paul Aurich <paul@darkrain42.org>
parents:
29605
diff
changeset
|
1071 presence.chat_info.codes); |
40fee5f86bf8
jabber: Proper memory management (and fix a segfault) and whitespace
Paul Aurich <paul@darkrain42.org>
parents:
29605
diff
changeset
|
1072 |
40fee5f86bf8
jabber: Proper memory management (and fix a segfault) and whitespace
Paul Aurich <paul@darkrain42.org>
parents:
29605
diff
changeset
|
1073 g_free(presence.status); |
40fee5f86bf8
jabber: Proper memory management (and fix a segfault) and whitespace
Paul Aurich <paul@darkrain42.org>
parents:
29605
diff
changeset
|
1074 g_free(presence.vcard_avatar_hash); |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1075 g_free(presence.nickname); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1076 jabber_id_free(presence.jid_from); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1077 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1078 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1079 void jabber_presence_subscription_set(JabberStream *js, const char *who, const char *type) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1080 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1081 xmlnode *presence = xmlnode_new("presence"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1082 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1083 xmlnode_set_attrib(presence, "to", who); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1084 xmlnode_set_attrib(presence, "type", type); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1085 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1086 jabber_send(js, presence); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1087 xmlnode_free(presence); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1088 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1089 |
15822 | 1090 void purple_status_to_jabber(const PurpleStatus *status, JabberBuddyState *state, char **msg, int *priority) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1091 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1092 const char *status_id = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1093 const char *formatted_msg = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1094 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1095 if(state) *state = JABBER_BUDDY_STATE_UNKNOWN; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1096 if(msg) *msg = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1097 if(priority) *priority = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1098 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1099 if(!status) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1100 if(state) *state = JABBER_BUDDY_STATE_UNAVAILABLE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1101 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1102 if(state) { |
15822 | 1103 status_id = purple_status_get_id(status); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1104 *state = jabber_buddy_status_id_get_state(status_id); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1105 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1106 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1107 if(msg) { |
15822 | 1108 formatted_msg = purple_status_get_attr_string(status, "message"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1109 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1110 /* if the message is blank, then there really isn't a message */ |
27487
7a2891487a00
Don't pre-escape jbr->status. Almost every place required it in unescaped
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27439
diff
changeset
|
1111 if(formatted_msg && *formatted_msg) |
17576 | 1112 *msg = purple_markup_strip_html(formatted_msg); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1113 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1114 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1115 if(priority) |
15822 | 1116 *priority = purple_status_get_attr_int(status, "priority"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1117 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1118 } |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1119 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1120 /* Incoming presence handlers */ |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1121 static void |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1122 parse_priority(JabberStream *js, JabberPresence *presence, xmlnode *priority) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1123 { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1124 char *p = xmlnode_get_data(priority); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1125 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1126 if (presence->priority != 0) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1127 purple_debug_warning("jabber", "presence stanza received with multiple " |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1128 "priority children!?\n"); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1129 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1130 if (p) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1131 presence->priority = atoi(p); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1132 g_free(p); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1133 } else |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1134 purple_debug_warning("jabber", "Empty <priority/> in presence!\n"); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1135 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1136 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1137 static void |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1138 parse_show(JabberStream *js, JabberPresence *presence, xmlnode *show) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1139 { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1140 char *cdata; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1141 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1142 if (presence->type != JABBER_PRESENCE_AVAILABLE) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1143 purple_debug_warning("jabber", "<show/> present on presence, but " |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1144 "type is not default ('available')\n"); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1145 return; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1146 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1147 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1148 cdata = xmlnode_get_data(show); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1149 if (cdata) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1150 presence->state = jabber_buddy_show_get_state(cdata); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1151 g_free(cdata); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1152 } else |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1153 purple_debug_warning("jabber", "<show/> present on presence, but " |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1154 "no contents!\n"); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1155 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1156 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1157 static void |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1158 parse_status(JabberStream *js, JabberPresence *presence, xmlnode *status) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1159 { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1160 /* TODO: Check/track language attribute? */ |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1161 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1162 g_free(presence->status); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1163 presence->status = xmlnode_get_data(status); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1164 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1165 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1166 static void |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1167 parse_delay(JabberStream *js, JabberPresence *presence, xmlnode *delay) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1168 { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1169 const char *stamp = xmlnode_get_attrib(delay, "stamp"); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1170 presence->delayed = TRUE; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1171 presence->sent = purple_str_to_time(stamp, TRUE, NULL, NULL, NULL); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1172 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1173 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1174 static void |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1175 parse_idle(JabberStream *js, JabberPresence *presence, xmlnode *query) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1176 { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1177 const gchar *seconds = xmlnode_get_attrib(query, "seconds"); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1178 if (seconds) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1179 presence->idle = atoi(seconds); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1180 if (presence->idle < 0) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1181 purple_debug_warning("jabber", "Received bogus idle time %s\n", seconds); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1182 presence->idle = 0; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1183 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1184 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1185 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1186 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1187 static void |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1188 parse_caps(JabberStream *js, JabberPresence *presence, xmlnode *c) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1189 { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1190 /* TODO: Move the rest of the caps handling in here, after changing the |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1191 * the "do we have details about this (node, ver) and exts" to not |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1192 * require the jbr to be present (since that happens later). |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1193 */ |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1194 presence->caps = c; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1195 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1196 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1197 static void |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1198 parse_nickname(JabberStream *js, JabberPresence *presence, xmlnode *nick) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1199 { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1200 g_free(presence->nickname); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1201 presence->nickname = xmlnode_get_data(nick); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1202 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1203 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1204 static void |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1205 parse_vcard_avatar(JabberStream *js, JabberPresence *presence, xmlnode *x) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1206 { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1207 xmlnode *photo = xmlnode_get_child(x, "photo"); |
31526
b2f6fec7b98e
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
matthew@bells23.org.uk
parents:
31233
diff
changeset
|
1208 |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1209 if (photo) { |
31527
c832d481d021
jabber: Tighter scoping
Paul Aurich <paul@darkrain42.org>
parents:
31526
diff
changeset
|
1210 char *hash_tmp = xmlnode_get_data(photo); |
c832d481d021
jabber: Tighter scoping
Paul Aurich <paul@darkrain42.org>
parents:
31526
diff
changeset
|
1211 g_free(presence->vcard_avatar_hash); |
c832d481d021
jabber: Tighter scoping
Paul Aurich <paul@darkrain42.org>
parents:
31526
diff
changeset
|
1212 presence->vcard_avatar_hash = |
31526
b2f6fec7b98e
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
matthew@bells23.org.uk
parents:
31233
diff
changeset
|
1213 hash_tmp ? hash_tmp : g_strdup(""); |
29560
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1214 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1215 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1216 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1217 static void |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1218 parse_muc_user(JabberStream *js, JabberPresence *presence, xmlnode *x) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1219 { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1220 xmlnode *status; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1221 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1222 if (presence->chat == NULL) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1223 purple_debug_warning("jabber", "Ignoring MUC gloop on non-MUC presence\n"); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1224 return; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1225 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1226 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1227 if (presence->chat->conv == NULL) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1228 presence->chat->muc = TRUE; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1229 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1230 for (status = xmlnode_get_child(x, "status"); status; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1231 status = xmlnode_get_next_twin(status)) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1232 const char *code = xmlnode_get_attrib(status, "code"); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1233 int val; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1234 if (!code) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1235 continue; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1236 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1237 val = atoi(code); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1238 if (val == 0 || val < 0) { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1239 purple_debug_warning("jabber", "Ignoring bogus status code '%s'\n", |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1240 code); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1241 continue; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1242 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1243 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1244 presence->chat_info.codes = g_slist_prepend(presence->chat_info.codes, GINT_TO_POINTER(val)); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1245 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1246 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1247 presence->chat_info.item = xmlnode_get_child(x, "item"); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1248 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1249 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1250 void jabber_presence_register_handler(const char *node, const char *xmlns, |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1251 JabberPresenceHandler *handler) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1252 { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1253 /* |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1254 * This is valid because nodes nor namespaces cannot have spaces in them |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1255 * (see http://www.w3.org/TR/2006/REC-xml-20060816/ and |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1256 * http://www.w3.org/TR/REC-xml-names/) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1257 */ |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1258 char *key = g_strdup_printf("%s %s", node, xmlns); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1259 g_hash_table_replace(presence_handlers, key, handler); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1260 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1261 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1262 void jabber_presence_init(void) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1263 { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1264 presence_handlers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1265 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1266 /* Core RFC things */ |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1267 jabber_presence_register_handler("priority", "jabber:client", parse_priority); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1268 jabber_presence_register_handler("show", "jabber:client", parse_show); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1269 jabber_presence_register_handler("status", "jabber:client", parse_status); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1270 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1271 /* XEPs */ |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1272 jabber_presence_register_handler("c", "http://jabber.org/protocol/caps", parse_caps); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1273 jabber_presence_register_handler("delay", NS_DELAYED_DELIVERY, parse_delay); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1274 jabber_presence_register_handler("nick", "http://jabber.org/protocol/nick", parse_nickname); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1275 jabber_presence_register_handler("query", NS_LAST_ACTIVITY, parse_idle); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1276 jabber_presence_register_handler("x", NS_DELAYED_DELIVERY_LEGACY, parse_delay); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1277 jabber_presence_register_handler("x", "http://jabber.org/protocol/muc#user", parse_muc_user); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1278 jabber_presence_register_handler("x", "vcard-temp:x:update", parse_vcard_avatar); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1279 } |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1280 |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1281 void jabber_presence_uninit(void) |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1282 { |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1283 g_hash_table_destroy(presence_handlers); |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1284 presence_handlers = NULL; |
13f320cde14f
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <paul@darkrain42.org>
parents:
29531
diff
changeset
|
1285 } |