managerimpl.h 38 KB
Newer Older
jpbl's avatar
jpbl committed
1
/*
2
 *  Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc.
jpbl's avatar
jpbl committed
3
4
 *  Author: Yan Morin <yan.morin@savoirfairelinux.com>
 *  Author: Laurielle Lea <laurielle.lea@savoirfairelinux.com>
5
 *  Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
6
 *  Author: Guillaume Carmel-Archambault <guillaume.carmel-archambault@savoirfairelinux.com>
jpbl's avatar
jpbl committed
7
8
9
 *
 *  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
10
 *  the Free Software Foundation; either version 3 of the License, or
jpbl's avatar
jpbl committed
11
12
13
14
15
16
17
18
19
20
 *  (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.
21
22
23
24
25
26
27
28
29
30
31
 *
 *  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.
jpbl's avatar
jpbl committed
32
33
 */

34
35
#ifndef __SFL_MANAGER_H__
#define __SFL_MANAGER_H__
jpbl's avatar
jpbl committed
36
37
38

#include <string>
#include <vector>
yanmorin's avatar
   
yanmorin committed
39
#include <set>
yanmorin's avatar
   
yanmorin committed
40
#include <map>
jpbl's avatar
jpbl committed
41
#include <cc++/thread.h>
42
#include "dbus/dbusmanager.h"
jpbl's avatar
jpbl committed
43
44
45

#include "observer.h"
#include "config/config.h"
yanmorin's avatar
   
yanmorin committed
46

yanmorin's avatar
   
yanmorin committed
47
#include "account.h"
yanmorin's avatar
   
yanmorin committed
48
#include "call.h"
49
#include "conference.h"
50
#include "numbercleaner.h"
jpbl's avatar
jpbl committed
51

52
53
54
55
#include "audio/sound/tonelist.h"  // for Tone::TONEID declaration
#include "audio/sound/audiofile.h" // AudioFile class contained by value here 
#include "audio/sound/dtmf.h" // DTMF class contained by value here
#include "audio/codecs/codecDescriptor.h" // CodecDescriptor class contained by value here
jpbl's avatar
jpbl committed
56

57
#include "audio/mainbuffer.h"
58
#include "yamlemitter.h"
59
#include "yamlparser.h"
60
#include "preferences.h"
61

jpbl's avatar
jpbl committed
62
63
64
65
class AudioLayer;
class GuiFramework;
class TelephoneTone;
class VoIPLink;
66

67
// class Conference;
yanmorin's avatar
   
yanmorin committed
68

jpbl's avatar
jpbl committed
69
70
71
72
#ifdef USE_ZEROCONF
class DNSService;
#endif

73
class HistoryManager;
74
class SIPAccount;
jpbl's avatar
jpbl committed
75

76
/** Define a type for a AccountMap container */
yanmorin's avatar
   
yanmorin committed
77
typedef std::map<AccountID, Account*> AccountMap;
78
79

/** Define a type for a CallID to AccountID Map inside ManagerImpl */
yanmorin's avatar
   
yanmorin committed
80
typedef std::map<CallID, AccountID> CallAccountMap;
yanmorin's avatar
   
yanmorin committed
81

Emmanuel Milou's avatar
Emmanuel Milou committed
82
83
typedef std::map<CallID, Call::CallConfiguration> CallConfigMap;

84
/** Define a type for CallID vector (waiting list, incoming not answered) */
yanmorin's avatar
   
yanmorin committed
85
86
typedef std::set<CallID> CallIDSet;

87
/** To send multiple string */
jpbl's avatar
jpbl committed
88
89
typedef std::list<std::string> TokenList;

90
91
/** To store conference objects by call ids 
    used to retreive the conference according to a call */
92
93
94
typedef std::map<CallID, Conference*> ConferenceCallMap;

/** To store conference objects by conference ids */
95
96
97
98
typedef std::map<CallID, Conference*> ConferenceMap;

static CallID default_conf = "conf"; 

99
100
101
102
103
104
105
106
107
108
109
110
static char * mapStateToChar[] = {
    (char*) "UNREGISTERED",
    (char*) "TRYING",
    (char*) "REGISTERED",
    (char*) "ERROR",
    (char*) "ERRORAUTH",
    (char*) "ERRORNETWORK",
    (char*) "ERRORHOST",
    (char*) "ERROREXISTSTUN",    
    (char*) "ERRORCONFSTUN"    
};

