168a8574f84f9081ab1975981cdb936c58bd8cf4
[citadel.git] / citadel / serv_sieve.h
1 /*
2  * $Id: $
3  */
4
5
6 #ifdef HAVE_LIBSIEVE
7
8 #include <sieve2.h>
9 #include <sieve2_error.h>
10
11 struct sdm_script {
12         struct sdm_script *next;
13         char script_name[256];
14         int script_active;
15         char *script_content;
16 };
17
18 struct sdm_vacation {
19         struct sdm_vacation *next;
20         char fromaddr[256];
21         time_t timestamp;
22 };
23
24 struct sdm_userdata {
25         sieve2_context_t *sieve2_context;       /**< for libsieve's use */
26         long config_msgnum;                     /**< confirms that a sieve config was located */
27         char config_roomname[ROOMNAMELEN];
28         long lastproc;                          /**< last message processed */
29         struct sdm_script *first_script;
30         struct sdm_vacation *first_vacation;
31 };
32
33 struct ctdl_sieve {
34         char *rfc822headers;
35         int cancel_implicit_keep;       /* Set to 1 if the message was successfully acted upon */
36         int keep;                       /* Set to 1 to suppress message deletion from the inbox */
37         long usernum;                   /* Owner of the mailbox we're processing */
38         long msgnum;                    /* Message base ID of the message being processed */
39         struct sdm_userdata *u;         /* Info related to the current session */
40         char recp_user[256];
41         char recp_node[256];
42         char recp_name[256];
43         char sender[256];               /* To whom shall we send reject bounces or vacation messages? */
44         char subject[1024];             /* Retain msg subject so we can use it in vacation messages */
45         char envelope_from[1024];
46         char envelope_to[1024];
47 };
48
49
50 /* If you change this string you will break all of your Sieve configs. */
51 #define CTDLSIEVECONFIGSEPARATOR        "\n-=<CtdlSieveConfigSeparator>=-\n"
52
53 /* Maximum time we keep vacation fromaddr records online.  This implies that a vacation
54  * rule cannot exceed this amount of time.   (Any more than 30 days is a ridiculously
55  * long vacation which the person probably doesn't deserve.)
56  */
57 #define MAX_VACATION    30
58
59 extern struct RoomProcList *sieve_list;
60
61 void sieve_queue_room(struct ctdlroom *);
62 void perform_sieve_processing(void);
63
64 void msiv_load(struct sdm_userdata *u);
65 void msiv_store(struct sdm_userdata *u, int changes_made);
66 int msiv_setactive(struct sdm_userdata *u, char *script_name);
67 char *msiv_getscript(struct sdm_userdata *u, char *script_name);
68 int msiv_deletescript(struct sdm_userdata *u, char *script_name);
69 void msiv_putscript(struct sdm_userdata *u, char *script_name, char *script_content);
70 extern char *msiv_extensions;
71
72 #endif /* HAVE_LIBSIEVE */