g_message("NOT IMPLEMENTED %s", __FUNCTION__);
return FALSE;
}
+
+gboolean
+modest_main_window_screen_is_on (ModestMainWindow *self)
+{
+ g_message("NOT IMPLEMENTED %s", __FUNCTION__);
+ return TRUE;
+}
void
-modest_platform_on_new_headers_received (TnyList *header_list)
+modest_platform_on_new_headers_received (TnyList *header_list,
+ gboolean show_visual)
{
/* TODO: implement this */
g_print ("--------------- NEW MESSAGE ARRIVED ---------------\n");
void
-modest_platform_remove_new_mail_notifications (void)
+modest_platform_remove_new_mail_notifications (gboolean only_visuals)
{
g_message ("NOT IMPLEMENTED %s", __FUNCTION__);
}
/* "Updating" banner for header view */
GtkWidget *updating_banner;
guint updating_banner_timeout;
+
+ /* Display state */
+ osso_display_state_t display_state;
};
#define MODEST_MAIN_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
MODEST_TYPE_MAIN_WINDOW, \
priv->sighandlers = NULL;
priv->updating_banner = NULL;
priv->updating_banner_timeout = 0;
+ priv->display_state = OSSO_DISPLAY_ON;
modest_window_mgr_register_help_id (modest_runtime_get_window_mgr(),
GTK_WINDOW(obj),
self);
}
-#if 0
-/** Idle handler, to send/receive at startup .*/
-gboolean
-sync_accounts_cb (ModestMainWindow *win)
-{
- modest_ui_actions_do_send_receive (NULL, MODEST_WINDOW (win));
- return FALSE; /* Do not call this idle handler again. */
-}
-#endif
-
static void
on_hildon_program_is_topmost_notify(GObject *self,
- GParamSpec *propert_param, gpointer user_data)
+ GParamSpec *propert_param,
+ gpointer user_data)
{
HildonProgram *app = HILDON_PROGRAM (self);
- /*
- ModestWindow* self = MODEST_WINDOW(user_data);
- */
-
/* Note that use of hildon_program_set_can_hibernate()
* is generally referred to as "setting the killable flag",
* though hibernation does not seem equal to death.
* because hibernation should only happen when the application
* is in the background: */
hildon_program_set_can_hibernate (app, FALSE);
+
+ /* Remove new mail visual notifications */
+ modest_platform_remove_new_mail_notifications (TRUE);
} else {
/* Allow hibernation if the program has gone to the background: */
/* However, prevent hibernation while the settings are being changed: */
const gboolean hibernation_prevented =
modest_window_mgr_get_hibernation_is_prevented (
- modest_runtime_get_window_mgr ());
+ modest_runtime_get_window_mgr ());
if (hibernation_prevented)
hildon_program_set_can_hibernate (app, FALSE);
modest_osso_save_state();
hildon_program_set_can_hibernate (app, TRUE);
}
- }
-
+ }
}
static void
}
}
+static void
+osso_display_event_cb (osso_display_state_t state,
+ gpointer data)
+{
+ ModestMainWindowPrivate *priv = MODEST_MAIN_WINDOW_GET_PRIVATE (data);
+
+ priv->display_state = state;
+
+ /* Stop blinking if the screen becomes on */
+ if (priv->display_state == OSSO_DISPLAY_ON)
+ modest_platform_remove_new_mail_notifications (TRUE);
+}
+
ModestWindow *
modest_main_window_new (void)
{
g_object_unref (window_icon);
}
+ /* Listen for changes in the screen, we don't want to show a
+ led pattern when the display is on for example */
+ osso_hw_set_display_event_cb (modest_maemo_utils_get_osso_context (),
+ osso_display_event_cb,
+ self);
+
/* Dont't restore settings here,
* because it requires a gtk_widget_show(),
* and we don't want to do that until later,
* so that the UI is not visible for non-menu D-Bus activation.
*/
- /* restore_settings (MODEST_MAIN_WINDOW(self), FALSE); */
return MODEST_WINDOW(self);
}
folder_empty = (tny_folder_change_get_new_all_count (change) == 0);
else
folder_empty = (tny_folder_get_all_count (TNY_FOLDER (folder)) == 0);
+
+ /* Play a sound (if configured) and make the LED blink */
+ if (changed & TNY_FOLDER_CHANGE_CHANGED_ADDED_HEADERS)
+ modest_platform_on_new_headers_received (NULL, FALSE);
-/* Check header removed (hide marked as DELETED headers) */
+ /* Check header removed (hide marked as DELETED headers) */
if (changed & TNY_FOLDER_CHANGE_CHANGED_EXPUNGED_HEADERS) {
modest_header_view_refilter (MODEST_HEADER_VIEW(priv->header_view));
}
else {
modest_main_window_set_contents_style (main_window,
MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS);
- }
+ }
}
}
}
}
+
+gboolean
+modest_main_window_screen_is_on (ModestMainWindow *self)
+{
+ ModestMainWindowPrivate *priv = NULL;
+
+ priv = MODEST_MAIN_WINDOW_GET_PRIVATE (self);
+
+ return (priv->display_state == OSSO_DISPLAY_ON) ? TRUE : FALSE;
+}
#include <dbus_api/modest-dbus-callbacks.h>
#include <maemo/modest-osso-autosave-callbacks.h>
#include <libosso.h>
+#include <mce/dbus-names.h>
#include <tny-maemo-conic-device.h>
#include <tny-simple-list.h>
#include <tny-folder.h>
#include <libgnomevfs/gnome-vfs-mime-utils.h>
#include <modest-account-settings-dialog.h>
#include <maemo/easysetup/modest-easysetup-wizard.h>
+#include <hildon/hildon-sound.h>
#ifdef MODEST_HAVE_ABOOK
#include <libosso-abook/osso-abook.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"
static void
on_modest_conf_update_interval_changed (ModestConf* self,
}
void
-modest_platform_on_new_headers_received (TnyList *header_list)
+modest_platform_on_new_headers_received (TnyList *header_list,
+ gboolean show_visual)
{
+ 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);
+
+ if (!show_visual) {
+ gboolean screen_on, app_in_foreground;
+ ModestWindow *main_window;
+
+ /* Get the screen status */
+ main_window = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr (), FALSE);
+ screen_on = modest_main_window_screen_is_on (MODEST_MAIN_WINDOW (main_window));
+
+ /* 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);
+
+ /* Activate LED. This must be deactivated by
+ modest_platform_remove_new_mail_notifications */
+ osso_rpc_run_system (modest_maemo_utils_get_osso_context (),
+ MCE_SERVICE,
+ MCE_REQUEST_PATH,
+ MCE_REQUEST_IF,
+ MCE_ACTIVATE_LED_PATTERN,
+ NULL,
+ DBUS_TYPE_STRING, MODEST_NEW_MAIL_LIGHTING_PATTERN,
+ DBUS_TYPE_INVALID);
+ }
+ /* We do a return here to avoid indentation with an else */
+ return;
+ }
+
#ifdef MODEST_HAVE_HILDON_NOTIFY
HildonNotification *notification;
TnyIterator *iter;
pattern. Show and play just one */
if (G_UNLIKELY (first_notification)) {
first_notification = FALSE;
- if (modest_conf_get_bool (modest_runtime_get_conf (),
- MODEST_CONF_PLAY_SOUND_MSG_ARRIVE,
- NULL)) {
+ if (play_sound) {
notify_notification_set_hint_string(NOTIFY_NOTIFICATION (notification),
- "sound-file", "/usr/share/sounds/ui-new_email.wav");
+ "sound-file", MODEST_NEW_MAIL_SOUND_FILE);
}
/* Set the led pattern */
"dialog-type", 4);
notify_notification_set_hint_string(NOTIFY_NOTIFICATION (notification),
"led-pattern",
- "PatternCommunicationEmail");
+ MODEST_NEW_MAIL_LIGHTING_PATTERN);
}
/* Notify. We need to do this in an idle because this function
}
void
-modest_platform_remove_new_mail_notifications (void)
+modest_platform_remove_new_mail_notifications (gboolean only_visuals)
{
+ if (only_visuals) {
+ osso_rpc_run_system (modest_maemo_utils_get_osso_context (),
+ MCE_SERVICE,
+ MCE_REQUEST_PATH,
+ MCE_REQUEST_IF,
+ MCE_DEACTIVATE_LED_PATTERN,
+ NULL,
+ DBUS_TYPE_STRING, MODEST_NEW_MAIL_LIGHTING_PATTERN,
+ DBUS_TYPE_INVALID);
+ return;
+ }
+
#ifdef MODEST_HAVE_HILDON_NOTIFY
GSList *notif_list = NULL;
void
modest_platform_connect_if_remote_and_perform (GtkWindow *parent_window,
- TnyFolderStore *folder_store,
- ModestConnectedPerformer callback,
- gpointer user_data)
+ TnyFolderStore *folder_store,
+ ModestConnectedPerformer callback,
+ gpointer user_data)
{
TnyAccount *account = NULL;
gtk_widget_show_all (GTK_WIDGET(main_win));
/* Remove new mail notifications if exist */
- modest_platform_remove_new_mail_notifications ();
+ modest_platform_remove_new_mail_notifications (FALSE);
}
gtk_main ();
cleanup:
gdk_threads_leave ();
- /* Remove new mail notifications if exist */
-/* modest_platform_remove_new_mail_notifications (); */
-
if (!modest_init_uninit ()) {
g_printerr ("modest: modest_init_uninit failed\n");
retval = 1;
/**
* modest_platform_on_new_headers_received:
* @header_list: the list of new received headers
+ * @show_visual: adds a visual notification
*
* Performs the required actions when new headers are
* received. Tipically it's useful for showing new email notifications
**/
-void modest_platform_on_new_headers_received (TnyList *header_list);
+void modest_platform_on_new_headers_received (TnyList *header_list,
+ gboolean show_visual);
/**
* modest_platform_show_help:
/**
* modest_platform_remove_new_mail_notifications:
+ * @only_visuals: remove only the visual notifications (like LEDs)
*
* Removes all the active new mail notifications
**/
-void modest_platform_remove_new_mail_notifications (void);
+void modest_platform_remove_new_mail_notifications (gboolean only_visuals);
/* ModestConnectedPerformer:
* @canceled: whether or not the user canceled
gpointer user_data)
{
GObject *source;
+ gboolean show_visual_notifications;
source = modest_mail_operation_get_source (self);
-
- /* Notify new messages have been downloaded. Do not notify if
- the send&receive was invoked by the user, i.e, if the mail
- operation has a source (the main window) */
- if ((new_headers != NULL) && (tny_list_get_length (new_headers) > 0) && !source)
- modest_platform_on_new_headers_received (new_headers);
-
+ show_visual_notifications = (source) ? FALSE : TRUE;
if (source)
g_object_unref (source);
+
+ /* Notify new messages have been downloaded. If the
+ send&receive was invoked by the user then do not show any
+ visual notification, only play a sound and activate the LED
+ (for the Maemo version) */
+ if ((new_headers != NULL) && (tny_list_get_length (new_headers) > 0))
+ modest_platform_on_new_headers_received (new_headers,
+ show_visual_notifications);
+
}
gboolean
*
* Returns: TRUE if transfer mode is enabled, FASE otherwise.
*/
-gboolean
-modest_main_window_transfer_mode_enabled (ModestMainWindow *self);
+gboolean modest_main_window_transfer_mode_enabled (ModestMainWindow *self);
+
+gboolean modest_main_window_screen_is_on (ModestMainWindow *self);
G_END_DECLS