2011-04-25 18:16:31 +02:00
|
|
|
/******************************************************************************\
|
2014-01-05 17:52:38 +01:00
|
|
|
* Copyright (c) 2004-2014
|
2011-04-25 18:16:31 +02:00
|
|
|
*
|
|
|
|
* Author(s):
|
|
|
|
* Volker Fischer
|
|
|
|
*
|
|
|
|
******************************************************************************
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it under
|
|
|
|
* the terms of the GNU General Public License as published by the Free Software
|
|
|
|
* Foundation; either version 2 of the License, or (at your option) any later
|
|
|
|
* version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
* details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
|
|
|
#include "settings.h"
|
|
|
|
|
|
|
|
|
|
|
|
/* Implementation *************************************************************/
|
2011-05-21 18:53:01 +02:00
|
|
|
void CSettings::Load()
|
2011-04-25 18:16:31 +02:00
|
|
|
{
|
2013-02-28 21:54:47 +01:00
|
|
|
int iIdx;
|
2011-04-25 18:16:31 +02:00
|
|
|
int iValue;
|
|
|
|
bool bValue;
|
|
|
|
QDomDocument IniXMLDocument;
|
|
|
|
|
|
|
|
// prepare file name for loading initialization data from XML file and read
|
|
|
|
// data from file if possible
|
2011-05-21 18:53:01 +02:00
|
|
|
QFile file ( strFileName );
|
2011-04-25 18:16:31 +02:00
|
|
|
if ( file.open ( QIODevice::ReadOnly ) )
|
|
|
|
{
|
|
|
|
QTextStream in ( &file );
|
|
|
|
IniXMLDocument.setContent ( in.readAll(), false );
|
|
|
|
|
|
|
|
file.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Actual settings data ---------------------------------------------------
|
|
|
|
if ( bIsClient )
|
|
|
|
{
|
|
|
|
// client:
|
|
|
|
|
|
|
|
// IP addresses
|
2013-02-28 21:54:47 +01:00
|
|
|
for ( iIdx = 0; iIdx < MAX_NUM_SERVER_ADDR_ITEMS; iIdx++ )
|
2011-04-25 18:16:31 +02:00
|
|
|
{
|
|
|
|
QString sDefaultIP = "";
|
|
|
|
|
|
|
|
// use default only for first entry
|
2013-02-28 21:54:47 +01:00
|
|
|
if ( iIdx == 0 )
|
2011-04-25 18:16:31 +02:00
|
|
|
{
|
|
|
|
sDefaultIP = DEFAULT_SERVER_ADDRESS;
|
|
|
|
}
|
|
|
|
|
2013-02-28 21:54:47 +01:00
|
|
|
pClient->vstrIPAddress[iIdx] =
|
2011-04-25 18:16:31 +02:00
|
|
|
GetIniSetting ( IniXMLDocument, "client",
|
2013-02-28 21:54:47 +01:00
|
|
|
QString ( "ipaddress%1" ).arg ( iIdx ), sDefaultIP );
|
|
|
|
}
|
|
|
|
|
|
|
|
// stored fader tags
|
|
|
|
for ( iIdx = 0; iIdx < MAX_NUM_STORED_FADER_LEVELS; iIdx++ )
|
|
|
|
{
|
2013-12-15 11:54:17 +01:00
|
|
|
pClient->vecStoredFaderTags[iIdx] = FromBase64ToString (
|
2013-02-28 21:54:47 +01:00
|
|
|
GetIniSetting ( IniXMLDocument, "client",
|
2013-12-15 11:54:17 +01:00
|
|
|
QString ( "storedfadertag%1_base64" ).arg ( iIdx ), "" ) );
|
2013-02-28 21:54:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// stored fader levels
|
|
|
|
for ( iIdx = 0; iIdx < MAX_NUM_STORED_FADER_LEVELS; iIdx++ )
|
|
|
|
{
|
|
|
|
if ( GetNumericIniSet ( IniXMLDocument, "client", QString ( "storedfaderlevel%1" ).arg ( iIdx ),
|
|
|
|
0, AUD_MIX_FADER_MAX, iValue ) )
|
|
|
|
{
|
|
|
|
pClient->vecStoredFaderLevels[iIdx] = iValue;
|
|
|
|
}
|
2011-04-25 18:16:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// name
|
2013-12-15 11:54:17 +01:00
|
|
|
pClient->ChannelInfo.strName = FromBase64ToString (
|
|
|
|
GetIniSetting ( IniXMLDocument, "client", "name_base64" ) );
|
2013-02-11 16:21:53 +01:00
|
|
|
|
|
|
|
// instrument
|
|
|
|
if ( GetNumericIniSet ( IniXMLDocument, "client", "instrument",
|
2013-02-28 21:54:47 +01:00
|
|
|
0, CInstPictures::GetNumAvailableInst() - 1, iValue ) )
|
2013-02-11 16:21:53 +01:00
|
|
|
{
|
|
|
|
pClient->ChannelInfo.iInstrument = iValue;
|
|
|
|
}
|
2011-04-25 18:16:31 +02:00
|
|
|
|
|
|
|
// audio fader
|
|
|
|
if ( GetNumericIniSet ( IniXMLDocument, "client", "audfad",
|
|
|
|
AUD_FADER_IN_MIN, AUD_FADER_IN_MAX, iValue ) )
|
|
|
|
{
|
|
|
|
pClient->SetAudioInFader ( iValue );
|
|
|
|
}
|
|
|
|
|
|
|
|
// reverberation level
|
|
|
|
if ( GetNumericIniSet ( IniXMLDocument, "client", "revlev",
|
|
|
|
0, AUD_REVERB_MAX, iValue ) )
|
|
|
|
{
|
|
|
|
pClient->SetReverbLevel ( iValue );
|
|
|
|
}
|
|
|
|
|
|
|
|
// reverberation channel assignment
|
|
|
|
if ( GetFlagIniSet ( IniXMLDocument, "client", "reverblchan", bValue ) )
|
|
|
|
{
|
|
|
|
pClient->SetReverbOnLeftChan ( bValue );
|
|
|
|
}
|
|
|
|
|
|
|
|
// sound card selection
|
|
|
|
// special case with this setting: the sound card initialization depends
|
|
|
|
// on this setting call, therefore, if no setting file parameter could
|
|
|
|
// 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 channel mapping settings: make sure these settings are
|
|
|
|
// set AFTER the sound card device is set, otherwise the settings are
|
|
|
|
// 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
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
2011-05-27 22:29:37 +02:00
|
|
|
// network jitter buffer size for server
|
|
|
|
if ( GetNumericIniSet ( IniXMLDocument, "client", "jitbufserver",
|
|
|
|
MIN_NET_BUF_SIZE_NUM_BL, MAX_NET_BUF_SIZE_NUM_BL, iValue ) )
|
|
|
|
{
|
|
|
|
pClient->SetServerSockBufNumFrames ( iValue );
|
|
|
|
}
|
|
|
|
|
2011-04-25 18:16:31 +02:00
|
|
|
// 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 ) );
|
|
|
|
}
|
|
|
|
|
2013-08-15 21:15:01 +02:00
|
|
|
// audio quality
|
|
|
|
if ( GetNumericIniSet ( IniXMLDocument, "client", "audioquality",
|
|
|
|
0, 2 /* AQ_HIGH */, iValue ) )
|
2011-04-25 18:16:31 +02:00
|
|
|
{
|
2013-08-15 21:15:01 +02:00
|
|
|
pClient->SetAudioQuality ( static_cast<EAudioQuality> ( iValue ) );
|
2011-04-25 18:16:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// flag whether stereo mode is used
|
|
|
|
if ( GetFlagIniSet ( IniXMLDocument, "client", "stereoaudio", bValue ) )
|
|
|
|
{
|
|
|
|
pClient->SetUseStereo ( bValue );
|
|
|
|
}
|
2011-05-02 21:48:36 +02:00
|
|
|
|
|
|
|
// central server address
|
|
|
|
pClient->SetServerListCentralServerAddress (
|
|
|
|
GetIniSetting ( IniXMLDocument, "client", "centralservaddr" ) );
|
|
|
|
|
|
|
|
// use default central server address flag
|
|
|
|
if ( GetFlagIniSet ( IniXMLDocument, "client", "defcentservaddr", bValue ) )
|
|
|
|
{
|
|
|
|
pClient->SetUseDefaultCentralServerAddress ( bValue );
|
|
|
|
}
|
2013-08-26 21:59:18 +02:00
|
|
|
|
|
|
|
// window position of the main window
|
2013-12-15 11:54:17 +01:00
|
|
|
pClient->vecWindowPosMain = FromBase64ToByteArray (
|
|
|
|
GetIniSetting ( IniXMLDocument, "client", "winposmain_base64" ) );
|
2013-08-26 21:59:18 +02:00
|
|
|
|
|
|
|
// window position of the settings window
|
2013-12-15 11:54:17 +01:00
|
|
|
pClient->vecWindowPosSettings = FromBase64ToByteArray (
|
|
|
|
GetIniSetting ( IniXMLDocument, "client", "winposset_base64" ) );
|
2013-08-26 21:59:18 +02:00
|
|
|
|
|
|
|
// window position of the chat window
|
2013-12-15 11:54:17 +01:00
|
|
|
pClient->vecWindowPosChat = FromBase64ToByteArray (
|
|
|
|
GetIniSetting ( IniXMLDocument, "client", "winposchat_base64" ) );
|
2013-08-26 21:59:18 +02:00
|
|
|
|
|
|
|
// window position of the connect window
|
2013-12-15 11:54:17 +01:00
|
|
|
pClient->vecWindowPosConnect = FromBase64ToByteArray (
|
|
|
|
GetIniSetting ( IniXMLDocument, "client", "winposcon_base64" ) );
|
2013-08-26 21:59:18 +02:00
|
|
|
|
|
|
|
// visibility state of the settings window
|
|
|
|
if ( GetFlagIniSet ( IniXMLDocument, "client", "winvisset", bValue ) )
|
|
|
|
{
|
|
|
|
pClient->bWindowWasShownSettings = bValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// visibility state of the chat window
|
|
|
|
if ( GetFlagIniSet ( IniXMLDocument, "client", "winvischat", bValue ) )
|
|
|
|
{
|
|
|
|
pClient->bWindowWasShownChat = bValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// visibility state of the connect window
|
|
|
|
if ( GetFlagIniSet ( IniXMLDocument, "client", "winviscon", bValue ) )
|
|
|
|
{
|
|
|
|
pClient->bWindowWasShownConnect = bValue;
|
|
|
|
}
|
2011-04-25 18:16:31 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// server:
|
|
|
|
|
2011-04-30 15:01:26 +02:00
|
|
|
// central server address
|
|
|
|
pServer->SetServerListCentralServerAddress (
|
|
|
|
GetIniSetting ( IniXMLDocument, "server", "centralservaddr" ) );
|
|
|
|
|
2011-04-30 21:51:49 +02:00
|
|
|
// use default central server address flag
|
|
|
|
if ( GetFlagIniSet ( IniXMLDocument, "server", "defcentservaddr", bValue ) )
|
|
|
|
{
|
|
|
|
pServer->SetUseDefaultCentralServerAddress ( bValue );
|
|
|
|
}
|
|
|
|
|
2011-04-30 15:01:26 +02:00
|
|
|
// server list enabled flag
|
|
|
|
if ( GetFlagIniSet ( IniXMLDocument, "server", "servlistenabled", bValue ) )
|
|
|
|
{
|
|
|
|
pServer->SetServerListEnabled ( bValue );
|
|
|
|
}
|
|
|
|
|
2011-04-25 18:16:31 +02:00
|
|
|
// name
|
|
|
|
pServer->SetServerName ( GetIniSetting ( IniXMLDocument, "server", "name" ) );
|
|
|
|
|
|
|
|
// city
|
2011-04-30 15:01:26 +02:00
|
|
|
pServer->SetServerCity ( GetIniSetting ( IniXMLDocument, "server", "city" ) );
|
2011-04-25 18:16:31 +02:00
|
|
|
|
|
|
|
// country
|
|
|
|
if ( GetNumericIniSet ( IniXMLDocument, "server", "country",
|
|
|
|
0, static_cast<int> ( QLocale::LastCountry ), iValue ) )
|
|
|
|
{
|
|
|
|
pServer->SetServerCountry ( static_cast<QLocale::Country> ( iValue ) );
|
|
|
|
}
|
2011-05-08 17:01:20 +02:00
|
|
|
|
|
|
|
// start minimized on OS start
|
|
|
|
if ( GetFlagIniSet ( IniXMLDocument, "server", "autostartmin", bValue ) )
|
|
|
|
{
|
|
|
|
pServer->SetAutoRunMinimized ( bValue );
|
|
|
|
}
|
2011-04-25 18:16:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-21 18:53:01 +02:00
|
|
|
void CSettings::Save()
|
2011-04-25 18:16:31 +02:00
|
|
|
{
|
2013-02-28 21:54:47 +01:00
|
|
|
int iIdx;
|
|
|
|
|
2011-04-25 18:16:31 +02:00
|
|
|
// create XML document for storing initialization parameters
|
|
|
|
QDomDocument IniXMLDocument;
|
|
|
|
|
|
|
|
|
|
|
|
// Actual settings data ---------------------------------------------------
|
|
|
|
if ( bIsClient )
|
|
|
|
{
|
|
|
|
// client:
|
|
|
|
|
|
|
|
// IP addresses
|
2013-02-28 21:54:47 +01:00
|
|
|
for ( iIdx = 0; iIdx < MAX_NUM_SERVER_ADDR_ITEMS; iIdx++ )
|
2011-04-25 18:16:31 +02:00
|
|
|
{
|
|
|
|
PutIniSetting ( IniXMLDocument, "client",
|
2013-02-28 21:54:47 +01:00
|
|
|
QString ( "ipaddress%1" ).arg ( iIdx ),
|
|
|
|
pClient->vstrIPAddress[iIdx] );
|
|
|
|
}
|
|
|
|
|
|
|
|
// stored fader tags
|
|
|
|
for ( iIdx = 0; iIdx < MAX_NUM_STORED_FADER_LEVELS; iIdx++ )
|
|
|
|
{
|
|
|
|
PutIniSetting ( IniXMLDocument, "client",
|
2013-12-15 11:54:17 +01:00
|
|
|
QString ( "storedfadertag%1_base64" ).arg ( iIdx ),
|
|
|
|
ToBase64 ( pClient->vecStoredFaderTags[iIdx] ) );
|
2013-02-28 21:54:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// stored fader levels
|
|
|
|
for ( iIdx = 0; iIdx < MAX_NUM_STORED_FADER_LEVELS; iIdx++ )
|
|
|
|
{
|
|
|
|
SetNumericIniSet ( IniXMLDocument, "client",
|
|
|
|
QString ( "storedfaderlevel%1" ).arg ( iIdx ),
|
|
|
|
pClient->vecStoredFaderLevels[iIdx] );
|
2011-04-25 18:16:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// name
|
2013-12-15 11:54:17 +01:00
|
|
|
PutIniSetting ( IniXMLDocument, "client", "name_base64",
|
|
|
|
ToBase64 ( pClient->ChannelInfo.strName ) );
|
2013-02-11 16:21:53 +01:00
|
|
|
|
|
|
|
// instrument
|
|
|
|
SetNumericIniSet ( IniXMLDocument, "client", "instrument",
|
|
|
|
pClient->ChannelInfo.iInstrument );
|
2011-04-25 18:16:31 +02:00
|
|
|
|
|
|
|
// 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() );
|
|
|
|
|
2011-05-27 22:29:37 +02:00
|
|
|
// network jitter buffer size for server
|
|
|
|
SetNumericIniSet ( IniXMLDocument, "client", "jitbufserver",
|
|
|
|
pClient->GetServerSockBufNumFrames() );
|
|
|
|
|
2011-04-25 18:16:31 +02:00
|
|
|
// 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() ) );
|
|
|
|
|
2013-08-15 21:15:01 +02:00
|
|
|
// audio quality
|
|
|
|
SetNumericIniSet ( IniXMLDocument, "client", "audioquality",
|
|
|
|
static_cast<int> ( pClient->GetAudioQuality() ) );
|
2011-04-25 18:16:31 +02:00
|
|
|
|
|
|
|
// flag whether stereo mode is used
|
|
|
|
SetFlagIniSet ( IniXMLDocument, "client", "stereoaudio",
|
|
|
|
pClient->GetUseStereo() );
|
2011-05-02 21:48:36 +02:00
|
|
|
|
|
|
|
// central server address
|
|
|
|
PutIniSetting ( IniXMLDocument, "client", "centralservaddr",
|
|
|
|
pClient->GetServerListCentralServerAddress() );
|
|
|
|
|
|
|
|
// use default central server address flag
|
|
|
|
SetFlagIniSet ( IniXMLDocument, "client", "defcentservaddr",
|
|
|
|
pClient->GetUseDefaultCentralServerAddress() );
|
2013-08-26 21:59:18 +02:00
|
|
|
|
|
|
|
// window position of the main window
|
2013-12-15 11:54:17 +01:00
|
|
|
PutIniSetting ( IniXMLDocument, "client", "winposmain_base64",
|
2013-12-14 23:09:59 +01:00
|
|
|
ToBase64 ( pClient->vecWindowPosMain ) );
|
2013-08-26 21:59:18 +02:00
|
|
|
|
|
|
|
// window position of the settings window
|
2013-12-15 11:54:17 +01:00
|
|
|
PutIniSetting ( IniXMLDocument, "client", "winposset_base64",
|
2013-12-14 23:09:59 +01:00
|
|
|
ToBase64 ( pClient->vecWindowPosSettings ) );
|
2013-08-26 21:59:18 +02:00
|
|
|
|
|
|
|
// window position of the chat window
|
2013-12-15 11:54:17 +01:00
|
|
|
PutIniSetting ( IniXMLDocument, "client", "winposchat_base64",
|
2013-12-14 23:09:59 +01:00
|
|
|
ToBase64 ( pClient->vecWindowPosChat ) );
|
2013-08-26 21:59:18 +02:00
|
|
|
|
|
|
|
// window position of the connect window
|
2013-12-15 11:54:17 +01:00
|
|
|
PutIniSetting ( IniXMLDocument, "client", "winposcon_base64",
|
2013-12-14 23:09:59 +01:00
|
|
|
ToBase64 ( pClient->vecWindowPosConnect ) );
|
2013-08-26 21:59:18 +02:00
|
|
|
|
|
|
|
// visibility state of the settings window
|
|
|
|
SetFlagIniSet ( IniXMLDocument, "client", "winvisset",
|
|
|
|
pClient->bWindowWasShownSettings );
|
|
|
|
|
|
|
|
// visibility state of the chat window
|
|
|
|
SetFlagIniSet ( IniXMLDocument, "client", "winvischat",
|
|
|
|
pClient->bWindowWasShownChat );
|
|
|
|
|
|
|
|
// visibility state of the connect window
|
|
|
|
SetFlagIniSet ( IniXMLDocument, "client", "winviscon",
|
|
|
|
pClient->bWindowWasShownConnect );
|
2011-04-25 18:16:31 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// server:
|
|
|
|
|
2011-04-30 15:01:26 +02:00
|
|
|
// central server address
|
|
|
|
PutIniSetting ( IniXMLDocument, "server", "centralservaddr",
|
|
|
|
pServer->GetServerListCentralServerAddress() );
|
|
|
|
|
2011-04-30 21:51:49 +02:00
|
|
|
// use default central server address flag
|
|
|
|
SetFlagIniSet ( IniXMLDocument, "server", "defcentservaddr",
|
|
|
|
pServer->GetUseDefaultCentralServerAddress() );
|
|
|
|
|
2011-04-30 15:01:26 +02:00
|
|
|
// server list enabled flag
|
|
|
|
SetFlagIniSet ( IniXMLDocument, "server", "servlistenabled",
|
|
|
|
pServer->GetServerListEnabled() );
|
|
|
|
|
2011-04-25 18:16:31 +02:00
|
|
|
// name
|
|
|
|
PutIniSetting ( IniXMLDocument, "server", "name",
|
|
|
|
pServer->GetServerName() );
|
|
|
|
|
|
|
|
// city
|
|
|
|
PutIniSetting ( IniXMLDocument, "server", "city",
|
|
|
|
pServer->GetServerCity() );
|
|
|
|
|
|
|
|
// country
|
|
|
|
SetNumericIniSet ( IniXMLDocument, "server", "country",
|
|
|
|
static_cast<int> ( pServer->GetServerCountry() ) );
|
2011-05-08 17:01:20 +02:00
|
|
|
|
|
|
|
// start minimized on OS start
|
|
|
|
SetFlagIniSet ( IniXMLDocument, "server", "autostartmin",
|
|
|
|
pServer->GetAutoRunMinimized() );
|
2011-04-25 18:16:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// prepare file name for storing initialization data in XML file and store
|
|
|
|
// XML data in file
|
2011-05-21 18:53:01 +02:00
|
|
|
QFile file ( strFileName );
|
2011-04-25 18:16:31 +02:00
|
|
|
if ( file.open ( QIODevice::WriteOnly ) )
|
|
|
|
{
|
|
|
|
QTextStream out ( &file );
|
|
|
|
out << IniXMLDocument.toString();
|
2011-05-21 08:11:39 +02:00
|
|
|
|
|
|
|
file.close();
|
2011-04-25 18:16:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Help functions **************************************************************
|
2011-05-21 18:53:01 +02:00
|
|
|
void CSettings::SetFileName ( const QString& sNFiName )
|
2011-04-25 18:16:31 +02:00
|
|
|
{
|
|
|
|
// return the file name with complete path, take care if given file name is
|
|
|
|
// empty
|
2011-05-21 18:53:01 +02:00
|
|
|
strFileName = sNFiName;
|
|
|
|
if ( strFileName.isEmpty() )
|
2011-04-25 18:16:31 +02:00
|
|
|
{
|
|
|
|
// we use the Qt default setting file paths for the different OSs by
|
|
|
|
// utilizing the QSettings class
|
|
|
|
const QSettings TempSettingsObject (
|
|
|
|
QSettings::IniFormat, QSettings::UserScope, APP_NAME, APP_NAME );
|
|
|
|
|
|
|
|
const QString sConfigDir =
|
|
|
|
QFileInfo ( TempSettingsObject.fileName() ).absolutePath();
|
|
|
|
|
|
|
|
// make sure the directory exists
|
|
|
|
if ( !QFile::exists ( sConfigDir ) )
|
|
|
|
{
|
|
|
|
QDir TempDirectoryObject;
|
|
|
|
TempDirectoryObject.mkpath ( sConfigDir );
|
|
|
|
}
|
|
|
|
|
|
|
|
// append the actual file name
|
|
|
|
if ( bIsClient )
|
|
|
|
{
|
2011-05-21 18:53:01 +02:00
|
|
|
strFileName = sConfigDir + "/" + DEFAULT_INI_FILE_NAME;
|
2011-04-25 18:16:31 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-05-21 18:53:01 +02:00
|
|
|
strFileName = sConfigDir + "/" + DEFAULT_INI_FILE_NAME_SERVER;
|
2011-04-25 18:16:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-30 18:04:22 +02:00
|
|
|
void CSettings::SetNumericIniSet ( QDomDocument& xmlFile,
|
|
|
|
const QString& strSection,
|
|
|
|
const QString& strKey,
|
|
|
|
const int iValue )
|
2011-04-25 18:16:31 +02:00
|
|
|
{
|
|
|
|
// convert input parameter which is an integer to string and store
|
|
|
|
PutIniSetting ( xmlFile, strSection, strKey, QString("%1").arg(iValue) );
|
|
|
|
}
|
|
|
|
|
2011-04-30 18:04:22 +02:00
|
|
|
bool CSettings::GetNumericIniSet ( const QDomDocument& xmlFile,
|
|
|
|
const QString& strSection,
|
|
|
|
const QString& strKey,
|
|
|
|
const int iRangeStart,
|
|
|
|
const int iRangeStop,
|
|
|
|
int& iValue )
|
2011-04-25 18:16:31 +02:00
|
|
|
{
|
|
|
|
// init return value
|
|
|
|
bool bReturn = false;
|
|
|
|
|
|
|
|
const QString strGetIni = GetIniSetting ( xmlFile, strSection, strKey );
|
|
|
|
|
|
|
|
// check if it is a valid parameter
|
|
|
|
if ( !strGetIni.isEmpty() )
|
|
|
|
{
|
|
|
|
// convert string from init file to integer
|
|
|
|
iValue = strGetIni.toInt();
|
|
|
|
|
|
|
|
// check range
|
|
|
|
if ( ( iValue >= iRangeStart ) && ( iValue <= iRangeStop ) )
|
|
|
|
{
|
|
|
|
bReturn = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bReturn;
|
|
|
|
}
|
|
|
|
|
2011-04-30 18:04:22 +02:00
|
|
|
void CSettings::SetFlagIniSet ( QDomDocument& xmlFile,
|
|
|
|
const QString& strSection,
|
|
|
|
const QString& strKey,
|
|
|
|
const bool bValue )
|
2011-04-25 18:16:31 +02:00
|
|
|
{
|
|
|
|
// we encode true -> "1" and false -> "0"
|
|
|
|
if ( bValue == true )
|
|
|
|
{
|
|
|
|
PutIniSetting ( xmlFile, strSection, strKey, "1" );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PutIniSetting ( xmlFile, strSection, strKey, "0" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-30 18:04:22 +02:00
|
|
|
bool CSettings::GetFlagIniSet ( const QDomDocument& xmlFile,
|
|
|
|
const QString& strSection,
|
|
|
|
const QString& strKey,
|
|
|
|
bool& bValue )
|
2011-04-25 18:16:31 +02:00
|
|
|
{
|
|
|
|
// init return value
|
|
|
|
bool bReturn = false;
|
|
|
|
|
|
|
|
const QString strGetIni = GetIniSetting ( xmlFile, strSection, strKey );
|
|
|
|
|
|
|
|
if ( !strGetIni.isEmpty() )
|
|
|
|
{
|
|
|
|
if ( strGetIni.toInt() )
|
|
|
|
{
|
|
|
|
bValue = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bValue = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bReturn = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return bReturn;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Init-file routines using XML ***********************************************
|
2011-04-30 18:04:22 +02:00
|
|
|
QString CSettings::GetIniSetting ( const QDomDocument& xmlFile,
|
|
|
|
const QString& sSection,
|
|
|
|
const QString& sKey,
|
|
|
|
const QString& sDefaultVal )
|
2011-04-25 18:16:31 +02:00
|
|
|
{
|
|
|
|
// init return parameter with default value
|
|
|
|
QString sResult ( sDefaultVal );
|
|
|
|
|
|
|
|
// get section
|
|
|
|
QDomElement xmlSection = xmlFile.firstChildElement ( sSection );
|
|
|
|
if ( !xmlSection.isNull() )
|
|
|
|
{
|
|
|
|
// get key
|
|
|
|
QDomElement xmlKey = xmlSection.firstChildElement ( sKey );
|
|
|
|
if ( !xmlKey.isNull() )
|
|
|
|
{
|
|
|
|
// get value
|
|
|
|
sResult = xmlKey.text();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return sResult;
|
|
|
|
}
|
|
|
|
|
2011-04-30 18:04:22 +02:00
|
|
|
void CSettings::PutIniSetting ( QDomDocument& xmlFile,
|
|
|
|
const QString& sSection,
|
|
|
|
const QString& sKey,
|
|
|
|
const QString& sValue )
|
2011-04-25 18:16:31 +02:00
|
|
|
{
|
|
|
|
// check if section is already there, if not then create it
|
|
|
|
QDomElement xmlSection = xmlFile.firstChildElement ( sSection );
|
|
|
|
if ( xmlSection.isNull() )
|
|
|
|
{
|
|
|
|
// create new root element and add to document
|
|
|
|
xmlSection = xmlFile.createElement ( sSection );
|
|
|
|
xmlFile.appendChild ( xmlSection );
|
|
|
|
}
|
|
|
|
|
|
|
|
// check if key is already there, if not then create it
|
|
|
|
QDomElement xmlKey = xmlSection.firstChildElement ( sKey );
|
|
|
|
if ( xmlKey.isNull() )
|
|
|
|
{
|
|
|
|
xmlKey = xmlFile.createElement ( sKey );
|
|
|
|
xmlSection.appendChild ( xmlKey );
|
|
|
|
}
|
|
|
|
|
|
|
|
// add actual data to the key
|
|
|
|
QDomText currentValue = xmlFile.createTextNode ( sValue );
|
|
|
|
xmlKey.appendChild ( currentValue );
|
|
|
|
}
|