1// Copyright (C) 2017 Witekio.
2// Copyright (C) 2018 The Qt Company Ltd.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
4
5#ifndef QCOAPREPLY_H
6#define QCOAPREPLY_H
7
8#include <QtCoap/qcoapmessage.h>
9#include <QtCoap/qcoaprequest.h>
10#include <QtCoap/qcoapglobal.h>
11#include <QtCoap/qcoapnamespace.h>
12#include <QtCore/qiodevice.h>
13
14QT_BEGIN_NAMESPACE
15
16class QCoapInternalReply;
17class QCoapReplyPrivate;
18class Q_COAP_EXPORT QCoapReply : public QIODevice
19{
20 Q_OBJECT
21public:
22 ~QCoapReply() override;
23
24 QtCoap::ResponseCode responseCode() const;
25 QCoapMessage message() const;
26 QCoapRequest request() const;
27 QUrl url() const;
28 QtCoap::Method method() const;
29 QtCoap::Error errorReceived() const;
30 bool isRunning() const;
31 bool isFinished() const;
32 bool isAborted() const;
33 bool isSuccessful() const;
34 void abortRequest();
35
36Q_SIGNALS:
37 void finished(QCoapReply *reply);
38 void notified(QCoapReply *reply, const QCoapMessage &message);
39 void error(QCoapReply *reply, QtCoap::Error error);
40 void aborted(const QCoapToken &token);
41
42protected:
43 qint64 readData(char *data, qint64 maxSize) override;
44 qint64 writeData(const char *data, qint64 maxSize) override;
45
46 Q_DECLARE_PRIVATE(QCoapReply)
47 Q_PRIVATE_SLOT(d_func(), void _q_setRunning(const QCoapToken &, QCoapMessageId))
48 Q_PRIVATE_SLOT(d_func(), void _q_setContent(const QHostAddress &host, const QCoapMessage &,
49 QtCoap::ResponseCode))
50 Q_PRIVATE_SLOT(d_func(), void _q_setNotified())
51 Q_PRIVATE_SLOT(d_func(), void _q_setObserveCancelled())
52 Q_PRIVATE_SLOT(d_func(), void _q_setFinished(QtCoap::Error))
53 Q_PRIVATE_SLOT(d_func(), void _q_setError(QtCoap::ResponseCode))
54 Q_PRIVATE_SLOT(d_func(), void _q_setError(QtCoap::Error))
55
56private:
57 explicit QCoapReply(QCoapReplyPrivate &dd, QObject *parent = nullptr);
58 friend class QCoapResourceDiscoveryReply;
59};
60
61QT_END_NAMESPACE
62
63#endif // QCOAPREPLY_H
64

source code of qtcoap/src/coap/qcoapreply.h