mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-09 21:45:34 +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_Cancel, &QPushButton::clicked, this, &CLoginAdvComponent::loginCancelled, Qt::QueuedConnection);
|
||||||
connect(ui->pb_Connect, &QPushButton::clicked, this, &CLoginAdvComponent::toggleNetworkConnection, 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);
|
connect(ui->comp_NetworkDetails, &CNetworkDetailsComponent::requestNetworkSettings, this, &CLoginAdvComponent::requestNetworkSettings, Qt::QueuedConnection);
|
||||||
|
|
||||||
// overlay
|
// overlay
|
||||||
@@ -104,6 +104,7 @@ namespace BlackGui
|
|||||||
// Stored data
|
// Stored data
|
||||||
this->loadRememberedUserData();
|
this->loadRememberedUserData();
|
||||||
|
|
||||||
|
// signals
|
||||||
if (sGui && sGui->getIContextSimulator())
|
if (sGui && sGui->getIContextSimulator())
|
||||||
{
|
{
|
||||||
connect(sGui->getIContextSimulator(), &IContextSimulator::vitalityLost, this, &CLoginAdvComponent::autoLogoffDetection, Qt::QueuedConnection);
|
connect(sGui->getIContextSimulator(), &IContextSimulator::vitalityLost, this, &CLoginAdvComponent::autoLogoffDetection, Qt::QueuedConnection);
|
||||||
@@ -155,7 +156,8 @@ namespace BlackGui
|
|||||||
const CStatusMessageList pilotMsgs = ui->form_Pilot->validate();
|
const CStatusMessageList pilotMsgs = ui->form_Pilot->validate();
|
||||||
if (pilotMsgs.isFailure())
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,13 +170,13 @@ namespace BlackGui
|
|||||||
const INetwork::LoginMode mode = ui->comp_NetworkDetails->getLoginMode();
|
const INetwork::LoginMode mode = ui->comp_NetworkDetails->getLoginMode();
|
||||||
switch (mode)
|
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;
|
case INetwork::LoginAsObserver: CLogMessage(this).info(u"login in observer mode"); break;
|
||||||
default: break; // INetwork::LoginNormal
|
default: break; // INetwork::LoginNormal
|
||||||
}
|
}
|
||||||
|
|
||||||
// Server
|
// Server
|
||||||
currentServer = this->getCurrentServer();
|
currentServer = this->getCurrentServer();
|
||||||
const CUser user = this->getUserFromPilotGuiValues();
|
const CUser user = this->getUserFromPilotGuiValues();
|
||||||
currentServer.setUser(user);
|
currentServer.setUser(user);
|
||||||
|
|
||||||
@@ -191,18 +193,38 @@ namespace BlackGui
|
|||||||
currentServer.setVoiceSetup(voice);
|
currentServer.setVoiceSetup(voice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update for own aircraft context
|
||||||
sGui->getIContextOwnAircraft()->updateOwnAircraftPilot(currentServer.getUser());
|
sGui->getIContextOwnAircraft()->updateOwnAircraftPilot(currentServer.getUser());
|
||||||
|
|
||||||
// set own aircraft from all values
|
// set own aircraft from all values
|
||||||
ownAircraft = sGui->getIContextOwnAircraft()->getOwnAircraft();
|
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
|
// Login
|
||||||
if (sGui->getIContextAudio())
|
if (sGui && sGui->getIContextAudio())
|
||||||
{
|
{
|
||||||
sGui->getIContextAudio()->setVoiceSetup(currentServer.getVoiceSetup());
|
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())
|
if (msg.isSuccess())
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(currentServer.isValidForLogin(), Q_FUNC_INFO, "invalid server");
|
Q_ASSERT_X(currentServer.isValidForLogin(), Q_FUNC_INFO, "invalid server");
|
||||||
|
|||||||
@@ -327,7 +327,7 @@ namespace BlackGui
|
|||||||
sGui->getIContextAudio()->setVoiceSetup(currentServer.getVoiceSetup());
|
sGui->getIContextAudio()->setVoiceSetup(currentServer.getVoiceSetup());
|
||||||
}
|
}
|
||||||
|
|
||||||
msg = sGui->getIContextNetwork()->connectToNetwork(currentServer, {}, true, {}, true, mode);
|
msg = sGui->getIContextNetwork()->connectToNetwork(currentServer, {}, true, {}, true, {}, mode);
|
||||||
if (msg.isSuccess())
|
if (msg.isSuccess())
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(currentServer.isValidForLogin(), Q_FUNC_INFO, "invalid server");
|
Q_ASSERT_X(currentServer.isValidForLogin(), Q_FUNC_INFO, "invalid server");
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
using namespace BlackMisc::Network;
|
using namespace BlackMisc::Network;
|
||||||
using namespace BlackMisc::Audio;
|
using namespace BlackMisc::Audio;
|
||||||
|
using namespace BlackMisc::Aviation;
|
||||||
using namespace BlackCore;
|
using namespace BlackCore;
|
||||||
using namespace BlackCore::Data;
|
using namespace BlackCore::Data;
|
||||||
|
|
||||||
@@ -59,10 +60,10 @@ namespace BlackGui
|
|||||||
|
|
||||||
constexpr int MaxLength = 10;
|
constexpr int MaxLength = 10;
|
||||||
constexpr int MinLength = 0;
|
constexpr int MinLength = 0;
|
||||||
CUpperCaseValidator *ucv = new CUpperCaseValidator(MinLength, MaxLength, ui->le_Copilot);
|
CUpperCaseValidator *ucv = new CUpperCaseValidator(MinLength, MaxLength, ui->le_PartnerCallsign);
|
||||||
ucv->setAllowedCharacters09AZ();
|
ucv->setAllowedCharacters09AZ();
|
||||||
ui->le_Copilot->setMaxLength(MaxLength);
|
ui->le_PartnerCallsign->setMaxLength(MaxLength);
|
||||||
ui->le_Copilot->setValidator(ucv);
|
ui->le_PartnerCallsign->setValidator(ucv);
|
||||||
|
|
||||||
const int tab = m_networkSetup.wasLastUsedWithOtherServer() ? LoginOthers : LoginVATSIM;
|
const int tab = m_networkSetup.wasLastUsedWithOtherServer() ? LoginOthers : LoginVATSIM;
|
||||||
ui->tw_Network->setCurrentIndex(tab);
|
ui->tw_Network->setCurrentIndex(tab);
|
||||||
@@ -243,6 +244,17 @@ namespace BlackGui
|
|||||||
return this->isVatsimServerSelected() ? this->getCurrentVatsimServer() : this->getCurrentOtherServer();
|
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()
|
void CNetworkDetailsComponent::reloadOtherServersSetup()
|
||||||
{
|
{
|
||||||
const CServerList otherServers(m_networkSetup.getOtherServersPlusPredefinedServers());
|
const CServerList otherServers(m_networkSetup.getOtherServersPlusPredefinedServers());
|
||||||
|
|||||||
@@ -100,6 +100,12 @@ namespace BlackGui
|
|||||||
//! Current server based on selected tab
|
//! Current server based on selected tab
|
||||||
BlackMisc::Network::CServer getCurrentServer() const;
|
BlackMisc::Network::CServer getCurrentServer() const;
|
||||||
|
|
||||||
|
//! Pilot or Co-pilot callsign?
|
||||||
|
bool hasPartnerCallsign() const;
|
||||||
|
|
||||||
|
//! Pilot or Co-pilot callsign
|
||||||
|
BlackMisc::Aviation::CCallsign getPartnerCallsign() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
//! Override the pilot
|
//! Override the pilot
|
||||||
void overridePilot(const BlackMisc::Network::CUser &user);
|
void overridePilot(const BlackMisc::Network::CUser &user);
|
||||||
|
|||||||
@@ -250,9 +250,9 @@
|
|||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QLineEdit" name="le_Copilot">
|
<widget class="QLineEdit" name="le_PartnerCallsign">
|
||||||
<property name="placeholderText">
|
<property name="placeholderText">
|
||||||
<string>partner callsign</string>
|
<string>partner callsign (pilot/co-pilot)</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -276,7 +276,7 @@
|
|||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="lbl_Copilot">
|
<widget class="QLabel" name="lbl_Copilot">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Co/Pilot callsign</string>
|
<string>Partner callsign</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -418,7 +418,7 @@
|
|||||||
<tabstop>comp_VatsimServers</tabstop>
|
<tabstop>comp_VatsimServers</tabstop>
|
||||||
<tabstop>pb_DetailsVatsim</tabstop>
|
<tabstop>pb_DetailsVatsim</tabstop>
|
||||||
<tabstop>pb_OverrideCredentialsVatsim</tabstop>
|
<tabstop>pb_OverrideCredentialsVatsim</tabstop>
|
||||||
<tabstop>le_Copilot</tabstop>
|
<tabstop>le_PartnerCallsign</tabstop>
|
||||||
<tabstop>comp_OtherServers</tabstop>
|
<tabstop>comp_OtherServers</tabstop>
|
||||||
<tabstop>pb_RefreshOtherServers</tabstop>
|
<tabstop>pb_RefreshOtherServers</tabstop>
|
||||||
<tabstop>pb_OtherServersGotoSettings</tabstop>
|
<tabstop>pb_OtherServersGotoSettings</tabstop>
|
||||||
|
|||||||
Reference in New Issue
Block a user