/* Copyright (c) 2016-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "str.h"
#include "message-date.h"
#include "message-address.h"
#include "message-part-data.h"
#include "imap-bodystructure.h"
#include "mail-search.h"
#include "mail-search-mime.h"
#include "index-search-private.h"
struct search_mimepart_stack {
unsigned int index;
};
struct search_mimepart_context {
/* message parts parsed from BODYSTRUCTURE */
};
struct search_mimepart_context *mpctx);
struct mail_search_mime_arg *args)
{
int ret;
/* PARENT EXISTS: matches if this part has a parent.
*/
}
/* PARENT <mpart-key>: matches if this part's parent matches the
mpart-key (subargs).
*/
return ret;
}
struct mail_search_mime_arg *args)
{
int ret = 0;
/* CHILD EXISTS: matches if this part has any children; i.e., it is
multipart.
*/
}
/* CHILD <mpart-key>: matches if this part has any child that mathes
the mpart-key (subargs).
*/
T_BEGIN {
/* preserve current stack for any nested CHILD PARENT nastiness */
depth++;
else {
}
break;
depth++;
else {
}
} else {
break;
depth--;
}
}
}
} T_END;
return ret;
}
static int
{
return 0;
/* FIXME: Normalization is required */
}
static int
const struct message_part_envelope *envelope)
{
int timezone_offset;
return 0;
/* NOTE: RFC-3501 specifies that timezone is ignored
in searches. sent_time is returned as UTC, so change it. */
// FIXME: adjust comment
return 0;
switch (type) {
case SEARCH_MIME_SENTBEFORE:
case SEARCH_MIME_SENTON:
return (sent_time >= search_time &&
case SEARCH_MIME_SENTSINCE:
default:
i_unreached();
}
}
static int
const struct message_part_envelope *envelope)
{
return 0;
switch (type) {
case SEARCH_MIME_CC:
break;
case SEARCH_MIME_BCC:
break;
case SEARCH_MIME_FROM:
break;
case SEARCH_MIME_SENDER:
break;
case SEARCH_MIME_REPLY_TO:
break;
case SEARCH_MIME_TO:
break;
default:
i_unreached();
}
/* FIXME: do we need to normalize anything? at least case insensitivity.
MIME header encoding will make this a bit difficult, so it should
probably be normalized directly in the struct message_address. */
}
static int
struct mail_search_mime_arg *arg)
{
char *key;
const char *value;
return 0;
} else {
}
case SEARCH_MIME_FILENAME_IS:
default:
break;
}
i_unreached();
}
static void
struct mail_search_mime_arg *arg)
{
}
static int
unsigned int params_count,
{
unsigned int i;
/* FIXME: Is normalization required? */
for (i = 0; i < params_count; i++) {
return 1;
}
}
return 0;
}
static int
const char *key)
{
const char *const *lang;
/* FIXME: Should use RFC 4647 matching rules */
return 1;
lang++;
}
}
return 0;
}
/* Returns >0 = matched, 0 = not matched (unused), -1 = unknown */
struct mail_search_mime_arg *arg)
{
case SEARCH_MIME_OR:
case SEARCH_MIME_SUB:
i_unreached();
case SEARCH_MIME_SIZE_EQUAL:
case SEARCH_MIME_SIZE_LARGER:
case SEARCH_MIME_SIZE_SMALLER:
case SEARCH_MIME_DESCRIPTION:
return seach_arg_mime_substring_match(mpctx,
return seach_arg_mime_param_match
case SEARCH_MIME_ENCODING:
case SEARCH_MIME_ID:
case SEARCH_MIME_LANGUAGE:
case SEARCH_MIME_LOCATION:
case SEARCH_MIME_MD5:
case SEARCH_MIME_TYPE:
case SEARCH_MIME_SUBTYPE:
case SEARCH_MIME_PARAM:
return seach_arg_mime_param_match
case SEARCH_MIME_SENTBEFORE:
case SEARCH_MIME_SENTON:
case SEARCH_MIME_SENTSINCE:
case SEARCH_MIME_CC:
case SEARCH_MIME_BCC:
case SEARCH_MIME_FROM:
case SEARCH_MIME_REPLY_TO:
case SEARCH_MIME_SENDER:
case SEARCH_MIME_TO:
case SEARCH_MIME_SUBJECT:
return 0;
return seach_arg_mime_substring_match(mpctx,
case SEARCH_MIME_IN_REPLY_TO:
return 0;
return seach_arg_mime_substring_match(mpctx,
case SEARCH_MIME_MESSAGE_ID:
return 0;
return seach_arg_mime_substring_match(mpctx,
case SEARCH_MIME_DEPTH_EQUAL:
case SEARCH_MIME_DEPTH_MIN:
case SEARCH_MIME_DEPTH_MAX:
case SEARCH_MIME_INDEX:
case SEARCH_MIME_PARENT:
case SEARCH_MIME_CHILD:
case SEARCH_MIME_FILENAME_IS:
case SEARCH_MIME_HEADER:
case SEARCH_MIME_BODY:
case SEARCH_MIME_TEXT:
break;
}
return -1;
}
struct search_mimepart_context *mpctx)
{
case -1:
/* unknown */
break;
case 0:
ARG_SET_RESULT(arg, 0);
break;
default:
break;
}
}
struct mail_search_mime_arg *args,
struct message_part *parts)
{
int ret;
return ret;
} else {
break;
}
}
}
return 0;
}
/* Returns >0 = matched, 0 = not matched, -1 = unknown */
struct mail_search_arg *arg)
{
return -1;
}
/* FIXME: could the mail object already have message_part tree with
data? */
return -1;
return -1;
}
/* FIXME: implement HEADER, BODY and TEXT (not from BODYSTRUCTURE)
Needs to support FTS */
return seach_arg_mime_parts_match
}
struct search_mimepart_context *mpctx)
{
case -1:
/* unknown */
break;
case 0:
ARG_SET_RESULT(arg, 0);
break;
default:
break;
}
}
struct index_search_context *ctx)
{
int ret;
return ret;
}
static void
{
case SEARCH_MIME_FILENAME_IS:
break;
default:
break;
}
}
struct index_search_context *ctx)
{
}