aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>2011-02-19 00:42:08 +0800
committerSjoerd Simons <sjoerd.simons@collabora.co.uk>2011-02-23 22:50:43 +0800
commit37dc8d1981d655f72f5abffebc063492037b3da6 (patch)
tree22cd9dc64c10a9d320787220d2360a2f64fa72b4
parentf44380b57b8f1bdfe4b2de41445d21fe99f85c92 (diff)
downloadgsoc2013-empathy-37dc8d1981d655f72f5abffebc063492037b3da6.tar
gsoc2013-empathy-37dc8d1981d655f72f5abffebc063492037b3da6.tar.gz
gsoc2013-empathy-37dc8d1981d655f72f5abffebc063492037b3da6.tar.bz2
gsoc2013-empathy-37dc8d1981d655f72f5abffebc063492037b3da6.tar.lz
gsoc2013-empathy-37dc8d1981d655f72f5abffebc063492037b3da6.tar.xz
gsoc2013-empathy-37dc8d1981d655f72f5abffebc063492037b3da6.tar.zst
gsoc2013-empathy-37dc8d1981d655f72f5abffebc063492037b3da6.zip
EmpathyEventManager: handle Call channels
-rw-r--r--src/empathy-event-manager.c98
-rw-r--r--src/empathy-event-manager.h1
2 files changed, 95 insertions, 4 deletions
diff --git a/src/empathy-event-manager.c b/src/empathy-event-manager.c
index 2e6526fdb..f6c05da85 100644
--- a/src/empathy-event-manager.c
+++ b/src/empathy-event-manager.c
@@ -29,7 +29,13 @@
#include <telepathy-glib/interfaces.h>
#include <telepathy-glib/simple-approver.h>
+#if HAVE_CALL
+ #include <telepathy-yell/telepathy-yell.h>
+#endif
+
#include <libempathy/empathy-idle.h>
+
+#include <libempathy/empathy-channel-factory.h>
#include <libempathy/empathy-tp-contact-factory.h>
#include <libempathy/empathy-contact-manager.h>
#include <libempathy/empathy-tp-chat.h>
@@ -403,6 +409,14 @@ reject_channel_claim_cb (GObject *source,
{
empathy_tp_streamed_media_close (user_data);
}
+#if HAVE_CALL
+ else if (TPY_IS_CALL_CHANNEL (user_data))
+ {
+ tpy_call_channel_hangup_async (user_data,
+ TPY_CALL_STATE_CHANGE_REASON_USER_REQUESTED,
+ "", "", NULL, NULL);
+ }
+#endif
else if (EMPATHY_IS_TP_CHAT (user_data))
{
empathy_tp_chat_leave (user_data);
@@ -484,7 +498,6 @@ event_channel_process_voip_func (EventPriv *event)
GtkWidget *dialog;
GtkWidget *button;
GtkWidget *image;
- EmpathyTpStreamedMedia *call;
gboolean video;
gchar *title;
@@ -494,9 +507,25 @@ event_channel_process_voip_func (EventPriv *event)
return;
}
- call = EMPATHY_TP_STREAMED_MEDIA (event->approval->handler_instance);
-
- video = empathy_tp_streamed_media_has_initial_video (call);
+ if (event->public.type == EMPATHY_EVENT_TYPE_VOIP)
+ {
+ EmpathyTpStreamedMedia *call;
+ call = EMPATHY_TP_STREAMED_MEDIA (event->approval->handler_instance);
+ video = empathy_tp_streamed_media_has_initial_video (call);
+ }
+#if HAVE_CALL
+ else if (event->public.type == EMPATHY_EVENT_TYPE_CALL)
+ {
+ TpyCallChannel *call;
+ call = TPY_CALL_CHANNEL (event->approval->handler_instance);
+ g_object_get (G_OBJECT (call), "initial-video", &video, NULL);
+ }
+#endif
+ else
+ {
+ g_warning ("Unknown event type: %d", event->public.type);
+ return;
+ }
dialog = gtk_message_dialog_new (NULL, 0,
GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE,
@@ -636,6 +665,41 @@ cdo_invalidated_cb (TpProxy *cdo,
event_manager_approval_done (approval);
}
+#if HAVE_CALL
+static void
+event_manager_call_channel_got_contact (EventManagerApproval *approval)
+{
+ EmpathyEventManagerPriv *priv = GET_PRIV (approval->manager);
+ GtkWidget *window = empathy_main_window_dup ();
+ TpyCallChannel *call;
+ gchar *header;
+ gboolean video;
+
+ call = TPY_CALL_CHANNEL (approval->handler_instance);
+
+ g_object_get (G_OBJECT (call), "initial-video", &video, NULL);
+
+ header = g_strdup_printf (
+ video ? _("Incoming video call from %s") :_("Incoming call from %s"),
+ empathy_contact_get_alias (approval->contact));
+
+ event_manager_add (approval->manager, NULL,
+ approval->contact, EMPATHY_EVENT_TYPE_CALL,
+ video ? EMPATHY_IMAGE_VIDEO_CALL : EMPATHY_IMAGE_VOIP,
+ header, NULL, approval,
+ event_channel_process_voip_func, NULL);
+
+ g_free (header);
+
+ priv->ringing++;
+ if (priv->ringing == 1)
+ empathy_sound_start_playing (window,
+ EMPATHY_SOUND_PHONE_INCOMING, MS_BETWEEN_RING);
+
+ g_object_unref (window);
+}
+#endif
+
static void
event_manager_media_channel_got_contact (EventManagerApproval *approval)
{
@@ -870,6 +934,9 @@ find_main_channel (GList *channels)
channel_type = tp_channel_get_channel_type_id (channel);
if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_STREAMED_MEDIA ||
+#if HAVE_CALL
+ channel_type == TPY_IFACE_QUARK_CHANNEL_TYPE_CALL ||
+#endif
channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_FILE_TRANSFER ||
channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_SERVER_AUTHENTICATION)
return channel;
@@ -982,6 +1049,15 @@ approve_channels (TpSimpleApprover *approver,
}
}
+#if HAVE_CALL
+ else if (channel_type == TPY_IFACE_QUARK_CHANNEL_TYPE_CALL)
+ {
+ TpyCallChannel *call = TPY_CALL_CHANNEL (channel);
+
+ approval->handler_instance = G_OBJECT (call);
+ event_manager_call_channel_got_contact (approval);
+ }
+#endif
else if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_FILE_TRANSFER)
{
TpHandle handle;
@@ -1238,6 +1314,7 @@ empathy_event_manager_init (EmpathyEventManager *manager)
EmpathyEventManagerPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (manager,
EMPATHY_TYPE_EVENT_MANAGER, EmpathyEventManagerPriv);
TpDBusDaemon *dbus;
+ EmpathyChannelFactory *factory;
GError *error = NULL;
manager->priv = priv;
@@ -1260,6 +1337,11 @@ empathy_event_manager_init (EmpathyEventManager *manager)
priv->approver = tp_simple_approver_new (dbus, "Empathy.EventManager", FALSE,
approve_channels, manager, NULL);
+ factory = empathy_channel_factory_new ();
+ tp_base_client_set_channel_factory (priv->approver,
+ TP_CLIENT_CHANNEL_FACTORY (factory));
+ g_object_unref (factory);
+
/* Private text channels */
tp_base_client_take_approver_filter (priv->approver,
tp_asv_new (
@@ -1289,6 +1371,14 @@ empathy_event_manager_init (EmpathyEventManager *manager)
TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA,
TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT,
NULL));
+#if HAVE_CALL
+ tp_base_client_take_approver_filter (priv->approver,
+ tp_asv_new (
+ TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
+ TPY_IFACE_CHANNEL_TYPE_CALL,
+ TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT,
+ NULL));
+#endif
/* I don't feel good about doing this, and I'm sorry, but the
* capabilities connection feature is added earlier because it's
diff --git a/src/empathy-event-manager.h b/src/empathy-event-manager.h
index d15f43712..09b146582 100644
--- a/src/empathy-event-manager.h
+++ b/src/empathy-event-manager.h
@@ -51,6 +51,7 @@ struct _EmpathyEventManagerClass {
typedef enum {
EMPATHY_EVENT_TYPE_CHAT,
EMPATHY_EVENT_TYPE_VOIP,
+ EMPATHY_EVENT_TYPE_CALL,
EMPATHY_EVENT_TYPE_TRANSFER,
EMPATHY_EVENT_TYPE_SUBSCRIPTION,
EMPATHY_EVENT_TYPE_PRESENCE,