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

Proposed by Ted Gould
Status: Merged
Merged at revision: 395
Proposed branch: lp:~ted/libindicate/always-interest-signal
Merge into: lp:libindicate/0.6
Diff against target: 96 lines (+37/-0)
1 file modified
libindicate/server.c (+37/-0)
To merge this branch: bzr merge lp:~ted/libindicate/always-interest-signal
Reviewer Review Type Date Requested Status
Mikkel Kamstrup Erlandsen (community) Approve
Review via email: mp+45485@code.launchpad.net

Description of the change

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.

To post a comment you must log in.
Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

 review approve

From a technical standpoint it looks fine, but I have no idea on how
it fits in with the bigger picture - but i trust you :-)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libindicate/server.c'
2--- libindicate/server.c 2010-09-03 17:48:41 +0000
3+++ libindicate/server.c 2011-01-07 05:19:52 +0000
4@@ -111,6 +111,7 @@
5 /* Folks caches */
6 gint max_indicators;
7 gboolean interests[INDICATE_INTEREST_LAST];
8+ gulong interest_timer;
9 };
10
11 #define INDICATE_SERVER_GET_PRIVATE(o) \
12@@ -159,6 +160,7 @@
13 static void indicate_server_interested_folks_set (IndicateServerInterestedFolk * folk, IndicateInterests interest, gboolean value);
14 static void indicate_server_interested_folks_copy (IndicateServerInterestedFolk * folk, gboolean * interests);
15 static void indicate_server_interested_folks_destroy(IndicateServerInterestedFolk * folk);
16+static gboolean interest_timer (gpointer user_data);
17
18 /* DBus API */
19 gboolean _indicate_interface_server_get_indicator_count (IndicateServer * server, guint * count, GError **error);
20@@ -307,6 +309,10 @@
21
22 Emitted when a listener signals that they are no longer interested in
23 this server for a particular reason. This signal is emitted by DBus.
24+
25+ @note This signal is also emitted after a timeout when the object
26+ is created with @arg1 set to #INDICATOR_INTREST_NONE if no one has
27+ shown any interest in the server.
28 */
29 signals[INTEREST_REMOVED] = g_signal_new(INDICATE_SERVER_SIGNAL_INTEREST_REMOVED,
30 G_TYPE_FROM_CLASS (class),
31@@ -417,6 +423,8 @@
32 dbus_connection_add_filter(dbus_g_connection_get_connection(priv->connection), dbus_filter_new_listener, server, NULL);
33 dbus_bus_add_match(dbus_g_connection_get_connection(priv->connection), "type='signal',interface='" INDICATE_LISTENER_DBUS_IFACE "',member='IndicatorServersReport'", NULL);
34
35+ priv->interest_timer = g_timeout_add(500, interest_timer, server);
36+
37 return;
38 }
39
40@@ -440,6 +448,11 @@
41 priv->dbus_proxy = NULL;
42 }
43
44+ if (priv->interest_timer != 0) {
45+ g_source_remove(priv->interest_timer);
46+ priv->interest_timer = 0;
47+ }
48+
49 return;
50 }
51
52@@ -810,6 +823,11 @@
53
54 IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
55
56+ if (priv->interest_timer != 0) {
57+ g_source_remove(priv->interest_timer);
58+ priv->interest_timer = 0;
59+ }
60+
61 GList * entry = g_list_find_custom(priv->interestedfolks, &localfolk, indicate_server_interested_folks_equal);
62 IndicateServerInterestedFolk * folkpointer = NULL;
63 if (entry == NULL) {
64@@ -844,6 +862,11 @@
65
66 IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
67
68+ /* NOTE: We're not removing the timer here, because we know the timer
69+ started in a state where there was no interest. So if someone has
70+ since shown interest, there'll be no timer, and if they haven't then
71+ this function won't send a signal anyway. */
72+
73 /* Figure out the folk that we're talking to. If we
74 have an entry for them, use it, otherwise we need
75 to create one. */
76@@ -882,6 +905,20 @@
77 return TRUE;
78 }
79
80+/* This little timer fires if no one shows any interest at startup
81+ and signals a removed of NONE saying that there is no interest. */
82+static gboolean
83+interest_timer (gpointer user_data)
84+{
85+ g_return_val_if_fail(INDICATE_IS_SERVER(user_data), FALSE);
86+ IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(user_data);
87+
88+ g_signal_emit(G_OBJECT(user_data), signals[INTEREST_REMOVED], 0, INDICATE_INTEREST_NONE, TRUE);
89+ priv->interest_timer = 0;
90+
91+ return FALSE;
92+}
93+
94 /* Checks to see if a particular interest value is
95 set. Uses the interest cache. */
96 static gboolean

Subscribers

People subscribed via source and target branches

to all changes: