Remove all dbus linking on windows

This commit is contained in:
Bart De Vries 2024-02-21 13:43:15 +01:00
parent 581e4a6bb2
commit 72043c0dd5
3 changed files with 24 additions and 22 deletions

View File

@ -9,7 +9,10 @@ find_package(Qt6 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Core Qml Multim
find_package(KF6 ${KF_MIN_VERSION} REQUIRED COMPONENTS CoreAddons I18n)
if (NOT ANDROID)
find_package(Qt6 ${QT_MIN_VERSION} REQUIRED COMPONENTS DBus Widgets)
if (NOT WIN32)
find_package(Qt6 ${QT_MIN_VERSION} REQUIRED COMPONENTS DBus)
endif()
find_package(Qt6 ${QT_MIN_VERSION} REQUIRED COMPONENTS Widgets)
endif()
find_package(LIBVLC)
@ -79,6 +82,7 @@ ecm_qt_declare_logging_category(KMediaSession
if(ANDROID)
target_sources(KMediaSession PRIVATE androidlogging.h)
else()
if (NOT WIN32)
set(KMediaSession_dbus_srcs "")
qt_add_dbus_interface(KMediaSession_dbus_srcs dbus-interfaces/org.freedesktop.PowerManagement.Inhibit.xml inhibitinterface)
qt_add_dbus_interface(KMediaSession_dbus_srcs dbus-interfaces/org.gnome.SessionManager.xml gnomesessioninterface)
@ -87,6 +91,7 @@ else()
mpris2/mediaplayer2player.cpp
${KMediaSession_dbus_srcs}
)
endif()
endif()
if (LIBVLC_FOUND)
@ -148,7 +153,7 @@ if (GSTREAMER_FOUND)
target_link_libraries(KMediaSession PRIVATE PkgConfig::GSTREAMER)
endif()
if (ANDROID)
if (ANDROID OR WIN32)
else()
target_link_libraries(KMediaSession PRIVATE Qt::DBus)
endif()

View File

@ -11,7 +11,7 @@
#include "mpris2logging.h"
#include <QDebug>
#if !defined Q_OS_ANDROID
#if !defined Q_OS_ANDROID && !defined Q_OS_WIN
#include <QDBusConnection>
#endif
@ -22,7 +22,7 @@
#endif
#include "kmediasession.h"
#if !defined Q_OS_ANDROID
#if !defined Q_OS_ANDROID && !defined Q_OS_WIN
#include "mediaplayer2.h"
#include "mediaplayer2player.h"
#endif
@ -33,7 +33,7 @@ Mpris2::Mpris2(QObject *parent)
{
qCDebug(Mpris2Log) << "Mpris2::Mpris2()";
#if !defined Q_OS_ANDROID
#if !defined Q_OS_ANDROID && !defined Q_OS_WIN
connect(m_audioPlayer, &KMediaSession::playerNameChanged, this, [this]() {
bool success = true;
if (m_mp2) {
@ -52,7 +52,7 @@ Mpris2::Mpris2(QObject *parent)
void Mpris2::initDBusService(const QString &playerName)
{
qCDebug(Mpris2Log) << "Mpris2::initDBusService(" << playerName << ")";
#if !defined Q_OS_ANDROID
#if !defined Q_OS_ANDROID && !defined Q_OS_WIN
QString tryPlayerName = playerName;
QString mpris2Name(QStringLiteral("org.mpris.MediaPlayer2.") + tryPlayerName);
@ -63,11 +63,8 @@ void Mpris2::initDBusService(const QString &playerName)
// or the name is already taken. In that event the MPRIS2 spec wants the
// following:
if (!success) {
#if defined Q_OS_WIN
tryPlayerName = tryPlayerName + QLatin1String(".instance") + QString::number(GetCurrentProcessId());
#else
tryPlayerName = tryPlayerName + QLatin1String(".instance") + QString::number(getpid());
#endif
success = QDBusConnection::sessionBus().registerService(QStringLiteral("org.mpris.MediaPlayer2.") + tryPlayerName);
}
@ -86,7 +83,7 @@ void Mpris2::initDBusService(const QString &playerName)
bool Mpris2::unregisterDBusService(const QString &playerName)
{
bool success = true;
#if !defined Q_OS_ANDROID
#if !defined Q_OS_ANDROID && !defined Q_OS_WIN
QString oldMpris2Name(QStringLiteral("org.mpris.MediaPlayer2.") + playerName);
success = QDBusConnection::sessionBus().unregisterService(oldMpris2Name);
@ -108,7 +105,7 @@ bool Mpris2::showProgressOnTaskBar() const
void Mpris2::setShowProgressOnTaskBar(bool value)
{
qCDebug(Mpris2Log) << "Mpris2::setShowProgressOnTaskBar" << value << ")";
#if !defined Q_OS_ANDROID
#if !defined Q_OS_ANDROID && !defined Q_OS_WIN
m_mp2p->setShowProgressOnTaskBar(value);
#endif
m_ShowProgressOnTaskBar = value;

View File

@ -14,7 +14,7 @@
#include <QObject>
#include <QSharedPointer>
#if !defined Q_OS_ANDROID
#if !defined Q_OS_ANDROID && !defined Q_OS_WIN
class MediaPlayer2Player;
class MediaPlayer2;
#endif
@ -42,7 +42,7 @@ private:
void initDBusService(const QString &playerName);
bool unregisterDBusService(const QString &playerName);
#if !defined Q_OS_ANDROID
#if !defined Q_OS_ANDROID && !defined Q_OS_WIN
std::unique_ptr<MediaPlayer2> m_mp2;
std::unique_ptr<MediaPlayer2Player> m_mp2p;
#endif