added central server setting

This commit is contained in:
Volker Fischer 2011-05-02 19:48:36 +00:00
parent 99432273c8
commit d3b9f90f45
12 changed files with 885 additions and 715 deletions

View file

@ -47,7 +47,9 @@ CClient::CClient ( const quint16 iPortNumber ) :
bFraSiFactDefSupported ( false ),
bFraSiFactSafeSupported ( false ),
bOpenChatOnNewMessage ( true ),
eGUIDesign ( GD_ORIGINAL )
eGUIDesign ( GD_ORIGINAL ),
strCentralServerAddress ( "" ),
bUseDefaultCentralServerAddress ( true )
{
// init audio encoder/decoder (mono)
CeltModeMono = celt_mode_create (

View file

@ -106,6 +106,18 @@ public:
bool GetUseStereo() const { return bUseStereo; }
void SetUseStereo ( const bool bNUseStereo );
void SetServerListCentralServerAddress ( const QString& sNCentServAddr )
{ strCentralServerAddress = sNCentServAddr; }
QString GetServerListCentralServerAddress()
{ return strCentralServerAddress; }
void SetUseDefaultCentralServerAddress ( const bool bNUDCSeAddr )
{ bUseDefaultCentralServerAddress = bNUDCSeAddr; }
bool GetUseDefaultCentralServerAddress()
{ return bUseDefaultCentralServerAddress; }
int GetAudioInFader() const { return iAudioInFader; }
void SetAudioInFader ( const int iNV ) { iAudioInFader = iNV; }
@ -290,6 +302,9 @@ protected:
bool bOpenChatOnNewMessage;
EGUIDesign eGUIDesign;
QString strCentralServerAddress;
bool bUseDefaultCentralServerAddress;
CVector<int16_t> vecsAudioSndCrdMono;
CVector<double> vecdAudioStereo;
CVector<int16_t> vecsNetwork;
@ -323,7 +338,6 @@ signals:
int iPingTime,
int iNumClients );
void Disconnected();
void Stopped();
};
#endif /* !defined ( CLIENT_HOIHGE76GEKJH98_3_43445KJIUHF1912__INCLUDED_ ) */

View file

