Ring Daemon
Loading...
Searching...
No Matches
jamiplugin.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2004-2026 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 <cstdint>
20#ifdef __cplusplus
21#define EXTERNAL_C_LINKAGE extern "C"
22// clang-format off
23#define C_INTERFACE_START EXTERNAL_C_LINKAGE {
24#define C_INTERFACE_END }
25// clang-format on
26#else
27#define C_LINKAGE
28#define C_INTERFACE_START
29#define C_INTERFACE_END
30#endif
31
32#define JAMI_PLUGIN_ABI_VERSION 1 // 0 doesn't exist, considered as error
33
34// JAMI_PLUGIN_API_VERSION reflects changes in Services Managers
35// (CallServicesManager, ChatServicesMansge, and PreferenceServicesManagers) and in JAMI_PluginAPI.
36#define JAMI_PLUGIN_API_VERSION 2 // 0 doesn't exist, considered as error
37
39
44typedef struct JAMI_PluginVersion
45{
46 // Plugin is not loadable if this number differs from th one
47 // stored in the plugin loader
48 uint32_t abi;
49
50 // A difference in API number may be acceptable, see the loader code
51 uint32_t api;
53
54struct JAMI_PluginAPI;
55
61{
62 const JAMI_PluginAPI* pluginApi; // this API
63 const char* type;
65
66// Function that may be implemented by plugin and called by daemon
67typedef void* (*JAMI_PluginCreateFunc)(JAMI_PluginObjectParams* params, void* closure);
68// Function that destroys a JAMI_PluginCreateFunc instance
69typedef void (*JAMI_PluginDestroyFunc)(void* object, void* closure);
70
83
84// Plugins exposed API prototype
85typedef int32_t (*JAMI_PluginFunc)(const JAMI_PluginAPI* api, const char* name, void* data);
86
91typedef struct JAMI_PluginAPI
92{
93 JAMI_PluginVersion version; // Structure version, always the first data
94 void* context; // Opaque structure used by next functions
95
96 // API usable by plugin implementors
101
102// Plugins destruction function prototype
103typedef void (*JAMI_PluginExitFunc)(void);
104
105// Plugins main function prototype
107
109
110#define JAMI_DYN_INIT_FUNC_NAME "JAMI_dynPluginInit" // Main function expected name
111#define JAMI_PLUGIN_INIT_STATIC(fname, pname) JAMI_PLUGIN_INIT(fname, pname)
112#define JAMI_PLUGIN_INIT_DYNAMIC(pname) JAMI_PLUGIN_INIT(JAMI_dynPluginInit, pname)
113
114/* Define here platform dependent way to export a declaration x to the dynamic
115 * loading system.
116 */
117
118/* Default case (like POSIX/.so) */
119
120#define JAMI_PLUGIN_INIT(fname, pname) (EXTERNAL_C_LINKAGE JAMI_PluginExitFunc fname(const JAMI_PluginAPI*(pname)))
121#define JAMI_PLUGIN_EXIT(fname) (EXTERNAL_C_LINKAGE void fname(void))
#define C_INTERFACE_START
Definition jamiplugin.h:28
void(* JAMI_PluginDestroyFunc)(void *object, void *closure)
Definition jamiplugin.h:69
void(* JAMI_PluginExitFunc)(void)
Definition jamiplugin.h:103
int32_t(* JAMI_PluginFunc)(const JAMI_PluginAPI *api, const char *name, void *data)
Definition jamiplugin.h:85
JAMI_PluginExitFunc(* JAMI_PluginInitFunc)(const JAMI_PluginAPI *api)
Definition jamiplugin.h:106
#define C_INTERFACE_END
Definition jamiplugin.h:29
void *(* JAMI_PluginCreateFunc)(JAMI_PluginObjectParams *params, void *closure)
Definition jamiplugin.h:67
This structure is filled by the PluginManager.
Definition jamiplugin.h:92
JAMI_PluginFunc manageComponent
Definition jamiplugin.h:99
JAMI_PluginVersion version
Definition jamiplugin.h:93
JAMI_PluginFunc invokeService
Definition jamiplugin.h:98
JAMI_PluginFunc registerObjectFactory
Definition jamiplugin.h:97
This structure is filled by plugin.
Definition jamiplugin.h:77
JAMI_PluginCreateFunc create
Definition jamiplugin.h:80
JAMI_PluginDestroyFunc destroy
Definition jamiplugin.h:81
JAMI_PluginVersion version
Definition jamiplugin.h:78
JAMI_PluginCreateFunc parameter.
Definition jamiplugin.h:61
const JAMI_PluginAPI * pluginApi
Definition jamiplugin.h:62
Contains ABI and API versions.
Definition jamiplugin.h:45