SSH: Use Qt5-style connects

The heavy lifting was done by clazy.

Change-Id: I04261849c92c54990f9f142fe541d984c5fb21d3
Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
This commit is contained in:
Orgad Shaneh
2016-06-07 22:04:26 +03:00
committed by Orgad Shaneh
parent 4cb94be1b5
commit 35036110ce
10 changed files with 50 additions and 47 deletions

View File

@@ -284,19 +284,20 @@ void SftpFileSystemModel::handleSshConnectionFailure()
void SftpFileSystemModel::handleSftpChannelInitialized()
{
connect(d->sftpChannel.data(),
SIGNAL(fileInfoAvailable(QSsh::SftpJobId,QList<QSsh::SftpFileInfo>)),
SLOT(handleFileInfo(QSsh::SftpJobId,QList<QSsh::SftpFileInfo>)));
connect(d->sftpChannel.data(), SIGNAL(finished(QSsh::SftpJobId,QString)),
SLOT(handleSftpJobFinished(QSsh::SftpJobId,QString)));
&SftpChannel::fileInfoAvailable,
this, &SftpFileSystemModel::handleFileInfo);
connect(d->sftpChannel.data(), &SftpChannel::finished,
this, &SftpFileSystemModel::handleSftpJobFinished);
statRootDirectory();
}
void SftpFileSystemModel::handleSshConnectionEstablished()
{
d->sftpChannel = d->sshConnection->createSftpChannel();
connect(d->sftpChannel.data(), SIGNAL(initialized()), SLOT(handleSftpChannelInitialized()));
connect(d->sftpChannel.data(), SIGNAL(channelError(QString)),
SLOT(handleSftpChannelError(QString)));
connect(d->sftpChannel.data(), &SftpChannel::initialized,
this, &SftpFileSystemModel::handleSftpChannelInitialized);
connect(d->sftpChannel.data(), &SftpChannel::channelError,
this, &SftpFileSystemModel::handleSftpChannelError);
d->sftpChannel->initialize();
}

View File

@@ -76,7 +76,7 @@ signals:
// Success <=> error.isEmpty().
void sftpOperationFinished(QSsh::SftpJobId, const QString &error);
private slots:
private:
void handleSshConnectionEstablished();
void handleSshConnectionFailure();
void handleSftpChannelInitialized();
@@ -84,7 +84,6 @@ private slots:
void handleFileInfo(QSsh::SftpJobId jobId, const QList<QSsh::SftpFileInfo> &fileInfoList);
void handleSftpJobFinished(QSsh::SftpJobId jobId, const QString &errorMessage);
private:
int columnCount(const QModelIndex &parent = QModelIndex()) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;

View File

@@ -281,7 +281,7 @@ SshTcpIpForwardServer::Ptr SshChannelManager::createForwardServer(const QString
void SshChannelManager::insertChannel(AbstractSshChannel *priv,
const QSharedPointer<QObject> &pub)
{
connect(priv, SIGNAL(timeout()), this, SIGNAL(timeout()));
connect(priv, &AbstractSshChannel::timeout, this, &SshChannelManager::timeout);
m_channels.insert(priv->localChannelId(), priv);
m_sessions.insert(priv, pub);
}

View File

@@ -100,14 +100,14 @@ SshConnection::SshConnection(const SshConnectionParameters &serverInfo, QObject
qRegisterMetaType<QList <QSsh::SftpFileInfo> >("QList<QSsh::SftpFileInfo>");
d = new Internal::SshConnectionPrivate(this, serverInfo);
connect(d, SIGNAL(connected()), this, SIGNAL(connected()),
connect(d, &Internal::SshConnectionPrivate::connected, this, &SshConnection::connected,
Qt::QueuedConnection);
connect(d, SIGNAL(dataAvailable(QString)), this,
SIGNAL(dataAvailable(QString)), Qt::QueuedConnection);
connect(d, SIGNAL(disconnected()), this, SIGNAL(disconnected()),
connect(d, &Internal::SshConnectionPrivate::dataAvailable, this,
&SshConnection::dataAvailable, Qt::QueuedConnection);
connect(d, &Internal::SshConnectionPrivate::disconnected, this, &SshConnection::disconnected,
Qt::QueuedConnection);
connect(d, SIGNAL(error(QSsh::SshError)), this,
SIGNAL(error(QSsh::SshError)), Qt::QueuedConnection);
connect(d, &Internal::SshConnectionPrivate::error, this,
&SshConnection::error, Qt::QueuedConnection);
}
void SshConnection::connectToHost()
@@ -135,7 +135,7 @@ SshConnection::State SshConnection::state() const
SshError SshConnection::errorState() const
{
return d->error();
return d->errorState();
}
QString SshConnection::errorString() const
@@ -227,7 +227,8 @@ SshConnectionPrivate::SshConnectionPrivate(SshConnection *conn,
m_timeoutTimer.setInterval(m_connParams.timeout * 1000);
m_keepAliveTimer.setSingleShot(true);
m_keepAliveTimer.setInterval(10000);
connect(m_channelManager, SIGNAL(timeout()), this, SLOT(handleTimeout()));
connect(m_channelManager, &SshChannelManager::timeout,
this, &SshConnectionPrivate::handleTimeout);
}
SshConnectionPrivate::~SshConnectionPrivate()
@@ -589,7 +590,7 @@ void SshConnectionPrivate::handleUserAuthSuccessPacket()
m_timeoutTimer.stop();
emit connected();
m_lastInvalidMsgSeqNr = InvalidSeqNr;
connect(&m_keepAliveTimer, SIGNAL(timeout()), SLOT(sendKeepAlivePacket()));
connect(&m_keepAliveTimer, &QTimer::timeout, this, &SshConnectionPrivate::sendKeepAlivePacket);
m_keepAliveTimer.start();
}
@@ -767,13 +768,16 @@ void SshConnectionPrivate::connectToHost()
return;
}
connect(m_socket, SIGNAL(connected()), this, SLOT(handleSocketConnected()));
connect(m_socket, SIGNAL(readyRead()), this, SLOT(handleIncomingData()));
connect(m_socket, SIGNAL(error(QAbstractSocket::SocketError)), this,
SLOT(handleSocketError()));
connect(m_socket, SIGNAL(disconnected()), this,
SLOT(handleSocketDisconnected()));
connect(&m_timeoutTimer, SIGNAL(timeout()), this, SLOT(handleTimeout()));
connect(m_socket, &QAbstractSocket::connected,
this, &SshConnectionPrivate::handleSocketConnected);
connect(m_socket, &QIODevice::readyRead,
this, &SshConnectionPrivate::handleIncomingData);
connect(m_socket,
static_cast<void (QAbstractSocket::*)(QAbstractSocket::SocketError)>(&QAbstractSocket::error),
this, &SshConnectionPrivate::handleSocketError);
connect(m_socket, &QAbstractSocket::disconnected,
this, &SshConnectionPrivate::handleSocketDisconnected);
connect(&m_timeoutTimer, &QTimer::timeout, this, &SshConnectionPrivate::handleTimeout);
m_state = SocketConnecting;
m_keyExchangeState = NoKeyExchange;
m_timeoutTimer.start();

View File

@@ -90,7 +90,7 @@ public:
quint16 remotePort);
SshStateInternal state() const { return m_state; }
SshError error() const { return m_error; }
SshError errorState() const { return m_error; }
QString errorString() const { return m_errorString; }
signals:
@@ -100,12 +100,12 @@ signals:
void error(QSsh::SshError);
private:
Q_SLOT void handleSocketConnected();
Q_SLOT void handleIncomingData();
Q_SLOT void handleSocketError();
Q_SLOT void handleSocketDisconnected();
Q_SLOT void handleTimeout();
Q_SLOT void sendKeepAlivePacket();
void handleSocketConnected();
void handleIncomingData();
void handleSocketError();
void handleSocketDisconnected();
void handleTimeout();
void sendKeepAlivePacket();
void handleServerId();
void handlePackets();

