Integrate draft API header and internal test 37/66337/1
authorKyungwook Tak <k.tak@samsung.com>
Fri, 18 Mar 2016 07:56:46 +0000 (16:56 +0900)
committerKyungwook Tak <k.tak@samsung.com>
Mon, 18 Apr 2016 11:11:59 +0000 (20:11 +0900)
Change-Id: I5c4f8bbeb4e0dbda352e4b6583350dcf3c8bf27c
Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
22 files changed:
packaging/csr-framework.spec
src/CMakeLists.txt
src/framework/client/client-common.cpp [moved from src/framework/client/api.cpp with 67% similarity]
src/framework/client/client-common.h [new file with mode: 0644]
src/framework/client/content-screening.cpp [new file with mode: 0644]
src/framework/client/engine-manager.cpp [new file with mode: 0644]
src/framework/client/error.cpp [moved from src/include/csr/api.h with 75% similarity]
src/framework/client/web-protection.cpp [new file with mode: 0644]
src/framework/common/command-id.h
src/framework/service/logic.cpp
src/framework/service/logic.h
src/include/CMakeLists.txt
src/include/csr/content-screening-types.h [new file with mode: 0644]
src/include/csr/content-screening.h [new file with mode: 0644]
src/include/csr/engine-manager.h [new file with mode: 0644]
src/include/csr/error.h
src/include/csr/web-protection-types.h [new file with mode: 0644]
src/include/csr/web-protection.h [new file with mode: 0644]
test/CMakeLists.txt
test/test-api-content-screening.cpp [new file with mode: 0644]
test/test-api-engine-manager.cpp [moved from test/test-api.cpp with 62% similarity]
test/test-api-web-protection.cpp [new file with mode: 0644]

index b608e66..27887cb 100644 (file)
@@ -147,8 +147,12 @@ fi
 
 %files devel
 %defattr(-,root,root,-)
-%{_includedir}/csr/csr/api.h
+%{_includedir}/csr/csr/content-screening.h
+%{_includedir}/csr/csr/content-screening-types.h
+%{_includedir}/csr/csr/web-protection.h
+%{_includedir}/csr/csr/web-protection-types.h
 %{_includedir}/csr/csr/error.h
+%{_includedir}/csr/csr/engine-manager.h
 %{_libdir}/pkgconfig/%{service_name}.pc
 %{_libdir}/lib%{service_name}-client.so
 %{_libdir}/lib%{service_name}-common.so
index f87caad..b2c6d3d 100644 (file)
@@ -66,7 +66,11 @@ PKG_CHECK_MODULES(${TARGET_CSR_CLIENT}_DEP
 )
 
 SET(${TARGET_CSR_CLIENT}_SRCS
-       framework/client/api.cpp
+       framework/client/client-common.cpp
+       framework/client/content-screening.cpp
+       framework/client/engine-manager.cpp
+       framework/client/error.cpp
+       framework/client/web-protection.cpp
 )
 
 INCLUDE_DIRECTORIES(
similarity index 67%
rename from src/framework/client/api.cpp
rename to src/framework/client/client-common.cpp
index d8604c6..b72faa0 100644 (file)
  *  limitations under the License
  */
 /*
- * @file        api.cpp
+ * @file        client-common.cpp
  * @author      Kyungwook Tak (k.tak@samsung.com)
  * @version     1.0
- * @brief       csr client C APIs
+ * @brief       client common for both of cs / wp
  */
-#include "csr/api.h"
-#include "csr/error.h"
+#include "client-common.h"
 
-#include <functional>
-#include <string>
 #include <exception>
 
+#include "audit/logger.h"
 #include "raw-buffer.h"
-#include "message-buffer.h"
 #include "connection.h"
 #include "socket.h"
-#include "command-id.h"
-#include "audit/logger.h"
-
-#define API __attribute__((visibility("default")))
 
 static void init_lib(void) __attribute__((constructor));
 static void init_lib(void)
@@ -42,6 +35,8 @@ static void init_lib(void)
        Csr::Audit::Logger::setTag("CSR_CLIENT");
 }
 
