#ifndef MAIL_SEARCH_H
#define MAIL_SEARCH_H
#include "seq-range-array.h"
#include "mail-types.h"
#include "mail-thread.h"
struct mail_search_mime_part;
enum mail_search_arg_type {
/* sequence sets */
/* flags */
/* dates (date_type required) */
/* sizes */
/* headers */
/* body */
/* extensions */
};
enum mail_search_date_type {
};
enum mail_search_arg_flag {
When NOT set: Adjust search timestamps so that the email's timezone
is included in the comparisons. For example
"04-Nov-2016 00:00:00 +0200" would match 4th day. This allows
searching for mails with dates from the email sender's point of
without this flag the dates are compared using the server's local
timezone.
When set: Compare the timestamp as UTC. For example
"04-Nov-2016 00:00:00 +0200" would be treated as
"03-Nov-2016 22:00:00 UTC" and would match 3rd day. This allows
searching for mails within precise time interval. Since imap-dates
don't allow specifying timezone this isn't really possible with IMAP
};
enum mail_search_modseq_type {
};
struct mail_search_modseq {
};
struct mail_search_arg {
/* NOTE: when adding new fields, make sure mail_search_arg_dup_one()
and mail_search_arg_one_equals() are updated. */
struct {
const char *str;
} value;
/* set by mail_search_args_init(): */
struct {
/* Note that initialized keywords may be empty if the keyword
wasn't valid in this mailbox. */
} initialized;
void *context;
};
struct mail_search_args {
/* Stop mail_search_next() when finding a non-matching mail.
(Could be useful when wanting to find only the oldest mails.) */
/* fts plugin has already expanded the search args - no need to do
it again. */
};
STMT_START { \
} STMT_END
void *context);
/* Allocate keywords for search arguments. If change_uidsets is TRUE,
change uidsets to seqsets. */
ATTR_NULL(4);
/* Initialize arg and its children. args is used for getting mailbox and
pool. */
struct mail_search_arg *arg,
bool change_uidsets,
/* Free memory allocated by mail_search_args_init(). The args can initialized
afterwards again if needed. The args can be reused for other queries after
calling this. */
/* Free arg and its siblings and children. */
/* Free arg and its children, but not its siblings. */
/* Convert sequence sets in args to UIDs. */
/* Returns TRUE if the two search arguments are fully compatible.
Always returns FALSE if there are seqsets, since they may point to different
messages depending on when the search is run. */
const struct mail_search_args *args2);
/* Same as mail_search_args_equal(), but for individual mail_search_arg
structs. All the siblings of arg1 and arg2 are also compared. */
const struct mail_search_arg *arg2);
/* Same as mail_search_arg_equals(), but don't compare siblings. */
const struct mail_search_arg *arg2);
struct mail_search_args *
struct mail_search_arg *
/* Reset the results in search arguments. match_always is reset only if
full_reset is TRUE. */
/* goes through arguments in list that don't have a result yet.
Returns 1 = search matched, 0 = search unmatched, -1 = don't know yet */
CALLBACK_TYPECHECK(callback, void (*)( \
/* Fills have_headers and have_body based on if such search argument exists
that needs to be checked. Returns the headers that we're searching for, or
NULL if we're searching for TEXT. */
const char *const *
bool *have_headers, bool *have_body);
/* Returns FALSE if search query contains MAILBOX[_GLOB] args such that the
query can never match any messages in the given mailbox. */
guaranteed to have match_not=FALSE. */
/* Append all args as IMAP SEARCH AND-query to the dest string and returns TRUE.
If some search arg can't be written as IMAP SEARCH parameter, error_r is set
and FALSE is returned. */
const char **error_r);
/* Like mail_search_args_to_imap(), but append only a single arg. */
const char **error_r);
const struct mail_search_arg *args);
/* Serialization for search args' results. */
const unsigned char *data,
#endif