support for setting the server info parameters via the command line arguments

This commit is contained in:
Volker Fischer 2011-04-25 13:25:33 +00:00
parent 3322af3bcc
commit 886251367b
5 changed files with 578 additions and 524 deletions

File diff suppressed because it is too large Load diff

View file

@ -169,10 +169,12 @@ CServer::CServer ( const QString& strLoggingFileName,
const QString& strHTMLStatusFileName, const QString& strHTMLStatusFileName,
const QString& strHistoryFileName, const QString& strHistoryFileName,
const QString& strServerNameForHTMLStatusFile, const QString& strServerNameForHTMLStatusFile,
const QString& strCentralServer ) : const QString& strCentralServer,
const QString& strServerInfo ) :
Socket ( this, iPortNumber ), Socket ( this, iPortNumber ),
bWriteStatusHTMLFile ( false ), bWriteStatusHTMLFile ( false ),
ServerListManager ( strCentralServer, ServerListManager ( strCentralServer,
strServerInfo,
&ConnLessProtocol ) &ConnLessProtocol )
{ {
int i; int i;

View file

@ -108,7 +108,8 @@ public:
const QString& strHTMLStatusFileName, const QString& strHTMLStatusFileName,
const QString& strHistoryFileName, const QString& strHistoryFileName,
const QString& strServerNameForHTMLStatusFile, const QString& strServerNameForHTMLStatusFile,
const QString& strCentralServer ); const QString& strCentralServer,
const QString& strServerInfo );
void Start(); void Start();
void Stop(); void Stop();

View file

@ -27,6 +27,7 @@
/* Implementation *************************************************************/ /* Implementation *************************************************************/
CServerListManager::CServerListManager ( const QString& sNCentServAddr, CServerListManager::CServerListManager ( const QString& sNCentServAddr,
const QString& strServerInfo,
CProtocol* pNConLProt ) CProtocol* pNConLProt )
: strCentralServerAddress ( sNCentServAddr ), : strCentralServerAddress ( sNCentServAddr ),
pConnLessProtocol ( pNConLProt ) pConnLessProtocol ( pNConLProt )
@ -54,17 +55,46 @@ CServerListManager::CServerListManager ( const QString& sNCentServAddr,
// never be deleted // never be deleted
ServerList.clear(); ServerList.clear();
// per definition the client substitudes the IP address of the central server // init server list entry (server info for this server) with defaults, per
// itself for his server list // definition the client substitudes the IP address of the central server
ServerList.append ( CServerListEntry ( // itself for his server list
CHostAddress(), CServerListEntry ThisServerListEntry (
"Master Server", // TEST CHostAddress(),
"", "",
QLocale::Germany, // TEST "",
"Munich", // TEST QLocale::AnyCountry,
USED_NUM_CHANNELS, "",
true ) ); // TEST USED_NUM_CHANNELS,
false );
// parse the server info string according to definition:
// [name];[city];[country as QLocale ID]
if ( !strServerInfo.isEmpty() )
{
// split the different parameter strings
QStringList slSeparateParameters = strServerInfo.split ( ";" );
// per definition, we expect three parameters
if ( slSeparateParameters.count() == 3 )
{
// [name]
ThisServerListEntry.strName = slSeparateParameters[0];
// [city]
ThisServerListEntry.strCity = slSeparateParameters[1];
// [country as QLocale ID]
const int iCountry = slSeparateParameters[2].toInt();
if ( ( iCountry >= 0 ) && ( iCountry <= QLocale::LastCountry ) )
{
ThisServerListEntry.eCountry = static_cast<QLocale::Country> (
iCountry );
}
}
}
// per definition, the first entry in the server list it the own server
ServerList.append ( ThisServerListEntry );
// Connections ------------------------------------------------------------- // Connections -------------------------------------------------------------

View file

@ -122,6 +122,7 @@ class CServerListManager : public QObject
public: public:
CServerListManager ( const QString& sNCentServAddr, CServerListManager ( const QString& sNCentServAddr,
const QString& strServerInfo,
CProtocol* pNConLProt ); CProtocol* pNConLProt );
void SetEnabled ( const bool bState ); void SetEnabled ( const bool bState );