support for storing/recovering settings for the server in GUI mode

This commit is contained in:
Volker Fischer 2011-04-25 16:16:31 +00:00
parent 886251367b
commit 328dbd2b1c
6 changed files with 886 additions and 784 deletions

View File

@ -46,8 +46,9 @@
#define VERSION "3.1.3cvs" #define VERSION "3.1.3cvs"
#define APP_NAME "llcon" #define APP_NAME "llcon"
// default name of the ini-file // default names of the ini-file for client and server
#define DEFAULT_INI_FILE_NAME "llcon.ini" #define DEFAULT_INI_FILE_NAME "llcon.ini"
#define DEFAULT_INI_FILE_NAME_SERVER "llconserver.ini"
// file name for logging file // file name for logging file
#define DEFAULT_LOG_FILE_NAME "llconsrvlog.txt" #define DEFAULT_LOG_FILE_NAME "llconsrvlog.txt"

View File

@ -349,6 +349,10 @@ int main ( int argc, char** argv )
if ( bUseGUI ) if ( bUseGUI )
{ {
// load settings from init-file
CSettings Settings ( &Server );
Settings.Load ( strIniFileName );
// GUI object for the server // GUI object for the server
CLlconServerDlg ServerDlg ( &Server, 0 ); CLlconServerDlg ServerDlg ( &Server, 0 );
@ -359,6 +363,9 @@ int main ( int argc, char** argv )
// show dialog // show dialog
ServerDlg.show(); ServerDlg.show();
app.exec(); app.exec();
// save settings to init-file
Settings.Save ( strIniFileName );
} }
else else
{ {

View File

@ -126,6 +126,22 @@ public:
CVector<int>& veciJitBufNumFrames, CVector<int>& veciJitBufNumFrames,
CVector<int>& veciNetwFrameSizeFact ); CVector<int>& veciNetwFrameSizeFact );
void SetServerName ( const QString& strNewName )
{ ServerListManager.SetServerName ( strNewName ); }
QString GetServerName() { return ServerListManager.GetServerName(); }
void SetServerCity ( const QString& strNewCity )
{ ServerListManager.SetServerCity ( strNewCity ); }
QString GetServerCity() { return ServerListManager.GetServerCity(); }
void SetServerCountry ( const QLocale::Country eNewCountry )
{ ServerListManager.SetServerCountry ( eNewCountry ); }
QLocale::Country GetServerCountry()
{ return ServerListManager.GetServerCountry(); }
protected: protected:
// access functions for actual channels // access functions for actual channels
bool IsConnected ( const int iChanNum ) bool IsConnected ( const int iChanNum )

View File

