From 0e07bc87d2de810c81e32609be2804ee8bffb093 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Fri, 27 Apr 2012 13:46:22 +0200 Subject: [PATCH] TpChannel: Deprecate all TpHandle APIs that have TpContact variant https://bugs.freedesktop.org/show_bug.cgi?id=49213 --- examples/client/inspect-channel.c | 14 +++++++------- telepathy-glib/channel-contacts.c | 2 ++ telepathy-glib/channel-group.c | 12 ++++++++++++ telepathy-glib/channel.c | 20 +++++++++++++------- telepathy-glib/channel.h | 24 ++++++++++++++++-------- telepathy-glib/stream-tube-channel.c | 3 ++- 6 files changed, 52 insertions(+), 23 deletions(-) diff --git a/examples/client/inspect-channel.c b/examples/client/inspect-channel.c index a4987b6..84bc33c 100644 --- a/examples/client/inspect-channel.c +++ b/examples/client/inspect-channel.c @@ -64,18 +64,18 @@ channel_ready_cb (GObject *source, if (tp_proxy_has_interface_by_id (channel, TP_IFACE_QUARK_CHANNEL_INTERFACE_GROUP)) { - const TpIntset *members = tp_channel_group_get_members (channel); - TpIntsetFastIter group_iter; - TpHandle member; + GPtrArray *members = tp_channel_group_dup_members_contacts (channel); + guint i; printf ("Group members:\n"); - tp_intset_fast_iter_init (&group_iter, members); - - while (tp_intset_fast_iter_next (&group_iter, &member)) + for (i = 0; i < members->len; i++) { - printf ("\tcontact #%u\n", member); + TpContact *member = g_ptr_array_index (members, i); + + printf ("\tcontact #%u\n", tp_contact_get_handle (member)); } + g_ptr_array_unref (members); } data->exit_status = 0; diff --git a/telepathy-glib/channel-contacts.c b/telepathy-glib/channel-contacts.c index 7bdebe3..6896a46 100644 --- a/telepathy-glib/channel-contacts.c +++ b/telepathy-glib/channel-contacts.c @@ -175,6 +175,7 @@ _tp_channel_contacts_init (TpChannel *self) self->priv->handle, self->priv->identifier); } + G_GNUC_BEGIN_IGNORE_DEPRECATIONS if (tp_channel_get_initiator_handle (self) != 0 && !tp_str_empty (tp_channel_get_initiator_identifier (self))) { @@ -183,6 +184,7 @@ _tp_channel_contacts_init (TpChannel *self) tp_channel_get_initiator_handle (self), tp_channel_get_initiator_identifier (self)); } + G_GNUC_END_IGNORE_DEPRECATIONS } void diff --git a/telepathy-glib/channel-group.c b/telepathy-glib/channel-group.c index 63af6c7..236b725 100644 --- a/telepathy-glib/channel-group.c +++ b/telepathy-glib/channel-group.c @@ -79,6 +79,7 @@ local_pending_info_free (LocalPendingInfo *info) * * Returns: the handle representing the user, or 0 * Since: 0.7.12 + * Deprecated: New code should use tp_channel_group_get_self_contact() instead. */ TpHandle tp_channel_group_get_self_handle (TpChannel *self) @@ -122,6 +123,8 @@ tp_channel_group_get_flags (TpChannel *self) * * Returns: (transfer none): the members, or %NULL * Since: 0.7.12 + * Deprecated: New code should use tp_channel_group_dup_members_contacts() + * instead. */ const TpIntset * tp_channel_group_get_members (TpChannel *self) @@ -146,6 +149,8 @@ tp_channel_group_get_members (TpChannel *self) * * Returns: (transfer none): the local-pending members, or %NULL * Since: 0.7.12 + * Deprecated: New code should use tp_channel_group_dup_local_pending_contacts() + * instead. */ const TpIntset * tp_channel_group_get_local_pending (TpChannel *self) @@ -170,6 +175,8 @@ tp_channel_group_get_local_pending (TpChannel *self) * * Returns: (transfer none): the remote-pending members, or %NULL * Since: 0.7.12 + * Deprecated: New code should use + * tp_channel_group_dup_remote_pending_contacts() instead. */ const TpIntset * tp_channel_group_get_remote_pending (TpChannel *self) @@ -203,6 +210,8 @@ tp_channel_group_get_remote_pending (TpChannel *self) * * Returns: %TRUE if the contact is in fact local-pending * Since: 0.7.12 + * Deprecated: New code should use + * tp_channel_group_get_local_pending_contact_info() instead. */ gboolean tp_channel_group_get_local_pending_info (TpChannel *self, @@ -302,6 +311,7 @@ tp_channel_group_get_local_pending_info (TpChannel *self, * * Returns: the global handle that owns the given handle, or 0 * Since: 0.7.12 + * Deprecated: New code should use tp_channel_group_get_contact_owner() instead. */ TpHandle tp_channel_group_get_handle_owner (TpChannel *self, @@ -707,8 +717,10 @@ _tp_channel_emit_initial_sets (TpChannel *self) TpChannelGroupChangeReason reason; const gchar *message; + G_GNUC_BEGIN_IGNORE_DEPRECATIONS tp_channel_group_get_local_pending_info (self, handle, &actor, &reason, &message); + G_GNUC_END_IGNORE_DEPRECATIONS g_signal_emit_by_name (self, "group-members-changed", message, &empty_array, &empty_array, &local_pending, &empty_array, actor, diff --git a/telepathy-glib/channel.c b/telepathy-glib/channel.c index 1b6329a..41f016a 100644 --- a/telepathy-glib/channel.c +++ b/telepathy-glib/channel.c @@ -444,6 +444,8 @@ tp_channel_get_property (GObject *object, { TpChannel *self = TP_CHANNEL (object); + /* We still need to use deprecated getters funcs */ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS switch (property_id) { case PROP_CONNECTION: @@ -499,6 +501,7 @@ tp_channel_get_property (GObject *object, G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } + G_GNUC_END_IGNORE_DEPRECATIONS } /** @@ -1642,6 +1645,7 @@ tp_channel_class_init (TpChannelClass *klass) * Change notification is via notify::group-self-handle. * * Since: 0.7.12 + * Deprecated: Use #TpChannel:group-self-contact instead. */ param_spec = g_param_spec_uint ("group-self-handle", "Group.SelfHandle", "Undefined if not a group", 0, G_MAXUINT32, 0, @@ -1718,6 +1722,7 @@ tp_channel_class_init (TpChannelClass *klass) * finished preparing %TP_CHANNEL_FEATURE_CORE; until then, it may be 0. * * Since: 0.11.15 + * Deprecated: Use #TpChannel:initiator-contact instead. */ param_spec = g_param_spec_uint ("initiator-handle", "TpHandle", "The handle of the initiator of the channel", @@ -1738,6 +1743,7 @@ tp_channel_class_init (TpChannelClass *klass) * the empty string. * * Since: 0.11.15 + * Deprecated: Use #TpChannel:initiator-contact instead. */ param_spec = g_param_spec_string ("initiator-identifier", "Initiator identifier", @@ -1804,6 +1810,7 @@ tp_channel_class_init (TpChannelClass *klass) * Emitted when the group members change in a Group channel that is ready. * * Since: 0.7.12 + * Deprecated: Use #TpChannel::group-contacts-changed instead. */ signals[SIGNAL_GROUP_MEMBERS_CHANGED] = g_signal_new ( "group-members-changed", G_OBJECT_CLASS_TYPE (klass), @@ -1836,6 +1843,7 @@ tp_channel_class_init (TpChannelClass *klass) * applications can connect to this signal and ignore the other. * * Since: 0.7.21 + * Deprecated: Use #TpChannel::group-contacts-changed instead. */ signals[SIGNAL_GROUP_MEMBERS_CHANGED_DETAILED] = g_signal_new ( "group-members-changed-detailed", G_OBJECT_CLASS_TYPE (klass), @@ -2356,6 +2364,7 @@ tp_channel_get_requested (TpChannel *self) * Returns: the value of #TpChannel:initiator-handle * * Since: 0.11.15 + * Deprecated: New code should use tp_channel_get_initiator_contact() instead. */ TpHandle tp_channel_get_initiator_handle (TpChannel *self) @@ -2373,6 +2382,7 @@ tp_channel_get_initiator_handle (TpChannel *self) * Returns: the value of #TpChannel:initiator-identifier * * Since: 0.11.15 + * Deprecated: New code should use tp_channel_get_initiator_contact() instead. */ const gchar * tp_channel_get_initiator_identifier (TpChannel *self) @@ -2430,7 +2440,6 @@ tp_channel_join_async (TpChannel *self, { GSimpleAsyncResult *result; GArray *array; - TpHandle self_handle; g_return_if_fail (TP_IS_CHANNEL (self)); g_return_if_fail (tp_proxy_is_prepared (self, TP_CHANNEL_FEATURE_GROUP)); @@ -2438,9 +2447,8 @@ tp_channel_join_async (TpChannel *self, result = g_simple_async_result_new (G_OBJECT (self), callback, user_data, tp_channel_join_async); - self_handle = tp_channel_group_get_self_handle (self); array = g_array_sized_new (FALSE, FALSE, sizeof (TpHandle), 1); - g_array_append_val (array, self_handle); + g_array_append_val (array, self->priv->group_self_handle); tp_cli_channel_interface_group_call_add_members (self, -1, array, message, channel_join_cb, result, g_object_unref, NULL); @@ -2563,7 +2571,6 @@ group_prepared_cb (GObject *source, LeaveCtx *ctx = user_data; TpChannel *self = (TpChannel *) source; GError *error = NULL; - TpHandle self_handle; GArray *handles; if (!tp_proxy_prepare_finish (source, res, &error)) @@ -2575,15 +2582,14 @@ group_prepared_cb (GObject *source, goto call_close; } - self_handle = tp_channel_group_get_self_handle (self); - if (self_handle == 0) + if (self->priv->group_self_handle == 0) { DEBUG ("We are not in the channel, fallback to Close()"); goto call_close; } handles = g_array_sized_new (FALSE, FALSE, sizeof (TpHandle), 1); - g_array_append_val (handles, self_handle); + g_array_append_val (handles, self->priv->group_self_handle); tp_cli_channel_interface_group_call_remove_members_with_reason ( self, -1, handles, ctx->message, ctx->reason, diff --git a/telepathy-glib/channel.h b/telepathy-glib/channel.h index aeaa712..cf31db6 100644 --- a/telepathy-glib/channel.h +++ b/telepathy-glib/channel.h @@ -106,21 +106,29 @@ const gchar *tp_channel_get_identifier (TpChannel *self); TpConnection *tp_channel_borrow_connection (TpChannel *self); GHashTable *tp_channel_borrow_immutable_properties (TpChannel *self); -TpHandle tp_channel_group_get_self_handle (TpChannel *self); +TpHandle tp_channel_group_get_self_handle (TpChannel *self) + _TP_GNUC_DEPRECATED_FOR (tp_channel_group_get_self_contact); TpChannelGroupFlags tp_channel_group_get_flags (TpChannel *self); -const TpIntset *tp_channel_group_get_members (TpChannel *self); -const TpIntset *tp_channel_group_get_local_pending (TpChannel *self); -const TpIntset *tp_channel_group_get_remote_pending (TpChannel *self); +const TpIntset *tp_channel_group_get_members (TpChannel *self) + _TP_GNUC_DEPRECATED_FOR (tp_channel_group_dup_members_contacts); +const TpIntset *tp_channel_group_get_local_pending (TpChannel *self) + _TP_GNUC_DEPRECATED_FOR (tp_channel_group_dup_local_pending_contacts); +const TpIntset *tp_channel_group_get_remote_pending (TpChannel *self) + _TP_GNUC_DEPRECATED_FOR (tp_channel_group_dup_remote_pending_contacts); gboolean tp_channel_group_get_local_pending_info (TpChannel *self, TpHandle local_pending, TpHandle *actor, - TpChannelGroupChangeReason *reason, const gchar **message); + TpChannelGroupChangeReason *reason, const gchar **message) + _TP_GNUC_DEPRECATED_FOR (tp_channel_group_get_local_pending_contact_info); -TpHandle tp_channel_group_get_handle_owner (TpChannel *self, TpHandle handle); +TpHandle tp_channel_group_get_handle_owner (TpChannel *self, TpHandle handle) + _TP_GNUC_DEPRECATED_FOR (tp_channel_group_get_contact_owner); gboolean tp_channel_get_requested (TpChannel *self); -TpHandle tp_channel_get_initiator_handle (TpChannel *self); -const gchar * tp_channel_get_initiator_identifier (TpChannel *self); +TpHandle tp_channel_get_initiator_handle (TpChannel *self) + _TP_GNUC_DEPRECATED_FOR (tp_channel_get_initiator_contact); +const gchar * tp_channel_get_initiator_identifier (TpChannel *self) + _TP_GNUC_DEPRECATED_FOR (tp_channel_get_initiator_contact); #define TP_CHANNEL_FEATURE_CORE \ tp_channel_get_feature_quark_core () diff --git a/telepathy-glib/stream-tube-channel.c b/telepathy-glib/stream-tube-channel.c index dc52f07..6008560 100644 --- a/telepathy-glib/stream-tube-channel.c +++ b/telepathy-glib/stream-tube-channel.c @@ -599,8 +599,9 @@ new_local_connection_identified (TpStreamTubeChannel *self, /* We are accepting a tube so the contact of the connection is the * initiator of the tube */ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS initiator_handle = tp_channel_get_initiator_handle (TP_CHANNEL (self)); - + G_GNUC_END_IGNORE_DEPRECATIONS connection = tp_channel_borrow_connection (TP_CHANNEL (self)); features = tp_simple_client_factory_dup_contact_features ( -- 1.7.9.5