mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-09 05:28:09 +08:00
committed by
Mathew Sutcliffe
parent
51cbd2a394
commit
1c1fdabd2e
@@ -1,10 +1,12 @@
|
||||
#include "avatcstation.h"
|
||||
#include "aviocomsystem.h"
|
||||
#include "vvoiceroom.h"
|
||||
#include "blackmiscfreefunctions.h"
|
||||
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackMisc::Geo;
|
||||
using namespace BlackMisc::Network;
|
||||
using namespace BlackMisc::Voice;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
@@ -142,7 +144,7 @@ namespace BlackMisc
|
||||
(void)QT_TRANSLATE_NOOP("Aviation", "until(UTC)");
|
||||
(void)QT_TRANSLATE_NOOP("Aviation", "range");
|
||||
(void)QT_TRANSLATE_NOOP("Aviation", "distance");
|
||||
|
||||
(void)QT_TRANSLATE_NOOP("Network", "voiceroom");
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -161,6 +163,7 @@ namespace BlackMisc
|
||||
argument << this->m_bookedUntilUtc;
|
||||
argument << this->m_atis;
|
||||
argument << this->m_metar;
|
||||
argument << this->m_voiceRoom;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -179,6 +182,7 @@ namespace BlackMisc
|
||||
argument >> this->m_bookedUntilUtc;
|
||||
argument >> this->m_atis;
|
||||
argument >> this->m_metar;
|
||||
argument >> this->m_voiceRoom;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -205,6 +209,7 @@ namespace BlackMisc
|
||||
if (other.getController() != this->getController()) return false;
|
||||
if (other.getAtis() != this->getAtis()) return false;
|
||||
if (other.getMetar() != this->getMetar()) return false;
|
||||
if (other.getVoiceRoom() != this->getVoiceRoom()) return false;
|
||||
|
||||
return this->getBookedFromUtc() == other.getBookedFromUtc() &&
|
||||
this->getBookedUntilUtc() == other.getBookedUntilUtc();
|
||||
@@ -292,6 +297,7 @@ namespace BlackMisc
|
||||
hashs << this->m_distanceToPlane.getValueHash();
|
||||
hashs << this->m_metar.getValueHash();
|
||||
hashs << this->m_atis.getValueHash();
|
||||
hashs << this->m_voiceRoom.getValueHash();
|
||||
hashs << qHash(this->m_isOnline ? 1 : 3);
|
||||
hashs << qHash(this->m_bookedFromUtc);
|
||||
hashs << qHash(this->m_bookedUntilUtc);
|
||||
@@ -343,6 +349,10 @@ namespace BlackMisc
|
||||
return this->m_metar.toQVariant();
|
||||
case IndexMetarMessage:
|
||||
return QVariant(this->m_metar.getMessage());
|
||||
case IndexVoiceRoom:
|
||||
return QVariant(this->m_voiceRoom.toQVariant());
|
||||
case IndexVoiceRoomUrl:
|
||||
return QVariant(this->m_voiceRoom.getVoiceRoomUrl());
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -407,6 +417,12 @@ namespace BlackMisc
|
||||
case IndexMetarMessage:
|
||||
this->setMetarMessage(variant.value<QString>());
|
||||
break;
|
||||
case IndexVoiceRoom:
|
||||
this->setVoiceRoom(variant.value<CVoiceRoom>());
|
||||
break;
|
||||
case IndexVoiceRoomUrl:
|
||||
this->setVoiceRoom(CVoiceRoom(variant.toString()));
|
||||
break;
|
||||
default:
|
||||
Q_ASSERT_X(false, "CAtcStation", "index unknown (setter)");
|
||||
break;
|
||||
|
||||
@@ -9,11 +9,13 @@
|
||||
|
||||
#ifndef BLACKMISC_ATCSTATION_H
|
||||
#define BLACKMISC_ATCSTATION_H
|
||||
|
||||
#include "valuemap.h"
|
||||
#include "pqfrequency.h"
|
||||
#include "pqlength.h"
|
||||
#include "pqtime.h"
|
||||
#include "nwuser.h"
|
||||
#include "vvoiceroom.h"
|
||||
#include "coordinategeodetic.h"
|
||||
#include "avcallsign.h"
|
||||
#include "avinformationmessage.h"
|
||||
@@ -55,7 +57,9 @@ namespace BlackMisc
|
||||
IndexAtis,
|
||||
IndexAtisMessage,
|
||||
IndexMetar,
|
||||
IndexMetarMessage
|
||||
IndexMetarMessage,
|
||||
IndexVoiceRoom,
|
||||
IndexVoiceRoomUrl
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -283,6 +287,24 @@ namespace BlackMisc
|
||||
*/
|
||||
void setOnline(bool online) { this->m_isOnline = online; }
|
||||
|
||||
/*!
|
||||
* \brief Get voice room
|
||||
* \return
|
||||
*/
|
||||
const BlackMisc::Voice::CVoiceRoom &getVoiceRoom() const { return this->m_voiceRoom; }
|
||||
|
||||
/*!
|
||||
* \brief Set voice room
|
||||
* \param
|
||||
*/
|
||||
void setVoiceRoom(const BlackMisc::Voice::CVoiceRoom &voiceRoom) { this->m_voiceRoom = voiceRoom; }
|
||||
|
||||
/*!
|
||||
* \brief Valid voice room?
|
||||
* \return
|
||||
*/
|
||||
bool hasValidVoiceRoom() const { return this->m_voiceRoom.isValid(); }
|
||||
|
||||
/*!
|
||||
* Booked date/time if any.
|
||||
* This represents the closest booking within a time frame as there can be multiple bookings.
|
||||
@@ -468,6 +490,7 @@ namespace BlackMisc
|
||||
QDateTime m_bookedUntilUtc;
|
||||
CInformationMessage m_atis;
|
||||
CInformationMessage m_metar;
|
||||
BlackMisc::Voice::CVoiceRoom m_voiceRoom;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -102,9 +102,10 @@ void BlackMisc::Settings::registerMetadata()
|
||||
*/
|
||||
void BlackMisc::Voice::registerMetadata()
|
||||
{
|
||||
COutputAudioDevice::registerMetadata();
|
||||
CInputAudioDevice::registerMetadata();
|
||||
CAudioDevice::registerMetadata();
|
||||
CAudioDeviceList::registerMetadata();
|
||||
CVoiceRoom::registerMetadata();
|
||||
CVoiceRoomList::registerMetadata();
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -9,22 +9,48 @@
|
||||
|
||||
#include "vaudiodevice.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include <QtNetwork/QHostInfo>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Voice
|
||||
{
|
||||
/*
|
||||
* Constructor
|
||||
*/
|
||||
CAudioDevice::CAudioDevice() :
|
||||
m_type(Unknown), m_deviceIndex(invalidDevice()),
|
||||
m_deviceName(""), m_hostName(CAudioDevice::hostName())
|
||||
{
|
||||
// void
|
||||
}
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
*/
|
||||
CAudioDevice::CAudioDevice(DeviceType type, const int16_t index, const QString &name) :
|
||||
m_type(type), m_deviceIndex(index),
|
||||
m_deviceName(name), m_hostName(CAudioDevice::hostName())
|
||||
{
|
||||
// void
|
||||
}
|
||||
|
||||
/*
|
||||
* Host name
|
||||
*/
|
||||
QString CAudioDevice::hostName()
|
||||
{
|
||||
QHostInfo hostInfo = QHostInfo::fromName(QHostInfo::localHostName());
|
||||
return hostInfo.localHostName();
|
||||
}
|
||||
|
||||
/*
|
||||
* Same device?
|
||||
*/
|
||||
bool CAudioDevice::operator ==(const CAudioDevice &other) const
|
||||
{
|
||||
if (&other == this)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (m_deviceIndex == other.m_deviceIndex)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (&other == this) return true;
|
||||
if (m_deviceIndex == other.m_deviceIndex && m_type == other.m_type) return true;
|
||||
|
||||
// otherwise
|
||||
return false;
|
||||
@@ -38,23 +64,30 @@ namespace BlackMisc
|
||||
return !((*this) == other);
|
||||
}
|
||||
|
||||
/*
|
||||
* Hash
|
||||
*/
|
||||
uint CAudioDevice::getValueHash() const
|
||||
{
|
||||
QList<uint> hashs;
|
||||
hashs << qHash(static_cast<uint>(m_type));
|
||||
hashs << qHash(m_deviceIndex);
|
||||
hashs << qHash(m_deviceName);
|
||||
hashs << qHash(m_hostName);
|
||||
return BlackMisc::calculateHash(hashs, "CAudioDevice");
|
||||
}
|
||||
|
||||
void CAudioDevice::registerMetadata()
|
||||
{
|
||||
qRegisterMetaType<CAudioDevice>();
|
||||
qDBusRegisterMetaType<CAudioDevice>();
|
||||
}
|
||||
|
||||
/*
|
||||
* As String
|
||||
*/
|
||||
QString CAudioDevice::convertToQString(bool /* i18n */) const
|
||||
{
|
||||
return m_deviceName;
|
||||
if (this->m_hostName.isEmpty()) return m_deviceName;
|
||||
QString s(this->m_deviceName);
|
||||
s.append(" [");
|
||||
s.append(this->hostName());
|
||||
s.append("]");
|
||||
return s;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -62,8 +95,10 @@ namespace BlackMisc
|
||||
*/
|
||||
void CAudioDevice::marshallToDbus(QDBusArgument &argument) const
|
||||
{
|
||||
argument << static_cast<uint>(m_type);
|
||||
argument << m_deviceIndex;
|
||||
argument << m_deviceName;
|
||||
argument << m_hostName;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -71,20 +106,21 @@ namespace BlackMisc
|
||||
*/
|
||||
void CAudioDevice::unmarshallFromDbus(const QDBusArgument &argument)
|
||||
{
|
||||
uint t;
|
||||
argument >> t;
|
||||
this->m_type = static_cast<DeviceType>(t);
|
||||
argument >> m_deviceIndex;
|
||||
argument >> m_deviceName;
|
||||
argument >> m_hostName;
|
||||
}
|
||||
|
||||
void CInputAudioDevice::registerMetadata()
|
||||
/*
|
||||
* Register
|
||||
*/
|
||||
void CAudioDevice::registerMetadata()
|
||||
{
|
||||
qRegisterMetaType<CInputAudioDevice>();
|
||||
qDBusRegisterMetaType<CInputAudioDevice>();
|
||||
}
|
||||
|
||||
void COutputAudioDevice::registerMetadata()
|
||||
{
|
||||
qRegisterMetaType<COutputAudioDevice>();
|
||||
qDBusRegisterMetaType<COutputAudioDevice>();
|
||||
qRegisterMetaType<CAudioDevice>();
|
||||
qDBusRegisterMetaType<CAudioDevice>();
|
||||
}
|
||||
|
||||
} // Voice
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
*/
|
||||
|
||||
#include "valueobject.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
@@ -31,18 +30,27 @@ namespace BlackMisc
|
||||
{
|
||||
public:
|
||||
|
||||
/*!
|
||||
* \brief Type
|
||||
*/
|
||||
enum DeviceType
|
||||
{
|
||||
InputDevice,
|
||||
OutputDevice,
|
||||
Unknown
|
||||
};
|
||||
|
||||
/*!
|
||||
* Default constructor.
|
||||
* If m_deviceIndex is -1, default should be used. However on Windows this doesnt work. Needs
|
||||
* to be checked in Vatlib.
|
||||
*/
|
||||
CAudioDevice() : m_deviceIndex(invalidDevice()), m_deviceName("") {}
|
||||
|
||||
CAudioDevice();
|
||||
|
||||
/*!
|
||||
* Constructor.
|
||||
*/
|
||||
CAudioDevice(const int16_t index, const QString &name) : m_deviceIndex(index), m_deviceName(name) {}
|
||||
CAudioDevice(DeviceType type, const int16_t index, const QString &getName);
|
||||
|
||||
/*!
|
||||
* \brief QVariant, required for DBus QVariant lists
|
||||
@@ -57,13 +65,19 @@ namespace BlackMisc
|
||||
* Get the device index
|
||||
* \return
|
||||
*/
|
||||
int16_t index() const { return m_deviceIndex; }
|
||||
int16_t getIndex() const { return m_deviceIndex; }
|
||||
|
||||
/*!
|
||||
* Get the device name
|
||||
* \return
|
||||
*/
|
||||
const QString &name() const { return m_deviceName; }
|
||||
const QString &getName() const { return m_deviceName; }
|
||||
|
||||
/*!
|
||||
* \brief Type
|
||||
* \return
|
||||
*/
|
||||
DeviceType getType() const { return m_type; }
|
||||
|
||||
/*!
|
||||
* \brief Valid audio device object?
|
||||
@@ -95,8 +109,16 @@ namespace BlackMisc
|
||||
*/
|
||||
static void registerMetadata();
|
||||
|
||||
/*!
|
||||
* \brief Device type
|
||||
* \return
|
||||
*/
|
||||
static int16_t defaultDevice() {return -1;}
|
||||
|
||||
/*!
|
||||
* \brief Device type
|
||||
* \return
|
||||
*/
|
||||
static int16_t invalidDevice() {return -2;}
|
||||
|
||||
protected:
|
||||
@@ -125,76 +147,22 @@ namespace BlackMisc
|
||||
* deviceIndex is the number is the reference for the VVL. The device is selected by this index.
|
||||
* The managing class needs to take care, that indexes are valid.
|
||||
*/
|
||||
DeviceType m_type;
|
||||
int16_t m_deviceIndex;
|
||||
QString m_deviceName;
|
||||
QString m_hostName;
|
||||
|
||||
};
|
||||
|
||||
class CInputAudioDevice : public CAudioDevice
|
||||
{
|
||||
public:
|
||||
private:
|
||||
/*!
|
||||
* Default constructor.
|
||||
*/
|
||||
CInputAudioDevice() : CAudioDevice() {}
|
||||
|
||||
|
||||
/*!
|
||||
* Constructor.
|
||||
*/
|
||||
CInputAudioDevice(const int16_t index, const QString &name) : CAudioDevice(index, name) {}
|
||||
|
||||
/*!
|
||||
* \brief QVariant, required for DBus QVariant lists
|
||||
* \brief Own host name
|
||||
* \return
|
||||
*/
|
||||
virtual QVariant toQVariant() const
|
||||
{
|
||||
return QVariant::fromValue(*this);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Register metadata
|
||||
*/
|
||||
static void registerMetadata();
|
||||
|
||||
static QString hostName();
|
||||
};
|
||||
|
||||
class COutputAudioDevice : public CAudioDevice
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
* Default constructor.
|
||||
*/
|
||||
COutputAudioDevice() : CAudioDevice() {}
|
||||
|
||||
|
||||
/*!
|
||||
* Constructor.
|
||||
*/
|
||||
COutputAudioDevice(const int16_t index, const QString &name) : CAudioDevice(index, name) {}
|
||||
|
||||
/*!
|
||||
* \brief QVariant, required for DBus QVariant lists
|
||||
* \return
|
||||
*/
|
||||
virtual QVariant toQVariant() const
|
||||
{
|
||||
return QVariant::fromValue(*this);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Register metadata
|
||||
*/
|
||||
static void registerMetadata();
|
||||
|
||||
};
|
||||
} // Voice
|
||||
} // BlackMisc
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Voice::CAudioDevice)
|
||||
Q_DECLARE_METATYPE(BlackMisc::Voice::COutputAudioDevice)
|
||||
Q_DECLARE_METATYPE(BlackMisc::Voice::CInputAudioDevice)
|
||||
|
||||
|
||||
#endif // BLACKMISC_AUDIODEVICE_H
|
||||
#endif // guard
|
||||
|
||||
76
src/blackmisc/vaudiodevicelist.cpp
Normal file
76
src/blackmisc/vaudiodevicelist.cpp
Normal file
@@ -0,0 +1,76 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / authors
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "vaudiodevicelist.h"
|
||||
#include "predicates.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Voice
|
||||
{
|
||||
/*
|
||||
* Default constructor
|
||||
*/
|
||||
CAudioDeviceList::CAudioDeviceList() { }
|
||||
|
||||
/*
|
||||
* Construct from base class object
|
||||
*/
|
||||
CAudioDeviceList::CAudioDeviceList(const CSequence &other) :
|
||||
CSequence(other)
|
||||
{ }
|
||||
|
||||
/*
|
||||
* Output devices
|
||||
*/
|
||||
CAudioDeviceList CAudioDeviceList::getOutputDevices() const
|
||||
{
|
||||
CAudioDeviceList outList;
|
||||
if (this->isEmpty()) return outList;
|
||||
foreach(CAudioDevice device, *this)
|
||||
{
|
||||
if (device.getType() == CAudioDevice::OutputDevice) outList.push_back(device);
|
||||
}
|
||||
return outList;
|
||||
}
|
||||
|
||||
/*
|
||||
* Output devices
|
||||
*/
|
||||
CAudioDeviceList CAudioDeviceList::getInputDevices() const
|
||||
{
|
||||
CAudioDeviceList inList;
|
||||
if (this->isEmpty()) return inList;
|
||||
foreach(CAudioDevice device, *this)
|
||||
{
|
||||
if (device.getType() == CAudioDevice::InputDevice) inList.push_back(device);
|
||||
}
|
||||
return inList;
|
||||
}
|
||||
|
||||
/*
|
||||
* Count as of type
|
||||
*/
|
||||
int CAudioDeviceList::count(CAudioDevice::DeviceType type) const
|
||||
{
|
||||
int c = 0;
|
||||
foreach(CAudioDevice device, *this)
|
||||
{
|
||||
if (device.getType() == type) c++;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
/*
|
||||
* Register metadata
|
||||
*/
|
||||
void CAudioDeviceList::registerMetadata()
|
||||
{
|
||||
qRegisterMetaType<CAudioDeviceList>();
|
||||
qDBusRegisterMetaType<CAudioDeviceList>();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
83
src/blackmisc/vaudiodevicelist.h
Normal file
83
src/blackmisc/vaudiodevicelist.h
Normal file
@@ -0,0 +1,83 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / authors
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/*!
|
||||
\file
|
||||
*/
|
||||
|
||||
#ifndef BLACKMISC_AUDIODEVICELIST_H
|
||||
#define BLACKMISC_AUDIODEVICELIST_H
|
||||
|
||||
#include "vaudiodevice.h"
|
||||
#include "sequence.h"
|
||||
#include "collection.h"
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Voice
|
||||
{
|
||||
/*!
|
||||
* Value object encapsulating a list of audio devices.
|
||||
*/
|
||||
class CAudioDeviceList : public CSequence<CAudioDevice>
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
* \brief Default constructor.
|
||||
*/
|
||||
CAudioDeviceList();
|
||||
|
||||
/*!
|
||||
* \brief Construct from a base class object.
|
||||
* \param other
|
||||
*/
|
||||
CAudioDeviceList(const CSequence &other);
|
||||
|
||||
/*!
|
||||
* \brief QVariant, required for DBus QVariant lists
|
||||
* \return
|
||||
*/
|
||||
virtual QVariant asQVariant() const
|
||||
{
|
||||
return QVariant::fromValue(*this);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Get output devices in that list
|
||||
* \return
|
||||
*/
|
||||
CAudioDeviceList getOutputDevices() const;
|
||||
|
||||
/*!
|
||||
* \brief Get output devices in that list
|
||||
* \return
|
||||
*/
|
||||
CAudioDeviceList getInputDevices() const;
|
||||
|
||||
/*!
|
||||
* \brief Count (as of type)
|
||||
* \param type
|
||||
* \return
|
||||
*/
|
||||
int count(CAudioDevice::DeviceType type) const;
|
||||
|
||||
/*!
|
||||
* \brief Register metadata
|
||||
*/
|
||||
static void registerMetadata();
|
||||
|
||||
};
|
||||
|
||||
} //namespace
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Voice::CAudioDeviceList)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CCollection<BlackMisc::Voice::CAudioDevice>)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CSequence<BlackMisc::Voice::CAudioDevice>)
|
||||
|
||||
#endif //guard
|
||||
@@ -7,6 +7,8 @@
|
||||
#define BLACKMISC_VOICEALLCLASSES_H
|
||||
|
||||
#include "blackmisc/vaudiodevice.h"
|
||||
#include "blackmisc/vaudiodevicelist.h"
|
||||
#include "blackmisc/vvoiceroom.h"
|
||||
#include "blackmisc/vvoiceroomlist.h"
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -17,11 +17,15 @@ namespace BlackMisc
|
||||
{
|
||||
namespace Voice
|
||||
{
|
||||
CVoiceRoom::CVoiceRoom(const QString &serverSpec) : m_hostname(""), m_channel("")
|
||||
CVoiceRoom::CVoiceRoom(const QString &serverUrl, bool connected) :
|
||||
m_hostname(""), m_channel(""), m_connected(connected), m_audioPlaying(false)
|
||||
{
|
||||
if (serverSpec.contains("/"))
|
||||
if (serverUrl.contains("/"))
|
||||
{
|
||||
QStringList splittedSpec = serverSpec.split("/");
|
||||
QString url = serverUrl.trimmed().toLower();
|
||||
url.replace(CVoiceRoom::protocolComplete(), "");
|
||||
url.replace(CVoiceRoom::protocol(), "");
|
||||
QStringList splittedSpec = serverUrl.split("/");
|
||||
m_hostname = splittedSpec.at(0);
|
||||
m_channel = splittedSpec.at(1);
|
||||
}
|
||||
@@ -32,18 +36,11 @@ namespace BlackMisc
|
||||
*/
|
||||
bool CVoiceRoom::operator ==(const CVoiceRoom &other) const
|
||||
{
|
||||
if (&other == this)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (m_hostname == other.m_hostname && m_channel == other.m_channel)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// otherwise
|
||||
return false;
|
||||
if (&other == this) return true;
|
||||
return (m_hostname == other.m_hostname &&
|
||||
m_channel == other.m_channel &&
|
||||
m_connected == other.m_connected &&
|
||||
m_audioPlaying == other.m_audioPlaying);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -54,25 +51,37 @@ namespace BlackMisc
|
||||
return !((*this) == other);
|
||||
}
|
||||
|
||||
/*
|
||||
* Value hash
|
||||
*/
|
||||
uint CVoiceRoom::getValueHash() const
|
||||
{
|
||||
QList<uint> hashs;
|
||||
hashs << qHash(m_hostname);
|
||||
hashs << qHash(m_channel);
|
||||
hashs << qHash(m_connected);
|
||||
hashs << qHash(m_audioPlaying);
|
||||
return BlackMisc::calculateHash(hashs, "CVoiceRoom");
|
||||
}
|
||||
|
||||
/*
|
||||
* Metadata
|
||||
*/
|
||||
void CVoiceRoom::registerMetadata()
|
||||
{
|
||||
qRegisterMetaType<CVoiceRoom>();
|
||||
qDBusRegisterMetaType<CVoiceRoom>();
|
||||
}
|
||||
|
||||
QString CVoiceRoom::convertToQString(bool /* i18n */ ) const
|
||||
/*
|
||||
* To string
|
||||
*/
|
||||
QString CVoiceRoom::convertToQString(bool /* i18n */) const
|
||||
{
|
||||
if (m_hostname.isEmpty() || m_channel.isEmpty()) return "Unknown";
|
||||
QString s = m_hostname;
|
||||
s.append("/").append(m_channel);
|
||||
if (!this->isValid()) return "Invalid";
|
||||
QString s = this->getVoiceRoomUrl(false);
|
||||
s.append(this ->isConnected() ? " connected" : " unconnected");
|
||||
if (this->m_audioPlaying) s.append(" playing");
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -83,6 +92,8 @@ namespace BlackMisc
|
||||
{
|
||||
argument << m_hostname;
|
||||
argument << m_channel;
|
||||
argument << m_connected;
|
||||
argument << m_audioPlaying;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -92,8 +103,29 @@ namespace BlackMisc
|
||||
{
|
||||
argument >> m_hostname;
|
||||
argument >> m_channel;
|
||||
argument >> m_connected;
|
||||
argument >> m_audioPlaying;
|
||||
}
|
||||
|
||||
/*
|
||||
* Server URL
|
||||
*/
|
||||
QString CVoiceRoom::getVoiceRoomUrl(bool noProtocol) const
|
||||
{
|
||||
if (!this->isValid()) return "";
|
||||
QString url(noProtocol ? "" : CVoiceRoom::protocolComplete());
|
||||
url.append(this->m_hostname);
|
||||
url.append("/");
|
||||
url.append(this->m_channel);
|
||||
return url;
|
||||
}
|
||||
|
||||
/*
|
||||
* ATIS voice channel
|
||||
*/
|
||||
bool CVoiceRoom::isAtis() const
|
||||
{
|
||||
return (this->m_channel.contains("ATIS", Qt::CaseInsensitive));
|
||||
}
|
||||
} // Voice
|
||||
} // BlackMisc
|
||||
|
||||
@@ -8,10 +8,8 @@
|
||||
*/
|
||||
|
||||
#include "valueobject.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
|
||||
#ifndef BLACKMISC_VOICEROOM_H
|
||||
#define BLACKMISC_VOICEROOM_H
|
||||
|
||||
@@ -29,17 +27,23 @@ namespace BlackMisc
|
||||
/*!
|
||||
* Default constructor.
|
||||
*/
|
||||
CVoiceRoom() : m_hostname(""), m_channel("") {}
|
||||
CVoiceRoom() :
|
||||
m_hostname(""), m_channel(""), m_connected(false), m_audioPlaying(false) {}
|
||||
|
||||
/*!
|
||||
* Constructor.
|
||||
* \param hostname
|
||||
* \param channel
|
||||
*/
|
||||
CVoiceRoom(const QString &hostname, const QString &channel) : m_hostname(hostname), m_channel(channel) {}
|
||||
CVoiceRoom(const QString &hostname, const QString &channel) :
|
||||
m_hostname(hostname), m_channel(channel), m_audioPlaying(false) {}
|
||||
|
||||
/*!
|
||||
* Constructor.
|
||||
* \param serverUrl
|
||||
* \param connected
|
||||
*/
|
||||
CVoiceRoom(const QString &serverSpec);
|
||||
CVoiceRoom(const QString &serverUrl, bool connected = false);
|
||||
|
||||
/*!
|
||||
* \brief QVariant, required for DBus QVariant lists
|
||||
@@ -54,13 +58,13 @@ namespace BlackMisc
|
||||
* Get the host name
|
||||
* \return
|
||||
*/
|
||||
const QString &hostName() const { return m_hostname; }
|
||||
const QString &getHostName() const { return m_hostname; }
|
||||
|
||||
/*!
|
||||
* Get the voice room
|
||||
* \return
|
||||
*/
|
||||
const QString &channel() const { return m_channel; }
|
||||
const QString &getChannel() const { return m_channel; }
|
||||
|
||||
/*!
|
||||
* Set the host name
|
||||
@@ -74,6 +78,13 @@ namespace BlackMisc
|
||||
*/
|
||||
void setChannel(const QString &channel) { m_channel = channel; }
|
||||
|
||||
/*!
|
||||
* \brief Server URL
|
||||
* \param noProtocol
|
||||
* \return
|
||||
*/
|
||||
QString getVoiceRoomUrl(bool noProtocol = true) const;
|
||||
|
||||
/*!
|
||||
* \brief Valid voice room object?
|
||||
* \return
|
||||
@@ -81,10 +92,40 @@ namespace BlackMisc
|
||||
bool isValid() const { return !this->m_hostname.isEmpty() && !this->m_channel.isEmpty(); }
|
||||
|
||||
/*!
|
||||
* \brief Equal operator ==
|
||||
* \param other
|
||||
* @return
|
||||
* \brief Is connected
|
||||
* \return
|
||||
*/
|
||||
bool isConnected() const { return this->isValid() && this->m_connected; }
|
||||
|
||||
/*!
|
||||
* \brief Set connected status
|
||||
* \param isConnected
|
||||
*/
|
||||
void setConnected(bool isConnected) { this->m_connected = isConnected; }
|
||||
|
||||
/*!
|
||||
* \brief Is audio playing in this room?
|
||||
* \return
|
||||
*/
|
||||
bool isAudioPlaying() const { return this->m_audioPlaying; }
|
||||
|
||||
/*!
|
||||
* \brief Set audio playing
|
||||
* \param playing
|
||||
*/
|
||||
void setAudioPlaying(bool playing) { this->m_audioPlaying = playing; }
|
||||
|
||||
/*!
|
||||
* \brief Is ATIS voice channel
|
||||
* \return
|
||||
*/
|
||||
bool isAtis() const;
|
||||
|
||||
/*!
|
||||
* \brief Equal operator ==
|
||||
* \param other
|
||||
* @return
|
||||
*/
|
||||
bool operator ==(const CVoiceRoom &other) const;
|
||||
|
||||
/*!
|
||||
@@ -104,6 +145,18 @@ namespace BlackMisc
|
||||
*/
|
||||
static void registerMetadata();
|
||||
|
||||
/*!
|
||||
* \brief Protocol
|
||||
* \return
|
||||
*/
|
||||
static const QString &protocol() { static QString p("vvl"); return p; }
|
||||
|
||||
/*!
|
||||
* \brief Protocol
|
||||
* \return
|
||||
*/
|
||||
static const QString &protocolComplete() { static QString p("vvl://"); return p; }
|
||||
|
||||
protected:
|
||||
|
||||
/*!
|
||||
@@ -125,15 +178,15 @@ namespace BlackMisc
|
||||
*/
|
||||
virtual void unmarshallFromDbus(const QDBusArgument &argument);
|
||||
|
||||
|
||||
private:
|
||||
QString m_hostname;
|
||||
QString m_channel;
|
||||
|
||||
bool m_connected;
|
||||
bool m_audioPlaying;
|
||||
};
|
||||
} // Voice
|
||||
} // BlackMisc
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Voice::CVoiceRoom)
|
||||
|
||||
#endif // BLACKMISC_VOICEROOM_H
|
||||
#endif // guard
|
||||
|
||||
35
src/blackmisc/vvoiceroomlist.cpp
Normal file
35
src/blackmisc/vvoiceroomlist.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / authors
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "vvoiceroomlist.h"
|
||||
#include "predicates.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Voice
|
||||
{
|
||||
/*
|
||||
* Default constructor
|
||||
*/
|
||||
CVoiceRoomList::CVoiceRoomList() { }
|
||||
|
||||
/*
|
||||
* Construct from base class object
|
||||
*/
|
||||
CVoiceRoomList::CVoiceRoomList(const CSequence &other) :
|
||||
CSequence(other)
|
||||
{ }
|
||||
|
||||
/*
|
||||
* Register metadata
|
||||
*/
|
||||
void CVoiceRoomList::registerMetadata()
|
||||
{
|
||||
qRegisterMetaType<CVoiceRoomList>();
|
||||
qDBusRegisterMetaType<CVoiceRoomList>();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
64
src/blackmisc/vvoiceroomlist.h
Normal file
64
src/blackmisc/vvoiceroomlist.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / authors
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/*!
|
||||
\file
|
||||
*/
|
||||
|
||||
#ifndef BLACKMISC_VOICEROOMLIST_H
|
||||
#define BLACKMISC_VOICEROOMLIST_H
|
||||
|
||||
#include "vvoiceroom.h"
|
||||
#include "sequence.h"
|
||||
#include "collection.h"
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Voice
|
||||
{
|
||||
/*!
|
||||
* Value object encapsulating a list of voice rooms.
|
||||
*/
|
||||
class CVoiceRoomList : public CSequence<CVoiceRoom>
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
* \brief Default constructor.
|
||||
*/
|
||||
CVoiceRoomList();
|
||||
|
||||
/*!
|
||||
* \brief Construct from a base class object.
|
||||
* \param other
|
||||
*/
|
||||
CVoiceRoomList(const CSequence &other);
|
||||
|
||||
/*!
|
||||
* \brief QVariant, required for DBus QVariant lists
|
||||
* \return
|
||||
*/
|
||||
virtual QVariant asQVariant() const
|
||||
{
|
||||
return QVariant::fromValue(*this);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Register metadata
|
||||
*/
|
||||
static void registerMetadata();
|
||||
|
||||
};
|
||||
|
||||
} //namespace
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Voice::CVoiceRoomList)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CCollection<BlackMisc::Voice::CVoiceRoom>)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CSequence<BlackMisc::Voice::CVoiceRoom>)
|
||||
|
||||
#endif //guard
|
||||
Reference in New Issue
Block a user