aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-filter-driver.h
blob: d003cc4a48bff1affc0d86e69f74960ca8d2672f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
 *  Copyright (C) 2000 Ximian Inc.
 *
 *  Authors: Michael Zucchi <notzed@ximian.com>
 *           Jeffrey Stedfast <fejj@ximian.com>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of version 2 of the GNU General Public
 * License as published by the Free Software Foundation.
 *
 * 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 _CAMEL_FILTER_DRIVER_H
#define _CAMEL_FILTER_DRIVER_H

#include <glib.h>
#include <camel/camel-object.h>
#include <camel/camel-session.h>
#include <camel/camel-folder.h>
#include <camel/camel-uid-cache.h>

#define CAMEL_FILTER_DRIVER_TYPE   (camel_filter_driver_get_type())
#define CAMEL_FILTER_DRIVER(obj)         CAMEL_CHECK_CAST (obj, camel_filter_driver_get_type (), CamelFilterDriver)
#define CAMEL_FILTER_DRIVER_CLASS(klass) CAMEL__CHECK_CLASS_CAST (klass, camel_filter_driver_get_type (), CamelFilterDriverClass)
#define CAMEL_IS_FILTER_DRIVER(obj)      CAMEL_CHECK_TYPE (obj, camel_filter_driver_get_type ())

typedef struct _CamelFilterDriverClass CamelFilterDriverClass;

struct _CamelFilterDriver {
    CamelObject parent;

    struct _CamelFilterDriverPrivate *priv;
};

struct _CamelFilterDriverClass {
    CamelObjectClass parent_class;
};

/* FIXME: this maybe should change... */
/* type of status for a status report */
enum camel_filter_status_t {
    CAMEL_FILTER_STATUS_NONE,
    CAMEL_FILTER_STATUS_START,  /* start of new message processed */
    CAMEL_FILTER_STATUS_ACTION, /* an action performed */
    CAMEL_FILTER_STATUS_PROGRESS,   /* (an) extra update(s), if its taking longer to process */
    CAMEL_FILTER_STATUS_END,    /* end of message */
};

typedef CamelFolder * (*CamelFilterGetFolderFunc) (CamelFilterDriver *driver, const char *uri,
                           void *data, CamelException *ex);
/* report status */
typedef void (CamelFilterStatusFunc) (CamelFilterDriver *driver, enum camel_filter_status_t status,
                      int pc, const char *desc, void *data);

typedef void (CamelFilterShellExecFunc) (CamelFilterDriver *driver, const char *command, void *data);

CamelType          camel_filter_driver_get_type (void);
CamelFilterDriver  *camel_filter_driver_new     (void);

/* modifiers */
void camel_filter_driver_reset_filtered_count (CamelFilterDriver *driver);
int  camel_filter_driver_get_filtered_count   (CamelFilterDriver *driver);

void camel_filter_driver_set_logfile          (CamelFilterDriver *d, FILE *logfile);

void camel_filter_driver_set_status_func      (CamelFilterDriver *d, CamelFilterStatusFunc *func, void *data);
void camel_filter_driver_set_shell_exec_func  (CamelFilterDriver *d, CamelFilterShellExecFunc *func, void *data);
void camel_filter_driver_set_folder_func      (CamelFilterDriver *d, CamelFilterGetFolderFunc fetcher, void *data);

void camel_filter_driver_set_default_folder   (CamelFilterDriver *d, CamelFolder *def);

void camel_filter_driver_add_rule             (CamelFilterDriver *d, const char *name, const char *match,
                           const char *action);

/*void camel_filter_driver_set_global(CamelFilterDriver *, const char *name, const char *value);*/

int  camel_filter_driver_filter_message       (CamelFilterDriver *driver, CamelMimeMessage *message,
                           CamelMessageInfo *info, const char *uri,
                           CamelFolder *source, const char *source_url,
                           const char *original_source_url, CamelException *ex);

int  camel_filter_driver_filter_mbox          (CamelFilterDriver *driver, const char *mbox,
                           const char *original_source_url, CamelException *ex);

int  camel_filter_driver_filter_folder        (CamelFilterDriver *driver, CamelFolder *folder, CamelUIDCache *cache,
                           GPtrArray *uids, gboolean remove, CamelException *ex);

#if 0
/* generate the search query/action string for a filter option */
void camel_filter_driver_expand_option (CamelFilterDriver *d, GString *s, GString *action, struct filter_option *op);

/* get info about rules (options) */
int camel_filter_driver_rule_count (CamelFilterDriver *d);
struct filter_option *camel_filter_driver_rule_get (CamelFilterDriver *d, int n);
#endif

#endif /* ! _CAMEL_FILTER_DRIVER_H */