Listen on dbus and ipc socket at the same time 78/38978/4
authorMateusz Malicki <m.malicki2@samsung.com>
Tue, 5 May 2015 15:44:08 +0000 (17:44 +0200)
committerJan Olszak <j.olszak@samsung.com>
Wed, 6 May 2015 14:13:44 +0000 (07:13 -0700)
[Feature]       Possibility to handle ipc and dbus requests without recompiling the code.
                To build without dbus add --define 'without_dbus ON' to gbs arguments
[Cause]         N/A
[Solution]      N/A
[Verification]  Build with --define 'without_dbus ON' and without it,
                run tests for each build, check if server starts

Change-Id: Ibd00485c4b3a6451a1cb7046f3488ff77150b3ea

15 files changed:
CMakeLists.txt
client/host-ipc-connection.cpp
common/api/dbus-method-result-builder.hpp
packaging/vasum.spec
server/host-dbus-connection.cpp
server/host-dbus-definitions.hpp
server/host-ipc-connection.cpp
server/host-ipc-definitions.hpp
server/zones-manager.cpp
server/zones-manager.hpp
tests/unit_tests/client/ut-client.cpp
tests/unit_tests/server/configs/CMakeLists.txt
tests/unit_tests/server/configs/ut-zones-manager/templates/console-dbus.conf.in [deleted file]
tests/unit_tests/server/configs/ut-zones-manager/templates/console-ipc.conf.in [deleted file]
tests/unit_tests/server/ut-zones-manager.cpp

index 9b61793..2e960c6 100644 (file)
@@ -122,7 +122,9 @@ ADD_DEFINITIONS(-DVASUM_USER="${VASUM_USER}")
 ADD_DEFINITIONS(-DINPUT_EVENT_GROUP="${INPUT_EVENT_GROUP}")
 ADD_DEFINITIONS(-DDISK_GROUP="${DISK_GROUP}")
 ADD_DEFINITIONS(-DTTY_GROUP="${TTY_GROUP}")
-#ADD_DEFINITIONS(-DDBUS_CONNECTION)
+IF(NOT WITHOUT_DBUS)
+    ADD_DEFINITIONS(-DDBUS_CONNECTION)
+ENDIF(NOT WITHOUT_DBUS)
 
 ## Python packages directory ###################################################
 IF(NOT DEFINED PYTHON_SITELIB)
index 121f7ad..6541881 100644 (file)
@@ -46,183 +46,183 @@ void HostIPCConnection::create(const std::string& address)
 void HostIPCConnection::callGetZoneIds(api::ZoneIds& argOut)
 {
     api::Void argVoid;
-    call(api::METHOD_GET_ZONE_ID_LIST, argVoid, argOut);
+    call(api::ipc::METHOD_GET_ZONE_ID_LIST, argVoid, argOut);
 }
 
 void HostIPCConnection::callGetActiveZoneId(api::ZoneId& argOut)
 {
     api::Void argVoid;
-    call(api::METHOD_GET_ACTIVE_ZONE_ID, argVoid, argOut);
+    call(api::ipc::METHOD_GET_ACTIVE_ZONE_ID, argVoid, argOut);
 }
 
 void HostIPCConnection::callSetActiveZone(const api::ZoneId& argIn)
 {
     mClient->callSync<api::ZoneId, api::Void>(
-            api::METHOD_SET_ACTIVE_ZONE,
+            api::ipc::METHOD_SET_ACTIVE_ZONE,
             std::make_shared<api::ZoneId>(argIn));
 }
 
 void HostIPCConnection::callGetZoneInfo(const api::ZoneId& argIn, api::ZoneInfoOut& argOut)
 {
     argOut = *mClient->callSync<api::ZoneId, api::ZoneInfoOut>(
-        api::METHOD_GET_ZONE_INFO,
+        api::ipc::METHOD_GET_ZONE_INFO,
         std::make_shared<api::ZoneId>(argIn));
 }
 
 void HostIPCConnection::callSetNetdevAttrs(const api::SetNetDevAttrsIn& argIn)
 {
     mClient->callSync<api::SetNetDevAttrsIn, api::Void>(
-            api::METHOD_SET_NETDEV_ATTRS,
+            api::ipc::METHOD_SET_NETDEV_ATTRS,
             std::make_shared<api::SetNetDevAttrsIn>(argIn));
 
     api::Void argVoid;
-    call(api::METHOD_SET_NETDEV_ATTRS, argIn, argVoid);
+    call(api::ipc::METHOD_SET_NETDEV_ATTRS, argIn, argVoid);
 }
 
 void HostIPCConnection::callGetNetdevAttrs(const api::GetNetDevAttrsIn& argIn, api::GetNetDevAttrs& argOut)
 {
     argOut = *mClient->callSync<api::GetNetDevAttrsIn, api::GetNetDevAttrs>(
-        api::METHOD_GET_NETDEV_ATTRS,
+        api::ipc::METHOD_GET_NETDEV_ATTRS,
         std::make_shared<api::GetNetDevAttrsIn>(argIn));
 }
 
 void HostIPCConnection::callGetNetdevList(const api::ZoneId& argIn, api::NetDevList& argOut)
 {
     argOut = *mClient->callSync<api::ZoneId, api::NetDevList>(
-        api::METHOD_GET_NETDEV_LIST,
+        api::ipc::METHOD_GET_NETDEV_LIST,
         std::make_shared<api::ZoneId>(argIn));
 }
 
 void HostIPCConnection::callCreateNetdevVeth(const api::CreateNetDevVethIn& argIn)
 {
     mClient->callSync<api::CreateNetDevVethIn, api::Void>(
-            api::METHOD_CREATE_NETDEV_VETH,
+            api::ipc::METHOD_CREATE_NETDEV_VETH,
             std::make_shared<api::CreateNetDevVethIn>(argIn));
 }
 
 void HostIPCConnection::callCreateNetdevMacvlan(const api::CreateNetDevMacvlanIn& argIn)
 {
     mClient->callSync<api::CreateNetDevMacvlanIn, api::Void>(
-            api::METHOD_CREATE_NETDEV_MACVLAN,
+            api::ipc::METHOD_CREATE_NETDEV_MACVLAN,
             std::make_shared<api::CreateNetDevMacvlanIn>(argIn));
 }
 
 void HostIPCConnection::callCreateNetdevPhys(const api::CreateNetDevPhysIn& argIn)
 {
     mClient->callSync<api::CreateNetDevPhysIn, api::Void>(
-            api::METHOD_CREATE_NETDEV_PHYS,
+            api::ipc::METHOD_CREATE_NETDEV_PHYS,
             std::make_shared<api::CreateNetDevPhysIn>(argIn));
 }
 
 void HostIPCConnection::callDestroyNetdev(const api::DestroyNetDevIn& argIn)
 {
     mClient->callSync<api::DestroyNetDevIn, api::Void>(
-            api::METHOD_DESTROY_NETDEV,
+            api::ipc::METHOD_DESTROY_NETDEV,
             std::make_shared<api::DestroyNetDevIn>(argIn));
 }
 
 void HostIPCConnection::callDeleteNetdevIpAddress(const api::DeleteNetdevIpAddressIn& argIn)
 {
     mClient->callSync<api::DeleteNetdevIpAddressIn, api::Void>(
-            api::METHOD_DELETE_NETDEV_IP_ADDRESS,
+            api::ipc::METHOD_DELETE_NETDEV_IP_ADDRESS,
             std::make_shared<api::DeleteNetdevIpAddressIn>(argIn));
 }
 
 void HostIPCConnection::callDeclareFile(const api::DeclareFileIn& argIn, api::Declaration& argOut)
 {
     argOut = *mClient->callSync<api::DeclareFileIn, api::Declaration>(
-        api::METHOD_DECLARE_FILE,
+        api::ipc::METHOD_DECLARE_FILE,
         std::make_shared<api::DeclareFileIn>(argIn));
 }
 
 void HostIPCConnection::callDeclareMount(const api::DeclareMountIn& argIn, api::Declaration& argOut)
 {
     argOut = *mClient->callSync<api::DeclareMountIn, api::Declaration>(
-        api::METHOD_DECLARE_MOUNT,
+        api::ipc::METHOD_DECLARE_MOUNT,
         std::make_shared<api::DeclareMountIn>(argIn));
 }
 
 void HostIPCConnection::callDeclareLink(const api::DeclareLinkIn& argIn, api::Declaration& argOut)
 {
     argOut = *mClient->callSync<api::DeclareLinkIn, api::Declaration>(
-        api::METHOD_DECLARE_LINK,
+        api::ipc::METHOD_DECLARE_LINK,
         std::make_shared<api::DeclareLinkIn>(argIn));
 }
 
 void HostIPCConnection::callGetDeclarations(const api::ZoneId& argIn, api::Declarations& argOut)
 {
     argOut = *mClient->callSync<api::ZoneId, api::Declarations>(
-        api::METHOD_GET_DECLARATIONS,
+        api::ipc::METHOD_GET_DECLARATIONS,
         std::make_shared<api::ZoneId>(argIn));
 }
 
 void HostIPCConnection::callRemoveDeclaration(const api::RemoveDeclarationIn& argIn)
 {
     mClient->callSync<api::RemoveDeclarationIn, api::Void>(
-            api::METHOD_REMOVE_DECLARATION,
+            api::ipc::METHOD_REMOVE_DECLARATION,
             std::make_shared<api::RemoveDeclarationIn>(argIn));
 }
 
 void HostIPCConnection::callCreateZone(const api::CreateZoneIn& argIn)
 {
     mClient->callSync<api::CreateZoneIn, api::Void>(
-            api::METHOD_CREATE_ZONE,
+            api::ipc::METHOD_CREATE_ZONE,
             std::make_shared<api::CreateZoneIn>(argIn));
 }
 
 void HostIPCConnection::callDestroyZone(const api::ZoneId& argIn)
 {
     mClient->callSync<api::ZoneId, api::Void>(
-            api::METHOD_DESTROY_ZONE,
+            api::ipc::METHOD_DESTROY_ZONE,
             std::make_shared<api::ZoneId>(argIn));
 }
 
 void HostIPCConnection::callShutdownZone(const api::ZoneId& argIn)
 {
     mClient->callSync<api::ZoneId, api::Void>(
-            api::METHOD_SHUTDOWN_ZONE,
+            api::ipc::METHOD_SHUTDOWN_ZONE,
             std::make_shared<api::ZoneId>(argIn));
 }
 
 void HostIPCConnection::callStartZone(const api::ZoneId& argIn)
 {
     mClient->callSync<api::ZoneId, api::Void>(
-            api::METHOD_START_ZONE,
+            api::ipc::METHOD_START_ZONE,
             std::make_shared<api::ZoneId>(argIn));
 }
 
 void HostIPCConnection::callLockZone(const api::ZoneId& argIn)
 {
     mClient->callSync<api::ZoneId, api::Void>(
-            api::METHOD_LOCK_ZONE,
+            api::ipc::METHOD_LOCK_ZONE,
             std::make_shared<api::ZoneId>(argIn));
 }
 
 void HostIPCConnection::callUnlockZone(const api::ZoneId& argIn)
 {
     mClient->callSync<api::ZoneId, api::Void>(
-            api::METHOD_UNLOCK_ZONE,
+            api::ipc::METHOD_UNLOCK_ZONE,
             std::make_shared<api::ZoneId>(argIn));
 }
 
 void HostIPCConnection::callGrantDevice(const api::GrantDeviceIn& argIn)
 {
     mClient->callSync<api::GrantDeviceIn, api::Void>(
-            api::METHOD_GRANT_DEVICE,
+            api::ipc::METHOD_GRANT_DEVICE,
             std::make_shared<api::GrantDeviceIn>(argIn));
 }
 
 void HostIPCConnection::callRevokeDevice(const api::RevokeDeviceIn& argIn)
 {
     mClient->callSync<api::RevokeDeviceIn, api::Void>(
-            api::METHOD_REVOKE_DEVICE,
+            api::ipc::METHOD_REVOKE_DEVICE,
             std::make_shared<api::RevokeDeviceIn>(argIn));
 }
 
 void HostIPCConnection::callNotifyActiveZone(const api::NotifActiveZoneIn& argIn)
 {
     mClient->callSync<api::NotifActiveZoneIn, api::Void>(
-            api::METHOD_NOTIFY_ACTIVE_ZONE,
+            api::ipc::METHOD_NOTIFY_ACTIVE_ZONE,
             std::make_shared<api::NotifActiveZoneIn>(argIn));
 }
 
