]> git.0d.be Git - empathy.git/commitdiff
use tp_text_channel_set_chat_state_async() directly
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Thu, 19 May 2011 12:15:21 +0000 (14:15 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Wed, 25 May 2011 07:22:42 +0000 (09:22 +0200)
libempathy-gtk/empathy-chat.c
libempathy/empathy-tp-chat.c
libempathy/empathy-tp-chat.h

index 1dbaf5d8ae9e07eacbe5006a8da6cf8aed751add..3fdb3bd53a20449fa100ca670c5269350d638336 100644 (file)
@@ -326,6 +326,34 @@ chat_composing_remove_timeout (EmpathyChat *chat)
        }
 }
 
+static void
+set_chate_state_cb (GObject *source,
+                   GAsyncResult *result,
+                   gpointer user_data)
+{
+       GError *error = NULL;
+
+       if (!tp_text_channel_set_chat_state_finish (TP_TEXT_CHANNEL (source), result,
+               &error)) {
+               DEBUG ("Failed to set chat state: %s", error->message);
+               g_error_free (error);
+       }
+}
+
+static void
+set_chat_state (EmpathyChat *self,
+               TpChannelChatState state)
+{
+       EmpathyChatPriv *priv = GET_PRIV (self);
+
+       if (!tp_proxy_has_interface_by_id (priv->tp_chat,
+               TP_IFACE_QUARK_CHANNEL_INTERFACE_CHAT_STATE))
+               return;
+
+       tp_text_channel_set_chat_state_async (TP_TEXT_CHANNEL (priv->tp_chat), state,
+               set_chate_state_cb, self);
+}
+
 static gboolean
 chat_composing_stop_timeout_cb (EmpathyChat *chat)
 {
@@ -334,8 +362,7 @@ chat_composing_stop_timeout_cb (EmpathyChat *chat)
        priv = GET_PRIV (chat);
 
        priv->composing_stop_timeout_id = 0;
-       empathy_tp_chat_set_state (priv->tp_chat,
-                                  TP_CHANNEL_CHAT_STATE_PAUSED);
+       set_chat_state (chat, TP_CHANNEL_CHAT_STATE_PAUSED);
 
        return FALSE;
 }
@@ -351,8 +378,7 @@ chat_composing_start (EmpathyChat *chat)
                /* Just restart the timeout */
                chat_composing_remove_timeout (chat);
        } else {
-               empathy_tp_chat_set_state (priv->tp_chat,
-                                          TP_CHANNEL_CHAT_STATE_COMPOSING);
+               set_chat_state (chat, TP_CHANNEL_CHAT_STATE_COMPOSING);
        }
 
        priv->composing_stop_timeout_id = g_timeout_add_seconds (
@@ -369,8 +395,7 @@ chat_composing_stop (EmpathyChat *chat)
        priv = GET_PRIV (chat);
 
        chat_composing_remove_timeout (chat);
-       empathy_tp_chat_set_state (priv->tp_chat,
-                                  TP_CHANNEL_CHAT_STATE_ACTIVE);
+       set_chat_state (chat, TP_CHANNEL_CHAT_STATE_ACTIVE);
 }
 
 static gint
index 34e2d40b271b01975b3309704b791b90f5a2eba6..02bdc80e396eaf124204ac23f0e023ce11183ced 100644 (file)
@@ -1578,25 +1578,6 @@ empathy_tp_chat_send (EmpathyTpChat *self,
        g_free (message_body);
 }
 
-void
-empathy_tp_chat_set_state (EmpathyTpChat *self,
-                          TpChannelChatState  state)
-{
-       g_return_if_fail (EMPATHY_IS_TP_CHAT (self));
-
-       if (tp_proxy_has_interface_by_id (self,
-                                         TP_IFACE_QUARK_CHANNEL_INTERFACE_CHAT_STATE)) {
-               DEBUG ("Set state: %d", state);
-               tp_cli_channel_interface_chat_state_call_set_chat_state ((TpChannel *) self, -1,
-                                                                        state,
-                                                                        tp_chat_async_cb,
-                                                                        "setting chat state",
-                                                                        NULL,
-                                                                        G_OBJECT (self));
-       }
-}
-
-
 const GList *
 empathy_tp_chat_get_pending_messages (EmpathyTpChat *self)
 {
index 31f9198e15995b1508dbb18d2b197ee76f185f76..de55c1a8cf04e9605c1ddf8e1388be12b4b5ecc0 100644 (file)
@@ -81,8 +81,6 @@ EmpathyContact *empathy_tp_chat_get_remote_contact   (EmpathyTpChat      *chat);
 TpAccount    * empathy_tp_chat_get_account          (EmpathyTpChat      *chat);
 void           empathy_tp_chat_send                 (EmpathyTpChat      *chat,
                                                     TpMessage     *message);
-void           empathy_tp_chat_set_state            (EmpathyTpChat      *chat,
-                                                    TpChannelChatState  state);
 void           empathy_tp_chat_set_property         (EmpathyTpChat      *chat,
                                                     const gchar        *name,
                                                     const GValue       *value);