]> git.0d.be Git - empathy.git/commitdiff
Change the type of EmpathyContact.priv.groups to GeeHashSet.
authorTravis Reitter <travis.reitter@collabora.co.uk>
Mon, 2 May 2011 19:58:04 +0000 (12:58 -0700)
committerTravis Reitter <travis.reitter@collabora.co.uk>
Mon, 6 Jun 2011 16:30:52 +0000 (09:30 -0700)
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

index 44a561b6e2772b7af7b57fc1f9c864cc5354024a..831be25fcb19a17f21503c9b51c3ccc584900b53 100644 (file)
@@ -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;
     }
 }