From 66a0d1d60e9b19946b1b27c0c2a3ff1f86179270 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Fri, 13 Sep 2013 12:09:34 +0200 Subject: [PATCH 2/2] use TP_SEAL_ENABLE https://bugs.freedesktop.org/show_bug.cgi?id=69311 --- configure.ac | 1 + src/idle-connection.c | 33 ++++++++++++++++++++++++--------- src/idle-im-manager.c | 4 ++-- src/idle-muc-channel.c | 22 ++++++++++++---------- src/idle-muc-manager.c | 5 +++-- src/protocol.c | 13 +++++++++---- 6 files changed, 51 insertions(+), 27 deletions(-) diff --git a/configure.ac b/configure.ac index c097609..3a73bf2 100644 --- a/configure.ac +++ b/configure.ac @@ -93,6 +93,7 @@ PKG_CHECK_MODULES([GLIB], PKG_CHECK_MODULES([DBUS], [dbus-1 >= 0.51, dbus-glib-1 >= 0.51]) +AC_DEFINE([TP_SEAL_ENABLE], [], [Prevent to use sealed variables]) AC_DEFINE([TP_DISABLE_SINGLE_INCLUDE], [], [Disable single header include]) AC_DEFINE(TP_VERSION_MIN_REQUIRED, TP_VERSION_0_22, [Ignore post 0.22 deprecations]) AC_DEFINE(TP_VERSION_MAX_ALLOWED, TP_VERSION_0_22, [Prevent post 0.22 APIs]) diff --git a/src/idle-connection.c b/src/idle-connection.c index 90536b5..6ab5fea 100644 --- a/src/idle-connection.c +++ b/src/idle-connection.c @@ -459,6 +459,21 @@ const gchar * const *idle_connection_get_implemented_interfaces (void) { return interfaces_always_present; } +static GPtrArray * +get_interfaces_always_present (TpBaseConnection *base) +{ + GPtrArray *interfaces; + const gchar **iter; + + interfaces = TP_BASE_CONNECTION_CLASS ( + idle_connection_parent_class)->get_interfaces_always_present (base); + + for (iter = interfaces_always_present; *iter != NULL; iter++) + g_ptr_array_add (interfaces, (gchar *) *iter); + + return interfaces; +} + static void idle_connection_class_init(IdleConnectionClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS(klass); TpBaseConnectionClass *parent_class = TP_BASE_CONNECTION_CLASS(klass); @@ -481,7 +496,7 @@ static void idle_connection_class_init(IdleConnectionClass *klass) { parent_class->disconnected = _iface_disconnected; parent_class->shut_down = _iface_shut_down; parent_class->start_connecting = _iface_start_connecting; - parent_class->interfaces_always_present = interfaces_always_present; + parent_class->get_interfaces_always_present = get_interfaces_always_present; param_spec = g_param_spec_string("nickname", "IRC nickname", "The nickname to be visible to others in IRC.", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); g_object_class_install_property(object_class, PROP_NICKNAME, param_spec); @@ -630,7 +645,7 @@ static void _iface_shut_down(TpBaseConnection *base) { } static void _connection_disconnect_with_gerror(IdleConnection *conn, TpConnectionStatusReason reason, const gchar *key, const GError *error) { - if (TP_BASE_CONNECTION (conn)->status == TP_CONNECTION_STATUS_DISCONNECTED) { + if (tp_base_connection_get_status (TP_BASE_CONNECTION (conn)) == TP_CONNECTION_STATUS_DISCONNECTED) { IDLE_DEBUG ("Already disconnected; refusing to report error %s", error->message); } else { GHashTable *details = tp_asv_new(key, G_TYPE_STRING, error->message, NULL); @@ -666,7 +681,7 @@ static void _password_prompt_cb(GObject *source, GAsyncResult *result, gpointer if (error != NULL) { IDLE_DEBUG("Simple password manager failed: %s", error->message); - if (base_conn->status != TP_CONNECTION_STATUS_DISCONNECTED) + if (tp_base_connection_get_status (base_conn) != TP_CONNECTION_STATUS_DISCONNECTED) _connection_disconnect_with_gerror(conn, TP_CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED, "debug-message", @@ -1004,7 +1019,7 @@ idle_connection_get_max_message_length(IdleConnection *conn) static IdleParserHandlerResult _error_handler(IdleParser *parser, IdleParserMessageCode code, GValueArray *args, gpointer user_data) { IdleConnection *conn = IDLE_CONNECTION(user_data); - TpConnectionStatus status = conn->parent.status; + TpConnectionStatus status = tp_base_connection_get_status (TP_BASE_CONNECTION (conn)); TpConnectionStatusReason reason; const gchar *msg; const gchar *begin; @@ -1049,7 +1064,7 @@ static IdleParserHandlerResult _error_handler(IdleParser *parser, IdleParserMess static IdleParserHandlerResult _erroneous_nickname_handler(IdleParser *parser, IdleParserMessageCode code, GValueArray *args, gpointer user_data) { IdleConnection *conn = IDLE_CONNECTION(user_data); - if (conn->parent.status == TP_CONNECTION_STATUS_CONNECTING) + if (tp_base_connection_get_status (TP_BASE_CONNECTION (conn)) == TP_CONNECTION_STATUS_CONNECTING) connection_connect_cb(conn, FALSE, TP_CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED); return IDLE_PARSER_HANDLER_RESULT_HANDLED; @@ -1063,7 +1078,7 @@ static IdleParserHandlerResult _nick_handler(IdleParser *parser, IdleParserMessa if (old_handle == new_handle) return IDLE_PARSER_HANDLER_RESULT_NOT_HANDLED; - if (old_handle == conn->parent.self_handle) { + if (old_handle == tp_base_connection_get_self_handle (TP_BASE_CONNECTION (conn))) { IDLE_DEBUG("Self renamed: handle was %d, now %d", old_handle, new_handle); tp_base_connection_set_self_handle(TP_BASE_CONNECTION(conn), new_handle); } @@ -1078,7 +1093,7 @@ static IdleParserHandlerResult _nick_handler(IdleParser *parser, IdleParserMessa static IdleParserHandlerResult _nickname_in_use_handler(IdleParser *parser, IdleParserMessageCode code, GValueArray *args, gpointer user_data) { IdleConnection *conn = IDLE_CONNECTION(user_data); - if (conn->parent.status == TP_CONNECTION_STATUS_CONNECTING) + if (tp_base_connection_get_status (TP_BASE_CONNECTION (conn)) == TP_CONNECTION_STATUS_CONNECTING) connection_connect_cb(conn, FALSE, TP_CONNECTION_STATUS_REASON_NAME_IN_USE); return IDLE_PARSER_HANDLER_RESULT_HANDLED; @@ -1237,7 +1252,7 @@ static void connection_connect_cb(IdleConnection *conn, gboolean success, TpConn static void connection_disconnect_cb(IdleConnection *conn, TpConnectionStatusReason reason) { TpBaseConnection *base = TP_BASE_CONNECTION(conn); - if (base->status == TP_CONNECTION_STATUS_DISCONNECTED) + if (tp_base_connection_get_status (base) == TP_CONNECTION_STATUS_DISCONNECTED) g_idle_add(_finish_shutdown_idle_func, base); else tp_base_connection_change_status(base, TP_CONNECTION_STATUS_DISCONNECTED, reason); @@ -1425,7 +1440,7 @@ static void idle_connection_request_rename(IdleSvcConnectionInterfaceRenaming *i static void idle_connection_set_aliases(TpSvcConnectionInterfaceAliasing *iface, GHashTable *aliases, DBusGMethodInvocation *context) { IdleConnection *conn = IDLE_CONNECTION(iface); - const gchar *requested_alias = g_hash_table_lookup(aliases, GUINT_TO_POINTER(conn->parent.self_handle)); + const gchar *requested_alias = g_hash_table_lookup(aliases, GUINT_TO_POINTER(tp_base_connection_get_self_handle (TP_BASE_CONNECTION (conn)))); if ((g_hash_table_size(aliases) != 1) || !requested_alias) { GError error = {TP_ERROR, TP_ERROR_NOT_AVAILABLE, "You can only set your own alias in IRC"}; diff --git a/src/idle-im-manager.c b/src/idle-im-manager.c index 8d7c22d..ab15713 100644 --- a/src/idle-im-manager.c +++ b/src/idle-im-manager.c @@ -347,7 +347,7 @@ _im_manager_requestotron (IdleIMManager *self, } /* Don't support opening a channel to our self handle */ - if (handle == base_conn->self_handle) + if (handle == tp_base_connection_get_self_handle (base_conn)) { g_set_error (&error, TP_ERROR, TP_ERROR_NOT_IMPLEMENTED, "Can't open a text channel to yourself"); @@ -358,7 +358,7 @@ _im_manager_requestotron (IdleIMManager *self, if (channel == NULL) { - _im_manager_new_channel (self, handle, base_conn->self_handle, request_token); + _im_manager_new_channel (self, handle, tp_base_connection_get_self_handle (base_conn), request_token); return TRUE; } diff --git a/src/idle-muc-channel.c b/src/idle-muc-channel.c index f91ca03..bc864bf 100644 --- a/src/idle-muc-channel.c +++ b/src/idle-muc-channel.c @@ -205,6 +205,7 @@ idle_muc_channel_constructed (GObject *obj) "text/plain", NULL }; + TpHandle self_handle = tp_base_connection_get_self_handle (conn); G_OBJECT_CLASS (idle_muc_channel_parent_class)->constructed (obj); @@ -213,7 +214,7 @@ idle_muc_channel_constructed (GObject *obj) tp_base_channel_register (base); - tp_group_mixin_init(obj, G_STRUCT_OFFSET(IdleMUCChannel, group), contact_handles, conn->self_handle); + tp_group_mixin_init(obj, G_STRUCT_OFFSET(IdleMUCChannel, group), contact_handles, self_handle); tp_group_mixin_change_flags(obj, TP_CHANNEL_GROUP_FLAG_PROPERTIES, 0); /* initialize message mixin */ @@ -229,7 +230,7 @@ idle_muc_channel_constructed (GObject *obj) TpIntset *remote; TpHandle initiator = tp_base_channel_get_initiator (base); - g_assert (initiator == conn->self_handle); + g_assert (initiator == self_handle); remote = tp_intset_new_containing (initiator); tp_group_mixin_change_members (obj, "", NULL, NULL, NULL, remote, @@ -737,7 +738,7 @@ void idle_muc_channel_join(IdleMUCChannel *chan, TpHandle joiner) { set = tp_intset_new(); tp_intset_add(set, joiner); - if (joiner == base_conn->self_handle) { + if (joiner == tp_base_connection_get_self_handle (base_conn)) { /* woot we managed to get into a channel, great */ change_state(chan, MUC_STATE_JOINED); tp_group_mixin_change_members((GObject *)(chan), NULL, set, NULL, NULL, NULL, joiner, TP_CHANNEL_GROUP_CHANGE_REASON_NONE); @@ -768,7 +769,7 @@ static void _network_member_left(IdleMUCChannel *chan, TpHandle leaver, TpHandle tp_intset_add(set, leaver); tp_group_mixin_change_members((GObject *) chan, message, NULL, set, NULL, NULL, actor, reason); - if (leaver == base_conn->self_handle) { + if (leaver == tp_base_connection_get_self_handle (base_conn)) { change_state(chan, MUC_STATE_PARTED); if (!tp_base_channel_is_destroyed (base)) { @@ -798,7 +799,7 @@ void idle_muc_channel_invited(IdleMUCChannel *chan, TpHandle inviter) { TpIntset *local = tp_intset_new(); tp_intset_add(add, inviter); - tp_intset_add(local, base_conn->self_handle); + tp_intset_add(local, tp_base_connection_get_self_handle (base_conn)); tp_group_mixin_change_members((GObject *)(chan), NULL, add, NULL, local, NULL, inviter, TP_CHANNEL_GROUP_CHANGE_REASON_INVITED); @@ -822,7 +823,7 @@ void idle_muc_channel_namereply(IdleMUCChannel *chan, GValueArray *args) { gchar modechar = g_value_get_char(g_value_array_get_nth(args, i + 1)); #endif - if (handle == base_conn->self_handle) { + if (handle == tp_base_connection_get_self_handle (base_conn)) { guint remove = MODE_FLAG_OPERATOR_PRIVILEGE | MODE_FLAG_VOICE_PRIVILEGE | MODE_FLAG_HALFOP_PRIVILEGE; guint add = 0; @@ -908,7 +909,7 @@ void idle_muc_channel_mode(IdleMUCChannel *chan, GValueArray *args) { if ((i + 1) < args->n_values) { TpHandle handle = tp_handle_ensure(handles, g_value_get_string(g_value_array_get_nth(args, ++i)), NULL, NULL); - if (handle == base_conn->self_handle) { + if (handle == tp_base_connection_get_self_handle (base_conn)) { IDLE_DEBUG("got MODE '%c' concerning us", *modes); mode_accum |= _modechar_to_modeflag(*modes); } @@ -1234,8 +1235,9 @@ static gboolean add_member(GObject *gobj, TpHandle handle, const gchar *message, IdleMUCChannelPrivate *priv = obj->priv; TpBaseChannel *base = TP_BASE_CHANNEL (obj); TpBaseConnection *base_conn = tp_base_channel_get_connection (base); + TpHandle self_handle = tp_base_connection_get_self_handle (base_conn); - if (handle == base_conn->self_handle) { + if (handle == self_handle) { if (tp_handle_set_is_member(obj->group.members, handle) || tp_handle_set_is_member(obj->group.remote_pending, handle)) { GError *e = g_error_new (TP_ERROR, TP_ERROR_NOT_AVAILABLE, "we are already a member of or trying to join %s", priv->channel_name); @@ -1275,7 +1277,7 @@ static gboolean add_member(GObject *gobj, TpHandle handle, const gchar *message, tp_intset_add(add_set, handle); - tp_group_mixin_change_members(gobj, NULL, NULL, NULL, NULL, add_set, base_conn->self_handle, TP_CHANNEL_GROUP_CHANGE_REASON_INVITED); + tp_group_mixin_change_members(gobj, NULL, NULL, NULL, NULL, add_set, self_handle, TP_CHANNEL_GROUP_CHANGE_REASON_INVITED); } } @@ -1305,7 +1307,7 @@ static gboolean remove_member(GObject *gobj, TpHandle handle, const gchar *messa TpBaseChannel *base = TP_BASE_CHANNEL (obj); TpBaseConnection *base_conn = tp_base_channel_get_connection (base); - if (handle == base_conn->self_handle) { + if (handle == tp_base_connection_get_self_handle (base_conn)) { part_from_channel(obj, message); return TRUE; } diff --git a/src/idle-muc-manager.c b/src/idle-muc-manager.c index 03a5beb..b5909f0 100644 --- a/src/idle-muc-manager.c +++ b/src/idle-muc-manager.c @@ -270,7 +270,7 @@ static IdleParserHandlerResult _invite_handler(IdleParser *parser, IdleParserMes TpHandle room_handle = g_value_get_uint(g_value_array_get_nth(args, 2)); IdleMUCChannel *chan; - if (invited_handle != priv->conn->parent.self_handle) + if (invited_handle != tp_base_connection_get_self_handle (TP_BASE_CONNECTION (priv->conn))) return IDLE_PARSER_HANDLER_RESULT_HANDLED; if (!priv->channels) { @@ -830,7 +830,8 @@ _muc_manager_request ( } else { - channel = _muc_manager_new_channel (self, handle, base_conn->self_handle, TRUE); + channel = _muc_manager_new_channel (self, handle, + tp_base_connection_get_self_handle (base_conn), TRUE); idle_muc_channel_join_attempt (channel); } diff --git a/src/protocol.c b/src/protocol.c index 489410a..b6ba690 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -178,10 +178,15 @@ identify_account (TpBaseProtocol *self G_GNUC_UNUSED, return nick_at_server; } -static GStrv -get_interfaces (TpBaseProtocol *self) +static GPtrArray * +get_interfaces_array (TpBaseProtocol *self) { - return g_new0 (gchar *, 1); + GPtrArray *interfaces; + + interfaces = TP_BASE_PROTOCOL_CLASS ( + idle_protocol_parent_class)->get_interfaces_array (self); + + return interfaces; } static void @@ -244,7 +249,7 @@ idle_protocol_class_init (IdleProtocolClass *klass) base_class->new_connection = new_connection; base_class->normalize_contact = normalize_contact; base_class->identify_account = identify_account; - base_class->get_interfaces = get_interfaces; + base_class->get_interfaces_array = get_interfaces_array; base_class->get_connection_details = get_connection_details; base_class->dup_authentication_types = dup_authentication_types; } -- 1.8.3.1