IPC agnostic MethodResultBuilder 01/36601/10
authorJan Olszak <j.olszak@samsung.com>
Tue, 10 Mar 2015 12:35:55 +0000 (13:35 +0100)
committerPiotr Bartosiewicz <p.bartosiewi@partner.samsung.com>
Thu, 12 Mar 2015 12:57:18 +0000 (05:57 -0700)
[Feature]       ZoneManager and Zone doesn't know
                which IPC mechanism is used.
[Cause]         N/A
[Solution]      N/A
[Verification]  Build, run tests, run tests with valgrind

Change-Id: I852fa5ed3bcd105096cb7ca740f9e98fb8b6adba

17 files changed:
client/vasum-client-impl.cpp
common/api/dbus-method-result-builder.hpp [new file with mode: 0644]
common/api/ipc-method-result-builder.cpp [new file with mode: 0644]
common/api/ipc-method-result-builder.hpp [new file with mode: 0644]
common/api/messages.hpp [new file with mode: 0644]
common/api/method-result-builder.hpp [new file with mode: 0644]
server/host-connection.cpp
server/host-connection.hpp
server/host-dbus-definitions.hpp
server/zone-connection.cpp
server/zone-connection.hpp
server/zone.cpp
server/zone.hpp
server/zones-manager.cpp
server/zones-manager.hpp
tests/unit_tests/server/ut-zone-connection.cpp
tests/unit_tests/server/ut-zones-manager.cpp

index d8ba562..1ac4c3c 100644 (file)
@@ -74,7 +74,7 @@ void toDict(GVariant* in, VsmArrayString* keys, VsmArrayString* values)
     value_type* outv = (value_type*)calloc(size + 1, sizeof(value_type));
 
     g_variant_iter_init(&iter, in);