@ -195,6 +195,23 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
cbUseStereo->setAccessibleName ( tr ( "Stereo check box" ) );
// central server address
QString strCentrServAddr = tr ( "<b>Central Server Address:</b> The "
"Central server address is the IP address or URL of the central server "
"at which the server list of the connection dialog is managed. If the "
"Default check box is checked, the default central server address is "
"shown read-only." );
LabelCentralServerAddress->setWhatsThis ( strCentrServAddr );
cbDefaultCentralServer->setWhatsThis ( strCentrServAddr );
LineEditCentralServerAddress->setWhatsThis ( strCentrServAddr );
cbDefaultCentralServer->setAccessibleName (
tr ( "Default central server check box" ) );
LineEditCentralServerAddress->setAccessibleName (
tr ( "Central server address line edit" ) );
// current connection status parameter
QString strConnStats = tr ( "<b>Current Connection Status "
"Parameter:</b> The ping time is the time required for the audio "
@ -300,6 +317,17 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
cbUseStereo->setCheckState ( Qt::Unchecked );
}
// update default central server address check box
if ( pClient->GetUseDefaultCentralServerAddress() )
{
cbDefaultCentralServer->setCheckState ( Qt::Checked );
}
else
{
cbDefaultCentralServer->setCheckState ( Qt::Unchecked );
}
UpdateCentralServerDependency();
// set text for sound card buffer delay radio buttons
rButBufferDelayPreferred->setText ( GenSndCrdBufferDelayString (
FRAME_SIZE_FACTOR_PREFERRED * SYSTEM_FRAME_SIZE_SAMPLES,
@ -345,6 +373,14 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
QObject::connect ( cbAutoJitBuf, SIGNAL ( stateChanged ( int ) ),
this, SLOT ( OnAutoJitBuf ( int ) ) );
QObject::connect ( cbDefaultCentralServer, SIGNAL ( stateChanged ( int ) ),
this, SLOT ( OnDefaultCentralServerStateChanged ( int ) ) );
// line edits
QObject::connect ( LineEditCentralServerAddress,
SIGNAL ( editingFinished() ),
this, SLOT ( OnLineEditCentralServerAddressEditingFinished() ) );
// combo boxes
QObject::connect ( cbSoundcard, SIGNAL ( activated ( int ) ),
this, SLOT ( OnSoundCrdSelection ( int ) ) );
@ -483,6 +519,33 @@ void CClientSettingsDlg::UpdateSoundChannelSelectionFrame()
#endif
}
void CClientSettingsDlg::UpdateCentralServerDependency()
{
const bool bCurUseDefCentServAddr =
pClient->GetUseDefaultCentralServerAddress();
// If the default central server address is enabled, the line edit shows
// the default server and is not editable. Make sure the line edit does not
// fire signals when we update the text.
LineEditCentralServerAddress->blockSignals ( true );
{
if ( bCurUseDefCentServAddr )
{
LineEditCentralServerAddress->setText ( DEFAULT_SERVER_ADDRESS );
}
else
{
LineEditCentralServerAddress->setText (
pClient->GetServerListCentralServerAddress() );
}
}
LineEditCentralServerAddress->blockSignals ( false );
// the line edit of the central server address is only enabled, if not the
// default address is used
LineEditCentralServerAddress->setEnabled ( !bCurUseDefCentServAddr );
}
void CClientSettingsDlg::OnDriverSetupBut()
{
pClient->OpenSndCrdDriverSetup();
@ -582,6 +645,22 @@ void CClientSettingsDlg::OnUseStereoStateChanged ( int value )
UpdateDisplay(); // upload rate will be changed
}
void CClientSettingsDlg::OnDefaultCentralServerStateChanged ( int value )
{
// apply new setting to the client
pClient->SetUseDefaultCentralServerAddress ( value == Qt::Checked );
// update GUI dependencies
UpdateCentralServerDependency();
}
void CClientSettingsDlg::OnLineEditCentralServerAddressEditingFinished()
{
// store new setting in the client
pClient->SetServerListCentralServerAddress (
LineEditCentralServerAddress->text() );
}
void CClientSettingsDlg::OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton* button )
{
if ( button == rButBufferDelayPreferred )

View file

@ -71,6 +71,7 @@ protected:
void UpdateJitterBufferFrame();
void UpdateSoundCardFrame();
void UpdateSoundChannelSelectionFrame();
void UpdateCentralServerDependency();
QString GenSndCrdBufferDelayString ( const int iFrameSize,
const QString strAddText = "" );
@ -90,6 +91,8 @@ protected:
void OnGUIDesignFancyStateChanged ( int value );
void OnUseHighQualityAudioStateChanged ( int value );
void OnUseStereoStateChanged ( int value );
void OnDefaultCentralServerStateChanged ( int value );
void OnLineEditCentralServerAddressEditingFinished();
void OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton* button );
void OnSoundCrdSelection ( int iSndDevIdx );
void OnSndCrdLeftInChannelSelection ( int iChanIdx );

View file

