From eb0e697d2936bc21d57c4c269540bda864e193e2 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 1 Nov 2013 14:38:38 +0000 Subject: [PATCH 3/5] Use non-deprecated GValueArray functions This works around GValueArray being deprecated in GLib, but still part of dbus-glib-derived APIs. --- configure.ac | 2 +- src/call-stream.c | 2 +- src/conn-location.c | 53 +++++++++++++++++++----------------------------- src/conn-mail-notif.c | 4 ++-- src/media-factory.c | 16 +++++---------- src/search-channel.c | 23 +++++---------------- src/server-tls-manager.c | 14 +++++++++---- 7 files changed, 45 insertions(+), 69 deletions(-) diff --git a/configure.ac b/configure.ac index aa8cc4d..ee589bc 100644 --- a/configure.ac +++ b/configure.ac @@ -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) diff --git a/src/call-stream.c b/src/call-stream.c index 1a28969..4653ff6 100644 --- a/src/call-stream.c +++ b/src/call-stream.c @@ -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)); diff --git a/src/conn-location.c b/src/conn-location.c index ae78d68..b511966 100644 --- a/src/conn-location.c +++ b/src/conn-location.c @@ -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) diff --git a/src/conn-mail-notif.c b/src/conn-mail-notif.c index 0bc7169..afefdf7 100644 --- a/src/conn-mail-notif.c +++ b/src/conn-mail-notif.c @@ -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); } diff --git a/src/media-factory.c b/src/media-factory.c index 6a86149..039f549 100644 --- a/src/media-factory.c +++ b/src/media-factory.c @@ -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 diff --git a/src/search-channel.c b/src/search-channel.c index 0c253ba..ab8a7d1 100644 --- a/src/search-channel.c +++ b/src/search-channel.c @@ -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 * diff --git a/src/server-tls-manager.c b/src/server-tls-manager.c index 4e961cd..6a23c99 100644 --- a/src/server-tls-manager.c +++ b/src/server-tls-manager.c @@ -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); -- 1.8.4.2