summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2014-04-07 16:48:30 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2014-04-07 16:48:30 +0100
commit7b36d5a69e0ddc3fa06060d84635cc33fc9a72d2 (patch)
tree2912c9bd05b326c14290aa1e3cf6320da89ab89b
parent7da3b25b39736fadb21c5e955f5ec297fa64e57b (diff)
McpRequest: use GVariant for the requested propertiesnext-gvariant1
-rw-r--r--mission-control-plugins/implementation.h2
-rw-r--r--mission-control-plugins/request.c12
-rw-r--r--mission-control-plugins/request.h4
-rw-r--r--src/plugin-request.c8
-rw-r--r--tests/twisted/mcp-plugin.c6
5 files changed, 14 insertions, 18 deletions
diff --git a/mission-control-plugins/implementation.h b/mission-control-plugins/implementation.h
index aa6e4fe8..b1ad5bf8 100644
--- a/mission-control-plugins/implementation.h
+++ b/mission-control-plugins/implementation.h
@@ -35,7 +35,7 @@ struct _McpRequestIface {
gint64 (*get_user_action_time) (McpRequest *self);
guint (*get_n_requests) (McpRequest *self);
- GHashTable * (*ref_nth_request) (McpRequest *self, guint n);
+ GVariant * (*ref_nth_request) (McpRequest *self, guint n);
void (*deny) (McpRequest *self, GQuark domain, gint code,
const gchar *message);
diff --git a/mission-control-plugins/request.c b/mission-control-plugins/request.c
index 36dac1dc..cf549bbb 100644
--- a/mission-control-plugins/request.c
+++ b/mission-control-plugins/request.c
@@ -115,7 +115,7 @@ mcp_request_get_n_requests (McpRequest *self)
return iface->get_n_requests (self);
}
-GHashTable *
+GVariant *
mcp_request_ref_nth_request (McpRequest *self,
guint n)
{
@@ -147,20 +147,20 @@ mcp_request_find_request_by_type (McpRequest *self,
guint start_from,
GQuark channel_type,
guint *ret_index,
- GHashTable **ret_ref_requested_properties)
+ GVariant **ret_ref_requested_properties)
{
guint i = start_from;
while (1)
{
- GHashTable *req = mcp_request_ref_nth_request (self, i);
+ GVariant *req = mcp_request_ref_nth_request (self, i);
if (req == NULL)
return FALSE;
if (channel_type == 0 ||
channel_type == g_quark_try_string (
- tp_asv_get_string (req, TP_IFACE_CHANNEL ".ChannelType")))
+ tp_vardict_get_string (req, TP_IFACE_CHANNEL ".ChannelType")))
{
if (ret_index != NULL)
*ret_index = i;
@@ -168,12 +168,12 @@ mcp_request_find_request_by_type (McpRequest *self,
if (ret_ref_requested_properties != NULL)
*ret_ref_requested_properties = req;
else
- g_hash_table_unref (req);
+ g_variant_unref (req);
return TRUE;
}
- g_hash_table_unref (req);
+ g_variant_unref (req);
i++;
}
}
diff --git a/mission-control-plugins/request.h b/mission-control-plugins/request.h
index d98f20db..11aa939f 100644
--- a/mission-control-plugins/request.h
+++ b/mission-control-plugins/request.h
@@ -52,7 +52,7 @@ GType mcp_request_get_type (void) G_GNUC_CONST;
gboolean mcp_request_find_request_by_type (McpRequest *self,
guint start_from, GQuark channel_type,
- guint *ret_index, GHashTable **ret_ref_requested_properties);
+ guint *ret_index, GVariant **ret_ref_requested_properties);
/* virtual methods */
@@ -62,7 +62,7 @@ const gchar *mcp_request_get_cm_name (McpRequest *self);
gint64 mcp_request_get_user_action_time (McpRequest *self);
guint mcp_request_get_n_requests (McpRequest *self);
-GHashTable *mcp_request_ref_nth_request (McpRequest *self, guint n);
+GVariant *mcp_request_ref_nth_request (McpRequest *self, guint n);
void mcp_request_deny (McpRequest *self, GQuark domain, gint code,
const gchar *message);
diff --git a/src/plugin-request.c b/src/plugin-request.c
index a4c3f033..0025313d 100644
--- a/src/plugin-request.c
+++ b/src/plugin-request.c
@@ -190,12 +190,11 @@ plugin_req_get_n_requests (McpRequest *obj)
return 1;
}
-static GHashTable *
+static GVariant *
plugin_req_ref_nth_request (McpRequest *obj,
guint n)
{
McdPluginRequest *self = MCD_PLUGIN_REQUEST (obj);
- GHashTable *requested_properties;
g_return_val_if_fail (self != NULL, NULL);
@@ -205,10 +204,7 @@ plugin_req_ref_nth_request (McpRequest *obj,
return NULL;
}
- requested_properties = _mcd_request_get_properties (
- self->real_request);
- g_return_val_if_fail (requested_properties != NULL, NULL);
- return g_hash_table_ref (requested_properties);
+ return mcd_request_dup_properties (self->real_request);
}
static void
diff --git a/tests/twisted/mcp-plugin.c b/tests/twisted/mcp-plugin.c
index 0d04329b..7cb90843 100644
--- a/tests/twisted/mcp-plugin.c
+++ b/tests/twisted/mcp-plugin.c
@@ -399,12 +399,12 @@ static void
test_rejection_plugin_check_request (McpRequestPolicy *policy,
McpRequest *request)
{
- GHashTable *properties = mcp_request_ref_nth_request (request, 0);
+ GVariant *properties = mcp_request_ref_nth_request (request, 0);
DEBUG ("%s", G_STRFUNC);
if (!tp_strdiff (
- tp_asv_get_string (properties, TP_IFACE_CHANNEL ".ChannelType"),
+ tp_vardict_get_string (properties, TP_IFACE_CHANNEL ".ChannelType"),
"com.example.ForbiddenChannel"))
{
DEBUG ("Forbidden channel detected, denying request");
@@ -421,7 +421,7 @@ test_rejection_plugin_check_request (McpRequestPolicy *policy,
"No, you don't");
}
- g_hash_table_unref (properties);
+ g_variant_unref (properties);
}
static void