]> git.0d.be Git - empathy.git/commitdiff
Updating empathy_tp_chat_leave() function in empathy-tp-chat API
authorChandni Verma <chandniverma2112@gmail.com>
Wed, 23 Feb 2011 06:14:54 +0000 (11:44 +0530)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Fri, 25 Feb 2011 09:24:55 +0000 (10:24 +0100)
libempathy-gtk/empathy-chat.c
libempathy/empathy-tp-chat.c
libempathy/empathy-tp-chat.h
src/empathy-event-manager.c

index b8e8789c56b5d767b9df636a2edba55ba30b141c..fbe2425b656f69c8ca54c07fc1f450fadfdca920 100644 (file)
@@ -2765,7 +2765,7 @@ chat_finalize (GObject *object)
                        chat_members_changed_cb, chat);
                g_signal_handlers_disconnect_by_func (priv->tp_chat,
                        chat_remote_contact_changed_cb, chat);
-               empathy_tp_chat_leave (priv->tp_chat);
+               empathy_tp_chat_leave (priv->tp_chat, "");
                g_object_unref (priv->tp_chat);
        }
        if (priv->account) {
index e24ba84f5a8de08e426aa31abdde47a5b0a950b2..20692a1888f2b7b5ad79c9f125ddd6a1e8c6303b 100644 (file)
@@ -1185,7 +1185,7 @@ tp_chat_got_remote_contact_cb (TpConnection            *connection,
 
        if (error) {
                DEBUG ("Error: %s", error->message);
-               empathy_tp_chat_leave (EMPATHY_TP_CHAT (chat));
+               empathy_tp_chat_leave (EMPATHY_TP_CHAT (chat), "");
                return;
        }
 
@@ -1206,7 +1206,7 @@ tp_chat_got_self_contact_cb (TpConnection            *connection,
 
        if (error) {
                DEBUG ("Error: %s", error->message);
-               empathy_tp_chat_leave (EMPATHY_TP_CHAT (chat));
+               empathy_tp_chat_leave (EMPATHY_TP_CHAT (chat), "");
                return;
        }
 
@@ -1557,16 +1557,6 @@ empathy_tp_chat_new (TpAccount *account,
                             NULL);
 }
 
-static void
-empathy_tp_chat_close (EmpathyTpChat *chat) {
-       EmpathyTpChatPriv *priv = GET_PRIV (chat);
-
-       /* If there are still messages left, it'll come back..
-        * We loose the ordering of sent messages though */
-       tp_cli_channel_call_close (priv->channel, -1, tp_chat_async_cb,
-               "closing channel", NULL, NULL);
-}
-
 const gchar *
 empathy_tp_chat_get_id (EmpathyTpChat *chat)
 {
@@ -1867,47 +1857,27 @@ empathy_tp_chat_can_add_contact (EmpathyTpChat *self)
 }
 
 static void
-leave_remove_members_cb (TpChannel *proxy,
-                        const GError *error,
-                        gpointer user_data,
-                        GObject *weak_object)
+tp_channel_leave_async_cb (GObject *source_object,
+        GAsyncResult *res,
+        gpointer user_data)
 {
-       EmpathyTpChat *self = user_data;
-
-       if (error == NULL)
-               return;
+       GError *error = NULL;
 
-       DEBUG ("RemoveMembers failed (%s); closing the channel", error->message);
-       empathy_tp_chat_close (self);
+       if (!tp_channel_leave_finish (TP_CHANNEL (source_object), res, &error)) {
+               DEBUG ("Could not leave channel properly: (%s); closing the channel",
+                       error->message);
+               g_error_free (error);
+       }
 }
 
 void
-empathy_tp_chat_leave (EmpathyTpChat *self)
+empathy_tp_chat_leave (EmpathyTpChat *self,
+               const gchar *message)
 {
        EmpathyTpChatPriv *priv = GET_PRIV (self);
-       TpHandle self_handle;
-       GArray *array;
-
-       if (!tp_proxy_has_interface_by_id (priv->channel,
-               TP_IFACE_QUARK_CHANNEL_INTERFACE_GROUP)) {
-               empathy_tp_chat_close (self);
-               return;
-       }
-
-       self_handle = tp_channel_group_get_self_handle (priv->channel);
-       if (self_handle == 0) {
-               /* we are not member of the channel */
-               empathy_tp_chat_close (self);
-               return;
-       }
-
-       array = g_array_sized_new (FALSE, FALSE, sizeof (TpHandle), 1);
-       g_array_insert_val (array, 0, self_handle);
-
-       tp_cli_channel_interface_group_call_remove_members (priv->channel, -1, array,
-               "", leave_remove_members_cb, self, NULL, G_OBJECT (self));
 
-       g_array_free (array, TRUE);
+       tp_channel_leave_async (priv->channel, TP_CHANNEL_GROUP_CHANGE_REASON_NONE,
+               message, tp_channel_leave_async_cb, self);
 }
 
 static void
index 8511335cfa51d5fd1665edac619e43edf58d325b..7c83bec77eb0c12f29a9e2186366a089d7ba494f 100644 (file)
@@ -100,7 +100,8 @@ gboolean       empathy_tp_chat_provide_password_finish (EmpathyTpChat *chat,
                                                        GError **error);
 gboolean       empathy_tp_chat_can_add_contact (EmpathyTpChat *self);
 
-void           empathy_tp_chat_leave                (EmpathyTpChat      *chat);
+void           empathy_tp_chat_leave                (EmpathyTpChat      *chat,
+                                                      const gchar *message);
 void           empathy_tp_chat_join                 (EmpathyTpChat      *chat);
 
 gboolean       empathy_tp_chat_is_invited           (EmpathyTpChat      *chat,
index 9699a3a07e12e3c0e418e554c80b5490450c69ab..599a6a48e88cd43e6beea159516d8344d80de1a4 100644 (file)
@@ -409,7 +409,7 @@ reject_channel_claim_cb (GObject *source,
     }
   else if (EMPATHY_IS_TP_CHAT (user_data))
     {
-      empathy_tp_chat_leave (user_data);
+      empathy_tp_chat_leave (user_data, "");
     }
   else if (EMPATHY_IS_TP_FILE (user_data))
     {