From f8f0ce3973b9fec8a7ec0422df6c67f3e2a3f96d Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Thu, 14 Aug 2003 01:24:32 +0300 Subject: [PATCH] Removed get_address() and get_first_mailbox() from mail interface. --HG-- branch : HEAD --- src/imap/imap-sort.c | 34 ++++++++++++++++++++++-------- src/lib-storage/index/index-mail.c | 31 --------------------------- src/lib-storage/mail-storage.h | 7 ------ src/lib-storage/proxy-mail.c | 17 --------------- 4 files changed, 25 insertions(+), 64 deletions(-) diff --git a/src/imap/imap-sort.c b/src/imap/imap-sort.c index 74b3b5d9f9..98ffa51fbb 100644 --- a/src/imap/imap-sort.c +++ b/src/imap/imap-sort.c @@ -12,6 +12,7 @@ #include "str.h" #include "imap-base-subject.h" #include "mail-storage.h" +#include "message-address.h" #include "imap-sort.h" #include @@ -274,6 +275,21 @@ static const char *string_table_get(struct sort_context *ctx, const char *str) 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; @@ -290,7 +306,7 @@ static void mail_sort_check_flush(struct sort_context *ctx, struct mail *mail) } 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)); @@ -310,7 +326,7 @@ static void mail_sort_check_flush(struct sort_context *ctx, struct mail *mail) } 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)); @@ -345,7 +361,7 @@ static void mail_sort_check_flush(struct sort_context *ctx, struct mail *mail) } 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)); @@ -408,7 +424,7 @@ static void mail_sort_input(struct sort_context *ctx, struct mail *mail) 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)); } @@ -422,7 +438,7 @@ static void mail_sort_input(struct sort_context *ctx, struct mail *mail) 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)); } @@ -436,7 +452,7 @@ static void mail_sort_input(struct sort_context *ctx, struct mail *mail) 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)); } @@ -556,13 +572,13 @@ static const char *get_str(enum mail_sort_type type, const unsigned char *buf, 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(); diff --git a/src/lib-storage/index/index-mail.c b/src/lib-storage/index/index-mail.c index 542c6ff0bd..64222387d1 100644 --- a/src/lib-storage/index/index-mail.c +++ b/src/lib-storage/index/index-mail.c @@ -808,35 +808,6 @@ static struct istream *get_headers(struct mail *_mail, 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) @@ -996,8 +967,6 @@ static struct mail index_mail = { get_size, get_header, get_headers, - get_address, - get_first_mailbox, get_stream, get_special, index_storage_update_flags, diff --git a/src/lib-storage/mail-storage.h b/src/lib-storage/mail-storage.h index 203d2986be..9e2eed7a35 100644 --- a/src/lib-storage/mail-storage.h +++ b/src/lib-storage/mail-storage.h @@ -377,13 +377,6 @@ struct mail { 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, diff --git a/src/lib-storage/proxy-mail.c b/src/lib-storage/proxy-mail.c index 7ab43c2629..c7aa7fcffd 100644 --- a/src/lib-storage/proxy-mail.c +++ b/src/lib-storage/proxy-mail.c @@ -45,21 +45,6 @@ static const char *_get_header(struct mail *mail, const char *field) 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) @@ -113,8 +98,6 @@ void proxy_mail_init(struct proxy_mail *proxy, struct mail *mail) 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; -- 2.47.3