42
struct mail_search_seqset {
44
struct mail_search_seqset *next;
51
enum mail_search_arg_flag {
52
/* For (SENT)BEFORE/SINCE/ON searches: Don't drop timezone from
54
MAIL_SEARCH_ARG_FLAG_USE_TZ = 0x01,
57
enum mail_search_modseq_type {
58
MAIL_SEARCH_MODSEQ_TYPE_ANY = 0,
59
MAIL_SEARCH_MODSEQ_TYPE_PRIVATE,
60
MAIL_SEARCH_MODSEQ_TYPE_SHARED
63
struct mail_search_modseq {
65
enum mail_search_modseq_type type;
47
68
struct mail_search_arg {
50
71
enum mail_search_arg_type type;
52
73
struct mail_search_arg *subargs;
53
struct mail_search_seqset *seqset;
74
ARRAY_TYPE(seq_range) seqset;
57
78
enum mail_flags flags;
79
enum mail_search_arg_flag search_flags;
80
enum mail_thread_type thread_type;
58
81
struct mail_keywords *keywords;
82
struct mail_search_modseq *modseq;
83
struct mail_search_args *search_args;
84
struct mail_search_result *search_result;
66
92
int result; /* -1 = unknown, 0 = unmatched, 1 = matched */
95
struct mail_search_args {
96
int refcount, init_refcount;
100
struct mail_search_arg *args;
103
unsigned int simplified:1;
104
unsigned int have_inthreads:1;
69
107
#define ARG_SET_RESULT(arg, res) \
71
109
(arg)->result = !(arg)->not ? (res) : \
75
113
typedef void mail_search_foreach_callback_t(struct mail_search_arg *arg,
116
/* Allocate keywords for search arguments. If change_uidsets is TRUE,
117
change uidsets to seqsets. */
118
void mail_search_args_init(struct mail_search_args *args,
119
struct mailbox *box, bool change_uidsets,
120
const ARRAY_TYPE(seq_range) *search_saved_uidset);
121
/* Free keywords. The args can initialized afterwards again if needed.
122
The args can be reused for other queries after calling this. */
123
void mail_search_args_deinit(struct mail_search_args *args);
124
/* Convert sequence sets in args to UIDs. */
125
void mail_search_args_seq2uid(struct mail_search_args *args);
126
/* Returns TRUE if the two search arguments are fully compatible.
127
Always returns FALSE if there are seqsets, since they may point to different
128
messages depending on when the search is run. */
129
bool mail_search_args_equal(const struct mail_search_args *args1,
130
const struct mail_search_args *args2);
132
void mail_search_args_ref(struct mail_search_args *args);
133
void mail_search_args_unref(struct mail_search_args **args);
135
struct mail_search_args *
136
mail_search_args_dup(const struct mail_search_args *args);
78
138
/* Reset the results in search arguments. match_always is reset only if
79
139
full_reset is TRUE. */
80
140
void mail_search_args_reset(struct mail_search_arg *args, bool full_reset);
102
162
mail_search_args_analyze(struct mail_search_arg *args,
103
163
bool *have_headers, bool *have_body);
105
/* 1) Change args so that SEARCH_SUB and SEARCH_OR will never have "not" set
106
2) Drop unnecessary nested SEARCH_SUB and SEARCH_ORs */
107
void mail_search_args_simplify(struct mail_search_arg *args);
165
/* Simplify/optimize search arguments */
166
void mail_search_args_simplify(struct mail_search_args *args);