1 /*
2  * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2020 the Claws Mail Team and Hiroyuki Yamamoto
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  */
19 
20 #ifndef FILTER_NEW_H
21 
22 #define FILTER_NEW_H
23 
24 #include <glib.h>
25 #include "matcher.h"
26 #include "procmsg.h"
27 
28 struct _FilteringAction {
29 	gint	type;
30 	gint	account_id;
31 	gchar  *destination;
32 	gint	labelcolor;
33 	gint	score;
34 	gchar  *header;
35 };
36 
37 typedef struct _FilteringAction FilteringAction;
38 
39 struct _FilteringProp {
40 	gboolean enabled;
41 	gchar *name;
42 	gint account_id;
43 	MatcherList * matchers;
44 	GSList * action_list;
45 };
46 
47 typedef struct _FilteringProp FilteringProp;
48 
49 enum {
50 	FILTERING_ACCOUNT_RULES_SKIP = 0,
51 	FILTERING_ACCOUNT_RULES_FORCE = 1,
52 	FILTERING_ACCOUNT_RULES_USE_CURRENT = 2
53 };
54 
55 typedef enum {
56 	FILTERING_INCORPORATION,
57 	FILTERING_MANUALLY,
58 	FILTERING_FOLDER_PROCESSING,
59 	FILTERING_PRE_PROCESSING,
60 	FILTERING_POST_PROCESSING
61 } FilteringInvocationType;
62 
63 typedef enum {
64 	FILTERING_DEBUG_LEVEL_LOW,
65 	FILTERING_DEBUG_LEVEL_MED,
66 	FILTERING_DEBUG_LEVEL_HIGH
67 } FilteringDebugLevel;
68 
69 /* extern GSList * prefs_filtering; */
70 
71 
72 FilteringAction * filteringaction_new(int type, int account_id,
73 				      gchar * destination,
74                                       gint labelcolor, gint score, gchar *header);
75 void filteringaction_free(FilteringAction *action);
76 FilteringAction * filteringaction_parse(gchar **str);
77 gboolean filteringaction_apply_action_list (GSList *action_list, MsgInfo *info);
78 
79 FilteringProp * filteringprop_new(gboolean enabled,
80 				  const gchar *name,
81 				  gint account_id,
82 				  MatcherList *matchers,
83 				  GSList *action_list);
84 void filteringprop_free(FilteringProp *prop);
85 
86 FilteringProp * filteringprop_parse(gchar **str);
87 
88 void filter_msginfo_move_or_delete(GSList *filtering_list, MsgInfo *info);
89 gboolean processing_enabled(GSList *filtering_list);
90 gboolean filter_message_by_msginfo(GSList *flist, MsgInfo *info, PrefsAccount *ac_prefs,
91 								   FilteringInvocationType context, gchar *extra_info);
92 
93 gchar * filteringaction_to_string(FilteringAction *action);
94 void prefs_filtering_write_config(void);
95 void prefs_filtering_read_config(void);
96 gchar * filteringaction_list_to_string(GSList * action_list);
97 gchar * filteringprop_to_string(FilteringProp *prop);
98 
99 void prefs_filtering_clear(void);
100 void prefs_filtering_clear_folder(Folder *folder);
101 
102 FilteringProp * filteringprop_copy(FilteringProp *src);
103 void filtering_move_and_copy_msgs(GSList *msglist);
104 extern GSList * filtering_rules;
105 extern GSList * pre_global_processing;
106 extern GSList * post_global_processing;
107 
108 gboolean filtering_peek_per_account_rules(GSList *filtering_list);
109 
110 GSList *filtering_action_list_sort(GSList *action_list);
111 gboolean filtering_action_list_rename_path(GSList *action_list, const gchar *old_path,
112 					const gchar *new_path);
113 
114 #endif
115