Ring Daemon
Loading...
Searching...
No Matches
plugin_manager_interface.cpp
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
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, accountId, key, value);
82#endif
83 return {};
84}
85
86std::map<std::string, std::string>
87getPluginPreferencesValues(const std::string& path, const std::string& accountId)
88{
89#ifdef ENABLE_PLUGIN
90 return jami::Manager::instance().getJamiPluginManager().getPluginPreferencesValuesMap(path, accountId);
91#endif
92 return {};
93}
94bool
95resetPluginPreferencesValues(const std::string& path, const std::string& accountId)
96{
97#ifdef ENABLE_PLUGIN
98 return jami::Manager::instance().getJamiPluginManager().resetPluginPreferencesValuesMap(path, accountId);
99#endif
100}
101
102std::vector<std::string>
104{
105#ifdef ENABLE_PLUGIN
106 return jami::Manager::instance().getJamiPluginManager().getInstalledPlugins();
107#endif
108 return {};
109}
110
111std::vector<std::string>
113{
114#ifdef ENABLE_PLUGIN
115 return jami::Manager::instance().pluginPreferences.getLoadedPlugins();
116#endif
117 return {};
118}
119
120int
121installPlugin(const std::string& jplPath, bool force)
122{
123#ifdef ENABLE_PLUGIN
124 return jami::Manager::instance().getJamiPluginManager().installPlugin(jplPath, force);
125#endif
126 return -1;
127}
128
129int
130uninstallPlugin(const std::string& pluginRootPath)
131{
132#ifdef ENABLE_PLUGIN
133 int status = jami::Manager::instance().getJamiPluginManager().uninstallPlugin(pluginRootPath);
134 jami::Manager::instance().pluginPreferences.saveStateLoadedPlugins(pluginRootPath, false);
136 return status;
137#endif
138 return -1;
139}
140
141std::map<std::string, std::string>
143{
144#ifdef ENABLE_PLUGIN
145 return jami::Manager::instance().getJamiPluginManager().getPlatformInfo();
146#endif
147 return {};
148}
149
150std::vector<std::string>
152{
153#ifdef ENABLE_PLUGIN
154 return jami::Manager::instance().getJamiPluginManager().getCallServicesManager().getCallMediaHandlers();
155#endif
156 return {};
157}
158
159std::vector<std::string>
161{
162#ifdef ENABLE_PLUGIN
163 return jami::Manager::instance().getJamiPluginManager().getChatServicesManager().getChatHandlers();
164#endif
165 return {};
166}
167
168void
169toggleCallMediaHandler(const std::string& mediaHandlerId, const std::string& callId, bool toggle)
170{
171#ifdef ENABLE_PLUGIN
172 jami::Manager::instance().getJamiPluginManager().getCallServicesManager().toggleCallMediaHandler(mediaHandlerId,
173 callId,
174 toggle);
175#endif
176}
177
178void
179toggleChatHandler(const std::string& chatHandlerId, const std::string& accountId, const std::string& peerId, bool toggle)
180{
181#ifdef ENABLE_PLUGIN
182 jami::Manager::instance().getJamiPluginManager().getChatServicesManager().toggleChatHandler(chatHandlerId,
183 accountId,
184 peerId,
185 toggle);
186#endif
187}
188
189std::map<std::string, std::string>
190getCallMediaHandlerDetails(const std::string& mediaHandlerId)
191{
192#ifdef ENABLE_PLUGIN
193 return jami::Manager::instance().getJamiPluginManager().getCallServicesManager().getCallMediaHandlerDetails(
194 mediaHandlerId);
195#endif
196 return {};
197}
198
199std::vector<std::string>
200getCallMediaHandlerStatus(const std::string& callId)
201{
202#ifdef ENABLE_PLUGIN
203 return jami::Manager::instance().getJamiPluginManager().getCallServicesManager().getCallMediaHandlerStatus(callId);
204#endif
205 return {};
206}
207
208std::map<std::string, std::string>
209getChatHandlerDetails(const std::string& chatHandlerId)
210{
211#ifdef ENABLE_PLUGIN
212 return jami::Manager::instance().getJamiPluginManager().getChatServicesManager().getChatHandlerDetails(
213 chatHandlerId);
214#endif
215 return {};
216}
217
218std::vector<std::string>
219getChatHandlerStatus(const std::string& accountId, const std::string& peerId)
220{
221#ifdef ENABLE_PLUGIN
222 return jami::Manager::instance().getJamiPluginManager().getChatServicesManager().getChatHandlerStatus(accountId,
223 peerId);
224#endif
225 return {};
226}
227
228bool
230{
231#ifdef ENABLE_PLUGIN
232 return jami::Manager::instance().pluginPreferences.getPluginsEnabled();
233#endif
234 return false;
235}
236
237void
239{
240#ifdef ENABLE_PLUGIN
241 jami::Manager::instance().pluginPreferences.setPluginsEnabled(state);
242 for (auto& item : jami::Manager::instance().pluginPreferences.getLoadedPlugins()) {
243 if (state)
244 jami::Manager::instance().getJamiPluginManager().loadPlugin(item);
245 else
246 jami::Manager::instance().getJamiPluginManager().unloadPlugin(item);
247 }
249#endif
250}
251
252void
253sendWebViewMessage(const std::string& pluginId,
254 const std::string& webViewId,
255 const std::string& messageId,
256 const std::string& payload)
257{
258#ifdef ENABLE_PLUGIN
259 jami::Manager::instance().getJamiPluginManager().getWebViewServicesManager().sendWebViewMessage(pluginId,
260 webViewId,
261 messageId,
262 payload);
263#endif
264}
265
266std::string
267sendWebViewAttach(const std::string& pluginId,
268 const std::string& accountId,
269 const std::string& webViewId,
270 const std::string& action)
271{
272#ifdef ENABLE_PLUGIN
273 return jami::Manager::instance().getJamiPluginManager().getWebViewServicesManager().sendWebViewAttach(pluginId,
274 accountId,
275 webViewId,
276 action);
277#endif
278}
279
280void
281sendWebViewDetach(const std::string& pluginId, const std::string& webViewId)
282{
283#ifdef ENABLE_PLUGIN
284 jami::Manager::instance().getJamiPluginManager().getWebViewServicesManager().sendWebViewDetach(pluginId, webViewId);
285#endif
286}
287} // namespace libjami
static LIBJAMI_TEST_EXPORT Manager & instance()
Definition manager.cpp:694
void saveConfig()
Save config to file.
Definition manager.cpp:1755
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()