aboutsummaryrefslogtreecommitdiff
path: root/src/custom-service-appstore.c
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-11-06 23:38:22 -0600
committerTed Gould <ted@canonical.com>2009-11-06 23:38:22 -0600
commitd0abddaaf72e621a495871e5805cd39a51891b2b (patch)
treed002a9321028c98bc975d37a5e666d110b312c9d /src/custom-service-appstore.c
parentffd996217a130a5252ca804c506205bbbbadef3a (diff)
downloadayatana-indicator-application-d0abddaaf72e621a495871e5805cd39a51891b2b.tar.gz
ayatana-indicator-application-d0abddaaf72e621a495871e5805cd39a51891b2b.tar.bz2
ayatana-indicator-application-d0abddaaf72e621a495871e5805cd39a51891b2b.zip
Grabbing the properties and going to town. Turning back into another signal.
Diffstat (limited to 'src/custom-service-appstore.c')
-rw-r--r--src/custom-service-appstore.c46
1 files changed, 45 insertions, 1 deletions
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 <dbus/dbus-glib.h>
#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;
}