preferences.h 12.4 KB
Newer Older
1
/*
2
 *  Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010, 2011 Savoir-Faire Linux Inc.
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
 *  Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
 *
 *  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., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *  Additional permission under GNU GPL version 3 section 7:
 *
 *  If you modify this program, or any covered work, by linking or
 *  combining it with the OpenSSL project's OpenSSL library (or a
 *  modified version of that library), containing parts covered by the
 *  terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
 *  grants you additional permission to convey the resulting work.
 *  Corresponding Source for a non-source form of such a combination
 *  shall include the source code for the parts of OpenSSL used as well
 *  as that of the covered work.
 */

#ifndef __PREFERENCE_H__
#define __PREFERENCE_H__

#include "config/serializable.h"
35
36
#include <string>
#include <map>
37

38
class AudioLayer;
Julien Bonjean's avatar
Julien Bonjean committed
39

40
class Preferences : public Serializable {
Julien Bonjean's avatar
Julien Bonjean committed
41
    public:
42
        static const char * const DFT_ZONE;
43
        static const char * const REGISTRATION_EXPIRE_KEY;
44

Julien Bonjean's avatar
Julien Bonjean committed
45
46
        Preferences();

47
48
        virtual void serialize(Conf::YamlEmitter &emitter);
        virtual void unserialize(const Conf::MappingNode &map);
Julien Bonjean's avatar
Julien Bonjean committed
49

50
51
        std::string getAccountOrder() const {
            return accountOrder_;
Julien Bonjean's avatar
Julien Bonjean committed
52
        }
53

54
        void setAccountOrder(const std::string &ord) {
55
            accountOrder_ = ord;
Julien Bonjean's avatar
Julien Bonjean committed
56
57
        }

58
59
        int getHistoryLimit() const {
            return historyLimit_;
Julien Bonjean's avatar
Julien Bonjean committed
60
        }
61

62
        void setHistoryLimit(int lim) {
63
            historyLimit_ = lim;
Julien Bonjean's avatar
Julien Bonjean committed
64
65
        }

66
67
        int getHistoryMaxCalls() const {
            return historyMaxCalls_;
Julien Bonjean's avatar
Julien Bonjean committed
68
        }
69

70
        void setHistoryMaxCalls(int max) {
71
            historyMaxCalls_ = max;
Julien Bonjean's avatar
Julien Bonjean committed
72
73
        }

74
75
        bool getNotifyMails() const {
            return notifyMails_;
Julien Bonjean's avatar
Julien Bonjean committed
76
        }
77

78
        void setNotifyMails(bool mails) {
79
            notifyMails_ = mails;
Julien Bonjean's avatar
Julien Bonjean committed
80
81
        }

82
83
        std::string getZoneToneChoice() const {
            return zoneToneChoice_;
Julien Bonjean's avatar
Julien Bonjean committed
84
        }
85

86
        void setZoneToneChoice(const std::string &str) {
87
            zoneToneChoice_ = str;
Julien Bonjean's avatar
Julien Bonjean committed
88
89
        }

90
91
        int getRegistrationExpire() const {
            return registrationExpire_;
Julien Bonjean's avatar
Julien Bonjean committed
92
        }
93

94
        void setRegistrationExpire(int exp) {
95
            registrationExpire_ = exp;
Julien Bonjean's avatar
Julien Bonjean committed
96
97
        }

98
99
        int getPortNum() const {
            return portNum_;
Julien Bonjean's avatar
Julien Bonjean committed
100
        }
101

102
        void setPortNum(int port) {
103
            portNum_ = port;
Julien Bonjean's avatar
Julien Bonjean committed
104
105
        }

106
107
        bool getSearchBarDisplay() const {
            return searchBarDisplay_;
Julien Bonjean's avatar
Julien Bonjean committed
108
        }
109

110
        void setSearchBarDisplay(bool search) {
111
            searchBarDisplay_ = search;
Julien Bonjean's avatar
Julien Bonjean committed
112
113
        }

114
115
        bool getZeroConfenable() const {
            return zeroConfenable_;
Julien Bonjean's avatar
Julien Bonjean committed
116
        }
117
        void setZeroConfenable(bool enable) {
118
            zeroConfenable_ = enable;
Julien Bonjean's avatar
Julien Bonjean committed
119
120
        }

121
122
        bool getMd5Hash() const {
            return md5Hash_;
Julien Bonjean's avatar
Julien Bonjean committed
123
        }
124
        void setMd5Hash(bool md5) {
125
            md5Hash_ = md5;
Julien Bonjean's avatar
Julien Bonjean committed
126
127
128
        }

