From bb38a76d1b00e93187967aa2880e79e671f02eba Mon Sep 17 00:00:00 2001 From: zheng_wenlong Date: Mon, 3 Sep 2018 10:39:15 +0900 Subject: [PATCH] Update lastest code from agl-service-homescreen-2017 Update the lastest code from agl-service-homescreen-2017. To impove homescreen-service's extensibility. "Change homescreen-service from c project to c++ project" Relative Commit: https://gerrit.automotivelinux.org/gerrit/#/c/16351/ Change-Id: Id7e50fa61fdfcff30f69588aa1da4d93695edfc1 Signed-off-by: zheng_wenlong Signed-off-by: wang_zhiqiang --- src/CMakeLists.txt | 4 ++-- src/hmi-debug.h | 7 +++++++ src/{homescreen.c => homescreen.cpp} | 28 ++++++++++------------------ src/{hs-helper.c => hs-helper.cpp} | 16 +++++++++++----- src/hs-helper.h | 12 +++--------- 5 files changed, 33 insertions(+), 34 deletions(-) rename src/{homescreen.c => homescreen.cpp} (88%) rename src/{hs-helper.c => hs-helper.cpp} (96%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 363cdae..dbd7fbe 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -23,8 +23,8 @@ 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.c - hs-helper.c) + homescreen.cpp + hs-helper.cpp) link_libraries(-Wl,--as-needed -Wl,--gc-sections -Wl,--no-undefined) include_directories(${PROJECT_SOURCE_DIR}/include) diff --git a/src/hmi-debug.h b/src/hmi-debug.h index 2a744ba..3c71ff5 100644 --- a/src/hmi-debug.h +++ b/src/hmi-debug.h @@ -17,6 +17,10 @@ #ifndef __HMI_DEBUG_H__ #define __HMI_DEBUG_H__ +#ifdef __cplusplus +extern "C" { +#endif + #include #include #include @@ -67,4 +71,7 @@ static void _HMI_LOG(enum LOG_LEVEL level, const char* file, const char* func, c free(message); } +#ifdef __cplusplus +} +#endif #endif //__HMI_DEBUG_H__ \ No newline at end of file diff --git a/src/homescreen.c b/src/homescreen.cpp similarity index 88% rename from src/homescreen.c rename to src/homescreen.cpp index f1a8fcd..85ea99f 100644 --- a/src/homescreen.c +++ b/src/homescreen.cpp @@ -14,18 +14,9 @@ * limitations under the License. */ +#ifndef _GNU_SOURCE #define _GNU_SOURCE -#define AFB_BINDING_VERSION 2 -#include - -#include -#include -#include -#include -#include -#include -#include -#include +#endif #include "hs-helper.h" #include "hmi-debug.h" @@ -259,13 +250,13 @@ static void unsubscribe(struct afb_req request) * array of the verbs exported to afb-daemon */ static const struct afb_verb_v2 verbs[]= { - /* VERB'S NAME SESSION MANAGEMENT FUNCTION TO CALL */ - { .verb = "ping", .session = AFB_SESSION_NONE, .callback = pingSample, .auth = NULL }, - { .verb = "tap_shortcut", .session = AFB_SESSION_NONE, .callback = tap_shortcut, .auth = NULL }, - { .verb = "on_screen_message", .session = AFB_SESSION_NONE, .callback = on_screen_message, .auth = NULL }, - { .verb = "on_screen_reply", .session = AFB_SESSION_NONE, .callback = on_screen_reply, .auth = NULL }, - { .verb = "subscribe", .session = AFB_SESSION_NONE, .callback = subscribe, .auth = NULL }, - { .verb = "unsubscribe", .session = AFB_SESSION_NONE, .callback = unsubscribe, .auth = NULL }, + /* 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 = "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 }, {NULL } /* marker for end of the array */ }; @@ -307,6 +298,7 @@ static void onevent(const char *event, struct json_object *object) const struct afb_binding_v2 afbBindingV2 = { .api = "homescreen", .specification = NULL, + .info = NULL, .verbs = verbs, .preinit = preinit, .init = init, diff --git a/src/hs-helper.c b/src/hs-helper.cpp similarity index 96% rename from src/hs-helper.c rename to src/hs-helper.cpp index 3415510..452ae24 100644 --- a/src/hs-helper.c +++ b/src/hs-helper.cpp @@ -14,12 +14,18 @@ * limitations under the License. */ -#include "hs-helper.h" -#include #include -#include -#include -#include +#include +#include "hs-helper.h" + + +const char* evlist[] = { + "tap_shortcut", + "on_screen_message", + "on_screen_reply", + "reserved" + }; + REQ_ERROR get_value_uint16(const struct afb_req request, const char *source, uint16_t *out_id) { diff --git a/src/hs-helper.h b/src/hs-helper.h index 5ce9eb5..fe74303 100644 --- a/src/hs-helper.h +++ b/src/hs-helper.h @@ -18,9 +18,8 @@ #define HOMESCREEN_HELPER_H #define AFB_BINDING_VERSION 2 #include -#include -#include -#include +#include + typedef enum REQ_ERROR { @@ -30,12 +29,7 @@ typedef enum REQ_ERROR OUT_RANGE }REQ_ERROR; -static const char* evlist[] = { - "tap_shortcut", - "on_screen_message", - "on_screen_reply", - "reserved" - }; +extern const char* evlist[]; 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); -- 2.16.6