Ring Daemon 16.0.0
Loading...
Searching...
No Matches
jami::PluginUtils Namespace Reference

Functions

std::map< std::string, std::string > checkManifestJsonContentValidity (const Json::Value &root)
 Check if manifest.json has minimum format and parses its content to a map<string, string>.
 
std::map< std::string, std::string > checkManifestValidity (const std::vector< uint8_t > &vec)
 Recives manifest.json file contents, and checks its validity.
 
std::map< std::string, std::string > checkManifestValidity (std::istream &stream)
 Reads manifest.json stream and checks if it's valid.
 
bool checkPluginValidity (const std::filesystem::path &rootPath)
 Validates a plugin based on its manifest.json file.
 
const std::regex DATA_REGEX ("^data" DIR_SEPARATOR_STR_ESC ".+")
 
std::filesystem::path dataPath (const std::filesystem::path &pluginSoPath)
 Returns data path given a plugin's library path.
 
std::string getLanguage ()
 Returns the language of the current locale.
 
std::map< std::string, std::string > getLocales (const std::string &rootPath, const std::string &lang)
 Returns the available keys and translations for a given plugin.
 
std::map< std::string, std::string > getPlatformInfo ()
 Returns a map with platform information.
 
std::filesystem::path getRootPathFromSoPath (const std::filesystem::path &soPath)
 Returns installation path given a plugin's library path.
 
std::filesystem::path manifestPath (const std::filesystem::path &rootPath)
 Returns complete manifest.json file path given a installation path.
 
std::map< std::string, std::string > parseManifestFile (const std::filesystem::path &manifestFilePath, const std::string &rootPath)
 Parses the manifest file of an installed plugin if it's valid.
 
std::string parseManifestTranslation (const std::string &rootPath, std::ifstream &manifestFile)
 Parses the manifest file of an installed plugin if it's valid.
 
std::map< std::string, std::string > processLocaleFile (const std::string &localeFilePath)
 Returns the available keys and translations for a given file.
 
std::unique_ptr< dht::crypto::Certificate > readPluginCertificate (const std::string &rootPath, const std::string &pluginId)
 Read the plugin's certificate.
 
std::unique_ptr< dht::crypto::Certificate > readPluginCertificateFromArchive (const std::string &jplPath)
 Read plugin certificate without uncompressing the whole archive.and return an object Certificate.
 
std::map< std::string, std::string > readPluginManifestFromArchive (const std::string &jplPath)
 Reads the manifest file content without uncompressing the whole archive and return a map with manifest contents if success.
 
std::map< std::string, std::vector< uint8_t > > readPluginSignatureFromArchive (const std::string &jplPath)
 Reads signature file content without uncompressing the whole archive and.
 
std::vector< uint8_treadSignatureFileFromArchive (const std::string &jplPath)
 Read the signature of the file signature without uncompressing the whole archive.
 
const std::regex SO_REGEX (DIR_SEPARATOR_STR_ESC "(.*)" DIR_SEPARATOR_STR_ESC "([a-zA-Z0-9]+.(dylib|so|dll|lib).*)")
 
std::pair< bool, std::string_view > uncompressJplFunction (std::string_view relativeFileName)
 Function used by archiver to extract files from plugin jpl to the plugin installation path.
 

Function Documentation

◆ checkManifestJsonContentValidity()

std::map< std::string, std::string > jami::PluginUtils::checkManifestJsonContentValidity ( const Json::Value &  root)

Check if manifest.json has minimum format and parses its content to a map<string, string>.

Parameters
root
Returns
Maps with manifest.json content if success.

Definition at line 100 of file pluginsutils.cpp.

References jami::emitSignal(), and jami::swarm_protocol::version.

Referenced by checkManifestValidity(), and checkManifestValidity().

Here is the call graph for this function:

◆ checkManifestValidity() [1/2]

std::map< std::string, std::string > jami::PluginUtils::checkManifestValidity ( const std::vector< uint8_t > &  vec)

Recives manifest.json file contents, and checks its validity.

Parameters
vec
Returns
Maps with manifest.json content if success.

Definition at line 138 of file pluginsutils.cpp.

References checkManifestJsonContentValidity(), and jami::emitSignal().

Here is the call graph for this function:

◆ checkManifestValidity() [2/2]

std::map< std::string, std::string > jami::PluginUtils::checkManifestValidity ( std::istream &  stream)

Reads manifest.json stream and checks if it's valid.

Parameters
stream
Returns
Maps with manifest.json content if success.

