mirror of
https://github.com/Lurkki14/tuxclocker.git
synced 2024-11-28 19:03:50 -06:00
daemon: create some objects in dbus
This commit is contained in:
parent
4247583c57
commit
eb027a6e2e
@ -1,42 +1,58 @@
|
|||||||
|
#include <iostream>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDBusConnection>
|
#include <QDBusConnection>
|
||||||
#include <QDBusError>
|
#include <QDBusError>
|
||||||
#include <QDBusMetaType>
|
#include <QDBusMetaType>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <patterns.hpp>
|
||||||
#include <Plugin.hpp>
|
#include <Plugin.hpp>
|
||||||
|
#include <Tree.hpp>
|
||||||
|
|
||||||
#include "AssignableAdaptorFactory.h"
|
#include "AdaptorFactory.hpp"
|
||||||
#include "EnumData.h"
|
//#include "DummyAdaptor.hpp"
|
||||||
#include "Result.h"
|
|
||||||
#include "ReadableAdaptorFactory.h"
|
|
||||||
|
|
||||||
using namespace TuxClocker;
|
using namespace TuxClocker;
|
||||||
|
using namespace TuxClocker::Device;
|
||||||
|
using namespace TuxClocker::Plugin;
|
||||||
|
using namespace mpark::patterns;
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
QCoreApplication a(argc, argv);
|
QCoreApplication a(argc, argv);
|
||||||
|
|
||||||
auto plugins = Plugin::DevicePlugin::loadPlugins();
|
auto connection = QDBusConnection::systemBus();
|
||||||
|
auto plugins = DevicePlugin::loadPlugins();
|
||||||
|
QVector<QDBusAbstractAdaptor*> adaptors;
|
||||||
|
|
||||||
|
QObject root;
|
||||||
if (plugins.has_value()) {
|
if (plugins.has_value()) {
|
||||||
qDebug() << "found " << plugins.value().size() << " plugins";
|
qDebug() << "found " << plugins.value().size() << " plugins";
|
||||||
for (auto &plugin : plugins.value()) {
|
for (auto &plugin : plugins.value()) {
|
||||||
plugin->foo();
|
auto n = plugin->deviceRootNode();
|
||||||
plugin->deviceRootNode();
|
TreeNode<DeviceNode>::preorder(plugin->deviceRootNode(), [](auto val) {std::cout << val.name << "\n";});
|
||||||
|
|
||||||
|
TreeNode<DeviceNode>::preorder(plugin->deviceRootNode(), [&](auto nodeVal) {
|
||||||
|
auto obj = new QObject(&root); // Is destroyed when root goes out of scope
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*registerMetatypes();
|
|
||||||
|
|
||||||
QObject root;
|
//registerReadables(&root, connection);
|
||||||
|
//registerAssignables(&root, connection);
|
||||||
auto connection = QDBusConnection::systemBus();
|
|
||||||
registerReadables(&root, connection);
|
|
||||||
registerAssignables(&root, connection);
|
|
||||||
|
|
||||||
|
DummyAdaptor ad(&root);
|
||||||
connection.registerObject("/", &root);
|
connection.registerObject("/", &root);
|
||||||
|
|
||||||
if (!connection.registerService("org.tuxclocker")) {
|
if (!connection.registerService("org.tuxclocker")) {
|
||||||
qDebug() << "unable to register:" << connection.lastError().message();
|
qDebug() << "unable to register:" << connection.lastError().message();
|
||||||
}*/
|
}
|
||||||
|
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
@ -4,17 +4,19 @@ qt5_dep = dependency('qt5',
|
|||||||
|
|
||||||
boost_dep = dependency('boost', modules : ['system'])
|
boost_dep = dependency('boost', modules : ['system'])
|
||||||
|
|
||||||
#moc_files = qt5.preprocess(moc_headers : #['ReadableDynamicVariantAdaptor.h',
|
patterns_inc = include_directories('../include/deps/patterns/include/mpark')
|
||||||
# 'AssignableEnumAdaptor.h',
|
|
||||||
# 'AssignableVariantRangeAdaptor.h'],
|
moc_files = qt5.preprocess(moc_headers : ['Adaptors.hpp',
|
||||||
# dependencies : qt5_dep)
|
'DummyAdaptor.hpp'],
|
||||||
|
dependencies : qt5_dep)
|
||||||
|
|
||||||
sources = ['main.cpp']
|
sources = ['main.cpp']
|
||||||
|
|
||||||
executable('tuxclockerd',
|
executable('tuxclockerd',
|
||||||
sources,
|
sources,
|
||||||
|
moc_files,
|
||||||
override_options : ['cpp_std=c++17'],
|
override_options : ['cpp_std=c++17'],
|
||||||
include_directories : incdir,
|
include_directories : [incdir, patterns_inc],
|
||||||
dependencies : [qt5_dep, boost_dep, dl],
|
dependencies : [qt5_dep, boost_dep, dl],
|
||||||
link_with : libtuxclocker,
|
link_with : libtuxclocker,
|
||||||
install : true)
|
install : true)
|
||||||
@ -22,7 +24,8 @@ executable('tuxclockerd',
|
|||||||
# DBus data directory
|
# DBus data directory
|
||||||
|
|
||||||
dbus_data_dir = join_paths(get_option('prefix'), get_option('datadir'), 'dbus-1')
|
dbus_data_dir = join_paths(get_option('prefix'), get_option('datadir'), 'dbus-1')
|
||||||
|
|
||||||
dbus_system_services_dir = join_paths(dbus_data_dir, 'system.d')
|
dbus_system_services_dir = join_paths(dbus_data_dir, 'system.d')
|
||||||
|
|
||||||
install_data('org.tuxclocker.conf', install_dir : dbus_system_services_dir)
|
install_data('org.tuxclocker.conf', install_dir : dbus_system_services_dir)
|
||||||
|
|
||||||
|
dbus_service_dir = join_paths(dbus_data_dir, 'system-services')
|
||||||
|
install_data('org.tuxclocker.service', install_dir : dbus_service_dir)
|
||||||
|
Loading…
Reference in New Issue
Block a user