annotate src/imap/imap-fetch.c @ 1926:982bd89b42fd HEAD

BYE if trying to fetch body[] of expunged message.
author Timo Sirainen <tss@iki.fi>
date Wed, 28 Apr 2004 21:57:13 +0300
parents 79790750c349
children aae574ed7f4c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
988
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
1 /* Copyright (C) 2002 Timo Sirainen */
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
2
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
3 #include "common.h"
1672
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
4 #include "buffer.h"
988
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
5 #include "istream.h"
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
6 #include "ostream.h"
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
7 #include "str.h"
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
8 #include "message-send.h"
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
9 #include "message-size.h"
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
10 #include "imap-date.h"
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
11 #include "commands.h"
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
12 #include "imap-fetch.h"
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents: 1845
diff changeset
13 #include "imap-util.h"
988
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
14
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
15 #include <unistd.h>
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
16
1672
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
17 const char *const *imap_fetch_get_body_fields(const char *fields)
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
18 {
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
19 const char **field_list, **field, **dest;
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
20
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
21 while (*fields == ' ')
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
22 fields++;
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
23 if (*fields == '(')
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
24 fields++;
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
25
1837
b730eeca8861 Don't request empty headers
Timo Sirainen <tss@iki.fi>
parents: 1820
diff changeset
26 field_list = t_strsplit_spaces(t_strcut(fields, ')'), " ");
1672
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
27
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
28 /* array ends at ")" element */
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
29 for (field = dest = field_list; *field != NULL; field++) {
1820
02bc3ef29b22 Added t_strsplit_spaces().
Timo Sirainen <tss@iki.fi>
parents: 1808
diff changeset
30 *dest = *field;
02bc3ef29b22 Added t_strsplit_spaces().
Timo Sirainen <tss@iki.fi>
parents: 1808
diff changeset
31 dest++;
1672
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
32 }
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
33 *dest = NULL;
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
34
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
35 return field_list;
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
36 }
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
37
988
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
38 static void fetch_uid(struct imap_fetch_context *ctx, struct mail *mail)
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
39 {
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
40 str_printfa(ctx->str, "UID %u ", mail->uid);
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
41 }
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
42
1638
e95c0e462591 API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents: 1534
diff changeset
43 static int fetch_flags(struct imap_fetch_context *ctx, struct mail *mail,
e95c0e462591 API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents: 1534
diff changeset
44 const struct mail_full_flags *flags)
988
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
45 {
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents: 1845
diff changeset
46 struct mail_full_flags full_flags;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents: 1845
diff changeset
47
1638
e95c0e462591 API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents: 1534
diff changeset
48 if (flags == NULL) {
e95c0e462591 API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents: 1534
diff changeset
49 flags = mail->get_flags(mail);
e95c0e462591 API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents: 1534
diff changeset
50 if (flags == NULL)
e95c0e462591 API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents: 1534
diff changeset
51 return FALSE;
e95c0e462591 API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents: 1534
diff changeset
52 }
988
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
53
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents: 1845
diff changeset
54 if (ctx->update_seen) {
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents: 1845
diff changeset
55 /* \Seen change isn't shown by get_flags() yet */
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents: 1845
diff changeset
56 full_flags = *flags;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents: 1845
diff changeset
57 full_flags.flags |= MAIL_SEEN;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents: 1845
diff changeset
58 flags = &full_flags;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents: 1845
diff changeset
59 }
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents: 1845
diff changeset
60
1638
e95c0e462591 API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents: 1534
diff changeset
61 str_printfa(ctx->str, "FLAGS (%s) ", imap_write_flags(flags));
988
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
62 return TRUE;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
63 }
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
64
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
65 static int fetch_internaldate(struct imap_fetch_context *ctx, struct mail *mail)
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
66 {
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
67 time_t time;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
68
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
69 time = mail->get_received_date(mail);
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
70 if (time == (time_t)-1)
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
71 return FALSE;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
72
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
73 str_printfa(ctx->str, "INTERNALDATE \"%s\" ", imap_to_datetime(time));
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
74 return TRUE;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
75 }
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
76
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
77 static int fetch_rfc822_size(struct imap_fetch_context *ctx, struct mail *mail)
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
78 {
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
79 uoff_t size;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
80
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
81 size = mail->get_size(mail);
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
82 if (size == (uoff_t)-1)
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
83 return FALSE;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
84
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
85 str_printfa(ctx->str, "RFC822.SIZE %"PRIuUOFF_T" ", size);
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
86 return TRUE;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
87 }
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
88
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
89 static int fetch_body(struct imap_fetch_context *ctx, struct mail *mail)
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
90 {
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
91 const char *body;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
92
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
93 body = mail->get_special(mail, MAIL_FETCH_IMAP_BODY);
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
94 if (body == NULL)
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
95 return FALSE;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
96
1764
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
97 if (ctx->first) {
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
98 if (o_stream_send_str(ctx->output, "BODY (") < 0)
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
99 return FALSE;
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
100 ctx->first = FALSE;
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
101 } else {
1766
53e06e33393f Missing spaces in ENVELOPE, BODY and BODYSTRUCTURE replies.
Timo Sirainen <tss@iki.fi>
parents: 1764
diff changeset
102 if (o_stream_send_str(ctx->output, " BODY (") < 0)
1764
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
103 return FALSE;
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
104 }
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
105
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
106 if (o_stream_send_str(ctx->output, body) < 0)
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
107 return FALSE;
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
108
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
109 if (o_stream_send(ctx->output, ")", 1) < 0)
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
110 return FALSE;
988
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
111 return TRUE;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
112 }
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
113
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
114 static int fetch_bodystructure(struct imap_fetch_context *ctx,
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
115 struct mail *mail)
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
116 {
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
117 const char *bodystructure;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
118
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
119 bodystructure = mail->get_special(mail, MAIL_FETCH_IMAP_BODYSTRUCTURE);
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
120 if (bodystructure == NULL)
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
121 return FALSE;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
122
1764
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
123 if (ctx->first) {
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
124 if (o_stream_send_str(ctx->output, "BODYSTRUCTURE (") < 0)
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
125 return FALSE;
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
126 ctx->first = FALSE;
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
127 } else {
1766
53e06e33393f Missing spaces in ENVELOPE, BODY and BODYSTRUCTURE replies.
Timo Sirainen <tss@iki.fi>
parents: 1764
diff changeset
128 if (o_stream_send_str(ctx->output, " BODYSTRUCTURE (") < 0)
1764
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
129 return FALSE;
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
130 }
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
131
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
132 if (o_stream_send_str(ctx->output, bodystructure) < 0)
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
133 return FALSE;
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
134
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
135 if (o_stream_send(ctx->output, ")", 1) < 0)
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
136 return FALSE;
988
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
137 return TRUE;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
138 }
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
139
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
140 static int fetch_envelope(struct imap_fetch_context *ctx, struct mail *mail)
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
141 {
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
142 const char *envelope;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
143
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
144 envelope = mail->get_special(mail, MAIL_FETCH_IMAP_ENVELOPE);
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
145 if (envelope == NULL)
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
146 return FALSE;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
147
1764
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
148 if (ctx->first) {
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
149 if (o_stream_send_str(ctx->output, "ENVELOPE (") < 0)
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
150 return FALSE;
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
151 ctx->first = FALSE;
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
152 } else {
1766
53e06e33393f Missing spaces in ENVELOPE, BODY and BODYSTRUCTURE replies.
Timo Sirainen <tss@iki.fi>
parents: 1764
diff changeset
153 if (o_stream_send_str(ctx->output, " ENVELOPE (") < 0)
1764
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
154 return FALSE;
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
155 }
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
156
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
157 if (o_stream_send_str(ctx->output, envelope) < 0)
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
158 return FALSE;
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
159
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
160 if (o_stream_send(ctx->output, ")", 1) < 0)
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
161 return FALSE;
988
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
162 return TRUE;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
163 }
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
164
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
165 static int fetch_send_rfc822(struct imap_fetch_context *ctx, struct mail *mail)
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
166 {
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
167 struct message_size hdr_size, body_size;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
168 struct istream *stream;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
169 const char *str;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
170
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
171 stream = mail->get_stream(mail, &hdr_size, &body_size);
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
172 if (stream == NULL)
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
173 return FALSE;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
174
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
175 message_size_add(&body_size, &hdr_size);
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
176
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
177 str = t_strdup_printf(" RFC822 {%"PRIuUOFF_T"}\r\n",
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
178 body_size.virtual_size);
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
179 if (ctx->first) {
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
180 str++; ctx->first = FALSE;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
181 }
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
182 if (o_stream_send_str(ctx->output, str) < 0)
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
183 return FALSE;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
184
991
21788a1e9e39 Partial fetches are working fast again - faster than ever actually.
Timo Sirainen <tss@iki.fi>
parents: 988
diff changeset
185 return message_send(ctx->output, stream, &body_size,
1808
36d0e23dc231 BODY[HEADER] and RFC822.HEADER fetching was broken (why did it work before?..)
Timo Sirainen <tss@iki.fi>
parents: 1782
diff changeset
186 0, body_size.virtual_size, NULL,
36d0e23dc231 BODY[HEADER] and RFC822.HEADER fetching was broken (why did it work before?..)
Timo Sirainen <tss@iki.fi>
parents: 1782
diff changeset
187 !mail->has_no_nuls) >= 0;
988
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
188 }
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
189
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
190 static int fetch_send_rfc822_header(struct imap_fetch_context *ctx,
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
191 struct mail *mail)
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
192 {
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
193 struct message_size hdr_size;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
194 struct istream *stream;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
195 const char *str;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
196
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
197 stream = mail->get_stream(mail, &hdr_size, NULL);
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
198 if (stream == NULL)
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
199 return FALSE;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
200
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
201 str = t_strdup_printf(" RFC822.HEADER {%"PRIuUOFF_T"}\r\n",
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
202 hdr_size.virtual_size);
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
203 if (ctx->first) {
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
204 str++; ctx->first = FALSE;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
205 }
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
206 if (o_stream_send_str(ctx->output, str) < 0)
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
207 return FALSE;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
208
1391
e0dbaabbc22b Partial fetches were broken when they stopped between virtual CR and LF.
Timo Sirainen <tss@iki.fi>
parents: 996
diff changeset
209 return message_send(ctx->output, stream, &hdr_size,
1808
36d0e23dc231 BODY[HEADER] and RFC822.HEADER fetching was broken (why did it work before?..)
Timo Sirainen <tss@iki.fi>
parents: 1782
diff changeset
210 0, hdr_size.virtual_size, NULL,
36d0e23dc231 BODY[HEADER] and RFC822.HEADER fetching was broken (why did it work before?..)
Timo Sirainen <tss@iki.fi>
parents: 1782
diff changeset
211 !mail->has_no_nuls) >= 0;
988
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
212 }
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
213
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
214 static int fetch_send_rfc822_text(struct imap_fetch_context *ctx,
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
215 struct mail *mail)
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
216 {
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
217 struct message_size hdr_size, body_size;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
218 struct istream *stream;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
219 const char *str;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
220
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
221 stream = mail->get_stream(mail, &hdr_size, &body_size);
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
222 if (stream == NULL)
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
223 return FALSE;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
224
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
225 str = t_strdup_printf(" RFC822.TEXT {%"PRIuUOFF_T"}\r\n",
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
226 body_size.virtual_size);
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
227 if (ctx->first) {
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
228 str++; ctx->first = FALSE;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
229 }
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
230 if (o_stream_send_str(ctx->output, str) < 0)
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
231 return FALSE;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
232
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
233 i_stream_seek(stream, hdr_size.physical_size);
991
21788a1e9e39 Partial fetches are working fast again - faster than ever actually.
Timo Sirainen <tss@iki.fi>
parents: 988
diff changeset
234 return message_send(ctx->output, stream, &body_size,
1808
36d0e23dc231 BODY[HEADER] and RFC822.HEADER fetching was broken (why did it work before?..)
Timo Sirainen <tss@iki.fi>
parents: 1782
diff changeset
235 0, body_size.virtual_size, NULL,
36d0e23dc231 BODY[HEADER] and RFC822.HEADER fetching was broken (why did it work before?..)
Timo Sirainen <tss@iki.fi>
parents: 1782
diff changeset
236 !mail->has_no_nuls) >= 0;
988
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
237 }
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
238
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
239 static int fetch_mail(struct imap_fetch_context *ctx, struct mail *mail)
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
240 {
1638
e95c0e462591 API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents: 1534
diff changeset
241 const struct mail_full_flags *flags;
988
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
242 struct imap_fetch_body_data *body;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
243 size_t len, orig_len;
1638
e95c0e462591 API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents: 1534
diff changeset
244 int failed, data_written, seen_updated = FALSE;
e95c0e462591 API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents: 1534
diff changeset
245
e95c0e462591 API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents: 1534
diff changeset
246 if (!ctx->update_seen)
e95c0e462591 API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents: 1534
diff changeset
247 flags = NULL;
e95c0e462591 API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents: 1534
diff changeset
248 else {
e95c0e462591 API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents: 1534
diff changeset
249 flags = mail->get_flags(mail);
e95c0e462591 API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents: 1534
diff changeset
250 if (flags == NULL)
e95c0e462591 API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents: 1534
diff changeset
251 return FALSE;
e95c0e462591 API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents: 1534
diff changeset
252
e95c0e462591 API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents: 1534
diff changeset
253 if ((flags->flags & MAIL_SEEN) == 0) {
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents: 1845
diff changeset
254 if (mail->update_flags(mail, &ctx->seen_flag,
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents: 1845
diff changeset
255 MODIFY_ADD) < 0)
1638
e95c0e462591 API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents: 1534
diff changeset
256 return FALSE;
e95c0e462591 API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents: 1534
diff changeset
257 seen_updated = TRUE;
e95c0e462591 API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents: 1534
diff changeset
258 }
e95c0e462591 API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents: 1534
diff changeset
259 }
988
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
260
994
ab4091b2ddc2 FETCH ate too much memory
Timo Sirainen <tss@iki.fi>
parents: 991
diff changeset
261 t_push();
ab4091b2ddc2 FETCH ate too much memory
Timo Sirainen <tss@iki.fi>
parents: 991
diff changeset
262
988
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
263 str_truncate(ctx->str, 0);
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
264 str_printfa(ctx->str, "* %u FETCH (", mail->seq);
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
265 orig_len = str_len(ctx->str);
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
266
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
267 failed = TRUE;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
268 data_written = FALSE;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
269 do {
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
270 /* write the data into temp string */
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
271 if (ctx->imap_data & IMAP_FETCH_UID)
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
272 fetch_uid(ctx, mail);
1638
e95c0e462591 API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents: 1534
diff changeset
273 if ((ctx->fetch_data & MAIL_FETCH_FLAGS) || seen_updated)
e95c0e462591 API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents: 1534
diff changeset
274 if (!fetch_flags(ctx, mail, flags))
994
ab4091b2ddc2 FETCH ate too much memory
Timo Sirainen <tss@iki.fi>
parents: 991
diff changeset
275 break;
988
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
276 if (ctx->fetch_data & MAIL_FETCH_RECEIVED_DATE)
994
ab4091b2ddc2 FETCH ate too much memory
Timo Sirainen <tss@iki.fi>
parents: 991
diff changeset
277 if (!fetch_internaldate(ctx, mail))
ab4091b2ddc2 FETCH ate too much memory
Timo Sirainen <tss@iki.fi>
parents: 991
diff changeset
278 break;
988
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
279 if (ctx->fetch_data & MAIL_FETCH_SIZE)
994
ab4091b2ddc2 FETCH ate too much memory
Timo Sirainen <tss@iki.fi>
parents: 991
diff changeset
280 if (!fetch_rfc822_size(ctx, mail))
ab4091b2ddc2 FETCH ate too much memory
Timo Sirainen <tss@iki.fi>
parents: 991
diff changeset
281 break;
988
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
282
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
283 /* send the data written into temp string */
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
284 len = str_len(ctx->str);
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
285 ctx->first = len == orig_len;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
286
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
287 if (!ctx->first)
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
288 str_truncate(ctx->str, --len);
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
289 if (o_stream_send(ctx->output, str_data(ctx->str), len) < 0)
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
290 break;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
291
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
292 data_written = TRUE;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
293
1764
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
294 /* medium size data .. seems to be faster without
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
295 putting through string */
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
296 if (ctx->fetch_data & MAIL_FETCH_IMAP_BODY)
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
297 if (!fetch_body(ctx, mail))
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
298 break;
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
299 if (ctx->fetch_data & MAIL_FETCH_IMAP_BODYSTRUCTURE)
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
300 if (!fetch_bodystructure(ctx, mail))
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
301 break;
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
302 if (ctx->fetch_data & MAIL_FETCH_IMAP_ENVELOPE)
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
303 if(!fetch_envelope(ctx, mail))
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
304 break;
fbb28b07c60f Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
305
988
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
306 /* large data */
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
307 if (ctx->imap_data & IMAP_FETCH_RFC822)
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
308 if (!fetch_send_rfc822(ctx, mail))
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
309 break;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
310 if (ctx->imap_data & IMAP_FETCH_RFC822_HEADER)
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
311 if (!fetch_send_rfc822_header(ctx, mail))
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
312 break;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
313 if (ctx->imap_data & IMAP_FETCH_RFC822_TEXT)
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
314 if (!fetch_send_rfc822_text(ctx, mail))
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
315 break;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
316
1926
982bd89b42fd BYE if trying to fetch body[] of expunged message.
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
317 failed = FALSE;
982bd89b42fd BYE if trying to fetch body[] of expunged message.
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
318
988
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
319 for (body = ctx->bodies; body != NULL; body = body->next) {
1926
982bd89b42fd BYE if trying to fetch body[] of expunged message.
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
320 if (!imap_fetch_body_section(ctx, body, mail)) {
982bd89b42fd BYE if trying to fetch body[] of expunged message.
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
321 failed = TRUE;
988
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
322 break;
1926
982bd89b42fd BYE if trying to fetch body[] of expunged message.
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
323 }
988
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
324 }
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
325 } while (0);
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
326
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
327 if (data_written) {
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
328 if (o_stream_send(ctx->output, ")\r\n", 3) < 0)
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
329 failed = TRUE;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
330 }
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
331
994
ab4091b2ddc2 FETCH ate too much memory
Timo Sirainen <tss@iki.fi>
parents: 991
diff changeset
332 t_pop();
988
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
333 return !failed;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
334 }
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
335
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
336 int imap_fetch(struct client *client,
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
337 enum mail_fetch_field fetch_data,
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
338 enum imap_fetch_field imap_data,
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
339 struct imap_fetch_body_data *bodies,
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents: 1845
diff changeset
340 struct mail_search_arg *search_args)
988
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
341 {
1639
3621292209f4 Explicit lock() method for mailbox.
Timo Sirainen <tss@iki.fi>
parents: 1638
diff changeset
342 struct mailbox *box = client->mailbox;
988
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
343 struct imap_fetch_context ctx;
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents: 1845
diff changeset
344 struct mailbox_transaction_context *t;
988
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
345 struct mail *mail;
1672
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
346 struct imap_fetch_body_data *body;
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
347 const char *null = NULL;
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
348 const char *const *wanted_headers, *const *arr;
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
349 buffer_t *buffer;
1638
e95c0e462591 API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents: 1534
diff changeset
350
e95c0e462591 API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents: 1534
diff changeset
351 memset(&ctx, 0, sizeof(ctx));
e95c0e462591 API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents: 1534
diff changeset
352 ctx.fetch_data = fetch_data;
e95c0e462591 API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents: 1534
diff changeset
353 ctx.imap_data = imap_data;
e95c0e462591 API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents: 1534
diff changeset
354 ctx.bodies = bodies;
e95c0e462591 API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents: 1534
diff changeset
355 ctx.output = client->output;
e95c0e462591 API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents: 1534
diff changeset
356 ctx.select_counter = client->select_counter;
e95c0e462591 API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents: 1534
diff changeset
357 ctx.seen_flag.flags = MAIL_SEEN;
988
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
358
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents: 1845
diff changeset
359 if (!mailbox_is_readonly(box)) {
988
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
360 /* If we have any BODY[..] sections, \Seen flag is added for
1672
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
361 all messages. */
988
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
362 for (body = bodies; body != NULL; body = body->next) {
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
363 if (!body->peek) {
1638
e95c0e462591 API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents: 1534
diff changeset
364 ctx.update_seen = TRUE;
988
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
365 break;
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
366 }
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
367 }
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
368
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
369 if (imap_data & (IMAP_FETCH_RFC822|IMAP_FETCH_RFC822_TEXT))
1638
e95c0e462591 API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents: 1534
diff changeset
370 ctx.update_seen = TRUE;
988
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
371 }
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
372
1672
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
373 /* If we have only BODY[HEADER.FIELDS (...)] fetches, get them
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
374 separately rather than parsing the full header so mail storage
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
375 can try to cache them. */
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
376 ctx.body_fetch_from_cache = TRUE;
1782
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1766
diff changeset
377 buffer = buffer_create_dynamic(pool_datastack_create(), 64, (size_t)-1);
1672
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
378 for (body = bodies; body != NULL; body = body->next) {
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
379 if (strncmp(body->section, "HEADER.FIELDS ", 14) != 0) {
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
380 ctx.body_fetch_from_cache = FALSE;
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
381 break;
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
382 }
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
383
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
384 arr = imap_fetch_get_body_fields(body->section + 14);
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
385 while (*arr != NULL) {
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
386 buffer_append(buffer, arr, sizeof(*arr));
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
387 arr++;
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
388 }
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
389 }
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
390 buffer_append(buffer, &null, sizeof(null));
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
391 wanted_headers = !ctx.body_fetch_from_cache ? NULL :
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
392 buffer_get_data(buffer, NULL);
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1642
diff changeset
393
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents: 1845
diff changeset
394 t = mailbox_transaction_begin(box, TRUE);
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents: 1845
diff changeset
395 ctx.search_ctx = mailbox_search_init(t, NULL, search_args, NULL,
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents: 1845
diff changeset
396 fetch_data, wanted_headers);
1845
bd8b6ed35327 Removed fetch_init/fetch_next from mail-storage. search_* makes it
Timo Sirainen <tss@iki.fi>
parents: 1837
diff changeset
397 if (ctx.search_ctx == NULL)
1639
3621292209f4 Explicit lock() method for mailbox.
Timo Sirainen <tss@iki.fi>
parents: 1638
diff changeset
398 ctx.failed = TRUE;
3621292209f4 Explicit lock() method for mailbox.
Timo Sirainen <tss@iki.fi>
parents: 1638
diff changeset
399 else {
3621292209f4 Explicit lock() method for mailbox.
Timo Sirainen <tss@iki.fi>
parents: 1638
diff changeset
400 ctx.str = str_new(default_pool, 8192);
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents: 1845
diff changeset
401 while ((mail = mailbox_search_next(ctx.search_ctx)) != NULL) {
1639
3621292209f4 Explicit lock() method for mailbox.
Timo Sirainen <tss@iki.fi>
parents: 1638
diff changeset
402 if (!fetch_mail(&ctx, mail)) {
3621292209f4 Explicit lock() method for mailbox.
Timo Sirainen <tss@iki.fi>
parents: 1638
diff changeset
403 ctx.failed = TRUE;
3621292209f4 Explicit lock() method for mailbox.
Timo Sirainen <tss@iki.fi>
parents: 1638
diff changeset
404 break;
3621292209f4 Explicit lock() method for mailbox.
Timo Sirainen <tss@iki.fi>
parents: 1638
diff changeset
405 }
988
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
406 }
1639
3621292209f4 Explicit lock() method for mailbox.
Timo Sirainen <tss@iki.fi>
parents: 1638
diff changeset
407 str_free(ctx.str);
988
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
408
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents: 1845
diff changeset
409 if (mailbox_search_deinit(ctx.search_ctx) < 0)
1639
3621292209f4 Explicit lock() method for mailbox.
Timo Sirainen <tss@iki.fi>
parents: 1638
diff changeset
410 ctx.failed = TRUE;
3621292209f4 Explicit lock() method for mailbox.
Timo Sirainen <tss@iki.fi>
parents: 1638
diff changeset
411 }
3621292209f4 Explicit lock() method for mailbox.
Timo Sirainen <tss@iki.fi>
parents: 1638
diff changeset
412
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents: 1845
diff changeset
413 if (ctx.failed)
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents: 1845
diff changeset
414 mailbox_transaction_rollback(t);
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents: 1845
diff changeset
415 else {
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents: 1845
diff changeset
416 if (mailbox_transaction_commit(t) < 0)
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents: 1845
diff changeset
417 ctx.failed = TRUE;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents: 1845
diff changeset
418 }
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents: 1845
diff changeset
419 return ctx.failed ? -1 : 0;
988
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
420 }