+namespace Csr {
+
 namespace {
 
 inline Csr::Connection makeConnection(const std::string &address)
@@ -63,8 +58,9 @@ inline Csr::RawBuffer dispatch(const Csr::Connection &connection, const Csr::Raw
        return connection.receive();
 }
 
-using Encoder = std::function<Csr::MessageBuffer(void)>;
-using Decoder = std::function<csr_error_e(Csr::MessageBuffer &&)>;
+} // namespace Csr::anonymous
+
+namespace Client {
 
 auto defaultDecoder = [](Csr::MessageBuffer &&msg) {
        csr_error_e retcode = CSR_ERROR_NONE;
@@ -72,7 +68,8 @@ auto defaultDecoder = [](Csr::MessageBuffer &&msg) {
        return retcode;
 };
 
-auto post = [](Encoder &&encoder, Decoder &&decoder = defaultDecoder) {
+int post(Encoder &&encoder, Decoder &&decoder)
+{
        try {
                auto conn = makeConnection();
 
@@ -85,7 +82,7 @@ auto post = [](Encoder &&encoder, Decoder &&decoder = defaultDecoder) {
                Csr::MessageBuffer msg;
                msg.push(response);
 
-               return decoder(std::move(msg));
+               return decoder ? decoder(std::move(msg)) : defaultDecoder(std::move(msg));
        } catch (const std::exception &e) {
                ERROR("std exception occured: " << e.what());
                /* TODO: divide error codes per exception respectively */
@@ -94,29 +91,8 @@ auto post = [](Encoder &&encoder, Decoder &&decoder = defaultDecoder) {
                ERROR("Unhandled excpeion occured in post!");
                return CSR_ERROR_UNKNOWN;
        }
-};
-
-inline std::string toStlString(const char *cstr)
-{
-       return (cstr == nullptr) ? std::string() : std::string(cstr);
 }
 
-} // namespace anonymous
+} // namespace Csr::Client
 
-API
-int csr_file_scan(const char *filepath)
-{
-       DEBUG("csr_file_scan API start!");
-       return post([&]() {
-                       return Csr::MessageBuffer::Serialize(Csr::CommandId::FILE_SCAN, toStlString(filepath));
-               });
-}
-
-API
-int csr_file_judge(const char *filepath, int judge)
-{
-       DEBUG("csr_file_judge API start!");
-       return post([&]() {
-                       return Csr::MessageBuffer::Serialize(Csr::CommandId::FILE_JUDGE, toStlString(filepath), judge);
-               });
-}
+} // namespace Csr
diff --git a/src/framework/client/client-common.h b/src/framework/client/client-common.h
new file mode 100644 (file)
index 0000000..6c45af8
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ *  Copyright (c) 2016 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        client-common.h
+ * @author      Kyungwook Tak (k.tak@samsung.com)
+ * @version     1.0
+ * @brief       client common for both of cs / wp
+ */
+#pragma once
+
+#include <functional>
+#include <string>
+
+#include "csr/error.h"
+#include "message-buffer.h"
+
+
+namespace Csr {
+namespace Client {
+
+/* Encode parameters which is Command ID specific */
+using Encoder = std::function<Csr::MessageBuffer(void)>;
+
+/* Decode parameters which is Command ID specific */
+using Decoder = std::function<csr_error_e(Csr::MessageBuffer &&)>;
+
+inline std::string toStlString(const char *cstr)
+{
+       return (cstr == nullptr) ? std::string() : std::string(cstr);
+}
+
+/* post request to server with given encoder/decoder
+ * If decoder isn't assigned, default decoder do only deserialize
+ * return code(csr_error_e) from message buffer and return it */
+int post(Encoder &&encoder, Decoder &&decoder = nullptr);
+
+}
+}
diff --git a/src/framework/client/content-screening.cpp b/src/framework/client/content-screening.cpp
new file mode 100644 (file)
index 0000000..a560a01
--- /dev/null
@@ -0,0 +1,349 @@
+/*
+ *  Copyright (c) 2016 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        content-screening.cpp
+ * @author      Kyungwook Tak (k.tak@samsung.com)
+ * @version     1.0
+ * @brief       CSR Content Screening APIs
+ */
+#include "csr/content-screening.h"
+
+#include <functional>
+
+#include "message-buffer.h"
+#include "command-id.h"
+#include "audit/logger.h"
+#include "client-common.h"
+
+#define API __attribute__((visibility("default")))
+
+API
+int csr_cs_context_create(csr_cs_context_h* phandle)
+{
+       (void) phandle;
+
+       DEBUG("start!");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_cs_context_destroy(csr_cs_context_h handle)
+{
+       (void) handle;
+
+       DEBUG("start!");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_cs_set_ask_user(csr_cs_context_h handle, csr_cs_ask_user_e ask_user)
+{
+       (void) handle;
+       (void) ask_user;
+
+       DEBUG("start!");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_cs_set_popup_message(csr_cs_context_h handle, const char* message)
+{
+       (void) handle;
+       (void) message;
+
+       DEBUG("start!");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_cs_set_core_usage(csr_cs_context_h handle, csr_cs_core_usage_e usage)
+{
+       (void) handle;
+       (void) usage;
+
+       DEBUG("start!");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_cs_set_scan_on_cloud(csr_cs_context_h handle)
+{
+       (void) handle;
+
+       DEBUG("start!");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_cs_scan_data(csr_cs_context_h handle, const unsigned char *data, unsigned int length, csr_cs_detected_h *pdetected)
+{
+       (void) handle;
+       (void) data;
+       (void) length;
+       (void) pdetected;
+
+       DEBUG("start!");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_cs_scan_file(csr_cs_context_h handle, const char *file_path, csr_cs_detected_h *pdetected)
+{
+       (void) handle;
+       (void) pdetected;
+
+       DEBUG("start!");
+       // Request to server sample with arguments
+       return Csr::Client::post([&]() {
+                       // TODO: options in handle should be serialized and send to server
+                       return Csr::MessageBuffer::Serialize(
+                               Csr::CommandId::SCAN_FILE,
+                               Csr::Client::toStlString(file_path));
+               });
+       // TODO: Deserialize detected item and give it out
+}
+
+API
+int csr_cs_set_callback_on_detected(csr_cs_context_h handle, csr_cs_on_detected_cb callback)
+{
+       (void) handle;
+       (void) callback;
+
+       DEBUG("start!");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_cs_set_callback_on_completed(csr_cs_context_h handle, csr_cs_on_completed_cb callback)
+{
+       (void) handle;
+       (void) callback;
+
+       DEBUG("start!");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_cs_set_callback_on_cancelled(csr_cs_context_h handle, csr_cs_on_cancelled_cb callback)
+{
+       (void) handle;
+       (void) callback;
+
+       DEBUG("start!");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_cs_set_callback_on_error(csr_cs_context_h handle, csr_cs_on_error_cb callback)
+{
+       (void) handle;
+       (void) callback;
+
+       DEBUG("start!");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_cs_set_callback_on_file_scanned(csr_cs_context_h handle, csr_cs_on_file_scanned_cb callback)
+{
+       (void) handle;
+       (void) callback;
+
+       DEBUG("start!");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_cs_scan_files_async(csr_cs_context_h handle, const char **file_paths, unsigned int count,  void *user_data)
+{
+       (void) handle;
+       (void) file_paths;
+       (void) count;
+       (void) user_data;
+
+       DEBUG("start!");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_cs_scan_dir_async(csr_cs_context_h handle, const char *dir_path)
+{
+       (void) handle;
+       (void) dir_path;
+
+       DEBUG("start!");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_cs_scan_dirs_async(csr_cs_context_h handle, const char **file_paths, unsigned int count, void *user_data)
+{
+       (void) handle;
+       (void) file_paths;
+       (void) count;
+       (void) user_data;
+
+       DEBUG("start!");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_cs_scan_cancel(csr_cs_context_h handle)
+{
+       (void) handle;
+
+       DEBUG("start!");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_cs_detected_get_severity(csr_cs_detected_h detected, csr_cs_severity_level_e* pseverity)
+{
+       (void) detected;
+       (void) pseverity;
+
+       DEBUG("start!");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_cs_detected_get_threat_type(csr_cs_detected_h detected, csr_cs_threat_type_e* pthreat_type)
+{
+       (void) detected;
+       (void) pthreat_type;
+
+       DEBUG("start!");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_cs_detected_get_malware_name(csr_cs_detected_h detected, char** malware_name)
+{
+       (void) detected;
+       (void) malware_name;
+
+       DEBUG("start!");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_cs_detected_get_detailed_url(csr_cs_detected_h detected, char** detailed_url)
+{
+       (void) detected;
+       (void) detailed_url;
+
+       DEBUG("start!");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_cs_detected_get_timestamp(csr_cs_detected_h detected, long* timestamp)
+{
+       (void) detected;
+       (void) timestamp;
+
+       DEBUG("start!");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_cs_detected_get_file_name(csr_cs_detected_h detected, char** file_name)
+{
+       (void) detected;
+       (void) file_name;
+
+       DEBUG("start!");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_cs_detected_get_user_response(csr_cs_detected_h detected, csr_cs_user_response_e* presponse)
+{
+       (void) detected;
+       (void) detected;
+       (void) presponse;
+
+       DEBUG("start!");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_cs_judge_detected_malware(csr_cs_context_h handle, const char *file_path, csr_cs_action_e action)
+{
+       (void) handle;
+       (void) file_path;
+       (void) action;
+
+       DEBUG("start!");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_cs_get_detected_malware(csr_cs_context_h handle, const char *file_path, csr_cs_detected_h *pdetected)
+{
+       (void) handle;
+       (void) file_path;
+       (void) pdetected;
+
+       DEBUG("start!");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_cs_get_detected_malwares(csr_cs_context_h handle, const char *dir, csr_cs_detected_list_h *plist, int *pcount)
+{
+       (void) handle;
+       (void) dir;
+       (void) plist;
+       (void) pcount;
+
+       DEBUG("start!");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_cs_get_ignored_malware(csr_cs_context_h handle, const char *file_path, csr_cs_detected_h *pdetected)
+{
+       (void) handle;
+       (void) file_path;
+       (void) pdetected;
+
+       DEBUG("start!");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_cs_get_ignored_malwares(csr_cs_context_h handle, const char *dir, csr_cs_detected_list_h *plist, int *pcount)
+{
+       (void) handle;
+       (void) dir;
+       (void) plist;
+       (void) pcount;
+
+       DEBUG("start!");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_cs_dlist_get_detected(csr_cs_detected_list_h list, int index, csr_cs_detected_h *pdetected)
+{
+       (void) list;
+       (void) index;
+       (void) pdetected;
+
+       DEBUG("start!");
+       return CSR_ERROR_NONE;
+}
diff --git a/src/framework/client/engine-manager.cpp b/src/framework/client/engine-manager.cpp
new file mode 100644 (file)
index 0000000..147d7c1
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ *  Copyright (c) 2016 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        engine-manager.cpp
+ * @author      Kyungwook Tak (k.tak@samsung.com)
+ * @version     1.0
+ * @brief       CSR Engine manager APIs
+ */
+#include "csr/engine-manager.h"
+
+#include "audit/logger.h"
+
+#define API __attribute__((visibility("default")))
+
+API
+int csr_get_selected_engine(csr_engine_id_e id, csr_engine_h *engine)
+{
+       (void) id;
+       (void) engine;
+       DEBUG("start");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_engine_get_vendor(csr_engine_h engine, char **vendor)
+{
+       (void) engine;
+       (void) vendor;
+       DEBUG("start");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_engine_get_name(csr_engine_h engine, char **name)
+{
+       (void) engine;
+       (void) name;
+       DEBUG("start");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_engine_get_version(csr_engine_h engine, char **version)
+{
+       (void) engine;
+       (void) version;
+       DEBUG("start");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_engine_get_data_version(csr_engine_h engine, char **version)
+{
+       (void) engine;
+       (void) version;
+       DEBUG("start");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_engine_get_activated(csr_engine_h engine, csr_activated_e *pactivated)
+{
+       (void) engine;
+       (void) pactivated;
+
+       DEBUG("start");
+       return CSR_ERROR_NONE;
+}
similarity index 75%
rename from src/include/csr/api.h
rename to src/framework/client/error.cpp
index da9a3da..17755ff 100644 (file)
  *  limitations under the License
  */
 /*
- * @file        api.h
+ * @file        error.cpp
  * @author      Kyungwook Tak (k.tak@samsung.com)
  * @version     1.0
  * @brief
  */
-#ifndef __CSR_API_H_
-#define __CSR_API_H_
-
 #include "csr/error.h"
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include "audit/logger.h"
 
-int csr_file_scan(const char *filepath);
+#define API __attribute__((visibility("default")))
 
-int csr_file_judge(const char *filepath, int judge);
+API
+int csr_get_error_string(int error_code, char** string)
+{
+       (void) error_code;
+       (void) string;
 
-#ifdef __cplusplus
+       DEBUG("start");
+       return CSR_ERROR_NONE;
 }
-#endif
-
-#endif
diff --git a/src/framework/client/web-protection.cpp b/src/framework/client/web-protection.cpp
new file mode 100644 (file)
index 0000000..3db2c50
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ *  Copyright (c) 2016 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        web-protection.cpp
+ * @author      Kyungwook Tak (k.tak@samsung.com)
+ * @version     1.0
+ * @brief       CSR Web Protection APIs
+ */
+#include "csr/web-protection.h"
+
+#include <functional>
+
+#include "message-buffer.h"
+#include "command-id.h"
+#include "audit/logger.h"
+#include "client-common.h"
+
+#define API __attribute__((visibility("default")))
+
+API
+int csr_wp_context_create(csr_wp_context_h* phandle)
+{
+       (void) phandle;
+
+       DEBUG("start");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_wp_context_destroy(csr_wp_context_h handle)
+{
+       (void) handle;
+
+       DEBUG("start");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_wp_set_ask_user(csr_wp_context_h handle, csr_wp_ask_user_e ask_user)
+{
+       (void) handle;
+       (void) ask_user;
+
+       DEBUG("start");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_wp_set_popup_message(csr_wp_context_h handle, const char* message)
+{
+       (void) handle;
+       (void) message;
+
+       DEBUG("start");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_wp_check_url(csr_wp_context_h handle, const char *url, csr_wp_check_result_h *presult)
+{
+       (void) handle;
+       (void) presult;
+
+       DEBUG("start");
+       // Request to server sample with arguments
+       return Csr::Client::post([&]() {
+                       // TODO: options in handle should be serialized and send to server
+                       return Csr::MessageBuffer::Serialize(
+                               Csr::CommandId::CHECK_URL,
+                               Csr::Client::toStlString(url));
+               });
+       // TODO: Deserialize result and give it out
+}
+
+API
+int csr_wp_result_get_risk_level(csr_wp_check_result_h result, csr_wp_risk_level_e* plevel)
+{
+       (void) result;
+       (void) plevel;
+
+       DEBUG("start");
+       return CSR_ERROR_NONE;
+}
+
+API
+int csr_wp_result_get_user_response(csr_wp_check_result_h result, csr_wp_user_response_e* presponse)
+{
+       (void) result;
+       (void) presponse;
+
+       DEBUG("start");
+       return CSR_ERROR_NONE;
+}
index 419998c..2ad184f 100644 (file)
@@ -24,8 +24,9 @@
 namespace Csr {
 
 enum class CommandId : int {
-       FILE_SCAN  = 0x01,
-       FILE_JUDGE = 0x02
+       SCAN_FILE    = 0x01,
+       JUDGE_STATUS = 0x02,
+       CHECK_URL    = 0x03
 };
 
 }
index e7abadb..0332cb9 100644 (file)
@@ -23,7 +23,7 @@
 
 #include <string>
 #include <utility>
-#include <iostream>
+#include <stdexcept>
 
 #include "audit/logger.h"
 #include "csr/error.h"
@@ -45,22 +45,24 @@ RawBuffer Logic::dispatch(const RawBuffer &in)
        INFO("Request dispatch! CommandId: " << static_cast<int>(info.first));
 
        switch (info.first) {
-       case CommandId::FILE_SCAN: {
+       case CommandId::SCAN_FILE: {
                std::string filepath;
+               // csr-cs handle deserialize
                info.second.Deserialize(filepath);
-               return fileScan(filepath);
+               return scanFile(filepath);
        }
 
-       case CommandId::FILE_JUDGE: {
-               std::string filepath;
-               int judge;
-               info.second.Deserialize(filepath, judge);
-               return fileJudge(filepath, judge);
+       /* TODO: should we separate command->logic mapping of CS and WP ? */
+       case CommandId::CHECK_URL: {
+               std::string url;
+               // csr-wp handle deserialize
+               info.second.Deserialize(url);
+               return checkUrl(url);
        }
 
        default:
-               /* TODO: throw request info broken exception */
-               return RawBuffer();
+               throw std::range_error(FORMAT("Command id[" << static_cast<int>(info.first)
+                       << "] isn't in range."));
        }
 }
 
@@ -75,18 +77,15 @@ std::pair<CommandId, MessageBuffer> Logic::getRequestInfo(const RawBuffer &data)
        return std::make_pair(id, std::move(msgbuffer));
 }
 
-RawBuffer Logic::fileScan(const std::string &filepath)
+RawBuffer Logic::scanFile(const std::string &filepath)
 {
-       DEBUG("Do filescan through engine with filepath: " << filepath);
-
+       DEBUG("Scan file[" << filepath << "] by engine");
        return MessageBuffer::Serialize(CSR_ERROR_NONE).pop();
 }
 
-RawBuffer Logic::fileJudge(const std::string &filepath, int judge)
+RawBuffer Logic::checkUrl(const std::string &url)
 {
-       DEBUG("Do filejudge through engine with filepath: " << filepath
-               << " and judge: " << judge);
-
+       DEBUG("CHeck url[" << url << "] by engine");
        return MessageBuffer::Serialize(CSR_ERROR_NONE).pop();
 }
 
index 9baecd2..4f3dbb3 100644 (file)
@@ -40,8 +40,8 @@ public:
 private:
        std::pair<CommandId, MessageBuffer> getRequestInfo(const RawBuffer &);
 
-       RawBuffer fileScan(const std::string &filepath);
-       RawBuffer fileJudge(const std::string &filepath, int judge);
+       RawBuffer scanFile(const std::string &filepath);
+       RawBuffer checkUrl(const std::string &url);
 };
 
 }
index db25033..240089e 100644 (file)
 # @author      Kyungwook Tak (k.tak@samsung.com)
 # @brief       install headers to be built with clients
 #
-INSTALL(
-       FILES
-               csr/api.h
-               csr/error.h
-       DESTINATION
-               ${INCLUDE_INSTALL_DIR}/csr/csr
-)
+INSTALL(DIRECTORY csr DESTINATION ${INCLUDE_INSTALL_DIR}/csr)
diff --git a/src/include/csr/content-screening-types.h b/src/include/csr/content-screening-types.h
new file mode 100644 (file)
index 0000000..c3adce2
--- /dev/null
@@ -0,0 +1,139 @@
+/*
+ *  Copyright (c) 2016 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        content-screening-types.h
+ * @author      Dongsun Lee (ds73.lee@samsung.com)
+ * @version     1.0
+ * @brief
+ */
+#ifndef __CSR_CONTENT_SCREENING_TYPES_H_
+#define __CSR_CONTENT_SCREENING_TYPES_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief Severity level of an detected malware
+ */
+typedef enum {
+       CSR_CS_SEVERITY_LOW    = 0x01,  /**< Low Severity. Process with a warning log. */
+       CSR_CS_SEVERITY_MEDIUM = 0x02,  /**< Medium Severity. Prompt the user before processing. Ask the user if the user wants the application to process the data. */
+       CSR_CS_SEVERITY_HIGH   = 0x03   /**< High Severity. Do not process the data and prompt user for removal. */
+} csr_cs_severity_level_e;
+
+/**
+ * @brief the type of a threat detected
+ */
+typedef enum {
+       CSR_CS_THREAT_MALWARE = 0x00,  /**< Malware. */
+       CSR_CS_THREAT_RISKY   = 0x01,  /**< It's not a malware but still risky. */
+       CSR_CS_THREAT_GENERIC = 0x02   /**< Generic threat */
+} csr_cs_threat_type_e;
+
+/**
+ * @brief the options about prompting a popup to a user.
+ */
+typedef enum {
+       CSR_CS_NOT_ASK_USER = 0x00, /**< Do not ask the user even if malicious contents were found.*/
+       CSR_CS_ASK_USER     = 0x01  /**< Ask the user when malicious contents were found */
+} csr_cs_ask_user_e;
+
+/**
+ * @brief the user response for a popup.
+ */
+typedef enum {
+       CSR_CS_NO_ASK_USER   = 0x00, /**< There was no popup for asking the user. */
+       CSR_CS_REMOVE        = 0x01, /**< A user decided to remove a detected malicious content and it was removed */
+       CSR_CS_IGNORE        = 0x02, /**< A user decided to ignore a detected malicious content.*/
+       CSR_CS_SKIP          = 0x03, /**< A user decided to skip a detected malicious content.*/
+       CSR_CS_REMOVE_FAILED = 0x04  /**< A user decided to remove but removal failed.*/
+} csr_cs_user_response_e;
+
+/**
+ * @brief  the action types for the detected malware files
+ */
+typedef enum {
+       CSR_CS_ACTION_REMOVE   = 0x00,  /* Remove the detected malware file */
+       CSR_CS_ACTION_IGNORE   = 0x01,  /* Ignore the detected malware file */
+       CSR_CS_ACTION_UNIGNORE = 0x02   /* Unignore the previously ignored file */
+} csr_cs_action_e;
+
+/**
+ * @brief Maximum core usage during scanning
+ */
+typedef enum {
+       CSR_CS_USE_CORE_DEFAULT = 0x00,  /* Use default setting value */
+       CSR_CS_USE_CORE_ALL     = 0x01,  /* Use all cores during scanning. */
+       CSR_CS_USE_CORE_HALF    = 0x02,  /* Use half cores during scanning. */
+       CSR_CS_USE_CORE_SINGLE  = 0x03   /* Use a single core during scanning */
+} csr_cs_core_usage_e;
+
+/**
+ * @brief TCS context handle.
+ */
+typedef struct __csr_cs_context_s* csr_cs_context_h;
+
+/**
+ * @brief TCS detected malware info handle.
+ */
+typedef struct __csr_cs_detected_s* csr_cs_detected_h;
+
+/**
+ * @brief TCS detected malware list handle
+ */
+typedef struct __csr_cs_detected_list_s* csr_cs_detected_list_h;
+
+/**
+ * @brief TCS engine info handle.
+ */
+typedef struct __csr_cs_engine_s* csr_cs_engine_h;
+
+/**
+ * @brief The callback function is called  when a malware detected.\
+ *        It's only for an asynchronous scan function.
+ */
+typedef void (*csr_cs_on_detected_cb)(void *user_data, csr_cs_detected_h* pdetected);
+
+/**
+ * @brief The callback function is called  when scanning is fininshed without an error.\
+ *        It's only for an asynchronous scan function.
+ */
+typedef void (*csr_cs_on_completed_cb)(void *user_data);
+
+/**
+ * @brief The callback function is called  when scanning is cancelled without an error.\
+ *        It's only for an asynchronous scan function.
+ */
+typedef void (*csr_cs_on_cancelled_cb)(void *user_data);
+
+/**
+ * @brief The callback function is called when scanning is fininshed with an error.\
+ *        It's only for an asynchronous scan function.
+ */
+typedef void (*csr_cs_on_error_cb)(void *user_data, int error_code);
+
+/**
+ * @brief The callback function is called when a file scan is completed.\
+ *        It's only for an asynchronous scan function.
+ */
+typedef void (*csr_cs_on_file_scanned_cb)(void *user_data, const char* file_path);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/include/csr/content-screening.h b/src/include/csr/content-screening.h
new file mode 100644 (file)
index 0000000..8055f12
--- /dev/null
@@ -0,0 +1,667 @@
+/*
+ *  Copyright (c) 2016 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        content-screening.h
+ * @author      Dongsun Lee (ds73.lee@samsung.com)
+ * @version     1.0
+ * @brief
+ */
+#ifndef __CSR_CONTENT_SCREENING_API_H_
+#define __CSR_CONTENT_SCREENING_API_H_
+
+#include "csr/content-screening-types.h"
+#include "csr/error.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief Initializes and returns a Malware Screening API handle.
+ *
+ * @details A Malware Screening API handle (or CSR CS handle) is obtained using the
+ *          csr_cs_context_create() function. The handle is required for subsequent
+ *          CSR CS API calls. The csr_cs_context_destroy() function releases/closes
+ *          the handle. Multiple handles can be obtained using csr_cs_context_create().
+ *
+ * @param[out] phandle A pointer of CSR CS context handle.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                  Successful
+ * @retval #CSR_ERROR_OUT_OF_MEMORY         Not enough memory
+ * @retval #CSR_ERROR_INVALID_PARAMETER     phandle is invalid
+ * @retval #CSR_ERROR_PERMISSION_DENIED     Permission denied
+ * @retval #CSR_ERROR_SOCKET                Socket error between client and server
+ * @retval #CSR_ERROR_SERVER                Server has been failed for some reason
+ * @retval #CSR_ERROR_ENGINE_INTERNAL       Engine Internal error
+ * @retval #CSR_ERROR_UNKNOWN               Error with unknown reason
+ */
+int csr_cs_context_create(csr_cs_context_h* phandle);
+
+/**
+ * @brief Releases all system resources associated with a Malware Screening API handle.
+ *
+ * @details The handle is one returned by the csr_cs_context_create() function.
+ *
+ * @param[in] handle CSR CS context handle returned by csr_cs_context_create().
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                  Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE        Invalid handle
+ * @retval #CSR_ERROR_SOCKET                Socket error between client and server
+ * @retval #CSR_ERROR_SERVER                Server has been failed for some reason
+ * @retval #CSR_ERROR_ENGINE_INTERNAL       Engine Internal error
+ * @retval #CSR_ERROR_UNKNOWN               Error with unknown reason
+ */
+int csr_cs_context_destroy(csr_cs_context_h handle);
+
+/**
+ * @brief Sets a popup option in case that a malware is detected.
+ *
+ * @details If #CSR_CS_ASK_USER is set, a popup will be prompted to a user when a malware
+ *          is detected(#CSR_CS_SEVERITY_MEDIUM or #CSR_CS_SEVERITY_HIGH). If
+ *          #CSR_CS_NOT_ASK_USER is set, no popup will be prompted even when a malware is
+ *          detected. The default value of this option is #CSR_CS_ASK_USER. When a user
+ *          selects to remove a detected malicious content, the content will be removed
+ *          only if the client has the permission to remove the content.
+ *
+ * @param[in] handle    CSR CS context handle returned by csr_cs_context_create().
+ * @param[in] ask_user  A popup option in case for a risky URL.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                  Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE        Invalid handle
+ * @retval #CSR_ERROR_INVALID_PARAMETER     ask_user is invalid
+ * @retval #CSR_ERROR_UNKNOWN               Error with unknown reason
+ */
+int csr_cs_set_ask_user(csr_cs_context_h handle, csr_cs_ask_user_e ask_user);
+
+/**
+ * @brief Sets a popup message of a client in case that a malware is detected.
+ *
+ * @details When a popup is prompted to a user, the message set by this method will be
+ *          shown. When a client doesn't set his own popup message, the default message
+ *          will be shown in the popup.
+ *
+ * @param[in] handle  CSR CS context handle returned by csr_cs_context_create().
+ * @param[in] message a message in a popup.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                  Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE        Invalid handle
+ * @retval #CSR_ERROR_INVALID_PARAMETER     message is invalid. Max size is 64 bytes.
+ * @retval #CSR_ERROR_UNKNOWN               Error with unknown reason
+ *
+ * @see csr_cs_context_create()
+ */
+int csr_cs_set_popup_message(csr_cs_context_h handle, const char* message);
+
+/**
+ * @brief Sets a maxium core usage during scanning.
+ *
+ * @details If a core usage is not set, CSR_CS_USE_CORE_DEFAULT will be used.
+ *
+ * @param[in] handle    CSR CS context handle returned by csr_cs_context_create().
+ * @param[in] usage     A maxium core usage during scanning.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                  Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE        Invalid handle
+ * @retval #CSR_ERROR_INVALID_PARAMETER     usage is invalid
+ * @retval #CSR_ERROR_UNKNOWN               Error with unknown reason
+ */
+int csr_cs_set_core_usage(csr_cs_context_h handle, csr_cs_core_usage_e usage);
+
+/**
+ * @brief Sets a database which is used in scanning.
+ *
+ * @details If a database is not set or an engine does not support "scanning on cloud",
+ *          the scanning will be done in a local device.
+ *
+ * @param[in] handle    CSR CS context handle returned by csr_cs_context_create().
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                  Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE        Invalid handle
+ * @retval #CSR_ERROR_UNKNOWN               Error with unknown reason
+ */
+int csr_cs_set_scan_on_cloud(csr_cs_context_h handle);
+
+/**
+ * @brief Main function for caller to scan a data buffer for malware.
+ *
+ * @details  Scan data synchronously.
+ *
+ * @param[in]  handle     CSR CS context handle returned by csr_cs_context_create().
+ * @param[in]  data       A scan target data.
+ * @param[in]  length     A size of a scan target data.
+ * @param[out] pdetected  A pointer of the detected malware handle. It can be null when no malware detected.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                  Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE        Invalid handle
+ * @retval #CSR_ERROR_OUT_OF_MEMORY         Not enough memory
+ * @retval #CSR_ERROR_INVALID_PARAMETER     data or presult is invalid
+ * @retval #CSR_ERROR_SOCKET                Socket error between client and server
+ * @retval #CSR_ERROR_SERVER                Server has been failed for some reason
+ * @retval #CSR_ERROR_ENGINE_NOT_SELECTED   No engine selected
+ * @retval #CSR_ERROR_ENGINE_NOT_ACTIVATED  Engine is not activated
+ * @retval #CSR_ERROR_ENGINE_INTERNAL       Engine Internal error
+ * @retval #CSR_ERROR_UNKNOWN               Error with unknown reason
+ */
+int csr_cs_scan_data(csr_cs_context_h handle,
+                  const unsigned char *data,
+                  unsigned int length,
+                  csr_cs_detected_h *pdetected);
+
+/**
+ * @brief Main function for caller to scan a file specified by file path for malware.
+ *
+ * @details  Scan file synchronously.
+ *
+ * @param[in]  handle     CSR CS context handle returned by csr_cs_context_create().
+ * @param[in]  file_path  A path of scan target file.
+ * @param[out] pdetected  A pointer of the detected malware handle. It can be null when no malware detected.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                  Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE        Invalid handle
+ * @retval #CSR_ERROR_OUT_OF_MEMORY         Not enough memory
+ * @retval #CSR_ERROR_INVALID_PARAMETER     file_path or presult is invalid
+ * @retval #CSR_ERROR_PERMISSION_DENIED     Access denied
+ * @retval #CSR_ERROR_FILE_NOT_FOUND        File not found
+ * @retval #CSR_ERROR_SOCKET                Socket error between client and server
+ * @retval #CSR_ERROR_SERVER                Server has been failed for some reason
+ * @retval #CSR_ERROR_ENGINE_NOT_SELECTED   No engine selected
+ * @retval #CSR_ERROR_ENGINE_NOT_ACTIVATED  Engine is not activated
+ * @retval #CSR_ERROR_ENGINE_INTERNAL       Engine Internal error
+ * @retval #CSR_ERROR_UNKNOWN               Error with unknown reason
+ */
+int csr_cs_scan_file(csr_cs_context_h handle,
+                  const char *file_path,
+                  csr_cs_detected_h *pdetected);
+
+/**
+ * @brief Sets a callback function for detection of a malware.
+ *
+ * @details Callback for asynchronous scan function.
+ *
+ * @param[in] handle    CSR CS context handle returned by csr_cs_context_create().
+ * @param[in] callback  a callback function for detection of a malware.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                  Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE        Invalid handle
+ * @retval #CSR_ERROR_INVALID_PARAMETER     callback is invalid
+ * @retval #CSR_ERROR_UNKNOWN               Error with unknown reason
+ */
+int csr_cs_set_callback_on_detected(csr_cs_context_h handle, csr_cs_on_detected_cb callback);
+
+/**
+ * @brief Sets a callback function for scanning completed without an error.
+ *
+ * @details Callback for asynchronous scan function.
+ *
+ * @param[in] handle    CSR CS context handle returned by csr_cs_context_create().
+ * @param[in] callback  a callback function for scanning completed without an error.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                  Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE        Invalid handle
+ * @retval #CSR_ERROR_INVALID_PARAMETER     callback is invalid
+ * @retval #CSR_ERROR_UNKNOWN               Error with unknown reason
+ */
+int csr_cs_set_callback_on_completed(csr_cs_context_h handle, csr_cs_on_completed_cb callback);
+
+/**
+ * @brief Sets a callback function for scanning cancelled.
+ *
+ * @details Callback for asynchronous scan function.
+ *
+ * @param[in] handle    CSR CS context handle returned by csr_cs_context_create().
+ * @param[in] callback  a callback function for scanning cancelled.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                  Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE        Invalid handle
+ * @retval #CSR_ERROR_INVALID_PARAMETER     callback is invalid
+ * @retval #CSR_ERROR_UNKNOWN               Error with unknown reason
+ */
+int csr_cs_set_callback_on_cancelled(csr_cs_context_h handle, csr_cs_on_cancelled_cb callback);
+
+/**
+ * @brief Sets a callback function for scanning stopped with an error.
+ *
+ * @details Callback for asynchronous scan function.
+ *
+ * @param[in] handle    CSR CS context handle returned by csr_cs_context_create().
+ * @param[in] callback  a callback function for scanning stopped with an error.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                  Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE        Invalid handle
+ * @retval #CSR_ERROR_INVALID_PARAMETER     callback is invalid
+ * @retval #CSR_ERROR_UNKNOWN               Error with unknown reason
+ */
+int csr_cs_set_callback_on_error(csr_cs_context_h handle, csr_cs_on_error_cb callback);
+
+
+/**
+ * @brief Sets a callback function for the case that a file scan is completed.
+ *
+ * @details Callback for asynchronous scan function.
+ *
+ * @param[in] handle    CSR CS context handle returned by csr_cs_context_create().
+ * @param[in] callback  a callback function for the case that a file scan is completed.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                  Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE        Invalid handle
+ * @retval #CSR_ERROR_INVALID_PARAMETER     callback is invalid
+ * @retval #CSR_ERROR_UNKNOWN               Error with unknown reason
+ */
+int csr_cs_set_callback_on_file_scanned(csr_cs_context_h handle, csr_cs_on_file_scanned_cb callback);
+
+/**
+ * @brief Main function for caller to scan files specified by an array of file paths
+ *        for malware.
+ *
+ * @details  Asynchronous function. The caller should set callback functions before
+ *           calls this.
+ *
+ * @param[in]  handle       CSR CS context handle returned by csr_cs_context_create().
+ * @param[in]  file_paths   An array of scan target files.
+ * @param[in]  count        A number of scan target files.
+ * @param[in]  user_data    The pointer of a user data. It can be null.\n
+ *                          It is delivered back to the client when a callback function is called.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                  Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE        Invalid handle
+ * @retval #CSR_ERROR_OUT_OF_MEMORY         Not enough memory
+ * @retval #CSR_ERROR_INVALID_PARAMETER     file_paths or count is invalid
+ * @retval #CSR_ERROR_PERMISSION_DENIED     Access denied
+ * @retval #CSR_ERROR_FILE_NOT_FOUND        File not found
+ * @retval #CSR_ERROR_SOCKET                Socket error between client and server
+ * @retval #CSR_ERROR_SERVER                Server has been failed for some reason
+ * @retval #CSR_ERROR_ENGINE_NOT_SELECTED   No engine selected
+ * @retval #CSR_ERROR_ENGINE_NOT_ACTIVATED  Engine is not activated
+ * @retval #CSR_ERROR_ENGINE_INTERNAL       Engine Internal error
+ * @retval #CSR_ERROR_UNKNOWN               Error with unknown reason
+ */
+int csr_cs_scan_files_async(csr_cs_context_h handle,
+                  const char **file_paths,
+                  unsigned int count,
+                  void *user_data);
+
+/**
+ * @brief Main function for caller to scan a directoy specified by
+ *        directory path for malware.
+ *
+ * @details  Asynchronous function. The caller should set callback functions before calls
+ *           this. All files under target directory which can be accessed by a client are
+ *           scanned.
+ *
+ * @param[in]  handle     CSR CS context handle returned by csr_cs_context_create().
+ * @param[in]  dir_path   A path of scan target directory.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                  Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE        Invalid handle
+ * @retval #CSR_ERROR_OUT_OF_MEMORY         Not enough memory
+ * @retval #CSR_ERROR_INVALID_PARAMETER     file_path or presult is invalid
+ * @retval #CSR_ERROR_PERMISSION_DENIED     Access denied
+ * @retval #CSR_ERROR_FILE_NOT_FOUND        File not found
+ * @retval #CSR_ERROR_SOCKET                Socket error between client and server
+ * @retval #CSR_ERROR_SERVER                Server has been failed for some reason
+ * @retval #CSR_ERROR_ENGINE_NOT_SELECTED   No engine selected
+ * @retval #CSR_ERROR_ENGINE_NOT_ACTIVATED  Engine is not activated
+ * @retval #CSR_ERROR_ENGINE_INTERNAL       Engine Internal error
+ * @retval #CSR_ERROR_UNKNOWN               Error with unknown reason
+ */
+int csr_cs_scan_dir_async(csr_cs_context_h handle,
+                  const char *dir_path);
+
+/**
+ * @brief Main function for caller to scan directories specified by
+ *        an array of directory paths for malware.
+ *
+ * @details  Asynchronous function. The caller should set callback functions before calls
+ *           this. All files under target directories which can be accessed by a client
+ *           are scanned.
+ *
+ * @param[in]  handle       CSR CS context handle returned by csr_cs_context_create().
+ * @param[in]  dir_paths    An array of scan target directories.
+ * @param[in]  count        A number of scan target directories.
+ * @param[in]  user_data    The pointer of a user data. It can be null.
+ *                          It is delivered back to the client when a callback
+ *                          function is called.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                  Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE        Invalid handle
+ * @retval #CSR_ERROR_OUT_OF_MEMORY         Not enough memory
+ * @retval #CSR_ERROR_INVALID_PARAMETER     file_paths or count is invalid
+ * @retval #CSR_ERROR_PERMISSION_DENIED     Access denied
+ * @retval #CSR_ERROR_FILE_NOT_FOUND        File not found
+ * @retval #CSR_ERROR_SOCKET                Socket error between client and server
+ * @retval #CSR_ERROR_SERVER                Server has been failed for some reason
+ * @retval #CSR_ERROR_ENGINE_NOT_SELECTED   No engine selected
+ * @retval #CSR_ERROR_ENGINE_NOT_ACTIVATED  Engine is not activated
+ * @retval #CSR_ERROR_ENGINE_INTERNAL       Engine Internal error
+ * @retval #CSR_ERROR_UNKNOWN               Error with unknown reason
+ */
+int csr_cs_scan_dirs_async(csr_cs_context_h handle,
+                  const char **file_paths,
+                  unsigned int count,
+                  void *user_data);
+
+
+/**
+ * @brief Cancels a running scanning task.
+ *
+ * @details It's only for an asynchronous scan function.
+ *
+ * @param[in] handle    CSR CS context handle returned by csr_cs_context_create().
+ * @param[in] callback  a callback function for the case that a file scan is completed.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                  Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE        Invalid handle
+ * @retval #CSR_ERROR_INVALID_PARAMETER     callback is invalid
+ * @retval #CSR_ERROR_NO_TASK               No task to cancel
+ * @retval #CSR_ERROR_UNKNOWN               Error with unknown reason
+ */
+int csr_cs_scan_cancel(csr_cs_context_h handle);
+
+//==============================================================================
+// Result related
+//==============================================================================
+
+/**
+ * @brief extracts the severity of a detected malware from the detected malware handle.
+ *
+ * @param[in]  detected    A detected malware handle returned
+ *                         by csr_cs_result_get_detected_by_idx() or
+ *                         csr_cs_result_get_detected_most_severe().
+ * @param[out] pseverity  A pointer of the severity of a detected malware.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                 Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE       Invalid detected malware handle
+ * @retval #CSR_ERROR_INVALID_PARAMETER    pseverity is invalid.
+ * @retval #CSR_ERROR_UNKNOWN              Error with unknown reason
+ */
+int csr_cs_detected_get_severity(csr_cs_detected_h detected, csr_cs_severity_level_e* pseverity);
+
+/**
+ * @brief extracts the threat type of a detected malware from the detected malware handle.
+ *
+ * @param[in]  detected      A detected malware handle.
+ * @param[out] pthreat_type  A pointer of the threat type of a detected malware.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                 Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE       Invalid detected malware handle
+ * @retval #CSR_ERROR_INVALID_PARAMETER    pharmful_type is invalid.
+ * @retval #CSR_ERROR_UNKNOWN              Error with unknown reason
+ */
+int csr_cs_detected_get_threat_type(csr_cs_detected_h detected, csr_cs_threat_type_e* pthreat_type);
+
+/**
+ * @brief extracts the name of a detected malware from the detected malware handle.
+ *
+ * @param[in]  detected      A detected malware handle.
+ * @param[out] malware_name  A pointer of the name of a detected malware. A caller
+ *                           should not free this string.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                 Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE       Invalid detected malware handle
+ * @retval #CSR_ERROR_INVALID_PARAMETER    malware_name is invalid
+ * @retval #CSR_ERROR_UNKNOWN              Error with unknown reason
+ */
+int csr_cs_detected_get_malware_name(csr_cs_detected_h detected, char** malware_name);
+
+/**
+ * @brief extracts an url that contains detailed information on vendor's web site from the detected malware handle.
+ *
+ * @param[in]  detected      A detected malware handle.
+ * @param[out] detailed_url  A pointer of an url that contains detailed information on vendor's web site.\n
+ *                           It can be null if a vendor doesn't provide this information.\n
+ *                           A caller should not free this string.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                 Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE       Invalid detected malware handle
+ * @retval #CSR_ERROR_INVALID_PARAMETER    malware_name is invalid.
+ * @retval #CSR_ERROR_UNKNOWN              Error with unknown reason
+ */
+int csr_cs_detected_get_detailed_url(csr_cs_detected_h detected, char** detailed_url);
+
+/**
+ * @brief extracts the time stamp when a malware is detected from the detected malware handle.
+ *
+ * @param[in]  detected   A detected malware handle.
+ * @param[out] timestamp  A pointer of the time stamp in milli second when a malware is detected. A caller should not free this.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                 Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE       Invalid detected malware handle
+ * @retval #CSR_ERROR_INVALID_PARAMETER    timestamp is invalid
+ * @retval #CSR_ERROR_UNKNOWN              Error with unknown reason
+ */
+int csr_cs_detected_get_timestamp(csr_cs_detected_h detected, long* timestamp);
+
+/**
+ * @brief extracts the file name where a malware is detected from the detected malware handle.
+ *
+ * @param[in]  detected      A detected malware handle.
+ * @param[out] file_name  A pointer of the file name where a malware is detected. A caller should not free this string. The file name is Null for csr_cs_scan_data.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                 Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE       Invalid detected malware handle
+ * @retval #CSR_ERROR_INVALID_PARAMETER    file_name is invalid
+ * @retval #CSR_ERROR_UNKNOWN              Error with unknown reason
+ */
+int csr_cs_detected_get_file_name(csr_cs_detected_h detected, char** file_name);
+
+/**
+ * @brief extracts a user reponse of a popup from the detected malware handle.
+ *
+ * @param[in]  detected      A detected malware handle.
+ * @param[out] presponse     A pointer of the user response.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                 Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE       Invalid result handle
+ * @retval #CSR_ERROR_INVALID_PARAMETER    presponse is invalid
+ * @retval #CSR_ERROR_UNKNOWN              Error with unknown reason
+ *
+ */
+int csr_cs_detected_get_user_response(csr_cs_detected_h detected, csr_cs_user_response_e* presponse);
+
+/**
+ * @brief Judges how a detected malware file is handled.
+ *
+ * @details  A detected malware may be removed or ignored. When action is
+ *           #CSR_CS_ACTION_REMOVE, the detected malware file will be removed. If a
+ *           detected malware is in an application, the application will be removed.
+ *           Otherwise, only the file will be removed. When a client removes a detected
+ *           malware with this API, the client must have the privilege to remove it.
+ *           When action is #CSR_CS_ACTION_IGNORE, the dectected malware file won't be
+ *           removed. And the ignored file will not treated as malicious. When action is
+ *           #CSR_CS_ACTION_UNIGNORE, the ignored file will be considered as mailicous
+ *           again.
+ *
+ * @param[in]  handle     CSR CS context handle returned by csr_cs_context_create().
+ * @param[in]  file_path  A path of a detected malware file.
+ * @param[in]  action     An action to be taken.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                  Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE        Invalid handle
+ * @retval #CSR_ERROR_OUT_OF_MEMORY         Not enough memory
+ * @retval #CSR_ERROR_INVALID_PARAMETER     file_path or action is invalid
+ * @retval #CSR_ERROR_PERMISSION_DENIED     No permission to remove
+ * @retval #CSR_ERROR_FILE_NOT_FOUND        File to take action on not found
+ * @retval #CSR_ERROR_SOCKET                Socket error between client and server
+ * @retval #CSR_ERROR_SERVER                Server has been failed for some reason
+ * @retval #CSR_ERROR_UNKNOWN               Error with unknown reason
+ */
+int csr_cs_judge_detected_malware(csr_cs_context_h handle, const char *file_path, csr_cs_action_e action);
+
+
+/**
+ * @brief Gets information on a detected malware file specified by file path.
+ *
+ * @param[in]  handle     CSR CS context handle returned by csr_cs_context_create().
+ * @param[in]  file_path  A path of a detected malware file.
+ * @param[out] pdetected  A pointer of the detected malware handle. It can be null when
+ *                        no malware file.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                  Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE        Invalid handle
+ * @retval #CSR_ERROR_OUT_OF_MEMORY         Not enough memory
+ * @retval #CSR_ERROR_INVALID_PARAMETER     file_path or action is invalid
+ * @retval #CSR_ERROR_FILE_NOT_FOUND        No malware file
+ * @retval #CSR_ERROR_SOCKET                Socket error between client and server
+ * @retval #CSR_ERROR_SERVER                Server has been failed for some reason
+ * @retval #CSR_ERROR_UNKNOWN               Error with unknown reason
+ */
+int csr_cs_get_detected_malware(csr_cs_context_h handle, const char *file_path, csr_cs_detected_h *pdetected);
+
+/**
+ * @brief Gets information on a detected malware files specified by directory path.
+ *
+ * @param[in]  handle     CSR CS context handle returned by csr_cs_context_create().
+ * @param[in]  dir        A directory path where detected malware files exists.
+ * @param[out] plist      A pointer of the detected malware list handle. It can be null
+ *                        when no malware file.
+ * @param[out] pcount     Count of detected malware files which existed in the specified
+ *                        directory.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                  Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE        Invalid handle
+ * @retval #CSR_ERROR_OUT_OF_MEMORY         Not enough memory
+ * @retval #CSR_ERROR_INVALID_PARAMETER     file_path or action is invalid
+ * @retval #CSR_ERROR_FILE_NOT_FOUND        No malware file
+ * @retval #CSR_ERROR_SOCKET                Socket error between client and server
+ * @retval #CSR_ERROR_SERVER                Server has been failed for some reason
+ * @retval #CSR_ERROR_UNKNOWN               Error with unknown reason
+ */
+int csr_cs_get_detected_malwares(csr_cs_context_h handle, const char *dir,
+                              csr_cs_detected_list_h *plist, int *pcount);
+
+/**
+ * @brief Gets information on a ignored malware file specified by file path.
+ *
+ * @param[in]  handle     CSR CS context handle returned by csr_cs_context_create().
+ * @param[in]  file_path  A path of a ignored malware file.
+ * @param[out] pdetected  A pointer of the detected malware handle. It can be null when
+ *                        no ignored file.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                  Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE        Invalid handle
+ * @retval #CSR_ERROR_OUT_OF_MEMORY         Not enough memory
+ * @retval #CSR_ERROR_INVALID_PARAMETER     file_path or action is invalid
+ * @retval #CSR_ERROR_FILE_NOT_FOUND        No ignored file
+ * @retval #CSR_ERROR_SOCKET                Socket error between client and server
+ * @retval #CSR_ERROR_SERVER                Server has been failed for some reason
+ * @retval #CSR_ERROR_UNKNOWN               Error with unknown reason
+ */
+int csr_cs_get_ignored_malware(csr_cs_context_h handle, const char *file_path, csr_cs_detected_h *pdetected);
+
+/**
+ * @brief Gets information on a ignored malware files specified by directory path.
+ *
+ * @param[in]  handle     CSR CS context handle returned by csr_cs_context_create().
+ * @param[in]  dir        A directory path where ignored malware files exists.
+ * @param[out] plist      A pointer of the detected malware list handle. It can be null
+ *                        when no ignored file.
+ * @param[out] pcount     Count of ignored malware files which existed in the specified
+ *                        directory.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                  Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE        Invalid handle
+ * @retval #CSR_ERROR_OUT_OF_MEMORY         Not enough memory
+ * @retval #CSR_ERROR_INVALID_PARAMETER     file_path or action is invalid
+ * @retval #CSR_ERROR_FILE_NOT_FOUND        No ingored file
+ * @retval #CSR_ERROR_SOCKET                Socket error between client and server
+ * @retval #CSR_ERROR_SERVER                Server has been failed for some reason
+ * @retval #CSR_ERROR_UNKNOWN               Error with unknown reason
+ */
+int csr_cs_get_ignored_malwares(csr_cs_context_h handle, const char *dir,
+                              csr_cs_detected_list_h *plist, int *pcount);
+
+/**
+ * @brief Extracts the detected malware handle from the detected malware list handle.
+ *
+ * @param[in]  list        A detected malware list handle returned by
+ *                         csr_cs_get_detected_malwares() or
+ *                         csr_cs_get_ignored_malwares().
+ * @param[in]  index       An index of a target detected malware handle to get.
+ * @param[out] pdetected   A pointer of the detected malware handle. It can be null when
+ *                         index is invalid.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                 Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE       Invalid list
+ * @retval #CSR_ERROR_INVALID_PARAMETER    index or pdetected is invalid.
+ * @retval #CSR_ERROR_UNKNOWN              Error with unknown reason
+ */
+int csr_cs_dlist_get_detected(csr_cs_detected_list_h list, int index, csr_cs_detected_h *pdetected);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/include/csr/engine-manager.h b/src/include/csr/engine-manager.h
new file mode 100644 (file)
index 0000000..94d13e0
--- /dev/null
@@ -0,0 +1,165 @@
+/*
+ *  Copyright (c) 2016 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        engine-manager.h
+ * @author      Dongsun Lee (ds73.lee@samsung.com)
+ * @version     1.0
+ * @brief
+ */
+#ifndef __CSR_ENGINE_MANAGER_H_
+#define __CSR_ENGINE_MANAGER_H_
+
+#include "csr/content-screening-types.h"
+#include "csr/web-protection-types.h"
+#include "csr/error.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct __csr_engine_h *csr_engine_h;
+
+
+typedef enum {
+       CSR_ENGINE_CS = 0x01,  /**< Content screening engine id */
+       CSR_ENGINE_WP = 0x02   /**< Web protection engine id */
+} csr_engine_id_e;
+
+/**
+ * @brief State of engine activation
+ */
+typedef enum {
+       CSR_NOT_ACTIVATED = 0x01,  /**< Engine is not activated */
+       CSR_ACTIVATED     = 0x02   /**< Engine is activated */
+} csr_activated_e;
+
+/**
+ * @brief Gets the handle of a selected engine information.
+ *
+ * @param[in]  id       Engine identifier to get handle.
+ * @param[out] pengine  A pointer of the engine information handle.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                 Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE       Invalid handle
+ * @retval #CSR_ERROR_INVALID_PARAMETER    pengine is invalid
+ * @retval #CSR_ERROR_ENGINE_NOT_SELECTED  No engine selected
+ * @retval #CSR_ERROR_ENGINE_NOT_ACTIVATED Engine is not activated
+ * @retval #CSR_ERROR_ENGINE_INTERNAL      Engine Internal error
+ * @retval #CSR_ERROR_UNKNOWN              Error with unknown reason
+ *
+ * @see csr_context_create()
+ */
+int csr_get_selected_engine(csr_engine_id_e id, csr_engine_h *engine);
+
+/**
+ * @brief Extracts an vendor name from the engine information handle.
+ *
+ * @param[in]  engine  The engine information handle.
+ * @param[out] vendor  A pointer of the engine's vendor name. A caller should not free it.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                 Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE       Invalid engine information handle
+ * @retval #CSR_ERROR_INVALID_PARAMETER    engine_vendor is invalid
+ * @retval #CSR_ERROR_ENGINE_INTERNAL      Engine Internal error
+ * @retval #CSR_ERROR_UNKNOWN              Error with unknown reason
+ *
+ * @see csr_get_engine_info()
+ */
+int csr_engine_get_vendor(csr_engine_h engine, char **vendor);
+
+/**
+ * @brief Extracts an engine name from the engine information handle.
+ *
+ * @param[in]  engine  The engine information handle.
+ * @param[out] name    A pointer of the engine's name. A caller should not free it.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                 Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE       Invalid engine information handle
+ * @retval #CSR_ERROR_INVALID_PARAMETER    engine_name is invalid
+ * @retval #CSR_ERROR_ENGINE_INTERNAL      Engine Internal error
+ * @retval #CSR_ERROR_UNKNOWN              Error with unknown reason
+ *
+ * @see csr_get_engine_info()
+ */
+int csr_engine_get_name(csr_engine_h engine, char **name);
+
+/**
+ * @brief Extracts an engine version from the engine information handle.
+ *
+ * @param[in]  engine   An engine information handle.
+ * @param[out] version  A pointer of the engine's version. A caller should not free it.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                 Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE       Invalid engine information handle
+ * @retval #CSR_ERROR_INVALID_PARAMETER    engine_version is invalid
+ * @retval #CSR_ERROR_UNKNOWN              Error with unknown reason
+ * @retval #CSR_ERROR_ENGINE_INTERNAL      Engine Internal error
+ * @retval #CSR_ERROR_UNKNOWN              Error with unknown reason
+ *
+ * @see csr_get_engine_info()
+ */
+int csr_engine_get_version(csr_engine_h engine, char **version);
+
+/**
+ * @brief Extracts an engine's data version from the engine information handle.
+ *
+ * @param[in]  engine   The engine information handle.
+ * @param[out] version  A pointer of the data version. It can be null. A caller should not free it.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                 Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE       Invalid engine information handle
+ * @retval #CSR_ERROR_INVALID_PARAMETER    engine_version is invalid
+ * @retval #CSR_ERROR_UNKNOWN              Error with unknown reason
+ * @retval #CSR_ERROR_ENGINE_INTERNAL      Engine Internal error
+ * @retval #CSR_ERROR_UNKNOWN              Error with unknown reason
+ *
+ * @see csr_get_engine_info()
+ */
+int csr_engine_get_data_version(csr_engine_h engine, char **version);
+
+/**
+ * @brief Extracts the state of engine activation from the engine information handle.
+ *
+ * @param[in]  engine      The engine information handle.
+ * @param[out] pactivated  A pointer of the engine state.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                 Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE       Invalid engine information handle
+ * @retval #CSR_ERROR_INVALID_PARAMETER    pactivated is invalid
+ * @retval #CSR_ERROR_ENGINE_INTERNAL      Engine Internal error
+ * @retval #CSR_ERROR_UNKNOWN              Error with unknown reason
+ *
+ * @see csr_get_engine_info()
+ */
+int csr_engine_get_activated(csr_engine_h engine, csr_activated_e *pactivated);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
index 68e4d6e..8665ee0 100644 (file)
  */
 /*
  * @file        error.h
- * @author      Kyungwook Tak (k.tak@samsung.com)
+ * @author      Dongsun Lee (ds73.lee@samsung.com)
  * @version     1.0
- * @brief       csr error codes
+ * @brief
  */
-#ifndef __TIZEN_CORE_CSR_ERROR_H_
-#define __TIZEN_CORE_CSR_ERROR_H_
+#ifndef __CSR_ERROR_H_
+#define __CSR_ERROR_H_
 
 #include <tizen.h>
 
 extern "C" {
 #endif
 
+/* define it temporary until this code goes into capi-base-common package */
+#ifndef TIZEN_ERROR_CSR
 #define TIZEN_ERROR_CSR 0x60 // 0110 0000
+#endif
+
 
+/**
+ * @brief Enumeration for CSR Errors.
+ */
 typedef enum {
-       CSR_ERROR_NONE              = TIZEN_ERROR_NONE,              /**< Success */
-       CSR_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid function parameter */
-       CSR_ERROR_OUT_OF_MEMORY     = TIZEN_ERROR_OUT_OF_MEMORY,     /**< Out of memory */
-       CSR_ERROR_PERMISSION_DEINED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
-       CSR_ERROR_SOCKET            = TIZEN_ERROR_CSR | 0x01,        /**< Socket error between client and csr-server */
-       CSR_ERROR_BAD_REQUEST       = TIZEN_ERROR_CSR | 0x02,        /**< Invalid request from client */
-       CSR_ERROR_BAD_RESPONSE      = TIZEN_ERROR_CSR | 0x03,        /**< Invalid response from csr-server */
-       CSR_ERROR_SEND_FAILED       = TIZEN_ERROR_CSR | 0x04,        /**< Transmitting request failed */
-       CSR_ERROR_RECV_FAILED       = TIZEN_ERROR_CSR | 0x05,        /**< Receiving response failed */
-       CSR_ERROR_SERVER            = TIZEN_ERROR_CSR | 0x06,        /**< csr-server has been failed for some reason */
-       CSR_ERROR_UNKNOWN           = TIZEN_ERROR_CSR | 0xFF         /**< Unknown reason */
+       CSR_ERROR_NONE                  = TIZEN_ERROR_NONE,              /**< Successful */
+       CSR_ERROR_INVALID_PARAMETER     = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid function parameter */
+       CSR_ERROR_OUT_OF_MEMORY         = TIZEN_ERROR_OUT_OF_MEMORY,     /**< Out of memory */
+       CSR_ERROR_PERMISSION_DENIED     = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
+       CSR_ERROR_SOCKET                = TIZEN_ERROR_CSR | 0x01,        /**< Socket error between client and server */
+       CSR_ERROR_INVALID_HANDLE        = TIZEN_ERROR_CSR | 0x02,        /**< The given handle is invalid */
+       CSR_ERROR_SERVER                = TIZEN_ERROR_CSR | 0x03,        /**< Server has been failed for some reason */
+       CSR_ERROR_NO_TASK               = TIZEN_ERROR_CSR | 0x04,        /**< No Task exists*/
+       CSR_ERROR_ENGINE_PERMISSION     = TIZEN_ERROR_CSR | 0x11,        /**< Insufficient permission of engine */
+       CSR_ERROR_ENGINE_NOT_SELECTED   = TIZEN_ERROR_CSR | 0x12,        /**< No engine is selected*/
+       CSR_ERROR_ENGINE_NOT_ACTIVATED  = TIZEN_ERROR_CSR | 0x13,        /**< Engine is not activated*/
+       CSR_ERROR_ENGINE_INTERNAL       = TIZEN_ERROR_CSR | 0x19,        /**< Engine Internal error*/
+       CSR_ERROR_UNKNOWN               = TIZEN_ERROR_CSR | 0xFF,        /**< The error with unknown reason */
 } csr_error_e;
 
+/**
+ * @brief get the error string for a given error code.
+ *
+ * @param[in]  error_code  An error code.
+ * @param[out] string      A pointer of the error string. A caller should not free it.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                 Successful
+ * @retval #CSR_ERROR_INVALID_PARAMETER    error_code or error_string is invalid
+ * @retval #CSR_ERROR_UNKNOWN              Error with unknown reason
+ */
+int csr_get_error_string(int error_code, char** string);
+
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/include/csr/web-protection-types.h b/src/include/csr/web-protection-types.h
new file mode 100644 (file)
index 0000000..2e0f322
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ *  Copyright (c) 2016 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        web-protection-types.h
+ * @author      Dongsun Lee (ds73.lee@samsung.com)
+ * @version     1.0
+ * @brief
+ */
+#ifndef __CSR_WEB_PROTECTION_TYPES_H_
+#define __CSR_WEB_PROTECTION_TYPES_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief Maximum message size.
+ */
+#define MAX_MESSAGE_SIZE 64
+
+/**
+ * CSR WP context handle.
+ */
+typedef struct __csr_wp_context_s* csr_wp_context_h;
+
+/**
+ * CSR WP scan result handle.
+ */
+typedef struct __csr_wp_check_result_h* csr_wp_check_result_h;
+
+/**
+ * @brief the options about prompting a popup to a user.
+ */
+typedef enum {
+       CSR_WP_NOT_ASK_USER = 0x00, /**< Do not ask the user even if a URL turns out risky.*/
+       CSR_WP_ASK_USER     = 0x01  /**< Ask the user when a URL turns out risky */
+} csr_wp_ask_user_e;
+
+/**
+ * @brief the user response for a popup.
+ */
+typedef enum {
+       CSR_WP_NO_ASK_USER           = 0x00, /**< There was no popup for asking the user. */
+       CSR_WP_PROCESSING_ALLOWED    = 0x01, /**< A user allowed to process the url. */
+       CSR_WP_PROCESSING_DISALLOWED = 0x02  /**< A user disallowed to process the url. */
+} csr_wp_user_response_e;
+
+/**
+ * @brief Risk level of a url
+ */
+typedef enum {
+       CSR_WP_RISK_LOW        = 0x01,  /**< Risk Low. */
+       CSR_WP_RISK_UNVERIFIED = 0x02,  /**< Risk Unverified. There is no information about the url.*/
+       CSR_WP_RISK_MEDIUM     = 0x03,  /**< Risk Medium. Prompt the user before processing. Ask the user if they want the application to process the url. */
+       CSR_WP_RISK_HIGH       = 0x04   /**< High Risk.Do not process the url and just notify the user */
+} csr_wp_risk_level_e;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/include/csr/web-protection.h b/src/include/csr/web-protection.h
new file mode 100644 (file)
index 0000000..f4ec2ac
--- /dev/null
@@ -0,0 +1,198 @@
+/*
+ *  Copyright (c) 2016 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        web-protection.h
+ * @author      Dongsun Lee (ds73.lee@samsung.com)
+ * @version     1.0
+ * @brief
+ */
+#ifndef __CSR_WEB_PROTECTION_API_H_
+#define __CSR_WEB_PROTECTION_API_H_
+
+#include "csr/web-protection-types.h"
+#include "csr/error.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//==============================================================================
+// Main function related
+//==============================================================================
+/**
+ * @brief Initializes and returns a CSR Web Protection API handle.
+ *
+ * @details A Web Protection API handle (or CSR WP handle) is obtained using the
+ *          csr_wp_context_create(). The handle is required for subsequent CSR WP API
+ *          calls. The csr_wp_context_destroy() releases/closes the handle. Multiple
+ *          handles can be obtained using csr_wp_context_create().
+ *
+ * @param[out] phandle A pointer of CSR WP context handle.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                  Successful
+ * @retval #CSR_ERROR_OUT_OF_MEMORY         Not enough memory
+ * @retval #CSR_ERROR_INVALID_PARAMETER     phandle is invalid
+ * @retval #CSR_ERROR_PERMISSION_DENIED     Permission denied
+ * @retval #CSR_ERROR_SOCKET                Socket error between client and server
+ * @retval #CSR_ERROR_SERVER                Server has been failed for some reason
+ * @retval #CSR_ERROR_ENGINE_INTERNAL       Engine Internal error
+ * @retval #CSR_ERROR_UNKNOWN               Error with unknown reason
+ *
+ * @see csr_wp_context_destroy()
+ */
+int csr_wp_context_create(csr_wp_context_h* phandle);
+
+/**
+ * @brief Releases all system resources associated with a CSR Web Protection API handle.
+ *
+ * @details The handle is one returned by the csr_wp_context_create().
+ *
+ * @param[in] handle CSR WP context handle returned by csr_wp_context_create().
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                  Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE        Invalid handle
+ * @retval #CSR_ERROR_SOCKET                Socket error between client and server
+ * @retval #CSR_ERROR_SERVER                Server has been failed for some reason
+ * @retval #CSR_ERROR_ENGINE_INTERNAL       Engine Internal error
+ * @retval #CSR_ERROR_UNKNOWN               Error with unknown reason
+ *
+ * @see csr_wp_context_create()
+ */
+int csr_wp_context_destroy(csr_wp_context_h handle);
+
+/**
+ * @brief Sets a popup option in case for a risky URL.
+ *
+ * @details If #CSR_WP_ASK_USER is set, a popup will be prompted to a user when a URL
+ *          turns out risky(#CSR_WP_RISK_MEDIUM or #CSR_WP_RISK_HIGH). If
+ *          #CSR_WP_NOT_ASK_USER is set, no popup will be prompted even when a URL turns
+ *          out risky. The default value of this option is #CSR_WP_ASK_USER.
+ *
+ * @param[in] handle    TWS context handle returned by csr_wp_context_create().
+ * @param[in] ask_user  A popup option in case for a risky URL.
+ *
+ * @return #TWS_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #TWS_ERROR_NONE                  Successful
+ * @retval #TWS_ERROR_INVALID_HANDLE        Invalid handle
+ * @retval #TWS_ERROR_INVALID_PARAMETER     ask_user is invalid
+ * @retval #TWS_ERROR_UNKNOWN               Error with unknown reason
+ *
+ * @see csr_wp_context_create()
+ */
+int csr_wp_set_ask_user(csr_wp_context_h handle, csr_wp_ask_user_e ask_user);
+
+/**
+ * @brief Sets a popup message of a client in case for a risky URL.
+ *
+ * @details When a popup is prompted to a user, the message set by this method will be
+ *          shown. When a client doesn't set his own popup message, the default message
+ *          will be shown in the popup.
+ *
+ * @param[in] handle   CSR WP context handle returned by csr_wp_context_create().
+ * @param[in] message  A message in a popup.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                  Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE        Invalid handle
+ * @retval #CSR_ERROR_INVALID_PARAMETER     message is invalid. Max size is 64 bytes.
+ * @retval #CSR_ERROR_UNKNOWN               Error with unknown reason
+ *
+ * @see csr_wp_context_create()
+ */
+int csr_wp_set_popup_message(csr_wp_context_h handle, const char* message);
+
+/**
+ * @brief Main function for caller to check URL reputation against the engine vendor's
+ *        database.
+ *
+ * @details Checks whether accessing the URL is risky or not and returns a result handle
+ *          with the Risk level for the URL. The system resources associated with the
+ *          result handle will be released when csr_wp_context_destroy() is called.
+ *
+ * @param[in]  handle   CSR WP context handle returned by csr_wp_context_create().
+ * @param[in]  url      URL to check.
+ * @param[out] presult  A pointer of the result handle with the Risk level for the URL.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                  Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE        Invalid handle
+ * @retval #CSR_ERROR_OUT_OF_MEMORY         Not enough memory
+ * @retval #CSR_ERROR_PERMISSION_DENIED     Permission denied
+ * @retval #CSR_ERROR_INVALID_PARAMETER     URL or presult is invalid
+ * @retval #CSR_ERROR_SOCKET                Socket error between client and server
+ * @retval #CSR_ERROR_SERVER                Server has been failed for some reason
+ * @retval #CSR_ERROR_ENGINE_NOT_SELECTED   No engine selected
+ * @retval #CSR_ERROR_ENGINE_NOT_ACTIVATED  Engine is not activated
+ * @retval #CSR_ERROR_ENGINE_INTERNAL       Engine Internal error
+ * @retval #CSR_ERROR_UNKNOWN               Error with unknown reason
+ *
+ * @see csr_wp_context_create()
+ * @see csr_wp_set_ask_user()
+ * @see csr_wp_set_popup_message()
+ */
+int csr_wp_check_url(csr_wp_context_h handle, const char *url, csr_wp_check_result_h *presult);
+
+//==============================================================================
+// Result related
+//==============================================================================
+/**
+ * @brief Extracts a risk level of the url from the result handle.
+ *
+ * @param[in]  result  A result handle returned by csr_wp_check_url().
+ * @param[out] plevel  A pointer of the risk level for the given URL.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                 Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE       Invalid result handle
+ * @retval #CSR_ERROR_INVALID_PARAMETER    plevel is invalid
+ * @retval #CSR_ERROR_UNKNOWN              Error with unknown reason
+ *
+ * @see csr_wp_check_url()
+ */
+int csr_wp_result_get_risk_level(csr_wp_check_result_h result, csr_wp_risk_level_e* plevel);
+
+/**
+ * @brief Extracts a user reponse of a popup from the result handle.
+ *
+ * @param[in]  result     A result handle returned by csr_wp_check_url().
+ * @param[out] presponse  A pointer of the user response.
+ *
+ * @return #TWS_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #TWS_ERROR_NONE                 Successful
+ * @retval #TWS_ERROR_INVALID_HANDLE       Invalid result handle
+ * @retval #TWS_ERROR_INVALID_PARAMETER    presponse is invalid
+ * @retval #TWS_ERROR_UNKNOWN              Error with unknown reason
+ *
+ * @see csr_wp_check_url()
+ * @see #csr_wp_user_response_e
+ */
+int csr_wp_result_get_user_response(csr_wp_check_result_h result, csr_wp_user_response_e* presponse);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
index 743fb5c..00f4a82 100644 (file)
@@ -24,9 +24,11 @@ PKG_CHECK_MODULES(${TARGET_CSR_TEST}_DEP
 )
 
 SET(${TARGET_CSR_TEST}_SRCS
-       test-main.cpp
-       test-api.cpp
        colour_log_formatter.cpp
+       test-api-content-screening.cpp
+       test-api-engine-manager.cpp
+       test-api-web-protection.cpp
+       test-main.cpp
 )
 
 INCLUDE_DIRECTORIES(
diff --git a/test/test-api-content-screening.cpp b/test/test-api-content-screening.cpp
new file mode 100644 (file)
index 0000000..5c81ac5
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ *  Copyright (c) 2016 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        test-api-content-screening.cpp
+ * @author      Kyungwook Tak (k.tak@samsung.com)
+ * @version     1.0
+ * @brief       CSR Content screening API test
+ */
+#define BOOST_TEST_MODULE CSR_API_TEST
+#include <csr/content-screening.h>
+
+#include <string>
+#include <iostream>
+#include <boost/test/unit_test.hpp>
+
+BOOST_AUTO_TEST_SUITE(API_CONTENT_SCREENING)
+
+BOOST_AUTO_TEST_CASE(context_create_destroy)
+{
+       csr_cs_context_h handle;
+       int ret = CSR_ERROR_UNKNOWN;
+
+       BOOST_REQUIRE_NO_THROW(ret = csr_cs_context_create(&handle));
+       BOOST_REQUIRE(ret == CSR_ERROR_NONE);
+
+       BOOST_REQUIRE_NO_THROW(ret = csr_cs_context_destroy(handle));
+       BOOST_REQUIRE(ret == CSR_ERROR_NONE);
+}
+
+BOOST_AUTO_TEST_CASE(scan_file)
+{
+       csr_cs_context_h handle;
+       int ret = CSR_ERROR_UNKNOWN;
+
+       BOOST_REQUIRE_NO_THROW(ret = csr_cs_context_create(&handle));
+       BOOST_REQUIRE(ret == CSR_ERROR_NONE);
+
+       csr_cs_detected_h detected;
+       BOOST_REQUIRE_NO_THROW(ret = csr_cs_scan_file(handle, "dummy_file_path", &detected));
+       BOOST_REQUIRE(ret == CSR_ERROR_NONE);
+
+       BOOST_REQUIRE_NO_THROW(ret = csr_cs_context_destroy(handle));
+       BOOST_REQUIRE(ret == CSR_ERROR_NONE);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
similarity index 62%
rename from test/test-api.cpp
rename to test/test-api-engine-manager.cpp
index 0c060d1..2765339 100644 (file)
  *  limitations under the License
  */
 /*
- * @file        test-api.cpp
+ * @file        test-api-engine-manager.cpp
  * @author      Kyungwook Tak (k.tak@samsung.com)
  * @version     1.0
- * @brief
+ * @brief       CSR Engine manager API test
  */
-#define BOOST_TEST_MODULE CSR_API_TEST
-#include <csr/api.h>
+#include <csr/engine-manager.h>
 
 #include <string>
-#include <iostream>
 #include <boost/test/unit_test.hpp>
 
-BOOST_AUTO_TEST_SUITE(API_TEST)
+BOOST_AUTO_TEST_SUITE(API_ENGINE_MANAGER)
 
-BOOST_AUTO_TEST_CASE(FILE_SCAN)
+BOOST_AUTO_TEST_CASE(get_selected_engine)
 {
-       std::string filepath = "this is not real file path";
        int ret = CSR_ERROR_UNKNOWN;
 
-       BOOST_REQUIRE_NO_THROW(ret = csr_file_scan(filepath.c_str()));
+       csr_engine_h handle;
+       BOOST_REQUIRE_NO_THROW(ret = csr_get_selected_engine(CSR_ENGINE_CS, &handle));
        BOOST_REQUIRE(ret == CSR_ERROR_NONE);
 }
 
-BOOST_AUTO_TEST_CASE(FILE_JUDGE)
+BOOST_AUTO_TEST_CASE(get_name)
 {
-       std::string filepath = "this is not real file path";
        int ret = CSR_ERROR_UNKNOWN;
-       int judge = 1;
 
-       BOOST_REQUIRE_NO_THROW(ret = csr_file_judge(filepath.c_str(), judge));
+       csr_engine_h handle;
+       BOOST_REQUIRE_NO_THROW(ret = csr_get_selected_engine(CSR_ENGINE_CS, &handle));
+       BOOST_REQUIRE(ret == CSR_ERROR_NONE);
+
+       char *name = nullptr;
+       BOOST_REQUIRE_NO_THROW(ret = csr_engine_get_name(handle, &name));
        BOOST_REQUIRE(ret == CSR_ERROR_NONE);
 }
 
diff --git a/test/test-api-web-protection.cpp b/test/test-api-web-protection.cpp
new file mode 100644 (file)
index 0000000..073aa71
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ *  Copyright (c) 2016 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        test-api-web-protection.cpp
+ * @author      Kyungwook Tak (k.tak@samsung.com)
+ * @version     1.0
+ * @brief       CSR Web protection API test
+ */
+#include <csr/web-protection.h>
+
+#include <string>
+#include <iostream>
+#include <boost/test/unit_test.hpp>
+
+BOOST_AUTO_TEST_SUITE(API_WEB_PROTECTION)
+
+BOOST_AUTO_TEST_CASE(context_create_destroy)
+{
+       csr_wp_context_h handle;
+       int ret = CSR_ERROR_UNKNOWN;
+
+       BOOST_REQUIRE_NO_THROW(ret = csr_wp_context_create(&handle));
+       BOOST_REQUIRE(ret == CSR_ERROR_NONE);
+
+       BOOST_REQUIRE_NO_THROW(ret = csr_wp_context_destroy(handle));
+       BOOST_REQUIRE(ret == CSR_ERROR_NONE);
+}
+
+BOOST_AUTO_TEST_CASE(check_url)
+{
+       csr_wp_context_h handle;
+       int ret = CSR_ERROR_UNKNOWN;
+
+       BOOST_REQUIRE_NO_THROW(ret = csr_wp_context_create(&handle));
+       BOOST_REQUIRE(ret == CSR_ERROR_NONE);
+
+       csr_wp_check_result_h result;
+       BOOST_REQUIRE_NO_THROW(ret = csr_wp_check_url(handle, "dummy/url/test", &result));
+       BOOST_REQUIRE(ret == CSR_ERROR_NONE);
+
+       BOOST_REQUIRE_NO_THROW(ret = csr_wp_context_destroy(handle));
+       BOOST_REQUIRE(ret == CSR_ERROR_NONE);
+}
+
+BOOST_AUTO_TEST_SUITE_END()