@ -192,7 +192,7 @@
<item>
<widget class="QComboBox" name="cbSoundcard" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -442,6 +442,34 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QLabel" name="LabelCentralServerAddress" >
<property name="text" >
<string>Central Server Address:</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbDefaultCentralServer" >
<property name="text" >
<string>Default</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLineEdit" name="LineEditCentralServerAddress" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
@ -450,7 +478,7 @@
<property name="sizeHint" >
<size>
<width>201</width>
<height>81</height>
<height>21</height>
</size>
</property>
</spacer>
@ -610,6 +638,25 @@
<header>multicolorled.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>cbAutoJitBuf</tabstop>
<tabstop>SliderNetBuf</tabstop>
<tabstop>cbSoundcard</tabstop>
<tabstop>cbLInChan</tabstop>
<tabstop>cbRInChan</tabstop>
<tabstop>cbLOutChan</tabstop>
<tabstop>cbROutChan</tabstop>
<tabstop>rButBufferDelayPreferred</tabstop>
<tabstop>rButBufferDelayDefault</tabstop>
<tabstop>rButBufferDelaySafe</tabstop>
<tabstop>ButtonDriverSetup</tabstop>
<tabstop>cbOpenChatOnNewMessage</tabstop>
<tabstop>cbGUIDesignFancy</tabstop>
<tabstop>cbUseHighQualityAudio</tabstop>
<tabstop>cbUseStereo</tabstop>
<tabstop>cbDefaultCentralServer</tabstop>
<tabstop>LineEditCentralServerAddress</tabstop>
</tabstops>
<resources>
<include location="resources.qrc" />
</resources>

View file

