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
22
src/main.cpp
22
src/main.cpp
|
@ -64,6 +64,7 @@ int main ( int argc, char** argv )
|
||||||
QString strLoggingFileName = "";
|
QString strLoggingFileName = "";
|
||||||
QString strHistoryFileName = "";
|
QString strHistoryFileName = "";
|
||||||
QString strCentralServer = "";
|
QString strCentralServer = "";
|
||||||
|
QString strServerInfo = "";
|
||||||
|
|
||||||
// QT docu: argv()[0] is the program name, argv()[1] is the first
|
// QT docu: argv()[0] is the program name, argv()[1] is the first
|
||||||
// argument and argv()[argc()-1] is the last argument.
|
// argument and argv()[argc()-1] is the last argument.
|
||||||
|
@ -196,6 +197,21 @@ int main ( int argc, char** argv )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Server info ---------------------------------------------------------
|
||||||
|
if ( GetStringArgument ( tsConsole,
|
||||||
|
argc,
|
||||||
|
argv,
|
||||||
|
i,
|
||||||
|
"-o",
|
||||||
|
"--serverinfo",
|
||||||
|
strArgument ) )
|
||||||
|
{
|
||||||
|
strServerInfo = strArgument;
|
||||||
|
tsConsole << "- server info: " << strServerInfo << endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Initialization file -------------------------------------------------
|
// Initialization file -------------------------------------------------
|
||||||
if ( GetStringArgument ( tsConsole,
|
if ( GetStringArgument ( tsConsole,
|
||||||
argc,
|
argc,
|
||||||
|
@ -328,7 +344,8 @@ int main ( int argc, char** argv )
|
||||||
strHTMLStatusFileName,
|
strHTMLStatusFileName,
|
||||||
strHistoryFileName,
|
strHistoryFileName,
|
||||||
strServerName,
|
strServerName,
|
||||||
strCentralServer );
|
strCentralServer,
|
||||||
|
strServerInfo );
|
||||||
|
|
||||||
if ( bUseGUI )
|
if ( bUseGUI )
|
||||||
{
|
{
|
||||||
|
@ -394,6 +411,9 @@ QString UsageArguments ( char **argv )
|
||||||
" -y, --history enable connection history and set file\n"
|
" -y, --history enable connection history and set file\n"
|
||||||
" name (server only)\n"
|
" name (server only)\n"
|
||||||
" -e, --centralserver address of the central server (server only)\n"
|
" -e, --centralserver address of the central server (server only)\n"
|
||||||
|
" -o, --serverinfo infos of the server in the format:"
|
||||||
|
" [name];[city];[country as QLocale ID] (server "
|
||||||
|
" only)\n"
|
||||||
" -c, --connect connect to last server on startup (client\n"
|
" -c, --connect connect to last server on startup (client\n"
|
||||||
" only)\n"
|
" only)\n"
|
||||||
" -d, --disableleds disable LEDs in main window (client only)\n"
|
" -d, --disableleds disable LEDs in main window (client only)\n"
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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();
|
||||||
|
|
|
@ -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 -------------------------------------------------------------
|
||||||
|
|
|
@ -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 );
|
||||||
|
|
Loading…
Add table
Reference in a new issue