Commit d0bd03f4 d0bd03f4f67b4970f43ac22885a9897b84cb9ec0 by Alain Magloire

add expire to Makefile.am

Add EXPIRE in capa.c
new optio --expire in pop3d.c
in update state set the new header in quit.c
in retr.c mark the message Downloaded.
new file.
1 parent 35f50c31
......@@ -26,7 +26,7 @@ SUBDIRS = testsuite
pop3d_SOURCES = apop.c auth.c capa.c dele.c extra.c pop3d.c pop3d.h \
list.c lock.c noop.c quit.c retr.c rset.c stat.c stls.c signal.c top.c \
uidl.c user.c logindelay.c
uidl.c user.c logindelay.c expire.c
pop3d_LDADD = \
../mailbox/mbox/libmu_mbox.la\
......
......@@ -47,9 +47,12 @@ pop3d_capa (const char *arg)
pop3d_outf ("STLS\r\n");
#endif /* WITH_TLS */
/* FIXME: This can be Implemented by setting an header field on the
message. */
/*pop3d_outf ("EXPIRE NEVER\r\n"); */
/* This can be Implemented by setting an header field on the message. */
if (expire < 0)
pop3d_outf ("EXPIRE NEVER\r\n");
else
pop3d_outf ("EXPIRE %d\r\n", expire);
if (state == TRANSACTION) /* let's not advertise to just anyone */
pop3d_outf ("IMPLEMENTATION %s\r\n", PACKAGE_STRING);
pop3d_outf (".\r\n");
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2003 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Mailutils is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Mailutils; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "pop3d.h"
/* EXPIRE see RFC2449:
Implementation:
When a message is downloaded it is mark, pop3d_mark_retr(attr)
at the update state the expire date is set on a header field
asprintf (.. "X-Expire-Timestamp: %ld", (long)time(NULL));
The message is not actually remove, we rely on external
program to do it.
*/
void
pop3d_mark_retr (attribute_t attr)
{
attribute_set_userflag (attr, POP3_ATTRIBUTE_RETR);
}
int
pop3d_is_retr (attribute_t attr)
{
return attribute_is_userflag (attr, POP3_ATTRIBUTE_RETR);
}
void
pop3d_unmark_retr (attribute_t attr)
{
if (attribute_is_userflag (attr, POP3_ATTRIBUTE_RETR))
attribute_unset_userflag (attr, POP3_ATTRIBUTE_RETR);
}
......@@ -47,6 +47,9 @@ time_t login_delay = 0;
char *login_stat_file = LOGIN_STAT_FILE;
#endif
/* Minimum advertise retention times of messages. */
int expire = -1;
static int pop3d_mainloop __P ((int fd, FILE *, FILE *));
static void pop3d_daemon_init __P ((void));
static void pop3d_daemon __P ((unsigned int, unsigned int));
......@@ -59,6 +62,7 @@ static char doc[] = N_("GNU pop3d -- the POP3 daemon");
#define OPT_LOGIN_DELAY 257
#define OPT_STAT_FILE 258
#define OPT_EXPIRE 259
static struct argp_option options[] = {
{"undelete", 'u', NULL, 0,
......@@ -69,6 +73,8 @@ static struct argp_option options[] = {
{"stat-file", OPT_STAT_FILE, N_("FILENAME"), 0,
N_("Name of login statistics file"), 0},
#endif
{"expire", OPT_EXPIRE, N_("DAYS"), 0,
N_("Minimum advertise retention days of messages, default -1 means NEVER"), 0},
{NULL, 0, NULL, 0, NULL, 0}
};
......@@ -122,8 +128,12 @@ pop3d_parse_opt (int key, char *arg, struct argp_state *astate)
case OPT_STAT_FILE:
login_stat_file = arg;
break;
#endif
case OPT_STAT_FILE:
expire = strtoul (arg, &p, 10);
break;
default:
return ARGP_ERR_UNKNOWN;
}
......
......@@ -88,6 +88,9 @@ extern void update_login_delay __P((char *username));
# define update_login_delay(u)
#endif
/* Minimum advertise retention time for messages. */
extern int expire;
/* Size of the MD5 digest for APOP */
#define APOP_DIGEST 70
......@@ -165,6 +168,7 @@ extern void update_login_delay __P((char *username));
#endif
#define POP3_ATTRIBUTE_DELE 0x0001
#define POP3_ATTRIBUTE_RETR 0x0010
#define AUTHORIZATION 0
#define TRANSACTION 1
......
......@@ -62,16 +62,29 @@ pop3d_fix_mark ()
{
size_t i;
size_t total = 0;
char *value = NULL;
int len;
mailbox_messages_count (mbox, &total);
len = asprintf (&value, "%ul", (unsigned long) time (NULL));
for (i = 1; i <= total; i++)
{
message_t msg = NULL;
attribute_t attr = NULL;
mailbox_get_message (mbox, i, &msg);
message_get_attribute (msg, &attr);
if (pop3d_is_deleted (attr))
attribute_set_deleted (attr);
// Mark the message with a timestamp.
if (expire >= 0 && pop3d_is_retr (attr))
{
header_t header = NULL;
message_get_header (msg, &header);
header_set_value (header, "X-Expire-Timestamp", value, len);
}
}
free (value);
}
......
......@@ -77,6 +77,8 @@ pop3d_retr (const char *arg)
if (!attribute_is_read (attr))
attribute_set_read (attr);
pop3d_mark_retr (attr);
free (buf);
pop3d_outf (".\r\n");
......