Remove zone-host connection 28/38728/10
authorMateusz Malicki <m.malicki2@samsung.com>
Mon, 27 Apr 2015 09:12:06 +0000 (11:12 +0200)
committerDariusz Michaluk <d.michaluk@samsung.com>
Tue, 5 May 2015 07:36:15 +0000 (00:36 -0700)
[Feature]       No dbus connection with zone
[Cause]         N/A
[Solution]      Remove code responsible for zone connection
[Verification]  Build with and without DBUS_CONNECTION macro, run tests for each build
                (NOTE: ClientSuite/NotRunningServer will fail)

Change-Id: Ida474fba31111eb431ddc97c4bc3def1eeb932c7

53 files changed:
client/dbus-connection.cpp [deleted file]
client/dbus-connection.hpp [deleted file]
client/host-dbus-connection.cpp [deleted file]
client/host-dbus-connection.hpp [deleted file]
client/host-ipc-connection.cpp
client/host-ipc-connection.hpp
client/ipc-connection.cpp [deleted file]
client/ipc-connection.hpp [deleted file]
client/vasum-client-impl.cpp
client/vasum-client-impl.hpp
client/zone-dbus-connection.cpp [deleted file]
client/zone-dbus-connection.hpp [deleted file]
server/common-definitions.hpp [moved from server/common-dbus-definitions.hpp with 52% similarity]
server/configs/lxc-templates/template.sh
server/configs/templates/default.conf
server/host-dbus-connection.cpp
server/host-dbus-connection.hpp
server/host-dbus-definitions.hpp
server/host-ipc-connection.cpp
server/host-ipc-connection.hpp
server/host-ipc-definitions.hpp
server/ipc-callback-wrapper.hpp [new file with mode: 0644]
server/zone-config.hpp
server/zone-connection-transport.cpp [deleted file]
server/zone-connection-transport.hpp [deleted file]
server/zone-connection.cpp [deleted file]
server/zone-connection.hpp [deleted file]
server/zone-dbus-definitions.hpp [deleted file]
server/zone.cpp
server/zone.hpp
server/zones-manager.cpp
server/zones-manager.hpp
tests/unit_tests/client/configs/CMakeLists.txt
tests/unit_tests/client/configs/ut-client/templates/console-dbus.conf.in
tests/unit_tests/client/configs/ut-client/templates/console-ipc.conf.in [new file with mode: 0644]
tests/unit_tests/client/ut-client.cpp
tests/unit_tests/lxc/templates/minimal-dbus.sh
tests/unit_tests/server/configs/CMakeLists.txt
tests/unit_tests/server/configs/ut-server/templates/default.conf
tests/unit_tests/server/configs/ut-zone-admin/templates/buggy.conf
tests/unit_tests/server/configs/ut-zone-admin/templates/missing.conf
tests/unit_tests/server/configs/ut-zone-admin/templates/test-no-shutdown.conf
tests/unit_tests/server/configs/ut-zone-admin/templates/test.conf
tests/unit_tests/server/configs/ut-zone-connection/ut-dbus.conf [deleted file]
tests/unit_tests/server/configs/ut-zone/templates/buggy.conf
tests/unit_tests/server/configs/ut-zone/templates/test-dbus.conf.in
tests/unit_tests/server/configs/ut-zone/templates/test.conf
tests/unit_tests/server/configs/ut-zones-manager/templates/console-dbus.conf.in
tests/unit_tests/server/configs/ut-zones-manager/templates/console-ipc.conf.in [new file with mode: 0644]
tests/unit_tests/server/configs/ut-zones-manager/templates/console.conf
tests/unit_tests/server/ut-zone-connection.cpp [deleted file]
tests/unit_tests/server/ut-zone.cpp
tests/unit_tests/server/ut-zones-manager.cpp

diff --git a/client/dbus-connection.cpp b/client/dbus-connection.cpp
deleted file mode 100644 (file)
index b52bd71..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Mateusz Malicki <m.malicki2@samsung.com>
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License
- */
-
-
-/**
- * @file
- * @author  Mateusz Malicki (m.malicki2@samsung.com)
- * @brief   SimpleDbus's wrapper
- */
-
-#include <config.hpp>
-#include "dbus-connection.hpp"
-#include "exception.hpp"
-#include <dbus/connection.hpp>
-#include <gio/gio.h>
-
-using namespace vasum::client;
-
-
-DbusConnection::DbusConnection(const std::string& definition,
-                               const std::string& busName,
-                               const std::string& objectPath,
-                               const std::string& interface)
-    : mDefinition(definition)
-    , mBusName(busName)
-    , mObjectPath(objectPath)
-    , mInterface(interface)
-{
-}
-
-DbusConnection::~DbusConnection()
-{
-}
-
-void DbusConnection::create(const std::shared_ptr<dbus::DbusConnection>& connection)
-{
-    mConnection = connection;
-}
-
-void DbusConnection::callMethod(const std::string& method,
-                                GVariant* args_in,
-                                const std::string& args_spec_out,
-                                GVariant** args_out)
-{
-    dbus::GVariantPtr ret = mConnection->callMethod(mBusName,
-                                                    mObjectPath,
-                                                    mInterface,
-                                                    method,
-                                                    args_in,
-                                                    args_spec_out);
-    if (args_out != NULL) {
-        *args_out = ret.release();
-    }
-}
-
-DbusConnection::SubscriptionId DbusConnection::signalSubscribe(const std::string& signal,
-                                                               const SignalCallback& signalCallback)
-{
-    auto onSignal = [this, signal, signalCallback](const std::string& /*senderBusName*/,
-                                                   const std::string& objectPath,
-                                                   const std::string& interface,
-                                                   const std::string& signalName,
-                                                   GVariant * parameters) {
-        if (objectPath == mObjectPath &&
-            interface == mInterface &&
-            signalName == signal) {
-
-            signalCallback(parameters);
-        }
-    };
-    return mConnection->signalSubscribe(onSignal, mBusName);
-}
-
-void DbusConnection::signalUnsubscribe(SubscriptionId id)
-{
-    mConnection->signalUnsubscribe(id);
-}
-
-std::string DbusConnection::getArgsOutSpec(const std::string& methodName)
-{
-    //TODO: Information about output argumnets of all methods can be computed in constuctor
-    GError *error = NULL;
-    GDBusNodeInfo* nodeInfo = g_dbus_node_info_new_for_xml(mDefinition.c_str(), &error);
-    if (error) {
-        std::string msg = error->message;
-        g_error_free (error);
-        throw ClientException("Invalid xml: " + msg);
-    }
-    GDBusInterfaceInfo* interfaceInfo = g_dbus_node_info_lookup_interface(nodeInfo, mInterface.c_str());
-    if (interfaceInfo == NULL) {
-        throw ClientException("Invalid xml: can't find interface: " + mInterface);
-    }
-    GDBusMethodInfo* methodInfo = g_dbus_interface_info_lookup_method(interfaceInfo, methodName.c_str());
-    if (methodInfo == NULL) {
-        throw ClientException("Invalid xml: can't find method: " + methodName);
-    }
-
-    std::string signature;
-    for (GDBusArgInfo** argInfo = methodInfo->out_args; *argInfo; ++argInfo) {
-        signature += (*argInfo)->signature;
-    }
-    g_dbus_node_info_unref(nodeInfo);
-    return "(" + signature + ")";
-}
diff --git a/client/dbus-connection.hpp b/client/dbus-connection.hpp
deleted file mode 100644 (file)
index 3cb37ad..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Mateusz Malicki <m.malicki2@samsung.com>
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License
- */
-
-
-/**
- * @file
- * @author  Mateusz Malicki (m.malicki2@samsung.com)
- * @brief   SimpleDbus's wrapper
- */
-
-#ifndef VASUM_CLIENT_DBUS_CONNECTION_HPP
-#define VASUM_CLIENT_DBUS_CONNECTION_HPP
-
-#include <api/messages.hpp>
-#include <config/manager.hpp>
-#include <dbus/connection.hpp>
-#include <type_traits>
-#include <string>
-#include <memory>
-
-namespace vasum {
-namespace client {
-
-/**
- * SimpleDbus client definition.
- *
- * DbusConnection uses SimpleDbus API.
- */
-class DbusConnection {
-public:
-    typedef unsigned int SubscriptionId;
-
-    DbusConnection(const std::string& definition,
-                   const std::string& busName,
-                   const std::string& objectPath,
-                   const std::string& interface);
-    virtual ~DbusConnection();
-    void create(const std::shared_ptr<dbus::DbusConnection>& connection);
-
-    template<typename ArgIn, typename ArgOut>
-    typename std::enable_if<!std::is_same<ArgOut, vasum::api::Void>::value>::type
-    call(const std::string& method, const ArgIn& argIn, ArgOut& argOut);
-
-    template<typename ArgIn, typename ArgOut>
-    typename std::enable_if<std::is_same<ArgOut, vasum::api::Void>::value>::type
-    call(const std::string& method, const ArgIn& argIn, ArgOut& argOut);
-
-    template<typename ArgOut>
-    typename std::enable_if<!std::is_const<ArgOut>::value>::type
-    call(const std::string& method, ArgOut& argOut) {
-        vasum::api::Void argIn;
-        call(method, argIn, argOut);
-    }
-
-    template<typename ArgIn>
-    typename std::enable_if<std::is_const<ArgIn>::value>::type
-    call(const std::string& method, ArgIn& argIn) {
-        vasum::api::Void argOut;
-        call(method, argIn, argOut);
-    }
-
-    template<typename Arg>
-    SubscriptionId signalSubscribe(const std::string& signal,
-                                   const std::function<void(const Arg& arg)>& signalCallback);
-    void signalUnsubscribe(SubscriptionId id);
-
-private:
-    typedef std::function<void(GVariant* parameters)> SignalCallback;
-
-    std::shared_ptr<dbus::DbusConnection> mConnection;
-    const std::string mDefinition;
-    const std::string mBusName;
-    const std::string mObjectPath;
-    const std::string mInterface;
-
-    void callMethod(const std::string& method,
-                    GVariant* args_in,
-                    const std::string& args_spec_out,
-                    GVariant** args_out);
-    SubscriptionId signalSubscribe(const std::string& signal, const SignalCallback& signalCallback);
-
-    /**
-     * Get signature of method output parameters
-     */
-    std::string getArgsOutSpec(const std::string& methodName);
-};
-
-template<typename ArgIn, typename ArgOut>
-typename std::enable_if<!std::is_same<ArgOut, vasum::api::Void>::value>::type
-DbusConnection::call(const std::string& method, const ArgIn& argIn, ArgOut& argOut)
-{
-    GVariant* gArgOut = NULL;
-    callMethod(method, config::saveToGVariant(argIn), getArgsOutSpec(method), &gArgOut);
-    config::loadFromGVariant(gArgOut, argOut);
-    g_variant_unref(gArgOut);
-}
-
-template<typename ArgIn, typename ArgOut>
-typename std::enable_if<std::is_same<ArgOut, vasum::api::Void>::value>::type
-DbusConnection::call(const std::string& method, const ArgIn& argIn, ArgOut& /* argOut */)
-{
-    callMethod(method, config::saveToGVariant(argIn), "", NULL);
-}
-
-template<typename Arg>
-DbusConnection::SubscriptionId DbusConnection::signalSubscribe(const std::string& signal,
-                                                               const std::function<void(const Arg& arg)>& signalCallback)
-{
-    SignalCallback callback = [signalCallback](GVariant* parameters) {
-        Arg param;
-        config::loadFromGVariant(parameters, param);
-        signalCallback(param);
-    };
-    return signalSubscribe(signal, callback);
-}
-
-} // namespace client
-} // namespace vasum
-
-#endif /* VASUM_CLIENT_DBUS_CONNECTION_HPP */
diff --git a/client/host-dbus-connection.cpp b/client/host-dbus-connection.cpp
deleted file mode 100644 (file)
index 1f375a0..0000000
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Mateusz Malicki <m.malicki2@samsung.com>
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License
- */
-
-
-/**
- * @file
- * @author  Mateusz Malicki (m.malicki2@samsung.com)
- * @brief   Host client class
- */
-
-
-#include <config.hpp>
-#include "host-dbus-connection.hpp"
-#include <api/messages.hpp>
-#include <host-dbus-definitions.hpp>
-
-namespace vasum {
-namespace client {
-
-HostDbusConnection::HostDbusConnection()
-    : mConnection(vasum::api::host::DEFINITION,
-                  vasum::api::host::BUS_NAME,
-                  vasum::api::host::OBJECT_PATH,
-                  vasum::api::host::INTERFACE)
-{
-}
-
-void HostDbusConnection::create(const std::shared_ptr<dbus::DbusConnection>& connection)
-{
-    mConnection.create(connection);
-}
-
-void HostDbusConnection::callGetZoneIds(vasum::api::ZoneIds& argOut)
-{
-    mConnection.call(vasum::api::host::METHOD_GET_ZONE_ID_LIST, argOut);
-}
-
-void HostDbusConnection::callGetActiveZoneId(vasum::api::ZoneId& argOut)
-{
-    mConnection.call(vasum::api::host::METHOD_GET_ACTIVE_ZONE_ID, argOut);
-}
-
-void HostDbusConnection::callSetActiveZone(const vasum::api::ZoneId& argIn)
-{
-    mConnection.call(vasum::api::host::METHOD_SET_ACTIVE_ZONE, argIn);
-}
-
-void HostDbusConnection::callGetZoneInfo(const vasum::api::ZoneId& argIn, vasum::api::ZoneInfoOut& argOut)
-{
-    mConnection.call(vasum::api::host::METHOD_GET_ZONE_INFO, argIn, argOut);
-}
-
-void HostDbusConnection::callSetNetdevAttrs(const vasum::api::SetNetDevAttrsIn& argIn)
-{
-    mConnection.call(vasum::api::host::METHOD_SET_NETDEV_ATTRS, argIn);
-}
-
-void HostDbusConnection::callGetNetdevAttrs(const vasum::api::GetNetDevAttrsIn& argIn, vasum::api::GetNetDevAttrs& argOut)
-{
-    mConnection.call(vasum::api::host::METHOD_GET_NETDEV_ATTRS, argIn, argOut);
-}
-
-void HostDbusConnection::callGetNetdevList(const vasum::api::ZoneId& argIn, vasum::api::NetDevList& argOut)
-{
-    mConnection.call(vasum::api::host::METHOD_GET_NETDEV_LIST, argIn, argOut);
-}
-
-void HostDbusConnection::callCreateNetdevVeth(const vasum::api::CreateNetDevVethIn& argIn)
-{
-    mConnection.call(vasum::api::host::METHOD_CREATE_NETDEV_VETH, argIn);
-}
-
-void HostDbusConnection::callCreateNetdevMacvlan(const vasum::api::CreateNetDevMacvlanIn& argIn)
-{
-    mConnection.call(vasum::api::host::METHOD_CREATE_NETDEV_MACVLAN, argIn);
-}
-
-void HostDbusConnection::callCreateNetdevPhys(const vasum::api::CreateNetDevPhysIn& argIn)
-{
-    mConnection.call(vasum::api::host::METHOD_CREATE_NETDEV_PHYS, argIn);
-}
-
-void HostDbusConnection::callDestroyNetdev(const vasum::api::DestroyNetDevIn& argIn)
-{
-    mConnection.call(vasum::api::host::METHOD_DESTROY_NETDEV, argIn);
-}
-
-void HostDbusConnection::callDeleteNetdevIpAddress(const vasum::api::DeleteNetdevIpAddressIn& argIn)
-{
-    mConnection.call(vasum::api::host::METHOD_DELETE_NETDEV_IP_ADDRESS, argIn);
-}
-
-void HostDbusConnection::callDeclareFile(const vasum::api::DeclareFileIn& argIn, vasum::api::Declaration& argOut)
-{
-    mConnection.call(vasum::api::host::METHOD_DECLARE_FILE, argIn, argOut);
-}
-
-void HostDbusConnection::callDeclareMount(const vasum::api::DeclareMountIn& argIn, vasum::api::Declaration& argOut)
-{
-    mConnection.call(vasum::api::host::METHOD_DECLARE_MOUNT, argIn, argOut);
-}
-
-void HostDbusConnection::callDeclareLink(const vasum::api::DeclareLinkIn& argIn, vasum::api::Declaration& argOut)
-{
-    mConnection.call(vasum::api::host::METHOD_DECLARE_LINK, argIn, argOut);
-}
-
-void HostDbusConnection::callGetDeclarations(const vasum::api::ZoneId& argIn, vasum::api::Declarations& argOut)
-{
-    mConnection.call(vasum::api::host::METHOD_GET_DECLARATIONS, argIn, argOut);
-}
-
-void HostDbusConnection::callRemoveDeclaration(const vasum::api::RemoveDeclarationIn& argIn)
-{
-    mConnection.call(vasum::api::host::METHOD_REMOVE_DECLARATION, argIn);
-}
-
-void HostDbusConnection::callCreateZone(const vasum::api::CreateZoneIn& argIn)
-{
-    mConnection.call(vasum::api::host::METHOD_CREATE_ZONE, argIn);
-}
-
-void HostDbusConnection::callDestroyZone(const vasum::api::ZoneId& argIn)
-{
-    mConnection.call(vasum::api::host::METHOD_DESTROY_ZONE, argIn);
-}
-
-void HostDbusConnection::callShutdownZone(const vasum::api::ZoneId& argIn)
-{
-    mConnection.call(vasum::api::host::METHOD_SHUTDOWN_ZONE, argIn);
-}
-
-void HostDbusConnection::callStartZone(const vasum::api::ZoneId& argIn)
-{
-    mConnection.call(vasum::api::host::METHOD_START_ZONE, argIn);
-}
-
-void HostDbusConnection::callLockZone(const vasum::api::ZoneId& argIn)
-{
-    mConnection.call(vasum::api::host::METHOD_LOCK_ZONE, argIn);
-}
-
-void HostDbusConnection::callUnlockZone(const vasum::api::ZoneId& argIn)
-{
-    mConnection.call(vasum::api::host::METHOD_UNLOCK_ZONE, argIn);
-}
-
-void HostDbusConnection::callGrantDevice(const vasum::api::GrantDeviceIn& argIn)
-{
-    mConnection.call(vasum::api::host::METHOD_GRANT_DEVICE, argIn);
-}
-
-void HostDbusConnection::callRevokeDevice(const vasum::api::RevokeDeviceIn& argIn)
-{
-    mConnection.call(vasum::api::host::METHOD_REVOKE_DEVICE, argIn);
-}
-
-void HostDbusConnection::callGetZoneConnections(vasum::api::Connections& argOut)
-{
-    mConnection.call(vasum::api::host::METHOD_GET_ZONE_CONNECTIONS, argOut);
-}
-
-HostDbusConnection::SubscriptionId
-HostDbusConnection::subscribeZoneConnectionState(const ZoneConnectionStateCallback& callback)
-{
-    return mConnection.signalSubscribe<vasum::api::ConnectionState>(
-        vasum::api::host::SIGNAL_ZONE_CONNECTION_STATE, callback);
-}
-
-void HostDbusConnection::unsubscribe(const SubscriptionId& id)
-{
-    mConnection.signalUnsubscribe(id);
-}
-
-} // namespace client
-} // namespace vasum
diff --git a/client/host-dbus-connection.hpp b/client/host-dbus-connection.hpp
deleted file mode 100644 (file)
index 8785fa0..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Mateusz Malicki <m.malicki2@samsung.com>
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License
- */
-
-
-/**
- * @file
- * @author  Mateusz Malicki (m.malicki2@samsung.com)
- * @brief   Host client class
- */
-
-#ifndef VASUM_CLIENT_HOST_DBUS_CONNECTION_HPP
-#define VASUM_CLIENT_HOST_DBUS_CONNECTION_HPP
-
-#include "dbus-connection.hpp"
-#include <api/messages.hpp>
-
-namespace vasum {
-namespace client {
-
-/**
- * vasum's client definition.
- *
- * HostDbusConnection is used for communication with the vasum's server from host through dbus
- */
-class HostDbusConnection {
-public:
-    typedef unsigned int SubscriptionId;
-    typedef std::function<void(const vasum::api::ConnectionState&)> ZoneConnectionStateCallback;
-
-    HostDbusConnection();
-
-    void create(const std::shared_ptr<dbus::DbusConnection>& connection);
-
-    void callGetZoneIds(vasum::api::ZoneIds& argOut);
-    void callGetActiveZoneId(vasum::api::ZoneId& argOut);
-    void callSetActiveZone(const vasum::api::ZoneId& argIn);
-    void callGetZoneInfo(const vasum::api::ZoneId& argIn, vasum::api::ZoneInfoOut& argOut);
-    void callSetNetdevAttrs(const vasum::api::SetNetDevAttrsIn& argIn);
-    void callGetNetdevAttrs(const vasum::api::GetNetDevAttrsIn& argIn, vasum::api::GetNetDevAttrs& argOut);
-    void callGetNetdevList(const vasum::api::ZoneId& argIn, vasum::api::NetDevList& argOut);
-    void callCreateNetdevVeth(const vasum::api::CreateNetDevVethIn& argIn);
-    void callCreateNetdevMacvlan(const vasum::api::CreateNetDevMacvlanIn& argIn);
-    void callCreateNetdevPhys(const vasum::api::CreateNetDevPhysIn& argIn);
-    void callDestroyNetdev(const vasum::api::DestroyNetDevIn& argIn);
-    void callDeleteNetdevIpAddress(const vasum::api::DeleteNetdevIpAddressIn& argIn);
-    void callDeclareFile(const vasum::api::DeclareFileIn& argIn, vasum::api::Declaration& argOut);
-    void callDeclareMount(const vasum::api::DeclareMountIn& argIn, vasum::api::Declaration& argOut);
-    void callDeclareLink(const vasum::api::DeclareLinkIn& argIn, vasum::api::Declaration& argOut);
-    void callGetDeclarations(const vasum::api::ZoneId& argIn, vasum::api::Declarations& argOut);
-    void callRemoveDeclaration(const vasum::api::RemoveDeclarationIn& argIn);
-    void callCreateZone(const vasum::api::CreateZoneIn& argIn);
-    void callDestroyZone(const vasum::api::ZoneId& argIn);
-    void callShutdownZone(const vasum::api::ZoneId& argIn);
-    void callStartZone(const vasum::api::ZoneId& argIn);
-    void callLockZone(const vasum::api::ZoneId& argIn);
-    void callUnlockZone(const vasum::api::ZoneId& argIn);
-    void callGrantDevice(const vasum::api::GrantDeviceIn& argIn);
-    void callRevokeDevice(const vasum::api::RevokeDeviceIn& argIn);
-    void callGetZoneConnections(vasum::api::Connections& argOut);
-    SubscriptionId subscribeZoneConnectionState(const ZoneConnectionStateCallback& callback);
-    void unsubscribe(const SubscriptionId& id);
-private:
-    DbusConnection mConnection;
-};
-
-} // namespace client
-} // namespace vasum
-
-#endif /* VASUM_CLIENT_HOST_DBUS_CONNECTION_HPP */
index adb44eb..121f7ad 100644 (file)
@@ -33,150 +33,228 @@ namespace client {
 
 void HostIPCConnection::createSystem()
 {
-    mConnection.createSystem();
+    mClient.reset(new ipc::Client(mDispatcher.getPoll(), HOST_IPC_SOCKET));
+    mClient->start();
 }
 
-void HostIPCConnection::callGetZoneIds(vasum::api::ZoneIds& argOut)
+void HostIPCConnection::create(const std::string& address)
 {
-    mConnection.call(vasum::api::host::METHOD_GET_ZONE_ID_LIST, argOut);
+    mClient.reset(new ipc::Client(mDispatcher.getPoll(), address));
+    mClient->start();
 }
 
-void HostIPCConnection::callGetActiveZoneId(vasum::api::ZoneId& argOut)
+void HostIPCConnection::callGetZoneIds(api::ZoneIds& argOut)
 {
-    mConnection.call(vasum::api::host::METHOD_GET_ACTIVE_ZONE_ID, argOut);
+    api::Void argVoid;
+    call(api::METHOD_GET_ZONE_ID_LIST, argVoid, argOut);
 }
 
-void HostIPCConnection::callSetActiveZone(const vasum::api::ZoneId& argIn)
+void HostIPCConnection::callGetActiveZoneId(api::ZoneId& argOut)
 {
-    mConnection.call(vasum::api::host::METHOD_SET_ACTIVE_ZONE, argIn);
+    api::Void argVoid;
+    call(api::METHOD_GET_ACTIVE_ZONE_ID, argVoid, argOut);
 }
 
-void HostIPCConnection::callGetZoneInfo(const vasum::api::ZoneId& argIn, vasum::api::ZoneInfoOut& argOut)
+void HostIPCConnection::callSetActiveZone(const api::ZoneId& argIn)
 {
-    mConnection.call(vasum::api::host::METHOD_GET_ZONE_INFO, argIn, argOut);
+    mClient->callSync<api::ZoneId, api::Void>(
+            api::METHOD_SET_ACTIVE_ZONE,
+            std::make_shared<api::ZoneId>(argIn));
 }
 
-void HostIPCConnection::callSetNetdevAttrs(const vasum::api::SetNetDevAttrsIn& argIn)
+void HostIPCConnection::callGetZoneInfo(const api::ZoneId& argIn, api::ZoneInfoOut& argOut)
 {
-    mConnection.call(vasum::api::host::METHOD_SET_NETDEV_ATTRS, argIn);
+    argOut = *mClient->callSync<api::ZoneId, api::ZoneInfoOut>(
+        api::METHOD_GET_ZONE_INFO,
+        std::make_shared<api::ZoneId>(argIn));
 }
 
-void HostIPCConnection::callGetNetdevAttrs(const vasum::api::GetNetDevAttrsIn& argIn, vasum::api::GetNetDevAttrs& argOut)
+void HostIPCConnection::callSetNetdevAttrs(const api::SetNetDevAttrsIn& argIn)
 {
-    mConnection.call(vasum::api::host::METHOD_GET_NETDEV_ATTRS, argIn, argOut);
+    mClient->callSync<api::SetNetDevAttrsIn, api::Void>(
+            api::METHOD_SET_NETDEV_ATTRS,
+            std::make_shared<api::SetNetDevAttrsIn>(argIn));
+
+    api::Void argVoid;
+    call(api::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,
+        std::make_shared<api::GetNetDevAttrsIn>(argIn));
 }
 
-void HostIPCConnection::callGetNetdevList(const vasum::api::ZoneId& argIn, vasum::api::NetDevList& argOut)
+void HostIPCConnection::callGetNetdevList(const api::ZoneId& argIn, api::NetDevList& argOut)
 {
-    mConnection.call(vasum::api::host::METHOD_GET_NETDEV_LIST, argIn, argOut);
+    argOut = *mClient->callSync<api::ZoneId, api::NetDevList>(
+        api::METHOD_GET_NETDEV_LIST,
+        std::make_shared<api::ZoneId>(argIn));
 }
 
-void HostIPCConnection::callCreateNetdevVeth(const vasum::api::CreateNetDevVethIn& argIn)
+void HostIPCConnection::callCreateNetdevVeth(const api::CreateNetDevVethIn& argIn)
 {
-    mConnection.call(vasum::api::host::METHOD_CREATE_NETDEV_VETH, argIn);
+    mClient->callSync<api::CreateNetDevVethIn, api::Void>(
+            api::METHOD_CREATE_NETDEV_VETH,
+            std::make_shared<api::CreateNetDevVethIn>(argIn));
 }
 
-void HostIPCConnection::callCreateNetdevMacvlan(const vasum::api::CreateNetDevMacvlanIn& argIn)
+void HostIPCConnection::callCreateNetdevMacvlan(const api::CreateNetDevMacvlanIn& argIn)
 {
-    mConnection.call(vasum::api::host::METHOD_CREATE_NETDEV_MACVLAN, argIn);
+    mClient->callSync<api::CreateNetDevMacvlanIn, api::Void>(
+            api::METHOD_CREATE_NETDEV_MACVLAN,
+            std::make_shared<api::CreateNetDevMacvlanIn>(argIn));
 }
 
-void HostIPCConnection::callCreateNetdevPhys(const vasum::api::CreateNetDevPhysIn& argIn)
+void HostIPCConnection::callCreateNetdevPhys(const api::CreateNetDevPhysIn& argIn)
 {
-    mConnection.call(vasum::api::host::METHOD_CREATE_NETDEV_PHYS, argIn);
+    mClient->callSync<api::CreateNetDevPhysIn, api::Void>(
+            api::METHOD_CREATE_NETDEV_PHYS,
+            std::make_shared<api::CreateNetDevPhysIn>(argIn));
 }
 
-void HostIPCConnection::callDestroyNetdev(const vasum::api::DestroyNetDevIn& argIn)
+void HostIPCConnection::callDestroyNetdev(const api::DestroyNetDevIn& argIn)
 {
-    mConnection.call(vasum::api::host::METHOD_DESTROY_NETDEV, argIn);
+    mClient->callSync<api::DestroyNetDevIn, api::Void>(
+            api::METHOD_DESTROY_NETDEV,
+            std::make_shared<api::DestroyNetDevIn>(argIn));
 }
 
-void HostIPCConnection::callDeleteNetdevIpAddress(const vasum::api::DeleteNetdevIpAddressIn& argIn)
+void HostIPCConnection::callDeleteNetdevIpAddress(const api::DeleteNetdevIpAddressIn& argIn)
 {
-    mConnection.call(vasum::api::host::METHOD_DELETE_NETDEV_IP_ADDRESS, argIn);
+    mClient->callSync<api::DeleteNetdevIpAddressIn, api::Void>(
+            api::METHOD_DELETE_NETDEV_IP_ADDRESS,
+            std::make_shared<api::DeleteNetdevIpAddressIn>(argIn));
 }
 
-void HostIPCConnection::callDeclareFile(const vasum::api::DeclareFileIn& argIn, vasum::api::Declaration& argOut)
+void HostIPCConnection::callDeclareFile(const api::DeclareFileIn& argIn, api::Declaration& argOut)
 {
-    mConnection.call(vasum::api::host::METHOD_DECLARE_FILE, argIn, argOut);
+    argOut = *mClient->callSync<api::DeclareFileIn, api::Declaration>(
+        api::METHOD_DECLARE_FILE,
+        std::make_shared<api::DeclareFileIn>(argIn));
 }
 
-void HostIPCConnection::callDeclareMount(const vasum::api::DeclareMountIn& argIn, vasum::api::Declaration& argOut)
+void HostIPCConnection::callDeclareMount(const api::DeclareMountIn& argIn, api::Declaration& argOut)
 {
-    mConnection.call(vasum::api::host::METHOD_DECLARE_MOUNT, argIn, argOut);
+    argOut = *mClient->callSync<api::DeclareMountIn, api::Declaration>(
+        api::METHOD_DECLARE_MOUNT,
+        std::make_shared<api::DeclareMountIn>(argIn));
 }
 
-void HostIPCConnection::callDeclareLink(const vasum::api::DeclareLinkIn& argIn, vasum::api::Declaration& argOut)
+void HostIPCConnection::callDeclareLink(const api::DeclareLinkIn& argIn, api::Declaration& argOut)
 {
-    mConnection.call(vasum::api::host::METHOD_DECLARE_LINK, argIn, argOut);
+    argOut = *mClient->callSync<api::DeclareLinkIn, api::Declaration>(
+        api::METHOD_DECLARE_LINK,
+        std::make_shared<api::DeclareLinkIn>(argIn));
 }
 
-void HostIPCConnection::callGetDeclarations(const vasum::api::ZoneId& argIn, vasum::api::Declarations& argOut)
+void HostIPCConnection::callGetDeclarations(const api::ZoneId& argIn, api::Declarations& argOut)
 {
-    mConnection.call(vasum::api::host::METHOD_GET_DECLARATIONS, argIn, argOut);
+    argOut = *mClient->callSync<api::ZoneId, api::Declarations>(
+        api::METHOD_GET_DECLARATIONS,
+        std::make_shared<api::ZoneId>(argIn));
 }
 
-void HostIPCConnection::callRemoveDeclaration(const vasum::api::RemoveDeclarationIn& argIn)
+void HostIPCConnection::callRemoveDeclaration(const api::RemoveDeclarationIn& argIn)
 {
-    mConnection.call(vasum::api::host::METHOD_REMOVE_DECLARATION, argIn);
+    mClient->callSync<api::RemoveDeclarationIn, api::Void>(
+            api::METHOD_REMOVE_DECLARATION,
+            std::make_shared<api::RemoveDeclarationIn>(argIn));
 }
 
-void HostIPCConnection::callCreateZone(const vasum::api::CreateZoneIn& argIn)
+void HostIPCConnection::callCreateZone(const api::CreateZoneIn& argIn)
 {
-    mConnection.call(vasum::api::host::METHOD_CREATE_ZONE, argIn);
+    mClient->callSync<api::CreateZoneIn, api::Void>(
+            api::METHOD_CREATE_ZONE,
+            std::make_shared<api::CreateZoneIn>(argIn));
 }
 
-void HostIPCConnection::callDestroyZone(const vasum::api::ZoneId& argIn)
+void HostIPCConnection::callDestroyZone(const api::ZoneId& argIn)
 {
-    mConnection.call(vasum::api::host::METHOD_DESTROY_ZONE, argIn);
+    mClient->callSync<api::ZoneId, api::Void>(
+            api::METHOD_DESTROY_ZONE,
+            std::make_shared<api::ZoneId>(argIn));
 }
 
-void HostIPCConnection::callShutdownZone(const vasum::api::ZoneId& argIn)
+void HostIPCConnection::callShutdownZone(const api::ZoneId& argIn)
 {
-    mConnection.call(vasum::api::host::METHOD_SHUTDOWN_ZONE, argIn);
+    mClient->callSync<api::ZoneId, api::Void>(
+            api::METHOD_SHUTDOWN_ZONE,
+            std::make_shared<api::ZoneId>(argIn));
 }
 
-void HostIPCConnection::callStartZone(const vasum::api::ZoneId& argIn)
+void HostIPCConnection::callStartZone(const api::ZoneId& argIn)
 {
-    mConnection.call(vasum::api::host::METHOD_START_ZONE, argIn);
+    mClient->callSync<api::ZoneId, api::Void>(
+            api::METHOD_START_ZONE,
+            std::make_shared<api::ZoneId>(argIn));
 }
 
-void HostIPCConnection::callLockZone(const vasum::api::ZoneId& argIn)
+void HostIPCConnection::callLockZone(const api::ZoneId& argIn)
 {
-    mConnection.call(vasum::api::host::METHOD_LOCK_ZONE, argIn);
+    mClient->callSync<api::ZoneId, api::Void>(
+            api::METHOD_LOCK_ZONE,
+            std::make_shared<api::ZoneId>(argIn));
 }
 
-void HostIPCConnection::callUnlockZone(const vasum::api::ZoneId& argIn)
+void HostIPCConnection::callUnlockZone(const api::ZoneId& argIn)
 {
-    mConnection.call(vasum::api::host::METHOD_UNLOCK_ZONE, argIn);
+    mClient->callSync<api::ZoneId, api::Void>(
+            api::METHOD_UNLOCK_ZONE,
+            std::make_shared<api::ZoneId>(argIn));
 }
 
-void HostIPCConnection::callGrantDevice(const vasum::api::GrantDeviceIn& argIn)
+void HostIPCConnection::callGrantDevice(const api::GrantDeviceIn& argIn)
 {
-    mConnection.call(vasum::api::host::METHOD_GRANT_DEVICE, argIn);
+    mClient->callSync<api::GrantDeviceIn, api::Void>(
+            api::METHOD_GRANT_DEVICE,
+            std::make_shared<api::GrantDeviceIn>(argIn));
 }
 
-void HostIPCConnection::callRevokeDevice(const vasum::api::RevokeDeviceIn& argIn)
+void HostIPCConnection::callRevokeDevice(const api::RevokeDeviceIn& argIn)
 {
-    mConnection.call(vasum::api::host::METHOD_REVOKE_DEVICE, argIn);
+    mClient->callSync<api::RevokeDeviceIn, api::Void>(
+            api::METHOD_REVOKE_DEVICE,
+            std::make_shared<api::RevokeDeviceIn>(argIn));
 }
 
-void HostIPCConnection::callGetZoneConnections(vasum::api::Connections& argOut)
+void HostIPCConnection::callNotifyActiveZone(const api::NotifActiveZoneIn& argIn)
 {
-    mConnection.call(vasum::api::host::METHOD_GET_ZONE_CONNECTIONS, argOut);
+    mClient->callSync<api::NotifActiveZoneIn, api::Void>(
+            api::METHOD_NOTIFY_ACTIVE_ZONE,
+            std::make_shared<api::NotifActiveZoneIn>(argIn));
+}
+
+void HostIPCConnection::callFileMoveRequest(const api::FileMoveRequestIn& argIn,
+                                            api::FileMoveRequestStatus& argOut)
+{
+    argOut = *mClient->callSync<api::FileMoveRequestIn, api::FileMoveRequestStatus>(
+        api::METHOD_FILE_MOVE_REQUEST,
+        std::make_shared<api::FileMoveRequestIn>(argIn));
+}
+
+void HostIPCConnection::signalSwitchToDefault()
+{
+
+    mClient->signal(api::SIGNAL_SWITCH_TO_DEFAULT,
+                    std::make_shared<api::Void>());
 }
 
 HostIPCConnection::SubscriptionId
-HostIPCConnection::subscribeZoneConnectionState(const ZoneConnectionStateCallback& callback)
+HostIPCConnection::subscribeNotification(const NotificationCallback& callback)
 {
-    mConnection.subscribe<ZoneConnectionStateCallback, vasum::api::ConnectionState>(
-            vasum::api::host::SIGNAL_ZONE_CONNECTION_STATE, callback);
-    return vasum::api::host::SIGNAL_ZONE_CONNECTION_STATE;
+    auto callbackWrapper = [callback] (const ipc::PeerID,
+                                       std::shared_ptr<api::Notification>& data) {
+        callback(*data);
+    };
+    mClient->setSignalHandler<api::Notification>(api::SIGNAL_NOTIFICATION, callbackWrapper);
+    return api::SIGNAL_NOTIFICATION;
 }
 
 void HostIPCConnection::unsubscribe(const SubscriptionId& id)
 {
-    mConnection.unsubscribe(id);
+    mClient->removeMethod(id);
 }
 
 } // namespace client
