summaryrefslogtreecommitdiff
path: root/libresourceqt/src/resource-engine.cpp
diff options
context:
space:
mode:
authorVsevolod Buzinov <ext-vsevolod.buzinov@nokia.com>2010-06-10 10:45:18 +0300
committerVsevolod Buzinov <ext-vsevolod.buzinov@nokia.com>2010-06-10 10:45:18 +0300
commit705b4c51fb64e0f0290332d3a3413c2a6b82ac05 (patch)
tree5bd9bcdf1b5a19859953e5b50c6f6622dd3364d0 /libresourceqt/src/resource-engine.cpp
parent6a6d3799cb686d5cc91c79e281fb8b0ba436fe0c (diff)
parent3cbcb1b12a5280f95e0b887aad37a695927f7ac7 (diff)
downloadlibresourceqt-705b4c51fb64e0f0290332d3a3413c2a6b82ac05.tar.gz
Merge branch 'master' of ssh://karma.research.nokia.com/u/repositories/libresourceqt
Diffstat (limited to 'libresourceqt/src/resource-engine.cpp')
-rw-r--r--libresourceqt/src/resource-engine.cpp17
1 files changed, 14 insertions, 3 deletions
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__);