Ring Daemon 16.0.0
Loading...
Searching...
No Matches
account_config.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
19#include "config/serializable.h"
20#include "string_utils.h"
21
22#include <string>
23#include <string_view>
24#include <utility>
25#include <map>
26#include <filesystem>
27
28using namespace std::literals;
29
30namespace jami {
31constexpr const char* const DEFAULT_RINGTONE_PATH = "default.opus";
32
34{
35 AccountConfig(const std::string& type_, const std::string& id_, const std::filesystem::path& path_ = {})
36 : type(type_)
37 , id(id_)
38 , path(path_)
39 {}
40
41 void serializeDiff(YAML::Emitter& out, const AccountConfig& def) const;
42
43 virtual void serialize(YAML::Emitter& out) const = 0;
44 virtual void unserialize(const YAML::Node& node);
45
46 virtual std::map<std::string, std::string> toMap() const;
47 virtual void fromMap(const std::map<std::string, std::string>&);
48
50 const std::string type;
51
53 const std::string id;
54
58 const std::filesystem::path path;
59
61 std::string alias {};
62
63 std::string username {};
64
66 std::string hostname {};
67
69 bool enabled {true};
70
72 bool autoAnswerEnabled {false};
73
76
78 bool sendReadReceipt {true};
79
81 bool sendComposing {true};
82
84 bool isRendezVous {false};
85
94
95 std::vector<unsigned> activeCodecs {};
96
100 bool ringtoneEnabled {true};
101
106
110 bool videoEnabled {true};
111
115 std::string displayName {};
116
120 std::string customUserAgent {};
121
125 std::string mailbox {};
126
130 bool upnpEnabled {true};
131
132 std::set<std::string> defaultModerators {};
135
139 std::string deviceKey {};
143 std::string platform {};
144
148 std::string notificationTopic {};
149
153 std::string uiCustomization {};
154};
155
156inline void
157parseString(const std::map<std::string, std::string>& details, const char* key, std::string& s)
158{
159 auto it = details.find(key);
160 if (it != details.end())
161 s = it->second;
162}
163
164inline void
165parseBool(const std::map<std::string, std::string>& details, const char* key, bool& s)
166{
167 auto it = details.find(key);
168 if (it != details.end())
169 s = it->second == TRUE_STR;
170}
171
172template<class T>
173inline void
174parseInt(const std::map<std::string, std::string>& details, const char* key, T& s)
175{
176 auto it = details.find(key);
177 if (it != details.end())
178 s = to_int<T>(it->second);
179}
180
181void parsePath(const std::map<std::string, std::string>& details,
182 const char* key,
183 std::string& s,
184 const std::filesystem::path& base);
185
186} // namespace jami
void parseBool(const std::map< std::string, std::string > &details, const char *key, bool &s)
static constexpr const char TRUE_STR[]
void emitSignal(Args... args)
Definition ring_signal.h:64
void parseInt(const std::map< std::string, std::string > &details, const char *key, T &s)
void parseString(const std::map< std::string, std::string > &details, const char *key, std::string &s)
void parsePath(const std::map< std::string, std::string > &details, const char *key, std::string &s, const std::filesystem::path &base)
constexpr const char *const DEFAULT_RINGTONE_PATH
std::string platform
Device push notification platform.
std::vector< unsigned > activeCodecs
std::string deviceKey
Device push notification token.
bool ringtoneEnabled
Play ringtone when receiving a call.
bool enabled
True if the account is enabled.
std::string alias
A user-defined name for this account.
std::string hostname
SIP hostname (SIP account) or DHT bootstrap nodes (Jami account)
AccountConfig(const std::string &type_, const std::string &id_, const std::filesystem::path &path_={})
bool autoAnswerEnabled
If true, automatically answer calls to this account.
std::set< std::string > defaultModerators
bool denySecondCallEnabled
If true, automatically deny new calls when already in one call to this account.
virtual void fromMap(const std::map< std::string, std::string > &)
const std::string type
Account type.
virtual std::map< std::string, std::string > toMap() const
int activeCallLimit
The number of concurrent calls for the account -1: Unlimited 0: Do not disturb 1: Single call +: Mult...
bool upnpEnabled
UPnP IGD controller and the mutex to access it.
virtual void serialize(YAML::Emitter &out) const =0
std::string uiCustomization
information about the customization of ui
std::string mailbox
Account mail box.
bool sendReadReceipt
If true, send displayed status (and emit to the client)
std::string notificationTopic
Push notification topic.
const std::filesystem::path path
Path where the configuration file is stored.
void serializeDiff(YAML::Emitter &out, const AccountConfig &def) const
bool isRendezVous
If true mix calls into a conference.
std::string displayName
Display name when calling.
std::string ringtonePath
Ringtone file used for this account.
bool videoEnabled
Allows user to temporarily disable video calling.
std::string customUserAgent
User-agent used for registration.
virtual void unserialize(const YAML::Node &node)
bool sendComposing
If true, send composing status (and emit to the client)
const std::string id
Account id.