diff options
author | Vivek Dasmohapatra <vivek@collabora.co.uk> | 2011-05-31 19:35:04 +0100 |
---|---|---|
committer | Vivek Dasmohapatra <vivek@collabora.co.uk> | 2011-06-01 13:51:29 +0100 |
commit | b2b8407b4c41b1bc2074882c199984bf77ade554 (patch) | |
tree | 06982c14d0fb8015dc43e9e6f76b00b020008a68 | |
parent | 9a0990b433fe9a90b1373c8aacaa5501d905f817 (diff) |
_mcd_master_account_replace_transport would accept "no connection" as a successful replacement if no account conditions were specified, forcing unwanted reconnections
-rw-r--r-- | src/mcd-master.c | 53 |
1 files changed, 29 insertions, 24 deletions
diff --git a/src/mcd-master.c b/src/mcd-master.c index 3b846223..c4866487 100644 --- a/src/mcd-master.c +++ b/src/mcd-master.c @@ -705,42 +705,47 @@ _mcd_master_account_replace_transport (McdMaster *master, { McdMasterPrivate *priv = MCD_MASTER_PRIV (master); GHashTable *conditions; - gboolean ret = FALSE; + gboolean connected = FALSE; + gboolean unconditional = FALSE; + guint i; g_return_val_if_fail (MCD_IS_ACCOUNT (account), FALSE); conditions = mcd_account_get_conditions (account); - if (g_hash_table_size (conditions) == 0) - ret = TRUE; - else + unconditional = g_hash_table_size (conditions) == 0; + + for (i = 0; !connected && i < priv->transport_plugins->len; i++) { - guint i; - for (i = 0; i < priv->transport_plugins->len; i++) + McdTransportPlugin *plugin; + const GList *transports; + + plugin = g_ptr_array_index (priv->transport_plugins, i); + transports = mcd_transport_plugin_get_transports (plugin); + + while (transports != NULL) { - McdTransportPlugin *plugin; - const GList *transports; + McdTransport *transport = transports->data; + McdTransportStatus status = + mcd_transport_get_status (plugin, transport); + + transports = g_list_next (transports); - plugin = g_ptr_array_index (priv->transport_plugins, i); - transports = mcd_transport_plugin_get_transports (plugin); - while (transports) + if (status != MCD_TRANSPORT_STATUS_CONNECTED) + continue; + + if (unconditional || + mcd_transport_plugin_check_conditions (plugin, transport, + conditions)) { - McdTransport *transport = transports->data; - if (mcd_transport_get_status (plugin, transport) == - MCD_TRANSPORT_STATUS_CONNECTED && - mcd_transport_plugin_check_conditions (plugin, transport, - conditions)) - { - mcd_account_connection_bind_transport (account, transport); - ret = TRUE; - goto finish; - } - transports = transports->next; + mcd_account_connection_bind_transport (account, transport); + connected = TRUE; + break; } } } -finish: + g_hash_table_unref (conditions); - return ret; + return connected; } gboolean |