diff options
author | zheng_wenlong <wenlong_zheng@nexty-ele.com> | 2019-06-21 12:44:48 +0900 |
---|---|---|
committer | zheng_wenlong <wenlong_zheng@nexty-ele.com> | 2019-06-21 12:44:48 +0900 |
commit | c8193621f75bcf66720cd8bccedd55a00d4e0e24 (patch) | |
tree | 203e3751a0a45a951c97e57b55b73e094215eece /homescreen | |
parent | c38d55fc0b43215f63c873e7578554f5942e69b3 (diff) |
Change VUI disconnect message display condition
Diffstat (limited to 'homescreen')
-rw-r--r-- | homescreen/qml/main.qml | 2 | ||||
-rw-r--r-- | homescreen/src/homescreenvoice.cpp | 58 | ||||
-rw-r--r-- | homescreen/src/homescreenvoice.h | 4 |
3 files changed, 48 insertions, 16 deletions
diff --git a/homescreen/qml/main.qml b/homescreen/qml/main.qml index a0ff4f4..6ca2b5d 100644 --- a/homescreen/qml/main.qml +++ b/homescreen/qml/main.qml @@ -322,7 +322,7 @@ Window { anchors.right: parent.right anchors.bottomMargin: 50 anchors.rightMargin: 0 - visible: true + visible: false Image { id: voiceimage anchors.left: parent.left diff --git a/homescreen/src/homescreenvoice.cpp b/homescreen/src/homescreenvoice.cpp index f56625e..0c08b5f 100644 --- a/homescreen/src/homescreenvoice.cpp +++ b/homescreen/src/homescreenvoice.cpp @@ -26,7 +26,7 @@ static const char API[] = "vshl-core"; -const string vshl_core_event = "{\"va_id\": \"VA-001\", \"events\": [\"voice_dialogstate_event\"]}"; +const string vshl_core_event = "{\"va_id\": \"VA-001\", \"events\": [\"voice_dialogstate_event\",\"voice_connectionstate_event\"]}"; static void _on_hangup_static(void *closure, struct afb_wsj1 *wsj) { @@ -56,6 +56,15 @@ const std::vector<std::string> HomescreenVoice::state_lists { std::string("SPEAKING") }; +const std::vector<std::string> HomescreenVoice::connect_lists { + std::string("DISCONNECTED"), + std::string("CONNECTED") +}; + +const std::vector<std::string> HomescreenVoice::event_lists { + std::string("vshl-core/voice_dialogstate_event#VA-001"), + std::string("vshl-core/voice_connectionstate_event#VA-001") +}; static void event_loop_run(struct sd_event* loop){ sd_event_loop(loop); @@ -193,32 +202,53 @@ void HomescreenVoice::on_event(void *closure, const char *event, struct afb_wsj1 return; } struct json_object* ev_contents = afb_wsj1_msg_object_j(msg); + struct json_object *json_event_str; + + if(!json_object_object_get_ex(ev_contents, "event", &json_event_str)) { + HMI_ERROR("HomescreenVoice", "got json_event_str error."); + return; + } struct json_object *json_data_str; if(!json_object_object_get_ex(ev_contents, "data", &json_data_str)) { - HMI_ERROR("HomescreenVoice", "got ev_contents error."); + HMI_ERROR("HomescreenVoice", "got data error."); return; } struct json_object *json_state; struct json_object *json_data = json_tokener_parse(json_object_get_string(json_data_str)); if(!json_object_object_get_ex(json_data, "state", &json_state)) { - HMI_ERROR("HomescreenVoice", "got json_data1 error."); + HMI_ERROR("HomescreenVoice", "got state error."); return; } const char* info = json_object_get_string(json_state); - - if (strcasecmp(info, HomescreenVoice::state_lists[0].c_str()) == 0) { - emit statusChanged(true); + const char* eventinfo = json_object_get_string(json_event_str); + const char* warnginfo = "Alexa disconnect!"; + if(strcasecmp(eventinfo, HomescreenVoice::event_lists[0].c_str()) == 0){ + if (strcasecmp(info, HomescreenVoice::state_lists[0].c_str()) == 0) { + if(connect){ + emit statusChanged(true); + emit showInformation(QString(QLatin1String(info))); + } + } + else if ((strcasecmp(info, HomescreenVoice::state_lists[1].c_str()) == 0)|| + (strcasecmp(info, HomescreenVoice::state_lists[2].c_str()) == 0)|| + (strcasecmp(info, HomescreenVoice::state_lists[3].c_str()) == 0)|| + (strcasecmp(info, HomescreenVoice::state_lists[4].c_str()) == 0)){ + emit statusChanged(false); + emit showInformation(QString(QLatin1String(info))); + } + }else if(strcasecmp(eventinfo, HomescreenVoice::event_lists[1].c_str()) == 0){ + if (strcasecmp(info, HomescreenVoice::connect_lists[0].c_str()) == 0) { + HMI_DEBUG("HomescreenVoice", "connect false!"); + connect = false; + emit showInformation(QString(QLatin1String(warnginfo))); + } + else if (strcasecmp(info, HomescreenVoice::connect_lists[1].c_str()) == 0){ + connect = true; + emit statusChanged(true); + } } - else if ((strcasecmp(info, HomescreenVoice::state_lists[1].c_str()) == 0)|| - (strcasecmp(info, HomescreenVoice::state_lists[2].c_str()) == 0)|| - (strcasecmp(info, HomescreenVoice::state_lists[3].c_str()) == 0)|| - (strcasecmp(info, HomescreenVoice::state_lists[4].c_str()) == 0)){ - emit statusChanged(false); - } - - emit showInformation(QString(QLatin1String(info))); } /** diff --git a/homescreen/src/homescreenvoice.h b/homescreen/src/homescreenvoice.h index 011280c..5b60a1e 100644 --- a/homescreen/src/homescreenvoice.h +++ b/homescreen/src/homescreenvoice.h @@ -38,6 +38,8 @@ public: explicit HomescreenVoice(QObject *parent = 0); ~HomescreenVoice(); static const std::vector<std::string> state_lists; + static const std::vector<std::string> connect_lists; + static const std::vector<std::string> event_lists; int init(int port, const string& token); void on_hangup(void *closure, struct afb_wsj1 *wsj); @@ -59,7 +61,7 @@ private: std::string muri; int mport = 2000; std::string mtoken = "hs"; - + bool connect = false; }; #endif // HOMESCREENVOICE_H |