From: wang_zhiqiang Date: Tue, 9 Oct 2018 02:11:34 +0000 (+0800) Subject: emit event to one application X-Git-Tag: 6.99.1~2 X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?p=src%2Flibhomescreen.git;a=commitdiff_plain;h=8bf11a8668902565b0e9a23e320777f5fb611848 emit event to one application changed agl-service-homescreen and libhomescreen to make agl-service-homescreen emit event to one application only. BUG-AGL: SPEC-1764 Change-Id: If595c6043b559d64dff62bd826482c651e9ae808 Signed-off-by: wang_zhiqiang --- diff --git a/src/libhomescreen.cpp b/src/libhomescreen.cpp index cfd382d..c3e76ba 100644 --- a/src/libhomescreen.cpp +++ b/src/libhomescreen.cpp @@ -471,27 +471,29 @@ void LibHomeScreen::on_event(void *closure, const char *event, struct afb_wsj1_m onEvent(ev, ev_contents); } - const char* event_only = strchr(event, '/'); - if (event_only != nullptr) { - event_only = event_only + 1; - }else{ - HMI_WARNING("libhomescreen","event_only is null."); + const char* event_type = nullptr; + struct json_object *json_event_type; + if(json_object_object_get_ex(json_data, "type", &json_event_type)) { + event_type = json_object_get_string(json_event_type); + } + else { + HMI_WARNING("libhomescreen","event_type is null."); return; } - if (strcasecmp(event_only, LibHomeScreen::event_list[0].c_str()) == 0) { + if (strcasecmp(event_type, LibHomeScreen::event_list[0].c_str()) == 0) { auto i = this->handlers.find(Event_TapShortcut); if ( i != this->handlers.end() ) { i->second(json_data); } } - else if (strcasecmp(event_only, LibHomeScreen::event_list[1].c_str()) == 0) { + else if (strcasecmp(event_type, LibHomeScreen::event_list[1].c_str()) == 0) { auto i = this->handlers.find(Event_OnScreenMessage); if ( i != this->handlers.end() ) { i->second(json_data); } } - else if (strcasecmp(event_only, LibHomeScreen::event_list[2].c_str()) == 0) { + else if (strcasecmp(event_type, LibHomeScreen::event_list[2].c_str()) == 0) { auto i = this->handlers.find(Event_OnScreenReply); if ( i != this->handlers.end() ) { i->second(json_data);