diff options
author | Ted Gould <ted@canonical.com> | 2009-01-16 00:01:50 -0600 |
---|---|---|
committer | Ted Gould <ted@canonical.com> | 2009-01-16 00:01:50 -0600 |
commit | df1713a31e272324244419c0b7b6fbf9b3179069 (patch) | |
tree | 74f95250e94e33ed40bde5c636f6063fb0c11e80 /libindicate | |
parent | ad1cc2dcd28d83bd83ac7ad8f5d97f70546ea900 (diff) | |
download | libayatana-indicator-df1713a31e272324244419c0b7b6fbf9b3179069.tar.gz libayatana-indicator-df1713a31e272324244419c0b7b6fbf9b3179069.tar.bz2 libayatana-indicator-df1713a31e272324244419c0b7b6fbf9b3179069.zip |
Handling the case that we're destroying an entry because the bus told us to. Properly signalling all of the removals
Diffstat (limited to 'libindicate')
-rw-r--r-- | libindicate/listener.c | 48 |
1 files changed, 44 insertions, 4 deletions
diff --git a/libindicate/listener.c b/libindicate/listener.c index 5baa36f..bf613d6 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -213,20 +213,60 @@ dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, c if (prev != NULL && prev[0] == '\0') { todo_list_add(name, proxy, listener); } + if (new != NULL && new[0] == '\0') { + proxy_t * proxyt; + proxyt = g_hash_table_lookup(listener->proxies_working, name); + if (proxyt != NULL) { + g_hash_table_remove(listener->proxies_working, name); + proxy_struct_destroy(proxyt); + } + proxyt = g_hash_table_lookup(listener->proxies_possible, name); + if (proxyt != NULL) { + g_hash_table_remove(listener->proxies_possible, name); + proxy_struct_destroy(proxyt); + } + } return; } static void -proxy_struct_destroy (gpointer data) +proxy_struct_destroy_indicators (gpointer key, gpointer value, gpointer data) { + gchar * type = (gchar *)key; + GHashTable * indicators = (GHashTable *)value; proxy_t * proxy_data = data; - g_object_unref(proxy_data->proxy); - g_free(proxy_data->name); + GList * keys = g_hash_table_get_keys(indicators); + GList * indicator; + for (indicator = keys; indicator != NULL; indicator = indicator->next) { + guint id = (guint)indicator->data; + g_signal_emit(proxy_data->listener, signals[INDICATOR_REMOVED], 0, proxy_data->name, id, type, TRUE); + } + g_list_free(keys); + + g_hash_table_remove_all(indicators); + return; +} + +static void +proxy_struct_destroy (gpointer data) +{ + proxy_t * proxy_data = data; /* TODO: Clear the indicators by signaling */ - /* TODO: Remove from the appropriate listener hash */ + if (proxy_data->indicators != NULL) { + g_hash_table_foreach(proxy_data->indicators, + proxy_struct_destroy_indicators, + proxy_data); + g_hash_table_remove_all(proxy_data->indicators); + + g_signal_emit(proxy_data->listener, signals[SERVER_REMOVED], 0, proxy_data->name, TRUE); + proxy_data->indicators = NULL; + } + + g_free(proxy_data->name); + g_free(proxy_data); return; } |