index 216e976..8fa6e06 100644 (file)
 #ifndef VASUM_CLIENT_HOST_IPC_CONNECTION_HPP
 #define VASUM_CLIENT_HOST_IPC_CONNECTION_HPP
 
-#include "ipc-connection.hpp"
 #include <api/messages.hpp>
+#include <epoll/thread-dispatcher.hpp>
+#include <ipc/client.hpp>
+
+#include <functional>
 
 namespace vasum {
 namespace client {
@@ -38,8 +41,9 @@ namespace client {
 class HostIPCConnection {
 public:
     typedef unsigned int SubscriptionId;
-    typedef std::function<void(const vasum::api::ConnectionState&)> ZoneConnectionStateCallback;
+    typedef std::function<void(const vasum::api::Notification&)> NotificationCallback;
     void createSystem();
+    void create(const std::string& address);
 
     void callGetZoneIds(vasum::api::ZoneIds& argOut);
     void callGetActiveZoneId(vasum::api::ZoneId& argOut);
@@ -67,11 +71,22 @@ public:
     void callGrantDevice(const vasum::api::GrantDeviceIn& argIn);
     void callRevokeDevice(const vasum::api::RevokeDeviceIn& argIn);
     void callGetZoneConnections(vasum::api::Connections& argOut);
-    SubscriptionId subscribeZoneConnectionState(const ZoneConnectionStateCallback& callback);
+    void callNotifyActiveZone(const vasum::api::NotifActiveZoneIn& argIn);
+    void callFileMoveRequest(const vasum::api::FileMoveRequestIn& argIn,
+                             vasum::api::FileMoveRequestStatus& argOut);
+    void signalSwitchToDefault();
+    SubscriptionId subscribeNotification(const NotificationCallback& callback);
     void unsubscribe(const SubscriptionId& id);
 
 private:
-    IPCConnection mConnection;
+    epoll::ThreadDispatcher mDispatcher;
+    std::unique_ptr<ipc::Client> mClient;
+
+    template<typename ArgIn, typename ArgOut>
+    void call(const ipc::MethodID method, const ArgIn& argIn, ArgOut& argOut, int timeout = 5000) {
+        auto out = mClient->callSync<ArgIn, ArgOut>(method, std::make_shared<ArgIn>(argIn), timeout);
+        argOut = *out;
+    }
 };
 
 } // namespace client
diff --git a/client/ipc-connection.cpp b/client/ipc-connection.cpp
deleted file mode 100644 (file)
index 04954bc..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Mateusz Malicki <m.malicki2@samsung.com>
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License
- */
-
-
-/**
- * @file
- * @author  Mateusz Malicki (m.malicki2@samsung.com)
- * @brief   IPCConnection class
- */
-
-#include <config.hpp>
-#include "ipc-connection.hpp"
-
-namespace {
-
-const std::string SOCKET_PATH = HOST_IPC_SOCKET;
-
-} // namespace
-
-vasum::client::IPCConnection::IPCConnection()
-{
-}
-
-vasum::client::IPCConnection::~IPCConnection()
-{
-}
-
-void vasum::client::IPCConnection::createSystem()
-{
-    mClient.reset(new ipc::Client(mDispatcher.getPoll(), SOCKET_PATH));
-    mClient->start();
-}
diff --git a/client/ipc-connection.hpp b/client/ipc-connection.hpp
deleted file mode 100644 (file)
index 1cb4d10..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Mateusz Malicki <m.malicki2@samsung.com>
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License
- */
-
-
-/**
- * @file
- * @author  Mateusz Malicki (m.malicki2@samsung.com)
- * @brief   IPCConnection class
- */
-
-#ifndef VASUM_CLIENT_IPC_CONNECTION_HPP
-#define VASUM_CLIENT_IPC_CONNECTION_HPP
-
-#include <api/messages.hpp>
-#include <ipc/client.hpp>
-#include <ipc/types.hpp>
-#include <epoll/thread-dispatcher.hpp>
-#include <type_traits>
-#include <memory>
-
-namespace vasum {
-namespace client {
-
-/**
- * IPCConnection class
- */
-class IPCConnection {
-public:
-    IPCConnection();
-    virtual ~IPCConnection();
-
-    void createSystem();
-
-    template<typename ArgIn, typename ArgOut>
-    typename std::enable_if<!std::is_integral<ArgOut>::value>::type
-    call(const ipc::MethodID method, const ArgIn& argIn, ArgOut& argOut, unsigned int timeout = 50000) {
-        auto out = mClient->callSync<ArgIn, ArgOut>(method, std::make_shared<ArgIn>(argIn), timeout);
-        argOut = *out;
-    }
-
-    template<typename ArgOut>
-    typename std::enable_if<!std::is_const<ArgOut>::value>::type
-    call(const ipc::MethodID method, ArgOut& argOut, unsigned int timeout = 50000) {
-        vasum::api::Void argIn;
-        call(method, argIn, argOut, timeout);
-    }
-
-    template<typename ArgIn>
-    typename std::enable_if<std::is_const<ArgIn>::value>::type
-    call(const ipc::MethodID method, ArgIn& argIn, unsigned int timeout = 50000) {
-        vasum::api::Void argOut;
-        call(method, argIn, argOut, timeout);
-    }
-
-    template<typename Callback, typename ArgIn>
-    void subscribe(const ipc::MethodID signal, const Callback& callback) {
-        auto callbackWrapper = [callback] (const ipc::PeerID, std::shared_ptr<ArgIn>& data) {
-            callback(*data);
-        };
-        mClient->setSignalHandler<ArgIn>(signal, callbackWrapper);
-    }
-
-    void unsubscribe(const ipc::MethodID signal) {
-        mClient->removeMethod(signal);
-    }
-
-private:
-    epoll::ThreadDispatcher mDispatcher;
-    std::unique_ptr<ipc::Client> mClient;
-};
-
-} // namespace client
-} // namespace vasum
-
-#endif /* VASUM_CLIENT_IPC_CONNECTION_HPP */
index 49b5846..8866e5f 100644 (file)
 #include "vasum-client-impl.hpp"
 #include "utils.hpp"
 #include "exception.hpp"
-#include "host-dbus-connection.hpp"
 #include "host-ipc-connection.hpp"
-#include "zone-dbus-connection.hpp"
-#include <zone-dbus-definitions.hpp>
-
-#include <dbus/connection.hpp>
-#include <dbus/exception.hpp>
-#include <utils/glib-loop.hpp>
 
 #include <algorithm>
 #include <vector>
@@ -52,8 +45,6 @@ using namespace vasum;
 
 namespace {
 
-unique_ptr<utils::ScopedGlibLoop> gGlibLoop;
-
 VsmZoneState getZoneState(const char* state)
 {
     if (strcmp(state, "STOPPED") == 0) {
@@ -90,16 +81,6 @@ void convert(const api::VectorOfStrings& in, VsmArrayString& out)
     }
 }
 
-void convert(const api::VectorOfStringPairs& in, VsmArrayString& keys, VsmArrayString& values)
-{
-    keys = reinterpret_cast<char**>(calloc(in.values.size() + 1, sizeof(char*)));
-    values = reinterpret_cast<char**>(calloc(in.values.size() + 1, sizeof(char*)));
-    for (size_t i = 0; i < in.values.size(); ++i) {
-        keys[i] = ::strdup(in.values[i].first.c_str());
-        values[i] = ::strdup(in.values[i].second.c_str());
-    }
-}
-
 void convert(const api::ZoneInfoOut& info, VsmZone& zone)
 {
     VsmZone vsmZone = reinterpret_cast<VsmZone>(malloc(sizeof(*vsmZone)));
@@ -145,23 +126,13 @@ bool readFirstLineOfFile(const string& path, string& ret)
 
 VsmStatus Client::vsm_start_glib_loop() noexcept
 {
-    try {
-        if (!gGlibLoop) {
-            gGlibLoop.reset(new utils::ScopedGlibLoop());
-        }
-    } catch (const exception&) {
-        return VSMCLIENT_OTHER_ERROR;
-    }
+    // TPDP: Remove vsm_start_glib_loop from API
     return VSMCLIENT_SUCCESS;
 }
 
 VsmStatus Client::vsm_stop_glib_loop() noexcept
 {
-    try {
-        gGlibLoop.reset();
-    } catch (const exception&) {
-        return VSMCLIENT_OTHER_ERROR;
-    }
+    // TPDP: Remove vsm_stop_glib_loop from API
     return VSMCLIENT_SUCCESS;
 }
 
@@ -198,16 +169,10 @@ VsmStatus Client::coverException(const function<void(void)>& worker) noexcept
         mStatus = Status(VSMCLIENT_OTHER_ERROR, ex.what());
     } catch (const vasum::ClientException& ex) {
         mStatus = Status(VSMCLIENT_CUSTOM_ERROR, ex.what());
-    } catch (const dbus::DbusCustomException& ex) {
+    } catch (const ipc::IPCUserException& ex) {
         mStatus = Status(VSMCLIENT_CUSTOM_ERROR, ex.what());
-    } catch (const dbus::DbusIOException& ex) {
+    } catch (const ipc::IPCException& ex) {
         mStatus = Status(VSMCLIENT_IO_ERROR, ex.what());
-    } catch (const dbus::DbusOperationException& ex) {
-        mStatus = Status(VSMCLIENT_OPERATION_FAILED, ex.what());
-    } catch (const dbus::DbusInvalidArgumentException& ex) {
-        mStatus = Status(VSMCLIENT_INVALID_ARGUMENT, ex.what());
-    } catch (const dbus::DbusException& ex) {
-        mStatus = Status(VSMCLIENT_OTHER_ERROR, ex.what());
     } catch (const exception& ex) {
         mStatus = Status(VSMCLIENT_CUSTOM_ERROR, ex.what());
     }
@@ -217,28 +182,14 @@ VsmStatus Client::coverException(const function<void(void)>& worker) noexcept
 VsmStatus Client::createSystem() noexcept
 {
     return coverException([&] {
-        shared_ptr<dbus::DbusConnection> connection(dbus::DbusConnection::createSystem().release());
-
-#ifdef DBUS_CONNECTION
-        mHostClient.create(connection);
-#else
         mHostClient.createSystem();
-#endif
-        mZoneClient.create(connection);
     });
 }
 
 VsmStatus Client::create(const string& address) noexcept
 {
     return coverException([&] {
-        shared_ptr<dbus::DbusConnection> connection(dbus::DbusConnection::create(address).release());
-
-#ifdef DBUS_CONNECTION
-        mHostClient.create(connection);
-#else
-        mHostClient.createSystem();
-#endif
-        mZoneClient.create(connection);
+        mHostClient.create(address);
     });
 }
 
@@ -252,15 +203,11 @@ VsmStatus Client::vsm_get_status() const noexcept
     return mStatus.mVsmStatus;
 }
 
-VsmStatus Client::vsm_get_zone_dbuses(VsmArrayString* keys, VsmArrayString* values) noexcept
+VsmStatus Client::vsm_get_zone_dbuses(VsmArrayString* /*keys*/, VsmArrayString* /*values*/) noexcept
 {
-    assert(keys);
-    assert(values);
-
     return coverException([&] {
-        api::Connections dbuses;
-        mHostClient.callGetZoneConnections(dbuses);
-        convert(dbuses, *keys, *values);
+        //TODO: Remove vsm_get_zone_dbuses from API
+        throw OperationFailedException("Not implemented");
     });
 }
 
@@ -322,6 +269,7 @@ VsmStatus Client::vsm_lookup_zone_by_id(const char* id, VsmZone* zone) noexcept
 VsmStatus Client::vsm_lookup_zone_by_terminal_id(int, VsmString*) noexcept
 {
     return coverException([&] {
+        //TODO: Implement vsm_lookup_zone_by_terminal_id
         throw OperationFailedException("Not implemented");
     });
 }
@@ -390,25 +338,13 @@ VsmStatus Client::vsm_unlock_zone(const char* id) noexcept
     });
 }
 
-VsmStatus Client::vsm_add_state_callback(VsmZoneDbusStateCallback zoneDbusStateCallback,
-                                    void* data,
-                                    VsmSubscriptionId* subscriptionId) noexcept
+VsmStatus Client::vsm_add_state_callback(VsmZoneDbusStateCallback /* zoneDbusStateCallback */,
+                                    void* /* data */,
+                                    VsmSubscriptionId* /* subscriptionId */) noexcept
 {
-    assert(zoneDbusStateCallback);
-
     return coverException([&] {
-        auto onSigal = [=](const api::ConnectionState& dbus)
-        {
-            zoneDbusStateCallback(dbus.first.c_str(),
-                                  dbus.second.c_str(),
-                                  data);
-        };
-
-        VsmSubscriptionId id;
-        id = mHostClient.subscribeZoneConnectionState(onSigal);
-        if (subscriptionId) {
-            *subscriptionId = id;
-        }
+        //TODO: Implement vsm_add_state_callback
+        throw OperationFailedException("Not implemented");
     });
 }
 
@@ -758,57 +694,36 @@ VsmStatus Client::vsm_remove_declaration(const char* id, VsmString declaration)
     });
 }
 
-VsmStatus Client::vsm_notify_active_zone(const char* application, const char* message) noexcept
+VsmStatus Client::vsm_notify_active_zone(const char* /*application*/, const char* /*message*/) noexcept
 {
-    assert(application);
-    assert(message);
-
     return coverException([&] {
-        mZoneClient.callNotifyActiveZone({ application, message });
+        //TODO: Implement vsm_notify_active_zone
+        throw OperationFailedException("Not implemented");
     });
 }
 
-VsmStatus Client::vsm_file_move_request(const char* destZone, const char* path) noexcept
+VsmStatus Client::vsm_file_move_request(const char* /*destZone*/, const char* /*path*/) noexcept
 {
-    assert(destZone);
-    assert(path);
-
     return coverException([&] {
-        api::FileMoveRequestStatus status;
-        mZoneClient.callFileMoveRequest({ destZone, path }, status);
-        if (status.value != api::zone::FILE_MOVE_SUCCEEDED) {
-            throw ClientException(status.value);
-        }
+        //TODO: Implement vsm_file_move_request
+        throw OperationFailedException("Not implemented");
     });
 }
 
-VsmStatus Client::vsm_add_notification_callback(VsmNotificationCallback notificationCallback,
-                                           void* data,
-                                           VsmSubscriptionId* subscriptionId) noexcept
+VsmStatus Client::vsm_add_notification_callback(VsmNotificationCallback /*notificationCallback*/,
+                                           void* /*data*/,
+                                           VsmSubscriptionId* /*subscriptionId*/) noexcept
 {
-    assert(notificationCallback);
-
     return coverException([&] {
-        auto onSignal = [=](const api::Notification& notification)
-        {
-            notificationCallback(notification.zone.c_str(),
-                                 notification.application.c_str(),
-                                 notification.message.c_str(),
-                                 data);
-        };
-
-        VsmSubscriptionId id;
-        id = mZoneClient.subscribeNotification(onSignal);
-        if (subscriptionId) {
-            *subscriptionId = id;
-        }
+        //TODO: Implement vsm_add_notification_callback
+        throw OperationFailedException("Not implemented");
     });
 }
 
 VsmStatus Client::vsm_del_notification_callback(VsmSubscriptionId subscriptionId) noexcept
 {
     return coverException([&] {
-        mZoneClient.unsubscribe(subscriptionId);
+        mHostClient.unsubscribe(subscriptionId);
     });
 }
 
index 9e8118c..3f3b13a 100644 (file)
 #define VASUM_CLIENT_IMPL_HPP
 
 #include "vasum-client.h"
-#ifdef DBUS_CONNECTION
-#include "host-dbus-connection.hpp"
-#else
 #include "host-ipc-connection.hpp"
-#endif
-#include "zone-dbus-connection.hpp"
 
 #include <functional>
 #include <linux/if_link.h>
@@ -324,12 +319,7 @@ public:
      */
     static VsmStatus vsm_stop_glib_loop() noexcept;
 private:
-#ifdef DBUS_CONNECTION
-    typedef vasum::client::HostDbusConnection HostConnection;
-#else
     typedef vasum::client::HostIPCConnection HostConnection;
