refs #242, adjusted network context

* some formatting
* own aircraft data used for voice room member resolution
This commit is contained in:
Klaus Basan
2014-05-28 13:19:31 +02:00
parent f1ac4deda6
commit b6afcefd59
5 changed files with 47 additions and 22 deletions

View File

@@ -53,6 +53,9 @@ namespace BlackCore
//! ATC station (booked) list has been changed
void changedAtcStationsBooked();
//! Connection status changed for online station
void changedAtcStationOnlineConnectionStatus(const BlackMisc::Aviation::CAtcStation &atcStation, bool connected);
//! Aircraft list has been changed
void changedAircraftsInRange();

View File

@@ -145,8 +145,12 @@ namespace BlackCore
CAtcStation s;
CAtcStationList stations;
stations.push_back(stationsCom1.isEmpty() ? s : stationsCom1[0]);
stations.push_back(stationsCom2.isEmpty() ? s : stationsCom2[0]);
CAtcStation com1 = stationsCom1.isEmpty() ? s : stationsCom1[0];
CAtcStation com2 = stationsCom2.isEmpty() ? s : stationsCom2[0];
stations.push_back(com1);
stations.push_back(com2);
return stations;
}
@@ -168,7 +172,6 @@ namespace BlackCore
*/
void CContextNetwork::psFsdAtcPositionUpdate(const CCallsign &callsign, const BlackMisc::PhysicalQuantities::CFrequency &frequency, const CCoordinateGeodetic &position, const BlackMisc::PhysicalQuantities::CLength &range)
{
// this->log(Q_FUNC_INFO, callsign.toQString(), frequency.toQString(), position.toQString(), range.toQString());
CAtcStationList stationsWithCallsign = this->m_atcStationsOnline.findByCallsign(callsign);
if (stationsWithCallsign.isEmpty())
{
@@ -182,14 +185,17 @@ namespace BlackCore
station.calculcateDistanceToPlane(this->ownAircraft().getPosition());
this->m_vatsimDataFileReader->getAtcStations().updateFromVatsimDataFileStation(station); // prefill
this->m_atcStationsOnline.push_back(station);
emit this->changedAtcStationsOnline();
if (this->isConnected())
{
emit this->m_network->sendAtisQuery(callsign); // request ATIS
emit this->m_network->sendRealNameQuery(callsign);
emit this->m_network->sendAtisQuery(callsign); // request ATIS and voice rooms
emit this->m_network->sendServerQuery(callsign);
}
emit this->changedAtcStationsOnline();
// Remark: this->changedAtcStationOnlineConnectionStatus(station, true);
// will be sent in psFsdAtisVoiceRoomQueryReceived
}
else
{
@@ -208,8 +214,15 @@ namespace BlackCore
*/
void CContextNetwork::psFsdAtcControllerDisconnected(const CCallsign &callsign)
{
this->m_atcStationsOnline.removeIf(&CAtcStation::getCallsign, callsign);
emit this->changedAtcStationsOnline();
if (this->m_atcStationsOnline.contains(&CAtcStation::getCallsign, callsign))
{
CAtcStation removeStation = this->m_atcStationsOnline.findByCallsign(callsign).front();
this->m_atcStationsOnline.removeIf(&CAtcStation::getCallsign, callsign);
emit this->changedAtcStationsOnline();
emit this->changedAtcStationOnlineConnectionStatus(removeStation, false);
}
// booked
this->m_atcStationsBooked.applyIf(&CAtcStation::getCallsign, callsign, CIndexVariantMap(CAtcStation::IndexIsOnline, QVariant(false)));
}
@@ -235,7 +248,12 @@ namespace BlackCore
CIndexVariantMap vm(CAtcStation::IndexVoiceRoomUrl, trimmedUrl);
this->m_atcStationsOnline.applyIf(&CAtcStation::getCallsign, callsign, vm);
this->m_atcStationsBooked.applyIf(&CAtcStation::getCallsign, callsign, vm);
if (this->m_atcStationsOnline.contains(&CAtcStation::getCallsign, callsign)) emit this->changedAtcStationsBooked();
if (this->m_atcStationsOnline.contains(&CAtcStation::getCallsign, callsign))
{
CAtcStation station = this->m_atcStationsOnline.findFirstByCallsign(callsign);
emit this->changedAtcStationsBooked();
emit this->changedAtcStationOnlineConnectionStatus(station, true);
}
if (this->m_atcStationsBooked.contains(&CAtcStation::getCallsign, callsign)) emit this->changedAtcStationsBooked();
}
@@ -267,7 +285,6 @@ namespace BlackCore
*/
void CContextNetwork::psFsdMetarReceived(const QString &metarMessage)
{
// this->log(Q_FUNC_INFO, metarMessage);
if (metarMessage.length() < 10) return; // invalid
const QString icaoCode = metarMessage.left(4).toUpper();
const QString icaoCodeTower = icaoCode + "_TWR";

View File

@@ -314,6 +314,14 @@ namespace BlackCore
if (callsigns.isEmpty()) return users;
CCallsignList searchList(callsigns);
// myself, which is not in the lists below
CAircraft ownAircraft = this->getOwnAircraft();
if (!ownAircraft.getCallsign().isEmpty() && searchList.contains(ownAircraft.getCallsign()))
{
searchList.remove(ownAircraft.getCallsign());
users.push_back(ownAircraft.getPilot());
}
// do aircrafts first, this will handle most callsigns
foreach(CAircraft aircraft, this->m_aircraftsInRange)
{
@@ -408,7 +416,7 @@ namespace BlackCore
}
// send as message
QString m("connection status changed from %1 to %2");
QString m("Connection status changed from %1 to %2");
m = m.arg(INetwork::connectionStatusToString(from), INetwork::connectionStatusToString(to));
if (!message.isEmpty()) m.append(" ").append(message);
msgs.push_back(CStatusMessage(CStatusMessage::TypeTrafficNetwork,

View File

@@ -37,6 +37,9 @@ namespace BlackCore
s = connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(),
"changedAtcStationsOnline", this, SIGNAL(changedAtcStationsOnline()));
Q_ASSERT(s);
s = connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(),
"changedAtcStationOnlineConnectionStatus", this, SIGNAL(changedAtcStationOnlineConnectionStatus(BlackMisc::Aviation::CAtcStation,bool)));
Q_ASSERT(s);
s = connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(),
"connectionTerminated", this, SIGNAL(connectionTerminated()));
Q_ASSERT(s);

View File

@@ -20,7 +20,7 @@
namespace BlackCore
{
//! \brief Network context proxy
//! Network context proxy
class CContextNetworkProxy : public IContextNetwork
{
Q_OBJECT
@@ -34,14 +34,14 @@ namespace BlackCore
private:
BlackMisc::CGenericDBusInterface *m_dBusInterface; /*!< DBus interface */
//! \brief Relay connection signals to local signals.
//! Relay connection signals to local signals.
void relaySignals(const QString &serviceName, QDBusConnection &connection);
protected:
//! \brief Constructor
//! Constructor
CContextNetworkProxy(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : IContextNetwork(mode, runtime), m_dBusInterface(nullptr) {}
//! \brief DBus version constructor
//! DBus version constructor
CContextNetworkProxy(const QString &serviceName, QDBusConnection &connection, CRuntimeConfig::ContextMode mode, CRuntime *runtime);
public slots: // IContextNetwork overrides
@@ -49,16 +49,10 @@ namespace BlackCore
//! \copydoc IContextNetwork::readAtcBookingsFromSource()
virtual void readAtcBookingsFromSource() const override;
/*!
* \copydoc IContextNetwork::getAtcStationsOnline()
* \todo If I make this &getAtcStations XML is not generated correctly, needs to be crosschecked with the latest version of Qt
*/
//! \copydoc IContextNetwork::getAtcStationsOnline()
virtual const BlackMisc::Aviation::CAtcStationList getAtcStationsOnline() const override;
/*!
* \copydoc IContextNetwork::getAtcStationsBooked()
* \todo If I make this &getAtcStations XML is not generated correctly
*/
//! \copydoc IContextNetwork::getAtcStationsBooked()
virtual const BlackMisc::Aviation::CAtcStationList getAtcStationsBooked() const override;
//! \copydoc IContextNetwork::getAircraftsInRange()