mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Ref T703, get partner callsign and validate it
* added functions in network details * validation and login with partner callsign
This commit is contained in:
committed by
Mat Sutcliffe
parent
6adea91618
commit
dd70a67cf0
@@ -82,7 +82,7 @@ namespace BlackGui
|
||||
|
||||
connect(ui->pb_Cancel, &QPushButton::clicked, this, &CLoginAdvComponent::loginCancelled, Qt::QueuedConnection);
|
||||
connect(ui->pb_Connect, &QPushButton::clicked, this, &CLoginAdvComponent::toggleNetworkConnection, Qt::QueuedConnection);
|
||||
connect(ui->comp_NetworkDetails, &CNetworkDetailsComponent::overridePilot, this, &CLoginAdvComponent::overrideCredentialsToPilot, Qt::QueuedConnection);
|
||||
connect(ui->comp_NetworkDetails, &CNetworkDetailsComponent::overridePilot, this, &CLoginAdvComponent::overrideCredentialsToPilot, Qt::QueuedConnection);
|
||||
connect(ui->comp_NetworkDetails, &CNetworkDetailsComponent::requestNetworkSettings, this, &CLoginAdvComponent::requestNetworkSettings, Qt::QueuedConnection);
|
||||
|
||||
// overlay
|
||||
@@ -104,6 +104,7 @@ namespace BlackGui
|
||||
// Stored data
|
||||
this->loadRememberedUserData();
|
||||
|
||||
// signals
|
||||
if (sGui && sGui->getIContextSimulator())
|
||||
{
|
||||
connect(sGui->getIContextSimulator(), &IContextSimulator::vitalityLost, this, &CLoginAdvComponent::autoLogoffDetection, Qt::QueuedConnection);
|
||||
@@ -155,7 +156,8 @@ namespace BlackGui
|
||||
const CStatusMessageList pilotMsgs = ui->form_Pilot->validate();
|
||||
if (pilotMsgs.isFailure())
|
||||
{
|
||||
this->showOverlayHTMLMessage(CStatusMessage(this).validationWarning(u"Invalid pilot data, login not possible"), OverlayMessageMs);
|
||||
// this->showOverlayHTMLMessage(CStatusMessage(this).validationWarning(u"Invalid pilot data, login not possible"), OverlayMessageMs);
|
||||
this->showOverlayMessagesOrHTMLMessage(pilotMsgs, false, OverlayMessageMs);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -168,13 +170,13 @@ namespace BlackGui
|
||||
const INetwork::LoginMode mode = ui->comp_NetworkDetails->getLoginMode();
|
||||
switch (mode)
|
||||
{
|
||||
case INetwork::LoginStealth: CLogMessage(this).info(u"login in stealth mode"); break;
|
||||
case INetwork::LoginStealth: CLogMessage(this).info(u"login in stealth mode"); break;
|
||||
case INetwork::LoginAsObserver: CLogMessage(this).info(u"login in observer mode"); break;
|
||||
default: break; // INetwork::LoginNormal
|
||||
}
|
||||
|
||||
// Server
|
||||
currentServer = this->getCurrentServer();
|
||||
currentServer = this->getCurrentServer();
|
||||
const CUser user = this->getUserFromPilotGuiValues();
|
||||
currentServer.setUser(user);
|
||||
|
||||
@@ -191,18 +193,38 @@ namespace BlackGui
|
||||
currentServer.setVoiceSetup(voice);
|
||||
}
|
||||
|
||||
// update for own aircraft context
|
||||
sGui->getIContextOwnAircraft()->updateOwnAircraftPilot(currentServer.getUser());
|
||||
|
||||
// set own aircraft from all values
|
||||
ownAircraft = sGui->getIContextOwnAircraft()->getOwnAircraft();
|
||||
|
||||
// check the copilot stuff
|
||||
CCallsign partnerCs;
|
||||
if (ui->comp_NetworkDetails->hasPartnerCallsign())
|
||||
{
|
||||
partnerCs = ui->comp_NetworkDetails->getPartnerCallsign();
|
||||
if (partnerCs == ownAircraft.getCallsign())
|
||||
{
|
||||
this->showOverlayHTMLMessage("Your callsign and the pilot/copilot callsign must be NOT the same", OverlayMessageMs);
|
||||
return;
|
||||
}
|
||||
|
||||
const bool ok = (partnerCs.asString().startsWith(ownAircraft.getCallsignAsString(), Qt::CaseInsensitive) || ownAircraft.getCallsignAsString().startsWith(partnerCs.asString(), Qt::CaseInsensitive));
|
||||
if (!ok)
|
||||
{
|
||||
this->showOverlayHTMLMessage("Callsign and the pilot/copilot callsign appear not to be synchronized", OverlayMessageMs);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Login
|
||||
if (sGui->getIContextAudio())
|
||||
if (sGui && sGui->getIContextAudio())
|
||||
{
|
||||
sGui->getIContextAudio()->setVoiceSetup(currentServer.getVoiceSetup());
|
||||
}
|
||||
|
||||
msg = sGui->getIContextNetwork()->connectToNetwork(currentServer, values.ownLiverySend, values.useLivery, values.ownAircraftModelStringSend, values.useModelString, mode);
|
||||
msg = sGui->getIContextNetwork()->connectToNetwork(currentServer, values.ownLiverySend, values.useLivery, values.ownAircraftModelStringSend, values.useModelString, partnerCs, mode);
|
||||
if (msg.isSuccess())
|
||||
{
|
||||
Q_ASSERT_X(currentServer.isValidForLogin(), Q_FUNC_INFO, "invalid server");
|
||||
|
||||
@@ -327,7 +327,7 @@ namespace BlackGui
|
||||
sGui->getIContextAudio()->setVoiceSetup(currentServer.getVoiceSetup());
|
||||
}
|
||||
|
||||
msg = sGui->getIContextNetwork()->connectToNetwork(currentServer, {}, true, {}, true, mode);
|
||||
msg = sGui->getIContextNetwork()->connectToNetwork(currentServer, {}, true, {}, true, {}, mode);
|
||||
if (msg.isSuccess())
|
||||
{
|
||||
Q_ASSERT_X(currentServer.isValidForLogin(), Q_FUNC_INFO, "invalid server");
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
using namespace BlackMisc::Network;
|
||||
using namespace BlackMisc::Audio;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackCore;
|
||||
using namespace BlackCore::Data;
|
||||
|
||||
@@ -59,10 +60,10 @@ namespace BlackGui
|
||||
|
||||
constexpr int MaxLength = 10;
|
||||
constexpr int MinLength = 0;
|
||||
CUpperCaseValidator *ucv = new CUpperCaseValidator(MinLength, MaxLength, ui->le_Copilot);
|
||||
CUpperCaseValidator *ucv = new CUpperCaseValidator(MinLength, MaxLength, ui->le_PartnerCallsign);
|
||||
ucv->setAllowedCharacters09AZ();
|
||||
ui->le_Copilot->setMaxLength(MaxLength);
|
||||
ui->le_Copilot->setValidator(ucv);
|
||||
ui->le_PartnerCallsign->setMaxLength(MaxLength);
|
||||
ui->le_PartnerCallsign->setValidator(ucv);
|
||||
|
||||
const int tab = m_networkSetup.wasLastUsedWithOtherServer() ? LoginOthers : LoginVATSIM;
|
||||
ui->tw_Network->setCurrentIndex(tab);
|
||||
@@ -243,6 +244,17 @@ namespace BlackGui
|
||||
return this->isVatsimServerSelected() ? this->getCurrentVatsimServer() : this->getCurrentOtherServer();
|
||||
}
|
||||
|
||||
bool CNetworkDetailsComponent::hasPartnerCallsign() const
|
||||
{
|
||||
return !ui->le_PartnerCallsign->text().isEmpty();
|
||||
}
|
||||
|
||||
CCallsign CNetworkDetailsComponent::getPartnerCallsign() const
|
||||
{
|
||||
if (ui->le_PartnerCallsign->text().isEmpty()) { return {}; }
|
||||
return CCallsign(ui->le_PartnerCallsign->text(), CCallsign::Aircraft);
|
||||
}
|
||||
|
||||
void CNetworkDetailsComponent::reloadOtherServersSetup()
|
||||
{
|
||||
const CServerList otherServers(m_networkSetup.getOtherServersPlusPredefinedServers());
|
||||
|
||||
@@ -100,6 +100,12 @@ namespace BlackGui
|
||||
//! Current server based on selected tab
|
||||
BlackMisc::Network::CServer getCurrentServer() const;
|
||||
|
||||
//! Pilot or Co-pilot callsign?
|
||||
bool hasPartnerCallsign() const;
|
||||
|
||||
//! Pilot or Co-pilot callsign
|
||||
BlackMisc::Aviation::CCallsign getPartnerCallsign() const;
|
||||
|
||||
signals:
|
||||
//! Override the pilot
|
||||
void overridePilot(const BlackMisc::Network::CUser &user);
|
||||
|
||||
@@ -250,9 +250,9 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="le_Copilot">
|
||||
<widget class="QLineEdit" name="le_PartnerCallsign">
|
||||
<property name="placeholderText">
|
||||
<string>partner callsign</string>
|
||||
<string>partner callsign (pilot/co-pilot)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -276,7 +276,7 @@
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_Copilot">
|
||||
<property name="text">
|
||||
<string>Co/Pilot callsign</string>
|
||||
<string>Partner callsign</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -418,7 +418,7 @@
|
||||
<tabstop>comp_VatsimServers</tabstop>
|
||||
<tabstop>pb_DetailsVatsim</tabstop>
|
||||
<tabstop>pb_OverrideCredentialsVatsim</tabstop>
|
||||
<tabstop>le_Copilot</tabstop>
|
||||
<tabstop>le_PartnerCallsign</tabstop>
|
||||
<tabstop>comp_OtherServers</tabstop>
|
||||
<tabstop>pb_RefreshOtherServers</tabstop>
|
||||
<tabstop>pb_OtherServersGotoSettings</tabstop>
|
||||
|
||||
Reference in New Issue
Block a user