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>
This commit is contained in:
Christian Kandeler
2011-11-14 17:23:51 +01:00
parent 75a7bf2919
commit 232724cc11
20 changed files with 135 additions and 137 deletions

View File

@@ -103,12 +103,11 @@ void SshRemoteProcess::init()
{ {
connect(d, SIGNAL(started()), this, SIGNAL(started()), connect(d, SIGNAL(started()), this, SIGNAL(started()),
Qt::QueuedConnection); Qt::QueuedConnection);
connect(d, SIGNAL(outputAvailable(QByteArray)), this, connect(d, SIGNAL(readyReadStandardOutput()), this, SIGNAL(readyReadStandardOutput()),
SIGNAL(outputAvailable(QByteArray)), Qt::QueuedConnection);
connect(d, SIGNAL(errorOutputAvailable(QByteArray)), this,
SIGNAL(errorOutputAvailable(QByteArray)), Qt::QueuedConnection);
connect(d, SIGNAL(closed(int)), this, SIGNAL(closed(int)),
Qt::QueuedConnection); Qt::QueuedConnection);
connect(d, SIGNAL(readyReadStandardError()), this,
SIGNAL(readyReadStandardError()), Qt::QueuedConnection);
connect(d, SIGNAL(closed(int)), this, SIGNAL(closed(int)), Qt::QueuedConnection);
} }
void SshRemoteProcess::addToEnvironment(const QByteArray &var, const QByteArray &value) void SshRemoteProcess::addToEnvironment(const QByteArray &var, const QByteArray &value)
@@ -168,6 +167,9 @@ int SshRemoteProcess::exitCode() const { return d->m_exitCode; }
QByteArray SshRemoteProcess::exitSignal() const { return d->m_signal; } QByteArray SshRemoteProcess::exitSignal() const { return d->m_signal; }
QByteArray SshRemoteProcess::readAllStandardOutput() { return d->readAllStandardOutput(); }
QByteArray SshRemoteProcess::readAllStandardError() { return d->readAllStandardError(); }
namespace Internal { namespace Internal {
SshRemoteProcessPrivate::SshRemoteProcessPrivate(const QByteArray &command, SshRemoteProcessPrivate::SshRemoteProcessPrivate(const QByteArray &command,
@@ -212,6 +214,20 @@ void SshRemoteProcessPrivate::setProcState(ProcessState newState)
} }
} }
QByteArray SshRemoteProcessPrivate::readAllStandardOutput()
{
const QByteArray data = m_stdout;
m_stdout.clear();
return data;
}
QByteArray SshRemoteProcessPrivate::readAllStandardError()
{
const QByteArray data = m_stderr;
m_stderr.clear();
return data;
}
void SshRemoteProcessPrivate::closeHook() void SshRemoteProcessPrivate::closeHook()
{ {
if (m_wasRunning) { if (m_wasRunning) {
@@ -268,16 +284,19 @@ void SshRemoteProcessPrivate::handleChannelFailure()
void SshRemoteProcessPrivate::handleChannelDataInternal(const QByteArray &data) void SshRemoteProcessPrivate::handleChannelDataInternal(const QByteArray &data)
{ {
emit outputAvailable(data); m_stdout += data;
emit readyReadStandardOutput();
} }
void SshRemoteProcessPrivate::handleChannelExtendedDataInternal(quint32 type, void SshRemoteProcessPrivate::handleChannelExtendedDataInternal(quint32 type,
const QByteArray &data) const QByteArray &data)
{ {
if (type != SSH_EXTENDED_DATA_STDERR) if (type != SSH_EXTENDED_DATA_STDERR) {
qWarning("Unknown extended data type %u", type); qWarning("Unknown extended data type %u", type);
else } else {
emit errorOutputAvailable(data); m_stderr += data;
emit readyReadStandardError();
}
} }
void SshRemoteProcessPrivate::handleExitStatus(const SshChannelExitStatus &exitStatus) void SshRemoteProcessPrivate::handleExitStatus(const SshChannelExitStatus &exitStatus)

View File

@@ -92,6 +92,9 @@ public:
int exitCode() const; int exitCode() const;
QByteArray exitSignal() const; QByteArray exitSignal() const;
QByteArray readAllStandardOutput();
QByteArray readAllStandardError();
// Note: This is ignored by the OpenSSH server. // Note: This is ignored by the OpenSSH server.
void sendSignal(const QByteArray &signal); void sendSignal(const QByteArray &signal);
void kill() { sendSignal(KillSignal); } void kill() { sendSignal(KillSignal); }
@@ -100,8 +103,9 @@ public:
signals: signals:
void started(); void started();
void outputAvailable(const QByteArray &output);
void errorOutputAvailable(const QByteArray &output); void readyReadStandardOutput();
void readyReadStandardError();
/* /*
* Parameter is of type ExitStatus, but we use int because of * Parameter is of type ExitStatus, but we use int because of

View File

@@ -60,10 +60,13 @@ public:
virtual void closeHook(); virtual void closeHook();
QByteArray readAllStandardOutput();
QByteArray readAllStandardError();
signals: signals:
void started(); void started();
void outputAvailable(const QByteArray &output); void readyReadStandardOutput();
void errorOutputAvailable(const QByteArray &output); void readyReadStandardError();
void closed(int exitStatus); void closed(int exitStatus);
private: private:
@@ -96,6 +99,9 @@ private:
bool m_useTerminal; bool m_useTerminal;
SshPseudoTerminal m_terminal; SshPseudoTerminal m_terminal;
QByteArray m_stdout;
QByteArray m_stderr;
SshRemoteProcess *m_proc; SshRemoteProcess *m_proc;
}; };

View File

@@ -74,6 +74,8 @@ private slots:
void handleDisconnected(); void handleDisconnected();
void handleProcessStarted(); void handleProcessStarted();
void handleProcessFinished(int exitStatus); void handleProcessFinished(int exitStatus);
void handleStdout();
void handleStderr();
private: private:
enum State { Inactive, Connecting, Connected, ProcessRunning }; enum State { Inactive, Connecting, Connected, ProcessRunning };
@@ -150,10 +152,8 @@ void SshRemoteProcessRunnerPrivate::handleConnected()
connect(m_process.data(), SIGNAL(started()), SLOT(handleProcessStarted())); connect(m_process.data(), SIGNAL(started()), SLOT(handleProcessStarted()));
connect(m_process.data(), SIGNAL(closed(int)), connect(m_process.data(), SIGNAL(closed(int)),
SLOT(handleProcessFinished(int))); SLOT(handleProcessFinished(int)));
connect(m_process.data(), SIGNAL(outputAvailable(QByteArray)), connect(m_process.data(), SIGNAL(readyReadStandardOutput()), SLOT(handleStdout()));
SIGNAL(processOutputAvailable(QByteArray))); connect(m_process.data(), SIGNAL(readyReadStandardError()), SLOT(handleStderr()));
connect(m_process.data(), SIGNAL(errorOutputAvailable(QByteArray)),
SIGNAL(processErrorOutputAvailable(QByteArray)));
if (m_runInTerminal) if (m_runInTerminal)
m_process->requestTerminal(m_terminal); m_process->requestTerminal(m_terminal);
m_process->start(); m_process->start();
@@ -198,6 +198,16 @@ void SshRemoteProcessRunnerPrivate::handleProcessFinished(int exitStatus)
emit processClosed(exitStatus); emit processClosed(exitStatus);
} }
void SshRemoteProcessRunnerPrivate::handleStdout()
{
emit processOutputAvailable(m_process->readAllStandardOutput());
}
void SshRemoteProcessRunnerPrivate::handleStderr()
{
emit processErrorOutputAvailable(m_process->readAllStandardError());
}
void SshRemoteProcessRunnerPrivate::setState(State state) void SshRemoteProcessRunnerPrivate::setState(State state)
{ {
if (m_state != state) { if (m_state != state) {

View File

@@ -151,8 +151,8 @@ void RemoteGdbProcess::handleAppOutputReaderStarted()
QTC_ASSERT(m_state == StartingFifoReader, return); QTC_ASSERT(m_state == StartingFifoReader, return);
setState(StartingGdb); setState(StartingGdb);
connect(m_appOutputReader.data(), SIGNAL(outputAvailable(QByteArray)), connect(m_appOutputReader.data(), SIGNAL(readyReadStandardOutput()),
this, SLOT(handleAppOutput(QByteArray))); this, SLOT(handleAppOutput()));
QByteArray cmdLine = "DISPLAY=:0.0 " + m_command.toUtf8() + ' ' QByteArray cmdLine = "DISPLAY=:0.0 " + m_command.toUtf8() + ' '
+ Utils::QtcProcess::joinArgsUnix(m_cmdArgs).toUtf8() + Utils::QtcProcess::joinArgsUnix(m_cmdArgs).toUtf8()
+ " -tty=" + m_appOutputFileName; + " -tty=" + m_appOutputFileName;
@@ -163,10 +163,10 @@ void RemoteGdbProcess::handleAppOutputReaderStarted()
SLOT(handleGdbStarted())); SLOT(handleGdbStarted()));
connect(m_gdbProc.data(), SIGNAL(closed(int)), this, connect(m_gdbProc.data(), SIGNAL(closed(int)), this,
SLOT(handleGdbFinished(int))); SLOT(handleGdbFinished(int)));
connect(m_gdbProc.data(), SIGNAL(outputAvailable(QByteArray)), this, connect(m_gdbProc.data(), SIGNAL(readyReadStandardOutput()), this,
SLOT(handleGdbOutput(QByteArray))); SLOT(handleGdbOutput()));
connect(m_gdbProc.data(), SIGNAL(errorOutputAvailable(QByteArray)), this, connect(m_gdbProc.data(), SIGNAL(readyReadStandardError()), this,
SLOT(handleErrOutput(QByteArray))); SLOT(handleErrOutput()));
m_gdbProc->start(); m_gdbProc->start();
} }
@@ -265,12 +265,13 @@ QString RemoteGdbProcess::errorString() const
return m_error; return m_error;
} }
void RemoteGdbProcess::handleGdbOutput(const QByteArray &output) void RemoteGdbProcess::handleGdbOutput()
{ {
if (m_state == Inactive) if (m_state == Inactive)
return; return;
QTC_ASSERT(m_state == RunningGdb, return); QTC_ASSERT(m_state == RunningGdb, return);
const QByteArray &output = m_gdbProc->readAllStandardOutput();
// TODO: Carriage return removal still necessary? // TODO: Carriage return removal still necessary?
m_currentGdbOutput += removeCarriageReturn(output); m_currentGdbOutput += removeCarriageReturn(output);
#if 0 #if 0
@@ -343,16 +344,16 @@ void RemoteGdbProcess::sendInput(const QByteArray &data)
m_gdbProc->sendInput(data); m_gdbProc->sendInput(data);
} }
void RemoteGdbProcess::handleAppOutput(const QByteArray &output) void RemoteGdbProcess::handleAppOutput()
{ {
if (m_state == RunningGdb) if (m_state == RunningGdb)
m_adapter->handleApplicationOutput(output); m_adapter->handleApplicationOutput(m_appOutputReader->readAllStandardOutput());
} }
void RemoteGdbProcess::handleErrOutput(const QByteArray &output) void RemoteGdbProcess::handleErrOutput()
{ {
if (m_state == RunningGdb) { if (m_state == RunningGdb) {
m_errorOutput += output; m_errorOutput += m_gdbProc->readAllStandardError();
emit readyReadStandardError(); emit readyReadStandardError();
} }
} }

View File

@@ -88,9 +88,9 @@ private slots:
void handleAppOutputReaderFinished(int exitStatus); void handleAppOutputReaderFinished(int exitStatus);
void handleGdbStarted(); void handleGdbStarted();
void handleGdbFinished(int exitStatus); void handleGdbFinished(int exitStatus);
void handleGdbOutput(const QByteArray &output); void handleGdbOutput();
void handleAppOutput(const QByteArray &output); void handleAppOutput();
void handleErrOutput(const QByteArray &output); void handleErrOutput();
private: private:
enum State { enum State {

View File

@@ -136,12 +136,9 @@ void MaemoRemoteMounter::unmount()
.arg(remoteSudo, m_mountSpecs.at(i).mountSpec.remoteMountPoint); .arg(remoteSudo, m_mountSpecs.at(i).mountSpec.remoteMountPoint);
} }
m_umountStderr.clear();
m_unmountProcess = m_connection->createRemoteProcess(remoteCall.toUtf8()); m_unmountProcess = m_connection->createRemoteProcess(remoteCall.toUtf8());
connect(m_unmountProcess.data(), SIGNAL(closed(int)), this, connect(m_unmountProcess.data(), SIGNAL(closed(int)), this,
SLOT(handleUnmountProcessFinished(int))); SLOT(handleUnmountProcessFinished(int)));
connect(m_unmountProcess.data(), SIGNAL(errorOutputAvailable(QByteArray)),
this, SLOT(handleUmountStderr(QByteArray)));
setState(Unmounting); setState(Unmounting);
m_unmountProcess->start(); m_unmountProcess->start();
} }
@@ -176,10 +173,9 @@ void MaemoRemoteMounter::handleUnmountProcessFinished(int exitStatus)
emit reportProgress(tr("Finished unmounting.")); emit reportProgress(tr("Finished unmounting."));
emit unmounted(); emit unmounted();
} else { } else {
if (!m_umountStderr.isEmpty()) { const QByteArray &umountStderr = m_unmountProcess->readAllStandardError();
errorMsg += tr("\nstderr was: '%1'") if (!umountStderr.isEmpty())
.arg(QString::fromUtf8(m_umountStderr)); errorMsg += tr("\nstderr was: '%1'").arg(QString::fromUtf8(umountStderr));
}
emit error(errorMsg); emit error(errorMsg);
} }
} }
@@ -229,14 +225,11 @@ void MaemoRemoteMounter::startUtfsClients()
} }
emit reportProgress(tr("Starting remote UTFS clients...")); emit reportProgress(tr("Starting remote UTFS clients..."));
m_utfsClientStderr.clear();
m_mountProcess = m_connection->createRemoteProcess(remoteCall.toUtf8()); m_mountProcess = m_connection->createRemoteProcess(remoteCall.toUtf8());
connect(m_mountProcess.data(), SIGNAL(started()), this, connect(m_mountProcess.data(), SIGNAL(started()), this,
SLOT(handleUtfsClientsStarted())); SLOT(handleUtfsClientsStarted()));
connect(m_mountProcess.data(), SIGNAL(closed(int)), this, connect(m_mountProcess.data(), SIGNAL(closed(int)), this,
SLOT(handleUtfsClientsFinished(int))); SLOT(handleUtfsClientsFinished(int)));
connect(m_mountProcess.data(), SIGNAL(errorOutputAvailable(QByteArray)),
this, SLOT(handleUtfsClientStderr(QByteArray)));
m_mountProcess->start(); m_mountProcess->start();
setState(UtfsClientsStarting); setState(UtfsClientsStarting);
@@ -268,9 +261,9 @@ void MaemoRemoteMounter::handleUtfsClientsFinished(int exitStatus)
} else { } else {
QString errMsg = tr("Failure running UTFS client: %1") QString errMsg = tr("Failure running UTFS client: %1")
.arg(m_mountProcess->errorString()); .arg(m_mountProcess->errorString());
if (!m_utfsClientStderr.isEmpty()) const QByteArray &mountStderr = m_mountProcess->readAllStandardError();
errMsg += tr("\nstderr was: '%1'") if (!mountStderr.isEmpty())
.arg(QString::fromUtf8(m_utfsClientStderr)); errMsg += tr("\nstderr was: '%1'").arg(QString::fromUtf8(mountStderr));
emit error(errMsg); emit error(errMsg);
} }
} }
@@ -343,18 +336,6 @@ void MaemoRemoteMounter::handleUtfsServerFinished(int /* exitCode */,
handleUtfsServerError(static_cast<QProcess *>(sender())->error()); handleUtfsServerError(static_cast<QProcess *>(sender())->error());
} }
void MaemoRemoteMounter::handleUtfsClientStderr(const QByteArray &output)
{
if (m_state != Inactive)
m_utfsClientStderr += output;
}
void MaemoRemoteMounter::handleUmountStderr(const QByteArray &output)
{
if (m_state != Inactive)
m_umountStderr += output;
}
QString MaemoRemoteMounter::utfsClientOnDevice() const QString MaemoRemoteMounter::utfsClientOnDevice() const
{ {
return QLatin1String("/usr/lib/mad-developer/utfs-client"); return QLatin1String("/usr/lib/mad-developer/utfs-client");

View File

@@ -91,9 +91,7 @@ signals:
private slots: private slots:
void handleUtfsClientsStarted(); void handleUtfsClientsStarted();
void handleUtfsClientsFinished(int exitStatus); void handleUtfsClientsFinished(int exitStatus);
void handleUtfsClientStderr(const QByteArray &output);
void handleUnmountProcessFinished(int exitStatus); void handleUnmountProcessFinished(int exitStatus);
void handleUmountStderr(const QByteArray &output);
void handleUtfsServerError(QProcess::ProcessError procError); void handleUtfsServerError(QProcess::ProcessError procError);
void handleUtfsServerFinished(int exitCode, void handleUtfsServerFinished(int exitCode,
QProcess::ExitStatus exitStatus); QProcess::ExitStatus exitStatus);
@@ -134,8 +132,6 @@ private:
typedef QSharedPointer<QProcess> ProcPtr; typedef QSharedPointer<QProcess> ProcPtr;
QList<ProcPtr> m_utfsServers; QList<ProcPtr> m_utfsServers;
QByteArray m_utfsClientStderr;
QByteArray m_umountStderr;
RemoteLinux::PortList *m_freePorts; RemoteLinux::PortList *m_freePorts;
const RemoteLinux::RemoteLinuxUsedPortsGatherer *m_portsGatherer; const RemoteLinux::RemoteLinuxUsedPortsGatherer *m_portsGatherer;
bool m_remoteMountsAllowed; bool m_remoteMountsAllowed;

View File

@@ -233,10 +233,8 @@ void GenericDirectUploadService::handleMkdirFinished(int exitStatus)
// See comment in SftpChannel::createLink as to why we can't use it. // See comment in SftpChannel::createLink as to why we can't use it.
d->lnProc = connection()->createRemoteProcess(command.toUtf8()); d->lnProc = connection()->createRemoteProcess(command.toUtf8());
connect(d->lnProc.data(), SIGNAL(closed(int)), SLOT(handleLnFinished(int))); connect(d->lnProc.data(), SIGNAL(closed(int)), SLOT(handleLnFinished(int)));
connect(d->lnProc.data(), SIGNAL(outputAvailable(QByteArray)), connect(d->lnProc.data(), SIGNAL(readyReadStandardOutput()), SLOT(handleStdOutData()));
SLOT(handleStdOutData(QByteArray))); connect(d->lnProc.data(), SIGNAL(readyReadStandardError()), SLOT(handleStdErrData()));
connect(d->lnProc.data(), SIGNAL(errorOutputAvailable(QByteArray)),
SLOT(handleStdErrData(QByteArray)));
d->lnProc->start(); d->lnProc->start();
} else { } else {
const SftpJobId job = d->uploader->uploadFile(df.localFilePath, remoteFilePath, 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() void GenericDirectUploadService::stopDeployment()
@@ -328,10 +330,8 @@ void GenericDirectUploadService::uploadNextFile()
const QString command = QLatin1String("mkdir -p ") + dirToCreate; const QString command = QLatin1String("mkdir -p ") + dirToCreate;
d->mkdirProc = connection()->createRemoteProcess(command.toUtf8()); d->mkdirProc = connection()->createRemoteProcess(command.toUtf8());
connect(d->mkdirProc.data(), SIGNAL(closed(int)), SLOT(handleMkdirFinished(int))); connect(d->mkdirProc.data(), SIGNAL(closed(int)), SLOT(handleMkdirFinished(int)));
connect(d->mkdirProc.data(), SIGNAL(outputAvailable(QByteArray)), connect(d->mkdirProc.data(), SIGNAL(readyReadStandardOutput()), SLOT(handleStdOutData()));
SLOT(handleStdOutData(QByteArray))); connect(d->mkdirProc.data(), SIGNAL(readyReadStandardError()), SLOT(handleStdErrData()));
connect(d->mkdirProc.data(), SIGNAL(errorOutputAvailable(QByteArray)),
SLOT(handleStdErrData(QByteArray)));
emit progressMessage(tr("Uploading file '%1'...") emit progressMessage(tr("Uploading file '%1'...")
.arg(QDir::toNativeSeparators(df.localFilePath))); .arg(QDir::toNativeSeparators(df.localFilePath)));
d->mkdirProc->start(); d->mkdirProc->start();

View File

@@ -69,8 +69,8 @@ private slots:
void handleUploadFinished(Utils::SftpJobId jobId, const QString &errorMsg); void handleUploadFinished(Utils::SftpJobId jobId, const QString &errorMsg);
void handleMkdirFinished(int exitStatus); void handleMkdirFinished(int exitStatus);
void handleLnFinished(int exitStatus); void handleLnFinished(int exitStatus);
void handleStdOutData(const QByteArray &data); void handleStdOutData();
void handleStdErrData(const QByteArray &data); void handleStdErrData();
private: private:
void checkDeploymentNeeded(const DeployableFile &file) const; void checkDeploymentNeeded(const DeployableFile &file) const;

View File

@@ -57,8 +57,6 @@ public:
SshConnection::Ptr connection; SshConnection::Ptr connection;
SshRemoteProcess::Ptr process; SshRemoteProcess::Ptr process;
RemoteLinuxUsedPortsGatherer portsGatherer; RemoteLinuxUsedPortsGatherer portsGatherer;
QByteArray remoteStdout;
QByteArray remoteStderr;
State state; State state;
}; };
@@ -127,10 +125,6 @@ void GenericLinuxDeviceTester::handleConnected()
QTC_ASSERT(d->state == Connecting, return); QTC_ASSERT(d->state == Connecting, return);
d->process = d->connection->createRemoteProcess("uname -rsm"); 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))); connect(d->process.data(), SIGNAL(closed(int)), SLOT(handleProcessFinished(int)));
emit progressMessage("Checking kernel version..."); emit progressMessage("Checking kernel version...");
@@ -146,31 +140,18 @@ void GenericLinuxDeviceTester::handleConnectionFailure()
setFinished(TestFailure); 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) void GenericLinuxDeviceTester::handleProcessFinished(int exitStatus)
{ {
QTC_ASSERT(d->state == RunningUname, return); QTC_ASSERT(d->state == RunningUname, return);
if (exitStatus != SshRemoteProcess::ExitedNormally || d->process->exitCode() != 0) { if (exitStatus != SshRemoteProcess::ExitedNormally || d->process->exitCode() != 0) {
if (!d->remoteStderr.isEmpty()) const QByteArray stderrOutput = d->process->readAllStandardError();
emit errorMessage(tr("uname failed: %1\n").arg(QString::fromUtf8(d->remoteStderr))); if (!stderrOutput.isEmpty())
emit errorMessage(tr("uname failed: %1\n").arg(QString::fromUtf8(stderrOutput)));
else else
emit errorMessage(tr("uname failed.\n")); emit errorMessage(tr("uname failed.\n"));
} else { } else {
emit progressMessage(QString::fromUtf8(d->remoteStdout)); emit progressMessage(QString::fromUtf8(d->process->readAllStandardOutput()));
} }
connect(&d->portsGatherer, SIGNAL(error(QString)), SLOT(handlePortsGatheringError(QString))); connect(&d->portsGatherer, SIGNAL(error(QString)), SLOT(handlePortsGatheringError(QString)));
@@ -209,8 +190,6 @@ void GenericLinuxDeviceTester::handlePortListReady()
void GenericLinuxDeviceTester::setFinished(TestResult result) void GenericLinuxDeviceTester::setFinished(TestResult result)
{ {
d->state = Inactive; d->state = Inactive;
d->remoteStdout.clear();
d->remoteStderr.clear();
disconnect(d->connection.data(), 0, this, 0); disconnect(d->connection.data(), 0, this, 0);
disconnect(&d->portsGatherer, 0, this, 0); disconnect(&d->portsGatherer, 0, this, 0);
emit finished(result); emit finished(result);

View File

@@ -85,8 +85,6 @@ public:
private slots: private slots:
void handleConnected(); void handleConnected();
void handleConnectionFailure(); void handleConnectionFailure();
void handleRemoteStdOut(const QByteArray &data);
void handleRemoteStdErr(const QByteArray &data);
void handleProcessFinished(int exitStatus); void handleProcessFinished(int exitStatus);
void handlePortsGatheringError(const QString &message); void handlePortsGatheringError(const QString &message);
void handlePortListReady(); void handlePortListReady();

View File

@@ -271,10 +271,8 @@ void AbstractRemoteLinuxApplicationRunner::startExecution(const QByteArray &remo
d->runner = d->connection->createRemoteProcess(remoteCall); d->runner = d->connection->createRemoteProcess(remoteCall);
connect(d->runner.data(), SIGNAL(started()), SLOT(handleRemoteProcessStarted())); connect(d->runner.data(), SIGNAL(started()), SLOT(handleRemoteProcessStarted()));
connect(d->runner.data(), SIGNAL(closed(int)), SLOT(handleRemoteProcessFinished(int))); connect(d->runner.data(), SIGNAL(closed(int)), SLOT(handleRemoteProcessFinished(int)));
connect(d->runner.data(), SIGNAL(outputAvailable(QByteArray)), connect(d->runner.data(), SIGNAL(readyReadStandardOutput()), SLOT(handleRemoteStdout()));
SIGNAL(remoteOutput(QByteArray))); connect(d->runner.data(), SIGNAL(readyReadStandardError()), SLOT(handleRemoteStderr()));
connect(d->runner.data(), SIGNAL(errorOutputAvailable(QByteArray)),
SIGNAL(remoteErrorOutput(QByteArray)));
d->state = ProcessStarting; d->state = ProcessStarting;
d->runner->start(); d->runner->start();
} }
@@ -357,6 +355,16 @@ void AbstractRemoteLinuxApplicationRunner::handleUsedPortsAvailable()
doAdditionalInitializations(); doAdditionalInitializations();
} }
void AbstractRemoteLinuxApplicationRunner::handleRemoteStdout()
{
emit remoteOutput(d->runner->readAllStandardOutput());
}
void AbstractRemoteLinuxApplicationRunner::handleRemoteStderr()
{
emit remoteErrorOutput(d->runner->readAllStandardError());
}
bool AbstractRemoteLinuxApplicationRunner::canRun(QString &whyNot) const bool AbstractRemoteLinuxApplicationRunner::canRun(QString &whyNot) const
{ {
if (d->remoteExecutable.isEmpty()) { if (d->remoteExecutable.isEmpty()) {

View File

@@ -102,6 +102,8 @@ private slots:
void handleRemoteProcessFinished(int exitStatus); void handleRemoteProcessFinished(int exitStatus);
void handlePortsGathererError(const QString &errorMsg); void handlePortsGathererError(const QString &errorMsg);
void handleUsedPortsAvailable(); void handleUsedPortsAvailable();
void handleRemoteStdout();
void handleRemoteStderr();
private: private:

View File

@@ -218,8 +218,8 @@ void CallgrindController::getLocalDataFile()
// if there are files like callgrind.out.PID.NUM, set it to the most recent one of those // if there are files like callgrind.out.PID.NUM, set it to the most recent one of those
QString cmd = QString("ls -t %1* | head -n 1").arg(fileName); QString cmd = QString("ls -t %1* | head -n 1").arg(fileName);
m_findRemoteFile = m_ssh->createRemoteProcess(cmd.toUtf8()); m_findRemoteFile = m_ssh->createRemoteProcess(cmd.toUtf8());
connect(m_findRemoteFile.data(), SIGNAL(outputAvailable(QByteArray)), connect(m_findRemoteFile.data(), SIGNAL(readyReadStandardOutput()), this,
this, SLOT(foundRemoteFile(QByteArray))); SLOT(foundRemoteFile()));
m_findRemoteFile->start(); m_findRemoteFile->start();
} else { } else {
QDir dir(workingDir, QString("%1.*").arg(baseFileName), QDir::Time); QDir dir(workingDir, QString("%1.*").arg(baseFileName), QDir::Time);
@@ -232,9 +232,9 @@ void CallgrindController::getLocalDataFile()
} }
} }
void CallgrindController::foundRemoteFile(const QByteArray &file) void CallgrindController::foundRemoteFile()
{ {
m_remoteFile = file.trimmed(); m_remoteFile = m_findRemoteFile->readAllStandardOutput().trimmed();
m_sftp = m_ssh->createSftpChannel(); m_sftp = m_ssh->createSftpChannel();
connect(m_sftp.data(), SIGNAL(finished(Utils::SftpJobId,QString)), connect(m_sftp.data(), SIGNAL(finished(Utils::SftpJobId,QString)),

View File

@@ -87,7 +87,7 @@ private Q_SLOTS:
void processError(QProcess::ProcessError); void processError(QProcess::ProcessError);
void processFinished(int, QProcess::ExitStatus); void processFinished(int, QProcess::ExitStatus);
void foundRemoteFile(const QByteArray &file); void foundRemoteFile();
void sftpInitialized(); void sftpInitialized();
void sftpJobFinished(Utils::SftpJobId job, const QString &error); void sftpJobFinished(Utils::SftpJobId job, const QString &error);

View File

@@ -210,10 +210,8 @@ void RemoteValgrindProcess::connected()
cmd += m_valgrindExe + ' ' + arguments; cmd += m_valgrindExe + ' ' + arguments;
m_process = m_connection->createRemoteProcess(cmd.toUtf8()); m_process = m_connection->createRemoteProcess(cmd.toUtf8());
connect(m_process.data(), SIGNAL(errorOutputAvailable(QByteArray)), connect(m_process.data(), SIGNAL(readyReadStandardError()), this, SLOT(standardError()));
this, SLOT(standardError(QByteArray))); connect(m_process.data(), SIGNAL(readyReadStandardOutput()), this, SLOT(standardOutput()));
connect(m_process.data(), SIGNAL(outputAvailable(QByteArray)),
this, SLOT(standardOutput(QByteArray)));
connect(m_process.data(), SIGNAL(closed(int)), connect(m_process.data(), SIGNAL(closed(int)),
this, SLOT(closed(int))); this, SLOT(closed(int)));
connect(m_process.data(), SIGNAL(started()), connect(m_process.data(), SIGNAL(started()),
@@ -250,17 +248,15 @@ void RemoteValgrindProcess::processStarted()
).arg(proc, QFileInfo(m_debuggee).fileName()); ).arg(proc, QFileInfo(m_debuggee).fileName());
m_findPID = m_connection->createRemoteProcess(cmd.toUtf8()); m_findPID = m_connection->createRemoteProcess(cmd.toUtf8());
connect(m_findPID.data(), SIGNAL(errorOutputAvailable(QByteArray)), connect(m_findPID.data(), SIGNAL(readyReadStandardError()), this, SLOT(standardError()));
this, SLOT(standardOutput(QByteArray))); connect(m_findPID.data(), SIGNAL(readyReadStandardOutput()), SLOT(findPIDOutputReceived()));
connect(m_findPID.data(), SIGNAL(outputAvailable(QByteArray)),
this, SLOT(findPIDOutputReceived(QByteArray)));
m_findPID->start(); m_findPID->start();
} }
void RemoteValgrindProcess::findPIDOutputReceived(const QByteArray &output) void RemoteValgrindProcess::findPIDOutputReceived()
{ {
bool ok; bool ok;
m_pid = output.trimmed().toLongLong(&ok); m_pid = m_findPID->readAllStandardOutput().trimmed().toLongLong(&ok);
if (!ok) { if (!ok) {
m_pid = 0; m_pid = 0;
m_errorString = tr("Could not determine remote PID."); m_errorString = tr("Could not determine remote PID.");
@@ -272,14 +268,14 @@ void RemoteValgrindProcess::findPIDOutputReceived(const QByteArray &output)
} }
} }
void RemoteValgrindProcess::standardOutput(const QByteArray &output) void RemoteValgrindProcess::standardOutput()
{ {
emit processOutput(output, Utils::StdOutFormat); emit processOutput(m_process->readAllStandardOutput(), Utils::StdOutFormat);
} }
void RemoteValgrindProcess::standardError(const QByteArray &output) void RemoteValgrindProcess::standardError()
{ {
emit processOutput(output, Utils::StdErrFormat); emit processOutput(m_process->readAllStandardError(), Utils::StdErrFormat);
} }
void RemoteValgrindProcess::error(Utils::SshError error) void RemoteValgrindProcess::error(Utils::SshError error)

View File

@@ -146,9 +146,9 @@ private slots:
void connected(); void connected();
void error(Utils::SshError error); void error(Utils::SshError error);
void processStarted(); void processStarted();
void findPIDOutputReceived(const QByteArray &output); void findPIDOutputReceived();
void standardOutput(const QByteArray &output); void standardOutput();
void standardError(const QByteArray &output); void standardError();
private: private:
Utils::SshConnectionParameters m_params; Utils::SshConnectionParameters m_params;

View File

@@ -83,10 +83,8 @@ void Shell::handleConnected()
{ {
m_shell = m_connection->createRemoteShell(); m_shell = m_connection->createRemoteShell();
connect(m_shell.data(), SIGNAL(started()), SLOT(handleShellStarted())); connect(m_shell.data(), SIGNAL(started()), SLOT(handleShellStarted()));
connect(m_shell.data(), SIGNAL(outputAvailable(QByteArray)), connect(m_shell.data(), SIGNAL(readyReadStandardOutput()), SLOT(handleRemoteStdout()));
SLOT(handleRemoteStdout(QByteArray))); connect(m_shell.data(), SIGNAL(readyReadStandardError()), SLOT(handleRemoteStderr()));
connect(m_shell.data(), SIGNAL(errorOutputAvailable(QByteArray)),
SLOT(handleRemoteStderr(QByteArray)));
connect(m_shell.data(), SIGNAL(closed(int)), SLOT(handleChannelClosed(int))); connect(m_shell.data(), SIGNAL(closed(int)), SLOT(handleChannelClosed(int)));
m_shell->start(); m_shell->start();
} }
@@ -97,14 +95,14 @@ void Shell::handleShellStarted()
connect(notifier, SIGNAL(activated(int)), SLOT(handleStdin())); connect(notifier, SIGNAL(activated(int)), SLOT(handleStdin()));
} }
void Shell::handleRemoteStdout(const QByteArray &output) void Shell::handleRemoteStdout()
{ {
std::cout << output.data() << std::flush; std::cout << m_shell->readAllStandardOutput().data() << std::flush;
} }
void Shell::handleRemoteStderr(const QByteArray &output) void Shell::handleRemoteStderr()
{ {
std::cerr << output.data() << std::flush; std::cerr << m_shell->readAllStandardError().data() << std::flush;
} }
void Shell::handleChannelClosed(int exitStatus) void Shell::handleChannelClosed(int exitStatus)

View File

@@ -56,8 +56,8 @@ public:
private slots: private slots:
void handleConnected(); void handleConnected();
void handleConnectionError(); void handleConnectionError();
void handleRemoteStdout(const QByteArray &output); void handleRemoteStdout();
void handleRemoteStderr(const QByteArray &output); void handleRemoteStderr();
void handleShellMessage(const QString &message); void handleShellMessage(const QString &message);
void handleChannelClosed(int exitStatus); void handleChannelClosed(int exitStatus);
void handleShellStarted(); void handleShellStarted();