2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2007 Hiroyuki Yamamoto and the Claws Mail team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #ifndef __PROCMIME_H__
21 #define __PROCMIME_H__
27 typedef struct _MimeType MimeType;
28 typedef struct _MimeInfo MimeInfo;
58 DISPOSITIONTYPE_INLINE,
59 DISPOSITIONTYPE_ATTACHMENT,
60 DISPOSITIONTYPE_UNKNOWN
66 MIMECONTENT_FILE, /* the file contains all content including sub parts */
85 * An example of MimeInfo structure:
87 * 1: +- message/rfc822 (root)
89 * 2: +- multipart/mixed (children of 1)
91 * 3: +- multipart/alternative (children of 2)
93 * 4: | +- text/plain (children of 3)
95 * 5: | +- text/html (next of 4)
97 * 6: +- message/rfc822 (next of 3)
99 * 7: | ... (children of 6)
101 * 8: +- image/jpeg (next of 6)
117 /* --- NEW MIME STUFF --- */
122 GHashTable *typeparameters;
124 /* Content-Transfer-Encoding */
125 EncodingType encoding_type;
127 /* Content-Description */
133 /* Content-Location */
139 /* Content-Disposition */
140 DispositionType disposition;
141 GHashTable *dispositionparameters;
144 PrivacyData *privacy;
147 #define IS_BOUNDARY(s, bnd, len) \
148 (bnd && s[0] == '-' && s[1] == '-' && !strncmp(s + 2, bnd, len))
152 #endif /* __cplusplus */
154 /* MimeInfo handling */
156 MimeInfo *procmime_mimeinfo_new (void);
157 void procmime_mimeinfo_free_all (MimeInfo *mimeinfo);
159 MimeInfo *procmime_mimeinfo_insert (MimeInfo *parent,
161 void procmime_mimeinfo_replace (MimeInfo *old_mimeinfo,
162 MimeInfo *new_mimeinfo);
164 MimeInfo *procmime_mimeinfo_parent (MimeInfo *mimeinfo);
165 MimeInfo *procmime_mimeinfo_next (MimeInfo *mimeinfo);
167 MimeInfo *procmime_scan_message (MsgInfo *msginfo);
168 void procmime_scan_multipart_message (MimeInfo *mimeinfo,
170 const gchar *procmime_mimeinfo_get_parameter
176 void procmime_scan_encoding (MimeInfo *mimeinfo,
177 const gchar *encoding);
178 void procmime_scan_content_type (MimeInfo *mimeinfo,
179 const gchar *content_type);
180 void procmime_scan_content_disposition (MimeInfo *mimeinfo,
181 const gchar *content_disposition);
182 void procmime_scan_content_description (MimeInfo *mimeinfo,
183 const gchar *content_description);
184 void procmime_scan_subject (MimeInfo *mimeinfo,
185 const gchar *subject);
186 MimeInfo *procmime_scan_mime_header (FILE *fp);
188 gboolean procmime_decode_content (MimeInfo *mimeinfo);
189 gboolean procmime_encode_content (MimeInfo *mimeinfo, EncodingType encoding);
190 gint procmime_get_part (const gchar *outfile,
192 FILE *procmime_get_text_content (MimeInfo *mimeinfo);
193 FILE *procmime_get_first_text_content (MsgInfo *msginfo);
194 FILE *procmime_get_first_encrypted_text_content
197 gboolean procmime_find_string_part (MimeInfo *mimeinfo,
198 const gchar *filename,
200 StrFindFunc find_func);
201 gboolean procmime_find_string (MsgInfo *msginfo,
203 StrFindFunc find_func);
205 gchar *procmime_get_tmp_file_name (MimeInfo *mimeinfo);
206 gchar *procmime_get_part_file_name (MimeInfo *mimeinfo);
208 gchar *procmime_get_mime_type (const gchar *filename);
210 GList *procmime_get_mime_type_list (void);
212 EncodingType procmime_get_encoding_for_charset (const gchar *charset);
213 EncodingType procmime_get_encoding_for_text_file(const gchar *file,
214 gboolean *has_binary);
215 const gchar *procmime_get_encoding_str (EncodingType encoding);
216 MimeInfo *procmime_scan_file (const gchar *filename);
217 MimeInfo *procmime_scan_queue_file (const gchar *filename);
218 const gchar *procmime_get_media_type_str (MimeMediaType type);
219 MimeMediaType procmime_get_media_type (const gchar *str);
220 gchar *procmime_get_content_type_str (MimeMediaType type,
221 const gchar *subtype);
222 void procmime_force_charset (const gchar *str);
223 void procmime_force_encoding (EncodingType encoding);
224 gboolean procmime_msginfo_is_encrypted (MsgInfo *msginfo);
226 void renderer_read_config(void);
227 void renderer_write_config(void);
229 gint procmime_write_mimeinfo(MimeInfo *mimeinfo, FILE *fp);
233 #endif /* __cplusplus */
235 #endif /* __PROCMIME_H__ */