processing mails in folder - you can define rules than will be executed when entering...
authorHoà Viêt Dinh <dinh.viet.hoa@free.fr>
Sun, 25 Nov 2001 12:55:27 +0000 (12:55 +0000)
committerHoà Viêt Dinh <dinh.viet.hoa@free.fr>
Sun, 25 Nov 2001 12:55:27 +0000 (12:55 +0000)
ChangeLog.claws
configure.in
src/folderview.c
src/main.c
src/prefs_filtering.c
src/summaryview.c
src/summaryview.h

index 31268f3..a45a993 100644 (file)
@@ -1,3 +1,15 @@
+2001-11-25 [hoa]       0.6.5claws33
+
+       * src/main.c
+               processing mails at startup
+
+       * src/folderview.c
+       * src/summaryview.[ch]
+               processing mails when entering folder
+
+       * src/prefs_filtering.c
+               fixed some UI bugs
+
 2001-11-24 [alfons]    0.6.5claws32
 
        * src/summaryview.[ch]
index c75cdd7..7cd4322 100644 (file)
@@ -8,7 +8,7 @@ MINOR_VERSION=6
 MICRO_VERSION=5
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws32
+EXTRA_VERSION=claws33
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl
index 4de8dc8..464e4b5 100644 (file)
@@ -217,6 +217,8 @@ static void folderview_drag_received_cb  (GtkWidget        *widget,
                                          FolderView       *folderview);
 static void folderview_scoring_cb(FolderView *folderview, guint action,
                                  GtkWidget *widget);
+static void folderview_processing_cb(FolderView *folderview, guint action,
+                                    GtkWidget *widget);
 static void folderview_property_cb(FolderView *folderview, guint action, GtkWidget *widget);
 
 static GtkItemFactoryEntry folderview_mbox_popup_entries[] =
@@ -228,6 +230,7 @@ static GtkItemFactoryEntry folderview_mbox_popup_entries[] =
        {N_("/Remove _mailbox"),        NULL, folderview_remove_mailbox_cb, 0, NULL},
        {N_("/---"),                    NULL, NULL, 0, "<Separator>"},
        {N_("/_Property..."),           NULL, NULL, 0, NULL},
+       {N_("/_Processing..."),         NULL, folderview_processing_cb, 0, NULL},
        {N_("/_Scoring..."),            NULL, folderview_scoring_cb, 0, NULL}
 };
 
@@ -243,6 +246,7 @@ static GtkItemFactoryEntry folderview_mail_popup_entries[] =
        {N_("/Remove _mailbox"),        NULL, folderview_remove_mailbox_cb, 0, NULL},
        {N_("/---"),                    NULL, NULL, 0, "<Separator>"},
        {N_("/_Property..."),           NULL, folderview_property_cb, 0, NULL},
+       {N_("/_Processing..."),         NULL, folderview_processing_cb, 0, NULL},
        {N_("/_Scoring..."),            NULL, folderview_scoring_cb, 0, NULL}
 };
 
@@ -258,6 +262,7 @@ static GtkItemFactoryEntry folderview_imap_popup_entries[] =
        {N_("/Remove _IMAP4 account"),  NULL, folderview_rm_imap_server_cb, 0, NULL},
        {N_("/---"),                    NULL, NULL, 0, "<Separator>"},
        {N_("/_Property..."),           NULL, NULL, 0, NULL},
+       {N_("/_Processing..."),         NULL, folderview_processing_cb, 0, NULL},
        {N_("/_Scoring..."),            NULL, folderview_scoring_cb, 0, NULL}
 };
 
@@ -270,6 +275,7 @@ static GtkItemFactoryEntry folderview_news_popup_entries[] =
        {N_("/Remove _news account"),    NULL, folderview_rm_news_server_cb, 0, NULL},
        {N_("/---"),                     NULL, NULL, 0, "<Separator>"},
        {N_("/_Property..."),            NULL, NULL, 0, NULL},
+       {N_("/_Processing..."),         NULL, folderview_processing_cb, 0, NULL},
        {N_("/_Scoring..."),            NULL, folderview_scoring_cb, 0, NULL}
 };
 
@@ -1202,6 +1208,7 @@ static void folderview_button_pressed(GtkWidget *ctree, GdkEventButton *event,
        gboolean rescan_tree     = FALSE;
        gboolean remove_tree     = FALSE;
        gboolean folder_property = FALSE;
+       gboolean folder_processing  = FALSE;
        gboolean folder_scoring  = FALSE;
 
        if (!event) return;
@@ -1252,12 +1259,14 @@ static void folderview_button_pressed(GtkWidget *ctree, GdkEventButton *event,
                        if (item->parent == NULL)
                                update_tree = rescan_tree = TRUE;
                        else if (item->stype == F_NORMAL)
-                               rename_folder = delete_folder = folder_property = folder_scoring = TRUE;
+                               rename_folder = delete_folder = folder_property = folder_scoring = folder_processing = TRUE;
                        else if (item->stype == F_INBOX)
-                               folder_property = folder_scoring = TRUE;
+                               folder_property = folder_scoring = folder_processing = TRUE;
+                       else if (item->stype == F_TRASH)
+                               folder_processing = TRUE;
                } else if (FOLDER_TYPE(folder) == F_NEWS) {
                        if (item->parent != NULL)
-                               delete_folder = folder_scoring = TRUE;
+                               delete_folder = folder_scoring = folder_processing = TRUE;
                }
        }
 
