summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2014-04-04 13:54:30 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2014-04-07 16:16:06 +0100
commit2baac35337e4dd4c1e019e4ce535f2ee969176e6 (patch)
tree9cde67e8fe97690d71ff3373679f814ba13894d7
parentd6380b42b6226a057f1ea6fb55eb27b6eada4089 (diff)
TpCapabilities: operate in terms of GVariant
-rw-r--r--docs/reference/telepathy-glib/telepathy-glib-sections.txt3
-rw-r--r--telepathy-glib/capabilities-internal.h4
-rw-r--r--telepathy-glib/capabilities.c285
-rw-r--r--telepathy-glib/capabilities.h5
-rw-r--r--telepathy-glib/connection.c5
-rw-r--r--telepathy-glib/contact.c5
-rw-r--r--telepathy-glib/protocol.c4
-rw-r--r--telepathy-glib/versions/main-1.0.abi3
-rw-r--r--tests/capabilities.c648
-rw-r--r--tests/dbus/connection.c9
-rw-r--r--tests/dbus/text-respawn.c7
11 files changed, 356 insertions, 622 deletions
diff --git a/docs/reference/telepathy-glib/telepathy-glib-sections.txt b/docs/reference/telepathy-glib/telepathy-glib-sections.txt
index b56131842..00efc3e8a 100644
--- a/docs/reference/telepathy-glib/telepathy-glib-sections.txt
+++ b/docs/reference/telepathy-glib/telepathy-glib-sections.txt
@@ -3805,8 +3805,7 @@ TpContactPrivate
<FILE>capabilities</FILE>
<TITLE>capabilities</TITLE>
TpCapabilities
-tp_capabilities_get_channel_classes
-tp_capabilities_dup_channel_classes_variant
+tp_capabilities_dup_channel_classes
tp_capabilities_is_specific_to_contact
tp_capabilities_supports_text_chatrooms
tp_capabilities_supports_text_chats
diff --git a/telepathy-glib/capabilities-internal.h b/telepathy-glib/capabilities-internal.h
index 10dd0fe3a..b42015a32 100644
--- a/telepathy-glib/capabilities-internal.h
+++ b/telepathy-glib/capabilities-internal.h
@@ -26,8 +26,8 @@
G_BEGIN_DECLS
-/* NULL-safe for @classes */
-TpCapabilities * _tp_capabilities_new (const GPtrArray *classes,
+/* NULL-safe for @classes, consumes floating ref */
+TpCapabilities * _tp_capabilities_new (GVariant *classes,
gboolean contact_specific);
G_END_DECLS
diff --git a/telepathy-glib/capabilities.c b/telepathy-glib/capabilities.c
index ec4e0347c..60ff7e426 100644
--- a/telepathy-glib/capabilities.c
+++ b/telepathy-glib/capabilities.c
@@ -70,36 +70,15 @@ G_DEFINE_TYPE (TpCapabilities, tp_capabilities, G_TYPE_OBJECT)
enum {
PROP_CHANNEL_CLASSES = 1,
PROP_CONTACT_SPECIFIC,
- PROP_CHANNEL_CLASSES_VARIANT,
N_PROPS
};
struct _TpCapabilitiesPrivate {
- GPtrArray *classes;
gboolean contact_specific;
GVariant *classes_variant;
};
/**
- * tp_capabilities_get_channel_classes:
- * @self: a #TpCapabilities object
- *
- * <!-- -->
- *
- * Returns: (transfer none) (element-type GHashTable): the same #GPtrArray as
- * the #TpCapabilities:channel-classes property
- *
- * Since: 0.11.3
- */
-GPtrArray *
-tp_capabilities_get_channel_classes (TpCapabilities *self)
-{
- g_return_val_if_fail (self != NULL, NULL);
-
- return self->priv->classes;
-}
-
-/**
* tp_capabilities_is_specific_to_contact:
* @self: a #TpCapabilities object
*
@@ -124,7 +103,7 @@ tp_capabilities_constructed (GObject *object)
((GObjectClass *) tp_capabilities_parent_class)->constructed;
TpCapabilities *self = TP_CAPABILITIES (object);
- g_assert (self->priv->classes != NULL);
+ g_assert (self->priv->classes_variant != NULL);
if (chain_up != NULL)
chain_up (object);
@@ -135,13 +114,6 @@ tp_capabilities_dispose (GObject *object)
{
TpCapabilities *self = TP_CAPABILITIES (object);
- if (self->priv->classes != NULL)
- {
- g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
- self->priv->classes);
- self->priv->classes = NULL;
- }
-
tp_clear_pointer (&self->priv->classes_variant, g_variant_unref);
((GObjectClass *) tp_capabilities_parent_class)->dispose (object);
@@ -157,15 +129,11 @@ tp_capabilities_get_property (GObject *object,
switch (property_id)
{
- case PROP_CHANNEL_CLASSES:
- g_value_set_boxed (value, self->priv->classes);
- break;
-
case PROP_CONTACT_SPECIFIC:
g_value_set_boolean (value, self->priv->contact_specific);
break;
- case PROP_CHANNEL_CLASSES_VARIANT:
+ case PROP_CHANNEL_CLASSES:
g_value_set_variant (value, self->priv->classes_variant);
break;
@@ -186,10 +154,17 @@ tp_capabilities_set_property (GObject *object,
switch (property_id)
{
case PROP_CHANNEL_CLASSES:
- self->priv->classes = g_value_dup_boxed (value);
- self->priv->classes_variant = g_variant_ref_sink (_tp_boxed_to_variant (
- TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST, "a(a{sv}as)",
- self->priv->classes));
+ {
+ GVariant *variant = g_value_dup_variant (value);
+ gchar *s;
+
+ s = g_variant_print (variant, TRUE);
+ DEBUG ("%s", s);
+ g_free (s);
+ g_return_if_fail (g_variant_is_of_type (variant,
+ G_VARIANT_TYPE ("a(a{sv}as)")));
+ self->priv->classes_variant = variant;
+ }
break;
case PROP_CONTACT_SPECIFIC:
@@ -215,29 +190,6 @@ tp_capabilities_class_init (TpCapabilitiesClass *klass)
object_class->dispose = tp_capabilities_dispose;
/**
- * TpCapabilities:channel-classes:
- *
- * The underlying data structure used by Telepathy to represent the
- * requests that can succeed.
- *
- * This can be used by advanced clients to determine whether an unusually
- * complex request would succeed. See the Telepathy D-Bus API Specification
- * for details of how to interpret the returned #GPtrArray of
- * #TP_STRUCT_TYPE_REQUESTABLE_CHANNEL_CLASS.
- *
- * The higher-level methods like
- * tp_capabilities_supports_text_chats() are likely to be more useful to
- * the majority of clients.
- */
- param_spec = g_param_spec_boxed ("channel-classes",
- "GPtrArray of TP_STRUCT_TYPE_REQUESTABLE_CHANNEL_CLASS",
- "The channel classes supported",
- TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
- g_object_class_install_property (object_class, PROP_CHANNEL_CLASSES,
- param_spec);
-
- /**
* TpCapabilities:contact-specific:
*
* Whether this object accurately describes the capabilities of a particular
@@ -253,7 +205,7 @@ tp_capabilities_class_init (TpCapabilitiesClass *klass)
param_spec);
/**
- * TpCapabilities:channel-classes-variant:
+ * TpCapabilities:channel-classes:
*
* The underlying data structure used by Telepathy to represent the
* requests that can succeed.
@@ -266,16 +218,14 @@ tp_capabilities_class_init (TpCapabilitiesClass *klass)
* The higher-level methods like
* tp_capabilities_supports_text_chats() are likely to be more useful to
* the majority of clients.
- *
- * Since: 0.19.0
*/
- param_spec = g_param_spec_variant ("channel-classes-variant",
+ param_spec = g_param_spec_variant ("channel-classes",
"GVariant of type a(a{sv}as)",
"The channel classes supported",
G_VARIANT_TYPE ("a(a{sv}as)"),
NULL,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
- g_object_class_install_property (object_class, PROP_CHANNEL_CLASSES_VARIANT,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (object_class, PROP_CHANNEL_CLASSES,
param_spec);
}
@@ -286,27 +236,24 @@ tp_capabilities_init (TpCapabilities *self)
TpCapabilitiesPrivate);
}
-/* NULL-safe for @classes */
+/* NULL-safe for @classes, sinks floating refs */
TpCapabilities *
-_tp_capabilities_new (const GPtrArray *classes,
+_tp_capabilities_new (GVariant *classes,
gboolean contact_specific)
{
- GPtrArray *empty = NULL;
TpCapabilities *self;
if (classes == NULL)
- {
- empty = g_ptr_array_sized_new (0);
- classes = empty;
- }
+ classes = g_variant_new ("a(a{sv}as)", NULL);
+
+ g_variant_ref_sink (classes);
self = g_object_new (TP_TYPE_CAPABILITIES,
"channel-classes", classes,
"contact-specific", contact_specific,
NULL);
- if (empty != NULL)
- g_ptr_array_unref (empty);
+ g_variant_unref (classes);
return self;
}
@@ -316,28 +263,24 @@ supports_simple_channel (TpCapabilities *self,
const gchar *expected_chan_type,
TpEntityType expected_handle_type)
{
- guint i;
+ GVariantIter iter;
+ GVariant *fixed;
g_return_val_if_fail (TP_IS_CAPABILITIES (self), FALSE);
- for (i = 0; i < self->priv->classes->len; i++)
+ g_variant_iter_init (&iter, self->priv->classes_variant);
+
+ while (g_variant_iter_loop (&iter, "(@a{sv}@as)", &fixed, NULL))
{
- GValueArray *arr = g_ptr_array_index (self->priv->classes, i);
- GHashTable *fixed;
- const gchar * const *allowed;
const gchar *chan_type;
TpEntityType handle_type;
gboolean valid;
- tp_value_array_unpack (arr, 2,
- &fixed,
- &allowed);
-
- if (g_hash_table_size (fixed) != 2)
+ if (g_variant_n_children (fixed) != 2)
continue;
- chan_type = tp_asv_get_string (fixed, TP_PROP_CHANNEL_CHANNEL_TYPE);
- handle_type = tp_asv_get_uint32 (fixed,
+ chan_type = tp_vardict_get_string (fixed, TP_PROP_CHANNEL_CHANNEL_TYPE);
+ handle_type = tp_vardict_get_uint32 (fixed,
TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, &valid);
if (!valid)
@@ -345,7 +288,10 @@ supports_simple_channel (TpCapabilities *self,
if (!tp_strdiff (chan_type, expected_chan_type) &&
handle_type == expected_handle_type)
- return TRUE;
+ {
+ g_variant_unref (fixed);
+ return TRUE;
+ }
}
return FALSE;
@@ -430,25 +376,22 @@ tp_capabilities_supports_text_chatrooms (TpCapabilities *self)
gboolean
tp_capabilities_supports_sms (TpCapabilities *self)
{
- guint i;
+ GVariantIter iter;
+ GVariant *fixed;
+ const gchar **allowed;
g_return_val_if_fail (TP_IS_CAPABILITIES (self), FALSE);
- for (i = 0; i < self->priv->classes->len; i++)
+ g_variant_iter_init (&iter, self->priv->classes_variant);
+
+ while (g_variant_iter_loop (&iter, "(@a{sv}^a&s)", &fixed, &allowed))
{
- GValueArray *arr = g_ptr_array_index (self->priv->classes, i);
- GHashTable *fixed;
- const gchar * const *allowed;
const gchar *chan_type;
TpEntityType handle_type;
gboolean valid;
guint nb_fixed_props;
- tp_value_array_unpack (arr, 2,
- &fixed,
- &allowed);
-
- handle_type = tp_asv_get_uint32 (fixed,
+ handle_type = tp_vardict_get_uint32 (fixed,
TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, &valid);
if (!valid)
@@ -457,14 +400,14 @@ tp_capabilities_supports_sms (TpCapabilities *self)
if (handle_type != TP_ENTITY_TYPE_CONTACT)
continue;
- chan_type = tp_asv_get_string (fixed, TP_PROP_CHANNEL_CHANNEL_TYPE);
+ chan_type = tp_vardict_get_string (fixed, TP_PROP_CHANNEL_CHANNEL_TYPE);
if (tp_strdiff (chan_type, TP_IFACE_CHANNEL_TYPE_TEXT))
continue;
/* SMSChannel be either in fixed or allowed properties */
- if (tp_asv_get_boolean (fixed, TP_PROP_CHANNEL_INTERFACE_SMS1_SMS_CHANNEL,
- NULL))
+ if (tp_vardict_get_boolean (fixed,
+ TP_PROP_CHANNEL_INTERFACE_SMS1_SMS_CHANNEL, NULL))
{
/* In fixed, succeed if there is no more fixed properties required */
nb_fixed_props = 3;
@@ -479,8 +422,12 @@ tp_capabilities_supports_sms (TpCapabilities *self)
nb_fixed_props = 2;
}
- if (g_hash_table_size (fixed) == nb_fixed_props)
- return TRUE;
+ if (g_variant_n_children (fixed) == nb_fixed_props)
+ {
+ g_variant_unref (fixed);
+ g_free (allowed);
+ return TRUE;
+ }
}
return FALSE;
@@ -493,29 +440,26 @@ supports_call_full (TpCapabilities *self,
gboolean expected_initial_audio,
gboolean expected_initial_video)
{
- guint i;
+ GVariantIter iter;
+ GVariant *fixed;
+ const gchar **allowed_prop;
g_return_val_if_fail (TP_IS_CAPABILITIES (self), FALSE);
- for (i = 0; i < self->priv->classes->len; i++)
+ g_variant_iter_init (&iter, self->priv->classes_variant);
+
+ while (g_variant_iter_loop (&iter, "(@a{sv}^a&s)", &fixed, &allowed_prop))
{
- GValueArray *arr = g_ptr_array_index (self->priv->classes, i);
- GHashTable *fixed_prop;
- const gchar * const *allowed_prop;
const gchar *chan_type;
TpEntityType handle_type;
gboolean valid;
guint nb_fixed_props = 2;
- tp_value_array_unpack (arr, 2,
- &fixed_prop,
- &allowed_prop);
-
- chan_type = tp_asv_get_string (fixed_prop, TP_PROP_CHANNEL_CHANNEL_TYPE);
+ chan_type = tp_vardict_get_string (fixed, TP_PROP_CHANNEL_CHANNEL_TYPE);
if (tp_strdiff (chan_type, TP_IFACE_CHANNEL_TYPE_CALL1))
continue;
- handle_type = tp_asv_get_uint32 (fixed_prop,
+ handle_type = tp_vardict_get_uint32 (fixed,
TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, &valid);
if (!valid || handle_type != expected_handle_type)
continue;
@@ -523,7 +467,7 @@ supports_call_full (TpCapabilities *self,
if (expected_initial_audio)
{
/* We want audio, INITIAL_AUDIO must be in either fixed or allowed */
- if (tp_asv_get_boolean (fixed_prop,
+ if (tp_vardict_get_boolean (fixed,
TP_PROP_CHANNEL_TYPE_CALL1_INITIAL_AUDIO, NULL))
{
nb_fixed_props++;
@@ -538,7 +482,7 @@ supports_call_full (TpCapabilities *self,
if (expected_initial_video)
{
/* We want video, INITIAL_VIDEO must be in either fixed or allowed */
- if (tp_asv_get_boolean (fixed_prop,
+ if (tp_vardict_get_boolean (fixed,
TP_PROP_CHANNEL_TYPE_CALL1_INITIAL_VIDEO, NULL))
{
nb_fixed_props++;
@@ -551,8 +495,12 @@ supports_call_full (TpCapabilities *self,
}
/* We found the right class */
- if (g_hash_table_size (fixed_prop) == nb_fixed_props)
- return TRUE;
+ if (g_variant_n_children (fixed) == nb_fixed_props)
+ {
+ g_variant_unref (fixed);
+ g_free (allowed_prop);
+ return TRUE;
+ }
}
return FALSE;
@@ -628,28 +576,27 @@ static gboolean
supports_file_transfer (TpCapabilities *self,
FTCapFlags flags)
{
- guint i;
+ GVariantIter iter;
+ GVariant *fixed;
+ const gchar **allowed;
g_return_val_if_fail (TP_IS_CAPABILITIES (self), FALSE);
- for (i = 0; i < self->priv->classes->len; i++)
+ g_variant_iter_init (&iter, self->priv->classes_variant);
+
+ while (g_variant_iter_loop (&iter, "(@a{sv}^a&s)", &fixed, &allowed))
{
- GValueArray *arr = g_ptr_array_index (self->priv->classes, i);
- GHashTable *fixed;
const gchar *chan_type;
TpEntityType handle_type;
gboolean valid;
guint n_fixed = 2;
- const gchar * const *allowed;
-
- tp_value_array_unpack (arr, 2, &fixed, &allowed);
- chan_type = tp_asv_get_string (fixed, TP_PROP_CHANNEL_CHANNEL_TYPE);
+ chan_type = tp_vardict_get_string (fixed, TP_PROP_CHANNEL_CHANNEL_TYPE);
if (tp_strdiff (chan_type, TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER1))
continue;
- handle_type = tp_asv_get_uint32 (fixed,
+ handle_type = tp_vardict_get_uint32 (fixed,
TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, &valid);
if (!valid)
@@ -696,9 +643,11 @@ supports_file_transfer (TpCapabilities *self,
continue;
}
- if (n_fixed != tp_asv_size (fixed))
+ if (n_fixed != g_variant_n_children (fixed))
continue;
+ g_variant_unref (fixed);
+ g_free (allowed);
return TRUE;
}
@@ -805,31 +754,28 @@ tp_capabilities_supports_tubes_common (TpCapabilities *self,
const gchar *service_prop,
const gchar *expected_service)
{
- guint i;
+ GVariantIter iter;
+ GVariant *fixed;
+ const gchar **allowed;
g_return_val_if_fail (TP_IS_CAPABILITIES (self), FALSE);
g_return_val_if_fail (expected_handle_type == TP_ENTITY_TYPE_CONTACT ||
expected_handle_type == TP_ENTITY_TYPE_ROOM, FALSE);
- for (i = 0; i < self->priv->classes->len; i++)
+ g_variant_iter_init (&iter, self->priv->classes_variant);
+
+ while (g_variant_iter_loop (&iter, "(@a{sv}^a&s)", &fixed, &allowed))
{
- GValueArray *arr = g_ptr_array_index (self->priv->classes, i);
- GHashTable *fixed;
- const gchar * const *allowed;
const gchar *chan_type;
TpEntityType handle_type;
gboolean valid;
guint nb_fixed_props = 2;
- tp_value_array_unpack (arr, 2,
- &fixed,
- &allowed);
-
- chan_type = tp_asv_get_string (fixed, TP_PROP_CHANNEL_CHANNEL_TYPE);
+ chan_type = tp_vardict_get_string (fixed, TP_PROP_CHANNEL_CHANNEL_TYPE);
if (tp_strdiff (chan_type, expected_channel_type))
continue;
- handle_type = tp_asv_get_uint32 (fixed,
+ handle_type = tp_vardict_get_uint32 (fixed,
TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, &valid);
if (!valid || handle_type != expected_handle_type)
continue;
@@ -839,13 +785,17 @@ tp_capabilities_supports_tubes_common (TpCapabilities *self,
const gchar *service;
nb_fixed_props++;
- service = tp_asv_get_string (fixed, service_prop);
+ service = tp_vardict_get_string (fixed, service_prop);
if (tp_strdiff (service, expected_service))
continue;
}
- if (g_hash_table_size (fixed) == nb_fixed_props)
- return TRUE;
+ if (g_variant_n_children (fixed) == nb_fixed_props)
+ {
+ g_variant_unref (fixed);
+ g_free (allowed);
+ return TRUE;
+ }
}
return FALSE;
@@ -941,7 +891,10 @@ tp_capabilities_supports_contact_search (TpCapabilities *self,
gboolean *with_server)
{
gboolean ret = FALSE;
- guint i, j;
+ GVariantIter iter;
+ GVariant *fixed;
+ const gchar **allowed_properties;
+ guint j;
g_return_val_if_fail (TP_IS_CAPABILITIES (self), FALSE);
@@ -951,22 +904,20 @@ tp_capabilities_supports_contact_search (TpCapabilities *self,
if (with_server)
*with_server = FALSE;
- for (i = 0; i < self->priv->classes->len; i++)
+ g_variant_iter_init (&iter, self->priv->classes_variant);
+
+ while (g_variant_iter_loop (&iter, "(@a{sv}^a&s)", &fixed,
+ &allowed_properties))
{
- GValueArray *arr = g_ptr_array_index (self->priv->classes, i);
- GHashTable *fixed;
const gchar *chan_type;
- const gchar **allowed_properties;
-
- tp_value_array_unpack (arr, 2, &fixed, &allowed_properties);
/* ContactSearch channel should have ChannelType and TargetEntityType=NONE
* but CM implementations are wrong and omitted TargetEntityType,
* so it's set in stone now. */
- if (g_hash_table_size (fixed) != 1)
+ if (g_variant_n_children (fixed) != 1)
continue;
- chan_type = tp_asv_get_string (fixed, TP_PROP_CHANNEL_CHANNEL_TYPE);
+ chan_type = tp_vardict_get_string (fixed, TP_PROP_CHANNEL_CHANNEL_TYPE);
if (tp_strdiff (chan_type, TP_IFACE_CHANNEL_TYPE_CONTACT_SEARCH1))
continue;
@@ -1048,27 +999,27 @@ tp_capabilities_supports_room_list (TpCapabilities *self,
{
gboolean result = FALSE;
gboolean server = FALSE;
- guint i;
+ GVariantIter iter;
+ GVariant *fixed;
+ const gchar **allowed_properties;
- for (i = 0; i < self->priv->classes->len; i++)
+ g_variant_iter_init (&iter, self->priv->classes_variant);
+
+ while (g_variant_iter_loop (&iter, "(@a{sv}^a&s)", &fixed,
+ &allowed_properties))
{
- GValueArray *arr = g_ptr_array_index (self->priv->classes, i);
- GHashTable *fixed;
const gchar *chan_type;
- const gchar **allowed_properties;
TpEntityType handle_type;
gboolean valid;
- tp_value_array_unpack (arr, 2, &fixed, &allowed_properties);
-
- if (g_hash_table_size (fixed) != 2)
+ if (g_variant_n_children (fixed) != 2)
continue;
- chan_type = tp_asv_get_string (fixed, TP_PROP_CHANNEL_CHANNEL_TYPE);
+ chan_type = tp_vardict_get_string (fixed, TP_PROP_CHANNEL_CHANNEL_TYPE);
if (tp_strdiff (chan_type, TP_IFACE_CHANNEL_TYPE_ROOM_LIST1))
continue;
- handle_type = tp_asv_get_uint32 (fixed,
+ handle_type = tp_vardict_get_uint32 (fixed,
TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, &valid);
if (!valid || handle_type != TP_ENTITY_TYPE_NONE)
continue;
@@ -1087,18 +1038,16 @@ tp_capabilities_supports_room_list (TpCapabilities *self,
}
/**
- * tp_capabilities_dup_channel_classes_variant:
+ * tp_capabilities_dup_channel_classes:
* @self: a #TpCapabilities
*
- * Return the #TpCapabilities:channel-classes-variant property
+ * Return the #TpCapabilities:channel-classes property
*
* Returns: (transfer full): the value of the
- * #TpCapabilities:channel-classes-variant property
- *
- * Since: 0.19.0
+ * #TpCapabilities:channel-classes property
*/
GVariant *
-tp_capabilities_dup_channel_classes_variant (TpCapabilities *self)
+tp_capabilities_dup_channel_classes (TpCapabilities *self)
{
return g_variant_ref (self->priv->classes_variant);
}
diff --git a/telepathy-glib/capabilities.h b/telepathy-glib/capabilities.h
index 07db17ed7..f7f2ebc40 100644
--- a/telepathy-glib/capabilities.h
+++ b/telepathy-glib/capabilities.h
@@ -54,10 +54,7 @@ GType tp_capabilities_get_type (void) G_GNUC_CONST;
(G_TYPE_INSTANCE_GET_CLASS ((obj), TP_TYPE_CAPABILITIES, \
TpCapabilitiesClass))
-GPtrArray * tp_capabilities_get_channel_classes (TpCapabilities *self);
-
-_TP_AVAILABLE_IN_0_20
-GVariant * tp_capabilities_dup_channel_classes_variant (TpCapabilities *self);
+GVariant *tp_capabilities_dup_channel_classes (TpCapabilities *self);
gboolean tp_capabilities_is_specific_to_contact (TpCapabilities *self);
diff --git a/telepathy-glib/connection.c b/telepathy-glib/connection.c
index 9c74988b7..93c1a1171 100644
--- a/telepathy-glib/connection.c
+++ b/telepathy-glib/connection.c
@@ -25,6 +25,7 @@
#include <string.h>
+#include <dbus/dbus-glib.h>
#include <dbus/dbus-protocol.h>
#include <telepathy-glib/asv.h>
@@ -538,8 +539,8 @@ tp_connection_get_rcc_cb (TpProxy *proxy,
DEBUG ("CAPABILITIES ready");
- self->priv->capabilities = _tp_capabilities_new (g_value_get_boxed (value),
- FALSE);
+ self->priv->capabilities = _tp_capabilities_new (
+ dbus_g_value_build_g_variant (value), FALSE);
finally:
while ((result = g_queue_pop_head (&self->priv->capabilities_queue)) != NULL)
diff --git a/telepathy-glib/contact.c b/telepathy-glib/contact.c
index 7ce988499..77cbaf7eb 100644
--- a/telepathy-glib/contact.c
+++ b/telepathy-glib/contact.c
@@ -43,6 +43,7 @@
#include "telepathy-glib/debug-internal.h"
#include "telepathy-glib/util-internal.h"
#include "telepathy-glib/variant-util.h"
+#include "telepathy-glib/variant-util-internal.h"
static const gchar *
nonnull (const gchar *s)
@@ -1839,7 +1840,9 @@ contact_maybe_set_capabilities (TpContact *self,
if (self == NULL || arr == NULL)
return;
- capabilities = _tp_capabilities_new (arr, TRUE);
+ capabilities = _tp_capabilities_new (_tp_boxed_to_variant (
+ TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
+ "a(a{sv}as)", arr), TRUE);
contact_set_capabilities (self, capabilities);
g_object_unref (capabilities);
}
diff --git a/telepathy-glib/protocol.c b/telepathy-glib/protocol.c
index ca0902c1c..9d4fe1c90 100644
--- a/telepathy-glib/protocol.c
+++ b/telepathy-glib/protocol.c
@@ -536,7 +536,9 @@ tp_protocol_constructed (GObject *object)
TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST);
if (rccs != NULL)
- self->priv->capabilities = _tp_capabilities_new (rccs, FALSE);
+ self->priv->capabilities = _tp_capabilities_new (_tp_boxed_to_variant (
+ TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
+ "a(a{sv}as)", (GPtrArray *) rccs), FALSE);
self->priv->authentication_types = asv_strdupv_or_empty (
protocol_properties,
diff --git a/telepathy-glib/versions/main-1.0.abi b/telepathy-glib/versions/main-1.0.abi
index 25f39306b..0d4e5e1e6 100644
--- a/telepathy-glib/versions/main-1.0.abi
+++ b/telepathy-glib/versions/main-1.0.abi
@@ -426,8 +426,7 @@ tp_call_stream_request_receiving_async
tp_call_stream_request_receiving_finish
tp_call_stream_set_sending_async
tp_call_stream_set_sending_finish
-tp_capabilities_dup_channel_classes_variant
-tp_capabilities_get_channel_classes
+tp_capabilities_dup_channel_classes
tp_capabilities_get_type
tp_capabilities_is_specific_to_contact
tp_capabilities_supports_audio_call
diff --git a/tests/capabilities.c b/tests/capabilities.c
index 399f66921..d3d83cd6e 100644
--- a/tests/capabilities.c
+++ b/tests/capabilities.c
@@ -28,60 +28,29 @@ setup (Test *test,
tp_debug_set_flags ("all");
}
-static void
-add_text_chat_class (GPtrArray *classes,
- TpEntityType handle_type)
+static GVariant *
+text_chat_class (TpEntityType handle_type)
{
- GHashTable *fixed;
- const gchar * const allowed[] = { NULL };
- GValueArray *arr;
-
- fixed = tp_asv_new (
- TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
- TP_IFACE_CHANNEL_TYPE_TEXT,
- TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, G_TYPE_UINT,
- handle_type,
- NULL);
-
- arr = tp_value_array_build (2,
- TP_HASH_TYPE_STRING_VARIANT_MAP, fixed,
- G_TYPE_STRV, allowed,
- G_TYPE_INVALID);
-
- g_hash_table_unref (fixed);
-
- g_ptr_array_add (classes, arr);
+ return g_variant_new_parsed ("({%s: <%s>, %s: <%u>}, @as [])",
+ TP_PROP_CHANNEL_CHANNEL_TYPE, TP_IFACE_CHANNEL_TYPE_TEXT,
+ TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, (guint32) handle_type);
}
-static void
-add_ft_class (GPtrArray *classes,
- const gchar * const *allowed)
+static GVariant *
+ft_class (const gchar * const *allowed)
{
- GHashTable *fixed;
const gchar * const default_allowed[] = {
TP_PROP_CHANNEL_TYPE_FILE_TRANSFER1_FILENAME,
TP_PROP_CHANNEL_TYPE_FILE_TRANSFER1_SIZE,
NULL };
- GValueArray *arr;
if (allowed == NULL)
allowed = default_allowed;
- fixed = tp_asv_new (
- TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
- TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER1,
- TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, G_TYPE_UINT,
- TP_ENTITY_TYPE_CONTACT,
- NULL);
-
- arr = tp_value_array_build (2,
- TP_HASH_TYPE_STRING_VARIANT_MAP, fixed,
- G_TYPE_STRV, allowed,
- G_TYPE_INVALID);
-
- g_hash_table_unref (fixed);
-
- g_ptr_array_add (classes, arr);
+ return g_variant_new_parsed ("({%s: <%s>, %s: <%u>}, %^as)",
+ TP_PROP_CHANNEL_CHANNEL_TYPE, TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER1,
+ TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, (guint32) TP_ENTITY_TYPE_CONTACT,
+ allowed);
}
static void
@@ -89,78 +58,66 @@ test_basics (Test *test,
gconstpointer data G_GNUC_UNUSED)
{
TpCapabilities *caps;
- GPtrArray *classes;
- GValueArray *arr;
- GHashTable *fixed;
- GStrv allowed;
+ GVariant *classes;
+ GVariant *fixed;
+ const gchar **allowed;
const gchar *chan_type;
TpEntityType handle_type;
gboolean valid;
- /* TpCapabilities containing the text chats and ft caps */
- classes = g_ptr_array_sized_new (2);
- add_text_chat_class (classes, TP_ENTITY_TYPE_CONTACT);
- add_ft_class (classes, NULL);
-
caps = tp_tests_object_new_static_class (TP_TYPE_CAPABILITIES,
- "channel-classes", classes,
+ "channel-classes", g_variant_new_parsed ("[%*, %*]",
+ text_chat_class (TP_ENTITY_TYPE_CONTACT),
+ ft_class (NULL)),
"contact-specific", FALSE,
NULL);
- g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
- classes);
-
g_assert (!tp_capabilities_is_specific_to_contact (caps));
- classes = tp_capabilities_get_channel_classes (caps);
+ classes = tp_capabilities_dup_channel_classes (caps);
- g_assert_cmpuint (classes->len, ==, 2);
+ g_assert_cmpuint (g_variant_n_children (classes), ==, 2);
/* Check text chats class */
- arr = g_ptr_array_index (classes, 0);
- g_assert_cmpuint (arr->n_values, ==, 2);
-
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- fixed = g_value_get_boxed (g_value_array_get_nth (arr, 0));
- allowed = g_value_get_boxed (g_value_array_get_nth (arr, 1));
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+ g_variant_get_child (classes, 0, "(@a{sv}^a&s)", &fixed, &allowed);
- g_assert_cmpuint (g_hash_table_size (fixed), ==, 2);
+ g_assert_cmpuint (g_variant_n_children (fixed), ==, 2);
- chan_type = tp_asv_get_string (fixed, TP_PROP_CHANNEL_CHANNEL_TYPE);
+ chan_type = tp_vardict_get_string (fixed, TP_PROP_CHANNEL_CHANNEL_TYPE);
g_assert_cmpstr (chan_type, ==, TP_IFACE_CHANNEL_TYPE_TEXT);
- handle_type = tp_asv_get_uint32 (fixed, TP_PROP_CHANNEL_TARGET_ENTITY_TYPE,
- &valid);
+ handle_type = tp_vardict_get_uint32 (fixed,
+ TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, &valid);
g_assert (valid);
g_assert_cmpuint (handle_type, ==, TP_ENTITY_TYPE_CONTACT);
- g_assert_cmpuint (g_strv_length (allowed), ==, 0);
+ g_assert_cmpuint (g_strv_length ((GStrv) allowed), ==, 0);
- /* Check ft class */
- arr = g_ptr_array_index (classes, 1);
- g_assert_cmpuint (arr->n_values, ==, 2);
+ g_variant_unref (fixed);
+ g_free (allowed);
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- fixed = g_value_get_boxed (g_value_array_get_nth (arr, 0));
- allowed = g_value_get_boxed (g_value_array_get_nth (arr, 1));
- G_GNUC_END_IGNORE_DEPRECATIONS
+ /* Check ft class */
+ g_variant_get_child (classes, 1, "(@a{sv}^a&s)", &fixed, &allowed);
- g_assert_cmpuint (g_hash_table_size (fixed), ==, 2);
+ g_assert_cmpuint (g_variant_n_children (fixed), ==, 2);
- chan_type = tp_asv_get_string (fixed, TP_PROP_CHANNEL_CHANNEL_TYPE);
+ chan_type = tp_vardict_get_string (fixed, TP_PROP_CHANNEL_CHANNEL_TYPE);
g_assert_cmpstr (chan_type, ==, TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER1);
- handle_type = tp_asv_get_uint32 (fixed, TP_PROP_CHANNEL_TARGET_ENTITY_TYPE,
- &valid);
+ handle_type = tp_vardict_get_uint32 (fixed,
+ TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, &valid);
g_assert (valid);
g_assert_cmpuint (handle_type, ==, TP_ENTITY_TYPE_CONTACT);
- g_assert_cmpuint (g_strv_length (allowed), ==, 2);
+ g_assert_cmpuint (g_strv_length ((GStrv) allowed), ==, 2);
g_assert (tp_strv_contains ((const gchar * const * ) allowed,
TP_PROP_CHANNEL_TYPE_FILE_TRANSFER1_FILENAME));
g_assert (tp_strv_contains ((const gchar * const * ) allowed,
TP_PROP_CHANNEL_TYPE_FILE_TRANSFER1_SIZE));
+ g_variant_unref (fixed);
+ g_free (allowed);
+
+ g_variant_unref (classes);
g_object_unref (caps);
}
@@ -169,20 +126,15 @@ test_supports (Test *test,
gconstpointer data G_GNUC_UNUSED)
{
TpCapabilities *caps;
- GPtrArray *classes;
-
- /* TpCapabilities containing the text chats caps */
- classes = g_ptr_array_sized_new (1);
- add_text_chat_class (classes, TP_ENTITY_TYPE_CONTACT);
+ GVariant *classes;
caps = tp_tests_object_new_static_class (TP_TYPE_CAPABILITIES,
- "channel-classes", classes,
+ "channel-classes", g_variant_new_parsed ("[%*, %*]",
+ text_chat_class (TP_ENTITY_TYPE_CONTACT),
+ ft_class (NULL)),
"contact-specific", TRUE,
NULL);
- g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
- classes);
-
g_assert (tp_capabilities_is_specific_to_contact (caps));
g_assert (tp_capabilities_supports_text_chats (caps));
g_assert (!tp_capabilities_supports_text_chatrooms (caps));
@@ -191,17 +143,12 @@ test_supports (Test *test,
g_object_unref (caps);
/* TpCapabilities containing the text chatrooms caps */
- classes = g_ptr_array_sized_new (1);
- add_text_chat_class (classes, TP_ENTITY_TYPE_ROOM);
-
caps = tp_tests_object_new_static_class (TP_TYPE_CAPABILITIES,
- "channel-classes", classes,
+ "channel-classes", g_variant_new_parsed ("[%*]",
+ text_chat_class (TP_ENTITY_TYPE_ROOM)),
"contact-specific", TRUE,
NULL);
- g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
- classes);
-
g_assert (tp_capabilities_is_specific_to_contact (caps));
g_assert (!tp_capabilities_supports_text_chats (caps));
g_assert (tp_capabilities_supports_text_chatrooms (caps));
@@ -210,18 +157,13 @@ test_supports (Test *test,
g_object_unref (caps);
/* TpCapabilities containing both caps */
- classes = g_ptr_array_sized_new (2);
- add_text_chat_class (classes, TP_ENTITY_TYPE_CONTACT);
- add_text_chat_class (classes, TP_ENTITY_TYPE_ROOM);
-
caps = tp_tests_object_new_static_class (TP_TYPE_CAPABILITIES,
- "channel-classes", classes,
+ "channel-classes", g_variant_new_parsed ("[%*, %*]",
+ text_chat_class (TP_ENTITY_TYPE_CONTACT),
+ text_chat_class (TP_ENTITY_TYPE_ROOM)),
"contact-specific", TRUE,
NULL);
- g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
- classes);
-
g_assert (tp_capabilities_is_specific_to_contact (caps));
g_assert (tp_capabilities_supports_text_chats (caps));
g_assert (tp_capabilities_supports_text_chatrooms (caps));
@@ -230,85 +172,74 @@ test_supports (Test *test,
g_object_unref (caps);
/* TpCapabilities containing no caps */
- caps = _tp_capabilities_new (NULL, TRUE);
+ caps = tp_tests_object_new_static_class (TP_TYPE_CAPABILITIES,
+ "channel-classes", g_variant_new_parsed ("@a(a{sv}as) []"),
+ "contact-specific", TRUE,
+ NULL);
g_assert (tp_capabilities_is_specific_to_contact (caps));
g_assert (!tp_capabilities_supports_text_chats (caps));
g_assert (!tp_capabilities_supports_text_chatrooms (caps));
g_assert (!tp_capabilities_supports_sms (caps));
- classes = tp_capabilities_get_channel_classes (caps);
- g_assert_cmpuint (classes->len, ==, 0);
+ classes = tp_capabilities_dup_channel_classes (caps);
+ g_assert_cmpuint (g_variant_n_children (classes), ==, 0);
+ g_variant_unref (classes);
g_object_unref (caps);
}
-static void
-add_stream_tube_class (GPtrArray *classes,
- TpEntityType handle_type,
+static GVariant *
+stream_tube_class (TpEntityType handle_type,
const gchar *service)
{
- GHashTable *fixed;
- const gchar * const allowed[] = { NULL };
- GValueArray *arr;
-
- fixed = tp_asv_new (
- TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
- TP_IFACE_CHANNEL_TYPE_STREAM_TUBE1,
- TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, G_TYPE_UINT,
- handle_type,
- NULL);
+ GVariantBuilder fixed;
+
+ g_variant_builder_init (&fixed, G_VARIANT_TYPE_VARDICT);
+ g_variant_builder_add (&fixed, "{sv}", TP_PROP_CHANNEL_CHANNEL_TYPE,
+ g_variant_new_string (TP_IFACE_CHANNEL_TYPE_STREAM_TUBE1));
+ g_variant_builder_add (&fixed, "{sv}", TP_PROP_CHANNEL_TARGET_ENTITY_TYPE,
+ g_variant_new_uint32 (handle_type));
if (service != NULL)
{
- tp_asv_set_string (fixed, TP_PROP_CHANNEL_TYPE_STREAM_TUBE1_SERVICE,
- service);
+ g_variant_builder_add (&fixed, "{sv}",
+ TP_PROP_CHANNEL_TYPE_STREAM_TUBE1_SERVICE,
+ g_variant_new_string (service));
}
- arr = tp_value_array_build (2,
- TP_HASH_TYPE_STRING_VARIANT_MAP, fixed,
- G_TYPE_STRV, allowed,
- G_TYPE_INVALID);
-
- g_hash_table_unref (fixed);
-
- g_ptr_array_add (classes, arr);
+ return g_variant_new_parsed ("(%@a{sv}, @as [])",
+ g_variant_builder_end (&fixed));
}
-static void
-add_dbus_tube_class (GPtrArray *classes,
- TpEntityType handle_type,
+static GVariant *
+dbus_tube_class (TpEntityType handle_type,
const gchar *service_name,
gboolean add_extra_fixed)
{
- GHashTable *fixed;
- const gchar * const allowed[] = { NULL };
- GValueArray *arr;
-
- fixed = tp_asv_new (
- TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
- TP_IFACE_CHANNEL_TYPE_DBUS_TUBE1,
- TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, G_TYPE_UINT,
- handle_type,
- NULL);
+ GVariantBuilder fixed;
+
+ g_variant_builder_init (&fixed, G_VARIANT_TYPE_VARDICT);
+ g_variant_builder_add (&fixed, "{sv}", TP_PROP_CHANNEL_CHANNEL_TYPE,
+ g_variant_new_string (TP_IFACE_CHANNEL_TYPE_DBUS_TUBE1));
+ g_variant_builder_add (&fixed, "{sv}", TP_PROP_CHANNEL_TARGET_ENTITY_TYPE,
+ g_variant_new_uint32 (handle_type));
if (service_name != NULL)
{
- tp_asv_set_string (fixed, TP_PROP_CHANNEL_TYPE_DBUS_TUBE1_SERVICE_NAME,
- service_name);
+ g_variant_builder_add (&fixed, "{sv}",
+ TP_PROP_CHANNEL_TYPE_DBUS_TUBE1_SERVICE_NAME,
+ g_variant_new_string (service_name));
}
if (add_extra_fixed)
- tp_asv_set_boolean (fixed, "ExtraBadgersRequired", TRUE);
-
- arr = tp_value_array_build (2,
- TP_HASH_TYPE_STRING_VARIANT_MAP, fixed,
- G_TYPE_STRV, allowed,
- G_TYPE_INVALID);
-
- g_hash_table_unref (fixed);
+ {
+ g_variant_builder_add (&fixed, "{sv}", "ExtraBadgersRequired",
+ g_variant_new_boolean (TRUE));
+ }
- g_ptr_array_add (classes, arr);
+ return g_variant_new_parsed ("(%@a{sv}, @as [])",
+ g_variant_builder_end (&fixed));
}
static void
@@ -316,10 +247,12 @@ test_supports_tube (Test *test,
gconstpointer data G_GNUC_UNUSED)
{
TpCapabilities *caps;
- GPtrArray *classes;
/* TpCapabilities containing no caps */
- caps = _tp_capabilities_new (NULL, TRUE);
+ caps = tp_tests_object_new_static_class (TP_TYPE_CAPABILITIES,
+ "channel-classes", g_variant_new_parsed ("@a(a{sv}as) []"),
+ "contact-specific", TRUE,
+ NULL);
g_assert (!tp_capabilities_supports_stream_tubes (caps,
TP_ENTITY_TYPE_CONTACT, NULL));
@@ -341,17 +274,12 @@ test_supports_tube (Test *test,
g_object_unref (caps);
/* TpCapabilities containing the private stream tube caps without service */
- classes = g_ptr_array_sized_new (1);
- add_stream_tube_class (classes, TP_ENTITY_TYPE_CONTACT, NULL);
-
caps = tp_tests_object_new_static_class (TP_TYPE_CAPABILITIES,
- "channel-classes", classes,
+ "channel-classes", g_variant_new_parsed ("[%*]",
+ stream_tube_class (TP_ENTITY_TYPE_CONTACT, NULL)),
"contact-specific", TRUE,
NULL);
- g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
- classes);
-
g_assert (tp_capabilities_supports_stream_tubes (caps, TP_ENTITY_TYPE_CONTACT,
NULL));
g_assert (!tp_capabilities_supports_stream_tubes (caps, TP_ENTITY_TYPE_ROOM,
@@ -373,18 +301,13 @@ test_supports_tube (Test *test,
/* TpCapabilities containing the private and muc stream tube caps without
* service */
- classes = g_ptr_array_sized_new (2);
- add_stream_tube_class (classes, TP_ENTITY_TYPE_CONTACT, NULL);
- add_stream_tube_class (classes, TP_ENTITY_TYPE_ROOM, NULL);
-
caps = tp_tests_object_new_static_class (TP_TYPE_CAPABILITIES,
- "channel-classes", classes,
+ "channel-classes", g_variant_new_parsed ("[%*, %*]",
+ stream_tube_class (TP_ENTITY_TYPE_CONTACT, NULL),
+ stream_tube_class (TP_ENTITY_TYPE_ROOM, NULL)),
"contact-specific", TRUE,
NULL);
- g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
- classes);
-
g_assert (tp_capabilities_supports_stream_tubes (caps, TP_ENTITY_TYPE_CONTACT,
NULL));
g_assert (tp_capabilities_supports_stream_tubes (caps, TP_ENTITY_TYPE_ROOM,
@@ -406,20 +329,15 @@ test_supports_tube (Test *test,
/* TpCapabilities containing the private and muc stream tube caps and
* one with a service */
- classes = g_ptr_array_sized_new (4);
- add_stream_tube_class (classes, TP_ENTITY_TYPE_CONTACT, NULL);
- add_stream_tube_class (classes, TP_ENTITY_TYPE_ROOM, NULL);
- add_stream_tube_class (classes, TP_ENTITY_TYPE_CONTACT, "test-service");
- add_stream_tube_class (classes, TP_ENTITY_TYPE_ROOM, "test-service");
-
caps = tp_tests_object_new_static_class (TP_TYPE_CAPABILITIES,
- "channel-classes", classes,
+ "channel-classes", g_variant_new_parsed ("[%*, %*, %*, %*]",
+ stream_tube_class (TP_ENTITY_TYPE_CONTACT, NULL),
+ stream_tube_class (TP_ENTITY_TYPE_ROOM, NULL),
+ stream_tube_class (TP_ENTITY_TYPE_CONTACT, "test-service"),
+ stream_tube_class (TP_ENTITY_TYPE_ROOM, "test-service")),
"contact-specific", TRUE,
NULL);
- g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
- classes);
-
g_assert (tp_capabilities_supports_stream_tubes (caps, TP_ENTITY_TYPE_CONTACT,
NULL));
g_assert (tp_capabilities_supports_stream_tubes (caps, TP_ENTITY_TYPE_ROOM,
@@ -444,18 +362,13 @@ test_supports_tube (Test *test,
g_object_unref (caps);
/* Connection capabilities */
- classes = g_ptr_array_sized_new (2);
- add_stream_tube_class (classes, TP_ENTITY_TYPE_CONTACT, NULL);
- add_dbus_tube_class (classes, TP_ENTITY_TYPE_CONTACT, NULL, FALSE);
-
caps = tp_tests_object_new_static_class (TP_TYPE_CAPABILITIES,
- "channel-classes", classes,
+ "channel-classes", g_variant_new_parsed ("[%*, %*]",
+ stream_tube_class (TP_ENTITY_TYPE_CONTACT, NULL),
+ dbus_tube_class (TP_ENTITY_TYPE_CONTACT, NULL, FALSE)),
"contact-specific", FALSE,
NULL);
- g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
- classes);
-
g_assert (tp_capabilities_supports_stream_tubes (caps, TP_ENTITY_TYPE_CONTACT,
NULL));
g_assert (!tp_capabilities_supports_stream_tubes (caps, TP_ENTITY_TYPE_ROOM,
@@ -478,17 +391,12 @@ test_supports_tube (Test *test,
g_object_unref (caps);
/* TpCapabilities containing the private dbus tube caps without service */
- classes = g_ptr_array_sized_new (1);
- add_dbus_tube_class (classes, TP_ENTITY_TYPE_CONTACT, NULL, FALSE);
-
caps = tp_tests_object_new_static_class (TP_TYPE_CAPABILITIES,
- "channel-classes", classes,
+ "channel-classes", g_variant_new_parsed ("[%*]",
+ dbus_tube_class (TP_ENTITY_TYPE_CONTACT, NULL, FALSE)),
"contact-specific", TRUE,
NULL);
- g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
- classes);
-
g_assert (!tp_capabilities_supports_stream_tubes (caps,
TP_ENTITY_TYPE_CONTACT, NULL));
g_assert (!tp_capabilities_supports_stream_tubes (caps, TP_ENTITY_TYPE_ROOM,
@@ -510,18 +418,13 @@ test_supports_tube (Test *test,
/* TpCapabilities containing the private and muc dbus tube caps without
* service */
- classes = g_ptr_array_sized_new (2);
- add_dbus_tube_class (classes, TP_ENTITY_TYPE_CONTACT, NULL, FALSE);
- add_dbus_tube_class (classes, TP_ENTITY_TYPE_ROOM, NULL, FALSE);
-
caps = tp_tests_object_new_static_class (TP_TYPE_CAPABILITIES,
- "channel-classes", classes,
+ "channel-classes", g_variant_new_parsed ("[%*, %*]",
+ dbus_tube_class (TP_ENTITY_TYPE_CONTACT, NULL, FALSE),
+ dbus_tube_class (TP_ENTITY_TYPE_ROOM, NULL, FALSE)),
"contact-specific", TRUE,
NULL);
- g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
- classes);
-
g_assert (!tp_capabilities_supports_stream_tubes (caps,
TP_ENTITY_TYPE_CONTACT, NULL));
g_assert (!tp_capabilities_supports_stream_tubes (caps, TP_ENTITY_TYPE_ROOM,
@@ -543,20 +446,15 @@ test_supports_tube (Test *test,
/* TpCapabilities containing the private and muc dbus tube caps and
* one with a service */
- classes = g_ptr_array_sized_new (4);
- add_dbus_tube_class (classes, TP_ENTITY_TYPE_CONTACT, NULL, FALSE);
- add_dbus_tube_class (classes, TP_ENTITY_TYPE_ROOM, NULL, FALSE);
- add_dbus_tube_class (classes, TP_ENTITY_TYPE_CONTACT, "com.Test", FALSE);
- add_dbus_tube_class (classes, TP_ENTITY_TYPE_ROOM, "com.Test", FALSE);
-
caps = tp_tests_object_new_static_class (TP_TYPE_CAPABILITIES,
- "channel-classes", classes,
+ "channel-classes", g_variant_new_parsed ("[%*, %*, %*, %*]",
+ dbus_tube_class (TP_ENTITY_TYPE_CONTACT, NULL, FALSE),
+ dbus_tube_class (TP_ENTITY_TYPE_ROOM, NULL, FALSE),
+ dbus_tube_class (TP_ENTITY_TYPE_CONTACT, "com.Test", FALSE),
+ dbus_tube_class (TP_ENTITY_TYPE_ROOM, "com.Test", FALSE)),
"contact-specific", TRUE,
NULL);
- g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
- classes);
-
g_assert (!tp_capabilities_supports_stream_tubes (caps,
TP_ENTITY_TYPE_CONTACT, NULL));
g_assert (!tp_capabilities_supports_stream_tubes (caps, TP_ENTITY_TYPE_ROOM,
@@ -581,53 +479,44 @@ test_supports_tube (Test *test,
g_object_unref (caps);
/* Any extra fixed prop make it unsupported */
- classes = g_ptr_array_sized_new (1);
- add_dbus_tube_class (classes, TP_ENTITY_TYPE_CONTACT, NULL, TRUE);
-
caps = tp_tests_object_new_static_class (TP_TYPE_CAPABILITIES,
- "channel-classes", classes,
+ "channel-classes", g_variant_new_parsed ("[%*]",
+ dbus_tube_class (TP_ENTITY_TYPE_CONTACT, NULL, TRUE)),
"contact-specific", TRUE,
NULL);
- g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
- classes);
-
g_assert (!tp_capabilities_supports_dbus_tubes (caps,
TP_ENTITY_TYPE_CONTACT, NULL));
g_object_unref (caps);
}
-static void
-add_room_list_class (GPtrArray *classes,
- gboolean server,
+static GVariant *
+room_list_class (gboolean server,
gboolean add_extra_fixed)
{
- GHashTable *fixed;
+ GVariantBuilder fixed;
const gchar * const allowed[] = {
TP_PROP_CHANNEL_TYPE_ROOM_LIST1_SERVER,
NULL };
const gchar * const no_allowed[] = { NULL };
- GValueArray *arr;
- fixed = tp_asv_new (
- TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
- TP_IFACE_CHANNEL_TYPE_ROOM_LIST1,
- TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, G_TYPE_UINT,
- TP_ENTITY_TYPE_NONE,
- NULL);
-
- if (add_extra_fixed)
- tp_asv_set_boolean (fixed, "ExtraBadgersRequired", TRUE);
+ g_variant_builder_init (&fixed, G_VARIANT_TYPE_VARDICT);
- arr = tp_value_array_build (2,
- TP_HASH_TYPE_STRING_VARIANT_MAP, fixed,
- G_TYPE_STRV, server ? allowed : no_allowed,
- G_TYPE_INVALID);
+ g_variant_builder_add (&fixed, "{sv}", TP_PROP_CHANNEL_CHANNEL_TYPE,
+ g_variant_new_string (TP_IFACE_CHANNEL_TYPE_ROOM_LIST1));
+ g_variant_builder_add (&fixed, "{sv}", TP_PROP_CHANNEL_TARGET_ENTITY_TYPE,
+ g_variant_new_uint32 (TP_ENTITY_TYPE_NONE));
- g_hash_table_unref (fixed);
+ if (add_extra_fixed)
+ {
+ g_variant_builder_add (&fixed, "{sv}", "ExtraBadgersRequired",
+ g_variant_new_boolean (TRUE));
+ }
- g_ptr_array_add (classes, arr);
+ return g_variant_new_parsed ("(%@a{sv}, %^as)",
+ g_variant_builder_end (&fixed),
+ server ? allowed : no_allowed);
}
static void
@@ -635,121 +524,91 @@ test_supports_room_list (Test *test,
gconstpointer data G_GNUC_UNUSED)
{
TpCapabilities *caps;
- GPtrArray *classes;
gboolean with_server = TRUE;
/* Does not support room list */
- classes = g_ptr_array_sized_new (4);
- add_ft_class (classes, NULL);
-
caps = tp_tests_object_new_static_class (TP_TYPE_CAPABILITIES,
- "channel-classes", classes,
+ "channel-classes", g_variant_new_parsed ("[%*]",
+ ft_class (NULL)),
"contact-specific", FALSE,
NULL);
- g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
- classes);
-
g_assert (!tp_capabilities_supports_room_list (caps, &with_server));
g_assert (!with_server);
g_object_unref (caps);
/* Support room list but no server */
- classes = g_ptr_array_sized_new (4);
- add_ft_class (classes, NULL);
- add_room_list_class (classes, FALSE, FALSE);
-
caps = tp_tests_object_new_static_class (TP_TYPE_CAPABILITIES,
- "channel-classes", classes,
+ "channel-classes", g_variant_new_parsed ("[%*, %*]",
+ ft_class (NULL),
+ room_list_class (FALSE, FALSE)),
"contact-specific", FALSE,
NULL);
- g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
- classes);
-
g_assert (tp_capabilities_supports_room_list (caps, &with_server));
g_assert (!with_server);
g_object_unref (caps);
/* Support room list with server */
- classes = g_ptr_array_sized_new (4);
- add_ft_class (classes, NULL);
- add_room_list_class (classes, TRUE, FALSE);
-
caps = tp_tests_object_new_static_class (TP_TYPE_CAPABILITIES,
- "channel-classes", classes,
+ "channel-classes", g_variant_new_parsed ("[%*, %*]",
+ ft_class (NULL),
+ room_list_class (TRUE, FALSE)),
"contact-specific", FALSE,
NULL);
- g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
- classes);
-
g_assert (tp_capabilities_supports_room_list (caps, &with_server));
g_assert (with_server);
g_object_unref (caps);
/* Any extra fixed prop make it unsupported */
- classes = g_ptr_array_sized_new (1);
- add_room_list_class (classes, FALSE, TRUE);
-
caps = tp_tests_object_new_static_class (TP_TYPE_CAPABILITIES,
- "channel-classes", classes,
+ "channel-classes", g_variant_new_parsed ("[%*]",
+ room_list_class (FALSE, TRUE)),
"contact-specific", FALSE,
NULL);
- g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
- classes);
-
g_assert (!tp_capabilities_supports_room_list (caps, NULL));
g_object_unref (caps);
}
-static void
-add_sms_class (GPtrArray *classes,
- gboolean add_extra_fixed,
+static GVariant *
+sms_class (gboolean add_extra_fixed,
gboolean use_allowed)
{
- GHashTable *fixed;
- GPtrArray *allowed;
- GValueArray *arr;
+ GVariantBuilder fixed;
+ const gchar *allowed[] = { NULL, NULL };
- fixed = tp_asv_new (
- TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
- TP_IFACE_CHANNEL_TYPE_TEXT,
- TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, G_TYPE_UINT,
- TP_ENTITY_TYPE_CONTACT,
- NULL);
-
- allowed = g_ptr_array_new ();
+ g_variant_builder_init (&fixed, G_VARIANT_TYPE_VARDICT);
+ g_variant_builder_add (&fixed, "{sv}", TP_PROP_CHANNEL_CHANNEL_TYPE,
+ g_variant_new_string (TP_IFACE_CHANNEL_TYPE_TEXT));
+ g_variant_builder_add (&fixed, "{sv}", TP_PROP_CHANNEL_TARGET_ENTITY_TYPE,
+ g_variant_new_uint32 (TP_ENTITY_TYPE_CONTACT));
if (use_allowed)
{
- g_ptr_array_add (allowed, TP_PROP_CHANNEL_INTERFACE_SMS1_SMS_CHANNEL);
+ allowed[0] = TP_PROP_CHANNEL_INTERFACE_SMS1_SMS_CHANNEL;
}
else
{
- tp_asv_set_boolean (fixed, TP_PROP_CHANNEL_INTERFACE_SMS1_SMS_CHANNEL,
- TRUE);
+ g_variant_builder_add (&fixed, "{sv}",
+ TP_PROP_CHANNEL_INTERFACE_SMS1_SMS_CHANNEL,
+ g_variant_new_boolean (TRUE));
}
- g_ptr_array_add (allowed, NULL);
-
if (add_extra_fixed)
- tp_asv_set_boolean (fixed, "ExtraBadgersRequired", TRUE);
-
- arr = tp_value_array_build (2,
- TP_HASH_TYPE_STRING_VARIANT_MAP, fixed,
- G_TYPE_STRV, allowed->pdata,
- G_TYPE_INVALID);
-
- g_hash_table_unref (fixed);
- g_ptr_array_unref (allowed);
+ {
+ g_variant_builder_add (&fixed, "{sv}", "ExtraBadgersRequired",
+ g_variant_new_boolean (TRUE));
+ }
- g_ptr_array_add (classes, arr);
+ return g_variant_new_parsed ("(%@a{sv}, %^as)",
+ g_variant_builder_end (&fixed),
+ allowed);
}
static void
@@ -757,74 +616,56 @@ test_supports_sms (Test *test,
gconstpointer data G_GNUC_UNUSED)
{
TpCapabilities *caps;
- GPtrArray *classes;
-
- classes = g_ptr_array_sized_new (1);
- add_sms_class (classes, FALSE, FALSE);
caps = tp_tests_object_new_static_class (TP_TYPE_CAPABILITIES,
- "channel-classes", classes,
+ "channel-classes", g_variant_new_parsed ("[%*]",
+ sms_class (FALSE, FALSE)),
"contact-specific", FALSE,
NULL);
- g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
- classes);
-
g_assert (tp_capabilities_supports_sms (caps));
g_object_unref (caps);
/* Reject if more fixed properties are required */
- classes = g_ptr_array_sized_new (1);
- add_sms_class (classes, TRUE, FALSE);
-
caps = tp_tests_object_new_static_class (TP_TYPE_CAPABILITIES,
- "channel-classes", classes,
+ "channel-classes", g_variant_new_parsed ("[%*]",
+ sms_class (TRUE, FALSE)),
"contact-specific", FALSE,
NULL);
- g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
- classes);
-
g_assert (!tp_capabilities_supports_sms (caps));
g_object_unref (caps);
/* Test with SMS as an allowed property */
- classes = g_ptr_array_sized_new (1);
- add_sms_class (classes, FALSE, TRUE);
-
caps = tp_tests_object_new_static_class (TP_TYPE_CAPABILITIES,
- "channel-classes", classes,
+ "channel-classes", g_variant_new_parsed ("[%*]",
+ sms_class (FALSE, TRUE)),
"contact-specific", FALSE,
NULL);
- g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
- classes);
-
g_assert (tp_capabilities_supports_sms (caps));
g_object_unref (caps);
}
-static void
-add_call_class (GPtrArray *classes,
- TpEntityType handle_type,
+static GVariant *
+call_class (TpEntityType handle_type,
gboolean initial_audio,
gboolean initial_video,
gboolean use_allowed,
gboolean add_extra_fixed)
{
- GHashTable *fixed;
+ GVariantBuilder fixed;
GPtrArray *allowed;
- GValueArray *arr;
+ GVariant *ret;
- fixed = tp_asv_new (
- TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
- TP_IFACE_CHANNEL_TYPE_CALL1,
- TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, G_TYPE_UINT,
- handle_type,
- NULL);
+ g_variant_builder_init (&fixed, G_VARIANT_TYPE_VARDICT);
+ g_variant_builder_add (&fixed, "{sv}", TP_PROP_CHANNEL_CHANNEL_TYPE,
+ g_variant_new_string (TP_IFACE_CHANNEL_TYPE_CALL1));
+ g_variant_builder_add (&fixed, "{sv}", TP_PROP_CHANNEL_TARGET_ENTITY_TYPE,
+ g_variant_new_uint32 (handle_type));
allowed = g_ptr_array_new ();
@@ -836,8 +677,9 @@ add_call_class (GPtrArray *classes,
}
else
{
- tp_asv_set_boolean (fixed, TP_PROP_CHANNEL_TYPE_CALL1_INITIAL_AUDIO,
- TRUE);
+ g_variant_builder_add (&fixed, "{sv}",
+ TP_PROP_CHANNEL_TYPE_CALL1_INITIAL_AUDIO,
+ g_variant_new_boolean (TRUE));
}
}
@@ -849,25 +691,23 @@ add_call_class (GPtrArray *classes,
}
else
{
- tp_asv_set_boolean (fixed, TP_PROP_CHANNEL_TYPE_CALL1_INITIAL_VIDEO,
- TRUE);
+ g_variant_builder_add (&fixed, "{sv}",
+ TP_PROP_CHANNEL_TYPE_CALL1_INITIAL_VIDEO,
+ g_variant_new_boolean (TRUE));
}
}
- g_ptr_array_add (allowed, NULL);
-
if (add_extra_fixed)
- tp_asv_set_boolean (fixed, "ExtraBadgersRequired", TRUE);
-
- arr = tp_value_array_build (2,
- TP_HASH_TYPE_STRING_VARIANT_MAP, fixed,
- G_TYPE_STRV, allowed->pdata,
- G_TYPE_INVALID);
+ {
+ g_variant_builder_add (&fixed, "{sv}", "ExtraBadgersRequired",
+ g_variant_new_boolean (TRUE));
+ }
- g_hash_table_unref (fixed);
+ g_ptr_array_add (allowed, NULL);
+ ret = g_variant_new_parsed ("(%@a{sv}, %^as)",
+ g_variant_builder_end (&fixed), allowed->pdata);
g_ptr_array_unref (allowed);
-
- g_ptr_array_add (classes, arr);
+ return ret;
}
static void
@@ -875,20 +715,14 @@ test_supports_call (Test *test,
gconstpointer data G_GNUC_UNUSED)
{
TpCapabilities *caps;
- GPtrArray *classes;
/* A class with no audio/video can't do anything */
- classes = g_ptr_array_sized_new (1);
- add_call_class (classes, TP_ENTITY_TYPE_CONTACT, FALSE, FALSE, FALSE, FALSE);
-
caps = tp_tests_object_new_static_class (TP_TYPE_CAPABILITIES,
- "channel-classes", classes,
+ "channel-classes", g_variant_new_parsed ("[%*]",
+ call_class (TP_ENTITY_TYPE_CONTACT, FALSE, FALSE, FALSE, FALSE)),
"contact-specific", FALSE,
NULL);
- g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
- classes);
-
g_assert (!tp_capabilities_supports_audio_call (caps,
TP_ENTITY_TYPE_CONTACT));
g_assert (!tp_capabilities_supports_audio_video_call (caps,
@@ -897,17 +731,12 @@ test_supports_call (Test *test,
g_object_unref (caps);
/* A class with only audio can't do audio_video */
- classes = g_ptr_array_sized_new (1);
- add_call_class (classes, TP_ENTITY_TYPE_CONTACT, TRUE, FALSE, FALSE, FALSE);
-
caps = tp_tests_object_new_static_class (TP_TYPE_CAPABILITIES,
- "channel-classes", classes,
+ "channel-classes", g_variant_new_parsed ("[%*]",
+ call_class (TP_ENTITY_TYPE_CONTACT, TRUE, FALSE, FALSE, FALSE)),
"contact-specific", FALSE,
NULL);
- g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
- classes);
-
g_assert (tp_capabilities_supports_audio_call (caps,
TP_ENTITY_TYPE_CONTACT));
g_assert (!tp_capabilities_supports_audio_video_call (caps,
@@ -916,17 +745,12 @@ test_supports_call (Test *test,
g_object_unref (caps);
/* A class with audio and video in fixed can't do audio only */
- classes = g_ptr_array_sized_new (1);
- add_call_class (classes, TP_ENTITY_TYPE_CONTACT, TRUE, TRUE, FALSE, FALSE);
-
caps = tp_tests_object_new_static_class (TP_TYPE_CAPABILITIES,
- "channel-classes", classes,
+ "channel-classes", g_variant_new_parsed ("[%*]",
+ call_class (TP_ENTITY_TYPE_CONTACT, TRUE, TRUE, FALSE, FALSE)),
"contact-specific", FALSE,
NULL);
- g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
- classes);
-
g_assert (!tp_capabilities_supports_audio_call (caps,
TP_ENTITY_TYPE_CONTACT));
g_assert (tp_capabilities_supports_audio_video_call (caps,
@@ -935,17 +759,12 @@ test_supports_call (Test *test,
g_object_unref (caps);
/* A class with audio and video in allowed can do audio only */
- classes = g_ptr_array_sized_new (1);
- add_call_class (classes, TP_ENTITY_TYPE_CONTACT, TRUE, TRUE, TRUE, FALSE);
-
caps = tp_tests_object_new_static_class (TP_TYPE_CAPABILITIES,
- "channel-classes", classes,
+ "channel-classes", g_variant_new_parsed ("[%*]",
+ call_class (TP_ENTITY_TYPE_CONTACT, TRUE, TRUE, TRUE, FALSE)),
"contact-specific", FALSE,
NULL);
- g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
- classes);
-
g_assert (tp_capabilities_supports_audio_call (caps,
TP_ENTITY_TYPE_CONTACT));
g_assert (tp_capabilities_supports_audio_video_call (caps,
@@ -954,17 +773,12 @@ test_supports_call (Test *test,
g_object_unref (caps);
/* A class with unknown extra fixed can't do anything */
- classes = g_ptr_array_sized_new (1);
- add_call_class (classes, TP_ENTITY_TYPE_CONTACT, TRUE, TRUE, TRUE, TRUE);
-
caps = tp_tests_object_new_static_class (TP_TYPE_CAPABILITIES,
- "channel-classes", classes,
+ "channel-classes", g_variant_new_parsed ("[%*]",
+ call_class (TP_ENTITY_TYPE_CONTACT, TRUE, TRUE, TRUE, TRUE)),
"contact-specific", FALSE,
NULL);
- g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
- classes);
-
g_assert (!tp_capabilities_supports_audio_call (caps,
TP_ENTITY_TYPE_CONTACT));
g_assert (!tp_capabilities_supports_audio_video_call (caps,
@@ -978,7 +792,6 @@ test_supports_ft_props (Test *test,
gconstpointer data G_GNUC_UNUSED)
{
TpCapabilities *caps;
- GPtrArray *classes;
const gchar * const allow_uri[] = { TP_PROP_CHANNEL_TYPE_FILE_TRANSFER1_URI,
NULL };
const gchar * const allow_desc[] = {
@@ -999,17 +812,12 @@ test_supports_ft_props (Test *test,
g_object_unref (caps);
- classes = g_ptr_array_sized_new (1);
- add_ft_class (classes, NULL);
-
caps = tp_tests_object_new_static_class (TP_TYPE_CAPABILITIES,
- "channel-classes", classes,
+ "channel-classes", g_variant_new_parsed ("[%*]",
+ ft_class (NULL)),
"contact-specific", TRUE,
NULL);
- g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
- classes);
-
g_assert (tp_capabilities_supports_file_transfer (caps));
g_assert (!tp_capabilities_supports_file_transfer_uri (caps));
g_assert (!tp_capabilities_supports_file_transfer_description (caps));
@@ -1018,17 +826,12 @@ test_supports_ft_props (Test *test,
g_object_unref (caps);
- classes = g_ptr_array_sized_new (1);
- add_ft_class (classes, allow_uri);
-
caps = tp_tests_object_new_static_class (TP_TYPE_CAPABILITIES,
- "channel-classes", classes,
+ "channel-classes", g_variant_new_parsed ("[%*]",
+ ft_class (allow_uri)),
"contact-specific", TRUE,
NULL);
- g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
- classes);
-
g_assert (tp_capabilities_supports_file_transfer (caps));
g_assert (tp_capabilities_supports_file_transfer_uri (caps));
g_assert (!tp_capabilities_supports_file_transfer_description (caps));
@@ -1037,17 +840,12 @@ test_supports_ft_props (Test *test,
g_object_unref (caps);
- classes = g_ptr_array_sized_new (1);
- add_ft_class (classes, allow_desc);
-
caps = tp_tests_object_new_static_class (TP_TYPE_CAPABILITIES,
- "channel-classes", classes,
+ "channel-classes", g_variant_new_parsed ("[%*]",
+ ft_class (allow_desc)),
"contact-specific", TRUE,
NULL);
- g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
- classes);
-
g_assert (tp_capabilities_supports_file_transfer (caps));
g_assert (!tp_capabilities_supports_file_transfer_uri (caps));
g_assert (tp_capabilities_supports_file_transfer_description (caps));
@@ -1056,17 +854,12 @@ test_supports_ft_props (Test *test,
g_object_unref (caps);
- classes = g_ptr_array_sized_new (1);
- add_ft_class (classes, allow_date);
-
caps = tp_tests_object_new_static_class (TP_TYPE_CAPABILITIES,
- "channel-classes", classes,
+ "channel-classes", g_variant_new_parsed ("[%*]",
+ ft_class (allow_date)),
"contact-specific", TRUE,
NULL);
- g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
- classes);
-
g_assert (tp_capabilities_supports_file_transfer (caps));
g_assert (!tp_capabilities_supports_file_transfer_uri (caps));
g_assert (!tp_capabilities_supports_file_transfer_description (caps));
@@ -1075,17 +868,12 @@ test_supports_ft_props (Test *test,
g_object_unref (caps);
- classes = g_ptr_array_sized_new (1);
- add_ft_class (classes, allow_initial_offset);
-
caps = tp_tests_object_new_static_class (TP_TYPE_CAPABILITIES,
- "channel-classes", classes,
+ "channel-classes", g_variant_new_parsed ("[%*]",
+ ft_class (allow_initial_offset)),
"contact-specific", TRUE,
NULL);
- g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
- classes);
-
g_assert (tp_capabilities_supports_file_transfer (caps));
g_assert (!tp_capabilities_supports_file_transfer_uri (caps));
g_assert (!tp_capabilities_supports_file_transfer_description (caps));
@@ -1100,26 +888,20 @@ test_classes_variant (Test *test,
gconstpointer data G_GNUC_UNUSED)
{
TpCapabilities *caps;
- GPtrArray *classes;
GVariant *v, *v2, *class, *fixed, *allowed;
const gchar *chan_type;
guint32 handle_type;
const gchar **strv;
/* TpCapabilities containing the text chats and ft caps */
- classes = g_ptr_array_sized_new (2);
- add_text_chat_class (classes, TP_ENTITY_TYPE_CONTACT);
- add_ft_class (classes, NULL);
-
caps = tp_tests_object_new_static_class (TP_TYPE_CAPABILITIES,
- "channel-classes", classes,
+ "channel-classes", g_variant_new_parsed ("[%*, %*]",
+ text_chat_class (TP_ENTITY_TYPE_CONTACT),
+ ft_class (NULL)),
"contact-specific", FALSE,
NULL);
- g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
- classes);
-
- v = tp_capabilities_dup_channel_classes_variant (caps);
+ v = tp_capabilities_dup_channel_classes (caps);
g_assert (v != NULL);
g_assert_cmpstr (g_variant_get_type_string (v), ==, "a(a{sv}as)");
@@ -1181,7 +963,7 @@ test_classes_variant (Test *test,
g_variant_unref (allowed);
/* Test GObject getter */
- g_object_get (caps, "channel-classes-variant", &v2, NULL);
+ g_object_get (caps, "channel-classes", &v2, NULL);
g_assert (g_variant_equal (v, v2));
g_variant_unref (v);
diff --git a/tests/dbus/connection.c b/tests/dbus/connection.c
index 771c59592..c8aaef4d9 100644
--- a/tests/dbus/connection.c
+++ b/tests/dbus/connection.c
@@ -115,7 +115,7 @@ test_prepare (Test *test,
TP_CONNECTION_FEATURE_CAPABILITIES, 0 };
TpConnectionStatusReason reason;
TpCapabilities *caps;
- GPtrArray *classes;
+ GVariant *classes;
gchar *cm_name, *protocol_name;
test->conn = tp_tests_connection_new (test->dbus, test->conn_name, test->conn_path,
@@ -187,9 +187,10 @@ test_prepare (Test *test,
caps = tp_connection_get_capabilities (test->conn);
g_assert (caps != NULL);
- classes = tp_capabilities_get_channel_classes (caps);
- g_assert (classes != NULL);
- g_assert_cmpint (classes->len, ==, 0);
+ classes = tp_capabilities_dup_channel_classes (caps);
+ g_assert_cmpstr (g_variant_get_type_string (classes), ==, "a(a{sv}as)");
+ g_assert_cmpuint (g_variant_n_children (classes), ==, 0);
+ g_variant_unref (classes);
}
static void
diff --git a/tests/dbus/text-respawn.c b/tests/dbus/text-respawn.c
index 8cc09d729..042e90943 100644
--- a/tests/dbus/text-respawn.c
+++ b/tests/dbus/text-respawn.c
@@ -155,7 +155,7 @@ test (Fixture *f,
TpHandle handle;
GPtrArray *message;
TpCapabilities *caps;
- GPtrArray *classes;
+ GVariant *classes;
GQuark conn_features[] = { TP_CONNECTION_FEATURE_CAPABILITIES, 0 };
GTestDBus *test_dbus;
@@ -200,9 +200,10 @@ test (Fixture *f,
caps = tp_connection_get_capabilities (conn);
g_assert (caps != NULL);
- classes = tp_capabilities_get_channel_classes (caps);
+ classes = tp_capabilities_dup_channel_classes (caps);
g_assert (classes != NULL);
- g_assert_cmpint (classes->len, ==, 1);
+ g_assert_cmpuint (g_variant_n_children (classes), ==, 1);
+ g_variant_unref (classes);
g_assert (tp_capabilities_supports_text_chats (caps));
MYASSERT (tp_cli_channel_type_text_connect_to_message_received (chan, on_received,