From 21cf1f25c3a50e22742d7ff6b5cde4179babf177 Mon Sep 17 00:00:00 2001 From: Chupligin Sergey Date: Wed, 13 Mar 2024 13:58:04 +0000 Subject: [PATCH] WIP --- CMakeLists.txt | 2 + data/glacier-home.conf | 13 +++ src/CMakeLists.txt | 31 +++++-- src/audiocontrol/audioroutemanager.cpp | 22 +++++ src/audiocontrol/audioroutemanager.h | 16 ++++ src/audiocontrol/audiorouteservice.cpp | 91 +++++++++++++++++++ src/audiocontrol/audiorouteservice.h | 27 ++++++ .../org.nemomobile.Route.Manager.xml | 64 +++++++++++++ src/main.cpp | 4 + .../org.maemo.resource.manager.xml | 59 ++++++++++++ .../resourcecontrolmanager.cpp | 21 +++++ src/resourcecontrol/resourcecontrolmanager.h | 16 ++++ .../resourcecontrolservice.cpp | 61 +++++++++++++ src/resourcecontrol/resourcecontrolservice.h | 21 +++++ 14 files changed, 439 insertions(+), 9 deletions(-) create mode 100644 data/glacier-home.conf create mode 100644 src/audiocontrol/audioroutemanager.cpp create mode 100644 src/audiocontrol/audioroutemanager.h create mode 100644 src/audiocontrol/audiorouteservice.cpp create mode 100644 src/audiocontrol/audiorouteservice.h create mode 100644 src/audiocontrol/org.nemomobile.Route.Manager.xml create mode 100644 src/resourcecontrol/org.maemo.resource.manager.xml create mode 100644 src/resourcecontrol/resourcecontrolmanager.cpp create mode 100644 src/resourcecontrol/resourcecontrolmanager.h create mode 100644 src/resourcecontrol/resourcecontrolservice.cpp create mode 100644 src/resourcecontrol/resourcecontrolservice.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 28d179b..5072165 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,7 @@ pkg_check_modules(LIPSTICK lipstick-qt6 REQUIRED IMPORTED_TARGET) pkg_check_modules(NEMODEVICELOCK nemodevicelock REQUIRED IMPORTED_TARGET) pkg_check_modules(NEMOCONNECTIVITY nemoconnectivity REQUIRED IMPORTED_TARGET) pkg_check_modules(MLITE6 mlite6 REQUIRED IMPORTED_TARGET) +pkg_check_modules(LIBRESOURCE libresourceqt6 REQUIRED IMPORTED_TARGET) find_package(ECM REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) @@ -46,6 +47,7 @@ add_subdirectory(settings-plugins) if(USE_SYSTEMD) install(FILES data/lipstick.service DESTINATION /usr/lib/systemd/user) + install(FILES data/glacier-home.conf DESTINATION /etc/dbus-1/system.d) endif() install(FILES data/nemovars.conf diff --git a/data/glacier-home.conf b/data/glacier-home.conf new file mode 100644 index 0000000..b413eac --- /dev/null +++ b/data/glacier-home.conf @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ccfcd27..9cf25b8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,6 +2,16 @@ file(GLOB_RECURSE QML_JS_FILES *.qml *.js) set(SRC main.cpp + audiocontrol/audioroutemanager.h + audiocontrol/audioroutemanager.cpp + audiocontrol/audiorouteservice.h + audiocontrol/audiorouteservice.cpp + audiocontrol/org.nemomobile.Route.Manager.xml + resourcecontrol/org.maemo.resource.manager.xml + resourcecontrol/resourcecontrolservice.cpp + resourcecontrol/resourcecontrolservice.h + resourcecontrol/resourcecontrolmanager.cpp + resourcecontrol/resourcecontrolmanager.h fileutils.cpp fileutils.h mceconnect.cpp @@ -17,15 +27,17 @@ set(SRC models/searchmodel.cpp ${QML_JS_FILES}) -#add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/geoagent.h ${CMAKE_CURRENT_SOURCE_DIR}/geoagent.cpp -# DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/org.freedesktop.GeoClue2.Agent.xml -# COMMENT "Generate adaptors files for Dbus service" -# COMMAND qdbusxml2cpp -l GeoclueAgent -i geoclueagent.h -a geoagent.h: ${CMAKE_CURRENT_SOURCE_DIR}/org.freedesktop.GeoClue2.Agent.xml -# COMMAND qdbusxml2cpp -i geoagent.h -l GeoclueAgent -i geoclueagent.h -a :geoagent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/org.freedesktop.GeoClue2.Agent.xml -# WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) +qt_add_dbus_adaptor(SRC "${CMAKE_SOURCE_DIR}/src/audiocontrol/org.nemomobile.Route.Manager.xml" + "audiocontrol/audiorouteservice.h" + "AudioRouteService" + "routemanageradaptor" + "RouteManagerAdaptor") -#set_property(SOURCE geoagent.h PROPERTY SKIP_AUTOGEN ON) -#set_property(SOURCE geoagent.cpp PROPERTY SKIP_AUTOGEN ON) +qt_add_dbus_adaptor(SRC "${CMAKE_SOURCE_DIR}/src/resourcecontrol/org.maemo.resource.manager.xml" + "resourcecontrol/resourcecontrolservice.h" + "ResourceControlService" + "resourcecontroladaptor" + "ResourCecontrolAdaptor") if(USE_GEOCLUE2) add_compile_options(-DUSE_GEOCLUE2) @@ -50,7 +62,8 @@ target_link_libraries(lipstick PUBLIC PkgConfig::LIPSTICK PkgConfig::MLITE6 PkgConfig::NEMODEVICELOCK - PkgConfig::NEMOCONNECTIVITY) + PkgConfig::NEMOCONNECTIVITY + PkgConfig::LIBRESOURCE) target_link_libraries(lipstick PUBLIC Qt6::WaylandCompositor) diff --git a/src/audiocontrol/audioroutemanager.cpp b/src/audiocontrol/audioroutemanager.cpp new file mode 100644 index 0000000..413d63b --- /dev/null +++ b/src/audiocontrol/audioroutemanager.cpp @@ -0,0 +1,22 @@ +#include "audioroutemanager.h" +#include "routemanageradaptor.h" + +#include +#include + +AudioRouteManager::AudioRouteManager(QObject* parent) + : QObject { parent } +{ + QDBusConnection systemBus = QDBusConnection::systemBus(); + + m_audioRouteSerice = new AudioRouteService(this); + new RouteManagerAdaptor(m_audioRouteSerice); + + if(!systemBus.registerObject("/org/nemomobile/Route/Manager", "org.nemomobile.Route.Manager", m_audioRouteSerice)) { + qWarning() << "Cant register Audio Router Manager"; + } + + if (!systemBus.registerService("org.nemomobile.Route.Manager")) { + qWarning("Unable to register D-Bus service %s: %s", "org.nemomobile.Route.Manager", systemBus.lastError().message().toUtf8().constData()); + } +} diff --git a/src/audiocontrol/audioroutemanager.h b/src/audiocontrol/audioroutemanager.h new file mode 100644 index 0000000..c7f234e --- /dev/null +++ b/src/audiocontrol/audioroutemanager.h @@ -0,0 +1,16 @@ +#ifndef AUDIOROUTEMANAGER_H +#define AUDIOROUTEMANAGER_H + +#include +#include "audiorouteservice.h" + +class AudioRouteManager : public QObject { + Q_OBJECT +public: + explicit AudioRouteManager(QObject* parent = nullptr); + +private: + AudioRouteService* m_audioRouteSerice; +}; + +#endif // AUDIOROUTEMANAGER_H diff --git a/src/audiocontrol/audiorouteservice.cpp b/src/audiocontrol/audiorouteservice.cpp new file mode 100644 index 0000000..3bdde3a --- /dev/null +++ b/src/audiocontrol/audiorouteservice.cpp @@ -0,0 +1,91 @@ +#include "audiorouteservice.h" +#include +#include + +AudioRouteService::AudioRouteService(QObject *parent) + : QObject(parent) +{ +} + +QString AudioRouteService::ActiveRoutes(uint &output_device_type, QString &input_device, uint &input_device_type) +{ + qDebug() << output_device_type; + qDebug() << input_device; + qDebug() << input_device_type; + + qWarning() << "NOT IMPLEMENTED YEAT" << Q_FUNC_INFO; + return ""; +} + +QString AudioRouteService::GetAll(uint &output_device_type, QString &input_device, uint &input_device_type, QVariantMap &features) +{ + qDebug() << output_device_type; + qDebug() << input_device; + qDebug() << input_device_type; + qDebug() << features; + + qWarning() << "NOT IMPLEMENTED YEAT" << Q_FUNC_INFO; + return ""; +} + +void AudioRouteService::Disable(const QString &feature) +{ + qDebug() << feature; + qWarning() << "NOT IMPLEMENTED YEAT" << Q_FUNC_INFO; +} + +void AudioRouteService::Enable(const QString &feature) +{ + qDebug() << feature; + qWarning() << "NOT IMPLEMENTED YEAT" << Q_FUNC_INFO; +} + +void AudioRouteService::Prefer(const QString &device) +{ + qDebug() << device; + qWarning() << "NOT IMPLEMENTED YEAT" << Q_FUNC_INFO; +} + +QStringList AudioRouteService::Features() +{ + qWarning() << "NOT IMPLEMENTED YEAT" << Q_FUNC_INFO; + QStringList features = QStringList() << "bluetooth_override" + << "speaker" + << "voicecallrecord" + << "fmradioloopback" + << "fmradio" + << "emergencycall"; + + return features; +} + +QStringList AudioRouteService::FeaturesAllowed() +{ + qWarning() << "NOT IMPLEMENTED YEAT" << Q_FUNC_INFO; + return QStringList(); +} + +QStringList AudioRouteService::FeaturesEnabled() +{ + qWarning() << "NOT IMPLEMENTED YEAT" << Q_FUNC_INFO; + return QStringList(); +} + +uint AudioRouteService::InterfaceVersion() +{ + qWarning() << "NOT IMPLEMENTED YEAT" << Q_FUNC_INFO; + return 0; +} + +QVariantMap AudioRouteService::Routes() +{ + qWarning() << "NOT IMPLEMENTED YEAT" << Q_FUNC_INFO; + return QVariantMap(); +} + +QVariantMap AudioRouteService::RoutesFiltered(uint filter) +{ + qDebug() << filter; + qWarning() << "NOT IMPLEMENTED YEAT" << Q_FUNC_INFO; + return QVariantMap(); +} diff --git a/src/audiocontrol/audiorouteservice.h b/src/audiocontrol/audiorouteservice.h new file mode 100644 index 0000000..28ac0bf --- /dev/null +++ b/src/audiocontrol/audiorouteservice.h @@ -0,0 +1,27 @@ +#ifndef AUDIOROUTESERVICE_H +#define AUDIOROUTESERVICE_H + +#include + +class AudioRouteService : public QObject { + Q_OBJECT + +public: + explicit AudioRouteService(QObject *parent = nullptr); + QString ActiveRoutes(uint &output_device_type, QString &input_device, uint &input_device_type); + QString GetAll(uint &output_device_type, QString &input_device, uint &input_device_type, QVariantMap &features); + + void Disable(const QString &feature); + void Enable(const QString &feature); + void Prefer(const QString &device); + + QStringList Features(); + QStringList FeaturesAllowed(); + QStringList FeaturesEnabled(); + uint InterfaceVersion(); + + QVariantMap Routes(); + QVariantMap RoutesFiltered(uint filter); +}; + +#endif // AUDIOROUTESERVICE_H diff --git a/src/audiocontrol/org.nemomobile.Route.Manager.xml b/src/audiocontrol/org.nemomobile.Route.Manager.xml new file mode 100644 index 0000000..13a5560 --- /dev/null +++ b/src/audiocontrol/org.nemomobile.Route.Manager.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main.cpp b/src/main.cpp index 478548b..8e87c07 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -46,6 +46,8 @@ #include "logging.h" #include "mceconnect.h" +#include "audiocontrol/audioroutemanager.h" + int main(int argc, char** argv) { HomeApplication app(argc, argv, QString()); @@ -65,6 +67,7 @@ int main(int argc, char** argv) QmlPath::append("/usr/share/glacier-home/qml"); QGuiApplication::setFont(QFont("Open Sans")); + AudioRouteManager* audioRouteManager = new AudioRouteManager(); FileUtils* fileUtils = new FileUtils(); MceConnect* mceConnect = new MceConnect(); @@ -93,6 +96,7 @@ int main(int argc, char** argv) } app.engine()->rootContext()->setContextProperty("nativeOrientation", nativeOrientation); + app.engine()->rootContext()->setContextProperty("audioRouteManager", audioRouteManager); app.engine()->rootContext()->setContextProperty("fileUtils", fileUtils); app.engine()->rootContext()->setContextProperty("mceConnect", mceConnect); app.engine()->addImportPath("/usr/lib/qt6/qml"); diff --git a/src/resourcecontrol/org.maemo.resource.manager.xml b/src/resourcecontrol/org.maemo.resource.manager.xml new file mode 100644 index 0000000..713b9d4 --- /dev/null +++ b/src/resourcecontrol/org.maemo.resource.manager.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/resourcecontrol/resourcecontrolmanager.cpp b/src/resourcecontrol/resourcecontrolmanager.cpp new file mode 100644 index 0000000..77145ee --- /dev/null +++ b/src/resourcecontrol/resourcecontrolmanager.cpp @@ -0,0 +1,21 @@ +#include "resourcecontrolmanager.h" +#include "resourcecontroladaptor.h" + +#include +#include + +ResourceControlManager::ResourceControlManager(QObject* parent) + : QObject { parent } +{ + QDBusConnection systemBus = QDBusConnection::systemBus(); + m_resourceControlServce = new ResourceControlService(this); + new ResourCecontrolAdaptor(m_resourceControlServce); + + if(!systemBus.registerObject("/org/maemo/resource/manager", "org.maemo.resource.manager", m_resourceControlServce)) { + qWarning() << "Cant register Resource Control Manager"; + } + + if (!systemBus.registerService("org.maemo.resource.manager")) { + qWarning("Unable to register D-Bus service %s: %s", "org.maemo.resource.manager", systemBus.lastError().message().toUtf8().constData()); + } +} diff --git a/src/resourcecontrol/resourcecontrolmanager.h b/src/resourcecontrol/resourcecontrolmanager.h new file mode 100644 index 0000000..95ede6c --- /dev/null +++ b/src/resourcecontrol/resourcecontrolmanager.h @@ -0,0 +1,16 @@ +#ifndef RESOURCECONTROLMANAGER_H +#define RESOURCECONTROLMANAGER_H + +#include +#include "resourcecontrolservice.h" + +class ResourceControlManager : public QObject { + Q_OBJECT +public: + explicit ResourceControlManager(QObject* parent = nullptr); + +private: + ResourceControlService* m_resourceControlServce; +}; + +#endif // RESOURCECONTROLMANAGER_H diff --git a/src/resourcecontrol/resourcecontrolservice.cpp b/src/resourcecontrol/resourcecontrolservice.cpp new file mode 100644 index 0000000..20eece2 --- /dev/null +++ b/src/resourcecontrol/resourcecontrolservice.cpp @@ -0,0 +1,61 @@ +#include "resourcecontrolservice.h" +#include + +ResourceControlService::ResourceControlService(QObject* parent) + : QObject { parent } +{ +} + +QVariantMap ResourceControlService::Register(const QVariantMap &send) +{ + qWarning() << "NOT IMPLEMENTED YEAT" << Q_FUNC_INFO << send; + return QVariantMap(); +} + +QVariantMap ResourceControlService::acquire(const QVariantMap &send) +{ + qWarning() << "NOT IMPLEMENTED YEAT" << Q_FUNC_INFO << send; + return QVariantMap(); +} + +QVariantMap ResourceControlService::advice(const QVariantMap &send) +{ + qWarning() << "NOT IMPLEMENTED YEAT" << Q_FUNC_INFO << send; + return QVariantMap(); +} + +QVariantMap ResourceControlService::audio(const QVariantMap &send) +{ + qWarning() << "NOT IMPLEMENTED YEAT" << Q_FUNC_INFO << send; + return QVariantMap(); +} + +QVariantMap ResourceControlService::grant(const QVariantMap &send) +{ + qWarning() << "NOT IMPLEMENTED YEAT" << Q_FUNC_INFO << send; + return QVariantMap(); +} + +QVariantMap ResourceControlService::release(const QVariantMap &send) +{ + qWarning() << "NOT IMPLEMENTED YEAT" << Q_FUNC_INFO << send; + return QVariantMap(); +} + +QVariantMap ResourceControlService::unregister(const QVariantMap &send) +{ + qWarning() << "NOT IMPLEMENTED YEAT" << Q_FUNC_INFO << send; + return QVariantMap(); +} + +QVariantMap ResourceControlService::update(const QVariantMap &send) +{ + qWarning() << "NOT IMPLEMENTED YEAT" << Q_FUNC_INFO << send; + return QVariantMap(); +} + +QVariantMap ResourceControlService::video(const QVariantMap &send) +{ + qWarning() << "NOT IMPLEMENTED YEAT" << Q_FUNC_INFO << send; + return QVariantMap(); +} diff --git a/src/resourcecontrol/resourcecontrolservice.h b/src/resourcecontrol/resourcecontrolservice.h new file mode 100644 index 0000000..af7f032 --- /dev/null +++ b/src/resourcecontrol/resourcecontrolservice.h @@ -0,0 +1,21 @@ +#ifndef RESOURCECONTROLSERVICE_H +#define RESOURCECONTROLSERVICE_H + +#include + +class ResourceControlService : public QObject { + Q_OBJECT +public: + explicit ResourceControlService(QObject* parent = nullptr); + QVariantMap Register(const QVariantMap &send); + QVariantMap acquire(const QVariantMap &send); + QVariantMap advice(const QVariantMap &send); + QVariantMap audio(const QVariantMap &send); + QVariantMap grant(const QVariantMap &send); + QVariantMap release(const QVariantMap &send); + QVariantMap unregister(const QVariantMap &send); + QVariantMap update(const QVariantMap &send); + QVariantMap video(const QVariantMap &send); +}; + +#endif // RESOURCECONTROLSERVICE_H