From 3a31d84ffac20a5905b23607b3832972478b8ef4 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Mon, 13 Jun 2011 01:24:18 +0200 Subject: [PATCH] Add _tp_proxy_ensure_factory --- telepathy-glib/proxy-internal.h | 3 ++ telepathy-glib/proxy.c | 25 ++++++++++++++++++++++- telepathy-glib/simple-client-factory-internal.h | 3 ++ telepathy-glib/simple-client-factory.c | 10 +++++++++ 4 files changed, 40 insertions(+), 1 deletions(-) diff --git a/telepathy-glib/proxy-internal.h b/telepathy-glib/proxy-internal.h index 4fce531..0440036 100644 --- a/telepathy-glib/proxy-internal.h +++ b/telepathy-glib/proxy-internal.h @@ -43,4 +43,7 @@ gboolean _tp_proxy_will_announce_connected_finish (TpProxy *self, GAsyncResult *result, GError **error); +void _tp_proxy_ensure_factory (gpointer self, + TpSimpleClientFactory *factory); + #endif diff --git a/telepathy-glib/proxy.c b/telepathy-glib/proxy.c index ed6d94c..4473223 100644 --- a/telepathy-glib/proxy.c +++ b/telepathy-glib/proxy.c @@ -25,12 +25,13 @@ #include #include -#include +#include #include #include "dbus-internal.h" #define DEBUG_FLAG TP_DEBUG_PROXY #include "debug-internal.h" +#include "simple-client-factory-internal.h" #include "util-internal.h" #include "_gen/signals-marshal.h" @@ -1412,6 +1413,28 @@ tp_proxy_get_factory (gpointer self) return proxy->priv->factory; } +void +_tp_proxy_ensure_factory (gpointer proxy, + TpSimpleClientFactory *factory) +{ + TpProxy *self = proxy; + + if (self->priv->factory != NULL) + return; + + if (factory != NULL) + { + self->priv->factory = g_object_ref (factory); + } + else + { + self->priv->factory = (TpSimpleClientFactory *) + tp_automatic_client_factory_new (self->dbus_daemon); + } + + _tp_simple_client_factory_insert_proxy (self->priv->factory, self); +} + /** * tp_proxy_get_dbus_daemon: * @self: a #TpProxy or subclass diff --git a/telepathy-glib/simple-client-factory-internal.h b/telepathy-glib/simple-client-factory-internal.h index cb7c974..72daa90 100644 --- a/telepathy-glib/simple-client-factory-internal.h +++ b/telepathy-glib/simple-client-factory-internal.h @@ -25,6 +25,9 @@ G_BEGIN_DECLS +void _tp_simple_client_factory_insert_proxy (TpSimpleClientFactory *self, + gpointer proxy); + TpAccountManager *_tp_account_manager_new_with_factory (TpDBusDaemon *bus_daemon, TpSimpleClientFactory *factory); diff --git a/telepathy-glib/simple-client-factory.c b/telepathy-glib/simple-client-factory.c index df5d216..8d33499 100644 --- a/telepathy-glib/simple-client-factory.c +++ b/telepathy-glib/simple-client-factory.c @@ -144,6 +144,16 @@ lookup_proxy (TpSimpleClientFactory *self, return g_hash_table_lookup (self->priv->proxy_cache, object_path); } +void +_tp_simple_client_factory_insert_proxy (TpSimpleClientFactory *self, + gpointer proxy) +{ + g_return_if_fail (lookup_proxy (self, + tp_proxy_get_object_path (proxy)) == NULL); + + insert_proxy (self, proxy); +} + static TpAccountManager * create_account_manager_impl (TpSimpleClientFactory *self) { -- 1.7.4.1