diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2010-11-24 18:17:51 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2010-11-24 18:17:51 +0000 |
| commit | aa3f57c0236c77f2fd90415fc1f3062a93b25b93 (patch) | |
| tree | d9ab905b952cf9289239b95db99f39321a54e65b /src/plugins/General/mpris | |
| parent | 5c2f5798c6222d35e08fa0853812e2390181e735 (diff) | |
| download | qmmp-aa3f57c0236c77f2fd90415fc1f3062a93b25b93.tar.gz qmmp-aa3f57c0236c77f2fd90415fc1f3062a93b25b93.tar.bz2 qmmp-aa3f57c0236c77f2fd90415fc1f3062a93b25b93.zip | |
some api changes, partial mpris 2.0 implementation
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1991 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/General/mpris')
| -rw-r--r-- | src/plugins/General/mpris/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/plugins/General/mpris/mpris.cpp | 26 | ||||
| -rw-r--r-- | src/plugins/General/mpris/mpris.pro | 11 | ||||
| -rw-r--r-- | src/plugins/General/mpris/root2object.cpp | 88 | ||||
| -rw-r--r-- | src/plugins/General/mpris/root2object.h | 58 |
5 files changed, 167 insertions, 18 deletions
diff --git a/src/plugins/General/mpris/CMakeLists.txt b/src/plugins/General/mpris/CMakeLists.txt index 069492b1c..d1eb3e2a3 100644 --- a/src/plugins/General/mpris/CMakeLists.txt +++ b/src/plugins/General/mpris/CMakeLists.txt @@ -33,6 +33,7 @@ SET(libmpris_SRCS mpris.cpp mprisfactory.cpp rootobject.cpp + root2object.cpp playerobject.cpp tracklistobject.cpp ) @@ -41,6 +42,7 @@ SET(libmpris_MOC_HDRS mprisfactory.h mpris.h rootobject.h + root2object.h playerobject.h tracklistobject.h ) diff --git a/src/plugins/General/mpris/mpris.cpp b/src/plugins/General/mpris/mpris.cpp index 4c6474311..d355f7f7f 100644 --- a/src/plugins/General/mpris/mpris.cpp +++ b/src/plugins/General/mpris/mpris.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Ilya Kotov * + * Copyright (C) 2008-2010 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -19,28 +19,28 @@ ***************************************************************************/ #include <QtDBus> - #include "playerobject.h" #include "rootobject.h" #include "tracklistobject.h" +#include "root2object.h" #include "mpris.h" -MPRIS::MPRIS(QObject *parent) - : General(parent) +MPRIS::MPRIS(QObject *parent) : General(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); + //MPRISv1 + connection.registerObject("/TrackList", new TrackListObject(this), QDBusConnection::ExportAllContents); + connection.registerObject("/Player", new PlayerObject(this), QDBusConnection::ExportAllContents); + connection.registerObject("/", new RootObject(this), QDBusConnection::ExportAllContents); + //MPRISv2 + connection.registerObject("/org/mpris/MediaPlayer2", new Root2Object(this), + QDBusConnection::ExportAllContents); connection.registerService("org.mpris.qmmp"); + connection.registerService("org.mpris.MediaPlayer2.qmmp"); } - MPRIS::~MPRIS() { + QDBusConnection::sessionBus().unregisterService("org.mpris.qmmp"); + QDBusConnection::sessionBus().unregisterService("org.mpris.MediaPlayer2.qmmp"); } - - diff --git a/src/plugins/General/mpris/mpris.pro b/src/plugins/General/mpris/mpris.pro index 7d1310348..e97282e03 100644 --- a/src/plugins/General/mpris/mpris.pro +++ b/src/plugins/General/mpris/mpris.pro @@ -40,16 +40,17 @@ INSTALLS += target HEADERS += mprisfactory.h \ mpris.h \ playerobject.h \ - rootobject.h \ - tracklistobject.h + rootobject.h \ + tracklistobject.h \ + root2object.h SOURCES += mprisfactory.cpp \ mpris.cpp \ playerobject.cpp \ - rootobject.cpp \ - tracklistobject.cpp + rootobject.cpp \ + tracklistobject.cpp \ + root2object.cpp INCLUDEPATH += ../../../../src LIBS += -lqmmpui -lqmmp - diff --git a/src/plugins/General/mpris/root2object.cpp b/src/plugins/General/mpris/root2object.cpp new file mode 100644 index 000000000..c0eca65fb --- /dev/null +++ b/src/plugins/General/mpris/root2object.cpp @@ -0,0 +1,88 @@ +/*************************************************************************** + * Copyright (C) 2010 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 <qmmp/qmmp.h> +#include <qmmp/decoder.h> +#include <qmmp/decoderfactory.h> +#include <qmmp/abstractengine.h> +#include <qmmp/enginefactory.h> +#include <qmmp/enginefactory.h> +#include <qmmp/inputsource.h> +#include <qmmp/inputsourcefactory.h> +#include <qmmp/metadatamanager.h> +#include "root2object.h" + +Root2Object::Root2Object(QObject *parent) : QObject(parent) +{} + + +Root2Object::~Root2Object() +{} + +bool Root2Object::canQuit() const +{ + return true; +} + +bool Root2Object::canRaise() const +{ + return false; +} + +QString Root2Object::desktopEntry() const +{ + return "qmmp"; +} + +bool Root2Object::hasTrackList() const +{ + return false; +} +QString Root2Object::identity() const +{ + QString name = "Qmmp " + Qmmp::strVersion(); + return name; +} + +QStringList Root2Object::supportedMimeTypes() const +{ + QStringList mimeTypes; + foreach(DecoderFactory *factory, *Decoder::factories()) + mimeTypes << factory->properties().contentTypes; + foreach(EngineFactory *factory, *AbstractEngine::factories()) + mimeTypes << factory->properties().contentTypes; + mimeTypes.removeDuplicates(); + return mimeTypes; +} + +QStringList Root2Object::supportedUriSchemes() const +{ + QStringList protocols = MetaDataManager::instance()->protocols(); + if(!protocols.contains("file")) //append file if needed + protocols.append("file"); + return protocols; +} + +void Root2Object::Quit() +{ + QMetaObject::invokeMethod(parent(), "exit"); +} + +void Root2Object::Raise(){} diff --git a/src/plugins/General/mpris/root2object.h b/src/plugins/General/mpris/root2object.h new file mode 100644 index 000000000..f661df200 --- /dev/null +++ b/src/plugins/General/mpris/root2object.h @@ -0,0 +1,58 @@ +/*************************************************************************** + * Copyright (C) 2010 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 ROOT2OBJECT_H +#define ROOT2OBJECT_H + +#include <QObject> +#include <QStringList> + +/** + @author Ilya Kotov <forkotov02@hotmail.ru> +*/ +class Root2Object : public QObject +{ +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 DesktopEntry READ desktopEntry) +Q_PROPERTY(bool HasTrackList READ hasTrackList) +Q_PROPERTY(QString Identity READ identity) +Q_PROPERTY(QStringList SupportedMimeTypes READ supportedMimeTypes) +Q_PROPERTY(QStringList SupportedUriSchemes READ supportedUriSchemes) + +public: + Root2Object(QObject *parent = 0); + virtual ~Root2Object(); + + bool canQuit() const; + bool canRaise() const; + QString desktopEntry() const; + bool hasTrackList() const; + QString identity() const; + QStringList supportedMimeTypes() const; + QStringList supportedUriSchemes() const; + +public slots: + void Quit(); + void Raise(); +}; + +#endif |
