[libgdata/libgdata-0-6] contacts: Don't return deleted groups in gdata_contacts_contact_get_groups()
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata/libgdata-0-6] contacts: Don't return deleted groups in gdata_contacts_contact_get_groups()
- Date: Thu, 30 Dec 2010 17:15:52 +0000 (UTC)
commit 7d81c280d6e665715c7a6ee5c65223fae87f5432
Author: Philip Withnall <philip tecnocode co uk>
Date: Tue Dec 21 17:48:50 2010 +0000
contacts: Don't return deleted groups in gdata_contacts_contact_get_groups()
Also take the opportunity to rewrite it to use GHashTableIter instead of
a tiny little callback function.
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 e30a642..e3140bf 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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]