From e015398ff28a56839f202467a3beb751a31f8423 Mon Sep 17 00:00:00 2001 From: Michael Elkins Date: Wed, 3 Oct 2001 05:42:22 +0000 Subject: [PATCH] added `Delete' configuration option to force -d option sync_mailbox() didn't consider MaxSize == 0 to mean "unlimited". load_config() needs to print a newline in its error messages since next_arg() kills the newline of the line that was read out of the config file. --- NEWS | 5 +++++ TODO | 2 ++ config.c | 43 +++++++++++++++++++++++-------------------- isync.1 | 12 +++++++++++- isync.h | 1 + isyncrc.sample | 4 ++++ main.c | 2 +- sync.c | 2 +- 8 files changed, 48 insertions(+), 23 deletions(-) diff --git a/NEWS b/NEWS index b011f1f..90752a6 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,8 @@ +[0.6] + +Added `Delete' configuration option to correspond to the -d command line +option. + [0.5] Updated SSL support. diff --git a/TODO b/TODO index aace6d5..8c82fc3 100644 --- a/TODO +++ b/TODO @@ -2,6 +2,8 @@ add support for syncing with other: and shared: via NAMESPACE finish implementing --quiet +--fast downloads the last message again if no new messages have arrived + isync gets confused when new mail is delivered while in the middle of an IMAP session. need to handled those asynchronous notifications properly. diff --git a/config.c b/config.c index 8fc93bb..bcd02e9 100644 --- a/config.c +++ b/config.c @@ -44,6 +44,7 @@ config_defaults (config_t * conf) conf->copy_deleted_to = global.copy_deleted_to; conf->use_namespace = global.use_namespace; conf->expunge = global.expunge; + conf->delete = global.delete; conf->poll = global.poll; #if HAVE_LIBSSL conf->require_ssl = global.require_ssl; @@ -133,7 +134,7 @@ load_config (const char *where) line++; if (!cmd || *cmd == '#') continue; - if (!strncasecmp ("mailbox", cmd, 7)) + if (!strcasecmp ("mailbox", cmd)) { if (*cur) cur = &(*cur)->next; @@ -142,13 +143,13 @@ load_config (const char *where) /* not expanded at this point */ (*cur)->path = strdup (val); } - else if (!strncasecmp ("maildir", cmd, 7)) + else if (!strcasecmp ("maildir", cmd)) { /* this only affects the global setting */ free (global.maildir); global.maildir = expand_strdup (val); } - else if (!strncasecmp ("host", cmd, 4)) + else if (!strcasecmp ("host", cmd)) { #if HAVE_LIBSSL if (!strncasecmp ("imaps:", val, 6)) @@ -175,111 +176,113 @@ load_config (const char *where) else global.host = strdup (val); } - else if (!strncasecmp ("user", cmd, 4)) + else if (!strcasecmp ("user", cmd)) { if (*cur) (*cur)->user = strdup (val); else global.user = strdup (val); } - else if (!strncasecmp ("pass", cmd, 4)) + else if (!strcasecmp ("pass", cmd)) { if (*cur) (*cur)->pass = strdup (val); else global.pass = strdup (val); } - else if (!strncasecmp ("port", cmd, 4)) + else if (!strcasecmp ("port", cmd)) { if (*cur) (*cur)->port = atoi (val); else global.port = atoi (val); } - else if (!strncasecmp ("box", cmd, 3)) + else if (!strcasecmp ("box", cmd)) { if (*cur) (*cur)->box = strdup (val); else global.box = strdup (val); } - else if (!strncasecmp ("alias", cmd, 5)) + else if (!strcasecmp ("alias", cmd)) { if (*cur) (*cur)->alias = strdup (val); } - else if (!strncasecmp ("maxsize", cmd, 7)) + else if (!strcasecmp ("maxsize", cmd)) { if (*cur) (*cur)->max_size = atol (val); else global.max_size = atol (val); } - else if (!strncasecmp ("UseNamespace", cmd, 12)) + else if (!strcasecmp ("UseNamespace", cmd)) { if (*cur) (*cur)->use_namespace = (strcasecmp (val, "yes") == 0); else global.use_namespace = (strcasecmp (val, "yes") == 0); } - else if (!strncasecmp ("CopyDeletedTo", cmd, 13)) + else if (!strcasecmp ("CopyDeletedTo", cmd)) { if (*cur) (*cur)->copy_deleted_to = strdup (val); else global.copy_deleted_to = strdup (val); } - else if (!strncasecmp ("Expunge", cmd, 7)) + else if (!strcasecmp ("Expunge", cmd)) { if (*cur) (*cur)->expunge = (strcasecmp (val, "yes") == 0); else global.expunge = (strcasecmp (val, "yes") == 0); } - else if (!strncasecmp ("Poll", cmd, 4)) +#if 0 + else if (!strcasecmp ("Poll", cmd)) { if (*cur) (*cur)->poll = atoi (val); else global.poll = atoi (val); } +#endif #if HAVE_LIBSSL - else if (!strncasecmp ("CertificateFile", cmd, 15)) + else if (!strcasecmp ("CertificateFile", cmd)) { if (*cur) (*cur)->cert_file = expand_strdup (val); else global.cert_file = expand_strdup (val); } - else if (!strncasecmp ("RequireSSL", cmd, 10)) + else if (!strcasecmp ("RequireSSL", cmd)) { if (*cur) (*cur)->require_ssl = (strcasecmp (val, "yes") == 0); else global.require_ssl = (strcasecmp (val, "yes") == 0); } - else if (!strncasecmp ("UseSSLv2", cmd, 8)) + else if (!strcasecmp ("UseSSLv2", cmd)) { if (*cur) (*cur)->use_sslv2 = (strcasecmp (val, "yes") == 0); else global.use_sslv2 = (strcasecmp (val, "yes") == 0); } - else if (!strncasecmp ("UseSSLv3", cmd, 8)) + else if (!strcasecmp ("UseSSLv3", cmd)) { if (*cur) (*cur)->use_sslv3 = (strcasecmp (val, "yes") == 0); else global.use_sslv3 = (strcasecmp (val, "yes") == 0); } - else if (!strncasecmp ("UseTLSv1", cmd, 8)) + else if (!strcasecmp ("UseTLSv1", cmd)) { if (*cur) (*cur)->use_tlsv1 = (strcasecmp (val, "yes") == 0); else global.use_tlsv1 = (strcasecmp (val, "yes") == 0); } - else if (!strncasecmp ("RequireCRAM", cmd, 11)) + else if (!strcasecmp ("RequireCRAM", cmd)) { if (*cur) (*cur)->require_cram = (strcasecmp (val, "yes") == 0); @@ -288,7 +291,7 @@ load_config (const char *where) } #endif else if (buf[0]) - printf ("%s:%d:unknown command:%s", path, line, cmd); + printf ("%s:%d:unknown command:%s\n", path, line, cmd); } fclose (fp); } diff --git a/isync.1 b/isync.1 index cfff57d..1390039 100644 --- a/isync.1 +++ b/isync.1 @@ -16,7 +16,7 @@ \" along with this program; if not, write to the Free Software \" Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA .. -.TH isync 1 "2001 Jan 16" +.TH isync 1 "2001 Oct 02" .. .SH NAME isync - synchronize IMAP4 and maildir mailboxes @@ -162,6 +162,11 @@ Specifies the remote IMAP mailbox to copy deleted messages prior to expunging (Default: none). .. .TP +\fBDelete\fR \fIyes|no\fR +Specifies whether messages in the local copy of the mailbox which don't +exist on the server are automatically deleted. (Default: no). +.. +.TP \fBExpunge\fR \fIyes|no\fR Specifies whether deleted messages are expunged by default (Default: no). \fBNOTE:\fR The @@ -289,6 +294,11 @@ has retrieved the initial message list, the new mail will not be fetched until the next time .B isync is invoked. +.P +It is currently impossible to unset the \\Flagged attribute of a message +once it is set. It has to be manually unset everywhere since isync +doesn't have enough information to know which was the last status of the +message. .SH SEE ALSO mutt(1), maildir(5) .P diff --git a/isync.h b/isync.h index 130967b..f008fa0 100644 --- a/isync.h +++ b/isync.h @@ -71,6 +71,7 @@ struct config #endif unsigned int use_namespace:1; unsigned int expunge:1; + unsigned int delete:1; }; /* struct representing local mailbox file */ diff --git a/isyncrc.sample b/isyncrc.sample index 977e68d..2c344b4 100644 --- a/isyncrc.sample +++ b/isyncrc.sample @@ -5,6 +5,10 @@ # by default, expunge deleted messages (same as -e on command line) Expunge yes +# by default delete messages in the local mailbox which no longer exist +# on the server +Delete yes + # copy deleted messages to the IMAP "Trash" folder CopyDeletedTo "Trash" diff --git a/main.c b/main.c index 42768ba..1b077d1 100644 --- a/main.c +++ b/main.c @@ -278,7 +278,7 @@ main (int argc, char **argv) if (!quiet) puts ("Synchronizing"); - i = delete ? SYNC_DELETE : 0; + i = (delete || box->delete) ? SYNC_DELETE : 0; i |= (expunge || box->expunge) ? SYNC_EXPUNGE : 0; if (sync_mailbox (mail, imap, i, box->max_size)) exit (1); diff --git a/sync.c b/sync.c index 3b0c6c7..92af851 100644 --- a/sync.c +++ b/sync.c @@ -104,7 +104,7 @@ sync_mailbox (mailbox_t * mbox, imap_t * imap, int flags, continue; /* not fatal */ } - if (sb.st_size > imap->box->max_size) + if (imap->box->max_size > 0 && sb.st_size > imap->box->max_size) { printf ("Warning, local message is too large (%ld), skipping...\n",