summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2011-09-08 13:45:16 +0100
committerJonny Lamb <jonny.lamb@collabora.co.uk>2011-09-08 13:59:12 +0100
commitba859fe40ec5849c067d71d7d7d2533c1e93fd48 (patch)
tree0ff4cbfcd0c9b041d307720dac00db20c3b15325
parent3177f72e2c248643bf69ec5fda488d8361d5c1e1 (diff)
account-manager: store an actual TpAccountManager to retain the client factory
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
-rw-r--r--telepathy-ytstenut-glib/account-manager.c46
1 files changed, 45 insertions, 1 deletions
diff --git a/telepathy-ytstenut-glib/account-manager.c b/telepathy-ytstenut-glib/account-manager.c
index 19c901c..4019bd1 100644
--- a/telepathy-ytstenut-glib/account-manager.c
+++ b/telepathy-ytstenut-glib/account-manager.c
@@ -24,6 +24,8 @@
#include "account-manager.h"
+#include "client-factory.h"
+
#include <telepathy-glib/defs.h>
#include <telepathy-glib/gtypes.h>
#include <telepathy-glib/interfaces.h>
@@ -79,18 +81,46 @@
G_DEFINE_TYPE (TpYtsAccountManager, tp_yts_account_manager, TP_TYPE_PROXY);
+struct _TpYtsAccountManagerPrivate
+{
+ /* We have to store this and not simply subclass it because that
+ * would change TpProxy:object-path from
+ * /org/freedesktop/Telepathy/AccountManager to
+ * /com/meego/xpmn/ytstenut/AccountManager which would mean loads of
+ * things (like how TpAM calls GetAll on ofdTp.AM) would stop
+ * working. This is a shame. Oh well. */
+ TpAccountManager *account_manager;
+};
+
static void
tp_yts_account_manager_init (TpYtsAccountManager *self)
{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, TP_TYPE_YTS_ACCOUNT_MANAGER,
+ TpYtsAccountManagerPrivate);
+}
+
+static void
+tp_yts_account_manager_dispose (GObject *object)
+{
+ TpYtsAccountManager *self = TP_YTS_ACCOUNT_MANAGER (object);
+ TpYtsAccountManagerPrivate *priv = self->priv;
+
+ tp_clear_object (&priv->account_manager);
+ G_OBJECT_CLASS (tp_yts_account_manager_parent_class)->dispose (object);
}
static void
tp_yts_account_manager_class_init (TpYtsAccountManagerClass *klass)
{
+ GObjectClass *object_class = (GObjectClass *) klass;
TpProxyClass *proxy_class = (TpProxyClass *) klass;
GType tp_type = TP_TYPE_YTS_ACCOUNT_MANAGER;
+ g_type_class_add_private (klass, sizeof (TpYtsAccountManagerPrivate));
+
+ object_class->dispose = tp_yts_account_manager_dispose;
+
proxy_class->interface = TP_YTS_IFACE_QUARK_ACCOUNT_MANAGER;
tp_proxy_init_known_interfaces ();
@@ -116,6 +146,7 @@ TpYtsAccountManager *
tp_yts_account_manager_new (TpDBusDaemon *bus_daemon)
{
TpYtsAccountManager *self;
+ TpSimpleClientFactory *factory;
g_return_val_if_fail (TP_IS_DBUS_DAEMON (bus_daemon), NULL);
@@ -126,6 +157,10 @@ tp_yts_account_manager_new (TpDBusDaemon *bus_daemon)
"object-path", TP_YTS_ACCOUNT_MANAGER_OBJECT_PATH,
NULL));
+ factory = tp_yts_client_factory_new (bus_daemon);
+ self->priv->account_manager = tp_account_manager_new_with_factory (factory);
+ g_object_unref (factory);
+
return self;
}
@@ -150,6 +185,7 @@ TpYtsAccountManager *
tp_yts_account_manager_dup (void)
{
TpDBusDaemon *dbus;
+ TpYtsAccountManager *self;
if (starter_account_manager_proxy != NULL)
return g_object_ref (starter_account_manager_proxy);
@@ -166,6 +202,10 @@ tp_yts_account_manager_dup (void)
g_object_unref (dbus);
+ self = starter_account_manager_proxy;
+
+ tp_account_manager_set_default (self->priv->account_manager);
+
return starter_account_manager_proxy;
}
@@ -203,6 +243,7 @@ on_account_manager_get_account_returned (TpProxy *proxy,
gpointer user_data,
GObject *weak_object)
{
+ TpYtsAccountManager *self = TP_YTS_ACCOUNT_MANAGER (weak_object);
GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data);
TpAccount *account;
GError *err = NULL;
@@ -211,7 +252,10 @@ on_account_manager_get_account_returned (TpProxy *proxy,
if (error == NULL)
{
path = g_value_get_boxed (value);
- account = tp_account_new (tp_proxy_get_dbus_daemon (proxy), path, &err);
+
+ account = tp_simple_client_factory_ensure_account (
+ tp_proxy_get_factory (self->priv->account_manager),
+ path, NULL, &err);
if (err == NULL)
{
tp_proxy_prepare_async (account, NULL, on_account_prepared,