Sun, 22 Jun 2008 17:25:23 +0000
* changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
* added function which parses a query node to internal caps structure
| 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 | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19335
diff
changeset
|
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 7014 | 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" | |
|
21195
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
21193
diff
changeset
|
36 | #include "google.h" |
| 7014 | 37 | #include "presence.h" |
| 38 | #include "iq.h" | |
| 39 | #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
|
40 | #include "adhoccommands.h" |
| 7014 | 41 | |
|
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
|
42 | #include "usertune.h" |
| 7014 | 43 | |
| 44 | ||
| 45 | static void chats_send_presence_foreach(gpointer key, gpointer val, | |
| 46 | gpointer user_data) | |
| 47 | { | |
| 48 | JabberChat *chat = val; | |
| 49 | xmlnode *presence = user_data; | |
| 8577 | 50 | char *chat_full_jid; |
| 51 | ||
|
23403
a8704d47889f
Fix the chat-room rejoining bug where the list appears empty.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23270
diff
changeset
|
52 | if(!chat->conv || chat->left) |
| 8577 | 53 | return; |
| 54 | ||
| 55 | chat_full_jid = g_strdup_printf("%s@%s/%s", chat->room, chat->server, | |
| 8401 | 56 | chat->handle); |
| 7014 | 57 | |
| 8401 | 58 | xmlnode_set_attrib(presence, "to", chat_full_jid); |
| 7014 | 59 | jabber_send(chat->js, presence); |
| 8401 | 60 | g_free(chat_full_jid); |
| 7014 | 61 | } |
| 62 | ||
| 15884 | 63 | void jabber_presence_fake_to_self(JabberStream *js, const PurpleStatus *gstatus) { |
| 10286 | 64 | char *my_base_jid; |
| 65 | ||
| 66 | if(!js->user) | |
| 67 | return; | |
| 68 | ||
| 69 | my_base_jid = g_strdup_printf("%s@%s", js->user->node, js->user->domain); | |
| 15884 | 70 | if(purple_find_buddy(js->gc->account, my_base_jid)) { |
| 8185 | 71 | JabberBuddy *jb; |
| 72 | JabberBuddyResource *jbr; | |
| 73 | if((jb = jabber_buddy_find(js, my_base_jid, TRUE))) { | |
| 9954 | 74 | JabberBuddyState state; |
| 14525 | 75 | char *msg; |
| 9954 | 76 | int priority; |
| 77 | ||
| 15884 | 78 | purple_status_to_jabber(gstatus, &state, &msg, &priority); |
| 9954 | 79 | |
| 10490 | 80 | 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
|
81 | jabber_buddy_remove_resource(jb, js->user->resource); |
|
c2b450de1fc0
[gaim-migrate @ 10609]
Daniel Atallah <datallah@pidgin.im>
parents:
9743
diff
changeset
|
82 | } else { |
| 9954 | 83 | 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
|
84 | } |
| 9954 | 85 | if((jbr = jabber_buddy_find_resource(jb, NULL))) { |
| 15884 | 86 | 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 | 87 | } else { |
| 15884 | 88 | purple_prpl_got_user_status(js->gc->account, my_base_jid, "offline", msg ? "message" : NULL, msg, NULL); |
| 9954 | 89 | } |
| 14525 | 90 | |
| 91 | g_free(msg); | |
| 8185 | 92 | } |
| 93 | } | |
| 94 | g_free(my_base_jid); | |
| 95 | } | |
| 96 | ||
| 7014 | 97 | |
| 15884 | 98 | void jabber_presence_send(PurpleAccount *account, PurpleStatus *status) |
| 7014 | 99 | { |
| 15884 | 100 | PurpleConnection *gc = NULL; |
|
10382
32e07712e224
[gaim-migrate @ 11608]
Luke Schierer <lschiere@pidgin.im>
parents:
10286
diff
changeset
|
101 | JabberStream *js = NULL; |
| 10189 | 102 | xmlnode *presence, *x, *photo; |
| 7014 | 103 | char *stripped = NULL; |
| 9954 | 104 | JabberBuddyState state; |
| 105 | int priority; | |
|
21193
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20169
diff
changeset
|
106 | const char *artist = NULL, *title = NULL, *source = NULL, *uri = NULL, *track = NULL; |
|
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20169
diff
changeset
|
107 | int length = -1; |
|
17824
52683dfc1f7d
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <am@adiumx.com>
parents:
17816
diff
changeset
|
108 | gboolean allowBuzz; |
|
21758
e70c407c994b
We need to work with the exclusive status.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21687
diff
changeset
|
109 | PurplePresence *p; |
|
21193
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20169
diff
changeset
|
110 | PurpleStatus *tune; |
| 7014 | 111 | |
|
21758
e70c407c994b
We need to work with the exclusive status.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21687
diff
changeset
|
112 | if (purple_account_is_disconnected(account)) |
|
e70c407c994b
We need to work with the exclusive status.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21687
diff
changeset
|
113 | return; |
|
e70c407c994b
We need to work with the exclusive status.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21687
diff
changeset
|
114 | |
|
e70c407c994b
We need to work with the exclusive status.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21687
diff
changeset
|
115 | p = purple_account_get_presence(account); |
|
21197
f109bdb267e0
presence is an xmlnode here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21195
diff
changeset
|
116 | if (NULL == status) { |
|
f109bdb267e0
presence is an xmlnode here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21195
diff
changeset
|
117 | status = purple_presence_get_active_status(p); |
|
18195
9cd0565f856e
kill some code duplication when sending current presence
Nathan Walp <nwalp@pidgin.im>
parents:
17703
diff
changeset
|
118 | } |
|
9cd0565f856e
kill some code duplication when sending current presence
Nathan Walp <nwalp@pidgin.im>
parents:
17703
diff
changeset
|
119 | |
|
21758
e70c407c994b
We need to work with the exclusive status.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21687
diff
changeset
|
120 | if (purple_status_is_exclusive(status)) { |
|
e70c407c994b
We need to work with the exclusive status.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21687
diff
changeset
|
121 | /* An exclusive status can't be deactivated. You should just |
|
e70c407c994b
We need to work with the exclusive status.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21687
diff
changeset
|
122 | * activate some other exclusive status. */ |
|
e70c407c994b
We need to work with the exclusive status.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21687
diff
changeset
|
123 | if (!purple_status_is_active(status)) |
|
e70c407c994b
We need to work with the exclusive status.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21687
diff
changeset
|
124 | return; |
|
e70c407c994b
We need to work with the exclusive status.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21687
diff
changeset
|
125 | } else { |
|
e70c407c994b
We need to work with the exclusive status.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21687
diff
changeset
|
126 | /* Work with the exclusive status. */ |
|
e70c407c994b
We need to work with the exclusive status.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21687
diff
changeset
|
127 | status = purple_presence_get_active_status(p); |
|
e70c407c994b
We need to work with the exclusive status.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21687
diff
changeset
|
128 | } |
| 17422 | 129 | |
| 15884 | 130 | gc = purple_account_get_connection(account); |
|
10755
a336a5d3102d
[gaim-migrate @ 12358]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
131 | js = gc->proto_data; |
|
a336a5d3102d
[gaim-migrate @ 12358]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
132 | |
|
18226
adf83935e838
really and truly enforce the no-presence-before-roster thing
Nathan Walp <nwalp@pidgin.im>
parents:
18195
diff
changeset
|
133 | /* 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
|
134 | if(!js->roster_parsed) { |
|
adf83935e838
really and truly enforce the no-presence-before-roster thing
Nathan Walp <nwalp@pidgin.im>
parents:
18195
diff
changeset
|
135 | 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
|
136 | return; |
|
adf83935e838
really and truly enforce the no-presence-before-roster thing
Nathan Walp <nwalp@pidgin.im>
parents:
18195
diff
changeset
|
137 | } |
|
adf83935e838
really and truly enforce the no-presence-before-roster thing
Nathan Walp <nwalp@pidgin.im>
parents:
18195
diff
changeset
|
138 | |
| 15884 | 139 | 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
|
140 | |
|
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
|
141 | /* 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
|
142 | 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
|
143 | /* 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
|
144 | |
|
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 | #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
|
146 | (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
|
147 | /* 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
|
148 | 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
|
149 | 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
|
150 | js->allowBuzz = allowBuzz; |
|
21195
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
21193
diff
changeset
|
151 | |
|
21197
f109bdb267e0
presence is an xmlnode here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21195
diff
changeset
|
152 | if (js->googletalk && stripped == NULL && purple_presence_is_status_primitive_active(p, PURPLE_STATUS_TUNE)) { |
|
f109bdb267e0
presence is an xmlnode here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21195
diff
changeset
|
153 | tune = purple_presence_get_status(p, "tune"); |
|
21195
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
21193
diff
changeset
|
154 | stripped = jabber_google_presence_outgoing(tune); |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
21193
diff
changeset
|
155 | } |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
21193
diff
changeset
|
156 | |
|
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
|
157 | presence = jabber_presence_create_js(js, state, stripped, priority); |
| 7014 | 158 | |
|
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
|
159 | 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
|
160 | 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
|
161 | 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
|
162 | 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
|
163 | 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
|
164 | } |
|
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 | |
|
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 | jabber_send(js, presence); |
| 7014 | 167 | |
|
17800
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
168 | 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
|
169 | 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
|
170 | |
|
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
|
171 | /* 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
|
172 | |
|
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
|
173 | 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
|
174 | 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
|
175 | 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
|
176 | 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
|
177 | 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
|
178 | 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
|
179 | 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
|
180 | js->old_priority = priority; |
|
17801
1a29a61dda8d
fixed a bug in the status change tracking code
Andreas Monitzer <am@adiumx.com>
parents:
17800
diff
changeset
|
181 | g_free(stripped); |
| 10189 | 182 | } |
|
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
|
183 | |
|
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
|
184 | /* next, check if there are any changes to the tune values */ |
|
21197
f109bdb267e0
presence is an xmlnode here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21195
diff
changeset
|
185 | tune = purple_presence_get_status(p, "tune"); |
|
21193
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20169
diff
changeset
|
186 | if (tune && purple_status_is_active(tune)) { |
|
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20169
diff
changeset
|
187 | artist = purple_status_get_attr_string(tune, PURPLE_TUNE_ARTIST); |
|
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20169
diff
changeset
|
188 | title = purple_status_get_attr_string(tune, PURPLE_TUNE_TITLE); |
|
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20169
diff
changeset
|
189 | source = purple_status_get_attr_string(tune, PURPLE_TUNE_ALBUM); |
|
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20169
diff
changeset
|
190 | uri = purple_status_get_attr_string(tune, PURPLE_TUNE_URL); |
|
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20169
diff
changeset
|
191 | track = purple_status_get_attr_string(tune, PURPLE_TUNE_TRACK); |
|
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20169
diff
changeset
|
192 | length = (!purple_status_get_attr_value(tune, PURPLE_TUNE_TIME)) ? -1 : |
|
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20169
diff
changeset
|
193 | purple_status_get_attr_int(tune, PURPLE_TUNE_TIME); |
|
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20169
diff
changeset
|
194 | } |
|
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
|
195 | |
|
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 | 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
|
197 | 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
|
198 | 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
|
199 | (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
|
200 | (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
|
201 | (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
|
202 | (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
|
203 | 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
|
204 | (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
|
205 | }; |
|
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 | 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
|
207 | |
|
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 | /* update old values */ |
|
20169
497e1cd1e059
Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents:
19899
diff
changeset
|
209 | g_free(js->old_artist); |
|
497e1cd1e059
Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents:
19899
diff
changeset
|
210 | g_free(js->old_title); |
|
497e1cd1e059
Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents:
19899
diff
changeset
|
211 | g_free(js->old_source); |
|
497e1cd1e059
Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents:
19899
diff
changeset
|
212 | g_free(js->old_uri); |
|
497e1cd1e059
Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents:
19899
diff
changeset
|
213 | g_free(js->old_track); |
|
17800
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
214 | 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
|
215 | 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
|
216 | 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
|
217 | 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
|
218 | 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
|
219 | js->old_track = g_strdup(track); |
| 10189 | 220 | } |
| 221 | ||
|
19899
483c4f495a6c
Various warning fixes for the xmpp prpl.
Daniel Atallah <datallah@pidgin.im>
parents:
19897
diff
changeset
|
222 | #undef CHANGED |
| 8185 | 223 | |
| 9954 | 224 | jabber_presence_fake_to_self(js, status); |
| 7014 | 225 | } |
| 226 | ||
| 9954 | 227 | xmlnode *jabber_presence_create(JabberBuddyState state, const char *msg, int priority) |
| 7014 | 228 | { |
|
17770
e67998927a3c
Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents:
17422
diff
changeset
|
229 | 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
|
230 | } |
|
e67998927a3c
Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents:
17422
diff
changeset
|
231 | |
|
e67998927a3c
Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents:
17422
diff
changeset
|
232 | 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
|
233 | { |
| 13385 | 234 | xmlnode *show, *status, *presence, *pri, *c; |
| 9954 | 235 | const char *show_string = NULL; |
| 7014 | 236 | |
| 237 | presence = xmlnode_new("presence"); | |
| 238 | ||
| 9954 | 239 | if(state == JABBER_BUDDY_STATE_UNAVAILABLE) |
| 240 | xmlnode_set_attrib(presence, "type", "unavailable"); | |
| 241 | else if(state != JABBER_BUDDY_STATE_ONLINE && | |
| 242 | state != JABBER_BUDDY_STATE_UNKNOWN && | |
| 243 | state != JABBER_BUDDY_STATE_ERROR) | |
| 12683 | 244 | show_string = jabber_buddy_state_get_show(state); |
| 9954 | 245 | |
| 246 | if(show_string) { | |
| 247 | show = xmlnode_new_child(presence, "show"); | |
| 248 | xmlnode_insert_data(show, show_string, -1); | |
| 7014 | 249 | } |
| 250 | ||
| 9954 | 251 | if(msg) { |
| 7014 | 252 | status = xmlnode_new_child(presence, "status"); |
| 253 | xmlnode_insert_data(status, msg, -1); | |
| 254 | } | |
| 255 | ||
| 11568 | 256 | if(priority) { |
| 257 | char *pstr = g_strdup_printf("%d", priority); | |
| 258 | pri = xmlnode_new_child(presence, "priority"); | |
| 259 | xmlnode_insert_data(pri, pstr, -1); | |
| 260 | g_free(pstr); | |
| 261 | } | |
| 262 | ||
| 13385 | 263 | /* JEP-0115 */ |
| 264 | c = xmlnode_new_child(presence, "c"); | |
| 13808 | 265 | xmlnode_set_namespace(c, "http://jabber.org/protocol/caps"); |
| 13385 | 266 | xmlnode_set_attrib(c, "node", CAPS0115_NODE); |
|
23586
e495a4623f76
Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23403
diff
changeset
|
267 | xmlnode_set_attrib(c, "hash", "sha-1"); |
|
23587
1691c5361029
* changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23586
diff
changeset
|
268 | xmlnode_set_attrib(c, "ver", jabber_caps_get_own_hash()); |
|
23586
e495a4623f76
Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23403
diff
changeset
|
269 | |
|
e495a4623f76
Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23403
diff
changeset
|
270 | #if 0 |
|
19894
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
19389
diff
changeset
|
271 | if(js != NULL) { |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
19389
diff
changeset
|
272 | /* add the extensions */ |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
19389
diff
changeset
|
273 | char extlist[1024]; |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
19389
diff
changeset
|
274 | unsigned remaining = 1023; /* one less for the \0 */ |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
19389
diff
changeset
|
275 | GList *feature; |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
19389
diff
changeset
|
276 | |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
19389
diff
changeset
|
277 | extlist[0] = '\0'; |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
19389
diff
changeset
|
278 | for(feature = jabber_features; feature && remaining > 0; feature = feature->next) { |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
19389
diff
changeset
|
279 | JabberFeature *feat = (JabberFeature*)feature->data; |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
19389
diff
changeset
|
280 | unsigned featlen; |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
19389
diff
changeset
|
281 | |
|
23586
e495a4623f76
Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23403
diff
changeset
|
282 | if(feat->is_enabled != NULL && feat->is_enabled(js, feat->namespace) == FALSE) |
|
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
|
283 | 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
|
284 | |
|
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
|
285 | featlen = strlen(feat->shortname); |
|
19894
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
19389
diff
changeset
|
286 | |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
19389
diff
changeset
|
287 | /* cut off when we don't have any more space left in our buffer (too bad) */ |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
19389
diff
changeset
|
288 | if(featlen > remaining) |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
19389
diff
changeset
|
289 | break; |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
19389
diff
changeset
|
290 | |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
19389
diff
changeset
|
291 | strncat(extlist,feat->shortname,remaining); |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
19389
diff
changeset
|
292 | remaining -= featlen; |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
19389
diff
changeset
|
293 | if(feature->next) { /* no space at the end */ |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
19389
diff
changeset
|
294 | strncat(extlist," ",remaining); |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
19389
diff
changeset
|
295 | --remaining; |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
19389
diff
changeset
|
296 | } |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
19389
diff
changeset
|
297 | } |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
19389
diff
changeset
|
298 | /* did we add anything? */ |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
19389
diff
changeset
|
299 | if(remaining < 1023) |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
19389
diff
changeset
|
300 | xmlnode_set_attrib(c, "ext", extlist); |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
19389
diff
changeset
|
301 | } |
|
23586
e495a4623f76
Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23403
diff
changeset
|
302 | #endif |
| 7014 | 303 | return presence; |
| 304 | } | |
| 305 | ||
| 306 | struct _jabber_add_permit { | |
| 15884 | 307 | PurpleConnection *gc; |
| 12285 | 308 | JabberStream *js; |
| 7014 | 309 | char *who; |
| 310 | }; | |
| 311 | ||
|
19335
4613b53d5741
Warning fixes in the aftermath of resiak's authorize_cb and deny_cb type fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
18991
diff
changeset
|
312 | static void authorize_add_cb(gpointer data) |
| 7014 | 313 | { |
|
19335
4613b53d5741
Warning fixes in the aftermath of resiak's authorize_cb and deny_cb type fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
18991
diff
changeset
|
314 | struct _jabber_add_permit *jap = data; |
|
21687
a191b234bf75
Prevent crashing when authorizing or denying after the account is disconnected.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
315 | if(PURPLE_CONNECTION_IS_VALID(jap->gc)) |
|
a191b234bf75
Prevent crashing when authorizing or denying after the account is disconnected.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
316 | jabber_presence_subscription_set(jap->gc->proto_data, |
|
a191b234bf75
Prevent crashing when authorizing or denying after the account is disconnected.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
317 | jap->who, "subscribed"); |
| 7014 | 318 | g_free(jap->who); |
| 319 | g_free(jap); | |
| 320 | } | |
| 321 | ||
|
19335
4613b53d5741
Warning fixes in the aftermath of resiak's authorize_cb and deny_cb type fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
18991
diff
changeset
|
322 | static void deny_add_cb(gpointer data) |
| 7014 | 323 | { |
|
19335
4613b53d5741
Warning fixes in the aftermath of resiak's authorize_cb and deny_cb type fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
18991
diff
changeset
|
324 | struct _jabber_add_permit *jap = data; |
|
21687
a191b234bf75
Prevent crashing when authorizing or denying after the account is disconnected.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
325 | if(PURPLE_CONNECTION_IS_VALID(jap->gc)) |
|
a191b234bf75
Prevent crashing when authorizing or denying after the account is disconnected.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
326 | jabber_presence_subscription_set(jap->gc->proto_data, |
|
a191b234bf75
Prevent crashing when authorizing or denying after the account is disconnected.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
327 | jap->who, "unsubscribed"); |
| 7014 | 328 | g_free(jap->who); |
| 329 | g_free(jap); | |
| 330 | } | |
| 331 | ||
| 10189 | 332 | static void jabber_vcard_parse_avatar(JabberStream *js, xmlnode *packet, gpointer blah) |
| 333 | { | |
| 10941 | 334 | JabberBuddy *jb = NULL; |
| 335 | xmlnode *vcard, *photo, *binval; | |
|
11127
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
11013
diff
changeset
|
336 | char *text; |
|
11137
cf40226ddff7
[gaim-migrate @ 13201]
Mark Doliner <markdoliner@pidgin.im>
parents:
11127
diff
changeset
|
337 | guchar *data; |
|
11127
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
11013
diff
changeset
|
338 | gsize size; |
| 10189 | 339 | const char *from = xmlnode_get_attrib(packet, "from"); |
| 340 | ||
| 341 | if(!from) | |
| 342 | return; | |
| 343 | ||
| 10941 | 344 | jb = jabber_buddy_find(js, from, TRUE); |
| 345 | ||
| 346 | js->pending_avatar_requests = g_slist_remove(js->pending_avatar_requests, jb); | |
| 347 | ||
| 10189 | 348 | if((vcard = xmlnode_get_child(packet, "vCard")) || |
| 349 | (vcard = xmlnode_get_child_with_namespace(packet, "query", "vcard-temp"))) { | |
| 10941 | 350 | if((photo = xmlnode_get_child(vcard, "PHOTO")) && |
| 11361 | 351 | (( (binval = xmlnode_get_child(photo, "BINVAL")) && |
| 352 | (text = xmlnode_get_data(binval))) || | |
| 353 | (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
|
354 | 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
|
355 | 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
|
356 | 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
|
357 | |
| 15884 | 358 | data = purple_base64_decode(text, &size); |
| 10189 | 359 | |
|
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
|
360 | 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
|
361 | 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
|
362 | 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
|
363 | 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
|
364 | snprintf(p, 3, "%02x", hashval[i]); |
| 10189 | 365 | |
|
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
|
366 | purple_buddy_icons_set_for_user(js->gc->account, from, data, size, hash); |
| 10941 | 367 | g_free(text); |
| 10189 | 368 | } |
| 369 | } | |
| 370 | } | |
| 371 | ||
|
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
|
372 | 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
|
373 | JabberStream *js; |
|
22929
f1860f6e1344
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents:
22622
diff
changeset
|
374 | JabberBuddy *jb; |
|
17816
1b7362b4a7a2
Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
17812
diff
changeset
|
375 | 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
|
376 | } 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
|
377 | |
|
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 | 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
|
379 | JabberPresenceCapabilities *userdata = user_data; |
|
22929
f1860f6e1344
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents:
22622
diff
changeset
|
380 | JabberID *jid; |
|
f1860f6e1344
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents:
22622
diff
changeset
|
381 | JabberBuddyResource *jbr; |
|
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
|
382 | GList *iter; |
|
21801
6d92632a6424
Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <datallah@pidgin.im>
parents:
21758
diff
changeset
|
383 | |
|
22929
f1860f6e1344
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents:
22622
diff
changeset
|
384 | jid = jabber_id_new(userdata->from); |
|
f1860f6e1344
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents:
22622
diff
changeset
|
385 | jbr = jabber_buddy_find_resource(userdata->jb, jid->resource); |
|
f1860f6e1344
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents:
22622
diff
changeset
|
386 | jabber_id_free(jid); |
|
f1860f6e1344
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents:
22622
diff
changeset
|
387 | |
|
f1860f6e1344
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents:
22622
diff
changeset
|
388 | if(!jbr) { |
|
f1860f6e1344
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents:
22622
diff
changeset
|
389 | g_free(userdata->from); |
|
f1860f6e1344
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents:
22622
diff
changeset
|
390 | g_free(userdata); |
|
f1860f6e1344
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents:
22622
diff
changeset
|
391 | return; |
|
f1860f6e1344
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents:
22622
diff
changeset
|
392 | } |
|
f1860f6e1344
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents:
22622
diff
changeset
|
393 | |
|
f1860f6e1344
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents:
22622
diff
changeset
|
394 | if(jbr->caps) |
|
f1860f6e1344
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents:
22622
diff
changeset
|
395 | jabber_caps_free_clientinfo(jbr->caps); |
|
f1860f6e1344
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents:
22622
diff
changeset
|
396 | jbr->caps = info; |
|
21801
6d92632a6424
Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <datallah@pidgin.im>
parents:
21758
diff
changeset
|
397 | |
|
6d92632a6424
Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <datallah@pidgin.im>
parents:
21758
diff
changeset
|
398 | if (info) { |
|
6d92632a6424
Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <datallah@pidgin.im>
parents:
21758
diff
changeset
|
399 | for(iter = info->features; iter; iter = g_list_next(iter)) { |
|
6d92632a6424
Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <datallah@pidgin.im>
parents:
21758
diff
changeset
|
400 | if(!strcmp((const char*)iter->data, "http://jabber.org/protocol/commands")) { |
|
6d92632a6424
Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <datallah@pidgin.im>
parents:
21758
diff
changeset
|
401 | JabberIq *iq = jabber_iq_new_query(userdata->js, JABBER_IQ_GET, "http://jabber.org/protocol/disco#items"); |
|
6d92632a6424
Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <datallah@pidgin.im>
parents:
21758
diff
changeset
|
402 | xmlnode *query = xmlnode_get_child_with_namespace(iq->node,"query","http://jabber.org/protocol/disco#items"); |
|
6d92632a6424
Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <datallah@pidgin.im>
parents:
21758
diff
changeset
|
403 | xmlnode_set_attrib(iq->node, "to", userdata->from); |
|
6d92632a6424
Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <datallah@pidgin.im>
parents:
21758
diff
changeset
|
404 | xmlnode_set_attrib(query, "node", "http://jabber.org/protocol/commands"); |
|
6d92632a6424
Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <datallah@pidgin.im>
parents:
21758
diff
changeset
|
405 | |
|
6d92632a6424
Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <datallah@pidgin.im>
parents:
21758
diff
changeset
|
406 | jabber_iq_set_callback(iq, jabber_adhoc_disco_result_cb, NULL); |
|
6d92632a6424
Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <datallah@pidgin.im>
parents:
21758
diff
changeset
|
407 | jabber_iq_send(iq); |
|
6d92632a6424
Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <datallah@pidgin.im>
parents:
21758
diff
changeset
|
408 | break; |
|
6d92632a6424
Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <datallah@pidgin.im>
parents:
21758
diff
changeset
|
409 | } |
|
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
|
410 | } |
|
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
|
411 | } |
|
21801
6d92632a6424
Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <datallah@pidgin.im>
parents:
21758
diff
changeset
|
412 | |
|
20210
d3336754b1a9
applied changes from d50ecf4dc52f25cbd219d6c19846436dec5a8853
Luke Schierer <lschiere@pidgin.im>
parents:
20169
diff
changeset
|
413 | g_free(userdata->from); |
|
d3336754b1a9
applied changes from d50ecf4dc52f25cbd219d6c19846436dec5a8853
Luke Schierer <lschiere@pidgin.im>
parents:
20169
diff
changeset
|
414 | g_free(userdata); |
|
17816
1b7362b4a7a2
Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
17812
diff
changeset
|
415 | } |
|
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
|
416 | |
| 7014 | 417 | void jabber_presence_parse(JabberStream *js, xmlnode *packet) |
| 418 | { | |
| 419 | const char *from = xmlnode_get_attrib(packet, "from"); | |
| 420 | const char *type = xmlnode_get_attrib(packet, "type"); | |
| 7944 | 421 | const char *real_jid = NULL; |
| 9152 | 422 | const char *affiliation = NULL; |
| 423 | const char *role = NULL; | |
| 7014 | 424 | char *status = NULL; |
| 425 | int priority = 0; | |
| 426 | JabberID *jid; | |
| 427 | JabberChat *chat; | |
| 428 | JabberBuddy *jb; | |
| 9954 | 429 | JabberBuddyResource *jbr = NULL, *found_jbr = NULL; |
| 15884 | 430 | PurpleConvChatBuddyFlags flags = PURPLE_CBFLAGS_NONE; |
|
9846
61f7349c153a
[gaim-migrate @ 10724]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9745
diff
changeset
|
431 | gboolean delayed = FALSE; |
| 15884 | 432 | PurpleBuddy *b = NULL; |
| 7014 | 433 | char *buddy_name; |
| 9954 | 434 | JabberBuddyState state = JABBER_BUDDY_STATE_UNKNOWN; |
| 7014 | 435 | xmlnode *y; |
| 436 | gboolean muc = FALSE; | |
| 10189 | 437 | 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
|
438 | xmlnode *caps = NULL; |
| 7014 | 439 | |
| 8043 | 440 | if(!(jb = jabber_buddy_find(js, from, TRUE))) |
| 441 | return; | |
| 442 | ||
| 443 | if(!(jid = jabber_id_new(from))) | |
| 7280 | 444 | return; |
| 445 | ||
| 7014 | 446 | if(jb->error_msg) { |
| 447 | g_free(jb->error_msg); | |
| 448 | jb->error_msg = NULL; | |
| 449 | } | |
| 450 | ||
| 7813 | 451 | if(type && !strcmp(type, "error")) { |
|
21150
bedd1215fb5e
Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents:
20210
diff
changeset
|
452 | char *msg = jabber_parse_error(js, packet, NULL); |
| 7644 | 453 | |
| 9954 | 454 | state = JABBER_BUDDY_STATE_ERROR; |
| 8401 | 455 | jb->error_msg = msg ? msg : g_strdup(_("Unknown Error in presence")); |
| 7813 | 456 | } else if(type && !strcmp(type, "subscribe")) { |
| 7014 | 457 | struct _jabber_add_permit *jap = g_new0(struct _jabber_add_permit, 1); |
| 15197 | 458 | gboolean onlist = FALSE; |
| 15884 | 459 | PurpleBuddy *buddy = purple_find_buddy(purple_connection_get_account(js->gc), from); |
| 15197 | 460 | JabberBuddy *jb = NULL; |
|
10949
b2949f5fc512
[gaim-migrate @ 12749]
Evan Schoenberg <evands@pidgin.im>
parents:
10941
diff
changeset
|
461 | |
| 15197 | 462 | if (buddy) { |
| 463 | 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
|
464 | if ((jb->subscription & JABBER_SUB_TO)) |
| 15197 | 465 | onlist = TRUE; |
| 466 | } | |
|
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
|
467 | |
| 7014 | 468 | jap->gc = js->gc; |
| 469 | jap->who = g_strdup(from); | |
| 12285 | 470 | jap->js = js; |
| 7014 | 471 | |
| 15884 | 472 | purple_account_request_authorization(purple_connection_get_account(js->gc), from, NULL, NULL, NULL, onlist, |
|
19335
4613b53d5741
Warning fixes in the aftermath of resiak's authorize_cb and deny_cb type fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
18991
diff
changeset
|
473 | authorize_add_cb, deny_add_cb, jap); |
| 8043 | 474 | jabber_id_free(jid); |
| 7145 | 475 | return; |
| 7813 | 476 | } else if(type && !strcmp(type, "subscribed")) { |
| 7014 | 477 | /* we've been allowed to see their presence, but we don't care */ |
| 8043 | 478 | jabber_id_free(jid); |
| 7014 | 479 | return; |
| 12285 | 480 | } else if(type && !strcmp(type, "unsubscribe")) { |
| 481 | /* XXX I'm not sure this is the right way to handle this, it | |
| 482 | * might be better to add "unsubscribe" to the presence status | |
| 483 | * if lower down, but I'm not sure. */ | |
| 484 | /* they are unsubscribing from our presence, we don't care */ | |
| 485 | /* Well, maybe just a little, we might want/need to start | |
| 486 | * acknowledging this (and the others) at some point. */ | |
| 487 | jabber_id_free(jid); | |
| 488 | return; | |
| 7014 | 489 | } else { |
| 490 | if((y = xmlnode_get_child(packet, "show"))) { | |
| 491 | char *show = xmlnode_get_data(y); | |
| 12683 | 492 | state = jabber_buddy_show_get_state(show); |
| 7014 | 493 | g_free(show); |
| 494 | } else { | |
| 9954 | 495 | state = JABBER_BUDDY_STATE_ONLINE; |
| 7014 | 496 | } |
| 497 | } | |
| 498 | ||
| 7310 | 499 | |
| 7014 | 500 | 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
|
501 | const char *xmlns; |
| 8135 | 502 | if(y->type != XMLNODE_TYPE_TAG) |
| 7014 | 503 | 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
|
504 | xmlns = xmlnode_get_namespace(y); |
| 7014 | 505 | |
| 506 | if(!strcmp(y->name, "status")) { | |
| 7615 | 507 | g_free(status); |
| 7014 | 508 | status = xmlnode_get_data(y); |
| 509 | } else if(!strcmp(y->name, "priority")) { | |
| 510 | char *p = xmlnode_get_data(y); | |
| 511 | if(p) { | |
| 512 | priority = atoi(p); | |
| 513 | g_free(p); | |
| 514 | } | |
|
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
|
515 | } 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
|
516 | /* 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
|
517 | 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
|
518 | } 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
|
519 | caps = y; /* store for later, when creating buddy resource */ |
| 7014 | 520 | } else if(!strcmp(y->name, "x")) { |
| 13808 | 521 | const char *xmlns = xmlnode_get_namespace(y); |
|
9846
61f7349c153a
[gaim-migrate @ 10724]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9745
diff
changeset
|
522 | if(xmlns && !strcmp(xmlns, "jabber:x:delay")) { |
| 9847 | 523 | /* 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
|
524 | delayed = TRUE; |
|
61f7349c153a
[gaim-migrate @ 10724]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9745
diff
changeset
|
525 | } else if(xmlns && !strcmp(xmlns, "http://jabber.org/protocol/muc#user")) { |
| 7629 | 526 | xmlnode *z; |
| 527 | ||
| 7014 | 528 | muc = TRUE; |
| 7629 | 529 | if((z = xmlnode_get_child(y, "status"))) { |
| 530 | const char *code = xmlnode_get_attrib(z, "code"); | |
| 531 | if(code && !strcmp(code, "201")) { | |
| 13445 | 532 | if((chat = jabber_chat_find(js, jid->node, jid->domain))) { |
| 15884 | 533 | chat->config_dialog_type = PURPLE_REQUEST_ACTION; |
| 13445 | 534 | chat->config_dialog_handle = |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
535 | purple_request_action(js->gc, |
| 13445 | 536 | _("Create New Room"), |
| 537 | _("Create New Room"), | |
| 538 | _("You are creating a new room. Would" | |
| 539 | " you like to configure it, or" | |
| 540 | " 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
|
541 | /* 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
|
542 | purple_connection_get_account(js->gc), NULL, chat->conv, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
543 | chat, 2, |
|
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
|
544 | _("_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
|
545 | _("_Accept Defaults"), G_CALLBACK(jabber_chat_create_instant_room)); |
| 13445 | 546 | } |
|
18971
34b3eb14ea8f
Commit a patch by bibliochat to handle an XMPP MUC status code that I pushed
Etan Reisner <deryni@pidgin.im>
parents:
18382
diff
changeset
|
547 | } else if(code && !strcmp(code, "210")) { |
|
34b3eb14ea8f
Commit a patch by bibliochat to handle an XMPP MUC status code that I pushed
Etan Reisner <deryni@pidgin.im>
parents:
18382
diff
changeset
|
548 | /* server rewrote room-nick */ |
|
34b3eb14ea8f
Commit a patch by bibliochat to handle an XMPP MUC status code that I pushed
Etan Reisner <deryni@pidgin.im>
parents:
18382
diff
changeset
|
549 | if((chat = jabber_chat_find(js, jid->node, jid->domain))) { |
|
34b3eb14ea8f
Commit a patch by bibliochat to handle an XMPP MUC status code that I pushed
Etan Reisner <deryni@pidgin.im>
parents:
18382
diff
changeset
|
550 | g_free(chat->handle); |
|
34b3eb14ea8f
Commit a patch by bibliochat to handle an XMPP MUC status code that I pushed
Etan Reisner <deryni@pidgin.im>
parents:
18382
diff
changeset
|
551 | chat->handle = g_strdup(jid->resource); |
|
34b3eb14ea8f
Commit a patch by bibliochat to handle an XMPP MUC status code that I pushed
Etan Reisner <deryni@pidgin.im>
parents:
18382
diff
changeset
|
552 | } |
| 7629 | 553 | } |
| 554 | } | |
| 7944 | 555 | if((z = xmlnode_get_child(y, "item"))) { |
| 556 | real_jid = xmlnode_get_attrib(z, "jid"); | |
| 9152 | 557 | affiliation = xmlnode_get_attrib(z, "affiliation"); |
| 558 | role = xmlnode_get_attrib(z, "role"); | |
| 9931 | 559 | if(affiliation != NULL && !strcmp(affiliation, "owner")) |
| 15884 | 560 | flags |= PURPLE_CBFLAGS_FOUNDER; |
|
9743
839b2bce3853
[gaim-migrate @ 10608]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9559
diff
changeset
|
561 | if (role != NULL) { |
|
839b2bce3853
[gaim-migrate @ 10608]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9559
diff
changeset
|
562 | if (!strcmp(role, "moderator")) |
| 15884 | 563 | flags |= PURPLE_CBFLAGS_OP; |
|
9743
839b2bce3853
[gaim-migrate @ 10608]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9559
diff
changeset
|
564 | else if (!strcmp(role, "participant")) |
| 15884 | 565 | flags |= PURPLE_CBFLAGS_VOICE; |
|
9743
839b2bce3853
[gaim-migrate @ 10608]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9559
diff
changeset
|
566 | } |
| 7944 | 567 | } |
| 10189 | 568 | } else if(xmlns && !strcmp(xmlns, "vcard-temp:x:update")) { |
| 569 | xmlnode *photo = xmlnode_get_child(y, "photo"); | |
| 570 | 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
|
571 | g_free(avatar_hash); |
| 10189 | 572 | avatar_hash = xmlnode_get_data(photo); |
| 573 | } | |
| 7014 | 574 | } |
| 575 | } | |
| 576 | } | |
| 577 | ||
| 578 | ||
| 7322 | 579 | if(jid->node && (chat = jabber_chat_find(js, jid->node, jid->domain))) { |
| 8462 | 580 | static int i = 1; |
| 7014 | 581 | char *room_jid = g_strdup_printf("%s@%s", jid->node, jid->domain); |
| 582 | ||
| 17049 | 583 | if(state == JABBER_BUDDY_STATE_ERROR) { |
|
21150
bedd1215fb5e
Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents:
20210
diff
changeset
|
584 | char *title, *msg = jabber_parse_error(js, packet, NULL); |
| 7014 | 585 | |
|
23403
a8704d47889f
Fix the chat-room rejoining bug where the list appears empty.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23270
diff
changeset
|
586 | if (!chat->conv) { |
|
a8704d47889f
Fix the chat-room rejoining bug where the list appears empty.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23270
diff
changeset
|
587 | title = g_strdup_printf(_("Error joining chat %s"), from); |
|
a8704d47889f
Fix the chat-room rejoining bug where the list appears empty.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23270
diff
changeset
|
588 | purple_serv_got_join_chat_failed(js->gc, chat->components); |
|
a8704d47889f
Fix the chat-room rejoining bug where the list appears empty.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23270
diff
changeset
|
589 | } else { |
| 8401 | 590 | title = g_strdup_printf(_("Error in chat %s"), from); |
|
18991
aa6a1feb874a
applied changes from 5542a465de12fedee4ebe7c124a754f9992d0d62
Mark Doliner <markdoliner@pidgin.im>
parents:
18989
diff
changeset
|
591 | if (g_hash_table_size(chat->members) == 0) |
|
aa6a1feb874a
applied changes from 5542a465de12fedee4ebe7c124a754f9992d0d62
Mark Doliner <markdoliner@pidgin.im>
parents:
18989
diff
changeset
|
592 | serv_got_chat_left(js->gc, chat->id); |
| 7321 | 593 | } |
| 15884 | 594 | purple_notify_error(js->gc, title, title, msg); |
| 8401 | 595 | g_free(title); |
| 596 | g_free(msg); | |
| 7014 | 597 | |
|
18991
aa6a1feb874a
applied changes from 5542a465de12fedee4ebe7c124a754f9992d0d62
Mark Doliner <markdoliner@pidgin.im>
parents:
18989
diff
changeset
|
598 | if (g_hash_table_size(chat->members) == 0) |
|
aa6a1feb874a
applied changes from 5542a465de12fedee4ebe7c124a754f9992d0d62
Mark Doliner <markdoliner@pidgin.im>
parents:
18989
diff
changeset
|
599 | /* Only destroy the chat if the error happened while joining */ |
|
aa6a1feb874a
applied changes from 5542a465de12fedee4ebe7c124a754f9992d0d62
Mark Doliner <markdoliner@pidgin.im>
parents:
18989
diff
changeset
|
600 | jabber_chat_destroy(chat); |
| 7310 | 601 | jabber_id_free(jid); |
| 7615 | 602 | g_free(status); |
| 8182 | 603 | 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
|
604 | g_free(avatar_hash); |
| 7014 | 605 | return; |
| 606 | } | |
| 607 | ||
| 608 | ||
| 7813 | 609 | if(type && !strcmp(type, "unavailable")) { |
| 7972 | 610 | gboolean nick_change = FALSE; |
| 7973 | 611 | |
| 9152 | 612 | /* If we haven't joined the chat yet, we don't care that someone |
| 613 | * left, or it was us leaving after we closed the chat */ | |
|
23403
a8704d47889f
Fix the chat-room rejoining bug where the list appears empty.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23270
diff
changeset
|
614 | if (!chat->conv || chat->left) { |
|
a8704d47889f
Fix the chat-room rejoining bug where the list appears empty.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23270
diff
changeset
|
615 | if (chat->left && |
|
a8704d47889f
Fix the chat-room rejoining bug where the list appears empty.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23270
diff
changeset
|
616 | jid->resource && chat->handle && !strcmp(jid->resource, chat->handle)) |
| 9152 | 617 | jabber_chat_destroy(chat); |
| 8182 | 618 | jabber_id_free(jid); |
| 619 | g_free(status); | |
| 620 | 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
|
621 | g_free(avatar_hash); |
| 8182 | 622 | return; |
| 623 | } | |
| 624 | ||
| 7973 | 625 | jabber_buddy_remove_resource(jb, jid->resource); |
| 7972 | 626 | if(chat->muc) { |
| 627 | xmlnode *x; | |
| 8135 | 628 | for(x = xmlnode_get_child(packet, "x"); x; x = xmlnode_get_next_twin(x)) { |
| 7972 | 629 | const char *xmlns, *nick, *code; |
| 630 | xmlnode *stat, *item; | |
| 13808 | 631 | if(!(xmlns = xmlnode_get_namespace(x)) || |
| 7972 | 632 | strcmp(xmlns, "http://jabber.org/protocol/muc#user")) |
| 633 | continue; | |
| 634 | if(!(stat = xmlnode_get_child(x, "status"))) | |
| 635 | continue; | |
| 9152 | 636 | if(!(code = xmlnode_get_attrib(stat, "code"))) |
| 7972 | 637 | continue; |
| 9152 | 638 | if(!strcmp(code, "301")) { |
| 639 | /* XXX: we got banned */ | |
| 640 | } else if(!strcmp(code, "303")) { | |
| 641 | if(!(item = xmlnode_get_child(x, "item"))) | |
| 642 | continue; | |
| 643 | if(!(nick = xmlnode_get_attrib(item, "nick"))) | |
| 644 | continue; | |
| 645 | nick_change = TRUE; | |
| 646 | if(!strcmp(jid->resource, chat->handle)) { | |
| 647 | g_free(chat->handle); | |
| 648 | chat->handle = g_strdup(nick); | |
| 649 | } | |
| 15884 | 650 | purple_conv_chat_rename_user(PURPLE_CONV_CHAT(chat->conv), jid->resource, nick); |
| 9152 | 651 | jabber_chat_remove_handle(chat, jid->resource); |
| 652 | break; | |
| 653 | } else if(!strcmp(code, "307")) { | |
| 654 | /* XXX: we got kicked */ | |
| 655 | } else if(!strcmp(code, "321")) { | |
| 656 | /* XXX: removed due to an affiliation change */ | |
| 657 | } else if(!strcmp(code, "322")) { | |
| 658 | /* XXX: removed because room is now members-only */ | |
| 659 | } else if(!strcmp(code, "332")) { | |
| 660 | /* XXX: removed due to system shutdown */ | |
| 8401 | 661 | } |
| 7972 | 662 | } |
| 663 | } | |
| 664 | if(!nick_change) { | |
| 9152 | 665 | if(!g_utf8_collate(jid->resource, chat->handle)) { |
| 7972 | 666 | serv_got_chat_left(js->gc, chat->id); |
| 667 | jabber_chat_destroy(chat); | |
| 668 | } else { | |
| 15884 | 669 | purple_conv_chat_remove_user(PURPLE_CONV_CHAT(chat->conv), jid->resource, |
| 7974 | 670 | status); |
| 9152 | 671 | jabber_chat_remove_handle(chat, jid->resource); |
| 7972 | 672 | } |
| 7014 | 673 | } |
| 674 | } else { | |
| 8182 | 675 | if(!chat->conv) { |
| 676 | chat->id = i++; | |
| 677 | chat->muc = muc; | |
| 678 | chat->conv = serv_got_joined_chat(js->gc, chat->id, room_jid); | |
| 15884 | 679 | purple_conv_chat_set_nick(PURPLE_CONV_CHAT(chat->conv), chat->handle); |
| 10486 | 680 | |
| 10941 | 681 | jabber_chat_disco_traffic(chat); |
| 8182 | 682 | } |
| 683 | ||
| 7973 | 684 | jabber_buddy_track_resource(jb, jid->resource, priority, state, |
| 685 | status); | |
| 686 | ||
| 9152 | 687 | jabber_chat_track_handle(chat, jid->resource, real_jid, affiliation, role); |
| 688 | ||
| 7014 | 689 | if(!jabber_chat_find_buddy(chat->conv, jid->resource)) |
| 15884 | 690 | 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
|
691 | real_jid, flags, !delayed); |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9320
diff
changeset
|
692 | else |
| 15884 | 693 | 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
|
694 | flags); |
| 7014 | 695 | } |
| 696 | g_free(room_jid); | |
| 697 | } else { | |
| 7322 | 698 | buddy_name = g_strdup_printf("%s%s%s", jid->node ? jid->node : "", |
|
18725
a3ab5c711de7
Now showing ad-hoc commands of other clients connected to the same account in the account menu (per XEP-0146). Since it is becoming messy in that menu, I also prefixed all ad-hoc commands with the node this command belongs to in [], which is the resource name for clients and the domain name for the server. Examples: "[home] Set status" for clients and "[jabber.org] Send message to all connected users" for servers.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
699 | jid->node ? "@" : "", jid->domain); |
| 15884 | 700 | if((b = purple_find_buddy(js->gc->account, buddy_name)) == NULL) { |
|
18725
a3ab5c711de7
Now showing ad-hoc commands of other clients connected to the same account in the account menu (per XEP-0146). Since it is becoming messy in that menu, I also prefixed all ad-hoc commands with the node this command belongs to in [], which is the resource name for clients and the domain name for the server. Examples: "[home] Set status" for clients and "[jabber.org] Send message to all connected users" for servers.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
701 | if(!jid->node || strcmp(jid->node,js->user->node) || strcmp(jid->domain,js->user->domain)) { |
|
22622
1ecb840b5101
Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <markdoliner@pidgin.im>
parents:
21801
diff
changeset
|
702 | purple_debug_warning("jabber", "Got presence for unknown buddy %s on account %s (%p)\n", |
|
18725
a3ab5c711de7
Now showing ad-hoc commands of other clients connected to the same account in the account menu (per XEP-0146). Since it is becoming messy in that menu, I also prefixed all ad-hoc commands with the node this command belongs to in [], which is the resource name for clients and the domain name for the server. Examples: "[home] Set status" for clients and "[jabber.org] Send message to all connected users" for servers.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
703 | buddy_name, purple_account_get_username(js->gc->account), js->gc->account); |
|
a3ab5c711de7
Now showing ad-hoc commands of other clients connected to the same account in the account menu (per XEP-0146). Since it is becoming messy in that menu, I also prefixed all ad-hoc commands with the node this command belongs to in [], which is the resource name for clients and the domain name for the server. Examples: "[home] Set status" for clients and "[jabber.org] Send message to all connected users" for servers.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
704 | jabber_id_free(jid); |
|
a3ab5c711de7
Now showing ad-hoc commands of other clients connected to the same account in the account menu (per XEP-0146). Since it is becoming messy in that menu, I also prefixed all ad-hoc commands with the node this command belongs to in [], which is the resource name for clients and the domain name for the server. Examples: "[home] Set status" for clients and "[jabber.org] Send message to all connected users" for servers.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
705 | g_free(avatar_hash); |
|
a3ab5c711de7
Now showing ad-hoc commands of other clients connected to the same account in the account menu (per XEP-0146). Since it is becoming messy in that menu, I also prefixed all ad-hoc commands with the node this command belongs to in [], which is the resource name for clients and the domain name for the server. Examples: "[home] Set status" for clients and "[jabber.org] Send message to all connected users" for servers.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
706 | g_free(buddy_name); |
|
a3ab5c711de7
Now showing ad-hoc commands of other clients connected to the same account in the account menu (per XEP-0146). Since it is becoming messy in that menu, I also prefixed all ad-hoc commands with the node this command belongs to in [], which is the resource name for clients and the domain name for the server. Examples: "[home] Set status" for clients and "[jabber.org] Send message to all connected users" for servers.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
707 | g_free(status); |
|
a3ab5c711de7
Now showing ad-hoc commands of other clients connected to the same account in the account menu (per XEP-0146). Since it is becoming messy in that menu, I also prefixed all ad-hoc commands with the node this command belongs to in [], which is the resource name for clients and the domain name for the server. Examples: "[home] Set status" for clients and "[jabber.org] Send message to all connected users" for servers.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
708 | return; |
|
a3ab5c711de7
Now showing ad-hoc commands of other clients connected to the same account in the account menu (per XEP-0146). Since it is becoming messy in that menu, I also prefixed all ad-hoc commands with the node this command belongs to in [], which is the resource name for clients and the domain name for the server. Examples: "[home] Set status" for clients and "[jabber.org] Send message to all connected users" for servers.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
709 | } else { |
|
a3ab5c711de7
Now showing ad-hoc commands of other clients connected to the same account in the account menu (per XEP-0146). Since it is becoming messy in that menu, I also prefixed all ad-hoc commands with the node this command belongs to in [], which is the resource name for clients and the domain name for the server. Examples: "[home] Set status" for clients and "[jabber.org] Send message to all connected users" for servers.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
710 | /* this is a different resource of our own account. Resume even when this account isn't on our blist */ |
|
a3ab5c711de7
Now showing ad-hoc commands of other clients connected to the same account in the account menu (per XEP-0146). Since it is becoming messy in that menu, I also prefixed all ad-hoc commands with the node this command belongs to in [], which is the resource name for clients and the domain name for the server. Examples: "[home] Set status" for clients and "[jabber.org] Send message to all connected users" for servers.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
711 | } |
| 7014 | 712 | } |
| 713 | ||
|
18725
a3ab5c711de7
Now showing ad-hoc commands of other clients connected to the same account in the account menu (per XEP-0146). Since it is becoming messy in that menu, I also prefixed all ad-hoc commands with the node this command belongs to in [], which is the resource name for clients and the domain name for the server. Examples: "[home] Set status" for clients and "[jabber.org] Send message to all connected users" for servers.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
714 | if(b && avatar_hash) { |
|
16534
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16018
diff
changeset
|
715 | const char *avatar_hash2 = purple_buddy_icons_get_checksum_for_user(b); |
| 10189 | 716 | if(!avatar_hash2 || strcmp(avatar_hash, avatar_hash2)) { |
| 717 | JabberIq *iq; | |
| 718 | xmlnode *vcard; | |
| 719 | ||
| 10941 | 720 | /* XXX this is a crappy way of trying to prevent |
| 721 | * someone from spamming us with presence packets | |
| 722 | * and causing us to DoS ourselves...what we really | |
| 723 | * need is a queue system that can throttle itself, | |
| 724 | * but i'm too tired to write that right now */ | |
| 725 | if(!g_slist_find(js->pending_avatar_requests, jb)) { | |
| 726 | ||
| 727 | js->pending_avatar_requests = g_slist_prepend(js->pending_avatar_requests, jb); | |
| 10189 | 728 | |
| 10941 | 729 | iq = jabber_iq_new(js, JABBER_IQ_GET); |
| 730 | xmlnode_set_attrib(iq->node, "to", buddy_name); | |
| 731 | vcard = xmlnode_new_child(iq->node, "vCard"); | |
| 13808 | 732 | xmlnode_set_namespace(vcard, "vcard-temp"); |
| 10941 | 733 | |
| 734 | jabber_iq_set_callback(iq, jabber_vcard_parse_avatar, NULL); | |
| 735 | jabber_iq_send(iq); | |
| 736 | } | |
| 10189 | 737 | } |
| 738 | } | |
| 739 | ||
| 9954 | 740 | if(state == JABBER_BUDDY_STATE_ERROR || |
| 7813 | 741 | (type && (!strcmp(type, "unavailable") || |
| 742 | !strcmp(type, "unsubscribed")))) { | |
| 15884 | 743 | PurpleConversation *conv; |
| 8043 | 744 | |
| 7014 | 745 | jabber_buddy_remove_resource(jb, jid->resource); |
| 8043 | 746 | if((conv = jabber_find_unnormalized_conv(from, js->gc->account))) |
| 15884 | 747 | purple_conversation_set_name(conv, buddy_name); |
| 8043 | 748 | |
| 7395 | 749 | } else { |
| 9954 | 750 | jbr = jabber_buddy_track_resource(jb, jid->resource, priority, |
| 751 | 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
|
752 | 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
|
753 | 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
|
754 | 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
|
755 | 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
|
756 | |
|
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
|
757 | 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
|
758 | 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
|
759 | userdata->js = js; |
|
22929
f1860f6e1344
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents:
22622
diff
changeset
|
760 | userdata->jb = jb; |
|
17816
1b7362b4a7a2
Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
17812
diff
changeset
|
761 | 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
|
762 | 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
|
763 | } |
|
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
|
764 | } |
| 7395 | 765 | } |
| 7014 | 766 | |
| 9954 | 767 | if((found_jbr = jabber_buddy_find_resource(jb, NULL))) { |
|
21195
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
21193
diff
changeset
|
768 | jabber_google_presence_incoming(js, buddy_name, found_jbr); |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
21193
diff
changeset
|
769 | purple_prpl_got_user_status(js->gc->account, buddy_name, jabber_buddy_state_get_status_id(found_jbr->state), "priority", found_jbr->priority, "message", found_jbr->status, NULL); |
| 9954 | 770 | } else { |
| 15884 | 771 | purple_prpl_got_user_status(js->gc->account, buddy_name, "offline", status ? "message" : NULL, status, NULL); |
| 9954 | 772 | } |
| 7014 | 773 | g_free(buddy_name); |
| 774 | } | |
| 775 | g_free(status); | |
| 776 | 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
|
777 | g_free(avatar_hash); |
| 7014 | 778 | } |
| 779 | ||
| 780 | void jabber_presence_subscription_set(JabberStream *js, const char *who, const char *type) | |
| 781 | { | |
| 782 | xmlnode *presence = xmlnode_new("presence"); | |
| 783 | ||
| 784 | xmlnode_set_attrib(presence, "to", who); | |
| 785 | xmlnode_set_attrib(presence, "type", type); | |
| 786 | ||
| 787 | jabber_send(js, presence); | |
| 788 | xmlnode_free(presence); | |
| 789 | } | |
| 9954 | 790 | |
| 15884 | 791 | void purple_status_to_jabber(const PurpleStatus *status, JabberBuddyState *state, char **msg, int *priority) |
| 9954 | 792 | { |
| 10216 | 793 | const char *status_id = NULL; |
| 14525 | 794 | const char *formatted_msg = NULL; |
| 10216 | 795 | |
| 13443 | 796 | if(state) *state = JABBER_BUDDY_STATE_UNKNOWN; |
| 797 | if(msg) *msg = NULL; | |
| 798 | if(priority) *priority = 0; | |
| 9954 | 799 | |
| 800 | if(!status) { | |
| 13443 | 801 | if(state) *state = JABBER_BUDDY_STATE_UNAVAILABLE; |
| 10216 | 802 | } else { |
| 803 | if(state) { | |
| 15884 | 804 | status_id = purple_status_get_id(status); |
| 10216 | 805 | *state = jabber_buddy_status_id_get_state(status_id); |
| 806 | } | |
| 807 | ||
|
13497
07fc0a9826b8
[gaim-migrate @ 15872]
Richard Laager <rlaager@pidgin.im>
parents:
13445
diff
changeset
|
808 | if(msg) { |
| 15884 | 809 | formatted_msg = purple_status_get_attr_string(status, "message"); |
| 10216 | 810 | |
|
13497
07fc0a9826b8
[gaim-migrate @ 15872]
Richard Laager <rlaager@pidgin.im>
parents:
13445
diff
changeset
|
811 | /* if the message is blank, then there really isn't a message */ |
| 14525 | 812 | if(formatted_msg && !*formatted_msg) |
| 813 | formatted_msg = NULL; | |
| 814 | ||
| 815 | if(formatted_msg) | |
| 17683 | 816 | *msg = purple_markup_strip_html(formatted_msg); |
|
13497
07fc0a9826b8
[gaim-migrate @ 15872]
Richard Laager <rlaager@pidgin.im>
parents:
13445
diff
changeset
|
817 | } |
| 11872 | 818 | |
| 10216 | 819 | if(priority) |
| 15884 | 820 | *priority = purple_status_get_attr_int(status, "priority"); |
| 9954 | 821 | } |
| 822 | } |