← Back to team overview

ayatana-commits team mailing list archive

[Merge] lp:~ted/libindicate/always-interest-signal into lp:libindicate

 

Ted Gould has proposed merging lp:~ted/libindicate/always-interest-signal into lp:libindicate.

Requested reviews:
  Indicator Applet Developers (indicator-applet-developers)

For more details, see:
https://code.launchpad.net/~ted/libindicate/always-interest-signal/+merge/45485

An old branch that I can't believe I didn't push!

This makes it so that the client always gets an interest signal no matter what.  So it can do a fallback when there is no interest and doesn't have to handle that specially itself.
-- 
https://code.launchpad.net/~ted/libindicate/always-interest-signal/+merge/45485
Your team ayatana-commits is subscribed to branch lp:libindicate.
=== modified file 'libindicate/server.c'
--- libindicate/server.c	2010-09-03 17:48:41 +0000
+++ libindicate/server.c	2011-01-07 05:18:56 +0000
@@ -111,6 +111,7 @@
 	/* Folks caches */
 	gint max_indicators;
 	gboolean interests[INDICATE_INTEREST_LAST];
+	gulong interest_timer;
 };
 
 #define INDICATE_SERVER_GET_PRIVATE(o) \
@@ -159,6 +160,7 @@
 static void indicate_server_interested_folks_set (IndicateServerInterestedFolk * folk, IndicateInterests interest, gboolean value);
 static void indicate_server_interested_folks_copy (IndicateServerInterestedFolk * folk, gboolean * interests);
 static void indicate_server_interested_folks_destroy(IndicateServerInterestedFolk * folk);
+static gboolean interest_timer (gpointer user_data);
 
 /* DBus API */
 gboolean _indicate_interface_server_get_indicator_count (IndicateServer * server, guint * count, GError **error);
@@ -307,6 +309,10 @@
 
 		Emitted when a listener signals that they are no longer interested in
 		this server for a particular reason.  This signal is emitted by DBus.
+
+		@note This signal is also emitted after a timeout when the object
+		is created with @arg1 set to #INDICATOR_INTREST_NONE if no one has
+		shown any interest in the server.
 	*/
 	signals[INTEREST_REMOVED] = g_signal_new(INDICATE_SERVER_SIGNAL_INTEREST_REMOVED,
 	                                        G_TYPE_FROM_CLASS (class),
@@ -417,6 +423,8 @@
 	dbus_connection_add_filter(dbus_g_connection_get_connection(priv->connection), dbus_filter_new_listener, server, NULL);
 	dbus_bus_add_match(dbus_g_connection_get_connection(priv->connection), "type='signal',interface='" INDICATE_LISTENER_DBUS_IFACE "',member='IndicatorServersReport'", NULL);
 
+	priv->interest_timer = g_timeout_add(500, interest_timer, server);
+
 	return;
 }
 
@@ -440,6 +448,11 @@
 		priv->dbus_proxy = NULL;
 	}
 
+	if (priv->interest_timer != 0) {
+		g_source_remove(priv->interest_timer);
+		priv->interest_timer = 0;
+	}
+
 	return;
 }
 
@@ -810,6 +823,11 @@
 
 	IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
 
+	if (priv->interest_timer != 0) {
+		g_source_remove(priv->interest_timer);
+		priv->interest_timer = 0;
+	}
+
 	GList * entry = g_list_find_custom(priv->interestedfolks, &localfolk, indicate_server_interested_folks_equal);
 	IndicateServerInterestedFolk * folkpointer = NULL;
 	if (entry == NULL) {
@@ -844,6 +862,11 @@
 
 	IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
 
+	/* NOTE: We're not removing the timer here, because we know the timer
+	   started in a state where there was no interest.  So if someone has
+	   since shown interest, there'll be no timer, and if they haven't then
+	   this function won't send a signal anyway. */
+
 	/* Figure out the folk that we're talking to.  If we
 	   have an entry for them, use it, otherwise we need
 	   to create one. */
@@ -882,6 +905,20 @@
 	return TRUE;
 }
 
+/* This little timer fires if no one shows any interest at startup
+   and signals a removed of NONE saying that there is no interest. */
+static gboolean
+interest_timer (gpointer user_data)
+{
+	g_return_val_if_fail(INDICATE_IS_SERVER(user_data), FALSE);
+	IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(user_data);
+
+	g_signal_emit(G_OBJECT(user_data), signals[INTEREST_REMOVED], 0, INDICATE_INTEREST_NONE, TRUE);
+	priv->interest_timer = 0;
+
+	return FALSE;
+}
+
 /* Checks to see if a particular interest value is
    set.  Uses the interest cache. */
 static gboolean


Follow ups