Add Request class for representing cynara requests 90/32190/8
authorAdam Malinowski <a.malinowsk2@partner.samsung.com>
Fri, 28 Nov 2014 15:40:36 +0000 (16:40 +0100)
committerAdam Malinowski <a.malinowsk2@partner.samsung.com>
Wed, 14 Jan 2015 10:43:24 +0000 (11:43 +0100)
Also prepare project to integration with cynara-agent library.

Change-Id: I14e8de8137ac9458f0b7eebacbebafeaba5ee788

packaging/askuser.spec
src/agent/CMakeLists.txt
src/agent/main/Request.h [new file with mode: 0644]

index f7d3127..c3614f9 100644 (file)
@@ -9,12 +9,11 @@ Source1001:    %{name}.manifest
 Source1002:    libaskuser-common.manifest
 Source1003:    askuser-plugins.manifest
 BuildRequires: cmake
-BuildRequires: zip
+BuildRequires: pkgconfig(cynara-agent)
+BuildRequires: pkgconfig(cynara-plugin)
 BuildRequires: pkgconfig(libsystemd-daemon)
 BuildRequires: pkgconfig(libsystemd-journal)
-BuildRequires: pkgconfig(cynara-plugin)
-BuildRequires: pkgconfig(cynara-agent)
-
+BuildRequires: zip
 %{?systemd_requires}
 
 %if !%{defined build_type}
index cbb04e3..5d90013 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+# Copyright (c) 2014-2015 Samsung Electronics Co., Ltd All Rights Reserved
 #
 #    Licensed under the Apache License, Version 2.0 (the "License");
 #    you may not use this file except in compliance with the License.
 # @author      Adam Malinowski <a.malinowsk2@partner.samsung.com>
 #
 
+PKG_CHECK_MODULES(AGENT_DEP
+    REQUIRED
+    cynara-agent
+    cynara-plugin
+    )
+
 SET(ASKUSER_AGENT_PATH ${ASKUSER_PATH}/agent)
 
 SET(ASKUSER_SOURCES
@@ -25,12 +31,14 @@ SET(ASKUSER_SOURCES
 
 INCLUDE_DIRECTORIES(
     ${ASKUSER_PATH}/common
+    ${AGENT_DEP_INCLUDE_DIRS}
     ${ASKUSER_AGENT_PATH}
     )
 
 ADD_EXECUTABLE(${TARGET_ASKUSER} ${ASKUSER_SOURCES})
 
 TARGET_LINK_LIBRARIES(${TARGET_ASKUSER}
+    ${AGENT_DEP_LIBRARIES}
     ${ASKUSER_DEP_LIBRARIES}
     ${TARGET_ASKUSER_COMMON}
     )
diff --git a/src/agent/main/Request.h b/src/agent/main/Request.h
new file mode 100644 (file)
index 0000000..28a6d38
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    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        Request.h
+ * @author      Adam Malinowski <a.malinowsk2@partner.samsung.com>
+ * @brief       This file declares class representing request from cynara service
+ */
+
+#pragma once
+
+#include <cstdlib>
+#include <vector>
+
+#include <cynara-agent.h>
+#include <cynara-plugin.h>
+
+namespace AskUser {
+
+namespace Agent {
+
+typedef enum {
+    RT_Action,
+    RT_Cancel,
+    RT_Close
+} RequestType;
+
+typedef cynara_agent_req_id RequestId;
+
+class Request {
+public:
+    Request() = default;
+    Request(RequestType type, RequestId id, void *data, std::size_t dataSize)
+        : m_type(type), m_id(id), m_data(static_cast<char *>(data), dataSize) {}
+    ~Request() {}
+
+    RequestType type() const {
+        return m_type;
+    }
+
+    RequestId id() const {
+        return m_id;
+    }
+
+    const Cynara::PluginData &data() const {
+        return m_data;
+    }
+
+private:
+    RequestType m_type;
+    RequestId m_id;
+    Cynara::PluginData m_data;
+};
+
+} // namespace Agent
+
+} // namespace AskUser