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

Static class that gathers functions to manage plugins' preferences. More...

#include <pluginpreferencesutils.h>

Collaboration diagram for jami::PluginPreferencesUtils:
Collaboration graph

Static Public Member Functions

static void addAlwaysHandlerPreference (const std::string &handlerName, const std::string &rootPath)
 Creates a "always" preference for a handler if this preference doesn't exist yet.
 
static std::string convertArrayToString (const Json::Value &jsonArray)
 Returns a colon separated string with values from a json::Value containing an array.
 
static void getAllowDenyListPreferences (ChatHandlerList &list)
 Reads ChantHandlers status from allowdeny.msgpack file.
 
static std::filesystem::path getAllowDenyListsPath ()
 Returns the path to allowdeny.msgpack file.
 
static bool getAlwaysPreference (const std::string &rootPath, const std::string &handlerName, const std::string &accountId)
 Read plugin's preferences and returns wheter a specific handler "always" preference is True or False.
 
static std::vector< std::map< std::string, std::string > > getPreferences (const std::filesystem::path &rootPath, const std::string &accountId="")
 Reads a preference.json file from the plugin installed in rootPath.
 
static std::filesystem::path getPreferencesConfigFilePath (const std::filesystem::path &rootPath, const std::string &accountId="")
 Given a plugin installation path, returns the path to the preference.json of this plugin.
 
static std::map< std::string, std::string > getPreferencesValuesMap (const std::filesystem::path &rootPath, const std::string &accountId="")
 Reads preferences values.
 
static std::map< std::string, std::string > getUserPreferencesValuesMap (const std::filesystem::path &rootPath, const std::string &accountId="")
 Reads preferences values which were modified from defaultValue.
 
static std::map< std::string, std::string > parsePreferenceConfig (const Json::Value &jsonPreference)
 Parses a single preference from json::Value to a Map<string, string>.
 
static bool resetPreferencesValuesMap (const std::string &rootPath, const std::string &accountId)
 Resets all preferences values to their defaultValues by erasing all data saved in preferences.msgpack.
 
static void setAllowDenyListPreferences (const ChatHandlerList &list)
 Saves ChantHandlers status provided by list.
 
static std::filesystem::path valuesFilePath (const std::filesystem::path &rootPath, const std::string &accountId="")
 Given a plugin installation path, returns the path to the preference.msgpack file.
 

Detailed Description

Static class that gathers functions to manage plugins' preferences.

Definition at line 33 of file pluginpreferencesutils.h.

Member Function Documentation

◆ addAlwaysHandlerPreference()

void jami::PluginPreferencesUtils::addAlwaysHandlerPreference ( const std::string &  handlerName,
const std::string &  rootPath 
)
static

Creates a "always" preference for a handler if this preference doesn't exist yet.

A "always" preference tells the Plugin System if in the event of a new call or chat message, the handler is suposed to be automatically activated.

Parameters
handlerName
rootPath

Definition at line 301 of file pluginpreferencesutils.cpp.

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

Here is the call graph for this function:

◆ convertArrayToString()

std::string jami::PluginPreferencesUtils::convertArrayToString ( const Json::Value &  jsonArray)
static

Returns a colon separated string with values from a json::Value containing an array.

Parameters
jsonArray
Returns
Colon separated string with jsonArray contents.

Definition at line 59 of file pluginpreferencesutils.cpp.

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

Referenced by convertArrayToString(), and parsePreferenceConfig().

Here is the call graph for this function:

◆ getAllowDenyListPreferences()

void jami::PluginPreferencesUtils::getAllowDenyListPreferences ( ChatHandlerList list)
static

Reads ChantHandlers status from allowdeny.msgpack file.

Parameters
[out]list

Definition at line 268 of file pluginpreferencesutils.cpp.

References jami::emitSignal(), getAllowDenyListsPath(), and JAMI_ERR.

Referenced by jami::ChatServicesManager::ChatServicesManager().

Here is the call graph for this function:

◆ getAllowDenyListsPath()

std::filesystem::path jami::PluginPreferencesUtils::getAllowDenyListsPath ( )
static

Returns the path to allowdeny.msgpack file.

The allowdeny.msgpack file persists ChatHandlers status for each conversation this handler was previously (de)activated.

Returns
allowdeny.msgpack file path.

Definition at line 53 of file pluginpreferencesutils.cpp.

References jami::fileutils::get_data_dir().

Referenced by getAllowDenyListPreferences(), and setAllowDenyListPreferences().

Here is the call graph for this function:

◆ getAlwaysPreference()

bool jami::PluginPreferencesUtils::getAlwaysPreference ( const std::string &  rootPath,
const std::string &  handlerName,
const std::string &  accountId 
)
static

Read plugin's preferences and returns wheter a specific handler "always" preference is True or False.

Parameters
rootPath
handlerName
accountId
Returns
True if the handler should be automatically toggled

Definition at line 362 of file pluginpreferencesutils.cpp.

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