-#endif
-    typedef vasum::client::ZoneDbusConnection ZoneConnection;
     struct Status {
         Status();
         Status(VsmStatus status, const std::string& msg = "");
@@ -340,7 +330,6 @@ private:
     Status mStatus;
 
     HostConnection mHostClient;
-    ZoneConnection mZoneClient;
 
     VsmStatus coverException(const std::function<void(void)>& worker) noexcept;
     VsmStatus vsm_netdev_get_ip_addr(const char* zone,
diff --git a/client/zone-dbus-connection.cpp b/client/zone-dbus-connection.cpp
deleted file mode 100644 (file)
index b7f82a8..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Mateusz Malicki <m.malicki2@samsung.com>
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License
- */
-
-
-/**
- * @file
- * @author  Mateusz Malicki (m.malicki2@samsung.com)
- * @brief   Zone client class
- */
-
-#include <config.hpp>
-#include "zone-dbus-connection.hpp"
-#include <api/messages.hpp>
-#include <zone-dbus-definitions.hpp>
-
-namespace vasum {
-namespace client {
-
-ZoneDbusConnection::ZoneDbusConnection()
-    : mConnection(vasum::api::zone::DEFINITION,
-                  vasum::api::zone::BUS_NAME,
-                  vasum::api::zone::OBJECT_PATH,
-                  vasum::api::zone::INTERFACE)
-{
-}
-
-void ZoneDbusConnection::create(const std::shared_ptr<dbus::DbusConnection>& connection)
-{
-    mConnection.create(connection);
-}
-
-void ZoneDbusConnection::callNotifyActiveZone(const vasum::api::NotifActiveZoneIn& argIn)
-{
-    mConnection.call(vasum::api::zone::METHOD_NOTIFY_ACTIVE_ZONE, argIn);
-}
-
-void ZoneDbusConnection::callFileMoveRequest(const vasum::api::FileMoveRequestIn& argIn,
-                                             vasum::api::FileMoveRequestStatus& argOut)
-{
-    mConnection.call(vasum::api::zone::METHOD_FILE_MOVE_REQUEST, argIn, argOut);
-}
-
-ZoneDbusConnection::SubscriptionId
-ZoneDbusConnection::subscribeNotification(const NotificationCallback& callback)
-{
-    return mConnection.signalSubscribe<vasum::api::Notification>(
-        vasum::api::zone::SIGNAL_NOTIFICATION, callback);
-}
-
-void ZoneDbusConnection::unsubscribe(const SubscriptionId& id )
-{
-    mConnection.signalUnsubscribe(id);
-}
-
-} // namespace client
-} // namespace vasum
diff --git a/client/zone-dbus-connection.hpp b/client/zone-dbus-connection.hpp
deleted file mode 100644 (file)
index 576b4cb..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Mateusz Malicki <m.malicki2@samsung.com>
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License
- */
-
-
-/**
- * @file
- * @author  Mateusz Malicki (m.malicki2@samsung.com)
- * @brief   Zone client class
- */
-
-#ifndef VASUM_CLIENT_ZONE_DBUS_CONNECTION_HPP
-#define VASUM_CLIENT_ZONE_DBUS_CONNECTION_HPP
-
-#include "dbus-connection.hpp"
-#include <api/messages.hpp>
-
-namespace vasum {
-namespace client {
-
-/**
- * vasum's client definition.
- *
- * ZoneDbusConnection is used for communication with the vasum's server from zone through dbus
- */
-class ZoneDbusConnection {
-public:
-    typedef unsigned int SubscriptionId;
-    typedef std::function<void(const vasum::api::Notification&)> NotificationCallback;
-
-    ZoneDbusConnection();
-    void create(const std::shared_ptr<dbus::DbusConnection>& connection);
-
-    void callNotifyActiveZone(const vasum::api::NotifActiveZoneIn& argIn);
-    void callFileMoveRequest(const vasum::api::FileMoveRequestIn& argIn,
-                             vasum::api::FileMoveRequestStatus& argOut);
-    SubscriptionId subscribeNotification(const NotificationCallback& callback);
-    void unsubscribe(const SubscriptionId& id);
-private:
-    DbusConnection mConnection;
-};
-
-} // namespace client
-} // namespace vasum
-
-#endif /* VASUM_CLIENT_ZONE_DBUS_CONNECTION_HPP */
similarity index 52%
rename from server/common-dbus-definitions.hpp
rename to server/common-definitions.hpp
index 178f363..5e85f92 100644 (file)
 /**
  * @file
  * @author  Jan Olszak (j.olszak@samsung.com)
- * @brief   Common dbus api definitions
+ * @brief   Common (dbus, IPC) api definitions
  */
 
-#ifndef SERVER_COMMON_DBUS_DEFINITIONS_HPP
-#define SERVER_COMMON_DBUS_DEFINITIONS_HPP
+#ifndef SERVER_COMMON_DEFINITIONS_HPP
+#define SERVER_COMMON_DEFINITIONS_HPP
 
 #include <string>
 
 
 namespace vasum {
 namespace api {
-const std::string ERROR_FORBIDDEN     = "org.tizen.vasum.Error.Forbidden";
-const std::string ERROR_FORWARDED     = "org.tizen.vasum.Error.Forwarded";
-const std::string ERROR_INVALID_ID    = "org.tizen.vasum.Error.InvalidId";
-const std::string ERROR_INVALID_STATE = "org.tizen.vasum.Error.InvalidState";
-const std::string ERROR_INTERNAL      = "org.tizen.vasum.Error.Internal";
 
-const std::string METHOD_PROXY_CALL    = "ProxyCall";
+/**
+ * Error codes that can be set in API handlers
+ */
+//TODO: Errors should use exception handling mechanism
+///@{
+const std::string ERROR_FORBIDDEN         = "org.tizen.vasum.Error.Forbidden";
+const std::string ERROR_FORWARDED         = "org.tizen.vasum.Error.Forwarded";
+const std::string ERROR_INVALID_ID        = "org.tizen.vasum.Error.InvalidId";
+const std::string ERROR_INVALID_STATE     = "org.tizen.vasum.Error.InvalidState";
+const std::string ERROR_INTERNAL          = "org.tizen.vasum.Error.Internal";
+const std::string ERROR_ZONE_NOT_RUNNING  = "org.tizen.vasum.Error.ZonesNotRunning";
+///@}
 
 } // namespace api
 } // namespace vasum
 
 
-#endif // SERVER_COMMON_DBUS_DEFINITIONS_HPP
+#endif // SERVER_COMMON_DEFINITIONS_HPP
index e7d5533..82cd0f9 100755 (executable)
@@ -40,7 +40,6 @@ lxc.pts = 256
 lxc.tty = 0
 
 lxc.mount.auto = proc sys cgroup
-lxc.mount.entry = /var/run/zones/${name}/run var/run none rw,bind 0 0
 
 # create a separate network per zone
 # - it forbids traffic sniffing (like macvlan in bridge mode)
index 3a99d20..ce88c6e 100644 (file)
@@ -10,7 +10,6 @@
     "vt" : 0,
     "shutdownTimeout" : 10,
     "switchToDefaultAfterTimeout" : true,
-    "enableZoneConnection" : false,
     "runMountPoint" : "~NAME~/run",
     "provisions" : [],
     "permittedToSend" : [ "/tmp/.*" ],
index 76f5bb8..b93ad21 100644 (file)
@@ -53,27 +53,31 @@ HostDbusConnection::HostDbusConnection()
     mDbusConnection = dbus::DbusConnection::createSystem();
 
     LOGT("Setting DBUS name");
-    mDbusConnection->setName(api::host::BUS_NAME,
+    mDbusConnection->setName(api::BUS_NAME,
                              std::bind(&HostDbusConnection::onNameAcquired, this),
                              std::bind(&HostDbusConnection::onNameLost, this));
 
     if (!waitForName(NAME_ACQUIRED_TIMEOUT)) {
-        LOGE("Could not acquire dbus name: " << api::host::BUS_NAME);
-        throw HostConnectionException("Could not acquire dbus name: " + api::host::BUS_NAME);
+        LOGE("Could not acquire dbus name: " << api::BUS_NAME);
+        throw HostConnectionException("Could not acquire dbus name: " + api::BUS_NAME);
     }
 
     LOGT("Registering DBUS interface");
     using namespace std::placeholders;
-    mDbusConnection->registerObject(api::host::OBJECT_PATH,
-                                    api::host::DEFINITION,
+    mDbusConnection->registerObject(api::OBJECT_PATH,
+                                    api::DEFINITION,
                                     std::bind(&HostDbusConnection::onMessageCall,
-                                            this, _1, _2, _3, _4, _5));
+                                              this, _1, _2, _3, _4, _5));
 
+    mSubscriptionId = mDbusConnection->signalSubscribe(std::bind(&HostDbusConnection::onSignalCall,
+                                                                 this, _1, _2, _3, _4, _5),
+                                                       std::string());
     LOGD("Connected");
 }
 
 HostDbusConnection::~HostDbusConnection()
 {
+    mDbusConnection->signalUnsubscribe(mSubscriptionId);
 }
 
 bool HostDbusConnection::waitForName(const unsigned int timeoutMs)
@@ -242,6 +246,20 @@ void HostDbusConnection::setRevokeDeviceCallback(const RevokeDeviceCallback& cal
     mRevokeDeviceCallback = callback;
 }
 
+void HostDbusConnection::setNotifyActiveZoneCallback(const NotifyActiveZoneCallback& callback)
+{
+    mNotifyActiveZoneCallback = callback;
+}
+
+void HostDbusConnection::setSwitchToDefaultCallback(const SwitchToDefaultCallback& callback)
+{
+    mSwitchToDefaultCallback = callback;
+}
+
+void HostDbusConnection::setFileMoveCallback(const FileMoveCallback& callback)
+{
+    mFileMoveCallback = callback;
+}
 
 void HostDbusConnection::onMessageCall(const std::string& objectPath,
                                    const std::string& interface,
@@ -249,11 +267,11 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
                                    GVariant* parameters,
                                    dbus::MethodResultBuilder::Pointer result)
 {
-    if (objectPath != api::host::OBJECT_PATH || interface != api::host::INTERFACE) {
+    if (objectPath != api::OBJECT_PATH || interface != api::INTERFACE) {
         return;
     }
 
-    if (methodName == api::host::METHOD_SET_ACTIVE_ZONE) {
+    if (methodName == api::METHOD_SET_ACTIVE_ZONE) {
         api::ZoneId zoneId;
         config::loadFromGVariant(parameters, zoneId);
 
@@ -264,14 +282,6 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::host::METHOD_GET_ZONE_CONNECTIONS) {
-        if (mGetZoneConnectionsCallback) {
-            auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Connections>>(result);
-            mGetZoneConnectionsCallback(rb);
-        }
-        return;
-    }
-
     if (methodName == api::METHOD_PROXY_CALL) {
         const gchar* target = NULL;
         const gchar* targetBusName = NULL;
@@ -301,7 +311,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::host::METHOD_GET_ZONE_ID_LIST) {
+    if (methodName == api::METHOD_GET_ZONE_ID_LIST) {
         if (mGetZoneIdsCallback) {
             auto rb = std::make_shared<api::DbusMethodResultBuilder<api::ZoneIds>>(result);
             mGetZoneIdsCallback(rb);
@@ -309,7 +319,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::host::METHOD_GET_ACTIVE_ZONE_ID) {
+    if (methodName == api::METHOD_GET_ACTIVE_ZONE_ID) {
         if (mGetActiveZoneIdCallback) {
             auto rb = std::make_shared<api::DbusMethodResultBuilder<api::ZoneId>>(result);
             mGetActiveZoneIdCallback(rb);
@@ -317,7 +327,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::host::METHOD_GET_ZONE_INFO) {
+    if (methodName == api::METHOD_GET_ZONE_INFO) {
         api::ZoneId zoneId;
         config::loadFromGVariant(parameters, zoneId);
 
@@ -328,7 +338,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::host::METHOD_SET_NETDEV_ATTRS) {
+    if (methodName == api::METHOD_SET_NETDEV_ATTRS) {
         api::SetNetDevAttrsIn data;
         config::loadFromGVariant(parameters, data);
 
@@ -339,7 +349,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::host::METHOD_GET_NETDEV_ATTRS) {
+    if (methodName == api::METHOD_GET_NETDEV_ATTRS) {
         api::GetNetDevAttrsIn data;
         config::loadFromGVariant(parameters, data);
 
@@ -350,7 +360,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::host::METHOD_GET_NETDEV_LIST) {
+    if (methodName == api::METHOD_GET_NETDEV_LIST) {
         api::ZoneId data;
         config::loadFromGVariant(parameters, data);
 
@@ -361,7 +371,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::host::METHOD_CREATE_NETDEV_VETH) {
+    if (methodName == api::METHOD_CREATE_NETDEV_VETH) {
         api::CreateNetDevVethIn data;
         config::loadFromGVariant(parameters, data);
 
@@ -372,7 +382,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::host::METHOD_CREATE_NETDEV_MACVLAN) {
+    if (methodName == api::METHOD_CREATE_NETDEV_MACVLAN) {
         api::CreateNetDevMacvlanIn data;
         config::loadFromGVariant(parameters, data);
 
@@ -382,7 +392,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         }
     }
 
-    if (methodName == api::host::METHOD_CREATE_NETDEV_PHYS) {
+    if (methodName == api::METHOD_CREATE_NETDEV_PHYS) {
         api::CreateNetDevPhysIn data;
         config::loadFromGVariant(parameters, data);
 
@@ -392,7 +402,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         }
     }
 
-    if (methodName == api::host::METHOD_DESTROY_NETDEV) {
+    if (methodName == api::METHOD_DESTROY_NETDEV) {
         api::DestroyNetDevIn data;
         config::loadFromGVariant(parameters, data);
 
@@ -402,7 +412,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         }
     }
 
-    if (methodName == api::host::METHOD_DELETE_NETDEV_IP_ADDRESS) {
+    if (methodName == api::METHOD_DELETE_NETDEV_IP_ADDRESS) {
         api::DeleteNetdevIpAddressIn data;
         config::loadFromGVariant(parameters, data);
         if (mDeleteNetdevIpAddressCallback) {
@@ -411,7 +421,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         }
     }
 
-    if (methodName == api::host::METHOD_DECLARE_FILE) {
+    if (methodName == api::METHOD_DECLARE_FILE) {
         api::DeclareFileIn data;
         config::loadFromGVariant(parameters, data);
 
@@ -422,7 +432,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::host::METHOD_DECLARE_MOUNT) {
+    if (methodName == api::METHOD_DECLARE_MOUNT) {
         api::DeclareMountIn data;
         config::loadFromGVariant(parameters, data);
 
@@ -433,7 +443,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::host::METHOD_DECLARE_LINK) {
+    if (methodName == api::METHOD_DECLARE_LINK) {
         api::DeclareLinkIn data;
         config::loadFromGVariant(parameters, data);
 
@@ -444,7 +454,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::host::METHOD_GET_DECLARATIONS) {
+    if (methodName == api::METHOD_GET_DECLARATIONS) {
         api::ZoneId data;
         config::loadFromGVariant(parameters, data);
 
@@ -455,7 +465,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::host::METHOD_REMOVE_DECLARATION) {
+    if (methodName == api::METHOD_REMOVE_DECLARATION) {
         api::RemoveDeclarationIn data;
         config::loadFromGVariant(parameters, data);
 
@@ -466,7 +476,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::host::METHOD_CREATE_ZONE) {
+    if (methodName == api::METHOD_CREATE_ZONE) {
         api::CreateZoneIn data;
         config::loadFromGVariant(parameters, data);
 
@@ -477,7 +487,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::host::METHOD_DESTROY_ZONE) {
+    if (methodName == api::METHOD_DESTROY_ZONE) {
         api::ZoneId data;
         config::loadFromGVariant(parameters, data);
 
@@ -488,7 +498,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::host::METHOD_SHUTDOWN_ZONE) {
+    if (methodName == api::METHOD_SHUTDOWN_ZONE) {
         api::ZoneId data;
         config::loadFromGVariant(parameters, data);
 
@@ -498,7 +508,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         }
     }
 
-    if (methodName == api::host::METHOD_START_ZONE) {
+    if (methodName == api::METHOD_START_ZONE) {
         api::ZoneId data;
         config::loadFromGVariant(parameters, data);
 
@@ -508,7 +518,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         }
     }
 
-    if (methodName == api::host::METHOD_LOCK_ZONE) {
+    if (methodName == api::METHOD_LOCK_ZONE) {
         api::ZoneId data;
         config::loadFromGVariant(parameters, data);
 
@@ -519,7 +529,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::host::METHOD_UNLOCK_ZONE) {
+    if (methodName == api::METHOD_UNLOCK_ZONE) {
         api::ZoneId data;
         config::loadFromGVariant(parameters, data);
 
@@ -530,7 +540,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::host::METHOD_GRANT_DEVICE) {
+    if (methodName == api::METHOD_GRANT_DEVICE) {
         api::GrantDeviceIn data;
         config::loadFromGVariant(parameters, data);
 
@@ -541,7 +551,7 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::host::METHOD_REVOKE_DEVICE) {
+    if (methodName == api::METHOD_REVOKE_DEVICE) {
         api::RevokeDeviceIn data;
         config::loadFromGVariant(parameters, data);
 
@@ -551,6 +561,43 @@ void HostDbusConnection::onMessageCall(const std::string& objectPath,
         }
         return;
     }
+
+    if (methodName == api::METHOD_NOTIFY_ACTIVE_ZONE) {
+        api::NotifActiveZoneIn data;
+        config::loadFromGVariant(parameters, data);
+
+        if (mNotifyActiveZoneCallback) {
+            auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Void>>(result);
+            mNotifyActiveZoneCallback(data, rb);
+        }
+    }
+
+    if (methodName == api::METHOD_FILE_MOVE_REQUEST) {
+        api::FileMoveRequestIn data;
+        config::loadFromGVariant(parameters, data);
+
+        if (mFileMoveCallback) {
+            auto rb = std::make_shared<api::DbusMethodResultBuilder<api::FileMoveRequestStatus>>(result);
+            mFileMoveCallback(data, rb);
+        }
+    }
+}
+
+void HostDbusConnection::onSignalCall(const std::string& /* senderBusName */,
+                                      const std::string& objectPath,
+                                      const std::string& interface,
+                                      const std::string& signalName,
+                                      GVariant* /* parameters */)
+{
+    if (objectPath != api::OBJECT_PATH || interface != api::INTERFACE) {
+        return;
+    }
+
+    if (signalName == api::SIGNAL_SWITCH_TO_DEFAULT) {
+        if (mSwitchToDefaultCallback) {
+            mSwitchToDefaultCallback();
+        }
+    }
 }
 
 void HostDbusConnection::proxyCallAsync(const std::string& busName,
@@ -569,14 +616,16 @@ void HostDbusConnection::proxyCallAsync(const std::string& busName,
                                      callback);
 }
 
-void HostDbusConnection::signalZoneConnectionState(const api::ConnectionState& state)
+void HostDbusConnection::sendNotification(const api::Notification& notify)
 {
-    GVariant* parameters = g_variant_new("(ss)", state.first.c_str(), state.second.c_str());
-    mDbusConnection->emitSignal(api::host::OBJECT_PATH,
-                                api::host::INTERFACE,
-                                api::host::SIGNAL_ZONE_CONNECTION_STATE,
+    GVariant* parameters = g_variant_new("(sss)",
+                                         notify.zone.c_str(),
+                                         notify.application.c_str(),
+                                         notify.message.c_str());
+    mDbusConnection->emitSignal(api::OBJECT_PATH,
+                                api::INTERFACE,
+                                api::SIGNAL_NOTIFICATION,
                                 parameters);
 }
 
-
 } // namespace vasum
index 455437d..cdd8dda 100644 (file)
@@ -131,6 +131,14 @@ public:
     typedef std::function<void(const api::RevokeDeviceIn& dataIn,
                                api::MethodResultBuilder::Pointer result
                               )> RevokeDeviceCallback;
+    typedef std::function<void(const api::NotifActiveZoneIn& notify,
+                               api::MethodResultBuilder::Pointer result
+                              )> NotifyActiveZoneCallback;
+    typedef std::function<void(const api::FileMoveRequestIn& request,
+                               api::MethodResultBuilder::Pointer result
+                              )> FileMoveCallback;
+    typedef std::function<void()> SwitchToDefaultCallback;
+
 
     /**
      * Register proxy call callback
@@ -273,6 +281,26 @@ public:
     void setRevokeDeviceCallback(const RevokeDeviceCallback& callback);
 
     /**
+     * Register notification request callback
+     */
+    void setNotifyActiveZoneCallback(const NotifyActiveZoneCallback& callback);
+
+    /**
+     * Register switch to default request callback
+     */
+    void setSwitchToDefaultCallback(const SwitchToDefaultCallback& callback);
+
+    /*
+     * Register file move request callback
+     */
+    void setFileMoveCallback(const FileMoveCallback& callback);
+
+    /**
+     * Send notification signal to this zone
+     */
+    void sendNotification(const api::Notification& notify);
+
+    /**
      * Make a proxy call
      */
     void proxyCallAsync(const std::string& busName,
@@ -288,6 +316,7 @@ private:
     std::condition_variable mNameCondition;
     bool mNameAcquired;
     bool mNameLost;
+    dbus::DbusConnection::SubscriptionId mSubscriptionId;
     ProxyCallCallback mProxyCallCallback;
     GetZoneConnectionsCallback mGetZoneConnectionsCallback;
     GetZoneIdsCallback mGetZoneIdsCallback;
@@ -315,6 +344,9 @@ private:
     UnlockZoneCallback mUnlockZoneCallback;
     GrantDeviceCallback mGrantDeviceCallback;
     RevokeDeviceCallback mRevokeDeviceCallback;
+    NotifyActiveZoneCallback mNotifyActiveZoneCallback;
+    SwitchToDefaultCallback mSwitchToDefaultCallback;
+    FileMoveCallback mFileMoveCallback;
 
     void onNameAcquired();
     void onNameLost();
@@ -325,6 +357,11 @@ private:
                        const std::string& methodName,
                        GVariant* parameters,
                        dbus::MethodResultBuilder::Pointer result);
+    void onSignalCall(const std::string& senderBusName,
+                      const std::string& objectPath,
+                      const std::string& interface,
+                      const std::string& signalName,
+                      GVariant* parameters);
 };
 
 
index b814c90..208276e 100644 (file)
 #ifndef SERVER_HOST_DBUS_DEFINITIONS_HPP
 #define SERVER_HOST_DBUS_DEFINITIONS_HPP
 
-#include "common-dbus-definitions.hpp"
-
+#include <string>
 
 namespace vasum {
 namespace api {
-namespace host {
 
 const std::string BUS_NAME                        = "org.tizen.vasum.host";
 const std::string OBJECT_PATH                     = "/org/tizen/vasum/host";
 const std::string INTERFACE                       = "org.tizen.vasum.host.manager";
 
-const std::string ERROR_ZONE_NOT_RUNNING          = "org.tizen.vasum.host.Error.ZonesNotRunning";
 
-const std::string METHOD_GET_ZONE_CONNECTIONS     = "GetZoneConnections";
 const std::string METHOD_GET_ZONE_ID_LIST         = "GetZoneIds";
 const std::string METHOD_GET_ACTIVE_ZONE_ID       = "GetActiveZoneId";
 const std::string METHOD_GET_ZONE_INFO            = "GetZoneInfo";
@@ -64,8 +60,19 @@ const std::string METHOD_LOCK_ZONE                = "LockZone";
 const std::string METHOD_UNLOCK_ZONE              = "UnlockZone";
 const std::string METHOD_GRANT_DEVICE             = "GrantDevice";
 const std::string METHOD_REVOKE_DEVICE            = "RevokeDevice";
+const std::string METHOD_PROXY_CALL               = "ProxyCall";
+
+const std::string METHOD_NOTIFY_ACTIVE_ZONE         = "NotifyActiveZone";
+const std::string METHOD_FILE_MOVE_REQUEST          = "FileMoveRequest";
+const std::string SIGNAL_NOTIFICATION               = "Notification";
+const std::string SIGNAL_SWITCH_TO_DEFAULT          = "SwitchToDefault";
 
-const std::string SIGNAL_ZONE_CONNECTION_STATE    = "ZoneConnectionState";
+const std::string FILE_MOVE_DESTINATION_NOT_FOUND   = "FILE_MOVE_DESTINATION_NOT_FOUND";
+const std::string FILE_MOVE_WRONG_DESTINATION       = "FILE_MOVE_WRONG_DESTINATION";
+const std::string FILE_MOVE_NO_PERMISSIONS_SEND     = "FILE_MOVE_NO_PERMISSIONS_SEND";
+const std::string FILE_MOVE_NO_PERMISSIONS_RECEIVE  = "FILE_MOVE_NO_PERMISSIONS_RECEIVE";
+const std::string FILE_MOVE_FAILED                  = "FILE_MOVE_FAILED";
+const std::string FILE_MOVE_SUCCEEDED               = "FILE_MOVE_SUCCEEDED";
 
 
 const std::string DEFINITION =
@@ -80,9 +87,6 @@ const std::string DEFINITION =
     "      <arg type='v' name='parameters' direction='in'/>"
     "      <arg type='v' name='result' direction='out'/>"
     "    </method>"
-    "    <method name='" + METHOD_GET_ZONE_CONNECTIONS + "'>"
-    "      <arg type='a(ss)' name='connections' direction='out'/>"
-    "    </method>"
     "    <method name='" + METHOD_GET_ZONE_ID_LIST + "'>"
     "      <arg type='as' name='result' direction='out'/>"
     "    </method>"
@@ -196,14 +200,34 @@ const std::string DEFINITION =
     "      <arg type='s' name='id' direction='in'/>"
     "      <arg type='s' name='device' direction='in'/>"
     "    </method>"
-    "    <signal name='" + SIGNAL_ZONE_CONNECTION_STATE + "'>"
+    "    <method name='" + METHOD_NOTIFY_ACTIVE_ZONE + "'>"
+    "      <arg type='s' name='application' direction='in'/>"
+    "      <arg type='s' name='message' direction='in'/>"
+    "    </method>"
+    "    <method name='" + METHOD_FILE_MOVE_REQUEST + "'>"
+    "      <arg type='s' name='destination' direction='in'/>"
+    "      <arg type='s' name='path' direction='in'/>"
+    "      <arg type='s' name='result' direction='out'/>"
+    "    </method>"
+    "    <method name='" + METHOD_PROXY_CALL + "'>"
+    "      <arg type='s' name='target' direction='in'/>"
+    "      <arg type='s' name='busName' direction='in'/>"
+    "      <arg type='s' name='objectPath' direction='in'/>"
+    "      <arg type='s' name='interface' direction='in'/>"
+    "      <arg type='s' name='method' direction='in'/>"
+    "      <arg type='v' name='parameters' direction='in'/>"
+    "      <arg type='v' name='result' direction='out'/>"
+    "    </method>"
+    "    <signal name='" + SIGNAL_NOTIFICATION + "'>"
     "      <arg type='s' name='zone'/>"
-    "      <arg type='s' name='address'/>"
+    "      <arg type='s' name='application'/>"
+    "      <arg type='s' name='message'/>"
+    "    </signal>"
+    "    <signal name='" + SIGNAL_SWITCH_TO_DEFAULT + "'>"
     "    </signal>"
     "  </interface>"
     "</node>";
 
-} // namespace host
 } // namespace api
 } // namespace vasum
 
index 817e62f..1bf2e78 100644 (file)
 
 namespace vasum {
 
-namespace {
-
-const std::string SOCKET_PATH = HOST_IPC_SOCKET;
-
-} // namespace
-
-
 HostIPCConnection::HostIPCConnection()
 {
     LOGT("Connecting to host IPC socket");
-    mService.reset(new ipc::Service(mDispatcher.getPoll(), SOCKET_PATH));
+    mService.reset(new ipc::Service(mDispatcher.getPoll(), HOST_IPC_SOCKET));
 
     LOGT("Starting IPC");
     mService->start();
@@ -52,221 +45,238 @@ HostIPCConnection::~HostIPCConnection()
 {
 }
 
-void HostIPCConnection::setGetZoneConnectionsCallback(const Callback<api::Connections>::type& callback)
+void HostIPCConnection::setGetZoneIdsCallback(const Method<api::ZoneIds>::type& callback)
 {
-    typedef Callback<api::Connections> Callback;
+    typedef IPCMethodWrapper<api::ZoneIds> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::host::METHOD_GET_ZONE_CONNECTIONS,
-        Callback::getCallbackWrapper(callback));
+        api::METHOD_GET_ZONE_ID_LIST,
+        Callback::getWrapper(callback));
 
 }
 
-void HostIPCConnection::setGetZoneIdsCallback(const Callback<api::ZoneIds>::type& callback)
+void HostIPCConnection::setGetActiveZoneIdCallback(const Method<api::ZoneId>::type& callback)
 {
-    typedef Callback<api::ZoneIds> Callback;
+    typedef IPCMethodWrapper<api::ZoneId> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::host::METHOD_GET_ZONE_ID_LIST,
-        Callback::getCallbackWrapper(callback));
+        api::METHOD_GET_ACTIVE_ZONE_ID,
+        Callback::getWrapper(callback));
 
 }
 
-void HostIPCConnection::setGetActiveZoneIdCallback(const Callback<api::ZoneId>::type& callback)
+void HostIPCConnection::setGetZoneInfoCallback(const Method<const api::ZoneId, api::ZoneInfoOut>::type& callback)
 {
-    typedef Callback<api::ZoneId> Callback;
+    typedef IPCMethodWrapper<const api::ZoneId, api::ZoneInfoOut> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::host::METHOD_GET_ACTIVE_ZONE_ID,
-        Callback::getCallbackWrapper(callback));
-
+        api::METHOD_GET_ZONE_INFO,
+        Callback::getWrapper(callback));
 }
 
-void HostIPCConnection::setGetZoneInfoCallback(const Callback<const api::ZoneId, api::ZoneInfoOut>::type& callback)
+void HostIPCConnection::setSetNetdevAttrsCallback(const Method<const api::SetNetDevAttrsIn>::type& callback)
 {
-    typedef Callback<const api::ZoneId, api::ZoneInfoOut> Callback;
+    typedef IPCMethodWrapper<const api::SetNetDevAttrsIn> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::host::METHOD_GET_ZONE_INFO,
-        Callback::getCallbackWrapper(callback));
+        api::METHOD_SET_NETDEV_ATTRS,
+        Callback::getWrapper(callback));
 }
 
-void HostIPCConnection::setSetNetdevAttrsCallback(const Callback<const api::SetNetDevAttrsIn>::type& callback)
+void HostIPCConnection::setGetNetdevAttrsCallback(const Method<const api::GetNetDevAttrsIn, api::GetNetDevAttrs>::type& callback)
 {
-    typedef Callback<const api::SetNetDevAttrsIn> Callback;
+    typedef IPCMethodWrapper<const api::GetNetDevAttrsIn, api::GetNetDevAttrs> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::host::METHOD_SET_NETDEV_ATTRS,
-        Callback::getCallbackWrapper(callback));
+        api::METHOD_GET_NETDEV_ATTRS,
+        Callback::getWrapper(callback));
 }
 
-void HostIPCConnection::setGetNetdevAttrsCallback(const Callback<const api::GetNetDevAttrsIn, api::GetNetDevAttrs>::type& callback)
+void HostIPCConnection::setGetNetdevListCallback(const Method<const api::ZoneId, api::NetDevList>::type& callback)
 {
-    typedef Callback<const api::GetNetDevAttrsIn, api::GetNetDevAttrs> Callback;
+    typedef IPCMethodWrapper<const api::ZoneId, api::NetDevList> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::host::METHOD_GET_NETDEV_ATTRS,
-        Callback::getCallbackWrapper(callback));
+        api::METHOD_GET_NETDEV_LIST,
+        Callback::getWrapper(callback));
 }
 
-void HostIPCConnection::setGetNetdevListCallback(const Callback<const api::ZoneId, api::NetDevList>::type& callback)
+void HostIPCConnection::setCreateNetdevVethCallback(const Method<const api::CreateNetDevVethIn>::type& callback)
 {
-    typedef Callback<const api::ZoneId, api::NetDevList> Callback;
+    typedef IPCMethodWrapper<const api::CreateNetDevVethIn> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::host::METHOD_GET_NETDEV_LIST,
-        Callback::getCallbackWrapper(callback));
+        api::METHOD_CREATE_NETDEV_VETH,
+        Callback::getWrapper(callback));
 }
 
-void HostIPCConnection::setCreateNetdevVethCallback(const Callback<const api::CreateNetDevVethIn>::type& callback)
+void HostIPCConnection::setCreateNetdevMacvlanCallback(const Method<const api::CreateNetDevMacvlanIn>::type& callback)
 {
-    typedef Callback<const api::CreateNetDevVethIn> Callback;
+    typedef IPCMethodWrapper<const api::CreateNetDevMacvlanIn> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::host::METHOD_CREATE_NETDEV_VETH,
-        Callback::getCallbackWrapper(callback));
+        api::METHOD_CREATE_NETDEV_MACVLAN,
+        Callback::getWrapper(callback));
 }
 
-void HostIPCConnection::setCreateNetdevMacvlanCallback(const Callback<const api::CreateNetDevMacvlanIn>::type& callback)
+void HostIPCConnection::setCreateNetdevPhysCallback(const Method<const api::CreateNetDevPhysIn>::type& callback)
 {
-    typedef Callback<const api::CreateNetDevMacvlanIn> Callback;
+    typedef IPCMethodWrapper<const api::CreateNetDevPhysIn> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::host::METHOD_CREATE_NETDEV_MACVLAN,
-        Callback::getCallbackWrapper(callback));
+        api::METHOD_CREATE_NETDEV_PHYS,
+        Callback::getWrapper(callback));
 }
 
-void HostIPCConnection::setCreateNetdevPhysCallback(const Callback<const api::CreateNetDevPhysIn>::type& callback)
+void HostIPCConnection::setDestroyNetdevCallback(const Method<const api::DestroyNetDevIn>::type& callback)
 {
-    typedef Callback<const api::CreateNetDevPhysIn> Callback;
+    typedef IPCMethodWrapper<const api::DestroyNetDevIn> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::host::METHOD_CREATE_NETDEV_PHYS,
-        Callback::getCallbackWrapper(callback));
+        api::METHOD_DESTROY_NETDEV,
+        Callback::getWrapper(callback));
 }
 
-void HostIPCConnection::setDestroyNetdevCallback(const Callback<const api::DestroyNetDevIn>::type& callback)
+void HostIPCConnection::setDeleteNetdevIpAddressCallback(const Method<const api::DeleteNetdevIpAddressIn>::type& callback)
 {
-    typedef Callback<const api::DestroyNetDevIn> Callback;
+    typedef IPCMethodWrapper<const api::DeleteNetdevIpAddressIn> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::host::METHOD_DESTROY_NETDEV,
-        Callback::getCallbackWrapper(callback));
+        api::METHOD_DELETE_NETDEV_IP_ADDRESS,
+        Callback::getWrapper(callback));
 }
 
-void HostIPCConnection::setDeleteNetdevIpAddressCallback(const Callback<const api::DeleteNetdevIpAddressIn>::type& callback)
+void HostIPCConnection::setDeclareFileCallback(const Method<const api::DeclareFileIn, api::Declaration>::type& callback)
 {
-    typedef Callback<const api::DeleteNetdevIpAddressIn> Callback;
+    typedef IPCMethodWrapper<const api::DeclareFileIn, api::Declaration> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::host::METHOD_DELETE_NETDEV_IP_ADDRESS,
-        Callback::getCallbackWrapper(callback));
+        api::METHOD_DECLARE_FILE,
+        Callback::getWrapper(callback));
 }
 
-void HostIPCConnection::setDeclareFileCallback(const Callback<const api::DeclareFileIn, api::Declaration>::type& callback)
+void HostIPCConnection::setDeclareMountCallback(const Method<const api::DeclareMountIn, api::Declaration>::type& callback)
 {
-    typedef Callback<const api::DeclareFileIn, api::Declaration> Callback;
+    typedef IPCMethodWrapper<const api::DeclareMountIn, api::Declaration> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::host::METHOD_DECLARE_FILE,
-        Callback::getCallbackWrapper(callback));
+        api::METHOD_DECLARE_MOUNT,
+        Callback::getWrapper(callback));
 }
 
