aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSona Kurazyan <sona.kurazyan@qt.io>2019-04-26 17:12:17 +0200
committerSona Kurazyan <sona.kurazyan@qt.io>2019-05-03 08:36:16 +0000
commit18289e7c1d2778460dccb1135fe283bd234954ad (patch)
tree6a00b98124cd70f3991ea878d519f30d8b418690
parent7a16e8d9b56b2740507021f84c522bd32a0ae1d7 (diff)
Remove the "Error" ending from QtCoap::Error enum value namesv5.13.0-rc3v5.13.0-rc2v5.13.0-rc1v5.13.0-beta4v5.13.05.13.0
QtCoap::Error is a scoped enum class, so its value names will get the "Error::" prefix anyway. No need to have it as a suffix for the value names. For the same reason replaced QtCoap::Error::NoError by QtCoap::Error::Ok. Change-Id: Iaf7b51cdab6ea330e940e5af73ba93a55eb48315 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r--examples/coap/consolecoapclient/coaphandler.cpp4
-rw-r--r--examples/coap/quicksecureclient/qmlcoapsecureclient.cpp2
-rw-r--r--examples/coap/simplecoapclient/mainwindow.cpp6
-rw-r--r--src/coap/qcoapnamespace.cpp50
-rw-r--r--src/coap/qcoapnamespace.h14
-rw-r--r--src/coap/qcoapprotocol.cpp16
-rw-r--r--src/coap/qcoapreply.cpp4
-rw-r--r--src/coap/qcoapreply_p.h4
-rw-r--r--tests/auto/qcoapclient/tst_qcoapclient.cpp4
-rw-r--r--tests/auto/qcoapreply/tst_qcoapreply.cpp10
10 files changed, 58 insertions, 56 deletions
diff --git a/examples/coap/consolecoapclient/coaphandler.cpp b/examples/coap/consolecoapclient/coaphandler.cpp
index 2533a02..650cf5c 100644
--- a/examples/coap/consolecoapclient/coaphandler.cpp
+++ b/examples/coap/consolecoapclient/coaphandler.cpp
@@ -88,7 +88,7 @@ bool CoapHandler::runDiscover(const QUrl &url)
void CoapHandler::onFinished(QCoapReply *reply)
{
- if (reply->errorReceived() == QtCoap::Error::NoError)
+ if (reply->errorReceived() == QtCoap::Error::Ok)
qCInfo(lcCoapClient) << "Request finished with payload:" << reply->readAll();
else
qCWarning(lcCoapClient, "Request failed");
@@ -116,7 +116,7 @@ void CoapHandler::onDiscovered(QCoapDiscoveryReply *reply, QVector<QCoapResource
void CoapHandler::onResponseToMulticast(QCoapReply *reply, const QCoapMessage& message,
const QHostAddress &sender)
{
- if (reply->errorReceived() == QtCoap::Error::NoError)
+ if (reply->errorReceived() == QtCoap::Error::Ok)
qCInfo(lcCoapClient) << "Got a response for multicast request from:" << sender.toString()
<< "with payload:" << message.payload();
else
diff --git a/examples/coap/quicksecureclient/qmlcoapsecureclient.cpp b/examples/coap/quicksecureclient/qmlcoapsecureclient.cpp
index 067570f..608ed0c 100644
--- a/examples/coap/quicksecureclient/qmlcoapsecureclient.cpp
+++ b/examples/coap/quicksecureclient/qmlcoapsecureclient.cpp
@@ -95,7 +95,7 @@ void QmlCoapSecureClient::setSecurityMode(QtCoap::SecurityMode mode)
[this](QCoapReply *reply) {
if (!reply)
emit finished("Something went wrong, received a null reply");
- else if (reply->errorReceived() != QtCoap::Error::NoError)
+ else if (reply->errorReceived() != QtCoap::Error::Ok)
emit finished(errorMessage(reply->errorReceived()));
else
emit finished(reply->message().payload());
diff --git a/examples/coap/simplecoapclient/mainwindow.cpp b/examples/coap/simplecoapclient/mainwindow.cpp
index 6cdb4da..e5cda55 100644
--- a/examples/coap/simplecoapclient/mainwindow.cpp
+++ b/examples/coap/simplecoapclient/mainwindow.cpp
@@ -106,7 +106,7 @@ void MainWindow::addMessage(const QString &message, bool isError)
void MainWindow::onFinished(QCoapReply *reply)
{
- if (reply->errorReceived() == QtCoap::Error::NoError)
+ if (reply->errorReceived() == QtCoap::Error::Ok)
addMessage(reply->message().payload());
}
@@ -124,7 +124,7 @@ void MainWindow::onError(QCoapReply *reply, QtCoap::Error error)
void MainWindow::onDiscovered(QCoapDiscoveryReply *reply, QVector<QCoapResource> resources)
{
- if (reply->errorReceived() != QtCoap::Error::NoError)
+ if (reply->errorReceived() != QtCoap::Error::Ok)
return;
QString message;
@@ -138,7 +138,7 @@ void MainWindow::onDiscovered(QCoapDiscoveryReply *reply, QVector<QCoapResource>
void MainWindow::onNotified(QCoapReply *reply, const QCoapMessage &message)
{
- if (reply->errorReceived() == QtCoap::Error::NoError)
+ if (reply->errorReceived() == QtCoap::Error::Ok)
addMessage("Received observe notification with payload: " + message.payload());
}
diff --git a/src/coap/qcoapnamespace.cpp b/src/coap/qcoapnamespace.cpp
index ca8e0b8..b1e5fc4 100644
--- a/src/coap/qcoapnamespace.cpp
+++ b/src/coap/qcoapnamespace.cpp
@@ -140,74 +140,74 @@ QT_BEGIN_NAMESPACE
Indicates the error condition found during processing of the request.
- \value NoError No error condition.
+ \value Ok No error condition.
- \value HostNotFoundError The remote host name was not found.
+ \value HostNotFound The remote host name was not found.
- \value AddressInUseError The address is already in use.
+ \value AddressInUse The address is already in use.
- \value TimeOutError The response did not arrive in time.
+ \value TimeOut The response did not arrive in time.
- \value BadRequestError The request was not recognized.
+ \value BadRequest The request was not recognized.
- \value UnauthorizedError The client is not authorized to perform
+ \value Unauthorized The client is not authorized to perform
the requested action.
- \value BadOptionError The request could not be understood by
+ \value BadOption The request could not be understood by
the server due to one or more unrecognized
or malformed options.
- \value ForbiddenError Access to this resource is forbidden.
+ \value Forbidden Access to this resource is forbidden.
- \value NotFoundError The resource requested was not found.
+ \value NotFound The resource requested was not found.
- \value MethodNotAllowedError The server does not allow the method used
+ \value MethodNotAllowed The server does not allow the method used
for the URL requested.
- \value NotAcceptableError No resource satisfying the request's acceptance
+ \value NotAcceptable No resource satisfying the request's acceptance
criteria was found.
- \value RequestEntityIncompleteError The server has not received the blocks of
+ \value RequestEntityIncomplete The server has not received the blocks of
the request body that it needs to proceed.
The client has not sent all blocks,
has not sent them in the order required by the
server, or sent them long enough ago
that the server has already discarded them.
- \value PreconditionFailedError One or more conditions given in the request
+ \value PreconditionFailed One or more conditions given in the request
header fields evaluated to false when tested
on the server.
- \value RequestEntityTooLargeError The request payload is larger than the
+ \value RequestEntityTooLarge The request payload is larger than the
server is willing or able to process.
- \value UnsupportedContentFormatError The payload is in a format not supported
+ \value UnsupportedContentFormat The payload is in a format not supported
by this method on the target resource.
- \value InternalServerFaultError The server encountered an unexpected
+ \value InternalServerFault The server encountered an unexpected
condition that prevented it from
fulfilling the request.
- \value NotImplementedError The server does not support the
+ \value NotImplemented The server does not support the
functionality required to fulfill the
request.
- \value BadGatewayError An error occurred with an upstream
+ \value BadGateway An error occurred with an upstream
server.
- \value ServiceUnavailableError The service is currently unavailable.
+ \value ServiceUnavailable The service is currently unavailable.
- \value GatewayTimeoutError The server, while acting as a gateway
+ \value GatewayTimeout The server, while acting as a gateway
or proxy, did not receive a timely
response from an upstream server it needed
to access in order to complete the request.
- \value ProxyingNotSupportedError The server is unable or unwilling to act
+ \value ProxyingNotSupported The server is unable or unwilling to act
as a forward-proxy for the URI specified
in the Proxy-Uri Option or using the scheme
specified in Proxy-Scheme.
- \value UnknownError An unknown error occurred.
+ \value Unknown An unknown error occurred.
*/
/*!
@@ -283,14 +283,14 @@ bool QtCoap::isError(QtCoap::ResponseCode code)
QtCoap::Error QtCoap::responseCodeError(QtCoap::ResponseCode code)
{
if (!isError(code))
- return QtCoap::Error::NoError;
+ return QtCoap::Error::Ok;
switch (code) {
-#define SINGLE_CASE(name, ignored) case ResponseCode::name: return Error::name ## Error;
+#define SINGLE_CASE(name, ignored) case ResponseCode::name: return Error::name;
FOR_EACH_COAP_ERROR(SINGLE_CASE)
#undef SINGLE_CASE
default:
- return Error::UnknownError;
+ return Error::Unknown;
}
}
diff --git a/src/coap/qcoapnamespace.h b/src/coap/qcoapnamespace.h
index afd44f1..353a046 100644
--- a/src/coap/qcoapnamespace.h
+++ b/src/coap/qcoapnamespace.h
@@ -67,16 +67,16 @@ namespace QtCoap
Q_ENUM_NS(ResponseCode)
enum class Error : quint8 {
- NoError,
- HostNotFoundError,
- AddressInUseError,
- TimeOutError,
+ Ok,
+ HostNotFound,
+ AddressInUse,
+ TimeOut,
-#define SINGLE_ERROR(name, ignored) name ## Error,
+#define SINGLE_ERROR(name, ignored) name,
FOR_EACH_COAP_ERROR(SINGLE_ERROR)
#undef SINGLE_ERROR
- UnknownError
+ Unknown
};
Q_ENUM_NS(Error)
@@ -121,6 +121,8 @@ namespace QtCoap
Q_COAP_EXPORT bool isError(ResponseCode code);
Q_COAP_EXPORT Error responseCodeError(ResponseCode code);
Q_COAP_EXPORT QRandomGenerator &randomGenerator();
+
+ Q_CLASSINFO("RegisterEnumClassesUnscoped", "false")
}
QT_END_NAMESPACE
diff --git a/src/coap/qcoapprotocol.cpp b/src/coap/qcoapprotocol.cpp
index b06a866..dd5f25d 100644
--- a/src/coap/qcoapprotocol.cpp
+++ b/src/coap/qcoapprotocol.cpp
@@ -233,7 +233,7 @@ void QCoapProtocolPrivate::onRequestTimeout(QCoapInternalRequest *request)
&& request->retransmissionCounter() < maxRetransmit) {
sendRequest(request);
} else {
- onRequestError(request, QtCoap::Error::TimeOutError);
+ onRequestError(request, QtCoap::Error::TimeOut);
}
}
@@ -249,7 +249,7 @@ void QCoapProtocolPrivate::onRequestMaxTransmissionSpanReached(QCoapInternalRequ
Q_ASSERT(QThread::currentThread() == q->thread());
if (isRequestRegistered(request))
- onRequestError(request, QtCoap::Error::TimeOutError);
+ onRequestError(request, QtCoap::Error::TimeOut);
}
/*!
@@ -267,7 +267,7 @@ void QCoapProtocolPrivate::onMulticastRequestExpired(QCoapInternalRequest *reque
QPointer<QCoapReply> userReply = userReplyForToken(request->token());
if (userReply) {
QMetaObject::invokeMethod(userReply, "_q_setFinished", Qt::QueuedConnection,
- Q_ARG(QtCoap::Error, QtCoap::Error::NoError));
+ Q_ARG(QtCoap::Error, QtCoap::Error::Ok));
} else {
qCWarning(lcCoapProtocol).nospace() << "Reply for token '" << request->token()
<< "' is not registered, reply is null.";
@@ -312,7 +312,7 @@ void QCoapProtocolPrivate::onRequestError(QCoapInternalRequest *request, QtCoap:
}
QMetaObject::invokeMethod(userReply.data(), "_q_setFinished", Qt::QueuedConnection,
- Q_ARG(QtCoap::Error, QtCoap::Error::NoError));
+ Q_ARG(QtCoap::Error, QtCoap::Error::Ok));
}
forgetExchange(request);
@@ -557,7 +557,7 @@ void QCoapProtocolPrivate::onLastMessageReceived(QCoapInternalRequest *request,
emit q->responseToMulticastReceived(userReply, *lastReply->message(), sender);
} else {
QMetaObject::invokeMethod(userReply, "_q_setFinished", Qt::QueuedConnection,
- Q_ARG(QtCoap::Error, QtCoap::Error::NoError));
+ Q_ARG(QtCoap::Error, QtCoap::Error::Ok));
forgetExchange(request);
}
}
@@ -733,13 +733,13 @@ void QCoapProtocolPrivate::onConnectionError(QAbstractSocket::SocketError socket
QtCoap::Error coapError;
switch (socketError) {
case QAbstractSocket::HostNotFoundError :
- coapError = QtCoap::Error::HostNotFoundError;
+ coapError = QtCoap::Error::HostNotFound;
break;
case QAbstractSocket::AddressInUseError :
- coapError = QtCoap::Error::AddressInUseError;
+ coapError = QtCoap::Error::AddressInUse;
break;
default:
- coapError = QtCoap::Error::UnknownError;
+ coapError = QtCoap::Error::Unknown;
break;
}
diff --git a/src/coap/qcoapreply.cpp b/src/coap/qcoapreply.cpp
index b8d0347..9122551 100644
--- a/src/coap/qcoapreply.cpp
+++ b/src/coap/qcoapreply.cpp
@@ -131,7 +131,7 @@ void QCoapReplyPrivate::_q_setFinished(QtCoap::Error newError)
isFinished = true;
isRunning = false;
- if (newError != QtCoap::Error::NoError)
+ if (newError != QtCoap::Error::Ok)
_q_setError(newError);
emit q->finished(q);
@@ -376,7 +376,7 @@ bool QCoapReply::isSuccessful() const
{
Q_D(const QCoapReply);
return d->isFinished && !QtCoap::isError(d->responseCode)
- && d->error == QtCoap::Error::NoError;
+ && d->error == QtCoap::Error::Ok;
}
/*!
diff --git a/src/coap/qcoapreply_p.h b/src/coap/qcoapreply_p.h
index e8c2df3..68e9062 100644
--- a/src/coap/qcoapreply_p.h
+++ b/src/coap/qcoapreply_p.h
@@ -58,14 +58,14 @@ public:
virtual void _q_setContent(const QHostAddress &sender, const QCoapMessage &, QtCoap::ResponseCode);
void _q_setNotified();
void _q_setObserveCancelled();
- void _q_setFinished(QtCoap::Error = QtCoap::Error::NoError);
+ void _q_setFinished(QtCoap::Error = QtCoap::Error::Ok);
void _q_setError(QtCoap::ResponseCode code);
void _q_setError(QtCoap::Error);
QCoapRequest request;
QCoapMessage message;
QtCoap::ResponseCode responseCode = QtCoap::ResponseCode::InvalidCode;
- QtCoap::Error error = QtCoap::Error::NoError;
+ QtCoap::Error error = QtCoap::Error::Ok;
bool isRunning = false;
bool isFinished = false;
bool isAborted = false;
diff --git a/tests/auto/qcoapclient/tst_qcoapclient.cpp b/tests/auto/qcoapclient/tst_qcoapclient.cpp
index 261a95a..3e5eac0 100644
--- a/tests/auto/qcoapclient/tst_qcoapclient.cpp
+++ b/tests/auto/qcoapclient/tst_qcoapclient.cpp
@@ -462,7 +462,7 @@ void tst_QCoapClient::socketError()
QTRY_COMPARE_WITH_TIMEOUT(spySocketError.count(), 1, 10000);
QTRY_COMPARE_WITH_TIMEOUT(spyClientError.count(), 1, 1000);
QCOMPARE(qvariant_cast<QtCoap::Error>(spyClientError.first().at(1)),
- QtCoap::Error::AddressInUseError);
+ QtCoap::Error::AddressInUse);
#else
QSKIP("Not an internal build, skipping this test");
#endif
@@ -516,7 +516,7 @@ void tst_QCoapClient::timeout()
qPrintable(errorMessage));
QCOMPARE(qvariant_cast<QtCoap::Error>(spyReplyError.first().at(1)),
- QtCoap::Error::TimeOutError);
+ QtCoap::Error::TimeOut);
QCOMPARE(spyReplyFinished.count(), 1);
QCOMPARE(spyReplyAborted.count(), 0);
QCOMPARE(spyClientError.count(), 1);
diff --git a/tests/auto/qcoapreply/tst_qcoapreply.cpp b/tests/auto/qcoapreply/tst_qcoapreply.cpp
index 200110f..d9a7562 100644
--- a/tests/auto/qcoapreply/tst_qcoapreply.cpp
+++ b/tests/auto/qcoapreply/tst_qcoapreply.cpp
@@ -66,19 +66,19 @@ void tst_QCoapReply::updateReply_data()
QTest::newRow("success")
<< QByteArray("Some data")
<< QtCoap::ResponseCode::Content
- << QtCoap::Error::NoError;
+ << QtCoap::Error::Ok;
QTest::newRow("content error")
<< QByteArray("Error")
<< QtCoap::ResponseCode::BadRequest
- << QtCoap::Error::NoError;
+ << QtCoap::Error::Ok;
QTest::newRow("finished error")
<< QByteArray("Error")
<< QtCoap::ResponseCode::Content
- << QtCoap::Error::BadRequestError;
+ << QtCoap::Error::BadRequest;
QTest::newRow("content & finished errors")
<< QByteArray("2Errors")
<< QtCoap::ResponseCode::BadGateway
- << QtCoap::Error::BadRequestError;
+ << QtCoap::Error::BadRequest;
}
void tst_QCoapReply::updateReply()
@@ -111,7 +111,7 @@ void tst_QCoapReply::updateReply()
QCOMPARE(spyReplyFinished.count(), 1);
QCOMPARE(spyReplyNotified.count(), 0);
QCOMPARE(spyReplyAborted.count(), 0);
- if (error != QtCoap::Error::NoError || QtCoap::isError(responseCode)) {
+ if (error != QtCoap::Error::Ok || QtCoap::isError(responseCode)) {
QVERIFY(spyReplyError.count() > 0);
QCOMPARE(reply.isSuccessful(), false);
} else {