From 5ac3d83a2a7d3877a4803144ddd18b80d98c4d29 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Thu, 12 Sep 2013 15:52:12 +0200 Subject: [PATCH 3/3] use TP_SEAL_ENABLE https://bugs.freedesktop.org/show_bug.cgi?id=69272 --- configure.ac | 1 + src/connection-capabilities.c | 10 ++++++---- src/connection.c | 35 ++++++++++++++++++++++++----------- src/im-channel-factory.c | 8 +++++--- src/media-channel.c | 18 +++++++++++------- src/media-manager.c | 2 +- src/protocol.c | 13 +++++++++---- 7 files changed, 57 insertions(+), 30 deletions(-) diff --git a/configure.ac b/configure.ac index 7e42519..d3b8f65 100644 --- a/configure.ac +++ b/configure.ac @@ -76,6 +76,7 @@ PKG_CHECK_MODULES(PURPLE,[purple >= 2.7]) PKG_CHECK_MODULES(GLIB,[glib-2.0 >= 2.22, gobject-2.0, gio-2.0]) PKG_CHECK_MODULES(DBUS_GLIB,[dbus-glib-1 >= 0.73]) +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/connection-capabilities.c b/src/connection-capabilities.c index ab59f05..1e33ad6 100644 --- a/src/connection-capabilities.c +++ b/src/connection-capabilities.c @@ -193,7 +193,8 @@ haze_connection_advertise_capabilities (TpSvcConnectionInterfaceCapabilities *if purple_media_manager_set_ui_caps (purple_media_manager_get(), caps); - _emit_capabilities_changed (self, base->self_handle, old_caps, caps); + _emit_capabilities_changed (self, tp_base_connection_get_self_handle (base), + old_caps, caps); #endif ret = g_ptr_array_new (); @@ -284,7 +285,8 @@ haze_connection_update_capabilities (TpSvcConnectionInterfaceContactCapabilities purple_media_manager_set_ui_caps (purple_media_manager_get(), caps); - _emit_capabilities_changed (self, base->self_handle, old_caps, caps); + _emit_capabilities_changed (self, tp_base_connection_get_self_handle (base), + old_caps, caps); #endif tp_svc_connection_interface_contact_capabilities_return_from_update_capabilities ( @@ -327,7 +329,7 @@ haze_connection_get_handle_capabilities (HazeConnection *self, /* TODO: Check for presence */ #ifdef ENABLE_MEDIA - if (handle == conn->self_handle) + if (handle == tp_base_connection_get_self_handle (conn)) caps = purple_media_manager_get_ui_caps (purple_media_manager_get ()); else { @@ -413,7 +415,7 @@ haze_connection_get_handle_contact_capabilities (HazeConnection *self, /* TODO: Check for presence */ #ifdef ENABLE_MEDIA - if (handle == conn->self_handle) + if (handle == tp_base_connection_get_self_handle (conn)) caps = purple_media_manager_get_ui_caps (purple_media_manager_get ()); else { diff --git a/src/connection.c b/src/connection.c index e74ad5d..8dd77dc 100644 --- a/src/connection.c +++ b/src/connection.c @@ -119,10 +119,20 @@ haze_connection_get_implemented_interfaces (void) return implemented_interfaces; } -const gchar ** -haze_connection_get_guaranteed_interfaces (void) +static GPtrArray * +haze_connection_get_interfaces_always_present (TpBaseConnection *base) { - return implemented_interfaces + HAZE_NUM_CONDITIONAL_INTERFACES; + GPtrArray *interfaces; + const gchar **iter; + + interfaces = TP_BASE_CONNECTION_CLASS ( + haze_connection_parent_class)->get_interfaces_always_present (base); + + for (iter = implemented_interfaces + HAZE_NUM_CONDITIONAL_INTERFACES; + *iter != NULL; iter++) + g_ptr_array_add (interfaces, (gchar *) *iter); + + return interfaces; } struct _HazeConnectionPrivate @@ -298,7 +308,8 @@ haze_report_disconnect_reason (PurpleConnection *gc, priv->disconnecting = TRUE; map_purple_error_to_tp (reason, - (base_conn->status == TP_CONNECTION_STATUS_CONNECTING), + (tp_base_connection_get_status (base_conn) == + TP_CONNECTION_STATUS_CONNECTING), &tp_reason, &tp_error_name); details = tp_asv_new ("debug-message", G_TYPE_STRING, text, NULL); tp_base_connection_disconnect_with_dbus_error (base_conn, tp_error_name, @@ -323,7 +334,8 @@ disconnected_cb (PurpleConnection *pc) priv->disconnecting = TRUE; - if(base_conn->status != TP_CONNECTION_STATUS_DISCONNECTED) + if (tp_base_connection_get_status (base_conn) != + TP_CONNECTION_STATUS_DISCONNECTED) { /* Because we have report_disconnect_reason, if status is not already * DISCONNECTED, we know that it was requested. */ @@ -453,7 +465,8 @@ _haze_connection_password_manager_prompt_cb (GObject *source, * AUTHENTICATION_FAILED-type message. */ } - else if (base_conn->status != TP_CONNECTION_STATUS_DISCONNECTED) + else if (tp_base_connection_get_status (base_conn) != + TP_CONNECTION_STATUS_DISCONNECTED) { tp_base_connection_disconnect_with_dbus_error (base_conn, tp_error_get_dbus_name (error->code), NULL, @@ -496,9 +509,9 @@ _haze_connection_start_connecting (TpBaseConnection *base, g_return_val_if_fail (self->account != NULL, FALSE); - base->self_handle = tp_handle_ensure (contact_handles, - purple_account_get_username (self->account), NULL, error); - if (!base->self_handle) + tp_base_connection_set_self_handle (base, tp_handle_ensure (contact_handles, + purple_account_get_username (self->account), NULL, error)); + if (tp_base_connection_get_self_handle (base) == 0) return FALSE; tp_base_connection_change_status(base, TP_CONNECTION_STATUS_CONNECTING, @@ -816,8 +829,8 @@ haze_connection_class_init (HazeConnectionClass *klass) haze_connection_get_unique_connection_name; base_class->start_connecting = _haze_connection_start_connecting; base_class->shut_down = _haze_connection_shut_down; - base_class->interfaces_always_present = - haze_connection_get_guaranteed_interfaces(); + base_class->get_interfaces_always_present = + haze_connection_get_interfaces_always_present; param_spec = g_param_spec_boxed ("parameters", "gchar * => GValue", "Connection parameters (password, etc.)", diff --git a/src/im-channel-factory.c b/src/im-channel-factory.c index 21fade5..31823ce 100644 --- a/src/im-channel-factory.c +++ b/src/im-channel-factory.c @@ -276,7 +276,8 @@ new_im_channel (HazeImChannelFactory *self, g_assert (!g_hash_table_lookup (self->priv->channels, GINT_TO_POINTER (handle))); - object_path = g_strdup_printf ("%s/ImChannel%u", conn->object_path, handle); + object_path = g_strdup_printf ("%s/ImChannel%u", + tp_base_connection_get_object_path (conn), handle); chan = g_object_new (HAZE_TYPE_IM_CHANNEL, "connection", self->priv->conn, @@ -573,8 +574,9 @@ haze_im_channel_factory_request (HazeImChannelFactory *self, goto error; } - chan = get_im_channel (self, handle, base_conn->self_handle, - request_token, &created); + chan = get_im_channel (self, handle, + tp_base_connection_get_self_handle (base_conn), request_token, + &created); g_assert (chan != NULL); if (!created) diff --git a/src/media-channel.c b/src/media-channel.c index 370936b..1cfd4d8 100644 --- a/src/media-channel.c +++ b/src/media-channel.c @@ -483,7 +483,7 @@ media_stream_info_cb(PurpleMedia *media, if (local == FALSE) actor = priv->initial_peer; else - actor = conn->self_handle; + actor = tp_base_connection_get_self_handle (conn); set = tp_intset_new_containing (actor); @@ -517,7 +517,7 @@ media_stream_info_cb(PurpleMedia *media, return; if (local == TRUE) - terminator = conn->self_handle; + terminator = tp_base_connection_get_self_handle (conn); else /* This will need to get the handle from name for multi-user calls */ terminator = priv->initial_peer; @@ -579,6 +579,7 @@ haze_media_channel_constructor (GType type, guint n_props, TpDBusDaemon *bus; TpIntset *set; TpHandleRepoIface *contact_handles; + TpHandle self_handle; obj = G_OBJECT_CLASS (haze_media_channel_parent_class)-> constructor (type, n_props, props); @@ -587,18 +588,19 @@ haze_media_channel_constructor (GType type, guint n_props, conn = (TpBaseConnection *) priv->conn; contact_handles = tp_base_connection_get_handles (conn, TP_HANDLE_TYPE_CONTACT); + self_handle = tp_base_connection_get_self_handle (conn); /* register object on the bus */ bus = tp_base_connection_get_dbus_daemon (conn); tp_dbus_daemon_register_object (bus, priv->object_path, obj); tp_group_mixin_init (obj, G_STRUCT_OFFSET (HazeMediaChannel, group), - contact_handles, conn->self_handle); + contact_handles, self_handle); if (priv->media != NULL) priv->creator = priv->initial_peer; else - priv->creator = conn->self_handle; + priv->creator = self_handle; /* automatically add creator to channel, but also ref them again (because * priv->creator is the InitiatorHandle) */ @@ -626,7 +628,7 @@ haze_media_channel_constructor (GType type, guint n_props, * group flags (all we can do is add or remove ourselves, which is always * valid per the spec) */ - set = tp_intset_new_containing (conn->self_handle); + set = tp_intset_new_containing (self_handle); tp_group_mixin_change_members (obj, "", NULL, NULL, set, NULL, priv->initial_peer, TP_CHANNEL_GROUP_CHANGE_REASON_INVITED); tp_intset_destroy (set); @@ -714,7 +716,8 @@ haze_media_channel_get_property (GObject *object, } break; case PROP_REQUESTED: - g_value_set_boolean (value, (priv->creator == base_conn->self_handle)); + g_value_set_boolean (value, (priv->creator == + tp_base_connection_get_self_handle (base_conn))); break; case PROP_INTERFACES: g_value_set_boxed (value, haze_media_channel_interfaces); @@ -1508,7 +1511,8 @@ haze_media_channel_request_initial_streams (HazeMediaChannel *chan, guint media_type; /* This has to be an outgoing call... */ - g_assert (priv->creator == priv->conn->parent.self_handle); + g_assert (priv->creator == tp_base_connection_get_self_handle ( + TP_BASE_CONNECTION (priv->conn))); if (priv->initial_audio) { diff --git a/src/media-manager.c b/src/media-manager.c index 544abc4..406b952 100644 --- a/src/media-manager.c +++ b/src/media-manager.c @@ -198,7 +198,7 @@ new_media_channel (HazeMediaManager *self, conn = (TpBaseConnection *) priv->conn; object_path = g_strdup_printf ("%s/MediaChannel%u", - conn->object_path, priv->channel_index); + tp_base_connection_get_object_path (conn), priv->channel_index); priv->channel_index += 1; chan = g_object_new (HAZE_TYPE_MEDIA_CHANNEL, diff --git a/src/protocol.c b/src/protocol.c index cd8593a..aa4d864 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -882,10 +882,15 @@ haze_protocol_identify_account (TpBaseProtocol *base, return ret; } -static GStrv -haze_protocol_get_interfaces (TpBaseProtocol *base) +static GPtrArray * +haze_protocol_get_interfaces_array (TpBaseProtocol *base) { - return g_new0 (gchar *, 1); + GPtrArray *interfaces; + + interfaces = TP_BASE_PROTOCOL_CLASS ( + haze_protocol_parent_class)->get_interfaces_array (base); + + return interfaces; } static void @@ -971,7 +976,7 @@ haze_protocol_class_init (HazeProtocolClass *cls) base_class->new_connection = haze_protocol_new_connection; base_class->normalize_contact = haze_protocol_normalize_contact; base_class->identify_account = haze_protocol_identify_account; - base_class->get_interfaces = haze_protocol_get_interfaces; + base_class->get_interfaces_array = haze_protocol_get_interfaces_array; base_class->get_connection_details = haze_protocol_get_connection_details; base_class->dup_authentication_types = haze_protocol_dup_authentication_types; -- 1.8.3.1