summaryrefslogtreecommitdiff
path: root/telepathy-logger
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2013-09-23 17:28:56 +0200
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2013-09-25 16:36:30 +0200
commit30f231cc4b89aac17dd0c1426ac0f11df7056454 (patch)
treeef667425daa73568d9d768f60c5bb28821c2ac50 /telepathy-logger
parent8e85b78d6aee35b0eb7181c8ad6a870c22fc8a37 (diff)
client-factory: turn to a singleton
https://bugs.freedesktop.org/show_bug.cgi?id=69797
Diffstat (limited to 'telepathy-logger')
-rw-r--r--telepathy-logger/client-factory-internal.h2
-rw-r--r--telepathy-logger/client-factory.c18
-rw-r--r--telepathy-logger/observer.c2
3 files changed, 19 insertions, 3 deletions
diff --git a/telepathy-logger/client-factory-internal.h b/telepathy-logger/client-factory-internal.h
index 9612c30..a9e9337 100644
--- a/telepathy-logger/client-factory-internal.h
+++ b/telepathy-logger/client-factory-internal.h
@@ -54,6 +54,6 @@ GType _tpl_client_factory_get_type (void);
(G_TYPE_INSTANCE_GET_CLASS ((obj), TPL_TYPE_CLIENT_FACTORY, \
TplClientFactoryClass))
-TpSimpleClientFactory *_tpl_client_factory_new (TpDBusDaemon *dbus);
+TpSimpleClientFactory *_tpl_client_factory_dup (TpDBusDaemon *dbus);
#endif /* __TPL_CLIENT_FACTORY_H__ */
diff --git a/telepathy-logger/client-factory.c b/telepathy-logger/client-factory.c
index 0d4b131..b3dd9fe 100644
--- a/telepathy-logger/client-factory.c
+++ b/telepathy-logger/client-factory.c
@@ -94,10 +94,26 @@ _tpl_client_factory_class_init (TplClientFactoryClass *cls)
simple_class->dup_channel_features = dup_channel_features_impl;
}
-TpSimpleClientFactory *
+
+static TpSimpleClientFactory *
_tpl_client_factory_new (TpDBusDaemon *dbus)
{
return g_object_new (TPL_TYPE_CLIENT_FACTORY,
"dbus-daemon", dbus,
NULL);
}
+
+TpSimpleClientFactory *
+_tpl_client_factory_dup (TpDBusDaemon *dbus)
+{
+ static TpSimpleClientFactory *singleton = NULL;
+
+ if (singleton != NULL)
+ return g_object_ref (singleton);
+
+ singleton = _tpl_client_factory_new (dbus);
+
+ g_object_add_weak_pointer (G_OBJECT (singleton), (gpointer) &singleton);
+
+ return singleton;
+}
diff --git a/telepathy-logger/observer.c b/telepathy-logger/observer.c
index ff9a07b..02c0d1d 100644
--- a/telepathy-logger/observer.c
+++ b/telepathy-logger/observer.c
@@ -289,7 +289,7 @@ _tpl_observer_dup (GError **error)
return NULL;
}
- factory = _tpl_client_factory_new (dbus);
+ factory = _tpl_client_factory_dup (dbus);
/* Pre-select feature to be initialized. */
tp_simple_client_factory_add_contact_features_varargs (factory,