-    for (int i = 0; g_variant_iter_loop(&iter, "{ss}", &key, &value); i++) {
+    for (int i = 0; g_variant_iter_loop(&iter, "(ss)", &key, &value); i++) {
         outk[i] = strdup(key);
         outv[i] = strdup(value);
     }
@@ -377,7 +377,7 @@ VsmStatus Client::vsm_get_zone_dbuses(VsmArrayString* keys, VsmArrayString* valu
     VsmStatus ret = callMethod(HOST_INTERFACE,
                                api::host::METHOD_GET_ZONE_DBUSES,
                                NULL,
-                               "(a{ss})",
+                               "(a(ss))",
                                &out);
     if (ret != VSMCLIENT_SUCCESS) {
         return ret;
diff --git a/common/api/dbus-method-result-builder.hpp b/common/api/dbus-method-result-builder.hpp
new file mode 100644 (file)
index 0000000..99f3bc0
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+*  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+*
+*  Contact: Jan Olszak (j.olszak@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  Jan Olszak (j.olszak@samsung.com)
+ * @brief   Interface for result builders
+
+ */
+
+#ifndef COMMON_RESULT_DBUS_METHOD_RESULT_BUILDER_HPP
+#define COMMON_RESULT_DBUS_METHOD_RESULT_BUILDER_HPP
+
+#include "config.hpp"
+
+#include "api/method-result-builder.hpp"
+
+#include "dbus/connection.hpp"
+#include "config/manager.hpp"
+
+#include <memory>
+#include <functional>
+
+namespace vasum {
+namespace api {
+
+template<typename Data>
+class DbusMethodResultBuilder: public MethodResultBuilder {
+public:
+    DbusMethodResultBuilder(const dbus::MethodResultBuilder::Pointer& methodResultBuilderPtr);
+    ~DbusMethodResultBuilder() {}
+
+private:
+    void setImpl(const std::shared_ptr<void>& data) override;
+    void setVoid() override;
+    void setError(const std::string& name, const std::string& message) override;
+
+    dbus::MethodResultBuilder::Pointer mMethodResultBuilderPtr;
+    std::function<GVariant*(std::shared_ptr<void>)> mSerialize;
+};
+
+template<typename Data>
+DbusMethodResultBuilder<Data>::DbusMethodResultBuilder(const dbus::MethodResultBuilder::Pointer& methodResultBuilderPtr)
+    : mMethodResultBuilderPtr(methodResultBuilderPtr)
+{
+    mSerialize = [](const std::shared_ptr<void> data)->GVariant* {
+        return config::saveToGVariant(*std::static_pointer_cast<Data>(data));
+    };
+}
+
+template<typename Data>
+void DbusMethodResultBuilder<Data>::setImpl(const std::shared_ptr<void>& data)
+{
+    GVariant* parameters = mSerialize(data);
+    mMethodResultBuilderPtr->set(parameters);
+}
+
+template<typename Data>
+void DbusMethodResultBuilder<Data>::setVoid()
+{
+    mMethodResultBuilderPtr->setVoid();
+}
+
+template<typename Data>
+void DbusMethodResultBuilder<Data>::setError(const std::string& name, const std::string& message)
+{
+    mMethodResultBuilderPtr->setError(name, message);
+}
+
+} // namespace result
+} // namespace vasum
+
+#endif // COMMON_RESULT_DBUS_METHOD_RESULT_BUILDER_HPP
diff --git a/common/api/ipc-method-result-builder.cpp b/common/api/ipc-method-result-builder.cpp
new file mode 100644 (file)
index 0000000..4ea2845
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+*  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+*
+*  Contact: Jan Olszak (j.olszak@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  Jan Olszak (j.olszak@samsung.com)
+ * @brief   Class for sending the result of a method
+ */
+
+#include "api/ipc-method-result-builder.hpp"
+
+namespace vasum {
+namespace api {
+
+IPCMethodResultBuilder::IPCMethodResultBuilder(const ipc::MethodResult::Pointer& methodResultPtr)
+    : mMethodResultPtr(methodResultPtr)
+{
+}
+
+void IPCMethodResultBuilder::setImpl(const std::shared_ptr<void>& data)
+{
+    mMethodResultPtr->set(data);
+}
+
+void IPCMethodResultBuilder::setVoid()
+{
+    mMethodResultPtr->setVoid();
+}
+
+void IPCMethodResultBuilder::setError(const std::string& , const std::string& message)
+{
+    // TODO: Change int codes to string names in IPC MethodResult
+    mMethodResultPtr->setError(1, message);
+}
+
+} // namespace result
+} // namespace vasum
+
+
diff --git a/common/api/ipc-method-result-builder.hpp b/common/api/ipc-method-result-builder.hpp
new file mode 100644 (file)
index 0000000..7b03ece
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+*  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+*
+*  Contact: Jan Olszak (j.olszak@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  Jan Olszak (j.olszak@samsung.com)
+ * @brief   Interface for result builders
+
+ */
+
+#ifndef COMMON_RESULT_IPC_METHOD_RESULT_BUILDER_HPP
+#define COMMON_RESULT_IPC_METHOD_RESULT_BUILDER_HPP
+
+#include "config.hpp"
+
+#include "api/method-result-builder.hpp"
+#include "ipc/method-result.hpp"
+
+#include <memory>
+
+namespace vasum {
+namespace api {
+
+class IPCMethodResultBuilder: public MethodResultBuilder {
+public:
+    IPCMethodResultBuilder(const ipc::MethodResult::Pointer& methodResult);
+    ~IPCMethodResultBuilder() {}
+
+private:
+    void setImpl(const std::shared_ptr<void>& data) override;
+    void setVoid() override;
+    void setError(const std::string& name, const std::string& message) override;
+
+    ipc::MethodResult::Pointer mMethodResultPtr;
+};
+
+
+} // namespace result
+} // namespace vasum
+
+#endif // COMMON_RESULT_IPC_METHOD_RESULT_BUILDER_HPP
diff --git a/common/api/messages.hpp b/common/api/messages.hpp
new file mode 100644 (file)
index 0000000..6c6d4da
--- /dev/null
@@ -0,0 +1,404 @@
+/*
+ *  Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Contact: Jan Olszak (j.olszak@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  Jan Olszak (j.olszak@samsung.com)
+ * @brief   Host's internal IPC messages declaration
+ */
+
+
+#ifndef COMMON_API_MESSAGES
+#define COMMON_API_MESSAGES
+
+#include "config/fields.hpp"
+#include <string>
+#include <vector>
+
+namespace vasum {
+namespace api {
+
+struct Void {
+    CONFIG_REGISTER_EMPTY
+};
+
+struct String {
+    std::string value;
+
+    CONFIG_REGISTER
+    (
+        value
+    )
+};
+
+struct StringPair {
+    std::string first;
+    std::string second;
+
+    CONFIG_REGISTER
+    (
+        first,
+        second
+    )
+};
+
+struct VectorOfStrings {
+    std::vector<std::string> values;
+
+    CONFIG_REGISTER
+    (
+        values
+    )
+};
+
+struct VectorOfStringPairs {
+    std::vector<api::StringPair> values;
+
+    CONFIG_REGISTER
+    (
+        values
+    )
+};
+
+typedef api::String ZoneId;
+typedef api::String Declaration;
+typedef api::String FileMoveRequestStatus;
+typedef api::VectorOfStrings ZoneIds;
+typedef api::VectorOfStrings Declarations;
+typedef api::VectorOfStrings NetDevList;
+typedef api::VectorOfStringPairs Dbuses;
+typedef api::VectorOfStringPairs NetDevAttrs;
+
+struct ZoneInfo {
+    std::string id;
+    int vt;
+    std::string state;
+    std::string rootPath;
+
+    CONFIG_REGISTER
+    (
+        id,
+        vt,
+        state,
+        rootPath
+    )
+};
+
+// struct MethodSetActiveZoneConfig {
+//     std::string id;
+
+//     CONFIG_REGISTER
+//     (
+//         id
+//     )
+// };
+
+// struct MethodGetZoneDbusesConfig {
+//     CONFIG_REGISTER_EMPTY
+// };
+
+// struct MethodGetZoneIdListConfig {
+//     CONFIG_REGISTER_EMPTY
+// };
+
+
+// struct MethodGetActiveZoneIdConfig {
+//     CONFIG_REGISTER_EMPTY
+// };
+
+
+// struct MethodGetZoneInfoConfig {
+//     std::string id;
+
+//     CONFIG_REGISTER
+//     (
+//         id
+//     )
+// };
+
+// struct MethodSetNetDevAttrsConfig {
+//     std::string zone;
+//     std::string netdev;
+
+//     struct Store {
+//         std::string key;
+//         std::string value;
+
+//         CONFIG_REGISTER
+//         (
+//             key,
+//             value
+//         )
+//     };
+
+//     std::vector<Store> attrs;
+
+//     CONFIG_REGISTER
+//     (
+//         zone,
+//         netdev,
+//         attrs
+//     )
+// };
+
+// struct MethodGetNetDevAttrsConfig {
+//     std::string zone;
+//     std::string netdev;
+
+//     CONFIG_REGISTER
+//     (
+//         zone,
+//         netdev
+//     )
+// };
+
+// struct MethodGetNetDevListConfig {
+//     std::string zone;
+
+//     CONFIG_REGISTER
+//     (
+//         zone
+//     )
+// };
+
+// struct MethodCreateNetDevVethConfig {
+//     std::string id;
+//     std::string zoneDev;
+//     std::string hostDev;
+
+//     CONFIG_REGISTER
+//     (
+//         id,
+//         zoneDev,
+//         hostDev
+//     )
+// };
+
+// struct MethodCreateNetDevMacvlanConfig {
+//     std::string id;
+//     std::string zoneDev;
+//     std::string hostDev;
+
+//     CONFIG_REGISTER
+//     (
+//         id,
+//         zoneDev,
+//         hostDev
+//     )
+// };
+
+// struct MethodCreateNetDevPhysConfig {
+//     std::string id;
+//     std::string devId;
+
+//     CONFIG_REGISTER
+//     (
+//         id,
+//         devId
+//     )
+// };
+
+// struct MethodGetDeclareFileConfig {
+//     std::string zone;
+//     int32_t type;
+//     std::string path;
+//     int32_t flags;
+//     int32_t mode;
+
+//     CONFIG_REGISTER
+//     (
+//         zone,
+//         type,
+//         path,
+//         flags,
+//         mode
+//     )
+// };
+
+// struct MethodGetDeclareMountConfig {
+//     std::string source;
+//     std::string zone;
+//     std::string target;
+//     uint64_t flags;
+//     std::string data;
+
+//     CONFIG_REGISTER
+//     (
+//         source,
+//         zone,
+//         target,
+//         flags,
+//         data
+//     )
+// };
+
+// struct MethodGetDeclareLinkConfig {
+//     std::string source;
+//     std::string zone;
+//     std::string target;
+
+//     CONFIG_REGISTER
+//     (
+//         source,
+//         zone,
+//         target
+//     )
+// };
+
+// struct MethodGetDeclarationConfig {
+//     std::string zone;
+//     std::string declarationId;
+
+//     CONFIG_REGISTER
+//     (
+//         zone,
+//         declarationId
+//     )
+// };
+
+// struct MethodRemoveDeclarationConfig {
+//     std::string id;
+//     std::string declarationId;
+
+//     CONFIG_REGISTER
+//     (
+//         id,
+//         declarationId
+//     )
+// };
+
+// struct MethodCreateZoneConfig {
+//     std::string id;
+//     std::string templateName;
+
+//     CONFIG_REGISTER
+//     (
+//         id,
+//         templateName
+//     )
+// };
+
+// struct MethodDestroyZoneConfig {
+//     std::string id;
+
+//     CONFIG_REGISTER
+//     (
+//         id
+//     )
+// };
+
+
+// struct MethodShutdownZoneConfig {
+//     std::string id;
+
+//     CONFIG_REGISTER
+//     (
+//         id
+//     )
+// };
+
+// struct MethodStartZoneConfig {
+//     std::string id;
+
+//     CONFIG_REGISTER
+//     (
+//         id
+//     )
+// };
+
+// struct MethodLockZoneConfig {
+//     std::string id;
+
+//     CONFIG_REGISTER
+//     (
+//         id
+//     )
+// };
+
+// struct MethodUnlockZoneConfig {
+//     std::string id;
+
+//     CONFIG_REGISTER
+//     (
+//         id
+//     )
+// };
+
+// struct MethodGrantDeviceConfig {
+//     std::string id;
+//     std::string device;
+//     uint32_t flags;
+
+//     CONFIG_REGISTER
+//     (
+//         id,
+//         device,
+//         flags
+//     )
+// };
+
+// struct MethodRevokeDeviceConfig {
+//     std::string id;
+//     std::string device;
+
+//     CONFIG_REGISTER
+//     (
+//         id,
+//         device
+//     )
+// };
+
+// TODO: Agregate configs if it makes sense. For example: MethodLockZoneConfig and MethodUnlockZoneConfig
+
+
+// Zone:
+// struct MethodNotifyActiveZoneConfig {
+//     std::string application;
+//     std::string message;
+
+//     CONFIG_REGISTER
+//     (
+//         application,
+//         message
+//     )
+// };
+
+// struct MethodFileMoveRequest {
+//     std::string destination;
+//     std::string path;
+
+//     CONFIG_REGISTER
+//     (
+//         destination,
+//         path
+//     )
+// };
+
+// struct MethodFileMoveRequestResult {
+//     std::string result;
+
+//     CONFIG_REGISTER
+//     (
+//         result
+//     )
+// };
+
+} // namespace api
+} // namespace vasum
+
+#endif // COMMON_API_MESSAGES
diff --git a/common/api/method-result-builder.hpp b/common/api/method-result-builder.hpp
new file mode 100644 (file)
index 0000000..04ede40
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+*  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+*
+*  Contact: Jan Olszak (j.olszak@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  Jan Olszak (j.olszak@samsung.com)
+ * @brief   Interface for result builders
+
+ */
+
+#ifndef COMMON_RESULT_METHOD_RESULT_BUILDER_HPP
+#define COMMON_RESULT_METHOD_RESULT_BUILDER_HPP
+
+#include <memory>
+
+#include "config/is-union.hpp"
+
+namespace vasum {
+namespace api {
+
+/**
+ * An interface used to set a result to a method call.
+ */
+class MethodResultBuilder {
+public:
+    typedef std::shared_ptr<MethodResultBuilder> Pointer;
+
+    virtual ~MethodResultBuilder() {}
+    virtual void setVoid() = 0;
+    virtual void setError(const std::string& name, const std::string& message) = 0;
+
+    template<typename Data>
+    void set(const std::shared_ptr<Data>& data)
+    {
+        static_assert(config::isVisitable<Data>::value, "Use only libConfig's structures");
+        setImpl(data);
+    }
+
+private:
+    virtual void setImpl(const std::shared_ptr<void>& data) =0;
+
+};
+
+} // namespace api
+} // namespace vasum
+
+#endif // COMMON_RESULT_METHOD_RESULT_BUILDER_HPP
index 6790480..a1a7448 100644 (file)
@@ -27,6 +27,8 @@
 #include "host-connection.hpp"
 #include "host-dbus-definitions.hpp"
 #include "exception.hpp"
+#include "api/dbus-method-result-builder.hpp"
+#include "api/messages.hpp"
 
 #include "logger/logger.hpp"
 
@@ -65,7 +67,7 @@ HostConnection::HostConnection()
     mDbusConnection->registerObject(api::host::OBJECT_PATH,
                                     api::host::DEFINITION,
                                     std::bind(&HostConnection::onMessageCall,
-                                              this, _1, _2, _3, _4, _5));
+                                            this, _1, _2, _3, _4, _5));
 
     LOGD("Connected");
 }
@@ -246,14 +248,16 @@ void HostConnection::onMessageCall(const std::string& objectPath,
         g_variant_get(parameters, "(&s)", &id);
 
         if (mSetActiveZoneCallback) {
-            mSetActiveZoneCallback(id, result);
+            auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Void>>(result);
+            mSetActiveZoneCallback(id, rb);
         }
         return;
     }
 
     if (methodName == api::host::METHOD_GET_ZONE_DBUSES) {
         if (mGetZoneDbusesCallback) {
-            mGetZoneDbusesCallback(result);
+            auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Dbuses>>(result);
+            mGetZoneDbusesCallback(rb);
         }
         return;
     }
@@ -287,31 +291,34 @@ void HostConnection::onMessageCall(const std::string& objectPath,
         return;
     }
 
-    if (methodName == api::host::METHOD_GET_ZONE_ID_LIST){
-        if (mGetZoneIdsCallback){
-            mGetZoneIdsCallback(result);
+    if (methodName == api::host::METHOD_GET_ZONE_ID_LIST) {
+        if (mGetZoneIdsCallback) {
+            auto rb = std::make_shared<api::DbusMethodResultBuilder<api::ZoneIds>>(result);
+            mGetZoneIdsCallback(rb);
         }
         return;
     }
 
-    if (methodName == api::host::METHOD_GET_ACTIVE_ZONE_ID){
-        if (mGetActiveZoneIdCallback){
-            mGetActiveZoneIdCallback(result);
+    if (methodName == api::host::METHOD_GET_ACTIVE_ZONE_ID) {
+        if (mGetActiveZoneIdCallback) {
+            auto rb = std::make_shared<api::DbusMethodResultBuilder<api::ZoneId>>(result);
+            mGetActiveZoneIdCallback(rb);
         }
         return;
     }
 
-    if (methodName == api::host::METHOD_GET_ZONE_INFO){
+    if (methodName == api::host::METHOD_GET_ZONE_INFO) {
         const gchar* id = NULL;
         g_variant_get(parameters, "(&s)", &id);
 
         if (mGetZoneInfoCallback) {
-            mGetZoneInfoCallback(id, result);
+            auto rb = std::make_shared<api::DbusMethodResultBuilder<api::ZoneInfo>>(result);
+            mGetZoneInfoCallback(id, rb);
         }
         return;
     }
 
-    if (methodName == api::host::METHOD_SET_NETDEV_ATTRS){
+    if (methodName == api::host::METHOD_SET_NETDEV_ATTRS) {
         const gchar* zone = NULL;
         const gchar* netdev = NULL;
         GVariantIter* iter;
@@ -324,26 +331,29 @@ void HostConnection::onMessageCall(const std::string& objectPath,
         }
         g_variant_iter_free(iter);
         if (mSetNetdevAttrsCallback) {
-            mSetNetdevAttrsCallback(zone, netdev, attrs, result);
+            auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Void>>(result);
+            mSetNetdevAttrsCallback(zone, netdev, attrs, rb);
         }
         return;
     }
 
-    if (methodName == api::host::METHOD_GET_NETDEV_ATTRS){
+    if (methodName == api::host::METHOD_GET_NETDEV_ATTRS) {
         const gchar* zone = NULL;
         const gchar* netdev = NULL;
         g_variant_get(parameters, "(&s&s)", &zone, &netdev);
         if (mGetNetdevAttrsCallback) {
-            mGetNetdevAttrsCallback(zone, netdev, result);
+            auto rb = std::make_shared<api::DbusMethodResultBuilder<api::NetDevAttrs>>(result);
+            mGetNetdevAttrsCallback(zone, netdev, rb);
         }
         return;
     }
 
-    if (methodName == api::host::METHOD_GET_NETDEV_LIST){
+    if (methodName == api::host::METHOD_GET_NETDEV_LIST) {
         const gchar* zone = NULL;
         g_variant_get(parameters, "(&s)", &zone);
         if (mGetNetdevListCallback) {
-            mGetNetdevListCallback(zone, result);
+            auto rb = std::make_shared<api::DbusMethodResultBuilder<api::NetDevList>>(result);
+            mGetNetdevListCallback(zone, rb);
         }
         return;
     }
@@ -355,7 +365,8 @@ void HostConnection::onMessageCall(const std::string& objectPath,
         const gchar* hostDev = NULL;
         g_variant_get(parameters, "(&s&s&s)", &id, &zoneDev, &hostDev);
         if (mCreateNetdevVethCallback) {
-            mCreateNetdevVethCallback(id, zoneDev, hostDev, result);
+            auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Void>>(result);
+            mCreateNetdevVethCallback(id, zoneDev, hostDev, rb);
         }
         return;
     }
@@ -367,7 +378,8 @@ void HostConnection::onMessageCall(const std::string& objectPath,
         guint32 mode;
         g_variant_get(parameters, "(&s&s&su)", &id, &zoneDev, &hostDev, &mode);
         if (mCreateNetdevMacvlanCallback) {
-            mCreateNetdevMacvlanCallback(id, zoneDev, hostDev, mode, result);
+            auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Void>>(result);
+            mCreateNetdevMacvlanCallback(id, zoneDev, hostDev, mode, rb);
         }
     }
 
@@ -376,7 +388,8 @@ void HostConnection::onMessageCall(const std::string& objectPath,
         const gchar* devId = NULL;
         g_variant_get(parameters, "(&s&s)", &id, &devId);
         if (mCreateNetdevPhysCallback) {
-            mCreateNetdevPhysCallback(id, devId, result);
+            auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Void>>(result);
+            mCreateNetdevPhysCallback(id, devId, rb);
         }
     }
 
@@ -389,7 +402,8 @@ void HostConnection::onMessageCall(const std::string& objectPath,
         g_variant_get(parameters, "(&si&sii)", &zone, &type, &path, &flags, &mode);
 
         if (mDeclareFileCallback) {
-            mDeclareFileCallback(zone, type, path, flags, mode, result);
+            auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Declaration>>(result);
+            mDeclareFileCallback(zone, type, path, flags, mode, rb);
         }
         return;
     }
@@ -411,7 +425,8 @@ void HostConnection::onMessageCall(const std::string& objectPath,
                       &data);
 
         if (mDeclareMountCallback) {
-            mDeclareMountCallback(source, zone, target, type, flags, data, result);
+            auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Declaration>>(result);
+            mDeclareMountCallback(source, zone, target, type, flags, data, rb);
         }
         return;
     }
@@ -423,7 +438,8 @@ void HostConnection::onMessageCall(const std::string& objectPath,
         g_variant_get(parameters, "(&s&s&s)", &source, &zone, &target);
 
         if (mDeclareLinkCallback) {
-            mDeclareLinkCallback(source, zone, target, result);
+            auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Declaration>>(result);
+            mDeclareLinkCallback(source, zone, target, rb);
         }
         return;
     }
@@ -433,7 +449,8 @@ void HostConnection::onMessageCall(const std::string& objectPath,
         g_variant_get(parameters, "(&s)", &zone);
 
         if (mGetDeclarationsCallback) {
-            mGetDeclarationsCallback(zone, result);
+            auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Declarations>>(result);
+            mGetDeclarationsCallback(zone, rb);
         }
         return;
     }
@@ -444,7 +461,8 @@ void HostConnection::onMessageCall(const std::string& objectPath,
         g_variant_get(parameters, "(&s&s)", &zone, &declarationId);
 
         if (mRemoveDeclarationCallback) {
-            mRemoveDeclarationCallback(zone, declarationId, result);
+            auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Void>>(result);
+            mRemoveDeclarationCallback(zone, declarationId, rb);
         }
         return;
     }
@@ -454,8 +472,9 @@ void HostConnection::onMessageCall(const std::string& objectPath,
         const gchar* templateName = NULL;
         g_variant_get(parameters, "(&s&s)", &id, &templateName);
 
-        if (mCreateZoneCallback){
-            mCreateZoneCallback(id, templateName, result);
+        if (mCreateZoneCallback) {
+            auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Void>>(result);
+            mCreateZoneCallback(id, templateName, rb);
         }
         return;
     }
@@ -464,8 +483,9 @@ void HostConnection::onMessageCall(const std::string& objectPath,
         const gchar* id = NULL;
         g_variant_get(parameters, "(&s)", &id);
 
-        if (mDestroyZoneCallback){
-            mDestroyZoneCallback(id, result);
+        if (mDestroyZoneCallback) {
+            auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Void>>(result);
+            mDestroyZoneCallback(id, rb);
         }
         return;
     }
@@ -474,8 +494,9 @@ void HostConnection::onMessageCall(const std::string& objectPath,
         const gchar* id = NULL;
         g_variant_get(parameters, "(&s)", &id);
 
-        if (mShutdownZoneCallback){
-            mShutdownZoneCallback(id, result);
+        if (mShutdownZoneCallback) {
+            auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Void>>(result);
+            mShutdownZoneCallback(id, rb);
         }
     }
 
@@ -483,8 +504,9 @@ void HostConnection::onMessageCall(const std::string& objectPath,
         const gchar* id = NULL;
         g_variant_get(parameters, "(&s)", &id);
 
-        if (mStartZoneCallback){
-            mStartZoneCallback(id, result);
+        if (mStartZoneCallback) {
+            auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Void>>(result);
+            mStartZoneCallback(id, rb);
         }
     }
 
@@ -492,8 +514,9 @@ void HostConnection::onMessageCall(const std::string& objectPath,
         const gchar* id = NULL;
         g_variant_get(parameters, "(&s)", &id);
 
-        if (mLockZoneCallback){
-            mLockZoneCallback(id, result);
+        if (mLockZoneCallback) {
+            auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Void>>(result);
+            mLockZoneCallback(id, rb);
         }
         return;
     }
@@ -502,8 +525,9 @@ void HostConnection::onMessageCall(const std::string& objectPath,
         const gchar* id = NULL;
         g_variant_get(parameters, "(&s)", &id);
 
-        if (mUnlockZoneCallback){
-            mUnlockZoneCallback(id, result);
+        if (mUnlockZoneCallback) {
+            auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Void>>(result);
+            mUnlockZoneCallback(id, rb);
         }
         return;
     }
@@ -514,8 +538,9 @@ void HostConnection::onMessageCall(const std::string& objectPath,
         uint32_t flags;
         g_variant_get(parameters, "(&s&su)", &id, &device, &flags);
 
-        if (mGrantDeviceCallback){
-            mGrantDeviceCallback(id, device, flags, result);
+        if (mGrantDeviceCallback) {
+            auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Void>>(result);
+            mGrantDeviceCallback(id, device, flags, rb);
         }
         return;
     }
@@ -525,8 +550,9 @@ void HostConnection::onMessageCall(const std::string& objectPath,
         const gchar* device = NULL;
         g_variant_get(parameters, "(&s&s)", &id, &device);
 
-        if (mRevokeDeviceCallback){
-            mRevokeDeviceCallback(id, device, result);
+        if (mRevokeDeviceCallback) {
+            auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Void>>(result);
+            mRevokeDeviceCallback(id, device, rb);
         }
         return;
     }
index 569c68f..3ef8cdf 100644 (file)
@@ -27,6 +27,7 @@
 #define SERVER_HOST_CONNECTION_HPP
 
 #include "dbus/connection.hpp"
+#include "api/method-result-builder.hpp"
 
 #include <mutex>
 #include <condition_variable>
@@ -53,48 +54,48 @@ public:
                                GVariant* parameters,
                                dbus::MethodResultBuilder::Pointer result
                               )> ProxyCallCallback;
-    typedef std::function<void(dbus::MethodResultBuilder::Pointer result
+    typedef std::function<void(api::MethodResultBuilder::Pointer result
                               )> GetZoneDbusesCallback;
-    typedef std::function<void(dbus::MethodResultBuilder::Pointer result
+    typedef std::function<void(api::MethodResultBuilder::Pointer result
                               )> GetZoneIdsCallback;
-    typedef std::function<void(dbus::MethodResultBuilder::Pointer result
+    typedef std::function<void(api::MethodResultBuilder::Pointer result
                               )> GetActiveZoneIdCallback;
     typedef std::function<void(const std::string& id,
-                               dbus::MethodResultBuilder::Pointer result
+                               api::MethodResultBuilder::Pointer result
                               )> GetZoneInfoCallback;
     typedef std::function<void(const std::string& zone,
                                const std::string& netdev,
                                const std::vector<std::tuple<std::string, std::string>>& attrs,
-                               dbus::MethodResultBuilder::Pointer result
+                               api::MethodResultBuilder::Pointer result
                               )> SetNetdevAttrsCallback;
     typedef std::function<void(const std::string& zone,
                                const std::string& netdev,
-                               dbus::MethodResultBuilder::Pointer result
+                               api::MethodResultBuilder::Pointer result
                               )> GetNetdevAttrsCallback;
     typedef std::function<void(const std::string& zone,
-                               dbus::MethodResultBuilder::Pointer result
+                               api::MethodResultBuilder::Pointer result
                               )> GetNetdevListCallback;
     typedef std::function<void(const std::string& zone,
                                const std::string& netdev,
                                const std::string& hostDev,
-                               dbus::MethodResultBuilder::Pointer result
+                               api::MethodResultBuilder::Pointer result
                               )> CreateNetdevVethCallback;
     typedef std::function<void(const std::string& id,
                                const std::string& zoneDev,
                                const std::string& hostDev,
                                const uint32_t& mode,
-                               dbus::MethodResultBuilder::Pointer result
+                               api::MethodResultBuilder::Pointer result
                               )> CreateNetdevMacvlanCallback;
     typedef std::function<void(const std::string& id,
                                const std::string& devId,
-                               dbus::MethodResultBuilder::Pointer result
+                               api::MethodResultBuilder::Pointer result
                               )> CreateNetdevPhysCallback;
     typedef std::function<void(const std::string& zone,
                                const int32_t& type,
                                const std::string& path,
                                const int32_t& flags,
                                const int32_t& mode,
-                               dbus::MethodResultBuilder::Pointer result
+                               api::MethodResultBuilder::Pointer result
                               )> DeclareFileCallback;
     typedef std::function<void(const std::string& source,
                                const std::string& zone,
@@ -102,50 +103,50 @@ public:
                                const std::string& type,
                                const uint64_t& flags,
                                const std::string& data,
-                               dbus::MethodResultBuilder::Pointer result
+                               api::MethodResultBuilder::Pointer result
                               )> DeclareMountCallback;
     typedef std::function<void(const std::string& source,
                                const std::string& zone,
                                const std::string& target,
-                               dbus::MethodResultBuilder::Pointer result
+                               api::MethodResultBuilder::Pointer result
                               )> DeclareLinkCallback;
     typedef std::function<void(const std::string& id,
-                               dbus::MethodResultBuilder::Pointer result
+                               api::MethodResultBuilder::Pointer result
                               )> GetDeclarationsCallback;
     typedef std::function<void(const std::string& id,
                                const std::string& declarationId,
-                               dbus::MethodResultBuilder::Pointer result
+                               api::MethodResultBuilder::Pointer result
                               )> RemoveDeclarationCallback;
     typedef std::function<void(const std::string& id,
-                               dbus::MethodResultBuilder::Pointer result
+                               api::MethodResultBuilder::Pointer result
                               )> SetActiveZoneCallback;
     typedef std::function<void(const std::string& id,
                                const std::string& templateName,
-                               dbus::MethodResultBuilder::Pointer result
+                               api::MethodResultBuilder::Pointer result
                               )> CreateZoneCallback;
     typedef std::function<void(const std::string& id,
-                               dbus::MethodResultBuilder::Pointer result
+                               api::MethodResultBuilder::Pointer result
                               )> DestroyZoneCallback;
     typedef std::function<void(const std::string& id,
-                               dbus::MethodResultBuilder::Pointer result
+                               api::MethodResultBuilder::Pointer result
                               )> ShutdownZoneCallback;
     typedef std::function<void(const std::string& id,
-                               dbus::MethodResultBuilder::Pointer result
+                               api::MethodResultBuilder::Pointer result
                               )> StartZoneCallback;
     typedef std::function<void(const std::string& id,
-                               dbus::MethodResultBuilder::Pointer result
+                               api::MethodResultBuilder::Pointer result
                               )> LockZoneCallback;
     typedef std::function<void(const std::string& id,
-                               dbus::MethodResultBuilder::Pointer result
+                               api::MethodResultBuilder::Pointer result
                               )> UnlockZoneCallback;
     typedef std::function<void(const std::string& id,
                                const std::string& device,
                                uint32_t flags,
-                               dbus::MethodResultBuilder::Pointer result
+                               api::MethodResultBuilder::Pointer result
                               )> GrantDeviceCallback;
     typedef std::function<void(const std::string& id,
                                const std::string& device,
-                               dbus::MethodResultBuilder::Pointer result
+                               api::MethodResultBuilder::Pointer result
                               )> RevokeDeviceCallback;
 
     /**
@@ -171,7 +172,7 @@ public:
     /**
      * Register a callback called to get the active zone id
      */
-    void setGetActiveZoneIdCallback(const GetZoneIdsCallback& callback);
+    void setGetActiveZoneIdCallback(const GetActiveZoneIdCallback& callback);
 
     /**
      * Register a callback called to get the zone informations
index 2c2a201..34d64eb 100644 (file)
@@ -79,7 +79,7 @@ const std::string DEFINITION =
     "      <arg type='v' name='result' direction='out'/>"
     "    </method>"
     "    <method name='" + METHOD_GET_ZONE_DBUSES + "'>"
-    "      <arg type='a{ss}' name='dbuses' direction='out'/>"
+    "      <arg type='a(ss)' name='dbuses' direction='out'/>"
     "    </method>"
     "    <method name='" + METHOD_GET_ZONE_ID_LIST + "'>"
     "      <arg type='as' name='result' direction='out'/>"
index 35341b3..a86886c 100644 (file)
@@ -30,6 +30,9 @@
 // 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"
 
 
@@ -139,10 +142,10 @@ void ZoneConnection::setDisplayOffCallback(const DisplayOffCallback& callback)
     mDisplayOffCallback = callback;
 }
 
-void ZoneConnection::setFileMoveRequestCallback(
-    const FileMoveRequestCallback& callback)
+void ZoneConnection::setFileMoveCallback(
+    const FileMoveCallback& callback)
 {
-    mFileMoveRequestCallback = callback;
+    mFileMoveCallback = callback;
 }
 
 void ZoneConnection::setProxyCallCallback(const ProxyCallCallback& callback)
@@ -165,8 +168,8 @@ void ZoneConnection::onMessageCall(const std::string& objectPath,
         const gchar* message = NULL;
         g_variant_get(parameters, "(&s&s)", &application, &message);
         if (mNotifyActiveZoneCallback) {
-            mNotifyActiveZoneCallback(application, message);
-            result->setVoid();
+            auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Void>>(result);
+            mNotifyActiveZoneCallback(application, message, rb);
         }
     }
 
@@ -174,8 +177,9 @@ void ZoneConnection::onMessageCall(const std::string& objectPath,
         const gchar* destination = NULL;
         const gchar* path = NULL;
         g_variant_get(parameters, "(&s&s)", &destination, &path);
-        if (mFileMoveRequestCallback) {
-            mFileMoveRequestCallback(destination, path, result);
+        if (mFileMoveCallback) {
+            auto rb = std::make_shared<api::DbusMethodResultBuilder<api::FileMoveRequestStatus>>(result);
+            mFileMoveCallback(destination, path, rb);
         }
     }
 
index 78b6e56..8f025b0 100644 (file)
 #define SERVER_ZONE_CONNECTION_HPP
 
 #include "dbus/connection.hpp"
+#include "api/method-result-builder.hpp"
 
 #include <mutex>
 #include <condition_variable>
 
-
 namespace vasum {
 
 
@@ -47,13 +47,14 @@ public:
     // ------------- API --------------
 
     typedef std::function<void(const std::string& application,
-                               const std::string& message
+                               const std::string& message,
+                               api::MethodResultBuilder::Pointer result
                               )> NotifyActiveZoneCallback;
 
     typedef std::function<void(const std::string& destination,
                                const std::string& path,
-                               dbus::MethodResultBuilder::Pointer result
-                              )> FileMoveRequestCallback;
+                               api::MethodResultBuilder::Pointer result
+                              )> FileMoveCallback;
 
     typedef std::function<void(const std::string& target,
                                const std::string& targetBusName,
@@ -62,7 +63,7 @@ public:
                                const std::string& targetMethod,
                                GVariant* parameters,
                                dbus::MethodResultBuilder::Pointer result
-                               )> ProxyCallCallback;
+                              )> ProxyCallCallback;
 
     /**
      * Register notification request callback
@@ -77,7 +78,7 @@ public:
     /*
      * Register file move request callback
      */
-    void setFileMoveRequestCallback(const FileMoveRequestCallback& callback);
+    void setFileMoveCallback(const FileMoveCallback& callback);
 
     /**
      * Register proxy call callback
@@ -110,7 +111,7 @@ private:
     OnNameLostCallback mOnNameLostCallback;
     NotifyActiveZoneCallback mNotifyActiveZoneCallback;
     DisplayOffCallback mDisplayOffCallback;
-    FileMoveRequestCallback mFileMoveRequestCallback;
+    FileMoveCallback mFileMoveCallback;
     ProxyCallCallback mProxyCallCallback;
 
     void onNameAcquired();
index 1bc2d09..181cc9e 100644 (file)
@@ -206,7 +206,7 @@ void Zone::connect()
         mConnection->setDisplayOffCallback(mDisplayOffCallback);
     }
     if (mFileMoveCallback) {
-        mConnection->setFileMoveRequestCallback(mFileMoveCallback);
+        mConnection->setFileMoveCallback(mFileMoveCallback);
     }
     if (mProxyCallCallback) {
         mConnection->setProxyCallCallback(mProxyCallCallback);
@@ -411,13 +411,13 @@ void Zone::setDisplayOffCallback(const DisplayOffCallback& callback)
     }
 }
 
-void Zone::setFileMoveRequestCallback(const FileMoveRequestCallback& callback)
+void Zone::setFileMoveCallback(const FileMoveCallback& callback)
 {
     Lock lock(mReconnectMutex);
 
     mFileMoveCallback = callback;
     if (mConnection) {
-        mConnection->setFileMoveRequestCallback(callback);
+        mConnection->setFileMoveCallback(callback);
     }
 }
 
index 69d0324..45bacbd 100644 (file)
@@ -67,7 +67,7 @@ public:
 
     typedef ZoneConnection::NotifyActiveZoneCallback NotifyActiveZoneCallback;
     typedef ZoneConnection::DisplayOffCallback DisplayOffCallback;
-    typedef ZoneConnection::FileMoveRequestCallback FileMoveRequestCallback;
+    typedef ZoneConnection::FileMoveCallback FileMoveCallback;
     typedef ZoneConnection::ProxyCallCallback ProxyCallCallback;
 
     typedef std::function<void(const std::string& address)> DbusStateChangedCallback;
@@ -210,7 +210,7 @@ public:
     /**
      * Register file move request callback
      */
-    void setFileMoveRequestCallback(const FileMoveRequestCallback& callback);
+    void setFileMoveCallback(const FileMoveCallback& callback);
 
     /**
      * Register dbus state changed callback
@@ -319,7 +319,7 @@ private:
     mutable std::recursive_mutex mReconnectMutex;
     NotifyActiveZoneCallback mNotifyCallback;
     DisplayOffCallback mDisplayOffCallback;
-    FileMoveRequestCallback mFileMoveCallback;
+    FileMoveCallback mFileMoveCallback;
     ProxyCallCallback mProxyCallCallback;
     DbusStateChangedCallback mDbusStateChangedCallback;
     std::string mDbusAddress;
index d90bab7..2dcfaa0 100644 (file)
@@ -40,6 +40,7 @@
 #include "utils/fs.hpp"
 #include "utils/img.hpp"
 #include "utils/environment.hpp"
+#include "api/messages.hpp"
 
 #include <boost/filesystem.hpp>
 #include <boost/regex.hpp>
@@ -56,7 +57,7 @@ namespace {
 
 bool regexMatchVector(const std::string& str, const std::vector<boost::regex>& v)
 {
-    for (const boost::regex& toMatch: v) {
+    for (const boost::regex& toMatch : v) {
         if (boost::regex_match(str, toMatch)) {
             return true;
         }
@@ -129,7 +130,7 @@ ZonesManager::ZonesManager(const std::string& configPath)
     mHostConnection.setProxyCallCallback(bind(&ZonesManager::handleProxyCall,
                                               this, HOST_ID, _1, _2, _3, _4, _5, _6, _7));
 
-    mHostConnection.setGetZoneDbusesCallback(bind(&ZonesManager::handleGetZoneDbuses,
+    mHostConnection.setGetZoneDbusesCallback(bind(&ZonesManager::handleGetZoneDbusesCall,
                                                   this, _1));
 
     mHostConnection.setGetZoneIdsCallback(bind(&ZonesManager::handleGetZoneIdsCall,
@@ -142,22 +143,22 @@ ZonesManager::ZonesManager(const std::string& configPath)
                                                 this, _1, _2));
 
     mHostConnection.setSetNetdevAttrsCallback(bind(&ZonesManager::handleSetNetdevAttrsCall,
-                                                this, _1, _2, _3, _4));
+                                                   this, _1, _2, _3, _4));
 
     mHostConnection.setGetNetdevAttrsCallback(bind(&ZonesManager::handleGetNetdevAttrsCall,
-                                                this, _1, _2, _3));
+                                                   this, _1, _2, _3));
 
     mHostConnection.setGetNetdevListCallback(bind(&ZonesManager::handleGetNetdevListCall,
-                                                this, _1, _2));
+                                                  this, _1, _2));
 
     mHostConnection.setCreateNetdevVethCallback(bind(&ZonesManager::handleCreateNetdevVethCall,
-                                                this, _1, _2, _3, _4));
+                                                     this, _1, _2, _3, _4));
 
     mHostConnection.setCreateNetdevMacvlanCallback(bind(&ZonesManager::handleCreateNetdevMacvlanCall,
-                                                this, _1, _2, _3, _4, _5));
+                                                        this, _1, _2, _3, _4, _5));
 
     mHostConnection.setCreateNetdevPhysCallback(bind(&ZonesManager::handleCreateNetdevPhysCall,
-                                                this, _1, _2, _3));
+                                                     this, _1, _2, _3));
 
     mHostConnection.setDeclareFileCallback(bind(&ZonesManager::handleDeclareFileCall,
                                                 this, _1, _2, _3, _4, _5, _6));
@@ -172,7 +173,7 @@ ZonesManager::ZonesManager(const std::string& configPath)
                                                     this, _1, _2));
 
     mHostConnection.setRemoveDeclarationCallback(bind(&ZonesManager::handleRemoveDeclarationCall,
-                                                    this, _1, _2, _3));
+                                                      this, _1, _2, _3));
 
     mHostConnection.setSetActiveZoneCallback(bind(&ZonesManager::handleSetActiveZoneCall,
                                                   this, _1, _2));
@@ -212,9 +213,9 @@ ZonesManager::ZonesManager(const std::string& configPath)
     if (mConfig.inputConfig.enabled) {
         LOGI("Registering input monitor [" << mConfig.inputConfig.device.c_str() << "]");
         mSwitchingSequenceMonitor.reset(
-                new InputMonitor(mConfig.inputConfig,
-                                 std::bind(&ZonesManager::switchingSequenceMonitorNotify,
-                                           this)));
+            new InputMonitor(mConfig.inputConfig,
+                             std::bind(&ZonesManager::switchingSequenceMonitorNotify,
+                                       this)));
     }
 
 
@@ -307,13 +308,13 @@ void ZonesManager::insertZone(const std::string& zoneId, const std::string& zone
                                         mConfig.runMountPointPrefix));
 
     using namespace std::placeholders;
-    zone->setNotifyActiveZoneCallback(bind(&ZonesManager::notifyActiveZoneHandler,
-                                           this, zoneId, _1, _2));
+    zone->setNotifyActiveZoneCallback(bind(&ZonesManager::handleNotifyActiveZoneCall,
+                                           this, zoneId, _1, _2, _3));
 
-    zone->setDisplayOffCallback(bind(&ZonesManager::displayOffHandler,
+    zone->setDisplayOffCallback(bind(&ZonesManager::handleDisplayOffCall,
                                      this, zoneId));
 
-    zone->setFileMoveRequestCallback(bind(&ZonesManager::handleZoneMoveFileRequest,
+    zone->setFileMoveCallback(bind(&ZonesManager::handleFileMoveCall,
                                           this, zoneId, _1, _2, _3));
 
     zone->setProxyCallCallback(bind(&ZonesManager::handleProxyCall,
@@ -547,11 +548,12 @@ void ZonesManager::setZonesDetachOnExit()
     }
 }
 
-void ZonesManager::notifyActiveZoneHandler(const std::string& caller,
-                                           const std::string& application,
-                                           const std::string& message)
+void ZonesManager::handleNotifyActiveZoneCall(const std::string& caller,
+                                          const std::string& application,
+                                          const std::string& message,
+                                          api::MethodResultBuilder::Pointer result)
 {
-    LOGI("notifyActiveZoneHandler(" << caller << ", " << application << ", " << message
+    LOGI("handleNotifyActiveZoneCall(" << caller << ", " << application << ", " << message
          << ") called");
 
     Lock lock(mMutex);
@@ -561,12 +563,14 @@ void ZonesManager::notifyActiveZoneHandler(const std::string& caller,
         if (iter != mZones.end() && caller != get(iter).getId()) {
             get(iter).sendNotification(caller, application, message);
         }
-    } catch(const VasumException&) {
+        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::displayOffHandler(const std::string& /*caller*/)
+void ZonesManager::handleDisplayOffCall(const std::string& /*caller*/)
 {
     // get config of currently set zone and switch if switchToDefaultAfterTimeout is true
     Lock lock(mMutex);
@@ -584,10 +588,10 @@ void ZonesManager::displayOffHandler(const std::string& /*caller*/)
     }
 }
 
-void ZonesManager::handleZoneMoveFileRequest(const std::string& srcZoneId,
-                                             const std::string& dstZoneId,
-                                             const std::string& path,
-                                             dbus::MethodResultBuilder::Pointer result)
+void ZonesManager::handleFileMoveCall(const std::string& srcZoneId,
+                                         const std::string& dstZoneId,
+                                         const std::string& path,
+                                         api::MethodResultBuilder::Pointer result)
 {
     // TODO: this implementation is only a placeholder.
     // There are too many unanswered questions and security concerns:
@@ -622,29 +626,35 @@ void ZonesManager::handleZoneMoveFileRequest(const std::string& srcZoneId,
     }
     Zone& srcZone = get(srcIter);
 
+    auto status = std::make_shared<api::FileMoveRequestStatus>();
+
     auto dstIter = findZone(dstZoneId);
     if (dstIter == mZones.end()) {
         LOGE("Destination zone '" << dstZoneId << "' not found");
-        result->set(g_variant_new("(s)", api::zone::FILE_MOVE_DESTINATION_NOT_FOUND.c_str()));
+        status->value = api::zone::FILE_MOVE_DESTINATION_NOT_FOUND;
+        result->set(status);
         return;
     }
     Zone& dstContanier = get(dstIter);
 
     if (srcZoneId == dstZoneId) {
         LOGE("Cannot send a file to yourself");
-        result->set(g_variant_new("(s)", api::zone::FILE_MOVE_WRONG_DESTINATION.c_str()));
+        status->value = api::zone::FILE_MOVE_WRONG_DESTINATION;
+        result->set(status);
         return;
     }
 
     if (!regexMatchVector(path, srcZone.getPermittedToSend())) {
         LOGE("Source zone has no permissions to send the file: " << path);
-        result->set(g_variant_new("(s)", api::zone::FILE_MOVE_NO_PERMISSIONS_SEND.c_str()));
+        status->value = api::zone::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);
-        result->set(g_variant_new("(s)", api::zone::FILE_MOVE_NO_PERMISSIONS_RECEIVE.c_str()));
+        status->value = api::zone::FILE_MOVE_NO_PERMISSIONS_RECEIVE;
+        result->set(status);
         return;
     }
 
@@ -654,9 +664,11 @@ void ZonesManager::handleZoneMoveFileRequest(const std::string& srcZoneId,
 
     if (!utils::moveFile(srcPath, dstPath)) {
         LOGE("Failed to move the file: " << path);
-        result->set(g_variant_new("(s)", api::zone::FILE_MOVE_FAILED.c_str()));
+        status->value = api::zone::FILE_MOVE_FAILED;
+        result->set(status);
     } else {
-        result->set(g_variant_new("(s)", api::zone::FILE_MOVE_SUCCEEDED.c_str()));
+        status->value = api::zone::FILE_MOVE_SUCCEEDED;
+        result->set(status);
         try {
             dstContanier.sendNotification(srcZoneId, path, api::zone::FILE_MOVE_SUCCEEDED);
         } catch (ServerException&) {
@@ -681,15 +693,15 @@ void ZonesManager::handleProxyCall(const std::string& caller,
                                               targetInterface,
                                               targetMethod)) {
         LOGW("Forbidden proxy call; " << caller << " -> " << target << "; " << targetBusName
-                << "; " << targetObjectPath << "; " << targetInterface << "; " << targetMethod);
+             << "; " << targetObjectPath << "; " << targetInterface << "; " << targetMethod);
         result->setError(api::ERROR_FORBIDDEN, "Proxy call forbidden");
         return;
     }
 
     LOGI("Proxy call; " << caller << " -> " << target << "; " << targetBusName
-            << "; " << targetObjectPath << "; " << targetInterface << "; " << targetMethod);
+         << "; " << targetObjectPath << "; " << targetInterface << "; " << targetMethod);
 
-    auto asyncResultCallback = [result](dbus::AsyncMethodCallResult& asyncMethodCallResult) {
+    auto asyncResultCallback = [result](dbus::AsyncMethodCallResult & asyncMethodCallResult) {
         try {
             GVariant* targetResult = asyncMethodCallResult.get();
             result->set(g_variant_new("(v)", targetResult));
@@ -719,26 +731,22 @@ void ZonesManager::handleProxyCall(const std::string& caller,
 
     Zone& targetZone = get(targetIter);
     targetZone.proxyCallAsync(targetBusName,
-                                   targetObjectPath,
-                                   targetInterface,
-                                   targetMethod,
-                                   parameters,
-                                   asyncResultCallback);
+                              targetObjectPath,
+                              targetInterface,
+                              targetMethod,
+                              parameters,
+                              asyncResultCallback);
 }
 
-void ZonesManager::handleGetZoneDbuses(dbus::MethodResultBuilder::Pointer result)
+void ZonesManager::handleGetZoneDbusesCall(api::MethodResultBuilder::Pointer result)
 {
     Lock lock(mMutex);
 
-    std::vector<GVariant*> entries;
+    auto dbuses = std::make_shared<api::Dbuses>();
     for (auto& zone : mZones) {
-        GVariant* zoneId = g_variant_new_string(zone->getId().c_str());
-        GVariant* dbusAddress = g_variant_new_string(zone->getDbusAddress().c_str());
-        GVariant* entry = g_variant_new_dict_entry(zoneId, dbusAddress);
-        entries.push_back(entry);
+        dbuses->values.push_back({zone->getId(), zone->getDbusAddress()});
     }
-    GVariant* dict = g_variant_new_array(G_VARIANT_TYPE("{ss}"), entries.data(), entries.size());
-    result->set(g_variant_new("(@a{ss})", dict));
+    result->set(dbuses);
 }
 
 void ZonesManager::handleDbusStateChanged(const std::string& zoneId,
@@ -747,31 +755,28 @@ void ZonesManager::handleDbusStateChanged(const std::string& zoneId,
     mHostConnection.signalZoneDbusState(zoneId, dbusAddress);
 }
 
-void ZonesManager::handleGetZoneIdsCall(dbus::MethodResultBuilder::Pointer result)
+void ZonesManager::handleGetZoneIdsCall(api::MethodResultBuilder::Pointer result)
 {
     Lock lock(mMutex);
 
-    std::vector<GVariant*> zoneIds;
-    for(auto& zone: mZones){
-        zoneIds.push_back(g_variant_new_string(zone->getId().c_str()));
+    auto zoneIds = std::make_shared<api::ZoneIds>();
+    for (const auto& zone : mZones) {
+        zoneIds->values.push_back(zone->getId());
     }
 
-    GVariant* array = g_variant_new_array(G_VARIANT_TYPE("s"),
-                                          zoneIds.data(),
-                                          zoneIds.size());
-    result->set(g_variant_new("(@as)", array));
+    result->set(zoneIds);
 }
 
-void ZonesManager::handleGetActiveZoneIdCall(dbus::MethodResultBuilder::Pointer result)
+void ZonesManager::handleGetActiveZoneIdCall(api::MethodResultBuilder::Pointer result)
 {
     LOGI("GetActiveZoneId call");
-
-    std::string id = getRunningForegroundZoneId();
-    result->set(g_variant_new("(s)", id.c_str()));
+    auto zoneId = std::make_shared<api::ZoneId>();
+    zoneId->value = getRunningForegroundZoneId();
+    result->set(zoneId);
 }
 
 void ZonesManager::handleGetZoneInfoCall(const std::string& id,
-                                         dbus::MethodResultBuilder::Pointer result)
+                                         api::MethodResultBuilder::Pointer result)
 {
     LOGI("GetZoneInfo call");
 
@@ -783,38 +788,33 @@ void ZonesManager::handleGetZoneInfoCall(const std::string& id,
         result->setError(api::ERROR_INVALID_ID, "No such zone id");
         return;
     }
+
     Zone& zone = get(iter);
-    const char* state;
+    auto zoneInfo = std::make_shared<api::ZoneInfo>();
 
     if (zone.isRunning()) {
-        state = "RUNNING";
+        zoneInfo->state = "RUNNING";
     } else if (zone.isStopped()) {
-        state = "STOPPED";
+        zoneInfo->state = "STOPPED";
     } else if (zone.isPaused()) {
-        state = "FROZEN";
+        zoneInfo->state = "FROZEN";
     } else {
         LOGE("Unrecognized state of zone id=" << id);
         result->setError(api::ERROR_INTERNAL, "Unrecognized state of zone");
         return;
     }
 
-    result->set(g_variant_new("((siss))",
-                              id.c_str(),
-                              zone.getVT(),
-                              state,
-                              zone.getRootPath().c_str()));
+    result->set(zoneInfo);
 }
 
 void ZonesManager::handleSetNetdevAttrsCall(const std::string& zone,
                                             const std::string& netdev,
-                                            const std::vector<
-                                                std::tuple<std::string, std::string>>& attrs,
-                                            dbus::MethodResultBuilder::Pointer result)
+                                            const std::vector<std::tuple<std::string, std::string>>& attrs,
+                                            api::MethodResultBuilder::Pointer result)
 {
     LOGI("SetNetdevAttrs call");
     try {
         Lock lock(mMutex);
-
         getZone(zone).setNetdevAttrs(netdev, attrs);
         result->setVoid();
     } catch (const InvalidZoneIdException&) {
@@ -828,23 +828,18 @@ void ZonesManager::handleSetNetdevAttrsCall(const std::string& zone,
 
 void ZonesManager::handleGetNetdevAttrsCall(const std::string& zone,
                                             const std::string& netdev,
-                                            dbus::MethodResultBuilder::Pointer result)
+                                            api::MethodResultBuilder::Pointer result)
 {
     LOGI("GetNetdevAttrs call");
     try {
         Lock lock(mMutex);
-
+        auto netDevAttrs = std::make_shared<api::NetDevAttrs>();
         const auto attrs = getZone(zone).getNetdevAttrs(netdev);
 
-        GVariantBuilder builder;
-        g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY);
-        for (const auto entry : attrs) {
-            g_variant_builder_add(&builder,
-                                  "(ss)",
-                                  std::get<0>(entry).c_str(),
-                                  std::get<1>(entry).c_str());
+        for (size_t i = 0; i < attrs.size(); ++i) {
+            netDevAttrs->values.push_back({std::get<0>(attrs[i]), std::get<1>(attrs[i])});
         }
-        result->set(g_variant_builder_end(&builder));
+        result->set(netDevAttrs);
     } catch (const InvalidZoneIdException&) {
         LOGE("No zone with id=" << zone);
         result->setError(api::ERROR_INVALID_ID, "No such zone id");
@@ -855,19 +850,14 @@ void ZonesManager::handleGetNetdevAttrsCall(const std::string& zone,
 }
 
 void ZonesManager::handleGetNetdevListCall(const std::string& zone,
-                                           dbus::MethodResultBuilder::Pointer result)
+                                           api::MethodResultBuilder::Pointer result)
 {
     LOGI("GetNetdevList call");
     try {
         Lock lock(mMutex);
-        std::vector<GVariant*> netdevs;
-        for(auto& netdev: getZone(zone).getNetdevList()){
-            netdevs.push_back(g_variant_new_string(netdev.c_str()));
-        }
-        GVariant* array = g_variant_new_array(G_VARIANT_TYPE("s"),
-                                              netdevs.data(),
-                                              netdevs.size());
-        result->set(g_variant_new("(@as)", array));
+        auto netDevList = std::make_shared<api::NetDevList>();
+        netDevList->values = getZone(zone).getNetdevList();
+        result->set(netDevList);
     } catch (const InvalidZoneIdException&) {
         LOGE("No zone with id=" << zone);
         result->setError(api::ERROR_INVALID_ID, "No such zone id");
@@ -880,7 +870,7 @@ void ZonesManager::handleGetNetdevListCall(const std::string& zone,
 void ZonesManager::handleCreateNetdevVethCall(const std::string& zone,
                                               const std::string& zoneDev,
                                               const std::string& hostDev,
-                                              dbus::MethodResultBuilder::Pointer result)
+                                              api::MethodResultBuilder::Pointer result)
 {
     LOGI("CreateNetdevVeth call");
     try {
@@ -901,7 +891,7 @@ void ZonesManager::handleCreateNetdevMacvlanCall(const std::string& zone,
                                                  const std::string& zoneDev,
                                                  const std::string& hostDev,
                                                  const uint32_t& mode,
-                                                 dbus::MethodResultBuilder::Pointer result)
+                                                 api::MethodResultBuilder::Pointer result)
 {
     LOGI("CreateNetdevMacvlan call");
     try {
@@ -920,7 +910,7 @@ void ZonesManager::handleCreateNetdevMacvlanCall(const std::string& zone,
 
 void ZonesManager::handleCreateNetdevPhysCall(const std::string& zone,
                                               const std::string& devId,
-                                              dbus::MethodResultBuilder::Pointer result)
+                                              api::MethodResultBuilder::Pointer result)
 {
     LOGI("CreateNetdevPhys call");
     try {
@@ -942,15 +932,15 @@ void ZonesManager::handleDeclareFileCall(const std::string& zone,
                                          const std::string& path,
                                          const int32_t& flags,
                                          const int32_t& mode,
-                                         dbus::MethodResultBuilder::Pointer result)
+                                         api::MethodResultBuilder::Pointer result)
 {
     LOGI("DeclareFile call");
 
     try {
         Lock lock(mMutex);
-
-        const std::string id = getZone(zone).declareFile(type, path, flags, mode);
-        result->set(g_variant_new("(s)", id.c_str()));
+        auto declaration = std::make_shared<api::Declaration>();
+        declaration->value = getZone(zone).declareFile(type, path, flags, mode);
+        result->set(declaration);
     } catch (const InvalidZoneIdException&) {
         LOGE("No zone with id=" << zone);
         result->setError(api::ERROR_INVALID_ID, "No such zone id");
@@ -966,15 +956,15 @@ void ZonesManager::handleDeclareMountCall(const std::string& source,
                                           const std::string& type,
                                           const uint64_t& flags,
                                           const std::string& data,
-                                          dbus::MethodResultBuilder::Pointer result)
+                                          api::MethodResultBuilder::Pointer result)
 {
     LOGI("DeclareMount call");
 
     try {
         Lock lock(mMutex);
-
-        const std::string id = getZone(zone).declareMount(source, target, type, flags, data);
-        result->set(g_variant_new("(s)", id.c_str()));
+        auto declaration = std::make_shared<api::Declaration>();
+        declaration->value = getZone(zone).declareMount(source, target, type, flags, data);
+        result->set(declaration);
     } catch (const InvalidZoneIdException&) {
         LOGE("No zone with id=" << zone);
         result->setError(api::ERROR_INVALID_ID, "No such zone id");
@@ -987,14 +977,14 @@ void ZonesManager::handleDeclareMountCall(const std::string& source,
 void ZonesManager::handleDeclareLinkCall(const std::string& source,
                                          const std::string& zone,
                                          const std::string& target,
-                                         dbus::MethodResultBuilder::Pointer result)
+                                         api::MethodResultBuilder::Pointer result)
 {
     LOGI("DeclareLink call");
     try {
         Lock lock(mMutex);
-
-        const std::string id = getZone(zone).declareLink(source, target);
-        result->set(g_variant_new("(s)", id.c_str()));
+        auto declaration = std::make_shared<api::Declaration>();
+        declaration->value = getZone(zone).declareLink(source, target);
+        result->set(declaration);
     } catch (const InvalidZoneIdException&) {
         LOGE("No zone with id=" << zone);
         result->setError(api::ERROR_INVALID_ID, "No such zone id");
@@ -1005,23 +995,14 @@ void ZonesManager::handleDeclareLinkCall(const std::string& source,
 }
 
 void ZonesManager::handleGetDeclarationsCall(const std::string& zone,
-                                             dbus::MethodResultBuilder::Pointer result)
+                                             api::MethodResultBuilder::Pointer result)
 {
     LOGI("GetDeclarations call Id=" << zone);
     try {
         Lock lock(mMutex);
-
-        std::vector<std::string> declarations = getZone(zone).getDeclarations();
-
-        std::vector<GVariant*> out;
-        for (auto declaration : declarations) {
-            out.push_back(g_variant_new_string(declaration.c_str()));
-        }
-
-        GVariant* array = g_variant_new_array(G_VARIANT_TYPE("s"),
-                                              out.data(),
-                                              out.size());
-        result->set(g_variant_new("(@as)", array));
+        auto declarations = std::make_shared<api::Declarations>();
+        declarations->values = getZone(zone).getDeclarations();
+        result->set(declarations);
     } catch (const InvalidZoneIdException&) {
         LOGE("No zone with id=" << zone);
         result->setError(api::ERROR_INVALID_ID, "No such zone id");
@@ -1029,12 +1010,11 @@ void ZonesManager::handleGetDeclarationsCall(const std::string& zone,
         LOGE(ex.what());
         result->setError(api::ERROR_INTERNAL, ex.what());
     }
-
 }
 
 void ZonesManager::handleRemoveDeclarationCall(const std::string& zone,
                                                const std::string& declarationId,
-                                               dbus::MethodResultBuilder::Pointer result)
+                                               api::MethodResultBuilder::Pointer result)
 {
     LOGI("RemoveDeclaration call Id=" << zone);
     try {
@@ -1053,20 +1033,20 @@ void ZonesManager::handleRemoveDeclarationCall(const std::string& zone,
 }
 
 void ZonesManager::handleSetActiveZoneCall(const std::string& id,
-                                           dbus::MethodResultBuilder::Pointer result)
+                                           api::MethodResultBuilder::Pointer result)
 {
     LOGI("SetActiveZone call; Id=" << id );
 
     Lock lock(mMutex);
 
     auto iter = findZone(id);
-    if (iter == mZones.end()){
+    if (iter == mZones.end()) {
         LOGE("No zone with id=" << id );
         result->setError(api::ERROR_INVALID_ID, "No such zone id");
         return;
     }
 
-    if (!get(iter).isRunning()){
+    if (!get(iter).isRunning()) {
         LOGE("Could not activate stopped or paused zone");
         result->setError(api::host::ERROR_ZONE_NOT_RUNNING,
                          "Could not activate stopped or paused zone");
@@ -1170,11 +1150,11 @@ void ZonesManager::createZone(const std::string& id,
         }
     }
 
-    auto removeAllWrapper = [](const std::string& path) -> bool {
+    auto removeAllWrapper = [](const std::string & path) -> bool {
         try {
             LOGD("Removing copied data");
             fs::remove_all(fs::path(path));
-        } catch(const std::exception& e) {
+        } catch (const std::exception& e) {
             LOGW("Failed to remove data: " << boost::diagnostic_information(e));
         }
         return true;
@@ -1208,7 +1188,7 @@ void ZonesManager::createZone(const std::string& id,
 
 void ZonesManager::handleCreateZoneCall(const std::string& id,
                                         const std::string& templateName,
-                                        dbus::MethodResultBuilder::Pointer result)
+                                        api::MethodResultBuilder::Pointer result)
 {
     try {
         createZone(id, templateName);
@@ -1221,7 +1201,7 @@ void ZonesManager::handleCreateZoneCall(const std::string& id,
 }
 
 void ZonesManager::handleDestroyZoneCall(const std::string& id,
-                                         dbus::MethodResultBuilder::Pointer result)
+                                         api::MethodResultBuilder::Pointer result)
 {
     auto destroyer = [id, result, this] {
         try {
@@ -1243,7 +1223,7 @@ void ZonesManager::handleDestroyZoneCall(const std::string& id,
 }
 
 void ZonesManager::handleShutdownZoneCall(const std::string& id,
-                                          dbus::MethodResultBuilder::Pointer result)
+                                          api::MethodResultBuilder::Pointer result)
 {
     LOGI("ShutdownZone call; Id=" << id );
 
@@ -1272,7 +1252,7 @@ void ZonesManager::handleShutdownZoneCall(const std::string& id,
 }
 
 void ZonesManager::handleStartZoneCall(const std::string& id,
-                                       dbus::MethodResultBuilder::Pointer result)
+                                       api::MethodResultBuilder::Pointer result)
 {
     LOGI("StartZone call; Id=" << id );
 
@@ -1299,7 +1279,7 @@ void ZonesManager::handleStartZoneCall(const std::string& id,
 }
 
 void ZonesManager::handleLockZoneCall(const std::string& id,
-                                      dbus::MethodResultBuilder::Pointer result)
+                                      api::MethodResultBuilder::Pointer result)
 {
     LOGI("LockZone call; Id=" << id );
 
@@ -1334,7 +1314,7 @@ void ZonesManager::handleLockZoneCall(const std::string& id,
 }
 
 void ZonesManager::handleUnlockZoneCall(const std::string& id,
-                                        dbus::MethodResultBuilder::Pointer result)
+                                        api::MethodResultBuilder::Pointer result)
 {
     LOGI("UnlockZone call; Id=" << id );
 
@@ -1369,7 +1349,7 @@ void ZonesManager::handleUnlockZoneCall(const std::string& id,
 void ZonesManager::handleGrantDeviceCall(const std::string& id,
                                          const std::string& device,
                                          uint32_t flags,
-                                         dbus::MethodResultBuilder::Pointer result)
+                                         api::MethodResultBuilder::Pointer result)
 {
     LOGI("GrantDevice call; id=" << id << "; dev=" << device);
 
@@ -1409,7 +1389,7 @@ void ZonesManager::handleGrantDeviceCall(const std::string& id,
 
 void ZonesManager::handleRevokeDeviceCall(const std::string& id,
                                           const std::string& device,
-                                          dbus::MethodResultBuilder::Pointer result)
+                                          api::MethodResultBuilder::Pointer result)
 {
     LOGI("RevokeDevice call; id=" << id << "; dev=" << device);
 
index cb730e3..825b1c8 100644 (file)
@@ -32,6 +32,7 @@
 #include "input-monitor.hpp"
 #include "proxy-call-policy.hpp"
 #include "utils/worker.hpp"
+#include "api/method-result-builder.hpp"
 
 #include <string>
 #include <memory>
@@ -145,14 +146,15 @@ private:
     int getVTForNewZone();
     void insertZone(const std::string& zoneId, const std::string& templatePath);
 
-    void notifyActiveZoneHandler(const std::string& caller,
-                                 const std::string& appliaction,
-                                 const std::string& message);
-    void displayOffHandler(const std::string& caller);
-    void handleZoneMoveFileRequest(const std::string& srcZoneId,
-                                   const std::string& dstZoneId,
-                                   const std::string& path,
-                                   dbus::MethodResultBuilder::Pointer result);
+    void handleNotifyActiveZoneCall(const std::string& caller,
+                                    const std::string& appliaction,
+                                    const std::string& message,
+                                    api::MethodResultBuilder::Pointer result);
+    void handleDisplayOffCall(const std::string& caller);
+    void handleFileMoveCall(const std::string& srcZoneId,
+                               const std::string& dstZoneId,
+                               const std::string& path,
+                               api::MethodResultBuilder::Pointer result);
     void handleProxyCall(const std::string& caller,
                          const std::string& target,
                          const std::string& targetBusName,
@@ -161,76 +163,76 @@ private:
                          const std::string& targetMethod,
                          GVariant* parameters,
                          dbus::MethodResultBuilder::Pointer result);
-    void handleGetZoneDbuses(dbus::MethodResultBuilder::Pointer result);
+    void handleGetZoneDbusesCall(api::MethodResultBuilder::Pointer result);
     void handleDbusStateChanged(const std::string& zoneId, const std::string& dbusAddress);
-    void handleGetZoneIdsCall(dbus::MethodResultBuilder::Pointer result);
-    void handleGetActiveZoneIdCall(dbus::MethodResultBuilder::Pointer result);
-    void handleGetZoneInfoCall(const std::string& id, dbus::MethodResultBuilder::Pointer result);
+    void handleGetZoneIdsCall(api::MethodResultBuilder::Pointer result);
+    void handleGetActiveZoneIdCall(api::MethodResultBuilder::Pointer result);
+    void handleGetZoneInfoCall(const std::string& id, api::MethodResultBuilder::Pointer result);
     void handleSetNetdevAttrsCall(const std::string& zone,
                                   const std::string& netdev,
                                   const std::vector<std::tuple<std::string, std::string>>& attrs,
-                                  dbus::MethodResultBuilder::Pointer result);
+                                  api::MethodResultBuilder::Pointer result);
     void handleGetNetdevAttrsCall(const std::string& zone,
                                   const std::string& netdev,
-                                  dbus::MethodResultBuilder::Pointer result);
+                                  api::MethodResultBuilder::Pointer result);
     void handleGetNetdevListCall(const std::string& zone,
-                                 dbus::MethodResultBuilder::Pointer result);
+                                 api::MethodResultBuilder::Pointer result);
     void handleCreateNetdevVethCall(const std::string& zone,
                                     const std::string& zoneDev,
                                     const std::string& hostDev,
-                                    dbus::MethodResultBuilder::Pointer result);
+                                    api::MethodResultBuilder::Pointer result);
     void handleCreateNetdevMacvlanCall(const std::string& zone,
                                        const std::string& zoneDev,
                                        const std::string& hostDev,
                                        const uint32_t& mode,
-                                       dbus::MethodResultBuilder::Pointer result);
+                                       api::MethodResultBuilder::Pointer result);
     void handleCreateNetdevPhysCall(const std::string& zone,
                                     const std::string& devId,
-                                    dbus::MethodResultBuilder::Pointer result);
+                                    api::MethodResultBuilder::Pointer result);
     void handleDeclareFileCall(const std::string& zone,
                                const int32_t& type,
                                const std::string& path,
                                const int32_t& flags,
                                const int32_t& mode,
-                               dbus::MethodResultBuilder::Pointer result);
+                               api::MethodResultBuilder::Pointer result);
     void handleDeclareMountCall(const std::string& source,
                                 const std::string& zone,
                                 const std::string& target,
                                 const std::string& type,
                                 const uint64_t& flags,
                                 const std::string& data,
-                                dbus::MethodResultBuilder::Pointer result);
+                                api::MethodResultBuilder::Pointer result);
     void handleDeclareLinkCall(const std::string& source,
                                const std::string& zone,
                                const std::string& target,
-                               dbus::MethodResultBuilder::Pointer result);
+                               api::MethodResultBuilder::Pointer result);
     void handleGetDeclarationsCall(const std::string& zone,
-                                   dbus::MethodResultBuilder::Pointer result);
+                                   api::MethodResultBuilder::Pointer result);
     void handleRemoveDeclarationCall(const std::string& zone,
                                      const std::string& declarationId,
-                                     dbus::MethodResultBuilder::Pointer result);
+                                     api::MethodResultBuilder::Pointer result);
     void handleSetActiveZoneCall(const std::string& id,
-                                 dbus::MethodResultBuilder::Pointer result);
+                                 api::MethodResultBuilder::Pointer result);
     void handleCreateZoneCall(const std::string& id,
                               const std::string& templateName,
-                              dbus::MethodResultBuilder::Pointer result);
+                              api::MethodResultBuilder::Pointer result);
     void handleDestroyZoneCall(const std::string& id,
-                               dbus::MethodResultBuilder::Pointer result);
+                               api::MethodResultBuilder::Pointer result);
     void handleShutdownZoneCall(const std::string& id,
-                                dbus::MethodResultBuilder::Pointer result);
+                                api::MethodResultBuilder::Pointer result);
     void handleStartZoneCall(const std::string& id,
-                             dbus::MethodResultBuilder::Pointer result);
+                             api::MethodResultBuilder::Pointer result);
     void handleLockZoneCall(const std::string& id,
-                            dbus::MethodResultBuilder::Pointer result);
+                            api::MethodResultBuilder::Pointer result);
     void handleUnlockZoneCall(const std::string& id,
-                              dbus::MethodResultBuilder::Pointer result);
+                              api::MethodResultBuilder::Pointer result);
     void handleGrantDeviceCall(const std::string& id,
                                const std::string& device,
                                uint32_t flags,
-                               dbus::MethodResultBuilder::Pointer result);
+                               api::MethodResultBuilder::Pointer result);
     void handleRevokeDeviceCall(const std::string& id,
                                 const std::string& device,
-                                dbus::MethodResultBuilder::Pointer result);
+                                api::MethodResultBuilder::Pointer result);
 };
 
 
index fb6df88..2a72b87 100644 (file)
@@ -41,6 +41,8 @@
 #include "utils/fs.hpp"
 #include "utils/scoped-dir.hpp"
 
+#include "api/method-result-builder.hpp"
+
 
 using namespace vasum;
 using namespace vasum::utils;
@@ -141,10 +143,11 @@ BOOST_AUTO_TEST_CASE(NotifyActiveZoneApiTest)
     Latch notifyCalled;
     ZoneConnection connection(acquireAddress(), nullptr);
 
-    auto callback = [&](const std::string& application, const std::string& message) {
+    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);
 
@@ -169,19 +172,19 @@ BOOST_AUTO_TEST_CASE(SignalNotificationApiTest)
                        const std::string& objectPath,
                        const std::string& interface,
                        const std::string& signalName,
-                       GVariant* parameters) {
+    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)"))) {
+                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")) {
+                    application == std::string("testapp") &&
+                    message == std::string("testmessage")) {
                 signalEmitted.set();
             }
         }
index 0e40093..ea858e2 100644 (file)
@@ -256,7 +256,7 @@ public:
                                                  api::host::INTERFACE,
                                                  api::host::METHOD_GET_ZONE_DBUSES,
                                                  NULL,
-                                                 "(a{ss})");
+                                                 "(a(ss))");
         GVariant* array = NULL;
         g_variant_get(result.get(), "(*)", &array);
         dbus::GVariantPtr autounref(array, g_variant_unref);
@@ -264,7 +264,7 @@ public:
         for (size_t n = 0; n < count; ++n) {
             const char* zoneId = NULL;
             const char* dbusAddress = NULL;
-            g_variant_get_child(array, n, "{&s&s}", &zoneId, &dbusAddress);
+            g_variant_get_child(array, n, "(&s&s)", &zoneId, &dbusAddress);
             dbuses.insert(Dbuses::value_type(zoneId, dbusAddress));
         }
         return dbuses;