configurationmanager_interface.h 12.5 KB
Newer Older
1
/*
2
 *  Copyright (C) 2004-2016 Savoir-faire Linux Inc.
Guillaume Roguez's avatar
Guillaume Roguez committed
3
 *
4
5
6
7
8
 *  Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>
 *  Author: Alexandre Bourget <alexandre.bourget@savoirfairelinux.com>
 *  Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
 *  Author: Guillaume Carmel-Archambault <guillaume.carmel-archambault@savoirfairelinux.com>
 *  Author: Guillaume Roguez <Guillaume.Roguez@savoirfairelinux.com>
9
 *  Author: Adrien Béraud <adrien.beraud@savoirfairelinux.com>
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
 */

26
#pragma once
27
28
29

#include <vector>
#include <map>
30
#include <memory>
31
#include <string>
32
#include <cstdint>
33
34

#include "dring.h"
35
#include "security_const.h"
36
37
38
39
40
41
42
43

namespace DRing {

void registerConfHandlers(const std::map<std::string, std::shared_ptr<CallbackWrapperBase>>&);

std::map<std::string, std::string> getAccountDetails(const std::string& accountID);
std::map<std::string, std::string> getVolatileAccountDetails(const std::string& accountID);
void setAccountDetails(const std::string& accountID, const std::map<std::string, std::string>& details);
44
std::map<std::string, std::string> testAccountICEInitialization(const std::string& accountID);
45
void setAccountActive(const std::string& accountID, bool active);
46
std::map<std::string, std::string> getAccountTemplate(const std::string& accountType);
47
std::string addAccount(const std::map<std::string, std::string>& details);
48
bool exportOnRing(const std::string& accountID, const std::string& password);
49
std::map<std::string, std::string> getKnownRingDevices(const std::string& accountID);
50

51
52
53
54
bool lookupName(const std::string& account, const std::string& nameserver, const std::string& name);
bool lookupAddress(const std::string& account, const std::string& nameserver, const std::string& address);
bool registerName(const std::string& account, const std::string& password, const std::string& name);

55
void removeAccount(const std::string& accountID);
56
void setAccountEnabled(const std::string& accountID, bool enable);
57
std::vector<std::string> getAccountList();
58
void sendRegister(const std::string& accountID, bool enable);
59
void registerAllAccounts(void);
Adrien Béraud's avatar
Adrien Béraud committed
60
uint64_t sendAccountTextMessage(const std::string& accountID, const std::string& to, const std::map<std::string, std::string>& payloads);
Edric Milaret's avatar
Edric Milaret committed
61
int getMessageStatus(uint64_t id);
62

63

64
65
std::map<std::string, std::string> getTlsDefaultSettings();

Eloi Bail's avatar
Eloi Bail committed
66
std::vector<unsigned> getCodecList();
67
68
std::vector<std::string> getSupportedTlsMethod();
std::vector<std::string> getSupportedCiphers(const std::string& accountID);
Eloi Bail's avatar
Eloi Bail committed
69
std::map<std::string, std::string> getCodecDetails(const std::string& accountID, const unsigned& codecId);
70
bool setCodecDetails(const std::string& accountID, const unsigned& codecId, const std::map<std::string, std::string>& details);
Eloi Bail's avatar
Eloi Bail committed
71
std::vector<unsigned> getActiveCodecList(const std::string& accountID);
72

Eloi Bail's avatar
Eloi Bail committed
73
void setActiveCodecList(const std::string& accountID, const std::vector<unsigned>& list);
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98

std::vector<std::string> getAudioPluginList();
void setAudioPlugin(const std::string& audioPlugin);
std::vector<std::string> getAudioOutputDeviceList();
void setAudioOutputDevice(int32_t index);
void setAudioInputDevice(int32_t index);
void setAudioRingtoneDevice(int32_t index);
std::vector<std::string> getAudioInputDeviceList();
std::vector<std::string> getCurrentAudioDevicesIndex();
int32_t getAudioInputDeviceIndex(const std::string& name);
int32_t getAudioOutputDeviceIndex(const std::string& name);
std::string getCurrentAudioOutputPlugin();
bool getNoiseSuppressState();
void setNoiseSuppressState(bool state);

bool isAgcEnabled();
void setAgcState(bool enabled);

void muteDtmf(bool mute);
bool isDtmfMuted();

bool isCaptureMuted();
void muteCapture(bool mute);
bool isPlaybackMuted();
void mutePlayback(bool mute);
99
100
bool isRingtoneMuted();
void muteRingtone(bool mute);
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120

std::string getAudioManager();
bool setAudioManager(const std::string& api);

std::string getRecordPath();
void setRecordPath(const std::string& recPath);
bool getIsAlwaysRecording();
void setIsAlwaysRecording(bool rec);

void setHistoryLimit(int32_t days);
int32_t getHistoryLimit();

void setAccountsOrder(const std::string& order);

std::map<std::string, std::string> getHookSettings();
void setHookSettings(const std::map<std::string, std::string>& settings);

std::vector<std::map<std::string, std::string>> getCredentials(const std::string& accountID);
void setCredentials(const std::string& accountID, const std::vector<std::map<std::string, std::string>>& details);

Adrien Béraud's avatar
Adrien Béraud committed
121
std::string getAddrFromInterfaceName(const std::string& iface);
122
123
124
125
126
127
128
129
130
131
132
133
134

std::vector<std::string> getAllIpInterface();
std::vector<std::string> getAllIpInterfaceByName();

std::map<std::string, std::string> getShortcuts();
void setShortcuts(const std::map<std::string, std::string> &shortcutsMap);

void setVolume(const std::string& device, double value);
double getVolume(const std::string& device);

/*
 * Security
 */
135
std::map<std::string, std::string> validateCertificate(const std::string& accountId, const std::string& certificate);
136
std::map<std::string, std::string> validateCertificatePath(const std::string& accountId,
137
    const std::string& certificatePath, const std::string& privateKey, const std::string& privateKeyPassword, const std::string& caList);
138

139
std::map<std::string, std::string> getCertificateDetails(const std::string& certificate);
140
std::map<std::string, std::string> getCertificateDetailsPath(const std::string& certificatePath, const std::string& privateKey, const std::string& privateKeyPassword);
141

142
143
std::vector<std::string> getPinnedCertificates();

144
std::vector<std::string> pinCertificate(const std::vector<uint8_t>& certificate, bool local);
145
146
147
148
149
150
151
152
153
154
155
156
157
158
bool unpinCertificate(const std::string& certId);

void pinCertificatePath(const std::string& path);
unsigned unpinCertificatePath(const std::string& path);

bool pinRemoteCertificate(const std::string& accountId, const std::string& certId);
bool setCertificateStatus(const std::string& account, const std::string& certId, const std::string& status);
std::vector<std::string> getCertificatesByStatus(const std::string& account, const std::string& status);

/* contact requests */
std::map<std::string, std::string> getTrustRequests(const std::string& accountId);
bool acceptTrustRequest(const std::string& accountId, const std::string& from);
bool discardTrustRequest(const std::string& accountId, const std::string& from);

159
void sendTrustRequest(const std::string& accountId, const std::string& to, const std::vector<uint8_t>& payload = {});
160

161
162
163
164
165
166
/*
 * Import/Export accounts
 */
int exportAccounts(std::vector<std::string> accountIDs, std::string filepath, std::string password);
int importAccounts(std::string archivePath, std::string password);

167
168
169
170
171
/*
 * Network connectivity
 */
void connectivityChanged();

Adrien Béraud's avatar
Adrien Béraud committed
172
173
struct AudioSignal {
        struct DeviceEvent {
174
                constexpr static const char* name = "audioDeviceEvent";
Adrien Béraud's avatar
Adrien Béraud committed
175
176
177
178
                using cb_type = void(void);
        };
};

Guillaume Roguez's avatar
Guillaume Roguez committed
179
180
181
182
183
184
185
186
187
188
// Configuration signal type definitions
struct ConfigurationSignal {
        struct VolumeChanged {
                constexpr static const char* name = "VolumeChanged";
                using cb_type = void(const std::string& /*device*/, double /*value*/);
        };
        struct AccountsChanged {
                constexpr static const char* name = "AccountsChanged";
                using cb_type = void(void);
        };
189
190
191
192
193
194
        struct Error {
                constexpr static const char* name = "Error";
                using cb_type = void(int /*alert*/);
        };

