comparison libpurple/protocols/jabber/presence.c @ 25443:5f9a24d1c25e

Remove some extra trailing whitespace I noticed after merging mlundblad's xmpp branches.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Mon, 02 Mar 2009 06:37:05 +0000
parents bba38f03085d
children 13541e130064 7e020fbe2cdb c4fd9222dda1 ff4212a5268f ae41d8e827e3
comparison
equal deleted inserted replaced
25442:13574de83636 25443:5f9a24d1c25e
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)) {
164 164
165 jabber_send(js, presence); 165 jabber_send(js, presence);
166 166
167 g_hash_table_foreach(js->chats, chats_send_presence_foreach, presence); 167 g_hash_table_foreach(js->chats, chats_send_presence_foreach, presence);
168 xmlnode_free(presence); 168 xmlnode_free(presence);
169 169
170 /* update old values */ 170 /* update old values */
171 171
172 if(js->old_msg) 172 if(js->old_msg)
173 g_free(js->old_msg); 173 g_free(js->old_msg);
174 if(js->old_avatarhash) 174 if(js->old_avatarhash)
175 g_free(js->old_avatarhash); 175 g_free(js->old_avatarhash);
176 js->old_msg = g_strdup(stripped); 176 js->old_msg = g_strdup(stripped);
189 uri = purple_status_get_attr_string(tune, PURPLE_TUNE_URL); 189 uri = purple_status_get_attr_string(tune, PURPLE_TUNE_URL);
190 track = purple_status_get_attr_string(tune, PURPLE_TUNE_TRACK); 190 track = purple_status_get_attr_string(tune, PURPLE_TUNE_TRACK);
191 length = (!purple_status_get_attr_value(tune, PURPLE_TUNE_TIME)) ? -1 : 191 length = (!purple_status_get_attr_value(tune, PURPLE_TUNE_TIME)) ? -1 :
192 purple_status_get_attr_int(tune, PURPLE_TUNE_TIME); 192 purple_status_get_attr_int(tune, PURPLE_TUNE_TIME);
193 } 193 }
194 194
195 if(CHANGED(artist, js->old_artist) || CHANGED(title, js->old_title) || CHANGED(source, js->old_source) || 195 if(CHANGED(artist, js->old_artist) || CHANGED(title, js->old_title) || CHANGED(source, js->old_source) ||
196 CHANGED(uri, js->old_uri) || CHANGED(track, js->old_track) || (length != js->old_length)) { 196 CHANGED(uri, js->old_uri) || CHANGED(track, js->old_track) || (length != js->old_length)) {
197 PurpleJabberTuneInfo tuneinfo = { 197 PurpleJabberTuneInfo tuneinfo = {
198 (char*)artist, 198 (char*)artist,
199 (char*)title, 199 (char*)title,
201 (char*)track, 201 (char*)track,
202 length, 202 length,
203 (char*)uri 203 (char*)uri
204 }; 204 };
205 jabber_tune_set(js->gc, &tuneinfo); 205 jabber_tune_set(js->gc, &tuneinfo);
206 206
207 /* update old values */ 207 /* update old values */
208 g_free(js->old_artist); 208 g_free(js->old_artist);
209 g_free(js->old_title); 209 g_free(js->old_title);
210 g_free(js->old_source); 210 g_free(js->old_source);
211 g_free(js->old_uri); 211 g_free(js->old_uri);
262 /* JEP-0115 */ 262 /* JEP-0115 */
263 c = xmlnode_new_child(presence, "c"); 263 c = xmlnode_new_child(presence, "c");
264 xmlnode_set_namespace(c, "http://jabber.org/protocol/caps"); 264 xmlnode_set_namespace(c, "http://jabber.org/protocol/caps");
265 xmlnode_set_attrib(c, "node", CAPS0115_NODE); 265 xmlnode_set_attrib(c, "node", CAPS0115_NODE);
266 xmlnode_set_attrib(c, "ver", VERSION); 266 xmlnode_set_attrib(c, "ver", VERSION);
267 267
268 if(js != NULL) { 268 if(js != NULL) {
269 /* add the extensions */ 269 /* add the extensions */
270 char extlist[1024]; 270 char extlist[1024];
271 unsigned remaining = 1023; /* one less for the \0 */ 271 unsigned remaining = 1023; /* one less for the \0 */
272 GList *feature; 272 GList *feature;
273 273
274 extlist[0] = '\0'; 274 extlist[0] = '\0';
275 for(feature = jabber_features; feature && remaining > 0; feature = feature->next) { 275 for(feature = jabber_features; feature && remaining > 0; feature = feature->next) {
276 JabberFeature *feat = (JabberFeature*)feature->data; 276 JabberFeature *feat = (JabberFeature*)feature->data;
277 unsigned featlen; 277 unsigned featlen;
278 278
279 if(feat->is_enabled != NULL && feat->is_enabled(js, feat->shortname, feat->namespace) == FALSE) 279 if(feat->is_enabled != NULL && feat->is_enabled(js, feat->shortname, feat->namespace) == FALSE)
280 continue; /* skip this feature */ 280 continue; /* skip this feature */
281 281
282 featlen = strlen(feat->shortname); 282 featlen = strlen(feat->shortname);
283 283
284 /* cut off when we don't have any more space left in our buffer (too bad) */ 284 /* cut off when we don't have any more space left in our buffer (too bad) */
285 if(featlen > remaining) 285 if(featlen > remaining)
286 break; 286 break;
287 287
288 strncat(extlist,feat->shortname,remaining); 288 strncat(extlist,feat->shortname,remaining);
289 remaining -= featlen; 289 remaining -= featlen;
290 if(feature->next) { /* no space at the end */ 290 if(feature->next) { /* no space at the end */
291 strncat(extlist," ",remaining); 291 strncat(extlist," ",remaining);
292 --remaining; 292 --remaining;
294 } 294 }
295 /* did we add anything? */ 295 /* did we add anything? */
296 if(remaining < 1023) 296 if(remaining < 1023)
297 xmlnode_set_attrib(c, "ext", extlist); 297 xmlnode_set_attrib(c, "ext", extlist);
298 } 298 }
299 299
300 return presence; 300 return presence;
301 } 301 }
302 302
303 struct _jabber_add_permit { 303 struct _jabber_add_permit {
304 PurpleConnection *gc; 304 PurpleConnection *gc;
743 state, status); 743 state, status);
744 if(caps) { 744 if(caps) {
745 const char *node = xmlnode_get_attrib(caps,"node"); 745 const char *node = xmlnode_get_attrib(caps,"node");
746 const char *ver = xmlnode_get_attrib(caps,"ver"); 746 const char *ver = xmlnode_get_attrib(caps,"ver");
747 const char *ext = xmlnode_get_attrib(caps,"ext"); 747 const char *ext = xmlnode_get_attrib(caps,"ext");
748 748
749 if(node && ver) { 749 if(node && ver) {
750 JabberPresenceCapabilities *userdata = g_new0(JabberPresenceCapabilities, 1); 750 JabberPresenceCapabilities *userdata = g_new0(JabberPresenceCapabilities, 1);
751 userdata->js = js; 751 userdata->js = js;
752 userdata->jb = jb; 752 userdata->jb = jb;
753 userdata->from = g_strdup(from); 753 userdata->from = g_strdup(from);