    private:
129
130
131
132
133
134
135
136
137
138
        std::string accountOrder_;
        int historyLimit_;
        int historyMaxCalls_;
        bool notifyMails_;
        std::string zoneToneChoice_;
        int registrationExpire_;
        int portNum_;
        bool searchBarDisplay_;
        bool zeroConfenable_;
        bool md5Hash_;
139
140
};

141
class VoipPreference : public Serializable {
Julien Bonjean's avatar
Julien Bonjean committed
142
143
    public:
        VoipPreference();
Alexandre Savard's avatar
Alexandre Savard committed
144

145
146
        virtual void serialize(Conf::YamlEmitter &emitter);
        virtual void unserialize(const Conf::MappingNode &map);
Alexandre Savard's avatar
Alexandre Savard committed
147

148
149
        bool getPlayDtmf() const {
            return playDtmf_;
Julien Bonjean's avatar
Julien Bonjean committed
150
        }
151

152
        void setPlayDtmf(bool dtmf) {
153
            playDtmf_ = dtmf;
Julien Bonjean's avatar
Julien Bonjean committed
154
        }
Alexandre Savard's avatar
Alexandre Savard committed
155

156
157
        bool getPlayTones() const {
            return playTones_;
Julien Bonjean's avatar
Julien Bonjean committed
158
        }
159

160
        void setPlayTones(bool tone) {
161
            playTones_ = tone;
Julien Bonjean's avatar
Julien Bonjean committed
162
        }
Alexandre Savard's avatar
Alexandre Savard committed
163

164
165
        int getPulseLength() const {
            return pulseLength_;
Julien Bonjean's avatar
Julien Bonjean committed
166
        }
167

168
        void setPulseLength(int length) {
169
            pulseLength_ = length;
Julien Bonjean's avatar
Julien Bonjean committed
170
        }
Alexandre Savard's avatar
Alexandre Savard committed
171

172
173
        bool getSymmetricRtp() const {
            return symmetricRtp_;
Julien Bonjean's avatar
Julien Bonjean committed
174
        }
175
        void setSymmetricRtp(bool sym) {
176
            symmetricRtp_ = sym;
Julien Bonjean's avatar
Julien Bonjean committed
177
        }
Alexandre Savard's avatar
Alexandre Savard committed
178

179
180
        std::string getZidFile() const {
            return zidFile_;
Julien Bonjean's avatar
Julien Bonjean committed
181
        }
182
        void setZidFile(const std::string &file) {
183
            zidFile_ = file;
Julien Bonjean's avatar
Julien Bonjean committed
184
        }
Alexandre Savard's avatar
Alexandre Savard committed
185

Julien Bonjean's avatar
Julien Bonjean committed
186
    private:
Alexandre Savard's avatar
Alexandre Savard committed
187

188
189
190
191
192
        bool playDtmf_;
        bool playTones_;
        int pulseLength_;
        bool symmetricRtp_;
        std::string zidFile_;
Alexandre Savard's avatar
Alexandre Savard committed
193
194
};