        // TODO: move those to AccountSignal in next API breakage
Guillaume Roguez's avatar
Guillaume Roguez committed
195
196
197
198
199
200
        struct StunStatusFailed {
                constexpr static const char* name = "StunStatusFailed";
                using cb_type = void(const std::string& /*account_id*/);
        };
        struct RegistrationStateChanged {
                constexpr static const char* name = "RegistrationStateChanged";
201
                using cb_type = void(const std::string& /*account_id*/, const std::string& /*state*/, int /*detailsCode*/, const std::string& /*detailsStr*/);
Guillaume Roguez's avatar
Guillaume Roguez committed
202
203
204
205
206
        };
        struct VolatileDetailsChanged {
                constexpr static const char* name = "VolatileDetailsChanged";
                using cb_type = void(const std::string& /*account_id*/, const std::map<std::string, std::string>& /* details */);
        };
207
208
        struct IncomingAccountMessage {
                constexpr static const char* name = "IncomingAccountMessage";
209
                using cb_type = void(const std::string& /*account_id*/, const std::string& /*from*/, const std::map<std::string, std::string>& /*payloads*/);
Guillaume Roguez's avatar
Guillaume Roguez committed
210
        };
Edric Milaret's avatar
Edric Milaret committed
211
212
213
        struct AccountMessageStatusChanged {
                constexpr static const char* name = "AccountMessageStatusChanged";
                using cb_type = void(const std::string& /*account_id*/, uint64_t /*message_id*/, const std::string& /*to*/, int /*state*/);
Adrien Béraud's avatar
Adrien Béraud committed
214
        };
215
216
        struct IncomingTrustRequest {
                constexpr static const char* name = "IncomingTrustRequest";
217
                using cb_type = void(const std::string& /*account_id*/, const std::string& /*from*/, const std::vector<uint8_t>& payload, time_t received);
218
        };
219
220
221
222
        struct ExportOnRingEnded {
                constexpr static const char* name = "ExportOnRingEnded";
                using cb_type = void(const std::string& /*account_id*/, int state, const std::string& pin);
        };
223
224
225
226
        struct NameRegistrationEnded {
                constexpr static const char* name = "NameRegistrationEnded";
                using cb_type = void(const std::string& /*account_id*/, int state, const std::string& name);
        };
227
228
229
230
        struct KnownDevicesChanged {
                constexpr static const char* name = "KnownDevicesChanged";
                using cb_type = void(const std::string& /*account_id*/, const std::map<std::string, std::string>& devices);
        };
231
232
233
234
        struct RegisteredNameFound {
                constexpr static const char* name = "RegisteredNameFound";
                using cb_type = void(const std::string& /*account_id*/, int state, const std::string& /*address*/, const std::string& /*name*/);
        };
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
        struct CertificatePinned {
                constexpr static const char* name = "CertificatePinned";
                using cb_type = void(const std::string& /*certId*/);
        };
        struct CertificatePathPinned {
                constexpr static const char* name = "CertificatePathPinned";
                using cb_type = void(const std::string& /*path*/, const std::vector<std::string>& /*certId*/);
        };
        struct CertificateExpired {
                constexpr static const char* name = "CertificateExpired";
                using cb_type = void(const std::string& /*certId*/);
        };
        struct CertificateStateChanged {
                constexpr static const char* name = "CertificateStateChanged";
                using cb_type = void(const std::string& /*account_id*/, const std::string& /*certId*/, const std::string& /*state*/);
        };
251
252
253
254
        struct MediaParametersChanged {
                constexpr static const char* name = "MediaParametersChanged";
                using cb_type = void(const std::string& /*accountId*/);
        };
255
#ifdef __ANDROID__
256
257
258
259
        /**
         * These are special getters for Android so the daemon can retreive
         * some informations only accessible through Java APIs
         */
260
261
262
263
        struct GetHardwareAudioFormat {
                constexpr static const char* name = "GetHardwareAudioFormat";
                using cb_type = void(std::vector<int32_t>* /* params_ret */);
        };
264
265
266
267
        struct GetAppDataPath {
                constexpr static const char* name = "GetAppDataPath";
                using cb_type = void(const std::string& name, std::vector<std::string>* /* path_ret */);
        };
268
#endif
Guillaume Roguez's avatar
Guillaume Roguez committed
269
270
};

271
272
273
274
275
276
277
278
// Can be used when a client's stdout is not available
struct DebugSignal {
    struct MessageSend {
        constexpr static const char* name = "MessageSend";
        using cb_type = void(const std::string&);
    };
};

279
} // namespace DRing