Update lastest code from agl-service-homescreen-2017 57/16457/2 5.99.6 flounder/5.99.6 flounder_5.99.6
authorzheng_wenlong <wenlong_zheng@nexty-ele.com>
Mon, 3 Sep 2018 01:39:15 +0000 (10:39 +0900)
committerZheng Wenlong <wenlong_zheng@nexty-ele.com>
Mon, 3 Sep 2018 07:38:43 +0000 (07:38 +0000)
    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 <wenlong_zheng@nexty-ele.com>
Signed-off-by: wang_zhiqiang <wang_zhiqiang@dl.cn.nexty-ele.com>
src/CMakeLists.txt
src/hmi-debug.h
src/homescreen.cpp [moved from src/homescreen.c with 88% similarity]
src/hs-helper.cpp [moved from src/hs-helper.c with 96% similarity]
src/hs-helper.h

index 363cdae..dbd7fbe 100644 (file)
@@ -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)
index 2a744ba..3c71ff5 100644 (file)
 #ifndef __HMI_DEBUG_H__
 #define __HMI_DEBUG_H__
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <time.h>
 #include <stdio.h>
 #include <stdarg.h>
@@ -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
similarity index 88%
rename from src/homescreen.c
rename to src/homescreen.cpp
index f1a8fcd..85ea99f 100644 (file)
  * limitations under the License.
  */
 
+#ifndef _GNU_SOURCE
 #define _GNU_SOURCE
-#define AFB_BINDING_VERSION 2
-#include <afb/afb-binding.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <unistd.h>
-#include <json-c/json.h>
-#include <glib.h>
-#include <pthread.h>
+#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,
similarity index 96%
rename from src/hs-helper.c
rename to src/hs-helper.cpp
index 3415510..452ae24 100644 (file)
  * limitations under the License.
  */
 
-#include "hs-helper.h"
-#include <stdlib.h>
 #include <string.h>
-#include <limits.h>
-#include <json-c/json.h>
-#include <stdarg.h>
+#include <cstdarg>
+#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)
 {
index 5ce9eb5..fe74303 100644 (file)
@@ -18,9 +18,8 @@
 #define HOMESCREEN_HELPER_H
 #define AFB_BINDING_VERSION 2
 #include <afb/afb-binding.h>
-#include <stdint.h>
-#include <glib.h>
-#include <errno.h>
+#include <json-c/json.h>
+
 
 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);