Ring Daemon 16.0.0
Loading...
Searching...
No Matches
pluginpreferencesutils.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 <json/json.h>
20#include <string>
21#include <set>
22#include <filesystem>
23
24namespace jami {
25
26using ChatHandlerList = std::map<std::pair<std::string, std::string>, std::map<std::string, bool>>;
27
34{
35public:
43 static std::filesystem::path getPreferencesConfigFilePath(const std::filesystem::path& rootPath,
44 const std::string& accountId = "");
45
55 static std::filesystem::path valuesFilePath(const std::filesystem::path& rootPath,
56 const std::string& accountId = "");
57
64 static std::filesystem::path getAllowDenyListsPath();
65
71 static std::string convertArrayToString(const Json::Value& jsonArray);
72
78 static std::map<std::string, std::string> parsePreferenceConfig(
79 const Json::Value& jsonPreference);
80
87 static std::vector<std::map<std::string, std::string>> getPreferences(
88 const std::filesystem::path& rootPath, const std::string& accountId = "");
89
96 static std::map<std::string, std::string> getUserPreferencesValuesMap(
97 const std::filesystem::path& rootPath, const std::string& accountId = "");
98
105 static std::map<std::string, std::string> getPreferencesValuesMap(
106 const std::filesystem::path& rootPath, const std::string& accountId = "");
107
115 static bool resetPreferencesValuesMap(const std::string& rootPath, const std::string& accountId);
116
122
128
136 static void addAlwaysHandlerPreference(const std::string& handlerName,
137 const std::string& rootPath);
138
147 static bool getAlwaysPreference(const std::string& rootPath,
148 const std::string& handlerName,
149 const std::string& accountId);
150
151private:
154};
155} // 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 ring_signal.h:64
std::map< std::pair< std::string, std::string >, std::map< std::string, bool > > ChatHandlerList