From a9dc3039532f108eeb1bec2484240c1e1fd5053b Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 29 Aug 2013 15:38:53 +0100 Subject: [PATCH 08/16] Remove the concept of binding accounts to transports We only have one transport now, so there are two options: either the account is a special one that "needs dispatch" and also bypasses the transport check (in practice this means cellular accounts), or it is connected via the Internet. Binding accounts to transports never made a vast amount of sense. If we have many parallel Internet connections (e.g. wired + wifi + cellular + VPN), Mission Control can't know which one a Connection is relying on - only the connection manager can know that - so we have to err on the side of disconnecting everything on a connectivity change anyway. A possible refinement in future Tp versions would be a way for a CM to tell MC "this connection does its own connectivity-monitoring, so don't kick it when we get disconnected". For now, we assume that everything needs the Internet, unless it's one of the accounts that wouldn't previously have been bound to a connection (i.e. _mcd_account_needs_dispatch() returns FALSE). --- src/kludge-transport.c | 2 -- src/mcd-account-priv.h | 2 -- src/mcd-account.c | 54 ++------------------------------------------- src/mcd-connection-plugin.h | 2 -- src/mcd-master.c | 20 ++++++----------- 5 files changed, 9 insertions(+), 71 deletions(-) diff --git a/src/kludge-transport.c b/src/kludge-transport.c index 4a0dd9c..47b6cc0 100644 --- a/src/kludge-transport.c +++ b/src/kludge-transport.c @@ -196,7 +196,6 @@ monitor_state_changed_cb ( */ DEBUG ("telling %s to %s", mcd_account_get_unique_name (account), connected ? "proceed" : "give up"); - mcd_account_connection_bind_transport (account, (McdTransport *) self); mcd_account_connection_proceed_with_reason (account, connected, connected ? TP_CONNECTION_STATUS_REASON_NONE_SPECIFIED : TP_CONNECTION_STATUS_REASON_NETWORK_ERROR); @@ -223,7 +222,6 @@ mcd_kludge_transport_account_connection_cb ( if (mcd_connectivity_monitor_is_online (priv->minotaur)) { - mcd_account_connection_bind_transport (account, (McdTransport *) self); mcd_account_connection_proceed (account, TRUE); } else if (g_hash_table_lookup (priv->pending_accounts, account) == NULL) diff --git a/src/mcd-account-priv.h b/src/mcd-account-priv.h index e80eb99..9063b1a 100644 --- a/src/mcd-account-priv.h +++ b/src/mcd-account-priv.h @@ -121,8 +121,6 @@ _mcd_account_write_conf (McdAccount *account) G_GNUC_INTERNAL void _mcd_account_connection_begin (McdAccount *account, gboolean user_initiated); G_GNUC_INTERNAL void _mcd_account_connection_class_init (McdAccountClass *klass); -G_GNUC_INTERNAL McdTransport *_mcd_account_connection_get_transport - (McdAccount *account); extern const McdDBusProp account_channelrequests_properties[]; diff --git a/src/mcd-account.c b/src/mcd-account.c index 5faf104..012367f 100644 --- a/src/mcd-account.c +++ b/src/mcd-account.c @@ -128,7 +128,6 @@ struct _McdAccountPrivate McdStorage *storage; TpDBusDaemon *dbus_daemon; - McdTransport *transport; McdAccountConnectionContext *connection_context; GKeyFile *keyfile; /* configuration file */ McpAccountStorage *storage_plugin; @@ -175,6 +174,8 @@ struct _McdAccountPrivate gboolean setting_avatar; gboolean hidden; + /* In addition to affecting dispatching, this flag also makes this + * account bypass connectivity checks. */ gboolean always_dispatch; /* These fields are used to cache the changed properties */ @@ -5016,7 +5017,6 @@ _mcd_account_set_connection (McdAccount *account, McdConnection *connection) else { priv->conn_status = TP_CONNECTION_STATUS_DISCONNECTED; - priv->transport = NULL; } } @@ -5041,56 +5041,6 @@ _mcd_account_set_has_been_online (McdAccount *account) } } -/** - * mcd_account_connection_bind_transport: - * @account: the #McdAccount. - * @transport: the #McdTransport. - * - * Set @account as dependent on @transport; connectivity plugins should call - * this function in the callback they registered with - * mcd_plugin_register_account_connection(). This tells the account manager to - * disconnect @account when @transport goes away. - */ -void -mcd_account_connection_bind_transport (McdAccount *account, - McdTransport *transport) -{ - g_return_if_fail (MCD_IS_ACCOUNT (account)); - - if (transport == account->priv->transport) - { - DEBUG ("account %s transport remains %p", - account->priv->unique_name, transport); - } - else if (transport == NULL) - { - DEBUG ("unbinding account %s from transport %p", - account->priv->unique_name, account->priv->transport); - account->priv->transport = NULL; - } - else if (account->priv->transport == NULL) - { - DEBUG ("binding account %s to transport %p", - account->priv->unique_name, transport); - - account->priv->transport = transport; - } - else - { - DEBUG ("disallowing migration of account %s from transport %p to %p", - account->priv->unique_name, account->priv->transport, - transport); - } -} - -McdTransport * -_mcd_account_connection_get_transport (McdAccount *account) -{ - g_return_val_if_fail (MCD_IS_ACCOUNT (account), NULL); - - return account->priv->transport; -} - McdAccountConnectionContext * _mcd_account_get_connection_context (McdAccount *self) { diff --git a/src/mcd-connection-plugin.h b/src/mcd-connection-plugin.h index 3ab255b..1e070e4 100644 --- a/src/mcd-connection-plugin.h +++ b/src/mcd-connection-plugin.h @@ -37,8 +37,6 @@ G_BEGIN_DECLS void mcd_account_connection_proceed (McdAccount *account, gboolean success); void mcd_account_connection_proceed_with_reason (McdAccount *account, gboolean success, TpConnectionStatusReason reason); -void mcd_account_connection_bind_transport (McdAccount *account, - McdTransport *transport); gboolean mcd_account_connection_is_user_initiated (McdAccount *account); #define MCD_ACCOUNT_CONNECTION_PRIORITY_POLICY 10000 diff --git a/src/mcd-master.c b/src/mcd-master.c index b5b8f7b..7d1dca0 100644 --- a/src/mcd-master.c +++ b/src/mcd-master.c @@ -152,7 +152,6 @@ mcd_master_transport_connected (McdMaster *master, McdTransportPlugin *plugin, DEBUG ("account %s would like to connect", mcd_account_get_unique_name (account)); _mcd_account_connect_with_auto_presence (account, FALSE); - mcd_account_connection_bind_transport (account, transport); } } @@ -174,7 +173,13 @@ mcd_master_transport_disconnected (McdMaster *master, McdTransportPlugin *plugin { McdAccount *account = MCD_ACCOUNT (v); - if (transport == _mcd_account_connection_get_transport (account)) + if (_mcd_account_needs_dispatch (account)) + { + /* special treatment for cellular accounts */ + DEBUG ("account %s is always dispatched and does not need a " + "transport", mcd_account_get_unique_name (account)); + } + else { McdConnection *connection; @@ -183,16 +188,6 @@ mcd_master_transport_disconnected (McdMaster *master, McdTransportPlugin *plugin connection = mcd_account_get_connection (account); if (connection) mcd_connection_close (connection); - mcd_account_connection_bind_transport (account, NULL); - - /* it may be that there is another transport to which the account - * can reconnect */ - if (_mcd_master_account_replace_transport (master, account)) - { - DEBUG ("conditions matched"); - _mcd_account_connect_with_auto_presence (account, FALSE); - } - } } } @@ -615,7 +610,6 @@ _mcd_master_account_replace_transport (McdMaster *master, if (status != MCD_TRANSPORT_STATUS_CONNECTED) continue; - mcd_account_connection_bind_transport (account, transport); connected = TRUE; break; } -- 1.8.4.rc3