diff options
author | Vsevolod Buzinov <ext-vsevolod.buzinov@nokia.com> | 2010-06-10 10:45:18 +0300 |
---|---|---|
committer | Vsevolod Buzinov <ext-vsevolod.buzinov@nokia.com> | 2010-06-10 10:45:18 +0300 |
commit | 705b4c51fb64e0f0290332d3a3413c2a6b82ac05 (patch) | |
tree | 5bd9bcdf1b5a19859953e5b50c6f6622dd3364d0 /libresourceqt | |
parent | 6a6d3799cb686d5cc91c79e281fb8b0ba436fe0c (diff) | |
parent | 3cbcb1b12a5280f95e0b887aad37a695927f7ac7 (diff) |
Merge branch 'master' of ssh://karma.research.nokia.com/u/repositories/libresourceqt
Diffstat (limited to 'libresourceqt')
-rw-r--r-- | libresourceqt/libresourceqt1.pc | 4 | ||||
-rw-r--r-- | libresourceqt/src/resource-engine.cpp | 17 | ||||
-rw-r--r-- | libresourceqt/src/resource-engine.h | 2 | ||||
-rw-r--r-- | libresourceqt/src/resource-set.cpp | 13 |
4 files changed, 27 insertions, 9 deletions
diff --git a/libresourceqt/libresourceqt1.pc b/libresourceqt/libresourceqt1.pc index e99b543..d4e36c8 100644 --- a/libresourceqt/libresourceqt1.pc +++ b/libresourceqt/libresourceqt1.pc @@ -5,7 +5,7 @@ includedir=${prefix}/include/resource/qt4 Name: libresourceqt1 Description: Maemo resource management Qt API -Version: 1.6 +Version: 1.8 Libs: -L${libdir} -lresourceqt Cflags: -I${includedir} -Requires: dbus-1 libdbus-qeventloop1 +Requires: dbus-1 libdbus-qeventloop1 libresource0 diff --git a/libresourceqt/src/resource-engine.cpp b/libresourceqt/src/resource-engine.cpp index 42f1b16..711669b 100644 --- a/libresourceqt/src/resource-engine.cpp +++ b/libresourceqt/src/resource-engine.cpp @@ -20,7 +20,7 @@ static void handleAdviceMessage(resmsg_t *msg, resset_t *rs, void *data); ResourceEngine::ResourceEngine(ResourceSet *resourceSet) : QObject(), connected(false), resourceSet(resourceSet), libresourceSet(NULL), requestId(0), messageMap(), connectionMode(0), - identifier(resourceSet->id()), aboutToBeDeleted(false) + identifier(resourceSet->id()), aboutToBeDeleted(false), isConnecting(false) { if (resourceSet->alwaysGetReply()) { connectionMode += RESMSG_MODE_ALWAYS_REPLY; @@ -69,9 +69,9 @@ bool ResourceEngine::initialize() if (ResourceEngine::libresourceConnection == NULL) { dbus_error_init(&dbusError); - dbusConnection = dbus_bus_get(DBUS_BUS_SESSION, &dbusError); + dbusConnection = dbus_bus_get(DBUS_BUS_SYSTEM, &dbusError); if (dbus_error_is_set(&dbusError)) { - qDebug("Error getting the session bus: %s", dbusError.message); + qDebug("Error getting the system bus: %s", dbusError.message); dbus_error_free(&dbusError); return false; } @@ -217,6 +217,11 @@ bool ResourceEngine::connectToManager() { qDebug("ResourceEngine(%d)::%s() - **************** locking....", identifier, __FUNCTION__); QMutexLocker locker(&mutex); + if (isConnecting) { + qDebug("ResourceEngine::%s().... allready connecting, ignoring request", __FUNCTION__); + return true; + } + isConnecting = true; resmsg_t resourceMessage; memset(&resourceMessage, 0, sizeof(resmsg_t)); resourceMessage.record.type = RESMSG_REGISTER; @@ -385,6 +390,7 @@ void ResourceEngine::handleStatusMessage(quint32 requestNo) if (originalMessageType == RESMSG_REGISTER) { qDebug("ResourceEngine(%d) - connected!", identifier); connected = true; + isConnecting = false; emit connectedToManager(); messageMap.remove(requestNo); } @@ -421,6 +427,11 @@ bool ResourceEngine::isConnectedToManager() return connected; } +bool ResourceEngine::isConnectingToManager() +{ + return isConnecting; +} + bool ResourceEngine::acquireResources() { qDebug("ResourceEngine(%d)::%s() - **************** locking....", identifier, __FUNCTION__); diff --git a/libresourceqt/src/resource-engine.h b/libresourceqt/src/resource-engine.h index fe3260a..38849aa 100644 --- a/libresourceqt/src/resource-engine.h +++ b/libresourceqt/src/resource-engine.h @@ -30,6 +30,7 @@ public: bool connectToManager(); bool disconnectFromManager(); bool isConnectedToManager(); + bool isConnectingToManager(); bool acquireResources(); bool releaseResources(); @@ -71,6 +72,7 @@ private: static resconn_t *libresourceConnection; quint32 identifier; bool aboutToBeDeleted; + bool isConnecting; }; } diff --git a/libresourceqt/src/resource-set.cpp b/libresourceqt/src/resource-set.cpp index d39d445..7dfd5d7 100644 --- a/libresourceqt/src/resource-set.cpp +++ b/libresourceqt/src/resource-set.cpp @@ -193,19 +193,19 @@ Resource * ResourceSet::resource(ResourceType type) const bool ResourceSet::acquire() { if (!initialized) { - qDebug("**************** ResourceSet::%s().... %d", __FUNCTION__, __LINE__); + qDebug("ResourceSet::%s().... initializing...", __FUNCTION__); pendingAcquire = true; return initialize(); } if (!resourceEngine->isConnectedToManager()) { - qDebug("**************** ResourceSet::%s().... %d", __FUNCTION__, __LINE__); + qDebug("ResourceSet::%s().... connecting...", __FUNCTION__); pendingAcquire = true; resourceEngine->connectToManager(); return true; } else { - qDebug("**************** ResourceSet::%s().... %d", __FUNCTION__, __LINE__); + qDebug("ResourceSet::%s().... acquiring", __FUNCTION__); return resourceEngine->acquireResources(); } } @@ -216,6 +216,7 @@ bool ResourceSet::release() return true; } + qDebug("ResourceSet::%s().... releasing...", __FUNCTION__); return resourceEngine->releaseResources(); } @@ -227,8 +228,10 @@ bool ResourceSet::update() if (!resourceEngine->isConnectedToManager()) { pendingUpdate = true; + resourceEngine->connectToManager(); return true; } + qDebug("ResourceSet::%s().... updating...", __FUNCTION__); return resourceEngine->updateResources(); } @@ -267,6 +270,7 @@ void ResourceSet::connectedHandler() { qDebug("**************** ResourceSet::%s().... %d", __FUNCTION__, __LINE__); qDebug("Connected to manager!"); + if (pendingAudioProperties) { registerAudioProperties(); } @@ -287,8 +291,9 @@ void ResourceSet::registerAudioProperties() pendingAudioProperties = true; initialize(); } - else if (!resourceEngine->isConnectedToManager()) { + if (!resourceEngine->isConnectedToManager() && !resourceEngine->isConnectingToManager()) { qDebug("%s(): Connecting to Manager...", __FUNCTION__); + pendingAudioProperties = true; resourceEngine->connectToManager(); } |