summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2011-09-08 13:46:43 +0100
committerJonny Lamb <jonny.lamb@collabora.co.uk>2011-09-08 13:59:12 +0100
commita9b6205ca39b809e0bbe113e273778413c042e93 (patch)
treebc51ca66133b2b824ebf14e55f6e4bd6e9ec32b8
parent4879bac09bfd5e138b8990baa048b29da97c8e79 (diff)
account-manager: add ensure_account function
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
-rw-r--r--docs/reference/telepathy-ytstenut-glib-sections.txt1
-rw-r--r--telepathy-ytstenut-glib/account-manager.c29
-rw-r--r--telepathy-ytstenut-glib/account-manager.h3
3 files changed, 33 insertions, 0 deletions
diff --git a/docs/reference/telepathy-ytstenut-glib-sections.txt b/docs/reference/telepathy-ytstenut-glib-sections.txt
index 854503f..ad45c85 100644
--- a/docs/reference/telepathy-ytstenut-glib-sections.txt
+++ b/docs/reference/telepathy-ytstenut-glib-sections.txt
@@ -6,6 +6,7 @@ TpYtsAccountManager
TpYtsAccountManagerClass
tp_yts_account_manager_new
tp_yts_account_manager_dup
+tp_yts_account_manager_ensure_account
tp_yts_account_manager_get_account_async
tp_yts_account_manager_get_account_finish
tp_yts_account_manager_hold
diff --git a/telepathy-ytstenut-glib/account-manager.c b/telepathy-ytstenut-glib/account-manager.c
index 4019bd1..5389927 100644
--- a/telepathy-ytstenut-glib/account-manager.c
+++ b/telepathy-ytstenut-glib/account-manager.c
@@ -209,6 +209,35 @@ tp_yts_account_manager_dup (void)
return starter_account_manager_proxy;
}
+/**
+ * tp_yts_account_manager_ensure_account:
+ * @self: a #TpYtsAccountManager
+ * @path: the account object path
+ * @error: a #GError to fill when an error is encountered
+ *
+ * Using the #TpYtsAccountManager ensure an account with object path
+ * @path. This should be used instead of tp_account_new() as it means
+ * the #TpYtsClientFactory will be propagated through to the new
+ * account and so new channel objects will be turned into
+ * #TpYtsChannel<!-- -->s.
+ *
+ * Returns: a #TpAccount
+ */
+TpAccount *
+tp_yts_account_manager_ensure_account (TpYtsAccountManager *self,
+ const gchar *path,
+ GError **error)
+{
+ TpSimpleClientFactory *factory;
+
+ g_return_val_if_fail (TP_IS_YTS_ACCOUNT_MANAGER (self), NULL);
+ g_return_val_if_fail (!tp_str_empty (path), NULL);
+
+ factory = tp_proxy_get_factory (self->priv->account_manager);
+
+ return tp_simple_client_factory_ensure_account (factory, path, NULL, error);
+}
+
static void
on_account_prepared (GObject *source,
GAsyncResult *result,
diff --git a/telepathy-ytstenut-glib/account-manager.h b/telepathy-ytstenut-glib/account-manager.h
index ec43bc8..61e0cc4 100644
--- a/telepathy-ytstenut-glib/account-manager.h
+++ b/telepathy-ytstenut-glib/account-manager.h
@@ -71,6 +71,9 @@ TpYtsAccountManager *tp_yts_account_manager_new (TpDBusDaemon *bus_daemon)
TpYtsAccountManager *tp_yts_account_manager_dup (void)
G_GNUC_WARN_UNUSED_RESULT;
+TpAccount *tp_yts_account_manager_ensure_account (TpYtsAccountManager *self,
+ const gchar *path, GError **error);
+
void tp_yts_account_manager_get_account_async (TpYtsAccountManager *self,
GCancellable *cancellable, GAsyncReadyCallback callback,
gpointer user_data);