View File

@@ -194,7 +194,6 @@ private:
connection->moveToThread(qobject_cast<QThread *>(threadObj));
}
private slots:
void cleanup()
{
QMutexLocker locker(&m_listMutex);

View File

@@ -44,12 +44,10 @@ public:
QString privateKeyFilePath() const;
QString publicKeyFilePath() const;
private slots:
private:
void keyTypeChanged();
void generateKeys();
void handleBrowseButtonClicked();
private:
void setPrivateKeyFile(const QString &filePath);
void saveKeys();
bool userForbidsOverwriting();

View File

@@ -127,10 +127,14 @@ void SshRemoteProcessRunner::handleConnected()
setState(Connected);
d->m_process = d->m_connection->createRemoteProcess(d->m_command);
connect(d->m_process.data(), SIGNAL(started()), SLOT(handleProcessStarted()));
connect(d->m_process.data(), SIGNAL(closed(int)), SLOT(handleProcessFinished(int)));
connect(d->m_process.data(), SIGNAL(readyReadStandardOutput()), SLOT(handleStdout()));
connect(d->m_process.data(), SIGNAL(readyReadStandardError()), SLOT(handleStderr()));
connect(d->m_process.data(), &SshRemoteProcess::started,
this, &SshRemoteProcessRunner::handleProcessStarted);
connect(d->m_process.data(), &SshRemoteProcess::closed,
this, &SshRemoteProcessRunner::handleProcessFinished);
connect(d->m_process.data(), &SshRemoteProcess::readyReadStandardOutput,
this, &SshRemoteProcessRunner::handleStdout);
connect(d->m_process.data(), &SshRemoteProcess::readyReadStandardError,
this, &SshRemoteProcessRunner::handleStderr);
if (d->m_runInTerminal)
d->m_process->requestTerminal(d->m_terminal);
d->m_process->start();

View File

@@ -65,7 +65,7 @@ signals:
void readyReadStandardError();
void processClosed(int exitStatus); // values are of type SshRemoteProcess::ExitStatus
private slots:
private:
void handleConnected();
void handleConnectionError(QSsh::SshError error);
void handleDisconnected();
@@ -73,8 +73,6 @@ private slots:
void handleProcessFinished(int exitStatus);
void handleStdout();
void handleStderr();
private:
void runInternal(const QByteArray &command, const QSsh::SshConnectionParameters &sshParams);
void setState(int newState);

View File

@@ -64,9 +64,6 @@ signals:
void error(const QString &reason);
void closed();
private slots:
void handleEof();
protected:
void handleOpenFailureInternal(const QString &reason) override;
void handleChannelDataInternal(const QByteArray &data) override;
@@ -76,6 +73,9 @@ protected:
void closeHook() override;
QByteArray m_data;
private:
void handleEof();
};
} // namespace Internal