[next] telepathy-glib: add tp_account_request_set_storage_provider()

Jonny Lamb jonny at kemper.freedesktop.org
Fri Aug 31 03:18:51 PDT 2012


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

Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date:   Tue Jul 17 15:51:59 2012 +0200

add tp_account_request_set_storage_provider()

---

 docs/reference/telepathy-glib-sections.txt |    1 +
 telepathy-glib/account-request.c           |   46 ++++++++++++++++++++++++++++
 telepathy-glib/account-request.h           |    4 ++
 tests/dbus/account-request.c               |   21 ++++++++++++-
 4 files changed, 71 insertions(+), 1 deletions(-)

diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt
index d225152..a41a3be 100644
--- a/docs/reference/telepathy-glib-sections.txt
+++ b/docs/reference/telepathy-glib-sections.txt
@@ -5281,6 +5281,7 @@ tp_account_request_set_connect_automatically
 tp_account_request_add_supersedes
 tp_account_request_set_avatar
 tp_account_request_set_service
+tp_account_request_set_storage_provider
 <SUBSECTION>
 tp_account_request_set_parameter
 tp_account_request_set_parameter_string
diff --git a/telepathy-glib/account-request.c b/telepathy-glib/account-request.c
index 3eea2f4..f7c8815 100644
--- a/telepathy-glib/account-request.c
+++ b/telepathy-glib/account-request.c
@@ -144,6 +144,7 @@ enum {
   PROP_AVATAR,
   PROP_AVATAR_MIME_TYPE,
   PROP_SERVICE,
+  PROP_STORAGE_PROVIDER,
   N_PROPS
 };
 
@@ -294,6 +295,10 @@ tp_account_request_get_property (GObject *object,
       g_value_set_string (value, tp_asv_get_string (self->priv->properties,
             TP_PROP_ACCOUNT_SERVICE));
       break;
+    case PROP_STORAGE_PROVIDER:
+      g_value_set_string (value, tp_asv_get_string (self->priv->properties,
+            TP_PROP_ACCOUNT_INTERFACE_STORAGE_STORAGE_PROVIDER));
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -698,6 +703,21 @@ tp_account_request_class_init (TpAccountRequestClass *klass)
           "The account's service",
           NULL,
           G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
+
+  /**
+   * TpAccountRequest:storage-provider:
+   *
+   * The account's storage provider. To change this property use
+   * tp_account_request_set_storage_provider().
+   *
+   * Since: UNRELEASED
+   */
+  g_object_class_install_property (object_class, PROP_STORAGE_PROVIDER,
+      g_param_spec_string ("storage-provider",
+          "Storage Provider",
+          "The account's storage provider",
+          NULL,
+          G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
 }
 
 /**
@@ -1111,6 +1131,32 @@ tp_account_request_set_service (TpAccountRequest *self,
 }
 
 /**
+ * tp_account_request_set_storage_provider:
+ * @self: a #TpAccountRequest
+ * @provider: the name of an account storage implementation
+ *
+ * Set the account storage to use when creating the account. Use the
+ * #TpAccountRequest:storage-provider property to read the current value.
+ *
+ * Since: UNRELEASED
+ */
+void
+tp_account_request_set_storage_provider (TpAccountRequest *self,
+    const gchar *provider)
+{
+  TpAccountRequestPrivate *priv;
+
+  g_return_if_fail (TP_IS_ACCOUNT_REQUEST (self));
+
+  priv = self->priv;
+
+  g_return_if_fail (priv->result == NULL && !priv->created);
+
+  tp_asv_set_string (priv->properties,
+      TP_PROP_ACCOUNT_INTERFACE_STORAGE_STORAGE_PROVIDER, provider);
+}
+
+/**
  * tp_account_request_set_parameter:
  * @self: a #TpAccountRequest
  * @key: the parameter key
diff --git a/telepathy-glib/account-request.h b/telepathy-glib/account-request.h
index 9ec4412..a589ef6 100644
--- a/telepathy-glib/account-request.h
+++ b/telepathy-glib/account-request.h
@@ -120,6 +120,10 @@ _TP_AVAILABLE_IN_0_20
 void tp_account_request_set_service (TpAccountRequest *self,
     const gchar *service);
 
+_TP_AVAILABLE_IN_UNRELEASED
+void tp_account_request_set_storage_provider (TpAccountRequest *self,
+    const gchar *provider);
+
 /* parameters */
 _TP_AVAILABLE_IN_0_20
 void tp_account_request_set_parameter (TpAccountRequest *self,
diff --git a/tests/dbus/account-request.c b/tests/dbus/account-request.c
index 96a2ad6..bc3b7d2 100644
--- a/tests/dbus/account-request.c
+++ b/tests/dbus/account-request.c
@@ -200,7 +200,7 @@ test_properties (Test *test,
   const gchar *s;
   gboolean b;
   GVariant *v;
-  gchar *service;
+  gchar *service, *storage_provider;
 
   test->account = tp_account_request_new (test->account_manager,
       "gabble", "jabber", "Walter Jr.");
@@ -373,6 +373,25 @@ test_properties (Test *test,
 
   g_variant_unref (props);
   g_free (service);
+
+  /* storage provider */
+  tp_account_request_set_storage_provider (test->account, "my.provider");
+
+  g_object_get (test->account,
+      "properties", &props,
+      "storage-provider", &storage_provider,
+      NULL);
+
+  v = g_variant_lookup_value (props,
+      TP_PROP_ACCOUNT_INTERFACE_STORAGE_STORAGE_PROVIDER, NULL);
+  g_assert (v != NULL);
+  g_assert_cmpstr (g_variant_get_string (v, NULL), ==, "my.provider");
+  g_variant_unref (v);
+
+  g_assert_cmpstr (storage_provider, ==, "my.provider");
+
+  g_variant_unref (props);
+  g_free (storage_provider);
 }
 
 static void



More information about the telepathy-commits mailing list