Merge pull request #99 from pljones/patch/log-connect-status-headless

Log connection status when no GUI active
This commit is contained in:
corrados 2020-04-19 12:08:46 +02:00 committed by GitHub
commit e44e739708
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 66 additions and 35 deletions

View file

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

View file

@ -545,36 +545,21 @@ void CServerDlg::UpdateGUIDependencies()
edtCentralServerAddress->setEnabled (
!bCurUseDefCentServAddr && bCurSerListEnabled );
QString strStatus;
QString strStatus = svrRegStatusToString ( eSvrRegStatus );
switch ( eSvrRegStatus )
{
case SRS_UNREGISTERED:
strStatus = "Unregistered";
break;
case SRS_BAD_ADDRESS:
strStatus = "<font color=""red""><b>Bad address</b></font>";
break;
case SRS_REQUESTED:
strStatus = "Registration requested";
break;
case SRS_TIME_OUT:
strStatus = "<font color=""red""><b>Registration failed</b></font>";
break;
case SRS_UNKNOWN_RESP:
strStatus = "Check server version";
case SRS_CENTRAL_SVR_FULL:
strStatus = "<font color=""red""><b>" + strStatus + "</b></font>";
break;
case SRS_REGISTERED:
strStatus = "<font color=""darkGreen""><b>Registered</b></font>";
strStatus = "<font color=""darkGreen""><b>" + strStatus + "</b></font>";
break;
case SRS_CENTRAL_SVR_FULL:
strStatus = "<font color=""red""><b>Central Server full</b></font>";
default:
break;
}
lblRegSvrStatus->setText ( strStatus );

View file

@ -479,6 +479,8 @@ void CServerListManager::CentralServerQueryServerList ( const CHostAddress& Inet
/* Slave server functionality *************************************************/
void CServerListManager::StoreRegistrationResult ( ESvrRegResult eResult )
{
qInfo() << "Server Registration Result received:" << svrRegResultToString ( eResult );
// we need the lock since the user might change the server properties at
// any time so another response could arrive
QMutexLocker locker ( &Mutex );
@ -486,20 +488,18 @@ void CServerListManager::StoreRegistrationResult ( ESvrRegResult eResult )
// we got some response, so stop the retry timer
TimerCLRegisterServerResp.stop();
eSvrRegStatus = ESvrRegStatus::SRS_UNKNOWN_RESP;
switch ( eResult )
{
case ESvrRegResult::SRR_REGISTERED:
eSvrRegStatus = ESvrRegStatus::SRS_REGISTERED;
break;
SetSvrRegStatus ( ESvrRegStatus::SRS_REGISTERED );
return;
case ESvrRegResult::SRR_CENTRAL_SVR_FULL:
eSvrRegStatus = ESvrRegStatus::SRS_CENTRAL_SVR_FULL;
break;
SetSvrRegStatus ( ESvrRegStatus::SRS_CENTRAL_SVR_FULL );
return;
}
emit SvrRegStatusChanged();
SetSvrRegStatus ( ESvrRegStatus::SRS_UNKNOWN_RESP );
}
void CServerListManager::OnTimerPingCentralServer()
@ -525,8 +525,7 @@ void CServerListManager::OnTimerCLRegisterServerResp()
if ( iSvrRegRetries >= REGISTER_SERVER_RETRY_LIMIT )
{
eSvrRegStatus = SRS_TIME_OUT;
emit SvrRegStatusChanged();
SetSvrRegStatus ( SRS_TIME_OUT );
}
else
{
@ -565,8 +564,7 @@ void CServerListManager::SlaveServerRegisterServer ( const bool bIsRegister )
if ( bIsRegister )
{
// register server
eSvrRegStatus = SRS_REQUESTED;
emit SvrRegStatusChanged();
SetSvrRegStatus ( SRS_REQUESTED );
pConnLessProtocol->CreateCLRegisterServerMes ( SlaveCurCentServerHostAddress,
SlaveCurLocalHostAddress,
@ -575,15 +573,20 @@ void CServerListManager::SlaveServerRegisterServer ( const bool bIsRegister )
else
{
// unregister server
eSvrRegStatus = SRS_UNREGISTERED;
emit SvrRegStatusChanged();
SetSvrRegStatus ( SRS_UNREGISTERED );
pConnLessProtocol->CreateCLUnregisterServerMes ( SlaveCurCentServerHostAddress );
}
}
else
{
eSvrRegStatus = SRS_BAD_ADDRESS;
SetSvrRegStatus ( SRS_BAD_ADDRESS );
emit SvrRegStatusChanged();
}
}
void CServerListManager::SetSvrRegStatus ( ESvrRegStatus eNSvrRegStatus )
{
qInfo() << "Server Registration Status update:" << svrRegStatusToString ( eNSvrRegStatus );
eSvrRegStatus = eNSvrRegStatus;
emit SvrRegStatusChanged();
}

View file

@ -177,6 +177,7 @@ public:
protected:
void SlaveServerRegisterServer ( const bool bIsRegister );
void SetSvrRegStatus ( ESvrRegStatus eNSvrRegStatus );
QTimer TimerPollList;
QTimer TimerRegistering;

View file

@ -584,6 +584,35 @@ enum ESvrRegStatus
SRS_CENTRAL_SVR_FULL = 6
};
inline QString svrRegStatusToString ( ESvrRegStatus eSvrRegStatus )
{
switch ( eSvrRegStatus )
{
case SRS_UNREGISTERED:
return "Unregistered";
case SRS_BAD_ADDRESS:
return "Bad address";
case SRS_REQUESTED:
return "Registration requested";
case SRS_TIME_OUT:
return "Registration failed";
case SRS_UNKNOWN_RESP:
return "Check server version";
case SRS_REGISTERED:
return "Registered";
case SRS_CENTRAL_SVR_FULL:
return "Central Server full";
}
return QString("Unknown value ").append( eSvrRegStatus );
}
// Central server registration outcome -----------------------------------------
enum ESvrRegResult
@ -593,6 +622,19 @@ enum ESvrRegResult
SRR_CENTRAL_SVR_FULL = 1
};
inline QString svrRegResultToString ( ESvrRegResult eSvrRegResult )
{
switch ( eSvrRegResult )
{
case SRR_REGISTERED:
return "Registered";
case SRR_CENTRAL_SVR_FULL:
return "Central Server full";
}
return QString("Unknown value ").append( eSvrRegResult );
}
// Skill level enum ------------------------------------------------------------
enum ESkillLevel