From 9aff9ba7149a1757f124db54599637801fa76ae6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 2 Nov 2009 19:52:47 -0600 Subject: Getting the name into a header. --- src/dbus-shared.h | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/dbus-shared.h (limited to 'src/dbus-shared.h') diff --git a/src/dbus-shared.h b/src/dbus-shared.h new file mode 100644 index 0000000..36436bd --- /dev/null +++ b/src/dbus-shared.h @@ -0,0 +1,3 @@ + +#define INDICATOR_CUSTOM_DBUS_ADDR "org.ayatana.indicator.custom" + -- cgit v1.2.3 From 10d1d2e0357629c137fa04c5436ab385eb46848b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 6 Nov 2009 12:25:29 -0600 Subject: Fleshing out connected to start bringing up the proxy. --- src/dbus-shared.h | 4 +++- src/indicator-custom.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) (limited to 'src/dbus-shared.h') diff --git a/src/dbus-shared.h b/src/dbus-shared.h index 36436bd..6cec06b 100644 --- a/src/dbus-shared.h +++ b/src/dbus-shared.h @@ -1,3 +1,5 @@ -#define INDICATOR_CUSTOM_DBUS_ADDR "org.ayatana.indicator.custom" +#define INDICATOR_CUSTOM_DBUS_ADDR "org.ayatana.indicator.custom" +#define INDICATOR_CUSTOM_DBUS_OBJ "/org/ayatana/indicator/custom/service" +#define INDICATOR_CUSTOM_DBUS_IFACE "org.ayatana.indicator.custom.service" diff --git a/src/indicator-custom.c b/src/indicator-custom.c index 8528a52..86eeffc 100644 --- a/src/indicator-custom.c +++ b/src/indicator-custom.c @@ -2,6 +2,8 @@ #include #include +#include + #include #include #include @@ -41,6 +43,8 @@ typedef struct _IndicatorCustomPrivate IndicatorCustomPrivate; struct _IndicatorCustomPrivate { IndicatorServiceManager * sm; + DBusGConnection * bus; + DBusGProxy * service_proxy; }; #define INDICATOR_CUSTOM_GET_PRIVATE(o) \ @@ -77,9 +81,14 @@ indicator_custom_init (IndicatorCustom *self) { IndicatorCustomPrivate * priv = INDICATOR_CUSTOM_GET_PRIVATE(self); + /* These are built in the connection phase */ + priv->bus = NULL; + priv->service_proxy = NULL; + priv->sm = indicator_service_manager_new(INDICATOR_CUSTOM_DBUS_ADDR); g_signal_connect(G_OBJECT(priv->sm), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(connected), self); + return; } @@ -93,6 +102,16 @@ indicator_custom_dispose (GObject *object) priv->sm = NULL; } + if (priv->bus != NULL) { + /* We're not incrementing the ref count on this one. */ + priv->bus = NULL; + } + + if (priv->service_proxy != NULL) { + g_object_unref(G_OBJECT(priv->service_proxy)); + priv->service_proxy = NULL; + } + G_OBJECT_CLASS (indicator_custom_parent_class)->dispose (object); return; } @@ -108,6 +127,26 @@ indicator_custom_finalize (GObject *object) void connected (IndicatorServiceManager * sm, gboolean connected, IndicatorCustom * custom) { + IndicatorCustomPrivate * priv = INDICATOR_CUSTOM_GET_PRIVATE(custom); + g_debug("Connected to Custom Indicator Service."); + + GError * error = NULL; + + if (priv->bus == NULL) { + priv->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; + } + } + + priv->service_proxy = dbus_g_proxy_new_for_name_owner(priv->bus, + INDICATOR_CUSTOM_DBUS_ADDR, + INDICATOR_CUSTOM_DBUS_OBJ, + INDICATOR_CUSTOM_DBUS_IFACE, + &error); 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 +++++++++++++++++++++-- src/dbus-shared.h | 12 +++++++++--- 2 files changed, 30 insertions(+), 5 deletions(-) (limited to 'src/dbus-shared.h') 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; } diff --git a/src/dbus-shared.h b/src/dbus-shared.h index 6cec06b..5c56e0b 100644 --- a/src/dbus-shared.h +++ b/src/dbus-shared.h @@ -1,5 +1,11 @@ -#define INDICATOR_CUSTOM_DBUS_ADDR "org.ayatana.indicator.custom" -#define INDICATOR_CUSTOM_DBUS_OBJ "/org/ayatana/indicator/custom/service" -#define INDICATOR_CUSTOM_DBUS_IFACE "org.ayatana.indicator.custom.service" +#define INDICATOR_CUSTOM_DBUS_ADDR "org.ayatana.indicator.custom" +#define INDICATOR_CUSTOM_DBUS_OBJ "/org/ayatana/indicator/custom/service" +#define INDICATOR_CUSTOM_DBUS_IFACE "org.ayatana.indicator.custom.service" + +#define NOTIFICATION_WATCHER_DBUS_OBJ "/org/ayatana/indicator/custom/NotificationWatcher" +#define NOTIFICATION_WATCHER_DBUS_IFACE "org.ayatana.indicator.custom.NotificationWatcher" + +#define NOTIFICATION_ITEM_DBUS_OBJ "/org/ayatana/indicator/custom/NotificationItem" +#define NOTIFICATION_ITEM_DBUS_IFACE "org.ayatana.indicator.custom.NotificationItem" -- 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 +++ src/dbus-shared.h | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src/dbus-shared.h') 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; } diff --git a/src/dbus-shared.h b/src/dbus-shared.h index 5c56e0b..364ac46 100644 --- a/src/dbus-shared.h +++ b/src/dbus-shared.h @@ -6,6 +6,5 @@ #define NOTIFICATION_WATCHER_DBUS_OBJ "/org/ayatana/indicator/custom/NotificationWatcher" #define NOTIFICATION_WATCHER_DBUS_IFACE "org.ayatana.indicator.custom.NotificationWatcher" -#define NOTIFICATION_ITEM_DBUS_OBJ "/org/ayatana/indicator/custom/NotificationItem" #define NOTIFICATION_ITEM_DBUS_IFACE "org.ayatana.indicator.custom.NotificationItem" -- cgit v1.2.3