Ring Daemon
Loading...
Searching...
No Matches
pluginpreferencesutils.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 <json/json.h>
20#include <string>
21#include <filesystem>
22
23namespace jami {
24
25using ChatHandlerList = std::map<std::pair<std::string, std::string>, std::map<std::string, bool>>;
26
33{
34public:
42 static std::filesystem::path getPreferencesConfigFilePath(const std::filesystem::path& rootPath,
43 const std::string& accountId = "");
44
54 static std::filesystem::path valuesFilePath(const std::filesystem::path& rootPath,
55 const std::string& accountId = "");
56
63 static std::filesystem::path getAllowDenyListsPath();
64
70 static std::string convertArrayToString(const Json::Value& jsonArray);
71
77 static std::map<std::string, std::string> parsePreferenceConfig(const Json::Value& jsonPreference);
78
85 static std::vector<std::map<std::string, std::string>> getPreferences(const std::filesystem::path& rootPath,
86 const std::string& accountId = "");
87
94 static std::map<std::string, std::string> getUserPreferencesValuesMap(const std::filesystem::path& rootPath,
95 const std::string& accountId = "");
96
103 static std::map<std::string, std::string> getPreferencesValuesMap(const std::filesystem::path& rootPath,
104 const std::string& accountId = "");
105
113 static bool resetPreferencesValuesMap(const std::string& rootPath, const std::string& accountId);
114
120
126
134 static void addAlwaysHandlerPreference(const std::string& handlerName, const std::string& rootPath);
135
144 static bool getAlwaysPreference(const std::string& rootPath,
145 const std::string& handlerName,
146 const std::string& accountId);
147
148private:
151};
152} // namespace jami
Static class that gathers functions to manage plugins' preferences.
static std::map< std::string, std::string > getPreferencesValuesMap(const std::filesystem::path &rootPath, const std::string &accountId="")
Reads preferences values.
static void getAllowDenyListPreferences(ChatHandlerList &list)
Reads ChantHandlers status from allowdeny.msgpack file.
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 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::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 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::filesystem::path getAllowDenyListsPath()
Returns the path to allowdeny.msgpack file.
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.
static void setAllowDenyListPreferences(const ChatHandlerList &list)
Saves ChantHandlers status provided by list.
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....
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 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.
void emitSignal(Args... args)
Definition jami_signal.h:64
std::map< std::pair< std::string, std::string >, std::map< std::string, bool > > ChatHandlerList