aboutsummaryrefslogtreecommitdiff
path: root/src/base/QXmppStanza.cpp
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2012-09-03 12:01:45 +0200
committerJeremy Lainé <jeremy.laine@m4x.org>2012-09-03 12:01:45 +0200
commit6f087827d2c08a1e7edc70d389521fcaf138c6e8 (patch)
tree03b7fe2f7e6114ce658e33aa438f12749079c0fc /src/base/QXmppStanza.cpp
parenta8443321caeedab90f82be99cf9fe388666c32cb (diff)
downloadqxmpp-6f087827d2c08a1e7edc70d389521fcaf138c6e8.tar.gz
add QXmppExtendedAddress
Diffstat (limited to 'src/base/QXmppStanza.cpp')
-rw-r--r--src/base/QXmppStanza.cpp128
1 files changed, 127 insertions, 1 deletions
diff --git a/src/base/QXmppStanza.cpp b/src/base/QXmppStanza.cpp
index 56cdba0a..08cd97f2 100644
--- a/src/base/QXmppStanza.cpp
+++ b/src/base/QXmppStanza.cpp
@@ -1,8 +1,10 @@
/*
* Copyright (C) 2008-2012 The QXmpp developers
*
- * Author:
+ * Authors:
* Manjeet Dahiya
+ * Jeremy Lainé
+ * Georg Rudoy
*
* Source:
* http://code.google.com/p/qxmpp
@@ -31,6 +33,130 @@
uint QXmppStanza::s_uniqeIdNo = 0;
+class QXmppExtendedAddressPrivate : public QSharedData
+{
+public:
+ bool delivered;
+ QString description;
+ QString jid;
+ QString type;
+};
+
+/// Constructs an empty extended address.
+
+QXmppExtendedAddress::QXmppExtendedAddress()
+ : d(new QXmppExtendedAddressPrivate())
+{
+ d->delivered = false;
+}
+
+/// Constructs a copy of other.
+///
+/// \param other
+///
+QXmppExtendedAddress::QXmppExtendedAddress(const QXmppExtendedAddress &other)
+ : d(other.d)
+{
+}
+
+QXmppExtendedAddress::~QXmppExtendedAddress()
+{
+}
+
+/// Assigns the other address to this one.
+///
+/// \param other
+///
+QXmppExtendedAddress& QXmppExtendedAddress::operator=(const QXmppExtendedAddress& other)
+{
+ d = other.d;
+ return *this;
+}
+
+/// Returns the human-readable description of the address.
+
+QString QXmppExtendedAddress::description() const
+{
+ return d->description;
+}
+
+/// Sets the human-readable \a description of the address.
+
+void QXmppExtendedAddress::setDescription(const QString &description)
+{
+ d->description = description;
+}
+
+/// Returns the JID of the address.
+
+QString QXmppExtendedAddress::jid() const
+{
+ return d->jid;
+}
+
+/// Sets the JID of the address.
+
+void QXmppExtendedAddress::setJid(const QString &jid)
+{
+ d->jid = jid;
+}
+
+/// Returns the type of the address.
+
+QString QXmppExtendedAddress::type() const
+{
+ return d->type;
+}
+
+/// Sets the \a type of the address.
+
+void QXmppExtendedAddress::setType(const QString &type)
+{
+ d->type = type;
+}
+
+/// Returns whether the stanza has been delivered to this address.
+
+bool QXmppExtendedAddress::isDelivered() const
+{
+ return d->delivered;
+}
+
+/// Sets whether the stanza has been \a delivered to this address.
+
+void QXmppExtendedAddress::setDelivered(bool delivered)
+{
+ d->delivered = delivered;
+}
+
+/// Checks whether this address is valid. The extended address is considered
+/// to be valid if at least type and JID fields are non-empty.
+
+bool QXmppExtendedAddress::isValid() const
+{
+ return !d->type.isEmpty() && !d->jid.isEmpty();
+}
+
+void QXmppExtendedAddress::parse(const QDomElement &element)
+{
+ d->delivered = element.attribute("delivered") == "true";
+ d->description = element.attribute("desc");
+ d->jid = element.attribute("jid");
+ d->type = element.attribute("type");
+}
+
+void QXmppExtendedAddress::toXml(QXmlStreamWriter *xmlWriter)
+{
+ xmlWriter->writeStartElement("address");
+ if (d->delivered)
+ xmlWriter->writeAttribute("delivered", "true");
+ if (!d->description.isEmpty())
+ xmlWriter->writeAttribute("desc", d->description);
+ xmlWriter->writeAttribute("jid", d->jid);
+ xmlWriter->writeAttribute("type", d->type);
+ xmlWriter->writeEndElement();
+}
+
QXmppStanza::Error::Error():
m_code(0),
m_type(static_cast<QXmppStanza::Error::Type>(-1)),