Referenced by jami::CallServicesManager::createAVSubject(), and jami::ChatServicesManager::publishMessage().

Here is the call graph for this function:

◆ getPreferences()

std::vector< std::map< std::string, std::string > > jami::PluginPreferencesUtils::getPreferences ( const std::filesystem::path &  rootPath,
const std::string &  accountId = "" 
)
static

Reads a preference.json file from the plugin installed in rootPath.

Parameters
rootPath
accountId
Returns
std::vector<std::map<std::string, std::string>> with preferences.json content

Definition at line 99 of file pluginpreferencesutils.cpp.

References jami::emitSignal(), jami::PluginUtils::getLanguage(), jami::PluginUtils::getLocales(), getPreferencesConfigFilePath(), JAMI_ERR, parsePreferenceConfig(), jami::string_remove_suffix(), and jami::string_replace().

Referenced by getAlwaysPreference(), jami::JamiPluginManager::getPluginPreferences(), getPreferencesValuesMap(), and jami::JamiPluginManager::setPluginPreference().

Here is the call graph for this function:

◆ getPreferencesConfigFilePath()

std::filesystem::path jami::PluginPreferencesUtils::getPreferencesConfigFilePath ( const std::filesystem::path &  rootPath,
const std::string &  accountId = "" 
)
static

Given a plugin installation path, returns the path to the preference.json of this plugin.

Parameters
rootPath
accountId
Returns
preference.json file path.

Definition at line 32 of file pluginpreferencesutils.cpp.

References jami::emitSignal().

Referenced by addAlwaysHandlerPreference(), and getPreferences().

Here is the call graph for this function:

◆ getPreferencesValuesMap()

std::map< std::string, std::string > jami::PluginPreferencesUtils::getPreferencesValuesMap ( const std::filesystem::path &  rootPath,
const std::string &  accountId = "" 
)
static

Reads preferences values.

Parameters
rootPath
accountId
Returns
Map with preference keys and actuall values.

Definition at line 198 of file pluginpreferencesutils.cpp.

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

Referenced by getAlwaysPreference(), jami::JamiPluginManager::getPluginPreferencesValuesMap(), and jami::JamiPluginManager::setPluginPreference().

Here is the call graph for this function:

◆ getUserPreferencesValuesMap()

std::map< std::string, std::string > jami::PluginPreferencesUtils::getUserPreferencesValuesMap ( const std::filesystem::path &  rootPath,
const std::string &  accountId = "" 
)
static

Reads preferences values which were modified from defaultValue.

Parameters
rootPath
accountId
Returns
Map with preference keys and actuall values.

Definition at line 162 of file pluginpreferencesutils.cpp.

References jami::emitSignal(), JAMI_ERR, and valuesFilePath().

Referenced by getPreferencesValuesMap(), and jami::JamiPluginManager::setPluginPreference().

Here is the call graph for this function:

◆ parsePreferenceConfig()

std::map< std::string, std::string > jami::PluginPreferencesUtils::parsePreferenceConfig ( const Json::Value &  jsonPreference)
static

Parses a single preference from json::Value to a Map<string, string>.

Parameters
jsonPreference
Returns
std::map<std::string, std::string> preference

Definition at line 82 of file pluginpreferencesutils.cpp.

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

Referenced by getPreferences().

Here is the call graph for this function:

◆ resetPreferencesValuesMap()

bool jami::PluginPreferencesUtils::resetPreferencesValuesMap ( const std::string &  rootPath,
const std::string &  accountId 
)
static

Resets all preferences values to their defaultValues by erasing all data saved in preferences.msgpack.

Parameters
rootPath
accountId
Returns
True if preferences were reset.

Definition at line 229 of file pluginpreferencesutils.cpp.

References jami::emitSignal(), JAMI_ERR, and valuesFilePath().

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

Here is the call graph for this function:

◆ setAllowDenyListPreferences()

void jami::PluginPreferencesUtils::setAllowDenyListPreferences ( const ChatHandlerList list)
static

Saves ChantHandlers status provided by list.

Parameters
[in]list

Definition at line 252 of file pluginpreferencesutils.cpp.

References jami::emitSignal(), getAllowDenyListsPath(), and JAMI_ERR.

Referenced by jami::ChatServicesManager::publishMessage().

Here is the call graph for this function:

◆ valuesFilePath()

std::filesystem::path jami::PluginPreferencesUtils::valuesFilePath ( const std::filesystem::path &  rootPath,
const std::string &  accountId = "" 
)
static

Given a plugin installation path, returns the path to the preference.msgpack file.

The preference.msgpack file saves the actuall preferences values if they were modified.

Parameters
rootPath
accountId
Returns
preference.msgpack file path.

Definition at line 42 of file pluginpreferencesutils.cpp.

References jami::emitSignal(), and jami::fileutils::get_data_dir().

Referenced by getUserPreferencesValuesMap(), resetPreferencesValuesMap(), and jami::JamiPluginManager::setPluginPreference().

Here is the call graph for this function:

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