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