Merge lp:~ted/indicator-application/startup-cleanup into lp:indicator-application/14.04

Proposed by Ted Gould
Status: Merged
Approved by: Charles Kerr
Approved revision: 254
Merged at revision: 246
Proposed branch: lp:~ted/indicator-application/startup-cleanup
Merge into: lp:indicator-application/14.04
Diff against target: 343 lines (+96/-65)
9 files modified
configure.ac (+1/-0)
data/Makefile.am (+6/-3)
data/indicator-application.conf.in (+3/-2)
data/indicator-application.desktop.in (+2/-4)
data/upstart/Makefile.am (+9/-0)
data/upstart/indicator-application.desktop.in (+8/-0)
src/Makefile.am (+1/-1)
src/application-service.c (+42/-26)
src/indicator-application.c (+24/-29)
To merge this branch: bzr merge lp:~ted/indicator-application/startup-cleanup
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+207774@code.launchpad.net

Commit message

Synchronize process management across indicators

Description of the change

This merge goes along with all of the other "startup-cleanup" merges to create a consistent startup for all indicators.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) wrote :

I built debs for all the startup-cleanup branches and tested them out; WfM

Revision history for this message
Charles Kerr (charlesk) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'configure.ac'
2--- configure.ac 2013-05-29 16:43:45 +0000
3+++ configure.ac 2014-02-22 04:22:05 +0000
4@@ -96,6 +96,7 @@
5 Makefile
6 src/Makefile
7 data/Makefile
8+data/upstart/Makefile
9 tests/Makefile
10 ])
11
12
13=== modified file 'data/Makefile.am'
14--- data/Makefile.am 2013-10-29 00:01:19 +0000
15+++ data/Makefile.am 2014-02-22 04:22:05 +0000
16@@ -1,15 +1,17 @@
17
18+SUBDIRS = upstart
19+
20 upstart_jobsdir = $(datadir)/upstart/sessions/
21 upstart_jobs_DATA = indicator-application.conf
22
23 %.conf: %.conf.in
24- sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@
25+ $(AM_V_GEN) sed -e "s|\@pkglibexecdir\@|$(pkglibexecdir)|" $< > $@
26
27 xdg_autostartdir = /etc/xdg/autostart
28 xdg_autostart_DATA = indicator-application.desktop
29
30 %.desktop: %.desktop.in
31- sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@
32+ $(AM_V_GEN) sed -e "s|\@pkglibexecdir\@|$(pkglibexecdir)|" $< > $@
33
34 overridedir = $(pkgdatadir)
35 override_DATA = ordering-override.keyfile
36@@ -20,5 +22,6 @@
37 ordering-override.keyfile
38
39 CLEANFILES = \
40- indicator-application.conf
41+ indicator-application.conf \
42+ indicator-application.desktop
43
44
45=== modified file 'data/indicator-application.conf.in'
46--- data/indicator-application.conf.in 2013-08-27 20:15:52 +0000
47+++ data/indicator-application.conf.in 2014-02-22 04:22:05 +0000
48@@ -3,13 +3,14 @@
49 # NOTE: Limiting only to Unity 7 right now as it's still using
50 # dbusmenu. That can be lifted after it is ported to GMenu
51
52-start on (indicators-loaded or indicator-services-start) and xsession SESSION=ubuntu
53+start on indicator-services-start and xsession SESSION=ubuntu
54 stop on desktop-end or indicator-services-end
55
56 emits appindicators-start appindicators-end
57
58 respawn
59+respawn limit 2 10
60
61-exec @libexecdir@/indicator-application-service
62+exec @pkglibexecdir@/indicator-application-service
63
64 pre-stop exec initctl emit appindicators-end
65
66=== modified file 'data/indicator-application.desktop.in'
67--- data/indicator-application.desktop.in 2013-10-29 00:01:19 +0000
68+++ data/indicator-application.desktop.in 2014-02-22 04:22:05 +0000
69@@ -1,9 +1,7 @@
70 [Desktop Entry]
71 Type=Application
72 Name=Indicator Application
73-Exec=@libexecdir@/indicator-application-service
74-NotShowIn=Unity;
75-NoDisplay=true
76+Exec=@pkglibexecdir@/indicator-application-service
77 StartupNotify=false
78 Terminal=false
79-
80+OnlyShowIn=Unity;XFCE;
81
82=== added directory 'data/upstart'
83=== added file 'data/upstart/Makefile.am'
84--- data/upstart/Makefile.am 1970-01-01 00:00:00 +0000
85+++ data/upstart/Makefile.am 2014-02-22 04:22:05 +0000
86@@ -0,0 +1,9 @@
87+
88+xdg_autostartdir = $(pkgdatadir)/upstart/xdg/autostart
89+xdg_autostart_DATA = indicator-application.desktop
90+
91+%.desktop: %.desktop.in
92+ sed -e "s|\@libexecdir\@|$(pkglibexecdir)|" $< > $@
93+
94+EXTRA_DIST = \
95+ indicator-application.desktop.in
96
97=== added file 'data/upstart/indicator-application.desktop.in'
98--- data/upstart/indicator-application.desktop.in 1970-01-01 00:00:00 +0000
99+++ data/upstart/indicator-application.desktop.in 2014-02-22 04:22:05 +0000
100@@ -0,0 +1,8 @@
101+[Desktop Entry]
102+Type=Application
103+Name=Indicator Application
104+Exec=@pkglibexecdir@/indicator-application-service
105+StartupNotify=false
106+Terminal=false
107+OnlyShowIn=Unity;XFCE;
108+Hidden=true
109
110=== modified file 'src/Makefile.am'
111--- src/Makefile.am 2014-01-16 19:31:25 +0000
112+++ src/Makefile.am 2014-02-22 04:22:05 +0000
113@@ -31,7 +31,7 @@
114 # Service
115 ##################################
116
117-libexec_PROGRAMS = indicator-application-service
118+pkglibexec_PROGRAMS = indicator-application-service
119
120 BUILT_SOURCES += \
121 application-service-marshal.h \
122
123=== modified file 'src/application-service.c'
124--- src/application-service.c 2013-01-22 20:32:18 +0000
125+++ src/application-service.c 2014-02-22 04:22:05 +0000
126@@ -21,7 +21,7 @@
127 */
128
129
130-#include "libindicator/indicator-service.h"
131+#include <gio/gio.h>
132 #include "application-service-appstore.h"
133 #include "application-service-watcher.h"
134 #include "dbus-shared.h"
135@@ -32,44 +32,60 @@
136 static ApplicationServiceAppstore * appstore = NULL;
137 /* Interface for applications */
138 static ApplicationServiceWatcher * watcher = NULL;
139-/* The service management interface */
140-static IndicatorService * service = NULL;
141-
142-/* Recieves the disonnection signal from the service
143- object and closes the mainloop. */
144-static void
145-service_disconnected (IndicatorService * service, gpointer data)
146-{
147- g_debug("Service disconnected");
148- if (mainloop != NULL) {
149- g_main_loop_quit(mainloop);
150- }
151- return;
152-}
153-
154+
155+/* Make sure we can set up all our objects before we get the name */
156+static void
157+bus_acquired (GDBusConnection * con, const gchar * name, gpointer user_data)
158+{
159+ g_debug("Bus Acquired, building objects");
160+
161+ /* Building our app store */
162+ appstore = application_service_appstore_new();
163+
164+ /* Adding a watcher for the Apps coming up */
165+ watcher = application_service_watcher_new(appstore);
166+}
167+
168+/* Nice to know, but we're not doing anything special */
169+static void
170+name_acquired (GDBusConnection * con, const gchar * name, gpointer user_data)
171+{
172+ g_debug("Name Acquired");
173+}
174+
175+/* Shouldn't happen under normal usage */
176+static void
177+name_lost (GDBusConnection * con, const gchar * name, gpointer user_data)
178+{
179+ g_warning("Name Lost");
180+ g_main_loop_quit(mainloop);
181+}
182+
183 /* Builds up the core objects and puts us spinning into
184 a main loop. */
185 int
186 main (int argc, char ** argv)
187 {
188- /* Bring us up as a basic indicator service */
189- service = indicator_service_new_version(INDICATOR_APPLICATION_DBUS_ADDR, INDICATOR_APPLICATION_SERVICE_VERSION);
190- g_signal_connect(G_OBJECT(service), INDICATOR_SERVICE_SIGNAL_SHUTDOWN, G_CALLBACK(service_disconnected), NULL);
191-
192- /* Building our app store */
193- appstore = application_service_appstore_new();
194-
195- /* Adding a watcher for the Apps coming up */
196- watcher = application_service_watcher_new(appstore);
197+ guint nameownership = g_bus_own_name(G_BUS_TYPE_SESSION,
198+ INDICATOR_APPLICATION_DBUS_ADDR,
199+ G_BUS_NAME_OWNER_FLAGS_NONE,
200+ bus_acquired,
201+ name_acquired,
202+ name_lost,
203+ NULL, NULL);
204
205 /* Building and executing our main loop */
206 mainloop = g_main_loop_new(NULL, FALSE);
207 g_main_loop_run(mainloop);
208
209+ g_debug("Finishing Main Loop");
210+
211+ g_bus_unown_name(nameownership);
212+
213 /* Unref'ing all the objects */
214+ g_main_loop_unref(mainloop);
215 g_object_unref(G_OBJECT(watcher));
216 g_object_unref(G_OBJECT(appstore));
217- g_object_unref(G_OBJECT(service));
218
219 return 0;
220 }
221
222=== modified file 'src/indicator-application.c'
223--- src/indicator-application.c 2012-04-11 17:22:39 +0000
224+++ src/indicator-application.c 2014-02-22 04:22:05 +0000
225@@ -37,7 +37,6 @@
226 /* Indicator Stuff */
227 #include <libindicator/indicator.h>
228 #include <libindicator/indicator-object.h>
229-#include <libindicator/indicator-service-manager.h>
230 #include <libindicator/indicator-image-helper.h>
231
232 /* Local Stuff */
233@@ -76,13 +75,13 @@
234
235 typedef struct _IndicatorApplicationPrivate IndicatorApplicationPrivate;
236 struct _IndicatorApplicationPrivate {
237- IndicatorServiceManager * sm;
238 GCancellable * service_proxy_cancel;
239 GDBusProxy * service_proxy;
240 GList * applications;
241 GHashTable * theme_dirs;
242 guint disconnect_kill;
243 GCancellable * get_apps_cancel;
244+ guint watch;
245 };
246
247 typedef struct _ApplicationEntry ApplicationEntry;
248@@ -107,9 +106,8 @@
249 static guint get_location (IndicatorObject * io, IndicatorObjectEntry * entry);
250 static void entry_scrolled (IndicatorObject * io, IndicatorObjectEntry * entry, gint delta, IndicatorScrollDirection direction);
251 static void entry_secondary_activate (IndicatorObject * io, IndicatorObjectEntry * entry, guint time, gpointer data);
252-void connection_changed (IndicatorServiceManager * sm, gboolean connected, IndicatorApplication * application);
253-static void connected (IndicatorApplication * application);
254-static void disconnected (IndicatorApplication * application);
255+static void connected (GDBusConnection * con, const gchar * name, const gchar * owner, gpointer user_data);
256+static void disconnected (GDBusConnection * con, const gchar * name, gpointer user_data);
257 static void disconnected_helper (gpointer data, gpointer user_data);
258 static gboolean disconnected_kill (gpointer user_data);
259 static void disconnected_kill_helper (gpointer data, gpointer user_data);
260@@ -159,8 +157,13 @@
261 priv->theme_dirs = NULL;
262 priv->disconnect_kill = 0;
263
264- priv->sm = indicator_service_manager_new_version(INDICATOR_APPLICATION_DBUS_ADDR, INDICATOR_APPLICATION_SERVICE_VERSION);
265- g_signal_connect(G_OBJECT(priv->sm), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(connection_changed), self);
266+ priv->watch = g_bus_watch_name(G_BUS_TYPE_SESSION,
267+ INDICATOR_APPLICATION_DBUS_ADDR,
268+ G_BUS_NAME_WATCHER_FLAGS_NONE,
269+ connected,
270+ disconnected,
271+ self,
272+ NULL);
273
274 priv->applications = NULL;
275
276@@ -191,11 +194,6 @@
277 0);
278 }
279
280- if (priv->sm != NULL) {
281- g_object_unref(priv->sm);
282- priv->sm = NULL;
283- }
284-
285 if (priv->service_proxy != NULL) {
286 g_object_unref(G_OBJECT(priv->service_proxy));
287 priv->service_proxy = NULL;
288@@ -218,6 +216,11 @@
289 priv->theme_dirs = NULL;
290 }
291
292+ if (priv->watch != 0) {
293+ g_bus_unwatch_name(priv->watch);
294+ priv->watch = 0;
295+ }
296+
297 G_OBJECT_CLASS (indicator_application_parent_class)->dispose (object);
298 return;
299 }
300@@ -230,25 +233,14 @@
301 return;
302 }
303
304-/* Responds to connection change event from the service manager and
305- splits it into two. */
306-void
307-connection_changed (IndicatorServiceManager * sm, gboolean connect, IndicatorApplication * application)
308-{
309- g_return_if_fail(IS_INDICATOR_APPLICATION(application));
310- if (connect) {
311- connected(application);
312- } else {
313- disconnected(application);
314- }
315- return;
316-}
317-
318 /* Brings up the connection to a service that has just come onto the
319 bus, or is atleast new to us. */
320-void
321-connected (IndicatorApplication * application)
322+static void
323+connected (GDBusConnection * con, const gchar * name, const gchar * owner, gpointer user_data)
324 {
325+ IndicatorApplication * application = INDICATOR_APPLICATION(user_data);
326+ g_return_if_fail(application != NULL);
327+
328 IndicatorApplicationPrivate * priv = INDICATOR_APPLICATION_GET_PRIVATE(application);
329 g_debug("Connected to Application Indicator Service.");
330
331@@ -323,8 +315,11 @@
332 service so that we can delete it if it doesn't come back.
333 Also, sets up a timeout on comming back. */
334 static void
335-disconnected (IndicatorApplication * application)
336+disconnected (GDBusConnection * con, const gchar * name, gpointer user_data)
337 {
338+ IndicatorApplication * application = INDICATOR_APPLICATION(user_data);
339+ g_return_if_fail(application != NULL);
340+
341 IndicatorApplicationPrivate * priv = INDICATOR_APPLICATION_GET_PRIVATE(application);
342 g_list_foreach(priv->applications, disconnected_helper, application);
343 /* I'll like this to be a little shorter, but it's a bit

Subscribers

People subscribed via source and target branches