telepathy-mission-control: McdStorage: remove _mcd_storage_store_connections
Simon McVittie
smcv at kemper.freedesktop.org
Tue Aug 28 08:15:59 PDT 2012
Module: telepathy-mission-control
Branch: master
Commit: 61066078763c94ef9ce7d674b7b2e19efe6d709e
URL: http://cgit.freedesktop.org/telepathy/telepathy-mission-control/commit/?id=61066078763c94ef9ce7d674b7b2e19efe6d709e
Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date: Mon Aug 27 18:02:51 2012 +0100
McdStorage: remove _mcd_storage_store_connections
I'm not sure why this was in McdStorage at all. It's a bit of a layering
violation: AccountManager has a Storage, so Storage shouldn't call into
AccountManager. We can fix the layering violation by adding a signal
to McdAccount.
Signed-off-by: Simon McVittie <simon.mcvittie at collabora.co.uk>
Reviewed-by: Xavier Claessens <xavier.claessens at collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=54151
---
src/Makefile.am | 1 -
src/mcd-account-manager-priv.h | 4 ----
src/mcd-account-manager.c | 8 +++++++-
src/mcd-account.c | 17 ++++++++++++++---
src/mcd-storage-priv.h | 35 -----------------------------------
src/mcd-storage.c | 17 +----------------
6 files changed, 22 insertions(+), 60 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 0c78fc4..cb94760 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -161,7 +161,6 @@ libmcd_convenience_la_SOURCES = \
mcd-transport.c \
mcd-storage.c \
mcd-storage.h \
- mcd-storage-priv.h \
plugin-dispatch-operation.c \
plugin-dispatch-operation.h \
plugin-loader.c \
diff --git a/src/mcd-account-manager-priv.h b/src/mcd-account-manager-priv.h
index 170953e..80a1e0f 100644
--- a/src/mcd-account-manager-priv.h
+++ b/src/mcd-account-manager-priv.h
@@ -50,10 +50,6 @@ G_GNUC_INTERNAL void _mcd_account_manager_create_account
const gchar *display_name, GHashTable *params, GHashTable *properties,
McdGetAccountCb callback, gpointer user_data, GDestroyNotify destroy);
-G_GNUC_INTERNAL
-void _mcd_account_manager_store_account_connections
- (McdAccountManager *manager);
-
G_END_DECLS
#endif
diff --git a/src/mcd-account-manager.c b/src/mcd-account-manager.c
index 45a50e6..4c11da9 100644
--- a/src/mcd-account-manager.c
+++ b/src/mcd-account-manager.c
@@ -655,6 +655,9 @@ unref_account (gpointer data)
g_object_unref (account);
}
+static void _mcd_account_manager_store_account_connections (
+ McdAccountManager *);
+
static void
add_account (McdAccountManager *account_manager, McdAccount *account,
const gchar *source)
@@ -682,6 +685,9 @@ add_account (McdAccountManager *account_manager, McdAccount *account,
account_manager);
g_signal_connect (account, "removed", G_CALLBACK (on_account_removed),
account_manager);
+ tp_g_signal_connect_object (account, "connection-path-changed",
+ G_CALLBACK (_mcd_account_manager_store_account_connections),
+ account_manager, G_CONNECT_SWAPPED);
/* some reports indicate this doesn't always fire for async backend *
* accounts: testing here hasn't shown this, but at least we will be *
@@ -1750,7 +1756,7 @@ mcd_account_manager_lookup_account_by_path (McdAccountManager *account_manager,
* The data is stored in a temporary file, and can be read when MC restarts
* after a crash.
*/
-void
+static void
_mcd_account_manager_store_account_connections (McdAccountManager *manager)
{
McdAccountManagerPrivate *priv;
diff --git a/src/mcd-account.c b/src/mcd-account.c
index 644ad15..c07ba67 100644
--- a/src/mcd-account.c
+++ b/src/mcd-account.c
@@ -23,7 +23,6 @@
#include "config.h"
#include "mcd-account.h"
-#include "mcd-storage-priv.h"
#include <stdio.h>
#include <string.h>
@@ -198,6 +197,7 @@ enum
{
CONNECTION_STATUS_CHANGED,
VALIDITY_CHANGED,
+ CONNECTION_PATH_CHANGED,
LAST_SIGNAL
};
@@ -3156,6 +3156,13 @@ mcd_account_class_init (McdAccountClass * klass)
NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
G_TYPE_NONE, 1,
G_TYPE_BOOLEAN);
+ _mcd_account_signals[CONNECTION_PATH_CHANGED] =
+ g_signal_new ("connection-path-changed",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL, g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1, G_TYPE_STRING);
_mcd_account_connection_class_init (klass);
@@ -3976,6 +3983,9 @@ mcd_account_get_connection_status (McdAccount *account)
return priv->conn_status;
}
+/* FIXME: if this was only called from _mcd_account_set_connection_status,
+ * we could combine CONNECTION_STATUS_CHANGED and CONNECTION_PATH_CHANGED
+ * into one signal... but for now, this is also called from McdConnection */
void
_mcd_account_tp_connection_changed (McdAccount *account,
TpConnection *tp_conn)
@@ -3994,9 +4004,10 @@ _mcd_account_tp_connection_changed (McdAccount *account,
}
mcd_account_changed_property (account, "Connection", &value);
- g_value_unset (&value);
- _mcd_storage_store_connections (account->priv->storage);
+ g_signal_emit (account, _mcd_account_signals[CONNECTION_PATH_CHANGED], 0,
+ g_value_get_boxed (&value));
+ g_value_unset (&value);
}
McdConnection *
diff --git a/src/mcd-storage-priv.h b/src/mcd-storage-priv.h
deleted file mode 100644
index 1b550d8..0000000
--- a/src/mcd-storage-priv.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Mission Control storage API - interface which provides access to account
- * parameter/setting storage
- *
- * Copyright © 2010 Nokia Corporation
- * Copyright © 2010 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <glib-object.h>
-#include <mission-control-plugins/mission-control-plugins.h>
-#include "mcd-storage.h"
-
-#ifndef MCD_STORAGE_PRIV_H
-#define MCD_STORAGE_PRIV_H
-
-G_BEGIN_DECLS
-
-G_GNUC_INTERNAL void _mcd_storage_store_connections (McdStorage *storage);
-
-G_END_DECLS
-
-#endif /* MCD_STORAGE_H */
diff --git a/src/mcd-storage.c b/src/mcd-storage.c
index 4166215..aa5f43d 100644
--- a/src/mcd-storage.c
+++ b/src/mcd-storage.c
@@ -21,7 +21,7 @@
#include "config.h"
-#include "mcd-storage-priv.h"
+#include "mcd-storage.h"
#include "mcd-master.h"
#include "mcd-account-manager-priv.h"
@@ -93,18 +93,3 @@ mcd_storage_set_strv (McdStorage *storage,
g_value_unset (&v);
return ret;
}
-
-void
-_mcd_storage_store_connections (McdStorage *storage)
-{
- McdMaster *master = mcd_master_get_default ();
- McdAccountManager *account_manager = NULL;
-
- g_object_get (master, "account-manager", &account_manager, NULL);
-
- if (account_manager != NULL)
- {
- _mcd_account_manager_store_account_connections (account_manager);
- g_object_unref (account_manager);
- }
-}
More information about the telepathy-commits
mailing list