[next] telepathy-glib: tp_account_manager_create_account_async: use GVariant

Guillaume Desmottes gdesmott at kemper.freedesktop.org
Thu Feb 27 06:07:36 PST 2014


Module: telepathy-glib
Branch: next
Commit: 21db3a0d772b76a058334ceee9e13b2fc30cc116
URL:    http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=21db3a0d772b76a058334ceee9e13b2fc30cc116

Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date:   Wed Feb 19 16:00:18 2014 +0100

tp_account_manager_create_account_async: use GVariant

---

 telepathy-glib/account-manager.c |   27 +++++++++++++++++++++------
 telepathy-glib/account-manager.h |    2 +-
 2 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/telepathy-glib/account-manager.c b/telepathy-glib/account-manager.c
index 5a7b39d..f17c8fe 100644
--- a/telepathy-glib/account-manager.c
+++ b/telepathy-glib/account-manager.c
@@ -31,6 +31,7 @@
 #include <telepathy-glib/proxy-subclass.h>
 #include <telepathy-glib/util-internal.h>
 #include <telepathy-glib/util.h>
+#include <telepathy-glib/variant-util-internal.h>
 
 #include "telepathy-glib/account-manager.h"
 
@@ -1224,9 +1225,9 @@ _tp_account_manager_created_cb (TpAccountManager *proxy,
  * @connection_manager: the name of a connection manager
  * @protocol: the name of a protocol
  * @display_name: the display name for the account
- * @parameters: (element-type utf8 GObject.Value) (transfer none): parameters
+ * @parameters: a #G_VARIANT_TYPE_VARDICT #GVariant containing the parameters
  *  for the new account
- * @properties: (element-type utf8 GObject.Value) (transfer none): properties
+ * @properties: a #G_VARIANT_TYPE_VARDICT #GVariant containing the properties
  *  for the new account
  * @callback: a callback to call when the request is satisfied
  * @user_data: data to pass to @callback
@@ -1242,6 +1243,8 @@ _tp_account_manager_created_cb (TpAccountManager *proxy,
  * tp_simple_client_factory_add_account_features() for the account
  * manager's #TpProxy:factory.
  *
+ * @parameters and @properties are consumed if they are floating.
+ *
  * It is usually better to use #TpAccountRequest instead, particularly when
  * using high-level language bindings.
  *
@@ -1252,12 +1255,13 @@ tp_account_manager_create_account_async (TpAccountManager *manager,
     const gchar *connection_manager,
     const gchar *protocol,
     const gchar *display_name,
-    GHashTable *parameters,
-    GHashTable *properties,
+    GVariant *parameters,
+    GVariant *properties,
     GAsyncReadyCallback callback,
     gpointer user_data)
 {
   GSimpleAsyncResult *res;
+  GHashTable *params_asv, *props_asv;
 
   g_return_if_fail (TP_IS_ACCOUNT_MANAGER (manager));
   g_return_if_fail (connection_manager != NULL);
@@ -1270,10 +1274,21 @@ tp_account_manager_create_account_async (TpAccountManager *manager,
   res = g_simple_async_result_new (G_OBJECT (manager), callback, user_data,
       tp_account_manager_create_account_finish);
 
+  g_variant_ref_sink (parameters);
+  params_asv = _tp_asv_from_vardict (parameters);
+
+  g_variant_ref_sink (properties);
+  props_asv = _tp_asv_from_vardict (properties);
+
   tp_cli_account_manager_call_create_account (manager,
-      -1, connection_manager, protocol, display_name, parameters,
-      properties, _tp_account_manager_created_cb, res, g_object_unref,
+      -1, connection_manager, protocol, display_name, params_asv,
+      props_asv, _tp_account_manager_created_cb, res, g_object_unref,
       G_OBJECT (manager));
+
+  g_variant_unref (parameters);
+  g_variant_unref (properties);
+  g_hash_table_unref (params_asv);
+  g_hash_table_unref (props_asv);
 }
 
 /**
diff --git a/telepathy-glib/account-manager.h b/telepathy-glib/account-manager.h
index 2fea7b6..d5f330d 100644
--- a/telepathy-glib/account-manager.h
+++ b/telepathy-glib/account-manager.h
@@ -102,7 +102,7 @@ TpConnectionPresenceType tp_account_manager_get_most_available_presence (
 
 void tp_account_manager_create_account_async (TpAccountManager *manager,
     const gchar *connection_manager, const gchar *protocol,
-    const gchar *display_name, GHashTable *parameters, GHashTable *properties,
+    const gchar *display_name, GVariant *parameters, GVariant *properties,
     GAsyncReadyCallback callback, gpointer user_data);
 
 TpAccount * tp_account_manager_create_account_finish (



More information about the telepathy-commits mailing list