@ -127,6 +127,7 @@ public:
void SetEnabled ( const bool bState ); void SetEnabled ( const bool bState );
bool GetEnabled() const { return bEnabled; } bool GetEnabled() const { return bEnabled; }
bool GetIsCentralServer() const { return bIsCentralServer; } bool GetIsCentralServer() const { return bIsCentralServer; }
void RegisterServer ( const CHostAddress& InetAddr, void RegisterServer ( const CHostAddress& InetAddr,
@ -134,6 +135,25 @@ public:
void QueryServerList ( const CHostAddress& InetAddr ); void QueryServerList ( const CHostAddress& InetAddr );
// set server infos -> per definition the server info of this server is
// stored in the first entry of the list, we assume here that the first
// entry is correctly created in the constructor of the class
void SetServerName ( const QString& strNewName )
{ ServerList[0].strName = strNewName; }
QString GetServerName() { return ServerList[0].strName; }
void SetServerCity ( const QString& strNewCity )
{ ServerList[0].strCity = strNewCity; }
QString GetServerCity() { return ServerList[0].strCity; }
void SetServerCountry ( const QLocale::Country eNewCountry )
{ ServerList[0].eCountry = eNewCountry; }
QLocale::Country GetServerCountry() { return ServerList[0].eCountry; }
protected: protected:
QTimer TimerPollList; QTimer TimerPollList;
QTimer TimerRegistering; QTimer TimerRegistering;

View File

@ -45,144 +45,167 @@ void CSettings::ReadIniFile ( const QString& sFileName )
// Actual settings data --------------------------------------------------- // Actual settings data ---------------------------------------------------
// IP addresses if ( bIsClient )
for ( int iIPAddrIdx = 0; iIPAddrIdx < MAX_NUM_SERVER_ADDR_ITEMS; iIPAddrIdx++ )
{ {
QString sDefaultIP = ""; // client:
// use default only for first entry // IP addresses
if ( iIPAddrIdx == 0 ) for ( int iIPAddrIdx = 0; iIPAddrIdx < MAX_NUM_SERVER_ADDR_ITEMS; iIPAddrIdx++ )
{ {
sDefaultIP = DEFAULT_SERVER_ADDRESS; QString sDefaultIP = "";
// use default only for first entry
if ( iIPAddrIdx == 0 )
{
sDefaultIP = DEFAULT_SERVER_ADDRESS;
}
pClient->vstrIPAddress[iIPAddrIdx] =
GetIniSetting ( IniXMLDocument, "client",
QString ( "ipaddress%1" ).arg ( iIPAddrIdx ), sDefaultIP );
} }
pClient->vstrIPAddress[iIPAddrIdx] = // name
GetIniSetting ( IniXMLDocument, "client", pClient->strName = GetIniSetting ( IniXMLDocument, "client", "name" );
QString ( "ipaddress%1" ).arg ( iIPAddrIdx ), sDefaultIP );
}
// name // audio fader
pClient->strName = GetIniSetting ( IniXMLDocument, "client", "name" ); if ( GetNumericIniSet ( IniXMLDocument, "client", "audfad",
AUD_FADER_IN_MIN, AUD_FADER_IN_MAX, iValue ) )
{
pClient->SetAudioInFader ( iValue );
}
// audio fader // reverberation level
if ( GetNumericIniSet ( IniXMLDocument, "client", "audfad", if ( GetNumericIniSet ( IniXMLDocument, "client", "revlev",
AUD_FADER_IN_MIN, AUD_FADER_IN_MAX, iValue ) ) 0, AUD_REVERB_MAX, iValue ) )
{ {
pClient->SetAudioInFader ( iValue ); pClient->SetReverbLevel ( iValue );
} }
// reverberation level // reverberation channel assignment
if ( GetNumericIniSet ( IniXMLDocument, "client", "revlev", if ( GetFlagIniSet ( IniXMLDocument, "client", "reverblchan", bValue ) )
0, AUD_REVERB_MAX, iValue ) ) {
{ pClient->SetReverbOnLeftChan ( bValue );
pClient->SetReverbLevel ( iValue ); }
}
// reverberation channel assignment // sound card selection
if ( GetFlagIniSet ( IniXMLDocument, "client", "reverblchan", bValue ) ) // special case with this setting: the sound card initialization depends
{ // on this setting call, therefore, if no setting file parameter could
pClient->SetReverbOnLeftChan ( bValue ); // be retrieved, the sound card is initialized with a default setting
} // defined here
if ( GetNumericIniSet ( IniXMLDocument, "client", "auddevidx",
1, MAX_NUMBER_SOUND_CARDS, iValue ) )
{
pClient->SetSndCrdDev ( iValue );
}
else
{
// use "INVALID_SNC_CARD_DEVICE" to tell the sound card driver that
// no device selection was done previously
pClient->SetSndCrdDev ( INVALID_SNC_CARD_DEVICE );
}
// sound card selection // sound card channel mapping settings: make sure these settings are
// special case with this setting: the sound card initialization depends on this setting // set AFTER the sound card device is set, otherwise the settings are
// call, therefore, if no setting file parameter could be retrieved, the sound card is // overwritten by the defaults
// initialized with a default setting defined here //
if ( GetNumericIniSet ( IniXMLDocument, "client", "auddevidx", // sound card left input channel mapping
1, MAX_NUMBER_SOUND_CARDS, iValue ) ) if ( GetNumericIniSet ( IniXMLDocument, "client", "sndcrdinlch",
{ 0, MAX_NUM_IN_OUT_CHANNELS - 1, iValue ) )
pClient->SetSndCrdDev ( iValue ); {
pClient->SetSndCrdLeftInputChannel ( iValue );
}
// sound card right input channel mapping
if ( GetNumericIniSet ( IniXMLDocument, "client", "sndcrdinrch",
0, MAX_NUM_IN_OUT_CHANNELS - 1, iValue ) )
{
pClient->SetSndCrdRightInputChannel ( iValue );
}
// sound card left output channel mapping
if ( GetNumericIniSet ( IniXMLDocument, "client", "sndcrdoutlch",
0, MAX_NUM_IN_OUT_CHANNELS - 1, iValue ) )
{
pClient->SetSndCrdLeftOutputChannel ( iValue );
}
// sound card right output channel mapping
if ( GetNumericIniSet ( IniXMLDocument, "client", "sndcrdoutrch",
0, MAX_NUM_IN_OUT_CHANNELS - 1, iValue ) )
{
pClient->SetSndCrdRightOutputChannel ( iValue );
}
// sound card preferred buffer size index
if ( GetNumericIniSet ( IniXMLDocument, "client", "prefsndcrdbufidx",
FRAME_SIZE_FACTOR_PREFERRED, FRAME_SIZE_FACTOR_SAFE, iValue ) )
{
// additional check required since only a subset of factors are
// defined
if ( ( iValue == FRAME_SIZE_FACTOR_PREFERRED ) ||
( iValue == FRAME_SIZE_FACTOR_DEFAULT ) ||
( iValue == FRAME_SIZE_FACTOR_SAFE ) )
{
pClient->SetSndCrdPrefFrameSizeFactor ( iValue );
}
}
// automatic network jitter buffer size setting
if ( GetFlagIniSet ( IniXMLDocument, "client", "autojitbuf", bValue ) )
{
pClient->SetDoAutoSockBufSize ( bValue );
}
// network jitter buffer size
if ( GetNumericIniSet ( IniXMLDocument, "client", "jitbuf",
MIN_NET_BUF_SIZE_NUM_BL, MAX_NET_BUF_SIZE_NUM_BL, iValue ) )
{
pClient->SetSockBufNumFrames ( iValue );
}
// flag whether the chat window shall be opened on a new chat message
if ( GetFlagIniSet ( IniXMLDocument, "client", "openchatonnewmessage", bValue ) )
{
pClient->SetOpenChatOnNewMessage ( bValue );
}
// GUI design
if ( GetNumericIniSet ( IniXMLDocument, "client", "guidesign",
0, 1 /* GD_ORIGINAL */, iValue ) )
{
pClient->SetGUIDesign ( static_cast<EGUIDesign> ( iValue ) );
}
// flag whether using high quality audio or not
if ( GetFlagIniSet ( IniXMLDocument, "client", "highqualityaudio", bValue ) )
{
pClient->SetCELTHighQuality ( bValue );
}
// flag whether stereo mode is used
if ( GetFlagIniSet ( IniXMLDocument, "client", "stereoaudio", bValue ) )
{
pClient->SetUseStereo ( bValue );
}
} }
else else
{ {
// use "INVALID_SNC_CARD_DEVICE" to tell the sound card driver that no // server:
// device selection was done previously
pClient->SetSndCrdDev ( INVALID_SNC_CARD_DEVICE );
}
// sound card channel mapping settings: make sure these settings are // name
// set AFTER the sound card device is set, otherwise the settings are pServer->SetServerName ( GetIniSetting ( IniXMLDocument, "server", "name" ) );
// overwritten by the defaults
//
// sound card left input channel mapping
if ( GetNumericIniSet ( IniXMLDocument, "client", "sndcrdinlch",
0, MAX_NUM_IN_OUT_CHANNELS - 1, iValue ) )
{
pClient->SetSndCrdLeftInputChannel ( iValue );
}
// sound card right input channel mapping // city
if ( GetNumericIniSet ( IniXMLDocument, "client", "sndcrdinrch", pServer->SetServerCity ( GetIniSetting ( IniXMLDocument, "server", "name" ) );
0, MAX_NUM_IN_OUT_CHANNELS - 1, iValue ) )
{
pClient->SetSndCrdRightInputChannel ( iValue );
}
// sound card left output channel mapping // country
if ( GetNumericIniSet ( IniXMLDocument, "client", "sndcrdoutlch", if ( GetNumericIniSet ( IniXMLDocument, "server", "country",
0, MAX_NUM_IN_OUT_CHANNELS - 1, iValue ) ) 0, static_cast<int> ( QLocale::LastCountry ), iValue ) )
{
pClient->SetSndCrdLeftOutputChannel ( iValue );
}
// sound card right output channel mapping
if ( GetNumericIniSet ( IniXMLDocument, "client", "sndcrdoutrch",
0, MAX_NUM_IN_OUT_CHANNELS - 1, iValue ) )
{
pClient->SetSndCrdRightOutputChannel ( iValue );
}
// sound card preferred buffer size index
if ( GetNumericIniSet ( IniXMLDocument, "client", "prefsndcrdbufidx",
FRAME_SIZE_FACTOR_PREFERRED, FRAME_SIZE_FACTOR_SAFE, iValue ) )
{
// additional check required since only a subset of factors are
// defined
if ( ( iValue == FRAME_SIZE_FACTOR_PREFERRED ) ||
( iValue == FRAME_SIZE_FACTOR_DEFAULT ) ||
( iValue == FRAME_SIZE_FACTOR_SAFE ) )
{ {
pClient->SetSndCrdPrefFrameSizeFactor ( iValue ); pServer->SetServerCountry ( static_cast<QLocale::Country> ( iValue ) );
} }
} }
// automatic network jitter buffer size setting
if ( GetFlagIniSet ( IniXMLDocument, "client", "autojitbuf", bValue ) )
{
pClient->SetDoAutoSockBufSize ( bValue );
}
// network jitter buffer size
if ( GetNumericIniSet ( IniXMLDocument, "client", "jitbuf",
MIN_NET_BUF_SIZE_NUM_BL, MAX_NET_BUF_SIZE_NUM_BL, iValue ) )
{
pClient->SetSockBufNumFrames ( iValue );
}
// flag whether the chat window shall be opened on a new chat message
if ( GetFlagIniSet ( IniXMLDocument, "client", "openchatonnewmessage", bValue ) )
{
pClient->SetOpenChatOnNewMessage ( bValue );
}
// GUI design
if ( GetNumericIniSet ( IniXMLDocument, "client", "guidesign",
0, 1 /* GD_ORIGINAL */, iValue ) )
{
pClient->SetGUIDesign ( static_cast<EGUIDesign> ( iValue ) );
}
// flag whether using high quality audio or not
if ( GetFlagIniSet ( IniXMLDocument, "client", "highqualityaudio", bValue ) )
{
pClient->SetCELTHighQuality ( bValue );
}
// flag whether stereo mode is used
if ( GetFlagIniSet ( IniXMLDocument, "client", "stereoaudio", bValue ) )
{
pClient->SetUseStereo ( bValue );
}
} }
void CSettings::WriteIniFile ( const QString& sFileName ) void CSettings::WriteIniFile ( const QString& sFileName )
@ -192,77 +215,98 @@ void CSettings::WriteIniFile ( const QString& sFileName )
// Actual settings data --------------------------------------------------- // Actual settings data ---------------------------------------------------
// IP addresses if ( bIsClient )
for ( int iIPAddrIdx = 0; iIPAddrIdx < MAX_NUM_SERVER_ADDR_ITEMS; iIPAddrIdx++ )
{ {
PutIniSetting ( IniXMLDocument, "client", // client:
QString ( "ipaddress%1" ).arg ( iIPAddrIdx ),
pClient->vstrIPAddress[iIPAddrIdx] ); // IP addresses
for ( int iIPAddrIdx = 0; iIPAddrIdx < MAX_NUM_SERVER_ADDR_ITEMS; iIPAddrIdx++ )
{
PutIniSetting ( IniXMLDocument, "client",
QString ( "ipaddress%1" ).arg ( iIPAddrIdx ),
pClient->vstrIPAddress[iIPAddrIdx] );
}
// name
PutIniSetting ( IniXMLDocument, "client", "name",
pClient->strName );
// audio fader
SetNumericIniSet ( IniXMLDocument, "client", "audfad",
pClient->GetAudioInFader() );
// reverberation level
SetNumericIniSet ( IniXMLDocument, "client", "revlev",
pClient->GetReverbLevel() );
// reverberation channel assignment
SetFlagIniSet ( IniXMLDocument, "client", "reverblchan",
pClient->IsReverbOnLeftChan() );
// sound card selection
SetNumericIniSet ( IniXMLDocument, "client", "auddevidx",
pClient->GetSndCrdDev() );
// sound card left input channel mapping
SetNumericIniSet ( IniXMLDocument, "client", "sndcrdinlch",
pClient->GetSndCrdLeftInputChannel() );
// sound card right input channel mapping
SetNumericIniSet ( IniXMLDocument, "client", "sndcrdinrch",
pClient->GetSndCrdRightInputChannel() );
// sound card left output channel mapping
SetNumericIniSet ( IniXMLDocument, "client", "sndcrdoutlch",
pClient->GetSndCrdLeftOutputChannel() );
// sound card right output channel mapping
SetNumericIniSet ( IniXMLDocument, "client", "sndcrdoutrch",
pClient->GetSndCrdRightOutputChannel() );
// sound card preferred buffer size index
SetNumericIniSet ( IniXMLDocument, "client", "prefsndcrdbufidx",
pClient->GetSndCrdPrefFrameSizeFactor() );
// automatic network jitter buffer size setting
SetFlagIniSet ( IniXMLDocument, "client", "autojitbuf",
pClient->GetDoAutoSockBufSize() );
// network jitter buffer size
SetNumericIniSet ( IniXMLDocument, "client", "jitbuf",
pClient->GetSockBufNumFrames() );
// flag whether the chat window shall be opened on a new chat message
SetFlagIniSet ( IniXMLDocument, "client", "openchatonnewmessage",
pClient->GetOpenChatOnNewMessage() );
// GUI design
SetNumericIniSet ( IniXMLDocument, "client", "guidesign",
static_cast<int> ( pClient->GetGUIDesign() ) );
// flag whether using high quality audio or not
SetFlagIniSet ( IniXMLDocument, "client", "highqualityaudio",
pClient->GetCELTHighQuality() );
// flag whether stereo mode is used
SetFlagIniSet ( IniXMLDocument, "client", "stereoaudio",
pClient->GetUseStereo() );
} }
else
{
// server:
// name // name
PutIniSetting ( IniXMLDocument, "client", "name", PutIniSetting ( IniXMLDocument, "server", "name",
pClient->strName ); pServer->GetServerName() );
// audio fader // city
SetNumericIniSet ( IniXMLDocument, "client", "audfad", PutIniSetting ( IniXMLDocument, "server", "city",
pClient->GetAudioInFader() ); pServer->GetServerCity() );
// reverberation level // country
SetNumericIniSet ( IniXMLDocument, "client", "revlev", SetNumericIniSet ( IniXMLDocument, "server", "country",
pClient->GetReverbLevel() ); static_cast<int> ( pServer->GetServerCountry() ) );
}
// reverberation channel assignment
SetFlagIniSet ( IniXMLDocument, "client", "reverblchan",
pClient->IsReverbOnLeftChan() );
// sound card selection
SetNumericIniSet ( IniXMLDocument, "client", "auddevidx",
pClient->GetSndCrdDev() );
// sound card left input channel mapping
SetNumericIniSet ( IniXMLDocument, "client", "sndcrdinlch",
pClient->GetSndCrdLeftInputChannel() );
// sound card right input channel mapping
SetNumericIniSet ( IniXMLDocument, "client", "sndcrdinrch",
pClient->GetSndCrdRightInputChannel() );
// sound card left output channel mapping
SetNumericIniSet ( IniXMLDocument, "client", "sndcrdoutlch",
pClient->GetSndCrdLeftOutputChannel() );
// sound card right output channel mapping
SetNumericIniSet ( IniXMLDocument, "client", "sndcrdoutrch",
pClient->GetSndCrdRightOutputChannel() );
// sound card preferred buffer size index
SetNumericIniSet ( IniXMLDocument, "client", "prefsndcrdbufidx",
pClient->GetSndCrdPrefFrameSizeFactor() );
// automatic network jitter buffer size setting
SetFlagIniSet ( IniXMLDocument, "client", "autojitbuf",
pClient->GetDoAutoSockBufSize() );
// network jitter buffer size
SetNumericIniSet ( IniXMLDocument, "client", "jitbuf",
pClient->GetSockBufNumFrames() );
// flag whether the chat window shall be opened on a new chat message
SetFlagIniSet ( IniXMLDocument, "client", "openchatonnewmessage",
pClient->GetOpenChatOnNewMessage() );
// GUI design
SetNumericIniSet ( IniXMLDocument, "client", "guidesign",
static_cast<int> ( pClient->GetGUIDesign() ) );
// flag whether using high quality audio or not
SetFlagIniSet ( IniXMLDocument, "client", "highqualityaudio",
pClient->GetCELTHighQuality() );
// flag whether stereo mode is used
SetFlagIniSet ( IniXMLDocument, "client", "stereoaudio",
pClient->GetUseStereo() );
// prepare file name for storing initialization data in XML file and store // prepare file name for storing initialization data in XML file and store
// XML data in file // XML data in file
@ -274,6 +318,8 @@ void CSettings::WriteIniFile ( const QString& sFileName )
} }
} }
// Help functions **************************************************************
QString CSettings::GetIniFileNameWithPath ( const QString& sFileName ) QString CSettings::GetIniFileNameWithPath ( const QString& sFileName )
{ {
// return the file name with complete path, take care if given file name is // return the file name with complete path, take care if given file name is
@ -297,7 +343,14 @@ QString CSettings::GetIniFileNameWithPath ( const QString& sFileName )
} }
// append the actual file name // append the actual file name
sCurFileName = sConfigDir + "/" + DEFAULT_INI_FILE_NAME; if ( bIsClient )
{
sCurFileName = sConfigDir + "/" + DEFAULT_INI_FILE_NAME;
}
else
{
sCurFileName = sConfigDir + "/" + DEFAULT_INI_FILE_NAME_SERVER;
}
} }
return sCurFileName; return sCurFileName;

