Example #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;
}
Example #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;
}