support for setting the server info parameters via the command line arguments
This commit is contained in:
parent
3322af3bcc
commit
886251367b
5 changed files with 578 additions and 524 deletions
1044
src/main.cpp
1044
src/main.cpp
File diff suppressed because it is too large
Load diff
|
@ -169,10 +169,12 @@ CServer::CServer ( const QString& strLoggingFileName,
|
|||
const QString& strHTMLStatusFileName,
|
||||
const QString& strHistoryFileName,
|
||||
const QString& strServerNameForHTMLStatusFile,
|
||||
const QString& strCentralServer ) :
|
||||
const QString& strCentralServer,
|
||||
const QString& strServerInfo ) :
|
||||
Socket ( this, iPortNumber ),
|
||||
bWriteStatusHTMLFile ( false ),
|
||||
ServerListManager ( strCentralServer,
|
||||
strServerInfo,
|
||||
&ConnLessProtocol )
|
||||
{
|
||||
int i;
|
||||
|
|
|
@ -108,7 +108,8 @@ public:
|
|||
const QString& strHTMLStatusFileName,
|
||||
const QString& strHistoryFileName,
|
||||
const QString& strServerNameForHTMLStatusFile,
|
||||
const QString& strCentralServer );
|
||||
const QString& strCentralServer,
|
||||
const QString& strServerInfo );
|
||||
|
||||
void Start();
|
||||
void Stop();
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
/* Implementation *************************************************************/
|
||||
CServerListManager::CServerListManager ( const QString& sNCentServAddr,
|
||||
const QString& strServerInfo,
|
||||
CProtocol* pNConLProt )
|
||||
: strCentralServerAddress ( sNCentServAddr ),
|
||||
pConnLessProtocol ( pNConLProt )
|
||||
|
@ -54,17 +55,46 @@ CServerListManager::CServerListManager ( const QString& sNCentServAddr,
|
|||
// never be deleted
|
||||
ServerList.clear();
|
||||
|
||||
// per definition the client substitudes the IP address of the central server
|
||||
// itself for his server list
|
||||
ServerList.append ( CServerListEntry (
|
||||
CHostAddress(),
|
||||
"Master Server", // TEST
|
||||
"",
|
||||
QLocale::Germany, // TEST
|
||||
"Munich", // TEST
|
||||
USED_NUM_CHANNELS,
|
||||
true ) ); // TEST
|
||||
// init server list entry (server info for this server) with defaults, per
|
||||
// definition the client substitudes the IP address of the central server
|
||||
// itself for his server list
|
||||
CServerListEntry ThisServerListEntry (
|
||||
CHostAddress(),
|
||||
"",
|
||||
"",
|
||||
QLocale::AnyCountry,
|
||||
"",
|
||||
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 -------------------------------------------------------------
|
||||
|
|
|
@ -122,6 +122,7 @@ class CServerListManager : public QObject
|
|||
|
||||
public:
|
||||
CServerListManager ( const QString& sNCentServAddr,
|
||||
const QString& strServerInfo,
|
||||
CProtocol* pNConLProt );
|
||||
|
||||
void SetEnabled ( const bool bState );
|
||||
|
|
Loading…
Reference in a new issue