telepathy-mission-control: _mcd_account_reconnect: if the account isn' t valid, just disconnect

Simon McVittie smcv at kemper.freedesktop.org
Tue Feb 4 06:11:11 PST 2014


Module: telepathy-mission-control
Branch: master
Commit: a9eb0c74c190d172cf3d47fa264ab5fb4a30ce62
URL:    http://cgit.freedesktop.org/telepathy/telepathy-mission-control/commit/?id=a9eb0c74c190d172cf3d47fa264ab5fb4a30ce62

Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date:   Thu Jan 30 16:59:41 2014 +0000

_mcd_account_reconnect: if the account isn't valid, just disconnect

It is not valid to call _mcd_account_connection_begin() unless the
account has a TpProtocol; in particular, if the account is "valid",
then we know it does have a TpProtocol.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=71093
Reviewed-by: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>

---

 src/mcd-account.c |   36 ++++++++++++++++--------------------
 1 file changed, 16 insertions(+), 20 deletions(-)

diff --git a/src/mcd-account.c b/src/mcd-account.c
index 79b0cc4..9374751 100644
--- a/src/mcd-account.c
+++ b/src/mcd-account.c
@@ -2664,6 +2664,11 @@ void
 _mcd_account_reconnect (McdAccount *self,
     gboolean user_initiated)
 {
+    DEBUG ("%s", mcd_account_get_unique_name (self));
+
+    /* If the account is disabled, invalid or has offline requested presence,
+     * disconnecting should be a no-op, so we keep this before checking
+     * whether we want to. */
     /* FIXME: this isn't quite right. If we've just called RequestConnection
      * (possibly with out of date parameters) but we haven't got a Connection
      * back from the CM yet, the old parameters will still be used, I think
@@ -2671,32 +2676,28 @@ _mcd_account_reconnect (McdAccount *self,
     if (self->priv->connection)
         mcd_connection_close (self->priv->connection, NULL);
 
-    _mcd_account_connection_begin (self, user_initiated);
-}
-
-static void
-account_reconnect (TpSvcAccount *service,
-                   DBusGMethodInvocation *context)
-{
-    McdAccount *self = MCD_ACCOUNT (service);
-    McdAccountPrivate *priv = self->priv;
-
-    DEBUG ("%s", mcd_account_get_unique_name (self));
-
     /* if we can't, or don't want to, connect this method is a no-op */
-    if (!priv->enabled ||
+    if (!self->priv->enabled ||
         !mcd_account_is_valid (self) ||
-        priv->req_presence_type == TP_CONNECTION_PRESENCE_TYPE_OFFLINE)
+        self->priv->req_presence_type == TP_CONNECTION_PRESENCE_TYPE_OFFLINE)
     {
         DEBUG ("doing nothing (enabled=%c, valid=%c and "
                "combined presence=%i)",
                self->priv->enabled ? 'T' : 'F',
                mcd_account_is_valid (self) ? 'T' : 'F',
                self->priv->req_presence_type);
-        tp_svc_account_return_from_reconnect (context);
         return;
     }
 
+    _mcd_account_connection_begin (self, user_initiated);
+}
+
+static void
+account_reconnect (TpSvcAccount *service,
+                   DBusGMethodInvocation *context)
+{
+    McdAccount *self = MCD_ACCOUNT (service);
+
     /* Reconnect() counts as user-initiated */
     _mcd_account_reconnect (self, TRUE);
 
@@ -4984,11 +4985,6 @@ _mcd_account_connection_begin (McdAccount *account,
 
     /* If we get this far, the account should be valid, so getting the
      * protocol should succeed.
-     *
-     * (FIXME: as far as I can see, this is not necessarily true when
-     * _mcd_account_reconnect is called by McdAccountManager? But older
-     * MC would have asserted in that situation too, so this is at least
-     * not a regression.)
      */
     protocol = mcd_account_dup_protocol (account);
     g_assert (protocol != NULL);



More information about the telepathy-commits mailing list