[folks] Handle connections which are ready as soon as they're connected



commit bae4f448fd91ac4fcf3a26ab3687da2b62080ade
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Mon Aug 2 13:12:21 2010 +0100

    Handle connections which are ready as soon as they're connected
    
    This fixes contacts from Facebook and MSN accounts sometimes not showing up
    in the contact list. Closes: bgo#625815

 backends/telepathy/tpf-persona-store.vala |   39 +++++++++++++++++-----------
 1 files changed, 24 insertions(+), 15 deletions(-)
---
diff --git a/backends/telepathy/tpf-persona-store.vala b/backends/telepathy/tpf-persona-store.vala
index c2174d9..650867a 100644
--- a/backends/telepathy/tpf-persona-store.vala
+++ b/backends/telepathy/tpf-persona-store.vala
@@ -319,24 +319,33 @@ public class Tpf.PersonaStore : Folks.PersonaStore
         return;
 
       var conn = this.account.get_connection ();
-      conn.notify["connection-ready"].connect ((s, p) =>
-        {
-          var c = (Connection) s;
+      conn.notify["connection-ready"].connect (this.connection_ready_cb);
 
-          this.ll.connection_connect_to_new_group_channels (c,
-              this.new_group_channels_cb);
+      /* Deal with the case where the connection is already ready
+       * FIXME: We have to access the property manually until bgo#571348 is
+       * fixed. */
+      bool connection_ready = false;
+      conn.get ("connection-ready", out connection_ready);
 
-          this.add_standard_channel (c, "publish");
-          this.add_standard_channel (c, "stored");
-          this.add_standard_channel (c, "subscribe");
-          this.conn = c;
+      if (connection_ready == true)
+        this.connection_ready_cb (conn, null);
+      else
+        conn.prepare_async.begin (null);
+    }
 
-          /* We can only initialise the favourite contacts once conn is prepared
-           */
-          this.initialise_favourite_contacts.begin ();
-        });
+  private void connection_ready_cb (Object s, ParamSpec? p)
+    {
+      Connection c = (Connection) s;
+      this.ll.connection_connect_to_new_group_channels (c,
+          this.new_group_channels_cb);
+
+      this.add_standard_channel (c, "publish");
+      this.add_standard_channel (c, "stored");
+      this.add_standard_channel (c, "subscribe");
+      this.conn = c;
 
-      conn.prepare_async.begin (null);
+      /* We can only initialise the favourite contacts once conn is prepared */
+      this.initialise_favourite_contacts.begin ();
     }
 
   private void new_group_channels_cb (void *data)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]