support for querying the server version and OS type for debugging purpose (not in the regular version available)

This commit is contained in:
Volker Fischer 2014-02-21 21:25:26 +00:00
parent d080c568a3
commit 388664e48e
13 changed files with 274 additions and 34 deletions

View file

@ -199,6 +199,9 @@ QObject::connect ( &Channel, SIGNAL ( OpusSupported() ),
SIGNAL ( CLPingWithNumClientsReceived ( CHostAddress, int, int ) ),
this, SLOT ( OnCLPingWithNumClientsReceived ( CHostAddress, int, int ) ) );
QObject::connect ( &ConnLessProtocol,
SIGNAL ( CLVersionAndOSReceived ( CHostAddress, COSUtil::EOpSystemType, QString ) ),
SIGNAL ( CLVersionAndOSReceived ( CHostAddress, COSUtil::EOpSystemType, QString ) ) );
// other
QObject::connect ( &Sound, SIGNAL ( ReinitRequest ( int ) ),

View file

@ -260,6 +260,11 @@ public:
0 /* dummy */ );
}
void CreateCLServerListReqVerAndOSMes ( const CHostAddress& InetAddr )
{
ConnLessProtocol.CreateCLReqVersionAndOSMes ( InetAddr );
}
void CreateCLReqServerListMes ( const CHostAddress& InetAddr )
{ ConnLessProtocol.CreateCLReqServerListMes ( InetAddr ); }
@ -410,6 +415,11 @@ signals:
void CLPingTimeWithNumClientsReceived ( CHostAddress InetAddr,
int iPingTime,
int iNumClients );
void CLVersionAndOSReceived ( CHostAddress InetAddr,
COSUtil::EOpSystemType eOSType,
QString strVersion );
void Disconnected();
// #### COMPATIBILITY OLD VERSION, TO BE REMOVED ####

View file

@ -495,6 +495,10 @@ CClientDlg::CClientDlg ( CClient* pNCliP,
SIGNAL ( CLPingTimeWithNumClientsReceived ( CHostAddress, int, int ) ),
this, SLOT ( OnCLPingTimeWithNumClientsReceived ( CHostAddress, int, int ) ) );
QObject::connect ( pClient,
SIGNAL ( CLVersionAndOSReceived ( CHostAddress, COSUtil::EOpSystemType, QString ) ),
this, SLOT ( OnCLVersionAndOSReceived ( CHostAddress, COSUtil::EOpSystemType, QString ) ) );
QObject::connect ( pClient,
SIGNAL ( UpstreamRateChanged() ),
this, SLOT ( OnUpstreamRateChanged() ) );
@ -523,6 +527,9 @@ CClientDlg::CClientDlg ( CClient* pNCliP,
QObject::connect ( &ConnectDlg, SIGNAL ( CreateCLServerListPingMes ( CHostAddress ) ),
this, SLOT ( OnCreateCLServerListPingMes ( CHostAddress ) ) );
QObject::connect ( &ConnectDlg, SIGNAL ( CreateCLServerListReqVerAndOSMes ( CHostAddress ) ),
this, SLOT ( OnCreateCLServerListReqVerAndOSMes ( CHostAddress ) ) );
QObject::connect ( &ConnectDlg, SIGNAL ( accepted() ),
this, SLOT ( OnConnectDlgAccepted() ) );

View file

@ -129,6 +129,11 @@ public slots:
int iPingTime,
int iNumClients );
void OnCLVersionAndOSReceived ( CHostAddress InetAddr,
COSUtil::EOpSystemType eOSType,
QString strVersion )
{ ConnectDlg.SetVersionAndOSType ( InetAddr, eOSType, strVersion ); }
void OnOpenConnectionSetupDialog() { ShowConnectionSetupDialog(); }
void OnOpenGeneralSettings() { ShowGeneralSettings(); }
void OnOpenChatDialog() { ShowChatWindow(); }
@ -166,6 +171,9 @@ public slots:
void OnCreateCLServerListPingMes ( CHostAddress InetAddr )
{ pClient->CreateCLServerListPingMes ( InetAddr ); }
void OnCreateCLServerListReqVerAndOSMes ( CHostAddress InetAddr )
{ pClient->CreateCLServerListReqVerAndOSMes ( InetAddr ); }
void OnCLServerListReceived ( CHostAddress InetAddr,
CVector<CServerInfo> vecServerInfo )
{ ConnectDlg.SetServerList ( InetAddr, vecServerInfo ); }

