mirror of
https://github.com/Lurkki14/tuxclocker.git
synced 2025-02-25 18:55:24 -06:00
daemon: register paths in correct hierarchy
This commit is contained in:
parent
4ba9348f7d
commit
4f4fecfba0
@ -1,15 +1,16 @@
|
||||
#include <DBusTypes.hpp>
|
||||
#include <iostream>
|
||||
#include <QCoreApplication>
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusError>
|
||||
#include <QDBusMetaType>
|
||||
#include <QDebug>
|
||||
#include <QStack>
|
||||
#include <patterns.hpp>
|
||||
#include <Plugin.hpp>
|
||||
#include <Tree.hpp>
|
||||
|
||||
#include "AdaptorFactory.hpp"
|
||||
//#include "DummyAdaptor.hpp"
|
||||
|
||||
using namespace TuxClocker;
|
||||
using namespace TuxClocker::Device;
|
||||
@ -28,26 +29,46 @@ int main(int argc, char **argv) {
|
||||
qDebug() << "found " << plugins.value().size() << " plugins";
|
||||
for (auto &plugin : plugins.value()) {
|
||||
auto n = plugin->deviceRootNode();
|
||||
TreeNode<DeviceNode>::preorder(plugin->deviceRootNode(), [](auto val) {std::cout << val.name << "\n";});
|
||||
TreeNode<DeviceNode>::preorder(plugin->deviceRootNode(), [](auto val) {qDebug() << QString::fromStdString(val.name);});
|
||||
|
||||
TreeNode<DeviceNode>::preorder(plugin->deviceRootNode(), [&](auto nodeVal) {
|
||||
|
||||
/*TreeNode<DeviceNode>::preorder(plugin->deviceRootNode(), [&](auto nodeVal) {
|
||||
auto obj = new QObject(&root); // Is destroyed when root goes out of scope
|
||||
// Remove whitespaces to make valid object paths
|
||||
auto objName = QString::fromStdString(nodeVal.name).replace(" ", "");
|
||||
|
||||
if_let(pattern(some(arg)) = nodeVal.interface) = [&](auto iface) {
|
||||
adaptors.append(AdaptorFactory::adaptor(obj, iface).value());
|
||||
};
|
||||
|
||||
connection.registerObject("/" + objName, obj);
|
||||
});
|
||||
});*/
|
||||
|
||||
std::function<void(TreeNode<DeviceNode>, QString)> traverse;
|
||||
traverse = [&traverse, &connection, &adaptors, &root](
|
||||
TreeNode<DeviceNode> node,
|
||||
QString parentPath) {
|
||||
auto obj = new QObject(&root); // Is destroyed when root goes out of scope
|
||||
// Remove whitespaces to make valid object paths
|
||||
auto objName = QString::fromStdString(node.value().name).replace(" ", "");
|
||||
|
||||
if_let(pattern(some(arg)) = node.value().interface) = [&](auto iface) {
|
||||
adaptors.append(AdaptorFactory::adaptor(obj, iface).value());
|
||||
};
|
||||
auto thisPath = parentPath + objName + "/";
|
||||
connection.registerObject("/" + objName, obj);
|
||||
qDebug() << thisPath;
|
||||
for (const auto &child : node.children()) traverse(child, thisPath);
|
||||
};
|
||||
// Root node should always be empty
|
||||
for (const auto &node : plugin->deviceRootNode().children())
|
||||
traverse(node, "/");
|
||||
}
|
||||
}
|
||||
|
||||
//registerReadables(&root, connection);
|
||||
//registerAssignables(&root, connection);
|
||||
|
||||
DummyAdaptor ad(&root);
|
||||
//DummyAdaptor ad(&root);
|
||||
connection.registerObject("/", &root);
|
||||
|
||||
if (!connection.registerService("org.tuxclocker")) {
|
||||
|
Loading…
Reference in New Issue
Block a user