Esempio n. 1
0
void wxSocketImplUnix::OnWriteWaiting()
{
    wxASSERT_MSG( m_fd != INVALID_SOCKET, "invalid socket ready for writing?" );

    // see comment in the beginning of OnReadWaiting() above
    DisableEvents(wxSOCKET_OUTPUT_FLAG);


    // check whether this is a notification for the completion of a
    // non-blocking connect()
    if ( m_establishing && !m_server )
    {
        m_establishing = false;

        // check whether we connected successfully
        int error;
        SOCKOPTLEN_T len = sizeof(error);

        getsockopt(m_fd, SOL_SOCKET, SO_ERROR, (char*)&error, &len);

        if ( error )
        {
            OnStateChange(wxSOCKET_LOST);
            return;
        }

        OnStateChange(wxSOCKET_CONNECTION);
    }

    OnStateChange(wxSOCKET_OUTPUT);
}
Esempio n. 2
0
    void UpdateEvent() override
    {
        auto state = getData(MAP_VIOLET_HOLD);

        if (state != m_lastState)
        {
            OnStateChange(m_lastState, state);
            m_lastState = state;
        }

        switch (state)
        {
            case NotStarted:
                S0_ReviveGuards();
                S0_SpawnIntroMobs();
                S0_RemoveDeadIntroMobs();
                break;
            case InProgress:
                S2_SpawnPortals();
                break;
            case Finished: printf("State: %s\n", "State_Finished"); break;
            case Performed: printf("State: %s\n", "State_Performed"); break;
            case PreProgress:
                S1_ActivateCrystalFleeRoom();
                break;
        }
    }