Definition at line 123 of file pluginsutils.cpp.

References checkManifestJsonContentValidity(), and jami::emitSignal().

Referenced by parseManifestFile(), and readPluginManifestFromArchive().

Here is the call graph for this function:

◆ checkPluginValidity()

bool jami::PluginUtils::checkPluginValidity ( const std::filesystem::path &  rootPath)

Validates a plugin based on its manifest.json file.

Parameters
rootPath
Returns
True if valid

Definition at line 199 of file pluginsutils.cpp.

References jami::emitSignal(), manifestPath(), and parseManifestFile().

Referenced by jami::JamiPluginManager::getInstalledPlugins(), and jami::JamiPluginManager::uninstallPlugin().

Here is the call graph for this function:

◆ DATA_REGEX()

const std::regex jami::PluginUtils::DATA_REGEX ( "^data" DIR_SEPARATOR_STR_ESC ".+"  )

◆ dataPath()

std::filesystem::path jami::PluginUtils::dataPath ( const std::filesystem::path &  pluginSoPath)

Returns data path given a plugin's library path.

Parameters
pluginSoPath

Definition at line 94 of file pluginsutils.cpp.

References jami::emitSignal(), and getRootPathFromSoPath().

Here is the call graph for this function:

◆ getLanguage()

std::string jami::PluginUtils::getLanguage ( )

Returns the language of the current locale.

Returns
language

Definition at line 284 of file pluginsutils.cpp.

References jami::emitSignal(), JAMI_INFO, and jami::string_replace().

Referenced by jami::PluginPreferencesUtils::getPreferences(), and parseManifestTranslation().

Here is the call graph for this function:

◆ getLocales()

std::map< std::string, std::string > jami::PluginUtils::getLocales ( const std::string &  rootPath,
const std::string &  lang 
)

Returns the available keys and translations for a given plugin.

If the locale is not available, return the english default.

Parameters
rootPath
lang
Returns
locales map

Definition at line 331 of file pluginsutils.cpp.

References DIR_SEPARATOR_CH, jami::emitSignal(), and processLocaleFile().

Referenced by jami::PluginPreferencesUtils::getPreferences(), and parseManifestTranslation().

Here is the call graph for this function:

◆ getPlatformInfo()

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

Returns a map with platform information.

Returns
Map with platform information

Definition at line 80 of file pluginsutils.cpp.

References ABI.

Referenced by jami::JamiPluginManager::getPlatformInfo().

◆ getRootPathFromSoPath()

std::filesystem::path jami::PluginUtils::getRootPathFromSoPath ( const std::filesystem::path &  soPath)

Returns installation path given a plugin's library path.

Parameters
soPath

Definition at line 88 of file pluginsutils.cpp.

References jami::emitSignal().

Referenced by dataPath().

Here is the call graph for this function:

◆ manifestPath()

std::filesystem::path jami::PluginUtils::manifestPath ( const std::filesystem::path &  rootPath)

Returns complete manifest.json file path given a installation path.

Parameters
rootPath

Definition at line 74 of file pluginsutils.cpp.

References jami::emitSignal().

Referenced by jami::JamiPluginManager::checkPluginCertificatePublicKey(), checkPluginValidity(), jami::JamiPluginManager::getPluginDetails(), and jami::JamiPluginManager::installPlugin().

Here is the call graph for this function:

◆ parseManifestFile()

std::map< std::string, std::string > jami::PluginUtils::parseManifestFile ( const std::filesystem::path &  manifestFilePath,
const std::string &  rootPath 
)

Parses the manifest file of an installed plugin if it's valid.

Parameters
manifestFilePath
Returns
Map with manifest contents

Definition at line 157 of file pluginsutils.cpp.

References checkManifestValidity(), jami::emitSignal(), JAMI_ERR, and parseManifestTranslation().

Referenced by jami::JamiPluginManager::checkPluginCertificatePublicKey(), checkPluginValidity(), jami::JamiPluginManager::getPluginDetails(), and jami::JamiPluginManager::installPlugin().

Here is the call graph for this function:

◆ parseManifestTranslation()

std::string jami::PluginUtils::parseManifestTranslation ( const std::string &  rootPath,
std::ifstream &  manifestFile 
)

Parses the manifest file of an installed plugin if it's valid.

Parameters
rootPath
manifestFile
Returns
Map with manifest contents

Definition at line 173 of file pluginsutils.cpp.

References jami::emitSignal(), getLanguage(), getLocales(), and std::regex_search().

Referenced by parseManifestFile().

