preferences.h 15.9 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
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";
43
static const char * const registrationExpireKey = "registrationexpire";
44
45
46
47
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
class Preferences : public Serializable {
Julien Bonjean's avatar
Julien Bonjean committed
103
    public:
104
105
        static const char * const DFT_ZONE;

Julien Bonjean's avatar
Julien Bonjean committed
106
107
        Preferences();

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

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

112
113
        std::string getAccountOrder() const {
            return accountOrder_;
Julien Bonjean's avatar
Julien Bonjean committed
114
        }
115

116
        void setAccountOrder(const std::string &ord) {
117
            accountOrder_ = ord;
Julien Bonjean's avatar
Julien Bonjean committed
118
119
        }

120
121
        int getHistoryLimit() const {
            return historyLimit_;
Julien Bonjean's avatar
Julien Bonjean committed
122
        }
123

124
        void setHistoryLimit(int lim) {
125
            historyLimit_ = lim;
Julien Bonjean's avatar
Julien Bonjean committed
126
127
        }

128
129
        int getHistoryMaxCalls() const {
            return historyMaxCalls_;
Julien Bonjean's avatar
Julien Bonjean committed
130
        }
131

132
        void setHistoryMaxCalls(int max) {
133
            historyMaxCalls_ = max;
Julien Bonjean's avatar
Julien Bonjean committed
134
135
        }

136
137
        bool getNotifyMails() const {
            return notifyMails_;
Julien Bonjean's avatar
Julien Bonjean committed
138
        }
139

140
        void setNotifyMails(bool mails) {
141
            notifyMails_ = mails;
Julien Bonjean's avatar
Julien Bonjean committed
142
143
        }

144
145
        std::string getZoneToneChoice() const {
            return zoneToneChoice_;
Julien Bonjean's avatar
Julien Bonjean committed
146
        }
147

148
        void setZoneToneChoice(const std::string &str) {
149
            zoneToneChoice_ = str;
Julien Bonjean's avatar
Julien Bonjean committed
150
151
        }

152
153
        int getRegistrationExpire() const {
            return registrationExpire_;
Julien Bonjean's avatar
Julien Bonjean committed
154
        }
155

156
        void setRegistrationExpire(int exp) {
157
            registrationExpire_ = exp;
Julien Bonjean's avatar
Julien Bonjean committed
158
159
        }

160
161
        int getPortNum() const {
            return portNum_;
Julien Bonjean's avatar
Julien Bonjean committed
162
        }
163

164
        void setPortNum(int port) {
165
            portNum_ = port;
Julien Bonjean's avatar
Julien Bonjean committed
166
167
        }

168
169
        bool getSearchBarDisplay() const {
            return searchBarDisplay_;
Julien Bonjean's avatar
Julien Bonjean committed
170
        }
171

172
        void setSearchBarDisplay(bool search) {
173
            searchBarDisplay_ = search;
Julien Bonjean's avatar
Julien Bonjean committed
174
175
        }

176
177
        bool getZeroConfenable() const {
            return zeroConfenable_;
Julien Bonjean's avatar
Julien Bonjean committed
178
        }
179
        void setZeroConfenable(bool enable) {
180
            zeroConfenable_ = enable;
Julien Bonjean's avatar
Julien Bonjean committed
181
182
        }

183
184
        bool getMd5Hash() const {
            return md5Hash_;
Julien Bonjean's avatar
Julien Bonjean committed
185
        }
186
        void setMd5Hash(bool md5) {
187
            md5Hash_ = md5;
Julien Bonjean's avatar
Julien Bonjean committed
188
189
190
        }

    private:
191
192
193
194
195
196
197
198
199
200
        std::string accountOrder_;
        int historyLimit_;
        int historyMaxCalls_;
        bool notifyMails_;
        std::string zoneToneChoice_;
        int registrationExpire_;
        int portNum_;
        bool searchBarDisplay_;
        bool zeroConfenable_;
        bool md5Hash_;
201
202
};

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

207
        virtual void serialize(Conf::YamlEmitter *emitter);
Alexandre Savard's avatar
Alexandre Savard committed
208

209
        virtual void unserialize(Conf::MappingNode *map);
Alexandre Savard's avatar
Alexandre Savard committed
210

211
212
        bool getPlayDtmf() const {
            return playDtmf_;
Julien Bonjean's avatar
Julien Bonjean committed
213
        }
214

215
        void setPlayDtmf(bool dtmf) {
216
            playDtmf_ = dtmf;
Julien Bonjean's avatar
Julien Bonjean committed
217
        }
