mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-20 12:35:43 +08:00
Ref T730, code style, adding namespaces
This commit is contained in:
committed by
Mat Sutcliffe
parent
329b1e8c9a
commit
99edc9cb13
@@ -17,7 +17,7 @@ namespace BlackCore
|
||||
{
|
||||
namespace Connection
|
||||
{
|
||||
ClientConnection::ClientConnection(const QString &apiServer, QObject *parent) :
|
||||
CClientConnection::CClientConnection(const QString &apiServer, QObject *parent) :
|
||||
QObject(parent),
|
||||
m_apiServerConnection(apiServer, this)
|
||||
{
|
||||
@@ -27,13 +27,13 @@ namespace BlackCore
|
||||
// connect(&m_apiServerConnection, &ApiServerConnection::addCallsignFinished, this, &ClientConnection::addCallsignFinished);
|
||||
// connect(&m_apiServerConnection, &ApiServerConnection::removeCallsignFinished, this, &ClientConnection::removeCallsignFinished);
|
||||
|
||||
connect(&m_voiceServerTimer, &QTimer::timeout, this, &ClientConnection::voiceServerHeartbeat);
|
||||
connect(&m_voiceServerTimer, &QTimer::timeout, this, &CClientConnection::voiceServerHeartbeat);
|
||||
|
||||
connect(&m_udpSocket, &QUdpSocket::readyRead, this, &ClientConnection::readPendingDatagrams);
|
||||
connect(&m_udpSocket, qOverload<QAbstractSocket::SocketError>(&QUdpSocket::error), this, &ClientConnection::handleSocketError);
|
||||
connect(&m_udpSocket, &QUdpSocket::readyRead, this, &CClientConnection::readPendingDatagrams);
|
||||
connect(&m_udpSocket, qOverload<QAbstractSocket::SocketError>(&QUdpSocket::error), this, &CClientConnection::handleSocketError);
|
||||
}
|
||||
|
||||
void ClientConnection::connectTo(const QString &userName, const QString &password, const QString &callsign)
|
||||
void CClientConnection::connectTo(const QString &userName, const QString &password, const QString &callsign)
|
||||
{
|
||||
if (m_connection.m_connected)
|
||||
{
|
||||
@@ -57,7 +57,7 @@ namespace BlackCore
|
||||
qDebug() << "Connected:" << callsign;
|
||||
}
|
||||
|
||||
void ClientConnection::disconnectFrom(const QString &reason)
|
||||
void CClientConnection::disconnectFrom(const QString &reason)
|
||||
{
|
||||
if (! m_connection.m_connected)
|
||||
{
|
||||
@@ -82,27 +82,27 @@ namespace BlackCore
|
||||
qDebug() << "Disconnection complete";
|
||||
}
|
||||
|
||||
bool ClientConnection::receiveAudioDto() const
|
||||
bool CClientConnection::receiveAudioDto() const
|
||||
{
|
||||
return m_receiveAudioDto;
|
||||
}
|
||||
|
||||
void ClientConnection::setReceiveAudioDto(bool receiveAudioDto)
|
||||
void CClientConnection::setReceiveAudioDto(bool receiveAudioDto)
|
||||
{
|
||||
m_receiveAudioDto = receiveAudioDto;
|
||||
}
|
||||
|
||||
void ClientConnection::updateTransceivers(const QString &callsign, const QVector<TransceiverDto> &transceivers)
|
||||
void CClientConnection::updateTransceivers(const QString &callsign, const QVector<TransceiverDto> &transceivers)
|
||||
{
|
||||
m_apiServerConnection.updateTransceivers(callsign, transceivers);
|
||||
}
|
||||
|
||||
QVector<StationDto> ClientConnection::getAllAliasedStations()
|
||||
QVector<StationDto> CClientConnection::getAllAliasedStations()
|
||||
{
|
||||
return m_apiServerConnection.getAllAliasedStations();
|
||||
}
|
||||
|
||||
void ClientConnection::connectToVoiceServer()
|
||||
void CClientConnection::connectToVoiceServer()
|
||||
{
|
||||
QHostAddress localAddress(QHostAddress::AnyIPv4);
|
||||
m_udpSocket.bind(localAddress);
|
||||
@@ -111,14 +111,14 @@ namespace BlackCore
|
||||
qDebug() << "Connected to voice server (" + m_connection.m_tokens.VoiceServer.addressIpV4 << ")";
|
||||
}
|
||||
|
||||
void ClientConnection::disconnectFromVoiceServer()
|
||||
void CClientConnection::disconnectFromVoiceServer()
|
||||
{
|
||||
m_voiceServerTimer.stop();
|
||||
m_udpSocket.disconnectFromHost();
|
||||
qDebug() << "All TaskVoiceServer tasks stopped";
|
||||
}
|
||||
|
||||
void ClientConnection::readPendingDatagrams()
|
||||
void CClientConnection::readPendingDatagrams()
|
||||
{
|
||||
while (m_udpSocket.hasPendingDatagrams())
|
||||
{
|
||||
@@ -127,7 +127,7 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
void ClientConnection::processMessage(const QByteArray &messageDdata, bool loopback)
|
||||
void CClientConnection::processMessage(const QByteArray &messageDdata, bool loopback)
|
||||
{
|
||||
CryptoDtoSerializer::Deserializer deserializer = CryptoDtoSerializer::deserialize(*m_connection.voiceCryptoChannel, messageDdata, loopback);
|
||||
|
||||
@@ -151,13 +151,13 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
void ClientConnection::handleSocketError(QAbstractSocket::SocketError error)
|
||||
void CClientConnection::handleSocketError(QAbstractSocket::SocketError error)
|
||||
{
|
||||
Q_UNUSED(error);
|
||||
qDebug() << "UDP socket error" << m_udpSocket.errorString();
|
||||
}
|
||||
|
||||
void ClientConnection::voiceServerHeartbeat()
|
||||
void CClientConnection::voiceServerHeartbeat()
|
||||
{
|
||||
QUrl voiceServerUrl("udp://" + m_connection.m_tokens.VoiceServer.addressIpV4);
|
||||
qDebug() << "Sending voice server heartbeat to" << voiceServerUrl.host();
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace BlackCore
|
||||
namespace Connection
|
||||
{
|
||||
//! Client connection
|
||||
class ClientConnection : public QObject
|
||||
class CClientConnection : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace BlackCore
|
||||
};
|
||||
Q_ENUM(ConnectionStatus)
|
||||
|
||||
ClientConnection(const QString &apiServer, QObject *parent = nullptr);
|
||||
CClientConnection(const QString &apiServer, QObject *parent = nullptr);
|
||||
|
||||
void connectTo(const QString &userName, const QString &password, const QString &callsign);
|
||||
void disconnectFrom(const QString &reason = {});
|
||||
@@ -82,7 +82,7 @@ namespace BlackCore
|
||||
const QUuid m_networkVersion = QUuid("3a5ddc6d-cf5d-4319-bd0e-d184f772db80");
|
||||
|
||||
//Data
|
||||
ClientConnectionData m_connection;
|
||||
CClientConnectionData m_connection;
|
||||
|
||||
// Voice server
|
||||
QUdpSocket m_udpSocket;
|
||||
|
||||
@@ -17,27 +17,27 @@ namespace BlackCore
|
||||
{
|
||||
namespace Connection
|
||||
{
|
||||
qint64 ClientConnectionData::secondsSinceAuthentication() const
|
||||
qint64 CClientConnectionData::secondsSinceAuthentication() const
|
||||
{
|
||||
return m_authenticatedDateTimeUtc.secsTo(QDateTime::currentDateTimeUtc());
|
||||
}
|
||||
|
||||
bool ClientConnectionData::isVoiceServerAlive() const
|
||||
bool CClientConnectionData::isVoiceServerAlive() const
|
||||
{
|
||||
return m_lastVoiceServerHeartbeatAckUtc.secsTo(QDateTime::currentDateTimeUtc()) > serverTimeout;
|
||||
}
|
||||
|
||||
void ClientConnectionData::createCryptoChannels()
|
||||
void CClientConnectionData::createCryptoChannels()
|
||||
{
|
||||
if (! m_tokens.isValid)
|
||||
{
|
||||
qWarning() << "Tokens not set";
|
||||
}
|
||||
voiceCryptoChannel.reset(new CryptoDtoChannel(m_tokens.VoiceServer.channelConfig));
|
||||
voiceCryptoChannel.reset(new CCryptoDtoChannel(m_tokens.VoiceServer.channelConfig));
|
||||
// dataCryptoChannel.reset(new CryptoDtoChannel(m_tokens.DataServer.channelConfig));
|
||||
}
|
||||
|
||||
bool ClientConnectionData::voiceServerAlive() const
|
||||
bool CClientConnectionData::voiceServerAlive() const
|
||||
{
|
||||
return timeSinceAuthentication() < serverTimeout ||
|
||||
m_lastVoiceServerHeartbeatAckUtc.secsTo(QDateTime::currentDateTimeUtc()) < serverTimeout;
|
||||
|
||||
@@ -27,9 +27,9 @@ namespace BlackCore
|
||||
namespace Connection
|
||||
{
|
||||
//! Client connection data
|
||||
struct ClientConnectionData
|
||||
struct CClientConnectionData
|
||||
{
|
||||
ClientConnectionData() = default;
|
||||
CClientConnectionData() = default;
|
||||
|
||||
qint64 secondsSinceAuthentication() const;
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace BlackCore
|
||||
|
||||
PostCallsignResponseDto m_tokens;
|
||||
|
||||
QScopedPointer<Crypto::CryptoDtoChannel> voiceCryptoChannel;
|
||||
QScopedPointer<Crypto::CCryptoDtoChannel> voiceCryptoChannel;
|
||||
|
||||
QDateTime m_authenticatedDateTimeUtc;
|
||||
QDateTime m_lastVoiceServerHeartbeatAckUtc;
|
||||
|
||||
Reference in New Issue
Block a user