[empathy] Change the type of EmpathyContact.priv.groups to GeeHashSet.



commit a8833fd63b3bc3856cbd885158cba6b8fca1225a
Author: Travis Reitter <travis reitter collabora co uk>
Date:   Mon May 2 12:58:04 2011 -0700

    Change the type of EmpathyContact.priv.groups to GeeHashSet.
    
    This is to adjust to the newer API for folks_group_details_set_groups().
    It's also slightly cleaner than using a hash table to implement a set.
    
    Helps: bgo#648822 - Port Empathy to Folks 0.5.1

 libempathy/empathy-contact.c |   16 +++++++---------
 1 files changed, 7 insertions(+), 9 deletions(-)
---
diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c
index 44a561b..831be25 100644
--- a/libempathy/empathy-contact.c
+++ b/libempathy/empathy-contact.c
@@ -69,7 +69,7 @@ typedef struct {
    * more fields by searching the address using geoclue.
    */
   GHashTable *location;
-  GHashTable *groups;
+  GeeHashSet *groups;
   gchar **client_types;
 } EmpathyContactPriv;
 
@@ -424,8 +424,7 @@ contact_finalize (GObject *object)
 
   DEBUG ("finalize: %p", object);
 
-  if (priv->groups != NULL)
-    g_hash_table_destroy (priv->groups);
+  g_clear_object (&priv->groups);
   g_free (priv->alias);
   g_free (priv->id);
   g_strfreev (priv->client_types);
@@ -789,12 +788,11 @@ empathy_contact_change_group (EmpathyContact *contact, const gchar *group,
    * does */
   if (priv->groups == NULL)
     {
-      priv->groups = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
-          NULL);
+      priv->groups = gee_hash_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup,
+          g_free, g_str_hash, g_str_equal);
     }
 
-  g_hash_table_insert (priv->groups, g_strdup (group),
-      GUINT_TO_POINTER (is_member));
+  gee_collection_add (GEE_COLLECTION (priv->groups), group);
 }
 
 EmpathyAvatar *
@@ -949,8 +947,8 @@ empathy_contact_set_persona (EmpathyContact *contact,
   if (priv->groups != NULL)
     {
       folks_group_details_set_groups (FOLKS_GROUP_DETAILS (persona),
-          priv->groups);
-      g_hash_table_destroy (priv->groups);
+          GEE_SET (priv->groups));
+      g_object_unref (priv->groups);
       priv->groups = NULL;
     }
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]