mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
refs #320 port Network to new vatlib
* CNetworkVatlib * Contexts * Samples
This commit is contained in:
@@ -105,11 +105,10 @@ namespace BlackCore
|
||||
* Connection status changed
|
||||
* \param from old status
|
||||
* \param to new status
|
||||
* \param message further details
|
||||
* \remarks If I use the enum, adaptor / interface are not created correctly
|
||||
* \see INetwork::ConnectionStatus
|
||||
*/
|
||||
void connectionStatusChanged(uint from, uint to, const QString &message);
|
||||
void connectionStatusChanged(uint from, uint to);
|
||||
|
||||
//! Text messages received (also private chat messages, rfaio channel messages)
|
||||
void textMessagesReceived(const BlackMisc::Network::CTextMessageList &textMessages);
|
||||
|
||||
@@ -288,7 +288,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Connection status changed
|
||||
*/
|
||||
void CContextNetwork::ps_fsdConnectionStatusChanged(INetwork::ConnectionStatus from, INetwork::ConnectionStatus to, const QString &message)
|
||||
void CContextNetwork::ps_fsdConnectionStatusChanged(INetwork::ConnectionStatus from, INetwork::ConnectionStatus to)
|
||||
{
|
||||
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << from << to;
|
||||
auto fromOld = this->m_currentStatus;
|
||||
@@ -310,15 +310,15 @@ namespace BlackCore
|
||||
// send as message
|
||||
if (to == INetwork::DisconnectedError)
|
||||
{
|
||||
CLogMessage(this).error("Connection status changed from %1 to %2 %3") << INetwork::connectionStatusToString(from) << INetwork::connectionStatusToString(to) << message;
|
||||
CLogMessage(this).error("Connection status changed from %1 to %2") << INetwork::connectionStatusToString(from) << INetwork::connectionStatusToString(to);
|
||||
}
|
||||
else
|
||||
{
|
||||
CLogMessage(this).info("Connection status changed from %1 to %2 %3") << INetwork::connectionStatusToString(from) << INetwork::connectionStatusToString(to) << message;
|
||||
CLogMessage(this).info("Connection status changed from %1 to %2") << INetwork::connectionStatusToString(from) << INetwork::connectionStatusToString(to);
|
||||
}
|
||||
|
||||
// send as own signal
|
||||
emit this->connectionStatusChanged(from, to, message);
|
||||
emit this->connectionStatusChanged(from, to);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -196,7 +196,7 @@ namespace BlackCore
|
||||
* \param from old status
|
||||
* \param to new status
|
||||
*/
|
||||
void ps_fsdConnectionStatusChanged(INetwork::ConnectionStatus from, INetwork::ConnectionStatus to, const QString &message);
|
||||
void ps_fsdConnectionStatusChanged(INetwork::ConnectionStatus from, INetwork::ConnectionStatus to);
|
||||
|
||||
//! Radio text messages received
|
||||
void ps_fsdTextMessageReceived(const BlackMisc::Network::CTextMessageList &messages);
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace BlackCore
|
||||
void CContextNetworkProxy::relaySignals(const QString &serviceName, QDBusConnection &connection)
|
||||
{
|
||||
bool s = connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(),
|
||||
"connectionStatusChanged", this, SIGNAL(connectionStatusChanged(uint, uint, const QString &)));
|
||||
"connectionStatusChanged", this, SIGNAL(connectionStatusChanged(uint, uint)));
|
||||
Q_ASSERT(s);
|
||||
s = connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(),
|
||||
"changedAtcStationsBooked", this, SIGNAL(changedAtcStationsBooked()));
|
||||
|
||||
@@ -144,18 +144,6 @@ namespace BlackCore
|
||||
*/
|
||||
virtual bool isPendingConnection() const = 0;
|
||||
|
||||
/*!
|
||||
* Returns a list of URLs where network status data can be found.
|
||||
* To obtain the status, one of these URLs should be picked at random.
|
||||
*/
|
||||
virtual QList<QUrl> getStatusUrls() const = 0;
|
||||
|
||||
/*!
|
||||
* Returns a list of known servers which may be connected to.
|
||||
* Not all servers may be accepting connections; consult the CServer::isAcceptingConnections method.
|
||||
*/
|
||||
virtual BlackMisc::Network::CServerList getKnownServers() const = 0;
|
||||
|
||||
public slots:
|
||||
////////////////////////////////////////////////////////////////
|
||||
//! \name Network slots
|
||||
@@ -478,7 +466,7 @@ namespace BlackCore
|
||||
/*!
|
||||
* The status of our connection has changed.
|
||||
*/
|
||||
void connectionStatusChanged(ConnectionStatus oldStatus, ConnectionStatus newStatus, QString errorMessage = "");
|
||||
void connectionStatusChanged(ConnectionStatus oldStatus, ConnectionStatus newStatus);
|
||||
|
||||
/*!
|
||||
* We received a reply to one of our pings.
|
||||
@@ -490,7 +478,7 @@ namespace BlackCore
|
||||
* We received a reply to one of our queries.
|
||||
* \sa sendCapabilitiesQuery
|
||||
*/
|
||||
void capabilitiesReplyReceived(const BlackMisc::Aviation::CCallsign &callsign, quint32 capabilitiesFlags);
|
||||
void capabilitiesReplyReceived(const BlackMisc::Aviation::CCallsign &callsign, int capabilitiesFlags);
|
||||
|
||||
/*!
|
||||
* We received a reply to one of our queries.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -9,7 +9,7 @@
|
||||
#define BLACKCORE_NETWORK_VATLIB_H
|
||||
|
||||
#include "network.h"
|
||||
#include <vatlib/vatlib.h>
|
||||
#include <vatlib/vatlib2.h>
|
||||
#include <QScopedPointer>
|
||||
#include <QTimer>
|
||||
#include <QTextCodec>
|
||||
@@ -33,16 +33,10 @@ namespace BlackCore
|
||||
virtual ~CNetworkVatlib();
|
||||
|
||||
//! \copydoc INetwork::isConnected()
|
||||
virtual bool isConnected() const override { return m_status == Cvatlib_Network::connStatus_Connected; }
|
||||
virtual bool isConnected() const override { return m_status == vatStatusConnected; }
|
||||
|
||||
//! \copydoc INetwork::pendingConnection()
|
||||
virtual bool isPendingConnection() const override { return m_status == Cvatlib_Network::connStatus_Connecting; }
|
||||
|
||||
//! \copydoc INetwork::getStatusUrls()
|
||||
virtual QList<QUrl> getStatusUrls() const override;
|
||||
|
||||
//! \copydoc INetwork::getKnownServers()
|
||||
virtual BlackMisc::Network::CServerList getKnownServers() const override;
|
||||
virtual bool isPendingConnection() const override { return m_status == vatStatusConnecting; }
|
||||
|
||||
// Network slots
|
||||
//! \copydoc INetwork::presetLoginMode
|
||||
@@ -93,29 +87,31 @@ namespace BlackCore
|
||||
void sendAircraftInfo(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
private: //shimlib callbacks
|
||||
static void onConnectionStatusChanged(Cvatlib_Network *, Cvatlib_Network::connStatus oldStatus, Cvatlib_Network::connStatus newStatus, void *cbvar);
|
||||
static void onTextMessageReceived(Cvatlib_Network *, const char *from, const char *to, const char *msg, void *cbvar);
|
||||
static void onRadioMessageReceived(Cvatlib_Network *, const char *from, INT numFreq, INT *freqList, const char *msg, void *cbvar);
|
||||
static void onControllerDisconnected(Cvatlib_Network *, const char *callsign, void *cbvar);
|
||||
static void onInterimPilotPositionUpdate(Cvatlib_Network *, const char *callsign, Cvatlib_Network::PilotPosUpdate pos, void *cbvar);
|
||||
static void onAtcPositionUpdate(Cvatlib_Network *, const char *callsign, Cvatlib_Network::ATCPosUpdate pos, void *cbvar);
|
||||
static void onKicked(Cvatlib_Network *, const char *reason, void *cbvar);
|
||||
static void onPong(Cvatlib_Network *, const char *callsign, INT elapsedTime, void *cbvar);
|
||||
static void onMetarReceived(Cvatlib_Network *, const char *data, void *cbvar);
|
||||
static void onInfoQueryRequestReceived(Cvatlib_Network *, const char *callsign, Cvatlib_Network::infoQuery type, const char *data, void *cbvar);
|
||||
static void onInfoQueryReplyReceived(Cvatlib_Network *, const char *callsign, Cvatlib_Network::infoQuery type, const char *data, const char *data2, void *cbvar);
|
||||
static void onCapabilitiesReplyReceived(Cvatlib_Network *, const char *callsign, const char **keysValues, void *cbvar);
|
||||
static void onAtisReplyReceived(Cvatlib_Network *, const char *callsign, Cvatlib_Network::atisLineType type, const char *data, void *cbvar);
|
||||
static void onFlightPlanReceived(Cvatlib_Network *, const char *callsign, Cvatlib_Network::FlightPlan fp, void *cbvar);
|
||||
static void onTemperatureDataReceived(Cvatlib_Network *, Cvatlib_Network::TempLayer layers[4], INT pressure, void *cbvar);
|
||||
static void onErrorReceived(Cvatlib_Network *, Cvatlib_Network::error type, const char *msg, const char *data, void *cbvar);
|
||||
static void onWindDataReceived(Cvatlib_Network *, Cvatlib_Network::WindLayer layers[4], void *cbvar);
|
||||
static void onCloudDataReceived(Cvatlib_Network *, Cvatlib_Network::CloudLayer layers[2], Cvatlib_Network::StormLayer storm, float vis, void *cbvar);
|
||||
static void onPilotDisconnected(Cvatlib_Network *, const char *callsign, void *cbvar);
|
||||
static void onPilotInfoRequestReceived(Cvatlib_Network *, const char *callsign, void *cbvar);
|
||||
static void onPilotInfoReceived(Cvatlib_Network *, const char *callsign, const char **keysValues, void *cbvar);
|
||||
static void onPilotPositionUpdate(Cvatlib_Network *, const char *callsign, Cvatlib_Network::PilotPosUpdate pos, void *cbvar);
|
||||
static void onCustomPacketReceived(Cvatlib_Network *, const char *callsign, const char *packetId, const char **data, INT dataSize, void *cbvar);
|
||||
static void onConnectionStatusChanged(VatSessionID, VatConnectionStatus oldStatus, VatConnectionStatus newStatus, void *cbvar);
|
||||
static void onTextMessageReceived(VatSessionID, const char *from, const char *to, const char *msg, void *cbvar);
|
||||
|
||||
static void onRadioMessageReceived(VatSessionID, const char *from, int freqCount, int *freqList, const char *message, void *cbvar);
|
||||
|
||||
static void onControllerDisconnected(VatSessionID, const char *callsign, void *cbvar);
|
||||
static void onInterimPilotPositionUpdate(VatSessionID, const char *callsign, const VatPilotPosition *position, void *cbvar);
|
||||
static void onAtcPositionUpdate(VatSessionID, const char *callsign, const VatAtcPosition *pos, void *cbvar);
|
||||
static void onKicked(VatSessionID, const char *reason, void *cbvar);
|
||||
static void onPong(VatSessionID, const char *sender, double elapsedTime, void *cbvar);
|
||||
static void onMetarReceived(VatSessionID, const char *data, void *cbvar);
|
||||
static void onInfoQueryRequestReceived(VatSessionID, const char *callsign, VatInfoQueryType type, const char *data, void *cbvar);
|
||||
static void onInfoQueryReplyReceived(VatSessionID, const char *callsign, VatInfoQueryType type, const char *data, const char *data2, void *cbvar);
|
||||
static void onCapabilitiesReplyReceived(VatSessionID, const char *callsign, int capabilityFlags, void *cbvar);
|
||||
static void onAtisReplyReceived(VatSessionID, const char *callsign, const VatControllerAtis *atis, void *cbvar);
|
||||
static void onFlightPlanReceived(VatSessionID, const char *callsign, const VatFlightPlan *fp, void *cbvar);
|
||||
static void onTemperatureDataReceived(VatSessionID, const VatTempLayer layer[4], int pressure, void *cbvar);
|
||||
static void onWindDataReceived(VatSessionID, const VatWindLayer layer[4], void *cbvar);
|
||||
static void onCloudDataReceived(VatSessionID, const VatCloudLayer cloudLayer[2], VatThunderStormLayer thunderStormLayer, float visibility, void *cbvar);
|
||||
static void onErrorReceived(VatSessionID, VatServerError error, const char *msg, const char *data, void *cbvar);
|
||||
static void onPilotDisconnected(VatSessionID, const char *callsign, void *cbvar);
|
||||
static void onPilotInfoRequestReceived(VatSessionID, const char *callsign, void *cbvar);
|
||||
static void onPilotInfoReceived(VatSessionID, const char *callsign, const VatAircraftInfo *aircraftInfo, void *cbvar);
|
||||
static void onPilotPositionUpdate(VatSessionID, const char *callsign, const VatPilotPosition *position, void *cbvar);
|
||||
static void onCustomPacketReceived(VatSessionID, const char *callsign, const char *packetId, const char **data, int dataSize, void *cbvar);
|
||||
|
||||
private:
|
||||
QByteArray toFSD(QString qstr) const;
|
||||
@@ -125,9 +121,9 @@ namespace BlackCore
|
||||
QStringList fromFSD(const char **cstrArray, int size) const;
|
||||
|
||||
void initializeSession();
|
||||
void changeConnectionStatus(Cvatlib_Network::connStatus newStatus, QString errorMessage = "");
|
||||
bool isDisconnected() const { return m_status != Cvatlib_Network::connStatus_Connecting && m_status != Cvatlib_Network::connStatus_Connected; }
|
||||
QString getSocketError() const;
|
||||
void changeConnectionStatus(VatConnectionStatus newStatus);
|
||||
bool isDisconnected() const { return m_status != vatStatusConnecting && m_status != vatStatusConnected; }
|
||||
static void networkErrorHandler(const char *message);
|
||||
|
||||
private slots:
|
||||
void process();
|
||||
@@ -142,18 +138,17 @@ namespace BlackCore
|
||||
struct VatlibQScopedPointerDeleter
|
||||
{
|
||||
//! Called by QScopedPointer destructor
|
||||
static void cleanup(Cvatlib_Network *net) { if (net) net->Destroy(); }
|
||||
static void cleanup(VatSessionID session) { if (session) Vat_DestroyNetworkSession(session); }
|
||||
};
|
||||
|
||||
private:
|
||||
QScopedPointer<Cvatlib_Network, VatlibQScopedPointerDeleter> m_net;
|
||||
QScopedPointer<PCSBClient, VatlibQScopedPointerDeleter> m_net;
|
||||
LoginMode m_loginMode;
|
||||
Cvatlib_Network::connStatus m_status;
|
||||
VatConnectionStatus m_status;
|
||||
BlackMisc::Network::CServer m_server;
|
||||
BlackMisc::Aviation::CCallsign m_callsign;
|
||||
BlackMisc::Aviation::CAircraftIcao m_icaoCode;
|
||||
BlackMisc::Aviation::CAircraft m_ownAircraft; // not using callsign, user, or icao parts of this member because they can't be changed when connected
|
||||
QMap<BlackMisc::Aviation::CCallsign, BlackMisc::Aviation::CInformationMessage> m_atisParts;
|
||||
|
||||
QTimer m_processingTimer;
|
||||
QTimer m_updateTimer;
|
||||
|
||||
@@ -191,12 +191,11 @@ namespace BlackGui
|
||||
this->m_timestampBookedStationsChanged = QDateTime::currentDateTimeUtc();
|
||||
}
|
||||
|
||||
void CAtcStationComponent::ps_connectionStatusChanged(uint from, uint to, const QString &message)
|
||||
void CAtcStationComponent::ps_connectionStatusChanged(uint from, uint to)
|
||||
{
|
||||
INetwork::ConnectionStatus fromStatus = static_cast<INetwork::ConnectionStatus>(from);
|
||||
INetwork::ConnectionStatus toStatus = static_cast<INetwork::ConnectionStatus>(to);
|
||||
Q_UNUSED(fromStatus);
|
||||
Q_UNUSED(message);
|
||||
if (INetwork::isDisconnectedStatus(toStatus))
|
||||
{
|
||||
this->ui->tvp_AtcStationsOnline->clear();
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace BlackGui
|
||||
void ps_changedAtcStationsOnline();
|
||||
|
||||
//! Connection status has been changed
|
||||
void ps_connectionStatusChanged(uint from, uint to, const QString &message);
|
||||
void ps_connectionStatusChanged(uint from, uint to);
|
||||
|
||||
//! Request dummy ATC online stations
|
||||
void ps_testCreateDummyOnlineAtcStations(int number);
|
||||
|
||||
@@ -113,12 +113,11 @@ namespace BlackGui
|
||||
Q_UNUSED(paused);
|
||||
}
|
||||
|
||||
void CInfoBarStatusComponent::ps_onNetworkConnectionChanged(uint from, uint to, const QString &message)
|
||||
void CInfoBarStatusComponent::ps_onNetworkConnectionChanged(uint from, uint to)
|
||||
{
|
||||
INetwork::ConnectionStatus fromStatus = static_cast<INetwork::ConnectionStatus>(from);
|
||||
INetwork::ConnectionStatus toStatus = static_cast<INetwork::ConnectionStatus>(to);
|
||||
Q_UNUSED(fromStatus);
|
||||
Q_UNUSED(message);
|
||||
|
||||
switch (toStatus)
|
||||
{
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace BlackGui
|
||||
void ps_onSimulatorStatusChanged(bool connected, bool running, bool paused);
|
||||
|
||||
//! Network connection has been changed
|
||||
void ps_onNetworkConnectionChanged(uint from, uint to, const QString &message);
|
||||
void ps_onNetworkConnectionChanged(uint from, uint to);
|
||||
|
||||
//! Context menu requested
|
||||
void ps_customAudioContextMenuRequested(const QPoint &position);
|
||||
|
||||
@@ -129,13 +129,12 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CMainKeypadAreaComponent::ps_connectionStatusChanged(uint from, uint to, const QString &message)
|
||||
void CMainKeypadAreaComponent::ps_connectionStatusChanged(uint from, uint to)
|
||||
{
|
||||
INetwork::ConnectionStatus statusFrom = static_cast<INetwork::ConnectionStatus>(from);
|
||||
INetwork::ConnectionStatus statusTo = static_cast<INetwork::ConnectionStatus>(to);
|
||||
|
||||
Q_UNUSED(statusFrom);
|
||||
Q_UNUSED(message);
|
||||
|
||||
// Connected button
|
||||
if (statusTo == INetwork::Connected)
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace BlackGui
|
||||
void ps_buttonSelected();
|
||||
|
||||
//! \copydoc BlackCore::IContextNetwork::connectionStatusChanged
|
||||
void ps_connectionStatusChanged(uint from, uint to, const QString &message);
|
||||
void ps_connectionStatusChanged(uint from, uint to);
|
||||
|
||||
//! Command line entered
|
||||
void ps_commandEntered();
|
||||
|
||||
@@ -36,7 +36,8 @@ namespace BlackMisc
|
||||
{
|
||||
VFR = 0, //!< Visual flight rules
|
||||
IFR, //!< Instrument flight rules
|
||||
SVFR //!< Special VFR (reserved for ATC use)
|
||||
SVFR, //!< Special VFR (reserved for ATC use),
|
||||
DVFR //!< Defense VFR
|
||||
};
|
||||
|
||||
static const int MaxRemarksLength = 150; //!< Max remarks length
|
||||
|
||||
@@ -216,7 +216,7 @@ void SwiftGuiStd::ps_onConnectionTerminated()
|
||||
/*
|
||||
* Connection status changed
|
||||
*/
|
||||
void SwiftGuiStd::ps_onConnectionStatusChanged(uint /** from **/, uint to, const QString & /* message */)
|
||||
void SwiftGuiStd::ps_onConnectionStatusChanged(uint /** from **/, uint to)
|
||||
{
|
||||
this->updateGuiStatusInformation();
|
||||
INetwork::ConnectionStatus newStatus = static_cast<INetwork::ConnectionStatus>(to);
|
||||
|
||||
@@ -200,7 +200,7 @@ private slots:
|
||||
* \param from old status, as uint so it is compliant with DBus
|
||||
* \param to new status, as uint so it is compliant with DBus
|
||||
*/
|
||||
void ps_onConnectionStatusChanged(uint from, uint to, const QString &message);
|
||||
void ps_onConnectionStatusChanged(uint from, uint to);
|
||||
|
||||
//
|
||||
// GUI related slots
|
||||
|
||||
Reference in New Issue
Block a user