Files
logos-cpp-sdk/cpp/module_proxy.cpp
T

81 lines
2.4 KiB
C++
Raw Normal View History

2025-09-30 14:56:47 -04:00
#include "module_proxy.h"
#include "logos_provider_object.h"
2025-09-30 14:56:47 -04:00
#include <QDebug>
ModuleProxy::ModuleProxy(LogosProviderObject* provider, QObject* parent)
2025-09-30 14:56:47 -04:00
: QObject(parent)
, m_provider(provider)
2025-09-30 14:56:47 -04:00
{
if (m_provider) {
m_provider->setEventListener([this](const QString& eventName, const QVariantList& data) {
qDebug() << "[LogosProviderObject] ModuleProxy: forwarding event" << eventName << "as Qt signal";
emit eventResponse(eventName, data);
});
qDebug() << "[LogosProviderObject] ModuleProxy: created, wrapping LogosProviderObject"
<< m_provider->providerName();
2025-09-30 14:56:47 -04:00
}
}
ModuleProxy::~ModuleProxy()
{
qDebug() << "ModuleProxy: destroyed";
2025-09-30 14:56:47 -04:00
}
bool ModuleProxy::saveToken(const QString& from_module_name, const QString& token)
{
if (from_module_name.isEmpty()) {
qWarning() << "ModuleProxy: Cannot save token with empty module name";
return false;
}
if (token.isEmpty()) {
qWarning() << "ModuleProxy: Cannot save empty token for module:" << from_module_name;
return false;
}
m_tokens[from_module_name] = token;
qDebug() << "ModuleProxy: Token saved for module:" << from_module_name;
2025-09-30 14:56:47 -04:00
return true;
}
QVariant ModuleProxy::callRemoteMethod(const QString& authToken, const QString& methodName, const QVariantList& args)
{
if (!m_provider) {
qWarning() << "ModuleProxy: Cannot call method on null provider:" << methodName;
2025-09-30 14:56:47 -04:00
return QVariant();
}
if (methodName.isEmpty()) {
qWarning() << "ModuleProxy: Method name cannot be empty";
return QVariant();
}
2025-12-02 13:21:05 -05:00
if (methodName == "getPluginMethods" && args.isEmpty()) {
return QVariant(getPluginMethods());
}
qDebug() << "ModuleProxy: callRemoteMethod" << methodName << "args:" << args;
return m_provider->callMethod(methodName, args);
2025-09-30 14:56:47 -04:00
}
bool ModuleProxy::informModuleToken(const QString& authToken, const QString& moduleName, const QString& token)
{
Q_UNUSED(authToken)
2025-09-30 14:56:47 -04:00
if (!m_provider) {
qWarning() << "ModuleProxy: Cannot inform token on null provider";
2025-09-30 14:56:47 -04:00
return false;
}
return m_provider->informModuleToken(moduleName, token);
2025-09-30 14:56:47 -04:00
}
QJsonArray ModuleProxy::getPluginMethods()
{
if (!m_provider) return QJsonArray();
2025-09-30 14:56:47 -04:00
qDebug() << "[LogosProviderObject] ModuleProxy: calling LogosProviderObject::getMethods()";
return m_provider->getMethods();
2025-09-30 14:56:47 -04:00
}
#include "moc_module_proxy.cpp"