preferences.h 16.7 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
const std::string orderKey ("order");                         // :	1234/2345/
const std::string audioApiKey ("audioApi");                   // :	0
const std::string historyLimitKey ("historyLimit");           // :	30
const std::string historyMaxCallsKey ("historyMaxCalls");     // :	20
const std::string notifyMailsKey ("notifyMails");             // :	false
const std::string zoneToneChoiceKey ("zoneToneChoice");       // :	North America
const std::string registrationExpireKey ("registrationExpire");// :	180
const std::string portNumKey ("portNum");                     // :	5060
const std::string searchBarDisplayKey ("searchBarDisplay");   // :	true
const std::string zeroConfenableKey ("zeroConfenable");       // :	false
const std::string md5HashKey ("md5Hash");                     // :	false
48

49
// voip preferences
50
51
52
53
54
const std::string playDtmfKey ("playDtmf"); // true                    true
const std::string playTonesKey ("playTones"); // true
const std::string pulseLengthKey ("pulseLength"); //=250
const std::string symmetricRtpKey ("symmetric");// =true
const std::string zidFileKey ("zidFile");// =sfl.zid
Alexandre Savard's avatar
Alexandre Savard committed
55

56
// addressbook preferences
57
58
59
60
61
62
63
const std::string photoKey ("photo");//		false
const std::string enabledKey ("enabled");//		true
const std::string listKey ("list");//		1243608768.30329.0@emilou-desktop/1243456917.15690.23@emilou-desktop/
const std::string maxResultsKey ("maxResults");//		25
const std::string businessKey ("business");//		true
const std::string homeKey ("home");//		false
const std::string mobileKey ("mobile");//		false
64
65

// hooks preferences
66
67
68
69
70
71
const std::string iax2EnabledKey ("iax2Enabled");// :		false
const std::string numberAddPrefixKey ("numberAddPrefix");//:	false
const std::string numberEnabledKey ("numberEnabled"); //:	false
const std::string sipEnabledKey ("sipEnabled"); //:		false
const std::string urlCommandKey ("urlCommand"); //:		x-www-browser
const std::string urlSipFieldKey ("urlSipField"); //:		X-sflphone-url
72

73
// audio preferences
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
const std::string alsamapKey ("alsa");
const std::string pulsemapKey ("pulse");
const std::string cardinKey ("cardIn");// : 0
const std::string cardoutKey ("cardOut");// 0
const std::string cardringKey ("cardRing");// : 0
const std::string framesizeKey ("frameSize");// : 20
const std::string pluginKey ("plugin"); //: default
const std::string smplrateKey ("smplRate");//: 44100
const std::string devicePlaybackKey ("devicePlayback");//:
const std::string deviceRecordKey ("deviceRecord");// :
const std::string deviceRingtoneKey ("deviceRingtone");// :
const std::string recordpathKey ("recordPath");//: /home/msavard/Bureau
const std::string alwaysRecordingKey("alwaysRecording");
const std::string volumemicKey ("volumeMic");//:  100
const std::string volumespkrKey ("volumeSpkr");//: 100
const std::string noiseReduceKey ("noiseReduce");
const std::string echoCancelKey ("echoCancel");
const std::string echoTailKey ("echoTailLength");
const std::string echoDelayKey ("echoDelayLength");
Alexandre Savard's avatar
Alexandre Savard committed
93

94
// shortcut preferences
95
96
97
98
99
const std::string hangupShortKey ("hangUp");
const std::string pickupShortKey ("pickUp");
const std::string popupShortKey ("popupWindow");
const std::string toggleHoldShortKey ("toggleHold");
const std::string togglePickupHangupShortKey ("togglePickupHangup");
Julien Bonjean's avatar
Julien Bonjean committed
100
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
116
117
        Preferences();

        ~Preferences();

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

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


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

125
        int getAudioApi (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
126
127
128
129
130
131
            return _audioApi;
        }
        void setAudioApi (int api) {
            _audioApi = api;
        }

132
        int getHistoryLimit (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
133
134
135
136
137
138
            return _historyLimit;
        }
        void setHistoryLimit (int lim) {
            _historyLimit = lim;
        }

