more revision of filtering system
authorAlfons Hoogervorst <alfons@proteus.demon.nl>
Wed, 5 Dec 2001 22:09:25 +0000 (22:09 +0000)
committerAlfons Hoogervorst <alfons@proteus.demon.nl>
Wed, 5 Dec 2001 22:09:25 +0000 (22:09 +0000)
ChangeLog.claws
configure.in
src/filtering.c
src/folder.c
src/folder.h
src/inc.c

index 0810b443e5c263495261cb80bdb4ff76ab2b968b..f54c6aea728c238344f66b0f32e9611fbc2b51c9 100644 (file)
@@ -1,3 +1,18 @@
+2001-12-05 [alfons]    0.6.5claws53
+
+       * src/inc.c
+       * src/folder.[ch]
+       * src/procmsg.c
+       * src/filtering.c
+               more revisions of filtering system
+               (last stable version is marked as LAST_STABLE)
+               
+               | NOTE 1): the filtering system now uses a local folder called
+               | .processing. if filtering fails, check this directory
+               | for missing messages.
+               |
+               | NOTE 2): help us find the filtering actions still missing
+
 2001-12-05 [paul]      0.6.5claws52
 
        * src/mainwindow.c
 2001-12-05 [paul]      0.6.5claws52
 
        * src/mainwindow.c
index deb8bbaa5187de608b1f0f3b48fae00bb618c247..c56489019952231626ea0a15094e6a867c42b5c8 100644 (file)
@@ -8,7 +8,7 @@ MINOR_VERSION=6
 MICRO_VERSION=5
 INTERFACE_AGE=0
 BINARY_AGE=0
 MICRO_VERSION=5
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws52
+EXTRA_VERSION=claws53
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl
index 764d05c569e46e5ea63c53699034aee8ef960ed2..13c200a3062980a19bd5786220ab840a16b3a789 100644 (file)
@@ -334,13 +334,6 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
                        return FALSE;
                }       
 
                        return FALSE;
                }       
 
-               /* WRONG: can not update the mark, because the message has 
-                * been moved. info pertains to original location. 
-                * folder_item_move_msg() already updated the mark for the
-                * destination folder.
-               info->flags = 0;
-               filteringaction_update_mark(info);
-                */
                if (folder_table) {
                        val = GPOINTER_TO_INT(g_hash_table_lookup
                                              (folder_table, dest_folder));
                if (folder_table) {
                        val = GPOINTER_TO_INT(g_hash_table_lookup
                                              (folder_table, dest_folder));
@@ -349,13 +342,6 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
                                g_hash_table_insert(folder_table, dest_folder,
                                                    GINT_TO_POINTER(1));
                        }
                                g_hash_table_insert(folder_table, dest_folder,
                                                    GINT_TO_POINTER(1));
                        }
-                       val = GPOINTER_TO_INT(g_hash_table_lookup
-                                             (folder_table, info->folder));
-                       if (val == 0) {
-                               folder_item_scan(info->folder);
-                               g_hash_table_insert(folder_table, info->folder,
-                                                   GINT_TO_POINTER(1));
-                       }
                }
                return TRUE;
 
                }
                return TRUE;
 
@@ -366,10 +352,6 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
                if (!dest_folder)
                        return FALSE;
 
                if (!dest_folder)
                        return FALSE;
 
-               /* NOTE: the following call *will* update the mark file for
-                * the destination folder. but the original message will
-                * still be there in the inbox. */
-
                if (folder_item_copy_msg(dest_folder, info) == -1)
                        return FALSE;
 
                if (folder_item_copy_msg(dest_folder, info) == -1)
                        return FALSE;
 
@@ -387,50 +369,29 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
        case MATCHACTION_DELETE:
                if (folder_item_remove_msg(info->folder, info->msgnum) == -1)
                        return FALSE;
        case MATCHACTION_DELETE:
                if (folder_item_remove_msg(info->folder, info->msgnum) == -1)
                        return FALSE;
-
-               /* WRONG: can not update the mark. this would actually add
-                * a bogus record to the mark file for the message's original 
-                * folder. 
-               info->flags = 0;
-               filteringaction_update_mark(info);
-                */
-
                return TRUE;
 
        case MATCHACTION_MARK:
                MSG_SET_PERM_FLAGS(info->flags, MSG_MARKED);
                return TRUE;
 
        case MATCHACTION_MARK:
                MSG_SET_PERM_FLAGS(info->flags, MSG_MARKED);
