aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2013-04-18 11:13:03 -0500
committerCharles Kerr <charles.kerr@canonical.com>2013-04-18 11:13:03 -0500
commit67218e58889b101ceb5a50bcb40c37045fb2855d (patch)
treeba37f8f02116e8b2aefa23bf2be0509d53367e6a
parentd79745bdb2e9bbd02e162a5209de9f227d1dbbc3 (diff)
downloadayatana-indicator-session-67218e58889b101ceb5a50bcb40c37045fb2855d.tar.gz
ayatana-indicator-session-67218e58889b101ceb5a50bcb40c37045fb2855d.tar.bz2
ayatana-indicator-session-67218e58889b101ceb5a50bcb40c37045fb2855d.zip
indicator-session-service should exit when it loses ownership of its name on the bus.
-rw-r--r--src/main.c9
-rw-r--r--src/service.c23
-rw-r--r--src/service.h7
3 files changed, 38 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index 17b50b4..4511fce 100644
--- a/src/main.c
+++ b/src/main.c
@@ -60,6 +60,13 @@ parse_command_line (int * argc, char *** argv)
****
***/
+static void
+on_name_lost (gpointer instance, gpointer loop)
+{
+ g_debug ("exiting: service couldn't acquire or lost ownership of busname");
+ g_main_loop_quit ((GMainLoop*)loop);
+}
+
int
main (int argc, char ** argv)
{
@@ -76,6 +83,8 @@ main (int argc, char ** argv)
/* run */
service = indicator_session_service_new (replace);
loop = g_main_loop_new (NULL, FALSE);
+ g_signal_connect (service, INDICATOR_SESSION_SERVICE_SIGNAL_NAME_LOST,
+ G_CALLBACK(on_name_lost), loop);
g_main_loop_run (loop);
/* cleanup */
diff --git a/src/service.c b/src/service.c
index 2a10290..bcd88ff 100644
--- a/src/service.c
+++ b/src/service.c
@@ -37,6 +37,15 @@ G_DEFINE_TYPE (IndicatorSessionService,
indicator_session_service,
G_TYPE_OBJECT)
+/* signals enum */
+enum
+{
+ NAME_LOST,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
enum
{
PROP_0,
@@ -910,9 +919,13 @@ on_name_lost (GDBusConnection * connection G_GNUC_UNUSED,
const gchar * name,
gpointer gself)
{
+ IndicatorSessionService * self = INDICATOR_SESSION_SERVICE (gself);
+
g_debug ("%s %s name lost %s", G_STRLOC, G_STRFUNC, name);
- unexport (INDICATOR_SESSION_SERVICE (gself));
+ unexport (self);
+
+ g_signal_emit (self, signals[NAME_LOST], 0, NULL);
}
/***
@@ -1133,6 +1146,14 @@ indicator_session_service_class_init (IndicatorSessionServiceClass * klass)
g_type_class_add_private (klass, sizeof (IndicatorSessionServicePrivate));
+ signals[NAME_LOST] = g_signal_new (INDICATOR_SESSION_SERVICE_SIGNAL_NAME_LOST,
+ G_TYPE_FROM_CLASS(klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (IndicatorSessionServiceClass, name_lost),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
properties[PROP_0] = NULL;
properties[PROP_REPLACE] = g_param_spec_boolean ("replace",
diff --git a/src/service.h b/src/service.h
index 2a78855..3fad6bf 100644
--- a/src/service.h
+++ b/src/service.h
@@ -36,6 +36,9 @@ typedef struct _IndicatorSessionService IndicatorSessionService;
typedef struct _IndicatorSessionServiceClass IndicatorSessionServiceClass;
typedef struct _IndicatorSessionServicePrivate IndicatorSessionServicePrivate;
+/* signal keys */
+#define INDICATOR_SESSION_SERVICE_SIGNAL_NAME_LOST "name-lost"
+
/**
* The Indicator Session Service.
*/
@@ -49,6 +52,10 @@ struct _IndicatorSessionService
struct _IndicatorSessionServiceClass
{
GObjectClass parent_class;
+
+ /* signals */
+
+ void (* name_lost)(IndicatorSessionService * self);
};
/***