/src/libtomahawk/infosystem/infoplugins/unix/mprisplugin.h

http://github.com/tomahawk-player/tomahawk · 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. #ifndef MPRISPLUGIN_H
  19. #define MPRISPLUGIN_H
  20. #include "audio/audioengine.h"
  21. #include "infosystem/infosystem.h"
  22. #include <QObject>
  23. #include <QVariant>
  24. #include <QtDBus/QtDBus>
  25. namespace Tomahawk
  26. {
  27. namespace InfoSystem
  28. {
  29. class MprisPlugin : public InfoPlugin
  30. {
  31. Q_OBJECT
  32. public:
  33. MprisPlugin();
  34. virtual ~MprisPlugin();
  35. // MPRIS DBus Methods
  36. // org.mpris.MediaPlayer2
  37. Q_PROPERTY( bool CanQuit READ canQuit )
  38. bool canQuit() const;
  39. Q_PROPERTY( bool CanRaise READ canRaise )
  40. bool canRaise() const;
  41. Q_PROPERTY( QString DesktopEntry READ desktopEntry )
  42. QString desktopEntry() const;
  43. Q_PROPERTY( bool HasTrackList READ hasTrackList )
  44. bool hasTrackList() const;
  45. Q_PROPERTY( QString Identity READ identity )
  46. QString identity() const;
  47. Q_PROPERTY( QStringList SupportedMimeTypes READ supportedMimeTypes )
  48. QStringList supportedMimeTypes() const;
  49. Q_PROPERTY( QStringList SupportedUriSchemes READ supportedUriSchemes )
  50. QStringList supportedUriSchemes() const;
  51. // org.mpris.MediaPlayer2.Player
  52. Q_PROPERTY( bool CanControl READ canControl )
  53. bool canControl() const;
  54. Q_PROPERTY( bool CanGoNext READ canGoNext )
  55. bool canGoNext() const;
  56. Q_PROPERTY( bool CanGoPrevious READ canGoPrevious )
  57. bool canGoPrevious() const;
  58. Q_PROPERTY( bool CanPause READ canPause )
  59. bool canPause() const;
  60. Q_PROPERTY( bool CanPlay READ canPlay )
  61. bool canPlay() const;
  62. Q_PROPERTY( bool CanSeek READ canSeek )
  63. bool canSeek() const;
  64. Q_PROPERTY( QString LoopStatus READ loopStatus WRITE setLoopStatus )
  65. QString loopStatus() const;
  66. void setLoopStatus( const QString &value );
  67. Q_PROPERTY( double MaximumRate READ maximumRate )
  68. double maximumRate() const;
  69. Q_PROPERTY( QVariantMap Metadata READ metadata )
  70. QVariantMap metadata() const;
  71. Q_PROPERTY( double MinimumRate READ minimumRate )
  72. double minimumRate() const;
  73. Q_PROPERTY( QString PlaybackStatus READ playbackStatus )
  74. QString playbackStatus() const;
  75. Q_PROPERTY( qlonglong Position READ position )
  76. qlonglong position() const;
  77. Q_PROPERTY( double Rate READ rate WRITE setRate )
  78. double rate() const;
  79. void setRate( double value );
  80. Q_PROPERTY( bool Shuffle READ shuffle WRITE setShuffle )
  81. bool shuffle() const;
  82. void setShuffle( bool value );
  83. Q_PROPERTY( double Volume READ volume WRITE setVolume )
  84. double volume() const;
  85. void setVolume( double value );
  86. public slots:
  87. virtual void notInCacheSlot( const Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
  88. {
  89. Q_UNUSED( criteria );
  90. Q_UNUSED( requestData );
  91. }
  92. // org.mpris.MediaPlayer2
  93. void Raise();
  94. void Quit();
  95. // org.mpris.MediaPlayer2.Player
  96. void Next();
  97. void OpenUri( const QString &Uri );
  98. void Pause();
  99. void Play();
  100. void PlayPause();
  101. void Previous();
  102. void Seek( qlonglong Offset );
  103. void SetPosition( const QDBusObjectPath &TrackId, qlonglong Position );
  104. void Stop();
  105. protected slots:
  106. void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData );
  107. void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input );
  108. private slots:
  109. void stateChanged( AudioState newState, AudioState oldState );
  110. void onVolumeChanged( int volume );
  111. void onPlaylistChanged( Tomahawk::playlistinterface_ptr );
  112. void onTrackCountChanged( unsigned int tracks );
  113. void onSeeked( qint64 ms );
  114. void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
  115. void infoSystemFinished( QString target );
  116. signals:
  117. void Seeked( qlonglong Position );
  118. private:
  119. // Get Info
  120. // Push Info
  121. void audioStarted( const QVariant &input );
  122. void audioFinished( const QVariant &input );
  123. void audioStopped();
  124. void audioPaused();
  125. void audioResumed( const QVariant &input );
  126. // DBus
  127. void notifyPropertyChanged( const QString& interface, const QString& propertyName );
  128. QString m_playbackStatus;
  129. QTemporaryFile *m_coverTempFile;
  130. };
  131. };
  132. }
  133. #endif // MPRISPLUGIN_H