Ring Daemon
Loading...
Searching...
No Matches
jamipluginmanager.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 "noncopyable.h"
21#include "pluginmanager.h"
22
23#include "callservicesmanager.h"
24#include "chatservicesmanager.h"
26#include <opendht/crypto.h>
27#include <vector>
28#include <map>
29
30namespace jami {
31
32using PreferencesMap = std::map<std::string, std::map<std::string, std::string>>;
33
40{
41public:
43
50 std::string getPluginAuthor(const std::string& rootPath, const std::string& pluginId);
51
61 std::map<std::string, std::string> getPluginDetails(const std::string& rootPath, bool reset = false);
62
66 std::vector<std::string> getInstalledPlugins();
67
73 bool checkPluginCertificateValidity(dht::crypto::Certificate* cert);
74
80 bool checkPluginCertificatePublicKey(const std::string& oldJplPath, const std::string& newJplPath);
81
87 bool checkPluginSignatureFile(const std::string& jplPath);
88
95 bool checkPluginSignatureValidity(const std::string& jplPath, dht::crypto::Certificate* cert);
96
104 bool checkPluginSignature(const std::string& jplPath, dht::crypto::Certificate* cert);
105
112 std::unique_ptr<dht::crypto::Certificate> checkPluginCertificate(const std::string& jplPath, bool force);
113
124 int installPlugin(const std::string& jplPath, bool force);
125
132 int uninstallPlugin(const std::string& rootPath);
133
138 bool loadPlugin(const std::string& rootPath);
139
143 bool loadPlugins();
144
149 bool unloadPlugin(const std::string& rootPath);
150
154 std::vector<std::string> getLoadedPlugins() const;
155
161 std::vector<std::map<std::string, std::string>> getPluginPreferences(const std::string& rootPath,
162 const std::string& accountId);
163
169 std::map<std::string, std::string> getPluginPreferencesValuesMap(const std::string& rootPath,
170 const std::string& accountId);
171
175 std::map<std::string, std::string> getPlatformInfo();
176
187 bool setPluginPreference(const std::filesystem::path& rootPath,
188 const std::string& accountId,
189 const std::string& key,
190 const std::string& value);
191
198 bool resetPluginPreferencesValuesMap(const std::string& rootPath, const std::string& accountId);
199
201
203
205
207
208#ifdef LIBJAMI_TEST
209 void addPluginAuthority(const dht::crypto::Certificate& cert);
210#endif
211
212private:
214
218 void registerServices();
219
220 // PluginManager instance
221 PluginManager pm_;
222 dht::crypto::TrustList trust_;
223 // Map between plugins installation path and manifest infos.
224 std::map<std::string, std::map<std::string, std::string>> pluginDetailsMap_;
225
226 // Services instances
227 CallServicesManager callsm_;
228 ChatServicesManager chatsm_;
229 WebViewServicesManager webviewsm_;
230 PreferenceServicesManager preferencesm_;
231};
232} // namespace jami
This class provides the interface between loaded MediaHandlers and call's audio/video streams.
This class provides the interface between loaded ChatHandlers and conversation messages.
This class provides an interface to functions exposed to the Plugin System interface for lrc and clie...
bool loadPlugins()
Returns True if success.
ChatServicesManager & getChatServicesManager()
std::vector< std::map< std::string, std::string > > getPluginPreferences(const std::string &rootPath, const std::string &accountId)
Returns contents of plugin's preferences.json file.
std::string getPluginAuthor(const std::string &rootPath, const std::string &pluginId)
get the plugin's author
bool checkPluginSignature(const std::string &jplPath, dht::crypto::Certificate *cert)
Checks if the plugin signature mechanism is valid by signature of files and each files is signed.
bool resetPluginPreferencesValuesMap(const std::string &rootPath, const std::string &accountId)
Reset plugin's preferences values to their defaultValues.
std::vector< std::string > getLoadedPlugins() const
Returns vector with rootpaths of the loaded plugins.
CallServicesManager & getCallServicesManager()
bool loadPlugin(const std::string &rootPath)
Returns True if success.
int installPlugin(const std::string &jplPath, bool force)
Checks if the plugin has a valid manifest, installs the plugin if not previously installed or if inst...
std::unique_ptr< dht::crypto::Certificate > checkPluginCertificate(const std::string &jplPath, bool force)
Checks if the certificate mechanism is valid by checking certificate of the plugin.
bool checkPluginSignatureValidity(const std::string &jplPath, dht::crypto::Certificate *cert)
Check the validity of a plugin signature.
std::map< std::string, std::string > getPluginDetails(const std::string &rootPath, bool reset=false)
Parses a manifest file and return its content along with other internally added values.
bool checkPluginSignatureFile(const std::string &jplPath)
check if all file are present in the signature file
bool unloadPlugin(const std::string &rootPath)
Returns True if success.
std::map< std::string, std::string > getPluginPreferencesValuesMap(const std::string &rootPath, const std::string &accountId)
Returns a Map with preferences keys and values.
std::vector< std::string > getInstalledPlugins()
Returns a vector with installed plugins.
PreferenceServicesManager & getPreferenceServicesManager()
bool checkPluginCertificatePublicKey(const std::string &oldJplPath, const std::string &newJplPath)
check if the if the public key of the certificate is the same as the public key in the new plugin
bool setPluginPreference(const std::filesystem::path &rootPath, const std::string &accountId, const std::string &key, const std::string &value)
Modifies a preference value by saving it to a preferences.msgpack.
bool checkPluginCertificateValidity(dht::crypto::Certificate *cert)
Check the validity of a plugin certificate.
int uninstallPlugin(const std::string &rootPath)
Checks if the plugin has a valid manifest and if the plugin is loaded, tries to unload it and then re...
WebViewServicesManager & getWebViewServicesManager()
std::map< std::string, std::string > getPlatformInfo()
Returns a Map of platform system.
This class manages plugin (un)loading.
This class provides the interface between PreferenceHandlers and per account preferences.
This class provides the interface between loaded WebViewHandlers and client webviews.
void emitSignal(Args... args)
Definition jami_signal.h:64
std::map< std::string, std::map< std::string, std::string > > PreferencesMap
Simple macro to hide class' copy constructor and assignment operator.
#define NON_COPYABLE(ClassName)
Definition noncopyable.h:30