aboutsummaryrefslogtreecommitdiff
path: root/src/base
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2014-07-19 10:23:40 +0200
committerJeremy Lainé <jeremy.laine@m4x.org>2014-07-19 10:23:40 +0200
commit70e7b6005de3e4a2e0237f18196825d96f4ee4d3 (patch)
tree1b017e68025534d194362a6dc206f04a2ca8f553 /src/base
parent68f89992207c592cf0be8567d5c3d5e43157f9b6 (diff)
parent07ae4a63307928e1af97b75b3de23530c74beb3f (diff)
downloadqxmpp-70e7b6005de3e4a2e0237f18196825d96f4ee4d3.tar.gz
Merge branch 'master' of github.com:qxmpp-project/qxmpp
Diffstat (limited to 'src/base')
-rw-r--r--src/base/QXmppConstants.cpp2
-rw-r--r--src/base/QXmppConstants.h2
-rw-r--r--src/base/QXmppGlobal.h2
-rw-r--r--src/base/QXmppMessage.cpp126
-rw-r--r--src/base/QXmppMessage.h23
-rw-r--r--src/base/QXmppVCardIq.cpp94
-rw-r--r--src/base/QXmppVCardIq.h15
7 files changed, 263 insertions, 1 deletions
diff --git a/src/base/QXmppConstants.cpp b/src/base/QXmppConstants.cpp
index ec314376..76098d58 100644
--- a/src/base/QXmppConstants.cpp
+++ b/src/base/QXmppConstants.cpp
@@ -114,3 +114,5 @@ const char* ns_attention = "urn:xmpp:attention:0";
const char* ns_bob = "urn:xmpp:bob";
// XEP-0249: Direct MUC Invitations
const char* ns_conference = "jabber:x:conference";
+// XEP-0333: Chat Markers
+const char* ns_chat_markers = "urn:xmpp:chat-markers:0";
diff --git a/src/base/QXmppConstants.h b/src/base/QXmppConstants.h
index 85030c12..bf544159 100644
--- a/src/base/QXmppConstants.h
+++ b/src/base/QXmppConstants.h
@@ -115,5 +115,7 @@ extern const char* ns_attention;
extern const char* ns_bob;
// XEP-0249: Direct MUC Invitations
extern const char* ns_conference;
+// XEP-0333: Char Markers
+extern const char* ns_chat_markers;
#endif // QXMPPCONSTANTS_H
diff --git a/src/base/QXmppGlobal.h b/src/base/QXmppGlobal.h
index 52303f5f..ebddab73 100644
--- a/src/base/QXmppGlobal.h
+++ b/src/base/QXmppGlobal.h
@@ -52,7 +52,7 @@
/// available.
///
-#define QXMPP_VERSION 0x000800
+#define QXMPP_VERSION 0x000801
QXMPP_EXPORT QString QXmppVersion();
diff --git a/src/base/QXmppMessage.cpp b/src/base/QXmppMessage.cpp
index e32465b7..4bdc6329 100644
--- a/src/base/QXmppMessage.cpp
+++ b/src/base/QXmppMessage.cpp
@@ -48,6 +48,13 @@ static const char* message_types[] = {
"headline"
};
+static const char* marker_types[] = {
+ "",
+ "received",
+ "displayed",
+ "acknowledged"
+};
+
static const char *ns_xhtml = "http://www.w3.org/1999/xhtml";
enum StampType
@@ -80,6 +87,12 @@ public:
QString mucInvitationJid;
QString mucInvitationPassword;
QString mucInvitationReason;
+
+ // XEP-0333: Chat Markers
+ bool markable;
+ QXmppMessage::Marker marker;
+ QString markedId;
+ QString markedThread;
};
/// Constructs a QXmppMessage.
@@ -101,6 +114,9 @@ QXmppMessage::QXmppMessage(const QString& from, const QString& to, const
d->body = body;
d->thread = thread;
d->receiptRequested = false;
+
+ d->markable = false;
+ d->marker = NoMarker;
}
/// Constructs a copy of \a other.
@@ -363,6 +379,70 @@ namespace
}
}
+/// Returns true if a message is markable, as defined
+/// XEP-0333: Chat Markers.
+
+bool QXmppMessage::isMarkable() const
+{
+ return d->markable;
+}
+
+/// Sets if the message is markable, as defined
+/// XEP-0333: Chat Markers.
+
+void QXmppMessage::setMarkable(const bool markable)
+{
+ d->markable = markable;
+}
+
+/// Returns the message's marker id, as defined
+/// XEP-0333: Chat Markers.
+
+QString QXmppMessage::markedId() const
+{
+ return d->markedId;
+}
+
+/// Sets the message's marker id, as defined
+/// XEP-0333: Chat Markers.
+
+void QXmppMessage::setMarkerId(const QString &markerId)
+{
+ d->markedId = markerId;
+}
+
+/// Returns the message's marker thread, as defined
+/// XEP-0333: Chat Markers.
+
+QString QXmppMessage::markedThread() const
+{
+ return d->markedThread;
+}
+
+/// Sets the message's marked thread, as defined
+/// XEP-0333: Chat Markers.
+
+void QXmppMessage::setMarkedThread(const QString &markedThread)
+{
+ d->markedThread = markedThread;
+}
+
+/// Returns the message's marker, as defined
+/// XEP-0333: Chat Markers.
+
+QXmppMessage::Marker QXmppMessage::marker() const
+{
+ return d->marker;
+}
+
+/// Sets the message's marker, as defined
+/// XEP-0333: Chat Markers
+
+void QXmppMessage::setMarker(const Marker marker)
+{
+ d->marker = marker;
+}
+
/// \cond
void QXmppMessage::parse(const QDomElement &element)
{
@@ -433,6 +513,36 @@ void QXmppMessage::parse(const QDomElement &element)
// XEP-0224: Attention
d->attentionRequested = element.firstChildElement("attention").namespaceURI() == ns_attention;
+ // XEP-0333: Chat Markers
+ QDomElement markableElement = element.firstChildElement("markable");
+ if (!markableElement.isNull())
+ {
+ d->markable = true;
+ }
+ // check for all the marker types
+ QDomElement chatStateElement;
+ QXmppMessage::Marker marker = QXmppMessage::NoMarker;
+ for (int i = Received; i <= Acknowledged; i++)
+ {
+ chatStateElement = element.firstChildElement(marker_types[i]);
+ if (!chatStateElement.isNull() &&
+ chatStateElement.namespaceURI() == ns_chat_markers)
+ {
+ marker = static_cast<QXmppMessage::Marker>(i);
+ break;
+ }
+ }
+ // if marker is present, check it's the right ns
+ if (!chatStateElement.isNull())
+ {
+ if (chatStateElement.namespaceURI() == ns_chat_markers)
+ {
+ d->marker = marker;
+ d->markedId = chatStateElement.attribute("id", QString());
+ d->markedThread = chatStateElement.attribute("thread", QString());
+ }
+ }
+
const QList<QPair<QString, QString> > &knownElems = knownMessageSubelems();
QXmppElementList extensions;
@@ -555,6 +665,22 @@ void QXmppMessage::toXml(QXmlStreamWriter *xmlWriter) const
xmlWriter->writeEndElement();
}
+ // XEP-0333: Chat Markers
+ if (d->markable) {
+ xmlWriter->writeStartElement("markable");
+ xmlWriter->writeAttribute("xmlns", ns_chat_markers);
+ xmlWriter->writeEndElement();
+ }
+ if (d->marker != NoMarker) {
+ xmlWriter->writeStartElement(marker_types[d->marker]);
+ xmlWriter->writeAttribute("xmlns", ns_chat_markers);
+ xmlWriter->writeAttribute("id", d->markedId);
+ if (!d->markedThread.isNull() && !d->markedThread.isEmpty()) {
+ xmlWriter->writeAttribute("thread", d->markedThread);
+ }
+ xmlWriter->writeEndElement();
+ }
+
// other extensions
QXmppStanza::extensionsToXml(xmlWriter);
diff --git a/src/base/QXmppMessage.h b/src/base/QXmppMessage.h
index e927a85c..119dba3e 100644
--- a/src/base/QXmppMessage.h
+++ b/src/base/QXmppMessage.h
@@ -60,8 +60,18 @@ public:
Paused, ///< User had been composing but now has stopped.
};
+ /// This enum describes a chat marker as defined by
+ /// XEP-0333 : Char Markers
+ enum Marker {
+ NoMarker = 0,
+ Received,
+ Displayed,
+ Acknowledged
+ };
+
QXmppMessage(const QString& from = QString(), const QString& to = QString(),
const QString& body = QString(), const QString& thread = QString());
+
QXmppMessage(const QXmppMessage &other);
~QXmppMessage();
@@ -106,6 +116,19 @@ public:
QString xhtml() const;
void setXhtml(const QString &xhtml);
+ // XEP-0333
+ bool isMarkable() const;
+ void setMarkable(const bool);
+
+ QString markedId() const;
+ void setMarkerId(const QString&);
+
+ QString markedThread() const;
+ void setMarkedThread(const QString&);
+
+ Marker marker() const;
+ void setMarker(const Marker);
+
/// \cond
void parse(const QDomElement &element);
void toXml(QXmlStreamWriter *writer) const;
diff --git a/src/base/QXmppVCardIq.cpp b/src/base/QXmppVCardIq.cpp
index 6d9f1fdb..4a237200 100644
--- a/src/base/QXmppVCardIq.cpp
+++ b/src/base/QXmppVCardIq.cpp
@@ -86,6 +86,25 @@ QXmppVCardAddress& QXmppVCardAddress::operator=(const QXmppVCardAddress &other)
return *this;
}
+/// \brief Checks if two address objects represent the same address.
+
+bool operator==(const QXmppVCardAddress &left, const QXmppVCardAddress &right)
+{
+ return left.type() == right.type() &&
+ left.country() == right.country() &&
+ left.locality() == right.locality() &&
+ left.postcode() == right.postcode() &&
+ left.region() == right.region() &&
+ left.street() == right.street();
+}
+
+/// \brief Checks if two address objects represent different addresses.
+
+bool operator!=(const QXmppVCardAddress &left, const QXmppVCardAddress &right)
+{
+ return !(left == right);
+}
+
/// Returns the country.
QString QXmppVCardAddress::country() const
@@ -250,6 +269,21 @@ QXmppVCardEmail& QXmppVCardEmail::operator=(const QXmppVCardEmail &other)
return *this;
}
+/// \brief Checks if two email objects represent the same email address.
+
+bool operator==(const QXmppVCardEmail &left, const QXmppVCardEmail &right)
+{
+ return left.type() == right.type() &&
+ left.address() == right.address();
+}
+
+/// \brief Checks if two email objects represent different email addresses.
+
+bool operator!=(const QXmppVCardEmail &left, const QXmppVCardEmail &right)
+{
+ return !(left == right);
+}
+
/// Returns the e-mail address.
QString QXmppVCardEmail::address() const
@@ -353,6 +387,21 @@ QString QXmppVCardPhone::number() const
return d->number;
}
+/// \brief Checks if two phone objects represent the same phone number.
+
+bool operator==(const QXmppVCardPhone &left, const QXmppVCardPhone &right)
+{
+ return left.type() == right.type() &&
+ left.number() == right.number();
+}
+
+/// \brief Checks if two phone objects represent different phone numbers.
+
+bool operator!=(const QXmppVCardPhone &left, const QXmppVCardPhone &right)
+{
+ return !(left == right);
+}
+
/// Sets the phone \a number.
void QXmppVCardPhone::setNumber(const QString &number)
@@ -475,6 +524,23 @@ QXmppVCardOrganization& QXmppVCardOrganization::operator=(const QXmppVCardOrgani
return *this;
}
+/// \brief Checks if two organization objects represent the same organization.
+
+bool operator==(const QXmppVCardOrganization &left, const QXmppVCardOrganization &right)
+{
+ return left.organization() == right.organization() &&
+ left.unit() == right.unit() &&
+ left.title() == right.title() &&
+ left.role() == right.role();
+}
+
+/// \brief Checks if two organization objects represent different organizations.
+
+bool operator!=(const QXmppVCardOrganization &left, const QXmppVCardOrganization &right)
+{
+ return !(left == right);
+}
+
/// Returns the name of the organization.
QString QXmppVCardOrganization::organization() const
@@ -612,6 +678,34 @@ QXmppVCardIq& QXmppVCardIq::operator=(const QXmppVCardIq &other)
return *this;
}
+/// \brief Checks if two VCard objects represent the same VCard.
+
+bool operator==(const QXmppVCardIq &left, const QXmppVCardIq &right)
+{
+ return left.birthday() == right.birthday() &&
+ left.description() == right.description() &&
+ left.email() == right.email() &&
+ left.firstName() == right.firstName() &&
+ left.fullName() == right.fullName() &&
+ left.lastName() == right.lastName() &&
+ left.middleName() == right.middleName() &&
+ left.nickName() == right.nickName() &&
+ left.photo() == right.photo() &&
+ left.photoType() == right.photoType() &&
+ left.url() == right.url() &&
+ left.addresses() == right.addresses() &&
+ left.emails() == right.emails() &&
+ left.phones() == right.phones() &&
+ left.organization() == right.organization();
+}
+
+/// \brief Checks if two VCard objects represent different VCards.
+
+bool operator!=(const QXmppVCardIq &left, const QXmppVCardIq &right)
+{
+ return !(left == right);
+}
+
/// Returns the date of birth of the individual associated with the vCard.
///
diff --git a/src/base/QXmppVCardIq.h b/src/base/QXmppVCardIq.h
index cb54b91d..966ff632 100644
--- a/src/base/QXmppVCardIq.h
+++ b/src/base/QXmppVCardIq.h
@@ -84,6 +84,9 @@ private:
QSharedDataPointer<QXmppVCardAddressPrivate> d;
};
+QXMPP_EXPORT bool operator==(const QXmppVCardAddress&, const QXmppVCardAddress&);
+QXMPP_EXPORT bool operator!=(const QXmppVCardAddress&, const QXmppVCardAddress&);
+
/// \brief Represents a vCard e-mail address.
class QXMPP_EXPORT QXmppVCardEmail
@@ -121,6 +124,9 @@ private:
QSharedDataPointer<QXmppVCardEmailPrivate> d;
};
+QXMPP_EXPORT bool operator==(const QXmppVCardEmail&, const QXmppVCardEmail&);
+QXMPP_EXPORT bool operator!=(const QXmppVCardEmail&, const QXmppVCardEmail&);
+
/// \brief Represents a vCard phone number.
class QXMPP_EXPORT QXmppVCardPhone
@@ -166,6 +172,9 @@ private:
QSharedDataPointer<QXmppVCardPhonePrivate> d;
};
+QXMPP_EXPORT bool operator==(const QXmppVCardPhone&, const QXmppVCardPhone&);
+QXMPP_EXPORT bool operator!=(const QXmppVCardPhone&, const QXmppVCardPhone&);
+
/// \brief Represents organization information in XMPP vCards.
///
/// This contains both information about organization itself and
@@ -201,6 +210,9 @@ private:
QSharedDataPointer<QXmppVCardOrganizationPrivate> d;
};
+QXMPP_EXPORT bool operator==(const QXmppVCardOrganization&, const QXmppVCardOrganization&);
+QXMPP_EXPORT bool operator!=(const QXmppVCardOrganization&, const QXmppVCardOrganization&);
+
/// \brief Represents the XMPP vCard.
///
/// The functions names are self explanatory.
@@ -279,4 +291,7 @@ private:
QSharedDataPointer<QXmppVCardIqPrivate> d;
};
+QXMPP_EXPORT bool operator==(const QXmppVCardIq&, const QXmppVCardIq&);
+QXMPP_EXPORT bool operator!=(const QXmppVCardIq&, const QXmppVCardIq&);
+
#endif // QXMPPVCARDIQ_H