mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
Added class CVoiceRoom
refs #36 - This class encapsulates the information on a voice server room. - It basically consists of the tuple hostname and channel refs #81
This commit is contained in:
committed by
Mathew Sutcliffe
parent
62e1b411c5
commit
fcebc44b02
@@ -12,6 +12,7 @@
|
||||
|
||||
#include "../blackmisc/context.h"
|
||||
#include "../blackmisc/avcallsign.h"
|
||||
#include "../blackmisc/vvoiceroom.h"
|
||||
|
||||
#include <vatlib/vatlib.h>
|
||||
|
||||
@@ -45,8 +46,8 @@ namespace BlackCore
|
||||
virtual ~IVoiceClient() {}
|
||||
|
||||
virtual void setCallsign(const BlackMisc::Aviation::CCallsign &callsign) = 0;
|
||||
virtual void joinVoiceServer(const uint32_t comUnit, const QString &serverSpec) = 0;
|
||||
virtual void leaveVoiceServer(const uint32_t comUnit) = 0;
|
||||
virtual void joinVoiceRoom(const uint32_t comUnit, const BlackMisc::Voice::CVoiceRoom &voiceRoom) = 0;
|
||||
virtual void leaveVoiceRoom(const uint32_t comUnit) = 0;
|
||||
virtual void setVolume(const uint32_t comUnit, const uint32_t volumne) = 0;
|
||||
virtual void startTransmitting(const uint32_t comUnit) = 0;
|
||||
virtual void stopTransmitting(const uint32_t comUnit) = 0;
|
||||
@@ -57,6 +58,8 @@ namespace BlackCore
|
||||
virtual void getInputDevices(const uint32_t comUnit) = 0;
|
||||
virtual void getOutputDevices(const uint32_t comUnit) = 0;
|
||||
|
||||
virtual const BlackMisc::Voice::CVoiceRoom &voiceRoom (const uint32_t comUnit) = 0;
|
||||
|
||||
signals:
|
||||
void notConnected(const uint32_t comUnit);
|
||||
void connecting(const uint32_t comUnit);
|
||||
|
||||
@@ -69,12 +69,12 @@ namespace BlackCore
|
||||
|
||||
}
|
||||
|
||||
void CVoiceClientVatlib::onRoomStatusUpdate(Cvatlib_Voice_Simple *obj, roomStatusUpdate upd, int32_t roomIndex, void *cbVar)
|
||||
void CVoiceClientVatlib::onRoomStatusUpdate(Cvatlib_Voice_Simple *obj, Cvatlib_Voice_Simple::roomStatusUpdate upd, int32_t roomIndex, void *cbVar)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CVoiceClientVatlib::onRoomUserReceived(vatlib_Voice_Simple *obj, const char *name, void *cbVar)
|
||||
void CVoiceClientVatlib::onRoomUserReceived(Cvatlib_Voice_Simple *obj, const char *name, void *cbVar)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "voiceclient.h"
|
||||
|
||||
#include <QScopedPointer>
|
||||
#include <QMap>
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
@@ -41,12 +42,13 @@ namespace BlackCore
|
||||
private:
|
||||
|
||||
// shimlib callbacks
|
||||
void onRoomStatusUpdate(Cvatlib_Voice_Simple* obj, roomStatusUpdate upd, INT roomIndex, void* cbVar);
|
||||
void onRoomUserReceived(vatlib_Voice_Simple* obj, const char* name, void* cbVar);
|
||||
void onRoomStatusUpdate(Cvatlib_Voice_Simple* obj, Cvatlib_Voice_Simple::roomStatusUpdate upd, INT roomIndex, void* cbVar);
|
||||
void onRoomUserReceived(Cvatlib_Voice_Simple* obj, const char* name, void* cbVar);
|
||||
void onHardwareDeviceReceived(Cvatlib_Voice_Simple* obj, const char* name, void* cbVar);
|
||||
|
||||
QScopedPointer<Cvatlib_Voice_Simple> m_voice;
|
||||
BlackMisc::Aviation::CCallsign m_callsign;
|
||||
QMap<uint32_t, BlackMisc::Voice::CVoiceRoom> m_voiceRoomMap;
|
||||
|
||||
};
|
||||
|
||||
|
||||
90
src/blackmisc/vvoiceroom.cpp
Normal file
90
src/blackmisc/vvoiceroom.cpp
Normal file
@@ -0,0 +1,90 @@
|
||||
#include "vvoiceroom.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
|
||||
#include <QChar>
|
||||
#include <QStringList>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Voice
|
||||
{
|
||||
CVoiceRoom::CVoiceRoom(const QString &serverSpec) : m_hostname(""), m_channel("")
|
||||
{
|
||||
if (serverSpec.contains("/"))
|
||||
{
|
||||
QStringList splittedSpec = serverSpec.split("/");
|
||||
m_hostname = splittedSpec.at(0);
|
||||
m_channel = splittedSpec.at(1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Equal?
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
* Unequal?
|
||||
*/
|
||||
bool CVoiceRoom::operator !=(const CVoiceRoom &other) const
|
||||
{
|
||||
return !((*this) == other);
|
||||
}
|
||||
|
||||
uint CVoiceRoom::getValueHash() const
|
||||
{
|
||||
QList<uint> hashs;
|
||||
hashs << qHash(m_hostname);
|
||||
hashs << qHash(m_channel);
|
||||
return BlackMisc::calculateHash(hashs, "CVoiceRoom");
|
||||
}
|
||||
|
||||
void CVoiceRoom::registerMetadata()
|
||||
{
|
||||
qRegisterMetaType<CVoiceRoom>();
|
||||
qDBusRegisterMetaType<CVoiceRoom>();
|
||||
}
|
||||
|
||||
QString CVoiceRoom::convertToQString(bool i18n) const
|
||||
{
|
||||
if (m_hostname.isEmpty() || m_channel.isEmpty()) return "Unknown";
|
||||
QString s = m_hostname;
|
||||
s.append("/").append(m_channel);
|
||||
return s;
|
||||
}
|
||||
|
||||
/*
|
||||
* Marshall to DBus
|
||||
*/
|
||||
void CVoiceRoom::marshallToDbus(QDBusArgument &argument) const
|
||||
{
|
||||
argument << m_hostname;
|
||||
argument << m_channel;
|
||||
}
|
||||
|
||||
/*
|
||||
* Unmarshall from DBus
|
||||
*/
|
||||
void CVoiceRoom::unmarshallFromDbus(const QDBusArgument &argument)
|
||||
{
|
||||
argument >> m_hostname;
|
||||
argument >> m_channel;
|
||||
}
|
||||
|
||||
|
||||
} // Voice
|
||||
} // BlackMisc
|
||||
139
src/blackmisc/vvoiceroom.h
Normal file
139
src/blackmisc/vvoiceroom.h
Normal file
@@ -0,0 +1,139 @@
|
||||
/* 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_hostname(""), m_channel("") {}
|
||||
|
||||
/*!
|
||||
* Constructor.
|
||||
*/
|
||||
CVoiceRoom(const QString &hostname, const QString &channel) : m_hostname(hostname), m_channel(channel) {}
|
||||
|
||||
/*!
|
||||
* Constructor.
|
||||
*/
|
||||
CVoiceRoom(const QString &serverSpec);
|
||||
|
||||
/*!
|
||||
* \brief QVariant, required for DBus QVariant lists
|
||||
* \return
|
||||
*/
|
||||
virtual QVariant toQVariant() const
|
||||
{
|
||||
return QVariant::fromValue(*this);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get the host name
|
||||
* \return
|
||||
*/
|
||||
const QString &hostName() const { return m_hostname; }
|
||||
|
||||
/*!
|
||||
* Get the voice room
|
||||
* \return
|
||||
*/
|
||||
const QString &channel() const { return m_channel; }
|
||||
|
||||
/*!
|
||||
* Set the host name
|
||||
* \param
|
||||
*/
|
||||
void setHostName(const QString &hostName) { m_hostname = hostName; }
|
||||
|
||||
/*!
|
||||
* Set the voice channel
|
||||
* \param
|
||||
*/
|
||||
void setChannel(const QString &channel) { m_channel = channel; }
|
||||
|
||||
/*!
|
||||
* \brief Valid voice room object?
|
||||
* \return
|
||||
*/
|
||||
bool isValid() const { return !this->m_hostname.isEmpty() && !this->m_channel.isEmpty(); }
|
||||
|
||||
/*!
|
||||
* \brief Equal operator ==
|
||||
* \param other
|
||||
* @return
|
||||
*/
|
||||
bool operator ==(const CVoiceRoom &other) const;
|
||||
|
||||
/*!
|
||||
* \brief Unequal operator ==
|
||||
* \param other
|
||||
* @return
|
||||
*/
|
||||
bool operator !=(const CVoiceRoom &other) const;
|
||||
|
||||
/*!
|
||||
* \brief Value hash
|
||||
*/
|
||||
virtual uint getValueHash() const;
|
||||
|
||||
/*!
|
||||
* \brief Register metadata
|
||||
*/
|
||||
static void registerMetadata();
|
||||
|
||||
protected:
|
||||
|
||||
/*!
|
||||
* \brief Rounded value as string
|
||||
* \param i18n
|
||||
* \return
|
||||
*/
|
||||
virtual QString convertToQString(bool i18n = false) const;
|
||||
|
||||
/*!
|
||||
* \brief Stream to DBus <<
|
||||
* \param argument
|
||||
*/
|
||||
virtual void marshallToDbus(QDBusArgument &argument) const;
|
||||
|
||||
/*!
|
||||
* \brief Stream from DBus >>
|
||||
* \param argument
|
||||
*/
|
||||
virtual void unmarshallFromDbus(const QDBusArgument &argument);
|
||||
|
||||
|
||||
private:
|
||||
QString m_hostname;
|
||||
QString m_channel;
|
||||
|
||||
};
|
||||
} // Voice
|
||||
} // BlackMisc
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Voice::CVoiceRoom)
|
||||
|
||||
#endif // BLACKMISC_VOICEROOM_H
|
||||
Reference in New Issue
Block a user