]> code.citadel.org Git - citadel.git/commitdiff
* Added in some infrastructure to switch the client's message reading from
authorArt Cancro <ajc@citadel.org>
Sun, 21 Jul 2002 22:29:46 +0000 (22:29 +0000)
committerArt Cancro <ajc@citadel.org>
Sun, 21 Jul 2002 22:29:46 +0000 (22:29 +0000)
  conventional MSG0 to a MIME-download type thing, like WebCit does.

citadel/ChangeLog
citadel/citadel_ipc.c
citadel/citadel_ipc.h
citadel/messages.c

index beb473286d1cd5f39924e69411b8102ffe4f21ad..7639848958428540f4194f5ccc2cc8579acfe62e 100644 (file)
@@ -1,4 +1,8 @@
  $Log$
+ Revision 591.72  2002/07/21 22:29:46  ajc
+ * Added in some infrastructure to switch the client's message reading from
+   conventional MSG0 to a MIME-download type thing, like WebCit does.
+
  Revision 591.71  2002/07/21 15:45:07  error
  * Remove duplicate call for server time in who_is_online(); IPC does this now
 
@@ -3827,4 +3831,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 8d1f103faa79574103a64657180f66ecb0c03875..1a0678e97f60fad1e2cfbf83f546e808ad19c9dd 100644 (file)
@@ -383,6 +383,8 @@ int CtdlIPCGetSingleMessage(long msgnum, int headers, int as_mime,
        char aaa[SIZ];
        char *bbb = NULL;
        size_t bbbsize;
+       int multipart_hunting = 0;
+       char multipart_prefix[SIZ];
 
        if (!cret) return -1;
        if (!mret) return -1;
@@ -394,6 +396,7 @@ int CtdlIPCGetSingleMessage(long msgnum, int headers, int as_mime,
        ret = CtdlIPCGenericCommand(aaa, NULL, 0, &bbb, &bbbsize, cret);
        if (ret / 100 == 1) {
                if (!as_mime) {
+                       strcpy(mret[0]->mime_chosen, "1");      /* Default chosen-part is "1" */
                        while (strlen(bbb) > 4 && bbb[4] == '=') {
                                extract_token(aaa, bbb, 0, '\n');
                                remove_token(bbb, 0, '\n');
@@ -420,11 +423,32 @@ int CtdlIPCGetSingleMessage(long msgnum, int headers, int as_mime,
                                        strcpy(mret[0]->recipient, &aaa[5]);
                                else if (!strncasecmp(aaa, "time=", 5))
                                        mret[0]->time = atol(&aaa[5]);
+
+                               /* Multipart/alternative prefix & suffix strings help
+                                * us to determine which part we want to download.
+                                */
+                               else if (!strncasecmp(aaa, "pref=", 5)) {
+                                       extract(multipart_prefix, &aaa[5], 1);
+                                       if (!strcasecmp(multipart_prefix,
+                                          "multipart/alternative")) {
+                                               ++multipart_hunting;
+                                       }
+                               }
+                               else if (!strncasecmp(aaa, "suff=", 5)) {
+                                       extract(multipart_prefix, &aaa[5], 1);
+                                       if (!strcasecmp(multipart_prefix,
+                                          "multipart/alternative")) {
+                                               ++multipart_hunting;
+                                       }
+                               }
+
                                else if (!strncasecmp(aaa, "part=", 5)) {
                                        struct parts *ptr, *chain;
        
                                        ptr = (struct parts *)calloc(1, sizeof (struct parts));
                                        if (ptr) {
+
+                                               /* Fill the buffers for the caller */
                                                extract(ptr->name, &aaa[5], 0);
                                                extract(ptr->filename, &aaa[5], 1);
                                                extract(ptr->number, &aaa[5], 2);
@@ -439,6 +463,18 @@ int CtdlIPCGetSingleMessage(long msgnum, int headers, int as_mime,
                                                                chain = chain->next;
                                                        chain->next = ptr;
                                                }
+
+                                               /* Now handle multipart/alternative */
+                                               if (multipart_hunting > 0) {
+                                                       if ( (!strcasecmp(ptr->mimetype,
+                                                            "text/plain"))
+                                                          || (!strcasecmp(ptr->mimetype,
+                                                             "text/html")) ) {
+                                                               strcpy(mret[0]->mime_chosen,
+                                                                       ptr->number);
+                                                       }
+                                               }
+
                                        }
                                }
                        }
index f2a905eb2230d3a4706eed44f28e2aa7ea51147c..f794bc90334747c8c4fe1d484df8f374c5563d34 100644 (file)
@@ -43,6 +43,7 @@ struct ctdlipcmessage {
        time_t time;                    /* Time message was posted */
        char nhdr;                      /* Suppress message header? */
        char anonymous;                 /* An anonymous message */
+       char mime_chosen[SIZ];          /* Chosen MIME part to output */
 };
 
 
index 6689f90f0d704fc23fd68872f1fe807220df03d8..89c61fd7880e29450dce9a612b0291099c4e9d12 100644 (file)
@@ -552,6 +552,10 @@ int read_message(
                }
        }
 
+       /******* end of header output, start of message text output *******/
+
+       /* scr_printf("message->mime_chosen is <%s>\n", message->mime_chosen); FIXME */
+
        if (format_type == 0) {
                fr = fmout(screenwidth, NULL, message->text, dest,
                           ((pagin == 1) ? 1 : 0), screenheight, (-1), 1);
@@ -1521,12 +1525,12 @@ RMSGREAD:       scr_flush();
             int lasta = a;
             for (finda = a; ((finda < num_msgs) && (finda >= 0)); finda += rdir)
               {
-                /* this is repetitivly dumb, but that's what computers are for.
+                /* This is repetitively dumb, but that's what computers are for.
                    We have to load up messages until we find one by us */
                 char buf[SIZ];
                 int founda = 0;
                 
-                       snprintf(buf, sizeof buf, "MSG0 %ld|%d", msg_arr[finda], 1); /* read the header so we can get 'from=' */
+                       snprintf(buf, sizeof buf, "MSG0 %ld|1", msg_arr[finda]); /* read the header so we can get 'from=' */
                serv_puts(buf);
                serv_gets(buf);
                while (serv_gets(buf), strcmp(buf, "000"))