#include "str.h"
#include "imap-base-subject.h"
#include "mail-storage.h"
+#include "message-address.h"
#include "imap-sort.h"
#include <stdlib.h>
return value;
}
+static const char *get_first_mailbox(struct mail *mail, const char *field)
+{
+ struct message_address *addr;
+ const char *str;
+
+ str = mail->get_header(mail, field);
+ if (str == NULL)
+ return NULL;
+
+ addr = message_address_parse(data_stack_pool,
+ (const unsigned char *) str,
+ (size_t)-1, 1);
+ return addr != NULL ? addr->mailbox : NULL;
+}
+
static void mail_sort_check_flush(struct sort_context *ctx, struct mail *mail)
{
const char *str;
}
if (ctx->common_mask & MAIL_SORT_CC) {
- str = mail->get_first_mailbox(mail, "cc");
+ str = get_first_mailbox(mail, "cc");
if (str != NULL)
str = str_ucase(t_strdup_noconst(str));
}
if (ctx->common_mask & MAIL_SORT_FROM) {
- str = mail->get_first_mailbox(mail, "from");
+ str = get_first_mailbox(mail, "from");
if (str != NULL)
str = str_ucase(t_strdup_noconst(str));
}
if (ctx->common_mask & MAIL_SORT_TO) {
- str = mail->get_first_mailbox(mail, "to");
+ str = get_first_mailbox(mail, "to");
if (str != NULL)
str = str_ucase(t_strdup_noconst(str));
if (ctx->common_mask & MAIL_SORT_CC)
str = ctx->last_cc;
else {
- str = mail->get_first_mailbox(mail, "cc");
+ str = get_first_mailbox(mail, "cc");
if (str != NULL)
str = str_ucase(t_strdup_noconst(str));
}
if (ctx->common_mask & MAIL_SORT_FROM)
str = ctx->last_from;
else {
- str = mail->get_first_mailbox(mail, "from");
+ str = get_first_mailbox(mail, "from");
if (str != NULL)
str = str_ucase(t_strdup_noconst(str));
}
if (ctx->common_mask & MAIL_SORT_TO)
str = ctx->last_to;
else {
- str = mail->get_first_mailbox(mail, "to");
+ str = get_first_mailbox(mail, "to");
if (str != NULL)
str = str_ucase(t_strdup_noconst(str));
}
return imap_get_base_subject_cased(ctx->temp_pool,
str, NULL);
case MAIL_SORT_CC:
- str = mail->get_first_mailbox(mail, "cc");
+ str = get_first_mailbox(mail, "cc");
break;
case MAIL_SORT_FROM:
- str = mail->get_first_mailbox(mail, "from");
+ str = get_first_mailbox(mail, "from");
break;
case MAIL_SORT_TO:
- str = mail->get_first_mailbox(mail, "to");
+ str = get_first_mailbox(mail, "to");
break;
default:
i_unreached();
str_len(mail->data.header_data));
}
-static const struct message_address *
-get_address(struct mail *_mail, const char *field)
-{
- struct index_mail *mail = (struct index_mail *) _mail;
- const char *str;
-
- str = get_header(_mail, field);
- if (str == NULL)
- return NULL;
-
- return message_address_parse(mail->pool, (const unsigned char *) str,
- (size_t)-1, 1);
-}
-
-static const char *get_first_mailbox(struct mail *_mail, const char *field)
-{
- struct index_mail *mail = (struct index_mail *) _mail;
- struct message_address *addr;
- const char *str;
-
- str = get_header(_mail, field);
- if (str == NULL)
- return NULL;
-
- addr = message_address_parse(mail->pool, (const unsigned char *) str,
- (size_t)-1, 1);
- return addr != NULL ? addr->mailbox : NULL;
-}
-
static struct istream *get_stream(struct mail *_mail,
struct message_size *hdr_size,
struct message_size *body_size)
get_size,
get_header,
get_headers,
- get_address,
- get_first_mailbox,
get_stream,
get_special,
index_storage_update_flags,
struct istream *(*get_headers)(struct mail *mail,
const char *const minimum_fields[]);
- /* Returns the parsed address for given header field. */
- const struct message_address *(*get_address)(struct mail *mail,
- const char *field);
- /* Returns the first mailbox (RFC2822 local-part) field for given
- address header field. */
- const char *(*get_first_mailbox)(struct mail *mail, const char *field);
-
/* Returns input stream pointing to beginning of message header.
hdr_size and body_size are updated unless they're NULL. */
struct istream *(*get_stream)(struct mail *mail,
return p->mail->get_header(p->mail, field);
}
-static const struct message_address *
-_get_address(struct mail *mail, const char *field)
-{
- struct proxy_mail *p = (struct proxy_mail *) mail;
-
- return p->mail->get_address(p->mail, field);
-}
-
-static const char *_get_first_mailbox(struct mail *mail, const char *field)
-{
- struct proxy_mail *p = (struct proxy_mail *) mail;
-
- return p->mail->get_first_mailbox(p->mail, field);
-}
-
static struct istream *_get_stream(struct mail *mail,
struct message_size *hdr_size,
struct message_size *body_size)
pm->get_date = _get_date;
pm->get_size = _get_size;
pm->get_header = _get_header;
- pm->get_address = _get_address;
- pm->get_first_mailbox = _get_first_mailbox;
pm->get_stream = _get_stream;
pm->get_special = _get_special;
pm->update_flags = _update_flags;