Only notify for new headers without seen flag (fixes MB#3004)
[modest] / src / modest-ui-actions.c
index 77ac1d9..18468d8 100644 (file)
@@ -242,7 +242,6 @@ modest_ui_actions_run_account_setup_wizard (ModestWindow *win)
 
                window_list = modest_window_mgr_get_window_list (mgr);
                if (window_list == NULL) {
-                       ModestWindow *old_win;
                        win = MODEST_WINDOW (modest_accounts_window_new ());
                        if (modest_window_mgr_register_window (mgr, win, NULL)) {
                                gtk_widget_show_all (GTK_WIDGET (win));
@@ -251,14 +250,6 @@ modest_ui_actions_run_account_setup_wizard (ModestWindow *win)
                                win = NULL;
                        }
 
-                       old_win = win;
-                       win = MODEST_WINDOW (modest_folder_window_new (NULL));
-                       if (modest_window_mgr_register_window (mgr, win, NULL)) {
-                               gtk_widget_show_all (GTK_WIDGET (win));
-                       } else {
-                               gtk_widget_destroy (GTK_WIDGET (win));
-                               win = old_win;
-                       }
                } else {
                        g_list_free (window_list);
                }
@@ -2144,9 +2135,34 @@ new_messages_arrived (ModestMailOperation *self,
           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 (TNY_IS_LIST(new_headers) && (tny_list_get_length (new_headers)) > 0)
-               modest_platform_on_new_headers_received (new_headers,
-                                                        show_visual_notifications);
+       if (TNY_IS_LIST(new_headers) && (tny_list_get_length (new_headers)) > 0) {
+
+               /* We only notify about really new messages (not seen) we get */
+               TnyList *actually_new_list;
+               TnyIterator *iterator;
+               actually_new_list = TNY_LIST (tny_simple_list_new ());
+               for (iterator = tny_list_create_iterator (new_headers);
+                    !tny_iterator_is_done (iterator);
+                    tny_iterator_next (iterator)) {
+                       TnyHeader *header;
+                       TnyHeaderFlags flags;
+                       header = TNY_HEADER (tny_iterator_get_current (iterator));
+                       flags = tny_header_get_flags (header);
+
+                       if (!(flags & TNY_HEADER_FLAG_SEEN)) {
+                               tny_list_append (actually_new_list, G_OBJECT (header));
+                       }
+                       g_object_unref (header);
+                       
+               }
+               g_object_unref (iterator);
+
+               if (tny_list_get_length (actually_new_list) > 0) {
+                       modest_platform_on_new_headers_received (actually_new_list,
+                                                                show_visual_notifications);
+               }
+               g_object_unref (actually_new_list);
+       }
 
 }
 
@@ -3409,20 +3425,21 @@ do_create_folder (GtkWindow *parent_window,
 
 static void
 modest_ui_actions_create_folder(GtkWidget *parent_window,
-                                GtkWidget *folder_view)
+                                GtkWidget *folder_view,
+                               TnyFolderStore *parent_folder)
 {
-       TnyFolderStore *parent_folder;
-
+       if (!parent_folder) {
 #ifdef MODEST_TOOLKIT_HILDON2
-       ModestTnyAccountStore *acc_store;
+               ModestTnyAccountStore *acc_store;
 
-       acc_store = modest_runtime_get_account_store ();
+               acc_store = modest_runtime_get_account_store ();
 
-       parent_folder = (TnyFolderStore *)
-               modest_tny_account_store_get_local_folders_account (acc_store);
+               parent_folder = (TnyFolderStore *)
+                       modest_tny_account_store_get_local_folders_account (acc_store);
 #else
-       parent_folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW(folder_view));
+               parent_folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW(folder_view));
 #endif
+       }
 
        if (parent_folder) {
                do_create_folder (GTK_WINDOW (parent_window), parent_folder, NULL);
@@ -3444,13 +3461,13 @@ modest_ui_actions_on_new_folder (GtkAction *action, ModestWindow *window)
                if (!folder_view)
                        return;
 
-               modest_ui_actions_create_folder (GTK_WIDGET (window), folder_view);
+               modest_ui_actions_create_folder (GTK_WIDGET (window), folder_view, NULL);
 #ifdef MODEST_TOOLKIT_HILDON2
        } else if (MODEST_IS_FOLDER_WINDOW (window)) {
                GtkWidget *folder_view;
 
                folder_view = GTK_WIDGET (modest_folder_window_get_folder_view (MODEST_FOLDER_WINDOW (window)));
-               modest_ui_actions_create_folder (GTK_WIDGET (window), folder_view);
+               modest_ui_actions_create_folder (GTK_WIDGET (window), folder_view, NULL);
 #endif
        } else {
                g_assert_not_reached ();
@@ -4940,9 +4957,12 @@ on_move_to_dialog_response (GtkDialog *dialog,
 
        switch (response) {
                TnyFolderStore *dst_folder;
+               TnyFolderStore *selected;
 
        case MODEST_GTK_RESPONSE_NEW_FOLDER:
-               modest_ui_actions_create_folder (GTK_WIDGET (dialog), GTK_WIDGET (folder_view));
+               selected = modest_folder_view_get_selected (folder_view);
+               modest_ui_actions_create_folder (GTK_WIDGET (dialog), GTK_WIDGET (folder_view), selected);
+               g_object_unref (selected);
                return;
        case GTK_RESPONSE_NONE:
        case GTK_RESPONSE_CANCEL:
@@ -6693,3 +6713,31 @@ modest_ui_actions_on_delete_account (GtkWindow *parent_window,
        }
        return removed;
 }
+
+void 
+modest_ui_actions_on_fetch_images (GtkAction *action,
+                                  ModestWindow *window)
+{
+       g_return_if_fail (MODEST_IS_MSG_VIEW_WINDOW (window));
+
+       modest_msg_view_window_fetch_images (MODEST_MSG_VIEW_WINDOW (window));
+
+}
+
+void
+modest_ui_actions_on_reload_message (const gchar *msg_id)
+{
+       ModestWindow *window = NULL;
+
+       g_return_if_fail (msg_id && msg_id[0] != '\0');
+       if (!modest_window_mgr_find_registered_message_uid (modest_runtime_get_window_mgr (),
+                                                           msg_id,
+                                                           &window))
+               return;
+
+
+       if (window == NULL || !MODEST_IS_MSG_VIEW_WINDOW (window))
+               return;
+
+       modest_msg_view_window_reload (MODEST_MSG_VIEW_WINDOW (window));
+}