Ring Daemon 16.0.0
Loading...
Searching...
No Matches
jamiplugin.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2004-2025 Savoir-faire Linux Inc.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17#pragma once
18
19#include <inttypes.h>
20
21#ifdef __cplusplus
22#define EXTERNAL_C_LINKAGE extern "C"
23// clang-format off
24#define C_INTERFACE_START EXTERNAL_C_LINKAGE {
25#define C_INTERFACE_END }
26// clang-format on
27#else
28#define C_LINKAGE
29#define C_INTERFACE_START
30#define C_INTERFACE_END
31#endif
32
33#define JAMI_PLUGIN_ABI_VERSION 1 // 0 doesn't exist, considered as error
34
35// JAMI_PLUGIN_API_VERSION reflects changes in Services Managers
36// (CallServicesManager, ChatServicesMansge, and PreferenceServicesManagers) and in JAMI_PluginAPI.
37#define JAMI_PLUGIN_API_VERSION 2 // 0 doesn't exist, considered as error
38
40
45typedef struct JAMI_PluginVersion
46{
47 // Plugin is not loadable if this number differs from th one
48 // stored in the plugin loader
49 uint32_t abi;
50
51 // A difference in API number may be acceptable, see the loader code
52 uint32_t api;
54
55struct JAMI_PluginAPI;
56
62{
63 const JAMI_PluginAPI* pluginApi; // this API
64 const char* type;
66
67// Function that may be implemented by plugin and called by daemon
68typedef void* (*JAMI_PluginCreateFunc)(JAMI_PluginObjectParams* params, void* closure);
69// Function that destroys a JAMI_PluginCreateFunc instance
70typedef void (*JAMI_PluginDestroyFunc)(void* object, void* closure);
71
84
85// Plugins exposed API prototype
86typedef int32_t (*JAMI_PluginFunc)(const JAMI_PluginAPI* api, const char* name, void* data);
87
92typedef struct JAMI_PluginAPI
93{
94 JAMI_PluginVersion version; // Structure version, always the first data
95 void* context; // Opaque structure used by next functions
96
97 // API usable by plugin implementors
102
103// Plugins destruction function prototype
104typedef void (*JAMI_PluginExitFunc)(void);
105
106// Plugins main function prototype
108
110
111#define JAMI_DYN_INIT_FUNC_NAME "JAMI_dynPluginInit" // Main function expected name
112#define JAMI_PLUGIN_INIT_STATIC(fname, pname) JAMI_PLUGIN_INIT(fname, pname)
113#define JAMI_PLUGIN_INIT_DYNAMIC(pname) JAMI_PLUGIN_INIT(JAMI_dynPluginInit, pname)
114
115/* Define here platform dependent way to export a declaration x to the dynamic
116 * loading system.
117 */
118
119/* Default case (like POSIX/.so) */
120
121#define JAMI_PLUGIN_INIT(fname, pname) \
122 (EXTERNAL_C_LINKAGE JAMI_PluginExitFunc fname(const JAMI_PluginAPI* pname))
123#define JAMI_PLUGIN_EXIT(fname) (EXTERNAL_C_LINKAGE void fname(void))
#define C_INTERFACE_START
Definition jamiplugin.h:29
void(* JAMI_PluginDestroyFunc)(void *object, void *closure)
Definition jamiplugin.h:70
void(* JAMI_PluginExitFunc)(void)
Definition jamiplugin.h:104
int32_t(* JAMI_PluginFunc)(const JAMI_PluginAPI *api, const char *name, void *data)
Definition jamiplugin.h:86
JAMI_PluginExitFunc(* JAMI_PluginInitFunc)(const JAMI_PluginAPI *api)
Definition jamiplugin.h:107
#define C_INTERFACE_END
Definition jamiplugin.h:30
void *(* JAMI_PluginCreateFunc)(JAMI_PluginObjectParams *params, void *closure)
Definition jamiplugin.h:68
This structure is filled by the PluginManager.
Definition jamiplugin.h:93
JAMI_PluginFunc manageComponent
Definition jamiplugin.h:100
JAMI_PluginVersion version
Definition jamiplugin.h:94
JAMI_PluginFunc invokeService
Definition jamiplugin.h:99
JAMI_PluginFunc registerObjectFactory
Definition jamiplugin.h:98
This structure is filled by plugin.
Definition jamiplugin.h:78
JAMI_PluginCreateFunc create
Definition jamiplugin.h:81
JAMI_PluginDestroyFunc destroy
Definition jamiplugin.h:82
JAMI_PluginVersion version
Definition jamiplugin.h:79
JAMI_PluginCreateFunc parameter.
Definition jamiplugin.h:62
const JAMI_PluginAPI * pluginApi
Definition jamiplugin.h:63
Contains ABI and API versions.
Definition jamiplugin.h:46