aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/General/mpris
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2008-12-16 12:24:16 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2008-12-16 12:24:16 +0000
commit8ab140dace337d1d413433510a87e161759ccc53 (patch)
tree69c1a6656fb1e3226d8e9c6e4942d0c86a614b50 /src/plugins/General/mpris
parent98d4bdde3a1662ea17b03c803664fdef37d08d6e (diff)
downloadqmmp-8ab140dace337d1d413433510a87e161759ccc53.tar.gz
qmmp-8ab140dace337d1d413433510a87e161759ccc53.tar.bz2
qmmp-8ab140dace337d1d413433510a87e161759ccc53.zip
added some mpris methods
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@687 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/General/mpris')
-rw-r--r--src/plugins/General/mpris/CMakeLists.txt2
-rw-r--r--src/plugins/General/mpris/mpris.cpp3
-rw-r--r--src/plugins/General/mpris/mpris.pro6
-rw-r--r--src/plugins/General/mpris/tracklistobject.cpp88
-rw-r--r--src/plugins/General/mpris/tracklistobject.h64
5 files changed, 161 insertions, 2 deletions
diff --git a/src/plugins/General/mpris/CMakeLists.txt b/src/plugins/General/mpris/CMakeLists.txt
index 46bc621ed..2d3314132 100644
--- a/src/plugins/General/mpris/CMakeLists.txt
+++ b/src/plugins/General/mpris/CMakeLists.txt
@@ -34,6 +34,7 @@ SET(libmpris_SRCS
mprisfactory.cpp
rootobject.cpp
playerobject.cpp
+ tracklistobject.cpp
)
SET(libmpris_MOC_HDRS
@@ -41,6 +42,7 @@ SET(libmpris_MOC_HDRS
mpris.h
rootobject.h
playerobject.h
+ tracklistobject.h
)
SET(libmpris_RCCS translations/translations.qrc)
diff --git a/src/plugins/General/mpris/mpris.cpp b/src/plugins/General/mpris/mpris.cpp
index e2a6612ee..40c43cf73 100644
--- a/src/plugins/General/mpris/mpris.cpp
+++ b/src/plugins/General/mpris/mpris.cpp
@@ -22,6 +22,7 @@
#include "playerobject.h"
#include "rootobject.h"
+#include "tracklistobject.h"
#include "mpris.h"
MPRIS::MPRIS(QObject *parent)
@@ -29,7 +30,9 @@ MPRIS::MPRIS(QObject *parent)
{
PlayerObject *player = new PlayerObject(this);
RootObject *root = new RootObject(this);
+ TrackListObject *trackList = new TrackListObject(this);
QDBusConnection connection = QDBusConnection::sessionBus();
+ connection.registerObject("/TrackList", trackList, QDBusConnection::ExportAllContents);
connection.registerObject("/Player", player, QDBusConnection::ExportAllContents);
connection.registerObject("/", root, QDBusConnection::ExportAllContents);
connection.registerService("org.mpris.qmmp");
diff --git a/src/plugins/General/mpris/mpris.pro b/src/plugins/General/mpris/mpris.pro
index af6fec72a..7101a1888 100644
--- a/src/plugins/General/mpris/mpris.pro
+++ b/src/plugins/General/mpris/mpris.pro
@@ -33,12 +33,14 @@ INSTALLS += target
HEADERS += mprisfactory.h \
mpris.h \
playerobject.h \
- rootobject.h
+ rootobject.h \
+ tracklistobject.h
SOURCES += mprisfactory.cpp \
mpris.cpp \
playerobject.cpp \
- rootobject.cpp
+ rootobject.cpp \
+ tracklistobject.cpp
INCLUDEPATH += ../../../../src
diff --git a/src/plugins/General/mpris/tracklistobject.cpp b/src/plugins/General/mpris/tracklistobject.cpp
new file mode 100644
index 000000000..ba8e2c1ba
--- /dev/null
+++ b/src/plugins/General/mpris/tracklistobject.cpp
@@ -0,0 +1,88 @@
+/***************************************************************************
+ * Copyright (C) 2008 by Ilya Kotov *
+ * forkotov02@hotmail.ru *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include <QFile>
+
+#include <qmmpui/playlistmodel.h>
+#include <qmmpui/mediaplayer.h>
+#include <qmmpui/playlistitem.h>
+
+#include "tracklistobject.h"
+
+TrackListObject::TrackListObject(QObject *parent)
+ : QObject(parent)
+{
+ m_player = MediaPlayer::instance();
+ m_model = m_player->playListModel();
+ connect (m_model, SIGNAL(listChanged()), SLOT(updateTrackList()));
+}
+
+
+TrackListObject::~TrackListObject()
+{
+}
+
+/*int TrackListObject::AddTrack(const QString &in0, bool in1)
+{
+ m_model->addFile(in0);
+ if(in1)
+ {
+ m_model->set
+ }
+ return 1;
+}*/
+
+int TrackListObject::GetCurrentTrack()
+{
+ return m_model->currentRow();
+}
+
+int TrackListObject::GetLength()
+{
+ return m_model->count();
+}
+
+QVariantMap TrackListObject::GetMetadata(int in0)
+{
+ QVariantMap map;
+ PlayListItem *item = m_model->item(in0);
+ if (item)
+ {
+ if (QFile::exists(item->url()))
+ map.insert("location", "file://" + item->url());
+ else
+ map.insert("location", item->url());
+ map.insert("title", item->title());
+ map.insert("artist", item->artist());
+ map.insert("album", item->album());
+ map.insert("tracknumber", item->track());
+ map.insert("time", item->length());
+ map.insert("mtime", item->length() * 1000);
+ map.insert("genre", item->genre());
+ map.insert("comment", item->comment());
+ map.insert("year", item->year());
+ }
+ return map;
+}
+
+void TrackListObject::updateTrackList()
+{
+ emit TrackListChange(m_model->count());
+}
diff --git a/src/plugins/General/mpris/tracklistobject.h b/src/plugins/General/mpris/tracklistobject.h
new file mode 100644
index 000000000..736ef1f2b
--- /dev/null
+++ b/src/plugins/General/mpris/tracklistobject.h
@@ -0,0 +1,64 @@
+/***************************************************************************
+ * Copyright (C) 2008 by Ilya Kotov *
+ * forkotov02@hotmail.ru *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef TRACKLISTOBJECT_H
+#define TRACKLISTOBJECT_H
+
+#include <QObject>
+#include <QString>
+#include <QVariantMap>
+
+class PlayListModel;
+class MediaPlayer;
+
+/**
+ @author Ilya Kotov <forkotov02@hotmail.ru>
+*/
+class TrackListObject : public QObject
+{
+ Q_OBJECT
+ Q_CLASSINFO("D-Bus Interface", "org.freedesktop.MediaPlayer")
+
+public:
+ TrackListObject(QObject *parent = 0);
+
+ ~TrackListObject();
+
+public slots:
+ //int AddTrack(const QString &in0, bool in1);
+ /*void DelTrack(int in0);*/
+ int GetCurrentTrack();
+ int GetLength();
+ QVariantMap GetMetadata(int in0);
+ /*void SetLoop(bool in0);
+ void SetRandom(bool in0);*/
+
+signals:
+ void TrackListChange(int in0);
+
+private slots:
+ void updateTrackList();
+
+private:
+ PlayListModel *m_model;
+ MediaPlayer *m_player;
+
+};
+
+#endif