/*!
    Event filter. End key is filtered from the main window and either the view
    takes case or the app is exited by default.
*/
bool NmApplication::eventFilter(QObject *obj, QEvent *event)
{
    bool consumed(false);

    if (obj && obj == mMainWindow && event && event->type() == QEvent::KeyPress) {
        QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
        if (keyEvent->key() == Qt::Key_No) {
            // End key, the "red" key.
            // Exit application if no pending operations are on-going.
        }
    }
    else if (event && event->type() == QEvent::ApplicationActivate) {
        NM_COMMENT("NmApplication::eventFilter ApplicationActivate");
        mApplicationHidden = false;
		// Update task switcher name & screenshot, we could have activated into some other mailbox
        updateActivity();
    }
    else if (event && event->type() == QEvent::ApplicationDeactivate) {
        NM_COMMENT("NmApplication::eventFilter ApplicationDeactivate");
        // Update the screenshot in the taskswitcher to represent current state
        if (!mApplicationHidden) {
            updateActivity();
        }
        // hide the sync indicator when app goes to background
        mUiEngine->enableSyncIndicator(false);
    }
    
    if (!consumed) {
        consumed = QObject::eventFilter(obj, event);
    }
    
    return consumed;
}
Пример #2
0
void Client::on(Connected) throw() {
    updateActivity();
    ip = sock->getIp();
    localIp = sock->getLocalIp();
    fire(ClientListener::Connected(), this);
    state = STATE_PROTOCOL;
}
Пример #3
0
void Client::on(Connected) noexcept
{
	updateActivity();
	{
#ifdef FLYLINKDC_USE_CS_CLIENT_SOCKET
		FastLock lock(csSock); // [+] brain-ripper
#endif
		boost::system::error_code ec;
		m_ip      = boost::asio::ip::address_v4::from_string(m_client_sock->getIp(), ec);
		dcassert(!ec);
	}
	if (m_client_sock->isSecure() && m_keyprint.compare(0, 7, "SHA256/", 7) == 0)
	{
		const auto kp = m_client_sock->getKeyprint();
		if (!kp.empty())
		{
			vector<uint8_t> kp2v(kp.size());
			Encoder::fromBase32(m_keyprint.c_str() + 7, &kp2v[0], kp2v.size());
			if (!std::equal(kp.begin(), kp.end(), kp2v.begin()))
			{
				state = STATE_DISCONNECTED;
				m_client_sock->removeListener(this);
				fire(ClientListener::Failed(), this, "Keyprint mismatch");
				return;
			}
		}
	}
#ifdef IRAINMAN_ENABLE_CON_STATUS_ON_FAV_HUBS
	FavoriteManager::getInstance()->changeConnectionStatus(getHubUrl(), ConnectionStatus::SUCCES);
#endif
	fire(ClientListener::Connected(), this);
	state = STATE_PROTOCOL;
}
Пример #4
0
void Client::connect() {
	if (sock) {
		BufferedSocket::putSocket(sock);
		sock = 0;
	}

	redirectUrl = Util::emptyString;
	setAutoReconnect(true);
	setReconnDelay(120 + Util::rand(0, 60));
	reloadSettings(true);
	setRegistered(false);
	setMyIdentity(Identity(ClientManager::getInstance()->getMe(), 0));
	setHubIdentity(Identity());

	setConnectState(STATE_CONNECTING);

	try {
		sock = BufferedSocket::getSocket(separator, v4only());
		sock->addListener(this);
		sock->connect(Socket::AddressInfo(address, Socket::AddressInfo::TYPE_URL), port, secure, SETTING(ALLOW_UNTRUSTED_HUBS), true, keyprint /**/);
	} catch (const Exception& e) {
		setConnectState(STATE_DISCONNECTED);
		fire(ClientListener::Failed(), hubUrl, e.getError());
	}
	updateActivity();
}
Пример #5
0
void Client::connect() {
	if(socket)
		BufferedSocket::putSocket(socket);

	setAutoReconnect(true);
	setReconnDelay(120 + Util::rand(0, 60));
	reloadSettings(true);
	setRegistered(false);
	setMyIdentity(Identity(ClientManager::getInstance()->getMe(), 0));
	setHubIdentity(Identity());

	try {
		socket = BufferedSocket::getSocket(separator);
		socket->addListener(this);
		socket->connect(address, port, secure, BOOLSETTING(ALLOW_UNTRUSTED_HUBS), true);
	} catch(const Exception& e) {
		if(socket) {
			BufferedSocket::putSocket(socket);
			socket = 0;
		}
		fire(ClientListener::Failed(), this, e.getError());
	}
	updateActivity();
	state = STATE_CONNECTING;
}
Пример #6
0
void Activity::updateCooperativeActivity(float dt)
{
    // cooperative work
    engine::DeviceState deviceState = Gameplay::iEngine->handleCooperativeLevel();
    switch( deviceState )
    {
    case engine::dsLost:
    case engine::dsNotReset:
        Sleep( 50 );
        return;
    case engine::dsDriverInternalError:
        getCore()->logMessage( "Driver internal error occured during cooperative work!" );
        PostQuitMessage( 0 );
        return;
    }
    if( !Gameplay::iEngine->canRestoreDevice() )
    {
        getCore()->logMessage( "Error during full screen cooperative work!" );
        Gameplay::iGameplay->setUnsafeCleanup( true );
        PostQuitMessage( 0 );
    }

    // abstract activity
    updateActivity( dt );
}
Пример #7
0
void Client::send(const char* aMessage, size_t aLen) {
    dcassert(sock);
    if(!sock)
        return;
    updateActivity();
    sock->write(aMessage, aLen);
}
Пример #8
0
void Client::send(const char* aMessage, size_t aLen) {
    if(!isReady()) {
        dcassert(0);
        return;
    }
    updateActivity();
    sock->write(aMessage, aLen);
    COMMAND_DEBUG(aMessage, DebugManager::HUB_OUT, getIpPort());
}
Пример #9
0
void Client::send(const char* aMessage, size_t aLen) {
	if (!isConnected() || !sock) {
		dcassert(0);
		return;
	}
	updateActivity();
	sock->write(aMessage, aLen);
	COMMAND_DEBUG(aMessage, DebugManager::TYPE_HUB, DebugManager::OUTGOING, getIpPort());
}
Пример #10
0
void
UserListItem::setHostAddreess(const QHostAddress& address)
{
  if (d->host_address_ == address)
    return;

  d->host_address_ = address;
  updateActivity();
  emitDataChanged();
}
Пример #11
0
void Client::on(BufferedSocketListener::Connected) noexcept {
	statusMessage(STRING(CONNECTED), LogMessage::SEV_INFO);

	updateActivity();
	ip = sock->getIp();
	localIp = sock->getLocalIp();
	
	fire(ClientListener::Connected(), this);
	setConnectState(STATE_PROTOCOL);
}
Пример #12
0
void CharacterController::update(float dt)
{
	if( character->getCurrentVehicle() ) {
		// Nevermind, the player is in a vehicle.

		auto& d = character->getMovement();

		if( character->getCurrentSeat() == 0 )
		{
			character->getCurrentVehicle()->setSteeringAngle(d.y);
			
			if( std::abs(d.x) > 0.01f )
			{
				character->getCurrentVehicle()->setHandbraking(false);
			}
			character->getCurrentVehicle()->setThrottle(d.x);
		}

		if( _currentActivity == nullptr ) {
			if( glm::length( d ) <= 0.1f )
			{
				vehicleIdle += dt;
			}
			else
			{
				vehicleIdle = 0.f;
			}
			
			if( vehicleIdle >= 1.f )
			{
				// If character is idle in vehicle, try to close the door.
				auto v = character->getCurrentVehicle();
				auto entryDoor = v->getSeatEntryDoor(character->getCurrentSeat());
				
				if( entryDoor && entryDoor->constraint )
				{
					character->getCurrentVehicle()->setPartTarget(entryDoor, true, entryDoor->closedAngle);
				}
			}
		}
	}

	if( updateActivity() ) {
		character->activityFinished();
		if( _currentActivity ) {
			delete _currentActivity;
			_currentActivity = nullptr;
		}
		if( _nextActivity ) {
			setActivity( _nextActivity );
			_nextActivity = nullptr;
		}
	}
}
Пример #13
0
void
UserListItem::setOnline(bool is_online)
{
  if (d->is_online_ == is_online)
    return;

  d->is_online_ = is_online;
  updateActivity();

  ChatWindow *window = ChatWindow::findWindow(d->uuid_);
  if (0 != window)
    window->updateUserState();
}
Пример #14
0
void
UserListItem::setName(const QString& name)
{
  if (name == d->name_)
    return;

  d->name_ = name;
  updateActivity();

  ChatWindow *window = ChatWindow::findWindow(d->uuid_);
  if (0 != window)
    window->updateUserState();
}
Пример #15
0
void Client::connect()
{
	reset_socket();
	// [!]IRainman moved to two function:
	// void Client::on(Failed, const string& aLine)
	// void Client::disconnect(bool graceLess)
	clearAvailableBytes();
	
	setAutoReconnect(true);
	setReconnDelay(120 + Util::rand(0, 60));
	const FavoriteHubEntry* fhe = reloadSettings(true);
	// [!]IRainman fix.
	resetRegistered(); // [!]
	resetOp(); // [+]
	// [-] setMyIdentity(Identity(ClientManager::getInstance()->getMe(), 0)); [-]
	// [-] setHubIdentity(Identity()); [-]
	// [~] IRainman fix.
	
	state = STATE_CONNECTING;
	
	try
	{
#ifdef FLYLINKDC_USE_CS_CLIENT_SOCKET
		FastLock lock(csSock); // [+] brain-ripper
#endif
		m_client_sock = BufferedSocket::getBufferedSocket(m_separator);
		m_client_sock->addListener(this);
		m_client_sock->connect(m_address,
		                       m_port,
		                       m_secure,
		                       BOOLSETTING(ALLOW_UNTRUSTED_HUBS),
		                       true);
		dcdebug("Client::connect() %p\n", (void*)this);
	}
	catch (const Exception& e)
	{
		state = STATE_DISCONNECTED;
		fire(ClientListener::Failed(), this, e.getError());
	}
	m_isActivMode = ClientManager::isActive(fhe); // [+] IRainman opt.
	updateActivity();
}
Пример #16
0
void Client::send(const char* aMessage, size_t aLen)
{
	if (!isReady())
	{
		dcdebug("Send message failed, hub is disconnected!");//[+] IRainman
		dcassert(isReady()); // ѕод отладкой падаем тут. найти причину.
		return;
	}
	updateActivity();
	{
#ifdef FLYLINKDC_USE_CS_CLIENT_SOCKET
		FastLock lock(csSock); // [+] brain-ripper
#endif
		m_client_sock->write(aMessage, aLen);
	}
	if (!CompatibilityManager::isWine())
	{
		COMMAND_DEBUG(aMessage, DebugTask::HUB_OUT, getIpPort());
	}
}
Пример #17
0
void Client::on(Connected) throw() {
    updateActivity();
    ip = sock->getIp();
    localIp = sock->getLocalIp();
    if(sock->isSecure() && keyprint.compare(0, 7, "SHA256/") == 0) {
        vector<uint8_t> kp = sock->getKeyprint();
        if(!kp.empty()) {
            vector<uint8_t> kp2v(kp.size());
            Encoder::fromBase32(keyprint.c_str() + 7, &kp2v[0], kp2v.size());
            if(!std::equal(kp.begin(), kp.end(), kp2v.begin())) {
                state = STATE_DISCONNECTED;
                sock->removeListener(this);
                fire(ClientListener::Failed(), this, "Keyprint mismatch");
                return;
            }
        }
    }
    fire(ClientListener::Connected(), this);
    state = STATE_PROTOCOL;
}
Пример #18
0
void Client::on(Failed, const string& aLine) noexcept
{
	// although failed consider initialized
	state = STATE_DISCONNECTED;//[!] IRainman fix
	FavoriteManager* l_fm = FavoriteManager::getInstance();
	l_fm->removeUserCommand(getHubUrl());
	
	{
#ifdef FLYLINKDC_USE_CS_CLIENT_SOCKET
		FastLock lock(csSock); // [+] brain-ripper
#endif
		if (m_client_sock)
			m_client_sock->removeListener(this);
	}
	// [-] IRainman.
	//SetEvent(m_hEventClientInitialized);
	updateActivity();
#ifdef IRAINMAN_ENABLE_CON_STATUS_ON_FAV_HUBS
	l_fm->changeConnectionStatus(getHubUrl(), ConnectionStatus::CONNECTION_FAILURE);
#endif
	fire(ClientListener::Failed(), this, aLine);
}
Пример #19
0
void Client::connect() {
    if(sock)
        BufferedSocket::putSocket(sock);

    setAutoReconnect(true);
    setReconnDelay(SETTING(RECONNECT_DELAY));
    reloadSettings(true);
    setRegistered(false);
    setMyIdentity(Identity(ClientManager::getInstance()->getMe(), 0));
    setHubIdentity(Identity());

    state = STATE_CONNECTING;

    try {
        sock = BufferedSocket::getSocket(separator);
        sock->addListener(this);
        sock->connect(address, port, secure, BOOLSETTING(ALLOW_UNTRUSTED_HUBS), true);
    } catch(const Exception& e) {
        shutdown();
        /// @todo at this point, this hub instance is completely useless
        fire(ClientListener::Failed(), this, e.getError());
    }
    updateActivity();
}
Пример #20
0
void PowerModel::calcStats(uint64_t timeinterval, bool keepPower, FlowID fid)
/* calcStats {{{1 */
{
    // This is called through sampler. So the power/thermal
    // simulator are called explicitly rather than periodically by
    // a timer.
    //
    //need to sync stats first

    energyBundle->setFreq(getFreq());

    if (!keepPower) {     // Calculate new Power
        updateActivity(timeinterval, fid);
        // Dump eSESC performance counters to file
        if (logfile)
            printStatus();

        mcpatWrapper->calcPower(activity, energyBundle, &clockInterval);

        //Turbo
        if (enableTurbo)
            updateTurboState();
        //FIXME: else i should copy lkg to scaled lkg

        //dumpTotalPower("totalp");


        if (doPowPred) {
            updatePowerHist();
            loadPredPower();
        }
    }

    //dumpTotalPower("totalpf");




    uint32_t throttleLength = 0;
    if (doTherm) {
        if (energyBundle->cntrs.size()>0) {
            sescThermWrapper->calcTemp(energyBundle, temperatures, timeInterval, throttleLength);
        }
    }

    updatePowerGStats();
    dumpTotalPower("totalpTh");
    //double tp = getLastTotalPower();
#ifdef ENABLE_CUDA
    double ed = getCurrentED();
    //printf("total Power TH:%f, ED:%f, Vol:%f  timeinterval=%lu\n", tp, ed, volNTC, (long unsigned int) timeinterval);
#else
    //printf("total Power TH:%f, Vol:%f  timeinterval=%lu\n", tp, volNTC, (long unsigned int) timeinterval);
#endif

    // Thermal Throttling
    throttle(fid, throttleLength);
    updatePowerTime(timeInterval);

    if (dumppwth && logpwrdyn/* && tc > 0*/) {
        dumpDynamic();
        if (logprf)
            dumpPerf(false);
    }
}
Пример #21
0
void Client::on(Line, const string& /*aLine*/) throw() {
	updateActivity();
}
Пример #22
0
void Client::on(Line, const string& aLine) noexcept {
	updateActivity();
	COMMAND_DEBUG(aLine, DebugManager::TYPE_HUB, DebugManager::INCOMING, getIpPort());
}
Пример #23
0
	void Session::onSocketDisconnected() noexcept {
		// Set the expiration time from this moment if there is no further activity
		updateActivity();

		fire(SessionListener::SocketDisconnected());
	}
Пример #24
0
void Client::on(Line, const string& aLine) noexcept
{
	updateActivity();
	COMMAND_DEBUG(aLine, DebugTask::HUB_IN, getIpPort());
}
Пример #25
0
void Client::on(Line, const string& aLine) throw() {
    updateActivity();
    COMMAND_DEBUG(aLine, DebugManager::HUB_IN, getIpPort())
}