コード例 #1
0
void AndroidRunner::logcatProcess(const QByteArray &text, QByteArray &buffer, bool onlyError)
{
    QList<QByteArray> lines = text.split('\n');
    // lines always contains at least one item
    lines[0].prepend(buffer);
    if (!lines.last().endsWith('\n')) {
        // incomplete line
        buffer = lines.last();
        lines.removeLast();
    } else {
        buffer.clear();
    }

    QByteArray pid(QString::fromLatin1("%1):").arg(m_processPID).toLatin1());
    foreach (QByteArray line, lines) {
        if (!line.contains(pid))
            continue;
        if (line.endsWith('\r'))
            line.chop(1);
        line.append('\n');
        if (onlyError || line.startsWith("F/")
                || line.startsWith("E/")
                || line.startsWith("D/Qt")
                || line.startsWith("W/"))
            emit remoteErrorOutput(line);
        else
            emit remoteOutput(line);

    }
}
コード例 #2
0
static void
output (char *fname, char *exHost, int fflag, char *execUsername, char **envp)
{
  char *disOut[MAX_PEEK_ARGS];
  int fidx;
  int pid = 0;
  struct stat buf;

  if (!fflag)
    {

      pid = fork ();
      if (pid < 0)
	{
	  perror ("fork");
	  exit (-1);
	}
    }

  if (pid > 0)
    {

      wait (NULL);
      return;
    }


  if (fflag)
    {
      disOut[0] = "tail";
      disOut[1] = "-f";
      fidx = 2;
    }
  else
    {
      disOut[0] = "cat";
      fidx = 1;
    }
  disOut[fidx + 1] = NULL;


  if (fname[0] != '/' || stat (fname, &buf) < 0)
    {
      remoteOutput (fidx, disOut, exHost, fname, execUsername, envp);
    }
  else
    {
      setuid (getuid ());

      disOut[fidx] = fname;
      lsfExecvp (disOut[0], disOut);
      fprintf (stderr, I18N_FUNC_S_S_FAIL_S, "execvp", disOut[0],
	       strerror (errno));
    }
  exit (-1);

}
コード例 #3
0
ファイル: maemosshthread.cpp プロジェクト: gidlbn/dlbn_02
bool MaemoSshRunner::runInternal()
{
    createConnection();
    connect(m_connection.data(), SIGNAL(remoteOutput(QByteArray)),
            this, SLOT(handleRemoteOutput(QByteArray)));
    initState();
    if (!m_connection->start())
        return false;
    if (stopRequested())
        return true;

    waitForStop();
    return !m_connection->hasError();
}
コード例 #4
0
void AndroidRunControl::start()
{
    m_running = true;
    emit started();
    disconnect(m_runner, 0, this, 0);

    connect(m_runner, SIGNAL(remoteErrorOutput(QByteArray)),
        SLOT(handleRemoteErrorOutput(QByteArray)));
    connect(m_runner, SIGNAL(remoteOutput(QByteArray)),
        SLOT(handleRemoteOutput(QByteArray)));
    connect(m_runner, SIGNAL(remoteProcessFinished(QString)),
        SLOT(handleRemoteProcessFinished(QString)));
    appendMessage(tr("Starting remote process."), Utils::NormalMessageFormat);
    m_runner->start();
}
コード例 #5
0
void MaemoDebugSupport::startExecution()
{
    if (m_state == Inactive)
        return;

    ASSERT_STATE(StartingRunner);

    if (!useGdb() && m_debuggingType != RemoteLinuxRunConfiguration::DebugQmlOnly) {
        if (!setPort(m_gdbServerPort))
            return;
    }
    if (m_debuggingType != RemoteLinuxRunConfiguration::DebugCppOnly) {
        if (!setPort(m_qmlPort))
            return;
    }

    if (useGdb()) {
        handleAdapterSetupDone();
        return;
    }

    setState(StartingRemoteProcess);
    m_gdbserverOutput.clear();
    connect(m_runner, SIGNAL(remoteErrorOutput(QByteArray)), this,
        SLOT(handleRemoteErrorOutput(QByteArray)));
    connect(m_runner, SIGNAL(remoteOutput(QByteArray)), this,
        SLOT(handleRemoteOutput(QByteArray)));
    if (m_debuggingType == RemoteLinuxRunConfiguration::DebugQmlOnly) {
        connect(m_runner, SIGNAL(remoteProcessStarted()),
            SLOT(handleRemoteProcessStarted()));
    }
    const QString &remoteExe = m_runner->remoteExecutable();
    QString args = m_runner->arguments();
    if (m_debuggingType != RemoteLinuxRunConfiguration::DebugCppOnly) {
        args += QString(QLatin1String(" -qmljsdebugger=port:%1,block"))
            .arg(m_qmlPort);
    }

    const QString remoteCommandLine = m_debuggingType == RemoteLinuxRunConfiguration::DebugQmlOnly
        ? QString::fromLocal8Bit("%1 %2 %3").arg(m_runner->commandPrefix()).arg(remoteExe).arg(args)
        : QString::fromLocal8Bit("%1 gdbserver :%2 %3 %4").arg(m_runner->commandPrefix())
              .arg(m_gdbServerPort).arg(remoteExe).arg(args);
    connect(m_runner, SIGNAL(remoteProcessFinished(qint64)),
        SLOT(handleRemoteProcessFinished(qint64)));
    m_runner->startExecution(remoteCommandLine.toUtf8());
}
コード例 #6
0
ファイル: maemosshthread.cpp プロジェクト: gidlbn/dlbn_02
void MaemoSshRunner::handleRemoteOutput(const QByteArray &curOutput)
{
    const QByteArray output
        = filterTerminalControlChars(m_potentialEndMarkerPrefix + curOutput);

    // Wait for a prompt before sending the command.
    if (!m_promptEncountered) {
        if (output.indexOf(m_prompt) != -1) {
            m_promptEncountered = true;

            /*
             * We don't have access to the remote process management, so we
             * try to track the lifetime of the process by adding a second command
             * that prints a rare character. When it occurs for the second time (the
             * first one is the echo from the remote terminal), we assume the
             * process has finished. If anyone actually prints this special character
             * in their application, they are out of luck.
             */
            const QString finalCommand = m_command + QLatin1String(";echo ")
                + QString::fromUtf8(EndMarker) + QLatin1Char('\n');
            if (!m_connection->sendInput(finalCommand.toUtf8()))
                stop();
        }
        return;
    }

    /*
     * The output the user should see is everything after the first
     * and before the last occurrence of our marker string.
     */
    int firstCharToEmit;
    int charsToEmitCount;
    const int endMarkerPos = output.indexOf(EndMarker);
    if (endMarkerPos != -1) {
        if (m_endMarkerCount++ == 0) {
            firstCharToEmit = endMarkerPos + EndMarker.count() + 1;
            int endMarkerPos2
                    = output.indexOf(EndMarker, firstCharToEmit);
            if (endMarkerPos2 != -1) {
                ++ m_endMarkerCount;
                charsToEmitCount = endMarkerPos2 - firstCharToEmit;
            } else {
                charsToEmitCount = -1;
            }
        } else {
            firstCharToEmit = m_potentialEndMarkerPrefix.count();
            charsToEmitCount = endMarkerPos - firstCharToEmit;
        }
    } else {
        if (m_endMarkerCount == 0) {
            charsToEmitCount = 0;
        } else {
            firstCharToEmit = m_potentialEndMarkerPrefix.count();
            charsToEmitCount = -1;
        }
    }

    if (charsToEmitCount != 0) {
        emit remoteOutput(QString::fromUtf8(output.data() + firstCharToEmit,
                                            charsToEmitCount));
    }
    if (m_endMarkerCount == 2)
        stop();

    m_potentialEndMarkerPrefix = output.right(EndMarker.count());
}