[dovecot-cvs] dovecot/src/imap Makefile.am, 1.25, 1.26 client.h,
1.18, 1.19 cmd-idle.c, 1.10, 1.11 cmd-select.c, 1.27,
1.28 cmd-status.c, 1.17, 1.18 cmd-store.c, 1.23,
1.24 commands-util.c, 1.32, 1.33 imap-fetch.c, 1.19,
1.20 imap-sync.c, NONE, 1.1 imap-sync.h, NONE,
1.1 mail-storage-callbacks.c, 1.10, 1.11
cras at dovecot.org
cras at dovecot.org
Mon Jul 12 14:35:53 EEST 2004
- Previous message: [dovecot-cvs] dovecot/src/lib-imap imap-util.c, 1.11,
1.12 imap-util.h, 1.9, 1.10
- Next message: [dovecot-cvs] dovecot/src/lib-storage mail-storage-private.h, 1.4,
1.5 mail-storage.c, 1.25, 1.26 mail-storage.h, 1.71,
1.72 proxy-mailbox.c, 1.7, 1.8
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/dovecot/src/imap
In directory talvi:/tmp/cvs-serv2470/imap
Modified Files:
Makefile.am client.h cmd-idle.c cmd-select.c cmd-status.c
cmd-store.c commands-util.c imap-fetch.c
mail-storage-callbacks.c
Added Files:
imap-sync.c imap-sync.h
Log Message:
Broke mailbox_sync() into iterator.
Index: Makefile.am
===================================================================
RCS file: /home/cvs/dovecot/src/imap/Makefile.am,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- Makefile.am 27 Apr 2004 20:25:52 -0000 1.25
+++ Makefile.am 12 Jul 2004 11:35:50 -0000 1.26
@@ -68,6 +68,7 @@
imap-messageset.c \
imap-search.c \
imap-sort.c \
+ imap-sync.c \
imap-thread.c \
mail-storage-callbacks.c \
main.c \
@@ -84,5 +85,6 @@
imap-messageset.h \
imap-search.h \
imap-sort.h \
+ imap-sync.h \
imap-thread.h \
namespace.h
Index: client.h
===================================================================
RCS file: /home/cvs/dovecot/src/imap/client.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- client.h 2 May 2004 20:32:15 -0000 1.18
+++ client.h 12 Jul 2004 11:35:50 -0000 1.19
@@ -25,6 +25,7 @@
struct mailbox *mailbox;
struct mailbox_keywords keywords;
unsigned int select_counter; /* increased when mailbox is changed */
+ uint32_t messages_count, recent_count;
time_t last_input;
unsigned int bad_counter;
Index: cmd-idle.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/cmd-idle.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- cmd-idle.c 27 Apr 2004 20:25:52 -0000 1.10
+++ cmd-idle.c 12 Jul 2004 11:35:50 -0000 1.11
@@ -5,6 +5,7 @@
#include "istream.h"
#include "ostream.h"
#include "commands.h"
+#include "imap-sync.h"
#include <stdlib.h>
@@ -19,7 +20,7 @@
o_stream_cork(client->output);
- if (client->idle_expunge) {
+ if (client->idle_expunge != 0) {
client_send_line(client,
t_strdup_printf("* %u EXPUNGE", client->idle_expunge));
}
@@ -28,12 +29,8 @@
client->io = io_add(i_stream_get_fd(client->input),
IO_READ, _client_input, client);
- if (client->mailbox != NULL) {
- mailbox_auto_sync(client->mailbox, mailbox_check_interval != 0 ?
- MAILBOX_SYNC_FLAG_NO_EXPUNGES :
- MAILBOX_SYNC_AUTO_STOP,
- mailbox_check_interval);
- }
+ if (client->mailbox != NULL)
+ mailbox_notify_changes(client->mailbox, 0, NULL, NULL);
client_sync_full(client);
if (done_ok)
@@ -78,21 +75,28 @@
static void idle_timeout(void *context)
{
struct client *client = context;
- struct mailbox_status status;
+
+ /* outlook workaround - it hasn't sent anything for a long time and
+ we're about to disconnect unless it does something. send a fake
+ EXISTS to see if it responds. it's expunged later. */
timeout_remove(client->idle_to);
client->idle_to = NULL;
- if (mailbox_get_status(client->mailbox, STATUS_MESSAGES, &status) < 0) {
+ client->idle_expunge = client->messages_count+1;
+ client_send_line(client,
+ t_strdup_printf("* %u EXISTS", client->idle_expunge));
+ mailbox_notify_changes(client->mailbox, 0, NULL, NULL);
+}
+
+static void idle_callback(struct mailbox *box, void *context)
+{
+ struct client *client = context;
+
+ if (imap_sync(client, box, 0) < 0) {
client_send_untagged_storage_error(client,
mailbox_get_storage(client->mailbox));
- idle_finish(client, TRUE);
- } else {
- client->idle_expunge = status.messages+1;
- client_send_line(client,
- t_strdup_printf("* %u EXISTS", client->idle_expunge));
-
- mailbox_auto_sync(client->mailbox, MAILBOX_SYNC_AUTO_STOP, 0);
+ mailbox_notify_changes(client->mailbox, 0, NULL, NULL);
}
}
@@ -113,9 +117,10 @@
if (interval == 0)
interval = DEFAULT_IDLE_CHECK_INTERVAL;
- if (client->mailbox != NULL)
- mailbox_auto_sync(client->mailbox, 0, interval);
-
+ if (client->mailbox != NULL) {
+ mailbox_notify_changes(client->mailbox, interval,
+ idle_callback, client);
+ }
client_send_line(client, "+ idling");
io_remove(client->io);
Index: cmd-select.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/cmd-select.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- cmd-select.c 20 Jun 2004 03:25:33 -0000 1.27
+++ cmd-select.c 12 Jul 2004 11:35:50 -0000 1.28
@@ -2,6 +2,7 @@
#include "common.h"
#include "commands.h"
+#include "imap-sync.h"
int _cmd_select_full(struct client *client, int readonly)
{
@@ -34,6 +35,12 @@
return TRUE;
}
+ if (imap_sync(client, box, 0) < 0) {
+ client_send_storage_error(client, storage);
+ mailbox_close(box);
+ return TRUE;
+ }
+
if (mailbox_get_status(box, STATUS_MESSAGES | STATUS_RECENT |
STATUS_FIRST_UNSEEN_SEQ | STATUS_UIDVALIDITY |
STATUS_UIDNEXT | STATUS_KEYWORDS,
@@ -45,6 +52,8 @@
client_save_keywords(&client->keywords,
status.keywords, status.keywords_count);
+ client->messages_count = status.messages;
+ client->recent_count = status.recent;
/* set client's mailbox only after getting status to make sure
we're not sending any expunge/exists replies too early to client */
@@ -81,12 +90,6 @@
client_send_tagline(client, mailbox_is_readonly(box) ?
"OK [READ-ONLY] Select completed." :
"OK [READ-WRITE] Select completed.");
-
- if (mailbox_check_interval != 0) {
- mailbox_auto_sync(box, MAILBOX_SYNC_FLAG_NO_EXPUNGES,
- mailbox_check_interval);
- }
-
return TRUE;
}
Index: cmd-status.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/cmd-status.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- cmd-status.c 20 Jun 2004 03:25:33 -0000 1.17
+++ cmd-status.c 12 Jul 2004 11:35:50 -0000 1.18
@@ -4,6 +4,7 @@
#include "str.h"
#include "imap-quote.h"
#include "commands.h"
+#include "imap-sync.h"
/* Returns status items, or -1 if error */
static enum mailbox_status_items
@@ -64,7 +65,10 @@
return FALSE;
}
- failed = mailbox_get_status(box, items, status) < 0;
+ if (imap_sync(client, box, 0) < 0)
+ failed = TRUE;
+ else
+ failed = mailbox_get_status(box, items, status) < 0;
if (box != client->mailbox)
mailbox_close(box);
Index: cmd-store.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/cmd-store.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- cmd-store.c 2 May 2004 20:32:15 -0000 1.23
+++ cmd-store.c 12 Jul 2004 11:35:50 -0000 1.24
@@ -1,6 +1,7 @@
/* Copyright (C) 2002 Timo Sirainen */
#include "common.h"
+#include "str.h"
#include "commands.h"
#include "imap-search.h"
#include "imap-util.h"
@@ -37,19 +38,21 @@
static int mail_send_flags(struct client *client, struct mail *mail)
{
const struct mail_full_flags *flags;
- const char *str;
+ string_t *str;
flags = mail->get_flags(mail);
if (flags == NULL)
return FALSE;
t_push();
- str = imap_write_flags(flags);
- str = t_strdup_printf(client->cmd_uid ?
- "* %u FETCH (FLAGS (%s) UID %u)" :
- "* %u FETCH (FLAGS (%s))",
- mail->seq, str, mail->uid);
- client_send_line(client, str);
+ str = t_str_new(128);
+ str_printfa(str, "* %u FETCH (FLAGS (", mail->seq);
+ imap_write_flags(str, flags);
+ if (client->cmd_uid)
+ str_printfa(str, ") UID %u)", mail->uid);
+ else
+ str_append(str, "))");
+ client_send_line(client, str_c(str));
t_pop();
return TRUE;
Index: commands-util.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/commands-util.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- commands-util.c 20 Jun 2004 03:25:33 -0000 1.32
+++ commands-util.c 12 Jul 2004 11:35:50 -0000 1.33
@@ -7,6 +7,7 @@
#include "imap-util.h"
#include "mail-storage.h"
#include "imap-parser.h"
+#include "imap-sync.h"
#include "namespace.h"
/* Maximum length for mailbox name, including it's path. This isn't fully
@@ -116,7 +117,7 @@
if (client->mailbox == NULL)
return;
- if (mailbox_sync(client->mailbox, 0) < 0) {
+ if (imap_sync(client, client->mailbox, 0) < 0) {
client_send_untagged_storage_error(client,
mailbox_get_storage(client->mailbox));
}
@@ -127,7 +128,7 @@
if (client->mailbox == NULL)
return;
- if (mailbox_sync(client->mailbox, MAILBOX_SYNC_FLAG_FAST) < 0) {
+ if (imap_sync(client, client->mailbox, MAILBOX_SYNC_FLAG_FAST) < 0) {
client_send_untagged_storage_error(client,
mailbox_get_storage(client->mailbox));
}
@@ -138,8 +139,8 @@
if (client->mailbox == NULL)
return;
- if (mailbox_sync(client->mailbox, MAILBOX_SYNC_FLAG_FAST |
- MAILBOX_SYNC_FLAG_NO_EXPUNGES) < 0) {
+ if (imap_sync(client, client->mailbox, MAILBOX_SYNC_FLAG_FAST |
+ MAILBOX_SYNC_FLAG_NO_EXPUNGES) < 0) {
client_send_untagged_storage_error(client,
mailbox_get_storage(client->mailbox));
}
Index: imap-fetch.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/imap-fetch.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- imap-fetch.c 28 Apr 2004 18:57:13 -0000 1.19
+++ imap-fetch.c 12 Jul 2004 11:35:50 -0000 1.20
@@ -58,7 +58,9 @@
flags = &full_flags;
}
- str_printfa(ctx->str, "FLAGS (%s) ", imap_write_flags(flags));
+ str_append(ctx->str, "FLAGS (");
+ imap_write_flags(ctx->str, flags);
+ str_append(ctx->str, ") ");
return TRUE;
}
--- NEW FILE: imap-sync.c ---
/* Copyright (C) 2002 Timo Sirainen */
#include "common.h"
#include "str.h"
#include "imap-util.h"
#include "mail-storage.h"
#include "imap-sync.h"
int imap_sync(struct client *client, struct mailbox *box,
enum mailbox_sync_flags flags)
{
struct mailbox_transaction_context *t;
struct mailbox_sync_context *ctx;
struct mailbox_sync_rec sync_rec;
struct mailbox_status status;
struct mail *mail;
const struct mail_full_flags *mail_flags;
string_t *str;
uint32_t seq;
if (client->mailbox != box) {
/* mailbox isn't selected - we only wish to sync the mailbox
without sending anything to client */
ctx = mailbox_sync_init(box, flags);
while (mailbox_sync_next(ctx, &sync_rec) > 0)
;
return mailbox_sync_deinit(ctx, &status);
}
t_push();
str = t_str_new(256);
t = mailbox_transaction_begin(box, FALSE);
ctx = mailbox_sync_init(box, flags);
while (mailbox_sync_next(ctx, &sync_rec) > 0) {
switch (sync_rec.type) {
case MAILBOX_SYNC_TYPE_FLAGS:
for (seq = sync_rec.seq1; seq <= sync_rec.seq2; seq++) {
mail = mailbox_fetch(t, seq, MAIL_FETCH_FLAGS);
mail_flags = mail->get_flags(mail);
if (mail_flags == NULL)
continue;
str_truncate(str, 0);
str_printfa(str, "* %u FETCH (FLAGS (", seq);
imap_write_flags(str, mail_flags);
str_append(str, "))");
client_send_line(client, str_c(str));
}
break;
case MAILBOX_SYNC_TYPE_EXPUNGE:
for (seq = sync_rec.seq2; seq >= sync_rec.seq1; seq--) {
str_truncate(str, 0);
str_printfa(str, "* %u EXPUNGE", seq);
client_send_line(client, str_c(str));
}
break;
}
}
if (mailbox_sync_deinit(ctx, &status) < 0) {
mailbox_transaction_rollback(t);
t_pop();
return -1;
}
mailbox_transaction_commit(t);
if (status.messages != client->messages_count) {
client->messages_count = status.messages;
str_truncate(str, 0);
str_printfa(str, "* %u EXISTS", status.messages);
client_send_line(client, str_c(str));
}
if (status.recent != client->recent_count) {
client->recent_count = status.recent;
str_truncate(str, 0);
str_printfa(str, "* %u RECENT", status.recent);
client_send_line(client, str_c(str));
}
/*FIXME:client_save_keywords(&client->keywords, keywords, keywords_count);
client_send_mailbox_flags(client, mailbox, keywords, keywords_count);*/
t_pop();
return 0;
}
--- NEW FILE: imap-sync.h ---
#ifndef __IMAP_SYNC_H
#define __IMAP_SYNC_H
int imap_sync(struct client *client, struct mailbox *box,
enum mailbox_sync_flags flags);
#endif
Index: mail-storage-callbacks.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/mail-storage-callbacks.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- mail-storage-callbacks.c 25 May 2004 17:50:36 -0000 1.10
+++ mail-storage-callbacks.c 12 Jul 2004 11:35:50 -0000 1.11
@@ -33,79 +33,8 @@
o_stream_flush(client->output);
}
-static void expunge(struct mailbox *mailbox, unsigned int seq, void *context)
-{
- struct client *client = context;
- char str[MAX_INT_STRLEN+20];
-
- if (client->mailbox != mailbox)
- return;
-
- i_snprintf(str, sizeof(str), "* %u EXPUNGE", seq);
- client_send_line(client, str);
-}
-
-static void update_flags(struct mailbox *mailbox, unsigned int seq,
- const struct mail_full_flags *flags, void *context)
-{
- struct client *client = context;
- const char *str;
-
- if (client->mailbox != mailbox)
- return;
-
- t_push();
- str = imap_write_flags(flags);
- str = t_strdup_printf("* %u FETCH (FLAGS (%s))", seq, str);
- client_send_line(client, str);
- t_pop();
-}
-
-static void message_count_changed(struct mailbox *mailbox, unsigned int count,
- void *context)
-{
- struct client *client = context;
- char str[MAX_INT_STRLEN+20];
-
- if (client->mailbox != mailbox)
- return;
-
- i_snprintf(str, sizeof(str), "* %u EXISTS", count);
- client_send_line(client, str);
-}
-
-static void recent_count_changed(struct mailbox *mailbox, unsigned int count,
- void *context)
-{
- struct client *client = context;
- char str[MAX_INT_STRLEN+20];
-
- if (client->mailbox != mailbox)
- return;
-
- i_snprintf(str, sizeof(str), "* %u RECENT", count);
- client_send_line(client, str);
-}
-
-static void new_keywords(struct mailbox *mailbox, const char *keywords[],
- unsigned int keywords_count, void *context)
-{
- struct client *client = context;
-
- if (client->mailbox != mailbox)
- return;
-
- client_save_keywords(&client->keywords, keywords, keywords_count);
- client_send_mailbox_flags(client, mailbox, keywords, keywords_count);
-}
-
struct mail_storage_callbacks mail_storage_callbacks = {
alert_no_diskspace,
notify_ok,
- notify_no,
- expunge,
- update_flags,
- message_count_changed,
- recent_count_changed,
- new_keywords
+ notify_no
};
- Previous message: [dovecot-cvs] dovecot/src/lib-imap imap-util.c, 1.11,
1.12 imap-util.h, 1.9, 1.10
- Next message: [dovecot-cvs] dovecot/src/lib-storage mail-storage-private.h, 1.4,
1.5 mail-storage.c, 1.25, 1.26 mail-storage.h, 1.71,
1.72 proxy-mailbox.c, 1.7, 1.8
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list