diff options
| author | 2008-11-17 11:51:41 +0000 | |
|---|---|---|
| committer | 2008-11-17 11:51:41 +0000 | |
| commit | fe80ec81af1e63e9801c406f8c3842ae33415c69 (patch) | |
| tree | a36634c68fdeb404cfe8595bf386d973ae5cb6c7 /src/modules | |
| parent | added some comment to explain changes (diff) | |
| download | KVIrc-fe80ec81af1e63e9801c406f8c3842ae33415c69.tar.gz KVIrc-fe80ec81af1e63e9801c406f8c3842ae33415c69.tar.bz2 KVIrc-fe80ec81af1e63e9801c406f8c3842ae33415c69.zip | |
removed old interfaces to mediaplayer based on kde3/dcop
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@2874 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src/modules')
| -rw-r--r-- | src/modules/mediaplayer/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/modules/mediaplayer/libkvimediaplayer.cpp | 5 | ||||
| -rw-r--r-- | src/modules/mediaplayer/mp_amarokinterface.cpp | 196 | ||||
| -rw-r--r-- | src/modules/mediaplayer/mp_amarokinterface.h | 76 | ||||
| -rw-r--r-- | src/modules/mediaplayer/mp_dcopinterface.cpp | 224 | ||||
| -rw-r--r-- | src/modules/mediaplayer/mp_dcopinterface.h | 57 | ||||
| -rw-r--r-- | src/modules/mediaplayer/mp_jukinterface.cpp | 184 | ||||
| -rw-r--r-- | src/modules/mediaplayer/mp_jukinterface.h | 77 |
8 files changed, 2 insertions, 819 deletions
diff --git a/src/modules/mediaplayer/CMakeLists.txt b/src/modules/mediaplayer/CMakeLists.txt index b50fef72b..68bbe0935 100644 --- a/src/modules/mediaplayer/CMakeLists.txt +++ b/src/modules/mediaplayer/CMakeLists.txt @@ -2,8 +2,6 @@ SET(kvimediaplayer_SRCS libkvimediaplayer.cpp - mp_amarokinterface.cpp - mp_dcopinterface.cpp mp_interface.cpp mp_jukinterface.cpp mp_mp3.cpp diff --git a/src/modules/mediaplayer/libkvimediaplayer.cpp b/src/modules/mediaplayer/libkvimediaplayer.cpp index 861932fcc..a4b40da0b 100644 --- a/src/modules/mediaplayer/libkvimediaplayer.cpp +++ b/src/modules/mediaplayer/libkvimediaplayer.cpp @@ -25,7 +25,6 @@ //============================================================================= #include "mp_interface.h" -#include "mp_amarokinterface.h" #include "mp_amipinterface.h" #include "mp_mprisinterface.h" #include "mp_jukinterface.h" @@ -1489,7 +1488,8 @@ MP_KVS_FUNCTION(status) scripts). The module has replaced the old mediaplayer module which after years of development had developed some design flaws and needed a complete rewrite. At the moment of writing the supported players are: xmms (unix), audacious (unix), winamp (windows), - amarok (kde) and juk (kde). You choose the player interface by either setting + every player supported by the amip project (windows), every player using the mpris interface + (amarok2, juk under kde). You choose the player interface by either setting the option in the settings dialog, by manually setting [cmd]option[/cmd] stringPreferredMediaPlayer or by running [cmd]mediaplayer.detect[/cmd] that will guess the media player interface for you.[br] If you're going to use the Winamp media player then you must install the "gen_kvirc.dll" plugin @@ -1621,7 +1621,6 @@ static bool mediaplayer_module_init( KviModule * m ) #endif #ifdef COMPILE_KDE3_SUPPORT - g_pDescriptorList->append(MP_CREATE_DESCRIPTOR(KviAmarokInterface)); g_pDescriptorList->append(MP_CREATE_DESCRIPTOR(KviJukInterface)); #endif diff --git a/src/modules/mediaplayer/mp_amarokinterface.cpp b/src/modules/mediaplayer/mp_amarokinterface.cpp deleted file mode 100644 index e958e8fc5..000000000 --- a/src/modules/mediaplayer/mp_amarokinterface.cpp +++ /dev/null @@ -1,196 +0,0 @@ -//============================================================================= -// -// File : mp_amarokinterface.cpp -// Creation date : Sun 27 Mar 2005 16:55:09 by Szymon Stefanek -// -// This file is part of the KVIrc IRC client distribution -// Copyright (C) 2005-2008 Szymon Stefanek <pragma at kvirc dot net> -// -// 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 opinion) 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 "mp_amarokinterface.h" - -#ifdef COMPILE_KDE3_SUPPORT - -#include "kvi_app.h" -#include "kvi_locale.h" - -#include "dcopclient.h" -#include "kurl.h" - -#include <QDataStream> -#include <QLinkedList> - -MP_IMPLEMENT_DESCRIPTOR( - KviAmarokInterface, - "amarok", - __tr2qs_ctx( - "An interface to the AmaroK KDE media player." - , - "mediaplayer" - ) -) - - -KviAmarokInterface::KviAmarokInterface() - : KviDCOPHelper(true, "amarok") -{ -} - -KviAmarokInterface::~KviAmarokInterface() -{ -} - -int KviAmarokInterface::detect(bool bStart){ return detectApp("amarok",bStart,95,99); } - -bool KviAmarokInterface::prev(){ return voidRetVoidDCOPCall("player","prev()"); } -bool KviAmarokInterface::next(){ return voidRetVoidDCOPCall("player","next()"); } -bool KviAmarokInterface::play(){ return voidRetVoidDCOPCall("player","play()"); } -bool KviAmarokInterface::stop(){ return voidRetVoidDCOPCall("player","stop()"); } -bool KviAmarokInterface::pause(){ return voidRetVoidDCOPCall("player","pause()"); } -bool KviAmarokInterface::mute(){ return voidRetVoidDCOPCall("player","mute()"); } -bool KviAmarokInterface::quit(){ return voidRetVoidDCOPCall("MainApplication-Interface","quit()"); } - -bool KviAmarokInterface::jumpTo(kvs_int_t &iPos) -{ - return voidRetIntDCOPCall("player","seek(int)",iPos/1000); -} -bool KviAmarokInterface::setVol(kvs_int_t &iVol) -{ - return voidRetIntDCOPCall("player","setVolume(int)",100*iVol/255); -} - -#define MP_DCOP_STRING_CALL(_fncname,_iface,_fnc) \ -QString KviAmarokInterface::_fncname() \ -{ \ - QString ret; \ - if(!stringRetVoidDCOPCall(_iface,_fnc,ret))return false; \ - return ret; \ -} - -MP_DCOP_STRING_CALL(nowPlaying,"player","nowPlaying()") -MP_DCOP_STRING_CALL(artist,"player","artist()") -MP_DCOP_STRING_CALL(title,"player","title()") -MP_DCOP_STRING_CALL(genre,"player","genre()") -MP_DCOP_STRING_CALL(year,"player","year()") -MP_DCOP_STRING_CALL(comment,"player","comment()") -MP_DCOP_STRING_CALL(album,"player","album()") - -int KviAmarokInterface::getVol() -{ - int ret; - if(!intRetVoidDCOPCall("player","getVolume()",ret))return false; - return ret * 255 / 100; -} - -int KviAmarokInterface::sampleRate() -{ - int ret; - if(!intRetVoidDCOPCall("player","sampleRate()",ret))return false; - return ret; -} - -int KviAmarokInterface::length() -{ - int ret; - if(!intRetVoidDCOPCall("player","trackTotalTime()",ret))return false; - return ret * 1000; -} - -int KviAmarokInterface::position() -{ - int ret; - if(!intRetVoidDCOPCall("player","trackCurrentTime()",ret))return false; - return ret * 1000; -} - -bool KviAmarokInterface::getRepeat() -{ - bool ret; - if(!boolRetVoidDCOPCall("player","repeatTrackStatus()",ret))return false; - return ret; -} - -bool KviAmarokInterface::getShuffle() -{ - bool ret; - if(!boolRetVoidDCOPCall("player","randomModeStatus()",ret))return false; - return ret; -} - -bool KviAmarokInterface::setRepeat(bool &bVal) -{ - return voidRetBoolDCOPCall("player","enableRepeatTrack(bool)",bVal); -} - -bool KviAmarokInterface::setShuffle(bool &bVal) -{ - return voidRetBoolDCOPCall("player","enableRandomMode(bool)",bVal); -} - -KviMediaPlayerInterface::PlayerStatus KviAmarokInterface::status() -{ - int ret; - if(!intRetVoidDCOPCall("player","status()",ret))return KviMediaPlayerInterface::Unknown; - switch(ret) - { - case 0: - return KviMediaPlayerInterface::Stopped; - break; - case 1: - return KviMediaPlayerInterface::Paused; - break; - case 2: - return KviMediaPlayerInterface::Playing; - break; - default: - return KviMediaPlayerInterface::Unknown; - break; - } - return KviMediaPlayerInterface::Unknown; -} - -QString KviAmarokInterface::mrl() -{ - QString ret; - if(!stringRetVoidDCOPCall("player","encodedURL()",ret))return false; - KURL url(ret); - return url.prettyURL(); -} - -int KviAmarokInterface::bitRate() -{ - QString ret; - if(!stringRetVoidDCOPCall("player","bitrate()",ret))return false; - int a = ret.toInt(); - return a; -} - -bool KviAmarokInterface::playMrl(const QString &mrl) -{ - QString title; - QByteArray data, replyData; - KviQCString replyType; - QDataStream arg(data,IO_WriteOnly); - arg << KURL(mrl); - if(!g_pApp->dcopClient()->call(m_szAppId,"playlist","playMedia(KURL)",data,replyType,replyData)) - return false; - return true; -} - - -#endif //COMPILE_KDE_SUPPORT diff --git a/src/modules/mediaplayer/mp_amarokinterface.h b/src/modules/mediaplayer/mp_amarokinterface.h deleted file mode 100644 index df6b569b2..000000000 --- a/src/modules/mediaplayer/mp_amarokinterface.h +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef _MP_AMAROKINTERFACE_H_ -#define _MP_AMAROKINTERFACE_H_ -//============================================================================= -// -// File : mp_amarokinterface.h -// Creation date : Sun 27 Mar 2005 16:55:09 by Szymon Stefanek -// -// This file is part of the KVIrc IRC client distribution -// Copyright (C) 2005 Szymon Stefanek <pragma at kvirc dot net> -// -// 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 opinion) 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 "kvi_settings.h" - - -#ifdef COMPILE_KDE3_SUPPORT - - #include "kvi_dcophelper.h" - #include "mp_interface.h" - - class KviAmarokInterface : public KviMediaPlayerInterface, private KviDCOPHelper - { - public: - KviAmarokInterface(); - ~KviAmarokInterface(); - public: - virtual int detect(bool bStart); - virtual bool prev(); - virtual bool next(); - virtual bool play(); - virtual bool stop(); - virtual bool pause(); - virtual bool jumpTo(kvs_int_t &iPos); - virtual bool setVol(kvs_int_t &iVol); - virtual bool mute(); - virtual int getVol(); - virtual bool quit(); - virtual QString nowPlaying(); - virtual QString mrl(); - virtual QString title(); - virtual QString artist(); - virtual QString genre(); - virtual QString comment(); - virtual QString year(); - virtual QString album(); - virtual int position(); - virtual int length(); - virtual int bitRate(); - virtual int sampleRate(); - virtual bool playMrl(const QString &mrl); - virtual KviMediaPlayerInterface::PlayerStatus status(); - virtual bool getRepeat(); - virtual bool getShuffle(); - virtual bool setRepeat(bool &bVal); - virtual bool setShuffle(bool &bVal); - }; - - MP_DECLARE_DESCRIPTOR(KviAmarokInterface) - -#endif //COMPILE_KDE_SUPPORT - -#endif //!_MP_AMAROKINTERFACE_H_ diff --git a/src/modules/mediaplayer/mp_dcopinterface.cpp b/src/modules/mediaplayer/mp_dcopinterface.cpp deleted file mode 100644 index e21d53809..000000000 --- a/src/modules/mediaplayer/mp_dcopinterface.cpp +++ /dev/null @@ -1,224 +0,0 @@ -//============================================================================= -// -// File : mp_dcopinterface.cpp -// Creation date : Sun 27 Mar 2005 16:56:21 by Szymon Stefanek -// -// This file is part of the KVIrc IRC client distribution -// Copyright (C) 2005-2008 Szymon Stefanek <pragma at kvirc dot net> -// -// 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 opinion) 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 "mp_dcopinterface.h" - -#ifdef COMPILE_KDE3_SUPPORT - -#include "dcopclient.h" - -#include <QDataStream> -#include <QLinkedList> - -#include "kvi_app.h" -#include "kvi_thread.h" - -KviMediaPlayerDCOPInterface::KviMediaPlayerDCOPInterface(const KviQCString &szAppId) -: KviMediaPlayerInterface() -{ - m_szAppId = szAppId; -} - -KviMediaPlayerDCOPInterface::~KviMediaPlayerDCOPInterface() -{ -} - -bool KviMediaPlayerDCOPInterface::ensureAppRunning(const QString &szApp) -{ - if(findRunningApp(m_szAppId))return true; - return startApp(m_szAppId,400); -} - - -bool KviMediaPlayerDCOPInterface::simpleDCOPCall(const KviQCString &szObj,const KviQCString &szFunc) -{ - if(!ensureAppRunning(m_szAppId))return false; - QByteArray data; - return g_pApp->dcopClient()->send(m_szAppId,szObj,szFunc,data); -} - -bool KviMediaPlayerDCOPInterface::boolDCOPCall(const KviQCString &szObj,const KviQCString &szFunc,bool bVal) -{ - if(!ensureAppRunning(m_szAppId))return false; - QByteArray data; - QDataStream arg(data, IO_WriteOnly); - arg << bVal; - return g_pApp->dcopClient()->send(m_szAppId,szObj,szFunc,data); -} - -bool KviMediaPlayerDCOPInterface::intDCOPCall(const KviQCString &szObj,const KviQCString &szFunc,int iVal) -{ - if(!ensureAppRunning(m_szAppId))return false; - QByteArray data; - QDataStream arg(data, IO_WriteOnly); - arg << iVal; - return g_pApp->dcopClient()->send(m_szAppId,szObj,szFunc,data); -} - -bool KviMediaPlayerDCOPInterface::floatDCOPCall(const KviQCString &szObj,const KviQCString &szFunc,float fVal) -{ - if(!ensureAppRunning(m_szAppId))return false; - QByteArray data; - QDataStream arg(data, IO_WriteOnly); - arg << fVal; - return g_pApp->dcopClient()->send(m_szAppId,szObj,szFunc,data); -} - -bool KviMediaPlayerDCOPInterface::stringDCOPCall(const KviQCString &szObj,const KviQCString &szFunc,QString szVal) -{ - if(!ensureAppRunning(m_szAppId))return false; - QByteArray data; - QDataStream arg(data, IO_WriteOnly); - arg << szVal; - return g_pApp->dcopClient()->send(m_szAppId,szObj,szFunc,data); -} - -bool KviMediaPlayerDCOPInterface::stringRetDCOPCall(const KviQCString &szObj,const KviQCString &szFunc,QString &ret) -{ - if(!ensureAppRunning(m_szAppId))return false; - QString title; - QByteArray data, replyData; - KviQCString replyType; - if(!g_pApp->dcopClient()->call(m_szAppId,szObj,szFunc,data,replyType,replyData)) - return false; - QDataStream reply( replyData, IO_ReadOnly ); - if(replyType == "QString") - { - reply >> ret; - return true; - } - return false; -} - -bool KviMediaPlayerDCOPInterface::intRetDCOPCall(const KviQCString &szObj,const KviQCString &szFunc,int &ret) -{ - if(!ensureAppRunning(m_szAppId))return false; - QString title; - QByteArray data, replyData; - KviQCString replyType; - if(!g_pApp->dcopClient()->call(m_szAppId,szObj,szFunc,data,replyType,replyData)) - return false; - QDataStream reply( replyData, IO_ReadOnly ); - if(replyType == "int") - { - reply >> ret; - return true; - } - return false; -} - -bool KviMediaPlayerDCOPInterface::boolRetDCOPCall(const KviQCString &szObj,const KviQCString &szFunc,bool &ret) -{ - if(!ensureAppRunning(m_szAppId))return false; - QString title; - QByteArray data, replyData; - KviQCString replyType; - if(!g_pApp->dcopClient()->call(m_szAppId,szObj,szFunc,data,replyType,replyData)) - return false; - QDataStream reply( replyData, IO_ReadOnly ); - if(replyType == "bool") - { - reply >> ret; - return true; - } - return false; -} - - -bool KviMediaPlayerDCOPInterface::findRunningApp(const QString &szApp) -{ - QLinkedList<KviQCString> allApps = g_pApp->dcopClient()->registeredApplications(); - QLinkedList<KviQCString>::iterator iterator; - KviQCString sz = szApp.toLocal8Bit(); - for(iterator = allApps.begin();iterator != allApps.end();iterator++) - { - if(*iterator == sz)return true; - } - return false; -} - -int KviMediaPlayerDCOPInterface::detectApp(const QString &szApp,bool bStart,int iScoreWhenFound,int iScoreWhenStarted) -{ - // lookup the amarok interface - if(!g_pApp->dcopClient())return 0; - if(findRunningApp(szApp))return 95; // found a running amarok, no need to run further - - // no amarok app found - if(bStart) - { - // try to start it - if(!startApp(szApp,5000))return 10; // very low possibility - return findRunningApp(szApp) ? 99 : 0; // try to find it again - } - - return 30; // it still might be installed on the system but we're just unable to start it... -} - - -bool KviMediaPlayerDCOPInterface::startApp(const QString &szApp,int iWaitMSecs) -{ - // we could use KApplication::startServiceByDesktopName here - // but we want to be able to wait a defined amount of time - QStringList tmp; - QByteArray data, replyData; - KviQCString replyType; - QDataStream arg(data, IO_WriteOnly); - arg << szApp << tmp; - if(!g_pApp->dcopClient()->call( - "klauncher", - "klauncher", - "start_service_by_desktop_name(QString,QStringList)", - data, - replyType, - replyData)) - { - return false; - } else { - QDataStream reply(replyData, IO_ReadOnly); - if(replyType != "serviceResult")return false; - int result; - KviQCString dcopName; - QString error; - reply >> result >> dcopName >> error; - if(result != 0)return false; - } - // ok , we seem to have started it.. but it might take some seconds - // for the app to get registered - // we wait up to five seconds - if(iWaitMSecs > 0) - { - int i = 0; - while(i < iWaitMSecs) - { - if(findRunningApp(szApp))return true; - KviThread::msleep(100); - i += 100; - } - return findRunningApp(szApp); - } - return true; -} - - -#endif //COMPILE_KDE_SUPPORT diff --git a/src/modules/mediaplayer/mp_dcopinterface.h b/src/modules/mediaplayer/mp_dcopinterface.h deleted file mode 100644 index eea0f0f06..000000000 --- a/src/modules/mediaplayer/mp_dcopinterface.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef _MP_DCOPINTERFACE_H_ -#define _MP_DCOPINTERFACE_H_ -//============================================================================= -// -// File : mp_dcopinterface.h -// Creation date : Sun 27 Mar 2005 16:56:21 by Szymon Stefanek -// -// This file is part of the KVIrc IRC client distribution -// Copyright (C) 2005-2008 Szymon Stefanek <pragma at kvirc dot net> -// -// 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 opinion) 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 "kvi_settings.h" - -#ifdef COMPILE_KDE3_SUPPORT - -#include "mp_interface.h" - -class KviMediaPlayerDCOPInterface : public KviMediaPlayerInterface -{ -public: - KviMediaPlayerDCOPInterface(const KviQCString &szAppId); - ~KviMediaPlayerDCOPInterface(); -protected: - KviQCString m_szAppId; -protected: - bool ensureAppRunning(const QString &szApp); - bool findRunningApp(const QString &szApp); - bool startApp(const QString &szApp,int iWaitMSecs = 0); - int detectApp(const QString &szApp,bool bStart,int iScoreWhenFound,int iScoreWhenStarted); - bool simpleDCOPCall(const KviQCString &szObj,const KviQCString &szFunc); - bool intDCOPCall(const KviQCString &szObj,const KviQCString &szFunc,int iVal); - bool boolDCOPCall(const KviQCString &szObj,const KviQCString &szFunc,bool bVal); - bool stringDCOPCall(const KviQCString &szObj,const KviQCString &szFunc,QString szVal); - bool floatDCOPCall(const KviQCString &szObj,const KviQCString &szFunc,float fVal); - bool stringRetDCOPCall(const KviQCString &szObj,const KviQCString &szFunc,QString &ret); - bool intRetDCOPCall(const KviQCString &szObj,const KviQCString &szFunc,int &ret); - bool boolRetDCOPCall(const KviQCString &szObj,const KviQCString &szFunc,bool &ret); -}; - -#endif //COMPILE_KDE_SUPPORT - -#endif //!_MP_DCOPINTERFACE_H_ diff --git a/src/modules/mediaplayer/mp_jukinterface.cpp b/src/modules/mediaplayer/mp_jukinterface.cpp deleted file mode 100644 index 184d8f5d6..000000000 --- a/src/modules/mediaplayer/mp_jukinterface.cpp +++ /dev/null @@ -1,184 +0,0 @@ -//============================================================================= -// -// File : mp_jukinterface.cpp -// Creation date : Tue 29 Mar 2005 01:38:34 by Szymon Stfeanek -// -// This file is part of the KVIrc IRC client distribution -// Copyright (C) 2005-2008 Szymon Stfeanek <pragma at kvirc dot net> -// -// 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 opinion) 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 "mp_jukinterface.h" - -#ifdef COMPILE_KDE3_SUPPORT - -#include "kvi_app.h" -#include "kvi_locale.h" - -#include "dcopclient.h" -#include "kurl.h" - -#include <QDataStream> -#include <QLinkedList> - -// the dcop interface of this player is incomplete :( - -MP_IMPLEMENT_DESCRIPTOR( - KviJukInterface, - "juk", - __tr2qs_ctx( - "An interface to the Juk KDE media player." - , - "mediaplayer" - ) -) - - -KviJukInterface::KviJukInterface() - : KviDCOPHelper(true, "amarok") -{ -} - -KviJukInterface::~KviJukInterface() -{ -} - -int KviJukInterface::detect(bool bStart){ return detectApp("juk",bStart,90,96); } - -bool KviJukInterface::prev(){ return voidRetVoidDCOPCall("Player","forward()"); } -bool KviJukInterface::next(){ return voidRetVoidDCOPCall("Player","back()"); } -bool KviJukInterface::play(){ return voidRetVoidDCOPCall("Player","play()"); } -bool KviJukInterface::stop(){ return voidRetVoidDCOPCall("Player","stop()"); } -bool KviJukInterface::pause(){ return voidRetVoidDCOPCall("Player","pause()"); } -bool KviJukInterface::quit(){ return voidRetVoidDCOPCall("MainApplication-Interface","quit()"); } - -bool KviJukInterface::setVol(kvs_int_t &iVol) -{ - return voidRetFloatDCOPCall("player","setVolume(float)",(float)(iVol)/255.); -} - -bool KviJukInterface::jumpTo(kvs_int_t &iPos) -{ - return voidRetIntDCOPCall("player","seek(int)",iPos/1000); -} - -bool KviJukInterface::getShuffle() -{ - QString szMode; - if(!stringRetVoidDCOPCall("player","randomPlayMode()",szMode))return false; - return (szMode != "NoRandom"); -} - -bool KviJukInterface::setShuffle(bool &bVal) -{ - QString szMode; - if(bVal) - { - szMode = "Random"; - } else { - szMode = "NoRandom"; - } - if(!voidRetStringDCOPCall("player","setRandomPlayMode(QString)",szMode))return false; - return true; -} - - -#define MP_DCOP_STRING_CALL(_fncname,_iface,_fnc) \ -QString KviJukInterface::_fncname() \ -{ \ - QString ret; \ - if(!stringRetVoidDCOPCall(_iface,_fnc,ret))return false; \ - return ret; \ -} - -MP_DCOP_STRING_CALL(nowPlaying,"Player","playingString()") - -/* - FIXME: there is trackProperty(propertyName) for these... -MP_DCOP_STRING_CALL(artist,"player","artist()") -MP_DCOP_STRING_CALL(title,"player","title()") -MP_DCOP_STRING_CALL(genre,"player","genre()") -MP_DCOP_STRING_CALL(year,"player","year()") -MP_DCOP_STRING_CALL(comment,"player","comment()") -MP_DCOP_STRING_CALL(album,"player","album()") - - -int KviJukInterface::sampleRate() -{ - int ret; - if(!intRetVoidDCOPCall("player","sampleRate()",ret))return false; - return ret; -} -*/ - -int KviJukInterface::length() -{ - int ret; - if(!intRetVoidDCOPCall("player","totalTime()",ret))return false; - return ret * 1000; -} - -int KviJukInterface::position() -{ - int ret; - if(!intRetVoidDCOPCall("player","currentTime()",ret))return false; - return ret * 1000; -} - -KviMediaPlayerInterface::PlayerStatus KviJukInterface::status() -{ - int ret; - if(!intRetVoidDCOPCall("player","status()",ret))return KviMediaPlayerInterface::Unknown; - switch(ret) - { - case 0: - return KviMediaPlayerInterface::Stopped; - break; - case 1: - return KviMediaPlayerInterface::Paused; - break; - case 2: - return KviMediaPlayerInterface::Playing; - break; - default: - return KviMediaPlayerInterface::Unknown; - break; - } - return KviMediaPlayerInterface::Unknown; -} - -QString KviJukInterface::mrl() -{ - // ugh :/ - QString ret; - return ret; -} - -bool KviJukInterface::playMrl(const QString &mrl) -{ - QString title; - QByteArray data, replyData; - KviQCString replyType; - QDataStream arg(data,IO_WriteOnly); - arg << mrl; - if(!g_pApp->dcopClient()->call(m_szAppId,"playlist","play(QString)",data,replyType,replyData)) - return false; - return true; -} - - -#endif //COMPILE_KDE_SUPPORT diff --git a/src/modules/mediaplayer/mp_jukinterface.h b/src/modules/mediaplayer/mp_jukinterface.h deleted file mode 100644 index bee81513b..000000000 --- a/src/modules/mediaplayer/mp_jukinterface.h +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef _MP_JUKINTERFACE_H_ -#define _MP_JUKINTERFACE_H_ -//============================================================================= -// -// File : mp_jukinterface.h -// Creation date : Tue 29 Mar 2005 01:38:34 by Szymon Stfeanek -// -// This file is part of the KVIrc IRC client distribution -// Copyright (C) 2005-2008 Szymon Stfeanek <pragma at kvirc dot net> -// -// 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 opinion) 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 "kvi_settings.h" - -#ifdef COMPILE_KDE3_SUPPORT - - #include "kvi_dcophelper.h" - #include "mp_interface.h" - - class KviJukInterface : public KviMediaPlayerInterface, private KviDCOPHelper - { - public: - KviJukInterface(); - ~KviJukInterface(); - public: - virtual int detect(bool bStart); - virtual bool prev(); - virtual bool next(); - virtual bool play(); - virtual bool stop(); - virtual bool pause(); - virtual bool quit(); - virtual bool jumpTo(kvs_int_t &iPos); - virtual bool setVol(kvs_int_t &iVol); - virtual QString nowPlaying(); - virtual QString mrl(); - /* - virtual QString title(); - virtual QString artist(); - virtual QString genre(); - virtual QString comment(); - virtual QString year(); - virtual QString album(); - */ - virtual int position(); - virtual int length(); - /* - virtual int bitRate(); - virtual int sampleRate(); - */ - virtual bool getShuffle(); - virtual bool setShuffle(bool &bVal); - - virtual bool playMrl(const QString &mrl); - virtual KviMediaPlayerInterface::PlayerStatus status(); - }; - - MP_DECLARE_DESCRIPTOR(KviJukInterface) - -#endif //COMPILE_KDE_SUPPORT - -#endif //!_MP_JUKINTERFACE_H_ |
