aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNot Zed <NotZed@HelixCode.com>2000-05-28 14:14:53 +0800
committerMichael Zucci <zucchi@src.gnome.org>2000-05-28 14:14:53 +0800
commitd11f78c349719e66a6eb569f6f1a65d268a6dec4 (patch)
tree0ca5820b101fda23a3aae53539e7018abac554d8
parent350fde81677a44e5203a38c833e5175c3b649de2 (diff)
downloadgsoc2013-evolution-d11f78c349719e66a6eb569f6f1a65d268a6dec4.tar
gsoc2013-evolution-d11f78c349719e66a6eb569f6f1a65d268a6dec4.tar.gz
gsoc2013-evolution-d11f78c349719e66a6eb569f6f1a65d268a6dec4.tar.bz2
gsoc2013-evolution-d11f78c349719e66a6eb569f6f1a65d268a6dec4.tar.lz
gsoc2013-evolution-d11f78c349719e66a6eb569f6f1a65d268a6dec4.tar.xz
gsoc2013-evolution-d11f78c349719e66a6eb569f6f1a65d268a6dec4.tar.zst
gsoc2013-evolution-d11f78c349719e66a6eb569f6f1a65d268a6dec4.zip
New file - lists rules appropriate for vfolders (no actions, etc).
2000-05-27 Not Zed <NotZed@HelixCode.com> * vfoldertypes.xml: New file - lists rules appropriate for vfolders (no actions, etc). * Makefile.am (EXTRA_DIST): Add vfoldertypes.xml * filter-driver.c (filter_driver_expand_option): Made public from expand_filter_option. (filter_driver_rule_count): find out how many user rules are defined. (filter_driver_rule_get): Get a user rule by index. svn path=/trunk/; revision=3240
-rw-r--r--filter/ChangeLog13
-rw-r--r--filter/Makefile.am6
-rw-r--r--filter/filter-driver.c76
-rw-r--r--filter/filter-driver.h8
-rw-r--r--filter/vfoldertypes.xml60
5 files changed, 133 insertions, 30 deletions
diff --git a/filter/ChangeLog b/filter/ChangeLog
index 9387f72a4e..cb9562d284 100644
--- a/filter/ChangeLog
+++ b/filter/ChangeLog
@@ -1,3 +1,16 @@
+2000-05-27 Not Zed <NotZed@HelixCode.com>
+
+ * vfoldertypes.xml: New file - lists rules appropriate for
+ vfolders (no actions, etc).
+
+ * Makefile.am (EXTRA_DIST): Add vfoldertypes.xml
+
+ * filter-driver.c (filter_driver_expand_option): Made public from
+ expand_filter_option.
+ (filter_driver_rule_count): find out how many user rules are
+ defined.
+ (filter_driver_rule_get): Get a user rule by index.
+
2000-05-21 Ettore Perazzoli <ettore@helixcode.com>
* filter-druid.c: Don't pass an empty URL to `gtk_html_begin()'
diff --git a/filter/Makefile.am b/filter/Makefile.am
index 05d56a2ca5..b6369253ac 100644
--- a/filter/Makefile.am
+++ b/filter/Makefile.am
@@ -28,8 +28,10 @@ libfilter_la_SOURCES = \
filter-driver.c \
filter-driver.h
-EXTRA_DIST = blank.xpm check.xpm filtertypes.xml
+EXTRA_DIST = blank.xpm check.xpm \
+ filtertypes.xml vfoldertypes.xml
# basic rules.
filterdir = $(prefix)/share/evolution
-filter_DATA = filtertypes.xml
+filter_DATA = filtertypes.xml vfoldertypes.xml
+
diff --git a/filter/filter-driver.c b/filter/filter-driver.c
index 17ced7412d..e43f543611 100644
--- a/filter/filter-driver.c
+++ b/filter/filter-driver.c
@@ -301,46 +301,52 @@ expand_variables(GString *out, char *source, GList *args, GHashTable *globals)
/*
build an expression for the filter
*/
-static void
-expand_filter_option(FilterDriver *d, GString *s, GString *action, struct filter_option *op)
+void
+filter_driver_expand_option(FilterDriver *d, GString *s, GString *action, struct filter_option *op)
{
GList *optionl;
FilterArg *arg;
struct _FilterDriverPrivate *p = _PRIVATE(d);
- g_string_append(s, "(and ");
- optionl = op->options;
- while (optionl) {
- struct filter_optionrule *or = optionl->data;
- if (or->rule->type == FILTER_XML_MATCH
- || or->rule->type == FILTER_XML_EXCEPT) {
- if (or->args) {
- arg = or->args->data;
- if (arg) {
- printf("arg = %s\n", arg->name);
+ if (s) {
+ g_string_append(s, "(and ");
+ optionl = op->options;
+ while (optionl) {
+ struct filter_optionrule *or = optionl->data;
+ if (or->rule->type == FILTER_XML_MATCH
+ || or->rule->type == FILTER_XML_EXCEPT) {
+ if (or->args) {
+ arg = or->args->data;
+ if (arg) {
+ printf("arg = %s\n", arg->name);
+ }
}
+ expand_variables(s, or->rule->code, or->args, p->globals);
}
- expand_variables(s, or->rule->code, or->args, p->globals);
+ optionl = g_list_next(optionl);
}
- optionl = g_list_next(optionl);
- }
- g_string_append(s, ")");
+ g_string_append(s, ")");
+ }
- g_string_append(action, "(begin ");
- optionl = op->options;
- while (optionl) {
- struct filter_optionrule *or = optionl->data;
- if (or->rule->type == FILTER_XML_ACTION) {
- expand_variables(action, or->rule->code, or->args, p->globals);
- g_string_append(action, " ");
+ if (action) {
+ g_string_append(action, "(begin ");
+ optionl = op->options;
+ while (optionl) {
+ struct filter_optionrule *or = optionl->data;
+ if (or->rule->type == FILTER_XML_ACTION) {
+ expand_variables(action, or->rule->code, or->args, p->globals);
+ g_string_append(action, " ");
+ }
+ optionl = g_list_next(optionl);
}
- optionl = g_list_next(optionl);
+ g_string_append(action, ")");
}
- g_string_append(action, ")");
- printf("combined rule '%s'\n", s->str);
- printf("combined action '%s'\n", action->str);
+ if (s)
+ printf("combined rule '%s'\n", s->str);
+ if (action)
+ printf("combined action '%s'\n", action->str);
}
static ESExpResult *
@@ -523,6 +529,20 @@ close_folders(FilterDriver *d)
}
int
+filter_driver_rule_count(FilterDriver *d)
+{
+ struct _FilterDriverPrivate *p = _PRIVATE(d);
+ return g_list_length(p->options);
+}
+
+struct filter_option *
+filter_driver_rule_get(FilterDriver *d, int n)
+{
+ struct _FilterDriverPrivate *p = _PRIVATE(d);
+ return g_list_nth_data(p->options, n);
+}
+
+int
filter_driver_run(FilterDriver *d, CamelFolder *source, CamelFolder *inbox)
{
struct _FilterDriverPrivate *p = _PRIVATE(d);
@@ -549,7 +569,7 @@ filter_driver_run(FilterDriver *d, CamelFolder *source, CamelFolder *inbox)
s = g_string_new("");
a = g_string_new("");
- expand_filter_option(d, s, a, fo);
+ filter_driver_expand_option(d, s, a, fo);
printf("searching expression %s\n", s->str);
p->matches = camel_folder_search_by_expression (p->source, s->str, p->ex);
diff --git a/filter/filter-driver.h b/filter/filter-driver.h
index dc670bc85e..ad9afca53f 100644
--- a/filter/filter-driver.h
+++ b/filter/filter-driver.h
@@ -25,6 +25,7 @@
#include <gtk/gtk.h>
#include <camel/camel-session.h>
#include <camel/camel-folder.h>
+#include "filter-xml.h"
#define FILTER_DRIVER(obj) GTK_CHECK_CAST (obj, filter_driver_get_type (), FilterDriver)
#define FILTER_DRIVER_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, filter_driver_get_type (), FilterDriverClass)
@@ -55,4 +56,11 @@ void filter_driver_set_global(FilterDriver *, const char *name, const char *valu
/* apply rules to a folder, unmatched messages goto inbox, if not NULL */
int filter_driver_run(FilterDriver *d, CamelFolder *source, CamelFolder *inbox);
+/* generate the search query/action string for a filter option */
+void filter_driver_expand_option(FilterDriver *d, GString *s, GString *action, struct filter_option *op);
+
+/* get info about rules (options) */
+int filter_driver_rule_count(FilterDriver *d);
+struct filter_option *filter_driver_rule_get(FilterDriver *d, int n);
+
#endif /* ! _FILTER_DRIVER_H */
diff --git a/filter/vfoldertypes.xml b/filter/vfoldertypes.xml
new file mode 100644
index 0000000000..bb12220d31
--- /dev/null
+++ b/filter/vfoldertypes.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0"?>
+<filterdescription>
+<ruleset type="match">
+<rule name="from-address">
+ <code>
+ (match-all (header-contains "From" ${sender}))
+ </code>
+ <description lang="en">The From address matches <source type="address" name="sender">sender(s)</source>.</description>
+</rule>
+
+<rule name="to-address">
+ <code>
+ (match-all (header-contains "To" ${receipient}))
+ </code>
+ <description lang="en">The To address matches <source type="address" name="receipient">receipients</source>.</description>
+</rule>
+
+<rule name="subject-contains">
+ <code>
+ (match-all (header-contains "Subject" ${words}))
+ </code>
+ <description lang="en">The Subject contains <source type="folder" name="words">words</source>.</description>
+</rule>
+
+<rule name="cc-address">
+ <code>
+ (match-all (header-contains "CC" ${self-email}))
+ </code>
+ <description lang="en">I am in the cc list.</description>
+</rule>
+
+</ruleset>
+
+<ruleset type="except">
+<rule name="except-me">
+ <code>
+ (match-all (not (header-contains "To" ${self-email})))
+ </code>
+ <description language="en">I am the receipient.</description>
+</rule>
+</ruleset>
+
+<optionset>
+ <option type="match">
+ <description language="en">For matching messages.</description>
+ </option>
+ <option type="match">
+ <description language="en">Messages from a certain person.</description>
+ <optionrule type="match" rule="from-address"/>
+ </option>
+ <option type="match">
+ <description language="en">Messages to a certain address.</description>
+ <optionrule type="match" rule="to-address"/>
+ </option>
+ <option type="match">
+ <description language="en">Messages with a given subject.</description>
+ <optionrule type="match" rule="subject-contains"/>
+ </option>
+</optionset>
+</filterdescription>