From 815098a41d337e30cf4904cd4999ed98f8cf58a7 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Sun, 18 Jan 2015 21:23:47 +0000 Subject: [PATCH] added new PROTMESSID_LICENCE_REQUIRED message --- src/protocol.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++ src/protocol.h | 4 ++++ 2 files changed, 51 insertions(+) diff --git a/src/protocol.cpp b/src/protocol.cpp index 3a106319..8a48f8de 100755 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -166,6 +166,13 @@ MESSAGES (with connection) note: does not have any data -> n = 0 +- PROTMESSID_LICENCE_REQUIRED: Licence required to connect to the server + + +---------------------+ + | 1 byte licence type | + +---------------------+ + + // #### COMPATIBILITY OLD VERSION, TO BE REMOVED #### - PROTMESSID_OPUS_SUPPORTED: Informs that OPUS codec is supported @@ -553,6 +560,10 @@ case PROTMESSID_CHANNEL_NAME: bRet = EvaluateReqNetwTranspPropsMes(); break; + case PROTMESSID_LICENCE_REQUIRED: + bRet = EvaluateLicenceRequiredMes ( vecbyMesBodyData ); + break; + // #### COMPATIBILITY OLD VERSION, TO BE REMOVED #### #ifdef USE_LEGACY_CELT case PROTMESSID_OPUS_SUPPORTED: @@ -1323,6 +1334,42 @@ bool CProtocol::EvaluateReqNetwTranspPropsMes() return false; // no error } +void CProtocol::CreateLicenceRequiredMes ( const ELicenceType eLicenceType ) +{ + CVector vecData ( 1 ); // 1 bytes of data + int iPos = 0; // init position pointer + + // build data vector + PutValOnStream ( vecData, iPos, static_cast ( eLicenceType ), 1 ); + + CreateAndSendMessage ( PROTMESSID_LICENCE_REQUIRED, vecData ); +} + +bool CProtocol::EvaluateLicenceRequiredMes ( const CVector& vecData ) +{ + int iPos = 0; // init position pointer + + // check size + if ( vecData.Size() != 1 ) + { + return true; // return error code + } + + // extract licence type + const ELicenceType eLicenceType = + static_cast ( GetValFromStream ( vecData, iPos, 1 ) ); + + if ( eLicenceType != LT_CREATIVECOMMONS ) + { + return true; // return error code + } + + // invoke message action + emit LicenceRequired ( eLicenceType ); + + return false; // no error +} + void CProtocol::CreateOpusSupportedMes() { CreateAndSendMessage ( PROTMESSID_OPUS_SUPPORTED, diff --git a/src/protocol.h b/src/protocol.h index 82f759c9..9ded6447 100755 --- a/src/protocol.h +++ b/src/protocol.h @@ -54,6 +54,7 @@ #define PROTMESSID_CONN_CLIENTS_LIST 24 // channel infos for connected clients #define PROTMESSID_CHANNEL_INFOS 25 // set channel infos #define PROTMESSID_OPUS_SUPPORTED 26 // tells that OPUS codec is supported +#define PROTMESSID_LICENCE_REQUIRED 27 // licence required // message IDs of connection less messages (CLM) // DEFINITION -> start at 1000, end at 1999, see IsConnectionLessMessageID @@ -100,6 +101,7 @@ public: void CreateChatTextMes ( const QString strChatText ); void CreateNetwTranspPropsMes ( const CNetworkTransportProps& NetTrProps ); void CreateReqNetwTranspPropsMes(); + void CreateLicenceRequiredMes ( const ELicenceType eLicenceType ); void CreateOpusSupportedMes(); void CreateCLPingMes ( const CHostAddress& InetAddr, const int iMs ); @@ -213,6 +215,7 @@ protected: bool EvaluateChatTextMes ( const CVector& vecData ); bool EvaluateNetwTranspPropsMes ( const CVector& vecData ); bool EvaluateReqNetwTranspPropsMes(); + bool EvaluateLicenceRequiredMes ( const CVector& vecData ); #ifdef USE_LEGACY_CELT bool EvaluateOpusSupportedMes(); #endif @@ -269,6 +272,7 @@ signals: void ChatTextReceived ( QString strChatText ); void NetTranspPropsReceived ( CNetworkTransportProps NetworkTransportProps ); void ReqNetTranspProps(); + void LicenceRequired ( ELicenceType eLicenceType ); void CLPingReceived ( CHostAddress InetAddr, int iMs );