/src/libtomahawk/infosystem/infoplugins/unix/mprisplugin.h
C++ Header | 179 lines | 108 code | 46 blank | 25 comment | 0 complexity | 8cb626ce6e82808567fd97873ad0d739 MD5 | raw file
1/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> === 2 * 3 * Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org> 4 * 5 * Tomahawk is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * Tomahawk is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with Tomahawk. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19#ifndef MPRISPLUGIN_H 20#define MPRISPLUGIN_H 21 22#include "audio/audioengine.h" 23#include "infosystem/infosystem.h" 24 25#include <QObject> 26#include <QVariant> 27#include <QtDBus/QtDBus> 28 29namespace Tomahawk 30{ 31 32namespace InfoSystem 33{ 34 35class MprisPlugin : public InfoPlugin 36{ 37 Q_OBJECT 38 39public: 40 MprisPlugin(); 41 virtual ~MprisPlugin(); 42 43 // MPRIS DBus Methods 44 45 // org.mpris.MediaPlayer2 46 47 Q_PROPERTY( bool CanQuit READ canQuit ) 48 bool canQuit() const; 49 50 Q_PROPERTY( bool CanRaise READ canRaise ) 51 bool canRaise() const; 52 53 Q_PROPERTY( QString DesktopEntry READ desktopEntry ) 54 QString desktopEntry() const; 55 56 Q_PROPERTY( bool HasTrackList READ hasTrackList ) 57 bool hasTrackList() const; 58 59 Q_PROPERTY( QString Identity READ identity ) 60 QString identity() const; 61 62 Q_PROPERTY( QStringList SupportedMimeTypes READ supportedMimeTypes ) 63 QStringList supportedMimeTypes() const; 64 65 Q_PROPERTY( QStringList SupportedUriSchemes READ supportedUriSchemes ) 66 QStringList supportedUriSchemes() const; 67 68 // org.mpris.MediaPlayer2.Player 69 70 Q_PROPERTY( bool CanControl READ canControl ) 71 bool canControl() const; 72 73 Q_PROPERTY( bool CanGoNext READ canGoNext ) 74 bool canGoNext() const; 75 76 Q_PROPERTY( bool CanGoPrevious READ canGoPrevious ) 77 bool canGoPrevious() const; 78 79 Q_PROPERTY( bool CanPause READ canPause ) 80 bool canPause() const; 81 82 Q_PROPERTY( bool CanPlay READ canPlay ) 83 bool canPlay() const; 84 85 Q_PROPERTY( bool CanSeek READ canSeek ) 86 bool canSeek() const; 87 88 Q_PROPERTY( QString LoopStatus READ loopStatus WRITE setLoopStatus ) 89 QString loopStatus() const; 90 void setLoopStatus( const QString &value ); 91 92 Q_PROPERTY( double MaximumRate READ maximumRate ) 93 double maximumRate() const; 94 95 Q_PROPERTY( QVariantMap Metadata READ metadata ) 96 QVariantMap metadata() const; 97 98 Q_PROPERTY( double MinimumRate READ minimumRate ) 99 double minimumRate() const; 100 101 Q_PROPERTY( QString PlaybackStatus READ playbackStatus ) 102 QString playbackStatus() const; 103 104 Q_PROPERTY( qlonglong Position READ position ) 105 qlonglong position() const; 106 107 Q_PROPERTY( double Rate READ rate WRITE setRate ) 108 double rate() const; 109 void setRate( double value ); 110 111 Q_PROPERTY( bool Shuffle READ shuffle WRITE setShuffle ) 112 bool shuffle() const; 113 void setShuffle( bool value ); 114 115 Q_PROPERTY( double Volume READ volume WRITE setVolume ) 116 double volume() const; 117 void setVolume( double value ); 118 119public slots: 120 virtual void notInCacheSlot( const Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData ) 121 { 122 Q_UNUSED( criteria ); 123 Q_UNUSED( requestData ); 124 } 125 126 // org.mpris.MediaPlayer2 127 void Raise(); 128 void Quit(); 129 130 // org.mpris.MediaPlayer2.Player 131 void Next(); 132 void OpenUri( const QString &Uri ); 133 void Pause(); 134 void Play(); 135 void PlayPause(); 136 void Previous(); 137 void Seek( qlonglong Offset ); 138 void SetPosition( const QDBusObjectPath &TrackId, qlonglong Position ); 139 void Stop(); 140 141 142protected slots: 143 void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData ); 144 void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input ); 145 146private slots: 147 void stateChanged( AudioState newState, AudioState oldState ); 148 void onVolumeChanged( int volume ); 149 void onPlaylistChanged( Tomahawk::playlistinterface_ptr ); 150 void onTrackCountChanged( unsigned int tracks ); 151 void onSeeked( qint64 ms ); 152 153 void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output ); 154 void infoSystemFinished( QString target ); 155 156signals: 157 void Seeked( qlonglong Position ); 158 159private: 160 // Get Info 161 162 // Push Info 163 void audioStarted( const QVariant &input ); 164 void audioFinished( const QVariant &input ); 165 void audioStopped(); 166 void audioPaused(); 167 void audioResumed( const QVariant &input ); 168 169 // DBus 170 void notifyPropertyChanged( const QString& interface, const QString& propertyName ); 171 QString m_playbackStatus; 172 QTemporaryFile *m_coverTempFile; 173}; 174 175}; 176 177} 178 179#endif // MPRISPLUGIN_H