summaryrefslogtreecommitdiffstats
path: root/src/remoteobjects/qconnectionfactories.cpp
diff options
context:
space:
mode:
authorBrett Stottlemyer <bstottle@ford.com>2018-07-15 20:43:18 -0400
committerBrett Stottlemyer <bstottle@ford.com>2018-08-15 18:54:13 +0000
commite170cbe42b8f654894e4035c8ddfd6759a034be8 (patch)
treea0bf0b811aed03836f85df6acfa2414a552f0153 /src/remoteobjects/qconnectionfactories.cpp
parent8761c1a282f596a64e0fc624c87added43fb47d8 (diff)
Support externally generated QIODevices
This adds the APIs that will be necessary to create SSL sockets flexibly (and outside of QtRO) and pass them in. The integration tests are extended to show everything works if the tcp/ip connection is created outside QtRO. The Registry is supported by allowing an "external schema" to be set as the HostNode's url, which is then used by the registry as the address for any remoted() source objects. The client Node calls registerExternalSchema() with a std::function callback that can create the client-side QIODevice given the registry provided url. Change-Id: I0f2d0ea270771e096a787134ef87d537769045f6 Reviewed-by: Michael Brasser <michael.brasser@live.com>
Diffstat (limited to 'src/remoteobjects/qconnectionfactories.cpp')
-rw-r--r--src/remoteobjects/qconnectionfactories.cpp38
1 files changed, 37 insertions, 1 deletions
diff --git a/src/remoteobjects/qconnectionfactories.cpp b/src/remoteobjects/qconnectionfactories.cpp
index 317d2fa..0ca2fa8 100644
--- a/src/remoteobjects/qconnectionfactories.cpp
+++ b/src/remoteobjects/qconnectionfactories.cpp
@@ -79,13 +79,14 @@ inline bool fromDataStream(QDataStream &in, QRemoteObjectPacketTypeEnum &type, Q
case Ping: type = Ping; break;
case Pong: type = Pong; break;
default:
- qCWarning(QT_REMOTEOBJECT_IO) << "Invalid packet received" << type;
+ qCWarning(QT_REMOTEOBJECT_IO) << "Invalid packet received" << _type;
}
if (type == Invalid)
return false;
if (type == ObjectList)
return true;
in >> name;
+ qCDebug(QT_REMOTEOBJECT_IO) << "Packet received of type" << type << "for object" << name;
return true;
}
@@ -225,6 +226,41 @@ ServerIoDevice *QConnectionAbstractServer::nextPendingConnection()
return iodevice;
}
+ExternalIoDevice::ExternalIoDevice(QIODevice *device, QObject *parent)
+ : IoDeviceBase(parent)
+ , m_device(device)
+{
+ initializeDataStream();
+ connect(m_device, &QIODevice::aboutToClose, this, [this]() { this->m_isClosing = true; });
+ connect(m_device, &QIODevice::readyRead, this, &ExternalIoDevice::readyRead);
+ auto meta = device->metaObject();
+ if (-1 == meta->indexOfSignal(SIGNAL(disconnected())))
+ connect(m_device, SIGNAL(disconnected()), this, SIGNAL(disconnected()));
+}
+
+QIODevice *ExternalIoDevice::connection() const
+{
+ return m_device;
+}
+
+bool ExternalIoDevice::isOpen() const
+{
+ if (!m_device)
+ return false;
+ return m_device->isOpen() && IoDeviceBase::isOpen();
+}
+
+void ExternalIoDevice::doClose()
+{
+ if (isOpen())
+ m_device->close();
+}
+
+QString ExternalIoDevice::deviceType() const
+{
+ return QStringLiteral("ExternalIoDevice");
+}
+
/*!
\class QtROServerFactory
\inmodule QtRemoteObjects