Commit c6ef8996 authored by ck's avatar ck
Browse files

SSH: Add isConnected(), allow redundant calls to start().

parent b6d7f55b
......@@ -115,6 +115,7 @@ public:
}
}
bool isConnected() const { return channel() != -1; }
bool hasError() const { return !m_error.isEmpty(); }
QString error() const { return m_error; }
int channel() const { return m_channel; }
......@@ -255,6 +256,9 @@ InteractiveSshConnection::~InteractiveSshConnection()
bool InteractiveSshConnection::start()
{
if (isConnected())
return true;
if (!d->conn.start(true, wakeupReader, d->outputReader))
return false;
......@@ -297,6 +301,11 @@ InteractiveSshConnection::Ptr InteractiveSshConnection::create(const SshServerIn
return Ptr(new InteractiveSshConnection(server));
}
bool InteractiveSshConnection::isConnected() const
{
return d->conn.isConnected();
}
bool InteractiveSshConnection::hasError() const
{
return d->conn.hasError();
......@@ -335,11 +344,14 @@ SftpConnection::~SftpConnection()
bool SftpConnection::start()
{
if (isConnected())
return true;
if (!d->conn.start(false, 0, 0))
return false;
if (!d->conn.ssh->initSftp(d->sftp, d->conn.channel())
|| !d->sftp.setTimeout(d->conn.server().timeout)) {
d->conn.setError(tr("Error setting up SFTP subsystem"), true);
quit();
return false;
}
return true;
......@@ -456,6 +468,11 @@ void SftpConnection::quit()
d->conn.quit();
}
bool SftpConnection::isConnected() const
{
return d->conn.isConnected();
}
bool SftpConnection::hasError() const
{
return d->conn.hasError();
......
......@@ -81,6 +81,7 @@ public:
bool start();
void quit();
bool isConnected() const;
bool sendInput(const QByteArray &input); // Should normally end in newline.
QByteArray waitForRemoteOutput(int msecs = -1);
bool hasError() const;
......@@ -124,6 +125,7 @@ public:
static Ptr create(const SshServerInfo &server);
bool start();
void quit();
bool isConnected() const;
bool hasError() const;
QString error() const;
bool upload(const QString &localFilePath, const QByteArray &remoteFilePath);
......
......@@ -110,7 +110,7 @@ void AbstractMaemoRunControl::handleInitialCleanupFinished()
emit appendMessage(this, tr("Initial cleanup canceled by user."), false);
emit finished();
} else if (m_initialCleaner->hasError()) {
handleError(tr("Error running initial cleanup: %1.")
handleError(tr("Error running initial cleanup: %1")
.arg(m_initialCleaner->error()));
emit finished();
} else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment