2010-11-21 16:13:26 +01:00
|
|
|
/* This file is part of Clementine.
|
2014-11-02 19:36:21 +01:00
|
|
|
Copyright 2010-2011, Paweł Bara <keirangtp@gmail.com>
|
|
|
|
Copyright 2010-2012, David Sansome <me@davidsansome.com>
|
|
|
|
Copyright 2011-2012, 2014, John Maguire <john.maguire@gmail.com>
|
|
|
|
Copyright 2013, Aggelos Biboudis <biboudis@gmail.com>
|
|
|
|
Copyright 2014, Krzysztof Sobiecki <sobkas@gmail.com>
|
2010-11-21 16:13:26 +01:00
|
|
|
|
|
|
|
Clementine is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Clementine is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2014-11-01 19:26:05 +01:00
|
|
|
#ifndef CORE_MPRIS2_H_
|
|
|
|
#define CORE_MPRIS2_H_
|
2010-11-21 16:13:26 +01:00
|
|
|
|
|
|
|
#include "playlist/playlistitem.h"
|
|
|
|
|
|
|
|
#include <QMetaObject>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QtDBus>
|
|
|
|
|
2012-02-12 14:41:50 +01:00
|
|
|
class Application;
|
2010-11-21 16:13:26 +01:00
|
|
|
class MainWindow;
|
2012-10-11 15:38:51 +02:00
|
|
|
class Playlist;
|
2010-11-21 16:13:26 +01:00
|
|
|
|
|
|
|
typedef QList<QVariantMap> TrackMetadata;
|
|
|
|
typedef QList<QDBusObjectPath> TrackIds;
|
|
|
|
Q_DECLARE_METATYPE(TrackMetadata)
|
|
|
|
|
2012-10-11 15:38:51 +02:00
|
|
|
struct MprisPlaylist {
|
|
|
|
QDBusObjectPath id;
|
|
|
|
QString name;
|
|
|
|
QString icon; // Uri
|
|
|
|
};
|
|
|
|
typedef QList<MprisPlaylist> MprisPlaylistList;
|
|
|
|
Q_DECLARE_METATYPE(MprisPlaylist);
|
|
|
|
Q_DECLARE_METATYPE(MprisPlaylistList);
|
|
|
|
|
|
|
|
struct MaybePlaylist {
|
|
|
|
bool valid;
|
|
|
|
MprisPlaylist playlist;
|
|
|
|
};
|
|
|
|
Q_DECLARE_METATYPE(MaybePlaylist);
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
QDBusArgument& operator<<(QDBusArgument& arg, const MprisPlaylist& playlist);
|
|
|
|
const QDBusArgument& operator>>(const QDBusArgument& arg,
|
|
|
|
MprisPlaylist& playlist);
|
2012-10-11 15:38:51 +02:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
QDBusArgument& operator<<(QDBusArgument& arg, const MaybePlaylist& playlist);
|
|
|
|
const QDBusArgument& operator>>(const QDBusArgument& arg,
|
|
|
|
MaybePlaylist& playlist);
|
2012-10-11 15:38:51 +02:00
|
|
|
|
2010-12-04 23:27:58 +01:00
|
|
|
namespace mpris {
|
|
|
|
|
2010-12-05 12:39:06 +01:00
|
|
|
class Mpris1;
|
2010-12-04 23:27:58 +01:00
|
|
|
|
|
|
|
class Mpris2 : public QObject {
|
2010-11-21 16:13:26 +01:00
|
|
|
Q_OBJECT
|
|
|
|
|
2012-10-11 15:38:51 +02:00
|
|
|
public:
|
2014-02-07 16:34:20 +01:00
|
|
|
// org.mpris.MediaPlayer2 MPRIS 2.0 Root interface
|
|
|
|
Q_PROPERTY(bool CanQuit READ CanQuit)
|
|
|
|
Q_PROPERTY(bool CanRaise READ CanRaise)
|
|
|
|
Q_PROPERTY(bool HasTrackList READ HasTrackList)
|
|
|
|
Q_PROPERTY(QString Identity READ Identity)
|
|
|
|
Q_PROPERTY(QString DesktopEntry READ DesktopEntry)
|
|
|
|
Q_PROPERTY(QStringList SupportedUriSchemes READ SupportedUriSchemes)
|
|
|
|
Q_PROPERTY(QStringList SupportedMimeTypes READ SupportedMimeTypes)
|
|
|
|
|
|
|
|
// org.mpris.MediaPlayer2 MPRIS 2.2 Root interface
|
|
|
|
Q_PROPERTY(bool CanSetFullscreen READ CanSetFullscreen)
|
|
|
|
Q_PROPERTY(bool Fullscreen READ Fullscreen WRITE SetFullscreen)
|
|
|
|
|
|
|
|
// org.mpris.MediaPlayer2.Player MPRIS 2.0 Player interface
|
|
|
|
Q_PROPERTY(QString PlaybackStatus READ PlaybackStatus)
|
|
|
|
Q_PROPERTY(QString LoopStatus READ LoopStatus WRITE SetLoopStatus)
|
|
|
|
Q_PROPERTY(double Rate READ Rate WRITE SetRate)
|
|
|
|
Q_PROPERTY(bool Shuffle READ Shuffle WRITE SetShuffle)
|
|
|
|
Q_PROPERTY(QVariantMap Metadata READ Metadata)
|
|
|
|
Q_PROPERTY(double Volume READ Volume WRITE SetVolume)
|
|
|
|
Q_PROPERTY(qlonglong Position READ Position)
|
|
|
|
Q_PROPERTY(double MinimumRate READ MinimumRate)
|
|
|
|
Q_PROPERTY(double MaximumRate READ MaximumRate)
|
|
|
|
Q_PROPERTY(bool CanGoNext READ CanGoNext)
|
|
|
|
Q_PROPERTY(bool CanGoPrevious READ CanGoPrevious)
|
|
|
|
Q_PROPERTY(bool CanPlay READ CanPlay)
|
|
|
|
Q_PROPERTY(bool CanPause READ CanPause)
|
|
|
|
Q_PROPERTY(bool CanSeek READ CanSeek)
|
|
|
|
Q_PROPERTY(bool CanControl READ CanControl)
|
|
|
|
|
|
|
|
// org.mpris.MediaPlayer2.TrackList MPRIS 2.0 Player interface
|
|
|
|
Q_PROPERTY(TrackIds Tracks READ Tracks)
|
|
|
|
Q_PROPERTY(bool CanEditTracks READ CanEditTracks)
|
|
|
|
|
|
|
|
// org.mpris.MediaPlayer2.Playlists MPRIS 2.1 Playlists interface
|
|
|
|
Q_PROPERTY(quint32 PlaylistCount READ PlaylistCount)
|
|
|
|
Q_PROPERTY(QStringList Orderings READ Orderings)
|
|
|
|
Q_PROPERTY(MaybePlaylist ActivePlaylist READ ActivePlaylist)
|
2011-01-08 16:31:14 +01:00
|
|
|
|
2014-02-10 16:03:54 +01:00
|
|
|
Mpris2(Application* app, Mpris1* mpris1, QObject* parent = nullptr);
|
2011-01-08 16:31:14 +01:00
|
|
|
|
2010-11-21 16:13:26 +01:00
|
|
|
// Root Properties
|
|
|
|
bool CanQuit() const;
|
|
|
|
bool CanRaise() const;
|
|
|
|
bool HasTrackList() const;
|
|
|
|
QString Identity() const;
|
|
|
|
QString DesktopEntry() const;
|
|
|
|
QStringList SupportedUriSchemes() const;
|
|
|
|
QStringList SupportedMimeTypes() const;
|
|
|
|
|
2012-10-11 13:45:42 +02:00
|
|
|
// Root Properties added in MPRIS 2.2
|
|
|
|
bool CanSetFullscreen() const { return false; }
|
|
|
|
bool Fullscreen() const { return false; }
|
|
|
|
void SetFullscreen(bool) {}
|
|
|
|
|
2010-11-21 16:13:26 +01:00
|
|
|
// Methods
|
|
|
|
void Raise();
|
|
|
|
void Quit();
|
|
|
|
|
|
|
|
// Player Properties
|
|
|
|
QString PlaybackStatus() const;
|
|
|
|
QString LoopStatus() const;
|
|
|
|
void SetLoopStatus(const QString& value);
|
|
|
|
double Rate() const;
|
|
|
|
void SetRate(double value);
|
|
|
|
bool Shuffle() const;
|
|
|
|
void SetShuffle(bool value);
|
|
|
|
QVariantMap Metadata() const;
|
|
|
|
double Volume() const;
|
|
|
|
void SetVolume(double value);
|
|
|
|
qlonglong Position() const;
|
|
|
|
double MaximumRate() const;
|
|
|
|
double MinimumRate() const;
|
|
|
|
bool CanGoNext() const;
|
|
|
|
bool CanGoPrevious() const;
|
|
|
|
bool CanPlay() const;
|
|
|
|
bool CanPause() const;
|
|
|
|
bool CanSeek() const;
|
|
|
|
bool CanControl() const;
|
|
|
|
|
|
|
|
// Methods
|
|
|
|
void Next();
|
|
|
|
void Previous();
|
|
|
|
void Pause();
|
|
|
|
void PlayPause();
|
|
|
|
void Stop();
|
|
|
|
void Play();
|
|
|
|
void Seek(qlonglong offset);
|
|
|
|
void SetPosition(const QDBusObjectPath& trackId, qlonglong offset);
|
|
|
|
void OpenUri(const QString& uri);
|
|
|
|
|
|
|
|
// TrackList Properties
|
|
|
|
TrackIds Tracks() const;
|
|
|
|
bool CanEditTracks() const;
|
|
|
|
|
|
|
|
// Methods
|
|
|
|
TrackMetadata GetTracksMetadata(const TrackIds& tracks) const;
|
2014-02-07 16:34:20 +01:00
|
|
|
void AddTrack(const QString& uri, const QDBusObjectPath& afterTrack,
|
|
|
|
bool setAsCurrent);
|
2010-11-21 16:13:26 +01:00
|
|
|
void RemoveTrack(const QDBusObjectPath& trackId);
|
|
|
|
void GoTo(const QDBusObjectPath& trackId);
|
|
|
|
|
2012-10-11 15:38:51 +02:00
|
|
|
// Playlist Properties
|
|
|
|
quint32 PlaylistCount() const;
|
|
|
|
QStringList Orderings() const;
|
|
|
|
MaybePlaylist ActivePlaylist() const;
|
|
|
|
|
|
|
|
// Methods
|
|
|
|
void ActivatePlaylist(const QDBusObjectPath& playlist_id);
|
2014-02-07 16:34:20 +01:00
|
|
|
QList<MprisPlaylist> GetPlaylists(quint32 index, quint32 max_count,
|
|
|
|
const QString& order, bool reverse_order);
|
2012-10-11 15:38:51 +02:00
|
|
|
|
2014-11-01 19:26:05 +01:00
|
|
|
signals:
|
2010-11-21 16:13:26 +01:00
|
|
|
// Player
|
|
|
|
void Seeked(qlonglong position);
|
|
|
|
|
|
|
|
// TrackList
|
|
|
|
void TrackListReplaced(const TrackIds& Tracks, QDBusObjectPath CurrentTrack);
|
|
|
|
void TrackAdded(const TrackMetadata& Metadata, QDBusObjectPath AfterTrack);
|
|
|
|
void TrackRemoved(const QDBusObjectPath& trackId);
|
2014-02-07 16:34:20 +01:00
|
|
|
void TrackMetadataChanged(const QDBusObjectPath& trackId,
|
|
|
|
const TrackMetadata& metadata);
|
2010-11-21 16:13:26 +01:00
|
|
|
|
2011-01-04 12:33:22 +01:00
|
|
|
void RaiseMainWindow();
|
|
|
|
|
2012-10-11 15:38:51 +02:00
|
|
|
// Playlist
|
|
|
|
void PlaylistChanged(const MprisPlaylist& playlist);
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private slots:
|
2010-12-04 23:27:58 +01:00
|
|
|
void ArtLoaded(const Song& song, const QString& art_uri);
|
2010-12-13 00:20:41 +01:00
|
|
|
void EngineStateChanged(Engine::State newState);
|
2010-12-04 23:27:58 +01:00
|
|
|
void VolumeChanged();
|
|
|
|
|
2010-12-13 00:20:41 +01:00
|
|
|
void PlaylistManagerInitialized();
|
|
|
|
void CurrentSongChanged(const Song& song);
|
|
|
|
void ShuffleModeChanged();
|
|
|
|
void RepeatModeChanged();
|
2012-10-11 15:38:51 +02:00
|
|
|
void PlaylistChanged(Playlist* playlist);
|
2013-11-19 00:13:45 +01:00
|
|
|
void PlaylistCollectionChanged(Playlist* playlist);
|
2010-12-13 00:20:41 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private:
|
2010-12-04 23:27:58 +01:00
|
|
|
void EmitNotification(const QString& name);
|
|
|
|
void EmitNotification(const QString& name, const QVariant& val);
|
2014-02-07 16:34:20 +01:00
|
|
|
void EmitNotification(const QString& name, const QVariant& val,
|
|
|
|
const QString& mprisEntity);
|
2010-11-21 16:13:26 +01:00
|
|
|
|
2010-12-13 00:20:41 +01:00
|
|
|
QString PlaybackStatus(Engine::State state) const;
|
|
|
|
|
2010-12-05 12:39:06 +01:00
|
|
|
QString current_track_id() const;
|
|
|
|
|
2011-01-06 20:29:54 +01:00
|
|
|
QString DesktopEntryAbsolutePath() const;
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private:
|
2010-11-21 16:13:26 +01:00
|
|
|
static const char* kMprisObjectPath;
|
|
|
|
static const char* kServiceName;
|
|
|
|
static const char* kFreedesktopPath;
|
|
|
|
|
|
|
|
QVariantMap last_metadata_;
|
|
|
|
|
2012-02-12 14:41:50 +01:00
|
|
|
Application* app_;
|
2010-12-05 12:39:06 +01:00
|
|
|
Mpris1* mpris1_;
|
2010-11-21 16:13:26 +01:00
|
|
|
};
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
} // namespace mpris
|
2010-12-04 23:27:58 +01:00
|
|
|
|
2014-11-01 19:26:05 +01:00
|
|
|
#endif // CORE_MPRIS2_H_
|