Commit 6d577b4f authored by Simon McVittie's avatar Simon McVittie

Use non-deprecated GValueArray functions

This works around GValueArray being deprecated in GLib, but still part
of dbus-glib-derived APIs.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=26609Reviewed-by: Guillaume Desmottes's avatarGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
parent 1aeffdb7
......@@ -228,7 +228,7 @@ PKG_CHECK_MODULES(GLIB,
[glib-2.0 >= 2.32, gobject-2.0, gthread-2.0, gio-2.0])
PKG_CHECK_MODULES(GMODULE, [gmodule-2.0 >= 2.32])
AC_DEFINE(GLIB_VERSION_MIN_REQUIRED, GLIB_VERSION_2_30, [Ignore post 2.30 deprecations])
AC_DEFINE(GLIB_VERSION_MIN_REQUIRED, GLIB_VERSION_2_32, [Ignore post 2.32 deprecations])
AC_DEFINE(GLIB_VERSION_MAX_ALLOWED, GLIB_VERSION_2_32, [Prevent post 2.32 APIs])
AC_SUBST(GLIB_CFLAGS)
......
......@@ -101,7 +101,7 @@ get_stun_servers (GabbleCallStream *self)
WockyJingleFactory *jf;
GList *stun_servers;
arr = g_ptr_array_new_with_free_func ((GDestroyNotify) g_value_array_free);
arr = g_ptr_array_new_with_free_func ((GDestroyNotify) tp_value_array_free);
jf = wocky_jingle_session_get_factory (self->priv->content->session);
stun_servers = wocky_jingle_info_get_stun_servers (
wocky_jingle_factory_get_jingle_info (jf));
......
......@@ -439,28 +439,21 @@ conn_location_properties_getter (GObject *object,
}
else if (!tp_strdiff (g_quark_to_string (name), "LocationAccessControl"))
{
GValueArray *access_control = g_value_array_new (2);
GValue type = {0,};
GValue variant = {0,};
GValue *allocated_value;
/* G_TYPE_UINT is the D-Bus type of TpRichPresenceAccessControlType */
g_value_init (&type, G_TYPE_UINT);
g_value_set_uint (&type,
TP_RICH_PRESENCE_ACCESS_CONTROL_TYPE_PUBLISH_LIST);
g_value_array_append (access_control, &type);
g_value_unset (&type);
g_value_init (&variant, G_TYPE_VALUE);
GValueArray *access_control;
GValue dummy = G_VALUE_INIT;
/* For Publish_List, the variant isn't used, so we set a dummy value,
* (guint) 0 */
allocated_value = tp_g_value_slice_new (G_TYPE_UINT);
g_value_set_uint (allocated_value, 0);
g_value_set_boxed (&variant, allocated_value);
g_value_array_append (access_control, &variant);
g_value_unset (&variant);
tp_g_value_slice_free (allocated_value);
g_value_init (&dummy, G_TYPE_UINT);
g_value_set_uint (&dummy, 0);
access_control = tp_value_array_build (2,
G_TYPE_UINT,
(guint) TP_RICH_PRESENCE_ACCESS_CONTROL_TYPE_PUBLISH_LIST,
G_TYPE_VALUE, &dummy,
G_TYPE_INVALID);
g_value_unset (&dummy);
g_value_take_boxed (value, access_control);
}
else if (name == g_quark_from_static_string ("SupportedLocationFeatures"))
......@@ -486,9 +479,9 @@ conn_location_properties_setter (GObject *object,
gpointer setter_data,
GError **error)
{
GValueArray *access_control;
GValue *access_control_type_value;
TpRichPresenceAccessControlType access_control_type;
guint access_control_type;
GValue *access_control_argument;
g_return_val_if_fail (interface ==
TP_IFACE_QUARK_CONNECTION_INTERFACE_LOCATION, FALSE);
......@@ -496,17 +489,13 @@ conn_location_properties_setter (GObject *object,
* already checked this. */
g_assert (name == g_quark_from_static_string ("LocationAccessControl"));
access_control = g_value_get_boxed (value);
/* TpDBusPropertiesMixin already checked this */
g_assert (access_control->n_values == 2);
access_control_type_value = g_value_array_get_nth (access_control, 0);
/* TpDBusPropertiesMixin already checked this */
g_assert (G_VALUE_TYPE (access_control_type_value) == G_TYPE_UINT);
/* TpDBusPropertiesMixin already checked that it was a (uv). */
g_assert (G_VALUE_HOLDS (value,
TP_STRUCT_TYPE_RICH_PRESENCE_ACCESS_CONTROL));
access_control_type = g_value_get_uint (access_control_type_value);
tp_value_array_unpack (g_value_get_boxed (value), 2,
&access_control_type,
&access_control_argument);
if (access_control_type !=
TP_RICH_PRESENCE_ACCESS_CONTROL_TYPE_PUBLISH_LIST)
......
......@@ -123,7 +123,7 @@ return_from_request_inbox_url (GabbleConnection *conn)
if (error == NULL)
{
g_value_array_free (result);
tp_value_array_free (result);
g_ptr_array_unref (empty_array);
}
else
......@@ -214,7 +214,7 @@ gabble_mail_notification_request_mail_url (
tp_svc_connection_interface_mail_notification_return_from_request_mail_url (
context, result);
g_value_array_free (result);
tp_value_array_free (result);
g_ptr_array_unref (empty_array);
g_free (url);
}
......
......@@ -768,7 +768,6 @@ gabble_media_factory_get_contact_caps (GabbleCapsChannelManager *manager,
{
MediaCapabilities typeflags =
_gabble_media_factory_caps_to_typeflags (caps);
GValueArray *va;
const gchar * const *call_allowed;
typeflags &= (MEDIA_CAPABILITY_AUDIO |
......@@ -811,16 +810,11 @@ gabble_media_factory_get_contact_caps (GabbleCapsChannelManager *manager,
}
/* Call channel */
va = g_value_array_new (2);
g_value_array_append (va, NULL);
g_value_array_append (va, NULL);
g_value_init (va->values + 0, TP_HASH_TYPE_CHANNEL_CLASS);
g_value_init (va->values + 1, G_TYPE_STRV);
g_value_take_boxed (va->values + 0,
gabble_media_factory_call_channel_class ());
g_value_set_static_boxed (va->values + 1, call_allowed);
g_ptr_array_add (arr, va);
g_ptr_array_add (arr,
tp_value_array_build (2,
TP_HASH_TYPE_CHANNEL_CLASS, gabble_media_factory_call_channel_class (),
G_TYPE_STRV, call_allowed,
G_TYPE_INVALID));
}
static void
......
......@@ -519,26 +519,13 @@ static GValueArray *
make_field (const gchar *field_name,
gchar **values)
{
GValueArray *field = g_value_array_new (3);
GValue *value;
static const gchar **empty = { NULL };
g_value_array_append (field, NULL);
value = g_value_array_get_nth (field, 0);
g_value_init (value, G_TYPE_STRING);
g_value_set_static_string (value, field_name);
g_value_array_append (field, NULL);
value = g_value_array_get_nth (field, 1);
g_value_init (value, G_TYPE_STRV);
g_value_set_static_boxed (value, empty);
g_value_array_append (field, NULL);
value = g_value_array_get_nth (field, 2);
g_value_init (value, G_TYPE_STRV);
g_value_set_boxed (value, values);
return field;
return tp_value_array_build (3,
G_TYPE_STRING, field_name,
G_TYPE_STRV, empty,
G_TYPE_STRV, values,
G_TYPE_INVALID);
}
static gchar *
......
......@@ -556,7 +556,9 @@ gabble_server_tls_manager_get_rejection_details (GabbleServerTLSManager *self,
GabbleTLSCertificate *certificate;
GPtrArray *rejections;
GValueArray *rejection;
TpTLSCertificateRejectReason tls_reason;
guint tls_reason;
const gchar *dbus_error_tmp;
GHashTable *details_tmp;
/* We probably want the rejection details of last completed operation */
g_return_if_fail (self->priv->completed_channels != NULL);
......@@ -574,9 +576,13 @@ gabble_server_tls_manager_get_rejection_details (GabbleServerTLSManager *self,
rejection = g_ptr_array_index (rejections, 0);
tls_reason = g_value_get_uint (g_value_array_get_nth (rejection, 0));
*dbus_error = g_value_dup_string (g_value_array_get_nth (rejection, 1));
*details = g_value_dup_boxed (g_value_array_get_nth (rejection, 2));
tp_value_array_unpack (rejection, 3,
&tls_reason,
&dbus_error_tmp,
&details_tmp);
*dbus_error = g_strdup (dbus_error_tmp);
*details = g_boxed_copy (TP_HASH_TYPE_STRING_VARIANT_MAP, details_tmp);
*reason = cert_reject_reason_to_conn_reason (tls_reason);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment