make filtered message don't stay in .processing but try to move them to inbox; also...
authorAlfons Hoogervorst <alfons@proteus.demon.nl>
Wed, 9 Jan 2002 20:43:32 +0000 (20:43 +0000)
committerAlfons Hoogervorst <alfons@proteus.demon.nl>
Wed, 9 Jan 2002 20:43:32 +0000 (20:43 +0000)
ChangeLog.claws
configure.in
src/filtering.c
src/summaryview.c

index f9ef1de..2deb663 100644 (file)
@@ -1,3 +1,17 @@
+2001-01-09 [alfons]    0.6.6claws45
+
+       * src/filtering.c
+               break up filteringprop_apply() in three separate pieces
+               so we can drop messages that failed processing in the
+               inbox
+
+       * src/summaryview.c
+               fix bug #469598 "no refresh of inbox after filter" which 
+               was introduced by the new summary view locking, and which 
+               prevented the summary view to update after a manual filter 
+               message. claw's filter message requires a summary_show().
+               (aargh, summary_show() again! :-)
+               
 2002-01-07 [alfons]    0.6.6claws44
 
        * src/headerwindow.c
index 2d32b1f..bb4e0f0 100644 (file)
@@ -8,7 +8,7 @@ MINOR_VERSION=6
 MICRO_VERSION=6
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws44
+EXTRA_VERSION=claws45
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl
index b144a3a..6505945 100644 (file)
@@ -262,72 +262,76 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
        }
 }
 
-/* filteringprop_apply() - runs the action on one MsgInfo if it matches the 
- * criterium. certain actions can be followed by other actions. in this
- * case the function returns FALSE. if an action can not be followed
- * by others, the function returns TRUE. */
-static gboolean filteringprop_apply(FilteringProp * filtering, MsgInfo * info,
-                                   GHashTable *folder_table)
+static gboolean filtering_match_condition(FilteringProp *filtering, MsgInfo *info)
 {
-       if (matcherlist_match(filtering->matchers, info)) {
-               gboolean result;
-               gchar   *action_str;
-               gchar    buf[256]; 
-
-               if (FALSE == (result = filteringaction_apply(filtering->action, info,
-                                              folder_table))) {
-                       action_str = filteringaction_to_string(buf, sizeof buf, filtering->action);
-                       g_warning(_("action %s could not be applied"), action_str);
-               }
+       return matcherlist_match(filtering->matchers, info);
+}
 
-               switch(filtering->action->type) {
-               case MATCHACTION_MOVE:
-               case MATCHACTION_DELETE:
-                       return TRUE; /* MsgInfo invalid for message */
-               case MATCHACTION_EXECUTE:
-               case MATCHACTION_COPY:
-               case MATCHACTION_MARK:
-               case MATCHACTION_MARK_AS_READ:
-               case MATCHACTION_UNMARK:
-               case MATCHACTION_MARK_AS_UNREAD:
-               case MATCHACTION_FORWARD:
-               case MATCHACTION_FORWARD_AS_ATTACHMENT:
-               case MATCHACTION_BOUNCE:
-                       return FALSE; /* MsgInfo still valid for message */
-               default:
-                       return FALSE;
-               }
+static gboolean filtering_apply_rule(FilteringProp *filtering, MsgInfo *info, 
+                                    GHashTable *foldertable)
+{
+       gboolean result;
+       gchar    actionstr;
+       gchar    buf[50];
+
+       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));
        }
