SIPXTAPI_API SIPX_RESULT sipxLineGetByUrl(const char* szLineUrl, SIPX_LINE* phLine) { assert(szLineUrl != NULL) ; assert(phLine != NULL) ; *phLine = sipxLineLookupHandle(szLineUrl); return (phLine) ? SIPX_RESULT_SUCCESS : SIPX_RESULT_FAILURE; }
bool SipXMessageObserver::handleIncomingInfoMessage(SipMessage* pMessage) { bool bRet = false; SIPX_INSTANCE_DATA* pInst = (SIPX_INSTANCE_DATA*) pMessage->getResponseListenerData(); if (NULL != pInst && NULL != pMessage) { if (mTestResponseCode != 0) // for unit testing purposes. { if (mTestResponseCode == 408) // a timeout response is being tested { // simulate a timeout .... OsTask::delay(1000); // respond to whomever sent us the message SipMessage sipResponse; sipResponse.setOkResponseData(pMessage); sipResponse.setResponseFirstHeaderLine(SIP_PROTOCOL_VERSION, mTestResponseCode, "timed out"); pInst->pSipUserAgent->send(sipResponse); return true ; } } else { // respond to whomever sent us the message SipMessage sipResponse; sipResponse.setOkResponseData(pMessage); pInst->pSipUserAgent->send(sipResponse); } // Find Line UtlString lineId; pMessage->getToUri(&lineId); UtlString requestUri; pMessage->getRequestUri(&requestUri); SIPX_LINE hLine = sipxLineLookupHandle(pInst, lineId.data(), requestUri); if (!pMessage->isResponse()) { // find call UtlString callId; pMessage->getCallIdField(&callId); SIPX_CALL hCall = sipxCallLookupHandle(callId, pInst->pCallManager); if (0 == hCall) { // we are unaware of the call context } SIPX_INFO_DATA* pInfoData = new SIPX_INFO_DATA; memset((void*)pInfoData, 0, sizeof(SIPX_INFO_DATA)); pInfoData->infoData.nSize = sizeof(SIPX_INFO_INFO); pInfoData->infoData.hCall = hCall; pInfoData->infoData.hLine = hLine; Url fromUrl; pInfoData->infoData.szFromURL = lineId.data(); pInfoData->infoData.nContentLength = pMessage->getContentLength(); // get and set the content type UtlString contentType; pMessage->getContentType(&contentType) ; pInfoData->infoData.szContentType = strdup(contentType.data()); // get the user agent UtlString userAgent; pMessage->getUserAgentField(&userAgent); pInfoData->infoData.szUserAgent = strdup(userAgent.data()); // get the content UtlString body; ssize_t dummyLength = pMessage->getContentLength(); const HttpBody* pBody = pMessage->getBody(); if (pBody == NULL) { return false; } pBody->getBytes(&body, &dummyLength); pInfoData->infoData.pContent = body.data(); // set the Instance pInfoData->pInst = pInst; // Create Mutex pInfoData->pMutex = new OsRWMutex(OsRWMutex::Q_FIFO); UtlVoidPtr* ptr = NULL; UtlSListIterator eventListenerItor(*g_pEventListeners); while ((ptr = (UtlVoidPtr*) eventListenerItor()) != NULL) { EVENT_LISTENER_DATA *pData = (EVENT_LISTENER_DATA*) ptr->getValue(); if (pData->pInst == pInfoData->pInst) { pData->pCallbackProc(EVENT_CATEGORY_INFO, &(pInfoData->infoData), pData->pUserData); } } bRet = true; } // if (0 != hLine) } // if (NULL != pInst && NULL != pMessage) return bRet; }