make Tool | Filter Message work with filtering system, so setting flags in actions...
authorAlfons Hoogervorst <alfons@proteus.demon.nl>
Sun, 24 Feb 2002 12:55:45 +0000 (12:55 +0000)
committerAlfons Hoogervorst <alfons@proteus.demon.nl>
Sun, 24 Feb 2002 12:55:45 +0000 (12:55 +0000)
ChangeLog.claws
configure.in
src/filtering.c
src/summaryview.c

index 4e3e4bf86cbb8810c5ba53c443653fddae63a184..f4c0de83b46099f68fa9a01c94a3f067a19de91a 100644 (file)
@@ -1,3 +1,15 @@
+2002-02-24 [alfons]    0.7.2claws9
+
+       * src/summaryview.c
+       * src/filtering.c
+               make Tool | Filter Message work with filtering system so
+               setting flags also works
+
+               TODO:
+
+               - Processing uses the same function as Tool | Filter
+                 Message, but doesn't use the same update proc yet
+
 2002-02-23 [paul]      0.7.2claws8
 
        * sync with sylpheed 0.7.2cvs14
index 68fb0d9b17ca0de9f741f588cd3aee777dbed481..b1aecaf995cf065d988c40b0fd6784efefa83e39 100644 (file)
@@ -8,7 +8,7 @@ MINOR_VERSION=7
 MICRO_VERSION=2
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws8
+EXTRA_VERSION=claws9
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 5491c4ce927eb0671af247d710901146400f0a80..b30b930c6a0c9016a87d5fb8b7bd1e31badf9626 100644 (file)
@@ -184,6 +184,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
                return TRUE;
 
        case MATCHACTION_MARK_AS_UNREAD:
+               debug_print("*** setting unread flags\n");
                MSG_SET_PERM_FLAGS(info->flags, MSG_UNREAD | MSG_NEW);
                return TRUE;
        
@@ -276,7 +277,7 @@ static gboolean filtering_apply_rule(FilteringProp *filtering, MsgInfo *info,
 
        if (FALSE == (result = filteringaction_apply(filtering->action, info, foldertable))) {
                g_warning(_("action %s could not be applied"), 
-                         filteringaction_to_string(buf, sizeof buf, filtering->action));
+               filteringaction_to_string(buf, sizeof buf, filtering->action));
        }
        return result;
 }
