[empathy] add empathy_connection_aggregator_rename_group()



commit 69f4cb22dcefd39cadcbe274b1896b06a3eadc15
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Mon Feb 13 14:19:28 2012 +0100

    add empathy_connection_aggregator_rename_group()
    
    https://bugzilla.gnome.org/show_bug.cgi?id=501065

 libempathy/empathy-connection-aggregator.c |   41 ++++++++++++++++++++++++++++
 libempathy/empathy-connection-aggregator.h |    5 +++
 2 files changed, 46 insertions(+), 0 deletions(-)
---
diff --git a/libempathy/empathy-connection-aggregator.c b/libempathy/empathy-connection-aggregator.c
index fde365c..2b517bf 100644
--- a/libempathy/empathy-connection-aggregator.c
+++ b/libempathy/empathy-connection-aggregator.c
@@ -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);
+    }
+}
diff --git a/libempathy/empathy-connection-aggregator.h b/libempathy/empathy-connection-aggregator.h
index c21c04d..5f85193 100644
--- a/libempathy/empathy-connection-aggregator.h
+++ b/libempathy/empathy-connection-aggregator.h
@@ -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__*/



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