diff options
author | Ted Gould <ted@gould.cx> | 2010-08-11 22:12:40 -0500 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2010-08-11 22:12:40 -0500 |
commit | d72265317345f41ea39f306c149fcf098ba1194e (patch) | |
tree | be2966862864ac51d4d11ea8c7522c4ed8c837a9 | |
parent | 360e8a40e548f5080193dd60d9c7fd5c2fb50089 (diff) | |
download | ayatana-indicator-application-d72265317345f41ea39f306c149fcf098ba1194e.tar.gz ayatana-indicator-application-d72265317345f41ea39f306c149fcf098ba1194e.tar.bz2 ayatana-indicator-application-d72265317345f41ea39f306c149fcf098ba1194e.zip |
Handle the proxy being destroyed, and cleaning up the approver.
-rw-r--r-- | src/application-service-appstore.c | 38 |
1 files changed, 38 insertions, 0 deletions
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); |