Added D-Bus support 1.3.3
authorNikolay Tischenko <niktischenko@gmail.com>
Mon, 4 Oct 2010 17:56:24 +0000 (00:56 +0700)
committerNikolay Tischenko <niktischenko@gmail.com>
Mon, 4 Oct 2010 17:56:24 +0000 (00:56 +0700)
Service description in resources/ru.somebody.someplayer.xml

13 files changed:
resources/ru.somebody.someplayer.xml [new file with mode: 0644]
someplayer.pro
src/dbusadaptor.cpp [new file with mode: 0644]
src/dbusadaptor.h [new file with mode: 0644]
src/libraryform.cpp
src/main.cpp
src/mainwindow.cpp
src/player/player.cpp
src/player/player.h
src/playerform.cpp
src/playerform.h
src/someplayer.h
src/ui/settingsdialog.ui

diff --git a/resources/ru.somebody.someplayer.xml b/resources/ru.somebody.someplayer.xml
new file mode 100644 (file)
index 0000000..06a7b50
--- /dev/null
@@ -0,0 +1,47 @@
+<!--
+/*
+ * SomePlayer - An alternate music player for Maemo 5
+ * Copyright (C) 2010 Nikolay (somebody) Tischenko <niktischenko@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 2
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+-->
+
+<node>
+       <interface name="ru.somebody.someplayer">
+               <method name="prev">
+                       <annotation name="org.freedesktop.DBus.Method.NoReply" value="true" />
+               </method>
+               <method name="next">
+                       <annotation name="org.freedesktop.DBus.Method.NoReply" value="true" />
+               </method>
+               <method name="toggle">
+                       <annotation name="org.freedesktop.DBus.Method.NoReply" value="true" />
+               </method>
+               <method name="stop">
+                       <annotation name="org.freedesktop.DBus.Method.NoReply" value="true" />
+               </method>
+               <method name="artist">
+                       <arg type="s" direction="out"/>
+               </method>
+               <method name="album">
+                       <arg type="s" direction="out"/>
+               </method>
+               <method name="title">
+                       <arg type="s" direction="out"/>
+               </method>
+       </interface>
+</node>
+
index c446198..2aae545 100644 (file)
@@ -4,7 +4,7 @@
 #
 #-------------------------------------------------
 
-QT       += core gui phonon sql
+QT       += core gui phonon sql dbus
 
 TARGET = someplayer
 TEMPLATE = app
@@ -120,7 +120,8 @@ SOURCES += src/main.cpp\
     src/timerdialog.cpp \
     src/equalizerdialog.cpp \
     src/saveplaylistdialog.cpp \
-    src/settingsdialog.cpp
+    src/settingsdialog.cpp \
+    src/dbusadaptor.cpp
 
 HEADERS  += src/mainwindow.h \
                src/player/player.h \
@@ -219,7 +220,8 @@ HEADERS  += src/mainwindow.h \
     src/equalizerdialog.h \
     src/saveplaylistdialog.h \
     src/settingsdialog.h \
-    src/abstractitemrenderer.h
+    src/abstractitemrenderer.h \
+    src/dbusadaptor.h
 
 FORMS    += src/ui/mainwindow.ui \
     src/ui/playerform.ui \
diff --git a/src/dbusadaptor.cpp b/src/dbusadaptor.cpp
new file mode 100644 (file)
index 0000000..25b90e0
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * SomePlayer - An alternate music player for Maemo 5
+ * Copyright (C) 2010 Nikolay (somebody) Tischenko <niktischenko@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 2
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+#include "dbusadaptor.h"
+#include <QtCore/QMetaObject>
+#include <QtCore/QByteArray>
+#include <QtCore/QList>
+#include <QtCore/QMap>
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QVariant>
+
+/*
+ * Implementation of adaptor class DBusAdaptop
+ */
+
+DBusAdaptop::DBusAdaptop(QObject *parent)
+    : QDBusAbstractAdaptor(parent)
+{
+    // constructor
+    setAutoRelaySignals(true);
+}
+
+DBusAdaptop::~DBusAdaptop()
+{
+    // destructor
+}
+
+QString DBusAdaptop::album()
+{
+    // handle method call ru.somebody.someplayer.album
+    QString out0;
+    QMetaObject::invokeMethod(parent(), "album", Q_RETURN_ARG(QString, out0));
+    return out0;
+}
+
+QString DBusAdaptop::artist()
+{
+    // handle method call ru.somebody.someplayer.artist
+    QString out0;
+    QMetaObject::invokeMethod(parent(), "artist", Q_RETURN_ARG(QString, out0));
+    return out0;
+}
+
+void DBusAdaptop::next()
+{
+    // handle method call ru.somebody.someplayer.next
+    QMetaObject::invokeMethod(parent(), "next");
+}
+
+void DBusAdaptop::prev()
+{
+    // handle method call ru.somebody.someplayer.prev
+    QMetaObject::invokeMethod(parent(), "prev");
+}
+
+void DBusAdaptop::stop()
+{
+    // handle method call ru.somebody.someplayer.stop
+    QMetaObject::invokeMethod(parent(), "stop");
+}
+
+QString DBusAdaptop::title()
+{
+    // handle method call ru.somebody.someplayer.title
+    QString out0;
+    QMetaObject::invokeMethod(parent(), "title", Q_RETURN_ARG(QString, out0));
+    return out0;
+}
+
+void DBusAdaptop::toggle()
+{
+    // handle method call ru.somebody.someplayer.toggle
+    QMetaObject::invokeMethod(parent(), "toggle");
+}
+
diff --git a/src/dbusadaptor.h b/src/dbusadaptor.h
new file mode 100644 (file)
index 0000000..30ebd0b
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * SomePlayer - An alternate music player for Maemo 5
+ * Copyright (C) 2010 Nikolay (somebody) Tischenko <niktischenko@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 2
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+#ifndef DBUSADAPTOR
+#define DBUSADAPTOR
+
+#include <QtCore/QObject>
+#include <QtDBus/QtDBus>
+class QByteArray;
+template<class T> class QList;
+template<class Key, class Value> class QMap;
+class QString;
+class QStringList;
+class QVariant;
+
+/*
+ * Adaptor class for interface ru.somebody.someplayer
+ */
+class DBusAdaptop: public QDBusAbstractAdaptor
+{
+    Q_OBJECT
+    Q_CLASSINFO("D-Bus Interface", "ru.somebody.someplayer")
+    Q_CLASSINFO("D-Bus Introspection", ""
+"  <interface name=\"ru.somebody.someplayer\">\n"
+"    <method name=\"prev\">\n"
+"      <annotation value=\"true\" name=\"org.freedesktop.DBus.Method.NoReply\"/>\n"
+"    </method>\n"
+"    <method name=\"next\">\n"
+"      <annotation value=\"true\" name=\"org.freedesktop.DBus.Method.NoReply\"/>\n"
+"    </method>\n"
+"    <method name=\"toggle\">\n"
+"      <annotation value=\"true\" name=\"org.freedesktop.DBus.Method.NoReply\"/>\n"
+"    </method>\n"
+"    <method name=\"stop\">\n"
+"      <annotation value=\"true\" name=\"org.freedesktop.DBus.Method.NoReply\"/>\n"
+"    </method>\n"
+"    <method name=\"artist\">\n"
+"      <arg direction=\"out\" type=\"s\"/>\n"
+"    </method>\n"
+"    <method name=\"album\">\n"
+"      <arg direction=\"out\" type=\"s\"/>\n"
+"    </method>\n"
+"    <method name=\"title\">\n"
+"      <arg direction=\"out\" type=\"s\"/>\n"
+"    </method>\n"
+"  </interface>\n"
+        "")
+public:
+    DBusAdaptop(QObject *parent);
+    virtual ~DBusAdaptop();
+
+public: // PROPERTIES
+public Q_SLOTS: // METHODS
+    QString album();
+    QString artist();
+    Q_NOREPLY void next();
+    Q_NOREPLY void prev();
+    Q_NOREPLY void stop();
+    QString title();
+    Q_NOREPLY void toggle();
+Q_SIGNALS: // SIGNALS
+};
+
+#endif
index 756baba..bb190f1 100644 (file)
@@ -87,6 +87,7 @@ LibraryForm::LibraryForm(Library *lib, QWidget *parent) :
        Config config;
        _icons_theme = config.getValue("ui/iconstheme").toString();
        _current_playlist_changed = true;
