preferences.h 16.3 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
35
 *  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"

36
// general preferences
37
38
39
40
41
42
43
44
45
46
47
static const char * const orderKey = "order";
static const char * const audioApiKey = "audioApi";
static const char * const historyLimitKey = "historyLimit";
static const char * const historyMaxCallsKey = "historyMaxCalls";
static const char * const  notifyMailsKey = "notifyMails";
static const char * const zoneToneChoiceKey = "zoneToneChoice";
static const char * const registrationExpireKey = "registrationExpire";
static const char * const portNumKey = "portNum";
static const char * const searchBarDisplayKey = "searchBarDisplay";
static const char * const zeroConfenableKey = "zeroConfenable";
static const char * const md5HashKey = "md5Hash";
48

49
// voip preferences
50
51
52
53
54
static const char * const playDtmfKey = "playDtmf";
static const char * const playTonesKey = "playTones";
static const char * const pulseLengthKey = "pulseLength";
static const char * const symmetricRtpKey = "symmetric";
static const char * const zidFileKey = "zidFile";
Alexandre Savard's avatar
Alexandre Savard committed
55

56
// addressbook preferences
57
58
59
60
61
62
63
static const char * const photoKey = "photo";
static const char * const enabledKey = "enabled";
static const char * const listKey = "list";
static const char * const maxResultsKey = "maxResults";
static const char * const businessKey = "business";
static const char * const homeKey = "home";
static const char * const mobileKey = "mobile";
64
65

// hooks preferences
66
67
68
69
70
71
static const char * const iax2EnabledKey = "iax2Enabled";
static const char * const numberAddPrefixKey = "numberAddPrefix";
static const char * const numberEnabledKey = "numberEnabled";
static const char * const sipEnabledKey = "sipEnabled";
static const char * const urlCommandKey = "urlCommand";
static const char * const urlSipFieldKey = "urlSipField";
72

73
// audio preferences
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
static const char * const alsamapKey = "alsa";
static const char * const pulsemapKey = "pulse";
static const char * const cardinKey = "cardIn";
static const char * const cardoutKey = "cardOut";
static const char * const cardringKey = "cardRing";
static const char * const pluginKey = "plugin";
static const char * const smplrateKey = "smplRate";
static const char * const devicePlaybackKey = "devicePlayback";
static const char * const deviceRecordKey = "deviceRecord";
static const char * const deviceRingtoneKey = "deviceRingtone";
static const char * const recordpathKey = "recordPath";
static const char * const alwaysRecordingKey = "alwaysRecording";
static const char * const volumemicKey = "volumeMic";
static const char * const volumespkrKey = "volumeSpkr";
static const char * const noiseReduceKey = "noiseReduce";
static const char * const echoCancelKey = "echoCancel";
static const char * const echoTailKey = "echoTailLength";
static const char * const echoDelayKey = "echoDelayLength";
Alexandre Savard's avatar
Alexandre Savard committed
92

93
// shortcut preferences
94
95
96
97
98
static const char * const hangupShortKey = "hangUp";
static const char * const pickupShortKey = "pickUp";
static const char * const popupShortKey = "popupWindow";
static const char * const toggleHoldShortKey = "toggleHold";
static const char * const togglePickupHangupShortKey = "togglePickupHangup";
Julien Bonjean's avatar
Julien Bonjean committed
99

100
class AudioLayer;
Julien Bonjean's avatar
Julien Bonjean committed
101
102
103
104
105
106

class Preferences : public Serializable
{

    public:

107
108
        static const char * const DFT_ZONE;

Julien Bonjean's avatar
Julien Bonjean committed
109
110
111
112
113
114
115
        Preferences();

        virtual void serialize (Conf::YamlEmitter *emitter);

