2001-04-19 14:21:46 +02:00
|
|
|
/*
|
|
|
|
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
|
2007-01-03 06:42:43 +01:00
|
|
|
* Copyright (C) 1999-2007 Hiroyuki Yamamoto and the Claws Mail team
|
2001-04-19 14:21:46 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2007-07-11 18:38:12 +02:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2001-04-19 14:21:46 +02:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2007-07-11 18:38:12 +02:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
2001-04-19 14:21:46 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __PROCMIME_H__
|
|
|
|
#define __PROCMIME_H__
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef struct _MimeType MimeType;
|
|
|
|
typedef struct _MimeInfo MimeInfo;
|
|
|
|
|
2004-11-12 07:41:50 +01:00
|
|
|
#include "procmsg.h"
|
|
|
|
#include "utils.h"
|
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
ENC_7BIT,
|
|
|
|
ENC_8BIT,
|
2002-09-20 14:52:36 +02:00
|
|
|
ENC_BINARY,
|
2001-04-19 14:21:46 +02:00
|
|
|
ENC_QUOTED_PRINTABLE,
|
|
|
|
ENC_BASE64,
|
|
|
|
ENC_X_UUENCODE,
|
|
|
|
ENC_UNKNOWN
|
|
|
|
} EncodingType;
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
2004-01-12 22:28:31 +01:00
|
|
|
MIMETYPE_TEXT,
|
|
|
|
MIMETYPE_IMAGE,
|
|
|
|
MIMETYPE_AUDIO,
|
|
|
|
MIMETYPE_VIDEO,
|
|
|
|
MIMETYPE_APPLICATION,
|
|
|
|
MIMETYPE_MESSAGE,
|
|
|
|
MIMETYPE_MULTIPART,
|
2005-09-14 10:11:20 +02:00
|
|
|
MIMETYPE_UNKNOWN
|
2004-01-12 22:28:31 +01:00
|
|
|
} MimeMediaType;
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
DISPOSITIONTYPE_INLINE,
|
|
|
|
DISPOSITIONTYPE_ATTACHMENT,
|
2005-09-14 10:11:20 +02:00
|
|
|
DISPOSITIONTYPE_UNKNOWN
|
2004-01-12 22:28:31 +01:00
|
|
|
} DispositionType;
|
|
|
|
|
2004-10-12 11:45:18 +02:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
MIMECONTENT_EMPTY,
|
|
|
|
MIMECONTENT_FILE, /* the file contains all content including sub parts */
|
2005-09-14 10:11:20 +02:00
|
|
|
MIMECONTENT_MEM
|
2004-10-12 11:45:18 +02:00
|
|
|
} MimeContent;
|
|
|
|
|
2004-01-12 22:28:31 +01:00
|
|
|
#include <glib.h>
|
|
|
|
#include <stdio.h>
|
2001-04-19 14:21:46 +02:00
|
|
|
|
2003-07-20 00:36:53 +02:00
|
|
|
#include "procmsg.h"
|
2004-01-12 22:28:31 +01:00
|
|
|
#include "privacy.h"
|
2003-07-20 00:36:53 +02:00
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
struct _MimeType
|
|
|
|
{
|
|
|
|
gchar *type;
|
|
|
|
gchar *sub_type;
|
|
|
|
|
|
|
|
gchar *extension;
|
|
|
|
};
|
|
|
|
|
2001-09-20 13:53:09 +02:00
|
|
|
/*
|
|
|
|
* An example of MimeInfo structure:
|
|
|
|
*
|
2004-01-12 22:28:31 +01:00
|
|
|
* 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 6)
|
2001-09-20 13:53:09 +02:00
|
|
|
*/
|
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
struct _MimeInfo
|
|
|
|
{
|
2004-01-12 22:28:31 +01:00
|
|
|
/* Internal data */
|
2004-10-12 11:45:18 +02:00
|
|
|
MimeContent content;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
gchar *filename;
|
2004-10-19 09:28:20 +02:00
|
|
|
gchar *mem;
|
|
|
|
} data;
|
2004-10-12 11:45:18 +02:00
|
|
|
gboolean tmp;
|
2001-04-19 14:21:46 +02:00
|
|
|
|
2004-01-12 22:28:31 +01:00
|
|
|
GNode *node;
|
2001-04-19 14:21:46 +02:00
|
|
|
|
2004-01-12 22:28:31 +01:00
|
|
|
/* --- NEW MIME STUFF --- */
|
|
|
|
/* Content-Type */
|
|
|
|
MimeMediaType type;
|
|
|
|
gchar *subtype;
|
2001-04-19 14:21:46 +02:00
|
|
|
|
2004-10-12 11:45:18 +02:00
|
|
|
GHashTable *typeparameters;
|
2004-01-12 22:28:31 +01:00
|
|
|
|
|
|
|
/* Content-Transfer-Encoding */
|
|
|
|
EncodingType encoding_type;
|
2001-04-19 14:21:46 +02:00
|
|
|
|
2004-01-12 22:28:31 +01:00
|
|
|
/* Content-Description */
|
|
|
|
gchar *description;
|
|
|
|
|
|
|
|
/* Content-ID */
|
|
|
|
gchar *id;
|
|
|
|
|
2006-03-16 19:13:25 +01:00
|
|
|
/* Content-Location */
|
|
|
|
gchar *location;
|
|
|
|
|
2004-01-12 22:28:31 +01:00
|
|
|
guint offset;
|
|
|
|
guint length;
|
|
|
|
|
|
|
|
/* Content-Disposition */
|
|
|
|
DispositionType disposition;
|
2004-10-12 11:45:18 +02:00
|
|
|
GHashTable *dispositionparameters;
|
2004-01-12 22:28:31 +01:00
|
|
|
|
|
|
|
/* Privacy */
|
|
|
|
PrivacyData *privacy;
|
2001-04-19 14:21:46 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#define IS_BOUNDARY(s, bnd, len) \
|
|
|
|
(bnd && s[0] == '-' && s[1] == '-' && !strncmp(s + 2, bnd, len))
|
|
|
|
|
2004-08-06 13:34:34 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
/* MimeInfo handling */
|
|
|
|
|
|
|
|
MimeInfo *procmime_mimeinfo_new (void);
|
|
|
|
void procmime_mimeinfo_free_all (MimeInfo *mimeinfo);
|
|
|
|
|
|
|
|
MimeInfo *procmime_mimeinfo_insert (MimeInfo *parent,
|
|
|
|
MimeInfo *mimeinfo);
|
2003-04-05 22:38:53 +02:00
|
|
|
void procmime_mimeinfo_replace (MimeInfo *old_mimeinfo,
|
|
|
|
MimeInfo *new_mimeinfo);
|
2001-09-20 13:53:09 +02:00
|
|
|
|
2004-01-12 22:28:31 +01:00
|
|
|
MimeInfo *procmime_mimeinfo_parent (MimeInfo *mimeinfo);
|
2001-09-20 13:53:09 +02:00
|
|
|
MimeInfo *procmime_mimeinfo_next (MimeInfo *mimeinfo);
|
2001-04-19 14:21:46 +02:00
|
|
|
|
|
|
|
MimeInfo *procmime_scan_message (MsgInfo *msginfo);
|
|
|
|
void procmime_scan_multipart_message (MimeInfo *mimeinfo,
|
|
|
|
FILE *fp);
|
2004-01-12 22:28:31 +01:00
|
|
|
const gchar *procmime_mimeinfo_get_parameter
|
|
|
|
(MimeInfo *mimeinfo,
|
|
|
|
const gchar *name);
|
2001-04-19 14:21:46 +02:00
|
|
|
|
|
|
|
/* scan headers */
|
|
|
|
|
|
|
|
void procmime_scan_encoding (MimeInfo *mimeinfo,
|
|
|
|
const gchar *encoding);
|
|
|
|
void procmime_scan_content_type (MimeInfo *mimeinfo,
|
|
|
|
const gchar *content_type);
|
|
|
|
void procmime_scan_content_disposition (MimeInfo *mimeinfo,
|
|
|
|
const gchar *content_disposition);
|
2001-12-22 17:09:08 +01:00
|
|
|
void procmime_scan_content_description (MimeInfo *mimeinfo,
|
|
|
|
const gchar *content_description);
|
|
|
|
void procmime_scan_subject (MimeInfo *mimeinfo,
|
|
|
|
const gchar *subject);
|
2002-02-21 15:56:09 +01:00
|
|
|
MimeInfo *procmime_scan_mime_header (FILE *fp);
|
2001-04-19 14:21:46 +02:00
|
|
|
|
2004-01-12 22:28:31 +01:00
|
|
|
gboolean procmime_decode_content (MimeInfo *mimeinfo);
|
2004-10-12 11:45:18 +02:00
|
|
|
gboolean procmime_encode_content (MimeInfo *mimeinfo, EncodingType encoding);
|
2001-04-19 14:21:46 +02:00
|
|
|
gint procmime_get_part (const gchar *outfile,
|
|
|
|
MimeInfo *mimeinfo);
|
2004-01-12 22:28:31 +01:00
|
|
|
FILE *procmime_get_text_content (MimeInfo *mimeinfo);
|
2001-09-20 13:53:09 +02:00
|
|
|
FILE *procmime_get_first_text_content (MsgInfo *msginfo);
|
2005-06-25 11:48:51 +02:00
|
|
|
FILE *procmime_get_first_encrypted_text_content
|
|
|
|
(MsgInfo *msginfo);
|
2001-09-20 13:53:09 +02:00
|
|
|
|
|
|
|
gboolean procmime_find_string_part (MimeInfo *mimeinfo,
|
|
|
|
const gchar *filename,
|
|
|
|
const gchar *str,
|
2004-11-12 07:41:50 +01:00
|
|
|
StrFindFunc find_func);
|
2001-09-20 13:53:09 +02:00
|
|
|
gboolean procmime_find_string (MsgInfo *msginfo,
|
|
|
|
const gchar *str,
|
2004-11-12 07:41:50 +01:00
|
|
|
StrFindFunc find_func);
|
2001-04-19 14:21:46 +02:00
|
|
|
|
|
|
|
gchar *procmime_get_tmp_file_name (MimeInfo *mimeinfo);
|
2005-04-01 10:16:46 +02:00
|
|
|
gchar *procmime_get_part_file_name (MimeInfo *mimeinfo);
|
2001-04-19 14:21:46 +02:00
|
|
|
|
|
|
|
gchar *procmime_get_mime_type (const gchar *filename);
|
|
|
|
|
2001-06-29 20:48:24 +02:00
|
|
|
GList *procmime_get_mime_type_list (void);
|
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
EncodingType procmime_get_encoding_for_charset (const gchar *charset);
|
2006-02-08 13:56:43 +01:00
|
|
|
EncodingType procmime_get_encoding_for_text_file(const gchar *file,
|
|
|
|
gboolean *has_binary);
|
2001-04-19 14:21:46 +02:00
|
|
|
const gchar *procmime_get_encoding_str (EncodingType encoding);
|
2004-10-12 11:45:18 +02:00
|
|
|
MimeInfo *procmime_scan_file (const gchar *filename);
|
|
|
|
MimeInfo *procmime_scan_queue_file (const gchar *filename);
|
|
|
|
const gchar *procmime_get_media_type_str (MimeMediaType type);
|
|
|
|
MimeMediaType procmime_get_media_type (const gchar *str);
|
|
|
|
gchar *procmime_get_content_type_str (MimeMediaType type,
|
|
|
|
const gchar *subtype);
|
2004-10-02 18:33:17 +02:00
|
|
|
void procmime_force_charset (const gchar *str);
|
|
|
|
void procmime_force_encoding (EncodingType encoding);
|
2005-06-25 11:48:51 +02:00
|
|
|
gboolean procmime_msginfo_is_encrypted (MsgInfo *msginfo);
|
2004-10-12 11:45:18 +02:00
|
|
|
|
2002-01-28 00:21:17 +01:00
|
|
|
void renderer_read_config(void);
|
|
|
|
void renderer_write_config(void);
|
|
|
|
|
2004-10-12 11:45:18 +02:00
|
|
|
gint procmime_write_mimeinfo(MimeInfo *mimeinfo, FILE *fp);
|
|
|
|
|
2003-04-05 22:38:53 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
#endif /* __PROCMIME_H__ */
|