111
/** Manager (controller) of sflphone daemon */
jpbl's avatar
jpbl committed
112
class ManagerImpl {
113
114
115
116
  public:
    ManagerImpl (void);
    ~ManagerImpl (void);

117
118
119
120

    /**
     * General preferences configuration
     */ 
121
    Preferences preferences;
122

123
124
125
    /**
     * Voip related preferences
     */
Alexandre Savard's avatar
Alexandre Savard committed
126
127
    VoipPreference voipPreferences;

128
129
130
    /**
     * Addressbook related preferences
     */ 
131
132
    AddressbookPreference addressbookPreference;

133
134
135
    /**
     * Hook preferences
     */
136
137
    HookPreference hookPreference;

138
139
140
    /**
     * Audio preferences
     */
141
142
    AudioPreference audioPreference;

143
144
145
146
147
148
149
150
    /**
     * Shortcut preferences
     */ 
    ShortcutPreferences shortcutPreferences;

    /**
     * Method to build preferences from configuration
     */
151
    short buildConfiguration();
152

153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
    /**
     * Initialisation of thread (sound) and map.
     * Init a new VoIPLink, audio codec and audio driver
     */
    void init (void);

    /**
     * Terminate all thread (sound, link) and unload AccountMap
     */
    void terminate (void);

    /**
     * Set user interface manager.
     * @param man The DBUS interface implementation
     */
    void setDBusManager (DBusManagerImpl* man) { _dbus = man; }

    /**
     * Accessor to audiodriver.
     * it's multi-thread and use mutex internally
     * @return AudioLayer*  The audio layer object
     */
    AudioLayer* getAudioDriver(void) const { return _audiodriver; }

    /**
     * Get a descriptor map of codec available
     * @return CodecDescriptor  The internal codec map
     */
    CodecDescriptor& getCodecDescriptorMap(void) {return _codecDescriptorMap;}

    /**
     * Functions which occur with a user's action
     * Place a new call
     * @param accountId	The account to make tha call with
     * @param id  The call identifier
     * @param to  The recipient of the call
     * @return bool true on success
     *		  false otherwise
     */
    bool outgoingCall(const AccountID& accountId, const CallID& id, const std::string& to);

    /**
     * Functions which occur with a user's action
     * Answer the call
     * @param id  The call identifier
     */
    bool answerCall(const CallID& id);

    /**
     * Functions which occur with a user's action
     * Hangup the call
     * @param id  The call identifier
     */
    bool hangupCall(const CallID& id);

Alexandre Savard's avatar
Alexandre Savard committed
208
209
210
211
212
213
214
215

    /**
     * Functions which occur with a user's action
     * Hangup the conference (hangup every participants)
     * @param id  The call identifier
     */
    bool hangupConference(const ConfID& id);

216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
    /**
     * Functions which occur with a user's action
     * Cancel the call
     * @param id  The call identifier
     */
    bool cancelCall(const CallID& id);

    /**
     * Functions which occur with a user's action
     * Put the call on hold
     * @param id  The call identifier
     */
    bool onHoldCall(const CallID& id);

    /**
     * Functions which occur with a user's action
     * Put the call off hold
     * @param id  The call identifier
     */
    bool offHoldCall(const CallID& id);

    /**
     * Functions which occur with a user's action
     * Transfer the call
     * @param id  The call identifier
     * @param to  The recipient of the transfer
     */
    bool transferCall(const CallID& id, const std::string& to);

245
246
247
248
249
250
251
252
253
254
    /**
     * Notify the client the transfer is successful
     */
    void transferSucceded();

