SSH: Improve SshRemoteProcessRunner API.

It's silly that we fix the connection parameters in the constructor. A
given object of the class, once created, should be able to repeatedly
run any command with any connection.

Change-Id: Ia45b9d5b6f25c25fb46751cdb47cf81877d8f9a9
Reviewed-by: Christian Kandeler <christian.kandeler@nokia.com>
This commit is contained in:
Christian Kandeler
2011-11-09 14:19:50 +01:00
parent f9623b5ad6
commit fd26ab22e9
14 changed files with 116 additions and 172 deletions

View File

@@ -53,7 +53,7 @@ namespace Internal {
class StartGdbServerDialogPrivate
{
public:
StartGdbServerDialogPrivate() : processList(0), runner(0) {}
StartGdbServerDialogPrivate() : processList(0) {}
LinuxDeviceConfiguration::ConstPtr currentDevice() const
{
@@ -65,7 +65,7 @@ public:
QSortFilterProxyModel proxyModel;
Ui::StartGdbServerDialog ui;
RemoteLinuxUsedPortsGatherer gatherer;
Utils::SshRemoteProcessRunner *runner;
Utils::SshRemoteProcessRunner runner;
};
} // namespace Internal
@@ -203,7 +203,7 @@ void StartGdbServerDialog::startGdbServer()
void StartGdbServerDialog::handleConnectionError()
{
d->ui.textBrowser->append(tr("Connection error: %1")
.arg(d->runner->connection()->errorString()));
.arg(d->runner.connection()->errorString()));
emit processAborted();
}
@@ -238,20 +238,18 @@ void StartGdbServerDialog::handleProcessClosed(int status)
void StartGdbServerDialog::startGdbServerOnPort(int port, int pid)
{
LinuxDeviceConfiguration::ConstPtr device = d->currentDevice();
delete d->runner;
d->runner = new Utils::SshRemoteProcessRunner(device->sshParameters(), this);
connect(d->runner, SIGNAL(connectionError(Utils::SshError)),
SLOT(handleConnectionError()));
connect(d->runner, SIGNAL(processStarted()), SLOT(handleProcessStarted()));
connect(d->runner, SIGNAL(processOutputAvailable(QByteArray)),
SLOT(handleProcessOutputAvailable(QByteArray)));
connect(d->runner, SIGNAL(processErrorOutputAvailable(QByteArray)),
SLOT(handleProcessErrorOutput(QByteArray)));
connect(d->runner, SIGNAL(processClosed(int)), SLOT(handleProcessClosed(int)));
connect(&d->runner, SIGNAL(connectionError(Utils::SshError)),
SLOT(handleConnectionError()));
connect(&d->runner, SIGNAL(processStarted()), SLOT(handleProcessStarted()));
connect(&d->runner, SIGNAL(processOutputAvailable(QByteArray)),
SLOT(handleProcessOutputAvailable(QByteArray)));
connect(&d->runner, SIGNAL(processErrorOutputAvailable(QByteArray)),
SLOT(handleProcessErrorOutput(QByteArray)));
connect(&d->runner, SIGNAL(processClosed(int)), SLOT(handleProcessClosed(int)));
QByteArray cmd = "/usr/bin/gdbserver --attach localhost:"
+ QByteArray::number(port) + " " + QByteArray::number(pid);
d->runner->run(cmd);
d->runner.run(cmd, device->sshParameters());
}
} // namespace RemoteLinux