diff options
Diffstat (limited to 'src/base')
| -rw-r--r-- | src/base/QXmppStartTlsPacket.cpp | 14 | ||||
| -rw-r--r-- | src/base/QXmppStartTlsPacket.h | 3 |
2 files changed, 12 insertions, 5 deletions
diff --git a/src/base/QXmppStartTlsPacket.cpp b/src/base/QXmppStartTlsPacket.cpp index f4c5e2fb..445f519e 100644 --- a/src/base/QXmppStartTlsPacket.cpp +++ b/src/base/QXmppStartTlsPacket.cpp @@ -65,14 +65,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 9b91bef9..5396f5d9 100644 --- a/src/base/QXmppStartTlsPacket.h +++ b/src/base/QXmppStartTlsPacket.h @@ -39,7 +39,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); |
