diff --git a/daemon/src/call.cpp b/daemon/src/call.cpp index 258d2ca22e8d95e4eb0bb9a72208fd1e5f055dba..73ccbe36548f9c39acb521b111988e7098d2517e 100644 --- a/daemon/src/call.cpp +++ b/daemon/src/call.cpp @@ -43,7 +43,7 @@ Call::Call(const std::string& id, Call::CallType type) , type_(type) , connectionState_(Call::Disconnected) , callState_(Call::Inactive) - , callConfig_(Call::Classic) + , isIPToIP_(false) , peerName_() , peerNumber_() , displayName_() diff --git a/daemon/src/call.h b/daemon/src/call.h index fcb5bba7341812870785af5b04c3127a71db8d81..18d754f557f49b9c6c0206f75c864623f9ec3ef6 100644 --- a/daemon/src/call.h +++ b/daemon/src/call.h @@ -46,11 +46,6 @@ class Call : public Recordable { public: static const char * const DEFAULT_ID; - /** - * This determines if the call is a direct IP-to-IP call or a classic call, made with an existing account - */ - enum CallConfiguration {Classic, IPtoIP}; - /** * This determines if the call originated from the local user (Outgoing) * or from some remote peer (Incoming). @@ -193,12 +188,12 @@ class Call : public Recordable { std::string getStateStr(); - void setCallConfiguration(Call::CallConfiguration callConfig) { - callConfig_ = callConfig; + void setIPToIP(bool IPToIP) { + isIPToIP_ = IPToIP; } - Call::CallConfiguration getCallConfiguration() const { - return callConfig_; + bool isIPtoIP() const { + return isIPToIP_; } /** @@ -267,7 +262,7 @@ class Call : public Recordable { CallState callState_; /** Direct IP-to-IP or classic call */ - CallConfiguration callConfig_; + bool isIPToIP_; /** Name of the peer */ std::string peerName_; diff --git a/daemon/src/managerimpl.cpp b/daemon/src/managerimpl.cpp index 4c34fc676148bf17d676c32b023688a63b799d14..d8e57fe3fecfa95a74d899f8b40b54b1a6e4e847 100644 --- a/daemon/src/managerimpl.cpp +++ b/daemon/src/managerimpl.cpp @@ -75,7 +75,7 @@ ManagerImpl::ManagerImpl() : telephoneTone_(0), audiofile_(0), speakerVolume_(0), micVolume_(0), audiolayerMutex_(), waitingCall_(), waitingCallMutex_(), nbIncomingWaitingCall_(0), path_(), callAccountMap_(), - callAccountMapMutex_(), callConfigMap_(), accountMap_(), + callAccountMapMutex_(), IPToIPMap_(), accountMap_(), mainBuffer_(), conferenceMap_(), history_(new History), imModule_(new sfl::InstantMessaging) { @@ -215,9 +215,10 @@ bool ManagerImpl::outgoingCall(const std::string& account_id, static const char * const SIP_SCHEME = "sip:"; static const char * const SIPS_SCHEME = "sips:"; - Call::CallConfiguration callConfig = (to_cleaned.find(SIP_SCHEME) == 0 or to_cleaned.find(SIPS_SCHEME) == 0) ? Call::IPtoIP : Call::Classic; + bool IPToIP = to_cleaned.find(SIP_SCHEME) == 0 or + to_cleaned.find(SIPS_SCHEME) == 0; - associateConfigToCall(call_id, callConfig); + setIPToIPForCall(call_id, IPToIP); // in any cases we have to detach from current communication if (hasCurrentCall()) { @@ -230,7 +231,7 @@ bool ManagerImpl::outgoingCall(const std::string& account_id, detachParticipant(Call::DEFAULT_ID, current_call_id); } - if (callConfig == Call::IPtoIP) { + if (IPToIP) { DEBUG("Manager: Start IP2IP call"); /* We need to retrieve the sip voiplink instance */ @@ -351,7 +352,7 @@ void ManagerImpl::hangupCall(const std::string& callId) DEBUG("Manager: Send DBUS call state change (HUNGUP) for id %s", callId.c_str()); dbus_.getCallManager()->callStateChanged(callId, "HUNGUP"); - if (not isValidCall(callId) and not getConfigFromCall(callId) == Call::IPtoIP) { + if (not isValidCall(callId) and not isIPToIP(callId)) { ERROR("Manager: Error: Could not hang up call, call not valid"); return; } @@ -373,7 +374,7 @@ void ManagerImpl::hangupCall(const std::string& callId) switchCall(""); } - if (getConfigFromCall(callId) == Call::IPtoIP) { + if (isIPToIP(callId)) { /* Direct IP to IP call */ try { SIPVoIPLink::instance()->hangup(callId); @@ -428,7 +429,7 @@ void ManagerImpl::onHoldCall(const std::string& callId) std::string current_call_id(getCurrentCallId()); try { - if (getConfigFromCall(callId) == Call::IPtoIP) { + if (isIPToIP(callId)) { /* Direct IP to IP call */ SIPVoIPLink::instance()-> onhold(callId); } else { @@ -488,7 +489,7 @@ void ManagerImpl::offHoldCall(const std::string& callId) bool isRec = false; /* Direct IP to IP call */ - if (getConfigFromCall(callId) == Call::IPtoIP) + if (isIPToIP(callId)) SIPVoIPLink::instance()-> offhold(callId); else { /* Classic call, attached to an account */ @@ -532,7 +533,7 @@ bool ManagerImpl::transferCall(const std::string& callId, const std::string& to) switchCall(""); // Direct IP to IP call - if (getConfigFromCall(callId) == Call::IPtoIP) + if (isIPToIP(callId)) SIPVoIPLink::instance()->transfer(callId, to); else { std::string accountid(getAccountFromCall(callId)); @@ -563,7 +564,7 @@ void ManagerImpl::transferSucceded() bool ManagerImpl::attendedTransfer(const std::string& transferID, const std::string& targetID) { - if (getConfigFromCall(transferID) == Call::IPtoIP) + if (isIPToIP(transferID)) return SIPVoIPLink::instance()->attendedTransfer(transferID, targetID); // Classic call, attached to an account @@ -588,7 +589,7 @@ void ManagerImpl::refuseCall(const std::string& id) /* Direct IP to IP call */ - if (getConfigFromCall(id) == Call::IPtoIP) + if (isIPToIP(id)) SIPVoIPLink::instance()->refuse(id); else { /* Classic call, attached to an account */ @@ -1382,7 +1383,7 @@ void ManagerImpl::incomingCall(Call* call, const std::string& accountId) associateCallToAccount(call->getCallId(), accountId); if (accountId.empty()) - associateConfigToCall(call->getCallId(), Call::IPtoIP); + setIPToIPForCall(call->getCallId(), true); else { // strip sip: which is not required and bring confusion with ip to ip calls // when placing new call from history (if call is IAX, do nothing) @@ -1578,7 +1579,7 @@ void ManagerImpl::peerHungupCall(const std::string& call_id) } /* Direct IP to IP call */ - if (getConfigFromCall(call_id) == Call::IPtoIP) + if (isIPToIP(call_id)) SIPVoIPLink::instance()->hangup(call_id); else { const std::string account_id(getAccountFromCall(call_id)); @@ -2886,30 +2887,16 @@ void ManagerImpl::setHookSettings(const std::map<std::string, std::string>& sett // saveConfig(); } -bool ManagerImpl::associateConfigToCall(const std::string& callID, - Call::CallConfiguration config) +void ManagerImpl::setIPToIPForCall(const std::string& callID, bool IPToIP) { - if (getConfigFromCall(callID) == 0) { // nothing with the same ID - callConfigMap_[callID] = config; - DEBUG("Manager: Associate call %s with config %d", callID.c_str(), config); - return true; - } else - return false; -} - -Call::CallConfiguration ManagerImpl::getConfigFromCall(const std::string& callID) const -{ - CallConfigMap::const_iterator iter = callConfigMap_.find(callID); - - if (iter == callConfigMap_.end()) - return (Call::CallConfiguration) 0; - else - return iter->second; + if (not isIPToIP(callID)) // no IPToIP calls with the same ID + IPToIPMap_[callID] = IPToIP; } -bool ManagerImpl::removeCallConfig(const std::string& callID) +bool ManagerImpl::isIPToIP(const std::string& callID) const { - return callConfigMap_.erase(callID); + std::map<std::string, bool>::const_iterator iter = IPToIPMap_.find(callID); + return iter != IPToIPMap_.end() and iter->second; } std::map<std::string, std::string> ManagerImpl::getCallDetails(const std::string& callID) diff --git a/daemon/src/managerimpl.h b/daemon/src/managerimpl.h index e6b9823837f056e59281367a35e1c11cfaf8be2a..84f6e876d326e1858938f87f5aad51c779a854f5 100644 --- a/daemon/src/managerimpl.h +++ b/daemon/src/managerimpl.h @@ -82,8 +82,6 @@ typedef std::map<std::string, Account*> AccountMap; /** Define a type for a std::string to std::string Map inside ManagerImpl */ typedef std::map<std::string, std::string> CallAccountMap; -typedef std::map<std::string, Call::CallConfiguration> CallConfigMap; - /** To send multiple string */ typedef std::list<std::string> TokenList; @@ -1060,13 +1058,11 @@ class ManagerImpl { /** Mutex to lock the call account map (main thread + voiplink thread) */ ost::Mutex callAccountMapMutex_; - CallConfigMap callConfigMap_; - - bool associateConfigToCall(const std::string& callID, Call::CallConfiguration config); + std::map<std::string, bool> IPToIPMap_; - Call::CallConfiguration getConfigFromCall(const std::string& callID) const; + void setIPToIPForCall(const std::string& callID, bool IPToIP); - bool removeCallConfig(const std::string& callID); + bool isIPToIP(const std::string& callID) const; /** *Contains a list of account (sip, aix, etc) and their respective voiplink/calls */ diff --git a/daemon/src/sip/sipvoiplink.cpp b/daemon/src/sip/sipvoiplink.cpp index cc59163995c5acc63da22704499131dffb7d7aec..28aaa2baaf46c3610793da8227cb0844d87fdf5c 100644 --- a/daemon/src/sip/sipvoiplink.cpp +++ b/daemon/src/sip/sipvoiplink.cpp @@ -875,7 +875,7 @@ bool SIPVoIPLink::SIPNewIpToIpCall(const std::string& id, const std::string& to) return false; SIPCall *call = new SIPCall(id, Call::Outgoing, cp_); - call->setCallConfiguration(Call::IPtoIP); + call->setIPToIP(true); call->initRecFileName(to); std::string localAddress(getInterfaceAddrFromName(account->getLocalInterface()));