Beispiel #1
0
Datei: ugui.cpp Projekt: sgh/aos
void UGui::addRoot(Drawable* child) {
	drawLock();
	eventLock();
	Drawable* d = _root;

	while (d) {
		assert(d != child);
		if (!d->_next)
			break;

		if (d->_next->_modal && !child->_modal)
			break;

		d = d->_next;
	}
	
	child->_parent = NULL;

	if (d) { // Not the first child
		child->_prev = d;
		child->_next = d->_next;
		d->_next = child;
	} else { // First child
		_root = child;
		child->_prev = NULL;
		child->_next = NULL;
	}

	child->update();
	child->real_invalidate();
	eventUnlock();
	drawUnlock();
}
Beispiel #2
0
Datei: ugui.cpp Projekt: sgh/aos
void UGui::processEvents(Drawable* d) {
	while (d) {
		d->predraw();
		eventLock();
		d->processEvents();
		eventUnlock();
		processEvents(d->_children);
		d = d->next();
	}
}
Beispiel #3
0
BString VisionApp::GetEvent(int32 which) const
{
	BAutolock eventLock(const_cast<BLocker*>(&fSettingsLock));

	BString value;

	if (eventLock.IsLocked()) {
		if (which < MAX_EVENTS && which >= 0) {
			value = fEvents[which];
		}
	}
	return value.String();
}
Beispiel #4
0
void VisionApp::SetEvent(int32 which, const char* event)
{
	BAutolock eventLock(const_cast<BLocker*>(&fSettingsLock));

	if (!eventLock.IsLocked()) return;

	BString eventStr;
	eventStr = "event";
	eventStr << which;

	if (which < MAX_EVENTS && which >= 0 && fEvents[which].Compare(event)) {
		fEvents[which] = event;

		SetString(eventStr.String(), 0, event);
	}
}
Beispiel #5
0
Datei: ugui.cpp Projekt: sgh/aos
void UGui::removeRoot(Drawable* child) {
	drawLock();
	eventLock();
	child->real_invalidate();
	child->invalidateOverlapped();

	// Setup links
	if (child->_next)
		child->_next->_prev = child->_prev;
	if (child->_prev)
		child->_prev->_next = child->_next;

	child->_next = NULL;
	child->_prev = NULL;
	child->_parent = NULL;

	if (_root == child)
		_root = NULL;
	eventUnlock();
	drawUnlock();
}
bool SipXMessageObserver::handleIncomingInfoStatus(SipMessage* pSipMessage, int messageType)
{
    OsStackTraceLogger stackLogger(FAC_SIPXTAPI, PRI_DEBUG, "SipXMessageObserver::handleIncomingInfoStatus");

    if (NULL == pSipMessage)
    {
        // something went wrong
        return false;
    }
    
    SIPX_INFO hInfo = (SIPX_INFO)pSipMessage->getResponseListenerData();
    if (hInfo)
    {
        SIPX_INFOSTATUS_INFO infoStatus;
        
        memset((void*) &infoStatus, 0, sizeof(SIPX_INFOSTATUS_INFO));
        infoStatus.nSize = sizeof(SIPX_INFOSTATUS_INFO);
        infoStatus.responseCode = pSipMessage->getResponseStatusCode();
        infoStatus.event = INFOSTATUS_RESPONSE;
        
        infoStatus.hInfo = hInfo;
        SIPX_INFO_DATA* pInfoData = sipxInfoLookup(hInfo, SIPX_LOCK_READ, stackLogger);

        if(pInfoData)
        {
            
            int statusCode = pSipMessage->getResponseStatusCode();
            if (statusCode < 400)
            {
                infoStatus.status = SIPX_MESSAGE_OK;
            }
            // May want to add special case for authentication
            //else if(statusCode == HTTP_PROXY_UNAUTHORIZED_CODE || statusCode == HTTP_UNAUTHORIZED_CODE)
            //{
            //    infoStatus.status = 
            //}
            else if (statusCode < 500)
            {
                infoStatus.status = SIPX_MESSAGE_FAILURE;
            }
            else if (statusCode < 600)
            {
                infoStatus.status = SIPX_MESSAGE_SERVER_FAILURE;
            }
            else 
            {
                infoStatus.status = SIPX_MESSAGE_GLOBAL_FAILURE;
            }
            
            UtlString sResponseText;
            pSipMessage->getResponseStatusText(&sResponseText);
            infoStatus.szResponseText = sResponseText.data();
            
            UtlVoidPtr* ptr = NULL;
            OsLock eventLock(*g_pEventListenerLock) ;
            UtlSListIterator eventListenerItor(*g_pEventListeners);
            while ((ptr = (UtlVoidPtr*) eventListenerItor()) != NULL)
            {
                EVENT_LISTENER_DATA *pData = (EVENT_LISTENER_DATA*) ptr->getValue();
                if (pData)
                {
                    if(pInfoData->pInst == pData->pInst)
                    {
                        pData->pCallbackProc(EVENT_CATEGORY_INFO_STATUS, &infoStatus, pData->pUserData);
                    }
                }
                else
                {
                    OsSysLog::add(FAC_SIPXTAPI, PRI_ERR,
                            "SipXMessageObserver::handleIncomingInfoStatus NULL pData  in listener");
                }
            }

            // I think the following is incorrect.  I think this is not added as a global mssage observer, only
            // as an obsever to individual transactions when the INFO is sent.  So this is not needed.
            pInfoData->pInst->pSipUserAgent->removeMessageObserver(*(this->getMessageQueue()), (void*)hInfo);
            
            // release lock
            sipxInfoReleaseLock(pInfoData, SIPX_LOCK_READ, stackLogger);
        }

        // If an INFO was resent with auth credentials, don't remove the INFO object.  Wait
        // for the response to the resend.
        if(messageType != SipMessageEvent::AUTHENTICATION_RETRY)
        {
            // info message has been handled, so go ahead and delete the object    
            sipxInfoObjectFree(hInfo);
        }
     }
     return true;
}
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.setResponseData(pMessage, 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(lineId.data(), requestUri) ; 
        
        //if (0 != hLine)
        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_INFO infoData;
            
            infoData.nSize = sizeof(SIPX_INFO_INFO);
            infoData.hCall = hCall;
            infoData.hLine = hLine;
            Url fromUrl;
            
            infoData.szFromURL = lineId.data();
            infoData.nContentLength = pMessage->getContentLength();
            
            // get and set the content type
            UtlString contentType;
            pMessage->getContentType(&contentType) ;
            infoData.szContentType = contentType.data();
            
            // get the user agent
            UtlString userAgent;
            pMessage->getUserAgentField(&userAgent);
            infoData.szUserAgent = userAgent.data();
            
            // get the content
            UtlString body;
            int dummyLength = pMessage->getContentLength();
            const HttpBody* pBody = pMessage->getBody();
            pBody->getBytes(&body, &dummyLength);    
            infoData.pContent = body.data();
            
            UtlVoidPtr* ptr = NULL;
	        OsLock eventLock(*g_pEventListenerLock) ;
            UtlSListIterator eventListenerItor(*g_pEventListeners);
            while ((ptr = (UtlVoidPtr*) eventListenerItor()) != NULL)
            {
                EVENT_LISTENER_DATA *pData = (EVENT_LISTENER_DATA*) ptr->getValue();
                if (pData->pInst == pInst)
                {
                    pData->pCallbackProc(EVENT_CATEGORY_INFO, &infoData, pData->pUserData);
                }
            }
            
            bRet = true;
        } // if (0 != hLine)
    } // if (NULL != pInst && NULL != pMessage)
    return bRet;
}