diff options
| author | 0xd34df00d <0xd34df00d@gmail.com> | 2014-03-22 22:51:00 +0400 |
|---|---|---|
| committer | 0xd34df00d <0xd34df00d@gmail.com> | 2014-03-22 22:51:00 +0400 |
| commit | 23d73cbe97ecf10f8b45787447b9971a068e61c8 (patch) | |
| tree | b77254e5c646995cccd15c09aafeaaecc77bceda /src/base | |
| parent | a4c3f19e874cace34af4476a06cc4b530b46c516 (diff) | |
| download | qxmpp-23d73cbe97ecf10f8b45787447b9971a068e61c8.tar.gz | |
Added QXmppVCardOrganization API.
Diffstat (limited to 'src/base')
| -rw-r--r-- | src/base/QXmppVCardIq.cpp | 113 | ||||
| -rw-r--r-- | src/base/QXmppVCardIq.h | 39 |
2 files changed, 152 insertions, 0 deletions
diff --git a/src/base/QXmppVCardIq.cpp b/src/base/QXmppVCardIq.cpp index 11e34e2c..9703c5dc 100644 --- a/src/base/QXmppVCardIq.cpp +++ b/src/base/QXmppVCardIq.cpp @@ -440,6 +440,99 @@ void QXmppVCardPhone::toXml(QXmlStreamWriter *writer) const } /// \endcond +class QXmppVCardOrganizationPrivate : public QSharedData +{ +public: + QString organization; + QString unit; + QString role; + QString title; +}; + +QXmppVCardOrganization::QXmppVCardOrganization() + : d(new QXmppVCardOrganizationPrivate) +{ +} + +QXmppVCardOrganization::QXmppVCardOrganization(const QXmppVCardOrganization &other) + : d(other.d) +{ +} + +QXmppVCardOrganization::~QXmppVCardOrganization() +{ +} + +QXmppVCardOrganization& QXmppVCardOrganization::operator=(const QXmppVCardOrganization &other) +{ + d = other.d; + return *this; +} + +QString QXmppVCardOrganization::organization() const +{ + return d->organization; +} + +void QXmppVCardOrganization::setOrganization(const QString &org) +{ + d->organization = org; +} + +QString QXmppVCardOrganization::unit() const +{ + return d->unit; +} + +void QXmppVCardOrganization::setUnit(const QString &unit) +{ + d->unit = unit; +} + +QString QXmppVCardOrganization::role() const +{ + return d->role; +} + +void QXmppVCardOrganization::setRole(const QString &role) +{ + d->role = role; +} + +QString QXmppVCardOrganization::title() const +{ + return d->title; +} + +void QXmppVCardOrganization::setTitle(const QString &title) +{ + d->title = title; +} + +void QXmppVCardOrganization::parse(const QDomElement &cardElem) +{ + d->title = cardElem.firstChildElement("TITLE").text(); + d->role = cardElem.firstChildElement("ROLE").text(); + + const QDomElement &orgElem = cardElem.firstChildElement("ORG"); + d->organization = orgElem.firstChildElement("ORGNAME").text(); + d->unit = orgElem.firstChildElement("ORGUNIT").text(); +} + +void QXmppVCardOrganization::toXml(QXmlStreamWriter *stream) const +{ + if (!d->unit.isEmpty() || !d->organization.isEmpty()) + { + stream->writeStartElement("ORG"); + stream->writeTextElement("ORGNAME", d->organization); + stream->writeTextElement("ORGUNIT", d->unit); + stream->writeEndElement(); + } + + helperToXmlAddTextElement(stream, "TITLE", d->title); + helperToXmlAddTextElement(stream, "ROLE", d->role); +} + class QXmppVCardIqPrivate : public QSharedData { public: @@ -459,6 +552,7 @@ public: QList<QXmppVCardAddress> addresses; QList<QXmppVCardEmail> emails; QList<QXmppVCardPhone> phones; + QXmppVCardOrganization organization; }; /// Constructs a QXmppVCardIq for the specified recipient. @@ -732,6 +826,21 @@ void QXmppVCardIq::setPhones(const QList<QXmppVCardPhone> &phones) { d->phones = phones; } + +/// Returns the organization info. + +QXmppVCardOrganization QXmppVCardIq::organization() const +{ + return d->organization; +} + +/// Sets the organization info. + +void QXmppVCardIq::setOrganization(const QXmppVCardOrganization &org) +{ + d->organization = org; +} + /// \cond bool QXmppVCardIq::isVCard(const QDomElement &nodeRecv) { @@ -774,6 +883,8 @@ void QXmppVCardIq::parseElementFromChild(const QDomElement& nodeRecv) } child = child.nextSiblingElement(); } + + d->organization.parse(cardElement); } void QXmppVCardIq::toXmlElementFromChild(QXmlStreamWriter *writer) const @@ -821,6 +932,8 @@ void QXmppVCardIq::toXmlElementFromChild(QXmlStreamWriter *writer) const if (!d->url.isEmpty()) helperToXmlAddTextElement(writer, "URL", d->url); + d->organization.toXml(writer); + writer->writeEndElement(); } /// \endcond diff --git a/src/base/QXmppVCardIq.h b/src/base/QXmppVCardIq.h index e1de81b6..1a2ebe06 100644 --- a/src/base/QXmppVCardIq.h +++ b/src/base/QXmppVCardIq.h @@ -33,6 +33,7 @@ class QXmppVCardAddressPrivate; class QXmppVCardEmailPrivate; class QXmppVCardPhonePrivate; +class QXmppVCardOrganizationPrivate; class QXmppVCardIqPrivate; /// \brief Represent a vCard address. @@ -165,6 +166,41 @@ private: QSharedDataPointer<QXmppVCardPhonePrivate> d; }; +/// \brief Represents organization information in XMPP vCards. +/// +/// This contains both information about organization itself and +/// information about job position in the organization. + +class QXMPP_EXPORT QXmppVCardOrganization +{ +public: + QXmppVCardOrganization(); + QXmppVCardOrganization(const QXmppVCardOrganization &other); + ~QXmppVCardOrganization(); + + QXmppVCardOrganization& operator=(const QXmppVCardOrganization &other); + + QString organization() const; + void setOrganization(const QString&); + + QString unit() const; + void setUnit(const QString&); + + QString title() const; + void setTitle(const QString&); + + QString role() const; + void setRole(const QString&); + + /// \cond + void parse(const QDomElement &element); + void toXml(QXmlStreamWriter *stream) const; + /// \endcond + +private: + QSharedDataPointer<QXmppVCardOrganizationPrivate> d; +}; + /// \brief Represents the XMPP vCard. /// /// The functions names are self explanatory. @@ -226,6 +262,9 @@ public: QList<QXmppVCardPhone> phones() const; void setPhones(const QList<QXmppVCardPhone> &phones); + QXmppVCardOrganization organization() const; + void setOrganization(const QXmppVCardOrganization&); + /// \cond static bool isVCard(const QDomElement &element); /// \endcond |
