Ejemplo n.º 1
0
void ofxRemoteUIClient::updateAutoDiscovery(float dt){

	bool neigbhorChange = false;
	bool neighborJustLaunched = false;
	//listen for broadcast from all servers in the broadcast channel OFXREMOTEUI_BROADCAST_PORT
	while( broadcastReceiver.hasWaitingMessages() ){// check for waiting messages from client
		ofxOscMessage m;
		broadcastReceiver.getNextMessage(&m);
		neigbhorChange |= closebyServers.gotPing( m.getRemoteIp(), m.getArgAsInt32(0)/*port*/, m.getArgAsString(1), m.getArgAsString(2));
		//read the broadcast sequence number
		int broadcastSequenceNumber = m.getArgAsInt32(3);
		neighborJustLaunched = (broadcastSequenceNumber == 0); //keep track of just launched apps
		if(neighborJustLaunched){
			if(callBack != NULL){
				RemoteUIClientCallBackArg cbArg; // to notify our "delegate"
				cbArg.action = NEIGHBOR_JUST_LAUNCHED_SERVER;
				cbArg.host = m.getRemoteIp();
				cbArg.port = m.getArgAsInt32(0);
				callBack(cbArg);
			}
		}
		//cout << "got broadcast message from " << m.getRemoteIp() << ":" << m.getArgAsInt32(0) << endl;
		//closebyServers.print();
	}

	neigbhorChange |= closebyServers.update(dt);

	if(neigbhorChange){
		if(callBack != NULL){
			RemoteUIClientCallBackArg cbArg; // to notify our "delegate"
			cbArg.action = NEIGHBORS_UPDATED;
			callBack(cbArg);
		}
	}
}
Ejemplo n.º 2
0
void StatusUpdateRequest::finalize()
{
	if(!success) {
		twitObj->getLastCurlError( replyMsg );
		LOG4CXX_ERROR(logger, user << " - Curl error: " << replyMsg );
		callBack(user, replyMsg);
	} else {
		std::string error = getErrorMessage(replyMsg);
		if(error.length()) LOG4CXX_ERROR(logger, user << " - " << error)
		else LOG4CXX_INFO(logger, "Updated status for " << user << ": " << data);
		callBack(user, error);
	}
}
Ejemplo n.º 3
0
void ProfileImageRequest::finalize()
{
	Error errResponse;
	if(!success) {
		LOG4CXX_ERROR(logger,  user << " - " << error);
		img = "";
		errResponse.setMessage(error);
		callBack(user, buddy, img, reqID, errResponse);
	} else {
		LOG4CXX_INFO(logger, user << " - " << callbackdata);
		img = callbackdata;
		callBack(user, buddy, img, reqID, errResponse);
	}
}
Ejemplo n.º 4
0
void DestroyFriendRequest::finalize()
{
	Error error;
	if(!success) {
		std::string curlerror;
		twitObj->getLastCurlError(curlerror);
		error.setMessage(curlerror);
		LOG4CXX_ERROR(logger, user << " Curl error: " << curlerror);
		callBack(user, friendInfo, error);
	} else {
		error = getErrorMessage(replyMsg);
		if(error.getMessage().length()) LOG4CXX_ERROR(logger, user << " - " << error.getMessage());
		callBack(user, friendInfo, error);
	}
}
Ejemplo n.º 5
0
void FetchFriends::finalize()
{
	Error error;
	if(!success) {
		std::string curlerror;
		twitObj->getLastCurlError(curlerror);
		error.setMessage(curlerror);	
		LOG4CXX_ERROR(logger,  user << " - " << curlerror)
		callBack(user, friends, friendAvatars, error);
	} else {
		error = getErrorMessage(replyMsg);
		if(error.getMessage().length()) LOG4CXX_ERROR(logger,  user << " - " << error.getMessage())
		callBack(user, friends, friendAvatars, error);	
	} 
}
Ejemplo n.º 6
0
 void CallBackOperation::operationOnCompletion(const Operation::Ptr& operation, OperationResultType type)
 {
     (void)type;
     (void)operation;
     assert(operation.get() == this);
     callBack();
 }
