From 0553c6bb55e67bd3451b3baeaa1c5d5334f859c5 Mon Sep 17 00:00:00 2001 From: Sergio Villar Senin Date: Mon, 11 Jun 2007 11:08:36 +0000 Subject: [PATCH 1/1] * Added a first implementation for new messages notifications pmo-trunk-r2148 --- configure.ac | 6 +++--- src/maemo/modest-platform.c | 27 ++++++++++++++++++++++----- src/modest-init.c | 10 ++++++++++ src/widgets/modest-header-view.c | 30 +++++++++++++----------------- 4 files changed, 48 insertions(+), 25 deletions(-) diff --git a/configure.ac b/configure.ac index e48eead..93d462e 100644 --- a/configure.ac +++ b/configure.ac @@ -92,10 +92,10 @@ if test "x$with_platform" = "xmaemo"; then PKG_CHECK_MODULES(HILDON, hildon-1 >= 0.9.9, hildon1=yes, hildon1=no) if test "$hildon1" == "yes"; then # the 'new' hildon - PKG_CHECK_MODULES(MODEST_LIBTINYMAIL_MAEMO, conic libtinymail-maemo-1.0 hildon-1 libosso libhildonmime osso-addressbook-1.0 wpeditor hildon-help libebook-1.2 libalarm) + PKG_CHECK_MODULES(MODEST_LIBTINYMAIL_MAEMO, conic libtinymail-maemo-1.0 hildon-1 libosso libhildonmime osso-addressbook-1.0 wpeditor hildon-help libebook-1.2 libalarm hildon-notify libnotify) else # the old hildon - PKG_CHECK_MODULES(MODEST_LIBTINYMAIL_MAEMO, conic libtinymail-maemo-1.0 hildon-libs >= 0.12.0 libosso libossomime libossohelp osso-addressbook-1.0 libwpeditor-plus libebook-1.2 libalarm gnome-vfs-module-2.0) + PKG_CHECK_MODULES(MODEST_LIBTINYMAIL_MAEMO, conic libtinymail-maemo-1.0 hildon-libs >= 0.12.0 libosso libossomime libossohelp osso-addressbook-1.0 libwpeditor-plus libebook-1.2 libalarm gnome-vfs-module-2.0 hildon-notify libnotify) AC_DEFINE_UNQUOTED(MODEST_HILDON_VERSION_0, 1, ["The Hildon version we support."]) fi @@ -141,7 +141,7 @@ else # gnome frontend AC_MSG_ERROR([Sorry, the GNOME Frontend is currently not working]) - PKG_CHECK_MODULES(MODEST_LIBTINYMAIL_GNOME_DESKTOP,libtinymail-gnome-desktop-1.0 libnm_glib glib-2.0 >= 2.8 gtk+-2.0 >= 2.10) + PKG_CHECK_MODULES(MODEST_LIBTINYMAIL_GNOME_DESKTOP,libtinymail-gnome-desktop-1.0 libnm_glib glib-2.0 >= 2.8 gtk+-2.0 >= 2.10 libnotify) AC_SUBST(MODEST_LIBTINYMAIL_GNOME_DESKTOP_CFLAGS) AC_SUBST(MODEST_LIBTINYMAIL_GNOME_DESKTOP_LIBS) AC_DEFINE_UNQUOTED(MODEST_PLATFORM_GNOME, 1, ["Whether modest is being built for the GNOME platform."]) diff --git a/src/maemo/modest-platform.c b/src/maemo/modest-platform.c index e662811..5afd73e 100644 --- a/src/maemo/modest-platform.c +++ b/src/maemo/modest-platform.c @@ -47,7 +47,7 @@ #include #include #include - +#include #define HILDON_OSSO_URI_ACTION "uri-action" @@ -805,10 +805,27 @@ modest_platform_get_global_settings_dialog () void modest_platform_on_new_msg (void) { - /* TODO: play sound SR-SND-18 */ - /* TODO: LED lightning pattern */ - /* TODO: update the application icon in the task navigator */ - g_print ("--------------- NEW MESSAGE ARRIVED ---------------\n"); + HildonNotification *not; + + /* Create a new notification. FIXME put the right values, need + some more specs */ + not = hildon_notification_new ("Summary", + "Description", + "qgn_contact_group_chat_invitation", + "system.note.dialog"); + + /* Play sound SR-SND-18. TODO: play the right file */ +/* hildon_notification_set_sound (not, "/usr/share/sounds/ui-battery_low.wav"); */ + + /* Set the led pattern */ + notify_notification_set_hint_int32 (NOTIFY_NOTIFICATION (not), "led-pattern", 3); + + /* Notify. We need to do this in an idle because this function + could be called from a thread */ + if (!notify_notification_show (NOTIFY_NOTIFICATION (not), NULL)) + g_error ("Failed to send notification"); + + g_object_unref (not); } diff --git a/src/modest-init.c b/src/modest-init.c index ace733a..18684cb 100644 --- a/src/modest-init.c +++ b/src/modest-init.c @@ -48,6 +48,11 @@ #include #include "widgets/modest-global-settings-dialog.h" #include "modest-tny-msg.h" +#ifdef MODEST_PLATFORM_MAEMO +#include +#else +#include +#endif static gboolean init_header_columns (ModestConf *conf, gboolean overwrite); static gboolean init_default_account_maybe (ModestAccountMgr *acc_mgr); @@ -191,7 +196,12 @@ modest_init_init_ui (gint argc, gchar** argv) g_set_application_name (modest_platform_get_app_name()); /* g_message (modest_platform_get_app_name()); */ + /* Init stock icons */ init_stock_icons (); + + /* Init notification system */ + notify_init ("Basics"); + return TRUE; } diff --git a/src/widgets/modest-header-view.c b/src/widgets/modest-header-view.c index a24b458..dffd7b8 100644 --- a/src/widgets/modest-header-view.c +++ b/src/widgets/modest-header-view.c @@ -1216,6 +1216,14 @@ on_focus_in (GtkWidget *self, return FALSE; } +static gboolean +idle_notify_added_headers (gpointer data) +{ + modest_platform_on_new_msg (); + + return FALSE; +} + static void folder_monitor_update (TnyFolderObserver *self, TnyFolderChange *change) @@ -1227,23 +1235,11 @@ folder_monitor_update (TnyFolderObserver *self, changed = tny_folder_change_get_changed (change); - if (changed & TNY_FOLDER_CHANGE_CHANGED_ADDED_HEADERS) { -/* TnyIterator *iter; */ -/* TnyList *list; */ -/* /\* The added headers *\/ */ -/* list = tny_simple_list_new (); */ -/* tny_folder_change_get_added_headers (change, list); */ -/* iter = tny_list_create_iterator (list); */ -/* while (!tny_iterator_is_done (iter)) */ -/* { */ -/* TnyHeader *header = TNY_HEADER (tny_iterator_get_current (iter)); */ -/* g_object_unref (G_OBJECT (header)); */ -/* tny_iterator_next (iter); */ -/* } */ -/* g_object_unref (G_OBJECT (iter)); */ -/* g_object_unref (G_OBJECT (list)); */ - modest_platform_on_new_msg (); - } + /* We need an idle because this function is called from within + a thread, so it could cause problems if the modest platform + code calls dbus for example */ + if (changed & TNY_FOLDER_CHANGE_CHANGED_ADDED_HEADERS) + g_idle_add (idle_notify_added_headers, NULL); g_mutex_unlock (priv->observers_lock); } -- 1.7.9.5