139
        int getHistoryMaxCalls (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
140
141
142
143
144
145
            return _historyMaxCalls;
        }
        void setHistoryMaxCalls (int max) {
            _historyMaxCalls = max;
        }

146
        bool getNotifyMails (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
147
148
149
150
151
152
            return _notifyMails;
        }
        void setNotifyMails (bool mails) {
            _notifyMails = mails;
        }

153
        std::string getZoneToneChoice (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
154
155
156
157
158
159
            return _zoneToneChoice;
        }
        void setZoneToneChoice (std::string str) {
            _zoneToneChoice = str;
        }

160
        int getRegistrationExpire (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
161
162
163
164
165
166
            return _registrationExpire;
        }
        void setRegistrationExpire (int exp) {
            _registrationExpire = exp;
        }

167
        int getPortNum (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
168
169
170
171
172
173
            return _portNum;
        }
        void setPortNum (int port) {
            _portNum = port;
        }

174
        bool getSearchBarDisplay (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
175
176
177
178
179
180
            return _searchBarDisplay;
        }
        void setSearchBarDisplay (bool search) {
            _searchBarDisplay = search;
        }

181
        bool getZeroConfenable (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
182
183
184
185
186
187
            return _zeroConfenable;
        }
        void setZeroConfenable (bool enable) {
            _zeroConfenable = enable;
        }

188
        bool getMd5Hash (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
            return _md5Hash;
        }
        void setMd5Hash (bool md5) {
            _md5Hash = md5;
        }

    private:

        // account order
        std::string _accountOrder;

        int _audioApi;
        int _historyLimit;
        int _historyMaxCalls;
        bool _notifyMails;
        std::string _zoneToneChoice;
        int _registrationExpire;
        int _portNum;
        bool _searchBarDisplay;
        bool _zeroConfenable;
        bool _md5Hash;
210
211
212

};

Alexandre Savard's avatar
Alexandre Savard committed
213

Julien Bonjean's avatar
Julien Bonjean committed
214
215
class VoipPreference : public Serializable
{
Alexandre Savard's avatar
Alexandre Savard committed
216

Julien Bonjean's avatar
Julien Bonjean committed
217
    public:
Alexandre Savard's avatar
Alexandre Savard committed
218

Julien Bonjean's avatar
Julien Bonjean committed
219
        VoipPreference();
Alexandre Savard's avatar
Alexandre Savard committed
220

Julien Bonjean's avatar
Julien Bonjean committed
221
        ~VoipPreference();
Alexandre Savard's avatar
Alexandre Savard committed
222

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

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

227
        bool getPlayDtmf (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
228
229
230
231
232
            return _playDtmf;
        }
        void setPlayDtmf (bool dtmf) {
            _playDtmf = dtmf;
        }
Alexandre Savard's avatar
Alexandre Savard committed
233

234
        bool getPlayTones (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
235
236
237
238
239
            return _playTones;
        }
        void setPlayTones (bool tone) {
            _playTones = tone;
        }
Alexandre Savard's avatar
Alexandre Savard committed
240

241
        int getPulseLength (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
242
243
244
245
246
            return _pulseLength;
        }
        void setPulseLength (int length) {
            _pulseLength = length;
        }
Alexandre Savard's avatar
Alexandre Savard committed
247

248
        bool getSymmetricRtp (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
249
250
251
252
253
            return _symmetricRtp;
        }
        void setSymmetricRtp (bool sym) {
            _symmetricRtp = sym;
        }
Alexandre Savard's avatar
Alexandre Savard committed
254

255
        std::string getZidFile (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
256
257
258
259
260
            return _zidFile;
        }
        void setZidFile (std::string file) {
            _zidFile = file;
        }
Alexandre Savard's avatar
Alexandre Savard committed
261

Julien Bonjean's avatar
Julien Bonjean committed
262
    private:
Alexandre Savard's avatar
Alexandre Savard committed
263

Julien Bonjean's avatar
Julien Bonjean committed
264
265
266
267
268
        bool _playDtmf;
        bool _playTones;
        int _pulseLength;
        bool _symmetricRtp;
        std::string _zidFile;
Alexandre Savard's avatar
Alexandre Savard committed
269
270
271

};

Julien Bonjean's avatar
Julien Bonjean committed
272
273
274
275
276
277
278
279
280
281
282
283
284
class AddressbookPreference : public Serializable
{

