diff options
author | wang_zhiqiang <wang_zhiqiang@dl.cn.nexty-ele.com> | 2018-10-09 10:11:34 +0800 |
---|---|---|
committer | wang_zhiqiang <wang_zhiqiang@dl.cn.nexty-ele.com> | 2018-10-16 13:52:07 +0800 |
commit | 8bf11a8668902565b0e9a23e320777f5fb611848 (patch) | |
tree | 2787c4be124b4da8bf6bd81ef045f34e14210d00 | |
parent | cac960f01705b024bf5536bf536a2a7caf9dbe99 (diff) |
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 <wang_zhiqiang@dl.cn.nexty-ele.com>
-rw-r--r-- | src/libhomescreen.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
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); |