From 69f4cb22dcefd39cadcbe274b1896b06a3eadc15 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Mon, 13 Feb 2012 14:19:28 +0100 Subject: 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(+) (limited to 'libempathy') diff --git a/libempathy/empathy-connection-aggregator.c b/libempathy/empathy-connection-aggregator.c index fde365c27..2b517bf51 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 c21c04dec..5f85193c9 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__*/ -- cgit v1.2.3