aboutsummaryrefslogtreecommitdiff
path: root/src/base/QXmppMixIq.cpp
diff options
context:
space:
mode:
authorLinus Jahn <lnj@kaidan.im>2019-01-22 20:36:31 +0100
committerJeremy Lainé <jeremy.laine@m4x.org>2019-01-27 16:21:03 +0100
commit9df7e7f24a2a6c313e7367d596601e07dbd2baeb (patch)
tree3130352e18d162dbf388a3c8d2c68a0516e7d5c7 /src/base/QXmppMixIq.cpp
parent95063b18660246efe91391d71dd08ec5ab69810d (diff)
downloadqxmpp-9df7e7f24a2a6c313e7367d596601e07dbd2baeb.tar.gz
mix iq: Use d-pointer to remain binary compatibility
Diffstat (limited to 'src/base/QXmppMixIq.cpp')
-rw-r--r--src/base/QXmppMixIq.cpp75
1 files changed, 47 insertions, 28 deletions
diff --git a/src/base/QXmppMixIq.cpp b/src/base/QXmppMixIq.cpp
index a081ba9f..b0e9f3a1 100644
--- a/src/base/QXmppMixIq.cpp
+++ b/src/base/QXmppMixIq.cpp
@@ -31,12 +31,31 @@ static const QStringList MIX_ACTION_TYPES = QStringList() << ""
<< "client-join" << "client-leave" << "join" << "leave"
<< "update-subscription" << "setnick" << "create" << "destroy";
+class QXmppMixIqPrivate : QSharedData
+{
+public:
+ QString jid;
+ QString channelName;
+ QStringList nodes;
+ QString nick;
+ QXmppMixIq::Type actionType = QXmppMixIq::None;
+};
+
+QXmppMixIq::QXmppMixIq()
+ : d(new QXmppMixIqPrivate)
+{
+}
+
+QXmppMixIq::~QXmppMixIq()
+{
+}
+
/// Returns the channel JID. It also contains a participant id for Join/
/// ClientJoin results.
QString QXmppMixIq::jid() const
{
- return m_jid;
+ return d->jid;
}
/// Sets the channel JID. For results of Join/ClientJoin queries this also
@@ -44,7 +63,7 @@ QString QXmppMixIq::jid() const
void QXmppMixIq::setJid(const QString& jid)
{
- m_jid = jid;
+ d->jid = jid;
}
/// Returns the channel name (the name part of the channel JID). This may still
@@ -52,7 +71,7 @@ void QXmppMixIq::setJid(const QString& jid)
QString QXmppMixIq::channelName() const
{
- return m_channelName;
+ return d->channelName;
}
/// Sets the channel name for creating/destroying specific channels. When you
@@ -61,14 +80,14 @@ QString QXmppMixIq::channelName() const
void QXmppMixIq::setChannelName(const QString& channelName)
{
- m_channelName = channelName;
+ d->channelName = channelName;
}
/// Returns the list of nodes to subscribe to.
QStringList QXmppMixIq::nodes() const
{
- return m_nodes;
+ return d->nodes;
}
/// Sets the nodes to subscribe to. Note that for UpdateSubscription queries
@@ -76,35 +95,35 @@ QStringList QXmppMixIq::nodes() const
void QXmppMixIq::setNodes(const QStringList& nodes)
{
- m_nodes = nodes;
+ d->nodes = nodes;
}
/// Returns the user's nickname in the channel.
QString QXmppMixIq::nick() const
{
- return m_nick;
+ return d->nick;
}
/// Sets the nickname for the channel.
void QXmppMixIq::setNick(const QString& nick)
{
- m_nick = nick;
+ d->nick = nick;
}
/// Returns the MIX channel action type.
QXmppMixIq::Type QXmppMixIq::actionType() const
{
- return m_actionType;
+ return d->actionType;
}
/// Sets the channel action.
void QXmppMixIq::setActionType(QXmppMixIq::Type type)
{
- m_actionType = type;
+ d->actionType = type;
}
/// \cond
@@ -119,27 +138,27 @@ void QXmppMixIq::parseElementFromChild(const QDomElement& element)
{
QDomElement child = element.firstChildElement();
// determine action type
- m_actionType = (QXmppMixIq::Type) MIX_ACTION_TYPES.indexOf(child.tagName());
+ d->actionType = (QXmppMixIq::Type) MIX_ACTION_TYPES.indexOf(child.tagName());
if (child.namespaceURI() == ns_mix_pam) {
if (child.hasAttribute("channel"))
- m_jid = child.attribute("channel");
+ d->jid = child.attribute("channel");
child = child.firstChildElement();
}
if (!child.isNull() && child.namespaceURI() == ns_mix) {
if (child.hasAttribute("jid"))
- m_jid = child.attribute("jid");
+ d->jid = child.attribute("jid");
if (child.hasAttribute("channel"))
- m_channelName = child.attribute("channel");
+ d->channelName = child.attribute("channel");
QDomElement subChild = child.firstChildElement();
while (!subChild.isNull()) {
if (subChild.tagName() == "subscribe")
- m_nodes << subChild.attribute("node");
+ d->nodes << subChild.attribute("node");
else if (subChild.tagName() == "nick")
- m_nick = subChild.text();
+ d->nick = subChild.text();
subChild = subChild.nextSiblingElement();
}
@@ -148,36 +167,36 @@ void QXmppMixIq::parseElementFromChild(const QDomElement& element)
void QXmppMixIq::toXmlElementFromChild(QXmlStreamWriter* writer) const
{
- if (m_actionType == None)
+ if (d->actionType == None)
return;
- writer->writeStartElement(MIX_ACTION_TYPES.at(m_actionType));
- if (m_actionType == ClientJoin || m_actionType == ClientLeave) {
+ writer->writeStartElement(MIX_ACTION_TYPES.at(d->actionType));
+ if (d->actionType == ClientJoin || d->actionType == ClientLeave) {
writer->writeAttribute("xmlns", ns_mix_pam);
if (type() == Set)
- helperToXmlAddAttribute(writer, "channel", m_jid);
+ helperToXmlAddAttribute(writer, "channel", d->jid);
- if (m_actionType == ClientJoin)
+ if (d->actionType == ClientJoin)
writer->writeStartElement("join");
- else if (m_actionType == ClientLeave)
+ else if (d->actionType == ClientLeave)
writer->writeStartElement("leave");
}
writer->writeAttribute("xmlns", ns_mix);
- helperToXmlAddAttribute(writer, "channel", m_channelName);
+ helperToXmlAddAttribute(writer, "channel", d->channelName);
if (type() == Result)
- helperToXmlAddAttribute(writer, "jid", m_jid);
+ helperToXmlAddAttribute(writer, "jid", d->jid);
- for (auto node : m_nodes) {
+ for (auto node : d->nodes) {
writer->writeStartElement("subscribe");
writer->writeAttribute("node", node);
writer->writeEndElement();
}
- if (!m_nick.isEmpty())
- writer->writeTextElement("nick", m_nick);
+ if (!d->nick.isEmpty())
+ writer->writeTextElement("nick", d->nick);
writer->writeEndElement();
- if (m_actionType == ClientJoin || m_actionType == ClientLeave)
+ if (d->actionType == ClientJoin || d->actionType == ClientLeave)
writer->writeEndElement();
}
/// \endcond