    public:

        AddressbookPreference();

        ~AddressbookPreference();

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

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

285
        bool getPhoto (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
286
287
288
289
290
291
            return _photo;
        }
        void setPhoto (bool p) {
            _photo = p;
        }

292
        bool getEnabled (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
293
294
295
296
297
298
            return _enabled;
        }
        void setEnabled (bool e) {
            _enabled = e;
        }

299
        std::string getList (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
300
301
302
303
304
305
            return _list;
        }
        void setList (std::string l) {
            _list = l;
        }

306
        int getMaxResults (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
307
308
309
310
311
312
            return _maxResults;
        }
        void setMaxResults (int r) {
            _maxResults = r;
        }

313
        bool getBusiness (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
314
315
316
317
318
319
            return _business;
        }
        void setBusiness (bool b) {
            _business = b;
        }

320
        bool getHome (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
321
322
323
324
325
326
            return _home;
        }
        void setHone (bool h) {
            _home = h;
        }

327
        bool getMobile (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
            return _mobile;
        }
        void setMobile (bool m) {
            _mobile = m;
        }

    private:

        bool _photo;
        bool _enabled;
        std::string _list;
        int _maxResults;
        bool _business;
        bool _home;
        bool _mobile;
343
344
345
346

};


Julien Bonjean's avatar
Julien Bonjean committed
347
348
class HookPreference : public Serializable
{
349

Julien Bonjean's avatar
Julien Bonjean committed
350
    public:
351

Julien Bonjean's avatar
Julien Bonjean committed
352
        HookPreference();
353

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

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

358
        bool getIax2Enabled (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
359
360
361
362
363
            return _iax2Enabled;
        }
        void setIax2Enabled (bool i) {
            _iax2Enabled = i;
        }
364

365
        std::string getNumberAddPrefix (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
366
367
368
369
370
            return _numberAddPrefix;
        }
        void setNumberAddPrefix (std::string n) {
            _numberAddPrefix = n;
        }
371

372
        bool getNumberEnabled (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
373
374
375
376
377
            return _numberEnabled;
        }
        void setNumberEnabled (bool n) {
            _numberEnabled = n;
        }
378

379
        bool getSipEnabled (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
380
381
382
383
384
            return _sipEnabled;
        }
        void setSipEnabled (bool s) {
            _sipEnabled = s;
        }
385

386
        std::string getUrlCommand (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
387
388
389
390
391
            return _urlCommand;
        }
        void setUrlCommand (std::string u) {
            _urlCommand = u;
        }
392

393
        std::string getUrlSipField (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
394
395
396
397
398
            return _urlSipField;
        }
        void setUrlSipField (std::string u) {
            _urlSipField = u;
        }
399

Julien Bonjean's avatar
Julien Bonjean committed
400
    private:
401

Julien Bonjean's avatar
Julien Bonjean committed
402
403
404
405
406
407
        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
408
409
410
411

};


Julien Bonjean's avatar
Julien Bonjean committed
412
413
414
415
416
417
418
419
420
421
422
423
424
425
class AudioPreference : public Serializable
{

    public:

        AudioPreference();

        ~AudioPreference();

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

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

        // alsa preference
426
        int getCardin (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
427
428
429
430
431
432
            return _cardin;
        }
        void setCardin (int c) {
            _cardin = c;
        }

433
        int getCardout (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
434
435
436
437
438
439
            return _cardout;
        }
        void setCardout (int c) {
            _cardout = c;
        }

440
        int getCardring (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
441
442
443
444
445
446
            return _cardring;
        }
        void setCardring (int c) {
            _cardring = c;
        }

447
        int getFramesize (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
448
449
450
451
452
453
            return _framesize;
        }
        void setFramesize (int f) {
            _framesize = f;
        }

454
        std::string getPlugin (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
455
456
457
458
459
460
            return _plugin;
        }
        void setPlugin (std::string p) {
            _plugin = p;
        }

461
        int getSmplrate (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
462
463
464
465
466
467
468
            return _smplrate;
        }
        void setSmplrate (int r) {
            _smplrate = r;
        }

