From a03abe920238ad1b3aa2580fa259b740aabec2ad Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 30 Jan 2014 16:59:41 +0000 Subject: [PATCH 4/5] _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 --- 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); -- 1.9.rc1