0.8.11claws76
authorChristoph Hohmann <reboot@gmx.ch>
Mon, 7 Apr 2003 22:32:29 +0000 (22:32 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Mon, 7 Apr 2003 22:32:29 +0000 (22:32 +0000)
* src/filtering.[ch]
* src/inc.[ch]
* src/mbox.c
* src/procmsg.[ch]
        add procmsg_msginfo_filter() to execute filtering actions

ChangeLog.claws
configure.ac
src/filtering.c
src/filtering.h
src/inc.c
src/inc.h
src/mbox.c
src/plugins/spamassassin/spamassassin.c
src/procmsg.c
src/procmsg.h

index 9318e6b406fa7629a2ff56661e95eeccd962c483..1899a8a7c8ae8342329c94196c2e201e372cf66c 100644 (file)
@@ -1,3 +1,11 @@
+2003-04-07 [christoph] 0.8.11claws76
+
+       * src/filtering.[ch]
+       * src/inc.[ch]
+       * src/mbox.c
+       * src/procmsg.[ch]
+               add procmsg_msginfo_filter() to execute filtering actions
+
 2003-04-06 [christoph] 0.8.11claws75
 
        * src/imap.c
 2003-04-06 [christoph] 0.8.11claws75
 
        * src/imap.c
index 5a45d0fdd2538b651cb06df4b6629a65bdd2c931..ec9c2a70a9a83d57871be6d479e1b21cd19b2f13 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=11
 INTERFACE_AGE=0
 BINARY_AGE=0
 MICRO_VERSION=11
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws75
+EXTRA_VERSION=claws76
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 5640ad6f5017505e42865d27d1f83b7e396aaf01..019bfa39ec22e3a089bfba0d54d834ef0bb32dc3 100644 (file)
@@ -322,17 +322,13 @@ static gboolean filtering_is_final_action(FilteringProp *filtering)
        }
 }
 
        }
 }
 