@ -28,6 +28,7 @@
/* Implementation *************************************************************/
CConnectDlg::CConnectDlg ( QWidget* parent, Qt::WindowFlags f )
: QDialog ( parent, f ),
strCentralServerAddress ( "" ),
strSelectedAddress ( "" ),
bServerListReceived ( false ),
bStateOK ( false ),
@ -93,8 +94,12 @@ CConnectDlg::CConnectDlg ( QWidget* parent, Qt::WindowFlags f )
this, SLOT ( OnTimerReRequestServList() ) );
}
void CConnectDlg::LoadStoredServers ( const CVector<QString>& vstrIPAddresses )
void CConnectDlg::Init ( const QString strNewCentralServerAddr,
const CVector<QString>& vstrIPAddresses )
{
// take central server address string
strCentralServerAddress = strNewCentralServerAddr;
// load stored IP addresses in combo box
LineEditServerAddr->clear();
for ( int iLEIdx = 0; iLEIdx < MAX_NUM_SERVER_ADDR_ITEMS; iLEIdx++ )
@ -120,15 +125,10 @@ void CConnectDlg::showEvent ( QShowEvent* )
// clear server list view
ListViewServers->clear();
// TEST
QString strNAddr = "llcon.dyndns.org:22122";
// get the IP address of the central server (using the ParseNetworAddress
// function) when the connect dialog is opened, this seems to be the correct
// time to do it
if ( LlconNetwUtil().ParseNetworkAddress ( strNAddr,
if ( LlconNetwUtil().ParseNetworkAddress ( strCentralServerAddress,
CentralServerAddress ) )
{
// send the request for the server list

View file

@ -56,11 +56,12 @@ class CConnectDlg : public QDialog, private Ui_CConnectDlgBase
public:
CConnectDlg ( QWidget* parent = 0, Qt::WindowFlags f = 0 );
void Init ( const QString strNewCentralServerAddr,
const CVector<QString>& vstrIPAddresses );
void SetServerList ( const CHostAddress& InetAddr,
const CVector<CServerInfo>& vecServerInfo );
void LoadStoredServers ( const CVector<QString>& vstrNewIPAddresses );
void SetPingTimeAndNumClientsResult ( CHostAddress& InetAddr,
const int iPingTime,
const int iPingTimeLEDColor,
@ -76,6 +77,7 @@ protected:
QTimer TimerPing;
QTimer TimerReRequestServList;
QString strCentralServerAddress;
CHostAddress CentralServerAddress;
CVector<QString> vstrIPAddresses;
QString strSelectedAddress;

View file

@ -24,9 +24,18 @@
<layout class="QVBoxLayout" >
<item>
<widget class="QTreeWidget" name="ListViewServers" >
<property name="editTriggers" >
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="tabKeyNavigation" >
<bool>true</bool>
</property>
<property name="rootIsDecorated" >
<bool>false</bool>
</property>
<property name="itemsExpandable" >
<bool>false</bool>
</property>
<column>
<property name="text" >
<string>Server Name</string>

View file

@ -375,10 +375,6 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP,
SIGNAL ( Disconnected() ),
this, SLOT ( OnDisconnected() ) );
QObject::connect ( pClient,
SIGNAL ( Stopped() ),
this, SLOT ( OnStopped() ) );
QObject::connect ( pClient,
SIGNAL ( ChatTextReceived ( QString ) ),
this, SLOT ( OnChatTextReceived ( QString ) ) );
@ -510,11 +506,6 @@ void CLlconClientDlg::OnConnectDisconBut()
ConnectDisconnect ( !pClient->IsRunning() );
}
void CLlconClientDlg::OnStopped()
{
ConnectDisconnect ( false );
}
void CLlconClientDlg::OnOpenGeneralSettings()
{
// open general settings dialog
@ -734,8 +725,19 @@ void CLlconClientDlg::ConnectDisconnect ( const bool bDoStart )
// start/stop client, set button text
if ( bDoStart )
{
// get the central server address string
QString strCurCentServAddr;
if ( pClient->GetUseDefaultCentralServerAddress() )
{
strCurCentServAddr = DEFAULT_SERVER_ADDRESS;
}
else
{
strCurCentServAddr = pClient->GetServerListCentralServerAddress();
}
// init the connect dialog and execute it (modal dialog)
ConnectDlg.LoadStoredServers ( pClient->vstrIPAddress );
ConnectDlg.Init ( strCurCentServAddr, pClient->vstrIPAddress );
ConnectDlg.exec();
// check if state is OK (e.g., no Cancel was pressed)

View file

@ -155,7 +155,6 @@ public slots:
{ ConnectDlg.SetServerList ( InetAddr, vecServerInfo ); }
void OnDisconnected();
void OnStopped();
void OnGUIDesignChanged()
{ SetGUIDesign ( pClient->GetGUIDesign() ); }

View file

@ -121,10 +121,6 @@ CLlconServerDlg::CLlconServerDlg ( CServer* pNServP,
vecpListViewItems[i]->setHidden ( true );
}
// update central server name line edit
LineEditCentralServerAddress->setText (
pServer->GetServerListCentralServerAddress() );
// update default central server address check box
if ( pServer->GetUseDefaultCentralServerAddress() )
{
@ -349,7 +345,6 @@ void CLlconServerDlg::UpdateGUIDependencies()
// if register server is not enabled, we disable all the configuration
// controls for the server list
cbDefaultCentralServer->setEnabled ( bCurSerListEnabled );
LineEditCentralServerAddress->setEnabled ( bCurSerListEnabled );
GroupBoxServerInfo->setEnabled ( bCurSerListEnabled );
// If the default central server address is enabled, the line edit shows

View file

@ -188,6 +188,16 @@ void CSettings::ReadIniFile ( const QString& sFileName )
{
pClient->SetUseStereo ( bValue );
}
// central server address
pClient->SetServerListCentralServerAddress (
GetIniSetting ( IniXMLDocument, "client", "centralservaddr" ) );
// use default central server address flag
if ( GetFlagIniSet ( IniXMLDocument, "client", "defcentservaddr", bValue ) )
{
pClient->SetUseDefaultCentralServerAddress ( bValue );
}
}
else
{
@ -306,6 +316,14 @@ void CSettings::WriteIniFile ( const QString& sFileName )
// flag whether stereo mode is used
SetFlagIniSet ( IniXMLDocument, "client", "stereoaudio",
pClient->GetUseStereo() );
// central server address
PutIniSetting ( IniXMLDocument, "client", "centralservaddr",
pClient->GetServerListCentralServerAddress() );
// use default central server address flag
SetFlagIniSet ( IniXMLDocument, "client", "defcentservaddr",
pClient->GetUseDefaultCentralServerAddress() );
}
else
{