]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/gossip-chat.c
[darcs-to-svn @ after a timeout we are in PAUSED chat state]
[empathy.git] / libempathy-gtk / gossip-chat.c
index d1e0369367d7439dcce71fe5e15299e093445a3c..614abd7d78dcd9ee579ec30ebfe8f00ef288c757 100644 (file)
@@ -35,7 +35,6 @@
 #include <gtk/gtk.h>
 #include <glade/glade.h>
 
-#include <libempathy/empathy-session.h>
 #include <libempathy/empathy-contact-manager.h>
 #include <libempathy/gossip-debug.h>
 #include <libempathy/gossip-utils.h>
 #define COMPOSING_STOP_TIMEOUT 5
 
 struct _GossipChatPriv {
-       EmpathyTpChat    *tp_chat;
-       GossipChatWindow *window;
-
-       GtkTooltips      *tooltips;
-       guint             composing_stop_timeout_id;
-       gboolean          sensitive;
-       gchar            *id;
-       GSList           *sent_messages;
-       gint              sent_messages_index;
+       EmpathyContactManager *manager;
+       EmpathyTpChat         *tp_chat;
+       GossipChatWindow      *window;
+
+       GtkTooltips           *tooltips;
+       guint                  composing_stop_timeout_id;
+       gboolean               sensitive;
+       gchar                 *id;
+       GSList                *sent_messages;
+       gint                   sent_messages_index;
        /* Used to automatically shrink a window that has temporarily
         * grown due to long input. 
         */
-       gint              padding_height;
-       gint              default_window_height;
-       gint              last_input_height;
-       gboolean          vscroll_visible;
+       gint                   padding_height;
+       gint                   default_window_height;
+       gint                   last_input_height;
+       gboolean               vscroll_visible;
 };
 
 typedef struct {
@@ -133,6 +133,10 @@ static void             chat_composing_start              (GossipChat      *chat
 static void             chat_composing_stop               (GossipChat      *chat);
 static void             chat_composing_remove_timeout     (GossipChat      *chat);
 static gboolean         chat_composing_stop_timeout_cb    (GossipChat      *chat);
+static void             chat_state_changed_cb             (EmpathyTpChat   *tp_chat,
+                                                          GossipContact   *contact,
+                                                          TelepathyChannelChatState  state,
+                                                          GossipChat      *chat);
 
 enum {
        COMPOSING,
@@ -220,8 +224,8 @@ gossip_chat_init (GossipChat *chat)
 
        priv = GET_PRIV (chat);
 
+       priv->manager = empathy_contact_manager_new ();
        priv->tooltips = gtk_tooltips_new ();
-
        priv->default_window_height = -1;
        priv->vscroll_visible = FALSE;
        priv->sensitive = TRUE;
@@ -238,7 +242,7 @@ gossip_chat_init (GossipChat *chat)
                          "changed",
                          G_CALLBACK (chat_input_text_buffer_changed_cb),
                          chat);
-       g_signal_connect (GOSSIP_CHAT (chat)->view,
+       g_signal_connect (chat->view,
                          "focus_in_event",
                          G_CALLBACK (chat_text_view_focus_in_event_cb),
                          chat);
@@ -280,7 +284,8 @@ chat_finalize (GObject *object)
        g_slist_free (priv->sent_messages);
 
        chat_composing_remove_timeout (chat);
-       g_object_unref (GOSSIP_CHAT (object)->account);
+       g_object_unref (chat->account);
+       g_object_unref (priv->manager);
 
        if (priv->tp_chat) {
                g_object_unref (priv->tp_chat);
@@ -953,10 +958,8 @@ chat_composing_start (GossipChat *chat)
                /* Just restart the timeout */
                chat_composing_remove_timeout (chat);
        } else {
-       /* FIXME:
-               gossip_session_send_composing (gossip_app_get_session (),
-                                              priv->contact, TRUE);
-                                             */
+               empathy_tp_chat_set_state (priv->tp_chat,
+                                          TP_CHANNEL_CHAT_STATE_COMPOSING);
        }
 
        priv->composing_stop_timeout_id = g_timeout_add (
@@ -973,9 +976,8 @@ chat_composing_stop (GossipChat *chat)
        priv = GET_PRIV (chat);
 
        chat_composing_remove_timeout (chat);
-       /* FIXME:
-       gossip_session_send_composing (gossip_app_get_session (),
-                                      priv->contact, FALSE);*/
+       empathy_tp_chat_set_state (priv->tp_chat,
+                                  TP_CHANNEL_CHAT_STATE_ACTIVE);
 }
 
 static void
@@ -999,13 +1001,21 @@ chat_composing_stop_timeout_cb (GossipChat *chat)
        priv = GET_PRIV (chat);
 
        priv->composing_stop_timeout_id = 0;
-       /* FIXME:
-       gossip_session_send_composing (gossip_app_get_session (),
-                                      priv->contact, FALSE);*/
+       empathy_tp_chat_set_state (priv->tp_chat,
+                                  TP_CHANNEL_CHAT_STATE_PAUSED);
 
        return FALSE;
 }
 
+static void
+chat_state_changed_cb (EmpathyTpChat             *tp_chat,
+                      GossipContact             *contact,
+                      TelepathyChannelChatState  state,
+                      GossipChat                *chat)
+{
+       /* FIXME: not yet implemented */
+}
+
 gboolean
 gossip_chat_get_is_command (const gchar *str)
 {
@@ -1071,13 +1081,13 @@ gossip_chat_get_tooltip (GossipChat *chat)
        return NULL;
 }
 
-GdkPixbuf *
-gossip_chat_get_status_pixbuf (GossipChat *chat)
+const gchar *
+gossip_chat_get_status_icon_name (GossipChat *chat)
 {
        g_return_val_if_fail (GOSSIP_IS_CHAT (chat), NULL);
 
-       if (GOSSIP_CHAT_GET_CLASS (chat)->get_status_pixbuf) {
-               return GOSSIP_CHAT_GET_CLASS (chat)->get_status_pixbuf (chat);
+       if (GOSSIP_CHAT_GET_CLASS (chat)->get_status_icon_name) {
+               return GOSSIP_CHAT_GET_CLASS (chat)->get_status_icon_name (chat);
        }
 
        return NULL;
@@ -1097,13 +1107,13 @@ gossip_chat_get_contact (GossipChat *chat)
 GossipContact *
 gossip_chat_get_own_contact (GossipChat *chat)
 {
-       EmpathyContactManager *manager;
+       GossipChatPriv *priv;
 
        g_return_val_if_fail (GOSSIP_IS_CHAT (chat), NULL);
 
-       manager = empathy_session_get_contact_manager ();
+       priv = GET_PRIV (chat);
 
-       return empathy_contact_manager_get_own (manager, chat->account);
+       return empathy_contact_manager_get_own (priv->manager, chat->account);
 }
 
 GtkWidget *
@@ -1218,6 +1228,9 @@ gossip_chat_set_tp_chat (GossipChat    *chat,
        g_signal_connect (tp_chat, "message-received",
                          G_CALLBACK (chat_message_received_cb),
                          chat);
+       g_signal_connect (tp_chat, "chat-state-changed",
+                         G_CALLBACK (chat_state_changed_cb),
+                         chat);
        g_signal_connect (tp_chat, "destroy",
                          G_CALLBACK (chat_destroy_cb),
                          chat);
@@ -1367,7 +1380,7 @@ gossip_chat_should_play_sound (GossipChat *chat)
 
        g_return_val_if_fail (GOSSIP_IS_CHAT (chat), FALSE);
 
-       window = gossip_chat_get_window (GOSSIP_CHAT (chat));
+       window = gossip_chat_get_window (chat);
        if (!window) {
                return TRUE;
        }