Fix FSF address (Tobias Mueller, #470445)
[platform/upstream/evolution-data-server.git] / camel / camel-filter-driver.h
1 /*
2  *  Copyright (C) 2000 Ximian Inc.
3  *
4  *  Authors: Michael Zucchi <notzed@ximian.com>
5  *           Jeffrey Stedfast <fejj@ximian.com>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of version 2 of the GNU Lesser General Public
9  * License as published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this program; if not, write to the
18  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21
22 #ifndef _CAMEL_FILTER_DRIVER_H
23 #define _CAMEL_FILTER_DRIVER_H
24
25 #include <glib.h>
26 #include <camel/camel-object.h>
27 #include <camel/camel-session.h>
28 #include <camel/camel-folder.h>
29 #include <camel/camel-uid-cache.h>
30
31 #define CAMEL_FILTER_DRIVER_TYPE         (camel_filter_driver_get_type ())
32 #define CAMEL_FILTER_DRIVER(obj)         CAMEL_CHECK_CAST (obj, CAMEL_FILTER_DRIVER_TYPE, CamelFilterDriver)
33 #define CAMEL_FILTER_DRIVER_CLASS(klass) CAMEL__CHECK_CLASS_CAST (klass, CAMEL_FILTER_DRIVER_TYPE, CamelFilterDriverClass)
34 #define CAMEL_IS_FILTER_DRIVER(obj)      CAMEL_CHECK_TYPE (obj, CAMEL_FILTER_DRIVER_TYPE)
35
36 G_BEGIN_DECLS
37
38 typedef struct _CamelFilterDriverClass CamelFilterDriverClass;
39
40 struct _CamelFilterDriver {
41         CamelObject parent;
42         
43         struct _CamelFilterDriverPrivate *priv;
44 };
45
46 struct _CamelFilterDriverClass {
47         CamelObjectClass parent_class;
48 };
49
50 /* FIXME: this maybe should change... */
51 /* type of status for a status report */
52 enum camel_filter_status_t {
53         CAMEL_FILTER_STATUS_NONE,
54         CAMEL_FILTER_STATUS_START,      /* start of new message processed */
55         CAMEL_FILTER_STATUS_ACTION,     /* an action performed */
56         CAMEL_FILTER_STATUS_PROGRESS,   /* (an) extra update(s), if its taking longer to process */
57         CAMEL_FILTER_STATUS_END,        /* end of message */
58 };
59
60 typedef CamelFolder * (*CamelFilterGetFolderFunc) (CamelFilterDriver *driver, const char *uri,
61                                                    void *data, CamelException *ex);
62 /* report status */
63 typedef void (CamelFilterStatusFunc) (CamelFilterDriver *driver, enum camel_filter_status_t status,
64                                       int pc, const char *desc, void *data);
65
66 typedef void (CamelFilterShellFunc)      (CamelFilterDriver *driver, int argc, char **argv, void *data);
67 typedef void (CamelFilterPlaySoundFunc)  (CamelFilterDriver *driver, const char *filename, void *data);
68 typedef void (CamelFilterSystemBeepFunc) (CamelFilterDriver *driver, void *data);
69
70 CamelType          camel_filter_driver_get_type (void);
71 CamelFilterDriver  *camel_filter_driver_new     (CamelSession *);
72
73 /* modifiers */
74 void camel_filter_driver_set_logfile          (CamelFilterDriver *d, FILE *logfile);
75
76 void camel_filter_driver_set_status_func      (CamelFilterDriver *d, CamelFilterStatusFunc *func, void *data);
77 void camel_filter_driver_set_shell_func       (CamelFilterDriver *d, CamelFilterShellFunc *func, void *data);
78 void camel_filter_driver_set_play_sound_func  (CamelFilterDriver *d, CamelFilterPlaySoundFunc *func, void *data);
79 void camel_filter_driver_set_system_beep_func (CamelFilterDriver *d, CamelFilterSystemBeepFunc *func, void *data);
80 void camel_filter_driver_set_folder_func      (CamelFilterDriver *d, CamelFilterGetFolderFunc fetcher, void *data);
81
82 void camel_filter_driver_set_default_folder   (CamelFilterDriver *d, CamelFolder *def);
83
84 void camel_filter_driver_add_rule             (CamelFilterDriver *d, const char *name, const char *match,
85                                                const char *action);
86 int  camel_filter_driver_remove_rule_by_name  (CamelFilterDriver *d, const char *name);
87
88 /*void camel_filter_driver_set_global(CamelFilterDriver *, const char *name, const char *value);*/
89
90 void camel_filter_driver_flush                (CamelFilterDriver *driver, CamelException *ex);
91
92 int  camel_filter_driver_filter_message       (CamelFilterDriver *driver, CamelMimeMessage *message,
93                                                CamelMessageInfo *info, const char *uri,
94                                                CamelFolder *source, const char *source_url,
95                                                const char *original_source_url, CamelException *ex);
96
97 int  camel_filter_driver_filter_mbox          (CamelFilterDriver *driver, const char *mbox,
98                                                const char *original_source_url, CamelException *ex);
99
100 int  camel_filter_driver_filter_folder        (CamelFilterDriver *driver, CamelFolder *folder, CamelUIDCache *cache,
101                                                GPtrArray *uids, gboolean remove, CamelException *ex);
102
103 #if 0
104 /* generate the search query/action string for a filter option */
105 void camel_filter_driver_expand_option (CamelFilterDriver *d, GString *s, GString *action, struct filter_option *op);
106
107 /* get info about rules (options) */
108 int camel_filter_driver_rule_count (CamelFilterDriver *d);
109 struct filter_option *camel_filter_driver_rule_get (CamelFilterDriver *d, int n);
110 #endif
111
112 G_END_DECLS
113
114 #endif /* ! _CAMEL_FILTER_DRIVER_H */