* Minor IMAP tweaks. It still doesn't work. :(
authorArt Cancro <ajc@citadel.org>
Sat, 25 Nov 2000 06:17:06 +0000 (06:17 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 25 Nov 2000 06:17:06 +0000 (06:17 +0000)
citadel/ChangeLog
citadel/imap_fetch.c
citadel/imap_tools.c
citadel/imap_tools.h

index 562c67d98b68c8e907d5bcbcb204874786805ef5..f1d11c7645674c046b2813855d9837f5ae082e03 100644 (file)
@@ -1,4 +1,7 @@
  $Log$
+ Revision 573.28  2000/11/25 06:17:06  ajc
+ * Minor IMAP tweaks.  It still doesn't work.  :(
+
  Revision 573.27  2000/11/23 07:22:21  error
  * citadel.spec: update version number
 
@@ -2141,5 +2144,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import 
-
-
index 6e18fcc60d5bca923999d5ef0b413272e2ed8006..2e68e5cdc2065b575baf96ac52ddffe842a0e2fc 100644 (file)
@@ -214,11 +214,32 @@ void imap_load_part(char *name, char *filename, char *partnum, char *disp,
  * Implements the ENVELOPE fetch item
  * 
  * FIXME ... we have to actually do something useful here.
+ *
+ * Note that the imap_strout() function can cleverly output NULL fields as NIL,
+ * so we don't have to check for that condition like we do elsewhere.
  */
 void imap_fetch_envelope(long msgnum, struct CtdlMessage *msg) {
+       char buf[256];
+       time_t msgdate;
+
+       if (msg->cm_fields['T'] != NULL) {
+               msgdate = atol(msg->cm_fields['T']);
+       }
+       else {
+               msgdate = time(NULL);
+       }
+
+       datestring(buf, msgdate, DATESTRING_IMAP);
+
        cprintf("ENVELOPE (");
-       cprintf("NIL ");        /* date */
-       cprintf("NIL ");        /* subject */
+
+       /* date */
+       cprintf("\"%s\" ", buf);
+
+       /* subject */
+       imap_strout(msg->cm_fields['U']);
+       cprintf(" ");
+
        cprintf("NIL ");        /* from */
        cprintf("NIL ");        /* sender */
        cprintf("NIL ");        /* reply-to */
@@ -226,8 +247,11 @@ void imap_fetch_envelope(long msgnum, struct CtdlMessage *msg) {
        cprintf("NIL ");        /* cc */
        cprintf("NIL ");        /* bcc */
        cprintf("NIL ");        /* in-reply-to */
-       cprintf("NIL");         /* message-id */
-       cprintf(")\r\n");
+
+       /* message ID */
+       imap_strout(msg->cm_fields['I']);
+
+       cprintf(") ");
 }
 
 
@@ -287,6 +311,7 @@ void imap_fetch_body(long msgnum, char *item, int is_peek,
        for (i=0; i<strlen(partial); ++i) {
                if (partial[i]=='>') partial[i] = 0;
        }
+       if (is_partial == 0) strcpy(partial, "");
        lprintf(9, "Partial is %s\n", partial);
 
        tmp = tmpfile();
index 8d59d4e97b702c7c5e588faa37ea262209a40888..e2527c4d867a7b96302269d1650da63f7465a1b7 100644 (file)
@@ -7,12 +7,45 @@
 
 #include <stdlib.h>
 #include <unistd.h>
+#include <stdio.h>
 #include <ctype.h>
 #include <string.h>
 #include "citadel.h"
+#include "sysdep_decls.h"
 #include "tools.h"
 #include "imap_tools.h"
 
+
+/*
+ * Output a string to the IMAP client, either as a literal or quoted.
+ * (We do a literal if it has any double-quotes or backslashes.)
+ */
+void imap_strout(char *buf) {
+       int i;
+       int is_literal = 0;
+
+       if (buf == NULL) {              /* yeah, we handle this */
+               cprintf("NIL");
+               return;
+       }
+
+       for (i=0; i<strlen(buf); ++i) {
+               if ( (buf[i]=='\"') || (buf[i]=='\\') ) is_literal = 1;
+       }
+
+       if (is_literal) {
+               cprintf("{%d}\r\n%s", strlen(buf), buf);
+       }
+
+       else {
+               cprintf("\"%s\"", buf);
+       }
+}
+
+       
+
+
+
 /*
  * Break a command down into tokens, taking into consideration the
  * possibility of escaping spaces using quoted tokens
index d363cd8c2ea2523e3a796c4e4dc7b0399b835ba3..7df3279913c36561a64e6baccbad11d598892d0b 100644 (file)
@@ -3,5 +3,6 @@
  *
  */
 
+void imap_strout(char *buf);
 int imap_parameterize(char **args, char *buf);
 void imap_mailboxname(char *buf, int bufsize, struct quickroom *qrbuf);