forked from qt-creator/qt-creator
BlackBerry: Refactor parsing of blackberry-* processes output
This moves the parsing of the output from all blackberry-* processes used in the deploy steps, and when launching the application on the device, to a separate class. Errors and warnings coming from those processes will have issues added to the Issues tab. Change-Id: I455b26d77301bdfe93ece2c8470526ed174a50ed Reviewed-by: Mehdi Fekari <mfekari@blackberry.com> Reviewed-by: Nicolas Arnaud-Cormos <nicolas@kdab.com>
This commit is contained in:
committed by
Tobias Nätterlund
parent
7ae31f2ea9
commit
42eeb6ecdc
@@ -53,6 +53,8 @@ BlackBerryAbstractDeployStep::BlackBerryAbstractDeployStep(ProjectExplorer::Buil
|
|||||||
, m_futureInterface(0)
|
, m_futureInterface(0)
|
||||||
, m_eventLoop(0)
|
, m_eventLoop(0)
|
||||||
{
|
{
|
||||||
|
connect(&m_outputParser, SIGNAL(addTask(ProjectExplorer::Task)), this, SIGNAL(addTask(ProjectExplorer::Task)));
|
||||||
|
connect(&m_outputParser, SIGNAL(progressParsed(int)), this, SLOT(reportProgress(int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
BlackBerryAbstractDeployStep::BlackBerryAbstractDeployStep(ProjectExplorer::BuildStepList *bsl, BlackBerryAbstractDeployStep *bs)
|
BlackBerryAbstractDeployStep::BlackBerryAbstractDeployStep(ProjectExplorer::BuildStepList *bsl, BlackBerryAbstractDeployStep *bs)
|
||||||
@@ -63,6 +65,8 @@ BlackBerryAbstractDeployStep::BlackBerryAbstractDeployStep(ProjectExplorer::Buil
|
|||||||
, m_futureInterface(0)
|
, m_futureInterface(0)
|
||||||
, m_eventLoop(0)
|
, m_eventLoop(0)
|
||||||
{
|
{
|
||||||
|
connect(&m_outputParser, SIGNAL(addTask(ProjectExplorer::Task)), this, SIGNAL(addTask(ProjectExplorer::Task)));
|
||||||
|
connect(&m_outputParser, SIGNAL(progressParsed(int)), this, SLOT(reportProgress(int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
BlackBerryAbstractDeployStep::~BlackBerryAbstractDeployStep()
|
BlackBerryAbstractDeployStep::~BlackBerryAbstractDeployStep()
|
||||||
@@ -196,6 +200,7 @@ void BlackBerryAbstractDeployStep::processReadyReadStdOutput()
|
|||||||
|
|
||||||
void BlackBerryAbstractDeployStep::stdOutput(const QString &line)
|
void BlackBerryAbstractDeployStep::stdOutput(const QString &line)
|
||||||
{
|
{
|
||||||
|
m_outputParser.stdOutput(line);
|
||||||
emit addOutput(line, BuildStep::NormalOutput, BuildStep::DontAppendNewline);
|
emit addOutput(line, BuildStep::NormalOutput, BuildStep::DontAppendNewline);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,5 +243,6 @@ void BlackBerryAbstractDeployStep::handleProcessFinished(int exitCode, QProcess:
|
|||||||
|
|
||||||
void BlackBerryAbstractDeployStep::stdError(const QString &line)
|
void BlackBerryAbstractDeployStep::stdError(const QString &line)
|
||||||
{
|
{
|
||||||
|
m_outputParser.stdError(line);
|
||||||
emit addOutput(line, BuildStep::ErrorOutput, BuildStep::DontAppendNewline);
|
emit addOutput(line, BuildStep::ErrorOutput, BuildStep::DontAppendNewline);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,8 @@
|
|||||||
#ifndef QNX_INTERNAL_BLACKBERRYABSTRACTDEPLOYSTEP_H
|
#ifndef QNX_INTERNAL_BLACKBERRYABSTRACTDEPLOYSTEP_H
|
||||||
#define QNX_INTERNAL_BLACKBERRYABSTRACTDEPLOYSTEP_H
|
#define QNX_INTERNAL_BLACKBERRYABSTRACTDEPLOYSTEP_H
|
||||||
|
|
||||||
|
#include "blackberryprocessparser.h"
|
||||||
|
|
||||||
#include <projectexplorer/buildstep.h>
|
#include <projectexplorer/buildstep.h>
|
||||||
#include <projectexplorer/processparameters.h>
|
#include <projectexplorer/processparameters.h>
|
||||||
|
|
||||||
@@ -62,7 +64,6 @@ protected:
|
|||||||
BlackBerryAbstractDeployStep(ProjectExplorer::BuildStepList *bsl, BlackBerryAbstractDeployStep *bs);
|
BlackBerryAbstractDeployStep(ProjectExplorer::BuildStepList *bsl, BlackBerryAbstractDeployStep *bs);
|
||||||
|
|
||||||
void addCommand(const QString &command, const QStringList &arguments);
|
void addCommand(const QString &command, const QStringList &arguments);
|
||||||
void reportProgress(int progress);
|
|
||||||
|
|
||||||
virtual void stdOutput(const QString &line);
|
virtual void stdOutput(const QString &line);
|
||||||
virtual void stdError(const QString &line);
|
virtual void stdError(const QString &line);
|
||||||
@@ -74,6 +75,8 @@ protected:
|
|||||||
void raiseError(const QString &errorMessage);
|
void raiseError(const QString &errorMessage);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void reportProgress(int progress);
|
||||||
|
|
||||||
void processReadyReadStdOutput();
|
void processReadyReadStdOutput();
|
||||||
void processReadyReadStdError();
|
void processReadyReadStdError();
|
||||||
|
|
||||||
@@ -97,6 +100,8 @@ private:
|
|||||||
QTimer *m_timer;
|
QTimer *m_timer;
|
||||||
QFutureInterface<bool> *m_futureInterface;
|
QFutureInterface<bool> *m_futureInterface;
|
||||||
QEventLoop *m_eventLoop;
|
QEventLoop *m_eventLoop;
|
||||||
|
|
||||||
|
BlackBerryProcessParser m_outputParser;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -44,31 +44,6 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
qint64 parsePid(const QString &line)
|
|
||||||
{
|
|
||||||
QTC_ASSERT(line.startsWith(QLatin1String("result::")), return -1);
|
|
||||||
|
|
||||||
int pidIndex = -1;
|
|
||||||
if (line.contains(QLatin1String("running"))) // "result::running,<pid>"
|
|
||||||
pidIndex = 16;
|
|
||||||
else // "result::<pid>"
|
|
||||||
pidIndex = 8;
|
|
||||||
|
|
||||||
bool ok;
|
|
||||||
const qint64 pid = line.mid(pidIndex).toInt(&ok);
|
|
||||||
if (!ok)
|
|
||||||
return -1;
|
|
||||||
return pid;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString parseAppId(const QString &line)
|
|
||||||
{
|
|
||||||
QTC_ASSERT(line.startsWith(QLatin1String("Info: Launching")), return QString());
|
|
||||||
|
|
||||||
const int endOfId = line.indexOf(QLatin1String("..."));
|
|
||||||
return line.mid(16, endOfId - 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool parseRunningState(const QString &line)
|
bool parseRunningState(const QString &line)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(line.startsWith(QLatin1String("result::")), return false);
|
QTC_ASSERT(line.startsWith(QLatin1String("result::")), return false);
|
||||||
@@ -115,6 +90,9 @@ BlackBerryApplicationRunner::BlackBerryApplicationRunner(bool debugMode, BlackBe
|
|||||||
m_runningStateTimer->setSingleShot(true);
|
m_runningStateTimer->setSingleShot(true);
|
||||||
connect(m_runningStateTimer, SIGNAL(timeout()), this, SLOT(determineRunningState()));
|
connect(m_runningStateTimer, SIGNAL(timeout()), this, SLOT(determineRunningState()));
|
||||||
connect(this, SIGNAL(started()), this, SLOT(checkSlog2Info()));
|
connect(this, SIGNAL(started()), this, SLOT(checkSlog2Info()));
|
||||||
|
|
||||||
|
connect(&m_launchStopProcessParser, SIGNAL(pidParsed(qint64)), this, SLOT(setPid(qint64)));
|
||||||
|
connect(&m_launchStopProcessParser, SIGNAL(applicationIdParsed(QString)), this, SLOT(setApplicationId(QString)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlackBerryApplicationRunner::start()
|
void BlackBerryApplicationRunner::start()
|
||||||
@@ -229,12 +207,8 @@ void BlackBerryApplicationRunner::readStandardOutput()
|
|||||||
process->setReadChannel(QProcess::StandardOutput);
|
process->setReadChannel(QProcess::StandardOutput);
|
||||||
while (process->canReadLine()) {
|
while (process->canReadLine()) {
|
||||||
QString line = QString::fromLocal8Bit(process->readLine());
|
QString line = QString::fromLocal8Bit(process->readLine());
|
||||||
|
m_launchStopProcessParser.stdOutput(line);
|
||||||
emit output(line, Utils::StdOutFormat);
|
emit output(line, Utils::StdOutFormat);
|
||||||
|
|
||||||
if (line.startsWith(QLatin1String("result::")))
|
|
||||||
m_pid = parsePid(line);
|
|
||||||
else if (line.startsWith(QLatin1String("Info: Launching")))
|
|
||||||
m_appId = parseAppId(line);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,6 +218,7 @@ void BlackBerryApplicationRunner::readStandardError()
|
|||||||
process->setReadChannel(QProcess::StandardError);
|
process->setReadChannel(QProcess::StandardError);
|
||||||
while (process->canReadLine()) {
|
while (process->canReadLine()) {
|
||||||
const QString line = QString::fromLocal8Bit(process->readLine());
|
const QString line = QString::fromLocal8Bit(process->readLine());
|
||||||
|
m_launchStopProcessParser.stdError(line);
|
||||||
emit output(line, Utils::StdErrFormat);
|
emit output(line, Utils::StdErrFormat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -318,6 +293,16 @@ void BlackBerryApplicationRunner::readLaunchTime()
|
|||||||
m_launchDateTimeProcess->run("date +\"%d %H:%M:%S\"", m_sshParams);
|
m_launchDateTimeProcess->run("date +\"%d %H:%M:%S\"", m_sshParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BlackBerryApplicationRunner::setPid(qint64 pid)
|
||||||
|
{
|
||||||
|
m_pid = pid;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BlackBerryApplicationRunner::setApplicationId(const QString &applicationId)
|
||||||
|
{
|
||||||
|
m_appId = applicationId;
|
||||||
|
}
|
||||||
|
|
||||||
void BlackBerryApplicationRunner::handleTailOutput()
|
void BlackBerryApplicationRunner::handleTailOutput()
|
||||||
{
|
{
|
||||||
QSsh::SshRemoteProcessRunner *process = qobject_cast<QSsh::SshRemoteProcessRunner *>(sender());
|
QSsh::SshRemoteProcessRunner *process = qobject_cast<QSsh::SshRemoteProcessRunner *>(sender());
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
#define QNX_INTERNAL_BLACKBERRYAPPLICATIONRUNNER_H
|
#define QNX_INTERNAL_BLACKBERRYAPPLICATIONRUNNER_H
|
||||||
|
|
||||||
#include "blackberrydeviceconfiguration.h"
|
#include "blackberrydeviceconfiguration.h"
|
||||||
|
#include "blackberryprocessparser.h"
|
||||||
|
|
||||||
#include <projectexplorer/runconfiguration.h>
|
#include <projectexplorer/runconfiguration.h>
|
||||||
|
|
||||||
@@ -94,6 +95,9 @@ private slots:
|
|||||||
void handleSlog2InfoFound();
|
void handleSlog2InfoFound();
|
||||||
void readLaunchTime();
|
void readLaunchTime();
|
||||||
|
|
||||||
|
void setPid(qint64 pid);
|
||||||
|
void setApplicationId(const QString &applicationId);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void reset();
|
void reset();
|
||||||
void killTailProcess();
|
void killTailProcess();
|
||||||
@@ -118,6 +122,8 @@ private:
|
|||||||
|
|
||||||
QProcess *m_launchProcess;
|
QProcess *m_launchProcess;
|
||||||
QProcess *m_stopProcess;
|
QProcess *m_stopProcess;
|
||||||
|
BlackBerryProcessParser m_launchStopProcessParser;
|
||||||
|
|
||||||
QSsh::SshRemoteProcessRunner *m_tailProcess;
|
QSsh::SshRemoteProcessRunner *m_tailProcess;
|
||||||
QSsh::SshRemoteProcessRunner *m_testSlog2Process;
|
QSsh::SshRemoteProcessRunner *m_testSlog2Process;
|
||||||
QSsh::SshRemoteProcessRunner *m_launchDateTimeProcess;
|
QSsh::SshRemoteProcessRunner *m_launchDateTimeProcess;
|
||||||
|
|||||||
@@ -42,11 +42,6 @@
|
|||||||
using namespace Qnx;
|
using namespace Qnx;
|
||||||
using namespace Qnx::Internal;
|
using namespace Qnx::Internal;
|
||||||
|
|
||||||
namespace {
|
|
||||||
const char ERROR_MESSAGE_START[] = "Error: ";
|
|
||||||
const char AUTHENTICATION_ERROR[] = "Authentication failed.";
|
|
||||||
}
|
|
||||||
|
|
||||||
BlackBerryCheckDevModeStep::BlackBerryCheckDevModeStep(ProjectExplorer::BuildStepList *bsl) :
|
BlackBerryCheckDevModeStep::BlackBerryCheckDevModeStep(ProjectExplorer::BuildStepList *bsl) :
|
||||||
BlackBerryAbstractDeployStep(bsl, Core::Id(Constants::QNX_CHECK_DEVELOPMENT_MODE_BS_ID))
|
BlackBerryAbstractDeployStep(bsl, Core::Id(Constants::QNX_CHECK_DEVELOPMENT_MODE_BS_ID))
|
||||||
{
|
{
|
||||||
@@ -96,26 +91,6 @@ ProjectExplorer::BuildStepConfigWidget *BlackBerryCheckDevModeStep::createConfig
|
|||||||
return new BlackBerryCheckDevModeStepConfigWidget();
|
return new BlackBerryCheckDevModeStepConfigWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlackBerryCheckDevModeStep::stdOutput(const QString &line)
|
|
||||||
{
|
|
||||||
handleErrorOutput(line);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlackBerryCheckDevModeStep::stdError(const QString &line)
|
|
||||||
{
|
|
||||||
handleErrorOutput(line);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlackBerryCheckDevModeStep::handleErrorOutput(const QString &line)
|
|
||||||
{
|
|
||||||
if (line.startsWith(QLatin1String(ERROR_MESSAGE_START))) {
|
|
||||||
if (line.contains(QLatin1String(AUTHENTICATION_ERROR)))
|
|
||||||
raiseError(tr("Authentication failed. Please make sure the password for the device is correct."));
|
|
||||||
else
|
|
||||||
raiseError(line);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString BlackBerryCheckDevModeStep::password() const
|
QString BlackBerryCheckDevModeStep::password() const
|
||||||
{
|
{
|
||||||
BlackBerryDeviceConfiguration::ConstPtr device = BlackBerryDeviceConfiguration::device(target()->kit());
|
BlackBerryDeviceConfiguration::ConstPtr device = BlackBerryDeviceConfiguration::device(target()->kit());
|
||||||
|
|||||||
@@ -48,17 +48,12 @@ public:
|
|||||||
bool init();
|
bool init();
|
||||||
ProjectExplorer::BuildStepConfigWidget *createConfigWidget();
|
ProjectExplorer::BuildStepConfigWidget *createConfigWidget();
|
||||||
|
|
||||||
void stdOutput(const QString &line);
|
|
||||||
void stdError(const QString &line);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BlackBerryCheckDevModeStep(ProjectExplorer::BuildStepList *bsl, BlackBerryCheckDevModeStep *bs);
|
BlackBerryCheckDevModeStep(ProjectExplorer::BuildStepList *bsl, BlackBerryCheckDevModeStep *bs);
|
||||||
|
|
||||||
void processStarted(const ProjectExplorer::ProcessParameters ¶ms);
|
void processStarted(const ProjectExplorer::ProcessParameters ¶ms);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void handleErrorOutput(const QString &line);
|
|
||||||
|
|
||||||
QString password() const;
|
QString password() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -48,25 +48,6 @@
|
|||||||
using namespace Qnx;
|
using namespace Qnx;
|
||||||
using namespace Qnx::Internal;
|
using namespace Qnx::Internal;
|
||||||
|
|
||||||
namespace {
|
|
||||||
int parseProgress(const QString &line)
|
|
||||||
{
|
|
||||||
const QString startOfLine = QLatin1String("Info: Progress ");
|
|
||||||
if (!line.startsWith(startOfLine))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
const int percentPos = line.indexOf(QLatin1Char('%'));
|
|
||||||
const QString progressStr = line.mid(startOfLine.length(), percentPos - startOfLine.length());
|
|
||||||
|
|
||||||
bool ok;
|
|
||||||
const int progress = progressStr.toInt(&ok);
|
|
||||||
if (!ok)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
return progress;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BlackBerryDeployStep::BlackBerryDeployStep(ProjectExplorer::BuildStepList *bsl)
|
BlackBerryDeployStep::BlackBerryDeployStep(ProjectExplorer::BuildStepList *bsl)
|
||||||
: BlackBerryAbstractDeployStep(bsl, Core::Id(Constants::QNX_DEPLOY_PACKAGE_BS_ID))
|
: BlackBerryAbstractDeployStep(bsl, Core::Id(Constants::QNX_DEPLOY_PACKAGE_BS_ID))
|
||||||
{
|
{
|
||||||
@@ -144,15 +125,6 @@ void BlackBerryDeployStep::cleanup()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlackBerryDeployStep::stdOutput(const QString &line)
|
|
||||||
{
|
|
||||||
const int progress = parseProgress(line);
|
|
||||||
if (progress > -1)
|
|
||||||
reportProgress(progress);
|
|
||||||
|
|
||||||
BlackBerryAbstractDeployStep::stdOutput(line);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlackBerryDeployStep::processStarted(const ProjectExplorer::ProcessParameters ¶ms)
|
void BlackBerryDeployStep::processStarted(const ProjectExplorer::ProcessParameters ¶ms)
|
||||||
{
|
{
|
||||||
QString arguments = params.prettyArguments();
|
QString arguments = params.prettyArguments();
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
BlackBerryDeployStep(ProjectExplorer::BuildStepList *bsl, BlackBerryDeployStep *bs);
|
BlackBerryDeployStep(ProjectExplorer::BuildStepList *bsl, BlackBerryDeployStep *bs);
|
||||||
|
|
||||||
void stdOutput(const QString &line);
|
|
||||||
void processStarted(const ProjectExplorer::ProcessParameters ¶ms);
|
void processStarted(const ProjectExplorer::ProcessParameters ¶ms);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
133
src/plugins/qnx/blackberryprocessparser.cpp
Normal file
133
src/plugins/qnx/blackberryprocessparser.cpp
Normal file
@@ -0,0 +1,133 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2011 - 2013 Research In Motion
|
||||||
|
**
|
||||||
|
** Contact: Research In Motion (blackberry-qt@qnx.com)
|
||||||
|
** Contact: KDAB (info@kdab.com)
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://qt.digia.com/licensing. For further information
|
||||||
|
** use the contact form at http://qt.digia.com/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||||
|
** packaging of this file. Please review the following information to
|
||||||
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||||
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "blackberryprocessparser.h"
|
||||||
|
|
||||||
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
|
#include <projectexplorer/task.h>
|
||||||
|
|
||||||
|
using namespace Qnx;
|
||||||
|
using namespace Qnx::Internal;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
const char ERROR_MESSAGE_START[] = "Error: ";
|
||||||
|
const char WARNING_MESSAGE_START[] = "Warning: ";
|
||||||
|
const char PROGRESS_MESSAGE_START[] = "Info: Progress ";
|
||||||
|
const char PID_MESSAGE_START[] = "result::";
|
||||||
|
const char APPLICATION_ID_MESSAGE_START[] = "Info: Launching ";
|
||||||
|
|
||||||
|
const char AUTHENTICATION_ERROR[] = "Authentication failed.";
|
||||||
|
}
|
||||||
|
|
||||||
|
BlackBerryProcessParser::BlackBerryProcessParser()
|
||||||
|
{
|
||||||
|
m_messageReplacements[QLatin1String(AUTHENTICATION_ERROR)] =
|
||||||
|
tr("Authentication failed. Please make sure the password for the device is correct.");
|
||||||
|
}
|
||||||
|
|
||||||
|
void BlackBerryProcessParser::stdOutput(const QString &line)
|
||||||
|
{
|
||||||
|
parse(line);
|
||||||
|
IOutputParser::stdOutput(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BlackBerryProcessParser::stdError(const QString &line)
|
||||||
|
{
|
||||||
|
parse(line);
|
||||||
|
IOutputParser::stdError(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BlackBerryProcessParser::parse(const QString &line)
|
||||||
|
{
|
||||||
|
bool isErrorMessage = line.startsWith(QLatin1String(ERROR_MESSAGE_START));
|
||||||
|
bool isWarningMessage = line.startsWith(QLatin1String(WARNING_MESSAGE_START));
|
||||||
|
if (isErrorMessage || isWarningMessage)
|
||||||
|
parseErrorAndWarningMessage(line, isErrorMessage);
|
||||||
|
else if (line.startsWith(QLatin1String(PROGRESS_MESSAGE_START)))
|
||||||
|
parseProgress(line);
|
||||||
|
else if (line.startsWith(QLatin1String(PID_MESSAGE_START)))
|
||||||
|
parsePid(line);
|
||||||
|
else if (line.startsWith(QLatin1String(APPLICATION_ID_MESSAGE_START)))
|
||||||
|
parseApplicationId(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BlackBerryProcessParser::parseErrorAndWarningMessage(const QString &line, bool isErrorMessage)
|
||||||
|
{
|
||||||
|
QString message = line.mid(line.indexOf(QLatin1String(": ")) + 2).trimmed();
|
||||||
|
|
||||||
|
foreach (const QString &key, m_messageReplacements.keys()) {
|
||||||
|
if (message.startsWith(key)) {
|
||||||
|
message = m_messageReplacements[key];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ProjectExplorer::Task task(isErrorMessage ? ProjectExplorer::Task::Error : ProjectExplorer::Task::Warning,
|
||||||
|
message,
|
||||||
|
Utils::FileName(),
|
||||||
|
-1,
|
||||||
|
Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
|
||||||
|
emit addTask(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BlackBerryProcessParser::parseProgress(const QString &line)
|
||||||
|
{
|
||||||
|
const QString startOfLine = QLatin1String(PROGRESS_MESSAGE_START);
|
||||||
|
|
||||||
|
const int percentPos = line.indexOf(QLatin1Char('%'));
|
||||||
|
const QString progressStr = line.mid(startOfLine.length(), percentPos - startOfLine.length());
|
||||||
|
|
||||||
|
bool ok;
|
||||||
|
const int progress = progressStr.toInt(&ok);
|
||||||
|
if (ok)
|
||||||
|
emit progressParsed(progress);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BlackBerryProcessParser::parsePid(const QString &line)
|
||||||
|
{
|
||||||
|
int pidIndex = -1;
|
||||||
|
if (line.contains(QLatin1String("running"))) // "result::running,<pid>"
|
||||||
|
pidIndex = 16;
|
||||||
|
else // "result::<pid>"
|
||||||
|
pidIndex = 8;
|
||||||
|
|
||||||
|
bool ok;
|
||||||
|
const qint64 pid = line.mid(pidIndex).toInt(&ok);
|
||||||
|
if (ok)
|
||||||
|
emit pidParsed(pid);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BlackBerryProcessParser::parseApplicationId(const QString &line)
|
||||||
|
{
|
||||||
|
const int endOfId = line.indexOf(QLatin1String("..."));
|
||||||
|
const QString applicationId = line.mid(16, endOfId - 16);
|
||||||
|
emit applicationIdParsed(applicationId);
|
||||||
|
}
|
||||||
69
src/plugins/qnx/blackberryprocessparser.h
Normal file
69
src/plugins/qnx/blackberryprocessparser.h
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2011 - 2013 Research In Motion
|
||||||
|
**
|
||||||
|
** Contact: Research In Motion (blackberry-qt@qnx.com)
|
||||||
|
** Contact: KDAB (info@kdab.com)
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://qt.digia.com/licensing. For further information
|
||||||
|
** use the contact form at http://qt.digia.com/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||||
|
** packaging of this file. Please review the following information to
|
||||||
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||||
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef QNX_INTERNAL_BLACKBERRYPROCESSPARSER_H
|
||||||
|
#define QNX_INTERNAL_BLACKBERRYPROCESSPARSER_H
|
||||||
|
|
||||||
|
#include <projectexplorer/ioutputparser.h>
|
||||||
|
|
||||||
|
namespace Qnx {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
class BlackBerryProcessParser : public ProjectExplorer::IOutputParser
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
BlackBerryProcessParser();
|
||||||
|
|
||||||
|
void stdOutput(const QString &line);
|
||||||
|
void stdError(const QString &line);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void progressParsed(int progress);
|
||||||
|
void pidParsed(qint64 pid);
|
||||||
|
void applicationIdParsed(const QString &applicationId);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void parse(const QString &line);
|
||||||
|
|
||||||
|
void parseErrorAndWarningMessage(const QString &line, bool isErrorMessage);
|
||||||
|
void parseProgress(const QString &line);
|
||||||
|
void parsePid(const QString &line);
|
||||||
|
void parseApplicationId(const QString &line);
|
||||||
|
|
||||||
|
QMap<QString, QString> m_messageReplacements;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace Qnx
|
||||||
|
|
||||||
|
#endif // QNX_INTERNAL_BLACKBERRYPROCESSPARSER_H
|
||||||
@@ -77,7 +77,8 @@ SOURCES += qnxplugin.cpp \
|
|||||||
blackberrydeviceconnection.cpp \
|
blackberrydeviceconnection.cpp \
|
||||||
blackberrydeviceconnectionmanager.cpp \
|
blackberrydeviceconnectionmanager.cpp \
|
||||||
blackberrydeviceinformation.cpp \
|
blackberrydeviceinformation.cpp \
|
||||||
blackberrysshkeysgenerator.cpp
|
blackberrysshkeysgenerator.cpp \
|
||||||
|
blackberryprocessparser.cpp
|
||||||
|
|
||||||
HEADERS += qnxplugin.h\
|
HEADERS += qnxplugin.h\
|
||||||
qnxconstants.h \
|
qnxconstants.h \
|
||||||
@@ -154,7 +155,8 @@ HEADERS += qnxplugin.h\
|
|||||||
blackberrydeviceconnection.h \
|
blackberrydeviceconnection.h \
|
||||||
blackberrydeviceconnectionmanager.h \
|
blackberrydeviceconnectionmanager.h \
|
||||||
blackberrydeviceinformation.h \
|
blackberrydeviceinformation.h \
|
||||||
blackberrysshkeysgenerator.h
|
blackberrysshkeysgenerator.h \
|
||||||
|
blackberryprocessparser.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
blackberrydeviceconfigurationwizardsetuppage.ui \
|
blackberrydeviceconfigurationwizardsetuppage.ui \
|
||||||
|
|||||||
@@ -93,6 +93,8 @@ QtcPlugin {
|
|||||||
"blackberryqtversion.h",
|
"blackberryqtversion.h",
|
||||||
"blackberryqtversionfactory.cpp",
|
"blackberryqtversionfactory.cpp",
|
||||||
"blackberryqtversionfactory.h",
|
"blackberryqtversionfactory.h",
|
||||||
|
"blackberryprocessparser.cpp",
|
||||||
|
"blackberryprocessparser.h",
|
||||||
"blackberryrunconfiguration.cpp",
|
"blackberryrunconfiguration.cpp",
|
||||||
"blackberryrunconfiguration.h",
|
"blackberryrunconfiguration.h",
|
||||||
"blackberryrunconfigurationfactory.cpp",
|
"blackberryrunconfigurationfactory.cpp",
|
||||||
|
|||||||
Reference in New Issue
Block a user