aboutsummaryrefslogtreecommitdiffstats
path: root/src/empathy-event-manager.c
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@gmail.com>2009-06-26 22:24:34 +0800
committerXavier Claessens <xclaesse@gmail.com>2009-06-26 23:40:10 +0800
commitbef0b0057e4a76924b64c2c3b1d5e2edc237fbe2 (patch)
tree7dd83179ad0c7f0e9c40c23674e7f3d4f5d50074 /src/empathy-event-manager.c
parent53050e14aadcd76d454a5236454e3d44f63f0ddd (diff)
downloadgsoc2013-empathy-bef0b0057e4a76924b64c2c3b1d5e2edc237fbe2.tar
gsoc2013-empathy-bef0b0057e4a76924b64c2c3b1d5e2edc237fbe2.tar.gz
gsoc2013-empathy-bef0b0057e4a76924b64c2c3b1d5e2edc237fbe2.tar.bz2
gsoc2013-empathy-bef0b0057e4a76924b64c2c3b1d5e2edc237fbe2.tar.lz
gsoc2013-empathy-bef0b0057e4a76924b64c2c3b1d5e2edc237fbe2.tar.xz
gsoc2013-empathy-bef0b0057e4a76924b64c2c3b1d5e2edc237fbe2.tar.zst
gsoc2013-empathy-bef0b0057e4a76924b64c2c3b1d5e2edc237fbe2.zip
Port EmpathyEventManager to new empathy-sound API.
Diffstat (limited to 'src/empathy-event-manager.c')
-rw-r--r--src/empathy-event-manager.c97
1 files changed, 16 insertions, 81 deletions
diff --git a/src/empathy-event-manager.c b/src/empathy-event-manager.c
index 35c91c48c..a80aad236 100644
--- a/src/empathy-event-manager.c
+++ b/src/empathy-event-manager.c
@@ -41,7 +41,7 @@
#include <libempathy-gtk/empathy-conf.h>
#include <libempathy-gtk/empathy-images.h>
#include <libempathy-gtk/empathy-contact-dialogs.h>
-#include <libempathy-gtk/empathy-ui-utils.h>
+#include <libempathy-gtk/empathy-sound.h>
#include "empathy-event-manager.h"
#include "empathy-main-window.h"
@@ -54,6 +54,9 @@
#define NOTIFICATION_TIMEOUT 2 /* seconds */
+/* The time interval in milliseconds between 2 incoming rings */
+#define MS_BETWEEN_RING 500
+
typedef struct {
EmpathyEventManager *manager;
EmpathyDispatchOperation *operation;
@@ -78,8 +81,6 @@ typedef struct {
/* Ongoing approvals */
GSList *approvals;
- /* voip ringing sound */
- guint voip_timeout;
gint ringing;
} EmpathyEventManagerPriv;
@@ -165,81 +166,6 @@ 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)
{
@@ -473,7 +399,9 @@ event_manager_approval_done (EventManagerApproval *approval)
approval->operation);
if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_STREAMED_MEDIA)
{
- event_manager_stop_ringing (approval->manager);
+ priv->ringing--;
+ if (priv->ringing == 0)
+ empathy_sound_stop (EMPATHY_SOUND_PHONE_INCOMING);
}
}
@@ -518,6 +446,7 @@ event_manager_operation_invalidated_cb (EmpathyDispatchOperation *operation,
static void
event_manager_media_channel_got_contact (EventManagerApproval *approval)
{
+ EmpathyEventManagerPriv *priv = GET_PRIV (approval->manager);
gchar *header;
header = g_strdup_printf (_("Incoming call from %s"),
@@ -528,7 +457,11 @@ event_manager_media_channel_got_contact (EventManagerApproval *approval)
approval, event_channel_process_voip_func, NULL);
g_free (header);
- event_manager_start_ringing (approval->manager);
+
+ priv->ringing++;
+ if (priv->ringing == 1)
+ empathy_sound_start_playing (empathy_main_window_get (),
+ EMPATHY_SOUND_PHONE_INCOMING, MS_BETWEEN_RING);
}
static void
@@ -1058,6 +991,9 @@ event_manager_finalize (GObject *object)
{
EmpathyEventManagerPriv *priv = GET_PRIV (object);
+ if (priv->ringing > 0)
+ empathy_sound_stop (EMPATHY_SOUND_PHONE_INCOMING);
+
g_slist_foreach (priv->events, (GFunc) event_free, NULL);
g_slist_free (priv->events);
g_slist_foreach (priv->approvals, (GFunc) event_manager_approval_free, NULL);
@@ -1178,4 +1114,3 @@ empathy_event_inhibit_updates (EmpathyEvent *event_public)
event->inhibit = TRUE;
}
-