Ring Daemon 16.0.0
Loading...
Searching...
No Matches
plugin_manager_interface.cpp
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
19
20#ifdef HAVE_CONFIG_H
21#include "config.h"
22#endif // HAVE_CONFIG_H
23
24#ifdef ENABLE_PLUGIN
25#include "manager.h"
27#endif
28
29namespace libjami {
30bool
31loadPlugin(const std::string& path)
32{
33#ifdef ENABLE_PLUGIN
34 bool status = jami::Manager::instance().getJamiPluginManager().loadPlugin(path);
35
36 jami::Manager::instance().pluginPreferences.saveStateLoadedPlugins(path, status);
38 return status;
39#endif
40 return false;
41}
42
43bool
44unloadPlugin(const std::string& path)
45{
46#ifdef ENABLE_PLUGIN
47 bool status = jami::Manager::instance().getJamiPluginManager().unloadPlugin(path);
48
49 jami::Manager::instance().pluginPreferences.saveStateLoadedPlugins(path, false);
51 return status;
52#endif
53 return false;
54}
55
56std::map<std::string, std::string>
57getPluginDetails(const std::string& path)
58{
59#ifdef ENABLE_PLUGIN
60 return jami::Manager::instance().getJamiPluginManager().getPluginDetails(path);
61#endif
62 return {};
63}
64
65std::vector<std::map<std::string, std::string>>
66getPluginPreferences(const std::string& path, const std::string& accountId)
67{
68#ifdef ENABLE_PLUGIN
69 return jami::Manager::instance().getJamiPluginManager().getPluginPreferences(path, accountId);
70#endif
71 return {};
72}
73
74bool
75setPluginPreference(const std::string& path,
76 const std::string& accountId,
77 const std::string& key,
78 const std::string& value)
79{
80#ifdef ENABLE_PLUGIN
81 return jami::Manager::instance().getJamiPluginManager().setPluginPreference(path,
82 accountId,
83 key,
84 value);
85#endif
86 return {};
87}
88
89std::map<std::string, std::string>
90getPluginPreferencesValues(const std::string& path, const std::string& accountId)
91{
92#ifdef ENABLE_PLUGIN
93 return jami::Manager::instance().getJamiPluginManager().getPluginPreferencesValuesMap(path,
94 accountId);
95#endif
96 return {};
97}
98bool
99resetPluginPreferencesValues(const std::string& path, const std::string& accountId)
100{
101#ifdef ENABLE_PLUGIN
103 .getJamiPluginManager()
104 .resetPluginPreferencesValuesMap(path, accountId);
105#endif
106}
107
108std::vector<std::string>
110{
111#ifdef ENABLE_PLUGIN
112 return jami::Manager::instance().getJamiPluginManager().getInstalledPlugins();
113#endif
114 return {};
115}
116
117std::vector<std::string>
119{
120#ifdef ENABLE_PLUGIN
121 return jami::Manager::instance().pluginPreferences.getLoadedPlugins();
122#endif
123 return {};
124}
125
126int
127installPlugin(const std::string& jplPath, bool force)
128{
129#ifdef ENABLE_PLUGIN
130 return jami::Manager::instance().getJamiPluginManager().installPlugin(jplPath, force);
131#endif
132 return -1;
133}
134
135int
136uninstallPlugin(const std::string& pluginRootPath)
137{
138#ifdef ENABLE_PLUGIN
139 int status = jami::Manager::instance().getJamiPluginManager().uninstallPlugin(pluginRootPath);
140 jami::Manager::instance().pluginPreferences.saveStateLoadedPlugins(pluginRootPath, false);
142 return status;
143#endif
144 return -1;
145}
146
147std::map<std::string, std::string>
149#ifdef ENABLE_PLUGIN
150 return jami::Manager::instance().getJamiPluginManager().getPlatformInfo();
151#endif
152 return {};
153}
154
155std::vector<std::string>
157{
158#ifdef ENABLE_PLUGIN
160 .getJamiPluginManager()
161 .getCallServicesManager()
162 .getCallMediaHandlers();
163#endif
164 return {};
165}
166
167std::vector<std::string>
169{
170#ifdef ENABLE_PLUGIN
172 .getJamiPluginManager()
173 .getChatServicesManager()
174 .getChatHandlers();
175#endif
176 return {};
177}
178
179void
180toggleCallMediaHandler(const std::string& mediaHandlerId, const std::string& callId, bool toggle)
181{
182#ifdef ENABLE_PLUGIN
184 .getJamiPluginManager()
185 .getCallServicesManager()
186 .toggleCallMediaHandler(mediaHandlerId, callId, toggle);
187#endif
188}
189
190void
191toggleChatHandler(const std::string& chatHandlerId,
192 const std::string& accountId,
193 const std::string& peerId,
194 bool toggle)
195{
196#ifdef ENABLE_PLUGIN
198 .getJamiPluginManager()
199 .getChatServicesManager()
200 .toggleChatHandler(chatHandlerId, accountId, peerId, toggle);
201#endif
202}
203
204std::map<std::string, std::string>
205getCallMediaHandlerDetails(const std::string& mediaHandlerId)
206{
207#ifdef ENABLE_PLUGIN
209 .getJamiPluginManager()
210 .getCallServicesManager()
211 .getCallMediaHandlerDetails(mediaHandlerId);
212#endif
213 return {};
214}
215
216std::vector<std::string>
217getCallMediaHandlerStatus(const std::string& callId)
218{
219#ifdef ENABLE_PLUGIN
221 .getJamiPluginManager()
222 .getCallServicesManager()
223 .getCallMediaHandlerStatus(callId);
224#endif
225 return {};
226}
227
228std::map<std::string, std::string>
229getChatHandlerDetails(const std::string& chatHandlerId)
230{
231#ifdef ENABLE_PLUGIN
233 .getJamiPluginManager()
234 .getChatServicesManager()
235 .getChatHandlerDetails(chatHandlerId);
236#endif
237 return {};
238}
239
240std::vector<std::string>
241getChatHandlerStatus(const std::string& accountId, const std::string& peerId)
242{
243#ifdef ENABLE_PLUGIN
245 .getJamiPluginManager()
246 .getChatServicesManager()
247 .getChatHandlerStatus(accountId, peerId);
248#endif
249 return {};
250}
251
252bool
254{
255#ifdef ENABLE_PLUGIN
256 return jami::Manager::instance().pluginPreferences.getPluginsEnabled();
257#endif
258 return false;
259}
260
261void
263{
264#ifdef ENABLE_PLUGIN
265 jami::Manager::instance().pluginPreferences.setPluginsEnabled(state);
266 for (auto& item : jami::Manager::instance().pluginPreferences.getLoadedPlugins()) {
267 if (state)
268 jami::Manager::instance().getJamiPluginManager().loadPlugin(item);
269 else
270 jami::Manager::instance().getJamiPluginManager().unloadPlugin(item);
271 }
273#endif
274}
275
276void
277sendWebViewMessage(const std::string& pluginId,
278 const std::string& webViewId,
279 const std::string& messageId,
280 const std::string& payload)
281{
282#ifdef ENABLE_PLUGIN
284 .getJamiPluginManager()
285 .getWebViewServicesManager()
286 .sendWebViewMessage(pluginId, webViewId, messageId, payload);
287#endif
288}
289
290std::string
291sendWebViewAttach(const std::string& pluginId,
292 const std::string& accountId,
293 const std::string& webViewId,
294 const std::string& action)
295{
296#ifdef ENABLE_PLUGIN
298 .getJamiPluginManager()
299 .getWebViewServicesManager()
300 .sendWebViewAttach(pluginId, accountId, webViewId, action);
301#endif
302}
303
304void
305sendWebViewDetach(const std::string& pluginId, const std::string& webViewId)
306{
307#ifdef ENABLE_PLUGIN
309 .getJamiPluginManager()
310 .getWebViewServicesManager()
311 .sendWebViewDetach(pluginId, webViewId);
312#endif
313}
314} // namespace libjami
static LIBJAMI_TEST_EXPORT Manager & instance()
Definition manager.cpp:676
void saveConfig()
Save config to file.
Definition manager.cpp:1751
void toggleChatHandler(const std::string &chatHandlerId, const std::string &accountId, const std::string &peerId, bool toggle)
void toggleCallMediaHandler(const std::string &mediaHandlerId, const std::string &callId, bool toggle)
void sendWebViewDetach(const std::string &pluginId, const std::string &webViewId)
std::map< std::string, std::string > getPlatformInfo()
std::vector< std::string > getLoadedPlugins()
std::map< std::string, std::string > getCallMediaHandlerDetails(const std::string &mediaHandlerId)
bool unloadPlugin(const std::string &path)
bool setPluginPreference(const std::string &path, const std::string &accountId, const std::string &key, const std::string &value)
void sendWebViewMessage(const std::string &pluginId, const std::string &webViewId, const std::string &messageId, const std::string &payload)
std::vector< std::map< std::string, std::string > > getPluginPreferences(const std::string &path, const std::string &accountId)
std::map< std::string, std::string > getPluginPreferencesValues(const std::string &path, const std::string &accountId)
std::string sendWebViewAttach(const std::string &pluginId, const std::string &accountId, const std::string &webViewId, const std::string &action)
std::map< std::string, std::string > getChatHandlerDetails(const std::string &chatHandlerId)
std::vector< std::string > getChatHandlers()
bool resetPluginPreferencesValues(const std::string &path, const std::string &accountId)
std::map< std::string, std::string > getPluginDetails(const std::string &path)
std::vector< std::string > getCallMediaHandlerStatus(const std::string &callId)
std::vector< std::string > getChatHandlerStatus(const std::string &accountId, const std::string &peerId)
std::vector< std::string > getCallMediaHandlers()
void setPluginsEnabled(bool state)
int installPlugin(const std::string &jplPath, bool force)
int uninstallPlugin(const std::string &pluginRootPath)
bool loadPlugin(const std::string &path)
std::vector< std::string > getInstalledPlugins()