aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2012-09-02 17:01:52 +0200
committerJeremy Lainé <jeremy.laine@m4x.org>2012-09-02 17:01:52 +0200
commit9d6acca05fd618540df843d60c199a9b0e3b6e43 (patch)
tree2a57b1ad2aa452f471bc46ca245dc6fec234803a
parent76b2060429b4c39ac957600196a9bc1de840e59e (diff)
downloadqxmpp-9d6acca05fd618540df843d60c199a9b0e3b6e43.tar.gz
add support for vCard "DESC" element
-rw-r--r--src/base/QXmppVCardIq.cpp18
-rw-r--r--src/base/QXmppVCardIq.h3
-rw-r--r--tests/vcard.cpp2
3 files changed, 23 insertions, 0 deletions
diff --git a/src/base/QXmppVCardIq.cpp b/src/base/QXmppVCardIq.cpp
index 27bcbc34..68f573e5 100644
--- a/src/base/QXmppVCardIq.cpp
+++ b/src/base/QXmppVCardIq.cpp
@@ -438,6 +438,7 @@ class QXmppVCardIqPrivate : public QSharedData
{
public:
QDate birthday;
+ QString description;
QString firstName;
QString fullName;
QString lastName;
@@ -504,6 +505,20 @@ void QXmppVCardIq::setBirthday(const QDate &birthday)
d->birthday = birthday;
}
+/// Returns the free-form descriptive text.
+
+QString QXmppVCardIq::description() const
+{
+ return d->description;
+}
+
+/// Sets the free-form descriptive text.
+
+void QXmppVCardIq::setDescription(const QString &description)
+{
+ d->description = description;
+}
+
/// Returns the email address.
///
@@ -722,6 +737,7 @@ void QXmppVCardIq::parseElementFromChild(const QDomElement& nodeRecv)
// vCard
QDomElement cardElement = nodeRecv.firstChildElement("vCard");
d->birthday = QDate::fromString(cardElement.firstChildElement("BDAY").text(), "yyyy-MM-dd");
+ d->description = cardElement.firstChildElement("DESC").text();
d->fullName = cardElement.firstChildElement("FN").text();
d->nickName = cardElement.firstChildElement("NICKNAME").text();
QDomElement nameElement = cardElement.firstChildElement("N");
@@ -762,6 +778,8 @@ void QXmppVCardIq::toXmlElementFromChild(QXmlStreamWriter *writer) const
address.toXml(writer);
if (d->birthday.isValid())
helperToXmlAddTextElement(writer, "BDAY", d->birthday.toString("yyyy-MM-dd"));
+ if (!d->description.isEmpty())
+ helperToXmlAddTextElement(writer, "DESC", d->description);
foreach (const QXmppVCardEmail &email, d->emails)
email.toXml(writer);
if (!d->fullName.isEmpty())
diff --git a/src/base/QXmppVCardIq.h b/src/base/QXmppVCardIq.h
index 1c1b1063..ddecd3f1 100644
--- a/src/base/QXmppVCardIq.h
+++ b/src/base/QXmppVCardIq.h
@@ -187,6 +187,9 @@ public:
QDate birthday() const;
void setBirthday(const QDate &birthday);
+ QString description() const;
+ void setDescription(const QString &description);
+
QString email() const;
void setEmail(const QString&);
diff --git a/tests/vcard.cpp b/tests/vcard.cpp
index 1a9d175c..92c1c5ee 100644
--- a/tests/vcard.cpp
+++ b/tests/vcard.cpp
@@ -137,6 +137,7 @@ void tst_QXmppVCardIq::testVCard()
"<vCard xmlns=\"vcard-temp\">"
"<ADR><CTRY>France</CTRY></ADR>"
"<BDAY>1983-09-14</BDAY>"
+ "<DESC>I like XMPP.</DESC>"
"<EMAIL><INTERNET/><USERID>foo.bar@example.com</USERID></EMAIL>"
"<FN>Foo Bar!</FN>"
"<NICKNAME>FooBar</NICKNAME>"
@@ -161,6 +162,7 @@ void tst_QXmppVCardIq::testVCard()
QCOMPARE(vcard.addresses()[0].country(), QLatin1String("France"));
QCOMPARE(int(vcard.addresses()[0].type()), int(QXmppVCardEmail::None));
QCOMPARE(vcard.birthday(), QDate(1983, 9, 14));
+ QCOMPARE(vcard.description(), QLatin1String("I like XMPP."));
QCOMPARE(vcard.email(), QLatin1String("foo.bar@example.com"));
QCOMPARE(vcard.emails().size(), 1);
QCOMPARE(vcard.emails()[0].address(), QLatin1String("foo.bar@example.com"));