Ejemplo n.º 7
0
void DirectMessageRequest::finalize()
{
	Error error;
	if(!success) {
		std::string curlerror;
		twitObj->getLastCurlError(curlerror);
		error.setMessage(curlerror);	
		LOG4CXX_ERROR(logger, user << " Curl error: " << curlerror);
		callBack(user, username, messages, error);
	} else {
		error = getErrorMessage(replyMsg);
		if(error.getMessage().length()) LOG4CXX_ERROR(logger,  user << " - " << error.getMessage())
		else LOG4CXX_INFO(logger, user << " - " << replyMsg)
		callBack(user, username, messages, error);	
	}
}
// ---------------------------------------------------------------------------
// CDTMFPayloadFormatWrite::HandleControlChar
// Takes care of handling 'p' and 'w' chars in a DTMF string.
// ---------------------------------------------------------------------------
//
void CDTMFPayloadFormatWrite::HandleControlChar( const TChar& aChar )
    {
    if ( 'p' == aChar )
        {
        // 'p' char is interpreted as a 2.5 second pause
        DP_DTMF_WRITE( _L("CDTMFPayloadFormatWrite::HandleControlChar - PAUSE DETECTED") );
        iSendTimer->Cancel();
        iStateMachine->ChangeStateTo( EStateSendPaused );
        TCallBack callBack( HandleTimerEventL, this );
        iSendTimer->Start( 
            TTimeIntervalMicroSeconds32( KDTMFPauseLengthInUs ),
            TTimeIntervalMicroSeconds32( KDTMFPauseLengthInUs ), 
            callBack );
        }
    else if ( 'w' == aChar )
        {
        // Stop in a DTMF string
        DP_DTMF_WRITE( _L("CDTMFPayloadFormatWrite::HandleControlChar - STOP DETECTED ") );

        if ( iNotifyStopReq )
            {
            iSendTimer->Cancel();
            iStateMachine->ChangeStateTo( EStateSendStopped );

            SendEventSignalToClient( KMccDtmfStopInDtmfString );
            }
        }
    else
        {
        // not a control character
        }
    }
Ejemplo n.º 9
0
void CMenu::handleKeyRelease(uint8_t key)
{
    Serial.print("key pressed: "); Serial.println(key);

    if (key == 1) // Go up
    {
        if (activeItem == firstItem)
        {
            // Wrap to end
            while (activeItem->next)
                activeItem = activeItem->next;
        }
        else
        {
            SMenuItem *it = firstItem;
            while (it->next && (it->next != activeItem))
                it = it->next;
            if (it)
                activeItem = it;
        }
        markDirty();
    }
    else if (key == 2) // Go down
    {
        activeItem = activeItem->next;
        if (!activeItem)
            activeItem = firstItem;
        markDirty();
    }
    else // Activate
    {
        if (callBack)
            callBack(activeItem);
    }
}
Ejemplo n.º 10
0
void TestFindingL(CContactDatabase& aDb)
	{
	test.Next(_L("Test FindLC"));

	syncChecker->SetValidateResponseL(MContactSynchroniser::ERead,KErrLocked);
	syncChecker->SetValidateResponseL(MContactSynchroniser::ESearch,KErrLocked);
	
	CContactItemFieldDef* fieldDef=new(ELeave) CContactItemFieldDef;
	CleanupStack::PushL(fieldDef);
	fieldDef->AppendL(KUidContactFieldFamilyName); 
	
	
	TRAPD(err,TestFindL(aDb, KGivenEditName, fieldDef, test) );
	test(err==KErrLocked);
	CleanupStack::PopAndDestroy(fieldDef);

	CContactItemFieldDef* fieldDef2=new(ELeave) CContactItemFieldDef;
	CleanupStack::PushL(fieldDef2);
	fieldDef2->AppendL(KUidContactFieldPhoneNumber); 
	TRAP(err, TestFindL(aDb, KTelephoneNum, fieldDef2, test) );
	test(err==KErrLocked);
	CleanupStack::PopAndDestroy(fieldDef2);

	test.Next(_L("Test FindInTextDefL"));

	TCallBack callBack(findWordSplitterL);
	CContactTextDef* textDef=CContactTextDef::NewLC();
	textDef->AppendL(TContactTextDefItem(KUidContactFieldFamilyName));
	CDesCArray* desArray = new(ELeave) CDesCArrayFlat(5);
	desArray->AppendL(_L("e"));
	
	CContactIdArray* arr = NULL;
	TRAP(err,arr = TestFindInTextDefL(aDb,*desArray,textDef, callBack, test) );
	
//	test(err==KErrLocked);
	desArray->Delete(0);
	delete desArray;
//FIX
	delete arr;	
	CleanupStack::PopAndDestroy(textDef); 

	test.Next(_L("Test FindInTextDefL2"));

	TCallBack callBack2(findWordSplitterL);
	CContactTextDef* textDef2=CContactTextDef::NewLC();
	textDef2->AppendL(TContactTextDefItem(KUidContactFieldFamilyName));
	textDef2->AppendL(TContactTextDefItem(KUidContactFieldUrl));
	CDesCArray* desArray2 = new(ELeave) CDesCArrayFlat(5);
	desArray2->AppendL(_L("e"));
	
	TRAP(err,arr = TestFindInTextDefL(aDb,*desArray2,textDef2, callBack2, test) );
//	test(err==KErrLocked);
	desArray2->Delete(0);
	delete desArray2;
//FIX
	delete arr;	
	CleanupStack::PopAndDestroy(textDef2);
	}
