diff --git a/daemon/src/managerimpl.cpp b/daemon/src/managerimpl.cpp index aab64b6c4f5dc83dca4ed45e1729d0204cd3ae7e..ed92262516dd944b57642518a3fa398a020d309b 100644 --- a/daemon/src/managerimpl.cpp +++ b/daemon/src/managerimpl.cpp @@ -6,7 +6,6 @@ * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com> * Author: Guillaume Carmel-Archambault <guillaume.carmel-archambault@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 @@ -1669,18 +1668,16 @@ void ManagerImpl::removeWaitingCall (const std::string& id) ost::MutexLock m (_waitingCallMutex); // should return more than 1 if it erase a call - if (_waitingCall.erase (id)) { + if (_waitingCall.erase (id)) _nbIncomingWaitingCall--; - } } bool ManagerImpl::isWaitingCall (const std::string& id) { CallIDSet::iterator iter = _waitingCall.find (id); - if (iter != _waitingCall.end()) { + if (iter != _waitingCall.end()) return false; - } return true; } @@ -1691,11 +1688,7 @@ bool ManagerImpl::isWaitingCall (const std::string& id) // SipEvent Thread bool ManagerImpl::incomingCall (Call* call, const std::string& accountId) { - - std::string from, number, display_name, display; - - if (!call) - _error ("Manager: Error: no call at this point"); + assert(call); stopTone(); @@ -1704,12 +1697,12 @@ bool ManagerImpl::incomingCall (Call* call, const std::string& accountId) associateCallToAccount (call->getCallId(), accountId); // If account is null it is an ip to ip call - if (accountId == "") { + if (accountId.empty()) associateConfigToCall (call->getCallId(), Call::IPtoIP); - } else { + 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) - std::string peerNumber = call->getPeerNumber(); + std::string peerNumber(call->getPeerNumber()); int startIndex = peerNumber.find ("sip:"); @@ -1717,7 +1710,6 @@ bool ManagerImpl::incomingCall (Call* call, const std::string& accountId) std::string strippedPeerNumber = peerNumber.substr (startIndex + 4); call->setPeerNumber (strippedPeerNumber); } - } if (!hasCurrentCall()) { @@ -1726,17 +1718,16 @@ bool ManagerImpl::incomingCall (Call* call, const std::string& accountId) call->setConnectionState (Call::Ringing); ringtone (accountId); - } else { + } else _debug ("Manager: has current call, beep in current audio stream"); - } addWaitingCall (call->getCallId()); - from = call->getPeerName(); - number = call->getPeerNumber(); - display_name = call->getDisplayName(); + std::string from(call->getPeerName()); + std::string number(call->getPeerNumber()); + std::string display_name(call->getDisplayName()); - if (from != "" && number != "") { + if (not from.empty() and not number.empty()) { from.append (" <"); from.append (number); from.append (">"); @@ -1749,7 +1740,7 @@ bool ManagerImpl::incomingCall (Call* call, const std::string& accountId) /* Broadcast a signal over DBus */ _debug ("Manager: From: %s, Number: %s, Display Name: %s", from.c_str(), number.c_str(), display_name.c_str()); - display = display_name; + std::string display(display_name); display.append (" "); display.append (from); @@ -1764,21 +1755,19 @@ void ManagerImpl::incomingMessage (const std::string& callID, const std::string& from, const std::string& message) { - if (participToConference (callID)) { _debug ("Manager: Particip to a conference, send message to everyone"); Conference *conf = getConferenceFromCallID (callID); ParticipantSet participants = conf->getParticipantList(); - ParticipantSet::iterator iter_participant = participants.begin(); - - while (iter_participant != participants.end()) { + for (ParticipantSet::const_iterator iter_participant = participants.begin(); + iter_participant != participants.end(); ++iter_participant) { if (*iter_participant == callID) continue; - std::string accountId = getAccountFromCall (*iter_participant); + std::string accountId(getAccountFromCall (*iter_participant)); _debug ("Manager: Send message to %s, (%s)", (*iter_participant).c_str(), accountId.c_str()); @@ -1797,16 +1786,13 @@ void ManagerImpl::incomingMessage (const std::string& callID, _debug ("Manager: Failed to get voip link while sending instant message"); return; } - - iter_participant++; } // in case of a conference we must notify client using conference id _dbus.getCallManager()->incomingMessage (conf->getConfID(), from, message); - } else { + } else _dbus.getCallManager()->incomingMessage (callID, from, message); - } } diff --git a/daemon/src/sip/sipvoiplink.cpp b/daemon/src/sip/sipvoiplink.cpp index f58d8ba1e1d4ec8abc88df612d54814f52f3918e..9c23f12751feee5ff605ab680ed1eeee7dd1914e 100644 --- a/daemon/src/sip/sipvoiplink.cpp +++ b/daemon/src/sip/sipvoiplink.cpp @@ -3759,13 +3759,12 @@ transaction_request_cb (pjsip_rx_data *rdata) _debug ("UserAgent: Account ID for this call, %s", account_id.c_str()); /* If we don't find any account to receive the call */ - if (account_id == "") { + if (account_id.empty()) _debug ("UserAgent: Username %s doesn't match any account, using IP2IP!",userName.c_str()); - } /* Get the voip link associated to the incoming call */ /* The account must before have been associated to the call in ManagerImpl */ - if((link = dynamic_cast<SIPVoIPLink *> (Manager::instance().getAccountLink (account_id))) == NULL) { + if ((link = dynamic_cast<SIPVoIPLink *> (Manager::instance().getAccountLink (account_id))) == NULL) { _warn ("UserAgent: Error: cannot retrieve the voiplink from the account ID..."); pjsip_endpt_respond_stateless (_endpt, rdata, PJSIP_SC_INTERNAL_SERVER_ERROR, NULL, NULL, NULL); @@ -3796,7 +3795,7 @@ transaction_request_cb (pjsip_rx_data *rdata) std::string method_name = "NOTIFY"; // Retrieve all the message. Should contains only the method name but ... - std::string request = rdata->msg_info.msg->line.req.method.name.ptr; + std::string request(rdata->msg_info.msg->line.req.method.name.ptr); // Check if the message is a notification if (request.find (method_name) != (size_t)-1) { @@ -3847,35 +3846,30 @@ transaction_request_cb (pjsip_rx_data *rdata) /******************************************* URL HOOK *********************************************/ if (Manager::instance().hookPreference.getSipEnabled()) { - _debug ("UserAgent: Set sip url hooks"); - std::string header_value; - - header_value = fetchHeaderValue (rdata->msg_info.msg, - Manager::instance().hookPreference.getUrlSipField()); + std::string header_value(fetchHeaderValue (rdata->msg_info.msg, + Manager::instance().hookPreference.getUrlSipField())); if (header_value.size () < header_value.max_size()) { - if (header_value!="") { + if (not header_value.empty()) { urlhook->addAction (header_value, Manager::instance().hookPreference.getUrlCommand()); } } else throw std::length_error ("UserAgent: Url exceeds std::string max_size"); - } /************************************************************************************************/ - _info ("UserAgent: Create a new call"); // Generate a new call ID for the incoming call! id = Manager::instance().getNewCallID(); - if((call = new SIPCall (id, Call::Incoming, _cp)) == NULL) { + if ((call = new SIPCall (id, Call::Incoming, _cp)) == NULL) { _warn ("UserAgent: Error: Unable to create an incoming call"); pjsip_endpt_respond_stateless (_endpt, rdata, PJSIP_SC_INTERNAL_SERVER_ERROR, - NULL, NULL, NULL); + NULL, NULL, NULL); return false; } @@ -3904,13 +3898,11 @@ transaction_request_cb (pjsip_rx_data *rdata) } - if (addrToUse == "0.0.0.0") { + if (addrToUse == "0.0.0.0") link->loadSIPLocalIP (&addrToUse); - } - if (addrSdp == "0.0.0.0") { + if (addrSdp == "0.0.0.0") addrSdp = addrToUse; - } call->setConnectionState (Call::Progressing); call->setPeerNumber (peerNumber); @@ -3985,9 +3977,8 @@ transaction_request_cb (pjsip_rx_data *rdata) } } - status = call->getLocalSDP()->receiveOffer (r_sdp, account->getActiveCodecs ()); - if (status!=PJ_SUCCESS) { + if (status != PJ_SUCCESS) { delete call; call = NULL; _warn ("UserAgent: fail in receiving initial offer"); @@ -4038,7 +4029,7 @@ transaction_request_cb (pjsip_rx_data *rdata) } // Check if call have been transfered - if(replaced_dlg) { // If Replace header present + if (replaced_dlg) { // If Replace header present _debug("UserAgent: Replace request foud"); @@ -4046,7 +4037,7 @@ transaction_request_cb (pjsip_rx_data *rdata) // Always answer the new INVITE with 200, regardless whether // the replaced call is in early or confirmed state. - if((status = pjsip_inv_answer(inv, 200, NULL, NULL, &response)) == PJ_SUCCESS) + if ((status = pjsip_inv_answer(inv, 200, NULL, NULL, &response)) == PJ_SUCCESS) pjsip_inv_send_msg(inv, response); // Get the INVITE session associated with the replaced dialog. @@ -4058,8 +4049,7 @@ transaction_request_cb (pjsip_rx_data *rdata) status = pjsip_inv_send_msg(replaced_inv, tdata); call->replaceInvSession(inv); - } - else { // Prooceed with normal call flow + } else { // Prooceed with normal call flow // Send a 180 Ringing response _info ("UserAgent: Send a 180 Ringing response"); @@ -4089,7 +4079,6 @@ transaction_request_cb (pjsip_rx_data *rdata) NULL, NULL, NULL); return false; } - } /* Done */