mail-search.h revision 78f8407de32c9a51f2db00f4edb466f4279fa456
#ifndef MAIL_SEARCH_H
#define MAIL_SEARCH_H
#include "seq-range-array.h"
#include "mail-types.h"
#include "mail-thread.h"
enum mail_search_arg_type {
/* sequence sets */
/* flags */
/* dates (date_type required) */
SEARCH_ON, /* time must point to beginning of the day */
/* sizes */
/* headers */
/* body */
/* extensions */
};
enum mail_search_date_type {
};
enum mail_search_arg_flag {
comparisons */
MAIL_SEARCH_ARG_FLAG_USE_TZ = 0x01,
};
enum mail_search_modseq_type {
};
struct mail_search_modseq {
enum mail_search_modseq_type type;
};
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 mail_search_arg *next;
enum mail_search_arg_type type;
struct {
struct mail_search_arg *subargs;
const char *str;
enum mail_flags flags;
enum mail_thread_type thread_type;
struct mail_search_modseq *modseq;
struct mail_search_result *search_result;
} value;
/* set by mail_search_args_init(): */
struct {
struct mail_search_args *search_args;
struct mail_keywords *keywords;
struct imap_match_glob *mailbox_glob;
} initialized;
void *context;
const char *hdr_field_name; /* for SEARCH_HEADER* */
int result; /* -1 = unknown, 0 = unmatched, 1 = matched */
};
struct mail_search_args {
int refcount, init_refcount;
struct mail_search_arg *args;
unsigned int simplified:1;
unsigned int have_inthreads:1;
/* Stop mail_search_next() when finding a non-matching mail.
(Could be useful when wanting to find only the oldest mails.) */
unsigned int stop_on_nonmatch:1;
/* fts plugin has already expanded the search args - no need to do
it again. */
unsigned int fts_expanded:1;
};
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 children. */
/* 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