[Telepathy-commits] [telepathy-mission-control/master] Make McAccountManager a singleton
mardy
mardy at 64d1ce6a-1406-0410-9ac8-afed03b27183
Mon Nov 17 00:05:14 PST 2008
Always return the previous instance. If this is not always desirable, we might
later introduce some API to disable this behaviour.
git-svn-id: https://projects.maemo.org/svn/chavo/trunk/framework/open/telepathy-mission-control@20539 64d1ce6a-1406-0410-9ac8-afed03b27183
---
libmcclient/mc-account-manager.c | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/libmcclient/mc-account-manager.c b/libmcclient/mc-account-manager.c
index 598c1f4..d6822ca 100644
--- a/libmcclient/mc-account-manager.c
+++ b/libmcclient/mc-account-manager.c
@@ -95,6 +95,8 @@ enum
guint _mc_account_manager_signals[LAST_SIGNAL] = { 0 };
+static McAccountManager *account_manager_singleton = NULL;
+
static void create_props (TpProxy *proxy, GHashTable *props);
static void setup_props_monitor (TpProxy *proxy, GQuark interface);
@@ -238,6 +240,23 @@ manager_props_free (McAccountManagerProps *props)
g_free (props);
}
+static GObject *
+constructor (GType type, guint n_params, GObjectConstructParam *params)
+{
+ GObject *object;
+
+ if (!account_manager_singleton)
+ {
+ object = G_OBJECT_CLASS (mc_account_manager_parent_class)->constructor
+ (type, n_params, params);
+ account_manager_singleton = MC_ACCOUNT_MANAGER (object);
+ }
+ else
+ object = g_object_ref (account_manager_singleton);
+
+ return object;
+}
+
static void
dispose (GObject *object)
{
@@ -274,6 +293,7 @@ mc_account_manager_class_init (McAccountManagerClass *klass)
TpProxyClass *proxy_class = (TpProxyClass *) klass;
g_type_class_add_private (object_class, sizeof (McAccountManagerPrivate));
+ object_class->constructor = constructor;
object_class->finalize = finalize;
object_class->dispose = dispose;
--
1.5.6.5
More information about the Telepathy-commits
mailing list