diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/coap/qcoapclient.cpp | 22 | ||||
-rw-r--r-- | src/coap/qcoapclient.h | 4 | ||||
-rw-r--r-- | src/coap/qcoapconnection.cpp | 8 | ||||
-rw-r--r-- | src/coap/qcoapconnection.h | 6 | ||||
-rw-r--r-- | src/coap/qcoapconnection_p.h | 2 | ||||
-rw-r--r-- | src/coap/qcoapinternalreply_p.h | 2 | ||||
-rw-r--r-- | src/coap/qcoapinternalrequest.cpp | 22 | ||||
-rw-r--r-- | src/coap/qcoapinternalrequest_p.h | 2 | ||||
-rw-r--r-- | src/coap/qcoapmessage.h | 2 | ||||
-rw-r--r-- | src/coap/qcoapmessage_p.h | 4 | ||||
-rw-r--r-- | src/coap/qcoapnamespace.cpp | 50 | ||||
-rw-r--r-- | src/coap/qcoapnamespace.h | 24 | ||||
-rw-r--r-- | src/coap/qcoapprotocol.cpp | 26 | ||||
-rw-r--r-- | src/coap/qcoapqudpconnection.cpp | 12 | ||||
-rw-r--r-- | src/coap/qcoapqudpconnection.h | 2 | ||||
-rw-r--r-- | src/coap/qcoapqudpconnection_p.h | 2 | ||||
-rw-r--r-- | src/coap/qcoapreply.cpp | 4 | ||||
-rw-r--r-- | src/coap/qcoapreply_p.h | 6 | ||||
-rw-r--r-- | src/coap/qcoaprequest.cpp | 4 | ||||
-rw-r--r-- | src/coap/qcoaprequest.h | 4 | ||||
-rw-r--r-- | src/coap/qcoaprequest_p.h | 4 |
21 files changed, 107 insertions, 105 deletions
diff --git a/src/coap/qcoapclient.cpp b/src/coap/qcoapclient.cpp index dced30e..767f7f0 100644 --- a/src/coap/qcoapclient.cpp +++ b/src/coap/qcoapclient.cpp @@ -236,7 +236,7 @@ QCoapReply *QCoapClient::get(const QCoapRequest &request) { Q_D(QCoapClient); - QCoapRequest copyRequest(request, QtCoap::Get); + QCoapRequest copyRequest(request, QtCoap::Method::Get); copyRequest.adjustUrl(d->connection->isSecure()); return d->sendRequest(copyRequest); @@ -265,7 +265,7 @@ QCoapReply *QCoapClient::put(const QCoapRequest &request, const QByteArray &data { Q_D(QCoapClient); - QCoapRequest copyRequest(request, QtCoap::Put); + QCoapRequest copyRequest(request, QtCoap::Method::Put); copyRequest.setPayload(data); copyRequest.adjustUrl(d->connection->isSecure()); @@ -311,7 +311,7 @@ QCoapReply *QCoapClient::post(const QCoapRequest &request, const QByteArray &dat { Q_D(QCoapClient); - QCoapRequest copyRequest(request, QtCoap::Post); + QCoapRequest copyRequest(request, QtCoap::Method::Post); copyRequest.setPayload(data); copyRequest.adjustUrl(d->connection->isSecure()); @@ -360,7 +360,7 @@ QCoapReply *QCoapClient::deleteResource(const QCoapRequest &request) { Q_D(QCoapClient); - QCoapRequest copyRequest(request, QtCoap::Delete); + QCoapRequest copyRequest(request, QtCoap::Method::Delete); copyRequest.adjustUrl(d->connection->isSecure()); return d->sendRequest(copyRequest); @@ -400,13 +400,13 @@ QCoapDiscoveryReply *QCoapClient::discover(QtCoap::MulticastGroup group, int por QString base; switch (group) { - case QtCoap::AllCoapNodesIPv4: + case QtCoap::MulticastGroup::AllCoapNodesIPv4: base = QStringLiteral("224.0.1.187"); break; - case QtCoap::AllCoapNodesIPv6LinkLocal: + case QtCoap::MulticastGroup::AllCoapNodesIPv6LinkLocal: base = QStringLiteral("ff02::fd"); break; - case QtCoap::AllCoapNodesIPv6SiteLocal: + case QtCoap::MulticastGroup::AllCoapNodesIPv6SiteLocal: base = QStringLiteral("ff05::fd"); break; } @@ -417,7 +417,7 @@ QCoapDiscoveryReply *QCoapClient::discover(QtCoap::MulticastGroup group, int por discoveryUrl.setPort(port); QCoapRequest request(discoveryUrl); - request.setMethod(QtCoap::Get); + request.setMethod(QtCoap::Method::Get); request.adjustUrl(d->connection->isSecure()); return d->sendDiscovery(request); @@ -443,7 +443,7 @@ QCoapDiscoveryReply *QCoapClient::discover(const QUrl &url, const QString &disco discoveryUrl.setPath(url.path() + discoveryPath); QCoapRequest request(discoveryUrl); - request.setMethod(QtCoap::Get); + request.setMethod(QtCoap::Method::Get); request.adjustUrl(d->connection->isSecure()); return d->sendDiscovery(request); @@ -458,7 +458,7 @@ QCoapDiscoveryReply *QCoapClient::discover(const QUrl &url, const QString &disco */ QCoapReply *QCoapClient::observe(const QCoapRequest &request) { - QCoapRequest copyRequest(request, QtCoap::Get); + QCoapRequest copyRequest(request, QtCoap::Method::Get); copyRequest.enableObserve(); return get(copyRequest); @@ -579,7 +579,7 @@ bool QCoapClientPrivate::send(QCoapReply *reply) // According to https://tools.ietf.org/html/rfc7252#section-8.1, // multicast requests MUST be Non-confirmable. if (QHostAddress(reply->url().host()).isMulticast() - && reply->request().type() == QCoapMessage::Confirmable) { + && reply->request().type() == QCoapMessage::MessageType::Confirmable) { qCWarning(lcCoapClient, "Failed to send request, " "multicast requests must be non-confirmable."); return false; diff --git a/src/coap/qcoapclient.h b/src/coap/qcoapclient.h index 4645c4c..fb06903 100644 --- a/src/coap/qcoapclient.h +++ b/src/coap/qcoapclient.h @@ -53,7 +53,7 @@ class Q_COAP_EXPORT QCoapClient : public QObject { Q_OBJECT public: - explicit QCoapClient(QtCoap::SecurityMode securityMode = QtCoap::NoSec, + explicit QCoapClient(QtCoap::SecurityMode securityMode = QtCoap::SecurityMode::NoSec, QObject *parent = nullptr); explicit QCoapClient(QCoapConnection *connection, QObject *parent = nullptr); ~QCoapClient(); @@ -74,7 +74,7 @@ public: void cancelObserve(const QUrl &url); void disconnect(); - QCoapDiscoveryReply *discover(QtCoap::MulticastGroup group = QtCoap::AllCoapNodesIPv4, + QCoapDiscoveryReply *discover(QtCoap::MulticastGroup group = QtCoap::MulticastGroup::AllCoapNodesIPv4, int port = QtCoap::DefaultPort, const QString &discoveryPath = QLatin1String("/.well-known/core")); QCoapDiscoveryReply *discover(const QUrl &baseUrl, diff --git a/src/coap/qcoapconnection.cpp b/src/coap/qcoapconnection.cpp index 7ee529a..96e98fa 100644 --- a/src/coap/qcoapconnection.cpp +++ b/src/coap/qcoapconnection.cpp @@ -120,7 +120,7 @@ Q_LOGGING_CATEGORY(lcCoapConnection, "qt.coap.connection") QCoapConnectionPrivate::QCoapConnectionPrivate(QtCoap::SecurityMode security) : securityMode(security) - , state(QCoapConnection::Unconnected) + , state(QCoapConnection::ConnectionState::Unconnected) {} /*! @@ -145,7 +145,7 @@ QCoapConnection::QCoapConnection(QObjectPrivate &dd, QObject *parent) connect(this, &QCoapConnection::bound, this, [this]() { Q_D(QCoapConnection); - d->state = QCoapConnection::Bound; + d->state = ConnectionState::Bound; startToSendRequest(); }); } @@ -187,7 +187,7 @@ QCoapConnectionPrivate::sendRequest(const QByteArray &request, const QString &ho bool QCoapConnection::isSecure() const { Q_D(const QCoapConnection); - return d->securityMode != QtCoap::NoSec; + return d->securityMode != QtCoap::SecurityMode::NoSec; } /*! @@ -262,7 +262,7 @@ void QCoapConnection::disconnect() close(); d->framesToSend.clear(); - d->state = QCoapConnection::Unconnected; + d->state = ConnectionState::Unconnected; } QT_END_NAMESPACE diff --git a/src/coap/qcoapconnection.h b/src/coap/qcoapconnection.h index 017053b..6f2931f 100644 --- a/src/coap/qcoapconnection.h +++ b/src/coap/qcoapconnection.h @@ -43,18 +43,18 @@ class Q_COAP_EXPORT QCoapConnection : public QObject { Q_OBJECT public: - enum ConnectionState { + enum class ConnectionState : quint8 { Unconnected, Bound }; - explicit QCoapConnection(QtCoap::SecurityMode securityMode = QtCoap::NoSec, + explicit QCoapConnection(QtCoap::SecurityMode securityMode = QtCoap::SecurityMode::NoSec, QObject *parent = nullptr); virtual ~QCoapConnection(); bool isSecure() const; QtCoap::SecurityMode securityMode() const; - QCoapConnection::ConnectionState state() const; + ConnectionState state() const; QCoapSecurityConfiguration securityConfiguration() const; Q_INVOKABLE void setSecurityConfiguration(const QCoapSecurityConfiguration &configuration); diff --git a/src/coap/qcoapconnection_p.h b/src/coap/qcoapconnection_p.h index 90535ca..d75c794 100644 --- a/src/coap/qcoapconnection_p.h +++ b/src/coap/qcoapconnection_p.h @@ -60,7 +60,7 @@ struct CoapFrame { class Q_AUTOTEST_EXPORT QCoapConnectionPrivate : public QObjectPrivate { public: - QCoapConnectionPrivate(QtCoap::SecurityMode security = QtCoap::NoSec); + QCoapConnectionPrivate(QtCoap::SecurityMode security = QtCoap::SecurityMode::NoSec); ~QCoapConnectionPrivate() override = default; diff --git a/src/coap/qcoapinternalreply_p.h b/src/coap/qcoapinternalreply_p.h index db9a052..f144b47 100644 --- a/src/coap/qcoapinternalreply_p.h +++ b/src/coap/qcoapinternalreply_p.h @@ -78,7 +78,7 @@ class Q_AUTOTEST_EXPORT QCoapInternalReplyPrivate : public QCoapInternalMessageP public: QCoapInternalReplyPrivate() = default; - QtCoap::ResponseCode responseCode = QtCoap::InvalidCode; + QtCoap::ResponseCode responseCode = QtCoap::ResponseCode::InvalidCode; QHostAddress senderAddress; }; diff --git a/src/coap/qcoapinternalrequest.cpp b/src/coap/qcoapinternalrequest.cpp index b8eb51e..2e10432 100644 --- a/src/coap/qcoapinternalrequest.cpp +++ b/src/coap/qcoapinternalrequest.cpp @@ -97,7 +97,7 @@ QCoapInternalRequest::QCoapInternalRequest(const QCoapRequest &request, QObject bool QCoapInternalRequest::isValid() const { Q_D(const QCoapInternalRequest); - return isUrlValid(d->targetUri) && d->method != QtCoap::Invalid; + return isUrlValid(d->targetUri) && d->method != QtCoap::Method::Invalid; } /*! @@ -110,8 +110,8 @@ void QCoapInternalRequest::initForAcknowledgment(quint16 messageId, const QByteA { Q_D(QCoapInternalRequest); - setMethod(QtCoap::Invalid); - d->message.setType(QCoapMessage::Acknowledgment); + setMethod(QtCoap::Method::Invalid); + d->message.setType(QCoapMessage::MessageType::Acknowledgment); d->message.setMessageId(messageId); d->message.setToken(token); d->message.setPayload(QByteArray()); @@ -129,8 +129,8 @@ void QCoapInternalRequest::initForReset(quint16 messageId) { Q_D(QCoapInternalRequest); - setMethod(QtCoap::Invalid); - d->message.setType(QCoapMessage::Reset); + setMethod(QtCoap::Method::Invalid); + d->message.setType(QCoapMessage::MessageType::Reset); d->message.setMessageId(messageId); d->message.setToken(QByteArray()); d->message.setPayload(QByteArray()); @@ -171,12 +171,12 @@ QByteArray QCoapInternalRequest::toQByteArray() const QByteArray pdu; // Insert header - appendByte(&pdu, (d->message.version() << 6) // CoAP version - | (d->message.type() << 4) // Message type - | d->message.token().length()); // Token Length - appendByte(&pdu, d->method & 0xFF); // Method code - appendByte(&pdu, (d->message.messageId() >> 8) & 0xFF); // Message ID - appendByte(&pdu, d->message.messageId() & 0xFF); + appendByte(&pdu, (d->message.version() << 6) // CoAP version + | (static_cast<quint8>(d->message.type()) << 4) // Message type + | d->message.token().length()); // Token Length + appendByte(&pdu, static_cast<quint8>(d->method) & 0xFF); // Method code + appendByte(&pdu, (d->message.messageId() >> 8) & 0xFF); // Message ID + appendByte(&pdu, d->message.messageId() & 0xFF); // Insert Token pdu.append(d->message.token()); diff --git a/src/coap/qcoapinternalrequest_p.h b/src/coap/qcoapinternalrequest_p.h index 1b50aae..549f5f0 100644 --- a/src/coap/qcoapinternalrequest_p.h +++ b/src/coap/qcoapinternalrequest_p.h @@ -118,7 +118,7 @@ public: QCoapInternalRequestPrivate() = default; QUrl targetUri; - QtCoap::Method method = QtCoap::Invalid; + QtCoap::Method method = QtCoap::Method::Invalid; QCoapConnection *connection = nullptr; QByteArray fullPayload; diff --git a/src/coap/qcoapmessage.h b/src/coap/qcoapmessage.h index 550ff88..36288a7 100644 --- a/src/coap/qcoapmessage.h +++ b/src/coap/qcoapmessage.h @@ -44,7 +44,7 @@ class QCoapMessagePrivate; class Q_COAP_EXPORT QCoapMessage { public: - enum MessageType { + enum class MessageType : quint8 { Confirmable, NonConfirmable, Acknowledgment, diff --git a/src/coap/qcoapmessage_p.h b/src/coap/qcoapmessage_p.h index 9cfd282..b16ba2b 100644 --- a/src/coap/qcoapmessage_p.h +++ b/src/coap/qcoapmessage_p.h @@ -51,12 +51,12 @@ QT_BEGIN_NAMESPACE class Q_AUTOTEST_EXPORT QCoapMessagePrivate : public QSharedData { public: - QCoapMessagePrivate(QCoapMessage::MessageType type = QCoapMessage::NonConfirmable); + QCoapMessagePrivate(QCoapMessage::MessageType type = QCoapMessage::MessageType::NonConfirmable); QCoapMessagePrivate(const QCoapMessagePrivate &other); ~QCoapMessagePrivate(); quint8 version = 1; - QCoapMessage::MessageType type = QCoapMessage::NonConfirmable; + QCoapMessage::MessageType type = QCoapMessage::MessageType::NonConfirmable; quint16 messageId = 0; QByteArray token; QVector<QCoapOption> options; diff --git a/src/coap/qcoapnamespace.cpp b/src/coap/qcoapnamespace.cpp index df44ce2..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::NoError; + return QtCoap::Error::Ok; switch (code) { -#define SINGLE_CASE(name, ignored) case name: return name ## Error; +#define SINGLE_CASE(name, ignored) case ResponseCode::name: return Error::name; FOR_EACH_COAP_ERROR(SINGLE_CASE) #undef SINGLE_CASE default: - return UnknownError; + return Error::Unknown; } } diff --git a/src/coap/qcoapnamespace.h b/src/coap/qcoapnamespace.h index 72b91cd..353a046 100644 --- a/src/coap/qcoapnamespace.h +++ b/src/coap/qcoapnamespace.h @@ -49,7 +49,7 @@ namespace QtCoap { Q_COAP_EXPORT Q_NAMESPACE - enum ResponseCode { + enum class ResponseCode : quint8 { EmptyMessage = 0x00, Created = 0x41, // 2.01 Deleted = 0x42, // 2.02 @@ -66,21 +66,21 @@ namespace QtCoap }; Q_ENUM_NS(ResponseCode) - enum Error { - NoError, - HostNotFoundError, - AddressInUseError, - TimeOutError, + enum class Error : quint8 { + 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) - enum Method { + enum class Method : quint8 { Invalid, Get, Post, @@ -103,7 +103,7 @@ namespace QtCoap }; Q_ENUM_NS(Port) - enum SecurityMode { + enum class SecurityMode : quint8 { NoSec = 0, PreSharedKey, RawPublicKey, @@ -111,7 +111,7 @@ namespace QtCoap }; Q_ENUM_NS(SecurityMode) - enum MulticastGroup { + enum class MulticastGroup : quint8 { AllCoapNodesIPv4, AllCoapNodesIPv6LinkLocal, AllCoapNodesIPv6SiteLocal @@ -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 971c70b..dd5f25d 100644 --- a/src/coap/qcoapprotocol.cpp +++ b/src/coap/qcoapprotocol.cpp @@ -168,7 +168,7 @@ void QCoapProtocol::sendRequest(QPointer<QCoapReply> reply, QCoapConnection *con internalRequest->setToSendBlock(0, d->blockSize); } - if (requestMessage->type() == QCoapMessage::Confirmable) + if (requestMessage->type() == QCoapMessage::MessageType::Confirmable) internalRequest->setTimeout(QtCoap::randomGenerator().bounded(minTimeout(), maxTimeout())); else internalRequest->setTimeout(maxTimeout()); @@ -229,11 +229,11 @@ void QCoapProtocolPrivate::onRequestTimeout(QCoapInternalRequest *request) if (!isRequestRegistered(request)) return; - if (request->message()->type() == QCoapMessage::Confirmable + if (request->message()->type() == QCoapMessage::MessageType::Confirmable && request->retransmissionCounter() < maxRetransmit) { sendRequest(request); } else { - onRequestError(request, QtCoap::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::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::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::NoError)); + Q_ARG(QtCoap::Error, QtCoap::Error::Ok)); } forgetExchange(request); @@ -366,7 +366,7 @@ void QCoapProtocolPrivate::onFrameReceived(const QByteArray &data, const QHostAd // Remove option to ensure that it will stop request->removeOption(QCoapOption::Observe); sendReset(request); - } else if (messageReceived->type() == QCoapMessage::Confirmable) { + } else if (messageReceived->type() == QCoapMessage::MessageType::Confirmable) { sendAcknowledgment(request); } @@ -505,8 +505,8 @@ void QCoapProtocolPrivate::onLastMessageReceived(QCoapInternalRequest *request, auto lastReply = replies.last(); // Ignore empty ACK messages - if (lastReply->message()->type() == QCoapMessage::Acknowledgment - && lastReply->responseCode() == QtCoap::EmptyMessage) { + if (lastReply->message()->type() == QCoapMessage::MessageType::Acknowledgment + && lastReply->responseCode() == QtCoap::ResponseCode::EmptyMessage) { exchangeMap[request->token()].replies.takeLast(); return; } @@ -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::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::HostNotFoundError; + coapError = QtCoap::Error::HostNotFound; break; case QAbstractSocket::AddressInUseError : - coapError = QtCoap::AddressInUseError; + coapError = QtCoap::Error::AddressInUse; break; default: - coapError = QtCoap::UnknownError; + coapError = QtCoap::Error::Unknown; break; } diff --git a/src/coap/qcoapqudpconnection.cpp b/src/coap/qcoapqudpconnection.cpp index 831b23d..e38fe5b 100644 --- a/src/coap/qcoapqudpconnection.cpp +++ b/src/coap/qcoapqudpconnection.cpp @@ -101,12 +101,12 @@ QCoapQUdpConnection::QCoapQUdpConnection(QCoapQUdpConnectionPrivate &dd, QObject auto configuration = QSslConfiguration::defaultDtlsConfiguration(); switch (d->securityMode) { - case QtCoap::RawPublicKey: + case QtCoap::SecurityMode::RawPublicKey: qCWarning(lcCoapConnection, "RawPublicKey security is not supported yet," "disabling security"); - d->securityMode = QtCoap::NoSec; + d->securityMode = QtCoap::SecurityMode::NoSec; break; - case QtCoap::PreSharedKey: + case QtCoap::SecurityMode::PreSharedKey: d->dtls = new QDtls(QSslSocket::SslClientMode, this); configuration.setPeerVerifyMode(QSslSocket::VerifyNone); d->dtls->setDtlsConfiguration(configuration); @@ -114,7 +114,7 @@ QCoapQUdpConnection::QCoapQUdpConnection(QCoapQUdpConnectionPrivate &dd, QObject connect(d->dtls, &QDtls::pskRequired, this, &QCoapQUdpConnection::pskRequired); connect(d->dtls, &QDtls::handshakeTimeout, this, &QCoapQUdpConnection::handshakeTimeout); break; - case QtCoap::Certificate: + case QtCoap::SecurityMode::Certificate: d->dtls = new QDtls(QSslSocket::SslClientMode, this); configuration.setPeerVerifyMode(QSslSocket::VerifyPeer); d->dtls->setDtlsConfiguration(configuration); @@ -126,7 +126,7 @@ QCoapQUdpConnection::QCoapQUdpConnection(QCoapQUdpConnectionPrivate &dd, QObject } #else qCWarning(lcCoapConnection, "DTLS is disabled, falling back to QtCoap::NoSec mode."); - d->securityMode = QtCoap::NoSec; + d->securityMode = QtCoap::SecurityMode::NoSec; #endif } } @@ -194,7 +194,7 @@ void QCoapQUdpConnectionPrivate::bindSocket() { Q_Q(QCoapQUdpConnection); - if (state != QCoapQUdpConnection::Bound && bind()) + if (state != QCoapQUdpConnection::ConnectionState::Bound && bind()) emit q->bound(); } diff --git a/src/coap/qcoapqudpconnection.h b/src/coap/qcoapqudpconnection.h index 76c5abf..f9ca356 100644 --- a/src/coap/qcoapqudpconnection.h +++ b/src/coap/qcoapqudpconnection.h @@ -48,7 +48,7 @@ class Q_COAP_EXPORT QCoapQUdpConnection : public QCoapConnection Q_OBJECT public: - explicit QCoapQUdpConnection(QtCoap::SecurityMode security = QtCoap::NoSec, + explicit QCoapQUdpConnection(QtCoap::SecurityMode security = QtCoap::SecurityMode::NoSec, QObject *parent = nullptr); ~QCoapQUdpConnection() override = default; diff --git a/src/coap/qcoapqudpconnection_p.h b/src/coap/qcoapqudpconnection_p.h index 587f5a2..3901af8 100644 --- a/src/coap/qcoapqudpconnection_p.h +++ b/src/coap/qcoapqudpconnection_p.h @@ -56,7 +56,7 @@ class QSslPreSharedKeyAuthenticator; class Q_AUTOTEST_EXPORT QCoapQUdpConnectionPrivate : public QCoapConnectionPrivate { public: - QCoapQUdpConnectionPrivate(QtCoap::SecurityMode security = QtCoap::NoSec); + QCoapQUdpConnectionPrivate(QtCoap::SecurityMode security = QtCoap::SecurityMode::NoSec); ~QCoapQUdpConnectionPrivate() override; virtual bool bind(); diff --git a/src/coap/qcoapreply.cpp b/src/coap/qcoapreply.cpp index 1770deb..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::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::NoError; + && d->error == QtCoap::Error::Ok; } /*! diff --git a/src/coap/qcoapreply_p.h b/src/coap/qcoapreply_p.h index b786ce2..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::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::InvalidCode; - QtCoap::Error error = QtCoap::NoError; + QtCoap::ResponseCode responseCode = QtCoap::ResponseCode::InvalidCode; + QtCoap::Error error = QtCoap::Error::Ok; bool isRunning = false; bool isFinished = false; bool isAborted = false; diff --git a/src/coap/qcoaprequest.cpp b/src/coap/qcoaprequest.cpp index 58420ac..1d9a441 100644 --- a/src/coap/qcoaprequest.cpp +++ b/src/coap/qcoaprequest.cpp @@ -146,7 +146,7 @@ QCoapRequest::QCoapRequest(const QCoapRequest &other) : QCoapRequest::QCoapRequest(const QCoapRequest &other, QtCoap::Method method) : QCoapRequest(other) { - if (method != QtCoap::Invalid) + if (method != QtCoap::Method::Invalid) setMethod(method); } @@ -278,7 +278,7 @@ QCoapRequest &QCoapRequest::operator=(const QCoapRequest &other) */ bool QCoapRequest::isValid() const { - return isUrlValid(url()) && method() != QtCoap::Invalid; + return isUrlValid(url()) && method() != QtCoap::Method::Invalid; } /*! diff --git a/src/coap/qcoaprequest.h b/src/coap/qcoaprequest.h index 600a635..c833334 100644 --- a/src/coap/qcoaprequest.h +++ b/src/coap/qcoaprequest.h @@ -46,10 +46,10 @@ class Q_COAP_EXPORT QCoapRequest : public QCoapMessage { public: explicit QCoapRequest(const QUrl &url = QUrl(), - MessageType type = NonConfirmable, + MessageType type = MessageType::NonConfirmable, const QUrl &proxyUrl = QUrl()); explicit QCoapRequest(const char* url, - MessageType type = NonConfirmable); + MessageType type = MessageType::NonConfirmable); QCoapRequest(const QCoapRequest &other); ~QCoapRequest(); diff --git a/src/coap/qcoaprequest_p.h b/src/coap/qcoaprequest_p.h index 35d4c70..67c26c6 100644 --- a/src/coap/qcoaprequest_p.h +++ b/src/coap/qcoaprequest_p.h @@ -52,7 +52,7 @@ class Q_AUTOTEST_EXPORT QCoapRequestPrivate : public QCoapMessagePrivate { public: QCoapRequestPrivate(const QUrl &url = QUrl(), - QCoapMessage::MessageType type = QCoapMessage::NonConfirmable, + QCoapMessage::MessageType type = QCoapMessage::MessageType::NonConfirmable, const QUrl &proxyUrl = QUrl()); QCoapRequestPrivate(const QCoapRequestPrivate &other) = default; ~QCoapRequestPrivate(); @@ -61,7 +61,7 @@ public: QUrl uri; QUrl proxyUri; - QtCoap::Method method = QtCoap::Invalid; + QtCoap::Method method = QtCoap::Method::Invalid; }; QT_END_NAMESPACE |