Here is the call graph for this function:

◆ processLocaleFile()

std::map< std::string, std::string > jami::PluginUtils::processLocaleFile ( const std::string &  localeFilePath)

Returns the available keys and translations for a given file.

If the locale is not available, return empty map.

Parameters
localeFilePath
Returns
locales map

Definition at line 352 of file pluginsutils.cpp.

References jami::emitSignal().

Referenced by getLocales().

Here is the call graph for this function:

◆ readPluginCertificate()

std::unique_ptr< dht::crypto::Certificate > jami::PluginUtils::readPluginCertificate ( const std::string &  rootPath,
const std::string &  pluginId 
)

Read the plugin's certificate.

Parameters
rootPath
pluginId
Returns
Certificate object pointer

Definition at line 216 of file pluginsutils.cpp.

References DIR_SEPARATOR_CH, jami::emitSignal(), JAMI_ERR, and jami::fileutils::loadFile().

Referenced by jami::JamiPluginManager::checkPluginCertificatePublicKey(), and jami::JamiPluginManager::getPluginAuthor().

Here is the call graph for this function:

◆ readPluginCertificateFromArchive()

std::unique_ptr< dht::crypto::Certificate > jami::PluginUtils::readPluginCertificateFromArchive ( const std::string &  jplPath)

Read plugin certificate without uncompressing the whole archive.and return an object Certificate.

Parameters
jplPath
Returns
Certificate object pointer

Definition at line 229 of file pluginsutils.cpp.

References jami::emitSignal(), JAMI_ERR, jami::archiver::readFileFromArchive(), and readPluginManifestFromArchive().

Referenced by jami::JamiPluginManager::checkPluginCertificate(), and jami::JamiPluginManager::checkPluginCertificatePublicKey().

Here is the call graph for this function:

◆ readPluginManifestFromArchive()

std::map< std::string, std::string > jami::PluginUtils::readPluginManifestFromArchive ( const std::string &  jplPath)

Reads the manifest file content without uncompressing the whole archive and return a map with manifest contents if success.

Parameters
jplPath
Returns
Map with manifest contents

Definition at line 205 of file pluginsutils.cpp.

References checkManifestValidity(), jami::emitSignal(), JAMI_ERR, and jami::archiver::readFileFromArchive().

Referenced by jami::JamiPluginManager::checkPluginSignatureFile(), jami::JamiPluginManager::installPlugin(), and readPluginCertificateFromArchive().

Here is the call graph for this function:

◆ readPluginSignatureFromArchive()

std::map< std::string, std::vector< uint8_t > > jami::PluginUtils::readPluginSignatureFromArchive ( const std::string &  jplPath)

Reads signature file content without uncompressing the whole archive and.

Parameters
jplPathreturn a map of signature path as key and signature content as value.

Definition at line 245 of file pluginsutils.cpp.

References jami::emitSignal(), JAMI_ERR, and jami::archiver::readFileFromArchive().

Referenced by jami::JamiPluginManager::checkPluginSignatureFile(), and jami::JamiPluginManager::checkPluginSignatureValidity().

Here is the call graph for this function:

◆ readSignatureFileFromArchive()

std::vector< uint8_t > jami::PluginUtils::readSignatureFileFromArchive ( const std::string &  jplPath)

Read the signature of the file signature without uncompressing the whole archive.

Parameters
jplPath
Returns
Signature file content

Definition at line 261 of file pluginsutils.cpp.

References jami::emitSignal(), and jami::archiver::readFileFromArchive().

Referenced by jami::JamiPluginManager::checkPluginSignatureValidity().

Here is the call graph for this function:

◆ SO_REGEX()

const std::regex jami::PluginUtils::SO_REGEX ( DIR_SEPARATOR_STR_ESC "(.*)" DIR_SEPARATOR_STR_ESC "([a-zA-Z0-9]+.(dylib|so|dll|lib).*)"  )

Referenced by uncompressJplFunction().

◆ uncompressJplFunction()

std::pair< bool, std::string_view > jami::PluginUtils::uncompressJplFunction ( std::string_view  relativeFileName)

Function used by archiver to extract files from plugin jpl to the plugin installation path.

Parameters
relativeFileName
Returns
Pair <bool, string> meaning if file should be extracted and where to.

Definition at line 267 of file pluginsutils.cpp.

References ABI, jami::emitSignal(), std::regex_search(), SO_REGEX(), and std::svsub_match_view().

Referenced by jami::JamiPluginManager::installPlugin().

Here is the call graph for this function: