aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac1
-rw-r--r--data/Makefile.am9
-rw-r--r--data/indicator-application.conf.in5
-rw-r--r--data/indicator-application.desktop.in6
-rw-r--r--data/upstart/Makefile.am9
-rw-r--r--data/upstart/indicator-application.desktop.in8
-rw-r--r--src/Makefile.am2
-rw-r--r--src/application-service.c60
-rw-r--r--src/indicator-application.c53
9 files changed, 92 insertions, 61 deletions
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..b26a669 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,15 +1,17 @@
+SUBDIRS = upstart
+
upstart_jobsdir = $(datadir)/upstart/sessions/
upstart_jobs_DATA = indicator-application.conf
%.conf: %.conf.in
- sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@
+ $(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|\@libexecdir\@|$(libexecdir)|" $< > $@
+ $(AM_V_GEN) sed -e "s|\@pkglibexecdir\@|$(pkglibexecdir)|" $< > $@
overridedir = $(pkgdatadir)
override_DATA = ordering-override.keyfile
@@ -20,5 +22,6 @@ EXTRA_DIST = \
ordering-override.keyfile
CLEANFILES = \
- indicator-application.conf
+ indicator-application.conf \
+ indicator-application.desktop
diff --git a/data/indicator-application.conf.in b/data/indicator-application.conf.in
index ddc803c..d3a103d 100644
--- a/data/indicator-application.conf.in
+++ b/data/indicator-application.conf.in
@@ -3,13 +3,14 @@ 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
+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 61d3c4d..c724a0f 100644
--- a/data/indicator-application.desktop.in
+++ b/data/indicator-application.desktop.in
@@ -1,9 +1,7 @@
[Desktop Entry]
Type=Application
Name=Indicator Application
-Exec=@libexecdir@/indicator-application-service
-NotShowIn=Unity;
-NoDisplay=true
+Exec=@pkglibexecdir@/indicator-application-service
StartupNotify=false
Terminal=false
-
+OnlyShowIn=Unity;XFCE;
diff --git a/data/upstart/Makefile.am b/data/upstart/Makefile.am
new file mode 100644
index 0000000..f7bc09e
--- /dev/null
+++ b/data/upstart/Makefile.am
@@ -0,0 +1,9 @@
+
+xdg_autostartdir = $(pkgdatadir)/upstart/xdg/autostart
+xdg_autostart_DATA = indicator-application.desktop
+
+%.desktop: %.desktop.in
+ 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
new file mode 100644
index 0000000..f4ba076
--- /dev/null
+++ b/data/upstart/indicator-application.desktop.in
@@ -0,0 +1,8 @@
+[Desktop Entry]
+Type=Application
+Name=Indicator Application
+Exec=@pkglibexecdir@/indicator-application-service
+StartupNotify=false
+Terminal=false
+OnlyShowIn=Unity;XFCE;
+Hidden=true
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 \
diff --git a/src/application-service.c b/src/application-service.c
index 5262d9d..7024e91 100644
--- a/src/application-service.c
+++ b/src/application-service.c
@@ -21,7 +21,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "libindicator/indicator-service.h"
+#include <gio/gio.h>
#include "application-service-appstore.h"
#include "application-service-watcher.h"
#include "dbus-shared.h"
@@ -32,44 +32,60 @@ 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. */
+/* Make sure we can set up all our objects before we get the name */
static void
-service_disconnected (IndicatorService * service, gpointer data)
+bus_acquired (GDBusConnection * con, const gchar * name, gpointer user_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);
+ 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));
- g_object_unref(G_OBJECT(service));
return 0;
}
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 <http://www.gnu.org/licenses/>.
/* Indicator Stuff */
#include <libindicator/indicator.h>
#include <libindicator/indicator-object.h>
-#include <libindicator/indicator-service-manager.h>
#include <libindicator/indicator-image-helper.h>
/* 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