Sun, 07 Jun 2009 05:36:45 +0000
Use js->state to track whether the roster has been retrieved.
| 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" |
|
c087855dc551
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
24 | #include "conversation.h" |
| 7014 | 25 | #include "debug.h" |
| 26 | #include "notify.h" | |
| 27 | #include "request.h" | |
| 28 | #include "server.h" | |
| 9954 | 29 | #include "status.h" |
|
7095
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
30 | #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
|
31 | #include "xmlnode.h" |
| 7014 | 32 | |
| 33 | #include "buddy.h" | |
| 34 | #include "chat.h" | |
|
21195
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
21193
diff
changeset
|
35 | #include "google.h" |
| 7014 | 36 | #include "presence.h" |
| 37 | #include "iq.h" | |
| 38 | #include "jutil.h" | |
|
17816
1b7362b4a7a2
Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
17812
diff
changeset
|
39 | #include "adhoccommands.h" |
| 7014 | 40 | |
|
17800
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
41 | #include "usertune.h" |
| 7014 | 42 | |
| 43 | ||
| 44 | static void chats_send_presence_foreach(gpointer key, gpointer val, | |
| 45 | gpointer user_data) | |
| 46 | { | |
| 47 | JabberChat *chat = val; | |
| 48 | xmlnode *presence = user_data; | |
| 8577 | 49 | char *chat_full_jid; |
| 50 | ||
|
23403
a8704d47889f
Fix the chat-room rejoining bug where the list appears empty.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23270
diff
changeset
|
51 | if(!chat->conv || chat->left) |
| 8577 | 52 | return; |
| 53 | ||
| 54 | chat_full_jid = g_strdup_printf("%s@%s/%s", chat->room, chat->server, | |
| 8401 | 55 | chat->handle); |
| 7014 | 56 | |
| 8401 | 57 | xmlnode_set_attrib(presence, "to", chat_full_jid); |
| 7014 | 58 | jabber_send(chat->js, presence); |
| 8401 | 59 | g_free(chat_full_jid); |
| 7014 | 60 | } |
| 61 | ||
| 15884 | 62 | void jabber_presence_fake_to_self(JabberStream *js, const PurpleStatus *gstatus) { |
| 10286 | 63 | char *my_base_jid; |
| 64 | ||
| 65 | if(!js->user) | |
| 66 | return; | |
| 67 | ||
| 68 | my_base_jid = g_strdup_printf("%s@%s", js->user->node, js->user->domain); | |
| 15884 | 69 | if(purple_find_buddy(js->gc->account, my_base_jid)) { |
| 8185 | 70 | JabberBuddy *jb; |
| 71 | JabberBuddyResource *jbr; | |
| 72 | if((jb = jabber_buddy_find(js, my_base_jid, TRUE))) { | |
| 9954 | 73 | JabberBuddyState state; |
| 14525 | 74 | char *msg; |
| 9954 | 75 | int priority; |
| 76 | ||
| 15884 | 77 | purple_status_to_jabber(gstatus, &state, &msg, &priority); |
| 9954 | 78 | |
| 10490 | 79 | if (state == JABBER_BUDDY_STATE_UNAVAILABLE || state == JABBER_BUDDY_STATE_UNKNOWN) { |
|
9744
c2b450de1fc0
[gaim-migrate @ 10609]
Daniel Atallah <datallah@pidgin.im>
parents:
9743
diff
changeset
|
80 | jabber_buddy_remove_resource(jb, js->user->resource); |
|
c2b450de1fc0
[gaim-migrate @ 10609]
Daniel Atallah <datallah@pidgin.im>
parents:
9743
diff
changeset
|
81 | } else { |
| 9954 | 82 | jabber_buddy_track_resource(jb, js->user->resource, priority, state, msg); |
|
9744
c2b450de1fc0
[gaim-migrate @ 10609]
Daniel Atallah <datallah@pidgin.im>
parents:
9743
diff
changeset
|
83 | } |
| 9954 | 84 | if((jbr = jabber_buddy_find_resource(jb, NULL))) { |
| 15884 | 85 | purple_prpl_got_user_status(js->gc->account, my_base_jid, jabber_buddy_state_get_status_id(jbr->state), "priority", jbr->priority, jbr->status ? "message" : NULL, jbr->status, NULL); |
| 9954 | 86 | } else { |
| 15884 | 87 | purple_prpl_got_user_status(js->gc->account, my_base_jid, "offline", msg ? "message" : NULL, msg, NULL); |
| 9954 | 88 | } |
| 14525 | 89 | |
| 90 | g_free(msg); | |
| 8185 | 91 | } |
| 92 | } | |
| 93 | g_free(my_base_jid); | |
| 94 | } | |
| 95 | ||
|
24717
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
96 | void jabber_set_status(PurpleAccount *account, PurpleStatus *status) |
| 7014 | 97 | { |
|
24717
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
98 | PurpleConnection *gc; |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
99 | JabberStream *js; |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
100 | |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
101 | if (!purple_account_is_connected(account)) |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
102 | return; |
|
27155
53502d71efdd
Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents:
27145
diff
changeset
|
103 | |
|
24717
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
104 | if (!purple_status_is_active(status)) |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
105 | return; |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
106 | |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
107 | if (purple_status_is_exclusive(status) && !purple_status_is_active(status)) { |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
108 | /* An exclusive status can't be deactivated. You should just |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
109 | * activate some other exclusive status. */ |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
110 | return; |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
111 | } |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
112 | |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
113 | gc = purple_account_get_connection(account); |
|
26072
e8fce2b2b9fe
propagate from branch 'im.pidgin.pidgin' (head b4bbfacd7f2050d87deeda12ea7bb3adc3608cb7)
Paul Aurich <darkrain42@pidgin.im>
diff
changeset
|
114 | js = purple_connection_get_protocol_data(gc); |
|
24717
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
115 | jabber_presence_send(js, FALSE); |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
116 | } |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
117 | |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
118 | void jabber_presence_send(JabberStream *js, gboolean force) |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
119 | { |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
120 | PurpleAccount *account; |
| 10189 | 121 | xmlnode *presence, *x, *photo; |
| 7014 | 122 | char *stripped = NULL; |
| 9954 | 123 | JabberBuddyState state; |
| 124 | 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
|
125 | 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
|
126 | 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
|
127 | gboolean allowBuzz; |
|
21758
e70c407c994b
We need to work with the exclusive status.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21687
diff
changeset
|
128 | PurplePresence *p; |
|
24717
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
129 | PurpleStatus *status, *tune; |
|
18195
9cd0565f856e
kill some code duplication when sending current presence
Nathan Walp <nwalp@pidgin.im>
parents:
17703
diff
changeset
|
130 | |
|
24717
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
131 | account = purple_connection_get_account(js->gc); |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
132 | p = purple_account_get_presence(account); |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
133 | status = purple_presence_get_active_status(p); |
|
10755
a336a5d3102d
[gaim-migrate @ 12358]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
134 | |
|
18226
adf83935e838
really and truly enforce the no-presence-before-roster thing
Nathan Walp <nwalp@pidgin.im>
parents:
18195
diff
changeset
|
135 | /* we don't want to send presence before we've gotten our roster */ |
|
27278
b34a1cea4872
Use js->state to track whether the roster has been retrieved.
Paul Aurich <darkrain42@pidgin.im>
parents:
27202
diff
changeset
|
136 | if (js->state != JABBER_STREAM_CONNECTED) { |
|
18226
adf83935e838
really and truly enforce the no-presence-before-roster thing
Nathan Walp <nwalp@pidgin.im>
parents:
18195
diff
changeset
|
137 | 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
|
138 | return; |
|
adf83935e838
really and truly enforce the no-presence-before-roster thing
Nathan Walp <nwalp@pidgin.im>
parents:
18195
diff
changeset
|
139 | } |
|
adf83935e838
really and truly enforce the no-presence-before-roster thing
Nathan Walp <nwalp@pidgin.im>
parents:
18195
diff
changeset
|
140 | |
| 15884 | 141 | purple_status_to_jabber(status, &state, &stripped, &priority); |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25154
diff
changeset
|
142 | |
|
17824
52683dfc1f7d
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <am@adiumx.com>
parents:
17816
diff
changeset
|
143 | /* 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
|
144 | 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
|
145 | /* changing the buzz state has to trigger a re-broadcasting of the presence for caps */ |
|
23574
5c7073191c5a
make googletalk tune hack work, previously it's not doing anything unless
Ka-Hing Cheung <khc@pidgin.im>
parents:
23403
diff
changeset
|
146 | |
|
24717
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
147 | tune = purple_presence_get_status(p, "tune"); |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
148 | if (js->googletalk && !stripped && purple_status_is_active(tune)) { |
|
23574
5c7073191c5a
make googletalk tune hack work, previously it's not doing anything unless
Ka-Hing Cheung <khc@pidgin.im>
parents:
23403
diff
changeset
|
149 | stripped = jabber_google_presence_outgoing(tune); |
|
5c7073191c5a
make googletalk tune hack work, previously it's not doing anything unless
Ka-Hing Cheung <khc@pidgin.im>
parents:
23403
diff
changeset
|
150 | } |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25154
diff
changeset
|
151 | |
|
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
|
152 | #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
|
153 | (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
|
154 | /* check if there are any differences to the <presence> and send them in that case */ |
|
24717
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
155 | if (force || allowBuzz != js->allowBuzz || js->old_state != state || |
|
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
156 | CHANGED(js->old_msg, stripped) || js->old_priority != priority || |
|
26958
a955bd42f529
propagate from branch 'im.pidgin.pidgin' (head 36f75a1d52a6af5574bf847d60054a1392dcbc67)
Paul Aurich <darkrain42@pidgin.im>
diff
changeset
|
157 | CHANGED(js->old_avatarhash, js->avatar_hash) || js->old_idle != js->idle) { |
|
24717
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
158 | /* Need to update allowBuzz before creating the presence (with caps) */ |
|
17824
52683dfc1f7d
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <am@adiumx.com>
parents:
17816
diff
changeset
|
159 | js->allowBuzz = allowBuzz; |
|
21195
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
21193
diff
changeset
|
160 | |
|
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
|
161 | presence = jabber_presence_create_js(js, state, stripped, priority); |
| 7014 | 162 | |
|
25810
5cf3c22e52df
Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents:
25154
diff
changeset
|
163 | /* Per XEP-0153 4.1, we must always send the <x> */ |
|
5cf3c22e52df
Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents:
25154
diff
changeset
|
164 | x = xmlnode_new_child(presence, "x"); |
|
5cf3c22e52df
Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents:
25154
diff
changeset
|
165 | xmlnode_set_namespace(x, "vcard-temp:x:update"); |
|
5cf3c22e52df
Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents:
25154
diff
changeset
|
166 | /* |
|
5cf3c22e52df
Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents:
25154
diff
changeset
|
167 | * FIXME: Per XEP-0153 4.3.2 bullet 2, we must not publish our |
|
5cf3c22e52df
Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents:
25154
diff
changeset
|
168 | * image hash if another resource has logged in and updated the |
|
5cf3c22e52df
Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents:
25154
diff
changeset
|
169 | * vcard avatar. Requires changes in jabber_presence_parse. |
|
5cf3c22e52df
Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents:
25154
diff
changeset
|
170 | */ |
|
5cf3c22e52df
Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents:
25154
diff
changeset
|
171 | if (js->vcard_fetched) { |
|
5cf3c22e52df
Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents:
25154
diff
changeset
|
172 | /* Always publish a <photo>; it's empty if we have no image. */ |
|
17800
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
173 | photo = xmlnode_new_child(x, "photo"); |
|
25810
5cf3c22e52df
Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents:
25154
diff
changeset
|
174 | if (js->avatar_hash) |
|
5cf3c22e52df
Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents:
25154
diff
changeset
|
175 | xmlnode_insert_data(photo, js->avatar_hash, -1); |
|
17800
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
176 | } |
|
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 | |
|
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 | jabber_send(js, presence); |
| 7014 | 179 | |
|
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
|
180 | 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
|
181 | xmlnode_free(presence); |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25154
diff
changeset
|
182 | |
|
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
|
183 | /* update old values */ |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25154
diff
changeset
|
184 | |
|
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
|
185 | 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
|
186 | 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
|
187 | 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
|
188 | 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
|
189 | 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
|
190 | 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
|
191 | 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
|
192 | js->old_priority = priority; |
| 25229 | 193 | js->old_idle = js->idle; |
| 10189 | 194 | } |
|
23575
7a22a015d694
let's not leak if nothing is changed
Ka-Hing Cheung <khc@pidgin.im>
parents:
23574
diff
changeset
|
195 | g_free(stripped); |
|
7a22a015d694
let's not leak if nothing is changed
Ka-Hing Cheung <khc@pidgin.im>
parents:
23574
diff
changeset
|
196 | |
|
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
|
197 | /* next, check if there are any changes to the tune values */ |
|
24717
13c7497f44f8
Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents:
24716
diff
changeset
|
198 | if (purple_status_is_active(tune)) { |
|
21193
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20169
diff
changeset
|
199 | 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
|
200 | 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
|
201 | 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
|
202 | 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
|
203 | 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
|
204 | 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
|
205 | 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
|
206 | } |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25154
diff
changeset
|
207 | |
|
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
|
208 | 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
|
209 | 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
|
210 | 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
|
211 | (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
|
212 | (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
|
213 | (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
|
214 | (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
|
215 | 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
|
216 | (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
|
217 | }; |
|
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 | jabber_tune_set(js->gc, &tuneinfo); |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25154
diff
changeset
|
219 | |
|
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
|
220 | /* update old values */ |
|
20169
497e1cd1e059
Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents:
19899
diff
changeset
|
221 | g_free(js->old_artist); |
|
497e1cd1e059
Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents:
19899
diff
changeset
|
222 | g_free(js->old_title); |
|
497e1cd1e059
Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents:
19899
diff
changeset
|
223 | g_free(js->old_source); |
|
497e1cd1e059
Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents:
19899
diff
changeset
|
224 | g_free(js->old_uri); |
|
497e1cd1e059
Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents:
19899
diff
changeset
|
225 | 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
|
226 | 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
|
227 | 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
|
228 | 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
|
229 | 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
|
230 | 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
|
231 | js->old_track = g_strdup(track); |
| 10189 | 232 | } |
| 233 | ||
|
19899
483c4f495a6c
Various warning fixes for the xmpp prpl.
Daniel Atallah <datallah@pidgin.im>
parents:
19897
diff
changeset
|
234 | #undef CHANGED |
| 8185 | 235 | |
| 9954 | 236 | jabber_presence_fake_to_self(js, status); |
| 7014 | 237 | } |
| 238 | ||
| 9954 | 239 | xmlnode *jabber_presence_create(JabberBuddyState state, const char *msg, int priority) |
| 7014 | 240 | { |
|
17770
e67998927a3c
Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents:
17422
diff
changeset
|
241 | 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
|
242 | } |
|
e67998927a3c
Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents:
17422
diff
changeset
|
243 | |
|
e67998927a3c
Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents:
17422
diff
changeset
|
244 | 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
|
245 | { |
| 13385 | 246 | xmlnode *show, *status, *presence, *pri, *c; |
| 9954 | 247 | const char *show_string = NULL; |
|
27202
5244a5510e0e
Add Gmail video support.
Michael Ruprecht <maiku@pidgin.im>
parents:
27155
diff
changeset
|
248 | gboolean audio_enabled, video_enabled; |
| 7014 | 249 | |
| 250 | presence = xmlnode_new("presence"); | |
| 251 | ||
| 9954 | 252 | if(state == JABBER_BUDDY_STATE_UNAVAILABLE) |
| 253 | xmlnode_set_attrib(presence, "type", "unavailable"); | |
| 254 | else if(state != JABBER_BUDDY_STATE_ONLINE && | |
| 255 | state != JABBER_BUDDY_STATE_UNKNOWN && | |
| 256 | state != JABBER_BUDDY_STATE_ERROR) | |
| 12683 | 257 | show_string = jabber_buddy_state_get_show(state); |
| 9954 | 258 | |
| 259 | if(show_string) { | |
| 260 | show = xmlnode_new_child(presence, "show"); | |
| 261 | xmlnode_insert_data(show, show_string, -1); | |
| 7014 | 262 | } |
| 263 | ||
| 9954 | 264 | if(msg) { |
| 7014 | 265 | status = xmlnode_new_child(presence, "status"); |
| 266 | xmlnode_insert_data(status, msg, -1); | |
| 267 | } | |
| 268 | ||
| 11568 | 269 | if(priority) { |
| 270 | char *pstr = g_strdup_printf("%d", priority); | |
| 271 | pri = xmlnode_new_child(presence, "priority"); | |
| 272 | xmlnode_insert_data(pri, pstr, -1); | |
| 273 | g_free(pstr); | |
| 274 | } | |
| 275 | ||
| 25229 | 276 | /* if we are idle and not offline, include idle */ |
| 277 | if (js->idle && state != JABBER_BUDDY_STATE_UNAVAILABLE) { | |
| 278 | xmlnode *query = xmlnode_new_child(presence, "query"); | |
| 279 | gchar seconds[10]; | |
| 280 | g_snprintf(seconds, 10, "%d", (int) (time(NULL) - js->idle)); | |
|
27155
53502d71efdd
Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents:
27145
diff
changeset
|
281 | |
| 25229 | 282 | xmlnode_set_namespace(query, "jabber:iq:last"); |
| 283 | xmlnode_set_attrib(query, "seconds", seconds); | |
| 284 | } | |
|
26958
a955bd42f529
propagate from branch 'im.pidgin.pidgin' (head 36f75a1d52a6af5574bf847d60054a1392dcbc67)
Paul Aurich <darkrain42@pidgin.im>
diff
changeset
|
285 | |
| 13385 | 286 | /* JEP-0115 */ |
|
23595
728a8a576f11
* correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23591
diff
changeset
|
287 | /* calculate hash */ |
|
728a8a576f11
* correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23591
diff
changeset
|
288 | jabber_caps_calculate_own_hash(js); |
|
728a8a576f11
* correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23591
diff
changeset
|
289 | /* create xml */ |
| 13385 | 290 | c = xmlnode_new_child(presence, "c"); |
| 13808 | 291 | xmlnode_set_namespace(c, "http://jabber.org/protocol/caps"); |
| 13385 | 292 | 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
|
293 | xmlnode_set_attrib(c, "hash", "sha-1"); |
|
24716
047f5075ca58
Entity Capabilities must be per-JabberStream
Paul Aurich <darkrain42@pidgin.im>
parents:
23954
diff
changeset
|
294 | xmlnode_set_attrib(c, "ver", jabber_caps_get_own_hash(js)); |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25154
diff
changeset
|
295 | |
|
26668
ef06285f3b64
Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <darkrain42@pidgin.im>
parents:
26658
diff
changeset
|
296 | #ifdef USE_VV |
|
ef06285f3b64
Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <darkrain42@pidgin.im>
parents:
26658
diff
changeset
|
297 | /* |
|
ef06285f3b64
Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <darkrain42@pidgin.im>
parents:
26658
diff
changeset
|
298 | * MASSIVE HUGE DISGUSTING HACK |
|
ef06285f3b64
Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <darkrain42@pidgin.im>
parents:
26658
diff
changeset
|
299 | * This is a huge hack. As far as I can tell, Google Talk's gmail client |
|
ef06285f3b64
Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <darkrain42@pidgin.im>
parents:
26658
diff
changeset
|
300 | * doesn't bother to check the actual features we advertise; they |
|
26674
133392eaf4b8
Make my comment parse correctly.
Paul Aurich <darkrain42@pidgin.im>
parents:
26668
diff
changeset
|
301 | * just assume that if we specify a 'voice-v1' ext (ignoring that |
|
133392eaf4b8
Make my comment parse correctly.
Paul Aurich <darkrain42@pidgin.im>
parents:
26668
diff
changeset
|
302 | * these are to be assigned no semantic value), we support receiving voice |
|
133392eaf4b8
Make my comment parse correctly.
Paul Aurich <darkrain42@pidgin.im>
parents:
26668
diff
changeset
|
303 | * calls. |
|
27202
5244a5510e0e
Add Gmail video support.
Michael Ruprecht <maiku@pidgin.im>
parents:
27155
diff
changeset
|
304 | * |
|
5244a5510e0e
Add Gmail video support.
Michael Ruprecht <maiku@pidgin.im>
parents:
27155
diff
changeset
|
305 | * Ditto for 'video-v1'. |
|
26668
ef06285f3b64
Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <darkrain42@pidgin.im>
parents:
26658
diff
changeset
|
306 | */ |
|
27202
5244a5510e0e
Add Gmail video support.
Michael Ruprecht <maiku@pidgin.im>
parents:
27155
diff
changeset
|
307 | audio_enabled = jabber_audio_enabled(js, NULL /* unused */); |
|
5244a5510e0e
Add Gmail video support.
Michael Ruprecht <maiku@pidgin.im>
parents:
27155
diff
changeset
|
308 | video_enabled = jabber_video_enabled(js, NULL /* unused */); |
|
5244a5510e0e
Add Gmail video support.
Michael Ruprecht <maiku@pidgin.im>
parents:
27155
diff
changeset
|
309 | |
|
5244a5510e0e
Add Gmail video support.
Michael Ruprecht <maiku@pidgin.im>
parents:
27155
diff
changeset
|
310 | if (audio_enabled && video_enabled) |
|
5244a5510e0e
Add Gmail video support.
Michael Ruprecht <maiku@pidgin.im>
parents:
27155
diff
changeset
|
311 | xmlnode_set_attrib(c, "ext", "voice-v1 video-v1"); |
|
5244a5510e0e
Add Gmail video support.
Michael Ruprecht <maiku@pidgin.im>
parents:
27155
diff
changeset
|
312 | else if (audio_enabled) |
|
26668
ef06285f3b64
Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <darkrain42@pidgin.im>
parents:
26658
diff
changeset
|
313 | xmlnode_set_attrib(c, "ext", "voice-v1"); |
|
27202
5244a5510e0e
Add Gmail video support.
Michael Ruprecht <maiku@pidgin.im>
parents:
27155
diff
changeset
|
314 | else if (video_enabled) |
|
5244a5510e0e
Add Gmail video support.
Michael Ruprecht <maiku@pidgin.im>
parents:
27155
diff
changeset
|
315 | xmlnode_set_attrib(c, "ext", "video-v1"); |
|
26668
ef06285f3b64
Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <darkrain42@pidgin.im>
parents:
26658
diff
changeset
|
316 | #endif |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25154
diff
changeset
|
317 | |
| 7014 | 318 | return presence; |
| 319 | } | |
| 320 | ||
| 321 | struct _jabber_add_permit { | |
| 15884 | 322 | PurpleConnection *gc; |
| 12285 | 323 | JabberStream *js; |
| 7014 | 324 | char *who; |
| 325 | }; | |
| 326 | ||
|
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
|
327 | static void authorize_add_cb(gpointer data) |
| 7014 | 328 | { |
|
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
|
329 | 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
|
330 | 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
|
331 | 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
|
332 | jap->who, "subscribed"); |
| 7014 | 333 | g_free(jap->who); |
| 334 | g_free(jap); | |
| 335 | } | |
| 336 | ||
|
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
|
337 | static void deny_add_cb(gpointer data) |
| 7014 | 338 | { |
|
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
|
339 | 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
|
340 | 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
|
341 | 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
|
342 | jap->who, "unsubscribed"); |
| 7014 | 343 | g_free(jap->who); |
| 344 | g_free(jap); | |
| 345 | } | |
| 346 | ||
|
26687
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
347 | static void |
|
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
348 | jabber_vcard_parse_avatar(JabberStream *js, const char *from, |
|
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
349 | JabberIqType type, const char *id, |
|
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
350 | xmlnode *packet, gpointer blah) |
| 10189 | 351 | { |
| 10941 | 352 | JabberBuddy *jb = NULL; |
|
27006
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
353 | xmlnode *vcard, *photo, *binval, *fn, *nick; |
|
11127
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
11013
diff
changeset
|
354 | char *text; |
| 10189 | 355 | |
| 356 | if(!from) | |
| 357 | return; | |
| 358 | ||
| 10941 | 359 | jb = jabber_buddy_find(js, from, TRUE); |
| 360 | ||
| 361 | js->pending_avatar_requests = g_slist_remove(js->pending_avatar_requests, jb); | |
| 362 | ||
| 10189 | 363 | if((vcard = xmlnode_get_child(packet, "vCard")) || |
| 364 | (vcard = xmlnode_get_child_with_namespace(packet, "query", "vcard-temp"))) { | |
|
27006
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
365 | /* The logic here regarding the nickname and full name is copied from |
|
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
366 | * buddy.c:jabber_vcard_parse. */ |
|
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
367 | gchar *nickname = NULL; |
|
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
368 | if ((fn = xmlnode_get_child(vcard, "FN"))) |
|
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
369 | nickname = xmlnode_get_data(fn); |
|
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
370 | |
|
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
371 | if ((nick = xmlnode_get_child(vcard, "NICKNAME"))) { |
|
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
372 | char *tmp = xmlnode_get_data(nick); |
|
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
373 | char *bare_jid = jabber_get_bare_jid(from); |
|
27145
f34175723f73
Fix a crash when <NICKNAME/> is present in a vcard, but has no data.
Paul Aurich <darkrain42@pidgin.im>
parents:
27103
diff
changeset
|
374 | if (tmp && strstr(bare_jid, tmp) == NULL) { |
|
27006
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
375 | g_free(nickname); |
|
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
376 | nickname = tmp; |
|
27145
f34175723f73
Fix a crash when <NICKNAME/> is present in a vcard, but has no data.
Paul Aurich <darkrain42@pidgin.im>
parents:
27103
diff
changeset
|
377 | } else if (tmp) |
|
27006
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
378 | g_free(tmp); |
|
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
379 | |
|
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
380 | g_free(bare_jid); |
|
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
381 | } |
|
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
382 | |
|
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
383 | if (nickname) { |
|
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
384 | serv_got_alias(js->gc, from, nickname); |
|
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
385 | g_free(nickname); |
|
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
386 | } |
|
34ced9e04b08
When we download a buddy's vCard to update an avatar, also try to update the nickname.
Paul Aurich <darkrain42@pidgin.im>
parents:
26998
diff
changeset
|
387 | |
| 10941 | 388 | if((photo = xmlnode_get_child(vcard, "PHOTO")) && |
| 11361 | 389 | (( (binval = xmlnode_get_child(photo, "BINVAL")) && |
| 390 | (text = xmlnode_get_data(binval))) || | |
| 391 | (text = xmlnode_get_data(photo)))) { | |
|
26948
19be50c7fbff
Use jabber_calculate_data_sha1sum in one more place.
Paul Aurich <darkrain42@pidgin.im>
parents:
26946
diff
changeset
|
392 | guchar *data; |
|
19be50c7fbff
Use jabber_calculate_data_sha1sum in one more place.
Paul Aurich <darkrain42@pidgin.im>
parents:
26946
diff
changeset
|
393 | gchar *hash; |
|
19be50c7fbff
Use jabber_calculate_data_sha1sum in one more place.
Paul Aurich <darkrain42@pidgin.im>
parents:
26946
diff
changeset
|
394 | gsize size; |
|
16534
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16018
diff
changeset
|
395 | |
| 15884 | 396 | data = purple_base64_decode(text, &size); |
|
26948
19be50c7fbff
Use jabber_calculate_data_sha1sum in one more place.
Paul Aurich <darkrain42@pidgin.im>
parents:
26946
diff
changeset
|
397 | hash = jabber_calculate_data_sha1sum(data, size); |
| 10189 | 398 | |
|
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
|
399 | purple_buddy_icons_set_for_user(js->gc->account, from, data, size, hash); |
|
26948
19be50c7fbff
Use jabber_calculate_data_sha1sum in one more place.
Paul Aurich <darkrain42@pidgin.im>
parents:
26946
diff
changeset
|
400 | g_free(hash); |
| 10941 | 401 | g_free(text); |
| 10189 | 402 | } |
| 403 | } | |
| 404 | } | |
| 405 | ||
|
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
|
406 | 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
|
407 | 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
|
408 | 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
|
409 | 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
|
410 | } 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
|
411 | |
|
24880
ae4e8598d0bf
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents:
24878
diff
changeset
|
412 | static void |
|
ae4e8598d0bf
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents:
24878
diff
changeset
|
413 | jabber_presence_set_capabilities(JabberCapsClientInfo *info, GList *exts, |
|
ae4e8598d0bf
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents:
24878
diff
changeset
|
414 | JabberPresenceCapabilities *userdata) |
|
24719
80121be525d4
Rewrite jabber_presence_set_capabilities a little
Paul Aurich <darkrain42@pidgin.im>
parents:
24717
diff
changeset
|
415 | { |
|
22929
f1860f6e1344
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents:
22622
diff
changeset
|
416 | JabberBuddyResource *jbr; |
|
27066
6c1375ed1e59
Don't crash when resource is NULL. Thanks, Marcus!
Paul Aurich <darkrain42@pidgin.im>
parents:
27007
diff
changeset
|
417 | char *resource = g_utf8_strchr(userdata->from, -1, '/'); |
|
6c1375ed1e59
Don't crash when resource is NULL. Thanks, Marcus!
Paul Aurich <darkrain42@pidgin.im>
parents:
27007
diff
changeset
|
418 | |
|
6c1375ed1e59
Don't crash when resource is NULL. Thanks, Marcus!
Paul Aurich <darkrain42@pidgin.im>
parents:
27007
diff
changeset
|
419 | if (resource) |
|
6c1375ed1e59
Don't crash when resource is NULL. Thanks, Marcus!
Paul Aurich <darkrain42@pidgin.im>
parents:
27007
diff
changeset
|
420 | resource += 1; |
|
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
|
421 | |
|
24719
80121be525d4
Rewrite jabber_presence_set_capabilities a little
Paul Aurich <darkrain42@pidgin.im>
parents:
24717
diff
changeset
|
422 | jbr = jabber_buddy_find_resource(userdata->jb, resource); |
|
80121be525d4
Rewrite jabber_presence_set_capabilities a little
Paul Aurich <darkrain42@pidgin.im>
parents:
24717
diff
changeset
|
423 | if (!jbr) { |
|
22929
f1860f6e1344
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents:
22622
diff
changeset
|
424 | 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
|
425 | g_free(userdata); |
|
24880
ae4e8598d0bf
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents:
24878
diff
changeset
|
426 | if (exts) { |
|
ae4e8598d0bf
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents:
24878
diff
changeset
|
427 | g_list_foreach(exts, (GFunc)g_free, NULL); |
|
ae4e8598d0bf
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents:
24878
diff
changeset
|
428 | g_list_free(exts); |
|
ae4e8598d0bf
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents:
24878
diff
changeset
|
429 | } |
|
22929
f1860f6e1344
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents:
22622
diff
changeset
|
430 | return; |
|
f1860f6e1344
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents:
22622
diff
changeset
|
431 | } |
|
f1860f6e1344
Fix a crash in Jabber that I think happens someone someone signs off
Mark Doliner <markdoliner@pidgin.im>
parents:
22622
diff
changeset
|
432 | |
|
24882
7e842d8123e8
Partial disapproval of 19969457944c4807924bcde3090063b23d35ba17
Paul Aurich <darkrain42@pidgin.im>
parents:
24880
diff
changeset
|
433 | /* Any old jbr->caps.info is owned by the caps code */ |
|
24880
ae4e8598d0bf
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents:
24878
diff
changeset
|
434 | if (jbr->caps.exts) { |
|
ae4e8598d0bf
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents:
24878
diff
changeset
|
435 | g_list_foreach(jbr->caps.exts, (GFunc)g_free, NULL); |
|
ae4e8598d0bf
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents:
24878
diff
changeset
|
436 | g_list_free(jbr->caps.exts); |
|
ae4e8598d0bf
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents:
24878
diff
changeset
|
437 | } |
|
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
|
438 | |
|
24880
ae4e8598d0bf
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents:
24878
diff
changeset
|
439 | jbr->caps.info = info; |
|
ae4e8598d0bf
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents:
24878
diff
changeset
|
440 | jbr->caps.exts = exts; |
|
21801
6d92632a6424
Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <datallah@pidgin.im>
parents:
21758
diff
changeset
|
441 | |
|
27073
09bf5e6921e4
Only try to fetch adhoc commands from buddies once. Pushed updates (which we support now) are far superior.
Paul Aurich <darkrain42@pidgin.im>
parents:
27068
diff
changeset
|
442 | if (!jbr->commands_fetched && jabber_resource_has_capability(jbr, "http://jabber.org/protocol/commands")) { |
|
24802
eb481e98ac6a
Sprinkle jabber_resource_has_capability in places
Paul Aurich <darkrain42@pidgin.im>
parents:
24741
diff
changeset
|
443 | JabberIq *iq = jabber_iq_new_query(userdata->js, JABBER_IQ_GET, "http://jabber.org/protocol/disco#items"); |
|
eb481e98ac6a
Sprinkle jabber_resource_has_capability in places
Paul Aurich <darkrain42@pidgin.im>
parents:
24741
diff
changeset
|
444 | xmlnode *query = xmlnode_get_child_with_namespace(iq->node, "query", "http://jabber.org/protocol/disco#items"); |
|
eb481e98ac6a
Sprinkle jabber_resource_has_capability in places
Paul Aurich <darkrain42@pidgin.im>
parents:
24741
diff
changeset
|
445 | xmlnode_set_attrib(iq->node, "to", userdata->from); |
|
eb481e98ac6a
Sprinkle jabber_resource_has_capability in places
Paul Aurich <darkrain42@pidgin.im>
parents:
24741
diff
changeset
|
446 | xmlnode_set_attrib(query, "node", "http://jabber.org/protocol/commands"); |
|
eb481e98ac6a
Sprinkle jabber_resource_has_capability in places
Paul Aurich <darkrain42@pidgin.im>
parents:
24741
diff
changeset
|
447 | jabber_iq_set_callback(iq, jabber_adhoc_disco_result_cb, NULL); |
|
eb481e98ac6a
Sprinkle jabber_resource_has_capability in places
Paul Aurich <darkrain42@pidgin.im>
parents:
24741
diff
changeset
|
448 | jabber_iq_send(iq); |
|
27073
09bf5e6921e4
Only try to fetch adhoc commands from buddies once. Pushed updates (which we support now) are far superior.
Paul Aurich <darkrain42@pidgin.im>
parents:
27068
diff
changeset
|
449 | |
|
09bf5e6921e4
Only try to fetch adhoc commands from buddies once. Pushed updates (which we support now) are far superior.
Paul Aurich <darkrain42@pidgin.im>
parents:
27068
diff
changeset
|
450 | jbr->commands_fetched = TRUE; |
|
17816
1b7362b4a7a2
Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
17812
diff
changeset
|
451 | } |
|
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
|
452 | |
|
20210
d3336754b1a9
applied changes from d50ecf4dc52f25cbd219d6c19846436dec5a8853
Luke Schierer <lschiere@pidgin.im>
parents:
20169
diff
changeset
|
453 | g_free(userdata->from); |
|
d3336754b1a9
applied changes from d50ecf4dc52f25cbd219d6c19846436dec5a8853
Luke Schierer <lschiere@pidgin.im>
parents:
20169
diff
changeset
|
454 | 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
|
455 | } |
|
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
|
456 | |
| 7014 | 457 | void jabber_presence_parse(JabberStream *js, xmlnode *packet) |
| 458 | { | |
|
27103
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
27073
diff
changeset
|
459 | const char *from; |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
27073
diff
changeset
|
460 | const char *type; |
| 7944 | 461 | const char *real_jid = NULL; |
| 9152 | 462 | const char *affiliation = NULL; |
| 463 | const char *role = NULL; | |
| 7014 | 464 | char *status = NULL; |
| 465 | int priority = 0; | |
| 466 | JabberID *jid; | |
| 467 | JabberChat *chat; | |
| 468 | JabberBuddy *jb; | |
| 9954 | 469 | JabberBuddyResource *jbr = NULL, *found_jbr = NULL; |
| 15884 | 470 | PurpleConvChatBuddyFlags flags = PURPLE_CBFLAGS_NONE; |
|
9846
61f7349c153a
[gaim-migrate @ 10724]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9745
diff
changeset
|
471 | gboolean delayed = FALSE; |
| 25229 | 472 | const gchar *stamp = NULL; /* from <delayed/> element */ |
| 15884 | 473 | PurpleBuddy *b = NULL; |
| 7014 | 474 | char *buddy_name; |
| 9954 | 475 | JabberBuddyState state = JABBER_BUDDY_STATE_UNKNOWN; |
| 7014 | 476 | xmlnode *y; |
| 477 | gboolean muc = FALSE; | |
| 10189 | 478 | 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
|
479 | xmlnode *caps = NULL; |
| 25229 | 480 | int idle = 0; |
|
26998
5d912b08679d
A little bit better (free memory and support receiving the nick in subscriptions) and Changelog.
Paul Aurich <darkrain42@pidgin.im>
parents:
26997
diff
changeset
|
481 | gchar *nickname = NULL; |
|
27103
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
27073
diff
changeset
|
482 | gboolean signal_return; |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
27073
diff
changeset
|
483 | |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
27073
diff
changeset
|
484 | from = xmlnode_get_attrib(packet, "from"); |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
27073
diff
changeset
|
485 | type = xmlnode_get_attrib(packet, "type"); |
| 7014 | 486 | |
| 8043 | 487 | if(!(jb = jabber_buddy_find(js, from, TRUE))) |
| 488 | return; | |
| 489 | ||
|
27103
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
27073
diff
changeset
|
490 | signal_return = GPOINTER_TO_INT(purple_signal_emit_return_1(jabber_plugin, |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
27073
diff
changeset
|
491 | "jabber-receiving-presence", js->gc, type, from, packet)); |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
27073
diff
changeset
|
492 | if (signal_return) |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
27073
diff
changeset
|
493 | return; |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
27073
diff
changeset
|
494 | |
| 8043 | 495 | if(!(jid = jabber_id_new(from))) |
| 7280 | 496 | return; |
| 497 | ||
| 7014 | 498 | if(jb->error_msg) { |
| 499 | g_free(jb->error_msg); | |
| 500 | jb->error_msg = NULL; | |
| 501 | } | |
| 502 | ||
| 7813 | 503 | 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
|
504 | char *msg = jabber_parse_error(js, packet, NULL); |
| 7644 | 505 | |
| 9954 | 506 | state = JABBER_BUDDY_STATE_ERROR; |
| 8401 | 507 | jb->error_msg = msg ? msg : g_strdup(_("Unknown Error in presence")); |
| 7813 | 508 | } else if(type && !strcmp(type, "subscribe")) { |
| 7014 | 509 | struct _jabber_add_permit *jap = g_new0(struct _jabber_add_permit, 1); |
| 15197 | 510 | gboolean onlist = FALSE; |
| 15884 | 511 | PurpleBuddy *buddy = purple_find_buddy(purple_connection_get_account(js->gc), from); |
| 15197 | 512 | JabberBuddy *jb = NULL; |
|
26998
5d912b08679d
A little bit better (free memory and support receiving the nick in subscriptions) and Changelog.
Paul Aurich <darkrain42@pidgin.im>
parents:
26997
diff
changeset
|
513 | xmlnode *nick; |
|
5d912b08679d
A little bit better (free memory and support receiving the nick in subscriptions) and Changelog.
Paul Aurich <darkrain42@pidgin.im>
parents:
26997
diff
changeset
|
514 | |
|
5d912b08679d
A little bit better (free memory and support receiving the nick in subscriptions) and Changelog.
Paul Aurich <darkrain42@pidgin.im>
parents:
26997
diff
changeset
|
515 | nick = xmlnode_get_child_with_namespace(packet, "nick", "http://jabber.org/protocol/nick"); |
|
5d912b08679d
A little bit better (free memory and support receiving the nick in subscriptions) and Changelog.
Paul Aurich <darkrain42@pidgin.im>
parents:
26997
diff
changeset
|
516 | if (nick) |
|
5d912b08679d
A little bit better (free memory and support receiving the nick in subscriptions) and Changelog.
Paul Aurich <darkrain42@pidgin.im>
parents:
26997
diff
changeset
|
517 | nickname = xmlnode_get_data(nick); |
|
10949
b2949f5fc512
[gaim-migrate @ 12749]
Evan Schoenberg <evands@pidgin.im>
parents:
10941
diff
changeset
|
518 | |
| 15197 | 519 | if (buddy) { |
| 520 | jb = jabber_buddy_find(js, from, TRUE); | |
|
24740
3842816fc042
A fix from Paul Aurich for a long-standing XMPP issue with duplicate buddies. Fixes #479.
Daniel Atallah <datallah@pidgin.im>
parents:
23575
diff
changeset
|
521 | if ((jb->subscription & (JABBER_SUB_TO | JABBER_SUB_PENDING))) |
| 15197 | 522 | onlist = TRUE; |
| 523 | } | |
|
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
|
524 | |
| 7014 | 525 | jap->gc = js->gc; |
| 526 | jap->who = g_strdup(from); | |
| 12285 | 527 | jap->js = js; |
| 7014 | 528 | |
|
26998
5d912b08679d
A little bit better (free memory and support receiving the nick in subscriptions) and Changelog.
Paul Aurich <darkrain42@pidgin.im>
parents:
26997
diff
changeset
|
529 | purple_account_request_authorization(purple_connection_get_account(js->gc), from, NULL, nickname, 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
|
530 | authorize_add_cb, deny_add_cb, jap); |
|
26998
5d912b08679d
A little bit better (free memory and support receiving the nick in subscriptions) and Changelog.
Paul Aurich <darkrain42@pidgin.im>
parents:
26997
diff
changeset
|
531 | g_free(nickname); |
| 8043 | 532 | jabber_id_free(jid); |
| 7145 | 533 | return; |
| 7813 | 534 | } else if(type && !strcmp(type, "subscribed")) { |
| 7014 | 535 | /* we've been allowed to see their presence, but we don't care */ |
| 8043 | 536 | jabber_id_free(jid); |
| 7014 | 537 | return; |
| 12285 | 538 | } else if(type && !strcmp(type, "unsubscribe")) { |
| 539 | /* XXX I'm not sure this is the right way to handle this, it | |
| 540 | * might be better to add "unsubscribe" to the presence status | |
| 541 | * if lower down, but I'm not sure. */ | |
| 542 | /* they are unsubscribing from our presence, we don't care */ | |
| 543 | /* Well, maybe just a little, we might want/need to start | |
| 544 | * acknowledging this (and the others) at some point. */ | |
| 545 | jabber_id_free(jid); | |
| 546 | return; | |
| 7014 | 547 | } else { |
| 548 | if((y = xmlnode_get_child(packet, "show"))) { | |
| 549 | char *show = xmlnode_get_data(y); | |
| 12683 | 550 | state = jabber_buddy_show_get_state(show); |
| 7014 | 551 | g_free(show); |
| 552 | } else { | |
| 9954 | 553 | state = JABBER_BUDDY_STATE_ONLINE; |
| 7014 | 554 | } |
| 555 | } | |
| 556 | ||
| 7310 | 557 | |
| 7014 | 558 | 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
|
559 | const char *xmlns; |
| 8135 | 560 | if(y->type != XMLNODE_TYPE_TAG) |
| 7014 | 561 | 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
|
562 | xmlns = xmlnode_get_namespace(y); |
| 7014 | 563 | |
| 564 | if(!strcmp(y->name, "status")) { | |
| 7615 | 565 | g_free(status); |
| 7014 | 566 | status = xmlnode_get_data(y); |
| 567 | } else if(!strcmp(y->name, "priority")) { | |
| 568 | char *p = xmlnode_get_data(y); | |
| 569 | if(p) { | |
| 570 | priority = atoi(p); | |
| 571 | g_free(p); | |
| 572 | } | |
|
25154
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25110
diff
changeset
|
573 | } else if(xmlns == NULL) { |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25110
diff
changeset
|
574 | /* The rest of the cases used to check xmlns individually. */ |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25110
diff
changeset
|
575 | 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
|
576 | } 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
|
577 | /* 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
|
578 | delayed = TRUE; |
| 25229 | 579 | stamp = xmlnode_get_attrib(y, "stamp"); |
|
25154
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25110
diff
changeset
|
580 | } else if(!strcmp(y->name, "c") && !strcmp(xmlns, "http://jabber.org/protocol/caps")) { |
|
17816
1b7362b4a7a2
Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
17812
diff
changeset
|
581 | caps = y; /* store for later, when creating buddy resource */ |
|
26997
e30b31076fcb
Handle User Nick notifications via <presence/> stanzas (receive-only). Refs #864.
Paul Aurich <darkrain42@pidgin.im>
parents:
26976
diff
changeset
|
582 | } else if (g_str_equal(y->name, "nick") && g_str_equal(xmlns, "http://jabber.org/protocol/nick")) { |
|
26998
5d912b08679d
A little bit better (free memory and support receiving the nick in subscriptions) and Changelog.
Paul Aurich <darkrain42@pidgin.im>
parents:
26997
diff
changeset
|
583 | nickname = xmlnode_get_data(y); |
| 7014 | 584 | } else if(!strcmp(y->name, "x")) { |
|
25154
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25110
diff
changeset
|
585 | if(!strcmp(xmlns, "jabber:x:delay")) { |
| 9847 | 586 | /* 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
|
587 | delayed = TRUE; |
| 25229 | 588 | stamp = xmlnode_get_attrib(y, "stamp"); |
|
25154
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25110
diff
changeset
|
589 | } else if(!strcmp(xmlns, "http://jabber.org/protocol/muc#user")) { |
| 7629 | 590 | xmlnode *z; |
| 591 | ||
| 7014 | 592 | muc = TRUE; |
| 7629 | 593 | if((z = xmlnode_get_child(y, "status"))) { |
| 594 | const char *code = xmlnode_get_attrib(z, "code"); | |
| 595 | if(code && !strcmp(code, "201")) { | |
| 13445 | 596 | if((chat = jabber_chat_find(js, jid->node, jid->domain))) { |
| 15884 | 597 | chat->config_dialog_type = PURPLE_REQUEST_ACTION; |
| 13445 | 598 | chat->config_dialog_handle = |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
599 | purple_request_action(js->gc, |
| 13445 | 600 | _("Create New Room"), |
| 601 | _("Create New Room"), | |
| 602 | _("You are creating a new room. Would" | |
| 603 | " you like to configure it, or" | |
| 604 | " 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
|
605 | /* 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
|
606 | purple_connection_get_account(js->gc), NULL, chat->conv, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
607 | 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
|
608 | _("_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
|
609 | _("_Accept Defaults"), G_CALLBACK(jabber_chat_create_instant_room)); |
| 13445 | 610 | } |
|
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
|
611 | } 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
|
612 | /* 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
|
613 | 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
|
614 | 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
|
615 | 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
|
616 | } |
| 7629 | 617 | } |
| 618 | } | |
| 7944 | 619 | if((z = xmlnode_get_child(y, "item"))) { |
| 620 | real_jid = xmlnode_get_attrib(z, "jid"); | |
| 9152 | 621 | affiliation = xmlnode_get_attrib(z, "affiliation"); |
| 622 | role = xmlnode_get_attrib(z, "role"); | |
| 9931 | 623 | if(affiliation != NULL && !strcmp(affiliation, "owner")) |
| 15884 | 624 | flags |= PURPLE_CBFLAGS_FOUNDER; |
|
9743
839b2bce3853
[gaim-migrate @ 10608]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9559
diff
changeset
|
625 | if (role != NULL) { |
|
839b2bce3853
[gaim-migrate @ 10608]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9559
diff
changeset
|
626 | if (!strcmp(role, "moderator")) |
| 15884 | 627 | flags |= PURPLE_CBFLAGS_OP; |
|
9743
839b2bce3853
[gaim-migrate @ 10608]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9559
diff
changeset
|
628 | else if (!strcmp(role, "participant")) |
| 15884 | 629 | flags |= PURPLE_CBFLAGS_VOICE; |
|
9743
839b2bce3853
[gaim-migrate @ 10608]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9559
diff
changeset
|
630 | } |
| 7944 | 631 | } |
|
25154
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25110
diff
changeset
|
632 | } else if(!strcmp(xmlns, "vcard-temp:x:update")) { |
| 10189 | 633 | xmlnode *photo = xmlnode_get_child(y, "photo"); |
| 634 | 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
|
635 | g_free(avatar_hash); |
| 10189 | 636 | avatar_hash = xmlnode_get_data(photo); |
| 637 | } | |
| 7014 | 638 | } |
|
27155
53502d71efdd
Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents:
27145
diff
changeset
|
639 | } else if (!strcmp(y->name, "query") && |
| 25229 | 640 | !strcmp(xmlnode_get_namespace(y), "jabber:iq:last")) { |
| 641 | /* resource has specified idle */ | |
| 642 | const gchar *seconds = xmlnode_get_attrib(y, "seconds"); | |
| 643 | if (seconds) { | |
| 644 | /* we may need to take "delayed" into account here */ | |
| 645 | idle = atoi(seconds); | |
| 646 | } | |
| 7014 | 647 | } |
| 648 | } | |
| 649 | ||
| 25229 | 650 | if (idle && delayed && stamp) { |
| 651 | /* if we have a delayed presence, we need to add the delay to the idle | |
| 652 | value */ | |
| 653 | time_t offset = time(NULL) - purple_str_to_time(stamp, TRUE, NULL, NULL, | |
| 654 | NULL); | |
| 655 | purple_debug_info("jabber", "got delay %s yielding %ld s offset\n", | |
| 656 | stamp, offset); | |
|
27155
53502d71efdd
Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents:
27145
diff
changeset
|
657 | idle += offset; |
| 25229 | 658 | } |
| 7014 | 659 | |
| 7322 | 660 | if(jid->node && (chat = jabber_chat_find(js, jid->node, jid->domain))) { |
| 8462 | 661 | static int i = 1; |
| 7014 | 662 | |
| 17049 | 663 | 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
|
664 | char *title, *msg = jabber_parse_error(js, packet, NULL); |
| 7014 | 665 | |
|
23403
a8704d47889f
Fix the chat-room rejoining bug where the list appears empty.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23270
diff
changeset
|
666 | 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
|
667 | 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
|
668 | 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
|
669 | } else { |
| 8401 | 670 | title = g_strdup_printf(_("Error in chat %s"), from); |
|
18991
aa6a1feb874a
applied changes from 5542a465de12fedee4ebe7c124a754f9992d0d62
Mark Doliner <markdoliner@pidgin.im>
parents:
18989
diff
changeset
|
671 | if (g_hash_table_size(chat->members) == 0) |
|
aa6a1feb874a
applied changes from 5542a465de12fedee4ebe7c124a754f9992d0d62
Mark Doliner <markdoliner@pidgin.im>
parents:
18989
diff
changeset
|
672 | serv_got_chat_left(js->gc, chat->id); |
| 7321 | 673 | } |
| 15884 | 674 | purple_notify_error(js->gc, title, title, msg); |
| 8401 | 675 | g_free(title); |
| 676 | g_free(msg); | |
| 7014 | 677 | |
|
18991
aa6a1feb874a
applied changes from 5542a465de12fedee4ebe7c124a754f9992d0d62
Mark Doliner <markdoliner@pidgin.im>
parents:
18989
diff
changeset
|
678 | if (g_hash_table_size(chat->members) == 0) |
|
aa6a1feb874a
applied changes from 5542a465de12fedee4ebe7c124a754f9992d0d62
Mark Doliner <markdoliner@pidgin.im>
parents:
18989
diff
changeset
|
679 | /* Only destroy the chat if the error happened while joining */ |
|
aa6a1feb874a
applied changes from 5542a465de12fedee4ebe7c124a754f9992d0d62
Mark Doliner <markdoliner@pidgin.im>
parents:
18989
diff
changeset
|
680 | jabber_chat_destroy(chat); |
| 7310 | 681 | jabber_id_free(jid); |
| 7615 | 682 | g_free(status); |
|
17702
15af85f94634
Don't check for null before calling free. I can't help but get rid
Mark Doliner <markdoliner@pidgin.im>
parents:
17683
diff
changeset
|
683 | g_free(avatar_hash); |
|
26998
5d912b08679d
A little bit better (free memory and support receiving the nick in subscriptions) and Changelog.
Paul Aurich <darkrain42@pidgin.im>
parents:
26997
diff
changeset
|
684 | g_free(nickname); |
| 7014 | 685 | return; |
| 686 | } | |
| 687 | ||
| 688 | ||
| 7813 | 689 | if(type && !strcmp(type, "unavailable")) { |
| 7972 | 690 | gboolean nick_change = FALSE; |
| 7973 | 691 | |
|
27007
bdcf196bf54d
Don't crash when a broken server sends us an occupant's presence with an
Paul Aurich <darkrain42@pidgin.im>
parents:
27006
diff
changeset
|
692 | /* If the chat nick is invalid, we haven't yet joined, or we've |
|
bdcf196bf54d
Don't crash when a broken server sends us an occupant's presence with an
Paul Aurich <darkrain42@pidgin.im>
parents:
27006
diff
changeset
|
693 | * already left (it was probably us leaving after we closed the |
|
bdcf196bf54d
Don't crash when a broken server sends us an occupant's presence with an
Paul Aurich <darkrain42@pidgin.im>
parents:
27006
diff
changeset
|
694 | * chat), we don't care. |
|
bdcf196bf54d
Don't crash when a broken server sends us an occupant's presence with an
Paul Aurich <darkrain42@pidgin.im>
parents:
27006
diff
changeset
|
695 | */ |
|
bdcf196bf54d
Don't crash when a broken server sends us an occupant's presence with an
Paul Aurich <darkrain42@pidgin.im>
parents:
27006
diff
changeset
|
696 | if (!jid->resource || !chat->conv || chat->left) { |
|
23403
a8704d47889f
Fix the chat-room rejoining bug where the list appears empty.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23270
diff
changeset
|
697 | 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
|
698 | jid->resource && chat->handle && !strcmp(jid->resource, chat->handle)) |
| 9152 | 699 | jabber_chat_destroy(chat); |
| 8182 | 700 | jabber_id_free(jid); |
| 701 | g_free(status); | |
|
17702
15af85f94634
Don't check for null before calling free. I can't help but get rid
Mark Doliner <markdoliner@pidgin.im>
parents:
17683
diff
changeset
|
702 | g_free(avatar_hash); |
|
26998
5d912b08679d
A little bit better (free memory and support receiving the nick in subscriptions) and Changelog.
Paul Aurich <darkrain42@pidgin.im>
parents:
26997
diff
changeset
|
703 | g_free(nickname); |
| 8182 | 704 | return; |
| 705 | } | |
| 706 | ||
| 7973 | 707 | jabber_buddy_remove_resource(jb, jid->resource); |
| 7972 | 708 | if(chat->muc) { |
| 709 | xmlnode *x; | |
| 8135 | 710 | for(x = xmlnode_get_child(packet, "x"); x; x = xmlnode_get_next_twin(x)) { |
| 7972 | 711 | const char *xmlns, *nick, *code; |
| 712 | xmlnode *stat, *item; | |
| 13808 | 713 | if(!(xmlns = xmlnode_get_namespace(x)) || |
| 7972 | 714 | strcmp(xmlns, "http://jabber.org/protocol/muc#user")) |
| 715 | continue; | |
| 716 | if(!(stat = xmlnode_get_child(x, "status"))) | |
| 717 | continue; | |
| 9152 | 718 | if(!(code = xmlnode_get_attrib(stat, "code"))) |
| 7972 | 719 | continue; |
| 9152 | 720 | if(!strcmp(code, "301")) { |
| 721 | /* XXX: we got banned */ | |
| 722 | } else if(!strcmp(code, "303")) { | |
| 723 | if(!(item = xmlnode_get_child(x, "item"))) | |
| 724 | continue; | |
| 725 | if(!(nick = xmlnode_get_attrib(item, "nick"))) | |
| 726 | continue; | |
| 727 | nick_change = TRUE; | |
| 728 | if(!strcmp(jid->resource, chat->handle)) { | |
| 729 | g_free(chat->handle); | |
| 730 | chat->handle = g_strdup(nick); | |
| 731 | } | |
| 15884 | 732 | purple_conv_chat_rename_user(PURPLE_CONV_CHAT(chat->conv), jid->resource, nick); |
| 9152 | 733 | jabber_chat_remove_handle(chat, jid->resource); |
| 734 | break; | |
| 735 | } else if(!strcmp(code, "307")) { | |
| 736 | /* XXX: we got kicked */ | |
| 737 | } else if(!strcmp(code, "321")) { | |
| 738 | /* XXX: removed due to an affiliation change */ | |
| 739 | } else if(!strcmp(code, "322")) { | |
| 740 | /* XXX: removed because room is now members-only */ | |
| 741 | } else if(!strcmp(code, "332")) { | |
| 742 | /* XXX: removed due to system shutdown */ | |
| 8401 | 743 | } |
| 7972 | 744 | } |
| 745 | } | |
| 746 | if(!nick_change) { | |
| 9152 | 747 | if(!g_utf8_collate(jid->resource, chat->handle)) { |
| 7972 | 748 | serv_got_chat_left(js->gc, chat->id); |
| 749 | jabber_chat_destroy(chat); | |
| 750 | } else { | |
| 15884 | 751 | purple_conv_chat_remove_user(PURPLE_CONV_CHAT(chat->conv), jid->resource, |
| 7974 | 752 | status); |
| 9152 | 753 | jabber_chat_remove_handle(chat, jid->resource); |
| 7972 | 754 | } |
| 7014 | 755 | } |
| 756 | } else { | |
|
27007
bdcf196bf54d
Don't crash when a broken server sends us an occupant's presence with an
Paul Aurich <darkrain42@pidgin.im>
parents:
27006
diff
changeset
|
757 | /* |
|
bdcf196bf54d
Don't crash when a broken server sends us an occupant's presence with an
Paul Aurich <darkrain42@pidgin.im>
parents:
27006
diff
changeset
|
758 | * XEP-0045 mandates the presence to include a resource (which is |
|
bdcf196bf54d
Don't crash when a broken server sends us an occupant's presence with an
Paul Aurich <darkrain42@pidgin.im>
parents:
27006
diff
changeset
|
759 | * treated as the chat nick). Some non-compliant servers allow |
|
bdcf196bf54d
Don't crash when a broken server sends us an occupant's presence with an
Paul Aurich <darkrain42@pidgin.im>
parents:
27006
diff
changeset
|
760 | * joining without a nick. |
|
bdcf196bf54d
Don't crash when a broken server sends us an occupant's presence with an
Paul Aurich <darkrain42@pidgin.im>
parents:
27006
diff
changeset
|
761 | */ |
|
bdcf196bf54d
Don't crash when a broken server sends us an occupant's presence with an
Paul Aurich <darkrain42@pidgin.im>
parents:
27006
diff
changeset
|
762 | if (!jid->resource) { |
|
bdcf196bf54d
Don't crash when a broken server sends us an occupant's presence with an
Paul Aurich <darkrain42@pidgin.im>
parents:
27006
diff
changeset
|
763 | jabber_id_free(jid); |
|
bdcf196bf54d
Don't crash when a broken server sends us an occupant's presence with an
Paul Aurich <darkrain42@pidgin.im>
parents:
27006
diff
changeset
|
764 | g_free(avatar_hash); |
|
bdcf196bf54d
Don't crash when a broken server sends us an occupant's presence with an
Paul Aurich <darkrain42@pidgin.im>
parents:
27006
diff
changeset
|
765 | g_free(nickname); |
|
bdcf196bf54d
Don't crash when a broken server sends us an occupant's presence with an
Paul Aurich <darkrain42@pidgin.im>
parents:
27006
diff
changeset
|
766 | g_free(status); |
|
bdcf196bf54d
Don't crash when a broken server sends us an occupant's presence with an
Paul Aurich <darkrain42@pidgin.im>
parents:
27006
diff
changeset
|
767 | return; |
|
bdcf196bf54d
Don't crash when a broken server sends us an occupant's presence with an
Paul Aurich <darkrain42@pidgin.im>
parents:
27006
diff
changeset
|
768 | } |
|
bdcf196bf54d
Don't crash when a broken server sends us an occupant's presence with an
Paul Aurich <darkrain42@pidgin.im>
parents:
27006
diff
changeset
|
769 | |
| 8182 | 770 | if(!chat->conv) { |
| 26975 | 771 | char *room_jid = g_strdup_printf("%s@%s", jid->node, jid->domain); |
| 8182 | 772 | chat->id = i++; |
| 773 | chat->muc = muc; | |
| 774 | chat->conv = serv_got_joined_chat(js->gc, chat->id, room_jid); | |
| 15884 | 775 | purple_conv_chat_set_nick(PURPLE_CONV_CHAT(chat->conv), chat->handle); |
| 10486 | 776 | |
| 10941 | 777 | jabber_chat_disco_traffic(chat); |
| 26975 | 778 | g_free(room_jid); |
| 8182 | 779 | } |
| 780 | ||
| 7973 | 781 | jabber_buddy_track_resource(jb, jid->resource, priority, state, |
| 782 | status); | |
| 783 | ||
| 9152 | 784 | jabber_chat_track_handle(chat, jid->resource, real_jid, affiliation, role); |
| 785 | ||
| 7014 | 786 | if(!jabber_chat_find_buddy(chat->conv, jid->resource)) |
| 15884 | 787 | 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
|
788 | real_jid, flags, !delayed); |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9320
diff
changeset
|
789 | else |
| 15884 | 790 | 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
|
791 | flags); |
| 7014 | 792 | } |
| 793 | } else { | |
| 7322 | 794 | 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
|
795 | jid->node ? "@" : "", jid->domain); |
| 15884 | 796 | 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
|
797 | 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
|
798 | 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
|
799 | 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
|
800 | 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
|
801 | 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
|
802 | g_free(buddy_name); |
|
26998
5d912b08679d
A little bit better (free memory and support receiving the nick in subscriptions) and Changelog.
Paul Aurich <darkrain42@pidgin.im>
parents:
26997
diff
changeset
|
803 | g_free(nickname); |
|
18725
a3ab5c711de7
Now showing ad-hoc commands of other clients connected to the same account in the account menu (per XEP-0146). Since it is becoming messy in that menu, I also prefixed all ad-hoc commands with the node this command belongs to in [], which is the resource name for clients and the domain name for the server. Examples: "[home] Set status" for clients and "[jabber.org] Send message to all connected users" for servers.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
804 | 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
|
805 | 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
|
806 | } 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
|
807 | /* 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
|
808 | } |
| 7014 | 809 | } |
| 810 | ||
|
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
|
811 | 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
|
812 | const char *avatar_hash2 = purple_buddy_icons_get_checksum_for_user(b); |
| 10189 | 813 | if(!avatar_hash2 || strcmp(avatar_hash, avatar_hash2)) { |
| 814 | JabberIq *iq; | |
| 815 | xmlnode *vcard; | |
| 816 | ||
| 10941 | 817 | /* XXX this is a crappy way of trying to prevent |
| 818 | * someone from spamming us with presence packets | |
| 819 | * and causing us to DoS ourselves...what we really | |
| 820 | * need is a queue system that can throttle itself, | |
| 821 | * but i'm too tired to write that right now */ | |
| 822 | if(!g_slist_find(js->pending_avatar_requests, jb)) { | |
| 823 | ||
| 824 | js->pending_avatar_requests = g_slist_prepend(js->pending_avatar_requests, jb); | |
| 10189 | 825 | |
| 10941 | 826 | iq = jabber_iq_new(js, JABBER_IQ_GET); |
| 827 | xmlnode_set_attrib(iq->node, "to", buddy_name); | |
| 828 | vcard = xmlnode_new_child(iq->node, "vCard"); | |
| 13808 | 829 | xmlnode_set_namespace(vcard, "vcard-temp"); |
| 10941 | 830 | |
| 831 | jabber_iq_set_callback(iq, jabber_vcard_parse_avatar, NULL); | |
| 832 | jabber_iq_send(iq); | |
| 833 | } | |
| 10189 | 834 | } |
| 835 | } | |
| 836 | ||
| 9954 | 837 | if(state == JABBER_BUDDY_STATE_ERROR || |
| 7813 | 838 | (type && (!strcmp(type, "unavailable") || |
| 839 | !strcmp(type, "unsubscribed")))) { | |
| 15884 | 840 | PurpleConversation *conv; |
| 8043 | 841 | |
| 7014 | 842 | jabber_buddy_remove_resource(jb, jid->resource); |
| 8043 | 843 | if((conv = jabber_find_unnormalized_conv(from, js->gc->account))) |
| 15884 | 844 | purple_conversation_set_name(conv, buddy_name); |
| 8043 | 845 | |
| 7395 | 846 | } else { |
| 9954 | 847 | jbr = jabber_buddy_track_resource(jb, jid->resource, priority, |
| 848 | state, status); | |
| 25229 | 849 | if (idle) { |
| 850 | jbr->idle = time(NULL) - idle; | |
| 851 | } else { | |
| 852 | jbr->idle = 0; | |
| 853 | } | |
| 7395 | 854 | } |
| 7014 | 855 | |
| 9954 | 856 | 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
|
857 | jabber_google_presence_incoming(js, buddy_name, found_jbr); |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
21193
diff
changeset
|
858 | purple_prpl_got_user_status(js->gc->account, buddy_name, jabber_buddy_state_get_status_id(found_jbr->state), "priority", found_jbr->priority, "message", found_jbr->status, NULL); |
| 25229 | 859 | purple_prpl_got_user_idle(js->gc->account, buddy_name, found_jbr->idle, found_jbr->idle); |
|
26998
5d912b08679d
A little bit better (free memory and support receiving the nick in subscriptions) and Changelog.
Paul Aurich <darkrain42@pidgin.im>
parents:
26997
diff
changeset
|
860 | if (nickname) |
|
5d912b08679d
A little bit better (free memory and support receiving the nick in subscriptions) and Changelog.
Paul Aurich <darkrain42@pidgin.im>
parents:
26997
diff
changeset
|
861 | serv_got_alias(js->gc, buddy_name, nickname); |
| 9954 | 862 | } else { |
| 15884 | 863 | purple_prpl_got_user_status(js->gc->account, buddy_name, "offline", status ? "message" : NULL, status, NULL); |
| 9954 | 864 | } |
| 7014 | 865 | g_free(buddy_name); |
| 866 | } | |
|
26976
5173897818ed
Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <darkrain42@pidgin.im>
parents:
26975
diff
changeset
|
867 | |
|
5173897818ed
Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <darkrain42@pidgin.im>
parents:
26975
diff
changeset
|
868 | if (caps && (!type || g_str_equal(type, "available"))) { |
|
5173897818ed
Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <darkrain42@pidgin.im>
parents:
26975
diff
changeset
|
869 | /* handle Entity Capabilities (XEP-0115) */ |
|
5173897818ed
Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <darkrain42@pidgin.im>
parents:
26975
diff
changeset
|
870 | const char *node = xmlnode_get_attrib(caps, "node"); |
|
5173897818ed
Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <darkrain42@pidgin.im>
parents:
26975
diff
changeset
|
871 | const char *ver = xmlnode_get_attrib(caps, "ver"); |
|
5173897818ed
Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <darkrain42@pidgin.im>
parents:
26975
diff
changeset
|
872 | const char *hash = xmlnode_get_attrib(caps, "hash"); |
|
5173897818ed
Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <darkrain42@pidgin.im>
parents:
26975
diff
changeset
|
873 | const char *ext = xmlnode_get_attrib(caps, "ext"); |
|
5173897818ed
Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <darkrain42@pidgin.im>
parents:
26975
diff
changeset
|
874 | |
|
5173897818ed
Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <darkrain42@pidgin.im>
parents:
26975
diff
changeset
|
875 | /* v1.3 uses: node, ver, and optionally ext. |
|
5173897818ed
Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <darkrain42@pidgin.im>
parents:
26975
diff
changeset
|
876 | * v1.5 uses: node, ver, and hash. */ |
|
5173897818ed
Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <darkrain42@pidgin.im>
parents:
26975
diff
changeset
|
877 | if (node && *node && ver && *ver) { |
|
27068
3353c0f46a1a
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents:
27066
diff
changeset
|
878 | gchar **exts = ext && *ext ? g_strsplit(ext, " ", -1) : NULL; |
|
3353c0f46a1a
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents:
27066
diff
changeset
|
879 | jbr = jabber_buddy_find_resource(jb, jid->resource); |
|
3353c0f46a1a
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents:
27066
diff
changeset
|
880 | |
|
3353c0f46a1a
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents:
27066
diff
changeset
|
881 | /* Look it up if we don't already have all this information */ |
|
3353c0f46a1a
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents:
27066
diff
changeset
|
882 | if (!jbr || !jbr->caps.info || |
|
3353c0f46a1a
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents:
27066
diff
changeset
|
883 | !g_str_equal(node, jbr->caps.info->tuple.node) || |
|
3353c0f46a1a
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents:
27066
diff
changeset
|
884 | !g_str_equal(ver, jbr->caps.info->tuple.ver) || |
|
3353c0f46a1a
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents:
27066
diff
changeset
|
885 | !purple_strequal(hash, jbr->caps.info->tuple.hash) || |
|
3353c0f46a1a
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents:
27066
diff
changeset
|
886 | !jabber_caps_exts_known(jbr->caps.info, (gchar **)exts)) { |
|
3353c0f46a1a
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents:
27066
diff
changeset
|
887 | JabberPresenceCapabilities *userdata = g_new0(JabberPresenceCapabilities, 1); |
|
3353c0f46a1a
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents:
27066
diff
changeset
|
888 | userdata->js = js; |
|
3353c0f46a1a
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents:
27066
diff
changeset
|
889 | userdata->jb = jb; |
|
3353c0f46a1a
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents:
27066
diff
changeset
|
890 | userdata->from = g_strdup(from); |
|
3353c0f46a1a
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents:
27066
diff
changeset
|
891 | jabber_caps_get_info(js, from, node, ver, hash, exts, |
|
3353c0f46a1a
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents:
27066
diff
changeset
|
892 | (jabber_caps_get_info_cb)jabber_presence_set_capabilities, |
|
3353c0f46a1a
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents:
27066
diff
changeset
|
893 | userdata); |
|
3353c0f46a1a
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents:
27066
diff
changeset
|
894 | } else { |
|
3353c0f46a1a
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents:
27066
diff
changeset
|
895 | if (exts) |
|
3353c0f46a1a
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents:
27066
diff
changeset
|
896 | g_strfreev(exts); |
|
3353c0f46a1a
Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <darkrain42@pidgin.im>
parents:
27066
diff
changeset
|
897 | } |
|
26976
5173897818ed
Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <darkrain42@pidgin.im>
parents:
26975
diff
changeset
|
898 | } |
|
5173897818ed
Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <darkrain42@pidgin.im>
parents:
26975
diff
changeset
|
899 | } |
|
5173897818ed
Fetch and track capabilities for MUC members. Add a further constraint for
Paul Aurich <darkrain42@pidgin.im>
parents:
26975
diff
changeset
|
900 | |
|
26998
5d912b08679d
A little bit better (free memory and support receiving the nick in subscriptions) and Changelog.
Paul Aurich <darkrain42@pidgin.im>
parents:
26997
diff
changeset
|
901 | g_free(nickname); |
| 7014 | 902 | g_free(status); |
| 903 | 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
|
904 | g_free(avatar_hash); |
| 7014 | 905 | } |
| 906 | ||
| 907 | void jabber_presence_subscription_set(JabberStream *js, const char *who, const char *type) | |
| 908 | { | |
| 909 | xmlnode *presence = xmlnode_new("presence"); | |
| 910 | ||
| 911 | xmlnode_set_attrib(presence, "to", who); | |
| 912 | xmlnode_set_attrib(presence, "type", type); | |
| 913 | ||
| 914 | jabber_send(js, presence); | |
| 915 | xmlnode_free(presence); | |
| 916 | } | |
| 9954 | 917 | |
| 15884 | 918 | void purple_status_to_jabber(const PurpleStatus *status, JabberBuddyState *state, char **msg, int *priority) |
| 9954 | 919 | { |
| 10216 | 920 | const char *status_id = NULL; |
| 14525 | 921 | const char *formatted_msg = NULL; |
| 10216 | 922 | |
| 13443 | 923 | if(state) *state = JABBER_BUDDY_STATE_UNKNOWN; |
| 924 | if(msg) *msg = NULL; | |
| 925 | if(priority) *priority = 0; | |
| 9954 | 926 | |
| 927 | if(!status) { | |
| 13443 | 928 | if(state) *state = JABBER_BUDDY_STATE_UNAVAILABLE; |
| 10216 | 929 | } else { |
| 930 | if(state) { | |
| 15884 | 931 | status_id = purple_status_get_id(status); |
| 10216 | 932 | *state = jabber_buddy_status_id_get_state(status_id); |
| 933 | } | |
| 934 | ||
|
13497
07fc0a9826b8
[gaim-migrate @ 15872]
Richard Laager <rlaager@pidgin.im>
parents:
13445
diff
changeset
|
935 | if(msg) { |
| 15884 | 936 | formatted_msg = purple_status_get_attr_string(status, "message"); |
| 10216 | 937 | |
|
13497
07fc0a9826b8
[gaim-migrate @ 15872]
Richard Laager <rlaager@pidgin.im>
parents:
13445
diff
changeset
|
938 | /* if the message is blank, then there really isn't a message */ |
| 14525 | 939 | if(formatted_msg && !*formatted_msg) |
| 940 | formatted_msg = NULL; | |
| 941 | ||
| 942 | if(formatted_msg) | |
| 17683 | 943 | *msg = purple_markup_strip_html(formatted_msg); |
|
13497
07fc0a9826b8
[gaim-migrate @ 15872]
Richard Laager <rlaager@pidgin.im>
parents:
13445
diff
changeset
|
944 | } |
| 11872 | 945 | |
| 10216 | 946 | if(priority) |
| 15884 | 947 | *priority = purple_status_get_attr_int(status, "priority"); |
| 9954 | 948 | } |
| 949 | } |