+       setAttribute(Qt::WA_Maemo5StackedWindow);
 }
 
 LibraryForm::~LibraryForm()
index 1fca7d9..84fb50f 100644 (file)
@@ -23,7 +23,7 @@
 int main(int argc, char *argv[])
 {
        QApplication a(argc, argv);
-       a.setApplicationName("someplayer");
+       a.setApplicationName("ru.somebody.someplayer");
        MainWindow w;
 
 
index 8fe95e9..f704c25 100644 (file)
@@ -91,6 +91,7 @@ MainWindow::MainWindow(QWidget *parent) :
        _library_form->updateIcons();
        _player_form->updateIcons();
        hideSearchPanel();
+       _player_form->reload(true);
        library();
 }
 
index 6aa78d6..80fc64e 100644 (file)
@@ -302,3 +302,21 @@ void Player::setEqualizerValue(int band, double value) {
        Config config;
        config.setValue(QString("equalizer/band%1").arg(band), value);
 }
+
+QString Player::artist() {
+       if (_current < 0)
+               return "";
+       return _playlist.tracks().at(_current).metadata().artist();
+}
+
+QString Player::album() {
+       if (_current < 0)
+               return "";
+       return _playlist.tracks().at(_current).metadata().album();
+}
+
+QString Player::title() {
+       if (_current < 0)
+               return "";
+       return _playlist.tracks().at(_current).metadata().title();
+}
index ee520da..562aad4 100644 (file)
@@ -93,6 +93,9 @@ namespace SomePlayer {
                        void disableEqualizer();
                        void setEqualizerValue(int band, double value);
                        void equalizerValue(int band, double *);
+                       QString artist();
+                       QString album();
+                       QString title();
                private slots:
                        void _stateChanged(Phonon::State, Phonon::State);
                        void _tick(qint64);
index 20118df..3bf359c 100644 (file)
@@ -116,6 +116,13 @@ PlayerForm::PlayerForm(Library* lib, QWidget *parent) :
        connect(_tag_resolver, SIGNAL(decoded(Track)), this, SLOT(_track_decoded(Track)));
        connect(ui->volumeButton, SIGNAL(clicked()), this, SLOT(_toggle_volume()));
        ui->topWidget->setVisible(false);
+       setAttribute(Qt::WA_Maemo5StackedWindow);
+
+       // dbus
+       _dbusadaptor = new DBusAdaptop(_player);
+       QDBusConnection connection = QDBusConnection::sessionBus();
+       bool ret = connection.registerService(_SERVICE_NAME_);
+       ret = connection.registerObject("/", _player);
 }
 
 PlayerForm::~PlayerForm()
