Ver código fonte

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 24 anos atrás
pai
commit
e015398ff2
8 arquivos alterados com 48 adições e 23 exclusões
  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]
 [0.5]
 
 
 Updated SSL support.
 Updated SSL support.

+ 2 - 0
TODO

@@ -2,6 +2,8 @@ add support for syncing with other: and shared: via NAMESPACE
 
 
 finish implementing --quiet
 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
 isync gets confused when new mail is delivered while in the middle of an
 IMAP session.  need to handled those asynchronous notifications properly.
 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->copy_deleted_to = global.copy_deleted_to;
     conf->use_namespace = global.use_namespace;
     conf->use_namespace = global.use_namespace;
     conf->expunge = global.expunge;
     conf->expunge = global.expunge;
+    conf->delete = global.delete;
     conf->poll = global.poll;
     conf->poll = global.poll;
 #if HAVE_LIBSSL
 #if HAVE_LIBSSL
     conf->require_ssl = global.require_ssl;
     conf->require_ssl = global.require_ssl;
@@ -133,7 +134,7 @@ load_config (const char *where)
 	line++;
 	line++;
 	if (!cmd || *cmd == '#')
 	if (!cmd || *cmd == '#')
 	    continue;
 	    continue;
-	if (!strncasecmp ("mailbox", cmd, 7))
+	if (!strcasecmp ("mailbox", cmd))
 	{
 	{
 	    if (*cur)
 	    if (*cur)
 		cur = &(*cur)->next;
 		cur = &(*cur)->next;
@@ -142,13 +143,13 @@ load_config (const char *where)
 	    /* not expanded at this point */
 	    /* not expanded at this point */
 	    (*cur)->path = strdup (val);
 	    (*cur)->path = strdup (val);
 	}
 	}
-	else if (!strncasecmp ("maildir", cmd, 7))
+	else if (!strcasecmp ("maildir", cmd))
 	{
 	{
 	    /* this only affects the global setting */
 	    /* this only affects the global setting */
 	    free (global.maildir);
 	    free (global.maildir);
 	    global.maildir = expand_strdup (val);
 	    global.maildir = expand_strdup (val);
 	}
 	}
-	else if (!strncasecmp ("host", cmd, 4))
+	else if (!strcasecmp ("host", cmd))
 	{
 	{
 #if HAVE_LIBSSL
 #if HAVE_LIBSSL
 	    if (!strncasecmp ("imaps:", val, 6))
 	    if (!strncasecmp ("imaps:", val, 6))
@@ -175,111 +176,113 @@ load_config (const char *where)
 	    else
 	    else
 		global.host = strdup (val);
 		global.host = strdup (val);
 	}
 	}
-	else if (!strncasecmp ("user", cmd, 4))
+	else if (!strcasecmp ("user", cmd))
 	{
 	{
 	    if (*cur)
 	    if (*cur)
 		(*cur)->user = strdup (val);
 		(*cur)->user = strdup (val);
 	    else
 	    else
 		global.user = strdup (val);
 		global.user = strdup (val);
 	}
 	}
-	else if (!strncasecmp ("pass", cmd, 4))
+	else if (!strcasecmp ("pass", cmd))
 	{
 	{
 	    if (*cur)
 	    if (*cur)
 		(*cur)->pass = strdup (val);
 		(*cur)->pass = strdup (val);
 	    else
 	    else
 		global.pass = strdup (val);
 		global.pass = strdup (val);
 	}
 	}
-	else if (!strncasecmp ("port", cmd, 4))
+	else if (!strcasecmp ("port", cmd))
 	{
 	{
 	    if (*cur)
 	    if (*cur)
 		(*cur)->port = atoi (val);
 		(*cur)->port = atoi (val);
 	    else
 	    else
 		global.port = atoi (val);
 		global.port = atoi (val);
 	}
 	}
-	else if (!strncasecmp ("box", cmd, 3))
+	else if (!strcasecmp ("box", cmd))
 	{
 	{
 	    if (*cur)
 	    if (*cur)
 		(*cur)->box = strdup (val);
 		(*cur)->box = strdup (val);
 	    else
 	    else
 		global.box = strdup (val);
 		global.box = strdup (val);
 	}
 	}
-	else if (!strncasecmp ("alias", cmd, 5))
+	else if (!strcasecmp ("alias", cmd))
 	{
 	{
 	    if (*cur)
 	    if (*cur)
 		(*cur)->alias = strdup (val);
 		(*cur)->alias = strdup (val);
 	}
 	}
