]> git.0d.be Git - empathy.git/commitdiff
Make sure we don't expect contact id and handle to be directly ready. Add some _run_u...
authorXavier Claessens <xclaesse@src.gnome.org>
Tue, 11 Mar 2008 12:22:37 +0000 (12:22 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Tue, 11 Mar 2008 12:22:37 +0000 (12:22 +0000)
svn path=/trunk/; revision=755

17 files changed:
libempathy-gtk/empathy-chat-view.c
libempathy-gtk/empathy-chat-window.c
libempathy-gtk/empathy-chat.c
libempathy-gtk/empathy-contact-dialogs.c
libempathy-gtk/empathy-contact-list-store.c
libempathy-gtk/empathy-contact-list-view.c
libempathy-gtk/empathy-contact-widget.c
libempathy-gtk/empathy-main-window.c
libempathy-gtk/empathy-private-chat.c
libempathy-gtk/empathy-status-icon.c
libempathy-gtk/empathy-theme-boxes.c
libempathy/empathy-debug.c
libempathy/empathy-tp-call.c
libempathy/empathy-tp-chatroom.c
libempathy/empathy-tp-contact-factory.c
libempathy/empathy-tp-contact-list.c
libempathy/empathy-utils.c

index f4ad7f316c4a3848f9fbe74cd2e9052478c5f22a..af523180dadc178fa24fe87bc5fac8ac9718d98a 100644 (file)
@@ -715,31 +715,19 @@ chat_view_avatar_cache_data_free (gpointer ptr)
 GdkPixbuf *
 empathy_chat_view_get_avatar_pixbuf_with_cache (EmpathyContact *contact)
 {
-       static GHashTable *avatar_cache = NULL;
        AvatarData        *data;
        EmpathyAvatar     *avatar;
        GdkPixbuf         *tmp_pixbuf;
        GdkPixbuf         *pixbuf = NULL;
 
-       /* Init avatar cache */
-       if (!avatar_cache) {
-               avatar_cache = g_hash_table_new_full (empathy_contact_hash,
-                                                     empathy_contact_equal,
-                                                     g_object_unref,
-                                                     chat_view_avatar_cache_data_free);
-       }
-
        /* Check if avatar is in cache and if it's up to date */
        avatar = empathy_contact_get_avatar (contact);
-       data = g_hash_table_lookup (avatar_cache, contact);
+       data = g_object_get_data (G_OBJECT (contact), "chat-view-avatar-cache");
        if (data) {
                if (avatar && !tp_strdiff (avatar->token, data->token)) {
                        /* We have the avatar in cache */
                        return data->pixbuf;
                }
-
-               /* The cache is outdate */
-               g_hash_table_remove (avatar_cache, contact);
        }
 
        /* Avatar not in cache, create pixbuf */
@@ -757,9 +745,8 @@ empathy_chat_view_get_avatar_pixbuf_with_cache (EmpathyContact *contact)
        data->token = g_strdup (avatar->token);
        data->pixbuf = pixbuf;
 
-       g_hash_table_insert (avatar_cache,
-                            g_object_ref (contact),
-                            data);
+       g_object_set_data_full (G_OBJECT (contact), "chat-view-avatar-cache",
+                               data, chat_view_avatar_cache_data_free);
 
        return data->pixbuf;
 }
index 5c3946e988d88d9a226b9636ae58378da682c483..bbf66fbcf5b37d22da8027c9d59b38213d40249e 100644 (file)
@@ -37,7 +37,6 @@
 #include <libmissioncontrol/mission-control.h>
 
 #include <libempathy/empathy-contact-factory.h>
-#include <libempathy/empathy-contact-list.h>
 #include <libempathy/empathy-log-manager.h>
 #include <libempathy/empathy-chatroom-manager.h>
 #include <libempathy/empathy-contact.h>
index 3494b02fd3ea2874e0ec82bab956039f445bb321..1b2fcccb2a9a09dab1ecf1df96c908e348b16d53 100644 (file)
@@ -1211,7 +1211,7 @@ chat_state_changed_cb (EmpathyTpChat      *tp_chat,
 
        /* Find the contact in the list. After that l is the list elem or NULL */
        for (l = priv->compositors; l; l = l->next) {
-               if (empathy_contact_equal (contact, l->data)) {
+               if (contact == l->data) {
                        break;
                }
        }
index e0785c3ce18b57a1a46ae2b2aef444bb79a79c86..1805213a6ff7e060479d5e2399b4d1382fb228cd 100644 (file)
@@ -53,7 +53,7 @@ contact_dialogs_find (GtkDialog      *dialog,
        contact_widget = g_object_get_data (G_OBJECT (dialog), "contact_widget");
        this_contact = empathy_contact_widget_get_contact (contact_widget);
 
-       return !empathy_contact_equal (contact, this_contact);
+       return contact != this_contact;
 }
 
 /*
index 46fa99474280545b922d6c9e3be0cf0374801d5d..84c7223ff9c1675e7a7080ea5a37b1a623dc8253 100644 (file)
@@ -880,7 +880,8 @@ contact_list_store_add_contact (EmpathyContactListStore *store,
 
        priv = GET_PRIV (store);
        
-       if (!priv->show_offline && !empathy_contact_is_online (contact)) {
+       if (!(empathy_contact_get_ready (contact) & EMPATHY_CONTACT_READY_ID) ||
+           (!priv->show_offline && !empathy_contact_is_online (contact))) {
                return;
        }
 
@@ -1488,15 +1489,14 @@ contact_list_store_find_contact_foreach (GtkTreeModel *model,
                            EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, &contact,
                            -1);
 
-       if (!contact) {
-               return FALSE;
-       }
-
-       if (empathy_contact_equal (contact, fc->contact)) {
+       if (contact == fc->contact) {
                fc->found = TRUE;
                fc->iters = g_list_append (fc->iters, gtk_tree_iter_copy (iter));
        }
-       g_object_unref (contact);
+
+       if (contact) {
+               g_object_unref (contact);
+       }
 
        return FALSE;
 }
index b12387419ab38b8285c36360eb35c8d89ea84943..24174c8b7ad4b2b7be2c51b1705e1b5e22a27d41 100644 (file)
@@ -774,6 +774,10 @@ contact_list_view_drag_data_received (GtkWidget         *widget,
                return;
        }
 
+       empathy_contact_run_until_ready (contact,
+                                        EMPATHY_CONTACT_READY_HANDLE,
+                                        NULL);
+
        model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
 
        /* Get source group information. */
index 0c3f40dc19cd623880c6f92fc2a6da17035bebb1..c0b4596de1e0699df926be63ada4039d8235b385 100644 (file)
@@ -306,9 +306,7 @@ static void
 contact_widget_set_contact (EmpathyContactWidget *information,
                            EmpathyContact        *contact)
 {
-       if (contact == information->contact ||
-           (contact && information->contact &&
-            empathy_contact_equal (contact, information->contact))) {
+       if (contact == information->contact) {
                return;
        }
 
@@ -512,6 +510,10 @@ contact_widget_change_contact (EmpathyContactWidget *information)
        }
 
        if (contact) {
+               empathy_contact_run_until_ready (contact,
+                                                EMPATHY_CONTACT_READY_HANDLE |
+                                                EMPATHY_CONTACT_READY_ID,
+                                                NULL);
                contact_widget_set_contact (information, contact);
                g_object_unref (contact);
        }
index ca8a16abf4bc12de1b0818036afa5dc5b0da7893..c447c473d839a8015e1606abc526dab6dd3c36ee 100644 (file)
@@ -669,9 +669,15 @@ main_window_edit_personal_information_cb (GtkWidget         *widget,
                account = accounts->data;
                factory = empathy_contact_factory_new ();
                contact = empathy_contact_factory_get_user (factory, account);
+               empathy_contact_run_until_ready (contact,
+                                                EMPATHY_CONTACT_READY_HANDLE |
+                                                EMPATHY_CONTACT_READY_ID,
+                                                NULL);
+
                empathy_contact_information_dialog_show (contact,
                                                         GTK_WINDOW (window->window),
                                                         TRUE, TRUE);
+
                g_slist_foreach (accounts, (GFunc) g_object_unref, NULL);
                g_slist_free (accounts);
                g_object_unref (factory);
index 4ee02e4671dea8f59ca5f232c0e45790db4fd5ea..a8b2941aa4ef97c2011adec814582e0e1df35806 100644 (file)
@@ -105,6 +105,10 @@ private_chat_constructor (GType                  type,
        priv->contact = empathy_contact_factory_get_from_handle (priv->factory,
                                                                 account,
                                                                 tp_chan->handle);
+       empathy_contact_run_until_ready (priv->contact,
+                                        EMPATHY_CONTACT_READY_ID |
+                                        EMPATHY_CONTACT_READY_NAME,
+                                        NULL);
 
        priv->name = g_strdup (empathy_contact_get_name (priv->contact));
 
index 9f10bd37eb7665996c6e8d1f1ab7390e5157bad7..241a2841f4be5dad72a73183601000ec4e8b1b2b 100644 (file)
@@ -418,6 +418,10 @@ status_icon_call_local_pending_cb (EmpathyTpGroup    *group,
 
                /* We are local pending, it's an incoming call, we need to ask
                 * the user if he wants to accept the call. */
+               empathy_contact_run_until_ready (member,
+                                                EMPATHY_CONTACT_READY_NAME,
+                                                NULL);
+
                empathy_debug (DEBUG_DOMAIN, "INCOMING call, add event");
 
                msg = g_strdup_printf (_("Incoming call from %s:\n%s"),
@@ -708,7 +712,6 @@ status_icon_pendings_changed_cb (EmpathyContactManager *manager,
        EmpathyStatusIconPriv *priv;
        StatusIconEvent       *event;
        GString               *str;
-       GList                 *l;
 
        priv = GET_PRIV (icon);
 
@@ -717,11 +720,9 @@ status_icon_pendings_changed_cb (EmpathyContactManager *manager,
                return;
        }
 
-       for (l = priv->events; l; l = l->next) {
-               if (empathy_contact_equal (contact, ((StatusIconEvent*)l->data)->user_data)) {
-                       return;
-               }
-       }
+       empathy_contact_run_until_ready (contact,
+                                        EMPATHY_CONTACT_READY_NAME,
+                                        NULL);
 
        str = g_string_new (NULL);
        g_string_printf (str, _("Subscription requested by %s"),
index 7285a9e9e061f033a4f7d623a00b871db0e571e4..4e6a272c03f6ad6154ca72f735047969329961e3 100644 (file)
@@ -573,7 +573,7 @@ theme_boxes_maybe_append_header (EmpathyTheme        *theme,
        }
        else if (!from_self &&
                 (!empathy_chat_view_get_last_contact (view) ||
-                 !empathy_contact_equal (contact, empathy_chat_view_get_last_contact (view)))) {
+                 !(contact == empathy_chat_view_get_last_contact (view)))) {
                header = TRUE;
        }
 
index f395730251c3664dc624b2bd54db38f7550856d5..d81e6dca731c5789181fc11c6fba98bde338017e 100644 (file)
@@ -54,9 +54,11 @@ debug_init (void)
                const gchar *env;
                gint         i;
 
-               env = g_getenv ("EMPATHY_DEBUG");
+               env = g_getenv ("TELEPATHY_GLIB_DEBUG");
                tp_debug_set_flags (env);
 
+               env = g_getenv ("EMPATHY_DEBUG");
+
                if (env) {
                        debug_strv = g_strsplit_set (env, ":, ", 0);
                } else {
index afc6ff657be3c9ad4a69ec86313f8a01caa30e91..d218fd8ef981666b60255caf056abe780e464be0 100644 (file)
@@ -392,7 +392,6 @@ static void
 tp_call_is_ready (EmpathyTpCall *call)
 {
   EmpathyTpCallPriv *priv = GET_PRIV (call);
-  EmpathyContact *self_contact;
   GList *members;
   GList *local_pendings;
   GList *remote_pendings;
@@ -404,13 +403,11 @@ tp_call_is_ready (EmpathyTpCall *call)
   if (!members)
     return;
 
-  self_contact = empathy_tp_group_get_self_contact (priv->group);
   local_pendings = empathy_tp_group_get_local_pendings (priv->group);
   remote_pendings = empathy_tp_group_get_remote_pendings (priv->group);
 
   if (local_pendings &&
-      empathy_contact_equal (EMPATHY_CONTACT (((EmpathyPendingInfo *)
-            local_pendings->data)->member), self_contact))
+      empathy_contact_is_user (((EmpathyPendingInfo *) local_pendings->data)->member))
     {
       empathy_debug (DEBUG_DOMAIN,
           "Incoming call is ready - %p",
@@ -418,8 +415,7 @@ tp_call_is_ready (EmpathyTpCall *call)
       priv->is_incoming = TRUE;
       priv->contact = g_object_ref (members->data);
     }
-  else if (remote_pendings &&
-      empathy_contact_equal (EMPATHY_CONTACT (members->data), self_contact))
+  else if (remote_pendings && empathy_contact_is_user (members->data))
     {
       empathy_debug (DEBUG_DOMAIN,
           "Outgoing call is ready - %p", remote_pendings->data);
@@ -428,7 +424,6 @@ tp_call_is_ready (EmpathyTpCall *call)
       tp_call_request_streams (call);
     }
 
-  g_object_unref (self_contact);
   g_list_foreach (members, (GFunc) g_object_unref, NULL);
   g_list_free (members);
   g_list_foreach (local_pendings, (GFunc) empathy_pending_info_free, NULL);
@@ -458,10 +453,8 @@ tp_call_member_added_cb (EmpathyTpGroup *group,
 
   if (priv->status == EMPATHY_TP_CALL_STATUS_PENDING)
     {
-      if ((priv->is_incoming &&
-            !empathy_contact_equal (contact, priv->contact))
-          || (!priv->is_incoming &&
-            empathy_contact_equal (contact, priv->contact)))
+      if ((priv->is_incoming && contact != priv->contact) ||
+          (!priv->is_incoming && contact == priv->contact))
         {
           priv->status = EMPATHY_TP_CALL_STATUS_ACCEPTED;
           g_signal_emit (call, signals[STATUS_CHANGED_SIGNAL], 0);
@@ -831,17 +824,13 @@ void
 empathy_tp_call_accept_incoming_call (EmpathyTpCall *call)
 {
   EmpathyTpCallPriv *priv = GET_PRIV (call);
-  GList *local_pendings;
+  EmpathyContact *self_contact;
 
   empathy_debug (DEBUG_DOMAIN, "Accepting incoming call");
 
-  local_pendings = empathy_tp_group_get_local_pendings (priv->group);
-
-  empathy_tp_group_add_member (priv->group, EMPATHY_CONTACT
-      (((EmpathyPendingInfo *) local_pendings->data)->member), NULL);
-
-  g_list_foreach (local_pendings, (GFunc) empathy_pending_info_free, NULL);
-  g_list_free (local_pendings);
+  self_contact = empathy_tp_group_get_self_contact (priv->group);
+  empathy_tp_group_add_member (priv->group, self_contact, NULL);
+  g_object_unref (self_contact);
 }
 
 void
index a00aa581b8ceea3e2c6ca54bcff6fa10aa1c33e9..b66b38d2c2ccc3e3b274019105df633a5ebfa58d 100644 (file)
@@ -46,18 +46,6 @@ static void            empathy_tp_chatroom_class_init (EmpathyTpChatroomClass  *
 static void            tp_chatroom_iface_init         (EmpathyContactListIface *iface);
 static void            empathy_tp_chatroom_init       (EmpathyTpChatroom       *chatroom);
 static void            tp_chatroom_finalize           (GObject                 *object);
-static void            tp_chatroom_member_added_cb    (EmpathyTpGroup          *group,
-                                                      EmpathyContact          *contact,
-                                                      EmpathyContact          *actor,
-                                                      guint                    reason,
-                                                      const gchar             *message,
-                                                      EmpathyTpChatroom       *chatroom);
-static void            tp_chatroom_member_removed_cb  (EmpathyTpGroup          *group,
-                                                      EmpathyContact          *contact,
-                                                      EmpathyContact          *actor,
-                                                      guint                    reason,
-                                                      const gchar             *message,
-                                                      EmpathyTpChatroom       *chatroom);
 static void            tp_chatroom_add                (EmpathyContactList      *list,
                                                       EmpathyContact           *contact,
                                                       const gchar             *message);
@@ -114,14 +102,59 @@ tp_chatroom_finalize (GObject *object)
        G_OBJECT_CLASS (empathy_tp_chatroom_parent_class)->finalize (object);
 }
 
+static void
+tp_chatroom_member_added_cb (EmpathyTpGroup    *group,
+                            EmpathyContact    *contact,
+                            EmpathyContact    *actor,
+                            guint              reason,
+                            const gchar       *message,
+                            EmpathyTpChatroom *chatroom)
+{
+       g_signal_emit_by_name (chatroom, "members-changed",
+                              contact, actor, reason, message,
+                              TRUE);
+}
+
+static void
+tp_chatroom_member_removed_cb (EmpathyTpGroup    *group,
+                              EmpathyContact    *contact,
+                              EmpathyContact    *actor,
+                              guint              reason,
+                              const gchar       *message,
+                              EmpathyTpChatroom *chatroom)
+{
+       g_signal_emit_by_name (chatroom, "members-changed",
+                              contact, actor, reason, message,
+                              FALSE);
+}
+static void
+tp_chatroom_local_pending_cb  (EmpathyTpGroup    *group,
+                              EmpathyContact    *contact,
+                              EmpathyContact    *actor,
+                              guint              reason,
+                              const gchar       *message,
+                              EmpathyTpChatroom *chatroom)
+{
+       EmpathyTpChatroomPriv *priv = GET_PRIV (chatroom);
+
+       if (empathy_contact_is_user (contact)) {
+               priv->invitor = g_object_ref (actor);
+               priv->invit_message = g_strdup (message);
+               priv->is_invited = TRUE;
+
+               empathy_debug (DEBUG_DOMAIN, "We are invited to join by %s (%d): %s",
+                              empathy_contact_get_id (priv->invitor),
+                              empathy_contact_get_handle (priv->invitor),
+                              priv->invit_message);
+       }
+}
+
 EmpathyTpChatroom *
 empathy_tp_chatroom_new (McAccount *account,
                         TpChan    *tp_chan)
 {
        EmpathyTpChatroomPriv *priv;
        EmpathyTpChatroom     *chatroom;
-       GList                 *members, *l;
-       EmpathyContact        *user;
 
        g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL);
        g_return_val_if_fail (TELEPATHY_IS_CHAN (tp_chan), NULL);
@@ -142,32 +175,9 @@ empathy_tp_chatroom_new (McAccount *account,
        g_signal_connect (priv->group, "member-removed",
                          G_CALLBACK (tp_chatroom_member_removed_cb),
                          chatroom);
-
-       /* Check if we are invited to join the chat */
-       user = empathy_tp_group_get_self_contact (priv->group);
-       members = empathy_tp_group_get_local_pendings (priv->group);
-       for (l = members; l; l = l->next) {
-               EmpathyPendingInfo *info;
-
-               info = l->data;
-
-               if (!empathy_contact_equal (user, info->member)) {
-                       continue;
-               }
-
-               priv->invitor = g_object_ref (info->actor);
-               priv->invit_message = g_strdup (info->message);
-               priv->is_invited = TRUE;
-
-               empathy_debug (DEBUG_DOMAIN, "We are invited to join by %s (%d): %s",
-                              empathy_contact_get_id (priv->invitor),
-                              empathy_contact_get_handle (priv->invitor),
-                              priv->invit_message);
-       }
-
-       g_list_foreach (members, (GFunc) empathy_pending_info_free, NULL);
-       g_list_free (members);
-       g_object_unref (user);
+       g_signal_connect (priv->group, "local-pending",
+                         G_CALLBACK (tp_chatroom_local_pending_cb),
+                         chatroom);
 
        return chatroom;
 }
@@ -229,32 +239,6 @@ empathy_tp_chatroom_set_topic (EmpathyTpChatroom *chatroom,
        /* FIXME: not implemented */
 }
 
-static void
-tp_chatroom_member_added_cb (EmpathyTpGroup    *group,
-                            EmpathyContact    *contact,
-                            EmpathyContact    *actor,
-                            guint              reason,
-                            const gchar       *message,
-                            EmpathyTpChatroom *chatroom)
-{
-       g_signal_emit_by_name (chatroom, "members-changed",
-                              contact, actor, reason, message,
-                              TRUE);
-}
-
-static void
-tp_chatroom_member_removed_cb (EmpathyTpGroup    *group,
-                              EmpathyContact    *contact,
-                              EmpathyContact    *actor,
-                              guint              reason,
-                              const gchar       *message,
-                              EmpathyTpChatroom *chatroom)
-{
-       g_signal_emit_by_name (chatroom, "members-changed",
-                              contact, actor, reason, message,
-                              FALSE);
-}
-
 static void
 tp_chatroom_add (EmpathyContactList *list,
                 EmpathyContact     *contact,
index 8773207e095cd825a35c4894e1aa104c119bbe39..bbb17394b7881d46bc9fa90a50e47df397b83810 100644 (file)
@@ -731,6 +731,8 @@ tp_contact_factory_got_self_handle_cb (TpConnection *proxy,
                return;
        }
 
+       empathy_debug (DEBUG_DOMAIN, "Connection ready");
+
        empathy_contact_set_handle (priv->user, handle);
        priv->ready = TRUE;
 
index b89384487faa9d22833dcc411d09e66ff7544354..779aa6132e888882fcddca59966e762899c4003a 100644 (file)
@@ -710,8 +710,8 @@ empathy_tp_contact_list_new (McAccount *account)
        priv->tp_conn = tp_conn;
        priv->account = g_object_ref (account);
        priv->mc = mc;
-       priv->contacts_groups = g_hash_table_new_full (empathy_contact_hash,
-                                                      empathy_contact_equal,
+       priv->contacts_groups = g_hash_table_new_full (g_direct_hash,
+                                                      g_direct_equal,
                                                       (GDestroyNotify) g_object_unref,
                                                       (GDestroyNotify) tp_contact_list_group_list_free);
 
index f54f4193fee98faa7e595fde6967e84df9cf898b..c24927b363c1ef6e93b6340ab857399e1cde0eaf 100644 (file)
@@ -452,6 +452,10 @@ empathy_call_with_contact (EmpathyContact *contact)
        group = empathy_tp_group_new (account, new_chan);
        factory = empathy_contact_factory_new ();
        self_contact = empathy_contact_factory_get_user (factory, account);
+       empathy_contact_run_until_ready (self_contact,
+                                        EMPATHY_CONTACT_READY_HANDLE,
+                                        NULL);
+
        empathy_tp_group_add_member (group, contact, "");
        empathy_tp_group_add_member (group, self_contact, "");