aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>2009-02-03 17:03:26 +0800
committerxclaesse <xclaesse@4ee84921-47dd-4033-b63a-18d7a039a3e4>2009-02-03 17:03:26 +0800
commit852cae7cf82c73e731cf49c76e9e9fe7fcef53e4 (patch)
tree7c2372779abc79af9d3d391338616b75cda1acdb
parent092c060e8f7d461a9340b192e8d70e7af5558796 (diff)
downloadgsoc2013-empathy-852cae7cf82c73e731cf49c76e9e9fe7fcef53e4.tar
gsoc2013-empathy-852cae7cf82c73e731cf49c76e9e9fe7fcef53e4.tar.gz
gsoc2013-empathy-852cae7cf82c73e731cf49c76e9e9fe7fcef53e4.tar.bz2
gsoc2013-empathy-852cae7cf82c73e731cf49c76e9e9fe7fcef53e4.tar.lz
gsoc2013-empathy-852cae7cf82c73e731cf49c76e9e9fe7fcef53e4.tar.xz
gsoc2013-empathy-852cae7cf82c73e731cf49c76e9e9fe7fcef53e4.tar.zst
gsoc2013-empathy-852cae7cf82c73e731cf49c76e9e9fe7fcef53e4.zip
Let the event-manager manage the sounds
Let the event-manager handle sounds instead of the main window. Also make the incoming phone sound be played in a loop. Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk> git-svn-id: svn+ssh://svn.gnome.org/svn/empathy/trunk@2393 4ee84921-47dd-4033-b63a-18d7a039a3e4
-rw-r--r--src/empathy-event-manager.c109
-rw-r--r--src/empathy-main-window.c3
2 files changed, 109 insertions, 3 deletions
diff --git a/src/empathy-event-manager.c b/src/empathy-event-manager.c
index 3d49127fe..15a783947 100644
--- a/src/empathy-event-manager.c
+++ b/src/empathy-event-manager.c
@@ -37,8 +37,10 @@
#include <libempathy-gtk/empathy-images.h>
#include <libempathy-gtk/empathy-contact-dialogs.h>
+#include <libempathy-gtk/empathy-ui-utils.h>
#include "empathy-event-manager.h"
+#include "empathy-main-window.h"
#include "empathy-tube-dispatch.h"
#define DEBUG_FLAG EMPATHY_DEBUG_DISPATCHER
@@ -66,6 +68,10 @@ typedef struct {
GSList *events;
/* Ongoing approvals */
GSList *approvals;
+
+ /* voip ringing sound */
+ guint voip_timeout;
+ gint ringing;
} EmpathyEventManagerPriv;
typedef struct _EventPriv EventPriv;
@@ -141,6 +147,81 @@ event_free (EventPriv *event)
g_slice_free (EventPriv, event);
}
+static void event_manager_ringing_finished_cb (ca_context *c, guint id,
+ int error_code, gpointer user_data);
+
+static gboolean
+event_manager_ringing_timeout_cb (gpointer data)
+{
+ EmpathyEventManager *manager = EMPATHY_EVENT_MANAGER (data);
+ EmpathyEventManagerPriv *priv = GET_PRIV (manager);
+
+ priv->voip_timeout = 0;
+
+ empathy_sound_play_full (empathy_main_window_get (),
+ EMPATHY_SOUND_PHONE_INCOMING, event_manager_ringing_finished_cb,
+ manager);
+
+ return FALSE;
+}
+
+static gboolean
+event_manager_ringing_idle_cb (gpointer data)
+{
+ EmpathyEventManager *manager = EMPATHY_EVENT_MANAGER (data);
+ EmpathyEventManagerPriv *priv = GET_PRIV (manager);
+
+ if (priv->ringing > 0)
+ priv->voip_timeout = g_timeout_add (500, event_manager_ringing_timeout_cb,
+ data);
+
+ return FALSE;
+}
+
+static void
+event_manager_ringing_finished_cb (ca_context *c, guint id, int error_code,
+ gpointer user_data)
+{
+ if (error_code == CA_ERROR_CANCELED)
+ return;
+
+ g_idle_add (event_manager_ringing_idle_cb, user_data);
+}
+
+static void
+event_manager_start_ringing (EmpathyEventManager *manager)
+{
+ EmpathyEventManagerPriv *priv = GET_PRIV (manager);
+
+ priv->ringing++;
+
+ if (priv->ringing == 1)
+ {
+ empathy_sound_play_full (empathy_main_window_get (),
+ EMPATHY_SOUND_PHONE_INCOMING, event_manager_ringing_finished_cb,
+ manager);
+ }
+}
+
+static void
+event_manager_stop_ringing (EmpathyEventManager *manager)
+{
+ EmpathyEventManagerPriv *priv = GET_PRIV (manager);
+
+ priv->ringing--;
+
+ if (priv->ringing > 0)
+ return;
+
+ empathy_sound_stop (EMPATHY_SOUND_PHONE_INCOMING);
+
+ if (priv->voip_timeout != 0)
+ {
+ g_source_remove (priv->voip_timeout);
+ priv->voip_timeout = 0;
+ }
+}
+
static void
event_remove (EventPriv *event)
{
@@ -271,6 +352,10 @@ event_manager_chat_message_received_cb (EmpathyTpChat *tp_chat,
msg, approval, event_text_channel_process_func, NULL);
g_free (header);
+ empathy_sound_play (empathy_main_window_get (),
+ EMPATHY_SOUND_CONVERSATION_NEW);
+
+ g_free (msg);
}
static void
@@ -279,6 +364,18 @@ event_manager_approval_done (EventManagerApproval *approval)
EmpathyEventManagerPriv *priv = GET_PRIV (approval->manager);
GSList *l;
+ if (approval->operation != NULL)
+ {
+ GQuark channel_type;
+
+ channel_type = empathy_dispatch_operation_get_channel_type_id (
+ approval->operation);
+ if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_STREAMED_MEDIA)
+ {
+ event_manager_stop_ringing (approval->manager);
+ }
+ }
+
priv->approvals = g_slist_remove (priv->approvals, approval);
for (l = priv->events; l; l = l->next)
@@ -339,6 +436,9 @@ event_manager_media_channel_got_name_cb (EmpathyContact *contact,
approval, event_channel_process_func, NULL);
g_free (header);
+ event_manager_start_ringing (approval->manager);
+
+ g_free (msg);
}
static void
@@ -397,6 +497,11 @@ event_manager_add_tube_approval (EventManagerApproval *approval,
msg, approval, event_manager_tube_approved_cb, approval);
g_free (header);
+ /* FIXME better sound for incoming tubes ? */
+ empathy_sound_play (empathy_main_window_get (),
+ EMPATHY_SOUND_CONVERSATION_NEW);
+
+ g_free (msg);
}
static void
@@ -528,6 +633,10 @@ event_manager_approve_channel_cb (EmpathyDispatcher *dispatcher,
event_manager_add (manager, contact, EMPATHY_IMAGE_DOCUMENT_SEND,
header, NULL, approval, event_channel_process_func, NULL);
+ /* FIXME better sound for incoming file transfers ?*/
+ empathy_sound_play (empathy_main_window_get (),
+ EMPATHY_SOUND_CONVERSATION_NEW);
+
g_object_unref (factory);
g_object_unref (account);
g_free (header);
diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c
index 57872a7b5..77fa538d6 100644
--- a/src/empathy-main-window.c
+++ b/src/empathy-main-window.c
@@ -292,9 +292,6 @@ main_window_flash_cb (EmpathyMainWindow *window)
static void
main_window_flash_start (EmpathyMainWindow *window)
{
- empathy_sound_play (GTK_WIDGET (window->window),
- EMPATHY_SOUND_CONVERSATION_NEW);
-
if (window->flash_timeout_id != 0) {
return;
}