[Pkg-telepathy-commits] [telepathy-glib-1] 73/212: TpLogger: Always create from a factory
Simon McVittie
smcv at debian.org
Wed May 14 12:08:53 UTC 2014
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to branch debian
in repository telepathy-glib-1.
commit cbeca8cb478f5bd4366e3c37e7a115385216210a
Author: Xavier Claessens <xavier.claessens at collabora.com>
Date: Sat Mar 29 18:29:12 2014 -0400
TpLogger: Always create from a factory
---
.../telepathy-glib/telepathy-glib-sections.txt | 1 +
telepathy-glib/client-factory-internal.h | 2 +
telepathy-glib/client-factory.c | 27 ++++++++++++
telepathy-glib/client-factory.h | 2 +
telepathy-glib/logger.c | 49 ++++++++++------------
5 files changed, 54 insertions(+), 27 deletions(-)
diff --git a/docs/reference/telepathy-glib/telepathy-glib-sections.txt b/docs/reference/telepathy-glib/telepathy-glib-sections.txt
index 2a5e9a5..90a7e35 100644
--- a/docs/reference/telepathy-glib/telepathy-glib-sections.txt
+++ b/docs/reference/telepathy-glib/telepathy-glib-sections.txt
@@ -5730,6 +5730,7 @@ tp_client_factory_get_dbus_connection
<SUBSECTION>
tp_client_factory_ensure_account_manager
tp_client_factory_ensure_channel_dispatcher
+tp_client_factory_dup_logger
<SUBSECTION>
tp_client_factory_ensure_account
tp_client_factory_dup_account_features
diff --git a/telepathy-glib/client-factory-internal.h b/telepathy-glib/client-factory-internal.h
index 0516a1e..09e2537 100644
--- a/telepathy-glib/client-factory-internal.h
+++ b/telepathy-glib/client-factory-internal.h
@@ -90,6 +90,8 @@ TpConnectionManager *_tp_connection_manager_new (TpClientFactory *factory,
GError **error);
gchar *_tp_connection_manager_build_object_path (const gchar *name);
+TpLogger *_tp_logger_new (TpClientFactory *factory);
+
G_END_DECLS
#endif
diff --git a/telepathy-glib/client-factory.c b/telepathy-glib/client-factory.c
index a628ff8..09d91dd 100644
--- a/telepathy-glib/client-factory.c
+++ b/telepathy-glib/client-factory.c
@@ -679,6 +679,33 @@ tp_client_factory_ensure_channel_dispatcher (TpClientFactory *self)
}
/**
+ * tp_client_factory_dup_logger:
+ * @self: a #TpClientFactory object
+ *
+ * <!-- -->
+ *
+ * Returns: (transfer full): a reference to a #TpLogger singleton.
+ *
+ * Since: 0.UNRELEASED
+ */
+TpLogger *
+tp_client_factory_dup_logger (TpClientFactory *self)
+{
+ TpLogger *logger;
+
+ g_return_val_if_fail (TP_IS_CLIENT_FACTORY (self), NULL);
+
+ logger = lookup_proxy (self, TP_LOGGER_OBJECT_PATH);
+ if (logger != NULL)
+ return g_object_ref (logger);
+
+ logger = _tp_logger_new (self);
+ insert_proxy (self, logger);
+
+ return logger;
+}
+
+/**
* tp_client_factory_ensure_account:
* @self: a #TpClientFactory object
* @object_path: the object path of an account
diff --git a/telepathy-glib/client-factory.h b/telepathy-glib/client-factory.h
index dc802a7..8df4679 100644
--- a/telepathy-glib/client-factory.h
+++ b/telepathy-glib/client-factory.h
@@ -36,6 +36,7 @@
#include <telepathy-glib/contact.h>
#include <telepathy-glib/dbus-daemon.h>
#include <telepathy-glib/debug-client.h>
+#include <telepathy-glib/logger.h>
#include <telepathy-glib/protocol.h>
#include <telepathy-glib/tls-certificate.h>
@@ -139,6 +140,7 @@ TpAccountManager *tp_client_factory_ensure_account_manager (
TpClientFactory *self);
TpChannelDispatcher *tp_client_factory_ensure_channel_dispatcher (
TpClientFactory *self);
+TpLogger *tp_client_factory_dup_logger (TpClientFactory *self);
/* TpAccount */
TpAccount *tp_client_factory_ensure_account (TpClientFactory *self,
diff --git a/telepathy-glib/logger.c b/telepathy-glib/logger.c
index bb1e281..fe06d25 100644
--- a/telepathy-glib/logger.c
+++ b/telepathy-glib/logger.c
@@ -27,6 +27,7 @@
#include <telepathy-glib/proxy-subclass.h>
#define DEBUG_FLAG TP_DEBUG_PROXY
+#include "telepathy-glib/client-factory-internal.h"
#include "telepathy-glib/debug-internal.h"
#include "telepathy-glib/dbus-internal.h"
@@ -79,51 +80,45 @@ tp_logger_init (TpLogger *self)
TP_TYPE_LOGGER, TpLoggerPriv);
}
-static gpointer logger_singleton = NULL;
+TpLogger *
+_tp_logger_new (TpClientFactory *factory)
+{
+ return g_object_new (TP_TYPE_LOGGER,
+ "dbus-daemon", tp_client_factory_get_dbus_daemon (factory),
+ "bus-name", TP_LOGGER_BUS_NAME,
+ "object-path", TP_LOGGER_OBJECT_PATH,
+ "factory", factory,
+ NULL);
+}
/**
* tp_logger_dup:
*
- * Returns an logger proxy on the session bus.
- * This logger proxy will always have
- * the result of tp_dbus_daemon_dup() as its #TpProxy:dbus-daemon.
+ * Returns the default #TpClientFactory's #TpLogger. It will use
+ * tp_client_factory_dup(), print a warning and return %NULL if it fails.
*
- * The returned #TpLogger is cached; the same #TpLogger object
- * will be returned by this function repeatedly, as long as at least one
- * reference exists.
+ * Returns: (transfer full): a reference on a #TpLogger singleton.
*
- * Returns: (transfer full): an logger proxy on the session
- * bus, or %NULL if it wasn't possible to get a dbus daemon proxy for
- * the appropriate bus
-
* Since: 0.99.8
*/
TpLogger *
tp_logger_dup (void)
{
- TpDBusDaemon *dbus;
+ TpLogger *self;
+ TpClientFactory *factory;
GError *error = NULL;
- if (logger_singleton != NULL)
- g_object_ref (logger_singleton);
-
- dbus = tp_dbus_daemon_dup (&error);
- if (dbus == NULL)
+ factory = tp_client_factory_dup (&error);
+ if (factory == NULL)
{
- WARNING ("Error getting default TpDBusDaemon: %s", error->message);
+ WARNING ("Error getting default TpClientFactory: %s", error->message);
g_clear_error (&error);
return NULL;
}
- logger_singleton = g_object_new (TP_TYPE_LOGGER,
- "dbus-daemon", dbus,
- "bus-name", TP_LOGGER_BUS_NAME,
- "object-path", TP_LOGGER_OBJECT_PATH,
- NULL);
+ self = tp_client_factory_dup_logger (factory);
- g_assert (logger_singleton != NULL);
- g_object_add_weak_pointer (logger_singleton, &logger_singleton);
+ g_object_unref (factory);
- g_object_unref (dbus);
- return logger_singleton;
+ return self;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-telepathy/telepathy-glib-1.git
More information about the Pkg-telepathy-commits
mailing list