mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-15 09:15:34 +08:00
Ref T730, code style, adding namespaces
This commit is contained in:
committed by
Mat Sutcliffe
parent
329b1e8c9a
commit
99edc9cb13
@@ -14,7 +14,7 @@ namespace BlackCore
|
||||
{
|
||||
namespace Crypto
|
||||
{
|
||||
CryptoDtoChannel::CryptoDtoChannel(QString channelTag, const QByteArray &aeadReceiveKey, const QByteArray &aeadTransmitKey, int receiveSequenceHistorySize)
|
||||
CCryptoDtoChannel::CCryptoDtoChannel(QString channelTag, const QByteArray &aeadReceiveKey, const QByteArray &aeadTransmitKey, int receiveSequenceHistorySize)
|
||||
{
|
||||
ChannelTag = channelTag;
|
||||
m_aeadReceiveKey = aeadReceiveKey;
|
||||
@@ -27,7 +27,7 @@ namespace BlackCore
|
||||
receiveSequenceHistoryDepth = 0;
|
||||
}
|
||||
|
||||
CryptoDtoChannel::CryptoDtoChannel(CryptoDtoChannelConfigDto channelConfig, int receiveSequenceHistorySize)
|
||||
CCryptoDtoChannel::CCryptoDtoChannel(CryptoDtoChannelConfigDto channelConfig, int receiveSequenceHistorySize)
|
||||
{
|
||||
ChannelTag = channelConfig.channelTag;
|
||||
m_aeadReceiveKey = channelConfig.aeadReceiveKey;
|
||||
@@ -41,7 +41,7 @@ namespace BlackCore
|
||||
receiveSequenceHistoryDepth = 0;
|
||||
}
|
||||
|
||||
QByteArray CryptoDtoChannel::getTransmitKey(CryptoDtoMode mode)
|
||||
QByteArray CCryptoDtoChannel::getTransmitKey(CryptoDtoMode mode)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
@@ -54,7 +54,7 @@ namespace BlackCore
|
||||
return {};
|
||||
}
|
||||
|
||||
QByteArray CryptoDtoChannel::getTransmitKey(CryptoDtoMode mode, uint &sequenceToSend)
|
||||
QByteArray CCryptoDtoChannel::getTransmitKey(CryptoDtoMode mode, uint &sequenceToSend)
|
||||
{
|
||||
sequenceToSend = transmitSequence;
|
||||
transmitSequence++;
|
||||
@@ -71,12 +71,12 @@ namespace BlackCore
|
||||
return {};
|
||||
}
|
||||
|
||||
QString CryptoDtoChannel::getChannelTag() const
|
||||
QString CCryptoDtoChannel::getChannelTag() const
|
||||
{
|
||||
return ChannelTag;
|
||||
}
|
||||
|
||||
QByteArray CryptoDtoChannel::getReceiveKey(CryptoDtoMode mode)
|
||||
QByteArray CCryptoDtoChannel::getReceiveKey(CryptoDtoMode mode)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
@@ -89,7 +89,7 @@ namespace BlackCore
|
||||
return {};
|
||||
}
|
||||
|
||||
bool CryptoDtoChannel::checkReceivedSequence(uint sequenceReceived)
|
||||
bool CCryptoDtoChannel::checkReceivedSequence(uint sequenceReceived)
|
||||
{
|
||||
if (contains(sequenceReceived))
|
||||
{
|
||||
@@ -113,7 +113,7 @@ namespace BlackCore
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CryptoDtoChannel::contains(uint sequence)
|
||||
bool CCryptoDtoChannel::contains(uint sequence)
|
||||
{
|
||||
for (int i = 0; i < receiveSequenceHistoryDepth; i++)
|
||||
{
|
||||
@@ -123,7 +123,7 @@ namespace BlackCore
|
||||
return false;
|
||||
}
|
||||
|
||||
uint CryptoDtoChannel::getMin(int &minIndex)
|
||||
uint CCryptoDtoChannel::getMin(int &minIndex)
|
||||
{
|
||||
uint minValue = std::numeric_limits<uint>::max();
|
||||
minIndex = -1;
|
||||
|
||||
@@ -26,14 +26,14 @@ namespace BlackCore
|
||||
namespace Crypto
|
||||
{
|
||||
//! Crypto channel
|
||||
class CryptoDtoChannel
|
||||
class CCryptoDtoChannel
|
||||
{
|
||||
public:
|
||||
//! Ctor
|
||||
CryptoDtoChannel(QString channelTag, const QByteArray &aeadReceiveKey, const QByteArray &aeadTransmitKey, int receiveSequenceHistorySize = 10);
|
||||
CCryptoDtoChannel(QString channelTag, const QByteArray &aeadReceiveKey, const QByteArray &aeadTransmitKey, int receiveSequenceHistorySize = 10);
|
||||
|
||||
//! Ctor
|
||||
CryptoDtoChannel(CryptoDtoChannelConfigDto channelConfig, int receiveSequenceHistorySize = 10);
|
||||
CCryptoDtoChannel(CryptoDtoChannelConfigDto channelConfig, int receiveSequenceHistorySize = 10);
|
||||
|
||||
QByteArray getTransmitKey(CryptoDtoMode mode);
|
||||
QByteArray getTransmitKey(CryptoDtoMode mode, uint &sequenceToSend);
|
||||
|
||||
@@ -17,12 +17,12 @@ namespace BlackCore
|
||||
{
|
||||
CryptoDtoSerializer::CryptoDtoSerializer() { }
|
||||
|
||||
CryptoDtoSerializer::Deserializer CryptoDtoSerializer::deserialize(CryptoDtoChannel &channel, const QByteArray &bytes, bool loopback)
|
||||
CryptoDtoSerializer::Deserializer CryptoDtoSerializer::deserialize(CCryptoDtoChannel &channel, const QByteArray &bytes, bool loopback)
|
||||
{
|
||||
return Deserializer(channel, bytes, loopback);
|
||||
}
|
||||
|
||||
CryptoDtoSerializer::Deserializer::Deserializer(CryptoDtoChannel &channel, const QByteArray &bytes, bool loopback)
|
||||
CryptoDtoSerializer::Deserializer::Deserializer(CCryptoDtoChannel &channel, const QByteArray &bytes, bool loopback)
|
||||
{
|
||||
QByteArray data(bytes);
|
||||
QBuffer buffer(&data);
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace BlackCore
|
||||
public:
|
||||
CryptoDtoSerializer();
|
||||
|
||||
//! Serialize a DTO
|
||||
template<typename T>
|
||||
static QByteArray Serialize(const QString &channelTag, CryptoDtoMode mode, const QByteArray &transmitKey, uint sequenceToBeSent, T dto)
|
||||
{
|
||||
@@ -105,8 +106,9 @@ namespace BlackCore
|
||||
return {};
|
||||
}
|
||||
|
||||
//! Serialize a DTO
|
||||
template<typename T>
|
||||
static QByteArray Serialize(CryptoDtoChannel &channel, CryptoDtoMode mode, T dto)
|
||||
static QByteArray Serialize(CCryptoDtoChannel &channel, CryptoDtoMode mode, T dto)
|
||||
{
|
||||
uint sequenceToSend = 0;
|
||||
QByteArray transmitKey = channel.getTransmitKey(mode, sequenceToSend);
|
||||
@@ -115,7 +117,7 @@ namespace BlackCore
|
||||
|
||||
struct Deserializer
|
||||
{
|
||||
Deserializer(CryptoDtoChannel &channel, const QByteArray &bytes, bool loopback);
|
||||
Deserializer(CCryptoDtoChannel &channel, const QByteArray &bytes, bool loopback);
|
||||
|
||||
template<typename T>
|
||||
T getDto()
|
||||
@@ -143,7 +145,7 @@ namespace BlackCore
|
||||
bool verified = false;
|
||||
};
|
||||
|
||||
static Deserializer deserialize(CryptoDtoChannel &channel, const QByteArray &bytes, bool loopback);
|
||||
static Deserializer deserialize(CCryptoDtoChannel &channel, const QByteArray &bytes, bool loopback);
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
Reference in New Issue
Block a user