Ring Daemon 16.0.0
Loading...
Searching...
No Matches
jami::JamiPluginManager Class Reference

This class provides an interface to functions exposed to the Plugin System interface for lrc and clients. More...

#include <jamipluginmanager.h>

Collaboration diagram for jami::JamiPluginManager:
Collaboration graph

Public Member Functions

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 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 checkPluginCertificateValidity (dht::crypto::Certificate *cert)
 Check the validity of a plugin certificate.
 
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 checkPluginSignatureFile (const std::string &jplPath)
 check if all file are present in the signature file
 
bool checkPluginSignatureValidity (const std::string &jplPath, dht::crypto::Certificate *cert)
 Check the validity of a plugin signature.
 
CallServicesManagergetCallServicesManager ()
 
ChatServicesManagergetChatServicesManager ()
 
std::vector< std::string > getInstalledPlugins ()
 Returns a vector with installed plugins.
 
std::vector< std::string > getLoadedPlugins () const
 Returns vector with rootpaths of the loaded plugins.
 
std::map< std::string, std::string > getPlatformInfo ()
 Returns a Map of platform system.
 
std::string getPluginAuthor (const std::string &rootPath, const std::string &pluginId)
 get the plugin's author
 
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.
 
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::map< std::string, std::string > getPluginPreferencesValuesMap (const std::string &rootPath, const std::string &accountId)
 Returns a Map with preferences keys and values.
 
PreferenceServicesManagergetPreferenceServicesManager ()
 
WebViewServicesManagergetWebViewServicesManager ()
 
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 installing a newer version of it.
 
 JamiPluginManager ()
 
bool loadPlugin (const std::string &rootPath)
 Returns True if success.
 
bool loadPlugins ()
 Returns True if success.
 
bool resetPluginPreferencesValuesMap (const std::string &rootPath, const std::string &accountId)
 Reset plugin's preferences values to their defaultValues.
 
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.
 
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 removes plugin folder.
 
bool unloadPlugin (const std::string &rootPath)
 Returns True if success.
 

Detailed Description

This class provides an interface to functions exposed to the Plugin System interface for lrc and clients.

Definition at line 42 of file jamipluginmanager.h.

Constructor & Destructor Documentation

◆ JamiPluginManager()

jami::JamiPluginManager::JamiPluginManager ( )

Definition at line 55 of file jamipluginmanager.cpp.

Member Function Documentation

◆ checkPluginCertificate()

std::unique_ptr< dht::crypto::Certificate > jami::JamiPluginManager::checkPluginCertificate ( const std::string &  jplPath,
bool  force 
)

Checks if the certificate mechanism is valid by checking certificate of the plugin.

Parameters
jplPath
force
Returns
return certificate if valid

Definition at line 241 of file jamipluginmanager.cpp.

References checkPluginCertificateValidity(), jami::emitSignal(), and jami::PluginUtils::readPluginCertificateFromArchive().

Referenced by installPlugin().

Here is the call graph for this function:

◆ checkPluginCertificatePublicKey()

bool jami::JamiPluginManager::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

Parameters
oldJplPath,newJplPathreturn true if valid

Definition at line 127 of file jamipluginmanager.cpp.

References DIR_SEPARATOR_CH, jami::emitSignal(), JAMI_ERR, jami::PluginUtils::manifestPath(), jami::PluginUtils::parseManifestFile(), jami::PluginUtils::readPluginCertificate(), and jami::PluginUtils::readPluginCertificateFromArchive().

Referenced by installPlugin().

Here is the call graph for this function:

◆ checkPluginCertificateValidity()

bool jami::JamiPluginManager::checkPluginCertificateValidity ( dht::crypto::Certificate *  cert)

Check the validity of a plugin certificate.

Parameters
cert
Returns
true if valid

Definition at line 152 of file jamipluginmanager.cpp.

References jami::emitSignal(), JAMI_ERROR, and store_ca_crt.

Referenced by checkPluginCertificate().

Here is the call graph for this function:

◆ checkPluginSignature()

bool jami::JamiPluginManager::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.

Parameters
jplPath

return true if the plugin signature is valid

Definition at line 228 of file jamipluginmanager.cpp.

References checkPluginSignatureFile(), checkPluginSignatureValidity(), and jami::emitSignal().

Referenced by installPlugin().

Here is the call graph for this function:

◆ checkPluginSignatureFile()

bool jami::JamiPluginManager::checkPluginSignatureFile ( const std::string &  jplPath)

check if all file are present in the signature file

Parameters
jplPathreturn true if valid

Definition at line 171 of file jamipluginmanager.cpp.

References jami::emitSignal(), jami::archiver::listFilesFromArchive(), jami::PluginUtils::readPluginManifestFromArchive(), and jami::PluginUtils::readPluginSignatureFromArchive().

Referenced by checkPluginSignature().

