diff options
author | Sona Kurazyan <sona.kurazyan@qt.io> | 2019-05-10 17:44:44 +0200 |
---|---|---|
committer | Sona Kurazyan <sona.kurazyan@qt.io> | 2019-05-14 15:15:01 +0000 |
commit | a5beff7436aba965d16b63d5677b6d3920724c59 (patch) | |
tree | 3fc7fdad064018e15e2fe9a0e17e1fd1d3e8a5e5 | |
parent | 149ca6289869a30cfd033160b5662d02671fe3e1 (diff) |
Hide internally used methods from QtCoap namespace
Additionally rename responseCodeError() -> errorForResponseCode().
This change is based on the feedback from API review.
Change-Id: Ida63a854f628d3d92a93bd54bd80f2368de48d8d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r-- | src/coap/coap.pro | 1 | ||||
-rw-r--r-- | src/coap/qcoapdiscoveryreply.cpp | 1 | ||||
-rw-r--r-- | src/coap/qcoapnamespace.cpp | 10 | ||||
-rw-r--r-- | src/coap/qcoapnamespace.h | 4 | ||||
-rw-r--r-- | src/coap/qcoapnamespace_p.h | 57 | ||||
-rw-r--r-- | src/coap/qcoapprotocol.cpp | 3 | ||||
-rw-r--r-- | src/coap/qcoapreply.cpp | 4 | ||||
-rw-r--r-- | tests/auto/qcoapreply/tst_qcoapreply.cpp | 24 |
8 files changed, 89 insertions, 15 deletions
diff --git a/src/coap/coap.pro b/src/coap/coap.pro index fc81397..54df74b 100644 --- a/src/coap/coap.pro +++ b/src/coap/coap.pro @@ -25,6 +25,7 @@ PRIVATE_HEADERS += \ qcoapinternalreply_p.h \ qcoapinternalrequest_p.h \ qcoapmessage_p.h \ + qcoapnamespace_p.h \ qcoapoption_p.h \ qcoapprotocol_p.h \ qcoapqudpconnection_p.h \ diff --git a/src/coap/qcoapdiscoveryreply.cpp b/src/coap/qcoapdiscoveryreply.cpp index def9d19..abde474 100644 --- a/src/coap/qcoapdiscoveryreply.cpp +++ b/src/coap/qcoapdiscoveryreply.cpp @@ -30,6 +30,7 @@ #include "qcoapdiscoveryreply_p.h" #include "qcoapinternalreply_p.h" +#include "qcoapnamespace_p.h" QT_BEGIN_NAMESPACE diff --git a/src/coap/qcoapnamespace.cpp b/src/coap/qcoapnamespace.cpp index a20a152..dbf0f52 100644 --- a/src/coap/qcoapnamespace.cpp +++ b/src/coap/qcoapnamespace.cpp @@ -27,7 +27,7 @@ ** ****************************************************************************/ -#include "qcoapnamespace.h" +#include "qcoapnamespace_p.h" QT_BEGIN_NAMESPACE @@ -269,6 +269,8 @@ QT_BEGIN_NAMESPACE */ /*! + \internal + Returns \c true if \a code corresponds to an error, returns \c false otherwise. */ bool QtCoap::isError(QtCoap::ResponseCode code) @@ -277,10 +279,12 @@ bool QtCoap::isError(QtCoap::ResponseCode code) } /*! + \internal + Returns the QtCoap::Error corresponding to the \a code passed to this method. */ -QtCoap::Error QtCoap::responseCodeError(QtCoap::ResponseCode code) +QtCoap::Error QtCoap::errorForResponseCode(QtCoap::ResponseCode code) { if (!isError(code)) return QtCoap::Error::Ok; @@ -295,6 +299,8 @@ QtCoap::Error QtCoap::responseCodeError(QtCoap::ResponseCode code) } /*! + \internal + Returns the internal random generator used for generating token values and message IDs. */ diff --git a/src/coap/qcoapnamespace.h b/src/coap/qcoapnamespace.h index 1a64311..f81c92b 100644 --- a/src/coap/qcoapnamespace.h +++ b/src/coap/qcoapnamespace.h @@ -118,10 +118,6 @@ namespace QtCoap }; Q_ENUM_NS(MulticastGroup) - Q_COAP_EXPORT bool isError(ResponseCode code); - Q_COAP_EXPORT Error responseCodeError(ResponseCode code); - Q_COAP_EXPORT QRandomGenerator &randomGenerator(); - Q_CLASSINFO("RegisterEnumClassesUnscoped", "false") } diff --git a/src/coap/qcoapnamespace_p.h b/src/coap/qcoapnamespace_p.h new file mode 100644 index 0000000..0417a04 --- /dev/null +++ b/src/coap/qcoapnamespace_p.h @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtCoap module. +** +** $QT_BEGIN_LICENSE:GPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCOAPNAMESPACE_P_H +#define QCOAPNAMESPACE_P_H + +#include "qcoapnamespace.h" + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +namespace QtCoap +{ + bool Q_AUTOTEST_EXPORT isError(QtCoap::ResponseCode code); + Error Q_AUTOTEST_EXPORT errorForResponseCode(QtCoap::ResponseCode code); + QRandomGenerator Q_AUTOTEST_EXPORT &randomGenerator(); +} + +QT_END_NAMESPACE + +#endif // QCOAPNAMESPACE_P_H diff --git a/src/coap/qcoapprotocol.cpp b/src/coap/qcoapprotocol.cpp index 0e50452..2de5583 100644 --- a/src/coap/qcoapprotocol.cpp +++ b/src/coap/qcoapprotocol.cpp @@ -32,6 +32,7 @@ #include "qcoapinternalrequest_p.h" #include "qcoapinternalreply_p.h" #include "qcoapconnection_p.h" +#include "qcoapnamespace_p.h" #include <QtCore/qrandom.h> #include <QtCore/qthread.h> @@ -291,7 +292,7 @@ void QCoapProtocolPrivate::onMulticastRequestExpired(QCoapInternalRequest *reque */ void QCoapProtocolPrivate::onRequestError(QCoapInternalRequest *request, QCoapInternalReply *reply) { - QtCoap::Error error = QtCoap::responseCodeError(reply->responseCode()); + QtCoap::Error error = QtCoap::errorForResponseCode(reply->responseCode()); onRequestError(request, error, reply); } diff --git a/src/coap/qcoapreply.cpp b/src/coap/qcoapreply.cpp index 9122551..847539e 100644 --- a/src/coap/qcoapreply.cpp +++ b/src/coap/qcoapreply.cpp @@ -30,6 +30,8 @@ #include "qcoapreply_p.h" #include "qcoapinternalreply_p.h" +#include "qcoapnamespace_p.h" + #include <QtCore/qmath.h> #include <QtCore/qloggingcategory.h> @@ -161,7 +163,7 @@ void QCoapReplyPrivate::_q_setError(QtCoap::Error newError) */ void QCoapReplyPrivate::_q_setError(QtCoap::ResponseCode code) { - _q_setError(QtCoap::responseCodeError(code)); + _q_setError(QtCoap::errorForResponseCode(code)); } /*! diff --git a/tests/auto/qcoapreply/tst_qcoapreply.cpp b/tests/auto/qcoapreply/tst_qcoapreply.cpp index d9a7562..f22098e 100644 --- a/tests/auto/qcoapreply/tst_qcoapreply.cpp +++ b/tests/auto/qcoapreply/tst_qcoapreply.cpp @@ -33,6 +33,9 @@ #include <QtCoap/qcoapreply.h> #include <private/qcoapreply_p.h> +#include <private/qcoapnamespace_p.h> + +#ifdef QT_BUILD_INTERNAL class tst_QCoapReply : public QObject { @@ -128,20 +131,15 @@ void tst_QCoapReply::updateReply() void tst_QCoapReply::requestData() { -#ifdef QT_BUILD_INTERNAL QCoapReplyForTests reply((QCoapRequest())); reply.setRunning("token", 543); QCOMPARE(reply.request().token(), QByteArray("token")); QCOMPARE(reply.request().messageId(), 543); -#else - QSKIP("Not an internal build, skipping this test"); -#endif } void tst_QCoapReply::abortRequest() { -#ifdef QT_BUILD_INTERNAL QCoapReplyForTests reply((QCoapRequest())); reply.setRunning("token", 543); @@ -154,10 +152,22 @@ void tst_QCoapReply::abortRequest() QTRY_COMPARE_WITH_TIMEOUT(spyFinished.count(), 1, 1000); QVERIFY(arguments.at(0).toByteArray() == "token"); QCOMPARE(reply.isSuccessful(), false); +} + #else - QSKIP("Not an internal build, skipping this test"); + +class tst_QCoapReply : public QObject +{ + Q_OBJECT + +private slots: + void initTestCase() + { + QSKIP("Not an internal build, nothing to test"); + } +}; + #endif -} QTEST_MAIN(tst_QCoapReply) |