| 1 | // Copyright (C) 2017-2015 Ford Motor Company |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QCONNECTIONFACTORIES_P_H |
| 5 | #define QCONNECTIONFACTORIES_P_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include <QtCore/qdatastream.h> |
| 19 | #include <QtCore/qiodevice.h> |
| 20 | #include <QtCore/qpointer.h> |
| 21 | #include <QtCore/private/qobject_p.h> |
| 22 | |
| 23 | #include <QtRemoteObjects/qtremoteobjectglobal.h> |
| 24 | #include <QtRemoteObjects/qconnectionfactories.h> |
| 25 | #include "qremoteobjectpacket_p.h" |
| 26 | |
| 27 | #include <memory> |
| 28 | |
| 29 | QT_BEGIN_NAMESPACE |
| 30 | |
| 31 | namespace QtRemoteObjects { |
| 32 | |
| 33 | static const int dataStreamVersion = QDataStream::Qt_6_2; |
| 34 | static const QLatin1String protocolVersion("QtRO 2.0"); |
| 35 | |
| 36 | } |
| 37 | |
| 38 | class QtROExternalIoDevice : public QtROIoDeviceBase |
| 39 | { |
| 40 | Q_OBJECT |
| 41 | |
| 42 | public: |
| 43 | explicit QtROExternalIoDevice(QIODevice *device, QObject *parent=nullptr); |
| 44 | QIODevice *connection() const override; |
| 45 | bool isOpen() const override; |
| 46 | |
| 47 | protected: |
| 48 | void doClose() override; |
| 49 | QString deviceType() const override; |
| 50 | private: |
| 51 | Q_DECLARE_PRIVATE(QtROExternalIoDevice) |
| 52 | }; |
| 53 | |
| 54 | class QtROIoDeviceBasePrivate : public QObjectPrivate |
| 55 | { |
| 56 | public: |
| 57 | QtROIoDeviceBasePrivate(); |
| 58 | |
| 59 | // TODO Remove stream() |
| 60 | QDataStream &stream() { return m_dataStream; } |
| 61 | |
| 62 | bool m_isClosing = false; |
| 63 | quint32 m_curReadSize = 0; |
| 64 | QDataStream m_dataStream; |
| 65 | QSet<QString> m_remoteObjects; |
| 66 | std::unique_ptr<QRemoteObjectPackets::CodecBase> m_codec { nullptr }; |
| 67 | Q_DECLARE_PUBLIC(QtROIoDeviceBase) |
| 68 | }; |
| 69 | |
| 70 | class QtROClientIoDevicePrivate : public QtROIoDeviceBasePrivate |
| 71 | { |
| 72 | public: |
| 73 | QtROClientIoDevicePrivate() : QtROIoDeviceBasePrivate() { } |
| 74 | QUrl m_url; |
| 75 | Q_DECLARE_PUBLIC(QtROClientIoDevice) |
| 76 | }; |
| 77 | |
| 78 | class QtROExternalIoDevicePrivate : public QtROIoDeviceBasePrivate |
| 79 | { |
| 80 | public: |
| 81 | QtROExternalIoDevicePrivate(QIODevice *device) : QtROIoDeviceBasePrivate(), m_device(device) { } |
| 82 | QPointer<QIODevice> m_device; |
| 83 | Q_DECLARE_PUBLIC(QtROExternalIoDevice) |
| 84 | }; |
| 85 | |
| 86 | QT_END_NAMESPACE |
| 87 | |
| 88 | #endif |
| 89 |
