Пример #1
0
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;
}
Пример #2
0
static struct _EEventItem *
emph_construct_item(EPluginHook *eph, xmlNodePtr root, EEventHookClass *klass)
{
	struct _EEventItem *item;
	EEventHookTargetMap *map;
	char *tmp;

	item = g_malloc0(sizeof(*item));

	tmp = (char *)xmlGetProp(root, (const unsigned char *)"target");
	if (tmp == NULL)
		goto error;
	map = g_hash_table_lookup(klass->target_map, tmp);
	xmlFree(tmp);
	if (map == NULL)
		goto error;
	item->target_type = map->id;
	item->type = e_plugin_hook_id(root, emph_item_types, "type");
	if (item->type == -1)
		item->type = E_EVENT_PASS;
	item->priority = e_plugin_xml_int(root, "priority", 0);
	item->id = e_plugin_xml_prop(root, "id");
	item->enable = e_plugin_hook_mask(root, map->mask_bits, "enable");
	item->user_data = e_plugin_xml_prop(root, "handle");

	if (item->user_data == NULL || item->id == NULL)
		goto error;

	item->handle = emph_event_handle;

	return item;
error:
	emph_free_item(item);
	return NULL;
}
Пример #3
0
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;
}
Пример #4
0
static gint
plugin_ui_hook_construct (EPluginHook *hook,
                          EPlugin *plugin,
                          xmlNodePtr node)
{
	EPluginUIHookPrivate *priv;

	priv = E_PLUGIN_UI_HOOK_GET_PRIVATE (hook);

	/* XXX The EPlugin should be a property of EPluginHookClass.
	 *     Then it could be passed directly to g_object_new() and
	 *     we wouldn't have to chain up here. */

	/* Chain up to parent's construct() method. */
	E_PLUGIN_HOOK_CLASS (parent_class)->construct (hook, plugin, node);

	for (node = node->children; node != NULL; node = node->next) {
		xmlNodePtr child;
		xmlBufferPtr buffer;
		const gchar *content;
		gchar *id;

		if (strcmp ((gchar *) node->name, "ui-manager") != 0)
			continue;

		id = e_plugin_xml_prop (node, "id");
		if (id == NULL) {
			g_warning ("<ui-manager> requires 'id' property");
			continue;
		}

		/* Extract the XML content below <ui-manager> */
		buffer = xmlBufferCreate ();
		child = node->children;
		while (child != NULL && xmlNodeIsText (child))
			child = child->next;
		if (child != NULL)
			xmlNodeDump (buffer, node->doc, child, 2, 1);
		content = (const gchar *) xmlBufferContent (buffer);

		g_hash_table_insert (
			priv->ui_definitions,
			id, g_strdup (content));

		xmlBufferFree (buffer);
	}

	return 0;
}
Пример #5
0
static gint
plugin_lib_construct (EPlugin *plugin,
                      xmlNodePtr root)
{
	EPluginLib *plugin_lib = E_PLUGIN_LIB (plugin);

	/* Set the location before chaining up, as some EPluginHooks
	 * will cause the module to load during hook construction. */

	plugin_lib->location = e_plugin_xml_prop (root, "location");

	if (plugin_lib->location == NULL) {
		g_warning ("Library plugin '%s' has no location", plugin->id);
		return -1;
	}
#ifdef G_OS_WIN32
	{
		gchar *mapped_location =
			e_util_replace_prefix (
				EVOLUTION_PREFIX,
				e_util_get_prefix (),
				plugin_lib->location);
		g_free (plugin_lib->location);
		plugin_lib->location = mapped_location;
	}
#endif

	/* Chain up to parent's construct() method. */
	if (E_PLUGIN_CLASS (parent_class)->construct (plugin, root) == -1)
		return -1;

	/* If we're enabled, check for the load-on-startup property */
	if (plugin->enabled) {
		xmlChar *tmp;

		tmp = xmlGetProp (root, (const guchar *)"load-on-startup");
		if (tmp) {
			if (plugin_lib_loadmodule (plugin) != 0) {
				xmlFree (tmp);
				return -1;
			}
			xmlFree (tmp);
		}
	}

	return 0;
}
Пример #6
0
static struct _EImportHookImporter *
emph_construct_importer(EPluginHook *eph, xmlNodePtr root)
{
	struct _EImportHookImporter *item;
	EImportHookTargetMap *map;
	EImportHookClass *klass = (EImportHookClass *)G_OBJECT_GET_CLASS(eph);
	char *tmp;

	d(printf("  loading import item\n"));
	item = g_malloc0(sizeof(*item));

	tmp = (char *)xmlGetProp(root, (const unsigned char *)"target");
	if (tmp == NULL)
		goto error;
	map = g_hash_table_lookup(klass->target_map, tmp);
	xmlFree(tmp);
	if (map == NULL)
		goto error;

	item->importer.type = map->id;
	item->supported = e_plugin_xml_prop(root, "supported");
	item->get_widget = e_plugin_xml_prop(root, "get-widget");
	item->import = e_plugin_xml_prop(root, "import");
	item->cancel = e_plugin_xml_prop(root, "cancel");

	item->importer.name = e_plugin_xml_prop(root, "name");
	item->importer.description = e_plugin_xml_prop(root, "description");

	item->importer.user_data = eph;

	if (item->import == NULL || item->supported == NULL)
		goto error;

	item->importer.supported = eih_supported;
	item->importer.import = eih_import;
	if (item->get_widget)
		item->importer.get_widget = eih_get_widget;
	if (item->cancel)
		item->importer.cancel = eih_cancel;

	return item;
error:
	d(printf("error!\n"));
	eih_free_importer((EImportImporter *)item, NULL);
	return NULL;
}