-static void filter_msginfo(GSList * filtering_list, FolderItem *inbox,
-                          MsgInfo * info)
+static gboolean filter_msginfo(GSList * filtering_list, MsgInfo * info)
 {
        GSList  *l;
        gboolean final;
        gboolean applied;
        
 {
        GSList  *l;
        gboolean final;
        gboolean applied;
        
-       if (info == NULL) {
-               g_warning("msginfo is not set");
-               return;
-       }
+       g_return_val_if_fail(info != NULL, TRUE);
        
        for (l = filtering_list, final = FALSE, applied = FALSE; l != NULL; l = g_slist_next(l)) {
                FilteringProp * filtering = (FilteringProp *) l->data;
        
        for (l = filtering_list, final = FALSE, applied = FALSE; l != NULL; l = g_slist_next(l)) {
                FilteringProp * filtering = (FilteringProp *) l->data;
@@ -347,87 +343,15 @@ 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) {
        /* 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 (inbox != info->folder) {
-                       if (folder_item_move_msg(inbox, info) == -1) {
-                               debug_print("*** Could not drop message in inbox; check .processing\n");
-                               return;
-                       }       
-               }       
+               return FALSE;
        }
        }
-}
 
 
-/*!
- *\brief       filters a message based on its message info data
- *
- *\param       flist filter and actions list
- *\param       info message
- */
-void filter_message_by_msginfo_with_inbox(GSList *flist, MsgInfo *info, FolderItem *def_inbox)
-{
-       FolderItem *inbox;
-
-       if ((def_inbox == NULL)) {
-               debug_print("using default inbox as final destination!\n");
-               inbox = folder_get_default_inbox();
-       } else
-               inbox = def_inbox;
-
-       /*
-        * message is already in a folder. the filtering code will
-        * handle duplicate moves and copies.
-        */
-       filter_msginfo(flist, inbox, info);
+       return TRUE;
 }
 
 }
 
-void filter_message_by_msginfo(GSList *flist, MsgInfo *info)
+gboolean filter_message_by_msginfo(GSList *flist, MsgInfo *info)
 {
 {
-       filter_message_by_msginfo_with_inbox(flist, info, info->folder);
-}
-
-/*!
- *\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
-  *            changed after the call to this function
-  */
-void filter_message(GSList *filtering_list, FolderItem *inbox,
-                   gint msgnum)
-{
-       MsgInfo *msginfo;
-       gchar *filename;
-       MsgFlags  msgflags = { 0, 0 };
-       FolderItem *item = folder_get_default_processing();
-
-       if (item == NULL) {
-               g_warning("folderitem not set");
-               return;
-       }
-
-       filename = folder_item_fetch_msg(item, msgnum);
-
-       if (filename == NULL) {
-               g_warning("filename is not set");
-               return;
-       }
-
-       msginfo = procheader_parse_file(filename, msgflags, TRUE, FALSE);
-       
-       g_free(filename);
-
-       if (msginfo == NULL) {
-               g_warning("could not get info for %s", filename);
-               return;
-       }
-
-       msginfo->folder = item;
-       msginfo->msgnum = msgnum;
-
-       filter_msginfo(filtering_list, inbox, msginfo);
-
-       procmsg_msginfo_free(msginfo);
+       return filter_msginfo(flist, info);
 }
 
 gchar *filteringaction_to_string(gchar *dest, gint destlen, FilteringAction *action)
 }
 
 gchar *filteringaction_to_string(gchar *dest, gint destlen, FilteringAction *action)
index 839051c9667db76679ece0c63fc0f8385770b151..15f677f3ddf973e4dea54f51544e2ee23beeb45e 100644 (file)
@@ -58,11 +58,7 @@ void filteringprop_free(FilteringProp *prop);
 FilteringProp * filteringprop_parse(gchar **str);
 
 void filter_msginfo_move_or_delete(GSList *filtering_list, MsgInfo *info);
 FilteringProp * filteringprop_parse(gchar **str);
 
 void filter_msginfo_move_or_delete(GSList *filtering_list, MsgInfo *info);
-void filter_message_by_msginfo_with_inbox(GSList *flist, MsgInfo *info, 
-                                         FolderItem *def_inbox);
-void filter_message_by_msginfo(GSList *flist, MsgInfo *info);
-void filter_message(GSList *filtering_list, FolderItem *inbox,
-                   gint msgnum);
+gboolean filter_message_by_msginfo(GSList *flist, MsgInfo *info);
 
 gchar * filteringaction_to_string(gchar *dest, gint destlen, FilteringAction *action);
 void prefs_filtering_write_config(void);
 
 gchar * filteringaction_to_string(gchar *dest, gint destlen, FilteringAction *action);
 void prefs_filtering_write_config(void);
index e67722de61e137be2d4efeddc2ce199ca0fd6e64..42d7a192089953c0a8689cb4fb7bec3cacd329d8 100644 (file)
--- a/src/inc.c
+++ b/src/inc.c
@@ -582,20 +582,9 @@ static gint inc_start(IncProgressDialog *inc_dialog)
 
                /* process messages */
                for(msglist_element = msglist; msglist_element != NULL; msglist_element = msglist_element->next) {
 
                /* process messages */
                for(msglist_element = msglist; msglist_element != NULL; msglist_element = msglist_element->next) {
-                       MailFilteringData mail_filtering_data;
                        msginfo = (MsgInfo *) msglist_element->data;
                        msginfo = (MsgInfo *) msglist_element->data;
-                       
-                       mail_filtering_data.msginfo = msginfo;
-                       
-                       if (!hooks_invoke(MAIL_FILTERING_HOOKLIST, &mail_filtering_data)) {
-                               /* filter if enabled in prefs or move to inbox if not */
-                               if(global_processing && pop3_session->ac_prefs->filter_on_recv) {
-                                       filter_message_by_msginfo_with_inbox(global_processing, msginfo,
-                                                                            inbox);
-                               } else {
-                                       folder_item_move_msg(inbox, msginfo);
-                               }
-                       }
+                       if (!pop3_session->ac_prefs->filter_on_recv || !procmsg_msginfo_filter(msginfo))
+                               folder_item_move_msg(inbox, msginfo);
                        procmsg_msginfo_free(msginfo);
                }
                g_slist_free(msglist);
                        procmsg_msginfo_free(msginfo);
                }
                g_slist_free(msglist);
index 013864e8ade3d7982c7c9b2ee67c8fef71a0acb5..8cf1cf8809b702ce471ee637d1e7f3e61690ce92 100644 (file)
--- a/src/inc.h
+++ b/src/inc.h
 #include "session.h"
 #include "pop.h"
 
 #include "session.h"
 #include "pop.h"
 
-#define MAIL_FILTERING_HOOKLIST "mail_filtering_hooklist"
-
 typedef struct _IncProgressDialog      IncProgressDialog;
 typedef struct _IncSession             IncSession;
 typedef struct _IncProgressDialog      IncProgressDialog;
 typedef struct _IncSession             IncSession;
-typedef struct _MailFilteringData      MailFilteringData;
-
 typedef enum
 {
        INC_SUCCESS,
 typedef enum
 {
        INC_SUCCESS,
@@ -71,11 +67,6 @@ struct _IncSession
        gpointer data;
 };
 
        gpointer data;
 };
 
-struct _MailFilteringData
-{
-       MsgInfo *msginfo;
-};
-
 #define TIMEOUT_ITV    200
 
 void inc_mail                  (MainWindow     *mainwin,
 #define TIMEOUT_ITV    200
 
 void inc_mail                  (MainWindow     *mainwin,
index ed152ac01f2fd6687ab541193c8c67dfdde874d1..b2c3105ed9385b3c4971e89b81b8bda9db4921ee 100644 (file)
@@ -62,6 +62,7 @@ gint proc_mbox(FolderItem *dest, const gchar *mbox)
        gchar buf[MSGBUFSIZE], from_line[MSGBUFSIZE];
        gchar *tmp_file;
        gint msgs = 0;
        gchar buf[MSGBUFSIZE], from_line[MSGBUFSIZE];
        gchar *tmp_file;
        gint msgs = 0;
+       MsgInfo *msginfo;
 
        g_return_val_if_fail(dest != NULL, -1);
        g_return_val_if_fail(mbox != NULL, -1);
 
        g_return_val_if_fail(dest != NULL, -1);
        g_return_val_if_fail(mbox != NULL, -1);
@@ -212,8 +213,11 @@ gint proc_mbox(FolderItem *dest, const gchar *mbox)
                        return -1;
                }
 
                        return -1;
                }
 
-               filter_message(global_processing, dest,
-                              msgnum);
+               
+               msginfo = folder_item_get_msginfo(dropfolder, msgnum);
+               if (!procmsg_msginfo_filter(msginfo))
+                       folder_item_move_msg(dropfolder, msginfo);
+               procmsg_msginfo_free(msginfo);
 
                msgs++;
        } while (from_line[0] != '\0');
 
                msgs++;
        } while (from_line[0] != '\0');
index 719ca7a552978c51012231e61544daa47b422d3f..99bb273bdfc36925056daf1f11c99b646b4f8bf6 100644 (file)
@@ -32,7 +32,6 @@
 #include "plugin.h"
 #include "common/utils.h"
 #include "hooks.h"
 #include "plugin.h"
 #include "common/utils.h"
 #include "hooks.h"
-#include "inc.h"
 #include "procmsg.h"
 #include "folder.h"
 #include "prefs.h"
 #include "procmsg.h"
 #include "folder.h"
 #include "prefs.h"
index d4d242f34aa3e661eb514f7358040f95dac5b450..e38abfa6d68d3c4cbba4bc47866a1d96f35033ab 100644 (file)
@@ -41,6 +41,7 @@
 #include "news.h"
 #include "hooks.h"
 #include "msgcache.h"
 #include "news.h"
 #include "hooks.h"
 #include "msgcache.h"
+#include "filtering.h"
 
 typedef struct _FlagInfo       FlagInfo;
 
 
 typedef struct _FlagInfo       FlagInfo;
 
@@ -1331,3 +1332,26 @@ void procmsg_msginfo_set_to_folder(MsgInfo *msginfo, FolderItem *to_folder)
                folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
        }
 }
                folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
        }
 }
