Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change "Central Server" to "Directory Server" in variables and settings #2079

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/clientdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,10 +510,7 @@ CClientDlg::CClientDlg ( CClient* pNCliP,

QObject::connect ( &ClientSettingsDlg, &CClientSettingsDlg::AudioChannelsChanged, this, &CClientDlg::OnAudioChannelsChanged );

QObject::connect ( &ClientSettingsDlg,
&CClientSettingsDlg::CustomCentralServerAddrChanged,
&ConnectDlg,
&CConnectDlg::OnCustomCentralServerAddrChanged );
QObject::connect ( &ClientSettingsDlg, &CClientSettingsDlg::DirectoryAddressChanged, &ConnectDlg, &CConnectDlg::OnCustomDirectoryAddressChanged );

QObject::connect ( &ClientSettingsDlg, &CClientSettingsDlg::NumMixerPanelRowsChanged, this, &CClientDlg::OnNumMixerPanelRowsChanged );

Expand Down
49 changes: 23 additions & 26 deletions src/clientsettingsdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,13 +353,13 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, CClientSettings* pNSet
cbxInputBoost->setAccessibleName ( tr ( "Input Boost combo box" ) );

// custom directory server address
QString strCentrServAddr = "<b>" + tr ( "Custom Directory Server Address" ) + ":</b> " +
tr ( "Leave this blank unless you need to enter the address of a directory "
"server other than the default." );
QString strCustomDirectoryAddress = "<b>" + tr ( "Custom Directory Server Address" ) + ":</b> " +
tr ( "Leave this blank unless you need to enter the address of a directory "
"server other than the default." );

lblCentralServerAddress->setWhatsThis ( strCentrServAddr );
cbxCentralServerAddress->setWhatsThis ( strCentrServAddr );
cbxCentralServerAddress->setAccessibleName ( tr ( "Directory server address combo box" ) );
lblDirectoryAddress->setWhatsThis ( strCustomDirectoryAddress );
cbxDirectoryAddress->setWhatsThis ( strCustomDirectoryAddress );
cbxDirectoryAddress->setAccessibleName ( tr ( "Directory server address combo box" ) );

// current connection status parameter
QString strConnStats = "<b>" + tr ( "Audio Upstream Rate" ) + ":</b> " +
Expand Down Expand Up @@ -445,8 +445,8 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, CClientSettings* pNSet
cbxLanguage->Init ( pSettings->strLanguage );

// init custom directory server address combo box (max MAX_NUM_SERVER_ADDR_ITEMS entries)
cbxCentralServerAddress->setMaxCount ( MAX_NUM_SERVER_ADDR_ITEMS );
cbxCentralServerAddress->setInsertPolicy ( QComboBox::NoInsert );
cbxDirectoryAddress->setMaxCount ( MAX_NUM_SERVER_ADDR_ITEMS );
cbxDirectoryAddress->setInsertPolicy ( QComboBox::NoInsert );

// update new client fader level edit box
edtNewClientLevel->setText ( QString::number ( pSettings->iNewClientFaderLevel ) );
Expand Down Expand Up @@ -667,15 +667,12 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, CClientSettings* pNSet
this,
&CClientSettingsDlg::OnMeterStyleActivated );

QObject::connect ( cbxCentralServerAddress->lineEdit(),
&QLineEdit::editingFinished,
this,
&CClientSettingsDlg::OnCentralServerAddressEditingFinished );
QObject::connect ( cbxDirectoryAddress->lineEdit(), &QLineEdit::editingFinished, this, &CClientSettingsDlg::OnDirectoryAddressEditingFinished );

QObject::connect ( cbxCentralServerAddress,
QObject::connect ( cbxDirectoryAddress,
static_cast<void ( QComboBox::* ) ( int )> ( &QComboBox::activated ),
this,
&CClientSettingsDlg::OnCentralServerAddressEditingFinished );
&CClientSettingsDlg::OnDirectoryAddressEditingFinished );

QObject::connect ( cbxLanguage, &CLanguageComboBox::LanguageChanged, this, &CClientSettingsDlg::OnLanguageChanged );