        //pulseaudio preference
469
        std::string getDevicePlayback (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
470
471
            return _devicePlayback;
        }
472
        void setDevicePlayback (const std::string &p) {
Julien Bonjean's avatar
Julien Bonjean committed
473
474
475
            _devicePlayback = p;
        }

476
        std::string getDeviceRecord (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
477
478
            return _deviceRecord;
        }
479
        void setDeviceRecord (const std::string &r) {
Julien Bonjean's avatar
Julien Bonjean committed
480
481
482
            _deviceRecord = r;
        }

483
        std::string getDeviceRingtone (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
484
485
486
487
488
489
490
            return _deviceRingtone;
        }
        void setDeviceRingtone (std::string r) {
            _deviceRingtone = r;
        }

        // general preference
491
        std::string getRecordpath (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
492
493
            return _recordpath;
        }
494
        void setRecordpath (const std::string &r) {
Julien Bonjean's avatar
Julien Bonjean committed
495
496
497
            _recordpath = r;
        }

498
        bool getIsAlwaysRecording(void) const {
499
500
501
502
503
504
505
        	return _alwaysRecording;
        }

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

506
        int getVolumemic (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
507
508
509
510
511
512
            return _volumemic;
        }
        void setVolumemic (int m) {
            _volumemic = m;
        }

513
        int getVolumespkr (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
514
515
516
517
518
519
            return _volumespkr;
        }
        void setVolumespkr (int s) {
            _volumespkr = s;
        }

520
        bool getNoiseReduce (void) const {
521
522
523
524
525
526
527
            return _noisereduce;
        }

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

528
        bool getEchoCancel(void) const {
529
530
531
532
533
534
535
        	return _echocancel;
        }

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

536
        int getEchoCancelTailLength(void) const {
537
538
539
540
541
542
543
        	return _echoCancelTailLength;
        }

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

544
        int getEchoCancelDelay(void) const {
545
546
547
548
549
550
551
        	return _echoCancelDelay;
        }

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

Julien Bonjean's avatar
Julien Bonjean committed
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
    private:

        // alsa preference
        int _cardin; // 0
        int _cardout; // 0
        int _cardring;// 0
        int _framesize; // 20
        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
569
        bool _alwaysRecording;
Julien Bonjean's avatar
Julien Bonjean committed
570
571
572
        int _volumemic; //:  100
        int _volumespkr; //: 100

573
        bool _noisereduce;
574
575
576
        bool _echocancel;
        int _echoCancelTailLength;
        int _echoCancelDelay;
577
578
};

579

Julien Bonjean's avatar
Julien Bonjean committed
580
581
class ShortcutPreferences : public Serializable
{
582

Julien Bonjean's avatar
Julien Bonjean committed
583
    public:
584

Julien Bonjean's avatar
Julien Bonjean committed
585
        ShortcutPreferences();
586

Julien Bonjean's avatar
Julien Bonjean committed
587
        ~ShortcutPreferences();
588

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

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

593
594
        void setShortcuts (std::map<std::string, std::string> shortcuts);
        std::map<std::string, std::string> getShortcuts (void) const;
595

596
        std::string getHangup (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
597
598
599
600
601
            return _hangup;
        }
        void setHangup (std::string hangup) {
            _hangup = hangup;
        }
602

603
        std::string getPickup (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
604
605
606
607
608
            return _pickup;
        }
        void setPickup (std::string pickup) {
            _pickup = pickup;
        }
609

610
        std::string getPopup (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
611
612
613
614
615
            return _popup;
        }
        void setPopup (std::string popup) {
            _popup = popup;
        }
616

617
        std::string getToggleHold (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
618
619
620
621
622
            return _toggleHold;
        }
        void setToggleHold (std::string hold) {
            _toggleHold = hold;
        }
623

624
        std::string getTogglePickupHangup (void) const {
Julien Bonjean's avatar
Julien Bonjean committed
625
626
627
628
629
            return _togglePickupHangup;
        }
        void setTogglePickupHangup (std::string toggle) {
            _togglePickupHangup = toggle;
        }
630

Julien Bonjean's avatar
Julien Bonjean committed
631
    private:
632

Julien Bonjean's avatar
Julien Bonjean committed
633
634
635
636
637
        std::string _hangup;
        std::string _pickup;
        std::string _popup;
        std::string _toggleHold;
        std::string _togglePickupHangup;
638
639
};

640
#endif