diff options
| author | Manjeet Dahiya <manjeetdahiya@gmail.com> | 2010-09-07 06:57:12 +0000 |
|---|---|---|
| committer | Manjeet Dahiya <manjeetdahiya@gmail.com> | 2010-09-07 06:57:12 +0000 |
| commit | 966a6f2f63f089624dbd50844069f2b86e13dd81 (patch) | |
| tree | 7e0d09a354c2e64e9cb0c7d0cf211792eea44099 /src | |
| parent | d70690296ad04d77b4b2791281025405fc8f0a65 (diff) | |
| download | qxmpp-966a6f2f63f089624dbd50844069f2b86e13dd81.tar.gz | |
QXmppVCard to QXmppVCardIq
Diffstat (limited to 'src')
| -rw-r--r-- | src/QXmppVCard.h | 162 | ||||
| -rw-r--r-- | src/QXmppVCardIq.cpp (renamed from src/QXmppVCard.cpp) | 62 | ||||
| -rw-r--r-- | src/QXmppVCardIq.h | 121 | ||||
| -rw-r--r-- | src/src.pro | 3 |
4 files changed, 195 insertions, 153 deletions
diff --git a/src/QXmppVCard.h b/src/QXmppVCard.h index 2f417514..0a5ad5b3 100644 --- a/src/QXmppVCard.h +++ b/src/QXmppVCard.h @@ -1,121 +1,41 @@ -/* - * Copyright (C) 2008-2010 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * http://code.google.com/p/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#ifndef QXMPPVCARD_H -#define QXMPPVCARD_H - -#include "QXmppIq.h" -#include <QDate> -#include <QMap> -#include <QDomElement> - -class QImage; - -/// \brief Represents the XMPP vCard. -/// -/// The functions names are self explanatory. -/// Look at QXmppVCardManager and <B>XEP-0054: vcard-temp</B> for more details. -/// -/// There are many field of XMPP vCard which are not present in -/// this class. File a issue for the same. We will add the requested -/// field to this class. -/// - -class QXmppVCard : public QXmppIq -{ -public: - QXmppVCard(const QString& bareJid = ""); - - QDate birthday() const; - void setBirthday(const QDate &birthday); - - QString email() const; - void setEmail(const QString&); - - QString firstName() const; - void setFirstName(const QString&); - - QString fullName() const; - void setFullName(const QString&); - - QString lastName() const; - void setLastName(const QString&); - - QString middleName() const; - void setMiddleName(const QString&); - - QString nickName() const; - void setNickName(const QString&); - - QByteArray photo() const; - void setPhoto(const QByteArray&); - - QString photoType() const; - void setPhotoType(const QString &type); - - QString url() const; - void setUrl(const QString&); - - static bool isVCard(const QDomElement &element); - - /// \cond -// deprecated in release 0.3.0, as it drags in a dependency -// on QtGui, whilst the rest of QXmpp does not require QtGui -#ifndef QXMPP_NO_GUI - QImage Q_DECL_DEPRECATED photoAsImage() const; - void Q_DECL_DEPRECATED setPhoto(const QImage&); -#endif - -// deprecated accessors, use the form without "get" instead -// deprecated in release 0.2.0 - QString Q_DECL_DEPRECATED getFullName() const; - QString Q_DECL_DEPRECATED getNickName() const; -#ifndef QXMPP_NO_GUI - QImage Q_DECL_DEPRECATED getPhotoAsImage() const; -#endif - const QByteArray Q_DECL_DEPRECATED & getPhoto() const; - /// \endcond - -protected: - /// \cond - void parseElementFromChild(const QDomElement&); - void toXmlElementFromChild(QXmlStreamWriter *writer) const; - /// \endcond - -private: - QDate m_birthday; - QString m_email; - QString m_firstName; - QString m_fullName; - QString m_lastName; - QString m_middleName; - QString m_nickName; - QString m_url; - - // not as 64 base - QByteArray m_photo; - QString m_photoType; -}; - -#endif // QXMPPVCARD_H +/*
+ * Copyright (C) 2008-2010 The QXmpp developers
+ *
+ * Authors:
+ * Manjeet Dahiya
+ *
+ * Source:
+ * http://code.google.com/p/qxmpp
+ *
+ * This file is a part of QXmpp library.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ */
+
+#ifndef QXMPPVCARD_H
+#define QXMPPVCARD_H
+
+// deprecated in release 0.3.0
+#warning "QXmppVCard.h is deprecated, use QXmppVCardIq instead"
+
+#include "QXmppVCardIq.h"
+
+// QXmppVCard inherits QXmppVCardIq, to maintain backward compatibility
+class QXmppVCard : public QXmppVCardIq
+{
+public:
+ QXmppVCard(const QString& bareJid = ""):QXmppVCardIq(bareJid)
+ {
+ }
+};
+
+#endif //QXMPPVCARD_H
diff --git a/src/QXmppVCard.cpp b/src/QXmppVCardIq.cpp index da4ada0a..7f0f8f6a 100644 --- a/src/QXmppVCard.cpp +++ b/src/QXmppVCardIq.cpp @@ -30,7 +30,7 @@ #include <QImageReader> #endif -#include "QXmppVCard.h" +#include "QXmppVCardIq.h" #include "QXmppUtils.h" #include "QXmppConstants.h" @@ -53,7 +53,7 @@ QString getImageType(const QByteArray &contents) return "image/unknown"; } -QXmppVCard::QXmppVCard(const QString& jid) : QXmppIq(QXmppIq::Get) +QXmppVCardIq::QXmppVCardIq(const QString& jid) : QXmppIq(QXmppIq::Get) { // for self jid should be empty setTo(jid); @@ -62,7 +62,7 @@ QXmppVCard::QXmppVCard(const QString& jid) : QXmppIq(QXmppIq::Get) /// Returns the date of birth of the individual associated with the vCard. /// -QDate QXmppVCard::birthday() const +QDate QXmppVCardIq::birthday() const { return m_birthday; } @@ -71,7 +71,7 @@ QDate QXmppVCard::birthday() const /// /// \param birthday -void QXmppVCard::setBirthday(const QDate &birthday) +void QXmppVCardIq::setBirthday(const QDate &birthday) { m_birthday = birthday; } @@ -79,7 +79,7 @@ void QXmppVCard::setBirthday(const QDate &birthday) /// Returns the email address. /// -QString QXmppVCard::email() const +QString QXmppVCardIq::email() const { return m_email; } @@ -88,7 +88,7 @@ QString QXmppVCard::email() const /// /// \param email -void QXmppVCard::setEmail(const QString &email) +void QXmppVCardIq::setEmail(const QString &email) { m_email = email; } @@ -96,7 +96,7 @@ void QXmppVCard::setEmail(const QString &email) /// Returns the first name. /// -QString QXmppVCard::firstName() const +QString QXmppVCardIq::firstName() const { return m_firstName; } @@ -105,7 +105,7 @@ QString QXmppVCard::firstName() const /// /// \param firstName -void QXmppVCard::setFirstName(const QString &firstName) +void QXmppVCardIq::setFirstName(const QString &firstName) { m_firstName = firstName; } @@ -113,7 +113,7 @@ void QXmppVCard::setFirstName(const QString &firstName) /// Returns the full name. /// -QString QXmppVCard::fullName() const +QString QXmppVCardIq::fullName() const { return m_fullName; } @@ -122,7 +122,7 @@ QString QXmppVCard::fullName() const /// /// \param fullName -void QXmppVCard::setFullName(const QString &fullName) +void QXmppVCardIq::setFullName(const QString &fullName) { m_fullName = fullName; } @@ -130,7 +130,7 @@ void QXmppVCard::setFullName(const QString &fullName) /// Returns the last name. /// -QString QXmppVCard::lastName() const +QString QXmppVCardIq::lastName() const { return m_lastName; } @@ -139,7 +139,7 @@ QString QXmppVCard::lastName() const /// /// \param lastName -void QXmppVCard::setLastName(const QString &lastName) +void QXmppVCardIq::setLastName(const QString &lastName) { m_lastName = lastName; } @@ -147,7 +147,7 @@ void QXmppVCard::setLastName(const QString &lastName) /// Returns the middle name. /// -QString QXmppVCard::middleName() const +QString QXmppVCardIq::middleName() const { return m_middleName; } @@ -156,7 +156,7 @@ QString QXmppVCard::middleName() const /// /// \param middleName -void QXmppVCard::setMiddleName(const QString &middleName) +void QXmppVCardIq::setMiddleName(const QString &middleName) { m_middleName = middleName; } @@ -164,7 +164,7 @@ void QXmppVCard::setMiddleName(const QString &middleName) /// Returns the nickname. /// -QString QXmppVCard::nickName() const +QString QXmppVCardIq::nickName() const { return m_nickName; } @@ -173,7 +173,7 @@ QString QXmppVCard::nickName() const /// /// \param nickName -void QXmppVCard::setNickName(const QString &nickName) +void QXmppVCardIq::setNickName(const QString &nickName) { m_nickName = nickName; } @@ -182,7 +182,7 @@ void QXmppVCard::setNickName(const QString &nickName) /// homepage or a location at which you can find real-time information about /// the vCard. -QString QXmppVCard::url() const +QString QXmppVCardIq::url() const { return m_url; } @@ -193,7 +193,7 @@ QString QXmppVCard::url() const /// /// \param url -void QXmppVCard::setUrl(const QString& url) +void QXmppVCardIq::setUrl(const QString& url) { m_url = url; } @@ -210,38 +210,38 @@ void QXmppVCard::setUrl(const QString& url) /// QImage myImage = imageReader.read(); /// \endcode -QByteArray QXmppVCard::photo() const +QByteArray QXmppVCardIq::photo() const { return m_photo; } /// Sets the photo's binary contents. -void QXmppVCard::setPhoto(const QByteArray& photo) +void QXmppVCardIq::setPhoto(const QByteArray& photo) { m_photo = photo; } /// Returns the photo's MIME type. -QString QXmppVCard::photoType() const +QString QXmppVCardIq::photoType() const { return m_photoType; } /// Sets the photo's MIME type. -void QXmppVCard::setPhotoType(const QString& photoType) +void QXmppVCardIq::setPhotoType(const QString& photoType) { m_photoType = photoType; } -bool QXmppVCard::isVCard(const QDomElement &nodeRecv) +bool QXmppVCardIq::isVCard(const QDomElement &nodeRecv) { return nodeRecv.firstChildElement("vCard").namespaceURI() == ns_vcard; } -void QXmppVCard::parseElementFromChild(const QDomElement& nodeRecv) +void QXmppVCardIq::parseElementFromChild(const QDomElement& nodeRecv) { // vCard QDomElement cardElement = nodeRecv.firstChildElement("vCard"); @@ -262,7 +262,7 @@ void QXmppVCard::parseElementFromChild(const QDomElement& nodeRecv) m_photoType = photoElement.firstChildElement("TYPE").text(); } -void QXmppVCard::toXmlElementFromChild(QXmlStreamWriter *writer) const +void QXmppVCardIq::toXmlElementFromChild(QXmlStreamWriter *writer) const { writer->writeStartElement("vCard"); helperToXmlAddAttribute(writer,"xmlns", ns_vcard); @@ -310,7 +310,7 @@ void QXmppVCard::toXmlElementFromChild(QXmlStreamWriter *writer) const } #ifndef QXMPP_NO_GUI -QImage QXmppVCard::photoAsImage() const +QImage QXmppVCardIq::photoAsImage() const { QBuffer buffer; buffer.setData(m_photo); @@ -319,7 +319,7 @@ QImage QXmppVCard::photoAsImage() const return imageReader.read(); } -void QXmppVCard::setPhoto(const QImage& image) +void QXmppVCardIq::setPhoto(const QImage& image) { QByteArray ba; QBuffer buffer(&ba); @@ -330,23 +330,23 @@ void QXmppVCard::setPhoto(const QImage& image) } #endif -QString QXmppVCard::getFullName() const +QString QXmppVCardIq::getFullName() const { return m_fullName; } -QString QXmppVCard::getNickName() const +QString QXmppVCardIq::getNickName() const { return m_nickName; } -const QByteArray& QXmppVCard::getPhoto() const +const QByteArray& QXmppVCardIq::getPhoto() const { return m_photo; } #ifndef QXMPP_NO_GUI -QImage QXmppVCard::getPhotoAsImage() const +QImage QXmppVCardIq::getPhotoAsImage() const { return photoAsImage(); } diff --git a/src/QXmppVCardIq.h b/src/QXmppVCardIq.h new file mode 100644 index 00000000..cdb5d8b7 --- /dev/null +++ b/src/QXmppVCardIq.h @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2008-2010 The QXmpp developers + * + * Author: + * Manjeet Dahiya + * + * Source: + * http://code.google.com/p/qxmpp + * + * This file is a part of QXmpp library. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + */ + + +#ifndef QXMPPVCARDIQ_H +#define QXMPPVCARDIQ_H + +#include "QXmppIq.h" +#include <QDate> +#include <QMap> +#include <QDomElement> + +class QImage; + +/// \brief Represents the XMPP vCard. +/// +/// The functions names are self explanatory. +/// Look at QXmppVCardManager and <B>XEP-0054: vcard-temp</B> for more details. +/// +/// There are many field of XMPP vCard which are not present in +/// this class. File a issue for the same. We will add the requested +/// field to this class. +/// + +class QXmppVCardIq : public QXmppIq +{ +public: + QXmppVCardIq(const QString& bareJid = ""); + + QDate birthday() const; + void setBirthday(const QDate &birthday); + + QString email() const; + void setEmail(const QString&); + + QString firstName() const; + void setFirstName(const QString&); + + QString fullName() const; + void setFullName(const QString&); + + QString lastName() const; + void setLastName(const QString&); + + QString middleName() const; + void setMiddleName(const QString&); + + QString nickName() const; + void setNickName(const QString&); + + QByteArray photo() const; + void setPhoto(const QByteArray&); + + QString photoType() const; + void setPhotoType(const QString &type); + + QString url() const; + void setUrl(const QString&); + + static bool isVCard(const QDomElement &element); + + /// \cond +// deprecated in release 0.3.0, as it drags in a dependency +// on QtGui, whilst the rest of QXmpp does not require QtGui +#ifndef QXMPP_NO_GUI + QImage Q_DECL_DEPRECATED photoAsImage() const; + void Q_DECL_DEPRECATED setPhoto(const QImage&); +#endif + +// deprecated accessors, use the form without "get" instead +// deprecated in release 0.2.0 + QString Q_DECL_DEPRECATED getFullName() const; + QString Q_DECL_DEPRECATED getNickName() const; +#ifndef QXMPP_NO_GUI + QImage Q_DECL_DEPRECATED getPhotoAsImage() const; +#endif + const QByteArray Q_DECL_DEPRECATED & getPhoto() const; + /// \endcond + +protected: + /// \cond + void parseElementFromChild(const QDomElement&); + void toXmlElementFromChild(QXmlStreamWriter *writer) const; + /// \endcond + +private: + QDate m_birthday; + QString m_email; + QString m_firstName; + QString m_fullName; + QString m_lastName; + QString m_middleName; + QString m_nickName; + QString m_url; + + // not as 64 base + QByteArray m_photo; + QString m_photoType; +}; + +#endif // QXMPPVCARDIQ_H diff --git a/src/src.pro b/src/src.pro index f369be40..5bcb3289 100644 --- a/src/src.pro +++ b/src/src.pro @@ -79,6 +79,7 @@ INSTALL_HEADERS = QXmppUtils.h \ QXmppRemoteMethod.h \ QXmppRpcIq.h \ QXmppVCardManager.h \ + QXmppVCardIq.h \ QXmppVCard.h \ QXmppVersionIq.h HEADERS += $$INSTALL_HEADERS @@ -133,7 +134,7 @@ SOURCES += QXmppUtils.cpp \ QXmppRemoteMethod.cpp \ QXmppRpcIq.cpp \ QXmppVCardManager.cpp \ - QXmppVCard.cpp \ + QXmppVCardIq.cpp \ QXmppVersionIq.cpp # Plugins |
