]> git.0d.be Git - empathy.git/commitdiff
add empathy_connection_aggregator_rename_group()
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Mon, 13 Feb 2012 13:19:28 +0000 (14:19 +0100)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Fri, 20 Apr 2012 09:33:08 +0000 (11:33 +0200)
https://bugzilla.gnome.org/show_bug.cgi?id=501065

libempathy/empathy-connection-aggregator.c
libempathy/empathy-connection-aggregator.h

index fde365c27eaa25995f494394b048a90542b435db..2b517bf51a397cb02a3e2e64d39497f1cb2bb0c9 100644 (file)
@@ -288,3 +288,44 @@ empathy_connection_aggregator_dup_all_contacts (
 
   return result;
 }
+
+static void
+rename_group_cb (GObject *source,
+    GAsyncResult *result,
+    gpointer user_data)
+{
+  GError *error = NULL;
+
+  if (!tp_connection_rename_group_finish (TP_CONNECTION (source), result,
+        &error))
+    {
+      DEBUG ("Failed to rename group on %s: %s",
+          tp_proxy_get_object_path (source), error->message);
+      g_error_free (error);
+    }
+}
+
+void
+empathy_connection_aggregator_rename_group (EmpathyConnectionAggregator *self,
+    const gchar *old_name,
+    const gchar *new_name)
+{
+  GList *l;
+
+  for (l = self->priv->conns; l != NULL; l = g_list_next (l))
+    {
+      TpConnection *conn = l->data;
+      const gchar * const *groups;
+
+      groups = tp_connection_get_contact_groups (conn);
+
+      if (!tp_strv_contains (groups, old_name))
+        continue;
+
+      DEBUG ("Rename group '%s' to '%s' on %s", old_name, new_name,
+          tp_proxy_get_object_path (conn));
+
+      tp_connection_rename_group_async (conn, old_name, new_name,
+          rename_group_cb, NULL);
+    }
+}
index c21c04dec8d6dd881930b4adba662750485b2599..5f85193c984cebbd3708a785091888278b5e7f2d 100644 (file)
@@ -67,6 +67,11 @@ GList * empathy_connection_aggregator_get_all_groups (
 GPtrArray * empathy_connection_aggregator_dup_all_contacts (
     EmpathyConnectionAggregator *self);
 
+void empathy_connection_aggregator_rename_group (
+    EmpathyConnectionAggregator *self,
+    const gchar *old_name,
+    const gchar *new_name);
+
 G_END_DECLS
 
 #endif /* #ifndef __EMPATHY_CONNECTION_AGGREGATOR_H__*/