changeset 25794: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
files libpurple/protocols/jabber/buddy.c libpurple/protocols/jabber/disco.c libpurple/protocols/jabber/jabber.c libpurple/protocols/jabber/jabber.h libpurple/protocols/jabber/presence.c libpurple/protocols/jabber/presence.h libpurple/protocols/jabber/roster.c
diffstat 7 files changed, 12 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/buddy.c	Sun Nov 16 22:48:22 2008 +0000
+++ b/libpurple/protocols/jabber/buddy.c	Mon Nov 17 18:22:26 2008 +0000
@@ -627,7 +627,7 @@
 
 	gpresence = purple_account_get_presence(gc->account);
 	status = purple_presence_get_active_status(gpresence);
-	jabber_presence_send(gc->account, status, FALSE);
+	jabber_presence_send(gc->account, status);
 }
 
 /*
--- a/libpurple/protocols/jabber/disco.c	Sun Nov 16 22:48:22 2008 +0000
+++ b/libpurple/protocols/jabber/disco.c	Mon Nov 17 18:22:26 2008 +0000
@@ -348,7 +348,7 @@
 	}
 
 	/* Send initial presence; this will trigger receipt of presence for contacts on the roster */
-	jabber_presence_send(js->gc->account, NULL, FALSE);
+	jabber_presence_send(js->gc->account, NULL);
 
 	if (js->server_caps & JABBER_CAP_ADHOC) {
 		/* The server supports ad-hoc commands, so let's request the list */
--- a/libpurple/protocols/jabber/jabber.c	Sun Nov 16 22:48:22 2008 +0000
+++ b/libpurple/protocols/jabber/jabber.c	Mon Nov 17 18:22:26 2008 +0000
@@ -1441,7 +1441,7 @@
 	
 	/* send out an updated prescence */
 	purple_debug_info("jabber", "sending updated presence for idle\n");
-	jabber_presence_send(account, status, TRUE);
+	jabber_presence_send(account, status);
 }
 
 void jabber_add_feature(const char *shortname, const char *namespace, JabberFeatureEnabled cb) {
--- a/libpurple/protocols/jabber/jabber.h	Sun Nov 16 22:48:22 2008 +0000
+++ b/libpurple/protocols/jabber/jabber.h	Mon Nov 17 18:22:26 2008 +0000
@@ -153,6 +153,7 @@
 	GList *file_transfers;
 
 	time_t idle;
+	time_t old_idle;
 
 	JabberID *user;
 	PurpleConnection *gc;
--- 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);
--- a/libpurple/protocols/jabber/presence.h	Sun Nov 16 22:48:22 2008 +0000
+++ b/libpurple/protocols/jabber/presence.h	Mon Nov 17 18:22:26 2008 +0000
@@ -26,8 +26,7 @@
 #include "jabber.h"
 #include "xmlnode.h"
 
-void jabber_presence_send(PurpleAccount *account, PurpleStatus *status,
-	gboolean update_idle);
+void jabber_presence_send(PurpleAccount *account, PurpleStatus *status);
 xmlnode *jabber_presence_create(JabberBuddyState state, const char *msg, int priority); /* DEPRECATED */
 xmlnode *jabber_presence_create_js(JabberStream *js, JabberBuddyState state, const char *msg, int priority);
 void jabber_presence_parse(JabberStream *js, xmlnode *packet);
--- a/libpurple/protocols/jabber/roster.c	Sun Nov 16 22:48:22 2008 +0000
+++ b/libpurple/protocols/jabber/roster.c	Mon Nov 17 18:22:26 2008 +0000
@@ -261,7 +261,7 @@
 	if(!js->roster_parsed) {
 		js->roster_parsed = TRUE;
 
-		jabber_presence_send(js->gc->account, NULL, FALSE);
+		jabber_presence_send(js->gc->account, NULL);
 	}
 }