From efd7be1cf7c80abc13c6d3bb3bc99cef18b8db7b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 19:59:38 -0500 Subject: Adding a count for the number of approvers that have approved the application. --- src/application-service-appstore.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 55906ff..83b64f3 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -85,6 +85,7 @@ struct _Application { gchar * label; gchar * guide; gboolean currently_free; + gint approved_by; }; #define APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(o) \ @@ -734,6 +735,7 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst app->label = NULL; app->guide = NULL; app->currently_free = FALSE; + app->approved_by = 0; /* Get the DBus proxy for the NotificationItem interface */ GError * error = NULL; -- cgit v1.2.3 From e8b76a6a10b53e0cc4d34895fb396a5bc9ab4c54 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 20:04:06 -0500 Subject: Changing to a list, we're going to need to track who so when they disconnect we can know the state change. --- src/application-service-appstore.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 83b64f3..9c34a79 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -85,7 +85,7 @@ struct _Application { gchar * label; gchar * guide; gboolean currently_free; - gint approved_by; + GList * approved_by; }; #define APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(o) \ @@ -735,7 +735,7 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst app->label = NULL; app->guide = NULL; app->currently_free = FALSE; - app->approved_by = 0; + app->approved_by = NULL; /* Get the DBus proxy for the NotificationItem interface */ GError * error = NULL; -- cgit v1.2.3 From fbdf4bfec6dad26c7b3ffdedd9f1616abf20f196 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 20:26:08 -0500 Subject: Managing the list with the approver returns. --- src/application-service-appstore.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 9c34a79..b2c18d4 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -949,6 +949,15 @@ static void approver_request_cb (DBusGProxy *proxy, gboolean OUT_approved, GError *error, gpointer userdata) { g_debug("Approver responded: %s", OUT_approved ? "approve" : "rejected"); + Application * app = (Application *)userdata; + + if (OUT_approved) { + app->approved_by = g_list_prepend(app->approved_by, proxy); + } else { + app->approved_by = g_list_remove(app->approved_by, proxy); + } + + /* TODO: Apply status */ return; } -- cgit v1.2.3 From a635d68dff58440961c12f1db6f998836b1c556f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 20:31:30 -0500 Subject: Adding a visible state entry to the application structure --- src/application-service-appstore.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index b2c18d4..c32cd5e 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -62,6 +62,12 @@ struct _ApplicationServiceAppstorePrivate { AppLruFile * lrufile; }; +typedef enum { + VISIBLE_STATE_HIDDEN, + VISIBLE_STATE_NORMAL, + VISIBLE_STATE_ATTENTION +} visible_state_t; + typedef struct _Approver Approver; struct _Approver { DBusGProxy * proxy; @@ -86,6 +92,7 @@ struct _Application { gchar * guide; gboolean currently_free; GList * approved_by; + visible_state_t visible_state; }; #define APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(o) \ @@ -736,6 +743,7 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst app->guide = NULL; app->currently_free = FALSE; app->approved_by = NULL; + app->visible_state = VISIBLE_STATE_HIDDEN; /* Get the DBus proxy for the NotificationItem interface */ GError * error = NULL; -- cgit v1.2.3 From ddd87466241652a8f889e7c27f6e6b6b31797450 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 20:33:01 -0500 Subject: Making sure to clean up the approved by list --- src/application-service-appstore.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index c32cd5e..d0723b9 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -405,6 +405,9 @@ application_free (Application * app) if (app->guide != NULL) { g_free(app->guide); } + if (app->approved_by != NULL) { + g_list_free(app->approved_by); + } g_free(app); return; -- cgit v1.2.3 From b7419c3d3e23ddc3be51f1d3c182360ffe76bf8d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 20:58:36 -0500 Subject: Changing the apply_status function to be less about applying the status and more about trying to apply a visual state that can be determined by things like approvers. This means that it doesn't get passed the status. --- src/application-service-appstore.c | 77 +++++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 30 deletions(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index d0723b9..bff4c77 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -116,7 +116,7 @@ static void application_service_appstore_init (ApplicationServiceAppstore 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); +static void apply_status (Application * app); 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); @@ -264,6 +264,8 @@ 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)); + app->status = string_to_status(g_value_get_string(g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_STATUS))); + ApplicationServiceAppstorePrivate * priv = app->appstore->priv; app_lru_file_touch(priv->lrufile, app->id, app->category); @@ -306,7 +308,7 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err /* 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)))); + apply_status(app); return; } @@ -421,13 +423,16 @@ application_removed_cb (DBusGProxy * proxy, gpointer userdata) Application * app = (Application *)userdata; /* Remove from the panel */ - apply_status(app, APP_INDICATOR_STATUS_PASSIVE); + app->status = APP_INDICATOR_STATUS_PASSIVE; + apply_status(app); /* Destroy the data */ application_free(app); return; } +/* Look and see if an application exists in the application + list already */ static gboolean can_add_application (GList *applications, Application *app) { @@ -466,49 +471,60 @@ app_sort_func (gconstpointer a, gconstpointer b, gpointer userdata) it removes it from the panel. If we're coming online, then it add it to the panel. Otherwise it changes the icon. */ static void -apply_status (Application * app, AppIndicatorStatus status) +apply_status (Application * app) { - if (app->status == status) { - return; - } - g_debug("Changing app status to: %d", status); - ApplicationServiceAppstore * appstore = app->appstore; ApplicationServiceAppstorePrivate * priv = appstore->priv; + visible_state_t goal_state = VISIBLE_STATE_HIDDEN; + + if (app->status != APP_INDICATOR_STATUS_PASSIVE && + g_list_length(app->approved_by) == g_list_length(priv->approvers)) { + if (app->status == APP_INDICATOR_STATUS_ACTIVE) { + goal_state = VISIBLE_STATE_NORMAL; + } else if (app->status == APP_INDICATOR_STATUS_ATTENTION) { + goal_state = VISIBLE_STATE_ATTENTION; + } + } + + /* Nothing needs to change, we're good */ + if (app->visible_state == goal_state) { + return; + } + /* This means we're going off line */ - if (status == APP_INDICATOR_STATUS_PASSIVE) { + if (goal_state == VISIBLE_STATE_HIDDEN) { gint position = get_position(app); if (position == -1) return; g_signal_emit(G_OBJECT(appstore), signals[APPLICATION_REMOVED], 0, position, TRUE); - priv->applications = g_list_remove(priv->applications, app); + priv->applications = g_list_remove(priv->applications, app); } else { /* Figure out which icon we should be using */ gchar * newicon = app->icon; - if (status == APP_INDICATOR_STATUS_ATTENTION && app->aicon != NULL && app->aicon[0] != '\0') { + if (goal_state == VISIBLE_STATE_ATTENTION && app->aicon != NULL && app->aicon[0] != '\0') { newicon = app->aicon; } /* Determine whether we're already shown or not */ - if (app->status == APP_INDICATOR_STATUS_PASSIVE) { - if (can_add_application (priv->applications, app)) { - /* Put on panel */ - priv->applications = g_list_insert_sorted_with_data (priv->applications, app, app_sort_func, priv->lrufile); - - g_signal_emit(G_OBJECT(app->appstore), - signals[APPLICATION_ADDED], 0, - newicon, - g_list_index(priv->applications, app), /* Position */ - app->dbus_name, - app->menu, - app->icon_theme_path, - app->label, - app->guide, - TRUE); - } + if (app->visible_state == VISIBLE_STATE_HIDDEN) { + if (can_add_application (priv->applications, app)) { + /* Put on panel */ + priv->applications = g_list_insert_sorted_with_data (priv->applications, app, app_sort_func, priv->lrufile); + + g_signal_emit(G_OBJECT(app->appstore), + signals[APPLICATION_ADDED], 0, + newicon, + g_list_index(priv->applications, app), /* Position */ + app->dbus_name, + app->menu, + app->icon_theme_path, + app->label, + app->guide, + TRUE); + } } else { /* Icon update */ gint position = get_position(app); @@ -520,7 +536,7 @@ apply_status (Application * app, AppIndicatorStatus status) } } - app->status = status; + app->visible_state = goal_state; return; } @@ -642,7 +658,8 @@ new_status (DBusGProxy * proxy, const gchar * status, gpointer data) Application * app = (Application *)data; if (!app->validated) return; - apply_status(app, string_to_status(status)); + app->status = string_to_status(status); + apply_status(app); return; } -- cgit v1.2.3 From ba6904978575157936f0fb3ce9fd4aa78ac740ee Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 21:15:58 -0500 Subject: Moving some TODOs --- src/application-service-appstore.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index bff4c77..6ee2c47 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -305,7 +305,6 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err app->guide = 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); @@ -985,7 +984,7 @@ approver_request_cb (DBusGProxy *proxy, gboolean OUT_approved, GError *error, gp app->approved_by = g_list_remove(app->approved_by, proxy); } - /* TODO: Apply status */ + apply_status(app); return; } -- cgit v1.2.3 From 4398a699958b13e6e5739520eb83f9530dd333f7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 21:30:44 -0500 Subject: Make it so that an approver that gets free'd gets removed from the applications list of approval. --- src/application-service-appstore.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 6ee2c47..5467f31 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -220,7 +220,7 @@ application_service_appstore_dispose (GObject *object) } if (priv->approvers != NULL) { - g_list_foreach(priv->approvers, approver_free, NULL); + g_list_foreach(priv->approvers, approver_free, object); g_list_free(priv->approvers); priv->approvers = NULL; } @@ -955,12 +955,27 @@ _application_service_server_get_applications (ApplicationServiceAppstore * appst return TRUE; } +/* Removes and approver from our list of approvers and + then sees if that changes our status. Most likely this + could make us visible if this approver rejected us. */ +static void +remove_approver (gpointer papp, gpointer pproxy) +{ + Application * app = (Application *)papp; + app->approved_by = g_list_remove(app->approved_by, pproxy); + apply_status(app); + return; +} + /* Frees the data associated with an approver */ static void approver_free (gpointer papprover, gpointer user_data) { Approver * approver = (Approver *)papprover; g_return_if_fail(approver != NULL); + + ApplicationServiceAppstore * appstore = APPLICATION_SERVICE_APPSTORE(user_data); + g_list_foreach(appstore->priv->applications, remove_approver, approver->proxy); if (approver->proxy != NULL) { g_object_unref(approver->proxy); -- cgit v1.2.3 From 0db4eb579e37326484df53ff9dab3a4a6b6a8b40 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 21:48:54 -0500 Subject: Switching a few status checks to look at the visible state --- src/application-service-appstore.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 5467f31..f5b2db4 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -565,7 +565,7 @@ new_icon_cb (DBusGProxy * proxy, GValue value, GError * error, gpointer userdata if (app->icon != NULL) g_free(app->icon); app->icon = g_strdup(newicon); - if (app->status == APP_INDICATOR_STATUS_ACTIVE) { + if (app->visible_state == VISIBLE_STATE_NORMAL) { gint position = get_position(app); if (position == -1) return; @@ -603,7 +603,7 @@ new_aicon_cb (DBusGProxy * proxy, GValue value, GError * error, gpointer userdat if (app->aicon != NULL) g_free(app->aicon); app->aicon = g_strdup(newicon); - if (app->status == APP_INDICATOR_STATUS_ATTENTION) { + if (app->visible_state == VISIBLE_STATE_ATTENTION) { gint position = get_position(app); if (position == -1) return; @@ -676,7 +676,7 @@ new_icon_theme_path (DBusGProxy * proxy, const gchar * icon_theme_path, gpointer if (app->icon_theme_path != NULL) g_free(app->icon_theme_path); app->icon_theme_path = g_strdup(icon_theme_path); - if (app->status == APP_INDICATOR_STATUS_ACTIVE) { + if (app->visible_state != VISIBLE_STATE_HIDDEN) { gint position = get_position(app); if (position == -1) return; -- cgit v1.2.3 From 360e8a40e548f5080193dd60d9c7fd5c2fb50089 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 21:52:43 -0500 Subject: Simplifying the visual state to just be shown/hidden while letting the status show which icon is shown. --- src/application-service-appstore.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index f5b2db4..0991286 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -64,8 +64,7 @@ struct _ApplicationServiceAppstorePrivate { typedef enum { VISIBLE_STATE_HIDDEN, - VISIBLE_STATE_NORMAL, - VISIBLE_STATE_ATTENTION + VISIBLE_STATE_SHOWN } visible_state_t; typedef struct _Approver Approver; @@ -479,11 +478,7 @@ apply_status (Application * app) if (app->status != APP_INDICATOR_STATUS_PASSIVE && g_list_length(app->approved_by) == g_list_length(priv->approvers)) { - if (app->status == APP_INDICATOR_STATUS_ACTIVE) { - goal_state = VISIBLE_STATE_NORMAL; - } else if (app->status == APP_INDICATOR_STATUS_ATTENTION) { - goal_state = VISIBLE_STATE_ATTENTION; - } + goal_state = VISIBLE_STATE_SHOWN; } /* Nothing needs to change, we're good */ @@ -503,7 +498,7 @@ apply_status (Application * app) } else { /* Figure out which icon we should be using */ gchar * newicon = app->icon; - if (goal_state == VISIBLE_STATE_ATTENTION && app->aicon != NULL && app->aicon[0] != '\0') { + if (app->status == APP_INDICATOR_STATUS_ATTENTION && app->aicon != NULL && app->aicon[0] != '\0') { newicon = app->aicon; } @@ -565,7 +560,7 @@ new_icon_cb (DBusGProxy * proxy, GValue value, GError * error, gpointer userdata if (app->icon != NULL) g_free(app->icon); app->icon = g_strdup(newicon); - if (app->visible_state == VISIBLE_STATE_NORMAL) { + if (app->visible_state == VISIBLE_STATE_SHOWN && app->status == APP_INDICATOR_STATUS_ACTIVE) { gint position = get_position(app); if (position == -1) return; @@ -603,7 +598,7 @@ new_aicon_cb (DBusGProxy * proxy, GValue value, GError * error, gpointer userdat if (app->aicon != NULL) g_free(app->aicon); app->aicon = g_strdup(newicon); - if (app->visible_state == VISIBLE_STATE_ATTENTION) { + if (app->visible_state == VISIBLE_STATE_SHOWN && app->status == APP_INDICATOR_STATUS_ATTENTION) { gint position = get_position(app); if (position == -1) return; -- cgit v1.2.3 From d72265317345f41ea39f306c149fcf098ba1194e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 22:12:40 -0500 Subject: Handle the proxy being destroyed, and cleaning up the approver. --- src/application-service-appstore.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 0991286..00de4b9 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -1017,6 +1017,42 @@ check_with_new_approver (gpointer papp, gpointer papprove) return; } +/* Look through all the approvers and find the one with a given + proxy. */ +static gint +approver_find_by_proxy (gconstpointer papprover, gconstpointer pproxy) +{ + Approver * approver = (Approver *)papprover; + + if (approver->proxy == pproxy) { + return 0; + } + + return -1; +} + +/* Tracks when a proxy gets destroyed so that we know that the + approver has dropped off the bus. */ +static void +approver_destroyed (gpointer pproxy, gpointer pappstore) +{ + ApplicationServiceAppstore * appstore = APPLICATION_SERVICE_APPSTORE(pappstore); + + GList * lapprover = g_list_find_custom(appstore->priv->approvers, pproxy, approver_find_by_proxy); + if (lapprover == NULL) { + g_warning("Approver proxy died, but we don't seem to have that approver."); + return; + } + + Approver * approver = (Approver *)lapprover->data; + approver->proxy = NULL; + + appstore->priv->approvers = g_list_remove(appstore->priv->approvers, approver); + approver_free(approver, appstore); + + 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) @@ -1041,6 +1077,8 @@ application_service_appstore_approver_add (ApplicationServiceAppstore * appstore return; } + g_signal_connect(G_OBJECT(approver->proxy), "destroy", G_CALLBACK(approver_destroyed), appstore); + priv->approvers = g_list_prepend(priv->approvers, approver); g_list_foreach(priv->applications, check_with_new_approver, approver); -- cgit v1.2.3 From fa45eaa48e679ddf2c264185e624723a7c1c27ac Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 22:22:24 -0500 Subject: Switching the get_position() function to look at the visibility of the applications. --- src/application-service-appstore.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 00de4b9..1b10033 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -342,18 +342,34 @@ string_to_status(const gchar * status_string) } /* A small helper function to get the position of an application - in the app list. */ + in the app list of the applications that are visible. */ static gint get_position (Application * app) { ApplicationServiceAppstore * appstore = app->appstore; ApplicationServiceAppstorePrivate * priv = appstore->priv; - GList * applistitem = g_list_find(priv->applications, app); - if (applistitem == NULL) { - return -1; + GList * lapp; + gint count; + + /* Go through the list and try to find ours */ + for (lapp = priv->applications, count = 0; lapp != NULL; lapp = g_list_next(lapp), count++) { + if (lapp->data == app) { + break; + } + + /* If the selected app isn't visible let's not + count it's position */ + Application * thisapp = (Application *)(lapp->data); + if (thisapp->visible_state == VISIBLE_STATE_HIDDEN) { + count--; + } } - return g_list_position(priv->applications, applistitem); + if (lapp == NULL) { + return -1; + } + + return count; } /* A simple global function for dealing with freeing the information -- cgit v1.2.3 From 98252b227acb7d969aed26490dab7cba13298a7c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 22:26:47 -0500 Subject: Making sure to only list the visible applications. --- src/application-service-appstore.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 1b10033..6e666bc 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -914,6 +914,10 @@ _application_service_server_get_applications (ApplicationServiceAppstore * appst for (listpntr = priv->applications; listpntr != NULL; listpntr = g_list_next(listpntr)) { Application * app = (Application *)listpntr->data; + if (app->visible_state == VISIBLE_STATE_HIDDEN) { + continue; + } + GValueArray * values = g_value_array_new(5); GValue value = {0}; -- cgit v1.2.3 From 7a4bfc9135ea55b0f495513fbd7ad2734b328098 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 22:31:25 -0500 Subject: Changing it so that the list of applications has all the applications in it, independent of visible state. --- src/application-service-appstore.c | 56 ++++++++++---------------------------- 1 file changed, 15 insertions(+), 41 deletions(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 6e666bc..4ba2aca 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -114,6 +114,7 @@ static void application_service_appstore_class_init (ApplicationServiceAppstoreC static void application_service_appstore_init (ApplicationServiceAppstore *self); static void application_service_appstore_dispose (GObject *object); static void application_service_appstore_finalize (GObject *object); +static gint app_sort_func (gconstpointer a, gconstpointer b, gpointer userdata); static AppIndicatorStatus string_to_status(const gchar * status_string); static void apply_status (Application * app); static void approver_free (gpointer papprover, gpointer user_data); @@ -244,6 +245,7 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err { if (error != NULL) { g_warning("Unable to get properties: %s", error->message); + /* TODO: We need to free all the application data here */ return; } @@ -304,6 +306,7 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err app->guide = g_strdup(""); } + priv->applications = g_list_insert_sorted_with_data (priv->applications, app, app_sort_func, priv->lrufile); g_list_foreach(priv->approvers, check_with_old_approver, app); apply_status(app); @@ -445,30 +448,6 @@ application_removed_cb (DBusGProxy * proxy, gpointer userdata) return; } -/* Look and see if an application exists in the application - list already */ -static gboolean -can_add_application (GList *applications, Application *app) -{ - if (applications) - { - GList *l = NULL; - - for (l = applications; l != NULL; l = g_list_next (l)) - { - Application *tmp_app = (Application *)l->data; - - if (g_strcmp0 (tmp_app->dbus_name, app->dbus_name) == 0 && - g_strcmp0 (tmp_app->dbus_object, app->dbus_object) == 0) - { - return FALSE; - } - } - } - - return TRUE; -} - /* This function takes two Application structure pointers and uses the lrufile to compare them. */ static gint @@ -510,7 +489,6 @@ apply_status (Application * app) g_signal_emit(G_OBJECT(appstore), signals[APPLICATION_REMOVED], 0, position, TRUE); - priv->applications = g_list_remove(priv->applications, app); } else { /* Figure out which icon we should be using */ gchar * newicon = app->icon; @@ -520,21 +498,17 @@ apply_status (Application * app) /* Determine whether we're already shown or not */ if (app->visible_state == VISIBLE_STATE_HIDDEN) { - if (can_add_application (priv->applications, app)) { - /* Put on panel */ - priv->applications = g_list_insert_sorted_with_data (priv->applications, app, app_sort_func, priv->lrufile); - - g_signal_emit(G_OBJECT(app->appstore), - signals[APPLICATION_ADDED], 0, - newicon, - g_list_index(priv->applications, app), /* Position */ - app->dbus_name, - app->menu, - app->icon_theme_path, - app->label, - app->guide, - TRUE); - } + /* Put on panel */ + g_signal_emit(G_OBJECT(app->appstore), + signals[APPLICATION_ADDED], 0, + newicon, + g_list_index(priv->applications, app), /* Position */ + app->dbus_name, + app->menu, + app->icon_theme_path, + app->label, + app->guide, + TRUE); } else { /* Icon update */ gint position = get_position(app); @@ -867,7 +841,7 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst } /* Removes an application. Currently only works for the apps - that are shown. /TODO Need to fix that. */ + that are shown. */ void application_service_appstore_application_remove (ApplicationServiceAppstore * appstore, const gchar * dbus_name, const gchar * dbus_object) { -- cgit v1.2.3 From eadc69dd38700b68d314bc30d9a78e8400c22042 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 13 Aug 2010 09:50:46 -0500 Subject: Freeing the allocated keys. --- src/application-service-appstore.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 4ac1576..9764798 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -298,6 +298,7 @@ load_override_file (GHashTable * hash, const gchar * filename) g_hash_table_insert(hash, g_strdup(key), GINT_TO_POINTER(val)); } + g_strfreev(keys); g_key_file_free(keyfile); return; -- cgit v1.2.3 From c04a7cf4f33a7079be7718b72c5408f51f225ca3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 13 Aug 2010 12:24:11 -0500 Subject: Uhg, broken merge. --- src/application-service-appstore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 57c4671..771f2af 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -392,7 +392,7 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err app->guide = g_strdup(""); } - priv->applications = g_list_insert_sorted_with_data (priv->applications, app, app_sort_func, priv->lrufile); + priv->applications = g_list_insert_sorted_with_data (priv->applications, app, app_sort_func, NULL); g_list_foreach(priv->approvers, check_with_old_approver, app); apply_status(app); -- cgit v1.2.3 From a0023d1bfb43aeb51d7b259dfc23c32139c8b14c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 13 Aug 2010 14:01:38 -0500 Subject: Responding to approver errors like they're approval. --- src/application-service-appstore.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 771f2af..056f0e1 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -1083,10 +1083,15 @@ approver_free (gpointer papprover, gpointer user_data) static void approver_request_cb (DBusGProxy *proxy, gboolean OUT_approved, GError *error, gpointer userdata) { - g_debug("Approver responded: %s", OUT_approved ? "approve" : "rejected"); + if (error == NULL) { + g_debug("Approver responded: %s", OUT_approved ? "approve" : "rejected"); + } else { + g_debug("Approver responded error: %s", error->message); + } + Application * app = (Application *)userdata; - if (OUT_approved) { + if (OUT_approved || error != NULL) { app->approved_by = g_list_prepend(app->approved_by, proxy); } else { app->approved_by = g_list_remove(app->approved_by, proxy); -- cgit v1.2.3 From ba5b85a76a469fb5fa860a723ffd09c939bc7f0e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 13 Aug 2010 14:01:57 -0500 Subject: Making sure to remove our applications from the list as well. --- src/application-service-appstore.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 056f0e1..73fc5d1 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -551,6 +551,9 @@ application_removed_cb (DBusGProxy * proxy, gpointer userdata) app->status = APP_INDICATOR_STATUS_PASSIVE; apply_status(app); + /* Remove from the application list */ + app->appstore->priv->applications = g_list_remove(app->appstore->priv->applications, app); + /* Destroy the data */ application_free(app); return; -- cgit v1.2.3 From 93f92e8e6a6bda708d227f3ebe9c8dae15694b9e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 16 Aug 2010 12:41:02 -0500 Subject: Making the list so that if there are errors we handle them well. --- src/application-service-appstore.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 73fc5d1..85d72f7 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -578,10 +578,12 @@ apply_status (Application * app) ApplicationServiceAppstore * appstore = app->appstore; ApplicationServiceAppstorePrivate * priv = appstore->priv; + g_debug("Applying status. Status: %d Approved by: %d Approvers: %d Visible: %d", app->status, g_list_length(app->approved_by), g_list_length(priv->approvers), app->visible_state); + visible_state_t goal_state = VISIBLE_STATE_HIDDEN; if (app->status != APP_INDICATOR_STATUS_PASSIVE && - g_list_length(app->approved_by) == g_list_length(priv->approvers)) { + g_list_length(app->approved_by) >= g_list_length(priv->approvers)) { goal_state = VISIBLE_STATE_SHOWN; } -- cgit v1.2.3 From fb1811ef2421e512b49bc5bb5c2796ba669ca29f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 16 Aug 2010 12:42:41 -0500 Subject: Making it so that we don't set the proxy to null right away. --- src/application-service-appstore.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 85d72f7..9f1920d 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -75,6 +75,7 @@ typedef enum { typedef struct _Approver Approver; struct _Approver { DBusGProxy * proxy; + gboolean destroy_by_proxy; }; typedef struct _Application Application; @@ -1076,7 +1077,9 @@ approver_free (gpointer papprover, gpointer user_data) g_list_foreach(appstore->priv->applications, remove_approver, approver->proxy); if (approver->proxy != NULL) { - g_object_unref(approver->proxy); + if (!approver->destroy_by_proxy) { + g_object_unref(approver->proxy); + } approver->proxy = NULL; } @@ -1153,7 +1156,7 @@ approver_destroyed (gpointer pproxy, gpointer pappstore) } Approver * approver = (Approver *)lapprover->data; - approver->proxy = NULL; + approver->destroy_by_proxy = TRUE; appstore->priv->approvers = g_list_remove(appstore->priv->approvers, approver); approver_free(approver, appstore); @@ -1171,6 +1174,7 @@ application_service_appstore_approver_add (ApplicationServiceAppstore * appstore ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE_GET_PRIVATE (appstore); Approver * approver = g_new0(Approver, 1); + approver->destroy_by_proxy = FALSE; GError * error = NULL; approver->proxy = dbus_g_proxy_new_for_name_owner(priv->bus, -- cgit v1.2.3 From 72c93f2c3aea90bc18a694a723915f33701a021b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 16 Aug 2010 12:43:38 -0500 Subject: Commenting out debug message --- src/application-service-appstore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 9f1920d..30af2ea 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -579,7 +579,7 @@ apply_status (Application * app) ApplicationServiceAppstore * appstore = app->appstore; ApplicationServiceAppstorePrivate * priv = appstore->priv; - g_debug("Applying status. Status: %d Approved by: %d Approvers: %d Visible: %d", app->status, g_list_length(app->approved_by), g_list_length(priv->approvers), app->visible_state); + /* g_debug("Applying status. Status: %d Approved by: %d Approvers: %d Visible: %d", app->status, g_list_length(app->approved_by), g_list_length(priv->approvers), app->visible_state); */ visible_state_t goal_state = VISIBLE_STATE_HIDDEN; -- cgit v1.2.3 From 1d51365ac7ecc5299f49c1c8a1985caa16a125c9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 18 Aug 2010 10:27:53 -0500 Subject: XAyatana the register interface --- src/notification-watcher.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notification-watcher.xml b/src/notification-watcher.xml index cc7882d..5f19dd2 100644 --- a/src/notification-watcher.xml +++ b/src/notification-watcher.xml @@ -22,7 +22,7 @@ - + -- cgit v1.2.3 From a1e4f99efd90621eb9615ca761e65a37f941cbe8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 18 Aug 2010 10:29:09 -0500 Subject: Changing function name as well. --- src/application-service-watcher.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/application-service-watcher.c b/src/application-service-watcher.c index 4fe3bc7..5b77620 100644 --- a/src/application-service-watcher.c +++ b/src/application-service-watcher.c @@ -34,7 +34,7 @@ static gboolean _notification_watcher_server_register_status_notifier_item (Appl static gboolean _notification_watcher_server_registered_status_notifier_items (ApplicationServiceWatcher * appwatcher, GArray ** apps); static gboolean _notification_watcher_server_protocol_version (ApplicationServiceWatcher * appwatcher, char ** version); static gboolean _notification_watcher_server_register_notification_host (ApplicationServiceWatcher * appwatcher, const gchar * host); -static gboolean _notification_watcher_server_register_notification_approver (ApplicationServiceWatcher * appwatcher, const gchar * path, const GArray * categories, DBusGMethodInvocation * method); +static gboolean _notification_watcher_server_x_ayatana_register_notification_approver (ApplicationServiceWatcher * appwatcher, const gchar * path, const GArray * categories, DBusGMethodInvocation * method); static gboolean _notification_watcher_server_is_notification_host_registered (ApplicationServiceWatcher * appwatcher, gboolean * haveHost); static void get_name_cb (DBusGProxy * proxy, guint status, GError * error, gpointer data); @@ -252,7 +252,7 @@ get_name_cb (DBusGProxy * proxy, guint status, GError * error, gpointer data) } static gboolean -_notification_watcher_server_register_notification_approver (ApplicationServiceWatcher * appwatcher, const gchar * path, const GArray * categories, DBusGMethodInvocation * method) +_notification_watcher_server_x_ayatana_register_notification_approver (ApplicationServiceWatcher * appwatcher, const gchar * path, const GArray * categories, DBusGMethodInvocation * method) { ApplicationServiceWatcherPrivate * priv = APPLICATION_SERVICE_WATCHER_GET_PRIVATE(appwatcher); -- cgit v1.2.3 From 12c8cd4a0caa402426b23adad343e83d05d27d3f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 18 Aug 2010 10:31:20 -0500 Subject: Adding a signal to the approver interface --- src/notification-approver.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/notification-approver.xml b/src/notification-approver.xml index b1e69b9..4a8e39b 100644 --- a/src/notification-approver.xml +++ b/src/notification-approver.xml @@ -18,5 +18,12 @@ + + + + + + + -- cgit v1.2.3 From ca213633c7a98b7d9dd37a5a373f7ef825098eeb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 18 Aug 2010 14:02:47 -0500 Subject: Connecting into the signal coming from the approver --- src/application-service-appstore.c | 29 +++++++++++++++++++++++++++++ src/application-service-marshal.list | 1 + 2 files changed, 30 insertions(+) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 30af2ea..789ca48 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -183,6 +183,12 @@ application_service_appstore_class_init (ApplicationServiceAppstoreClass *klass) G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_object_register_marshaller(_application_service_marshal_VOID__BOOLEAN_STRING_OBJECT, + G_TYPE_NONE, + G_TYPE_BOOLEAN, + G_TYPE_STRING, + G_TYPE_OBJECT, + G_TYPE_INVALID); dbus_g_object_type_install_info(APPLICATION_SERVICE_APPSTORE_TYPE, &dbus_glib__application_service_server_object_info); @@ -1164,6 +1170,17 @@ approver_destroyed (gpointer pproxy, gpointer pappstore) return; } +/* A signal when an approver changes the why that it thinks about + a particular indicator. */ +void +approver_revise_judgement (DBusGProxy * proxy, gboolean new_status, gchar * address, DBusGProxy * get_path, gpointer user_data) +{ + ApplicationServiceAppstore * appstore = APPLICATION_SERVICE_APPSTORE(user_data); + appstore = NULL; + + 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) @@ -1191,6 +1208,18 @@ application_service_appstore_approver_add (ApplicationServiceAppstore * appstore g_signal_connect(G_OBJECT(approver->proxy), "destroy", G_CALLBACK(approver_destroyed), appstore); + dbus_g_proxy_add_signal(approver->proxy, + "ReviseJudgement", + G_TYPE_BOOLEAN, + G_TYPE_STRING, + DBUS_TYPE_G_OBJECT_PATH, + G_TYPE_INVALID); + dbus_g_proxy_connect_signal(approver->proxy, + "ReviseJudgement", + G_CALLBACK(approver_revise_judgement), + appstore, + NULL); + priv->approvers = g_list_prepend(priv->approvers, approver); g_list_foreach(priv->applications, check_with_new_approver, approver); diff --git a/src/application-service-marshal.list b/src/application-service-marshal.list index f432028..2b2efa5 100644 --- a/src/application-service-marshal.list +++ b/src/application-service-marshal.list @@ -20,3 +20,4 @@ VOID: STRING, INT, STRING, STRING, STRING, STRING, STRING VOID: INT, STRING, STRING VOID: INT, STRING VOID: STRING, STRING +VOID: BOOL, STRING, OBJECT -- cgit v1.2.3 From 1865cf3b4e415dcb8b9cf85208ab88596d00b043 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 18 Aug 2010 14:26:10 -0500 Subject: Refactor so that there is a function to look for applications. --- src/application-service-appstore.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 789ca48..7040b2a 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -959,6 +959,24 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst return; } +/* Looks for an application in the list of applications */ +static Application * +find_application (ApplicationServiceAppstore * appstore, const gchar * address, const gchar * object) +{ + ApplicationServiceAppstorePrivate * priv = appstore->priv; + GList * listpntr; + + for (listpntr = priv->applications; listpntr != NULL; listpntr = g_list_next(listpntr)) { + Application * app = (Application *)listpntr->data; + + if (!g_strcmp0(app->dbus_name, address) && !g_strcmp0(app->dbus_object, object)) { + return app; + } + } + + return NULL; +} + /* Removes an application. Currently only works for the apps that are shown. */ void @@ -968,16 +986,11 @@ 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 = appstore->priv; - GList * listpntr; - - for (listpntr = priv->applications; listpntr != NULL; listpntr = g_list_next(listpntr)) { - Application * app = (Application *)listpntr->data; - - if (!g_strcmp0(app->dbus_name, dbus_name) && !g_strcmp0(app->dbus_object, dbus_object)) { - application_removed_cb(NULL, app); - break; /* NOTE: Must break as the list will become inconsistent */ - } + Application * app = find_application(appstore, dbus_name, dbus_object); + if (app != NULL) { + application_removed_cb(NULL, app); + } else { + g_warning("Unable to find application %s:%s", dbus_name, dbus_object); } return; -- cgit v1.2.3 From 9fc60ae8675fe81a3c051e5f4de0378ecfd75069 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 18 Aug 2010 14:26:38 -0500 Subject: Flesh out the revise judgement handler to update the list of approvers. --- src/application-service-appstore.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 7040b2a..2d77d28 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -1188,8 +1188,27 @@ approver_destroyed (gpointer pproxy, gpointer pappstore) void approver_revise_judgement (DBusGProxy * proxy, gboolean new_status, gchar * address, DBusGProxy * get_path, gpointer user_data) { + g_return_if_fail(IS_APPLICATION_SERVICE_APPSTORE(user_data)); + g_return_if_fail(address != NULL && address[0] != '\0'); + g_return_if_fail(get_path != NULL); + const gchar * path = dbus_g_proxy_get_path(get_path); + g_return_if_fail(path != NULL && path[0] != '\0'); + ApplicationServiceAppstore * appstore = APPLICATION_SERVICE_APPSTORE(user_data); - appstore = NULL; + + Application * app = find_application(appstore, address, path); + + if (app == NULL) { + g_warning("Unable to update approver status of application (%s:%s) as it was not found", address, path); + return; + } + + if (new_status) { + app->approved_by = g_list_prepend(app->approved_by, proxy); + } else { + app->approved_by = g_list_remove(app->approved_by, proxy); + } + apply_status(app); return; } -- cgit v1.2.3 From ced17927880fc723477afd0a7ee4be7aee9eac32 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 19 Aug 2010 13:56:42 -0500 Subject: Fix approver for function change --- tests/test-approver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-approver.c b/tests/test-approver.c index bc25761..2665505 100644 --- a/tests/test-approver.c +++ b/tests/test-approver.c @@ -128,7 +128,7 @@ check_for_service (gpointer user_data) NOTIFICATION_WATCHER_DBUS_IFACE); g_debug("Registering Approver"); - org_kde_StatusNotifierWatcher_register_notification_approver_async (proxy, APPROVER_PATH, &cats, register_cb, NULL); + org_kde_StatusNotifierWatcher_x_ayatana_register_notification_approver_async (proxy, APPROVER_PATH, &cats, register_cb, NULL); return FALSE; } -- cgit v1.2.3 From b51c1debf9807ad357564975c394badbafccaa1b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 19 Aug 2010 13:56:53 -0500 Subject: 0.2.5 --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 0b57308..035c9da 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(indicator-application, 0.2.4, ted@canonical.com) +AC_INIT(indicator-application, 0.2.5, ted@canonical.com) AC_COPYRIGHT([Copyright 2009, 2010 Canonical]) AC_PREREQ(2.53) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(indicator-application, 0.2.4) +AM_INIT_AUTOMAKE(indicator-application, 0.2.5) AM_MAINTAINER_MODE -- cgit v1.2.3