bool AbstractManager::start()
{
    if(!mThread)
    {
        mThread = new ManagerThread(this,this);
        connect(mThread,
                SIGNAL(commandFinished()),
                this,
                SIGNAL(commandFinished()));
    }

    mThread->start();
    return true;
}
void SimpleBackend::tryNextFunction () {
	RK_TRACE (PHP);

	if ((!busy) && (!command_stack.isEmpty ())) {
		// clean up previous command if applicable
		if (command_stack.first ()->complete) {
			delete command_stack.first ();
			command_stack.pop_front ();

			if (!command_stack.count ()) return;
		}

		busy = true;
		command_stack.first ()->complete = true;
		current_flags = command_stack.first ()->flags;
		current_type = command_stack.first ()->type;

		current_values.clear ();
		template_pos = 0;
		if (current_type == Preprocess) current_template = preprocess_template;
		else if (current_type == Printout) current_template = printout_template;
		else if (current_type == Calculate) current_template = calculate_template;
		else if (current_type == Preview) current_template = preview_template;
		template_sep = current_template.indexOf ("!!!");

		if (template_sep < 0) {
			commandFinished ("");
			return;
		}

		processCall ();
	}
}
BlinkyPendantUploader::BlinkyPendantUploader(QObject *parent) :
    BlinkyUploader(parent)
{
    connect(&commandQueue, SIGNAL(error(QString)),
            this, SLOT(handleError(QString)));
    connect(&commandQueue, SIGNAL(commandFinished(QString, QByteArray)),
            this, SLOT(handleCommandFinished(QString, QByteArray)));
}
예제 #4
0
BlinkyTapeUploader::BlinkyTapeUploader(QObject *parent) :
    PatternUploader(parent)
{
    bootloaderResetTimer = new QTimer(this);

    state = State_Ready;

    connect(&programmer,SIGNAL(error(QString)),
            this,SLOT(handleProgrammerError(QString)));
    connect(&programmer,SIGNAL(commandFinished(QString,QByteArray)),
            this,SLOT(handleProgrammerCommandFinished(QString,QByteArray)));
}
예제 #5
0
void ConversationModel::sendMessage(const QString &text)
{
    if (text.isEmpty())
        return;

    ChatMessageCommand *command = new ChatMessageCommand;
    connect(command, SIGNAL(commandFinished()), this, SLOT(messageReply()));
    command->send(m_contact->conn(), QDateTime::currentDateTime(), text, lastReceivedId);

    beginInsertRows(QModelIndex(), 0, 0);
    MessageData message = { text, QDateTime::currentDateTime(), command->identifier(), Sending };
    messages.prepend(message);
    endInsertRows();
}
예제 #6
0
void N3GetType0Command::processPacket(const QByteArray &packet)
{
    inBuffer.append(packet);

    if (inBuffer.size() >= type0Size) {

        //Verify the packet received
        inBuffer = QByteArray::fromHex(inBuffer);

        if (verifyType0Record()) {
            setEncryptionKey();
            emit userDataAvailable(QSharedPointer<N3GetType0CommandResult>(new N3GetType0CommandResult(inBuffer)));
            emit commandFinished();
        }
    }
}
void ManagerThread::run()
{
    while(!bExited)
    {
        if(bHasCommand && mManager)
        {
            try
            {
                ICommand* command = mManager->dequeueCommand();
                while(command && !bExited)
                {
                    if(command)
                    {
                        mManager->mCurCommand = command;
                        mManager->doAction(command);
                    }

                    if(!bExited)
                    {
                        mManager->deleteCommand(command);
                        command = mManager->dequeueCommand();
                    }
                };
            }
            catch(QString err)
            {
                emit errorOccured(err);
            }
            if(!bExited)
            {
                mManager->mCurCommand = 0;
                bHasCommand = false;
                emit commandFinished();
            }
        }
    }

    if(bExited)
    {
        bExitAccepted = true;
    }
}
void SimpleBackend::finishCall (const QString &conditions) {
	RK_TRACE (PHP);

	QString conds = conditions;
	int repl = current_values.count();
	for (int i = repl; i > 0; --i) {
		QString placeholder = "%" + QString::number (i);
		QString replacement = current_values[i-1];
		conds.replace (placeholder, replacement);
	}

	QString output;
	int pos = 3;
	int max = conds.length ();
	do {
		int cond_end = conds.indexOf ("!?!", pos);
		if (cond_end < 0) cond_end = max;
		QString condition = conds.mid (pos, cond_end - pos);

		int if_end = condition.indexOf ("!:!");
		RK_ASSERT (if_end >= 0);
		QString if_part = condition.left (if_end);

		int if_mid = if_part.indexOf ("!=!");
		RK_ASSERT (if_mid >= 0);
		QString if_compare = if_part.left (if_mid);

		QString if_against = if_part.mid (if_mid + 3);
		if ((if_compare.isEmpty() && if_against.isEmpty ()) || (if_compare == if_against)) {
			output = condition.mid (if_end + 3);
			break;
		}

		pos = cond_end + 3;
	} while (pos < max);

	// reached end of template
	commandFinished (output);
}
예제 #9
0
void VVimCmdLineEdit::keyPressEvent(QKeyEvent *p_event)
{
    int key = p_event->key();
    int modifiers = p_event->modifiers();

    if (m_registerPending) {
        // Ctrl and Shift may be sent out first.
        if (key == Qt::Key_Control || key == Qt::Key_Shift || key == Qt::Key_Meta) {
            goto exit;
        }

        // Expecting a register name.
        emit requestRegister(key, modifiers);

        p_event->accept();
        setRegisterPending(false);
        return;
    }

    if ((key == Qt::Key_Return && modifiers == Qt::NoModifier)
        || (key == Qt::Key_Enter && modifiers == Qt::KeypadModifier)) {
        // Enter, complete the command line input.
        p_event->accept();
        emit commandFinished(m_type, getCommand());
        return;
    } else if (key == Qt::Key_Escape
               || (key == Qt::Key_BracketLeft && isControlModifier(modifiers))) {
        // Exit command line input.
        setText(commandLineTypeLeader(m_type));
        p_event->accept();
        emit commandCancelled();
        return;
    }

    switch (key) {
    case Qt::Key_U:
        if (isControlModifier(modifiers)) {
            // Ctrl+U, delete all user input.
            setText(commandLineTypeLeader(m_type));
            p_event->accept();
            return;
        }

        break;

    case Qt::Key_N:
        if (!isControlModifier(modifiers)) {
            break;
        }
        // Ctrl+N, request next command.
        // Fall through.
    case Qt::Key_Down:
    {
        emit requestNextCommand(m_type, getCommand());
        p_event->accept();
        return;
    }

    case Qt::Key_P:
        if (!isControlModifier(modifiers)) {
            break;
        }
        // Ctrl+P, request previous command.
        // Fall through.
    case Qt::Key_Up:
    {
        emit requestPreviousCommand(m_type, getCommand());
        p_event->accept();
        return;
    }

    case Qt::Key_R:
    {
        if (isControlModifier(modifiers)) {
            // Ctrl+R, insert the content of a register.
            setRegisterPending(true);
            p_event->accept();
            return;
        }
    }

    default:
        break;
    }

exit:
    VLineEdit::keyPressEvent(p_event);
}
예제 #10
0
파일: dbgdriver.cpp 프로젝트: isdamir/kdbg
void DebuggerDriver::processOutput(const QByteArray& data)
{
    // write to log file (do not log delayed output - it would appear twice)
    if (m_logFile.isOpen()) {
	m_logFile.write(data);
	m_logFile.flush();
    }
    
    /*
     * gdb sometimes produces stray output while it's idle. This happens if
     * it receives a signal, most prominently a SIGCONT after a SIGTSTP:
     * The user haltet kdbg with Ctrl-Z, then continues it with "fg", which
     * also continues gdb, which repeats the prompt!
     */
    if (m_activeCmd == 0 && m_state != DSinterrupted) {
	// ignore the output
	TRACE("ignoring stray output: " + QString(data));
	return;
    }
    ASSERT(m_state == DSrunning || m_state == DSrunningLow || m_state == DSinterrupted);
    ASSERT(m_activeCmd != 0 || m_state == DSinterrupted);

    // collect output until next prompt string is found
    
    // accumulate it
    m_output += data;

    // check for a prompt
    int promptStart = findPrompt(m_output);
    if (promptStart >= 0)
    {
	// found prompt!

	// terminate output before the prompt
	m_output.resize(promptStart);

	/*
	 * We've got output for the active command. But if it was
	 * interrupted, ignore it.
	 */
	if (m_state != DSinterrupted) {
	    /*
	     * m_state shouldn't be DSidle while we are parsing the output
	     * so that all commands produced by parse() go into the queue
	     * instead of being written to gdb immediately.
	     */
	    ASSERT(m_state != DSidle);
	    CmdQueueItem* cmd = m_activeCmd;
	    m_activeCmd = 0;
	    commandFinished(cmd);
	    delete cmd;
	}

	// empty buffer
	m_output.clear();
	// also clear delayed output if interrupted
	if (m_state == DSinterrupted) {
	    m_delayedOutput = std::queue<QByteArray>();
	}

	/*
	 * We parsed some output successfully. Unless there's more delayed
	 * output, the debugger must be idle now, so send down the next
	 * command.
	 */
	if (m_delayedOutput.empty()) {
	    if (m_hipriCmdQueue.empty() && m_lopriCmdQueue.empty()) {
		// no pending commands
		m_state = DSidle;
		emit enterIdleState();
	    } else {
		writeCommand();
	    }
	}
    }
}