[Pkg-telepathy-commits] [telepathy-mission-control-6] 81/90: McpDispatchOperation: use GVariant for the channel's properties
Simon McVittie
smcv at debian.org
Wed May 14 12:09:09 UTC 2014
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to branch debian
in repository telepathy-mission-control-6.
commit 39cfcee85a694806f6a59e74bf793efc9d08a242
Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date: Mon Apr 7 16:44:23 2014 +0100
McpDispatchOperation: use GVariant for the channel's properties
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=77139
---
mission-control-plugins/dispatch-operation.c | 41 ++++++++++++----------------
mission-control-plugins/dispatch-operation.h | 4 +--
mission-control-plugins/implementation.h | 2 +-
src/plugin-dispatch-operation.c | 18 ++----------
tests/twisted/mcp-plugin.c | 22 ++++++---------
5 files changed, 32 insertions(+), 55 deletions(-)
diff --git a/mission-control-plugins/dispatch-operation.c b/mission-control-plugins/dispatch-operation.c
index 489686e..c61235d 100644
--- a/mission-control-plugins/dispatch-operation.c
+++ b/mission-control-plugins/dispatch-operation.c
@@ -215,14 +215,10 @@ mcp_dispatch_operation_get_nth_channel_path (McpDispatchOperation *self,
* %NULL if @n is greater than or equal to
* mcp_dispatch_operation_get_n_channels().
*
- * The keys of the hash table are strings and the values are in #GValue
- * structures, using the same representation as dbus-glib, tp_asv_get_string()
- * etc. Do not add or remove entries in this hash table.
- *
- * Returns: a reference to a hash table, which must be released with
- * g_hash_table_unref() by the caller
+ * Returns: (transfer full) (allow-none): a reference to
+ * a %G_VARIANT_TYPE_VARDICT, or %NULL
*/
-GHashTable *
+GVariant *
mcp_dispatch_operation_ref_nth_channel_properties (McpDispatchOperation *self,
guint n)
{
@@ -343,10 +339,10 @@ mcp_dispatch_operation_destroy_channels (McpDispatchOperation *self,
* mcp_dispatch_operation_get_nth_channel_path() etc.
* @ret_dup_path: if not %NULL, used to return the object path of the first
* matching channel, which must be freed with g_free()
- * @ret_ref_immutable_properties: if not %NULL, used to return a reference to
- * immutable properties, as if via
+ * @ret_ref_immutable_properties: (out) (transfer full) (allow-none): if
+ * not %NULL, used to return a reference to immutable properties, as if via
* mcp_dispatch_operation_ref_nth_channel_properties(), which must be
- * released with g_hash_table_unref()
+ * released with g_variant_unref()
* @ret_ref_channel: if not %NULL, used to return a #TpChannel, which is not
* guaranteed to be ready immediately, and must be released with
* g_object_unref()
@@ -367,7 +363,7 @@ mcp_dispatch_operation_find_channel_by_type (McpDispatchOperation *self,
GQuark channel_type,
guint *ret_index,
gchar **ret_dup_path,
- GHashTable **ret_ref_immutable_properties,
+ GVariant **ret_ref_immutable_properties,
TpChannel **ret_ref_channel)
{
const gchar *channel_type_str = g_quark_to_string (channel_type);
@@ -381,27 +377,25 @@ mcp_dispatch_operation_find_channel_by_type (McpDispatchOperation *self,
for (i = start_from; i < mcp_dispatch_operation_get_n_channels (self); i++)
{
- GHashTable *properties =
+ GVariant *properties =
mcp_dispatch_operation_ref_nth_channel_properties (self, i);
const gchar *channel_path =
mcp_dispatch_operation_get_nth_channel_path (self, i);
if (properties != NULL &&
channel_path != NULL &&
- !tp_strdiff (tp_asv_get_string (properties,
+ !tp_strdiff (tp_vardict_get_string (properties,
TP_IFACE_CHANNEL ".ChannelType"),
channel_type_str) &&
- tp_asv_get_uint32 (properties, TP_IFACE_CHANNEL ".TargetEntityType",
- &valid) == entity_type &&
+ tp_vardict_get_uint32 (properties,
+ TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, &valid) == entity_type &&
valid)
{
if (ret_index != NULL)
*ret_index = i;
if (ret_ref_immutable_properties != NULL)
- *ret_ref_immutable_properties = properties;
- else
- g_hash_table_unref (properties);
+ *ret_ref_immutable_properties = g_variant_ref (properties);
if (ret_dup_path != NULL)
*ret_dup_path = g_strdup (channel_path);
@@ -413,15 +407,16 @@ mcp_dispatch_operation_find_channel_by_type (McpDispatchOperation *self,
*ret_ref_channel = tp_client_factory_ensure_channel (
client_factory, connection, channel_path,
- tp_asv_to_vardict (properties), NULL);
+ properties, NULL);
g_object_unref (connection);
}
+ g_variant_unref (properties);
return TRUE;
}
- g_hash_table_unref (properties);
+ g_variant_unref (properties);
}
return FALSE;
@@ -474,7 +469,7 @@ mcp_dispatch_operation_ref_nth_channel (McpDispatchOperation *self,
guint n)
{
TpConnection *connection;
- GHashTable *channel_properties = NULL;
+ GVariant *channel_properties = NULL;
const gchar *channel_path = NULL;
TpChannel *channel = NULL;
@@ -497,11 +492,11 @@ mcp_dispatch_operation_ref_nth_channel (McpDispatchOperation *self,
goto finally;
channel = tp_client_factory_ensure_channel (client_factory,
- connection, channel_path, tp_asv_to_vardict (channel_properties), NULL);
+ connection, channel_path, channel_properties, NULL);
finally:
tp_clear_object (&connection);
- tp_clear_pointer (&channel_properties, g_hash_table_unref);
+ g_clear_pointer (&channel_properties, g_variant_unref);
return channel;
}
diff --git a/mission-control-plugins/dispatch-operation.h b/mission-control-plugins/dispatch-operation.h
index dc23d9c..d528f33 100644
--- a/mission-control-plugins/dispatch-operation.h
+++ b/mission-control-plugins/dispatch-operation.h
@@ -56,7 +56,7 @@ gboolean mcp_dispatch_operation_find_channel_by_type (
TpClientFactory *client_factory,
guint start_from, TpEntityType entity_type, GQuark channel_type,
guint *ret_index, gchar **ret_dup_path,
- GHashTable **ret_ref_immutable_properties, TpChannel **ret_ref_channel);
+ GVariant **ret_ref_immutable_properties, TpChannel **ret_ref_channel);
TpConnection *mcp_dispatch_operation_ref_connection (
McpDispatchOperation *self, TpClientFactory *client_factory);
@@ -79,7 +79,7 @@ const gchar *mcp_dispatch_operation_get_cm_name (McpDispatchOperation *self);
guint mcp_dispatch_operation_get_n_channels (McpDispatchOperation *self);
const gchar *mcp_dispatch_operation_get_nth_channel_path (
McpDispatchOperation *self, guint n);
-GHashTable *mcp_dispatch_operation_ref_nth_channel_properties (
+GVariant *mcp_dispatch_operation_ref_nth_channel_properties (
McpDispatchOperation *self, guint n);
McpDispatchOperationDelay *mcp_dispatch_operation_start_delay (
diff --git a/mission-control-plugins/implementation.h b/mission-control-plugins/implementation.h
index 59096f9..aa6e4fe 100644
--- a/mission-control-plugins/implementation.h
+++ b/mission-control-plugins/implementation.h
@@ -59,7 +59,7 @@ struct _McpDispatchOperationIface {
guint (*get_n_channels) (McpDispatchOperation *self);
const gchar * (*get_nth_channel_path) (McpDispatchOperation *self,
guint n);
- GHashTable * (*ref_nth_channel_properties) (McpDispatchOperation *self,
+ GVariant * (*ref_nth_channel_properties) (McpDispatchOperation *self,
guint n);
/* Delay the dispatch */
diff --git a/src/plugin-dispatch-operation.c b/src/plugin-dispatch-operation.c
index 22d777c..fd6b6fd 100644
--- a/src/plugin-dispatch-operation.c
+++ b/src/plugin-dispatch-operation.c
@@ -201,15 +201,12 @@ plugin_do_get_nth_channel_path (McpDispatchOperation *obj,
return mcd_channel_get_object_path (channel);
}
-static GHashTable *
+static GVariant *
plugin_do_ref_nth_channel_properties (McpDispatchOperation *obj,
guint n)
{
McdPluginDispatchOperation *self = MCD_PLUGIN_DISPATCH_OPERATION (obj);
McdChannel *channel;
- GVariant *variant;
- GValue value = G_VALUE_INIT;
- GHashTable *ret;
g_return_val_if_fail (self != NULL, NULL);
@@ -218,18 +215,7 @@ plugin_do_ref_nth_channel_properties (McpDispatchOperation *obj,
if (channel == NULL || n != 0)
return NULL;
- variant = mcd_channel_dup_immutable_properties (channel);
-
- if (variant == NULL)
- return NULL;
-
- /* For compatibility, we have to return the older type here. */
- dbus_g_value_parse_g_variant (variant, &value);
- g_assert (G_VALUE_HOLDS (&value, TP_HASH_TYPE_STRING_VARIANT_MAP));
- ret = g_value_dup_boxed (&value);
- g_value_unset (&value);
-
- return ret;
+ return mcd_channel_dup_immutable_properties (channel);
}
diff --git a/tests/twisted/mcp-plugin.c b/tests/twisted/mcp-plugin.c
index d93aa11..0d04329 100644
--- a/tests/twisted/mcp-plugin.c
+++ b/tests/twisted/mcp-plugin.c
@@ -165,7 +165,7 @@ static void
test_permission_plugin_check_cdo (McpDispatchOperationPolicy *policy,
McpDispatchOperation *dispatch_operation)
{
- GHashTable *properties = mcp_dispatch_operation_ref_nth_channel_properties (
+ GVariant *properties = mcp_dispatch_operation_ref_nth_channel_properties (
dispatch_operation, 0);
DEBUG ("enter");
@@ -178,7 +178,7 @@ test_permission_plugin_check_cdo (McpDispatchOperationPolicy *policy,
/* currently this example just checks the first channel */
- if (!tp_strdiff (tp_asv_get_string (properties,
+ if (!tp_strdiff (tp_vardict_get_string (properties,
TP_IFACE_CHANNEL ".TargetID"),
"policy at example.net"))
{
@@ -206,7 +206,7 @@ test_permission_plugin_check_cdo (McpDispatchOperationPolicy *policy,
g_object_unref (bus);
}
- g_hash_table_unref (properties);
+ g_variant_unref (properties);
}
static void
@@ -219,7 +219,7 @@ handler_is_suitable_async (McpDispatchOperationPolicy *self,
{
GSimpleAsyncResult *simple = g_simple_async_result_new ((GObject *) self,
callback, user_data, handler_is_suitable_async);
- GHashTable *properties = mcp_dispatch_operation_ref_nth_channel_properties (
+ GVariant *properties = mcp_dispatch_operation_ref_nth_channel_properties (
dispatch_operation, 0);
DEBUG ("enter");
@@ -232,7 +232,7 @@ handler_is_suitable_async (McpDispatchOperationPolicy *self,
/* currently this example just checks the first channel */
- if (!tp_strdiff (tp_asv_get_string (properties,
+ if (!tp_strdiff (tp_vardict_get_string (properties,
TP_IFACE_CHANNEL ".TargetID"),
"policy at example.net"))
{
@@ -260,7 +260,7 @@ handler_is_suitable_async (McpDispatchOperationPolicy *self,
}
finally:
- g_hash_table_unref (properties);
+ g_clear_pointer (&properties, g_variant_unref);
if (simple != NULL)
{
@@ -283,8 +283,6 @@ static void
test_permission_plugin_check_request (McpRequestPolicy *policy,
McpRequest *request)
{
- GHashTable *properties = mcp_request_ref_nth_request (request, 0);
-
DEBUG ("%s", G_STRFUNC);
if (mcp_request_find_request_by_type (request,
@@ -313,8 +311,6 @@ test_permission_plugin_check_request (McpRequestPolicy *policy,
NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, permission_cb, ctx);
g_object_unref (bus);
}
-
- g_hash_table_unref (properties);
}
static void
@@ -362,7 +358,7 @@ static void
test_rejection_plugin_check_cdo (McpDispatchOperationPolicy *policy,
McpDispatchOperation *dispatch_operation)
{
- GHashTable *properties = mcp_dispatch_operation_ref_nth_channel_properties (
+ GVariant *properties = mcp_dispatch_operation_ref_nth_channel_properties (
dispatch_operation, 0);
const gchar *target_id;
@@ -376,7 +372,7 @@ test_rejection_plugin_check_cdo (McpDispatchOperationPolicy *policy,
/* currently this example just checks the first channel */
- target_id = tp_asv_get_string (properties, TP_IFACE_CHANNEL ".TargetID");
+ target_id = tp_vardict_get_string (properties, TP_IFACE_CHANNEL ".TargetID");
if (!tp_strdiff (target_id, "rick.astley at example.net"))
{
@@ -389,7 +385,7 @@ test_rejection_plugin_check_cdo (McpDispatchOperationPolicy *policy,
mcp_dispatch_operation_destroy_channels (dispatch_operation, TRUE);
}
- g_hash_table_unref (properties);
+ g_variant_unref (properties);
}
static void
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-telepathy/telepathy-mission-control-6.git
More information about the Pkg-telepathy-commits
mailing list