-               filteringaction_update_mark(info);
-
-               CHANGE_FLAGS(info);
-
                return TRUE;
 
        case MATCHACTION_UNMARK:
                MSG_UNSET_PERM_FLAGS(info->flags, MSG_MARKED);
                return TRUE;
 
        case MATCHACTION_UNMARK:
                MSG_UNSET_PERM_FLAGS(info->flags, MSG_MARKED);
-               filteringaction_update_mark(info);
-
-               CHANGE_FLAGS(info);
-
                return TRUE;
                
        case MATCHACTION_MARK_AS_READ:
                MSG_UNSET_PERM_FLAGS(info->flags, MSG_UNREAD | MSG_NEW);
                return TRUE;
                
        case MATCHACTION_MARK_AS_READ:
                MSG_UNSET_PERM_FLAGS(info->flags, MSG_UNREAD | MSG_NEW);
-               filteringaction_update_mark(info);
-
-               CHANGE_FLAGS(info);
-
                return TRUE;
 
        case MATCHACTION_MARK_AS_UNREAD:
                MSG_SET_PERM_FLAGS(info->flags, MSG_UNREAD | MSG_NEW);
                return TRUE;
 
        case MATCHACTION_MARK_AS_UNREAD:
                MSG_SET_PERM_FLAGS(info->flags, MSG_UNREAD | MSG_NEW);
-               filteringaction_update_mark(info);
-
-               CHANGE_FLAGS(info);
-               
+               return TRUE;
+       
+       case MATCHACTION_COLOR:
+               MSG_SET_COLORLABEL_VALUE(info->flags, action->labelcolor);
                return TRUE;
 
        case MATCHACTION_FORWARD:
                return TRUE;
 
        case MATCHACTION_FORWARD:
-
                account = account_find_from_id(action->account_id);
                compose = compose_forward(account, info, FALSE);
                if (compose->account->protocol == A_NNTP)
                account = account_find_from_id(action->account_id);
                compose = compose_forward(account, info, FALSE);
                if (compose->account->protocol == A_NNTP)
@@ -465,12 +426,10 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
                        gtk_widget_destroy(compose->window);
                        return TRUE;
                }
                        gtk_widget_destroy(compose->window);
                        return TRUE;
                }
-
                gtk_widget_destroy(compose->window);
                return FALSE;
 
        case MATCHACTION_BOUNCE:
                gtk_widget_destroy(compose->window);
                return FALSE;
 
        case MATCHACTION_BOUNCE:
-
                account = account_find_from_id(action->account_id);
                compose = compose_bounce(account, info);
                if (compose->account->protocol == A_NNTP)
                account = account_find_from_id(action->account_id);
                compose = compose_bounce(account, info);
                if (compose->account->protocol == A_NNTP)
@@ -489,7 +448,6 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
                return FALSE;
 
        case MATCHACTION_EXECUTE:
                return FALSE;
 
        case MATCHACTION_EXECUTE:
-
                cmd = matching_build_command(action->destination, info);
                if (cmd == NULL)
                        return TRUE;
                cmd = matching_build_command(action->destination, info);
                if (cmd == NULL)
                        return TRUE;
@@ -497,8 +455,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
                        system(cmd);
                        g_free(cmd);
                }
                        system(cmd);
                        g_free(cmd);
                }
-
-               return TRUE;
+               return FALSE;
 
        default:
                return FALSE;
 
        default:
                return FALSE;
@@ -555,8 +512,10 @@ static gboolean filteringprop_apply(FilteringProp * filtering, MsgInfo * info,
 void filter_msginfo(GSList * filtering_list, MsgInfo * info,
                    GHashTable *folder_table)
 {
 void filter_msginfo(GSList * filtering_list, MsgInfo * info,
                    GHashTable *folder_table)
 {
-       GSList * l;
-
+       GSList          *l;
+       gboolean         result;
+       FolderItem      *inbox;
+       
        if (info == NULL) {
                g_warning(_("msginfo is not set"));
                return;
        if (info == NULL) {
                g_warning(_("msginfo is not set"));
                return;
@@ -564,10 +523,32 @@ void filter_msginfo(GSList * filtering_list, MsgInfo * info,
        
        for(l = filtering_list ; l != NULL ; l = g_slist_next(l)) {
                FilteringProp * filtering = (FilteringProp *) l->data;
        
        for(l = filtering_list ; l != NULL ; l = g_slist_next(l)) {
                FilteringProp * filtering = (FilteringProp *) l->data;
-               
-               if (filteringprop_apply(filtering, info, folder_table))
+               if (TRUE == (result = filteringprop_apply(filtering, info, folder_table))) 
                        break;
        }
                        break;
        }
+
+       /* drop in inbox too */
+       if (!result) {
+               gint val;
+
+               inbox = folder_get_default_inbox();
+               g_assert(inbox);
+               
+               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));
+                       }
+               }
+       }
 }
 
 void filter_msginfo_move_or_delete(GSList * filtering_list, MsgInfo * info,
 }
 
 void filter_msginfo_move_or_delete(GSList * filtering_list, MsgInfo * info,
index c45262f25ab2b86f4618ac0cf518319ca4c34e8a..ca10f0e70d5444d36a70d94881db9c59b6c0ab0d 100644 (file)
@@ -1546,3 +1546,51 @@ FolderItem * folder_find_item_from_identifier(const gchar *identifier)
                        folder_item_find_func, d);
        return d[1];
 }
                        folder_item_find_func, d);
        return d[1];
 }
