Skip to content

Finish Abstraction & Refactor (Ongoing)#25

Draft
iurimatias wants to merge 6 commits intomasterfrom
refactor_p2
Draft

Finish Abstraction & Refactor (Ongoing)#25
iurimatias wants to merge 6 commits intomasterfrom
refactor_p2

Conversation

@iurimatias
Copy link
Member

  • abstract qt remote registry
  • abstract connection/transport; and clearly separate qt remote obj and qt local into separate implementations

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a transport abstraction layer to unify Local (in-process) and Remote (Qt Remote Objects) module communication, and refactors the provider/consumer APIs to use this abstraction instead of directly depending on PluginRegistry / QRemoteObjects.

Changes:

  • Added LogosTransport* interfaces plus factories and Qt-based local/remote implementations.
  • Added a minimal LogosRegistry interface with a factory (NullRegistry for local, QtRemoteRegistry for remote).
  • Updated build/packaging (CMake + Nix include install) to ship the new transport/registry sources and headers.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
nix/include.nix Installs new transport/registry headers/sources and implementation folders into the Nix include output.
cpp/logos_transport.h Defines transport host/connection interfaces for publishing, connecting, requesting handles, and invoking methods.
cpp/logos_transport_factory.h Declares factory functions for selecting local vs remote transport.
cpp/logos_transport_factory.cpp Implements mode-based factory selection for transport host/connection.
cpp/logos_registry.h Defines minimal registry interface for “registry is initialized” checks.
cpp/logos_registry_factory.h Declares mode-based registry creation API.
cpp/logos_registry_factory.cpp Implements NullRegistry (local) vs QtRemoteRegistry (remote) creation.
cpp/logos_api_provider.h Replaces direct registry host usage with a transport-host abstraction.
cpp/logos_api_provider.cpp Publishes/unpublishes module proxies via transport instead of PluginRegistry/QRemoteObjectRegistryHost directly.
cpp/logos_api_consumer.h Replaces direct node usage with a transport-connection abstraction.
cpp/logos_api_consumer.cpp Requests handles and performs calls through the transport layer; removes direct QRemoteObjectNode logic.
cpp/implementations/qt_local/local_transport.h Declares local transport host/connection (PluginRegistry-based).
cpp/implementations/qt_local/local_transport.cpp Implements local transport via PluginRegistry and ModuleProxy.
cpp/implementations/qt_remote/remote_transport.h Declares remote transport host/connection (Qt Remote Objects-based).
cpp/implementations/qt_remote/remote_transport.cpp Implements remote transport via QRemoteObjectRegistryHost/QRemoteObjectNode and pending calls.
cpp/implementations/qt_remote/qt_remote_registry.h Declares a registry wrapper backed by QRemoteObjectRegistryHost.
cpp/implementations/qt_remote/qt_remote_registry.cpp Implements QtRemoteRegistry lifecycle and initialization check.
cpp/CMakeLists.txt Adds new sources/headers and include dirs; installs implementation headers; links RemoteObjects.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +12 to +22
return std::make_unique<LocalTransportHost>();
}
return std::make_unique<RemoteTransportHost>(registryUrl);
}

std::unique_ptr<LogosTransportConnection> createConnection(const QString& registryUrl)
{
if (LogosModeConfig::isLocal()) {
return std::make_unique<LocalTransportConnection>();
}
return std::make_unique<RemoteTransportConnection>(registryUrl);
Comment on lines +26 to +28
return std::make_unique<NullRegistry>();
}
return std::make_unique<QtRemoteRegistry>(url);
Comment on lines +48 to +50
* @param objectName The name of the object to acquire
* @param timeout Timeout to wait for the object to be ready (default 20000ms)
* @return QObject* pointer to the object, or nullptr if failed
Comment on lines 69 to +82
QVariant LogosAPIConsumer::invokeRemoteMethod(const QString& authToken, const QString& objectName, const QString& methodName,
const QVariantList& args, Timeout timeout)
{
qDebug() << "LogosAPIConsumer: Calling invokeRemoteMethod:" << objectName << methodName << "args_count:" << args.size() << "timeout:" << timeout.ms;

// This method handles both ModuleProxy-wrapped modules (template_module, package_manager)
// and direct remote object calls for other modules
QObject* plugin = requestObject(objectName, timeout);
QObject* plugin = m_transport->requestObject(objectName, timeout.ms);
if (!plugin) {
qWarning() << "LogosAPIConsumer: Failed to acquire plugin/replica for object:" << objectName;
return QVariant();
}

ModuleProxy* moduleProxy = qobject_cast<ModuleProxy*>(plugin);
if (moduleProxy) {
QVariant result = moduleProxy->callRemoteMethod(authToken, methodName, args);
if (!LogosModeConfig::isLocal()) {
delete plugin;
}
return result;
}

if (LogosModeConfig::isLocal()) {
qWarning() << "LogosAPIConsumer: Local mode requires ModuleProxy-wrapped objects";
return QVariant();
}

// Remote mode: callRemoteMethod returns QRemoteObjectPendingCall, not QVariant
QRemoteObjectPendingCall pendingCall;
bool success = QMetaObject::invokeMethod(
plugin,
"callRemoteMethod",
Qt::DirectConnection,
Q_RETURN_ARG(QRemoteObjectPendingCall, pendingCall),
Q_ARG(QString, authToken),
Q_ARG(QString, methodName),
Q_ARG(QVariantList, args)
);

if (!success) {
qWarning() << "LogosAPIConsumer: Failed to invoke callRemoteMethod on replica for object:" << objectName;
delete plugin;
return QVariant();
}

// Wait for the result
pendingCall.waitForFinished(timeout.ms);
delete plugin;

if (!pendingCall.isFinished() || pendingCall.error() != QRemoteObjectPendingCall::NoError) {
qWarning() << "LogosAPIConsumer: Remote callRemoteMethod failed or timed out:" << pendingCall.error();
return QVariant();
}

return pendingCall.returnValue();
QVariant result = m_transport->callRemoteMethod(plugin, authToken, methodName, args, timeout.ms);
m_transport->releaseObject(plugin);
return result;
connectToRegistry();
}
m_transport = LogosTransportFactory::createConnection(m_registryUrl);
m_transport->connectToHost();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants