* Added a first implementation for new messages notifications
authorSergio Villar Senin <svillar@igalia.com>
Mon, 11 Jun 2007 11:08:36 +0000 (11:08 +0000)
committerSergio Villar Senin <svillar@igalia.com>
Mon, 11 Jun 2007 11:08:36 +0000 (11:08 +0000)
pmo-trunk-r2148

configure.ac
src/maemo/modest-platform.c
src/modest-init.c
src/widgets/modest-header-view.c

index e48eead..93d462e 100644 (file)
@@ -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."])
index e662811..5afd73e 100644 (file)
@@ -47,7 +47,7 @@
 #include <gtk/gtkmenuitem.h>
 #include <gtk/gtkmain.h>
 #include <string.h>
-
+#include <hildon/hildon-notification.h>
 
 #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);
 }
 
 
index ace733a..18684cb 100644 (file)
 #include <modest-icon-names.h>
 #include "widgets/modest-global-settings-dialog.h"
 #include "modest-tny-msg.h"
+#ifdef MODEST_PLATFORM_MAEMO
+#include <hildon/hildon-notification.h>
+#else
+#include <libnotify/notify.h>
+#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;
 }
 
index a24b458..dffd7b8 100644 (file)
@@ -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);
 }