File indexing completed on 2025-01-19 04:28:11
0001 /** 0002 * SPDX-FileCopyrightText: 2014 Sujith Haridasan <sujith.haridasan@kdemail.net> 0003 * SPDX-FileCopyrightText: 2014 Ashish Madeti <ashishmadeti@gmail.com> 0004 * SPDX-FileCopyrightText: 2016 Matthieu Gallien <matthieu_gallien@yahoo.fr> 0005 * SPDX-FileCopyrightText: 2022-2023 Bart De Vries <bart@mogwai.be> 0006 * 0007 * SPDX-License-Identifier: GPL-3.0-or-later 0008 */ 0009 0010 #include "mediaplayer2.h" 0011 #include "mpris2logging.h" 0012 0013 #include <QCoreApplication> 0014 #include <QDebug> 0015 0016 #include <KAboutData> 0017 0018 MediaPlayer2::MediaPlayer2(KMediaSession *audioPlayer, QObject *parent) 0019 : QDBusAbstractAdaptor(parent) 0020 , m_audioPlayer(audioPlayer) 0021 { 0022 qCDebug(Mpris2Log) << "MediaPlayer2::MediaPlayer2()"; 0023 0024 connect(this, &MediaPlayer2::raisePlayer, audioPlayer, &KMediaSession::raiseWindowRequested); 0025 connect(this, &MediaPlayer2::quitPlayer, audioPlayer, &KMediaSession::quitRequested); 0026 } 0027 0028 MediaPlayer2::~MediaPlayer2() 0029 { 0030 qCDebug(Mpris2Log) << "MediaPlayer2::~MediaPlayer2()"; 0031 } 0032 0033 bool MediaPlayer2::CanQuit() const 0034 { 0035 qCDebug(Mpris2Log) << "MediaPlayer2::CanQuit()"; 0036 return true; 0037 } 0038 0039 bool MediaPlayer2::CanRaise() const 0040 { 0041 qCDebug(Mpris2Log) << "MediaPlayer2::CanRaise()"; 0042 return true; 0043 } 0044 bool MediaPlayer2::HasTrackList() const 0045 { 0046 qCDebug(Mpris2Log) << "MediaPlayer2::HasTrackList()"; 0047 return false; 0048 } 0049 0050 void MediaPlayer2::Quit() 0051 { 0052 qCDebug(Mpris2Log) << "MediaPlayer2::Quit()"; 0053 Q_EMIT quitPlayer(); 0054 } 0055 0056 void MediaPlayer2::Raise() 0057 { 0058 qCDebug(Mpris2Log) << "MediaPlayer2::Raise()"; 0059 Q_EMIT raisePlayer(); 0060 } 0061 0062 QString MediaPlayer2::Identity() const 0063 { 0064 qCDebug(Mpris2Log) << "MediaPlayer2::Identity()"; 0065 if (m_audioPlayer) { 0066 return m_audioPlayer->playerName(); 0067 } 0068 return QStringLiteral("kmediasession"); 0069 } 0070 0071 QString MediaPlayer2::DesktopEntry() const 0072 { 0073 qCDebug(Mpris2Log) << "MediaPlayer2::DesktopEntry()"; 0074 if (m_audioPlayer) { 0075 return m_audioPlayer->desktopEntryName(); 0076 } 0077 return QLatin1String(""); 0078 } 0079 0080 QStringList MediaPlayer2::SupportedUriSchemes() const 0081 { 0082 qCDebug(Mpris2Log) << "MediaPlayer2::SupportedUriSchemes()"; 0083 return QStringList() << QStringLiteral("file"); 0084 } 0085 0086 QStringList MediaPlayer2::SupportedMimeTypes() const 0087 { 0088 qCDebug(Mpris2Log) << "MediaPlayer2::SupportedMimeTypes()"; 0089 return QStringList(); 0090 }