diff options
| author | Linus Jahn <lnj@kaidan.im> | 2019-06-16 08:31:15 +0200 |
|---|---|---|
| committer | LNJ <lnj@kaidan.im> | 2019-10-19 16:43:36 +0200 |
| commit | 98f2fd04b0a95840584320858ff54cd5caff8f70 (patch) | |
| tree | d7f3e2bc8be6b6c63bb31214ec84b1737a4288b8 /src/base/QXmppMessage.h | |
| parent | 38d0769c80c47627225d6278ef17453915b3a854 (diff) | |
| download | qxmpp-98f2fd04b0a95840584320858ff54cd5caff8f70.tar.gz | |
Refactor & clean up QXmppMessage
This simplifies parsing and fixes a possible bug:
The bug case looks like this:
- We have one element we want to parse (e,g, "attachment" with namespace xyz)
- There is another element called "attachment" in the stanza and it's
located before the other element.
- QXmppMessage tries to parse the attachment element using
firstChildElement("attachment") and checks the namespace
- The namespace (of the first) element doesn't match
- The actual "attachment" element is not parsed
This also fixes the "constructor does not initialize these fields: […]"
warnings for QXmppMessagePrivate.
Diffstat (limited to 'src/base/QXmppMessage.h')
| -rw-r--r-- | src/base/QXmppMessage.h | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/base/QXmppMessage.h b/src/base/QXmppMessage.h index 2743ca13..21c656c1 100644 --- a/src/base/QXmppMessage.h +++ b/src/base/QXmppMessage.h @@ -3,6 +3,8 @@ * * Author: * Manjeet Dahiya + * Jeremy Lainé + * Linus Jahn * * Source: * https://github.com/qxmpp-project/qxmpp @@ -24,7 +26,6 @@ #ifndef QXMPPMESSAGE_H #define QXMPPMESSAGE_H -#include <QDateTime> #include "QXmppStanza.h" class QXmppMessagePrivate; @@ -36,9 +37,8 @@ class QXmppMessagePrivate; class QXMPP_EXPORT QXmppMessage : public QXmppStanza { public: - /// This enum described a message type. - enum Type - { + /// This enum describes a message type. + enum Type { Error = 0, Normal, Chat, @@ -48,8 +48,7 @@ public: /// This enum describes a chat state as defined by XEP-0085: Chat State /// Notifications. - enum State - { + enum State { None = 0, ///< The message does not contain any chat state information. Active, ///< User is actively participating in the chat session. Inactive, ///< User has not been actively participating in the chat session. @@ -94,6 +93,8 @@ public: QXmppMessage& operator=(const QXmppMessage &other); + bool isXmppStanza() const override; + QString body() const; void setBody(const QString&); @@ -133,7 +134,7 @@ public: QString xhtml() const; void setXhtml(const QString &xhtml); - // XEP-0333: Chat Markers + // XEP-0333: Chat State Markers bool isMarkable() const; void setMarkable(const bool); @@ -150,8 +151,6 @@ public: bool isPrivate() const; void setPrivate(const bool); - bool isXmppStanza() const override; - // XEP-0066: Out of Band Data QString outOfBandUrl() const; void setOutOfBandUrl(const QString&); @@ -199,6 +198,9 @@ public: /// \endcond private: + void parseExtension(const QDomElement &element, QXmppElementList &unknownElements); + void parseXElement(const QDomElement &element, QXmppElementList &unknownElements); + QSharedDataPointer<QXmppMessagePrivate> d; }; |