+
+/**
+ * Apply filtering actions to the msginfo
+ *
+ * \param msginfo The MsgInfo describing the message that should be filtered
+ * \return TRUE if the message was moved and MsgInfo is now invalid,
+ *         FALSE otherwise
+ */
+gboolean procmsg_msginfo_filter(MsgInfo *msginfo)
+{
+       MailFilteringData mail_filtering_data;
+                       
+       mail_filtering_data.msginfo = msginfo;                  
+       if (hooks_invoke(MAIL_FILTERING_HOOKLIST, &mail_filtering_data))
+               return TRUE;
+
+       /* filter if enabled in prefs or move to inbox if not */
+       if((global_processing != NULL) &&
+          filter_message_by_msginfo(global_processing, msginfo))
+               return TRUE;
+
+       return FALSE;
+}
index afeecef4bf5b4cbd8313b7a1d582c1c8d75a07e8..d5216e7fcbd334a17807a944435ad2a8eff5ea38 100644 (file)
 #include <sys/types.h>
 #include <string.h>
 
 #include <sys/types.h>
 #include <string.h>
 
-typedef struct _MsgInfo                MsgInfo;
-typedef struct _MsgFlags       MsgFlags;
-typedef struct _MsgInfoUpdate  MsgInfoUpdate;
+typedef struct _MsgInfo                        MsgInfo;
+typedef struct _MsgFlags               MsgFlags;
+typedef struct _MsgInfoUpdate          MsgInfoUpdate;
+typedef struct _MailFilteringData      MailFilteringData;
 
 typedef GSList MsgInfoList;
 typedef GSList MsgNumberList;
 
 typedef GSList MsgInfoList;
 typedef GSList MsgNumberList;
