From ecf44bf6a995071c7f0e5760dc3ed03542b993a0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 28 Oct 2009 14:57:38 -0500 Subject: Adding an appstore object to hold all of our apps. --- src/custom-service-appstore.c | 57 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/custom-service-appstore.c (limited to 'src/custom-service-appstore.c') diff --git a/src/custom-service-appstore.c b/src/custom-service-appstore.c new file mode 100644 index 0000000..c1bc345 --- /dev/null +++ b/src/custom-service-appstore.c @@ -0,0 +1,57 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "custom-service-appstore.h" + +typedef struct _CustomServiceAppstorePrivate CustomServiceAppstorePrivate; + +struct _CustomServiceAppstorePrivate { + int demo; +}; + +#define CUSTOM_SERVICE_APPSTORE_GET_PRIVATE(o) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((o), CUSTOM_SERVICE_APPSTORE_TYPE, CustomServiceAppstorePrivate)) + +static void custom_service_appstore_class_init (CustomServiceAppstoreClass *klass); +static void custom_service_appstore_init (CustomServiceAppstore *self); +static void custom_service_appstore_dispose (GObject *object); +static void custom_service_appstore_finalize (GObject *object); + +G_DEFINE_TYPE (CustomServiceAppstore, custom_service_appstore, G_TYPE_OBJECT); + +static void +custom_service_appstore_class_init (CustomServiceAppstoreClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (klass, sizeof (CustomServiceAppstorePrivate)); + + object_class->dispose = custom_service_appstore_dispose; + object_class->finalize = custom_service_appstore_finalize; + + return; +} + +static void +custom_service_appstore_init (CustomServiceAppstore *self) +{ + + return; +} + +static void +custom_service_appstore_dispose (GObject *object) +{ + + G_OBJECT_CLASS (custom_service_appstore_parent_class)->dispose (object); + return; +} + +static void +custom_service_appstore_finalize (GObject *object) +{ + + G_OBJECT_CLASS (custom_service_appstore_parent_class)->finalize (object); + return; +} -- cgit v1.2.3 From 8903841582ea26b4987fbe04b5a5545d8d65f729 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 28 Oct 2009 15:12:46 -0500 Subject: Boom! Now we're implementing dbus. --- src/custom-service-appstore.c | 56 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'src/custom-service-appstore.c') diff --git a/src/custom-service-appstore.c b/src/custom-service-appstore.c index c1bc345..7f88d46 100644 --- a/src/custom-service-appstore.c +++ b/src/custom-service-appstore.c @@ -4,6 +4,18 @@ #include "custom-service-appstore.h" +/* DBus Prototypes */ +static gboolean _custom_service_server_get_applications (CustomServiceAppstore * appstore, GArray ** apps, gpointer user_data); + +static gboolean _notification_watcher_server_register_service (CustomServiceAppstore * appstore, const gchar * service, gpointer user_data); +static gboolean _notification_watcher_server_registered_services (CustomServiceAppstore * appstore, GArray ** apps, gpointer user_data); +static gboolean _notification_watcher_server_protocol_version (CustomServiceAppstore * appstore, char ** version, gpointer user_data); +static gboolean _notification_watcher_server_register_notification_host (CustomServiceAppstore * appstore, const gchar * host, gpointer user_data); +static gboolean _notification_watcher_server_is_notification_host_registered (CustomServiceAppstore * appstore, gboolean * haveHost, gpointer user_data); + +#include "custom-service-server.h" +#include "notification-watcher-server.h" + typedef struct _CustomServiceAppstorePrivate CustomServiceAppstorePrivate; struct _CustomServiceAppstorePrivate { @@ -55,3 +67,47 @@ custom_service_appstore_finalize (GObject *object) G_OBJECT_CLASS (custom_service_appstore_parent_class)->finalize (object); return; } + +/* DBus Interface */ +static gboolean +_custom_service_server_get_applications (CustomServiceAppstore * appstore, GArray ** apps, gpointer user_data) +{ + + return FALSE; +} + +static gboolean +_notification_watcher_server_register_service (CustomServiceAppstore * appstore, const gchar * service, gpointer user_data) +{ + + return FALSE; +} + +static gboolean +_notification_watcher_server_registered_services (CustomServiceAppstore * appstore, GArray ** apps, gpointer user_data) +{ + + return FALSE; +} + +static gboolean +_notification_watcher_server_protocol_version (CustomServiceAppstore * appstore, char ** version, gpointer user_data) +{ + + return FALSE; +} + +static gboolean +_notification_watcher_server_register_notification_host (CustomServiceAppstore * appstore, const gchar * host, gpointer user_data) +{ + + return FALSE; +} + +static gboolean +_notification_watcher_server_is_notification_host_registered (CustomServiceAppstore * appstore, gboolean * haveHost, gpointer user_data) +{ + + return FALSE; +} + -- cgit v1.2.3 From 714f372137fb2a9a992a6d0c23dc12a58b34c43d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 28 Oct 2009 15:52:48 -0500 Subject: Registering ourselves on dbus --- src/custom-service-appstore.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/custom-service-appstore.c') diff --git a/src/custom-service-appstore.c b/src/custom-service-appstore.c index 7f88d46..1e61852 100644 --- a/src/custom-service-appstore.c +++ b/src/custom-service-appstore.c @@ -42,12 +42,29 @@ custom_service_appstore_class_init (CustomServiceAppstoreClass *klass) object_class->dispose = custom_service_appstore_dispose; object_class->finalize = custom_service_appstore_finalize; + dbus_g_object_type_install_info(CUSTOM_SERVICE_APPSTORE_TYPE, + &dbus_glib__notification_watcher_server_object_info); + dbus_g_object_type_install_info(CUSTOM_SERVICE_APPSTORE_TYPE, + &dbus_glib__custom_service_server_object_info); + return; } static void custom_service_appstore_init (CustomServiceAppstore *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, + "/my/path", + G_OBJECT(self)); return; } -- cgit v1.2.3 From 46443702113ebba13864a1452333a3bd25a9088e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 6 Nov 2009 16:19:35 -0600 Subject: Changing some API and implementing the simple stuff. --- src/custom-service-appstore.c | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) (limited to 'src/custom-service-appstore.c') diff --git a/src/custom-service-appstore.c b/src/custom-service-appstore.c index 1e61852..f8d34d0 100644 --- a/src/custom-service-appstore.c +++ b/src/custom-service-appstore.c @@ -2,16 +2,18 @@ #include "config.h" #endif +#include #include "custom-service-appstore.h" +#include "dbus-shared.h" /* DBus Prototypes */ -static gboolean _custom_service_server_get_applications (CustomServiceAppstore * appstore, GArray ** apps, gpointer user_data); +static gboolean _custom_service_server_get_applications (CustomServiceAppstore * appstore, GArray ** apps); -static gboolean _notification_watcher_server_register_service (CustomServiceAppstore * appstore, const gchar * service, gpointer user_data); -static gboolean _notification_watcher_server_registered_services (CustomServiceAppstore * appstore, GArray ** apps, gpointer user_data); -static gboolean _notification_watcher_server_protocol_version (CustomServiceAppstore * appstore, char ** version, gpointer user_data); -static gboolean _notification_watcher_server_register_notification_host (CustomServiceAppstore * appstore, const gchar * host, gpointer user_data); -static gboolean _notification_watcher_server_is_notification_host_registered (CustomServiceAppstore * appstore, gboolean * haveHost, gpointer user_data); +static gboolean _notification_watcher_server_register_service (CustomServiceAppstore * appstore, const gchar * service, DBusGMethodInvocation * method); +static gboolean _notification_watcher_server_registered_services (CustomServiceAppstore * appstore, GArray ** apps); +static gboolean _notification_watcher_server_protocol_version (CustomServiceAppstore * appstore, char ** version); +static gboolean _notification_watcher_server_register_notification_host (CustomServiceAppstore * appstore, const gchar * host); +static gboolean _notification_watcher_server_is_notification_host_registered (CustomServiceAppstore * appstore, gboolean * haveHost); #include "custom-service-server.h" #include "notification-watcher-server.h" @@ -63,7 +65,7 @@ custom_service_appstore_init (CustomServiceAppstore *self) } dbus_g_connection_register_g_object(session_bus, - "/my/path", + INDICATOR_CUSTOM_DBUS_OBJ, G_OBJECT(self)); return; @@ -87,44 +89,47 @@ custom_service_appstore_finalize (GObject *object) /* DBus Interface */ static gboolean -_custom_service_server_get_applications (CustomServiceAppstore * appstore, GArray ** apps, gpointer user_data) +_custom_service_server_get_applications (CustomServiceAppstore * appstore, GArray ** apps) { return FALSE; } static gboolean -_notification_watcher_server_register_service (CustomServiceAppstore * appstore, const gchar * service, gpointer user_data) +_notification_watcher_server_register_service (CustomServiceAppstore * appstore, const gchar * service, DBusGMethodInvocation * method) { - return FALSE; + + + dbus_g_method_return(method, G_TYPE_NONE); + return TRUE; } static gboolean -_notification_watcher_server_registered_services (CustomServiceAppstore * appstore, GArray ** apps, gpointer user_data) +_notification_watcher_server_registered_services (CustomServiceAppstore * appstore, GArray ** apps) { return FALSE; } static gboolean -_notification_watcher_server_protocol_version (CustomServiceAppstore * appstore, char ** version, gpointer user_data) +_notification_watcher_server_protocol_version (CustomServiceAppstore * appstore, char ** version) { - - return FALSE; + *version = g_strdup("Ayatana Version 1"); + return TRUE; } static gboolean -_notification_watcher_server_register_notification_host (CustomServiceAppstore * appstore, const gchar * host, gpointer user_data) +_notification_watcher_server_register_notification_host (CustomServiceAppstore * appstore, const gchar * host) { return FALSE; } static gboolean -_notification_watcher_server_is_notification_host_registered (CustomServiceAppstore * appstore, gboolean * haveHost, gpointer user_data) +_notification_watcher_server_is_notification_host_registered (CustomServiceAppstore * appstore, gboolean * haveHost) { - - return FALSE; + *haveHost = TRUE; + return TRUE; } -- cgit v1.2.3 From 3ea189ef44422c02eacfb25089968acaaff61ab1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 6 Nov 2009 16:40:36 -0600 Subject: Putting some signals on here. --- src/custom-service-appstore.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'src/custom-service-appstore.c') diff --git a/src/custom-service-appstore.c b/src/custom-service-appstore.c index f8d34d0..a012fae 100644 --- a/src/custom-service-appstore.c +++ b/src/custom-service-appstore.c @@ -18,8 +18,8 @@ static gboolean _notification_watcher_server_is_notification_host_registered (Cu #include "custom-service-server.h" #include "notification-watcher-server.h" +/* Private Stuff */ typedef struct _CustomServiceAppstorePrivate CustomServiceAppstorePrivate; - struct _CustomServiceAppstorePrivate { int demo; }; @@ -27,6 +27,16 @@ struct _CustomServiceAppstorePrivate { #define CUSTOM_SERVICE_APPSTORE_GET_PRIVATE(o) \ (G_TYPE_INSTANCE_GET_PRIVATE ((o), CUSTOM_SERVICE_APPSTORE_TYPE, CustomServiceAppstorePrivate)) +/* Signals Stuff */ +enum { + APPLICATION_ADDED, + APPLICATION_REMOVED, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + +/* GObject stuff */ static void custom_service_appstore_class_init (CustomServiceAppstoreClass *klass); static void custom_service_appstore_init (CustomServiceAppstore *self); static void custom_service_appstore_dispose (GObject *object); @@ -44,6 +54,22 @@ custom_service_appstore_class_init (CustomServiceAppstoreClass *klass) object_class->dispose = custom_service_appstore_dispose; object_class->finalize = custom_service_appstore_finalize; + signals[APPLICATION_ADDED] = g_signal_new ("application-added", + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (CustomServiceAppstore, application_added), + NULL, NULL, + g_cclosure_marshal_VOID__POINTER, + G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_NONE); + signals[APPLICATION_REMOVED] = g_signal_new ("application-removed", + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (CustomServiceAppstore, application_removed), + NULL, NULL, + g_cclosure_marshal_VOID__INT, + G_TYPE_NONE, 1, G_TYPE_INT, G_TYPE_NONE); + + dbus_g_object_type_install_info(CUSTOM_SERVICE_APPSTORE_TYPE, &dbus_glib__notification_watcher_server_object_info); dbus_g_object_type_install_info(CUSTOM_SERVICE_APPSTORE_TYPE, -- cgit v1.2.3 From 53f654eec6419c4999a620f9f1e0aaf3f2ac5e89 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 6 Nov 2009 16:47:54 -0600 Subject: Adding in a set of marshallers to make our signals all happy. --- src/custom-service-appstore.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/custom-service-appstore.c') diff --git a/src/custom-service-appstore.c b/src/custom-service-appstore.c index a012fae..02d7927 100644 --- a/src/custom-service-appstore.c +++ b/src/custom-service-appstore.c @@ -4,6 +4,7 @@ #include #include "custom-service-appstore.h" +#include "custom-service-marshal.h" #include "dbus-shared.h" /* DBus Prototypes */ @@ -59,7 +60,7 @@ custom_service_appstore_class_init (CustomServiceAppstoreClass *klass) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (CustomServiceAppstore, application_added), NULL, NULL, - g_cclosure_marshal_VOID__POINTER, + _custom_service_marshal_VOID__STRING_INT_STRING_STRING, G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_NONE); signals[APPLICATION_REMOVED] = g_signal_new ("application-removed", G_TYPE_FROM_CLASS(klass), -- 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-appstore.c | 48 ------------------------------------------- 1 file changed, 48 deletions(-) (limited to 'src/custom-service-appstore.c') diff --git a/src/custom-service-appstore.c b/src/custom-service-appstore.c index 02d7927..493d4f4 100644 --- a/src/custom-service-appstore.c +++ b/src/custom-service-appstore.c @@ -10,14 +10,7 @@ /* DBus Prototypes */ static gboolean _custom_service_server_get_applications (CustomServiceAppstore * appstore, GArray ** apps); -static gboolean _notification_watcher_server_register_service (CustomServiceAppstore * appstore, const gchar * service, DBusGMethodInvocation * method); -static gboolean _notification_watcher_server_registered_services (CustomServiceAppstore * appstore, GArray ** apps); -static gboolean _notification_watcher_server_protocol_version (CustomServiceAppstore * appstore, char ** version); -static gboolean _notification_watcher_server_register_notification_host (CustomServiceAppstore * appstore, const gchar * host); -static gboolean _notification_watcher_server_is_notification_host_registered (CustomServiceAppstore * appstore, gboolean * haveHost); - #include "custom-service-server.h" -#include "notification-watcher-server.h" /* Private Stuff */ typedef struct _CustomServiceAppstorePrivate CustomServiceAppstorePrivate; @@ -71,8 +64,6 @@ custom_service_appstore_class_init (CustomServiceAppstoreClass *klass) G_TYPE_NONE, 1, G_TYPE_INT, G_TYPE_NONE); - dbus_g_object_type_install_info(CUSTOM_SERVICE_APPSTORE_TYPE, - &dbus_glib__notification_watcher_server_object_info); dbus_g_object_type_install_info(CUSTOM_SERVICE_APPSTORE_TYPE, &dbus_glib__custom_service_server_object_info); @@ -121,42 +112,3 @@ _custom_service_server_get_applications (CustomServiceAppstore * appstore, GArra return FALSE; } - -static gboolean -_notification_watcher_server_register_service (CustomServiceAppstore * appstore, const gchar * service, DBusGMethodInvocation * method) -{ - - - - dbus_g_method_return(method, G_TYPE_NONE); - return TRUE; -} - -static gboolean -_notification_watcher_server_registered_services (CustomServiceAppstore * appstore, GArray ** apps) -{ - - return FALSE; -} - -static gboolean -_notification_watcher_server_protocol_version (CustomServiceAppstore * appstore, char ** version) -{ - *version = g_strdup("Ayatana Version 1"); - return TRUE; -} - -static gboolean -_notification_watcher_server_register_notification_host (CustomServiceAppstore * appstore, const gchar * host) -{ - - return FALSE; -} - -static gboolean -_notification_watcher_server_is_notification_host_registered (CustomServiceAppstore * appstore, gboolean * haveHost) -{ - *haveHost = TRUE; - return TRUE; -} - -- cgit v1.2.3 From 78a6d0dc74a7ea166e207f8036cc4930bcdcbbbd Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 6 Nov 2009 21:16:47 -0600 Subject: Adding app add/remove to appstore --- src/custom-service-appstore.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/custom-service-appstore.c') diff --git a/src/custom-service-appstore.c b/src/custom-service-appstore.c index 493d4f4..ceb2c17 100644 --- a/src/custom-service-appstore.c +++ b/src/custom-service-appstore.c @@ -105,6 +105,28 @@ custom_service_appstore_finalize (GObject *object) return; } +void +custom_service_appstore_application_add (CustomServiceAppstore * appstore, gchar * dbus_name, gchar * dbus_object) +{ + g_return_if_fail(IS_CUSTOM_SERVICE_APPSTORE(appstore)); + g_return_if_fail(dbus_name != NULL && dbus_name[0] != '\0'); + g_return_if_fail(dbus_object != NULL && dbus_object[0] != '\0'); + + + return; +} + +void +custom_service_appstore_application_remove (CustomServiceAppstore * appstore, gchar * dbus_name, gchar * dbus_object) +{ + g_return_if_fail(IS_CUSTOM_SERVICE_APPSTORE(appstore)); + g_return_if_fail(dbus_name != NULL && dbus_name[0] != '\0'); + g_return_if_fail(dbus_object != NULL && dbus_object[0] != '\0'); + + + return; +} + /* DBus Interface */ static gboolean _custom_service_server_get_applications (CustomServiceAppstore * appstore, GArray ** apps) @@ -112,3 +134,4 @@ _custom_service_server_get_applications (CustomServiceAppstore * appstore, GArra return FALSE; } + -- 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-appstore.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/custom-service-appstore.c') diff --git a/src/custom-service-appstore.c b/src/custom-service-appstore.c index ceb2c17..b25ffa7 100644 --- a/src/custom-service-appstore.c +++ b/src/custom-service-appstore.c @@ -106,7 +106,7 @@ custom_service_appstore_finalize (GObject *object) } void -custom_service_appstore_application_add (CustomServiceAppstore * appstore, gchar * dbus_name, gchar * dbus_object) +custom_service_appstore_application_add (CustomServiceAppstore * appstore, const gchar * dbus_name, const gchar * dbus_object) { g_return_if_fail(IS_CUSTOM_SERVICE_APPSTORE(appstore)); g_return_if_fail(dbus_name != NULL && dbus_name[0] != '\0'); @@ -117,7 +117,7 @@ custom_service_appstore_application_add (CustomServiceAppstore * appstore, gchar } void -custom_service_appstore_application_remove (CustomServiceAppstore * appstore, gchar * dbus_name, gchar * dbus_object) +custom_service_appstore_application_remove (CustomServiceAppstore * appstore, const gchar * dbus_name, const gchar * dbus_object) { g_return_if_fail(IS_CUSTOM_SERVICE_APPSTORE(appstore)); g_return_if_fail(dbus_name != NULL && dbus_name[0] != '\0'); -- cgit v1.2.3 From e25d64ff5a87e06212c03167a7b430bd320442dd Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 6 Nov 2009 21:53:59 -0600 Subject: Adding an application list. --- src/custom-service-appstore.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/custom-service-appstore.c') diff --git a/src/custom-service-appstore.c b/src/custom-service-appstore.c index b25ffa7..65c6b6b 100644 --- a/src/custom-service-appstore.c +++ b/src/custom-service-appstore.c @@ -15,7 +15,14 @@ static gboolean _custom_service_server_get_applications (CustomServiceAppstore * /* Private Stuff */ typedef struct _CustomServiceAppstorePrivate CustomServiceAppstorePrivate; struct _CustomServiceAppstorePrivate { - int demo; + GList * applications; +}; + +typedef struct _Application Application; +struct _Application { + gchar * dbus_name; + gchar * dbus_object; + DBusGProxy * dbus_proxy; }; #define CUSTOM_SERVICE_APPSTORE_GET_PRIVATE(o) \ @@ -73,6 +80,9 @@ custom_service_appstore_class_init (CustomServiceAppstoreClass *klass) static void custom_service_appstore_init (CustomServiceAppstore *self) { + CustomServiceAppstorePrivate * priv = CUSTOM_SERVICE_APPSTORE_GET_PRIVATE(self); + + priv->applications = NULL; GError * error = NULL; DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error); @@ -92,6 +102,13 @@ custom_service_appstore_init (CustomServiceAppstore *self) static void custom_service_appstore_dispose (GObject *object) { + CustomServiceAppstorePrivate * priv = CUSTOM_SERVICE_APPSTORE_GET_PRIVATE(object); + + while (priv->applications != NULL) { + custom_service_appstore_application_remove(CUSTOM_SERVICE_APPSTORE(object), + ((Application *)priv->applications->data)->dbus_name, + ((Application *)priv->applications->data)->dbus_object); + } G_OBJECT_CLASS (custom_service_appstore_parent_class)->dispose (object); return; -- cgit v1.2.3 From 8b92c1c28c4d956b45aa85a31a7a201ef831fe2f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 6 Nov 2009 22:15:19 -0600 Subject: Building a proxy. --- src/custom-service-appstore.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'src/custom-service-appstore.c') diff --git a/src/custom-service-appstore.c b/src/custom-service-appstore.c index 65c6b6b..5b8f7e0 100644 --- a/src/custom-service-appstore.c +++ b/src/custom-service-appstore.c @@ -15,6 +15,7 @@ static gboolean _custom_service_server_get_applications (CustomServiceAppstore * /* Private Stuff */ typedef struct _CustomServiceAppstorePrivate CustomServiceAppstorePrivate; struct _CustomServiceAppstorePrivate { + DBusGConnection * bus; GList * applications; }; @@ -85,14 +86,14 @@ custom_service_appstore_init (CustomServiceAppstore *self) priv->applications = NULL; GError * error = NULL; - DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error); + priv->bus = dbus_g_bus_get(DBUS_BUS_STARTER, &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, + dbus_g_connection_register_g_object(priv->bus, INDICATOR_CUSTOM_DBUS_OBJ, G_OBJECT(self)); @@ -128,7 +129,25 @@ custom_service_appstore_application_add (CustomServiceAppstore * appstore, const g_return_if_fail(IS_CUSTOM_SERVICE_APPSTORE(appstore)); g_return_if_fail(dbus_name != NULL && dbus_name[0] != '\0'); g_return_if_fail(dbus_object != NULL && dbus_object[0] != '\0'); + CustomServiceAppstorePrivate * priv = CUSTOM_SERVICE_APPSTORE_GET_PRIVATE(appstore); + Application * app = g_new(Application, 1); + + app->dbus_name = g_strdup(dbus_name); + app->dbus_object = g_strdup(dbus_object); + + GError * error = NULL; + app->dbus_proxy = dbus_g_proxy_new_for_name_owner(priv->bus, + app->dbus_name, + app->dbus_object, + NOTIFICATION_ITEM_DBUS_IFACE, + &error); + if (error != NULL) { + g_warning("Unable to get notification item proxy for object '%s' on host '%s': %s", dbus_object, dbus_name, error->message); + g_error_free(error); + g_free(app); + return; + } return; } -- cgit v1.2.3 From 1cee2f386e28a93036c68bb3f7ff96294440713e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 6 Nov 2009 22:17:54 -0600 Subject: Forgot to save. --- src/custom-service-appstore.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/custom-service-appstore.c') diff --git a/src/custom-service-appstore.c b/src/custom-service-appstore.c index 5b8f7e0..6368206 100644 --- a/src/custom-service-appstore.c +++ b/src/custom-service-appstore.c @@ -149,6 +149,9 @@ custom_service_appstore_application_add (CustomServiceAppstore * appstore, const return; } + + + return; } -- cgit v1.2.3 From 4bcfbf41887d4b597cf727ed23e4d59946ff7666 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 6 Nov 2009 22:46:30 -0600 Subject: Building the property proxy. --- src/custom-service-appstore.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/custom-service-appstore.c') diff --git a/src/custom-service-appstore.c b/src/custom-service-appstore.c index 6368206..fc49b83 100644 --- a/src/custom-service-appstore.c +++ b/src/custom-service-appstore.c @@ -24,6 +24,7 @@ struct _Application { gchar * dbus_name; gchar * dbus_object; DBusGProxy * dbus_proxy; + DBusGProxy * prop_proxy; }; #define CUSTOM_SERVICE_APPSTORE_GET_PRIVATE(o) \ @@ -142,6 +143,7 @@ custom_service_appstore_application_add (CustomServiceAppstore * appstore, const app->dbus_object, NOTIFICATION_ITEM_DBUS_IFACE, &error); + if (error != NULL) { g_warning("Unable to get notification item proxy for object '%s' on host '%s': %s", dbus_object, dbus_name, error->message); g_error_free(error); @@ -149,6 +151,19 @@ custom_service_appstore_application_add (CustomServiceAppstore * appstore, const return; } + app->prop_proxy = dbus_g_proxy_new_for_name_owner(priv->bus, + app->dbus_name, + app->dbus_object, + DBUS_INTERFACE_PROPERTIES, + &error); + + if (error != NULL) { + g_warning("Unable to get property proxy for object '%s' on host '%s': %s", dbus_object, dbus_name, error->message); + g_error_free(error); + g_object_unref(app->dbus_proxy); + g_free(app); + return; + } -- cgit v1.2.3 From d0abddaaf72e621a495871e5805cd39a51891b2b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 6 Nov 2009 23:38:22 -0600 Subject: Grabbing the properties and going to town. Turning back into another signal. --- src/custom-service-appstore.c | 46 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) (limited to 'src/custom-service-appstore.c') diff --git a/src/custom-service-appstore.c b/src/custom-service-appstore.c index fc49b83..a69bde6 100644 --- a/src/custom-service-appstore.c +++ b/src/custom-service-appstore.c @@ -5,6 +5,7 @@ #include #include "custom-service-appstore.h" #include "custom-service-marshal.h" +#include "dbus-properties-client.h" #include "dbus-shared.h" /* DBus Prototypes */ @@ -12,6 +13,13 @@ static gboolean _custom_service_server_get_applications (CustomServiceAppstore * #include "custom-service-server.h" +#define NOTIFICATION_ITEM_PROP_ID "Id" +#define NOTIFICATION_ITEM_PROP_CATEGORY "Category" +#define NOTIFICATION_ITEM_PROP_STATUS "Status" +#define NOTIFICATION_ITEM_PROP_ICON_NAME "IconName" +#define NOTIFICATION_ITEM_PROP_AICON_NAME "AttentionIconName" +#define NOTIFICATION_ITEM_PROP_MENU "Menu" + /* Private Stuff */ typedef struct _CustomServiceAppstorePrivate CustomServiceAppstorePrivate; struct _CustomServiceAppstorePrivate { @@ -23,6 +31,7 @@ typedef struct _Application Application; struct _Application { gchar * dbus_name; gchar * dbus_object; + CustomServiceAppstore * appstore; /* not ref'd */ DBusGProxy * dbus_proxy; DBusGProxy * prop_proxy; }; @@ -124,6 +133,37 @@ custom_service_appstore_finalize (GObject *object) return; } +static void +get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * error, gpointer data) +{ + if (error != NULL) { + g_warning("Unable to get properties: %s", error->message); + return; + } + + Application * app = (Application *)data; + + if (g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_MENU) == NULL || + g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_ICON_NAME) == NULL) { + g_warning("Notification Item on object %s of %s doesn't have enough properties.", app->dbus_object, app->dbus_name); + g_free(app); // Need to do more than this, but it gives the idea of the flow we're going for. + return; + } + + CustomServiceAppstorePrivate * priv = CUSTOM_SERVICE_APPSTORE_GET_PRIVATE(app->appstore); + priv->applications = g_list_prepend(priv->applications, app); + + g_signal_emit(G_OBJECT(app->appstore), + signals[APPLICATION_ADDED], 0, + g_value_get_string(g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_ICON_NAME)), + 0, /* Position */ + app->dbus_name, + g_value_get_string(g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_MENU)), + TRUE); + + return; +} + void custom_service_appstore_application_add (CustomServiceAppstore * appstore, const gchar * dbus_name, const gchar * dbus_object) { @@ -136,6 +176,7 @@ custom_service_appstore_application_add (CustomServiceAppstore * appstore, const app->dbus_name = g_strdup(dbus_name); app->dbus_object = g_strdup(dbus_object); + app->appstore = appstore; GError * error = NULL; app->dbus_proxy = dbus_g_proxy_new_for_name_owner(priv->bus, @@ -165,7 +206,10 @@ custom_service_appstore_application_add (CustomServiceAppstore * appstore, const return; } - + org_freedesktop_DBus_Properties_get_all_async(app->prop_proxy, + NOTIFICATION_ITEM_DBUS_IFACE, + get_all_properties_cb, + app); return; } -- cgit v1.2.3 From 5a87d20ea3873748036185ae74da33ed88cf9d63 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 23 Nov 2009 13:09:58 -0600 Subject: Commenting. --- src/custom-service-appstore.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/custom-service-appstore.c') diff --git a/src/custom-service-appstore.c b/src/custom-service-appstore.c index a69bde6..81910dd 100644 --- a/src/custom-service-appstore.c +++ b/src/custom-service-appstore.c @@ -164,20 +164,27 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err return; } +/* Adding a new NotificationItem object from DBus in to the + appstore. First, we need to get the information on it + though. */ void custom_service_appstore_application_add (CustomServiceAppstore * appstore, const gchar * dbus_name, const gchar * dbus_object) { + /* Make sure we got a sensible request */ g_return_if_fail(IS_CUSTOM_SERVICE_APPSTORE(appstore)); g_return_if_fail(dbus_name != NULL && dbus_name[0] != '\0'); g_return_if_fail(dbus_object != NULL && dbus_object[0] != '\0'); CustomServiceAppstorePrivate * priv = CUSTOM_SERVICE_APPSTORE_GET_PRIVATE(appstore); + /* Build the application entry. This will be carried + along until we're sure we've got everything. */ Application * app = g_new(Application, 1); app->dbus_name = g_strdup(dbus_name); app->dbus_object = g_strdup(dbus_object); app->appstore = appstore; + /* Get the DBus proxy for the NotificationItem interface */ GError * error = NULL; app->dbus_proxy = dbus_g_proxy_new_for_name_owner(priv->bus, app->dbus_name, @@ -192,6 +199,7 @@ custom_service_appstore_application_add (CustomServiceAppstore * appstore, const return; } + /* Grab the property proxy interface */ app->prop_proxy = dbus_g_proxy_new_for_name_owner(priv->bus, app->dbus_name, app->dbus_object, @@ -206,11 +214,14 @@ custom_service_appstore_application_add (CustomServiceAppstore * appstore, const return; } + /* Get all the propertiees */ org_freedesktop_DBus_Properties_get_all_async(app->prop_proxy, NOTIFICATION_ITEM_DBUS_IFACE, get_all_properties_cb, app); + /* We're returning, nothing is yet added until the properties + come back and give us more info. */ return; } -- cgit v1.2.3 From 9a4835415f4df9b906a4d489245b0aecab43c09d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 23 Nov 2009 13:26:32 -0600 Subject: Adding in a TODO --- src/custom-service-appstore.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/custom-service-appstore.c') diff --git a/src/custom-service-appstore.c b/src/custom-service-appstore.c index 81910dd..6cb2dd9 100644 --- a/src/custom-service-appstore.c +++ b/src/custom-service-appstore.c @@ -152,6 +152,10 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err CustomServiceAppstorePrivate * priv = CUSTOM_SERVICE_APPSTORE_GET_PRIVATE(app->appstore); priv->applications = g_list_prepend(priv->applications, app); + + /* TODO: We need to have the position determined better. This + would involve looking at the name and category and sorting + it with the other entries. */ g_signal_emit(G_OBJECT(app->appstore), signals[APPLICATION_ADDED], 0, -- cgit v1.2.3 From 009e468befbd97cf69263b47a01bc66d9a119d66 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 23 Nov 2009 15:59:30 -0600 Subject: Adding a debug message on getting an application. --- src/custom-service-appstore.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/custom-service-appstore.c') diff --git a/src/custom-service-appstore.c b/src/custom-service-appstore.c index 6cb2dd9..fdb227a 100644 --- a/src/custom-service-appstore.c +++ b/src/custom-service-appstore.c @@ -174,6 +174,8 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err void custom_service_appstore_application_add (CustomServiceAppstore * appstore, const gchar * dbus_name, const gchar * dbus_object) { + g_debug("Adding new application: %s:%s", dbus_name, dbus_object); + /* Make sure we got a sensible request */ g_return_if_fail(IS_CUSTOM_SERVICE_APPSTORE(appstore)); g_return_if_fail(dbus_name != NULL && dbus_name[0] != '\0'); -- cgit v1.2.3 From 4b23fc39d2fed996dd651d101dc1fb0a5b76d8f0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 24 Nov 2009 15:17:03 -0600 Subject: Woot, basic remove support. Causes warnings, but it works. --- src/custom-service-appstore.c | 48 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'src/custom-service-appstore.c') diff --git a/src/custom-service-appstore.c b/src/custom-service-appstore.c index fdb227a..bdf8ffb 100644 --- a/src/custom-service-appstore.c +++ b/src/custom-service-appstore.c @@ -168,6 +168,51 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err return; } +/* A simple global function for dealing with freeing the information + in an Application structure */ +static void +application_free (Application * app) +{ + if (app == NULL) return; + + if (app->dbus_name != NULL) { + g_free(app->dbus_name); + } + if (app->dbus_object != NULL) { + g_free(app->dbus_object); + } + + g_free(app); + return; +} + +/* Gets called when the proxy is destroyed, which is usually when it + drops off of the bus. */ +static void +application_removed_cb (DBusGProxy * proxy, gpointer userdata) +{ + Application * app = (Application *)userdata; + CustomServiceAppstore * appstore = app->appstore; + CustomServiceAppstorePrivate * priv = CUSTOM_SERVICE_APPSTORE_GET_PRIVATE(appstore); + + GList * applistitem = g_list_find(priv->applications, app); + if (applistitem == NULL) { + g_warning("Removing an application that isn't in the application list?"); + return; + } + + gint position = g_list_position(priv->applications, applistitem); + + g_signal_emit(G_OBJECT(appstore), + signals[APPLICATION_REMOVED], 0, + position, TRUE); + + priv->applications = g_list_remove(priv->applications, app); + + application_free(app); + return; +} + /* Adding a new NotificationItem object from DBus in to the appstore. First, we need to get the information on it though. */ @@ -204,6 +249,9 @@ custom_service_appstore_application_add (CustomServiceAppstore * appstore, const g_free(app); return; } + + /* We've got it, let's watch it for destruction */ + g_signal_connect(G_OBJECT(app->dbus_proxy), "destroy", G_CALLBACK(application_removed_cb), app); /* Grab the property proxy interface */ app->prop_proxy = dbus_g_proxy_new_for_name_owner(priv->bus, -- cgit v1.2.3