aboutsummaryrefslogtreecommitdiff
path: root/src/base
diff options
context:
space:
mode:
authorLinus Jahn <lnj@kaidan.im>2022-03-12 22:10:06 +0100
committerLinus Jahn <lnj@kaidan.im>2022-03-12 22:23:48 +0100
commitad48b7f07914713bf314fa5005bbf21a24c4a867 (patch)
tree96f2fcaad9bc51c79672331e03245492e99f3f14 /src/base
parent102493de1743d6b010d0274635da37ea3f434473 (diff)
downloadqxmpp-ad48b7f07914713bf314fa5005bbf21a24c4a867.tar.gz
Stanza_p.h: Move function definitions into Stanza.cpp
This way the function definition is shared and it avoids unused function warnings in QXmppStreamManagement.cpp.
Diffstat (limited to 'src/base')
-rw-r--r--src/base/QXmppStanza.cpp148
-rw-r--r--src/base/QXmppStanza_p.h144
-rw-r--r--src/base/QXmppStreamManagement.cpp2
3 files changed, 156 insertions, 138 deletions
diff --git a/src/base/QXmppStanza.cpp b/src/base/QXmppStanza.cpp
index 3aff0404..800db220 100644
--- a/src/base/QXmppStanza.cpp
+++ b/src/base/QXmppStanza.cpp
@@ -15,8 +15,156 @@
#include <QDomElement>
#include <QXmlStreamWriter>
+using namespace QXmpp::Private;
+
uint QXmppStanza::s_uniqeIdNo = 0;
+namespace QXmpp::Private {
+
+QString conditionToString(QXmppStanza::Error::Condition condition)
+{
+ switch (condition) {
+ case QXmppStanza::Error::BadRequest:
+ return "bad-request";
+ case QXmppStanza::Error::Conflict:
+ return "conflict";
+ case QXmppStanza::Error::FeatureNotImplemented:
+ return "feature-not-implemented";
+ case QXmppStanza::Error::Forbidden:
+ return "forbidden";
+ case QXmppStanza::Error::Gone:
+ return "gone";
+ case QXmppStanza::Error::InternalServerError:
+ return "internal-server-error";
+ case QXmppStanza::Error::ItemNotFound:
+ return "item-not-found";
+ case QXmppStanza::Error::JidMalformed:
+ return "jid-malformed";
+ case QXmppStanza::Error::NotAcceptable:
+ return "not-acceptable";
+ case QXmppStanza::Error::NotAllowed:
+ return "not-allowed";
+ case QXmppStanza::Error::NotAuthorized:
+ return "not-authorized";
+ QT_WARNING_PUSH
+ QT_WARNING_DISABLE_DEPRECATED
+ case QXmppStanza::Error::PaymentRequired:
+ QT_WARNING_POP
+ return "payment-required";
+ case QXmppStanza::Error::PolicyViolation:
+ return "policy-violation";
+ case QXmppStanza::Error::RecipientUnavailable:
+ return "recipient-unavailable";
+ case QXmppStanza::Error::Redirect:
+ return "redirect";
+ case QXmppStanza::Error::RegistrationRequired:
+ return "registration-required";
+ case QXmppStanza::Error::RemoteServerNotFound:
+ return "remote-server-not-found";
+ case QXmppStanza::Error::RemoteServerTimeout:
+ return "remote-server-timeout";
+ case QXmppStanza::Error::ResourceConstraint:
+ return "resource-constraint";
+ case QXmppStanza::Error::ServiceUnavailable:
+ return "service-unavailable";
+ case QXmppStanza::Error::SubscriptionRequired:
+ return "subscription-required";
+ case QXmppStanza::Error::UndefinedCondition:
+ return "undefined-condition";
+ case QXmppStanza::Error::UnexpectedRequest:
+ return "unexpected-request";
+ }
+ return {};
+}
+
+std::optional<QXmppStanza::Error::Condition> conditionFromString(const QString &string)
+{
+ if (string == "bad-request")
+ return QXmppStanza::Error::BadRequest;
+ else if (string == "conflict")
+ return QXmppStanza::Error::Conflict;
+ else if (string == "feature-not-implemented")
+ return QXmppStanza::Error::FeatureNotImplemented;
+ else if (string == "forbidden")
+ return QXmppStanza::Error::Forbidden;
+ else if (string == "gone")
+ return QXmppStanza::Error::Gone;
+ else if (string == "internal-server-error")
+ return QXmppStanza::Error::InternalServerError;
+ else if (string == "item-not-found")
+ return QXmppStanza::Error::ItemNotFound;
+ else if (string == "jid-malformed")
+ return QXmppStanza::Error::JidMalformed;
+ else if (string == "not-acceptable")
+ return QXmppStanza::Error::NotAcceptable;
+ else if (string == "not-allowed")
+ return QXmppStanza::Error::NotAllowed;
+ else if (string == "not-authorized")
+ return QXmppStanza::Error::NotAuthorized;
+ else if (string == "payment-required") {
+ QT_WARNING_PUSH
+ QT_WARNING_DISABLE_DEPRECATED
+ return QXmppStanza::Error::PaymentRequired;
+ QT_WARNING_POP
+ } else if (string == "policy-violation")
+ return QXmppStanza::Error::PolicyViolation;
+ else if (string == "recipient-unavailable")
+ return QXmppStanza::Error::RecipientUnavailable;
+ else if (string == "redirect")
+ return QXmppStanza::Error::Redirect;
+ else if (string == "registration-required")
+ return QXmppStanza::Error::RegistrationRequired;
+ else if (string == "remote-server-not-found")
+ return QXmppStanza::Error::RemoteServerNotFound;
+ else if (string == "remote-server-timeout")
+ return QXmppStanza::Error::RemoteServerTimeout;
+ else if (string == "resource-constraint")
+ return QXmppStanza::Error::ResourceConstraint;
+ else if (string == "service-unavailable")
+ return QXmppStanza::Error::ServiceUnavailable;
+ else if (string == "subscription-required")
+ return QXmppStanza::Error::SubscriptionRequired;
+ else if (string == "undefined-condition")
+ return QXmppStanza::Error::UndefinedCondition;
+ else if (string == "unexpected-request")
+ return QXmppStanza::Error::UnexpectedRequest;
+ return std::nullopt;
+}
+
+QString typeToString(QXmppStanza::Error::Type type)
+{
+ switch (type) {
+ case QXmppStanza::Error::Cancel:
+ return QStringLiteral("cancel");
+ case QXmppStanza::Error::Continue:
+ return QStringLiteral("continue");
+ case QXmppStanza::Error::Modify:
+ return QStringLiteral("modify");
+ case QXmppStanza::Error::Auth:
+ return QStringLiteral("auth");
+ case QXmppStanza::Error::Wait:
+ return QStringLiteral("wait");
+ }
+ return {};
+}
+
+std::optional<QXmppStanza::Error::Type> typeFromString(const QString &string)
+{
+ if (string == QStringLiteral("cancel"))
+ return QXmppStanza::Error::Cancel;
+ else if (string == QStringLiteral("continue"))
+ return QXmppStanza::Error::Continue;
+ else if (string == QStringLiteral("modify"))
+ return QXmppStanza::Error::Modify;
+ else if (string == QStringLiteral("auth"))
+ return QXmppStanza::Error::Auth;
+ else if (string == QStringLiteral("wait"))
+ return QXmppStanza::Error::Wait;
+ return std::nullopt;
+}
+
+} // QXmpp::Private
+
class QXmppExtendedAddressPrivate : public QSharedData
{
public:
diff --git a/src/base/QXmppStanza_p.h b/src/base/QXmppStanza_p.h
index 70741e8d..75303795 100644
--- a/src/base/QXmppStanza_p.h
+++ b/src/base/QXmppStanza_p.h
@@ -21,146 +21,14 @@
// We mean it.
//
-static QString conditionToString(QXmppStanza::Error::Condition condition)
-{
- switch (condition) {
- case QXmppStanza::Error::BadRequest:
- return "bad-request";
- case QXmppStanza::Error::Conflict:
- return "conflict";
- case QXmppStanza::Error::FeatureNotImplemented:
- return "feature-not-implemented";
- case QXmppStanza::Error::Forbidden:
- return "forbidden";
- case QXmppStanza::Error::Gone:
- return "gone";
- case QXmppStanza::Error::InternalServerError:
- return "internal-server-error";
- case QXmppStanza::Error::ItemNotFound:
- return "item-not-found";
- case QXmppStanza::Error::JidMalformed:
- return "jid-malformed";
- case QXmppStanza::Error::NotAcceptable:
- return "not-acceptable";
- case QXmppStanza::Error::NotAllowed:
- return "not-allowed";
- case QXmppStanza::Error::NotAuthorized:
- return "not-authorized";
- QT_WARNING_PUSH
- QT_WARNING_DISABLE_DEPRECATED
- case QXmppStanza::Error::PaymentRequired:
- QT_WARNING_POP
- return "payment-required";
- case QXmppStanza::Error::PolicyViolation:
- return "policy-violation";
- case QXmppStanza::Error::RecipientUnavailable:
- return "recipient-unavailable";
- case QXmppStanza::Error::Redirect:
- return "redirect";
- case QXmppStanza::Error::RegistrationRequired:
- return "registration-required";
- case QXmppStanza::Error::RemoteServerNotFound:
- return "remote-server-not-found";
- case QXmppStanza::Error::RemoteServerTimeout:
- return "remote-server-timeout";
- case QXmppStanza::Error::ResourceConstraint:
- return "resource-constraint";
- case QXmppStanza::Error::ServiceUnavailable:
- return "service-unavailable";
- case QXmppStanza::Error::SubscriptionRequired:
- return "subscription-required";
- case QXmppStanza::Error::UndefinedCondition:
- return "undefined-condition";
- case QXmppStanza::Error::UnexpectedRequest:
- return "unexpected-request";
- }
- return {};
-}
-
-static std::optional<QXmppStanza::Error::Condition> conditionFromString(const QString &string)
-{
- if (string == "bad-request")
- return QXmppStanza::Error::BadRequest;
- else if (string == "conflict")
- return QXmppStanza::Error::Conflict;
- else if (string == "feature-not-implemented")
- return QXmppStanza::Error::FeatureNotImplemented;
- else if (string == "forbidden")
- return QXmppStanza::Error::Forbidden;
- else if (string == "gone")
- return QXmppStanza::Error::Gone;
- else if (string == "internal-server-error")
- return QXmppStanza::Error::InternalServerError;
- else if (string == "item-not-found")
- return QXmppStanza::Error::ItemNotFound;
- else if (string == "jid-malformed")
- return QXmppStanza::Error::JidMalformed;
- else if (string == "not-acceptable")
- return QXmppStanza::Error::NotAcceptable;
- else if (string == "not-allowed")
- return QXmppStanza::Error::NotAllowed;
- else if (string == "not-authorized")
- return QXmppStanza::Error::NotAuthorized;
- else if (string == "payment-required") {
- QT_WARNING_PUSH
- QT_WARNING_DISABLE_DEPRECATED
- return QXmppStanza::Error::PaymentRequired;
- QT_WARNING_POP
- } else if (string == "policy-violation")
- return QXmppStanza::Error::PolicyViolation;
- else if (string == "recipient-unavailable")
- return QXmppStanza::Error::RecipientUnavailable;
- else if (string == "redirect")
- return QXmppStanza::Error::Redirect;
- else if (string == "registration-required")
- return QXmppStanza::Error::RegistrationRequired;
- else if (string == "remote-server-not-found")
- return QXmppStanza::Error::RemoteServerNotFound;
- else if (string == "remote-server-timeout")
- return QXmppStanza::Error::RemoteServerTimeout;
- else if (string == "resource-constraint")
- return QXmppStanza::Error::ResourceConstraint;
- else if (string == "service-unavailable")
- return QXmppStanza::Error::ServiceUnavailable;
- else if (string == "subscription-required")
- return QXmppStanza::Error::SubscriptionRequired;
- else if (string == "undefined-condition")
- return QXmppStanza::Error::UndefinedCondition;
- else if (string == "unexpected-request")
- return QXmppStanza::Error::UnexpectedRequest;
- return std::nullopt;
-}
+namespace QXmpp::Private {
-static QString typeToString(QXmppStanza::Error::Type type)
-{
- switch (type) {
- case QXmppStanza::Error::Cancel:
- return QStringLiteral("cancel");
- case QXmppStanza::Error::Continue:
- return QStringLiteral("continue");
- case QXmppStanza::Error::Modify:
- return QStringLiteral("modify");
- case QXmppStanza::Error::Auth:
- return QStringLiteral("auth");
- case QXmppStanza::Error::Wait:
- return QStringLiteral("wait");
- }
- return {};
-}
+// defined in QXmppStanza.cpp
+auto conditionToString(QXmppStanza::Error::Condition condition) -> QString;
+auto conditionFromString(const QString &string) -> std::optional<QXmppStanza::Error::Condition>;
+auto typeToString(QXmppStanza::Error::Type type) -> QString;
+auto typeFromString(const QString &string) -> std::optional<QXmppStanza::Error::Type>;
-static std::optional<QXmppStanza::Error::Type> typeFromString(const QString &string)
-{
- if (string == QStringLiteral("cancel"))
- return QXmppStanza::Error::Cancel;
- else if (string == QStringLiteral("continue"))
- return QXmppStanza::Error::Continue;
- else if (string == QStringLiteral("modify"))
- return QXmppStanza::Error::Modify;
- else if (string == QStringLiteral("auth"))
- return QXmppStanza::Error::Auth;
- else if (string == QStringLiteral("wait"))
- return QXmppStanza::Error::Wait;
- return std::nullopt;
}
#endif
diff --git a/src/base/QXmppStreamManagement.cpp b/src/base/QXmppStreamManagement.cpp
index 63c6e3fd..af08dc71 100644
--- a/src/base/QXmppStreamManagement.cpp
+++ b/src/base/QXmppStreamManagement.cpp
@@ -9,6 +9,8 @@
#include "QXmppStream.h"
#include "QXmppStreamManagement_p.h"
+using namespace QXmpp::Private;
+
/// \cond
QXmppStreamManagementEnable::QXmppStreamManagementEnable(const bool resume, const unsigned max)
: m_resume(resume), m_max(max)