aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/General
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2008-03-18 11:17:32 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2008-03-18 11:17:32 +0000
commit625b2712c1c9fa46ba43684a24a477aa60d88089 (patch)
treee1f0d7a6239bb48b079d7c067a16d9ac6fd729b8 /src/plugins/General
parent3626269d655501b4d973e29060a9e96893e5af98 (diff)
downloadqmmp-625b2712c1c9fa46ba43684a24a477aa60d88089.tar.gz
qmmp-625b2712c1c9fa46ba43684a24a477aa60d88089.tar.bz2
qmmp-625b2712c1c9fa46ba43684a24a477aa60d88089.zip
dbus plugin: more properties and signals
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@277 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/General')
-rw-r--r--src/plugins/General/dbuscontrol/dbusadaptor.cpp68
-rw-r--r--src/plugins/General/dbuscontrol/dbusadaptor.h29
-rw-r--r--src/plugins/General/dbuscontrol/dbuscontrol.cpp17
-rw-r--r--src/plugins/General/dbuscontrol/dbuscontrol.h9
4 files changed, 122 insertions, 1 deletions
diff --git a/src/plugins/General/dbuscontrol/dbusadaptor.cpp b/src/plugins/General/dbuscontrol/dbusadaptor.cpp
index 730ab5ee3..7b02caa5d 100644
--- a/src/plugins/General/dbuscontrol/dbusadaptor.cpp
+++ b/src/plugins/General/dbuscontrol/dbusadaptor.cpp
@@ -20,6 +20,7 @@
#include <qmmpui/control.h>
+#include "dbuscontrol.h"
#include "dbusadaptor.h"
DBUSAdaptor::DBUSAdaptor(Control *ctrl, QObject *parent)
@@ -27,6 +28,7 @@ DBUSAdaptor::DBUSAdaptor(Control *ctrl, QObject *parent)
{
m_control = ctrl;
setAutoRelaySignals(TRUE);
+ connect(parent, SIGNAL(stateChanged()), SLOT (processState()));
}
DBUSAdaptor::~DBUSAdaptor()
@@ -67,6 +69,56 @@ void DBUSAdaptor::setBalance(int bal)
QMetaObject::invokeMethod(m_control, "setVolume", Q_ARG(int, left), Q_ARG(int, right));
}
+int DBUSAdaptor::length()
+{
+ return qobject_cast<DBUSControl *>(parent())->info()->length();
+}
+
+int DBUSAdaptor::year()
+{
+ return qobject_cast<DBUSControl *>(parent())->info()->year();
+}
+
+QString DBUSAdaptor::title()
+{
+ return qobject_cast<DBUSControl *>(parent())->info()->title();
+}
+
+QString DBUSAdaptor::artist()
+{
+ return qobject_cast<DBUSControl *>(parent())->info()->artist();
+}
+
+QString DBUSAdaptor::album()
+{
+ return qobject_cast<DBUSControl *>(parent())->info()->album();
+}
+
+QString DBUSAdaptor::comment()
+{
+ return qobject_cast<DBUSControl *>(parent())->info()->comment();
+}
+
+QString DBUSAdaptor::genre()
+{
+ return qobject_cast<DBUSControl *>(parent())->info()->genre();
+}
+
+bool DBUSAdaptor::isPlaying()
+{
+ return qobject_cast<DBUSControl *>(parent())->state() == General::Playing;
+}
+
+bool DBUSAdaptor::isPaused()
+{
+ return qobject_cast<DBUSControl *>(parent())->state() == General::Paused;
+}
+
+bool DBUSAdaptor::isStopped()
+{
+ return qobject_cast<DBUSControl *>(parent())->state() == General::Stopped;
+}
+
void DBUSAdaptor::play()
{
QMetaObject::invokeMethod(m_control, "play");
@@ -92,8 +144,24 @@ 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::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();
+}
+
diff --git a/src/plugins/General/dbuscontrol/dbusadaptor.h b/src/plugins/General/dbuscontrol/dbusadaptor.h
index 942e0b9ec..e02142b9b 100644
--- a/src/plugins/General/dbuscontrol/dbusadaptor.h
+++ b/src/plugins/General/dbuscontrol/dbusadaptor.h
@@ -33,6 +33,16 @@ 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(bool isPlaying READ isPlaying)
+Q_PROPERTY(bool isPaused READ isPaused)
+Q_PROPERTY(bool isStopped READ isStopped)
public:
DBUSAdaptor(Control *ctrl, QObject *parent = 0);
@@ -43,6 +53,21 @@ public:
void setVolume(int);
int balance();
void setBalance(int);
+ int length();
+ int year();
+ QString title();
+ QString artist();
+ QString album();
+ QString comment();
+ QString genre();
+ bool isPlaying();
+ bool isPaused();
+ bool isStopped();
+
+signals:
+ void started();
+ void paused();
+ void stopped();
public slots:
void play();
@@ -50,8 +75,12 @@ public slots:
void next();
void previous();
void pause();
+ void toggleVisibility();
void exit();
+private slots:
+ void processState();
+
private:
Control *m_control;
};
diff --git a/src/plugins/General/dbuscontrol/dbuscontrol.cpp b/src/plugins/General/dbuscontrol/dbuscontrol.cpp
index e2e673b21..2b2214846 100644
--- a/src/plugins/General/dbuscontrol/dbuscontrol.cpp
+++ b/src/plugins/General/dbuscontrol/dbuscontrol.cpp
@@ -32,6 +32,7 @@ DBUSControl::DBUSControl(Control *control, QObject *parent)
connection.registerService("org.qmmp.dbus");
m_left = 0;
m_right = 0;
+ m_state = General::Stopped;
}
@@ -41,6 +42,8 @@ DBUSControl::~DBUSControl()
void DBUSControl::setState(const uint &state)
{
+ m_state = state;
+ emit stateChanged();
switch ((uint) state)
{
case General::Playing:
@@ -53,13 +56,15 @@ void DBUSControl::setState(const uint &state)
}
case General::Stopped:
{
+ m_song = SongInfo();
break;
}
}
}
-void DBUSControl::setSongInfo(const SongInfo&)
+void DBUSControl::setSongInfo(const SongInfo &song)
{
+ m_song = song;
}
void DBUSControl::setVolume(int left, int right)
@@ -68,6 +73,16 @@ void DBUSControl::setVolume(int left, int right)
m_right = right;
}
+SongInfo *DBUSControl::info()
+{
+ return &m_song;
+}
+
+uint DBUSControl::state()
+{
+ return m_state;
+}
+
int DBUSControl::leftVolume()
{
return m_left;
diff --git a/src/plugins/General/dbuscontrol/dbuscontrol.h b/src/plugins/General/dbuscontrol/dbuscontrol.h
index 58bac24ce..40ff4f3f0 100644
--- a/src/plugins/General/dbuscontrol/dbuscontrol.h
+++ b/src/plugins/General/dbuscontrol/dbuscontrol.h
@@ -38,9 +38,16 @@ public:
~DBUSControl();
+ //general api
void setState(const uint& state);
void setSongInfo(const SongInfo &song);
void setVolume(int left, int right);
+ //helper functions
+ SongInfo *info();
+ uint state();
+
+signals:
+ void stateChanged();
public slots:
int leftVolume();
@@ -49,6 +56,8 @@ public slots:
private:
DBUSAdaptor *m_adaptor;
int m_left, m_right;
+ SongInfo m_song;
+ uint m_state;
};
#endif