@@ -328,45 +329,58 @@ static void filter_msginfo(GSList * filtering_list, FolderItem *inbox,
        /* put in inbox if a final rule could not be applied, or
         * the last rule was not a final one. */
        if ((final && !applied) || !final) {
-               if (folder_item_move_msg(inbox, info) == -1) {
-                       debug_print(_("*** Could not drop message in inbox; still in .processing\n"));
-                       return;
-               }       
-               if (folder_table) {
-                       val = GPOINTER_TO_INT(g_hash_table_lookup
-                                             (folder_table, inbox));
-                       if (val == 0) {
-                               folder_item_scan(inbox);
-                               g_hash_table_insert(folder_table, inbox,
-                                                   GINT_TO_POINTER(1));
+               if (inbox != info->folder) {
+                       if (folder_item_move_msg(inbox, info) == -1) {
+                               debug_print(_("*** Could not drop message in inbox; check .processing\n"));
+                               return;
+                       }       
+                       if (folder_table) {
+                               val = GPOINTER_TO_INT(g_hash_table_lookup
+                                                     (folder_table, inbox));
+                               if (val == 0) {
+                                       folder_item_scan(inbox);
+                                       g_hash_table_insert(folder_table, inbox,
+                                                           GINT_TO_POINTER(1));
+                               }
                        }
-               }
+               }       
        }
 }
 
-void filter_msginfo_move_or_delete(GSList * filtering_list, MsgInfo * info,
-                                  GHashTable *folder_table)
+/*!
+ *\brief       filters a message based on its message info data
+ *
+ *\param       flist filter and actions list
+ *\param       info message
+ *\param       ftable table with changed folders after call
+ */
+void filter_message_by_msginfo(GSList *flist, MsgInfo *info, GHashTable *ftable)
 {
-       GSList * l;
-
-       if (info == NULL) {
-               g_warning(_("msginfo is not set"));
-               return;
-       }
-       
-       for(l = filtering_list ; l != NULL ; l = g_slist_next(l)) {
-               FilteringProp * filtering = (FilteringProp *) l->data;
-
-               switch (filtering->action->type) {
-               case MATCHACTION_MOVE:
-               case MATCHACTION_DELETE:
-                       if (filtering_match_condition(filtering, info) &&
-                           filtering_apply_rule(filtering, info, folder_table))
-                               return;
-               }
-       }
+       FolderItem *inbox;
+
+       if (info->folder == NULL) {
+               debug_print("using default inbox as final destination!\n");
+               inbox = folder_get_default_inbox(); 
+       } else
+               inbox = info->folder;
+
+       /*
+        * message is already in a folder. the filtering code will
+        * handle duplicate moves and copies.
+        */
+       filter_msginfo(flist, inbox,  info, ftable);
 }
 
+/*!
+ *\brief       filters a message waiting to be processed in the
+ *             .processing folder. 
+ *
+  *\param      filtering_list list of filters and actions
+  *\param      inbox default inbox when no filter could be applied
+  *\param      msgnum message number in processing folder
+  *\param      folder_table table with folders that have been
+  *            changed after the call to this function
+  */
 void filter_message(GSList *filtering_list, FolderItem *inbox,
                    gint msgnum, GHashTable *folder_table)
 {
index 84ed56c7db059ba063a4916ac448385272af03f6..4b5ee5c99b0b5d2e7a53dc310fe1d4f009c523dd 100644 (file)
@@ -3751,8 +3751,8 @@ void summary_processing(SummaryView *summaryview, GSList * mlist)
                MsgInfo * msginfo;
 
                msginfo = (MsgInfo *) cur->data;
-               filter_msginfo_move_or_delete(processing_list, msginfo,
-                                             summaryview->folder_table);
+               filter_message_by_msginfo(processing_list, msginfo,
+                                         summaryview->folder_table);
        }
        
        folder_item_scan_foreach(summaryview->folder_table);
@@ -3831,13 +3831,7 @@ void summary_filter(SummaryView *summaryview)
         * we want the lock to be context aware...  
         */
        if (global_processing) {
-               /*
-                * CLAWS: to prevent summary_show to write the cache,
-                * we force an update of the summaryview in a special way,
-                * like inc.c::inc_finished().
-                */
-               folderview_unselect(summaryview->folderview);
-               folderview_select(summaryview->folderview, summaryview->folder_item);
+               summary_show(summaryview, summaryview->folder_item, TRUE);              
        }               
 }
 
@@ -3858,10 +3852,8 @@ static void summary_filter_func(GtkCTree *ctree, GtkCTreeNode *node,
                if (dest && strcmp2(dest->path, FILTER_NOT_RECEIVE) != 0 &&
                    summaryview->folder_item != dest)
                        summary_move_row_to(summaryview, node, dest);
-       }
-       else 
-               filter_msginfo_move_or_delete(global_processing, msginfo,
-                                             summaryview->folder_table);
+       } else 
+               filter_message_by_msginfo(global_processing, msginfo, summaryview->folder_table);
 }
 
 void summary_filter_open(SummaryView *summaryview, PrefsFilterType type)
@@ -4942,8 +4934,7 @@ static gboolean processing_apply_func(GNode *node, gpointer data)
                        MsgInfo * msginfo;
                        
                        msginfo = (MsgInfo *) cur->data;
-                       filter_msginfo_move_or_delete(processing, msginfo,
-                                                     NULL);
+                       filter_message_by_msginfo(processing, msginfo, NULL);
                        procmsg_msginfo_free(msginfo);
                }