summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVsevolod Buzinov <ext-vsevolod.buzinov@nokia.com>2010-08-06 11:05:19 +0300
committerVsevolod Buzinov <ext-vsevolod.buzinov@nokia.com>2010-08-06 11:05:19 +0300
commite259ac49bc79329e2b6736eab08f666e3ab87615 (patch)
tree960b2918b883fd1977cf8d5471f9229054b12e77
parentb4e779fd1d17f25e14520e4904e2b294a7402f7b (diff)
parent68260cf98b7878d8db912450081e8cf5e5b4d5ef (diff)
downloadlibresourceqt-e259ac49bc79329e2b6736eab08f666e3ab87615.tar.gz
Merge branch 'master' of ssh://karma.research.nokia.com/u/repositories/libresourceqt
-rw-r--r--common.pri2
-rw-r--r--libdbus-qeventloop/dbusconnectioneventloop.h4
-rw-r--r--libmediaoverridesqt/libmediaoverridesqt.pro (renamed from libresource-overridesqt/libresource-overridesqt.pro)4
-rw-r--r--libmediaoverridesqt/libmediaoverridesqt1.pc (renamed from libresource-overridesqt/libresource-overridesqt1.pc)4
-rw-r--r--libmediaoverridesqt/override.cpp (renamed from libresource-overridesqt/override.cpp)0
-rw-r--r--libmediaoverridesqt/override.h (renamed from libresource-overridesqt/override.h)0
-rw-r--r--libresourceqt.pro10
-rw-r--r--libresourceqt/libresourceqt.pro3
-rw-r--r--libresourceqt/src/resource-engine.cpp19
-rw-r--r--libresourceqt/src/resource-set.cpp42
-rw-r--r--mediaoverrider/main.cpp (renamed from resourceoverrider/main.cpp)4
-rw-r--r--mediaoverrider/mediaoverrider.cpp (renamed from resourceoverrider/resourceoverrider.cpp)18
-rw-r--r--mediaoverrider/mediaoverrider.desktop (renamed from resourceoverrider/resourceoverrider.desktop)4
-rw-r--r--mediaoverrider/mediaoverrider.h (renamed from resourceoverrider/resourceoverrider.h)6
-rw-r--r--mediaoverrider/mediaoverrider.pro (renamed from resourceoverrider/resourceoverrider.pro)12
-rw-r--r--resourceqt-client/client.h1
-rw-r--r--tests/test-dbus-qeventloop/test-dbus-qeventloop.cpp1
17 files changed, 81 insertions, 53 deletions
diff --git a/common.pri b/common.pri
index fadd3bb..eefcd81 100644
--- a/common.pri
+++ b/common.pri
@@ -1,6 +1,6 @@
LIBDBUSQEVENTLOOP = $${PWD}/libdbus-qeventloop
LIBRESOURCEQT = $${PWD}/libresourceqt
-LIBRESOURCEOVERRIDESQT = $${PWD}/libresource-overridesqt
+LIBMEDIAOVERRIDESQT = $${PWD}/libmediaoverridesqt
LIBRESOURCEINC = $${LIBRESOURCEQT}/include/qt4
POLICY = $${LIBRESOURCEINC}/policy
diff --git a/libdbus-qeventloop/dbusconnectioneventloop.h b/libdbus-qeventloop/dbusconnectioneventloop.h
index d44f667..13259c3 100644
--- a/libdbus-qeventloop/dbusconnectioneventloop.h
+++ b/libdbus-qeventloop/dbusconnectioneventloop.h
@@ -63,6 +63,10 @@ public:
static bool addConnection(DBusConnection* conn);
static void removeConnection(DBusConnection* conn);
+ static DBUSConnectionEventLoop &getInstance(void) {
+ return classInstance;
+ }
+
private:
bool internalAddConnection(DBusConnection* conn);
void internalRemoveConnection(DBusConnection* conn);
diff --git a/libresource-overridesqt/libresource-overridesqt.pro b/libmediaoverridesqt/libmediaoverridesqt.pro
index c306266..20296c4 100644
--- a/libresource-overridesqt/libresource-overridesqt.pro
+++ b/libmediaoverridesqt/libmediaoverridesqt.pro
@@ -1,6 +1,6 @@
include(../common.pri)
TEMPLATE = lib
-TARGET = resource-overridesqt
+TARGET = mediaoverridesqt
DESTDIR = build
DEPENDPATH += .
INCLUDEPATH += .
@@ -29,7 +29,7 @@ headers.files = $${PUBLIC_HEADERS}
INSTALLBASE = /usr
target.path = $${INSTALLBASE}/lib
headers.path = $${INSTALLBASE}/include/resource/qt4/policy
-pc.files = libresource-overridesqt1.pc
+pc.files = libmediaoverridesqt1.pc
pc.path = $${INSTALLBASE}/lib/pkgconfig
INSTALLS = target headers pc
diff --git a/libresource-overridesqt/libresource-overridesqt1.pc b/libmediaoverridesqt/libmediaoverridesqt1.pc
index a6cf64e..7666624 100644
--- a/libresource-overridesqt/libresource-overridesqt1.pc
+++ b/libmediaoverridesqt/libmediaoverridesqt1.pc
@@ -3,8 +3,8 @@ exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include/resource/qt4
-Name: libresource-overridesqt1
-Description: Maemo resource management Qt API
+Name: libmediaoverridesqt1
+Description: Maemo overrides Qt API
Version: 1.11
Libs: -L${libdir}
Cflags: -I${includedir}
diff --git a/libresource-overridesqt/override.cpp b/libmediaoverridesqt/override.cpp
index 71102df..71102df 100644
--- a/libresource-overridesqt/override.cpp
+++ b/libmediaoverridesqt/override.cpp
diff --git a/libresource-overridesqt/override.h b/libmediaoverridesqt/override.h
index c906a55..c906a55 100644
--- a/libresource-overridesqt/override.h
+++ b/libmediaoverridesqt/override.h
diff --git a/libresourceqt.pro b/libresourceqt.pro
index ed89bee..cb5523a 100644
--- a/libresourceqt.pro
+++ b/libresourceqt.pro
@@ -5,10 +5,10 @@
CONFIG += ordered
TEMPLATE = subdirs
-SUBDIRS = libdbus-qeventloop \
- libresourceqt \
- libresource-overridesqt \
- resourceqt-client \
- resourceoverrider \
+SUBDIRS = libdbus-qeventloop \
+ libresourceqt \
+ libmediaoverridesqt \
+ resourceqt-client \
+ mediaoverrider \
tests
diff --git a/libresourceqt/libresourceqt.pro b/libresourceqt/libresourceqt.pro
index d78339a..355a594 100644
--- a/libresourceqt/libresourceqt.pro
+++ b/libresourceqt/libresourceqt.pro
@@ -28,9 +28,6 @@ MOC_DIR = moc
CONFIG += qt link_pkgconfig dll
QT = core
PKGCONFIG += dbus-1 libresource0
-#CONFIG(release, release|debug) {
-# DEFINES += QT_NO_DEBUG_OUTPUT QT_NO_WARNING_OUTPUT QT_NO_DEBUG_STREAM
-#}
# Install directives
headers.files = $${PUBLIC_HEADERS}
diff --git a/libresourceqt/src/resource-engine.cpp b/libresourceqt/src/resource-engine.cpp
index e4068d2..dae826b 100644
--- a/libresourceqt/src/resource-engine.cpp
+++ b/libresourceqt/src/resource-engine.cpp
@@ -3,6 +3,8 @@
using namespace ResourcePolicy;
+static QMultiMap<resconn_t *, ResourceEngine *> engineMap;
+
resconn_t *ResourceEngine::libresourceConnection = NULL;
quint32 ResourceEngine::libresourceUsers = 0;
@@ -88,9 +90,11 @@ bool ResourceEngine::initialize()
resproto_set_handler(ResourceEngine::libresourceConnection, RESMSG_UNREGISTER, handleUnregisterMessage);
resproto_set_handler(ResourceEngine::libresourceConnection, RESMSG_GRANT, handleGrantMessage);
resproto_set_handler(ResourceEngine::libresourceConnection, RESMSG_ADVICE, handleAdviceMessage);
+ engineMap.insert(ResourceEngine::libresourceConnection, this);
}
else {
ResourceEngine::libresourceUsers += 1;
+ engineMap.insert(ResourceEngine::libresourceConnection, this);
}
qDebug("ResourceEngine (%u, %p) is now initialized. %d users",
@@ -277,7 +281,7 @@ bool ResourceEngine::disconnectFromManager()
bool ret = true;
if (libresourceSet != NULL) {
- ret = resconn_disconnect(libresourceSet, &resourceMessage, statusCallbackHandler) != 0;
+ ret = resconn_disconnect(libresourceSet, &resourceMessage, statusCallbackHandler)?true:false;
}
return ret;
}
@@ -561,15 +565,14 @@ static void connectionIsUp(resconn_t *connection)
{
qDebug("**************** %s() - locking....", __FUNCTION__);
QMutexLocker locker(&mutex);
- if (NULL == connection->dbus.rsets->userdata) {
- qDebug("IGNORING connectionIsUp");
- return;
- }
- ResourceEngine *resourceEngine;
- resourceEngine = reinterpret_cast<ResourceEngine *>(connection->dbus.rsets->userdata);
qDebug("connection is up");
- resourceEngine->handleConnectionIsUp(connection);
+
+ QList<ResourceEngine*> engines = engineMap.values(connection);
+ for (int i = 0; i < engines.size(); ++i) {
+ ResourceEngine *resourceEngine = engines.at(i);
+ resourceEngine->handleConnectionIsUp(connection);
+ }
}
void ResourceEngine::handleConnectionIsUp(resconn_t *connection)
diff --git a/libresourceqt/src/resource-set.cpp b/libresourceqt/src/resource-set.cpp
index 8ddb54b..babddfe 100644
--- a/libresourceqt/src/resource-set.cpp
+++ b/libresourceqt/src/resource-set.cpp
@@ -272,18 +272,40 @@ bool ResourceSet::alwaysGetReply()
void ResourceSet::connectedHandler()
{
qDebug("**************** ResourceSet::%s().... %d", __FUNCTION__, __LINE__);
- qDebug("Connected to manager!");
+ if (resourceEngine->isConnectedToManager()) {
+ qDebug("ResourceSet::%s() Connected to manager!", __FUNCTION__);
- if (pendingAudioProperties) {
- registerAudioProperties();
- }
- if (pendingUpdate) {
- resourceEngine->updateResources();
- pendingUpdate = false;
+ if (pendingAudioProperties) {
+ registerAudioProperties();
+ }
+ if (pendingUpdate) {
+ resourceEngine->updateResources();
+ pendingUpdate = false;
+ }
+ if (pendingAcquire) {
+ resourceEngine->acquireResources();
+ pendingAcquire = false;
+ }
}
- if (pendingAcquire) {
- resourceEngine->acquireResources();
- pendingAcquire = false;
+ else { // assuming reconnecting
+ qDebug("ResourceSet::%s() Reconnecting to manager...", __FUNCTION__);
+
+ // first check if we have any acquired resources
+ for (int i = 0; i < NumberOfTypes; i++) {
+ if (resourceSet[i] != NULL) {
+ if (resourceSet[i]->isGranted()) {
+ if (i == AudioPlaybackType) {
+ pendingAudioProperties = true;
+ qDebug("ResourceSet::%s() We have audio", __FUNCTION__);
+ }
+ qDebug("ResourceSet::%s() We have acquired resources. Re-acquire", __FUNCTION__);
+ pendingAcquire = true;
+ resourceSet[i]->unsetGranted();
+ }
+ }
+ }
+ // now reconnect
+ resourceEngine->connectToManager();
}
}
diff --git a/resourceoverrider/main.cpp b/mediaoverrider/main.cpp
index 13634d5..db13d33 100644
--- a/resourceoverrider/main.cpp
+++ b/mediaoverrider/main.cpp
@@ -1,8 +1,8 @@
-#include "resourceoverrider.h"
+#include "mediaoverrider.h"
int main(int argc, char **argv)
{
- ResourceOverrider app(argc, argv);
+ MediaOverrider app(argc, argv);
// MApplication app(argc, argv);
return app.run();
diff --git a/resourceoverrider/resourceoverrider.cpp b/mediaoverrider/mediaoverrider.cpp
index 606d419..24d9afc 100644
--- a/resourceoverrider/resourceoverrider.cpp
+++ b/mediaoverrider/mediaoverrider.cpp
@@ -1,9 +1,9 @@
-#include "resourceoverrider.h"
+#include "mediaoverrider.h"
-ResourceOverrider::ResourceOverrider(int argc, char **argv, QObject *parent):
+MediaOverrider::MediaOverrider(int argc, char **argv, QObject *parent):
QObject(parent), app(argc, argv)
{
-// MTheme::loadCSS("resourceoverrider.css");
+// MTheme::loadCSS("MediaOverrider.css");
window = new MApplicationWindow;
page = new MApplicationPage;
@@ -21,7 +21,7 @@ ResourceOverrider::ResourceOverrider(int argc, char **argv, QObject *parent):
muteButton->setText("Mute");
muteButton->setViewType(MButton::toggleType);
muteButton->setCheckable(true);
- policy->addItem(muteButton, 1,0);
+ policy->addItem(muteButton, 1, 0);
muteButton->setObjectName("button");
privacyButton = new MButton(page->centralWidget());
@@ -55,10 +55,10 @@ ResourceOverrider::ResourceOverrider(int argc, char **argv, QObject *parent):
}
-ResourceOverrider::~ResourceOverrider()
+MediaOverrider::~MediaOverrider()
{}
-int ResourceOverrider::run()
+int MediaOverrider::run()
{
page->appear();
window->show();
@@ -66,17 +66,17 @@ int ResourceOverrider::run()
return app.exec();
}
-void ResourceOverrider::handleMuteChange(bool newState)
+void MediaOverrider::handleMuteChange(bool newState)
{
muteButton->setChecked(newState);
}
-void ResourceOverrider::handlePrivacyChange(bool newState)
+void MediaOverrider::handlePrivacyChange(bool newState)
{
privacyButton->setChecked(newState);
}
-void ResourceOverrider::handleBtChange(bool newState)
+void MediaOverrider::handleBtChange(bool newState)
{
btButton->setChecked(newState);
}
diff --git a/resourceoverrider/resourceoverrider.desktop b/mediaoverrider/mediaoverrider.desktop
index 4200658..b257a5e 100644
--- a/resourceoverrider/resourceoverrider.desktop
+++ b/mediaoverrider/mediaoverrider.desktop
@@ -1,7 +1,7 @@
[Desktop Entry]
Type=Application
-Name=Policy Resource Overrider
+Name=Policy Media Overrider
Icon=icon-l-music
-Exec=/usr/bin/resourceoverrider
+Exec=/usr/bin/mediaoverrider
OnlyShowIn=X-MeeGo;
diff --git a/resourceoverrider/resourceoverrider.h b/mediaoverrider/mediaoverrider.h
index 755d426..052a7e0 100644
--- a/resourceoverrider/resourceoverrider.h
+++ b/mediaoverrider/mediaoverrider.h
@@ -9,12 +9,12 @@
#include <override.h>
-class ResourceOverrider: public QObject
+class MediaOverrider: public QObject
{
Q_OBJECT
public:
- ResourceOverrider(int argc, char **argv, QObject *parent=NULL);
- ~ResourceOverrider();
+ MediaOverrider(int argc, char **argv, QObject *parent=NULL);
+ ~MediaOverrider();
int run();
private slots:
void handleMuteChange(bool newState);
diff --git a/resourceoverrider/resourceoverrider.pro b/mediaoverrider/mediaoverrider.pro
index 6bbbdcb..e74679a 100644
--- a/resourceoverrider/resourceoverrider.pro
+++ b/mediaoverrider/mediaoverrider.pro
@@ -1,19 +1,19 @@
include(../common.pri)
TEMPLATE = app
-TARGET = resourceoverrider
+TARGET = mediaoverrider
MOC_DIR = moc
OBJECTS_DIR = build
DEPENDPATH += .
-INCLUDEPATH += $${LIBRESOURCEOVERRIDESQT}
+INCLUDEPATH += $${LIBMEDIAOVERRIDESQT}
CONFIG += qt meegotouch
QT += dbus
-LIBS += -L$${LIBRESOURCEOVERRIDESQT}/build -lresource-overridesqt
+LIBS += -L$${LIBMEDIAOVERRIDESQT}/build -lmediaoverridesqt
# Input
-HEADERS += resourceoverrider.h
-SOURCES += main.cpp resourceoverrider.cpp
+HEADERS += mediaoverrider.h
+SOURCES += main.cpp mediaoverrider.cpp
QMAKE_DISTCLEAN += -r moc build
@@ -22,7 +22,7 @@ QMAKE_DISTCLEAN += -r moc build
target.path = /usr/bin/
desktop.path = /usr/share/applications/
-desktop.files = resourceoverrider.desktop
+desktop.files = mediaoverrider.desktop
INSTALLS = target desktop
diff --git a/resourceqt-client/client.h b/resourceqt-client/client.h
index 3100160..200e4b6 100644
--- a/resourceqt-client/client.h
+++ b/resourceqt-client/client.h
@@ -4,6 +4,7 @@
#include <QObject>
#include <QtCore/QTextStream>
+#include <stdint.h>
#include <policy/resource-set.h>
#include <sys/resource.h>
diff --git a/tests/test-dbus-qeventloop/test-dbus-qeventloop.cpp b/tests/test-dbus-qeventloop/test-dbus-qeventloop.cpp
index 032156a..db31150 100644
--- a/tests/test-dbus-qeventloop/test-dbus-qeventloop.cpp
+++ b/tests/test-dbus-qeventloop/test-dbus-qeventloop.cpp
@@ -1,4 +1,5 @@
#include "dbusconnectioneventloop.h"
+#include <stdint.h>
#include <QtTest/QtTest>
class TestDbusQEventLoop: public QObject