From eab17404ecccc6719decb7e8846d9c8e75e917c1 Mon Sep 17 00:00:00 2001 From: Tibor Csötönyi Date: Sun, 7 May 2023 21:29:44 +0200 Subject: Code review fixes --- src/CMakeLists.txt | 5 ++-- src/base/QXmppJingleData.cpp | 71 +++++++++++++++++++++++++++++++++++++++----- src/base/QXmppJingleData.h | 19 ++++++++++-- src/base/QXmppJingleIq.h | 5 ++++ 4 files changed, 87 insertions(+), 13 deletions(-) create mode 100644 src/base/QXmppJingleIq.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 56bebdcb..7e94efdc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -35,7 +35,8 @@ set(INSTALL_HEADER_FILES base/QXmppHttpUploadIq.h base/QXmppIbbIq.h base/QXmppIq.h - base/QXmppJingleData.h + base/QXmppJingleIq.h + base/QXmppJingleData.h base/QXmppLogger.h base/QXmppMamIq.h base/QXmppMessage.h @@ -173,7 +174,7 @@ set(SOURCE_FILES base/QXmppHttpUploadIq.cpp base/QXmppIbbIq.cpp base/QXmppIq.cpp - base/QXmppJingleData.cpp + base/QXmppJingleData.cpp base/QXmppLogger.cpp base/QXmppMamIq.cpp base/QXmppMessage.cpp diff --git a/src/base/QXmppJingleData.cpp b/src/base/QXmppJingleData.cpp index 2d497115..78cd4017 100644 --- a/src/base/QXmppJingleData.cpp +++ b/src/base/QXmppJingleData.cpp @@ -375,6 +375,60 @@ void QXmppJingleIq::Content::setDescription(const QXmppJingleDescription &descri d->description = description; } +/// \deprecated This method is deprecated since QXmpp 1.6. Use +/// \c QXmppJingleIq::Conent::description().media() instead. +QString QXmppJingleIq::Content::descriptionMedia() const +{ + return d->description.media(); +} + +/// \deprecated This method is deprecated since QXmpp 1.6. Use +/// \c QXmppJingleIq::Conent::description().setMedia() instead. +void QXmppJingleIq::Content::setDescriptionMedia(const QString &media) +{ + d->description.setMedia(media); +} + +/// Returns the description's 32-bit synchronization source for the media stream as specified by +/// \xep{0167, Jingle RTP Sessions} and RFC 3550. +/// +/// \since QXmpp 0.9 +/// \deprecated This method is deprecated since QXmpp 1.6. Use +/// \c QXmppJingleIq::Content::description().setSsrc() instead. +/// +quint32 QXmppJingleIq::Content::descriptionSsrc() const +{ + return d->description.ssrc(); +} + +/// \deprecated This method is deprecated since QXmpp 1.6. Use +/// \c QXmppJingleIq::Conent::description().setSsrc() instead. +void QXmppJingleIq::Content::setDescriptionSsrc(quint32 ssrc) +{ + d->description.setSsrc(ssrc); +} + +/// \deprecated This method is deprecated since QXmpp 1.6. Use +/// \c QXmppJingleIq::Conent::description().addPayloadType() instead. +void QXmppJingleIq::Content::addPayloadType(const QXmppJinglePayloadType &payload) +{ + d->description.addPayloadType(payload); +} + +/// \deprecated This method is deprecated since QXmpp 1.6. Use +/// \c QXmppJingleIq::Conent::description().payloadTypes() instead. +QList QXmppJingleIq::Content::payloadTypes() const +{ + return d->description.payloadTypes(); +} + +/// \deprecated This method is deprecated since QXmpp 1.6. Use +/// \c QXmppJingleIq::Conent::description().setPayloadTypes() instead. +void QXmppJingleIq::Content::setPayloadTypes(const QList &payloadTypes) +{ + d->description.setPayloadTypes(payloadTypes); +} + /// /// Returns whether multiplexing of RTP data and control packets on a single port is supported as /// specified by \xep{0167, Jingle RTP Sessions} and RFC 5761. @@ -3079,12 +3133,13 @@ void QXmppJingleMessageInitiationElement::setMigratedTo(const QString &migratedT /// \cond void QXmppJingleMessageInitiationElement::parse(const QDomElement &element) { - d->type = stringToJmiElementType(element.nodeName()); + std::optional type { stringToJmiElementType(element.nodeName()) }; - if (d->type == Type::None) { + if (!type.has_value()) { return; } + d->type = type.value(); d->id = element.attribute(QStringLiteral("id")); // Type::Proceed and Type::Ringing don't need any parsing aside of the id. @@ -3108,12 +3163,12 @@ void QXmppJingleMessageInitiationElement::parse(const QDomElement &element) break; case Type::Finish: - if (const auto &reasonElement = element.firstChildElement("reason"); !reasonElement.isNull()) { + if (auto reasonElement = element.firstChildElement("reason"); !reasonElement.isNull()) { d->reason = QXmppJingleReason(); d->reason->parse(reasonElement); } - if (const auto &migratedToElement = element.firstChildElement("migrated"); !migratedToElement.isNull()) { + if (auto migratedToElement = element.firstChildElement("migrated"); !migratedToElement.isNull()) { d->migratedTo = migratedToElement.attribute("to"); } @@ -3158,13 +3213,13 @@ QXMPP_PRIVATE_DEFINE_RULE_OF_SIX(QXmppJingleMessageInitiationElement) /// bool QXmppJingleMessageInitiationElement::isJingleMessageInitiationElement(const QDomElement &element) { - return (element.nodeName() == QStringLiteral("propose") || element.nodeName() == QStringLiteral("ringing") || element.nodeName() == QStringLiteral("proceed") || element.nodeName() == QStringLiteral("retract") || element.nodeName() == QStringLiteral("reject") || element.nodeName() == QStringLiteral("finish")) && element.hasAttribute(QStringLiteral("id")) && element.namespaceURI() == ns_jingle_message_initiation; + return stringToJmiElementType(element.tagName()).has_value() && element.hasAttribute(QStringLiteral("id")) && element.namespaceURI() == ns_jingle_message_initiation; } /// /// Takes a Jingle Message Initiation element type and parses it to a string. /// -QString QXmppJingleMessageInitiationElement::jmiElementTypeToString(Type type) const +QString QXmppJingleMessageInitiationElement::jmiElementTypeToString(Type type) { switch (type) { case Type::Propose: @@ -3187,7 +3242,7 @@ QString QXmppJingleMessageInitiationElement::jmiElementTypeToString(Type type) c /// /// Takes a string and parses it to a Jingle Message Initiation element type. /// -QXmppJingleMessageInitiationElement::Type QXmppJingleMessageInitiationElement::stringToJmiElementType(const QString &typeStr) const +std::optional QXmppJingleMessageInitiationElement::stringToJmiElementType(const QString &typeStr) { if (typeStr == "propose") { return Type::Propose; @@ -3203,5 +3258,5 @@ QXmppJingleMessageInitiationElement::Type QXmppJingleMessageInitiationElement::s return Type::Finish; } - return Type::None; + return std::nullopt; } diff --git a/src/base/QXmppJingleData.h b/src/base/QXmppJingleData.h index 1e425f4d..82ef8c00 100644 --- a/src/base/QXmppJingleData.h +++ b/src/base/QXmppJingleData.h @@ -463,6 +463,8 @@ public: using RtpSessionState = std::variant; + using Reason = QXmppJingleReason; + /// \internal /// /// The QXmppJingleIq::Content class represents the "content" element of a @@ -492,6 +494,18 @@ public: QXmppJingleDescription description() const; void setDescription(const QXmppJingleDescription &description); +#if QXMPP_DEPRECATED_SINCE(1, 6) + QString descriptionMedia() const; + void setDescriptionMedia(const QString &media); + + quint32 descriptionSsrc() const; + void setDescriptionSsrc(quint32 ssrc); + + void addPayloadType(const QXmppJinglePayloadType &payload); + QList payloadTypes() const; + void setPayloadTypes(const QList &payloadTypes); +#endif + bool isRtpMultiplexingSupported() const; void setRtpMultiplexingSupported(bool isRtpMultiplexingSupported); @@ -636,11 +650,10 @@ public: /// \endcond static bool isJingleMessageInitiationElement(const QDomElement &); + static QString jmiElementTypeToString(Type type); + static std::optional stringToJmiElementType(const QString &typeStr); private: - QString jmiElementTypeToString(Type type) const; - Type stringToJmiElementType(const QString &typeStr) const; - QSharedDataPointer d; }; diff --git a/src/base/QXmppJingleIq.h b/src/base/QXmppJingleIq.h new file mode 100644 index 00000000..358f7d0b --- /dev/null +++ b/src/base/QXmppJingleIq.h @@ -0,0 +1,5 @@ +// SPDX-FileCopyrightText: 2010 Jeremy Lainé +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#include "QXmppJingleData.h" -- cgit v1.2.3