    /**
     * Notify the client that the transfer failed
     */
    void transferFailed();

255
256
257
258
259
260
261
    /**
     * Functions which occur with a user's action
     * Refuse the call
     * @param id  The call identifier
     */
    bool refuseCall(const CallID& id);

262
263
264
265
266
    /**
     * Create a new conference given two participant
     * @param the first participant ID
     * @param the second participant ID
     */ 
267
    Conference* createConference(const CallID& id1, const CallID& id2);
268

269
270
271
272
    /**
     * Delete this conference
     * @param the conference ID
     */ 
273
274
    void removeConference(const CallID& conference_id);

275
276
277
278
    /**
     * Return the conference id for which this call is attached
     * @ param the call id
     */
279
280
    Conference* getConferenceFromCallID(const CallID& call_id);

281
282
283
284
    /**
     * Hold every participant to a conference
     * @param the conference id
     */
285
286
    void holdConference(const CallID& conferece_id);

287
288
289
290
    /**
     * Unhold all conference participants 
     * @param the conference id
     */
291
292
    void unHoldConference(const CallID& conference_id);

293
294
295
296
    /**
     * Test if this id is a conference (usefull to test current call)
     * @param the call id
     */
297
298
    bool isConference(const CallID& call_id);

299
300
301
302
    /**
     * Test if a call id particips to this conference
     * @param the call id
     */
303
304
    bool participToConference(const CallID& call_id);

305
306
307
308
309
    /**
     * Add a participant to a conference
     * @param the call id
     * @param the conference id
     */
310
    void addParticipant(const CallID& call_id, const CallID& conference_id);
311

312
313
314
315
    /**
     * Bind the main participant to a conference (mainly called on a double click action)
     * @param the conference id
     */
316
317
    void addMainParticipant(const CallID& conference_id);

318
319
320
321
322
    /**
     * Join two participants to create a conference
     * @param the fist call id
     * @param the second call id
     */
323
324
    void joinParticipant(const CallID& call_id1, const CallID& call_id2);

325
326
327
328
329
    /**
     * Detach a participant from a conference, put the call on hold, do not hangup it
     * @param call id
     * @param the current call id
     */
330
    void detachParticipant(const CallID& call_id, const CallID& current_call_id);
331

332
333
334
335
    /**
     * Remove the conference participant from a conference
     * @param call id
     */
336
    void removeParticipant(const CallID& call_id);
337
338
339
340
341
342
343
    
    /**
     * Process remaining participant given a conference and the current call id.
     * Mainly called when a participant is detached or hagned up
     * @param current call id
     * @param conference pointer
     */
344
345
    void processRemainingParticipant(CallID current_call_id, Conference *conf);

346
347
348
    /**
     * Join two conference together into one unique conference
     */
349
350
    void joinConference(const CallID& conf_id1, const CallID& conf_id2);

351
352
    void addStream(const CallID& call_id);

353
354
    void removeStream(const CallID& call_id);

355
356
    /**
     * Save config to file
357
358
359
360
361
362
363
     * @return true on success
     *	    false otherwise
     */
    bool saveConfig (void);

    /**
     * Send registration to all enabled accounts
364
365
     * @return 0 on registration success
     *          1 otherelse
366
     */
367
    int initRegisterAccounts();
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384

    /**
     * @return true if we tried to register once
     */
    bool _hasTriedToRegister;

    /**
     * Handle choice of the DTMF-send-way
     * @param   id: callid of the line.
     * @param   code: pressed key.
     */
    bool sendDtmf(const CallID& id, char code);

    /**
     * Play the dtmf-associated sound
     * @param code  The pressed key
     */
385
    bool playDtmf (char code);
386
387
388
389
390
391
392
393
394

    /**
     * Play a ringtone
     * @return bool True on success
     *	      false otherwise
     */
    bool playTone ();

    /**
395
     * Play a special ringtone ( BUSY ) if there's at least one message on the voice mail
396
397
398
399
400
401
402
403
     * @return bool True on success
     *	      false otherwise
     */
    bool playToneWithMessage ();

    /**
     * Acts on the audio streams and audio files
     */
404
    void stopTone (void);
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442

    /**
     * When receiving a new incoming call, add it to the callaccount map
     * and notify user
     * @param call A call pointer
     * @param accountId an account id
     * @return bool True if the call was added correctly
     */
    bool incomingCall(Call* call, const AccountID& accountId);

    /**
     * Notify the user that the recipient of the call has answered and the put the
     * call in Current state
     * @param id  The call identifier
     */
    void peerAnsweredCall(const CallID& id);

    /**
     * Rings back because the outgoing call is ringing and the put the
     * call in Ringing state
     * @param id  The call identifier
     */
    void peerRingingCall(const CallID& id);

    /**
     * Put the call in Hungup state, remove the call from the list
     * @param id  The call identifier
     */
    void peerHungupCall(const CallID& id);

    /**
     * Notify the client with an incoming message
     * @param accountId	The account identifier
     * @param message The content of the message
     */
    void incomingMessage(const AccountID& accountId, const std::string& message);