Expand Down Expand Up @@ -731,7 +728,7 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, CClientSettings* pNSet
void CClientSettingsDlg::showEvent ( QShowEvent* )
{
UpdateDisplay();
UpdateCustomCentralServerComboBox();
UpdateDirectoryServerComboBox();

// set the name
pedtAlias->setText ( pClient->ChannelInfo.strName );
Expand Down Expand Up @@ -981,24 +978,24 @@ void CClientSettingsDlg::OnEnableOPUS64StateChanged ( int value )

void CClientSettingsDlg::OnFeedbackDetectionChanged ( int value ) { pSettings->bEnableFeedbackDetection = value == Qt::Checked; }

void CClientSettingsDlg::OnCentralServerAddressEditingFinished()
void CClientSettingsDlg::OnDirectoryAddressEditingFinished()
{
// if the user has selected and deleted an entry in the combo box list,
// we delete the corresponding entry in the directory server address vector
if ( cbxCentralServerAddress->currentText().isEmpty() && cbxCentralServerAddress->currentData().isValid() )
if ( cbxDirectoryAddress->currentText().isEmpty() && cbxDirectoryAddress->currentData().isValid() )
{
pSettings->vstrCentralServerAddress[cbxCentralServerAddress->currentData().toInt()] = "";
pSettings->vstrDirectoryAddress[cbxDirectoryAddress->currentData().toInt()] = "";
}
else
{
// store new address at the top of the list, if the list was already
// full, the last element is thrown out
pSettings->vstrCentralServerAddress.StringFiFoWithCompare ( NetworkUtil::FixAddress ( cbxCentralServerAddress->currentText() ) );
pSettings->vstrDirectoryAddress.StringFiFoWithCompare ( NetworkUtil::FixAddress ( cbxDirectoryAddress->currentText() ) );
}

// update combo box list and inform connect dialog about the new address
UpdateCustomCentralServerComboBox();
emit CustomCentralServerAddrChanged();
UpdateDirectoryServerComboBox();
emit DirectoryAddressChanged();
}

void CClientSettingsDlg::OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton* button )
Expand Down Expand Up @@ -1042,17 +1039,17 @@ void CClientSettingsDlg::UpdateDisplay()
}
}

