aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-01-18 23:12:40 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-01-18 23:12:40 +0800
commitdbb95ed92ec1acc6d6bbf7b4a1dbcaf931070e4f (patch)
treeec1372f331b02a2a2101b1c2c25f88b26e8c3ff4
parent8eb3671bdebf2b31323d8ad26a0e89f9907cb828 (diff)
parent1acf8998707505a367ef27e04730907b56408b3d (diff)
downloadgsoc2013-empathy-dbb95ed92ec1acc6d6bbf7b4a1dbcaf931070e4f.tar
gsoc2013-empathy-dbb95ed92ec1acc6d6bbf7b4a1dbcaf931070e4f.tar.gz
gsoc2013-empathy-dbb95ed92ec1acc6d6bbf7b4a1dbcaf931070e4f.tar.bz2
gsoc2013-empathy-dbb95ed92ec1acc6d6bbf7b4a1dbcaf931070e4f.tar.lz
gsoc2013-empathy-dbb95ed92ec1acc6d6bbf7b4a1dbcaf931070e4f.tar.xz
gsoc2013-empathy-dbb95ed92ec1acc6d6bbf7b4a1dbcaf931070e4f.tar.zst
gsoc2013-empathy-dbb95ed92ec1acc6d6bbf7b4a1dbcaf931070e4f.zip
Merge remote branch 'glassrose/Display-typing-icon-in-muc-contacts-list-609419'
-rw-r--r--libempathy-gtk/empathy-contact-list-store.c60
-rw-r--r--libempathy/empathy-tp-chat.c9
-rw-r--r--libempathy/empathy-tp-chat.h3
-rw-r--r--src/empathy-chat-manager.c4
4 files changed, 74 insertions, 2 deletions
diff --git a/libempathy-gtk/empathy-contact-list-store.c b/libempathy-gtk/empathy-contact-list-store.c
index d87461eeb..a8dbe6cbc 100644
--- a/libempathy-gtk/empathy-contact-list-store.c
+++ b/libempathy-gtk/empathy-contact-list-store.c
@@ -34,12 +34,14 @@
#include <telepathy-glib/util.h>
#include <libempathy/empathy-utils.h>
+#include <libempathy/empathy-tp-chat.h>
#include <libempathy/empathy-enum-types.h>
#include <libempathy/empathy-contact-manager.h>
#include "empathy-contact-list-store.h"
#include "empathy-ui-utils.h"
#include "empathy-gtk-enum-types.h"
+#include "empathy-images.h"
#define DEBUG_FLAG EMPATHY_DEBUG_CONTACT
#include <libempathy/empathy-debug.h>
@@ -181,6 +183,32 @@ enum {
G_DEFINE_TYPE (EmpathyContactListStore, empathy_contact_list_store, GTK_TYPE_TREE_STORE);
+static void
+contact_list_store_chat_state_changed_cb (TpChannel *self,
+ guint contact_handle,
+ guint state,
+ gpointer store)
+{
+ EmpathyContactListStorePriv *priv = GET_PRIV (store);
+ GList *contacts, *l;
+
+ contacts = empathy_contact_list_get_members (priv->list);
+
+ /* Find the contact in the list. After that l is the list elem or NULL */
+ for (l = contacts; l != NULL; l = l->next) {
+ if (empathy_contact_get_handle (EMPATHY_CONTACT (l->data)) ==
+ contact_handle) {
+ break;
+ }
+ }
+
+ if (l != NULL)
+ contact_list_store_contact_update (store, l->data);
+
+ g_list_foreach (contacts, (GFunc) g_object_unref, NULL);
+ g_list_free (contacts);
+}
+
static gboolean
contact_list_store_iface_setup (gpointer user_data)
{
@@ -206,6 +234,20 @@ contact_list_store_iface_setup (gpointer user_data)
G_CALLBACK (contact_list_store_groups_changed_cb),
store);
+ if (EMPATHY_IS_TP_CHAT (priv->list)) {
+ TpChannel *channel;
+
+ channel = empathy_tp_chat_get_channel (EMPATHY_TP_CHAT (priv->list));
+ if (!tp_proxy_is_prepared (channel, TP_CHANNEL_FEATURE_CHAT_STATES)) {
+ DEBUG ("Chat state feature not prepared");
+ } else {
+ g_signal_connect (channel,
+ "chat-state-changed",
+ G_CALLBACK (contact_list_store_chat_state_changed_cb),
+ store);
+ }
+ }
+
/* Add contacts already created. */
contacts = empathy_contact_list_get_members (priv->list);
for (l = contacts; l; l = l->next) {
@@ -1835,9 +1877,25 @@ contact_list_store_get_contact_status_icon (EmpathyContactListStore *store,
EmpathyContact *contact)
{
GdkPixbuf *pixbuf_status = NULL;
+ EmpathyContactListStorePriv *priv;
const gchar *status_icon_name = NULL;
+ gboolean composing = FALSE;
+
+ priv = GET_PRIV (store);
+
+ if (EMPATHY_IS_TP_CHAT (priv->list)) {
+ if (empathy_tp_chat_get_chat_state (EMPATHY_TP_CHAT (priv->list),
+ contact) ==
+ TP_CHANNEL_CHAT_STATE_COMPOSING)
+ composing = TRUE;
+ }
+
+ if (composing) {
+ status_icon_name = EMPATHY_IMAGE_TYPING;
+ } else {
+ status_icon_name = empathy_icon_name_for_contact (contact);
+ }
- status_icon_name = empathy_icon_name_for_contact (contact);
if (status_icon_name == NULL)
return NULL;
diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c
index f1351049a..e24ba84f5 100644
--- a/libempathy/empathy-tp-chat.c
+++ b/libempathy/empathy-tp-chat.c
@@ -1959,3 +1959,12 @@ empathy_tp_chat_is_invited (EmpathyTpChat *self,
return tp_channel_group_get_local_pending_info (priv->channel, self_handle,
inviter, NULL, NULL);
}
+
+TpChannelChatState
+empathy_tp_chat_get_chat_state (EmpathyTpChat *chat,
+ EmpathyContact *contact)
+{
+ EmpathyTpChatPriv *priv = GET_PRIV (chat);
+ return tp_channel_get_chat_state (priv->channel,
+ empathy_contact_get_handle (contact));
+}
diff --git a/libempathy/empathy-tp-chat.h b/libempathy/empathy-tp-chat.h
index 8858f4971..8511335cf 100644
--- a/libempathy/empathy-tp-chat.h
+++ b/libempathy/empathy-tp-chat.h
@@ -105,6 +105,9 @@ void empathy_tp_chat_join (EmpathyTpChat *chat);
gboolean empathy_tp_chat_is_invited (EmpathyTpChat *chat,
TpHandle *inviter);
+TpChannelChatState
+ empathy_tp_chat_get_chat_state (EmpathyTpChat *chat,
+ EmpathyContact *contact);
G_END_DECLS
diff --git a/src/empathy-chat-manager.c b/src/empathy-chat-manager.c
index 38c91fa4d..c84b5f447 100644
--- a/src/empathy-chat-manager.c
+++ b/src/empathy-chat-manager.c
@@ -289,9 +289,11 @@ empathy_chat_manager_init (EmpathyChatManager *self)
priv->handler = tp_simple_handler_new (dbus, FALSE, FALSE, "Empathy.Chat",
FALSE, handle_channels, self, NULL);
- /* EmpathyTpChat relies on this feature being prepared */
+ /* EmpathyTpChat relies on these features being prepared */
tp_base_client_add_connection_features_varargs (priv->handler,
TP_CONNECTION_FEATURE_CAPABILITIES, 0);
+ tp_base_client_add_channel_features_varargs (priv->handler,
+ TP_CHANNEL_FEATURE_CHAT_STATES, 0);
g_object_unref (dbus);