summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-06-23 16:09:08 +0200
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-06-24 12:25:02 +0200
commita49f10492aa82e6dcdbafb03ce0ff399c5f845c7 (patch)
treed0f24f54ae3509d3168b7346ad7abab4069635f1
parent6152cfdcbd35509c5207ef337acca2f47a807c5b (diff)
downloadtelepathy-glib-a49f10492aa82e6dcdbafb03ce0ff399c5f845c7.tar.gz
TpChannelRequest: add properties and accessors for Account, UserActionTime and PreferredHandler (#38605)
I didn't add Requests as it's less useful and I'm not sure we want to expose more string -> GVariant hash table in the API.
-rw-r--r--docs/reference/telepathy-glib-sections.txt3
-rw-r--r--telepathy-glib/channel-request.c148
-rw-r--r--telepathy-glib/channel-request.h7
-rw-r--r--tests/dbus/channel-request.c37
4 files changed, 193 insertions, 2 deletions
diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt
index 936c0e56d..a04315c0d 100644
--- a/docs/reference/telepathy-glib-sections.txt
+++ b/docs/reference/telepathy-glib-sections.txt
@@ -4588,6 +4588,9 @@ tp_channel_request_new
tp_channel_request_init_known_interfaces
tp_channel_request_set_channel_factory
tp_channel_request_get_immutable_properties
+tp_channel_request_get_account
+tp_channel_request_get_user_action_time
+tp_channel_request_get_preferred_handler
tp_channel_request_get_hints
<SUBSECTION>
tp_cli_channel_request_callback_for_cancel
diff --git a/telepathy-glib/channel-request.c b/telepathy-glib/channel-request.c
index 8544f5bf7..daaa11242 100644
--- a/telepathy-glib/channel-request.c
+++ b/telepathy-glib/channel-request.c
@@ -21,6 +21,7 @@
#include "telepathy-glib/channel-request.h"
+#include <telepathy-glib/account-manager.h>
#include <telepathy-glib/automatic-proxy-factory.h>
#include <telepathy-glib/channel.h>
#include <telepathy-glib/connection.h>
@@ -102,6 +103,9 @@ enum {
enum {
PROP_CHANNEL_FACTORY = 1,
PROP_IMMUTABLE_PROPERTIES,
+ PROP_ACCOUNT,
+ PROP_USER_ACTION_TIME,
+ PROP_PREFERRED_HANDLER,
PROP_HINTS,
};
@@ -167,6 +171,20 @@ tp_channel_request_get_property (GObject *object,
g_value_set_boxed (value, self->priv->immutable_properties);
break;
+ case PROP_ACCOUNT:
+ g_value_set_object (value, tp_channel_request_get_account (self));
+ break;
+
+ case PROP_USER_ACTION_TIME:
+ g_value_set_int64 (value,
+ tp_channel_request_get_user_action_time (self));
+ break;
+
+ case PROP_PREFERRED_HANDLER:
+ g_value_set_string (value,
+ tp_channel_request_get_preferred_handler (self));
+ break;
+
case PROP_HINTS:
g_value_set_boxed (value, tp_channel_request_get_hints (self));
break;
@@ -387,6 +405,57 @@ tp_channel_request_class_init (TpChannelRequestClass *klass)
param_spec);
/**
+ * TpChannelRequest:account:
+ *
+ * The #TpAccount on which this request was made, not guaranteed
+ * to be prepared.
+ *
+ * Read-only.
+ *
+ * Since: 0.15.UNRELEASED
+ */
+ param_spec = g_param_spec_object ("account", "Account", "Account",
+ TP_TYPE_ACCOUNT,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (object_class, PROP_ACCOUNT, param_spec);
+
+ /**
+ * TpChannelRequest:user-action-time:
+ *
+ * The time at which user action occurred, or
+ * #TP_USER_ACTION_TIME_NOT_USER_ACTION if this channel request is
+ * for some reason not involving user action.
+ *
+ * Read-only.
+ *
+ * Since: 0.15.UNRELEASED
+ */
+ param_spec = g_param_spec_int64 ("user-action-time", "UserActionTime",
+ "UserActionTime",
+ 0, G_MAXINT64, 0,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (object_class, PROP_USER_ACTION_TIME,
+ param_spec);
+
+ /**
+ * TpChannelRequest:preferred-handler:
+ *
+ * Either the well-known bus name (starting with #TP_CLIENT_BUS_NAME_BASE)
+ * of the preferred handler for this channel request,
+ * or %NULL to indicate that any handler would be acceptable.
+ *
+ * Read-only.
+ *
+ * Since: 0.15.UNRELEASED
+ */
+ param_spec = g_param_spec_string ("preferred-handler", "PreferredHandler",
+ "PreferredHandler",
+ NULL,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (object_class, PROP_PREFERRED_HANDLER,
+ param_spec);
+
+ /**
* TpChannelRequest:hints:
*
* A #TP_HASH_TYPE_STRING_VARIANT_MAP of metadata provided by
@@ -570,6 +639,85 @@ tp_channel_request_get_immutable_properties (TpChannelRequest *self)
}
/**
+ * tp_channel_request_get_account:
+ * @self: a #tpchannelrequest
+ *
+ * Return the value of the #TpChannelRequest:account construct-only property
+ *
+ * returns: (transfer none): the value of #TpChannelRequest:account
+ *
+ * since: 0.15.UNRELEASED
+ */
+TpAccount *
+tp_channel_request_get_account (TpChannelRequest *self)
+{
+ const gchar *path;
+ TpAccountManager *mgr;
+ TpAccount *account;
+
+ g_return_val_if_fail (TP_IS_CHANNEL_REQUEST (self), NULL);
+
+ if (self->priv->immutable_properties == NULL)
+ return NULL;
+
+ path = tp_asv_get_object_path (self->priv->immutable_properties,
+ TP_PROP_CHANNEL_REQUEST_ACCOUNT);
+ if (path == NULL)
+ return NULL;
+
+ mgr = tp_account_manager_dup ();
+
+ account = tp_account_manager_ensure_account (mgr, path);
+
+ g_object_unref (mgr);
+ return account;
+}
+
+/**
+ * tp_channel_request_get_user_action_time:
+ * @self: a #tpchannelrequest
+ *
+ * return the #TpChannelRequest:user-action-time construct-only property
+ *
+ * returns: the value of #TpChannelRequest:user-action-time
+ *
+ * since: 0.15.UNRELEASED
+ */
+gint64
+tp_channel_request_get_user_action_time (TpChannelRequest *self)
+{
+ g_return_val_if_fail (TP_IS_CHANNEL_REQUEST (self), 0);
+
+ if (self->priv->immutable_properties == NULL)
+ return 0;
+
+ return tp_asv_get_int64 (self->priv->immutable_properties,
+ TP_PROP_CHANNEL_REQUEST_USER_ACTION_TIME, NULL);
+}
+
+/**
+ * tp_channel_request_get_preferred_handler:
+ * @self: a #tpchannelrequest
+ *
+ * return the #TpChannelRequest:preferred-handler construct-only property
+ *
+ * returns: the value of #TpChannelRequest:preferred-handler
+ *
+ * since: 0.15.UNRELEASED
+ */
+const gchar *
+tp_channel_request_get_preferred_handler (TpChannelRequest *self)
+{
+ g_return_val_if_fail (TP_IS_CHANNEL_REQUEST (self), NULL);
+
+ if (self->priv->immutable_properties == NULL)
+ return NULL;
+
+ return tp_asv_get_string (self->priv->immutable_properties,
+ TP_PROP_CHANNEL_REQUEST_PREFERRED_HANDLER);
+}
+
+/**
* tp_channel_request_get_hints:
* @self: a #TpChannelRequest
*
diff --git a/telepathy-glib/channel-request.h b/telepathy-glib/channel-request.h
index 5ffedfe1b..9d31e6683 100644
--- a/telepathy-glib/channel-request.h
+++ b/telepathy-glib/channel-request.h
@@ -22,6 +22,7 @@
#ifndef TP_CHANNEL_REQUEST_H
#define TP_CHANNEL_REQUEST_H
+#include <telepathy-glib/account.h>
#include <telepathy-glib/client-channel-factory.h>
#include <telepathy-glib/dbus.h>
#include <telepathy-glib/defs.h>
@@ -77,6 +78,12 @@ void tp_channel_request_set_channel_factory (TpChannelRequest *self,
const GHashTable * tp_channel_request_get_immutable_properties (
TpChannelRequest *self);
+TpAccount * tp_channel_request_get_account (TpChannelRequest *self);
+
+gint64 tp_channel_request_get_user_action_time (TpChannelRequest *self);
+
+const gchar * tp_channel_request_get_preferred_handler (TpChannelRequest *self);
+
const GHashTable * tp_channel_request_get_hints (TpChannelRequest *self);
G_END_DECLS
diff --git a/tests/dbus/channel-request.c b/tests/dbus/channel-request.c
index 7aba2e29f..cc121e359 100644
--- a/tests/dbus/channel-request.c
+++ b/tests/dbus/channel-request.c
@@ -332,16 +332,24 @@ test_immutable_properties (Test *test,
g_hash_table_unref (props);
}
+#define ACCOUNT_PATH TP_ACCOUNT_OBJECT_PATH_BASE "a/b/c"
+
static void
-test_hints (Test *test,
+test_properties (Test *test,
gconstpointer data G_GNUC_UNUSED)
{
gboolean ok;
GHashTable *props, *hints;
+ TpAccount *account;
+ gint64 user_action_time;
+ const gchar *handler;
hints = tp_asv_new ("test", G_TYPE_STRING, "hi", NULL);
props = tp_asv_new (
+ TP_PROP_CHANNEL_REQUEST_ACCOUNT, DBUS_TYPE_G_OBJECT_PATH, ACCOUNT_PATH,
+ TP_PROP_CHANNEL_REQUEST_USER_ACTION_TIME, G_TYPE_INT64, 12345,
+ TP_PROP_CHANNEL_REQUEST_PREFERRED_HANDLER, G_TYPE_STRING, "Badger",
TP_PROP_CHANNEL_REQUEST_HINTS, TP_HASH_TYPE_STRING_VARIANT_MAP, hints,
NULL);
@@ -355,6 +363,31 @@ test_hints (Test *test,
g_hash_table_unref (props);
g_hash_table_unref (hints);
+ /* Account */
+ account = tp_channel_request_get_account (test->cr);
+ g_assert (TP_IS_ACCOUNT (account));
+ g_assert_cmpstr (tp_proxy_get_object_path (account), ==, ACCOUNT_PATH);
+
+ g_object_get (test->cr, "account", &account, NULL);
+ g_assert (TP_IS_ACCOUNT (account));
+ g_assert_cmpstr (tp_proxy_get_object_path (account), ==, ACCOUNT_PATH);
+ g_object_unref (account);
+
+ /* UserActionTime */
+ user_action_time = tp_channel_request_get_user_action_time (test->cr);
+ g_assert_cmpint (user_action_time, ==, 12345);
+
+ g_object_get (test->cr, "user-action-time", &user_action_time, NULL);
+ g_assert_cmpint (user_action_time, ==, 12345);
+
+ /* PreferredHandler */
+ handler = tp_channel_request_get_preferred_handler (test->cr);
+ g_assert_cmpstr (handler, ==, "Badger");
+
+ g_object_get (test->cr, "preferred-handler", &handler, NULL);
+ g_assert_cmpstr (handler, ==, "Badger");
+
+ /* Hints */
hints = (GHashTable *) tp_channel_request_get_hints (test->cr);
g_assert_cmpstr (tp_asv_get_string (hints, "test"), ==, "hi");
@@ -377,7 +410,7 @@ main (int argc,
g_test_add ("/cr/failed", Test, NULL, setup, test_failed, teardown);
g_test_add ("/cr/immutable-properties", Test, NULL, setup,
test_immutable_properties, teardown);
- g_test_add ("/cr/hints", Test, NULL, setup, test_hints, teardown);
+ g_test_add ("/cr/properties", Test, NULL, setup, test_properties, teardown);
return g_test_run ();
}