From 0912dcdd8496ac6f0b70c51087dbd522de6dd025 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Tue, 25 Nov 2008 20:39:00 +0000 Subject: 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 --- src/plugins/General/CMakeLists.txt | 2 +- src/plugins/General/General.pro | 2 +- src/plugins/General/dbuscontrol/CMakeLists.txt | 61 ------- src/plugins/General/dbuscontrol/dbusadaptor.cpp | 200 --------------------- src/plugins/General/dbuscontrol/dbusadaptor.h | 99 ---------- src/plugins/General/dbuscontrol/dbuscontrol.cpp | 51 ------ src/plugins/General/dbuscontrol/dbuscontrol.h | 58 ------ src/plugins/General/dbuscontrol/dbuscontrol.pro | 44 ----- .../General/dbuscontrol/dbuscontrolfactory.cpp | 61 ------- .../General/dbuscontrol/dbuscontrolfactory.h | 45 ----- .../translations/dbuscontrol_plugin_cs.ts | 26 --- .../translations/dbuscontrol_plugin_de.ts | 26 --- .../translations/dbuscontrol_plugin_ru.ts | 26 --- .../translations/dbuscontrol_plugin_uk_UA.ts | 27 --- .../translations/dbuscontrol_plugin_zh_CN.ts | 26 --- .../translations/dbuscontrol_plugin_zh_TW.ts | 26 --- .../dbuscontrol/translations/translations.qrc | 11 -- src/plugins/General/mpris/CMakeLists.txt | 63 +++++++ src/plugins/General/mpris/mpris.cpp | 56 ++++++ src/plugins/General/mpris/mpris.h | 57 ++++++ src/plugins/General/mpris/mpris.pro | 46 +++++ src/plugins/General/mpris/mprisfactory.cpp | 61 +++++++ src/plugins/General/mpris/mprisfactory.h | 45 +++++ src/plugins/General/mpris/playerobject.cpp | 117 ++++++++++++ src/plugins/General/mpris/playerobject.h | 77 ++++++++ src/plugins/General/mpris/rootobject.cpp | 49 +++++ src/plugins/General/mpris/rootobject.h | 52 ++++++ 27 files changed, 625 insertions(+), 789 deletions(-) delete mode 100644 src/plugins/General/dbuscontrol/CMakeLists.txt delete mode 100644 src/plugins/General/dbuscontrol/dbusadaptor.cpp delete mode 100644 src/plugins/General/dbuscontrol/dbusadaptor.h delete mode 100644 src/plugins/General/dbuscontrol/dbuscontrol.cpp delete mode 100644 src/plugins/General/dbuscontrol/dbuscontrol.h delete mode 100644 src/plugins/General/dbuscontrol/dbuscontrol.pro delete mode 100644 src/plugins/General/dbuscontrol/dbuscontrolfactory.cpp delete mode 100644 src/plugins/General/dbuscontrol/dbuscontrolfactory.h delete mode 100644 src/plugins/General/dbuscontrol/translations/dbuscontrol_plugin_cs.ts delete mode 100644 src/plugins/General/dbuscontrol/translations/dbuscontrol_plugin_de.ts delete mode 100644 src/plugins/General/dbuscontrol/translations/dbuscontrol_plugin_ru.ts delete mode 100644 src/plugins/General/dbuscontrol/translations/dbuscontrol_plugin_uk_UA.ts delete mode 100644 src/plugins/General/dbuscontrol/translations/dbuscontrol_plugin_zh_CN.ts delete mode 100644 src/plugins/General/dbuscontrol/translations/dbuscontrol_plugin_zh_TW.ts delete mode 100644 src/plugins/General/dbuscontrol/translations/translations.qrc create mode 100644 src/plugins/General/mpris/CMakeLists.txt create mode 100644 src/plugins/General/mpris/mpris.cpp create mode 100644 src/plugins/General/mpris/mpris.h create mode 100644 src/plugins/General/mpris/mpris.pro create mode 100644 src/plugins/General/mpris/mprisfactory.cpp create mode 100644 src/plugins/General/mpris/mprisfactory.h create mode 100644 src/plugins/General/mpris/playerobject.cpp create mode 100644 src/plugins/General/mpris/playerobject.h create mode 100644 src/plugins/General/mpris/rootobject.cpp create mode 100644 src/plugins/General/mpris/rootobject.h (limited to 'src') 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/CMakeLists.txt b/src/plugins/General/dbuscontrol/CMakeLists.txt deleted file mode 100644 index b646cee80..000000000 --- a/src/plugins/General/dbuscontrol/CMakeLists.txt +++ /dev/null @@ -1,61 +0,0 @@ -project(libdbuscontrol) - -cmake_minimum_required(VERSION 2.4.8 FATAL_ERROR) - -SET (QT_USE_QTDBUS TRUE) - -INCLUDE(FindQt4) - -include(${QT_USE_FILE}) - -if(COMMAND cmake_policy) -cmake_policy(SET CMP0003 NEW) -endif(COMMAND cmake_policy) - -# qt plugin -ADD_DEFINITIONS( -Wall ) -ADD_DEFINITIONS(${QT_DEFINITIONS}) -ADD_DEFINITIONS(-DQT_PLUGIN) -ADD_DEFINITIONS(-DQT_NO_DEBUG) -ADD_DEFINITIONS(-DQT_SHARED) -ADD_DEFINITIONS(-DQT_THREAD) - - - -include_directories(${CMAKE_CURRENT_BINARY_DIR}) - -# libqmmpui & libqmmp -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(libdbuscontrol_MOC_HDRS - dbuscontrolfactory.h - dbuscontrol.h - dbusadaptor.h -) - -SET(libdbuscontrol_RCCS translations/translations.qrc) - -QT4_ADD_RESOURCES(libdbuscontrol_RCC_SRCS ${libdbuscontrol_RCCS}) - -QT4_WRAP_CPP(libdbuscontrol_MOC_SRCS ${libdbuscontrol_MOC_HDRS}) - -# user interface - - -# QT4_WRAP_UI(libdbuscontrol_UIS_H ${libdbuscontrol_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) 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(parent())->info()->length(); -} - -int DBUSAdaptor::year() -{ - return 0;//qobject_cast(parent())->info()->year(); -} - -QString DBUSAdaptor::title() -{ - return QString();//qobject_cast(parent())->info()->title(); -} - -QString DBUSAdaptor::artist() -{ - return QString();//qobject_cast(parent())->info()->artist(); -} - -QString DBUSAdaptor::album() -{ - return QString();//qobject_cast(parent())->info()->album(); -} - -QString DBUSAdaptor::comment() -{ - return QString();//qobject_cast(parent())->info()->comment(); -} - -QString DBUSAdaptor::genre() -{ - return QString();//qobject_cast(parent())->info()->genre(); -} - -QString DBUSAdaptor::path() -{ - return QString();//qobject_cast(parent())->info()->path(); -} - -bool DBUSAdaptor::isPlaying() -{ - //return qobject_cast(parent())->state() == General::Playing; - return FALSE; -} - -bool DBUSAdaptor::isPaused() -{ - //return qobject_cast(parent())->state() == General::Paused; - return FALSE; -} - -bool DBUSAdaptor::isStopped() -{ - //return qobject_cast(parent())->state() == General::Stopped; - return FALSE; -} - -int DBUSAdaptor::elapsedTime() -{ - //return qobject_cast(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(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 - -class Control; - -/** - @author Ilya Kotov -*/ -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.cpp b/src/plugins/General/dbuscontrol/dbuscontrol.cpp deleted file mode 100644 index bc734ab35..000000000 --- a/src/plugins/General/dbuscontrol/dbuscontrol.cpp +++ /dev/null @@ -1,51 +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 "dbusadaptor.h" -#include "dbuscontrol.h" - -DBUSControl::DBUSControl(QObject *parent) - : General(parent) -{ - new DBUSAdaptor(this); - QDBusConnection connection = QDBusConnection::sessionBus(); - connection.registerObject("/Qmmp", this); - connection.registerService("org.qmmp.dbus"); - m_left = 0; - m_right = 0; - m_time = 0; - //m_state = General::Stopped; -} - - -DBUSControl::~DBUSControl() -{ -} - -int DBUSControl::leftVolume() -{ - return m_left; -} - -int DBUSControl::rightVolume() -{ - return m_right; -} - diff --git a/src/plugins/General/dbuscontrol/dbuscontrol.h b/src/plugins/General/dbuscontrol/dbuscontrol.h deleted file mode 100644 index 9079f3e27..000000000 --- a/src/plugins/General/dbuscontrol/dbuscontrol.h +++ /dev/null @@ -1,58 +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 STATUSICON_H -#define STATUSICON_H - - -#include - -class Control; -class DBUSAdaptor; - -/** - @author Ilya Kotov -*/ - -class DBUSControl : public General -{ -Q_OBJECT -public: - DBUSControl(QObject *parent = 0); - - ~DBUSControl(); - -signals: - void stateChanged(); - void timeChanged(); - void volumeChanged(); - void songChanged(); - -public slots: - int leftVolume(); - int rightVolume(); - -private: - DBUSAdaptor *m_adaptor; - int m_left, m_right; - uint m_state; - int m_time; -}; - -#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/dbuscontrolfactory.cpp b/src/plugins/General/dbuscontrol/dbuscontrolfactory.cpp deleted file mode 100644 index 88c071d05..000000000 --- a/src/plugins/General/dbuscontrol/dbuscontrolfactory.cpp +++ /dev/null @@ -1,61 +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 - -#include "dbuscontrol.h" -#include "dbuscontrolfactory.h" - -const GeneralProperties DBUSControlFactory::properties() const -{ - GeneralProperties properties; - properties.name = tr("D-Bus Plugin"); - properties.hasAbout = TRUE; - properties.hasSettings = FALSE; - properties.visibilityControl = FALSE; - return properties; -} - -General *DBUSControlFactory::create(QObject *parent) -{ - return new DBUSControl(parent); -} - -QDialog *DBUSControlFactory::createConfigDialog(QWidget *) -{ - return 0; -} - -void DBUSControlFactory::showAbout(QWidget *parent) -{ - QMessageBox::about (parent, tr("About D-Bus Plugin"), - tr("Qmmp D-Bus Plugin")+"\n"+ - tr("Writen by: Ilya Kotov ")); -} - -QTranslator *DBUSControlFactory::createTranslator(QObject *parent) -{ - QTranslator *translator = new QTranslator(parent); - QString locale = QLocale::system().name(); - translator->load(QString(":/dbuscontrol_plugin_") + locale); - return translator; -} - -Q_EXPORT_PLUGIN(DBUSControlFactory) diff --git a/src/plugins/General/dbuscontrol/dbuscontrolfactory.h b/src/plugins/General/dbuscontrol/dbuscontrolfactory.h deleted file mode 100644 index af06b30bc..000000000 --- a/src/plugins/General/dbuscontrol/dbuscontrolfactory.h +++ /dev/null @@ -1,45 +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 STATUSICONFACTORY_H -#define STATUSICONFACTORY_H - -/** - @author Ilya Kotov -*/ -#include -#include - -#include -#include - -class DBUSControlFactory : public QObject, public GeneralFactory -{ -Q_OBJECT -Q_INTERFACES(GeneralFactory); -public: - const GeneralProperties properties() const; - General *create(QObject *parent); - QDialog *createConfigDialog(QWidget *parent); - void showAbout(QWidget *parent); - QTranslator *createTranslator(QObject *parent); - -}; - -#endif 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 @@ - - - - DBUSControlFactory - - - D-Bus Plugin - Modul D-Bus - - - - About D-Bus Plugin - O modulu D-Bus - - - - Qmmp D-Bus Plugin - Modul Qmmp D-Bus - - - - Writen by: Ilya Kotov <forkotov02@hotmail.ru> - Autor: Ilja Kotov <forkotov02@hotmail.ru> - - - 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 @@ - - - - DBUSControlFactory - - - D-Bus Plugin - D-Bus Plugin - - - - About D-Bus Plugin - Über D-Bus Plugin - - - - Qmmp D-Bus Plugin - Qmmp D-Bus Plugin - - - - Writen by: Ilya Kotov <forkotov02@hotmail.ru> - Autor: Ilya Kotov <forkotov02@hotmail.ru> - - - 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 @@ - - - - DBUSControlFactory - - - D-Bus Plugin - Модуль D-Bus - - - - About D-Bus Plugin - О модуле D-bus - - - - Qmmp D-Bus Plugin - Модуль D-Bus для Qmmp - - - - Writen by: Ilya Kotov <forkotov02@hotmail.ru> - Разработчик: Илья Котов <forkotov02@hotmail.ru> - - - 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 @@ - - - - - DBUSControlFactory - - - D-Bus Plugin - Модуль D-Bus - - - - About D-Bus Plugin - Про модуль D-bus - - - - Qmmp D-Bus Plugin - Модуль D-Bus для Qmmp - - - - Writen by: Ilya Kotov <forkotov02@hotmail.ru> - Розробник: Ілля Котов <forkotov02@hotmail.ru> - - - 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 @@ - - - - DBUSControlFactory - - - D-Bus Plugin - D-Bus 插件 - - - - About D-Bus Plugin - 关于 D-Bus 插件 - - - - Qmmp D-Bus Plugin - Qmmp D-Bus 插件 - - - - Writen by: Ilya Kotov <forkotov02@hotmail.ru> - 作者:Ilya Kotov <forkotov02@hotmail.ru> - - - 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 @@ - - - - DBUSControlFactory - - - D-Bus Plugin - D-Bus 插件 - - - - About D-Bus Plugin - 關於 D-Bus 插件 - - - - Qmmp D-Bus Plugin - Qmmp D-Bus 插件 - - - - Writen by: Ilya Kotov <forkotov02@hotmail.ru> - 作者:Ilya Kotov <forkotov02@hotmail.ru> - - - 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 @@ - - - - dbuscontrol_plugin_cs.qm - dbuscontrol_plugin_de.qm - dbuscontrol_plugin_zh_CN.qm - dbuscontrol_plugin_zh_TW.qm - dbuscontrol_plugin_ru.qm - dbuscontrol_plugin_uk_UA.qm - - diff --git a/src/plugins/General/mpris/CMakeLists.txt b/src/plugins/General/mpris/CMakeLists.txt new file mode 100644 index 000000000..d82bd30f3 --- /dev/null +++ b/src/plugins/General/mpris/CMakeLists.txt @@ -0,0 +1,63 @@ +project(libmpris) + +cmake_minimum_required(VERSION 2.4.8 FATAL_ERROR) + +SET (QT_USE_QTDBUS TRUE) + +INCLUDE(FindQt4) + +include(${QT_USE_FILE}) + +if(COMMAND cmake_policy) +cmake_policy(SET CMP0003 NEW) +endif(COMMAND cmake_policy) + +# qt plugin +ADD_DEFINITIONS( -Wall ) +ADD_DEFINITIONS(${QT_DEFINITIONS}) +ADD_DEFINITIONS(-DQT_PLUGIN) +ADD_DEFINITIONS(-DQT_NO_DEBUG) +ADD_DEFINITIONS(-DQT_SHARED) +ADD_DEFINITIONS(-DQT_THREAD) + + + +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +# libqmmpui & libqmmp +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../) +link_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../qmmpui) +link_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../qmmp) + +SET(libmpris_SRCS + mpris.cpp + mprisfactory.cpp + rootobject.cpp + playerobject.cpp +) + +SET(libmpris_MOC_HDRS + mprisfactory.h + mpris.h + rootobject.h + playerobject.h +) + +SET(libmpris_RCCS translations/translations.qrc) + +QT4_ADD_RESOURCES(libmpris_RCC_SRCS ${libmpris_RCCS}) + +QT4_WRAP_CPP(libmpris_MOC_SRCS ${libmpris_MOC_HDRS}) + +# user interface + + +# 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(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/mpris/mpris.cpp b/src/plugins/General/mpris/mpris.cpp new file mode 100644 index 000000000..e2a6612ee --- /dev/null +++ b/src/plugins/General/mpris/mpris.cpp @@ -0,0 +1,56 @@ +/*************************************************************************** + * 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 + +#include "playerobject.h" +#include "rootobject.h" +#include "mpris.h" + +MPRIS::MPRIS(QObject *parent) + : General(parent) +{ + PlayerObject *player = new PlayerObject(this); + RootObject *root = new RootObject(this); + QDBusConnection connection = QDBusConnection::sessionBus(); + 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; + //m_state = General::Stopped; +} + + +MPRIS::~MPRIS() +{ +} + +int MPRIS::leftVolume() +{ + return m_left; +} + +int MPRIS::rightVolume() +{ + return m_right; +} + diff --git a/src/plugins/General/mpris/mpris.h b/src/plugins/General/mpris/mpris.h new file mode 100644 index 000000000..8b90d2881 --- /dev/null +++ b/src/plugins/General/mpris/mpris.h @@ -0,0 +1,57 @@ +/*************************************************************************** + * 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 MPRIS_H +#define MPRIS_H + + +#include + +class DBUSAdaptor; + +/** + @author Ilya Kotov +*/ + +class MPRIS : public General +{ +Q_OBJECT +public: + MPRIS(QObject *parent = 0); + + ~MPRIS(); + +signals: + void stateChanged(); + void timeChanged(); + void volumeChanged(); + void songChanged(); + +public slots: + int leftVolume(); + int rightVolume(); + +private: + DBUSAdaptor *m_adaptor; + int m_left, m_right; + uint m_state; + int m_time; +}; + +#endif 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/mpris/mprisfactory.cpp b/src/plugins/General/mpris/mprisfactory.cpp new file mode 100644 index 000000000..c7011486d --- /dev/null +++ b/src/plugins/General/mpris/mprisfactory.cpp @@ -0,0 +1,61 @@ +/*************************************************************************** + * 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 + +#include "mpris.h" +#include "mprisfactory.h" + +const GeneralProperties MPRISFactory::properties() const +{ + GeneralProperties properties; + properties.name = tr("MPRIS Plugin"); + properties.hasAbout = TRUE; + properties.hasSettings = FALSE; + properties.visibilityControl = FALSE; + return properties; +} + +General *MPRISFactory::create(QObject *parent) +{ + return new MPRIS(parent); +} + +QDialog *MPRISFactory::createConfigDialog(QWidget *) +{ + return 0; +} + +void MPRISFactory::showAbout(QWidget *parent) +{ + QMessageBox::about (parent, tr("About MPRIS Plugin"), + tr("Qmmp MPRIS Plugin")+"\n"+ + tr("Writen by: Ilya Kotov ")); +} + +QTranslator *MPRISFactory::createTranslator(QObject *parent) +{ + QTranslator *translator = new QTranslator(parent); + QString locale = QLocale::system().name(); + translator->load(QString(":/mpris_plugin_") + locale); + return translator; +} + +Q_EXPORT_PLUGIN(MPRISFactory) diff --git a/src/plugins/General/mpris/mprisfactory.h b/src/plugins/General/mpris/mprisfactory.h new file mode 100644 index 000000000..27708dd6e --- /dev/null +++ b/src/plugins/General/mpris/mprisfactory.h @@ -0,0 +1,45 @@ +/*************************************************************************** + * 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 MPRISFACTORY_H +#define MPRISFACTORY_H + +/** + @author Ilya Kotov +*/ +#include +#include + +#include +#include + +class MPRISFactory : public QObject, public GeneralFactory +{ +Q_OBJECT +Q_INTERFACES(GeneralFactory); +public: + const GeneralProperties properties() const; + General *create(QObject *parent); + QDialog *createConfigDialog(QWidget *parent); + void showAbout(QWidget *parent); + QTranslator *createTranslator(QObject *parent); + +}; + +#endif 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 +#include + +#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 +#include +#include + +class SoundCore; + +/** + @author Ilya Kotov +*/ + +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 +#include + +/** + @author Ilya Kotov +*/ + + +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 -- cgit v1.2.3-13-gbd6f