From 7d97429147d87f2fb8b1d7861ee31c55fcbb75b1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 14 Feb 2014 15:10:24 -0600 Subject: Respawn limit and better rules --- data/indicator-application.conf.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/data/indicator-application.conf.in b/data/indicator-application.conf.in index ddc803c..15a318d 100644 --- a/data/indicator-application.conf.in +++ b/data/indicator-application.conf.in @@ -3,12 +3,13 @@ description "Indicator Application Service" # NOTE: Limiting only to Unity 7 right now as it's still using # dbusmenu. That can be lifted after it is ported to GMenu -start on (indicators-loaded or indicator-services-start) and xsession SESSION=ubuntu +start on indicator-services-start and xsession SESSION=ubuntu stop on desktop-end or indicator-services-end emits appindicators-start appindicators-end respawn +respawn limit 2 10 exec @libexecdir@/indicator-application-service -- cgit v1.2.3 From cbe78c0c70ec10404da6ec8de61058aa56ae8fd2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 14 Feb 2014 15:24:24 -0600 Subject: Fixing the autostart file --- data/indicator-application.desktop.in | 3 --- 1 file changed, 3 deletions(-) diff --git a/data/indicator-application.desktop.in b/data/indicator-application.desktop.in index 61d3c4d..7a5073b 100644 --- a/data/indicator-application.desktop.in +++ b/data/indicator-application.desktop.in @@ -2,8 +2,5 @@ Type=Application Name=Indicator Application Exec=@libexecdir@/indicator-application-service -NotShowIn=Unity; -NoDisplay=true StartupNotify=false Terminal=false - -- cgit v1.2.3 From 4d7566c239afe3c47228d0c249e6377e8d7d5f53 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 19 Feb 2014 21:10:15 -0600 Subject: Make sure this is for Unity and XFCE --- data/indicator-application.desktop.in | 1 + 1 file changed, 1 insertion(+) diff --git a/data/indicator-application.desktop.in b/data/indicator-application.desktop.in index 7a5073b..2783781 100644 --- a/data/indicator-application.desktop.in +++ b/data/indicator-application.desktop.in @@ -4,3 +4,4 @@ Name=Indicator Application Exec=@libexecdir@/indicator-application-service StartupNotify=false Terminal=false +OnlyShowIn=Unity;XFCE; -- cgit v1.2.3 From c6a36f4305d52fb74d9990174fb9c455c01f4014 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 19 Feb 2014 21:14:06 -0600 Subject: Adding a desktop file for the Upstart override --- data/indicator-application.upstart.desktop.in | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 data/indicator-application.upstart.desktop.in diff --git a/data/indicator-application.upstart.desktop.in b/data/indicator-application.upstart.desktop.in new file mode 100644 index 0000000..ee1c4a1 --- /dev/null +++ b/data/indicator-application.upstart.desktop.in @@ -0,0 +1,8 @@ +[Desktop Entry] +Type=Application +Name=Indicator Application +Exec=@libexecdir@/indicator-application-service +StartupNotify=false +Terminal=false +OnlyShowIn=Unity;XFCE; +Hidden=true -- cgit v1.2.3 From f179a2c7f91497854fa787eb0c65e547a791f038 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 19 Feb 2014 21:27:31 -0600 Subject: Build the upstart desktop file in its own directory --- configure.ac | 1 + data/Makefile.am | 2 ++ data/indicator-application.upstart.desktop.in | 8 -------- data/upstart/Makefile.am | 9 +++++++++ data/upstart/indicator-application.desktop.in | 8 ++++++++ 5 files changed, 20 insertions(+), 8 deletions(-) delete mode 100644 data/indicator-application.upstart.desktop.in create mode 100644 data/upstart/Makefile.am create mode 100644 data/upstart/indicator-application.desktop.in diff --git a/configure.ac b/configure.ac index 2d1ccc0..d49a986 100644 --- a/configure.ac +++ b/configure.ac @@ -96,6 +96,7 @@ AC_OUTPUT([ Makefile src/Makefile data/Makefile +data/upstart/Makefile tests/Makefile ]) diff --git a/data/Makefile.am b/data/Makefile.am index 77ec71d..6f46c2e 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -1,4 +1,6 @@ +SUBDIRS = upstart + upstart_jobsdir = $(datadir)/upstart/sessions/ upstart_jobs_DATA = indicator-application.conf diff --git a/data/indicator-application.upstart.desktop.in b/data/indicator-application.upstart.desktop.in deleted file mode 100644 index ee1c4a1..0000000 --- a/data/indicator-application.upstart.desktop.in +++ /dev/null @@ -1,8 +0,0 @@ -[Desktop Entry] -Type=Application -Name=Indicator Application -Exec=@libexecdir@/indicator-application-service -StartupNotify=false -Terminal=false -OnlyShowIn=Unity;XFCE; -Hidden=true diff --git a/data/upstart/Makefile.am b/data/upstart/Makefile.am new file mode 100644 index 0000000..a384c75 --- /dev/null +++ b/data/upstart/Makefile.am @@ -0,0 +1,9 @@ + +xdg_autostartdir = $(datadir)/upstart/xdg/autostart +xdg_autostart_DATA = indicator-application.desktop + +%.desktop: %.desktop.in + sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@ + +EXTRA_DIST = \ + indicator-application.desktop.in diff --git a/data/upstart/indicator-application.desktop.in b/data/upstart/indicator-application.desktop.in new file mode 100644 index 0000000..ee1c4a1 --- /dev/null +++ b/data/upstart/indicator-application.desktop.in @@ -0,0 +1,8 @@ +[Desktop Entry] +Type=Application +Name=Indicator Application +Exec=@libexecdir@/indicator-application-service +StartupNotify=false +Terminal=false +OnlyShowIn=Unity;XFCE; +Hidden=true -- cgit v1.2.3 From dd359a11a25e6aa082d405c56c5b1255cd844c76 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 19 Feb 2014 21:31:05 -0600 Subject: Switch to using pkglibexecdir --- data/Makefile.am | 4 ++-- data/indicator-application.conf.in | 2 +- data/indicator-application.desktop.in | 2 +- data/upstart/Makefile.am | 4 ++-- data/upstart/indicator-application.desktop.in | 2 +- src/Makefile.am | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/data/Makefile.am b/data/Makefile.am index 6f46c2e..3f9f7ad 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -5,13 +5,13 @@ upstart_jobsdir = $(datadir)/upstart/sessions/ upstart_jobs_DATA = indicator-application.conf %.conf: %.conf.in - sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@ + sed -e "s|\@pkglibexecdir\@|$(pkglibexecdir)|" $< > $@ xdg_autostartdir = /etc/xdg/autostart xdg_autostart_DATA = indicator-application.desktop %.desktop: %.desktop.in - sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@ + sed -e "s|\@pkglibexecdir\@|$(pkglibexecdir)|" $< > $@ overridedir = $(pkgdatadir) override_DATA = ordering-override.keyfile diff --git a/data/indicator-application.conf.in b/data/indicator-application.conf.in index 15a318d..d3a103d 100644 --- a/data/indicator-application.conf.in +++ b/data/indicator-application.conf.in @@ -11,6 +11,6 @@ emits appindicators-start appindicators-end respawn respawn limit 2 10 -exec @libexecdir@/indicator-application-service +exec @pkglibexecdir@/indicator-application-service pre-stop exec initctl emit appindicators-end diff --git a/data/indicator-application.desktop.in b/data/indicator-application.desktop.in index 2783781..c724a0f 100644 --- a/data/indicator-application.desktop.in +++ b/data/indicator-application.desktop.in @@ -1,7 +1,7 @@ [Desktop Entry] Type=Application Name=Indicator Application -Exec=@libexecdir@/indicator-application-service +Exec=@pkglibexecdir@/indicator-application-service StartupNotify=false Terminal=false OnlyShowIn=Unity;XFCE; diff --git a/data/upstart/Makefile.am b/data/upstart/Makefile.am index a384c75..f7bc09e 100644 --- a/data/upstart/Makefile.am +++ b/data/upstart/Makefile.am @@ -1,9 +1,9 @@ -xdg_autostartdir = $(datadir)/upstart/xdg/autostart +xdg_autostartdir = $(pkgdatadir)/upstart/xdg/autostart xdg_autostart_DATA = indicator-application.desktop %.desktop: %.desktop.in - sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@ + sed -e "s|\@libexecdir\@|$(pkglibexecdir)|" $< > $@ EXTRA_DIST = \ indicator-application.desktop.in diff --git a/data/upstart/indicator-application.desktop.in b/data/upstart/indicator-application.desktop.in index ee1c4a1..f4ba076 100644 --- a/data/upstart/indicator-application.desktop.in +++ b/data/upstart/indicator-application.desktop.in @@ -1,7 +1,7 @@ [Desktop Entry] Type=Application Name=Indicator Application -Exec=@libexecdir@/indicator-application-service +Exec=@pkglibexecdir@/indicator-application-service StartupNotify=false Terminal=false OnlyShowIn=Unity;XFCE; diff --git a/src/Makefile.am b/src/Makefile.am index a68c007..4174cbc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -31,7 +31,7 @@ libapplication_la_LDFLAGS = $(COVERAGE_LDFLAGS) \ # Service ################################## -libexec_PROGRAMS = indicator-application-service +pkglibexec_PROGRAMS = indicator-application-service BUILT_SOURCES += \ application-service-marshal.h \ -- cgit v1.2.3 From e48b26bcffdf75b4454611f88018c1a783c2e9c9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 20 Feb 2014 14:48:59 -0600 Subject: Removes the indicator service code --- data/Makefile.am | 7 ++++--- src/application-service.c | 19 ------------------- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/data/Makefile.am b/data/Makefile.am index 3f9f7ad..b26a669 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -5,13 +5,13 @@ upstart_jobsdir = $(datadir)/upstart/sessions/ upstart_jobs_DATA = indicator-application.conf %.conf: %.conf.in - sed -e "s|\@pkglibexecdir\@|$(pkglibexecdir)|" $< > $@ + $(AM_V_GEN) sed -e "s|\@pkglibexecdir\@|$(pkglibexecdir)|" $< > $@ xdg_autostartdir = /etc/xdg/autostart xdg_autostart_DATA = indicator-application.desktop %.desktop: %.desktop.in - sed -e "s|\@pkglibexecdir\@|$(pkglibexecdir)|" $< > $@ + $(AM_V_GEN) sed -e "s|\@pkglibexecdir\@|$(pkglibexecdir)|" $< > $@ overridedir = $(pkgdatadir) override_DATA = ordering-override.keyfile @@ -22,5 +22,6 @@ EXTRA_DIST = \ ordering-override.keyfile CLEANFILES = \ - indicator-application.conf + indicator-application.conf \ + indicator-application.desktop diff --git a/src/application-service.c b/src/application-service.c index 5262d9d..21e3f9d 100644 --- a/src/application-service.c +++ b/src/application-service.c @@ -32,30 +32,12 @@ static GMainLoop * mainloop = NULL; static ApplicationServiceAppstore * appstore = NULL; /* Interface for applications */ static ApplicationServiceWatcher * watcher = NULL; -/* The service management interface */ -static IndicatorService * service = NULL; -/* Recieves the disonnection signal from the service - object and closes the mainloop. */ -static void -service_disconnected (IndicatorService * service, gpointer data) -{ - g_debug("Service disconnected"); - if (mainloop != NULL) { - g_main_loop_quit(mainloop); - } - return; -} - /* Builds up the core objects and puts us spinning into a main loop. */ int main (int argc, char ** argv) { - /* Bring us up as a basic indicator service */ - service = indicator_service_new_version(INDICATOR_APPLICATION_DBUS_ADDR, INDICATOR_APPLICATION_SERVICE_VERSION); - g_signal_connect(G_OBJECT(service), INDICATOR_SERVICE_SIGNAL_SHUTDOWN, G_CALLBACK(service_disconnected), NULL); - /* Building our app store */ appstore = application_service_appstore_new(); @@ -69,7 +51,6 @@ main (int argc, char ** argv) /* Unref'ing all the objects */ g_object_unref(G_OBJECT(watcher)); g_object_unref(G_OBJECT(appstore)); - g_object_unref(G_OBJECT(service)); return 0; } -- cgit v1.2.3 From b12215e8f5872e02c23fdceaa51415f1bd8dd058 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 20 Feb 2014 15:21:11 -0600 Subject: Own the name --- src/application-service.c | 45 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/src/application-service.c b/src/application-service.c index 21e3f9d..7024e91 100644 --- a/src/application-service.c +++ b/src/application-service.c @@ -21,7 +21,7 @@ with this program. If not, see . */ -#include "libindicator/indicator-service.h" +#include #include "application-service-appstore.h" #include "application-service-watcher.h" #include "dbus-shared.h" @@ -33,22 +33,57 @@ static ApplicationServiceAppstore * appstore = NULL; /* Interface for applications */ static ApplicationServiceWatcher * watcher = NULL; -/* Builds up the core objects and puts us spinning into - a main loop. */ -int -main (int argc, char ** argv) +/* Make sure we can set up all our objects before we get the name */ +static void +bus_acquired (GDBusConnection * con, const gchar * name, gpointer user_data) { + g_debug("Bus Acquired, building objects"); + /* Building our app store */ appstore = application_service_appstore_new(); /* Adding a watcher for the Apps coming up */ watcher = application_service_watcher_new(appstore); +} + +/* Nice to know, but we're not doing anything special */ +static void +name_acquired (GDBusConnection * con, const gchar * name, gpointer user_data) +{ + g_debug("Name Acquired"); +} + +/* Shouldn't happen under normal usage */ +static void +name_lost (GDBusConnection * con, const gchar * name, gpointer user_data) +{ + g_warning("Name Lost"); + g_main_loop_quit(mainloop); +} + +/* Builds up the core objects and puts us spinning into + a main loop. */ +int +main (int argc, char ** argv) +{ + guint nameownership = g_bus_own_name(G_BUS_TYPE_SESSION, + INDICATOR_APPLICATION_DBUS_ADDR, + G_BUS_NAME_OWNER_FLAGS_NONE, + bus_acquired, + name_acquired, + name_lost, + NULL, NULL); /* Building and executing our main loop */ mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); + g_debug("Finishing Main Loop"); + + g_bus_unown_name(nameownership); + /* Unref'ing all the objects */ + g_main_loop_unref(mainloop); g_object_unref(G_OBJECT(watcher)); g_object_unref(G_OBJECT(appstore)); -- cgit v1.2.3 From 7ae14a373ce72721b4f08e65f0ec481a93ced91d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 20 Feb 2014 15:38:21 -0600 Subject: Switch to a name watch --- src/indicator-application.c | 53 ++++++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/src/indicator-application.c b/src/indicator-application.c index 321d3d7..e78c69e 100644 --- a/src/indicator-application.c +++ b/src/indicator-application.c @@ -37,7 +37,6 @@ with this program. If not, see . /* Indicator Stuff */ #include #include -#include #include /* Local Stuff */ @@ -76,13 +75,13 @@ INDICATOR_SET_TYPE(INDICATOR_APPLICATION_TYPE) typedef struct _IndicatorApplicationPrivate IndicatorApplicationPrivate; struct _IndicatorApplicationPrivate { - IndicatorServiceManager * sm; GCancellable * service_proxy_cancel; GDBusProxy * service_proxy; GList * applications; GHashTable * theme_dirs; guint disconnect_kill; GCancellable * get_apps_cancel; + guint watch; }; typedef struct _ApplicationEntry ApplicationEntry; @@ -107,9 +106,8 @@ static GList * get_entries (IndicatorObject * io); static guint get_location (IndicatorObject * io, IndicatorObjectEntry * entry); static void entry_scrolled (IndicatorObject * io, IndicatorObjectEntry * entry, gint delta, IndicatorScrollDirection direction); static void entry_secondary_activate (IndicatorObject * io, IndicatorObjectEntry * entry, guint time, gpointer data); -void connection_changed (IndicatorServiceManager * sm, gboolean connected, IndicatorApplication * application); -static void connected (IndicatorApplication * application); -static void disconnected (IndicatorApplication * application); +static void connected (GDBusConnection * con, const gchar * name, const gchar * owner, gpointer user_data); +static void disconnected (GDBusConnection * con, const gchar * name, gpointer user_data); static void disconnected_helper (gpointer data, gpointer user_data); static gboolean disconnected_kill (gpointer user_data); static void disconnected_kill_helper (gpointer data, gpointer user_data); @@ -159,8 +157,13 @@ indicator_application_init (IndicatorApplication *self) priv->theme_dirs = NULL; priv->disconnect_kill = 0; - priv->sm = indicator_service_manager_new_version(INDICATOR_APPLICATION_DBUS_ADDR, INDICATOR_APPLICATION_SERVICE_VERSION); - g_signal_connect(G_OBJECT(priv->sm), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(connection_changed), self); + priv->watch = g_bus_watch_name(G_BUS_TYPE_SESSION, + INDICATOR_APPLICATION_DBUS_ADDR, + G_BUS_NAME_WATCHER_FLAGS_NONE, + connected, + disconnected, + self, + NULL); priv->applications = NULL; @@ -191,11 +194,6 @@ indicator_application_dispose (GObject *object) 0); } - if (priv->sm != NULL) { - g_object_unref(priv->sm); - priv->sm = NULL; - } - if (priv->service_proxy != NULL) { g_object_unref(G_OBJECT(priv->service_proxy)); priv->service_proxy = NULL; @@ -218,6 +216,11 @@ indicator_application_dispose (GObject *object) priv->theme_dirs = NULL; } + if (priv->watch != 0) { + g_bus_unwatch_name(priv->watch); + priv->watch = 0; + } + G_OBJECT_CLASS (indicator_application_parent_class)->dispose (object); return; } @@ -230,25 +233,14 @@ indicator_application_finalize (GObject *object) return; } -/* Responds to connection change event from the service manager and - splits it into two. */ -void -connection_changed (IndicatorServiceManager * sm, gboolean connect, IndicatorApplication * application) -{ - g_return_if_fail(IS_INDICATOR_APPLICATION(application)); - if (connect) { - connected(application); - } else { - disconnected(application); - } - return; -} - /* Brings up the connection to a service that has just come onto the bus, or is atleast new to us. */ -void -connected (IndicatorApplication * application) +static void +connected (GDBusConnection * con, const gchar * name, const gchar * owner, gpointer user_data) { + IndicatorApplication * application = INDICATOR_APPLICATION(user_data); + g_return_if_fail(application != NULL); + IndicatorApplicationPrivate * priv = INDICATOR_APPLICATION_GET_PRIVATE(application); g_debug("Connected to Application Indicator Service."); @@ -323,8 +315,11 @@ service_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data) service so that we can delete it if it doesn't come back. Also, sets up a timeout on comming back. */ static void -disconnected (IndicatorApplication * application) +disconnected (GDBusConnection * con, const gchar * name, gpointer user_data) { + IndicatorApplication * application = INDICATOR_APPLICATION(user_data); + g_return_if_fail(application != NULL); + IndicatorApplicationPrivate * priv = INDICATOR_APPLICATION_GET_PRIVATE(application); g_list_foreach(priv->applications, disconnected_helper, application); /* I'll like this to be a little shorter, but it's a bit -- cgit v1.2.3