mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-08-10 11:36:08 +08:00
refs #234, add methods to resolve user names from VATSIM file and display them in voice rooms
This commit is contained in:
@@ -339,11 +339,20 @@ namespace BlackCore
|
||||
}
|
||||
|
||||
// we might have unresolved callsigns
|
||||
// these are the ones not in range
|
||||
foreach(CCallsign callsign, searchList)
|
||||
{
|
||||
CUser user;
|
||||
user.setCallsign(callsign);
|
||||
users.push_back(user);
|
||||
CUserList usersByCallsign = this->m_vatsimDataFileReader->getUsersForCallsign(callsign);
|
||||
if (usersByCallsign.isEmpty())
|
||||
{
|
||||
CUser user;
|
||||
user.setCallsign(callsign);
|
||||
users.push_back(user);
|
||||
}
|
||||
else
|
||||
{
|
||||
users.push_back(usersByCallsign[0]);
|
||||
}
|
||||
}
|
||||
return users;
|
||||
}
|
||||
@@ -365,11 +374,7 @@ namespace BlackCore
|
||||
if (callsigns.isEmpty()) return clients;
|
||||
foreach(CCallsign callsign, callsigns)
|
||||
{
|
||||
CClientList clientsForCallsign = this->m_otherClients.findBy(&CClient::getCallsign, callsign);
|
||||
foreach(CClient c, clientsForCallsign)
|
||||
{
|
||||
clients.push_back(c);
|
||||
}
|
||||
clients.push_back(this->m_otherClients.findBy(&CClient::getCallsign, callsign));
|
||||
}
|
||||
return clients;
|
||||
}
|
||||
|
||||
@@ -44,6 +44,61 @@ namespace BlackCore
|
||||
this->m_updateTimer->start(updatePeriodMs);
|
||||
}
|
||||
|
||||
CUserList CVatsimDataFileReader::getPilotsForCallsigns(const CCallsignList &callsigns)
|
||||
{
|
||||
CUserList users;
|
||||
if (callsigns.isEmpty()) return users;
|
||||
foreach(CCallsign callsign, callsigns)
|
||||
{
|
||||
users.push_back(this->m_aircrafts.findByCallsign(callsign).getPilots());
|
||||
}
|
||||
return users;
|
||||
}
|
||||
|
||||
CUserList CVatsimDataFileReader::getPilotsForCallsign(const CCallsign &callsign)
|
||||
{
|
||||
CCallsignList callsigns;
|
||||
callsigns.push_back(callsign);
|
||||
return this->getPilotsForCallsigns(callsigns);
|
||||
}
|
||||
|
||||
CUserList CVatsimDataFileReader::getControllersForCallsign(const CCallsign &callsign)
|
||||
{
|
||||
CCallsignList callsigns;
|
||||
callsigns.push_back(callsign);
|
||||
return this->getControllersForCallsigns(callsigns);
|
||||
}
|
||||
|
||||
CUserList CVatsimDataFileReader::getUsersForCallsign(const CCallsign &callsign)
|
||||
{
|
||||
CCallsignList callsigns;
|
||||
callsigns.push_back(callsign);
|
||||
return this->getUsersForCallsigns(callsigns);
|
||||
}
|
||||
|
||||
CUserList CVatsimDataFileReader::getControllersForCallsigns(const CCallsignList &callsigns)
|
||||
{
|
||||
CUserList users;
|
||||
if (callsigns.isEmpty()) return users;
|
||||
foreach(CCallsign callsign, callsigns)
|
||||
{
|
||||
users.push_back(this->m_atcStations.findByCallsign(callsign).getControllers());
|
||||
}
|
||||
return users;
|
||||
}
|
||||
|
||||
CUserList CVatsimDataFileReader::getUsersForCallsigns(const CCallsignList &callsigns)
|
||||
{
|
||||
CUserList users;
|
||||
if (callsigns.isEmpty()) return users;
|
||||
foreach(CCallsign callsign, callsigns)
|
||||
{
|
||||
users.push_back(this->getPilotsForCallsign(callsign));
|
||||
users.push_back(this->getControllersForCallsign(callsign));
|
||||
}
|
||||
return users;
|
||||
}
|
||||
|
||||
/*
|
||||
* Data file read from XML
|
||||
*/
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
#include "blackmisc/avatcstationlist.h"
|
||||
#include "blackmisc/avaircraftlist.h"
|
||||
#include "blackmisc/nwserverlist.h"
|
||||
#include "blackmisc/nwuserlist.h"
|
||||
#include "blackmisc/avcallsignlist.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QTimer>
|
||||
#include <QNetworkReply>
|
||||
@@ -50,6 +53,23 @@ namespace BlackCore
|
||||
//! Get all voice servers
|
||||
const BlackMisc::Network::CServerList &getVoiceServers() { return this->m_voiceServers; }
|
||||
|
||||
//! Users for callsign(s)
|
||||
BlackMisc::Network::CUserList getUsersForCallsigns(const BlackMisc::Aviation::CCallsignList &callsigns);
|
||||
|
||||
//! User for callsign
|
||||
BlackMisc::Network::CUserList getUsersForCallsign(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
//! Controllers for callsigns
|
||||
BlackMisc::Network::CUserList getControllersForCallsigns(const BlackMisc::Aviation::CCallsignList &callsigns);
|
||||
|
||||
//! Controllers for callsign
|
||||
BlackMisc::Network::CUserList getControllersForCallsign(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
//! Users for callsigns
|
||||
BlackMisc::Network::CUserList getPilotsForCallsigns(const BlackMisc::Aviation::CCallsignList &callsigns);
|
||||
|
||||
//! Users for callsign
|
||||
BlackMisc::Network::CUserList getPilotsForCallsign(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
private slots:
|
||||
//! Data have been read
|
||||
|
||||
@@ -47,6 +47,20 @@ namespace BlackMisc
|
||||
return this->findBy(&CAircraft::getCallsign, callsign);
|
||||
}
|
||||
|
||||
/*
|
||||
* All pilots
|
||||
*/
|
||||
CUserList CAircraftList::getPilots() const
|
||||
{
|
||||
CUserList users;
|
||||
for (auto i = this->begin(); i != this->end(); ++i)
|
||||
{
|
||||
CAircraft aircraft = *i;
|
||||
if (aircraft.getPilot().isValid()) users.push_back(aircraft.getPilot());
|
||||
}
|
||||
return users;
|
||||
}
|
||||
|
||||
/*
|
||||
* Aircrafts within range
|
||||
*/
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#define BLACKMISC_AIRCRAFTLIST_H
|
||||
|
||||
#include "avaircraft.h"
|
||||
#include "nwuserlist.h"
|
||||
#include "collection.h"
|
||||
#include "sequence.h"
|
||||
#include <QObject>
|
||||
@@ -43,6 +44,8 @@ namespace BlackMisc
|
||||
CAircraftList findByCallsign(const CCallsign &callsign) const;
|
||||
|
||||
//! All pilots (with valid data)
|
||||
BlackMisc::Network::CUserList getPilots() const;
|
||||
|
||||
/*!
|
||||
* Find 0..n stations within range of given coordinate
|
||||
* \param coordinate other position
|
||||
|
||||
@@ -79,6 +79,21 @@ namespace BlackMisc
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* All pilots
|
||||
*/
|
||||
CUserList CAtcStationList::getControllers() const
|
||||
{
|
||||
CUserList users;
|
||||
for (auto i = this->begin(); i != this->end(); ++i)
|
||||
{
|
||||
CAtcStation station = *i;
|
||||
if (station.getController().isValid()) users.push_back(station.getController());
|
||||
}
|
||||
return users;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Merge with booking
|
||||
*/
|
||||
@@ -160,7 +175,6 @@ namespace BlackMisc
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Merge with VATSIM data file
|
||||
*/
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#ifndef BLACKMISC_ATCSTATIONLIST_H
|
||||
#define BLACKMISC_ATCSTATIONLIST_H
|
||||
|
||||
#include "nwuserlist.h"
|
||||
#include "avatcstation.h"
|
||||
#include "collection.h"
|
||||
#include "sequence.h"
|
||||
@@ -49,6 +50,8 @@ namespace BlackMisc
|
||||
CAtcStationList findIfComUnitTunedIn25KHz(const BlackMisc::Aviation::CComSystem &comUnit) const;
|
||||
|
||||
//! All controllers (with valid data)
|
||||
BlackMisc::Network::CUserList getControllers() const;
|
||||
|
||||
//! Update distances to coordinate, usually own aircraft's position
|
||||
void calculateDistancesToPlane(const BlackMisc::Geo::CCoordinateGeodetic &position);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user