Ring Daemon 16.0.0
Loading...
Searching...
No Matches
jamipluginmanager.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 "noncopyable.h"
21#include "pluginmanager.h"
23
24#include "callservicesmanager.h"
25#include "chatservicesmanager.h"
27#include <opendht/crypto.h>
28#include <vector>
29#include <map>
30#include <list>
31#include <algorithm>
32
33namespace jami {
34
35using PreferencesMap = std::map<std::string, std::map<std::string, std::string>>;
36
43{
44public:
46
53 std::string getPluginAuthor(const std::string& rootPath, const std::string& pluginId);
54
64 std::map<std::string, std::string> getPluginDetails(const std::string& rootPath, bool reset = false);
65
69 std::vector<std::string> getInstalledPlugins();
70
76 bool checkPluginCertificateValidity(dht::crypto::Certificate* cert);
77
83 bool checkPluginCertificatePublicKey(const std::string& oldJplPath, const std::string& newJplPath);
84
90 bool checkPluginSignatureFile(const std::string& jplPath);
91
98 bool checkPluginSignatureValidity(const std::string& jplPath, dht::crypto::Certificate* cert);
99
107 bool checkPluginSignature(const std::string& jplPath, dht::crypto::Certificate* cert);
108
115 std::unique_ptr<dht::crypto::Certificate> checkPluginCertificate(const std::string& jplPath, bool force);
116
127 int installPlugin(const std::string& jplPath, bool force);
128
135 int uninstallPlugin(const std::string& rootPath);
136
141 bool loadPlugin(const std::string& rootPath);
142
146 bool loadPlugins();
147
152 bool unloadPlugin(const std::string& rootPath);
153
157 std::vector<std::string> getLoadedPlugins() const;
158
164 std::vector<std::map<std::string, std::string>> getPluginPreferences(
165 const std::string& rootPath, const std::string& accountId);
166
172 std::map<std::string, std::string> getPluginPreferencesValuesMap(const std::string& rootPath,
173 const std::string& accountId);
174
178 std::map<std::string, std::string> getPlatformInfo();
179
190 bool setPluginPreference(const std::filesystem::path& rootPath,
191 const std::string& accountId,
192 const std::string& key,
193 const std::string& value);
194
201 bool resetPluginPreferencesValuesMap(const std::string& rootPath, const std::string& accountId);
202
204
206
208
210
211#ifdef LIBJAMI_TEST
212 void addPluginAuthority(const dht::crypto::Certificate& cert);
213#endif
214
215private:
217
221 void registerServices();
222
223 // PluginManager instance
224 PluginManager pm_;
225 dht::crypto::TrustList trust_;
226 // Map between plugins installation path and manifest infos.
227 std::map<std::string, std::map<std::string, std::string>> pluginDetailsMap_;
228
229 // Services instances
230 CallServicesManager callsm_;
231 ChatServicesManager chatsm_;
232 WebViewServicesManager webviewsm_;
233 PreferenceServicesManager preferencesm_;
234};
235} // 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 ring_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