[empathy] Move empathy_tp_contact_factory_set_alias() to EmpathyContact



commit ea03354dacd0da472875bb64d0f2d8c124f3193b
Author: Xavier Claessens <xclaesse gmail com>
Date:   Wed May 26 11:34:06 2010 +0200

    Move empathy_tp_contact_factory_set_alias() to EmpathyContact

 libempathy-gtk/empathy-contact-dialogs.c |    2 +-
 libempathy-gtk/empathy-contact-widget.c  |    2 +-
 libempathy/empathy-contact.c             |   38 ++++++++++++++++++++++++
 libempathy/empathy-contact.h             |    1 +
 libempathy/empathy-tp-contact-factory.c  |   46 ------------------------------
 libempathy/empathy-tp-contact-factory.h  |    2 -
 6 files changed, 41 insertions(+), 50 deletions(-)
---
diff --git a/libempathy-gtk/empathy-contact-dialogs.c b/libempathy-gtk/empathy-contact-dialogs.c
index aaeea4b..f83ac7a 100644
--- a/libempathy-gtk/empathy-contact-dialogs.c
+++ b/libempathy-gtk/empathy-contact-dialogs.c
@@ -76,7 +76,7 @@ subscription_dialog_response_cb (GtkDialog *dialog,
 		empathy_contact_list_add (EMPATHY_CONTACT_LIST (manager),
 					  contact, "");
 
-		empathy_tp_contact_factory_set_alias (contact,
+		empathy_contact_set_alias (contact,
 			empathy_contact_widget_get_alias (contact_widget));
 	}
 	else if (response == GTK_RESPONSE_NO) {
diff --git a/libempathy-gtk/empathy-contact-widget.c b/libempathy-gtk/empathy-contact-widget.c
index 6131882..05dfb7a 100644
--- a/libempathy-gtk/empathy-contact-widget.c
+++ b/libempathy-gtk/empathy-contact-widget.c
@@ -956,7 +956,7 @@ contact_widget_entry_alias_focus_event_cb (GtkEditable *editable,
         }
       else
         {
-          empathy_tp_contact_factory_set_alias (information->contact, alias);
+          empathy_contact_set_alias (information->contact, alias);
         }
     }
 
diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c
index d764528..bd8a63e 100644
--- a/libempathy/empathy-contact.c
+++ b/libempathy/empathy-contact.c
@@ -618,6 +618,44 @@ empathy_contact_set_name (EmpathyContact *contact,
   g_object_unref (contact);
 }
 
+static void
+contact_set_aliases_cb (TpConnection *connection,
+    const GError *error,
+    gpointer user_data,
+    GObject *weak_object)
+{
+	if (error)
+		DEBUG ("Error: %s", error->message);
+}
+
+void
+empathy_contact_set_alias (EmpathyContact *contact,
+    const gchar *alias)
+{
+	TpConnection *connection;
+	GHashTable *new_alias;
+	guint handle;
+
+	g_return_if_fail (EMPATHY_IS_CONTACT (contact));
+
+	handle = empathy_contact_get_handle (contact);
+
+	DEBUG ("Setting alias for contact %s (%d) to %s",
+		empathy_contact_get_id (contact),
+		handle, alias);
+
+	new_alias = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL,
+	    g_free);
+
+	g_hash_table_insert (new_alias, GUINT_TO_POINTER (handle), g_strdup (alias));
+
+	connection = empathy_contact_get_connection (contact);
+	tp_cli_connection_interface_aliasing_call_set_aliases (connection, -1,
+	    new_alias, contact_set_aliases_cb, NULL, NULL, NULL);
+
+	g_hash_table_destroy (new_alias);
+}
+
 EmpathyAvatar *
 empathy_contact_get_avatar (EmpathyContact *contact)
 {
diff --git a/libempathy/empathy-contact.h b/libempathy/empathy-contact.h
index da46326..568ecd5 100644
--- a/libempathy/empathy-contact.h
+++ b/libempathy/empathy-contact.h
@@ -84,6 +84,7 @@ const gchar * empathy_contact_get_id (EmpathyContact *contact);
 void empathy_contact_set_id (EmpathyContact *contact, const gchar *id);
 const gchar * empathy_contact_get_name (EmpathyContact *contact);
 void empathy_contact_set_name (EmpathyContact *contact, const gchar *name);
+void empathy_contact_set_alias (EmpathyContact *contact, const gchar *alias);
 EmpathyAvatar * empathy_contact_get_avatar (EmpathyContact *contact);
 void empathy_contact_set_avatar (EmpathyContact *contact,
     EmpathyAvatar *avatar);
diff --git a/libempathy/empathy-tp-contact-factory.c b/libempathy/empathy-tp-contact-factory.c
index d2fbcf7..a8afecf 100644
--- a/libempathy/empathy-tp-contact-factory.c
+++ b/libempathy/empathy-tp-contact-factory.c
@@ -345,49 +345,3 @@ empathy_tp_contact_factory_get_from_handle (TpConnection            *connection,
 					      weak_object);
 }
 
-static void
-tp_contact_factory_set_aliases_cb (TpConnection *connection,
-				   const GError *error,
-				   gpointer      user_data,
-				   GObject      *tp_factory)
-{
-	if (error) {
-		DEBUG ("Error: %s", error->message);
-	}
-}
-
-void
-empathy_tp_contact_factory_set_alias (EmpathyContact *contact,
-				      const gchar *alias)
-{
-	TpConnection *connection;
-	GHashTable *new_alias;
-	guint       handle;
-
-	g_return_if_fail (EMPATHY_IS_CONTACT (contact));
-
-	handle = empathy_contact_get_handle (contact);
-
-	DEBUG ("Setting alias for contact %s (%d) to %s",
-		empathy_contact_get_id (contact),
-		handle, alias);
-
-	new_alias = g_hash_table_new_full (g_direct_hash,
-					   g_direct_equal,
-					   NULL,
-					   g_free);
-
-	g_hash_table_insert (new_alias,
-			     GUINT_TO_POINTER (handle),
-			     g_strdup (alias));
-
-	connection = empathy_contact_get_connection (contact);
-	tp_cli_connection_interface_aliasing_call_set_aliases (connection,
-							       -1,
-							       new_alias,
-							       tp_contact_factory_set_aliases_cb,
-							       NULL, NULL, NULL);
-
-	g_hash_table_destroy (new_alias);
-}
-
diff --git a/libempathy/empathy-tp-contact-factory.h b/libempathy/empathy-tp-contact-factory.h
index 59109da..29146cb 100644
--- a/libempathy/empathy-tp-contact-factory.h
+++ b/libempathy/empathy-tp-contact-factory.h
@@ -80,8 +80,6 @@ void                     empathy_tp_contact_factory_get_from_handle  (TpConnecti
 								      gpointer                 user_data,
 								      GDestroyNotify           destroy,
 								      GObject                 *weak_object);
-void                     empathy_tp_contact_factory_set_alias        (EmpathyContact          *contact,
-								      const gchar             *alias);
 G_END_DECLS
 
 #endif /* __EMPATHY_TP_CONTACT_FACTORY_H__ */



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