diff options
-rw-r--r-- | src/mcd-account-connection.c | 27 | ||||
-rw-r--r-- | src/mcd-connection-plugin.h | 7 | ||||
-rw-r--r-- | src/mcd-master.c | 20 |
3 files changed, 38 insertions, 16 deletions
diff --git a/src/mcd-account-connection.c b/src/mcd-account-connection.c index 1989c81e..b7213ed8 100644 --- a/src/mcd-account-connection.c +++ b/src/mcd-account-connection.c @@ -122,6 +122,33 @@ mcd_account_connection_proceed (McdAccount *account, gboolean success) } } +/** + * 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)); + + g_object_set_data ((GObject *)account, "transport", transport); +} + +McdTransport * +_mcd_account_connection_get_transport (McdAccount *account) +{ + g_return_val_if_fail (MCD_IS_ACCOUNT (account), NULL); + + return g_object_get_data ((GObject *)account, "transport"); +} + inline void _mcd_account_connection_class_init (McdAccountClass *klass) { diff --git a/src/mcd-connection-plugin.h b/src/mcd-connection-plugin.h index 4cd719fc..80f3d8b2 100644 --- a/src/mcd-connection-plugin.h +++ b/src/mcd-connection-plugin.h @@ -29,12 +29,15 @@ #include <glib.h> #include <glib-object.h> #include "mcd-plugin.h" +#include "mcd-transport.h" G_BEGIN_DECLS typedef void (*McdAccountConnectionFunc) (McdAccount *account, GHashTable *parameters, gpointer userdata); void mcd_account_connection_proceed (McdAccount *account, gboolean success); +void mcd_account_connection_bind_transport (McdAccount *account, + McdTransport *transport); #define MCD_ACCOUNT_CONNECTION_PRIORITY_POLICY 10000 #define MCD_ACCOUNT_CONNECTION_PRIORITY_TRANSPORT 20000 @@ -45,6 +48,10 @@ void mcd_plugin_register_account_connection (McdPlugin *plugin, gint priority, gpointer userdata); +/* not exported */ +G_GNUC_INTERNAL +McdTransport *_mcd_account_connection_get_transport (McdAccount *account); + G_END_DECLS #endif /* __MCD_CONNECTION_PLUGIN_H__ */ diff --git a/src/mcd-master.c b/src/mcd-master.c index 77552d92..534e3fc8 100644 --- a/src/mcd-master.c +++ b/src/mcd-master.c @@ -129,18 +129,6 @@ typedef struct { static McdMaster *default_master = NULL; -static inline void -set_account_transport (McdAccount *account, McdTransport *transport) -{ - g_object_set_data ((GObject *)account, "transport", transport); -} - -static inline McdTransport * -get_account_transport (McdAccount *account) -{ - return g_object_get_data ((GObject *)account, "transport"); -} - static void check_account_transport (gpointer key, gpointer value, gpointer userdata) { @@ -166,7 +154,7 @@ check_account_transport (gpointer key, gpointer value, gpointer userdata) g_debug ("conditions matched"); _mcd_account_request_connection (account); if (g_hash_table_size (conditions) > 0) - set_account_transport (account, td->transport); + mcd_account_connection_bind_transport (account, td->transport); } g_hash_table_unref (conditions); } @@ -195,7 +183,7 @@ disconnect_account_transport (gpointer key, gpointer value, gpointer userdata) McdAccount *account = MCD_ACCOUNT (value); TransportData *td = userdata; - if (td->transport == get_account_transport (account)) + if (td->transport == _mcd_account_connection_get_transport (account)) { McdConnection *connection; @@ -204,7 +192,7 @@ disconnect_account_transport (gpointer key, gpointer value, gpointer userdata) connection = mcd_account_get_connection (account); if (connection) mcd_connection_close (connection); - set_account_transport (account, NULL); + mcd_account_connection_bind_transport (account, NULL); /* it may be that there is another transport to which the account can * reconnect */ @@ -1324,7 +1312,7 @@ _mcd_master_account_conditions_satisfied (McdMaster *master, mcd_transport_plugin_check_conditions (plugin, transport, conditions)) { - set_account_transport (account, transport); + mcd_account_connection_bind_transport (account, transport); ret = TRUE; goto finish; } |