aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxclaesse <xclaesse@4ee84921-47dd-4033-b63a-18d7a039a3e4>2008-04-14 21:00:56 +0800
committerxclaesse <xclaesse@4ee84921-47dd-4033-b63a-18d7a039a3e4>2008-04-14 21:00:56 +0800
commit9d06602e071eaa5ce843cad3259352578ac63a6f (patch)
treec7cf7b351e6a126eaa22b94c27fb9444d0779e3b
parentc4ec2add2e541a219b201120e706f4746996b738 (diff)
downloadgsoc2013-empathy-9d06602e071eaa5ce843cad3259352578ac63a6f.tar
gsoc2013-empathy-9d06602e071eaa5ce843cad3259352578ac63a6f.tar.gz
gsoc2013-empathy-9d06602e071eaa5ce843cad3259352578ac63a6f.tar.bz2
gsoc2013-empathy-9d06602e071eaa5ce843cad3259352578ac63a6f.tar.lz
gsoc2013-empathy-9d06602e071eaa5ce843cad3259352578ac63a6f.tar.xz
gsoc2013-empathy-9d06602e071eaa5ce843cad3259352578ac63a6f.tar.zst
gsoc2013-empathy-9d06602e071eaa5ce843cad3259352578ac63a6f.zip
Set "remote-contact" property even if there is a group interface.
git-svn-id: svn+ssh://svn.gnome.org/svn/empathy/trunk@937 4ee84921-47dd-4033-b63a-18d7a039a3e4
-rw-r--r--libempathy/empathy-tp-chat.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c
index 767aec113..8265339ac 100644
--- a/libempathy/empathy-tp-chat.c
+++ b/libempathy/empathy-tp-chat.c
@@ -54,6 +54,7 @@ struct _EmpathyTpChatPriv {
gboolean had_properties_list;
GPtrArray *properties;
gboolean ready;
+ guint nb_members;
};
typedef struct {
@@ -121,6 +122,27 @@ tp_chat_member_added_cb (EmpathyTpGroup *group,
const gchar *message,
EmpathyTpChat *chat)
{
+ EmpathyTpChatPriv *priv = GET_PRIV (chat);
+
+ priv->nb_members++;
+ if (priv->nb_members > 2 && priv->remote_contact) {
+ /* We now have more than 2 members, this is not a p2p chat
+ * anymore. Remove the remote-contact as it makes no sense, the
+ * EmpathyContactList interface must be used now. */
+ g_object_unref (priv->remote_contact);
+ priv->remote_contact = NULL;
+ g_object_notify (G_OBJECT (chat), "remote-contact");
+ }
+ if (priv->nb_members <= 2 && !priv->remote_contact &&
+ !empathy_contact_is_user (contact)) {
+ /* This is a p2p chat, if it's not ourself that means this is
+ * the remote contact with who we are chatting. This is to
+ * avoid forcing the usage of the EmpathyContactList interface
+ * for p2p chats. */
+ priv->remote_contact = g_object_ref (contact);
+ g_object_notify (G_OBJECT (chat), "remote-contact");
+ }
+
g_signal_emit_by_name (chat, "members-changed",
contact, actor, reason, message,
TRUE);
@@ -134,6 +156,25 @@ tp_chat_member_removed_cb (EmpathyTpGroup *group,
const gchar *message,
EmpathyTpChat *chat)
{
+ EmpathyTpChatPriv *priv = GET_PRIV (chat);
+
+ priv->nb_members--;
+ if (priv->nb_members <= 2 && !priv->remote_contact) {
+ GList *members, *l;
+
+ /* We are not a MUC anymore, get the remote contact back */
+ members = empathy_tp_group_get_members (group);
+ for (l = members; l; l = l->next) {
+ if (!empathy_contact_is_user (l->data)) {
+ priv->remote_contact = g_object_ref (l->data);
+ g_object_notify (G_OBJECT (chat), "remote-contact");
+ break;
+ }
+ }
+ g_list_foreach (members, (GFunc) g_object_unref, NULL);
+ g_list_free (members);
+ }
+
g_signal_emit_by_name (chat, "members-changed",
contact, actor, reason, message,
FALSE);