Ejemplo n.º 11
0
BSPSector* BSP::sectorCallBack(BSPSector* sector, engine::IBSPSectorCallBack callBack, void* data)
{
    if( sector->_leftSubset )
    {
        if( !sectorCallBack( sector->_leftSubset, callBack, data ) ) return NULL;
        return sectorCallBack( sector->_rightSubset, callBack, data );
    }
    return ( callBack( sector, data ) ? sector : NULL );
}
Ejemplo n.º 12
0
void FcmPushClient::executeCallBacks()
{

    while (!callBacksQueue.empty()){
        callBack(callBacksQueue.front());
        callBacksQueue.pop();
    }

}
void TestFindInTextDefLC(CContactDatabase& aDb, TContactItemId aIccId, TContactItemId aNonIccId)
	{
	test.Next(_L("Test FindInTextDefLC"));
	// Successful find of icc entry
	syncChecker->SetValidateResponseL(MContactSynchroniser::ESearch,KErrNone);
	syncChecker->SetValidateResponseL(MContactSynchroniser::ERead,KErrNone);

	TCallBack callBack(findWordSplitterL);
	CContactTextDef* textDef=CContactTextDef::NewLC();
	textDef->AppendL(TContactTextDefItem(KUidContactFieldFamilyName));
	CDesCArray* desArray = new(ELeave) CDesCArrayFlat(5);
	desArray->AppendL(_L("icc"));
	syncChecker->ResetMethodCallCountsL();
	CContactIdArray* array = aDb.FindInTextDefLC(*desArray,textDef,callBack);
	//test(syncChecker->ValidateMethodCallCountL() == 3);
	test(array!=NULL);
	test(array->Count() == 1);
	test((*array)[0]==aIccId);
	CleanupStack::PopAndDestroy(array);
	array=NULL;

	test.Next(_L("Test searching when ICC locked"));
	// Unsuccessful find of icc entry because icc locked
	syncChecker->SetValidateResponseL(MContactSynchroniser::ESearch,KErrLocked);
	syncChecker->ResetMethodCallCountsL();
	TRAPD(err,array = aDb.FindInTextDefLC(*desArray,textDef,callBack));
	test(syncChecker->ValidateMethodCallCountL() == 1);
	test(err==KErrLocked);
	test(array==NULL);
	desArray->Delete(0);
	delete desArray;

	// successful find of non-icc entry, even though icc locked
	CDesCArray* desArray2 = new(ELeave) CDesCArrayFlat(5);
	desArray2->AppendL(_L("non-icc"));
	syncChecker->ResetMethodCallCountsL();
	array = aDb.FindInTextDefLC(*desArray2,textDef,callBack);
	test(syncChecker->ValidateMethodCallCountL() == 0);
	test(array!=NULL);
	test(array->Count() == 1);
	test((*array)[0]==aNonIccId);

	// both the icc and non-icc entry should match the search criteria, but only the
	// non-icc entry should be returned since icc is locked
	SetNameField(aDb,aIccId,KNonIccName);
	syncChecker->ResetMethodCallCountsL();
	TRAP(err,array = aDb.FindInTextDefLC(*desArray2,textDef,callBack));
	test(syncChecker->ValidateMethodCallCountL() == 1);
	test(err==KErrLocked);
	test(array!=NULL);
	test(array->Count() == 1);
	test((*array)[0]==aNonIccId);
	desArray2->Delete(0);
	delete desArray2;
	SetNameField(aDb,aIccId,KIccName);
	CleanupStack::PopAndDestroy(2,textDef); // array, textDef
	}
void CMMFAudioPolicyServer::ConstructL()
	{
	// Create AudioPolicy singleton
	iAudioPolicy = CAudioPolicy::NewL(this);
	TCallBack callBack(SendNotification,this);
	iNotificationTimer = CNotificationTimer::NewL(callBack);
	// Call base class to Start server
	StartL(KNullDesC);
	}
