From f43fbe8cdb7adf761c2b23206b4c13ee5efc3332 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Mon, 21 Jun 2010 13:14:35 +0200 Subject: stop handling internally stream media channels We are going to do it properly using TpSimpleHandler. --- libempathy/empathy-dispatch-operation.c | 30 ------------------------------ 1 file changed, 30 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-dispatch-operation.c b/libempathy/empathy-dispatch-operation.c index 83cf72483..65fe4b17b 100644 --- a/libempathy/empathy-dispatch-operation.c +++ b/libempathy/empathy-dispatch-operation.c @@ -441,17 +441,6 @@ empathy_dispatcher_operation_tp_chat_ready_cb (GObject *object, channel_wrapper_ready (self); } -static void -call_status_changed_cb (EmpathyTpCall *call, - GParamSpec *spec, - EmpathyDispatchOperation *self) -{ - if (empathy_tp_call_get_status (call) <= EMPATHY_TP_CALL_STATUS_READYING) - return; - - channel_wrapper_ready (self); -} - static void empathy_dispatch_operation_channel_ready_cb (TpChannel *channel, const GError *error, gpointer user_data) @@ -488,25 +477,6 @@ empathy_dispatch_operation_channel_ready_cb (TpChannel *channel, goto out; } } - else if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_STREAMED_MEDIA) - { - gboolean requested; - EmpathyTpCall *call = empathy_tp_call_new (channel); - priv->channel_wrapper = G_OBJECT (call); - - requested = tp_asv_get_boolean (tp_channel_borrow_immutable_properties ( - channel), TP_PROP_CHANNEL_REQUESTED, NULL); - - if (!requested && - empathy_tp_call_get_status (call) <= EMPATHY_TP_CALL_STATUS_READYING) - { - /* For incoming calls, we have to wait that the TpCall is ready as - * the call-handler rely on it. */ - priv->ready_handler = g_signal_connect (call, - "notify::status", G_CALLBACK (call_status_changed_cb), self); - goto out; - } - } else if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_FILE_TRANSFER) { EmpathyTpFile *file = empathy_tp_file_new (channel, priv->incoming); -- cgit v1.2.3 From 6b7a7b32680892b3e5cc45e8ef012fc323d06a4c Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Mon, 21 Jun 2010 13:15:25 +0200 Subject: call-factory: use TpSimpleHandler to handle incoming calls (#622368) --- libempathy/empathy-call-factory.c | 130 +++++++++++++++++++++++++++++++++++--- libempathy/empathy-call-factory.h | 3 - 2 files changed, 120 insertions(+), 13 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-call-factory.c b/libempathy/empathy-call-factory.c index d02b58327..b45b8621b 100644 --- a/libempathy/empathy-call-factory.c +++ b/libempathy/empathy-call-factory.c @@ -22,12 +22,25 @@ #include #include +#include +#include +#include + #include "empathy-marshal.h" #include "empathy-call-factory.h" #include "empathy-utils.h" G_DEFINE_TYPE(EmpathyCallFactory, empathy_call_factory, G_TYPE_OBJECT) +static void handle_channels_cb (TpSimpleHandler *handler, + TpAccount *account, + TpConnection *connection, + GList *channels, + GList *requests_satisfied, + gint64 user_action_time, + TpHandleChannelsContext *context, + gpointer user_data); + /* signal enum */ enum { @@ -39,6 +52,7 @@ static guint signals[LAST_SIGNAL] = {0}; /* private structure */ typedef struct { + TpBaseClient *handler; gboolean dispose_has_run; } EmpathyCallFactoryPriv; @@ -51,8 +65,54 @@ empathy_call_factory_init (EmpathyCallFactory *obj) { EmpathyCallFactoryPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (obj, EMPATHY_TYPE_CALL_FACTORY, EmpathyCallFactoryPriv); + TpDBusDaemon *dbus; + GError *error = NULL; obj->priv = priv; + + dbus = tp_dbus_daemon_dup (&error); + if (dbus == NULL) + { + g_warning ("Failed to get TpDBusDaemon: %s", error->message); + g_error_free (error); + return; + } + + priv->handler = tp_simple_handler_new (dbus, FALSE, FALSE, + "Empathy.AudioVideo", FALSE, handle_channels_cb, obj, NULL); + + tp_base_client_take_handler_filter (priv->handler, tp_asv_new ( + TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, + TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA, + TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT, + NULL)); + + tp_base_client_take_handler_filter (priv->handler, tp_asv_new ( + TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, + TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA, + TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT, + TP_PROP_CHANNEL_TYPE_STREAMED_MEDIA_INITIAL_AUDIO, G_TYPE_BOOLEAN, TRUE, + NULL)); + + tp_base_client_take_handler_filter (priv->handler, tp_asv_new ( + TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, + TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA, + TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT, + TP_PROP_CHANNEL_TYPE_STREAMED_MEDIA_INITIAL_VIDEO, G_TYPE_BOOLEAN, TRUE, + NULL)); + + tp_base_client_add_handler_capabilities_varargs (priv->handler, + "org.freedesktop.Telepathy.Channel.Interface.MediaSignalling/ice-udp", + "org.freedesktop.Telepathy.Channel.Interface.MediaSignalling/gtalk-p2p", + NULL); + + if (!tp_base_client_register (priv->handler, &error)) + { + g_warning ("Failed to register Handler: %s", error->message); + g_error_free (error); + } + + g_object_unref (dbus); } static GObject * @@ -159,6 +219,7 @@ empathy_call_factory_new_call_with_streams (EmpathyCallFactory *factory, handler, TRUE); g_object_unref (handler); +#endif } @@ -176,26 +237,75 @@ empathy_call_factory_new_call (EmpathyCallFactory *factory, empathy_call_factory_new_call_with_streams (factory, contact, TRUE, FALSE); } -void -empathy_call_factory_claim_channel (EmpathyCallFactory *factory, - EmpathyDispatchOperation *operation) +static void +create_call_handler (EmpathyCallFactory *factory, + EmpathyTpCall *call) { EmpathyCallHandler *handler; - EmpathyTpCall *call; g_return_if_fail (factory != NULL); - g_return_if_fail (operation != NULL); - - call = EMPATHY_TP_CALL ( - empathy_dispatch_operation_get_channel_wrapper (operation)); handler = empathy_call_handler_new_for_channel (call); - empathy_dispatch_operation_claim (operation); - /* FIXME should actually look at the channel */ g_signal_emit (factory, signals[NEW_CALL_HANDLER], 0, handler, FALSE); g_object_unref (handler); } +static void +call_status_changed_cb (EmpathyTpCall *call, + GParamSpec *spec, + EmpathyCallFactory *self) +{ + if (empathy_tp_call_get_status (call) <= EMPATHY_TP_CALL_STATUS_READYING) + return; + + create_call_handler (self, call); + + g_signal_handlers_disconnect_by_func (call, call_status_changed_cb, self); + g_object_unref (call); +} + +static void +handle_channels_cb (TpSimpleHandler *handler, + TpAccount *account, + TpConnection *connection, + GList *channels, + GList *requests_satisfied, + gint64 user_action_time, + TpHandleChannelsContext *context, + gpointer user_data) +{ + EmpathyCallFactory *self = user_data; + GList *l; + + for (l = channels; l != NULL; l = g_list_next (l)) + { + TpChannel *channel = l->data; + EmpathyTpCall *call; + + if (tp_proxy_get_invalidated (channel) != NULL) + continue; + + if (tp_channel_get_channel_type_id (channel) != + TP_IFACE_QUARK_CHANNEL_TYPE_STREAMED_MEDIA) + continue; + + call = empathy_tp_call_new (channel); + + if (empathy_tp_call_get_status (call) <= EMPATHY_TP_CALL_STATUS_READYING) + { + /* We have to wait that the TpCall is ready as the + * call-handler rely on it. */ + tp_g_signal_connect_object (call, "notify::status", + G_CALLBACK (call_status_changed_cb), self, 0); + continue; + } + + create_call_handler (self, call); + g_object_unref (call); + } + + tp_handle_channels_context_accept (context); +} diff --git a/libempathy/empathy-call-factory.h b/libempathy/empathy-call-factory.h index 27b205973..f7cd9d240 100644 --- a/libempathy/empathy-call-factory.h +++ b/libempathy/empathy-call-factory.h @@ -70,9 +70,6 @@ void empathy_call_factory_new_call (EmpathyCallFactory *factory, void empathy_call_factory_new_call_with_streams (EmpathyCallFactory *factory, EmpathyContact *contact, gboolean initial_audio, gboolean initial_video); -void empathy_call_factory_claim_channel (EmpathyCallFactory *factory, - EmpathyDispatchOperation *operation); - G_END_DECLS #endif /* #ifndef __EMPATHY_CALL_FACTORY_H__*/ -- cgit v1.2.3 From f20aa2a8401a472c6d9d2ffa0979ae8169f1df85 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Mon, 21 Jun 2010 14:55:54 +0200 Subject: remove empathy_call_factory_new_call It's not used any more. --- libempathy/empathy-call-factory.c | 15 --------------- libempathy/empathy-call-factory.h | 3 --- 2 files changed, 18 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-call-factory.c b/libempathy/empathy-call-factory.c index b45b8621b..376ff91e4 100644 --- a/libempathy/empathy-call-factory.c +++ b/libempathy/empathy-call-factory.c @@ -222,21 +222,6 @@ empathy_call_factory_new_call_with_streams (EmpathyCallFactory *factory, #endif } - -/** - * empathy_call_factory_new_call: - * @factory: an #EmpathyCallFactory - * @contact: an #EmpathyContact - * - * Initiate a new call with @contact. - */ -void -empathy_call_factory_new_call (EmpathyCallFactory *factory, - EmpathyContact *contact) -{ - empathy_call_factory_new_call_with_streams (factory, contact, TRUE, FALSE); -} - static void create_call_handler (EmpathyCallFactory *factory, EmpathyTpCall *call) diff --git a/libempathy/empathy-call-factory.h b/libempathy/empathy-call-factory.h index f7cd9d240..c17163dfe 100644 --- a/libempathy/empathy-call-factory.h +++ b/libempathy/empathy-call-factory.h @@ -64,9 +64,6 @@ EmpathyCallFactory *empathy_call_factory_initialise (void); EmpathyCallFactory *empathy_call_factory_get (void); -void empathy_call_factory_new_call (EmpathyCallFactory *factory, - EmpathyContact *contact); - void empathy_call_factory_new_call_with_streams (EmpathyCallFactory *factory, EmpathyContact *contact, gboolean initial_audio, gboolean initial_video); -- cgit v1.2.3 From eafc9830daea1f750be9b68d7360a8b4b8345e5a Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Mon, 21 Jun 2010 16:21:34 +0200 Subject: tp-call: use the Requested property to check if the call is an incoming one or not --- libempathy/empathy-tp-call.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-tp-call.c b/libempathy/empathy-tp-call.c index 3aae89fce..4c78649a0 100644 --- a/libempathy/empathy-tp-call.c +++ b/libempathy/empathy-tp-call.c @@ -61,7 +61,6 @@ enum PROP_0, PROP_CHANNEL, PROP_CONTACT, - PROP_IS_INCOMING, PROP_STATUS, PROP_AUDIO_STREAM, PROP_VIDEO_STREAM @@ -279,9 +278,7 @@ tp_call_got_contact_cb (TpConnection *connection, } priv->contact = g_object_ref (contact); - priv->is_incoming = TRUE; priv->status = EMPATHY_TP_CALL_STATUS_PENDING; - g_object_notify (G_OBJECT (call), "is-incoming"); g_object_notify (G_OBJECT (call), "contact"); g_object_notify (G_OBJECT (call), "status"); } @@ -333,9 +330,7 @@ empathy_tp_call_to (EmpathyTpCall *call, EmpathyContact *contact, g_assert (audio || video); priv->contact = g_object_ref (contact); - priv->is_incoming = FALSE; priv->status = EMPATHY_TP_CALL_STATUS_PENDING; - g_object_notify (G_OBJECT (call), "is-incoming"); g_object_notify (G_OBJECT (call), "contact"); g_object_notify (G_OBJECT (call), "status"); @@ -407,6 +402,8 @@ tp_call_constructor (GType type, GObject *object; EmpathyTpCall *call; EmpathyTpCallPriv *priv; + GHashTable *props; + gboolean requested; object = G_OBJECT_CLASS (empathy_tp_call_parent_class)->constructor (type, n_construct_params, construct_params); @@ -430,6 +427,12 @@ tp_call_constructor (GType type, tp_cli_channel_type_streamed_media_call_list_streams (priv->channel, -1, tp_call_request_streams_cb, NULL, NULL, G_OBJECT (call)); + /* Is the call incoming? */ + props = tp_channel_borrow_immutable_properties (priv->channel); + requested = tp_asv_get_boolean (props, TP_PROP_CHANNEL_REQUESTED, NULL); + + priv->is_incoming = !requested; + /* Update status when members changes */ tp_call_update_status (call); g_signal_connect_swapped (priv->channel, "group-members-changed", @@ -513,9 +516,6 @@ tp_call_get_property (GObject *object, case PROP_CONTACT: g_value_set_object (value, priv->contact); break; - case PROP_IS_INCOMING: - g_value_set_boolean (value, priv->is_incoming); - break; case PROP_STATUS: g_value_set_uint (value, priv->status); break; @@ -553,10 +553,6 @@ empathy_tp_call_class_init (EmpathyTpCallClass *klass) g_param_spec_object ("contact", "Call contact", "Call contact", EMPATHY_TYPE_CONTACT, G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); - g_object_class_install_property (object_class, PROP_IS_INCOMING, - g_param_spec_boolean ("is-incoming", "Is media stream incoming", - "Is media stream incoming", FALSE, G_PARAM_READABLE | - G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); g_object_class_install_property (object_class, PROP_STATUS, g_param_spec_uint ("status", "Call status", "Call status", 0, 255, 0, G_PARAM_READABLE | G_PARAM_STATIC_NICK | -- cgit v1.2.3 From 066f1c90a7e6461ccb8ea11a2f511604abbd2472 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Mon, 21 Jun 2010 16:47:18 +0200 Subject: tp-call: use TargetHandle to get the remote contact --- libempathy/empathy-tp-call.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-tp-call.c b/libempathy/empathy-tp-call.c index 4c78649a0..9758f500b 100644 --- a/libempathy/empathy-tp-call.c +++ b/libempathy/empathy-tp-call.c @@ -278,9 +278,14 @@ tp_call_got_contact_cb (TpConnection *connection, } priv->contact = g_object_ref (contact); - priv->status = EMPATHY_TP_CALL_STATUS_PENDING; + + if (priv->status < EMPATHY_TP_CALL_STATUS_PENDING) + { + priv->status = EMPATHY_TP_CALL_STATUS_PENDING; + g_object_notify (G_OBJECT (call), "status"); + } + g_object_notify (G_OBJECT (call), "contact"); - g_object_notify (G_OBJECT (call), "status"); } static void @@ -298,16 +303,6 @@ tp_call_update_status (EmpathyTpCall *call) tp_intset_iter_init (&iter, set); while (tp_intset_iter_next (&iter)) { - if (priv->contact == NULL && iter.element != self_handle) - { - TpConnection *connection; - - /* We found the remote contact */ - connection = tp_channel_borrow_connection (priv->channel); - empathy_tp_contact_factory_get_from_handle (connection, iter.element, - tp_call_got_contact_cb, NULL, NULL, G_OBJECT (call)); - } - if (priv->status == EMPATHY_TP_CALL_STATUS_PENDING && ((priv->is_incoming && iter.element == self_handle) || (!priv->is_incoming && iter.element != self_handle))) @@ -433,6 +428,12 @@ tp_call_constructor (GType type, priv->is_incoming = !requested; + /* Get the remote contact */ + empathy_tp_contact_factory_get_from_handle ( + tp_channel_borrow_connection (priv->channel), + tp_channel_get_handle (priv->channel, NULL), tp_call_got_contact_cb, + NULL, NULL, object); + /* Update status when members changes */ tp_call_update_status (call); g_signal_connect_swapped (priv->channel, "group-members-changed", -- cgit v1.2.3 From 57459c6892de159e92a90231e8c10e63c566ac32 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Tue, 22 Jun 2010 11:20:32 +0200 Subject: tp-call: use tp_g_signal_connect_object to connect signal on the channel This ensure that the cb won't be called after the TpCall has been destroyed. --- libempathy/empathy-tp-call.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-tp-call.c b/libempathy/empathy-tp-call.c index 9758f500b..dfaf3384b 100644 --- a/libempathy/empathy-tp-call.c +++ b/libempathy/empathy-tp-call.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "empathy-tp-call.h" #include "empathy-tp-contact-factory.h" @@ -436,8 +437,8 @@ tp_call_constructor (GType type, /* Update status when members changes */ tp_call_update_status (call); - g_signal_connect_swapped (priv->channel, "group-members-changed", - G_CALLBACK (tp_call_update_status), call); + tp_g_signal_connect_object (priv->channel, "group-members-changed", + G_CALLBACK (tp_call_update_status), call, G_CONNECT_SWAPPED); return object; } -- cgit v1.2.3 From 2064d5324ec602a7a6c2e9e63d5b406e5228824c Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Tue, 22 Jun 2010 11:25:01 +0200 Subject: empathy_call_factory_new_call_with_streams: request channel using the CD Also allow caller to pass the timestamp and an optionnal callback. --- libempathy/empathy-call-factory.c | 41 ++++++++++++++++++++++++++------------- libempathy/empathy-call-factory.h | 8 +++++++- 2 files changed, 34 insertions(+), 15 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-call-factory.c b/libempathy/empathy-call-factory.c index 376ff91e4..65ab88359 100644 --- a/libempathy/empathy-call-factory.c +++ b/libempathy/empathy-call-factory.c @@ -26,6 +26,7 @@ #include #include +#include "empathy-dispatcher.h" #include "empathy-marshal.h" #include "empathy-call-factory.h" #include "empathy-utils.h" @@ -205,21 +206,33 @@ void empathy_call_factory_new_call_with_streams (EmpathyCallFactory *factory, EmpathyContact *contact, gboolean initial_audio, - gboolean initial_video) + gboolean initial_video, + gint64 timestamp, + EmpathyDispatcherRequestCb callback, + gpointer user_data) { - EmpathyCallHandler *handler; - - g_return_if_fail (factory != NULL); - g_return_if_fail (contact != NULL); - - handler = empathy_call_handler_new_for_contact_with_streams (contact, - initial_audio, initial_video); - - g_signal_emit (factory, signals[NEW_CALL_HANDLER], 0, - handler, TRUE); - - g_object_unref (handler); -#endif + EmpathyDispatcher *dispatcher; + GHashTable *request; + + request = tp_asv_new ( + TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, + TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA, + TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT, + TP_PROP_CHANNEL_TARGET_HANDLE, G_TYPE_UINT, + empathy_contact_get_handle (contact), + TP_PROP_CHANNEL_TYPE_STREAMED_MEDIA_INITIAL_AUDIO, G_TYPE_BOOLEAN, + initial_audio, + TP_PROP_CHANNEL_TYPE_STREAMED_MEDIA_INITIAL_VIDEO, G_TYPE_BOOLEAN, + initial_video, + NULL); + + dispatcher = empathy_dispatcher_dup_singleton (); + + empathy_dispatcher_create_channel (dispatcher, + empathy_contact_get_connection (contact), request, timestamp, callback, + user_data); + + g_object_unref (dispatcher); } static void diff --git a/libempathy/empathy-call-factory.h b/libempathy/empathy-call-factory.h index c17163dfe..b9b812b8d 100644 --- a/libempathy/empathy-call-factory.h +++ b/libempathy/empathy-call-factory.h @@ -25,6 +25,7 @@ #include #include +#include G_BEGIN_DECLS @@ -65,7 +66,12 @@ EmpathyCallFactory *empathy_call_factory_initialise (void); EmpathyCallFactory *empathy_call_factory_get (void); void empathy_call_factory_new_call_with_streams (EmpathyCallFactory *factory, - EmpathyContact *contact, gboolean initial_audio, gboolean initial_video); + EmpathyContact *contact, + gboolean initial_audio, + gboolean initial_video, + gint64 timestamp, + EmpathyDispatcherRequestCb callback, + gpointer user_data); G_END_DECLS -- cgit v1.2.3 From bd2d501f03e157f8f26a52f75e06dcb49621f663 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Tue, 22 Jun 2010 11:28:00 +0200 Subject: empathy_call_handler_start_call: use empathy_call_factory_new_call_with_streams --- libempathy/empathy-call-handler.c | 55 +++++++++------------------------------ 1 file changed, 13 insertions(+), 42 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-call-handler.c b/libempathy/empathy-call-handler.c index ec8b055c2..32c80916e 100644 --- a/libempathy/empathy-call-handler.c +++ b/libempathy/empathy-call-handler.c @@ -29,6 +29,7 @@ #include #include "empathy-call-handler.h" +#include "empathy-call-factory.h" #include "empathy-dispatcher.h" #include "empathy-marshal.h" #include "empathy-utils.h" @@ -464,18 +465,21 @@ empathy_call_handler_start_tpfs (EmpathyCallHandler *self) static void empathy_call_handler_request_cb (EmpathyDispatchOperation *operation, - const GError *error, gpointer user_data) + const GError *error, + gpointer user_data) { EmpathyCallHandler *self = EMPATHY_CALL_HANDLER (user_data); EmpathyCallHandlerPriv *priv = GET_PRIV (self); + TpChannel *channel; if (error != NULL) return; - priv->call = EMPATHY_TP_CALL ( - empathy_dispatch_operation_get_channel_wrapper (operation)); + channel = empathy_dispatch_operation_get_channel (operation); + g_assert (channel != NULL); + + priv->call = empathy_tp_call_new (channel); - g_object_ref (priv->call); g_object_notify (G_OBJECT (self), "tp-call"); empathy_call_handler_start_tpfs (self); @@ -492,11 +496,6 @@ empathy_call_handler_start_call (EmpathyCallHandler *handler, { EmpathyCallHandlerPriv *priv = GET_PRIV (handler); - EmpathyDispatcher *dispatcher; - TpConnection *connection; - GList *classes; - GValue *value; - GHashTable *request; if (priv->call != NULL) { @@ -505,41 +504,13 @@ empathy_call_handler_start_call (EmpathyCallHandler *handler, return; } + /* No TpCall object (we are redialing). Request a new media channel that + * will be used to create a new EmpathyTpCall. */ g_assert (priv->contact != NULL); - dispatcher = empathy_dispatcher_dup_singleton (); - connection = empathy_contact_get_connection (priv->contact); - classes = empathy_dispatcher_find_requestable_channel_classes - (dispatcher, connection, TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA, - TP_HANDLE_TYPE_CONTACT, NULL); - - if (classes == NULL) - return; - - g_list_free (classes); - - request = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, - (GDestroyNotify) tp_g_value_slice_free); - - /* org.freedesktop.Telepathy.Channel.ChannelType */ - value = tp_g_value_slice_new (G_TYPE_STRING); - g_value_set_string (value, TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA); - g_hash_table_insert (request, TP_IFACE_CHANNEL ".ChannelType", value); - - /* org.freedesktop.Telepathy.Channel.TargetHandleType */ - value = tp_g_value_slice_new (G_TYPE_UINT); - g_value_set_uint (value, TP_HANDLE_TYPE_CONTACT); - g_hash_table_insert (request, TP_IFACE_CHANNEL ".TargetHandleType", value); - - /* org.freedesktop.Telepathy.Channel.TargetHandle*/ - value = tp_g_value_slice_new (G_TYPE_UINT); - g_value_set_uint (value, empathy_contact_get_handle (priv->contact)); - g_hash_table_insert (request, TP_IFACE_CHANNEL ".TargetHandle", value); - - empathy_dispatcher_create_channel (dispatcher, connection, - request, timestamp, empathy_call_handler_request_cb, handler); - - g_object_unref (dispatcher); + empathy_call_factory_new_call_with_streams (empathy_call_factory_get (), + priv->contact, priv->initial_audio, priv->initial_video, timestamp, + empathy_call_handler_request_cb, handler); } /** -- cgit v1.2.3 From b379e5e873e51d3bcad1fc055b2f7974267c7daa Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Tue, 22 Jun 2010 11:37:20 +0200 Subject: empathy_tp_call_accept_incoming_call: early return if the call is not an incoming one We use to rely in the call handler on the presence or not of the TpCall object to check if the call was incoming or not. But now TpCall object are created earlier so that's not true any more. --- libempathy/empathy-tp-call.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'libempathy') diff --git a/libempathy/empathy-tp-call.c b/libempathy/empathy-tp-call.c index dfaf3384b..583e9fc9f 100644 --- a/libempathy/empathy-tp-call.c +++ b/libempathy/empathy-tp-call.c @@ -621,7 +621,9 @@ empathy_tp_call_accept_incoming_call (EmpathyTpCall *call) g_return_if_fail (EMPATHY_IS_TP_CALL (call)); g_return_if_fail (priv->status == EMPATHY_TP_CALL_STATUS_PENDING); - g_return_if_fail (priv->is_incoming); + + if (!priv->is_incoming) + return; DEBUG ("Accepting incoming call"); -- cgit v1.2.3 From 31e110e96745858e11fce4fffab2334d5e32a873 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Tue, 22 Jun 2010 11:38:39 +0200 Subject: remove empathy_call_handler_new_for_contact_with_streams --- libempathy/empathy-call-handler.c | 21 --------------------- libempathy/empathy-call-handler.h | 3 --- 2 files changed, 24 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-call-handler.c b/libempathy/empathy-call-handler.c index 32c80916e..c3cbf4ee7 100644 --- a/libempathy/empathy-call-handler.c +++ b/libempathy/empathy-call-handler.c @@ -279,27 +279,6 @@ empathy_call_handler_new_for_contact (EmpathyContact *contact) "contact", contact, NULL)); } -/** - * empathy_call_handler_new_for_contact_with_streams: - * @contact: an #EmpathyContact - * @audio: if %TRUE the call will be started with audio - * @video: if %TRUE the call will be started with video - * - * Creates a new #EmpathyCallHandler with contact @contact. - * - * Return value: a new #EmpathyCallHandler - */ -EmpathyCallHandler * -empathy_call_handler_new_for_contact_with_streams (EmpathyContact *contact, - gboolean audio, gboolean video) -{ - return EMPATHY_CALL_HANDLER (g_object_new (EMPATHY_TYPE_CALL_HANDLER, - "contact", contact, - "initial-audio", audio, - "initial-video", video, - NULL)); -} - EmpathyCallHandler * empathy_call_handler_new_for_channel (EmpathyTpCall *call) { diff --git a/libempathy/empathy-call-handler.h b/libempathy/empathy-call-handler.h index f0be11ba5..942fa7520 100644 --- a/libempathy/empathy-call-handler.h +++ b/libempathy/empathy-call-handler.h @@ -64,9 +64,6 @@ GType empathy_call_handler_get_type (void); EmpathyCallHandler * empathy_call_handler_new_for_contact ( EmpathyContact *contact); -EmpathyCallHandler * empathy_call_handler_new_for_contact_with_streams ( - EmpathyContact *contact, gboolean audio, gboolean video); - EmpathyCallHandler * empathy_call_handler_new_for_channel ( EmpathyTpCall *call); -- cgit v1.2.3 From d22972c5b30ef8b771a148e57d80a9f4d54424c8 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Tue, 22 Jun 2010 11:42:54 +0200 Subject: remove empathy_tp_call_to We don't need it any more: - The TpContact is now always set during object construction - The status is changed once the contact has been set - We don't need to request streams any more as we use Initial{Audio,Video} --- libempathy/empathy-call-handler.c | 3 --- libempathy/empathy-tp-call.c | 22 ---------------------- libempathy/empathy-tp-call.h | 3 --- 3 files changed, 28 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-call-handler.c b/libempathy/empathy-call-handler.c index c3cbf4ee7..9ba115a60 100644 --- a/libempathy/empathy-call-handler.c +++ b/libempathy/empathy-call-handler.c @@ -463,9 +463,6 @@ empathy_call_handler_request_cb (EmpathyDispatchOperation *operation, empathy_call_handler_start_tpfs (self); - empathy_tp_call_to (priv->call, priv->contact, - priv->initial_audio, priv->initial_video); - empathy_dispatch_operation_claim (operation); } diff --git a/libempathy/empathy-tp-call.c b/libempathy/empathy-tp-call.c index 583e9fc9f..16689e608 100644 --- a/libempathy/empathy-tp-call.c +++ b/libempathy/empathy-tp-call.c @@ -316,28 +316,6 @@ tp_call_update_status (EmpathyTpCall *call) g_object_unref (call); } -void -empathy_tp_call_to (EmpathyTpCall *call, EmpathyContact *contact, - gboolean audio, gboolean video) -{ - EmpathyTpCallPriv *priv = GET_PRIV (call); - EmpathyCapabilities capabilities = 0; - - g_assert (audio || video); - - priv->contact = g_object_ref (contact); - priv->status = EMPATHY_TP_CALL_STATUS_PENDING; - g_object_notify (G_OBJECT (call), "contact"); - g_object_notify (G_OBJECT (call), "status"); - - if (video) - capabilities |= EMPATHY_CAPABILITIES_VIDEO; - if (audio) - capabilities |= EMPATHY_CAPABILITIES_AUDIO; - - tp_call_request_streams_for_capabilities (call, capabilities); -} - static void tp_call_channel_invalidated_cb (TpChannel *channel, GQuark domain, diff --git a/libempathy/empathy-tp-call.h b/libempathy/empathy-tp-call.h index ff51055e7..d866a2e6e 100644 --- a/libempathy/empathy-tp-call.h +++ b/libempathy/empathy-tp-call.h @@ -76,9 +76,6 @@ GType empathy_tp_call_get_type (void) G_GNUC_CONST; EmpathyTpCall *empathy_tp_call_new (TpChannel *channel); void empathy_tp_call_close (EmpathyTpCall *call); -void empathy_tp_call_to (EmpathyTpCall *call, EmpathyContact *contact, - gboolean audio, gboolean video); - void empathy_tp_call_accept_incoming_call (EmpathyTpCall *call); void empathy_tp_call_request_video_stream_direction (EmpathyTpCall *call, gboolean is_sending); -- cgit v1.2.3