[telepathy-glib/master] fd.o#24257: tp_account_prepare: fail if invalidated

David Laban david.laban at collabora.co.uk
Fri Nov 13 04:17:12 PST 2009


Added "invalidated" callback _tp_account_invalidated_cb
which causes all prepare results to complete with an error.

Also: invalidate account if get properties fails.
---
 telepathy-glib/account.c |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/telepathy-glib/account.c b/telepathy-glib/account.c
index 369f0ea..f18d999 100644
--- a/telepathy-glib/account.c
+++ b/telepathy-glib/account.c
@@ -325,6 +325,31 @@ _tp_account_become_ready (TpAccount *self,
 }
 
 static void
+_tp_account_invalidated_cb (TpAccount *self,
+    guint domain,
+    guint code,
+    gchar *message)
+{
+  TpAccountPrivate *priv = self->priv;
+  GList *l;
+
+  /* Make all currently pending callbacks fail. */
+  for (l = priv->callbacks; l != NULL; l = l->next)
+    {
+      TpAccountFeatureCallback *cb = l->data;
+
+      g_simple_async_result_set_error (cb->result,
+          domain, code, "%s", message);
+      g_simple_async_result_complete (cb->result);
+      g_object_unref (cb->result);
+      g_slice_free (TpAccountFeatureCallback, cb);
+    }
+
+  g_list_free (priv->callbacks);
+  priv->callbacks = NULL;
+}
+
+static void
 _tp_account_removed_cb (TpAccount *self,
     gpointer unused G_GNUC_UNUSED,
     GObject *object G_GNUC_UNUSED)
@@ -599,6 +624,7 @@ _tp_account_got_all_cb (TpProxy *proxy,
     {
       DEBUG ("Failed to get the initial set of account properties: %s",
           error->message);
+      tp_proxy_invalidate ((TpProxy *) self, error);
       return;
     }
 
@@ -654,6 +680,9 @@ _tp_account_constructed (GObject *object)
 
   priv->icon_name = g_strdup_printf ("im-%s", priv->proto_name);
 
+  g_signal_connect (self, "invalidated",
+      G_CALLBACK (_tp_account_invalidated_cb), NULL);
+
   tp_cli_account_connect_to_account_property_changed (self,
       _tp_account_properties_changed, NULL, NULL, object, NULL);
 
-- 
1.5.6.5




More information about the telepathy-commits mailing list