Set gstreamer driver in canberra for playing sounds (supports aac then).
[modest] / src / hildon2 / modest-platform.c
index 0223d15..77cc610 100644 (file)
@@ -79,6 +79,7 @@
 #include <modest-selector-picker.h>
 #include <modest-icon-names.h>
 #include <modest-count-stream.h>
+#include <math.h>
 
 #ifdef MODEST_HAVE_MCE
 #include <mce/dbus-names.h>
 #define MODEST_ALARMD_APPID PACKAGE_NAME
 
 static ca_context *ca_con = NULL;
+static gboolean ca_con_opened = FALSE;
 
 
 static void modest_platform_play_email_tone (void);
@@ -475,9 +477,9 @@ modest_platform_show_uri_popup (const gchar *uri)
                 * and/or might have security implications
                 * we still allow to copy the url though
                 */
-               if (!g_str_has_prefix (uri, "file:")) {                 
-               
-                       GSList *node;                   
+               if (!g_str_has_prefix (uri, "file:")) {
+
+                       GSList *node;
                        popup_info->actions = actions_list;
                        popup_info->uri = g_strdup (uri);
 
@@ -489,6 +491,7 @@ modest_platform_show_uri_popup (const gchar *uri)
                                action_name = hildon_uri_action_get_name (action);
                                translation_domain = hildon_uri_action_get_translation_domain (action);
                                menu_item = gtk_menu_item_new_with_label (dgettext(translation_domain, action_name));
+                               hildon_gtk_widget_set_theme_size (menu_item, MODEST_EDITABLE_SIZE);
                                g_object_set_data (G_OBJECT(menu_item), HILDON_OSSO_URI_ACTION, (gpointer)action_name);  /* hack */
                                g_signal_connect (G_OBJECT (menu_item), "activate", G_CALLBACK (activate_uri_popup_item),
                                                  popup_info);
@@ -997,7 +1000,7 @@ modest_platform_run_folder_common_dialog (GtkWindow *parent_window,
                                          gchar **folder_name,
                                          TnyFolderStore **parent)
 {
-       GtkWidget *accept_btn = NULL; 
+       GtkWidget *accept_btn = NULL;
        GtkWidget *dialog, *entry = NULL, *label_entry = NULL,  *label_location = NULL, *hbox;
        GtkWidget *account_picker = NULL;
        GList *buttons = NULL;
@@ -1604,10 +1607,12 @@ modest_platform_on_new_headers_received (GList *URI_list,
        app_in_foreground = hildon_program_get_is_topmost (hildon_program_get_instance ());
        screen_on = modest_window_mgr_screen_is_on (modest_runtime_get_window_mgr ());
 
-       /* If the screen is on and the app is in the
-          foreground we don't show anything */
-       if (screen_on && app_in_foreground)
+       /* If the screen is on and the app is in the foreground we
+          don't show anything, just play a chime */
+       if (screen_on && app_in_foreground) {
+               modest_platform_play_email_tone ();
                return;
+       }
 
        if (g_list_length (URI_list) == 0)
                return;
@@ -1648,6 +1653,10 @@ modest_platform_on_new_headers_received (GList *URI_list,
                                            -1);
 
        /* Set the led pattern */
+       if (data->time)
+               notify_notification_set_hint_int32 (NOTIFY_NOTIFICATION (notification),
+                                                   "time", data->time);
+
        notify_notification_set_hint_int32 (NOTIFY_NOTIFICATION (notification),
                                            "dialog-type", 4);
        notify_notification_set_hint_string(NOTIFY_NOTIFICATION (notification),
@@ -2069,14 +2078,17 @@ modest_platform_run_certificate_confirmation_dialog (const gchar* server_name,
           example. With GTK_RESPONSE_HELP the view button is aligned
           to the left while the other two to the right */
        note = hildon_note_new_confirmation_add_buttons  (
-               NULL,
+               (GtkWindow *) win,
                question,
                _HL("wdgt_bd_yes"),     GTK_RESPONSE_OK,
                _HL("wdgt_bd_view"),          GTK_RESPONSE_APPLY,   /* abusing this... */
                _HL("wdgt_bd_no"), GTK_RESPONSE_CANCEL,
                NULL, NULL);
 
-       g_signal_connect (G_OBJECT(note), "response", 
+       modest_window_mgr_set_modal (modest_runtime_get_window_mgr (),
+                                    (GtkWindow *) note, (GtkWindow *) win);
+
+       g_signal_connect (G_OBJECT(note), "response",
                          G_CALLBACK(on_cert_dialog_response),
                          (gpointer) certificate);
 
@@ -2613,6 +2625,19 @@ modest_platform_get_osso_context (void)
        return modest_maemo_utils_get_osso_context ();
 }
 
+static gfloat
+convert_volume_to_db (int linear_volume)
+{
+    gfloat linear_converted = linear_volume / 100.0;
+    gfloat db_vol = 0.0;
+    
+    db_vol = 20 * log10 (linear_converted);
+    if (isinf (db_vol) != 0)
+        return -60.0;
+
+    return db_vol;
+}
+
 static void
 modest_platform_play_email_tone (void)
 {
@@ -2620,6 +2645,7 @@ modest_platform_play_email_tone (void)
        gint mail_volume_int;
        int ret;
        ca_proplist *pl = NULL;
+       gfloat db_volume;
 
 #ifdef MODEST_USE_PROFILE
        gchar *active_profile;
@@ -2649,18 +2675,29 @@ modest_platform_play_email_tone (void)
                if (ca_con == NULL) {
                        if ((ret = ca_context_create (&ca_con)) != CA_SUCCESS) {
                                g_warning("ca_context_create: %s\n", ca_strerror(ret));
+                               ca_con = NULL;
+                               return;
+                       }
+                       if ((ret = ca_context_set_driver (ca_con, "gstreamer")) != CA_SUCCESS) {
+                               g_warning ("ca_context_set_driver: %s\n", ca_strerror (ret));
+                               ca_con = NULL;
                                return;
                        }
                }
 
-               if ((ret = ca_context_open(ca_con)) != CA_SUCCESS) {
-                       g_warning("ca_context_open: %s\n", ca_strerror(ret));
-                       return;
+               if (!ca_con_opened) {
+                       if ((ret = ca_context_open(ca_con)) != CA_SUCCESS) {
+                               g_warning("ca_context_open: %s\n", ca_strerror(ret));
+                               return;
+                       } else {
+                               ca_con_opened = TRUE;
+                       }
                }
 
                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);
+               db_volume = convert_volume_to_db (mail_volume_int);
+               ca_proplist_setf(pl, CA_PROP_CANBERRA_VOLUME, "%f", db_volume);
 
                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));
@@ -2932,6 +2969,7 @@ on_move_to_dialog_row_activated (GtkTreeView       *tree_view,
        } else {
                move_to_dialog_set_selected_folder_store (dialog, selected);
        }
+       g_object_unref (selected);
 }
 
 static void