unregistering the server does work now correctly
This commit is contained in:
parent
ed74f3e370
commit
97d32de751
4 changed files with 47 additions and 24 deletions
|
@ -228,9 +228,21 @@ void CLlconServerDlg::OnDefaultCentralServerStateChanged ( int value )
|
|||
|
||||
void CLlconServerDlg::OnRegisterServerStateChanged ( int value )
|
||||
{
|
||||
const bool bRegState = ( value == Qt::Checked );
|
||||
|
||||
// apply new setting to the server and update it
|
||||
pServer->SetServerListEnabled ( value == Qt::Checked );
|
||||
pServer->SetServerListEnabled ( bRegState );
|
||||
|
||||
// If registering is enabled, update data. If registering is disabled,
|
||||
// unregister slave server
|
||||
if ( bRegState )
|
||||
{
|
||||
pServer->UpdateServerList();
|
||||
}
|
||||
else
|
||||
{
|
||||
pServer->UnregisterSlaveServer();
|
||||
}
|
||||
|
||||
// update GUI dependencies
|
||||
UpdateGUIDependencies();
|
||||
|
|
|
@ -130,6 +130,8 @@ public:
|
|||
// Server list management --------------------------------------------------
|
||||
void UpdateServerList() { ServerListManager.Update(); }
|
||||
|
||||
void UnregisterSlaveServer() { ServerListManager.SlaveServerUnregister(); }
|
||||
|
||||
void SetServerListEnabled ( const bool bState )
|
||||
{ ServerListManager.SetEnabled ( bState ); }
|
||||
|
||||
|
|
|
@ -376,14 +376,12 @@ void CServerListManager::CentralServerQueryServerList ( const CHostAddress& Inet
|
|||
|
||||
|
||||
/* Slave server functionality *************************************************/
|
||||
void CServerListManager::OnTimerRegistering()
|
||||
void CServerListManager::SlaveServerRegisterServer ( const bool bIsRegister )
|
||||
{
|
||||
// we need the lock since the user might change the server properties at
|
||||
// any time
|
||||
QMutexLocker locker ( &Mutex );
|
||||
|
||||
if ( !bIsCentralServer && bEnabled )
|
||||
{
|
||||
// get the correct central server address
|
||||
QString strCurCentrServAddr;
|
||||
if ( bUseDefaultCentralServerAddress )
|
||||
|
@ -405,8 +403,16 @@ void CServerListManager::OnTimerRegistering()
|
|||
if ( LlconNetwUtil().ParseNetworkAddress ( strCurCentrServAddr,
|
||||
HostAddress ) )
|
||||
{
|
||||
if ( bIsRegister )
|
||||
{
|
||||
// register server
|
||||
pConnLessProtocol->CreateCLRegisterServerMes ( HostAddress,
|
||||
ServerList[0] );
|
||||
}
|
||||
else
|
||||
{
|
||||
// unregister server
|
||||
pConnLessProtocol->CreateCLUnregisterServerMes ( HostAddress );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -150,6 +150,7 @@ public:
|
|||
|
||||
void CentralServerQueryServerList ( const CHostAddress& InetAddr );
|
||||
|
||||
void SlaveServerUnregister() { SlaveServerRegisterServer ( false ); }
|
||||
|
||||
// set server infos -> per definition the server info of this server is
|
||||
// stored in the first entry of the list, we assume here that the first
|
||||
|
@ -170,6 +171,8 @@ public:
|
|||
QLocale::Country GetServerCountry() { return ServerList[0].eCountry; }
|
||||
|
||||
protected:
|
||||
void SlaveServerRegisterServer ( const bool bIsRegister );
|
||||
|
||||
QTimer TimerPollList;
|
||||
QTimer TimerRegistering;
|
||||
QMutex Mutex;
|
||||
|
@ -184,7 +187,7 @@ protected:
|
|||
|
||||
public slots:
|
||||
void OnTimerPollList();
|
||||
void OnTimerRegistering();
|
||||
void OnTimerRegistering() { SlaveServerRegisterServer ( true ); }
|
||||
};
|
||||
|
||||
#endif /* !defined ( SERVERLIST_HOIJH8OUWEF_WFEIOBU_3_43445KJIUHF1912__INCLUDED_ ) */
|
||||
|
|
Loading…
Reference in a new issue