View file

@ -385,10 +385,20 @@ void CConnectDlg::OnTimerPing()
CurServerAddress ) )
{
// if address is valid, send ping
// TEST send request for version and OS instead of ping message
const bool bEnableVerOSDebugging = false; // if this is set the "false", we have to regular version
if ( bEnableVerOSDebugging )
{
emit CreateCLServerListReqVerAndOSMes ( CurServerAddress );
}
else
{
emit CreateCLServerListPingMes ( CurServerAddress );
}
}
}
}
void CConnectDlg::SetPingTimeAndNumClientsResult ( CHostAddress& InetAddr,
const int iPingTime,
@ -468,3 +478,33 @@ void CConnectDlg::SetPingTimeAndNumClientsResult ( CHostAddress&
}
}
}
void CConnectDlg::SetVersionAndOSType ( CHostAddress InetAddr,
COSUtil::EOpSystemType eOSType,
QString strVersion )
{
// apply the received version and OS type to the correct server list entry
const int iServerListLen = lvwServers->topLevelItemCount();
for ( int iIdx = 0; iIdx < iServerListLen; iIdx++ )
{
// compare the received address with the user data string of the
// host address by a string compare
if ( !lvwServers->topLevelItem ( iIdx )->
data ( 0, Qt::UserRole ).toString().
compare ( InetAddr.toString() ) )
{
// TEST since this is just a debug info, we just reuse the ping column (note
// the we have to replace the ping message emit with the version and OS request
// so that this works, see above code)
lvwServers->topLevelItem ( iIdx )->
setText ( 1, strVersion + "/" + COSUtil::GetOperatingSystemString ( eOSType ) );
// a version and OS type was received, set item to visible
if ( lvwServers->topLevelItem ( iIdx )->isHidden() )
{
lvwServers->topLevelItem ( iIdx )->setHidden ( false );
}
}
}
}

View file

@ -62,6 +62,10 @@ public:
const CMultiColorLED::ELightColor ePingTimeLEDColor,
const int iNumClients );
void SetVersionAndOSType ( CHostAddress InetAddr,
COSUtil::EOpSystemType eOSType,
QString strVersion );
bool GetServerListItemWasChosen() const { return bServerListItemWasChosen; }
QString GetSelectedAddress() const { return strSelectedAddress; }
QString GetSelectedServerName() const { return strSelectedServerName; }
@ -92,4 +96,5 @@ public slots:
signals:
void ReqServerListQuery ( CHostAddress InetAddr );
void CreateCLServerListPingMes ( CHostAddress InetAddr );
void CreateCLServerListReqVerAndOSMes ( CHostAddress InetAddr );
};

View file

@ -213,6 +213,7 @@ LED bar: lbr
#define MAX_LEN_SERVER_NAME 20
#define MAX_LEN_SERVER_TOPIC 32
#define MAX_LEN_SERVER_CITY 20
#define MAX_LEN_VERSION_TEXT 20
// common tool tip bottom line text
#define TOOLTIP_COM_END_TEXT tr ( \

View file

