diff --git a/src/client.cpp b/src/client.cpp index 4374bdff..a6e76985 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -347,6 +347,16 @@ int CClient::EvaluatePingMessage ( const int iMs ) return PreciseTime.elapsed() - iMs; } +void CClient::SetCentralServerAddressType ( const ECSAddType eNCSAT ) +{ + if ( eCentralServerAddressType != eNCSAT ) + { + // update type and emit message to update the server list, too + eCentralServerAddressType = eNCSAT; + emit CentralServerAddressTypeChanged(); + } +} + void CClient::SetDoAutoSockBufSize ( const bool bValue ) { // first, set new value in the channel object diff --git a/src/client.h b/src/client.h index 653a9ee7..33fc60b0 100755 --- a/src/client.h +++ b/src/client.h @@ -126,7 +126,7 @@ public: bool IsConnected() { return Channel.IsConnected(); } EGUIDesign GetGUIDesign() const { return eGUIDesign; } - void SetGUIDesign ( const EGUIDesign eNGD ) { eGUIDesign = eNGD; } + void SetGUIDesign ( const EGUIDesign eNGD ) { eGUIDesign = eNGD; } bool GetDisplayChannelLevels() const { return bDisplayChannelLevels; } void SetDisplayChannelLevels ( const bool bNDCL ); @@ -140,13 +140,13 @@ public: void SetServerListCentralServerAddress ( const QString& sNCentServAddr ) { strCentralServerAddress = sNCentServAddr; } QString GetServerListCentralServerAddress() { return strCentralServerAddress; } - void SetCentralServerAddressType ( const ECSAddType eNCSAT ) { eCentralServerAddressType = eNCSAT; } + void SetCentralServerAddressType ( const ECSAddType eNCSAT ); ECSAddType GetCentralServerAddressType() { return eCentralServerAddressType; } - int GetAudioInFader() const { return iAudioInFader; } + int GetAudioInFader() const { return iAudioInFader; } void SetAudioInFader ( const int iNV ) { iAudioInFader = iNV; } - int GetReverbLevel() const { return iReverbLevel; } + int GetReverbLevel() const { return iReverbLevel; } void SetReverbLevel ( const int iNL ) { iReverbLevel = iNL; } bool IsReverbOnLeftChan() const { return bReverbOnLeftChan; } @@ -206,8 +206,7 @@ public: int GetSndCrdRightOutputChannel() { return Sound.GetRightOutputChannel(); } void SetSndCrdPrefFrameSizeFactor ( const int iNewFactor ); - int GetSndCrdPrefFrameSizeFactor() - { return iSndCrdPrefFrameSizeFactor; } + int GetSndCrdPrefFrameSizeFactor() { return iSndCrdPrefFrameSizeFactor; } int GetSndCrdActualMonoBlSize() { @@ -429,4 +428,5 @@ signals: void Disconnected(); void ControllerInFaderLevel ( int iChannelIdx, int iValue ); + void CentralServerAddressTypeChanged(); }; diff --git a/src/clientdlg.cpp b/src/clientdlg.cpp index 1d49ee49..1a11fd14 100755 --- a/src/clientdlg.cpp +++ b/src/clientdlg.cpp @@ -454,6 +454,10 @@ CClientDlg::CClientDlg ( CClient* pNCliP, SIGNAL ( Disconnected() ), this, SLOT ( OnDisconnected() ) ); + QObject::connect ( pClient, + SIGNAL ( CentralServerAddressTypeChanged() ), + this, SLOT ( OnCentralServerAddressTypeChanged() ) ); + QObject::connect ( pClient, SIGNAL ( ChatTextReceived ( QString ) ), this, SLOT ( OnChatTextReceived ( QString ) ) ); @@ -725,6 +729,18 @@ void CClientDlg::OnDisconnected() UpdateDisplay(); } +void CClientDlg::OnCentralServerAddressTypeChanged() +{ + // if the server list is shown and the server type was changed, update the list + if ( ConnectDlg.isVisible() ) + { + ConnectDlg.SetCentralServerAddress ( NetworkUtil::GetCentralServerAddress ( pClient->GetCentralServerAddressType(), + pClient->GetServerListCentralServerAddress() ) ); + + ConnectDlg.RequestServerList(); + } +} + void CClientDlg::OnChatTextReceived ( QString strChatText ) { ChatDlg.AddChatText ( strChatText ); @@ -814,13 +830,10 @@ void CClientDlg::SetMyWindowTitle ( const int iNumClients ) void CClientDlg::ShowConnectionSetupDialog() { - // get the central server address string - const QString strCurCentServAddr = - NetworkUtil::GetCentralServerAddress ( pClient->GetCentralServerAddressType(), - pClient->GetServerListCentralServerAddress() ); - // init the connect dialog - ConnectDlg.Init ( strCurCentServAddr, pClient->vstrIPAddress ); + ConnectDlg.Init ( pClient->vstrIPAddress ); + ConnectDlg.SetCentralServerAddress ( NetworkUtil::GetCentralServerAddress ( pClient->GetCentralServerAddressType(), + pClient->GetServerListCentralServerAddress() ) ); // show connect dialog ConnectDlg.show(); diff --git a/src/clientdlg.h b/src/clientdlg.h index 79549c8d..9c7cfdba 100755 --- a/src/clientdlg.h +++ b/src/clientdlg.h @@ -198,6 +198,7 @@ public slots: void OnConnectDlgAccepted(); void OnDisconnected(); + void OnCentralServerAddressTypeChanged(); void OnGUIDesignChanged() { SetGUIDesign ( pClient->GetGUIDesign() ); } diff --git a/src/connectdlg.cpp b/src/connectdlg.cpp index e7a480cd..6c773421 100755 --- a/src/connectdlg.cpp +++ b/src/connectdlg.cpp @@ -154,12 +154,8 @@ CConnectDlg::CConnectDlg ( const bool bNewShowCompleteRegList, this, SLOT ( OnTimerReRequestServList() ) ); } -void CConnectDlg::Init ( const QString strNewCentralServerAddr, - const CVector& vstrIPAddresses ) +void CConnectDlg::Init ( const CVector& vstrIPAddresses ) { - // take central server address string - strCentralServerAddress = strNewCentralServerAddr; - // load stored IP addresses in combo box cbxServerAddr->clear(); cbxServerAddr->clearEditText(); @@ -175,8 +171,14 @@ void CConnectDlg::Init ( const QString strNewCentralServerAddr, void CConnectDlg::showEvent ( QShowEvent* ) { - // reset flags (on opening the connect dialg, we always want to request a - // new updated server list per definition) + // on opening the connect dialg, we always want to request a + // new updated server list per definition + RequestServerList(); +} + +void CConnectDlg::RequestServerList() +{ + // reset flags bServerListReceived = false; bServerListItemWasChosen = false; @@ -215,6 +217,8 @@ void CConnectDlg::OnTimerReRequestServList() // server list if ( !bServerListReceived ) { + // note that this is a connection less message which may get lost + // and therefore it makes sense to re-transmit it emit ReqServerListQuery ( CentralServerAddress ); } } diff --git a/src/connectdlg.h b/src/connectdlg.h index ae9aee55..8ed6b677 100755 --- a/src/connectdlg.h +++ b/src/connectdlg.h @@ -51,8 +51,8 @@ public: QWidget* parent = nullptr, Qt::WindowFlags f = nullptr ); - void Init ( const QString strNewCentralServerAddr, - const CVector& vstrIPAddresses ); + void Init ( const CVector& vstrIPAddresses ); + void SetCentralServerAddress ( const QString strNewCentralServerAddr ) { strCentralServerAddress = strNewCentralServerAddr; } void SetServerList ( const CHostAddress& InetAddr, const CVector& vecServerInfo ); @@ -71,9 +71,10 @@ public: QString strVersion ); #endif - bool GetServerListItemWasChosen() const { return bServerListItemWasChosen; } + bool GetServerListItemWasChosen() const { return bServerListItemWasChosen; } QString GetSelectedAddress() const { return strSelectedAddress; } QString GetSelectedServerName() const { return strSelectedServerName; } + void RequestServerList(); protected: virtual void showEvent ( QShowEvent* ); @@ -83,16 +84,15 @@ protected: QTreeWidgetItem* GetParentListViewItem ( QTreeWidgetItem* pItem ); void DeleteAllListViewItemChilds ( QTreeWidgetItem* pItem ); - QTimer TimerPing; - QTimer TimerReRequestServList; - QString strCentralServerAddress; - CHostAddress CentralServerAddress; - CVector vstrIPAddresses; - QString strSelectedAddress; - QString strSelectedServerName; - bool bShowCompleteRegList; - bool bServerListReceived; - bool bServerListItemWasChosen; + QTimer TimerPing; + QTimer TimerReRequestServList; + QString strCentralServerAddress; + CHostAddress CentralServerAddress; + QString strSelectedAddress; + QString strSelectedServerName; + bool bShowCompleteRegList; + bool bServerListReceived; + bool bServerListItemWasChosen; public slots: void OnServerListItemSelectionChanged();