@@ -1274,6 +1283,7 @@ static void folderview_button_pressed(GtkWidget *ctree, GdkEventButton *event,
                SET_SENS(mail_factory, "/Rescan folder tree", rescan_tree);
                SET_SENS(mail_factory, "/Remove mailbox", remove_tree);
                SET_SENS(mail_factory, "/Property...", folder_property);
+               SET_SENS(mail_factory, "/Processing...", folder_processing);
                SET_SENS(mail_factory, "/Scoring...", folder_scoring);
        } else if (FOLDER_TYPE(folder) == F_IMAP) {
                popup = folderview->imap_popup;
@@ -1284,6 +1294,7 @@ static void folderview_button_pressed(GtkWidget *ctree, GdkEventButton *event,
                SET_SENS(imap_factory, "/Update folder tree", update_tree);
                SET_SENS(imap_factory, "/Rescan folder tree", rescan_tree);
                SET_SENS(imap_factory, "/Remove IMAP4 account", remove_tree);
+               SET_SENS(imap_factory, "/Processing...", folder_processing);
                SET_SENS(imap_factory, "/Scoring...", folder_scoring);
        } else if (FOLDER_TYPE(folder) == F_NEWS) {
                popup = folderview->news_popup;
@@ -1291,6 +1302,7 @@ static void folderview_button_pressed(GtkWidget *ctree, GdkEventButton *event,
                SET_SENS(news_factory, "/Subscribe to newsgroup...", new_folder);
                SET_SENS(news_factory, "/Remove newsgroup", delete_folder);
                SET_SENS(news_factory, "/Remove news account", remove_tree);
+               SET_SENS(news_factory, "/Processing...", folder_processing);
                SET_SENS(news_factory, "/Scoring...", folder_scoring);
        } else if (FOLDER_TYPE(folder) == F_MBOX) {
                popup = folderview->mbox_popup;
@@ -1298,6 +1310,7 @@ static void folderview_button_pressed(GtkWidget *ctree, GdkEventButton *event,
                SET_SENS(mbox_factory, "/Create new folder...", new_folder);
                SET_SENS(mbox_factory, "/Rename folder...", rename_folder);
                SET_SENS(mbox_factory, "/Delete folder", delete_folder);
+               SET_SENS(mbox_factory, "/Processing...", folder_processing);
                SET_SENS(mbox_factory, "/Scoring...", folder_scoring);
        } else
                return;
@@ -2236,6 +2249,21 @@ static void folderview_scoring_cb(FolderView *folderview, guint action,
        prefs_scoring_open(item);
 }
 
+static void folderview_processing_cb(FolderView *folderview, guint action,
+                                    GtkWidget *widget)
+{
+       GtkCTree *ctree = GTK_CTREE(folderview->ctree);
+       FolderItem *item;
+
+       if (!folderview->selected) return;
+
+       item = gtk_ctree_node_get_row_data(ctree, folderview->selected);
+       g_return_if_fail(item != NULL);
+       g_return_if_fail(item->folder != NULL);
+
+       prefs_filtering_open(item);
+}
+
 static void folderview_property_cb(FolderView *folderview, guint action, GtkWidget *widget) {
        GtkCTree *ctree = GTK_CTREE(folderview->ctree);
        FolderItem *item;
index 393021c..b730b35 100644 (file)
@@ -285,6 +285,8 @@ int main(int argc, char *argv[])
 
        /* prefs_scoring_read_config(); */
        prefs_matcher_read_config();
+       /* make one all-folder processing before using sylpheed */
+       processing_apply(mainwin->summaryview);
 
        addressbook_read_file();
 
index ec53221..d745e58 100644 (file)
@@ -126,9 +126,9 @@ enum {
        ACTION_MARK_AS_UNREAD = 6,
        ACTION_FORWARD = 7,
        ACTION_FORWARD_AS_ATTACHMENT = 8,
-       ACTION_EXECUTE = 9,
-       ACTION_COLOR = 10,
-       ACTION_BOUNCE = 11
+       ACTION_BOUNCE = 9,
+       ACTION_EXECUTE = 10,
+       ACTION_COLOR = 11,
 };
 
 static gint get_sel_from_list(GtkList * list)
index 008cadb..891ad25 100644 (file)
@@ -250,6 +250,7 @@ static void summary_unthread_for_exec_func  (GtkCTree       *ctree,
                                                 GtkCTreeNode   *node,
                                                 gpointer        data);
 
+void summary_processing(SummaryView *summaryview, GSList * mlist);
 static void summary_filter_func                (GtkCTree               *ctree,
                                         GtkCTreeNode           *node,
                                         gpointer                data);
@@ -758,6 +759,8 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item,
 
        mlist = item->folder->get_msg_list(item->folder, item, !update_cache);
 
+       summary_processing(summaryview, mlist);
+
        for(cur = mlist ; cur != NULL ; cur = g_slist_next(cur)) {
                MsgInfo * msginfo = (MsgInfo *) cur->data;
 
@@ -3557,6 +3560,62 @@ static void summary_unthread_for_exec_func(GtkCTree *ctree, GtkCTreeNode *node,
        }
 }
 
+void summary_processing(SummaryView *summaryview, GSList * mlist)
+{
+       GSList * processing_list;
+       FolderItem * folder_item;
+       GSList * cur;
+       gchar * id;
+       gchar * buf;
+
+       folder_item = summaryview->folder_item;
+       if (folder_item == NULL)
+               return;
+
+       processing_list = folder_item->prefs->processing;
+
+       if (processing_list == NULL)
+               return;
+
+       summary_lock(summaryview);
+       
+       buf = g_strdup_printf(_("Processing (%s)..."), folder_item->path);
+       debug_print(buf);
+       STATUSBAR_PUSH(summaryview->mainwin, buf);
+       g_free(buf);
+
+       main_window_cursor_wait(summaryview->mainwin);
+
+       summaryview->folder_table = g_hash_table_new(NULL, NULL);
+
+       for(cur = mlist ; cur != NULL ; cur = cur->next) {
+               MsgInfo * msginfo;
+
+               msginfo = (MsgInfo *) cur->data;
+               filter_msginfo_move_or_delete(processing_list, msginfo,
+                                             summaryview->folder_table);
+       }
+       
+       folder_item_scan_foreach(summaryview->folder_table);
+       folderview_update_item_foreach(summaryview->folder_table);
+       
+       g_hash_table_destroy(summaryview->folder_table);
+       summaryview->folder_table = NULL;
+       
+       if (prefs_common.immediate_exec) {
+               summary_unlock(summaryview);
+               summary_execute(summaryview);
+               summary_lock(summaryview);
+       } else
+               summary_status_show(summaryview);
+
+       debug_print(_("done.\n"));
+       STATUSBAR_POP(summaryview->mainwin);
+       main_window_cursor_normal(summaryview->mainwin);
+
+       summary_unlock(summaryview);
+}
+
 void summary_filter(SummaryView *summaryview)
 {
        if (!prefs_common.fltlist && !global_processing) {
@@ -4687,6 +4746,68 @@ static void summary_unignore_thread(SummaryView *summaryview)
 
        summary_status_show(summaryview);
 }
+
+
+static gboolean processing_apply_func(GNode *node, gpointer data)
+{
+       FolderItem *item;
+       GSList * processing;
+       SummaryView * summaryview = (SummaryView *) data;
+       
+       if (node == NULL)
+               return FALSE;
+
+       item = node->data;
+       /* prevent from the warning */
+       if (item->path == NULL)
+               return FALSE;
+       processing = item->prefs->processing;
+
+       if (processing != NULL) {
+               gchar * buf;
+               GSList * mlist;
+               GSList * cur;
+
+               buf = g_strdup_printf(_("Processing (%s)..."), item->path);
+               debug_print(buf);
+               STATUSBAR_PUSH(summaryview->mainwin, buf);
+               g_free(buf);
+
+               mlist = item->folder->get_msg_list(item->folder, item,
+                                                  TRUE);
+               
+               for(cur = mlist ; cur != NULL ; cur = cur->next) {
+                       MsgInfo * msginfo;
+                       
+                       msginfo = (MsgInfo *) cur->data;
+                       filter_msginfo_move_or_delete(processing, msginfo,
+                                                     NULL);
+                       procmsg_msginfo_free(msginfo);
+               }
+
+               g_slist_free(mlist);
+               
+               STATUSBAR_POP(summaryview->mainwin);
+       }
+
+
+       return FALSE;
+}
+
+void processing_apply(SummaryView * summaryview)
+{
+       GList * cur;
+
+       for (cur = folder_get_list() ; cur != NULL ; cur = g_list_next(cur)) {
+               Folder *folder;
+
+               folder = (Folder *) cur->data;
+               g_node_traverse(folder->node, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
+                               processing_apply_func, summaryview);
+       }
+}
+
+
 /*
  * End of Source.
  */
index cdf5862..dccf3b2 100644 (file)
@@ -247,4 +247,6 @@ void summary_set_colorlabel_color (GtkCTree         *ctree,
 
 void summary_set_column_order    (SummaryView          *summaryview);
 
+void processing_apply();
+
 #endif /* __SUMMARY_H__ */