@ -263,6 +263,17 @@ CONNECTION LESS MESSAGES
note: does not have any data -> n = 0
- PROTMESSID_CLM_VERSION_AND_OS: Version number and operating system
+-------------------------+------------------+------------------------------+
| 1 byte operating system | 2 bytes number n | n bytes UTF-8 string version |
+-------------------------+------------------+------------------------------+
- PROTMESSID_CLM_REQ_VERSION_AND_OS: Request version number and operating system
note: does not have any data -> n = 0
******************************************************************************
*
* This program is free software; you can redistribute it and/or modify it under
@ -615,6 +626,14 @@ if ( rand() < ( RAND_MAX / 2 ) ) return false;
case PROTMESSID_CLM_DISCONNECTION:
bRet = EvaluateCLDisconnectionMes ( InetAddr );
break;
case PROTMESSID_CLM_VERSION_AND_OS:
bRet = EvaluateCLVersionAndOSMes ( InetAddr, vecbyMesBodyData );
break;
case PROTMESSID_CLM_REQ_VERSION_AND_OS:
bRet = EvaluateCLReqVersionAndOSMes ( InetAddr );
break;
}
}
else
@ -1784,6 +1803,89 @@ bool CProtocol::EvaluateCLDisconnectionMes ( const CHostAddress& InetAddr )
return false; // no error
}
void CProtocol::CreateCLVersionAndOSMes ( const CHostAddress& InetAddr )
{
int iPos = 0; // init position pointer
// get the version number string
const QString strVerion = VERSION;
// convert version string to utf-8
const QByteArray strUTF8Version = strVerion.toUtf8();
// size of current message body
const int iEntrLen =
1 /* operating system */ +
2 /* version utf-8 string size */ + strUTF8Version.size();
// build data vector
CVector<uint8_t> vecData ( iEntrLen );
// operating system (1 byte)
PutValOnStream ( vecData, iPos,
static_cast<uint32_t> ( COSUtil::GetOperatingSystem() ), 1 );
// version
PutStringUTF8OnStream ( vecData, iPos, strUTF8Version );
CreateAndImmSendConLessMessage ( PROTMESSID_CLM_VERSION_AND_OS,
vecData,
InetAddr );
}
bool CProtocol::EvaluateCLVersionAndOSMes ( const CHostAddress& InetAddr,
const CVector<uint8_t>& vecData )
{
int iPos = 0; // init position pointer
const int iDataLen = vecData.Size();
// check size (the first 1 byte)
if ( iDataLen < 1 )
{
return true; // return error code
}
// operating system (1 byte)
const COSUtil::EOpSystemType eOSType =
static_cast<COSUtil::EOpSystemType> ( GetValFromStream ( vecData, iPos, 1 ) );
// version text
QString strVersion;
if ( GetStringFromStream ( vecData,
iPos,
MAX_LEN_VERSION_TEXT,
strVersion ) )
{
return true; // return error code
}
// check size: all data is read, the position must now be at the end
if ( iPos != iDataLen )
{
return true; // return error code
}
// invoke message action
emit CLVersionAndOSReceived ( InetAddr, eOSType, strVersion );
return false; // no error
}
void CProtocol::CreateCLReqVersionAndOSMes ( const CHostAddress& InetAddr )
{
CreateAndImmSendConLessMessage ( PROTMESSID_CLM_REQ_VERSION_AND_OS,
CVector<uint8_t> ( 0 ),
InetAddr );
}
bool CProtocol::EvaluateCLReqVersionAndOSMes ( const CHostAddress& InetAddr )
{
// invoke message action
emit CLReqVersionAndOS ( InetAddr );
return false; // no error
}
/******************************************************************************\
* Message generation and parsing *

View file

@ -67,10 +67,8 @@
#define PROTMESSID_CLM_SEND_EMPTY_MESSAGE 1008 // an empty message shall be send
#define PROTMESSID_CLM_EMPTY_MESSAGE 1009 // empty message
#define PROTMESSID_CLM_DISCONNECTION 1010 // disconnection
// TODO implement message for querying the version and operating system of the server
#define PROTMESSID_CLM_VERSION_AND_OS 1011 // version number and operating system
#define PROTMESSID_CLM_REQ_VERSION_AND_OS 1012 // request version number and operating system
// lengths of message as defined in protocol.cpp file
#define MESS_HEADER_LENGTH_BYTE 7 // TAG (2), ID (2), cnt (1), length (2)
@ -119,6 +117,8 @@ public:
const CHostAddress& TargetInetAddr );
void CreateCLEmptyMes ( const CHostAddress& InetAddr );
void CreateCLDisconnection ( const CHostAddress& InetAddr );
void CreateCLVersionAndOSMes ( const CHostAddress& InetAddr );
void CreateCLReqVersionAndOSMes ( const CHostAddress& InetAddr );
static bool ParseMessageFrame ( const CVector<uint8_t>& vecbyData,
const int iNumBytesIn,
@ -228,6 +228,9 @@ protected:
bool EvaluateCLReqServerListMes ( const CHostAddress& InetAddr );
bool EvaluateCLSendEmptyMesMes ( const CVector<uint8_t>& vecData );
bool EvaluateCLDisconnectionMes ( const CHostAddress& InetAddr );
bool EvaluateCLVersionAndOSMes ( const CHostAddress& InetAddr,
const CVector<uint8_t>& vecData );
bool EvaluateCLReqVersionAndOSMes ( const CHostAddress& InetAddr );
int iOldRecID;
int iOldRecCnt;
@ -278,6 +281,10 @@ signals:
void CLReqServerList ( CHostAddress InetAddr );
void CLSendEmptyMes ( CHostAddress TargetInetAddr );
void CLDisconnection ( CHostAddress InetAddr );
void CLVersionAndOSReceived ( CHostAddress InetAddr,
COSUtil::EOpSystemType eOSType,
QString strVersion );
void CLReqVersionAndOS ( CHostAddress InetAddr );
};
#endif /* !defined ( PROTOCOL_H__3B123453_4344_BB2392354455IUHF1912__INCLUDED_ ) */

