aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/General
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2008-11-25 20:39:00 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2008-11-25 20:39:00 +0000
commit0912dcdd8496ac6f0b70c51087dbd522de6dd025 (patch)
treef14d3fb4c91e73e8f080052d543a328465d87e2b /src/plugins/General
parent4779fa87bb6f000e1c99a8e475e1964d7a22637e (diff)
downloadqmmp-0912dcdd8496ac6f0b70c51087dbd522de6dd025.tar.gz
qmmp-0912dcdd8496ac6f0b70c51087dbd522de6dd025.tar.bz2
qmmp-0912dcdd8496ac6f0b70c51087dbd522de6dd025.zip
partial mpris support, removed dbus plugin
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@633 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/General')
-rw-r--r--src/plugins/General/CMakeLists.txt2
-rw-r--r--src/plugins/General/General.pro2
-rw-r--r--src/plugins/General/dbuscontrol/dbusadaptor.cpp200
-rw-r--r--src/plugins/General/dbuscontrol/dbusadaptor.h99
-rw-r--r--src/plugins/General/dbuscontrol/dbuscontrol.pro44
-rw-r--r--src/plugins/General/dbuscontrol/translations/dbuscontrol_plugin_cs.ts26
-rw-r--r--src/plugins/General/dbuscontrol/translations/dbuscontrol_plugin_de.ts26
-rw-r--r--src/plugins/General/dbuscontrol/translations/dbuscontrol_plugin_ru.ts26
-rw-r--r--src/plugins/General/dbuscontrol/translations/dbuscontrol_plugin_uk_UA.ts27
-rw-r--r--src/plugins/General/dbuscontrol/translations/dbuscontrol_plugin_zh_CN.ts26
-rw-r--r--src/plugins/General/dbuscontrol/translations/dbuscontrol_plugin_zh_TW.ts26
-rw-r--r--src/plugins/General/dbuscontrol/translations/translations.qrc11
-rw-r--r--src/plugins/General/mpris/CMakeLists.txt (renamed from src/plugins/General/dbuscontrol/CMakeLists.txt)36
-rw-r--r--src/plugins/General/mpris/mpris.cpp (renamed from src/plugins/General/dbuscontrol/dbuscontrol.cpp)23
-rw-r--r--src/plugins/General/mpris/mpris.h (renamed from src/plugins/General/dbuscontrol/dbuscontrol.h)11
-rw-r--r--src/plugins/General/mpris/mpris.pro46
-rw-r--r--src/plugins/General/mpris/mprisfactory.cpp (renamed from src/plugins/General/dbuscontrol/dbuscontrolfactory.cpp)26
-rw-r--r--src/plugins/General/mpris/mprisfactory.h (renamed from src/plugins/General/dbuscontrol/dbuscontrolfactory.h)6
-rw-r--r--src/plugins/General/mpris/playerobject.cpp117
-rw-r--r--src/plugins/General/mpris/playerobject.h77
-rw-r--r--src/plugins/General/mpris/rootobject.cpp49
-rw-r--r--src/plugins/General/mpris/rootobject.h52
22 files changed, 397 insertions, 561 deletions
diff --git a/src/plugins/General/CMakeLists.txt b/src/plugins/General/CMakeLists.txt
index 17e93cb00..d596e06ef 100644
--- a/src/plugins/General/CMakeLists.txt
+++ b/src/plugins/General/CMakeLists.txt
@@ -4,7 +4,7 @@ SET(USE_STATICON TRUE CACHE BOOL "enable/disable status icon plugin")
SET(USE_NOTIFIER TRUE CACHE BOOL "enable/disable notifier plugin")
IF(USE_DBUS)
-add_subdirectory(dbuscontrol)
+add_subdirectory(mpris)
ENDIF(USE_DBUS)
IF(USE_SCROBBLER)
diff --git a/src/plugins/General/General.pro b/src/plugins/General/General.pro
index 176ed7f1c..8ba55358b 100644
--- a/src/plugins/General/General.pro
+++ b/src/plugins/General/General.pro
@@ -1,5 +1,5 @@
SUBDIRS += statusicon \
#scrobbler \
- dbuscontrol \
+ mpris \
notifier
TEMPLATE = subdirs
diff --git a/src/plugins/General/dbuscontrol/dbusadaptor.cpp b/src/plugins/General/dbuscontrol/dbusadaptor.cpp
deleted file mode 100644
index 415ec35dc..000000000
--- a/src/plugins/General/dbuscontrol/dbusadaptor.cpp
+++ /dev/null
@@ -1,200 +0,0 @@
-/***************************************************************************
- * 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 "dbuscontrol.h"
-#include "dbusadaptor.h"
-
-DBUSAdaptor::DBUSAdaptor(QObject *parent)
- : QDBusAbstractAdaptor(parent)
-{
- setAutoRelaySignals(TRUE);
- connect(parent, SIGNAL(stateChanged()), SLOT (processState()));
- connect(parent, SIGNAL(volumeChanged()), SLOT (processVolume()));
- connect(parent, SIGNAL(timeChanged()), SLOT (processTime()));
- connect(parent, SIGNAL(songChanged()), SIGNAL(songChanged()));
-}
-
-DBUSAdaptor::~DBUSAdaptor()
-{}
-
-int DBUSAdaptor::volume()
-{
- int left, right;
- QMetaObject::invokeMethod(parent(), "leftVolume", Q_RETURN_ARG(int, left));
- QMetaObject::invokeMethod(parent(), "rightVolume", Q_RETURN_ARG(int, right));
- return qMax(left, right);
-}
-
-void DBUSAdaptor::setVolume(int volume)
-{
- volume = qMin(volume, 100);
- volume = qMax(volume, 0);
- int bal = balance();
- int left = volume-qMax(bal,0)*volume/100;
- int right = volume+qMin(bal,0)*volume/100;
- //QMetaObject::invokeMethod(m_control, "setVolume", Q_ARG(int, left), Q_ARG(int, right));
-}
-
-int DBUSAdaptor::balance()
-{
- int left, right;
- QMetaObject::invokeMethod(parent(), "leftVolume", Q_RETURN_ARG(int, left));
- QMetaObject::invokeMethod(parent(), "rightVolume", Q_RETURN_ARG(int, right));
- if(left || right)
- return (right-left)*100/qMax(left, right);
- else
- return 0;
-}
-
-void DBUSAdaptor::setBalance(int bal)
-{
- bal = qMin(bal,100);
- bal = qMax(bal,-100);
- int left = volume()-qMax(bal,0)*volume()/100;
- int right = volume()+qMin(bal,0)*volume()/100;
- //QMetaObject::invokeMethod(m_control, "setVolume", Q_ARG(int, left), Q_ARG(int, right));
-}
-
-int DBUSAdaptor::length()
-{
- return 0;//qobject_cast<DBUSControl *>(parent())->info()->length();
-}
-
-int DBUSAdaptor::year()
-{
- return 0;//qobject_cast<DBUSControl *>(parent())->info()->year();
-}
-
-QString DBUSAdaptor::title()
-{
- return QString();//qobject_cast<DBUSControl *>(parent())->info()->title();
-}
-
-QString DBUSAdaptor::artist()
-{
- return QString();//qobject_cast<DBUSControl *>(parent())->info()->artist();
-}
-
-QString DBUSAdaptor::album()
-{
- return QString();//qobject_cast<DBUSControl *>(parent())->info()->album();
-}
-
-QString DBUSAdaptor::comment()
-{
- return QString();//qobject_cast<DBUSControl *>(parent())->info()->comment();
-}
-
-QString DBUSAdaptor::genre()
-{
- return QString();//qobject_cast<DBUSControl *>(parent())->info()->genre();
-}
-
-QString DBUSAdaptor::path()
-{
- return QString();//qobject_cast<DBUSControl *>(parent())->info()->path();
-}
-
-bool DBUSAdaptor::isPlaying()
-{
- //return qobject_cast<DBUSControl *>(parent())->state() == General::Playing;
- return FALSE;
-}
-
-bool DBUSAdaptor::isPaused()
-{
- //return qobject_cast<DBUSControl *>(parent())->state() == General::Paused;
- return FALSE;
-}
-
-bool DBUSAdaptor::isStopped()
-{
- //return qobject_cast<DBUSControl *>(parent())->state() == General::Stopped;
- return FALSE;
-}
-
-int DBUSAdaptor::elapsedTime()
-{
- //return qobject_cast<DBUSControl *>(parent())->elapsedTime();
- return 0;
-}
-
-void DBUSAdaptor::play()
-{
- //QMetaObject::invokeMethod(m_control, "play");
-}
-
-void DBUSAdaptor::stop()
-{
- //QMetaObject::invokeMethod(m_control, "stop");
-}
-
-void DBUSAdaptor::next()
-{
- //QMetaObject::invokeMethod(m_control, "next");
-}
-
-void DBUSAdaptor::previous()
-{
- //QMetaObject::invokeMethod(m_control, "previous");
-}
-
-void DBUSAdaptor::pause()
-{
- //QMetaObject::invokeMethod(m_control, "pause");
-}
-
-void DBUSAdaptor::toggleVisibility()
-{
- //QMetaObject::invokeMethod(m_control, "toggleVisibility");
-}
-
-void DBUSAdaptor::exit()
-{
- //QMetaObject::invokeMethod(m_control, "exit");
-}
-
-void DBUSAdaptor::seek(int time)
-{
- if ((time < 0) || (time > length()))
- return;
- //QMetaObject::invokeMethod(m_control, "seek", Q_ARG(int, time));
-}
-
-void DBUSAdaptor::processState()
-{
- /*uint state = qobject_cast<DBUSControl *>(parent())->state();
- if(state == General::Playing)
- emit started();
- else if(state == General::Stopped)
- emit stopped();
- else if(state == General::Paused)
- emit paused();*/
-}
-
-void DBUSAdaptor::processVolume()
-{
- emit volumeChanged(volume(), balance());
-}
-
-void DBUSAdaptor::processTime()
-{
- emit timeChanged(elapsedTime());
-}
diff --git a/src/plugins/General/dbuscontrol/dbusadaptor.h b/src/plugins/General/dbuscontrol/dbusadaptor.h
deleted file mode 100644
index 5d82db044..000000000
--- a/src/plugins/General/dbuscontrol/dbusadaptor.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/***************************************************************************
- * 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 DBUSADAPTOR_H
-#define DBUSADAPTOR_H
-
-#include <QtDBus>
-
-class Control;
-
-/**
- @author Ilya Kotov <forkotov02@hotmail.ru>
-*/
-class DBUSAdaptor : public QDBusAbstractAdaptor
-{
-Q_OBJECT
-Q_CLASSINFO("D-Bus Interface", "org.qmmp.dbus")
-Q_PROPERTY(int volume READ volume WRITE setVolume)
-Q_PROPERTY(int balance READ balance WRITE setBalance)
-Q_PROPERTY(int length READ length)
-Q_PROPERTY(int year READ year)
-Q_PROPERTY(QString title READ title)
-Q_PROPERTY(QString artist READ artist)
-Q_PROPERTY(QString album READ album)
-Q_PROPERTY(QString comment READ comment)
-Q_PROPERTY(QString genre READ genre)
-Q_PROPERTY(QString path READ path)
-Q_PROPERTY(bool isPlaying READ isPlaying)
-Q_PROPERTY(bool isPaused READ isPaused)
-Q_PROPERTY(bool isStopped READ isStopped)
-Q_PROPERTY(int elapsedTime READ elapsedTime)
-
-
-public:
- DBUSAdaptor(QObject *parent = 0);
-
- ~DBUSAdaptor();
-
- int volume();
- void setVolume(int);
- int balance();
- void setBalance(int);
- int length();
- int year();
- QString title();
- QString artist();
- QString album();
- QString comment();
- QString genre();
- QString path();
- bool isPlaying();
- bool isPaused();
- bool isStopped();
- int elapsedTime();
-
-signals:
- void started();
- void paused();
- void stopped();
- void volumeChanged(int vol, int bal);
- void timeChanged(int newTime);
- void songChanged();
-
-public slots:
- void play();
- void stop();
- void next();
- void previous();
- void pause();
- void toggleVisibility();
- void exit();
- void seek(int time);
-
-private slots:
- void processState();
- void processVolume();
- void processTime();
-
-private:
- Control *m_control;
-};
-
-#endif
diff --git a/src/plugins/General/dbuscontrol/dbuscontrol.pro b/src/plugins/General/dbuscontrol/dbuscontrol.pro
deleted file mode 100644
index ca13031f8..000000000
--- a/src/plugins/General/dbuscontrol/dbuscontrol.pro
+++ /dev/null
@@ -1,44 +0,0 @@
-include(../../plugins.pri)
-
-CONFIG += release \
-warn_on \
-plugin \
- lib \
- qdbus
-
-TARGET=$$PLUGINS_PREFIX/General/dbuscontrol
-QMAKE_CLEAN =$$PLUGINS_PREFIX/General/libdbuscontrol.so
-
-TEMPLATE = lib
-QMAKE_LIBDIR += ../../../../lib
-
-TRANSLATIONS = translations/dbuscontrol_plugin_cs.ts \
- translations/dbuscontrol_plugin_de.ts \
- translations/dbuscontrol_plugin_zh_CN.ts \
- translations/dbuscontrol_plugin_zh_TW.ts \
- translations/dbuscontrol_plugin_ru.ts \
- translations/dbuscontrol_plugin_uk_UA.ts
-RESOURCES = translations/translations.qrc
-
-isEmpty(LIB_DIR){
- LIB_DIR = /lib
-}
-target.path = $$LIB_DIR/qmmp/General
-INSTALLS += target
-#FORMS += settingsdialog.ui
-
-#RESOURCES += images/images.qrc
-
-
-HEADERS += dbuscontrolfactory.h \
- dbuscontrol.h \
- dbusadaptor.h
-
-SOURCES += dbuscontrolfactory.cpp \
- dbuscontrol.cpp \
- dbusadaptor.cpp
-
-INCLUDEPATH += ../../../../src
-
-LIBS += -lqmmpui -lqmmp
-
diff --git a/src/plugins/General/dbuscontrol/translations/dbuscontrol_plugin_cs.ts b/src/plugins/General/dbuscontrol/translations/dbuscontrol_plugin_cs.ts
deleted file mode 100644
index 19acbfa81..000000000
--- a/src/plugins/General/dbuscontrol/translations/dbuscontrol_plugin_cs.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE TS><TS version="1.1" language="cs">
-<context>
- <name>DBUSControlFactory</name>
- <message>
- <location filename="../dbuscontrolfactory.cpp" line="29"/>
- <source>D-Bus Plugin</source>
- <translation>Modul D-Bus</translation>
- </message>
- <message>
- <location filename="../dbuscontrolfactory.cpp" line="48"/>
- <source>About D-Bus Plugin</source>
- <translation>O modulu D-Bus</translation>
- </message>
- <message>
- <location filename="../dbuscontrolfactory.cpp" line="49"/>
- <source>Qmmp D-Bus Plugin</source>
- <translation>Modul Qmmp D-Bus</translation>
- </message>
- <message>
- <location filename="../dbuscontrolfactory.cpp" line="50"/>
- <source>Writen by: Ilya Kotov &lt;forkotov02@hotmail.ru&gt;</source>
- <translation>Autor: Ilja Kotov &lt;forkotov02@hotmail.ru&gt;</translation>
- </message>
-</context>
-</TS>
diff --git a/src/plugins/General/dbuscontrol/translations/dbuscontrol_plugin_de.ts b/src/plugins/General/dbuscontrol/translations/dbuscontrol_plugin_de.ts
deleted file mode 100644
index be6fae6c1..000000000
--- a/src/plugins/General/dbuscontrol/translations/dbuscontrol_plugin_de.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE TS><TS version="1.1" language="de">
-<context>
- <name>DBUSControlFactory</name>
- <message>
- <location filename="../dbuscontrolfactory.cpp" line="29"/>
- <source>D-Bus Plugin</source>
- <translation>D-Bus Plugin</translation>
- </message>
- <message>
- <location filename="../dbuscontrolfactory.cpp" line="48"/>
- <source>About D-Bus Plugin</source>
- <translation>Über D-Bus Plugin</translation>
- </message>
- <message>
- <location filename="../dbuscontrolfactory.cpp" line="49"/>
- <source>Qmmp D-Bus Plugin</source>
- <translation>Qmmp D-Bus Plugin</translation>
- </message>
- <message>
- <location filename="../dbuscontrolfactory.cpp" line="50"/>
- <source>Writen by: Ilya Kotov &lt;forkotov02@hotmail.ru&gt;</source>
- <translation>Autor: Ilya Kotov &lt;forkotov02@hotmail.ru&gt;</translation>
- </message>
-</context>
-</TS>
diff --git a/src/plugins/General/dbuscontrol/translations/dbuscontrol_plugin_ru.ts b/src/plugins/General/dbuscontrol/translations/dbuscontrol_plugin_ru.ts
deleted file mode 100644
index aaaa99ab8..000000000
--- a/src/plugins/General/dbuscontrol/translations/dbuscontrol_plugin_ru.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE TS><TS version="1.1" language="ru">
-<context>
- <name>DBUSControlFactory</name>
- <message>
- <location filename="../dbuscontrolfactory.cpp" line="29"/>
- <source>D-Bus Plugin</source>
- <translation>Модуль D-Bus</translation>
- </message>
- <message>
- <location filename="../dbuscontrolfactory.cpp" line="48"/>
- <source>About D-Bus Plugin</source>
- <translation>О модуле D-bus</translation>
- </message>
- <message>
- <location filename="../dbuscontrolfactory.cpp" line="49"/>
- <source>Qmmp D-Bus Plugin</source>
- <translation>Модуль D-Bus для Qmmp</translation>
- </message>
- <message>
- <location filename="../dbuscontrolfactory.cpp" line="50"/>
- <source>Writen by: Ilya Kotov &lt;forkotov02@hotmail.ru&gt;</source>
- <translation>Разработчик: Илья Котов &lt;forkotov02@hotmail.ru&gt;</translation>
- </message>
-</context>
-</TS>
diff --git a/src/plugins/General/dbuscontrol/translations/dbuscontrol_plugin_uk_UA.ts b/src/plugins/General/dbuscontrol/translations/dbuscontrol_plugin_uk_UA.ts
deleted file mode 100644
index 787c9b70c..000000000
--- a/src/plugins/General/dbuscontrol/translations/dbuscontrol_plugin_uk_UA.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE TS><TS version="1.1" language="uk">
-<defaultcodec></defaultcodec>
-<context>
- <name>DBUSControlFactory</name>
- <message>
- <location filename="../dbuscontrolfactory.cpp" line="29"/>
- <source>D-Bus Plugin</source>
- <translation>Модуль D-Bus</translation>
- </message>
- <message>
- <location filename="../dbuscontrolfactory.cpp" line="48"/>
- <source>About D-Bus Plugin</source>
- <translation>Про модуль D-bus</translation>
- </message>
- <message>
- <location filename="../dbuscontrolfactory.cpp" line="49"/>
- <source>Qmmp D-Bus Plugin</source>
- <translation>Модуль D-Bus для Qmmp</translation>
- </message>
- <message>
- <location filename="../dbuscontrolfactory.cpp" line="50"/>
- <source>Writen by: Ilya Kotov &lt;forkotov02@hotmail.ru&gt;</source>
- <translation>Розробник: Ілля Котов &lt;forkotov02@hotmail.ru&gt;</translation>
- </message>
-</context>
-</TS>
diff --git a/src/plugins/General/dbuscontrol/translations/dbuscontrol_plugin_zh_CN.ts b/src/plugins/General/dbuscontrol/translations/dbuscontrol_plugin_zh_CN.ts
deleted file mode 100644
index a2fb5d6ce..000000000
--- a/src/plugins/General/dbuscontrol/translations/dbuscontrol_plugin_zh_CN.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE TS><TS version="1.1" language="zh_CN">
-<context>
- <name>DBUSControlFactory</name>
- <message>
- <location filename="../dbuscontrolfactory.cpp" line="29"/>
- <source>D-Bus Plugin</source>
- <translation>D-Bus 插件</translation>
- </message>
- <message>
- <location filename="../dbuscontrolfactory.cpp" line="48"/>
- <source>About D-Bus Plugin</source>
- <translation>关于 D-Bus 插件</translation>
- </message>
- <message>
- <location filename="../dbuscontrolfactory.cpp" line="49"/>
- <source>Qmmp D-Bus Plugin</source>
- <translation>Qmmp D-Bus 插件</translation>
- </message>
- <message>
- <location filename="../dbuscontrolfactory.cpp" line="50"/>
- <source>Writen by: Ilya Kotov &lt;forkotov02@hotmail.ru&gt;</source>
- <translation>作者:Ilya Kotov &lt;forkotov02@hotmail.ru&gt;</translation>
- </message>
-</context>
-</TS>
diff --git a/src/plugins/General/dbuscontrol/translations/dbuscontrol_plugin_zh_TW.ts b/src/plugins/General/dbuscontrol/translations/dbuscontrol_plugin_zh_TW.ts
deleted file mode 100644
index eeafbc6b6..000000000
--- a/src/plugins/General/dbuscontrol/translations/dbuscontrol_plugin_zh_TW.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE TS><TS version="1.1" language="zh_TW">
-<context>
- <name>DBUSControlFactory</name>
- <message>
- <location filename="../dbuscontrolfactory.cpp" line="29"/>
- <source>D-Bus Plugin</source>
- <translation>D-Bus 插件</translation>
- </message>
- <message>
- <location filename="../dbuscontrolfactory.cpp" line="48"/>
- <source>About D-Bus Plugin</source>
- <translation>關於 D-Bus 插件</translation>
- </message>
- <message>
- <location filename="../dbuscontrolfactory.cpp" line="49"/>
- <source>Qmmp D-Bus Plugin</source>
- <translation>Qmmp D-Bus 插件</translation>
- </message>
- <message>
- <location filename="../dbuscontrolfactory.cpp" line="50"/>
- <source>Writen by: Ilya Kotov &lt;forkotov02@hotmail.ru&gt;</source>
- <translation>作者:Ilya Kotov &lt;forkotov02@hotmail.ru&gt;</translation>
- </message>
-</context>
-</TS>
diff --git a/src/plugins/General/dbuscontrol/translations/translations.qrc b/src/plugins/General/dbuscontrol/translations/translations.qrc
deleted file mode 100644
index da4731d6c..000000000
--- a/src/plugins/General/dbuscontrol/translations/translations.qrc
+++ /dev/null
@@ -1,11 +0,0 @@
-<!DOCTYPE RCC>
-<RCC version="1.0">
- <qresource>
- <file>dbuscontrol_plugin_cs.qm</file>
- <file>dbuscontrol_plugin_de.qm</file>
- <file>dbuscontrol_plugin_zh_CN.qm</file>
- <file>dbuscontrol_plugin_zh_TW.qm</file>
- <file>dbuscontrol_plugin_ru.qm</file>
- <file>dbuscontrol_plugin_uk_UA.qm</file>
- </qresource>
-</RCC>
diff --git a/src/plugins/General/dbuscontrol/CMakeLists.txt b/src/plugins/General/mpris/CMakeLists.txt
index b646cee80..d82bd30f3 100644
--- a/src/plugins/General/dbuscontrol/CMakeLists.txt
+++ b/src/plugins/General/mpris/CMakeLists.txt
@@ -1,4 +1,4 @@
-project(libdbuscontrol)
+project(libmpris)
cmake_minimum_required(VERSION 2.4.8 FATAL_ERROR)
@@ -29,33 +29,35 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../)
link_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../qmmpui)
link_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../qmmp)
-SET(libdbuscontrol_SRCS
- dbuscontrol.cpp
- dbuscontrolfactory.cpp
- dbusadaptor.cpp
+SET(libmpris_SRCS
+ mpris.cpp
+ mprisfactory.cpp
+ rootobject.cpp
+ playerobject.cpp
)
-SET(libdbuscontrol_MOC_HDRS
- dbuscontrolfactory.h
- dbuscontrol.h
- dbusadaptor.h
+SET(libmpris_MOC_HDRS
+ mprisfactory.h
+ mpris.h
+ rootobject.h
+ playerobject.h
)
-SET(libdbuscontrol_RCCS translations/translations.qrc)
+SET(libmpris_RCCS translations/translations.qrc)
-QT4_ADD_RESOURCES(libdbuscontrol_RCC_SRCS ${libdbuscontrol_RCCS})
+QT4_ADD_RESOURCES(libmpris_RCC_SRCS ${libmpris_RCCS})
-QT4_WRAP_CPP(libdbuscontrol_MOC_SRCS ${libdbuscontrol_MOC_HDRS})
+QT4_WRAP_CPP(libmpris_MOC_SRCS ${libmpris_MOC_HDRS})
# user interface
-# QT4_WRAP_UI(libdbuscontrol_UIS_H ${libdbuscontrol_UIS})
+# QT4_WRAP_UI(libmpris_UIS_H ${libmpris_UIS})
# Don't forget to include output directory, otherwise
# the UI file won't be wrapped!
include_directories(${CMAKE_CURRENT_BINARY_DIR})
-ADD_LIBRARY(dbuscontrol SHARED ${libdbuscontrol_SRCS} ${libdbuscontrol_MOC_SRCS} ${libdbuscontrol_RCC_SRCS})
-add_dependencies(dbuscontrol qmmpui libqmmp)
-target_link_libraries(dbuscontrol ${QT_LIBRARIES} -lqmmpui -lqmmp)
-install(TARGETS dbuscontrol DESTINATION ${LIB_DIR}/qmmp/General)
+ADD_LIBRARY(mpris SHARED ${libmpris_SRCS} ${libmpris_MOC_SRCS} ${libmpris_RCC_SRCS})
+add_dependencies(mpris qmmpui libqmmp)
+target_link_libraries(mpris ${QT_LIBRARIES} -lqmmpui -lqmmp)
+install(TARGETS mpris DESTINATION ${LIB_DIR}/qmmp/General)
diff --git a/src/plugins/General/dbuscontrol/dbuscontrol.cpp b/src/plugins/General/mpris/mpris.cpp
index bc734ab35..e2a6612ee 100644
--- a/src/plugins/General/dbuscontrol/dbuscontrol.cpp
+++ b/src/plugins/General/mpris/mpris.cpp
@@ -18,16 +18,21 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
-#include "dbusadaptor.h"
-#include "dbuscontrol.h"
+#include <QtDBus>
-DBUSControl::DBUSControl(QObject *parent)
+#include "playerobject.h"
+#include "rootobject.h"
+#include "mpris.h"
+
+MPRIS::MPRIS(QObject *parent)
: General(parent)
{
- new DBUSAdaptor(this);
+ PlayerObject *player = new PlayerObject(this);
+ RootObject *root = new RootObject(this);
QDBusConnection connection = QDBusConnection::sessionBus();
- connection.registerObject("/Qmmp", this);
- connection.registerService("org.qmmp.dbus");
+ connection.registerObject("/Player", player, QDBusConnection::ExportAllContents);
+ connection.registerObject("/", root, QDBusConnection::ExportAllContents);
+ connection.registerService("org.mpris.qmmp");
m_left = 0;
m_right = 0;
m_time = 0;
@@ -35,16 +40,16 @@ DBUSControl::DBUSControl(QObject *parent)
}
-DBUSControl::~DBUSControl()
+MPRIS::~MPRIS()
{
}
-int DBUSControl::leftVolume()
+int MPRIS::leftVolume()
{
return m_left;
}
-int DBUSControl::rightVolume()
+int MPRIS::rightVolume()
{
return m_right;
}
diff --git a/src/plugins/General/dbuscontrol/dbuscontrol.h b/src/plugins/General/mpris/mpris.h
index 9079f3e27..8b90d2881 100644
--- a/src/plugins/General/dbuscontrol/dbuscontrol.h
+++ b/src/plugins/General/mpris/mpris.h
@@ -17,26 +17,25 @@
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
-#ifndef STATUSICON_H
-#define STATUSICON_H
+#ifndef MPRIS_H
+#define MPRIS_H
#include <qmmpui/general.h>
-class Control;
class DBUSAdaptor;
/**
@author Ilya Kotov <forkotov02@hotmail.ru>
*/
-class DBUSControl : public General
+class MPRIS : public General
{
Q_OBJECT
public:
- DBUSControl(QObject *parent = 0);
+ MPRIS(QObject *parent = 0);
- ~DBUSControl();
+ ~MPRIS();
signals:
void stateChanged();
diff --git a/src/plugins/General/mpris/mpris.pro b/src/plugins/General/mpris/mpris.pro
new file mode 100644
index 000000000..af6fec72a
--- /dev/null
+++ b/src/plugins/General/mpris/mpris.pro
@@ -0,0 +1,46 @@
+include(../../plugins.pri)
+
+CONFIG += release \
+warn_on \
+plugin \
+ lib \
+ qdbus
+
+TARGET =$$PLUGINS_PREFIX/General/mpris
+QMAKE_CLEAN =$$PLUGINS_PREFIX/General/libmpris.so
+
+TEMPLATE = lib
+QMAKE_LIBDIR += ../../../../lib
+
+TRANSLATIONS = translations/mpris_plugin_cs.ts \
+ translations/mpris_plugin_de.ts \
+ translations/mpris_plugin_zh_CN.ts \
+ translations/mpris_plugin_zh_TW.ts \
+ translations/mpris_plugin_ru.ts \
+ translations/mpris_plugin_uk_UA.ts
+RESOURCES = translations/translations.qrc
+
+isEmpty(LIB_DIR){
+ LIB_DIR = /lib
+}
+target.path = $$LIB_DIR/qmmp/General
+INSTALLS += target
+#FORMS += settingsdialog.ui
+
+#RESOURCES += images/images.qrc
+
+
+HEADERS += mprisfactory.h \
+ mpris.h \
+ playerobject.h \
+ rootobject.h
+
+SOURCES += mprisfactory.cpp \
+ mpris.cpp \
+ playerobject.cpp \
+ rootobject.cpp
+
+INCLUDEPATH += ../../../../src
+
+LIBS += -lqmmpui -lqmmp
+
diff --git a/src/plugins/General/dbuscontrol/dbuscontrolfactory.cpp b/src/plugins/General/mpris/mprisfactory.cpp
index 88c071d05..c7011486d 100644
--- a/src/plugins/General/dbuscontrol/dbuscontrolfactory.cpp
+++ b/src/plugins/General/mpris/mprisfactory.cpp
@@ -20,42 +20,42 @@
#include <QtGui>
-#include "dbuscontrol.h"
-#include "dbuscontrolfactory.h"
+#include "mpris.h"
+#include "mprisfactory.h"
-const GeneralProperties DBUSControlFactory::properties() const
+const GeneralProperties MPRISFactory::properties() const
{
GeneralProperties properties;
- properties.name = tr("D-Bus Plugin");
+ properties.name = tr("MPRIS Plugin");
properties.hasAbout = TRUE;
properties.hasSettings = FALSE;
properties.visibilityControl = FALSE;
return properties;
}
-General *DBUSControlFactory::create(QObject *parent)
+General *MPRISFactory::create(QObject *parent)
{
- return new DBUSControl(parent);
+ return new MPRIS(parent);
}
-QDialog *DBUSControlFactory::createConfigDialog(QWidget *)
+QDialog *MPRISFactory::createConfigDialog(QWidget *)
{
return 0;
}
-void DBUSControlFactory::showAbout(QWidget *parent)
+void MPRISFactory::showAbout(QWidget *parent)
{
- QMessageBox::about (parent, tr("About D-Bus Plugin"),
- tr("Qmmp D-Bus Plugin")+"\n"+
+ QMessageBox::about (parent, tr("About MPRIS Plugin"),
+ tr("Qmmp MPRIS Plugin")+"\n"+
tr("Writen by: Ilya Kotov <forkotov02@hotmail.ru>"));
}
-QTranslator *DBUSControlFactory::createTranslator(QObject *parent)
+QTranslator *MPRISFactory::createTranslator(QObject *parent)
{
QTranslator *translator = new QTranslator(parent);
QString locale = QLocale::system().name();
- translator->load(QString(":/dbuscontrol_plugin_") + locale);
+ translator->load(QString(":/mpris_plugin_") + locale);
return translator;
}
-Q_EXPORT_PLUGIN(DBUSControlFactory)
+Q_EXPORT_PLUGIN(MPRISFactory)
diff --git a/src/plugins/General/dbuscontrol/dbuscontrolfactory.h b/src/plugins/General/mpris/mprisfactory.h
index af06b30bc..27708dd6e 100644
--- a/src/plugins/General/dbuscontrol/dbuscontrolfactory.h
+++ b/src/plugins/General/mpris/mprisfactory.h
@@ -17,8 +17,8 @@
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
-#ifndef STATUSICONFACTORY_H
-#define STATUSICONFACTORY_H
+#ifndef MPRISFACTORY_H
+#define MPRISFACTORY_H
/**
@author Ilya Kotov <forkotov02@hotmail.ru>
@@ -29,7 +29,7 @@
#include <qmmpui/general.h>
#include <qmmpui/generalfactory.h>
-class DBUSControlFactory : public QObject, public GeneralFactory
+class MPRISFactory : public QObject, public GeneralFactory
{
Q_OBJECT
Q_INTERFACES(GeneralFactory);
diff --git a/src/plugins/General/mpris/playerobject.cpp b/src/plugins/General/mpris/playerobject.cpp
new file mode 100644
index 000000000..21c296dec
--- /dev/null
+++ b/src/plugins/General/mpris/playerobject.cpp
@@ -0,0 +1,117 @@
+/***************************************************************************
+ * 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 <qmmp/soundcore.h>
+
+#include "playerobject.h"
+
+PlayerObject::PlayerObject(QObject *parent)
+ : QDBusAbstractAdaptor(parent)
+{
+ setAutoRelaySignals(TRUE);
+ m_core = SoundCore::instance();
+}
+
+PlayerObject::~PlayerObject()
+{}
+
+void PlayerObject::Next()
+{
+
+}
+
+void PlayerObject::Prev()
+{
+
+}
+
+void PlayerObject::Pause()
+{
+ m_core->pause();
+}
+
+void PlayerObject::Stop()
+{
+ m_core->stop();
+}
+
+void PlayerObject::Play()
+{
+ //m_core->play();
+}
+
+PlayerStatus PlayerObject::GetStatus()
+{
+ PlayerStatus st;
+ st.state = 2;
+ if (m_core->state() == Qmmp::Playing)
+ st.state = 0;
+ else if (m_core->state() == Qmmp::Paused)
+ st.state = 1;
+ st.random = 0; //TODO playlist support
+ st.repeat = 0;
+ st.repeatPlayList = 0;
+ return st;
+}
+
+QVariantMap PlayerObject::GetMetadata()
+{
+ QVariantMap map;
+
+ if (QFile::exists(m_core->metaData(Qmmp::URL)))
+ map.insert("location", "file://" +m_core->metaData(Qmmp::URL));
+ else
+ map.insert("location", m_core->metaData(Qmmp::URL));
+ map.insert("title", m_core->metaData(Qmmp::TITLE));
+ map.insert("artist", m_core->metaData(Qmmp::ARTIST));
+ map.insert("album", m_core->metaData(Qmmp::ALBUM));
+ map.insert("tracknumber", m_core->metaData(Qmmp::TRACK));
+ map.insert("time", m_core->length());
+ map.insert("mtime", m_core->length() * 1000);
+ map.insert("genre", m_core->metaData(Qmmp::GENRE));
+ map.insert("comment", m_core->metaData(Qmmp::COMMENT));
+ map.insert("audio-bitrate", m_core->bitrate());
+ map.insert("audio-samplerate", m_core->frequency());
+ map.insert("year", m_core->metaData(Qmmp::YEAR));
+ return map;
+}
+
+void PlayerObject::VolumeSet(int volume)
+{
+ int balance = (m_core->rightVolume() - m_core->leftVolume()) * 100/VolumeGet();
+ m_core->setVolume(volume - qMax(balance,0)*volume/100,
+ volume + qMin(balance,0)*volume/100);
+}
+
+int PlayerObject::VolumeGet()
+{
+ return qMax(m_core->leftVolume(), m_core->rightVolume());
+}
+
+void PlayerObject::PositionSet(int pos)
+{
+ m_core->seek(pos / 1000);
+}
+
+qint64 PlayerObject::PositionGet()
+{
+ return m_core->elapsed() * 1000;
+}
diff --git a/src/plugins/General/mpris/playerobject.h b/src/plugins/General/mpris/playerobject.h
new file mode 100644
index 000000000..09f112728
--- /dev/null
+++ b/src/plugins/General/mpris/playerobject.h
@@ -0,0 +1,77 @@
+/***************************************************************************
+ * 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 PLAYEROBJECT_H
+#define PLAYEROBJECT_H
+
+#include <QtDBus>
+#include <QString>
+#include <QVariant>
+
+class SoundCore;
+
+/**
+ @author Ilya Kotov <forkotov02@hotmail.ru>
+*/
+
+struct PlayerStatus
+{
+ int state; // 0 = Playing, 1 = Paused, 2 = Stopped.
+ int random; // 0 = Playing linearly, 1 = Playing randomly.
+ int repeat; // 0 = Go to the next element once the current has finished playing, 1 = Repeat the current element
+ int repeatPlayList; // 0 = Stop playing once the last element has been played, 1 = Never give up playing
+};
+
+
+class PlayerObject : public QDBusAbstractAdaptor
+{
+Q_OBJECT
+Q_CLASSINFO("D-Bus Interface", "org.freedesktop.MediaPlayer")
+
+public:
+ PlayerObject(QObject *parent = 0);
+
+ ~PlayerObject();
+
+public slots:
+ void Next();
+ void Prev();
+ void Pause();
+ void Stop();
+ void Play();
+ //void Repeat();
+ PlayerStatus GetStatus();
+ QVariantMap GetMetadata();
+ //GetCaps
+ void VolumeSet(int in0);
+ int VolumeGet();
+ void PositionSet(int in0);
+ qint64 PositionGet();
+
+signals:
+ //TrackChange
+ //StatusChange
+ //CapsChange
+
+private:
+ SoundCore *m_core;
+
+};
+
+#endif
diff --git a/src/plugins/General/mpris/rootobject.cpp b/src/plugins/General/mpris/rootobject.cpp
new file mode 100644
index 000000000..4869fd862
--- /dev/null
+++ b/src/plugins/General/mpris/rootobject.cpp
@@ -0,0 +1,49 @@
+/***************************************************************************
+ * 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 "rootobject.h"
+
+RootObject::RootObject(QObject *parent)
+ : QDBusAbstractAdaptor(parent)
+{
+}
+
+
+RootObject::~RootObject()
+{
+}
+
+QString RootObject::Identity()
+{
+ QString name = "Qmmp 0.3.0-svn";
+ return name;
+}
+
+Version RootObject::MprisVersion()
+{
+ struct Version v;
+ v.major = 1;
+ v.minor = 0;
+ return v;
+}
+
+void RootObject::Quit()
+{
+ QMetaObject::invokeMethod(parent(), "exit");
+}
diff --git a/src/plugins/General/mpris/rootobject.h b/src/plugins/General/mpris/rootobject.h
new file mode 100644
index 000000000..1bae78e4c
--- /dev/null
+++ b/src/plugins/General/mpris/rootobject.h
@@ -0,0 +1,52 @@
+/***************************************************************************
+ * 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 ROOTOBJECT_H
+#define ROOTOBJECT_H
+
+#include <QDBusAbstractAdaptor>
+#include <QString>
+
+/**
+ @author Ilya Kotov <forkotov02@hotmail.ru>
+*/
+
+
+struct Version
+{
+ quint16 major;
+ quint16 minor;
+};
+
+class RootObject : public QDBusAbstractAdaptor
+{
+Q_OBJECT
+Q_CLASSINFO("D-Bus Interface", "org.freedesktop.MediaPlayer")
+public:
+ RootObject(QObject *parent = 0);
+
+ ~RootObject();
+
+public slots:
+ QString Identity();
+ Version MprisVersion();
+ void Quit();
+};
+
+#endif