Merge lp:~ken-vandine/telepathy-indicator/lp_947590 into lp:telepathy-indicator

Proposed by Ken VanDine
Status: Merged
Merged at revision: 57
Proposed branch: lp:~ken-vandine/telepathy-indicator/lp_947590
Merge into: lp:telepathy-indicator
Prerequisite: lp:~ken-vandine/telepathy-indicator/lp_926072
Diff against target: 114 lines (+61/-2)
1 file modified
src/indicator-approver.c (+61/-2)
To merge this branch: bzr merge lp:~ken-vandine/telepathy-indicator/lp_947590
Reviewer Review Type Date Requested Status
Sebastien Bacher Approve
Review via email: mp+98778@code.launchpad.net

Description of the change

Use IndicateInterests to determine if there are listeners, this will prevent crashers when telepathy-indicator is run in gnome-shell or other environments without a messaging indicator (LP: #947590)

To post a comment you must log in.
Revision history for this message
Sebastien Bacher (seb128) wrote :

Looks fine to me

Is there any reason at all to run the indicator under gnome-shell? Wouldn't it make sense to add an OnlyShowIn=Unity; do the autostart desktop there?

review: Approve
Revision history for this message
Ken VanDine (ken-vandine) wrote :

Good idea, I'll do that as well. It is good to check interest anyway, in case the indicator goes away for any reason. If it goes away, and a message arrives, it would cause a crash.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/indicator-approver.c'
2--- src/indicator-approver.c 2012-03-22 04:10:26 +0000
3+++ src/indicator-approver.c 2012-03-22 04:10:26 +0000
4@@ -34,6 +34,7 @@
5 #include <unity.h>
6
7 static GHashTable *indicators = NULL;
8+static gboolean has_interest = FALSE;
9 UnityLauncherEntry *launcher = NULL;
10 GList *conns;
11
12@@ -65,7 +66,7 @@
13 }
14
15 const gchar *channel_id;
16- g_debug ("indicator_remove_by_id: %s", id);
17+ g_debug ("find_indicator_by_id: %s", id);
18
19 GHashTableIter iter;
20 gpointer data, indicator;
21@@ -429,6 +430,13 @@
22 GList *channels, TpChannelDispatchOperation *dispatch_op, TpAddDispatchOperationContext *context,
23 gpointer user_data)
24 {
25+ if (has_interest == FALSE)
26+ {
27+ g_debug ("add_dispatch_operation_cb but there are no listeners with interest");
28+ tp_add_dispatch_operation_context_accept (context);
29+ return;
30+ }
31+
32 GList *itr;
33 TpChannel *channel;
34 TpHandle handle;
35@@ -454,7 +462,12 @@
36 GList *channels, TpChannelDispatchOperation *dispatch_op, GList *requests, TpObserveChannelsContext *context,
37 gpointer user_data)
38 {
39- g_debug ("observer_add_dispatch_operation_cb");
40+ if (has_interest == FALSE)
41+ {
42+ g_debug ("observer_add_dispatch_operation_cb but there are no listeners with interest");
43+ tp_observe_channels_context_accept (context);
44+ return;
45+ }
46 GList *itr;
47 TpChannel *channel;
48
49@@ -483,6 +496,13 @@
50 server_display (IndicateServer * indicate_server, guint timestamp, gpointer user_data)
51 {
52 g_debug ("server_display at %u", timestamp);
53+
54+ if (has_interest == FALSE)
55+ {
56+ g_debug ("server_display but there are no listeners with interest");
57+ return;
58+ }
59+
60 GDesktopAppInfo *app;
61 GError *error = NULL;
62
63@@ -500,6 +520,34 @@
64 g_object_unref (app);
65 }
66
67+static void
68+indicate_server_show_interest (IndicateServer * server, IndicateInterests interest, gpointer data)
69+{
70+ g_debug ("indicate_server_show_interest");
71+ if (interest == INDICATE_INTEREST_SERVER_SIGNAL)
72+ {
73+ if (has_interest == FALSE)
74+ {
75+ has_interest = TRUE;
76+ }
77+ }
78+ return;
79+}
80+
81+static void
82+indicate_server_remove_interest (IndicateServer * server, IndicateInterests interest, gpointer data)
83+{
84+ g_debug ("indicate_server_remove_interest");
85+ if (interest == INDICATE_INTEREST_SERVER_SIGNAL)
86+ {
87+ if (has_interest == TRUE)
88+ {
89+ has_interest = FALSE;
90+ }
91+ }
92+ return;
93+}
94+
95 static IndicateServer *
96 indicate_server_setup ()
97 {
98@@ -517,6 +565,17 @@
99 g_signal_connect (G_OBJECT (indicate_server),
100 INDICATE_SERVER_SIGNAL_SERVER_DISPLAY,
101 G_CALLBACK (server_display), NULL);
102+
103+ g_signal_connect (G_OBJECT (indicate_server),
104+ INDICATE_SERVER_SIGNAL_INTEREST_ADDED,
105+ G_CALLBACK (indicate_server_show_interest), NULL);
106+ g_signal_connect (G_OBJECT (indicate_server),
107+ INDICATE_SERVER_SIGNAL_INTEREST_REMOVED,
108+ G_CALLBACK (indicate_server_remove_interest), NULL);
109+
110+ has_interest = indicate_server_check_interest (indicate_server,
111+ INDICATE_INTEREST_SERVER_SIGNAL);
112+
113 return indicate_server;
114 }
115

Subscribers

People subscribed via source and target branches

to all changes: