]> git.0d.be Git - empathy.git/blobdiff - libempathy/empathy-tp-chat.c
Merge back from master
[empathy.git] / libempathy / empathy-tp-chat.c
index 1bee75ed82b4d9e4f0d6376b1180ef7cc881df97..69057a87860214cb611ec2f308018fd7d6ada127 100644 (file)
@@ -26,6 +26,7 @@
 #include <telepathy-glib/channel.h>
 #include <telepathy-glib/dbus.h>
 #include <telepathy-glib/util.h>
+#include <telepathy-glib/interfaces.h>
 
 #include "empathy-tp-chat.h"
 #include "empathy-tp-contact-factory.h"
@@ -886,17 +887,18 @@ chat_lookup_contact (EmpathyTpChat *chat,
        for (l = priv->members; l; l = l->next) {
                EmpathyContact *c = l->data;
 
-               if (empathy_contact_get_handle (c) == handle) {
-                       if (remove) {
-                               /* Caller takes the reference. */
-                               priv->members = g_list_delete_link (
-                                       priv->members, l);
-                       } else {
-                               g_object_ref (c);
-                       }
+               if (empathy_contact_get_handle (c) != handle) {
+                       continue;
+               }
 
-                       return c;
+               if (remove) {
+                       /* Caller takes the reference. */
+                       priv->members = g_list_delete_link (priv->members, l);
+               } else {
+                       g_object_ref (c);
                }
+
+               return c;
        }
 
        return NULL;
@@ -914,15 +916,16 @@ tp_chat_group_members_changed_cb (TpChannel     *self,
                                  EmpathyTpChat *chat)
 {
        EmpathyTpChatPriv *priv = GET_PRIV (chat);
-       EmpathyContact *contact, *actor_contact = NULL;
+       EmpathyContact *contact;
+       EmpathyContact *actor_contact = NULL;
        guint i;
 
        if (actor != 0) {
                actor_contact = chat_lookup_contact (chat, actor, FALSE);
                if (actor_contact == NULL) {
-                       /* TODO: handle this a tad more gracefully: perhaps the
-                        * actor was a server op. We could use the contact-ids
-                        * detail of MembersChangedDetailed.
+                       /* FIXME: handle this a tad more gracefully: perhaps
+                        * the actor was a server op. We could use the
+                        * contact-ids detail of MembersChangedDetailed.
                         */
                        DEBUG ("actor %u not a channel member", actor);
                }
@@ -1030,7 +1033,7 @@ tp_chat_constructor (GType                  type,
 
                /* Get initial member contacts */
                members = tp_channel_group_get_members (priv->channel);
-               handles = tp_intset_to_array (members);         
+               handles = tp_intset_to_array (members);
                empathy_tp_contact_factory_get_from_handles (priv->factory,
                        handles->len, (TpHandle *) handles->data,
                        tp_chat_got_added_contacts_cb, NULL, NULL, chat);
@@ -1326,13 +1329,16 @@ empathy_tp_chat_set_state (EmpathyTpChat      *chat,
        g_return_if_fail (EMPATHY_IS_TP_CHAT (chat));
        g_return_if_fail (priv->ready);
 
-       DEBUG ("Set state: %d", state);
-       tp_cli_channel_interface_chat_state_call_set_chat_state (priv->channel, -1,
-                                                                state,
-                                                                tp_chat_async_cb,
-                                                                "setting chat state",
-                                                                NULL,
-                                                                G_OBJECT (chat));
+       if (tp_proxy_has_interface_by_id (priv->channel,
+                                         TP_IFACE_QUARK_CHANNEL_INTERFACE_CHAT_STATE)) {
+               DEBUG ("Set state: %d", state);
+               tp_cli_channel_interface_chat_state_call_set_chat_state (priv->channel, -1,
+                                                                        state,
+                                                                        tp_chat_async_cb,
+                                                                        "setting chat state",
+                                                                        NULL,
+                                                                        G_OBJECT (chat));
+       }
 }