195
class AddressbookPreference : public Serializable {
Julien Bonjean's avatar
Julien Bonjean committed
196
197
198
    public:
        AddressbookPreference();

199
200
        virtual void serialize(Conf::YamlEmitter &emitter);
        virtual void unserialize(const Conf::MappingNode &map);
Julien Bonjean's avatar
Julien Bonjean committed
201

202
203
        bool getPhoto() const {
            return photo_;
Julien Bonjean's avatar
Julien Bonjean committed
204
        }
205

206
        void setPhoto(bool p) {
207
            photo_ = p;
Julien Bonjean's avatar
Julien Bonjean committed
208
209
        }

210
211
        bool getEnabled() const {
            return enabled_;
Julien Bonjean's avatar
Julien Bonjean committed
212
        }
213

214
        void setEnabled(bool e) {
215
            enabled_ = e;
Julien Bonjean's avatar
Julien Bonjean committed
216
217
        }

218
219
        std::string getList() const {
            return list_;
Julien Bonjean's avatar
Julien Bonjean committed
220
        }
221

222
        void setList(const std::string &l) {
223
            list_ = l;
Julien Bonjean's avatar
Julien Bonjean committed
224
225
        }

226
227
        int getMaxResults() const {
            return maxResults_;
Julien Bonjean's avatar
Julien Bonjean committed
228
        }
229

230
        void setMaxResults(int r) {
231
            maxResults_ = r;
Julien Bonjean's avatar
Julien Bonjean committed
232
233
        }

234
235
        bool getBusiness() const {
            return business_;
Julien Bonjean's avatar
Julien Bonjean committed
236
        }
237

238
        void setBusiness(bool b) {
239
            business_ = b;
Julien Bonjean's avatar
Julien Bonjean committed
240
241
        }

242
243
        bool getHome() const {
            return home_;
Julien Bonjean's avatar
Julien Bonjean committed
244
        }
245
        void setHone(bool h) {
246
            home_ = h;
Julien Bonjean's avatar
Julien Bonjean committed
247
248
        }

249
250
        bool getMobile() const {
            return mobile_;
Julien Bonjean's avatar
Julien Bonjean committed
251
        }
252
        void setMobile(bool m) {
253
            mobile_ = m;
Julien Bonjean's avatar
Julien Bonjean committed
254
255
256
257
        }

    private:

258
259
260
261
262
263
264
        bool photo_;
        bool enabled_;
        std::string list_;
        int maxResults_;
        bool business_;
        bool home_;
        bool mobile_;
265
266
267
};


Tristan Matthews's avatar
Tristan Matthews committed
268
269
class pjsip_msg;

270
class HookPreference : public Serializable {
Julien Bonjean's avatar
Julien Bonjean committed
271
272
    public:
        HookPreference();
273
        HookPreference(const std::map<std::string, std::string> &settings);
274

275
276
        virtual void serialize(Conf::YamlEmitter &emitter);
        virtual void unserialize(const Conf::MappingNode &map);
277

278
        std::string getNumberAddPrefix() const {
279
280
281
282
            if (numberEnabled_)
                return numberAddPrefix_;
            else
                return "";
Julien Bonjean's avatar
Julien Bonjean committed
283
        }
284

285
        std::map<std::string, std::string> toMap() const;
Tristan Matthews's avatar
Tristan Matthews committed
286
        void runHook(pjsip_msg *msg);
287

Julien Bonjean's avatar
Julien Bonjean committed
288
    private:
289
290
291
292
293
294
        bool iax2Enabled_;
        std::string numberAddPrefix_;
        bool numberEnabled_;
        bool sipEnabled_;
        std::string urlCommand_;
        std::string urlSipField_;
295
296
};

297
class AudioPreference : public Serializable {
Julien Bonjean's avatar
Julien Bonjean committed
298
299
    public:
        AudioPreference();
300
301
302
        AudioLayer *createAudioLayer();
        AudioLayer *switchAndCreateAudioLayer();

303
304
        std::string getAudioApi() const {
            return audioApi_;
305
306
        }

307
        void setAudioApi(const std::string &api) {
308
            audioApi_ = api;
309
        }
310

311
312
        virtual void serialize(Conf::YamlEmitter &emitter);
        virtual void unserialize(const Conf::MappingNode &map);
Julien Bonjean's avatar
Julien Bonjean committed
313
314