        virtual void unserialize (Conf::MappingNode *map);


116
        std::string getAccountOrder (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
117
118
            return _accountOrder;
        }
119
        void setAccountOrder (const std::string &ord) {
Julien Bonjean's avatar
Julien Bonjean committed
120
121
122
            _accountOrder = ord;
        }

123
        int getHistoryLimit (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
124
125
126
127
128
129
            return _historyLimit;
        }
        void setHistoryLimit (int lim) {
            _historyLimit = lim;
        }

130
        int getHistoryMaxCalls (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
131
132
133
134
135
136
            return _historyMaxCalls;
        }
        void setHistoryMaxCalls (int max) {
            _historyMaxCalls = max;
        }

137
        bool getNotifyMails (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
138
139
140
141
142
143
            return _notifyMails;
        }
        void setNotifyMails (bool mails) {
            _notifyMails = mails;
        }

144
        std::string getZoneToneChoice (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
145
146
            return _zoneToneChoice;
        }
147
        void setZoneToneChoice (const std::string &str) {
Julien Bonjean's avatar
Julien Bonjean committed
148
149
150
            _zoneToneChoice = str;
        }

151
        int getRegistrationExpire (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
152
153
154
155
156
157
            return _registrationExpire;
        }
        void setRegistrationExpire (int exp) {
            _registrationExpire = exp;
        }

158
        int getPortNum (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
159
160
161
162
163
164
            return _portNum;
        }
        void setPortNum (int port) {
            _portNum = port;
        }

165
        bool getSearchBarDisplay (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
166
167
168
169
170
171
            return _searchBarDisplay;
        }
        void setSearchBarDisplay (bool search) {
            _searchBarDisplay = search;
        }

172
        bool getZeroConfenable (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
173
174
175
176
177
178
            return _zeroConfenable;
        }
        void setZeroConfenable (bool enable) {
            _zeroConfenable = enable;
        }

179
        bool getMd5Hash (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
            return _md5Hash;
        }
        void setMd5Hash (bool md5) {
            _md5Hash = md5;
        }

    private:

        // account order
        std::string _accountOrder;

        int _historyLimit;
        int _historyMaxCalls;
        bool _notifyMails;
        std::string _zoneToneChoice;
        int _registrationExpire;
        int _portNum;
        bool _searchBarDisplay;
        bool _zeroConfenable;
        bool _md5Hash;
200
201
202

};

Alexandre Savard's avatar
Alexandre Savard committed
203

Julien Bonjean's avatar
Julien Bonjean committed
204
205
206
207
class VoipPreference : public Serializable
{
    public:
        VoipPreference();
Alexandre Savard's avatar
Alexandre Savard committed
208

Julien Bonjean's avatar
Julien Bonjean committed
209
        virtual void serialize (Conf::YamlEmitter *emitter);
Alexandre Savard's avatar
Alexandre Savard committed
210

Julien Bonjean's avatar
Julien Bonjean committed
211
        virtual void unserialize (Conf::MappingNode *map);
Alexandre Savard's avatar
Alexandre Savard committed
212

213
        bool getPlayDtmf (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
214
215
216
217
218
            return _playDtmf;
        }
        void setPlayDtmf (bool dtmf) {
            _playDtmf = dtmf;
        }
Alexandre Savard's avatar
Alexandre Savard committed
219

220
        bool getPlayTones (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
221
222
223
224
225
            return _playTones;
        }
        void setPlayTones (bool tone) {
            _playTones = tone;
        }
Alexandre Savard's avatar
Alexandre Savard committed
226

227
        int getPulseLength (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
228
229
230
231
232
            return _pulseLength;
        }
        void setPulseLength (int length) {
            _pulseLength = length;
        }
Alexandre Savard's avatar
Alexandre Savard committed
233

234
        bool getSymmetricRtp (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
235
236
237
238
239
            return _symmetricRtp;
        }
        void setSymmetricRtp (bool sym) {
            _symmetricRtp = sym;
        }
Alexandre Savard's avatar
Alexandre Savard committed
240

241
        std::string getZidFile (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
242
243
            return _zidFile;
        }
244
        void setZidFile (const std::string &file) {
Julien Bonjean's avatar
Julien Bonjean committed
245
246
            _zidFile = file;
        }
Alexandre Savard's avatar
Alexandre Savard committed
247

Julien Bonjean's avatar
Julien Bonjean committed
248
    private:
Alexandre Savard's avatar
Alexandre Savard committed
249

Julien Bonjean's avatar
Julien Bonjean committed
250
251
252
253
254
        bool _playDtmf;
        bool _playTones;
        int _pulseLength;
        bool _symmetricRtp;
        std::string _zidFile;
Alexandre Savard's avatar
Alexandre Savard committed
255
256
257

};

Julien Bonjean's avatar
Julien Bonjean committed
258
259
260
261
262
263
264
265
266
class AddressbookPreference : public Serializable
{
    public:
        AddressbookPreference();

        virtual void serialize (Conf::YamlEmitter *emitter);

        virtual void unserialize (Conf::MappingNode *map);

267
        bool getPhoto (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
268
269
270
271
272
273
            return _photo;
        }
        void setPhoto (bool p) {
            _photo = p;
        }

274
        bool getEnabled (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
275
276
277
278
279
280
            return _enabled;
        }
        void setEnabled (bool e) {
            _enabled = e;
        }

281
        std::string getList (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
282
283
            return _list;
        }
284
        void setList (const std::string &l) {
Julien Bonjean's avatar
Julien Bonjean committed
285
286
287
            _list = l;
        }

288
        int getMaxResults (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
289
290
291
292
293
294
            return _maxResults;
        }
        void setMaxResults (int r) {
            _maxResults = r;
        }

295
        bool getBusiness (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
296
297
298
299
300
301
            return _business;
        }
        void setBusiness (bool b) {
            _business = b;
        }

302
        bool getHome (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
303
304
305
306
307
308
            return _home;
        }
        void setHone (bool h) {
            _home = h;
        }

309
        bool getMobile (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
            return _mobile;
        }
        void setMobile (bool m) {
            _mobile = m;
        }

