void ACDCallManager::addMapTransferAgentCallHandleToCall(SIPX_CALL hCall, ACDCall* pCallRef) { if (!pCallRef) return; mLock.acquire(); UtlInt callKey(hCall); ACDCall* pCall = dynamic_cast<ACDCall*>(mTransferCallHandleMap.findValue(&callKey)); if (!pCall) mTransferCallHandleMap.insertKeyAndValue(new UtlInt(hCall), pCallRef); mLock.release(); }
//////////////////////////////////////////////////////////////////////////////////////////////////// // // NAME: ACDCallManager::addDeadCallToMap(void) // // SYNOPSIS: // // DESCRIPTION: // // RETURNS: None. // // ERRORS: None. // // CAVEATS: None. // //////////////////////////////////////////////////////////////////////////////////////////////////// void ACDCallManager::addDeadCallToMap(SIPX_CALL hCall, UtlContainable* pCall) { if (!pCall) return; mLock.acquire(); UtlInt callKey(hCall); UtlContainable* pOld = mDeadCallHandleMap.findValue(&callKey) ; if (!pOld) { mDeadCallHandleMap.insertKeyAndValue(new UtlInt(hCall), pCall); OsSysLog::add(FAC_ACD, PRI_INFO, "ACDCallManager::addDeadCallToMap added hCall=%d ACDCall(%p)", hCall, pCall); } mLock.release(); }
void Templateiser::replaceVar ( std::string &code, std::string::const_iterator &itr, const std::string &str ) { // find the end of the ]] std::string key; itr = readKey(key,itr,str); if (itr != str.end()) { std::string lowerKey; std::string val; tolower(key,lowerKey); if (callKey(val,lowerKey)) code += val; else code += "[$"+key+"]"; } }
//////////////////////////////////////////////////////////////////////////////////////////////////// // // NAME: ACDCallManager::addMapAgentCallHandleToCall(void) // // SYNOPSIS: // // DESCRIPTION: // // RETURNS: None. // // ERRORS: None. // // CAVEATS: None. // //////////////////////////////////////////////////////////////////////////////////////////////////// void ACDCallManager::addMapAgentCallHandleToCall(SIPX_CALL hCall, ACDCall* pCallRef) { if (!pCallRef) return; mLock.acquire(); UtlInt callKey(hCall); ACDCall* pCall = dynamic_cast<ACDCall*>(mAgentCallHandleMap.findValue(&callKey)); if (!pCall) { mAgentCallHandleMap.insertKeyAndValue(new UtlInt(hCall), pCallRef); OsSysLog::add(FAC_ACD, PRI_INFO, "ACDCallManager::addMapAgent added hCall=%d ACDCall(%p)", hCall, pCallRef); } else { OsSysLog::add(FAC_ACD, PRI_ERR, "ACDCallManager::addMapAgent failed because hCall=%d already there.", hCall); } mLock.release(); }
void ACDCallManager::updateTransferCallState(SIPX_CALLSTATE_INFO* pCallInfo) { SIPX_CALL hCallHandle = SIPX_CALL_NULL; SIPX_CALL hAssociatedCallHandle; int callEvent; int callCause; const char* remUri; char userUri[512]; ACDCall* pCallRef; mLock.acquire(); // Extract the call handle and state info hAssociatedCallHandle = pCallInfo->hAssociatedCall; callEvent = pCallInfo->event; callCause = pCallInfo->cause; remUri = pCallInfo->remoteAddress; /** * For the NEWCALL_TRANSFER event - find the ACDCall object instance * on the basis of the Associated call handle (from the older leg). */ if (pCallInfo->cause == CALLSTATE_NEW_CALL_TRANSFER) { if (TRUE == validateTransferToLine(pCallInfo)) { // Don't allow agents to transfer calls INTO the acd. It screws // things up. The correct behavior would be to move the call // the agent is currently handling into a new queue, but due to // the inability to remove calls from a conference, this just doesn't // work. Hangup on the transfer attempt. Ths should leave // caller and agent connected. OsSysLog::add(FAC_ACD, PRI_WARNING, "ACDCallManager::updateTransferCallState - " "CALLSTATE_OFFERING::%d to the ACD Line REJECTED", pCallInfo->cause); sipxCallReject(pCallInfo->hCall, SIP_BAD_REQUEST_CODE, "Agent Transfer Loop Rejected"); return ; } // not an agent transferring into the acd hCallHandle = hAssociatedCallHandle; UtlInt callKey(hCallHandle); pCallRef = dynamic_cast<ACDCall*>(mAgentCallHandleMap.findValue(&callKey)); } else // not new call transfer { UtlInt searchKey(pCallInfo->hCall); pCallRef = dynamic_cast<ACDCall*>(mTransferCallHandleMap.findValue(&searchKey)); } if (pCallRef != NULL) { if (callCause == CALLSTATE_NEW_CALL_TRANSFER) { addMapTransferAgentCallHandleToCall(pCallInfo->hCall, pCallRef); pCallRef->mFlagTransfer = TRUE; // only set TRUE here. } if ( (callCause == CALLSTATE_REMOTE_OFFERING_NORMAL) && (pCallRef->mFlagTransfer == TRUE)) { UtlString userId, hostAddress; Url remoteUrl(remUri); remoteUrl.getUserId(userId); remoteUrl.getHostAddress(hostAddress); if (remUri) { // Now find the agent for this remUri sprintf(userUri,"sip:%s@%s",userId.data(),hostAddress.data()); UtlString agentUri(userUri); ACDAgent* pAgentRef = mpAcdServer->getAcdAgentManager()->getAcdAgentReference(agentUri); if (!pAgentRef) { OsSysLog::add(FAC_ACD, gACD_DEBUG, "ACDCallManager::updateTransferCallState - " "Failed to find Agent. This is probably an agent that is not signed in: " "call(%d), TransferAgentCall(%d), agentUri(%s)", pCallRef->getCallHandle(), pCallInfo->hCall, agentUri.data()); // A non registered agent is not yet supported - so do not try ! pAgentRef = mpAcdServer->getAcdAgentManager()->createACDAgent(userUri, "dummy", "", FALSE, FALSE, NULL, TRUE); if (!pAgentRef) { assert(0); } } //set the mhCallHandle of the Agent object pAgentRef->setCallHandle(pCallInfo->hCall); // set the transfer agent object in the call object pCallRef->mpTransferAgent = pAgentRef; OsSysLog::add(FAC_ACD, gACD_DEBUG, "ACDCallManager::updateTransferCallState - " "success in finding Agent: call(%d), TransferAgentCall(%d) AgentUri(%s)", pCallRef->getCallHandle(), pCallInfo->hCall, pAgentRef->getUriString()->data()); } } if ( (callCause == CALLSTATE_REMOTE_OFFERING_NORMAL) && (pCallRef->mFlagTransfer == FALSE)) { ; // do nothing } else { pCallRef->updateState(hCallHandle, callEvent, callCause); } } mLock.release(); return; }
OsStatus ACDCallManager::updateCallState(SIPX_CALLSTATE_INFO* pCallInfo) { SIPX_CALL hCallHandle; SIPX_LINE hLineHandle; int callEvent; int callCause; OsStatus status = OS_FAILED ; mLock.acquire(); // Extract the call handle and state info hCallHandle = pCallInfo->hCall; hLineHandle = pCallInfo->hLine; callEvent = pCallInfo->event; callCause = pCallInfo->cause; OsSysLog::add(FAC_ACD, gACD_DEBUG, "ACDCallManager::updateCallState hCall=%d hLine=%d callEvent %d callCause %d associated callHandle %d remoteAddr %s", hCallHandle, hLineHandle, callEvent, callCause, pCallInfo->hAssociatedCall, pCallInfo->remoteAddress); // Search for the call handle in the various maps // Inbound calls are in the mCallHandleMap char *which = "mCallHandleMap" ; UtlHashMap *map = &mCallHandleMap ; UtlInt callKey(hCallHandle); UtlContainable *pValue = NULL ; pValue = mCallHandleMap.findValue(&callKey) ; if (pValue == NULL) { // Calls to agents are in the mAgentCallHandleMap which = "mAgentCallHandleMap" ; map = &mAgentCallHandleMap ; pValue = mAgentCallHandleMap.findValue(&callKey) ; } if (pValue == NULL) { // In transfer mode, sometimes calls end up in the mTransferCallHandleMap which = "mTransferCallHandleMap" ; map = &mTransferCallHandleMap ; pValue = mTransferCallHandleMap.findValue(&callKey) ; } if (pValue == NULL) { which = "mDeadCallHandleMap" ; map = &mDeadCallHandleMap ; pValue = mDeadCallHandleMap.findValue(&callKey) ; } if (pValue != NULL) { if (callEvent == CALLSTATE_DESTROYED) { // If event is destroyed, then that is the last we will see of this // handle. Remove it from whatever map we found it in. OsSysLog::add(FAC_ACD, gACD_DEBUG, "ACDCallManager::updateCallState - " "removing hCall=%d from %s", hCallHandle, which) ; map->removeReference(&callKey); } else { if (map != &mDeadCallHandleMap) { // Pass event along to the ACDCall we found ACDCall* pCallRef = dynamic_cast<ACDCall*>(pValue); OsSysLog::add(FAC_ACD, gACD_DEBUG, "ACDCallManager::updateCallState - " "Found ACDCall Call(%d) hCall=%d Object(%p) using %s", pCallRef->mhCallHandle, hCallHandle, pCallRef, which) ; pCallRef->updateState(hCallHandle, callEvent, callCause); } else { OsSysLog::add(FAC_ACD, gACD_DEBUG, "ACDCallManager::updateCallState - ignoring dead hCall=%d events", hCallHandle); // Kill the darn thing, just to make sure it goes away sipxCallDestroy(hCallHandle) ; } } status = OS_SUCCESS ; } else { OsSysLog::add(FAC_ACD, gACD_DEBUG, "ACDCallManager::updateCallState - did not find hCall=%d hLine=%d", hCallHandle, hLineHandle); } mLock.release(); return status; }