Alexandre Savard's avatar
Alexandre Savard committed
218

219
220
        bool getPlayTones() const {
            return playTones_;
Julien Bonjean's avatar
Julien Bonjean committed
221
        }
222

223
        void setPlayTones(bool tone) {
224
            playTones_ = tone;
Julien Bonjean's avatar
Julien Bonjean committed
225
        }
Alexandre Savard's avatar
Alexandre Savard committed
226

227
228
        int getPulseLength() const {
            return pulseLength_;
Julien Bonjean's avatar
Julien Bonjean committed
229
        }
230

231
        void setPulseLength(int length) {
232
            pulseLength_ = length;
Julien Bonjean's avatar
Julien Bonjean committed
233
        }
Alexandre Savard's avatar
Alexandre Savard committed
234

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

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

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

251
252
253
254
255
        bool playDtmf_;
        bool playTones_;
        int pulseLength_;
        bool symmetricRtp_;
        std::string zidFile_;
Alexandre Savard's avatar
Alexandre Savard committed
256
257
};

258
class AddressbookPreference : public Serializable {
Julien Bonjean's avatar
Julien Bonjean committed
259
260
261
    public:
        AddressbookPreference();

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

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

266
267
        bool getPhoto() const {
            return photo_;
Julien Bonjean's avatar
Julien Bonjean committed
268
        }
269

270
        void setPhoto(bool p) {
271
            photo_ = p;
Julien Bonjean's avatar
Julien Bonjean committed
272
273
        }

274
275
        bool getEnabled() const {
            return enabled_;
Julien Bonjean's avatar
Julien Bonjean committed
276
        }
277

278
        void setEnabled(bool e) {
279
            enabled_ = e;
Julien Bonjean's avatar
Julien Bonjean committed
280
281
        }

282
283
        std::string getList() const {
            return list_;
Julien Bonjean's avatar
Julien Bonjean committed
284
        }
285

286
        void setList(const std::string &l) {
287
            list_ = l;
Julien Bonjean's avatar
Julien Bonjean committed
288
289
        }

290
291
        int getMaxResults() const {
            return maxResults_;
Julien Bonjean's avatar
Julien Bonjean committed
292
        }
293

294
        void setMaxResults(int r) {
295
            maxResults_ = r;
Julien Bonjean's avatar
Julien Bonjean committed
296
297
        }

298
299
        bool getBusiness() const {
            return business_;
Julien Bonjean's avatar
Julien Bonjean committed
300
        }
301

302
        void setBusiness(bool b) {
303
            business_ = b;
Julien Bonjean's avatar
Julien Bonjean committed
304
305
        }

306
307
        bool getHome() const {
            return home_;
Julien Bonjean's avatar
Julien Bonjean committed
308
        }
309
        void setHone(bool h) {
310
            home_ = h;
Julien Bonjean's avatar
Julien Bonjean committed
311
312
        }

313
314
        bool getMobile() const {
            return mobile_;
Julien Bonjean's avatar
Julien Bonjean committed
315
        }
316
        void setMobile(bool m) {
317
            mobile_ = m;
Julien Bonjean's avatar
Julien Bonjean committed
318
319
320
321
        }

    private:

322
323
324
325
326
327
328
        bool photo_;
        bool enabled_;
        std::string list_;
        int maxResults_;
        bool business_;
        bool home_;
        bool mobile_;
329
330
331
332

};


333
class HookPreference : public Serializable {
Julien Bonjean's avatar
Julien Bonjean committed
334
335
    public:
        HookPreference();
336

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

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

341
342
        bool getIax2Enabled() const {
            return iax2Enabled_;
Julien Bonjean's avatar
Julien Bonjean committed
343
        }
344

345
        void setIax2Enabled(bool i) {
346
            iax2Enabled_ = i;
Julien Bonjean's avatar
Julien Bonjean committed
347
        }
348

349
350
        std::string getNumberAddPrefix() const {
            return numberAddPrefix_;
Julien Bonjean's avatar
Julien Bonjean committed
351
        }
352

353
        void setNumberAddPrefix(const std::string &n) {
354
            numberAddPrefix_ = n;
Julien Bonjean's avatar
Julien Bonjean committed
355
        }
356

357
358
        bool getNumberEnabled() const {
            return numberEnabled_;
Julien Bonjean's avatar
Julien Bonjean committed
359
        }
360

361
        void setNumberEnabled(bool n) {
362
            numberEnabled_ = n;
Julien Bonjean's avatar
Julien Bonjean committed
363
        }
364

365
366
        bool getSipEnabled() const {
            return sipEnabled_;
Julien Bonjean's avatar
Julien Bonjean committed
367
        }
368

369
        void setSipEnabled(bool s) {
370
            sipEnabled_ = s;
Julien Bonjean's avatar
Julien Bonjean committed
371
        }
372

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

380
381
        std::string getUrlSipField() const {
            return urlSipField_;
Julien Bonjean's avatar
Julien Bonjean committed
382
        }
383
        void setUrlSipField(const std::string &u) {
384
            urlSipField_ = u;
Julien Bonjean's avatar
Julien Bonjean committed
385
        }
386

Julien Bonjean's avatar
Julien Bonjean committed
387
    private:
388
389
390
391
392
393
        bool iax2Enabled_;
        std::string numberAddPrefix_;
        bool numberEnabled_;
        bool sipEnabled_;
        std::string urlCommand_;
        std::string urlSipField_;
394
395
396

};