Here is the call graph for this function:

◆ checkPluginSignatureValidity()

bool jami::JamiPluginManager::checkPluginSignatureValidity ( const std::string &  jplPath,
dht::crypto::Certificate *  cert 
)

Check the validity of a plugin signature.

Parameters
jplPath
cert
Returns
true if valid

Definition at line 202 of file jamipluginmanager.cpp.

References jami::emitSignal(), JAMI_ERROR, jami::archiver::readFileFromArchive(), jami::PluginUtils::readPluginSignatureFromArchive(), and jami::PluginUtils::readSignatureFileFromArchive().

Referenced by checkPluginSignature().

Here is the call graph for this function:

◆ getCallServicesManager()

CallServicesManager & jami::JamiPluginManager::getCallServicesManager ( )
inline

Definition at line 203 of file jamipluginmanager.h.

◆ getChatServicesManager()

ChatServicesManager & jami::JamiPluginManager::getChatServicesManager ( )
inline

Definition at line 205 of file jamipluginmanager.h.

◆ getInstalledPlugins()

std::vector< std::string > jami::JamiPluginManager::getInstalledPlugins ( )

Returns a vector with installed plugins.

Definition at line 103 of file jamipluginmanager.cpp.

References jami::PluginUtils::checkPluginValidity(), jami::emitSignal(), jami::fileutils::get_data_dir(), and jami::Manager::instance().

Here is the call graph for this function:

◆ getLoadedPlugins()

std::vector< std::string > jami::JamiPluginManager::getLoadedPlugins ( ) const

Returns vector with rootpaths of the loaded plugins.

Definition at line 400 of file jamipluginmanager.cpp.

References jami::emitSignal(), and jami::PluginManager::getLoadedPlugins().

Here is the call graph for this function:

◆ getPlatformInfo()

std::map< std::string, std::string > jami::JamiPluginManager::getPlatformInfo ( )

Returns a Map of platform system.

Definition at line 165 of file jamipluginmanager.cpp.

References jami::PluginUtils::getPlatformInfo().

Here is the call graph for this function:

◆ getPluginAuthor()

std::string jami::JamiPluginManager::getPluginAuthor ( const std::string &  rootPath,
const std::string &  pluginId 
)

get the plugin's author

Parameters
rootPath
pluginId
Returns
string

Definition at line 65 of file jamipluginmanager.cpp.

References jami::emitSignal(), JAMI_ERROR, and jami::PluginUtils::readPluginCertificate().

Referenced by getPluginDetails().

Here is the call graph for this function:

◆ getPluginDetails()

std::map< std::string, std::string > jami::JamiPluginManager::getPluginDetails ( const std::string &  rootPath,
bool  reset = false 
)

Parses a manifest file and return its content along with other internally added values.

Parameters
rootPathinstallation path
resetIf true, overrides previous details values Reset is only used in the UT for now, but it can be useful if we want to reset plugins language without restarting the application
Returns
Map where the keyset is {"id", "name", "description", "version", "iconPath", "backgroundPath","soPath"}

Definition at line 76 of file jamipluginmanager.cpp.

References DIR_SEPARATOR_CH, jami::emitSignal(), getPluginAuthor(), LIB_PREFIX, LIB_TYPE, jami::PluginUtils::manifestPath(), and jami::PluginUtils::parseManifestFile().

Referenced by loadPlugin(), and unloadPlugin().

Here is the call graph for this function:

◆ getPluginPreferences()

std::vector< std::map< std::string, std::string > > jami::JamiPluginManager::getPluginPreferences ( const std::string &  rootPath,
const std::string &  accountId 
)

Returns contents of plugin's preferences.json file.

Parameters
rootPath
accountId

Definition at line 415 of file jamipluginmanager.cpp.

References jami::emitSignal(), and jami::PluginPreferencesUtils::getPreferences().

Here is the call graph for this function:

◆ getPluginPreferencesValuesMap()

std::map< std::string, std::string > jami::JamiPluginManager::getPluginPreferencesValuesMap ( const std::string &  rootPath,
const std::string &  accountId 
)

Returns a Map with preferences keys and values.

Parameters
rootPath
accountId

Definition at line 492 of file jamipluginmanager.cpp.

References jami::emitSignal(), and jami::PluginPreferencesUtils::getPreferencesValuesMap().

Here is the call graph for this function:

◆ getPreferenceServicesManager()

PreferenceServicesManager & jami::JamiPluginManager::getPreferenceServicesManager ( )
inline

Definition at line 209 of file jamipluginmanager.h.

◆ getWebViewServicesManager()

WebViewServicesManager & jami::JamiPluginManager::getWebViewServicesManager ( )
inline

Definition at line 207 of file jamipluginmanager.h.

◆ installPlugin()

int jami::JamiPluginManager::installPlugin ( const std::string &  jplPath,
bool  force 
)

