From 9b7c9836b29a7df4500496e888e1af964376520a Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 17 Sep 2014 19:21:09 +0100 Subject: [PATCH] Adapt to tp-glib: fill channel properties in terms of GVariant, redo TpCMParamSpec as objects --- src/ft-channel.c | 6 +- src/im-channel.c | 4 +- src/muc-channel.c | 4 +- src/protocol.c | 334 +++++++++++++++++++++++++--------------------- src/roomlist-channel.c | 4 +- src/search-channel.c | 4 +- src/server-sasl-channel.c | 4 +- src/server-tls-channel.c | 4 +- src/tube-dbus.c | 6 +- src/tube-stream.c | 6 +- src/write-mgr-file.c | 83 ++++++++---- 11 files changed, 259 insertions(+), 200 deletions(-) diff --git a/src/ft-channel.c b/src/ft-channel.c index 6ca4e2b..df10ac6 100644 --- a/src/ft-channel.c +++ b/src/ft-channel.c @@ -498,14 +498,14 @@ file_transfer_channel_properties_setter (GObject *object, static void gabble_file_transfer_channel_fill_immutable_properties (TpBaseChannel *chan, - GHashTable *properties) + GVariantDict *properties) { TpBaseChannelClass *cls = TP_BASE_CHANNEL_CLASS ( gabble_file_transfer_channel_parent_class); cls->fill_immutable_properties (chan, properties); - tp_dbus_properties_mixin_fill_properties_hash ( + tp_dbus_properties_mixin_fill_properties ( G_OBJECT (chan), properties, TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER1, "State", TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER1, "ContentType", @@ -526,7 +526,7 @@ gabble_file_transfer_channel_fill_immutable_properties (TpBaseChannel *chan, /* URI is immutable only for outgoing transfers */ if (tp_base_channel_is_requested (chan)) { - tp_dbus_properties_mixin_fill_properties_hash (G_OBJECT (chan), properties, + tp_dbus_properties_mixin_fill_properties (G_OBJECT (chan), properties, TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER1, "URI", NULL); } } diff --git a/src/im-channel.c b/src/im-channel.c index 45871a1..f2a1067 100644 --- a/src/im-channel.c +++ b/src/im-channel.c @@ -161,14 +161,14 @@ static void gabble_im_channel_finalize (GObject *object); static void gabble_im_channel_fill_immutable_properties (TpBaseChannel *chan, - GHashTable *properties) + GVariantDict *properties) { TpBaseChannelClass *cls = TP_BASE_CHANNEL_CLASS ( gabble_im_channel_parent_class); cls->fill_immutable_properties (chan, properties); - tp_dbus_properties_mixin_fill_properties_hash ( + tp_dbus_properties_mixin_fill_properties ( G_OBJECT (chan), properties, TP_IFACE_CHANNEL_TYPE_TEXT, "MessagePartSupportFlags", TP_IFACE_CHANNEL_TYPE_TEXT, "DeliveryReportingSupport", diff --git a/src/muc-channel.c b/src/muc-channel.c index e465888..ee81ee3 100644 --- a/src/muc-channel.c +++ b/src/muc-channel.c @@ -1024,12 +1024,12 @@ static gboolean gabble_muc_channel_remove_member (GObject *obj, static void gabble_muc_channel_fill_immutable_properties ( TpBaseChannel *chan, - GHashTable *properties) + GVariantDict *properties) { TP_BASE_CHANNEL_CLASS (gabble_muc_channel_parent_class)->fill_immutable_properties ( chan, properties); - tp_dbus_properties_mixin_fill_properties_hash ( + tp_dbus_properties_mixin_fill_properties ( G_OBJECT (chan), properties, TP_IFACE_CHANNEL_INTERFACE_CONFERENCE1, "InitialChannels", TP_IFACE_CHANNEL_INTERFACE_CONFERENCE1, "InitialInviteeHandles", diff --git a/src/protocol.c b/src/protocol.c index 277f34b..f7dc460 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -50,6 +50,11 @@ #define VCARD_FIELD_NAME "x-" PROTOCOL_NAME #define ENGLISH_NAME "Jabber" +struct _GabbleJabberProtocolPrivate +{ + GPtrArray *params; +}; + static void addressing_iface_init (TpProtocolAddressingInterface *iface); G_DEFINE_TYPE_WITH_CODE (GabbleJabberProtocol, gabble_jabber_protocol, @@ -57,169 +62,179 @@ G_DEFINE_TYPE_WITH_CODE (GabbleJabberProtocol, gabble_jabber_protocol, G_IMPLEMENT_INTERFACE (TP_TYPE_PROTOCOL_ADDRESSING, addressing_iface_init); ) -static TpCMParamSpec jabber_params[] = { - { "account", DBUS_TYPE_STRING_AS_STRING, G_TYPE_STRING, - TP_CONN_MGR_PARAM_FLAG_REQUIRED | TP_CONN_MGR_PARAM_FLAG_REGISTER, NULL, - 0 /* unused */, - /* FIXME: validate the JID according to the RFC */ - tp_cm_param_filter_string_nonempty, NULL }, - { "password", DBUS_TYPE_STRING_AS_STRING, G_TYPE_STRING, - TP_CONN_MGR_PARAM_FLAG_REGISTER | TP_CONN_MGR_PARAM_FLAG_SECRET, - NULL, 0 /* unused */, NULL, NULL }, - - { "server", DBUS_TYPE_STRING_AS_STRING, G_TYPE_STRING, 0, NULL, - 0 /* unused */, - /* FIXME: validate the server properly */ - tp_cm_param_filter_string_nonempty, NULL }, - - { "resource", DBUS_TYPE_STRING_AS_STRING, G_TYPE_STRING, 0, NULL, - 0 /* unused */, - /* FIXME: validate the resource according to the RFC */ - tp_cm_param_filter_string_nonempty, NULL }, - - { "priority", DBUS_TYPE_INT16_AS_STRING, G_TYPE_INT, - TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, GINT_TO_POINTER(0), - 0 /* unused */, NULL, NULL }, - - { "port", DBUS_TYPE_UINT16_AS_STRING, G_TYPE_UINT, - TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, GUINT_TO_POINTER(5222), - 0 /* unused */, - tp_cm_param_filter_uint_nonzero, NULL }, - - { "old-ssl", DBUS_TYPE_BOOLEAN_AS_STRING, G_TYPE_BOOLEAN, - TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, GINT_TO_POINTER(FALSE), - 0 /* unused */, NULL, NULL }, - - { "require-encryption", DBUS_TYPE_BOOLEAN_AS_STRING, G_TYPE_BOOLEAN, - TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, GINT_TO_POINTER(TRUE), - 0 /* unused */, NULL, NULL }, - - { "register", DBUS_TYPE_BOOLEAN_AS_STRING, G_TYPE_BOOLEAN, - TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, GINT_TO_POINTER(FALSE), - 0 /* unused */, NULL, NULL }, - - { "low-bandwidth", DBUS_TYPE_BOOLEAN_AS_STRING, G_TYPE_BOOLEAN, - TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, GINT_TO_POINTER(FALSE), - 0 /* unused */, NULL, NULL }, - - { "https-proxy-server", DBUS_TYPE_STRING_AS_STRING, G_TYPE_STRING, 0, NULL, - 0 /* unused */, - /* FIXME: validate properly */ - tp_cm_param_filter_string_nonempty, NULL }, - - { "https-proxy-port", DBUS_TYPE_UINT16_AS_STRING, G_TYPE_UINT, - TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, - GUINT_TO_POINTER(GABBLE_PARAMS_DEFAULT_HTTPS_PROXY_PORT), - 0 /* unused */, - tp_cm_param_filter_uint_nonzero, NULL }, - - { "fallback-conference-server", DBUS_TYPE_STRING_AS_STRING, G_TYPE_STRING, - TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, - "conference.telepathy.im", - 0 /* offset, not used */, - /* FIXME: validate properly */ - tp_cm_param_filter_string_nonempty, NULL }, - - { "stun-server", DBUS_TYPE_STRING_AS_STRING, G_TYPE_STRING, 0, NULL, - 0 /* unused */, - /* FIXME: validate properly */ - tp_cm_param_filter_string_nonempty, NULL }, - - { "stun-port", DBUS_TYPE_UINT16_AS_STRING, G_TYPE_UINT, - TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, - GUINT_TO_POINTER(GABBLE_PARAMS_DEFAULT_STUN_PORT), - 0 /* unused */, - tp_cm_param_filter_uint_nonzero, NULL }, - - { "fallback-stun-server", DBUS_TYPE_STRING_AS_STRING, G_TYPE_STRING, - TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, - GABBLE_PARAMS_DEFAULT_FALLBACK_STUN_SERVER, - 0 /* unused */, - /* FIXME: validate properly */ - tp_cm_param_filter_string_nonempty, NULL }, - - { "fallback-stun-port", DBUS_TYPE_UINT16_AS_STRING, G_TYPE_UINT, - TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, - GUINT_TO_POINTER(GABBLE_PARAMS_DEFAULT_STUN_PORT), - 0 /* unused */, - tp_cm_param_filter_uint_nonzero, NULL }, - - { "ignore-ssl-errors", DBUS_TYPE_BOOLEAN_AS_STRING, G_TYPE_BOOLEAN, - TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, GINT_TO_POINTER(FALSE), - 0 /* unused */, NULL, NULL }, - - { "alias", DBUS_TYPE_STRING_AS_STRING, G_TYPE_STRING, 0, NULL, - 0 /* unused */, - /* setting a 0-length alias makes no sense */ - tp_cm_param_filter_string_nonempty, NULL }, - - { "fallback-socks5-proxies", "as", 0, - TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, NULL, - 0 /* unused */, - NULL, NULL }, - - { "keepalive-interval", "u", G_TYPE_UINT, - TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, GUINT_TO_POINTER (30), - 0 /* unused */, NULL, NULL }, - - { TP_PROP_CONNECTION_INTERFACE_CONTACT_LIST1_DOWNLOAD_AT_CONNECTION, - DBUS_TYPE_BOOLEAN_AS_STRING, G_TYPE_BOOLEAN, - TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT | TP_CONN_MGR_PARAM_FLAG_DBUS_PROPERTY, - GUINT_TO_POINTER (TRUE), - 0 /* unused */, NULL, NULL }, - - { "fallback-servers", "as", 0, - 0, NULL, 0 /* unused */, NULL, NULL }, - - { "extra-certificate-identities", "as", 0, - 0, NULL, 0 /* unused */, NULL, NULL }, - - { "account-path-suffix", "s", G_TYPE_STRING, - 0, NULL, 0 /* unused */, NULL, NULL }, - - { NULL, NULL, 0, 0, NULL, 0 } -}; - static const gchar *default_socks5_proxies[] = GABBLE_PARAMS_DEFAULT_SOCKS5_PROXIES; static void gabble_jabber_protocol_init (GabbleJabberProtocol *self) { + self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GABBLE_TYPE_JABBER_PROTOCOL, + GabbleJabberProtocolPrivate); } -static const TpCMParamSpec * -get_parameters (TpBaseProtocol *self G_GNUC_UNUSED) +static GPtrArray * +dup_parameters (TpBaseProtocol *base) { - static gsize init_value = 0; + GabbleJabberProtocol *self = GABBLE_JABBER_PROTOCOL (base); - if (g_once_init_enter (&init_value)) + if (self->priv->params == NULL) { - guint i; - - for (i = 0; jabber_params[i].name != NULL; i++) - { - if (!g_strcmp0 (jabber_params[i].name, - "fallback-socks5-proxies")) - { - jabber_params[i].gtype = G_TYPE_STRV; - jabber_params[i].def = default_socks5_proxies; - } - else if (!g_strcmp0 (jabber_params[i].name, - "fallback-servers")) - { - jabber_params[i].gtype = G_TYPE_STRV; - } - else if (!g_strcmp0 (jabber_params[i].name, - "extra-certificate-identities")) - { - jabber_params[i].gtype = G_TYPE_STRV; - } - } - - g_once_init_leave (&init_value, 1); + const gchar *none[] = { NULL }; + + self->priv->params = g_ptr_array_new_full (25, + (GDestroyNotify) tp_cm_param_spec_unref); + + g_ptr_array_add (self->priv->params, + tp_cm_param_spec_new ("account", + TP_CONN_MGR_PARAM_FLAG_REQUIRED | TP_CONN_MGR_PARAM_FLAG_REGISTER, + g_variant_new_string (""), + /* FIXME: validate the JID according to the RFC */ + tp_cm_param_filter_string_nonempty, NULL, NULL)); + + g_ptr_array_add (self->priv->params, + tp_cm_param_spec_new ("password", + TP_CONN_MGR_PARAM_FLAG_REGISTER | TP_CONN_MGR_PARAM_FLAG_SECRET, + g_variant_new_string (""), + NULL, NULL, NULL)); + + g_ptr_array_add (self->priv->params, + tp_cm_param_spec_new ("server", 0, g_variant_new_string (""), + /* FIXME: validate the server properly */ + NULL, NULL, NULL)); + + g_ptr_array_add (self->priv->params, + tp_cm_param_spec_new ("resource", 0, g_variant_new_string (""), + /* FIXME: validate the resource according to the RFC */ + tp_cm_param_filter_string_nonempty, NULL, NULL)); + + g_ptr_array_add (self->priv->params, + tp_cm_param_spec_new ("priority", + TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, + g_variant_new_int32 (0), + NULL, NULL, NULL)); + + g_ptr_array_add (self->priv->params, + tp_cm_param_spec_new ("port", + TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, + g_variant_new_uint32 (5222), + NULL, NULL, NULL)); + + g_ptr_array_add (self->priv->params, + tp_cm_param_spec_new ("old-ssl", + TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, + g_variant_new_boolean (FALSE), + NULL, NULL, NULL)); + + g_ptr_array_add (self->priv->params, + tp_cm_param_spec_new ("require-encryption", + TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, + g_variant_new_boolean (TRUE), + NULL, NULL, NULL)); + + g_ptr_array_add (self->priv->params, + tp_cm_param_spec_new ("register", + TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, + g_variant_new_boolean (FALSE), + NULL, NULL, NULL)); + + g_ptr_array_add (self->priv->params, + tp_cm_param_spec_new ("low-bandwidth", + TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, + g_variant_new_boolean (FALSE), + NULL, NULL, NULL)); + + g_ptr_array_add (self->priv->params, + tp_cm_param_spec_new ("https-proxy-server", + 0, g_variant_new_string (""), + /* FIXME: validate properly */ + tp_cm_param_filter_string_nonempty, NULL, NULL)); + + g_ptr_array_add (self->priv->params, + tp_cm_param_spec_new ("https-proxy-port", + TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, + g_variant_new_uint32 (GABBLE_PARAMS_DEFAULT_HTTPS_PROXY_PORT), + tp_cm_param_filter_uint_nonzero, NULL, NULL)); + + g_ptr_array_add (self->priv->params, + tp_cm_param_spec_new ("fallback-conference-server", + TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, + g_variant_new_string ("conference.telepathy.im"), + /* FIXME: validate properly */ + tp_cm_param_filter_string_nonempty, NULL, NULL)); + + g_ptr_array_add (self->priv->params, + tp_cm_param_spec_new ("stun-server", + 0, g_variant_new_string (""), + /* FIXME: validate properly */ + tp_cm_param_filter_string_nonempty, NULL, NULL)); + + g_ptr_array_add (self->priv->params, + tp_cm_param_spec_new ("stun-port", + TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, + g_variant_new_uint32 (GABBLE_PARAMS_DEFAULT_STUN_PORT), + tp_cm_param_filter_uint_nonzero, NULL, NULL)); + + g_ptr_array_add (self->priv->params, + tp_cm_param_spec_new ("fallback-stun-server", + TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, + g_variant_new_string (GABBLE_PARAMS_DEFAULT_FALLBACK_STUN_SERVER), + /* FIXME: validate properly */ + tp_cm_param_filter_string_nonempty, NULL, NULL)); + + g_ptr_array_add (self->priv->params, + tp_cm_param_spec_new ("fallback-stun-port", + TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, + g_variant_new_uint32 (GABBLE_PARAMS_DEFAULT_STUN_PORT), + tp_cm_param_filter_uint_nonzero, NULL, NULL)); + + g_ptr_array_add (self->priv->params, + tp_cm_param_spec_new ("ignore-ssl-errors", + TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, + g_variant_new_boolean (FALSE), + NULL, NULL, NULL)); + + g_ptr_array_add (self->priv->params, + tp_cm_param_spec_new ("alias", 0, + g_variant_new_string (""), + /* setting a 0-length alias makes no sense */ + tp_cm_param_filter_string_nonempty, NULL, NULL)); + + g_ptr_array_add (self->priv->params, + tp_cm_param_spec_new ("fallback-socks5-proxies", + TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, + g_variant_new_strv (default_socks5_proxies, -1), + NULL, NULL, NULL)); + + g_ptr_array_add (self->priv->params, + tp_cm_param_spec_new ("keepalive-interval", + TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, + g_variant_new_uint32 (30), + NULL, NULL, NULL)); + + g_ptr_array_add (self->priv->params, + tp_cm_param_spec_new ( + TP_PROP_CONNECTION_INTERFACE_CONTACT_LIST1_DOWNLOAD_AT_CONNECTION, + TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT | + TP_CONN_MGR_PARAM_FLAG_DBUS_PROPERTY, + g_variant_new_boolean (TRUE), + NULL, NULL, NULL)); + + g_ptr_array_add (self->priv->params, + tp_cm_param_spec_new ("fallback-servers", + 0, g_variant_new_strv (none, 0), + NULL, NULL, NULL)); + + g_ptr_array_add (self->priv->params, + tp_cm_param_spec_new ("extra-certificate-identities", + 0, g_variant_new_strv (none, 0), + NULL, NULL, NULL)); + + g_ptr_array_add (self->priv->params, + tp_cm_param_spec_new ("account-path-suffix", + 0, g_variant_new_string (""), + NULL, NULL, NULL)); } - return jabber_params; + return g_ptr_array_ref (self->priv->params); } #define MAP(x,y) { x, y } @@ -454,12 +469,27 @@ get_avatar_details (TpBaseProtocol *base, } static void +finalize (GObject *object) +{ + GabbleJabberProtocol *self = GABBLE_JABBER_PROTOCOL (object); + + g_clear_pointer (&self->priv->params, g_ptr_array_unref); + + G_OBJECT_CLASS (gabble_jabber_protocol_parent_class)->finalize (object); +} + +static void gabble_jabber_protocol_class_init (GabbleJabberProtocolClass *klass) { + GObjectClass *oclass = (GObjectClass *) klass; TpBaseProtocolClass *base_class = (TpBaseProtocolClass *) klass; - base_class->get_parameters = get_parameters; + g_type_class_add_private (klass, sizeof (GabbleJabberProtocolPrivate)); + + oclass->finalize = finalize; + + base_class->dup_parameters = dup_parameters; base_class->new_connection = new_connection; base_class->normalize_contact = normalize_contact; base_class->identify_account = identify_account; diff --git a/src/roomlist-channel.c b/src/roomlist-channel.c index 2686148..c2c0106 100644 --- a/src/roomlist-channel.c +++ b/src/roomlist-channel.c @@ -146,12 +146,12 @@ static void gabble_roomlist_channel_finalize (GObject *object); static void gabble_roomlist_channel_fill_immutable_properties ( TpBaseChannel *chan, - GHashTable *properties) + GVariantDict *properties) { TP_BASE_CHANNEL_CLASS (gabble_roomlist_channel_parent_class)->fill_immutable_properties ( chan, properties); - tp_dbus_properties_mixin_fill_properties_hash ( + tp_dbus_properties_mixin_fill_properties ( G_OBJECT (chan), properties, TP_IFACE_CHANNEL_TYPE_ROOM_LIST1, "Server", NULL); diff --git a/src/search-channel.c b/src/search-channel.c index b322d5c..887da96 100644 --- a/src/search-channel.c +++ b/src/search-channel.c @@ -1090,12 +1090,12 @@ gabble_search_channel_set_property (GObject *object, static void gabble_search_channel_fill_immutable_properties ( TpBaseChannel *chan, - GHashTable *properties) + GVariantDict *properties) { TP_BASE_CHANNEL_CLASS (gabble_search_channel_parent_class)->fill_immutable_properties ( chan, properties); - tp_dbus_properties_mixin_fill_properties_hash ( + tp_dbus_properties_mixin_fill_properties ( G_OBJECT (chan), properties, TP_IFACE_CHANNEL_TYPE_CONTACT_SEARCH1, "AvailableSearchKeys", TP_IFACE_CHANNEL_TYPE_CONTACT_SEARCH1, "Server", diff --git a/src/server-sasl-channel.c b/src/server-sasl-channel.c index 67a1fa3..cacd25e 100644 --- a/src/server-sasl-channel.c +++ b/src/server-sasl-channel.c @@ -129,12 +129,12 @@ gabble_server_sasl_channel_init (GabbleServerSaslChannel *self) static void gabble_server_sasl_channel_fill_immutable_properties (TpBaseChannel *channel, - GHashTable *properties) + GVariantDict *properties) { TP_BASE_CHANNEL_CLASS (gabble_server_sasl_channel_parent_class) ->fill_immutable_properties (channel, properties); - tp_dbus_properties_mixin_fill_properties_hash (G_OBJECT (channel), + tp_dbus_properties_mixin_fill_properties (G_OBJECT (channel), properties, TP_IFACE_CHANNEL_TYPE_SERVER_AUTHENTICATION1, "AuthenticationMethod", TP_IFACE_CHANNEL_INTERFACE_SASL_AUTHENTICATION1, diff --git a/src/server-tls-channel.c b/src/server-tls-channel.c index 4cd5fcc..72265ff 100644 --- a/src/server-tls-channel.c +++ b/src/server-tls-channel.c @@ -205,12 +205,12 @@ gabble_server_tls_channel_constructed (GObject *object) static void gabble_server_tls_channel_fill_immutable_properties ( TpBaseChannel *chan, - GHashTable *properties) + GVariantDict *properties) { TP_BASE_CHANNEL_CLASS (gabble_server_tls_channel_parent_class) ->fill_immutable_properties (chan, properties); - tp_dbus_properties_mixin_fill_properties_hash ( + tp_dbus_properties_mixin_fill_properties ( G_OBJECT (chan), properties, TP_IFACE_CHANNEL_TYPE_SERVER_TLS_CONNECTION1, "ServerCertificate", TP_IFACE_CHANNEL_TYPE_SERVER_TLS_CONNECTION1, "Hostname", diff --git a/src/tube-dbus.c b/src/tube-dbus.c index daf7034..cd2f2de 100644 --- a/src/tube-dbus.c +++ b/src/tube-dbus.c @@ -809,14 +809,14 @@ gabble_tube_dbus_constructed (GObject *obj) static void gabble_tube_dbus_fill_immutable_properties (TpBaseChannel *chan, - GHashTable *properties) + GVariantDict *properties) { TpBaseChannelClass *cls = TP_BASE_CHANNEL_CLASS ( gabble_tube_dbus_parent_class); cls->fill_immutable_properties (chan, properties); - tp_dbus_properties_mixin_fill_properties_hash ( + tp_dbus_properties_mixin_fill_properties ( G_OBJECT (chan), properties, TP_IFACE_CHANNEL_TYPE_DBUS_TUBE1, "ServiceName", TP_IFACE_CHANNEL_TYPE_DBUS_TUBE1, "SupportedAccessControls", @@ -824,7 +824,7 @@ gabble_tube_dbus_fill_immutable_properties (TpBaseChannel *chan, if (!tp_base_channel_is_requested (chan)) { - tp_dbus_properties_mixin_fill_properties_hash ( + tp_dbus_properties_mixin_fill_properties ( G_OBJECT (chan), properties, TP_IFACE_CHANNEL_INTERFACE_TUBE1, "Parameters", NULL); diff --git a/src/tube-stream.c b/src/tube-stream.c index d253baf..17e67cb 100644 --- a/src/tube-stream.c +++ b/src/tube-stream.c @@ -1374,14 +1374,14 @@ gabble_tube_stream_constructed (GObject *obj) static void gabble_tube_stream_fill_immutable_properties (TpBaseChannel *chan, - GHashTable *properties) + GVariantDict *properties) { TpBaseChannelClass *cls = TP_BASE_CHANNEL_CLASS ( gabble_tube_stream_parent_class); cls->fill_immutable_properties (chan, properties); - tp_dbus_properties_mixin_fill_properties_hash ( + tp_dbus_properties_mixin_fill_properties ( G_OBJECT (chan), properties, TP_IFACE_CHANNEL_TYPE_STREAM_TUBE1, "Service", TP_IFACE_CHANNEL_TYPE_STREAM_TUBE1, "SupportedSocketTypes", @@ -1389,7 +1389,7 @@ gabble_tube_stream_fill_immutable_properties (TpBaseChannel *chan, if (!tp_base_channel_is_requested (chan)) { - tp_dbus_properties_mixin_fill_properties_hash ( + tp_dbus_properties_mixin_fill_properties ( G_OBJECT (chan), properties, TP_IFACE_CHANNEL_INTERFACE_TUBE1, "Parameters", NULL); diff --git a/src/write-mgr-file.c b/src/write-mgr-file.c index e8e863b..614b674 100644 --- a/src/write-mgr-file.c +++ b/src/write-mgr-file.c @@ -42,56 +42,81 @@ static void write_parameters (GKeyFile *f, gchar *section_name, TpBaseProtocol *protocol) { - const TpCMParamSpec *parameters = - tp_base_protocol_get_parameters (protocol); - const TpCMParamSpec *row; + GPtrArray *parameters = tp_base_protocol_dup_parameters (protocol); + guint i; + + g_assert (parameters != NULL); - for (row = parameters; row->name; row++) + for (i = 0; i < parameters->len; i++) { - gchar *param_name = g_strdup_printf ("param-%s", row->name); - gchar *param_value = g_strdup_printf ("%s%s%s%s", row->dtype, - (row->flags & TP_CONN_MGR_PARAM_FLAG_REQUIRED ? " required" : ""), - (row->flags & TP_CONN_MGR_PARAM_FLAG_REGISTER ? " register" : ""), - (row->flags & TP_CONN_MGR_PARAM_FLAG_SECRET ? " secret" : "")); + TpCMParamSpec *spec = g_ptr_array_index (parameters, i); + + gchar *param_name = g_strdup_printf ("param-%s", spec->name); + gchar *param_value = g_strdup_printf ("%s%s%s%s", spec->dtype, + (spec->flags & TP_CONN_MGR_PARAM_FLAG_REQUIRED ? " required" : ""), + (spec->flags & TP_CONN_MGR_PARAM_FLAG_REGISTER ? " register" : ""), + (spec->flags & TP_CONN_MGR_PARAM_FLAG_SECRET ? " secret" : "")); g_key_file_set_string (f, section_name, param_name, param_value); g_free (param_value); g_free (param_name); } - for (row = parameters; row->name; row++) + for (i = 0; i < parameters->len; i++) { - if (row->flags & TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT) + TpCMParamSpec *spec = g_ptr_array_index (parameters, i); + + if (spec->flags & TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT) { - gchar *default_name = g_strdup_printf ("default-%s", row->name); + gchar *default_name = g_strdup_printf ("default-%s", spec->name); - switch (row->gtype) + switch (spec->dtype[0]) { - case G_TYPE_STRING: + case 's': g_key_file_set_string (f, section_name, default_name, - row->def); + g_variant_get_string (spec->def, NULL)); + break; + + case 'i': + g_key_file_set_integer (f, section_name, default_name, + g_variant_get_int32 (spec->def)); break; - case G_TYPE_INT: - case G_TYPE_UINT: + + case 'u': g_key_file_set_integer (f, section_name, default_name, - GPOINTER_TO_INT(row->def)); + g_variant_get_uint32 (spec->def)); break; - case G_TYPE_BOOLEAN: + + case 'q': + g_key_file_set_integer (f, section_name, default_name, + g_variant_get_uint16 (spec->def)); + break; + + case 'n': + g_key_file_set_integer (f, section_name, default_name, + g_variant_get_int16 (spec->def)); + break; + + case 'b': g_key_file_set_boolean (f, section_name, default_name, - GPOINTER_TO_INT(row->def) ? 1 : 0); + g_variant_get_boolean (spec->def)); break; - default: - /* can't be in the case because G_TYPE_STRV is actually a - * function */ - if (row->gtype == G_TYPE_STRV) + + case 'a': + if (!tp_strdiff (spec->dtype, "as")) { + gsize n; + const gchar **strv = g_variant_get_strv (spec->def, &n); + g_key_file_set_string_list (f, section_name, default_name, - (const gchar **) row->def, - g_strv_length ((gchar **) row->def)); + strv, n); + g_free (strv); } } g_free (default_name); } } + + g_ptr_array_unref (parameters); } static void @@ -329,6 +354,7 @@ mgr_file_contents (const char *busname, GabbleJabberProtocol *protocol = protocols->data; gchar *section_name; GHashTable *props; + GVariant *props_variant; const gchar * const *ifaces; const gchar * const *c_ifaces; const gchar * const *addr_vcard_fields; @@ -337,9 +363,12 @@ mgr_file_contents (const char *busname, const gchar * const *mime_types; g_object_get (G_OBJECT (protocol), - "immutable-properties", &props, + "immutable-properties", &props_variant, NULL); + props = tp_asv_from_vardict (props_variant); + g_variant_unref (props_variant); + section_name = g_strdup_printf ("Protocol %s", tp_base_protocol_get_name (TP_BASE_PROTOCOL (protocol))); -- 2.1.0