diff options
| author | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2011-04-19 11:04:08 +0100 |
|---|---|---|
| committer | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2011-04-19 11:04:08 +0100 |
| commit | a06f0e7cff4afac90f69057e31b80d52a896121b (patch) | |
| tree | 69328053cca12cff68765c60a823e37312e4e75f | |
| parent | 34555aa5d322785704b174b4ec3ecfb0a4023b47 (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>
| -rw-r--r-- | salut/status.c | 19 | ||||
| -rw-r--r-- | tests/twisted/salut/status.py | 3 |
2 files changed, 18 insertions, 4 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, diff --git a/tests/twisted/salut/status.py b/tests/twisted/salut/status.py index 84170e3..9f028c2 100644 --- a/tests/twisted/salut/status.py +++ b/tests/twisted/salut/status.py @@ -172,8 +172,7 @@ def test(q, bus, conn): # check property discovered = status.Get(ycs.STATUS_IFACE, 'DiscoveredStatuses', dbus_interface=dbus.PROPERTIES_IFACE) - assertEquals({'testsuite@testsuite': {CAP_NAME: {'ants.in.their.pants': ''}}}, - discovered) + assertEquals({}, discovered) if __name__ == '__main__': exec_test(test) |