View File

@ -32,13 +32,15 @@
#include <qtextstream.h> #include <qtextstream.h>
#include "global.h" #include "global.h"
#include "client.h" #include "client.h"
#include "server.h"
/* Classes ********************************************************************/ /* Classes ********************************************************************/
class CSettings class CSettings
{ {
public: public:
CSettings ( CClient* pNCliP ) : pClient ( pNCliP ) {} CSettings ( CClient* pNCliP ) : pClient ( pNCliP ), bIsClient ( true ) {}
CSettings ( CServer* pNSerP ) : pServer ( pNSerP ), bIsClient ( false ) {}
void Load ( const QString& sFileName = "" ) { ReadIniFile ( sFileName ); } void Load ( const QString& sFileName = "" ) { ReadIniFile ( sFileName ); }
void Save ( const QString& sFileName = "" ) { WriteIniFile ( sFileName ); } void Save ( const QString& sFileName = "" ) { WriteIniFile ( sFileName ); }
@ -66,8 +68,11 @@ protected:
void PutIniSetting ( QDomDocument& xmlFile, const QString& sSection, void PutIniSetting ( QDomDocument& xmlFile, const QString& sSection,
const QString& sKey, const QString& sValue = "" ); const QString& sKey, const QString& sValue = "" );
// pointer to the client object needed for the various settings // pointer to the client/server object which stores the various settings
CClient* pClient; CClient* pClient; // for client
CServer* pServer; // for server
bool bIsClient;
}; };
#endif // !defined ( SETTINGS_H__3B0BA660_DGEG56G456G9876D31912__INCLUDED_ ) #endif // !defined ( SETTINGS_H__3B0BA660_DGEG56G456G9876D31912__INCLUDED_ )