-void HostIPCConnection::setDeclareMountCallback(const Callback<const api::DeclareMountIn, api::Declaration>::type& callback)
+void HostIPCConnection::setDeclareLinkCallback(const Method<const api::DeclareLinkIn, api::Declaration>::type& callback)
 {
-    typedef Callback<const api::DeclareMountIn, api::Declaration> Callback;
+    typedef IPCMethodWrapper<const api::DeclareLinkIn, api::Declaration> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::host::METHOD_DECLARE_MOUNT,
-        Callback::getCallbackWrapper(callback));
+        api::METHOD_DECLARE_LINK,
+        Callback::getWrapper(callback));
 }
 
-void HostIPCConnection::setDeclareLinkCallback(const Callback<const api::DeclareLinkIn, api::Declaration>::type& callback)
+void HostIPCConnection::setGetDeclarationsCallback(const Method<const api::ZoneId, api::Declarations>::type& callback)
 {
-    typedef Callback<const api::DeclareLinkIn, api::Declaration> Callback;
+    typedef IPCMethodWrapper<const api::ZoneId, api::Declarations> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::host::METHOD_DECLARE_LINK,
-        Callback::getCallbackWrapper(callback));
+        api::METHOD_GET_DECLARATIONS,
+        Callback::getWrapper(callback));
 }
 
-void HostIPCConnection::setGetDeclarationsCallback(const Callback<const api::ZoneId, api::Declarations>::type& callback)
+void HostIPCConnection::setRemoveDeclarationCallback(const Method<const api::RemoveDeclarationIn>::type& callback)
 {
-    typedef Callback<const api::ZoneId, api::Declarations> Callback;
+    typedef IPCMethodWrapper<const api::RemoveDeclarationIn> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::host::METHOD_GET_DECLARATIONS,
-        Callback::getCallbackWrapper(callback));
+        api::METHOD_REMOVE_DECLARATION,
+        Callback::getWrapper(callback));
 }
 
-void HostIPCConnection::setRemoveDeclarationCallback(const Callback<const api::RemoveDeclarationIn>::type& callback)
+void HostIPCConnection::setSetActiveZoneCallback(const Method<const api::ZoneId>::type& callback)
 {
-    typedef Callback<const api::RemoveDeclarationIn> Callback;
+    typedef IPCMethodWrapper<const api::ZoneId> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::host::METHOD_REMOVE_DECLARATION,
-        Callback::getCallbackWrapper(callback));
+        api::METHOD_SET_ACTIVE_ZONE,
+        Callback::getWrapper(callback));
 }
 
-void HostIPCConnection::setSetActiveZoneCallback(const Callback<const api::ZoneId>::type& callback)
+void HostIPCConnection::setCreateZoneCallback(const Method<const api::CreateZoneIn>::type& callback)
 {
-    typedef Callback<const api::ZoneId> Callback;
+    typedef IPCMethodWrapper<const api::CreateZoneIn> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::host::METHOD_SET_ACTIVE_ZONE,
-        Callback::getCallbackWrapper(callback));
+        api::METHOD_CREATE_ZONE,
+        Callback::getWrapper(callback));
 }
 
-void HostIPCConnection::setCreateZoneCallback(const Callback<const api::CreateZoneIn>::type& callback)
+void HostIPCConnection::setDestroyZoneCallback(const Method<const api::ZoneId>::type& callback)
 {
-    typedef Callback<const api::CreateZoneIn> Callback;
+    typedef IPCMethodWrapper<const api::ZoneId> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::host::METHOD_CREATE_ZONE,
-        Callback::getCallbackWrapper(callback));
+        api::METHOD_DESTROY_ZONE,
+        Callback::getWrapper(callback));
 }
 
-void HostIPCConnection::setDestroyZoneCallback(const Callback<const api::ZoneId>::type& callback)
+void HostIPCConnection::setShutdownZoneCallback(const Method<const api::ZoneId>::type& callback)
 {
-    typedef Callback<const api::ZoneId> Callback;
+    typedef IPCMethodWrapper<const api::ZoneId> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::host::METHOD_DESTROY_ZONE,
-        Callback::getCallbackWrapper(callback));
+        api::METHOD_SHUTDOWN_ZONE,
+        Callback::getWrapper(callback));
 }
 
-void HostIPCConnection::setShutdownZoneCallback(const Callback<const api::ZoneId>::type& callback)
+void HostIPCConnection::setStartZoneCallback(const Method<const api::ZoneId>::type& callback)
 {
-    typedef Callback<const api::ZoneId> Callback;
+    typedef IPCMethodWrapper<const api::ZoneId> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::host::METHOD_SHUTDOWN_ZONE,
-        Callback::getCallbackWrapper(callback));
+        api::METHOD_START_ZONE,
+        Callback::getWrapper(callback));
 }
 
-void HostIPCConnection::setStartZoneCallback(const Callback<const api::ZoneId>::type& callback)
+void HostIPCConnection::setLockZoneCallback(const Method<const api::ZoneId>::type& callback)
 {
-    typedef Callback<const api::ZoneId> Callback;
+    typedef IPCMethodWrapper<const api::ZoneId> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::host::METHOD_START_ZONE,
-        Callback::getCallbackWrapper(callback));
+        api::METHOD_LOCK_ZONE,
+        Callback::getWrapper(callback));
 }
 
-void HostIPCConnection::setLockZoneCallback(const Callback<const api::ZoneId>::type& callback)
+void HostIPCConnection::setUnlockZoneCallback(const Method<const api::ZoneId>::type& callback)
 {
-    typedef Callback<const api::ZoneId> Callback;
+    typedef IPCMethodWrapper<const api::ZoneId> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::host::METHOD_LOCK_ZONE,
-        Callback::getCallbackWrapper(callback));
+        api::METHOD_UNLOCK_ZONE,
+        Callback::getWrapper(callback));
 }
 
-void HostIPCConnection::setUnlockZoneCallback(const Callback<const api::ZoneId>::type& callback)
+void HostIPCConnection::setGrantDeviceCallback(const Method<const api::GrantDeviceIn>::type& callback)
 {
-    typedef Callback<const api::ZoneId> Callback;
+    typedef IPCMethodWrapper<const api::GrantDeviceIn> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::host::METHOD_UNLOCK_ZONE,
-        Callback::getCallbackWrapper(callback));
+        api::METHOD_GRANT_DEVICE,
+        Callback::getWrapper(callback));
 }
 
-void HostIPCConnection::setGrantDeviceCallback(const Callback<const api::GrantDeviceIn>::type& callback)
+void HostIPCConnection::setRevokeDeviceCallback(const Method<const api::RevokeDeviceIn>::type& callback)
 {
-    typedef Callback<const api::GrantDeviceIn> Callback;
+    typedef IPCMethodWrapper<const api::RevokeDeviceIn> Callback;
     mService->setMethodHandler<Callback::out, Callback::in>(
-        api::host::METHOD_GRANT_DEVICE,
-        Callback::getCallbackWrapper(callback));
+        api::METHOD_REVOKE_DEVICE,
+        Callback::getWrapper(callback));
 }
 
-void HostIPCConnection::setRevokeDeviceCallback(const Callback<const api::RevokeDeviceIn>::type& callback)
+void HostIPCConnection::setNotifyActiveZoneCallback(
+    const Method<const vasum::api::NotifActiveZoneIn>::type& callback)
 {
-    typedef Callback<const api::RevokeDeviceIn> Callback;
-    mService->setMethodHandler<Callback::out, Callback::in>(
-        api::host::METHOD_REVOKE_DEVICE,
-        Callback::getCallbackWrapper(callback));
+    typedef IPCMethodWrapper<const api::NotifActiveZoneIn> Method;
+    mService->setMethodHandler<Method::out, Method::in>(
+        api::METHOD_NOTIFY_ACTIVE_ZONE,
+        Method::getWrapper(callback));
+}
+
+void HostIPCConnection::setSwitchToDefaultCallback(const Signal<const api::Void>::type& callback)
+{
+    typedef IPCSignalWrapper<const api::Void> Signal;
+    mService->setSignalHandler<Signal::in>(
+        api::SIGNAL_SWITCH_TO_DEFAULT,
+        Signal::getWrapper(callback));
+}
+
+void HostIPCConnection::setFileMoveCallback(const Method<const api::FileMoveRequestIn,
+                                            api::FileMoveRequestStatus>::type& callback)
+{
+    typedef IPCMethodWrapper<const api::FileMoveRequestIn, api::FileMoveRequestStatus> Method;
+    mService->setMethodHandler<Method::out, Method::in>(
+        api::METHOD_FILE_MOVE_REQUEST,
+        Method::getWrapper(callback));
 }
 
-void HostIPCConnection::signalZoneConnectionState(const api::ConnectionState& connectionState)
+void HostIPCConnection::sendNotification(const api::Notification& notification)
 {
-   mService->signal(api::host::SIGNAL_ZONE_CONNECTION_STATE,
-                    std::make_shared<api::ConnectionState>(connectionState));
+    mService->signal(api::SIGNAL_NOTIFICATION,
+                     std::make_shared<api::Notification>(notification));
 }
 
 } // namespace vasum
index 61c8f4a..d5144fd 100644 (file)
 #define SERVER_HOST_IPC_CONNECTION_HPP
 
 #include "api/messages.hpp"
-#include "api/method-result-builder.hpp"
-#include "api/ipc-method-result-builder.hpp"
 #include "epoll/thread-dispatcher.hpp"
 #include "ipc/service.hpp"
