diff --git a/src/chatdlg.cpp b/src/chatdlg.cpp index a6d88cef..2982916c 100755 --- a/src/chatdlg.cpp +++ b/src/chatdlg.cpp @@ -31,7 +31,8 @@ CChatDlg::CChatDlg ( QWidget* parent, Qt::WindowFlags f ) : { setupUi ( this ); - // add help text to controls ----------------------------------------------- + + // Add help text to controls ----------------------------------------------- lineEditLocalInputText->setAccessibleName ( "New chat text edit box" ); TextViewChatWindow->setAccessibleName ( "Chat history" ); diff --git a/src/clientsettingsdlg.cpp b/src/clientsettingsdlg.cpp index e475942d..dee65ddf 100755 --- a/src/clientsettingsdlg.cpp +++ b/src/clientsettingsdlg.cpp @@ -31,6 +31,7 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent, { setupUi ( this ); + // Add help text to controls ----------------------------------------------- // jitter buffer QString strJitterBufferSize = tr ( "Jitter Buffer Size: The jitter " diff --git a/src/global.h b/src/global.h index 2240449b..6d820ca2 100755 --- a/src/global.h +++ b/src/global.h @@ -60,7 +60,7 @@ #define LLCON_DOWNLOAD_URL "http://sourceforge.net/projects/llcon/files" // defined port number for client and server -#define LLCON_DEFAULT_PORT_NUMBER 22124 +#define LLCON_DEFAULT_PORT_NUMBER 22122 // system sample rate (the sound card and audio coder works on this sample rate) #define SYSTEM_SAMPLE_RATE_HZ 48000 // Hz diff --git a/src/llconclientdlg.cpp b/src/llconclientdlg.cpp index ea001e29..04eeec05 100755 --- a/src/llconclientdlg.cpp +++ b/src/llconclientdlg.cpp @@ -55,6 +55,7 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, { setupUi ( this ); + // Add help text to controls ----------------------------------------------- // input level meter QString strInpLevH = tr ( "Input Level Meter: The input level " diff --git a/src/llconserverdlg.cpp b/src/llconserverdlg.cpp index 025991ec..840bcea3 100755 --- a/src/llconserverdlg.cpp +++ b/src/llconserverdlg.cpp @@ -31,6 +31,75 @@ CLlconServerDlg::CLlconServerDlg ( CServer* pNServP, QWidget* parent ) { setupUi ( this ); + + // Add help text to controls ----------------------------------------------- + // client list + ListViewClients->setWhatsThis ( tr ( "Client List: The client list " + "shows all clients which are currently connected to this server. Some " + "informations about the clients like the IP address, name, buffer " + "state are given for each connected client." ) ); + + ListViewClients->setAccessibleName ( tr ( "Connected clients list view" ) ); + + // register server flag + cbRegisterServer->setWhatsThis ( tr ( "Register Server Status: If " + "the register server check box is checked, this server registers " + "itself at the central server so that all " ) + APP_NAME + + tr ( " users can see the server in the connect dialog server list and " + "connect to it. The registering of the server is renewed periodically " + "to make sure that all servers in the connect dialog server list are " + "actually available." ) ); + + // central server address + QString strCentrServAddr = tr ( "Central Server Address: The " + "Central server address is the IP address or URL of the central server " + "at which this server is registered. 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" ) ); + + // server name + QString strServName = tr ( "Server Name: The server name identifies " + "your server in the connect dialog server list at the clients. If no " + "name is given, the IP address is shown instead." ); + + LabelServerName->setWhatsThis ( strServName ); + LineEditServerName->setWhatsThis ( strServName ); + + LineEditServerName->setAccessibleName ( tr ( "Server name line edit" ) ); + + // location city + QString strLocCity = tr ( "Location City: The city in which this " + "server is located can be set here. If a city name is entered, it " + "will be shown in the connect dialog server list at the clients." ); + + LabelLocationCity->setWhatsThis ( strLocCity ); + LineEditLocationCity->setWhatsThis ( strLocCity ); + + LineEditLocationCity->setAccessibleName ( tr ( + "City where the server is located line edit" ) ); + + // location country + QString strLocCountry = tr ( "Location country: The country in " + "which this server is located can be set here. If a country is " + "entered, it will be shown in the connect dialog server list at the " + "clients." ); + + LabelLocationCountry->setWhatsThis ( strLocCountry ); + ComboBoxLocationCountry->setWhatsThis ( strLocCountry ); + + ComboBoxLocationCountry->setAccessibleName ( tr ( + "Country where the server is located combo box" ) ); + + // set text for version and application name TextLabelNameVersion->setText ( QString ( APP_NAME ) + tr ( " server " ) + QString ( VERSION ) ); @@ -54,6 +123,16 @@ CLlconServerDlg::CLlconServerDlg ( CServer* pNServP, QWidget* parent ) LineEditCentralServerAddress->setText ( pServer->GetServerListCentralServerAddress() ); + // update default central server address check box + if ( pServer->GetUseDefaultCentralServerAddress() ) + { + cbDefaultCentralServer->setCheckState ( Qt::Checked ); + } + else + { + cbDefaultCentralServer->setCheckState ( Qt::Unchecked ); + } + // update server name line edit LineEditServerName->setText ( pServer->GetServerName() ); @@ -86,9 +165,7 @@ CLlconServerDlg::CLlconServerDlg ( CServer* pNServP, QWidget* parent ) static_cast ( pServer->GetServerCountry() ) ) ); // update register server check box - const bool bCurSerListEnabled = pServer->GetServerListEnabled(); - - if ( bCurSerListEnabled ) + if ( pServer->GetServerListEnabled() ) { cbRegisterServer->setCheckState ( Qt::Checked ); } @@ -97,8 +174,8 @@ CLlconServerDlg::CLlconServerDlg ( CServer* pNServP, QWidget* parent ) cbRegisterServer->setCheckState ( Qt::Unchecked ); } - // update GUI dependency - UpdateServerInfosDependency ( bCurSerListEnabled ); + // update GUI dependencies + UpdateGUIDependencies(); // Main menu bar ----------------------------------------------------------- @@ -114,10 +191,13 @@ CLlconServerDlg::CLlconServerDlg ( CServer* pNServP, QWidget* parent ) QObject::connect ( cbRegisterServer, SIGNAL ( stateChanged ( int ) ), this, SLOT ( OnRegisterServerStateChanged ( int ) ) ); + QObject::connect ( cbDefaultCentralServer, SIGNAL ( stateChanged ( int ) ), + this, SLOT ( OnDefaultCentralServerStateChanged ( int ) ) ); + // line edits QObject::connect ( LineEditCentralServerAddress, - SIGNAL ( textChanged ( const QString& ) ), - this, SLOT ( OnLineEditCentralServerAddressTextChanged ( const QString& ) ) ); + SIGNAL ( editingFinished() ), + this, SLOT ( OnLineEditCentralServerAddressEditingFinished() ) ); QObject::connect ( LineEditServerName, SIGNAL ( textChanged ( const QString& ) ), this, SLOT ( OnLineEditServerNameTextChanged ( const QString& ) ) ); @@ -138,58 +218,64 @@ CLlconServerDlg::CLlconServerDlg ( CServer* pNServP, QWidget* parent ) Timer.start ( GUI_CONTRL_UPDATE_TIME ); } -void CLlconServerDlg::OnRegisterServerStateChanged ( int value ) +void CLlconServerDlg::OnDefaultCentralServerStateChanged ( int value ) { - const bool bEnabled = ( value == Qt::Checked ); - - // update GUI dependency - UpdateServerInfosDependency ( bEnabled ); - // apply new setting to the server and update it - pServer->SetServerListEnabled ( bEnabled ); + pServer->SetUseDefaultCentralServerAddress ( value == Qt::Checked ); pServer->UpdateServerList(); + + // update GUI dependencies + UpdateGUIDependencies(); } -void CLlconServerDlg::OnLineEditCentralServerAddressTextChanged ( const QString& strNewAddr ) +void CLlconServerDlg::OnRegisterServerStateChanged ( int value ) { // apply new setting to the server and update it - pServer->SetServerListCentralServerAddress ( strNewAddr ); + pServer->SetServerListEnabled ( value == Qt::Checked ); + pServer->UpdateServerList(); -// TODO -// only apply this in case the focus is lost and the name has actually changed! -pServer->UpdateServerList(); + // update GUI dependencies + UpdateGUIDependencies(); +} +void CLlconServerDlg::OnLineEditCentralServerAddressEditingFinished() +{ + // apply new setting to the server and update it + pServer->SetServerListCentralServerAddress ( + LineEditCentralServerAddress->text() ); + + pServer->UpdateServerList(); } void CLlconServerDlg::OnLineEditServerNameTextChanged ( const QString& strNewName ) { - // check length - if ( strNewName.length() <= MAX_LEN_SERVER_NAME ) - { + // check length + if ( strNewName.length() <= MAX_LEN_SERVER_NAME ) + { // apply new setting to the server and update it pServer->SetServerName ( strNewName ); pServer->UpdateServerList(); - } - else - { - // text is too long, update control with shortend text - LineEditServerName->setText ( strNewName.left ( MAX_LEN_SERVER_NAME ) ); + } + else + { + // text is too long, update control with shortend text + LineEditServerName->setText ( strNewName.left ( MAX_LEN_SERVER_NAME ) ); } } void CLlconServerDlg::OnLineEditLocationCityTextChanged ( const QString& strNewCity ) { - // check length - if ( strNewCity.length() <= MAX_LEN_SERVER_CITY ) - { + // check length + if ( strNewCity.length() <= MAX_LEN_SERVER_CITY ) + { // apply new setting to the server and update it pServer->SetServerCity ( strNewCity ); pServer->UpdateServerList(); - } - else - { - // text is too long, update control with shortend text - LineEditLocationCity->setText ( strNewCity.left ( MAX_LEN_SERVER_CITY ) ); + } + else + { + // text is too long, update control with shortend text + LineEditLocationCity->setText ( strNewCity.left ( MAX_LEN_SERVER_CITY ) ); } } @@ -250,14 +336,41 @@ void CLlconServerDlg::OnTimer() ListViewMutex.unlock(); } -void CLlconServerDlg::UpdateServerInfosDependency ( const bool bState ) +void CLlconServerDlg::UpdateGUIDependencies() { + // get the states which define the GUI dependencies from the server + const bool bCurSerListEnabled = pServer->GetServerListEnabled(); + + const bool bCurUseDefCentServAddr = + pServer->GetUseDefaultCentralServerAddress(); + // if register server is not enabled, we disable all the configuration // controls for the server list - LabelCentralServerAddress->setEnabled ( bState ); - cbDefaultCentralServer->setEnabled ( bState ); - LineEditCentralServerAddress->setEnabled ( bState ); - GroupBoxServerInfo->setEnabled ( bState ); + cbDefaultCentralServer->setEnabled ( bCurSerListEnabled ); + LineEditCentralServerAddress->setEnabled ( bCurSerListEnabled ); + GroupBoxServerInfo->setEnabled ( bCurSerListEnabled ); + + // 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 ( + pServer->GetServerListCentralServerAddress() ); + } + } + LineEditCentralServerAddress->blockSignals ( false ); + + // the line edit of the central server address is only enabled, if the + // server list is enabled and not the default address is used + LineEditCentralServerAddress->setEnabled ( + !bCurUseDefCentServAddr && bCurSerListEnabled ); } void CLlconServerDlg::customEvent ( QEvent* Event ) diff --git a/src/llconserverdlg.h b/src/llconserverdlg.h index 55113b13..36aba428 100755 --- a/src/llconserverdlg.h +++ b/src/llconserverdlg.h @@ -67,12 +67,12 @@ protected: QMenuBar* pMenu; virtual void customEvent ( QEvent* Event ); - void UpdateServerInfosDependency ( const bool bState ); - + void UpdateGUIDependencies(); public slots: void OnRegisterServerStateChanged ( int value ); - void OnLineEditCentralServerAddressTextChanged ( const QString& strNewAddr ); + void OnDefaultCentralServerStateChanged ( int value ); + void OnLineEditCentralServerAddressEditingFinished(); void OnLineEditServerNameTextChanged ( const QString& strNewName ); void OnLineEditLocationCityTextChanged ( const QString& strNewCity ); void OnComboBoxLocationCountryActivated ( int iCntryListItem ); diff --git a/src/llconserverdlgbase.ui b/src/llconserverdlgbase.ui index 8b0cbc45..93cdf385 100755 --- a/src/llconserverdlgbase.ui +++ b/src/llconserverdlgbase.ui @@ -6,7 +6,7 @@ 0 0 588 - 438 + 378 @@ -67,6 +67,9 @@ + + + @@ -74,9 +77,6 @@ - - - diff --git a/src/main.cpp b/src/main.cpp index e5e6daaf..b1ded77d 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -349,6 +349,11 @@ int main ( int argc, char** argv ) if ( bUseGUI ) { + // special case for the GUI mode: as the default we want to use + // the default central server address (if not given in the + // settings file) + Server.SetUseDefaultCentralServerAddress ( true ); + // load settings from init-file CSettings Settings ( &Server ); Settings.Load ( strIniFileName ); diff --git a/src/server.h b/src/server.h index 67681671..ac333d87 100755 --- a/src/server.h +++ b/src/server.h @@ -141,6 +141,12 @@ public: QString GetServerListCentralServerAddress() { return ServerListManager.GetCentralServerAddress(); } + void SetUseDefaultCentralServerAddress ( const bool bNUDCSeAddr ) + { ServerListManager.SetUseDefaultCentralServerAddress ( bNUDCSeAddr ); } + + bool GetUseDefaultCentralServerAddress() + { return ServerListManager.GetUseDefaultCentralServerAddress(); } + void SetServerName ( const QString& strNewName ) { ServerListManager.SetServerName ( strNewName ); } diff --git a/src/serverlist.cpp b/src/serverlist.cpp index 4c4d1a91..a72e1ad1 100755 --- a/src/serverlist.cpp +++ b/src/serverlist.cpp @@ -29,7 +29,8 @@ CServerListManager::CServerListManager ( const QString& sNCentServAddr, const QString& strServerInfo, CProtocol* pNConLProt ) - : pConnLessProtocol ( pNConLProt ) + : bUseDefaultCentralServerAddress ( false ), + pConnLessProtocol ( pNConLProt ) { // set the central server address SetCentralServerAddress ( sNCentServAddr ); @@ -294,6 +295,17 @@ void CServerListManager::OnTimerRegistering() if ( !bIsCentralServer && bEnabled ) { + // get the correct central server address + QString strCurCentrServAddr; + if ( bUseDefaultCentralServerAddress ) + { + strCurCentrServAddr = DEFAULT_SERVER_ADDRESS; + } + else + { + strCurCentrServAddr = strCentralServerAddress; + } + // For the slave server, the slave server properties are store in the // very first item in the server list (which is actually no server list // but just one item long for the slave server). @@ -301,7 +313,7 @@ void CServerListManager::OnTimerRegistering() // it is an URL of a dynamic IP address, the IP address might have // changed in the meanwhile. CHostAddress HostAddress; - if ( LlconNetwUtil().ParseNetworkAddress ( strCentralServerAddress, + if ( LlconNetwUtil().ParseNetworkAddress ( strCurCentrServAddr, HostAddress ) ) { pConnLessProtocol->CreateCLRegisterServerMes ( HostAddress, diff --git a/src/serverlist.h b/src/serverlist.h index 6c12afea..7a9e5923 100755 --- a/src/serverlist.h +++ b/src/serverlist.h @@ -135,6 +135,12 @@ public: void SetCentralServerAddress ( const QString sNCentServAddr ); QString GetCentralServerAddress() { return strCentralServerAddress; } + void SetUseDefaultCentralServerAddress ( const bool bNUDCSeAddr ) + { bUseDefaultCentralServerAddress = bNUDCSeAddr; } + + bool GetUseDefaultCentralServerAddress() + { return bUseDefaultCentralServerAddress; } + bool GetIsCentralServer() const { return bIsCentralServer; } void RegisterServer ( const CHostAddress& InetAddr, @@ -169,6 +175,7 @@ protected: QString strCentralServerAddress; bool bEnabled; bool bIsCentralServer; + bool bUseDefaultCentralServerAddress; CProtocol* pConnLessProtocol; diff --git a/src/settings.cpp b/src/settings.cpp index cff2fb08..6f0fdaef 100755 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -197,6 +197,12 @@ void CSettings::ReadIniFile ( const QString& sFileName ) pServer->SetServerListCentralServerAddress ( GetIniSetting ( IniXMLDocument, "server", "centralservaddr" ) ); + // use default central server address flag + if ( GetFlagIniSet ( IniXMLDocument, "server", "defcentservaddr", bValue ) ) + { + pServer->SetUseDefaultCentralServerAddress ( bValue ); + } + // server list enabled flag if ( GetFlagIniSet ( IniXMLDocument, "server", "servlistenabled", bValue ) ) { @@ -309,6 +315,10 @@ void CSettings::WriteIniFile ( const QString& sFileName ) PutIniSetting ( IniXMLDocument, "server", "centralservaddr", pServer->GetServerListCentralServerAddress() ); + // use default central server address flag + SetFlagIniSet ( IniXMLDocument, "server", "defcentservaddr", + pServer->GetUseDefaultCentralServerAddress() ); + // server list enabled flag SetFlagIniSet ( IniXMLDocument, "server", "servlistenabled", pServer->GetServerListEnabled() );