summaryrefslogtreecommitdiffstats
path: root/demo#3/common/agl-service-homescreen/src
diff options
context:
space:
mode:
Diffstat (limited to 'demo#3/common/agl-service-homescreen/src')
-rw-r--r--demo#3/common/agl-service-homescreen/src/CMakeLists.txt69
-rw-r--r--demo#3/common/agl-service-homescreen/src/export.map1
-rw-r--r--demo#3/common/agl-service-homescreen/src/hmi-debug.h77
-rw-r--r--demo#3/common/agl-service-homescreen/src/homescreen.cpp449
-rw-r--r--demo#3/common/agl-service-homescreen/src/hs-client.cpp255
-rw-r--r--demo#3/common/agl-service-homescreen/src/hs-client.h52
-rw-r--r--demo#3/common/agl-service-homescreen/src/hs-clientmanager.cpp219
-rw-r--r--demo#3/common/agl-service-homescreen/src/hs-clientmanager.h66
-rw-r--r--demo#3/common/agl-service-homescreen/src/hs-helper.cpp246
-rw-r--r--demo#3/common/agl-service-homescreen/src/hs-helper.h48
10 files changed, 1482 insertions, 0 deletions
diff --git a/demo#3/common/agl-service-homescreen/src/CMakeLists.txt b/demo#3/common/agl-service-homescreen/src/CMakeLists.txt
new file mode 100644
index 0000000..bf8b33f
--- /dev/null
+++ b/demo#3/common/agl-service-homescreen/src/CMakeLists.txt
@@ -0,0 +1,69 @@
+#
+# Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+#
+# 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.
+#
+
+cmake_minimum_required(VERSION 2.8)
+
+set(TARGETS_HSBINDER homescreen-service)
+
+INCLUDE(FindThreads)
+FIND_PACKAGE(Threads)
+
+pkg_check_modules(hs_binding_depends afb-daemon glib-2.0 gio-2.0 gio-unix-2.0 json-c)
+set(binding_hs_sources
+ homescreen.cpp
+ hs-helper.cpp
+ hs-clientmanager.cpp
+ hs-client.cpp)
+
+link_libraries(-Wl,--as-needed -Wl,--gc-sections -Wl,--no-undefined)
+include_directories(${PROJECT_SOURCE_DIR}/include)
+add_library(${TARGETS_HSBINDER} MODULE ${binding_hs_sources})
+
+target_compile_options(${TARGETS_HSBINDER} PRIVATE ${hs_binding_depends_CFLAGS})
+if(DEFINED DEBUGMODE)
+ target_compile_options(${TARGETS_HSBINDER} PRIVATE -g -O0)
+else(DEFINED DEBUGMODE)
+ target_compile_options(${TARGETS_HSBINDER} PRIVATE -g -O2)
+endif(DEFINED DEBUGMODE)
+
+target_include_directories(${TARGETS_HSBINDER} PRIVATE ${hs_binding_depends_INCLUDE_DIRS})
+target_link_libraries(${TARGETS_HSBINDER} ${CMAKE_THREAD_LIBS_INIT} ${link_libraries} ${hs_binding_depends_LIBRARIES})
+
+# Binder exposes a unique public entry point
+
+set_target_properties(${TARGETS_HSBINDER} PROPERTIES
+ PREFIX ""
+ LINK_FLAGS "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/export.map"
+ )
+
+# installation directory
+#INSTALL(TARGETS ${TARGETS_HSBINDER}
+# LIBRARY DESTINATION ${binding_install_dir})
+
+if(NOT EXISTS ${PROJECT_BINARY_DIR}/package)
+ add_custom_command(TARGET ${TARGETS_HSBINDER} POST_BUILD
+ COMMAND cp -rf ${PROJECT_SOURCE_DIR}/package ${PROJECT_BINARY_DIR}
+ )
+endif()
+
+add_custom_command(TARGET ${TARGETS_HSBINDER} POST_BUILD
+ COMMAND mkdir -p ${PROJECT_BINARY_DIR}/package/root/lib
+ COMMAND cp -rf ${PROJECT_BINARY_DIR}/src/${TARGETS_HSBINDER}.so ${PROJECT_BINARY_DIR}/package/root/lib
+)
+
+add_custom_target(package DEPENDS ${PROJECT_BINARY_DIR}/package/root
+ COMMAND wgtpkg-pack -f -o ${PROJECT_BINARY_DIR}/package/${TARGETS_HSBINDER}-2017.wgt ${PROJECT_BINARY_DIR}/package/root
+)
diff --git a/demo#3/common/agl-service-homescreen/src/export.map b/demo#3/common/agl-service-homescreen/src/export.map
new file mode 100644
index 0000000..f3961c0
--- /dev/null
+++ b/demo#3/common/agl-service-homescreen/src/export.map
@@ -0,0 +1 @@
+{ global: afbBindingV*; local: *; }; \ No newline at end of file
diff --git a/demo#3/common/agl-service-homescreen/src/hmi-debug.h b/demo#3/common/agl-service-homescreen/src/hmi-debug.h
new file mode 100644
index 0000000..3c71ff5
--- /dev/null
+++ b/demo#3/common/agl-service-homescreen/src/hmi-debug.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+ *
+ * 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.
+ */
+
+#ifndef __HMI_DEBUG_H__
+#define __HMI_DEBUG_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <time.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#include <stdlib.h>
+
+enum LOG_LEVEL{
+ LOG_LEVEL_NONE = 0,
+ LOG_LEVEL_ERROR,
+ LOG_LEVEL_WARNING,
+ LOG_LEVEL_NOTICE,
+ LOG_LEVEL_INFO,
+ LOG_LEVEL_DEBUG,
+ LOG_LEVEL_MAX = LOG_LEVEL_DEBUG
+};
+
+#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
+
+#define HMI_ERROR(prefix, args,...) _HMI_LOG(LOG_LEVEL_ERROR, __FILENAME__, __FUNCTION__, __LINE__, prefix, args, ##__VA_ARGS__)
+#define HMI_WARNING(prefix, args,...) _HMI_LOG(LOG_LEVEL_WARNING, __FILENAME__, __FUNCTION__,__LINE__, prefix, args,##__VA_ARGS__)
+#define HMI_NOTICE(prefix, args,...) _HMI_LOG(LOG_LEVEL_NOTICE, __FILENAME__, __FUNCTION__,__LINE__, prefix, args,##__VA_ARGS__)
+#define HMI_INFO(prefix, args,...) _HMI_LOG(LOG_LEVEL_INFO, __FILENAME__, __FUNCTION__,__LINE__, prefix, args,##__VA_ARGS__)
+#define HMI_DEBUG(prefix, args,...) _HMI_LOG(LOG_LEVEL_DEBUG, __FILENAME__, __FUNCTION__,__LINE__, prefix, args,##__VA_ARGS__)
+
+static char ERROR_FLAG[6][20] = {"NONE", "ERROR", "WARNING", "NOTICE", "INFO", "DEBUG"};
+
+static void _HMI_LOG(enum LOG_LEVEL level, const char* file, const char* func, const int line, const char* prefix, const char* log, ...)
+{
+ const int log_level = (getenv("USE_HMI_DEBUG") == NULL)?LOG_LEVEL_ERROR:atoi(getenv("USE_HMI_DEBUG"));
+ if(log_level < level)
+ {
+ return;
+ }
+
+ char *message;
+ struct timespec tp;
+ unsigned int time;
+
+ clock_gettime(CLOCK_REALTIME, &tp);
+ time = (tp.tv_sec * 1000000L) + (tp.tv_nsec / 1000);
+
+ va_list args;
+ va_start(args, log);
+ if (log == NULL || vasprintf(&message, log, args) < 0)
+ message = NULL;
+ fprintf(stderr, "[%10.3f] [%s %s] [%s, %s(), Line:%d] >>> %s \n", time / 1000.0, prefix, ERROR_FLAG[level], file, func, line, message);
+ va_end(args);
+ free(message);
+}
+
+#ifdef __cplusplus
+}
+#endif
+#endif //__HMI_DEBUG_H__ \ No newline at end of file
diff --git a/demo#3/common/agl-service-homescreen/src/homescreen.cpp b/demo#3/common/agl-service-homescreen/src/homescreen.cpp
new file mode 100644
index 0000000..db739ee
--- /dev/null
+++ b/demo#3/common/agl-service-homescreen/src/homescreen.cpp
@@ -0,0 +1,449 @@
+/*
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+ *
+ * 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.
+ */
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+#include <memory>
+#include <algorithm>
+#include "hs-helper.h"
+#include "hmi-debug.h"
+#include "hs-clientmanager.h"
+
+#define EVENT_SUBSCRIBE_ERROR_CODE 100
+
+const char _error[] = "error";
+const char _application_name[] = "application_name";
+const char _display_message[] = "display_message";
+const char _reply_message[] = "reply_message";
+const char _args[] = "args";
+const char _parameter[] = "parameter";
+
+static HS_ClientManager* g_client_manager = HS_ClientManager::instance();
+
+static std::unordered_map<std::string, HS_Client*> g_client_map;
+
+/*
+********** Method of HomeScreen Service (API) **********
+*/
+
+static void pingSample(struct afb_req request)
+{
+ static int pingcount = 0;
+ afb_req_success_f(request, json_object_new_int(pingcount), "Ping count = %d", pingcount);
+ HMI_NOTICE("homescreen-service","Verbosity macro at level notice invoked at ping invocation count = %d", pingcount);
+ pingcount++;
+}
+
+/**
+ * tap_shortcut notify for homescreen
+ * When Shortcut area is tapped, notify these applciations
+ *
+ * #### Parameters
+ * Request key
+ * - application_name : application name
+ *
+ * #### Return
+ * None
+ *
+ */
+static void tap_shortcut (struct afb_req request)
+{
+ HMI_NOTICE("homescreen-service","called.");
+
+ int ret = 0;
+ const char* value = afb_req_value(request, _application_name);
+ if (value) {
+ HMI_NOTICE("homescreen-service","request params = %s.", value);
+ // first step get appid from appname, next step change appname to appid
+ std::string appid(value);
+ std::transform(appid.begin(), appid.end(), appid.begin(), ::tolower);
+ HS_Client* client = g_client_manager->find(appid);
+ if(client != nullptr) {
+ if(client->tap_shortcut(value) != 0) {
+ afb_req_fail_f(request, "afb_event_push failed", "called %s.", __FUNCTION__);
+ return;
+ }
+ }
+ else {
+ // app is not started, do nothing
+ }
+ } else {
+ afb_req_fail_f(request, "failed", "called %s, Unknown palameter", __FUNCTION__);
+ return;
+ }
+
+ // response to HomeScreen
+ struct json_object *res = json_object_new_object();
+ hs_add_object_to_json_object_func(res, __FUNCTION__, 2,
+ _error, ret);
+ afb_req_success(request, res, "afb_event_push event [tap_shortcut]");
+}
+
+/**
+ * showWindow event
+ *
+ * #### Parameters
+ * - id : app's id
+ * - parameter : parameter from app to new window
+ *
+ * #### Return
+ * None
+ *
+ */
+static void showWindow(struct afb_req request)
+{
+ HMI_NOTICE("homescreen-service","called.");
+
+ int ret = 0;
+ const char* value = afb_req_value(request, _application_name);
+ if (value) {
+ HMI_NOTICE("homescreen-service","request params = %s.", value);
+ // first step get appid from appname, next step change appname to appid
+ std::string appid(value);
+ std::transform(appid.begin(), appid.end(), appid.begin(), ::tolower);
+ HS_Client* client = g_client_manager->find(appid);
+ if(client != nullptr) {
+ if(client->showWindow(request, value) != 0) {
+ afb_req_fail_f(request, "afb_event_push failed", "called %s.", __FUNCTION__);
+ return;
+ }
+ }
+ else {
+ // app is not started, do nothing
+ }
+ } else {
+ afb_req_fail_f(request, "failed", "called %s, Unknown palameter", __FUNCTION__);
+ return;
+ }
+
+ // response to HomeScreen
+ struct json_object *res = json_object_new_object();
+ hs_add_object_to_json_object_func(res, __FUNCTION__, 2,
+ _error, ret);
+ afb_req_success(request, res, "afb_event_push event [showWindow]");
+}
+
+/**
+ * HomeScreen OnScreen message
+ *
+ * #### Parameters
+ * Request key
+ * - display_message : message for display
+ *
+ * #### Return
+ * None
+ *
+ */
+static void on_screen_message (struct afb_req request)
+{
+ HMI_NOTICE("homescreen-service","called.");
+
+ int ret = 0;
+ const char* value = afb_req_value(request, _display_message);
+ if (value) {
+
+ HMI_NOTICE("homescreen-service","request params = %s.", value);
+ for(auto m : g_client_manager->getAllClient()) {
+ if(m->on_screen_message(request, value) != 0) {
+ afb_req_fail_f(request, "afb_event_push failed", "called %s.", __FUNCTION__);
+ return;
+ }
+ }
+ } else {
+ afb_req_fail_f(request, "failed", "called %s, Unknown palameter", __FUNCTION__);
+ return;
+ }
+
+ // response to HomeScreen
+ struct json_object *res = json_object_new_object();
+ hs_add_object_to_json_object_func(res, __FUNCTION__, 2,
+ _error, ret);
+ afb_req_success(request, res, "afb_event_push event [on_screen_message]");
+}
+
+/**
+ * HomeScreen OnScreen Reply
+ *
+ * #### Parameters
+ * Request key
+ * - reply_message : message for reply
+ *
+ * #### Return
+ * None
+ *
+ */
+static void on_screen_reply (struct afb_req request)
+{
+ HMI_NOTICE("homescreen-service","called.");
+
+ int ret = 0;
+ const char* value = afb_req_value(request, _reply_message);
+ if (value) {
+
+ HMI_NOTICE("homescreen-service","request params = %s.", value);
+ for(auto m : g_client_manager->getAllClient()) {
+ if(m->on_screen_reply(request, value) != 0) {
+ afb_req_fail_f(request, "afb_event_push failed", "called %s.", __FUNCTION__);
+ return;
+ }
+ }
+ } else {
+ afb_req_fail_f(request, "failed", "called %s, Unknown palameter", __FUNCTION__);
+ return;
+ }
+
+ // response to HomeScreen
+ struct json_object *res = json_object_new_object();
+ hs_add_object_to_json_object_func(res, __FUNCTION__, 2,
+ _error, ret);
+ afb_req_success(request, res, "afb_event_push event [on_screen_reply]");
+}
+
+/**
+ * Subscribe event
+ *
+ * #### Parameters
+ * - event : Event name. Event list is written in libhomescreen.cpp
+ *
+ * #### Return
+ * None
+ *
+ */
+static void subscribe(struct afb_req request)
+{
+ const char *value = afb_req_value(request, "event");
+ HMI_NOTICE("homescreen-service","value is %s", value);
+ int ret = 0;
+ if(value) {
+ std::string appid(afb_req_get_application_id(request));
+ std::transform(appid.begin(), appid.end(), appid.begin(), ::tolower);
+ if(g_client_manager->getClient(request, appid)->subscribe(request, value) != 0) {
+ afb_req_fail_f(request, "afb_req_subscribe failed", "called %s.", __FUNCTION__);
+ return;
+ }
+ }
+ else {
+ HMI_NOTICE("homescreen-service","Please input event name");
+ ret = EVENT_SUBSCRIBE_ERROR_CODE;
+ }
+ /*create response json object*/
+ struct json_object *res = json_object_new_object();
+ hs_add_object_to_json_object_func(res, __FUNCTION__, 2,
+ _error, ret);
+ afb_req_success_f(request, res, "homescreen binder subscribe event name [%s]", value);
+}
+
+/**
+ * Unsubscribe event
+ *
+ * #### Parameters
+ * - event : Event name. Event list is written in libhomescreen.cpp
+ *
+ * #### Return
+ * None
+ *
+ */
+static void unsubscribe(struct afb_req request)
+{
+ const char *value = afb_req_value(request, "event");
+ HMI_NOTICE("homescreen-service","value is %s", value);
+ int ret = 0;
+ if(value) {
+ std::string appid(afb_req_get_application_id(request));
+ std::transform(appid.begin(), appid.end(), appid.begin(), ::tolower);
+ HS_Client* client = g_client_manager->find(appid);
+ if(client != nullptr) {
+ if(client->unsubscribe(request, value) != 0) {
+ afb_req_fail_f(request, "afb_req_unsubscribe failed", "called %s.", __FUNCTION__);
+ return;
+ }
+ }
+ else {
+ HMI_NOTICE("homescreen-service","not find app's client, unsubscribe failed");
+ ret = EVENT_SUBSCRIBE_ERROR_CODE;
+ }
+ }
+ else{
+ HMI_NOTICE("homescreen-service","Please input event name");
+ ret = EVENT_SUBSCRIBE_ERROR_CODE;
+ }
+ /*create response json object*/
+ struct json_object *res = json_object_new_object();
+ hs_add_object_to_json_object_func(res, __FUNCTION__, 2,
+ _error, ret);
+ afb_req_success_f(request, res, "homescreen binder unsubscribe event name [%s]", value);
+}
+
+/**
+ * allocateRestriction event
+ *
+ * #### Parameters
+ * - value : the json contents to Restriction App.
+ * {"area":"area id"}
+ *
+ * #### Return
+ * None
+ *
+ */
+static void allocateRestriction(struct afb_req request)
+{
+ HMI_NOTICE("homescreen-service","called.");
+
+ int ret = 0;
+ const char* value = afb_req_value(request, _args);
+ if (value) {
+ HMI_NOTICE("homescreen-service","request args = %s.", value);
+ HS_Client* client = g_client_manager->find(std::string("restriction"));
+ if(client != nullptr) {
+ if(client->allocateRestriction(request, value) != 0) {
+ afb_req_fail_f(request, "afb_event_push failed", "called %s.", __FUNCTION__);
+ return;
+ }
+ }
+ else {
+ // app is not started, do nothing
+ }
+ } else {
+ afb_req_fail_f(request, "failed", "called %s, Unknown palameter", __FUNCTION__);
+ return;
+ }
+
+ // response to Application
+ struct json_object *res = json_object_new_object();
+ hs_add_object_to_json_object_func(res, __FUNCTION__, 2,
+ _error, ret);
+ afb_req_success(request, res, "afb_event_push event [allocateRestriction]");
+}
+
+/**
+ * releaseRestriction event
+ *
+ * #### Parameters
+ * - value : the json contents to Restriction App.
+ * {"area":"area id"}
+ *
+ * #### Return
+ * None
+ *
+ */
+static void releaseRestriction(struct afb_req request)
+{
+ HMI_NOTICE("homescreen-service","called.");
+
+ int ret = 0;
+ const char* value = afb_req_value(request, _args);
+ if (value) {
+ HMI_NOTICE("homescreen-service","request args = %s.", value);
+ HS_Client* client = g_client_manager->find(std::string("restriction"));
+ if(client != nullptr) {
+ if(client->releaseRestriction(request, value) != 0) {
+ afb_req_fail_f(request, "afb_event_push failed", "called %s.", __FUNCTION__);
+ return;
+ }
+ }
+ else {
+ // app is not started, do nothing
+ }
+ } else {
+ afb_req_fail_f(request, "failed", "called %s, Unknown palameter", __FUNCTION__);
+ return;
+ }
+
+ // response to Application
+ struct json_object *res = json_object_new_object();
+ hs_add_object_to_json_object_func(res, __FUNCTION__, 2,
+ _error, ret);
+ afb_req_success(request, res, "afb_event_push event [releaseRestriction]");
+}
+
+/*
+ * array of the verbs exported to afb-daemon
+ */
+static const struct afb_verb_v2 verbs[]= {
+ /* VERB'S NAME FUNCTION TO CALL authorisation some info SESSION MANAGEMENT */
+ { .verb = "ping", .callback = pingSample, .auth = NULL, .info = NULL, .session = AFB_SESSION_NONE },
+ { .verb = "tap_shortcut", .callback = tap_shortcut, .auth = NULL, .info = NULL, .session = AFB_SESSION_NONE },
+ { .verb = "showWindow", .callback = showWindow, .auth = NULL, .info = NULL, .session = AFB_SESSION_NONE, },
+ { .verb = "on_screen_message", .callback = on_screen_message, .auth = NULL, .info = NULL, .session = AFB_SESSION_NONE },
+ { .verb = "on_screen_reply", .callback = on_screen_reply, .auth = NULL, .info = NULL, .session = AFB_SESSION_NONE },
+ { .verb = "subscribe", .callback = subscribe, .auth = NULL, .info = NULL, .session = AFB_SESSION_NONE },
+ { .verb = "unsubscribe", .callback = unsubscribe, .auth = NULL, .info = NULL, .session = AFB_SESSION_NONE },
+ { .verb = "allocateRestriction", .callback = allocateRestriction, .auth = NULL, .info = NULL, .session = AFB_SESSION_NONE, },
+ { .verb = "releaseRestriction", .callback = releaseRestriction, .auth = NULL, .info = NULL, .session = AFB_SESSION_NONE, },
+ {NULL } /* marker for end of the array */
+};
+
+/**
+ * homescreen binding preinit function
+ *
+ * #### Parameters
+ * - null
+ *
+ * #### Return
+ * None
+ *
+ */
+static int preinit()
+{
+ HMI_NOTICE("homescreen-service","binding preinit (was register)");
+ return 0;
+}
+
+/**
+ * homescreen binding init function
+ *
+ * #### Parameters
+ * - null
+ *
+ * #### Return
+ * None
+ *
+ */
+static int init()
+{
+ HMI_NOTICE("homescreen-service","binding init");
+
+ g_client_manager->init();
+
+ return 0;
+}
+
+/**
+ * homescreen binding event function
+ *
+ * #### Parameters
+ * - event : event name
+ * - object : event json object
+ *
+ * #### Return
+ * None
+ *
+ */
+static void onevent(const char *event, struct json_object *object)
+{
+ HMI_NOTICE("homescreen-service","on_event %s", event);
+}
+
+const struct afb_binding_v2 afbBindingV2 = {
+ .api = "homescreen",
+ .specification = NULL,
+ .info = NULL,
+ .verbs = verbs,
+ .preinit = preinit,
+ .init = init,
+ .onevent = onevent
+};
diff --git a/demo#3/common/agl-service-homescreen/src/hs-client.cpp b/demo#3/common/agl-service-homescreen/src/hs-client.cpp
new file mode 100644
index 0000000..b2f9215
--- /dev/null
+++ b/demo#3/common/agl-service-homescreen/src/hs-client.cpp
@@ -0,0 +1,255 @@
+/*
+ * Copyright (c) 2018 TOYOTA MOTOR CORPORATION
+ *
+ * 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.
+ */
+
+#include "hs-client.h"
+#include "hs-helper.h"
+#include "hmi-debug.h"
+
+static const char _type[] = "type";
+
+/**
+ * HS_Client construction function
+ *
+ * #### Parameters
+ * - id: app's id
+ *
+ * #### Return
+ * None
+ *
+ */
+HS_Client::HS_Client(struct afb_req request, std::string id) : my_id(id)
+{
+ HMI_NOTICE("homescreen-service","called.");
+ my_event = afb_daemon_make_event(id.c_str());
+}
+
+/**
+ * HS_Client destruction function
+ *
+ * #### Parameters
+ * - null
+ *
+ * #### Return
+ * None
+ *
+ */
+HS_Client::~HS_Client()
+{
+ HMI_NOTICE("homescreen-service","called.");
+ afb_event_unref(my_event);
+}
+
+/**
+ * push tap_shortcut event
+ *
+ * #### Parameters
+ * - appname: app's name.
+ *
+ * #### Return
+ * result
+ *
+ */
+int HS_Client::tap_shortcut(const char* appname)
+{
+ if(!checkEvent(__FUNCTION__))
+ return 0;
+
+ HMI_NOTICE("homescreen-service","%s application_name = %s.", __FUNCTION__, appname);
+ struct json_object* push_obj = json_object_new_object();
+ hs_add_object_to_json_object_str( push_obj, 4, _application_name, appname,
+ _type, __FUNCTION__);
+ afb_event_push(my_event, push_obj);
+ return 0;
+}
+
+/**
+ * push showWindow event
+ *
+ * #### Parameters
+ * - appname: app's name.
+ *
+ * #### Return
+ * result
+ *
+ */
+int HS_Client::showWindow(struct afb_req request, const char* appname)
+{
+ if(!checkEvent(__FUNCTION__))
+ return 0;
+
+ HMI_NOTICE("homescreen-service","%s application_name = %s.", __FUNCTION__, appname);
+ struct json_object* push_obj = json_object_new_object();
+ hs_add_object_to_json_object_str( push_obj, 4, _application_name, appname,
+ _type, __FUNCTION__);
+ const char *param = afb_req_value(request, _parameter);
+ json_object_object_add(push_obj, _parameter, json_tokener_parse(param));
+ afb_event_push(my_event, push_obj);
+ return 0;
+}
+/**
+ * push on_screen_message event
+ *
+ * #### Parameters
+ * - message: post message.
+ *
+ * #### Return
+ * result
+ *
+ */
+int HS_Client::on_screen_message(struct afb_req request, const char* message)
+{
+ if(!checkEvent(__FUNCTION__))
+ return 0;
+
+ HMI_NOTICE("homescreen-service","push %s event message [%s].", __FUNCTION__, message);
+ struct json_object* push_obj = json_object_new_object();
+ hs_add_object_to_json_object_str( push_obj, 4, _display_message, message,
+ _type, __FUNCTION__);
+ afb_event_push(my_event, push_obj);
+ return 0;
+}
+
+/**
+ * push on_screen_reply event
+ *
+ * #### Parameters
+ * - message: reply message.
+ *
+ * #### Return
+ * result
+ *
+ */
+int HS_Client::on_screen_reply(struct afb_req request, const char* message)
+{
+ if(!checkEvent(__FUNCTION__))
+ return 0;
+
+ HMI_NOTICE("homescreen-service","push %s event message [%s].", __FUNCTION__, message);
+ struct json_object* push_obj = json_object_new_object();
+ hs_add_object_to_json_object_str( push_obj, 4, _reply_message, message,
+ _type, __FUNCTION__);
+ afb_event_push(my_event, push_obj);
+ return 0;
+}
+
+/**
+ * subscribe event
+ *
+ * #### Parameters
+ * - event: homescreen event, tap_shortcut etc.
+ *
+ * #### Return
+ * result
+ *
+ */
+int HS_Client::subscribe(struct afb_req request, const char* event)
+{
+ int ret = 0;
+ auto ip = event_list.find(std::string(event));
+ if(ip == event_list.end()) {
+ event_list[std::string(event)] = 0;
+ ret = afb_req_subscribe(request, my_event);
+ }
+ return ret;
+}
+
+/**
+ * unsubscribe event
+ *
+ * #### Parameters
+ * - event: homescreen event, tap_shortcut etc.
+ *
+ * #### Return
+ * result
+ *
+ */
+int HS_Client::unsubscribe(struct afb_req request, const char* event)
+{
+ int ret = 0;
+ event_list.erase(std::string(event));
+ if(event_list.empty()) {
+ ret = afb_req_unsubscribe(request, my_event);
+ }
+ return ret;
+}
+
+/**
+ * allocate restriction
+ *
+ * #### Parameters
+ * - area: display area.
+ *
+ * #### Return
+ * result
+ *
+ */
+int HS_Client::allocateRestriction(struct afb_req request, const char* area)
+{
+ if(!checkEvent(__FUNCTION__))
+ return 0;
+
+ HMI_NOTICE("homescreen-service","%s area=%s.", __FUNCTION__, area);
+ struct json_object* push_obj = json_object_new_object();
+ hs_add_object_to_json_object_str( push_obj, 4, _application_name, "restriction",
+ _type, __FUNCTION__);
+ json_object_object_add(push_obj, _args, json_tokener_parse(area));
+ afb_event_push(my_event, push_obj);
+ return 0;
+}
+
+/**
+ * release restriction
+ *
+ * #### Parameters
+ * - area: display area.
+ *
+ * #### Return
+ * result
+ *
+ */
+int HS_Client::releaseRestriction(struct afb_req request, const char* area)
+{
+ if(!checkEvent(__FUNCTION__))
+ return 0;
+
+ HMI_NOTICE("homescreen-service","%s area=%s.", __FUNCTION__, area);
+ struct json_object* push_obj = json_object_new_object();
+ hs_add_object_to_json_object_str( push_obj, 4, _application_name, "restriction",
+ _type, __FUNCTION__);
+ json_object_object_add(push_obj, _args, json_tokener_parse(area));
+ afb_event_push(my_event, push_obj);
+ return 0;
+}
+
+/**
+ * check if client subscribe event
+ *
+ * #### Parameters
+ * - event: homescreen event, tap_shortcut etc.
+ *
+ * #### Return
+ * true: found
+ * false: not found
+ *
+ */
+bool HS_Client::checkEvent(const char* event)
+{
+ auto ip = event_list.find(std::string(event));
+ if(ip == event_list.end())
+ return false;
+ else
+ return true;
+}
diff --git a/demo#3/common/agl-service-homescreen/src/hs-client.h b/demo#3/common/agl-service-homescreen/src/hs-client.h
new file mode 100644
index 0000000..bd881e6
--- /dev/null
+++ b/demo#3/common/agl-service-homescreen/src/hs-client.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2018 TOYOTA MOTOR CORPORATION
+ *
+ * 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.
+ */
+
+#ifndef HOMESCREEN_CLIENT_H
+#define HOMESCREEN_CLIENT_H
+
+#include <string>
+#include <unordered_map>
+#include "hs-helper.h"
+
+
+class HS_Client {
+public:
+ HS_Client(struct afb_req request, const char* id) : HS_Client(request, std::string(id)){}
+ HS_Client(struct afb_req request, std::string id);
+ HS_Client(HS_Client&) = delete;
+ HS_Client &operator=(HS_Client&) = delete;
+ ~HS_Client();
+
+ int tap_shortcut(const char* appname);
+ int showWindow(struct afb_req request, const char* appname);
+ int on_screen_message (struct afb_req request, const char* message);
+ int on_screen_reply (struct afb_req request, const char* message);
+ int subscribe(struct afb_req request, const char* event);
+ int unsubscribe(struct afb_req request, const char* event);
+ int allocateRestriction(struct afb_req request, const char* area);
+ int releaseRestriction(struct afb_req request, const char* area);
+
+private:
+ bool checkEvent(const char* event);
+
+private:
+ std::string my_id;
+ struct afb_event my_event;
+ std::unordered_map<std::string, int> event_list;
+
+};
+
+#endif // HOMESCREEN_CLIENT_H \ No newline at end of file
diff --git a/demo#3/common/agl-service-homescreen/src/hs-clientmanager.cpp b/demo#3/common/agl-service-homescreen/src/hs-clientmanager.cpp
new file mode 100644
index 0000000..3dea3a6
--- /dev/null
+++ b/demo#3/common/agl-service-homescreen/src/hs-clientmanager.cpp
@@ -0,0 +1,219 @@
+/*
+ * Copyright (c) 2018 TOYOTA MOTOR CORPORATION
+ *
+ * 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.
+ */
+
+#include "hs-clientmanager.h"
+#include "hmi-debug.h"
+
+HS_ClientManager* HS_ClientManager::me = nullptr;
+
+static void cbRemoveClientCtxt(void *data)
+{
+ HS_ClientManager::instance()->removeClientCtxt(data);
+}
+
+/**
+ * HS_ClientManager construction function
+ *
+ * #### Parameters
+ * - Nothing
+ *
+ * #### Return
+ * None
+ *
+ */
+HS_ClientManager::HS_ClientManager()
+{
+}
+
+/**
+ * get instance
+ *
+ * #### Parameters
+ * - Nothing
+ *
+ * #### Return
+ * HS_ClientManager instance pointer
+ *
+ */
+HS_ClientManager* HS_ClientManager::instance(void)
+{
+ if(me == nullptr)
+ me = new HS_ClientManager();
+
+ return me;
+}
+
+/**
+ * HS_ClientManager init function
+ *
+ * #### Parameters
+ * - Nothing
+ *
+ * #### Return
+ * init result
+ *
+ */
+int HS_ClientManager::init(void)
+{
+ HMI_NOTICE("homescreen-service","called.");
+ // TODO : connect to windowmanger
+ // get applist from appfw
+}
+
+/**
+ * find HS_Client in client_list
+ *
+ * #### Parameters
+ * - appid: app's id
+ *
+ * #### Return
+ * found HS_Client pointer
+ *
+ */
+HS_Client* HS_ClientManager::find(std::string appid)
+{
+ std::lock_guard<std::mutex> lock(this->mtx);
+ HS_Client* p = nullptr;
+ auto ip = client_list.find(appid);
+ if(ip != client_list.end()) {
+ p = client_list[appid];
+ }
+ return p;
+}
+
+/**
+ * get HS_Client
+ *
+ * #### Parameters
+ * - appid: app's id
+ *
+ * #### Return
+ * found HS_Client pointer
+ *
+ */
+HS_Client* HS_ClientManager::getClient(afb_req req, std::string appid)
+{
+ std::lock_guard<std::mutex> lock(this->mtx);
+ HS_Client* p = nullptr;
+ auto ip = client_list.find(appid);
+ if(ip != client_list.end()) {
+ p = client_list[appid];
+ }
+ else {
+ appid2ctxt[appid] = createClientCtxt(req, appid);
+ p = addClient(req, appid);
+ }
+ return p;
+}
+
+/**
+ * get HS_Client pointers set
+ *
+ * #### Parameters
+ * - Nothing
+ *
+ * #### Return
+ * HS_Client pointers set
+ *
+ */
+std::vector<HS_Client*> HS_ClientManager::getAllClient(void)
+{
+ std::lock_guard<std::mutex> lock(this->mtx);
+ std::vector<HS_Client*> v;
+ for(auto a : client_list)
+ v.push_back(a.second);
+ return v;
+}
+
+/**
+ * create client's afb_req_context
+ *
+ * #### Parameters
+ * - appid: app's id
+ *
+ * #### Return
+ * HS_ClientCtxt pointer
+ *
+ */
+HS_ClientCtxt* HS_ClientManager::createClientCtxt(afb_req req, std::string appid)
+{
+ HS_ClientCtxt *ctxt = (HS_ClientCtxt *)afb_req_context_get(req);
+ if (!ctxt)
+ {
+ HMI_NOTICE("homescreen-service", "create new session for %s", appid.c_str());
+ HS_ClientCtxt *ctxt = new HS_ClientCtxt(appid.c_str());
+ afb_req_session_set_LOA(req, 1);
+ afb_req_context_set(req, ctxt, cbRemoveClientCtxt);
+ }
+ return ctxt;
+}
+
+/**
+ * add Client
+ *
+ * #### Parameters
+ * - ctxt: app's id
+ *
+ * #### Return
+ * HS_Client pointer
+ *
+ */
+HS_Client* HS_ClientManager::addClient(afb_req req, std::string appid)
+{
+ return (client_list[appid] = new HS_Client(req, appid));
+}
+
+/**
+ * remove Client
+ *
+ * #### Parameters
+ * - appid: app's id
+ *
+ * #### Return
+ * None
+ *
+ */
+void HS_ClientManager::removeClient(std::string appid)
+{
+ delete client_list[appid];
+ client_list.erase(appid);
+}
+
+/**
+ * remove Client from list
+ *
+ * #### Parameters
+ * - data: HS_ClientCtxt pointer
+ *
+ * #### Return
+ * None
+ *
+ */
+void HS_ClientManager::removeClientCtxt(void *data)
+{
+ HS_ClientCtxt *ctxt = (HS_ClientCtxt *)data;
+ if(ctxt == nullptr)
+ {
+ HMI_ERROR("homescreen-service", "data is nullptr");
+ return;
+ }
+
+ HMI_NOTICE("homescreen-service", "remove app %s", ctxt->id.c_str());
+ std::lock_guard<std::mutex> lock(this->mtx);
+ removeClient(ctxt->id);
+ delete appid2ctxt[ctxt->id];
+ appid2ctxt.erase(ctxt->id);
+}
diff --git a/demo#3/common/agl-service-homescreen/src/hs-clientmanager.h b/demo#3/common/agl-service-homescreen/src/hs-clientmanager.h
new file mode 100644
index 0000000..cb49088
--- /dev/null
+++ b/demo#3/common/agl-service-homescreen/src/hs-clientmanager.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2018 TOYOTA MOTOR CORPORATION
+ *
+ * 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.
+ */
+
+#ifndef HOMESCREEN_CLIENTMANAGER_H
+#define HOMESCREEN_CLIENTMANAGER_H
+
+#include <string>
+#include <vector>
+#include <mutex>
+#include <memory>
+#include <unordered_map>
+#include "hs-helper.h"
+#include "hs-client.h"
+
+typedef struct HS_ClientCtxt
+{
+ std::string id;
+ HS_ClientCtxt(const char *appid)
+ {
+ id = appid;
+ }
+} HS_ClientCtxt;
+
+
+class HS_ClientManager {
+public:
+ HS_ClientManager();
+ ~HS_ClientManager() = default;
+ HS_ClientManager(HS_ClientManager const &) = delete;
+ HS_ClientManager &operator=(HS_ClientManager const &) = delete;
+ HS_ClientManager(HS_ClientManager &&) = delete;
+ HS_ClientManager &operator=(HS_ClientManager &&) = delete;
+
+ static HS_ClientManager* instance(void);
+ int init(void);
+ HS_Client* find(std::string appid);
+ HS_Client* getClient(afb_req req, std::string appid);
+ std::vector<HS_Client*> getAllClient(void);
+ void removeClientCtxt(void *data);
+
+private:
+ HS_ClientCtxt* createClientCtxt(afb_req req, std::string appid);
+ HS_Client* addClient(afb_req req, std::string appid);
+ void removeClient(std::string appid);
+
+private:
+ static HS_ClientManager* me;
+ std::unordered_map<std::string, HS_Client*> client_list;
+ std::unordered_map<std::string, HS_ClientCtxt*> appid2ctxt;
+ std::mutex mtx;
+};
+
+#endif // HOMESCREEN_CLIENTMANAGER_H \ No newline at end of file
diff --git a/demo#3/common/agl-service-homescreen/src/hs-helper.cpp b/demo#3/common/agl-service-homescreen/src/hs-helper.cpp
new file mode 100644
index 0000000..8780cc0
--- /dev/null
+++ b/demo#3/common/agl-service-homescreen/src/hs-helper.cpp
@@ -0,0 +1,246 @@
+/*
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+ *
+ * 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.
+ */
+
+#include <string.h>
+#include <cstdarg>
+#include "hs-helper.h"
+
+
+const char* evlist[] = {
+ "tap_shortcut",
+ "showWindow",
+ "on_screen_message",
+ "on_screen_reply",
+ "allocateRestriction",
+ "releaseRestriction",
+ "reserved"
+ };
+
+/**
+ * get uint16 value from source
+ *
+ * #### Parameters
+ * - request : Describes the request by bindings from afb-daemon
+ * - source : input source
+ * - out_id : output uint16 value
+ *
+ * #### Return
+ * error code
+ *
+ */
+REQ_ERROR get_value_uint16(const struct afb_req request, const char *source, uint16_t *out_id)
+{
+ char* endptr;
+ const char* tmp = afb_req_value (request, source);
+ if(!tmp)
+ {
+ return REQ_FAIL;
+ }
+ long tmp_id = strtol(tmp,&endptr,10);
+
+ /* error check of range */
+ if( (tmp_id > UINT16_MAX) || (tmp_id < 0) )
+ {
+ return OUT_RANGE;
+ }
+ if(*endptr != '\0')
+ {
+ return NOT_NUMBER;
+ }
+
+ *out_id = (uint16_t)tmp_id;
+ return REQ_OK;
+}
+
+/**
+ * get int16 value from source
+ *
+ * #### Parameters
+ * - request : Describes the request by bindings from afb-daemon
+ * - source : input source
+ * - out_id : output int16 value
+ *
+ * #### Return
+ * error code
+ *
+ */
+REQ_ERROR get_value_int16(const struct afb_req request, const char *source, int16_t *out_id)
+{
+ char* endptr;
+ const char* tmp = afb_req_value (request, source);
+ if(!tmp)
+ {
+ return REQ_FAIL;
+ }
+ long tmp_id = strtol(tmp,&endptr,10);
+
+ /* error check of range */
+ if( (tmp_id > INT16_MAX) || (tmp_id < INT16_MIN) )
+ {
+ return OUT_RANGE;
+ }
+ if(*endptr != '\0')
+ {
+ return NOT_NUMBER;
+ }
+
+ *out_id = (int16_t)tmp_id;
+ return REQ_OK;
+}
+
+/**
+ * get int32 value from source
+ *
+ * #### Parameters
+ * - request : Describes the request by bindings from afb-daemon
+ * - source : input source
+ * - out_id : output int32 value
+ *
+ * #### Return
+ * error code
+ *
+ */
+REQ_ERROR get_value_int32(const struct afb_req request, const char *source, int32_t *out_id)
+{
+ char* endptr;
+ const char* tmp = afb_req_value (request, source);
+ if(!tmp)
+ {
+ return REQ_FAIL;
+ }
+ long tmp_id = strtol(tmp,&endptr,10);
+
+ /* error check of range */
+ if( (tmp_id > INT32_MAX) || (tmp_id < INT32_MIN) )
+ {
+ return OUT_RANGE;
+ }
+ if(*endptr != '\0')
+ {
+ return NOT_NUMBER;
+ }
+
+ *out_id = (int32_t)tmp_id;
+ return REQ_OK;
+}
+
+/**
+ * add int object to json object
+ *
+ * #### Parameters
+ * - j_obj : the json object will join in int json object
+ * - count : input parameter number
+ * - ... : parameter list
+ *
+ * #### Return
+ * None
+ *
+ */
+void hs_add_object_to_json_object(struct json_object* j_obj, int count,...)
+{
+ va_list args;
+ va_start(args, count);
+ for(int i = 0; i < count; ++i )
+ {
+ char *key = va_arg(args, char*);
+ int value = va_arg(args, int);
+ json_object_object_add(j_obj, key, json_object_new_int((int32_t)value));
+ ++i;
+ }
+ va_end(args);
+}
+
+/**
+ * add string object to json object
+ *
+ * #### Parameters
+ * - j_obj : the json object will join in string json object
+ * - count : input parameter number
+ * - ... : parameter list
+ *
+ * #### Return
+ * None
+ *
+ */
+void hs_add_object_to_json_object_str(struct json_object* j_obj, int count,...)
+{
+ va_list args;
+ va_start(args, count);
+ for(int i = 0; i < count; ++i )
+ {
+ char *key = va_arg(args, char*);
+ char *value = va_arg(args, char*);
+ json_object_object_add(j_obj, key, json_object_new_string(value));
+ ++i;
+ }
+ va_end(args);
+}
+
+/**
+ * add new json object to json object
+ *
+ * #### Parameters
+ * - j_obj : the json object will join in new json object
+ * - verb_name : new json object's verb value
+ * - count : input parameter number
+ * - ... : parameter list
+ *
+ * #### Return
+ * None
+ *
+ */
+void hs_add_object_to_json_object_func(struct json_object* j_obj, const char* verb_name, int count, ...)
+{
+ va_list args;
+ va_start(args, count);
+
+ json_object_object_add(j_obj,"verb", json_object_new_string(verb_name));
+
+ for(int i = 0; i < count; ++i )
+ {
+ char *key = va_arg(args, char*);
+ int value = va_arg(args, int);
+ json_object_object_add(j_obj, key, json_object_new_int((int32_t)value));
+ ++i;
+ }
+ va_end(args);
+}
+
+/**
+ * search event position in event list
+ *
+ * #### Parameters
+ * - value : searched event name
+ *
+ * #### Return
+ * event's index in event list
+ *
+ */
+int hs_search_event_name_index(const char* value)
+{
+ size_t buf_size = 50;
+ size_t size = sizeof evlist / sizeof *evlist;
+ int ret = -1;
+ for(size_t i = 0 ; i < size ; ++i)
+ {
+ if(!strncmp(value, evlist[i], buf_size))
+ {
+ ret = i;
+ break;
+ }
+ }
+ return ret;
+}
diff --git a/demo#3/common/agl-service-homescreen/src/hs-helper.h b/demo#3/common/agl-service-homescreen/src/hs-helper.h
new file mode 100644
index 0000000..b2354e0
--- /dev/null
+++ b/demo#3/common/agl-service-homescreen/src/hs-helper.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+ *
+ * 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.
+ */
+
+#ifndef HOMESCREEN_HELPER_H
+#define HOMESCREEN_HELPER_H
+#define AFB_BINDING_VERSION 2
+#include <afb/afb-binding.h>
+#include <json-c/json.h>
+
+
+typedef enum REQ_ERROR
+{
+ REQ_FAIL = -1,
+ REQ_OK=0,
+ NOT_NUMBER,
+ OUT_RANGE
+}REQ_ERROR;
+
+extern const char* evlist[];
+extern const char _error[];
+extern const char _application_name[];
+extern const char _display_message[];
+extern const char _reply_message[];
+extern const char _args[];
+extern const char _parameter[];
+
+REQ_ERROR get_value_uint16(const struct afb_req request, const char *source, uint16_t *out_id);
+REQ_ERROR get_value_int16(const struct afb_req request, const char *source, int16_t *out_id);
+REQ_ERROR get_value_int32(const struct afb_req request, const char *source, int32_t *out_id);
+void hs_add_object_to_json_object(struct json_object* j_obj, int count, ...);
+void hs_add_object_to_json_object_str(struct json_object* j_obj, int count, ...);
+void hs_add_object_to_json_object_func(struct json_object* j_obj, const char* verb_name, int count, ...);
+int hs_search_event_name_index(const char* value);
+
+#endif /*HOMESCREEN_HELPER_H*/