aboutsummaryrefslogtreecommitdiffstats
path: root/filter/rule-context.c
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2004-06-17 15:34:07 +0800
committerMichael Zucci <zucchi@src.gnome.org>2004-06-17 15:34:07 +0800
commit5d5f3b88c3ad76e0b81763f9c48b7fee84df2292 (patch)
tree09183c61366e096483b998752eb9eb37224c210f /filter/rule-context.c
parent7ca7b54a79f4abb9aa3e173e4ef245049d7c72bc (diff)
downloadgsoc2013-evolution-5d5f3b88c3ad76e0b81763f9c48b7fee84df2292.tar
gsoc2013-evolution-5d5f3b88c3ad76e0b81763f9c48b7fee84df2292.tar.gz
gsoc2013-evolution-5d5f3b88c3ad76e0b81763f9c48b7fee84df2292.tar.bz2
gsoc2013-evolution-5d5f3b88c3ad76e0b81763f9c48b7fee84df2292.tar.lz
gsoc2013-evolution-5d5f3b88c3ad76e0b81763f9c48b7fee84df2292.tar.xz
gsoc2013-evolution-5d5f3b88c3ad76e0b81763f9c48b7fee84df2292.tar.zst
gsoc2013-evolution-5d5f3b88c3ad76e0b81763f9c48b7fee84df2292.zip
** See #59885.
2004-06-17 Not Zed <NotZed@Ximian.com> ** See #59885. ** Moved all of the mailer specific filter stuff into mail/*. * filter-element.c (copy_value): implement for base types. * filter-element.c (filter_element_copy_value): do this as a virtual method. * filter.glade: moved the vfolder stuff to mail/ * libfilter-i18n.h: removed, moved to mailer. * filter-errors.xml: moved the vfolder/filtering errors to the mail error file. * Makefile.am (EXTRA_DIST): moved *types.xml to mail. (INCLUDES): removed a bunch of mail dependencies. * filter-*.[ch], vfolder-*.[ch]: Moved all mail related filter and vfolder stuff to mail directory. * score-*.[ch]: Removed all of it. * vfolder-context.c (vfolder_new_element): and for vfolders. * filter-context.c (filter_new_element): implement for filter element types. * rule-context.c (rc_new_element): replacement for old filter_element_new_type_name. only has the basics. * filter-part.c (filter_part_xml_create): take a rule context as an argument & and look up the element name off the context. * rule-context.c (rule_context_new_element): new virtual method to get an element for a given name. * filter-element.c (filter_element_new_type_name): removed. svn path=/trunk/; revision=26379
Diffstat (limited to 'filter/rule-context.c')
-rw-r--r--filter/rule-context.c66
1 files changed, 64 insertions, 2 deletions
diff --git a/filter/rule-context.c b/filter/rule-context.c
index 291f9d303f..560e9100a4 100644
--- a/filter/rule-context.c
+++ b/filter/rule-context.c
@@ -41,6 +41,15 @@
#include "filter-rule.h"
#include "filter-marshal.h"
+#include "filter-input.h"
+#include "filter-option.h"
+#include "filter-code.h"
+#include "filter-colour.h"
+#include "filter-datespec.h"
+#include "filter-int.h"
+#include "filter-file.h"
+#include "filter-label.h"
+
#define d(x)
static int load(RuleContext *rc, const char *system, const char *user);
@@ -48,6 +57,7 @@ static int save(RuleContext *rc, const char *user);
static int revert(RuleContext *rc, const char *user);
static GList *rename_uri(RuleContext *rc, const char *olduri, const char *newuri, GCompareFunc cmp);
static GList *delete_uri(RuleContext *rc, const char *uri, GCompareFunc cmp);
+static FilterElement *new_element(RuleContext *rc, const char *name);
static void rule_context_class_init(RuleContextClass *klass);
static void rule_context_init(RuleContext *rc);
@@ -110,7 +120,8 @@ rule_context_class_init(RuleContextClass *klass)
klass->revert = revert;
klass->rename_uri = rename_uri;
klass->delete_uri = delete_uri;
-
+ klass->new_element = new_element;
+
/* signals */
signals[RULE_ADDED] =
g_signal_new("rule_added",
@@ -326,7 +337,7 @@ load(RuleContext *rc, const char *system, const char *user)
if (!strcmp(rule->name, "part")) {
FilterPart *part = FILTER_PART(g_object_new(part_map->type, NULL, NULL));
- if (filter_part_xml_create(part, rule) == 0) {
+ if (filter_part_xml_create(part, rule, rc) == 0) {
part_map->append(rc, part);
} else {
g_object_unref(part);
@@ -883,3 +894,54 @@ rule_context_free_uri_list(RuleContext *rc, GList *uris)
l = n;
}
}
+
+static FilterElement *
+new_element(RuleContext *rc, const char *type)
+{
+ if (!strcmp (type, "string")) {
+ return (FilterElement *) filter_input_new ();
+ } else if (!strcmp (type, "address")) {
+ /* FIXME: temporary ... need real address type */
+ return (FilterElement *) filter_input_new_type_name (type);
+ } else if (!strcmp (type, "code")) {
+ return (FilterElement *) filter_code_new ();
+ } else if (!strcmp (type, "colour")) {
+ return (FilterElement *) filter_colour_new ();
+ } else if (!strcmp (type, "optionlist")) {
+ return (FilterElement *) filter_option_new ();
+ } else if (!strcmp (type, "datespec")) {
+ return (FilterElement *) filter_datespec_new ();
+ } else if (!strcmp (type, "command")) {
+ return (FilterElement *) filter_file_new_type_name (type);
+ } else if (!strcmp (type, "file")) {
+ return (FilterElement *) filter_file_new_type_name (type);
+ } else if (!strcmp (type, "integer")) {
+ return (FilterElement *) filter_int_new ();
+ } else if (!strcmp (type, "regex")) {
+ return (FilterElement *) filter_input_new_type_name (type);
+ } else if (!strcmp (type, "label")) {
+ return (FilterElement *) filter_label_new ();
+ } else {
+ g_warning("Unknown filter type '%s'", type);
+ return NULL;
+ }
+}
+
+/**
+ * rule_context_new_element:
+ * @rc:
+ * @name:
+ *
+ * create a new filter element based on name.
+ *
+ * Return value:
+ **/
+FilterElement *
+rule_context_new_element(RuleContext *rc, const char *name)
+{
+ if (name == NULL)
+ return NULL;
+
+ return RULE_CONTEXT_GET_CLASS(rc)->new_element(rc, name);
+}
+