397
class AudioPreference : public Serializable {
Julien Bonjean's avatar
Julien Bonjean committed
398
399
    public:
        AudioPreference();
400
401
402
        AudioLayer *createAudioLayer();
        AudioLayer *switchAndCreateAudioLayer();

403
404
        std::string getAudioApi() const {
            return audioApi_;
405
406
        }

407
        void setAudioApi(const std::string &api) {
408
            audioApi_ = api;
409
        }
410

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

413
        virtual void unserialize(Conf::MappingNode *map);
Julien Bonjean's avatar
Julien Bonjean committed
414
415

        // alsa preference
416
417
        int getCardin() const {
            return cardin_;
Julien Bonjean's avatar
Julien Bonjean committed
418
        }
419
        void setCardin(int c) {
420
            cardin_ = c;
Julien Bonjean's avatar
Julien Bonjean committed
421
422
        }

423
424
        int getCardout() const {
            return cardout_;
Julien Bonjean's avatar
Julien Bonjean committed
425
        }
426

427
        void setCardout(int c) {
428
            cardout_ = c;
Julien Bonjean's avatar
Julien Bonjean committed
429
430
        }

431
432
        int getCardring() const {
            return cardring_;
Julien Bonjean's avatar
Julien Bonjean committed
433
        }
434

435
        void setCardring(int c) {
436
            cardring_ = c;
Julien Bonjean's avatar
Julien Bonjean committed
437
438
        }

439
440
        std::string getPlugin() const {
            return plugin_;
Julien Bonjean's avatar
Julien Bonjean committed
441
        }
442

443
        void setPlugin(const std::string &p) {
444
            plugin_ = p;
Julien Bonjean's avatar
Julien Bonjean committed
445
446
        }

447
448
        int getSmplrate() const {
            return smplrate_;
Julien Bonjean's avatar
Julien Bonjean committed
449
        }
450
        void setSmplrate(int r) {
451
            smplrate_ = r;
Julien Bonjean's avatar
Julien Bonjean committed
452
453
454
        }

        //pulseaudio preference
455
456
        std::string getDevicePlayback() const {
            return devicePlayback_;
Julien Bonjean's avatar
Julien Bonjean committed
457
        }
458

459
        void setDevicePlayback(const std::string &p) {
460
            devicePlayback_ = p;
Julien Bonjean's avatar
Julien Bonjean committed
461
462
        }

463
464
        std::string getDeviceRecord() const {
            return deviceRecord_;
Julien Bonjean's avatar
Julien Bonjean committed
465
        }
466
        void setDeviceRecord(const std::string &r) {
467
            deviceRecord_ = r;
Julien Bonjean's avatar
Julien Bonjean committed
468
469
        }

470
471
        std::string getDeviceRingtone() const {
            return deviceRingtone_;
Julien Bonjean's avatar
Julien Bonjean committed
472
        }
473

474
        void setDeviceRingtone(const std::string &r) {
475
            deviceRingtone_ = r;
Julien Bonjean's avatar
Julien Bonjean committed
476
477
478
        }

        // general preference
479
480
        std::string getRecordpath() const {
            return recordpath_;
Julien Bonjean's avatar
Julien Bonjean committed
481
        }
482
        void setRecordpath(const std::string &r) {
483
            recordpath_ = r;
Julien Bonjean's avatar
Julien Bonjean committed
484
485
        }

486
487
        bool getIsAlwaysRecording() const {
            return alwaysRecording_;
488
489
490
        }

