Wed, 11 Jul 2007 22:27:44 +0000
propagate from branch 'im.pidgin.pidgin' (head 716f4775cbdf4b1d6ca8bb122964f9f1b04fca72)
to branch 'im.pidgin.soc.2007.xmpp' (head 72d8799d2913424cd7f99b7ca3a0920e5bd8532d)
| 7014 | 1 | /* |
| 15884 | 2 | * purple - Jabber Protocol Plugin |
| 7014 | 3 | * |
| 4 | * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com> | |
| 5 | * | |
| 6 | * This program is free software; you can redistribute it and/or modify | |
| 7 | * it under the terms of the GNU General Public License as published by | |
| 8 | * the Free Software Foundation; either version 2 of the License, or | |
| 9 | * (at your option) any later version. | |
| 10 | * | |
| 11 | * This program is distributed in the hope that it will be useful, | |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | * GNU General Public License for more details. | |
| 15 | * | |
| 16 | * You should have received a copy of the GNU General Public License | |
| 17 | * along with this program; if not, write to the Free Software | |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 19 | * | |
| 20 | */ | |
| 21 | #include "internal.h" | |
| 22 | ||
|
15952
c087855dc551
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
23 | #include "account.h" |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10646
diff
changeset
|
24 | #include "cipher.h" |
|
15952
c087855dc551
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
25 | #include "conversation.h" |
| 7014 | 26 | #include "debug.h" |
| 27 | #include "notify.h" | |
| 28 | #include "request.h" | |
| 29 | #include "server.h" | |
| 9954 | 30 | #include "status.h" |
|
7095
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
31 | #include "util.h" |
|
15952
c087855dc551
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
32 | #include "xmlnode.h" |
| 7014 | 33 | |
| 34 | #include "buddy.h" | |
| 35 | #include "chat.h" | |
| 36 | #include "presence.h" | |
| 37 | #include "iq.h" | |
| 38 | #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
|
39 | #include "adhoccommands.h" |
| 7014 | 40 | |
|
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
|
41 | #include "usertune.h" |
| 7014 | 42 | |
| 43 | ||
| 44 | static void chats_send_presence_foreach(gpointer key, gpointer val, | |
| 45 | gpointer user_data) | |
| 46 | { | |
| 47 | JabberChat *chat = val; | |
| 48 | xmlnode *presence = user_data; | |
| 8577 | 49 | char *chat_full_jid; |
| 50 | ||
| 51 | if(!chat->conv) | |
| 52 | return; | |
| 53 | ||
| 54 | chat_full_jid = g_strdup_printf("%s@%s/%s", chat->room, chat->server, | |
| 8401 | 55 | chat->handle); |
| 7014 | 56 | |
| 8401 | 57 | xmlnode_set_attrib(presence, "to", chat_full_jid); |
| 7014 | 58 | jabber_send(chat->js, presence); |
| 8401 | 59 | g_free(chat_full_jid); |
| 7014 | 60 | } |
| 61 | ||
| 15884 | 62 | void jabber_presence_fake_to_self(JabberStream *js, const PurpleStatus *gstatus) { |
| 10286 | 63 | char *my_base_jid; |
| 64 | ||
| 65 | if(!js->user) | |
| 66 | return; | |
| 67 | ||
| 68 | my_base_jid = g_strdup_printf("%s@%s", js->user->node, js->user->domain); | |
| 15884 | 69 | if(purple_find_buddy(js->gc->account, my_base_jid)) { |
| 8185 | 70 | JabberBuddy *jb; |
| 71 | JabberBuddyResource *jbr; | |
| 72 | if((jb = jabber_buddy_find(js, my_base_jid, TRUE))) { | |
| 9954 | 73 | JabberBuddyState state; |
| 14525 | 74 | char *msg; |
| 9954 | 75 | int priority; |
| 76 | ||
| 15884 | 77 | purple_status_to_jabber(gstatus, &state, &msg, &priority); |
| 9954 | 78 | |
| 10490 | 79 | if (state == JABBER_BUDDY_STATE_UNAVAILABLE || state == JABBER_BUDDY_STATE_UNKNOWN) { |
|
9744
c2b450de1fc0
[gaim-migrate @ 10609]
Daniel Atallah <datallah@pidgin.im>
parents:
9743
diff
changeset
|
80 | jabber_buddy_remove_resource(jb, js->user->resource); |
|
c2b450de1fc0
[gaim-migrate @ 10609]
Daniel Atallah <datallah@pidgin.im>
parents:
9743
diff
changeset
|
81 | } else { |
| 9954 | 82 | jabber_buddy_track_resource(jb, js->user->resource, priority, state, msg); |
|
9744
c2b450de1fc0
[gaim-migrate @ 10609]
Daniel Atallah <datallah@pidgin.im>
parents:
9743
diff
changeset
|
83 | } |
| 9954 | 84 | if((jbr = jabber_buddy_find_resource(jb, NULL))) { |
| 15884 | 85 | purple_prpl_got_user_status(js->gc->account, my_base_jid, jabber_buddy_state_get_status_id(jbr->state), "priority", jbr->priority, jbr->status ? "message" : NULL, jbr->status, NULL); |
| 9954 | 86 | } else { |
| 15884 | 87 | purple_prpl_got_user_status(js->gc->account, my_base_jid, "offline", msg ? "message" : NULL, msg, NULL); |
| 9954 | 88 | } |
| 14525 | 89 | |
| 90 | g_free(msg); | |
| 8185 | 91 | } |
| 92 | } | |
| 93 | g_free(my_base_jid); | |
| 94 | } | |
| 95 | ||
| 7014 | 96 | |
| 15884 | 97 | void jabber_presence_send(PurpleAccount *account, PurpleStatus *status) |
| 7014 | 98 | { |
| 15884 | 99 | PurpleConnection *gc = NULL; |
|
10382
32e07712e224
[gaim-migrate @ 11608]
Luke Schierer <lschiere@pidgin.im>
parents:
10286
diff
changeset
|
100 | JabberStream *js = NULL; |
|
11251
e38d86958a63
[gaim-migrate @ 13420]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11183
diff
changeset
|
101 | gboolean disconnected; |
|
10755
a336a5d3102d
[gaim-migrate @ 12358]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
102 | int primitive; |
| 10189 | 103 | xmlnode *presence, *x, *photo; |
| 7014 | 104 | char *stripped = NULL; |
| 9954 | 105 | JabberBuddyState state; |
| 106 | int priority; | |
|
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
|
107 | const char *artist, *title, *source, *uri, *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
|
108 | int length; |
|
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
|
109 | gboolean allowBuzz; |
| 7014 | 110 | |
|
18195
9cd0565f856e
kill some code duplication when sending current presence
Nathan Walp <nwalp@pidgin.im>
parents:
17703
diff
changeset
|
111 | if(NULL == status) { |
|
9cd0565f856e
kill some code duplication when sending current presence
Nathan Walp <nwalp@pidgin.im>
parents:
17703
diff
changeset
|
112 | PurplePresence *gpresence = purple_account_get_presence(account); |
|
9cd0565f856e
kill some code duplication when sending current presence
Nathan Walp <nwalp@pidgin.im>
parents:
17703
diff
changeset
|
113 | status = purple_presence_get_active_status(gpresence); |
|
9cd0565f856e
kill some code duplication when sending current presence
Nathan Walp <nwalp@pidgin.im>
parents:
17703
diff
changeset
|
114 | } |
|
9cd0565f856e
kill some code duplication when sending current presence
Nathan Walp <nwalp@pidgin.im>
parents:
17703
diff
changeset
|
115 | |
| 15884 | 116 | if(!purple_status_is_active(status)) |
| 10486 | 117 | return; |
| 118 | ||
| 15884 | 119 | disconnected = purple_account_is_disconnected(account); |
|
10755
a336a5d3102d
[gaim-migrate @ 12358]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
120 | |
|
11251
e38d86958a63
[gaim-migrate @ 13420]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11183
diff
changeset
|
121 | if(disconnected) |
|
10755
a336a5d3102d
[gaim-migrate @ 12358]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
122 | return; |
|
a336a5d3102d
[gaim-migrate @ 12358]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
123 | |
| 17422 | 124 | primitive = purple_status_type_get_primitive(purple_status_get_type(status)); |
| 125 | ||
| 15884 | 126 | gc = purple_account_get_connection(account); |
|
10755
a336a5d3102d
[gaim-migrate @ 12358]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
127 | js = gc->proto_data; |
|
a336a5d3102d
[gaim-migrate @ 12358]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
128 | |
|
18226
adf83935e838
really and truly enforce the no-presence-before-roster thing
Nathan Walp <nwalp@pidgin.im>
parents:
18195
diff
changeset
|
129 | /* we don't want to send presence before we've gotten our roster */ |
|
adf83935e838
really and truly enforce the no-presence-before-roster thing
Nathan Walp <nwalp@pidgin.im>
parents:
18195
diff
changeset
|
130 | if(!js->roster_parsed) { |
|
adf83935e838
really and truly enforce the no-presence-before-roster thing
Nathan Walp <nwalp@pidgin.im>
parents:
18195
diff
changeset
|
131 | purple_debug_info("jabber", "attempt to send presence before roster retrieved\n"); |
|
adf83935e838
really and truly enforce the no-presence-before-roster thing
Nathan Walp <nwalp@pidgin.im>
parents:
18195
diff
changeset
|
132 | return; |
|
adf83935e838
really and truly enforce the no-presence-before-roster thing
Nathan Walp <nwalp@pidgin.im>
parents:
18195
diff
changeset
|
133 | } |
|
adf83935e838
really and truly enforce the no-presence-before-roster thing
Nathan Walp <nwalp@pidgin.im>
parents:
18195
diff
changeset
|
134 | |
| 15884 | 135 | purple_status_to_jabber(status, &state, &stripped, &priority); |
|
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
|
136 | |
|
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
|
137 | /* 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
|
138 | 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
|
139 | /* changing the buzz state has to trigger a re-broadcasting of the presence for caps */ |
|
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
|
140 | |
|
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
|
141 | #define CHANGED(a,b) ((!a && b) || (a && a[0] == '\0' && b && b[0] != '\0') || \ |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
142 | (a && !b) || (a && a[0] != '\0' && b && b[0] == '\0') || (a && b && strcmp(a,b))) |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
143 | /* check if there are any differences to the <presence> and send them in that case */ |
|
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
|
144 | if (allowBuzz != js->allowBuzz || js->old_state != state || CHANGED(js->old_msg, stripped) || |
|
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
|
145 | js->old_priority != priority || CHANGED(js->old_avatarhash, js->avatar_hash)) { |
|
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
|
146 | js->allowBuzz = allowBuzz; |
|
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
|
147 | presence = jabber_presence_create_js(js, state, stripped, priority); |
| 7014 | 148 | |
|
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
|
149 | if(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
|
150 | x = xmlnode_new_child(presence, "x"); |
|
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
|
151 | xmlnode_set_namespace(x, "vcard-temp:x:update"); |
|
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
|
152 | photo = xmlnode_new_child(x, "photo"); |
|
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
|
153 | xmlnode_insert_data(photo, js->avatar_hash, -1); |
|
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
|
154 | } |
|
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
|
155 | |
|
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
|
156 | jabber_send(js, presence); |
| 7014 | 157 | |
|
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
|
158 | g_hash_table_foreach(js->chats, chats_send_presence_foreach, presence); |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
159 | xmlnode_free(presence); |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
160 | |
|
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
|
161 | /* update old values */ |
|
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
|
162 | |
|
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
|
163 | if(js->old_msg) |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
164 | g_free(js->old_msg); |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
165 | if(js->old_avatarhash) |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
166 | g_free(js->old_avatarhash); |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
167 | 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
|
168 | 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
|
169 | 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
|
170 | js->old_priority = priority; |
|
17801
1a29a61dda8d
fixed a bug in the status change tracking code
Andreas Monitzer <am@adiumx.com>
parents:
17800
diff
changeset
|
171 | g_free(stripped); |
| 10189 | 172 | } |
|
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
|
173 | |
|
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
|
174 | /* next, check if there are any changes to the tune values */ |
|
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
|
175 | artist = purple_status_get_attr_string(status, PURPLE_TUNE_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
|
176 | title = purple_status_get_attr_string(status, PURPLE_TUNE_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
|
177 | source = purple_status_get_attr_string(status, PURPLE_TUNE_ALBUM); |
|
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
|
178 | uri = purple_status_get_attr_string(status, PURPLE_TUNE_URL); |
|
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
|
179 | track = purple_status_get_attr_string(status, PURPLE_TUNE_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
|
180 | length = (!purple_status_get_attr_value(status, PURPLE_TUNE_TIME))?-1:purple_status_get_attr_int(status, PURPLE_TUNE_TIME); |
|
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
|
181 | |
|
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
|
182 | if(CHANGED(artist, js->old_artist) || CHANGED(title, js->old_title) || CHANGED(source, js->old_source) || |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
183 | CHANGED(uri, js->old_uri) || CHANGED(track, js->old_track) || (length != js->old_length)) { |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
184 | 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
|
185 | (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
|
186 | (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
|
187 | (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
|
188 | (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
|
189 | 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
|
190 | (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
|
191 | }; |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
192 | jabber_tune_set(js->gc, &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
|
193 | |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
194 | /* update old values */ |
|
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
|
195 | if(js->old_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
|
196 | g_free(js->old_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
|
197 | if(js->old_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
|
198 | g_free(js->old_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
|
199 | if(js->old_source) |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
200 | g_free(js->old_source); |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
201 | if(js->old_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
|
202 | g_free(js->old_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
|
203 | if(js->old_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
|
204 | g_free(js->old_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
|
205 | 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
|
206 | 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
|
207 | 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
|
208 | 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
|
209 | 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
|
210 | js->old_track = g_strdup(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
|
211 | } |
|
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
|
212 | |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
213 | #undef CHANGED(a,b) |
|
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
|
214 | |
| 9954 | 215 | jabber_presence_fake_to_self(js, status); |
| 7014 | 216 | } |
| 217 | ||
| 9954 | 218 | xmlnode *jabber_presence_create(JabberBuddyState state, const char *msg, int priority) |
| 7014 | 219 | { |
|
17770
e67998927a3c
Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents:
17422
diff
changeset
|
220 | return jabber_presence_create_js(NULL, state, msg, priority); |
|
e67998927a3c
Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents:
17422
diff
changeset
|
221 | } |
|
e67998927a3c
Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents:
17422
diff
changeset
|
222 | |
|
e67998927a3c
Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents:
17422
diff
changeset
|
223 | xmlnode *jabber_presence_create_js(JabberStream *js, JabberBuddyState state, const char *msg, int priority) |
|
e67998927a3c
Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents:
17422
diff
changeset
|
224 | { |
| 13385 | 225 | xmlnode *show, *status, *presence, *pri, *c; |
| 9954 | 226 | const char *show_string = NULL; |
| 7014 | 227 | |
| 228 | presence = xmlnode_new("presence"); | |
| 229 | ||
| 9954 | 230 | if(state == JABBER_BUDDY_STATE_UNAVAILABLE) |
| 231 | xmlnode_set_attrib(presence, "type", "unavailable"); | |
| 232 | else if(state != JABBER_BUDDY_STATE_ONLINE && | |
| 233 | state != JABBER_BUDDY_STATE_UNKNOWN && | |
| 234 | state != JABBER_BUDDY_STATE_ERROR) | |
| 12683 | 235 | show_string = jabber_buddy_state_get_show(state); |
| 9954 | 236 | |
| 237 | if(show_string) { | |
| 238 | show = xmlnode_new_child(presence, "show"); | |
| 239 | xmlnode_insert_data(show, show_string, -1); | |
| 7014 | 240 | } |
| 241 | ||
| 9954 | 242 | if(msg) { |
| 7014 | 243 | status = xmlnode_new_child(presence, "status"); |
| 244 | xmlnode_insert_data(status, msg, -1); | |
| 245 | } | |
| 246 | ||
| 11568 | 247 | if(priority) { |
| 248 | char *pstr = g_strdup_printf("%d", priority); | |
| 249 | pri = xmlnode_new_child(presence, "priority"); | |
| 250 | xmlnode_insert_data(pri, pstr, -1); | |
| 251 | g_free(pstr); | |
| 252 | } | |
| 253 | ||
| 13385 | 254 | /* JEP-0115 */ |
| 255 | c = xmlnode_new_child(presence, "c"); | |
| 13808 | 256 | xmlnode_set_namespace(c, "http://jabber.org/protocol/caps"); |
| 13385 | 257 | xmlnode_set_attrib(c, "node", CAPS0115_NODE); |
| 258 | xmlnode_set_attrib(c, "ver", VERSION); | |
|
17770
e67998927a3c
Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents:
17422
diff
changeset
|
259 | |
|
e67998927a3c
Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents:
17422
diff
changeset
|
260 | if(js != NULL) { |
|
e67998927a3c
Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents:
17422
diff
changeset
|
261 | /* add the extensions */ |
|
e67998927a3c
Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents:
17422
diff
changeset
|
262 | char extlist[1024]; |
|
e67998927a3c
Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents:
17422
diff
changeset
|
263 | unsigned remaining = 1023; /* one less for the \0 */ |
| 17771 | 264 | GList *feature; |
|
17770
e67998927a3c
Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents:
17422
diff
changeset
|
265 | |
|
e67998927a3c
Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents:
17422
diff
changeset
|
266 | extlist[0] = '\0'; |
|
17773
6956b763b3d1
Implemented adding callbacks for PEP events. Moved the feature list to be application-global instead of per-connection (makes more sense).
Andreas Monitzer <am@adiumx.com>
parents:
17771
diff
changeset
|
267 | for(feature = jabber_features; feature && remaining > 0; feature = feature->next) { |
|
17770
e67998927a3c
Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents:
17422
diff
changeset
|
268 | JabberFeature *feat = (JabberFeature*)feature->data; |
|
17783
2687df1ca202
PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents:
17773
diff
changeset
|
269 | unsigned featlen; |
|
2687df1ca202
PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents:
17773
diff
changeset
|
270 | |
|
2687df1ca202
PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents:
17773
diff
changeset
|
271 | if(feat->is_enabled != NULL && feat->is_enabled(js, feat->shortname, feat->namespace) == FALSE) |
|
2687df1ca202
PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents:
17773
diff
changeset
|
272 | continue; /* skip this feature */ |
|
2687df1ca202
PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents:
17773
diff
changeset
|
273 | |
|
2687df1ca202
PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents:
17773
diff
changeset
|
274 | featlen = strlen(feat->shortname); |
|
2687df1ca202
PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents:
17773
diff
changeset
|
275 | |
|
17770
e67998927a3c
Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents:
17422
diff
changeset
|
276 | /* cut off when we don't have any more space left in our buffer (too bad) */ |
|
e67998927a3c
Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents:
17422
diff
changeset
|
277 | if(featlen > remaining) |
|
e67998927a3c
Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents:
17422
diff
changeset
|
278 | break; |
|
e67998927a3c
Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents:
17422
diff
changeset
|
279 | |
|
e67998927a3c
Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents:
17422
diff
changeset
|
280 | strncat(extlist,feat->shortname,remaining); |
|
e67998927a3c
Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents:
17422
diff
changeset
|
281 | remaining -= featlen; |
| 17771 | 282 | if(feature->next) { /* no space at the end */ |
| 283 | strncat(extlist," ",remaining); | |
| 284 | --remaining; | |
| 285 | } | |
|
17770
e67998927a3c
Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents:
17422
diff
changeset
|
286 | } |
|
e67998927a3c
Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents:
17422
diff
changeset
|
287 | /* did we add anything? */ |
|
e67998927a3c
Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents:
17422
diff
changeset
|
288 | if(remaining < 1023) |
|
e67998927a3c
Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents:
17422
diff
changeset
|
289 | xmlnode_set_attrib(c, "ext", extlist); |
|
e67998927a3c
Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents:
17422
diff
changeset
|
290 | } |
| 13385 | 291 | |
| 7014 | 292 | return presence; |
| 293 | } | |
| 294 | ||
| 295 | struct _jabber_add_permit { | |
| 15884 | 296 | PurpleConnection *gc; |
| 12285 | 297 | JabberStream *js; |
| 7014 | 298 | char *who; |
| 299 | }; | |
| 300 | ||
| 301 | static void authorize_add_cb(struct _jabber_add_permit *jap) | |
| 302 | { | |
|
14030
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13952
diff
changeset
|
303 | jabber_presence_subscription_set(jap->gc->proto_data, jap->who, |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13952
diff
changeset
|
304 | "subscribed"); |
| 7014 | 305 | g_free(jap->who); |
| 306 | g_free(jap); | |
| 307 | } | |
| 308 | ||
| 309 | static void deny_add_cb(struct _jabber_add_permit *jap) | |
| 310 | { | |
|
14030
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13952
diff
changeset
|
311 | jabber_presence_subscription_set(jap->gc->proto_data, jap->who, |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13952
diff
changeset
|
312 | "unsubscribed"); |
| 7014 | 313 | |
| 314 | g_free(jap->who); | |
| 315 | g_free(jap); | |
| 316 | } | |
| 317 | ||
| 10189 | 318 | static void jabber_vcard_parse_avatar(JabberStream *js, xmlnode *packet, gpointer blah) |
| 319 | { | |
| 10941 | 320 | JabberBuddy *jb = NULL; |
| 321 | xmlnode *vcard, *photo, *binval; | |
|
11127
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
11013
diff
changeset
|
322 | char *text; |
|
11137
cf40226ddff7
[gaim-migrate @ 13201]
Mark Doliner <markdoliner@pidgin.im>
parents:
11127
diff
changeset
|
323 | guchar *data; |
|
11127
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
11013
diff
changeset
|
324 | gsize size; |
| 10189 | 325 | const char *from = xmlnode_get_attrib(packet, "from"); |
| 326 | ||
| 327 | if(!from) | |
| 328 | return; | |
| 329 | ||
| 10941 | 330 | jb = jabber_buddy_find(js, from, TRUE); |
| 331 | ||
| 332 | js->pending_avatar_requests = g_slist_remove(js->pending_avatar_requests, jb); | |
| 333 | ||
| 10189 | 334 | if((vcard = xmlnode_get_child(packet, "vCard")) || |
| 335 | (vcard = xmlnode_get_child_with_namespace(packet, "query", "vcard-temp"))) { | |
| 10941 | 336 | if((photo = xmlnode_get_child(vcard, "PHOTO")) && |
| 11361 | 337 | (( (binval = xmlnode_get_child(photo, "BINVAL")) && |
| 338 | (text = xmlnode_get_data(binval))) || | |
| 339 | (text = xmlnode_get_data(photo)))) { | |
|
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
|
340 | unsigned char hashval[20]; |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16018
diff
changeset
|
341 | char hash[41], *p; |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16018
diff
changeset
|
342 | int i; |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16018
diff
changeset
|
343 | |
| 15884 | 344 | data = purple_base64_decode(text, &size); |
| 10189 | 345 | |
|
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
|
346 | purple_cipher_digest_region("sha1", data, size, |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16018
diff
changeset
|
347 | sizeof(hashval), hashval, NULL); |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16018
diff
changeset
|
348 | p = hash; |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16018
diff
changeset
|
349 | for(i=0; i<20; i++, p+=2) |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16018
diff
changeset
|
350 | snprintf(p, 3, "%02x", hashval[i]); |
| 10189 | 351 | |
|
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
|
352 | purple_buddy_icons_set_for_user(js->gc->account, from, data, size, hash); |
| 10941 | 353 | g_free(text); |
| 10189 | 354 | } |
| 355 | } | |
| 356 | } | |
| 357 | ||
|
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
|
358 | typedef struct _JabberPresenceCapabilities { |
|
1b7362b4a7a2
Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
17812
diff
changeset
|
359 | JabberStream *js; |
|
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
|
360 | JabberBuddyResource *jbr; |
|
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
|
361 | 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
|
362 | } 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
|
363 | |
|
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
|
364 | static void jabber_presence_set_capabilities(JabberCapsClientInfo *info, gpointer user_data) { |
|
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
|
365 | JabberPresenceCapabilities *userdata = user_data; |
|
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
|
366 | GList *iter; |
|
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
|
367 | |
|
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
|
368 | if(userdata->jbr->caps) |
|
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
|
369 | jabber_caps_free_clientinfo(userdata->jbr->caps); |
|
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
|
370 | userdata->jbr->caps = info; |
|
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
|
371 | |
|
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
|
372 | for(iter = info->features; iter; iter = g_list_next(iter)) { |
|
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
|
373 | if(!strcmp((const char*)iter->data, "http://jabber.org/protocol/commands")) { |
|
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
|
374 | JabberIq *iq = jabber_iq_new_query(userdata->js, JABBER_IQ_GET, "http://jabber.org/protocol/disco#items"); |
|
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
|
375 | xmlnode *query = xmlnode_get_child_with_namespace(iq->node,"query","http://jabber.org/protocol/disco#items"); |
|
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
|
376 | xmlnode_set_attrib(iq->node, "to", userdata->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
|
377 | xmlnode_set_attrib(query, "node", "http://jabber.org/protocol/commands"); |
|
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
|
378 | |
|
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
|
379 | jabber_iq_set_callback(iq, jabber_adhoc_disco_result_cb, NULL); |
|
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
|
380 | jabber_iq_send(iq); |
|
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
|
381 | break; |
|
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
|
382 | } |
|
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
|
383 | } |
|
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
|
384 | g_free(user_data); |
|
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
|
385 | } |
|
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
|
386 | |
| 7014 | 387 | void jabber_presence_parse(JabberStream *js, xmlnode *packet) |
| 388 | { | |
| 389 | const char *from = xmlnode_get_attrib(packet, "from"); | |
| 390 | const char *type = xmlnode_get_attrib(packet, "type"); | |
| 7944 | 391 | const char *real_jid = NULL; |
| 9152 | 392 | const char *affiliation = NULL; |
| 393 | const char *role = NULL; | |
| 7014 | 394 | char *status = NULL; |
| 395 | int priority = 0; | |
| 396 | JabberID *jid; | |
| 397 | JabberChat *chat; | |
| 398 | JabberBuddy *jb; | |
| 9954 | 399 | JabberBuddyResource *jbr = NULL, *found_jbr = NULL; |
| 15884 | 400 | PurpleConvChatBuddyFlags flags = PURPLE_CBFLAGS_NONE; |
|
9846
61f7349c153a
[gaim-migrate @ 10724]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9745
diff
changeset
|
401 | gboolean delayed = FALSE; |
| 15884 | 402 | PurpleBuddy *b = NULL; |
| 7014 | 403 | char *buddy_name; |
| 9954 | 404 | JabberBuddyState state = JABBER_BUDDY_STATE_UNKNOWN; |
| 7014 | 405 | xmlnode *y; |
| 406 | gboolean muc = FALSE; | |
| 10189 | 407 | char *avatar_hash = NULL; |
|
17816
1b7362b4a7a2
Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
17812
diff
changeset
|
408 | xmlnode *caps = NULL; |
| 7014 | 409 | |
| 8043 | 410 | if(!(jb = jabber_buddy_find(js, from, TRUE))) |
| 411 | return; | |
| 412 | ||
| 413 | if(!(jid = jabber_id_new(from))) | |
| 7280 | 414 | return; |
| 415 | ||
| 7014 | 416 | if(jb->error_msg) { |
| 417 | g_free(jb->error_msg); | |
| 418 | jb->error_msg = NULL; | |
| 419 | } | |
| 420 | ||
| 7813 | 421 | if(type && !strcmp(type, "error")) { |
| 8401 | 422 | char *msg = jabber_parse_error(js, packet); |
| 7644 | 423 | |
| 9954 | 424 | state = JABBER_BUDDY_STATE_ERROR; |
| 8401 | 425 | jb->error_msg = msg ? msg : g_strdup(_("Unknown Error in presence")); |
| 7813 | 426 | } else if(type && !strcmp(type, "subscribe")) { |
| 7014 | 427 | struct _jabber_add_permit *jap = g_new0(struct _jabber_add_permit, 1); |
| 15197 | 428 | gboolean onlist = FALSE; |
| 15884 | 429 | PurpleBuddy *buddy = purple_find_buddy(purple_connection_get_account(js->gc), from); |
| 15197 | 430 | JabberBuddy *jb = NULL; |
|
10949
b2949f5fc512
[gaim-migrate @ 12749]
Evan Schoenberg <evands@pidgin.im>
parents:
10941
diff
changeset
|
431 | |
| 15197 | 432 | if (buddy) { |
| 433 | jb = jabber_buddy_find(js, from, TRUE); | |
|
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
|
434 | if ((jb->subscription & JABBER_SUB_TO)) |
| 15197 | 435 | onlist = TRUE; |
| 436 | } | |
|
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
|
437 | |
| 7014 | 438 | jap->gc = js->gc; |
| 439 | jap->who = g_strdup(from); | |
| 12285 | 440 | jap->js = js; |
| 7014 | 441 | |
| 15884 | 442 | purple_account_request_authorization(purple_connection_get_account(js->gc), from, NULL, NULL, NULL, onlist, |
|
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
|
443 | G_CALLBACK(authorize_add_cb), G_CALLBACK(deny_add_cb), jap); |
| 8043 | 444 | jabber_id_free(jid); |
| 7145 | 445 | return; |
| 7813 | 446 | } else if(type && !strcmp(type, "subscribed")) { |
| 7014 | 447 | /* we've been allowed to see their presence, but we don't care */ |
| 8043 | 448 | jabber_id_free(jid); |
| 7014 | 449 | return; |
| 12285 | 450 | } else if(type && !strcmp(type, "unsubscribe")) { |
| 451 | /* XXX I'm not sure this is the right way to handle this, it | |
| 452 | * might be better to add "unsubscribe" to the presence status | |
| 453 | * if lower down, but I'm not sure. */ | |
| 454 | /* they are unsubscribing from our presence, we don't care */ | |
| 455 | /* Well, maybe just a little, we might want/need to start | |
| 456 | * acknowledging this (and the others) at some point. */ | |
| 457 | jabber_id_free(jid); | |
| 458 | return; | |
| 7014 | 459 | } else { |
| 460 | if((y = xmlnode_get_child(packet, "show"))) { | |
| 461 | char *show = xmlnode_get_data(y); | |
| 12683 | 462 | state = jabber_buddy_show_get_state(show); |
| 7014 | 463 | g_free(show); |
| 464 | } else { | |
| 9954 | 465 | state = JABBER_BUDDY_STATE_ONLINE; |
| 7014 | 466 | } |
| 467 | } | |
| 468 | ||
| 7310 | 469 | |
| 7014 | 470 | for(y = packet->child; y; y = y->next) { |
|
17816
1b7362b4a7a2
Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
17812
diff
changeset
|
471 | const char *xmlns; |
| 8135 | 472 | if(y->type != XMLNODE_TYPE_TAG) |
| 7014 | 473 | continue; |
|
17816
1b7362b4a7a2
Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
17812
diff
changeset
|
474 | xmlns = xmlnode_get_namespace(y); |
| 7014 | 475 | |
| 476 | if(!strcmp(y->name, "status")) { | |
| 7615 | 477 | g_free(status); |
| 7014 | 478 | status = xmlnode_get_data(y); |
| 479 | } else if(!strcmp(y->name, "priority")) { | |
| 480 | char *p = xmlnode_get_data(y); | |
| 481 | if(p) { | |
| 482 | priority = atoi(p); | |
| 483 | g_free(p); | |
| 484 | } | |
|
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
|
485 | } else if(!strcmp(y->name, "delay") && !strcmp(xmlns, "urn:xmpp:delay")) { |
|
17812
be440f0a0acf
Forgot to implement XEP-0203 for presence packets, too.
Andreas Monitzer <am@adiumx.com>
parents:
17801
diff
changeset
|
486 | /* XXX: compare the time. jabber:x:delay can happen on presence packets that aren't really and truly delayed */ |
|
be440f0a0acf
Forgot to implement XEP-0203 for presence packets, too.
Andreas Monitzer <am@adiumx.com>
parents:
17801
diff
changeset
|
487 | delayed = 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 | } else if(!strcmp(y->name, "c") && !strcmp(xmlns, "http://jabber.org/protocol/caps")) { |
|
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
|
489 | caps = y; /* store for later, when creating buddy resource */ |
| 7014 | 490 | } else if(!strcmp(y->name, "x")) { |
| 13808 | 491 | const char *xmlns = xmlnode_get_namespace(y); |
|
9846
61f7349c153a
[gaim-migrate @ 10724]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9745
diff
changeset
|
492 | if(xmlns && !strcmp(xmlns, "jabber:x:delay")) { |
| 9847 | 493 | /* XXX: compare the time. jabber:x:delay can happen on presence packets that aren't really and truly delayed */ |
|
9846
61f7349c153a
[gaim-migrate @ 10724]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9745
diff
changeset
|
494 | delayed = TRUE; |
|
61f7349c153a
[gaim-migrate @ 10724]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9745
diff
changeset
|
495 | } else if(xmlns && !strcmp(xmlns, "http://jabber.org/protocol/muc#user")) { |
| 7629 | 496 | xmlnode *z; |
| 497 | ||
| 7014 | 498 | muc = TRUE; |
| 7629 | 499 | if((z = xmlnode_get_child(y, "status"))) { |
| 500 | const char *code = xmlnode_get_attrib(z, "code"); | |
| 501 | if(code && !strcmp(code, "201")) { | |
| 13445 | 502 | if((chat = jabber_chat_find(js, jid->node, jid->domain))) { |
| 15884 | 503 | chat->config_dialog_type = PURPLE_REQUEST_ACTION; |
| 13445 | 504 | chat->config_dialog_handle = |
| 15884 | 505 | purple_request_action(js->gc, |
| 13445 | 506 | _("Create New Room"), |
| 507 | _("Create New Room"), | |
| 508 | _("You are creating a new room. Would" | |
| 509 | " you like to configure it, or" | |
| 510 | " accept the default settings?"), | |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16018
diff
changeset
|
511 | /* Default Action */ 1, |
|
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16018
diff
changeset
|
512 | purple_connection_get_account(js->gc), NULL, chat->conv, |
|
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16018
diff
changeset
|
513 | chat, 2, |
|
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16018
diff
changeset
|
514 | _("_Configure Room"), G_CALLBACK(jabber_chat_request_room_configure), |
|
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16018
diff
changeset
|
515 | _("_Accept Defaults"), G_CALLBACK(jabber_chat_create_instant_room)); |
| 13445 | 516 | } |
| 7629 | 517 | } |
| 518 | } | |
| 7944 | 519 | if((z = xmlnode_get_child(y, "item"))) { |
| 520 | real_jid = xmlnode_get_attrib(z, "jid"); | |
| 9152 | 521 | affiliation = xmlnode_get_attrib(z, "affiliation"); |
| 522 | role = xmlnode_get_attrib(z, "role"); | |
| 9931 | 523 | if(affiliation != NULL && !strcmp(affiliation, "owner")) |
| 15884 | 524 | flags |= PURPLE_CBFLAGS_FOUNDER; |
|
9743
839b2bce3853
[gaim-migrate @ 10608]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9559
diff
changeset
|
525 | if (role != NULL) { |
|
839b2bce3853
[gaim-migrate @ 10608]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9559
diff
changeset
|
526 | if (!strcmp(role, "moderator")) |
| 15884 | 527 | flags |= PURPLE_CBFLAGS_OP; |
|
9743
839b2bce3853
[gaim-migrate @ 10608]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9559
diff
changeset
|
528 | else if (!strcmp(role, "participant")) |
| 15884 | 529 | flags |= PURPLE_CBFLAGS_VOICE; |
|
9743
839b2bce3853
[gaim-migrate @ 10608]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9559
diff
changeset
|
530 | } |
| 7944 | 531 | } |
| 10189 | 532 | } else if(xmlns && !strcmp(xmlns, "vcard-temp:x:update")) { |
| 533 | xmlnode *photo = xmlnode_get_child(y, "photo"); | |
| 534 | if(photo) { | |
|
17702
15af85f94634
Don't check for null before calling free. I can't help but get rid
Mark Doliner <markdoliner@pidgin.im>
parents:
17683
diff
changeset
|
535 | g_free(avatar_hash); |
| 10189 | 536 | avatar_hash = xmlnode_get_data(photo); |
| 537 | } | |
| 7014 | 538 | } |
| 539 | } | |
| 540 | } | |
| 541 | ||
| 542 | ||
| 7322 | 543 | if(jid->node && (chat = jabber_chat_find(js, jid->node, jid->domain))) { |
| 8462 | 544 | static int i = 1; |
| 7014 | 545 | char *room_jid = g_strdup_printf("%s@%s", jid->node, jid->domain); |
| 546 | ||
| 17049 | 547 | if(state == JABBER_BUDDY_STATE_ERROR) { |
| 8401 | 548 | char *title, *msg = jabber_parse_error(js, packet); |
| 7014 | 549 | |
| 7321 | 550 | if(chat->conv) { |
| 8401 | 551 | title = g_strdup_printf(_("Error in chat %s"), from); |
| 7321 | 552 | serv_got_chat_left(js->gc, chat->id); |
| 553 | } else { | |
| 8401 | 554 | title = g_strdup_printf(_("Error joining chat %s"), from); |
| 7321 | 555 | } |
| 15884 | 556 | purple_notify_error(js->gc, title, title, msg); |
| 8401 | 557 | g_free(title); |
| 558 | g_free(msg); | |
| 7014 | 559 | |
| 560 | jabber_chat_destroy(chat); | |
| 7310 | 561 | jabber_id_free(jid); |
| 7615 | 562 | g_free(status); |
| 8182 | 563 | g_free(room_jid); |
|
17702
15af85f94634
Don't check for null before calling free. I can't help but get rid
Mark Doliner <markdoliner@pidgin.im>
parents:
17683
diff
changeset
|
564 | g_free(avatar_hash); |
| 7014 | 565 | return; |
| 566 | } | |
| 567 | ||
| 568 | ||
| 7813 | 569 | if(type && !strcmp(type, "unavailable")) { |
| 7972 | 570 | gboolean nick_change = FALSE; |
| 7973 | 571 | |
| 9152 | 572 | /* If we haven't joined the chat yet, we don't care that someone |
| 573 | * left, or it was us leaving after we closed the chat */ | |
| 8182 | 574 | if(!chat->conv) { |
| 10558 | 575 | if(jid->resource && chat->handle && !strcmp(jid->resource, chat->handle)) |
| 9152 | 576 | jabber_chat_destroy(chat); |
| 8182 | 577 | jabber_id_free(jid); |
| 578 | g_free(status); | |
| 579 | g_free(room_jid); | |
|
17702
15af85f94634
Don't check for null before calling free. I can't help but get rid
Mark Doliner <markdoliner@pidgin.im>
parents:
17683
diff
changeset
|
580 | g_free(avatar_hash); |
| 8182 | 581 | return; |
| 582 | } | |
| 583 | ||
| 7973 | 584 | jabber_buddy_remove_resource(jb, jid->resource); |
| 7972 | 585 | if(chat->muc) { |
| 586 | xmlnode *x; | |
| 8135 | 587 | for(x = xmlnode_get_child(packet, "x"); x; x = xmlnode_get_next_twin(x)) { |
| 7972 | 588 | const char *xmlns, *nick, *code; |
| 589 | xmlnode *stat, *item; | |
| 13808 | 590 | if(!(xmlns = xmlnode_get_namespace(x)) || |
| 7972 | 591 | strcmp(xmlns, "http://jabber.org/protocol/muc#user")) |
| 592 | continue; | |
| 593 | if(!(stat = xmlnode_get_child(x, "status"))) | |
| 594 | continue; | |
| 9152 | 595 | if(!(code = xmlnode_get_attrib(stat, "code"))) |
| 7972 | 596 | continue; |
| 9152 | 597 | if(!strcmp(code, "301")) { |
| 598 | /* XXX: we got banned */ | |
| 599 | } else if(!strcmp(code, "303")) { | |
| 600 | if(!(item = xmlnode_get_child(x, "item"))) | |
| 601 | continue; | |
| 602 | if(!(nick = xmlnode_get_attrib(item, "nick"))) | |
| 603 | continue; | |
| 604 | nick_change = TRUE; | |
| 605 | if(!strcmp(jid->resource, chat->handle)) { | |
| 606 | g_free(chat->handle); | |
| 607 | chat->handle = g_strdup(nick); | |
| 608 | } | |
| 15884 | 609 | purple_conv_chat_rename_user(PURPLE_CONV_CHAT(chat->conv), jid->resource, nick); |
| 9152 | 610 | jabber_chat_remove_handle(chat, jid->resource); |
| 611 | break; | |
| 612 | } else if(!strcmp(code, "307")) { | |
| 613 | /* XXX: we got kicked */ | |
| 614 | } else if(!strcmp(code, "321")) { | |
| 615 | /* XXX: removed due to an affiliation change */ | |
| 616 | } else if(!strcmp(code, "322")) { | |
| 617 | /* XXX: removed because room is now members-only */ | |
| 618 | } else if(!strcmp(code, "332")) { | |
| 619 | /* XXX: removed due to system shutdown */ | |
| 8401 | 620 | } |
| 7972 | 621 | } |
| 622 | } | |
| 623 | if(!nick_change) { | |
| 9152 | 624 | if(!g_utf8_collate(jid->resource, chat->handle)) { |
| 7972 | 625 | serv_got_chat_left(js->gc, chat->id); |
| 626 | jabber_chat_destroy(chat); | |
| 627 | } else { | |
| 15884 | 628 | purple_conv_chat_remove_user(PURPLE_CONV_CHAT(chat->conv), jid->resource, |
| 7974 | 629 | status); |
| 9152 | 630 | jabber_chat_remove_handle(chat, jid->resource); |
| 7972 | 631 | } |
| 7014 | 632 | } |
| 633 | } else { | |
| 8182 | 634 | if(!chat->conv) { |
| 635 | chat->id = i++; | |
| 636 | chat->muc = muc; | |
| 637 | chat->conv = serv_got_joined_chat(js->gc, chat->id, room_jid); | |
| 15884 | 638 | purple_conv_chat_set_nick(PURPLE_CONV_CHAT(chat->conv), chat->handle); |
| 10486 | 639 | |
| 10941 | 640 | jabber_chat_disco_traffic(chat); |
| 8182 | 641 | } |
| 642 | ||
| 7973 | 643 | jabber_buddy_track_resource(jb, jid->resource, priority, state, |
| 644 | status); | |
| 645 | ||
| 9152 | 646 | jabber_chat_track_handle(chat, jid->resource, real_jid, affiliation, role); |
| 647 | ||
| 7014 | 648 | if(!jabber_chat_find_buddy(chat->conv, jid->resource)) |
| 15884 | 649 | purple_conv_chat_add_user(PURPLE_CONV_CHAT(chat->conv), jid->resource, |
|
9846
61f7349c153a
[gaim-migrate @ 10724]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9745
diff
changeset
|
650 | real_jid, flags, !delayed); |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9320
diff
changeset
|
651 | else |
| 15884 | 652 | purple_conv_chat_user_set_flags(PURPLE_CONV_CHAT(chat->conv), jid->resource, |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9320
diff
changeset
|
653 | flags); |
| 7014 | 654 | } |
| 655 | g_free(room_jid); | |
| 656 | } else { | |
| 7322 | 657 | buddy_name = g_strdup_printf("%s%s%s", jid->node ? jid->node : "", |
| 658 | jid->node ? "@" : "", jid->domain); | |
| 15884 | 659 | if((b = purple_find_buddy(js->gc->account, buddy_name)) == NULL) { |
|
18310
dbc5240f6bf5
Fix a crash when you have an IM window open on a jabber account and the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18226
diff
changeset
|
660 | purple_debug_warning("jabber", "Got presence for unknown buddy %s on account %s (%x)\n", |
| 15884 | 661 | buddy_name, purple_account_get_username(js->gc->account), js->gc->account); |
| 7014 | 662 | jabber_id_free(jid); |
| 17703 | 663 | g_free(avatar_hash); |
| 7014 | 664 | g_free(buddy_name); |
| 7615 | 665 | g_free(status); |
| 7014 | 666 | return; |
| 667 | } | |
| 668 | ||
| 10189 | 669 | if(avatar_hash) { |
|
16534
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16018
diff
changeset
|
670 | const char *avatar_hash2 = purple_buddy_icons_get_checksum_for_user(b); |
| 10189 | 671 | if(!avatar_hash2 || strcmp(avatar_hash, avatar_hash2)) { |
| 672 | JabberIq *iq; | |
| 673 | xmlnode *vcard; | |
| 674 | ||
| 10941 | 675 | /* XXX this is a crappy way of trying to prevent |
| 676 | * someone from spamming us with presence packets | |
| 677 | * and causing us to DoS ourselves...what we really | |
| 678 | * need is a queue system that can throttle itself, | |
| 679 | * but i'm too tired to write that right now */ | |
| 680 | if(!g_slist_find(js->pending_avatar_requests, jb)) { | |
| 681 | ||
| 682 | js->pending_avatar_requests = g_slist_prepend(js->pending_avatar_requests, jb); | |
| 10189 | 683 | |
| 10941 | 684 | iq = jabber_iq_new(js, JABBER_IQ_GET); |
| 685 | xmlnode_set_attrib(iq->node, "to", buddy_name); | |
| 686 | vcard = xmlnode_new_child(iq->node, "vCard"); | |
| 13808 | 687 | xmlnode_set_namespace(vcard, "vcard-temp"); |
| 10941 | 688 | |
| 689 | jabber_iq_set_callback(iq, jabber_vcard_parse_avatar, NULL); | |
| 690 | jabber_iq_send(iq); | |
| 691 | } | |
| 10189 | 692 | } |
| 693 | } | |
| 694 | ||
| 9954 | 695 | if(state == JABBER_BUDDY_STATE_ERROR || |
| 7813 | 696 | (type && (!strcmp(type, "unavailable") || |
| 697 | !strcmp(type, "unsubscribed")))) { | |
| 15884 | 698 | PurpleConversation *conv; |
| 8043 | 699 | |
| 7014 | 700 | jabber_buddy_remove_resource(jb, jid->resource); |
| 8043 | 701 | if((conv = jabber_find_unnormalized_conv(from, js->gc->account))) |
| 15884 | 702 | purple_conversation_set_name(conv, buddy_name); |
| 8043 | 703 | |
| 7395 | 704 | } else { |
| 9954 | 705 | jbr = jabber_buddy_track_resource(jb, jid->resource, priority, |
| 706 | state, status); | |
|
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
|
707 | if(caps) { |
|
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
|
708 | const char *node = xmlnode_get_attrib(caps,"node"); |
|
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
|
709 | const char *ver = xmlnode_get_attrib(caps,"ver"); |
|
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
|
710 | const char *ext = xmlnode_get_attrib(caps,"ext"); |
|
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
|
711 | |
|
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
|
712 | if(node && ver) { |
|
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
|
713 | JabberPresenceCapabilities *userdata = g_new0(JabberPresenceCapabilities, 1); |
|
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
|
714 | userdata->js = js; |
|
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
|
715 | userdata->jbr = jbr; |
|
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
|
716 | userdata->from = g_strdup(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
|
717 | jabber_caps_get_info(js, from, node, ver, ext, jabber_presence_set_capabilities, userdata); |
|
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
|
718 | } |
|
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
|
719 | } |
| 7395 | 720 | } |
| 7014 | 721 | |
| 9954 | 722 | if((found_jbr = jabber_buddy_find_resource(jb, NULL))) { |
|
18366
6a0ad943967f
When an XMPP buddy signs off, show the status of the currently highest priority buddy, rather than the status of the signed off buddy. Fixes #1126
Sean Egan <seanegan@pidgin.im>
parents:
18330
diff
changeset
|
723 | purple_prpl_got_user_status(js->gc->account, buddy_name, jabber_buddy_state_get_status_id(found_jbr->state), "priority", found_jbr->priority, found_jbr->status ? "message" : NULL, found_jbr->status, NULL); |
| 9954 | 724 | } else { |
| 15884 | 725 | purple_prpl_got_user_status(js->gc->account, buddy_name, "offline", status ? "message" : NULL, status, NULL); |
| 9954 | 726 | } |
| 7014 | 727 | g_free(buddy_name); |
| 728 | } | |
| 729 | g_free(status); | |
| 730 | jabber_id_free(jid); | |
|
17702
15af85f94634
Don't check for null before calling free. I can't help but get rid
Mark Doliner <markdoliner@pidgin.im>
parents:
17683
diff
changeset
|
731 | g_free(avatar_hash); |
| 7014 | 732 | } |
| 733 | ||
| 734 | void jabber_presence_subscription_set(JabberStream *js, const char *who, const char *type) | |
| 735 | { | |
| 736 | xmlnode *presence = xmlnode_new("presence"); | |
| 737 | ||
| 738 | xmlnode_set_attrib(presence, "to", who); | |
| 739 | xmlnode_set_attrib(presence, "type", type); | |
| 740 | ||
| 741 | jabber_send(js, presence); | |
| 742 | xmlnode_free(presence); | |
| 743 | } | |
| 9954 | 744 | |
| 15884 | 745 | void purple_status_to_jabber(const PurpleStatus *status, JabberBuddyState *state, char **msg, int *priority) |
| 9954 | 746 | { |
| 10216 | 747 | const char *status_id = NULL; |
| 14525 | 748 | const char *formatted_msg = NULL; |
| 10216 | 749 | |
| 13443 | 750 | if(state) *state = JABBER_BUDDY_STATE_UNKNOWN; |
| 751 | if(msg) *msg = NULL; | |
| 752 | if(priority) *priority = 0; | |
| 9954 | 753 | |
| 754 | if(!status) { | |
| 13443 | 755 | if(state) *state = JABBER_BUDDY_STATE_UNAVAILABLE; |
| 10216 | 756 | } else { |
| 757 | if(state) { | |
| 15884 | 758 | status_id = purple_status_get_id(status); |
| 10216 | 759 | *state = jabber_buddy_status_id_get_state(status_id); |
| 760 | } | |
| 761 | ||
|
13497
07fc0a9826b8
[gaim-migrate @ 15872]
Richard Laager <rlaager@pidgin.im>
parents:
13445
diff
changeset
|
762 | if(msg) { |
| 15884 | 763 | formatted_msg = purple_status_get_attr_string(status, "message"); |
| 10216 | 764 | |
|
13497
07fc0a9826b8
[gaim-migrate @ 15872]
Richard Laager <rlaager@pidgin.im>
parents:
13445
diff
changeset
|
765 | /* if the message is blank, then there really isn't a message */ |
| 14525 | 766 | if(formatted_msg && !*formatted_msg) |
| 767 | formatted_msg = NULL; | |
| 768 | ||
| 769 | if(formatted_msg) | |
| 17683 | 770 | *msg = purple_markup_strip_html(formatted_msg); |
|
13497
07fc0a9826b8
[gaim-migrate @ 15872]
Richard Laager <rlaager@pidgin.im>
parents:
13445
diff
changeset
|
771 | } |
| 11872 | 772 | |
| 10216 | 773 | if(priority) |
| 15884 | 774 | *priority = purple_status_get_attr_int(status, "priority"); |
| 9954 | 775 | } |
| 776 | } |