diff options
author | Philip Withnall <philip@tecnocode.co.uk> | 2010-12-21 17:48:50 +0000 |
---|---|---|
committer | Philip Withnall <philip@tecnocode.co.uk> | 2010-12-30 17:15:20 +0000 |
commit | 7d81c280d6e665715c7a6ee5c65223fae87f5432 (patch) | |
tree | 7dd755511d74ee388c71b723cc1fb10aacc414ec | |
parent | 17511eb647878adeb541aa12b3cf14e13f63c4e4 (diff) | |
download | libgdata-0-6.tar.gz |
contacts: Don't return deleted groups in gdata_contacts_contact_get_groups()libgdata-0-6
Also take the opportunity to rewrite it to use GHashTableIter instead of
a tiny little callback function.
-rw-r--r-- | gdata/services/contacts/gdata-contacts-contact.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/gdata/services/contacts/gdata-contacts-contact.c b/gdata/services/contacts/gdata-contacts-contact.c index e30a6428..e3140bf6 100644 --- a/gdata/services/contacts/gdata-contacts-contact.c +++ b/gdata/services/contacts/gdata-contacts-contact.c @@ -1147,12 +1147,6 @@ gdata_contacts_contact_is_group_deleted (GDataContactsContact *self, const gchar return GPOINTER_TO_UINT (g_hash_table_lookup (self->priv->groups, href)); } -static void -get_groups_cb (const gchar *href, gpointer deleted, GList **groups) -{ - *groups = g_list_prepend (*groups, (gchar*) href); -} - /** * gdata_contacts_contact_get_groups: * @self: a #GDataContactsContact @@ -1166,11 +1160,20 @@ get_groups_cb (const gchar *href, gpointer deleted, GList **groups) GList * gdata_contacts_contact_get_groups (GDataContactsContact *self) { + GHashTableIter iter; + const gchar *href; + gpointer value; GList *groups = NULL; g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL); - g_hash_table_foreach (self->priv->groups, (GHFunc) get_groups_cb, &groups); + g_hash_table_iter_init (&iter, self->priv->groups); + while (g_hash_table_iter_next (&iter, (gpointer*) &href, &value) == TRUE) { + /* Add the group to the list as long as it hasn't been deleted */ + if (GPOINTER_TO_UINT (value) == FALSE) + groups = g_list_prepend (groups, (gpointer) href); + } + return g_list_reverse (groups); } |