File: sieve-ext-enotify.h

package info (click to toggle)
dovecot 1:2.2.13-12~deb8u4
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 38,792 kB
  • sloc: ansic: 341,472; sh: 16,920; makefile: 5,393; cpp: 1,474; perl: 265; xml: 44; python: 34; pascal: 27
file content (171 lines) | stat: -rw-r--r-- 4,153 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
/* Copyright (c) 2002-2013 Pigeonhole authors, see the included COPYING file
 */

#ifndef __SIEVE_EXT_ENOTIFY_H
#define __SIEVE_EXT_ENOTIFY_H

#include "lib.h"
#include "compat.h"
#include <stdarg.h>

#include "sieve-common.h"
#include "sieve-error.h"

/*
 * Forward declarations
 */

struct sieve_enotify_method;
struct sieve_enotify_env;
struct sieve_enotify_action;
struct sieve_enotify_print_env;
struct sieve_enotify_exec_env;

/*
 * Notify method definition
 */

struct sieve_enotify_method_def {
	const char *identifier;

	/* Registration */
	bool (*load)
		(const struct sieve_enotify_method *nmth, void **context);
	void (*unload)
		(const struct sieve_enotify_method *nmth);

	/* Validation */
	bool (*compile_check_uri)
		(const struct sieve_enotify_env *nenv, const char *uri,
			const char *uri_body);
	bool (*compile_check_message)
		(const struct sieve_enotify_env *nenv, string_t *message);
	bool (*compile_check_from)
		(const struct sieve_enotify_env *nenv, string_t *from);
	bool (*compile_check_option)
		(const struct sieve_enotify_env *nenv, const char *option,
			const char *value);

	/* Runtime */
	bool (*runtime_check_uri)
		(const struct sieve_enotify_env *nenv, const char *uri,
			const char *uri_body);
	const char *(*runtime_get_method_capability)
		(const struct sieve_enotify_env *nenv, const char *uri,
			const char *uri_body, const char *capability);
	bool (*runtime_check_operands)
		(const struct sieve_enotify_env *nenv, const char *uri,
			const char *uri_body, string_t *message, string_t *from,
			pool_t context_pool, void **method_context);
	bool (*runtime_set_option)
		(const struct sieve_enotify_env *nenv, void *method_context,
			const char *option, const char *value);

	/* Action duplicates */
	int (*action_check_duplicates)
		(const struct sieve_enotify_env *nenv,
			const struct sieve_enotify_action *nact,
			const struct sieve_enotify_action *nact_other);

	/* Action print */
	void (*action_print)
		(const struct sieve_enotify_print_env *penv,
			const struct sieve_enotify_action *nact);

	/* Action execution */
	bool (*action_execute)
		(const struct sieve_enotify_exec_env *nenv,
			const struct sieve_enotify_action *nact);
};

/*
 * Notify method instance
 */

struct sieve_enotify_method {
	const struct sieve_enotify_method_def *def;
	int id;

	struct sieve_instance *svinst;
	void *context;
};

const struct sieve_enotify_method *sieve_enotify_method_register
	(struct sieve_instance *svinst,
		const struct sieve_enotify_method_def *nmth_def);
void  sieve_enotify_method_unregister
	(const struct sieve_enotify_method *nmth);

/*
 * Notify method environment
 */

struct sieve_enotify_env {
	struct sieve_instance *svinst;

	const struct sieve_enotify_method *method;

	struct sieve_error_handler *ehandler;
};

/*
 * Notify method printing
 */

void sieve_enotify_method_printf
	(const struct sieve_enotify_print_env *penv, const char *fmt, ...)
		ATTR_FORMAT(2, 3);

/*
 * Notify execution environment
 */

struct sieve_enotify_exec_env {
	struct sieve_instance *svinst;

	const struct sieve_enotify_method *method;

	const struct sieve_script_env *scriptenv;
	const struct sieve_message_data *msgdata;
	struct sieve_message_context *msgctx;

	struct sieve_error_handler *ehandler;
};

/*
 * Notify action
 */

struct sieve_enotify_action {
	const struct sieve_enotify_method *method;
	void *method_context;

	sieve_number_t importance;
	const char *message;
	const char *from;
};

/*
 * Error handling
 */

#define sieve_enotify_error(ENV, ...) \
	sieve_error((ENV)->ehandler, NULL, __VA_ARGS__ )

#define sieve_enotify_warning(ENV, ...) \
	sieve_warning((ENV)->ehandler, NULL, __VA_ARGS__ )

#define sieve_enotify_info(ENV, ...) \
	sieve_info((ENV)->ehandler, NULL, __VA_ARGS__ )

#define sieve_enotify_global_error(ENV, ...) \
	sieve_global_error((ENV)->svinst, (ENV)->ehandler, NULL, __VA_ARGS__ )

#define sieve_enotify_global_warning(ENV, ...) \
	sieve_global_warning((ENV)->svinst, (ENV)->ehandler, NULL, __VA_ARGS__ )

#define sieve_enotify_global_info(ENV, ...) \
	sieve_global_info((ENV)->svinst, (ENV)->ehandler, NULL, __VA_ARGS__ )

#endif /* __SIEVE_EXT_ENOTIFY_H */