Updated the MIME Parser API to include Content-ID in
authorArt Cancro <ajc@citadel.org>
Fri, 26 Sep 2008 16:02:27 +0000 (16:02 +0000)
committerArt Cancro <ajc@citadel.org>
Fri, 26 Sep 2008 16:02:27 +0000 (16:02 +0000)
the callback functions.  This effects the entire Citadel system, so
you will have to update all three components now.

citadel/citadel.h
citadel/modules/calendar/serv_calendar.c
citadel/modules/imap/imap_fetch.c
citadel/modules/notes/serv_notes.c
citadel/modules/vcard/serv_vcard.c
citadel/msgbase.c
libcitadel/lib/libcitadel.h
libcitadel/lib/mime_parser.c
webcit/groupdav_get.c
webcit/webcit.c
webcit/webcit.h

index 5f205c4cbb4f8decd08254c8ddab41e3635f7ea9..5b6bb0a69fae3a7b1f276d16a7d806f312f494f3 100644 (file)
@@ -38,10 +38,10 @@ extern "C" {
  * usually more strict because you're not really supposed to dump/load and
  * upgrade at the same time.
  */
-#define REV_LEVEL      738             /* This version */
+#define REV_LEVEL      739             /* This version */
 #define REV_MIN                591             /* Oldest compatible database */
 #define EXPORT_REV_MIN 737             /* Oldest compatible export files */
-#define LIBCITADEL_MIN 738             /* Minimum required version of libcitadel */
+#define LIBCITADEL_MIN 739             /* Minimum required version of libcitadel */
 
 #define SERVER_TYPE 0                  /* zero for stock Citadel; other developers please
                                           obtain SERVER_TYPE codes for your implementations */
index 62b3a4e42c95b64aebdb75a6263fda17d01d31bd..b1cc6e4963643176ffcfb064a85a54705714d487 100644 (file)
@@ -19,7 +19,7 @@
 #ifdef HAVE_STRINGS_H
 #include <strings.h>
 #endif
-#include <ical.h>
+#include <libical/ical.h>
 #include <libcitadel.h>
 #include "citadel.h"
 #include "server.h"
@@ -355,7 +355,7 @@ void ical_send_a_reply(icalcomponent *request, char *action) {
  */
 void ical_locate_part(char *name, char *filename, char *partnum, char *disp,
                void *content, char *cbtype, char *cbcharset, size_t length, char *encoding,
-               void *cbuserdata) {
+               char *cbid, void *cbuserdata) {
 
        struct ical_respond_data *ird = NULL;
 
@@ -514,7 +514,7 @@ struct original_event_container {
  */
 void ical_locate_original_event(char *name, char *filename, char *partnum, char *disp,
                void *content, char *cbtype, char *cbcharset, size_t length, char *encoding,
-               void *cbuserdata) {
+               char *cbid, void *cbuserdata) {
 
        struct original_event_container *oec = NULL;
 
@@ -2007,7 +2007,7 @@ void ical_saving_vevent(icalcomponent *cal) {
  */
 void ical_obj_beforesave_backend(char *name, char *filename, char *partnum,
                char *disp, void *content, char *cbtype, char *cbcharset, size_t length,
-               char *encoding, void *cbuserdata)
+               char *encoding, char *cbid, void *cbuserdata)
 {
        icalcomponent *cal, *nested_event, *nested_todo, *whole_cal;
        icalproperty *p;
@@ -2151,7 +2151,7 @@ int ical_obj_beforesave(struct CtdlMessage *msg)
  */
 void ical_obj_aftersave_backend(char *name, char *filename, char *partnum,
                char *disp, void *content, char *cbtype, char *cbcharset, size_t length,
-               char *encoding, void *cbuserdata)
+               char *encoding, char *cbid, void *cbuserdata)
 {
        icalcomponent *cal;
 
index a7a4f3fd3cba6c10d0d42154cfe5de83dc1ce0c2..75a05dbb41ab571672a005cd720dedbc43367d15 100644 (file)
@@ -261,7 +261,7 @@ void imap_fetch_rfc822(long msgnum, char *whichfmt) {
  */
 void imap_load_part(char *name, char *filename, char *partnum, char *disp,
                    void *content, char *cbtype, char *cbcharset, size_t length, char *encoding,
-                   void *cbuserdata)
+                   char *cbid, void *cbuserdata)
 {
        char mbuf2[SIZ];
        char *desired_section;
@@ -728,7 +728,7 @@ void imap_fetch_body(long msgnum, char *item, int is_peek) {
 void imap_fetch_bodystructure_pre(
                char *name, char *filename, char *partnum, char *disp,
                void *content, char *cbtype, char *cbcharset, size_t length, char *encoding,
-               void *cbuserdata
+               char *cbid, void *cbuserdata
                ) {
 
        cprintf("(");
@@ -742,7 +742,7 @@ void imap_fetch_bodystructure_pre(
 void imap_fetch_bodystructure_post(
                char *name, char *filename, char *partnum, char *disp,
                void *content, char *cbtype, char *cbcharset, size_t length, char *encoding,
-               void *cbuserdata
+               char *cbid, void *cbuserdata
                ) {
 
        char subtype[128];
@@ -768,7 +768,7 @@ void imap_fetch_bodystructure_post(
 void imap_fetch_bodystructure_part(
                char *name, char *filename, char *partnum, char *disp,
                void *content, char *cbtype, char *cbcharset, size_t length, char *encoding,
-               void *cbuserdata
+               char *cbid, void *cbuserdata
                ) {
 
        int have_cbtype = 0;
index 56c1e6ee94690a9260bfcfc8753911001bf54008..8d3f888224e7c763e88a66ffd4feea799ea953b4 100644 (file)
@@ -49,7 +49,7 @@
  */
 void notes_extract_vnote(char *name, char *filename, char *partnum, char *disp,
                   void *content, char *cbtype, char *cbcharset, size_t length,
-                  char *encoding, void *cbuserdata)
+                  char *encoding, char *cbid, void *cbuserdata)
 {
        struct vnote **v = (struct vnote **) cbuserdata;
 
index a6f6f9d514f22a78364a4d6feeb9ff6cfa8b6363..8561d43cec9ae7747a7208ceb6c05ed40c120e5a 100644 (file)
@@ -458,7 +458,7 @@ void extract_friendly_name(char *namebuf, size_t namebuf_len, struct vCard *v)
  */
 void vcard_extract_vcard(char *name, char *filename, char *partnum, char *disp,
                   void *content, char *cbtype, char *cbcharset, size_t length,
-                  char *encoding, void *cbuserdata)
+                  char *encoding, char *cbid, void *cbuserdata)
 {
        struct vCard **v = (struct vCard **) cbuserdata;
 
@@ -1176,7 +1176,7 @@ void cmd_gvea(char *argbuf)
  */
 void dvca_mime_callback(char *name, char *filename, char *partnum, char *disp,
                void *content, char *cbtype, char *cbcharset, size_t length, char *encoding,
-               void *cbuserdata) {
+               char *cbid, void *cbuserdata) {
 
        struct vCard *v;
        char displayname[256];
index e48dca90193a79e6d7ef841ef69bd9a355e3548b..9ccc60a9a1841ee3bcbc7e9c557494035979e62c 100644 (file)
@@ -925,7 +925,7 @@ void memfmout(
  */
 void list_this_part(char *name, char *filename, char *partnum, char *disp,
                    void *content, char *cbtype, char *cbcharset, size_t length, char *encoding,
-                   void *cbuserdata)
+                   char *cbid, void *cbuserdata)
 {
        struct ma_info *ma;
        
@@ -941,7 +941,7 @@ void list_this_part(char *name, char *filename, char *partnum, char *disp,
  */
 void list_this_pref(char *name, char *filename, char *partnum, char *disp,
                    void *content, char *cbtype, char *cbcharset, size_t length, char *encoding,
-                   void *cbuserdata)
+                   char *cbid, void *cbuserdata)
 {
        struct ma_info *ma;
        
@@ -960,7 +960,7 @@ void list_this_pref(char *name, char *filename, char *partnum, char *disp,
  */
 void list_this_suff(char *name, char *filename, char *partnum, char *disp,
                    void *content, char *cbtype, char *cbcharset, size_t length, char *encoding,
-                   void *cbuserdata)
+                   char *cbid, void *cbuserdata)
 {
        struct ma_info *ma;
        
@@ -979,7 +979,7 @@ void list_this_suff(char *name, char *filename, char *partnum, char *disp,
  */
 void mime_download(char *name, char *filename, char *partnum, char *disp,
                   void *content, char *cbtype, char *cbcharset, size_t length,
-                  char *encoding, void *cbuserdata)
+                  char *encoding, char *cbid, void *cbuserdata)
 {
 
        /* Silently go away if there's already a download open... */
@@ -1008,7 +1008,7 @@ void mime_download(char *name, char *filename, char *partnum, char *disp,
  */
 void mime_spew_section(char *name, char *filename, char *partnum, char *disp,
                   void *content, char *cbtype, char *cbcharset, size_t length,
-                  char *encoding, void *cbuserdata)
+                  char *encoding, char *cbid, void *cbuserdata)
 {
        int *found_it = (int *)cbuserdata;
 
@@ -1161,7 +1161,7 @@ void CtdlFreeMessage(struct CtdlMessage *msg)
  */
 void fixed_output_pre(char *name, char *filename, char *partnum, char *disp,
                void *content, char *cbtype, char *cbcharset, size_t length, char *encoding,
-               void *cbuserdata)
+               char *cbid, void *cbuserdata)
 {
        struct ma_info *ma;
        
@@ -1181,7 +1181,7 @@ void fixed_output_pre(char *name, char *filename, char *partnum, char *disp,
  */
 void fixed_output_post(char *name, char *filename, char *partnum, char *disp,
                void *content, char *cbtype, char *cbcharset, size_t length,
-               char *encoding, void *cbuserdata)
+               char *encoding, char *cbid, void *cbuserdata)
 {
        struct ma_info *ma;
        
@@ -1201,7 +1201,7 @@ void fixed_output_post(char *name, char *filename, char *partnum, char *disp,
  */
 void fixed_output(char *name, char *filename, char *partnum, char *disp,
                void *content, char *cbtype, char *cbcharset, size_t length,
-               char *encoding, void *cbuserdata)
+               char *encoding, char *cbid, void *cbuserdata)
 {
        char *ptr;
        char *wptr;
@@ -1274,7 +1274,7 @@ void fixed_output(char *name, char *filename, char *partnum, char *disp,
  */
 void choose_preferred(char *name, char *filename, char *partnum, char *disp,
                void *content, char *cbtype, char *cbcharset, size_t length,
-               char *encoding, void *cbuserdata)
+               char *encoding, char *cbid, void *cbuserdata)
 {
        char buf[1024];
        int i;
@@ -1304,7 +1304,7 @@ void choose_preferred(char *name, char *filename, char *partnum, char *disp,
  */
 void output_preferred(char *name, char *filename, char *partnum, char *disp,
                void *content, char *cbtype, char *cbcharset, size_t length,
-               char *encoding, void *cbuserdata)
+               char *encoding, char *cbid, void *cbuserdata)
 {
        int i;
        char buf[128];
@@ -1352,7 +1352,7 @@ void output_preferred(char *name, char *filename, char *partnum, char *disp,
        /* No translations required or possible: output as text/plain */
        cprintf("Content-type: text/plain\n\n");
        fixed_output(name, filename, partnum, disp, content, cbtype, cbcharset,
-                       length, encoding, cbuserdata);
+                       length, encoding, cbid, cbuserdata);
 }
 
 
@@ -1368,7 +1368,7 @@ struct encapmsg {
  */
 void extract_encapsulated_message(char *name, char *filename, char *partnum, char *disp,
                   void *content, char *cbtype, char *cbcharset, size_t length,
-                  char *encoding, void *cbuserdata)
+                  char *encoding, char *cbid, void *cbuserdata)
 {
        struct encapmsg *encap;
 
index 2c5b48d915cede3b930d2691571c6b8d005ec528..35438cdd7625121041795f56c4a409d1f77acdb6 100644 (file)
@@ -15,7 +15,7 @@
 #include <time.h>
 #include <stdlib.h>
 #include <stdarg.h>
-#define LIBCITADEL_VERSION_NUMBER      738
+#define LIBCITADEL_VERSION_NUMBER      739
 
 /*
  * Here's a bunch of stupid magic to make the MIME parser portable.
@@ -90,6 +90,7 @@ void mime_parser(char *content_start, char *content_end,
                        char *cbcharset,
                        size_t cblength,
                        char *cbencoding,
+                       char *cbid,
                        void *cbuserdata),
                void (*PreMultiPartCallBack)
                        (char *cbname,
@@ -101,6 +102,7 @@ void mime_parser(char *content_start, char *content_end,
                        char *cbcharset,
                        size_t cblength,
                        char *cbencoding,
+                       char *cbid,
                        void *cbuserdata),
                void (*PostMultiPartCallBack)
                        (char *cbname,
@@ -112,6 +114,7 @@ void mime_parser(char *content_start, char *content_end,
                        char *cbcharset,
                        size_t cblength,
                        char *cbencoding,
+                       char *cbid,
                        void *cbuserdata),
                void *userdata,
                int dont_decode
@@ -124,6 +127,7 @@ void mime_decode(char *partnum,
                 char *part_start, size_t length,
                 char *content_type, char *charset, char *encoding,
                 char *disposition,
+                char *id,
                 char *name, char *filename,
                 void (*CallBack)
                  (char *cbname,
@@ -135,6 +139,7 @@ void mime_decode(char *partnum,
                   char *cbcharset,
                   size_t cblength,
                   char *cbencoding,
+                  char *cbid,
                   void *cbuserdata),
                 void (*PreMultiPartCallBack)
                  (char *cbname,
@@ -146,6 +151,7 @@ void mime_decode(char *partnum,
                   char *cbcharset,
                   size_t cblength,
                   char *cbencoding,
+                  char *cbid,
                   void *cbuserdata),
                 void (*PostMultiPartCallBack)
                  (char *cbname,
@@ -157,6 +163,7 @@ void mime_decode(char *partnum,
                   char *cbcharset,
                   size_t cblength,
                   char *cbencoding,
+                  char *cbid,
                   void *cbuserdata),
                  void *userdata,
                  int dont_decode
@@ -173,6 +180,7 @@ void the_mime_parser(char *partnum,
                       char *cbcharset,
                       size_t cblength,
                       char *cbencoding,
+                      char *cbid,
                       void *cbuserdata),
                     void (*PreMultiPartCallBack)
                      (char *cbname,
@@ -184,6 +192,7 @@ void the_mime_parser(char *partnum,
                       char *cbcharset,
                       size_t cblength,
                       char *cbencoding,
+                      char *cbid,
                       void *cbuserdata),
                     void (*PostMultiPartCallBack)
                      (char *cbname,
@@ -195,6 +204,7 @@ void the_mime_parser(char *partnum,
                       char *cbcharset,
                       size_t cblength,
                       char *cbencoding,
+                      char *cbid,
                       void *cbuserdata),
                      void *userdata,
                      int dont_decode
index bbc255463f44bfc038812dbd66c105f27e88a88a..68f09a277514719acd1dfc9e3cc14ffbbc1eb6fa 100644 (file)
@@ -116,6 +116,7 @@ void mime_decode(char *partnum,
                 char *part_start, size_t length,
                 char *content_type, char *charset, char *encoding,
                 char *disposition,
+                char *id,
                 char *name, char *filename,
                 void (*CallBack)
                  (char *cbname,
@@ -127,6 +128,7 @@ void mime_decode(char *partnum,
                   char *cbcharset,
                   size_t cblength,
                   char *cbencoding,
+                  char *cbid,
                   void *cbuserdata),
                 void (*PreMultiPartCallBack)
                  (char *cbname,
@@ -138,6 +140,7 @@ void mime_decode(char *partnum,
                   char *cbcharset,
                   size_t cblength,
                   char *cbencoding,
+                  char *cbid,
                   void *cbuserdata),
                 void (*PostMultiPartCallBack)
                  (char *cbname,
@@ -149,6 +152,7 @@ void mime_decode(char *partnum,
                   char *cbcharset,
                   size_t cblength,
                   char *cbencoding,
+                  char *cbid,
                   void *cbuserdata),
                  void *userdata,
                  int dont_decode
@@ -171,7 +175,7 @@ void mime_decode(char *partnum,
                if (CallBack != NULL) {
                        CallBack(name, filename, fixed_partnum(partnum),
                                disposition, part_start,
-                               content_type, charset, length, encoding, userdata);
+                               content_type, charset, length, encoding, id, userdata);
                        }
                return;
        }
@@ -203,7 +207,7 @@ void mime_decode(char *partnum,
        if (bytes_decoded > 0) if (CallBack != NULL) {
                CallBack(name, filename, fixed_partnum(partnum),
                        disposition, decoded,
-                       content_type, charset, bytes_decoded, "binary", userdata);
+                       content_type, charset, bytes_decoded, "binary", id, userdata);
        }
 
        free(decoded);
@@ -227,6 +231,7 @@ void the_mime_parser(char *partnum,
                       char *cbcharset,
                       size_t cblength,
                       char *cbencoding,
+                      char *cbid,
                       void *cbuserdata),
                     void (*PreMultiPartCallBack)
                      (char *cbname,
@@ -238,6 +243,7 @@ void the_mime_parser(char *partnum,
                       char *cbcharset,
                       size_t cblength,
                       char *cbencoding,
+                      char *cbid,
                       void *cbuserdata),
                     void (*PostMultiPartCallBack)
                      (char *cbname,
@@ -249,6 +255,7 @@ void the_mime_parser(char *partnum,
                       char *cbcharset,
                       size_t cblength,
                       char *cbencoding,
+                      char *cbid,
                       void *cbuserdata),
                      void *userdata,
                      int dont_decode
@@ -270,6 +277,7 @@ void the_mime_parser(char *partnum,
        size_t content_length;
        char *encoding;
        char *disposition;
+       char *id;
        char *name = NULL;
        char *content_type_name;
        char *content_disposition_name;
@@ -320,6 +328,9 @@ void the_mime_parser(char *partnum,
        disposition = malloc(SIZ);
        memset(disposition, 0, SIZ);
 
+       id = malloc(SIZ);
+       memset(id, 0, SIZ);
+
        /* If the caller didn't supply an endpointer, generate one by measure */
        if (content_end == NULL) {
                content_end = &content_start[strlen(content_start)];
@@ -359,6 +370,11 @@ void the_mime_parser(char *partnum,
                                extract_key(content_disposition_name, disposition, "name");
                                extract_key(filename, disposition, "filename");
                        }
+                       if (!strncasecmp(header, "Content-ID:", 11)) {
+                               strcpy(id, &header[11]);
+                               striplt(id);
+                               stripallbut(id, '<', '>');
+                       }
                        if (!strncasecmp(header, "Content-length: ", 15)) {
                                char clbuf[10];
                                safestrncpy(clbuf, &header[15], sizeof clbuf);
@@ -400,7 +416,7 @@ void the_mime_parser(char *partnum,
                if (PreMultiPartCallBack != NULL) {
                        PreMultiPartCallBack("", "", partnum, "",
                                NULL, content_type, charset,
-                               0, encoding, userdata);
+                               0, encoding, id, userdata);
                }
 
                /* Figure out where the boundaries are */
@@ -478,7 +494,7 @@ void the_mime_parser(char *partnum,
 
                if (PostMultiPartCallBack != NULL) {
                        PostMultiPartCallBack("", "", partnum, "", NULL,
-                               content_type, charset, 0, encoding, userdata);
+                               content_type, charset, 0, encoding, id, userdata);
                }
                goto end_parser;
        }
@@ -518,7 +534,7 @@ void the_mime_parser(char *partnum,
                 */
                mime_decode(partnum,
                        part_start, length,
-                       content_type, charset, encoding, disposition,
+                       content_type, charset, encoding, disposition, id,
                        name, filename,
                        CallBack, NULL, NULL,
                        userdata, dont_decode
@@ -532,7 +548,7 @@ void the_mime_parser(char *partnum,
                        if (PreMultiPartCallBack != NULL) {
                                PreMultiPartCallBack("", "", partnum, "",
                                        NULL, content_type, charset,
-                                       0, encoding, userdata);
+                                       0, encoding, id, userdata);
                        }
                        if (CallBack != NULL) {
                                if (strlen(partnum) > 0) {
@@ -557,7 +573,7 @@ void the_mime_parser(char *partnum,
                        }
                        if (PostMultiPartCallBack != NULL) {
                                PostMultiPartCallBack("", "", partnum, "", NULL,
-                                       content_type, charset, 0, encoding, userdata);
+                                       content_type, charset, 0, encoding, id, userdata);
                        }
 
 
@@ -577,6 +593,7 @@ end_parser: /* free the buffers!  end the oppression!! */
        free(content_disposition_name);
        free(filename);
        free(disposition);
+       free(id);
 }
 
 
@@ -600,6 +617,7 @@ void mime_parser(char *content_start,
                   char *cbcharset,
                   size_t cblength,
                   char *cbencoding,
+                  char *cbid,
                   void *cbuserdata),
 
                 void (*PreMultiPartCallBack)
@@ -612,6 +630,7 @@ void mime_parser(char *content_start,
                   char *cbcharset,
                   size_t cblength,
                   char *cbencoding,
+                  char *cbid,
                   void *cbuserdata),
 
                 void (*PostMultiPartCallBack)
@@ -624,6 +643,7 @@ void mime_parser(char *content_start,
                   char *cbcharset,
                   size_t cblength,
                   char *cbencoding,
+                  char *cbid,
                   void *cbuserdata),
 
                  void *userdata,
index 928a5669b947695fa15f561e374cd7f2ac6720a3..40b62d72c1506502d2831ad86d0d838d0c8aed19 100644 (file)
@@ -46,7 +46,7 @@ void groupdav_get_big_ics(void) {
  */
 void extract_preferred(char *name, char *filename, char *partnum, char *disp,
                        void *content, char *cbtype, char *cbcharset,
-                       size_t length, char *encoding, void *userdata)
+                       size_t length, char *encoding, char *cbid, void *userdata)
 {
        struct epdata *epdata = (struct epdata *)userdata;
        int hit = 0;
index e03a8154595034ceb35ca213967f218433bf5caa..51105a76bb72052be0eacf27ea2d6bf4bf456cb9 100644 (file)
@@ -1147,11 +1147,12 @@ void authorization_required(const char *message)
  * cbcharset   Character set
  * length      Content length
  * encoding    MIME encoding type (not needed)
+ * cbid                Content ID (not needed)
  * userdata    Not used here
  */
 void upload_handler(char *name, char *filename, char *partnum, char *disp,
                        void *content, char *cbtype, char *cbcharset,
-                       size_t length, char *encoding, void *userdata)
+                       size_t length, char *encoding, char *cbid, void *userdata)
 {
        urlcontent *u;
 #ifdef DEBUG_URLSTRINGS
index ebb565fc8cb91288dbd3b918e30a9ce95d553362..220c68f7d9ddd8f6abd6a268c3db7b3bd6c63dc8 100644 (file)
@@ -107,9 +107,9 @@ extern locale_t wc_locales[];
 #define PORT_NUM               2000            /* port number to listen on */
 #define DEVELOPER_ID           0
 #define CLIENT_ID              4
-#define CLIENT_VERSION         737             /* This version of WebCit */
-#define MINIMUM_CIT_VERSION    737             /* min required Citadel ver */
-#define        LIBCITADEL_MIN          738             /* min required libcitadel ver */
+#define CLIENT_VERSION         739             /* This version of WebCit */
+#define MINIMUM_CIT_VERSION    739             /* min required Citadel ver */
+#define        LIBCITADEL_MIN          739             /* min required libcitadel ver */
 #define DEFAULT_HOST           "localhost"     /* Default Citadel server */
 #define DEFAULT_PORT           "504"
 #define TARGET                 "webcit01"      /* Target for inline URL's */