diff options
Diffstat (limited to 'libresourceqt')
-rw-r--r-- | libresourceqt/include/qt4/policy/resource-set.h | 6 | ||||
-rw-r--r-- | libresourceqt/src/resource-set.cpp | 34 |
2 files changed, 40 insertions, 0 deletions
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<ResourceType> 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(); + } + } +} + |