    private:

        bool _photo;
        bool _enabled;
        std::string _list;
        int _maxResults;
        bool _business;
        bool _home;
        bool _mobile;
325
326
327
328

};


Julien Bonjean's avatar
Julien Bonjean committed
329
330
331
332
class HookPreference : public Serializable
{
    public:
        HookPreference();
333

Julien Bonjean's avatar
Julien Bonjean committed
334
        virtual void serialize (Conf::YamlEmitter *emitter);
335

Julien Bonjean's avatar
Julien Bonjean committed
336
        virtual void unserialize (Conf::MappingNode *map);
337

338
        bool getIax2Enabled (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
339
340
341
342
343
            return _iax2Enabled;
        }
        void setIax2Enabled (bool i) {
            _iax2Enabled = i;
        }
344

345
        std::string getNumberAddPrefix (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
346
347
            return _numberAddPrefix;
        }
348
        void setNumberAddPrefix (const std::string &n) {
Julien Bonjean's avatar
Julien Bonjean committed
349
350
            _numberAddPrefix = n;
        }
351

352
        bool getNumberEnabled (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
353
354
355
356
357
            return _numberEnabled;
        }
        void setNumberEnabled (bool n) {
            _numberEnabled = n;
        }
358

359
        bool getSipEnabled (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
360
361
362
363
364
            return _sipEnabled;
        }
        void setSipEnabled (bool s) {
            _sipEnabled = s;
        }
365

366
        std::string getUrlCommand (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
367
368
            return _urlCommand;
        }
369
        void setUrlCommand (const std::string &u) {
Julien Bonjean's avatar
Julien Bonjean committed
370
371
            _urlCommand = u;
        }
372

373
        std::string getUrlSipField (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
374
375
            return _urlSipField;
        }
376
        void setUrlSipField (const std::string &u) {
Julien Bonjean's avatar
Julien Bonjean committed
377
378
            _urlSipField = u;
        }
379

Julien Bonjean's avatar
Julien Bonjean committed
380
381
382
383
384
385
386
    private:
        bool _iax2Enabled;// :		false
        std::string _numberAddPrefix;//:	false
        bool _numberEnabled; //:	false
        bool _sipEnabled; //:		false
        std::string _urlCommand; //:		x-www-browser
        std::string _urlSipField; //:		X-sflphone-url
387
388
389

};

Julien Bonjean's avatar
Julien Bonjean committed
390
391
392
393
class AudioPreference : public Serializable
{
    public:
        AudioPreference();
394
395
396
397
398
399
400
401
402
403
        AudioLayer *createAudioLayer();
        AudioLayer *switchAndCreateAudioLayer();

        std::string getAudioApi (void) const {
            return _audioApi;
        }

        void setAudioApi (const std::string &api) {
            _audioApi = api;
        }
Julien Bonjean's avatar
Julien Bonjean committed
404
405
406
407
408
        virtual void serialize (Conf::YamlEmitter *emitter);

        virtual void unserialize (Conf::MappingNode *map);

        // alsa preference
409
        int getCardin (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
410
411
412
413
414
415
            return _cardin;
        }
        void setCardin (int c) {
            _cardin = c;
        }

416
        int getCardout (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
417
418
419
420
421
422
            return _cardout;
        }
        void setCardout (int c) {
            _cardout = c;
        }

423
        int getCardring (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
424
425
426
427
428
429
            return _cardring;
        }
        void setCardring (int c) {
            _cardring = c;
        }

430
        std::string getPlugin (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
431
432
            return _plugin;
        }
433
434

        void setPlugin (const std::string &p) {
Julien Bonjean's avatar
Julien Bonjean committed
435
436
437
            _plugin = p;
        }

438
        int getSmplrate (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
439
440
441
442
443
444
445
            return _smplrate;
        }
        void setSmplrate (int r) {
            _smplrate = r;
        }

        //pulseaudio preference
446
        std::string getDevicePlayback (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
447
448
            return _devicePlayback;
        }
449

450
        void setDevicePlayback (const std::string &p) {
Julien Bonjean's avatar
Julien Bonjean committed
451
452
453
            _devicePlayback = p;
        }

454
        std::string getDeviceRecord (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
455
456
            return _deviceRecord;
        }
457
        void setDeviceRecord (const std::string &r) {
Julien Bonjean's avatar
Julien Bonjean committed
458
459
460
            _deviceRecord = r;
        }

461
        std::string getDeviceRingtone (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
462
463
            return _deviceRingtone;
        }
464
465