Esempio n. 3
0
/* void closeProgressDialog (in boolean forceClose); */
NS_IMETHODIMP nsPrintProgress::CloseProgressDialog(bool forceClose)
{
    m_closeProgress = true;
    // XXX Invalid cast of bool to nsresult (bug 778106)
    return OnStateChange(nullptr, nullptr, nsIWebProgressListener::STATE_STOP,
                         (nsresult)forceClose);
}
Esempio n. 4
0
/* void closeProgressDialog (in boolean forceClose); */
NS_IMETHODIMP nsPrintProgress::CloseProgressDialog(bool forceClose)
{
  m_closeProgress = true;
  // XXX Casting bool to nsresult
  return OnStateChange(nullptr, nullptr, nsIWebProgressListener::STATE_STOP,
                       static_cast<nsresult>(forceClose));
}
void CNetworkConnection::initializeSocket()
{
	m_pSocket->disconnect();

	connect(m_pSocket, SIGNAL(connected()),
			this, SIGNAL(connected()));
	connect(m_pSocket, SIGNAL(connected()),
			this, SIGNAL(readyToTransfer()));
	connect(m_pSocket, SIGNAL(readyRead()),
			this, SIGNAL(readyToTransfer()));
	connect(m_pSocket, SIGNAL(disconnected()),
			this, SIGNAL(disconnected()));
	connect(m_pSocket, SIGNAL(error(QAbstractSocket::SocketError)),
			this, SIGNAL(error(QAbstractSocket::SocketError)));
	connect(m_pSocket, SIGNAL(bytesWritten(qint64)),
			this, SIGNAL(bytesWritten(qint64)));
	connect(m_pSocket, SIGNAL(stateChanged(QAbstractSocket::SocketState)),
			this, SIGNAL(stateChanged(QAbstractSocket::SocketState)));
	connect(m_pSocket, SIGNAL(aboutToClose()),
			this, SLOT(OnAboutToClose()));

	connect(this, SIGNAL(connected()), this, SLOT(OnConnect()), Qt::QueuedConnection);
	connect(this, SIGNAL(disconnected()), this, SLOT(OnDisconnect()), Qt::QueuedConnection);
	connect(this, SIGNAL(readyRead()), this, SLOT(OnRead()), Qt::QueuedConnection);
	connect(this, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(OnError(QAbstractSocket::SocketError)), Qt::QueuedConnection);
	connect(this, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(OnStateChange(QAbstractSocket::SocketState)), Qt::QueuedConnection);
}
Esempio n. 6
0
void cUIMenuSubMenu::SetTheme( cUITheme * Theme ) {
	cUIMenuItem::SetTheme( Theme );

	mSkinArrow		= Theme->GetByName( Theme->Abbr() + "_" + "menuarrow" );

	OnStateChange();
}
Esempio n. 7
0
NS_IMETHODIMP nsPrintProgress::SetProcessCanceledByUser(bool aProcessCanceledByUser)
{
    if(m_PrintSetting)
        m_PrintSetting->SetIsCancelled(true);
    m_processCanceled = aProcessCanceledByUser;
    OnStateChange(nullptr, nullptr, nsIWebProgressListener::STATE_STOP, NS_OK);
    return NS_OK;
}
NS_IMETHODIMP nsPrintProgress::SetProcessCanceledByUser(PRBool aProcessCanceledByUser)
{
  if(m_PrintSetting)
    m_PrintSetting->SetIsCancelled(PR_TRUE);
  m_processCanceled = aProcessCanceledByUser;
  OnStateChange(nsnull, nsnull, nsIWebProgressListener::STATE_STOP, PR_FALSE);
  return NS_OK;
}
Esempio n. 9
0
void CG2Node::SetupSlots()
{
	connect(this, SIGNAL(connected()), this, SLOT(OnConnect()), Qt::QueuedConnection);
	connect(this, SIGNAL(disconnected()), this, SLOT(OnDisconnect()), Qt::QueuedConnection);
	connect(this, SIGNAL(readyRead()), this, SLOT(OnRead()), Qt::QueuedConnection);
	connect(this, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(OnError(QAbstractSocket::SocketError)), Qt::QueuedConnection);
	connect(this, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(OnStateChange(QAbstractSocket::SocketState)), Qt::QueuedConnection);
}
Esempio n. 10
0
void wxSocketImplUnix::OnReadWaiting()
{
    wxASSERT_MSG( m_fd != INVALID_SOCKET, "invalid socket ready for reading?" );

    // we need to disable the read notifications until we read all the data
    // already available for the socket, otherwise we're going to keep getting
    // them continuously which is worse than inefficient: as IO notifications
    // have higher priority than idle events in e.g. GTK+, our pending events
    // whose handlers typically call Read() which would consume the data and so
    // stop the notifications flood would never be dispatched at all if the
    // notifications were not disabled
    DisableEvents(wxSOCKET_INPUT_FLAG);


    // find out what are we going to notify about exactly
    wxSocketNotify notify;

    // TCP listening sockets become ready for reading when there is a pending
    // connection
    if ( m_server && m_stream )
    {
        notify = wxSOCKET_CONNECTION;
    }
    else // check if there is really any input available
    {
        switch ( CheckForInput() )
        {
            case 1:
                notify = wxSOCKET_INPUT;
                break;

            case 0:
                // reading 0 bytes for a TCP socket means that the connection
                // was closed by peer but for UDP it just means that we got an
                // empty datagram
                notify = m_stream ? wxSOCKET_LOST : wxSOCKET_INPUT;
                break;

            default:
                wxFAIL_MSG( "unexpected CheckForInput() return value" );
                wxFALLTHROUGH;

            case -1:
                if ( GetLastError() == wxSOCKET_WOULDBLOCK )
                {
                    // just a spurious wake up
                    EnableEvents(wxSOCKET_INPUT_FLAG);
                    return;
                }

                notify = wxSOCKET_LOST;
        }
    }

    OnStateChange(notify);
}
Esempio n. 11
0
void wxSocketImplUnix::OnExceptionWaiting()
{
    // when using epoll() this is called when an error occurred on the socket
    // so close it if it hadn't been done yet -- what else can we do?
    //
    // notice that we shouldn't be called at all when using select() as we
    // don't use wxFDIO_EXCEPTION when registering the socket for monitoring
    // and this is good because select() would call this for any OOB data which
    // is not necessarily an error
    if ( m_fd != INVALID_SOCKET )
        OnStateChange(wxSOCKET_LOST);
}
Esempio n. 12
0
void Dispatcher::UpdateInternalLocked(ObserverList* obs_to_remove, zx_signals_t signals) {
    ZX_DEBUG_ASSERT(is_waitable());

    for (auto it = observers_.begin(); it != observers_.end();) {
        StateObserver::Flags it_flags = it->OnStateChange(signals);
        if (it_flags & StateObserver::kNeedRemoval) {
            auto to_remove = it;
            ++it;
            obs_to_remove->push_back(observers_.erase(to_remove));
        } else {
            ++it;
        }
    }
}
Esempio n. 13
0
void wxGenericCollapsiblePane::Collapse(bool collapse)
{
    // optimization
    if ( IsCollapsed() == collapse )
        return;

    // update our state
    m_pPane->Show(!collapse);

    // update button label
    // NB: this must be done after updating our "state"
    m_pButton->SetLabel(GetBtnLabel());

    OnStateChange(GetBestSize());
}
Esempio n. 14
0
void Widget::SetState( State state ) {
	// Do nothing if state wouldn't change.
	if( m_state == state ) {
		return;
	}

	State old_state( m_state );
	m_state = state;

	// If HandleStateChange() changed the state, do not call observer, will be
	// done from there too.
	if( m_state != old_state ) {
		HandleStateChange( old_state );
		OnStateChange();
	}

	if( state == Active ) {
		GrabFocus( shared_from_this() );
	}
}
Esempio n. 15
0
void wxGenericCollapsiblePane::Collapse(bool collapse)
{
    // optimization
    if ( IsCollapsed() == collapse )
        return;

    // update our state
    m_pPane->Show(!collapse);

    // update button label
#if defined( __WXMAC__ ) && !defined(__WXUNIVERSAL__)
    m_pButton->SetOpen( !collapse );
#else
    // NB: this must be done after updating our "state"
    m_pButton->SetLabel(GetBtnLabel());
#endif


    OnStateChange(GetBestSize());
}
void RhsRobotBase::StartCompetition()			//Robot's main function
{
	DriverStation *pDS = DriverStation::GetInstance();

	Init();		//Initialize the robot

	while(true)
	{
		if(!pDS->IsNewControlData())
		{
			Wait(0.002);
			continue;
		}

		//Checks the current state of the robot
		if(IsDisabled())
		{
			currentRobotState = ROBOT_STATE_DISABLED;
		}
		else if(IsEnabled() && IsAutonomous())
		{
			currentRobotState = ROBOT_STATE_AUTONOMOUS;
		}
		else if(IsEnabled() && IsOperatorControl())
		{
			currentRobotState = ROBOT_STATE_TELEOPERATED;
		}
		else if(IsEnabled() && IsTest())
		{
			currentRobotState = ROBOT_STATE_TEST;
		}
		else
		{
			currentRobotState = ROBOT_STATE_UNKNOWN;
		}

		if(HasStateChanged())			//Checks for state changes
		{
			switch(GetCurrentRobotState())
			{
			case ROBOT_STATE_DISABLED:
				printf("ROBOT_STATE_DISABLED\n");
				robotMessage.command = COMMAND_ROBOT_STATE_DISABLED;
				//robotMessage.robotMode = ROBOT_STATE_DISABLED;
				break;
			case ROBOT_STATE_AUTONOMOUS:
				printf("ROBOT_STATE_AUTONOMOUS\n");
				robotMessage.command = COMMAND_ROBOT_STATE_AUTONOMOUS;
				//robotMessage.robotMode = ROBOT_STATE_AUTONOMOUS;
				break;
			case ROBOT_STATE_TELEOPERATED:
				printf("ROBOT_STATE_TELEOPERATED\n");
				robotMessage.command = COMMAND_ROBOT_STATE_TELEOPERATED;
				//robotMessage.robotMode = ROBOT_STATE_TELEOPERATED;
				break;
			case ROBOT_STATE_TEST:
				printf("ROBOT_STATE_TEST\n");
				robotMessage.command = COMMAND_ROBOT_STATE_TEST;
				//robotMessage.robotMode = ROBOT_STATE_TEST;
				break;
			case ROBOT_STATE_UNKNOWN:
				printf("ROBOT_STATE_UNKNOWN\n");
				robotMessage.command = COMMAND_ROBOT_STATE_UNKNOWN;
				//robotMessage.robotMode = ROBOT_STATE_UNKNOWN;
				break;
			}

			OnStateChange();			//Handles the state change
		}

		if(IsEnabled())
		{
			if((currentRobotState == ROBOT_STATE_TELEOPERATED) || 
					(currentRobotState == ROBOT_STATE_TEST) ||
					(currentRobotState == ROBOT_STATE_AUTONOMOUS))
			{
				Run();			//Robot logic
			}
		}

		previousRobotState = currentRobotState;

		++loop;		//Increment the loop counter
	}
}
Esempio n. 17
0
DWORD FAR PASCAL CController::RunController(CController* pController)
{
	if ( !pController )
		return 0;

	VARIANT_BOOL fIsSupported;
	pController->m_pGame->get_IsSupported(&fIsSupported);
	if ( fIsSupported==VARIANT_FALSE ) {
		MessageBox(pController->m_hParentWnd, "This game is not supported by Visual PinMAME", "Failed to start", MB_ICONINFORMATION|MB_OK);
		return 1;
	}

	g_fHandleMechanics = pController->m_iHandleMechanics;
	g_fHandleKeyboard  = pController->m_fHandleKeyboard;
	g_fMechSamples = pController->m_fMechSamples;

	// Load the game specific settings
	LoadGameSettings(pController->m_szROM);

	// set some options for the mamew environment
	// set_option("window", "1", 0);
	set_option("resolution", "1x1x16", 0);
	set_option("debug_resolution", "640x480x16", 0);
	set_option("maximize", "0", 0);
	set_option("throttle", "1", 0);
	set_option("sleep", "1", 0);
	set_option("autoframeskip", "0", 0);
	set_option("skip_gameinfo", "1", 0);
	set_option("skip_disclaimer", "1", 0);
	set_option("keepaspect", "0", 0);

	VARIANT fHasSound;
	VariantInit(&fHasSound);
	pController->m_pGameSettings->get_Value(CComBSTR("sound"), &fHasSound);
	if (fHasSound.boolVal==VARIANT_FALSE)
		options.samplerate = 0; // indicates game sound disabled

#ifndef DEBUG
	void* pSplashWnd = NULL;
	if(!cabinetMode)
	// display the splash screen
	CreateSplashWnd(&pSplashWnd, pController->m_szSplashInfoLine);
#endif

	// set the global pointer to Controller
	m_pController = pController;

	g_fPause = 0;

	int iSyncLevel = synclevel;
	if ( iSyncLevel<0 )
		iSyncLevel = 0;
	else if ( iSyncLevel>60 )
		iSyncLevel = 60;

	if ( iSyncLevel ) {
		if ( iSyncLevel<=20 )
			g_iSyncFactor = 1024;
		else
			g_iSyncFactor = (int) (1024.0*(iSyncLevel/60.0));

		g_hEnterThrottle = CreateEvent(NULL, false, true, NULL);
	}
#ifndef DEBUG
	else {
		// just in case
		g_iSyncFactor = 0;
		g_hEnterThrottle = INVALID_HANDLE_VALUE;

		switch ( threadpriority ) {
			case 1:
				SetThreadPriority(pController->m_hThreadRun, THREAD_PRIORITY_ABOVE_NORMAL);
				break;
			case 2:
				SetThreadPriority(pController->m_hThreadRun, THREAD_PRIORITY_HIGHEST);
				break;
		}
	}
#endif

	vpm_game_init(pController->m_nGameNo);
	run_game(pController->m_nGameNo);
	vpm_game_exit(pController->m_nGameNo);

	if ( iSyncLevel ) {
		SetEvent(g_hEnterThrottle);
		CloseHandle(g_hEnterThrottle);
		g_hEnterThrottle = INVALID_HANDLE_VALUE;
		g_iSyncFactor = 0;
	}
	else
		SetThreadPriority(pController->m_hThreadRun, THREAD_PRIORITY_NORMAL);

	// fire the OnMachineStopped event
	OnStateChange(0);

	// reset the global pointer to Controller
	m_pController = NULL;

#ifndef DEBUG
	if(!cabinetMode)
	// destroy the splash screensync
		DestroySplashWnd(&pSplashWnd); 
#endif

	return 0;
}
Esempio n. 18
0
/* void closeProgressDialog (in boolean forceClose); */
NS_IMETHODIMP nsMsgProgress::CloseProgressDialog(bool forceClose)
{
  m_closeProgress = true;
  return OnStateChange(nullptr, nullptr, nsIWebProgressListener::STATE_STOP, forceClose ? NS_ERROR_FAILURE : NS_OK);
}
/* void closeProgressDialog (in boolean forceClose); */
NS_IMETHODIMP nsPrintProgress::CloseProgressDialog(bool forceClose)
{
  m_closeProgress = true;
  return OnStateChange(nsnull, nsnull, nsIWebProgressListener::STATE_STOP, forceClose);
}
NS_IMETHODIMP nsPrintProgress::SetProcessCanceledByUser(bool aProcessCanceledByUser)
{
  m_processCanceled = aProcessCanceledByUser;
  OnStateChange(nsnull, nsnull, nsIWebProgressListener::STATE_STOP, false);
  return NS_OK;
}
Esempio n. 21
0
void Character::SetState(int state){
	mState = state;
	OnStateChange();
}
Esempio n. 22
0
NS_IMETHODIMP nsMsgProgress::SetProcessCanceledByUser(PRBool aProcessCanceledByUser)
{
  m_processCanceled = aProcessCanceledByUser;
  OnStateChange(nsnull, nsnull, nsIWebProgressListener::STATE_STOP, NS_BINDING_ABORTED);
  return NS_OK;
}
Esempio n. 23
0
/* void closeProgressDialog (in boolean forceClose); */
NS_IMETHODIMP nsMsgProgress::CloseProgressDialog(PRBool forceClose)
{
  m_closeProgress = PR_TRUE;
  return OnStateChange(nsnull, nsnull, nsIWebProgressListener::STATE_STOP, forceClose ? NS_ERROR_FAILURE : NS_OK);
}