add event
[src/libhomescreen.git] / src / libhomescreen.cpp
index b5a534d..8b0ffd8 100644 (file)
@@ -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.");
        }
 }