        void setDeviceRingtone (const std::string &r) {
Julien Bonjean's avatar
Julien Bonjean committed
466
467
468
469
            _deviceRingtone = r;
        }

        // general preference
470
        std::string getRecordpath (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
471
472
            return _recordpath;
        }
473
        void setRecordpath (const std::string &r) {
Julien Bonjean's avatar
Julien Bonjean committed
474
475
476
            _recordpath = r;
        }

477
        bool getIsAlwaysRecording(void) const {
478
479
480
481
482
483
484
        	return _alwaysRecording;
        }

        void setIsAlwaysRecording(bool rec) {
        	_alwaysRecording = rec;
        }

485
        int getVolumemic (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
486
487
488
489
490
491
            return _volumemic;
        }
        void setVolumemic (int m) {
            _volumemic = m;
        }

492
        int getVolumespkr (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
493
494
495
496
497
498
            return _volumespkr;
        }
        void setVolumespkr (int s) {
            _volumespkr = s;
        }

499
        bool getNoiseReduce (void) const {
500
501
502
503
504
505
506
            return _noisereduce;
        }

        void setNoiseReduce (bool noise) {
            _noisereduce = noise;
        }

507
        bool getEchoCancel(void) const {
508
509
510
511
512
513
514
        	return _echocancel;
        }

        void setEchoCancel(bool echo) {
        	_echocancel = echo;
        }

515
        int getEchoCancelTailLength(void) const {
516
517
518
519
520
521
522
        	return _echoCancelTailLength;
        }

        void setEchoCancelTailLength(int length) {
        	_echoCancelTailLength = length;
        }

523
        int getEchoCancelDelay(void) const {
524
525
526
527
528
529
530
        	return _echoCancelDelay;
        }

        void setEchoCancelDelay(int delay) {
        	_echoCancelDelay = delay;
        }

Julien Bonjean's avatar
Julien Bonjean committed
531
    private:
532
        std::string _audioApi;
Julien Bonjean's avatar
Julien Bonjean committed
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547

        // alsa preference
        int _cardin; // 0
        int _cardout; // 0
        int _cardring;// 0
        std::string _plugin; // default
        int _smplrate;// 44100

        //pulseaudio preference
        std::string _devicePlayback;//:
        std::string _deviceRecord; //:
        std::string _deviceRingtone; //:

        // general preference
        std::string _recordpath; //: /home/msavard/Bureau
548
        bool _alwaysRecording;
Julien Bonjean's avatar
Julien Bonjean committed
549
550
551
        int _volumemic; //:  100
        int _volumespkr; //: 100

552
        bool _noisereduce;
553
554
555
        bool _echocancel;
        int _echoCancelTailLength;
        int _echoCancelDelay;
556
557
};

Julien Bonjean's avatar
Julien Bonjean committed
558
559
560
561
562
class ShortcutPreferences : public Serializable
{
    public:
        virtual void serialize (Conf::YamlEmitter *emitter);
        virtual void unserialize (Conf::MappingNode *map);
563

564
565
        void setShortcuts (std::map<std::string, std::string> shortcuts);
        std::map<std::string, std::string> getShortcuts (void) const;
566

567
        std::string getHangup (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
568
569
            return _hangup;
        }
570
        void setHangup (const std::string &hangup) {
Julien Bonjean's avatar
Julien Bonjean committed
571
572
            _hangup = hangup;
        }
573

574
        std::string getPickup (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
575
576
            return _pickup;
        }
577
        void setPickup (const std::string &pickup) {
Julien Bonjean's avatar
Julien Bonjean committed
578
579
            _pickup = pickup;
        }
580

581
        std::string getPopup (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
582
583
            return _popup;
        }
584
        void setPopup (const std::string &popup) {
Julien Bonjean's avatar
Julien Bonjean committed
585
586
            _popup = popup;
        }
587

588
        std::string getToggleHold (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
589
590
591
592
593
            return _toggleHold;
        }
        void setToggleHold (std::string hold) {
            _toggleHold = hold;
        }
594

595
        std::string getTogglePickupHangup (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
596
597
            return _togglePickupHangup;
        }
598
        void setTogglePickupHangup (const std::string &toggle) {
Julien Bonjean's avatar
Julien Bonjean committed
599
600
            _togglePickupHangup = toggle;
        }
601

Julien Bonjean's avatar
Julien Bonjean committed
602
603
604
605
606
607
    private:
        std::string _hangup;
        std::string _pickup;
        std::string _popup;
        std::string _toggleHold;
        std::string _togglePickupHangup;
608
609
};

610
#endif