Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
neochapay committed Mar 13, 2024
1 parent 9a58ebd commit a27c189
Show file tree
Hide file tree
Showing 14 changed files with 439 additions and 10 deletions.
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 @@ -45,6 +46,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>
32 changes: 22 additions & 10 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ 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
controlcenterbuttonsmodel.cpp
controlcenterbuttonsmodel.h
fileutils.cpp
Expand All @@ -15,15 +23,17 @@ set(SRC
${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 @@ -35,7 +45,8 @@ if(USE_GEOCLUE2)
geoagent.h)
endif()

add_executable(lipstick ${SRC} ${GEOCLUE_SRC})
add_executable(lipstick ${SRC} ${GEOCLUE_SRC}
resourcecontrol/resourcecontrolmanager.h resourcecontrol/resourcecontrolmanager.cpp)

target_link_libraries(lipstick PUBLIC
Qt6::Gui
Expand All @@ -45,7 +56,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 <QObject>
#include "audiorouteservice.h"

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 <QVariantMap>
#include <QDebug>

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 @@ -45,6 +45,8 @@
#include "mceconnect.h"
#include "logging.h"

#include "audiocontrol/audioroutemanager.h"

int main(int argc, char** argv)
{
HomeApplication app(argc, argv, QString());
Expand All @@ -64,6 +66,7 @@ int main(int argc, char** argv)
QmlPath::append("/usr/share/lipstick-glacier-home-qt6/qml");
QGuiApplication::setFont(QFont("Open Sans"));

AudioRouteManager* audioRouteManager = new AudioRouteManager();
FileUtils* fileUtils = new FileUtils();
MceConnect* mceConnect = new MceConnect();

Expand Down Expand Up @@ -92,6 +95,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
Loading

0 comments on commit a27c189

Please sign in to comment.