    /**
443
     * Notify the client he has voice mails
444
445
446
     * @param accountId	  The account identifier
     * @param nb_msg The number of messages
     */
Emmanuel Milou's avatar
Emmanuel Milou committed
447
    void startVoiceMessageNotification(const AccountID& accountId, int nb_msg);
448

449
450
    /**
     * Notify the client through DBus that registration state has been updated
451
     */
452
    void connectionStatusNotification(void);
453
454
455

    /**
     * ConfigurationManager - Send registration request
456
     * @param accountId The account to register/unregister
457
     * @param enable The flag for the type of registration
458
459
460
     *		 0 for unregistration request
     *		 1 for registration request
     */
461
    void sendRegister( const ::std::string& accountId , const int32_t& enable);
462
463
464

    bool getCallStatus(const std::string& sequenceId);

465
466
    /**
     * Get account list
467
468
469
470
     * @return std::vector<std::string> A list of accoundIDs
     */
    std::vector< std::string >  getAccountList();

471
472
473
474
475
    /**
     * Set the account order in the config file
     */
    void setAccountsOrder (const std::string& order);

476
477
478
479
480
481
    /**
     * Load the accounts order set by the user from the sflphonedrc config file
     * @return std::vector<std::string> A vector containing the account ID's
     */
    std::vector<std::string> loadAccountOrder ();

482
483
484
485
486
487
488
    /**
     * Retrieve details about a given account
     * @param accountID	  The account identifier
     * @return std::map< std::string, std::string > The account details
     */
    std::map< std::string, std::string > getAccountDetails(const AccountID& accountID);

489
490
491
492
493
494
495
    /**
     * Retrieve details about a given call
     * @param callID	  The account identifier
     * @return std::map< std::string, std::string > The call details
     */
    std::map< std::string, std::string > getCallDetails(const CallID& callID);

496
497
498
499
500
501
    /**
     * Get call list
     * @return std::vector<std::string> A list of call IDs
     */
    std::vector< std::string >  getCallList (void);

502
503
504
505
506
507
508
509
510
511
512
513
514
    /**
     * Retrieve details about a given call
     * @param callID	  The account identifier
     * @return std::map< std::string, std::string > The call details
     */
    std::map< std::string, std::string > getConferenceDetails(const CallID& callID);

    /**
     * Get call list
     * @return std::vector<std::string> A list of call IDs
     */
    std::vector< std::string >  getConferenceList (void);

515
516
517
518
519
520
521

    /**
     * Get a list of participant to a conference
     * @return std::vector<std::string> A list of call IDs
     */
    std::vector< std::string >  getParticipantList (const std::string& confID);

522
523
524
525
526
527
528
    /**
     * Save the details of an existing account, given the account ID
     * This will load the configuration map with the given data.
     * It will also register/unregister links where the 'Enabled' switched.
     * @param accountID	  The account identifier
     * @param details	  The account parameters
     */
529
    void setAccountDetails( const ::std::string& accountID,
530
	const std::map< ::std::string, ::std::string >& details );
531
532
533
534

    /**
     * Add a new account, and give it a new account ID automatically
     * @param details The new account parameters
jquentin's avatar
jquentin committed
535
     * @return The account Id given to the new account
536
     */
jquentin's avatar
jquentin committed
537
    std::string addAccount(const std::map< ::std::string, ::std::string >& details);
538
539
540
541
542
543
544
545

    /**
     * Delete an existing account, unregister VoIPLink associated, and
     * purge from configuration.
     * @param accountID	The account unique ID
     */
    void removeAccount(const AccountID& accountID);

546
547
548
549
550
551
552

    /**
     * Deletes all credentials defined for an account
     * @param accountID The account unique ID
     */
    void deleteAllCredential(const AccountID& accountID);
    
Alexandre Savard's avatar
Alexandre Savard committed
553
554
555
556
557
558
559
    /**
     * Get current codec name
     * @param call id
     * @return std::string The codec name
     */
    std::string getCurrentCodecName(const CallID& id);

560
    /**
561
     * Set input audio plugin
562
563
564
565
566
     * @param audioPlugin The audio plugin
     */
    void setInputAudioPlugin(const std::string& audioPlugin);

    /**
567
     * Set output audio plugin
568
569
570
571
572
573
574
575
576
577
578
     * @param audioPlugin The audio plugin
     */
    void setOutputAudioPlugin(const std::string& audioPlugin);

