summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Rauwolf <rauwolf@itestra.de>2013-03-19 10:44:27 +0100
committerPhilip Rauwolf <rauwolf@itestra.de>2013-03-19 10:44:27 +0100
commit4d9a70be8f8dfa3c80903abeb154b9a9030778db (patch)
tree061ec7ebd7e2664de3c19cc30f7eb7d15fbde264
parent8502749512b58b6567ebc0121b3b29019a6125a3 (diff)
downloadgenivi-common-api-dbus-runtime-4d9a70be8f8dfa3c80903abeb154b9a9030778db.tar.gz
Added a return of "false" if the dbus connection name could not be
accquired.
-rw-r--r--src/CommonAPI/DBus/DBusFactory.cpp28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/CommonAPI/DBus/DBusFactory.cpp b/src/CommonAPI/DBus/DBusFactory.cpp
index de74ef1..f45e9b7 100644
--- a/src/CommonAPI/DBus/DBusFactory.cpp
+++ b/src/CommonAPI/DBus/DBusFactory.cpp
@@ -120,27 +120,29 @@ bool DBusFactory::registerAdapter(std::shared_ptr<StubBase> stubBase,
DBusAddressTranslator::getInstance().searchForDBusAddress(commonApiAddress, interfaceName, connectionName, objectPath);
if(acquiredConnectionName_ == "") {
- dbusConnection_->requestServiceNameAndBlock(connectionName);
+ bool isServiceNameAcquired = dbusConnection_->requestServiceNameAndBlock(connectionName);
+ if(!isServiceNameAcquired) {
+ return false;
+ }
acquiredConnectionName_ = connectionName;
} else if (acquiredConnectionName_ != connectionName) {
- return NULL;
+ return false;
}
if(!registeredAdapterFactoryFunctions_) {
registeredAdapterFactoryFunctions_ = new std::unordered_map<std::string, DBusAdapterFactoryFunction> {};
}
- for (auto it = registeredAdapterFactoryFunctions_->begin(); it != registeredAdapterFactoryFunctions_->end(); ++it) {
- if(it->first == interfaceId) {
- std::shared_ptr<DBusStubAdapter> dbusStubAdapter = (it->second)(commonApiAddress, interfaceName, connectionName, objectPath, dbusConnection_, stubBase);
- if(!dbusStubAdapter) {
- return false;
- }
- std::string address = domain + ":" + serviceName + ":" + participantId;
- if(registeredServices_.insert( {std::move(address), dbusStubAdapter} ).second) {
- dbusStubAdapter->init();
- return true;
- }
+ auto foundFunction = registeredAdapterFactoryFunctions_->find(interfaceId);
+ if(foundFunction != registeredAdapterFactoryFunctions_->end()) {
+ std::shared_ptr<DBusStubAdapter> dbusStubAdapter = (foundFunction->second)(commonApiAddress, interfaceName, connectionName, objectPath, dbusConnection_, stubBase);
+ if(!dbusStubAdapter) {
+ return false;
+ }
+ std::string address = domain + ":" + serviceName + ":" + participantId;
+ if(registeredServices_.insert( {std::move(address), dbusStubAdapter} ).second) {
+ dbusStubAdapter->init();
+ return true;
}
}