1 /* 2 * This program is free software; you can redistribute it and/or modify it 3 * under the terms of the GNU Lesser General Public License as published by 4 * the Free Software Foundation. 5 * 6 * This program is distributed in the hope that it will be useful, but 7 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 8 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 9 * for more details. 10 * 11 * You should have received a copy of the GNU Lesser General Public License 12 * along with this program; if not, see <http://www.gnu.org/licenses/>. 13 * 14 * 15 * Authors: 16 * Not Zed <notzed@lostzed.mmc.com.au> 17 * Jeffrey Stedfast <fejj@ximian.com> 18 * 19 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) 20 * 21 */ 22 23 #if !defined (__E_UTIL_H_INSIDE__) && !defined (LIBEUTIL_COMPILATION) 24 #error "Only <e-util/e-util.h> should be included directly." 25 #endif 26 27 #ifndef E_FILTER_RULE_H 28 #define E_FILTER_RULE_H 29 30 #include <e-util/e-filter-part.h> 31 32 /* Standard GObject macros */ 33 #define E_TYPE_FILTER_RULE \ 34 (e_filter_rule_get_type ()) 35 #define E_FILTER_RULE(obj) \ 36 (G_TYPE_CHECK_INSTANCE_CAST \ 37 ((obj), E_TYPE_FILTER_RULE, EFilterRule)) 38 #define E_FILTER_RULE_CLASS(cls) \ 39 (G_TYPE_CHECK_CLASS_CAST \ 40 ((cls), E_TYPE_FILTER_RULE, EFilterRuleClass)) 41 #define E_IS_FILTER_RULE(obj) \ 42 (G_TYPE_CHECK_INSTANCE_TYPE \ 43 ((obj), E_TYPE_FILTER_RULE)) 44 #define E_IS_FILTER_RULE_CLASS(cls) \ 45 (G_TYPE_CHECK_CLASS_TYPE \ 46 ((cls), E_TYPE_FILTER_RULE)) 47 #define E_FILTER_RULE_GET_CLASS(obj) \ 48 (G_TYPE_INSTANCE_GET_CLASS \ 49 ((obj), E_TYPE_FILTER_RULE, EFilterRuleClass)) 50 51 G_BEGIN_DECLS 52 53 struct _RuleContext; 54 55 typedef struct _EFilterRule EFilterRule; 56 typedef struct _EFilterRuleClass EFilterRuleClass; 57 typedef struct _EFilterRulePrivate EFilterRulePrivate; 58 59 enum _filter_grouping_t { 60 E_FILTER_GROUP_ALL, /* all rules must match */ 61 E_FILTER_GROUP_ANY /* any rule must match */ 62 }; 63 64 /* threading, if the context supports it */ 65 enum _filter_threading_t { 66 E_FILTER_THREAD_NONE, /* don't add any thread matching */ 67 E_FILTER_THREAD_ALL, /* add all possible threads */ 68 E_FILTER_THREAD_REPLIES, /* add only replies */ 69 E_FILTER_THREAD_REPLIES_PARENTS, /* replies plus parents */ 70 E_FILTER_THREAD_SINGLE /* messages with no replies or parents */ 71 }; 72 73 #define E_FILTER_SOURCE_INCOMING "incoming" /* performed on incoming email */ 74 #define E_FILTER_SOURCE_DEMAND "demand" /* performed on the selected folder 75 * when the user asks for it */ 76 #define E_FILTER_SOURCE_OUTGOING "outgoing"/* performed on outgoing mail */ 77 #define E_FILTER_SOURCE_JUNKTEST "junktest"/* check incoming mail for junk */ 78 79 struct _EFilterRule { 80 GObject parent_object; 81 EFilterRulePrivate *priv; 82 83 gchar *name; 84 gchar *source; 85 86 enum _filter_grouping_t grouping; 87 enum _filter_threading_t threading; 88 89 guint system:1; /* this is a system rule, cannot be edited/deleted */ 90 GList *parts; 91 92 gboolean enabled; 93 }; 94 95 struct _EFilterRuleClass { 96 GObjectClass parent_class; 97 98 /* virtual methods */ 99 gint (*validate) (EFilterRule *rule, 100 EAlert **alert); 101 gint (*eq) (EFilterRule *rule_a, 102 EFilterRule *rule_b); 103 104 xmlNodePtr (*xml_encode) (EFilterRule *rule); 105 gint (*xml_decode) (EFilterRule *rule, 106 xmlNodePtr node, 107 struct _ERuleContext *context); 108 109 void (*build_code) (EFilterRule *rule, 110 GString *out); 111 112 void (*copy) (EFilterRule *dst_rule, 113 EFilterRule *src_rule); 114 115 GtkWidget * (*get_widget) (EFilterRule *rule, 116 struct _ERuleContext *context); 117 118 /* signals */ 119 void (*changed) (EFilterRule *rule); 120 }; 121 122 GType e_filter_rule_get_type (void) G_GNUC_CONST; 123 EFilterRule * e_filter_rule_new (void); 124 EFilterRule * e_filter_rule_clone (EFilterRule *rule); 125 void e_filter_rule_set_name (EFilterRule *rule, 126 const gchar *name); 127 void e_filter_rule_set_source (EFilterRule *rule, 128 const gchar *source); 129 gint e_filter_rule_validate (EFilterRule *rule, 130 EAlert **alert); 131 gint e_filter_rule_eq (EFilterRule *rule_a, 132 EFilterRule *rule_b); 133 xmlNodePtr e_filter_rule_xml_encode (EFilterRule *rule); 134 gint e_filter_rule_xml_decode (EFilterRule *rule, 135 xmlNodePtr node, 136 struct _ERuleContext *context); 137 void e_filter_rule_copy (EFilterRule *dst_rule, 138 EFilterRule *src_rule); 139 void e_filter_rule_add_part (EFilterRule *rule, 140 EFilterPart *part); 141 void e_filter_rule_remove_part (EFilterRule *rule, 142 EFilterPart *part); 143 void e_filter_rule_replace_part (EFilterRule *rule, 144 EFilterPart *old_part, 145 EFilterPart *new_part); 146 GtkWidget * e_filter_rule_get_widget (EFilterRule *rule, 147 struct _ERuleContext *context); 148 void e_filter_rule_build_code (EFilterRule *rule, 149 GString *out); 150 void e_filter_rule_emit_changed (EFilterRule *rule); 151 152 /* static functions */ 153 EFilterRule * e_filter_rule_next_list (GList *list, 154 EFilterRule *last, 155 const gchar *source); 156 EFilterRule * e_filter_rule_find_list (GList *list, 157 const gchar *name, 158 const gchar *source); 159 160 G_END_DECLS 161 162 #endif /* E_FILTER_RULE_H */ 163