forked from qt-creator/qt-creator
SSH: Add isConnected(), allow redundant calls to start().
This commit is contained in:
@@ -115,6 +115,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isConnected() const { return channel() != -1; }
|
||||||
bool hasError() const { return !m_error.isEmpty(); }
|
bool hasError() const { return !m_error.isEmpty(); }
|
||||||
QString error() const { return m_error; }
|
QString error() const { return m_error; }
|
||||||
int channel() const { return m_channel; }
|
int channel() const { return m_channel; }
|
||||||
@@ -255,6 +256,9 @@ InteractiveSshConnection::~InteractiveSshConnection()
|
|||||||
|
|
||||||
bool InteractiveSshConnection::start()
|
bool InteractiveSshConnection::start()
|
||||||
{
|
{
|
||||||
|
if (isConnected())
|
||||||
|
return true;
|
||||||
|
|
||||||
if (!d->conn.start(true, wakeupReader, d->outputReader))
|
if (!d->conn.start(true, wakeupReader, d->outputReader))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -297,6 +301,11 @@ InteractiveSshConnection::Ptr InteractiveSshConnection::create(const SshServerIn
|
|||||||
return Ptr(new InteractiveSshConnection(server));
|
return Ptr(new InteractiveSshConnection(server));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool InteractiveSshConnection::isConnected() const
|
||||||
|
{
|
||||||
|
return d->conn.isConnected();
|
||||||
|
}
|
||||||
|
|
||||||
bool InteractiveSshConnection::hasError() const
|
bool InteractiveSshConnection::hasError() const
|
||||||
{
|
{
|
||||||
return d->conn.hasError();
|
return d->conn.hasError();
|
||||||
@@ -335,11 +344,14 @@ SftpConnection::~SftpConnection()
|
|||||||
|
|
||||||
bool SftpConnection::start()
|
bool SftpConnection::start()
|
||||||
{
|
{
|
||||||
|
if (isConnected())
|
||||||
|
return true;
|
||||||
if (!d->conn.start(false, 0, 0))
|
if (!d->conn.start(false, 0, 0))
|
||||||
return false;
|
return false;
|
||||||
if (!d->conn.ssh->initSftp(d->sftp, d->conn.channel())
|
if (!d->conn.ssh->initSftp(d->sftp, d->conn.channel())
|
||||||
|| !d->sftp.setTimeout(d->conn.server().timeout)) {
|
|| !d->sftp.setTimeout(d->conn.server().timeout)) {
|
||||||
d->conn.setError(tr("Error setting up SFTP subsystem"), true);
|
d->conn.setError(tr("Error setting up SFTP subsystem"), true);
|
||||||
|
quit();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -456,6 +468,11 @@ void SftpConnection::quit()
|
|||||||
d->conn.quit();
|
d->conn.quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SftpConnection::isConnected() const
|
||||||
|
{
|
||||||
|
return d->conn.isConnected();
|
||||||
|
}
|
||||||
|
|
||||||
bool SftpConnection::hasError() const
|
bool SftpConnection::hasError() const
|
||||||
{
|
{
|
||||||
return d->conn.hasError();
|
return d->conn.hasError();
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ public:
|
|||||||
|
|
||||||
bool start();
|
bool start();
|
||||||
void quit();
|
void quit();
|
||||||
|
bool isConnected() const;
|
||||||
bool sendInput(const QByteArray &input); // Should normally end in newline.
|
bool sendInput(const QByteArray &input); // Should normally end in newline.
|
||||||
QByteArray waitForRemoteOutput(int msecs = -1);
|
QByteArray waitForRemoteOutput(int msecs = -1);
|
||||||
bool hasError() const;
|
bool hasError() const;
|
||||||
@@ -124,6 +125,7 @@ public:
|
|||||||
static Ptr create(const SshServerInfo &server);
|
static Ptr create(const SshServerInfo &server);
|
||||||
bool start();
|
bool start();
|
||||||
void quit();
|
void quit();
|
||||||
|
bool isConnected() const;
|
||||||
bool hasError() const;
|
bool hasError() const;
|
||||||
QString error() const;
|
QString error() const;
|
||||||
bool upload(const QString &localFilePath, const QByteArray &remoteFilePath);
|
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 appendMessage(this, tr("Initial cleanup canceled by user."), false);
|
||||||
emit finished();
|
emit finished();
|
||||||
} else if (m_initialCleaner->hasError()) {
|
} else if (m_initialCleaner->hasError()) {
|
||||||
handleError(tr("Error running initial cleanup: %1.")
|
handleError(tr("Error running initial cleanup: %1")
|
||||||
.arg(m_initialCleaner->error()));
|
.arg(m_initialCleaner->error()));
|
||||||
emit finished();
|
emit finished();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user