HAND_NPC_EMOTION_CHANGE_NOTIFY, // npc表情变化通知
HAND_TIMELINE_STATUS_CHANGE_NOTIFY, // 时间线状态变化通知
HAND_UPGRADE_DESCRIPTION_NOTIFY, // 升级描述通知
+ HAND_STORY_RESPONSE_FINISHED_NOTIFY, // 故事响应finished通知
+ HAND_DIALOGUE_RESPONSE_FINISHED_NOTIFY, // 对话响应finished通知
MAX_NUM_HANDLER,
} UiServiceMsgId;
static void HandNpcEmotionChangeNotify(Request *request);
static void HandTimelineStatusChangeNotify(Request *request);
static void HandUpgradeDescriptionNotify(Request *request);
+static void HandStoryResponseFinishedNotify(Request *request);
+static void HandDialogueResponseFinishedNotify(Request *request);
// 消息处理程序项数组(每个消息类型对应一个处理函数,函数名以 Handle 开头)
MsgHandlerEntry msgHandlers[] = {
{HANDLE_JUMP_OTA_VIEW, HandleJumpOtaView},
{HAND_NPC_EMOTION_CHANGE_NOTIFY,HandNpcEmotionChangeNotify},
{HAND_TIMELINE_STATUS_CHANGE_NOTIFY,HandTimelineStatusChangeNotify},
{HAND_UPGRADE_DESCRIPTION_NOTIFY,HandUpgradeDescriptionNotify},
+ {HAND_STORY_RESPONSE_FINISHED_NOTIFY,HandStoryResponseFinishedNotify},
+ {HAND_DIALOGUE_RESPONSE_FINISHED_NOTIFY,HandDialogueResponseFinishedNotify},
};
/* -------------------------------------------------------------------------- */
void ScreenTurnOn(int32_t timeout)
GraphicService::GetInstance()->PostGraphicEvent(
std::bind(&OHOS::OtaModel::SetUpgradeDescription,OHOS::OtaModel::GetInstance(), description));
}
+
+void HandStoryResponseFinishedNotify(Request *request)
+{
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandStoryResponseFinishedNotify msg_id = %d", request->msgId);
+ if (request->data && request->len == sizeof(bool)) {
+ bool finished = *(static_cast<bool*>(request->data));
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandStoryResponseFinishedNotify finished = %d", finished);
+ GraphicService::GetInstance()->PostGraphicEvent(
+ std::bind(&OHOS::ThunderBirdModel::HandleStoryResponseFinished,
+ OHOS::ThunderBirdModel::GetInstance(), finished));
+ }
+}
+
+void HandDialogueResponseFinishedNotify(Request *request)
+{
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandDialogueResponseFinishedNotify msg_id = %d", request->msgId);
+ if (request->data && request->len == sizeof(bool)) {
+ bool finished = *(static_cast<bool*>(request->data));
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandDialogueResponseFinishedNotify finished = %d", finished);
+ GraphicService::GetInstance()->PostGraphicEvent(
+ std::bind(&OHOS::ThunderBirdModel::HandleDialogueResponseFinished,
+ OHOS::ThunderBirdModel::GetInstance(), finished));
+ }
+}
/* -------------------------------------------------------------------------- */
#ifdef __cplusplus
}
{
ln_parse_voice_chat_response(json_str, (int)strlen(json_str));
}
+ // 如果finished=true,通知ThunderBirdModel
+ if (data_msg && data_msg->finished) {
+ push_dialogue_response_finished_notification(true);
+ }
break;
}
case WS_CMD_CHOOSE_STORY_RESPONSE:
{
push_text_to_ui(data_msg->text_content);
- break;
+ // 如果finished=true,通知ThunderBirdModel
+ if (data_msg && data_msg->finished) {
+ push_story_response_finished_notification(true);
+ }
+ break;
}
case WS_CMD_RANDOM_STORY_RESPONSE:
{
push_text_to_ui(data_msg->text_content);
+ // 如果finished=true,通知ThunderBirdModel
+ if (data_msg && data_msg->finished) {
+ push_story_response_finished_notification(true);
+ }
break;
}
case WS_CMD_AUDIO_PLAYBACK_START:
cJSON *data_data = cJSON_GetObjectItem(data_obj, "data");
if (data_data && cJSON_IsObject(data_data)) {
// 解析storyTheme字段,存储到text_content中
- cJSON *story_theme = cJSON_GetObjectItem(data_data, "storyTheme");
- if (story_theme && cJSON_IsString(story_theme) && story_theme->valuestring) {
- strncpy(data_msg->text_content, story_theme->valuestring, sizeof(data_msg->text_content) - 1);
- data_msg->text_content[sizeof(data_msg->text_content) - 1] = '\0';
+ // cJSON *story_theme = cJSON_GetObjectItem(data_data, "storyTheme");
+ // if (story_theme && cJSON_IsString(story_theme) && story_theme->valuestring) {
+ // strncpy(data_msg->text_content, story_theme->valuestring, sizeof(data_msg->text_content) - 1);
+ // data_msg->text_content[sizeof(data_msg->text_content) - 1] = '\0';
+ // }
+ cJSON *story_content = cJSON_GetObjectItem(data_data, "storyContent");
+ if (story_content && cJSON_IsString(story_content) && story_content->valuestring) {
+ // 如果text_content为空,使用storyContent填充
+ if (strlen(data_msg->text_content) == 0) {
+ strncpy(data_msg->text_content, story_content->valuestring, sizeof(data_msg->text_content) - 1);
+ data_msg->text_content[sizeof(data_msg->text_content) - 1] = '\0';
+ }
}
// 解析storyAudioUrl字段,存储到audio_url中
//通知时间线状态变化
void push_timeline_status_change_notification(const char *description, const char *emotion)
{
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[TIMELINE_STATUS_CHANGE] description=%s, emotion=%s", description, emotion);
- char payload[512] = {0};
const char *d = description ? description : "";
const char *e = emotion ? emotion : "";
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[TIMELINE_STATUS_CHANGE] description=[%s], emotion=[%s]", d, e);
+ char payload[512] = {0};
(void)snprintf(payload, sizeof(payload) - 1, "%s|%s", d, e);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[TIMELINE_STATUS_CHANGE] payload=[%s], len=%d", payload, (int)strlen(payload));
SendMsgToUIService(HAND_TIMELINE_STATUS_CHANGE_NOTIFY, 0, (void *)payload, (int32_t)strlen(payload));
}
(void)snprintf(payload, sizeof(payload) - 1, "%s", d);
SendMsgToUIService(HAND_UPGRADE_DESCRIPTION_NOTIFY, 0, (void *)payload, (int32_t)strlen(payload));
}
+
+//通知故事响应finished
+void push_story_response_finished_notification(bool finished)
+{
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[STORY_RESPONSE_FINISHED] finished=%d", finished);
+ SendMsgToUIService(HAND_STORY_RESPONSE_FINISHED_NOTIFY, 0, &finished, sizeof(finished));
+}
+
+//通知对话响应finished
+void push_dialogue_response_finished_notification(bool finished)
+{
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[DIALOGUE_RESPONSE_FINISHED] finished=%d", finished);
+ SendMsgToUIService(HAND_DIALOGUE_RESPONSE_FINISHED_NOTIFY, 0, &finished, sizeof(finished));
+}
#ifdef __cplusplus
};
#endif
\ No newline at end of file
void push_timeline_status_change_notification(const char *description, const char *emotion);
//推送升级描述
void push_upgrade_description_notification(const char *description);
+//通知故事响应finished
+void push_story_response_finished_notification(bool finished);
+//通知对话响应finished
+void push_dialogue_response_finished_notification(bool finished);
#ifdef __cplusplus
}
#endif