2 * e-mail-parser-extension.c
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program; if not, see <http://www.gnu.org/licenses/>.
18 #include "e-mail-parser-extension.h"
20 G_DEFINE_ABSTRACT_TYPE (
22 e_mail_parser_extension
,
26 e_mail_parser_extension_class_init (EMailParserExtensionClass
*class)
28 class->priority
= G_PRIORITY_DEFAULT
;
32 e_mail_parser_extension_init (EMailParserExtension
*extension
)
37 * e_mail_parser_extension_parse
38 * @extension: an #EMailParserExtension
39 * @parser: a #EMailParser
40 * @mime_part: (allow-none) a #CamelMimePart to parse
41 * @part_id: a #GString to which parser will append ID of the parsed part.
42 * @cancellable: (allow-none) A #GCancellable
43 * @out_mail_parts: a #GQueue to deposit #EMailPart instances
45 * A virtual function reimplemented in all mail parser extensions. The function
46 * decodes and parses the @mime_part, appending one or more #EMailPart<!-- -->s
47 * to the @out_mail_parts queue.
49 * When the function is unable to parse the @mime_part (either because it's
50 * broken or because it is a different MIME type then the extension is
51 * specialized for), the function will return %FALSE to indicate to the
52 * #EMailParser that it should pick another extension.
54 * When the @mime_part contains for example multipart/mixed of one RFC822
55 * message with an attachment and of one image, then parser must make sure
56 * that parts are appeded to @out_mail_parts in the correct order.
58 * part1.rfc822.plain_text
59 * part1.rfc822.attachment
62 * Implementation of this function must be thread-safe.
64 * Returns: %TRUE if the @mime_part was handled (even if no
65 * #EMailPart<!-- -->s were added to @out_mail_parts), or
66 * %FALSE if the @mime_part was not handled
69 e_mail_parser_extension_parse (EMailParserExtension
*extension
,
71 CamelMimePart
*mime_part
,
73 GCancellable
*cancellable
,
74 GQueue
*out_mail_parts
)
76 EMailParserExtensionClass
*class;
78 g_return_val_if_fail (E_IS_MAIL_PARSER_EXTENSION (extension
), FALSE
);
79 g_return_val_if_fail (E_IS_MAIL_PARSER (parser
), FALSE
);
81 class = E_MAIL_PARSER_EXTENSION_GET_CLASS (extension
);
82 g_return_val_if_fail (class != NULL
, FALSE
);
83 g_return_val_if_fail (class->parse
!= NULL
, FALSE
);
85 /* Check for cancellation before calling the method. */
86 if (g_cancellable_is_cancelled (cancellable
))
90 extension
, parser
, mime_part
, part_id
,
91 cancellable
, out_mail_parts
);