summaryrefslogtreecommitdiff
path: root/libmediaoverridesqt
diff options
context:
space:
mode:
authorWolf Bergenheim <ext-wolf.2.bergenheim@nokia.com>2010-08-05 13:32:04 +0300
committerWolf Bergenheim <ext-wolf.2.bergenheim@nokia.com>2010-08-05 13:32:04 +0300
commit186e21da5f83fc26cd33f13e800cd59316250d04 (patch)
treec00e4a568bcc0019ddfc27613ed959808d075daa /libmediaoverridesqt
parent223a40ec162252785591c2164f3ca1326d7878ea (diff)
downloadlibresourceqt-186e21da5f83fc26cd33f13e800cd59316250d04.tar.gz
Renamed libresource-overridesqt => libmediaoverridesqt
Renamed resourceoverrider => mediaoverrider
Diffstat (limited to 'libmediaoverridesqt')
-rw-r--r--libmediaoverridesqt/libmediaoverridesqt.pro36
-rw-r--r--libmediaoverridesqt/libmediaoverridesqt1.pc12
-rw-r--r--libmediaoverridesqt/override.cpp63
-rw-r--r--libmediaoverridesqt/override.h32
4 files changed, 143 insertions, 0 deletions
diff --git a/libmediaoverridesqt/libmediaoverridesqt.pro b/libmediaoverridesqt/libmediaoverridesqt.pro
new file mode 100644
index 0000000..20296c4
--- /dev/null
+++ b/libmediaoverridesqt/libmediaoverridesqt.pro
@@ -0,0 +1,36 @@
+include(../common.pri)
+TEMPLATE = lib
+TARGET = mediaoverridesqt
+DESTDIR = build
+DEPENDPATH += .
+INCLUDEPATH += .
+
+# Input
+PUBLIC_HEADERS = override.h
+
+HEADERS += $${PUBLIC_HEADERS}
+
+SOURCES += override.cpp
+
+QMAKE_CXXFLAGS += -Wall
+LIBS += -L$${LIBDBUSQEVENTLOOP}/build -ldbus-qeventloop
+
+OBJECTS_DIR = build
+MOC_DIR = moc
+
+CONFIG += qt dll
+QT += dbus
+PKGCONFIG += dbus-1 libresource0
+
+QMAKE_DISTCLEAN += -r moc build
+
+# Install directives
+headers.files = $${PUBLIC_HEADERS}
+INSTALLBASE = /usr
+target.path = $${INSTALLBASE}/lib
+headers.path = $${INSTALLBASE}/include/resource/qt4/policy
+pc.files = libmediaoverridesqt1.pc
+pc.path = $${INSTALLBASE}/lib/pkgconfig
+
+INSTALLS = target headers pc
+
diff --git a/libmediaoverridesqt/libmediaoverridesqt1.pc b/libmediaoverridesqt/libmediaoverridesqt1.pc
new file mode 100644
index 0000000..7666624
--- /dev/null
+++ b/libmediaoverridesqt/libmediaoverridesqt1.pc
@@ -0,0 +1,12 @@
+prefix=/usr
+exec_prefix=${prefix}
+libdir=${prefix}/lib
+includedir=${prefix}/include/resource/qt4
+
+Name: libmediaoverridesqt1
+Description: Maemo overrides Qt API
+Version: 1.11
+Libs: -L${libdir}
+Cflags: -I${includedir}
+Requires: QtDbus
+
diff --git a/libmediaoverridesqt/override.cpp b/libmediaoverridesqt/override.cpp
new file mode 100644
index 0000000..71102df
--- /dev/null
+++ b/libmediaoverridesqt/override.cpp
@@ -0,0 +1,63 @@
+#include "override.h"
+
+#define MANAGER_PATH "/org/maemo/Playback/Manager"
+#define MANAGER_SERVICE "org.maemo.Playback.Manager"
+#define MANAGER_INTERFACE "org.maemo.Playback.Manager"
+
+using namespace ResourcePolicy;
+
+Override * ResourcePolicy::createMute(QObject *parent)
+{
+ return new Override("Mute", parent);
+}
+
+Override * ResourcePolicy::createPrivacyOverride(QObject *parent)
+{
+ return new Override("PrivacyOverride", parent);
+}
+
+Override * ResourcePolicy::createBluetoothOVerride(QObject *parent)
+{
+ return new Override("BluetoothOverride", parent);
+}
+
+Override::Override(QString overrideType, QObject *parent):
+ QObject(parent), dBusConnection(QDBusConnection::sessionBus()), type(overrideType)
+{
+ dBusConnection.connect(MANAGER_SERVICE, MANAGER_PATH, MANAGER_INTERFACE,
+ type, this, SLOT(handleChange(bool)));
+}
+
+Override::~Override()
+{
+}
+
+void Override::fetchState()
+{
+ QDBusMessage msg;
+ QString method = "Get" + type;
+
+ msg = QDBusMessage::createMethodCall(MANAGER_SERVICE, MANAGER_PATH,
+ MANAGER_INTERFACE, method);
+ dBusConnection.send(msg);
+}
+
+void Override::request(bool newState)
+{
+ QDBusMessage msg;
+ QString method = "Request" + type;
+
+ msg = QDBusMessage::createMethodCall(MANAGER_SERVICE, MANAGER_PATH,
+ MANAGER_INTERFACE, method);
+
+ QVariantList args;
+ args.append(newState);
+ msg.setArguments(args);
+ dBusConnection.send(msg);
+}
+
+void Override::handleChange(bool newState)
+{
+ emit changed(newState);
+}
+
diff --git a/libmediaoverridesqt/override.h b/libmediaoverridesqt/override.h
new file mode 100644
index 0000000..c906a55
--- /dev/null
+++ b/libmediaoverridesqt/override.h
@@ -0,0 +1,32 @@
+#pragma once
+
+#include <QtDBus>
+#include <QDBusConnection>
+#include <QDBusArgument>
+
+namespace ResourcePolicy
+{
+ class Override : public QObject
+ {
+ Q_OBJECT
+public:
+ Override(QString overrideType, QObject *parent=NULL);
+ virtual ~Override();
+ void fetchState();
+
+signals:
+ void changed(bool newState);
+
+private slots:
+ void handleChange(bool newState);
+ void request(bool newState);
+
+private:
+ QDBusConnection dBusConnection;
+ QString type;
+ };
+ Override * createMute(QObject *parent=NULL);
+ Override * createPrivacyOverride(QObject *parent=NULL);
+ Override * createBluetoothOVerride(QObject *parent=NULL);
+}
+