From f15d3608dc4d6444fb587f9dfbb93c7a8b02c740 Mon Sep 17 00:00:00 2001 From: Wolf Bergenheim Date: Mon, 15 Feb 2010 10:12:24 +0200 Subject: added slots for connected, acquire and deny --- libresourceqt/include/qt4/policy/resource-set.h | 6 +++++ libresourceqt/src/resource-set.cpp | 34 +++++++++++++++++++++++++ 2 files changed, 40 insertions(+) (limited to 'libresourceqt') diff --git a/libresourceqt/include/qt4/policy/resource-set.h b/libresourceqt/include/qt4/policy/resource-set.h index ea54b8a..447dc8b 100644 --- a/libresourceqt/include/qt4/policy/resource-set.h +++ b/libresourceqt/include/qt4/policy/resource-set.h @@ -212,6 +212,12 @@ private: bool alwaysReply; bool initialized; bool pendingAcquire; + +private slots: + void connectedHandler(); + void handleAcquire(quint32); + void handleDeny(); + }; } diff --git a/libresourceqt/src/resource-set.cpp b/libresourceqt/src/resource-set.cpp index 80974d2..64f7645 100644 --- a/libresourceqt/src/resource-set.cpp +++ b/libresourceqt/src/resource-set.cpp @@ -144,3 +144,37 @@ void ResourceSet::setAlwaysReply() alwaysReply = true; } +void ResourceSet::connectedHandler() +{ + if (pendingAcquire) { + resourceEngine->acquireResources(); + } +} + +void ResourceSet::handleAcquire(quint32 bitmaskOfGrantedResources) +{ + QList optionalResources; + qDebug("Acquired resources: 0x%04x", bitmaskOfGrantedResources); + for(int i=0;i < NumberOfTypes; i++) { + ResourceType type = (ResourceType)i; + quint32 bitmask = resourceTypeToLibresourceType(type); + qDebug("Checking if resource %x(%x) is in the set", i, bitmask); + if ((bitmask & bitmaskOfGrantedResources) == bitmask) { + if (resourceSet[i]->isOptional()) { + optionalResources << type; + } + resourceSet[i]->setGranted(); + } + } + emit resourcesGranted(optionalResources); +} + +void ResourceSet::handleDeny() +{ + for(int i=0;i < NumberOfTypes; i++) { + if(resourceSet[i] != NULL) { + resourceSet[i]->unsetGranted(); + } + } +} + -- cgit v1.2.3