diff 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
line wrap: on
line diff
--- a/libpurple/protocols/jabber/presence.c	Sun Nov 16 22:48:22 2008 +0000
+++ b/libpurple/protocols/jabber/presence.c	Mon Nov 17 18:22:26 2008 +0000
@@ -95,8 +95,7 @@
 }
 
 
-void jabber_presence_send(PurpleAccount *account, PurpleStatus *status,
-	gboolean update_idle)
+void jabber_presence_send(PurpleAccount *account, PurpleStatus *status)
 {
 	PurpleConnection *gc = NULL;
 	JabberStream *js = NULL;
@@ -151,8 +150,9 @@
 #define CHANGED(a,b) ((!a && b) || (a && a[0] == '\0' && b && b[0] != '\0') || \
 					  (a && !b) || (a && a[0] != '\0' && b && b[0] == '\0') || (a && b && strcmp(a,b)))
 	/* check if there are any differences to the <presence> and send them in that case */
-	if (update_idle || allowBuzz != js->allowBuzz || js->old_state != state || CHANGED(js->old_msg, stripped) ||
-		js->old_priority != priority || CHANGED(js->old_avatarhash, js->avatar_hash)) {
+	if (allowBuzz != js->allowBuzz || js->old_state != state || CHANGED(js->old_msg, stripped) ||
+		js->old_priority != priority || CHANGED(js->old_avatarhash, js->avatar_hash) ||
+		js->old_idle != js->idle) {
 		js->allowBuzz = allowBuzz;
 
 		presence = jabber_presence_create_js(js, state, stripped, priority);
@@ -179,6 +179,7 @@
 		js->old_avatarhash = g_strdup(js->avatar_hash);
 		js->old_state = state;
 		js->old_priority = priority;
+		js->old_idle = js->idle;
 	}
 	g_free(stripped);
 
@@ -265,7 +266,7 @@
 	if (js->idle && state != JABBER_BUDDY_STATE_UNAVAILABLE) {
 		xmlnode *query = xmlnode_new_child(presence, "query");
 		gchar seconds[10];
-		g_sprintf(seconds, "%d", (int) (time(NULL) - js->idle));
+		g_snprintf(seconds, 10, "%d", (int) (time(NULL) - js->idle));
 		
 		xmlnode_set_namespace(query, "jabber:iq:last");
 		xmlnode_set_attrib(query, "seconds", seconds);