update example mimeinfo tree
[claws.git] / src / procmime.h
index 5a853c342d85734578379888b788034f57fe7048..9cc798a53755c7770b3ead05a5a3006013b7b02e 100644 (file)
 #ifndef __PROCMIME_H__
 #define __PROCMIME_H__
 
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
 #ifdef HAVE_CONFIG_H
 #  include "config.h"
 #endif
 typedef struct _MimeType       MimeType;
 typedef struct _MimeInfo       MimeInfo;
 
-#include "procmsg.h"
-
 typedef enum
 {
        ENC_7BIT,
        ENC_8BIT,
+       ENC_BINARY,
        ENC_QUOTED_PRINTABLE,
        ENC_BASE64,
        ENC_X_UUENCODE,
        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_UNKNOWN
-} ContentType;
+#include "procmsg.h"
 
 struct _MimeType
 {
@@ -63,57 +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;
-
-       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) \
@@ -122,13 +142,12 @@ struct _MimeInfo
 /* MimeInfo handling */
 
 MimeInfo *procmime_mimeinfo_new                (void);
-void procmime_mimeinfo_free            (MimeInfo       *mimeinfo);
 void procmime_mimeinfo_free_all                (MimeInfo       *mimeinfo);
 
 MimeInfo *procmime_mimeinfo_insert     (MimeInfo       *parent,
                                         MimeInfo       *mimeinfo);
-void procmime_mimeinfo_replace         (MimeInfo       *old,
-                                        MimeInfo       *new);
+void procmime_mimeinfo_replace         (MimeInfo       *old_mimeinfo,
+                                        MimeInfo       *new_mimeinfo);
 
 MimeInfo *procmime_mimeinfo_next       (MimeInfo       *mimeinfo);
 
@@ -144,13 +163,14 @@ void procmime_scan_content_type           (MimeInfo       *mimeinfo,
                                         const gchar    *content_type);
 void procmime_scan_content_disposition (MimeInfo       *mimeinfo,
                                         const gchar    *content_disposition);
+void procmime_scan_content_description (MimeInfo       *mimeinfo,
+                                        const gchar    *content_description);
+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);
@@ -166,12 +186,22 @@ 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);
 
 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);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
 
 #endif /* __PROCMIME_H__ */