+
+/* CLAWS: temporary local folder for filtering */
+
+static Folder *processing_folder;
+static FolderItem *processing_folder_item;
+
+static void folder_create_processing_folder(void)
+{
+#define PROCESSING_FOLDER ".processing"        
+       Folder     *tmpparent;
+       FolderItem *tmpfolder;
+       gchar      *tmpname;
+
+       tmpparent = folder_get_default_folder();
+       g_assert(tmpparent);
+       debug_print("tmpparentroot %s\n", LOCAL_FOLDER(tmpparent)->rootpath);
+       tmpname = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S,
+                             LOCAL_FOLDER(tmpparent)->rootpath,
+                             G_DIR_SEPARATOR_S, PROCESSING_FOLDER,
+                             NULL);
+
+       processing_folder = folder_new(F_MH, "PROCESSING", LOCAL_FOLDER(tmpparent)->rootpath);
+       g_assert(processing_folder);
+                             
+       if (!is_dir_exist(tmpname)) {
+               debug_print("*TMP* creating %s\n", tmpname);
+               processing_folder_item = processing_folder->create_folder(processing_folder,
+                                                                         processing_folder->node->data,
+                                                                         PROCESSING_FOLDER);
+               g_assert(processing_folder_item);                                                                         
+       }
+       else {
+               debug_print("*TMP* already created\n");
+               processing_folder_item = folder_item_new(".processing", ".processing");
+               g_assert(processing_folder_item);
+               folder_item_append(processing_folder->node->data, processing_folder_item);
+       }
+       g_free(tmpname);
+}
+
+FolderItem *folder_get_default_processing(void)
+{
+       if (!processing_folder_item) {
+               folder_create_processing_folder();
+       }
+       return processing_folder_item;
+}
+
index 8333140403a84d2382e009b399ac7e684018f627..899bddef201ef8b9507fe981b1a2d3a492bad3df 100644 (file)
@@ -278,6 +278,7 @@ FolderItem *folder_get_default_outbox       (void);
 FolderItem *folder_get_default_draft   (void);
 FolderItem *folder_get_default_queue   (void);
 FolderItem *folder_get_default_trash   (void);
 FolderItem *folder_get_default_draft   (void);
 FolderItem *folder_get_default_queue   (void);
 FolderItem *folder_get_default_trash   (void);
+FolderItem *folder_get_default_processing (void);
 
 gchar *folder_item_get_path            (FolderItem     *item);
 void   folder_item_scan                        (FolderItem     *item);
 
 gchar *folder_item_get_path            (FolderItem     *item);
 void   folder_item_scan                        (FolderItem     *item);
index d53793a01a344e1fa73ad317e1f49079a42a4244..58de021ea9762b0f439f1e196c90a035b77c3928 100644 (file)
--- a/src/inc.c
+++ b/src/inc.c
@@ -882,6 +882,7 @@ gint inc_drop_message(const gchar *file, Pop3State *state)
        FolderItem *dropfolder;
        gint val;
        gint msgnum;
        FolderItem *dropfolder;
        gint val;
        gint msgnum;
+       FolderItem *filtering_folder = folder_get_default_processing();
 
        if (state->ac_prefs->inbox) {
                inbox = folder_find_item_from_path(state->ac_prefs->inbox);
 
        if (state->ac_prefs->inbox) {
                inbox = folder_find_item_from_path(state->ac_prefs->inbox);
@@ -908,7 +909,7 @@ gint inc_drop_message(const gchar *file, Pop3State *state)
                        dropfolder = inbox;
        } else {
                /* new filtering */
                        dropfolder = inbox;
        } else {
                /* new filtering */
-               dropfolder = inbox;
+               dropfolder = filtering_folder;
        }
 
        val = GPOINTER_TO_INT(g_hash_table_lookup
        }
 
        val = GPOINTER_TO_INT(g_hash_table_lookup