diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2012-12-07 05:40:13 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2012-12-08 03:01:05 +0800 |
commit | 54455ca1ad6cae527544fed12d0de4ae95341082 (patch) | |
tree | b223d428459e3be79d1162d8217be6c2856f643b /em-format/e-mail-format-extensions.c | |
parent | 9d34f72ec1b99d58ee1c3a6d1a964a6dde166f79 (diff) | |
download | gsoc2013-evolution-54455ca1ad6cae527544fed12d0de4ae95341082.tar gsoc2013-evolution-54455ca1ad6cae527544fed12d0de4ae95341082.tar.gz gsoc2013-evolution-54455ca1ad6cae527544fed12d0de4ae95341082.tar.bz2 gsoc2013-evolution-54455ca1ad6cae527544fed12d0de4ae95341082.tar.lz gsoc2013-evolution-54455ca1ad6cae527544fed12d0de4ae95341082.tar.xz gsoc2013-evolution-54455ca1ad6cae527544fed12d0de4ae95341082.tar.zst gsoc2013-evolution-54455ca1ad6cae527544fed12d0de4ae95341082.zip |
Remove EMailExtension.
EMailExtension is now too trivial to keep as a standalone interface.
Add a 'mime_types' string array to the EMailFormatterExtension and
EMailFormatterParser interface structs.
Alter e_mail_extension_registry_add_extension() to take a 'mime_types'
string array and the GType of an extension to instantiate, rather than
the extension instance directly.
e_mail_extension_registry_remove_extension() is no longer needed.
Diffstat (limited to 'em-format/e-mail-format-extensions.c')
-rw-r--r-- | em-format/e-mail-format-extensions.c | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/em-format/e-mail-format-extensions.c b/em-format/e-mail-format-extensions.c index fa7d5d8683..01162bc9ea 100644 --- a/em-format/e-mail-format-extensions.c +++ b/em-format/e-mail-format-extensions.c @@ -86,16 +86,44 @@ static void load (EMailExtensionRegistry *ereg, TypeFunc *func_array) { - gint i = 0; + gint ii; - for (i = 0; func_array[i] != NULL; i++) { - GType type; - EMailExtension *extension; + for (ii = 0; func_array[ii] != NULL; ii++) { + GType extension_type; + GType interface_type; + gpointer extension_class; + const gchar **mime_types = NULL; - type = func_array[i](); - extension = g_object_new (type, NULL); + extension_type = func_array[ii](); + extension_class = g_type_class_ref (extension_type); - e_mail_extension_registry_add_extension (ereg, extension); + interface_type = E_TYPE_MAIL_FORMATTER_EXTENSION; + if (g_type_is_a (extension_type, interface_type)) { + EMailFormatterExtensionInterface *interface; + + interface = g_type_interface_peek ( + extension_class, interface_type); + mime_types = interface->mime_types; + } + + interface_type = E_TYPE_MAIL_PARSER_EXTENSION; + if (g_type_is_a (extension_type, interface_type)) { + EMailParserExtensionInterface *interface; + + interface = g_type_interface_peek ( + extension_class, interface_type); + mime_types = interface->mime_types; + } + + if (mime_types != NULL) + e_mail_extension_registry_add_extension ( + ereg, mime_types, extension_type); + else + g_critical ( + "%s does not define any MIME types", + g_type_name (extension_type)); + + g_type_class_unref (extension_class); } } |