[dovecot-cvs] dovecot/src/pop3 client.c, 1.34, 1.35 client.h, 1.6,
1.7 commands.c, 1.26, 1.27 common.h, 1.3, 1.4 main.c, 1.14, 1.15
cras at dovecot.org
cras at dovecot.org
Sun Sep 12 17:27:01 EEST 2004
Update of /var/lib/cvs/dovecot/src/pop3
In directory talvi:/tmp/cvs-serv5006/src/pop3
Modified Files:
client.c client.h commands.c common.h main.c
Log Message:
Added pop3_enable_last setting to enable deprecated LAST command.
Index: client.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/pop3/client.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- client.c 1 Sep 2004 14:28:25 -0000 1.34
+++ client.c 12 Sep 2004 14:26:58 -0000 1.35
@@ -71,7 +71,9 @@
return FALSE;
}
+ client->last_seen = 0;
client->messages_count = status.messages;
+ client->total_size = 0;
client->deleted_size = 0;
if (client->messages_count == 0)
@@ -89,16 +91,20 @@
return FALSE;
}
- client->total_size = 0;
- client->deleted_size = 0;
failed = FALSE;
while ((mail = mailbox_search_next(ctx)) != NULL) {
uoff_t size = mail->get_virtual_size(mail);
+ const struct mail_full_flags *flags;
- if (size == (uoff_t)-1) {
+ flags = mail->get_flags(mail);
+
+ if (flags == NULL || size == (uoff_t)-1) {
failed = TRUE;
break;
}
+
+ if ((flags->flags & MAIL_SEEN) != 0)
+ client->last_seen = mail->seq;
client->total_size += size;
i_assert(mail->seq <= client->messages_count);
Index: client.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/pop3/client.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- client.h 15 Aug 2004 03:40:32 -0000 1.6
+++ client.h 12 Sep 2004 14:26:58 -0000 1.7
@@ -26,6 +26,7 @@
uoff_t *message_sizes;
uoff_t total_size;
uoff_t deleted_size;
+ uint32_t last_seen;
unsigned char *deleted_bitmask;
Index: commands.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/pop3/commands.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- commands.c 2 Sep 2004 10:48:35 -0000 1.26
+++ commands.c 12 Sep 2004 14:26:58 -0000 1.27
@@ -166,6 +166,12 @@
return TRUE;
}
+static int cmd_last(struct client *client, const char *args __attr_unused__)
+{
+ client_send_line(client, "+OK %u", client->last_seen);
+ return TRUE;
+}
+
static int cmd_noop(struct client *client, const char *args __attr_unused__)
{
client_send_line(client, "+OK");
@@ -380,12 +386,23 @@
if (get_msgnum(client, args, &msgnum) == NULL)
return FALSE;
+ if (client->last_seen <= msgnum)
+ client->last_seen = msgnum+1;
+
fetch(client, msgnum, (uoff_t)-1);
return TRUE;
}
static int cmd_rset(struct client *client, const char *args __attr_unused__)
{
+ struct mailbox_transaction_context *t;
+ struct mail_search_context *search_ctx;
+ struct mail *mail;
+ struct mail_search_arg search_arg;
+ struct mail_full_flags seen_flag;
+
+ client->last_seen = 0;
+
if (client->deleted) {
client->deleted = FALSE;
memset(client->deleted_bitmask, 0, MSGS_BITMASK_SIZE(client));
@@ -393,6 +410,26 @@
client->deleted_size = 0;
}
+ if (enable_last_command) {
+ /* remove all \Seen flags */
+ memset(&search_arg, 0, sizeof(search_arg));
+ search_arg.type = SEARCH_ALL;
+
+ memset(&seen_flag, 0, sizeof(seen_flag));
+ seen_flag.flags = MAIL_SEEN;
+
+ t = mailbox_transaction_begin(client->mailbox, FALSE);
+ search_ctx = mailbox_search_init(t, NULL, &search_arg,
+ NULL, 0, NULL);
+ while ((mail = mailbox_search_next(search_ctx)) != NULL) {
+ if (mail->update_flags(mail, &seen_flag,
+ MODIFY_REMOVE) < 0)
+ break;
+ }
+ (void)mailbox_search_deinit(search_ctx);
+ (void)mailbox_transaction_commit(t, 0);
+ }
+
client_send_line(client, "+OK");
return TRUE;
}
@@ -544,6 +581,8 @@
case 'L':
if (strcmp(name, "LIST") == 0)
return cmd_list(client, args);
+ if (strcmp(name, "LAST") == 0 && enable_last_command)
+ return cmd_last(client, args);
break;
case 'N':
if (strcmp(name, "NOOP") == 0)
Index: common.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/pop3/common.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- common.h 10 Jul 2004 17:24:09 -0000 1.3
+++ common.h 12 Sep 2004 14:26:58 -0000 1.4
@@ -10,6 +10,7 @@
extern struct ioloop *ioloop;
extern enum client_workarounds client_workarounds;
+extern int enable_last_command;
extern void (*hook_mail_storage_created)(struct mail_storage **storage);
extern void (*hook_client_created)(struct client **client);
Index: main.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/pop3/main.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- main.c 22 Jul 2004 21:20:01 -0000 1.14
+++ main.c 12 Sep 2004 14:26:58 -0000 1.15
@@ -34,6 +34,7 @@
static struct module *modules;
static char log_prefix[128]; /* syslog() needs this to be permanent */
enum client_workarounds client_workarounds = 0;
+int enable_last_command = FALSE;
static void sig_quit(int signo __attr_unused__)
{
@@ -128,7 +129,9 @@
if (mail != NULL)
mail = t_strconcat("maildir:", mail, NULL);
}
- parse_workarounds();
+
+ parse_workarounds();
+ enable_last_command = getenv("POP3_ENABLE_LAST") != NULL;
storage = mail_storage_create_with_data(mail, getenv("USER"));
if (storage == NULL) {
More information about the dovecot-cvs
mailing list