From 9a6cc6f5dc690b121d7c4c4ab5239adecb01f187 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Mon, 16 Sep 2013 16:48:19 +0200 Subject: [PATCH 3/3] use TP_SEAL_ENABLE I changed TP_INTERNAL_CONNECTION_STATUS_NEW to TP_CONNECTION_STATUS_DISCONNECTED as tp_base_connection_get_status() returns DISCONNECTED instead of NEW. --- configure.ac | 1 + rakia/connection-aliasing.c | 9 +++++---- rakia/media-manager.c | 18 +++++++++--------- rakia/text-channel.c | 3 ++- rakia/text-manager.c | 5 +++-- src/protocol.c | 13 +++++++++---- src/sip-connection.c | 40 +++++++++++++++++++++++++++++----------- 7 files changed, 58 insertions(+), 31 deletions(-) diff --git a/configure.ac b/configure.ac index e572e3f..4a6b336 100644 --- a/configure.ac +++ b/configure.ac @@ -99,6 +99,7 @@ AC_DEFINE([GLIB_VERSION_MAX_ALLOWED], [GLIB_VERSION_2_30], [Prevent post 2.30 AP PKG_CHECK_MODULES([DBUS], [dbus-1 >= 0.60, dbus-glib-1 >= 0.60]) PKG_CHECK_MODULES([SOFIA_SIP_UA], [sofia-sip-ua-glib >= 1.12.11]) +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/rakia/connection-aliasing.c b/rakia/connection-aliasing.c index e585601..62ee5d7 100644 --- a/rakia/connection-aliasing.c +++ b/rakia/connection-aliasing.c @@ -138,7 +138,7 @@ conn_get_alias (TpBaseConnection *base, { gchar *alias = NULL; - if (handle == base->self_handle) + if (handle == tp_base_connection_get_self_handle (base)) { /* Get our user-settable alias from the connection property */ g_object_get (base, "alias", &alias, NULL); @@ -253,7 +253,7 @@ emit_self_alias_change (TpBaseConnection *base, const gchar *alias) g_value_take_boxed (&change_pair, dbus_g_type_specialized_construct (TP_STRUCT_TYPE_ALIAS_PAIR)); dbus_g_type_struct_set (&change_pair, - 0, base->self_handle, + 0, tp_base_connection_get_self_handle (base), 1, alias, G_MAXUINT); change_data = g_ptr_array_sized_new (1); @@ -300,11 +300,12 @@ rakia_connection_set_aliases (TpSvcConnectionInterfaceAliasing *iface, const gchar *alias; gchar *default_alias; gchar *to_free = NULL; + TpHandle self_handle = tp_base_connection_get_self_handle (base); TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED (base, context); /* We only care about the self alias */ - alias = g_hash_table_lookup (aliases, GINT_TO_POINTER (base->self_handle)); + alias = g_hash_table_lookup (aliases, GINT_TO_POINTER (self_handle)); if (alias == NULL || g_hash_table_size (aliases) > 1) { @@ -320,7 +321,7 @@ rakia_connection_set_aliases (TpSvcConnectionInterfaceAliasing *iface, contact_handles = tp_base_connection_get_handles (base, TP_HANDLE_TYPE_CONTACT); default_alias = conn_get_default_alias (base, - contact_handles, base->self_handle); + contact_handles, self_handle); if (strcmp (alias, default_alias) == 0) { diff --git a/rakia/media-manager.c b/rakia/media-manager.c index 2db7580..bb47611 100644 --- a/rakia/media-manager.c +++ b/rakia/media-manager.c @@ -268,7 +268,7 @@ new_call_channel (RakiaMediaManager *fac, GHashTable *request_properties, RakiaSipSession *session) { - RakiaMediaManagerPrivate *priv; + RakiaMediaManagerPrivate *priv = RAKIA_MEDIA_MANAGER_GET_PRIVATE (fac); RakiaCallChannel *chan = NULL; gchar *object_path; gboolean initial_audio = FALSE; @@ -277,13 +277,12 @@ new_call_channel (RakiaMediaManager *fac, const gchar *dtmf_initial_tones = NULL; const gchar *initial_audio_name = NULL; const gchar *initial_video_name = NULL; + TpHandle self_handle = tp_base_connection_get_self_handle (priv->conn); g_assert (initiator != 0); - priv = RAKIA_MEDIA_MANAGER_GET_PRIVATE (fac); - - object_path = g_strdup_printf ("%s/CallChannel%u", priv->conn->object_path, - priv->channel_index++); + object_path = g_strdup_printf ("%s/CallChannel%u", + tp_base_connection_get_object_path (priv->conn), priv->channel_index++); DEBUG("channel object path %s", object_path); @@ -321,7 +320,7 @@ new_call_channel (RakiaMediaManager *fac, "stun-server", priv->stun_server ? priv->stun_server : "", "stun-port", priv->stun_port, - "requested", (initiator == priv->conn->self_handle), + "requested", (initiator == self_handle), NULL); g_free (object_path); @@ -417,7 +416,7 @@ rakia_nua_i_invite_cb (TpBaseConnection *conn, DEBUG("Got incoming invite from <%s>", rakia_handle_inspect (conn, handle)); - if (handle == conn->self_handle) + if (handle == tp_base_connection_get_self_handle (conn)) { DEBUG("cannot handle calls from self"); nua_respond (ev->nua_handle, 501, "Calls from self are not supported", TAG_END()); @@ -589,6 +588,7 @@ rakia_media_manager_requestotron (TpChannelManager *manager, gboolean valid = FALSE; gboolean initial_audio = FALSE; gboolean initial_video = FALSE; + TpHandle self_handle = tp_base_connection_get_self_handle (conn); /* Supported modes of operation: * - RequestChannel(Contact, n) where n != 0: @@ -640,7 +640,7 @@ rakia_media_manager_requestotron (TpChannelManager *manager, * interface and its semantically required Group member changes; * we disable them until a better API is available through * Call channel type */ - if (handle == conn->self_handle) + if (handle == self_handle) { g_set_error (&error, TP_ERROR, TP_ERROR_NOT_IMPLEMENTED, "Cannot call self"); @@ -667,7 +667,7 @@ rakia_media_manager_requestotron (TpChannelManager *manager, } session = new_session (self, NULL, handle); - channel = new_call_channel (self, conn->self_handle, handle, + channel = new_call_channel (self, self_handle, handle, request_properties, session); g_object_unref (session); diff --git a/rakia/text-channel.c b/rakia/text-channel.c index 130b095..b31c855 100644 --- a/rakia/text-channel.c +++ b/rakia/text-channel.c @@ -360,7 +360,8 @@ rakia_text_channel_get_property(GObject *object, break; case PROP_REQUESTED: - g_value_set_boolean (value, (priv->initiator == base_conn->self_handle)); + g_value_set_boolean (value, (priv->initiator == + tp_base_connection_get_self_handle (base_conn))); break; case PROP_CHANNEL_DESTROYED: diff --git a/rakia/text-manager.c b/rakia/text-manager.c index 290b56c..fcb61e7 100644 --- a/rakia/text-manager.c +++ b/rakia/text-manager.c @@ -285,7 +285,7 @@ rakia_text_manager_new_channel (RakiaTextManager *fac, conn = priv->conn; object_path = g_strdup_printf ("%s/TextChannel%u", - conn->object_path, handle); + tp_base_connection_get_object_path (conn), handle); DEBUG ("object path %s", object_path); @@ -389,7 +389,8 @@ rakia_text_manager_requestotron (RakiaTextManager *self, if (channel == NULL) { rakia_text_manager_new_channel (self, - handle, base_conn->self_handle, request_token); + handle, tp_base_connection_get_self_handle (base_conn), + request_token); return TRUE; } diff --git a/src/protocol.c b/src/protocol.c index bf1fd70..a545e78 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -417,10 +417,15 @@ identify_account (TpBaseProtocol *self G_GNUC_UNUSED, return g_strdup (account); } -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 ( + rakia_protocol_parent_class)->get_interfaces_array (self); + + return interfaces; } static void @@ -527,7 +532,7 @@ rakia_protocol_class_init (RakiaProtocolClass *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; diff --git a/src/sip-connection.c b/src/sip-connection.c index f0ea3ed..43fc9cd 100644 --- a/src/sip-connection.c +++ b/src/sip-connection.c @@ -417,6 +417,21 @@ rakia_connection_get_implemented_interfaces (void) return interfaces_always_present; } +static GPtrArray * +get_interfaces_always_present (TpBaseConnection *base) +{ + GPtrArray *arr; + const gchar **iter; + + arr = TP_BASE_CONNECTION_CLASS ( + rakia_connection_parent_class)->get_interfaces_always_present (base); + + for (iter = interfaces_always_present; *iter != NULL; iter++) + g_ptr_array_add (arr, (gchar *) *iter); + + return arr; +} + static nua_handle_t *rakia_connection_create_nua_handle (RakiaBaseConnection *, TpHandle); static void rakia_connection_add_auth_handler (RakiaBaseConnection *, @@ -442,7 +457,7 @@ rakia_connection_class_init (RakiaConnectionClass *klass) base_class->disconnected = rakia_connection_disconnected; base_class->start_connecting = rakia_connection_start_connecting; base_class->shut_down = rakia_connection_shut_down; - base_class->interfaces_always_present = interfaces_always_present; + base_class->get_interfaces_always_present = get_interfaces_always_present; g_type_class_add_private (klass, sizeof (RakiaConnectionPrivate)); @@ -889,7 +904,7 @@ rakia_connection_nua_r_register_cb (RakiaConnection *self, } else /* if (ev->status == 200) */ { - if (base->status != TP_CONNECTION_STATUS_CONNECTING) + if (tp_base_connection_get_status (base) != TP_CONNECTION_STATUS_CONNECTING) return TRUE; DEBUG("successfully registered to the network"); @@ -946,8 +961,8 @@ rakia_connection_dispose (GObject *object) /* the base class is responsible for unreffing the self handle when we * disconnect */ - g_assert (base->status == TP_CONNECTION_STATUS_DISCONNECTED - || base->status == TP_INTERNAL_CONNECTION_STATUS_NEW); + g_assert (tp_base_connection_get_status (base) == + TP_CONNECTION_STATUS_DISCONNECTED); /* the base class owns channel factories/managers, * here we just nullify the references */ @@ -1004,8 +1019,10 @@ rakia_connection_start_connecting (TpBaseConnection *base, const gchar *sip_address; const url_t *local_url; su_root_t *root = NULL; + TpHandle self_handle; - g_assert (base->status == TP_INTERNAL_CONNECTION_STATUS_NEW); + g_assert (tp_base_connection_get_status (base) == + TP_CONNECTION_STATUS_DISCONNECTED); /* the construct parameters will be non-empty */ g_object_get (self, "sofia-root", &root, NULL); @@ -1013,16 +1030,18 @@ rakia_connection_start_connecting (TpBaseConnection *base, g_return_val_if_fail (priv->address != NULL, FALSE); contact_repo = tp_base_connection_get_handles (base, TP_HANDLE_TYPE_CONTACT); - base->self_handle = tp_handle_ensure (contact_repo, priv->address, + self_handle = tp_handle_ensure (contact_repo, priv->address, NULL, error); - if (base->self_handle == 0) + if (self_handle == 0) { return FALSE; } - sip_address = tp_handle_inspect(contact_repo, base->self_handle); + tp_base_connection_set_self_handle (base, self_handle); + + sip_address = tp_handle_inspect(contact_repo, self_handle); - DEBUG("self_handle = %d, sip_address = %s", base->self_handle, sip_address); + DEBUG("self_handle = %d, sip_address = %s", self_handle, sip_address); priv->account_url = rakia_base_connection_handle_to_uri (rbase, tp_base_connection_get_self_handle (base)); @@ -1084,8 +1103,7 @@ rakia_connection_start_connecting (TpBaseConnection *base, G_CALLBACK (rakia_connection_nua_r_register_cb), NULL); - priv->register_op = rakia_conn_create_register_handle (self, - base->self_handle); + priv->register_op = rakia_conn_create_register_handle (self, self_handle); if (priv->register_op == NULL) { g_set_error (error, TP_ERROR, TP_ERROR_NOT_AVAILABLE, -- 1.8.3.1