* Implemented the deprecated "LAST" command in POP3. Some clients need it.
authorArt Cancro <ajc@citadel.org>
Tue, 8 Feb 2000 21:00:48 +0000 (21:00 +0000)
committerArt Cancro <ajc@citadel.org>
Tue, 8 Feb 2000 21:00:48 +0000 (21:00 +0000)
* POP3 sessions now set the last-read pointer in Mail>.

citadel/ChangeLog
citadel/serv_pop3.c
citadel/serv_pop3.h
citadel/setup.c
citadel/sysconfig.h

index 03de74fef23269abe13c6785a0210486ece979d6..cb5efad3fa47063c2be74228de4db6366f2b7e40 100644 (file)
@@ -1,4 +1,8 @@
 $Log$
+Revision 1.457  2000/02/08 21:00:47  ajc
+* Implemented the deprecated "LAST" command in POP3.  Some clients need it.
+* POP3 sessions now set the last-read pointer in Mail>.
+
 Revision 1.456  2000/02/07 05:15:00  ajc
 * Renamed CtdlLocalHost() to CtdlHostAlias() and worked it a little deeper into
   the message routing logic.  Still needs some work on the gateway-domain
@@ -1607,3 +1611,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
        * Initial CVS import 
+
index a4d8a8a0813aa1b7ba0af97845b6332c2907575f..e9d42b9b51b758162ac00db1e30cf662c46bdbf4 100644 (file)
@@ -4,11 +4,19 @@
  * Copyright (C) 1998-2000 by Art Cancro and others.
  * This code is released under the terms of the GNU General Public License.
  *
- * This module implements all required POP3 server commands as described
- * in RFC1939.  It also implements nearly all of the optional commands.  The
- * only one missing is APOP, because it implements a "shared secret" method
- * of authentication which currently does not fit well with Citadel.  Perhaps
- * we'll do it later.
+ * Current status of standards conformance:
+ *
+ * -> All required POP3 commands described in RFC1939 are implemented.
+ * 
+ * -> Nearly all of the optional commands in RFC1939 are also implemented.
+ *    The only one missing is APOP, because it implements a "shared secret"
+ *    method  of authentication which would require some major changes to the
+ *    Citadel server core.
+ *
+ * -> The deprecated "LAST" command is included in this implementation, because
+ *    there exist mail clients which insist on using it (such as Bynari
+ *    TradeMail, and certain versions of Eudora).
+ * 
  */
 
 #include "sysdep.h"
@@ -135,8 +143,23 @@ void pop3_add_message(long msgnum) {
  * of messages in the inbox, or -1 for error)
  */
 int pop3_grab_mailbox(void) {
+        struct visit vbuf;
+       int i;
+
        if (getroom(&CC->quickroom, MAILROOM) != 0) return(-1);
+
+       /* Load up the messages */
        CtdlForEachMessage(MSGS_ALL, 0L, NULL, NULL, pop3_add_message);
+
+       /* Figure out which are old and which are new */
+        CtdlGetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
+       POP3->lastseen = (-1);
+       if (POP3->num_msgs) for (i=0; i<POP3->num_msgs; ++i) {
+               if ((POP3->msgs[POP3->num_msgs-1].msgnum) <= vbuf.v_lastseen) {
+                       POP3->lastseen = i;
+               }
+       }
+
        return(POP3->num_msgs);
 }
 
@@ -326,17 +349,31 @@ void pop3_dele(char *argbuf) {
 }
 
 
-/* Perform "UPDATE state" stuff (remove messages marked for deletion)
+/* Perform "UPDATE state" stuff
  */
 void pop3_update(void) {
        int i;
+        struct visit vbuf;
 
+       /* Remove messages marked for deletion */
        if (POP3->num_msgs > 0) for (i=0; i<POP3->num_msgs; ++i) {
                if (POP3->msgs[i].deleted) {
                        CtdlDeleteMessages(MAILROOM,
                                POP3->msgs[i].msgnum, NULL);
                }
        }
+
+       /* Set last read pointer */
+       if (POP3->num_msgs > 0) {
+               lgetuser(&CC->usersupp, CC->curr_user);
+
+               CtdlGetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
+               vbuf.v_lastseen = POP3->msgs[POP3->num_msgs-1].msgnum;
+               CtdlSetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
+
+               lputuser(&CC->usersupp);
+       }
+
 }
 
 
@@ -356,6 +393,14 @@ void pop3_rset(char *argbuf) {
 
 
 
+/* 
+ * LAST (Determine which message is the last unread message)
+ */
+void pop3_last(char *argbuf) {
+       cprintf("+OK %d\r\n", POP3->lastseen + 1);
+}
+
+
 
 /*
  * UIDL (Universal IDentifier Listing) is easy.  Our 'unique' message
@@ -471,6 +516,10 @@ void pop3_command_loop(void) {
                pop3_top(&cmdbuf[4]);
        }
 
+       else if (!strncasecmp(cmdbuf, "LAST", 4)) {
+               pop3_last(&cmdbuf[4]);
+       }
+
        else {
                cprintf("500 I'm afraid I can't do that, Dave.\r\n");
        }
index 13c7f187264ac5d9d54ca7f6099d39bd2726ff6c..be228e7b09fe84843a66d7f1b35ba047921c79ff 100644 (file)
@@ -7,9 +7,15 @@ struct pop3msg {
 };
 
 struct citpop3 {               /* Information about the current session */
-       struct pop3msg *msgs;
-       int num_msgs;
+       struct pop3msg *msgs;   /* Array of message pointers */
+       int num_msgs;           /* Number of messages in array */
+       int lastseen;           /* Offset of last-read message in array */
 };
+                               /* Note: the "lastseen" is represented as the
+                                * offset in this array (zero-based), so when
+                                * displaying it to a POP3 client, it must be
+                                * incremented by one.
+                                */
 
 #define POP3 ((struct citpop3 *)CtdlGetUserData(SYM_POP3))
 
index 1872eaeaf22082aefc1f573af101aa2acb5321bc..1dccd12f0cceedad621eeb3e4b60504f521fd941 100644 (file)
@@ -539,8 +539,10 @@ void set_str_val(int msgpos, char str[])
 {
        char buf[4096];
        char tempfile[64];
+       char setupmsg[256];
 
        sprintf(tempfile, tmpnam(NULL));
+       strcpy(setupmsg, "");
 
        switch (setup_type) {
        case UI_TEXT:
index 3ce4597f87e514ffb5fca948d6931d33a2f09ebd..198f7e557144b00ffd2536dd8a8d17742de1fcee 100644 (file)
@@ -83,8 +83,8 @@
  * These define what port to listen on for various services.
  * FIX ... put this in a programmable config somewhere
  */
-#define POP3_PORT              1110
-#define SMTP_PORT              2525
+#define POP3_PORT              110
+#define SMTP_PORT              25
 
 
 /*