diff -r 2a9df0617cfb src/imap/imap-fetch.c --- a/src/imap/imap-fetch.c Thu Mar 13 15:55:19 2008 +0200 +++ b/src/imap/imap-fetch.c Thu Mar 13 15:55:44 2008 +0200 @@ -9,6 +9,7 @@ #include "message-send.h" #include "message-size.h" #include "imap-date.h" +#include "imap-quote.h" #include "commands.h" #include "imap-fetch.h" #include "imap-util.h" @@ -20,7 +21,7 @@ #define ENVELOPE_NIL_REPLY \ "(NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)" -const struct imap_fetch_handler default_handlers[8]; +const struct imap_fetch_handler default_handlers[9]; static buffer_t *fetch_handlers = NULL; static int imap_fetch_handler_cmp(const void *p1, const void *p2) @@ -600,7 +601,28 @@ fetch_uid_init(struct imap_fetch_context return TRUE; } -const struct imap_fetch_handler default_handlers[8] = { +static int fetch_guid(struct imap_fetch_context *ctx, struct mail *mail, + void *context ATTR_UNUSED) +{ + const char *value; + + if (mail_get_special(mail, MAIL_FETCH_UIDL_FILE_NAME, &value) < 0) + return -1; + + str_append(ctx->cur_str, "X-GUID "); + imap_quote_append_string(ctx->cur_str, value, FALSE); + return 1; +} + +static bool +fetch_guid_init(struct imap_fetch_context *ctx ATTR_UNUSED, const char *name, + const struct imap_arg **args ATTR_UNUSED) +{ + imap_fetch_add_handler(ctx, TRUE, FALSE, name, "", fetch_guid, NULL); + return TRUE; +} + +const struct imap_fetch_handler default_handlers[9] = { { "BODY", fetch_body_init }, { "BODYSTRUCTURE", fetch_bodystructure_init }, { "ENVELOPE", fetch_envelope_init }, @@ -608,5 +630,6 @@ const struct imap_fetch_handler default_ { "INTERNALDATE", fetch_internaldate_init }, { "MODSEQ", fetch_modseq_init }, { "RFC822", fetch_rfc822_init }, - { "UID", fetch_uid_init } + { "UID", fetch_uid_init }, + { "X-GUID", fetch_guid_init } }; diff -r 2a9df0617cfb src/imap/imap-search.c --- a/src/imap/imap-search.c Thu Mar 13 15:55:19 2008 +0200 +++ b/src/imap/imap-search.c Thu Mar 13 15:55:44 2008 +0200 @@ -605,6 +605,9 @@ static bool search_arg_build(struct sear return ARG_NEW_SINGLE(SEARCH_ALL); } return ARG_NEW_STR(SEARCH_TEXT_FAST); + } else if (strcmp(str, "X-GUID") == 0) { + /* */ + return ARG_NEW_STR(SEARCH_GUID); } break; default: diff -r 2a9df0617cfb src/lib-storage/index/index-search.c --- a/src/lib-storage/index/index-search.c Thu Mar 13 15:55:19 2008 +0200 +++ b/src/lib-storage/index/index-search.c Thu Mar 13 15:55:44 2008 +0200 @@ -204,6 +204,7 @@ static int search_arg_match_cached(struc static int search_arg_match_cached(struct index_search_context *ctx, struct mail_search_arg *arg) { + const char *str; struct tm *tm; uoff_t virtual_size; time_t date; @@ -267,6 +268,11 @@ static int search_arg_match_cached(struc else return virtual_size > arg->value.size; + case SEARCH_GUID: + if (mail_get_special(ctx->mail, MAIL_FETCH_UIDL_FILE_NAME, + &str) < 0) + return -1; + return strcmp(str, arg->value.str) == 0; default: return -1; } diff -r 2a9df0617cfb src/lib-storage/mail-search.h --- a/src/lib-storage/mail-search.h Thu Mar 13 15:55:19 2008 +0200 +++ b/src/lib-storage/mail-search.h Thu Mar 13 15:55:44 2008 +0200 @@ -39,7 +39,8 @@ enum mail_search_arg_type { SEARCH_TEXT_FAST, /* extensions */ - SEARCH_MODSEQ + SEARCH_MODSEQ, + SEARCH_GUID }; enum mail_search_modseq_type {