-
-#include <functional>
+#include "ipc-callback-wrapper.hpp"
 
 namespace vasum {
 
 
-
 class HostIPCConnection {
 public:
-    template<typename ArgIn, typename ArgOut = api::Void>
-    class Callback {
+    template<typename ArgIn = const api::Void, typename ArgOut = api::Void>
+    class Method {
     public:
-        typedef typename std::remove_cv<ArgIn>::type in;
-        typedef ArgOut out;
-        typedef std::function<void(const in&, api::MethodResultBuilder::Pointer)> type;
-
-        static typename ipc::MethodHandler<out, in>::type
-        getCallbackWrapper(const type& callback) {
-            return [callback](const ipc::PeerID,
-                              const std::shared_ptr<in>& argIn,
-                              ipc::MethodResult::Pointer&& argOut)
-            {
-                auto rb = std::make_shared<api::IPCMethodResultBuilder>(argOut);
-                callback(*argIn, rb);
-            };
-        }
+        typedef typename IPCMethodWrapper<ArgIn, ArgOut>::type type;
     };
-
-    template<typename ArgOut>
-    class Callback<ArgOut, typename std::enable_if<!std::is_const<ArgOut>::value, api::Void>::type> {
+    template<typename ArgIn>
+    class Signal {
     public:
-        typedef api::Void in;
-        typedef ArgOut out;
-        typedef std::function<void(api::MethodResultBuilder::Pointer)> type;
-
-        static typename ipc::MethodHandler<out, in>::type
-        getCallbackWrapper(const type& callback) {
-            return [callback](const ipc::PeerID,
-                              const std::shared_ptr<in>& /* argIn */,
-                              ipc::MethodResult::Pointer&& argOut)
-            {
-                auto rb = std::make_shared<api::IPCMethodResultBuilder>(argOut);
-                callback(rb);
-            };
-        }
+        typedef typename IPCSignalWrapper<ArgIn>::type type;
     };
 
     HostIPCConnection();
     ~HostIPCConnection();
 
-    void setGetZoneConnectionsCallback(const Callback<api::Connections>::type& callback);
-    void setGetZoneIdsCallback(const Callback<api::ZoneIds>::type& callback);
-    void setGetActiveZoneIdCallback(const Callback<api::ZoneId>::type& callback);
-    void setGetZoneInfoCallback(const Callback<const api::ZoneId, api::ZoneInfoOut>::type& callback);
-    void setSetNetdevAttrsCallback(const Callback<const api::SetNetDevAttrsIn>::type& callback);
-    void setGetNetdevAttrsCallback(const Callback<const api::GetNetDevAttrsIn, api::GetNetDevAttrs>::type& callback);
-    void setGetNetdevListCallback(const Callback<const api::ZoneId, api::NetDevList>::type& callback);
-    void setCreateNetdevVethCallback(const Callback<const api::CreateNetDevVethIn>::type& callback);
-    void setCreateNetdevMacvlanCallback(const Callback<const api::CreateNetDevMacvlanIn>::type& callback);
-    void setCreateNetdevPhysCallback(const Callback<const api::CreateNetDevPhysIn>::type& callback);
-    void setDestroyNetdevCallback(const Callback<const api::DestroyNetDevIn>::type& callback);
-    void setDeleteNetdevIpAddressCallback(const Callback<const api::DeleteNetdevIpAddressIn>::type& callback);
-    void setDeclareFileCallback(const Callback<const api::DeclareFileIn, api::Declaration>::type& callback);
-    void setDeclareMountCallback(const Callback<const api::DeclareMountIn, api::Declaration>::type& callback);
-    void setDeclareLinkCallback(const Callback<const api::DeclareLinkIn, api::Declaration>::type& callback);
-    void setGetDeclarationsCallback(const Callback<const api::ZoneId, api::Declarations>::type& callback);
-    void setRemoveDeclarationCallback(const Callback<const api::RemoveDeclarationIn>::type& callback);
-    void setSetActiveZoneCallback(const Callback<const api::ZoneId>::type& callback);
-    void setCreateZoneCallback(const Callback<const api::CreateZoneIn>::type& callback);
-    void setDestroyZoneCallback(const Callback<const api::ZoneId>::type& callback);
-    void setShutdownZoneCallback(const Callback<const api::ZoneId>::type& callback);
-    void setStartZoneCallback(const Callback<const api::ZoneId>::type& callback);
-    void setLockZoneCallback(const Callback<const api::ZoneId>::type& callback);
-    void setUnlockZoneCallback(const Callback<const api::ZoneId>::type& callback);
-    void setGrantDeviceCallback(const Callback<const api::GrantDeviceIn>::type& callback);
-    void setRevokeDeviceCallback(const Callback<const api::RevokeDeviceIn>::type& callback);
+    void setGetZoneConnectionsCallback(const Method<api::Connections>::type& callback);
+    void setGetZoneIdsCallback(const Method<api::ZoneIds>::type& callback);
+    void setGetActiveZoneIdCallback(const Method<api::ZoneId>::type& callback);
+    void setGetZoneInfoCallback(const Method<const api::ZoneId, api::ZoneInfoOut>::type& callback);
+    void setSetNetdevAttrsCallback(const Method<const api::SetNetDevAttrsIn>::type& callback);
+    void setGetNetdevAttrsCallback(const Method<const api::GetNetDevAttrsIn, api::GetNetDevAttrs>::type& callback);
+    void setGetNetdevListCallback(const Method<const api::ZoneId, api::NetDevList>::type& callback);
+    void setCreateNetdevVethCallback(const Method<const api::CreateNetDevVethIn>::type& callback);
+    void setCreateNetdevMacvlanCallback(const Method<const api::CreateNetDevMacvlanIn>::type& callback);
+    void setCreateNetdevPhysCallback(const Method<const api::CreateNetDevPhysIn>::type& callback);
+    void setDestroyNetdevCallback(const Method<const api::DestroyNetDevIn>::type& callback);
+    void setDeleteNetdevIpAddressCallback(const Method<const api::DeleteNetdevIpAddressIn>::type& callback);
+    void setDeclareFileCallback(const Method<const api::DeclareFileIn, api::Declaration>::type& callback);
+    void setDeclareMountCallback(const Method<const api::DeclareMountIn, api::Declaration>::type& callback);
+    void setDeclareLinkCallback(const Method<const api::DeclareLinkIn, api::Declaration>::type& callback);
+    void setGetDeclarationsCallback(const Method<const api::ZoneId, api::Declarations>::type& callback);
+    void setRemoveDeclarationCallback(const Method<const api::RemoveDeclarationIn>::type& callback);
+    void setSetActiveZoneCallback(const Method<const api::ZoneId>::type& callback);
+    void setCreateZoneCallback(const Method<const api::CreateZoneIn>::type& callback);
+    void setDestroyZoneCallback(const Method<const api::ZoneId>::type& callback);
+    void setShutdownZoneCallback(const Method<const api::ZoneId>::type& callback);
+    void setStartZoneCallback(const Method<const api::ZoneId>::type& callback);
+    void setLockZoneCallback(const Method<const api::ZoneId>::type& callback);
+    void setUnlockZoneCallback(const Method<const api::ZoneId>::type& callback);
+    void setGrantDeviceCallback(const Method<const api::GrantDeviceIn>::type& callback);
+    void setRevokeDeviceCallback(const Method<const api::RevokeDeviceIn>::type& callback);
+    void setNotifyActiveZoneCallback(const Method<const vasum::api::NotifActiveZoneIn>::type& callback);
+    void setSwitchToDefaultCallback(const Signal<const api::Void>::type& callback);
+    void setFileMoveCallback(const Method<const api::FileMoveRequestIn,
+                             api::FileMoveRequestStatus>::type& callback);
     void signalZoneConnectionState(const api::ConnectionState& connectionState);
+    void sendNotification(const api::Notification& notification);
 
 private:
     epoll::ThreadDispatcher mDispatcher;
index b1fca09..8c31339 100644 (file)
@@ -29,9 +29,7 @@
 
 namespace vasum {
 namespace api {
-namespace host {
 
-const vasum::ipc::MethodID METHOD_GET_ZONE_CONNECTIONS     = 1;
 const vasum::ipc::MethodID METHOD_GET_ZONE_ID_LIST         = 2;
 const vasum::ipc::MethodID METHOD_GET_ACTIVE_ZONE_ID       = 3;
 const vasum::ipc::MethodID METHOD_GET_ZONE_INFO            = 4;
@@ -58,9 +56,18 @@ const vasum::ipc::MethodID METHOD_UNLOCK_ZONE              = 24;
 const vasum::ipc::MethodID METHOD_GRANT_DEVICE             = 25;
 const vasum::ipc::MethodID METHOD_REVOKE_DEVICE            = 26;
 
-const vasum::ipc::MethodID SIGNAL_ZONE_CONNECTION_STATE    = 27;
+const vasum::ipc::MethodID METHOD_NOTIFY_ACTIVE_ZONE         = 100;
+const vasum::ipc::MethodID METHOD_FILE_MOVE_REQUEST          = 101;
+const vasum::ipc::MethodID SIGNAL_NOTIFICATION               = 102;
+const vasum::ipc::MethodID SIGNAL_SWITCH_TO_DEFAULT          = 103;
+
+const std::string FILE_MOVE_DESTINATION_NOT_FOUND   = "FILE_MOVE_DESTINATION_NOT_FOUND";
+const std::string FILE_MOVE_WRONG_DESTINATION       = "FILE_MOVE_WRONG_DESTINATION";
+const std::string FILE_MOVE_NO_PERMISSIONS_SEND     = "FILE_MOVE_NO_PERMISSIONS_SEND";
+const std::string FILE_MOVE_NO_PERMISSIONS_RECEIVE  = "FILE_MOVE_NO_PERMISSIONS_RECEIVE";
+const std::string FILE_MOVE_FAILED                  = "FILE_MOVE_FAILED";
+const std::string FILE_MOVE_SUCCEEDED               = "FILE_MOVE_SUCCEEDED";
 
-} // namespace host
 } // namespace api
 } // namespace vasum
 
diff --git a/server/ipc-callback-wrapper.hpp b/server/ipc-callback-wrapper.hpp
new file mode 100644 (file)
index 0000000..04c0544
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Contact: Mateusz Malicki <m.malicki2@samsung.com>
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License
+ */
+
+/**
+ * @file
+ * @author  Mateusz Malicki (m.malicki2@samsung.com)
+ * @brief   IPCSignalWrapper and IPCMethodWrapper classes used to hide IPC specifics
+ */
+
+
+#ifndef SERVER_IPC_CALLBACK_WRAPPER_HPP
+#define SERVER_IPC_CALLBACK_WRAPPER_HPP
+
+#include "api/messages.hpp"
+#include "api/method-result-builder.hpp"
+#include "api/ipc-method-result-builder.hpp"
+
+#include <functional>
+
+namespace vasum {
+
+template<typename ArgIn>
+class IPCSignalWrapper {
+public:
+    typedef typename std::remove_cv<ArgIn>::type in;
+    typedef std::function<void(const in&)> type;
+
+    static typename ipc::SignalHandler<in>::type
+    getWrapper(const type& callback) {
+        return [callback](const ipc::PeerID, const std::shared_ptr<in>& argIn)
+        {
+            callback(*argIn);
+        };
+    }
+};
+
+template<>
+class IPCSignalWrapper<const api::Void> {
+public:
+    typedef api::Void in;
+    typedef std::function<void()> type;
+
+    static typename ipc::SignalHandler<in>::type
+    getWrapper(const type& callback) {
+        return [callback](const ipc::PeerID, const std::shared_ptr<in>& /* argIn */)
+        {
+            callback();
+        };
+    }
+};
+
+template<typename ArgIn = const api::Void, typename ArgOut = api::Void>
+class IPCMethodWrapper {
+public:
+    typedef typename std::remove_cv<ArgIn>::type in;
+    typedef ArgOut out;
+    typedef std::function<void(const in&, api::MethodResultBuilder::Pointer)> type;
+
+    static typename ipc::MethodHandler<out, in>::type
+    getWrapper(const type& callback) {
+        return [callback](const ipc::PeerID,
+                          const std::shared_ptr<in>& argIn,
+                          ipc::MethodResult::Pointer&& argOut)
+        {
+            auto rb = std::make_shared<api::IPCMethodResultBuilder>(argOut);
+            callback(*argIn, rb);
+        };
+    }
+};
+
+template<typename ArgOut>
+class IPCMethodWrapper<ArgOut, typename std::enable_if<!std::is_const<ArgOut>::value, api::Void>::type> {
+public:
+    typedef api::Void in;
+    typedef ArgOut out;
+    typedef std::function<void(api::MethodResultBuilder::Pointer)> type;
+
+    static typename ipc::MethodHandler<out, in>::type
+    getWrapper(const type& callback) {
+        return [callback](const ipc::PeerID,
+                          const std::shared_ptr<in>& /* argIn */,
+                          ipc::MethodResult::Pointer&& argOut)
+        {
+            auto rb = std::make_shared<api::IPCMethodResultBuilder>(argOut);
+            callback(rb);
+        };
+    }
+};
+
+} // namespace vasum
+
+#endif // SERVER_IPC_CALLBACK_WRAPPER_HPP
index 67b5f93..b845ef9 100644 (file)
@@ -60,12 +60,6 @@ struct ZoneConfig {
     bool switchToDefaultAfterTimeout;
 
     /**
-      * Specify, if D-Bus communication with the zone will be enabled.
-      * Setting this value to "false" will make the zone API not work inside the zone.
-      */
-    bool enableZoneConnection;
-
-    /**
      * Zone's CFS quota in us when it's in the foreground
      */
     std::int64_t cpuQuotaForeground;
@@ -106,7 +100,6 @@ struct ZoneConfig {
         initWithArgs,
         privilege, // TODO not needed?
         switchToDefaultAfterTimeout, // TODO move to dynamic and add an API to change
-        enableZoneConnection,
         cpuQuotaForeground,
         cpuQuotaBackground,
         permittedToSend, // TODO move to dynamic and add an API to change
diff --git a/server/zone-connection-transport.cpp b/server/zone-connection-transport.cpp
deleted file mode 100644 (file)
index 0a8f8a0..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- *  Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Piotr Bartosiewicz <p.bartosiewi@partner.samsung.com>
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License
- */
-
-/**
- * @file
- * @author  Piotr Bartosiewicz (p.bartosiewi@partner.samsung.com)
- * @brief   Implementation of a class for communication transport between zone and server
- */
-
-#include "config.hpp"
-
-#include "zone-connection-transport.hpp"
-#include "exception.hpp"
-
-#include "utils/file-wait.hpp"
-#include "utils/fs.hpp"
-#include "logger/logger.hpp"
-
-#include <boost/filesystem.hpp>
-#include <boost/system/system_error.hpp>
-
-namespace vasum {
-
-namespace {
-
-// Timeout in ms for waiting for dbus transport.
-// Should be very long to ensure dbus in zone is ready.
-// TODO: this should be in zone's configuration file
-const unsigned int TRANSPORT_READY_TIMEOUT = 2 * 60 * 1000;
-
-} // namespace
-
-
-ZoneConnectionTransport::ZoneConnectionTransport(const std::string& runMountPoint)
-    : mRunMountPoint(runMountPoint), mDetachOnExit(false)
-{
-    if (runMountPoint.empty()) {
-        return;
-    }
-    boost::system::error_code errorCode;
-    boost::filesystem::create_directories(runMountPoint, errorCode);
-    if (errorCode) {
-        LOGE("Initialization failed: could not create '" << runMountPoint << "' :" << errorCode);
-        throw ZoneConnectionException("Could not create: " + runMountPoint +
-                                           " :" + errorCode.message());
-    }
-
-    bool isMount = false;
-    if (!utils::isMountPoint(runMountPoint, isMount)) {
-        LOGE("Failed to check if " << runMountPoint << " is a mount point.");
-        throw ZoneConnectionException("Could not check if " + runMountPoint +
-                                           " is a mount point.");
-    }
-
-    if (!isMount) {
-        LOGD(runMountPoint << " not mounted - mounting.");
-
-        if (!utils::mountRun(runMountPoint)) {
-            LOGE("Initialization failed: could not mount " << runMountPoint);
-            throw ZoneConnectionException("Could not mount: " + runMountPoint);
-        }
-        LOGI("Mounted: " << runMountPoint);
-    }
-
-    // if there is no systemd in the zone this dir won't be created automatically
-    // TODO: will require chown with USER namespace enabled
-    std::string dbusDirectory = runMountPoint + "/dbus";
-    boost::filesystem::create_directories(dbusDirectory, errorCode);
-    if (errorCode) {
-        LOGE("Initialization failed: could not create '" << dbusDirectory << "' :" << errorCode);
-        throw ZoneConnectionException("Could not create: " + dbusDirectory +
-                                           " :" + errorCode.message());
-    }
-}
-
-
-ZoneConnectionTransport::~ZoneConnectionTransport()
-{
-    if (!mDetachOnExit) {
-        if (!mRunMountPoint.empty()) {
-            if (!utils::umount(mRunMountPoint)) {
-                LOGE("Deinitialization failed: could not umount " << mRunMountPoint);
-            }
-            LOGI("Unmounted: " << mRunMountPoint);
-        }
-    }
-}
-
-
-std::string ZoneConnectionTransport::acquireAddress() const
-{
-    if (mRunMountPoint.empty()) {
-        return std::string();
-    }
-
-    const std::string dbusPath = mRunMountPoint + "/dbus/system_bus_socket";
-
-    // TODO This should be done asynchronously.
-    LOGT("Waiting for " << dbusPath);
-    utils::waitForFile(dbusPath, TRANSPORT_READY_TIMEOUT);
-
-    return "unix:path=" + dbusPath;
-}
-
-void ZoneConnectionTransport::setDetachOnExit()
-{
-    mDetachOnExit = true;
-}
-
-} // namespace vasum
diff --git a/server/zone-connection-transport.hpp b/server/zone-connection-transport.hpp
deleted file mode 100644 (file)
index d651f3c..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- *  Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Piotr Bartosiewicz <p.bartosiewi@partner.samsung.com>
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License
- */
-
-/**
- * @file
- * @author  Piotr Bartosiewicz (p.bartosiewi@partner.samsung.com)
- * @brief   Declaration of a class for communication transport between zone and server
- */
-
-
-#ifndef SERVER_ZONE_CONNECTION_TRANSPORT_HPP
-#define SERVER_ZONE_CONNECTION_TRANSPORT_HPP
-
-#include "dbus/connection.hpp"
-
-
-namespace vasum {
-
-
-/**
- * This class provides a communication transport between zone and server.
- * The object lifecycle should cover lifecycle of a zone.
- */
-class ZoneConnectionTransport {
-public:
-    ZoneConnectionTransport(const std::string& runMountPoint);
-    ~ZoneConnectionTransport();
-
-    /**
-     * Gets dbus addres. Will block until address is available.
-     */
-    std::string acquireAddress() const;
-
-    /**
-     * Set whether object should detach from transport filesystem on exit
-     */
-    void setDetachOnExit();
-
-private:
-    std::string mRunMountPoint;
-    bool mDetachOnExit;
-};
-
-
-} // namespace vasum
-
-
-#endif // SERVER_ZONE_CONNECTION_TRANSPORT_HPP
diff --git a/server/zone-connection.cpp b/server/zone-connection.cpp
deleted file mode 100644 (file)
index 56aa547..0000000
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- *  Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Piotr Bartosiewicz <p.bartosiewi@partner.samsung.com>
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License
- */
-
-/**
- * @file
- * @author  Piotr Bartosiewicz (p.bartosiewi@partner.samsung.com)
- * @brief   Implementation of a class for communication between zone and server
- */
-
-#include "config.hpp"
-
-#include "zone-connection.hpp"
-#include "zone-dbus-definitions.hpp"
-#include "exception.hpp"
-// TODO: Switch to real power-manager dbus defs when they will be implemented in power-manager
-#include "fake-power-manager-dbus-definitions.hpp"
-
-#include "api/dbus-method-result-builder.hpp"
-#include "api/messages.hpp"
-
-#include "logger/logger.hpp"
-
-
-namespace vasum {
-
-namespace {
-
-// Timeout in ms for waiting for dbus name.
-// Can happen if glib loop is busy or not present.
-// TODO: this should be in zone's configuration file
-const unsigned int NAME_ACQUIRED_TIMEOUT = 5 * 1000;
-
-} // namespace
-
-
-ZoneConnection::ZoneConnection(const std::string& address, const OnNameLostCallback& callback)
-    : mNameAcquired(false)
-    , mNameLost(false)
-{
-    if (address.empty()) {
-        LOGE("Invalid zone connection address");
-        throw ZoneConnectionException("Invalid zone connection address");
-    }
-
-    LOGT("Connecting to DBUS on " << address);
-    mDbusConnection = dbus::DbusConnection::create(address);
-
-    LOGT("Setting DBUS name");
-    mDbusConnection->setName(api::zone::BUS_NAME,
-                             std::bind(&ZoneConnection::onNameAcquired, this),
-                             std::bind(&ZoneConnection::onNameLost, this));
-
-    if (!waitForNameAndSetCallback(NAME_ACQUIRED_TIMEOUT, callback)) {
-        LOGE("Could not acquire dbus name: " << api::zone::BUS_NAME);
-        throw ZoneConnectionException("Could not acquire dbus name: " + api::zone::BUS_NAME);
-    }
-
-    LOGT("Registering DBUS interface");
-    using namespace std::placeholders;
-    mDbusConnection->registerObject(api::zone::OBJECT_PATH,
-                                    api::zone::DEFINITION,
-                                    std::bind(&ZoneConnection::onMessageCall,
-                                              this,
-                                              _1,
-                                              _2,
-                                              _3,
-                                              _4,
-                                              _5));
-
-    mDbusConnection->signalSubscribe(std::bind(&ZoneConnection::onSignalReceived,
-                                               this,
-                                               _1,
-                                               _2,
-                                               _3,
-                                               _4,
-                                               _5),
-                                     std::string(fake_power_manager_api::BUS_NAME));
-
-    LOGD("Connected");
-}
-
-ZoneConnection::~ZoneConnection()
-{
-}
-
-bool ZoneConnection::waitForNameAndSetCallback(const unsigned int timeoutMs, const OnNameLostCallback& callback)
-{
-    std::unique_lock<std::mutex> lock(mNameMutex);
-    mNameCondition.wait_for(lock,
-                            std::chrono::milliseconds(timeoutMs),
-                            [this] {
-                                return mNameAcquired || mNameLost;
-                            });
-    if(mNameAcquired) {
-        mOnNameLostCallback = callback;
-    }
-
-    return mNameAcquired;
-}
-
-void ZoneConnection::onNameAcquired()
-{
-    std::unique_lock<std::mutex> lock(mNameMutex);
-    mNameAcquired = true;
-    mNameCondition.notify_one();
-}
-
-void ZoneConnection::onNameLost()
-{
-    std::unique_lock<std::mutex> lock(mNameMutex);
-    mNameLost = true;
-    mNameCondition.notify_one();
-
-    if (mOnNameLostCallback) {
-        mOnNameLostCallback();
-    }
-}
-
-void ZoneConnection::setNotifyActiveZoneCallback(
-    const NotifyActiveZoneCallback& callback)
-{
-    mNotifyActiveZoneCallback = callback;
-}
-
-void ZoneConnection::setSwitchToDefaultCallback(const SwitchToDefaultCallback& callback)
-{
-    mSwitchToDefaultCallback = callback;
-}
-
-void ZoneConnection::setFileMoveCallback(
-    const FileMoveCallback& callback)
-{
-    mFileMoveCallback = callback;
-}
-
-void ZoneConnection::setProxyCallCallback(const ProxyCallCallback& callback)
-{
-    mProxyCallCallback = callback;
-}
-
-void ZoneConnection::onMessageCall(const std::string& objectPath,
-                                        const std::string& interface,
-                                        const std::string& methodName,
-                                        GVariant* parameters,
-                                        dbus::MethodResultBuilder::Pointer result)
-{
-    if (objectPath != api::zone::OBJECT_PATH || interface != api::zone::INTERFACE) {
-        return;
-    }
-
-    if (methodName == api::zone::METHOD_NOTIFY_ACTIVE_ZONE) {
-        const gchar* application = NULL;
-        const gchar* message = NULL;
-        g_variant_get(parameters, "(&s&s)", &application, &message);
-        if (mNotifyActiveZoneCallback) {
-            auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Void>>(result);
-            mNotifyActiveZoneCallback(application, message, rb);
-        }
-    }
-
-    if (methodName == api::zone::METHOD_FILE_MOVE_REQUEST) {
-        const gchar* destination = NULL;
-        const gchar* path = NULL;
-        g_variant_get(parameters, "(&s&s)", &destination, &path);
-        if (mFileMoveCallback) {
-            auto rb = std::make_shared<api::DbusMethodResultBuilder<api::FileMoveRequestStatus>>(result);
-            mFileMoveCallback(destination, path, rb);
-        }
-    }
-
-    if (methodName == api::METHOD_PROXY_CALL) {
-        const gchar* target = NULL;
-        const gchar* targetBusName = NULL;
-        const gchar* targetObjectPath = NULL;
-        const gchar* targetInterface = NULL;
-        const gchar* targetMethod = NULL;
-        GVariant* rawArgs = NULL;
-        g_variant_get(parameters,
-                      "(&s&s&s&s&sv)",
-                      &target,
-                      &targetBusName,
-                      &targetObjectPath,
-                      &targetInterface,
-                      &targetMethod,
-                      &rawArgs);
-        dbus::GVariantPtr args(rawArgs, g_variant_unref);
-
-        if (mProxyCallCallback) {
-            mProxyCallCallback(target,
-                               targetBusName,
-                               targetObjectPath,
-                               targetInterface,
-                               targetMethod,
-                               args.get(),
-                               result);
-        }
-    }
-}
-
-void ZoneConnection::onSignalReceived(const std::string& senderBusName,
-                                           const std::string& objectPath,
-                                           const std::string& interface,
-                                           const std::string& signalName,
-                                           GVariant* /*parameters*/)
-{
-    LOGD("Received signal: " << senderBusName << "; " << objectPath << "; " << interface << "; "
-         << signalName);
-    if (objectPath == fake_power_manager_api::OBJECT_PATH &&
-        interface == fake_power_manager_api::INTERFACE) {
-        //power-manager sent us a signal, check it
-        if (signalName == fake_power_manager_api::SIGNAL_DISPLAY_OFF && mSwitchToDefaultCallback) {
-            mSwitchToDefaultCallback();
-        }
-    }
-}
-
-void ZoneConnection::sendNotification(const std::string& zone,
-                                           const std::string& application,
-                                           const std::string& message)
-{
-    GVariant* parameters = g_variant_new("(sss)",
-                                         zone.c_str(),
-                                         application.c_str(),
-                                         message.c_str());
-    mDbusConnection->emitSignal(api::zone::OBJECT_PATH,
-                                api::zone::INTERFACE,
-                                api::zone::SIGNAL_NOTIFICATION,
-                                parameters);
-}
-
-void ZoneConnection::proxyCallAsync(const std::string& busName,
-                                         const std::string& objectPath,
-                                         const std::string& interface,
-                                         const std::string& method,
-                                         GVariant* parameters,
-                                         const dbus::DbusConnection::AsyncMethodCallCallback& callback)
-{
-    mDbusConnection->callMethodAsync(busName,
-                                     objectPath,
-                                     interface,
-                                     method,
-                                     parameters,
-                                     std::string(),
-                                     callback);
-}
-
-
-} // namespace vasum
diff --git a/server/zone-connection.hpp b/server/zone-connection.hpp
deleted file mode 100644 (file)
index 441f645..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- *  Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Piotr Bartosiewicz <p.bartosiewi@partner.samsung.com>
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License
- */
-
-/**
- * @file
- * @author  Piotr Bartosiewicz (p.bartosiewi@partner.samsung.com)
- * @brief   Declaration of a class for communication between zone and server
- */
-
-
-#ifndef SERVER_ZONE_CONNECTION_HPP
-#define SERVER_ZONE_CONNECTION_HPP
-
-#include "dbus/connection.hpp"
-#include "api/method-result-builder.hpp"
-
-#include <mutex>
-#include <condition_variable>
-
-namespace vasum {
-
-
-class ZoneConnection {
-
-public:
-    typedef std::function<void()> OnNameLostCallback;
-    typedef std::function<void()> SwitchToDefaultCallback;
-
-    ZoneConnection(const std::string& address, const OnNameLostCallback& callback);
-    ~ZoneConnection();
-
-    // ------------- API --------------
-
-    typedef std::function<void(const std::string& application,
-                               const std::string& message,
-                               api::MethodResultBuilder::Pointer result
-                              )> NotifyActiveZoneCallback;
-
-    typedef std::function<void(const std::string& destination,
-                               const std::string& path,
-                               api::MethodResultBuilder::Pointer result
-                              )> FileMoveCallback;
-
-    typedef std::function<void(const std::string& target,
-                               const std::string& targetBusName,
-                               const std::string& targetObjectPath,
-                               const std::string& targetInterface,
-                               const std::string& targetMethod,
-                               GVariant* parameters,
-                               dbus::MethodResultBuilder::Pointer result
-                              )> ProxyCallCallback;
-
-    /**
-     * Register notification request callback
-     */
-    void setNotifyActiveZoneCallback(const NotifyActiveZoneCallback& callback);
-
-    /**
-     * Register switch to default request callback
-     */
-    void setSwitchToDefaultCallback(const SwitchToDefaultCallback& callback);
-
-    /*
-     * Register file move request callback
-     */
-    void setFileMoveCallback(const FileMoveCallback& callback);
-
-    /**
-     * Register proxy call callback
-     */
-    void setProxyCallCallback(const ProxyCallCallback& callback);
-
-    /**
-     * Send notification signal to this zone
-     */
-    void sendNotification(const std::string& zone,
-                          const std::string& application,
-                          const std::string& message);
-
-    /**
-     * Make a proxy call
-     */
-    void proxyCallAsync(const std::string& busName,
-                        const std::string& objectPath,
-                        const std::string& interface,
-                        const std::string& method,
-                        GVariant* parameters,
-                        const dbus::DbusConnection::AsyncMethodCallCallback& callback);
-
-private:
-    dbus::DbusConnection::Pointer mDbusConnection;
-    std::mutex mNameMutex;
-    std::condition_variable mNameCondition;
-    bool mNameAcquired;
-    bool mNameLost;
-    OnNameLostCallback mOnNameLostCallback;
-    NotifyActiveZoneCallback mNotifyActiveZoneCallback;
-    SwitchToDefaultCallback mSwitchToDefaultCallback;
-    FileMoveCallback mFileMoveCallback;
-    ProxyCallCallback mProxyCallCallback;
-
-    void onNameAcquired();
-    void onNameLost();
-    bool waitForNameAndSetCallback(const unsigned int timeoutMs, const OnNameLostCallback& callback);
-
-    void onMessageCall(const std::string& objectPath,
-                       const std::string& interface,
-                       const std::string& methodName,
-                       GVariant* parameters,
-                       dbus::MethodResultBuilder::Pointer result);
-    void onSignalReceived(const std::string& senderBusName,
-                          const std::string& objectPath,
-                          const std::string& interface,
-                          const std::string& signalName,
-                          GVariant* parameters);
-};
-
-
-} // namespace vasum
-
-
-#endif // SERVER_ZONE_CONNECTION_HPP
diff --git a/server/zone-dbus-definitions.hpp b/server/zone-dbus-definitions.hpp
deleted file mode 100644 (file)
index c46e99a..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- *  Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Piotr Bartosiewicz <p.bartosiewi@partner.samsung.com>
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License
- */
-
-/**
- * @file
- * @author  Piotr Bartosiewicz (p.bartosiewi@partner.samsung.com)
- * @brief   Zone dbus api definitions
- */
-
-#ifndef SERVER_ZONE_DBUS_DEFINITIONS_HPP
-#define SERVER_ZONE_DBUS_DEFINITIONS_HPP
-
-#include "common-dbus-definitions.hpp"
-
-
-namespace vasum {
-namespace api {
-namespace zone {
-
-const std::string BUS_NAME                          = "org.tizen.vasum.zone";
-const std::string OBJECT_PATH                       = "/org/tizen/vasum/zone";
-const std::string INTERFACE                         = "org.tizen.vasum.zone.manager";
-
-const std::string METHOD_NOTIFY_ACTIVE_ZONE    = "NotifyActiveZone";
-const std::string METHOD_FILE_MOVE_REQUEST          = "FileMoveRequest";
-const std::string SIGNAL_NOTIFICATION               = "Notification";
-
-const std::string FILE_MOVE_DESTINATION_NOT_FOUND   = "FILE_MOVE_DESTINATION_NOT_FOUND";
-const std::string FILE_MOVE_WRONG_DESTINATION       = "FILE_MOVE_WRONG_DESTINATION";
-const std::string FILE_MOVE_NO_PERMISSIONS_SEND     = "FILE_MOVE_NO_PERMISSIONS_SEND";
-const std::string FILE_MOVE_NO_PERMISSIONS_RECEIVE  = "FILE_MOVE_NO_PERMISSIONS_RECEIVE";
-const std::string FILE_MOVE_FAILED                  = "FILE_MOVE_FAILED";
-const std::string FILE_MOVE_SUCCEEDED               = "FILE_MOVE_SUCCEEDED";
-
-
-const std::string DEFINITION =
-    "<node>"
-    "  <interface name='" + INTERFACE + "'>"
-    "    <method name='" + METHOD_NOTIFY_ACTIVE_ZONE + "'>"
-    "      <arg type='s' name='application' direction='in'/>"
-    "      <arg type='s' name='message' direction='in'/>"
-    "    </method>"
-    "    <method name='" + METHOD_FILE_MOVE_REQUEST + "'>"
-    "      <arg type='s' name='destination' direction='in'/>"
-    "      <arg type='s' name='path' direction='in'/>"
-    "      <arg type='s' name='result' direction='out'/>"
-    "    </method>"
-    "    <method name='" + METHOD_PROXY_CALL + "'>"
-    "      <arg type='s' name='target' direction='in'/>"
-    "      <arg type='s' name='busName' direction='in'/>"
-    "      <arg type='s' name='objectPath' direction='in'/>"
-    "      <arg type='s' name='interface' direction='in'/>"
-    "      <arg type='s' name='method' direction='in'/>"
-    "      <arg type='v' name='parameters' direction='in'/>"
-    "      <arg type='v' name='result' direction='out'/>"
-    "    </method>"
-    "    <signal name='" + SIGNAL_NOTIFICATION + "'>"
-    "      <arg type='s' name='zone'/>"
-    "      <arg type='s' name='application'/>"
-    "      <arg type='s' name='message'/>"
-    "    </signal>"
-    "  </interface>"
-    "</node>";
-
-} // namespace zone
-} // namespace api
-} // namespace vasum
-
-
-#endif // SERVER_ZONE_DBUS_DEFINITIONS_HPP
index 2e47f25..8a1aa0b 100644 (file)
@@ -46,25 +46,19 @@ namespace {
 
 typedef std::lock_guard<std::recursive_mutex> Lock;
 
-// TODO: move constants to the config file when default values are implemented there
-const int RECONNECT_RETRIES = 15;
-const int RECONNECT_DELAY = 1 * 1000;
-
 const std::string STATE_STOPPED = "stopped";
 const std::string STATE_RUNNING = "running";
 const std::string STATE_PAUSED = "paused";
 
 } // namespace
 
-Zone::Zone(const utils::Worker::Pointer& worker,
-           const std::string& zoneId,
+Zone::Zone(const std::string& zoneId,
            const std::string& zonesPath,
            const std::string& zoneTemplatePath,
            const std::string& dbPath,
            const std::string& lxcTemplatePrefix,
            const std::string& baseRunMountPointPath)
-    : mWorker(worker)
-    , mDbPath(dbPath)
+    : mDbPath(dbPath)
 {
     const std::string dbPrefix = getZoneDbPrefix(zoneId);
     config::loadFromKVStoreWithJsonFile(dbPath, zoneTemplatePath, mConfig, dbPrefix);
@@ -89,19 +83,6 @@ Zone::Zone(const utils::Worker::Pointer& worker,
     mProvision.reset(new ZoneProvision(mRootPath, zoneTemplatePath, dbPath, dbPrefix, mConfig.validLinkPrefixes));
 }
 
-Zone::~Zone()
-{
-    // Make sure all OnNameLostCallbacks get finished and no new will
-    // get called before proceeding further. This guarantees no race
-    // condition on the reconnect thread.
-    {
-        Lock lock(mReconnectMutex);
-        disconnect();
-    }
-    // wait for all tasks to complete
-    mWorker.reset();
-}
-
 const std::vector<boost::regex>& Zone::getPermittedToSend() const
 {
     return mPermittedToSend;
@@ -164,16 +145,9 @@ void Zone::start()
     Lock lock(mReconnectMutex);
     updateRequestedState(STATE_RUNNING);
     mProvision->start();
-    if (mConfig.enableZoneConnection) {
-        mConnectionTransport.reset(new ZoneConnectionTransport(mRunMountPoint));
-    }
-
     mAdmin->start();
-    if (mConfig.enableZoneConnection) {
-        // Increase cpu quota before connect, otherwise it'd take ages.
-        goForeground();
-        connect();
-    }
+    // Increase cpu quota before connect, otherwise it'd take ages.
+    goForeground();
     // refocus in ZonesManager will adjust cpu quota after all
 }
 
@@ -187,54 +161,10 @@ void Zone::stop(bool saveState)
         // boost stopping
         goForeground();
     }
-    disconnect();
     mAdmin->stop();
-    mConnectionTransport.reset();
     mProvision->stop();
 }
 
-void Zone::connect()
-{
-    // assume called under reconnect lock
-    mConnectionAddress = mConnectionTransport->acquireAddress();
-    mConnection.reset(new ZoneConnection(mConnectionAddress,
-                                         std::bind(&Zone::onNameLostCallback, this)));
-    if (mNotifyCallback) {
-        mConnection->setNotifyActiveZoneCallback(mNotifyCallback);
-    }
-    if (mSwitchToDefaultCallback) {
-        mConnection->setSwitchToDefaultCallback(mSwitchToDefaultCallback);
-    }
-    if (mFileMoveCallback) {
-        mConnection->setFileMoveCallback(mFileMoveCallback);
-    }
-    if (mProxyCallCallback) {
-        mConnection->setProxyCallCallback(mProxyCallCallback);
-    }
-    if (mConnectionStateChangedCallback) {
-        mConnectionStateChangedCallback(mConnectionAddress);
-    }
-}
-
-void Zone::disconnect()
-{
-    // assume called under reconnect lock
-    if (mConnection) {
-        mConnection.reset();
-        mConnectionAddress.clear();
-        if (mConnectionStateChangedCallback) {
-            // notify about invalid address for this zone
-            mConnectionStateChangedCallback(std::string());
-        }
-    }
-}
-
-std::string Zone::getConnectionAddress() const
-{
-    Lock lock(mReconnectMutex);
-    return mConnectionAddress;
-}
-
 int Zone::getVT() const
 {
     Lock lock(mReconnectMutex);
@@ -300,9 +230,6 @@ void Zone::setDetachOnExit()
 {
     Lock lock(mReconnectMutex);
     mAdmin->setDetachOnExit();
-    if (mConnectionTransport) {
-        mConnectionTransport->setDetachOnExit();
-    }
 }
 
 void Zone::setDestroyOnExit()
@@ -348,120 +275,6 @@ bool Zone::isSwitchToDefaultAfterTimeoutAllowed() const
     return mConfig.switchToDefaultAfterTimeout;
 }
 
-void Zone::onNameLostCallback()
-{
-    LOGI(getId() << ": A connection to the DBUS server has been lost, reconnecting...");
-
-    mWorker->addTask(std::bind(&Zone::reconnectHandler, this));
-}
-
-void Zone::reconnectHandler()
-{
-    {
-        Lock lock(mReconnectMutex);
-        disconnect();
-    }
-
-    for (int i = 0; i < RECONNECT_RETRIES; ++i) {
-        // This sleeps even before the first try to give DBUS some time to come back up
-        std::this_thread::sleep_for(std::chrono::milliseconds(RECONNECT_DELAY));
-
-        Lock lock(mReconnectMutex);
-        if (isStopped()) {
-            LOGI(getId() << ": Has stopped, nothing to reconnect to, bailing out");
-            return;
-        }
-
-        try {
-            LOGT(getId() << ": Reconnect try " << i + 1);
-            connect();
-            LOGI(getId() << ": Reconnected");
-            return;
-        } catch (VasumException&) {
-            LOGT(getId() << ": Reconnect try " << i + 1 << " has been unsuccessful");
-        }
-    }
-
-    LOGE(getId() << ": Reconnecting to the DBUS has failed, stopping the zone");
-    stop(false);
-}
-
-void Zone::setNotifyActiveZoneCallback(const NotifyActiveZoneCallback& callback)
-{
-    Lock lock(mReconnectMutex);
-    mNotifyCallback = callback;
-    if (mConnection) {
-        mConnection->setNotifyActiveZoneCallback(mNotifyCallback);
-    }
-}
-
-void Zone::sendNotification(const std::string& zone,
-                                 const std::string& application,
-                                 const std::string& message)
-{
-    Lock lock(mReconnectMutex);
-    if (mConnection) {
-        mConnection->sendNotification(zone, application, message);
-    } else {
-        LOGE(getId() << ": Can't send notification, no connection to DBUS");
-    }
-}
-
-void Zone::setSwitchToDefaultCallback(const SwitchToDefaultCallback& callback)
-{
-    Lock lock(mReconnectMutex);
-
-    mSwitchToDefaultCallback = callback;
-    if (mConnection) {
-        mConnection->setSwitchToDefaultCallback(callback);
-    }
-}
-
-void Zone::setFileMoveCallback(const FileMoveCallback& callback)
-{
-    Lock lock(mReconnectMutex);
-
-    mFileMoveCallback = callback;
-    if (mConnection) {
-        mConnection->setFileMoveCallback(callback);
-    }
-}
-
-void Zone::setProxyCallCallback(const ProxyCallCallback& callback)
-{
-    Lock lock(mReconnectMutex);
-
-    mProxyCallCallback = callback;
-    if (mConnection) {
-        mConnection->setProxyCallCallback(callback);
-    }
-}
-
-void Zone::setConnectionStateChangedCallback(const ConnectionStateChangedCallback& callback)
-{
-    mConnectionStateChangedCallback = callback;
-}
-
-void Zone::proxyCallAsync(const std::string& busName,
-                               const std::string& objectPath,
-                               const std::string& interface,
-                               const std::string& method,
-                               GVariant* parameters,
-                               const dbus::DbusConnection::AsyncMethodCallCallback& callback)
-{
-    Lock lock(mReconnectMutex);
-    if (mConnection) {
-        mConnection->proxyCallAsync(busName,
-                                    objectPath,
-                                    interface,
-                                    method,
-                                    parameters,
-                                    callback);
-    } else {
-        LOGE(getId() << ": Can't do a proxy call, no connection to DBUS");
-    }
-}
-
 std::string Zone::declareFile(const int32_t& type,
                               const std::string& path,
                               const int32_t& flags,
index f24a6e6..6d13d85 100644 (file)
 
 #include "zone-config.hpp"
 #include "zone-admin.hpp"
-#include "zone-connection.hpp"
-#include "zone-connection-transport.hpp"
 #include "zone-provision.hpp"
-#include "utils/worker.hpp"
 
+#include <mutex>
 #include <string>
 #include <memory>
 #include <thread>
@@ -54,8 +52,7 @@ public:
      * @param lxcTemplatePrefix directory where templates are stored
      * @param baseRunMountPointPath base directory for run mount point
      */
-    Zone(const utils::Worker::Pointer& worker,
-         const std::string& zoneId,
+    Zone(const std::string& zoneId,
          const std::string& zonesPath,
          const std::string& zoneTemplatePath,
          const std::string& dbPath,
@@ -63,14 +60,7 @@ public:
          const std::string& baseRunMountPointPath);
     Zone(const Zone&) = delete;
     Zone& operator=(const Zone&) = delete;
-    ~Zone();
 
-    typedef ZoneConnection::NotifyActiveZoneCallback NotifyActiveZoneCallback;
-    typedef ZoneConnection::SwitchToDefaultCallback SwitchToDefaultCallback;
-    typedef ZoneConnection::FileMoveCallback FileMoveCallback;
-    typedef ZoneConnection::ProxyCallCallback ProxyCallCallback;
-
-    typedef std::function<void(const std::string& address)> ConnectionStateChangedCallback;
     typedef std::function<void(bool succeeded)> StartAsyncResultCallback;
 
     /**
@@ -135,8 +125,7 @@ public:
     /**
      * Set if zone should be detached on exit.
      *
-     * This sends detach flag to ZoneAdmin object and disables unmounting tmpfs
-     * in ZoneConnectionTransport.
+     * This sends detach flag to ZoneAdmin object.
      */
     void setDetachOnExit();
 
@@ -174,65 +163,12 @@ public:
      */
     bool isPaused();
 
-    // ZoneConnection API
-
     /**
      * @return Is switching to default zone after timeout allowed?
      */
     bool isSwitchToDefaultAfterTimeoutAllowed() const;
 
     /**
-     * Register notification request callback
-     */
-    void setNotifyActiveZoneCallback(const NotifyActiveZoneCallback& callback);
-
-    /**
-     * Register callback used when switching to default zone.
-     */
-    void setSwitchToDefaultCallback(const SwitchToDefaultCallback& callback);
-
-    /**
-     * Register proxy call callback
-     */
-    void setProxyCallCallback(const ProxyCallCallback& callback);
-
-    /**
-     * Send notification signal to this zone
-     *
-     * @param zone   name of zone in which the notification occurred
-     * @param application name of application that cause notification
-     * @param message     message to be send to zone
-     */
-    void sendNotification(const std::string& zone,
-                          const std::string& application,
-                          const std::string& message);
-
-    /**
-     * Register file move request callback
-     */
-    void setFileMoveCallback(const FileMoveCallback& callback);
-
-    /**
-     * Register dbus state changed callback
-     */
-    void setConnectionStateChangedCallback(const ConnectionStateChangedCallback& callback);
-
-    /**
-     * Make a proxy call
-     */
-    void proxyCallAsync(const std::string& busName,
-                        const std::string& objectPath,
-                        const std::string& interface,
-                        const std::string& method,
-                        GVariant* parameters,
-                        const dbus::DbusConnection::AsyncMethodCallCallback& callback);
-
-    /**
-     * Get a dbus address
-     */
-    std::string getConnectionAddress() const;
-
-    /**
      * Get id of VT
      */
     int getVT() const;
@@ -317,30 +253,18 @@ public:
     void deleteNetdevIpAddress(const std::string& netdev, const std::string& ip);
 
 private:
-    utils::Worker::Pointer mWorker;
     ZoneConfig mConfig;
     ZoneDynamicConfig mDynamicConfig;
     std::vector<boost::regex> mPermittedToSend;
     std::vector<boost::regex> mPermittedToRecv;
-    std::unique_ptr<ZoneConnectionTransport> mConnectionTransport;
     std::unique_ptr<ZoneAdmin> mAdmin;
-    std::unique_ptr<ZoneConnection> mConnection;
     std::unique_ptr<ZoneProvision> mProvision;
     mutable std::recursive_mutex mReconnectMutex;
-    NotifyActiveZoneCallback mNotifyCallback;
-    SwitchToDefaultCallback mSwitchToDefaultCallback;
-    FileMoveCallback mFileMoveCallback;
-    ProxyCallCallback mProxyCallCallback;
-    ConnectionStateChangedCallback mConnectionStateChangedCallback;
-    std::string mConnectionAddress;
     std::string mRunMountPoint;
     std::string mRootPath;
     std::string mDbPath;
 
     void onNameLostCallback();
-    void reconnectHandler();
-    void connect();
-    void disconnect();
     void saveDynamicConfig();
     void updateRequestedState(const std::string& state);
 };
index 1b6edf3..e6621d8 100644 (file)
 
 #include "config.hpp"
 
+#ifdef DBUS_CONNECTION
 #include "host-dbus-definitions.hpp"
-#include "common-dbus-definitions.hpp"
-#include "zone-dbus-definitions.hpp"
+#else
+#include "host-ipc-definitions.hpp"
+#endif
+#include "common-definitions.hpp"
 #include "dynamic-config-scheme.hpp"
 #include "zones-manager.hpp"
 #include "zone-admin.hpp"
@@ -55,6 +58,7 @@ namespace vasum {
 
 namespace {
 
+#ifdef ZONE_CONNECTION
 bool regexMatchVector(const std::string& str, const std::vector<boost::regex>& v)
 {
     for (const boost::regex& toMatch : v) {
@@ -65,6 +69,7 @@ bool regexMatchVector(const std::string& str, const std::vector<boost::regex>& v
 
     return false;
 }
+#endif
 
 const std::string HOST_ID = "host";
 const std::string ENABLED_FILE_NAME = "enabled";
@@ -124,17 +129,14 @@ ZonesManager::ZonesManager(const std::string& configPath)
                                         mDynamicConfig,
                                         getVasumDbPrefix());
 
-    mProxyCallPolicy.reset(new ProxyCallPolicy(mConfig.proxyCallRules));
 
     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
 
-    mHostConnection.setGetZoneConnectionsCallback(bind(&ZonesManager::handleGetZoneConnectionsCall,
-                                                       this, _1));
-
     mHostConnection.setGetZoneIdsCallback(bind(&ZonesManager::handleGetZoneIdsCall,
                                                this, _1));
 
@@ -210,6 +212,15 @@ ZonesManager::ZonesManager(const std::string& configPath)
     mHostConnection.setRevokeDeviceCallback(bind(&ZonesManager::handleRevokeDeviceCall,
                                                  this, _1, _2));
 
+    mHostConnection.setNotifyActiveZoneCallback(bind(&ZonesManager::handleNotifyActiveZoneCall,
+                                           this, "", _1, _2));
+
+    mHostConnection.setSwitchToDefaultCallback(bind(&ZonesManager::handleSwitchToDefaultCall,
+                                          this, ""));
+
+    mHostConnection.setFileMoveCallback(bind(&ZonesManager::handleFileMoveCall,
+                                        this, "", _1, _2));
+
     for (const auto& zoneId : mDynamicConfig.zoneIds) {
         insertZone(zoneId, getTemplatePathForExistingZone(zoneId));
     }
@@ -307,30 +318,13 @@ void ZonesManager::insertZone(const std::string& zoneId, const std::string& zone
     }
 
     LOGT("Creating Zone " << zoneId);
-    std::unique_ptr<Zone> zone(new Zone(mWorker->createSubWorker(),
-                                        zoneId,
+    std::unique_ptr<Zone> zone(new Zone(zoneId,
                                         mConfig.zonesPath,
                                         zoneTemplatePath,
                                         mConfig.dbPath,
                                         mConfig.lxcTemplatePrefix,
                                         mConfig.runMountPointPrefix));
 
-    using namespace std::placeholders;
-    zone->setNotifyActiveZoneCallback(bind(&ZonesManager::handleNotifyActiveZoneCall,
-                                           this, zoneId, _1, _2, _3));
-
-    zone->setSwitchToDefaultCallback(bind(&ZonesManager::handleSwitchToDefaultCall,
-                                     this, zoneId));
-
-    zone->setFileMoveCallback(bind(&ZonesManager::handleFileMoveCall,
-                                          this, zoneId, _1, _2, _3));
-
-    zone->setProxyCallCallback(bind(&ZonesManager::handleProxyCall,
-                                    this, zoneId, _1, _2, _3, _4, _5, _6, _7));
-
-    zone->setConnectionStateChangedCallback(bind(&ZonesManager::handleConnectionStateChanged,
-                                                 this, zoneId, _1));
-
     mZones.push_back(std::move(zone));
 
     // after zone is created successfully, put a file informing that zones are enabled
@@ -556,28 +550,6 @@ void ZonesManager::setZonesDetachOnExit()
     }
 }
 
-void ZonesManager::handleNotifyActiveZoneCall(const std::string& caller,
-                                          const std::string& application,
-                                          const std::string& message,
-                                          api::MethodResultBuilder::Pointer result)
-{
-    LOGI("handleNotifyActiveZoneCall(" << caller << ", " << application << ", " << message
-         << ") called");
-
-    Lock lock(mMutex);
-
-    try {
-        auto iter = getRunningForegroundZoneIterator();
-        if (iter != mZones.end() && caller != get(iter).getId()) {
-            get(iter).sendNotification(caller, application, message);
-        }
-        result->setVoid();
-    } catch (const VasumException&) {
-        LOGE("Notification from " << caller << " hasn't been sent");
-        result->setError(api::ERROR_INTERNAL, "Notification hasn't been sent");
-    }
-}
-
 void ZonesManager::handleSwitchToDefaultCall(const std::string& /*caller*/)
 {
     // get config of currently set zone and switch if switchToDefaultAfterTimeout is true
@@ -596,10 +568,33 @@ void ZonesManager::handleSwitchToDefaultCall(const std::string& /*caller*/)
     }
 }
 
+#ifdef ZONE_CONNECTION
+void ZonesManager::handleNotifyActiveZoneCall(const std::string& caller,
+                                              const api::NotifActiveZoneIn& notif,
+                                              api::MethodResultBuilder::Pointer result)
+{
+    const std::string& application = notif.first;
+    const std::string& message = notif.second;
+    LOGI("handleNotifyActiveZoneCall(" << caller << ", " << application << ", " << message
+         << ") called");
+
+    Lock lock(mMutex);
+
+    try {
+        auto iter = getRunningForegroundZoneIterator();
+        if (iter != mZones.end() && caller != get(iter).getId()) {
+            //XXX:get(iter).sendNotification(caller, application, message);
+        }
+        result->setVoid();
+    } catch (const VasumException&) {
+        LOGE("Notification from " << caller << " hasn't been sent");
+        result->setError(api::ERROR_INTERNAL, "Notification hasn't been sent");
+    }
+}
+
 void ZonesManager::handleFileMoveCall(const std::string& srcZoneId,
-                                         const std::string& dstZoneId,
-                                         const std::string& path,
-                                         api::MethodResultBuilder::Pointer result)
+                                      const api::FileMoveRequestIn& request,
+                                      api::MethodResultBuilder::Pointer result)
 {
     // TODO: this implementation is only a placeholder.
     // There are too many unanswered questions and security concerns:
@@ -620,6 +615,8 @@ void ZonesManager::handleFileMoveCall(const std::string& srcZoneId,
     // Now when the main process has obtained FDs (by either of those methods)
     // it can do the copying by itself.
 
+    const std::string& dstZoneId = request.first;
+    const std::string& path = request.second;
     LOGI("File move requested\n"
          << "src: " << srcZoneId << "\n"
          << "dst: " << dstZoneId << "\n"
@@ -639,7 +636,7 @@ void ZonesManager::handleFileMoveCall(const std::string& srcZoneId,
     auto dstIter = findZone(dstZoneId);
     if (dstIter == mZones.end()) {
         LOGE("Destination zone '" << dstZoneId << "' not found");
-        status->value = api::zone::FILE_MOVE_DESTINATION_NOT_FOUND;
+        status->value = api::FILE_MOVE_DESTINATION_NOT_FOUND;
         result->set(status);
         return;
     }
@@ -647,21 +644,21 @@ void ZonesManager::handleFileMoveCall(const std::string& srcZoneId,
 
     if (srcZoneId == dstZoneId) {
         LOGE("Cannot send a file to yourself");
-        status->value = api::zone::FILE_MOVE_WRONG_DESTINATION;
+        status->value = api::FILE_MOVE_WRONG_DESTINATION;
         result->set(status);
         return;
     }
 
     if (!regexMatchVector(path, srcZone.getPermittedToSend())) {
         LOGE("Source zone has no permissions to send the file: " << path);
-        status->value = api::zone::FILE_MOVE_NO_PERMISSIONS_SEND;
+        status->value = api::FILE_MOVE_NO_PERMISSIONS_SEND;
         result->set(status);
         return;
     }
 
     if (!regexMatchVector(path, dstContanier.getPermittedToRecv())) {
         LOGE("Destination zone has no permissions to receive the file: " << path);
-        status->value = api::zone::FILE_MOVE_NO_PERMISSIONS_RECEIVE;
+        status->value = api::FILE_MOVE_NO_PERMISSIONS_RECEIVE;
         result->set(status);
         return;
     }
@@ -672,19 +669,36 @@ void ZonesManager::handleFileMoveCall(const std::string& srcZoneId,
 
     if (!utils::moveFile(srcPath, dstPath)) {
         LOGE("Failed to move the file: " << path);
-        status->value = api::zone::FILE_MOVE_FAILED;
+        status->value = api::FILE_MOVE_FAILED;
         result->set(status);
     } else {
-        status->value = api::zone::FILE_MOVE_SUCCEEDED;
+        status->value = api::FILE_MOVE_SUCCEEDED;
         result->set(status);
         try {
-            dstContanier.sendNotification(srcZoneId, path, api::zone::FILE_MOVE_SUCCEEDED);
+            //XXX: dstContanier.sendNotification(srcZoneId, path, api::FILE_MOVE_SUCCEEDED);
         } catch (ServerException&) {
             LOGE("Notification to '" << dstZoneId << "' has not been sent");
         }
     }
 }
+#else
+void ZonesManager::handleNotifyActiveZoneCall(const std::string& /* caller */,
+                                              const api::NotifActiveZoneIn& /*notif*/,
+                                              api::MethodResultBuilder::Pointer result)
+{
+    result->setError(api::ERROR_INTERNAL, "Not implemented");
+}
+
+void ZonesManager::handleFileMoveCall(const std::string& /*srcZoneId*/,
+                                      const api::FileMoveRequestIn& /*request*/,
+                                      api::MethodResultBuilder::Pointer result)
+{
+    result->setError(api::ERROR_INTERNAL, "Not implemented");
+}
 
+#endif /* ZONE_CONNECTION */
+
+#ifdef DBUS_CONNECTION
 void ZonesManager::handleProxyCall(const std::string& caller,
                                    const std::string& target,
                                    const std::string& targetBusName,
@@ -718,54 +732,19 @@ void ZonesManager::handleProxyCall(const std::string& caller,
         }
     };
 
-    if (target == HOST_ID) {
-#ifdef DBUS_CONNECTION
-        mHostConnection.proxyCallAsync(targetBusName,
-                                       targetObjectPath,
-                                       targetInterface,
-                                       targetMethod,
-                                       parameters,
-                                       asyncResultCallback);
-#else
-        result->setError(api::ERROR_INVALID_ID, "Unsupported proxy call target");
-#endif
-        return;
-    }
-
-    Lock lock(mMutex);
-
-    auto targetIter = findZone(target);
-    if (targetIter == mZones.end()) {
-        LOGE("Target zone '" << target << "' not found");
+    if (target != HOST_ID) {
         result->setError(api::ERROR_INVALID_ID, "Unknown proxy call target");
         return;
     }
 
-    Zone& targetZone = get(targetIter);
-    targetZone.proxyCallAsync(targetBusName,
-                              targetObjectPath,
-                              targetInterface,
-                              targetMethod,
-                              parameters,
-                              asyncResultCallback);
-}
-
-void ZonesManager::handleGetZoneConnectionsCall(api::MethodResultBuilder::Pointer result)
-{
-    Lock lock(mMutex);
-
-    auto connections = std::make_shared<api::Connections>();
-    for (auto& zone : mZones) {
-        connections->values.push_back({zone->getId(), zone->getConnectionAddress()});
-    }
-    result->set(connections);
-}
-
-void ZonesManager::handleConnectionStateChanged(const std::string& zoneId ,
-                                                const std::string& address)
-{
-    mHostConnection.signalZoneConnectionState({zoneId, address});
+    mHostConnection.proxyCallAsync(targetBusName,
+                                   targetObjectPath,
+                                   targetInterface,
+                                   targetMethod,
+                                   parameters,
+                                   asyncResultCallback);
 }
+#endif
 
 void ZonesManager::handleGetZoneIdsCall(api::MethodResultBuilder::Pointer result)
 {
@@ -1081,7 +1060,7 @@ void ZonesManager::handleSetActiveZoneCall(const api::ZoneId& zoneId,
 
     if (!get(iter).isRunning()) {
         LOGE("Could not activate stopped or paused zone");
-        result->setError(api::host::ERROR_ZONE_NOT_RUNNING,
+        result->setError(api::ERROR_ZONE_NOT_RUNNING,
                          "Could not activate stopped or paused zone");
         return;
     }
index 31c90cd..42477ae 100644 (file)
 #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 "proxy-call-policy.hpp"
 #include "utils/worker.hpp"
 #include "api/method-result-builder.hpp"
 
@@ -131,7 +131,6 @@ private:
     HostConnection mHostConnection;
     // to hold InputMonitor pointer to monitor if zone switching sequence is recognized
     std::unique_ptr<InputMonitor> mSwitchingSequenceMonitor;
-    std::unique_ptr<ProxyCallPolicy> mProxyCallPolicy;
     // like set but keep insertion order
     // smart pointer is needed because Zone is not moveable (because of mutex)
     typedef std::vector<std::unique_ptr<Zone>> Zones;
@@ -157,14 +156,14 @@ private:
 
     // Zone's handlers---------------------------------------------------------
     void handleNotifyActiveZoneCall(const std::string& caller,
-                                    const std::string& appliaction,
-                                    const std::string& message,
+                                    const api::NotifActiveZoneIn& notif,
                                     api::MethodResultBuilder::Pointer result);
     void handleSwitchToDefaultCall(const std::string& caller);
     void handleFileMoveCall(const std::string& srcZoneId,
-                            const std::string& dstZoneId,
-                            const std::string& path,
+                            const api::FileMoveRequestIn& request,
                             api::MethodResultBuilder::Pointer result);
+#ifdef DBUS_CONNECTION
+    std::unique_ptr<ProxyCallPolicy> mProxyCallPolicy;
     void handleProxyCall(const std::string& caller,
                          const std::string& target,
                          const std::string& targetBusName,
@@ -173,10 +172,8 @@ private:
                          const std::string& targetMethod,
                          GVariant* parameters,
                          dbus::MethodResultBuilder::Pointer result);
-    void handleGetZoneConnectionsCall(api::MethodResultBuilder::Pointer result);
-    void handleConnectionStateChanged(const std::string& zoneId,
-                                      const std::string& address);
-    // Host's handlers --------------------------------------------------------
+#endif
+    // Handlers --------------------------------------------------------
     void handleGetZoneIdsCall(api::MethodResultBuilder::Pointer result);
     void handleGetActiveZoneIdCall(api::MethodResultBuilder::Pointer result);
     void handleGetZoneInfoCall(const api::ZoneId& data,
index 5587d11..64618ed 100644 (file)
@@ -26,6 +26,8 @@ FILE(GLOB client_manager_CONF_GEN ${CMAKE_BINARY_DIR}/ut-client/*.conf)
 
 CONFIGURE_FILE(ut-client/templates/console-dbus.conf.in
                ${CMAKE_BINARY_DIR}/ut-client/templates/console-dbus.conf @ONLY)
+CONFIGURE_FILE(ut-client/templates/console-ipc.conf.in
+               ${CMAKE_BINARY_DIR}/ut-client/templates/console-ipc.conf @ONLY)
 FILE(GLOB client_templates_CONF_GEN ${CMAKE_BINARY_DIR}/ut-client/templates/*.conf)
 
 ## Install #####################################################################
index 3481c09..2ff5998 100644 (file)
@@ -7,7 +7,6 @@
     "privilege" : 20,
     "vt" : -1,
     "switchToDefaultAfterTimeout" : true,
-    "enableZoneConnection" : true,
     "cpuQuotaForeground" : -1,
     "cpuQuotaBackground" : 1000,
     "shutdownTimeout" : 10,
diff --git a/tests/unit_tests/client/configs/ut-client/templates/console-ipc.conf.in b/tests/unit_tests/client/configs/ut-client/templates/console-ipc.conf.in
new file mode 100644 (file)
index 0000000..b7b103a
--- /dev/null
@@ -0,0 +1,18 @@
+{
+    "lxcTemplate" : "minimal-dbus.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 d53238f..f0e6b2e 100644 (file)
@@ -23,6 +23,8 @@
  * @brief   Unit tests of the client C API
  */
 
+#ifndef DBUS_CONNECTION
+
 #include <config.hpp>
 #include "ut.hpp"
 #include <vasum-client.h>
@@ -30,7 +32,7 @@
 #include "utils/latch.hpp"
 #include "utils/scoped-dir.hpp"
 #include "zones-manager.hpp"
-#include "zone-dbus-definitions.hpp"
+#include "host-ipc-definitions.hpp"
 #include "logger/logger.hpp"
 
 #include <map>
@@ -49,35 +51,23 @@ namespace {
 const std::string TEST_CONFIG_PATH =
     VSM_TEST_CONFIG_INSTALL_DIR "/client/ut-client/test-daemon.conf";
 const std::string ZONES_PATH = "/tmp/ut-zones"; // the same as in daemon.conf
-const std::string TEMPLATE_NAME = "console-dbus";
-
-struct Loop {
-    Loop()
-    {
-        vsm_start_glib_loop();
-    }
-    ~Loop()
-    {
-        vsm_stop_glib_loop();
-    }
-};
+const std::string TEMPLATE_NAME = "console-ipc";
 
 struct Fixture {
-    Loop loop;
     utils::ScopedDir mZonesPathGuard;
     utils::ScopedDir mRunGuard;
 
-    ZonesManager cm;
+    std::unique_ptr<ZonesManager> cm;
 
     Fixture()
         : mZonesPathGuard(ZONES_PATH)
         , mRunGuard("/tmp/ut-run")
-        , cm(TEST_CONFIG_PATH)
+        , cm(new ZonesManager(TEST_CONFIG_PATH))
     {
-        cm.createZone("zone1", TEMPLATE_NAME);
-        cm.createZone("zone2", TEMPLATE_NAME);
-        cm.createZone("zone3", TEMPLATE_NAME);
-        cm.restoreAll();
+        cm->createZone("zone1", TEMPLATE_NAME);
+        cm->createZone("zone2", TEMPLATE_NAME);
+        cm->createZone("zone3", TEMPLATE_NAME);
+        cm->restoreAll();
         LOGI("------- setup complete --------");
     }
 
@@ -87,32 +77,7 @@ struct Fixture {
     }
 };
 
-const int EVENT_TIMEOUT = 5000; ///< ms
-const std::map<std::string, std::string> EXPECTED_CONNECTIONS = {
-    {
-        "zone1",
-        "unix:path=/tmp/ut-run/zone1/dbus/system_bus_socket"
-    },
-    {
-        "zone2",
-        "unix:path=/tmp/ut-run/zone2/dbus/system_bus_socket"
-    },
-    {
-        "zone3",
-        "unix:path=/tmp/ut-run/zone3/dbus/system_bus_socket"
-    }
-};
-
-void convertDictToMap(VsmArrayString keys,
-                      VsmArrayString values,
-                      std::map<std::string, std::string>& ret)
-{
-    VsmArrayString iKeys;
-    VsmArrayString iValues;
-    for (iKeys = keys, iValues = values; *iKeys && *iValues; iKeys++, iValues++) {
-        ret.insert(std::make_pair(*iKeys, *iValues));
-    }
-}
+const std::set<std::string> EXPECTED_ZONES = { "zone1", "zone2", "zone3" };
 
 void convertArrayToSet(VsmArrayString values, std::set<std::string>& ret)
 {
@@ -153,35 +118,11 @@ BOOST_FIXTURE_TEST_SUITE(ClientSuite, Fixture)
 
 BOOST_AUTO_TEST_CASE(NotRunningServer)
 {
-    cm.shutdownAll();
-
-    VsmClient client = vsm_client_create();
-    VsmStatus status = vsm_connect_custom(client,
-                                          EXPECTED_CONNECTIONS.begin()->second.c_str());
-    BOOST_CHECK_EQUAL(VSMCLIENT_IO_ERROR, status);
-    vsm_client_free(client);
-}
+    cm.reset();
 
-BOOST_AUTO_TEST_CASE(GetZoneConnections)
-{
     VsmClient client = vsm_client_create();
     VsmStatus status = vsm_connect(client);
-    BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, status);
-    VsmArrayString keys, values;
-    status = vsm_get_zone_dbuses(client, &keys, &values);
-    //TODO: Clean up if BOOST_REQUIRE_EQUAL fail (remove client). Same in other client tests.
-    BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, status);
-
-    BOOST_CHECK_EQUAL(getArrayStringLength(keys, EXPECTED_CONNECTIONS.size() + 1u),
-                      EXPECTED_CONNECTIONS.size());
-    BOOST_CHECK_EQUAL(getArrayStringLength(values, EXPECTED_CONNECTIONS.size() + 1u),
-                      EXPECTED_CONNECTIONS.size());
-
-    std::map<std::string, std::string> zones;
-    convertDictToMap(keys, values, zones);
-    BOOST_CHECK(zones == EXPECTED_CONNECTIONS);
-    vsm_array_string_free(keys);
-    vsm_array_string_free(values);
+    BOOST_CHECK_EQUAL(VSMCLIENT_IO_ERROR, status);
     vsm_client_free(client);
 }
 
@@ -193,14 +134,14 @@ BOOST_AUTO_TEST_CASE(GetZoneIds)
     VsmArrayString values;
     status = vsm_get_zone_ids(client, &values);
     BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, status);
-    BOOST_CHECK_EQUAL(getArrayStringLength(values, EXPECTED_CONNECTIONS.size() + 1u),
-                      EXPECTED_CONNECTIONS.size());
+    BOOST_CHECK_EQUAL(getArrayStringLength(values, EXPECTED_ZONES.size() + 1u),
+                      EXPECTED_ZONES.size());
 
     std::set<std::string> zones;
     convertArrayToSet(values, zones);
 
     for (const auto& zone : zones) {
-        BOOST_CHECK(EXPECTED_CONNECTIONS.find(zone) != EXPECTED_CONNECTIONS.cend());
+        BOOST_CHECK(EXPECTED_ZONES.find(zone) != EXPECTED_ZONES.cend());
     }
     vsm_array_string_free(values);
     vsm_client_free(client);
@@ -215,7 +156,7 @@ BOOST_AUTO_TEST_CASE(GetActiveZoneId)
     status = vsm_get_active_zone_id(client, &zone);
     BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, status);
 
-    BOOST_CHECK_EQUAL(zone, cm.getRunningForegroundZoneId());
+    BOOST_CHECK_EQUAL(zone, cm->getRunningForegroundZoneId());
 
     vsm_string_free(zone);
     vsm_client_free(client);
@@ -245,14 +186,14 @@ BOOST_AUTO_TEST_CASE(SetActiveZone)
 {
     const std::string newActiveZoneId = "zone2";
 
-    BOOST_REQUIRE_NE(newActiveZoneId, cm.getRunningForegroundZoneId());
+    BOOST_REQUIRE_NE(newActiveZoneId, cm->getRunningForegroundZoneId());
 
     VsmClient client = vsm_client_create();
     VsmStatus status = vsm_connect(client);
     BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, status);
     status = vsm_set_active_zone(client, newActiveZoneId.c_str());
     BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, status);
-    BOOST_CHECK_EQUAL(newActiveZoneId, cm.getRunningForegroundZoneId());
+    BOOST_CHECK_EQUAL(newActiveZoneId, cm->getRunningForegroundZoneId());
     vsm_client_free(client);
 }
 
@@ -296,17 +237,18 @@ BOOST_AUTO_TEST_CASE(LockUnlockZone)
     vsm_client_free(client);
 }
 
+#ifdef ZONE_CONNECTION
 BOOST_AUTO_TEST_CASE(FileMoveRequest)
 {
     const std::string path = "/tmp/fake_path";
     const std::string secondZone = "fake_zone";
 
     VsmClient client = vsm_client_create();
-    VsmStatus status = vsm_connect_custom(client, EXPECTED_CONNECTIONS.begin()->second.c_str());
+    VsmStatus status = vsm_connect(client);
     BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, status);
     status = vsm_file_move_request(client, secondZone.c_str(), path.c_str());
     BOOST_REQUIRE_EQUAL(VSMCLIENT_CUSTOM_ERROR, status);
-    BOOST_REQUIRE_EQUAL(api::zone::FILE_MOVE_DESTINATION_NOT_FOUND,
+    BOOST_REQUIRE_EQUAL(api::FILE_MOVE_DESTINATION_NOT_FOUND,
                         vsm_get_status_message(client));
     vsm_client_free(client);
 }
@@ -332,9 +274,9 @@ BOOST_AUTO_TEST_CASE(Notification)
 
     CallbackData callbackData;
     std::map<std::string, VsmClient> clients;
-    for (const auto& it : EXPECTED_CONNECTIONS) {
+    for (const auto& it : EXPECTED_ZONES) {
         VsmClient client = vsm_client_create();
-        VsmStatus status = vsm_connect_custom(client, it.second.c_str());
+        VsmStatus status = vsm_connect_custom(client, it.c_str());
         BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, status);
         clients[it.first] = client;
     }
@@ -365,6 +307,7 @@ BOOST_AUTO_TEST_CASE(Notification)
         vsm_client_free(client.second);
     }
 }
+#endif
 
 BOOST_AUTO_TEST_CASE(GetZoneIdByPidTestSingle)
 {
@@ -398,8 +341,8 @@ BOOST_AUTO_TEST_CASE(GetZoneIdByPidTestMultiple)
 
     BOOST_CHECK(ids.count("host") == 1);
 
-    for (const auto& dbus : EXPECTED_CONNECTIONS) {
-        BOOST_CHECK(ids.count(dbus.first) == 1);
+    for (const auto& dbus : EXPECTED_ZONES) {
+        BOOST_CHECK(ids.count(dbus) == 1);
     }
 }
 
@@ -429,7 +372,7 @@ BOOST_AUTO_TEST_CASE(Provision)
 {
     VsmClient client = vsm_client_create();
     BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, vsm_connect(client));
-    const std::string zone = cm.getRunningForegroundZoneId();
+    const std::string zone = cm->getRunningForegroundZoneId();
     VsmArrayString declarations;
     BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, vsm_list_declarations(client, zone.c_str(), &declarations));
     BOOST_REQUIRE(declarations != NULL && declarations[0] == NULL);
@@ -469,3 +412,5 @@ BOOST_AUTO_TEST_CASE(ZoneGetNetdevs)
 
 
 BOOST_AUTO_TEST_SUITE_END()
+
+#endif /* !DBUS_CONNECTION */
index a8ff5b9..a33ccac 100755 (executable)
@@ -68,7 +68,6 @@ lxc.mount.entry = /lib lib none ro,bind 0 0
 lxc.mount.entry = /sbin sbin none ro,bind 0 0
 lxc.mount.entry = /usr usr none ro,rbind 0 0
 lxc.mount.entry = /opt opt none ro,rbind 0 0
-lxc.mount.entry = /tmp/ut-run/${name} var/run none rw,bind 0 0
 EOF
 
 if [ "$(uname -m)" = "x86_64" ]; then
index 6c8a1af..c5880b1 100644 (file)
@@ -32,8 +32,6 @@ FILE(GLOB zone_provision_CONF  ut-zone-provision/*.conf)
 
 FILE(GLOB admin_templates_CONF      ut-zone-admin/templates/*.conf)
 
-FILE(GLOB connection_CONF           ut-zone-connection/*.conf)
-
 
 ## Generate ####################################################################
 CONFIGURE_FILE(ut-server/test-daemon.conf.in
@@ -50,6 +48,8 @@ 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)
 
 
@@ -83,8 +83,5 @@ INSTALL(FILES        ${zone_provision_CONF}
 INSTALL(FILES        ${admin_templates_CONF}
         DESTINATION  ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-zone-admin/templates)
 
-INSTALL(FILES        ${connection_CONF}
-        DESTINATION  ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-zone-connection)
-
 INSTALL(FILES        dbus-1/system.d/org.tizen.vasum.tests.conf
         DESTINATION  ${SYSCONF_INSTALL_DIR}/dbus-1/system.d/)
index d07ecc6..5261493 100644 (file)
@@ -7,7 +7,6 @@
     "privilege" : 20,
     "vt" : -1,
     "switchToDefaultAfterTimeout" : true,
-    "enableZoneConnection" : false,
     "cpuQuotaForeground" : -1,
     "cpuQuotaBackground" : 1000,
     "shutdownTimeout" : 10,
index c3b07fe..99bc05e 100644 (file)
@@ -7,7 +7,6 @@
     "privilege" : 10,
     "vt" : -1,
     "switchToDefaultAfterTimeout" : true,
-    "enableZoneConnection" : false,
     "cpuQuotaForeground" : -1,
     "cpuQuotaBackground" : 1000,
     "shutdownTimeout" : 10,
index 7e20d62..6c7ce34 100644 (file)
@@ -7,7 +7,6 @@
     "privilege" : 10,
     "vt" : -1,
     "switchToDefaultAfterTimeout" : true,
-    "enableZoneConnection" : false,
     "cpuQuotaForeground" : -1,
     "cpuQuotaBackground" : 1000,
     "shutdownTimeout" : 10,
index 4aa7bd2..e4f2bf9 100644 (file)
@@ -7,7 +7,6 @@
     "privilege" : 10,
     "vt" : -1,
     "switchToDefaultAfterTimeout" : true,
-    "enableZoneConnection" : false,
     "cpuQuotaForeground" : -1,
     "cpuQuotaBackground" : 1000,
     "shutdownTimeout" : 10,
index 5083c0e..8af8d42 100644 (file)
@@ -7,7 +7,6 @@
     "privilege" : 10,
     "vt" : -1,
     "switchToDefaultAfterTimeout" : true,
-    "enableZoneConnection" : false,
     "cpuQuotaForeground" : -1,
     "cpuQuotaBackground" : 1000,
     "shutdownTimeout" : 10,
diff --git a/tests/unit_tests/server/configs/ut-zone-connection/ut-dbus.conf b/tests/unit_tests/server/configs/ut-zone-connection/ut-dbus.conf
deleted file mode 100644 (file)
index 66ee3f9..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<!-- This configuration file controls the zones message bus -->
-
-<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
- "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
-
-<busconfig>
-    <type>custom</type>
-    <listen>unix:path=/tmp/ut-zones/mount-point/dbus/system_bus_socket</listen>
-
-    <policy context="default">
-        <!-- Allow everything to be sent -->
-        <allow send_destination="*" eavesdrop="true"/>
-        <!-- Allow everything to be received -->
-        <allow eavesdrop="true"/>
-        <!-- Allow anyone to own anything -->
-        <allow own="*"/>
-    </policy>
-</busconfig>
index 1e71ece..5c98cfd 100644 (file)
@@ -7,7 +7,6 @@
     "privilege" : 10,
     "vt" : -1,
     "switchToDefaultAfterTimeout" : true,
-    "enableZoneConnection" : false,
     "cpuQuotaForeground" : -1,
     "cpuQuotaBackground" : 1000,
     "shutdownTimeout" : 10,
index da02e3b..d2fea11 100644 (file)
@@ -7,7 +7,6 @@
     "privilege" : 10,
     "vt" : -1,
     "switchToDefaultAfterTimeout" : true,
-    "enableZoneConnection" : true,
     "cpuQuotaForeground" : -1,
     "cpuQuotaBackground" : 1000,
     "shutdownTimeout" : 10,
index 7827fe3..38907a0 100644 (file)
@@ -7,7 +7,6 @@
     "privilege" : 10,
     "vt" : -1,
     "switchToDefaultAfterTimeout" : true,
-    "enableZoneConnection" : false,
     "cpuQuotaForeground" : -1,
     "cpuQuotaBackground" : 1000,
     "shutdownTimeout" : 10,
index 3481c09..2ff5998 100644 (file)
@@ -7,7 +7,6 @@
     "privilege" : 20,
     "vt" : -1,
     "switchToDefaultAfterTimeout" : true,
-    "enableZoneConnection" : true,
     "cpuQuotaForeground" : -1,
     "cpuQuotaBackground" : 1000,
     "shutdownTimeout" : 10,
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
new file mode 100644 (file)
index 0000000..fab7e58
--- /dev/null
@@ -0,0 +1,18 @@
+{
+    "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 d9f69ec..02a7dc6 100644 (file)
@@ -7,7 +7,6 @@
     "privilege" : 20,
     "vt" : -1,
     "switchToDefaultAfterTimeout" : true,
-    "enableZoneConnection" : false,
     "cpuQuotaForeground" : -1,
     "cpuQuotaBackground" : 1000,
     "shutdownTimeout" : 10,
diff --git a/tests/unit_tests/server/ut-zone-connection.cpp b/tests/unit_tests/server/ut-zone-connection.cpp
deleted file mode 100644 (file)
index c374c81..0000000
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- *  Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Piotr Bartosiewicz <p.bartosiewi@partner.samsung.com>
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License
- */
-
-
-/**
- * @file
- * @author  Piotr Bartosiewicz (p.bartosiewi@partner.samsung.com)
- * @brief   Unit tests of the ZoneConnection class
- */
-
-#include "config.hpp"
-#include "ut.hpp"
-
-#include "zone-connection.hpp"
-#include "zone-connection-transport.hpp"
-#include "host-dbus-definitions.hpp"
-#include "zone-dbus-definitions.hpp"
-// TODO: Switch to real power-manager dbus defs when they will be implemented in power-manager
-#include "fake-power-manager-dbus-definitions.hpp"
-
-#include "dbus/connection.hpp"
-#include "dbus/exception.hpp"
-#include "utils/scoped-daemon.hpp"
-#include "utils/glib-loop.hpp"
-#include "utils/latch.hpp"
-#include "utils/fs.hpp"
-#include "utils/scoped-dir.hpp"
-
-#include "api/method-result-builder.hpp"
-
-
-using namespace vasum;
-using namespace vasum::utils;
-using namespace dbus;
-
-namespace {
-
-const char* DBUS_DAEMON_PROC = "/usr/bin/dbus-daemon";
-const char* const DBUS_DAEMON_ARGS[] = {
-    DBUS_DAEMON_PROC,
-    "--config-file=" VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-zone-connection/ut-dbus.conf",
-    "--nofork",
-    NULL
-};
-
-const std::string ZONES_PATH = "/tmp/ut-zones";
-const std::string TRANSPORT_MOUNT_POINT = ZONES_PATH + "/mount-point";
-const int EVENT_TIMEOUT = 1000;
-
-class Fixture {
-public:
-    Fixture()
-        : mZonesPathGuard(ZONES_PATH)
-        , mTransport(TRANSPORT_MOUNT_POINT)
-    {
-        mDaemon.start(DBUS_DAEMON_PROC, DBUS_DAEMON_ARGS);
-    }
-
-    std::string acquireAddress()
-    {
-        return mTransport.acquireAddress();
-    }
-private:
-    ScopedGlibLoop mLoop;
-    ScopedDir mZonesPathGuard;
-    ZoneConnectionTransport mTransport;
-    ScopedDaemon mDaemon;
-};
-
-class DbusNameSetter {
-public:
-    DbusNameSetter()
-        : mNameAcquired(false),
-          mPendingDisconnect(false)
-    {
-    }
-
-    void setName(const std::unique_ptr<DbusConnection>& conn, const std::string& name)
-    {
-        conn->setName(name,
-                      std::bind(&DbusNameSetter::onNameAcquired, this),
-                      std::bind(&DbusNameSetter::onDisconnect, this));
-
-        if(!waitForName()) {
-            throw dbus::DbusOperationException("Could not acquire name.");
-        }
-    }
-
-    bool waitForName()
-    {
-        std::unique_lock<std::mutex> lock(mMutex);
-        mNameCondition.wait(lock, [this] {return mNameAcquired || mPendingDisconnect;});
-        return mNameAcquired;
-    }
-
-    void onNameAcquired()
-    {
-        std::unique_lock<std::mutex> lock(mMutex);
-        mNameAcquired = true;
-        mNameCondition.notify_one();
-    }
-
-    void onDisconnect()
-    {
-        std::unique_lock<std::mutex> lock(mMutex);
-        mPendingDisconnect = true;
-        mNameCondition.notify_one();
-    }
-
-private:
-    bool mNameAcquired;
-    bool mPendingDisconnect;
-    std::mutex mMutex;
-    std::condition_variable mNameCondition;
-};
-
-} // namespace
-
-BOOST_FIXTURE_TEST_SUITE(ZoneConnectionSuite, Fixture)
-
-BOOST_AUTO_TEST_CASE(ConstructorDestructorConnect)
-{
-    ZoneConnection(acquireAddress(), nullptr);
-}
-
-BOOST_AUTO_TEST_CASE(NotifyActiveZoneApi)
-{
-    Latch notifyCalled;
-    ZoneConnection connection(acquireAddress(), nullptr);
-
-    auto callback = [&](const std::string& application, const std::string& message, api::MethodResultBuilder::Pointer result) {
-        if (application == "testapp" && message == "testmessage") {
-            notifyCalled.set();
-        }
-        result->setVoid();
-    };
-    connection.setNotifyActiveZoneCallback(callback);
-
-    DbusConnection::Pointer client = DbusConnection::create(acquireAddress());
-    client->callMethod(api::zone::BUS_NAME,
-                       api::zone::OBJECT_PATH,
-                       api::zone::INTERFACE,
-                       api::zone::METHOD_NOTIFY_ACTIVE_ZONE,
-                       g_variant_new("(ss)", "testapp", "testmessage"),
-                       "()");
-    BOOST_CHECK(notifyCalled.wait(EVENT_TIMEOUT));
-}
-
-BOOST_AUTO_TEST_CASE(SignalNotificationApi)
-{
-    Latch signalEmitted;
-    ZoneConnection connection(acquireAddress(), nullptr);
-
-    DbusConnection::Pointer client = DbusConnection::create(acquireAddress());
-
-    auto handler = [&](const std::string& /*senderBusName*/,
-                       const std::string& objectPath,
-                       const std::string& interface,
-                       const std::string& signalName,
-    GVariant* parameters) {
-        if (objectPath == api::zone::OBJECT_PATH &&
-                interface == api::zone::INTERFACE &&
-                signalName == api::zone::SIGNAL_NOTIFICATION &&
-                g_variant_is_of_type(parameters, G_VARIANT_TYPE("(sss)"))) {
-
-            const gchar* zone = NULL;
-            const gchar* application = NULL;
-            const gchar* message = NULL;
-            g_variant_get(parameters, "(&s&s&s)", &zone, &application, &message);
-            if (zone == std::string("testzone") &&
-                    application == std::string("testapp") &&
-                    message == std::string("testmessage")) {
-                signalEmitted.set();
-            }
-        }
-    };
-    client->signalSubscribe(handler, api::zone::BUS_NAME);
-
-    connection.sendNotification("testzone", "testapp", "testmessage");
-
-    BOOST_CHECK(signalEmitted.wait(EVENT_TIMEOUT));
-}
-
-BOOST_AUTO_TEST_CASE(SignalSwitchToDefaultApi)
-{
-    Latch switchToDefaultCalled;
-    ZoneConnection connection(acquireAddress(), nullptr);
-
-    DbusConnection::Pointer client = DbusConnection::create(acquireAddress());
-
-    auto callback = [&]() {
-        switchToDefaultCalled.set();
-    };
-
-    connection.setSwitchToDefaultCallback(callback);
-
-    client->emitSignal(fake_power_manager_api::OBJECT_PATH,
-                       fake_power_manager_api::INTERFACE,
-                       fake_power_manager_api::SIGNAL_DISPLAY_OFF,
-                       nullptr);
-
-    // timeout should occur, since no name is set to client
-    BOOST_CHECK(!switchToDefaultCalled.wait(EVENT_TIMEOUT));
-
-    DbusNameSetter setter;
-
-    setter.setName(client, fake_power_manager_api::BUS_NAME);
-
-    client->emitSignal(fake_power_manager_api::OBJECT_PATH,
-                       fake_power_manager_api::INTERFACE,
-                       fake_power_manager_api::SIGNAL_DISPLAY_OFF,
-                       nullptr);
-
-    // now signal should be delivered correctly
-    BOOST_CHECK(switchToDefaultCalled.wait(EVENT_TIMEOUT));
-}
-
-
-BOOST_AUTO_TEST_SUITE_END()
index dc66753..b4938b4 100644 (file)
@@ -84,8 +84,7 @@ struct Fixture {
 
     std::unique_ptr<Zone> create(const std::string& configPath)
     {
-        return std::unique_ptr<Zone>(new Zone(utils::Worker::create(),
-                                              "zoneId",
+        return std::unique_ptr<Zone>(new Zone("zoneId",
                                               ZONES_PATH,
                                               configPath,
                                               DB_PATH,
index 5a9693f..a2811a9 100644 (file)
 #include "ut.hpp"
 
 #include "zones-manager.hpp"
-#include "zone-dbus-definitions.hpp"
 #ifdef DBUS_CONNECTION
+// TODO: Switch to real power-manager dbus defs when they will be implemented in power-manager
+#include "fake-power-manager-dbus-definitions.hpp"
 #include "host-dbus-definitions.hpp"
+#include "test-dbus-definitions.hpp"
+#include "dbus/connection.hpp"
+#include "dbus/exception.hpp"
 #else
 #include "host-ipc-definitions.hpp"
 #include <api/messages.hpp>
 #include <epoll/thread-dispatcher.hpp>
 #include <ipc/client.hpp>
 #endif
-#include "test-dbus-definitions.hpp"
-// TODO: Switch to real power-manager dbus defs when they will be implemented in power-manager
-#include "fake-power-manager-dbus-definitions.hpp"
 #include "exception.hpp"
 
-#include "dbus/connection.hpp"
-#include "dbus/exception.hpp"
 #include "utils/glib-loop.hpp"
 #include "config/exception.hpp"
 #include "utils/latch.hpp"
@@ -64,7 +63,9 @@
 using namespace vasum;
 using namespace config;
 using namespace vasum::utils;
+#ifdef DBUS_CONNECTION
 using namespace dbus;
+#endif
 
 namespace {
 
@@ -73,7 +74,6 @@ const std::string TEST_CONFIG_PATH = CONFIG_DIR + "/test-daemon.conf";
 const std::string MISSING_CONFIG_PATH = CONFIG_DIR + "/missing-daemon.conf";
 const int EVENT_TIMEOUT = 5000;
 //const int UNEXPECTED_EVENT_TIMEOUT = EVENT_TIMEOUT / 5;
-const int TEST_DBUS_CONNECTION_ZONES_COUNT = 3;
 const std::string TEST_APP_NAME = "testapp";
 const std::string TEST_MESSAGE = "testmessage";
 const std::string FILE_CONTENT = "File content\n"
@@ -82,7 +82,11 @@ 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
 /**
@@ -109,8 +113,7 @@ public:
                                MethodResultBuilder::Pointer result
                               )> TestApiMethodCallback;
     typedef std::function<void()> VoidResultCallback;
-    typedef std::function<void(const std::string& zoneId,
-                               const std::string& address)> SignalCallback;
+    typedef std::function<void(const api::Notification)> NotificationCallback;
 
     typedef std::map<std::string, std::string> Connections;
 
@@ -165,44 +168,48 @@ public:
 
     void signalSubscribe(const DbusConnection::SignalCallback& callback)
     {
-        mClient->signalSubscribe(callback, isHost() ? api::host::BUS_NAME : api::zone::BUS_NAME);
+        mClient->signalSubscribe(callback, isHost() ? api::BUS_NAME : api::BUS_NAME);
     }
 
-    void subscribeZoneConnectionState(const SignalCallback& callback) {
-        assert(isHost());
-        auto onSignal = [callback] (const std::string& /*senderBusName*/,
-                             const std::string& objectPath,
-                             const std::string& interface,
-                             const std::string& signalName,
-                             GVariant* parameters) {
-            if (objectPath == api::host::OBJECT_PATH &&
-                interface == api::host::INTERFACE &&
-                signalName == api::host::SIGNAL_ZONE_CONNECTION_STATE) {
-
-                const gchar* zoneId = NULL;
-                const gchar* address = NULL;
-                g_variant_get(parameters, "(&s&s)", &zoneId, &address);
-                callback(zoneId, address);
+    void subscribeNotification(const NotificationCallback& callback)
+    {
+        auto handler = [callback](const std::string& /*senderBusName*/,
+                          const std::string& objectPath,
+                          const std::string& interface,
+                          const std::string& signalName,
+                           GVariant* parameters)
+        {
+            if (objectPath == api::OBJECT_PATH &&
+                interface == api::INTERFACE &&
+                signalName == api::SIGNAL_NOTIFICATION &&
+                g_variant_is_of_type(parameters, G_VARIANT_TYPE("(sss)"))) {
+
+                const gchar* zone = NULL;
+                const gchar* application = NULL;
+                const gchar* message = NULL;
+                g_variant_get(parameters, "(&s&s&s)", &zone, &application, &message);
+                callback({zone, application, message});
             }
         };
-        mClient->signalSubscribe(onSignal, api::host::BUS_NAME);
+        mClient->signalSubscribe(handler, api::BUS_NAME);
     }
 
-    void emitSignal(const std::string& objectPath,
-                    const std::string& interface,
-                    const std::string& name,
-                    GVariant* parameters)
+    void signalSwitchToDefault()
     {
-        mClient->emitSignal(objectPath, interface, name, parameters);
+        // emit signal from dbus connection
+        mClient->emitSignal(api::OBJECT_PATH,
+                            api::INTERFACE,
+                            api::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::zone::BUS_NAME,
-                            api::zone::OBJECT_PATH,
-                            api::zone::INTERFACE,
-                            api::zone::METHOD_NOTIFY_ACTIVE_ZONE,
+        mClient->callMethod(api::BUS_NAME,
+                            api::OBJECT_PATH,
+                            api::INTERFACE,
+                            api::METHOD_NOTIFY_ACTIVE_ZONE,
                             parameters,
                             "()");
     }
@@ -210,10 +217,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::zone::BUS_NAME,
-                                                 api::zone::OBJECT_PATH,
-                                                 api::zone::INTERFACE,
-                                                 api::zone::METHOD_FILE_MOVE_REQUEST,
+        GVariantPtr result = mClient->callMethod(api::BUS_NAME,
+                                                 api::OBJECT_PATH,
+                                                 api::INTERFACE,
+                                                 api::METHOD_FILE_MOVE_REQUEST,
                                                  parameters,
                                                  "(s)");
 
@@ -271,12 +278,12 @@ public:
                                                    interface.c_str(),
                                                    method.c_str(),
                                                    parameters);
-        GVariantPtr result = mClient->callMethod(isHost() ? api::host::BUS_NAME :
-                                                            api::zone::BUS_NAME,
-                                                 isHost() ? api::host::OBJECT_PATH :
-                                                            api::zone::OBJECT_PATH,
-                                                 isHost() ? api::host::INTERFACE :
-                                                            api::zone::INTERFACE,
+        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,
                                                  packedParameters,
                                                  "(v)");
@@ -285,36 +292,13 @@ public:
         return GVariantPtr(unpackedResult, g_variant_unref);
     }
 
-    Connections callMethodGetZoneConnections()
-    {
-        assert(isHost());
-        Connections connections;
-        GVariantPtr result = mClient->callMethod(api::host::BUS_NAME,
-                                                 api::host::OBJECT_PATH,
-                                                 api::host::INTERFACE,
-                                                 api::host::METHOD_GET_ZONE_CONNECTIONS,
-                                                 NULL,
-                                                 "(a(ss))");
-        GVariant* array = NULL;
-        g_variant_get(result.get(), "(*)", &array);
-        dbus::GVariantPtr autounref(array, g_variant_unref);
-        size_t count = g_variant_n_children(array);
-        for (size_t n = 0; n < count; ++n) {
-            const char* zoneId = NULL;
-            const char* address = NULL;
-            g_variant_get_child(array, n, "(&s&s)", &zoneId, &address);
-            connections.insert(Connections::value_type(zoneId, address));
-        }
-        return connections;
-    }
-
     std::vector<std::string> callMethodGetZoneIds()
     {
         assert(isHost());
-        GVariantPtr result = mClient->callMethod(api::host::BUS_NAME,
-                                                 api::host::OBJECT_PATH,
-                                                 api::host::INTERFACE,
-                                                 api::host::METHOD_GET_ZONE_ID_LIST,
+        GVariantPtr result = mClient->callMethod(api::BUS_NAME,
+                                                 api::OBJECT_PATH,
+                                                 api::INTERFACE,
+                                                 api::METHOD_GET_ZONE_ID_LIST,
                                                  NULL,
                                                  "(as)");
 
@@ -336,10 +320,10 @@ public:
     std::string callMethodGetActiveZoneId()
     {
         assert(isHost());
-        GVariantPtr result = mClient->callMethod(api::host::BUS_NAME,
-                                                 api::host::OBJECT_PATH,
-                                                 api::host::INTERFACE,
-                                                 api::host::METHOD_GET_ACTIVE_ZONE_ID,
+        GVariantPtr result = mClient->callMethod(api::BUS_NAME,
+                                                 api::OBJECT_PATH,
+                                                 api::INTERFACE,
+                                                 api::METHOD_GET_ACTIVE_ZONE_ID,
                                                  NULL,
                                                  "(s)");
 
@@ -352,10 +336,10 @@ public:
     {
         assert(isHost());
         GVariant* parameters = g_variant_new("(s)", id.c_str());
-        GVariantPtr result = mClient->callMethod(api::host::BUS_NAME,
-                                                 api::host::OBJECT_PATH,
-                                                 api::host::INTERFACE,
-                                                 api::host::METHOD_SET_ACTIVE_ZONE,
+        GVariantPtr result = mClient->callMethod(api::BUS_NAME,
+                                                 api::OBJECT_PATH,
+                                                 api::INTERFACE,
+                                                 api::METHOD_SET_ACTIVE_ZONE,
                                                  parameters,
                                                  "()");
 
@@ -373,10 +357,10 @@ public:
 
         assert(isHost());
         GVariant* parameters = g_variant_new("(ss)", id.c_str(), templateName.c_str());
-        mClient->callMethodAsync(api::host::BUS_NAME,
-                                 api::host::OBJECT_PATH,
-                                 api::host::INTERFACE,
-                                 api::host::METHOD_CREATE_ZONE,
+        mClient->callMethodAsync(api::BUS_NAME,
+                                 api::OBJECT_PATH,
+                                 api::INTERFACE,
+                                 api::METHOD_CREATE_ZONE,
                                  parameters,
                                  "()",
                                  dropException(asyncResult));
@@ -393,10 +377,10 @@ public:
 
         assert(isHost());
         GVariant* parameters = g_variant_new("(s)", id.c_str());
-        mClient->callMethodAsync(api::host::BUS_NAME,
-                                 api::host::OBJECT_PATH,
-                                 api::host::INTERFACE,
-                                 api::host::METHOD_DESTROY_ZONE,
+        mClient->callMethodAsync(api::BUS_NAME,
+                                 api::OBJECT_PATH,
+                                 api::INTERFACE,
+                                 api::METHOD_DESTROY_ZONE,
                                  parameters,
                                  "()",
                                  dropException(asyncResult));
@@ -413,10 +397,10 @@ public:
 
         assert(isHost());
         GVariant* parameters = g_variant_new("(s)", id.c_str());
-        mClient->callMethodAsync(api::host::BUS_NAME,
-                                 api::host::OBJECT_PATH,
-                                 api::host::INTERFACE,
-                                 api::host::METHOD_SHUTDOWN_ZONE,
+        mClient->callMethodAsync(api::BUS_NAME,
+                                 api::OBJECT_PATH,
+                                 api::INTERFACE,
+                                 api::METHOD_SHUTDOWN_ZONE,
                                  parameters,
                                  "()",
                                  dropException(asyncResult));
@@ -433,10 +417,10 @@ public:
 
         assert(isHost());
         GVariant* parameters = g_variant_new("(s)", id.c_str());
-        mClient->callMethodAsync(api::host::BUS_NAME,
-                                 api::host::OBJECT_PATH,
-                                 api::host::INTERFACE,
-                                 api::host::METHOD_START_ZONE,
+        mClient->callMethodAsync(api::BUS_NAME,
+                                 api::OBJECT_PATH,
+                                 api::INTERFACE,
+                                 api::METHOD_START_ZONE,
                                  parameters,
                                  "()",
                                  dropException(asyncResult));
@@ -446,10 +430,10 @@ public:
     {
         assert(isHost());
         GVariant* parameters = g_variant_new("(s)", id.c_str());
-        GVariantPtr result = mClient->callMethod(api::host::BUS_NAME,
-                                                 api::host::OBJECT_PATH,
-                                                 api::host::INTERFACE,
-                                                 api::host::METHOD_LOCK_ZONE,
+        GVariantPtr result = mClient->callMethod(api::BUS_NAME,
+                                                 api::OBJECT_PATH,
+                                                 api::INTERFACE,
+                                                 api::METHOD_LOCK_ZONE,
                                                  parameters,
                                                  "()");
     }
@@ -458,10 +442,10 @@ public:
     {
         assert(isHost());
         GVariant* parameters = g_variant_new("(s)", id.c_str());
-        GVariantPtr result = mClient->callMethod(api::host::BUS_NAME,
-                                                 api::host::OBJECT_PATH,
-                                                 api::host::INTERFACE,
-                                                 api::host::METHOD_UNLOCK_ZONE,
+        GVariantPtr result = mClient->callMethod(api::BUS_NAME,
+                                                 api::OBJECT_PATH,
+                                                 api::INTERFACE,
+                                                 api::METHOD_UNLOCK_ZONE,
                                                  parameters,
                                                  "()");
     }
@@ -490,21 +474,14 @@ private:
 };
 
 typedef DbusAccessory HostAccessory;
-typedef DbusAccessory ZoneAccessory;
 
 #else
 //#ifdef DBUS_CONNECTION
 
 class HostIPCAccessory {
 public:
-    typedef std::function<void(const std::string& argument,
-                               MethodResultBuilder::Pointer result
-                              )> TestApiMethodCallback;
     typedef std::function<void()> VoidResultCallback;
-    typedef std::function<void(const std::string& zoneId,
-                               const std::string& address)> SignalCallback;
-
-    typedef std::map<std::string, std::string> Connections;
+    typedef std::function<void(const api::Notification)> NotificationCallback;
 
     HostIPCAccessory()
         : mClient(mDispatcher.getPoll(), HOST_IPC_SOCKET)
@@ -512,43 +489,23 @@ public:
         mClient.start();
     }
 
-    void subscribeZoneConnectionState(const SignalCallback& callback)
-    {
-        auto callbackWrapper = [callback] (const ipc::PeerID, std::shared_ptr<api::ConnectionState>& data) {
-            callback(data->first, data->second);
-        };
-        mClient.setSignalHandler<api::ConnectionState>(api::host::SIGNAL_ZONE_CONNECTION_STATE,
-                                                       callbackWrapper);
-    }
-
-    Connections callMethodGetZoneConnections()
-    {
-        const auto out = mClient.callSync<api::Void, api::Connections>(api::host::METHOD_GET_ZONE_CONNECTIONS,
-                                                                       std::make_shared<api::Void>());
-        Connections connections;
-        for (const auto& dbus : out->values) {
-            connections.insert(Connections::value_type(dbus.first, dbus.second));
-        }
-        return connections;
-    }
-
     std::vector<std::string> callMethodGetZoneIds()
     {
-        const auto out = mClient.callSync<api::Void, api::ZoneIds>(api::host::METHOD_GET_ZONE_ID_LIST,
+        const auto out = mClient.callSync<api::Void, api::ZoneIds>(api::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::host::METHOD_GET_ACTIVE_ZONE_ID,
+        const auto out = mClient.callSync<api::Void, api::ZoneId>(api::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::host::METHOD_SET_ACTIVE_ZONE,
+        mClient.callSync<api::ZoneId, api::Void>(api::METHOD_SET_ACTIVE_ZONE,
                                                  std::make_shared<api::ZoneId>(api::ZoneId{id}));
     }
 
@@ -561,7 +518,7 @@ public:
                 result();
             }
         };
-        mClient.callAsync<api::CreateZoneIn, api::Void>(api::host::METHOD_CREATE_ZONE,
+        mClient.callAsync<api::CreateZoneIn, api::Void>(api::METHOD_CREATE_ZONE,
                            std::make_shared<api::CreateZoneIn>(api::CreateZoneIn{id, templateName}),
                            asyncResult);
     }
@@ -574,7 +531,7 @@ public:
                 result();
             }
         };
-        mClient.callAsync<api::ZoneId, api::Void>(api::host::METHOD_DESTROY_ZONE,
+        mClient.callAsync<api::ZoneId, api::Void>(api::METHOD_DESTROY_ZONE,
                            std::make_shared<api::ZoneId>(api::ZoneId{id}),
                            asyncResult);
     }
@@ -587,7 +544,7 @@ public:
                 result();
             }
         };
-        mClient.callAsync<api::ZoneId, api::Void>(api::host::METHOD_SHUTDOWN_ZONE,
+        mClient.callAsync<api::ZoneId, api::Void>(api::METHOD_SHUTDOWN_ZONE,
                            std::make_shared<api::ZoneId>(api::ZoneId{id}),
                            asyncResult);
     }
@@ -600,195 +557,62 @@ public:
                 result();
             }
         };
-        mClient.callAsync<api::ZoneId, api::Void>(api::host::METHOD_START_ZONE,
+        mClient.callAsync<api::ZoneId, api::Void>(api::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::host::METHOD_LOCK_ZONE,
+        mClient.callSync<api::ZoneId, api::Void>(api::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::host::METHOD_UNLOCK_ZONE,
+        mClient.callSync<api::ZoneId, api::Void>(api::METHOD_UNLOCK_ZONE,
                                                   std::make_shared<api::ZoneId>(api::ZoneId{id}),
                                                   EVENT_TIMEOUT*10); //Prevent from IPCTimeoutException see LockUnlockZone
     }
 
-private:
-    epoll::ThreadDispatcher mDispatcher;
-    ipc::Client mClient;
-};
-
-class ZoneDbusAccessory {
-public:
-    typedef std::function<void(const std::string& argument,
-                               MethodResultBuilder::Pointer result
-                              )> TestApiMethodCallback;
-
-    typedef std::map<std::string, std::string> Connections;
-
-    ZoneDbusAccessory(int id)
-        : mId(id),
-          mClient(DbusConnection::create(acquireAddress())),
-          mNameAcquired(false),
-          mPendingDisconnect(false)
-    {
-    }
-
-    void setName(const std::string& name)
-    {
-        mClient->setName(name,
-                         std::bind(&ZoneDbusAccessory::onNameAcquired, this),
-                         std::bind(&ZoneDbusAccessory::onDisconnect, this));
-
-        if(!waitForName()) {
-            mClient.reset();
-            throw dbus::DbusOperationException("Could not acquire name.");
-        }
-    }
-
-    bool waitForName()
-    {
-        std::unique_lock<std::mutex> lock(mMutex);
-        mNameCondition.wait(lock, [this] {return mNameAcquired || mPendingDisconnect;});
-        return mNameAcquired;
-    }
-
-    void onNameAcquired()
-    {
-        std::unique_lock<std::mutex> lock(mMutex);
-        mNameAcquired = true;
-        mNameCondition.notify_one();
-    }
-
-    void onDisconnect()
-    {
-        std::unique_lock<std::mutex> lock(mMutex);
-        mPendingDisconnect = true;
-        mNameCondition.notify_one();
-    }
-
-    void signalSubscribe(const DbusConnection::SignalCallback& callback)
+    void subscribeNotification(const NotificationCallback& callback)
     {
-        mClient->signalSubscribe(callback, api::zone::BUS_NAME);
+        auto callbackWrapper = [callback] (const ipc::PeerID, std::shared_ptr<api::Notification>& data) {
+            callback(*data);
+        };
+        mClient.setSignalHandler<api::Notification>(api::SIGNAL_NOTIFICATION,
+                                                    callbackWrapper);
     }
 
-    void emitSignal(const std::string& objectPath,
-                    const std::string& interface,
-                    const std::string& name,
-                    GVariant* parameters)
+    void signalSwitchToDefault()
     {
-        mClient->emitSignal(objectPath, interface, name, parameters);
+        mClient.signal<api::Void>(api::SIGNAL_SWITCH_TO_DEFAULT, std::make_shared<api::Void>());
     }
 
     void callMethodNotify()
     {
-        GVariant* parameters = g_variant_new("(ss)", TEST_APP_NAME.c_str(), TEST_MESSAGE.c_str());
-        mClient->callMethod(api::zone::BUS_NAME,
-                            api::zone::OBJECT_PATH,
-                            api::zone::INTERFACE,
-                            api::zone::METHOD_NOTIFY_ACTIVE_ZONE,
-                            parameters,
-                            "()");
+        mClient.callSync<api::NotifActiveZoneIn, api::Void>(
+            api::METHOD_NOTIFY_ACTIVE_ZONE,
+            std::make_shared<api::NotifActiveZoneIn>(api::NotifActiveZoneIn{TEST_APP_NAME, TEST_MESSAGE}),
+            EVENT_TIMEOUT*10); //Prevent from IPCTimeoutException see LockUnlockZone
     }
 
     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::zone::BUS_NAME,
-                                                 api::zone::OBJECT_PATH,
-                                                 api::zone::INTERFACE,
-                                                 api::zone::METHOD_FILE_MOVE_REQUEST,
-                                                 parameters,
-                                                 "(s)");
-
-        const gchar* retcode = NULL;
-        g_variant_get(result.get(), "(&s)", &retcode);
-        return std::string(retcode);
-    }
-
-    void registerTestApiObject(const TestApiMethodCallback& callback)
-    {
-        auto handler = [callback](const std::string& objectPath,
-                          const std::string& interface,
-                          const std::string& methodName,
-                          GVariant* parameters,
-                          MethodResultBuilder::Pointer result) {
-            if (objectPath == testapi::OBJECT_PATH &&
-                interface == testapi::INTERFACE &&
-                methodName == testapi::METHOD) {
-                const gchar* argument = NULL;
-                g_variant_get(parameters, "(&s)", &argument);
-                if (callback) {
-                    callback(argument, result);
-                }
-            }
-        };
-        mClient->registerObject(testapi::OBJECT_PATH, testapi::DEFINITION, handler);
-    }
-
-    std::string testApiProxyCall(const std::string& target, const std::string& argument)
-    {
-        GVariant* parameters = g_variant_new("(s)", argument.c_str());
-        GVariantPtr result = proxyCall(target,
-                                       testapi::BUS_NAME,
-                                       testapi::OBJECT_PATH,
-                                       testapi::INTERFACE,
-                                       testapi::METHOD,
-                                       parameters);
-        const gchar* ret = NULL;
-        g_variant_get(result.get(), "(&s)", &ret);
-        return ret;
-    }
-
-
-    GVariantPtr proxyCall(const std::string& target,
-                          const std::string& busName,
-                          const std::string& objectPath,
-                          const std::string& interface,
-                          const std::string& method,
-                          GVariant* parameters)
-    {
-        GVariant* packedParameters = g_variant_new("(sssssv)",
-                                                   target.c_str(),
-                                                   busName.c_str(),
-                                                   objectPath.c_str(),
-                                                   interface.c_str(),
-                                                   method.c_str(),
-                                                   parameters);
-        GVariantPtr result = mClient->callMethod(api::zone::BUS_NAME,
-                                                 api::zone::OBJECT_PATH,
-                                                 api::zone::INTERFACE,
-                                                 api::METHOD_PROXY_CALL,
-                                                 packedParameters,
-                                                 "(v)");
-        GVariant* unpackedResult = NULL;
-        g_variant_get(result.get(), "(v)", &unpackedResult);
-        return GVariantPtr(unpackedResult, g_variant_unref);
+        auto result = mClient.callSync<api::FileMoveRequestIn, api::FileMoveRequestStatus>(
+            api::METHOD_FILE_MOVE_REQUEST,
+            std::make_shared<api::FileMoveRequestIn>(api::FileMoveRequestIn{dest, path}),
+            EVENT_TIMEOUT*10);
+        return result->value;
     }
 
 private:
-    const int mId;
-    DbusConnection::Pointer mClient;
-    bool mNameAcquired;
-    bool mPendingDisconnect;
-    std::mutex mMutex;
-    std::condition_variable mNameCondition;
-
-    std::string acquireAddress() const
-    {
-        std::string zoneId = "zone" + std::to_string(mId);
-        return "unix:path=/tmp/ut-run/" + zoneId + "/dbus/system_bus_socket";
-    }
+    epoll::ThreadDispatcher mDispatcher;
+    ipc::Client mClient;
 };
 
 typedef HostIPCAccessory HostAccessory;
-typedef ZoneDbusAccessory ZoneAccessory;
 
 #endif //DBUS_CONNECTION
 
@@ -889,6 +713,16 @@ 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);
@@ -907,37 +741,23 @@ BOOST_AUTO_TEST_CASE(NotifyActiveZone)
 
     auto handler = [](Latch& latch,
                       std::vector<std::string>& receivedSignalSources,
-                      const std::string& /*senderBusName*/,
-                      const std::string& objectPath,
-                      const std::string& interface,
-                      const std::string& signalName,
-                      GVariant* parameters)
+                      const api::Notification& notify)
         {
-            if (objectPath == api::zone::OBJECT_PATH &&
-                interface == api::zone::INTERFACE &&
-                signalName == api::zone::SIGNAL_NOTIFICATION &&
-                g_variant_is_of_type(parameters, G_VARIANT_TYPE("(sss)"))) {
-
-                const gchar* zone = NULL;
-                const gchar* application = NULL;
-                const gchar* message = NULL;
-                g_variant_get(parameters, "(&s&s&s)", &zone, &application, &message);
-                receivedSignalSources.push_back(zone);
-                if (application == TEST_APP_NAME && message == TEST_MESSAGE) {
-                    latch.set();
-                }
+            receivedSignalSources.push_back(notify.zone);
+            if (notify.application == TEST_APP_NAME && notify.message == TEST_MESSAGE) {
+                latch.set();
             }
         };
 
     using namespace std::placeholders;
     for (int i = 1; i <= TEST_DBUS_CONNECTION_ZONES_COUNT; ++i) {
-        connections[i]->signalSubscribe(std::bind(handler,
-                                             std::ref(signalReceivedLatch),
-                                             std::ref(signalReceivedSourcesMap[i]),
-                                             _1, _2, _3, _4, _5));
+        connections[i]->subscribeNotification(std::bind(handler,
+                                              std::ref(signalReceivedLatch),
+                                              std::ref(signalReceivedSourcesMap[i]),
+                                              _1));
     }
-    for (auto& dbus : connections) {
-        dbus.second->callMethodNotify();
+    for (auto& connection : connections) {
+        connection.second->callMethodNotify();
     }
 
     BOOST_REQUIRE(signalReceivedLatch.waitForN(connections.size() - 1u, EVENT_TIMEOUT));
@@ -959,43 +779,6 @@ BOOST_AUTO_TEST_CASE(NotifyActiveZone)
     connections.clear();
 }
 
-BOOST_AUTO_TEST_CASE(SwitchToDefault)
-{
-    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();
-
-    std::vector<std::unique_ptr<ZoneAccessory>> clients;
-    for (int i = 1; i <= TEST_DBUS_CONNECTION_ZONES_COUNT; ++i) {
-        clients.push_back(std::unique_ptr<ZoneAccessory>(new ZoneAccessory(i)));
-    }
-
-    for (auto& client : clients) {
-        client->setName(fake_power_manager_api::BUS_NAME);
-    }
-
-    auto isDefaultFocused = [&cm]() -> bool {
-        return cm.getRunningForegroundZoneId() == "zone1";
-    };
-
-    for (auto& client : clients) {
-        // TEST SWITCHING TO DEFAULT ZONE
-        // focus non-default zone
-        cm.focus("zone3");
-
-        // emit signal from dbus connection
-        client->emitSignal(fake_power_manager_api::OBJECT_PATH,
-                           fake_power_manager_api::INTERFACE,
-                           fake_power_manager_api::SIGNAL_DISPLAY_OFF,
-                           nullptr);
-
-        // check if default zone has focus
-        BOOST_CHECK(spinWaitFor(EVENT_TIMEOUT, isDefaultFocused));
-    }
-}
-
 BOOST_AUTO_TEST_CASE(MoveFile)
 {
     ZonesManager cm(TEST_CONFIG_PATH);
@@ -1014,31 +797,16 @@ BOOST_AUTO_TEST_CASE(MoveFile)
         connections[i] = std::unique_ptr<ZoneAccessory>(new ZoneAccessory(i));
     }
 
-    auto handler = [&](const std::string& /*senderBusName*/,
-                       const std::string& objectPath,
-                       const std::string& interface,
-                       const std::string& signalName,
-                       GVariant* parameters)
+    auto handler = [&](const api::Notification& notify)
         {
-            if (objectPath == api::zone::OBJECT_PATH &&
-                interface == api::zone::INTERFACE &&
-                signalName == api::zone::SIGNAL_NOTIFICATION &&
-                g_variant_is_of_type(parameters, G_VARIANT_TYPE("(sss)"))) {
-
-                const gchar* source = NULL;
-                const gchar* path = NULL;
-                const gchar* retcode = NULL;
-                g_variant_get(parameters, "(&s&s&s)", &source, &path, &retcode);
-
-                notificationSource = source;
-                notificationPath = path;
-                notificationRetcode = retcode;
+                notificationSource = notify.zone;
+                notificationPath = notify.application;
+                notificationRetcode = notify.message;
                 notificationLatch.set();
-            }
         };
 
     // subscribe the second (destination) zone for notifications
-    connections.at(2)->signalSubscribe(handler);
+    connections.at(2)->subscribeNotification(handler);
 
     const std::string TMP = "/tmp/ut-zones";
     const std::string NO_PATH = "path_doesnt_matter_here";
@@ -1051,28 +819,28 @@ BOOST_AUTO_TEST_CASE(MoveFile)
 
     // sending to a non existing zone
     BOOST_CHECK_EQUAL(connections.at(1)->callMethodMove(BUGGY_ZONE, NO_PATH),
-                      api::zone::FILE_MOVE_DESTINATION_NOT_FOUND);
+                      api::FILE_MOVE_DESTINATION_NOT_FOUND);
     BOOST_CHECK(notificationLatch.empty());
 
     // sending to self
     BOOST_CHECK_EQUAL(connections.at(1)->callMethodMove(ZONE1, NO_PATH),
-                      api::zone::FILE_MOVE_WRONG_DESTINATION);
+                      api::FILE_MOVE_WRONG_DESTINATION);
     BOOST_CHECK(notificationLatch.empty());
 
     // no permission to send
     BOOST_CHECK_EQUAL(connections.at(1)->callMethodMove(ZONE2, "/etc/secret1"),
-                      api::zone::FILE_MOVE_NO_PERMISSIONS_SEND);
+                      api::FILE_MOVE_NO_PERMISSIONS_SEND);
     BOOST_CHECK(notificationLatch.empty());
 
     // no permission to receive
     // TODO uncomment this after adding an api to change 'permittedTo*' config
     //BOOST_CHECK_EQUAL(connections.at(1)->callMethodMove(ZONE2, "/etc/secret2"),
-    //                  api::zone::FILE_MOVE_NO_PERMISSIONS_RECEIVE);
+    //                  api::FILE_MOVE_NO_PERMISSIONS_RECEIVE);
     //BOOST_CHECK(notificationLatch.empty());
 
     // non existing file
     BOOST_CHECK_EQUAL(connections.at(1)->callMethodMove(ZONE2, BUGGY_PATH),
-                      api::zone::FILE_MOVE_FAILED);
+                      api::FILE_MOVE_FAILED);
     BOOST_CHECK(notificationLatch.empty());
 
     // a working scenario
@@ -1085,20 +853,21 @@ BOOST_AUTO_TEST_CASE(MoveFile)
     BOOST_REQUIRE(utils::saveFileContent(ZONE1PATH + "/file", FILE_CONTENT));
 
     BOOST_CHECK_EQUAL(connections.at(1)->callMethodMove(ZONE2, TMP + "/file"),
-                      api::zone::FILE_MOVE_SUCCEEDED);
+                      api::FILE_MOVE_SUCCEEDED);
     BOOST_REQUIRE(notificationLatch.wait(EVENT_TIMEOUT));
     BOOST_REQUIRE(notificationLatch.empty());
     BOOST_CHECK_EQUAL(notificationSource, ZONE1);
     BOOST_CHECK_EQUAL(notificationPath, TMP + "/file");
-    BOOST_CHECK_EQUAL(notificationRetcode, api::zone::FILE_MOVE_SUCCEEDED);
+    BOOST_CHECK_EQUAL(notificationRetcode, api::FILE_MOVE_SUCCEEDED);
     BOOST_CHECK(!fs::exists(ZONE1PATH + "/file"));
     BOOST_CHECK_EQUAL(utils::readFileContent(ZONE2PATH + "/file"), FILE_CONTENT);
 
     fs::remove_all(ZONE1PATH, ec);
     fs::remove_all(ZONE2PATH, ec);
 }
+#endif
 
-BOOST_AUTO_TEST_CASE(AllowSwitchToDefault)
+BOOST_AUTO_TEST_CASE(SwitchToDefault)
 {
     ZonesManager cm(TEST_CONFIG_PATH);
     cm.createZone("zone1", ZONE_ACCESS_TEMPLATE);
@@ -1106,49 +875,21 @@ BOOST_AUTO_TEST_CASE(AllowSwitchToDefault)
     cm.createZone("zone3", ZONE_ACCESS_TEMPLATE);
     cm.restoreAll();
 
-    std::vector<std::unique_ptr<ZoneAccessory>> clients;
-    for (int i = 1; i <= TEST_DBUS_CONNECTION_ZONES_COUNT; ++i) {
-        clients.push_back(std::unique_ptr<ZoneAccessory>(new ZoneAccessory(i)));
-    }
-
-    for (auto& client : clients) {
-        client->setName(fake_power_manager_api::BUS_NAME);
-    }
+    HostAccessory host;
 
     auto isDefaultFocused = [&cm]() -> bool {
         return cm.getRunningForegroundZoneId() == "zone1";
     };
 
-    for (auto& client : clients) {
-        // focus non-default zone with allowed switching
-        cm.focus("zone3");
-
-        // emit signal from dbus connection
-        client->emitSignal(fake_power_manager_api::OBJECT_PATH,
-                           fake_power_manager_api::INTERFACE,
-                           fake_power_manager_api::SIGNAL_DISPLAY_OFF,
-                           nullptr);
-
-        // check if default zone has focus
-        BOOST_CHECK(spinWaitFor(EVENT_TIMEOUT, isDefaultFocused));
+    cm.focus("zone3");
 
-        // focus non-default zone with disabled switching
-        cm.focus("zone2");
+    host.signalSwitchToDefault();
 
-        // emit signal from dbus connection
-        client->emitSignal(fake_power_manager_api::OBJECT_PATH,
-                           fake_power_manager_api::INTERFACE,
-                           fake_power_manager_api::SIGNAL_DISPLAY_OFF,
-                           nullptr);
-
-        // now default zone should not be focused
-        // TODO uncomment this after adding an api to change 'switchToDefaultAfterTimeout'
-        //BOOST_CHECK(!spinWaitFor(UNEXPECTED_EVENT_TIMEOUT, isDefaultFocused));
-    }
+    // check if default zone has focus
+    BOOST_CHECK(spinWaitFor(EVENT_TIMEOUT, isDefaultFocused));
 }
 
-#ifdef DBUS_CONNECTION
-BOOST_AUTO_TEST_CASE(ProxyCall)
+BOOST_AUTO_TEST_CASE(AllowSwitchToDefault)
 {
     ZonesManager cm(TEST_CONFIG_PATH);
     cm.createZone("zone1", ZONE_ACCESS_TEMPLATE);
@@ -1156,152 +897,83 @@ BOOST_AUTO_TEST_CASE(ProxyCall)
     cm.createZone("zone3", ZONE_ACCESS_TEMPLATE);
     cm.restoreAll();
 
-    std::map<int, std::unique_ptr<DbusAccessory>> connections;
-    connections[0] = std::unique_ptr<DbusAccessory>(new HostAccessory());
-    for (int i = 1; i <= TEST_DBUS_CONNECTION_ZONES_COUNT; ++i) {
-        connections[i] = std::unique_ptr<DbusAccessory>(new ZoneAccessory(i));
-    }
+    HostAccessory host;
 
-    for (auto& dbus : connections) {
-        dbus.second->setName(testapi::BUS_NAME);
+    auto isDefaultFocused = [&cm]() -> bool {
+        return cm.getRunningForegroundZoneId() == "zone1";
+    };
 
-        const int id = dbus.first;
-        auto handler = [id](const std::string& argument, MethodResultBuilder::Pointer result) {
-            if (argument.empty()) {
-                result->setError("org.tizen.vasum.Error.Test", "Test error");
-            } else {
-                std::string ret = "reply from " + std::to_string(id) + ": " + argument;
-                result->set(g_variant_new("(s)", ret.c_str()));
-            }
-        };
-        dbus.second->registerTestApiObject(handler);
-    }
+    // focus non-default zone with allowed switching
+    cm.focus("zone3");
 
-    // host -> zone2
-    BOOST_CHECK_EQUAL("reply from 2: param1",
-                      connections.at(0)->testApiProxyCall("zone2",
-                                                     "param1"));
+    host.signalSwitchToDefault();
 
-    // host -> host
-    BOOST_CHECK_EQUAL("reply from 0: param2",
-                      connections.at(0)->testApiProxyCall("host",
-                                                     "param2"));
+    // check if default zone has focus
+    BOOST_CHECK(spinWaitFor(EVENT_TIMEOUT, isDefaultFocused));
+
+    // focus non-default zone with disabled switching
+    cm.focus("zone2");
+
+    host.signalSwitchToDefault();
 
-    // zone1 -> host
-    BOOST_CHECK_EQUAL("reply from 0: param3",
-                      connections.at(1)->testApiProxyCall("host",
-                                                     "param3"));
+    // now default zone should not be focused
+    // TODO uncomment this after adding an api to change 'switchToDefaultAfterTimeout'
+    //BOOST_CHECK(!spinWaitFor(UNEXPECTED_EVENT_TIMEOUT, isDefaultFocused));
+}
 
-    // zone1 -> zone2
-    BOOST_CHECK_EQUAL("reply from 2: param4",
-                      connections.at(1)->testApiProxyCall("zone2",
-                                                     "param4"));
+#ifdef DBUS_CONNECTION
+BOOST_AUTO_TEST_CASE(ProxyCall)
+{
+    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();
+
+    HostAccessory host;
+    host.setName(testapi::BUS_NAME);
+
+    auto handler = [](const std::string& argument, MethodResultBuilder::Pointer result) {
+        if (argument.empty()) {
+            result->setError("org.tizen.vasum.Error.Test", "Test error");
+        } else {
+            std::string ret = "reply from host: " + argument;
+            result->set(g_variant_new("(s)", ret.c_str()));
+        }
+    };
+    host.registerTestApiObject(handler);
 
-    // zone2 -> zone2
-    BOOST_CHECK_EQUAL("reply from 2: param5",
-                      connections.at(2)->testApiProxyCall("zone2",
-                                                     "param5"));
+    // host -> host
+    BOOST_CHECK_EQUAL("reply from host: param2",
+                      host.testApiProxyCall("host", "param2"));
 
     // host -> unknown
-    BOOST_CHECK_EXCEPTION(connections.at(0)->testApiProxyCall("unknown", "param"),
+    BOOST_CHECK_EXCEPTION(host.testApiProxyCall("unknown", "param"),
                           DbusCustomException,
                           WhatEquals("Unknown proxy call target"));
 
     // forwarding error
-    BOOST_CHECK_EXCEPTION(connections.at(0)->testApiProxyCall("host", ""),
+    BOOST_CHECK_EXCEPTION(host.testApiProxyCall("host", ""),
                           DbusCustomException,
                           WhatEquals("Test error"));
 
     // forbidden call
-    BOOST_CHECK_EXCEPTION(connections.at(0)->proxyCall("host",
-                                                       "org.fake",
-                                                       "/a/b",
-                                                       "c.d",
-                                                       "foo",
-                                                       g_variant_new("(s)", "arg")),
+    BOOST_CHECK_EXCEPTION(host.proxyCall("host",
+                                         "org.fake",
+                                         "/a/b",
+                                         "c.d",
+                                         "foo",
+                                         g_variant_new("(s)", "arg")),
                           DbusCustomException,
                           WhatEquals("Proxy call forbidden"));
 }
 #endif // DBUS_CONNECTION
 
 namespace {
-    const HostAccessory::Connections EXPECTED_CONNECTIONS_NONE = {
-        {"zone1", ""},
-        {"zone2", ""},
-        {"zone3", ""}};
-
-    const HostAccessory::Connections EXPECTED_CONNECTIONS_ALL = {
-        {"zone1",
-         "unix:path=/tmp/ut-run/zone1/dbus/system_bus_socket"},
-        {"zone2",
-         "unix:path=/tmp/ut-run/zone2/dbus/system_bus_socket"},
-        {"zone3",
-         "unix:path=/tmp/ut-run/zone3/dbus/system_bus_socket"}};
-} // namespace
-
-BOOST_AUTO_TEST_CASE(GetZoneConnections)
-{
-    ZonesManager cm(TEST_CONFIG_PATH);
-    HostAccessory host;
-    cm.createZone("zone1", ZONE_ACCESS_TEMPLATE);
-    cm.createZone("zone2", ZONE_ACCESS_TEMPLATE);
-    cm.createZone("zone3", ZONE_ACCESS_TEMPLATE);
-
-    BOOST_CHECK(EXPECTED_CONNECTIONS_NONE == host.callMethodGetZoneConnections());
-    cm.restoreAll();
-    BOOST_CHECK(EXPECTED_CONNECTIONS_ALL == host.callMethodGetZoneConnections());
-    cm.shutdownAll();
-    BOOST_CHECK(EXPECTED_CONNECTIONS_NONE == host.callMethodGetZoneConnections());
-}
-
-BOOST_AUTO_TEST_CASE(GetZoneConnectionsNoDbus)
-{
-    ZonesManager cm(TEST_CONFIG_PATH);
-    HostAccessory host;
-    cm.createZone("zone1", SIMPLE_TEMPLATE);
-    cm.createZone("zone2", SIMPLE_TEMPLATE);
-    cm.createZone("zone3", SIMPLE_TEMPLATE);
-
-    BOOST_CHECK(EXPECTED_CONNECTIONS_NONE == host.callMethodGetZoneConnections());
-    cm.restoreAll();
-    BOOST_CHECK(EXPECTED_CONNECTIONS_NONE == host.callMethodGetZoneConnections());
-    cm.shutdownAll();
-    BOOST_CHECK(EXPECTED_CONNECTIONS_NONE == host.callMethodGetZoneConnections());
-}
 
-BOOST_AUTO_TEST_CASE(ZoneConnectionsSignals)
-{
-    Latch signalLatch;
-    HostAccessory::Connections collectedConnections;
-    std::mutex collectedConnectionsMutex;
-
-    auto onSignal = [&] (const std::string& zoneId, const std::string& address) {
-        std::unique_lock<std::mutex> lock(collectedConnectionsMutex);
-        collectedConnections.insert(HostAccessory::Connections::value_type(zoneId, address));
-        signalLatch.set();
-    };
-
-    {
-        ZonesManager cm(TEST_CONFIG_PATH);
-        HostAccessory host;
-        host.subscribeZoneConnectionState(onSignal);
-        cm.createZone("zone1", ZONE_ACCESS_TEMPLATE);
-        cm.createZone("zone2", ZONE_ACCESS_TEMPLATE);
-        cm.createZone("zone3", ZONE_ACCESS_TEMPLATE);
-
-        BOOST_CHECK(signalLatch.empty());
-        BOOST_CHECK(collectedConnections.empty());
-
-        cm.restoreAll();
-
-        BOOST_REQUIRE(signalLatch.waitForN(TEST_DBUS_CONNECTION_ZONES_COUNT, EVENT_TIMEOUT));
-        BOOST_CHECK(signalLatch.empty());
-        std::unique_lock<std::mutex> lock(collectedConnectionsMutex);
-        BOOST_CHECK(EXPECTED_CONNECTIONS_ALL == collectedConnections);
-        collectedConnections.clear();
-    }
-}
+const std::set<std::string> EXPECTED_CONNECTIONS_NONE = { "zone1", "zone2", "zone3" };
 
+} // namespace
 
 BOOST_AUTO_TEST_CASE(GetZoneIds)
 {