diff options
author | 2019-06-25 11:03:17 +0800 | |
---|---|---|
committer | 2019-06-25 11:03:17 +0800 | |
commit | 31a095fa9180414dbd173e026e521b289b6a828c (patch) | |
tree | e73c6c7f362ba1118c29d73ab1cb4d79c9c7d55d | |
parent | e7975acfbcfb00a29940b35ae1c19c070cedc7a3 (diff) |
add eventsandbox/wangzhiqiang/als2019
Change-Id: Ib54394d6cb9debc6077eefceea37a570cff65525
-rw-r--r-- | include/libhomescreen.hpp | 4 | ||||
-rw-r--r-- | src/libhomescreen.cpp | 18 |
2 files changed, 21 insertions, 1 deletions
diff --git a/include/libhomescreen.hpp b/include/libhomescreen.hpp index d0b270a..bdfeb4b 100644 --- a/include/libhomescreen.hpp +++ b/include/libhomescreen.hpp @@ -53,6 +53,10 @@ public: Event_AppListChanged, Event_RegisterShortcut, Event_UpdateShortcut, + Event_SetDestination, + Event_CancelDestination, + Event_StartNavigation, + Event_StopNavigation, Event_Max }; diff --git a/src/libhomescreen.cpp b/src/libhomescreen.cpp index b5a534d..8b0ffd8 100644 --- a/src/libhomescreen.cpp +++ b/src/libhomescreen.cpp @@ -66,6 +66,10 @@ const std::vector<std::string> LibHomeScreen::event_list { std::string("application-list-changed"), std::string("registerShortcut"), std::string("updateShortcut"), + std::string("setDestination"), + std::string("cancelDestination"), + std::string("startNavigation"), + std::string("stopNavigation"), std::string("none") }; @@ -330,8 +334,20 @@ void LibHomeScreen::set_event_handler(enum EventType et, handler_func f) */ void LibHomeScreen::publishSubscription(void) { + struct json_object* j_obj = json_object_new_array(); for(auto &it : handlers) { - this->subscribe(LibHomeScreen::event_list[it.first - 1]); + json_object_array_add(j_obj, json_object_new_string(LibHomeScreen::event_list[it.first - 1].c_str())); + } + + if(!sp_websock) { + return; + } + struct json_object* push_obj = json_object_new_object(); + json_object_object_add(push_obj, "event", j_obj); + + int ret = afb_wsj1_call_j(sp_websock, API, "subscribe", push_obj, _on_reply_static, this); + if (ret < 0) { + HMI_ERROR("libhomescreen","Failed to call subscribe."); } } |