    /**
     * Get list of supported audio output device
     * @return std::vector<std::string> A list of the audio devices supporting playback
     */
    std::vector<std::string> getAudioOutputDeviceList(void);

    /**
579
     * Set audio device
580
     * @param index The index of the soundcard
581
     * @param the type of stream, either SFL_PCM_PLAYBACK, SFL_PCM_CAPTURE, SFL_PCM_RINGTONE
582
     */
583
    void setAudioDevice(const int index, const int streamType);
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603

    /**
     * Get list of supported audio input device
     * @return std::vector<std::string> A list of the audio devices supporting capture
     */
    std::vector<std::string> getAudioInputDeviceList(void);

    /**
     * Get string array representing integer indexes of output and input device
     * @return std::vector<std::string> A list of the current audio devices
     */
    std::vector<std::string> getCurrentAudioDevicesIndex();

    /**
     * Get index of an audio device
     * @param name The string description of an audio device
     * @return int  His index
     */
    int getAudioDeviceIndex( const std::string name );

604
    /**
605
606
607
     * Get current alsa plugin
     * @return std::string  The Alsa plugin
     */
608
    std::string getCurrentAudioOutputPlugin( void );
609

610
611
612
613
614
615
616
617
    std::string getEchoCancelState(void);

    void setEchoCancelState(std::string state);

    std::string getNoiseSuppressState(void);

    void setNoiseSuppressState(std::string state);

618
619
620
621
622
623
624
    /**
     * Convert a list of payload in a special format, readable by the server.
     * Required format: payloads separated with one slash.
     * @return std::string The serializabled string
     */
    std::string serialize(std::vector<std::string> v);

625
626
    std::vector<std::string> unserialize(std::string v);

627
628
629
630
631
    /**
     * Tells if IAX2 support is enabled
     * @return int 1 if IAX2 is enabled
     *	       0 otherwise
     */
632
    int isIax2Enabled( void );
633
634
635

    /**
     * Ringtone option.
636
     * If ringtone is enabled, ringtone on incoming call use custom choice. If not, only standart tone.
637
638
639
     * @return int	1 if enabled
     *	        0 otherwise
     */
640
    int isRingtoneEnabled( const AccountID& id );
641
642

    /**
643
     * Set the ringtone option
644
645
     * Inverse current value
     */
646
    void ringtoneEnabled( const AccountID& id );
647
648

    /**
649
     * Get the ringtone
650
651
     * @return gchar* The file name selected as a ringtone
     */
652
    std::string getRingtoneChoice( const AccountID& id);
653
654
655
656
657

    /**
     * Set a ringtone
     * @param tone The file name of the ringtone
     */
658
    void setRingtoneChoice( const std::string&, const AccountID& id);
659

660
661
662
663
664
665
666
667
668
669
    /**
     * Get the recording path from configuration tree
     * @return the string correspoding to the path
     */
    std::string getRecordPath( void );

    /**
     * Set the recoding path in the configuration tree
     * @param a string reresenting the path
     */
alexandresavard's avatar
alexandresavard committed
670
    void setRecordPath( const std::string& recPath);
671

672
673
674
675
676
677
678
679
680
681
682
683
    /** 
     * Set a credential for a given account. If it 
     * does not exist yet, it will be created.
     */
    void setCredential (const std::string& accountID, const int32_t& index, const std::map< std::string, std::string >& details);

    /**
     * Retreive the value set in the configuration file.
     * @return True if credentials hashing is enabled.
     */
    bool getMd5CredentialHashing(void);
    
684
    /**
685
     * Tells if the user wants to display the dialpad or not
686
687
688
     * @return int 1 if dialpad has to be displayed
     *	       0 otherwise
     */
689
    // int getDialpad( void );
690
691
692
693

    /**
     * Set the dialpad visible or not
     */
694
    // void setDialpad (bool display);
695

696
    /**
697
     * Tells if the user wants to display the volume controls or not
698
699
700
     * @return int 1 if the controls have to be displayed
     *	       0 otherwise
     */
701
    // int getVolumeControls( void );
702
703
704
705

