-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathplayer_adaptor.h
executable file
·177 lines (153 loc) · 6.94 KB
/
player_adaptor.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/***************************************************************************
* Project created by QtCreator 2018-06-01T17:15:24 *
* *
* goldfinch Copyright (C) 2014 AbouZakaria <yahiaui@gmail.com> *
* *
* This program 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. *
* *
* This program 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 this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef RUN_ADAPTOR_H
#define RUN_ADAPTOR_H
#include <QObject>
#include <QtDBus/QtDBus>
#include <QWidget>
#include <QMap>
#include <QVariant>
QT_BEGIN_NAMESPACE
#include <QApplication>
class QString;
QT_END_NAMESPACE
/*
* Adaptor class for interface org.mpris.MediaPlayer2
*/
class MainAdaptor: public QDBusAbstractAdaptor
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.mpris.MediaPlayer2")
Q_PROPERTY(bool CanQuit READ CanQuit)
Q_PROPERTY(bool CanRaise READ CanRaise)
Q_PROPERTY(QString Identity READ Identity)
Q_PROPERTY(QString DesktopEntry READ DesktopEntry)
Q_CLASSINFO("D-Bus Introspection",
" <interface name=\"org.mpris.MediaPlayer2\">\n"
" <property name=\"Identity\" type=\"s\" access=\"read\" />\n"
" <property name=\"DesktopEntry\" type=\"s\" access=\"read\" />\n"
" <property name=\"CanQuit\" type=\"b\" access=\"read\" />\n"
" <property name=\"CanRaise\" type=\"b\" access=\"read\" />\n"
" <method name=\"Quit\" />\n"
" <method name=\"Raise\" />\n"
" <method name=\"Hide\" />\n"
" <method name=\"ToggleHide\" />\n"
" </interface>\n"
)
public:
MainAdaptor(QObject *parent);
virtual ~MainAdaptor();
public Q_SLOTS: // METHODS
void Quit();
void Raise();
void Hide();
void ToggleHide();
bool CanQuit() {return true;}
bool CanRaise(){return true;}
QString DesktopEntry(){return QApplication::applicationName();}
QString Identity() {return QApplication::applicationDisplayName();}
// void SetUrl(const QString &url);
};
/*
* Adaptor class for interface org.mpris.MediaPlayer2.Player
*/
class PlayerAdaptor: public QDBusAbstractAdaptor
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.mpris.MediaPlayer2.Player")
Q_PROPERTY(bool CanPlay READ CanPlay)
Q_PROPERTY(bool CanPause READ CanPause)
Q_PROPERTY(bool CanSeek READ CanSeek)
Q_PROPERTY(bool CanGoPrevious READ CanGoPrevious)
Q_PROPERTY(bool CanGoNext READ CanGoNext)
Q_PROPERTY(bool CanControl READ CanControl)
Q_PROPERTY(QString PlaybackStatus READ PlaybackStatus)
Q_PROPERTY(QVariantMap Metadata READ Metadata)
Q_PROPERTY(qint64 Position READ Position)
Q_CLASSINFO("D-Bus Introspection",
" <interface name=\"org.mpris.MediaPlayer2.Player\">\n"
" <property name=\"Metadata\" type=\"a{sv}\" access=\"read\" />\n"
" <property name=\"PlaybackStatus\" type=\"s\" access=\"read\" />\n"
" <property name=\"LoopStatus\" type=\"s\" access=\"readwrite\" />\n"
" <property name=\"Volume\" type=\"d\" access=\"readwrite\" />\n"
" <property name=\"Shuffle\" type=\"d\" access=\"readwrite\" />\n"
" <property name=\"Position\" type=\"i\" access=\"read\" />\n"
" <property name=\"Rate\" type=\"d\" access=\"readwrite\" />\n"
" <property name=\"MinimumRate\" type=\"d\" access=\"readwrite\" />\n"
" <property name=\"MaximumRate\" type=\"d\" access=\"readwrite\" />\n"
" <property name=\"CanControl\" type=\"b\" access=\"read\" />\n"
" <property name=\"CanPlay\" type=\"b\" access=\"read\" />\n"
" <property name=\"CanPause\" type=\"b\" access=\"read\" />\n"
" <property name=\"CanSeek\" type=\"b\" access=\"read\" />\n"
" <method name=\"Previous\" />\n"
" <method name=\"Next\" />\n"
" <method name=\"Stop\" />\n"
" <method name=\"Play\" />\n"
" <method name=\"Pause\" />\n"
" <method name=\"PlayPause\" />\n"
" <method name=\"Seek\">\n"
" <arg type=\"x\" direction=\"in\" />\n"
" </method>"
" <method name=\"OpenUri\">\n"
" <arg type=\"s\" direction=\"in\" />\n"
" </method>\n"
" <method name=\"SetPosition\">\n"
" <arg type=\"o\" direction=\"in\" />\n"
" <arg type=\"x\" direction=\"in\" />\n"
" </method>\n"
" <signal name=\"Seeked\">\n"
" <arg type=\"x\" direction=\"out\" />\n"
" </signal>\n"
" </interface>\n"
"")
public:
PlayerAdaptor(QObject *parent);
virtual ~PlayerAdaptor();
Q_SIGNALS: // SIGNALS
void Seeked(qlonglong);
public Q_SLOTS: // METHODS
void Play();
void Pause();
void Stop();
void Next();
void Previous();
void Seek(qlonglong Offset);
void PlayPause();
void SetPosition(const QDBusObjectPath &TrackId, qlonglong Position);
bool CanPlay();
bool CanPause();
bool CanSeek();
bool CanGoPrevious();
bool CanGoNext();
bool CanControl(){return true;}
QString PlaybackStatus();
qint64 Position();
QVariantMap Metadata();
void setPos(qint64 p);
void propertiesChanged(QVariantMap changedProps);
void SetUrl(const QString &url);
static bool Notify(const QString &app_name, const QString &app_icon,
const QString &summary, const QString &body,
int expire_timeout);
private slots:
// FreeDesktopAdaptor* mFreeDesktopAdaptor;
};
#endif