// ---------------------------------------------------------------------------
// CDTMFPayloadFormatWrite::DoToneOffActionsL
// Called by sendtimer. Does actions belonging to tone off state and exits
// state when exit conditions are met. Actions include: sending final packets.
// ---------------------------------------------------------------------------
//
void CDTMFPayloadFormatWrite::DoToneOffActionsL( TBool aEntryToState )
    {
    DP_DTMF_WRITE2( _L("CDTMFPayloadFormatWrite::DoToneOffActionsL, tick = %u"), 
        User::NTickCount() );

    #ifdef VOIP_TRACE_ENABLED
        VoipTrace( "%x %x", MCC_TRACE, MCC_DTMF_PLF_WRITE_SENDFINALPKT );
    #endif
    
    if ( aEntryToState )
        {
        iSendTimer->Cancel();
        iFinalPacketCtr = 0;
        
        TCallBack callBack( HandleTimerEventL, this );
        iSendTimer->Start(
            TTimeIntervalMicroSeconds32( iCInfo.iPtime * KFactor1000 ),
            TTimeIntervalMicroSeconds32( iCInfo.iPtime * KFactor1000 ),
            callBack );
        }
    else
        {
        iFinalPacketCtr++;
        if ( KNumOfFinalPackets >= iFinalPacketCtr )
            {
            DeliverPacketL( *iSinkBuffer, EFalse );
            }
        else
            {
            TUint curOffDur = iFinalPacketCtr * iCInfo.iPtime * KFactor1000;
            if ( EModeManual == iSendingMode || 
                 KDTMFDefToneOffLengthInUs <= curOffDur )
                {
                // Prevent audio sending during final packet retransmission by
                // sending completion event only when also retransmissions are
                // done.
                if ( EModeManual == iSendingMode )
                    {
                    SendEventSignalToClient( KMccDtmfManualStop );
                    }
                else
                    {
                    SendEventSignalToClient( KMccDtmfSequenceStop );
                    }
                
                iSendTimer->Cancel();
                iFinalPacketCtr = 0;
                if ( iSendBuffer.Count() > 0 )
                	{
                	iSendBuffer.Remove( 0 );	
                	}
                iStateMachine->ChangeStateTo( EStateEncodeNextDigit );
                }
            }
        }
    }
Ejemplo n.º 16
0
TRIGGER( use )(obj user)
{
  int Q5DQ;
  loc Q59R = loc( getLocation(this) );
  loc Q5H8 = loc( getLocation(user) );
  if(getDistanceInTiles(Q59R, Q5H8) > 0x02)
  {
    ebarkTo(user, user, "If you had been closer, you might have stepped in and met a gruesome fate!");
    return(0x00);
  }
  if(hasObjVar(this, "MaidenWorking"))
  {
    return(0x00);
  }
  if(hasObjVar(this, "MaidenClosed"))
  {
    setType(this, 0x1249);
    removeObjVar(this, "MaidenClosed");
    setObjVar(this, "MaidenOpen", Q5DQ);
    callBack(this, 0x0A, 0x01);
    ebarkTo(user, user, "Hmm... you suspect that if you used this again, it might hurt.");
    return(0x00);
  }
  if(hasObjVar(this, "MaidenOpen"))
  {
    setType(this, 0x124B);
    removeObjVar(this, "MaidenOpen");
    setObjVar(this, "MaidenWorking", Q5DQ);
    callBack(this, 0x01, 0x03);
    callBack(this, 0x05, 0x02);
    int Q69K = getX(Q59R) + 0x01;
    int Q69T = getY(Q59R) + 0x01;
    int Q6A2 = getZ(Q59R);
    loc Q63E = loc( Q69K, Q69T, Q6A2 );
    if(!teleport(user, Q59R))
    {
    }
    loseHP(user, dice(0x0A, 0x03));
    return(0x01);
  }
  return(0x00);
}
Ejemplo n.º 17
0
//////////////////////////////////////////////////////////////
//
//	This function checks for a mouse press
//
//////////////////////////////////////////////////////////////
void TextString::checkMouse(int x, int y, int button, void callBack())
{
	//	we need to check the bounds of the object with the
	//	mouse coordinates, returns true if it is within bounds
	//	false if not.
	if (x > fontPosition.x && x < fontPosition.x + (getCalculatedSize().width))
	{
		if (y > fontPosition.y && y < fontPosition.y + (getCalculatedSize().height))
		{
			callBack();
		}
	}
}
Ejemplo n.º 18
0
void CacheController::_updateCacheByQuery(dbQuery& q, 
	void(*callBack)(T*, void* param), 
	void* param, 
	void(*updateSuccessed)(T*, void* param),
	void(*updateFailed)(T*, void* param)
	) {
	TIME_COST_BEGIN("Update Cache...");
	T* tempCache = NULL;
	try {	
		dbCursor<T> cursor(dbCursorForUpdate);

		int resultLine = cursor.select(q);
		cout << "Need to update " << resultLine << " lines in Cache - " << T::TABLE_NAME<< endl;

		do {
			T* cache = cursor.get();
			tempCache = cache;
			if (cache && callBack) {
				T oldCache = *cache;
				callBack(cache, param);	 
				
				cursor.update();	 
				int effectedLines = updateDiskDB(cache, &oldCache);
				assert(effectedLines <= 1);
				if (effectedLines == 1)
				{
					commit();
					if (updateSuccessed)
					{
						updateSuccessed(cache, param);
					}
				}
				else
				{
					rollback();
					if (updateFailed)
					{
						updateFailed(cache, param);
					}
				}
			}
		} while (cursor.next());
	} catch (dbException e) {
		cout << e.getMsg() << endl;
		updateFailed(tempCache, param);
	}
	TIME_COST_END("Update Cache...");
}
Ejemplo n.º 19
0
GLDEF_C void doDoFindInTextDefTestL(CDesCArray *aFindWords, CContactTextDef *aTextDef, CContactIdArray* aResultIds)
	{
	TCallBack callBack(findWordSplitterL);
	CAsyncFinder *finder=new(ELeave) CAsyncFinder;
	CleanupStack::PushL(finder);
	finder->ConstructL(CntTest->Db(),*aFindWords,aTextDef,callBack);
	runAsyncFindL(finder, aResultIds);
	CleanupStack::PopAndDestroy(); // finder
//
	CContactIdArray* ids=NULL;
	if (aTextDef)
		ids=CntTest->Db()->FindInTextDefLC(*aFindWords,aTextDef,callBack);
	else
		ids=CntTest->Db()->FindInTextDefLC(*aFindWords,callBack);
	CheckResult(ids,aResultIds);
	CleanupStack::PopAndDestroy(); // ids
	}
