Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Move audio control from OHM to glacier-home #229

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -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
Expand Down
13 changes: 13 additions & 0 deletions data/glacier-home.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<policy group="audio">
<allow own="org.nemomobile.Route.Manager"/>
</policy>
<policy group="whell">
<allow own="org.maemo.resource.manager"/>
</policy>
<policy context="default">
<allow send_destination="org.nemomobile.Route.Manager" send_interface="org.nemomobile.Route.Manager"/>
<allow send_destination="org.maemo.resource.manager" send_interface="org.maemo.resource.manager"/>
</policy>
</busconfig>
31 changes: 22 additions & 9 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand Down
22 changes: 22 additions & 0 deletions src/audiocontrol/audioroutemanager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "audioroutemanager.h"
#include "routemanageradaptor.h"

#include <QDBusConnection>
#include <QDBusError>

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());
}
}
16 changes: 16 additions & 0 deletions src/audiocontrol/audioroutemanager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef AUDIOROUTEMANAGER_H
#define AUDIOROUTEMANAGER_H

#include "audiorouteservice.h"
#include <QObject>

class AudioRouteManager : public QObject {
Q_OBJECT
public:
explicit AudioRouteManager(QObject* parent = nullptr);

private:
AudioRouteService* m_audioRouteSerice;
};

#endif // AUDIOROUTEMANAGER_H
91 changes: 91 additions & 0 deletions src/audiocontrol/audiorouteservice.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#include "audiorouteservice.h"
#include <QDebug>
#include <QVariantMap>

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();
}
27 changes: 27 additions & 0 deletions src/audiocontrol/audiorouteservice.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef AUDIOROUTESERVICE_H
#define AUDIOROUTESERVICE_H

#include <QObject>

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
64 changes: 64 additions & 0 deletions src/audiocontrol/org.nemomobile.Route.Manager.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.nemomobile.Route.Manager">
<method name="InterfaceVersion">
<arg name="version" type="u" direction="out"/>
</method>
<!-- since InterfaceVersion 1 -->
<method name="GetAll">
<annotation name="org.qtproject.QtDBus.QtTypeName.Out4" value="QVariantMap"/>
<arg name="output_device" type="s" direction="out"/>
<arg name="output_device_type" type="u" direction="out"/>
<arg name="input_device" type="s" direction="out"/>
<arg name="input_device_type" type="u" direction="out"/>
<arg name="features" type="a(suu)" direction="out"/>
</method>
<method name="Enable">
<arg name="feature" type="s" direction="in"/>
</method>
<method name="Disable">
<arg name="feature" type="s" direction="in"/>
</method>
<signal name="AudioRouteChanged">
<arg name="device" type="s"/>
<arg name="device_type" type="u"/>
</signal>
<signal name="AudioFeatureChanged">
<arg name="name" type="s"/>
<arg name="allowed" type="u"/>
<arg name="enabled" type="u"/>
</signal>

<!-- since InterfaceVersion 2 -->
<method name="Features">
<arg name="features" type="as" direction="out"/>
</method>
<method name="FeaturesAllowed">
<arg name="features_allowed" type="as" direction="out"/>
</method>
<method name="FeaturesEnabled">
<arg name="features_enabled" type="as" direction="out"/>
</method>
<method name="Routes">
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
<arg name="routes" type="a(su)" direction="out"/>
</method>
<method name="ActiveRoutes">
<arg name="output_device" type="s" direction="out"/>
<arg name="output_device_type" type="u" direction="out"/>
<arg name="input_device" type="s" direction="out"/>
<arg name="input_device_type" type="u" direction="out"/>
</method>

<!-- since InterfaceVersion 3 -->
<method name="RoutesFiltered">
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
<arg name="filter" type="u" direction="in"/>
<arg name="routes" type="a(su)" direction="out"/>
</method>

<method name="Prefer">
<arg name="device" type="sub" direction="in"/>
</method>
</interface>
</node>
4 changes: 4 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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();

Expand Down Expand Up @@ -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");
Expand Down
59 changes: 59 additions & 0 deletions src/resourcecontrol/org.maemo.resource.manager.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.maemo.resource.manager">
<method name="Register">
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QVariantMap"/>
<arg name="send" type="a(iuuuuuusu)" direction="in"/>
<arg name="error" type="a(iuuis)" direction="out"/>
</method>
<method name="unregister">
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QVariantMap"/>
<arg name="send" type="a(iuu)" direction="in"/>
<arg name="error" type="a(iuuis)" direction="out"/>
</method>
<method name="update">
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QVariantMap"/>
<arg name="send" type="a(iuuuuuusu)" direction="in"/>
<arg name="error" type="a(iuuis)" direction="out"/>
</method>
<method name="acquire">
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QVariantMap"/>
<arg name="send" type="a(iuu)" direction="in"/>
<arg name="error" type="a(iuuis)" direction="out"/>
</method>
<method name="release">
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QVariantMap"/>
<arg name="send" type="a(iuu)" direction="in"/>
<arg name="error" type="a(iuuis)" direction="out"/>
</method>
<method name="grant">
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QVariantMap"/>
<arg name="send" type="a(iuuu)" direction="in"/>
<arg name="error" type="a(iuuis)" direction="out"/>
</method>
<method name="advice">
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QVariantMap"/>
<arg name="send" type="a(iuuu)" direction="in"/>
<arg name="error" type="a(iuuis)" direction="out"/>
</method>
<method name="audio">
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QVariantMap"/>
<arg name="send" type="a(iuususis)" direction="in"/>
<arg name="error" type="a(iuuis)" direction="out"/>
</method>
<method name="video">
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QVariantMap"/>
<arg name="send" type="a(iuuu)" direction="in"/>
<arg name="error" type="a(iuuis)" direction="out"/>
</method>
</interface>
</node>
Loading
Loading