forked from qt-creator/qt-creator
QdbMakeDefaultAppService: Don't use SshRemoteProcessRunner
Use QtcProcess with a path on device instead. Change-Id: I4ce6d5d1cf42a678de8cc9695c7db782a81b34f9 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -29,9 +29,10 @@
|
|||||||
#include "qdbrunconfiguration.h"
|
#include "qdbrunconfiguration.h"
|
||||||
|
|
||||||
#include <projectexplorer/devicesupport/idevice.h>
|
#include <projectexplorer/devicesupport/idevice.h>
|
||||||
#include <projectexplorer/runconfigurationaspects.h>
|
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
#include <ssh/sshremoteprocessrunner.h>
|
#include <utils/qtcprocess.h>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Qdb {
|
namespace Qdb {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -39,62 +40,38 @@ namespace Internal {
|
|||||||
class QdbMakeDefaultAppServicePrivate
|
class QdbMakeDefaultAppServicePrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool makeDefault;
|
bool m_makeDefault = true;
|
||||||
QSsh::SshRemoteProcessRunner *processRunner;
|
QtcProcess m_process;
|
||||||
};
|
};
|
||||||
|
|
||||||
QdbMakeDefaultAppService::QdbMakeDefaultAppService(QObject *parent)
|
QdbMakeDefaultAppService::QdbMakeDefaultAppService(QObject *parent)
|
||||||
: AbstractRemoteLinuxDeployService(parent),
|
: AbstractRemoteLinuxDeployService(parent),
|
||||||
d(new QdbMakeDefaultAppServicePrivate)
|
d(new QdbMakeDefaultAppServicePrivate)
|
||||||
{
|
{
|
||||||
d->processRunner = 0;
|
connect(&d->m_process, &QtcProcess::done, this, [this] {
|
||||||
d->makeDefault = true;
|
if (d->m_process.error() != QProcess::UnknownError)
|
||||||
|
emit errorMessage(tr("Remote process failed: %1").arg(d->m_process.errorString()));
|
||||||
|
else if (d->m_makeDefault)
|
||||||
|
emit progressMessage(tr("Application set as the default one."));
|
||||||
|
else
|
||||||
|
emit progressMessage(tr("Reset the default application."));
|
||||||
|
|
||||||
|
stopDeployment();
|
||||||
|
});
|
||||||
|
connect(&d->m_process, &QtcProcess::readyReadStandardError, this, [this] {
|
||||||
|
emit stdErrData(QString::fromUtf8(d->m_process.readAllStandardError()));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
QdbMakeDefaultAppService::~QdbMakeDefaultAppService()
|
QdbMakeDefaultAppService::~QdbMakeDefaultAppService() = default;
|
||||||
{
|
|
||||||
cleanup();
|
|
||||||
delete d;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QdbMakeDefaultAppService::setMakeDefault(bool makeDefault)
|
void QdbMakeDefaultAppService::setMakeDefault(bool makeDefault)
|
||||||
{
|
{
|
||||||
d->makeDefault = makeDefault;
|
d->m_makeDefault = makeDefault;
|
||||||
}
|
|
||||||
|
|
||||||
void QdbMakeDefaultAppService::handleStdErr()
|
|
||||||
{
|
|
||||||
emit stdErrData(QString::fromUtf8(d->processRunner->readAllStandardError()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void QdbMakeDefaultAppService::handleProcessFinished()
|
|
||||||
{
|
|
||||||
const QString error = d->processRunner->errorString();
|
|
||||||
if (!error.isEmpty()) {
|
|
||||||
emit errorMessage(tr("Remote process failed: %1").arg(error));
|
|
||||||
stopDeployment();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: Check that ignoring is fine
|
|
||||||
QByteArray processOutput = d->processRunner->readAllStandardOutput();
|
|
||||||
|
|
||||||
if (d->makeDefault)
|
|
||||||
emit progressMessage(tr("Application set as the default one."));
|
|
||||||
else
|
|
||||||
emit progressMessage(tr("Reset the default application."));
|
|
||||||
|
|
||||||
stopDeployment();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QdbMakeDefaultAppService::doDeploy()
|
void QdbMakeDefaultAppService::doDeploy()
|
||||||
{
|
{
|
||||||
d->processRunner = new QSsh::SshRemoteProcessRunner;
|
|
||||||
connect(d->processRunner, &QSsh::SshRemoteProcessRunner::finished,
|
|
||||||
this, &QdbMakeDefaultAppService::handleProcessFinished);
|
|
||||||
connect(d->processRunner, &QSsh::SshRemoteProcessRunner::readyReadStandardError,
|
|
||||||
this, &QdbMakeDefaultAppService::handleStdErr);
|
|
||||||
|
|
||||||
QString remoteExe;
|
QString remoteExe;
|
||||||
|
|
||||||
if (ProjectExplorer::RunConfiguration *rc = target()->activeRunConfiguration()) {
|
if (ProjectExplorer::RunConfiguration *rc = target()->activeRunConfiguration()) {
|
||||||
@@ -102,28 +79,19 @@ void QdbMakeDefaultAppService::doDeploy()
|
|||||||
remoteExe = exeAspect->executable().toString();
|
remoteExe = exeAspect->executable().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString command = Constants::AppcontrollerFilepath;
|
const QString args = d->m_makeDefault && !remoteExe.isEmpty()
|
||||||
command += d->makeDefault && !remoteExe.isEmpty() ? QStringLiteral(" --make-default ") + remoteExe
|
? QStringLiteral("--make-default ") + remoteExe
|
||||||
: QStringLiteral(" --remove-default");
|
: QStringLiteral("--remove-default");
|
||||||
|
d->m_process.setCommand(
|
||||||
d->processRunner->run(command, deviceConfiguration()->sshParameters());
|
{deviceConfiguration()->mapToGlobalPath(Constants::AppcontrollerFilepath), {args}});
|
||||||
|
d->m_process.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QdbMakeDefaultAppService::stopDeployment()
|
void QdbMakeDefaultAppService::stopDeployment()
|
||||||
{
|
{
|
||||||
cleanup();
|
d->m_process.close();
|
||||||
handleDeploymentDone();
|
handleDeploymentDone();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QdbMakeDefaultAppService::cleanup()
|
|
||||||
{
|
|
||||||
if (d->processRunner) {
|
|
||||||
disconnect(d->processRunner, 0, this, 0);
|
|
||||||
d->processRunner->cancel();
|
|
||||||
delete d->processRunner;
|
|
||||||
d->processRunner = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Qdb
|
} // namespace Qdb
|
||||||
|
@@ -41,17 +41,11 @@ public:
|
|||||||
void setMakeDefault(bool makeDefault);
|
void setMakeDefault(bool makeDefault);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void handleStdErr();
|
|
||||||
void handleProcessFinished();
|
|
||||||
|
|
||||||
bool isDeploymentNecessary() const final { return true; }
|
bool isDeploymentNecessary() const final { return true; }
|
||||||
|
|
||||||
void doDeploy() final;
|
void doDeploy() final;
|
||||||
void stopDeployment() final;
|
void stopDeployment() final;
|
||||||
|
|
||||||
void cleanup();
|
std::unique_ptr<QdbMakeDefaultAppServicePrivate> d;
|
||||||
|
|
||||||
QdbMakeDefaultAppServicePrivate * const d;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
Reference in New Issue
Block a user