From 50d24637ff62a964bafe2eb836ca326dc146b689 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 3 Sep 2013 18:39:36 +0100 Subject: [PATCH 03/10] Put the connectivity monitor in the McdAccountManager Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68712 --- src/kludge-transport.c | 21 +++++++++++++-------- src/kludge-transport.h | 4 +++- src/mcd-account-manager.c | 11 +++++++++++ src/mcd-account-manager.h | 4 ++++ src/mcd-master.c | 3 ++- 5 files changed, 33 insertions(+), 10 deletions(-) diff --git a/src/kludge-transport.c b/src/kludge-transport.c index 47b6cc0..c9beb5b 100644 --- a/src/kludge-transport.c +++ b/src/kludge-transport.c @@ -75,10 +75,6 @@ mcd_kludge_transport_constructed (GObject *object) if (parent_class->constructed != NULL) parent_class->constructed (object); - priv->minotaur = mcd_connectivity_monitor_new (); - tp_g_signal_connect_object (priv->minotaur, "state-change", - (GCallback) monitor_state_changed_cb, self, 0); - /* We just use ourself as the McdTransport pointer... */ priv->transports = g_list_prepend (NULL, self); @@ -235,15 +231,24 @@ mcd_kludge_transport_account_connection_cb ( } static McdTransportPlugin * -mcd_kludge_transport_new (void) +mcd_kludge_transport_new (McdConnectivityMonitor *connectivity_monitor) { - return g_object_new (MCD_TYPE_KLUDGE_TRANSPORT, NULL); + McdKludgeTransport *self = g_object_new (MCD_TYPE_KLUDGE_TRANSPORT, NULL); + + /* Strictly speaking this should be done with properties, but I'm + * going to delete this class soon anyway. */ + self->priv->minotaur = connectivity_monitor; + tp_g_signal_connect_object (self->priv->minotaur, "state-change", + (GCallback) monitor_state_changed_cb, self, 0); + + return MCD_TRANSPORT_PLUGIN (self); } void -mcd_kludge_transport_install (McdMaster *master) +mcd_kludge_transport_install (McdMaster *master, + McdConnectivityMonitor *connectivity_monitor) { - McdTransportPlugin *self = mcd_kludge_transport_new (); + McdTransportPlugin *self = mcd_kludge_transport_new (connectivity_monitor); mcd_master_register_transport (master, self); mcd_master_register_account_connection (master, diff --git a/src/kludge-transport.h b/src/kludge-transport.h index 7f27043..b246f21 100644 --- a/src/kludge-transport.h +++ b/src/kludge-transport.h @@ -23,6 +23,7 @@ #include #include "mcd-master.h" #include "mcd-transport.h" +#include "connectivity-monitor.h" typedef struct _McdKludgeTransport McdKludgeTransport; typedef struct _McdKludgeTransportClass McdKludgeTransportClass; @@ -40,7 +41,8 @@ struct _McdKludgeTransport { GType mcd_kludge_transport_get_type (void); -void mcd_kludge_transport_install (McdMaster *master); +void mcd_kludge_transport_install (McdMaster *master, + McdConnectivityMonitor *connectivity_monitor); /* TYPE MACROS */ #define MCD_TYPE_KLUDGE_TRANSPORT \ diff --git a/src/mcd-account-manager.c b/src/mcd-account-manager.c index 2948225..0dc5363 100644 --- a/src/mcd-account-manager.c +++ b/src/mcd-account-manager.c @@ -90,6 +90,7 @@ struct _McdAccountManagerPrivate { TpDBusDaemon *dbus_daemon; TpSimpleClientFactory *client_factory; + McdConnectivityMonitor *minotaur; McdStorage *storage; GHashTable *accounts; @@ -1579,6 +1580,7 @@ _mcd_account_manager_dispose (GObject *object) tp_clear_object (&priv->dbus_daemon); tp_clear_object (&priv->client_factory); + tp_clear_object (&priv->minotaur); G_OBJECT_CLASS (mcd_account_manager_parent_class)->dispose (object); } @@ -1656,6 +1658,8 @@ _mcd_account_manager_constructed (GObject *obj) DEBUG (""); + priv->minotaur = mcd_connectivity_monitor_new (); + priv->storage = mcd_storage_new (priv->dbus_daemon); priv->accounts = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, unref_account); @@ -1704,6 +1708,13 @@ mcd_account_manager_get_dbus_daemon (McdAccountManager *account_manager) return account_manager->priv->dbus_daemon; } +McdConnectivityMonitor * +mcd_account_manager_get_connectivity_monitor (McdAccountManager *self) +{ + g_return_val_if_fail (MCD_IS_ACCOUNT_MANAGER (self), NULL); + return self->priv->minotaur; +} + /** * McdAccountManagerWriteConfCb: * @account_manager: the #McdAccountManager diff --git a/src/mcd-account-manager.h b/src/mcd-account-manager.h index 8241082..922f489 100644 --- a/src/mcd-account-manager.h +++ b/src/mcd-account-manager.h @@ -27,6 +27,7 @@ #include #include "mission-control-plugins/mission-control-plugins.h" #include "mcd-storage.h" +#include "connectivity-monitor.h" G_BEGIN_DECLS #define MCD_TYPE_ACCOUNT_MANAGER (mcd_account_manager_get_type ()) @@ -81,6 +82,9 @@ McdAccount *mcd_account_manager_lookup_account_by_path (McdAccountManager *accou McdStorage *mcd_account_manager_get_storage (McdAccountManager *manager); +McdConnectivityMonitor *mcd_account_manager_get_connectivity_monitor ( + McdAccountManager *self); + G_END_DECLS #endif diff --git a/src/mcd-master.c b/src/mcd-master.c index 7d1dca0..006a27b 100644 --- a/src/mcd-master.c +++ b/src/mcd-master.c @@ -373,7 +373,8 @@ mcd_master_constructor (GType type, guint n_params, tp_proxy_get_dbus_connection (TP_PROXY (priv->dbus_daemon))), TRUE); - mcd_kludge_transport_install (master); + mcd_kludge_transport_install (master, + mcd_account_manager_get_connectivity_monitor (priv->account_manager)); /* we assume that at this point all transport plugins have been registered. * We get the active transports and check whether some accounts should be -- 1.8.4.rc3