mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-09 05:28:09 +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
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
|
||||
Reference in New Issue
Block a user