View file

@ -422,6 +422,9 @@ CServer::CServer ( const int iNewMaxNumChan,
SIGNAL ( CLDisconnection ( CHostAddress ) ),
this, SLOT ( OnCLDisconnection ( CHostAddress ) ) );
QObject::connect ( &ConnLessProtocol,
SIGNAL ( CLReqVersionAndOS ( CHostAddress ) ),
this, SLOT ( OnCLReqVersionAndOS ( CHostAddress ) ) );
// CODE TAG: MAX_NUM_CHANNELS_TAG
// make sure we have MAX_NUM_CHANNELS connections!!!

View file

@ -317,6 +317,9 @@ public slots:
void OnCLReqServerList ( CHostAddress InetAddr )
{ ServerListManager.CentralServerQueryServerList ( InetAddr ); }
void OnCLReqVersionAndOS ( CHostAddress InetAddr )
{ ConnLessProtocol.CreateCLVersionAndOSMes ( InetAddr ); }
void OnCLRegisterServerReceived ( CHostAddress InetAddr,
CServerCoreInfo ServerInfo )
{

View file

@ -106,7 +106,7 @@ public slots:
CChannelCoreInfo ChannelCoreInfo;
// generate random protocol message
switch ( GenRandomIntInRange ( 0, 24 ) )
switch ( GenRandomIntInRange ( 0, 26 ) )
{
case 0: // PROTMESSID_JITT_BUF_SIZE
Protocol.CreateJitBufMes ( GenRandomIntInRange ( 0, 10 ) );
@ -260,12 +260,20 @@ public slots:
Protocol.CreateCLDisconnection ( CurHostAddress );
break;
case 23: // PROTMESSID_ACKN
case 23: // PROTMESSID_CLM_VERSION_AND_OS
Protocol.CreateCLVersionAndOSMes ( CurHostAddress );
break;
case 24: // PROTMESSID_CLM_REQ_VERSION_AND_OS
Protocol.CreateCLReqVersionAndOSMes ( CurHostAddress );
break;
case 25: // PROTMESSID_ACKN
Protocol.CreateAndImmSendAcknMess ( GenRandomIntInRange ( -10, 100 ),
GenRandomIntInRange ( -100, 100 ) );
break;
case 24:
case 26:
// arbitrary "audio" packet (with random sizes)
CVector<uint8_t> vecMessage ( GenRandomIntInRange ( 1, 1000 ) );
OnSendProtMessage ( vecMessage );

View file

@ -861,6 +861,49 @@ public:
};
// Operating system utility functions ------------------------------------------
class COSUtil
{
public:
enum EOpSystemType
{
// used for protocol -> enum values must be fixed!
OT_WINDOWS = 0,
OT_MAC_OS = 1,
OT_LINUX = 2,
OT_ANDROID = 3,
OT_I_OS = 4,
OT_UNIX = 5
};
static QString GetOperatingSystemString ( const EOpSystemType eOSType )
{
switch ( eOSType )
{
case OT_WINDOWS: return "Windows"; break;
case OT_MAC_OS: return "MacOS"; break;
case OT_LINUX: return "Linux"; break;
case OT_ANDROID: return "Android"; break;
case OT_I_OS: return "iOS"; break;
case OT_UNIX: return "Unix"; break;
}
}
static EOpSystemType GetOperatingSystem()
{
#ifdef _WIN32
return OT_WINDOWS;
#elif defined ( __APPLE__ ) || defined ( __MACOSX )
return OT_MAC_OS;
#elif definded ( ANDROID )
return OT_ANDROID;
#else
return OT_LINUX;
#endif
}
};
// Audio reverbration ----------------------------------------------------------
class CAudioReverb
{