Checks if the plugin has a valid manifest, installs the plugin if not previously installed or if installing a newer version of it.

Parameters
jplPath
forceIf true, allows installing an older plugin version.
Returns
0 if success 100 if already installed with similar version 200 if already installed with newer version libarchive (mizip in apple platforms) error codes otherwise

Definition at line 257 of file jamipluginmanager.cpp.

References CERTIFICATE_VERIFICATION_FAILED, checkPluginCertificate(), checkPluginCertificatePublicKey(), checkPluginSignature(), jami::emitSignal(), jami::fileutils::get_data_dir(), libjami::getPluginsEnabled(), jami::Manager::instance(), INVALID_PLUGIN, JAMI_ERR, libjami::loadPlugin(), loadPlugins(), jami::PluginUtils::manifestPath(), jami::PluginUtils::parseManifestFile(), PLUGIN_ALREADY_INSTALLED, PLUGIN_OLD_VERSION, jami::PluginUtils::readPluginManifestFromArchive(), jami::Manager::saveConfig(), libjami::setPluginsEnabled(), SIGNATURE_VERIFICATION_FAILED, SUCCESS, jami::archiver::uncompressArchive(), jami::PluginUtils::uncompressJplFunction(), uninstallPlugin(), and jami::swarm_protocol::version.

Here is the call graph for this function:

◆ loadPlugin()

bool jami::JamiPluginManager::loadPlugin ( const std::string &  rootPath)

Returns True if success.

Parameters
rootPathof the plugin folder

Definition at line 351 of file jamipluginmanager.cpp.

References jami::emitSignal(), getPluginDetails(), JAMI_ERR, JAMI_INFO, and jami::PluginManager::load().

Referenced by loadPlugins(), resetPluginPreferencesValuesMap(), and setPluginPreference().

Here is the call graph for this function:

◆ loadPlugins()

bool jami::JamiPluginManager::loadPlugins ( )

Returns True if success.

Definition at line 369 of file jamipluginmanager.cpp.

References jami::emitSignal(), jami::Manager::instance(), and loadPlugin().

Referenced by installPlugin().

Here is the call graph for this function:

◆ resetPluginPreferencesValuesMap()

bool jami::JamiPluginManager::resetPluginPreferencesValuesMap ( const std::string &  rootPath,
const std::string &  accountId 
)

Reset plugin's preferences values to their defaultValues.

Parameters
rootPath
accountId
Returns
True if success.

Definition at line 499 of file jamipluginmanager.cpp.

References jami::PluginManager::checkLoadedPlugin(), jami::emitSignal(), loadPlugin(), jami::PreferenceServicesManager::resetPreferences(), jami::PluginPreferencesUtils::resetPreferencesValuesMap(), and unloadPlugin().

Here is the call graph for this function:

◆ setPluginPreference()

bool jami::JamiPluginManager::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.

Plugin is reloaded only if the preference cannot take effect immediately. In other words, if we have to reload plugin so that preference may take effect.

Parameters
rootPath
accountId
key
value
Returns
True if success

Definition at line 421 of file jamipluginmanager.cpp.

References jami::PluginManager::checkLoadedPlugin(), jami::emitSignal(), jami::PluginPreferencesUtils::getPreferences(), jami::PluginPreferencesUtils::getPreferencesValuesMap(), jami::PluginPreferencesUtils::getUserPreferencesValuesMap(), JAMI_ERR, loadPlugin(), jami::CallServicesManager::setPreference(), jami::ChatServicesManager::setPreference(), jami::PreferenceServicesManager::setPreference(), unloadPlugin(), and jami::PluginPreferencesUtils::valuesFilePath().

Here is the call graph for this function:

◆ uninstallPlugin()

int jami::JamiPluginManager::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 removes plugin folder.

Parameters
rootPath
Returns
0 if success

Definition at line 323 of file jamipluginmanager.cpp.

References jami::PluginManager::checkLoadedPlugin(), jami::PluginUtils::checkPluginValidity(), jami::emitSignal(), FAILURE, jami::fileutils::get_data_dir(), jami::Manager::getAccountList(), jami::Manager::instance(), JAMI_INFO, SUCCESS, and libjami::unloadPlugin().

Referenced by installPlugin().

Here is the call graph for this function:

◆ unloadPlugin()

bool jami::JamiPluginManager::unloadPlugin ( const std::string &  rootPath)

Returns True if success.

Parameters
rootPathof the plugin folder

Definition at line 383 of file jamipluginmanager.cpp.

References jami::emitSignal(), getPluginDetails(), JAMI_ERR, JAMI_INFO, and jami::PluginManager::unload().

Referenced by resetPluginPreferencesValuesMap(), and setPluginPreference().

Here is the call graph for this function:

The documentation for this class was generated from the following files: