diff options
author | Christian Kandeler <christian.kandeler@nokia.com> | 2011-11-14 17:23:51 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@nokia.com> | 2011-11-14 17:42:27 +0100 |
commit | 232724cc11db671e9e92aa02a8b974f63ca26553 (patch) | |
tree | b737f7455feb01b09aa6313ad89b40cde1e0f9c3 /src/plugins/remotelinux | |
parent | 75a7bf2919f83474006564405a443704d9fadd52 (diff) | |
download | qt-creator-232724cc11db671e9e92aa02a8b974f63ca26553.tar.gz |
SSH: Make API of SshRemoteProcess more similar to the one of QProcess.
In the end, we want to derive it from QIODevice as well.
Change-Id: I30e7cb23ec8e5753c363d1f4457b650556860ac2
Reviewed-by: Christian Kandeler <christian.kandeler@nokia.com>
Diffstat (limited to 'src/plugins/remotelinux')
6 files changed, 32 insertions, 45 deletions
diff --git a/src/plugins/remotelinux/genericdirectuploadservice.cpp b/src/plugins/remotelinux/genericdirectuploadservice.cpp index 0e628e07fb..097166b680 100644 --- a/src/plugins/remotelinux/genericdirectuploadservice.cpp +++ b/src/plugins/remotelinux/genericdirectuploadservice.cpp @@ -233,10 +233,8 @@ void GenericDirectUploadService::handleMkdirFinished(int exitStatus) // See comment in SftpChannel::createLink as to why we can't use it. d->lnProc = connection()->createRemoteProcess(command.toUtf8()); connect(d->lnProc.data(), SIGNAL(closed(int)), SLOT(handleLnFinished(int))); - connect(d->lnProc.data(), SIGNAL(outputAvailable(QByteArray)), - SLOT(handleStdOutData(QByteArray))); - connect(d->lnProc.data(), SIGNAL(errorOutputAvailable(QByteArray)), - SLOT(handleStdErrData(QByteArray))); + connect(d->lnProc.data(), SIGNAL(readyReadStandardOutput()), SLOT(handleStdOutData())); + connect(d->lnProc.data(), SIGNAL(readyReadStandardError()), SLOT(handleStdErrData())); d->lnProc->start(); } else { const SftpJobId job = d->uploader->uploadFile(df.localFilePath, remoteFilePath, @@ -251,14 +249,18 @@ void GenericDirectUploadService::handleMkdirFinished(int exitStatus) } } -void GenericDirectUploadService::handleStdOutData(const QByteArray &data) +void GenericDirectUploadService::handleStdOutData() { - emit stdOutData(QString::fromUtf8(data)); + SshRemoteProcess * const process = qobject_cast<SshRemoteProcess *>(sender()); + if (process) + emit stdOutData(QString::fromUtf8(process->readAllStandardOutput())); } -void GenericDirectUploadService::handleStdErrData(const QByteArray &data) +void GenericDirectUploadService::handleStdErrData() { - emit stdErrData(QString::fromUtf8(data)); + SshRemoteProcess * const process = qobject_cast<SshRemoteProcess *>(sender()); + if (process) + emit stdErrData(QString::fromUtf8(process->readAllStandardError())); } void GenericDirectUploadService::stopDeployment() @@ -328,10 +330,8 @@ void GenericDirectUploadService::uploadNextFile() const QString command = QLatin1String("mkdir -p ") + dirToCreate; d->mkdirProc = connection()->createRemoteProcess(command.toUtf8()); connect(d->mkdirProc.data(), SIGNAL(closed(int)), SLOT(handleMkdirFinished(int))); - connect(d->mkdirProc.data(), SIGNAL(outputAvailable(QByteArray)), - SLOT(handleStdOutData(QByteArray))); - connect(d->mkdirProc.data(), SIGNAL(errorOutputAvailable(QByteArray)), - SLOT(handleStdErrData(QByteArray))); + connect(d->mkdirProc.data(), SIGNAL(readyReadStandardOutput()), SLOT(handleStdOutData())); + connect(d->mkdirProc.data(), SIGNAL(readyReadStandardError()), SLOT(handleStdErrData())); emit progressMessage(tr("Uploading file '%1'...") .arg(QDir::toNativeSeparators(df.localFilePath))); d->mkdirProc->start(); diff --git a/src/plugins/remotelinux/genericdirectuploadservice.h b/src/plugins/remotelinux/genericdirectuploadservice.h index 373768f071..b7d18d1aa3 100644 --- a/src/plugins/remotelinux/genericdirectuploadservice.h +++ b/src/plugins/remotelinux/genericdirectuploadservice.h @@ -69,8 +69,8 @@ private slots: void handleUploadFinished(Utils::SftpJobId jobId, const QString &errorMsg); void handleMkdirFinished(int exitStatus); void handleLnFinished(int exitStatus); - void handleStdOutData(const QByteArray &data); - void handleStdErrData(const QByteArray &data); + void handleStdOutData(); + void handleStdErrData(); private: void checkDeploymentNeeded(const DeployableFile &file) const; diff --git a/src/plugins/remotelinux/linuxdevicetester.cpp b/src/plugins/remotelinux/linuxdevicetester.cpp index 781500416d..8c9e1cd2b9 100644 --- a/src/plugins/remotelinux/linuxdevicetester.cpp +++ b/src/plugins/remotelinux/linuxdevicetester.cpp @@ -57,8 +57,6 @@ public: SshConnection::Ptr connection; SshRemoteProcess::Ptr process; RemoteLinuxUsedPortsGatherer portsGatherer; - QByteArray remoteStdout; - QByteArray remoteStderr; State state; }; @@ -127,10 +125,6 @@ void GenericLinuxDeviceTester::handleConnected() QTC_ASSERT(d->state == Connecting, return); d->process = d->connection->createRemoteProcess("uname -rsm"); - connect(d->process.data(), SIGNAL(outputAvailable(QByteArray)), - SLOT(handleRemoteStdOut(QByteArray))); - connect(d->process.data(), SIGNAL(errorOutputAvailable(QByteArray)), - SLOT(handleRemoteStdErr(QByteArray))); connect(d->process.data(), SIGNAL(closed(int)), SLOT(handleProcessFinished(int))); emit progressMessage("Checking kernel version..."); @@ -146,31 +140,18 @@ void GenericLinuxDeviceTester::handleConnectionFailure() setFinished(TestFailure); } -void GenericLinuxDeviceTester::handleRemoteStdOut(const QByteArray &data) -{ - QTC_ASSERT(d->state == RunningUname, return); - - d->remoteStdout += data; -} - -void GenericLinuxDeviceTester::handleRemoteStdErr(const QByteArray &data) -{ - QTC_ASSERT(d->state == RunningUname, return); - - d->remoteStderr += data; -} - void GenericLinuxDeviceTester::handleProcessFinished(int exitStatus) { QTC_ASSERT(d->state == RunningUname, return); if (exitStatus != SshRemoteProcess::ExitedNormally || d->process->exitCode() != 0) { - if (!d->remoteStderr.isEmpty()) - emit errorMessage(tr("uname failed: %1\n").arg(QString::fromUtf8(d->remoteStderr))); + const QByteArray stderrOutput = d->process->readAllStandardError(); + if (!stderrOutput.isEmpty()) + emit errorMessage(tr("uname failed: %1\n").arg(QString::fromUtf8(stderrOutput))); else emit errorMessage(tr("uname failed.\n")); } else { - emit progressMessage(QString::fromUtf8(d->remoteStdout)); + emit progressMessage(QString::fromUtf8(d->process->readAllStandardOutput())); } connect(&d->portsGatherer, SIGNAL(error(QString)), SLOT(handlePortsGatheringError(QString))); @@ -209,8 +190,6 @@ void GenericLinuxDeviceTester::handlePortListReady() void GenericLinuxDeviceTester::setFinished(TestResult result) { d->state = Inactive; - d->remoteStdout.clear(); - d->remoteStderr.clear(); disconnect(d->connection.data(), 0, this, 0); disconnect(&d->portsGatherer, 0, this, 0); emit finished(result); diff --git a/src/plugins/remotelinux/linuxdevicetester.h b/src/plugins/remotelinux/linuxdevicetester.h index ce2188e4da..1a469af806 100644 --- a/src/plugins/remotelinux/linuxdevicetester.h +++ b/src/plugins/remotelinux/linuxdevicetester.h @@ -85,8 +85,6 @@ public: private slots: void handleConnected(); void handleConnectionFailure(); - void handleRemoteStdOut(const QByteArray &data); - void handleRemoteStdErr(const QByteArray &data); void handleProcessFinished(int exitStatus); void handlePortsGatheringError(const QString &message); void handlePortListReady(); diff --git a/src/plugins/remotelinux/remotelinuxapplicationrunner.cpp b/src/plugins/remotelinux/remotelinuxapplicationrunner.cpp index 38568ae9d4..c38b29444d 100644 --- a/src/plugins/remotelinux/remotelinuxapplicationrunner.cpp +++ b/src/plugins/remotelinux/remotelinuxapplicationrunner.cpp @@ -271,10 +271,8 @@ void AbstractRemoteLinuxApplicationRunner::startExecution(const QByteArray &remo d->runner = d->connection->createRemoteProcess(remoteCall); connect(d->runner.data(), SIGNAL(started()), SLOT(handleRemoteProcessStarted())); connect(d->runner.data(), SIGNAL(closed(int)), SLOT(handleRemoteProcessFinished(int))); - connect(d->runner.data(), SIGNAL(outputAvailable(QByteArray)), - SIGNAL(remoteOutput(QByteArray))); - connect(d->runner.data(), SIGNAL(errorOutputAvailable(QByteArray)), - SIGNAL(remoteErrorOutput(QByteArray))); + connect(d->runner.data(), SIGNAL(readyReadStandardOutput()), SLOT(handleRemoteStdout())); + connect(d->runner.data(), SIGNAL(readyReadStandardError()), SLOT(handleRemoteStderr())); d->state = ProcessStarting; d->runner->start(); } @@ -357,6 +355,16 @@ void AbstractRemoteLinuxApplicationRunner::handleUsedPortsAvailable() doAdditionalInitializations(); } +void AbstractRemoteLinuxApplicationRunner::handleRemoteStdout() +{ + emit remoteOutput(d->runner->readAllStandardOutput()); +} + +void AbstractRemoteLinuxApplicationRunner::handleRemoteStderr() +{ + emit remoteErrorOutput(d->runner->readAllStandardError()); +} + bool AbstractRemoteLinuxApplicationRunner::canRun(QString &whyNot) const { if (d->remoteExecutable.isEmpty()) { diff --git a/src/plugins/remotelinux/remotelinuxapplicationrunner.h b/src/plugins/remotelinux/remotelinuxapplicationrunner.h index 6a88745c90..87c2b16e7d 100644 --- a/src/plugins/remotelinux/remotelinuxapplicationrunner.h +++ b/src/plugins/remotelinux/remotelinuxapplicationrunner.h @@ -102,6 +102,8 @@ private slots: void handleRemoteProcessFinished(int exitStatus); void handlePortsGathererError(const QString &errorMsg); void handleUsedPortsAvailable(); + void handleRemoteStdout(); + void handleRemoteStderr(); private: |