@@ -145,6 +146,7 @@ typedef enum
 #define MSG_IS_RETRCPT_PENDING(msg)    (((msg).perm_flags & MSG_RETRCPT_PENDING) != 0)
 
 #define MSGINFO_UPDATE_HOOKLIST "msginfo_update"
 #define MSG_IS_RETRCPT_PENDING(msg)    (((msg).perm_flags & MSG_RETRCPT_PENDING) != 0)
 
 #define MSGINFO_UPDATE_HOOKLIST "msginfo_update"
+#define MAIL_FILTERING_HOOKLIST "mail_filtering_hooklist"
 
 #include "folder.h"
 #include "procmime.h"
 
 #include "folder.h"
 #include "procmime.h"
@@ -201,6 +203,11 @@ struct _MsgInfoUpdate {
        MsgInfo *msginfo;
 };
 
        MsgInfo *msginfo;
 };
 
+struct _MailFilteringData
+{
+       MsgInfo *msginfo;
+};
+
 GHashTable *procmsg_msg_hash_table_create      (GSList         *mlist);
 void procmsg_msg_hash_table_append             (GHashTable     *msg_table,
                                                 GSList         *mlist);
 GHashTable *procmsg_msg_hash_table_create      (GSList         *mlist);
 void procmsg_msg_hash_table_append             (GHashTable     *msg_table,
                                                 GSList         *mlist);
@@ -269,4 +276,5 @@ void procmsg_update_unread_children (MsgInfo        *info,
                                         gboolean        newly_marked);
 void procmsg_msginfo_set_to_folder     (MsgInfo        *msginfo,
                                         FolderItem     *to_folder);
                                         gboolean        newly_marked);
 void procmsg_msginfo_set_to_folder     (MsgInfo        *msginfo,
                                         FolderItem     *to_folder);
+gboolean procmsg_msginfo_filter                (MsgInfo        *msginfo);
 #endif /* __PROCMSG_H__ */
 #endif /* __PROCMSG_H__ */