File indexing completed on 2024-04-28 04:50:48
0001 /* 0002 * dbusobjects.h 0003 * 0004 * Copyright (C) 2009-2011 Christoph Pfister <christophpfister@gmail.com> 0005 * 0006 * This program is free software; you can redistribute it and/or modify 0007 * it under the terms of the GNU General Public License as published by 0008 * the Free Software Foundation; either version 2 of the License, or 0009 * (at your option) any later version. 0010 * 0011 * This program is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0014 * GNU General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU General Public License along 0017 * with this program; if not, write to the Free Software Foundation, Inc., 0018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 0019 */ 0020 0021 #ifndef DBUSOBJECTS_H 0022 #define DBUSOBJECTS_H 0023 0024 #include <QVariantMap> 0025 #include <config-kaffeine.h> 0026 0027 class DvbTab; 0028 class MainWindow; 0029 class MediaWidget; 0030 class PlaylistTab; 0031 0032 struct MprisStatusStruct; 0033 struct MprisVersionStruct; 0034 struct TelevisionScheduleEntryStruct; 0035 0036 class MprisRootObject : public QObject 0037 { 0038 Q_OBJECT 0039 Q_CLASSINFO("D-Bus Interface", "org.freedesktop.MediaPlayer") 0040 public: 0041 explicit MprisRootObject(QObject *parent); 0042 ~MprisRootObject(); 0043 0044 public slots: 0045 QString Identity(); 0046 void Quit(); 0047 MprisVersionStruct MprisVersion(); 0048 }; 0049 0050 class MprisPlayerObject : public QObject 0051 { 0052 Q_OBJECT 0053 Q_CLASSINFO("D-Bus Interface", "org.freedesktop.MediaPlayer") 0054 public: 0055 MprisPlayerObject(MainWindow *mainWindow_, MediaWidget *mediaWidget_, 0056 PlaylistTab *playlistTab_, QObject *parent); 0057 ~MprisPlayerObject(); 0058 0059 public slots: 0060 void Next(); 0061 void Prev(); 0062 void Pause(); 0063 void Stop(); 0064 void Play(); 0065 void Repeat(bool repeat); 0066 MprisStatusStruct GetStatus(); 0067 QVariantMap GetMetadata(); 0068 int GetCaps(); 0069 void VolumeSet(int volume); 0070 int VolumeGet(); 0071 void PositionSet(int position); 0072 int PositionGet(); 0073 0074 // this functions are not part of the MPRIS specs 0075 0076 void IncreaseVolume(); 0077 void DecreaseVolume(); 0078 void ToggleMuted(); 0079 void ToggleFullScreen(); 0080 void ShortSkipBackward(); 0081 void ShortSkipForward(); 0082 void LongSkipBackward(); 0083 void LongSkipForward(); 0084 0085 /* // FIXME candidates 0086 void PlayAudioCd(); 0087 void PlayVideoCd(); 0088 void PlayDvd(); 0089 void ChangeAudioStream(int index); 0090 void ChangeSubtitle(int index); 0091 void TimeButtonClicked(); 0092 void AspectRatioAuto(); 0093 void AspectRatio4_3(); 0094 void AspectRatio16_9(); 0095 */ 0096 0097 signals: 0098 void TrackChange(const QVariantMap &metadata); // FIXME not emitted yet 0099 void StatusChange(const MprisStatusStruct &status); // FIXME not emitted yet 0100 void CapsChange(int capabilities); // FIXME not emitted yet 0101 0102 private: 0103 MainWindow *mainWindow; 0104 MediaWidget *mediaWidget; 0105 PlaylistTab *playlistTab; 0106 }; 0107 0108 class MprisTrackListObject : public QObject 0109 { 0110 Q_OBJECT 0111 Q_CLASSINFO("D-Bus Interface", "org.freedesktop.MediaPlayer") 0112 public: 0113 MprisTrackListObject(PlaylistTab *playlistTab_, QObject *parent); 0114 ~MprisTrackListObject(); 0115 0116 public slots: 0117 QVariantMap GetMetadata(int index); 0118 int GetCurrentTrack(); 0119 int GetLength(); 0120 int AddTrack(const QString &url, bool playImmediately); 0121 void DelTrack(int index); 0122 void SetLoop(bool loop); 0123 void SetRandom(bool random); 0124 0125 signals: 0126 void TrackListChange(int size); // FIXME not emitted yet 0127 0128 private: 0129 PlaylistTab *playlistTab; 0130 }; 0131 0132 #ifndef HAVE_DVB 0133 #error HAVE_DVB must be defined 0134 #endif /* HAVE_DVB */ 0135 0136 #if HAVE_DVB == 1 0137 0138 class DBusTelevisionObject : public QObject 0139 { 0140 Q_OBJECT 0141 Q_CLASSINFO("D-Bus Interface", "org.freedesktop.MediaPlayer") 0142 public: 0143 DBusTelevisionObject(DvbTab *dvbTab_, QObject *parent); 0144 ~DBusTelevisionObject(); 0145 0146 public slots: 0147 void DigitPressed(int digit); 0148 void PlayChannel(const QString &nameOrNumber); 0149 void PlayLastChannel(); 0150 void ToggleInstantRecord(); 0151 void ToggleOsd(); 0152 QList<TelevisionScheduleEntryStruct> ListProgramSchedule(); 0153 quint32 ScheduleProgram(const QString &name, const QString &channel, const QString &begin, 0154 const QString &duration, int repeat); 0155 void RemoveProgram(quint32 key); 0156 0157 private: 0158 DvbTab *dvbTab; 0159 }; 0160 0161 #endif /* HAVE_DVB == 1 */ 0162 0163 struct MprisStatusStruct 0164 { 0165 int state; 0166 int random; 0167 int repeatTrack; 0168 int repeatPlaylist; 0169 }; 0170 0171 Q_DECLARE_METATYPE(MprisStatusStruct) 0172 0173 struct MprisVersionStruct 0174 { 0175 quint16 major; 0176 quint16 minor; 0177 }; 0178 0179 Q_DECLARE_METATYPE(MprisVersionStruct) 0180 0181 struct TelevisionScheduleEntryStruct 0182 { 0183 quint32 key; 0184 QString name; 0185 QString channel; 0186 QString begin; 0187 QString duration; 0188 int repeat; 0189 bool isRunning; 0190 }; 0191 0192 Q_DECLARE_METATYPE(TelevisionScheduleEntryStruct) 0193 Q_DECLARE_METATYPE(QList<TelevisionScheduleEntryStruct>) 0194 0195 #endif /* DBUSOBJECTS_H */