-	else if (!strncasecmp ("maxsize", cmd, 7))
+	else if (!strcasecmp ("maxsize", cmd))
 	{
 	{
 	    if (*cur)
 	    if (*cur)
 		(*cur)->max_size = atol (val);
 		(*cur)->max_size = atol (val);
 	    else
 	    else
 		global.max_size = atol (val);
 		global.max_size = atol (val);
 	}
 	}
-	else if (!strncasecmp ("UseNamespace", cmd, 12))
+	else if (!strcasecmp ("UseNamespace", cmd))
 	{
 	{
 	    if (*cur)
 	    if (*cur)
 		(*cur)->use_namespace = (strcasecmp (val, "yes") == 0);
 		(*cur)->use_namespace = (strcasecmp (val, "yes") == 0);
 	    else
 	    else
 		global.use_namespace = (strcasecmp (val, "yes") == 0);
 		global.use_namespace = (strcasecmp (val, "yes") == 0);
 	}
 	}
-	else if (!strncasecmp ("CopyDeletedTo", cmd, 13))
+	else if (!strcasecmp ("CopyDeletedTo", cmd))
 	{
 	{
 	    if (*cur)
 	    if (*cur)
 		(*cur)->copy_deleted_to = strdup (val);
 		(*cur)->copy_deleted_to = strdup (val);
 	    else
 	    else
 		global.copy_deleted_to = strdup (val);
 		global.copy_deleted_to = strdup (val);
 	}
 	}
-	else if (!strncasecmp ("Expunge", cmd, 7))
+	else if (!strcasecmp ("Expunge", cmd))
 	{
 	{
 	    if (*cur)
 	    if (*cur)
 		(*cur)->expunge = (strcasecmp (val, "yes") == 0);
 		(*cur)->expunge = (strcasecmp (val, "yes") == 0);
 	    else
 	    else
 		global.expunge = (strcasecmp (val, "yes") == 0);
 		global.expunge = (strcasecmp (val, "yes") == 0);
 	}
 	}
-	else if (!strncasecmp ("Poll", cmd, 4))
+#if 0
+	else if (!strcasecmp ("Poll", cmd))
 	{
 	{
 	    if (*cur)
 	    if (*cur)
 		(*cur)->poll = atoi (val);
 		(*cur)->poll = atoi (val);
 	    else
 	    else
 		global.poll = atoi (val);
 		global.poll = atoi (val);
 	}
 	}
+#endif
 #if HAVE_LIBSSL
 #if HAVE_LIBSSL
-	else if (!strncasecmp ("CertificateFile", cmd, 15))
+	else if (!strcasecmp ("CertificateFile", cmd))
 	{
 	{
 	    if (*cur)
 	    if (*cur)
 		(*cur)->cert_file = expand_strdup (val);
 		(*cur)->cert_file = expand_strdup (val);
 	    else
 	    else
 		global.cert_file = expand_strdup (val);
 		global.cert_file = expand_strdup (val);
 	}
 	}
-	else if (!strncasecmp ("RequireSSL", cmd, 10))
+	else if (!strcasecmp ("RequireSSL", cmd))
 	{
 	{
 	    if (*cur)
 	    if (*cur)
 		(*cur)->require_ssl = (strcasecmp (val, "yes") == 0);
 		(*cur)->require_ssl = (strcasecmp (val, "yes") == 0);
 	    else
 	    else
 		global.require_ssl = (strcasecmp (val, "yes") == 0);
 		global.require_ssl = (strcasecmp (val, "yes") == 0);
 	}
 	}
-	else if (!strncasecmp ("UseSSLv2", cmd, 8))
+	else if (!strcasecmp ("UseSSLv2", cmd))
 	{
 	{
 	    if (*cur)
 	    if (*cur)
 		(*cur)->use_sslv2 = (strcasecmp (val, "yes") == 0);
 		(*cur)->use_sslv2 = (strcasecmp (val, "yes") == 0);
 	    else
 	    else
 		global.use_sslv2 = (strcasecmp (val, "yes") == 0);
 		global.use_sslv2 = (strcasecmp (val, "yes") == 0);
 	}
 	}
