]> granicus.if.org Git - mutt/commitdiff
POP3 LAST support. From Jason Lavoie <jason@mint.net> by way of
authorThomas Roessler <roessler@does-not-exist.org>
Wed, 7 Oct 1998 22:18:38 +0000 (22:18 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Wed, 7 Oct 1998 22:18:38 +0000 (22:18 +0000)
Michael Elkins.

Muttrc.in
doc/manual.sgml
init.h
mutt.h
pop.c

index c89aeea6c14505c578a464ebab39d7985b4fa233..fd9847a7185c6036822f9a07250071db881dad9d 100644 (file)
--- a/Muttrc.in
+++ b/Muttrc.in
@@ -212,4 +212,4 @@ macro pager \cb |urlview\n 'call urlview to extract URLs out of a message'
 # set pop_port=110
 # set pop_pass=""
 # set pop_user=""
-
+# unset pop_last
index 7ef59f35205d07362ce75528c593040991d49ef0..273336385aef5eef0154eeef00fb270bef3b6485 100644 (file)
@@ -3496,6 +3496,14 @@ Default: none
 
 The name or address of your POP3 server.
 
+<sect2>pop&lowbar;last<label id="pop_last">
+<p>
+Type: boolean<newline>
+Default: unset
+
+If this variable is set, mutt will try to use the "LAST" POP command
+for retrieving only unread messages from the POP server.
+
 <sect2>pop&lowbar;pass<label id="pop_pass">
 <p>
 Type: string<newline>
diff --git a/init.h b/init.h
index e4204b41f8b663edc2ce459cfe89335dcc1db30e..d7a270b76f1f1d95f948fcee0aae946fd9f9b633 100644 (file)
--- a/init.h
+++ b/init.h
@@ -210,6 +210,7 @@ struct option_t MuttVars[] = {
 #ifdef USE_POP
   { "pop_delete",      DT_BOOL, R_NONE, OPTPOPDELETE, 0 },
   { "pop_host",                DT_STR,  R_NONE, UL &PopHost, UL "" },
+  { "pop_last",                DT_BOOL, R_NONE, OPTPOPLAST, 0 },
   { "pop_port",                DT_NUM,  R_NONE, UL &PopPort, 110 },
   { "pop_pass",                DT_STR,  R_NONE, UL &PopPass, UL "" },
   { "pop_user",                DT_STR,  R_NONE, UL &PopUser, UL "" },
diff --git a/mutt.h b/mutt.h
index 21d7ac65748f1892919d26b4302921ee83f26e44..f0219d6d5c8e6f959c71d71d1ef35d8313cd2149 100644 (file)
--- a/mutt.h
+++ b/mutt.h
@@ -305,6 +305,7 @@ enum
   OPTPIPEDECODE,
   OPTPIPESPLIT,
   OPTPOPDELETE,
+  OPTPOPLAST,
   OPTPROMPTAFTER,
   OPTREADONLY,
   OPTRESOLVE,
diff --git a/pop.c b/pop.c
index ee08e9e9019d10922534965518a4d52e729857bb..3c7c778886bd85260b54cfedb24a2fb965d7ba14 100644 (file)
--- a/pop.c
+++ b/pop.c
@@ -82,7 +82,7 @@ void mutt_fetchPopMail (void)
   struct hostent *he;
   char buffer[2048];
   char msgbuf[SHORT_STRING];
-  int s, i, msgs, bytes, err = 0;
+  int s, i, last = 0, msgs, bytes, err = 0;
   CONTEXT ctx;
   MESSAGE *msg = NULL;
 
@@ -191,12 +191,26 @@ void mutt_fetchPopMail (void)
   if (mx_open_mailbox (NONULL(Spoolfile), M_APPEND, &ctx) == NULL)
     goto finish;
 
+  /* only get unread messages */
+  if(option(OPTPOPLAST))
+  {
+    write (s, "last\r\n", 6);
+    if (getLine (s, buffer, sizeof (buffer)) == -1)
+      goto fail;
+    
+    if (strncmp (buffer, "+OK", 3) == 0)
+      sscanf (buffer, "+OK %d", &last);
+    else
+      /* ignore an error here and assume all messages are new */
+      last = 0;
+  }
+  
   snprintf (msgbuf, sizeof (msgbuf),
            msgs > 1 ? _("Reading %d new message (%d bytes)...") :
-                   ("Reading %d new messages (%d bytes)..."), msgs, bytes);
+                   ("Reading %d new messages (%d bytes)..."), msgs - last, bytes);
   mutt_message (msgbuf);
 
-  for (i = 1 ; i <= msgs ; i++)
+  for (i = last + 1 ; i <= msgs ; i++)
   {
     snprintf (buffer, sizeof(buffer), "retr %d\r\n", i);
     write (s, buffer, strlen (buffer));