-       else
+       return result;
+}
+
+static gboolean filtering_is_final_action(FilteringProp *filtering)
+{
+       switch(filtering->action->type) {
+       case MATCHACTION_MOVE:
+       case MATCHACTION_DELETE:
+               return TRUE; /* MsgInfo invalid for message */
+       case MATCHACTION_EXECUTE:
+       case MATCHACTION_COPY:
+       case MATCHACTION_MARK:
+       case MATCHACTION_MARK_AS_READ:
+       case MATCHACTION_UNMARK:
+       case MATCHACTION_MARK_AS_UNREAD:
+       case MATCHACTION_FORWARD:
+       case MATCHACTION_FORWARD_AS_ATTACHMENT:
+       case MATCHACTION_BOUNCE:
+               return FALSE; /* MsgInfo still valid for message */
+       default:
                return FALSE;
+       }
 }
 
 static void filter_msginfo(GSList * filtering_list, FolderItem *inbox,
                           MsgInfo * info, GHashTable *folder_table)
 {
-       GSList          *l;
-       gboolean         result;
+       GSList  *l;
+       gboolean final;
+       gboolean applied;
+       gint val;
        
        if (info == NULL) {
                g_warning(_("msginfo is not set"));
                return;
        }
        
-       for(l = filtering_list ; l != NULL ; l = g_slist_next(l)) {
+       for (l = filtering_list, final = FALSE, applied = FALSE; l != NULL; l = g_slist_next(l)) {
                FilteringProp * filtering = (FilteringProp *) l->data;
-               if (TRUE == (result = filteringprop_apply(filtering, info, folder_table))) 
-                       break;
-       }
 
-       /* drop in inbox too */
-       if (!result) {
-               gint val;
+               if (filtering_match_condition(filtering, info)) {
+                       applied = filtering_apply_rule(filtering, info, folder_table);
+                       if (TRUE == (final = filtering_is_final_action(filtering)))
+                               break;
+               }               
+       }
 
+       /* 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));
@@ -356,7 +360,8 @@ void filter_msginfo_move_or_delete(GSList * filtering_list, MsgInfo * info,
                switch (filtering->action->type) {
                case MATCHACTION_MOVE:
                case MATCHACTION_DELETE:
-                       if (filteringprop_apply(filtering, info, folder_table))
+                       if (filtering_match_condition(filtering, info) &&
+                           filtering_apply_rule(filtering, info, folder_table))
                                return;
                }
        }
index 43d8b58..28e7494 100644 (file)
@@ -756,6 +756,7 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item,
        main_window_cursor_wait(summaryview->mainwin);
 
        mlist = item->folder->get_msg_list(item->folder, item, !update_cache);
+       debug_print("*** folder %s has %d messages\n", item->path, g_slist_length(mlist));
 
        summary_processing(summaryview, mlist);
 
@@ -3740,6 +3741,7 @@ void summary_filter(SummaryView *summaryview)
                        summary_status_show(summaryview);
        }
        else {
+               FolderItem *item = summaryview->folder_item;
                summaryview->folder_table = g_hash_table_new(NULL, NULL);
 
                gtk_ctree_pre_recursive(GTK_CTREE(summaryview->ctree), NULL,
@@ -3753,8 +3755,6 @@ void summary_filter(SummaryView *summaryview)
 
                g_hash_table_destroy(summaryview->folder_table);
                summaryview->folder_table = NULL;
-
-               summary_show(summaryview, summaryview->folder_item, FALSE);
        }
 
        debug_print(_("done.\n"));
@@ -3762,6 +3762,11 @@ void summary_filter(SummaryView *summaryview)
        main_window_cursor_normal(summaryview->mainwin);
 
        summary_unlock(summaryview);
+
+       /* CLAWS: summary_show() only valid after having a lock. ideally
+        * we want the lock to be context aware...  */
+       if (global_processing)
+               summary_show(summaryview, summaryview->folder_item, FALSE);
 }
 
 static void summary_filter_func(GtkCTree *ctree, GtkCTreeNode *node,
@@ -3782,7 +3787,7 @@ static void summary_filter_func(GtkCTree *ctree, GtkCTreeNode *node,
                    summaryview->folder_item != dest)
                        summary_move_row_to(summaryview, node, dest);
        }
-       else
+       else 
                filter_msginfo_move_or_delete(global_processing, msginfo,
                                              summaryview->folder_table);
 }