/* * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) version 3. * * 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with the program; if not, see * * * Authors: * Michael Zucchi * * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include "em-format-hook.h" #include /* class name -> klass map for EMFormat and subclasses */ static GHashTable *emfh_types; /* ********************************************************************** */ /* Mail formatter handler plugin */ /* */ static gpointer emfh_parent_class; #define emfh ((EMFormatHook *)eph) #define d(x) static const EPluginHookTargetKey emfh_flag_map[] = { { "inline", EM_FORMAT_HANDLER_INLINE }, { "inline_disposition", EM_FORMAT_HANDLER_INLINE_DISPOSITION }, { NULL } }; static void emfh_format_format(EMFormat *md, struct _CamelStream *stream, struct _CamelMimePart *part, const EMFormatHandler *info) { struct _EMFormatHookItem *item = (EMFormatHookItem *)info; if (item->hook->hook.plugin->enabled) { EMFormatHookTarget target = { md, stream, part, item }; e_plugin_invoke(item->hook->hook.plugin, item->format, &target); } else if (info->old) { info->old->handler(md, stream, part, info->old); } } static void emfh_free_item(struct _EMFormatHookItem *item) { /* FIXME: remove from formatter class */ g_free(item->handler.mime_type); g_free(item->format); g_free(item); } static void emfh_free_group(struct _EMFormatHookGroup *group) { g_slist_foreach(group->items, (GFunc)emfh_free_item, NULL); g_slist_free(group->items); g_free(group->id); g_free(group); } static struct _EMFormatHookItem * emfh_construct_item(EPluginHook *eph, EMFormatHookGroup *group, xmlNodePtr root) { struct _EMFormatHookItem *item; d(printf(" loading group item\n")); item = g_malloc0(sizeof(*item)); item->handler.mime_type = e_plugin_xml_prop(root, "mime_type"); item->handler.flags = e_plugin_hook_mask(root, emfh_flag_map, "flags"); item->format = e_plugin_xml_prop(root, "format"); item->handler.handler = emfh_format_format; item->hook = emfh; if (item->handler.mime_type == NULL || item->format == NULL) goto error; d(printf(" type='%s' format='%s'\n", item->handler.mime_type, item->format)); return item; error: d(printf("error!\n")); emfh_free_item(item); return NULL; } static struct _EMFormatHookGroup * emfh_construct_group(EPluginHook *eph, xmlNodePtr root) { struct _EMFormatHookGroup *group; xmlNodePtr node; d(printf(" loading group\n")); group = g_malloc0(sizeof(*group)); group->id = e_plugin_xml_prop(root, "id"); if (group->id == NULL) goto error; node = root->children; while (node) { if (0 == strcmp((gchar *)node->name, "item")) { struct _EMFormatHookItem *item; item = emfh_construct_item(eph, group, node); if (item) group->items = g_slist_append(group->items, item); } node = node->next; } return group; error: emfh_free_group(group); return NULL; } static int emfh_construct(EPluginHook *eph, EPlugin *ep, xmlNodePtr root) { xmlNodePtr node; d(printf("loading format hook\n")); if (((EPluginHookClass *)emfh_parent_class)->construct(eph, ep, root) == -1) return -1; node = root->children; while (node) { if (strcmp((gchar *)node->name, "group") == 0) { struct _EMFormatHookGroup *group; group = emfh_construct_group(eph, node); if (group) { EMFormatClass *klass; if (emfh_types && (klass = g_hash_table_lookup(emfh_types, group->id))) { GSList *l = group->items; for (;l;l=g_slist_next(l)) { EMFormatHookItem *item = l->data; /* TODO: only add handlers if enabled? */ /* Well, disabling is handled by the callback, if we leave as is, then we can enable the plugin after startup and it will start working automagically */ em_format_class_add_handler(klass, &item->handler); } } /* We don't actually need to keep this around once its set on the class */ emfh->groups = g_slist_append(emfh->groups, group); } } node = node->next; } eph->plugin = ep; /* Load the plugin as it does a few thing in the formatter thread. */ ((EPluginClass *)G_OBJECT_GET_CLASS(ep))->enable (ep, 1); return 0; } static void emfh_enable(EPluginHook *eph, gint state) { GSList *g, *l; EMFormatClass *klass; g = emfh->groups; if (emfh_types == NULL) return; for (;g;g=g_slist_next(g)) { struct _EMFormatHookGroup *group = g->data; klass = g_hash_table_lookup(emfh_types, group->id); for (l=group->items;l;l=g_slist_next(l)) { EMFormatHookItem *item = l->data; if (state) em_format_class_add_handler(klass, &item->handler); else em_format_class_remove_handler(klass, &item->handler); } } } static void emfh_finalise(GObject *o) { EPluginHook *eph = (EPluginHook *)o; g_slist_foreach(emfh->groups, (GFunc)emfh_free_group, NULL); g_slist_free(emfh->groups); ((GObjectClass *)emfh_parent_class)->finalize(o); } static void emfh_class_init(EPluginHookClass *klass) { ((GObjectClass *)klass)->finalize = emfh_finalise; klass->construct = emfh_construct; klass->enable = emfh_enable; klass->id = "org.gnome.evolution.mail.format:1.0"; } GType em_format_hook_get_type(void) { static GType type = 0; if (!type) { static const GTypeInfo info = { sizeof(EMFormatHookClass), NULL, NULL, (GClassInitFunc) emfh_class_init, NULL, NULL, sizeof(EMFormatHook), 0, (GInstanceInitFunc) NULL, }; emfh_parent_class = g_type_class_ref(e_plugin_hook_get_type()); type = g_type_register_static(e_plugin_hook_get_type(), "EMFormatHook", &info, 0); } return type; } void em_format_hook_register_type(GType type) { EMFormatClass *klass; if (emfh_types == NULL) emfh_types = g_hash_table_new(g_str_hash, g_str_equal); d(printf("registering formatter type '%s'\n", g_type_name(type))); klass = g_type_class_ref(type); g_hash_table_insert(emfh_types, (gpointer)g_type_name(type), klass); } ts/refs/?h=dependabot/npm_and_yarn/devel/electron4/files/eslint-utils-1.4.3&id=1d26a97aab4ec5fac01e1916a6c10f3e6988a5cf'>refslogtreecommitdiffstats
Commit message (Expand)AuthorAgeFilesLines
* Fixed dependencies and add PORTAUDIO optionrodrigo2017-08-132-2/+15
* audio/lmms: remove wrongly used PLIST_SUB from pkg-plistpi2016-10-291-5/+5
* Cleanup patches, a* categories.mat2016-07-274-9/+9
* Update LMMS from V0.4.15 to V1.1.3rodrigo2016-05-0752-738/+1235
* Remove ${PORTSDIR}/ from dependencies, Mk and categories a, b, and c.mat2016-04-011-14/+14
* Update freetype2 to 2.6.2. [1]kwm2015-12-111-11/+11
* Fix Github repo declarationrodrigo2015-09-132-4/+5
* Unbreak port, update MASTER_SITESrodrigo2015-09-103-8/+8
* Update portaudio to v19/Remove portaudio2 [1]bapt2015-05-314-32/+1
* Mark broken unfetchable portsbapt2015-04-061-0/+1
* Replace USES=libtool:oldver with USES=libtool or USES=libtool:keepla intijl2014-12-091-1/+1
* Cleanup plistbapt2014-10-201-81/+0
* math/fftw3:tijl2014-09-011-1/+1
* - Fix build on 8 and 9 (all archs) and 10 and 11 (32-bit archs) byadamw2014-08-312-44/+34
* Replace deprecate USE_DOS2UNIX by dos2unix to fix file format before patchrodrigo2014-04-241-2/+2
* restore dos2unix conversion for patched filesrodrigo2014-04-241-0/+1
* - support stagingrodrigo2014-04-223-226/+237
* Update maintainer email addressrodrigo2014-01-291-1/+1
* Update freetype to 2.5.2.kwm2013-12-251-0/+11
* In preparation for making libtool generate libraries with a sane name, fix allbapt2013-12-111-9/+9
* - Remove manual creation and removal of share/applications, as it's now in th...amdmi32013-10-221-1/+0
* Add NO_STAGE all over the place in preparation for the staging support (cat: ...bapt2013-09-201-0/+1
* - Remove MAKE_JOBS_SAFE variableak2013-08-151-1/+0
* - Update to 0.4.15madpilot2013-07-203-3/+13
* * Major update to FLAC 1.3.0, including shared library bumps.naddy2013-06-101-1/+1
* - Update to 0.4.14 [1]wg2013-05-273-1936/+1937
* Convert USE_PKGCONFIG -> USES=pkgconf for audio categorybapt2013-04-231-2/+1
* - convert USE_CMAKE to USESmakc2013-03-231-1/+1
* In categories starting with 'a', remove empty lines from pkg-plist (exceptdanfe2013-03-171-1/+0
* - convert to optionsngrm2012-10-281-19/+13
* convert libcddb and libsamplerate to only build depend on pkgconf, trackbapt2012-10-061-0/+1
* Fix typos in COMMENTcs2012-07-251-1/+1
* libogg.so.8: Bump PORTREVISION for ports that depend on libogg,naddy2012-07-201-1/+1
* - Convert USE_QT_VER=4 and QT_COMPONETS to USE_QT4miwi2012-06-061-2/+1
* - update png to 1.5.10dinoex2012-06-011-0/+1
* - Update to version 4.0.13 [1]pawel2012-05-083-1677/+1688
* fix the build by adjusting LIB_DEPENDS after changes tobf2012-03-071-1/+2
* - Update devel/sdl12 to 1.2.15mva2012-02-181-0/+1
* -Update to 0.4.12scheidell2011-12-0825-1863/+2314
* - Update to 1.5.1miwi2011-11-191-2/+2
* Remove CMAKE_USE_PTHREAD from the ports using it.rakuco2011-11-141-1/+0
* Fix build after bsd.cmake.mk's r1.13.rakuco2011-11-121-1/+1
* - update fftw3* to 3.3 [1], and adjust dependent portsbf2011-10-171-2/+2
* Kill EOL whitespace.danfe2011-06-231-1/+1
* - Get Rid MD5 supportmiwi2011-03-191-1/+0
* - Unbreak on recent 8.Xpav2010-09-032-6/+2
* Bump PORTREVISION for ports that depend on libogg, directly or indirectlynaddy2010-06-071-1/+1
* - update to 1.4.1dinoex2010-03-281-0/+1
* Mark BROKEN on 8.x: does not builderwin2010-03-131-0/+4
* - Update to 0.4.6miwi2010-01-226-114/+148
* - Fix compilation in presence of x11-toolkits/fltkamdmi32010-01-154-6/+35
* - Chase audio/fluidsynth shlib bumpmiwi2010-01-061-1/+2
* For ports maintained by ports@FreeBSD.org, remove names and/ordougb2009-12-211-3/+0
* - S/pluseaudio/pulseaudiomiwi2009-09-181-1/+1
* - Update to 0.4.5miwi2009-08-298-903/+28
* Bump PORTREVISION after libogg and libvorbisfile major version increment.naddy2009-07-071-0/+1
* - Update to 0.4.4miwi2009-05-2316-998/+3033
* - Attempt to build on 64-bits platformsgahr2009-04-122-9/+12
* Fails to compile on sparc64 as well as amd64.linimon2009-03-161-2/+4
* - Remove conditional checks relevant only on FreeBSD 5.x and olderpav2009-01-061-4/+0
* Conversion from (now defunct) autoconf-2.61 to autoconf-2.62ade2008-08-201-1/+1
* Bump portrevision due to upgrade of devel/gettext.edwin2008-06-061-1/+1
* Reset jylefort's port maintainerships. portmgr has taken his commit bitlinimon2008-04-291-1/+1
* - Remove unneeded dependency from gtk12/gtk20 [1]miwi2008-04-201-2/+2
* Update to FLAC 1.2.1. This version includes two and a half yearsnaddy2008-04-081-1/+1
* - Chase devel/sdl12 shlib version bumpmiwi2008-03-131-1/+1
* - Mark BROKEN on amd64 and 7.0pav2007-11-251-0/+4
* This appears to build on i386-6 and i386-7.linimon2007-11-181-5/+7
* Mark as broken: fails to install.linimon2007-10-021-0/+4
* Switch autoconf dependencies from 2.53 or 2.59 to 2.61.linimon2007-09-301-2/+2
* - Chase increase of audio/libvorbis shlib version.miwi2007-07-28