49
49
#include "audio/sound/tonelist.h"
50
50
#include "audio/sound/audiofile.h"
51
51
#include "audio/sound/dtmf.h"
52
#include "history/historymanager.h"
52
#include "history/history.h"
53
53
#include "sip/sipvoiplink.h"
54
54
#include "iax/iaxvoiplink.h"
55
55
#include "manager.h"
73
74
hasTriedToRegister_(false), audioCodecFactory(), dbus_(), config_(), currentCallId_(),
74
75
currentCallMutex_(), audiodriver_(0), dtmfKey_(0), toneMutex_(),
75
76
telephoneTone_(0), audiofile_(0), speakerVolume_(0), micVolume_(0),
76
audiolayerMutex_(), waitingCall_(), waitingCallMutex_(),
77
audioLayerMutex_(), waitingCall_(), waitingCallMutex_(),
77
78
nbIncomingWaitingCall_(0), path_(), callAccountMap_(),
78
callAccountMapMutex_(), callConfigMap_(), accountMap_(),
79
mainBuffer_(), conferenceMap_(), history_(new HistoryManager),
79
callAccountMapMutex_(), IPToIPMap_(), accountMap_(),
80
mainBuffer_(), conferenceMap_(), history_(new History),
80
81
imModule_(new sfl::InstantMessaging)
82
83
// initialize random generator for call id
121
122
initAudioDriver();
123
audioLayerMutexLock();
126
telephoneTone_ = new TelephoneTone(preferences.getZoneToneChoice(), audiodriver_->getSampleRate());
127
dtmfKey_ = new DTMF(8000);
125
ost::MutexLock lock(audioLayerMutex_);
127
telephoneTone_ = new TelephoneTone(preferences.getZoneToneChoice(), audiodriver_->getSampleRate());
128
dtmfKey_ = new DTMF(8000);
130
audioLayerMutexUnlock();
132
history_->load_history(preferences.getHistoryLimit());
132
history_->load(preferences.getHistoryLimit());
133
133
registerAccounts();
215
213
static const char * const SIP_SCHEME = "sip:";
216
214
static const char * const SIPS_SCHEME = "sips:";
218
Call::CallConfiguration callConfig = (to_cleaned.find(SIP_SCHEME) == 0 or to_cleaned.find(SIPS_SCHEME) == 0) ? Call::IPtoIP : Call::Classic;
216
bool IPToIP = to_cleaned.find(SIP_SCHEME) == 0 or
217
to_cleaned.find(SIPS_SCHEME) == 0;
220
associateConfigToCall(call_id, callConfig);
219
setIPToIPForCall(call_id, IPToIP);
222
221
// in any cases we have to detach from current communication
223
222
if (hasCurrentCall()) {
230
229
detachParticipant(Call::DEFAULT_ID, current_call_id);
233
if (callConfig == Call::IPtoIP) {
234
233
DEBUG("Manager: Start IP2IP call");
236
235
/* We need to retrieve the sip voiplink instance */
341
340
void ManagerImpl::hangupCall(const std::string& callId)
343
INFO("Manager: Hangup call %s", callId.c_str());
342
DEBUG("Manager: Hangup call %s", callId.c_str());
345
344
// store the current call id
346
345
std::string currentCallId(getCurrentCallId());
351
350
DEBUG("Manager: Send DBUS call state change (HUNGUP) for id %s", callId.c_str());
352
351
dbus_.getCallManager()->callStateChanged(callId, "HUNGUP");
354
if (not isValidCall(callId) and not getConfigFromCall(callId) == Call::IPtoIP) {
353
if (not isValidCall(callId) and not isIPToIP(callId)) {
355
354
ERROR("Manager: Error: Could not hang up call, call not valid");
376
if (getConfigFromCall(callId) == Call::IPtoIP) {
375
if (isIPToIP(callId)) {
377
376
/* Direct IP to IP call */
378
Call * call = SIPVoIPLink::instance()->getCall(callId);
379
history_->addCall(call, preferences.getHistoryLimit());
379
380
SIPVoIPLink::instance()->hangup(callId);
380
381
} catch (const VoipLinkException &e) {
381
382
ERROR("%s", e.what());
384
385
std::string accountId(getAccountFromCall(callId));
385
getAccountLink(accountId)->hangup(callId);
386
VoIPLink *link = getAccountLink(accountId);
387
Call * call = link->getCall(callId);
388
history_->addCall(call, preferences.getHistoryLimit());
389
link->hangup(callId);
386
390
removeCallAccount(callId);
428
432
std::string current_call_id(getCurrentCallId());
431
if (getConfigFromCall(callId) == Call::IPtoIP) {
432
/* Direct IP to IP call */
435
if (isIPToIP(callId)) {
433
436
SIPVoIPLink::instance()-> onhold(callId);
435
438
/* Classic call, attached to an account */
488
491
bool isRec = false;
490
/* Direct IP to IP call */
491
if (getConfigFromCall(callId) == Call::IPtoIP)
492
SIPVoIPLink::instance()-> offhold(callId);
493
if (isIPToIP(callId))
494
SIPVoIPLink::instance()->offhold(callId);
494
496
/* Classic call, attached to an account */
495
497
accountId = getAccountFromCall(callId);
534
536
// Direct IP to IP call
535
if (getConfigFromCall(callId) == Call::IPtoIP)
537
if (isIPToIP(callId)) {
536
538
SIPVoIPLink::instance()->transfer(callId, to);
538
std::string accountid(getAccountFromCall(callId));
540
std::string accountID(getAccountFromCall(callId));
540
if (accountid.empty())
542
if (accountID.empty())
543
getAccountLink(accountid)->transfer(callId, to);
545
VoIPLink *link = getAccountLink(accountID);
546
link->transfer(callId, to);
546
549
// remove waiting call in case we make transfer without even answer
556
559
dbus_.getCallManager()->transferFailed();
559
void ManagerImpl::transferSucceded()
562
void ManagerImpl::transferSucceeded()
561
dbus_.getCallManager()->transferSucceded();
564
dbus_.getCallManager()->transferSucceeded();
564
567
bool ManagerImpl::attendedTransfer(const std::string& transferID, const std::string& targetID)
566
if (getConfigFromCall(transferID) == Call::IPtoIP)
569
if (isIPToIP(transferID))
567
570
return SIPVoIPLink::instance()->attendedTransfer(transferID, targetID);
569
572
// Classic call, attached to an account
583
586
if (getCallList().size() <= 1) {
584
audioLayerMutexLock();
587
ost::MutexLock lock(audioLayerMutex_);
585
588
audiodriver_->stopStream();
586
audioLayerMutexUnlock();
589
591
/* Direct IP to IP call */
591
if (getConfigFromCall(id) == Call::IPtoIP)
592
594
SIPVoIPLink::instance()->refuse(id);
594
596
/* Classic call, attached to an account */
633
635
void ManagerImpl::removeConference(const std::string& conference_id)
635
637
DEBUG("Manager: Remove conference %s", conference_id.c_str());
637
638
DEBUG("Manager: number of participants: %u", conferenceMap_.size());
638
639
ConferenceMap::iterator iter = conferenceMap_.find(conference_id);
817
818
// reset ring buffer for all conference participant
818
819
// flush conference participants only
819
for (ParticipantSet::const_iterator iter_p = participants.begin();
820
iter_p != participants.end(); ++iter_p)
821
getMainBuffer()->flush(*iter_p);
820
for (ParticipantSet::const_iterator p = participants.begin();
821
p != participants.end(); ++p)
822
getMainBuffer()->flush(*p);
823
824
getMainBuffer()->flush(Call::DEFAULT_ID);
837
838
onHoldCall(current_call_id);
840
audioLayerMutexLock();
842
ConferenceMap::const_iterator iter = conferenceMap_.find(conference_id);
844
if (iter != conferenceMap_.end()) {
845
Conference *conf = iter->second;
842
ost::MutexLock lock(audioLayerMutex_);
844
ConferenceMap::const_iterator iter = conferenceMap_.find(conference_id);
846
if (iter != conferenceMap_.end()) {
847
Conference *conf = iter->second;
847
849
ParticipantSet participants(conf->getParticipantList());
960
961
conf->setState(Conference::ACTIVE_ATTACHED);
962
963
// set recording sampling rate
963
audioLayerMutexLock();
966
conf->setRecordingSmplRate(audiodriver_->getSampleRate());
968
audioLayerMutexUnlock();
965
ost::MutexLock lock(audioLayerMutex_);
967
conf->setRecordingSmplRate(audiodriver_->getSampleRate());
970
970
getMainBuffer()->stateInfo();
983
983
int successCounter = 0;
985
for (std::vector<std::string>::const_iterator iter = participantList.begin(); iter != participantList.end(); ++iter) {
986
std::string numberaccount(*iter);
985
for (std::vector<std::string>::const_iterator p = participantList.begin();
986
p != participantList.end(); ++p) {
987
std::string numberaccount(*p);
987
988
std::string tostr(numberaccount.substr(0, numberaccount.find(",")));
988
989
std::string account(numberaccount.substr(numberaccount.find(",") + 1, numberaccount.size()));
1011
1012
conferenceMap_.insert(std::make_pair(conf->getConfID(), conf));
1012
1013
dbus_.getCallManager()->conferenceCreated(conf->getConfID());
1014
audioLayerMutexLock();
1017
conf->setRecordingSmplRate(audiodriver_->getSampleRate());
1019
audioLayerMutexUnlock();
1016
ost::MutexLock lock(audioLayerMutex_);
1019
conf->setRecordingSmplRate(audiodriver_->getSampleRate());
1021
1022
getMainBuffer()->stateInfo();
1136
1137
// Reset ringbuffer's readpointers
1137
for (ParticipantSet::const_iterator iter_p = participants.begin();
1138
iter_p != participants.end();
1140
getMainBuffer()->flush(*iter_p);
1138
for (ParticipantSet::const_iterator p = participants.begin();
1139
p != participants.end(); ++p)
1140
getMainBuffer()->flush(*p);
1142
1142
getMainBuffer()->flush(Call::DEFAULT_ID);
1143
1143
} else if (n == 1) {
1144
ParticipantSet::iterator iter_participant = participants.begin();
1144
ParticipantSet::iterator p = participants.begin();
1146
1146
// bind main participant to remaining conference call
1147
if (iter_participant != participants.end()) {
1147
if (p != participants.end()) {
1148
1148
// this call is no longer a conference participant
1149
std::string currentAccountId(getAccountFromCall(*iter_participant));
1150
Call *call = getAccountLink(currentAccountId)->getCall(*iter_participant);
1149
std::string currentAccountId(getAccountFromCall(*p));
1150
Call *call = getAccountLink(currentAccountId)->getCall(*p);
1152
1152
call->setConfId("");
1153
1153
// if we are not listening to this conference
1154
1154
if (current_call_id != conf->getConfID())
1155
1155
onHoldCall(call->getCallId());
1157
switchCall(*iter_participant);
1187
1187
Conference *conf = iter->second;
1188
1188
ParticipantSet participants(conf->getParticipantList());
1190
for (ParticipantSet::const_iterator iter_p = participants.begin();
1191
iter_p != participants.end(); ++iter_p) {
1192
detachParticipant(*iter_p, "");
1193
addParticipant(*iter_p, conf_id2);
1190
for (ParticipantSet::const_iterator p = participants.begin();
1191
p != participants.end(); ++p) {
1192
detachParticipant(*p, "");
1193
addParticipant(*p, conf_id2);
1229
1229
// bind to main
1230
1230
getMainBuffer()->bindCallID(call_id);
1232
audioLayerMutexLock();
1232
ost::MutexLock lock(audioLayerMutex_);
1233
1233
audiodriver_->flushUrgent();
1234
1234
audiodriver_->flushMain();
1235
audioLayerMutexUnlock();
1238
1237
getMainBuffer()->stateInfo();
1337
1335
audiodriver_->putUrgent(buf, size * sizeof(SFLDataFormat));
1340
audioLayerMutexUnlock();
1342
1338
// TODO Cache the DTMF
1347
1343
// Multi-thread
1348
bool ManagerImpl::incomingCallWaiting()
1344
bool ManagerImpl::incomingCallWaiting() const
1350
1346
return nbIncomingWaitingCall_ > 0;
1382
1378
associateCallToAccount(call->getCallId(), accountId);
1384
1380
if (accountId.empty())
1385
associateConfigToCall(call->getCallId(), Call::IPtoIP);
1381
setIPToIPForCall(call->getCallId(), true);
1387
1383
// strip sip: which is not required and bring confusion with ip to ip calls
1388
1384
// when placing new call from history (if call is IAX, do nothing)
1389
1385
std::string peerNumber(call->getPeerNumber());
1391
size_t startIndex = peerNumber.find("sip:");
1387
const char SIP_PREFIX[] = "sip:";
1388
size_t startIndex = peerNumber.find(SIP_PREFIX);
1393
1390
if (startIndex != std::string::npos)
1394
call->setPeerNumber(peerNumber.substr(startIndex + 4));
1391
call->setPeerNumber(peerNumber.substr(startIndex + sizeof(SIP_PREFIX) - 1));
1397
1394
if (not hasCurrentCall()) {
1398
call->setConnectionState(Call::Ringing);
1395
call->setConnectionState(Call::RINGING);
1399
1396
ringtone(accountId);
1402
1399
addWaitingCall(call->getCallId());
1404
std::string from(call->getPeerName());
1405
1401
std::string number(call->getPeerNumber());
1407
if (not from.empty() and not number.empty())
1410
from += "<" + number + ">";
1403
std::string from("<" + number + ">");
1412
1404
dbus_.getCallManager()->incomingCall(accountId, call->getCallId(), call->getDisplayName() + " " + from);
1535
1527
// Connect audio streams
1538
audioLayerMutexLock();
1539
audiodriver_->flushMain();
1540
audiodriver_->flushUrgent();
1541
audioLayerMutexUnlock();
1531
ost::MutexLock lock(audioLayerMutex_);
1532
audiodriver_->flushMain();
1533
audiodriver_->flushUrgent();
1543
1536
if (audioPreference.getIsAlwaysRecording()) {
1544
1537
setRecordingCall(id);
1580
1573
/* Direct IP to IP call */
1581
if (getConfigFromCall(call_id) == Call::IPtoIP)
1574
if (isIPToIP(call_id)) {
1575
Call * call = SIPVoIPLink::instance()->getCall(call_id);
1576
history_->addCall(call, preferences.getHistoryLimit());
1582
1577
SIPVoIPLink::instance()->hangup(call_id);
1584
1580
const std::string account_id(getAccountFromCall(call_id));
1585
getAccountLink(account_id)->peerHungup(call_id);
1581
VoIPLink *link = getAccountLink(account_id);
1582
Call * call = link->getCall(call_id);
1583
history_->addCall(call, preferences.getHistoryLimit());
1584
link->peerHungup(call_id);
1588
1587
/* Broadcast a signal over DBus */
1595
1594
if (getCallList().empty()) {
1596
1595
DEBUG("Manager: Stop audio stream, there are no calls remaining");
1598
audioLayerMutexLock();
1596
ost::MutexLock lock(audioLayerMutex_);
1599
1597
audiodriver_->stopStream();
1600
audioLayerMutexUnlock();
1664
1661
if (not voipPreferences.getPlayTones())
1667
audioLayerMutexLock();
1669
if (audiodriver_ == NULL) {
1670
ERROR("Manager: Error: Audio layer not initialized");
1671
audioLayerMutexUnlock();
1665
ost::MutexLock lock(audioLayerMutex_);
1667
if (audiodriver_ == NULL) {
1668
ERROR("Manager: Error: Audio layer not initialized");
1672
audiodriver_->flushUrgent();
1673
audiodriver_->startStream();
1675
audiodriver_->flushUrgent();
1676
audiodriver_->startStream();
1677
audioLayerMutexUnlock();
1679
1676
if (telephoneTone_ != 0) {
1680
toneMutex_.enterMutex();
1677
ost::MutexLock lock(toneMutex_);
1681
1678
telephoneTone_->setCurrentTone(toneId);
1682
toneMutex_.leaveMutex();
1764
1758
+ RINGDIR + DIR_SEPARATOR_STR + ringchoice;
1767
audioLayerMutexLock();
1769
if (!audiodriver_) {
1770
ERROR("Manager: Error: no audio layer in ringtone");
1771
audioLayerMutexUnlock();
1763
ost::MutexLock lock(audioLayerMutex_);
1765
if (!audiodriver_) {
1766
ERROR("Manager: Error: no audio layer in ringtone");
1770
samplerate = audiodriver_->getSampleRate();
1775
int samplerate = audiodriver_->getSampleRate();
1777
audioLayerMutexUnlock();
1780
1774
ost::MutexLock m(toneMutex_);
1848
1841
if (mkdir(configdir.data(), 0700) != 0) {
1849
// If directory creation failed
1842
// If directory creation failed
1850
1843
if (errno != EEXIST)
1851
DEBUG("Cannot create directory: %m");
1844
DEBUG("Cannot create directory: %m");
1854
1847
static const char * const PROGNAME = "sflphoned";
1873
1866
std::string ManagerImpl::serialize(const std::vector<std::string> &v)
1877
for (std::vector<std::string>::const_iterator iter = v.begin(); iter != v.end(); ++iter)
1868
std::ostringstream os;
1869
std::copy(v.begin(), v.end(), std::ostream_iterator<std::string>(os, "/"));
1883
1873
std::string ManagerImpl::getCurrentCodecName(const std::string& id)
1932
1919
void ManagerImpl::setAudioDevice(const int index, int streamType)
1934
audioLayerMutexLock();
1921
ost::MutexLock lock(audioLayerMutex_);
1936
1923
AlsaLayer *alsaLayer = dynamic_cast<AlsaLayer*>(audiodriver_);
1938
1925
if (!alsaLayer) {
1939
1926
ERROR("Can't find alsa device");
1940
audioLayerMutexUnlock();
1975
1959
std::vector<std::string> devices;
1977
audioLayerMutexLock();
1961
ost::MutexLock lock(audioLayerMutex_);
1979
1963
AlsaLayer *alsalayer = dynamic_cast<AlsaLayer*>(audiodriver_);
1982
devices = alsalayer->getSoundCardsInfo(SFL_PCM_PLAYBACK);
1984
audioLayerMutexUnlock();
1966
devices = alsalayer->getAudioDeviceList(AUDIO_STREAM_PLAYBACK);
1986
1968
return devices;
1995
1977
std::vector<std::string> devices;
1997
audioLayerMutexLock();
1979
ost::MutexLock lock(audioLayerMutex_);
1999
1981
AlsaLayer *alsalayer = dynamic_cast<AlsaLayer *>(audiodriver_);
2002
devices = alsalayer->getSoundCardsInfo(SFL_PCM_CAPTURE);
2004
audioLayerMutexUnlock();
1984
devices = alsalayer->getAudioDeviceList(AUDIO_STREAM_CAPTURE);
2006
1986
return devices;
2021
2001
std::stringstream ssi, sso, ssr;
2022
sso << alsa->getIndexOut();
2002
sso << alsa->getIndexPlayback();
2023
2003
v.push_back(sso.str());
2024
ssi << alsa->getIndexIn();
2004
ssi << alsa->getIndexCapture();
2025
2005
v.push_back(ssi.str());
2026
ssr << alsa->getIndexRing();
2006
ssr << alsa->getIndexRingtone();
2027
2007
v.push_back(ssr.str());
2030
audioLayerMutexUnlock();
2120
2098
DEBUG("Manager: Start recorded file playback %s", filepath.c_str());
2122
audioLayerMutexLock();
2124
if (!audiodriver_) {
2125
ERROR("Manager: Error: No audio layer in start recorded file playback");
2126
audioLayerMutexUnlock();
2102
ost::MutexLock lock(audioLayerMutex_);
2104
if (!audiodriver_) {
2105
ERROR("Manager: Error: No audio layer in start recorded file playback");
2109
sampleRate = audiodriver_->getSampleRate();
2130
int sampleRate = audiodriver_->getSampleRate();
2132
audioLayerMutexUnlock();
2135
2113
ost::MutexLock m(toneMutex_);
2160
2137
DEBUG("Manager: Stop recorded file playback %s", filepath.c_str());
2162
audioLayerMutexLock();
2163
audiodriver_->stopStream();
2164
audioLayerMutexUnlock();
2140
ost::MutexLock lock(audioLayerMutex_);
2141
audiodriver_->stopStream();
2167
2145
ost::MutexLock m(toneMutex_);
2197
2175
void ManagerImpl::setAudioManager(const std::string &api)
2199
audioLayerMutexLock();
2201
if (!audiodriver_) {
2202
audioLayerMutexUnlock();
2206
if (api == audioPreference.getAudioApi()) {
2207
DEBUG("Manager: Audio manager chosen already in use. No changes made. ");
2208
audioLayerMutexUnlock();
2212
audioLayerMutexUnlock();
2178
ost::MutexLock lock(audioLayerMutex_);
2183
if (api == audioPreference.getAudioApi()) {
2184
DEBUG("Manager: Audio manager chosen already in use. No changes made. ");
2214
2189
switchAudioManager();
2227
2202
int soundCardIndex = 0;
2229
audioLayerMutexLock();
2204
ost::MutexLock lock(audioLayerMutex_);
2231
2206
if (audiodriver_ == NULL) {
2232
2207
ERROR("Manager: Error: Audio layer not initialized");
2233
audioLayerMutexUnlock();
2234
2208
return soundCardIndex;
2237
2211
AlsaLayer *alsalayer = dynamic_cast<AlsaLayer *>(audiodriver_);
2240
soundCardIndex = alsalayer -> soundCardGetIndex(name);
2242
audioLayerMutexUnlock();
2214
soundCardIndex = alsalayer -> getAudioDeviceIndex(name);
2244
2216
return soundCardIndex;
2296
2268
void ManagerImpl::initAudioDriver()
2298
audioLayerMutexLock();
2270
ost::MutexLock lock(audioLayerMutex_);
2299
2271
audiodriver_ = audioPreference.createAudioLayer();
2301
audioLayerMutexUnlock();
2304
2274
void ManagerImpl::switchAudioManager()
2306
audioLayerMutexLock();
2276
ost::MutexLock lock(audioLayerMutex_);
2308
2278
bool wasStarted = audiodriver_->isStarted();
2309
2279
delete audiodriver_;
2414
bool ManagerImpl::setConfig(const std::string& section,
2376
void ManagerImpl::setConfig(const std::string& section,
2415
2377
const std::string& name, const std::string& value)
2417
return config_.setConfigTreeItem(section, name, value);
2379
config_.setConfigTreeItem(section, name, value);
2421
bool ManagerImpl::setConfig(const std::string& section,
2383
void ManagerImpl::setConfig(const std::string& section,
2422
2384
const std::string& name, int value)
2424
2386
std::ostringstream valueStream;
2425
2387
valueStream << value;
2426
return config_.setConfigTreeItem(section, name, valueStream.str());
2388
config_.setConfigTreeItem(section, name, valueStream.str());
2429
2391
void ManagerImpl::setAccountsOrder(const std::string& order)
2551
2513
if (accountType == "SIP")
2552
2514
newAccount = new SIPAccount(newAccountID);
2553
2516
else if (accountType == "IAX")
2554
2517
newAccount = new IAXAccount(newAccountID);
2556
2520
ERROR("Unknown %s param when calling addAccount(): %s",
2557
2521
CONFIG_ACCOUNT_TYPE, accountType.c_str());
2565
2529
// Add the newly created account in the account order list
2566
2530
std::string accountList(preferences.getAccountOrder());
2532
newAccountID += "/";
2568
2533
if (not accountList.empty()) {
2569
newAccountID += "/";
2570
2534
// Prepend the new account
2571
2535
accountList.insert(0, newAccountID);
2572
2536
preferences.setAccountOrder(accountList);
2574
newAccountID += "/";
2575
2538
accountList = newAccountID;
2576
2539
preferences.setAccountOrder(accountList);
2777
2740
std::string ManagerImpl::getAccountIdFromNameAndServer(const std::string& userName, const std::string& server) const
2779
INFO("Manager : username = %s, server = %s", userName.c_str(), server.c_str());
2742
DEBUG("Manager : username = %s, server = %s", userName.c_str(), server.c_str());
2780
2743
// Try to find the account id from username and server name by full match
2782
2745
for (AccountMap::const_iterator iter = accountMap_.begin(); iter != accountMap_.end(); ++iter) {
2835
2798
addressbookPreference.setBusiness(settings.find("ADDRESSBOOK_DISPLAY_PHONE_BUSINESS")->second == 1);
2836
2799
addressbookPreference.setHone(settings.find("ADDRESSBOOK_DISPLAY_PHONE_HOME")->second == 1);
2837
2800
addressbookPreference.setMobile(settings.find("ADDRESSBOOK_DISPLAY_PHONE_MOBILE")->second == 1);
2839
// Write it to the configuration file
2840
// TODO save config is called for updateAddressbookSettings, updateHookSettings, setHistoryLimit each called
2841
// when closing preference window (in this order)
2845
2803
void ManagerImpl::setAddressbookList(const std::vector<std::string>& list)
2875
2833
hookPreference.setSipEnabled(settings.find("URLHOOK_SIP_ENABLED")->second == "true");
2876
2834
hookPreference.setUrlCommand(settings.find("URLHOOK_COMMAND")->second);
2877
2835
hookPreference.setUrlSipField(settings.find("URLHOOK_SIP_FIELD")->second);
2879
// Write it to the configuration file
2880
// TODO save config is called for updateAddressbookSettings, updateHookSettings, setHistoryLimit each called
2881
// when closing preference window (in this order)
2885
bool ManagerImpl::associateConfigToCall(const std::string& callID,
2886
Call::CallConfiguration config)
2888
if (getConfigFromCall(callID) == 0) { // nothing with the same ID
2889
callConfigMap_[callID] = config;
2890
DEBUG("Manager: Associate call %s with config %d", callID.c_str(), config);
2896
Call::CallConfiguration ManagerImpl::getConfigFromCall(const std::string& callID) const
2898
CallConfigMap::const_iterator iter = callConfigMap_.find(callID);
2900
if (iter == callConfigMap_.end())
2901
return (Call::CallConfiguration) 0;
2903
return iter->second;
2906
bool ManagerImpl::removeCallConfig(const std::string& callID)
2908
return callConfigMap_.erase(callID);
2838
void ManagerImpl::setIPToIPForCall(const std::string& callID, bool IPToIP)
2840
if (not isIPToIP(callID)) // no IPToIP calls with the same ID
2841
IPToIPMap_[callID] = IPToIP;
2844
bool ManagerImpl::isIPToIP(const std::string& callID) const
2846
std::map<std::string, bool>::const_iterator iter = IPToIPMap_.find(callID);
2847
return iter != IPToIPMap_.end() and iter->second;
2911
2850
std::map<std::string, std::string> ManagerImpl::getCallDetails(const std::string& callID)
2934
2873
type << call->getCallType();
2935
2874
call_details["ACCOUNTID"] = accountid;
2936
2875
call_details["PEER_NUMBER"] = call->getPeerNumber();
2937
call_details["PEER_NAME"] = call->getPeerName();
2938
2876
call_details["DISPLAY_NAME"] = call->getDisplayName();
2939
2877
call_details["CALL_STATE"] = call->getStateStr();
2940
2878
call_details["CALL_TYPE"] = type.str();
2951
2889
return call_details;
2954
std::vector<std::string> ManagerImpl::getHistorySerialized() const
2956
return history_->get_history_serialized();
2959
void ManagerImpl::setHistorySerialized(std::vector<std::string> history)
2961
history_->set_serialized_history(history, preferences.getHistoryLimit());;
2962
history_->save_history();
2892
std::vector<std::map<std::string, std::string> > ManagerImpl::getHistory() const
2894
return history_->getSerialized();
3002
2934
std::vector<std::string> ManagerImpl::getParticipantList(const std::string& confID) const
3004
2936
std::vector<std::string> v;
3006
2937
ConferenceMap::const_iterator iter_conf = conferenceMap_.find(confID);
3008
2939
if (iter_conf != conferenceMap_.end()) {