0
|
1 #ifndef __MAIL_SEARCH_H
|
|
2 #define __MAIL_SEARCH_H
|
|
3
|
|
4 #include "imap-parser.h"
|
|
5 #include "mail-storage.h"
|
|
6
|
|
7 typedef enum {
|
|
8 SEARCH_OR,
|
|
9 SEARCH_SUB,
|
|
10
|
|
11 /* message sets */
|
|
12 SEARCH_ALL,
|
|
13 SEARCH_SET,
|
|
14 SEARCH_UID,
|
|
15
|
|
16 /* flags */
|
|
17 SEARCH_ANSWERED,
|
|
18 SEARCH_DELETED,
|
|
19 SEARCH_DRAFT,
|
|
20 SEARCH_FLAGGED,
|
|
21 SEARCH_SEEN,
|
|
22 SEARCH_RECENT,
|
|
23 SEARCH_KEYWORD,
|
|
24
|
|
25 /* dates */
|
|
26 SEARCH_BEFORE,
|
|
27 SEARCH_ON,
|
|
28 SEARCH_SINCE,
|
|
29 SEARCH_SENTBEFORE,
|
|
30 SEARCH_SENTON,
|
|
31 SEARCH_SENTSINCE,
|
|
32
|
|
33 /* sizes */
|
|
34 SEARCH_SMALLER,
|
|
35 SEARCH_LARGER,
|
|
36
|
|
37 /* headers */
|
|
38 SEARCH_FROM,
|
|
39 SEARCH_TO,
|
|
40 SEARCH_CC,
|
|
41 SEARCH_BCC,
|
|
42 SEARCH_SUBJECT,
|
|
43 SEARCH_HEADER,
|
|
44
|
|
45 /* body */
|
|
46 SEARCH_BODY,
|
|
47 SEARCH_TEXT
|
|
48 } MailSearchArgType;
|
|
49
|
|
50 struct _MailSearchArg {
|
|
51 MailSearchArg *next;
|
|
52
|
|
53 MailSearchArgType type;
|
|
54 union {
|
|
55 MailSearchArg *subargs;
|
|
56 const char *str;
|
|
57 } value;
|
|
58
|
|
59 const char *hdr_value; /* for SEARCH_HEADER */
|
|
60 unsigned int not:1;
|
|
61
|
|
62 int result;
|
|
63 };
|
|
64
|
|
65 typedef void (*MailSearchForeachFunc)(MailSearchArg *arg, void *user_data);
|
|
66
|
|
67 /* Builds search arguments based on IMAP arguments. */
|
|
68 MailSearchArg *mail_search_args_build(Pool pool, ImapArg *args, int args_count,
|
|
69 const char **error);
|
|
70
|
|
71 /* Reset the results in search arguments */
|
|
72 void mail_search_args_reset(MailSearchArg *args);
|
|
73
|
|
74 /* goes through arguments in list that don't have a result yet.
|
|
75 Returns 1 = search matched, -1 = search unmatched, 0 = don't know yet */
|
|
76 int mail_search_args_foreach(MailSearchArg *args, MailSearchForeachFunc func,
|
|
77 void *user_data);
|
|
78
|
|
79 /* Fills have_headers, have_body and have_text based on if such search
|
|
80 argument exists that needs to be checked. */
|
|
81 void mail_search_args_analyze(MailSearchArg *args, int *have_headers,
|
|
82 int *have_body, int *have_text);
|
|
83
|
|
84 #endif
|