Line data Source code
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 <string>
20 : #include <map>
21 :
22 : namespace jami {
23 :
24 : /**
25 : * @brief This abstract class is an API we need to implement from plugin side.
26 : * In other words, a plugin functionality that handles preferences per account
27 : * must start from the implementation of this class.
28 : */
29 : class PreferenceHandler
30 : {
31 : public:
32 : virtual ~PreferenceHandler() {}
33 :
34 : /**
35 : * @brief Returns a map with handler's name, iconPath, and pluginId.
36 : */
37 : virtual std::map<std::string, std::string> getHandlerDetails() = 0;
38 :
39 : /**
40 : * @brief If a preference can have different values depending on accountId, those values should
41 : * be stored in the plugin through this function.
42 : * @param accountId
43 : * @param key
44 : * @param value
45 : */
46 : virtual void setPreferenceAttribute(const std::string& accountId, const std::string& key, const std::string& value)
47 : = 0;
48 :
49 : /**
50 : * @brief If a preference can be stored as per accountId, this function should return True.
51 : * @param key
52 : * @return True if preference can be changed through setPreferenceAttribute method.
53 : */
54 : virtual bool preferenceMapHasKey(const std::string& key) = 0;
55 :
56 : /**
57 : * @brief Reset stored preferences for given accountId.
58 : * @param accountId
59 : */
60 : virtual void resetPreferenceAttributes(const std::string& accountId) = 0;
61 :
62 : /**
63 : * @brief Returns the dataPath of the plugin that created this PreferenceHandler.
64 : */
65 0 : std::string id() const { return id_; }
66 :
67 : /**
68 : * @brief Should be called by the PreferenceHandler creator to set the plugins id_ variable.
69 : */
70 : virtual void setId(const std::string& id) final { id_ = id; }
71 :
72 : private:
73 : // Is the dataPath of the plugin that created this ChatHandler.
74 : std::string id_;
75 : };
76 : } // namespace jami
|