Mon, 22 Aug 2022 22:05:55 -0500
Create PurpleAuthorizationRequest and use it for notifications.
This replaces the old internal representation of authorization requests as well
as the UI's implementation of their own objects. Everything is now controlled
via PurpleAuthorizationRequest and the UI's display the notification for
interaction.
Testing Done:
Verified the notification and actions work in both finch and pidgin.
Reviewed at https://reviews.imfreedom.org/r/1613/
| 7014 | 1 | /* |
| 15884 | 2 | * purple - Jabber Protocol Plugin |
| 7014 | 3 | * |
|
28322
ac8fec1d2234
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents:
28138
diff
changeset
|
4 | * Purple is the legal property of its developers, whose names are too numerous |
|
ac8fec1d2234
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents:
28138
diff
changeset
|
5 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
ac8fec1d2234
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents:
28138
diff
changeset
|
6 | * source distribution. |
| 7014 | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify | |
| 9 | * it under the terms of the GNU General Public License as published by | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 19 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19335
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 7014 | 21 | * |
| 22 | */ | |
|
40439
e9838d634d5e
Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents:
40358
diff
changeset
|
23 | #include <glib/gi18n-lib.h> |
|
e9838d634d5e
Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents:
40358
diff
changeset
|
24 | |
|
40358
e6fe6fc1f516
move all protocols, purple plugins, and purple tests to use purple.h instead of including files individually
Gary Kramlich <grim@reaperworld.com>
parents:
40052
diff
changeset
|
25 | #include <purple.h> |
| 7014 | 26 | |
| 27 | #include "buddy.h" | |
| 28 | #include "chat.h" | |
| 29 | #include "presence.h" | |
| 30 | #include "iq.h" | |
| 31 | #include "jutil.h" | |
|
17816
1b7362b4a7a2
Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
17812
diff
changeset
|
32 | #include "adhoccommands.h" |
| 7014 | 33 | |
|
29413
fcf9343baf3d
jabber: Actually send a mood update when setting a mood status (using the generic mood selector).
Marcus Lundblad <malu@pidgin.im>
parents:
29223
diff
changeset
|
34 | #include "usermood.h" |
|
17800
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
35 | #include "usertune.h" |
| 7014 | 36 | |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
37 | static GHashTable *presence_handlers = NULL; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
38 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
39 | static const struct { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
40 | const char *name; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
41 | JabberPresenceType type; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
42 | } jabber_presence_types[] = { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
43 | { "error", JABBER_PRESENCE_ERROR }, |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
44 | { "probe", JABBER_PRESENCE_PROBE }, |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
45 | { "unavailable", JABBER_PRESENCE_UNAVAILABLE }, |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
46 | { "subscribe", JABBER_PRESENCE_SUBSCRIBE }, |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
47 | { "subscribed", JABBER_PRESENCE_SUBSCRIBED }, |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
48 | { "unsubscribe", JABBER_PRESENCE_UNSUBSCRIBE }, |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
49 | { "unsubscribed", JABBER_PRESENCE_UNSUBSCRIBED } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
50 | /* { NULL, JABBER_PRESENCE_AVAILABLE } the default */ |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
51 | }; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
52 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
53 | static JabberPresenceType |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
54 | str_to_presence_type(const char *type) |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
55 | { |
|
36256
a437550a9308
Remove -Wno-sign-compare and backport fixes from default.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31745
diff
changeset
|
56 | gsize i; |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
57 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
58 | if (type == NULL) |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
59 | return JABBER_PRESENCE_AVAILABLE; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
60 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
61 | for (i = 0; i < G_N_ELEMENTS(jabber_presence_types); ++i) |
|
38256
035f00c4fd87
Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
36256
diff
changeset
|
62 | if (purple_strequal(type, jabber_presence_types[i].name)) |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
63 | return jabber_presence_types[i].type; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
64 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
65 | purple_debug_warning("jabber", "Unknown presence type '%s'\n", type); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
66 | return JABBER_PRESENCE_AVAILABLE; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
67 | } |
| 7014 | 68 | |
| 69 | static void chats_send_presence_foreach(gpointer key, gpointer val, | |
| 70 | gpointer user_data) | |
| 71 | { | |
| 72 | JabberChat *chat = val; | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
73 | PurpleXmlNode *presence = user_data; |
| 8577 | 74 | char *chat_full_jid; |
| 75 | ||
|
23403
a8704d47889f
Fix the chat-room rejoining bug where the list appears empty.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23270
diff
changeset
|
76 | if(!chat->conv || chat->left) |
| 8577 | 77 | return; |
| 78 | ||
| 79 | chat_full_jid = g_strdup_printf("%s@%s/%s", chat->room, chat->server, | |
| 8401 | 80 | chat->handle); |
| 7014 | 81 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
82 | purple_xmlnode_set_attrib(presence, "to", chat_full_jid); |
| 7014 | 83 | jabber_send(chat->js, presence); |
| 8401 | 84 | g_free(chat_full_jid); |
| 7014 | 85 | } |
| 86 | ||
|
27280
55a39efcf7b8
Simplify the fake_to_self function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27278
diff
changeset
|
87 | void jabber_presence_fake_to_self(JabberStream *js, PurpleStatus *status) |
|
55a39efcf7b8
Simplify the fake_to_self function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27278
diff
changeset
|
88 | { |
|
55a39efcf7b8
Simplify the fake_to_self function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27278
diff
changeset
|
89 | PurpleAccount *account; |
|
27964
752edad344b3
jabber: Properly track own idle time in fake_to_self.
Paul Aurich <darkrain42@pidgin.im>
parents:
27860
diff
changeset
|
90 | PurplePresence *presence; |
|
29369
4f997d7ef056
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29338
diff
changeset
|
91 | JabberBuddy *jb; |
|
4f997d7ef056
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29338
diff
changeset
|
92 | JabberBuddyResource *jbr; |
|
27280
55a39efcf7b8
Simplify the fake_to_self function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27278
diff
changeset
|
93 | const char *username; |
|
29369
4f997d7ef056
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29338
diff
changeset
|
94 | JabberBuddyState state; |
|
4f997d7ef056
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29338
diff
changeset
|
95 | char *msg; |
|
4f997d7ef056
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29338
diff
changeset
|
96 | int priority; |
| 10286 | 97 | |
|
27280
55a39efcf7b8
Simplify the fake_to_self function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27278
diff
changeset
|
98 | g_return_if_fail(js->user != NULL); |
| 10286 | 99 | |
|
27280
55a39efcf7b8
Simplify the fake_to_self function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27278
diff
changeset
|
100 | account = purple_connection_get_account(js->gc); |
|
27860
2b75b87699c8
Support connecting to IDNA XMPP domains.
Paul Aurich <darkrain42@pidgin.im>
parents:
27847
diff
changeset
|
101 | username = purple_connection_get_display_name(js->gc); |
|
27964
752edad344b3
jabber: Properly track own idle time in fake_to_self.
Paul Aurich <darkrain42@pidgin.im>
parents:
27860
diff
changeset
|
102 | presence = purple_account_get_presence(account); |
|
27280
55a39efcf7b8
Simplify the fake_to_self function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27278
diff
changeset
|
103 | if (status == NULL) |
|
27964
752edad344b3
jabber: Properly track own idle time in fake_to_self.
Paul Aurich <darkrain42@pidgin.im>
parents:
27860
diff
changeset
|
104 | status = purple_presence_get_active_status(presence); |
|
29369
4f997d7ef056
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29338
diff
changeset
|
105 | purple_status_to_jabber(status, &state, &msg, &priority); |
|
27280
55a39efcf7b8
Simplify the fake_to_self function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27278
diff
changeset
|
106 | |
|
29369
4f997d7ef056
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29338
diff
changeset
|
107 | jb = js->user_jb; |
| 9954 | 108 | |
|
29369
4f997d7ef056
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29338
diff
changeset
|
109 | if (state == JABBER_BUDDY_STATE_UNAVAILABLE || |
|
4f997d7ef056
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29338
diff
changeset
|
110 | state == JABBER_BUDDY_STATE_UNKNOWN) { |
|
4f997d7ef056
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29338
diff
changeset
|
111 | jabber_buddy_remove_resource(jb, js->user->resource); |
|
4f997d7ef056
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29338
diff
changeset
|
112 | } else { |
|
4f997d7ef056
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29338
diff
changeset
|
113 | jbr = jabber_buddy_track_resource(jb, js->user->resource, priority, |
|
4f997d7ef056
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29338
diff
changeset
|
114 | state, msg); |
|
4f997d7ef056
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29338
diff
changeset
|
115 | jbr->idle = purple_presence_is_idle(presence) ? |
|
4f997d7ef056
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29338
diff
changeset
|
116 | purple_presence_get_idle_time(presence) : 0; |
|
4f997d7ef056
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29338
diff
changeset
|
117 | } |
| 14525 | 118 | |
|
29369
4f997d7ef056
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29338
diff
changeset
|
119 | /* |
|
4f997d7ef056
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29338
diff
changeset
|
120 | * While we need to track the status of this resource, the core |
|
4f997d7ef056
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29338
diff
changeset
|
121 | * only cares if we're on our own buddy list. |
|
4f997d7ef056
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29338
diff
changeset
|
122 | */ |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34671
diff
changeset
|
123 | if (purple_blist_find_buddy(account, username)) { |
|
29369
4f997d7ef056
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29338
diff
changeset
|
124 | jbr = jabber_buddy_find_resource(jb, NULL); |
|
4f997d7ef056
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29338
diff
changeset
|
125 | if (jbr) { |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36362
diff
changeset
|
126 | purple_protocol_got_user_status(account, username, |
|
27964
752edad344b3
jabber: Properly track own idle time in fake_to_self.
Paul Aurich <darkrain42@pidgin.im>
parents:
27860
diff
changeset
|
127 | jabber_buddy_state_get_status_id(jbr->state), |
|
752edad344b3
jabber: Properly track own idle time in fake_to_self.
Paul Aurich <darkrain42@pidgin.im>
parents:
27860
diff
changeset
|
128 | "priority", jbr->priority, |
|
752edad344b3
jabber: Properly track own idle time in fake_to_self.
Paul Aurich <darkrain42@pidgin.im>
parents:
27860
diff
changeset
|
129 | jbr->status ? "message" : NULL, jbr->status, |
|
752edad344b3
jabber: Properly track own idle time in fake_to_self.
Paul Aurich <darkrain42@pidgin.im>
parents:
27860
diff
changeset
|
130 | NULL); |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36362
diff
changeset
|
131 | purple_protocol_got_user_idle(account, username, jbr->idle, jbr->idle); |
|
27280
55a39efcf7b8
Simplify the fake_to_self function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27278
diff
changeset
|
132 | } else { |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36362
diff
changeset
|
133 | purple_protocol_got_user_status(account, username, "offline", |
|
27964
752edad344b3
jabber: Properly track own idle time in fake_to_self.
Paul Aurich <darkrain42@pidgin.im>
parents:
27860
diff
changeset
|
134 | msg ? "message" : NULL, msg, |
|
752edad344b3
jabber: Properly track own idle time in fake_to_self.
Paul Aurich <darkrain42@pidgin.im>
parents:
27860
diff
changeset
|
135 | NULL); |
| 8185 | 136 | } |
| 137 | } | |
|
29369
4f997d7ef056
jabber: Always track our own presence, even if we're not on the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29338
diff
changeset
|
138 | g_free(msg); |
| 8185 | 139 | } |
| 140 | ||
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40474
diff
changeset
|
141 | void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40474
diff
changeset
|
142 | jabber_set_status(PurpleProtocolServer *protocol_server, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40474
diff
changeset
|
143 | PurpleAccount *account, PurpleStatus *status) |
| 7014 | 144 | { |
|
24717
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
145 | PurpleConnection *gc; |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
146 | JabberStream *js; |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
147 | |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
148 | if (!purple_account_is_connected(account)) |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
149 | return; |
|
27155
53502d71efdd
Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents:
27145
diff
changeset
|
150 | |
|
24717
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
151 | if (purple_status_is_exclusive(status) && !purple_status_is_active(status)) { |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
152 | /* An exclusive status can't be deactivated. You should just |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
153 | * activate some other exclusive status. */ |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
154 | return; |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
155 | } |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
156 | |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
157 | gc = purple_account_get_connection(account); |
|
26072
e8fce2b2b9fe
propagate from branch 'im.pidgin.pidgin' (head b4bbfacd7f2050d87deeda12ea7bb3adc3608cb7)
Paul Aurich <darkrain42@pidgin.im>
diff
changeset
|
158 | js = purple_connection_get_protocol_data(gc); |
|
29413
fcf9343baf3d
jabber: Actually send a mood update when setting a mood status (using the generic mood selector).
Marcus Lundblad <malu@pidgin.im>
parents:
29223
diff
changeset
|
159 | |
|
fcf9343baf3d
jabber: Actually send a mood update when setting a mood status (using the generic mood selector).
Marcus Lundblad <malu@pidgin.im>
parents:
29223
diff
changeset
|
160 | /* it's a mood update */ |
|
34855
9c289149eed4
Global replaces according to GObject status API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
161 | if (purple_status_type_get_primitive(purple_status_get_status_type(status)) == PURPLE_STATUS_MOOD) { |
|
29413
fcf9343baf3d
jabber: Actually send a mood update when setting a mood status (using the generic mood selector).
Marcus Lundblad <malu@pidgin.im>
parents:
29223
diff
changeset
|
162 | const char *mood = |
|
fcf9343baf3d
jabber: Actually send a mood update when setting a mood status (using the generic mood selector).
Marcus Lundblad <malu@pidgin.im>
parents:
29223
diff
changeset
|
163 | purple_status_get_attr_string(status, PURPLE_MOOD_NAME); |
|
29816
4a729e2b9bdb
Enable setting mood message with the global mood selection UI, when the
Marcus Lundblad <malu@pidgin.im>
parents:
29749
diff
changeset
|
164 | const char *mood_text = |
|
4a729e2b9bdb
Enable setting mood message with the global mood selection UI, when the
Marcus Lundblad <malu@pidgin.im>
parents:
29749
diff
changeset
|
165 | purple_status_get_attr_string(status, PURPLE_MOOD_COMMENT); |
|
4a729e2b9bdb
Enable setting mood message with the global mood selection UI, when the
Marcus Lundblad <malu@pidgin.im>
parents:
29749
diff
changeset
|
166 | jabber_mood_set(js, mood, mood_text); |
|
29413
fcf9343baf3d
jabber: Actually send a mood update when setting a mood status (using the generic mood selector).
Marcus Lundblad <malu@pidgin.im>
parents:
29223
diff
changeset
|
167 | return; |
|
fcf9343baf3d
jabber: Actually send a mood update when setting a mood status (using the generic mood selector).
Marcus Lundblad <malu@pidgin.im>
parents:
29223
diff
changeset
|
168 | } |
|
fcf9343baf3d
jabber: Actually send a mood update when setting a mood status (using the generic mood selector).
Marcus Lundblad <malu@pidgin.im>
parents:
29223
diff
changeset
|
169 | |
|
24717
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
170 | jabber_presence_send(js, FALSE); |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
171 | } |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
172 | |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
173 | void jabber_presence_send(JabberStream *js, gboolean force) |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
174 | { |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
175 | PurpleAccount *account; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
176 | PurpleXmlNode *presence, *x, *photo; |
| 7014 | 177 | char *stripped = NULL; |
| 9954 | 178 | JabberBuddyState state; |
| 179 | int priority; | |
|
21193
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20169
diff
changeset
|
180 | const char *artist = NULL, *title = NULL, *source = NULL, *uri = NULL, *track = NULL; |
|
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20169
diff
changeset
|
181 | int length = -1; |
|
17824
52683dfc1f7d
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <am@adiumx.com>
parents:
17816
diff
changeset
|
182 | gboolean allowBuzz; |
|
21758
e70c407c994b
We need to work with the exclusive status.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21687
diff
changeset
|
183 | PurplePresence *p; |
|
24717
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
184 | PurpleStatus *status, *tune; |
|
18195
9cd0565f856e
kill some code duplication when sending current presence
Nathan Walp <nwalp@pidgin.im>
parents:
17703
diff
changeset
|
185 | |
|
24717
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
186 | account = purple_connection_get_account(js->gc); |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
187 | p = purple_account_get_presence(account); |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
188 | status = purple_presence_get_active_status(p); |
|
10755
a336a5d3102d
[gaim-migrate @ 12358]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
189 | |
|
18226
adf83935e838
really and truly enforce the no-presence-before-roster thing
Nathan Walp <nwalp@pidgin.im>
parents:
18195
diff
changeset
|
190 | /* we don't want to send presence before we've gotten our roster */ |
|
27278
b34a1cea4872
Use js->state to track whether the roster has been retrieved.
Paul Aurich <darkrain42@pidgin.im>
parents:
27202
diff
changeset
|
191 | if (js->state != JABBER_STREAM_CONNECTED) { |
|
29095
f2260f873535
jabber: Lower the prio of this message; it's not very important.
Paul Aurich <darkrain42@pidgin.im>
parents:
29059
diff
changeset
|
192 | purple_debug_misc("jabber", "attempt to send presence before roster retrieved\n"); |
|
18226
adf83935e838
really and truly enforce the no-presence-before-roster thing
Nathan Walp <nwalp@pidgin.im>
parents:
18195
diff
changeset
|
193 | return; |
|
adf83935e838
really and truly enforce the no-presence-before-roster thing
Nathan Walp <nwalp@pidgin.im>
parents:
18195
diff
changeset
|
194 | } |
|
adf83935e838
really and truly enforce the no-presence-before-roster thing
Nathan Walp <nwalp@pidgin.im>
parents:
18195
diff
changeset
|
195 | |
| 15884 | 196 | purple_status_to_jabber(status, &state, &stripped, &priority); |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25154
diff
changeset
|
197 | |
|
17824
52683dfc1f7d
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <am@adiumx.com>
parents:
17816
diff
changeset
|
198 | /* check for buzz support */ |
|
52683dfc1f7d
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <am@adiumx.com>
parents:
17816
diff
changeset
|
199 | allowBuzz = purple_status_get_attr_boolean(status,"buzz"); |
|
52683dfc1f7d
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <am@adiumx.com>
parents:
17816
diff
changeset
|
200 | /* changing the buzz state has to trigger a re-broadcasting of the presence for caps */ |
|
23574
5c7073191c5a
make googletalk tune hack work, previously it's not doing anything unless
Ka-Hing Cheung <khc@pidgin.im>
parents:
23403
diff
changeset
|
201 | |
|
17800
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
202 | /* check if there are any differences to the <presence> and send them in that case */ |
|
24717
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
203 | if (force || allowBuzz != js->allowBuzz || js->old_state != state || |
|
38266
7c1706b2bd11
Remove found redundant NULL checks
qarkai <qarkai@gmail.com>
parents:
38259
diff
changeset
|
204 | !purple_strequal(js->old_msg, stripped) || js->old_priority != priority || |
|
7c1706b2bd11
Remove found redundant NULL checks
qarkai <qarkai@gmail.com>
parents:
38259
diff
changeset
|
205 | !purple_strequal(js->old_avatarhash, js->avatar_hash) || js->old_idle != js->idle) { |
|
24717
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
206 | /* Need to update allowBuzz before creating the presence (with caps) */ |
|
17824
52683dfc1f7d
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <am@adiumx.com>
parents:
17816
diff
changeset
|
207 | js->allowBuzz = allowBuzz; |
|
21195
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
21193
diff
changeset
|
208 | |
|
17800
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
209 | presence = jabber_presence_create_js(js, state, stripped, priority); |
| 7014 | 210 | |
|
25810
5cf3c22e52df
Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents:
25154
diff
changeset
|
211 | /* Per XEP-0153 4.1, we must always send the <x> */ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
212 | x = purple_xmlnode_new_child(presence, "x"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
213 | purple_xmlnode_set_namespace(x, "vcard-temp:x:update"); |
|
25810
5cf3c22e52df
Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents:
25154
diff
changeset
|
214 | /* |
|
5cf3c22e52df
Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents:
25154
diff
changeset
|
215 | * FIXME: Per XEP-0153 4.3.2 bullet 2, we must not publish our |
|
5cf3c22e52df
Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents:
25154
diff
changeset
|
216 | * image hash if another resource has logged in and updated the |
|
5cf3c22e52df
Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents:
25154
diff
changeset
|
217 | * vcard avatar. Requires changes in jabber_presence_parse. |
|
5cf3c22e52df
Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents:
25154
diff
changeset
|
218 | */ |
|
5cf3c22e52df
Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents:
25154
diff
changeset
|
219 | if (js->vcard_fetched) { |
|
5cf3c22e52df
Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents:
25154
diff
changeset
|
220 | /* Always publish a <photo>; it's empty if we have no image. */ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
221 | photo = purple_xmlnode_new_child(x, "photo"); |
|
25810
5cf3c22e52df
Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents:
25154
diff
changeset
|
222 | if (js->avatar_hash) |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
223 | purple_xmlnode_insert_data(photo, js->avatar_hash, -1); |
|
17800
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
224 | } |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
225 | |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
226 | jabber_send(js, presence); |
| 7014 | 227 | |
|
17800
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
228 | g_hash_table_foreach(js->chats, chats_send_presence_foreach, presence); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
229 | purple_xmlnode_free(presence); |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25154
diff
changeset
|
230 | |
|
17800
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
231 | /* update old values */ |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25154
diff
changeset
|
232 | |
|
37423
d2f0259aa43f
Remove NULL-checks before free(). No functional change.
Michael McConville <mmcco@mykolab.com>
parents:
37238
diff
changeset
|
233 | g_free(js->old_msg); |
|
d2f0259aa43f
Remove NULL-checks before free(). No functional change.
Michael McConville <mmcco@mykolab.com>
parents:
37238
diff
changeset
|
234 | g_free(js->old_avatarhash); |
|
17800
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
235 | js->old_msg = g_strdup(stripped); |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
236 | js->old_avatarhash = g_strdup(js->avatar_hash); |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
237 | js->old_state = state; |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
238 | js->old_priority = priority; |
| 25229 | 239 | js->old_idle = js->idle; |
| 10189 | 240 | } |
|
23575
7a22a015d694
let's not leak if nothing is changed
Ka-Hing Cheung <khc@pidgin.im>
parents:
23574
diff
changeset
|
241 | g_free(stripped); |
|
7a22a015d694
let's not leak if nothing is changed
Ka-Hing Cheung <khc@pidgin.im>
parents:
23574
diff
changeset
|
242 | |
|
17800
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
243 | /* next, check if there are any changes to the tune values */ |
|
40726
645607090674
Remove Google Talk from the XMPP plugin.
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
244 | tune = purple_presence_get_status(p, "tune"); |
|
24717
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
245 | if (purple_status_is_active(tune)) { |
|
21193
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20169
diff
changeset
|
246 | artist = purple_status_get_attr_string(tune, PURPLE_TUNE_ARTIST); |
|
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20169
diff
changeset
|
247 | title = purple_status_get_attr_string(tune, PURPLE_TUNE_TITLE); |
|
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20169
diff
changeset
|
248 | source = purple_status_get_attr_string(tune, PURPLE_TUNE_ALBUM); |
|
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20169
diff
changeset
|
249 | uri = purple_status_get_attr_string(tune, PURPLE_TUNE_URL); |
|
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20169
diff
changeset
|
250 | track = purple_status_get_attr_string(tune, PURPLE_TUNE_TRACK); |
|
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20169
diff
changeset
|
251 | length = (!purple_status_get_attr_value(tune, PURPLE_TUNE_TIME)) ? -1 : |
|
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20169
diff
changeset
|
252 | purple_status_get_attr_int(tune, PURPLE_TUNE_TIME); |
|
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20169
diff
changeset
|
253 | } |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25154
diff
changeset
|
254 | |
|
38266
7c1706b2bd11
Remove found redundant NULL checks
qarkai <qarkai@gmail.com>
parents:
38259
diff
changeset
|
255 | if(!purple_strequal(artist, js->old_artist) || !purple_strequal(title, js->old_title) || |
|
7c1706b2bd11
Remove found redundant NULL checks
qarkai <qarkai@gmail.com>
parents:
38259
diff
changeset
|
256 | !purple_strequal(source, js->old_source) || !purple_strequal(uri, js->old_uri) || |
|
7c1706b2bd11
Remove found redundant NULL checks
qarkai <qarkai@gmail.com>
parents:
38259
diff
changeset
|
257 | !purple_strequal(track, js->old_track) || (length != js->old_length)) { |
|
17800
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
258 | PurpleJabberTuneInfo tuneinfo = { |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
259 | (char*)artist, |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
260 | (char*)title, |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
261 | (char*)source, |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
262 | (char*)track, |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
263 | length, |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
264 | (char*)uri |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
265 | }; |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
266 | jabber_tune_set(js->gc, &tuneinfo); |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25154
diff
changeset
|
267 | |
|
17800
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
268 | /* update old values */ |
|
20169
497e1cd1e059
Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents:
19899
diff
changeset
|
269 | g_free(js->old_artist); |
|
497e1cd1e059
Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents:
19899
diff
changeset
|
270 | g_free(js->old_title); |
|
497e1cd1e059
Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents:
19899
diff
changeset
|
271 | g_free(js->old_source); |
|
497e1cd1e059
Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents:
19899
diff
changeset
|
272 | g_free(js->old_uri); |
|
497e1cd1e059
Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents:
19899
diff
changeset
|
273 | g_free(js->old_track); |
|
17800
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
274 | js->old_artist = g_strdup(artist); |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
275 | js->old_title = g_strdup(title); |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
276 | js->old_source = g_strdup(source); |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
277 | js->old_uri = g_strdup(uri); |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
278 | js->old_length = length; |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
279 | js->old_track = g_strdup(track); |
| 10189 | 280 | } |
| 281 | ||
|
19899
483c4f495a6c
Various warning fixes for the xmpp prpl.
Daniel Atallah <datallah@pidgin.im>
parents:
19897
diff
changeset
|
282 | #undef CHANGED |
| 8185 | 283 | |
| 9954 | 284 | jabber_presence_fake_to_self(js, status); |
| 7014 | 285 | } |
| 286 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
287 | PurpleXmlNode *jabber_presence_create_js(JabberStream *js, JabberBuddyState state, const char *msg, int priority) |
| 7014 | 288 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
289 | PurpleXmlNode *show, *status, *presence, *pri, *c; |
| 9954 | 290 | const char *show_string = NULL; |
| 7014 | 291 | |
|
37659
19605664e064
Make explicit that we expect js to not be NULL
Jorge Villaseñor <salinasv@pidgin.im>
parents:
37423
diff
changeset
|
292 | g_return_val_if_fail(js !=NULL, NULL); |
|
19605664e064
Make explicit that we expect js to not be NULL
Jorge Villaseñor <salinasv@pidgin.im>
parents:
37423
diff
changeset
|
293 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
294 | presence = purple_xmlnode_new("presence"); |
| 7014 | 295 | |
| 9954 | 296 | if(state == JABBER_BUDDY_STATE_UNAVAILABLE) |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
297 | purple_xmlnode_set_attrib(presence, "type", "unavailable"); |
| 9954 | 298 | else if(state != JABBER_BUDDY_STATE_ONLINE && |
| 299 | state != JABBER_BUDDY_STATE_UNKNOWN && | |
| 300 | state != JABBER_BUDDY_STATE_ERROR) | |
| 12683 | 301 | show_string = jabber_buddy_state_get_show(state); |
| 9954 | 302 | |
| 303 | if(show_string) { | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
304 | show = purple_xmlnode_new_child(presence, "show"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
305 | purple_xmlnode_insert_data(show, show_string, -1); |
| 7014 | 306 | } |
| 307 | ||
| 9954 | 308 | if(msg) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
309 | status = purple_xmlnode_new_child(presence, "status"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
310 | purple_xmlnode_insert_data(status, msg, -1); |
| 7014 | 311 | } |
| 312 | ||
| 11568 | 313 | if(priority) { |
| 314 | char *pstr = g_strdup_printf("%d", priority); | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
315 | pri = purple_xmlnode_new_child(presence, "priority"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
316 | purple_xmlnode_insert_data(pri, pstr, -1); |
| 11568 | 317 | g_free(pstr); |
| 318 | } | |
| 319 | ||
| 25229 | 320 | /* if we are idle and not offline, include idle */ |
| 321 | if (js->idle && state != JABBER_BUDDY_STATE_UNAVAILABLE) { | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
322 | PurpleXmlNode *query = purple_xmlnode_new_child(presence, "query"); |
| 25229 | 323 | gchar seconds[10]; |
| 324 | g_snprintf(seconds, 10, "%d", (int) (time(NULL) - js->idle)); | |
|
27155
53502d71efdd
Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents:
27145
diff
changeset
|
325 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
326 | purple_xmlnode_set_namespace(query, NS_LAST_ACTIVITY); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
327 | purple_xmlnode_set_attrib(query, "seconds", seconds); |
| 25229 | 328 | } |
|
26958
a955bd42f529
propagate from branch 'im.pidgin.pidgin' (head 36f75a1d52a6af5574bf847d60054a1392dcbc67)
Paul Aurich <darkrain42@pidgin.im>
diff
changeset
|
329 | |
| 13385 | 330 | /* JEP-0115 */ |
|
23595
728a8a576f11
* correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23591
diff
changeset
|
331 | /* calculate hash */ |
|
728a8a576f11
* correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23591
diff
changeset
|
332 | jabber_caps_calculate_own_hash(js); |
|
728a8a576f11
* correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23591
diff
changeset
|
333 | /* create xml */ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
334 | c = purple_xmlnode_new_child(presence, "c"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
335 | purple_xmlnode_set_namespace(c, "http://jabber.org/protocol/caps"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
336 | purple_xmlnode_set_attrib(c, "node", CAPS0115_NODE); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
337 | purple_xmlnode_set_attrib(c, "hash", "sha-1"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
338 | purple_xmlnode_set_attrib(c, "ver", jabber_caps_get_own_hash(js)); |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25154
diff
changeset
|
339 | |
| 7014 | 340 | return presence; |
| 341 | } | |
| 342 | ||
| 343 | struct _jabber_add_permit { | |
| 15884 | 344 | PurpleConnection *gc; |
| 12285 | 345 | JabberStream *js; |
| 7014 | 346 | char *who; |
| 347 | }; | |
| 348 | ||
|
41514
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41248
diff
changeset
|
349 | static void |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41248
diff
changeset
|
350 | authorize_add_cb(G_GNUC_UNUSED PurpleAuthorizationRequest *request, |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41248
diff
changeset
|
351 | gpointer data) |
| 7014 | 352 | { |
|
19335
4613b53d5741
Warning fixes in the aftermath of resiak's authorize_cb and deny_cb type fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
18991
diff
changeset
|
353 | struct _jabber_add_permit *jap = data; |
|
36068
e9b9320a985a
Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
354 | |
|
e9b9320a985a
Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
355 | PURPLE_ASSERT_CONNECTION_IS_VALID(jap->gc); |
|
e9b9320a985a
Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
356 | |
|
e9b9320a985a
Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
357 | jabber_presence_subscription_set(purple_connection_get_protocol_data(jap->gc), |
|
e9b9320a985a
Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
358 | jap->who, "subscribed"); |
|
e9b9320a985a
Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
359 | |
| 7014 | 360 | g_free(jap->who); |
| 361 | g_free(jap); | |
| 362 | } | |
| 363 | ||
|
41514
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41248
diff
changeset
|
364 | static void |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41248
diff
changeset
|
365 | deny_add_cb(G_GNUC_UNUSED PurpleAuthorizationRequest *request, |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41248
diff
changeset
|
366 | const char *message, gpointer data) |
| 7014 | 367 | { |
|
19335
4613b53d5741
Warning fixes in the aftermath of resiak's authorize_cb and deny_cb type fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
18991
diff
changeset
|
368 | struct _jabber_add_permit *jap = data; |
|
36068
e9b9320a985a
Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
369 | |
|
e9b9320a985a
Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
370 | PURPLE_ASSERT_CONNECTION_IS_VALID(jap->gc); |
|
e9b9320a985a
Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
371 | |
|
e9b9320a985a
Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
372 | jabber_presence_subscription_set(purple_connection_get_protocol_data(jap->gc), |
|
e9b9320a985a
Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
373 | jap->who, "unsubscribed"); |
|
e9b9320a985a
Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
374 | |
| 7014 | 375 | g_free(jap->who); |
| 376 | g_free(jap); | |
| 377 | } | |
| 378 | ||
|
26687
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
379 | static void |
|
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
380 | jabber_vcard_parse_avatar(JabberStream *js, const char *from, |
|
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
381 | JabberIqType type, const char *id, |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
382 | PurpleXmlNode *packet, gpointer blah) |
| 10189 | 383 | { |
| 10941 | 384 | JabberBuddy *jb = NULL; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
385 | PurpleXmlNode *vcard, *photo, *binval, *fn, *nick; |
|
11127
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
11013
diff
changeset
|
386 | char *text; |
| 10189 | 387 | |
| 388 | if(!from) | |
| 389 | return; | |
| 390 | ||
| 10941 | 391 | jb = jabber_buddy_find(js, from, TRUE); |
| 392 | ||
| 393 | js->pending_avatar_requests = g_slist_remove(js->pending_avatar_requests, jb); | |
| 394 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
395 | if((vcard = purple_xmlnode_get_child(packet, "vCard")) || |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
396 | (vcard = purple_xmlnode_get_child_with_namespace(packet, "query", "vcard-temp"))) { |
|
27006
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
397 | /* The logic here regarding the nickname and full name is copied from |
|
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
398 | * buddy.c:jabber_vcard_parse. */ |
|
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
399 | gchar *nickname = NULL; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
400 | if ((fn = purple_xmlnode_get_child(vcard, "FN"))) |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
401 | nickname = purple_xmlnode_get_data(fn); |
|
27006
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
402 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
403 | if ((nick = purple_xmlnode_get_child(vcard, "NICKNAME"))) { |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
404 | char *tmp = purple_xmlnode_get_data(nick); |
|
27006
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
405 | char *bare_jid = jabber_get_bare_jid(from); |
|
27145
f34175723f73
Fix a crash when <NICKNAME/> is present in a vcard, but has no data.
Paul Aurich <darkrain42@pidgin.im>
parents:
27103
diff
changeset
|
406 | if (tmp && strstr(bare_jid, tmp) == NULL) { |
|
27006
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
407 | g_free(nickname); |
|
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
408 | nickname = tmp; |
|
37423
d2f0259aa43f
Remove NULL-checks before free(). No functional change.
Michael McConville <mmcco@mykolab.com>
parents:
37238
diff
changeset
|
409 | } else |
|
27006
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
410 | g_free(tmp); |
|
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
411 | |
|
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
412 | g_free(bare_jid); |
|
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
413 | } |
|
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
414 | |
|
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
415 | if (nickname) { |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
34999
diff
changeset
|
416 | purple_serv_got_alias(js->gc, from, nickname); |
|
27006
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
417 | g_free(nickname); |
|
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
418 | } |
|
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
419 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
420 | if ((photo = purple_xmlnode_get_child(vcard, "PHOTO"))) { |
|
31736
d7d283b25b0b
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
Matthew W. S. Bell <matthew@bells23.org.uk>
parents:
31445
diff
changeset
|
421 | guchar *data = NULL; |
|
d7d283b25b0b
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
Matthew W. S. Bell <matthew@bells23.org.uk>
parents:
31445
diff
changeset
|
422 | gchar *hash = NULL; |
|
d7d283b25b0b
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
Matthew W. S. Bell <matthew@bells23.org.uk>
parents:
31445
diff
changeset
|
423 | gsize size = 0; |
|
16534
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16018
diff
changeset
|
424 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
425 | if ((binval = purple_xmlnode_get_child(photo, "BINVAL")) && |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
426 | (text = purple_xmlnode_get_data(binval))) { |
|
38341
3da74e727e78
Remove purple_base64_encode/decode() wrappers
Mike Ruprecht <cmaiku@gmail.com>
parents:
38327
diff
changeset
|
427 | data = g_base64_decode(text, &size); |
|
31736
d7d283b25b0b
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
Matthew W. S. Bell <matthew@bells23.org.uk>
parents:
31445
diff
changeset
|
428 | g_free(text); |
|
d7d283b25b0b
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
Matthew W. S. Bell <matthew@bells23.org.uk>
parents:
31445
diff
changeset
|
429 | |
|
39920
f2980266abbd
Fix checksumming of Jabber avatars.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39897
diff
changeset
|
430 | if (data) { |
|
f2980266abbd
Fix checksumming of Jabber avatars.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39897
diff
changeset
|
431 | hash = g_compute_checksum_for_data(G_CHECKSUM_SHA1, data, |
|
f2980266abbd
Fix checksumming of Jabber avatars.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39897
diff
changeset
|
432 | size); |
|
f2980266abbd
Fix checksumming of Jabber avatars.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39897
diff
changeset
|
433 | } |
|
28611
156e0b180d48
jabber: Don't try to pull a photo out of the <PHOTO/> cdata.
Paul Aurich <darkrain42@pidgin.im>
parents:
28341
diff
changeset
|
434 | } |
| 10189 | 435 | |
|
32678
01f6312a4a7b
On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents:
32595
diff
changeset
|
436 | purple_buddy_icons_set_for_user(purple_connection_get_account(js->gc), from, data, size, hash); |
|
31736
d7d283b25b0b
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
Matthew W. S. Bell <matthew@bells23.org.uk>
parents:
31445
diff
changeset
|
437 | |
|
d7d283b25b0b
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
Matthew W. S. Bell <matthew@bells23.org.uk>
parents:
31445
diff
changeset
|
438 | g_free(hash); |
| 10189 | 439 | } |
| 440 | } | |
| 441 | } | |
| 442 | ||
|
39556
622bf98df0ac
Remove unnecessary struct tags.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38854
diff
changeset
|
443 | typedef struct { |
|
17816
1b7362b4a7a2
Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
17812
diff
changeset
|
444 | JabberStream *js; |
|
22929
f1860f6e1344
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents:
22622
diff
changeset
|
445 | JabberBuddy *jb; |
|
17816
1b7362b4a7a2
Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
17812
diff
changeset
|
446 | char *from; |
|
1b7362b4a7a2
Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
17812
diff
changeset
|
447 | } JabberPresenceCapabilities; |
|
1b7362b4a7a2
Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
17812
diff
changeset
|
448 | |
|
24880
ae4e8598d0bf
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents:
24878
diff
changeset
|
449 | static void |
|
ae4e8598d0bf
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents:
24878
diff
changeset
|
450 | jabber_presence_set_capabilities(JabberCapsClientInfo *info, GList *exts, |
|
ae4e8598d0bf
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents:
24878
diff
changeset
|
451 | JabberPresenceCapabilities *userdata) |
|
24719
80121be525d4
Rewrite jabber_presence_set_capabilities a little
Paul Aurich <darkrain42@pidgin.im>
parents:
24717
diff
changeset
|
452 | { |
|
22929
f1860f6e1344
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents:
22622
diff
changeset
|
453 | JabberBuddyResource *jbr; |
|
29059
8225f2507058
strchr() is safe when searching for an ASCII character in UTF8 strings.
Paul Aurich <darkrain42@pidgin.im>
parents:
29018
diff
changeset
|
454 | char *resource = strchr(userdata->from, '/'); |
|
21801
6d92632a6424
Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <datallah@pidgin.im>
parents:
21758
diff
changeset
|
455 | |
|
27066
6c1375ed1e59
Don't crash when resource is NULL. Thanks, Marcus!
Paul Aurich <darkrain42@pidgin.im>
parents:
27007
diff
changeset
|
456 | if (resource) |
|
6c1375ed1e59
Don't crash when resource is NULL. Thanks, Marcus!
Paul Aurich <darkrain42@pidgin.im>
parents:
27007
diff
changeset
|
457 | resource += 1; |
|
22929
f1860f6e1344
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents:
22622
diff
changeset
|
458 | |
|
24719
80121be525d4
Rewrite jabber_presence_set_capabilities a little
Paul Aurich <darkrain42@pidgin.im>
parents:
24717
diff
changeset
|
459 | jbr = jabber_buddy_find_resource(userdata->jb, resource); |
|
80121be525d4
Rewrite jabber_presence_set_capabilities a little
Paul Aurich <darkrain42@pidgin.im>
parents:
24717
diff
changeset
|
460 | if (!jbr) { |
|
22929
f1860f6e1344
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents:
22622
diff
changeset
|
461 | g_free(userdata->from); |
|
f1860f6e1344
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents:
22622
diff
changeset
|
462 | g_free(userdata); |
|
39897
16b440d4ab36
Use g_list_free_full instead of g_list_foreach+g_list_free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39557
diff
changeset
|
463 | g_list_free_full(exts, g_free); |
|
22929
f1860f6e1344
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents:
22622
diff
changeset
|
464 | return; |
|
f1860f6e1344
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents:
22622
diff
changeset
|
465 | } |
|
f1860f6e1344
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents:
22622
diff
changeset
|
466 | |
|
24882
7e842d8123e8
Partial disapproval of 19969457944c4807924bcde3090063b23d35ba17
Paul Aurich <darkrain42@pidgin.im>
parents:
24880
diff
changeset
|
467 | /* Any old jbr->caps.info is owned by the caps code */ |
|
39897
16b440d4ab36
Use g_list_free_full instead of g_list_foreach+g_list_free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39557
diff
changeset
|
468 | g_list_free_full(jbr->caps.exts, g_free); |
|
21801
6d92632a6424
Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <datallah@pidgin.im>
parents:
21758
diff
changeset
|
469 | |
|
24880
ae4e8598d0bf
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents:
24878
diff
changeset
|
470 | jbr->caps.info = info; |
|
ae4e8598d0bf
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents:
24878
diff
changeset
|
471 | jbr->caps.exts = exts; |
|
21801
6d92632a6424
Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <datallah@pidgin.im>
parents:
21758
diff
changeset
|
472 | |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36362
diff
changeset
|
473 | purple_protocol_got_media_caps( |
|
29548
e861ed14c1e1
Declare XMPP got media caps in the correct place.
Michael Ruprecht <maiku@pidgin.im>
parents:
29545
diff
changeset
|
474 | purple_connection_get_account(userdata->js->gc), |
|
e861ed14c1e1
Declare XMPP got media caps in the correct place.
Michael Ruprecht <maiku@pidgin.im>
parents:
29545
diff
changeset
|
475 | userdata->from); |
|
27750
f25b6a565494
Use Entity Capabilities to pick up Chat States support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents:
27747
diff
changeset
|
476 | if (info == NULL) |
|
f25b6a565494
Use Entity Capabilities to pick up Chat States support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents:
27747
diff
changeset
|
477 | goto out; |
|
f25b6a565494
Use Entity Capabilities to pick up Chat States support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents:
27747
diff
changeset
|
478 | |
|
27073
09bf5e6921e4
Only try to fetch adhoc commands from buddies once. Pushed updates (which we support now) are far superior.
Paul Aurich <darkrain42@pidgin.im>
parents:
27068
diff
changeset
|
479 | if (!jbr->commands_fetched && jabber_resource_has_capability(jbr, "http://jabber.org/protocol/commands")) { |
|
28984
1d84517d56eb
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents:
28832
diff
changeset
|
480 | JabberIq *iq = jabber_iq_new_query(userdata->js, JABBER_IQ_GET, NS_DISCO_ITEMS); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
481 | PurpleXmlNode *query = purple_xmlnode_get_child_with_namespace(iq->node, "query", NS_DISCO_ITEMS); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
482 | purple_xmlnode_set_attrib(iq->node, "to", userdata->from); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
483 | purple_xmlnode_set_attrib(query, "node", "http://jabber.org/protocol/commands"); |
|
24802
eb481e98ac6a
Sprinkle jabber_resource_has_capability in places
Paul Aurich <darkrain42@pidgin.im>
parents:
24741
diff
changeset
|
484 | jabber_iq_set_callback(iq, jabber_adhoc_disco_result_cb, NULL); |
|
eb481e98ac6a
Sprinkle jabber_resource_has_capability in places
Paul Aurich <darkrain42@pidgin.im>
parents:
24741
diff
changeset
|
485 | jabber_iq_send(iq); |
|
21801
6d92632a6424
Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <datallah@pidgin.im>
parents:
21758
diff
changeset
|
486 | |
|
27073
09bf5e6921e4
Only try to fetch adhoc commands from buddies once. Pushed updates (which we support now) are far superior.
Paul Aurich <darkrain42@pidgin.im>
parents:
27068
diff
changeset
|
487 | jbr->commands_fetched = TRUE; |
|
17816
1b7362b4a7a2
Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
17812
diff
changeset
|
488 | } |
|
21801
6d92632a6424
Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <datallah@pidgin.im>
parents:
21758
diff
changeset
|
489 | |
|
27750
f25b6a565494
Use Entity Capabilities to pick up Chat States support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents:
27747
diff
changeset
|
490 | out: |
|
20210
d3336754b1a9
applied changes from d50ecf4dc52f25cbd219d6c19846436dec5a8853
Luke Schierer <lschiere@pidgin.im>
parents:
20169
diff
changeset
|
491 | g_free(userdata->from); |
|
d3336754b1a9
applied changes from d50ecf4dc52f25cbd219d6c19846436dec5a8853
Luke Schierer <lschiere@pidgin.im>
parents:
20169
diff
changeset
|
492 | g_free(userdata); |
|
17816
1b7362b4a7a2
Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
17812
diff
changeset
|
493 | } |
|
1b7362b4a7a2
Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
17812
diff
changeset
|
494 | |
|
29885
d58d8fd70c25
jabber: Fix two warnings (which didn't occur on OS X, oddly)
Paul Aurich <darkrain42@pidgin.im>
parents:
29848
diff
changeset
|
495 | static gboolean |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
496 | handle_presence_chat(JabberStream *js, JabberPresence *presence, PurpleXmlNode *packet) |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
497 | { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
498 | static int i = 1; |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34653
diff
changeset
|
499 | PurpleChatUserFlags flags = PURPLE_CHAT_USER_NONE; |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
500 | JabberChat *chat = presence->chat; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
501 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
502 | if (presence->state == JABBER_BUDDY_STATE_ERROR) { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
503 | char *title, *msg = jabber_parse_error(js, packet, NULL); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
504 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
505 | if (!chat->conv) { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
506 | title = g_strdup_printf(_("Error joining chat %s"), presence->from); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
507 | purple_serv_got_join_chat_failed(js->gc, chat->components); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
508 | } else { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
509 | title = g_strdup_printf(_("Error in chat %s"), presence->from); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
510 | if (g_hash_table_size(chat->members) == 0) |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
34999
diff
changeset
|
511 | purple_serv_got_chat_left(js->gc, chat->id); |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
512 | } |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34331
diff
changeset
|
513 | purple_notify_error(js->gc, title, title, msg, |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34331
diff
changeset
|
514 | purple_request_cpar_from_connection(js->gc)); |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
515 | g_free(title); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
516 | g_free(msg); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
517 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
518 | if (g_hash_table_size(chat->members) == 0) |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
519 | /* Only destroy the chat if the error happened while joining */ |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
520 | jabber_chat_destroy(chat); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
521 | return FALSE; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
522 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
523 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
524 | if (presence->type == JABBER_PRESENCE_AVAILABLE) { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
525 | const char *jid = NULL; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
526 | const char *affiliation = NULL; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
527 | const char *role = NULL; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
528 | gboolean is_our_resource = FALSE; /* Is the presence about us? */ |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
529 | JabberBuddyResource *jbr; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
530 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
531 | /* |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
532 | * XEP-0045 mandates the presence to include a resource (which is |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
533 | * treated as the chat nick). Some non-compliant servers allow |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
534 | * joining without a nick. |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
535 | */ |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
536 | if (!presence->jid_from->resource) |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
537 | return FALSE; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
538 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
539 | if (presence->chat_info.item) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
540 | jid = purple_xmlnode_get_attrib(presence->chat_info.item, "jid"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
541 | affiliation = purple_xmlnode_get_attrib(presence->chat_info.item, "affiliation"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
542 | role = purple_xmlnode_get_attrib(presence->chat_info.item, "role"); |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
543 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
544 | |
|
31445
a574e4e63b36
jabber: Compatibility with older servers
Paul Aurich <darkrain42@pidgin.im>
parents:
31442
diff
changeset
|
545 | if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(110)) || |
|
38256
035f00c4fd87
Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
36256
diff
changeset
|
546 | purple_strequal(presence->jid_from->resource, chat->handle) || |
|
31445
a574e4e63b36
jabber: Compatibility with older servers
Paul Aurich <darkrain42@pidgin.im>
parents:
31442
diff
changeset
|
547 | purple_strequal(presence->to, jid)) |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
548 | is_our_resource = TRUE; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
549 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
550 | if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(201))) { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
551 | chat->config_dialog_type = PURPLE_REQUEST_ACTION; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
552 | chat->config_dialog_handle = |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
553 | purple_request_action(js->gc, |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
554 | _("Create New Room"), |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
555 | _("Create New Room"), |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
556 | _("You are creating a new room. Would" |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
557 | " you like to configure it, or" |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
558 | " accept the default settings?"), |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
559 | /* Default Action */ 1, |
| 34945 | 560 | purple_request_cpar_from_conversation(PURPLE_CONVERSATION(chat->conv)), |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
561 | chat, 2, |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
562 | _("_Configure Room"), G_CALLBACK(jabber_chat_request_room_configure), |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
563 | _("_Accept Defaults"), G_CALLBACK(jabber_chat_create_instant_room)); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
564 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
565 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
566 | if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(210))) { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
567 | /* server rewrote room-nick */ |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
568 | g_free(chat->handle); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
569 | chat->handle = g_strdup(presence->jid_from->resource); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
570 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
571 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
572 | if (purple_strequal(affiliation, "owner")) |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34653
diff
changeset
|
573 | flags |= PURPLE_CHAT_USER_FOUNDER; |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
574 | if (role) { |
|
38256
035f00c4fd87
Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
36256
diff
changeset
|
575 | if (purple_strequal(role, "moderator")) |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34653
diff
changeset
|
576 | flags |= PURPLE_CHAT_USER_OP; |
|
38256
035f00c4fd87
Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
36256
diff
changeset
|
577 | else if (purple_strequal(role, "participant")) |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34653
diff
changeset
|
578 | flags |= PURPLE_CHAT_USER_VOICE; |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
579 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
580 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
581 | if(!chat->conv) { |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
582 | PurpleConversation *conv; |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
583 | char *room_jid = g_strdup_printf("%s@%s", presence->jid_from->node, presence->jid_from->domain); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
584 | chat->id = i++; |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
585 | conv = purple_serv_got_joined_chat(js->gc, chat->id, room_jid); |
|
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
586 | chat->conv = PURPLE_CHAT_CONVERSATION(conv); |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
587 | purple_chat_conversation_set_nick(chat->conv, chat->handle); |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
588 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
589 | jabber_chat_disco_traffic(chat); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
590 | g_free(room_jid); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
591 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
592 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
593 | jbr = jabber_buddy_track_resource(presence->jb, presence->jid_from->resource, presence->priority, presence->state, presence->status); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
594 | jbr->commands_fetched = TRUE; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
595 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
596 | jabber_chat_track_handle(chat, presence->jid_from->resource, jid, affiliation, role); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
597 | |
|
41244
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
598 | if(!jabber_chat_find_buddy(chat->conv, presence->jid_from->resource)) { |
|
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
599 | gboolean new_arrival = FALSE; |
|
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
600 | |
|
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
601 | if(chat->joined != NULL) { |
|
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
602 | gint newer = -1; |
|
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
603 | |
|
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
604 | if(presence->sent != NULL) { |
|
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
605 | newer = g_date_time_compare(presence->sent, chat->joined); |
|
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
606 | } |
|
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
607 | |
|
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
608 | if(!presence->delayed || newer > 0) { |
|
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
609 | new_arrival = TRUE; |
|
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
610 | } |
|
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
611 | } |
|
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
612 | |
|
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
613 | purple_chat_conversation_add_user(chat->conv, |
|
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
614 | presence->jid_from->resource, |
|
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
615 | jid, flags, new_arrival); |
|
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
616 | } else { |
|
34671
ca9b45be7a63
Renamed chat buddy to chat user in a few more places
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
617 | purple_chat_user_set_flags(purple_chat_conversation_find_user(chat->conv, presence->jid_from->resource), |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
618 | flags); |
|
41244
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
619 | } |
|
31442
fd16ffae2043
jabber: Treat the presence storm on joining a room as not new arrivals.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
31441
diff
changeset
|
620 | |
|
41244
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
621 | if (is_our_resource && chat->joined == NULL) { |
|
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
622 | chat->joined = g_date_time_new_now_utc(); |
|
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
623 | } |
|
31442
fd16ffae2043
jabber: Treat the presence storm on joining a room as not new arrivals.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
31441
diff
changeset
|
624 | |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
625 | } else if (presence->type == JABBER_PRESENCE_UNAVAILABLE) { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
626 | gboolean nick_change = FALSE; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
627 | gboolean kick = FALSE; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
628 | gboolean is_our_resource = FALSE; /* Is the presence about us? */ |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
629 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
630 | const char *jid = NULL; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
631 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
632 | /* If the chat nick is invalid, we haven't yet joined, or we've |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
633 | * already left (it was probably us leaving after we closed the |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
634 | * chat), we don't care. |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
635 | */ |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
636 | if (!presence->jid_from->resource || !chat->conv || chat->left) { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
637 | if (chat->left && |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
638 | presence->jid_from->resource && chat->handle && purple_strequal(presence->jid_from->resource, chat->handle)) |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
639 | jabber_chat_destroy(chat); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
640 | return FALSE; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
641 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
642 | |
|
38256
035f00c4fd87
Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
36256
diff
changeset
|
643 | is_our_resource = purple_strequal(presence->jid_from->resource, chat->handle); |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
644 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
645 | jabber_buddy_remove_resource(presence->jb, presence->jid_from->resource); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
646 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
647 | if (presence->chat_info.item) |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
648 | jid = purple_xmlnode_get_attrib(presence->chat_info.item, "jid"); |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
649 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
650 | if (chat->muc) { |
|
31442
fd16ffae2043
jabber: Treat the presence storm on joining a room as not new arrivals.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
31441
diff
changeset
|
651 | if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(110))) { |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
652 | is_our_resource = TRUE; |
|
31442
fd16ffae2043
jabber: Treat the presence storm on joining a room as not new arrivals.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
31441
diff
changeset
|
653 | chat->joined = 0; |
|
fd16ffae2043
jabber: Treat the presence storm on joining a room as not new arrivals.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
31441
diff
changeset
|
654 | } |
|
29886
a663cae92ce0
jabber: Proper memory management (and fix a segfault) and whitespace
Paul Aurich <darkrain42@pidgin.im>
parents:
29885
diff
changeset
|
655 | |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
656 | if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(301))) { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
657 | /* XXX: We got banned. YAY! (No GIR, that's bad) */ |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
658 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
659 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
660 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
661 | if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(303))) { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
662 | const char *nick = NULL; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
663 | if (presence->chat_info.item) |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
664 | nick = purple_xmlnode_get_attrib(presence->chat_info.item, "nick"); |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
665 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
666 | /* nick change */ |
|
29945
2513f9f8b101
jabber: Whoops. Nick changes are supposed to actually work...
Paul Aurich <darkrain42@pidgin.im>
parents:
29910
diff
changeset
|
667 | if (!nick) { |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
668 | purple_debug_warning("jabber", "Chat presence indicating a nick change, but no new nickname!\n"); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
669 | } else { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
670 | nick_change = TRUE; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
671 | |
|
38256
035f00c4fd87
Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
36256
diff
changeset
|
672 | if (purple_strequal(presence->jid_from->resource, chat->handle)) { |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
673 | /* Changing our own nickname */ |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
674 | g_free(chat->handle); |
|
31441
84ef3d484bd4
jabber: Use a straight equality check instead of collate
Paul Aurich <darkrain42@pidgin.im>
parents:
31096
diff
changeset
|
675 | /* TODO: This should be resourceprep'd */ |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
676 | chat->handle = g_strdup(nick); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
677 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
678 | |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
679 | purple_chat_conversation_rename_user(chat->conv, |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
680 | presence->jid_from->resource, |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
681 | nick); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
682 | jabber_chat_remove_handle(chat, |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
683 | presence->jid_from->resource); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
684 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
685 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
686 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
687 | if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(307))) { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
688 | /* Someone was kicked from the room */ |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
689 | const char *actor = NULL; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
690 | char *reason = NULL; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
691 | char *tmp; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
692 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
693 | kick = TRUE; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
694 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
695 | if (presence->chat_info.item) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
696 | PurpleXmlNode *node; |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
697 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
698 | node = purple_xmlnode_get_child(presence->chat_info.item, "actor"); |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
699 | if (node) |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
700 | actor = purple_xmlnode_get_attrib(node, "jid"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
701 | node = purple_xmlnode_get_child(presence->chat_info.item, "reason"); |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
702 | if (node) |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
703 | reason = purple_xmlnode_get_data(node); |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
704 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
705 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
706 | if (reason == NULL) |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
707 | reason = g_strdup(_("No reason")); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
708 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
709 | if (is_our_resource) { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
710 | if (actor) |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
711 | tmp = g_strdup_printf(_("You have been kicked by %s: (%s)"), |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
712 | actor, reason); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
713 | else |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
714 | tmp = g_strdup_printf(_("You have been kicked: (%s)"), |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
715 | reason); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
716 | } else { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
717 | if (actor) |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
718 | tmp = g_strdup_printf(_("Kicked by %s (%s)"), |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
719 | actor, reason); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
720 | else |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
721 | tmp = g_strdup_printf(_("Kicked (%s)"), |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
722 | reason); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
723 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
724 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
725 | g_free(presence->status); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
726 | presence->status = tmp; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
727 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
728 | g_free(reason); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
729 | } |
|
29886
a663cae92ce0
jabber: Proper memory management (and fix a segfault) and whitespace
Paul Aurich <darkrain42@pidgin.im>
parents:
29885
diff
changeset
|
730 | |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
731 | if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(321))) { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
732 | /* XXX: removed due to an affiliation change */ |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
733 | } |
|
29886
a663cae92ce0
jabber: Proper memory management (and fix a segfault) and whitespace
Paul Aurich <darkrain42@pidgin.im>
parents:
29885
diff
changeset
|
734 | |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
735 | if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(322))) { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
736 | /* XXX: removed because room is now members-only */ |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
737 | } |
|
29886
a663cae92ce0
jabber: Proper memory management (and fix a segfault) and whitespace
Paul Aurich <darkrain42@pidgin.im>
parents:
29885
diff
changeset
|
738 | |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
739 | if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(332))) { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
740 | /* XXX: removed due to system shutdown */ |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
741 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
742 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
743 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
744 | /* |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
745 | * Possibly another connected resource of our JID (see XEP-0045 |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
746 | * v1.24 section 7.1.10) being disconnected. Should be |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
747 | * distinguished by the item_jid. |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
748 | * Also possibly works around bits of an Openfire bug. See |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
749 | * #8319. |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
750 | */ |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
751 | if (is_our_resource && jid && !purple_strequal(presence->to, jid)) { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
752 | /* TODO: When the above is a loop, this needs to still act |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
753 | * sanely for all cases (this code is a little fragile). */ |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
754 | if (!kick && !nick_change) |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
755 | /* Presumably, kicks and nick changes also affect us. */ |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
756 | is_our_resource = FALSE; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
757 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
758 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
759 | if(!nick_change) { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
760 | if (is_our_resource) { |
|
36088
4c386387f6f3
Switch purple_conversation_write_message to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36068
diff
changeset
|
761 | if (kick) { |
|
4c386387f6f3
Switch purple_conversation_write_message to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36068
diff
changeset
|
762 | gchar *msg = g_strdup_printf("%s: %s", |
|
4c386387f6f3
Switch purple_conversation_write_message to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36068
diff
changeset
|
763 | presence->jid_from->resource, |
|
4c386387f6f3
Switch purple_conversation_write_message to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36068
diff
changeset
|
764 | presence->status); |
|
4c386387f6f3
Switch purple_conversation_write_message to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36068
diff
changeset
|
765 | purple_conversation_write_system_message(PURPLE_CONVERSATION(chat->conv), msg, 0); |
|
4c386387f6f3
Switch purple_conversation_write_message to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36068
diff
changeset
|
766 | } |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
767 | |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
34999
diff
changeset
|
768 | purple_serv_got_chat_left(js->gc, chat->id); |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
769 | jabber_chat_destroy(chat); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
770 | } else { |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
771 | purple_chat_conversation_remove_user(chat->conv, presence->jid_from->resource, |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
772 | presence->status); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
773 | jabber_chat_remove_handle(chat, presence->jid_from->resource); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
774 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
775 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
776 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
777 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
778 | return TRUE; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
779 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
780 | |
|
29885
d58d8fd70c25
jabber: Fix two warnings (which didn't occur on OS X, oddly)
Paul Aurich <darkrain42@pidgin.im>
parents:
29848
diff
changeset
|
781 | static gboolean |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
782 | handle_presence_contact(JabberStream *js, JabberPresence *presence) |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
783 | { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
784 | JabberBuddyResource *jbr; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
785 | PurpleAccount *account; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
786 | PurpleBuddy *b; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
787 | char *buddy_name; |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
788 | PurpleConversation *im; |
|
40997
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40885
diff
changeset
|
789 | PurpleConversationManager *manager; |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
790 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
791 | buddy_name = jabber_id_get_bare_jid(presence->jid_from); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
792 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
793 | account = purple_connection_get_account(js->gc); |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34671
diff
changeset
|
794 | b = purple_blist_find_buddy(account, buddy_name); |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
795 | |
|
40997
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40885
diff
changeset
|
796 | manager = purple_conversation_manager_get_default(); |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
797 | /* |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
798 | * Unbind/unlock from sending messages to a specific resource on |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
799 | * presence changes. This is locked to a specific resource when |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
800 | * receiving a message (in message.c). |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
801 | */ |
|
40997
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40885
diff
changeset
|
802 | im = purple_conversation_manager_find_im(manager, account, buddy_name); |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
803 | if (im) { |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
804 | purple_debug_info("jabber", "Changed conversation binding from %s to %s\n", |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
805 | purple_conversation_get_name(im), buddy_name); |
|
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
806 | purple_conversation_set_name(im, buddy_name); |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
807 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
808 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
809 | if (b == NULL) { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
810 | if (presence->jb != js->user_jb) { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
811 | purple_debug_warning("jabber", "Got presence for unknown buddy %s on account %s (%p)\n", |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
812 | buddy_name, purple_account_get_username(account), account); |
|
30042
1f9ef63d40f7
jabber: Don't leak the buddy_name on this error
Paul Aurich <darkrain42@pidgin.im>
parents:
29945
diff
changeset
|
813 | g_free(buddy_name); |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
814 | return FALSE; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
815 | } else { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
816 | /* this is a different resource of our own account. Resume even when this account isn't on our blist */ |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
817 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
818 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
819 | |
|
31736
d7d283b25b0b
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
Matthew W. S. Bell <matthew@bells23.org.uk>
parents:
31445
diff
changeset
|
820 | if (b && presence->vcard_avatar_hash) { |
|
d7d283b25b0b
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
Matthew W. S. Bell <matthew@bells23.org.uk>
parents:
31445
diff
changeset
|
821 | const char *ah = presence->vcard_avatar_hash[0] != '\0' ? |
|
d7d283b25b0b
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
Matthew W. S. Bell <matthew@bells23.org.uk>
parents:
31445
diff
changeset
|
822 | presence->vcard_avatar_hash : NULL; |
|
d7d283b25b0b
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
Matthew W. S. Bell <matthew@bells23.org.uk>
parents:
31445
diff
changeset
|
823 | const char *ah2 = purple_buddy_icons_get_checksum_for_user(b); |
|
d7d283b25b0b
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
Matthew W. S. Bell <matthew@bells23.org.uk>
parents:
31445
diff
changeset
|
824 | if (!purple_strequal(ah, ah2)) { |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
825 | /* XXX this is a crappy way of trying to prevent |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
826 | * someone from spamming us with presence packets |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
827 | * and causing us to DoS ourselves...what we really |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
828 | * need is a queue system that can throttle itself, |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
829 | * but i'm too tired to write that right now */ |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
830 | if(!g_slist_find(js->pending_avatar_requests, presence->jb)) { |
|
31736
d7d283b25b0b
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
Matthew W. S. Bell <matthew@bells23.org.uk>
parents:
31445
diff
changeset
|
831 | JabberIq *iq; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
832 | PurpleXmlNode *vcard; |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
833 | |
|
31736
d7d283b25b0b
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
Matthew W. S. Bell <matthew@bells23.org.uk>
parents:
31445
diff
changeset
|
834 | js->pending_avatar_requests = |
|
d7d283b25b0b
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
Matthew W. S. Bell <matthew@bells23.org.uk>
parents:
31445
diff
changeset
|
835 | g_slist_prepend(js->pending_avatar_requests, presence->jb); |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
836 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
837 | iq = jabber_iq_new(js, JABBER_IQ_GET); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
838 | purple_xmlnode_set_attrib(iq->node, "to", buddy_name); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
839 | vcard = purple_xmlnode_new_child(iq->node, "vCard"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
840 | purple_xmlnode_set_namespace(vcard, "vcard-temp"); |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
841 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
842 | jabber_iq_set_callback(iq, jabber_vcard_parse_avatar, NULL); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
843 | jabber_iq_send(iq); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
844 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
845 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
846 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
847 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
848 | if (presence->state == JABBER_BUDDY_STATE_ERROR || |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
849 | presence->type == JABBER_PRESENCE_UNAVAILABLE || |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
850 | presence->type == JABBER_PRESENCE_UNSUBSCRIBED) { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
851 | jabber_buddy_remove_resource(presence->jb, presence->jid_from->resource); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
852 | } else { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
853 | jbr = jabber_buddy_track_resource(presence->jb, |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
854 | presence->jid_from->resource, presence->priority, |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
855 | presence->state, presence->status); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
856 | jbr->idle = presence->idle ? time(NULL) - presence->idle : 0; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
857 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
858 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
859 | jbr = jabber_buddy_find_resource(presence->jb, NULL); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
860 | if (jbr) { |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36362
diff
changeset
|
861 | purple_protocol_got_user_status(account, buddy_name, |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
862 | jabber_buddy_state_get_status_id(jbr->state), |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
863 | "priority", jbr->priority, |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
864 | "message", jbr->status, |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
865 | NULL); |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36362
diff
changeset
|
866 | purple_protocol_got_user_idle(account, buddy_name, |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
867 | jbr->idle, jbr->idle); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
868 | if (presence->nickname) |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
34999
diff
changeset
|
869 | purple_serv_got_alias(js->gc, buddy_name, presence->nickname); |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
870 | } else { |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36362
diff
changeset
|
871 | purple_protocol_got_user_status(account, buddy_name, |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
872 | jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_UNAVAILABLE), |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
873 | presence->status ? "message" : NULL, presence->status, |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
874 | NULL); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
875 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
876 | g_free(buddy_name); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
877 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
878 | return TRUE; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
879 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
880 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
881 | void jabber_presence_parse(JabberStream *js, PurpleXmlNode *packet) |
| 7014 | 882 | { |
|
27103
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
27073
diff
changeset
|
883 | const char *type; |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
884 | JabberBuddyResource *jbr = NULL; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
885 | gboolean signal_return, ret; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
886 | JabberPresence presence; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
887 | PurpleXmlNode *child; |
|
27103
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
27073
diff
changeset
|
888 | |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
889 | memset(&presence, 0, sizeof(presence)); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
890 | /* defaults */ |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
891 | presence.state = JABBER_BUDDY_STATE_UNKNOWN; |
|
41244
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
892 | presence.sent = g_date_time_new_now_utc(); |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
893 | /* interesting values */ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
894 | presence.from = purple_xmlnode_get_attrib(packet, "from"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
895 | presence.to = purple_xmlnode_get_attrib(packet, "to"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
896 | type = purple_xmlnode_get_attrib(packet, "type"); |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
897 | presence.type = str_to_presence_type(type); |
| 8043 | 898 | |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
899 | presence.jb = jabber_buddy_find(js, presence.from, TRUE); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
900 | g_return_if_fail(presence.jb != NULL); |
|
27103
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
27073
diff
changeset
|
901 | |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
902 | presence.jid_from = jabber_id_new(presence.from); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
903 | if (presence.jid_from == NULL) { |
|
27619
3600b7157ab7
Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents:
27618
diff
changeset
|
904 | purple_debug_error("jabber", "Ignoring presence with malformed 'from' " |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
905 | "JID: %s\n", presence.from); |
| 7280 | 906 | return; |
|
27619
3600b7157ab7
Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents:
27618
diff
changeset
|
907 | } |
| 7280 | 908 | |
|
36623
caaadef03507
Renamed purple_connection_get_protocol_info() to purple_connection_get_protocol()
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
909 | signal_return = GPOINTER_TO_INT(purple_signal_emit_return_1(purple_connection_get_protocol(js->gc), |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
910 | "jabber-receiving-presence", js->gc, type, presence.from, packet)); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
911 | if (signal_return) { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
912 | goto out; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
913 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
914 | |
|
30165
1002ebf2d580
jabber: Avoid an assertion failure for presence from bare domains
Paul Aurich <darkrain42@pidgin.im>
parents:
30042
diff
changeset
|
915 | if (presence.jid_from->node) |
|
1002ebf2d580
jabber: Avoid an assertion failure for presence from bare domains
Paul Aurich <darkrain42@pidgin.im>
parents:
30042
diff
changeset
|
916 | presence.chat = jabber_chat_find(js, presence.jid_from->node, |
|
1002ebf2d580
jabber: Avoid an assertion failure for presence from bare domains
Paul Aurich <darkrain42@pidgin.im>
parents:
30042
diff
changeset
|
917 | presence.jid_from->domain); |
|
37423
d2f0259aa43f
Remove NULL-checks before free(). No functional change.
Michael McConville <mmcco@mykolab.com>
parents:
37238
diff
changeset
|
918 | g_free(presence.jb->error_msg); |
|
d2f0259aa43f
Remove NULL-checks before free(). No functional change.
Michael McConville <mmcco@mykolab.com>
parents:
37238
diff
changeset
|
919 | presence.jb->error_msg = NULL; |
| 7014 | 920 | |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
921 | if (presence.type == JABBER_PRESENCE_AVAILABLE) { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
922 | presence.state = JABBER_BUDDY_STATE_ONLINE; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
923 | } else if (presence.type == JABBER_PRESENCE_ERROR) { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
924 | /* TODO: Is this handled properly? Should it be treated as per-jbr? */ |
|
21150
bedd1215fb5e
Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents:
20210
diff
changeset
|
925 | char *msg = jabber_parse_error(js, packet, NULL); |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
926 | presence.state = JABBER_BUDDY_STATE_ERROR; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
927 | presence.jb->error_msg = msg ? msg : g_strdup(_("Unknown Error in presence")); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
928 | } else if (presence.type == JABBER_PRESENCE_SUBSCRIBE) { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
929 | /* TODO: Move to handle_subscribe() (so nick is extracted by the |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
930 | * PresenceHandler */ |
| 7014 | 931 | struct _jabber_add_permit *jap = g_new0(struct _jabber_add_permit, 1); |
| 15197 | 932 | gboolean onlist = FALSE; |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
933 | PurpleAccount *account; |
|
41514
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41248
diff
changeset
|
934 | PurpleAuthorizationRequest *request = NULL; |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41248
diff
changeset
|
935 | PurpleNotification *notification = NULL; |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41248
diff
changeset
|
936 | PurpleNotificationManager *manager = NULL; |
|
27619
3600b7157ab7
Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents:
27618
diff
changeset
|
937 | PurpleBuddy *buddy; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
938 | PurpleXmlNode *nick; |
|
26998
5d912b08679d
A little bit better (free memory and support receiving the nick in subscriptions) and Changelog.
Paul Aurich <darkrain42@pidgin.im>
parents:
26997
diff
changeset
|
939 | |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
940 | account = purple_connection_get_account(js->gc); |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34671
diff
changeset
|
941 | buddy = purple_blist_find_buddy(account, presence.from); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
942 | nick = purple_xmlnode_get_child_with_namespace(packet, "nick", "http://jabber.org/protocol/nick"); |
|
26998
5d912b08679d
A little bit better (free memory and support receiving the nick in subscriptions) and Changelog.
Paul Aurich <darkrain42@pidgin.im>
parents:
26997
diff
changeset
|
943 | if (nick) |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
944 | presence.nickname = purple_xmlnode_get_data(nick); |
|
10949
b2949f5fc512
[gaim-migrate @ 12749]
Evan Schoenberg <evands@pidgin.im>
parents:
10941
diff
changeset
|
945 | |
| 15197 | 946 | if (buddy) { |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
947 | if ((presence.jb->subscription & (JABBER_SUB_TO | JABBER_SUB_PENDING))) |
| 15197 | 948 | onlist = TRUE; |
| 949 | } | |
|
16018
0cbbb5b642ce
fix prompting to add a buddy after authorization if they're already on our list
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
950 | |
| 7014 | 951 | jap->gc = js->gc; |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
952 | jap->who = g_strdup(presence.from); |
| 12285 | 953 | jap->js = js; |
| 7014 | 954 | |
|
41514
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41248
diff
changeset
|
955 | request = purple_authorization_request_new(account, presence.from); |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41248
diff
changeset
|
956 | purple_authorization_request_set_alias(request, presence.nickname); |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41248
diff
changeset
|
957 | purple_authorization_request_set_add(request, !onlist); |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41248
diff
changeset
|
958 | g_signal_connect(request, "accepted", G_CALLBACK(authorize_add_cb), |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41248
diff
changeset
|
959 | jap); |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41248
diff
changeset
|
960 | g_signal_connect(request, "denied", G_CALLBACK(deny_add_cb), jap); |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41248
diff
changeset
|
961 | |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41248
diff
changeset
|
962 | notification = purple_notification_new_from_authorization_request(request); |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41248
diff
changeset
|
963 | manager = purple_notification_manager_get_default(); |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41248
diff
changeset
|
964 | purple_notification_manager_add(manager, notification); |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41248
diff
changeset
|
965 | |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41248
diff
changeset
|
966 | g_object_unref(notification); |
|
27619
3600b7157ab7
Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents:
27618
diff
changeset
|
967 | |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
968 | goto out; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
969 | } else if (presence.type == JABBER_PRESENCE_SUBSCRIBED) { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
970 | /* This case (someone has approved our subscribe request) is handled |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
971 | * by the roster push the server sends along with this. |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
972 | */ |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
973 | goto out; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
974 | } else if (presence.type == JABBER_PRESENCE_UNSUBSCRIBE) { |
| 12285 | 975 | /* XXX I'm not sure this is the right way to handle this, it |
| 976 | * might be better to add "unsubscribe" to the presence status | |
| 977 | * if lower down, but I'm not sure. */ | |
| 978 | /* they are unsubscribing from our presence, we don't care */ | |
| 979 | /* Well, maybe just a little, we might want/need to start | |
| 980 | * acknowledging this (and the others) at some point. */ | |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
981 | goto out; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
982 | } else if (presence.type == JABBER_PRESENCE_PROBE) { |
|
27622
b0ea939829a3
I missed a few presence types.
Paul Aurich <darkrain42@pidgin.im>
parents:
27621
diff
changeset
|
983 | purple_debug_warning("jabber", "Ignoring presence probe\n"); |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
984 | goto out; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
985 | } else if (presence.type == JABBER_PRESENCE_UNAVAILABLE) { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
986 | presence.state = JABBER_BUDDY_STATE_UNAVAILABLE; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
987 | } else if (presence.type == JABBER_PRESENCE_UNSUBSCRIBED) { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
988 | presence.state = JABBER_BUDDY_STATE_UNKNOWN; |
| 7014 | 989 | } else { |
|
27619
3600b7157ab7
Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents:
27618
diff
changeset
|
990 | purple_debug_warning("jabber", "Ignoring presence with invalid type " |
|
3600b7157ab7
Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents:
27618
diff
changeset
|
991 | "'%s'\n", type); |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
992 | goto out; |
| 7014 | 993 | } |
| 994 | ||
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
995 | for (child = packet->child; child; child = child->next) { |
|
31096
442e7d4f6cc7
jabber: Protect against broken OSes and printf("%s", NULL) crashes
Paul Aurich <darkrain42@pidgin.im>
parents:
30744
diff
changeset
|
996 | const char *xmlns; |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
997 | char *key; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
998 | JabberPresenceHandler *pih; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
999 | if (child->type != PURPLE_XMLNODE_TYPE_TAG) |
|
25154
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25110
diff
changeset
|
1000 | continue; |
|
29886
a663cae92ce0
jabber: Proper memory management (and fix a segfault) and whitespace
Paul Aurich <darkrain42@pidgin.im>
parents:
29885
diff
changeset
|
1001 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
1002 | xmlns = purple_xmlnode_get_namespace(child); |
|
31096
442e7d4f6cc7
jabber: Protect against broken OSes and printf("%s", NULL) crashes
Paul Aurich <darkrain42@pidgin.im>
parents:
30744
diff
changeset
|
1003 | key = g_strdup_printf("%s %s", child->name, xmlns ? xmlns : ""); |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1004 | pih = g_hash_table_lookup(presence_handlers, key); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1005 | g_free(key); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1006 | if (pih) |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1007 | pih(js, &presence, child); |
| 25229 | 1008 | } |
| 7014 | 1009 | |
|
33402
dc22f856e957
fix a memory leak (I've been in c++ land too long)
Nathan Walp <nwalp@pidgin.im>
parents:
33400
diff
changeset
|
1010 | if (presence.delayed && presence.idle && presence.adjust_idle_for_delay) { |
|
41244
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
1011 | GDateTime *now = g_date_time_new_now_utc(); |
|
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
1012 | GTimeSpan difference = 0; |
|
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
1013 | |
|
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
1014 | difference = g_date_time_difference(now, presence.sent); |
|
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
1015 | |
|
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
1016 | g_date_time_unref(now); |
|
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
1017 | |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1018 | /* Delayed and idle, so update idle time */ |
|
41244
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
1019 | presence.idle = presence.idle + (difference / G_TIME_SPAN_SECOND); |
| 7014 | 1020 | } |
|
26976
5173897818ed
Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <darkrain42@pidgin.im>
parents:
26975
diff
changeset
|
1021 | |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1022 | /* TODO: Handle tracking jb(r) here? */ |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1023 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1024 | if (presence.chat) |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1025 | ret = handle_presence_chat(js, &presence, packet); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1026 | else |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1027 | ret = handle_presence_contact(js, &presence); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1028 | if (!ret) |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1029 | goto out; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1030 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1031 | if (presence.caps && presence.type == JABBER_PRESENCE_AVAILABLE) { |
|
26976
5173897818ed
Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <darkrain42@pidgin.im>
parents:
26975
diff
changeset
|
1032 | /* handle Entity Capabilities (XEP-0115) */ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
1033 | const char *node = purple_xmlnode_get_attrib(presence.caps, "node"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
1034 | const char *ver = purple_xmlnode_get_attrib(presence.caps, "ver"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
1035 | const char *hash = purple_xmlnode_get_attrib(presence.caps, "hash"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
1036 | const char *ext = purple_xmlnode_get_attrib(presence.caps, "ext"); |
|
26976
5173897818ed
Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <darkrain42@pidgin.im>
parents:
26975
diff
changeset
|
1037 | |
|
5173897818ed
Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <darkrain42@pidgin.im>
parents:
26975
diff
changeset
|
1038 | /* v1.3 uses: node, ver, and optionally ext. |
|
5173897818ed
Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <darkrain42@pidgin.im>
parents:
26975
diff
changeset
|
1039 | * v1.5 uses: node, ver, and hash. */ |
|
5173897818ed
Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <darkrain42@pidgin.im>
parents:
26975
diff
changeset
|
1040 | if (node && *node && ver && *ver) { |
|
27068
3353c0f46a1a
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents:
27066
diff
changeset
|
1041 | gchar **exts = ext && *ext ? g_strsplit(ext, " ", -1) : NULL; |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1042 | jbr = jabber_buddy_find_resource(presence.jb, presence.jid_from->resource); |
|
27068
3353c0f46a1a
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents:
27066
diff
changeset
|
1043 | |
|
3353c0f46a1a
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents:
27066
diff
changeset
|
1044 | /* Look it up if we don't already have all this information */ |
|
3353c0f46a1a
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents:
27066
diff
changeset
|
1045 | if (!jbr || !jbr->caps.info || |
|
38256
035f00c4fd87
Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
36256
diff
changeset
|
1046 | !purple_strequal(node, jbr->caps.info->tuple.node) || |
|
035f00c4fd87
Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
36256
diff
changeset
|
1047 | !purple_strequal(ver, jbr->caps.info->tuple.ver) || |
|
27068
3353c0f46a1a
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents:
27066
diff
changeset
|
1048 | !purple_strequal(hash, jbr->caps.info->tuple.hash) || |
|
3353c0f46a1a
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents:
27066
diff
changeset
|
1049 | !jabber_caps_exts_known(jbr->caps.info, (gchar **)exts)) { |
|
3353c0f46a1a
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents:
27066
diff
changeset
|
1050 | JabberPresenceCapabilities *userdata = g_new0(JabberPresenceCapabilities, 1); |
|
3353c0f46a1a
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents:
27066
diff
changeset
|
1051 | userdata->js = js; |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1052 | userdata->jb = presence.jb; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1053 | userdata->from = g_strdup(presence.from); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1054 | jabber_caps_get_info(js, presence.from, node, ver, hash, exts, |
|
27068
3353c0f46a1a
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents:
27066
diff
changeset
|
1055 | (jabber_caps_get_info_cb)jabber_presence_set_capabilities, |
|
3353c0f46a1a
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents:
27066
diff
changeset
|
1056 | userdata); |
|
3353c0f46a1a
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents:
27066
diff
changeset
|
1057 | } else { |
|
3353c0f46a1a
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents:
27066
diff
changeset
|
1058 | if (exts) |
|
3353c0f46a1a
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents:
27066
diff
changeset
|
1059 | g_strfreev(exts); |
|
3353c0f46a1a
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents:
27066
diff
changeset
|
1060 | } |
|
26976
5173897818ed
Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <darkrain42@pidgin.im>
parents:
26975
diff
changeset
|
1061 | } |
|
5173897818ed
Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <darkrain42@pidgin.im>
parents:
26975
diff
changeset
|
1062 | } |
|
5173897818ed
Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <darkrain42@pidgin.im>
parents:
26975
diff
changeset
|
1063 | |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1064 | out: |
|
40052
cc03b5af25ea
Use GSList functions instead of manual iterations
qarkai <qarkai@gmail.com>
parents:
39920
diff
changeset
|
1065 | g_slist_free(presence.chat_info.codes); |
|
29886
a663cae92ce0
jabber: Proper memory management (and fix a segfault) and whitespace
Paul Aurich <darkrain42@pidgin.im>
parents:
29885
diff
changeset
|
1066 | g_free(presence.status); |
|
a663cae92ce0
jabber: Proper memory management (and fix a segfault) and whitespace
Paul Aurich <darkrain42@pidgin.im>
parents:
29885
diff
changeset
|
1067 | g_free(presence.vcard_avatar_hash); |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1068 | g_free(presence.nickname); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1069 | jabber_id_free(presence.jid_from); |
|
41244
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
1070 | g_clear_pointer(&presence.sent, g_date_time_unref); |
| 7014 | 1071 | } |
| 1072 | ||
| 1073 | void jabber_presence_subscription_set(JabberStream *js, const char *who, const char *type) | |
| 1074 | { | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
1075 | PurpleXmlNode *presence = purple_xmlnode_new("presence"); |
| 7014 | 1076 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
1077 | purple_xmlnode_set_attrib(presence, "to", who); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
1078 | purple_xmlnode_set_attrib(presence, "type", type); |
| 7014 | 1079 | |
| 1080 | jabber_send(js, presence); | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
1081 | purple_xmlnode_free(presence); |
| 7014 | 1082 | } |
| 9954 | 1083 | |
|
39522
696fe0c9677f
Fix some const warnings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38854
diff
changeset
|
1084 | void purple_status_to_jabber(PurpleStatus *status, JabberBuddyState *state, char **msg, int *priority) |
| 9954 | 1085 | { |
| 10216 | 1086 | const char *status_id = NULL; |
| 14525 | 1087 | const char *formatted_msg = NULL; |
| 10216 | 1088 | |
| 13443 | 1089 | if(state) *state = JABBER_BUDDY_STATE_UNKNOWN; |
| 1090 | if(msg) *msg = NULL; | |
| 1091 | if(priority) *priority = 0; | |
| 9954 | 1092 | |
| 1093 | if(!status) { | |
| 13443 | 1094 | if(state) *state = JABBER_BUDDY_STATE_UNAVAILABLE; |
| 10216 | 1095 | } else { |
| 1096 | if(state) { | |
| 15884 | 1097 | status_id = purple_status_get_id(status); |
| 10216 | 1098 | *state = jabber_buddy_status_id_get_state(status_id); |
| 1099 | } | |
| 1100 | ||
|
13497
07fc0a9826b8
[gaim-migrate @ 15872]
Richard Laager <rlaager@pidgin.im>
parents:
13445
diff
changeset
|
1101 | if(msg) { |
| 15884 | 1102 | formatted_msg = purple_status_get_attr_string(status, "message"); |
| 10216 | 1103 | |
|
13497
07fc0a9826b8
[gaim-migrate @ 15872]
Richard Laager <rlaager@pidgin.im>
parents:
13445
diff
changeset
|
1104 | /* if the message is blank, then there really isn't a message */ |
|
27775
b8569a76e02e
Don't pre-escape jbr->status. Almost every place required it in unescaped
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27698
diff
changeset
|
1105 | if(formatted_msg && *formatted_msg) |
| 17683 | 1106 | *msg = purple_markup_strip_html(formatted_msg); |
|
13497
07fc0a9826b8
[gaim-migrate @ 15872]
Richard Laager <rlaager@pidgin.im>
parents:
13445
diff
changeset
|
1107 | } |
| 11872 | 1108 | |
| 10216 | 1109 | if(priority) |
| 15884 | 1110 | *priority = purple_status_get_attr_int(status, "priority"); |
| 9954 | 1111 | } |
| 1112 | } | |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1113 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1114 | /* Incoming presence handlers */ |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1115 | static void |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
1116 | parse_priority(JabberStream *js, JabberPresence *presence, PurpleXmlNode *priority) |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1117 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
1118 | char *p = purple_xmlnode_get_data(priority); |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1119 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1120 | if (presence->priority != 0) |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1121 | purple_debug_warning("jabber", "presence stanza received with multiple " |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1122 | "priority children!?\n"); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1123 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1124 | if (p) { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1125 | presence->priority = atoi(p); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1126 | g_free(p); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1127 | } else |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1128 | purple_debug_warning("jabber", "Empty <priority/> in presence!\n"); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1129 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1130 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1131 | static void |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
1132 | parse_show(JabberStream *js, JabberPresence *presence, PurpleXmlNode *show) |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1133 | { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1134 | char *cdata; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1135 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1136 | if (presence->type != JABBER_PRESENCE_AVAILABLE) { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1137 | purple_debug_warning("jabber", "<show/> present on presence, but " |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1138 | "type is not default ('available')\n"); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1139 | return; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1140 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1141 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
1142 | cdata = purple_xmlnode_get_data(show); |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1143 | if (cdata) { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1144 | presence->state = jabber_buddy_show_get_state(cdata); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1145 | g_free(cdata); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1146 | } else |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1147 | purple_debug_warning("jabber", "<show/> present on presence, but " |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1148 | "no contents!\n"); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1149 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1150 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1151 | static void |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
1152 | parse_status(JabberStream *js, JabberPresence *presence, PurpleXmlNode *status) |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1153 | { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1154 | /* TODO: Check/track language attribute? */ |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1155 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1156 | g_free(presence->status); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
1157 | presence->status = purple_xmlnode_get_data(status); |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1158 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1159 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1160 | static void |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
1161 | parse_delay(JabberStream *js, JabberPresence *presence, PurpleXmlNode *delay) |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1162 | { |
|
41244
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
1163 | GTimeZone *tz = g_time_zone_new_utc(); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
1164 | const char *stamp = purple_xmlnode_get_attrib(delay, "stamp"); |
|
41244
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
1165 | |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1166 | presence->delayed = TRUE; |
|
41244
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
1167 | presence->sent = g_date_time_new_from_iso8601(stamp, tz); |
|
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
1168 | |
|
5535c6fdd135
Port JabberPresence from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
1169 | g_time_zone_unref(tz); |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1170 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1171 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1172 | static void |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
1173 | parse_idle(JabberStream *js, JabberPresence *presence, PurpleXmlNode *query) |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1174 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
1175 | const gchar *seconds = purple_xmlnode_get_attrib(query, "seconds"); |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1176 | if (seconds) { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1177 | presence->idle = atoi(seconds); |
|
33402
dc22f856e957
fix a memory leak (I've been in c++ land too long)
Nathan Walp <nwalp@pidgin.im>
parents:
33400
diff
changeset
|
1178 | presence->adjust_idle_for_delay = TRUE; |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1179 | if (presence->idle < 0) { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1180 | purple_debug_warning("jabber", "Received bogus idle time %s\n", seconds); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1181 | presence->idle = 0; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1182 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1183 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1184 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1185 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1186 | static void |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
1187 | parse_caps(JabberStream *js, JabberPresence *presence, PurpleXmlNode *c) |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1188 | { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1189 | /* TODO: Move the rest of the caps handling in here, after changing the |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1190 | * the "do we have details about this (node, ver) and exts" to not |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1191 | * require the jbr to be present (since that happens later). |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1192 | */ |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1193 | presence->caps = c; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1194 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1195 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1196 | static void |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
1197 | parse_nickname(JabberStream *js, JabberPresence *presence, PurpleXmlNode *nick) |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1198 | { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1199 | g_free(presence->nickname); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
1200 | presence->nickname = purple_xmlnode_get_data(nick); |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1201 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1202 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1203 | static void |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
1204 | parse_vcard_avatar(JabberStream *js, JabberPresence *presence, PurpleXmlNode *x) |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1205 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
1206 | PurpleXmlNode *photo = purple_xmlnode_get_child(x, "photo"); |
|
31736
d7d283b25b0b
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
Matthew W. S. Bell <matthew@bells23.org.uk>
parents:
31445
diff
changeset
|
1207 | |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1208 | if (photo) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
1209 | char *hash_tmp = purple_xmlnode_get_data(photo); |
|
31737
f7ed528afc8d
jabber: Tighter scoping
Paul Aurich <darkrain42@pidgin.im>
parents:
31736
diff
changeset
|
1210 | g_free(presence->vcard_avatar_hash); |
|
f7ed528afc8d
jabber: Tighter scoping
Paul Aurich <darkrain42@pidgin.im>
parents:
31736
diff
changeset
|
1211 | presence->vcard_avatar_hash = |
|
31736
d7d283b25b0b
jabber: Correctly handle the unsetting case for a contact's vCard avatar.
Matthew W. S. Bell <matthew@bells23.org.uk>
parents:
31445
diff
changeset
|
1212 | hash_tmp ? hash_tmp : g_strdup(""); |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1213 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1214 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1215 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1216 | static void |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
1217 | parse_muc_user(JabberStream *js, JabberPresence *presence, PurpleXmlNode *x) |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1218 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
1219 | PurpleXmlNode *status; |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1220 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1221 | if (presence->chat == NULL) { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1222 | purple_debug_warning("jabber", "Ignoring MUC gloop on non-MUC presence\n"); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1223 | return; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1224 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1225 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1226 | if (presence->chat->conv == NULL) |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1227 | presence->chat->muc = TRUE; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1228 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
1229 | for (status = purple_xmlnode_get_child(x, "status"); status; |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
1230 | status = purple_xmlnode_get_next_twin(status)) { |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
1231 | const char *code = purple_xmlnode_get_attrib(status, "code"); |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1232 | int val; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1233 | if (!code) |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1234 | continue; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1235 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1236 | val = atoi(code); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1237 | if (val == 0 || val < 0) { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1238 | purple_debug_warning("jabber", "Ignoring bogus status code '%s'\n", |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1239 | code); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1240 | continue; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1241 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1242 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1243 | presence->chat_info.codes = g_slist_prepend(presence->chat_info.codes, GINT_TO_POINTER(val)); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1244 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1245 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
1246 | presence->chat_info.item = purple_xmlnode_get_child(x, "item"); |
|
29848
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1247 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1248 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1249 | void jabber_presence_register_handler(const char *node, const char *xmlns, |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1250 | JabberPresenceHandler *handler) |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1251 | { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1252 | /* |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1253 | * This is valid because nodes nor namespaces cannot have spaces in them |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1254 | * (see http://www.w3.org/TR/2006/REC-xml-20060816/ and |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1255 | * http://www.w3.org/TR/REC-xml-names/) |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1256 | */ |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1257 | char *key = g_strdup_printf("%s %s", node, xmlns); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1258 | g_hash_table_replace(presence_handlers, key, handler); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1259 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1260 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1261 | void jabber_presence_init(void) |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1262 | { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1263 | presence_handlers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1264 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1265 | /* Core RFC things */ |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1266 | jabber_presence_register_handler("priority", "jabber:client", parse_priority); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1267 | jabber_presence_register_handler("show", "jabber:client", parse_show); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1268 | jabber_presence_register_handler("status", "jabber:client", parse_status); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1269 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1270 | /* XEPs */ |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1271 | jabber_presence_register_handler("c", "http://jabber.org/protocol/caps", parse_caps); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1272 | jabber_presence_register_handler("delay", NS_DELAYED_DELIVERY, parse_delay); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1273 | jabber_presence_register_handler("nick", "http://jabber.org/protocol/nick", parse_nickname); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1274 | jabber_presence_register_handler("query", NS_LAST_ACTIVITY, parse_idle); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1275 | jabber_presence_register_handler("x", NS_DELAYED_DELIVERY_LEGACY, parse_delay); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1276 | jabber_presence_register_handler("x", "http://jabber.org/protocol/muc#user", parse_muc_user); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1277 | jabber_presence_register_handler("x", "vcard-temp:x:update", parse_vcard_avatar); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1278 | } |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1279 | |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1280 | void jabber_presence_uninit(void) |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1281 | { |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1282 | g_hash_table_destroy(presence_handlers); |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1283 | presence_handlers = NULL; |
|
999c0235bbc6
jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents:
29816
diff
changeset
|
1284 | } |