        // alsa preference
315
316
        int getCardin() const {
            return cardin_;
Julien Bonjean's avatar
Julien Bonjean committed
317
        }
318
        void setCardin(int c) {
319
            cardin_ = c;
Julien Bonjean's avatar
Julien Bonjean committed
320
321
        }

322
323
        int getCardout() const {
            return cardout_;
Julien Bonjean's avatar
Julien Bonjean committed
324
        }
325

326
        void setCardout(int c) {
327
            cardout_ = c;
Julien Bonjean's avatar
Julien Bonjean committed
328
329
        }

330
331
        int getCardring() const {
            return cardring_;
Julien Bonjean's avatar
Julien Bonjean committed
332
        }
333

334
        void setCardring(int c) {
335
            cardring_ = c;
Julien Bonjean's avatar
Julien Bonjean committed
336
337
        }

338
339
        std::string getPlugin() const {
            return plugin_;
Julien Bonjean's avatar
Julien Bonjean committed
340
        }
341

342
        void setPlugin(const std::string &p) {
343
            plugin_ = p;
Julien Bonjean's avatar
Julien Bonjean committed
344
345
        }

346
347
        int getSmplrate() const {
            return smplrate_;
Julien Bonjean's avatar
Julien Bonjean committed
348
        }
349
        void setSmplrate(int r) {
350
            smplrate_ = r;
Julien Bonjean's avatar
Julien Bonjean committed
351
352
353
        }

        //pulseaudio preference
354
355
        std::string getDevicePlayback() const {
            return devicePlayback_;
Julien Bonjean's avatar
Julien Bonjean committed
356
        }
357

358
        void setDevicePlayback(const std::string &p) {
359
            devicePlayback_ = p;
Julien Bonjean's avatar
Julien Bonjean committed
360
361
        }

362
363
        std::string getDeviceRecord() const {
            return deviceRecord_;
Julien Bonjean's avatar
Julien Bonjean committed
364
        }
365
        void setDeviceRecord(const std::string &r) {
366
            deviceRecord_ = r;
Julien Bonjean's avatar
Julien Bonjean committed
367
368
        }

369
370
        std::string getDeviceRingtone() const {
            return deviceRingtone_;
Julien Bonjean's avatar
Julien Bonjean committed
371
        }
372

373
        void setDeviceRingtone(const std::string &r) {
374
            deviceRingtone_ = r;
Julien Bonjean's avatar
Julien Bonjean committed
375
376
377
        }

        // general preference
378
379
        std::string getRecordpath() const {
            return recordpath_;
Julien Bonjean's avatar
Julien Bonjean committed
380
        }
381
        void setRecordpath(const std::string &r) {
382
            recordpath_ = r;
Julien Bonjean's avatar
Julien Bonjean committed
383
384
        }

385
386
        bool getIsAlwaysRecording() const {
            return alwaysRecording_;
387
388
389
        }

        void setIsAlwaysRecording(bool rec) {
390
            alwaysRecording_ = rec;
391
392
        }

393
394
        int getVolumemic() const {
            return volumemic_;
Julien Bonjean's avatar
Julien Bonjean committed
395
        }
396
        void setVolumemic(int m) {
397
            volumemic_ = m;
Julien Bonjean's avatar
Julien Bonjean committed
398
399
        }

400
401
        int getVolumespkr() const {
            return volumespkr_;
Julien Bonjean's avatar
Julien Bonjean committed
402
        }
403
        void setVolumespkr(int s) {
404
            volumespkr_ = s;
Julien Bonjean's avatar
Julien Bonjean committed
405
406
        }

407
408
        bool getNoiseReduce() const {
            return noisereduce_;
409
410
        }

411
        void setNoiseReduce(bool noise) {
412
            noisereduce_ = noise;
413
414
        }

415
416
        bool getEchoCancel() const {
            return echocancel_;
417
418
419
        }

