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 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