summaryrefslogtreecommitdiff
path: root/salut
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2011-04-19 11:04:08 +0100
committerJonny Lamb <jonny.lamb@collabora.co.uk>2011-04-19 11:04:08 +0100
commita06f0e7cff4afac90f69057e31b80d52a896121b (patch)
tree69328053cca12cff68765c60a823e37312e4e75f /salut
parent34555aa5d322785704b174b4ec3ecfb0a4023b47 (diff)
status: clean up the hash table and remove rubbish if a status is unset
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
Diffstat (limited to 'salut')
-rw-r--r--salut/status.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/salut/status.c b/salut/status.c
index 798361d..8395419 100644
--- a/salut/status.c
+++ b/salut/status.c
@@ -197,8 +197,23 @@ update_contact_status (YtstStatus *self,
* a problem, but let's be nice. */
emit = tp_strdiff (old_status, status_str);
- g_hash_table_insert (service_status_map, g_strdup (service_name),
- g_strdup (status_str));
+ if (status_str != NULL)
+ {
+ g_hash_table_insert (service_status_map, g_strdup (service_name),
+ g_strdup (status_str));
+ }
+ else
+ {
+ /* remove the service from the service status map */
+ g_hash_table_remove (service_status_map, service_name);
+
+ /* now run along up the hash table cleaning up */
+ if (g_hash_table_size (service_status_map) == 0)
+ g_hash_table_remove (capability_service_map, capability);
+
+ if (g_hash_table_size (capability_service_map) == 0)
+ g_hash_table_remove (priv->discovered_statuses, from);
+ }
if (emit)
tp_yts_svc_status_emit_status_changed (self, from, capability,