update example mimeinfo tree
[claws.git] / src / procmime.h
index 239ebd86a57b50eb13668414adb3a99eba32ce47..9cc798a53755c7770b3ead05a5a3006013b7b02e 100644 (file)
@@ -34,8 +34,6 @@ extern "C" {
 typedef struct _MimeType       MimeType;
 typedef struct _MimeInfo       MimeInfo;
 
-#include "procmsg.h"
-
 typedef enum
 {
        ENC_7BIT,
@@ -47,19 +45,7 @@ typedef enum
        ENC_UNKNOWN
 } EncodingType;
 
-typedef enum
-{
-       MIME_TEXT,
-       MIME_TEXT_HTML,
-       MIME_MESSAGE_RFC822,
-       MIME_APPLICATION,
-       MIME_APPLICATION_OCTET_STREAM,
-       MIME_MULTIPART,
-       MIME_IMAGE,
-       MIME_AUDIO,
-       MIME_TEXT_ENRICHED,
-       MIME_UNKNOWN
-} ContentType;
+#include "procmsg.h"
 
 struct _MimeType
 {
@@ -69,58 +55,85 @@ struct _MimeType
        gchar *extension;
 };
 
+typedef enum
+{
+       MIMETYPE_TEXT,
+       MIMETYPE_IMAGE,
+       MIMETYPE_AUDIO,
+       MIMETYPE_VIDEO,
+       MIMETYPE_APPLICATION,
+       MIMETYPE_MESSAGE,
+       MIMETYPE_MULTIPART,
+       MIMETYPE_UNKNOWN,
+} MimeMediaType;
+
 /*
  * An example of MimeInfo structure:
  *
- * multipart/mixed            root  <-+ parent
- *                                    |
- *   multipart/alternative      children <-+ parent
- *                                         |
- *     text/plain                 children  --+
- *                                            |
- *     text/html                  next      <-+
- *
- *   message/rfc822             next  <-+ main
- *                                      |
- *                                sub (capsulated message)
- *
- *   image/jpeg                 next
+ * 1: +- message/rfc822                        (root)
+ *      |
+ * 2:   +- multipart/mixed             (children of 1)
+ *      |  |
+ * 3:   |  +- multipart/alternative    (children of 2)
+ *      |  |  |
+ * 4:   |  |  +- text/plain            (children of 3)
+ *      |  |  |
+ * 5:   |  |  +- text/html             (next of 4)
+ *      |  |
+ * 6:   |  +- message/rfc822           (next of 3)
+ *      |     |
+ * 7:   |     ...                      (children of 6)
+ *      |
+ * 8:   +- image/jpeg                  (next of 2)
  */
 
 struct _MimeInfo
 {
        gchar *encoding;
 
-       EncodingType encoding_type;
-       ContentType  mime_type;
-
-       gchar *content_type;
        gchar *charset;
        gchar *name;
-       gchar *boundary;
 
        gchar *content_disposition;
-       gchar *filename;
-       gchar *description;
-
-       glong fpos;
-       guint size;
 
        MimeInfo *main;
-       MimeInfo *sub;
+
+       gint level;
+
+       /* Internal data */
+       gchar *filename;
+       gboolean tmpfile;
 
        MimeInfo *next;
        MimeInfo *parent;
        MimeInfo *children;
 
-#if USE_GPGME
-       MimeInfo *plaintext;
-       gchar *plaintextfile;
+       /* --- NEW MIME STUFF --- */
+       /* Content-Type */
+       MimeMediaType    type;
+       gchar           *subtype;
+
+       GHashTable      *parameters;
+
+       /* Content-Transfer-Encoding */
+       EncodingType     encoding_type;
+
+       /* Content-Description */
+       gchar           *description;
+
+       /* Content-ID */
+       gchar           *id;
+
+       guint            offset;
+       guint            length;
+
+       /* Privacy */
        gchar *sigstatus;
        gchar *sigstatus_full;
-#endif
-
-       gint level;
+       gboolean sig_ok;
+       gboolean sig_unknown;
+       gboolean sig_expired;
+       gboolean key_expired;
 };
 
 #define IS_BOUNDARY(s, bnd, len) \
@@ -156,11 +169,8 @@ void procmime_scan_subject              (MimeInfo       *mimeinfo,
                                         const gchar    *subject);
 MimeInfo *procmime_scan_mime_header    (FILE           *fp);
 
-FILE *procmime_decode_content          (FILE           *outfp,
-                                        FILE           *infp,
-                                        MimeInfo       *mimeinfo);
+gboolean procmime_decode_content       (MimeInfo       *mimeinfo);
 gint procmime_get_part                 (const gchar    *outfile,
-                                        const gchar    *infile,
                                         MimeInfo       *mimeinfo);
 FILE *procmime_get_text_content                (MimeInfo       *mimeinfo,
                                         FILE           *infp);
@@ -176,7 +186,6 @@ gboolean procmime_find_string               (MsgInfo        *msginfo,
 
 gchar *procmime_get_tmp_file_name      (MimeInfo       *mimeinfo);
 
-ContentType procmime_scan_mime_type    (const gchar    *mime_type);
 gchar *procmime_get_mime_type          (const gchar    *filename);
 
 GList *procmime_get_mime_type_list     (void);
@@ -184,6 +193,9 @@ GList *procmime_get_mime_type_list  (void);
 EncodingType procmime_get_encoding_for_charset (const gchar    *charset);
 EncodingType procmime_get_encoding_for_file    (const gchar    *file);
 const gchar *procmime_get_encoding_str         (EncodingType    encoding);
+MimeInfo *procmime_scan_file                   (gchar          *filename);
+MimeInfo *procmime_scan_queue_file             (gchar          *filename);
+const gchar *procmime_get_type_str             (MimeMediaType   type);
 
 void renderer_read_config(void);
 void renderer_write_config(void);