    /**
     * Set the volume controls ( mic and speaker ) visible or not
     */
706
    // void setVolumeControls (bool display);
707

alexandresavard's avatar
alexandresavard committed
708
    /**
alexandresavard's avatar
alexandresavard committed
709
     * Set recording on / off
alexandresavard's avatar
alexandresavard committed
710
711
712
713
714
     * Start recording
     * @param id  The call identifier
     */
    void setRecordingCall(const CallID& id);

alexandresavard's avatar
alexandresavard committed
715
716
717
718
719
    /**
     * Return true if the call is currently recorded
     */
    bool isRecording(const CallID& id);

720
    /**
721
722
     * Set the maximum number of days to keep in the history
     * @param calls The number of days
723
     */
724
    void setHistoryLimit (const int& days);
725
726

    /**
727
728
     * Get the maximum number of days to keep in the history
     * @return double The number of days 
729
     */
730
731
    int getHistoryLimit (void);

732
    // void setHistoryEnabled (void);
733

734
    // std::string getHistoryEnabled (void);
735

736

737
738
739
740
741
742
743
744
745
746
747
748
749
750
    /**
     * Configure the start-up option
     * @return int	1 if SFLphone should start in the system tray
     *	        0 otherwise
     */
    int isStartHidden( void );

    /**
     * Configure the start-up option
     * At startup, SFLphone can be displayed or start hidden in the system tray
     */
    void startHidden( void );

    /**
751
     * Configure the popup behaviour
752
     * @return int	1 if it should popup on incoming calls
753
     *		0 if it should never popups
754
     */
755
    // int popupMode( void );
756
757

    /**
758
     * Configure the popup behaviour
759
760
761
     * When SFLphone is in the system tray, you can configure when it popups
     * Never or only on incoming calls
     */
762
    // void switchPopupMode( void );
763

764
765
766
    /**
     * Determine whether or not the search bar (history) should be displayed
     */
767
    // int getSearchbar( void );
768
769
770
771

    /**
     * Configure the search bar behaviour
     */
772
    // void setSearchbar( void );
773

774
775
776
    /**
     * Set the desktop notification level
     */
777
    // void setNotify( void );
778
779
780
781
782

    /**
     * Get the desktop notification level
     * @return int The notification level
     */
783
    // int32_t getNotify( void );
784
785
786
787
788
789

    /**
     * Set the desktop mail notification level
     */
    void setMailNotify( void );

790

Emmanuel Milou's avatar
Emmanuel Milou committed
791
    /**
792
     * Addressbook configuration
Emmanuel Milou's avatar
Emmanuel Milou committed
793
794
795
796
     */
    std::map<std::string, int32_t> getAddressbookSettings (void);

    /**
797
     * Addressbook configuration
Emmanuel Milou's avatar
Emmanuel Milou committed
798
     */
799
800
    void setAddressbookSettings (const std::map<std::string, int32_t>& settings);

801
    /**
802
803
804
805
806
807
     * Addressbook list
     */
    void setAddressbookList(const std::vector<  std::string >& list);

    /**
     * Addressbook list
Emmanuel Milou's avatar
Emmanuel Milou committed
808
     */
809
810
    std::vector <std::string> getAddressbookList( void );

811
    /**
812
     * Hook configuration
813
814
815
816
     */
    std::map<std::string, std::string> getHookSettings (void);

    /**
817
     * Hook configuration
818
819
820
     */
     void setHookSettings (const std::map<std::string, std::string>& settings);

Emmanuel Milou's avatar
Emmanuel Milou committed
821

822
    /**
823
824
825
826
827
     * Get the audio manager
     * @return int The audio manager
     *		    0 ALSA
     *		    1 PULSEAUDIO
     */
828
    int32_t getAudioManager( void );
829
830
831
832

    /**
     * Set the audio manager
     */
833
    void setAudioManager( const int32_t& api );
834
835

    void switchAudioManager( void );
836

837
838
    void audioSamplingRateChanged( void );

839
    /**
840
841
842
     * Get the desktop mail notification level
     * @return int The mail notification level
     */
843
    int32_t getMailNotify( void );
844

845
846
847
848
849
850
851
852
853
    /**
     * Retrieve the formatted list of codecs payload in the user config file and
     * load in the active list of codecs
     * @return std::vector<std::string>	  The vector containing the active codecs
     */
    std::vector<std::string> retrieveActiveCodecs( void );

    /**
     * Get the list of the active codecs
854
     * @return std::vector< ::std::string >  The list of active codecs
855
856
     */
    std::vector< ::std::string > getActiveCodecList( void );
857
858
859
860
861
862

