2 * Claws Mail -- a GTK based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2021 the Claws Mail team and Hiroyuki Yamamoto
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 3 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, see <http://www.gnu.org/licenses/>.
20 #ifndef __PROCMIME_H__
21 #define __PROCMIME_H__
24 #include "claws-features.h"
31 #include "proctypes.h"
59 DISPOSITIONTYPE_INLINE
,
60 DISPOSITIONTYPE_ATTACHMENT
,
61 DISPOSITIONTYPE_UNKNOWN
67 MIMECONTENT_FILE
, /* the file contains all content including sub parts */
87 const gchar
*sub_type
;
89 gboolean (*parse
)(MimeParser
*parser
, MimeInfo
*mimeinfo
);
93 * An example of MimeInfo structure:
95 * 1: +- message/rfc822 (root)
97 * 2: +- multipart/mixed (children of 1)
99 * 3: +- multipart/alternative (children of 2)
101 * 4: | +- text/plain (children of 3)
103 * 5: | +- text/html (next of 4)
105 * 6: +- message/rfc822 (next of 3)
107 * 7: | ... (children of 6)
109 * 8: +- image/jpeg (next of 6)
125 /* --- NEW MIME STUFF --- */
130 GHashTable
*typeparameters
;
132 /* Content-Transfer-Encoding */
133 EncodingType encoding_type
;
135 /* Content-Description */
141 /* Content-Location */
147 /* Content-Disposition */
148 DispositionType disposition
;
149 GHashTable
*dispositionparameters
;
152 struct _PrivacyData
*privacy
;
153 GTask
*last_sig_check_task
;
154 SignatureData
*sig_data
;
159 #define IS_BOUNDARY(s, bnd, len) \
160 (bnd && s[0] == '-' && s[1] == '-' && !strncmp(s + 2, bnd, len))
164 #endif /* __cplusplus */
166 /* MimeInfo handling */
168 MimeInfo
*procmime_mimeinfo_new (void);
169 void procmime_mimeinfo_free_all (MimeInfo
**mimeinfo_ptr
);
171 MimeInfo
*procmime_mimeinfo_insert (MimeInfo
*parent
,
173 void procmime_mimeinfo_replace (MimeInfo
*old_mimeinfo
,
174 MimeInfo
*new_mimeinfo
);
176 MimeInfo
*procmime_mimeinfo_parent (MimeInfo
*mimeinfo
);
177 MimeInfo
*procmime_mimeinfo_next (MimeInfo
*mimeinfo
);
179 MimeInfo
*procmime_scan_message (MsgInfo
*msginfo
);
180 MimeInfo
*procmime_scan_message_short (MsgInfo
*msginfo
);
181 void procmime_scan_multipart_message (MimeInfo
*mimeinfo
,
183 const gchar
*procmime_mimeinfo_get_parameter
189 void procmime_scan_encoding (MimeInfo
*mimeinfo
,
190 const gchar
*encoding
);
191 void procmime_scan_content_type (MimeInfo
*mimeinfo
,
192 const gchar
*content_type
);
193 void procmime_scan_content_disposition (MimeInfo
*mimeinfo
,
194 const gchar
*content_disposition
);
195 void procmime_scan_content_description (MimeInfo
*mimeinfo
,
196 const gchar
*content_description
);
197 void procmime_scan_subject (MimeInfo
*mimeinfo
,
198 const gchar
*subject
);
199 MimeInfo
*procmime_scan_mime_header (FILE *fp
);
201 gboolean
procmime_decode_content (MimeInfo
*mimeinfo
);
202 gboolean
procmime_encode_content (MimeInfo
*mimeinfo
, EncodingType encoding
);
203 gint
procmime_get_part (const gchar
*outfile
,
205 FILE *procmime_get_first_text_content (MsgInfo
*msginfo
);
206 FILE *procmime_get_first_encrypted_text_content
209 gchar
*procmime_get_tmp_file_name (MimeInfo
*mimeinfo
);
210 gchar
*procmime_get_part_file_name (MimeInfo
*mimeinfo
);
212 gchar
*procmime_get_mime_type (const gchar
*filename
);
214 GList
*procmime_get_mime_type_list (void);
216 EncodingType
procmime_get_encoding_for_charset (const gchar
*charset
);
217 EncodingType
procmime_get_encoding_for_text_file(const gchar
*file
,
218 gboolean
*has_binary
);
219 const gchar
*procmime_get_encoding_str (EncodingType encoding
);
220 MimeInfo
*procmime_scan_file (const gchar
*filename
);
221 MimeInfo
*procmime_scan_queue_file (const gchar
*filename
);
222 const gchar
*procmime_get_media_type_str (MimeMediaType type
);
223 MimeMediaType
procmime_get_media_type (const gchar
*str
);
224 gchar
*procmime_get_content_type_str (MimeMediaType type
,
225 const gchar
*subtype
);
226 void procmime_force_charset (const gchar
*str
);
227 void procmime_force_encoding (EncodingType encoding
);
228 gboolean
procmime_msginfo_is_encrypted (MsgInfo
*msginfo
);
229 int procmime_write_mime_header (MimeInfo
*mimeinfo
,
231 void renderer_read_config(void);
233 gint
procmime_write_mimeinfo(MimeInfo
*mimeinfo
, FILE *fp
);
235 void procmime_mimeparser_register(MimeParser
*mimeparser
);
236 void procmime_mimeparser_unregister(MimeParser
*mimeparser
);
237 FILE *procmime_get_text_content(MimeInfo
*mimeinfo
);
238 FILE *procmime_get_binary_content(MimeInfo
*mimeinfo
);
240 /* scans mimeinfo contents, calling scan_callback() once per line.
241 * return TRUE and scan is aborted if scan_callback returns TRUE.
242 * return TRUE on error.
243 * return FALSE if scan completed and scan_callback never returned TRUE.
245 gboolean
procmime_scan_text_content(MimeInfo
*mimeinfo
,
246 gboolean (*scan_callback
)(const gchar
*str
, gpointer cb_data
),
248 void *procmime_get_part_as_string(MimeInfo
*mimeinfo
,
249 gboolean null_terminate
);
250 GInputStream
*procmime_get_part_as_inputstream(MimeInfo
*mimeinfo
);
251 GdkPixbuf
*procmime_get_part_as_pixbuf(MimeInfo
*mimeinfo
, GError
**error
);
255 #endif /* __cplusplus */
257 #endif /* __PROCMIME_H__ */