9d0f8f952216f50f0e6a9564c5f6d3f78ccbb322
[someplayer] / src / dbusadaptor.h
1 /*
2  * SomePlayer - An alternate music player for Maemo 5
3  * Copyright (C) 2010 Nikolay (somebody) Tischenko <niktischenko@gmail.com>
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program 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 this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18  */
19
20 #ifndef DBUSADAPTOR
21 #define DBUSADAPTOR
22
23 #include <QtCore/QObject>
24 #include <QtDBus/QtDBus>
25 #include <QTime>
26 #include <QVariant>
27
28 #define _DBUS_ACTION_TIMEOUT_ (500)
29
30 class QByteArray;
31 template<class T> class QList;
32 template<class Key, class Value> class QMap;
33 class QString;
34 class QStringList;
35 class QVariant;
36
37 /*
38  * Adaptor class for interface ru.somebody.someplayer
39  */
40 class DBusAdaptop: public QDBusAbstractAdaptor
41 {
42         Q_OBJECT
43         Q_CLASSINFO("D-Bus Interface", "ru.somebody.someplayer")
44         Q_CLASSINFO("D-Bus Introspection", ""
45                     "  <interface name=\"ru.somebody.someplayer\">\n"
46                     "    <method name=\"prev\">\n"
47                     "      <annotation value=\"true\" name=\"org.freedesktop.DBus.Method.NoReply\"/>\n"
48                     "    </method>\n"
49                     "    <method name=\"next\">\n"
50                     "      <annotation value=\"true\" name=\"org.freedesktop.DBus.Method.NoReply\"/>\n"
51                     "    </method>\n"
52                     "    <method name=\"toggle\">\n"
53                     "      <annotation value=\"true\" name=\"org.freedesktop.DBus.Method.NoReply\"/>\n"
54                     "    </method>\n"
55                     "    <method name=\"stop\">\n"
56                     "      <annotation value=\"true\" name=\"org.freedesktop.DBus.Method.NoReply\"/>\n"
57                     "    </method>\n"
58                     "    <method name=\"artist\">\n"
59                     "      <arg direction=\"out\" type=\"s\"/>\n"
60                     "    </method>\n"
61                     "    <method name=\"album\">\n"
62                     "      <arg direction=\"out\" type=\"s\"/>\n"
63                     "    </method>\n"
64                     "    <method name=\"title\">\n"
65                     "      <arg direction=\"out\" type=\"s\"/>\n"
66                     "    </method>\n"
67                     "    <method name=\"title_artist_album\">\n"
68                     "      <arg direction=\"out\" type=\"s\"/>\n"
69                     "    </method>\n"
70                     "    <method name=\"state\">\n"
71                     "      <arg direction=\"out\" type=\"s\"/>\n"
72                     "    </method>\n"
73                     "    <method name=\"albumart\">\n"
74                     "      <arg direction=\"out\" type=\"s\"/>\n"
75                     "    </method>\n"
76                     "  </interface>\n"
77                     "")
78 public:
79         DBusAdaptop(QObject *parent);
80         virtual ~DBusAdaptop();
81
82 public: // PROPERTIES
83 public Q_SLOTS: // METHODS
84         QString album();
85         QString artist();
86         Q_NOREPLY void next();
87         Q_NOREPLY void prev();
88         Q_NOREPLY void stop();
89         QString title();
90         QString title_artist_album();
91         QString state();
92         QString albumart();
93         Q_NOREPLY void toggle();
94         Q_NOREPLY void pause();
95         Q_NOREPLY void playIfPaused();
96
97         void processBTSignal(QString, QString);
98         void processBTConnect(QString, QDBusVariant);
99 Q_SIGNALS: // SIGNALS
100         void stateChanged();
101         void albumArt(QString path);
102 private:
103         QTime _time;
104         bool _is_bt_conencted;
105 };
106
107 #endif