From 0846dd9d9b8c73a881b23dd4e62045eb41b50c91 Mon Sep 17 00:00:00 2001 From: Bart De Vries Date: Mon, 3 May 2021 10:43:24 +0200 Subject: [PATCH] Disable DBus as dependency for Android --- CMakeLists.txt | 2 +- src/CMakeLists.txt | 22 ++++++++++++++-------- src/mpris2/mpris2.cpp | 12 ++++++++++++ src/mpris2/mpris2.h | 5 +++++ src/powermanagementinterface.cpp | 2 ++ 5 files changed, 34 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 21227e8a..5e072a81 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,7 +30,7 @@ find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Core Quick Test find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS CoreAddons Syndication Config I18n) if (ANDROID) - find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS Svg DBus) + find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS Svg) find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Kirigami2) find_package(OpenSSL REQUIRED) else() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 17c7a9a8..cf4991be 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,5 @@ -set(SRCS_alligator +set(SRCS_base main.cpp feedsmodel.cpp entriesmodel.cpp @@ -19,21 +19,27 @@ set(SRCS_alligator errorlogmodel.cpp error.h mpris2/mpris2.cpp - mpris2/mediaplayer2.cpp - mpris2/mediaplayer2player.cpp resources.qrc ) +if(ANDROID) + set (SRCS ${SRCS_base}) +else() + set (SRCS ${SRCS_base} + mpris2/mediaplayer2.cpp + mpris2/mediaplayer2player.cpp + ) -qt5_add_dbus_interface(SRCS_alligator dbus-interfaces/org.freedesktop.PowerManagement.Inhibit.xml inhibitinterface) -qt5_add_dbus_interface(SRCS_alligator dbus-interfaces/org.gnome.SessionManager.xml gnomesessioninterface) + qt5_add_dbus_interface(SRCS dbus-interfaces/org.freedesktop.PowerManagement.Inhibit.xml inhibitinterface) + qt5_add_dbus_interface(SRCS dbus-interfaces/org.gnome.SessionManager.xml gnomesessioninterface) +endif() -add_executable(alligator ${SRCS_alligator}) +add_executable(alligator ${SRCS}) kconfig_add_kcfg_files(alligator settingsmanager.kcfgc GENERATE_MOC) target_include_directories(alligator PRIVATE ${CMAKE_BINARY_DIR}) -target_link_libraries(alligator PRIVATE Qt5::Core Qt5::Qml Qt5::Quick Qt5::QuickControls2 Qt5::Sql Qt5::Multimedia Qt5::DBus KF5::Syndication KF5::CoreAddons KF5::ConfigGui KF5::I18n) +target_link_libraries(alligator PRIVATE Qt5::Core Qt5::Qml Qt5::Quick Qt5::QuickControls2 Qt5::Sql Qt5::Multimedia KF5::Syndication KF5::CoreAddons KF5::ConfigGui KF5::I18n) if(ANDROID) target_link_libraries(alligator PRIVATE @@ -72,7 +78,7 @@ if(ANDROID) overflow-menu ) else() - target_link_libraries(alligator PRIVATE Qt5::Widgets) + target_link_libraries(alligator PRIVATE Qt5::Widgets Qt5::DBus) endif() install(TARGETS alligator ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}) diff --git a/src/mpris2/mpris2.cpp b/src/mpris2/mpris2.cpp index f71321cf..c6e02a06 100644 --- a/src/mpris2/mpris2.cpp +++ b/src/mpris2/mpris2.cpp @@ -8,10 +8,14 @@ #include "mpris2.h" #include "audiomanager.h" +#if !defined Q_OS_ANDROID #include "mediaplayer2.h" #include "mediaplayer2player.h" +#endif +#if !defined Q_OS_ANDROID #include +#endif #if defined Q_OS_WIN #include @@ -26,6 +30,7 @@ Mpris2::Mpris2(QObject *parent) void Mpris2::initDBusService() { +#if !defined Q_OS_ANDROID QString mspris2Name(QStringLiteral("org.mpris.MediaPlayer2.") + m_playerName); bool success = QDBusConnection::sessionBus().registerService(mspris2Name); @@ -49,6 +54,7 @@ void Mpris2::initDBusService() connect(m_mp2.get(), &MediaPlayer2::raisePlayer, this, &Mpris2::raisePlayer); } +#endif } Mpris2::~Mpris2() = default; @@ -76,11 +82,13 @@ void Mpris2::setPlayerName(const QString &playerName) m_playerName = playerName; +#if !defined Q_OS_ANDROID if (m_audioPlayer && !m_playerName.isEmpty()) { if (!m_mp2) { initDBusService(); } } +#endif emit playerNameChanged(); } @@ -92,18 +100,22 @@ void Mpris2::setAudioPlayer(AudioManager *audioPlayer) m_audioPlayer = audioPlayer; +#if !defined Q_OS_ANDROID if (m_audioPlayer && !m_playerName.isEmpty()) { if (!m_mp2) { initDBusService(); } } +#endif emit audioPlayerChanged(); } void Mpris2::setShowProgressOnTaskBar(bool value) { +#if !defined Q_OS_ANDROID m_mp2p->setShowProgressOnTaskBar(value); +#endif mShowProgressOnTaskBar = value; Q_EMIT showProgressOnTaskBarChanged(); } diff --git a/src/mpris2/mpris2.h b/src/mpris2/mpris2.h index 4d149f10..604f0589 100644 --- a/src/mpris2/mpris2.h +++ b/src/mpris2/mpris2.h @@ -12,8 +12,10 @@ #include #include +#if !defined Q_OS_ANDROID class MediaPlayer2Player; class MediaPlayer2; +#endif class AudioManager; class Mpris2 : public QObject @@ -54,8 +56,11 @@ Q_SIGNALS: private: void initDBusService(); +#if !defined Q_OS_ANDROID std::unique_ptr m_mp2; std::unique_ptr m_mp2p; +#endif + QString m_playerName; AudioManager *m_audioPlayer = nullptr; bool mShowProgressOnTaskBar = true; diff --git a/src/powermanagementinterface.cpp b/src/powermanagementinterface.cpp index 1423ea74..6ba698e8 100644 --- a/src/powermanagementinterface.cpp +++ b/src/powermanagementinterface.cpp @@ -24,8 +24,10 @@ #include #include +#if !defined Q_OS_ANDROID && !defined Q_OS_WIN #include "gnomesessioninterface.h" #include "inhibitinterface.h" +#endif class PowerManagementInterfacePrivate {