Ejemplo n.º 20
0
// This delay function gives opportunity for the scheduler to run other
// active objects. The use of this function also ensures that all requests
// are completed within the test function.
void UT_CRtpComm::DelayL()
	{
	// set the end condition into false
	iCallBackCalled = EFalse;

	// set a timer for the test
	TCallBack callBack( StopScheduler, this );
	iTimer->Start( KTimerDelay, KTimerDelay, callBack );

	// wait for completion
	CActiveScheduler::Start();

	// cancel requests
	iTimer->Cancel();

	EUNIT_ASSERT( iCallBackCalled );
	}    
Ejemplo n.º 21
0
void CacheController::_traverseCacheByQuery(dbQuery& q, void(*callBack)(T*, void* param), void* param) {
    try {	
        dbCursor<T> cursor(dbCursorViewOnly);

     	TIME_COST_BEGIN("Get Cache...");
        int resultLine = cursor.select(q);
        cout << "Get Cache... - Results Lines: " << resultLine	<< endl;
		TIME_COST_END("Get Cache...");

        do {
            T* cache = cursor.get();
            if (cache && callBack) {
                callBack(cache, param);
            }
        } while (cursor.next());
    } catch (dbException e) {
        cout << e.getMsg() << endl;
    }
}
Ejemplo n.º 22
0
void RoundPageScrollView::update(float dt)
{
    int calId = calCurrId();
    if(currId != calId)
    {
        callBack(calId);
        currId = calId;
    }
    
    if(!isTouchMoving)
    {
        if(defaultAction)
        {
            easing(desW);
        }
        else
        {
            if(!isOpen)
            {
                radius = radius>80 ? radius-5 : 80;
                nodeScaleControll = nodeScaleControll>0.21? nodeScaleControll-0.04 : 0.2;
            }
            else
            {
                radius = radius<Radius ? radius+5 : Radius;
                nodeScaleControll = nodeScaleControll<1? nodeScaleControll+0.05 : 1;
                if(radius == Radius && nodeScaleControll == 1)
                {
                    setTouchEnabled(true);
                    defaultAction = true;
                    v0 = 0;
                    calDesW();
                }
            }
            //CCLog(PH::toStr(nodeScaleControll).c_str());
            w += 0.25*(dt*60);
        }
    }
    
    updatePos();
    render();
}
Ejemplo n.º 23
0
void ofxRemoteUIClient::updateAutoDiscovery(float dt){

	bool neigbhorChange = false;
	//listen for broadcast from all servers in the broadcast channel OFXREMOTEUI_BROADCAST_PORT
	while( broadcastReceiver.hasWaitingMessages() ){// check for waiting messages from client
		ofxOscMessage m;
		broadcastReceiver.getNextMessage(&m);
		neigbhorChange |= closebyServers.gotPing(m.getRemoteIp(), m.getArgAsInt32(0), m.getArgAsString(1), m.getArgAsString(2));
		//cout << "got broadcast message from " << m.getRemoteIp() << ":" << m.getArgAsInt32(0) << endl;
		//closebyServers.print();
	}

	neigbhorChange |= closebyServers.update(dt);

	if(neigbhorChange){
		if(callBack != NULL){
			RemoteUIClientCallBackArg cbArg; // to notify our "delegate"
			cbArg.action = NEIGHBORS_UPDATED;
			callBack(cbArg);
		}
	}
}
Ejemplo n.º 24
0
// Initial object setup
void CMediaClientAppUi::ConstructL() 
    {
    BaseConstructL();

	// set up view
    iAppView = CMediaClientView::NewL(ClientRect(), MediaClientEngine());
	iAppView -> SetDescription(KIdle);
    AddToStackL(iAppView); // app view should go onto control stack

	// set up filename buffer
	_LIT(KDefault,"c:\\");
    iFileName = KDefault;

	// set up link to engine
	MediaClientEngine().SetObserver(*this);
	iState = CMediaClientEngine::EIdle;

	// An asychronous call back object used to exit when a stream is playing
	// This allows media server time to clean up stream
	TCallBack callBack(CMediaClientAppUi::DoExit, this);
	iExitCallBack = new (ELeave) CAsyncCallBack(callBack,CActive::EPriorityLow);
    }
