diff options
author | Alberto Mardegan <alberto.mardegan@nokia.com> | 2009-02-24 11:28:51 +0200 |
---|---|---|
committer | Alberto Mardegan <alberto.mardegan@nokia.com> | 2009-02-24 11:28:51 +0200 |
commit | 866b3dfba3142dc3e8afa8491373cdc772137d4c (patch) | |
tree | 270e3b64efcb3de12fa7993e0e597f91bc37a20d | |
parent | 23835d83aecaa63defaedc2ad16c9354da9b3ece (diff) | |
parent | d071fb9b6d971a9ee24a7c6458357f013e9f8ada (diff) |
Merge branch 'bugfixes'
-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; } |