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 ), bFraSiFactDefSupported ( false ),
bFraSiFactSafeSupported ( false ), bFraSiFactSafeSupported ( false ),
bOpenChatOnNewMessage ( true ), bOpenChatOnNewMessage ( true ),
eGUIDesign ( GD_ORIGINAL ) eGUIDesign ( GD_ORIGINAL ),
strCentralServerAddress ( "" ),
bUseDefaultCentralServerAddress ( true )
{ {
// init audio encoder/decoder (mono) // init audio encoder/decoder (mono)
CeltModeMono = celt_mode_create ( CeltModeMono = celt_mode_create (

View file

@ -106,6 +106,18 @@ public:
bool GetUseStereo() const { return bUseStereo; } bool GetUseStereo() const { return bUseStereo; }
void SetUseStereo ( const bool bNUseStereo ); 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; } int GetAudioInFader() const { return iAudioInFader; }
void SetAudioInFader ( const int iNV ) { iAudioInFader = iNV; } void SetAudioInFader ( const int iNV ) { iAudioInFader = iNV; }
@ -290,6 +302,9 @@ protected:
bool bOpenChatOnNewMessage; bool bOpenChatOnNewMessage;
EGUIDesign eGUIDesign; EGUIDesign eGUIDesign;
QString strCentralServerAddress;
bool bUseDefaultCentralServerAddress;
CVector<int16_t> vecsAudioSndCrdMono; CVector<int16_t> vecsAudioSndCrdMono;
CVector<double> vecdAudioStereo; CVector<double> vecdAudioStereo;
CVector<int16_t> vecsNetwork; CVector<int16_t> vecsNetwork;
@ -323,7 +338,6 @@ signals:
int iPingTime, int iPingTime,
int iNumClients ); int iNumClients );
void Disconnected(); void Disconnected();
void Stopped();
}; };
#endif /* !defined ( CLIENT_HOIHGE76GEKJH98_3_43445KJIUHF1912__INCLUDED_ ) */ #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" ) ); 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 // current connection status parameter
QString strConnStats = tr ( "<b>Current Connection Status " QString strConnStats = tr ( "<b>Current Connection Status "
"Parameter:</b> The ping time is the time required for the audio " "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 ); 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 // set text for sound card buffer delay radio buttons
rButBufferDelayPreferred->setText ( GenSndCrdBufferDelayString ( rButBufferDelayPreferred->setText ( GenSndCrdBufferDelayString (
FRAME_SIZE_FACTOR_PREFERRED * SYSTEM_FRAME_SIZE_SAMPLES, FRAME_SIZE_FACTOR_PREFERRED * SYSTEM_FRAME_SIZE_SAMPLES,
@ -345,6 +373,14 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
QObject::connect ( cbAutoJitBuf, SIGNAL ( stateChanged ( int ) ), QObject::connect ( cbAutoJitBuf, SIGNAL ( stateChanged ( int ) ),
this, SLOT ( OnAutoJitBuf ( 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 // combo boxes
QObject::connect ( cbSoundcard, SIGNAL ( activated ( int ) ), QObject::connect ( cbSoundcard, SIGNAL ( activated ( int ) ),
this, SLOT ( OnSoundCrdSelection ( int ) ) ); this, SLOT ( OnSoundCrdSelection ( int ) ) );
@ -483,6 +519,33 @@ void CClientSettingsDlg::UpdateSoundChannelSelectionFrame()
#endif #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() void CClientSettingsDlg::OnDriverSetupBut()
{ {
pClient->OpenSndCrdDriverSetup(); pClient->OpenSndCrdDriverSetup();
@ -582,6 +645,22 @@ void CClientSettingsDlg::OnUseStereoStateChanged ( int value )
UpdateDisplay(); // upload rate will be changed 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 ) void CClientSettingsDlg::OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton* button )
{ {
if ( button == rButBufferDelayPreferred ) if ( button == rButBufferDelayPreferred )

View file

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

View file

@ -192,7 +192,7 @@
<item> <item>
<widget class="QComboBox" name="cbSoundcard" > <widget class="QComboBox" name="cbSoundcard" >
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" > <sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -442,6 +442,34 @@
</property> </property>
</widget> </widget>
</item> </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> <item>
<spacer> <spacer>
<property name="orientation" > <property name="orientation" >
@ -450,7 +478,7 @@
<property name="sizeHint" > <property name="sizeHint" >
<size> <size>
<width>201</width> <width>201</width>
<height>81</height> <height>21</height>
</size> </size>
</property> </property>
</spacer> </spacer>
@ -610,6 +638,25 @@
<header>multicolorled.h</header> <header>multicolorled.h</header>
</customwidget> </customwidget>
</customwidgets> </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> <resources>
<include location="resources.qrc" /> <include location="resources.qrc" />
</resources> </resources>

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -121,10 +121,6 @@ CLlconServerDlg::CLlconServerDlg ( CServer* pNServP,
vecpListViewItems[i]->setHidden ( true ); vecpListViewItems[i]->setHidden ( true );
} }
// update central server name line edit
LineEditCentralServerAddress->setText (
pServer->GetServerListCentralServerAddress() );
// update default central server address check box // update default central server address check box
if ( pServer->GetUseDefaultCentralServerAddress() ) if ( pServer->GetUseDefaultCentralServerAddress() )
{ {
@ -349,7 +345,6 @@ void CLlconServerDlg::UpdateGUIDependencies()
// if register server is not enabled, we disable all the configuration // if register server is not enabled, we disable all the configuration
// controls for the server list // controls for the server list
cbDefaultCentralServer->setEnabled ( bCurSerListEnabled ); cbDefaultCentralServer->setEnabled ( bCurSerListEnabled );
LineEditCentralServerAddress->setEnabled ( bCurSerListEnabled );
GroupBoxServerInfo->setEnabled ( bCurSerListEnabled ); GroupBoxServerInfo->setEnabled ( bCurSerListEnabled );
// If the default central server address is enabled, the line edit shows // 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 ); 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 else
{ {
@ -306,6 +316,14 @@ void CSettings::WriteIniFile ( const QString& sFileName )
// flag whether stereo mode is used // flag whether stereo mode is used
SetFlagIniSet ( IniXMLDocument, "client", "stereoaudio", SetFlagIniSet ( IniXMLDocument, "client", "stereoaudio",
pClient->GetUseStereo() ); pClient->GetUseStereo() );
// central server address
PutIniSetting ( IniXMLDocument, "client", "centralservaddr",
pClient->GetServerListCentralServerAddress() );
// use default central server address flag
SetFlagIniSet ( IniXMLDocument, "client", "defcentservaddr",
pClient->GetUseDefaultCentralServerAddress() );
} }
else else
{ {