    /*
     * Notify the client that an error occured
     * @param errCode The error code. Could be: ALSA_CAPTURE_ERROR
     *					       ALSA_PLAYBACK_ERROR
     */
863
    void notifyErrClient( const int32_t& errCode );
864
865
866
867
868
869
870
871
872
873

    /**
     * Retrieve in the configuration tree the value of a parameter in a specific section
     * @param section	The section to look in
     * @param name	The name of the parameter you want to get
     * @param arg	Undocumented
     * @return bool	true on success
     *			false otherwise
     */
    bool getConfig(const std::string& section, const std::string& name, TokenList& arg);
874

875
876
877
    /**
     * Change a specific value in the configuration tree.
     * This value will then be saved in the user config file sflphonedrc
878
     * @param section	The section name
879
     * @param name	The parameter name
880
     * @param value	The new string value
881
882
883
884
     * @return bool	true on success
     *		      false otherwise
     */
    bool setConfig(const std::string& section, const std::string& name, const std::string& value);
885

886
887
888
    /**
     * Change a specific value in the configuration tree.
     * This value will then be saved in the user config file sflphonedrc
889
     * @param section	The section name
890
     * @param name	The parameter name
891
     * @param value	The new int value
892
893
894
895
     * @return bool	true on success
     *		      false otherwise
     */
    bool setConfig(const std::string& section, const std::string& name, int value);
896
897
898
899
900
901
902
903
904
905
906
907
    
    inline std::string mapStateNumberToString(RegistrationState state) {
        std::string stringRepresentation;
        if (state > NumberOfState) {
            stringRepresentation = "ERROR";
            return stringRepresentation;
        }
        
        stringRepresentation = mapStateToChar[state];
        return stringRepresentation;
    }
    
908
    /**
909
910
911
912
913
914
     * Get a int from the configuration tree
     * Throw an Conf::ConfigTreeItemException if not found
     * @param section The section name to look in
     * @param name    The parameter name
     * @return int    The int value
     */
915
     
916
    int getConfigInt(const std::string& section, const std::string& name);
pierre-luc's avatar
pierre-luc committed
917
918
919
920
921
922
923
924
925
926
927
 
  /**
     * Get a bool from the configuration tree
     * Throw an Conf::ConfigTreeItemException if not found
     * @param section The section name to look in
     * @param name    The parameter name
     * @return bool    The bool value
     */
     
    bool getConfigBool(const std::string& section, const std::string& name);
            
928
    /**
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
     * Get a string from the configuration tree
     * Throw an Conf::ConfigTreeItemException if not found
     * @param section The section name to look in
     * @param name    The parameter name
     * @return sdt::string    The string value
     */
    std::string getConfigString(const std::string& section, const std::string& name);

    /**
     * Retrieve the soundcards index in the user config file and try to open audio devices
     * with a specific alsa plugin.
     * Set the audio layer sample rate
     */
    void selectAudioDriver(void);

    /**
945
     * Handle audio sounds heard by a caller while they wait for their
946
947
948
949
950
951
952
     * connection to a called party to be completed.
     */
    void ringback ();

    /**
     * Handle played music when an incoming call occurs
     */
953
    void ringtone (const AccountID& accountID);
954
955
956
957
958

    /**
     * Handle played music when a congestion occurs
     */
    void congestion ();
959

960
961
962
963
964
965
966
967
968
969
    /**
     * Handle played sound when a call can not be conpleted because of a busy recipient
     */
    void callBusy(const CallID& id);

    /**
     * Handle played sound when a failure occurs
     */
    void callFailure(const CallID& id);

970
    /**
971
     * Retrieve the current telephone tone
972
     * @return AudioLoop*   The audio tone or 0 if no tone (init before calling this function)
973
974
     */
    AudioLoop* getTelephoneTone();
975
976

    /**
977
     * Retrieve the current telephone file
978
     * @return AudioLoop* The audio file or 0 if the wav is stopped
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
     */
    AudioLoop* getTelephoneFile();

    /**
     * @return true is there is one or many incoming call waiting
     * new call, not anwsered or refused
     */
    bool incomingCallWaiting(void);

    /**
     * Notification of incoming call when you are already busy
     */
    void notificationIncomingCall(void);

    /*
     * Inline functions to manage speaker volume control
     * Read by main thread and AudioLayer thread
     * Write by main thread only
     * @return unsigned short	The volume value
     */
    unsigned short getSpkrVolume(void) { return _spkr_volume; }
1000