Ejemplo n.º 25
0
TRIGGER( use )(obj user)
{
  if(Q4BL(user, "The blacksmith skill", 0x00))
  {
    return(0x00);
  }
  if(hasObjVar(this, "inUse"))
  {
    systemMessage(user, "That is being used by someone else.");
    return(0x00);
  }
  else
  {
    setObjVar(this, "inUse", 0x00);
    callBack(this, 0x3C, 0x1B);
  }
  Q62D = user;
  systemMessage(user, "What would you like to do?");
  loc Q66U = loc( getLocation(user) );
  int Q4Q1;
  list Q5FD;
  int Q5E6;
  int Q620;
  int i;
  if(Q4ZM(user))
  {
    int Q5TE = getSkillLevelReal(user, 0x07);
    int Q56Z = Q4TF(user);
    clearList(Q5NZ);
    int Q5Z4 = Q4DY(Q56Z, Q5TE + 0xFA, 0x00, 0x00);
    Q5QT(user, "What would you like to do?");
  }
  else
  {
    cleanup();
  }
  return(0x00);
}
Ejemplo n.º 26
0
void PageScrollView::update(float dt)
{
    if(!isTouchMoving){
        int currId = getCurrentNodeId();
        if(PH::easing(content , getTargetPos()) && currIdCashe != currId)
        {
            callBack(nodes[currId]);
            currIdCashe = currId;
        }
	}

	if(isShowOne && !isViewStop){
        for(boost::container::flat_map<int, cocos2d::CCSprite*>::iterator it = nodes.begin() ; it != nodes.end() ; it++)
            it->second->setOpacity(0);
        
		float tp = -page.width*getCurrentNodeId();
		float cp = content->getPositionX();
		float temp = abs(tp - cp)/page.width;
        int id = getCurrentNodeId();
		nodes[id]->setOpacity(255*(1-temp));
		if(id < size-1 && cp < tp)nodes[id+1]->setOpacity(255*temp);
		if(id > 0 && cp > tp)nodes[id-1]->setOpacity(255*temp);
	}
}
Ejemplo n.º 27
0
ForkDesc *
FindLeastUsedThread(int type, int maxCount, int minPri, int *prand, int nopass, int (*callBack)(void *cbData, void *data), void *cbData)
{
    int i = -1;
    int j;
    ForkDesc *best = NULL;

    /*
     * 'random' start (actually sequential), if requested
     */

    if (prand) {
	i = *prand;
	if (i < 0 || i >= MaxFds)
	    i = -1;
    }

    if (nopass >= MaxFds)
	nopass = MaxFds - 1;

    /*
     * Scan through all available descriptors starting at position i.
     * Locate the best descriptor that meets our requirements.
     */

    for (j = 0; j < MaxFds; ++j) {
	ForkDesc *desc;

	i  = (i + 1) % MaxFds;

	/*
	 * nopass is used when scanning servers at the same priority, so we
	 * know when we've looped.
	 */

	if (i == nopass)
	    break;

	if ((desc = FDes[i]) != NULL && 
	    desc->d_Type == type &&
	    desc->d_Count < maxCount &&
	    (callBack == NULL || callBack(cbData, desc->d_Data)) &&
	    ((nopass < 0 && desc->d_Pri >= minPri) || desc->d_Pri == minPri)
	) {
	    if (best == NULL) {
		/*
		 * found at least one
		 */
		best = desc;
		if (prand != NULL)
		    *prand = i;
	    } else if (desc->d_Pri < best->d_Pri) {
		/*
		 * found one with a better (lower) priority
		 */
		best = desc;
		if (prand != NULL)
		    *prand = i;
	    } else if (desc->d_Pri == best->d_Pri) {
		/*
		 * found one with a better queue count
		 */
		if (desc->d_Pri == best->d_Pri &&
		    desc->d_Count < best->d_Count
		) {
		    best = desc;
		    if (prand != NULL)
			*prand = i;
		}
	    }
	}
    }
    return(best);
}
Ejemplo n.º 28
0
// Main message pump
//-----------------------------------------------------------------------------
int CPUTWindowWin::StartMessageLoop()
{
    // Clear message queue
MSG msg;
//for(;;)
//{
//    while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
//    {
//        if (msg.message == WM_DESTROY)
//            return CPUT_ERROR;
//        TranslateMessage( &msg );
//        DispatchMessage( &msg );
    //
//    }
//}

    //
    // Message pump
    //
    bool fRunning = true;
    while(fRunning)
    {
        // PeekMessage() is a passthru on no events
        // so it allows us to render while no events are present
        if( PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) )
        {
            if (msg.message == WM_QUIT)
            {
                PostQuitMessage(0);
                fRunning = false;
            }
            TranslateMessage( &msg );
            DispatchMessage( &msg );
        }
        else if (IsWindowMinimized()) 
        {
            Sleep(100);
        }
        else
        {
            // trigger render and other calls
            for (const auto &callBack : mLoopEventCallbacks) {
                callBack();
            }
        }
    }
    Destroy();
    //
    // Drain out the rest of the message queue.
    //
    while( PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) )
    {
        TranslateMessage( &msg );
        DispatchMessage( &msg );
    }

    uint32_t numWChars = MultiByteToWideChar(CP_UTF8, 0, mAppTitle.c_str(), -1, NULL, 0);
    wchar_t* wstr = new wchar_t[numWChars];
    MultiByteToWideChar(CP_UTF8, 0, mAppTitle.c_str(), -1, wstr, numWChars);

    if (UnregisterClass(wstr, mhInstance) == 0) {
        HandleWin32Error();
    }

    delete[] wstr;

    //
    // Set the window handle to NULL to indicate window shutdown is complete
    //
    mhWnd = NULL;

    // return code
    mAppClosedReturnCode =  (int) msg.wParam;
    return mAppClosedReturnCode;
}
Ejemplo n.º 29
0
//
// WndProc
// Handles the main message loop's events/messages
//-----------------------------------------------------------------------------
LRESULT CALLBACK CPUTWindowWin::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    CPUTEventHandledCode handledCode = CPUT_EVENT_UNHANDLED;
    LRESULT res;
    static bool sizing = false;
    switch (message)
    {
    case WM_COMMAND:
    {
        int     wmId, wmEvent;
        wmId = LOWORD(wParam);
        wmEvent = HIWORD(wParam);

        // handle any menu item events here
        // see reference code in file history for examples
    }
        break;
    case WM_KEYDOWN:  // WM_KEYDOWN: gives you EVERY key - including shifts/etc
    {
        CPUTKeyState state = CPUT_KEY_DOWN;
        CPUTKey key = ConvertVirtualKeyToCPUTKey(wParam);
        if (KEY_NONE != key)
        {
            for (const auto &callBack : mKeyboardEventCallbacks) {
                handledCode = callBack(key, state);
            }
        }
    }
        break;
    case WM_KEYUP:
    {
        CPUTKeyState state = CPUT_KEY_UP;
        CPUTKey key = ConvertVirtualKeyToCPUTKey(wParam);
        if (KEY_NONE != key)
        {

            for (const auto &callBack : mKeyboardEventCallbacks) {
                handledCode = callBack(key, state);
            }
        }
    }
        break;
    case WM_CHAR:
    {
        CPUTKeyState state = CPUT_KEY_DOWN;
        CPUTKey key = ConvertCharacterToCPUTKey(wParam);
        if (KEY_NONE != key)
        {
            for (const auto &callBack : mKeyboardEventCallbacks) {
                handledCode = callBack(key, state);
            }
        }
    }
        break;
    case WM_LBUTTONDBLCLK:
    case WM_MBUTTONDBLCLK:
    case WM_RBUTTONDBLCLK:
        // handle double-click events
        break;
    case WM_LBUTTONDOWN:
    case WM_MBUTTONDOWN:
    case WM_RBUTTONDOWN:
    {
        CPUTMouseState state = ConvertMouseState(wParam);

        short xPos = LOWORD(lParam);
        short yPos = HIWORD(lParam);

        for (const auto &callBack : mMouseEventCallbacks) {
            handledCode = callBack(xPos, yPos, 0, state, CPUT_EVENT_DOWN);
        }
    }
        break;
    case WM_LBUTTONUP:
    case WM_MBUTTONUP:
    case WM_RBUTTONUP:
    {
        CPUTMouseState state = ConvertMouseState(wParam);

        short xPos = LOWORD(lParam);
        short yPos = HIWORD(lParam);

        for (const auto &callBack : mMouseEventCallbacks) {
            handledCode = callBack(xPos, yPos, 0, state, CPUT_EVENT_UP);
        }
    }
        break;
    case WM_MOUSEMOVE:
    {
        CPUTMouseState state = ConvertMouseState(wParam);

        short xPos = LOWORD(lParam);
        short yPos = HIWORD(lParam);

        for (const auto &callBack : mMouseEventCallbacks) {
            handledCode = callBack(xPos, yPos, 0, state, CPUT_EVENT_MOVE);
        }
    }
        break;

    case WM_MOUSEWHEEL:
        {
            // get mouse position
            short xPos = LOWORD(lParam);
            short yPos = HIWORD(lParam);

            // get wheel delta
            int wheel = GET_WHEEL_DELTA_WPARAM(wParam);  // one 'click'

            for (const auto &callBack : mMouseEventCallbacks) {
                handledCode = callBack(xPos, yPos, wheel, CPUT_MOUSE_WHEEL, CPUT_EVENT_WHEEL);
            }
        }
        return 0;
        break;

    case WM_PAINT:
        PAINTSTRUCT ps;
        HDC hdc;
        hdc = BeginPaint(hWnd, &ps);
        EndPaint(hWnd, &ps);
        break;
    case WM_SIZING:
        sizing = true;
        break;
    case WM_MOVING:
    case WM_ERASEBKGND:
        // overriding this to do nothing avoids flicker and
        // the expense of re-creating tons of gfx contexts as it resizes
        break;

    //case WM_ACTIVATE:
        // check for maximize/minimize
      //  break;

    case WM_SIZE:
        int width, height;
        height = HIWORD(lParam);
        width  = LOWORD(lParam);
            
        RECT windowRect;
        if(0==GetClientRect(hWnd, &windowRect)) // this gets the client area inside the window frame *excluding* frames/menu bar/etc
            break;
        width = windowRect.right - windowRect.left;
        height = windowRect.bottom - windowRect.top;

        // if we have shrunk to 0 width/height - do not pass on this kind of resize - leads to 
        // various render target resizing warnings
        if(0==width || 0==height)
        {
            break;
        }

        {
            if (!sizing)
            {
                // maximize/minimize effect
                if ((SIZE_MAXIMIZED == wParam))
                {
                    // resize for new max/min size
                    for (const auto &callBack : mResizeEventCallbacks) {
                        callBack(width, height);
                    }
                    mbMaxMinFullScreen = true;
                }
                else if (SIZE_RESTORED == wParam)
                {
                    if (true == mbMaxMinFullScreen)
                    {
                        for (const auto &callBack : mResizeEventCallbacks) {
                            callBack(width, height);
                        }
                        mbMaxMinFullScreen = false;
                    }
                    else
                    {
                        for (const auto &callBack : mResizeEventCallbacks) {
                            callBack(width, height);
                        }
                    }
                }
            }
            else
            {
                for (const auto &callBack : mResizeEventCallbacks) {
                    callBack(width, height);
                }
            }
        }
        break;
    
    case WM_EXITSIZEMOVE:
        sizing = false;
        // update the system's size and make callback
        {
            RECT windowRect;
            if(0==GetClientRect(hWnd, &windowRect)) // this gets the client area inside the window frame *excluding* frames/menu bar/etc
                break;

            width = windowRect.right - windowRect.left;
            height = windowRect.bottom - windowRect.top;

            // if we have shrunk to 0 width/height - do not pass on this kind of resize - leads to 
            // various render target resizing warnings
            if(0==width || 0==height)
            {
                break;
            }
            for (const auto &callBack : mResizeEventCallbacks) {
                callBack(width, height);
            }
        }
        break;


    case WM_DESTROY:
        // time to shut down the system
        PostQuitMessage(0);
        break;

    default:
        // we don't handle it - pass it on thru to parent
        res = DefWindowProc(hWnd, message, wParam, lParam);
        return res;
    }

    // translate handled code
    if(CPUT_EVENT_HANDLED == handledCode)
    {
        return 1;
    }

    return 0;
}
Ejemplo n.º 30
0
void QuetzalChoiceDialog::onCancelClicked()
{
	callBack(m_cancel_cb);
	m_cancel_cb = NULL;
	quetzal_request_close(PURPLE_REQUEST_INPUT, this);
}