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 )
|
void CLlconServerDlg::OnRegisterServerStateChanged ( int value )
|
||||||
{
|
{
|
||||||
|
const bool bRegState = ( value == Qt::Checked );
|
||||||
|
|
||||||
// apply new setting to the server and update it
|
// apply new setting to the server and update it
|
||||||
pServer->SetServerListEnabled ( value == Qt::Checked );
|
pServer->SetServerListEnabled ( bRegState );
|
||||||
pServer->UpdateServerList();
|
|
||||||
|
// If registering is enabled, update data. If registering is disabled,
|
||||||
|
// unregister slave server
|
||||||
|
if ( bRegState )
|
||||||
|
{
|
||||||
|
pServer->UpdateServerList();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pServer->UnregisterSlaveServer();
|
||||||
|
}
|
||||||
|
|
||||||
// update GUI dependencies
|
// update GUI dependencies
|
||||||
UpdateGUIDependencies();
|
UpdateGUIDependencies();
|
||||||
|
|
|
@ -130,6 +130,8 @@ public:
|
||||||
// Server list management --------------------------------------------------
|
// Server list management --------------------------------------------------
|
||||||
void UpdateServerList() { ServerListManager.Update(); }
|
void UpdateServerList() { ServerListManager.Update(); }
|
||||||
|
|
||||||
|
void UnregisterSlaveServer() { ServerListManager.SlaveServerUnregister(); }
|
||||||
|
|
||||||
void SetServerListEnabled ( const bool bState )
|
void SetServerListEnabled ( const bool bState )
|
||||||
{ ServerListManager.SetEnabled ( bState ); }
|
{ ServerListManager.SetEnabled ( bState ); }
|
||||||
|
|
||||||
|
|
|
@ -376,37 +376,43 @@ void CServerListManager::CentralServerQueryServerList ( const CHostAddress& Inet
|
||||||
|
|
||||||
|
|
||||||
/* Slave server functionality *************************************************/
|
/* 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
|
// we need the lock since the user might change the server properties at
|
||||||
// any time
|
// any time
|
||||||
QMutexLocker locker ( &Mutex );
|
QMutexLocker locker ( &Mutex );
|
||||||
|
|
||||||
if ( !bIsCentralServer && bEnabled )
|
// get the correct central server address
|
||||||
|
QString strCurCentrServAddr;
|
||||||
|
if ( bUseDefaultCentralServerAddress )
|
||||||
{
|
{
|
||||||
// get the correct central server address
|
strCurCentrServAddr = DEFAULT_SERVER_ADDRESS;
|
||||||
QString strCurCentrServAddr;
|
}
|
||||||
if ( bUseDefaultCentralServerAddress )
|
else
|
||||||
{
|
{
|
||||||
strCurCentrServAddr = DEFAULT_SERVER_ADDRESS;
|
strCurCentrServAddr = strCentralServerAddress;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
strCurCentrServAddr = strCentralServerAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
// For the slave server, the slave server properties are store in the
|
// 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
|
// very first item in the server list (which is actually no server list
|
||||||
// but just one item long for the slave server).
|
// but just one item long for the slave server).
|
||||||
// Note that we always have to parse the server address again since if
|
// Note that we always have to parse the server address again since if
|
||||||
// it is an URL of a dynamic IP address, the IP address might have
|
// it is an URL of a dynamic IP address, the IP address might have
|
||||||
// changed in the meanwhile.
|
// changed in the meanwhile.
|
||||||
CHostAddress HostAddress;
|
CHostAddress HostAddress;
|
||||||
if ( LlconNetwUtil().ParseNetworkAddress ( strCurCentrServAddr,
|
if ( LlconNetwUtil().ParseNetworkAddress ( strCurCentrServAddr,
|
||||||
HostAddress ) )
|
HostAddress ) )
|
||||||
|
{
|
||||||
|
if ( bIsRegister )
|
||||||
{
|
{
|
||||||
|
// register server
|
||||||
pConnLessProtocol->CreateCLRegisterServerMes ( HostAddress,
|
pConnLessProtocol->CreateCLRegisterServerMes ( HostAddress,
|
||||||
ServerList[0] );
|
ServerList[0] );
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// unregister server
|
||||||
|
pConnLessProtocol->CreateCLUnregisterServerMes ( HostAddress );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,6 +150,7 @@ public:
|
||||||
|
|
||||||
void CentralServerQueryServerList ( const CHostAddress& InetAddr );
|
void CentralServerQueryServerList ( const CHostAddress& InetAddr );
|
||||||
|
|
||||||
|
void SlaveServerUnregister() { SlaveServerRegisterServer ( false ); }
|
||||||
|
|
||||||
// set server infos -> per definition the server info of this server is
|
// 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
|
// 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; }
|
QLocale::Country GetServerCountry() { return ServerList[0].eCountry; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void SlaveServerRegisterServer ( const bool bIsRegister );
|
||||||
|
|
||||||
QTimer TimerPollList;
|
QTimer TimerPollList;
|
||||||
QTimer TimerRegistering;
|
QTimer TimerRegistering;
|
||||||
QMutex Mutex;
|
QMutex Mutex;
|
||||||
|
@ -184,7 +187,7 @@ protected:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void OnTimerPollList();
|
void OnTimerPollList();
|
||||||
void OnTimerRegistering();
|
void OnTimerRegistering() { SlaveServerRegisterServer ( true ); }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* !defined ( SERVERLIST_HOIJH8OUWEF_WFEIOBU_3_43445KJIUHF1912__INCLUDED_ ) */
|
#endif /* !defined ( SERVERLIST_HOIJH8OUWEF_WFEIOBU_3_43445KJIUHF1912__INCLUDED_ ) */
|
||||||
|
|
Loading…
Reference in a new issue