void IdleTimeDetector::revert() { // revert and stop kDebug(5970) << "Entering function"; QDateTime end = QDateTime::currentDateTime(); int diff = start.secsTo(end)/secsPerMinute; emit(extractTime(idleminutes+diff)); // subtract the time that has been added on the display emit(stopAllTimers(idlestart)); }
QuickInterpreter::~QuickInterpreter() { shuttingDown = TRUE; stopAllTimers(); invalidateWrappers(); delete factory; delete toplevel; delete debugger; Q_ASSERT( wrapperShared->isEmpty() ); delete wrapperShared; }
bool IdleTimeDetector::qt_emit( int _id, QUObject* _o ) { switch ( _id - staticMetaObject()->signalOffset() ) { case 0: extractTime((int)static_QUType_int.get(_o+1)); break; case 1: stopAllTimers(); break; case 2: idleTimeUp(); break; case 3: idleBack(); break; default: return QObject::qt_emit(_id,_o); } return TRUE; }
void QuickInterpreter::clear() { sourceIdNames.clear(); debuggerEngine()->clear(); stopAllTimers(); invalidateWrappers(); if( toplevel ) toplevel->clear(); QSEngine::clear(); QSEngine::init(); init(); }
void ScriptEngine::run() { // TODO: can we add a short circuit for _stoppingAllScripts here? What does it mean to not start running if // we're in the process of stopping? if (!_isInitialized) { init(); } _isRunning = true; _isFinished = false; emit runningStateChanged(); QScriptValue result = evaluate(_scriptContents); QElapsedTimer startTime; startTime.start(); int thisFrame = 0; auto nodeList = DependencyManager::get<NodeList>(); auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>(); qint64 lastUpdate = usecTimestampNow(); while (!_isFinished) { int usecToSleep = (thisFrame++ * SCRIPT_DATA_CALLBACK_USECS) - startTime.nsecsElapsed() / 1000; // nsec to usec if (usecToSleep > 0) { usleep(usecToSleep); } if (_isFinished) { break; } QCoreApplication::processEvents(); if (_isFinished) { break; } if (!_isFinished && entityScriptingInterface->getEntityPacketSender()->serversExist()) { // release the queue of edit entity messages. entityScriptingInterface->getEntityPacketSender()->releaseQueuedMessages(); // since we're in non-threaded mode, call process so that the packets are sent if (!entityScriptingInterface->getEntityPacketSender()->isThreaded()) { entityScriptingInterface->getEntityPacketSender()->process(); } } if (!_isFinished && _isAvatar && _avatarData) { const int SCRIPT_AUDIO_BUFFER_SAMPLES = floor(((SCRIPT_DATA_CALLBACK_USECS * AudioConstants::SAMPLE_RATE) / (1000 * 1000)) + 0.5); const int SCRIPT_AUDIO_BUFFER_BYTES = SCRIPT_AUDIO_BUFFER_SAMPLES * sizeof(int16_t); QByteArray avatarByteArray = _avatarData->toByteArray(); auto avatarPacket = NLPacket::create(PacketType::AvatarData, avatarByteArray.size()); avatarPacket->write(avatarByteArray); nodeList->broadcastToNodes(std::move(avatarPacket), NodeSet() << NodeType::AvatarMixer); if (_isListeningToAudioStream || _avatarSound) { // if we have an avatar audio stream then send it out to our audio-mixer bool silentFrame = true; int16_t numAvailableSamples = SCRIPT_AUDIO_BUFFER_SAMPLES; const int16_t* nextSoundOutput = NULL; if (_avatarSound) { const QByteArray& soundByteArray = _avatarSound->getByteArray(); nextSoundOutput = reinterpret_cast<const int16_t*>(soundByteArray.data() + _numAvatarSoundSentBytes); int numAvailableBytes = (soundByteArray.size() - _numAvatarSoundSentBytes) > SCRIPT_AUDIO_BUFFER_BYTES ? SCRIPT_AUDIO_BUFFER_BYTES : soundByteArray.size() - _numAvatarSoundSentBytes; numAvailableSamples = numAvailableBytes / sizeof(int16_t); // check if the all of the _numAvatarAudioBufferSamples to be sent are silence for (int i = 0; i < numAvailableSamples; ++i) { if (nextSoundOutput[i] != 0) { silentFrame = false; break; } } _numAvatarSoundSentBytes += numAvailableBytes; if (_numAvatarSoundSentBytes == soundByteArray.size()) { // we're done with this sound object - so set our pointer back to NULL // and our sent bytes back to zero _avatarSound = NULL; _numAvatarSoundSentBytes = 0; } } auto audioPacket = NLPacket::create(silentFrame ? PacketType::SilentAudioFrame : PacketType::MicrophoneAudioNoEcho); // seek past the sequence number, will be packed when destination node is known audioPacket->seek(sizeof(quint16)); if (silentFrame) { if (!_isListeningToAudioStream) { // if we have a silent frame and we're not listening then just send nothing and break out of here break; } // write the number of silent samples so the audio-mixer can uphold timing audioPacket->writePrimitive(SCRIPT_AUDIO_BUFFER_SAMPLES); // use the orientation and position of this avatar for the source of this audio audioPacket->writePrimitive(_avatarData->getPosition()); glm::quat headOrientation = _avatarData->getHeadOrientation(); audioPacket->writePrimitive(headOrientation); } else if (nextSoundOutput) { // assume scripted avatar audio is mono and set channel flag to zero audioPacket->writePrimitive((quint8) 0); // use the orientation and position of this avatar for the source of this audio audioPacket->writePrimitive(_avatarData->getPosition()); glm::quat headOrientation = _avatarData->getHeadOrientation(); audioPacket->writePrimitive(headOrientation); // write the raw audio data audioPacket->write(reinterpret_cast<const char*>(nextSoundOutput), numAvailableSamples * sizeof(int16_t)); } // write audio packet to AudioMixer nodes auto nodeList = DependencyManager::get<NodeList>(); nodeList->eachNode([this, &nodeList, &audioPacket](const SharedNodePointer& node){ // only send to nodes of type AudioMixer if (node->getType() == NodeType::AudioMixer) { // pack sequence number quint16 sequence = _outgoingScriptAudioSequenceNumbers[node->getUUID()]++; audioPacket->seek(0); audioPacket->writePrimitive(sequence); // send audio packet nodeList->sendUnreliablePacket(*audioPacket, *node); } }); } } qint64 now = usecTimestampNow(); float deltaTime = (float) (now - lastUpdate) / (float) USECS_PER_SECOND; if (hasUncaughtException()) { int line = uncaughtExceptionLineNumber(); qCDebug(scriptengine) << "Uncaught exception at (" << _fileNameString << ") line" << line << ":" << uncaughtException().toString(); emit errorMessage("Uncaught exception at (" + _fileNameString + ") line" + QString::number(line) + ":" + uncaughtException().toString()); clearExceptions(); } if (!_isFinished) { emit update(deltaTime); } lastUpdate = now; } stopAllTimers(); // make sure all our timers are stopped if the script is ending emit scriptEnding(); // kill the avatar identity timer delete _avatarIdentityTimer; if (entityScriptingInterface->getEntityPacketSender()->serversExist()) { // release the queue of edit entity messages. entityScriptingInterface->getEntityPacketSender()->releaseQueuedMessages(); // since we're in non-threaded mode, call process so that the packets are sent if (!entityScriptingInterface->getEntityPacketSender()->isThreaded()) { // wait here till the edit packet sender is completely done sending while (entityScriptingInterface->getEntityPacketSender()->hasPacketsToSend()) { entityScriptingInterface->getEntityPacketSender()->process(); QCoreApplication::processEvents(); } } else { // FIXME - do we need to have a similar "wait here" loop for non-threaded packet senders? } } emit finished(_fileNameString); _isRunning = false; emit runningStateChanged(); emit doneRunning(); _doneRunningThisScript = true; }
static int checkTransition(tAuthRsnFsm *fsm, void *arg) { int retVal; tAniEapolKeyAvailEventData *data; tAniEapolRsnKeyDesc *rxDesc; tSirMicFailureInfo *micFailureInfo; if (fsm->disconnect) { stopAllTimers(fsm); gotoStateDisconnect(fsm); return ANI_OK; } if (fsm->authReq) { stopAllTimers(fsm); gotoStateAuthentication(fsm); return ANI_OK; } switch (fsm->currentState) { case INITIALIZE: break; case AUTHENTICATION: gotoStateAuthentication2(fsm); break; case AUTHENTICATION_2: gotoStateGetPsk( fsm ); break; case GET_PSK: //We always have PMK otherwise BAP won't let us here gotoStatePtkStart(fsm); break; case PTK_START: if ( fsm->eapolAvail ) { fsm->eapolAvail = eANI_BOOLEAN_FALSE; if (NULL == arg) { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "arg is NULL, exiting checkTransition()"); return ANI_E_FAILED; } data = (tAniEapolKeyAvailEventData *) arg; retVal = checkLocalReplayCounter(fsm, data); if (retVal != ANI_OK) return ANI_OK; // Caller should not fail retVal = derivePtk(fsm, data); if( !ANI_IS_STATUS_SUCCESS( retVal ) ) { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "Auth derivePtk failed with code %d!\n", retVal); return retVal; } retVal = checkMic(fsm, data); if (retVal != ANI_OK) { bapAuthDisconnect( fsm->ctx ); return retVal; } retVal = gotoStatePtkInitNego(fsm, arg); } else if ( fsm->msg2TimeOut ) { if (fsm->numTries <= authConsts.maxTries) { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "Auth Retransmitting EAPOL-Key Msg1\n"); // Stay in the same state but repeat actions gotoStatePtkStart(fsm); } else { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "Auth failed to recv EAPOL-Key Msg2 " "Disconnecting...\n"); gotoStateDisconnect(fsm); } } break; case PTK_INIT_NEGO: if (NULL == arg) { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "arg is NULL, exiting checkTransition()"); return ANI_E_FAILED; } data = (tAniEapolKeyAvailEventData *) arg; retVal = checkInfoElement(fsm, data); if (retVal != ANI_OK) { gotoStateDisconnect(fsm); } else { gotoStatePtkInitNegoTx(fsm); } break; case PTK_INIT_NEGO_TX: if (fsm->eapolAvail) { fsm->eapolAvail = eANI_BOOLEAN_FALSE; if (NULL == arg) { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "arg is NULL, exiting checkTransition()"); return ANI_E_FAILED; } data = (tAniEapolKeyAvailEventData *) arg; retVal = checkLocalReplayCounter(fsm, data); if (retVal != ANI_OK) return ANI_OK; // Caller should not fail retVal = checkMic(fsm, data); if (retVal != ANI_OK) { bapAuthDisconnect( fsm->ctx ); return retVal; } retVal = gotoStatePtkInitDone(fsm, data); } else if ( fsm->msg4TimeOut ) { if (fsm->numTries <= authConsts.maxTries) { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "Auth retransmitting EAPOL-Key Msg3 \n"); // Stay in the same state but repeat actions gotoStatePtkInitNegoTx(fsm); } else { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "Auth failed to recv EAPOL-Key Msg4 " "Disconnecting...\n" ); gotoStateDisconnect(fsm); } } break; case PTK_INIT_DONE: if (fsm->eapolAvail) { fsm->eapolAvail = eANI_BOOLEAN_FALSE; if (NULL == arg) { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "arg is NULL, exiting checkTransition()"); return ANI_E_FAILED; } data = (tAniEapolKeyAvailEventData *) arg; rxDesc = (tAniEapolRsnKeyDesc *) data->keyDesc; if (rxDesc->info.requestFlag) { retVal = checkPeerReplayCounter(fsm, data); if (retVal != ANI_OK) return ANI_OK; // Caller should not fail retVal = checkMic(fsm, data); if (retVal != ANI_OK) { bapAuthDisconnect( fsm->ctx->pvosGCtx ); return retVal; } retVal = gotoStateUpdateKeysReq(fsm, arg); } } else if (fsm->integFailed) { micFailureInfo = (tSirMicFailureInfo *) arg; gotoStateIntegFailure(fsm, arg); } break; case UPDATE_KEYS_REQ: if (NULL == arg) { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "arg is NULL, exiting checkTransition()"); return ANI_E_FAILED; } data = (tAniEapolKeyAvailEventData *) arg; rxDesc = (tAniEapolRsnKeyDesc *) data->keyDesc; if (rxDesc->info.errorFlag) { /* * This was generated by a unicast packet sent from the AP to the STA/BP. * The TX address is the AP's address. The src address is lost. * If the STA is a BP, then the true dst is lost. We will treat * the dst field as the address of the reporter of the MIC failure. */ micFailureInfo = (tSirMicFailureInfo *) vos_mem_malloc( sizeof(tSirMicFailureInfo) ); if( NULL == micFailureInfo ) { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "Fail to allocate memory for AuthRsnFsm: %d\n", fsm->currentState); return ANI_E_MALLOC_FAILED; } vos_mem_copy(micFailureInfo->taMacAddr, fsm->staCtx->authMac, sizeof(tAniMacAddr)); vos_mem_copy(micFailureInfo->dstMacAddr, fsm->staCtx->suppMac, sizeof(tAniMacAddr)); micFailureInfo->multicast = eANI_BOOLEAN_FALSE; // Copy whatever sequence number came in the EAPOL-key message vos_mem_copy(micFailureInfo->TSC, rxDesc->keyRecvSeqCounter, SIR_CIPHER_SEQ_CTR_SIZE); gotoStateIntegFailure(fsm, micFailureInfo); vos_mem_free(micFailureInfo); } else { // TBD: Untested. Why are local aNonce and local replyCtr not incremented in spec? gotoStatePtkStart(fsm); } break; case INTEG_FAILURE: gotoStateKeyUpdate(fsm); break; case KEY_UPDATE: gotoStatePtkStart(fsm); break; default: VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "Nothing to do in this state for AuthRsnFsm: %d\n", fsm->currentState); // Catch all for states that need no change: // assert(eANI_BOOLEAN_FALSE && "Illegal AuthRsnFsm state!"); return ANI_E_FAILED; } return ANI_OK; }
void QuickInterpreter::stop() { stopAllTimers(); debuggerEngine()->clear(); }