From ab660ab46dabfdd99fb4e5ee8641a305299852c8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 6 Nov 2009 16:55:48 -0600 Subject: Creating a new object to be our watcher. Apparently we can't have two DBus interfaces on the same object :( --- src/custom-service-watcher.c | 56 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/custom-service-watcher.c (limited to 'src/custom-service-watcher.c') diff --git a/src/custom-service-watcher.c b/src/custom-service-watcher.c new file mode 100644 index 0000000..5899b83 --- /dev/null +++ b/src/custom-service-watcher.c @@ -0,0 +1,56 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "custom-service-watcher.h" + +typedef struct _CustomServiceWatcherPrivate CustomServiceWatcherPrivate; +struct _CustomServiceWatcherPrivate { + int dummy; +}; + +#define CUSTOM_SERVICE_WATCHER_GET_PRIVATE(o) \ +(G_TYPE_INSTANCE_GET_PRIVATE ((o), CUSTOM_SERVICE_WATCHER_TYPE, CustomServiceWatcherPrivate)) + +static void custom_service_watcher_class_init (CustomServiceWatcherClass *klass); +static void custom_service_watcher_init (CustomServiceWatcher *self); +static void custom_service_watcher_dispose (GObject *object); +static void custom_service_watcher_finalize (GObject *object); + +G_DEFINE_TYPE (CustomServiceWatcher, custom_service_watcher, G_TYPE_OBJECT); + +static void +custom_service_watcher_class_init (CustomServiceWatcherClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (klass, sizeof (CustomServiceWatcherPrivate)); + + object_class->dispose = custom_service_watcher_dispose; + object_class->finalize = custom_service_watcher_finalize; + + return; +} + +static void +custom_service_watcher_init (CustomServiceWatcher *self) +{ + + return; +} + +static void +custom_service_watcher_dispose (GObject *object) +{ + + G_OBJECT_CLASS (custom_service_watcher_parent_class)->dispose (object); + return; +} + +static void +custom_service_watcher_finalize (GObject *object) +{ + + G_OBJECT_CLASS (custom_service_watcher_parent_class)->finalize (object); + return; +} -- cgit v1.2.3 From fa2ac0047468678ee0bd6cf8e03731bbfdd98dd3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 6 Nov 2009 17:05:28 -0600 Subject: Moving the watcher stuff to the new object. --- src/custom-service-watcher.c | 63 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) (limited to 'src/custom-service-watcher.c') diff --git a/src/custom-service-watcher.c b/src/custom-service-watcher.c index 5899b83..b4680ab 100644 --- a/src/custom-service-watcher.c +++ b/src/custom-service-watcher.c @@ -2,7 +2,17 @@ #include "config.h" #endif +#include #include "custom-service-watcher.h" +#include "dbus-shared.h" + +static gboolean _notification_watcher_server_register_service (CustomServiceWatcher * appstore, const gchar * service, DBusGMethodInvocation * method); +static gboolean _notification_watcher_server_registered_services (CustomServiceWatcher * appstore, GArray ** apps); +static gboolean _notification_watcher_server_protocol_version (CustomServiceWatcher * appstore, char ** version); +static gboolean _notification_watcher_server_register_notification_host (CustomServiceWatcher * appstore, const gchar * host); +static gboolean _notification_watcher_server_is_notification_host_registered (CustomServiceWatcher * appstore, gboolean * haveHost); + +#include "notification-watcher-server.h" typedef struct _CustomServiceWatcherPrivate CustomServiceWatcherPrivate; struct _CustomServiceWatcherPrivate { @@ -29,12 +39,26 @@ custom_service_watcher_class_init (CustomServiceWatcherClass *klass) object_class->dispose = custom_service_watcher_dispose; object_class->finalize = custom_service_watcher_finalize; + dbus_g_object_type_install_info(CUSTOM_SERVICE_WATCHER_TYPE, + &dbus_glib__notification_watcher_server_object_info); + return; } static void custom_service_watcher_init (CustomServiceWatcher *self) { + GError * error = NULL; + DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error); + if (error != NULL) { + g_error("Unable to get session bus: %s", error->message); + g_error_free(error); + return; + } + + dbus_g_connection_register_g_object(session_bus, + INDICATOR_CUSTOM_DBUS_OBJ "/more", + G_OBJECT(self)); return; } @@ -54,3 +78,42 @@ custom_service_watcher_finalize (GObject *object) G_OBJECT_CLASS (custom_service_watcher_parent_class)->finalize (object); return; } + +static gboolean +_notification_watcher_server_register_service (CustomServiceWatcher * appstore, const gchar * service, DBusGMethodInvocation * method) +{ + + + + dbus_g_method_return(method, G_TYPE_NONE); + return TRUE; +} + +static gboolean +_notification_watcher_server_registered_services (CustomServiceWatcher * appstore, GArray ** apps) +{ + + return FALSE; +} + +static gboolean +_notification_watcher_server_protocol_version (CustomServiceWatcher * appstore, char ** version) +{ + *version = g_strdup("Ayatana Version 1"); + return TRUE; +} + +static gboolean +_notification_watcher_server_register_notification_host (CustomServiceWatcher * appstore, const gchar * host) +{ + + return FALSE; +} + +static gboolean +_notification_watcher_server_is_notification_host_registered (CustomServiceWatcher * appstore, gboolean * haveHost) +{ + *haveHost = TRUE; + return TRUE; +} + -- cgit v1.2.3 From ced0ec2c7e9e9138fb42422e662bf03deb957343 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 6 Nov 2009 17:13:47 -0600 Subject: Connecting the watcher and the appstore. And actually building one. We're on DBus now. --- src/custom-service-watcher.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/custom-service-watcher.c') diff --git a/src/custom-service-watcher.c b/src/custom-service-watcher.c index b4680ab..2b83c13 100644 --- a/src/custom-service-watcher.c +++ b/src/custom-service-watcher.c @@ -16,7 +16,7 @@ static gboolean _notification_watcher_server_is_notification_host_registered (Cu typedef struct _CustomServiceWatcherPrivate CustomServiceWatcherPrivate; struct _CustomServiceWatcherPrivate { - int dummy; + CustomServiceAppstore * appstore; }; #define CUSTOM_SERVICE_WATCHER_GET_PRIVATE(o) \ @@ -48,6 +48,10 @@ custom_service_watcher_class_init (CustomServiceWatcherClass *klass) static void custom_service_watcher_init (CustomServiceWatcher *self) { + CustomServiceWatcherPrivate * priv = CUSTOM_SERVICE_WATCHER_GET_PRIVATE(self); + + priv->appstore = NULL; + GError * error = NULL; DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error); if (error != NULL) { @@ -66,6 +70,12 @@ custom_service_watcher_init (CustomServiceWatcher *self) static void custom_service_watcher_dispose (GObject *object) { + CustomServiceWatcherPrivate * priv = CUSTOM_SERVICE_WATCHER_GET_PRIVATE(object); + + if (priv->appstore != NULL) { + g_object_unref(G_OBJECT(priv->appstore)); + priv->appstore = NULL; + } G_OBJECT_CLASS (custom_service_watcher_parent_class)->dispose (object); return; @@ -79,6 +89,16 @@ custom_service_watcher_finalize (GObject *object) return; } +CustomServiceWatcher * +custom_service_watcher_new (CustomServiceAppstore * appstore) +{ + GObject * obj = g_object_new(CUSTOM_SERVICE_WATCHER_TYPE, NULL); + CustomServiceWatcherPrivate * priv = CUSTOM_SERVICE_WATCHER_GET_PRIVATE(obj); + priv->appstore = appstore; + g_object_ref(G_OBJECT(priv->appstore)); + return CUSTOM_SERVICE_WATCHER(obj); +} + static gboolean _notification_watcher_server_register_service (CustomServiceWatcher * appstore, const gchar * service, DBusGMethodInvocation * method) { -- cgit v1.2.3 From 591311a82b0ce6e0bc74439186bb22d5224d85c5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 6 Nov 2009 20:41:18 -0600 Subject: Woot! Now we have signals in our watcher. Let's rock on! --- src/custom-service-watcher.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src/custom-service-watcher.c') diff --git a/src/custom-service-watcher.c b/src/custom-service-watcher.c index 2b83c13..4f6c6d3 100644 --- a/src/custom-service-watcher.c +++ b/src/custom-service-watcher.c @@ -14,6 +14,7 @@ static gboolean _notification_watcher_server_is_notification_host_registered (Cu #include "notification-watcher-server.h" +/* Private Stuff */ typedef struct _CustomServiceWatcherPrivate CustomServiceWatcherPrivate; struct _CustomServiceWatcherPrivate { CustomServiceAppstore * appstore; @@ -22,6 +23,18 @@ struct _CustomServiceWatcherPrivate { #define CUSTOM_SERVICE_WATCHER_GET_PRIVATE(o) \ (G_TYPE_INSTANCE_GET_PRIVATE ((o), CUSTOM_SERVICE_WATCHER_TYPE, CustomServiceWatcherPrivate)) +/* Signals Stuff */ +enum { + SERVICE_REGISTERED, + SERVICE_UNREGISTERED, + NOTIFICATION_HOST_REGISTERED, + NOTIFICATION_HOST_UNREGISTERED, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + +/* GObject stuff */ static void custom_service_watcher_class_init (CustomServiceWatcherClass *klass); static void custom_service_watcher_init (CustomServiceWatcher *self); static void custom_service_watcher_dispose (GObject *object); @@ -39,6 +52,35 @@ custom_service_watcher_class_init (CustomServiceWatcherClass *klass) object_class->dispose = custom_service_watcher_dispose; object_class->finalize = custom_service_watcher_finalize; + signals[SERVICE_REGISTERED] = g_signal_new ("service-registered", + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (CustomServiceWatcherClass, service_registered), + NULL, NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, 1, G_TYPE_STRING, G_TYPE_NONE); + signals[SERVICE_UNREGISTERED] = g_signal_new ("service-unregistered", + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (CustomServiceWatcherClass, service_unregistered), + NULL, NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, 1, G_TYPE_STRING, G_TYPE_NONE); + signals[NOTIFICATION_HOST_REGISTERED] = g_signal_new ("notification-host-registered", + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (CustomServiceWatcherClass, notification_host_registered), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0, G_TYPE_NONE); + signals[NOTIFICATION_HOST_UNREGISTERED] = g_signal_new ("notification-host-unregistered", + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (CustomServiceWatcherClass, notification_host_unregistered), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0, G_TYPE_NONE); + dbus_g_object_type_install_info(CUSTOM_SERVICE_WATCHER_TYPE, &dbus_glib__notification_watcher_server_object_info); -- cgit v1.2.3 From bca77a7a1e38c1d97211394799cf103bc02b0547 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 6 Nov 2009 21:40:28 -0600 Subject: Getting the registration signal, and passing it up the stack. --- src/custom-service-watcher.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'src/custom-service-watcher.c') diff --git a/src/custom-service-watcher.c b/src/custom-service-watcher.c index 4f6c6d3..a0a1b27 100644 --- a/src/custom-service-watcher.c +++ b/src/custom-service-watcher.c @@ -3,14 +3,15 @@ #endif #include +#include #include "custom-service-watcher.h" #include "dbus-shared.h" -static gboolean _notification_watcher_server_register_service (CustomServiceWatcher * appstore, const gchar * service, DBusGMethodInvocation * method); -static gboolean _notification_watcher_server_registered_services (CustomServiceWatcher * appstore, GArray ** apps); -static gboolean _notification_watcher_server_protocol_version (CustomServiceWatcher * appstore, char ** version); -static gboolean _notification_watcher_server_register_notification_host (CustomServiceWatcher * appstore, const gchar * host); -static gboolean _notification_watcher_server_is_notification_host_registered (CustomServiceWatcher * appstore, gboolean * haveHost); +static gboolean _notification_watcher_server_register_service (CustomServiceWatcher * appwatcher, const gchar * service, DBusGMethodInvocation * method); +static gboolean _notification_watcher_server_registered_services (CustomServiceWatcher * appwatcher, GArray ** apps); +static gboolean _notification_watcher_server_protocol_version (CustomServiceWatcher * appwatcher, char ** version); +static gboolean _notification_watcher_server_register_notification_host (CustomServiceWatcher * appwatcher, const gchar * host); +static gboolean _notification_watcher_server_is_notification_host_registered (CustomServiceWatcher * appwatcher, gboolean * haveHost); #include "notification-watcher-server.h" @@ -142,38 +143,39 @@ custom_service_watcher_new (CustomServiceAppstore * appstore) } static gboolean -_notification_watcher_server_register_service (CustomServiceWatcher * appstore, const gchar * service, DBusGMethodInvocation * method) +_notification_watcher_server_register_service (CustomServiceWatcher * appwatcher, const gchar * service, DBusGMethodInvocation * method) { + CustomServiceWatcherPrivate * priv = CUSTOM_SERVICE_WATCHER_GET_PRIVATE(appwatcher); - + custom_service_appstore_application_add(priv->appstore, dbus_g_method_get_sender(method), service); dbus_g_method_return(method, G_TYPE_NONE); return TRUE; } static gboolean -_notification_watcher_server_registered_services (CustomServiceWatcher * appstore, GArray ** apps) +_notification_watcher_server_registered_services (CustomServiceWatcher * appwatcher, GArray ** apps) { return FALSE; } static gboolean -_notification_watcher_server_protocol_version (CustomServiceWatcher * appstore, char ** version) +_notification_watcher_server_protocol_version (CustomServiceWatcher * appwatcher, char ** version) { *version = g_strdup("Ayatana Version 1"); return TRUE; } static gboolean -_notification_watcher_server_register_notification_host (CustomServiceWatcher * appstore, const gchar * host) +_notification_watcher_server_register_notification_host (CustomServiceWatcher * appwatcher, const gchar * host) { return FALSE; } static gboolean -_notification_watcher_server_is_notification_host_registered (CustomServiceWatcher * appstore, gboolean * haveHost) +_notification_watcher_server_is_notification_host_registered (CustomServiceWatcher * appwatcher, gboolean * haveHost) { *haveHost = TRUE; return TRUE; -- cgit v1.2.3 From efd63e3ff881a38bdbd466774dcf506b485166c2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 23 Nov 2009 12:52:14 -0600 Subject: Fixing custom indicator watcher object path. --- src/custom-service-watcher.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/custom-service-watcher.c') diff --git a/src/custom-service-watcher.c b/src/custom-service-watcher.c index a0a1b27..7cc15ee 100644 --- a/src/custom-service-watcher.c +++ b/src/custom-service-watcher.c @@ -104,7 +104,7 @@ custom_service_watcher_init (CustomServiceWatcher *self) } dbus_g_connection_register_g_object(session_bus, - INDICATOR_CUSTOM_DBUS_OBJ "/more", + NOTIFICATION_WATCHER_DBUS_OBJ, G_OBJECT(self)); return; -- cgit v1.2.3