index 7d5e3db..59a3299 100644 (file)
@@ -30,6 +30,7 @@
 #include <QTime>
 #include "trackrenderer.h"
 #include "tagresolver.h"
+#include "dbusadaptor.h"
 
 namespace Ui {
     class PlayerForm;
@@ -110,6 +111,7 @@ private:
        int _search_current_id;
 
        QString _icons_theme;
+       DBusAdaptop *_dbusadaptor;
 };
 
 #endif // PLAYERFORM_H
index 8cb4600..159797a 100644 (file)
@@ -47,7 +47,9 @@ namespace SomePlayer {
 #include "config.h"
 
 #define _DYNAMIC_PLAYLIST_MAX_COUNT_ 50
-#define _SOMEPLAYER_VERSION_ "1.3.2"
+#define _SOMEPLAYER_VERSION_ "1.3.3"
 #define NDEBUG
 
+#define _SERVICE_NAME_ "ru.somebody.someplayer"
+
 #endif
index 5208f75..8368d57 100644 (file)
@@ -25,8 +25,8 @@
         <property name="geometry">
          <rect>
           <x>0</x>
-          <y>-88</y>
-          <width>760</width>
+          <y>0</y>
+          <width>776</width>
           <height>296</height>
          </rect>
         </property>
        </property>
       </spacer>
      </item>
-     <item>
-      <widget class="QDialogButtonBox" name="buttonBox">
-       <property name="orientation">
-        <enum>Qt::Horizontal</enum>
-       </property>
-       <property name="standardButtons">
-        <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
-       </property>
-      </widget>
-     </item>
     </layout>
    </item>
   </layout>
  </widget>
  <resources/>
- <connections>
-  <connection>
-   <sender>buttonBox</sender>
-   <signal>accepted()</signal>
-   <receiver>SettingsDialog</receiver>
-   <slot>accept()</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>248</x>
-     <y>254</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>157</x>
-     <y>274</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>buttonBox</sender>
-   <signal>rejected()</signal>
-   <receiver>SettingsDialog</receiver>
-   <slot>reject()</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>316</x>
-     <y>260</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>286</x>
-     <y>274</y>
-    </hint>
-   </hints>
-  </connection>
- </connections>
+ <connections/>
 </ui>