aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-06-22 23:26:10 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-06-22 23:26:10 +0800
commit09df593e038c3f7bfed05294155dbffeabba6ea0 (patch)
tree8c6fd98335639d995b0bf0a84ebb419221529b5c
parent603a22855ea710b276892654b86a529167f8d32b (diff)
parent89ca74a938a753c1137cc9f008619805622e490c (diff)
downloadgsoc2013-empathy-09df593e038c3f7bfed05294155dbffeabba6ea0.tar
gsoc2013-empathy-09df593e038c3f7bfed05294155dbffeabba6ea0.tar.gz
gsoc2013-empathy-09df593e038c3f7bfed05294155dbffeabba6ea0.tar.bz2
gsoc2013-empathy-09df593e038c3f7bfed05294155dbffeabba6ea0.tar.lz
gsoc2013-empathy-09df593e038c3f7bfed05294155dbffeabba6ea0.tar.xz
gsoc2013-empathy-09df593e038c3f7bfed05294155dbffeabba6ea0.tar.zst
gsoc2013-empathy-09df593e038c3f7bfed05294155dbffeabba6ea0.zip
Merge branch 'av-handler-622368'
-rw-r--r--libempathy-gtk/empathy-contact-menu.c6
-rw-r--r--libempathy-gtk/empathy-new-call-dialog.c40
-rw-r--r--libempathy/empathy-call-factory.c174
-rw-r--r--libempathy/empathy-call-factory.h14
-rw-r--r--libempathy/empathy-call-handler.c79
-rw-r--r--libempathy/empathy-call-handler.h3
-rw-r--r--libempathy/empathy-dispatch-operation.c30
-rw-r--r--libempathy/empathy-tp-call.c76
-rw-r--r--libempathy/empathy-tp-call.h3
-rw-r--r--src/empathy.c36
10 files changed, 216 insertions, 245 deletions
diff --git a/libempathy-gtk/empathy-contact-menu.c b/libempathy-gtk/empathy-contact-menu.c
index 6dfe63a6e..7c18694ae 100644
--- a/libempathy-gtk/empathy-contact-menu.c
+++ b/libempathy-gtk/empathy-contact-menu.c
@@ -248,7 +248,8 @@ empathy_contact_audio_call_menu_item_activated (GtkMenuItem *item,
EmpathyCallFactory *factory;
factory = empathy_call_factory_get ();
- empathy_call_factory_new_call_with_streams (factory, contact, TRUE, FALSE);
+ empathy_call_factory_new_call_with_streams (factory, contact, TRUE, FALSE,
+ gtk_get_current_event_time (), NULL, NULL);
}
GtkWidget *
@@ -280,7 +281,8 @@ empathy_contact_video_call_menu_item_activated (GtkMenuItem *item,
EmpathyCallFactory *factory;
factory = empathy_call_factory_get ();
- empathy_call_factory_new_call_with_streams (factory, contact, TRUE, TRUE);
+ empathy_call_factory_new_call_with_streams (factory, contact, TRUE, TRUE,
+ gtk_get_current_event_time (), NULL, NULL);
}
GtkWidget *
diff --git a/libempathy-gtk/empathy-new-call-dialog.c b/libempathy-gtk/empathy-new-call-dialog.c
index 10d34f36c..27ec3a2cd 100644
--- a/libempathy-gtk/empathy-new-call-dialog.c
+++ b/libempathy-gtk/empathy-new-call-dialog.c
@@ -69,24 +69,31 @@ struct _EmpathyNewCallDialogPriv {
*/
static void
-got_contact_cb (TpConnection *connection,
- EmpathyContact *contact,
- const GError *error,
- gpointer user_data,
- GObject *object)
+call_contact (TpConnection *connection,
+ const gchar *contact_id,
+ gboolean video,
+ gint64 timestamp)
{
- EmpathyCallFactory *call_factory;
- gboolean video = GPOINTER_TO_UINT (user_data);
+ 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_ID, G_TYPE_STRING, contact_id,
+ TP_PROP_CHANNEL_TYPE_STREAMED_MEDIA_INITIAL_AUDIO, G_TYPE_BOOLEAN,
+ TRUE,
+ TP_PROP_CHANNEL_TYPE_STREAMED_MEDIA_INITIAL_VIDEO, G_TYPE_BOOLEAN,
+ video,
+ NULL);
- if (error != NULL)
- {
- DEBUG ("Failed: %s", error->message);
- return;
- }
+ dispatcher = empathy_dispatcher_dup_singleton ();
+
+ empathy_dispatcher_create_channel (dispatcher, connection, request,
+ timestamp, NULL, NULL);
- call_factory = empathy_call_factory_get ();
- empathy_call_factory_new_call_with_streams (call_factory, contact, TRUE,
- video);
+ g_object_unref (dispatcher);
}
static void
@@ -108,8 +115,7 @@ empathy_new_call_dialog_response (GtkDialog *dialog, int response_id)
* we return from this function. */
video = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->check_video));
- empathy_tp_contact_factory_get_from_id (connection, contact_id,
- got_contact_cb, GUINT_TO_POINTER (video), NULL, NULL);
+ call_contact (connection, contact_id, video, gtk_get_current_event_time ());
out:
gtk_widget_destroy (GTK_WIDGET (dialog));
diff --git a/libempathy/empathy-call-factory.c b/libempathy/empathy-call-factory.c
index d02b58327..65ab88359 100644
--- a/libempathy/empathy-call-factory.c
+++ b/libempathy/empathy-call-factory.c
@@ -22,12 +22,26 @@
#include <stdio.h>
#include <stdlib.h>
+#include <telepathy-glib/simple-handler.h>
+#include <telepathy-glib/interfaces.h>
+#include <telepathy-glib/util.h>
+
+#include "empathy-dispatcher.h"
#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 +53,7 @@ static guint signals[LAST_SIGNAL] = {0};
/* private structure */
typedef struct {
+ TpBaseClient *handler;
gboolean dispose_has_run;
} EmpathyCallFactoryPriv;
@@ -51,8 +66,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 *
@@ -145,57 +206,104 @@ 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)
+{
+ 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
+create_call_handler (EmpathyCallFactory *factory,
+ EmpathyTpCall *call)
{
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);
+ handler = empathy_call_handler_new_for_channel (call);
g_signal_emit (factory, signals[NEW_CALL_HANDLER], 0,
- handler, TRUE);
+ handler, FALSE);
g_object_unref (handler);
}
-
-/**
- * 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)
+static void
+call_status_changed_cb (EmpathyTpCall *call,
+ GParamSpec *spec,
+ EmpathyCallFactory *self)
{
- empathy_call_factory_new_call_with_streams (factory, contact, TRUE, FALSE);
+ 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);
}
-void
-empathy_call_factory_claim_channel (EmpathyCallFactory *factory,
- EmpathyDispatchOperation *operation)
+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)
{
- EmpathyCallHandler *handler;
- EmpathyTpCall *call;
+ EmpathyCallFactory *self = user_data;
+ GList *l;
- g_return_if_fail (factory != NULL);
- g_return_if_fail (operation != NULL);
+ for (l = channels; l != NULL; l = g_list_next (l))
+ {
+ TpChannel *channel = l->data;
+ EmpathyTpCall *call;
- call = EMPATHY_TP_CALL (
- empathy_dispatch_operation_get_channel_wrapper (operation));
+ if (tp_proxy_get_invalidated (channel) != NULL)
+ continue;
- handler = empathy_call_handler_new_for_channel (call);
- empathy_dispatch_operation_claim (operation);
+ if (tp_channel_get_channel_type_id (channel) !=
+ TP_IFACE_QUARK_CHANNEL_TYPE_STREAMED_MEDIA)
+ continue;
- /* FIXME should actually look at the channel */
- g_signal_emit (factory, signals[NEW_CALL_HANDLER], 0,
- handler, FALSE);
+ call = empathy_tp_call_new (channel);
- g_object_unref (handler);
-}
+ 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..b9b812b8d 100644
--- a/libempathy/empathy-call-factory.h
+++ b/libempathy/empathy-call-factory.h
@@ -25,6 +25,7 @@
#include <libempathy/empathy-dispatch-operation.h>
#include <libempathy/empathy-call-handler.h>
+#include <libempathy/empathy-dispatcher.h>
G_BEGIN_DECLS
@@ -64,14 +65,13 @@ 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);
-
-void empathy_call_factory_claim_channel (EmpathyCallFactory *factory,
- EmpathyDispatchOperation *operation);
+ EmpathyContact *contact,
+ gboolean initial_audio,
+ gboolean initial_video,
+ gint64 timestamp,
+ EmpathyDispatcherRequestCb callback,
+ gpointer user_data);
G_END_DECLS
diff --git a/libempathy/empathy-call-handler.c b/libempathy/empathy-call-handler.c
index ec8b055c2..9ba115a60 100644
--- a/libempathy/empathy-call-handler.c
+++ b/libempathy/empathy-call-handler.c
@@ -29,6 +29,7 @@
#include <telepathy-farsight/stream.h>
#include "empathy-call-handler.h"
+#include "empathy-call-factory.h"
#include "empathy-dispatcher.h"
#include "empathy-marshal.h"
#include "empathy-utils.h"
@@ -278,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)
{
@@ -464,25 +444,25 @@ 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);
- empathy_tp_call_to (priv->call, priv->contact,
- priv->initial_audio, priv->initial_video);
-
empathy_dispatch_operation_claim (operation);
}
@@ -492,11 +472,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 +480,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);
}
/**
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);
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
@@ -442,17 +442,6 @@ empathy_dispatcher_operation_tp_chat_ready_cb (GObject *object,
}
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);
diff --git a/libempathy/empathy-tp-call.c b/libempathy/empathy-tp-call.c
index 3aae89fce..16689e608 100644
--- a/libempathy/empathy-tp-call.c
+++ b/libempathy/empathy-tp-call.c
@@ -25,6 +25,7 @@
#include <telepathy-glib/proxy-subclass.h>
#include <telepathy-glib/dbus.h>
#include <telepathy-glib/interfaces.h>
+#include <telepathy-glib/util.h>
#include "empathy-tp-call.h"
#include "empathy-tp-contact-factory.h"
@@ -61,7 +62,6 @@ enum
PROP_0,
PROP_CHANNEL,
PROP_CONTACT,
- PROP_IS_INCOMING,
PROP_STATUS,
PROP_AUDIO_STREAM,
PROP_VIDEO_STREAM
@@ -279,11 +279,14 @@ 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");
+
+ 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
@@ -301,16 +304,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)))
@@ -323,30 +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->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");
-
- 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,
@@ -407,6 +376,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,10 +401,22 @@ 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;
+
+ /* 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",
- 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;
}
@@ -513,9 +496,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 +533,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 |
@@ -623,7 +599,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");
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);
diff --git a/src/empathy.c b/src/empathy.c
index 2c7ea2a7f..85c0ea8b7 100644
--- a/src/empathy.c
+++ b/src/empathy.c
@@ -140,13 +140,6 @@ dispatch_cb (EmpathyDispatcher *dispatcher,
empathy_dispatch_operation_claim (operation);
}
- else if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_STREAMED_MEDIA)
- {
- EmpathyCallFactory *factory;
-
- factory = empathy_call_factory_get ();
- empathy_call_factory_claim_channel (factory, operation);
- }
else if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_FILE_TRANSFER)
{
EmpathyFTFactory *factory;
@@ -396,15 +389,9 @@ setup_dispatcher (void)
{ TP_IFACE_CHANNEL_TYPE_TEXT, TP_HANDLE_TYPE_ROOM },
/* file transfer to contacts */
{ TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, TP_HANDLE_TYPE_CONTACT },
- /* stream media to contacts */
- { TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA, TP_HANDLE_TYPE_CONTACT },
/* roomlists */
{ TP_IFACE_CHANNEL_TYPE_ROOM_LIST, TP_HANDLE_TYPE_NONE },
};
- gchar *capabilities[] = {
- "org.freedesktop.Telepathy.Channel.Interface.MediaSignalling/ice-udp",
- "org.freedesktop.Telepathy.Channel.Interface.MediaSignalling/gtalk-p2p",
- NULL };
GHashTable *asv;
guint i;
@@ -435,29 +422,8 @@ setup_dispatcher (void)
g_ptr_array_add (filters, asv);
}
- asv = tp_asv_new (
- TP_IFACE_CHANNEL ".ChannelType",
- G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA,
- TP_IFACE_CHANNEL ".TargetHandleType",
- G_TYPE_INT, TP_HANDLE_TYPE_CONTACT,
- TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA ".InitialAudio",
- G_TYPE_BOOLEAN, TRUE,
- NULL);
- g_ptr_array_add (filters, asv);
-
- asv = tp_asv_new (
- TP_IFACE_CHANNEL ".ChannelType",
- G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA,
- TP_IFACE_CHANNEL ".TargetHandleType",
- G_TYPE_INT, TP_HANDLE_TYPE_CONTACT,
- TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA ".InitialVideo",
- G_TYPE_BOOLEAN, TRUE,
- NULL);
- g_ptr_array_add (filters, asv);
-
-
empathy_dispatcher_add_handler (d, PACKAGE_NAME"MoreThanMeetsTheEye",
- filters, capabilities);
+ filters, NULL);
g_ptr_array_foreach (filters, (GFunc) g_hash_table_destroy, NULL);
g_ptr_array_free (filters, TRUE);