-	else if (!strncasecmp ("UseSSLv3", cmd, 8))
+	else if (!strcasecmp ("UseSSLv3", cmd))
 	{
 	{
 	    if (*cur)
 	    if (*cur)
 		(*cur)->use_sslv3 = (strcasecmp (val, "yes") == 0);
 		(*cur)->use_sslv3 = (strcasecmp (val, "yes") == 0);
 	    else
 	    else
 		global.use_sslv3 = (strcasecmp (val, "yes") == 0);
 		global.use_sslv3 = (strcasecmp (val, "yes") == 0);
 	}
 	}
-	else if (!strncasecmp ("UseTLSv1", cmd, 8))
+	else if (!strcasecmp ("UseTLSv1", cmd))
 	{
 	{
 	    if (*cur)
 	    if (*cur)
 		(*cur)->use_tlsv1 = (strcasecmp (val, "yes") == 0);
 		(*cur)->use_tlsv1 = (strcasecmp (val, "yes") == 0);
 	    else
 	    else
 		global.use_tlsv1 = (strcasecmp (val, "yes") == 0);
 		global.use_tlsv1 = (strcasecmp (val, "yes") == 0);
 	}
 	}
-	else if (!strncasecmp ("RequireCRAM", cmd, 11))
+	else if (!strcasecmp ("RequireCRAM", cmd))
 	{
 	{
 	    if (*cur)
 	    if (*cur)
 		(*cur)->require_cram = (strcasecmp (val, "yes") == 0);
 		(*cur)->require_cram = (strcasecmp (val, "yes") == 0);
@@ -288,7 +291,7 @@ load_config (const char *where)
 	}
 	}
 #endif
 #endif
 	else if (buf[0])
 	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);
     fclose (fp);
 }
 }

+ 11 - 1
isync.1

@@ -16,7 +16,7 @@
 \"  along with this program; if not, write to the Free Software
 \"  along with this program; if not, write to the Free Software
 \"  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 \"  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
 .SH NAME
 isync - synchronize IMAP4 and maildir mailboxes
 isync - synchronize IMAP4 and maildir mailboxes
@@ -162,6 +162,11 @@ Specifies the remote IMAP mailbox to copy deleted messages prior to
 expunging (Default: none).
 expunging (Default: none).
 ..
 ..
 .TP
 .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
 \fBExpunge\fR \fIyes|no\fR
 Specifies whether deleted messages are expunged by default (Default: no).
 Specifies whether deleted messages are expunged by default (Default: no).
 \fBNOTE:\fR  The
 \fBNOTE:\fR  The
@@ -289,6 +294,11 @@ has retrieved the initial message list, the new mail will not be fetched
 until the next time
 until the next time
 .B isync
 .B isync
 is invoked.
 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
 .SH SEE ALSO
 mutt(1), maildir(5)
 mutt(1), maildir(5)
 .P
 .P

+ 1 - 0
isync.h

@@ -71,6 +71,7 @@ struct config
 #endif
 #endif
     unsigned int use_namespace:1;
     unsigned int use_namespace:1;
     unsigned int expunge:1;
     unsigned int expunge:1;
+    unsigned int delete:1;
 };
 };
 
 
 /* struct representing local mailbox file */
 /* struct representing local mailbox file */

+ 4 - 0
isyncrc.sample

@@ -5,6 +5,10 @@
 # by default, expunge deleted messages (same as -e on command line)
 # by default, expunge deleted messages (same as -e on command line)
 Expunge yes
 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
 # copy deleted messages to the IMAP "Trash" folder
 CopyDeletedTo "Trash"
 CopyDeletedTo "Trash"
 
 

+ 1 - 1
main.c

@@ -278,7 +278,7 @@ main (int argc, char **argv)
 
 
 	if (!quiet)
 	if (!quiet)
 	    puts ("Synchronizing");
 	    puts ("Synchronizing");
-	i = delete ? SYNC_DELETE : 0;
+	i = (delete || box->delete) ? SYNC_DELETE : 0;
 	i |= (expunge || box->expunge) ? SYNC_EXPUNGE : 0;
 	i |= (expunge || box->expunge) ? SYNC_EXPUNGE : 0;
 	if (sync_mailbox (mail, imap, i, box->max_size))
 	if (sync_mailbox (mail, imap, i, box->max_size))
 	    exit (1);
 	    exit (1);

+ 1 - 1
sync.c

@@ -104,7 +104,7 @@ sync_mailbox (mailbox_t * mbox, imap_t * imap, int flags,
 
 
 		    continue;	/* not fatal */
 		    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
 		    printf
 			("Warning, local message is too large (%ld), skipping...\n",
 			("Warning, local message is too large (%ld), skipping...\n",