summaryrefslogtreecommitdiff
path: root/libresourceqt/src/resource-engine.cpp
diff options
context:
space:
mode:
authorWolf Bergenheim <ext-wolf.2.bergenheim@nokia.com>2010-12-01 16:26:59 +0200
committerWolf Bergenheim <ext-wolf.2.bergenheim@nokia.com>2010-12-01 16:26:59 +0200
commitc8917f1cbbf96a1c5c655d9adbd45a46833e70db (patch)
tree4e363a2b10e8b6476c68af6ce08d1c1a9a828771 /libresourceqt/src/resource-engine.cpp
parenta551ffd289ccb0ffc46a097da3874f955aa95920 (diff)
downloadlibresourceqt-c8917f1cbbf96a1c5c655d9adbd45a46833e70db.tar.gz
Added support for RESMSG_RELEASE message from manager
Diffstat (limited to 'libresourceqt/src/resource-engine.cpp')
-rw-r--r--libresourceqt/src/resource-engine.cpp38
1 files changed, 34 insertions, 4 deletions
diff --git a/libresourceqt/src/resource-engine.cpp b/libresourceqt/src/resource-engine.cpp
index b9d9ee2..accb3a0 100644
--- a/libresourceqt/src/resource-engine.cpp
+++ b/libresourceqt/src/resource-engine.cpp
@@ -39,6 +39,7 @@ static void statusCallbackHandler(resset_t *rset, resmsg_t *msg);
static void handleUnregisterMessage(resmsg_t *, resset_t *, void *data);
static void handleGrantMessage(resmsg_t *msg, resset_t *rs, void *data);
static void handleAdviceMessage(resmsg_t *msg, resset_t *rs, void *data);
+static void handleReleaseMessage(resmsg_t *message, resset_t *rs, void *data);
ResourceEngine::ResourceEngine(ResourceSet *resourceSet)
: QObject(), connected(false), resourceSet(resourceSet),
@@ -111,6 +112,7 @@ 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);
+ resproto_set_handler(ResourceEngine::libresourceConnection, RESMSG_RELEASE, handleReleaseMessage);
engineMap.insert(ResourceEngine::libresourceConnection, this);
}
else {
@@ -186,12 +188,12 @@ void ResourceEngine::receivedGrant(resmsg_notify_t *notifyMessage)
emit resourcesLost(allResourcesToBitmask(resourceSet));
}
else if (originaloriginalMessageType == RESMSG_ACQUIRE) {
- qDebug("ResourceEngine(%d) - request DENIED!", identifier);
- emit resourcesDenied();
+ qDebug("ResourceEngine(%d) - request DENIED!", identifier);
+ emit resourcesDenied();
}
else if (originaloriginalMessageType == RESMSG_RELEASE) {
- qDebug("ResourceEngine(%d) - confirmation to release", identifier);
- emit resourcesReleased();
+ qDebug("ResourceEngine(%d) - confirmation to release", identifier);
+ emit resourcesReleased();
}
else {
qDebug("ResourceEngine(%d) - Ignoring the receivedGrant", identifier);
@@ -205,6 +207,34 @@ void ResourceEngine::receivedGrant(resmsg_notify_t *notifyMessage)
messageMap.remove(notifyMessage->reqno);
}
+static void handleReleaseMessage(resmsg_t *message, resset_t *rs, void *)
+{
+ qDebug("**************** %s() - locking....", __FUNCTION__);
+ QMutexLocker locker(&mutex);
+ if (NULL == rs->userdata) {
+ qDebug("IGNORING release, no context");
+ return;
+ }
+ ResourceEngine *engine = reinterpret_cast<ResourceEngine *>(rs->userdata);
+ qDebug("recv: release: type=%d, id=%d, reqno=%d, resc=0x%04x engine->id() = %d",
+ message->notify.type, message->notify.id, message->notify.reqno,
+ message->notify.resrc, engine->id());
+ if(engine->id() != message->any.id) {
+ qDebug("Received an advice message, but it is not for us. Ignoring (%d != %d)",
+ engine->id(), message->any.id);
+ return;
+ }
+
+ engine->receivedRelease(&(message->notify));
+}
+
+void ResourceEngine::receivedRelease(resmsg_notify_t *message)
+{
+ uint32_t allResources = allResourcesToBitmask(resourceSet);
+ qDebug("ResourceEngine(%d) - %s: have: %02x got %02x", identifier, __FUNCTION__, allResources, message->resrc);
+ emit resourcesReleasedByManager();
+}
+
static void handleAdviceMessage(resmsg_t *message, resset_t *libresourceSet, void *)
{
qDebug("**************** %s() - locking....", __FUNCTION__);