Mercurial > pidgin
comparison libpurple/protocols/jabber/presence.c @ 25201:3d4ce9df0d48
Change jabber_presence_send to not take an extra argument to force idle updating
Changed a g_sprintf to g_snprintf
Thanks to darkrain42 for feedback and suggestions
author | Marcus Lundblad <ml@update.uu.se> |
---|---|
date | Mon, 17 Nov 2008 18:22:26 +0000 |
parents | bb996cc49073 |
children | f8e6484fa8ac |
comparison
equal
deleted
inserted
replaced
25200:bb996cc49073 | 25201:3d4ce9df0d48 |
---|---|
93 } | 93 } |
94 g_free(my_base_jid); | 94 g_free(my_base_jid); |
95 } | 95 } |
96 | 96 |
97 | 97 |
98 void jabber_presence_send(PurpleAccount *account, PurpleStatus *status, | 98 void jabber_presence_send(PurpleAccount *account, PurpleStatus *status) |
99 gboolean update_idle) | |
100 { | 99 { |
101 PurpleConnection *gc = NULL; | 100 PurpleConnection *gc = NULL; |
102 JabberStream *js = NULL; | 101 JabberStream *js = NULL; |
103 xmlnode *presence, *x, *photo; | 102 xmlnode *presence, *x, *photo; |
104 char *stripped = NULL; | 103 char *stripped = NULL; |
149 } | 148 } |
150 | 149 |
151 #define CHANGED(a,b) ((!a && b) || (a && a[0] == '\0' && b && b[0] != '\0') || \ | 150 #define CHANGED(a,b) ((!a && b) || (a && a[0] == '\0' && b && b[0] != '\0') || \ |
152 (a && !b) || (a && a[0] != '\0' && b && b[0] == '\0') || (a && b && strcmp(a,b))) | 151 (a && !b) || (a && a[0] != '\0' && b && b[0] == '\0') || (a && b && strcmp(a,b))) |
153 /* check if there are any differences to the <presence> and send them in that case */ | 152 /* check if there are any differences to the <presence> and send them in that case */ |
154 if (update_idle || allowBuzz != js->allowBuzz || js->old_state != state || CHANGED(js->old_msg, stripped) || | 153 if (allowBuzz != js->allowBuzz || js->old_state != state || CHANGED(js->old_msg, stripped) || |
155 js->old_priority != priority || CHANGED(js->old_avatarhash, js->avatar_hash)) { | 154 js->old_priority != priority || CHANGED(js->old_avatarhash, js->avatar_hash) || |
155 js->old_idle != js->idle) { | |
156 js->allowBuzz = allowBuzz; | 156 js->allowBuzz = allowBuzz; |
157 | 157 |
158 presence = jabber_presence_create_js(js, state, stripped, priority); | 158 presence = jabber_presence_create_js(js, state, stripped, priority); |
159 | 159 |
160 if(js->avatar_hash) { | 160 if(js->avatar_hash) { |
177 g_free(js->old_avatarhash); | 177 g_free(js->old_avatarhash); |
178 js->old_msg = g_strdup(stripped); | 178 js->old_msg = g_strdup(stripped); |
179 js->old_avatarhash = g_strdup(js->avatar_hash); | 179 js->old_avatarhash = g_strdup(js->avatar_hash); |
180 js->old_state = state; | 180 js->old_state = state; |
181 js->old_priority = priority; | 181 js->old_priority = priority; |
182 js->old_idle = js->idle; | |
182 } | 183 } |
183 g_free(stripped); | 184 g_free(stripped); |
184 | 185 |
185 /* next, check if there are any changes to the tune values */ | 186 /* next, check if there are any changes to the tune values */ |
186 tune = purple_presence_get_status(p, "tune"); | 187 tune = purple_presence_get_status(p, "tune"); |
263 | 264 |
264 /* if we are idle and not offline, include idle */ | 265 /* if we are idle and not offline, include idle */ |
265 if (js->idle && state != JABBER_BUDDY_STATE_UNAVAILABLE) { | 266 if (js->idle && state != JABBER_BUDDY_STATE_UNAVAILABLE) { |
266 xmlnode *query = xmlnode_new_child(presence, "query"); | 267 xmlnode *query = xmlnode_new_child(presence, "query"); |
267 gchar seconds[10]; | 268 gchar seconds[10]; |
268 g_sprintf(seconds, "%d", (int) (time(NULL) - js->idle)); | 269 g_snprintf(seconds, 10, "%d", (int) (time(NULL) - js->idle)); |
269 | 270 |
270 xmlnode_set_namespace(query, "jabber:iq:last"); | 271 xmlnode_set_namespace(query, "jabber:iq:last"); |
271 xmlnode_set_attrib(query, "seconds", seconds); | 272 xmlnode_set_attrib(query, "seconds", seconds); |
272 } | 273 } |
273 | 274 |