aboutsummaryrefslogtreecommitdiff
path: root/src/base
diff options
context:
space:
mode:
authorLinus Jahn <lnj@kaidan.im>2022-03-16 19:54:03 +0100
committerLinus Jahn <lnj@kaidan.im>2022-03-16 19:54:03 +0100
commit0383266d61577d0829f48d284e417b1ffb372812 (patch)
tree38c2569ce6dd8188f801338fd4678d9e362b49fc /src/base
parent5b682269631a14d707b5cf1a2893bfd72ba5a011 (diff)
parent395d2af80de7817dd2b092c2c7d9dfa3fa3f2744 (diff)
downloadqxmpp-0383266d61577d0829f48d284e417b1ffb372812.tar.gz
Merge branch '1.4'
Diffstat (limited to 'src/base')
-rw-r--r--src/base/QXmppMessage.cpp4
-rw-r--r--src/base/QXmppMixIq.cpp4
-rw-r--r--src/base/QXmppStartTlsPacket.cpp14
-rw-r--r--src/base/QXmppStartTlsPacket.h3
4 files changed, 18 insertions, 7 deletions
diff --git a/src/base/QXmppMessage.cpp b/src/base/QXmppMessage.cpp
index 16c0a1a7..41b654ed 100644
--- a/src/base/QXmppMessage.cpp
+++ b/src/base/QXmppMessage.cpp
@@ -1247,7 +1247,9 @@ bool QXmppMessage::parseExtension(const QDomElement &element, QXmpp::SceMode sce
// XEP-0334: Message Processing Hints
if (element.namespaceURI() == ns_message_processing_hints &&
HINT_TYPES.contains(element.tagName())) {
- addHint(Hint(1 << HINT_TYPES.indexOf(element.tagName())));
+ if (const auto index = HINT_TYPES.indexOf(element.tagName()); index >= 0) {
+ addHint(Hint(1 << index));
+ }
return true;
}
// XEP-0359: Unique and Stable Stanza IDs
diff --git a/src/base/QXmppMixIq.cpp b/src/base/QXmppMixIq.cpp
index d137ddea..6446850b 100644
--- a/src/base/QXmppMixIq.cpp
+++ b/src/base/QXmppMixIq.cpp
@@ -133,7 +133,9 @@ void QXmppMixIq::parseElementFromChild(const QDomElement &element)
{
QDomElement child = element.firstChildElement();
// determine action type
- d->actionType = (QXmppMixIq::Type)MIX_ACTION_TYPES.indexOf(child.tagName());
+ if (auto index = MIX_ACTION_TYPES.indexOf(child.tagName()); index >= 0) {
+ d->actionType = Type(index);
+ }
if (child.namespaceURI() == ns_mix_pam) {
if (child.hasAttribute(QStringLiteral("channel")))
diff --git a/src/base/QXmppStartTlsPacket.cpp b/src/base/QXmppStartTlsPacket.cpp
index e8d37ba7..60b2cf5b 100644
--- a/src/base/QXmppStartTlsPacket.cpp
+++ b/src/base/QXmppStartTlsPacket.cpp
@@ -46,14 +46,20 @@ void QXmppStartTlsPacket::parse(const QDomElement &element)
if (!QXmppStartTlsPacket::isStartTlsPacket(element))
return;
- m_type = Type(STARTTLS_TYPES.indexOf(element.tagName()));
+ if (auto index = STARTTLS_TYPES.indexOf(element.tagName()); index >= 0) {
+ m_type = Type(index);
+ } else {
+ m_type = Invalid;
+ }
}
void QXmppStartTlsPacket::toXml(QXmlStreamWriter *writer) const
{
- writer->writeStartElement(STARTTLS_TYPES.at(int(m_type)));
- writer->writeDefaultNamespace(ns_tls);
- writer->writeEndElement();
+ if (m_type != Invalid) {
+ writer->writeStartElement(STARTTLS_TYPES.at(int(m_type)));
+ writer->writeDefaultNamespace(ns_tls);
+ writer->writeEndElement();
+ }
}
/// \endcond
diff --git a/src/base/QXmppStartTlsPacket.h b/src/base/QXmppStartTlsPacket.h
index e25ff89b..191b80ce 100644
--- a/src/base/QXmppStartTlsPacket.h
+++ b/src/base/QXmppStartTlsPacket.h
@@ -20,7 +20,8 @@ public:
enum Type {
StartTls, ///< Used by the client to initiate STARTTLS.
Proceed, ///< Used by the server to accept STARTTLS.
- Failure ///< Used by the server to reject STARTTLS.
+ Failure, ///< Used by the server to reject STARTTLS.
+ Invalid, ///< Invalid type
};
QXmppStartTlsPacket(Type type = StartTls);