changeset 9234:f18eb3f22733

[gaim-migrate @ 10030] This appears to be somewhat hacky, but due to the lack of a timer in blist.c, we need a core place to emit buddy-idle-updated. server.c now maintains a list of idle buddies and emits the signal when appropriate. We really need a better way to do this, which I'll attempt to incorporate into the status rewrite, but perhaps the best way would involve the blist update timer being in blist.c. Anyhow, this works for now. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Tue, 08 Jun 2004 02:02:25 +0000
parents 0c352d0e4ddc
children 7ae39c31e401
files src/gtkblist.c src/server.c
diffstat 2 files changed, 36 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkblist.c	Mon Jun 07 10:09:29 2004 +0000
+++ b/src/gtkblist.c	Tue Jun 08 02:02:25 2004 +0000
@@ -3541,8 +3541,6 @@
 			idle = g_strdup_printf("(%d:%02d)", ihrs, imin);
 		else
 			idle = g_strdup_printf("(%d)", imin);
-
-		gaim_signal_emit(gaim_blist_get_handle(), "buddy-idle-updated", buddy);
 	}
 
 	if (buddy->evil > 0)
--- a/src/server.c	Mon Jun 07 10:09:29 2004 +0000
+++ b/src/server.c	Tue Jun 08 02:02:25 2004 +0000
@@ -1055,7 +1055,27 @@
 	g_free(message);
 }
 
+/*
+ * NOTE: This is a bit hacky, but needed for core support for the
+ *       buddy-idle-updated signal. It's temporary, and will be replaced
+ *       with better code in the status rewrite.
+ */
+static GList *idle_buddies = NULL;
+static guint idle_buddy_timeout_id = 0;
 
+static gboolean
+idle_timeout_cb(void)
+{
+	GList *l;
+
+	for (l = idle_buddies; l != NULL; l = l->next)
+	{
+		gaim_signal_emit(gaim_blist_get_handle(), "buddy-idle-updated",
+						 l->data);
+	}
+
+	return TRUE;
+}
 
 void serv_got_update(GaimConnection *gc, const char *name, int loggedin,
 					 int evil, time_t signon, time_t idle, int type)
@@ -1219,14 +1239,26 @@
 	if (!old_idle && idle)
 	{
 		gaim_signal_emit(gaim_blist_get_handle(), "buddy-idle", b);
+
+		idle_buddies = g_list_append(idle_buddies, b);
+
+		if (idle_buddy_timeout_id == 0)
+		{
+			idle_buddy_timeout_id = gaim_timeout_add(10000,
+				(GSourceFunc)idle_timeout_cb, NULL);
+		}
 	}
 	else if (old_idle && !idle)
 	{
 		gaim_signal_emit(gaim_blist_get_handle(), "buddy-unidle", b);
-	}
-	else if (old_idle != idle)
-	{
-		gaim_signal_emit(gaim_blist_get_handle(), "buddy-idle-updated", b);
+
+		idle_buddies = g_list_remove(idle_buddies, b);
+
+		if (idle_buddies == NULL)
+		{
+			gaim_timeout_remove(idle_buddy_timeout_id);
+			idle_buddy_timeout_id = 0;
+		}
 	}
 
 	if (c != NULL)