@@ -230,14 +230,14 @@ void HostIPCConnection::callFileMoveRequest(const api::FileMoveRequestIn& argIn,
                                             api::FileMoveRequestStatus& argOut)
 {
     argOut = *mClient->callSync<api::FileMoveRequestIn, api::FileMoveRequestStatus>(
-        api::METHOD_FILE_MOVE_REQUEST,
+        api::ipc::METHOD_FILE_MOVE_REQUEST,
         std::make_shared<api::FileMoveRequestIn>(argIn));
 }
 
 void HostIPCConnection::signalSwitchToDefault()
 {
 
-    mClient->signal(api::SIGNAL_SWITCH_TO_DEFAULT,
+    mClient->signal(api::ipc::SIGNAL_SWITCH_TO_DEFAULT,
                     std::make_shared<api::Void>());
 }
 
@@ -248,8 +248,8 @@ HostIPCConnection::subscribeNotification(const NotificationCallback& callback)
                                        std::shared_ptr<api::Notification>& data) {
         callback(*data);
     };
-    mClient->setSignalHandler<api::Notification>(api::SIGNAL_NOTIFICATION, callbackWrapper);
-    return api::SIGNAL_NOTIFICATION;
+    mClient->setSignalHandler<api::Notification>(api::ipc::SIGNAL_NOTIFICATION, callbackWrapper);
+    return api::ipc::SIGNAL_NOTIFICATION;
 }
 
 void HostIPCConnection::unsubscribe(const SubscriptionId& id)
