| 1 | // Copyright (C) 2017 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 QREMOTEOBJECTSOURCEIO_P_H |
| 5 | #define QREMOTEOBJECTSOURCEIO_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 "qconnectionfactories_p.h" |
| 19 | #include "qtremoteobjectglobal.h" |
| 20 | #include "qremoteobjectpacket_p.h" |
| 21 | |
| 22 | #include <QtCore/qiodevice.h> |
| 23 | #include <QtCore/qscopedpointer.h> |
| 24 | #include <QtNetwork/qlocalserver.h> |
| 25 | |
| 26 | QT_BEGIN_NAMESPACE |
| 27 | |
| 28 | class QRemoteObjectSourceBase; |
| 29 | class QRemoteObjectRootSource; |
| 30 | class SourceApiMap; |
| 31 | class QRemoteObjectHostBase; |
| 32 | |
| 33 | class QRemoteObjectSourceIo : public QObject |
| 34 | { |
| 35 | Q_OBJECT |
| 36 | public: |
| 37 | explicit QRemoteObjectSourceIo(const QUrl &address, QObject *parent = nullptr); |
| 38 | explicit QRemoteObjectSourceIo(QObject *parent = nullptr); |
| 39 | ~QRemoteObjectSourceIo() override; |
| 40 | |
| 41 | bool startListening(); |
| 42 | bool enableRemoting(QObject *object, const QMetaObject *meta, const QString &name, |
| 43 | const QString &typeName); |
| 44 | bool enableRemoting(QObject *object, const SourceApiMap *api, QObject *adapter = nullptr); |
| 45 | bool disableRemoting(QObject *object); |
| 46 | void newConnection(QtROIoDeviceBase *conn); |
| 47 | void setSocketOptions(QLocalServer::SocketOptions options); |
| 48 | |
| 49 | QUrl serverAddress() const; |
| 50 | |
| 51 | public Q_SLOTS: |
| 52 | void handleConnection(); |
| 53 | void onServerDisconnect(QObject *obj = nullptr); |
| 54 | void onServerRead(QObject *obj); |
| 55 | |
| 56 | Q_SIGNALS: |
| 57 | void remoteObjectAdded(const QRemoteObjectSourceLocation &); |
| 58 | void remoteObjectRemoved(const QRemoteObjectSourceLocation &); |
| 59 | void serverRemoved(const QUrl& url); |
| 60 | |
| 61 | public: |
| 62 | void registerSource(QRemoteObjectSourceBase *source); |
| 63 | void unregisterSource(QRemoteObjectSourceBase *source); |
| 64 | |
| 65 | QHash<QIODevice*, quint32> m_readSize; |
| 66 | QSet<QtROIoDeviceBase*> m_connections; |
| 67 | QHash<QObject *, QRemoteObjectRootSource*> m_objectToSourceMap; |
| 68 | QMap<QString, QRemoteObjectSourceBase*> m_sourceObjects; |
| 69 | QMap<QString, QRemoteObjectRootSource*> m_sourceRoots; |
| 70 | QHash<QtROIoDeviceBase*, QUrl> m_registryMapping; |
| 71 | QScopedPointer<QConnectionAbstractServer> m_server; |
| 72 | // TODO should have some sort of manager for the codec |
| 73 | QScopedPointer<QRemoteObjectPackets::CodecBase> m_codec{new QRemoteObjectPackets::QDataStreamCodec}; |
| 74 | QString m_rxName; |
| 75 | QVariantList m_rxArgs; |
| 76 | QUrl m_address; |
| 77 | }; |
| 78 | |
| 79 | QT_END_NAMESPACE |
| 80 | |
| 81 | #endif |
| 82 | |