[dovecot-cvs] dovecot/src/imap imap-fetch.c,1.44,1.45
cras at dovecot.org
cras at dovecot.org
Fri Aug 4 20:46:13 EEST 2006
Update of /var/lib/cvs/dovecot/src/imap
In directory talvi:/tmp/cvs-serv32668
Modified Files:
imap-fetch.c
Log Message:
When mailbox changes are noticed and they're sent to client, cork before
doing it so each command isn't sent in a separate packet.
Index: imap-fetch.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/imap/imap-fetch.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- imap-fetch.c 28 Jun 2006 13:10:32 -0000 1.44
+++ imap-fetch.c 4 Aug 2006 17:46:11 -0000 1.45
@@ -8,6 +8,7 @@
#include "str.h"
#include "message-send.h"
#include "message-size.h"
+#include "message-parser.h"
#include "imap-date.h"
#include "commands.h"
#include "imap-fetch.h"
@@ -15,7 +16,7 @@
#include <stdlib.h>
-const struct imap_fetch_handler default_handlers[7];
+const struct imap_fetch_handler default_handlers[8];
static buffer_t *fetch_handlers = NULL;
static int imap_fetch_handler_cmp(const void *p1, const void *p2)
@@ -516,12 +517,51 @@
return TRUE;
}
-const struct imap_fetch_handler default_handlers[7] = {
+static uoff_t textsize_count(const struct message_part *part)
+{
+ uoff_t size = 0;
+
+ for (; part != NULL; part = part->next) {
+ if (part->flags & (MESSAGE_PART_FLAG_TEXT |
+ MESSAGE_PART_FLAG_MESSAGE_RFC822)) {
+ size += part->header_size.physical_size +
+ part->body_size.physical_size;
+ }
+ if (part->children != NULL)
+ size += textsize_count(part->children);
+ }
+ return size;
+}
+
+static int fetch_textsize(struct imap_fetch_context *ctx, struct mail *mail,
+ void *context __attr_unused__)
+{
+ const struct message_part *part;
+
+ part = mail_get_parts(mail);
+ if (part == NULL)
+ return -1;
+
+ str_printfa(ctx->cur_str, "TEXTSIZE %"PRIuUOFF_T" ",
+ textsize_count(part));
+ return 1;
+}
+
+static bool fetch_textsize_init(struct imap_fetch_context *ctx __attr_unused__,
+ const char *name __attr_unused__,
+ struct imap_arg **args __attr_unused__)
+{
+ imap_fetch_add_handler(ctx, TRUE, FALSE, fetch_textsize, NULL);
+ return TRUE;
+}
+
+const struct imap_fetch_handler default_handlers[8] = {
{ "BODY", fetch_body_init },
{ "BODYSTRUCTURE", fetch_bodystructure_init },
{ "ENVELOPE", fetch_envelope_init },
{ "FLAGS", fetch_flags_init },
{ "INTERNALDATE", fetch_internaldate_init },
{ "RFC822", fetch_rfc822_init },
+ { "TEXTSIZE", fetch_textsize_init },
{ "UID", fetch_uid_init }
};
More information about the dovecot-cvs
mailing list