From: Alfons Hoogervorst Date: Wed, 5 Dec 2001 22:09:25 +0000 (+0000) Subject: more revision of filtering system X-Git-Tag: rel_0_6_6~77 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=0e7a5f527936ffdad387e1e06ebacde5a475874f more revision of filtering system --- diff --git a/ChangeLog.claws b/ChangeLog.claws index 0810b443e..f54c6aea7 100644 --- a/ChangeLog.claws +++ b/ChangeLog.claws @@ -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 diff --git a/configure.in b/configure.in index deb8bbaa5..c56489019 100644 --- a/configure.in +++ b/configure.in @@ -8,7 +8,7 @@ MINOR_VERSION=6 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 diff --git a/src/filtering.c b/src/filtering.c index 764d05c56..13c200a30 100644 --- a/src/filtering.c +++ b/src/filtering.c @@ -334,13 +334,6 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info, 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)); @@ -349,13 +342,6 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info, 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; @@ -366,10 +352,6 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info, 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; @@ -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; - - /* 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); - filteringaction_update_mark(info); - - CHANGE_FLAGS(info); - 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); - filteringaction_update_mark(info); - - CHANGE_FLAGS(info); - 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: - 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 FALSE; case MATCHACTION_BOUNCE: - 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: - 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); } - - return TRUE; + 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) { - GSList * l; - + GSList *l; + gboolean result; + FolderItem *inbox; + 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; - - if (filteringprop_apply(filtering, info, folder_table)) + if (TRUE == (result = filteringprop_apply(filtering, info, folder_table))) 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, diff --git a/src/folder.c b/src/folder.c index c45262f25..ca10f0e70 100644 --- a/src/folder.c +++ b/src/folder.c @@ -1546,3 +1546,51 @@ FolderItem * folder_find_item_from_identifier(const gchar *identifier) 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; +} + diff --git a/src/folder.h b/src/folder.h index 833314040..899bddef2 100644 --- a/src/folder.h +++ b/src/folder.h @@ -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_processing (void); gchar *folder_item_get_path (FolderItem *item); void folder_item_scan (FolderItem *item); diff --git a/src/inc.c b/src/inc.c index d53793a01..58de021ea 100644 --- 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 *filtering_folder = folder_get_default_processing(); 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; + dropfolder = filtering_folder; } val = GPOINTER_TO_INT(g_hash_table_lookup