Formats minimally release source files based on former clang-format
This commit is contained in:
387 files changed
+37323
-38074
No files matched your search
@@ -22,64 +22,63 @@
|
||||
namespace PrtCnv
|
||||
{
|
||||
|
||||
PrtCnvInjectionSocket::PrtCnvInjectionSocket()
|
||||
: m_Socket(nullptr)
|
||||
, m_Server(nullptr)
|
||||
, m_logger(getLogger("PrtCnvInjectionSocket"))
|
||||
{}
|
||||
|
||||
PrtCnvInjectionSocket::~PrtCnvInjectionSocket()
|
||||
{
|
||||
delete m_Socket;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Disconnects a TCP-client
|
||||
// ---------------------------------------------------------------
|
||||
void PrtCnvInjectionSocket::disconnectClient()
|
||||
{
|
||||
INFO_LOG(m_logger) << "A client has disconnected from the injection-server";
|
||||
emit disconnected(this);
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Reads in TCP-data and handles them
|
||||
// ---------------------------------------------------------------
|
||||
void PrtCnvInjectionSocket::processInputData()
|
||||
{
|
||||
INFO_LOG(m_logger) << "Injection-server has data received";
|
||||
N_CoPrtCnv::CoPrtCnvInjectionHeader injectionHeader;
|
||||
qint64 bytesRead = m_Socket->peek((char*)&injectionHeader, sizeof(injectionHeader));
|
||||
if (sizeof(injectionHeader) == bytesRead)
|
||||
PrtCnvInjectionSocket::PrtCnvInjectionSocket()
|
||||
: m_Socket(nullptr)
|
||||
, m_Server(nullptr)
|
||||
, m_logger(getLogger("PrtCnvInjectionSocket"))
|
||||
{
|
||||
if (injectionHeader.isIdCorrect())
|
||||
}
|
||||
|
||||
PrtCnvInjectionSocket::~PrtCnvInjectionSocket()
|
||||
{
|
||||
delete m_Socket;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Disconnects a TCP-client
|
||||
// ---------------------------------------------------------------
|
||||
void PrtCnvInjectionSocket::disconnectClient()
|
||||
{
|
||||
INFO_LOG(m_logger) << "A client has disconnected from the injection-server";
|
||||
emit disconnected(this);
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Reads in TCP-data and handles them
|
||||
// ---------------------------------------------------------------
|
||||
void PrtCnvInjectionSocket::processInputData()
|
||||
{
|
||||
INFO_LOG(m_logger) << "Injection-server has data received";
|
||||
N_CoPrtCnv::CoPrtCnvInjectionHeader injectionHeader;
|
||||
qint64 bytesRead = m_Socket->peek((char *)&injectionHeader, sizeof(injectionHeader));
|
||||
if (sizeof(injectionHeader) == bytesRead)
|
||||
{
|
||||
// check whether all bytes are available
|
||||
qint64 available = m_Socket->bytesAvailable();
|
||||
if (available < qint64(injectionHeader.m_Size + sizeof(injectionHeader)))
|
||||
{
|
||||
INFO_LOG(m_logger) << "not enough bytes available - waiting for more data: "
|
||||
<< "headersize=" << sizeof(injectionHeader) << " id1="
|
||||
<< injectionHeader.m_Id1 << " id2=" << injectionHeader.m_Id2
|
||||
<< " kind=" << (int)injectionHeader.m_Kind << " size="
|
||||
<< injectionHeader.m_Size;
|
||||
return; // try it later, when (maybe) enough bytes are available...
|
||||
}
|
||||
// enough bytes => read now all in
|
||||
m_Socket->read((char*)&injectionHeader, sizeof(injectionHeader));
|
||||
if (injectionHeader.isIdCorrect())
|
||||
{
|
||||
//INFO_LOG(m_logger) << "kind=" << (int)injectionHeader.m_Kind << " size=" << injectionHeader.m_Size;
|
||||
|
||||
// read the data
|
||||
QByteArray data(injectionHeader.m_Size, Qt::Uninitialized);
|
||||
m_Socket->read(data.data(), injectionHeader.m_Size);
|
||||
|
||||
switch (injectionHeader.m_Kind)
|
||||
// check whether all bytes are available
|
||||
qint64 available = m_Socket->bytesAvailable();
|
||||
if (available < qint64(injectionHeader.m_Size + sizeof(injectionHeader)))
|
||||
{
|
||||
case N_CoPrtCnv::CoPrtCnvInjectionHeader::eCentral:
|
||||
case N_CoPrtCnv::CoPrtCnvInjectionHeader::eRadio:
|
||||
INFO_LOG(m_logger) << "not enough bytes available - waiting for more data: "
|
||||
<< "headersize=" << sizeof(injectionHeader) << " id1=" << injectionHeader.m_Id1 << " id2=" << injectionHeader.m_Id2
|
||||
<< " kind=" << (int)injectionHeader.m_Kind << " size=" << injectionHeader.m_Size;
|
||||
return; // try it later, when (maybe) enough bytes are available...
|
||||
}
|
||||
// enough bytes => read now all in
|
||||
m_Socket->read((char *)&injectionHeader, sizeof(injectionHeader));
|
||||
if (injectionHeader.isIdCorrect())
|
||||
{
|
||||
//INFO_LOG(m_logger) << "kind=" << (int)injectionHeader.m_Kind << " size=" << injectionHeader.m_Size;
|
||||
|
||||
// read the data
|
||||
QByteArray data(injectionHeader.m_Size, Qt::Uninitialized);
|
||||
m_Socket->read(data.data(), injectionHeader.m_Size);
|
||||
|
||||
switch (injectionHeader.m_Kind)
|
||||
{
|
||||
case N_CoPrtCnv::CoPrtCnvInjectionHeader::eCentral:
|
||||
case N_CoPrtCnv::CoPrtCnvInjectionHeader::eRadio:
|
||||
{
|
||||
N_CoPrtCnv::CoPrtCnvCentralTelegram *tele = new N_CoPrtCnv::CoPrtCnvCentralTelegram(data);
|
||||
|
||||
@@ -97,31 +96,31 @@ void PrtCnvInjectionSocket::processInputData()
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
ERROR_LOG(m_logger) << "Unknown kind (" << injectionHeader.m_Kind << ") of injection-telegram";
|
||||
break;
|
||||
default:
|
||||
ERROR_LOG(m_logger) << "Unknown kind (" << injectionHeader.m_Kind << ") of injection-telegram";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Corrupt injection-telegram received => reconnect";
|
||||
m_Socket->disconnectFromHost();
|
||||
else
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Corrupt injection-telegram received => reconnect";
|
||||
m_Socket->disconnectFromHost();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
void PrtCnvInjectionSocket::setSocket(QTcpSocket* a_socket, PrtCnvInjectionThread* a_server)
|
||||
{
|
||||
m_Socket = a_socket;
|
||||
m_Server = a_server;
|
||||
connect(this, &PrtCnvInjectionSocket::disconnected, m_Server, &PrtCnvInjectionThread::disconnectClient, Qt::QueuedConnection);
|
||||
if (m_Socket)
|
||||
// ---------------------------------------------------------------
|
||||
void PrtCnvInjectionSocket::setSocket(QTcpSocket *a_socket, PrtCnvInjectionThread *a_server)
|
||||
{
|
||||
connect(m_Socket, &QTcpSocket::readyRead, this, &PrtCnvInjectionSocket::processInputData, Qt::QueuedConnection);
|
||||
connect(m_Socket, &QTcpSocket::disconnected, this, &PrtCnvInjectionSocket::disconnectClient, Qt::QueuedConnection);
|
||||
m_Socket = a_socket;
|
||||
m_Server = a_server;
|
||||
connect(this, &PrtCnvInjectionSocket::disconnected, m_Server, &PrtCnvInjectionThread::disconnectClient, Qt::QueuedConnection);
|
||||
if (m_Socket)
|
||||
{
|
||||
connect(m_Socket, &QTcpSocket::readyRead, this, &PrtCnvInjectionSocket::processInputData, Qt::QueuedConnection);
|
||||
connect(m_Socket, &QTcpSocket::disconnected, this, &PrtCnvInjectionSocket::disconnectClient, Qt::QueuedConnection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace PrtCnv
|
||||
Reference in new issue
Block a user