Merge lp:~indicator-applet-developers/libindicator/ubuntu into lp:~ubuntu-desktop/libindicator/ubuntu

Proposed by Ted Gould
Status: Merged
Merged at revision: not available
Proposed branch: lp:~indicator-applet-developers/libindicator/ubuntu
Merge into: lp:~ubuntu-desktop/libindicator/ubuntu
Diff against target: 606 lines (+271/-15)
11 files modified
.bzrignore (+4/-0)
Makefile.am.marshal (+45/-0)
configure.ac (+4/-2)
debian/changelog (+8/-0)
libindicator/Makefile.am (+8/-0)
libindicator/indicator-object-marshal.list (+1/-0)
libindicator/indicator-object.c (+52/-2)
libindicator/indicator-object.h (+9/-4)
libindicator/indicator-service-manager.c (+106/-0)
tests/dummy-indicator-signaler.c (+1/-0)
tests/test-loader.c (+33/-7)
To merge this branch: bzr merge lp:~indicator-applet-developers/libindicator/ubuntu
Reviewer Review Type Date Requested Status
Indicator Applet Developers Pending
Review via email: mp+17836@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Ted Gould (ted) wrote :

0.3.1

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.bzrignore'
--- .bzrignore 2009-12-02 21:58:52 +0000
+++ .bzrignore 2010-01-21 19:20:24 +0000
@@ -143,3 +143,7 @@
143tests/service-version-tester143tests/service-version-tester
144tests/service-manager-connect-nostart-tester144tests/service-manager-connect-nostart-tester
145tests/service-manager-nostart-connect145tests/service-manager-nostart-connect
146libindicator/indicator-object-marshal.c
147libindicator/indicator-object-marshal.h
148libindicator/libindicator_la-indicator-object-marshal.lo
149libindicator/stamp-marshal
146150
=== added file 'Makefile.am.marshal'
--- Makefile.am.marshal 1970-01-01 00:00:00 +0000
+++ Makefile.am.marshal 2010-01-21 19:20:25 +0000
@@ -0,0 +1,45 @@
1# Rules for generating marshal files using glib-genmarshal
2#
3# Define:
4# glib_marshal_list = marshal list file
5# glib_marshal_prefix = prefix for marshal functions
6#
7# before including Makefile.am.marshal. You will also need to have
8# the following targets already defined:
9#
10# CLEANFILES
11# DISTCLEANFILES
12# BUILT_SOURCES
13# EXTRA_DIST
14#
15# Author: Emmanuele Bassi <ebassi@linux.intel.com>
16
17marshal_h = $(glib_marshal_list:.list=.h)
18marshal_c = $(glib_marshal_list:.list=.c)
19
20CLEANFILES += stamp-marshal
21DISTCLEANFILES += $(marshal_h) $(marshal_c)
22BUILT_SOURCES += $(marshal_h) $(marshal_c)
23EXTRA_DIST += $(glib_marshal_list)
24
25stamp-marshal: $(glib_marshal_list)
26 $(QUIET_GEN)$(GLIB_GENMARSHAL) \
27 --prefix=$(glib_marshal_prefix) \
28 --header \
29 $(srcdir)/$(glib_marshal_list) > xgen-mh \
30 && (cmp -s xgen-mh $(marshal_h) || cp -f xgen-mh $(marshal_h)) \
31 && rm -f xgen-mh \
32 && echo timestamp > $(@F)
33
34$(marshal_h): stamp-marshal
35 @true
36
37$(marshal_c): $(marshal_h)
38 $(QUIET_GEN)(echo "#include \"$(marshal_h)\"" ; \
39 $(GLIB_GENMARSHAL) \
40 --prefix=$(glib_marshal_prefix) \
41 --body \
42 $(srcdir)/$(glib_marshal_list)) > xgen-mc \
43 && cp xgen-mc $(marshal_c) \
44 && rm -f xgen-mc
45
046
=== modified file 'configure.ac'
--- configure.ac 2009-11-04 19:07:37 +0000
+++ configure.ac 2010-01-21 19:20:25 +0000
@@ -1,10 +1,10 @@
11
2AC_INIT(libindicator, 0.3.0, ted@canonical.com)2AC_INIT(libindicator, 0.3.1, ted@canonical.com)
33
4AC_PREREQ(2.53)4AC_PREREQ(2.53)
55
6AM_CONFIG_HEADER(config.h)6AM_CONFIG_HEADER(config.h)
7AM_INIT_AUTOMAKE(libindicator, 0.3.0)7AM_INIT_AUTOMAKE(libindicator, 0.3.1)
88
9AM_MAINTAINER_MODE9AM_MAINTAINER_MODE
10m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES])10m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES])
@@ -15,6 +15,8 @@
15AC_STDC_HEADERS15AC_STDC_HEADERS
16AC_PROG_LIBTOOL16AC_PROG_LIBTOOL
1717
18AC_PATH_PROG([GLIB_GENMARSHAL], [glib-genmarshal])
19
18AC_SUBST(VERSION)20AC_SUBST(VERSION)
19AC_CONFIG_MACRO_DIR([m4])21AC_CONFIG_MACRO_DIR([m4])
2022
2123
=== modified file 'debian/changelog'
--- debian/changelog 2009-12-10 17:18:01 +0000
+++ debian/changelog 2010-01-21 19:20:25 +0000
@@ -1,3 +1,11 @@
1libindicator (0.3.1-0ubuntu1~ppa1) karmic; urgency=low
2
3 * Upstream release 0.3.1
4 * Adding in entry ordering.
5 * Adding in the code to restart services
6
7 -- Ted Gould <ted@ubuntu.com> Thu, 21 Jan 2010 13:15:07 -0600
8
1libindicator (0.3.0-0ubuntu1) lucid; urgency=low9libindicator (0.3.0-0ubuntu1) lucid; urgency=low
210
3 * debian/control:11 * debian/control:
412
=== modified file 'libindicator/Makefile.am'
--- libindicator/Makefile.am 2009-12-02 19:56:44 +0000
+++ libindicator/Makefile.am 2010-01-21 19:20:25 +0000
@@ -1,8 +1,11 @@
1BUILT_SOURCES = 1BUILT_SOURCES =
2CLEANFILES = 2CLEANFILES =
3DISTCLEANFILES =
3EXTRA_DIST = \4EXTRA_DIST = \
4 indicator.pc.in5 indicator.pc.in
56
7include $(top_srcdir)/Makefile.am.marshal
8
6libindicatorincludedir=$(includedir)/libindicator-0.3/libindicator9libindicatorincludedir=$(includedir)/libindicator-0.3/libindicator
710
8indicator_headers = \11indicator_headers = \
@@ -21,6 +24,8 @@
21 $(indicator_headers) \24 $(indicator_headers) \
22 dbus-shared.h \25 dbus-shared.h \
23 indicator-object.c \26 indicator-object.c \
27 indicator-object-marshal.h \
28 indicator-object-marshal.c \
24 indicator-service.c \29 indicator-service.c \
25 indicator-service-manager.c30 indicator-service-manager.c
2631
@@ -35,6 +40,9 @@
35pkgconfig_DATA = indicator.pc40pkgconfig_DATA = indicator.pc
36pkgconfigdir = $(libdir)/pkgconfig41pkgconfigdir = $(libdir)/pkgconfig
3742
43glib_marshal_list = indicator-object-marshal.list
44glib_marshal_prefix = _indicator_object_marshal
45
38##################################46##################################
39# DBus Specs47# DBus Specs
40##################################48##################################
4149
=== added file 'libindicator/indicator-object-marshal.list'
--- libindicator/indicator-object-marshal.list 1970-01-01 00:00:00 +0000
+++ libindicator/indicator-object-marshal.list 2010-01-21 19:20:25 +0000
@@ -0,0 +1,1 @@
1VOID: POINTER, UINT, UINT
02
=== modified file 'libindicator/indicator-object.c'
--- libindicator/indicator-object.c 2009-11-05 16:56:41 +0000
+++ libindicator/indicator-object.c 2010-01-21 19:20:25 +0000
@@ -27,6 +27,7 @@
2727
28#include "indicator.h"28#include "indicator.h"
29#include "indicator-object.h"29#include "indicator-object.h"
30#include "indicator-object-marshal.h"
3031
31/**32/**
32 IndicatorObjectPrivate:33 IndicatorObjectPrivate:
@@ -54,6 +55,7 @@
54enum {55enum {
55 ENTRY_ADDED,56 ENTRY_ADDED,
56 ENTRY_REMOVED,57 ENTRY_REMOVED,
58 ENTRY_MOVED,
57 LAST_SIGNAL59 LAST_SIGNAL
58};60};
5961
@@ -86,11 +88,14 @@
86 klass->get_image = NULL;88 klass->get_image = NULL;
8789
88 klass->get_entries = get_entries_default;90 klass->get_entries = get_entries_default;
91 klass->get_location = NULL;
8992
90 /**93 /**
91 IndicatorObject::entry-added:94 IndicatorObject::entry-added:
92 @arg0: The #IndicatorObject object95 @arg0: The #IndicatorObject object
93 96 @arg1: A pointer to the #IndicatorObjectEntry that
97 is being added.
98
94 Signaled when a new entry is added and should99 Signaled when a new entry is added and should
95 be shown by the person using this object.100 be shown by the person using this object.
96 */101 */
@@ -105,7 +110,9 @@
105 /**110 /**
106 IndicatorObject::entry-removed:111 IndicatorObject::entry-removed:
107 @arg0: The #IndicatorObject object112 @arg0: The #IndicatorObject object
108 113 @arg1: A pointer to the #IndicatorObjectEntry that
114 is being removed.
115
109 Signaled when an entry is removed and should116 Signaled when an entry is removed and should
110 be removed by the person using this object.117 be removed by the person using this object.
111 */118 */
@@ -116,6 +123,24 @@
116 NULL, NULL,123 NULL, NULL,
117 g_cclosure_marshal_VOID__POINTER,124 g_cclosure_marshal_VOID__POINTER,
118 G_TYPE_NONE, 1, G_TYPE_POINTER, G_TYPE_NONE);125 G_TYPE_NONE, 1, G_TYPE_POINTER, G_TYPE_NONE);
126 /**
127 IndicatorObject::entry-moved:
128 @arg0: The #IndicatorObject object
129 @arg1: A pointer to the #IndicatorObjectEntry that
130 is being moved.
131 @arg2: The old location of the entry
132 @arg3: The new location of the entry
133
134 When the order of the entries change, then this signal
135 is sent to tell the new location.
136 */
137 signals[ENTRY_MOVED] = g_signal_new (INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED,
138 G_TYPE_FROM_CLASS(klass),
139 G_SIGNAL_RUN_LAST,
140 G_STRUCT_OFFSET (IndicatorObjectClass, entry_moved),
141 NULL, NULL,
142 _indicator_object_marshal_VOID__POINTER_UINT_UINT,
143 G_TYPE_NONE, 3, G_TYPE_POINTER, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_NONE);
119144
120 return;145 return;
121}146}
@@ -342,3 +367,28 @@
342 g_error("No get_entries function on object. It must have been deleted?!?!");367 g_error("No get_entries function on object. It must have been deleted?!?!");
343 return NULL;368 return NULL;
344}369}
370
371/**
372 indicator_object_get_location:
373 @io: #IndicatorObject to query
374 @entry: The #IndicatorObjectEntry to look for.
375
376 This function looks on the class for the object and calls
377 it's #IndicatorObjectClass::get_location function. If the
378 function doesn't exist it returns zero.
379
380 Return value: Location of the @entry in the display or
381 zero if no location is specified.
382*/
383guint
384indicator_object_get_location (IndicatorObject * io, IndicatorObjectEntry * entry)
385{
386 g_return_val_if_fail(INDICATOR_IS_OBJECT(io), 0);
387 IndicatorObjectClass * class = INDICATOR_OBJECT_GET_CLASS(io);
388
389 if (class->get_location) {
390 return class->get_location(io, entry);
391 }
392
393 return 0;
394}
345395
=== modified file 'libindicator/indicator-object.h'
--- libindicator/indicator-object.h 2009-11-04 17:24:25 +0000
+++ libindicator/indicator-object.h 2010-01-21 19:20:25 +0000
@@ -40,6 +40,8 @@
40#define INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED_ID (g_signal_lookup(INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, INDICATOR_OBJECT_TYPE))40#define INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED_ID (g_signal_lookup(INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, INDICATOR_OBJECT_TYPE))
41#define INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED "entry-removed"41#define INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED "entry-removed"
42#define INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED_ID (g_signal_lookup(INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, INDICATOR_OBJECT_TYPE))42#define INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED_ID (g_signal_lookup(INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, INDICATOR_OBJECT_TYPE))
43#define INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED "entry-moved"
44#define INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED_ID (g_signal_lookup(INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, INDICATOR_OBJECT_TYPE))
4345
44typedef struct _IndicatorObject IndicatorObject;46typedef struct _IndicatorObject IndicatorObject;
45typedef struct _IndicatorObjectClass IndicatorObjectClass;47typedef struct _IndicatorObjectClass IndicatorObjectClass;
@@ -62,12 +64,14 @@
62 a #GList of #IndicatorObjectEntries. The list should be64 a #GList of #IndicatorObjectEntries. The list should be
63 under the ownership of the caller but the entires will65 under the ownership of the caller but the entires will
64 not be.66 not be.
67 @get_location: Returns the location that a particular entry
68 should be placed in. This is really only relevant for
69 indicators that have more than one entry.
65 @entry_added: Slot for #IndicatorObject::entry-added70 @entry_added: Slot for #IndicatorObject::entry-added
66 @entry_removed: Slot for #IndicatorObject::entry-removed71 @entry_removed: Slot for #IndicatorObject::entry-removed
72 @entry_moved: Slot for #IndicatorObject::entry-moved
67 @indicator_object_reserved_1: Reserved for future use73 @indicator_object_reserved_1: Reserved for future use
68 @indicator_object_reserved_2: Reserved for future use74 @indicator_object_reserved_2: Reserved for future use
69 @indicator_object_reserved_3: Reserved for future use
70 @indicator_object_reserved_4: Reserved for future use
71*/75*/
72struct _IndicatorObjectClass {76struct _IndicatorObjectClass {
73 GObjectClass parent_class;77 GObjectClass parent_class;
@@ -78,16 +82,16 @@
78 GtkMenu * (*get_menu) (IndicatorObject * io);82 GtkMenu * (*get_menu) (IndicatorObject * io);
7983
80 GList * (*get_entries) (IndicatorObject * io);84 GList * (*get_entries) (IndicatorObject * io);
85 guint (*get_location) (IndicatorObject * io, IndicatorObjectEntry * entry);
8186
82 /* Signals */87 /* Signals */
83 void (*entry_added) (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer user_data);88 void (*entry_added) (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer user_data);
84 void (*entry_removed) (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer user_data);89 void (*entry_removed) (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer user_data);
90 void (*entry_moved) (IndicatorObject * io, IndicatorObjectEntry * entry, guint old_pos, guint new_pos, gpointer user_data);
8591
86 /* Reserved */92 /* Reserved */
87 void (* indicator_object_reserved_1) (void);93 void (* indicator_object_reserved_1) (void);
88 void (* indicator_object_reserved_2) (void);94 void (* indicator_object_reserved_2) (void);
89 void (* indicator_object_reserved_3) (void);
90 void (* indicator_object_reserved_4) (void);
91};95};
9296
93/**97/**
@@ -117,6 +121,7 @@
117IndicatorObject * indicator_object_new_from_file (const gchar * file);121IndicatorObject * indicator_object_new_from_file (const gchar * file);
118122
119GList * indicator_object_get_entries (IndicatorObject * io);123GList * indicator_object_get_entries (IndicatorObject * io);
124guint indicator_object_get_location (IndicatorObject * io, IndicatorObjectEntry * entry);
120125
121G_END_DECLS126G_END_DECLS
122127
123128
=== modified file 'libindicator/indicator-service-manager.c'
--- libindicator/indicator-service-manager.c 2009-12-07 20:22:35 +0000
+++ libindicator/indicator-service-manager.c 2010-01-21 19:20:25 +0000
@@ -25,6 +25,8 @@
25#include "config.h"25#include "config.h"
26#endif26#endif
2727
28#include <stdlib.h>
29
28#include <dbus/dbus-glib-bindings.h>30#include <dbus/dbus-glib-bindings.h>
29#include <dbus/dbus-glib-lowlevel.h>31#include <dbus/dbus-glib-lowlevel.h>
3032
@@ -41,6 +43,7 @@
41 @connected: Whether we're connected to the service or not.43 @connected: Whether we're connected to the service or not.
42 @this_service_version: The version of the service that we're looking for.44 @this_service_version: The version of the service that we're looking for.
43 @bus: A reference to the bus so we don't have to keep getting it.45 @bus: A reference to the bus so we don't have to keep getting it.
46 @restart_count: The number of times we've restarted this service.
44*/47*/
45typedef struct _IndicatorServiceManagerPrivate IndicatorServiceManagerPrivate;48typedef struct _IndicatorServiceManagerPrivate IndicatorServiceManagerPrivate;
46struct _IndicatorServiceManagerPrivate {49struct _IndicatorServiceManagerPrivate {
@@ -50,6 +53,8 @@
50 gboolean connected;53 gboolean connected;
51 guint this_service_version;54 guint this_service_version;
52 DBusGConnection * bus;55 DBusGConnection * bus;
56 guint restart_count;
57 gint restart_source;
53};58};
5459
55/* Signals Stuff */60/* Signals Stuff */
@@ -60,6 +65,13 @@
6065
61static guint signals[LAST_SIGNAL] = { 0 };66static guint signals[LAST_SIGNAL] = { 0 };
6267
68/* If this env variable is set, we don't restart */
69#define TIMEOUT_ENV_NAME "INDICATOR_SERVICE_RESTART_DISABLE"
70#define TIMEOUT_MULTIPLIER 100 /* In ms */
71/* What to reset the restart_count to if we know that we're
72 in a recoverable error condition, but waiting a little bit
73 will probably make things better. 5 ~= 3 sec. */
74#define TIMEOUT_A_LITTLE_WHILE 5
6375
64/* Properties */76/* Properties */
65/* Enum for the properties so that they can be quickly77/* Enum for the properties so that they can be quickly
@@ -86,7 +98,9 @@
86/* Prototypes */98/* Prototypes */
87static void set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec);99static void set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec);
88static void get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec);100static void get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec);
101static void service_proxy_destroyed (DBusGProxy * proxy, gpointer user_data);
89static void start_service (IndicatorServiceManager * service);102static void start_service (IndicatorServiceManager * service);
103static void start_service_again (IndicatorServiceManager * manager);
90104
91G_DEFINE_TYPE (IndicatorServiceManager, indicator_service_manager, G_TYPE_OBJECT);105G_DEFINE_TYPE (IndicatorServiceManager, indicator_service_manager, G_TYPE_OBJECT);
92106
@@ -154,6 +168,8 @@
154 priv->connected = FALSE;168 priv->connected = FALSE;
155 priv->this_service_version = 0;169 priv->this_service_version = 0;
156 priv->bus = NULL;170 priv->bus = NULL;
171 priv->restart_count = 0;
172 priv->restart_source = 0;
157173
158 /* Start talkin' dbus */174 /* Start talkin' dbus */
159 GError * error = NULL;175 GError * error = NULL;
@@ -187,6 +203,13 @@
187{203{
188 IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(object);204 IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(object);
189205
206 /* Removing the idle task to restart if it exists. */
207 if (priv->restart_source != 0) {
208 g_source_remove(priv->restart_source);
209 }
210 /* Block any restart calls */
211 priv->restart_source = -1;
212
190 /* If we were connected we need to make sure to213 /* If we were connected we need to make sure to
191 tell people that it's no longer the case. */214 tell people that it's no longer the case. */
192 if (priv->connected) {215 if (priv->connected) {
@@ -309,18 +332,33 @@
309 if (error != NULL) {332 if (error != NULL) {
310 g_warning("Unable to set watch on '%s': '%s'", priv->name, error->message);333 g_warning("Unable to set watch on '%s': '%s'", priv->name, error->message);
311 g_error_free(error);334 g_error_free(error);
335 start_service_again(INDICATOR_SERVICE_MANAGER(user_data));
312 return;336 return;
313 }337 }
314338
339 /* We've done it, now let's stop counting. */
340 /* Note: we're not checking versions. Because, the hope is that
341 the guy holding the name we want with the wrong version will
342 drop and we can start another service quickly. */
343 priv->restart_count = 0;
344
315 if (service_api_version != INDICATOR_SERVICE_VERSION) {345 if (service_api_version != INDICATOR_SERVICE_VERSION) {
316 g_warning("Service is using a different version of the service interface. Expecting %d and got %d.", INDICATOR_SERVICE_VERSION, service_api_version);346 g_warning("Service is using a different version of the service interface. Expecting %d and got %d.", INDICATOR_SERVICE_VERSION, service_api_version);
317 dbus_g_proxy_call_no_reply(priv->service_proxy, "UnWatch", G_TYPE_INVALID);347 dbus_g_proxy_call_no_reply(priv->service_proxy, "UnWatch", G_TYPE_INVALID);
348
349 /* Let's make us wait a little while, then try again */
350 priv->restart_count = TIMEOUT_A_LITTLE_WHILE;
351 start_service_again(INDICATOR_SERVICE_MANAGER(user_data));
318 return;352 return;
319 }353 }
320354
321 if (this_service_version != priv->this_service_version) {355 if (this_service_version != priv->this_service_version) {
322 g_warning("Service is using a different API version than the manager. Expecting %d and got %d.", priv->this_service_version, this_service_version);356 g_warning("Service is using a different API version than the manager. Expecting %d and got %d.", priv->this_service_version, this_service_version);
323 dbus_g_proxy_call_no_reply(priv->service_proxy, "UnWatch", G_TYPE_INVALID);357 dbus_g_proxy_call_no_reply(priv->service_proxy, "UnWatch", G_TYPE_INVALID);
358
359 /* Let's make us wait a little while, then try again */
360 priv->restart_count = TIMEOUT_A_LITTLE_WHILE;
361 start_service_again(INDICATOR_SERVICE_MANAGER(user_data));
324 return;362 return;
325 }363 }
326364
@@ -343,11 +381,13 @@
343381
344 if (error != NULL) {382 if (error != NULL) {
345 g_warning("Unable to start service '%s': %s", priv->name, error->message);383 g_warning("Unable to start service '%s': %s", priv->name, error->message);
384 start_service_again(INDICATOR_SERVICE_MANAGER(user_data));
346 return;385 return;
347 }386 }
348387
349 if (status != DBUS_START_REPLY_SUCCESS && status != DBUS_START_REPLY_ALREADY_RUNNING) {388 if (status != DBUS_START_REPLY_SUCCESS && status != DBUS_START_REPLY_ALREADY_RUNNING) {
350 g_warning("Status of starting the process '%s' was an error: %d", priv->name, status);389 g_warning("Status of starting the process '%s' was an error: %d", priv->name, status);
390 start_service_again(INDICATOR_SERVICE_MANAGER(user_data));
351 return;391 return;
352 }392 }
353393
@@ -358,6 +398,7 @@
358 INDICATOR_SERVICE_INTERFACE,398 INDICATOR_SERVICE_INTERFACE,
359 &error);399 &error);
360 g_object_add_weak_pointer(G_OBJECT(priv->service_proxy), (gpointer *)&(priv->service_proxy));400 g_object_add_weak_pointer(G_OBJECT(priv->service_proxy), (gpointer *)&(priv->service_proxy));
401 g_signal_connect(G_OBJECT(priv->service_proxy), "destroy", G_CALLBACK(service_proxy_destroyed), user_data);
361402
362 org_ayatana_indicator_service_watch_async(priv->service_proxy,403 org_ayatana_indicator_service_watch_async(priv->service_proxy,
363 watch_cb,404 watch_cb,
@@ -379,6 +420,11 @@
379 g_return_if_fail(priv->dbus_proxy != NULL);420 g_return_if_fail(priv->dbus_proxy != NULL);
380 g_return_if_fail(priv->name != NULL);421 g_return_if_fail(priv->name != NULL);
381422
423 if (priv->service_proxy != NULL) {
424 g_object_unref(priv->service_proxy);
425 priv->service_proxy = NULL;
426 }
427
382 /* Check to see if we can get a proxy to it first. */428 /* Check to see if we can get a proxy to it first. */
383 priv->service_proxy = dbus_g_proxy_new_for_name_owner(priv->bus,429 priv->service_proxy = dbus_g_proxy_new_for_name_owner(priv->bus,
384 priv->name,430 priv->name,
@@ -396,6 +442,7 @@
396 service);442 service);
397 } else {443 } else {
398 g_object_add_weak_pointer(G_OBJECT(priv->service_proxy), (gpointer *)&(priv->service_proxy));444 g_object_add_weak_pointer(G_OBJECT(priv->service_proxy), (gpointer *)&(priv->service_proxy));
445 g_signal_connect(G_OBJECT(priv->service_proxy), "destroy", G_CALLBACK(service_proxy_destroyed), service);
399446
400 /* If we got a proxy just because we're good people then447 /* If we got a proxy just because we're good people then
401 we need to call watch on it just like 'start_service_cb'448 we need to call watch on it just like 'start_service_cb'
@@ -408,6 +455,65 @@
408 return;455 return;
409}456}
410457
458/* Responds to the destory event of the proxy and starts
459 setting up to restart the service. */
460static void
461service_proxy_destroyed (DBusGProxy * proxy, gpointer user_data)
462{
463 IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(user_data);
464 if (priv->connected) {
465 priv->connected = FALSE;
466 g_signal_emit(G_OBJECT(user_data), signals[CONNECTION_CHANGE], 0, FALSE, TRUE);
467 }
468 return start_service_again(INDICATOR_SERVICE_MANAGER(user_data));
469}
470
471/* The callback that starts the service for real after
472 the timeout as determined in 'start_service_again'.
473 This could be in the idle or a timer. */
474static gboolean
475start_service_again_cb (gpointer data)
476{
477 IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(data);
478 priv->restart_count++;
479 start_service(INDICATOR_SERVICE_MANAGER(data));
480 priv->restart_source = 0;
481 return FALSE;
482}
483
484/* This function tries to start a new service, perhaps
485 after a timeout that it determines. The real issue
486 here is that it throttles restarting if we're not
487 being successful. */
488static void
489start_service_again (IndicatorServiceManager * manager)
490{
491 IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(manager);
492
493 /* If we've already got a restart source running then
494 let's not do this again. */
495 if (priv->restart_source != 0) {
496 return;
497 }
498
499 /* Allow the restarting to be disabled */
500 if (g_getenv(TIMEOUT_ENV_NAME)) {
501 return;
502 }
503
504 if (priv->restart_count == 0) {
505 /* First time, do it in idle */
506 g_idle_add(start_service_again_cb, manager);
507 } else {
508 /* Not our first time 'round the block. Let's slow this down. */
509 if (priv->restart_count > 16)
510 priv->restart_count = 16; /* Not more than 1024x */
511 priv->restart_source = g_timeout_add((1 << priv->restart_count) * TIMEOUT_MULTIPLIER, start_service_again_cb, manager);
512 }
513
514 return;
515}
516
411/* API */517/* API */
412518
413/**519/**
414520
=== modified file 'tests/dummy-indicator-signaler.c'
--- tests/dummy-indicator-signaler.c 2009-11-04 17:14:22 +0000
+++ tests/dummy-indicator-signaler.c 2010-01-21 19:20:25 +0000
@@ -81,6 +81,7 @@
8181
82 g_signal_emit(G_OBJECT(self), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED_ID, 0, GUINT_TO_POINTER(5), TRUE);82 g_signal_emit(G_OBJECT(self), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED_ID, 0, GUINT_TO_POINTER(5), TRUE);
83 g_signal_emit(G_OBJECT(self), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED_ID, 0, GUINT_TO_POINTER(5), TRUE);83 g_signal_emit(G_OBJECT(self), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED_ID, 0, GUINT_TO_POINTER(5), TRUE);
84 g_signal_emit(G_OBJECT(self), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED_ID, 0, GUINT_TO_POINTER(5), 0, 1, TRUE);
8485
85 return FALSE; /* Don't queue again */86 return FALSE; /* Don't queue again */
86}87}
8788
=== modified file 'tests/test-loader.c'
--- tests/test-loader.c 2009-11-04 17:14:22 +0000
+++ tests/test-loader.c 2010-01-21 19:20:25 +0000
@@ -12,15 +12,22 @@
12}12}
1313
14void14void
15entry_move_cb (IndicatorObject * io, IndicatorObjectEntry * entry, gint old, gint new, gpointer data)
16{
17 return entry_change_cb(io, entry, data);
18}
19
20void
15test_loader_filename_dummy_signaler (void)21test_loader_filename_dummy_signaler (void)
16{22{
17 IndicatorObject * object = indicator_object_new_from_file(BUILD_DIR "/.libs/libdummy-indicator-signaler.so");23 IndicatorObject * object = indicator_object_new_from_file(BUILD_DIR "/.libs/libdummy-indicator-signaler.so");
18 g_assert(object != NULL);24 g_assert(object != NULL);
1925
20 gpointer added_value = NULL, removed_value = NULL;26 gpointer added_value = NULL, removed_value = NULL, moved_value = NULL;
2127
22 g_signal_connect(G_OBJECT(object), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_change_cb), &added_value);28 g_signal_connect(G_OBJECT(object), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_change_cb), &added_value);
23 g_signal_connect(G_OBJECT(object), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_change_cb), &removed_value);29 g_signal_connect(G_OBJECT(object), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_change_cb), &removed_value);
30 g_signal_connect(G_OBJECT(object), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, G_CALLBACK(entry_move_cb), &moved_value);
2431
25 GList * list = indicator_object_get_entries(object);32 GList * list = indicator_object_get_entries(object);
26 g_assert(list != NULL);33 g_assert(list != NULL);
@@ -32,12 +39,30 @@
3239
33 g_assert(GPOINTER_TO_UINT(added_value) == 5);40 g_assert(GPOINTER_TO_UINT(added_value) == 5);
34 g_assert(GPOINTER_TO_UINT(removed_value) == 5);41 g_assert(GPOINTER_TO_UINT(removed_value) == 5);
3542 g_assert(GPOINTER_TO_UINT(moved_value) == 5);
36 g_object_unref(object);43
3744 g_object_unref(object);
38 return;45
39}46 return;
4047}
48
49void
50test_loader_filename_dummy_simple_location (void)
51{
52 IndicatorObject * object = indicator_object_new_from_file(BUILD_DIR "/.libs/libdummy-indicator-simple.so");
53 g_assert(object != NULL);
54
55 GList * entries = indicator_object_get_entries(object);
56 g_assert(entries != NULL);
57 g_assert(g_list_length(entries) == 1);
58
59 g_assert(indicator_object_get_location(object, (IndicatorObjectEntry *)entries->data) == 0);
60 g_assert(indicator_object_get_location(object, NULL) == 0);
61
62 g_object_unref(object);
63
64 return;
65}
4166
42void67void
43test_loader_filename_dummy_simple_accessors (void)68test_loader_filename_dummy_simple_accessors (void)
@@ -125,6 +150,7 @@
125 g_test_add_func ("/libindicator/loader/dummy/blank_load", test_loader_filename_dummy_null);150 g_test_add_func ("/libindicator/loader/dummy/blank_load", test_loader_filename_dummy_null);
126 g_test_add_func ("/libindicator/loader/dummy/simple_load", test_loader_filename_dummy_simple);151 g_test_add_func ("/libindicator/loader/dummy/simple_load", test_loader_filename_dummy_simple);
127 g_test_add_func ("/libindicator/loader/dummy/simple_accessors", test_loader_filename_dummy_simple_accessors);152 g_test_add_func ("/libindicator/loader/dummy/simple_accessors", test_loader_filename_dummy_simple_accessors);
153 g_test_add_func ("/libindicator/loader/dummy/simple_location", test_loader_filename_dummy_simple_location);
128 g_test_add_func ("/libindicator/loader/dummy/signaler", test_loader_filename_dummy_signaler);154 g_test_add_func ("/libindicator/loader/dummy/signaler", test_loader_filename_dummy_signaler);
129155
130 return;156 return;

Subscribers

People subscribed via source and target branches

to all changes: