diff options
author | Robert Löfman <rlofman@x201.research.nokia.com> | 2010-11-18 14:50:40 +0200 |
---|---|---|
committer | Robert Löfman <rlofman@x201.research.nokia.com> | 2010-11-18 14:50:40 +0200 |
commit | 05f8fa1ebccab6eb55ccbd8a3921bc7016512749 (patch) | |
tree | 93e46f320e838869b5119237ff6fc50014c58ae2 | |
parent | 4b949a43b56a2336499c30e2bdc4c1cda8e81a68 (diff) | |
download | libresourceqt-05f8fa1ebccab6eb55ccbd8a3921bc7016512749.tar.gz |
Added bool ResourceSet::initAndConnect() so that one can connect without acquiring.
-rw-r--r-- | libresourceqt/include/qt4/policy/resource-set.h | 5 | ||||
-rw-r--r-- | libresourceqt/src/resource-set.cpp | 27 | ||||
-rw-r--r-- | resourceqt-client/client.cpp | 5 |
3 files changed, 28 insertions, 9 deletions
diff --git a/libresourceqt/include/qt4/policy/resource-set.h b/libresourceqt/include/qt4/policy/resource-set.h index dad892e..03c9d95 100644 --- a/libresourceqt/include/qt4/policy/resource-set.h +++ b/libresourceqt/include/qt4/policy/resource-set.h @@ -209,6 +209,11 @@ public: QString applicationClass(); /** + * Initialize and connect the ResourceEngine of this ResourceSet. + */ + bool initAndConnect(); + + /** * Try to acquire the \ref ResourceSet. The resourcesGranted() or * resourcesDenied() signal will be emited depending on whether the * requested resources could be acquired or not. diff --git a/libresourceqt/src/resource-set.cpp b/libresourceqt/src/resource-set.cpp index 8b46664..b6885a5 100644 --- a/libresourceqt/src/resource-set.cpp +++ b/libresourceqt/src/resource-set.cpp @@ -228,21 +228,34 @@ Resource * ResourceSet::resource(ResourceType type) const return resourceSet[type]; } -bool ResourceSet::acquire() +bool ResourceSet::initAndConnect() { - if (!initialized) { + if ( !initialized ) + { qDebug("ResourceSet::%s().... initializing...", __FUNCTION__); - pendingAcquire = true; return initialize(); } - if (!resourceEngine->isConnectedToManager()) { + if ( !resourceEngine->isConnectedToManager() ) + { qDebug("ResourceSet::%s().... connecting...", __FUNCTION__); + return resourceEngine->connectToManager(); + } + else + qDebug("ResourceSet::%s(): already connected", __FUNCTION__); + + return true; +} + +bool ResourceSet::acquire() +{ + if ( !initialized || !resourceEngine->isConnectedToManager() ) + { pendingAcquire = true; - resourceEngine->connectToManager(); - return true; + return initAndConnect(); } - else { + else + { qDebug("ResourceSet::%s().... acquiring", __FUNCTION__); return resourceEngine->acquireResources(); } diff --git a/resourceqt-client/client.cpp b/resourceqt-client/client.cpp index 25ae5a1..804ac56 100644 --- a/resourceqt-client/client.cpp +++ b/resourceqt-client/client.cpp @@ -133,9 +133,10 @@ bool Client::initialize(const CommandLineParser &parser) this, SLOT(doExit()))) { return false; } - output << "accepting input" << endl; - showPrompt(); + resourceSet->initAndConnect(); + output << "connecting...accepting input" << endl; + showPrompt(); return true; } |