Ref T761, partner callsign message relay (swift with co-pilot)

* handle server error messages correctly as "error"
* (relayed) sender can be ATC or aircraft
* relay private messages correctly
This commit is contained in:
Klaus Basan
2019-11-20 23:28:07 +01:00
committed by Mat Sutcliffe
parent 22d8b52fe8
commit f07ca09424
7 changed files with 45 additions and 29 deletions

View File

@@ -1285,28 +1285,28 @@ namespace BlackCore
const ServerError serverError = ServerError::fromTokens(tokens);
switch (serverError.m_errorNumber)
{
case ServerErrorCode::CallsignInUse: CLogMessage(this).error(u"The requested callsign is already taken"); break;
case ServerErrorCode::InvalidCallsign: CLogMessage(this).error(u"The requested callsign is not valid"); break;
case ServerErrorCode::InvalidCidPassword: CLogMessage(this).error(u"Wrong user ID or password, inactive account"); break;
case ServerErrorCode::InvalidRevision: CLogMessage(this).error(u"This server does not support our protocol version"); break;
case ServerErrorCode::ServerFull: CLogMessage(this).error(u"The server is full"); break;
case ServerErrorCode::CidSuspended: CLogMessage(this).error(u"Your user account is suspended"); break;
case ServerErrorCode::RatingTooLow: CLogMessage(this).error(u"You are not authorized to use the requested rating"); break;
case ServerErrorCode::InvalidClient: CLogMessage(this).error(u"This software is not authorized for use on this network"); break;
case ServerErrorCode::CallsignInUse: CLogMessage(this).error(u"The requested callsign is already taken"); break;
case ServerErrorCode::InvalidCallsign: CLogMessage(this).error(u"The requested callsign is not valid"); break;
case ServerErrorCode::InvalidCidPassword: CLogMessage(this).error(u"Wrong user ID or password, inactive account"); break;
case ServerErrorCode::InvalidRevision: CLogMessage(this).error(u"This server does not support our protocol version"); break;
case ServerErrorCode::ServerFull: CLogMessage(this).error(u"The server is full"); break;
case ServerErrorCode::CidSuspended: CLogMessage(this).error(u"Your user account is suspended"); break;
case ServerErrorCode::RatingTooLow: CLogMessage(this).error(u"You are not authorized to use the requested rating"); break;
case ServerErrorCode::InvalidClient: CLogMessage(this).error(u"This software is not authorized for use on this network"); break;
case ServerErrorCode::RequestedLevelTooHigh: CLogMessage(this).error(u"You are not authorized to use the requested pilot rating"); break;
case ServerErrorCode::NoError: CLogMessage(this).info(u"OK"); break;
case ServerErrorCode::SyntaxError: CLogMessage(this).info(u"Malformed packet: Syntax error: %1") << serverError.m_causingParameter; break;
case ServerErrorCode::InvalidSrcCallsign: CLogMessage(this).info(u"FSD message was using an invalid callsign: %1 (%2)") << serverError.m_causingParameter << serverError.m_description; break;
case ServerErrorCode::NoSuchCallsign: CLogMessage(this).info(u"FSD Server: no such callsign: %1 %2") << serverError.m_causingParameter << serverError.m_description; break;
case ServerErrorCode::NoFlightPlan: CLogMessage(this).info(u"FSD Server: no flight plan"); break;
case ServerErrorCode::NoWeatherProfile: CLogMessage(this).info(u"FSD Server: requested weather profile does not exist"); break;
case ServerErrorCode::NoError: CLogMessage(this).info(u"OK"); break;
case ServerErrorCode::SyntaxError: CLogMessage(this).error(u"Malformed packet: Syntax error: %1") << serverError.getCausingParameter(); break;
case ServerErrorCode::InvalidSrcCallsign: CLogMessage(this).info(u"FSD message was using an invalid callsign: %1 (%2)") << serverError.getCausingParameter() << serverError.getDescription(); break;
case ServerErrorCode::NoSuchCallsign: CLogMessage(this).info(u"FSD Server: no such callsign: %1 %2") << serverError.getCausingParameter() << serverError.getDescription(); break;
case ServerErrorCode::NoFlightPlan: CLogMessage(this).info(u"FSD Server: no flight plan"); break;
case ServerErrorCode::NoWeatherProfile: CLogMessage(this).info(u"FSD Server: requested weather profile does not exist"); break;
// we have no idea what these mean
case ServerErrorCode::AlreadyRegistered: CLogMessage(this).info(u"Server says already registered: %1") << serverError.m_description; break;
case ServerErrorCode::InvalidCtrl: CLogMessage(this).info(u"Server invalid control: %1") << serverError.m_description; break;
case ServerErrorCode::Unknown: CLogMessage(this).info(u"Server sent unknown error code: %1 (%2)") << serverError.m_causingParameter << serverError.m_description; break;
case ServerErrorCode::AuthTimeout: CLogMessage(this).error(u"Client did not authenticate in time"); break;
case ServerErrorCode::AlreadyRegistered: CLogMessage(this).warning(u"Server says already registered: %1") << serverError.getDescription(); break;
case ServerErrorCode::InvalidCtrl: CLogMessage(this).warning(u"Server invalid control: %1") << serverError.getDescription(); break;
case ServerErrorCode::Unknown: CLogMessage(this).warning(u"Server sent unknown error code: %1 (%2)") << serverError.getCausingParameter() << serverError.getDescription(); break;
case ServerErrorCode::AuthTimeout: CLogMessage(this).warning(u"Client did not authenticate in time"); break;
}
if (serverError.isFatalError()) { disconnectFromServer(); }
}

View File

@@ -63,7 +63,7 @@ namespace BlackCore
{
BlackMisc::CLogMessage(static_cast<ServerError *>(nullptr)).debug(u"Wrong number of arguments.");
return {};
};
}
return ServerError(tokens[0], tokens[1], static_cast<ServerErrorCode>(tokens[2].toInt()), tokens[3], tokens[4]);
}
}

View File

@@ -37,6 +37,11 @@ namespace BlackCore
//! PDU identifier
static QString pdu() { return "$ER"; }
//! Getter @{
const QString &getCausingParameter() const { static const QString n("no details"); return m_causingParameter.isEmpty() ? n : m_causingParameter; }
const QString &getDescription() const { static const QString n("no description"); return m_description.isEmpty() ? n : m_description; }
//! @}
//! Properties @{
ServerErrorCode m_errorNumber;
QString m_causingParameter;