mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 21:15:33 +08:00
In #85 the voice context will be renamed to audio context, so the CValueObject classes will be renamed to namespace Audio too. As #140 changes many CValueClasses, this crossover change is done in the same unit of work.
This commit is contained in:
@@ -6,9 +6,9 @@
|
||||
#ifndef BLACKMISC_VOICEALLCLASSES_H
|
||||
#define BLACKMISC_VOICEALLCLASSES_H
|
||||
|
||||
#include "blackmisc/vaudiodevice.h"
|
||||
#include "blackmisc/vaudiodevicelist.h"
|
||||
#include "blackmisc/vvoiceroom.h"
|
||||
#include "blackmisc/vvoiceroomlist.h"
|
||||
#include "blackmisc/audiodevice.h"
|
||||
#include "blackmisc/audiodevicelist.h"
|
||||
#include "blackmisc/voiceroom.h"
|
||||
#include "blackmisc/voiceroomlist.h"
|
||||
|
||||
#endif // guard
|
||||
@@ -3,12 +3,12 @@
|
||||
* 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 "audiodevicelist.h"
|
||||
#include "predicates.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Voice
|
||||
namespace Audio
|
||||
{
|
||||
/*
|
||||
* Default constructor
|
||||
@@ -10,7 +10,7 @@
|
||||
#ifndef BLACKMISC_AUDIODEVICELIST_H
|
||||
#define BLACKMISC_AUDIODEVICELIST_H
|
||||
|
||||
#include "vaudiodevice.h"
|
||||
#include "audiodevice.h"
|
||||
#include "sequence.h"
|
||||
#include "collection.h"
|
||||
#include <QObject>
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Voice
|
||||
namespace Audio
|
||||
{
|
||||
/*!
|
||||
* Value object encapsulating a list of audio devices.
|
||||
@@ -76,8 +76,8 @@ namespace BlackMisc
|
||||
} //namespace
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Voice::CAudioDeviceList)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CCollection<BlackMisc::Voice::CAudioDevice>)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CSequence<BlackMisc::Voice::CAudioDevice>)
|
||||
Q_DECLARE_METATYPE(BlackMisc::Audio::CAudioDeviceList)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CCollection<BlackMisc::Audio::CAudioDevice>)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CSequence<BlackMisc::Audio::CAudioDevice>)
|
||||
|
||||
#endif //guard
|
||||
@@ -14,6 +14,6 @@
|
||||
#include "blackmisc/networkallclasses.h"
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
#include "blackmisc/statusmessage.h"
|
||||
#include "blackmisc/voiceallclasses.h"
|
||||
#include "blackmisc/audioallclasses.h"
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "hwallclasses.h"
|
||||
#include "valuemap.h"
|
||||
#include "statusmessagelist.h"
|
||||
#include "voiceallclasses.h"
|
||||
#include "audioallclasses.h"
|
||||
|
||||
/*
|
||||
* Metadata for PQs
|
||||
@@ -103,7 +103,7 @@ void BlackMisc::Settings::registerMetadata()
|
||||
/*
|
||||
* Metadata for Voice
|
||||
*/
|
||||
void BlackMisc::Voice::registerMetadata()
|
||||
void BlackMisc::Audio::registerMetadata()
|
||||
{
|
||||
CAudioDevice::registerMetadata();
|
||||
CAudioDeviceList::registerMetadata();
|
||||
@@ -139,7 +139,7 @@ void BlackMisc::registerMetadata()
|
||||
Geo::registerMetadata();
|
||||
Network::registerMetadata();
|
||||
Settings::registerMetadata();
|
||||
Voice::registerMetadata();
|
||||
Audio::registerMetadata();
|
||||
Hardware::registerMetadata();
|
||||
}
|
||||
|
||||
|
||||
@@ -87,10 +87,10 @@ namespace BlackMisc
|
||||
void registerMetadata();
|
||||
}
|
||||
|
||||
namespace Voice
|
||||
namespace Audio
|
||||
{
|
||||
/*!
|
||||
* \brief Register metadata for voice
|
||||
* \brief Register metadata for audio / voice
|
||||
*/
|
||||
void registerMetadata();
|
||||
}
|
||||
|
||||
@@ -1,161 +0,0 @@
|
||||
/* 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
|
||||
*/
|
||||
|
||||
#include "vaudiodevice.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include <QtNetwork/QHostInfo>
|
||||
#include <tuple>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Voice
|
||||
{
|
||||
/*
|
||||
* Constructor
|
||||
*/
|
||||
CAudioDevice::CAudioDevice() :
|
||||
m_type(Unknown), m_deviceIndex(invalidDeviceIndex()),
|
||||
m_deviceName(""), m_hostName(CAudioDevice::hostName())
|
||||
{
|
||||
// void
|
||||
}
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
*/
|
||||
CAudioDevice::CAudioDevice(DeviceType type, const qint16 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 && m_type == other.m_type) return true;
|
||||
|
||||
// otherwise
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Unequal?
|
||||
*/
|
||||
bool CAudioDevice::operator !=(const CAudioDevice &other) const
|
||||
{
|
||||
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");
|
||||
}
|
||||
|
||||
/*
|
||||
* As String
|
||||
*/
|
||||
QString CAudioDevice::convertToQString(bool /* i18n */) const
|
||||
{
|
||||
if (this->m_hostName.isEmpty()) return m_deviceName;
|
||||
QString s(this->m_deviceName);
|
||||
s.append(" [");
|
||||
s.append(this->hostName());
|
||||
s.append("]");
|
||||
return s;
|
||||
}
|
||||
|
||||
/*
|
||||
* metaTypeId
|
||||
*/
|
||||
int CAudioDevice::getMetaTypeId() const
|
||||
{
|
||||
return qMetaTypeId<CAudioDevice>();
|
||||
}
|
||||
|
||||
/*
|
||||
* is a
|
||||
*/
|
||||
bool CAudioDevice::isA(int metaTypeId) const
|
||||
{
|
||||
if (metaTypeId == qMetaTypeId<CAudioDevice>()) { return true; }
|
||||
|
||||
return this->CValueObject::isA(metaTypeId);
|
||||
}
|
||||
|
||||
/*
|
||||
* Compare
|
||||
*/
|
||||
int CAudioDevice::compareImpl(const CValueObject &otherBase) const
|
||||
{
|
||||
const auto &other = static_cast<const CAudioDevice &>(otherBase);
|
||||
|
||||
const auto lhs = std::tie(this->m_type, this->m_deviceIndex, this->m_deviceName, this->m_hostName);
|
||||
const auto rhs = std::tie(other.m_type, other.m_deviceIndex, other.m_deviceName, other.m_hostName);
|
||||
|
||||
if (lhs < rhs) { return -1; }
|
||||
if (lhs > rhs) { return 1; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Marshall to DBus
|
||||
*/
|
||||
void CAudioDevice::marshallToDbus(QDBusArgument &argument) const
|
||||
{
|
||||
argument << static_cast<uint>(m_type);
|
||||
argument << m_deviceIndex;
|
||||
argument << m_deviceName;
|
||||
argument << m_hostName;
|
||||
}
|
||||
|
||||
/*
|
||||
* Unmarshall from DBus
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
* Register
|
||||
*/
|
||||
void CAudioDevice::registerMetadata()
|
||||
{
|
||||
qRegisterMetaType<CAudioDevice>();
|
||||
qDBusRegisterMetaType<CAudioDevice>();
|
||||
}
|
||||
|
||||
} // Voice
|
||||
} // BlackMisc
|
||||
@@ -1,163 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
#ifndef BLACKMISC_AUDIODEVICE_H
|
||||
#define BLACKMISC_AUDIODEVICE_H
|
||||
|
||||
/*!
|
||||
\file
|
||||
*/
|
||||
|
||||
#include "valueobject.h"
|
||||
#include <QString>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Voice
|
||||
{
|
||||
/*!
|
||||
* Value object encapsulating information of a audio device.
|
||||
* If you want to safe this object, use the name instead of the index, since the index can change after
|
||||
* a restart.
|
||||
*/
|
||||
class CAudioDevice : public BlackMisc::CValueObject
|
||||
{
|
||||
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();
|
||||
|
||||
/*!
|
||||
* Constructor.
|
||||
*/
|
||||
CAudioDevice(DeviceType type, const qint16 index, const QString &getName);
|
||||
|
||||
/*!
|
||||
* \copydoc CValueObject::toQVariant
|
||||
*/
|
||||
virtual QVariant toQVariant() const override
|
||||
{
|
||||
return QVariant::fromValue(*this);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get the device index
|
||||
* \return
|
||||
*/
|
||||
qint16 getIndex() const { return m_deviceIndex; }
|
||||
|
||||
/*!
|
||||
* Get the device name
|
||||
* \return
|
||||
*/
|
||||
const QString &getName() const { return m_deviceName; }
|
||||
|
||||
/*!
|
||||
* \brief Type
|
||||
* \return
|
||||
*/
|
||||
DeviceType getType() const { return m_type; }
|
||||
|
||||
//! \brief Valid audio device object?
|
||||
bool isValid() const { return m_deviceIndex >= -1 && !m_deviceName.isEmpty(); }
|
||||
|
||||
//! \brief Equal operator ==
|
||||
bool operator ==(const CAudioDevice &other) const;
|
||||
|
||||
//! \brief Unequal operator !=
|
||||
bool operator !=(const CAudioDevice &other) const;
|
||||
|
||||
//! \copydoc CValueObject::getValueHash
|
||||
virtual uint getValueHash() const override;
|
||||
|
||||
//! \brief Register metadata
|
||||
static void registerMetadata();
|
||||
|
||||
//! \brief Device index for default device
|
||||
static qint16 defaultDeviceIndex() {return -1;}
|
||||
|
||||
//! \brief Invalid device index
|
||||
static qint16 invalidDeviceIndex() {return -2;}
|
||||
|
||||
//! \brief default output device
|
||||
static CAudioDevice getDefaultOutputDevice()
|
||||
{
|
||||
return CAudioDevice(OutputDevice, defaultDeviceIndex(), "default");
|
||||
}
|
||||
|
||||
//! \brief default input device
|
||||
static CAudioDevice getDefaultInputDevice()
|
||||
{
|
||||
return CAudioDevice(InputDevice, defaultDeviceIndex(), "default");
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
//! \copydoc CValueObject::convertToQString
|
||||
virtual QString convertToQString(bool i18n = false) const override;
|
||||
|
||||
//! \copydoc CValueObject::getMetaTypeId
|
||||
virtual int getMetaTypeId() const override;
|
||||
|
||||
//! \copydoc CValueObject::isA
|
||||
virtual bool isA(int metaTypeId) const override;
|
||||
|
||||
//! \copydoc CValueObject::compareImpl
|
||||
virtual int compareImpl(const CValueObject &other) const override;
|
||||
|
||||
//! \copydoc CValueObject::marshallToDbus()
|
||||
virtual void marshallToDbus(QDBusArgument &argument) const override;
|
||||
|
||||
//! \copydoc CValueObject::unmarshallFromDbus()
|
||||
virtual void unmarshallFromDbus(const QDBusArgument &argument) override;
|
||||
|
||||
protected:
|
||||
/*!
|
||||
* \brief Device type, @see CAudioDevice::DeviceType
|
||||
*/
|
||||
DeviceType m_type;
|
||||
/*!
|
||||
* 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.
|
||||
*/
|
||||
qint16 m_deviceIndex;
|
||||
/*!
|
||||
* \brief Device name
|
||||
*/
|
||||
QString m_deviceName;
|
||||
/*!
|
||||
* We use a DBus based system. Hence an audio device can reside on a different
|
||||
* computer, this here is its name
|
||||
*/
|
||||
QString m_hostName;
|
||||
|
||||
private:
|
||||
/*!
|
||||
* \brief Own host name
|
||||
* \return
|
||||
*/
|
||||
static QString hostName();
|
||||
};
|
||||
|
||||
} // Voice
|
||||
} // BlackMisc
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Voice::CAudioDevice)
|
||||
|
||||
#endif // guard
|
||||
@@ -3,12 +3,12 @@
|
||||
* 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 "voiceroomlist.h"
|
||||
#include "predicates.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Voice
|
||||
namespace Audio
|
||||
{
|
||||
/*
|
||||
* Default constructor
|
||||
@@ -10,7 +10,7 @@
|
||||
#ifndef BLACKMISC_VOICEROOMLIST_H
|
||||
#define BLACKMISC_VOICEROOMLIST_H
|
||||
|
||||
#include "vvoiceroom.h"
|
||||
#include "voiceroom.h"
|
||||
#include "sequence.h"
|
||||
#include "collection.h"
|
||||
#include <QObject>
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Voice
|
||||
namespace Audio
|
||||
{
|
||||
/*!
|
||||
* Value object encapsulating a list of voice rooms.
|
||||
@@ -57,8 +57,8 @@ namespace BlackMisc
|
||||
} //namespace
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Voice::CVoiceRoomList)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CCollection<BlackMisc::Voice::CVoiceRoom>)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CSequence<BlackMisc::Voice::CVoiceRoom>)
|
||||
Q_DECLARE_METATYPE(BlackMisc::Audio::CVoiceRoomList)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CCollection<BlackMisc::Audio::CVoiceRoom>)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CSequence<BlackMisc::Audio::CVoiceRoom>)
|
||||
|
||||
#endif //guard
|
||||
@@ -1,164 +0,0 @@
|
||||
/* 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
|
||||
*/
|
||||
|
||||
#include "vvoiceroom.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include <QChar>
|
||||
#include <QStringList>
|
||||
#include <tuple>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Voice
|
||||
{
|
||||
CVoiceRoom::CVoiceRoom(const QString &serverUrl, bool connected) :
|
||||
m_connected(connected), m_audioPlaying(false)
|
||||
{
|
||||
if (serverUrl.contains("/"))
|
||||
{
|
||||
QString url = serverUrl.trimmed().toLower();
|
||||
url.replace(CVoiceRoom::protocolComplete(), "");
|
||||
url.replace(CVoiceRoom::protocol(), "");
|
||||
QStringList splitParts = serverUrl.split("/");
|
||||
m_hostname = splitParts.at(0);
|
||||
m_channel = splitParts.at(1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Equal?
|
||||
*/
|
||||
bool CVoiceRoom::operator ==(const CVoiceRoom &other) const
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
/*
|
||||
* Unequal?
|
||||
*/
|
||||
bool CVoiceRoom::operator !=(const CVoiceRoom &other) const
|
||||
{
|
||||
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>();
|
||||
}
|
||||
|
||||
/*
|
||||
* To string
|
||||
*/
|
||||
QString CVoiceRoom::convertToQString(bool /* i18n */) const
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
* metaTypeId
|
||||
*/
|
||||
int CVoiceRoom::getMetaTypeId() const
|
||||
{
|
||||
return qMetaTypeId<CVoiceRoom>();
|
||||
}
|
||||
|
||||
/*
|
||||
* is a
|
||||
*/
|
||||
bool CVoiceRoom::isA(int metaTypeId) const
|
||||
{
|
||||
if (metaTypeId == qMetaTypeId<CVoiceRoom>()) { return true; }
|
||||
|
||||
return CValueObject::isA(metaTypeId);
|
||||
}
|
||||
|
||||
/*
|
||||
* Compare
|
||||
*/
|
||||
int CVoiceRoom::compareImpl(const CValueObject &otherBase) const
|
||||
{
|
||||
const auto &other = static_cast<const CVoiceRoom &>(otherBase);
|
||||
|
||||
const auto lhs = std::tie(m_hostname, m_channel, m_connected, m_audioPlaying);
|
||||
const auto rhs = std::tie(other.m_hostname, other.m_channel, other.m_connected, other.m_audioPlaying);
|
||||
|
||||
if (lhs < rhs) { return -1; }
|
||||
if (lhs > rhs) { return 1; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Marshall to DBus
|
||||
*/
|
||||
void CVoiceRoom::marshallToDbus(QDBusArgument &argument) const
|
||||
{
|
||||
argument << m_hostname;
|
||||
argument << m_channel;
|
||||
argument << m_connected;
|
||||
argument << m_audioPlaying;
|
||||
}
|
||||
|
||||
/*
|
||||
* Unmarshall from DBus
|
||||
*/
|
||||
void CVoiceRoom::unmarshallFromDbus(const QDBusArgument &argument)
|
||||
{
|
||||
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
|
||||
@@ -1,187 +0,0 @@
|
||||
/* 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
|
||||
*/
|
||||
|
||||
#include "valueobject.h"
|
||||
#include <QString>
|
||||
|
||||
#ifndef BLACKMISC_VOICEROOM_H
|
||||
#define BLACKMISC_VOICEROOM_H
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Voice
|
||||
{
|
||||
/*!
|
||||
* Value object encapsulating information of a voice room
|
||||
*/
|
||||
class CVoiceRoom : public BlackMisc::CValueObject
|
||||
{
|
||||
public:
|
||||
|
||||
/*!
|
||||
* Default constructor.
|
||||
*/
|
||||
CVoiceRoom() :
|
||||
m_connected(false), m_audioPlaying(false) {}
|
||||
|
||||
/*!
|
||||
* Constructor.
|
||||
* \param hostname
|
||||
* \param channel
|
||||
*/
|
||||
CVoiceRoom(const QString &hostname, const QString &channel) :
|
||||
m_hostname(hostname), m_channel(channel), m_connected(false), m_audioPlaying(false) {}
|
||||
|
||||
/*!
|
||||
* Constructor.
|
||||
* \param serverUrl
|
||||
* \param connected
|
||||
*/
|
||||
CVoiceRoom(const QString &serverUrl, bool connected = false);
|
||||
|
||||
/*!
|
||||
* \copydoc CValueObject::toQVariant
|
||||
*/
|
||||
virtual QVariant toQVariant() const override
|
||||
{
|
||||
return QVariant::fromValue(*this);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get the host name
|
||||
* \return
|
||||
*/
|
||||
const QString &getHostName() const { return m_hostname; }
|
||||
|
||||
/*!
|
||||
* Get the voice room
|
||||
*/
|
||||
const QString &getChannel() const { return m_channel; }
|
||||
|
||||
/*!
|
||||
* \brief Set the host name
|
||||
*/
|
||||
void setHostName(const QString &hostName) { m_hostname = hostName; }
|
||||
|
||||
/*!
|
||||
* \brief Set the voice channel
|
||||
*/
|
||||
void setChannel(const QString &channel) { m_channel = channel; }
|
||||
|
||||
/*!
|
||||
* \brief Server URL
|
||||
* \param noProtocol either with (pseudo) protocol prefix or without
|
||||
* \return
|
||||
*/
|
||||
QString getVoiceRoomUrl(bool noProtocol = true) const;
|
||||
|
||||
/*!
|
||||
* \brief Valid voice room object?
|
||||
* \return
|
||||
*/
|
||||
bool isValid() const { return !this->m_hostname.isEmpty() && !this->m_channel.isEmpty(); }
|
||||
|
||||
/*!
|
||||
* \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;
|
||||
|
||||
/*!
|
||||
* \brief Unequal operator ==
|
||||
* \param other
|
||||
* @return
|
||||
*/
|
||||
bool operator !=(const CVoiceRoom &other) const;
|
||||
|
||||
/*!
|
||||
* \copydoc CValueObject::getValueHash
|
||||
*/
|
||||
virtual uint getValueHash() const override;
|
||||
|
||||
/*!
|
||||
* \brief Register metadata
|
||||
*/
|
||||
static void registerMetadata();
|
||||
|
||||
/*!
|
||||
* \brief Protocol prefix
|
||||
* \return
|
||||
*/
|
||||
static const QString &protocol() { static QString p("vvl"); return p; }
|
||||
|
||||
/*!
|
||||
* \brief Protocol
|
||||
* \return with protocol prefix or without
|
||||
*/
|
||||
static const QString &protocolComplete() { static QString p("vvl://"); return p; }
|
||||
|
||||
protected:
|
||||
|
||||
//! \copydoc CValueObject::convertToQString
|
||||
virtual QString convertToQString(bool i18n = false) const override;
|
||||
|
||||
//! \copydoc CValueObject::getMetaTypeId
|
||||
virtual int getMetaTypeId() const override;
|
||||
|
||||
//! \copydoc CValueObject::isA
|
||||
virtual bool isA(int metaTypeId) const override;
|
||||
|
||||
//! \copydoc CValueObject::compareImpl
|
||||
virtual int compareImpl(const CValueObject &other) const override;
|
||||
|
||||
//! \copydoc CValueObject::marshallToDbus
|
||||
virtual void marshallToDbus(QDBusArgument &argument) const override;
|
||||
|
||||
//! \copydoc CValueObject::unmarshallFromDbus
|
||||
virtual void unmarshallFromDbus(const QDBusArgument &argument) override;
|
||||
|
||||
private:
|
||||
QString m_hostname;
|
||||
QString m_channel;
|
||||
bool m_connected;
|
||||
bool m_audioPlaying;
|
||||
};
|
||||
} // Voice
|
||||
} // BlackMisc
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Voice::CVoiceRoom)
|
||||
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user