index 99f3bc0..c6422dc 100644 (file)
@@ -42,7 +42,7 @@ namespace api {
 template<typename Data>
 class DbusMethodResultBuilder: public MethodResultBuilder {
 public:
-    DbusMethodResultBuilder(const dbus::MethodResultBuilder::Pointer& methodResultBuilderPtr);
+    DbusMethodResultBuilder(const ::dbus::MethodResultBuilder::Pointer& methodResultBuilderPtr);
     ~DbusMethodResultBuilder() {}
 
 private:
@@ -50,12 +50,12 @@ private:
     void setVoid() override;
     void setError(const std::string& name, const std::string& message) override;
 
-    dbus::MethodResultBuilder::Pointer mMethodResultBuilderPtr;
+    ::dbus::MethodResultBuilder::Pointer mMethodResultBuilderPtr;
     std::function<GVariant*(std::shared_ptr<void>)> mSerialize;
 };
 
 template<typename Data>
-DbusMethodResultBuilder<Data>::DbusMethodResultBuilder(const dbus::MethodResultBuilder::Pointer& methodResultBuilderPtr)
+DbusMethodResultBuilder<Data>::DbusMethodResultBuilder(const ::dbus::MethodResultBuilder::Pointer& methodResultBuilderPtr)
     : mMethodResultBuilderPtr(methodResultBuilderPtr)
 {
     mSerialize = [](const std::shared_ptr<void> data)->GVariant* {
index 55567c7..64c3662 100644 (file)
@@ -70,7 +70,8 @@ between them. A process from inside a zone can request a switch of context
          -DVASUM_USER=%{vsm_user} \
          -DINPUT_EVENT_GROUP=%{input_event_group} \
          -DDISK_GROUP=%{disk_group} \
-         -DTTY_GROUP=%{tty_group}
+         -DTTY_GROUP=%{tty_group} \
+         -DWITHOUT_DBUS=%{?without_dbus}
 make -k %{?jobs:-j%jobs}
 
 %install
index b93ad21..98325ac 100644 (file)
@@ -53,19 +53,19 @@ HostDbusConnection::HostDbusConnection()
     mDbusConnection = dbus::DbusConnection::createSystem();
 
     LOGT("Setting DBUS name");
-    mDbusConnection->setName(api::BUS_NAME,
+    mDbusConnection->setName(api::dbus::BUS_NAME,
                              std::bind(&HostDbusConnection::onNameAcquired, this),
                              std::bind(&HostDbusConnection::onNameLost, this));
 
     if (!waitForName(NAME_ACQUIRED_TIMEOUT)) {
-        LOGE("Could not acquire dbus name: " << api::BUS_NAME);
-        throw HostConnectionException("Could not acquire dbus name: " + api::BUS_NAME);
+        LOGE("Could not acquire dbus name: " << api::dbus::BUS_NAME);
+        throw HostConnectionException("Could not acquire dbus name: " + api::dbus::BUS_NAME);
     }
 
     LOGT("Registering DBUS interface");
     using namespace std::placeholders;
-    mDbusConnection->registerObject(api::OBJECT_PATH,
-                                    api::DEFINITION,
+    mDbusConnection->registerObject(api::dbus::OBJECT_PATH,
+                                    api::dbus::DEFINITION,
                                     std::bind(&HostDbusConnection::onMessageCall,
                                               this, _1, _2, _3, _4, _5));
 
@@ -267,11 +267,11 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
                                    GVariant* parameters,
                                    dbus::MethodResultBuilder::Pointer result)
 {
-    if (objectPath != api::OBJECT_PATH || interface != api::INTERFACE) {
+    if (objectPath != api::dbus::OBJECT_PATH || interface != api::dbus::INTERFACE) {
         return;
     }
 
-    if (methodName == api::METHOD_SET_ACTIVE_ZONE) {
+    if (methodName == api::dbus::METHOD_SET_ACTIVE_ZONE) {
         api::ZoneId zoneId;
         config::loadFromGVariant(parameters, zoneId);
 
@@ -282,7 +282,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::METHOD_PROXY_CALL) {
+    if (methodName == api::dbus::METHOD_PROXY_CALL) {
         const gchar* target = NULL;
         const gchar* targetBusName = NULL;
         const gchar* targetObjectPath = NULL;
@@ -311,7 +311,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::METHOD_GET_ZONE_ID_LIST) {
+    if (methodName == api::dbus::METHOD_GET_ZONE_ID_LIST) {
         if (mGetZoneIdsCallback) {
             auto rb = std::make_shared<api::DbusMethodResultBuilder<api::ZoneIds>>(result);
             mGetZoneIdsCallback(rb);
@@ -319,7 +319,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::METHOD_GET_ACTIVE_ZONE_ID) {
+    if (methodName == api::dbus::METHOD_GET_ACTIVE_ZONE_ID) {
         if (mGetActiveZoneIdCallback) {
             auto rb = std::make_shared<api::DbusMethodResultBuilder<api::ZoneId>>(result);
             mGetActiveZoneIdCallback(rb);
@@ -327,7 +327,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::METHOD_GET_ZONE_INFO) {
+    if (methodName == api::dbus::METHOD_GET_ZONE_INFO) {
         api::ZoneId zoneId;
         config::loadFromGVariant(parameters, zoneId);
 
@@ -338,7 +338,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::METHOD_SET_NETDEV_ATTRS) {
+    if (methodName == api::dbus::METHOD_SET_NETDEV_ATTRS) {
         api::SetNetDevAttrsIn data;
         config::loadFromGVariant(parameters, data);
 
@@ -349,7 +349,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::METHOD_GET_NETDEV_ATTRS) {
+    if (methodName == api::dbus::METHOD_GET_NETDEV_ATTRS) {
         api::GetNetDevAttrsIn data;
         config::loadFromGVariant(parameters, data);
 
@@ -360,7 +360,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::METHOD_GET_NETDEV_LIST) {
+    if (methodName == api::dbus::METHOD_GET_NETDEV_LIST) {
         api::ZoneId data;
         config::loadFromGVariant(parameters, data);
 
@@ -371,7 +371,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::METHOD_CREATE_NETDEV_VETH) {
+    if (methodName == api::dbus::METHOD_CREATE_NETDEV_VETH) {
         api::CreateNetDevVethIn data;
         config::loadFromGVariant(parameters, data);
 
@@ -382,7 +382,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::METHOD_CREATE_NETDEV_MACVLAN) {
+    if (methodName == api::dbus::METHOD_CREATE_NETDEV_MACVLAN) {
         api::CreateNetDevMacvlanIn data;
         config::loadFromGVariant(parameters, data);
 
@@ -392,7 +392,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         }
     }
 
-    if (methodName == api::METHOD_CREATE_NETDEV_PHYS) {
+    if (methodName == api::dbus::METHOD_CREATE_NETDEV_PHYS) {
         api::CreateNetDevPhysIn data;
         config::loadFromGVariant(parameters, data);
 
@@ -402,7 +402,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         }
     }
 
-    if (methodName == api::METHOD_DESTROY_NETDEV) {
+    if (methodName == api::dbus::METHOD_DESTROY_NETDEV) {
         api::DestroyNetDevIn data;
         config::loadFromGVariant(parameters, data);
 
@@ -412,7 +412,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         }
     }
 
-    if (methodName == api::METHOD_DELETE_NETDEV_IP_ADDRESS) {
+    if (methodName == api::dbus::METHOD_DELETE_NETDEV_IP_ADDRESS) {
         api::DeleteNetdevIpAddressIn data;
         config::loadFromGVariant(parameters, data);
         if (mDeleteNetdevIpAddressCallback) {
@@ -421,7 +421,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         }
     }
 
-    if (methodName == api::METHOD_DECLARE_FILE) {
+    if (methodName == api::dbus::METHOD_DECLARE_FILE) {
         api::DeclareFileIn data;
         config::loadFromGVariant(parameters, data);
 
@@ -432,7 +432,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::METHOD_DECLARE_MOUNT) {
+    if (methodName == api::dbus::METHOD_DECLARE_MOUNT) {
         api::DeclareMountIn data;
         config::loadFromGVariant(parameters, data);
 
@@ -443,7 +443,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::METHOD_DECLARE_LINK) {
+    if (methodName == api::dbus::METHOD_DECLARE_LINK) {
         api::DeclareLinkIn data;
         config::loadFromGVariant(parameters, data);
 
@@ -454,7 +454,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::METHOD_GET_DECLARATIONS) {
+    if (methodName == api::dbus::METHOD_GET_DECLARATIONS) {
         api::ZoneId data;
         config::loadFromGVariant(parameters, data);
 
@@ -465,7 +465,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::METHOD_REMOVE_DECLARATION) {
+    if (methodName == api::dbus::METHOD_REMOVE_DECLARATION) {
         api::RemoveDeclarationIn data;
         config::loadFromGVariant(parameters, data);
 
@@ -476,7 +476,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::METHOD_CREATE_ZONE) {
+    if (methodName == api::dbus::METHOD_CREATE_ZONE) {
         api::CreateZoneIn data;
         config::loadFromGVariant(parameters, data);
 
@@ -487,7 +487,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::METHOD_DESTROY_ZONE) {
+    if (methodName == api::dbus::METHOD_DESTROY_ZONE) {
         api::ZoneId data;
         config::loadFromGVariant(parameters, data);
 
@@ -498,7 +498,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::METHOD_SHUTDOWN_ZONE) {
+    if (methodName == api::dbus::METHOD_SHUTDOWN_ZONE) {
         api::ZoneId data;
         config::loadFromGVariant(parameters, data);
 
@@ -508,7 +508,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         }
     }
 
-    if (methodName == api::METHOD_START_ZONE) {
+    if (methodName == api::dbus::METHOD_START_ZONE) {
         api::ZoneId data;
         config::loadFromGVariant(parameters, data);
 
@@ -518,7 +518,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         }
     }
 
-    if (methodName == api::METHOD_LOCK_ZONE) {
+    if (methodName == api::dbus::METHOD_LOCK_ZONE) {
         api::ZoneId data;
         config::loadFromGVariant(parameters, data);
 
@@ -529,7 +529,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::METHOD_UNLOCK_ZONE) {
+    if (methodName == api::dbus::METHOD_UNLOCK_ZONE) {
         api::ZoneId data;
         config::loadFromGVariant(parameters, data);
 
@@ -540,7 +540,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::METHOD_GRANT_DEVICE) {
+    if (methodName == api::dbus::METHOD_GRANT_DEVICE) {
         api::GrantDeviceIn data;
         config::loadFromGVariant(parameters, data);
 
@@ -551,7 +551,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::METHOD_REVOKE_DEVICE) {
+    if (methodName == api::dbus::METHOD_REVOKE_DEVICE) {
         api::RevokeDeviceIn data;
         config::loadFromGVariant(parameters, data);
 
@@ -562,7 +562,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::METHOD_NOTIFY_ACTIVE_ZONE) {
+    if (methodName == api::dbus::METHOD_NOTIFY_ACTIVE_ZONE) {
         api::NotifActiveZoneIn data;
         config::loadFromGVariant(parameters, data);
 
@@ -572,7 +572,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         }
     }
 
-    if (methodName == api::METHOD_FILE_MOVE_REQUEST) {
+    if (methodName == api::dbus::METHOD_FILE_MOVE_REQUEST) {
         api::FileMoveRequestIn data;
         config::loadFromGVariant(parameters, data);
 
@@ -589,11 +589,11 @@ void HostDbusConnection::onSignalCall(const std::string& /* senderBusName */,
                                       const std::string& signalName,
                                       GVariant* /* parameters */)
 {
-    if (objectPath != api::OBJECT_PATH || interface != api::INTERFACE) {
+    if (objectPath != api::dbus::OBJECT_PATH || interface != api::dbus::INTERFACE) {
         return;
     }
 
-    if (signalName == api::SIGNAL_SWITCH_TO_DEFAULT) {
+    if (signalName == api::dbus::SIGNAL_SWITCH_TO_DEFAULT) {
         if (mSwitchToDefaultCallback) {
             mSwitchToDefaultCallback();
         }
@@ -622,9 +622,9 @@ void HostDbusConnection::sendNotification(const api::Notification& notify)
                                          notify.zone.c_str(),
                                          notify.application.c_str(),
                                          notify.message.c_str());
-    mDbusConnection->emitSignal(api::OBJECT_PATH,
-                                api::INTERFACE,
-                                api::SIGNAL_NOTIFICATION,
+    mDbusConnection->emitSignal(api::dbus::OBJECT_PATH,
+                                api::dbus::INTERFACE,
+                                api::dbus::SIGNAL_NOTIFICATION,
                                 parameters);
 }
 
index 208276e..2d013c9 100644 (file)
@@ -29,6 +29,7 @@
 
 namespace vasum {
 namespace api {
+namespace dbus {
 
 const std::string BUS_NAME                        = "org.tizen.vasum.host";
 const std::string OBJECT_PATH                     = "/org/tizen/vasum/host";
@@ -228,6 +229,7 @@ const std::string DEFINITION =
     "  </interface>"
     "</node>";
 
+} // namespace dbus
 } // namespace api
 } // namespace vasum
 
index 1bf2e78..d6519e9 100644 (file)
@@ -49,7 +49,7 @@ void HostIPCConnection::setGetZoneIdsCallback(const Method<api::ZoneIds>::type&
 {
     typedef IPCMethodWrapper<api::ZoneIds> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::METHOD_GET_ZONE_ID_LIST,
+        api::ipc::METHOD_GET_ZONE_ID_LIST,
         Callback::getWrapper(callback));
 
 }
@@ -58,7 +58,7 @@ void HostIPCConnection::setGetActiveZoneIdCallback(const Method<api::ZoneId>::ty
 {
     typedef IPCMethodWrapper<api::ZoneId> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::METHOD_GET_ACTIVE_ZONE_ID,
+        api::ipc::METHOD_GET_ACTIVE_ZONE_ID,
         Callback::getWrapper(callback));
 
 }
@@ -67,7 +67,7 @@ void HostIPCConnection::setGetZoneInfoCallback(const Method<const api::ZoneId, a
 {
     typedef IPCMethodWrapper<const api::ZoneId, api::ZoneInfoOut> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::METHOD_GET_ZONE_INFO,
+        api::ipc::METHOD_GET_ZONE_INFO,
         Callback::getWrapper(callback));
 }
 
@@ -75,7 +75,7 @@ void HostIPCConnection::setSetNetdevAttrsCallback(const Method<const api::SetNet
 {
     typedef IPCMethodWrapper<const api::SetNetDevAttrsIn> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::METHOD_SET_NETDEV_ATTRS,
+        api::ipc::METHOD_SET_NETDEV_ATTRS,
         Callback::getWrapper(callback));
 }
 
@@ -83,7 +83,7 @@ void HostIPCConnection::setGetNetdevAttrsCallback(const Method<const api::GetNet
 {
     typedef IPCMethodWrapper<const api::GetNetDevAttrsIn, api::GetNetDevAttrs> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::METHOD_GET_NETDEV_ATTRS,
+        api::ipc::METHOD_GET_NETDEV_ATTRS,
         Callback::getWrapper(callback));
 }
 
@@ -91,7 +91,7 @@ void HostIPCConnection::setGetNetdevListCallback(const Method<const api::ZoneId,
 {
     typedef IPCMethodWrapper<const api::ZoneId, api::NetDevList> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::METHOD_GET_NETDEV_LIST,
+        api::ipc::METHOD_GET_NETDEV_LIST,
         Callback::getWrapper(callback));
 }
 
@@ -99,7 +99,7 @@ void HostIPCConnection::setCreateNetdevVethCallback(const Method<const api::Crea
 {
     typedef IPCMethodWrapper<const api::CreateNetDevVethIn> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::METHOD_CREATE_NETDEV_VETH,
+        api::ipc::METHOD_CREATE_NETDEV_VETH,
         Callback::getWrapper(callback));
 }
 
@@ -107,7 +107,7 @@ void HostIPCConnection::setCreateNetdevMacvlanCallback(const Method<const api::C
 {
     typedef IPCMethodWrapper<const api::CreateNetDevMacvlanIn> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::METHOD_CREATE_NETDEV_MACVLAN,
+        api::ipc::METHOD_CREATE_NETDEV_MACVLAN,
         Callback::getWrapper(callback));
 }
 
@@ -115,7 +115,7 @@ void HostIPCConnection::setCreateNetdevPhysCallback(const Method<const api::Crea
 {
     typedef IPCMethodWrapper<const api::CreateNetDevPhysIn> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::METHOD_CREATE_NETDEV_PHYS,
+        api::ipc::METHOD_CREATE_NETDEV_PHYS,
         Callback::getWrapper(callback));
 }
 
@@ -123,7 +123,7 @@ void HostIPCConnection::setDestroyNetdevCallback(const Method<const api::Destroy
 {
     typedef IPCMethodWrapper<const api::DestroyNetDevIn> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::METHOD_DESTROY_NETDEV,
+        api::ipc::METHOD_DESTROY_NETDEV,
         Callback::getWrapper(callback));
 }
 
@@ -131,7 +131,7 @@ void HostIPCConnection::setDeleteNetdevIpAddressCallback(const Method<const api:
 {
     typedef IPCMethodWrapper<const api::DeleteNetdevIpAddressIn> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::METHOD_DELETE_NETDEV_IP_ADDRESS,
+        api::ipc::METHOD_DELETE_NETDEV_IP_ADDRESS,
         Callback::getWrapper(callback));
 }
 
@@ -139,7 +139,7 @@ void HostIPCConnection::setDeclareFileCallback(const Method<const api::DeclareFi
 {
     typedef IPCMethodWrapper<const api::DeclareFileIn, api::Declaration> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::METHOD_DECLARE_FILE,
+        api::ipc::METHOD_DECLARE_FILE,
         Callback::getWrapper(callback));
 }
 
@@ -147,7 +147,7 @@ void HostIPCConnection::setDeclareMountCallback(const Method<const api::DeclareM
 {
     typedef IPCMethodWrapper<const api::DeclareMountIn, api::Declaration> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::METHOD_DECLARE_MOUNT,
+        api::ipc::METHOD_DECLARE_MOUNT,
         Callback::getWrapper(callback));
 }
 
@@ -155,7 +155,7 @@ void HostIPCConnection::setDeclareLinkCallback(const Method<const api::DeclareLi
 {
     typedef IPCMethodWrapper<const api::DeclareLinkIn, api::Declaration> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::METHOD_DECLARE_LINK,
+        api::ipc::METHOD_DECLARE_LINK,
         Callback::getWrapper(callback));
 }
 
@@ -163,7 +163,7 @@ void HostIPCConnection::setGetDeclarationsCallback(const Method<const api::ZoneI
 {
     typedef IPCMethodWrapper<const api::ZoneId, api::Declarations> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::METHOD_GET_DECLARATIONS,
+        api::ipc::METHOD_GET_DECLARATIONS,
         Callback::getWrapper(callback));
 }
 
@@ -171,7 +171,7 @@ void HostIPCConnection::setRemoveDeclarationCallback(const Method<const api::Rem
 {
     typedef IPCMethodWrapper<const api::RemoveDeclarationIn> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::METHOD_REMOVE_DECLARATION,
+        api::ipc::METHOD_REMOVE_DECLARATION,
         Callback::getWrapper(callback));
 }
 
@@ -179,7 +179,7 @@ void HostIPCConnection::setSetActiveZoneCallback(const Method<const api::ZoneId>
 {
     typedef IPCMethodWrapper<const api::ZoneId> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::METHOD_SET_ACTIVE_ZONE,
+        api::ipc::METHOD_SET_ACTIVE_ZONE,
         Callback::getWrapper(callback));
 }
 
@@ -187,7 +187,7 @@ void HostIPCConnection::setCreateZoneCallback(const Method<const api::CreateZone
 {
     typedef IPCMethodWrapper<const api::CreateZoneIn> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::METHOD_CREATE_ZONE,
+        api::ipc::METHOD_CREATE_ZONE,
         Callback::getWrapper(callback));
 }
 
@@ -195,7 +195,7 @@ void HostIPCConnection::setDestroyZoneCallback(const Method<const api::ZoneId>::
 {
     typedef IPCMethodWrapper<const api::ZoneId> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::METHOD_DESTROY_ZONE,
+        api::ipc::METHOD_DESTROY_ZONE,
         Callback::getWrapper(callback));
 }
 
@@ -203,7 +203,7 @@ void HostIPCConnection::setShutdownZoneCallback(const Method<const api::ZoneId>:
 {
     typedef IPCMethodWrapper<const api::ZoneId> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::METHOD_SHUTDOWN_ZONE,
+        api::ipc::METHOD_SHUTDOWN_ZONE,
         Callback::getWrapper(callback));
 }
 
@@ -211,7 +211,7 @@ void HostIPCConnection::setStartZoneCallback(const Method<const api::ZoneId>::ty
 {
     typedef IPCMethodWrapper<const api::ZoneId> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::METHOD_START_ZONE,
+        api::ipc::METHOD_START_ZONE,
         Callback::getWrapper(callback));
 }
 
@@ -219,7 +219,7 @@ void HostIPCConnection::setLockZoneCallback(const Method<const api::ZoneId>::typ
 {
     typedef IPCMethodWrapper<const api::ZoneId> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::METHOD_LOCK_ZONE,
+        api::ipc::METHOD_LOCK_ZONE,
         Callback::getWrapper(callback));
 }
 
@@ -227,7 +227,7 @@ void HostIPCConnection::setUnlockZoneCallback(const Method<const api::ZoneId>::t
 {
     typedef IPCMethodWrapper<const api::ZoneId> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::METHOD_UNLOCK_ZONE,
+        api::ipc::METHOD_UNLOCK_ZONE,
         Callback::getWrapper(callback));
 }
 
@@ -235,7 +235,7 @@ void HostIPCConnection::setGrantDeviceCallback(const Method<const api::GrantDevi
 {
     typedef IPCMethodWrapper<const api::GrantDeviceIn> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::METHOD_GRANT_DEVICE,
+        api::ipc::METHOD_GRANT_DEVICE,
         Callback::getWrapper(callback));
 }
 
@@ -243,7 +243,7 @@ void HostIPCConnection::setRevokeDeviceCallback(const Method<const api::RevokeDe
 {
     typedef IPCMethodWrapper<const api::RevokeDeviceIn> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::METHOD_REVOKE_DEVICE,
+        api::ipc::METHOD_REVOKE_DEVICE,
         Callback::getWrapper(callback));
 }
 
@@ -252,7 +252,7 @@ void HostIPCConnection::setNotifyActiveZoneCallback(
 {
     typedef IPCMethodWrapper<const api::NotifActiveZoneIn> Method;
     mService->setMethodHandler<Method::out, Method::in>(
-        api::METHOD_NOTIFY_ACTIVE_ZONE,
+        api::ipc::METHOD_NOTIFY_ACTIVE_ZONE,
         Method::getWrapper(callback));
 }
 
@@ -260,7 +260,7 @@ void HostIPCConnection::setSwitchToDefaultCallback(const Signal<const api::Void>
 {
     typedef IPCSignalWrapper<const api::Void> Signal;
     mService->setSignalHandler<Signal::in>(
-        api::SIGNAL_SWITCH_TO_DEFAULT,
+        api::ipc::SIGNAL_SWITCH_TO_DEFAULT,
         Signal::getWrapper(callback));
 }
 
@@ -269,13 +269,13 @@ void HostIPCConnection::setFileMoveCallback(const Method<const api::FileMoveRequ
 {
     typedef IPCMethodWrapper<const api::FileMoveRequestIn, api::FileMoveRequestStatus> Method;
     mService->setMethodHandler<Method::out, Method::in>(
-        api::METHOD_FILE_MOVE_REQUEST,
+        api::ipc::METHOD_FILE_MOVE_REQUEST,
         Method::getWrapper(callback));
 }
 
 void HostIPCConnection::sendNotification(const api::Notification& notification)
 {
-    mService->signal(api::SIGNAL_NOTIFICATION,
+    mService->signal(api::ipc::SIGNAL_NOTIFICATION,
                      std::make_shared<api::Notification>(notification));
 }
 
index 8c31339..a54b679 100644 (file)
@@ -29,6 +29,7 @@
 
 namespace vasum {
 namespace api {
+namespace ipc {
 
 const vasum::ipc::MethodID METHOD_GET_ZONE_ID_LIST         = 2;
 const vasum::ipc::MethodID METHOD_GET_ACTIVE_ZONE_ID       = 3;
@@ -68,6 +69,7 @@ const std::string FILE_MOVE_NO_PERMISSIONS_RECEIVE  = "FILE_MOVE_NO_PERMISSIONS_
 const std::string FILE_MOVE_FAILED                  = "FILE_MOVE_FAILED";
 const std::string FILE_MOVE_SUCCEEDED               = "FILE_MOVE_SUCCEEDED";
 
+} // namespace ipc
 } // namespace api
 } // namespace vasum
 
index e6621d8..953fad0 100644 (file)
 
 #include "config.hpp"
 
-#ifdef DBUS_CONNECTION
-#include "host-dbus-definitions.hpp"
-#else
-#include "host-ipc-definitions.hpp"
-#endif
 #include "common-definitions.hpp"
 #include "dynamic-config-scheme.hpp"
 #include "zones-manager.hpp"
@@ -117,109 +112,115 @@ bool zoneIsRunning(const std::unique_ptr<Zone>& zone) {
 
 } // namespace
 
-ZonesManager::ZonesManager(const std::string& configPath)
-    : mWorker(utils::Worker::create())
-    , mDetachOnExit(false)
+template<typename Connection>
+void ZonesManager::setHandlers(Connection& connection)
 {
-    LOGD("Instantiating ZonesManager object...");
+    using namespace std::placeholders;
+    connection.setGetZoneIdsCallback(bind(&ZonesManager::handleGetZoneIdsCall,
+                                          this, _1));
 
-    config::loadFromJsonFile(configPath, mConfig);
-    config::loadFromKVStoreWithJsonFile(mConfig.dbPath,
-                                        configPath,
-                                        mDynamicConfig,
-                                        getVasumDbPrefix());
+    connection.setGetActiveZoneIdCallback(bind(&ZonesManager::handleGetActiveZoneIdCall,
+                                               this, _1));
 
+    connection.setGetZoneInfoCallback(bind(&ZonesManager::handleGetZoneInfoCall,
+                                           this, _1, _2));
 
-    using namespace std::placeholders;
-#ifdef DBUS_CONNECTION
-    mProxyCallPolicy.reset(new ProxyCallPolicy(mConfig.proxyCallRules));
-    mHostConnection.setProxyCallCallback(bind(&ZonesManager::handleProxyCall,
-                                              this, HOST_ID, _1, _2, _3, _4, _5, _6, _7));
-#endif
+    connection.setSetNetdevAttrsCallback(bind(&ZonesManager::handleSetNetdevAttrsCall,
+                                              this, _1, _2));
 
-    mHostConnection.setGetZoneIdsCallback(bind(&ZonesManager::handleGetZoneIdsCall,
-                                               this, _1));
+    connection.setGetNetdevAttrsCallback(bind(&ZonesManager::handleGetNetdevAttrsCall,
+                                              this, _1, _2));
 
-    mHostConnection.setGetActiveZoneIdCallback(bind(&ZonesManager::handleGetActiveZoneIdCall,
-                                                    this, _1));
+    connection.setGetNetdevListCallback(bind(&ZonesManager::handleGetNetdevListCall,
+                                             this, _1, _2));
 
-    mHostConnection.setGetZoneInfoCallback(bind(&ZonesManager::handleGetZoneInfoCall,
+    connection.setCreateNetdevVethCallback(bind(&ZonesManager::handleCreateNetdevVethCall,
                                                 this, _1, _2));
 
-    mHostConnection.setSetNetdevAttrsCallback(bind(&ZonesManager::handleSetNetdevAttrsCall,
+    connection.setCreateNetdevMacvlanCallback(bind(&ZonesManager::handleCreateNetdevMacvlanCall,
                                                    this, _1, _2));
 
-    mHostConnection.setGetNetdevAttrsCallback(bind(&ZonesManager::handleGetNetdevAttrsCall,
-                                                   this, _1, _2));
+    connection.setCreateNetdevPhysCallback(bind(&ZonesManager::handleCreateNetdevPhysCall,
+                                                this, _1, _2));
 
-    mHostConnection.setGetNetdevListCallback(bind(&ZonesManager::handleGetNetdevListCall,
-                                                  this, _1, _2));
+    connection.setDestroyNetdevCallback(bind(&ZonesManager::handleDestroyNetdevCall,
+                                             this, _1, _2));
 
-    mHostConnection.setCreateNetdevVethCallback(bind(&ZonesManager::handleCreateNetdevVethCall,
+    connection.setDeleteNetdevIpAddressCallback(bind(&ZonesManager::handleDeleteNetdevIpAddressCall,
                                                      this, _1, _2));
 
-    mHostConnection.setCreateNetdevMacvlanCallback(bind(&ZonesManager::handleCreateNetdevMacvlanCall,
-                                                        this, _1, _2));
+    connection.setDeclareFileCallback(bind(&ZonesManager::handleDeclareFileCall,
+                                           this, _1, _2));
 
-    mHostConnection.setCreateNetdevPhysCallback(bind(&ZonesManager::handleCreateNetdevPhysCall,
-                                                     this, _1, _2));
-
-    mHostConnection.setDestroyNetdevCallback(bind(&ZonesManager::handleDestroyNetdevCall,
-                                                  this, _1, _2));
+    connection.setDeclareMountCallback(bind(&ZonesManager::handleDeclareMountCall,
+                                            this, _1, _2));
 
-    mHostConnection.setDeleteNetdevIpAddressCallback(bind(&ZonesManager::handleDeleteNetdevIpAddressCall,
-                                                          this, _1, _2));
+    connection.setDeclareLinkCallback(bind(&ZonesManager::handleDeclareLinkCall,
+                                           this, _1, _2));
 
-    mHostConnection.setDeclareFileCallback(bind(&ZonesManager::handleDeclareFileCall,
-                                                this, _1, _2));
+    connection.setGetDeclarationsCallback(bind(&ZonesManager::handleGetDeclarationsCall,
+                                               this, _1, _2));
 
-    mHostConnection.setDeclareMountCallback(bind(&ZonesManager::handleDeclareMountCall,
+    connection.setRemoveDeclarationCallback(bind(&ZonesManager::handleRemoveDeclarationCall,
                                                  this, _1, _2));
 
-    mHostConnection.setDeclareLinkCallback(bind(&ZonesManager::handleDeclareLinkCall,
-                                                this, _1, _2));
+    connection.setSetActiveZoneCallback(bind(&ZonesManager::handleSetActiveZoneCall,
+                                             this, _1, _2));
 
-    mHostConnection.setGetDeclarationsCallback(bind(&ZonesManager::handleGetDeclarationsCall,
-                                                    this, _1, _2));
+    connection.setCreateZoneCallback(bind(&ZonesManager::handleCreateZoneCall,
+                                          this, _1, _2));
 
-    mHostConnection.setRemoveDeclarationCallback(bind(&ZonesManager::handleRemoveDeclarationCall,
-                                                      this, _1, _2));
+    connection.setDestroyZoneCallback(bind(&ZonesManager::handleDestroyZoneCall,
+                                           this, _1, _2));
 
-    mHostConnection.setSetActiveZoneCallback(bind(&ZonesManager::handleSetActiveZoneCall,
-                                                  this, _1, _2));
+    connection.setShutdownZoneCallback(bind(&ZonesManager::handleShutdownZoneCall,
+                                            this, _1, _2));
 
-    mHostConnection.setCreateZoneCallback(bind(&ZonesManager::handleCreateZoneCall,
-                                               this, _1, _2));
+    connection.setStartZoneCallback(bind(&ZonesManager::handleStartZoneCall,
+                                         this, _1, _2));
 
-    mHostConnection.setDestroyZoneCallback(bind(&ZonesManager::handleDestroyZoneCall,
-                                                this, _1, _2));
+    connection.setLockZoneCallback(bind(&ZonesManager::handleLockZoneCall,
+                                        this, _1, _2));
 
-    mHostConnection.setShutdownZoneCallback(bind(&ZonesManager::handleShutdownZoneCall,
-                                                 this, _1, _2));
+    connection.setUnlockZoneCallback(bind(&ZonesManager::handleUnlockZoneCall,
+                                          this, _1, _2));
 
-    mHostConnection.setStartZoneCallback(bind(&ZonesManager::handleStartZoneCall,
-                                              this, _1, _2));
+    connection.setGrantDeviceCallback(bind(&ZonesManager::handleGrantDeviceCall,
+                                           this, _1, _2));
 
-    mHostConnection.setLockZoneCallback(bind(&ZonesManager::handleLockZoneCall,
-                                             this, _1, _2));
+    connection.setRevokeDeviceCallback(bind(&ZonesManager::handleRevokeDeviceCall,
+                                            this, _1, _2));
 
-    mHostConnection.setUnlockZoneCallback(bind(&ZonesManager::handleUnlockZoneCall,
-                                               this, _1, _2));
+    connection.setNotifyActiveZoneCallback(bind(&ZonesManager::handleNotifyActiveZoneCall,
+                                      this, "", _1, _2));
 
-    mHostConnection.setGrantDeviceCallback(bind(&ZonesManager::handleGrantDeviceCall,
-                                                this, _1, _2));
+    connection.setSwitchToDefaultCallback(bind(&ZonesManager::handleSwitchToDefaultCall,
+                                     this, ""));
 
-    mHostConnection.setRevokeDeviceCallback(bind(&ZonesManager::handleRevokeDeviceCall,
-                                                 this, _1, _2));
+    connection.setFileMoveCallback(bind(&ZonesManager::handleFileMoveCall,
+                                        this, "", _1, _2));
+}
 
-    mHostConnection.setNotifyActiveZoneCallback(bind(&ZonesManager::handleNotifyActiveZoneCall,
-                                           this, "", _1, _2));
+ZonesManager::ZonesManager(const std::string& configPath)
+    : mWorker(utils::Worker::create())
+    , mDetachOnExit(false)
+{
+    LOGD("Instantiating ZonesManager object...");
 
-    mHostConnection.setSwitchToDefaultCallback(bind(&ZonesManager::handleSwitchToDefaultCall,
-                                          this, ""));
+    config::loadFromJsonFile(configPath, mConfig);
+    config::loadFromKVStoreWithJsonFile(mConfig.dbPath,
+                                        configPath,
+                                        mDynamicConfig,
+                                        getVasumDbPrefix());
 
-    mHostConnection.setFileMoveCallback(bind(&ZonesManager::handleFileMoveCall,
-                                        this, "", _1, _2));
+    setHandlers(mHostIPCConnection);
+#ifdef DBUS_CONNECTION
+    using namespace std::placeholders;
+    mProxyCallPolicy.reset(new ProxyCallPolicy(mConfig.proxyCallRules));
+    mHostDbusConnection.setProxyCallCallback(bind(&ZonesManager::handleProxyCall,
+                                                  this, HOST_ID, _1, _2, _3, _4, _5, _6, _7));
+    setHandlers(mHostDbusConnection);
+#endif //DBUS_CONNECTION
 
     for (const auto& zoneId : mDynamicConfig.zoneIds) {
         insertZone(zoneId, getTemplatePathForExistingZone(zoneId));
@@ -737,14 +738,14 @@ void ZonesManager::handleProxyCall(const std::string& caller,
         return;
     }
 
-    mHostConnection.proxyCallAsync(targetBusName,
-                                   targetObjectPath,
-                                   targetInterface,
-                                   targetMethod,
-                                   parameters,
-                                   asyncResultCallback);
+    mHostDbusConnection.proxyCallAsync(targetBusName,
+                                       targetObjectPath,
+                                       targetInterface,
+                                       targetMethod,
+                                       parameters,
+                                       asyncResultCallback);
 }
-#endif
+#endif //DBUS_CONNECTION
 
 void ZonesManager::handleGetZoneIdsCall(api::MethodResultBuilder::Pointer result)
 {
index 42477ae..2a2f6d7 100644 (file)
 
 #include "zone.hpp"
 #include "zones-manager-config.hpp"
-#ifdef DBUS_CONNECTION
-#include "host-dbus-connection.hpp"
-#include "proxy-call-policy.hpp"
-#else
 #include "host-ipc-connection.hpp"
-#endif
 #include "input-monitor.hpp"
 #include "utils/worker.hpp"
 #include "api/method-result-builder.hpp"
 
+#ifdef DBUS_CONNECTION
+#include "host-dbus-connection.hpp"
+#include "proxy-call-policy.hpp"
+#endif //DBUS_CONNECTION
+
 #include <string>
 #include <memory>
 
@@ -118,17 +118,15 @@ public:
 private:
     typedef std::recursive_mutex Mutex;
     typedef std::unique_lock<Mutex> Lock;
-#ifdef DBUS_CONNECTION
-    typedef HostDbusConnection HostConnection;
-#else
-    typedef HostIPCConnection HostConnection;
-#endif
 
     utils::Worker::Pointer mWorker;
     Mutex mMutex; // used to protect mZones
     ZonesManagerConfig mConfig; //TODO make it const
     ZonesManagerDynamicConfig mDynamicConfig;
-    HostConnection mHostConnection;
+#ifdef DBUS_CONNECTION
+    HostDbusConnection mHostDbusConnection;
+#endif //DBUS_CONNECTION
+    HostIPCConnection mHostIPCConnection;
     // to hold InputMonitor pointer to monitor if zone switching sequence is recognized
     std::unique_ptr<InputMonitor> mSwitchingSequenceMonitor;
     // like set but keep insertion order
@@ -172,7 +170,7 @@ private:
                          const std::string& targetMethod,
                          GVariant* parameters,
                          dbus::MethodResultBuilder::Pointer result);
-#endif
+#endif //DBUS_CONNECTION
     // Handlers --------------------------------------------------------
     void handleGetZoneIdsCall(api::MethodResultBuilder::Pointer result);
     void handleGetActiveZoneIdCall(api::MethodResultBuilder::Pointer result);
@@ -222,6 +220,9 @@ private:
                                api::MethodResultBuilder::Pointer result);
     void handleRevokeDeviceCall(const api::RevokeDeviceIn& data,
                                 api::MethodResultBuilder::Pointer result);
+
+    template<typename Connection>
+    void setHandlers(Connection& connnection);
 };
 
 
index f0e6b2e..adc325e 100644 (file)
@@ -23,8 +23,6 @@
  * @brief   Unit tests of the client C API
  */
 
-#ifndef DBUS_CONNECTION
-
 #include <config.hpp>
 #include "ut.hpp"
 #include <vasum-client.h>
 #include "host-ipc-definitions.hpp"
 #include "logger/logger.hpp"
 
+#ifdef DBUS_CONNECTION
+#include "utils/glib-loop.hpp"
+#endif //DBUS_CONNECTION
+
 #include <map>
 #include <string>
 #include <utility>
@@ -56,6 +58,9 @@ const std::string TEMPLATE_NAME = "console-ipc";
 struct Fixture {
     utils::ScopedDir mZonesPathGuard;
     utils::ScopedDir mRunGuard;
+#ifdef DBUS_CONNECTION
+    utils::ScopedGlibLoop mLoop;
+#endif //DBUS_CONNECTION
 
     std::unique_ptr<ZonesManager> cm;
 
@@ -412,5 +417,3 @@ BOOST_AUTO_TEST_CASE(ZoneGetNetdevs)
 
 
 BOOST_AUTO_TEST_SUITE_END()
-
-#endif /* !DBUS_CONNECTION */
index c5880b1..a91d5d8 100644 (file)
@@ -46,10 +46,6 @@ CONFIGURE_FILE(ut-zones-manager/test-daemon.conf.in
                ${CMAKE_BINARY_DIR}/ut-zones-manager/test-daemon.conf @ONLY)
 FILE(GLOB manager_manager_CONF_GEN ${CMAKE_BINARY_DIR}/ut-zones-manager/*.conf)
 
-CONFIGURE_FILE(ut-zones-manager/templates/console-dbus.conf.in
-               ${CMAKE_BINARY_DIR}/ut-zones-manager/templates/console-dbus.conf @ONLY)
-CONFIGURE_FILE(ut-zones-manager/templates/console-ipc.conf.in
-               ${CMAKE_BINARY_DIR}/ut-zones-manager/templates/console-ipc.conf @ONLY)
 FILE(GLOB manager_templates_CONF_GEN ${CMAKE_BINARY_DIR}/ut-zones-manager/templates/*.conf)
 
 
diff --git a/tests/unit_tests/server/configs/ut-zones-manager/templates/console-dbus.conf.in b/tests/unit_tests/server/configs/ut-zones-manager/templates/console-dbus.conf.in
deleted file mode 100644 (file)
index 2ff5998..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-{
-    "lxcTemplate" : "minimal-dbus.sh",
-    "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; /usr/bin/dbus-daemon --config-file=@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-zones-manager/ut-dbus.conf --fork; read"],
-    "requestedState" : "running",
-    "ipv4Gateway" : "",
-    "ipv4" : "",
-    "privilege" : 20,
-    "vt" : -1,
-    "switchToDefaultAfterTimeout" : true,
-    "cpuQuotaForeground" : -1,
-    "cpuQuotaBackground" : 1000,
-    "shutdownTimeout" : 10,
-    "runMountPoint" : "/tmp/ut-run/~NAME~",
-    "provisions" : [],
-    "permittedToSend" : [ "/tmp/.*" ],
-    "permittedToRecv" : [ "/tmp/.*" ],
-    "validLinkPrefixes" : []
-}
diff --git a/tests/unit_tests/server/configs/ut-zones-manager/templates/console-ipc.conf.in b/tests/unit_tests/server/configs/ut-zones-manager/templates/console-ipc.conf.in
deleted file mode 100644 (file)
index fab7e58..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-{
-    "lxcTemplate" : "minimal.sh",
-    "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"],
-    "requestedState" : "running",
-    "ipv4Gateway" : "",
-    "ipv4" : "",
-    "privilege" : 20,
-    "vt" : -1,
-    "switchToDefaultAfterTimeout" : true,
-    "cpuQuotaForeground" : -1,
-    "cpuQuotaBackground" : 1000,
-    "shutdownTimeout" : 10,
-    "runMountPoint" : "/tmp/ut-run/~NAME~",
-    "provisions" : [],
-    "permittedToSend" : [ "/tmp/.*" ],
-    "permittedToRecv" : [ "/tmp/.*" ],
-    "validLinkPrefixes" : []
-}
index a2811a9..e052117 100644 (file)
 #include "test-dbus-definitions.hpp"
 #include "dbus/connection.hpp"
 #include "dbus/exception.hpp"
-#else
+#endif //DBUS_CONNECTION
 #include "host-ipc-definitions.hpp"
 #include <api/messages.hpp>
 #include <epoll/thread-dispatcher.hpp>
 #include <ipc/client.hpp>
-#endif
 #include "exception.hpp"
 
 #include "utils/glib-loop.hpp"
@@ -65,7 +64,8 @@ using namespace config;
 using namespace vasum::utils;
 #ifdef DBUS_CONNECTION
 using namespace dbus;
-#endif
+#endif //DBUS_CONNECTION
+
 
 namespace {
 
@@ -82,11 +82,6 @@ const std::string FILE_CONTENT = "File content\n"
 const std::string NON_EXISTANT_ZONE_ID = "NON_EXISTANT_ZONE_ID";
 const std::string ZONES_PATH = "/tmp/ut-zones"; // the same as in daemon.conf
 const std::string SIMPLE_TEMPLATE = "console";
-#ifdef DBUS_CONNECTION
-const std::string ZONE_ACCESS_TEMPLATE = "console-dbus";
-#else
-const std::string ZONE_ACCESS_TEMPLATE = "console-ipc";
-#endif
 
 #ifdef DBUS_CONNECTION
 /**
@@ -105,7 +100,7 @@ dropException(const DbusConnection::AsyncMethodCallCallback& fun)
     };
 }
 
-class DbusAccessory {
+class HostDbusAccessory {
 public:
     static const int HOST_ID = 0;
 
@@ -114,10 +109,9 @@ public:
                               )> TestApiMethodCallback;
     typedef std::function<void()> VoidResultCallback;
     typedef std::function<void(const api::Notification)> NotificationCallback;
-
     typedef std::map<std::string, std::string> Connections;
 
-    DbusAccessory()
+    HostDbusAccessory()
         : mId(0),
           mClient(DbusConnection::create(acquireAddress())),
           mNameAcquired(false),
@@ -125,7 +119,7 @@ public:
     {
     }
 
-    DbusAccessory(int id)
+    HostDbusAccessory(int id)
         : mId(id),
           mClient(DbusConnection::create(acquireAddress())),
           mNameAcquired(false),
@@ -136,8 +130,8 @@ public:
     void setName(const std::string& name)
     {
         mClient->setName(name,
-                         std::bind(&DbusAccessory::onNameAcquired, this),
-                         std::bind(&DbusAccessory::onDisconnect, this));
+                         std::bind(&HostDbusAccessory::onNameAcquired, this),
+                         std::bind(&HostDbusAccessory::onDisconnect, this));
 
         if(!waitForName()) {
             mClient.reset();
@@ -168,7 +162,7 @@ public:
 
     void signalSubscribe(const DbusConnection::SignalCallback& callback)
     {
-        mClient->signalSubscribe(callback, isHost() ? api::BUS_NAME : api::BUS_NAME);
+        mClient->signalSubscribe(callback, isHost() ? api::dbus::BUS_NAME : api::dbus::BUS_NAME);
     }
 
     void subscribeNotification(const NotificationCallback& callback)
@@ -179,9 +173,9 @@ public:
                           const std::string& signalName,
                            GVariant* parameters)
         {
-            if (objectPath == api::OBJECT_PATH &&
-                interface == api::INTERFACE &&
-                signalName == api::SIGNAL_NOTIFICATION &&
+            if (objectPath == api::dbus::OBJECT_PATH &&
+                interface == api::dbus::INTERFACE &&
+                signalName == api::dbus::SIGNAL_NOTIFICATION &&
                 g_variant_is_of_type(parameters, G_VARIANT_TYPE("(sss)"))) {
 
                 const gchar* zone = NULL;
@@ -191,25 +185,25 @@ public:
                 callback({zone, application, message});
             }
         };
-        mClient->signalSubscribe(handler, api::BUS_NAME);
+        mClient->signalSubscribe(handler, api::dbus::BUS_NAME);
     }
 
     void signalSwitchToDefault()
     {
         // emit signal from dbus connection
-        mClient->emitSignal(api::OBJECT_PATH,
-                            api::INTERFACE,
-                            api::SIGNAL_SWITCH_TO_DEFAULT,
+        mClient->emitSignal(api::dbus::OBJECT_PATH,
+                            api::dbus::INTERFACE,
+                            api::dbus::SIGNAL_SWITCH_TO_DEFAULT,
                             nullptr);
     }
 
     void callMethodNotify()
     {
         GVariant* parameters = g_variant_new("(ss)", TEST_APP_NAME.c_str(), TEST_MESSAGE.c_str());
-        mClient->callMethod(api::BUS_NAME,
-                            api::OBJECT_PATH,
-                            api::INTERFACE,
-                            api::METHOD_NOTIFY_ACTIVE_ZONE,
+        mClient->callMethod(api::dbus::BUS_NAME,
+                            api::dbus::OBJECT_PATH,
+                            api::dbus::INTERFACE,
+                            api::dbus::METHOD_NOTIFY_ACTIVE_ZONE,
                             parameters,
                             "()");
     }
@@ -217,10 +211,10 @@ public:
     std::string callMethodMove(const std::string& dest, const std::string& path)
     {
         GVariant* parameters = g_variant_new("(ss)", dest.c_str(), path.c_str());
-        GVariantPtr result = mClient->callMethod(api::BUS_NAME,
-                                                 api::OBJECT_PATH,
-                                                 api::INTERFACE,
-                                                 api::METHOD_FILE_MOVE_REQUEST,
+        GVariantPtr result = mClient->callMethod(api::dbus::BUS_NAME,
+                                                 api::dbus::OBJECT_PATH,
+                                                 api::dbus::INTERFACE,
+                                                 api::dbus::METHOD_FILE_MOVE_REQUEST,
                                                  parameters,
                                                  "(s)");
 
@@ -278,13 +272,13 @@ public:
                                                    interface.c_str(),
                                                    method.c_str(),
                                                    parameters);
-        GVariantPtr result = mClient->callMethod(isHost() ? api::BUS_NAME :
-                                                            api::BUS_NAME,
-                                                 isHost() ? api::OBJECT_PATH :
-                                                            api::OBJECT_PATH,
-                                                 isHost() ? api::INTERFACE :
-                                                            api::INTERFACE,
-                                                 api::METHOD_PROXY_CALL,
+        GVariantPtr result = mClient->callMethod(isHost() ? api::dbus::BUS_NAME :
+                                                            api::dbus::BUS_NAME,
+                                                 isHost() ? api::dbus::OBJECT_PATH :
+                                                            api::dbus::OBJECT_PATH,
+                                                 isHost() ? api::dbus::INTERFACE :
+                                                            api::dbus::INTERFACE,
+                                                 api::dbus::METHOD_PROXY_CALL,
                                                  packedParameters,
                                                  "(v)");
         GVariant* unpackedResult = NULL;
@@ -295,10 +289,10 @@ public:
     std::vector<std::string> callMethodGetZoneIds()
     {
         assert(isHost());
-        GVariantPtr result = mClient->callMethod(api::BUS_NAME,
-                                                 api::OBJECT_PATH,
-                                                 api::INTERFACE,
-                                                 api::METHOD_GET_ZONE_ID_LIST,
+        GVariantPtr result = mClient->callMethod(api::dbus::BUS_NAME,
+                                                 api::dbus::OBJECT_PATH,
+                                                 api::dbus::INTERFACE,
+                                                 api::dbus::METHOD_GET_ZONE_ID_LIST,
                                                  NULL,
                                                  "(as)");
 
@@ -320,10 +314,10 @@ public:
     std::string callMethodGetActiveZoneId()
     {
         assert(isHost());
-        GVariantPtr result = mClient->callMethod(api::BUS_NAME,
-                                                 api::OBJECT_PATH,
-                                                 api::INTERFACE,
-                                                 api::METHOD_GET_ACTIVE_ZONE_ID,
+        GVariantPtr result = mClient->callMethod(api::dbus::BUS_NAME,
+                                                 api::dbus::OBJECT_PATH,
+                                                 api::dbus::INTERFACE,
+                                                 api::dbus::METHOD_GET_ACTIVE_ZONE_ID,
                                                  NULL,
                                                  "(s)");
 
@@ -336,10 +330,10 @@ public:
     {
         assert(isHost());
         GVariant* parameters = g_variant_new("(s)", id.c_str());
-        GVariantPtr result = mClient->callMethod(api::BUS_NAME,
-                                                 api::OBJECT_PATH,
-                                                 api::INTERFACE,
-                                                 api::METHOD_SET_ACTIVE_ZONE,
+        GVariantPtr result = mClient->callMethod(api::dbus::BUS_NAME,
+                                                 api::dbus::OBJECT_PATH,
+                                                 api::dbus::INTERFACE,
+                                                 api::dbus::METHOD_SET_ACTIVE_ZONE,
                                                  parameters,
                                                  "()");
 
@@ -357,10 +351,10 @@ public:
 
         assert(isHost());
         GVariant* parameters = g_variant_new("(ss)", id.c_str(), templateName.c_str());
-        mClient->callMethodAsync(api::BUS_NAME,
-                                 api::OBJECT_PATH,
-                                 api::INTERFACE,
-                                 api::METHOD_CREATE_ZONE,
+        mClient->callMethodAsync(api::dbus::BUS_NAME,
+                                 api::dbus::OBJECT_PATH,
+                                 api::dbus::INTERFACE,
+                                 api::dbus::METHOD_CREATE_ZONE,
                                  parameters,
                                  "()",
                                  dropException(asyncResult));
@@ -377,10 +371,10 @@ public:
 
         assert(isHost());
         GVariant* parameters = g_variant_new("(s)", id.c_str());
-        mClient->callMethodAsync(api::BUS_NAME,
-                                 api::OBJECT_PATH,
-                                 api::INTERFACE,
-                                 api::METHOD_DESTROY_ZONE,
+        mClient->callMethodAsync(api::dbus::BUS_NAME,
+                                 api::dbus::OBJECT_PATH,
+                                 api::dbus::INTERFACE,
+                                 api::dbus::METHOD_DESTROY_ZONE,
                                  parameters,
                                  "()",
                                  dropException(asyncResult));
@@ -397,10 +391,10 @@ public:
 
         assert(isHost());
         GVariant* parameters = g_variant_new("(s)", id.c_str());
-        mClient->callMethodAsync(api::BUS_NAME,
-                                 api::OBJECT_PATH,
-                                 api::INTERFACE,
-                                 api::METHOD_SHUTDOWN_ZONE,
+        mClient->callMethodAsync(api::dbus::BUS_NAME,
+                                 api::dbus::OBJECT_PATH,
+                                 api::dbus::INTERFACE,
+                                 api::dbus::METHOD_SHUTDOWN_ZONE,
                                  parameters,
                                  "()",
                                  dropException(asyncResult));
@@ -417,10 +411,10 @@ public:
 
         assert(isHost());
         GVariant* parameters = g_variant_new("(s)", id.c_str());
-        mClient->callMethodAsync(api::BUS_NAME,
-                                 api::OBJECT_PATH,
-                                 api::INTERFACE,
-                                 api::METHOD_START_ZONE,
+        mClient->callMethodAsync(api::dbus::BUS_NAME,
+                                 api::dbus::OBJECT_PATH,
+                                 api::dbus::INTERFACE,
+                                 api::dbus::METHOD_START_ZONE,
                                  parameters,
                                  "()",
                                  dropException(asyncResult));
@@ -430,10 +424,10 @@ public:
     {
         assert(isHost());
         GVariant* parameters = g_variant_new("(s)", id.c_str());
-        GVariantPtr result = mClient->callMethod(api::BUS_NAME,
-                                                 api::OBJECT_PATH,
-                                                 api::INTERFACE,
-                                                 api::METHOD_LOCK_ZONE,
+        GVariantPtr result = mClient->callMethod(api::dbus::BUS_NAME,
+                                                 api::dbus::OBJECT_PATH,
+                                                 api::dbus::INTERFACE,
+                                                 api::dbus::METHOD_LOCK_ZONE,
                                                  parameters,
                                                  "()");
     }
@@ -442,10 +436,10 @@ public:
     {
         assert(isHost());
         GVariant* parameters = g_variant_new("(s)", id.c_str());
-        GVariantPtr result = mClient->callMethod(api::BUS_NAME,
-                                                 api::OBJECT_PATH,
-                                                 api::INTERFACE,
-                                                 api::METHOD_UNLOCK_ZONE,
+        GVariantPtr result = mClient->callMethod(api::dbus::BUS_NAME,
+                                                 api::dbus::OBJECT_PATH,
+                                                 api::dbus::INTERFACE,
+                                                 api::dbus::METHOD_UNLOCK_ZONE,
                                                  parameters,
                                                  "()");
     }
@@ -473,10 +467,7 @@ private:
     }
 };
 
-typedef DbusAccessory HostAccessory;
-
-#else
-//#ifdef DBUS_CONNECTION
+#endif //DBUS_CONNECTION
 
 class HostIPCAccessory {
 public:
@@ -491,21 +482,21 @@ public:
 
     std::vector<std::string> callMethodGetZoneIds()
     {
-        const auto out = mClient.callSync<api::Void, api::ZoneIds>(api::METHOD_GET_ZONE_ID_LIST,
+        const auto out = mClient.callSync<api::Void, api::ZoneIds>(api::ipc::METHOD_GET_ZONE_ID_LIST,
                                                                     std::make_shared<api::Void>());
         return out->values;
     }
 
     std::string callMethodGetActiveZoneId()
     {
-        const auto out = mClient.callSync<api::Void, api::ZoneId>(api::METHOD_GET_ACTIVE_ZONE_ID,
+        const auto out = mClient.callSync<api::Void, api::ZoneId>(api::ipc::METHOD_GET_ACTIVE_ZONE_ID,
                                                                   std::make_shared<api::Void>());
         return out->value;
     }
 
     void callMethodSetActiveZone(const std::string& id)
     {
-        mClient.callSync<api::ZoneId, api::Void>(api::METHOD_SET_ACTIVE_ZONE,
+        mClient.callSync<api::ZoneId, api::Void>(api::ipc::METHOD_SET_ACTIVE_ZONE,
                                                  std::make_shared<api::ZoneId>(api::ZoneId{id}));
     }
 
@@ -518,7 +509,7 @@ public:
                 result();
             }
         };
-        mClient.callAsync<api::CreateZoneIn, api::Void>(api::METHOD_CREATE_ZONE,
+        mClient.callAsync<api::CreateZoneIn, api::Void>(api::ipc::METHOD_CREATE_ZONE,
                            std::make_shared<api::CreateZoneIn>(api::CreateZoneIn{id, templateName}),
                            asyncResult);
     }
@@ -531,7 +522,7 @@ public:
                 result();
             }
         };
-        mClient.callAsync<api::ZoneId, api::Void>(api::METHOD_DESTROY_ZONE,
+        mClient.callAsync<api::ZoneId, api::Void>(api::ipc::METHOD_DESTROY_ZONE,
                            std::make_shared<api::ZoneId>(api::ZoneId{id}),
                            asyncResult);
     }
@@ -544,7 +535,7 @@ public:
                 result();
             }
         };
-        mClient.callAsync<api::ZoneId, api::Void>(api::METHOD_SHUTDOWN_ZONE,
+        mClient.callAsync<api::ZoneId, api::Void>(api::ipc::METHOD_SHUTDOWN_ZONE,
                            std::make_shared<api::ZoneId>(api::ZoneId{id}),
                            asyncResult);
     }
@@ -557,21 +548,21 @@ public:
                 result();
             }
         };
-        mClient.callAsync<api::ZoneId, api::Void>(api::METHOD_START_ZONE,
+        mClient.callAsync<api::ZoneId, api::Void>(api::ipc::METHOD_START_ZONE,
                            std::make_shared<api::ZoneId>(api::ZoneId{id}),
                            asyncResult);
     }
 
     void callMethodLockZone(const std::string& id)
     {
-        mClient.callSync<api::ZoneId, api::Void>(api::METHOD_LOCK_ZONE,
+        mClient.callSync<api::ZoneId, api::Void>(api::ipc::METHOD_LOCK_ZONE,
                                                   std::make_shared<api::ZoneId>(api::ZoneId{id}),
                                                   EVENT_TIMEOUT*10); //Prevent from IPCTimeoutException see LockUnlockZone
     }
 
     void callMethodUnlockZone(const std::string& id)
     {
-        mClient.callSync<api::ZoneId, api::Void>(api::METHOD_UNLOCK_ZONE,
+        mClient.callSync<api::ZoneId, api::Void>(api::ipc::METHOD_UNLOCK_ZONE,
                                                   std::make_shared<api::ZoneId>(api::ZoneId{id}),
                                                   EVENT_TIMEOUT*10); //Prevent from IPCTimeoutException see LockUnlockZone
     }
@@ -581,19 +572,19 @@ public:
         auto callbackWrapper = [callback] (const ipc::PeerID, std::shared_ptr<api::Notification>& data) {
             callback(*data);
         };
-        mClient.setSignalHandler<api::Notification>(api::SIGNAL_NOTIFICATION,
+        mClient.setSignalHandler<api::Notification>(api::ipc::SIGNAL_NOTIFICATION,
                                                     callbackWrapper);
     }
 
     void signalSwitchToDefault()
     {
-        mClient.signal<api::Void>(api::SIGNAL_SWITCH_TO_DEFAULT, std::make_shared<api::Void>());
+        mClient.signal<api::Void>(api::ipc::SIGNAL_SWITCH_TO_DEFAULT, std::make_shared<api::Void>());
     }
 
     void callMethodNotify()
     {
         mClient.callSync<api::NotifActiveZoneIn, api::Void>(
-            api::METHOD_NOTIFY_ACTIVE_ZONE,
+            api::ipc::METHOD_NOTIFY_ACTIVE_ZONE,
             std::make_shared<api::NotifActiveZoneIn>(api::NotifActiveZoneIn{TEST_APP_NAME, TEST_MESSAGE}),
             EVENT_TIMEOUT*10); //Prevent from IPCTimeoutException see LockUnlockZone
     }
@@ -601,7 +592,7 @@ public:
     std::string callMethodMove(const std::string& dest, const std::string& path)
     {
         auto result = mClient.callSync<api::FileMoveRequestIn, api::FileMoveRequestStatus>(
-            api::METHOD_FILE_MOVE_REQUEST,
+            api::ipc::METHOD_FILE_MOVE_REQUEST,
             std::make_shared<api::FileMoveRequestIn>(api::FileMoveRequestIn{dest, path}),
             EVENT_TIMEOUT*10);
         return result->value;
@@ -612,10 +603,6 @@ private:
     ipc::Client mClient;
 };
 
-typedef HostIPCAccessory HostAccessory;
-
-#endif //DBUS_CONNECTION
-
 template<class Predicate>
 bool spinWaitFor(int timeoutMs, Predicate pred)
 {
@@ -629,6 +616,8 @@ bool spinWaitFor(int timeoutMs, Predicate pred)
     return true;
 }
 
+} // namespace
+
 struct Fixture {
     vasum::utils::ScopedGlibLoop mLoop;
 
@@ -641,7 +630,21 @@ struct Fixture {
     {}
 };
 
-} // namespace
+struct IPCFixture : Fixture {
+    typedef HostIPCAccessory HostAccessory;
+};
+
+#ifdef DBUS_CONNECTION
+struct DbusFixture : Fixture {
+    typedef HostDbusAccessory HostAccessory;
+};
+#endif //DBUS_CONNECTION
+
+#ifdef DBUS_CONNECTION
+#define ACCESSORS  IPCFixture, DbusFixture
+#else //DBUS_CONNECTION
+#define ACCESSORS  IPCFixture
+#endif //DBUS_CONNECTION
 
 
 BOOST_FIXTURE_TEST_SUITE(ZonesManagerSuite, Fixture)
@@ -713,22 +716,13 @@ BOOST_AUTO_TEST_CASE(Focus)
     BOOST_CHECK(cm.getRunningForegroundZoneId() == "zone3");
 }
 
-BOOST_AUTO_TEST_CASE(StartStopWithZoneAccess)
-{
-    ZonesManager cm(TEST_CONFIG_PATH);
-    cm.createZone("zone1", ZONE_ACCESS_TEMPLATE);
-    cm.createZone("zone2", ZONE_ACCESS_TEMPLATE);
-    cm.createZone("zone3", ZONE_ACCESS_TEMPLATE);
-    cm.restoreAll();
-}
-
 #ifdef ZONE_CONNECTION
 BOOST_AUTO_TEST_CASE(NotifyActiveZone)
 {
     ZonesManager cm(TEST_CONFIG_PATH);
-    cm.createZone("zone1", ZONE_ACCESS_TEMPLATE);
-    cm.createZone("zone2", ZONE_ACCESS_TEMPLATE);
-    cm.createZone("zone3", ZONE_ACCESS_TEMPLATE);
+    cm.createZone("zone1", SIMPLE_TEMPLATE);
+    cm.createZone("zone2", SIMPLE_TEMPLATE);
+    cm.createZone("zone3", SIMPLE_TEMPLATE);
     cm.restoreAll();
 
     Latch signalReceivedLatch;
@@ -782,9 +776,9 @@ BOOST_AUTO_TEST_CASE(NotifyActiveZone)
 BOOST_AUTO_TEST_CASE(MoveFile)
 {
     ZonesManager cm(TEST_CONFIG_PATH);
-    cm.createZone("zone1", ZONE_ACCESS_TEMPLATE);
-    cm.createZone("zone2", ZONE_ACCESS_TEMPLATE);
-    cm.createZone("zone3", ZONE_ACCESS_TEMPLATE);
+    cm.createZone("zone1", SIMPLE_TEMPLATE);
+    cm.createZone("zone2", SIMPLE_TEMPLATE);
+    cm.createZone("zone3", SIMPLE_TEMPLATE);
     cm.restoreAll();
 
     Latch notificationLatch;
@@ -867,15 +861,15 @@ BOOST_AUTO_TEST_CASE(MoveFile)
 }
 #endif
 
-BOOST_AUTO_TEST_CASE(SwitchToDefault)
+MULTI_FIXTURE_TEST_CASE(SwitchToDefault, F, ACCESSORS)
 {
     ZonesManager cm(TEST_CONFIG_PATH);
-    cm.createZone("zone1", ZONE_ACCESS_TEMPLATE);
-    cm.createZone("zone2", ZONE_ACCESS_TEMPLATE);
-    cm.createZone("zone3", ZONE_ACCESS_TEMPLATE);
+    cm.createZone("zone1", SIMPLE_TEMPLATE);
+    cm.createZone("zone2", SIMPLE_TEMPLATE);
+    cm.createZone("zone3", SIMPLE_TEMPLATE);
     cm.restoreAll();
 
-    HostAccessory host;
+    typename F::HostAccessory host;
 
     auto isDefaultFocused = [&cm]() -> bool {
         return cm.getRunningForegroundZoneId() == "zone1";
@@ -889,15 +883,15 @@ BOOST_AUTO_TEST_CASE(SwitchToDefault)
     BOOST_CHECK(spinWaitFor(EVENT_TIMEOUT, isDefaultFocused));
 }
 
-BOOST_AUTO_TEST_CASE(AllowSwitchToDefault)
+MULTI_FIXTURE_TEST_CASE(AllowSwitchToDefault, F, ACCESSORS)
 {
     ZonesManager cm(TEST_CONFIG_PATH);
-    cm.createZone("zone1", ZONE_ACCESS_TEMPLATE);
-    cm.createZone("zone2", ZONE_ACCESS_TEMPLATE);
-    cm.createZone("zone3", ZONE_ACCESS_TEMPLATE);
+    cm.createZone("zone1", SIMPLE_TEMPLATE);
+    cm.createZone("zone2", SIMPLE_TEMPLATE);
+    cm.createZone("zone3", SIMPLE_TEMPLATE);
     cm.restoreAll();
 
-    HostAccessory host;
+    typename F::HostAccessory host;
 
     auto isDefaultFocused = [&cm]() -> bool {
         return cm.getRunningForegroundZoneId() == "zone1";
@@ -922,15 +916,15 @@ BOOST_AUTO_TEST_CASE(AllowSwitchToDefault)
 }
 
 #ifdef DBUS_CONNECTION
-BOOST_AUTO_TEST_CASE(ProxyCall)
+MULTI_FIXTURE_TEST_CASE(ProxyCall, F, DbusFixture)
 {
     ZonesManager cm(TEST_CONFIG_PATH);
-    cm.createZone("zone1", ZONE_ACCESS_TEMPLATE);
-    cm.createZone("zone2", ZONE_ACCESS_TEMPLATE);
-    cm.createZone("zone3", ZONE_ACCESS_TEMPLATE);
+    cm.createZone("zone1", SIMPLE_TEMPLATE);
+    cm.createZone("zone2", SIMPLE_TEMPLATE);
+    cm.createZone("zone3", SIMPLE_TEMPLATE);
     cm.restoreAll();
 
-    HostAccessory host;
+    typename F::HostAccessory host;
     host.setName(testapi::BUS_NAME);
 
     auto handler = [](const std::string& argument, MethodResultBuilder::Pointer result) {
@@ -967,7 +961,7 @@ BOOST_AUTO_TEST_CASE(ProxyCall)
                           DbusCustomException,
                           WhatEquals("Proxy call forbidden"));
 }
-#endif // DBUS_CONNECTION
+#endif //DBUS_CONNECTION
 
 namespace {
 
@@ -975,14 +969,14 @@ const std::set<std::string> EXPECTED_CONNECTIONS_NONE = { "zone1", "zone2", "zon
 
 } // namespace
 
-BOOST_AUTO_TEST_CASE(GetZoneIds)
+MULTI_FIXTURE_TEST_CASE(GetZoneIds, F, ACCESSORS)
 {
     ZonesManager cm(TEST_CONFIG_PATH);
     cm.createZone("zone1", SIMPLE_TEMPLATE);
     cm.createZone("zone2", SIMPLE_TEMPLATE);
     cm.createZone("zone3", SIMPLE_TEMPLATE);
 
-    HostAccessory host;
+    typename F::HostAccessory host;
 
     std::vector<std::string> zoneIds = {"zone1",
                                         "zone2",
@@ -992,7 +986,7 @@ BOOST_AUTO_TEST_CASE(GetZoneIds)
     BOOST_CHECK(returnedIds == zoneIds);// order should be preserved
 }
 
-BOOST_AUTO_TEST_CASE(GetActiveZoneId)
+MULTI_FIXTURE_TEST_CASE(GetActiveZoneId, F, ACCESSORS)
 {
     ZonesManager cm(TEST_CONFIG_PATH);
     cm.createZone("zone1", SIMPLE_TEMPLATE);
@@ -1000,7 +994,7 @@ BOOST_AUTO_TEST_CASE(GetActiveZoneId)
     cm.createZone("zone3", SIMPLE_TEMPLATE);
     cm.restoreAll();
 
-    HostAccessory host;
+    typename F::HostAccessory host;
 
     std::vector<std::string> zoneIds = {"zone1",
                                         "zone2",
@@ -1015,7 +1009,7 @@ BOOST_AUTO_TEST_CASE(GetActiveZoneId)
     BOOST_CHECK(host.callMethodGetActiveZoneId() == "");
 }
 
-BOOST_AUTO_TEST_CASE(SetActiveZone)
+MULTI_FIXTURE_TEST_CASE(SetActiveZone, F, ACCESSORS)
 {
     ZonesManager cm(TEST_CONFIG_PATH);
     cm.createZone("zone1", SIMPLE_TEMPLATE);
@@ -1023,7 +1017,7 @@ BOOST_AUTO_TEST_CASE(SetActiveZone)
     cm.createZone("zone3", SIMPLE_TEMPLATE);
     cm.restoreAll();
 
-    HostAccessory host;
+    typename F::HostAccessory host;
 
     std::vector<std::string> zoneIds = {"zone1",
                                         "zone2",
@@ -1044,7 +1038,7 @@ BOOST_AUTO_TEST_CASE(SetActiveZone)
                             WhatEquals("Could not activate stopped or paused zone"));
 }
 
-BOOST_AUTO_TEST_CASE(CreateDestroyZone)
+MULTI_FIXTURE_TEST_CASE(CreateDestroyZone, F, ACCESSORS)
 {
     const std::string zone1 = "test1";
     const std::string zone2 = "test2";
@@ -1060,7 +1054,7 @@ BOOST_AUTO_TEST_CASE(CreateDestroyZone)
         callDone.set();
     };
 
-    HostAccessory host;
+    typename F::HostAccessory host;
 
     // create zone1
     host.callAsyncMethodCreateZone(zone1, SIMPLE_TEMPLATE, resultCallback);
@@ -1096,7 +1090,7 @@ BOOST_AUTO_TEST_CASE(CreateDestroyZone)
     BOOST_CHECK_EQUAL(cm.getRunningForegroundZoneId(), "");
 }
 
-BOOST_AUTO_TEST_CASE(CreateDestroyZonePersistence)
+MULTI_FIXTURE_TEST_CASE(CreateDestroyZonePersistence, F, ACCESSORS)
 {
     const std::string zone = "test1";
 
@@ -1109,7 +1103,7 @@ BOOST_AUTO_TEST_CASE(CreateDestroyZonePersistence)
         ZonesManager cm(TEST_CONFIG_PATH);
         cm.restoreAll();
 
-        HostAccessory host;
+        typename F::HostAccessory host;
         return host.callMethodGetZoneIds();
     };
 
@@ -1118,7 +1112,7 @@ BOOST_AUTO_TEST_CASE(CreateDestroyZonePersistence)
     // create zone
     {
         ZonesManager cm(TEST_CONFIG_PATH);
-        HostAccessory host;
+        typename F::HostAccessory host;
         host.callAsyncMethodCreateZone(zone, SIMPLE_TEMPLATE, resultCallback);
         BOOST_REQUIRE(callDone.wait(EVENT_TIMEOUT));
     }
@@ -1132,7 +1126,7 @@ BOOST_AUTO_TEST_CASE(CreateDestroyZonePersistence)
     // destroy zone
     {
         ZonesManager cm(TEST_CONFIG_PATH);
-        HostAccessory host;
+        typename F::HostAccessory host;
         host.callAsyncMethodDestroyZone(zone, resultCallback);
         BOOST_REQUIRE(callDone.wait(EVENT_TIMEOUT));
     }
@@ -1140,7 +1134,7 @@ BOOST_AUTO_TEST_CASE(CreateDestroyZonePersistence)
     BOOST_CHECK(getZoneIds().empty());
 }
 
-BOOST_AUTO_TEST_CASE(ZoneStatePersistence)
+MULTI_FIXTURE_TEST_CASE(ZoneStatePersistence, F, ACCESSORS)
 {
     const std::string zone1 = "zone1";
     const std::string zone2 = "zone2";
@@ -1156,7 +1150,7 @@ BOOST_AUTO_TEST_CASE(ZoneStatePersistence)
     // firts run
     {
         ZonesManager cm(TEST_CONFIG_PATH);
-        HostAccessory host;
+        typename F::HostAccessory host;
 
         // zone1 - created
         host.callAsyncMethodCreateZone(zone1, SIMPLE_TEMPLATE, resultCallback);
@@ -1211,21 +1205,21 @@ BOOST_AUTO_TEST_CASE(ZoneStatePersistence)
     }
 }
 
-BOOST_AUTO_TEST_CASE(StartShutdownZone)
+MULTI_FIXTURE_TEST_CASE(StartShutdownZone, F, ACCESSORS)
 {
     const std::string zone1 = "zone1";
     const std::string zone2 = "zone2";
 
     ZonesManager cm(TEST_CONFIG_PATH);
-    cm.createZone(zone1, ZONE_ACCESS_TEMPLATE);
-    cm.createZone(zone2, ZONE_ACCESS_TEMPLATE);
+    cm.createZone(zone1, SIMPLE_TEMPLATE);
+    cm.createZone(zone2, SIMPLE_TEMPLATE);
 
     Latch callDone;
     auto resultCallback = [&]() {
         callDone.set();
     };
 
-    HostAccessory host;
+    typename F::HostAccessory host;
 
     // start zone1
     host.callAsyncMethodStartZone(zone1, resultCallback);
@@ -1251,15 +1245,15 @@ BOOST_AUTO_TEST_CASE(StartShutdownZone)
     BOOST_CHECK_EQUAL(cm.getRunningForegroundZoneId(), "");
 }
 
-BOOST_AUTO_TEST_CASE(LockUnlockZone)
+MULTI_FIXTURE_TEST_CASE(LockUnlockZone, F, ACCESSORS)
 {
     ZonesManager cm(TEST_CONFIG_PATH);
-    cm.createZone("zone1", ZONE_ACCESS_TEMPLATE);
-    cm.createZone("zone2", ZONE_ACCESS_TEMPLATE);
-    cm.createZone("zone3", ZONE_ACCESS_TEMPLATE);
+    cm.createZone("zone1", SIMPLE_TEMPLATE);
+    cm.createZone("zone2", SIMPLE_TEMPLATE);
+    cm.createZone("zone3", SIMPLE_TEMPLATE);
     cm.restoreAll();
 
-    HostAccessory host;
+    typename F::HostAccessory host;
 
     std::vector<std::string> zoneIds = {"zone1",
                                         "zone2",
@@ -1272,7 +1266,7 @@ BOOST_AUTO_TEST_CASE(LockUnlockZone)
             //This try catch clause is for prevent from test crashing
             //and should be removed after resolve following errors
             //TODO: Abort when zone is locked on destroying ZonesManager
-            HostAccessory host2; //TODO: After IPCTimeoutException host is useless -- fix it
+            typename F::HostAccessory host2; //TODO: After IPCTimeoutException host is useless -- fix it
             try { host2.callMethodUnlockZone(zoneId); } catch (...) {};
             throw;
         }