summaryrefslogtreecommitdiffstats
path: root/src/include/engagement/plugin.h
blob: 7bd7fa6170e67a655da6532cc11a116e3eaebc7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
 * (c) Copyright 2016 Olliver Schinagl
 * Author: Olliver Schinagl <oliver@schinagl.nl>
 *
 * SPDX-License-Identifier:	AGPL-3.0+
 */

/** \file
 * Common header to describe the generic plugin API.
 */
#ifndef _PLUGIN_H_
#define _PLUGIN_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <stdbool.h>
#include <stdint.h>

/**
 * @defgroup Plugins
 * @ingroup engagement
 *
 * Generic plugin API
 */

#define PLUGIN_MAGIC 0		/* TODO pick plugin magic */
#define PLUGIN_VERSION_MAJOR 0	/* TODO replace with version from src? @ENGAGEMENT_VERSION_MAJOR@ */
#define PLUGIN_VERSION_MINOR 0	/* TODO replace with version from src? */

#define PLUGIN_SYMBOL "calendar_plugin" /* TODO use generic name */

#define PLUGIN_INIT(plugin)

enum plugin_type {
	PLUGIN_TYPE_CALENDAR,
	PLUGIN_TYPE_DIRECTORY,
};

struct plugin_info {
	const char *name;
	const char *summary;
	const char *description;
	const char *help;
	const char *author;
	const char *email;
	const char *url;
};

struct plugin_version {
	uint8_t major;
	uint8_t minor;
	uint32_t micro;
};

struct plugin {
	uint32_t magic;
	void *_handle;
	enum plugin_type type;
	const char *id;
	struct plugin_version version;
	struct plugin_info info;
	void *dependencies; /* Unused/reserved */
	bool (*load)(void);
	bool (*unload)(void);
	void *ui; /* struct plugin_ui ui; Unused/reserved */
	void *ops;
	void *priv;
};

struct plugin *plugin_load(const char *path);
int plugin_unload(struct plugin *plugin);

#ifdef __cplusplus
}
#endif
#endif /* _PLUGIN_H_ */