File: sieve-storage.h

package info (click to toggle)
dovecot 1%3A2.2.27-3~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 48,308 kB
  • sloc: ansic: 430,242; sh: 17,401; makefile: 6,581; cpp: 1,557; perl: 295; xml: 44; pascal: 27; python: 27
file content (197 lines) | stat: -rw-r--r-- 5,344 bytes parent folder | download | duplicates (3)
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
/* Copyright (c) 2002-2016 Pigeonhole authors, see the included COPYING file
 */

#ifndef __SIEVE_STORAGE_H
#define __SIEVE_STORAGE_H

#define MAILBOX_ATTRIBUTE_PREFIX_SIEVE \
	MAILBOX_ATTRIBUTE_PREFIX_DOVECOT_PVT_SERVER"sieve/"
#define MAILBOX_ATTRIBUTE_PREFIX_SIEVE_FILES \
	MAILBOX_ATTRIBUTE_PREFIX_SIEVE"files/"
#define MAILBOX_ATTRIBUTE_SIEVE_DEFAULT \
	MAILBOX_ATTRIBUTE_PREFIX_SIEVE"default"

#define MAILBOX_ATTRIBUTE_SIEVE_DEFAULT_LINK 'L'
#define MAILBOX_ATTRIBUTE_SIEVE_DEFAULT_SCRIPT 'S'

/*
 * Storage object
 */

enum sieve_storage_flags {
	/* Storage is opened for read/write access (e.g. ManageSieve) */
	SIEVE_STORAGE_FLAG_READWRITE         = 0x01,
	/* This storage is used for synchronization (and not normal ManageSieve)
	 */
	SIEVE_STORAGE_FLAG_SYNCHRONIZING     = 0x02
};

struct sieve_storage;

struct sieve_storage *sieve_storage_create
(struct sieve_instance *svinst, const char *location,
	enum sieve_storage_flags flags, enum sieve_error *error_r)
	ATTR_NULL(4);
struct sieve_storage *sieve_storage_create_main
(struct sieve_instance *svinst, struct mail_user *user,
	enum sieve_storage_flags flags, enum sieve_error *error_r)
	ATTR_NULL(4);

void sieve_storage_ref(struct sieve_storage *storage);
void sieve_storage_unref(struct sieve_storage **_storage);

/*
 * Script access
 */

struct sieve_script *sieve_storage_get_script
	(struct sieve_storage *storage, const char *name,
		enum sieve_error *error_r) ATTR_NULL(3);
struct sieve_script *sieve_storage_open_script
	(struct sieve_storage *storage, const char *name,
		enum sieve_error *error_r) ATTR_NULL(3);
int sieve_storage_check_script
	(struct sieve_storage *storage, const char *name,
		enum sieve_error *error_r) ATTR_NULL(3);

/*
 * Script sequence
 */

struct sieve_script_sequence *sieve_storage_get_script_sequence
(struct sieve_storage *storage, enum sieve_error *error_r);

/*
 * Active script
 */

int sieve_storage_active_script_get_name
	(struct sieve_storage *storage, const char **name_r);

struct sieve_script *sieve_storage_active_script_open
	(struct sieve_storage *storage, enum sieve_error *error_r)
	ATTR_NULL(2);

int sieve_storage_active_script_get_last_change
	(struct sieve_storage *storage, time_t *last_change_r);

/*
 * Listing scripts in storage
 */

struct sieve_storage_list_context;

/* Create a context for listing the scripts in the storage */
struct sieve_storage_list_context *sieve_storage_list_init
	(struct sieve_storage *storage);
/* Get the next script in the storage. */
const char *sieve_storage_list_next
	(struct sieve_storage_list_context *lctx, bool *active_r)
	ATTR_NULL(2);
/* Destroy the listing context */
int sieve_storage_list_deinit
	(struct sieve_storage_list_context **lctx);

/*
 * Saving scripts in storage
 */

struct sieve_storage_save_context;

struct sieve_storage_save_context *
sieve_storage_save_init(struct sieve_storage *storage,
	const char *scriptname, struct istream *input);

int sieve_storage_save_continue(struct sieve_storage_save_context *sctx);

int sieve_storage_save_finish(struct sieve_storage_save_context *sctx);

struct sieve_script *sieve_storage_save_get_tempscript
  (struct sieve_storage_save_context *sctx);

bool sieve_storage_save_will_activate
	(struct sieve_storage_save_context *sctx);

void sieve_storage_save_set_mtime
	(struct sieve_storage_save_context *sctx, time_t mtime);

void sieve_storage_save_cancel(struct sieve_storage_save_context **sctx);

int sieve_storage_save_commit(struct sieve_storage_save_context **sctx);

int sieve_storage_save_as
	(struct sieve_storage *storage, struct istream *input,
		const char *name);

/* Saves input directly as a regular file at the active script path.
 * This is needed for the doveadm-sieve plugin.
 */
int sieve_storage_save_as_active
	(struct sieve_storage *storage, struct istream *input, time_t mtime);

/*
 * Management
 */

int sieve_storage_deactivate(struct sieve_storage *storage, time_t mtime);

/*
 * Storage quota
 */

enum sieve_storage_quota {
	SIEVE_STORAGE_QUOTA_NONE,
	SIEVE_STORAGE_QUOTA_MAXSIZE,
	SIEVE_STORAGE_QUOTA_MAXSCRIPTS,
	SIEVE_STORAGE_QUOTA_MAXSTORAGE
};

bool sieve_storage_quota_validsize
	(struct sieve_storage *storage, size_t size, uint64_t *limit_r);

uint64_t sieve_storage_quota_max_script_size
	(struct sieve_storage *storage);

int sieve_storage_quota_havespace
	(struct sieve_storage *storage, const char *scriptname, size_t size,
		enum sieve_storage_quota *quota_r, uint64_t *limit_r);

/*
 * Properties
 */

const char *sieve_storage_location
	(const struct sieve_storage *storage) ATTR_PURE;
bool sieve_storage_is_default
	(const struct sieve_storage *storage) ATTR_PURE;

int sieve_storage_is_singular
	(struct sieve_storage *storage);

/*
 * Error handling
 */

void sieve_storage_clear_error(struct sieve_storage *storage);

void sieve_storage_set_error
	(struct sieve_storage *storage, enum sieve_error error,
		const char *fmt, ...) ATTR_FORMAT(3, 4);
void sieve_storage_set_critical
	(struct sieve_storage *storage, 	const char *fmt, ...)
		ATTR_FORMAT(2, 3);

const char *sieve_storage_get_last_error
	(struct sieve_storage *storage, enum sieve_error *error_r)
	ATTR_NULL(2);

/*
 *
 */

int sieve_storage_get_last_change
	(struct sieve_storage *storage, time_t *last_change_r);
void sieve_storage_set_modified
	(struct sieve_storage *storage, time_t mtime);

#endif