        void setEchoCancel(bool echo) {
420
            echocancel_ = echo;
421
422
        }

423
424
        int getEchoCancelTailLength() const {
            return echoCancelTailLength_;
425
426
427
        }

        void setEchoCancelTailLength(int length) {
428
            echoCancelTailLength_ = length;
429
430
        }

431
432
        int getEchoCancelDelay() const {
            return echoCancelDelay_;
433
434
435
        }

        void setEchoCancelDelay(int delay) {
436
            echoCancelDelay_ = delay;
437
438
        }

Julien Bonjean's avatar
Julien Bonjean committed
439
    private:
440
        std::string audioApi_;
Julien Bonjean's avatar
Julien Bonjean committed
441
442

        // alsa preference
443
444
445
446
447
        int cardin_;
        int cardout_;
        int cardring_;
        std::string plugin_;
        int smplrate_;
Julien Bonjean's avatar
Julien Bonjean committed
448
449

        //pulseaudio preference
450
451
452
        std::string devicePlayback_;
        std::string deviceRecord_;
        std::string deviceRingtone_;
Julien Bonjean's avatar
Julien Bonjean committed
453
454

        // general preference
455
456
457
458
459
460
461
462
463
        std::string recordpath_; //: /home/msavard/Bureau
        bool alwaysRecording_;
        int volumemic_;
        int volumespkr_;

        bool noisereduce_;
        bool echocancel_;
        int echoCancelTailLength_;
        int echoCancelDelay_;
464
465
};

466
class ShortcutPreferences : public Serializable {
Julien Bonjean's avatar
Julien Bonjean committed
467
    public:
468
        ShortcutPreferences();
469
470
        virtual void serialize(Conf::YamlEmitter &emitter);
        virtual void unserialize(const Conf::MappingNode &map);
471

472
        void setShortcuts(std::map<std::string, std::string> shortcuts);
473
        std::map<std::string, std::string> getShortcuts() const;
474

475
476
        std::string getHangup() const {
            return hangup_;
Julien Bonjean's avatar
Julien Bonjean committed
477
        }
478

479
        void setHangup(const std::string &hangup) {
480
            hangup_ = hangup;
Julien Bonjean's avatar
Julien Bonjean committed
481
        }
482

483
484
        std::string getPickup() const {
            return pickup_;
Julien Bonjean's avatar
Julien Bonjean committed
485
        }
486

487
        void setPickup(const std::string &pickup) {
488
            pickup_ = pickup;
Julien Bonjean's avatar
Julien Bonjean committed
489
        }
490

491
492
        std::string getPopup() const {
            return popup_;
Julien Bonjean's avatar
Julien Bonjean committed
493
        }
494

495
        void setPopup(const std::string &popup) {
496
            popup_ = popup;
Julien Bonjean's avatar
Julien Bonjean committed
497
        }
498

499
500
        std::string getToggleHold() const {
            return toggleHold_;
Julien Bonjean's avatar
Julien Bonjean committed
501
        }
502

503
        void setToggleHold(const std::string &hold) {
504
            toggleHold_ = hold;
Julien Bonjean's avatar
Julien Bonjean committed
505
        }
506

507
508
        std::string getTogglePickupHangup() const {
            return togglePickupHangup_;
Julien Bonjean's avatar
Julien Bonjean committed
509
        }
510

511
        void setTogglePickupHangup(const std::string &toggle) {
512
            togglePickupHangup_ = toggle;
Julien Bonjean's avatar
Julien Bonjean committed
513
        }
514

Julien Bonjean's avatar
Julien Bonjean committed
515
    private:
516
517
518
519
520
        std::string hangup_;
        std::string pickup_;
        std::string popup_;
        std::string toggleHold_;
        std::string togglePickupHangup_;
521
522
};

523
#endif