void CClientSettingsDlg::UpdateCustomCentralServerComboBox()
void CClientSettingsDlg::UpdateDirectoryServerComboBox()
{
cbxCentralServerAddress->clear();
cbxCentralServerAddress->clearEditText();
cbxDirectoryAddress->clear();
cbxDirectoryAddress->clearEditText();

for ( int iLEIdx = 0; iLEIdx < MAX_NUM_SERVER_ADDR_ITEMS; iLEIdx++ )
{
if ( !pSettings->vstrCentralServerAddress[iLEIdx].isEmpty() )
if ( !pSettings->vstrDirectoryAddress[iLEIdx].isEmpty() )
{
// store the index as user data to the combo box item, too
cbxCentralServerAddress->addItem ( pSettings->vstrCentralServerAddress[iLEIdx], iLEIdx );
cbxDirectoryAddress->addItem ( pSettings->vstrDirectoryAddress[iLEIdx], iLEIdx );
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/clientsettingsdlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class CClientSettingsDlg : public CBaseDlg, private Ui_CClientSettingsDlgBase
protected:
void UpdateJitterBufferFrame();
void UpdateSoundCardFrame();
void UpdateCustomCentralServerComboBox();
void UpdateDirectoryServerComboBox();
void UpdateAudioFaderSlider();
QString GenSndCrdBufferDelayString ( const int iFrameSize, const QString strAddText = "" );

Expand All @@ -83,7 +83,7 @@ public slots:
void OnAutoJitBufStateChanged ( int value );
void OnEnableOPUS64StateChanged ( int value );
void OnFeedbackDetectionChanged ( int value );
void OnCentralServerAddressEditingFinished();
void OnDirectoryAddressEditingFinished();
void OnNewClientLevelEditingFinished() { pSettings->iNewClientFaderLevel = edtNewClientLevel->text().toInt(); }
void OnInputBoostChanged();
void OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton* button );
Expand Down Expand Up @@ -111,6 +111,6 @@ public slots:
void GUIDesignChanged();
void MeterStyleChanged();
void AudioChannelsChanged();
void CustomCentralServerAddrChanged();
void DirectoryAddressChanged();
void NumMixerPanelRowsChanged ( int value );
};
6 changes: 3 additions & 3 deletions src/clientsettingsdlgbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -967,14 +967,14 @@
</spacer>
</item>
<item>
<widget class="QLabel" name="lblCentralServerAddress">
<widget class="QLabel" name="lblDirectoryAddress">
<property name="text">
<string>Custom Directories:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cbxCentralServerAddress">
<widget class="QComboBox" name="cbxDirectoryAddress">
<property name="editable">
<bool>true</bool>
</property>
Expand Down Expand Up @@ -1298,7 +1298,7 @@
<tabstop>sldNetBuf</tabstop>
<tabstop>sldNetBufServer</tabstop>
<tabstop>chbEnableOPUS64</tabstop>
<tabstop>cbxCentralServerAddress</tabstop>
<tabstop>cbxDirectoryAddress</tabstop>
<tabstop>edtNewClientLevel</tabstop>
<tabstop>cbxInputBoost</tabstop>
<tabstop>chbDetectFeedback</tabstop>
Expand Down
67 changes: 33 additions & 34 deletions src/connectdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,16 @@ void CConnectDlg::RequestServerList()

// update list combo box (disable events to avoid a signal)
cbxDirectoryServer->blockSignals ( true );
if ( pSettings->eCentralServerAddressType == AT_CUSTOM )
if ( pSettings->eDirectoryType == AT_CUSTOM )
{
// iCustomDirectoryIndex is non-zero only if eCentralServerAddressType == AT_CUSTOM
// find the combobox item that corresponds to vstrCentralServerAddress[iCustomDirectoryIndex]
// iCustomDirectoryIndex is non-zero only if eDirectoryType == AT_CUSTOM
// find the combobox item that corresponds to vstrDirectoryAddress[iCustomDirectoryIndex]
// (the current selected custom directory)
cbxDirectoryServer->setCurrentIndex ( cbxDirectoryServer->findData ( QVariant ( pSettings->iCustomDirectoryIndex ) ) );
}
else
{
cbxDirectoryServer->setCurrentIndex ( static_cast<int> ( pSettings->eCentralServerAddressType ) );
cbxDirectoryServer->setCurrentIndex ( static_cast<int> ( pSettings->eDirectoryType ) );
}
cbxDirectoryServer->blockSignals ( false );

Expand All @@ -232,13 +232,12 @@ void CConnectDlg::RequestServerList()

// Allow IPv4 only for communicating with Directory Servers
if ( NetworkUtil().ParseNetworkAddress (
NetworkUtil::GetCentralServerAddress ( pSettings->eCentralServerAddressType,
pSettings->vstrCentralServerAddress[pSettings->iCustomDirectoryIndex] ),
CentralServerAddress,
NetworkUtil::GetDirectoryAddress ( pSettings->eDirectoryType, pSettings->vstrDirectoryAddress[pSettings->iCustomDirectoryIndex] ),
haDirectoryAddress,
false ) )
{
// send the request for the server list
emit ReqServerListQuery ( CentralServerAddress );
emit ReqServerListQuery ( haDirectoryAddress );

// start timer, if this message did not get any respond to retransmit
// the server list request message
Expand All @@ -257,19 +256,19 @@ void CConnectDlg::hideEvent ( QHideEvent* )
void CConnectDlg::OnDirectoryServerChanged ( int iTypeIdx )
{
// store the new directory server address type and request new list
// if iTypeIdx == AT_CUSTOM, then iCustomDirectoryIndex is the index into the vector holding the user's custom central servers
// if iTypeIdx == AT_CUSTOM, then iCustomDirectoryIndex is the index into the vector holding the user's custom directory servers
// if iTypeIdx != AT_CUSTOM, then iCustomDirectoryIndex MUST be 0;
if ( iTypeIdx >= AT_CUSTOM )
{
// the value for the index into the vector vstrCentralServerAddress is in the user data of the combobox item
// the value for the index into the vector vstrDirectoryAddress is in the user data of the combobox item
pSettings->iCustomDirectoryIndex = cbxDirectoryServer->itemData ( iTypeIdx ).toInt();
iTypeIdx = AT_CUSTOM;
}
else
{
pSettings->iCustomDirectoryIndex = 0;
}
pSettings->eCentralServerAddressType = static_cast<ECSAddType> ( iTypeIdx );
pSettings->eDirectoryType = static_cast<EDirectoryType> ( iTypeIdx );
RequestServerList();
}

Expand All @@ -281,7 +280,7 @@ void CConnectDlg::OnTimerReRequestServList()
{
// note that this is a connection less message which may get lost
// and therefore it makes sense to re-transmit it
emit ReqServerListQuery ( CentralServerAddress );
emit ReqServerListQuery ( haDirectoryAddress );
}
}

Expand All @@ -292,7 +291,7 @@ void CConnectDlg::SetServerList ( const CHostAddress& InetAddr, const CVector<CS
// we only accept a server list from the server address we have sent the
// request for this to (note that we cannot use the port number since the
// receive port and send port might be different at the directory server).
if ( bServerListReceived || ( InetAddr.InetAddr != CentralServerAddress.InetAddr ) )
if ( bServerListReceived || ( InetAddr.InetAddr != haDirectoryAddress.InetAddr ) )
{
return;
}
Expand Down Expand Up @@ -540,30 +539,30 @@ void CConnectDlg::OnServerAddrEditTextChanged ( const QString& )
lvwServers->clearSelection();
}

void CConnectDlg::OnCustomCentralServerAddrChanged()
void CConnectDlg::OnCustomDirectoryAddressChanged()
{

QString strPreviousSelection = cbxDirectoryServer->currentText();
UpdateDirectoryServerComboBox();
// after updating the combobox, we must re-select the previous directory selection

if ( pSettings->eCentralServerAddressType == AT_CUSTOM )
if ( pSettings->eDirectoryType == AT_CUSTOM )
{
// check if the currently select custom directory still exists in the now potentially re-ordered vector,
// if so, then change to its new index. (addresses Issue #1899)
int iNewIndex = cbxDirectoryServer->findText ( strPreviousSelection, Qt::MatchExactly );
if ( iNewIndex == INVALID_INDEX )
{
// previously selected custom directory has been deleted. change to default directory
pSettings->eCentralServerAddressType = static_cast<ECSAddType> ( AT_DEFAULT );
pSettings->iCustomDirectoryIndex = 0;
pSettings->eDirectoryType = static_cast<EDirectoryType> ( AT_DEFAULT );
pSettings->iCustomDirectoryIndex = 0;
RequestServerList();
}
else
{
// find previously selected custom directory in the now potentially re-ordered vector
pSettings->eCentralServerAddressType = static_cast<ECSAddType> ( AT_CUSTOM );
pSettings->iCustomDirectoryIndex = cbxDirectoryServer->itemData ( iNewIndex ).toInt();
pSettings->eDirectoryType = static_cast<EDirectoryType> ( AT_CUSTOM );
pSettings->iCustomDirectoryIndex = cbxDirectoryServer->itemData ( iNewIndex ).toInt();
cbxDirectoryServer->blockSignals ( true );
cbxDirectoryServer->setCurrentIndex ( cbxDirectoryServer->findData ( QVariant ( pSettings->iCustomDirectoryIndex ) ) );
cbxDirectoryServer->blockSignals ( false );
Expand All @@ -573,7 +572,7 @@ void CConnectDlg::OnCustomCentralServerAddrChanged()
{
// selected directory was not a custom directory
cbxDirectoryServer->blockSignals ( true );
cbxDirectoryServer->setCurrentIndex ( static_cast<int> ( pSettings->eCentralServerAddressType ) );
cbxDirectoryServer->setCurrentIndex ( static_cast<int> ( pSettings->eDirectoryType ) );
cbxDirectoryServer->blockSignals ( false );
}
}
Expand Down Expand Up @@ -730,21 +729,21 @@ void CConnectDlg::OnTimerPing()

for ( int iIdx = 0; iIdx < iServerListLen; iIdx++ )
{
CHostAddress CurServerAddress;
CHostAddress haServerAddress;

// try to parse host address string which is stored as user data
// in the server list item GUI control element
if ( NetworkUtil().ParseNetworkAddress ( lvwServers->topLevelItem ( iIdx )->data ( 0, Qt::UserRole ).toString(),
CurServerAddress,
haServerAddress,
bEnableIPv6 ) )
{
// if address is valid, send ping message using a new thread
QtConcurrent::run ( this, &CConnectDlg::EmitCLServerListPingMes, CurServerAddress );
QtConcurrent::run ( this, &CConnectDlg::EmitCLServerListPingMes, haServerAddress );
}
}
}

void CConnectDlg::EmitCLServerListPingMes ( const CHostAddress& CurServerAddress )
void CConnectDlg::EmitCLServerListPingMes ( const CHostAddress& haServerAddress )
{
// The ping time messages for all servers should not be sent all in a very
// short time since it showed that this leads to errors in the ping time
Expand All @@ -753,7 +752,7 @@ void CConnectDlg::EmitCLServerListPingMes ( const CHostAddress& CurServerAddress
// block the GUI).
QThread::msleep ( 11 );

emit CreateCLServerListPingMes ( CurServerAddress );
emit CreateCLServerListPingMes ( haServerAddress );
}

void CConnectDlg::SetPingTimeAndNumClientsResult ( const CHostAddress& InetAddr, const int iPingTime, const int iNumClients )
Expand Down Expand Up @@ -941,22 +940,22 @@ void CConnectDlg::UpdateDirectoryServerComboBox()
{
// directory server address type combo box
cbxDirectoryServer->clear();
cbxDirectoryServer->addItem ( csCentServAddrTypeToString ( AT_DEFAULT ) );
cbxDirectoryServer->addItem ( csCentServAddrTypeToString ( AT_ANY_GENRE2 ) );
cbxDirectoryServer->addItem ( csCentServAddrTypeToString ( AT_ANY_GENRE3 ) );
cbxDirectoryServer->addItem ( csCentServAddrTypeToString ( AT_GENRE_ROCK ) );
cbxDirectoryServer->addItem ( csCentServAddrTypeToString ( AT_GENRE_JAZZ ) );
cbxDirectoryServer->addItem ( csCentServAddrTypeToString ( AT_GENRE_CLASSICAL_FOLK ) );
cbxDirectoryServer->addItem ( csCentServAddrTypeToString ( AT_GENRE_CHORAL ) );
cbxDirectoryServer->addItem ( DirectoryTypeToString ( AT_DEFAULT ) );
cbxDirectoryServer->addItem ( DirectoryTypeToString ( AT_ANY_GENRE2 ) );
cbxDirectoryServer->addItem ( DirectoryTypeToString ( AT_ANY_GENRE3 ) );
cbxDirectoryServer->addItem ( DirectoryTypeToString ( AT_GENRE_ROCK ) );
cbxDirectoryServer->addItem ( DirectoryTypeToString ( AT_GENRE_JAZZ ) );
cbxDirectoryServer->addItem ( DirectoryTypeToString ( AT_GENRE_CLASSICAL_FOLK ) );
cbxDirectoryServer->addItem ( DirectoryTypeToString ( AT_GENRE_CHORAL ) );

// because custom directories are always added to the top of the vector, add the vector
// contents to the combobox in reverse order
for ( int i = MAX_NUM_SERVER_ADDR_ITEMS - 1; i >= 0; i-- )
{
if ( pSettings->vstrCentralServerAddress[i] != "" )
if ( pSettings->vstrDirectoryAddress[i] != "" )
{
// add vector index (i) to the combobox as user data
cbxDirectoryServer->addItem ( pSettings->vstrCentralServerAddress[i], i );
cbxDirectoryServer->addItem ( pSettings->vstrDirectoryAddress[i], i );
}
}
}
Loading