diff options
author | nobody <nobody@localhost> | 2000-07-06 12:58:12 +0800 |
---|---|---|
committer | nobody <nobody@localhost> | 2000-07-06 12:58:12 +0800 |
commit | a2d460b54b167a639bf05662d2f0de46acf73400 (patch) | |
tree | 4ba00fa4856e39912c9a54ecba72de80d51d2418 /filter | |
parent | 04f148f617112009091abd18b16463033dd322d0 (diff) | |
download | gsoc2013-evolution-BEFORE_GTK_1_3_CHANGES.tar gsoc2013-evolution-BEFORE_GTK_1_3_CHANGES.tar.gz gsoc2013-evolution-BEFORE_GTK_1_3_CHANGES.tar.bz2 gsoc2013-evolution-BEFORE_GTK_1_3_CHANGES.tar.lz gsoc2013-evolution-BEFORE_GTK_1_3_CHANGES.tar.xz gsoc2013-evolution-BEFORE_GTK_1_3_CHANGES.tar.zst gsoc2013-evolution-BEFORE_GTK_1_3_CHANGES.zip |
This commit was manufactured by cvs2svn to create tagBEFORE_GTK_1_3_CHANGES
'BEFORE_GTK_1_3_CHANGES'.
svn path=/tags/BEFORE_GTK_1_3_CHANGES/; revision=3911
Diffstat (limited to 'filter')
-rw-r--r-- | filter/.cvsignore | 9 | ||||
-rw-r--r-- | filter/ChangeLog | 406 | ||||
-rw-r--r-- | filter/Makefile.am | 39 | ||||
-rwxr-xr-x | filter/blank.xpm | 22 | ||||
-rwxr-xr-x | filter/check.xpm | 22 | ||||
-rw-r--r-- | filter/filter-arg-types.c | 784 | ||||
-rw-r--r-- | filter/filter-arg-types.h | 101 | ||||
-rw-r--r-- | filter/filter-arg.c | 547 | ||||
-rw-r--r-- | filter/filter-arg.h | 92 | ||||
-rw-r--r-- | filter/filter-driver.c | 578 | ||||
-rw-r--r-- | filter/filter-driver.h | 64 | ||||
-rw-r--r-- | filter/filter-druid.c | 728 | ||||
-rw-r--r-- | filter/filter-druid.h | 76 | ||||
-rw-r--r-- | filter/filter-editor.c | 408 | ||||
-rw-r--r-- | filter/filter-editor.h | 58 | ||||
-rw-r--r-- | filter/filter-format.c | 237 | ||||
-rw-r--r-- | filter/filter-format.h | 11 | ||||
-rw-r--r-- | filter/filter-xml.c | 584 | ||||
-rw-r--r-- | filter/filter-xml.h | 77 | ||||
-rw-r--r-- | filter/filtertypes.xml | 110 | ||||
-rw-r--r-- | filter/vfoldertypes.xml | 78 |
21 files changed, 0 insertions, 5031 deletions
diff --git a/filter/.cvsignore b/filter/.cvsignore deleted file mode 100644 index 7c13af9a14..0000000000 --- a/filter/.cvsignore +++ /dev/null @@ -1,9 +0,0 @@ -*.la -*.lo -.libs -.deps -.pure -Makefile -Makefile.in -filter-driver -filter-editor diff --git a/filter/ChangeLog b/filter/ChangeLog deleted file mode 100644 index 943b1736bd..0000000000 --- a/filter/ChangeLog +++ /dev/null @@ -1,406 +0,0 @@ -2000-07-05 Dan Winship <danw@helixcode.com> - - * remove some non-error case debugging messages. - - * filtertypes.xml: Fix typos and update the "to-address" rule to - match To or Cc. - * vfoldertypes.xml: Fix typos. - - * filter-driver.c (do_delete, do_copy, do_stop, - filter_driver_run): Add uids to the "processed" list only after - succesfully doing something with them. Fixes the problem where - copying a message to a folder that didn't exist would result in it - disapearing. - -2000-07-02 Ettore Perazzoli <ettore@helixcode.com> - - * filter-driver.c (filter_driver_new): Don't free the ruleset nor - the xmlDoc. This will make us leak [I think], but at least - filters work. - -2000-07-02 Dan Winship <danw@helixcode.com> - - * filter-driver.c (open_folder): freeze the folder to avoid - multiple folder_changed's - (close_folder): and thaw it. - -2000-07-02 Dan Winship <danw@helixcode.com> - - * filter-driver.c (filter_driver_new): kill - filter_driver_set_session and filter_driver_set_rules and instead - make filter_driver_new take the rules and a callback function it - can use to turn URIs into folders. - (open_folder): Use the callback function rather than calling camel - directly: some URIs need special handling to turn them into stores - and folders correctly, so let the mailer do that. - -2000-07-01 Ettore Perazzoli <ettore@helixcode.com> - - * filter-arg-types.c (arg_folder_edit_value): Only allow type - "mail" when selecting a folder for the filter. - -2000-07-01 Jeffrey Stedfast <fejj@helixcode.com> - - * filter-driver.c: Updated to reflect changes made to - camel-folder. - -2000-06-30 Peter Williams <peterw@curious-george.helixcode.com> - - * filter-xml.c (filter_load_optionset_file): Check for failure - when loading the filter doc. - - * filter-driver.c (filter_driver_set_rules): Ditto. - - * filter-editor.c (filter_editor_set_rule_files): Ditto. - -2000-06-29 Ettore Perazzoli <ettore@helixcode.com> - - * filter-arg-types.c: Replaced `global_shell_interface' with - `global_shell_client'. - (arg_folder_edit_value): Use - `evolution_shell_client_user_select_folder()'. - (create_listener): Removed. - (impl_FolderSelectionListener_selected): Removed, together with - all the ::Listener stuff. - -2000-06-29 Arik Devens <arik@helixcode.com> - - * vfoldertypes.xml (ruleset type="match"): Changed Cc to CC to be - the same as the other CC rule. None of this works however, cause - the CC code is not hooked up to camel... oh well ;-( - -2000-06-29 Arik Devens <arik@helixcode.com> - - * vfoldertypes.xml (ruleset type="match"): Added a Cc rule to - vfolders. Works like To except on the Cc of a message ;-) - -2000-06-28 Jeffrey Stedfast <fejj@helixcode.com> - - * filter-arg-types.c (arg_string_edit_value): Changed "Filter name" - to "Option value" as "Filter name" made no sense in the dialog - (arg_address_edit_value): Same - (arg_folder_edit_value): What do we want to return?? - -2000-06-27 Ettore Perazzoli <ettore@helixcode.com> - - * filter-xml.c (load_desc): Strdup content before assigning the - value. Also, no need to check for NULL when g_strdup()ing as - g_strdup() returns NULL for a NULL arg. - -2000-06-27 Ettore Perazzoli <ettore@helixcode.com> - - * Makefile.am (INCLUDES): `-I$(top_builddir)/shell' so that it - works with builddir != srcdir. [We need to #include - "Evolution.h".] - -2000-06-27 Michael Zucchi <zucchi@zedzone.mmc.com.au> - - * Makefile.am (INCLUDES): Add the shell dir for includes (for - corba interfaces). - - * filter-arg-types.c (impl_FolderSelectionListener_selected): - Listener for folder query. Sigh. - (create_listener): Create the listener object for the folder - dialogue query. Uses a global for linkage to the shell object, - via the mail component. - (arg_folder_edit_value): Call the folder selection dialogue to - edit the value, rather than a simple text widget. - -2000-06-26 Jeffrey Stedfast <fejj@helixcode.com> - - * filter-editor.c: Added a #include <gnome-xml/parser.h> as this - was needed (since we used the xml parser...) - (druid_dialogue_clicked): Do we want to use struct filter_option - or do we instead want to use struct filter_optionrule as we had before? - Since the function we pass the data to expects filter_option, I suspect - that that is what we want. - - * filter-format.h (filter_description_html_write): Renamed from - description_html_write in order to match function name in - filter-format.c - - * filter-druid.c (option_name_changed): Fixed a memory leak (Free'd - a filter description list). - - * filter-arg-types.c (arg_folder_edit_values): Free'd GList data in - argin->values. - - * filter-driver.c (filter_driver_set_rules): Added code to free an - xmlDoc and some other data. - - * filter-arg.h: Add prototypes for filter_arg_write_html() and - filter_arg_write_text(); - - * filter-arg-types.c: Lets see if we can't get rid of some of these - warnings... (use some casts to make warnings go away) - (arg_address_edit_value): Lets make sure that ad exists before looking - at member data. - -2000-06-16 Dan Winship <danw@helixcode.com> - - * filter-driver.c (do_delete, filter_driver_run): Update for Camel - flag handling changes. - -2000-06-15 Dan Winship <danw@helixcode.com> - - * filter-driver.c (open_folder, close_folder): Update for - CamelFolder changes. - -2000-06-09 Jacob Berkman <jacob@helixcode.com> - - * filter-editor.c (add_or_edit): use stock pixmap buttons - - * filter-druid.c (build_druid): remove the border on the notebook, - put the html widget in a scroll frame, and add some padding - -2000-06-06 Dan Winship <danw@helixcode.com> - - * filter-driver.c (open_folder): Update for folder - existence/creation changes. - -2000-06-02 Christopher James Lahey <clahey@helixcode.com> - - * filter-driver.c: Free the exception and the priv struct. - -2000-06-01 Christopher James Lahey <clahey@helixcode.com> - - * filter-arg-types.c (arg_address_edit_value): Search for ad in - arg->values instead of text since it's a list of - filter_arg_adresses. Also, free the old value in the list. - -2000-05-30 Not Zed <NotZed@HelixCode.com> - - * filtertypes.xml: And here too. - - * vfoldertypes.xml: Add body-contains and not-body-contains - types. - -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()' - anymore. - - * filter-arg-types.c: Updated for the new GtkHTML API which uses - `GtkHTMLStream *' instead of `GtkHTMLStreamHandle'. - * filter-arg.c: Likewise. - * filter-arg.h: Likewise. - * filter-druid.c: Likewise. - - * filter-format.c: Likewise. - * filter-format.h: Likewise. - -2000-05-18 Dan Winship <danw@helixcode.com> - - * filter-driver.c (filter_driver_run): update for - camel_folder_get_uids change - -2000-05-17 NotZed <NotZed@HelixCode.com> - - * filter-druid.c: Fix some html formatting. - -2000-05-16 NotZed <NotZed@HelixCode.com> - - * filter-driver.c (filter_driver_run): Delete all processed - messages. This is probably going to slow it down a bit. - (filter_driver_run): Close folders before destroying them *sigh*. - (open_folder): Actually open the folder. Doh. - - * filtertypes.xml: Initial filter rules. - - * filter-xml.c (filter_write_optionset): Save the description - also. - (write_description): Routine to save description - only saves 1 - node of description. - - * filter-arg.c (filter_arg_edit_clicked): Dont free edata here, - let the destroy do it(?) - - * filter-editor.c (main): Simple driver program for testing, so i - can fix all this really broken code *sigh* - -2000-05-15 NotZed <NotZed@HelixCode.com> - - * filter-editor.c (filter_editor_set_rule_files): filename based - interface. - (filter_editor_save_rules): Interface to save the options to a - filename. - - * filter-xml.[ch]: Bunch of cleanup. - - * filter-xml.c (filter_*_file): New interfaces to read/write files - directly, rather than messing with xmldoc crap. - - * Makefile.am: Removed filter-driver test program, now just part - of libfilter. - - * filter-driver.c: Made an object, with an api and everything, can - apply a filter to a given mailbox. - -2000-05-10 Christopher James Lahey <clahey@helixcode.com> - - * filter-arg.h: Changed tree.h to gnome-xml/tree.h. - - * Makefile.am: Added filter-arg-types.h, filter-arg.h, - filter-xml.h, filter-format.h, filter-druid.h, filter-editor.h. - -2000-05-02 Matt Loper <matt@helixcode.com> - - * Makefile.am: set G_LOG_DOMAIN. - -2000-05-01 NotZed <NotZed@HelixCode.com> - - * filter-driver.c (main): Fix for api. - -2000-04-30 Dan Winship <danw@helixcode.com> - - * filter-driver.c (start): Remove no-longer-necessary call to - camel_provider_register_as_module. - -2000-04-25 Ettore Perazzoli <ettore@helixcode.com> - - * Makefile.am (INCLUDES): Use `$(GTKHTML_CFLAGS)'. - -2000-04-20 NotZed <NotZed@HelixCode.com> - - * filter-driver.c: Removed a bunch of crappy unrequired headers. - - * Makefile.am (filter_driver_LDADD): Added libibex back again. - -2000-04-18 Dan Winship <danw@helixcode.com> - - * filter-driver.c: remove unused camel-log.h include - -2000-04-12 Matt Loper <matt@helixcode.com> - - * filter-arg.c (filter_arg_edit_value): Return a value. - -2000-03-27 NotZed <NotZed@HelixCode.com> - - * filter-xml.c (tokenise_xmlfreeprop): Free a prop after - tokenising it. - (find_node_attr): Free the prop after using it. - (load_desc): Ditto. I use free() because xmlFree() is nowhere to - be found. - (filter_load_optionset): Ditto. - - * filter-arg-types.c (arg_address_values_add_xml): free() xml - stuff, plugs a leak. - (arg_folder_values_add_xml): Ditto. - -2000-03-22 NotZed <NotZed@HelixCode.com> - - * filter-driver.c (main): Changed to use async search api. - -2000-03-04 NotZed <NotZed@HelixCode.com> - - * filter-druid.c (html_write_options): Output 'and' bits between - the rules. - - * filter-driver.c (main): Actually implement filtering, at least, - from Inbox. Copy messages to folder (in the same store only, so - far), delete, and stop processing are implemented, and the logic - to handle default processing. - - * filter-xml.c (load_optionvalue): Fix up a bug where we lost the - name of the arg (ouch). - * filter-xml.c: Wrapped printf's in debug macros. - -2000-03-02 NotZed <NotZed@HelixCode.com> - - * filter-druid.c (object_destroy): Disconnect the list signal, so - we dont get spurious emits during destroy. - (arg_changed): Callback to update filter arg asynchronously. - (arg_link_clicked): Edit the value non-modally. - - * filter-arg.c (filter_arg_edit_values_1): Changed to use - non-modal interface. - -2000-03-01 Ettore Perazzoli <ettore@helixcode.com> - - * Makefile.am: New file. - - * Makefile: Removed. I wonder why we are using plain Makefiles - instead of automake Makefiles at all. - -2000-02-29 NotZed <NotZed@HelixCode.com> - - * filter-driver.c (main): Remove gui code, this will be actual - filtering code. - - * Makefile: Added filter-editor to the library. - - * filter-editor.c (main): Comment out, make it a proper library. - -2000-02-28 NotZed <NotZed@HelixCode.com> - - * filter-druid.c: Removed unused header. - - * Makefile: Removed references to filter-sexp.[ch]. - - * filter-sexp.[ch]: Removed some unecessary includes. Moved to - e-util. Renamed callers. - -2000-02-24 NotZed <NotZed@HelixCode.com> - - * filter-xml.c (filter_description_free): - (filter_load_ruleset_free): - (filter_load_optionset_free): Functions for memory management. - - * filter-arg.c (filter_arg_copy): Copy the values of one arg into - another. - - * filter-editor.c: New widget, a dialogue which uses filter-druid - to present the various editing views. - (druid_dialogue_clicked): On finish, save the user's new filter - definition where it came from. - - * filter-druid.c: Changed to just being a notebook with no tabs, - rather than a full druid (no next/prev/etc buttons). - (option_name_changed): Update the option's description as the user - enters it in. - -2000-02-22 NotZed <NotZed@HelixCode.com> - - * filter-xml.c (filter_clone_optionrule): - (filter_clone_optionrule_free): - (filter_optionrule_new_from_rule): New utility functions for - working with the internal rule format. - - * filter-arg.[ch]: Added new callbacks for editing a single value, - and a new editor which shows all items in a list, and allows you - to edit them via the single-edit method. This needs some cleanup - for some unused/unusable virtual methods (edit_values, - write_html?). - - * Makefile: Add the druid for build. - - * filter-druid.c: A 'druid' widget for editing a single filter - rule. - -2000-02-21 Matt Loper <matt@helixcode.com> - - * .cvsignore: New file. - -2000-02-18 NotZed <NotZed@HelixCode.com> - - * blank/check.xpm: Added forgotten files. - - * Uh, more changes, lots, its still work in progress. - -2000-02-14 NotZed <notzed@helixcode.com> - - * Initial import. - diff --git a/filter/Makefile.am b/filter/Makefile.am deleted file mode 100644 index 2362e42c82..0000000000 --- a/filter/Makefile.am +++ /dev/null @@ -1,39 +0,0 @@ -INCLUDES = \ - -I $(top_srcdir) \ - -I $(top_srcdir)/libibex \ - -I $(top_srcdir)/camel \ - -I $(top_srcdir)/e-util \ - -I $(top_srcdir)/shell \ - -I $(top_srcdir)/camel/providers/mbox \ - -I $(top_builddir)/shell \ - -I $(GNOME_INCLUDEDIR) \ - $(GTKHTML_CFLAGS) \ - -DG_LOG_DOMAIN=\"filter\" -## - -noinst_LTLIBRARIES = \ - libfilter.la - -libfilter_la_SOURCES = \ - filter-arg-types.c \ - filter-arg-types.h \ - filter-arg.c \ - filter-arg.h \ - filter-xml.c \ - filter-xml.h \ - filter-format.c \ - filter-format.h \ - filter-druid.c \ - filter-druid.h \ - filter-editor.c \ - filter-editor.h \ - filter-driver.c \ - filter-driver.h - -EXTRA_DIST = blank.xpm check.xpm \ - filtertypes.xml vfoldertypes.xml - -# basic rules. -filterdir = $(prefix)/share/evolution -filter_DATA = filtertypes.xml vfoldertypes.xml - diff --git a/filter/blank.xpm b/filter/blank.xpm deleted file mode 100755 index 499f7a04fc..0000000000 --- a/filter/blank.xpm +++ /dev/null @@ -1,22 +0,0 @@ -/* XPM */ -static char * blank_xpm[] = { -"16 16 3 1", -" c None", -". c #000000", -"+ c #FFFFFF", -" ", -" .............. ", -" .++++++++++++. ", -" .++++++++++++. ", -" .++++++++++++. ", -" .++++++++++++. ", -" .++++++++++++. ", -" .++++++++++++. ", -" .++++++++++++. ", -" .++++++++++++. ", -" .++++++++++++. ", -" .++++++++++++. ", -" .++++++++++++. ", -" .++++++++++++. ", -" .............. ", -" "}; diff --git a/filter/check.xpm b/filter/check.xpm deleted file mode 100755 index 74f9b56122..0000000000 --- a/filter/check.xpm +++ /dev/null @@ -1,22 +0,0 @@ -/* XPM */ -static char * check_xpm[] = { -"16 16 3 1", -" c None", -". c #000000", -"+ c #FFFFFF", -" ", -" .............. ", -" .++++++++++++. ", -" .++++++++++++. ", -" .+++++++++.++. ", -" .++++++++..++. ", -" .+++++++...++. ", -" .++.+++...+++. ", -" .++..+...++++. ", -" .++.....+++++. ", -" .+++...++++++. ", -" .++++.+++++++. ", -" .++++++++++++. ", -" .++++++++++++. ", -" .............. ", -" "}; diff --git a/filter/filter-arg-types.c b/filter/filter-arg-types.c deleted file mode 100644 index 578eeee64e..0000000000 --- a/filter/filter-arg-types.c +++ /dev/null @@ -1,784 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Michael Zucchi <notzed@helixcode.com> - * - * Implementations of the filter-arg types. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public License - * as published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include <gnome.h> - -#include "evolution-shell-client.h" - -#include "filter-arg-types.h" - -/* ********************************************************************** */ -/* String */ -/* ********************************************************************** */ - -/* Use for a superclass of any items which are simple strings */ - -static void filter_arg_string_class_init (FilterArgStringClass *class); -static void filter_arg_string_init (FilterArgString *gspaper); - -static FilterArg *string_parent_class; - -guint -filter_arg_string_get_type (void) -{ - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "FilterArgString", - sizeof (FilterArgString), - sizeof (FilterArgStringClass), - (GtkClassInitFunc) filter_arg_string_class_init, - (GtkObjectInitFunc) filter_arg_string_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - type = gtk_type_unique (filter_arg_get_type (), &type_info); - } - - return type; -} - -static void -arg_string_write_html(FilterArg *argin, GtkHTML *html, GtkHTMLStream *stream) -{ - /* empty */ -} - -static void -arg_string_write_text(FilterArg *argin, GString *string) -{ - GList *l; - char *a; - - l = argin->values; - if (l == NULL) { - g_string_append(string, "folder"); - } - while (l) { - a = l->data; - g_string_append(string, a); - if (l->next) { - g_string_append(string, ", "); - } - l = g_list_next(l); - } -} - -static void -arg_string_edit_values(FilterArg *arg) -{ - printf("edit string values!\n"); -} - -/* pop up a dialogue, asking for a new string value */ -static int -arg_string_edit_value (FilterArg *arg, int index) -{ - GnomeDialog *dialogue; - GtkWidget *hbox; - GtkWidget *label; - GtkWidget *entry; - char *text = NULL; - char *newtext; - - dialogue = (GnomeDialog *)gnome_dialog_new ("Edit value", "Ok", "Cancel", 0); - - hbox = gtk_hbox_new (FALSE, 0); - label = gtk_label_new ("Option value"); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - entry = gtk_entry_new(); - gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0); - if (index >= 0) { - text = filter_arg_get_value (arg, index); - } - if (text) { - gtk_entry_set_text (GTK_ENTRY (entry), text); - } - gtk_box_pack_start (GTK_BOX (dialogue->vbox), hbox, TRUE, TRUE, 0); - gtk_widget_show_all (hbox); - gtk_object_ref (GTK_OBJECT (entry)); /* so we can get the text back afterwards */ - if (gnome_dialog_run_and_close (dialogue) == 0) { - GList *node; - - newtext = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry))); - gtk_object_unref (GTK_OBJECT (entry)); - if (index >= 0 && (node = g_list_find (arg->values, text))) { - node->data = newtext; - } else { - arg->values = g_list_append (arg->values, newtext); - } - g_free (text); - return g_list_index (arg->values, newtext); - } - return -1; -} - -static xmlNodePtr -arg_string_values_get_xml(FilterArg *argin) -{ - xmlNodePtr value; - GList *l; - char *a; - - value = xmlNewNode(NULL, "optionvalue"); - xmlSetProp(value, "name", argin->name); - - l = argin->values; - while (l) { - xmlNodePtr cur; - - a = l->data; - - cur = xmlNewChild(value, NULL, "folder", NULL); - if (a) - xmlSetProp(cur, "folder", a); - l = g_list_next(l); - } - - return value; -} - -static void -arg_string_values_add_xml(FilterArg *arg, xmlNodePtr node) -{ - xmlNodePtr n; - - n = node->childs; - while (n) { - if (!strcmp(n->name, "folder")) { - filter_arg_string_add(arg, xmlGetProp(n, "folder")); - } else { - g_warning("Loading folders from xml, wrong node encountered: %s\n", n->name); - } - n = n->next; - } -} - -static char * -arg_string_get_value_as_string(FilterArg *argin, void *data) -{ - char *a = (char *)data; - - return a; -} - -static void -arg_string_free_value(FilterArg *arg, void *a) -{ - g_free(a); -} - -static void -filter_arg_string_class_init (FilterArgStringClass *class) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *) class; - if (string_parent_class == NULL) - string_parent_class = gtk_type_class (gtk_object_get_type ()); - - class->parent_class.write_html = arg_string_write_html; - class->parent_class.write_text = arg_string_write_text; - class->parent_class.edit_values = arg_string_edit_values; - class->parent_class.edit_value = arg_string_edit_value; - class->parent_class.free_value = arg_string_free_value; - class->parent_class.get_value_as_string = arg_string_get_value_as_string; - - class->parent_class.values_get_xml = arg_string_values_get_xml; - class->parent_class.values_add_xml = arg_string_values_add_xml; -} - -static void -filter_arg_string_init (FilterArgString *arg) -{ - arg->arg.values = NULL; -} - -/** - * filter_arg_string_new: - * - * Create a new FilterArgString widget. - * - * Return value: A new FilterArgString widget. - **/ -FilterArg * -filter_arg_string_new (char *name) -{ - FilterArg *a = FILTER_ARG ( gtk_type_new (filter_arg_string_get_type ())); - a->name = g_strdup(name); - return a; -} - - -void -filter_arg_string_add(FilterArg *arg, char *name) -{ - filter_arg_add(arg, g_strdup(name)); -} - -void -filter_arg_string_remove(FilterArg *arg, char *name) -{ - /* do it */ -} - - -/* ********************************************************************** */ -/* Address */ -/* ********************************************************************** */ - -static void filter_arg_address_class_init (FilterArgAddressClass *class); -static void filter_arg_address_init (FilterArgAddress *gspaper); - -static FilterArg *parent_class; - -guint -filter_arg_address_get_type (void) -{ - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "FilterArgAddress", - sizeof (FilterArgAddress), - sizeof (FilterArgAddressClass), - (GtkClassInitFunc) filter_arg_address_class_init, - (GtkObjectInitFunc) filter_arg_address_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - type = gtk_type_unique (filter_arg_get_type (), &type_info); - } - - return type; -} - -static void -arg_address_write_html (FilterArg *argin, GtkHTML *html, GtkHTMLStream *stream) -{ - /* empty */ -} - -static void -arg_address_write_text (FilterArg *argin, GString *string) -{ - GList *l; - struct filter_arg_address *a; - - l = argin->values; - if (l == NULL) { - g_string_append (string, "email address"); - } - while (l) { - a = l->data; - g_string_append (string, a->name); - if (l->next) { - g_string_append (string, ", "); - } - l = g_list_next (l); - } -} - -static void -arg_address_edit_values(FilterArg *arg) -{ - printf ("edit it!\n"); -} - -static int -arg_address_edit_value (FilterArg *arg, int index) -{ - GnomeDialog *dialogue; - GtkWidget *hbox; - GtkWidget *label; - GtkWidget *entry; - char *text = NULL; - char *newtext; - struct filter_arg_address *ad = NULL; - - dialogue = (GnomeDialog *)gnome_dialog_new ("Edit Address value", "Ok", "Cancel", 0); - - hbox = gtk_hbox_new (FALSE, 0); - label = gtk_label_new ("Address"); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - entry = gtk_entry_new (); - gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0); - if (index >= 0 && (ad = filter_arg_get_value (arg, index))) { - text = ad->email; - } - if (text) { - gtk_entry_set_text (GTK_ENTRY (entry), text); - } - gtk_box_pack_start (GTK_BOX (dialogue->vbox), hbox, TRUE, TRUE, 0); - gtk_widget_show_all (hbox); - gtk_object_ref (GTK_OBJECT (entry)); /* so we can get the text back afterwards */ - if (gnome_dialog_run_and_close (dialogue) == 0) { - GList *node; - - newtext = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry))); - gtk_object_unref (GTK_OBJECT (entry)); - if (index >= 0 && ad && (node = g_list_find(arg->values, ad))) { - ad = node->data; - g_free (ad->email); - ad->email = newtext; - } else { - ad = g_malloc0 (sizeof(*ad)); - ad->email = newtext; - arg->values = g_list_append (arg->values, ad); - } - g_free (text); - return g_list_index (arg->values, ad); - } - return -1; -} - -static xmlNodePtr -arg_address_values_get_xml(FilterArg *argin) -{ - xmlNodePtr value; - GList *l; - struct filter_arg_address *a; - - /* hmm, perhaps this overhead should be in FilterArg, and this function just returns the base node?? */ - value = xmlNewNode(NULL, "optionvalue"); - xmlSetProp(value, "name", argin->name); - - l = argin->values; - while (l) { - xmlNodePtr cur; - - a = l->data; - - cur = xmlNewChild(value, NULL, "address", NULL); - if (a->name) - xmlSetProp(cur, "name", a->name); - if (a->email) - xmlSetProp(cur, "email", a->email); - l = g_list_next(l); - } - - return value; -} - -static void -arg_address_values_add_xml(FilterArg *arg, xmlNodePtr node) -{ - xmlNodePtr n; - - n = node->childs; - while (n) { - if (!strcmp(n->name, "address")) { - char *nm, *e; - nm = xmlGetProp(n, "name"); - e = xmlGetProp(n, "email"); - filter_arg_address_add(arg, nm, e); - free(nm); - free(e); - } else { - g_warning("Loading address from xml, wrong node encountered: %s\n", n->name); - } - n = n->next; - } -} - -/* the search string is just the raw email address */ -static char * -arg_address_get_value_as_string(FilterArg *argin, void *data) -{ - struct filter_arg_address *a = (struct filter_arg_address *)data; - - if (a->email == NULL - || a->email[0] == '\0') { - if (a->name == NULL - || a->name[0] == '\0') - return ""; - return a->name; - } else - return a->email; -} - -static void -arg_address_free_value(FilterArg *arg, struct filter_arg_address *a) -{ - g_free(a->name); - g_free(a->email); - g_free(a); -} - -static void -filter_arg_address_class_init (FilterArgAddressClass *class) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *) class; - if (parent_class == NULL) - parent_class = gtk_type_class (gtk_object_get_type ()); - - class->parent_class.write_html = arg_address_write_html; - class->parent_class.write_text = arg_address_write_text; - class->parent_class.edit_values= arg_address_edit_values; - class->parent_class.edit_value= arg_address_edit_value; - class->parent_class.free_value = arg_address_free_value; - - class->parent_class.values_get_xml = arg_address_values_get_xml; - class->parent_class.values_add_xml = arg_address_values_add_xml; - - class->parent_class.get_value_as_string = arg_address_get_value_as_string; -} - -static void -filter_arg_address_init (FilterArgAddress *arg) -{ -} - -/** - * filter_arg_address_new: - * - * Create a new FilterArgAddress widget. - * - * Return value: A new FilterArgAddress widget. - **/ -FilterArg * -filter_arg_address_new (char *name) -{ - FilterArg *a = FILTER_ARG ( gtk_type_new (filter_arg_address_get_type ())); - a->name = g_strdup(name); - return a; -} - -void -filter_arg_address_add(FilterArg *arg, char *name, char *email) -{ - struct filter_arg_address *a; - - a = g_malloc0(sizeof(*a)); - - a->name = g_strdup(name); - a->email = g_strdup(email); - - filter_arg_add(arg, a); -} - -void -filter_arg_address_remove(FilterArg *arg, char *name, char *email) -{ - -} - -/* ********************************************************************** */ -/* Folder */ -/* ********************************************************************** */ - - -#include <bonobo/bonobo-object.h> -#include <bonobo/bonobo-control.h> - -#include "Evolution.h" - -static void filter_arg_folder_class_init (FilterArgFolderClass *class); -static void filter_arg_folder_init (FilterArgFolder *gspaper); - -static FilterArg *folder_parent_class; -extern EvolutionShellClient *global_shell_client; - -guint -filter_arg_folder_get_type (void) -{ - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "FilterArgFolder", - sizeof (FilterArgFolder), - sizeof (FilterArgFolderClass), - (GtkClassInitFunc) filter_arg_folder_class_init, - (GtkObjectInitFunc) filter_arg_folder_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - type = gtk_type_unique (filter_arg_string_get_type (), &type_info); - } - - return type; -} - -static void -arg_folder_write_html(FilterArg *argin, GtkHTML *html, GtkHTMLStream *stream) -{ - /* empty */ -} - -static void -arg_folder_write_text(FilterArg *argin, GString *string) -{ - GList *l; - char *a; - - l = argin->values; - if (l == NULL) { - g_string_append(string, "folder"); - } - while (l) { - a = l->data; - g_string_append(string, a); - if (l->next) { - g_string_append(string, ", "); - } - l = g_list_next(l); - } -} - -static int -arg_folder_edit_value (FilterArg *arg, int index) -{ - const char *allowed_types[] = { "mail", NULL }; - char *def; - char *physical_uri; - - printf ("folder edit value %d\n", index); - - if (index < 0) { - def = ""; - } else { - def = filter_arg_get_value (arg, index); - } - - evolution_shell_client_user_select_folder (global_shell_client, - _("Select Folder"), - def, allowed_types, NULL, &physical_uri); - - if (physical_uri != NULL && physical_uri[0] != '\0') { - GList *node; - - if (index >= 0 && (node = g_list_index (arg->values, index))) - node->data = physical_uri; - else - arg->values = g_list_append (arg->values, physical_uri); - - gtk_signal_emit_by_name (GTK_OBJECT (arg), "changed"); - } else { - g_free (physical_uri); - } - -#warning "What do we really want to return here???" - return 0; -} - -static void -arg_folder_edit_values(FilterArg *argin) -{ - /*FilterArgFolder *arg = (FilterArgFolder *)argin;*/ - GList *l; - char *a, *start, *ptr, *ptrend, *ptrgap; - char outbuf[128], *outptr; /* FIXME: dont use a bounded buffer! */ - GtkWidget *dialogue; - GtkWidget *text; - guint i; - - dialogue = gnome_dialog_new ("Edit addresses", "Ok", "Cancel", NULL); - text = gtk_text_new (NULL, NULL); - gtk_object_ref (GTK_OBJECT (text)); - - l = argin->values; - while (l) { - a = l->data; - gtk_text_insert(GTK_TEXT (text), NULL, NULL, NULL, a, strlen(a)); - gtk_text_insert(GTK_TEXT (text), NULL, NULL, NULL, "\n", 1); - l = g_list_next(l); - } - - gtk_box_pack_start(GTK_BOX (GNOME_DIALOG(dialogue)->vbox), text, TRUE, TRUE, 2); - gtk_widget_show(text); - gtk_text_set_editable(GTK_TEXT (text), TRUE); - - gnome_dialog_run_and_close(GNOME_DIALOG (dialogue)); - - for (i = 0; i < g_list_length (argin->values); i++) - g_free (g_list_nth_data (argin->values, i)); - g_list_free (argin->values); - - argin->values = NULL; - ptr = GTK_TEXT(text)->text.ch; - ptrend = ptr + GTK_TEXT(text)->text_end; - ptrgap = ptr + GTK_TEXT(text)->gap_position; - - start = ptr; - outptr = outbuf; - while (ptr < ptrend) { - printf("%c", *ptr); - if (*ptr == '\n') { - int len = outptr - outbuf; - char *new; - - printf("(len = %d)", len); - - if (len>0) { - new = g_malloc(len+1); - new[len]=0; - memcpy(new, outbuf, len); - printf("(appending '%s')", new); - argin->values = g_list_append(argin->values, new); - } - outptr = outbuf; - } else { - *outptr++ = *ptr; - } - ptr++; - if (ptr==ptrgap) { - ptr += GTK_TEXT(text)->gap_size; - } - } - if (outptr > outbuf) { - int len = outptr-outbuf; - char *new; - - printf("(lastlen = %d)", len); - - new = g_malloc(len+1); - new[len] = 0; - memcpy(new, start, len); - argin->values = g_list_append(argin->values, new); - } - printf("\n"); -} - -static xmlNodePtr -arg_folder_values_get_xml(FilterArg *argin) -{ - xmlNodePtr value; - /*FilterArgFolder *arg = (FilterArgFolder *)argin;*/ - GList *l; - char *a; - - value = xmlNewNode(NULL, "optionvalue"); - xmlSetProp(value, "name", argin->name); - - l = argin->values; - while (l) { - xmlNodePtr cur; - - a = l->data; - - cur = xmlNewChild(value, NULL, "folder", NULL); - if (a) - xmlSetProp(cur, "name", a); - l = g_list_next(l); - } - - return value; -} - -static void -arg_folder_values_add_xml(FilterArg *arg, xmlNodePtr node) -{ - xmlNodePtr n; - - n = node->childs; - while (n) { - if (!strcmp(n->name, "folder")) { - char *name = xmlGetProp(n, "name"); - if (name) { - filter_arg_folder_add(arg, name); - free(name); - } else - g_warning("no xml prop 'name' on '%s'\n", n->name); - } else { - g_warning("Loading folders from xml, wrong node encountered: %s\n", n->name); - } - n = n->next; - } -} - -static char * -arg_folder_get_value_as_string(FilterArg *argin, void *data) -{ - /*FilterArgFolder *arg = (FilterArgFolder *)argin;*/ - char *a = (char *)data; - - return a; -} - -static void -arg_folder_free_value(FilterArg *arg, void *a) -{ - g_free(a); -} - -static void -filter_arg_folder_class_init (FilterArgFolderClass *class) -{ - GtkObjectClass *object_class; - FilterArgClass *filter_class; - - object_class = (GtkObjectClass *) class; - filter_class = (FilterArgClass *) class; - if (folder_parent_class == NULL) - folder_parent_class = gtk_type_class (filter_arg_string_get_type ()); - - /* FIXME: only need to over-ride the edit values right? */ - filter_class->edit_value = arg_folder_edit_value; - - filter_class->write_html = arg_folder_write_html; - filter_class->write_text = arg_folder_write_text; - filter_class->edit_values = arg_folder_edit_values; - filter_class->free_value = arg_folder_free_value; - - filter_class->values_get_xml = arg_folder_values_get_xml; - filter_class->values_add_xml = arg_folder_values_add_xml; -} - -static void -filter_arg_folder_init (FilterArgFolder *arg) -{ -} - -/** - * filter_arg_folder_new: - * - * Create a new FilterArgFolder widget. - * - * Return value: A new FilterArgFolder widget. - **/ -FilterArg * -filter_arg_folder_new (char *name) -{ - FilterArg *a = FILTER_ARG ( gtk_type_new (filter_arg_folder_get_type ())); - a->name = g_strdup(name); - return a; -} - - -void -filter_arg_folder_add(FilterArg *arg, char *name) -{ - filter_arg_add(arg, g_strdup(name)); -} - -void -filter_arg_folder_remove(FilterArg *arg, char *name) -{ - /* do it */ -} diff --git a/filter/filter-arg-types.h b/filter/filter-arg-types.h deleted file mode 100644 index 6a1d80bfae..0000000000 --- a/filter/filter-arg-types.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Michael Zucchi <notzed@helixcode.com> - * - * Implementations of the filter-args. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public License - * as published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef _FILTER_ARG_TYPES_H -#define _FILTER_ARG_TYPES_H - -#include "filter-arg.h" - -/* An Address */ -#define FILTER_ARG_ADDRESS(obj) GTK_CHECK_CAST (obj, filter_arg_address_get_type (), FilterArgAddress) -#define FILTER_ARG_ADDRESS_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, filter_arg_address_get_type (), FilterArgAddressClass) -#define IS_FILTER_ARG_ADDRESS(obj) GTK_CHECK_TYPE (obj, filter_arg_address_get_type ()) - -typedef struct _FilterArgAddress FilterArgAddress; -typedef struct _FilterArgAddressClass FilterArgAddressClass; - -struct _FilterArgAddress { - FilterArg arg; -}; - -struct _FilterArgAddressClass { - FilterArgClass parent_class; -}; - -struct filter_arg_address { - char *name; - char *email; -}; - -guint filter_arg_address_get_type (void); -FilterArg *filter_arg_address_new (char *name); -void filter_arg_address_add(FilterArg *, char *name, char *email); -void filter_arg_address_remove(FilterArg *, char *name, char *email); - -/* A simple String */ -#define FILTER_ARG_STRING(obj) GTK_CHECK_CAST (obj, filter_arg_string_get_type (), FilterArgString) -#define FILTER_ARG_STRING_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, filter_arg_string_get_type (), FilterArgStringClass) -#define IS_FILTER_ARG_STRING(obj) GTK_CHECK_TYPE (obj, filter_arg_string_get_type ()) - -typedef struct _FilterArgString FilterArgString; -typedef struct _FilterArgStringClass FilterArgStringClass; - -struct _FilterArgString { - FilterArg arg; - - /* Name/property to save/load to xml */ - /* char *xmlname; */ - /* char *xmlprop; */ -}; - -struct _FilterArgStringClass { - FilterArgClass parent_class; -}; - -guint filter_arg_string_get_type (void); -FilterArg *filter_arg_string_new (char *name); -void filter_arg_string_add(FilterArg *, char *name); -void filter_arg_string_remove(FilterArg *, char *name); - -/* A Folder, subclass of a string */ -#define FILTER_ARG_FOLDER(obj) GTK_CHECK_CAST (obj, filter_arg_folder_get_type (), FilterArgFolder) -#define FILTER_ARG_FOLDER_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, filter_arg_folder_get_type (), FilterArgFolderClass) -#define IS_FILTER_ARG_FOLDER(obj) GTK_CHECK_TYPE (obj, filter_arg_folder_get_type ()) - -typedef struct _FilterArgFolder FilterArgFolder; -typedef struct _FilterArgFolderClass FilterArgFolderClass; - -struct _FilterArgFolder { - FilterArgString arg; -}; - -struct _FilterArgFolderClass { - FilterArgStringClass parent_class; -}; - -guint filter_arg_folder_get_type (void); -FilterArg *filter_arg_folder_new (char *name); -void filter_arg_folder_add(FilterArg *, char *name); -void filter_arg_folder_remove(FilterArg *, char *name); - -#endif /* ! _FILTER_ARG_TYPES_H */ - diff --git a/filter/filter-arg.c b/filter/filter-arg.c deleted file mode 100644 index 8d659d7af9..0000000000 --- a/filter/filter-arg.c +++ /dev/null @@ -1,547 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Michael Zucchi <notzed@helixcode.com> - * - * Abstract filter argument class. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public License - * as published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include <gtk/gtk.h> -#include <gnome.h> - -#include "filter-arg.h" - - -static void filter_arg_class_init (FilterArgClass *class); -static void filter_arg_init (FilterArg *gspaper); - -#define _PRIVATE(x) (((FilterArg *)(x))->priv) - -struct _FilterArgPrivate { - GtkWidget *dialogue; /* editor widget */ - xmlNodePtr *oldargs; -}; - -static GtkObjectClass *parent_class; - -enum { - CHANGED, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -guint -filter_arg_get_type (void) -{ - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "FilterArg", - sizeof (FilterArg), - sizeof (FilterArgClass), - (GtkClassInitFunc) filter_arg_class_init, - (GtkObjectInitFunc) filter_arg_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - type = gtk_type_unique (gtk_object_get_type (), &type_info); - } - - return type; -} - -static FilterArg * -clone_default(FilterArg *a) -{ - xmlNodePtr values; - FilterArg *new = FILTER_ARG ( gtk_type_new (((GtkObject *)a)->klass->type) ); - - /* clone values */ - new->name = g_strdup(a->name); - values = filter_arg_values_get_xml(a); - filter_arg_values_add_xml(new, values); - xmlFreeNodeList(values); - - return new; -} - -static void -write_html_nothing(FilterArg *arg, GtkHTML *html, GtkHTMLStream *stream) -{ - /* empty */ -} - -static void -write_text_nothing(FilterArg *arg, GString *string) -{ - /* empty */ -} - -static void -edit_values_nothing(FilterArg *arg) -{ - /* empty */ -} - -static void * -edit_value_nothing(FilterArg *arg, void *v) -{ - return v; -} - -static void -free_value_nothing(FilterArg *arg, void *v) -{ - /* empty */ -} - -static gint -compare_pointers(gpointer a, gpointer b) -{ - return a == b; -} - -static void -filter_arg_class_init (FilterArgClass *class) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *) class; - parent_class = gtk_type_class (gtk_object_get_type ()); - - class->write_html = write_html_nothing; - class->write_text = write_text_nothing; - class->edit_values = edit_values_nothing; - class->edit_value = edit_value_nothing; - class->free_value = free_value_nothing; - class->clone = clone_default; - - signals[CHANGED] = - gtk_signal_new ("changed", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (FilterArgClass, changed), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); -} - -static void -filter_arg_init (FilterArg *arg) -{ - arg->values = NULL; - arg->priv = g_malloc0(sizeof(*arg->priv)); -} - -/** - * filter_arg_new: - * - * Create a new FilterArg widget. - * - * Return value: A new FilterArg widget. - **/ -FilterArg * -filter_arg_new (char *name) -{ - FilterArg *a = FILTER_ARG ( gtk_type_new (filter_arg_get_type ())); - if (name) - a->name = g_strdup(name); - return a; -} - -FilterArg * -filter_arg_clone (FilterArg *arg) -{ - return ((FilterArgClass *)(arg->object.klass))->clone(arg); -} - -void -filter_arg_copy(FilterArg *dst, FilterArg *src) -{ - xmlNodePtr values; - - g_return_if_fail( ((GtkObject *)src)->klass->type == ((GtkObject *)dst)->klass->type ); - - /* remove old values */ - while (dst->values) { - filter_arg_remove(dst, dst->values->data); - } - - /* clone values */ - values = filter_arg_values_get_xml(src); - filter_arg_values_add_xml(dst, values); - xmlFreeNodeList(values); -} - -void -filter_arg_add(FilterArg *arg, void *v) -{ - g_return_if_fail(v != NULL); - - arg->values = g_list_append(arg->values, v); - gtk_signal_emit(GTK_OBJECT(arg), signals[CHANGED]); -} - -void -filter_arg_remove(FilterArg *arg, void *v) -{ - arg->values = g_list_remove(arg->values, v); - ((FilterArgClass *)(arg->object.klass))->free_value(arg, v); - gtk_signal_emit(GTK_OBJECT(arg), signals[CHANGED]); -} - - -void -filter_arg_write_html(FilterArg *arg, GtkHTML *html, GtkHTMLStream *stream) -{ - ((FilterArgClass *)(arg->object.klass))->write_html(arg, html, stream); -} - -void -filter_arg_write_text(FilterArg *arg, GString *string) -{ - int count, i; - - count = filter_arg_get_count(arg); - for (i=0;i<count;i++) { - g_string_append(string, filter_arg_get_value_as_string(arg, i)); - if (i<count-1) { - g_string_append(string, ", "); - } - if (i==count-2 && count>1) { - g_string_append(string, "or "); - } - } - -#if 0 - ((FilterArgClass *)(arg->object.klass))->write_text(arg, string); -#endif -} -void -filter_arg_edit_values(FilterArg *arg) -{ - void filter_arg_edit_values_1(FilterArg *arg); - - g_return_if_fail(arg != NULL); - - -#if 1 - filter_arg_edit_values_1(arg); -#else - - if (((FilterArgClass *)(arg->object.klass))->edit_values) - ((FilterArgClass *)(arg->object.klass))->edit_values(arg); - else - g_warning("No implementation of virtual method edit_values"); -#endif -} - -int -filter_arg_edit_value(FilterArg *arg, int index) -{ - return ((FilterArgClass *)(arg->object.klass))->edit_value(arg, index); -} - -xmlNodePtr -filter_arg_values_get_xml(FilterArg *arg) -{ - return ((FilterArgClass *)(arg->object.klass))->values_get_xml(arg); -} -void -filter_arg_values_add_xml(FilterArg *arg, xmlNodePtr node) -{ - ((FilterArgClass *)(arg->object.klass))->values_add_xml(arg, node); -} - -/* returns the number of args in the arg list */ -int -filter_arg_get_count(FilterArg *arg) -{ - int count=0; - GList *l; - - for (l = arg->values;l;l=g_list_next(l)) - count++; - return count; -} - -void * -filter_arg_get_value(FilterArg *arg, int index) -{ - int count = 0; - GList *l; - - for (l = arg->values; l && count < index; l = g_list_next(l)) - count++; - if (l) - return l->data; - return NULL; -} - -char * -filter_arg_get_value_as_string(FilterArg *arg, int index) -{ - void *data; - - data = filter_arg_get_value(arg, index); - if (data) { - return ((FilterArgClass *)(arg->object.klass))->get_value_as_string(arg, data); - } else { - return ""; - } -} - - -struct filter_arg_edit { - FilterArg *arg; - GtkList *list; - GList *items; - GnomeDialog *dialogue; - GtkWidget *add, *remove, *edit; - GtkWidget *item_current; -}; - -static void -filter_arg_edit_add(GtkWidget *w, struct filter_arg_edit *edata) -{ - GtkWidget *listitem; - int i; - - i = filter_arg_edit_value(edata->arg, -1); - if (i>=0) { - gtk_list_remove_items_no_unref(edata->list, edata->items); - listitem = gtk_list_item_new_with_label(filter_arg_get_value_as_string(edata->arg, i)); - gtk_object_set_data(GTK_OBJECT (listitem), "arg_i", filter_arg_get_value(edata->arg, i)); - edata->items = g_list_append(edata->items, listitem); - gtk_widget_show(listitem); - - /* this api is nonsense */ - gtk_list_append_items(edata->list, g_list_copy(edata->items)); - } -} - -void dump_list(GList *list) -{ - printf("dumping list:\n"); - for (;list;list = g_list_next(list)) { - printf(" %p %p\n", list, list->data); - } -} - -static void -fill_list(struct filter_arg_edit *edata) -{ - GList *items = NULL; - int i, count; - GtkListItem *listitem; - - gtk_list_remove_items(edata->list, edata->items); - g_list_free(edata->items); - - count = filter_arg_get_count(edata->arg); - for (i=0;i<count;i++) { - char *labeltext; - labeltext = filter_arg_get_value_as_string(edata->arg, i); - listitem = (GtkListItem *)gtk_list_item_new_with_label(labeltext); - gtk_object_set_data((GtkObject *)listitem, "arg_i", filter_arg_get_value(edata->arg, i)); - items = g_list_append(items, listitem); - gtk_widget_show(GTK_WIDGET(listitem)); - } - - edata->item_current = NULL; - edata->items = items; - - gtk_list_append_items(edata->list, g_list_copy(edata->items)); -} - -static void -filter_arg_edit_edit(GtkWidget *w, struct filter_arg_edit *edata) -{ - char *name; - int i; - - /* yurck */ - if (edata->item_current - && (name = gtk_object_get_data(GTK_OBJECT (edata->item_current), "arg_i")) - && (i = g_list_index(edata->arg->values, name)) >= 0 - && (i = filter_arg_edit_value(edata->arg, i)) >= 0) { - - fill_list(edata); - } -} - -static void -filter_arg_edit_delete(GtkWidget *w, struct filter_arg_edit *edata) -{ - char *name; - - /* yurck */ - name = gtk_object_get_data(GTK_OBJECT (edata->item_current), "arg_i"); - if (edata->item_current && name) { - filter_arg_remove(edata->arg, name); - fill_list(edata); - } -} - -static void -edit_sensitise(struct filter_arg_edit *edata) -{ - int state = edata->item_current != NULL; - gtk_widget_set_sensitive(edata->remove, state); - gtk_widget_set_sensitive(edata->edit, state); -} - -static void -filter_arg_edit_select(GtkWidget *w, GtkListItem *list, struct filter_arg_edit *edata) -{ - edata->item_current = GTK_WIDGET (list); - edit_sensitise(edata); -} - -static void -filter_arg_edit_unselect(GtkWidget *w, GtkListItem *list, struct filter_arg_edit *edata) -{ - edata->item_current = NULL; - edit_sensitise(edata); -} - -static void -filter_arg_edit_clicked(GnomeDialog *d, int button, struct filter_arg_edit *edata) -{ - struct _FilterArgPrivate *p = _PRIVATE(edata->arg); - - if (button == 0) { - gtk_signal_emit(GTK_OBJECT(edata->arg), signals[CHANGED]); - } else { - /* cancel button, restore old values ... */ - while (edata->arg->values) { - filter_arg_remove(edata->arg, edata->arg->values->data); - } - filter_arg_values_add_xml(edata->arg, (xmlNodePtr) p->oldargs); - } - xmlFreeNodeList((xmlNodePtr) p->oldargs); - p->oldargs = NULL; - p->dialogue = NULL; - gnome_dialog_close(d); -} - -static void -filter_arg_edit_destroy(GnomeDialog *d, struct filter_arg_edit *edata) -{ - struct _FilterArgPrivate *p = _PRIVATE(edata->arg); - - if (p->oldargs) { - while (edata->arg->values) { - filter_arg_remove(edata->arg, edata->arg->values->data); - } - filter_arg_values_add_xml(edata->arg, (xmlNodePtr) p->oldargs); - xmlFreeNodeList((xmlNodePtr) p->oldargs); - p->oldargs = NULL; - } - - if (p->dialogue) { - p->dialogue = NULL; - gnome_dialog_close(d); - } - g_free(edata); -} - -void -filter_arg_edit_values_1(FilterArg *arg) -{ - GtkWidget *list; - GnomeDialog *dialogue; - GtkWidget *hbox; - GtkWidget *vbox; - GtkWidget *button; - GtkWidget *scrolled_window, *frame; - struct filter_arg_edit * edata; - struct _FilterArgPrivate *p = _PRIVATE(arg); - - /* dont show more than 1 editor for each type */ - if (p->dialogue) { - gdk_window_raise(GTK_WIDGET(p->dialogue)->window); - return; - } - - /* copy the current state */ - p->oldargs = filter_arg_values_get_xml(arg); - - edata = g_malloc0(sizeof(*edata)); - edata->item_current = NULL; - edata->arg = arg; - - dialogue = (GnomeDialog *)gnome_dialog_new("Edit values", "Ok", "Cancel", 0); - edata->dialogue = dialogue; - - p->dialogue = GTK_WIDGET (dialogue); - - hbox = gtk_hbox_new(FALSE, 0); - - list = gtk_list_new(); - edata->list = GTK_LIST (list); - edata->items = NULL; - fill_list(edata); - - scrolled_window = gtk_scrolled_window_new(NULL, NULL); - frame = gtk_frame_new("Option values"); - - gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window), list); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_container_set_focus_vadjustment(GTK_CONTAINER (list), - gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (scrolled_window))); - gtk_container_add(GTK_CONTAINER(frame), scrolled_window); - gtk_widget_set_usize(frame, 200, 300); - gtk_box_pack_start(GTK_BOX (hbox), frame, TRUE, TRUE, 0); - - /* buttons */ - vbox = gtk_vbox_new(FALSE, 0); - - button = gtk_button_new_with_label ("Add"); - gtk_box_pack_start(GTK_BOX (vbox), button, FALSE, TRUE, 0); - edata->add = button; - button = gtk_button_new_with_label ("Remove"); - gtk_box_pack_start(GTK_BOX (vbox), button, FALSE, TRUE, 0); - edata->remove = button; - button = gtk_button_new_with_label ("Edit"); - gtk_box_pack_start(GTK_BOX (vbox), button, FALSE, TRUE, 0); - edata->edit = button; - - gtk_box_pack_start(GTK_BOX (hbox), vbox, FALSE, FALSE, 0); - - gtk_signal_connect(GTK_OBJECT (edata->add), "clicked", filter_arg_edit_add, edata); - gtk_signal_connect(GTK_OBJECT (edata->edit), "clicked", filter_arg_edit_edit, edata); - gtk_signal_connect(GTK_OBJECT (edata->remove), "clicked", filter_arg_edit_delete, edata); - gtk_signal_connect(GTK_OBJECT (edata->list), "select_child", filter_arg_edit_select, edata); - gtk_signal_connect(GTK_OBJECT (edata->list), "unselect_child", filter_arg_edit_unselect, edata); - - gtk_widget_show(list); - gtk_widget_show_all(hbox); - gtk_box_pack_start(GTK_BOX (dialogue->vbox), hbox, TRUE, TRUE, 0); - - gtk_signal_connect(GTK_OBJECT (dialogue), "clicked", filter_arg_edit_clicked, edata); - gtk_signal_connect(GTK_OBJECT (dialogue), "destroy", filter_arg_edit_destroy, edata); - - edit_sensitise(edata); - - gtk_widget_show(GTK_WIDGET (dialogue)); -} - - diff --git a/filter/filter-arg.h b/filter/filter-arg.h deleted file mode 100644 index c7b038a996..0000000000 --- a/filter/filter-arg.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Michael Zucchi <notzed@helixcode.com> - * - * Abstract class to hold filter arguments. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public License - * as published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef _FILTER_ARG_H -#define _FILTER_ARG_H - -#include <gtk/gtk.h> -#include <gtkhtml/gtkhtml.h> -#include <gnome-xml/tree.h> /* gnome-xml */ - -#define FILTER_ARG(obj) GTK_CHECK_CAST (obj, filter_arg_get_type (), FilterArg) -#define FILTER_ARG_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, filter_arg_get_type (), FilterArgClass) -#define IS_FILTER_ARG(obj) GTK_CHECK_TYPE (obj, filter_arg_get_type ()) - -typedef struct _FilterArg FilterArg; -typedef struct _FilterArgClass FilterArgClass; - -struct _FilterArg { - GtkObject object; - - struct _FilterArgPrivate *priv; - - char *name; - GList *values; -}; - -struct _FilterArgClass { - GtkObjectClass parent_class; - - /* make a copy of yourself */ - struct _FilterArg * (*clone)(FilterArg *arg); - - /* virtual methods */ - void (*write_html)(FilterArg *arg, GtkHTML *html, GtkHTMLStream *stream); - void (*write_text)(FilterArg *arg, GString *string); - void (*free_value)(FilterArg *arg, void *v); - - void (*edit_values)(FilterArg *arg); - int (*edit_value)(FilterArg *arg, int index); - - void (*values_add_xml)(FilterArg *arg, xmlNodePtr node); - xmlNodePtr (*values_get_xml)(FilterArg *arg); - - char * (*get_value_as_string)(FilterArg *arg, void *data); - - /* signals */ - void (*changed)(FilterArg *arg); -}; - -guint filter_arg_get_type (void); -FilterArg *filter_arg_new (char *name); -FilterArg *filter_arg_clone(FilterArg *arg); -void filter_arg_copy (FilterArg *dst, FilterArg *src); -void filter_arg_value_add(FilterArg *a, void *v); - -void filter_arg_write_html(FilterArg *arg, GtkHTML *html, - GtkHTMLStream *stream); -void filter_arg_write_text(FilterArg *arg, GString *string); - -void filter_arg_edit_values(FilterArg *arg); -int filter_arg_edit_value(FilterArg *arg, int index); - -void filter_arg_remove(FilterArg *arg, void *v); -void filter_arg_add(FilterArg *arg, void *v); - -xmlNodePtr filter_arg_values_get_xml(FilterArg *arg); -void filter_arg_values_add_xml(FilterArg *arg, xmlNodePtr node); -int filter_arg_get_count(FilterArg *arg); -void *filter_arg_get_value(FilterArg *arg, int index); -char *filter_arg_get_value_as_string(FilterArg *arg, int index); - -#endif /* ! _FILTER_ARG_H */ - diff --git a/filter/filter-driver.c b/filter/filter-driver.c deleted file mode 100644 index aa26e38f51..0000000000 --- a/filter/filter-driver.c +++ /dev/null @@ -1,578 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Michael Zucchi <notzed@helixcode.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include "filter-driver.h" - -#include <glib.h> -#include <gtk/gtk.h> -#include <gnome.h> -#include <gtkhtml/gtkhtml.h> - -#include <gnome-xml/tree.h> -#include <gnome-xml/parser.h> - -#include "filter-arg-types.h" -#include "filter-xml.h" -#include "e-sexp.h" -#include "filter-format.h" - -#include <camel/camel.h> - -struct _FilterDriverPrivate { - GList *rules, *options; - GHashTable *globals; /* global variables */ - FilterFolderFetcher fetcher; - - /* run-time data */ - GHashTable *folders; /* currently open folders */ - GList *matches; /* all messages which match current rule */ - GHashTable *terminated; /* messages for which processing is terminated */ - GHashTable *processed; /* all messages that were processed in some way */ - - CamelFolder *source; /* temporary input folder */ - - CamelException *ex; - - /* evaluator */ - ESExp *eval; -}; - -#define _PRIVATE(o) (((FilterDriver *)(o))->priv) - -static void filter_driver_class_init (FilterDriverClass *klass); -static void filter_driver_init (FilterDriver *obj); -static void filter_driver_finalise (GtkObject *obj); - -static CamelFolder *open_folder(FilterDriver *d, const char *folder_url); -static int close_folders(FilterDriver *d); - -static ESExpResult *do_delete(struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *); -static ESExpResult *do_forward(struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *); -static ESExpResult *do_copy(struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *); -static ESExpResult *do_stop(struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *); - -static struct { - char *name; - ESExpFunc *func; - int type; /* set to 1 if a function can perform shortcut evaluation, or - doesn't execute everything, 0 otherwise */ -} symbols[] = { - { "delete", (ESExpFunc *)do_delete, 0 }, - { "forward-to", (ESExpFunc *)do_forward, 0 }, - { "copy-to", (ESExpFunc *)do_copy, 0 }, - { "stop", (ESExpFunc *)do_stop, 0 }, -}; - -static GtkObjectClass *filter_driver_parent; - -enum SIGNALS { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -guint -filter_driver_get_type (void) -{ - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "FilterDriver", - sizeof (FilterDriver), - sizeof (FilterDriverClass), - (GtkClassInitFunc) filter_driver_class_init, - (GtkObjectInitFunc) filter_driver_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - type = gtk_type_unique (gtk_object_get_type (), &type_info); - } - - return type; -} - -static void -filter_driver_class_init (FilterDriverClass *klass) -{ - GtkObjectClass *object_class = (GtkObjectClass *) klass; - - filter_driver_parent = gtk_type_class (gtk_object_get_type ()); - - object_class->finalize = filter_driver_finalise; - - gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); -} - -static void -filter_driver_init (FilterDriver *obj) -{ - struct _FilterDriverPrivate *p; - int i; - - p = _PRIVATE(obj) = g_malloc0(sizeof(*p)); - - p->eval = e_sexp_new(); - /* Load in builtin symbols */ - for(i=0;i<sizeof(symbols)/sizeof(symbols[0]);i++) { - if (symbols[i].type == 1) { - e_sexp_add_ifunction(p->eval, 0, symbols[i].name, (ESExpIFunc *)symbols[i].func, obj); - } else { - e_sexp_add_function(p->eval, 0, symbols[i].name, symbols[i].func, obj); - } - } - - p->globals = g_hash_table_new(g_str_hash, g_str_equal); - - p->ex = camel_exception_new (); -} - -static void -free_hash_strings(void *key, void *value, void *data) -{ - g_free(key); - g_free(value); -} - -static void -filter_driver_finalise (GtkObject *obj) -{ - FilterDriver *d = (FilterDriver *)obj; - struct _FilterDriverPrivate *p = _PRIVATE(d); - - g_hash_table_foreach(p->globals, free_hash_strings, d); - g_hash_table_destroy(p->globals); - - gtk_object_unref((GtkObject *)p->eval); - - camel_exception_free(p->ex); - - g_free(p); - - ((GtkObjectClass *)(filter_driver_parent))->finalize((GtkObject *)obj); -} - -/** - * filter_driver_new: - * @system: path to system rules - * @user: path to user rules - * @fetcher: function to call to fetch folders - * - * Create a new FilterDriver object. - * - * Return value: A new FilterDriver widget. - **/ -FilterDriver * -filter_driver_new (const char *system, const char *user, FilterFolderFetcher fetcher) -{ - FilterDriver *new; - struct _FilterDriverPrivate *p; - xmlDocPtr desc, filt; - - new = FILTER_DRIVER (gtk_type_new (filter_driver_get_type ())); - p = _PRIVATE(new); - - p->fetcher = fetcher; - -#warning "fix leaks, free xml docs here" - desc = xmlParseFile(system); - p->rules = filter_load_ruleset(desc); - - filt = xmlParseFile(user); - if (filt == NULL) - p->options = NULL; - else - p->options = filter_load_optionset(filt, p->rules); - - return new; -} - - -void filter_driver_set_global(FilterDriver *d, const char *name, const char *value) -{ - struct _FilterDriverPrivate *p = _PRIVATE(d); - char *oldkey, *oldvalue; - - if (g_hash_table_lookup_extended(p->globals, name, (void *)&oldkey, (void *)&oldvalue)) { - g_free(oldvalue); - g_hash_table_insert(p->globals, oldkey, g_strdup(value)); - } else { - g_hash_table_insert(p->globals, g_strdup(name), g_strdup(value)); - } -} - -extern int filter_find_arg(FilterArg *a, char *name); - -/* - - foreach rule - find matches - - foreach action - get all matches - - */ - -/* - splices ${cc} lines into a single string -*/ -static int -expand_variables(GString *out, char *source, GList *args, GHashTable *globals) -{ - GList *argl; - FilterArg *arg; - char *name= alloca(32); - char *start, *end, *newstart, *tmp, *val; - int namelen=32; - int len=0; - int ok = 0; - - start = source; - while ( (newstart = strstr(start, "${")) - && (end = strstr(newstart+2, "}")) ) { - len = end-newstart-2; - if (len+1>namelen) { - namelen = (len+1)*2; - name = alloca(namelen); - } - memcpy(name, newstart+2, len); - name[len] = 0; - argl = g_list_find_custom(args, name, (GCompareFunc) filter_find_arg); - if (argl) { - int i, count; - - tmp = g_strdup_printf("%.*s", newstart-start, start); - g_string_append(out, tmp); - g_free(tmp); - - arg = argl->data; - count = filter_arg_get_count(arg); - for (i=0;i<count;i++) { - g_string_append(out, " \""); - g_string_append(out, filter_arg_get_value_as_string(arg, i)); - g_string_append(out, "\""); - } - } else if ( (val = g_hash_table_lookup(globals, name)) ) { - tmp = g_strdup_printf("%.*s", newstart-start, start); - g_string_append(out, tmp); - g_free(tmp); - g_string_append(out, " \""); - g_string_append(out, val); - g_string_append(out, "\""); - } else { - ok = 1; - tmp = g_strdup_printf("%.*s", end-start+1, start); - g_string_append(out, tmp); - g_free(tmp); - } - start = end+1; - } - g_string_append(out, start); - - return ok; -} - -/* - build an expression for the filter -*/ -void -filter_driver_expand_option(FilterDriver *d, GString *s, GString *action, struct filter_option *op) -{ - GList *optionl; - FilterArg *arg; - struct _FilterDriverPrivate *p = _PRIVATE(d); - - 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; - expand_variables(s, or->rule->code, or->args, p->globals); - } - optionl = g_list_next(optionl); - } - - g_string_append(s, ")"); - } - - 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); - } - g_string_append(action, ")"); - } -} - -static ESExpResult * -do_delete(struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *d) -{ - struct _FilterDriverPrivate *p = _PRIVATE(d); - GList *m; - - printf("doing delete\n"); - m = p->matches; - while (m) { - printf(" %s\n", (char *)m->data); - - camel_folder_delete_message (p->source, m->data, p->ex); - if (g_hash_table_lookup(p->processed, m->data) == NULL) { - g_hash_table_insert(p->processed, g_strdup(m->data), (void *)1); - } - - m = m->next; - } - return NULL; -} - -static ESExpResult * -do_forward(struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *d) -{ - struct _FilterDriverPrivate *p = _PRIVATE(d); - GList *m; - - printf("doing forward on the following messages:\n"); - m = p->matches; - while (m) { - printf(" %s\n", (char *)m->data); - m = m->next; - } - return NULL; -} - -static ESExpResult * -do_copy(struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *d) -{ - GList *m; - int i; - struct _FilterDriverPrivate *p = _PRIVATE(d); - - printf("doing copy\n"); - for (i=0;i<argc;i++) { - if (argv[i]->type == ESEXP_RES_STRING) { - char *folder = argv[i]->value.string; - CamelFolder *outbox; - - outbox = open_folder(d, folder); - if (outbox == NULL) - continue; - - m = p->matches; - while (m) { - CamelMimeMessage *mm; - - printf("appending message %s to %s\n", (char *)m->data, folder); - - mm = camel_folder_get_message(p->source, m->data, p->ex); - camel_folder_append_message(outbox, mm, p->ex); - gtk_object_unref((GtkObject *)mm); - - if (!camel_exception_is_set(p->ex) && - g_hash_table_lookup(p->processed, m->data) == NULL) { - g_hash_table_insert(p->processed, g_strdup(m->data), (void *)1); - } - - m = m->next; - } - } - } - - return NULL; -} - -static ESExpResult * -do_stop(struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *d) -{ - GList *m; - struct _FilterDriverPrivate *p = _PRIVATE(d); - - printf("doing stop on the following messages:\n"); - m = p->matches; - while (m) { - printf(" %s\n", (char *)m->data); - g_hash_table_insert(p->terminated, g_strdup(m->data), (void *)1); - if (g_hash_table_lookup(p->processed, m->data) == NULL) { - g_hash_table_insert(p->processed, g_strdup(m->data), (void *)1); - } - m = m->next; - } - return NULL; -} - -static CamelFolder * -open_folder(FilterDriver *d, const char *folder_url) -{ - CamelFolder *camelfolder; - struct _FilterDriverPrivate *p = _PRIVATE(d); - - /* we have a lookup table of currently open folders */ - camelfolder = g_hash_table_lookup(p->folders, folder_url); - if (camelfolder) - return camelfolder; - - camelfolder = p->fetcher(folder_url); - if (camelfolder) { - g_hash_table_insert(p->folders, g_strdup(folder_url), camelfolder); - camel_folder_freeze(camelfolder); - } - - return camelfolder; -} - -static void -close_folder(void *key, void *value, void *data) -{ - CamelFolder *f = value; - FilterDriver *d = data; - struct _FilterDriverPrivate *p = _PRIVATE(d); - - g_free(key); - camel_folder_sync(f, FALSE, p->ex); - camel_folder_thaw(f); - gtk_object_unref((GtkObject *)f); -} - -/* flush/close all folders */ -static int -close_folders(FilterDriver *d) -{ - struct _FilterDriverPrivate *p = _PRIVATE(d); - - g_hash_table_foreach(p->folders, close_folder, d); - g_hash_table_destroy(p->folders); - p->folders = g_hash_table_new(g_str_hash, g_str_equal); - - /* FIXME: status from d */ - return 0; -} - -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); - ESExpResult *r; - GList *options; - GString *s, *a; - GPtrArray *all; - GList *m; - int i; - -#warning "This must be made mega-robust" - p->source = source; - - /* setup runtime data */ - p->folders = g_hash_table_new(g_str_hash, g_str_equal); - p->terminated = g_hash_table_new(g_str_hash, g_str_equal); - p->processed = g_hash_table_new(g_str_hash, g_str_equal); - - camel_exception_init(p->ex); - camel_folder_freeze(inbox); - - options = p->options; - while (options) { - struct filter_option *fo = options->data; - - s = g_string_new(""); - a = g_string_new(""); - filter_driver_expand_option(d, s, a, fo); - - p->matches = camel_folder_search_by_expression (p->source, s->str, p->ex); - - /* remove uid's for which processing is complete ... */ - m = p->matches; - while (m) { - GList *n = m->next; - - if (g_hash_table_lookup(p->terminated, m->data)) { - p->matches = g_list_remove_link(p->matches, m); - } - m = n; - } - - e_sexp_input_text(p->eval, a->str, strlen(a->str)); - e_sexp_parse(p->eval); - r = e_sexp_eval(p->eval); - e_sexp_result_free(r); - - g_string_free(s, TRUE); - g_string_free(a, TRUE); - - g_list_free(p->matches); - - options = g_list_next(options); - } - - /* apply the default of copying to an inbox, if we are given one, and make sure - we delete everything as well */ - all = camel_folder_get_uids(p->source, p->ex); - for (i = 0; i < all->len; i++) { - char *uid = all->pdata[i], *procuid; - CamelMimeMessage *mm; - - procuid = g_hash_table_lookup(p->processed, uid); - if (procuid == NULL) { - if (inbox) { - printf("Applying default rule to message %s\n", uid); - - mm = camel_folder_get_message(p->source, uid, p->ex); - camel_folder_append_message(inbox, mm, p->ex); - gtk_object_unref((GtkObject *)mm); - camel_folder_delete_message(p->source, uid, p->ex); - } - } else { - camel_folder_delete_message(p->source, uid, p->ex); - } - } - camel_folder_free_uids(p->source, all); - - g_hash_table_destroy(p->processed); - g_hash_table_destroy(p->terminated); - close_folders(d); - g_hash_table_destroy(p->folders); - camel_folder_thaw(inbox); - - return 0; -} diff --git a/filter/filter-driver.h b/filter/filter-driver.h deleted file mode 100644 index a7a752aecd..0000000000 --- a/filter/filter-driver.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Michael Zucchi <notzed@helixcode.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#ifndef _FILTER_DRIVER_H -#define _FILTER_DRIVER_H - -#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) -#define IS_FILTER_DRIVER(obj) GTK_CHECK_TYPE (obj, filter_driver_get_type ()) - -typedef struct _FilterDriver FilterDriver; -typedef struct _FilterDriverClass FilterDriverClass; - -struct _FilterDriver { - GtkObject parent; - - struct _FilterDriverPrivate *priv; -}; - -struct _FilterDriverClass { - GtkObjectClass parent_class; -}; - -typedef CamelFolder *(*FilterFolderFetcher) (const char *uri); - -guint filter_driver_get_type (void); -FilterDriver *filter_driver_new (const char *system, const char *user, FilterFolderFetcher fetcher); - -void filter_driver_set_global(FilterDriver *, const char *name, const char *value); - -/* 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/filter-druid.c b/filter/filter-druid.c deleted file mode 100644 index f516112d5d..0000000000 --- a/filter/filter-druid.c +++ /dev/null @@ -1,728 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Michael Zucchi <notzed@helixcode.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public License - * as published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include <glib.h> -#include <gtk/gtk.h> -#include <gnome.h> -#include <gtkhtml/gtkhtml.h> -#include <string.h> - -#include <gnome-xml/tree.h> -#include <gnome-xml/parser.h> - -#include "widgets/misc/e-scroll-frame.h" - -#include "filter-arg-types.h" -#include "filter-xml.h" -#include "filter-format.h" - - -#include "filter-druid.h" - -static void filter_druid_class_init (FilterDruidClass *klass); -static void filter_druid_init (FilterDruid *obj); - -#define _PRIVATE(x) (((FilterDruid *)(x))->priv) - -struct _FilterDruidPrivate { - GtkWidget *notebook; - int page; - - char *default_html; - - /* page 0 */ - GtkWidget *list0; - GtkWidget *html0; - GtkWidget *add0, *remove0, *up0, *down0; - GList *items0; - GtkFrame *listframe0; - - /* page 1 */ - GtkWidget *name1; - GtkWidget *activate1; - GtkHTML *html1; -}; - -/* forward ref's */ -static void build_druid(FilterDruid *d); -static void update_display(FilterDruid *f, int initial); - -/* globals */ -static GtkNotebookClass *filter_druid_parent; - -enum SIGNALS { - OPTION_SELECTED, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -guint -filter_druid_get_type (void) -{ - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "FilterDruid", - sizeof (FilterDruid), - sizeof (FilterDruidClass), - (GtkClassInitFunc) filter_druid_class_init, - (GtkObjectInitFunc) filter_druid_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - type = gtk_type_unique (gtk_notebook_get_type (), &type_info); - } - - return type; -} - -static void -object_destroy(FilterDruid *obj) -{ - struct _FilterDruidPrivate *p = _PRIVATE(obj); - - g_free(p->default_html); - - gtk_signal_disconnect_by_data((GtkObject *)p->list0, obj); - - /* FIXME: free lists? */ - - GTK_OBJECT_CLASS(filter_druid_parent)->destroy(GTK_OBJECT (obj)); -} - -static void -filter_druid_class_init (FilterDruidClass *klass) -{ - GtkObjectClass *object_class = (GtkObjectClass *) klass; - - filter_druid_parent = gtk_type_class (gtk_notebook_get_type ()); - - object_class->destroy = object_destroy; - - signals[OPTION_SELECTED] = - gtk_signal_new ("option_selected", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (FilterDruidClass, option_selected), - gtk_marshal_NONE__POINTER, - GTK_TYPE_NONE, 1, - GTK_TYPE_POINTER); - - gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); -} - -static void -filter_druid_init (FilterDruid *obj) -{ - struct _FilterDruidPrivate *priv; - - obj->priv = g_malloc0(sizeof(*obj->priv)); - priv = _PRIVATE(obj); -} - -/** - * filter_druid_new: - * - * Create a new FilterDruid object. - * - * Return value: A new FilterDruid widget. - **/ -FilterDruid * -filter_druid_new (void) -{ - FilterDruid *new = FILTER_DRUID ( gtk_type_new (filter_druid_get_type ())); - - build_druid(new); - - return new; -} - - -extern int filter_find_arg(FilterArg *a, char *name); - -#include "check.xpm" -#include "blank.xpm" - - -struct filter_optionrule * -find_optionrule(struct filter_option *option, char *name) -{ - GList *optionrulel; - struct filter_optionrule *or; - - optionrulel = option->options; - while (optionrulel) { - or = optionrulel->data; - if (!strcmp(or->rule->name, name)) { - return or; - } - optionrulel = g_list_next(optionrulel); - } - return NULL; -} - -static int display_order[] = { - FILTER_XML_MATCH, - FILTER_XML_EXCEPT, - FILTER_XML_ACTION, -}; -static char *display_pretext[] = { - "<b>For messages matching:</b><ul>", - "<b>Unless:</b><ul>", - "<b>Perform these actions:</b><ul>", -}; -static char *display_posttext[] = { - "</ul>", - "</ul>", - "</ul>", -}; - -void -html_write_options(GtkHTML *html, struct filter_option *option, char *def) -{ - GtkHTMLStream *stream; - GList *optionrulel; - int i; - - stream = gtk_html_begin(html); - - gtk_html_write(html, stream, "<body bgcolor=white alink=blue>", strlen("<body bgcolor=white alink=blue>")); - if (option) { - char *t; - - if (option->type == FILTER_XML_SEND) { - t = "<p>When a message is <i>sent</i>.</p>"; - } else { - t = "<p>When a message is <i>received</i>.</p>"; - } - gtk_html_write(html, stream, t, strlen(t)); - - for (i=0;i<sizeof(display_order)/sizeof(display_order[0]);i++) { - int doneheader = FALSE; - int donefirst = FALSE; - optionrulel = option->options; - while (optionrulel) { - struct filter_optionrule *or = optionrulel->data; - - if (or->rule->type == display_order[i]) { - if (!doneheader) { - gtk_html_write(html, stream, display_pretext[i], strlen(display_pretext[i])); - doneheader = TRUE; - } - - if (donefirst) { - gtk_html_write(html, stream, " <i>and</i> ", strlen(" <i>and</i> ")); - } - filter_description_html_write(or->rule->description, or->args, html, stream); - donefirst = TRUE; - gtk_html_write(html, stream, "<br>", strlen("<br>")); - } - optionrulel = g_list_next(optionrulel); - } - if (doneheader) { - gtk_html_write(html, stream, display_posttext[i], strlen(display_posttext[i])); - } - } - } else { - if (def == NULL) - def = "Select options."; - gtk_html_write(html, stream, def, strlen(def)); - } - gtk_html_end(html, stream, GTK_HTML_STREAM_OK); -} - -GList * -fill_rules(GList *rules, struct filter_option *option, int type) -{ - GList *rulel; - GtkWidget *listitem, *hbox, *checkbox, *label; - GList *items = NULL; - - rulel = rules; - while (rulel) { - struct filter_rule *fr = rulel->data; - char *labeltext; - - if (fr->type == type) { - int state; - - state = find_optionrule(option, fr->name) != NULL; - - labeltext = filter_description_text(fr->description, NULL); - - hbox = gtk_hbox_new(FALSE, 3); - checkbox = gnome_pixmap_new_from_xpm_d(state?check_xpm:blank_xpm); - gtk_box_pack_start(GTK_BOX(hbox), checkbox, FALSE, FALSE, 0); - label = gtk_label_new(labeltext); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, TRUE, 0); - listitem = gtk_list_item_new(); - gtk_container_add(GTK_CONTAINER(listitem), hbox); - gtk_widget_show_all(listitem); - - gtk_object_set_data(GTK_OBJECT(listitem), "checkbox", checkbox); - gtk_object_set_data(GTK_OBJECT(listitem), "checkstate", (void *)state); - gtk_object_set_data(GTK_OBJECT(listitem), "rule", fr); - - items = g_list_append(items, listitem); - } - rulel = g_list_next(rulel); - } - return items; -} - -GList * -fill_options(GList *options) -{ - GList *optionl; - GtkWidget *listitem; - GList *items = NULL; - - optionl = options; - while (optionl) { - struct filter_option *op = optionl->data; - char *labeltext; - - labeltext = filter_description_text(op->description, NULL); - listitem = gtk_list_item_new_with_label(labeltext); - g_free(labeltext); - gtk_widget_show_all(listitem); - - gtk_object_set_data(GTK_OBJECT(listitem), "option", op); - - items = g_list_append(items, listitem); - optionl = g_list_next(optionl); - } - return items; -} - -static void -select_rule_child(GtkList *list, GtkWidget *child, FilterDruid *f) -{ - GtkWidget *w; - struct filter_rule *fr = gtk_object_get_data(GTK_OBJECT(child), "rule"); - int state; - struct filter_optionrule *rule; - /*struct _FilterDruidPrivate *p = _PRIVATE(f);*/ - - w = gtk_object_get_data(GTK_OBJECT(child), "checkbox"); - state = !(int) gtk_object_get_data(GTK_OBJECT(child), "checkstate"); - - gnome_pixmap_load_xpm_d(GNOME_PIXMAP(w), state?check_xpm:blank_xpm); - gtk_object_set_data(GTK_OBJECT(child), "checkstate", (void *)state); - - if (state) { - rule = filter_optionrule_new_from_rule(fr); - f->option_current->options = g_list_append(f->option_current->options, rule); - } else { - rule = find_optionrule(f->option_current, fr->name); - if (rule) { - f->option_current->options = g_list_remove(f->option_current->options, rule); - filter_clone_optionrule_free(rule); - } - } - - update_display(f, 0); -} - - - -static void -select_option_child(GtkList *list, GtkWidget *child, FilterDruid *f) -{ - struct filter_option *op; - struct filter_option *new; - GList *optionsl; - struct _FilterDruidPrivate *p = _PRIVATE(f); - - switch (p->page) { - case 1: - case 2: - case 3: - select_rule_child(list, child, f); - default: - return; - case 0: - break; - } - - if (f->option_current) { - /* free option_current copy */ - optionsl = f->option_current->options; - while (optionsl) { - GList *op = optionsl; - optionsl = g_list_next(optionsl); - filter_clone_optionrule_free(op->data); - } - g_list_free(f->option_current->options); - g_free(f->option_current); - f->option_current = NULL; - } - - if (child) { - op = gtk_object_get_data(GTK_OBJECT(child), "option"); - - /* clone the option */ - new = g_malloc(sizeof(*new)); - new->type = op->type; - new->description = op->description; - new->options = NULL; - optionsl = op->options; - while (optionsl) { - struct filter_optionrule *ornew, - *or = optionsl->data; - ornew = filter_clone_optionrule(or); - new->options = g_list_append(new->options, ornew); - optionsl = g_list_next(optionsl); - } - f->option_current = new; - - gtk_signal_emit(GTK_OBJECT(f), signals[OPTION_SELECTED], op); - } - - update_display(f, 0); -} - -static void -unselect_option_child(GtkList *list, GtkWidget *child, FilterDruid *f) -{ - select_option_child(list, NULL, f); -} - -static void -arg_changed(FilterArg *arg, FilterDruid *f) -{ - FilterArg *orig; - - orig = gtk_object_get_data(GTK_OBJECT (arg), "origin"); - if (orig) { - filter_arg_copy(orig, arg); - update_display(f, 0); - } else { - /* FIXME: uh, what the fuck to do here? */ - update_display(f, 0); - } -} - -static void -arg_link_clicked(GtkHTML *html, const char *url, FilterDruid *f) -{ - if (!strncmp(url, "arg:", 4)) { - FilterArg *arg; - void *dummy; - - if ((sscanf(url+4, "%p %p", &dummy, &arg) == 2) && arg) { - gtk_signal_connect(GTK_OBJECT (arg), "changed", arg_changed, f); - filter_arg_edit_values(arg); - } - } -} - -static void -option_name_changed(GtkEntry *entry, FilterDruid *f) -{ - struct filter_desc *desc; - - if (f->option_current) { - /* FIXME: lots of memory leaks */ - desc = g_malloc0(sizeof(*desc)); - desc->data = g_strdup(gtk_entry_get_text(entry)); - desc->type = FILTER_XML_TEXT; - desc->vartype = -1; - desc->varname = NULL; -#warning "Zucchi: is this correct?" - filter_description_free (f->option_current->description); - f->option_current->description = g_list_append(NULL, desc); - } -} - -static void -dialogue_clicked(FilterDruid *d, int button, void *data) -{ - GString *s = g_string_new(""); - struct _FilterDruidPrivate *p = _PRIVATE(d); - int initial=0; - - g_string_free(s, TRUE); - - switch(button) { - case 1: - if (p->page<4) { - p->page++; - initial =1; - } - break; - case 0: - if (p->page>0) { - p->page--; - initial = 1; - } - break; - } - update_display(d, initial); -} - -static int filter_types[] = { FILTER_XML_MATCH, FILTER_XML_EXCEPT, FILTER_XML_ACTION }; -static char *filter_titles[] = { - "Select rule(s), where messages match", - "Select rule(s), where messages do not match", - "Select action(s) to apply to messages" - -}; -static void -update_display(FilterDruid *f, int initial) -{ - struct _FilterDruidPrivate *p = _PRIVATE(f); - - switch (p->page) { - case 0: - if (initial) { - gtk_signal_handler_block_by_data((GtkObject *)p->list0, f); - gtk_list_remove_items((GtkList *)p->list0, p->items0); - p->items0 = fill_options(f->options); - gtk_list_append_items((GtkList *)p->list0, p->items0); - gtk_signal_handler_unblock_by_data((GtkObject *)p->list0, f); - gtk_frame_set_label(p->listframe0, "Select rule type"); - } - - html_write_options((GtkHTML *)p->html0, f->option_current, p->default_html); - break; - case 1: - case 2: - case 3: - if (initial) { - gtk_signal_handler_block_by_data((GtkObject *)p->list0, f); - gtk_list_remove_items((GtkList *)p->list0, p->items0); - p->items0 = fill_rules(f->rules, f->option_current, filter_types[p->page-1]); - gtk_list_append_items((GtkList *)p->list0, p->items0); - gtk_signal_handler_unblock_by_data((GtkObject *)p->list0, f); - gtk_frame_set_label(p->listframe0, filter_titles[p->page-1]); - gtk_notebook_set_page(GTK_NOTEBOOK(p->notebook), 0); - } - - html_write_options((GtkHTML *)p->html0, f->option_current, p->default_html); - break; - case 4: - if (initial) { - char *text; - text = filter_description_text(f->option_current->description, NULL); - if (text == NULL) { - /* maybe this could fudge something out of the first - bits of the rule */ - if (f->option_current->type == FILTER_XML_SEND) { - text = "Filter messages sent"; - } else { - text = "Filter messages received"; - } - gtk_entry_set_text(GTK_ENTRY(p->name1), text); - } else { - gtk_entry_set_text(GTK_ENTRY(p->name1), text); - g_free(text); - } - gtk_notebook_set_page(GTK_NOTEBOOK(p->notebook), 1); - } - - html_write_options((GtkHTML *)p->html1, f->option_current, p->default_html); - break; - - } -} - -void -filter_druid_set_rules(FilterDruid *f, GList *options, GList *rules, struct filter_option *current) -{ - struct filter_option *new; - GList *optionsl; - - f->options = options; - f->rules = rules; - f->user = NULL; - - if (current) { - /* FIXME: free this list if it isn't empty ... */ - /* clone the 'current' option */ - new = g_malloc(sizeof(*new)); - new->type = current->type; - new->description = current->description; - new->options = NULL; - optionsl = current->options; - while (optionsl) { - struct filter_optionrule *ornew, - *or = optionsl->data; - ornew = filter_clone_optionrule(or); - new->options = g_list_append(new->options, ornew); - optionsl = g_list_next(optionsl); - } - f->option_current = new; - } else { - f->option_current = NULL; - } - - update_display(f, 1); -} - -static void -build_druid(FilterDruid *d) -{ - GtkWidget *vbox, *frame, *scrolled_window, *list, *html, *label; - GtkWidget *table; - struct _FilterDruidPrivate *p = _PRIVATE(d); - -#if 0 - gnome_dialog_append_buttons((GnomeDialog *)d, "Prev", "Next", "Finish", "Cancel", 0); - gnome_dialog_set_close((GnomeDialog *)d, FALSE); - gnome_dialog_set_sensitive((GnomeDialog *)d, 0, FALSE); - gnome_dialog_set_sensitive((GnomeDialog *)d, 1, FALSE); - gnome_dialog_set_sensitive((GnomeDialog *)d, 2, FALSE); - gnome_dialog_set_default((GnomeDialog *)d, 1); -#endif - - p->notebook = GTK_WIDGET (d); - gtk_notebook_set_show_tabs(GTK_NOTEBOOK(p->notebook), FALSE); - gtk_notebook_set_show_border(GTK_NOTEBOOK(p->notebook), FALSE); - - /* page0, initial setup page */ - vbox = gtk_vbox_new(FALSE, 3); - frame = gtk_frame_new("Filters"); - p->listframe0 = (GtkFrame *)frame; - - list = gtk_list_new(); - scrolled_window = gtk_scrolled_window_new(NULL, NULL); - gtk_widget_set_usize(scrolled_window, 400, 150); - gtk_container_set_border_width(GTK_CONTAINER(scrolled_window), GNOME_PAD_SMALL); - gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window), list); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - gtk_container_set_focus_vadjustment - (GTK_CONTAINER (list), - gtk_scrolled_window_get_vadjustment - (GTK_SCROLLED_WINDOW (scrolled_window))); - gtk_container_add(GTK_CONTAINER(frame), scrolled_window); - gtk_box_pack_start((GtkBox *)vbox, frame, TRUE, TRUE, 0); - - frame = gtk_frame_new("Filter Description (click on values to edit)"); - html = gtk_html_new(); - scrolled_window = e_scroll_frame_new (NULL, NULL); - gtk_widget_set_usize(scrolled_window, 400, 150); - gtk_container_set_border_width(GTK_CONTAINER(scrolled_window), GNOME_PAD_SMALL); - e_scroll_frame_set_policy (E_SCROLL_FRAME (scrolled_window), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - e_scroll_frame_set_shadow_type (E_SCROLL_FRAME (scrolled_window), - GTK_SHADOW_IN); - /*gtk_container_add(GTK_CONTAINER(frame1), html);*/ - gtk_container_add(GTK_CONTAINER(scrolled_window), html);//frame1); - gtk_container_add(GTK_CONTAINER(frame), scrolled_window); - gtk_box_pack_start((GtkBox *)vbox, frame, TRUE, TRUE, 0); - - p->html0 = html; - p->list0 = list; - - gtk_signal_connect(GTK_OBJECT(list), "select_child", select_option_child, d); - gtk_signal_connect(GTK_OBJECT(list), "unselect_child", select_option_child, d); -/* gtk_signal_connect(GTK_OBJECT(list), "unselect_child", unselect_option_child, d); */ -/* gtk_signal_connect(GTK_OBJECT(d), "clicked", dialogue_clicked, d);*/ - - gtk_signal_connect(GTK_OBJECT(html), "link_clicked", arg_link_clicked, d); - - gtk_notebook_append_page(GTK_NOTEBOOK(p->notebook), vbox, NULL); - - - /* page1, used for the final page display */ - vbox = gtk_vbox_new(FALSE, 3); - - frame = gtk_frame_new("Rule options"); - gtk_box_pack_start((GtkBox *)vbox, frame, FALSE, FALSE, 0); - - table = gtk_table_new (2, 2, FALSE); - gtk_container_set_border_width (GTK_CONTAINER (table), GNOME_PAD_SMALL); - gtk_table_set_row_spacings (GTK_TABLE (table), GNOME_PAD_SMALL); - gtk_table_set_col_spacings (GTK_TABLE (table), GNOME_PAD_SMALL); - - gtk_container_add(GTK_CONTAINER(frame), table); - - label = gtk_label_new("Name of rule"); - p->name1 = gtk_entry_new(); - gtk_signal_connect(GTK_OBJECT(p->name1), "changed", option_name_changed, d); - - p->activate1 = gtk_check_button_new_with_label("Activate rule?"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p->activate1), TRUE); - - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, 0, 0, 0, 0); - gtk_table_attach (GTK_TABLE (table), p->name1, 1, 2, 0, 1, - GTK_FILL | GTK_EXPAND, 0, 0, 0); - gtk_table_attach (GTK_TABLE (table), p->activate1, 0, 2, 1, 2, - GTK_FILL | GTK_EXPAND, 0, 0, 0); - - /* another copy of the filter thingy */ - frame = gtk_frame_new("Filter Description (click on values to edit)"); - html = gtk_html_new(); - p->html1 = (GtkHTML *)html; - scrolled_window = e_scroll_frame_new (NULL, NULL); - gtk_container_set_border_width (GTK_CONTAINER (scrolled_window), GNOME_PAD_SMALL); - e_scroll_frame_set_shadow_type (E_SCROLL_FRAME (scrolled_window), - GTK_SHADOW_IN); - gtk_widget_set_usize(scrolled_window, 400, 150); - e_scroll_frame_set_policy (E_SCROLL_FRAME (scrolled_window), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - gtk_container_add(GTK_CONTAINER(scrolled_window), html); - gtk_container_add(GTK_CONTAINER(frame), scrolled_window); - gtk_box_pack_start((GtkBox *)vbox, frame, TRUE, TRUE, 0); - - /* finish off */ - gtk_notebook_append_page(GTK_NOTEBOOK(p->notebook), vbox, NULL); - - gtk_signal_connect(GTK_OBJECT(html), "link_clicked", arg_link_clicked, d); - - gtk_widget_show_all(p->notebook); -} - -void -filter_druid_set_page(FilterDruid *f, enum FilterDruidPage page) -{ - struct _FilterDruidPrivate *p = _PRIVATE(f); - int initial = p->page != page; - - p->page = page; - update_display(f, initial); -} - - -void -filter_druid_set_default_html(FilterDruid *f, const char *html) -{ - struct _FilterDruidPrivate *p = _PRIVATE(f); - - g_free(p->default_html); - p->default_html = g_strdup(html); -} - -enum FilterDruidPage -filter_druid_get_page(FilterDruid *f) -{ - struct _FilterDruidPrivate *p = _PRIVATE(f); - - return p->page; -} - diff --git a/filter/filter-druid.h b/filter/filter-druid.h deleted file mode 100644 index 7927dc70dd..0000000000 --- a/filter/filter-druid.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Michael Zucchi <notzed@helixcode.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public License - * as published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef _FILTER_DRUID_H -#define _FILTER_DRUID_H - -#include <gtk/gtk.h> - -#include "filter-xml.h" - -#define FILTER_DRUID(obj) GTK_CHECK_CAST (obj, filter_druid_get_type (), FilterDruid) -#define FILTER_DRUID_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, filter_druid_get_type (), FilterDruidClass) -#define IS_FILTER_DRUID(obj) GTK_CHECK_TYPE (obj, filter_druid_get_type ()) - -typedef struct _FilterDruid FilterDruid; -typedef struct _FilterDruidClass FilterDruidClass; - -enum FilterDruidPage { - FILTER_DRUID_SELECT_RULE, - FILTER_DRUID_SELECT_MATCH, - FILTER_DRUID_SELECT_NOMATCH, - FILTER_DRUID_SELECT_ACTION, - FILTER_DRUID_SELECT_FINISH -}; - -struct _FilterDruid { - GtkNotebook parent; - - GList *options; /* all options */ - GList *rules; /* all rules */ - GList *user; /* current user options */ - - struct filter_option *option_current; - - struct _FilterDruidPrivate *priv; -}; - -struct _FilterDruidClass { - GtkNotebookClass parent_class; - - /* signals */ - void (*option_selected)(FilterDruid *f, struct filter_option *option); -}; - -guint filter_druid_get_type (void); -FilterDruid *filter_druid_new (void); - -/* Hmm, glists suck, no typesafety */ -void filter_druid_set_rules(FilterDruid *f, GList *options, GList *rules, struct filter_option *userrule); -void filter_druid_set_default_html(FilterDruid *f, const char *text); - -/* set the page of display */ -void filter_druid_set_page(FilterDruid *f, enum FilterDruidPage page); -enum FilterDruidPage filter_druid_get_page(FilterDruid *f); - -/* check if the druid is allowed to finish at this point */ -gboolean filter_druid_can_finish(FilterDruid *f); - -#endif /* ! _FILTER_DRUID_H */ diff --git a/filter/filter-editor.c b/filter/filter-editor.c deleted file mode 100644 index 3bd239befa..0000000000 --- a/filter/filter-editor.c +++ /dev/null @@ -1,408 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Michael Zucchi <notzed@helixcode.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public License - * as published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include <gnome-xml/parser.h> -#include "filter-druid.h" -#include "filter-editor.h" - - -static void filter_editor_class_init (FilterEditorClass *klass); -static void filter_editor_init (FilterEditor *obj); - -static GnomeDialogClass *filter_editor_parent; - -#define _PRIVATE(x) (((FilterEditor *)(x))->priv) - -struct _FilterEditorPrivate { - FilterDruid *druid; - - GtkWidget *edit, *add, *remove, *up, *down; - - /* for sub-druid */ - struct filter_option *druid_option; - GtkWidget *druid_dialogue; - FilterDruid *druid_druid; -}; - -enum SIGNALS { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -guint -filter_editor_get_type (void) -{ - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "FilterEditor", - sizeof (FilterEditor), - sizeof (FilterEditorClass), - (GtkClassInitFunc) filter_editor_class_init, - (GtkObjectInitFunc) filter_editor_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - type = gtk_type_unique (gnome_dialog_get_type (), &type_info); - } - - return type; -} - -static void -object_destroy(GtkObject *obj) -{ - struct _FilterEditorPrivate *p = _PRIVATE(obj); - - if (p->druid_druid) - gtk_object_unref(GTK_OBJECT (p->druid_dialogue)); - - GTK_OBJECT_CLASS(filter_editor_parent)->destroy(GTK_OBJECT (obj)); -} - -static void -filter_editor_class_init (FilterEditorClass *klass) -{ - GtkObjectClass *object_class = (GtkObjectClass *) klass; - - filter_editor_parent = gtk_type_class (gnome_dialog_get_type ()); - - object_class->destroy = object_destroy; - - gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); -} - -static void -filter_editor_init (FilterEditor *obj) -{ - obj->priv = g_malloc0(sizeof(*obj->priv)); -} - - -static void -sensitise(FilterEditor *e) -{ - struct _FilterEditorPrivate *p = _PRIVATE(e); - - gtk_widget_set_sensitive(p->add, TRUE); - gtk_widget_set_sensitive(p->edit, e->option_current != NULL); - gtk_widget_set_sensitive(p->remove, e->option_current != NULL); - gtk_widget_set_sensitive(p->up, g_list_index(e->useroptions, e->option_current)>0); - gtk_widget_set_sensitive(p->down, g_list_index(e->useroptions, e->option_current)!=g_list_length(e->useroptions)-1); -} - -static void -druid_option_selected(FilterDruid *f, struct filter_option *option, FilterEditor *e) -{ - e->option_current = option; - sensitise(e); -} - -static void -druid_dialogue_clicked(GnomeDialog *d, int button, FilterEditor *e) -{ - struct _FilterEditorPrivate *p = _PRIVATE(e); - int page = filter_druid_get_page(p->druid_druid); - - switch(button) { - case 1: - if (page<4) { - page++; - } - break; - case 0: - if (page>0) { - page--; - } - break; - case 2: - if (p->druid_druid->option_current) { -#warning "what is going on here?" - /* FIXME: should this be struct filter_option?? */ - struct filter_option *or; - - printf("refcount = %d\n", ((GtkObject *)p->druid_druid)->ref_count); - - or = p->druid_druid->option_current; - if (p->druid_option) { - GList *node; - - node = g_list_find(e->useroptions, p->druid_option); - if (node) { - /* FIXME: free old one */ - /* we need to know what type or is supposed to be before - we can free old data */ - node->data = or; - } else { - g_warning("Cannot find node I edited, appending instead"); - e->useroptions = g_list_append(e->useroptions, or); - } - } else { - e->useroptions = g_list_append(e->useroptions, or); - } - filter_druid_set_rules(p->druid, e->useroptions, e->rules, or); - } - case 3: - p->druid_dialogue = NULL; - gnome_dialog_close(d); - return; - } - filter_druid_set_page(p->druid_druid, page); - - gnome_dialog_set_sensitive(GNOME_DIALOG (p->druid_dialogue), 0, page > 0); - gnome_dialog_set_sensitive(GNOME_DIALOG (p->druid_dialogue), 1, page < 4); - /* FIXME: make this depenedant on when the rules are actually done */ - gnome_dialog_set_sensitive(GNOME_DIALOG (p->druid_dialogue), 2, page == 4); -} - -static void -druid_dialogue_option_selected(FilterDruid *f, struct filter_option *option, FilterEditor *e) -{ - struct _FilterEditorPrivate *p = _PRIVATE(e); - - gnome_dialog_set_sensitive(GNOME_DIALOG (p->druid_dialogue), 1, TRUE); -} - -static void -add_or_edit(FilterEditor *e, struct filter_option *option) -{ - GnomeDialog *dialogue; - FilterDruid *druid; - struct _FilterEditorPrivate *p = _PRIVATE(e); - - if (p->druid_dialogue) { - gdk_window_raise(GTK_WIDGET(p->druid_dialogue)->window); - return; - } - - dialogue = GNOME_DIALOG (gnome_dialog_new (option ? _("Edit Filter") : _("Create filter"), NULL)); - p->druid_dialogue = GTK_WIDGET (dialogue); - { - const char *pixmaps[] = { - GNOME_STOCK_BUTTON_PREV, - GNOME_STOCK_BUTTON_NEXT, - GNOME_STOCK_BUTTON_APPLY, - GNOME_STOCK_BUTTON_CANCEL, - NULL - }; - const char *names[] = { - N_("Back"), - N_("Next"), - N_("Finish"), - N_("Cancel"), - NULL - }; - if (option) - names[2] = N_("Apply"); - gnome_dialog_append_buttons_with_pixmaps(dialogue, names, pixmaps); - } - - gnome_dialog_set_close(dialogue, FALSE); - gnome_dialog_set_sensitive(dialogue, 0, FALSE); - gnome_dialog_set_sensitive(dialogue, 1, FALSE); - gnome_dialog_set_sensitive(dialogue, 2, FALSE); - gnome_dialog_set_default(dialogue, 1); - - gtk_signal_connect(GTK_OBJECT (dialogue), "clicked", druid_dialogue_clicked, e); - - druid = FILTER_DRUID (filter_druid_new()); - - p->druid_druid = druid; - - filter_druid_set_default_html(p->druid_druid, - _("<h2>Create Filtering Rule</h2>" - "<p>Select one of the base rules above, then continue " - "forwards to customise it.</p>")); - - filter_druid_set_rules(druid, e->systemoptions, e->rules, option); - gtk_box_pack_start(GTK_BOX (dialogue->vbox), GTK_WIDGET (druid), TRUE, TRUE, 0); - - if (option) { - druid_dialogue_clicked(dialogue, 1, e); - } - - p->druid_option = option; - - gtk_signal_connect(GTK_OBJECT (druid), "option_selected", druid_dialogue_option_selected, e); - - gtk_widget_show(GTK_WIDGET (druid)); - gtk_widget_show(GTK_WIDGET (dialogue)); -} - -static void -add_clicked(GtkWidget *w, FilterEditor *e) -{ - add_or_edit(e, NULL); -} - -static void -edit_clicked(GtkWidget *w, FilterEditor *e) -{ - add_or_edit(e, e->option_current); -} - -static void -remove_clicked(GtkWidget *w, FilterEditor *e) -{ - printf("remove current ...\n"); -} - -static void -up_clicked(GtkWidget *w, FilterEditor *e) -{ - printf("up ...\n"); -} - -static void -down_clicked(GtkWidget *w, FilterEditor *e) -{ - printf("down ...\n"); -} - -/* build the contents of the editor */ -static void -build_editor(FilterEditor *e) -{ - struct _FilterEditorPrivate *p = _PRIVATE(e); - GtkWidget *hbox; - GtkWidget *vbox; - - hbox = gtk_hbox_new(FALSE, 3); - - p->druid = FILTER_DRUID (filter_druid_new()); - gtk_box_pack_start(GTK_BOX (hbox), GTK_WIDGET (p->druid), TRUE, TRUE, 0); - - vbox = gtk_vbox_new(FALSE, 0); - - p->edit = gtk_button_new_with_label ("Edit"); - p->add = gtk_button_new_with_label ("Add"); - p->remove = gtk_button_new_with_label ("Remove"); - p->up = gtk_button_new_with_label ("Up"); - p->down = gtk_button_new_with_label ("Down"); - - gtk_box_pack_start(GTK_BOX (vbox), p->edit, FALSE, TRUE, 0); - gtk_box_pack_start(GTK_BOX (vbox), p->add, FALSE, TRUE, 3); - gtk_box_pack_start(GTK_BOX (vbox), p->remove, FALSE, TRUE, 0); - gtk_box_pack_start(GTK_BOX (vbox), p->up, FALSE, TRUE, 3); - gtk_box_pack_start(GTK_BOX (vbox), p->down, FALSE, TRUE, 0); - - gtk_box_pack_start(GTK_BOX (hbox), vbox, FALSE, FALSE, 0); - - gtk_box_pack_start(GTK_BOX (e->parent.vbox), hbox, TRUE, TRUE, 0); - - gtk_signal_connect(GTK_OBJECT (p->druid), "option_selected", druid_option_selected, e); - - gtk_signal_connect(GTK_OBJECT (p->edit), "clicked", edit_clicked, e); - gtk_signal_connect(GTK_OBJECT (p->add), "clicked", add_clicked, e); - gtk_signal_connect(GTK_OBJECT (p->remove), "clicked", remove_clicked, e); - gtk_signal_connect(GTK_OBJECT (p->up), "clicked", up_clicked, e); - gtk_signal_connect(GTK_OBJECT (p->down), "clicked", down_clicked, e); - - filter_druid_set_default_html(p->druid, "<h2>Filtering Rules</h2>" - "<p>Select one of the rules above to <i>view</i>, and " - "<i>edit</i>. Or <i>Add</i> a new rule.</p>"); - - gtk_widget_show_all(hbox); - sensitise(e); -} - - -/** - * filter_editor_new: - * - * Create a new FilterEditor object. - * - * Return value: A new FilterEditor widget. - **/ -FilterEditor * -filter_editor_new (void) -{ - FilterEditor *new = FILTER_EDITOR ( gtk_type_new (filter_editor_get_type ())); - - build_editor(new); - - return new; -} - -void -filter_editor_set_rules(FilterEditor *e, GList *rules, GList *systemoptions, GList *useroptions) -{ - struct _FilterEditorPrivate *p = _PRIVATE(e); - - e->rules= rules; - e->systemoptions = systemoptions; - e->useroptions = useroptions; - - filter_druid_set_rules(p->druid, useroptions, rules, NULL); -} - -void -filter_editor_set_rule_files(FilterEditor *e, const char *systemrules, const char *userrules) -{ - GList *rules, *options = NULL, *options2; - xmlDocPtr doc, out; - - doc = xmlParseFile(systemrules); - if( doc == NULL ) { - g_warning( "Couldn't load system rules file %s", systemrules ); - rules = NULL; - options2 = NULL; - } else { - rules = filter_load_ruleset(doc); - options2 = filter_load_optionset(doc, rules); - } - - out = xmlParseFile(userrules); - if (out) - options = filter_load_optionset(out, rules); - - filter_editor_set_rules(e, rules, options2, options); -} - -int -filter_editor_save_rules(FilterEditor *e, const char *userrules) -{ - return filter_write_optionset_file(userrules, e->useroptions); -} - -#ifdef STANDALONE - -int main(int argc, char **argv) -{ - FilterEditor *fe; - - gnome_init("Test", "0.0", argc, argv); - gdk_rgb_init (); - gtk_widget_set_default_colormap (gdk_rgb_get_cmap ()); - gtk_widget_set_default_visual (gdk_rgb_get_visual ()); - - fe = filter_editor_new(); - filter_editor_set_rule_files(fe, "/home/notzed/gnome/evolution/filter/filterdescription.xml", "/home/notzed/filters.xml"); - gtk_widget_show(fe); - - gtk_main(); - - return 0; -} - -#endif diff --git a/filter/filter-editor.h b/filter/filter-editor.h deleted file mode 100644 index 66f7a81e11..0000000000 --- a/filter/filter-editor.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Michael Zucchi <notzed@helixcode.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public License - * as published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef _FILTER_EDITOR_H -#define _FILTER_EDITOR_H - -#include <gtk/gtk.h> -#include <gnome.h> -#include "filter-xml.h" - -#define FILTER_EDITOR(obj) GTK_CHECK_CAST (obj, filter_editor_get_type (), FilterEditor) -#define FILTER_EDITOR_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, filter_editor_get_type (), FilterEditorClass) -#define IS_FILTER_EDITOR(obj) GTK_CHECK_TYPE (obj, filter_editor_get_type ()) - -typedef struct _FilterEditor FilterEditor; -typedef struct _FilterEditorClass FilterEditorClass; - -struct _FilterEditor { - GnomeDialog parent; - - struct _FilterEditorPrivate *priv; - - GList *rules; - GList *systemoptions; - GList *useroptions; - - struct filter_option *option_current; -}; - -struct _FilterEditorClass { - GnomeDialogClass parent_class; -}; - -guint filter_editor_get_type (void); -FilterEditor *filter_editor_new (void); - -void filter_editor_set_rules(FilterEditor *e, GList *rules, GList *systemoptions, GList *useroptions); -void filter_editor_set_rule_files(FilterEditor *e, const char *systemrules, const char *userrules); -int filter_editor_save_rules(FilterEditor *e, const char *userrules); - -#endif /* ! _FILTER_EDITOR_H */ diff --git a/filter/filter-format.c b/filter/filter-format.c deleted file mode 100644 index b7a2a956be..0000000000 --- a/filter/filter-format.c +++ /dev/null @@ -1,237 +0,0 @@ -/* -*- Mode: C; c-file-style: "linux"; indent-tabs-mode: t; c-basic-offset: 8; -*- */ - -#include <glib.h> -#include <gtk/gtk.h> -#include <gnome.h> -#include <gtkhtml/gtkhtml.h> - -#include <gnome-xml/tree.h> -#include <gnome-xml/parser.h> - -#include "filter-arg-types.h" -#include "filter-xml.h" - -#define d(x) - -/* FIXME: remove static, this is defined in filter-xml */ -static int -filter_find_rule(struct filter_rule *a, char *name) -{ - d(printf("finding, is %s = %s?\n", a->name, name)); - return strcmp(a->name, name); -} - -static int -filter_find_arg(FilterArg *a, char *name) -{ - d(printf("finding, is %s = %s?\n", a->name, name)); - return strcmp(a->name, name); -} - -static int display_order[] = { FILTER_XML_MATCH, FILTER_XML_ACTION, FILTER_XML_EXCEPT }; - -static struct filter_option * -option_clone(struct filter_option *source) -{ - struct filter_option *dest = g_malloc0(sizeof(*dest)); - GList *loptions; - struct filter_optionrule *old, *new; - - dest->type = source->type; - dest->description = source->description; - loptions = dest->options; - while (loptions) { - old = loptions->data; - new = g_malloc0(sizeof(*new)); - new->rule = old->rule; - /* FIXME: need to copy any args as well!!! */ - dest->options = g_list_append(dest->options, new); - loptions = g_list_next(loptions); - } - return dest; -} - - - -struct description_decode_lambda { - GString *str; - GList *args; - GtkHTML *html; - GtkHTMLStream *stream; -}; - -static char * -arg_text(FilterArg *arg) -{ - char *out = NULL; - GList *value, *next; - GString *str; - - value = arg->values; - - d(printf("getting text from arg %s\n", arg->name)); - - if (value == NULL) - return NULL; - - str = g_string_new(""); - filter_arg_write_text(arg, str); - out = str->str; - g_string_free(str, FALSE); - return out; -} - -static void -description_decode_text(struct filter_desc *d, struct description_decode_lambda *l) -{ - GList *list; - char *txt; - - switch (d->type) { - case FILTER_XML_TEXT: - case FILTER_XML_DESC: - dotext: - d(printf("appending '%s'\n", d->data)); - /* printf("vartype = %s\n", detokenise(d->vartype)); */ - d(printf("varname = %s\n", d->varname)); - if (d->vartype !=-1 && d->varname - && (list = g_list_find_custom(l->args, d->varname, (GCompareFunc) filter_find_arg)) - && (txt = arg_text(list->data))) { - } else { - txt = d->data; - } - g_string_append(l->str, txt); - break; - default: - printf("WARN: unknown desc text type '%d' = %s\n", d->type, d->data); - goto dotext; - } -} - -char * -filter_description_text(GList *description, GList *args) -{ - char *txt; - struct description_decode_lambda l; - - d(printf("\ndecoding ...\n")); - - l.str = g_string_new(""); - l.args = args; - g_list_foreach(description, (GFunc) description_decode_text, &l); - - d(printf("string is '%s'\n", l.str->str)); - - txt = l.str->str; - g_string_free(l.str, FALSE); - - return txt; -} - -static void -html_write(GtkHTML *html, GtkHTMLStream *stream, char *s) -{ - d(printf("appending html '%s'\n", s)); - gtk_html_write(html, stream, s, strlen(s)); -} - - -static void -description_decode_html(struct filter_desc *d, struct description_decode_lambda *l) -{ - GList *list; - char *txt, *end; - int free; - - switch (d->type) { - case FILTER_XML_TEXT: - case FILTER_XML_DESC: - dotext: - d(printf("appending '%s'\n", d->data)); - /*printf("vartype = %s\n", detokenise(d->vartype));*/ - d(printf("varname = %s\n", d->varname)); - free = FALSE; - if (d->vartype !=-1 && d->varname) { - char *link; - list = g_list_find_custom(l->args, d->varname, (GCompareFunc) filter_find_arg); - end = "</a>"; - if (list) { - txt = arg_text(list->data); - if (txt == NULL) - txt = d->data; - else - free = TRUE; - link = g_strdup_printf("<a href=\"arg:%p %p\">", d, list->data); - } else { - printf("cannot find arg '%s'\n", d->varname); - link = g_strdup_printf("<a href=\"arg:%p %p\">", d, NULL); - txt = d->data; - } - html_write(l->html, l->stream, link); - g_free(link); - } else { - txt = d->data; - end = NULL; - } - html_write(l->html, l->stream, txt); - if (end) { - html_write(l->html, l->stream, end); - } - if (free) - g_free(txt); - break; - default: - /*printf("WARN: unknown desc text type '%s' = %s\n", detokenise(d->type), d->data);*/ - goto dotext; - } -} - -void -filter_description_html_write(GList *description, GList *args, GtkHTML *html, GtkHTMLStream *stream) -{ - char *txt; - struct description_decode_lambda l; - - d(printf("\ndecoding ...\n")); - - l.str = NULL; - l.args = args; - l.html = html; - l.stream = stream; - g_list_foreach(description, (GFunc) description_decode_html, &l); -} - -#ifdef TESTER -int main(int argc, char **argv) -{ - GList *rules, *options; - xmlDocPtr doc, out, optionset, filteroptions; - - gnome_init("Test", "0.0", argc, argv); - - doc = xmlParseFile("filterdescription.xml"); - - rules = load_ruleset(doc); - options = load_optionset(doc, rules); - - out = xmlParseFile("saveoptions.xml"); - options = load_optionset(doc, rules); - - while (options) { - printf("applying a rule ...\n"); - filterme(options->data); - options = g_list_next(options); - } - -#if 0 - out = xmlNewDoc("1.0"); - optionset = save_optionset(out, options); - filteroptions = xmlNewDocNode(out, NULL, "filteroptions", NULL); - xmlAddChild(filteroptions, optionset); - xmlDocSetRootElement(out, filteroptions); - xmlSaveFile("saveoptions.xml", out); -#endif - return 0; -} -#endif - diff --git a/filter/filter-format.h b/filter/filter-format.h deleted file mode 100644 index 82c5d9fb13..0000000000 --- a/filter/filter-format.h +++ /dev/null @@ -1,11 +0,0 @@ - -#ifndef _FILTER_FORMAT_H -#define _FILTER_FORMAT_H - -#include <glib.h> - -char *filter_description_text(GList *description, GList *args); -void filter_description_html_write(GList *description, GList *args, - GtkHTML *html, GtkHTMLStream *stream); - -#endif /* _FILTER_FORMAT_H */ diff --git a/filter/filter-xml.c b/filter/filter-xml.c deleted file mode 100644 index ca95112127..0000000000 --- a/filter/filter-xml.c +++ /dev/null @@ -1,584 +0,0 @@ -/* -*- Mode: C; c-file-style: "linux"; indent-tabs-mode: t; c-basic-offset: 8; -*- */ - -/* Load save filter descriptions/options from an xml file */ - -#include <glib.h> -#include <gtk/gtk.h> -#include <gnome.h> -#include <gtkhtml/gtkhtml.h> - -#include <gnome-xml/tree.h> -#include <gnome-xml/parser.h> - -#include "filter-arg-types.h" -#include "filter-xml.h" - -#define d(x) - -struct token_tab { - char *name; - enum filter_xml_token token; -}; - -struct token_tab token_table[] = { - { "action", FILTER_XML_ACTION }, - { "address", FILTER_XML_ADDRESS }, - { "code", FILTER_XML_CODE }, - { "description", FILTER_XML_DESC }, - { "except", FILTER_XML_EXCEPT }, - { "folder", FILTER_XML_FOLDER }, - { "match", FILTER_XML_MATCH }, - { "name", FILTER_XML_NAME }, - { "option", FILTER_XML_OPTION }, - { "optionrule", FILTER_XML_OPTIONRULE }, - { "optionset", FILTER_XML_OPTIONSET }, - { "optionvalue", FILTER_XML_OPTIONVALUE }, - { "receive", FILTER_XML_RECEIVE }, - { "rule", FILTER_XML_RULE }, - { "ruleset", FILTER_XML_RULESET }, - { "send", FILTER_XML_SEND }, - { "source", FILTER_XML_SOURCE }, - { "text", FILTER_XML_TEXT }, -}; - -/* convert a name to a token value */ -static int -tokenise(const char *name) -{ - int i; - int len = sizeof(token_table)/sizeof(token_table[0]); - - if (name) { - for (i=0;i<len;i++) { - if (strcmp(name, token_table[i].name) == 0) - return token_table[i].token; - } - } - return -1; -} - -static int -tokenise_xmlfreeprop(char *name) -{ - int ret = -1; - ret = tokenise(name); - free(name); - return ret; -} - -static char * -detokenise(int token) -{ - int i; - int len = sizeof(token_table)/sizeof(token_table[0]); - - if (token>=0) { - for (i=0;i<len;i++) { - if (token_table[i].token == token) - return token_table[i].name; - } - } - return "<unknown>"; -} - - -static xmlNodePtr -find_node(xmlNodePtr start, char *name) -{ - d(printf("trying to find node '%s'\n", name)); - while (start && strcmp(start->name, name)) - start = start->next; - d(printf("node = %p\n", start)); - return start; -} - -static xmlNodePtr -find_node_attr(xmlNodePtr start, char *name, char *attrname, char *attrvalue) -{ - char *s; - - d(printf("looking for node named %s with attribute %s=%s\n", name, attrname, attrvalue)); - - while ( start && (start = find_node(start, name)) ) { - s = xmlGetProp(start, attrname); - d(printf(" comparing '%s' to '%s'\n", s, attrvalue)); - if (s && !strcmp(s, attrvalue)) { - free(s); - break; - } - free(s); - start = start->next; - } - return start; -} - -static GList * -load_desc(xmlNodePtr node, int type, int vartype, char *varname) -{ - struct filter_desc *desc; - xmlNodePtr n; - int newtype; - int newvartype; - char *newvarname; - GList *list = NULL; - - while (node) { - if (node->content) { - desc = g_malloc0(sizeof(*desc)); - desc->data = g_strdup (node->content); - desc->type = type; - desc->vartype = vartype; - desc->varname = g_strdup(varname); - d(printf(" **** node name = %s var name = %s var type = %s\n", node->name, varname, detokenise(vartype))); - list = g_list_append(list, desc); - d(printf("appending '%s'\n", node->content)); - newtype = type; - newvartype = -1; - newvarname = NULL; - } else { - newtype = tokenise(node->name); - newvartype = tokenise_xmlfreeprop(xmlGetProp(node, "type")); - newvarname = xmlGetProp(node, "name"); - } - n = node->childs; - while (n) { - d(printf("adding child '%s'\n", n->name)); - list = g_list_concat(list, load_desc(n, newtype, newvartype, newvarname)); - n = n->next; - } - if (newvarname) - free(newvarname); - node = node->next; - } - return list; -} - -GList * -filter_load_ruleset(xmlDocPtr doc) -{ - xmlNodePtr ruleset, rule, n; - struct filter_rule *r; - int type; - int ruletype; - GList *rules = NULL; - - g_return_val_if_fail(doc!=NULL, NULL); - - ruleset = find_node(doc->root->childs, "ruleset"); - - while (ruleset) { - - rule = ruleset->childs; - - ruletype = tokenise_xmlfreeprop(xmlGetProp(ruleset, "type")); - - d(printf("ruleset, name = %s\n", ruleset->name)); - - while (rule) { - - n = rule->childs; - r = g_malloc0(sizeof(*r)); - r->type = ruletype; - r->name = xmlGetProp(rule, "name"); - - d(printf(" rule, name = %s\n", r->name)); - - while (n) { - type = tokenise(n->name); - d(printf(" n, name = %s\n", n->name)); - d(printf(" ncontent = %s\n", n->content)); - d(printf(" childs = %p\n", n->childs)); - if (n->childs) { - d(printf(" childs content = %s\n", n->childs->content)); - } - switch(type) { - case FILTER_XML_CODE: - r->code = xmlNodeGetContent(n); - break; - case FILTER_XML_DESC: - d(printf(" ** loading description\n")); - r->description = load_desc(n->childs, type, -1, NULL); - d(printf(" ** done loading description\n")); - break; - default: - printf("warning, unknown token encountered\n"); - break; - } - n = n->next; - } - if (r) - rules = g_list_append(rules, r); - rule = rule->next; - } - ruleset = find_node(ruleset->next, "ruleset"); - } - return rules; -} - -int -filter_find_rule(struct filter_rule *a, char *name) -{ - d(printf("finding, is %s = %s?\n", a->name, name)); - return strcmp(a->name, name); -} - -int -filter_find_arg(FilterArg *a, char *name) -{ - d(printf("finding, is %s = %s?\n", a->name, name)); - return strcmp(a->name, name); -} - -static FilterArg * -load_optionvalue(struct filter_desc *desc, xmlNodePtr node) -{ - FilterArg *arg = NULL; - - d(printf("creating arg entry for '%s'\n", desc->varname)); - - switch(desc->vartype) { - case FILTER_XML_ADDRESS: - arg = filter_arg_address_new(desc->varname); - break; - case FILTER_XML_FOLDER: - arg = filter_arg_folder_new(desc->varname); - break; - default: - d(printf("ok, maybe we're not\n")); - /* unknown arg type, drop it */ - return NULL; - } - - if (node == NULL) - return arg; - - filter_arg_values_add_xml(arg, node); - - return arg; -} - -GList * -filter_load_optionset(xmlDocPtr doc, GList *rules) -{ - xmlNodePtr optionset, option, o, or; - struct filter_option *op; - struct filter_optionrule *optionrule; - struct filter_rule *fr; - struct filter_desc *desc; - int type; - GList *l = NULL; - GList *lrule; - GList *ldesc; - - g_return_val_if_fail(doc!=NULL, NULL); - - optionset = find_node(doc->root->childs, "optionset"); - if (optionset == NULL) { - printf("optionset not found\n"); - return NULL; - } - option = find_node(optionset->childs, "option"); - while (option) { - o = option->childs; - op = g_malloc0(sizeof(*op)); - d(printf("option = %s\n", o->name)); - d(printf("option, type=%s\n", xmlGetProp(option, "type"))); - op->type = tokenise_xmlfreeprop(xmlGetProp(option, "type")); - while (o) { - char *rulestr; - - type = tokenise(o->name); - switch (type) { - case FILTER_XML_OPTIONRULE: - rulestr = xmlGetProp(o, "rule"); - lrule = g_list_find_custom(rules, rulestr, (GCompareFunc) filter_find_rule); - if (lrule) { - fr = lrule->data; - d(printf("found rule : %s\n", fr->name)); - optionrule = g_malloc0(sizeof(*optionrule)); - optionrule->rule = fr; - op->options = g_list_append(op->options, optionrule); - - /* scan through all variables required, setup blank variables if they do not exist */ - ldesc = fr->description; - while (ldesc) { - desc = ldesc->data; - if (desc->varname && desc->vartype!=-1) { - FilterArg *arg; - /* try and see if there is a setting for this value */ - or = find_node_attr(o->childs, "optionvalue", "name", desc->varname); - arg = load_optionvalue(desc, or); - if (arg) { - optionrule->args = g_list_append(optionrule->args, arg); - d(printf("Adding arg %s\n", arg->name)); - } - } - ldesc = g_list_next(ldesc); - } - } else { - /* FIXME: memleak */ - printf("Cannot find rule: %s\n", rulestr); - } - free(rulestr); - break; - case FILTER_XML_DESC: - d(printf("loading option descriptiong\n")); - op->description = load_desc(option->childs, type, -1, NULL); - break; - } - o = o->next; - } - l = g_list_append(l, op); - option = find_node(option->next, "option"); - } - return l; -} - -static xmlNodePtr -write_description(xmlDocPtr doc, GList *descl) -{ - xmlNodePtr d; - struct filter_desc *desc; - - desc = descl->data; - d = xmlNewDocNode(doc, NULL, "description", NULL); - xmlNodeSetContent(d, desc->data); - return d; -} - -xmlNodePtr -filter_write_optionset(xmlDocPtr doc, GList *optionl) -{ - xmlNodePtr root, option, optionrule, optionvalue; - GList *optionrulel, *argl; - struct filter_optionrule *or; - - root = xmlNewDocNode(doc, NULL, "optionset", NULL); - - /* for all options */ - while (optionl) { - struct filter_option *op = optionl->data; - - option = xmlNewDocNode(doc, NULL, "option", NULL); - xmlSetProp(option, "type", detokenise(op->type)); - - if (op->description) { - xmlNodePtr desc; - - desc = write_description(doc, op->description); - xmlAddChild(option, desc); - } - - optionrulel = op->options; - while (optionrulel) { - or = optionrulel->data; - - optionrule = xmlNewDocNode(doc, NULL, "optionrule", NULL); - xmlSetProp(optionrule, "type", detokenise(or->rule->type)); - xmlSetProp(optionrule, "rule", or->rule->name); - - argl = or->args; - while (argl) { - FilterArg *arg = argl->data; - - optionvalue = filter_arg_values_get_xml(arg); - if (optionvalue) - xmlAddChild(optionrule, optionvalue); - - argl = g_list_next(argl); - } - - xmlAddChild(option, optionrule); - - optionrulel = g_list_next(optionrulel); - } - - xmlAddChild(root, option); - optionl = g_list_next(optionl); - } - - return root; -} - -/* utility functions */ -struct filter_optionrule * -filter_clone_optionrule(struct filter_optionrule *or) -{ - GList *arg; - struct filter_optionrule *rule; - - rule = g_malloc0(sizeof(*rule)); - - rule->rule = or->rule; - arg = or->args; - while (arg) { - FilterArg *new = filter_arg_clone(FILTER_ARG(arg->data)); - gtk_object_set_data((GtkObject *)new, "origin", arg->data); - rule->args = g_list_append(rule->args, new); - arg = g_list_next(arg); - } - return rule; -} - -void -filter_clone_optionrule_free(struct filter_optionrule *or) -{ - GList *argl; - - d(printf("---- free optionrule\n")); - - argl = or->args; - while (argl) { - gtk_object_unref(GTK_OBJECT(argl->data)); - argl = g_list_next(argl); - } - g_list_free(or->args); - g_free(or); -} - -struct filter_optionrule * -filter_optionrule_new_from_rule(struct filter_rule *rule) -{ - struct filter_optionrule *or; - GList *descl; - - or = g_malloc0(sizeof(*or)); - - or->rule = rule; - - descl = rule->description; - while (descl) { - struct filter_desc *desc = descl->data; - if (desc->varname && desc->vartype != -1) { - FilterArg *arg = NULL; - switch (desc->vartype) { - case FILTER_XML_ADDRESS: - arg = filter_arg_address_new(desc->varname); - break; - case FILTER_XML_FOLDER: - arg = filter_arg_folder_new(desc->varname); - break; - } - if (arg) { - or->args = g_list_append(or->args, arg); - } - } - descl = g_list_next(descl); - } - return or; -} - -void -filter_description_free(GList *descl) -{ - GList *node; - - node = descl; - while (node) { - GList *next = g_list_next(node); - struct filter_desc *d = node->data; - - g_free(d->data); - g_free(d->varname); - g_free(d); - - node = next; - } - g_list_free(descl); -} - -void -filter_load_ruleset_free(GList *nodel) -{ - GList *node = nodel; - - while (node) { - GList *next = g_list_next(node); - struct filter_rule *r = node->data; - - filter_description_free(r->description); - - /* g_free(r->name); */ - /* g_free(r->code); */ - - g_free(r); - node = next; - } - g_list_free(nodel); -} - -void -filter_load_optionset_free(GList *optionl) -{ - GList *option = optionl; - while (option) { - GList *next = g_list_next(option); - struct filter_option *fo = option->data; - GList *optionrule = fo->options; - - while (optionrule) { - GList *next = g_list_next(optionrule); - struct filter_optionrule *or = optionrule->data; - GList *arg = or->args; - - while (arg) { - gtk_object_unref(arg->data); - arg = g_list_next(arg); - } - - g_list_free(or->args); - g_free(or); - optionrule = next; - } - filter_description_free(fo->description); - g_list_free(fo->options); - g_free(fo); - option = next; - } -} - -GList *filter_load_ruleset_file(const char *name) -{ - xmlDocPtr doc; - GList *rules; - - doc = xmlParseFile(name); - rules = filter_load_ruleset(doc); - xmlFreeDoc(doc); - - return rules; -} - -GList *filter_load_optionset_file(const char *name, GList *rules) -{ - xmlDocPtr doc; - GList *options; - - doc = xmlParseFile(name); - if( doc == NULL ) { - g_warning( "Couldn't load option file %s!", name ); - return NULL; - } - options = filter_load_optionset(doc, rules); - xmlFreeDoc(doc); - - return options; -} - -int filter_write_optionset_file(const char *name, GList *optionl) -{ - xmlDocPtr out; - xmlDocPtr optionset; - xmlNodePtr filteroptions; - int ret; - - out = xmlNewDoc("1.0"); - optionset = filter_write_optionset(out, optionl); - filteroptions = xmlNewDocNode(out, NULL, "filteroptions", NULL); - xmlAddChild(filteroptions, optionset); - xmlDocSetRootElement(out, filteroptions); - ret = xmlSaveFile(name, out); - xmlFreeDoc(out); - - return ret; -} diff --git a/filter/filter-xml.h b/filter/filter-xml.h deleted file mode 100644 index ce8a5ffc3a..0000000000 --- a/filter/filter-xml.h +++ /dev/null @@ -1,77 +0,0 @@ - -#ifndef _FILTER_XML_H -#define _FILTER_XML_H - -#include <glib.h> -#include <gnome-xml/tree.h> - -#include "filter-arg.h" - -enum filter_xml_token { - FILTER_XML_TEXT=0, - FILTER_XML_RULE, - FILTER_XML_CODE, - FILTER_XML_DESC, - FILTER_XML_RULESET, - FILTER_XML_OPTION, - FILTER_XML_OPTIONRULE, - FILTER_XML_OPTIONSET, - FILTER_XML_OPTIONVALUE, - FILTER_XML_SOURCE, - FILTER_XML_SEND, - FILTER_XML_RECEIVE, - FILTER_XML_ADDRESS, - FILTER_XML_FOLDER, - FILTER_XML_NAME, - FILTER_XML_MATCH, - FILTER_XML_ACTION, - FILTER_XML_EXCEPT -}; - -struct filter_desc { - int type; - char *data; - char *varname; /* for named types */ - int vartype; -}; - -struct filter_rule { - int type; - char *name; - char *code; - GList *description; -}; - -struct filter_optionrule { - struct filter_rule *rule; - GList *args; /* FilterArg objects */ -}; - -struct filter_option { - int type; /* 'send' 'receive'? */ - GList *description; /* filter_desc */ - GList *options; /* option_rule */ -}; - -GList *filter_load_ruleset(xmlDocPtr doc); -GList *filter_load_optionset(xmlDocPtr doc, GList *rules); -xmlNodePtr filter_write_optionset(xmlDocPtr doc, GList *optionl); - -void filter_description_free(GList *descl); -void filter_load_ruleset_free(GList *nodel); -void filter_load_optionset_free(GList *optionl); - -GList *filter_load_ruleset_file(const char *name); -GList *filter_load_optionset_file(const char *name, GList *rules); -int filter_write_optionset_file(const char *name, GList *optionl); - -/* callbacks for searching GLists of various types */ -int filter_find_rule(struct filter_rule *a, char *name); -int filter_find_arg(FilterArg *a, char *name); - -/* utility functions */ -struct filter_optionrule *filter_clone_optionrule(struct filter_optionrule *or); -void filter_clone_optionrule_free(struct filter_optionrule *or); -struct filter_optionrule *filter_optionrule_new_from_rule(struct filter_rule *rule); - -#endif /* ! _FILTER_XML_H */ diff --git a/filter/filtertypes.xml b/filter/filtertypes.xml deleted file mode 100644 index dcba45dc00..0000000000 --- a/filter/filtertypes.xml +++ /dev/null @@ -1,110 +0,0 @@ -<?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 (or (header-contains "To" ${recipient}) - (header-contains "Cc" ${recipient}))) - </code> - <description lang="en">The To or Cc address matches <source type="address" name="recipient">recipients</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="body-contains"> - <code> - (match-all (body-contains ${words})) - </code> - <description lang="en">The body 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> - -<rule name="msg-size"> - <code> - (& (> message-size (size-lower size-range)) - (< message-size (size-uppwer size-range))) - </code> - <description lang="en">The message is a <source type="size-range" name="size">certain size</source>.</description> -</rule> -</ruleset> - -<ruleset type="action"> -<rule name="copy-me"> - <code> - (copy-to ${folder}) - </code> - <description language="en">Send a copy to <source type="folder" name="folder">folder</source>.</description> -</rule> -<rule name="forward"> - <code> - (forward-to ${address}) - </code> - <description language="en">Forward the message to <source type="address" name="address">people</source>.</description> -</rule> -<rule name="delete"> - <code> - (delete) - </code> - <description language="en">Delete message.</description> -</rule> -<rule name="stop"> - <code> - (stop) - </code> - <description language="en">Stop processing further rules for this message.</description> -</rule> -</ruleset> - -<ruleset type="except"> -<rule name="except-me"> - <code> - (match-all (not (header-contains "To" ${self-email}))) - </code> - <description language="en">When I am the recipient.</description> -</rule> - -<rule name="not-body-contains"> - <code> - (match-all (not (body-contains ${words}))) - </code> - <description lang="en">The body does not contain <source type="folder" name="words">words</source>.</description> -</rule> - -</ruleset> - -<optionset> - <option type="receive"> - <description language="en">When a message arrives.</description> - </option> - <option type="send"> - <description language="en">When a message is sent.</description> - </option> - <option type="receive"> - <description language="en">Copy incoming messages from a certain address to specific folder.</description> - <optionrule type="match" rule="from-address"/> - <optionrule type="action" rule="copy-me"/> - </option> - <option type="send"> - <description language="en">Copy sent messages to a specific folder.</description> - <optionrule type="action" rule="copy-me"/> - </option> -</optionset> -</filterdescription> diff --git a/filter/vfoldertypes.xml b/filter/vfoldertypes.xml deleted file mode 100644 index 13e2ebd96a..0000000000 --- a/filter/vfoldertypes.xml +++ /dev/null @@ -1,78 +0,0 @@ -<?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" ${recipient})) - </code> - <description lang="en">The To address matches <source type="address" name="recipient">recipients</source>.</description> -</rule> -<rule name="cc-address-other"> - <code> - (match-all (header-contains "CC" ${recipient})) - </code> - <description lang="en">The Cc address matches <source type="address" name="recipient">recipients</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="body-contains"> - <code> - (match-all (body-contains ${words})) - </code> - <description lang="en">The body 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 recipient.</description> -</rule> -<rule name="not-body-contains"> - <code> - (match-all (not (body-contains ${words}))) - </code> - <description lang="en">The body does not contain <source type="folder" name="words">words</source>.</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> |