Explorar o código

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.
Michael Elkins %!s(int64=24) %!d(string=hai) anos
pai
achega
e015398ff2
Modificáronse 8 ficheiros con 48 adicións e 23 borrados
  1. 5 0
      NEWS
  2. 2 0
      TODO
  3. 23 20
      config.c
  4. 11 1
      isync.1
  5. 1 0
      isync.h
  6. 4 0
      isyncrc.sample
  7. 1 1
      main.c
  8. 1 1
      sync.c

+ 5 - 0
NEWS

@@ -1,3 +1,8 @@
+[0.6]
+
+Added `Delete' configuration option to correspond to the -d command line
+option.
+
 [0.5]
 
 Updated SSL support.

+ 2 - 0
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.
 

+ 23 - 20
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);
 }

+ 11 - 1
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

+ 1 - 0
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 */

+ 4 - 0
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"
 

+ 1 - 1
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);

+ 1 - 1
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",