Mercurial > pidgin.yaz
comparison libpurple/protocols/jabber/presence.c @ 25982:7e020fbe2cdb
propagate from branch 'im.pidgin.pidgin' (head 303af74a38e7b313d4fb0be4d4054a16cb13d819)
to branch 'im.pidgin.cpw.darkrain42.xmpp.avatars' (head 11e989f3ac36a0f958f031d55245db093923ea76)
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Sat, 07 Mar 2009 01:32:29 +0000 |
parents | 0fa91206cf5a 5f9a24d1c25e |
children | 242a8c97270b |
comparison
equal
deleted
inserted
replaced
25832:2d92bbe6807b | 25982:7e020fbe2cdb |
---|---|
134 purple_debug_info("jabber", "attempt to send presence before roster retrieved\n"); | 134 purple_debug_info("jabber", "attempt to send presence before roster retrieved\n"); |
135 return; | 135 return; |
136 } | 136 } |
137 | 137 |
138 purple_status_to_jabber(status, &state, &stripped, &priority); | 138 purple_status_to_jabber(status, &state, &stripped, &priority); |
139 | 139 |
140 /* check for buzz support */ | 140 /* check for buzz support */ |
141 allowBuzz = purple_status_get_attr_boolean(status,"buzz"); | 141 allowBuzz = purple_status_get_attr_boolean(status,"buzz"); |
142 /* changing the buzz state has to trigger a re-broadcasting of the presence for caps */ | 142 /* changing the buzz state has to trigger a re-broadcasting of the presence for caps */ |
143 | 143 |
144 if (js->googletalk && stripped == NULL && purple_presence_is_status_primitive_active(p, PURPLE_STATUS_TUNE)) { | 144 if (js->googletalk && stripped == NULL && purple_presence_is_status_primitive_active(p, PURPLE_STATUS_TUNE)) { |
145 tune = purple_presence_get_status(p, "tune"); | 145 tune = purple_presence_get_status(p, "tune"); |
146 stripped = jabber_google_presence_outgoing(tune); | 146 stripped = jabber_google_presence_outgoing(tune); |
147 } | 147 } |
148 | 148 |
149 #define CHANGED(a,b) ((!a && b) || (a && a[0] == '\0' && b && b[0] != '\0') || \ | 149 #define CHANGED(a,b) ((!a && b) || (a && a[0] == '\0' && b && b[0] != '\0') || \ |
150 (a && !b) || (a && a[0] != '\0' && b && b[0] == '\0') || (a && b && strcmp(a,b))) | 150 (a && !b) || (a && a[0] != '\0' && b && b[0] == '\0') || (a && b && strcmp(a,b))) |
151 /* check if there are any differences to the <presence> and send them in that case */ | 151 /* check if there are any differences to the <presence> and send them in that case */ |
152 if (allowBuzz != js->allowBuzz || js->old_state != state || CHANGED(js->old_msg, stripped) || | 152 if (allowBuzz != js->allowBuzz || js->old_state != state || CHANGED(js->old_msg, stripped) || |
153 js->old_priority != priority || CHANGED(js->old_avatarhash, js->avatar_hash)) { | 153 js->old_priority != priority || CHANGED(js->old_avatarhash, js->avatar_hash)) { |
172 | 172 |
173 jabber_send(js, presence); | 173 jabber_send(js, presence); |
174 | 174 |
175 g_hash_table_foreach(js->chats, chats_send_presence_foreach, presence); | 175 g_hash_table_foreach(js->chats, chats_send_presence_foreach, presence); |
176 xmlnode_free(presence); | 176 xmlnode_free(presence); |
177 | 177 |
178 /* update old values */ | 178 /* update old values */ |
179 | 179 |
180 if(js->old_msg) | 180 if(js->old_msg) |
181 g_free(js->old_msg); | 181 g_free(js->old_msg); |
182 if(js->old_avatarhash) | 182 if(js->old_avatarhash) |
183 g_free(js->old_avatarhash); | 183 g_free(js->old_avatarhash); |
184 js->old_msg = g_strdup(stripped); | 184 js->old_msg = g_strdup(stripped); |
197 uri = purple_status_get_attr_string(tune, PURPLE_TUNE_URL); | 197 uri = purple_status_get_attr_string(tune, PURPLE_TUNE_URL); |
198 track = purple_status_get_attr_string(tune, PURPLE_TUNE_TRACK); | 198 track = purple_status_get_attr_string(tune, PURPLE_TUNE_TRACK); |
199 length = (!purple_status_get_attr_value(tune, PURPLE_TUNE_TIME)) ? -1 : | 199 length = (!purple_status_get_attr_value(tune, PURPLE_TUNE_TIME)) ? -1 : |
200 purple_status_get_attr_int(tune, PURPLE_TUNE_TIME); | 200 purple_status_get_attr_int(tune, PURPLE_TUNE_TIME); |
201 } | 201 } |
202 | 202 |
203 if(CHANGED(artist, js->old_artist) || CHANGED(title, js->old_title) || CHANGED(source, js->old_source) || | 203 if(CHANGED(artist, js->old_artist) || CHANGED(title, js->old_title) || CHANGED(source, js->old_source) || |
204 CHANGED(uri, js->old_uri) || CHANGED(track, js->old_track) || (length != js->old_length)) { | 204 CHANGED(uri, js->old_uri) || CHANGED(track, js->old_track) || (length != js->old_length)) { |
205 PurpleJabberTuneInfo tuneinfo = { | 205 PurpleJabberTuneInfo tuneinfo = { |
206 (char*)artist, | 206 (char*)artist, |
207 (char*)title, | 207 (char*)title, |
209 (char*)track, | 209 (char*)track, |
210 length, | 210 length, |
211 (char*)uri | 211 (char*)uri |
212 }; | 212 }; |
213 jabber_tune_set(js->gc, &tuneinfo); | 213 jabber_tune_set(js->gc, &tuneinfo); |
214 | 214 |
215 /* update old values */ | 215 /* update old values */ |
216 g_free(js->old_artist); | 216 g_free(js->old_artist); |
217 g_free(js->old_title); | 217 g_free(js->old_title); |
218 g_free(js->old_source); | 218 g_free(js->old_source); |
219 g_free(js->old_uri); | 219 g_free(js->old_uri); |
270 /* JEP-0115 */ | 270 /* JEP-0115 */ |
271 c = xmlnode_new_child(presence, "c"); | 271 c = xmlnode_new_child(presence, "c"); |
272 xmlnode_set_namespace(c, "http://jabber.org/protocol/caps"); | 272 xmlnode_set_namespace(c, "http://jabber.org/protocol/caps"); |
273 xmlnode_set_attrib(c, "node", CAPS0115_NODE); | 273 xmlnode_set_attrib(c, "node", CAPS0115_NODE); |
274 xmlnode_set_attrib(c, "ver", VERSION); | 274 xmlnode_set_attrib(c, "ver", VERSION); |
275 | 275 |
276 if(js != NULL) { | 276 if(js != NULL) { |
277 /* add the extensions */ | 277 /* add the extensions */ |
278 char extlist[1024]; | 278 char extlist[1024]; |
279 unsigned remaining = 1023; /* one less for the \0 */ | 279 unsigned remaining = 1023; /* one less for the \0 */ |
280 GList *feature; | 280 GList *feature; |
281 | 281 |
282 extlist[0] = '\0'; | 282 extlist[0] = '\0'; |
283 for(feature = jabber_features; feature && remaining > 0; feature = feature->next) { | 283 for(feature = jabber_features; feature && remaining > 0; feature = feature->next) { |
284 JabberFeature *feat = (JabberFeature*)feature->data; | 284 JabberFeature *feat = (JabberFeature*)feature->data; |
285 unsigned featlen; | 285 unsigned featlen; |
286 | 286 |
287 if(feat->is_enabled != NULL && feat->is_enabled(js, feat->shortname, feat->namespace) == FALSE) | 287 if(feat->is_enabled != NULL && feat->is_enabled(js, feat->shortname, feat->namespace) == FALSE) |
288 continue; /* skip this feature */ | 288 continue; /* skip this feature */ |
289 | 289 |
290 featlen = strlen(feat->shortname); | 290 featlen = strlen(feat->shortname); |
291 | 291 |
292 /* cut off when we don't have any more space left in our buffer (too bad) */ | 292 /* cut off when we don't have any more space left in our buffer (too bad) */ |
293 if(featlen > remaining) | 293 if(featlen > remaining) |
294 break; | 294 break; |
295 | 295 |
296 strncat(extlist,feat->shortname,remaining); | 296 strncat(extlist,feat->shortname,remaining); |
297 remaining -= featlen; | 297 remaining -= featlen; |
298 if(feature->next) { /* no space at the end */ | 298 if(feature->next) { /* no space at the end */ |
299 strncat(extlist," ",remaining); | 299 strncat(extlist," ",remaining); |
300 --remaining; | 300 --remaining; |
302 } | 302 } |
303 /* did we add anything? */ | 303 /* did we add anything? */ |
304 if(remaining < 1023) | 304 if(remaining < 1023) |
305 xmlnode_set_attrib(c, "ext", extlist); | 305 xmlnode_set_attrib(c, "ext", extlist); |
306 } | 306 } |
307 | 307 |
308 return presence; | 308 return presence; |
309 } | 309 } |
310 | 310 |
311 struct _jabber_add_permit { | 311 struct _jabber_add_permit { |
312 PurpleConnection *gc; | 312 PurpleConnection *gc; |
751 state, status); | 751 state, status); |
752 if(caps) { | 752 if(caps) { |
753 const char *node = xmlnode_get_attrib(caps,"node"); | 753 const char *node = xmlnode_get_attrib(caps,"node"); |
754 const char *ver = xmlnode_get_attrib(caps,"ver"); | 754 const char *ver = xmlnode_get_attrib(caps,"ver"); |
755 const char *ext = xmlnode_get_attrib(caps,"ext"); | 755 const char *ext = xmlnode_get_attrib(caps,"ext"); |
756 | 756 |
757 if(node && ver) { | 757 if(node && ver) { |
758 JabberPresenceCapabilities *userdata = g_new0(JabberPresenceCapabilities, 1); | 758 JabberPresenceCapabilities *userdata = g_new0(JabberPresenceCapabilities, 1); |
759 userdata->js = js; | 759 userdata->js = js; |
760 userdata->jb = jb; | 760 userdata->jb = jb; |
761 userdata->from = g_strdup(from); | 761 userdata->from = g_strdup(from); |