diff options
| author | Melvin Keskin <melvo@olomono.de> | 2022-10-02 21:46:52 +0200 |
|---|---|---|
| committer | Linus Jahn <lnj@kaidan.im> | 2022-10-02 21:48:01 +0200 |
| commit | 9ea4dc9cb762f8108b47124250e0c9e76a5b2cde (patch) | |
| tree | 4908525119aa115e1e1b66af84563829b9342d45 /src/base/QXmppJingleIq.cpp | |
| parent | 9f9d672e350ef4ce65983d2cac590aa23d74ac96 (diff) | |
| download | qxmpp-9ea4dc9cb762f8108b47124250e0c9e76a5b2cde.tar.gz | |
Implement XEP-0167: Jingle RTP Sessions error conditions (#485)
Diffstat (limited to 'src/base/QXmppJingleIq.cpp')
| -rw-r--r-- | src/base/QXmppJingleIq.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/base/QXmppJingleIq.cpp b/src/base/QXmppJingleIq.cpp index 01e27a04..fc198278 100644 --- a/src/base/QXmppJingleIq.cpp +++ b/src/base/QXmppJingleIq.cpp @@ -54,6 +54,12 @@ static const char *jingle_reasons[] = { "unsupported-transports", }; +static const QStringList JINGLE_RTP_ERROR_CONDITIONS = { + {}, + QStringLiteral("invalid-crypto"), + QStringLiteral("crypto-required") +}; + static const QStringList JINGLE_RTP_HEADER_EXTENSIONS_SENDERS = { QStringLiteral("both"), QStringLiteral("initiator"), @@ -947,6 +953,14 @@ QString QXmppJingleIq::Content::toSdp() const /// \endcond +/// +/// \enum QXmppJingleIq::Reason::RtpErrorCondition +/// +/// Condition of an RTP-specific error +/// +/// \since QXmpp 1.5 +/// + QXmppJingleIq::Reason::Reason() : m_type(None) { @@ -980,6 +994,30 @@ void QXmppJingleIq::Reason::setType(QXmppJingleIq::Reason::Type type) m_type = type; } +/// +/// Returns the RTP error condition as specified by \xep{0167, Jingle RTP Sessions}. +/// +/// \return the RTP error condition +/// +/// \since QXmpp 1.5 +/// +QXmppJingleIq::Reason::RtpErrorCondition QXmppJingleIq::Reason::rtpErrorCondition() const +{ + return m_rtpErrorCondition; +} + +/// +/// Sets the RTP error condition as specified by \xep{0167, Jingle RTP Sessions}. +/// +/// \param rtpErrorCondition RTP error condition +/// +/// \since QXmpp 1.5 +/// +void QXmppJingleIq::Reason::setRtpErrorCondition(RtpErrorCondition rtpErrorCondition) +{ + m_rtpErrorCondition = rtpErrorCondition; +} + /// \cond void QXmppJingleIq::Reason::parse(const QDomElement &element) { @@ -990,6 +1028,18 @@ void QXmppJingleIq::Reason::parse(const QDomElement &element) break; } } + + for (auto child = element.firstChildElement(); + !child.isNull(); + child = child.nextSiblingElement()) { + if (child.namespaceURI() == ns_jingle_rtp_errors) { + if (const auto index = JINGLE_RTP_ERROR_CONDITIONS.indexOf(child.tagName()); + index != -1) { + m_rtpErrorCondition = RtpErrorCondition(index); + } + break; + } + } } void QXmppJingleIq::Reason::toXml(QXmlStreamWriter *writer) const @@ -1003,6 +1053,13 @@ void QXmppJingleIq::Reason::toXml(QXmlStreamWriter *writer) const helperToXmlAddTextElement(writer, QStringLiteral("text"), m_text); } writer->writeEmptyElement(jingle_reasons[m_type]); + + if (m_rtpErrorCondition != NoErrorCondition) { + writer->writeStartElement(JINGLE_RTP_ERROR_CONDITIONS.at(m_rtpErrorCondition)); + writer->writeDefaultNamespace(ns_jingle_rtp_errors); + writer->writeEndElement(); + } + writer->writeEndElement(); } /// \endcond |
