From 925e3d8fea64fecdb16ce4a83750abb414f8687b Mon Sep 17 00:00:00 2001 From: Sense Hofstede Date: Thu, 8 Jul 2010 20:45:51 +0200 Subject: Removed all but one calls to the APPLICATION_SERVICE_APPSTORE_GET_PRIVATE() macro All references to the APPLICATION_SERVICE_APPSTORE_GET_PRIVATE() macro were removed from src/application-service-appstore.c. This makes this file comply with the recommended practise, which should reduce overhead. --- src/application-service-appstore.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 15abea3..886fe92 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -50,7 +50,6 @@ static gboolean _application_service_server_get_applications (ApplicationService #define NOTIFICATION_ITEM_SIG_NEW_STATUS "NewStatus" /* Private Stuff */ -typedef struct _ApplicationServiceAppstorePrivate ApplicationServiceAppstorePrivate; struct _ApplicationServiceAppstorePrivate { DBusGConnection * bus; GList * applications; @@ -139,7 +138,8 @@ application_service_appstore_class_init (ApplicationServiceAppstoreClass *klass) static void application_service_appstore_init (ApplicationServiceAppstore *self) { - ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(self); + + ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE_GET_PRIVATE (self); priv->applications = NULL; priv->lrufile = NULL; @@ -155,6 +155,8 @@ application_service_appstore_init (ApplicationServiceAppstore *self) dbus_g_connection_register_g_object(priv->bus, INDICATOR_APPLICATION_DBUS_OBJ, G_OBJECT(self)); + + self->priv = priv; return; } @@ -162,7 +164,7 @@ application_service_appstore_init (ApplicationServiceAppstore *self) static void application_service_appstore_dispose (GObject *object) { - ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(object); + ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE(object)->priv; while (priv->applications != NULL) { application_service_appstore_application_remove(APPLICATION_SERVICE_APPSTORE(object), @@ -209,7 +211,7 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err app->id = g_value_dup_string(g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_ID)); app->category = g_value_dup_string(g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_CATEGORY)); - ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(app->appstore); + ApplicationServiceAppstorePrivate * priv = app->appstore->priv; app_lru_file_touch(priv->lrufile, app->id, app->category); app->icon = g_value_dup_string(g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_ICON_NAME)); @@ -265,7 +267,7 @@ string_to_status(const gchar * status_string) static gint get_position (Application * app) { ApplicationServiceAppstore * appstore = app->appstore; - ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(appstore); + ApplicationServiceAppstorePrivate * priv = appstore->priv; GList * applistitem = g_list_find(priv->applications, app); if (applistitem == NULL) { @@ -384,7 +386,7 @@ apply_status (Application * app, AppIndicatorStatus status) g_debug("Changing app status to: %d", status); ApplicationServiceAppstore * appstore = app->appstore; - ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(appstore); + ApplicationServiceAppstorePrivate * priv = appstore->priv; /* This means we're going off line */ if (status == APP_INDICATOR_STATUS_PASSIVE) { @@ -567,7 +569,7 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst g_return_if_fail(IS_APPLICATION_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'); - ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(appstore); + ApplicationServiceAppstorePrivate * priv = appstore->priv; /* Build the application entry. This will be carried along until we're sure we've got everything. */ @@ -665,7 +667,7 @@ application_service_appstore_application_remove (ApplicationServiceAppstore * ap g_return_if_fail(dbus_name != NULL && dbus_name[0] != '\0'); g_return_if_fail(dbus_object != NULL && dbus_object[0] != '\0'); - ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(appstore); + ApplicationServiceAppstorePrivate * priv = appstore->priv; GList * listpntr; for (listpntr = priv->applications; listpntr != NULL; listpntr = g_list_next(listpntr)) { @@ -687,7 +689,7 @@ application_service_appstore_new (AppLruFile * lrufile) { g_return_val_if_fail(IS_APP_LRU_FILE(lrufile), NULL); ApplicationServiceAppstore * appstore = APPLICATION_SERVICE_APPSTORE(g_object_new(APPLICATION_SERVICE_APPSTORE_TYPE, NULL)); - ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(appstore); + ApplicationServiceAppstorePrivate * priv = appstore->priv; priv->lrufile = lrufile; return appstore; } @@ -696,7 +698,7 @@ application_service_appstore_new (AppLruFile * lrufile) static gboolean _application_service_server_get_applications (ApplicationServiceAppstore * appstore, GPtrArray ** apps, GError ** error) { - ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(appstore); + ApplicationServiceAppstorePrivate * priv = appstore->priv; *apps = g_ptr_array_new(); GList * listpntr; -- cgit v1.2.3 From d7c73248a5dccdb3929ed959f027366028ed757e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 9 Jul 2010 15:13:48 -0500 Subject: Adding a function to bring in approvers --- src/application-service-appstore.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 886fe92..340548f 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -745,3 +745,10 @@ _application_service_server_get_applications (ApplicationServiceAppstore * appst return TRUE; } +void +application_service_appstore_approver_add (ApplicationServiceAppstore * appstore, const gchar * dbus_name, const gchar * dbus_object) +{ + + return; +} + -- cgit v1.2.3 From 93572f1975170710345344512204e45e6eb3b145 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 9 Jul 2010 15:58:34 -0500 Subject: Adding some structures for approvers and making them real. --- src/application-service-appstore.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 340548f..335cd63 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -53,9 +53,15 @@ static gboolean _application_service_server_get_applications (ApplicationService struct _ApplicationServiceAppstorePrivate { DBusGConnection * bus; GList * applications; + GList * approvers; AppLruFile * lrufile; }; +typedef struct _Approver Approver; +struct _Approver { + DBusGProxy * proxy; +}; + typedef struct _Application Application; struct _Application { gchar * id; @@ -94,6 +100,7 @@ static void application_service_appstore_dispose (GObject *object); static void application_service_appstore_finalize (GObject *object); static AppIndicatorStatus string_to_status(const gchar * status_string); static void apply_status (Application * app, AppIndicatorStatus status); +void approver_free (gpointer papprover, gpointer user_data); G_DEFINE_TYPE (ApplicationServiceAppstore, application_service_appstore, G_TYPE_OBJECT); @@ -142,6 +149,7 @@ application_service_appstore_init (ApplicationServiceAppstore *self) ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE_GET_PRIVATE (self); priv->applications = NULL; + priv->approvers = NULL; priv->lrufile = NULL; GError * error = NULL; @@ -172,6 +180,12 @@ application_service_appstore_dispose (GObject *object) ((Application *)priv->applications->data)->dbus_object); } + if (priv->approvers != NULL) { + g_list_foreach(priv->approvers, approver_free, NULL); + g_list_free(priv->approvers); + priv->approvers = NULL; + } + G_OBJECT_CLASS (application_service_appstore_parent_class)->dispose (object); return; } @@ -745,6 +759,21 @@ _application_service_server_get_applications (ApplicationServiceAppstore * appst return TRUE; } +void +approver_free (gpointer papprover, gpointer user_data) +{ + Approver * approver = (Approver *)papprover; + g_return_if_fail(approver != NULL); + + if (approver->proxy != NULL) { + g_object_unref(approver->proxy); + approver->proxy = NULL; + } + + g_free(approver); + return; +} + void application_service_appstore_approver_add (ApplicationServiceAppstore * appstore, const gchar * dbus_name, const gchar * dbus_object) { -- cgit v1.2.3 From 4f7e748e6fc9a5b190b527b3089aa7bcffad092b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 9 Jul 2010 15:59:35 -0500 Subject: Comments --- src/application-service-appstore.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 335cd63..4b5004c 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -759,6 +759,7 @@ _application_service_server_get_applications (ApplicationServiceAppstore * appst return TRUE; } +/* Frees the data associated with an approver */ void approver_free (gpointer papprover, gpointer user_data) { @@ -774,6 +775,7 @@ approver_free (gpointer papprover, gpointer user_data) return; } +/* Adds a new approver to the app store */ void application_service_appstore_approver_add (ApplicationServiceAppstore * appstore, const gchar * dbus_name, const gchar * dbus_object) { -- cgit v1.2.3 From a281700349fbbcf9cc5df505c9d75b922da662a2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 9 Jul 2010 16:06:37 -0500 Subject: Building the approver structure and putting it in the list. --- src/application-service-appstore.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 4b5004c..e4c2d4c 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -779,6 +779,27 @@ approver_free (gpointer papprover, gpointer user_data) void application_service_appstore_approver_add (ApplicationServiceAppstore * appstore, const gchar * dbus_name, const gchar * dbus_object) { + g_return_if_fail(IS_APPLICATION_SERVICE_APPSTORE(appstore)); + g_return_if_fail(dbus_name != NULL); + g_return_if_fail(dbus_object != NULL); + ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE_GET_PRIVATE (appstore); + + Approver * approver = g_new0(Approver, 1); + + GError * error = NULL; + approver->proxy = dbus_g_proxy_new_for_name_owner(priv->bus, + dbus_name, + dbus_object, + NOTIFICATION_APPROVER_DBUS_IFACE, + &error); + if (error != NULL) { + g_warning("Unable to get approver interface on '%s:%s' : %s", dbus_name, dbus_object, error->message); + g_error_free(error); + g_free(approver); + return; + } + + priv->approvers = g_list_prepend(priv->approvers, approver); return; } -- cgit v1.2.3 From b3a0f3e22a8ec154dd738019fbf3dff346188aee Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 9 Jul 2010 16:16:48 -0500 Subject: Looking at all the applications when we get a new approver. --- src/application-service-appstore.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index e4c2d4c..3e4fd15 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -31,6 +31,7 @@ with this program. If not, see . #include "application-service-marshal.h" #include "dbus-properties-client.h" #include "dbus-shared.h" +#include "notification-approver-client.h" /* DBus Prototypes */ static gboolean _application_service_server_get_applications (ApplicationServiceAppstore * appstore, GPtrArray ** apps, GError ** error); @@ -100,7 +101,7 @@ static void application_service_appstore_dispose (GObject *object); static void application_service_appstore_finalize (GObject *object); static AppIndicatorStatus string_to_status(const gchar * status_string); static void apply_status (Application * app, AppIndicatorStatus status); -void approver_free (gpointer papprover, gpointer user_data); +static void approver_free (gpointer papprover, gpointer user_data); G_DEFINE_TYPE (ApplicationServiceAppstore, application_service_appstore, G_TYPE_OBJECT); @@ -760,7 +761,7 @@ _application_service_server_get_applications (ApplicationServiceAppstore * appst } /* Frees the data associated with an approver */ -void +static void approver_free (gpointer papprover, gpointer user_data) { Approver * approver = (Approver *)papprover; @@ -775,6 +776,33 @@ approver_free (gpointer papprover, gpointer user_data) return; } +/* What did the approver tell us? */ +static void +approver_request_cb (DBusGProxy *proxy, gboolean OUT_approved, GError *error, gpointer userdata) +{ + g_debug("Approver responded: %s", OUT_approved ? "approve" : "rejected"); + return; +} + +/* Run the applications through the new approver */ +static void +check_with_new_approver (gpointer papp, gpointer papprove) +{ + Application * app = (Application *)papp; + Approver * approver = (Approver *)papprove; + + org_ayatana_StatusNotifierApprover_approve_item_async(approver->proxy, + app->id, + app->category, + 0, + app->dbus_name, + app->dbus_object, + approver_request_cb, + app); + + return; +} + /* Adds a new approver to the app store */ void application_service_appstore_approver_add (ApplicationServiceAppstore * appstore, const gchar * dbus_name, const gchar * dbus_object) @@ -801,6 +829,8 @@ application_service_appstore_approver_add (ApplicationServiceAppstore * appstore priv->approvers = g_list_prepend(priv->approvers, approver); + g_list_foreach(priv->applications, check_with_new_approver, approver); + return; } -- cgit v1.2.3 From 306a78b6a438f0702d7f8475e726de53a7a7b66c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 9 Jul 2010 16:29:22 -0500 Subject: When we have new apps we can ask the approver about them. --- src/application-service-appstore.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 3e4fd15..311fcb1 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -102,6 +102,8 @@ static void application_service_appstore_finalize (GObject *object); static AppIndicatorStatus string_to_status(const gchar * status_string); static void apply_status (Application * app, AppIndicatorStatus status); static void approver_free (gpointer papprover, gpointer user_data); +static void check_with_new_approver (gpointer papp, gpointer papprove); +static void check_with_old_approver (gpointer papprove, gpointer papp); G_DEFINE_TYPE (ApplicationServiceAppstore, application_service_appstore, G_TYPE_OBJECT); @@ -251,11 +253,23 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err app->icon_path = g_strdup(""); } + /* TODO: Calling approvers, but we're ignoring the results. So, eh. */ + g_list_foreach(priv->approvers, check_with_old_approver, app); + apply_status(app, string_to_status(g_value_get_string(g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_STATUS)))); return; } +/* Check the application against an approver */ +static void +check_with_old_approver (gpointer papprove, gpointer papp) +{ + /* Funny the parallels, eh? */ + check_with_new_approver(papp, papprove); + return; +} + /* Simple translation function -- could be optimized */ static AppIndicatorStatus string_to_status(const gchar * status_string) -- cgit v1.2.3