        void setIsAlwaysRecording(bool rec) {
491
            alwaysRecording_ = rec;
492
493
        }

494
495
        int getVolumemic() const {
            return volumemic_;
Julien Bonjean's avatar
Julien Bonjean committed
496
        }
497
        void setVolumemic(int m) {
498
            volumemic_ = m;
Julien Bonjean's avatar
Julien Bonjean committed
499
500
        }

501
502
        int getVolumespkr() const {
            return volumespkr_;
Julien Bonjean's avatar
Julien Bonjean committed
503
        }
504
        void setVolumespkr(int s) {
505
            volumespkr_ = s;
Julien Bonjean's avatar
Julien Bonjean committed
506
507
        }

508
509
        bool getNoiseReduce() const {
            return noisereduce_;
510
511
        }

512
        void setNoiseReduce(bool noise) {
513
            noisereduce_ = noise;
514
515
        }

516
517
        bool getEchoCancel() const {
            return echocancel_;
518
519
520
        }

        void setEchoCancel(bool echo) {
521
            echocancel_ = echo;
522
523
        }

524
525
        int getEchoCancelTailLength() const {
            return echoCancelTailLength_;
526
527
528
        }

        void setEchoCancelTailLength(int length) {
529
            echoCancelTailLength_ = length;
530
531
        }

532
533
        int getEchoCancelDelay() const {
            return echoCancelDelay_;
534
535
536
        }

        void setEchoCancelDelay(int delay) {
537
            echoCancelDelay_ = delay;
538
539
        }

Julien Bonjean's avatar
Julien Bonjean committed
540
    private:
541
        std::string audioApi_;
Julien Bonjean's avatar
Julien Bonjean committed
542
543

        // alsa preference
544
545
546
547
548
        int cardin_;
        int cardout_;
        int cardring_;
        std::string plugin_;
        int smplrate_;
Julien Bonjean's avatar
Julien Bonjean committed
549
550

        //pulseaudio preference
551
552
553
        std::string devicePlayback_;
        std::string deviceRecord_;
        std::string deviceRingtone_;
Julien Bonjean's avatar
Julien Bonjean committed
554
555

        // general preference
556
557
558
559
560
561
562
563
564
        std::string recordpath_; //: /home/msavard/Bureau
        bool alwaysRecording_;
        int volumemic_;
        int volumespkr_;

        bool noisereduce_;
        bool echocancel_;
        int echoCancelTailLength_;
        int echoCancelDelay_;
565
566
};

567
class ShortcutPreferences : public Serializable {
Julien Bonjean's avatar
Julien Bonjean committed
568
    public:
569
        ShortcutPreferences();
570
571
        virtual void serialize(Conf::YamlEmitter *emitter);
        virtual void unserialize(Conf::MappingNode *map);
572

573
        void setShortcuts(std::map<std::string, std::string> shortcuts);
574
        std::map<std::string, std::string> getShortcuts() const;
575

576
577
        std::string getHangup() const {
            return hangup_;
Julien Bonjean's avatar
Julien Bonjean committed
578
        }
579

580
        void setHangup(const std::string &hangup) {
581
            hangup_ = hangup;
Julien Bonjean's avatar
Julien Bonjean committed
582
        }
583

584
585
        std::string getPickup() const {
            return pickup_;
Julien Bonjean's avatar
Julien Bonjean committed
586
        }
587

588
        void setPickup(const std::string &pickup) {
589
            pickup_ = pickup;
Julien Bonjean's avatar
Julien Bonjean committed
590
        }
591

592
593
        std::string getPopup() const {
            return popup_;
Julien Bonjean's avatar
Julien Bonjean committed
594
        }
595

596
        void setPopup(const std::string &popup) {
597
            popup_ = popup;
Julien Bonjean's avatar
Julien Bonjean committed
598
        }
599

600
601
        std::string getToggleHold() const {
            return toggleHold_;
Julien Bonjean's avatar
Julien Bonjean committed
602
        }
603

604
        void setToggleHold(const std::string &hold) {
605
            toggleHold_ = hold;
Julien Bonjean's avatar
Julien Bonjean committed
606
        }
607

608
609
        std::string getTogglePickupHangup() const {
            return togglePickupHangup_;
Julien Bonjean's avatar
Julien Bonjean committed
610
        }
611

612
        void setTogglePickupHangup(const std::string &toggle) {
613
            togglePickupHangup_ = toggle;
Julien Bonjean's avatar
Julien Bonjean committed
614
        }
615

Julien Bonjean's avatar
Julien Bonjean committed
616
    private:
617
618
619
620
621
        std::string hangup_;
        std::string pickup_;
        std::string popup_;
        std::string toggleHold_;
        std::string togglePickupHangup_;
622
623
};

624
#endif