added support for Central Server (North America) (Ticket #50), small bug fix for the Mac audio interface

This commit is contained in:
Volker Fischer 2020-04-11 14:27:50 +02:00
parent 1d4342bb7c
commit 82f5ad18f4
19 changed files with 175 additions and 138 deletions

View file

@ -466,7 +466,7 @@ QString CSound::CheckDeviceCapabilities ( const int iDriverIdx )
// store the input and out number of channels for this device // store the input and out number of channels for this device
iNumInChan = CountChannels ( audioInputDevice[iDriverIdx], true ); iNumInChan = CountChannels ( audioInputDevice[iDriverIdx], true );
iNumOutChan = CountChannels ( audioInputDevice[iDriverIdx], false ); iNumOutChan = CountChannels ( audioOutputDevice[iDriverIdx], false );
// clip the number of input/output channels to our allowed maximum // clip the number of input/output channels to our allowed maximum
if ( iNumInChan > MAX_NUM_IN_OUT_CHANNELS ) if ( iNumInChan > MAX_NUM_IN_OUT_CHANNELS )

View file

@ -69,7 +69,7 @@ CClient::CClient ( const quint16 iPortNumber,
bDisplayChannelLevels ( true ), bDisplayChannelLevels ( true ),
bJitterBufferOK ( true ), bJitterBufferOK ( true ),
strCentralServerAddress ( "" ), strCentralServerAddress ( "" ),
bUseDefaultCentralServerAddress ( true ), eCentralServerAddressType ( AT_DEFAULT ),
iServerSockBufNumFrames ( DEF_NET_BUF_SIZE_NUM_BL ) iServerSockBufNumFrames ( DEF_NET_BUF_SIZE_NUM_BL )
{ {
int iOpusError; int iOpusError;

View file

@ -137,17 +137,11 @@ public:
EAudChanConf GetAudioChannels() const { return eAudioChannelConf; } EAudChanConf GetAudioChannels() const { return eAudioChannelConf; }
void SetAudioChannels ( const EAudChanConf eNAudChanConf ); void SetAudioChannels ( const EAudChanConf eNAudChanConf );
void SetServerListCentralServerAddress ( const QString& sNCentServAddr ) void SetServerListCentralServerAddress ( const QString& sNCentServAddr ) { strCentralServerAddress = sNCentServAddr; }
{ strCentralServerAddress = sNCentServAddr; } QString GetServerListCentralServerAddress() { return strCentralServerAddress; }
QString GetServerListCentralServerAddress() void SetCentralServerAddressType ( const ECSAddType eNCSAT ) { eCentralServerAddressType = eNCSAT; }
{ return strCentralServerAddress; } ECSAddType GetCentralServerAddressType() { return eCentralServerAddressType; }
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; }
@ -370,7 +364,7 @@ protected:
bool bJitterBufferOK; bool bJitterBufferOK;
QString strCentralServerAddress; QString strCentralServerAddress;
bool bUseDefaultCentralServerAddress; ECSAddType eCentralServerAddressType;
CVector<int16_t> vecsAudioSndCrdMono; CVector<int16_t> vecsAudioSndCrdMono;

View file

@ -816,7 +816,7 @@ void CClientDlg::ShowConnectionSetupDialog()
{ {
// get the central server address string // get the central server address string
const QString strCurCentServAddr = const QString strCurCentServAddr =
SELECT_SERVER_ADDRESS ( pClient->GetUseDefaultCentralServerAddress(), NetworkUtil::GetCentralServerAddress ( pClient->GetCentralServerAddressType(),
pClient->GetServerListCentralServerAddress() ); pClient->GetServerListCentralServerAddress() );
// init the connect dialog // init the connect dialog

View file

@ -244,19 +244,16 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
// central server address // central server address
QString strCentrServAddr = tr ( "<b>Central Server Address:</b> The " QString strCentrServAddr = tr ( "<b>Central Server Address:</b> The "
"central server address is the IP address or URL of the central server " "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 " "at which the server list of the connection dialog is managed. With the "
"Default check box is checked, the default central server address is " "central server address type either the local region can be selected of "
"shown read-only." ); "the default central servers or a manual address can be specified." );
lblCentralServerAddress->setWhatsThis ( strCentrServAddr ); lblCentralServerAddress->setWhatsThis ( strCentrServAddr );
chbDefaultCentralServer->setWhatsThis ( strCentrServAddr ); cbxCentServAddrType->setWhatsThis ( strCentrServAddr );
edtCentralServerAddress->setWhatsThis ( strCentrServAddr ); edtCentralServerAddress->setWhatsThis ( strCentrServAddr );
chbDefaultCentralServer->setAccessibleName ( cbxCentServAddrType->setAccessibleName ( tr ( "Default central server type combo box" ) );
tr ( "Default central server check box" ) ); edtCentralServerAddress->setAccessibleName ( tr ( "Central server address line edit" ) );
edtCentralServerAddress->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 "
@ -346,15 +343,12 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
cbxAudioQuality->addItem ( "High" ); // AQ_HIGH cbxAudioQuality->addItem ( "High" ); // AQ_HIGH
cbxAudioQuality->setCurrentIndex ( static_cast<int> ( pClient->GetAudioQuality() ) ); cbxAudioQuality->setCurrentIndex ( static_cast<int> ( pClient->GetAudioQuality() ) );
// update default central server address check box // central server address type combo box
if ( pClient->GetUseDefaultCentralServerAddress() ) cbxCentServAddrType->clear();
{ cbxCentServAddrType->addItem ( "Manual" ); // AT_MANUAL
chbDefaultCentralServer->setCheckState ( Qt::Checked ); cbxCentServAddrType->addItem ( "Default" ); // AT_DEFAULT
} cbxCentServAddrType->addItem ( "Default (North America)" ); // AT_NORTH_AMERICA
else cbxCentServAddrType->setCurrentIndex ( static_cast<int> ( pClient->GetCentralServerAddressType() ) );
{
chbDefaultCentralServer->setCheckState ( Qt::Unchecked );
}
UpdateCentralServerDependency(); UpdateCentralServerDependency();
// update new client fader level edit box // update new client fader level edit box
@ -401,9 +395,6 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
QObject::connect ( chbAutoJitBuf, SIGNAL ( stateChanged ( int ) ), QObject::connect ( chbAutoJitBuf, SIGNAL ( stateChanged ( int ) ),
this, SLOT ( OnAutoJitBufStateChanged ( int ) ) ); this, SLOT ( OnAutoJitBufStateChanged ( int ) ) );
QObject::connect ( chbDefaultCentralServer, SIGNAL ( stateChanged ( int ) ),
this, SLOT ( OnDefaultCentralServerStateChanged ( int ) ) );
// line edits // line edits
QObject::connect ( edtCentralServerAddress, SIGNAL ( editingFinished() ), QObject::connect ( edtCentralServerAddress, SIGNAL ( editingFinished() ),
this, SLOT ( OnCentralServerAddressEditingFinished() ) ); this, SLOT ( OnCentralServerAddressEditingFinished() ) );
@ -433,6 +424,9 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
QObject::connect ( cbxAudioQuality, SIGNAL ( activated ( int ) ), QObject::connect ( cbxAudioQuality, SIGNAL ( activated ( int ) ),
this, SLOT ( OnAudioQualityActivated ( int ) ) ); this, SLOT ( OnAudioQualityActivated ( int ) ) );
QObject::connect ( cbxCentServAddrType, SIGNAL ( activated ( int ) ),
this, SLOT ( OnCentServAddrTypeActivated ( int ) ) );
// buttons // buttons
QObject::connect ( butDriverSetup, SIGNAL ( clicked() ), QObject::connect ( butDriverSetup, SIGNAL ( clicked() ),
this, SLOT ( OnDriverSetupClicked() ) ); this, SLOT ( OnDriverSetupClicked() ) );
@ -591,8 +585,7 @@ void CClientSettingsDlg::UpdateSoundChannelSelectionFrame()
void CClientSettingsDlg::UpdateCentralServerDependency() void CClientSettingsDlg::UpdateCentralServerDependency()
{ {
const bool bCurUseDefCentServAddr = const bool bCurUseDefCentServAddr = ( pClient->GetCentralServerAddressType() != AT_MANUAL );
pClient->GetUseDefaultCentralServerAddress();
// make sure the line edit does not fire signals when we update the text // make sure the line edit does not fire signals when we update the text
edtCentralServerAddress->blockSignals ( true ); edtCentralServerAddress->blockSignals ( true );
@ -696,6 +689,15 @@ void CClientSettingsDlg::OnAudioQualityActivated ( int iQualityIdx )
UpdateDisplay(); // upload rate will be changed UpdateDisplay(); // upload rate will be changed
} }
void CClientSettingsDlg::OnCentServAddrTypeActivated ( int iTypeIdx )
{
// apply new setting to the client
pClient->SetCentralServerAddressType ( static_cast<ECSAddType> ( iTypeIdx ) );
// update GUI dependencies
UpdateCentralServerDependency();
}
void CClientSettingsDlg::OnAutoJitBufStateChanged ( int value ) void CClientSettingsDlg::OnAutoJitBufStateChanged ( int value )
{ {
pClient->SetDoAutoSockBufSize ( value == Qt::Checked ); pClient->SetDoAutoSockBufSize ( value == Qt::Checked );
@ -722,15 +724,6 @@ void CClientSettingsDlg::OnDisplayChannelLevelsStateChanged ( int value )
emit DisplayChannelLevelsChanged(); emit DisplayChannelLevelsChanged();
} }
void CClientSettingsDlg::OnDefaultCentralServerStateChanged ( int value )
{
// apply new setting to the client
pClient->SetUseDefaultCentralServerAddress ( value == Qt::Checked );
// update GUI dependencies
UpdateCentralServerDependency();
}
void CClientSettingsDlg::OnCentralServerAddressEditingFinished() void CClientSettingsDlg::OnCentralServerAddressEditingFinished()
{ {
// store new setting in the client // store new setting in the client

View file

@ -91,7 +91,6 @@ protected:
void OnAutoJitBufStateChanged ( int value ); void OnAutoJitBufStateChanged ( int value );
void OnGUIDesignFancyStateChanged ( int value ); void OnGUIDesignFancyStateChanged ( int value );
void OnDisplayChannelLevelsStateChanged ( int value ); void OnDisplayChannelLevelsStateChanged ( int value );
void OnDefaultCentralServerStateChanged ( int value );
void OnCentralServerAddressEditingFinished(); void OnCentralServerAddressEditingFinished();
void OnNewClientLevelEditingFinished(); void OnNewClientLevelEditingFinished();
void OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton* button ); void OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton* button );
@ -102,6 +101,7 @@ protected:
void OnROutChanActivated ( int iChanIdx ); void OnROutChanActivated ( int iChanIdx );
void OnAudioChannelsActivated ( int iChanIdx ); void OnAudioChannelsActivated ( int iChanIdx );
void OnAudioQualityActivated ( int iQualityIdx ); void OnAudioQualityActivated ( int iQualityIdx );
void OnCentServAddrTypeActivated ( int iTypeIdx );
void OnDriverSetupClicked(); void OnDriverSetupClicked();
signals: signals:

View file

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>567</width> <width>567</width>
<height>351</height> <height>371</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -557,11 +557,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="chbDefaultCentralServer"> <widget class="QComboBox" name="cbxCentServAddrType"/>
<property name="text">
<string>Default</string>
</property>
</widget>
</item> </item>
</layout> </layout>
</item> </item>
@ -731,7 +727,7 @@
<tabstop>edtNewClientLevel</tabstop> <tabstop>edtNewClientLevel</tabstop>
<tabstop>chbGUIDesignFancy</tabstop> <tabstop>chbGUIDesignFancy</tabstop>
<tabstop>chbDisplayChannelLevels</tabstop> <tabstop>chbDisplayChannelLevels</tabstop>
<tabstop>chbDefaultCentralServer</tabstop> <tabstop>cbxCentServAddrType</tabstop>
<tabstop>edtCentralServerAddress</tabstop> <tabstop>edtCentralServerAddress</tabstop>
</tabstops> </tabstops>
<resources> <resources>

View file

@ -105,7 +105,6 @@ LED bar: lbr
// default server address // default server address
#define DEFAULT_SERVER_ADDRESS "jamulus.fischvolk.de" #define DEFAULT_SERVER_ADDRESS "jamulus.fischvolk.de"
#define DEFAULT_SERVER_NAME "Central Server" #define DEFAULT_SERVER_NAME "Central Server"
#define SELECT_SERVER_ADDRESS(a, b) ((a) ? (DEFAULT_SERVER_ADDRESS) : (b))
// download URL // download URL
#define LLCON_DOWNLOAD_URL "http://sourceforge.net/projects/llcon/files" #define LLCON_DOWNLOAD_URL "http://sourceforge.net/projects/llcon/files"

View file

@ -545,11 +545,6 @@ int main ( int argc, char** argv )
eLicenceType ); eLicenceType );
if ( bUseGUI ) 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 );
// special case for the GUI mode: we want the licenct type to be // special case for the GUI mode: we want the licenct type to be
// creative commons per default (if not given in the settings file) // creative commons per default (if not given in the settings file)
Server.SetLicenceType ( LT_CREATIVECOMMONS ); Server.SetLicenceType ( LT_CREATIVECOMMONS );

View file

@ -219,7 +219,8 @@ If enabled, the channel input level for each connected client will be displayed
![Central server address](centralserveraddress.png) ![Central server address](centralserveraddress.png)
The central server address is the IP address or URL of the central server at which the server list of the connection 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. dialog is managed. With the central server address type either the local region can be selected of the default
central servers or a manual address can be specified.
### Current connection status parameter ### Current connection status parameter

View file

@ -168,11 +168,11 @@ public:
QString GetServerListCentralServerAddress() QString GetServerListCentralServerAddress()
{ return ServerListManager.GetCentralServerAddress(); } { return ServerListManager.GetCentralServerAddress(); }
void SetUseDefaultCentralServerAddress ( const bool bNUDCSeAddr ) void SetCentralServerAddressType ( const ECSAddType eNCSAT )
{ ServerListManager.SetUseDefaultCentralServerAddress ( bNUDCSeAddr ); } { ServerListManager.SetCentralServerAddressType ( eNCSAT ); }
bool GetUseDefaultCentralServerAddress() ECSAddType GetCentralServerAddressType()
{ return ServerListManager.GetUseDefaultCentralServerAddress(); } { return ServerListManager.GetCentralServerAddressType(); }
void SetServerName ( const QString& strNewName ) void SetServerName ( const QString& strNewName )
{ ServerListManager.SetServerName ( strNewName ); } { ServerListManager.SetServerName ( strNewName ); }

View file

@ -73,18 +73,16 @@ CServerDlg::CServerDlg ( CServer* pNServP,
// central server address // central server address
QString strCentrServAddr = tr ( "<b>Central Server Address:</b> The " QString strCentrServAddr = tr ( "<b>Central Server Address:</b> The "
"Central server address is the IP address or URL of the central server " "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 " "at which this server is registered. With the central server address "
"checked, the default central server address is shown read-only." ); "type either the local region can be selected of the default central "
"servers or a manual address can be specified." );
lblCentralServerAddress->setWhatsThis ( strCentrServAddr ); lblCentralServerAddress->setWhatsThis ( strCentrServAddr );
chbDefaultCentralServer->setWhatsThis ( strCentrServAddr ); cbxCentServAddrType->setWhatsThis ( strCentrServAddr );
edtCentralServerAddress->setWhatsThis ( strCentrServAddr ); edtCentralServerAddress->setWhatsThis ( strCentrServAddr );
chbDefaultCentralServer->setAccessibleName ( cbxCentServAddrType->setAccessibleName ( tr ( "Default central server type combo box" ) );
tr ( "Default central server check box" ) ); edtCentralServerAddress->setAccessibleName ( tr ( "Central server address line edit" ) );
edtCentralServerAddress->setAccessibleName (
tr ( "Central server address line edit" ) );
// server name // server name
QString strServName = tr ( "<b>Server Name:</b> The server name identifies " QString strServName = tr ( "<b>Server Name:</b> The server name identifies "
@ -183,15 +181,12 @@ lvwClients->setMinimumHeight ( 140 );
vecpListViewItems[i]->setHidden ( true ); vecpListViewItems[i]->setHidden ( true );
} }
// update default central server address check box // central server address type combo box
if ( pServer->GetUseDefaultCentralServerAddress() ) cbxCentServAddrType->clear();
{ cbxCentServAddrType->addItem ( "Manual" ); // AT_MANUAL
chbDefaultCentralServer->setCheckState ( Qt::Checked ); cbxCentServAddrType->addItem ( "Default" ); // AT_DEFAULT
} cbxCentServAddrType->addItem ( "Default (North America)" ); // AT_NORTH_AMERICA
else cbxCentServAddrType->setCurrentIndex ( static_cast<int> ( pServer->GetCentralServerAddressType() ) );
{
chbDefaultCentralServer->setCheckState ( Qt::Unchecked );
}
// update server name line edit // update server name line edit
edtServerName->setText ( pServer->GetServerName() ); edtServerName->setText ( pServer->GetServerName() );
@ -293,9 +288,6 @@ lvwClients->setMinimumHeight ( 140 );
QObject::connect ( chbRegisterServer, SIGNAL ( stateChanged ( int ) ), QObject::connect ( chbRegisterServer, SIGNAL ( stateChanged ( int ) ),
this, SLOT ( OnRegisterServerStateChanged ( int ) ) ); this, SLOT ( OnRegisterServerStateChanged ( int ) ) );
QObject::connect ( chbDefaultCentralServer, SIGNAL ( stateChanged ( int ) ),
this, SLOT ( OnDefaultCentralServerStateChanged ( int ) ) );
QObject::connect ( chbStartOnOSStart, SIGNAL ( stateChanged ( int ) ), QObject::connect ( chbStartOnOSStart, SIGNAL ( stateChanged ( int ) ),
this, SLOT ( OnStartOnOSStartStateChanged ( int ) ) ); this, SLOT ( OnStartOnOSStartStateChanged ( int ) ) );
@ -316,6 +308,9 @@ lvwClients->setMinimumHeight ( 140 );
QObject::connect ( cbxLocationCountry, SIGNAL ( activated ( int ) ), QObject::connect ( cbxLocationCountry, SIGNAL ( activated ( int ) ),
this, SLOT ( OnLocationCountryActivated ( int ) ) ); this, SLOT ( OnLocationCountryActivated ( int ) ) );
QObject::connect ( cbxCentServAddrType, SIGNAL ( activated ( int ) ),
this, SLOT ( OnCentServAddrTypeActivated ( int ) ) );
// timers // timers
QObject::connect ( &Timer, SIGNAL ( timeout() ), this, SLOT ( OnTimer() ) ); QObject::connect ( &Timer, SIGNAL ( timeout() ), this, SLOT ( OnTimer() ) );
@ -372,16 +367,6 @@ void CServerDlg::OnUseCCLicenceStateChanged ( int value )
} }
} }
void CServerDlg::OnDefaultCentralServerStateChanged ( int value )
{
// apply new setting to the server and update it
pServer->SetUseDefaultCentralServerAddress ( value == Qt::Checked );
pServer->UpdateServerList();
// update GUI dependencies
UpdateGUIDependencies();
}
void CServerDlg::OnRegisterServerStateChanged ( int value ) void CServerDlg::OnRegisterServerStateChanged ( int value )
{ {
const bool bRegState = ( value == Qt::Checked ); const bool bRegState = ( value == Qt::Checked );
@ -451,6 +436,16 @@ void CServerDlg::OnLocationCountryActivated ( int iCntryListItem )
pServer->UpdateServerList(); pServer->UpdateServerList();
} }
void CServerDlg::OnCentServAddrTypeActivated ( int iTypeIdx )
{
// apply new setting to the server and update it
pServer->SetCentralServerAddressType ( static_cast<ECSAddType> ( iTypeIdx ) );
pServer->UpdateServerList();
// update GUI dependencies
UpdateGUIDependencies();
}
void CServerDlg::OnSysTrayActivated ( QSystemTrayIcon::ActivationReason ActReason ) void CServerDlg::OnSysTrayActivated ( QSystemTrayIcon::ActivationReason ActReason )
{ {
// on double click on the icon, show window in fore ground // on double click on the icon, show window in fore ground
@ -515,12 +510,11 @@ void CServerDlg::UpdateGUIDependencies()
// get the states which define the GUI dependencies from the server // get the states which define the GUI dependencies from the server
const bool bCurSerListEnabled = pServer->GetServerListEnabled(); const bool bCurSerListEnabled = pServer->GetServerListEnabled();
const bool bCurUseDefCentServAddr = const bool bCurUseDefCentServAddr = ( pServer->GetCentralServerAddressType() != AT_MANUAL );
pServer->GetUseDefaultCentralServerAddress();
// 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
chbDefaultCentralServer->setEnabled ( bCurSerListEnabled ); cbxCentServAddrType->setEnabled ( bCurSerListEnabled );
grbServerInfo->setEnabled ( bCurSerListEnabled ); grbServerInfo->setEnabled ( bCurSerListEnabled );
// make sure the line edit does not fire signals when we update the text // make sure the line edit does not fire signals when we update the text

View file

@ -84,13 +84,13 @@ public slots:
void OnAboutToQuit() { pSettings->Save(); } void OnAboutToQuit() { pSettings->Save(); }
void OnRegisterServerStateChanged ( int value ); void OnRegisterServerStateChanged ( int value );
void OnDefaultCentralServerStateChanged ( int value );
void OnStartOnOSStartStateChanged ( int value ); void OnStartOnOSStartStateChanged ( int value );
void OnUseCCLicenceStateChanged ( int value ); void OnUseCCLicenceStateChanged ( int value );
void OnCentralServerAddressEditingFinished(); void OnCentralServerAddressEditingFinished();
void OnServerNameTextChanged ( const QString& strNewName ); void OnServerNameTextChanged ( const QString& strNewName );
void OnLocationCityTextChanged ( const QString& strNewCity ); void OnLocationCityTextChanged ( const QString& strNewCity );
void OnLocationCountryActivated ( int iCntryListItem ); void OnLocationCountryActivated ( int iCntryListItem );
void OnCentServAddrTypeActivated ( int iTypeIdx );
void OnTimer(); void OnTimer();
void OnServerStarted() { UpdateSystemTrayIcon ( true ); } void OnServerStarted() { UpdateSystemTrayIcon ( true ); }
void OnServerStopped() { UpdateSystemTrayIcon ( false ); } void OnServerStopped() { UpdateSystemTrayIcon ( false ); }

View file

@ -82,11 +82,7 @@
<widget class="QLineEdit" name="edtCentralServerAddress"/> <widget class="QLineEdit" name="edtCentralServerAddress"/>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="chbDefaultCentralServer"> <widget class="QComboBox" name="cbxCentServAddrType"/>
<property name="text">
<string>Default</string>
</property>
</widget>
</item> </item>
</layout> </layout>
</item> </item>
@ -190,7 +186,7 @@
<tabstop>chbUseCCLicence</tabstop> <tabstop>chbUseCCLicence</tabstop>
<tabstop>chbRegisterServer</tabstop> <tabstop>chbRegisterServer</tabstop>
<tabstop>edtCentralServerAddress</tabstop> <tabstop>edtCentralServerAddress</tabstop>
<tabstop>chbDefaultCentralServer</tabstop> <tabstop>cbxCentServAddrType</tabstop>
<tabstop>edtServerName</tabstop> <tabstop>edtServerName</tabstop>
<tabstop>edtLocationCity</tabstop> <tabstop>edtLocationCity</tabstop>
<tabstop>cbxLocationCountry</tabstop> <tabstop>cbxLocationCountry</tabstop>

View file

@ -33,7 +33,7 @@ CServerListManager::CServerListManager ( const quint16 iNPortNum,
CProtocol* pNConLProt ) CProtocol* pNConLProt )
: iPortNumber ( iNPortNum ), : iPortNumber ( iNPortNum ),
iNumPredefinedServers ( 0 ), iNumPredefinedServers ( 0 ),
bUseDefaultCentralServerAddress ( false ), // must be false for the "no GUI" case eCentralServerAddressType ( AT_MANUAL ), // must be AT_MANUAL for the "no GUI" case
bCentServPingServerInList ( bNCentServPingServerInList ), bCentServPingServerInList ( bNCentServPingServerInList ),
pConnLessProtocol ( pNConLProt ) pConnLessProtocol ( pNConLProt )
{ {
@ -199,7 +199,7 @@ void CServerListManager::SetCentralServerAddress ( const QString sNCentServAddr
( (
( !strCentralServerAddress.toLower().compare ( "localhost" ) || ( !strCentralServerAddress.toLower().compare ( "localhost" ) ||
!strCentralServerAddress.compare ( "127.0.0.1" ) ) && !strCentralServerAddress.compare ( "127.0.0.1" ) ) &&
( !bUseDefaultCentralServerAddress ) ( eCentralServerAddressType == AT_MANUAL )
); );
bEnabled = true; bEnabled = true;
@ -480,7 +480,7 @@ void CServerListManager::SlaveServerRegisterServer ( const bool bIsRegister )
// get the correct central server address // get the correct central server address
const QString strCurCentrServAddr = const QString strCurCentrServAddr =
SELECT_SERVER_ADDRESS ( bUseDefaultCentralServerAddress, NetworkUtil::GetCentralServerAddress ( eCentralServerAddressType,
strCentralServerAddress ); strCentralServerAddress );
// For the slave server, the slave server properties are stored in the // For the slave server, the slave server properties are stored in the

View file

@ -142,11 +142,8 @@ public:
void SetCentralServerAddress ( const QString sNCentServAddr ); void SetCentralServerAddress ( const QString sNCentServAddr );
QString GetCentralServerAddress() { return strCentralServerAddress; } QString GetCentralServerAddress() { return strCentralServerAddress; }
void SetUseDefaultCentralServerAddress ( const bool bNUDCSeAddr ) void SetCentralServerAddressType ( const ECSAddType eNCSAT ) { eCentralServerAddressType = eNCSAT; }
{ bUseDefaultCentralServerAddress = bNUDCSeAddr; } ECSAddType GetCentralServerAddressType() { return eCentralServerAddressType; }
bool GetUseDefaultCentralServerAddress()
{ return bUseDefaultCentralServerAddress; }
bool GetIsCentralServer() const { return bIsCentralServer; } bool GetIsCentralServer() const { return bIsCentralServer; }
@ -195,7 +192,7 @@ protected:
int iNumPredefinedServers; int iNumPredefinedServers;
bool bEnabled; bool bEnabled;
bool bIsCentralServer; bool bIsCentralServer;
bool bUseDefaultCentralServerAddress; ECSAddType eCentralServerAddressType;
bool bCentServPingServerInList; bool bCentServPingServerInList;
CHostAddress SlaveCurCentServerHostAddress; CHostAddress SlaveCurCentServerHostAddress;

View file

@ -274,10 +274,26 @@ void CSettings::Load()
pClient->SetServerListCentralServerAddress ( pClient->SetServerListCentralServerAddress (
GetIniSetting ( IniXMLDocument, "client", "centralservaddr" ) ); GetIniSetting ( IniXMLDocument, "client", "centralservaddr" ) );
// use default central server address flag // central server address type
if ( GetNumericIniSet ( IniXMLDocument, "client", "centservaddrtype",
0, 2 /* AT_NORTH_AMERICA */, iValue ) )
{
pClient->SetCentralServerAddressType ( static_cast<ECSAddType> ( iValue ) );
}
else
{
// if no address type is given, choose one from the operating system locale
pClient->SetCentralServerAddressType ( CLocale::GetCentralServerAddressType ( QLocale::system().country() ) );
}
// TODO compatibility to old version
if ( GetFlagIniSet ( IniXMLDocument, "client", "defcentservaddr", bValue ) ) if ( GetFlagIniSet ( IniXMLDocument, "client", "defcentservaddr", bValue ) )
{ {
pClient->SetUseDefaultCentralServerAddress ( bValue ); // only the case that manual was set in old ini must be considered
if ( !bValue )
{
pClient->SetCentralServerAddressType ( AT_MANUAL );
}
} }
// window position of the main window // window position of the main window
@ -328,11 +344,27 @@ void CSettings::Load()
{ {
// server: // server:
// use default central server address flag (note that it is important // central server address type (note that it is important
// to set this setting prior to the "central server address") // to set this setting prior to the "central server address")
if ( GetNumericIniSet ( IniXMLDocument, "server", "centservaddrtype",
0, 2 /* AT_NORTH_AMERICA */, iValue ) )
{
pServer->SetCentralServerAddressType ( static_cast<ECSAddType> ( iValue ) );
}
else
{
// if no address type is given, choose one from the operating system locale
pServer->SetCentralServerAddressType ( CLocale::GetCentralServerAddressType ( QLocale::system().country() ) );
}
// TODO compatibility to old version
if ( GetFlagIniSet ( IniXMLDocument, "server", "defcentservaddr", bValue ) ) if ( GetFlagIniSet ( IniXMLDocument, "server", "defcentservaddr", bValue ) )
{ {
pServer->SetUseDefaultCentralServerAddress ( bValue ); // only the case that manual was set in old ini must be considered
if ( !bValue )
{
pServer->SetCentralServerAddressType ( AT_MANUAL );
}
} }
// central server address (to be set after the "use default central // central server address (to be set after the "use default central
@ -519,9 +551,9 @@ void CSettings::Save()
PutIniSetting ( IniXMLDocument, "client", "centralservaddr", PutIniSetting ( IniXMLDocument, "client", "centralservaddr",
pClient->GetServerListCentralServerAddress() ); pClient->GetServerListCentralServerAddress() );
// use default central server address flag // central server address type
SetFlagIniSet ( IniXMLDocument, "client", "defcentservaddr", SetNumericIniSet ( IniXMLDocument, "client", "centservaddrtype",
pClient->GetUseDefaultCentralServerAddress() ); static_cast<int> ( pClient->GetCentralServerAddressType() ) );
// window position of the main window // window position of the main window
PutIniSetting ( IniXMLDocument, "client", "winposmain_base64", PutIniSetting ( IniXMLDocument, "client", "winposmain_base64",
@ -567,9 +599,9 @@ void CSettings::Save()
PutIniSetting ( IniXMLDocument, "server", "centralservaddr", PutIniSetting ( IniXMLDocument, "server", "centralservaddr",
pServer->GetServerListCentralServerAddress() ); pServer->GetServerListCentralServerAddress() );
// use default central server address flag // central server address type
SetFlagIniSet ( IniXMLDocument, "server", "defcentservaddr", SetNumericIniSet ( IniXMLDocument, "server", "centservaddrtype",
pServer->GetUseDefaultCentralServerAddress() ); static_cast<int> ( pServer->GetCentralServerAddressType() ) );
// server list enabled flag // server list enabled flag
SetFlagIniSet ( IniXMLDocument, "server", "servlistenabled", SetFlagIniSet ( IniXMLDocument, "server", "servlistenabled",

View file

@ -908,6 +908,17 @@ CHostAddress NetworkUtil::GetLocalAddress()
} }
} }
QString NetworkUtil::GetCentralServerAddress ( const ECSAddType eCentralServerAddressType,
const QString& strCentralServerAddress )
{
switch ( eCentralServerAddressType )
{
case AT_MANUAL: return strCentralServerAddress;
case AT_NORTH_AMERICA: return QString ( "%1:%2" ).arg ( DEFAULT_SERVER_ADDRESS ).arg ( LLCON_PORT_NUMBER_NORTHAMERICA );
default: return DEFAULT_SERVER_ADDRESS; // AT_DEFAULT
}
}
// Instrument picture data base ------------------------------------------------ // Instrument picture data base ------------------------------------------------
CVector<CInstPictures::CInstPictProps>& CInstPictures::GetTable() CVector<CInstPictures::CInstPictProps>& CInstPictures::GetTable()
@ -992,7 +1003,7 @@ QString CInstPictures::GetName ( const int iInstrument )
} }
// Country flag icon data base ------------------------------------------------- // Locale management class -----------------------------------------------------
QString CLocale::GetCountryFlagIconsResourceReference ( const QLocale::Country eCountry ) QString CLocale::GetCountryFlagIconsResourceReference ( const QLocale::Country eCountry )
{ {
QString strReturn = ""; QString strReturn = "";
@ -1248,6 +1259,23 @@ QString CLocale::GetCountryFlagIconsResourceReference ( const QLocale::Country e
return strReturn; return strReturn;
} }
ECSAddType CLocale::GetCentralServerAddressType ( const QLocale::Country eCountry )
{
// TODO this is the initial implementation and should be extended in the future,
// maybe there is/will be some function in Qt to get the continent
switch ( eCountry )
{
case QLocale::UnitedStates:
case QLocale::Canada:
case QLocale::Mexico:
case QLocale::Greenland:
return AT_NORTH_AMERICA;
default:
return AT_DEFAULT;
}
}
// Console writer factory ------------------------------------------------------ // Console writer factory ------------------------------------------------------
QTextStream* ConsoleWriterFactory::get() QTextStream* ConsoleWriterFactory::get()

View file

@ -563,6 +563,15 @@ enum ELicenceType
}; };
// Central server address type -------------------------------------------------
enum ECSAddType
{
AT_MANUAL = 0,
AT_DEFAULT = 1, // Europe and others
AT_NORTH_AMERICA = 2
};
// Skill level enum ------------------------------------------------------------ // Skill level enum ------------------------------------------------------------
enum ESkillLevel enum ESkillLevel
{ {
@ -739,6 +748,7 @@ class CLocale
{ {
public: public:
static QString GetCountryFlagIconsResourceReference ( const QLocale::Country eCountry ); static QString GetCountryFlagIconsResourceReference ( const QLocale::Country eCountry );
static ECSAddType GetCentralServerAddressType ( const QLocale::Country eCountry );
}; };
@ -980,6 +990,8 @@ public:
CHostAddress& HostAddress ); CHostAddress& HostAddress );
static CHostAddress GetLocalAddress(); static CHostAddress GetLocalAddress();
static QString GetCentralServerAddress ( const ECSAddType eCentralServerAddressType,
const QString& strCentralServerAddress );
}; };