#include <osso-mem.h>
#include "hildon2/modest-hildon2-details-dialog.h"
#include "hildon2/modest-hildon2-window-mgr.h"
+#include <keys_nokia.h>
+#include <libprofile.h>
+#include <canberra.h>
#ifdef MODEST_HAVE_MCE
#include <mce/dbus-names.h>
#define HILDON_OSSO_URI_ACTION "uri-action"
#define URI_ACTION_COPY "copy:"
-#define MODEST_NEW_MAIL_SOUND_FILE "/usr/share/sounds/ui-new_email.wav"
#define MODEST_NEW_MAIL_LIGHTING_PATTERN "PatternCommunicationEmail"
+#define PROFILE_MAIL_TONE PROFILEKEY_EMAIL_ALERT_TONE
+#define PROFILE_MAIL_VOLUME PROFILEKEY_EMAIL_ALERT_VOLUME
+
+static void _modest_platform_play_email_tone (void);
+
static void
on_modest_conf_update_interval_changed (ModestConf* self,
void
modest_platform_push_email_notification(void)
{
- gboolean play_sound;
gboolean screen_on = TRUE, app_in_foreground;
- /* Check whether or not we should play a sound */
- play_sound = modest_conf_get_bool (modest_runtime_get_conf (),
- MODEST_CONF_PLAY_SOUND_MSG_ARRIVE,
- NULL);
-
- /* Get the screen status */
- /* TODO :obtain properly the screen_is_on status */
-
/* Get the window status */
app_in_foreground = hildon_program_get_is_topmost (hildon_program_get_instance ());
/* If the screen is on and the app is in the
foreground we don't show anything */
if (!(screen_on && app_in_foreground)) {
- /* Play a sound */
- if (play_sound)
- hildon_play_system_sound (MODEST_NEW_MAIL_SOUND_FILE);
+
+ _modest_platform_play_email_tone ();
/* Activate LED. This must be deactivated by
modest_platform_remove_new_mail_notifications */
}
#ifdef MODEST_HAVE_HILDON_NOTIFY
- gboolean play_sound;
-
- /* Check whether or not we should play a sound */
- play_sound = modest_conf_get_bool (modest_runtime_get_conf (),
- MODEST_CONF_PLAY_SOUND_MSG_ARRIVE,
- NULL);
-
HildonNotification *notification;
TnyIterator *iter;
GSList *notifications_list = NULL;
/* Play sound if the user wants. Show the LED
pattern. Show and play just one */
if (G_UNLIKELY (first_notification)) {
+ gchar *active_profile;
+ gchar *mail_tone;
+ gchar *mail_volume;
+ gint mail_volume_int;
+
first_notification = FALSE;
- if (play_sound) {
+
+ active_profile = profile_get_profile ();
+ mail_tone = profile_get_value (active_profile, PROFILE_MAIL_TONE);
+ mail_volume = profile_get_value (active_profile, PROFILE_MAIL_VOLUME);
+ mail_volume_int = profile_parse_int (mail_volume);
+
+ if (mail_volume_int > 0)
notify_notification_set_hint_string(NOTIFY_NOTIFICATION (notification),
- "sound-file", MODEST_NEW_MAIL_SOUND_FILE);
- }
+ "sound-file", mail_tone);
+
+ g_free (mail_volume);
+ g_free (mail_tone);
+ g_free (active_profile);
/* Set the led pattern */
notify_notification_set_hint_int32 (NOTIFY_NOTIFICATION (notification),
{
return modest_maemo_utils_get_osso_context ();
}
+
+static void
+_modest_platform_play_email_tone (void)
+{
+ gchar *active_profile;
+ gchar *mail_tone;
+ gchar *mail_volume;
+ gint mail_volume_int;
+ int ret;
+ ca_context *ca_con = NULL;
+ ca_proplist *pl = NULL;
+
+ active_profile = profile_get_profile ();
+ mail_tone = profile_get_value (active_profile, PROFILE_MAIL_TONE);
+ mail_volume = profile_get_value (active_profile, PROFILE_MAIL_VOLUME);
+ mail_volume_int = profile_parse_int (mail_volume);
+
+ if (mail_volume_int > 0) {
+
+ if ((ret = ca_context_create(&ca_con)) != CA_SUCCESS) {
+ g_warning("ca_context_create: %s\n", ca_strerror(ret));
+ return;
+ }
+
+ if ((ret = ca_context_open(ca_con)) != CA_SUCCESS) {
+ g_warning("ca_context_open: %s\n", ca_strerror(ret));
+ ca_context_destroy(ca_con);
+ return;
+ }
+
+ ca_proplist_create(&pl);
+ ca_proplist_sets(pl, CA_PROP_MEDIA_FILENAME, mail_tone);
+ ca_proplist_setf(pl, CA_PROP_CANBERRA_VOLUME, "%f", (gfloat) mail_volume_int);
+
+ ret = ca_context_play_full(ca_con, 0, pl, NULL, NULL);
+ g_debug("ca_context_play_full (vol %f): %s\n", (gfloat) mail_volume_int, ca_strerror(ret));
+
+ ca_proplist_destroy(pl);
+ ca_context_destroy(ca_con);
+ }
+
+ g_free (mail_volume);
+ g_free (mail_tone);
+ g_free (active_profile);
+}