summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolf Bergenheim <ext-wolf.2.bergenheim@nokia.com>2010-07-05 14:14:56 +0300
committerWolf Bergenheim <ext-wolf.2.bergenheim@nokia.com>2010-07-05 14:14:56 +0300
commit32ab94785e8b8d70bf1f5a2fd3fa0ee735b4a32e (patch)
tree0590f5f9cf636fc94eecb61a39721569412b4c7d
parent3ad5033772ff8c1a331f0c0b208a4a90b698e57b (diff)
Added libresource-overridesqt
-rw-r--r--common.pri1
-rw-r--r--libresource-overridesqt/libresource-overridesqt.pro36
-rw-r--r--libresource-overridesqt/libresource-overridesqt1.pc12
-rw-r--r--libresource-overridesqt/override.cpp63
-rw-r--r--libresource-overridesqt/override.h32
-rw-r--r--libresourceqt.pro9
-rw-r--r--resourceoverrider/main.cpp10
-rw-r--r--resourceoverrider/resourceoverrider.cpp83
-rw-r--r--resourceoverrider/resourceoverrider.h38
-rw-r--r--resourceoverrider/resourceoverrider.pro24
10 files changed, 305 insertions, 3 deletions
diff --git a/common.pri b/common.pri
index b9a164a..fadd3bb 100644
--- a/common.pri
+++ b/common.pri
@@ -1,5 +1,6 @@
LIBDBUSQEVENTLOOP = $${PWD}/libdbus-qeventloop
LIBRESOURCEQT = $${PWD}/libresourceqt
+LIBRESOURCEOVERRIDESQT = $${PWD}/libresource-overridesqt
LIBRESOURCEINC = $${LIBRESOURCEQT}/include/qt4
POLICY = $${LIBRESOURCEINC}/policy
diff --git a/libresource-overridesqt/libresource-overridesqt.pro b/libresource-overridesqt/libresource-overridesqt.pro
new file mode 100644
index 0000000..c306266
--- /dev/null
+++ b/libresource-overridesqt/libresource-overridesqt.pro
@@ -0,0 +1,36 @@
+include(../common.pri)
+TEMPLATE = lib
+TARGET = resource-overridesqt
+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 = libresource-overridesqt1.pc
+pc.path = $${INSTALLBASE}/lib/pkgconfig
+
+INSTALLS = target headers pc
+
diff --git a/libresource-overridesqt/libresource-overridesqt1.pc b/libresource-overridesqt/libresource-overridesqt1.pc
new file mode 100644
index 0000000..a6cf64e
--- /dev/null
+++ b/libresource-overridesqt/libresource-overridesqt1.pc
@@ -0,0 +1,12 @@
+prefix=/usr
+exec_prefix=${prefix}
+libdir=${prefix}/lib
+includedir=${prefix}/include/resource/qt4
+
+Name: libresource-overridesqt1
+Description: Maemo resource management Qt API
+Version: 1.11
+Libs: -L${libdir}
+Cflags: -I${includedir}
+Requires: QtDbus
+
diff --git a/libresource-overridesqt/override.cpp b/libresource-overridesqt/override.cpp
new file mode 100644
index 0000000..71102df
--- /dev/null
+++ b/libresource-overridesqt/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/libresource-overridesqt/override.h b/libresource-overridesqt/override.h
new file mode 100644
index 0000000..c906a55
--- /dev/null
+++ b/libresource-overridesqt/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);
+}
+
diff --git a/libresourceqt.pro b/libresourceqt.pro
index d032d2e..ed89bee 100644
--- a/libresourceqt.pro
+++ b/libresourceqt.pro
@@ -5,7 +5,10 @@
CONFIG += ordered
TEMPLATE = subdirs
-SUBDIRS = libdbus-qeventloop \
- libresourceqt \
- resourceqt-client \
+SUBDIRS = libdbus-qeventloop \
+ libresourceqt \
+ libresource-overridesqt \
+ resourceqt-client \
+ resourceoverrider \
tests
+
diff --git a/resourceoverrider/main.cpp b/resourceoverrider/main.cpp
new file mode 100644
index 0000000..13634d5
--- /dev/null
+++ b/resourceoverrider/main.cpp
@@ -0,0 +1,10 @@
+#include "resourceoverrider.h"
+
+int main(int argc, char **argv)
+{
+ ResourceOverrider app(argc, argv);
+// MApplication app(argc, argv);
+
+ return app.run();
+}
+
diff --git a/resourceoverrider/resourceoverrider.cpp b/resourceoverrider/resourceoverrider.cpp
new file mode 100644
index 0000000..606d419
--- /dev/null
+++ b/resourceoverrider/resourceoverrider.cpp
@@ -0,0 +1,83 @@
+#include "resourceoverrider.h"
+
+ResourceOverrider::ResourceOverrider(int argc, char **argv, QObject *parent):
+ QObject(parent), app(argc, argv)
+{
+// MTheme::loadCSS("resourceoverrider.css");
+ window = new MApplicationWindow;
+ page = new MApplicationPage;
+
+ layout = new MLayout;
+ policy = new MGridLayoutPolicy(layout);
+ policy->setSpacing(10);
+
+ page->setTitle("Resource Overrider");
+ MLabel * label = new MLabel("Press the toggle buttons to change overrides");
+ policy->addItem(label, 0, 1);
+ label->setObjectName("label");
+ label->setAlignment(Qt::AlignCenter);
+
+ muteButton = new MButton(page->centralWidget());
+ muteButton->setText("Mute");
+ muteButton->setViewType(MButton::toggleType);
+ muteButton->setCheckable(true);
+ policy->addItem(muteButton, 1,0);
+ muteButton->setObjectName("button");
+
+ privacyButton = new MButton(page->centralWidget());
+ privacyButton->setText("Privacy");
+ privacyButton->setViewType(MButton::toggleType);
+ privacyButton->setCheckable(true);
+ policy->addItem(privacyButton, 1, 1);
+ privacyButton->setObjectName("button");
+
+ btButton = new MButton(page->centralWidget());
+ btButton->setText("BT");
+ btButton->setViewType(MButton::toggleType);
+ btButton->setCheckable(true);
+ policy->addItem(btButton, 1, 2);
+ btButton->setObjectName("button");
+
+ page->centralWidget()->setLayout(layout);
+
+ mute = ResourcePolicy::createMute(this);
+ privacyOverride = ResourcePolicy::createPrivacyOverride(this);
+ btOverride = ResourcePolicy::createBluetoothOVerride(this);
+
+ QObject::connect(mute, SIGNAL(changed(bool)), this, SLOT(handleMuteChange(bool)));
+ QObject::connect(muteButton, SIGNAL(toggled(bool)), mute, SLOT(request(bool)));
+
+ QObject::connect(privacyOverride, SIGNAL(changed(bool)), this, SLOT(handlePrivacyChange(bool)));
+ QObject::connect(privacyButton, SIGNAL(toggled(bool)), privacyOverride, SLOT(request(bool)));
+
+ QObject::connect(btOverride, SIGNAL(changed(bool)), this, SLOT(handleBtChange(bool)));
+ QObject::connect(btButton, SIGNAL(toggled(bool)), btOverride, SLOT(request(bool)));
+
+}
+
+ResourceOverrider::~ResourceOverrider()
+{}
+
+int ResourceOverrider::run()
+{
+ page->appear();
+ window->show();
+
+ return app.exec();
+}
+
+void ResourceOverrider::handleMuteChange(bool newState)
+{
+ muteButton->setChecked(newState);
+}
+
+void ResourceOverrider::handlePrivacyChange(bool newState)
+{
+ privacyButton->setChecked(newState);
+}
+
+void ResourceOverrider::handleBtChange(bool newState)
+{
+ btButton->setChecked(newState);
+}
+
diff --git a/resourceoverrider/resourceoverrider.h b/resourceoverrider/resourceoverrider.h
new file mode 100644
index 0000000..755d426
--- /dev/null
+++ b/resourceoverrider/resourceoverrider.h
@@ -0,0 +1,38 @@
+#include <MApplication>
+#include <MApplicationWindow>
+#include <MApplicationPage>
+#include <MButton>
+#include <MLabel>
+#include <MGridLayoutPolicy>
+#include <MLayout>
+#include <MTheme>
+
+#include <override.h>
+
+class ResourceOverrider: public QObject
+{
+ Q_OBJECT
+public:
+ ResourceOverrider(int argc, char **argv, QObject *parent=NULL);
+ ~ResourceOverrider();
+ int run();
+private slots:
+ void handleMuteChange(bool newState);
+ void handlePrivacyChange(bool newState);
+ void handleBtChange(bool newState);
+
+private:
+ MApplication app;
+ ResourcePolicy::Override *mute;
+ ResourcePolicy::Override *privacyOverride;
+ ResourcePolicy::Override *btOverride;
+
+ MApplicationWindow *window;
+ MApplicationPage *page;
+ MLayout *layout;
+ MGridLayoutPolicy *policy;
+ MButton *muteButton;
+ MButton *privacyButton;
+ MButton *btButton;
+};
+
diff --git a/resourceoverrider/resourceoverrider.pro b/resourceoverrider/resourceoverrider.pro
new file mode 100644
index 0000000..05bae6b
--- /dev/null
+++ b/resourceoverrider/resourceoverrider.pro
@@ -0,0 +1,24 @@
+include(../common.pri)
+
+TEMPLATE = app
+TARGET = resourceoverrider
+MOC_DIR = moc
+OBJECTS_DIR = build
+DEPENDPATH += .
+INCLUDEPATH += $${LIBRESOURCEOVERRIDESQT}
+CONFIG += qt meegotouch
+QT += dbus
+
+LIBS += -L$${LIBRESOURCEOVERRIDESQT}/build -lresource-overridesqt
+
+# Input
+HEADERS += resourceoverrider.h
+SOURCES += main.cpp resourceoverrider.cpp
+
+QMAKE_DISTCLEAN += -r moc build
+
+# Install options
+
+target.path = /usr/bin/
+INSTALLS = target
+