From b4a01fc7783a1f5f58c56508b3d315c5316bec92 Mon Sep 17 00:00:00 2001 From: "stom.hwang" Date: Fri, 23 Sep 2016 17:43:47 +0900 Subject: [PATCH 01/16] Add API that gets the timestamp data from the sentence Change-Id: Ie89ca887c005df4295ef53a035e0f915f9fd98f6 Signed-off-by: stom.hwang --- common/vc_command.c | 916 ++++++++++++++++++++++++++++++++- common/vc_regex_rule.h | 57 ++ include/voice_control_command_expand.h | 21 + 3 files changed, 991 insertions(+), 3 deletions(-) mode change 100644 => 100755 common/vc_command.c create mode 100755 common/vc_regex_rule.h mode change 100644 => 100755 include/voice_control_command_expand.h diff --git a/common/vc_command.c b/common/vc_command.c old mode 100644 new mode 100755 index e728fb5..61053a9 --- a/common/vc_command.c +++ b/common/vc_command.c @@ -14,6 +14,8 @@ * limitations under the License. */ +#define _GNU_SOURCE + #include #include #include @@ -24,6 +26,8 @@ #include "vc_command.h" #include "vc_info_parser.h" #include "vc_main.h" +#include "vc_regex_rule.h" +#include "vc_config_mgr.h" #include "voice_control_command.h" #include "voice_control_command_expand.h" #include "voice_control_common.h" @@ -34,6 +38,17 @@ static int g_feature_enabled = -1; static int g_privilege_allowed = 1; /* Always True */ static cynara *p_cynara = NULL; +// For getting timestamp using regular expression +static regex_t reg[MAX_NUM_REGEX]; +static time_t t_now; //time_t is based on UTC +static struct tm *td_now; //if use localtime function, the value follows the local time zone, otherwise it follows the UTC. + +static int g_time_flag; +static int g_date_flag; + +static int g_data_sidx; +static int g_data_eidx; + static int __vc_cmd_get_feature_enabled() { if (0 == g_feature_enabled) { @@ -1341,7 +1356,7 @@ int vc_cmd_get_nlu_json(vc_cmd_h vc_cmd, char** json) } if (NULL == vc_cmd || NULL == json) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] NULL parameter"); + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] NULL parameter"); return VC_ERROR_INVALID_PARAMETER; } @@ -1349,14 +1364,909 @@ int vc_cmd_get_nlu_json(vc_cmd_h vc_cmd, char** json) cmd = (vc_cmd_s*)vc_cmd; if (VC_CMD_FORMAT_ACTION != cmd->format) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Action format"); + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Not Action format"); return VC_ERROR_INVALID_PARAMETER; } if (0 != vc_info_parser_get_nlu_result(json)) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get nlu result"); + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Fail to get nlu result"); return VC_ERROR_OPERATION_FAILED; } return 0; } + +static void __vc_cmd_regex_deinit(int num_regex) +{ + SLOG(LOG_DEBUG, TAG_VCCMD, "==== Start Deinitialize regex ===="); + int i; + + for (i = 0; i < num_regex; i++) { + regfree(®[i]); + } + + SLOG(LOG_DEBUG, TAG_VCCMD, "===="); + SLOG(LOG_DEBUG, TAG_VCCMD, ""); +} + +static int __vc_cmd_regex_init() +{ + SLOG(LOG_DEBUG, TAG_VCCMD, "==== Initialize regular expression ===="); + + int cflags = REG_EXTENDED | REG_ICASE; + int ret; + char errStr[128]; + char *lang = NULL; + int lang_type = 1; + + vc_config_mgr_get_default_language(&lang); + if (NULL == lang) { + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Fail to get current language"); + return VC_ERROR_OPERATION_FAILED; + } + + if (!strcmp("en_US", lang)) { + lang_type = 1; + } else if (!strcmp("ko_KR", lang)) { + lang_type = 0; + } else { + free(lang); + lang = NULL; + + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Not supported language type"); + return VC_ERROR_INVALID_LANGUAGE; + } + + free(lang); + lang = NULL; + + SLOG(LOG_DEBUG, TAG_VCCMD, "==== lang type > %d ====", lang_type); + + re_syntax_options = RE_SYNTAX_POSIX_EXTENDED; + + SLOG(LOG_DEBUG, TAG_VCCMD, "Regular expression > %s" , TIME_ABS1_REGEX[lang_type]); + ret = regcomp(®[0], TIME_ABS1_REGEX[lang_type], cflags); + if (0 != ret) { + regerror(ret, ®[0], errStr, sizeof(errStr)); + + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] regcomp() error > %s", errStr); + return VC_ERROR_OPERATION_FAILED; + } + + SLOG(LOG_DEBUG, TAG_VCCMD, "Regular expression > %s", TIME_ABS2_REGEX[lang_type]); + ret = regcomp(®[1], TIME_ABS2_REGEX[lang_type], cflags); + if (0 != ret) { + regerror(ret, ®[1], errStr, sizeof(errStr)); + __vc_cmd_regex_deinit(1); + + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] regcomp() error > %s", errStr); + return VC_ERROR_OPERATION_FAILED; + } + + SLOG(LOG_DEBUG, TAG_VCCMD, "Regular expression > %s", TIME_ABS3_REGEX[lang_type]); + ret = regcomp(®[2], TIME_ABS3_REGEX[lang_type], cflags); + if (0 != ret) { + regerror(ret, ®[2], errStr, sizeof(errStr)); + __vc_cmd_regex_deinit(2); + + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] regcomp() error > %s", errStr); + return VC_ERROR_OPERATION_FAILED; + } + + SLOG(LOG_DEBUG, TAG_VCCMD, "Regular expression > %s", TIME_REL1_REGEX[lang_type]); + ret = regcomp(®[3], TIME_REL1_REGEX[lang_type], cflags); + if (0 != ret) { + regerror(ret, ®[3], errStr, sizeof(errStr)); + __vc_cmd_regex_deinit(3); + + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] regcomp() error > %s", errStr); + return VC_ERROR_OPERATION_FAILED; + } + + SLOG(LOG_DEBUG, TAG_VCCMD, "Regular expression > %s", TIME_REL2_REGEX[lang_type]); + ret = regcomp(®[4], TIME_REL2_REGEX[lang_type], cflags); + if (0 != ret) { + regerror(ret, ®[4], errStr, sizeof(errStr)); + __vc_cmd_regex_deinit(4); + + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] regcomp() error > %s", errStr); + return VC_ERROR_OPERATION_FAILED; + } + + SLOG(LOG_DEBUG, TAG_VCCMD, "Regular expression > %s", TIME_REL3_REGEX[lang_type]); + ret = regcomp(®[5], TIME_REL3_REGEX[lang_type], cflags); + if (0 != ret) { + regerror(ret, ®[5], errStr, sizeof(errStr)); + __vc_cmd_regex_deinit(5); + + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] regcomp() error > %s", errStr); + return VC_ERROR_OPERATION_FAILED; + } + + SLOG(LOG_DEBUG, TAG_VCCMD, "Regular expression > %s", TIME_PHR_REGEX[lang_type]); + ret = regcomp(®[6], TIME_PHR_REGEX[lang_type], cflags); + if (0 != ret) { + regerror(ret, ®[6], errStr, sizeof(errStr)); + __vc_cmd_regex_deinit(6); + + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] regcomp() error > %s", errStr); + return VC_ERROR_OPERATION_FAILED; + } + + SLOG(LOG_DEBUG, TAG_VCCMD, "Regular expression > %s", DATE_ABS1_REGEX[lang_type]); + ret = regcomp(®[7], DATE_ABS1_REGEX[lang_type], cflags); + if (0 != ret) { + regerror(ret, ®[7], errStr, sizeof(errStr)); + __vc_cmd_regex_deinit(7); + + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] regcomp() error > %s", errStr); + return VC_ERROR_OPERATION_FAILED; + } + + SLOG(LOG_DEBUG, TAG_VCCMD, "Regular expression > %s", DATE_ABS2_REGEX[lang_type]); + ret = regcomp(®[8], DATE_ABS2_REGEX[lang_type], cflags); + if (0 != ret) { + regerror(ret, ®[8], errStr, sizeof(errStr)); + __vc_cmd_regex_deinit(8); + + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] regcomp() error > %s", errStr); + return VC_ERROR_OPERATION_FAILED; + } + + SLOG(LOG_DEBUG, TAG_VCCMD, "Regular expression > %s", DATE_ABS3_REGEX[lang_type]); + ret = regcomp(®[9], DATE_ABS3_REGEX[lang_type], cflags); + if (0 != ret) { + regerror(ret, ®[9], errStr, sizeof(errStr)); + __vc_cmd_regex_deinit(9); + + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] regcomp() error > %s", errStr); + return VC_ERROR_OPERATION_FAILED; + } + + SLOG(LOG_DEBUG, TAG_VCCMD, "Regular expression > %s", DATE_PHR1_REGEX[lang_type]); + ret = regcomp(®[10], DATE_PHR1_REGEX[lang_type], cflags); + if (0 != ret) { + regerror(ret, ®[10], errStr, sizeof(errStr)); + __vc_cmd_regex_deinit(10); + + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] regcomp() error > %s", errStr); + return VC_ERROR_OPERATION_FAILED; + } + + SLOG(LOG_DEBUG, TAG_VCCMD, "Regular expression > %s", DATE_PHR2_REGEX[lang_type]); + ret = regcomp(®[11], DATE_PHR2_REGEX[lang_type], cflags); + if (0 != ret) { + regerror(ret, ®[11], errStr, sizeof(errStr)); + __vc_cmd_regex_deinit(11); + + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] regcomp() error > %s", errStr); + return VC_ERROR_OPERATION_FAILED; + } + + SLOG(LOG_DEBUG, TAG_VCCMD, "===="); + SLOG(LOG_DEBUG, TAG_VCCMD, ""); + + return VC_ERROR_NONE; +} + +static void __vc_cmd_add_year(struct tm *td, int year) +{ + td->tm_year += year; +} + +static void __vc_cmd_add_mon(struct tm *td, int mon) +{ + int year = 0; + + mon = td->tm_mon + mon; + year = mon / 12; + + if (0 < year) { + __vc_cmd_add_year(td, year); + } + + td->tm_mon = mon % 12; +} + +static void __vc_cmd_add_mday(struct tm *td, int mday) +{ + int max_day[12] = {31, 28, 31, 30, 31, 30, 31, 30, 30, 31, 30, 31}; + int year = td->tm_year + 1900; + + int mon = 0; + + if ((0 == year % 4 && 0 != year % 100) || 0 == year % 400) max_day[1] = 29; + + mday = td->tm_mday + mday; + + for (mon = td->tm_mon; mday >= max_day[mon % 12]; mon++) { + mday -= max_day[mon % 12]; + + if (mon % 12 == 11) { + year++; + + if ((0 == year % 4 && 0 != year % 100) || 0 == year % 400) { + max_day[1] = 29; + } else { + max_day[1] = 28; + } + } + } + + mon = mon - td->tm_mon; + + if (0 < mon) { + __vc_cmd_add_mon(td, mon); + } + + td->tm_mday = mday; +} + +static void __vc_cmd_add_hour(struct tm *td, int hour) +{ + int day = 0; + + hour = td->tm_hour + hour; + day = hour / 24; + + if (0 < day) { + __vc_cmd_add_mday(td, day); + } + + td->tm_hour = hour % 24; +} + +static void __vc_cmd_add_min(struct tm *td, int min) +{ + int hour = 0; + + min = td->tm_min + min; + hour = min / 60; + + if (0 < hour) { + __vc_cmd_add_hour(td, hour); + } + + td->tm_min = min % 60; +} + +static void __copy_struct_tm(struct tm *des, struct tm *src) +{ + SLOG(LOG_DEBUG, TAG_VCCMD, "==== Start to copy struct tm ===="); + + des->tm_sec = src->tm_sec; + des->tm_min = src->tm_min; + des->tm_hour = src->tm_hour; + des->tm_mday = src->tm_mday; + des->tm_mon = src->tm_mon; + des->tm_year = src->tm_year; + des->tm_wday = src->tm_wday; + des->tm_yday = src->tm_yday; + des->tm_isdst = src->tm_isdst; + + des->tm_gmtoff = src->tm_gmtoff; + des->tm_zone = src->tm_zone; +} + +static void __update_data_sidx(int idx) +{ + if (g_data_sidx < 0 || g_data_sidx > idx) g_data_sidx = idx; +} + +static void __update_data_eidx(int idx) +{ + if (g_data_eidx < 0 || g_data_eidx < idx) g_data_eidx = idx; +} + +static int __vc_cmd_tphrase_check(const char *str, struct tm *td, int *exist) +{ + regmatch_t pmatch[3]; + int ret; + int len; + int idx; + + *exist = 0; + ret = regexec(®[6], str, 3, pmatch, 0); + if (0 == ret) { + idx = 1; + len = pmatch[idx].rm_eo - pmatch[idx].rm_so; + if (0 < len) { + if (12 < td->tm_hour) { + __vc_cmd_add_mday(td, 1); + } + + td->tm_hour = 12; + } else { + idx = 2; + len = pmatch[idx].rm_eo - pmatch[idx].rm_so; + + __vc_cmd_add_mday(td, 1); + } + + td->tm_min = 0; + td->tm_sec = 0; + SLOG(LOG_DEBUG, TAG_VCCMD, "Matched string > %.*s", len, str + pmatch[idx].rm_so); + + __update_data_sidx(pmatch[0].rm_so); + __update_data_eidx(pmatch[0].rm_eo); + + *exist = 1; + return VC_ERROR_NONE; + } + + SLOG(LOG_DEBUG, TAG_VCCMD, "[REGEX] There is no matched string"); + return VC_ERROR_NONE; +} + +static int __vc_cmd_trelative_check(const char *str, struct tm *td, int *exist) +{ + regmatch_t pmatch[2]; + int ret; + int len; + int sidx = -1; + int eidx = -1; + int hour = -1; + int min = -1; + + char *tempstr = NULL; + + *exist = 0; + ret = regexec(®[3], str, 1, pmatch, 0); + if (0 == ret) { + SLOG(LOG_DEBUG, TAG_VCCMD, "Matched string > %.*s", pmatch[0].rm_eo - pmatch[0].rm_so, str+pmatch[0].rm_so); + hour = min = -1; + + if (sidx < 0 || sidx > pmatch[0].rm_so) sidx = pmatch[0].rm_so; + if (eidx < 0 || eidx < pmatch[0].rm_eo) eidx = pmatch[0].rm_eo; + + ret = regexec(®[4], str, 2, pmatch, 0); + if (0 == ret) { + len = pmatch[1].rm_eo - pmatch[1].rm_so; + tempstr = strndup(str + pmatch[1].rm_so, len); + + if (NULL == tempstr) { + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Memory allocation is failed"); + return VC_ERROR_OUT_OF_MEMORY; + } + + hour = atoi(tempstr); + + free(tempstr); + tempstr = NULL; + + SLOG(LOG_DEBUG, TAG_VCCMD, "Matched string > %.*s", len, str + pmatch[1].rm_so); + + if (sidx < 0 || sidx > pmatch[0].rm_so) sidx = pmatch[0].rm_so; + if (eidx < 0 || eidx < pmatch[0].rm_eo) eidx = pmatch[0].rm_eo; + } + + ret = regexec(®[5], str, 2, pmatch, 0); + if (0 == ret) { + len = pmatch[1].rm_eo - pmatch[1].rm_so; + tempstr = strndup(str + pmatch[1].rm_so, len); + + if (NULL == tempstr) { + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Memory allocation is failed"); + return VC_ERROR_OUT_OF_MEMORY; + } + + min = atoi(tempstr); + + free(tempstr); + tempstr = NULL; + + SLOG(LOG_DEBUG, TAG_VCCMD, "Matched string > %.*s", len, str + pmatch[1].rm_so); + + if (sidx < 0 || sidx > pmatch[0].rm_so) sidx = pmatch[0].rm_so; + if (eidx < 0 || eidx < pmatch[0].rm_eo) eidx = pmatch[0].rm_eo; + } + + if (hour < 0 && min < 0) { + SLOG(LOG_DEBUG, TAG_VCCMD, "[REGEX] There is no matched string"); + return VC_ERROR_NONE; + } + + hour = hour < 0 ? 0 : hour; + min = min < 0 ? 0 : min; + + min = min + (hour * 60); + + __vc_cmd_add_min(td, min); + td->tm_sec = 0; + + __update_data_sidx(sidx); + __update_data_eidx(eidx); + + *exist = 1; + return VC_ERROR_NONE; + } + + SLOG(LOG_DEBUG, TAG_VCCMD, "[REGEX] There is no matched string"); + return VC_ERROR_NONE; +} + +static int __vc_cmd_tabsolute_check(const char *str, struct tm *td, int *exist) +{ + regmatch_t pmatch[5]; + int ret; + int len; + int idx; + int flag = -1; + int hour = -1; + int min = -1; + int sidx = -1; + int eidx = -1; + char *tempstr = NULL; + + *exist = 0; + ret = regexec(®[0], str, 5, pmatch, 0); + if (0 == ret) { + for (idx = 1; idx < 5 && 0 >= pmatch[idx].rm_eo - pmatch[idx].rm_so; idx++); + + flag = idx & 1; + + if (sidx < 0 || sidx > pmatch[0].rm_so) sidx = pmatch[0].rm_so; + if (eidx < 0 || eidx < pmatch[0].rm_eo) eidx = pmatch[0].rm_eo; + } + + ret = regexec(®[1], str, 2, pmatch, 0); + if (0 == ret) { + len = pmatch[1].rm_eo - pmatch[1].rm_so; + tempstr = strndup(str + pmatch[1].rm_so, len); + + if (NULL == tempstr) { + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Memory allocation is failed"); + return VC_ERROR_OUT_OF_MEMORY; + } + + hour = atoi(tempstr); + + if (0 <= flag) { + hour = hour + 12 * flag; + + if (12 == hour) hour = 0; + else if(24 == hour) hour = 12; + } + + if (0 > hour || 24 <= hour || (0 == flag && 12 < hour)) { + SLOG(LOG_DEBUG, TAG_VCCMD, "[REGEX] Incomming sentence is weird"); + return VC_ERROR_NONE; + } + + free(tempstr); + tempstr = NULL; + + SLOG(LOG_DEBUG, TAG_VCCMD, "Matched string > %.*s", len, str + pmatch[1].rm_so); + + if (sidx < 0 || sidx > pmatch[0].rm_so) sidx = pmatch[0].rm_so; + if (eidx < 0 || eidx < pmatch[0].rm_eo) eidx = pmatch[0].rm_eo; + } else if (0 < flag) { + SLOG(LOG_DEBUG, TAG_VCCMD, "[REGEX] Incomming sentence is weird"); + return VC_ERROR_NONE; + } + + ret = regexec(®[2], str, 2, pmatch, 0); + if (0 == ret) { + idx = 1; + len = pmatch[idx].rm_eo - pmatch[idx].rm_so; + if (0 < len) { + tempstr = strndup(str + pmatch[idx].rm_so, len); + + if (NULL == tempstr) { + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Memory allocation is failed"); + return VC_ERROR_OUT_OF_MEMORY; + } + + min = atoi(tempstr); + + if (0 > min || 60 <= min) { + SLOG(LOG_DEBUG, TAG_VCCMD, "[REGEX] Incomming sentence is weird"); + return VC_ERROR_NONE; + } + + td->tm_sec = 0; + + free(tempstr); + tempstr = NULL; + } else { + idx = 0; + min = 30; + } + + SLOG(LOG_DEBUG, TAG_VCCMD, "Matched string > %.*s", pmatch[idx].rm_eo - pmatch[idx].rm_so, str + pmatch[idx].rm_so); + if (sidx < 0 || sidx > pmatch[0].rm_so) sidx = pmatch[0].rm_so; + if (eidx < 0 || eidx < pmatch[0].rm_eo) eidx = pmatch[0].rm_eo; + } + + if (hour < 0 && min < 0) { + SLOG(LOG_DEBUG, TAG_VCCMD, "[REGEX] There is no matched string"); + return VC_ERROR_NONE; + } + + if (min >= 0 && hour >= 0) { + if (hour < td->tm_hour || (hour == td->tm_hour && min <= td->tm_min)) __vc_cmd_add_mday(td, 1); + + td->tm_hour = hour; + td->tm_min = min; + } else if (min >= 0) { + char *lang = NULL; + vc_config_mgr_get_default_language(&lang); + if (NULL == lang) { + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Fail to get current language"); + return VC_ERROR_OPERATION_FAILED; + } + + if (!strcmp("en_US", lang)) { + SLOG(LOG_DEBUG, TAG_VCCMD, "[REGEX] Incomming sentence is weird"); + free(lang); + lang = NULL; + return VC_ERROR_NONE; + } + if (min <= td->tm_min) __vc_cmd_add_hour(td, 1); + + td->tm_min = min; + + free(lang); + lang = NULL; + } else { + if (hour <= td->tm_hour) __vc_cmd_add_mday(td, 1); + + td->tm_hour = hour; + td->tm_min = 0; + } + + td->tm_sec = 0; + + __update_data_sidx(sidx); + __update_data_eidx(eidx); + + *exist = 1; + return VC_ERROR_NONE; +} + +static int __vc_cmd_dphrase_check(const char *str, struct tm *td, int *exist) +{ + regmatch_t pmatch[9]; + int ret; + int len; + int idx; + + *exist = 0; + ret = regexec(®[10], str, 5, pmatch, 0); + if (0 == ret) { + for (idx = 1; idx < 5 && 0 >= pmatch[idx].rm_eo - pmatch[idx].rm_so; idx++); + + len = pmatch[idx].rm_eo - pmatch[idx].rm_so; + + td->tm_year = td_now->tm_year; + td->tm_mon = td_now->tm_mon; + td->tm_mday = td_now->tm_mday; + + __vc_cmd_add_mday(td, idx - 1); + + SLOG(LOG_DEBUG, TAG_VCCMD, "Matched string > %.*s", len, str + pmatch[idx].rm_so); + + __update_data_sidx(pmatch[0].rm_so); + __update_data_eidx(pmatch[0].rm_eo); + + *exist = 1; + return VC_ERROR_NONE; + } + + ret = regexec(®[11], str, 9, pmatch, 0); + if (0 == ret) { + for (idx = 1; idx < 9; idx++) { + len = pmatch[idx].rm_eo - pmatch[idx].rm_so; + + if (0 < len) break; + } + + td->tm_year = td_now->tm_year; + td->tm_mon = td_now->tm_mon; + td->tm_mday = td_now->tm_mday; + + __vc_cmd_add_mday(td, idx + 1); + + SLOG(LOG_DEBUG, TAG_VCCMD, "Matched string > %.*s", len, str + pmatch[idx].rm_so); + + __update_data_sidx(pmatch[0].rm_so); + __update_data_eidx(pmatch[0].rm_eo); + + *exist = 1; + return VC_ERROR_NONE; + } + + SLOG(LOG_DEBUG, TAG_VCCMD, "[REGEX] There is no matched string"); + return VC_ERROR_NONE; +} + +static int __vc_cmd_dabsolute_check(const char *str, struct tm *td, int *exist) +{ + regmatch_t pmatch[13]; + int ret; + int len; + int idx; + int sidx = -1; + int eidx = -1; + int y_flag = 0; + int m_flag = 0; + int year = -1; + int mon = -1; + int day = -1; + char *tempstr = NULL; + + *exist = 0; + ret = regexec(®[9], str, 2, pmatch, 0); + if (0 == ret) { + len = pmatch[1].rm_eo - pmatch[1].rm_so; + tempstr = strndup(str + pmatch[1].rm_so, len); + + if (NULL == tempstr) { + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Memory allocation is failed"); + return VC_ERROR_OUT_OF_MEMORY; + } + + day = atoi(tempstr); + + free(tempstr); + tempstr = NULL; + + SLOG(LOG_DEBUG, TAG_VCCMD, "Matched string > %.*s", len, str + pmatch[1].rm_so); + + if (sidx < 0 || sidx > pmatch[0].rm_so) sidx = pmatch[0].rm_so; + if (eidx < 0 || eidx < pmatch[0].rm_eo) eidx = pmatch[0].rm_eo; + } else { + SLOG(LOG_DEBUG, TAG_VCCMD, "[REGEX] Incomming sentence is weird"); + return VC_ERROR_NONE; + } + + ret = regexec(®[8], str, 13, pmatch, 0); + if (0 == ret) { + for (idx = 1; idx < 13; idx++) { + len = pmatch[idx].rm_eo - pmatch[idx].rm_so; + + if (0 < len) { + mon = idx - 1; + break; + } + } + + m_flag = 1; + + SLOG(LOG_DEBUG, TAG_VCCMD, "Matched string > %.*s", len, str + pmatch[idx].rm_so); + + if (sidx < 0 || sidx > pmatch[0].rm_so) sidx = pmatch[0].rm_so; + if (eidx < 0 || eidx < pmatch[0].rm_eo) eidx = pmatch[0].rm_eo; + } else { + char *lang = NULL; + vc_config_mgr_get_default_language(&lang); + if (NULL == lang) { + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Fail to get current language"); + return VC_ERROR_OPERATION_FAILED; + } + + if (!strcmp("en_US", lang)) { + SLOG(LOG_DEBUG, TAG_VCCMD, "[REGEX] Incomming sentence is weird"); + free(lang); + lang = NULL; + return VC_ERROR_NONE; + } + + free(lang); + lang = NULL; + + mon = td->tm_mon; + } + + ret = regexec(®[7], str, 3, pmatch, 0); + if (0 == ret) { + if (!m_flag) return -1; + + len = pmatch[2].rm_eo - pmatch[2].rm_so; + tempstr = strndup(str + pmatch[2].rm_so, len); + + if (NULL == tempstr) { + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Memory allocation is failed"); + return VC_ERROR_OUT_OF_MEMORY; + } + + year = atoi(tempstr); + year = year > 1900 ? year - 1900 : year + 100; + + free(tempstr); + tempstr = NULL; + + y_flag = 1; + SLOG(LOG_DEBUG, TAG_VCCMD, "Matched string > %.*s", len, str + pmatch[2].rm_so); + + if (sidx < 0 || sidx > pmatch[0].rm_so) sidx = pmatch[0].rm_so; + if (eidx < 0 || eidx < pmatch[0].rm_eo) eidx = pmatch[0].rm_eo; + } else { + year = td->tm_year; + } + + if (g_time_flag < 0) { + td->tm_hour = 0; + td->tm_min = 0; + td->tm_sec = 0; + } else if (g_time_flag == 2) { + SLOG(LOG_DEBUG, TAG_VCCMD, "[REGEX] Incomming sentence is weird"); + return VC_ERROR_NONE; + } + + int max_day[12] = {31, 28, 31, 30, 31, 30, 31, 30, 30, 31, 30, 31}; + if ((0 == (year + 1900) % 4 && 0 != (year + 1900) % 100) || 0 == (year + 1900) % 400) max_day[1] = 29; + + if (max_day[mon] < day || 1 > day) { + SLOG(LOG_DEBUG, TAG_VCCMD, "[REGEX] Incomming sentence is weird"); + return VC_ERROR_NONE; + } + + td->tm_year = year; + td->tm_mon = mon; + td->tm_mday = day; + + if (!y_flag) { + if (!m_flag) { + if (day < td_now->tm_mday) __vc_cmd_add_mon(td, 1); + } else { + if (mon < td_now->tm_mon) __vc_cmd_add_year(td, 1); + else if (mon == td_now->tm_mon && day < td_now->tm_mday) __vc_cmd_add_year(td, 1); + } + } + + __update_data_sidx(sidx); + __update_data_eidx(eidx); + + *exist = 1; + return VC_ERROR_NONE; +} + +static int __vc_cmd_time_check(const char *str, struct tm *td) +{ + SLOG(LOG_DEBUG, TAG_VCCMD, "==== Check time value in string \"%s\"", str); + + vc_error_e ret; + int exist = 0; + + ret = __vc_cmd_tphrase_check(str, td, &exist); + if (1 == exist) { + g_time_flag = 1; + + SLOG(LOG_DEBUG, TAG_VCCMD, "==== Time value is exist"); + return ret; + } else if (VC_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Error is occured > (%d)", ret); + return ret; + } + + ret = __vc_cmd_trelative_check(str, td, &exist); + if (1 == exist) { + g_time_flag = 2; + + SLOG(LOG_DEBUG, TAG_VCCMD, "==== Time value is exist"); + return ret; + } else if (VC_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Error is occured > (%d)", ret); + return ret; + } + + ret = __vc_cmd_tabsolute_check(str, td, &exist); + if (1 == exist) { + g_time_flag = 3; + + SLOG(LOG_DEBUG, TAG_VCCMD, "==== Time value is exist"); + return ret; + } else if (VC_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Error is occured > (%d)", ret); + return ret; + } + + SLOG(LOG_DEBUG, TAG_VCCMD, "==== There is no time value"); + return VC_ERROR_NONE; +} + +static int __vc_cmd_date_check(const char *str, struct tm *td) +{ + SLOG(LOG_DEBUG, TAG_VCCMD, "==== Check date value in string \"%s\"", str); + + vc_error_e ret; + int exist = 0; + + ret = __vc_cmd_dphrase_check(str, td, &exist); + if (1 == exist) { + g_date_flag = 1; + + SLOG(LOG_DEBUG, TAG_VCCMD, "==== Date value is exist"); + return ret; + } else if (VC_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Error is occured > (%d)", ret); + return ret; + } + + ret = __vc_cmd_dabsolute_check(str, td, &exist); + if (1 == exist) { + g_date_flag = 1; + + SLOG(LOG_DEBUG, TAG_VCCMD, "==== Date value is exist"); + return ret; + } else if (VC_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Error is occured > (%d)", ret); + return ret; + } + + SLOG(LOG_DEBUG, TAG_VCCMD, "==== There is no date value"); + return VC_ERROR_NONE; +} + +int vc_cmd_get_datetime(const char *text, time_t *result, char **remain) +{ + SLOG(LOG_DEBUG, TAG_VCCMD, "==== Get timestamp data"); + + struct tm td; + const char *day_name[7] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; + vc_error_e ret; + + *result = -1; + if (NULL == text || NULL == result || NULL == remain) { + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter"); + return VC_ERROR_INVALID_PARAMETER; + } + + ret = __vc_cmd_regex_init(); + if (VC_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] initialize regex failed"); + return ret; + } + + g_data_sidx = g_data_eidx = -1; + + t_now = time(NULL); + td_now = localtime(&t_now); + SLOG(LOG_DEBUG, TAG_VCCMD, "Current timestamp = %d", (int)t_now); + + __copy_struct_tm(&td, td_now); + SLOG(LOG_DEBUG, TAG_VCCMD, "%d-%d-%d (%s), %d:%d:%d", + td.tm_year + 1900, td.tm_mon + 1, td.tm_mday, day_name[td.tm_wday], td.tm_hour, td.tm_min, td.tm_sec); + + g_time_flag = g_date_flag = -1; + + ret = __vc_cmd_time_check(text, &td); + if (VC_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Error is occured in the check > (%d)", ret); + return ret; + } + + ret = __vc_cmd_date_check(text, &td); + if (VC_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Error is occured in the check > (%d)", ret); + return ret; + } + + __vc_cmd_regex_deinit(12); + + if (g_time_flag > 0 || g_date_flag > 0) { + *result = mktime(&td); + + SLOG(LOG_DEBUG, TAG_VCCMD, "Timestamp in the text = %d", *result); + SLOG(LOG_DEBUG, TAG_VCCMD, "%d-%d-%d (%s), %d:%d:%d", + td.tm_year + 1900, td.tm_mon + 1, td.tm_mday, day_name[td.tm_wday], td.tm_hour, td.tm_min, td.tm_sec, td.tm_yday); + + *remain = (char *)calloc(sizeof(char), (strlen(text) + 1 - g_data_eidx + g_data_sidx)); + + if (NULL == *remain) { + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Out of memory error"); + return VC_ERROR_OUT_OF_MEMORY; + } + + strncpy(*remain, text, g_data_sidx); + strncat(*remain, text + g_data_eidx, strlen(text) - g_data_eidx); + } else { + SLOG(LOG_DEBUG, TAG_VCCMD, "[REGEX] There is no data in the text"); + } + + SLOG(LOG_DEBUG, TAG_VCCMD, "===="); + SLOG(LOG_DEBUG, TAG_VCCMD, ""); + + return VC_ERROR_NONE; +} \ No newline at end of file diff --git a/common/vc_regex_rule.h b/common/vc_regex_rule.h new file mode 100755 index 0000000..973cbe4 --- /dev/null +++ b/common/vc_regex_rule.h @@ -0,0 +1,57 @@ +#ifndef __VC_REGEX_RULE_H +#define __VC_REGEX_RULE_H + +#define MAX_NUM_REGEX 12 + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +//at noon / at midnight +const char *TIME_PHR_REGEX[2] = {"(정오)|(자정)", + "( at noon)|( at midnight)"}; +//morning / afternoon +const char *TIME_ABS1_REGEX[2] = {"(오후)|(오전)|(저녁)|(아침)", + "([0-9] p.?m.?)|([0-9] a.?m.?)|( afternoon)|( morning)"}; +//hh:mm / :mm / hh o'clock / pm / am +const char *TIME_ABS2_REGEX[2] = {"([1-9]|1[0-9]|2[0-4])시", + " at ([1-9]|1[0-9]|2[0-4])( o'clock|:| pm| p.m.| am| a.m.|$)"}; +const char *TIME_ABS3_REGEX[2] = {"([1-9]|[1-5][0-9])분|반", + ":([0-5][0-9])"}; +//hh hour(s) mm minute(s) (after / later) / hh hour(s) (after / later) / mm minute(s) (after / later) +const char *TIME_REL1_REGEX[2] = {"(시간|분).*[^오](뒤|후|있다가)", + " after([^a-zA-Z]|$)| later([^a-zA-Z]|$)| in [0-9]+ (minute|hour)"}; +const char *TIME_REL2_REGEX[2] = {"([1-9][0-9]*)시간", + "([1-9][0-9]*) hours?"}; +const char *TIME_REL3_REGEX[2] = {"([1-9][0-9]*)분", + "([1-9][0-9]*) minutes?"}; + +//day month, year / day month / day +const char *DATE_ABS1_REGEX[2] = {"(([1-2][0-9]{3})년)", + "(st|nd|rd|th),? ([1-2][0-9]{3})"}; +const char *DATE_ABS2_REGEX[2] = {"(1월)|(2월)|(3월)|(4월)|(5월)|(6월)|(7월)|(8월)|(9월)|(10월)|(11월)|(12월)", + "(January)|(February)|(March)|(April)|(May)|(June)|(July)|(August)|(September)|(October)|(November)|(December)"}; +const char *DATE_ABS3_REGEX[2] = {"([1-9]|[1-2][0-9]|3[0-1])일", + "([1-9]|[1-2][0-9]|3[0-1])(st|nd|rd|th)"}; +//today / tommorow / the day after tommorow +const char *DATE_PHR1_REGEX[2] = {"(오늘)|(내일)|(모레)|(글피)", + "(today)|(tommorow)|(the day after tommorow)"}; +const char *DATE_PHR2_REGEX[2] = {"(이틀)|(사흘)|(나흘)|(닷새)|(엿새)|(이레)|(여드레)|(아흐레)|(열흘)", + "(이틀)|(사흘)|(나흘)|(닷새)|(엿새)|(이레)|(여드레)|(아흐레)|(열흘)"}; + +//Monday / Tuesday / Wednesday / Thursday / Satruday / Sunday +const char *DATE_PHR3_REGEX[2] = {"(월|화|수|목|금|토|일)(요일)?", + "(Mon|Tues|Wednes|Thurs|Fri|Satur|Sun)(day)?"}; + + +#ifdef __cplusplus +} +#endif + + +#endif \ No newline at end of file diff --git a/include/voice_control_command_expand.h b/include/voice_control_command_expand.h old mode 100644 new mode 100755 index 8bd196c..695641f --- a/include/voice_control_command_expand.h +++ b/include/voice_control_command_expand.h @@ -198,6 +198,27 @@ int vc_cmd_set_unfixed_command(vc_cmd_h vc_command, const char* command); */ int vc_cmd_get_nlu_json(vc_cmd_h vc_cmd, char** json); +/** +* @brief Gets the datetime value from the setence. +* @since_tizen 3.0 +* +* @param[in] text The sentence to analyze +* @param[out] result The datetime value in the sentence +* @param[out] remain Remained text except time +* +* @remark If the function succeeds, @a remain must be released with free() by you when you no longer need it. +* If there is no time value in @a text or the function does not work correctly, +* @a result is -1. Otherwise @a result has the time value in @a text. +* +* @return 0 on success, otherwise a negative error value +* @retval #VC_CMD_ERROR_NONE Successful +* @retval #VC_ERROR_OPERATION_FAILED operation failure +* @retval #VC_ERROR_OUT_OF_MEMORY Not enough memory +* @retval #VC_CMD_ERROR_INVALID_PARAMETER Invalid parameter +* +* @see vc_cmd_set_datetime_lang() +*/ +int vc_cmd_get_datetime(const char *text, time_t *result, char **remain); #ifdef __cplusplus } -- 2.7.4 From f29a13694361eeedb03814ec4a6023dfb4de99a0 Mon Sep 17 00:00:00 2001 From: "stom.hwang" Date: Wed, 28 Sep 2016 10:11:25 +0900 Subject: [PATCH 02/16] Fix svace issue Change-Id: I2ffefe51b038297695eb547e4e70a9e4e1a79b7b Signed-off-by: stom.hwang --- common/vc_cmd_db.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) mode change 100644 => 100755 common/vc_cmd_db.c diff --git a/common/vc_cmd_db.c b/common/vc_cmd_db.c old mode 100644 new mode 100755 index 0168129..240928a --- a/common/vc_cmd_db.c +++ b/common/vc_cmd_db.c @@ -1249,12 +1249,13 @@ static int __vc_db_generate_command(vc_cmd_s* cmd, char** fixed_cmd, GSList** cm temp_close[0] = '\0'; // extract fixed command and remove space in front of '{' - temp = strtok(src_cmd, "{"); + char *tok_ptr = NULL; + temp = strtok_r(src_cmd, "{", &tok_ptr); __vc_db_remove_space(&temp); *fixed_cmd = strdup(temp); // merge command with fixed and vfixed - while (NULL != (temp = strtok(NULL, "|"))) { + while (NULL != (temp = strtok_r(NULL, "|", &tok_ptr))) { __vc_db_remove_space(&temp); snprintf(merge_cmd, 256, "%s %s", *fixed_cmd, temp); @@ -1277,12 +1278,14 @@ static int __vc_db_generate_command(vc_cmd_s* cmd, char** fixed_cmd, GSList** cm *fixed_cmd = strdup(temp_fixed); // remove close brace, '}' - temp = strtok(src_cmd, "}"); + char *tok_ptr = NULL; + temp = strtok_r(src_cmd, "}", &tok_ptr); // remove open brace, '{' temp = strchr(src_cmd, '{') + 1; - temp = strtok(temp, "|"); + tok_ptr = NULL; + temp = strtok_r(temp, "|", &tok_ptr); __vc_db_remove_space(&temp); // merge command with fixed and vfixed @@ -1291,7 +1294,7 @@ static int __vc_db_generate_command(vc_cmd_s* cmd, char** fixed_cmd, GSList** cm temp_list = g_slist_append(temp_list, dst_cmd); SLOG(LOG_ERROR, vc_db_tag(), "New generated cmd: %s", dst_cmd); - while (NULL != (temp = strtok(NULL, "|"))) { + while (NULL != (temp = strtok_r(NULL, "|", &tok_ptr))) { __vc_db_remove_space(&temp); // merge command with fixed and vfixed @@ -1299,7 +1302,7 @@ static int __vc_db_generate_command(vc_cmd_s* cmd, char** fixed_cmd, GSList** cm dst_cmd = strdup(merge_cmd); temp_list = g_slist_append(temp_list, dst_cmd); SLOG(LOG_ERROR, vc_db_tag(), "New generated cmd: %s", dst_cmd); - } + } } else if (VC_CMD_FORMAT_FIXED_AND_NONFIXED == cmd->format || VC_CMD_FORMAT_NONFIXED_AND_FIXED == cmd->format) { dst_cmd = strdup(src_cmd); temp_list = g_slist_append(temp_list, dst_cmd); -- 2.7.4 From 2fa3aefcbaf8bb49a433f2b8b840aed4c430b2a8 Mon Sep 17 00:00:00 2001 From: "stom.hwang" Date: Thu, 29 Sep 2016 13:30:13 +0900 Subject: [PATCH 03/16] Fix svace issue & typo Change-Id: I6627dd2bd5dbbfefba55a4eb6656097e995a5560 Signed-off-by: stom.hwang --- common/vc_command.c | 124 ++++++++++++++++++++++++------------------------ common/vc_json_parser.c | 9 ++-- 2 files changed, 67 insertions(+), 66 deletions(-) mode change 100644 => 100755 common/vc_json_parser.c diff --git a/common/vc_command.c b/common/vc_command.c index 61053a9..3252b90 100755 --- a/common/vc_command.c +++ b/common/vc_command.c @@ -41,7 +41,7 @@ static cynara *p_cynara = NULL; // For getting timestamp using regular expression static regex_t reg[MAX_NUM_REGEX]; static time_t t_now; //time_t is based on UTC -static struct tm *td_now; //if use localtime function, the value follows the local time zone, otherwise it follows the UTC. +static struct tm td_now; //if use localtime function, the value follows the local time zone, otherwise it follows the UTC. static int g_time_flag; static int g_date_flag; @@ -1381,7 +1381,7 @@ static void __vc_cmd_regex_deinit(int num_regex) SLOG(LOG_DEBUG, TAG_VCCMD, "==== Start Deinitialize regex ===="); int i; - for (i = 0; i < num_regex; i++) { + for (i = 0; num_regex > i; i++) { regfree(®[i]); } @@ -1582,7 +1582,7 @@ static void __vc_cmd_add_mday(struct tm *td, int mday) for (mon = td->tm_mon; mday >= max_day[mon % 12]; mon++) { mday -= max_day[mon % 12]; - if (mon % 12 == 11) { + if (11 == mon % 12) { year++; if ((0 == year % 4 && 0 != year % 100) || 0 == year % 400) { @@ -1650,12 +1650,12 @@ static void __copy_struct_tm(struct tm *des, struct tm *src) static void __update_data_sidx(int idx) { - if (g_data_sidx < 0 || g_data_sidx > idx) g_data_sidx = idx; + if (0 > g_data_sidx || idx < g_data_sidx) g_data_sidx = idx; } static void __update_data_eidx(int idx) { - if (g_data_eidx < 0 || g_data_eidx < idx) g_data_eidx = idx; + if (0 > g_data_eidx || idx > g_data_eidx) g_data_eidx = idx; } static int __vc_cmd_tphrase_check(const char *str, struct tm *td, int *exist) @@ -1685,7 +1685,7 @@ static int __vc_cmd_tphrase_check(const char *str, struct tm *td, int *exist) td->tm_min = 0; td->tm_sec = 0; - SLOG(LOG_DEBUG, TAG_VCCMD, "Matched string > %.*s", len, str + pmatch[idx].rm_so); + SLOG(LOG_DEBUG, TAG_VCCMD, "Matched string > %.*s", len, str + pmatch[0].rm_so); __update_data_sidx(pmatch[0].rm_so); __update_data_eidx(pmatch[0].rm_eo); @@ -1716,8 +1716,8 @@ static int __vc_cmd_trelative_check(const char *str, struct tm *td, int *exist) SLOG(LOG_DEBUG, TAG_VCCMD, "Matched string > %.*s", pmatch[0].rm_eo - pmatch[0].rm_so, str+pmatch[0].rm_so); hour = min = -1; - if (sidx < 0 || sidx > pmatch[0].rm_so) sidx = pmatch[0].rm_so; - if (eidx < 0 || eidx < pmatch[0].rm_eo) eidx = pmatch[0].rm_eo; + sidx = pmatch[0].rm_so; + eidx = pmatch[0].rm_eo; ret = regexec(®[4], str, 2, pmatch, 0); if (0 == ret) { @@ -1734,10 +1734,10 @@ static int __vc_cmd_trelative_check(const char *str, struct tm *td, int *exist) free(tempstr); tempstr = NULL; - SLOG(LOG_DEBUG, TAG_VCCMD, "Matched string > %.*s", len, str + pmatch[1].rm_so); + SLOG(LOG_DEBUG, TAG_VCCMD, "Matched string > %.*s", len, str + pmatch[0].rm_so); - if (sidx < 0 || sidx > pmatch[0].rm_so) sidx = pmatch[0].rm_so; - if (eidx < 0 || eidx < pmatch[0].rm_eo) eidx = pmatch[0].rm_eo; + if (pmatch[0].rm_so < sidx) sidx = pmatch[0].rm_so; + if (pmatch[0].rm_eo > eidx) eidx = pmatch[0].rm_eo; } ret = regexec(®[5], str, 2, pmatch, 0); @@ -1755,10 +1755,10 @@ static int __vc_cmd_trelative_check(const char *str, struct tm *td, int *exist) free(tempstr); tempstr = NULL; - SLOG(LOG_DEBUG, TAG_VCCMD, "Matched string > %.*s", len, str + pmatch[1].rm_so); + SLOG(LOG_DEBUG, TAG_VCCMD, "Matched string > %.*s", len, str + pmatch[0].rm_so); - if (sidx < 0 || sidx > pmatch[0].rm_so) sidx = pmatch[0].rm_so; - if (eidx < 0 || eidx < pmatch[0].rm_eo) eidx = pmatch[0].rm_eo; + if (pmatch[0].rm_so < sidx) sidx = pmatch[0].rm_so; + if (pmatch[0].rm_eo > eidx) eidx = pmatch[0].rm_eo; } if (hour < 0 && min < 0) { @@ -1766,8 +1766,8 @@ static int __vc_cmd_trelative_check(const char *str, struct tm *td, int *exist) return VC_ERROR_NONE; } - hour = hour < 0 ? 0 : hour; - min = min < 0 ? 0 : min; + hour = 0 > hour ? 0 : hour; + min = 0 > min ? 0 : min; min = min + (hour * 60); @@ -1801,12 +1801,12 @@ static int __vc_cmd_tabsolute_check(const char *str, struct tm *td, int *exist) *exist = 0; ret = regexec(®[0], str, 5, pmatch, 0); if (0 == ret) { - for (idx = 1; idx < 5 && 0 >= pmatch[idx].rm_eo - pmatch[idx].rm_so; idx++); + for (idx = 1; 5 > idx && 0 >= pmatch[idx].rm_eo - pmatch[idx].rm_so; idx++); flag = idx & 1; - if (sidx < 0 || sidx > pmatch[0].rm_so) sidx = pmatch[0].rm_so; - if (eidx < 0 || eidx < pmatch[0].rm_eo) eidx = pmatch[0].rm_eo; + sidx = pmatch[0].rm_so; + eidx = pmatch[0].rm_eo; } ret = regexec(®[1], str, 2, pmatch, 0); @@ -1836,10 +1836,10 @@ static int __vc_cmd_tabsolute_check(const char *str, struct tm *td, int *exist) free(tempstr); tempstr = NULL; - SLOG(LOG_DEBUG, TAG_VCCMD, "Matched string > %.*s", len, str + pmatch[1].rm_so); + SLOG(LOG_DEBUG, TAG_VCCMD, "Matched string > %.*s", len, str + pmatch[0].rm_so); - if (sidx < 0 || sidx > pmatch[0].rm_so) sidx = pmatch[0].rm_so; - if (eidx < 0 || eidx < pmatch[0].rm_eo) eidx = pmatch[0].rm_eo; + if (0 > sidx || pmatch[0].rm_so < sidx) sidx = pmatch[0].rm_so; + if (0 > eidx || pmatch[0].rm_eo > eidx) eidx = pmatch[0].rm_eo; } else if (0 < flag) { SLOG(LOG_DEBUG, TAG_VCCMD, "[REGEX] Incomming sentence is weird"); return VC_ERROR_NONE; @@ -1873,22 +1873,22 @@ static int __vc_cmd_tabsolute_check(const char *str, struct tm *td, int *exist) min = 30; } - SLOG(LOG_DEBUG, TAG_VCCMD, "Matched string > %.*s", pmatch[idx].rm_eo - pmatch[idx].rm_so, str + pmatch[idx].rm_so); - if (sidx < 0 || sidx > pmatch[0].rm_so) sidx = pmatch[0].rm_so; - if (eidx < 0 || eidx < pmatch[0].rm_eo) eidx = pmatch[0].rm_eo; + SLOG(LOG_DEBUG, TAG_VCCMD, "Matched string > %.*s", pmatch[0].rm_eo - pmatch[0].rm_so, str + pmatch[0].rm_so); + if (0 > sidx || pmatch[0].rm_so < sidx) sidx = pmatch[0].rm_so; + if (0 > eidx || pmatch[0].rm_eo > eidx) eidx = pmatch[0].rm_eo; } - if (hour < 0 && min < 0) { + if (0 > hour && 0 > min) { SLOG(LOG_DEBUG, TAG_VCCMD, "[REGEX] There is no matched string"); return VC_ERROR_NONE; } - if (min >= 0 && hour >= 0) { + if (0 <= min && 0 <= hour) { if (hour < td->tm_hour || (hour == td->tm_hour && min <= td->tm_min)) __vc_cmd_add_mday(td, 1); td->tm_hour = hour; td->tm_min = min; - } else if (min >= 0) { + } else if (0 <= min) { char *lang = NULL; vc_config_mgr_get_default_language(&lang); if (NULL == lang) { @@ -1926,7 +1926,7 @@ static int __vc_cmd_tabsolute_check(const char *str, struct tm *td, int *exist) static int __vc_cmd_dphrase_check(const char *str, struct tm *td, int *exist) { - regmatch_t pmatch[9]; + regmatch_t pmatch[10]; int ret; int len; int idx; @@ -1934,17 +1934,17 @@ static int __vc_cmd_dphrase_check(const char *str, struct tm *td, int *exist) *exist = 0; ret = regexec(®[10], str, 5, pmatch, 0); if (0 == ret) { - for (idx = 1; idx < 5 && 0 >= pmatch[idx].rm_eo - pmatch[idx].rm_so; idx++); + for (idx = 1; 5 > idx && 0 >= pmatch[idx].rm_eo - pmatch[idx].rm_so; idx++); len = pmatch[idx].rm_eo - pmatch[idx].rm_so; - td->tm_year = td_now->tm_year; - td->tm_mon = td_now->tm_mon; - td->tm_mday = td_now->tm_mday; + td->tm_year = td_now.tm_year; + td->tm_mon = td_now.tm_mon; + td->tm_mday = td_now.tm_mday; __vc_cmd_add_mday(td, idx - 1); - SLOG(LOG_DEBUG, TAG_VCCMD, "Matched string > %.*s", len, str + pmatch[idx].rm_so); + SLOG(LOG_DEBUG, TAG_VCCMD, "Matched string > %.*s", len, str + pmatch[0].rm_so); __update_data_sidx(pmatch[0].rm_so); __update_data_eidx(pmatch[0].rm_eo); @@ -1953,21 +1953,21 @@ static int __vc_cmd_dphrase_check(const char *str, struct tm *td, int *exist) return VC_ERROR_NONE; } - ret = regexec(®[11], str, 9, pmatch, 0); + ret = regexec(®[11], str, 10, pmatch, 0); if (0 == ret) { - for (idx = 1; idx < 9; idx++) { + for (idx = 1; 10 > idx; idx++) { len = pmatch[idx].rm_eo - pmatch[idx].rm_so; if (0 < len) break; } - td->tm_year = td_now->tm_year; - td->tm_mon = td_now->tm_mon; - td->tm_mday = td_now->tm_mday; + td->tm_year = td_now.tm_year; + td->tm_mon = td_now.tm_mon; + td->tm_mday = td_now.tm_mday; __vc_cmd_add_mday(td, idx + 1); - SLOG(LOG_DEBUG, TAG_VCCMD, "Matched string > %.*s", len, str + pmatch[idx].rm_so); + SLOG(LOG_DEBUG, TAG_VCCMD, "Matched string > %.*s", len, str + pmatch[0].rm_so); __update_data_sidx(pmatch[0].rm_so); __update_data_eidx(pmatch[0].rm_eo); @@ -1990,9 +1990,9 @@ static int __vc_cmd_dabsolute_check(const char *str, struct tm *td, int *exist) int eidx = -1; int y_flag = 0; int m_flag = 0; - int year = -1; - int mon = -1; - int day = -1; + int year = 0; + int mon = 0; + int day = 0; char *tempstr = NULL; *exist = 0; @@ -2011,10 +2011,10 @@ static int __vc_cmd_dabsolute_check(const char *str, struct tm *td, int *exist) free(tempstr); tempstr = NULL; - SLOG(LOG_DEBUG, TAG_VCCMD, "Matched string > %.*s", len, str + pmatch[1].rm_so); + SLOG(LOG_DEBUG, TAG_VCCMD, "Matched string > %.*s", len, str + pmatch[0].rm_so); - if (sidx < 0 || sidx > pmatch[0].rm_so) sidx = pmatch[0].rm_so; - if (eidx < 0 || eidx < pmatch[0].rm_eo) eidx = pmatch[0].rm_eo; + sidx = pmatch[0].rm_so; + eidx = pmatch[0].rm_eo; } else { SLOG(LOG_DEBUG, TAG_VCCMD, "[REGEX] Incomming sentence is weird"); return VC_ERROR_NONE; @@ -2022,7 +2022,7 @@ static int __vc_cmd_dabsolute_check(const char *str, struct tm *td, int *exist) ret = regexec(®[8], str, 13, pmatch, 0); if (0 == ret) { - for (idx = 1; idx < 13; idx++) { + for (idx = 1; 13 > idx; idx++) { len = pmatch[idx].rm_eo - pmatch[idx].rm_so; if (0 < len) { @@ -2033,10 +2033,10 @@ static int __vc_cmd_dabsolute_check(const char *str, struct tm *td, int *exist) m_flag = 1; - SLOG(LOG_DEBUG, TAG_VCCMD, "Matched string > %.*s", len, str + pmatch[idx].rm_so); + SLOG(LOG_DEBUG, TAG_VCCMD, "Matched string > %.*s", len, str + pmatch[0].rm_so); - if (sidx < 0 || sidx > pmatch[0].rm_so) sidx = pmatch[0].rm_so; - if (eidx < 0 || eidx < pmatch[0].rm_eo) eidx = pmatch[0].rm_eo; + if (0 > sidx || pmatch[0].rm_so < sidx) sidx = pmatch[0].rm_so; + if (0 > eidx || pmatch[0].rm_eo > eidx) eidx = pmatch[0].rm_eo; } else { char *lang = NULL; vc_config_mgr_get_default_language(&lang); @@ -2071,25 +2071,25 @@ static int __vc_cmd_dabsolute_check(const char *str, struct tm *td, int *exist) } year = atoi(tempstr); - year = year > 1900 ? year - 1900 : year + 100; + year = 1900 < year ? year - 1900 : year + 100; free(tempstr); tempstr = NULL; y_flag = 1; - SLOG(LOG_DEBUG, TAG_VCCMD, "Matched string > %.*s", len, str + pmatch[2].rm_so); + SLOG(LOG_DEBUG, TAG_VCCMD, "Matched string > %.*s", len, str + pmatch[0].rm_so); - if (sidx < 0 || sidx > pmatch[0].rm_so) sidx = pmatch[0].rm_so; - if (eidx < 0 || eidx < pmatch[0].rm_eo) eidx = pmatch[0].rm_eo; + if (0 > sidx || pmatch[0].rm_so < sidx) sidx = pmatch[0].rm_so; + if (0 > eidx || pmatch[0].rm_eo > eidx) eidx = pmatch[0].rm_eo; } else { year = td->tm_year; } - if (g_time_flag < 0) { + if (0 > g_time_flag) { td->tm_hour = 0; td->tm_min = 0; td->tm_sec = 0; - } else if (g_time_flag == 2) { + } else if (2 == g_time_flag) { SLOG(LOG_DEBUG, TAG_VCCMD, "[REGEX] Incomming sentence is weird"); return VC_ERROR_NONE; } @@ -2108,10 +2108,10 @@ static int __vc_cmd_dabsolute_check(const char *str, struct tm *td, int *exist) if (!y_flag) { if (!m_flag) { - if (day < td_now->tm_mday) __vc_cmd_add_mon(td, 1); + if (day < td_now.tm_mday) __vc_cmd_add_mon(td, 1); } else { - if (mon < td_now->tm_mon) __vc_cmd_add_year(td, 1); - else if (mon == td_now->tm_mon && day < td_now->tm_mday) __vc_cmd_add_year(td, 1); + if (mon < td_now.tm_mon) __vc_cmd_add_year(td, 1); + else if (mon == td_now.tm_mon && day < td_now.tm_mday) __vc_cmd_add_year(td, 1); } } @@ -2207,12 +2207,12 @@ int vc_cmd_get_datetime(const char *text, time_t *result, char **remain) const char *day_name[7] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; vc_error_e ret; - *result = -1; if (NULL == text || NULL == result || NULL == remain) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter"); return VC_ERROR_INVALID_PARAMETER; } + *result = -1; ret = __vc_cmd_regex_init(); if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] initialize regex failed"); @@ -2222,10 +2222,10 @@ int vc_cmd_get_datetime(const char *text, time_t *result, char **remain) g_data_sidx = g_data_eidx = -1; t_now = time(NULL); - td_now = localtime(&t_now); + localtime_r(&t_now, &td_now); SLOG(LOG_DEBUG, TAG_VCCMD, "Current timestamp = %d", (int)t_now); - __copy_struct_tm(&td, td_now); + __copy_struct_tm(&td, &td_now); SLOG(LOG_DEBUG, TAG_VCCMD, "%d-%d-%d (%s), %d:%d:%d", td.tm_year + 1900, td.tm_mon + 1, td.tm_mday, day_name[td.tm_wday], td.tm_hour, td.tm_min, td.tm_sec); diff --git a/common/vc_json_parser.c b/common/vc_json_parser.c old mode 100644 new mode 100755 index 6d50d51..4c99231 --- a/common/vc_json_parser.c +++ b/common/vc_json_parser.c @@ -363,16 +363,17 @@ static int __vc_json_set_commands(JsonObject *root_obj, int type, char* invocati cmd = NULL; } + free(temp_type); + free(prev_appid); + temp_type = NULL; + prev_appid = NULL; + ret = vc_db_commit_transaction(); if (0 != ret) { SLOG(LOG_ERROR, vc_json_tag(), "[ERROR] Fail to commit transaction for db"); return ret; } - free(temp_type); - free(prev_appid); - temp_type = NULL; - prev_appid = NULL; return VC_ERROR_NONE; } -- 2.7.4 From aca9db44d7920db763fe552444849cd4c8b99c8f Mon Sep 17 00:00:00 2001 From: Kwangyoun Kim Date: Wed, 5 Oct 2016 16:10:39 +0900 Subject: [PATCH 04/16] Add get error message and apply sound stream Change-Id: I0e1161c997444fe66656ed2fc4f84ecabfb5e893 --- client/vc_mgr.c | 31 ++++++++++++++++++ client/vc_mgr_client.c | 41 ++++++++++++++++++++++++ client/vc_mgr_client.h | 4 +++ include/voice_control_manager.h | 18 +++++++++++ server/vcd_recorder.c | 70 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 164 insertions(+) diff --git a/client/vc_mgr.c b/client/vc_mgr.c index 603e112..0469551 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -47,6 +47,8 @@ static int g_daemon_pid = 0; static int g_feature_enabled = -1; +static bool g_err_callback_status = false; + static Eina_Bool __vc_mgr_notify_state_changed(void *data); static Eina_Bool __vc_mgr_notify_error(void *data); static Eina_Bool __vc_mgr_notify_result(void *data); @@ -2176,6 +2178,32 @@ int vc_mgr_unset_pre_result_cb() return 0; } +int vc_mgr_get_error_message(char** err_msg) +{ + SLOG(LOG_DEBUG, TAG_VCM, "===== [Manager] Get error message"); + + if (NULL == err_msg) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] invalid parameter"); + return VC_ERROR_INVALID_PARAMETER; + } + + if (false == g_err_callback_status) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not in error callback"); + return VC_ERROR_OPERATION_FAILED; + } + + int ret; + ret = vc_mgr_client_get_error_message(g_vc_m, err_msg); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get error message"); + } + + SLOG(LOG_DEBUG, TAG_VCM, "====="); + SLOG(LOG_DEBUG, TAG_VCM, " "); + + return ret; +} + static Eina_Bool __vc_mgr_notify_error(void *data) { vc_h vc_m = (vc_h)data; @@ -2189,7 +2217,9 @@ static Eina_Bool __vc_mgr_notify_error(void *data) if (NULL != callback) { vc_mgr_client_use_callback(vc_m); + g_err_callback_status = true; callback(reason, user_data); + g_err_callback_status = false; vc_mgr_client_not_use_callback(vc_m); SLOG(LOG_DEBUG, TAG_VCM, "Error callback is called"); } else { @@ -2227,6 +2257,7 @@ int __vc_mgr_cb_error(int reason, int daemon_pid, char* msg) SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Error reason(%d), msg(%s)", reason, msg); vc_mgr_client_set_error(g_vc_m, reason); + vc_mgr_client_set_error_message(g_vc_m, msg); __vc_mgr_notify_error(g_vc_m); return 0; diff --git a/client/vc_mgr_client.c b/client/vc_mgr_client.c index 90d5b9e..4f01521 100644 --- a/client/vc_mgr_client.c +++ b/client/vc_mgr_client.c @@ -77,6 +77,7 @@ typedef struct { /* error data */ int reason; + char* err_msg; /* Authorized */ GSList* authorized_client_list; @@ -184,6 +185,7 @@ int vc_mgr_client_create(vc_h* vc) client->recognition_mode = VC_RECOGNITION_MODE_STOP_BY_SILENCE; client->reason = 0; + client->err_msg = NULL; client->cb_ref_count = 0; @@ -232,6 +234,10 @@ int vc_mgr_client_destroy(vc_h vc) free(data->all_result_text); } + if (NULL != data->err_msg) { + free(data->err_msg); + } + free(data); free(vc); @@ -685,6 +691,41 @@ int vc_mgr_client_get_error(vc_h vc, int* reason) return 0; } +int vc_mgr_client_set_error_message(vc_h vc, const char* err_msg) +{ + vc_mgr_client_s* client = __mgr_client_get(vc); + + /* check handle */ + if (NULL == client) + return VC_ERROR_INVALID_PARAMETER; + + if (NULL != client->err_msg) { + free(client->err_msg); + client->err_msg = NULL; + } + + if (NULL != err_msg) { + client->err_msg = strdup(err_msg); + } + + return 0; +} + +int vc_mgr_client_get_error_message(vc_h vc, char** err_msg) +{ + vc_mgr_client_s* client = __mgr_client_get(vc); + + /* check handle */ + if (NULL == client) + return VC_ERROR_INVALID_PARAMETER; + + if (NULL != client->err_msg) { + *err_msg = strdup(client->err_msg); + } + + return 0; +} + int vc_mgr_client_set_exclusive_command(vc_h vc, bool value) { vc_mgr_client_s* client = __mgr_client_get(vc); diff --git a/client/vc_mgr_client.h b/client/vc_mgr_client.h index 15cd295..51088c5 100644 --- a/client/vc_mgr_client.h +++ b/client/vc_mgr_client.h @@ -99,6 +99,10 @@ int vc_mgr_client_set_error(vc_h vc, int reason); int vc_mgr_client_get_error(vc_h vc, int* reason); +int vc_mgr_client_set_error_message(vc_h vc, const char* err_msg); + +int vc_mgr_client_get_error_message(vc_h vc, char** err_msg); + int vc_mgr_client_set_exclusive_command(vc_h vc, bool value); bool vc_mgr_client_get_exclusive_command(vc_h vc); diff --git a/include/voice_control_manager.h b/include/voice_control_manager.h index bdef272..abcd864 100644 --- a/include/voice_control_manager.h +++ b/include/voice_control_manager.h @@ -902,6 +902,24 @@ int vc_mgr_set_current_language_changed_cb(vc_current_language_changed_cb callba int vc_mgr_unset_current_language_changed_cb(); /** +* @brief Gets the current error message. +* +* @remarks This function should be called during as stt error callback. If not, the error as operation failure will be returned. \n +* If the function succeeds, @a err_msg must be released using free() when it is no longer required. +* +* @param[out] err_msg The current error message +* +* @return 0 on success, otherwise a negative error value +* @retval #VC_ERROR_NONE Successful +* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #VC_ERROR_INVALID_STATE Invalid state +* @retval $VC_ERROR_OPERATION_FAILED Operation failure +* +* @see vc_error_cb() +*/ +int vc_mgr_get_error_message(char** err_msg); + +/** * @brief Registers a callback function to be called when an error occurred. * * @param[in] callback Callback function to register diff --git a/server/vcd_recorder.c b/server/vcd_recorder.c index 764a7a4..bcda93e 100644 --- a/server/vcd_recorder.c +++ b/server/vcd_recorder.c @@ -50,6 +50,8 @@ static vcd_recorder_interrupt_cb g_interrupt_cb = NULL; static audio_in_h g_audio_h; +static sound_stream_info_h g_stream_info_h; + static vcp_audio_type_e g_audio_type; static unsigned int g_audio_rate; @@ -192,6 +194,51 @@ static void _bt_hid_audio_data_receive_cb(bt_hid_voice_data_s *voice_data, void #endif +static const char* __get_focus_changed_reason_code(sound_stream_focus_change_reason_e reason) +{ + switch (reason) { + case SOUND_STREAM_FOCUS_CHANGED_BY_MEDIA: return "SOUND_STREAM_FOCUS_CHANGED_BY_MEDIA"; + case SOUND_STREAM_FOCUS_CHANGED_BY_SYSTEM: return "SOUND_STREAM_FOCUS_CHANGED_BY_SYSTEM"; + case SOUND_STREAM_FOCUS_CHANGED_BY_ALARM: return "SOUND_STREAM_FOCUS_CHANGED_BY_ALARM"; + case SOUND_STREAM_FOCUS_CHANGED_BY_NOTIFICATION: return "SOUND_STREAM_FOCUS_CHANGED_BY_NOTIFICATION"; + case SOUND_STREAM_FOCUS_CHANGED_BY_EMERGENCY: return "SOUND_STREAM_FOCUS_CHANGED_BY_EMERGENCY"; + case SOUND_STREAM_FOCUS_CHANGED_BY_VOICE_INFORMATION: return "SOUND_STREAM_FOCUS_CHANGED_BY_VOICE_INFORMATION"; + case SOUND_STREAM_FOCUS_CHANGED_BY_VOICE_RECOGNITION: return "SOUND_STREAM_FOCUS_CHANGED_BY_VOICE_RECOGNITION"; + case SOUND_STREAM_FOCUS_CHANGED_BY_RINGTONE: return "SOUND_STREAM_FOCUS_CHANGED_BY_RINGTONE"; + case SOUND_STREAM_FOCUS_CHANGED_BY_VOIP: return "SOUND_STREAM_FOCUS_CHANGED_BY_VOIP"; + case SOUND_STREAM_FOCUS_CHANGED_BY_CALL: return "SOUND_STREAM_FOCUS_CHANGED_BY_CALL"; + case SOUND_STREAM_FOCUS_CHANGED_BY_MEDIA_EXTERNAL_ONLY: return "SOUND_STREAM_FOCUS_CHANGED_BY_MEDIA_EXTERNAL_ONLY"; + default: return "Undefined reason code"; + } +} + +static void __recorder_focus_state_cb(sound_stream_info_h stream_info, sound_stream_focus_change_reason_e reason, const char *extra_info, void *user_data) +{ + SLOG(LOG_DEBUG, TAG_VCD, "[Recorder] Focus state changed cb"); + + if (stream_info != g_stream_info_h) { + SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Invalid stream info handle"); + return; + } + + int ret; + sound_stream_focus_state_e state_for_recording; + ret = sound_manager_get_focus_state(g_stream_info_h, NULL, &state_for_recording); + if (SOUND_MANAGER_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to get focus state"); + return; + } + + SLOG(LOG_WARN, TAG_VCD, "[Recorder] focus state chagned to (%d) with reason (%s)", (int)state_for_recording, __get_focus_changed_reason_code(reason)); + + if (VCD_RECORDER_STATE_RECORDING == g_recorder_state && SOUND_STREAM_FOCUS_STATE_RELEASED == state_for_recording) { + SLOG(LOG_WARN, TAG_VCD, "[Recorder] Focus released as interrupt"); + if (NULL != g_interrupt_cb) { + g_interrupt_cb(); + } + } +} + int vcd_recorder_create(vcd_recoder_audio_cb audio_cb, vcd_recorder_interrupt_cb interrupt_cb) { if (NULL == audio_cb || NULL == interrupt_cb) { @@ -240,6 +287,10 @@ int vcd_recorder_create(vcd_recoder_audio_cb audio_cb, vcd_recorder_interrupt_cb g_is_valid_audio_in = false; } + if (0 != sound_manager_create_stream_information(SOUND_STREAM_TYPE_VOICE_RECOGNITION, __recorder_focus_state_cb, NULL, &g_stream_info_h)) { + SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to create stream info"); + } + g_audio_cb = audio_cb; g_interrupt_cb = interrupt_cb; g_recorder_state = VCD_RECORDER_STATE_READY; @@ -298,6 +349,10 @@ int vcd_recorder_destroy() g_recorder_state = VCD_RECORDER_STATE_READY; } + if (0 != sound_manager_destroy_stream_information(g_stream_info_h)) { + SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to destroy stream info"); + } + audio_in_destroy(g_audio_h); #ifdef TV_BT_MODE @@ -568,6 +623,16 @@ int vcd_recorder_start() SLOG(LOG_ERROR, TAG_VCD, "[Recorder] started = %d", started); if (false == started) { + ret = sound_manager_acquire_focus(g_stream_info_h, SOUND_STREAM_FOCUS_FOR_RECORDING, NULL); + if (SOUND_MANAGER_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to acquire focus : %d", ret); + } else { + ret = audio_in_set_stream_info(g_audio_h, g_stream_info_h); + if (AUDIO_IO_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to set stream info : %d", ret); + } + } + ret = audio_in_prepare(g_audio_h); if (AUDIO_IO_ERROR_NONE != ret) { if (AUDIO_IO_ERROR_SOUND_POLICY == ret) { @@ -654,6 +719,11 @@ int vcd_recorder_stop() SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to stop audio : %d", ret); return VCD_ERROR_OPERATION_FAILED; } + + ret = sound_manager_release_focus(g_stream_info_h, SOUND_STREAM_FOCUS_FOR_RECORDING, NULL); + if (SOUND_MANAGER_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to release focus : %d", ret); + } } return 0; } -- 2.7.4 From 8901194db49bdedc5a5a36e94a51f4d7cd538347 Mon Sep 17 00:00:00 2001 From: Kwangyoun Kim Date: Wed, 5 Oct 2016 18:34:43 +0900 Subject: [PATCH 05/16] Fix typo and add error handling Change-Id: I6d1d39fb11ece24b6521c18cad3e18a4ea4ec27e --- client/vc_mgr_client.c | 6 ++++++ include/voice_control_manager.h | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/client/vc_mgr_client.c b/client/vc_mgr_client.c index 4f01521..328ff33 100644 --- a/client/vc_mgr_client.c +++ b/client/vc_mgr_client.c @@ -706,6 +706,9 @@ int vc_mgr_client_set_error_message(vc_h vc, const char* err_msg) if (NULL != err_msg) { client->err_msg = strdup(err_msg); + if (NULL == client->err_msg) { + return VC_ERROR_OUT_OF_MEMORY; + } } return 0; @@ -721,6 +724,9 @@ int vc_mgr_client_get_error_message(vc_h vc, char** err_msg) if (NULL != client->err_msg) { *err_msg = strdup(client->err_msg); + if (NULL == *err_msg) { + return VC_ERROR_OUT_OF_MEMORY; + } } return 0; diff --git a/include/voice_control_manager.h b/include/voice_control_manager.h index abcd864..32f4cd7 100644 --- a/include/voice_control_manager.h +++ b/include/voice_control_manager.h @@ -904,7 +904,7 @@ int vc_mgr_unset_current_language_changed_cb(); /** * @brief Gets the current error message. * -* @remarks This function should be called during as stt error callback. If not, the error as operation failure will be returned. \n +* @remarks This function should be called during as vc error callback. If not, the error as operation failure will be returned. \n * If the function succeeds, @a err_msg must be released using free() when it is no longer required. * * @param[out] err_msg The current error message @@ -914,6 +914,7 @@ int vc_mgr_unset_current_language_changed_cb(); * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VC_ERROR_INVALID_STATE Invalid state * @retval $VC_ERROR_OPERATION_FAILED Operation failure +* @retval #VC_ERROR_OUT_OF_MEMORY Out of memory * * @see vc_error_cb() */ -- 2.7.4 From 91de4233b949bfa1120895e7175a7ce42ce01767 Mon Sep 17 00:00:00 2001 From: Kwangyoun Kim Date: Wed, 5 Oct 2016 19:53:00 +0900 Subject: [PATCH 06/16] Add internal state for prevent bug from async api call Change-Id: I8a0539cc5291f5e8860a7d6cc47950628b0ea6f7 --- client/vc_mgr.c | 51 ++++++++++++++++++++++++++++++++++ client/vc_mgr_client.c | 30 ++++++++++++++++++++ client/vc_mgr_client.h | 11 ++++++++ client/vc_widget.c | 2 +- include/voice_control_command_expand.h | 1 + include/voice_control_common.h | 5 +++- include/voice_control_widget.h | 4 +-- server/vcd_engine_agent.c | 3 ++ server/vcd_recorder.c | 10 +++++++ 9 files changed, 113 insertions(+), 4 deletions(-) mode change 100644 => 100755 client/vc_widget.c diff --git a/client/vc_mgr.c b/client/vc_mgr.c index 0469551..ab5c2f4 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -179,6 +179,8 @@ static void __vc_mgr_internal_unprepare() if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request finalize : %s", __vc_mgr_get_error_code(ret)); } + + vc_mgr_client_set_internal_state(g_vc_m, VC_INTERNAL_STATE_NONE); return; } @@ -1555,6 +1557,14 @@ int vc_mgr_start(bool exclusive_command_option) return VC_ERROR_INVALID_STATE; } + /* Check internal state for async */ + vc_internal_state_e internal_state = -1; + vc_mgr_client_get_internal_state(g_vc_m, &internal_state); + if (internal_state != VC_INTERNAL_STATE_NONE) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invaid State : Internal state is NOT none : %d", internal_state); + return VC_ERROR_IN_PROGRESS_TO_RECORDING; + } + vc_mgr_client_set_exclusive_command(g_vc_m, exclusive_command_option); bool start_by_client = false; @@ -1590,6 +1600,7 @@ int vc_mgr_start(bool exclusive_command_option) } } else { SLOG(LOG_DEBUG, TAG_VCM, "[SUCCESS] start recognition"); + vc_mgr_client_set_internal_state(g_vc_m, VC_INTERNAL_STATE_STARTING); } } @@ -1629,6 +1640,20 @@ int vc_mgr_stop() return VC_ERROR_INVALID_STATE; } + /* Check internal state for async */ + vc_internal_state_e internal_state = -1; + vc_mgr_client_get_internal_state(g_vc_m, &internal_state); + if (VC_INTERNAL_STATE_STARTING == internal_state) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State : Internal state is STARTING"); + return VC_ERROR_IN_PROGRESS_TO_RECORDING; + } else if (VC_INTERNAL_STATE_STOPPING == internal_state) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State : Internal state is STOPPING"); + return VC_ERROR_IN_PROGRESS_TO_PROCESSING; + } else if (VC_INTERNAL_STATE_CANCELING == internal_state) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State : Internal state is CANCELING"); + return VC_ERROR_IN_PROGRESS_TO_READY; + } + int ret = -1; int count = 0; /* do request */ @@ -1649,6 +1674,7 @@ int vc_mgr_stop() } } else { SLOG(LOG_DEBUG, TAG_VCM, "[SUCCESS] Stop recognition"); + vc_mgr_client_set_internal_state(g_vc_m, VC_INTERNAL_STATE_STOPPING); } } @@ -1688,6 +1714,19 @@ int vc_mgr_cancel() return VC_ERROR_INVALID_STATE; } + vc_internal_state_e internal_state = -1; + vc_mgr_client_get_internal_state(g_vc_m, &internal_state); + if (VC_INTERNAL_STATE_STARTING == internal_state) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State : Internal state is STARTING"); + return VC_ERROR_IN_PROGRESS_TO_RECORDING; + } else if (VC_INTERNAL_STATE_STOPPING == internal_state) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State : Internal state is STOPPING"); + return VC_ERROR_IN_PROGRESS_TO_PROCESSING; + } else if (VC_INTERNAL_STATE_CANCELING == internal_state) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State : Internal state is CANCELING"); + return VC_ERROR_IN_PROGRESS_TO_READY; + } + int ret = -1; int count = 0; while (0 != ret) { @@ -1707,6 +1746,7 @@ int vc_mgr_cancel() } } else { SLOG(LOG_DEBUG, TAG_VCM, "[SUCCESS] Cancel recognition"); + vc_mgr_client_set_internal_state(g_vc_m, VC_INTERNAL_STATE_CANCELING); } } @@ -2243,6 +2283,8 @@ int __vc_mgr_cb_error(int reason, int daemon_pid, char* msg) return -1; } + vc_mgr_client_set_internal_state(g_vc_m, VC_INTERNAL_STATE_NONE); + if (VC_ERROR_SERVICE_RESET == reason) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] VC daemon reset"); @@ -2344,6 +2386,15 @@ int __vc_mgr_cb_service_state(int state) SLOG(LOG_DEBUG, TAG_VCM, "Service State changed : Before(%d) Current(%d)", before_state, current_state); + vc_internal_state_e internal_state = -1; + vc_mgr_client_get_internal_state(g_vc_m, &internal_state); + if ((VC_INTERNAL_STATE_STARTING == internal_state && VC_SERVICE_STATE_RECORDING == current_state) || + (VC_INTERNAL_STATE_STOPPING == internal_state && VC_SERVICE_STATE_PROCESSING == current_state) || + (VC_INTERNAL_STATE_CANCELING == internal_state && VC_SERVICE_STATE_READY == current_state)) { + SLOG(LOG_DEBUG, TAG_VCM, "Internal state is changed to NONE"); + vc_mgr_client_set_internal_state(g_vc_m, VC_INTERNAL_STATE_NONE); + } + /* Save service state */ vc_mgr_client_set_service_state(g_vc_m, current_state); diff --git a/client/vc_mgr_client.c b/client/vc_mgr_client.c index 4f01521..e44644e 100644 --- a/client/vc_mgr_client.c +++ b/client/vc_mgr_client.c @@ -58,6 +58,8 @@ typedef struct { /* service state */ vc_service_state_e service_state; + vc_internal_state_e internal_state; + /* state */ vc_state_e before_state; vc_state_e current_state; @@ -175,6 +177,8 @@ int vc_mgr_client_create(vc_h* vc) client->service_state = 0; + client->internal_state = VC_INTERNAL_STATE_NONE; + client->before_state = VC_STATE_INITIALIZED; client->current_state = VC_STATE_INITIALIZED; @@ -603,6 +607,32 @@ int vc_mgr_client_get_service_state(vc_h vc, vc_service_state_e* state) return 0; } +int vc_mgr_client_set_internal_state(vc_h vc, vc_internal_state_e state) +{ + vc_mgr_client_s* client = __mgr_client_get(vc); + + /* check handle */ + if (NULL == client) + return VC_ERROR_INVALID_PARAMETER; + + client->internal_state = state; + + return 0; +} + +int vc_mgr_client_get_internal_state(vc_h vc, vc_internal_state_e* state) +{ + vc_mgr_client_s* client = __mgr_client_get(vc); + + /* check handle */ + if (NULL == client) + return VC_ERROR_INVALID_PARAMETER; + + *state = client->internal_state; + + return 0; +} + int vc_mgr_client_set_client_state(vc_h vc, vc_state_e state) { vc_mgr_client_s* client = __mgr_client_get(vc); diff --git a/client/vc_mgr_client.h b/client/vc_mgr_client.h index 51088c5..afee7a4 100644 --- a/client/vc_mgr_client.h +++ b/client/vc_mgr_client.h @@ -26,6 +26,13 @@ extern "C" { #endif +typedef enum { + VC_INTERNAL_STATE_NONE = 0, + VC_INTERNAL_STATE_STARTING = 1, + VC_INTERNAL_STATE_STOPPING = 2, + VC_INTERNAL_STATE_CANCELING = 3 +} vc_internal_state_e; + /* * Common function */ @@ -87,6 +94,10 @@ int vc_mgr_client_set_service_state(vc_h vc, vc_service_state_e state); int vc_mgr_client_get_service_state(vc_h vc, vc_service_state_e* state); +int vc_mgr_client_set_internal_state(vc_h vc, vc_internal_state_e state); + +int vc_mgr_client_get_internal_state(vc_h vc, vc_internal_state_e* state); + int vc_mgr_client_set_client_state(vc_h vc, vc_state_e state); int vc_mgr_client_get_client_state(vc_h vc, vc_state_e* state); diff --git a/client/vc_widget.c b/client/vc_widget.c old mode 100644 new mode 100755 index f05a6b6..e7a9ed1 --- a/client/vc_widget.c +++ b/client/vc_widget.c @@ -1106,7 +1106,7 @@ int vc_widget_set_send_current_command_list_cb(vc_widget_send_current_command_li return 0; } -int vc_widget_unsset_send_current_command_list_cb() +int vc_widget_unset_send_current_command_list_cb() { vc_state_e state; if (0 != vc_widget_client_get_state(g_vc_w, &state)) { diff --git a/include/voice_control_command_expand.h b/include/voice_control_command_expand.h index 695641f..fdb4101 100755 --- a/include/voice_control_command_expand.h +++ b/include/voice_control_command_expand.h @@ -18,6 +18,7 @@ #ifndef __VOICE_CONTROL_COMMAND_EXPAND_H__ #define __VOICE_CONTROL_COMMAND_EXPAND_H__ +#include #include #include diff --git a/include/voice_control_common.h b/include/voice_control_common.h index 86b07ac..b491719 100644 --- a/include/voice_control_common.h +++ b/include/voice_control_common.h @@ -50,7 +50,10 @@ typedef enum { VC_ERROR_OPERATION_REJECTED = TIZEN_ERROR_VOICE_CONTROL | 0x015, /**< Operation rejected */ VC_ERROR_ITERATION_END = TIZEN_ERROR_VOICE_CONTROL | 0x016, /**< List reached end */ VC_ERROR_EMPTY = TIZEN_ERROR_VOICE_CONTROL | 0x017, /**< List empty */ - VC_ERROR_SERVICE_RESET = TIZEN_ERROR_VOICE_CONTROL | 0x018 /**< Service Damon reset */ + VC_ERROR_SERVICE_RESET = TIZEN_ERROR_VOICE_CONTROL | 0x018, /**< Service Damon reset */ + VC_ERROR_IN_PROGRESS_TO_READY = TIZEN_ERROR_VOICE_CONTROL | 0x019, + VC_ERROR_IN_PROGRESS_TO_RECORDING = TIZEN_ERROR_VOICE_CONTROL | 0x020, + VC_ERROR_IN_PROGRESS_TO_PROCESSING = TIZEN_ERROR_VOICE_CONTROL | 0x021 } vc_error_e; /** diff --git a/include/voice_control_widget.h b/include/voice_control_widget.h index 91ddf74..2f8ca7a 100755 --- a/include/voice_control_widget.h +++ b/include/voice_control_widget.h @@ -63,7 +63,7 @@ typedef void (*vc_widget_show_tooltip_cb)(bool show, void* user_data); * @pre An application registers callback function using vc_widget_set_send_current_command_group_cb(). * * @see vc_widget_set_send_current_command_list_cb() -* @see vc_widget_unsset_send_current_command_list_cb() +* @see vc_widget_unset_send_current_command_list_cb() */ typedef void (*vc_widget_send_current_command_list_cb)(vc_cmd_list_h* vc_cmd_list, void* user_data); @@ -374,7 +374,7 @@ int vc_widget_set_send_current_command_list_cb(vc_widget_send_current_command_li * * @see vc_widget_set_send_current_command_list_cb() */ -int vc_widget_unsset_send_current_command_list_cb(); +int vc_widget_unset_send_current_command_list_cb(); /** * @brief Registers a callback function to be called when service state is changed. diff --git a/server/vcd_engine_agent.c b/server/vcd_engine_agent.c index 0863583..12f5754 100644 --- a/server/vcd_engine_agent.c +++ b/server/vcd_engine_agent.c @@ -428,6 +428,9 @@ int __internal_update_engine_list() } if (NULL != dirp) { + if (!strcmp(".", dirp->d_name) || !strcmp("..", dirp->d_name)) + continue; + vcengine_info_s* info = NULL; char* filepath = NULL; int filesize = 0; diff --git a/server/vcd_recorder.c b/server/vcd_recorder.c index bcda93e..f7e7313 100644 --- a/server/vcd_recorder.c +++ b/server/vcd_recorder.c @@ -194,6 +194,7 @@ static void _bt_hid_audio_data_receive_cb(bt_hid_voice_data_s *voice_data, void #endif +#if 0 static const char* __get_focus_changed_reason_code(sound_stream_focus_change_reason_e reason) { switch (reason) { @@ -238,6 +239,7 @@ static void __recorder_focus_state_cb(sound_stream_info_h stream_info, sound_str } } } +#endif int vcd_recorder_create(vcd_recoder_audio_cb audio_cb, vcd_recorder_interrupt_cb interrupt_cb) { @@ -287,9 +289,11 @@ int vcd_recorder_create(vcd_recoder_audio_cb audio_cb, vcd_recorder_interrupt_cb g_is_valid_audio_in = false; } +#if 0 if (0 != sound_manager_create_stream_information(SOUND_STREAM_TYPE_VOICE_RECOGNITION, __recorder_focus_state_cb, NULL, &g_stream_info_h)) { SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to create stream info"); } +#endif g_audio_cb = audio_cb; g_interrupt_cb = interrupt_cb; @@ -349,9 +353,11 @@ int vcd_recorder_destroy() g_recorder_state = VCD_RECORDER_STATE_READY; } +#if 0 if (0 != sound_manager_destroy_stream_information(g_stream_info_h)) { SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to destroy stream info"); } +#endif audio_in_destroy(g_audio_h); @@ -623,6 +629,7 @@ int vcd_recorder_start() SLOG(LOG_ERROR, TAG_VCD, "[Recorder] started = %d", started); if (false == started) { +#if 0 ret = sound_manager_acquire_focus(g_stream_info_h, SOUND_STREAM_FOCUS_FOR_RECORDING, NULL); if (SOUND_MANAGER_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to acquire focus : %d", ret); @@ -632,6 +639,7 @@ int vcd_recorder_start() SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to set stream info : %d", ret); } } +#endif ret = audio_in_prepare(g_audio_h); if (AUDIO_IO_ERROR_NONE != ret) { @@ -720,10 +728,12 @@ int vcd_recorder_stop() return VCD_ERROR_OPERATION_FAILED; } +#if 0 ret = sound_manager_release_focus(g_stream_info_h, SOUND_STREAM_FOCUS_FOR_RECORDING, NULL); if (SOUND_MANAGER_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to release focus : %d", ret); } +#endif } return 0; } -- 2.7.4 From fbd8e0a9497afe3e375000d973035bc4c7d31a19 Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Tue, 11 Oct 2016 14:40:30 +0900 Subject: [PATCH 07/16] Fix documentation for ACR Change-Id: Iea6ee606b333e855aefae0c67bc0713a290866df Signed-off-by: sooyeon.kim --- client/vc.c | 1 + common/vc_cmd_db.h | 2 +- common/vc_command.c | 6 +- include/CMakeLists.txt | 1 + include/voice_control.h | 1004 ++++++++++++++++---------------- include/voice_control_command.h | 738 ++++++++++++----------- include/voice_control_command_expand.h | 46 +- include/voice_control_common.h | 204 +++---- include/voice_control_internal.h | 65 +++ packaging/voice-control.spec | 1 + server/vcd_recorder.c | 2 + 11 files changed, 1044 insertions(+), 1026 deletions(-) create mode 100644 include/voice_control_internal.h diff --git a/client/vc.c b/client/vc.c index e6b4de9..46ef551 100644 --- a/client/vc.c +++ b/client/vc.c @@ -33,6 +33,7 @@ #include "vc_json_parser.h" #include "vc_main.h" #include "voice_control.h" +#include "voice_control_internal.h" #include "voice_control_authority.h" #include "voice_control_command.h" #include "voice_control_command_expand.h" diff --git a/common/vc_cmd_db.h b/common/vc_cmd_db.h index c0028b6..c580ce2 100644 --- a/common/vc_cmd_db.h +++ b/common/vc_cmd_db.h @@ -40,7 +40,7 @@ typedef enum { VC_DB_ERROR_OPERATION_REJECTED = TIZEN_ERROR_VOICE_CONTROL | 0x015, /**< Operation rejected */ VC_DB_ERROR_ITERATION_END = TIZEN_ERROR_VOICE_CONTROL | 0x016, /**< List reached end */ VC_DB_ERROR_EMPTY = TIZEN_ERROR_VOICE_CONTROL | 0x017, /**< List empty */ - VC_DB_ERROR_SERVICE_RESET = TIZEN_ERROR_VOICE_CONTROL | 0x018 /**< Service Damon reset */ + VC_DB_ERROR_SERVICE_RESET = TIZEN_ERROR_VOICE_CONTROL | 0x018 /**< Service daemon reset @if MOBILE (Since 3.0) @endif */ } vc_db_error_e; typedef struct _deactivated_app_s { diff --git a/common/vc_command.c b/common/vc_command.c index 3252b90..c37287e 100755 --- a/common/vc_command.c +++ b/common/vc_command.c @@ -1103,7 +1103,7 @@ int vc_cmd_get_type(vc_cmd_h vc_command, int* type) return 0; } -int vc_cmd_set_format(vc_cmd_h vc_command, vc_cmd_format_e format) +int vc_cmd_set_format(vc_cmd_h vc_command, int format) { if (0 != __vc_cmd_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; @@ -1127,7 +1127,7 @@ int vc_cmd_set_format(vc_cmd_h vc_command, vc_cmd_format_e format) return 0; } -int vc_cmd_get_format(vc_cmd_h vc_command, vc_cmd_format_e* format) +int vc_cmd_get_format(vc_cmd_h vc_command, int* format) { if (0 != __vc_cmd_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; @@ -2269,4 +2269,4 @@ int vc_cmd_get_datetime(const char *text, time_t *result, char **remain) SLOG(LOG_DEBUG, TAG_VCCMD, ""); return VC_ERROR_NONE; -} \ No newline at end of file +} diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index d40a4de..7d0db51 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -14,6 +14,7 @@ INSTALL(FILES ${CMAKE_BINARY_DIR}/include/voice-control-engine.pc DESTINATION ${ ## Install header files ## INSTALL(FILES ${CMAKE_BINARY_DIR}/include/voice_control.h DESTINATION ${INCLUDEDIR}) +INSTALL(FILES ${CMAKE_BINARY_DIR}/include/voice_control_internal.h DESTINATION ${INCLUDEDIR}) INSTALL(FILES ${CMAKE_BINARY_DIR}/include/voice_control_authority.h DESTINATION ${INCLUDEDIR}) INSTALL(FILES ${CMAKE_BINARY_DIR}/include/voice_control_command.h DESTINATION ${INCLUDEDIR}) INSTALL(FILES ${CMAKE_BINARY_DIR}/include/voice_control_command_expand.h DESTINATION ${INCLUDEDIR}) diff --git a/include/voice_control.h b/include/voice_control.h index 205a39a..4d9c51a 100644 --- a/include/voice_control.h +++ b/include/voice_control.h @@ -1,18 +1,18 @@ -/* -* Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved -* -* Licensed under the Apache License, Version 2.0 (the License); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an AS IS BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ +/** + * Copyright (c) 2011-2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef __VOICE_CONTROL_H__ @@ -22,9 +22,9 @@ #include /** -* @addtogroup CAPI_UIX_VOICE_CONTROL_MODULE -* @{ -*/ + * @addtogroup CAPI_UIX_VOICE_CONTROL_MODULE + * @{ + */ #ifdef __cplusplus extern "C" @@ -32,583 +32,567 @@ extern "C" #endif /** -* @file voice_control.h -* @brief This file contains the voice control client API and related callback definitions and enums. -*/ + * @file voice_control.h + * @brief This file contains the voice control client API and related callback definitions and enums. + */ /** -* @file voice_control_command.h -* @brief This file contains the command list and command API and related handle definitions and enums. -*/ + * @file voice_control_command.h + * @brief This file contains the command list and command API and related handle definitions and enums. + */ /** -* @file voice_control_common.h -* @brief This file contains the callback function definitions and enums. -*/ + * @file voice_control_common.h + * @brief This file contains the callback function definitions and enums. + */ /** -* @brief Definitions for foreground command type. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -*/ + * @brief Definitions for foreground command type. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + */ #define VC_COMMAND_TYPE_FOREGROUND 1 /** -* @brief Definitions for background command type. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -*/ + * @brief Definitions for background command type. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + */ #define VC_COMMAND_TYPE_BACKGROUND 2 /** -* @brief Definitions for ended dialog. -* @since_tizen 3.0 -*/ + * @brief Definitions for ended dialog. + * @since_tizen 3.0 + */ #define VC_DIALOG_END 0 /** -* @brief Definitions for continued dialog. -* @since_tizen 3.0 -*/ + * @brief Definitions for continued dialog. + * @since_tizen 3.0 + */ #define VC_DIALOG_CONTINUE 1 /** -* @brief Initializes voice control. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* @privlevel public -* @privilege %http://tizen.org/privilege/recorder -* -* @remarks If the function succeeds, @a vc must be released with vc_deinitialize(). -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_OUT_OF_MEMORY Out of memory -* @retval #VC_ERROR_OPERATION_FAILED Operation failure -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @post If this function is called, the state will be #VC_STATE_INITIALIZED. -* -* @see vc_deinitialize() -*/ + * @brief Initializes voice control. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @privlevel public + * @privilege %http://tizen.org/privilege/recorder + * + * @remarks If the function succeeds, @a vc must be released with vc_deinitialize(). + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_OUT_OF_MEMORY Out of memory + * @retval #VC_ERROR_OPERATION_FAILED Operation failure + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @post If this function is called, the state will be #VC_STATE_INITIALIZED. + * + * @see vc_deinitialize() + */ int vc_initialize(void); /** -* @brief Deinitializes voice control. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* @privlevel public -* @privilege %http://tizen.org/privilege/recorder -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_STATE Invalid state -* @retval #VC_ERROR_OPERATION_FAILED Operation failure -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @see vc_deinitialize() -*/ + * @brief Deinitializes voice control. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @privlevel public + * @privilege %http://tizen.org/privilege/recorder + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_STATE Invalid state + * @retval #VC_ERROR_OPERATION_FAILED Operation failure + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @see vc_deinitialize() + */ int vc_deinitialize(void); /** -* @brief Connects the voice control service. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* @privlevel public -* @privilege %http://tizen.org/privilege/recorder -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_STATE Invalid state -* @retval #VC_ERROR_OPERATION_FAILED Operation failure -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @pre The state should be #VC_STATE_INITIALIZED. -* @post If this function is called, the state will be #VC_STATE_READY. -* -* @see vc_unprepare() -*/ + * @brief Connects the voice control service. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @privlevel public + * @privilege %http://tizen.org/privilege/recorder + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_STATE Invalid state + * @retval #VC_ERROR_OPERATION_FAILED Operation failure + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state should be #VC_STATE_INITIALIZED. + * @post If this function is called, the state will be #VC_STATE_READY. + * + * @see vc_unprepare() + */ int vc_prepare(void); /** -* @brief Disconnects the voice control service. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* @privlevel public -* @privilege %http://tizen.org/privilege/recorder -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_STATE Invalid state -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @pre The state should be #VC_STATE_READY. -* @post If this function is called, the state will be #VC_STATE_INITIALIZED. -* -* @see vc_prepare() -*/ + * @brief Disconnects the voice control service. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @privlevel public + * @privilege %http://tizen.org/privilege/recorder + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_STATE Invalid state + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state should be #VC_STATE_READY. + * @post If this function is called, the state will be #VC_STATE_INITIALIZED. + * + * @see vc_prepare() + */ int vc_unprepare(void); /** -* @brief Retrieves all supported languages using callback function. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* @privlevel public -* @privilege %http://tizen.org/privilege/recorder -* -* @param[in] callback Callback function to invoke -* @param[in] user_data The user data to be passed to the callback function -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_OPERATION_FAILED Operation failure -* @retval #VC_ERROR_INVALID_STATE Invalid state -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @pre The state should be #VC_STATE_INITIALIZED or #VC_STATE_READY. -* @post This function invokes vc_supported_language_cb() repeatedly for getting languages. -* -* @see vc_supported_language_cb() -* @see vc_get_current_language() -*/ + * @brief Retrieves all supported languages using callback function. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @privlevel public + * @privilege %http://tizen.org/privilege/recorder + * + * @param[in] callback Callback function to invoke + * @param[in] user_data The user data to be passed to the callback function + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_OPERATION_FAILED Operation failure + * @retval #VC_ERROR_INVALID_STATE Invalid state + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state should be #VC_STATE_INITIALIZED or #VC_STATE_READY. + * @post This function invokes vc_supported_language_cb() repeatedly for getting languages. + * + * @see vc_supported_language_cb() + * @see vc_get_current_language() + */ int vc_foreach_supported_languages(vc_supported_language_cb callback, void* user_data); /** -* @brief Gets current language. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* @privlevel public -* @privilege %http://tizen.org/privilege/recorder -* -* @remark If the function succeeds, @a language must be released with free() by you when you no longer need it. -* -* @param[out] language A language is specified as an ISO 3166 alpha-2 two letter country-code \n -* followed by ISO 639-1 for the two-letter language code. \n -* For example, "ko_KR" for Korean, "en_US" for American English. -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_OUT_OF_MEMORY Out of memory -* @retval #VC_ERROR_OPERATION_FAILED Operation failure -* @retval #VC_ERROR_INVALID_STATE Invalid state -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @pre The state should be #VC_STATE_INITIALIZED or #VC_STATE_READY. -* -* @see vc_foreach_supported_languages() -*/ + * @brief Gets current language. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @privlevel public + * @privilege %http://tizen.org/privilege/recorder + * + * @remark If the function succeeds, @a language must be released with free() by you when you no longer need it. + * + * @param[out] language A language is specified as an ISO 3166 alpha-2 two letter country-code \n + * followed by ISO 639-1 for the two-letter language code. \n + * For example, "ko_KR" for Korean, "en_US" for American English. + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_OUT_OF_MEMORY Out of memory + * @retval #VC_ERROR_OPERATION_FAILED Operation failure + * @retval #VC_ERROR_INVALID_STATE Invalid state + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state should be #VC_STATE_INITIALIZED or #VC_STATE_READY. + * + * @see vc_foreach_supported_languages() + */ int vc_get_current_language(char** language); /** -* @brief Gets current state of voice control client. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* @privlevel public -* @privilege %http://tizen.org/privilege/recorder -* -* @param[out] state The current state -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @see vc_state_changed_cb() -* @see vc_set_state_changed_cb() -*/ + * @brief Gets current state of voice control client. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @privlevel public + * @privilege %http://tizen.org/privilege/recorder + * + * @param[out] state The current state + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @see vc_state_changed_cb() + * @see vc_set_state_changed_cb() + */ int vc_get_state(vc_state_e* state); /** -* @brief Gets current state of voice control service. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* @privlevel public -* @privilege %http://tizen.org/privilege/recorder -* -* @param[out] state The current state -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @pre The state should be #VC_STATE_READY. -* -* @see vc_request_start() -* @see vc_request_stop() -* @see vc_request_cancel() -* @see vc_set_service_state_changed_cb() -* @see vc_unset_service_state_changed_cb() -*/ + * @brief Gets current state of voice control service. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @privlevel public + * @privilege %http://tizen.org/privilege/recorder + * + * @param[out] state The current state + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state should be #VC_STATE_READY. + * + * @see vc_request_start() + * @see vc_request_stop() + * @see vc_request_cancel() + * @see vc_set_service_state_changed_cb() + * @see vc_unset_service_state_changed_cb() + */ int vc_get_service_state(vc_service_state_e* state); /** -* @brief Get system command list. -* @since_tizen 3.0 -* @privlevel public -* @privilege %http://tizen.org/privilege/recorder -* -* @remarks If system command is set by system voice app, the system command list can be retreived. -* -* @param[out] vc_sys_cmd_list System command list handle -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_INVALID_STATE Invalid state -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @pre The service state should be #VC_SERVICE_STATE_READY. -* -* @see vc_unset_command_list() -*/ + * @brief Gets the system command list. + * @since_tizen 3.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/recorder + * + * @remarks In the system command list, there are system commands predefined by product manufacturers. Those commands have the highest priority. + * Therefore, the user can not set any commands same with the system commands. \n + * The @a vc_sys_cmd_list must be released using free() when it is no longer required. + * + * @param[out] vc_sys_cmd_list System command list handle + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_INVALID_STATE Invalid state + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @pre The service state should be #VC_SERVICE_STATE_READY. + * + * @see vc_unset_command_list() + */ int vc_get_system_command_list(vc_cmd_list_h* vc_sys_cmd_list); /** -* @brief Sets invocation name. -* @since_tizen 3.0 -* @privlevel public -* @privilege %http://tizen.org/privilege/recorder -* -* @remarks The invocation name will be combined with background command. -* This function should be called before vc_set_command_list() or vc_set_command_list_from_file(). -* -* @param[in] name App name that wants to be invoked -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_INVALID_STATE Invalid state -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @pre The state should be #VC_STATE_READY. -* -* @see vc_set_command_list() -* @see vc_set_command_list_from_file() -*/ + * @brief Sets invocation name. + * @since_tizen 3.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/recorder + * + * @remarks Invocation name is used to activate background commands. The invocation name can be set as the application name or some words. + * For example, an application "Tizen Sample" has a background command, "Play music", and the invocation name of the application is set as "Tizen Sample". + * In order to activate the background command, users can say "Tizen Sample, Play music". + * The invocation name is dependent on the setting language. For example, if the setting language is "en_US"(English), the invocation name is also "en_US". + * If the setting language is "ja_JP"(Japanese) and the invocation name is "en_US", the invocation name will not be recognized. + * This function should be called before vc_set_command_list(). + * + * @param[in] name Invocation name that an application wants to be invoked by + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_INVALID_STATE Invalid state + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state should be #VC_STATE_READY. + * + * @see vc_set_command_list() + */ int vc_set_invocation_name(const char* name); /** -* @brief Request to display text and to speak text what app want. -* @since_tizen 3.0 -* @privlevel public -* @privilege %http://tizen.org/privilege/recorder -* -* @remarks If continue is true, the recognition will start again. In this case, 4 times can be restarted. -* -* @param[in] disp_text Text hat wants to be displayed -* @param[in] utt_text Text that wants to be spoken -* @param[in] continue Continue dialog session -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_INVALID_STATE Invalid state -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @pre The service state should be #VC_SERVICE_STATE_READY. -*/ -int vc_dialog(const char* disp_text, const char* utt_text, bool auto_start); - -/** -* @brief Sets command list. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* @privlevel public -* @privilege %http://tizen.org/privilege/recorder -* -* @remarks The command type is valid for #VC_COMMAND_TYPE_FOREGROUND or #VC_COMMAND_TYPE_BACKGROUND. \n -* The matched commands of command list should be set and they should include type and command text at least. -* -* @param[in] vc_cmd_list Command list handle -* @param[in] type Command type -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_INVALID_STATE Invalid state -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @pre The state should be #VC_STATE_READY. -* -* @see vc_unset_command_list() -*/ + * @brief Requests to start the dialogue. + * @details Using this function, the developer can transfer texts, for starting the dialogue, to the framework. + * There are two types of texts. One is a text for displaying, and the other is that for uttering. + * For example, if @a disp_text is "October 10th" and @a utt_text is "Today is October 10th.", "October 10th" will be displayed on the screen and "Today is October 10th." will be spoken. + * Also, the developer can set whether the dialogue restarts automatically or not, using @a auto_start. + * + * @since_tizen 3.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/recorder + * + * @remarks If @a auto_start is @c true, the recognition will start again. In this case, 4 times can be restarted. + * + * @param[in] disp_text Text to be displayed on the screen + * @param[in] utt_text Text to be spoken + * @param[in] auto_start A variable for setting whether the dialog session will be restarted automatically or not + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_INVALID_STATE Invalid state + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @pre The service state should be #VC_SERVICE_STATE_READY. + */ +int vc_request_dialog(const char* disp_text, const char* utt_text, bool auto_start); + +/** + * @brief Sets command list. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @privlevel public + * @privilege %http://tizen.org/privilege/recorder + * + * @remarks The command type is valid for #VC_COMMAND_TYPE_FOREGROUND or #VC_COMMAND_TYPE_BACKGROUND. \n + * The matched commands of command list should be set and they should include type and command text at least. + * + * @param[in] vc_cmd_list Command list handle + * @param[in] type Command type + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_INVALID_STATE Invalid state + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state should be #VC_STATE_READY. + * + * @see vc_unset_command_list() + */ int vc_set_command_list(vc_cmd_list_h vc_cmd_list, int type); /** -* @brief Sets command list from file. -* @since_tizen 3.0 -* @privlevel public -* @privilege %http://tizen.org/privilege/recorder -* -* @remarks The command type is valid for #VC_COMMAND_TYPE_FOREGROUND or #VC_COMMAND_TYPE_BACKGROUND. \n -* The matched commands of command list should be set and they should include type and command text at least. -* -* @param[in] file_path The file path including commands -* @param[in] type Command type -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_INVALID_STATE Invalid state -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @pre The state should be #VC_STATE_READY. -* -* @see vc_unset_command_list() -*/ -int vc_set_command_list_from_file(const char* file_path, int type); - -/** -* @brief Unsets command list. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* @privlevel public -* @privilege %http://tizen.org/privilege/recorder -* -* @param[in] type Command type -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_INVALID_STATE Invalid state -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @pre The state should be #VC_STATE_READY. -* -* @see vc_set_command_list() -* @see vc_set_command_list_from_file -*/ + * @brief Unsets command list. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @privlevel public + * @privilege %http://tizen.org/privilege/recorder + * + * @param[in] type Command type + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_INVALID_STATE Invalid state + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state should be #VC_STATE_READY. + * + * @see vc_set_command_list() + */ int vc_unset_command_list(int type); /** -* @brief Get recognition result using a callback function. -* @since_tizen 3.0 -* @privlevel public -* @privilege %http://tizen.org/privilege/recorder -* -* @param[in] callback Callback function to get recognition result -* @param[in] user_data The user data to be passed to the callback function -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_INVALID_STATE Invalid state -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @pre The state should be #VC_STATE_READY. -* -* @see vc_result_cb() -*/ + * @brief Gets the recognition result. + * @since_tizen 3.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/recorder + * + * @param[in] callback Callback function to get recognition result + * @param[in] user_data The user data to be passed to the callback function + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_INVALID_STATE Invalid state + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state should be #VC_STATE_READY. + * + * @see vc_result_cb() + */ int vc_get_result(vc_result_cb callback, void* user_data); /** -* @brief Registers a callback function for getting recognition result. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* @privlevel public -* @privilege %http://tizen.org/privilege/recorder -* -* @param[in] callback Callback function to register -* @param[in] user_data The user data to be passed to the callback function -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_INVALID_STATE Invalid state -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @pre The state should be #VC_STATE_INITIALIZED. -* -* @see vc_result_cb() -* @see vc_unset_result_cb() -*/ + * @brief Registers a callback function for getting recognition result. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @privlevel public + * @privilege %http://tizen.org/privilege/recorder + * + * @param[in] callback Callback function to register + * @param[in] user_data The user data to be passed to the callback function + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_INVALID_STATE Invalid state + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state should be #VC_STATE_INITIALIZED. + * + * @see vc_result_cb() + * @see vc_unset_result_cb() + */ int vc_set_result_cb(vc_result_cb callback, void* user_data); /** -* @brief Unregisters the callback function. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* @privlevel public -* @privilege %http://tizen.org/privilege/recorder -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_STATE Invalid state -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @pre The state should be #VC_STATE_INITIALIZED. -* -* @see vc_set_result_cb() -*/ + * @brief Unregisters the callback function. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @privlevel public + * @privilege %http://tizen.org/privilege/recorder + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_STATE Invalid state + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state should be #VC_STATE_INITIALIZED. + * + * @see vc_set_result_cb() + */ int vc_unset_result_cb(void); /** -* @brief Registers a callback function to be called when state is changed. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* @privlevel public -* @privilege %http://tizen.org/privilege/recorder -* -* @param[in] callback Callback function to register -* @param[in] user_data The user data to be passed to the callback function -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_INVALID_STATE Invalid state -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @pre The state should be #VC_STATE_INITIALIZED. -* -* @see vc_service_state_changed_cb() -* @see vc_unset_service_state_changed_cb() -*/ + * @brief Registers a callback function to be called when state is changed. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @privlevel public + * @privilege %http://tizen.org/privilege/recorder + * + * @param[in] callback Callback function to register + * @param[in] user_data The user data to be passed to the callback function + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_INVALID_STATE Invalid state + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state should be #VC_STATE_INITIALIZED. + * + * @see vc_service_state_changed_cb() + * @see vc_unset_service_state_changed_cb() + */ int vc_set_service_state_changed_cb(vc_service_state_changed_cb callback, void* user_data); /** -* @brief Unregisters the callback function. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* @privlevel public -* @privilege %http://tizen.org/privilege/recorder -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_STATE Invalid state -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @pre The state should be #VC_STATE_INITIALIZED. -* -* @see vc_set_service_state_changed_cb() -*/ + * @brief Unregisters the callback function. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @privlevel public + * @privilege %http://tizen.org/privilege/recorder + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_STATE Invalid state + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state should be #VC_STATE_INITIALIZED. + * + * @see vc_set_service_state_changed_cb() + */ int vc_unset_service_state_changed_cb(void); /** -* @brief Registers a callback function to be called when state is changed. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* @privlevel public -* @privilege %http://tizen.org/privilege/recorder -* -* @param[in] callback Callback function to register -* @param[in] user_data The user data to be passed to the callback function -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_INVALID_STATE Invalid state -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @pre The state should be #VC_STATE_INITIALIZED. -* -* @see vc_state_changed_cb() -* @see vc_unset_state_changed_cb() -*/ + * @brief Registers a callback function to be called when state is changed. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @privlevel public + * @privilege %http://tizen.org/privilege/recorder + * + * @param[in] callback Callback function to register + * @param[in] user_data The user data to be passed to the callback function + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_INVALID_STATE Invalid state + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state should be #VC_STATE_INITIALIZED. + * + * @see vc_state_changed_cb() + * @see vc_unset_state_changed_cb() + */ int vc_set_state_changed_cb(vc_state_changed_cb callback, void* user_data); /** -* @brief Unregisters the callback function. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* @privlevel public -* @privilege %http://tizen.org/privilege/recorder -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_STATE Invalid state -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @pre The state should be #VC_STATE_INITIALIZED. -* -* @see vc_set_state_changed_cb() -*/ + * @brief Unregisters the callback function. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @privlevel public + * @privilege %http://tizen.org/privilege/recorder + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_STATE Invalid state + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state should be #VC_STATE_INITIALIZED. + * + * @see vc_set_state_changed_cb() + */ int vc_unset_state_changed_cb(void); /** -* @brief Registers a callback function to be called when current language is changed. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* @privlevel public -* @privilege %http://tizen.org/privilege/recorder -* -* @param[in] callback Callback function to register -* @param[in] user_data The user data to be passed to the callback function -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_INVALID_STATE Invalid state -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @pre The state should be #VC_STATE_INITIALIZED. -* -* @see vc_current_language_changed_cb() -* @see vc_unset_current_language_changed_cb() -*/ + * @brief Registers a callback function to be called when current language is changed. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @privlevel public + * @privilege %http://tizen.org/privilege/recorder + * + * @param[in] callback Callback function to register + * @param[in] user_data The user data to be passed to the callback function + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_INVALID_STATE Invalid state + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state should be #VC_STATE_INITIALIZED. + * + * @see vc_current_language_changed_cb() + * @see vc_unset_current_language_changed_cb() + */ int vc_set_current_language_changed_cb(vc_current_language_changed_cb callback, void* user_data); /** -* @brief Unregisters the callback function. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* @privlevel public -* @privilege %http://tizen.org/privilege/recorder -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_STATE Invalid state -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @pre The state should be #VC_STATE_INITIALIZED. -* -* @see vc_set_current_language_changed_cb() -*/ + * @brief Unregisters the callback function. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @privlevel public + * @privilege %http://tizen.org/privilege/recorder + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_STATE Invalid state + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state should be #VC_STATE_INITIALIZED. + * + * @see vc_set_current_language_changed_cb() + */ int vc_unset_current_language_changed_cb(void); /** -* @brief Registers a callback function to be called when an error occurred. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* @privlevel public -* @privilege %http://tizen.org/privilege/recorder -* -* @param[in] callback Callback function to register -* @param[in] user_data The user data to be passed to the callback function -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_INVALID_STATE Invalid state -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @pre The state should be #VC_STATE_INITIALIZED. -* -* @see vc_error_cb() -* @see vc_unset_error_cb() -*/ + * @brief Registers a callback function to be called when an error occurred. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @privlevel public + * @privilege %http://tizen.org/privilege/recorder + * + * @param[in] callback Callback function to register + * @param[in] user_data The user data to be passed to the callback function + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_INVALID_STATE Invalid state + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state should be #VC_STATE_INITIALIZED. + * + * @see vc_error_cb() + * @see vc_unset_error_cb() + */ int vc_set_error_cb(vc_error_cb callback, void* user_data); /** -* @brief Unregisters the callback function. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* @privlevel public -* @privilege %http://tizen.org/privilege/recorder -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_STATE Invalid state -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @pre The state should be #VC_STATE_INITIALIZED. -* -* @see vc_set_error_cb() -*/ + * @brief Unregisters the callback function. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @privlevel public + * @privilege %http://tizen.org/privilege/recorder + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_STATE Invalid state + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state should be #VC_STATE_INITIALIZED. + * + * @see vc_set_error_cb() + */ int vc_unset_error_cb(void); diff --git a/include/voice_control_command.h b/include/voice_control_command.h index f913caa..8a7ee52 100644 --- a/include/voice_control_command.h +++ b/include/voice_control_command.h @@ -1,18 +1,18 @@ -/* -* Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved -* -* Licensed under the Apache License, Version 2.0 (the License); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an AS IS BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ +/** + * Copyright (c) 2011-2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef __VOICE_CONTROL_COMMAND_H__ @@ -20,14 +20,13 @@ #include - /** -* @defgroup CAPI_UIX_VOICE_CONTROL_COMMAND_MODULE Voice control command -* @ingroup CAPI_UIX_VOICE_CONTROL_MODULE -* -* @brief The @ref CAPI_UIX_VOICE_CONTROL_COMMAND_MODULE API provides functions for creating/destroying command list and add/remove/retrieve commands of list. -* @{ -*/ + * @defgroup CAPI_UIX_VOICE_CONTROL_COMMAND_MODULE Voice control command + * @ingroup CAPI_UIX_VOICE_CONTROL_MODULE + * + * @brief The @ref CAPI_UIX_VOICE_CONTROL_COMMAND_MODULE API provides functions for creating/destroying command list and add/remove/retrieve commands of list. + * @{ + */ #ifdef __cplusplus extern "C" @@ -36,428 +35,415 @@ extern "C" /** -* @brief The voice command handle. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -*/ + * @brief The voice command handle. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + */ typedef struct vc_cmd_s* vc_cmd_h; /** -* @brief The voice command list handle. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -*/ + * @brief The voice command list handle. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + */ typedef struct vc_cmd_list_s* vc_cmd_list_h; /** -* @brief Enumerations of command format. -* @since_tizen 3.0 -*/ -typedef enum { - VC_CMD_FORMAT_FIXED = 0, /**< fixed command only */ - VC_CMD_FORMAT_FIXED_AND_VFIXED, /**< Fixed + variable fixed command */ - VC_CMD_FORMAT_VFIXED_AND_FIXED, /**< Variable fixed + fixed command */ - VC_CMD_FORMAT_FIXED_AND_NONFIXED, /**< Fixed + non fixed command */ - VC_CMD_FORMAT_NONFIXED_AND_FIXED, /**< Non fixed + fixed command */ - VC_CMD_FORMAT_ACTION, /**< Action command */ - VC_CMD_FORMAT_PARTIAL /**< Partial matched command */ -} vc_cmd_format_e; - -/** -* @brief Called to retrieve The commands in list. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* -* @param[in] vc_command The command handle -* @param[in] user_data The user data passed from the foreach function -* -* @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop. -* @pre vc_cmd_list_foreach_commands() will invoke this callback. -* -* @see vc_cmd_list_foreach_commands() -*/ + * @brief Called to retrieve The commands in list. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * + * @param[in] vc_command The command handle + * @param[in] user_data The user data passed from the foreach function + * + * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop. + * @pre vc_cmd_list_foreach_commands() will invoke this callback. + * + * @see vc_cmd_list_foreach_commands() + */ typedef bool (*vc_cmd_list_cb)(vc_cmd_h vc_command, void* user_data); /** -* @brief Creates a handle for command list. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* -* @remarks If the function succeeds, @a The list handle must be released with vc_cmd_list_destroy(). -* -* @param[out] vc_cmd_list The command list handle -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_OUT_OF_MEMORY Out of memory -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @see vc_cmd_list_destroy() -*/ + * @brief Creates a handle for command list. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * + * @remarks If the function succeeds, @a The list handle must be released with vc_cmd_list_destroy(). + * + * @param[out] vc_cmd_list The command list handle + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_OUT_OF_MEMORY Out of memory + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @see vc_cmd_list_destroy() + */ int vc_cmd_list_create(vc_cmd_list_h* vc_cmd_list); /** -* @brief Destroys the handle for command list. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* -* @param[in] vc_cmd_list The command list handle -* @param[in] free_command The command free option @c true = release each commands in list, -* @c false = remove command from list -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @see vc_cmd_list_create() -*/ + * @brief Destroys the handle for command list. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * + * @param[in] vc_cmd_list The command list handle + * @param[in] free_command The command free option @c true = release each commands in list, + * @c false = remove command from list + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @see vc_cmd_list_create() + */ int vc_cmd_list_destroy(vc_cmd_list_h vc_cmd_list, bool free_command); /** -* @brief Gets command count of list. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* -* @param[in] vc_cmd_list The command list handle -* @param[out] count The count -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -*/ + * @brief Gets command count of list. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * + * @param[in] vc_cmd_list The command list handle + * @param[out] count The count + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + */ int vc_cmd_list_get_count(vc_cmd_list_h vc_cmd_list, int* count); /** -* @brief Adds command to command list. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* -* @param[in] vc_cmd_list The command list handle -* @param[in] vc_command The command handle -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @see vc_cmd_list_remove() -*/ + * @brief Adds command to command list. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * + * @param[in] vc_cmd_list The command list handle + * @param[in] vc_command The command handle + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @see vc_cmd_list_remove() + */ int vc_cmd_list_add(vc_cmd_list_h vc_cmd_list, vc_cmd_h vc_command); /** -* @brief Removes command from command list. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* -* @param[in] vc_cmd_list The command list handle -* @param[in] vc_command The command handle -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @see vc_cmd_list_add() -*/ + * @brief Removes command from command list. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * + * @param[in] vc_cmd_list The command list handle + * @param[in] vc_command The command handle + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @see vc_cmd_list_add() + */ int vc_cmd_list_remove(vc_cmd_list_h vc_cmd_list, vc_cmd_h vc_command); /** -* @brief Retrieves all commands of command list using callback function. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* -* @param[in] vc_cmd_list The command list handle -* @param[in] callback Callback function to invoke -* @param[in] user_data The user data to be passed to the callback function -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @post This function invokes vc_cmd_list_cb() repeatedly for getting commands. -* -* @see vc_cmd_list_cb() -*/ + * @brief Retrieves all commands of command list using callback function. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * + * @param[in] vc_cmd_list The command list handle + * @param[in] callback Callback function to invoke + * @param[in] user_data The user data to be passed to the callback function + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @post This function invokes vc_cmd_list_cb() repeatedly for getting commands. + * + * @see vc_cmd_list_cb() + */ int vc_cmd_list_foreach_commands(vc_cmd_list_h vc_cmd_list, vc_cmd_list_cb callback, void* user_data); /** -* @brief Retrieves all commands of system command list using callback function. -* @since_tizen 3.0 -* -* @param[in] callback Callback function to invoke -* @param[in] user_data The user data to be passed to the callback function -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @post This function invokes vc_cmd_list_cb() repeatedly for getting commands. -* -* @see vc_cmd_list_cb() -*/ -int vc_cmd_list_foreach_system_commands(vc_cmd_list_cb callback, void* user_data); + * @brief Retrieves all commands on the system command list using callback function. + * @since_tizen 3.0 + * + * @param[in] callback Callback function to invoke + * @param[in] user_data The user data to be passed to the callback function + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @post This function invokes vc_cmd_list_cb() for each command. + * + * @see vc_cmd_list_cb() + */ +int vc_cmd_list_foreach_system_command(vc_cmd_list_cb callback, void* user_data); /** -* @brief Moves index to first command. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* -* @param[in] vc_cmd_list The command list handle -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_EMPTY List empty -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @see vc_cmd_list_last() -*/ + * @brief Moves index to first command. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * + * @param[in] vc_cmd_list The command list handle + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_EMPTY List empty + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @see vc_cmd_list_last() + */ int vc_cmd_list_first(vc_cmd_list_h vc_cmd_list); /** -* @brief Moves index to last command. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* -* @param[in] vc_cmd_list The command list handle -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_EMPTY List empty -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @see vc_cmd_list_first() -*/ + * @brief Moves index to last command. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * + * @param[in] vc_cmd_list The command list handle + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_EMPTY List empty + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @see vc_cmd_list_first() + */ int vc_cmd_list_last(vc_cmd_list_h vc_cmd_list); /** -* @brief Moves index to next command. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* -* @param[in] vc_cmd_list The command list handle -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_EMPTY List empty -* @retval #VC_ERROR_ITERATION_END List reached end -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @see vc_cmd_list_prev() -*/ + * @brief Moves index to next command. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * + * @param[in] vc_cmd_list The command list handle + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_EMPTY List empty + * @retval #VC_ERROR_ITERATION_END List reached end + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @see vc_cmd_list_prev() + */ int vc_cmd_list_next(vc_cmd_list_h vc_cmd_list); /** -* @brief Moves index to previous command. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* -* @param[in] vc_cmd_list The command list handle -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_EMPTY List empty -* @retval #VC_ERROR_ITERATION_END List reached end -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @see vc_cmd_list_next() -*/ + * @brief Moves index to previous command. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * + * @param[in] vc_cmd_list The command list handle + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_EMPTY List empty + * @retval #VC_ERROR_ITERATION_END List reached end + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @see vc_cmd_list_next() + */ int vc_cmd_list_prev(vc_cmd_list_h vc_cmd_list); /** -* @brief Get current command from command list by index. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* -* @param[in] vc_cmd_list The command list handle -* @param[out] vc_command The command handle -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_EMPTY List empty -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @see vc_cmd_list_first() -* @see vc_cmd_list_last() -* @see vc_cmd_list_prev() -* @see vc_cmd_list_next() -*/ + * @brief Get current command from command list by index. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * + * @param[in] vc_cmd_list The command list handle + * @param[out] vc_command The command handle + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_EMPTY List empty + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @see vc_cmd_list_first() + * @see vc_cmd_list_last() + * @see vc_cmd_list_prev() + * @see vc_cmd_list_next() + */ int vc_cmd_list_get_current(vc_cmd_list_h vc_cmd_list, vc_cmd_h* vc_command); - /** -* @brief Creates a handle for command. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* -* @remarks If the function succeeds, @a The command handle must be released -* with vc_cmd_destroy() or vc_cmd_list_destroy(). -* You should set command and type if command is valid -* -* @param[out] vc_command The command handle -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_OUT_OF_MEMORY Out of memory -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @see vc_cmd_destroy() -*/ + * @brief Creates a handle for command. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * + * @remarks If the function succeeds, @a The command handle must be released + * with vc_cmd_destroy() or vc_cmd_list_destroy(). + * You should set command and type if command is valid. + * The command format is set to #VC_CMD_FORMAT_FIXED by default and can be changed with vc_cmd_set_format(). + * + * @param[out] vc_command The command handle + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_OUT_OF_MEMORY Out of memory + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @see vc_cmd_destroy() + */ int vc_cmd_create(vc_cmd_h* vc_command); /** -* @brief Destroys the handle. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* -* @param[in] vc_command The command handle -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @see vc_cmd_create() -*/ + * @brief Destroys the handle. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * + * @param[in] vc_command The command handle + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @see vc_cmd_create() + */ int vc_cmd_destroy(vc_cmd_h vc_command); /** -* @brief Sets command or action. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* -* @param[in] vc_command The command handle -* @param[in] command The command or action text -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @see vc_cmd_get_command() -*/ + * @brief Sets command or action. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * + * @param[in] vc_command The command handle + * @param[in] command The command or action text + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @see vc_cmd_get_command() + */ int vc_cmd_set_command(vc_cmd_h vc_command, const char* command); /** -* @brief Gets command. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* -* @remark If the function succeeds, @a command must be released with free() by you if they are not NULL. -* -* @param[in] vc_command The command handle -* @param[out] command The command text -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @see vc_cmd_set_command() -*/ + * @brief Gets command. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * + * @remark If the function succeeds, @a command must be released with free() by you if they are not NULL. + * + * @param[in] vc_command The command handle + * @param[out] command The command text + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @see vc_cmd_set_command() + */ int vc_cmd_get_command(vc_cmd_h vc_command, char** command); /** -* @brief Gets extra unfixed command. -* @since_tizen 3.0 -* -* @remark If the function succeeds, @a The command must be released with free() by you if they are not NULL. -* If you get the result command list in result callback and the command type of commands has non-fixed format, -* you should check non-fixed result using this function. -* -* @param[in] vc_command The command handle -* @param[out] command The unfixed command text -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported feature -*/ + * @brief Gets the unfixed command. + * @since_tizen 3.0 + * + * @remark After this function is successfully conducted, the @a command must be released with free() if it is not NULL. + * If the command in @a vc_command is NULL, @a command will be also NULL. + * This function should be used for commands which have non-fixed format. + * + * @param[in] vc_command The command handle + * @param[out] command The unfixed command text + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported feature + */ int vc_cmd_get_unfixed_command(vc_cmd_h vc_command, char** command); /** -* @brief Sets command type. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* -* @remark If you do not set the command type, the default value is -1. -* You should set type if command is valid -* -* @param[in] vc_command The command handle -* @param[in] type The command type -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @see vc_cmd_get_type() -*/ + * @brief Sets command type. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * + * @remark If you do not set the command type, the default value is -1. + * You should set type if command is valid + * + * @param[in] vc_command The command handle + * @param[in] type The command type + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @see vc_cmd_get_type() + */ int vc_cmd_set_type(vc_cmd_h vc_command, int type); /** -* @brief Gets command type. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* -* @param[in] vc_command The command handle -* @param[out] type The command type -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported -* -* @see vc_cmd_set_type() -*/ + * @brief Gets command type. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * + * @param[in] vc_command The command handle + * @param[out] type The command type + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @see vc_cmd_set_type() + */ int vc_cmd_get_type(vc_cmd_h vc_command, int* type); - /** -* @brief Sets command format. -* @since_tizen 3.0 -* -* @param[in] vc_command The command handle -* @param[in] format The command format -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported feature -* -* @see vc_cmd_get_format() -*/ -int vc_cmd_set_format(vc_cmd_h vc_command, vc_cmd_format_e format); + * @brief Sets the command format. + * @since_tizen 3.0 + * + * @remark The default format is #VC_CMD_FORMAT_FIXED. + * + * @param[in] vc_command The command handle + * @param[in] format The command format + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported feature + * + * @see vc_cmd_get_format() + */ +int vc_cmd_set_format(vc_cmd_h vc_command, int format); /** -* @brief Gets command format. -* @since_tizen 3.0 -* -* @remark If you do not set the format, the default format is #VC_CMD_FORMAT_FIXED. -* -* @param[in] vc_command The command handle -* @param[out] format The command format -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported feature -* -* @see vc_cmd_set_format() -*/ -int vc_cmd_get_format(vc_cmd_h vc_command, vc_cmd_format_e* format); + * @brief Gets the command format. + * @since_tizen 3.0 + * + * @remark The default format is #VC_CMD_FORMAT_FIXED. + * + * @param[in] vc_command The command handle + * @param[out] format The command format + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported feature + * + * @see vc_cmd_set_format() + */ +int vc_cmd_get_format(vc_cmd_h vc_command, int* format); #ifdef __cplusplus diff --git a/include/voice_control_command_expand.h b/include/voice_control_command_expand.h index fdb4101..2714301 100755 --- a/include/voice_control_command_expand.h +++ b/include/voice_control_command_expand.h @@ -29,40 +29,18 @@ extern "C" #endif /** -* @brief Sets command format. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* -* @param[in] vc_command The command handle -* @param[in] format The command format -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported feature -* -* @see vc_cmd_get_format() -*/ -int vc_cmd_set_format(vc_cmd_h vc_command, vc_cmd_format_e format); - -/** -* @brief Gets command format. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* -* @remark If you do not set the format, the default format is #VC_CMD_FORMAT_FIXED. -* -* @param[in] vc_command The command handle -* @param[out] format The command format -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_ERROR_NONE Successful -* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ERROR_NOT_SUPPORTED Not supported feature -* -* @see vc_cmd_set_format() -*/ -int vc_cmd_get_format(vc_cmd_h vc_command, vc_cmd_format_e* format); + * @brief Enumerations of command format. + * @since_tizen 3.0 + */ +typedef enum { + VC_CMD_FORMAT_FIXED = 0, /**< fixed command only */ + VC_CMD_FORMAT_FIXED_AND_VFIXED, /**< Fixed + variable fixed command */ + VC_CMD_FORMAT_VFIXED_AND_FIXED, /**< Variable fixed + fixed command */ + VC_CMD_FORMAT_FIXED_AND_NONFIXED, /**< Fixed + non fixed command */ + VC_CMD_FORMAT_NONFIXED_AND_FIXED, /**< Non fixed + fixed command */ + VC_CMD_FORMAT_ACTION, /**< Action command */ + VC_CMD_FORMAT_PARTIAL /**< Partial matched command */ +} vc_cmd_format_e; /** * @brief Sets command domain diff --git a/include/voice_control_common.h b/include/voice_control_common.h index b491719..d8d4043 100644 --- a/include/voice_control_common.h +++ b/include/voice_control_common.h @@ -1,18 +1,18 @@ -/* -* Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved -* -* Licensed under the Apache License, Version 2.0 (the License); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an AS IS BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ +/** + * Copyright (c) 2011-2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef __VOICE_CONTROL_COMMON_H__ @@ -21,9 +21,9 @@ #include /** -* @addtogroup CAPI_UIX_VOICE_CONTROL_MODULE -* @{ -*/ + * @addtogroup CAPI_UIX_VOICE_CONTROL_MODULE + * @{ + */ #ifdef __cplusplus extern "C" @@ -31,9 +31,9 @@ extern "C" #endif /** -* @brief Enumerations of error codes. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -*/ + * @brief Enumerations of error codes. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + */ typedef enum { VC_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ VC_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of Memory */ @@ -50,25 +50,25 @@ typedef enum { VC_ERROR_OPERATION_REJECTED = TIZEN_ERROR_VOICE_CONTROL | 0x015, /**< Operation rejected */ VC_ERROR_ITERATION_END = TIZEN_ERROR_VOICE_CONTROL | 0x016, /**< List reached end */ VC_ERROR_EMPTY = TIZEN_ERROR_VOICE_CONTROL | 0x017, /**< List empty */ - VC_ERROR_SERVICE_RESET = TIZEN_ERROR_VOICE_CONTROL | 0x018, /**< Service Damon reset */ + VC_ERROR_SERVICE_RESET = TIZEN_ERROR_VOICE_CONTROL | 0x018, /**< Service daemon reset @if MOBILE (Since 3.0) @endif */ VC_ERROR_IN_PROGRESS_TO_READY = TIZEN_ERROR_VOICE_CONTROL | 0x019, VC_ERROR_IN_PROGRESS_TO_RECORDING = TIZEN_ERROR_VOICE_CONTROL | 0x020, VC_ERROR_IN_PROGRESS_TO_PROCESSING = TIZEN_ERROR_VOICE_CONTROL | 0x021 } vc_error_e; /** -* @brief Enumerations of result event. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -*/ + * @brief Enumerations of result event. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + */ typedef enum { VC_RESULT_EVENT_RESULT_SUCCESS = 0, /**< Normal result */ VC_RESULT_EVENT_REJECTED = 1 /**< Rejected result */ } vc_result_event_e; /** -* @brief Enumerations of service state. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -*/ + * @brief Enumerations of service state. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + */ typedef enum { VC_SERVICE_STATE_NONE = 0, /**< 'None' state */ VC_SERVICE_STATE_READY = 1, /**< 'Ready' state */ @@ -77,9 +77,9 @@ typedef enum { } vc_service_state_e; /** -* @brief Enumerations of client state. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -*/ + * @brief Enumerations of client state. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + */ typedef enum { VC_STATE_NONE = 0, /**< 'None' state */ VC_STATE_INITIALIZED = 1, /**< 'Initialized' state */ @@ -88,92 +88,92 @@ typedef enum { /** -* @brief Called when client gets the recognition result. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* -* @remarks If the duplicated commands are recognized, the event(e.g. #VC_RESULT_EVENT_REJECTED) of command may be rejected \n -* for selecting command as priority. If you set similar or same commands or the recognized results are multi-results, -* vc_cmd_list has the multi commands. -* -* @param[in] event The result event (e.g. #VC_RESULT_EVENT_RESULT_SUCCESS, #VC_RESULT_EVENT_REJECTED) -* @param[in] vc_cmd_list The recognized command list -* @param[in] result The spoken text -* @param[in] user_data The user data passed from the callback registration function -* -* @pre An application registers callback function. -* -* @see vc_set_result_cb() -*/ + * @brief Called when client gets the recognition result. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * + * @remarks If the duplicated commands are recognized, the event(e.g. #VC_RESULT_EVENT_REJECTED) of command may be rejected \n + * for selecting command as priority. If you set similar or same commands or the recognized results are multi-results, + * vc_cmd_list has the multi commands. + * + * @param[in] event The result event (e.g. #VC_RESULT_EVENT_RESULT_SUCCESS, #VC_RESULT_EVENT_REJECTED) + * @param[in] vc_cmd_list The recognized command list + * @param[in] result The spoken text + * @param[in] user_data The user data passed from the callback registration function + * + * @pre An application registers callback function. + * + * @see vc_set_result_cb() + */ typedef void (*vc_result_cb)(vc_result_event_e event, vc_cmd_list_h vc_cmd_list, const char* result, void *user_data); /** -* @brief Called when default language is changed. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* -* @param[in] previous Previous language -* @param[in] current Current language -* @param[in] user_data The user data passed from the callback registration function -* -* @pre An application registers this callback to detect changing mode. -* -* @see vc_set_current_language_changed_cb() -*/ + * @brief Called when default language is changed. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * + * @param[in] previous Previous language + * @param[in] current Current language + * @param[in] user_data The user data passed from the callback registration function + * + * @pre An application registers this callback to detect changing mode. + * + * @see vc_set_current_language_changed_cb() + */ typedef void (*vc_current_language_changed_cb)(const char* previous, const char* current, void* user_data); /** -* @brief Called to retrieve supported language. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* -* @param[in] language A language is specified as an ISO 3166 alpha-2 two letter country-code \n -* followed by ISO 639-1 for the two-letter language code. \n -* For example, "ko_KR" for Korean, "en_US" for American English. -* @param[in] user_data The user data passed from the foreach function -* -* @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop. -* -* @pre The function will invoke this callback. -*/ + * @brief Called to retrieve supported language. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * + * @param[in] language A language is specified as an ISO 3166 alpha-2 two letter country-code \n + * followed by ISO 639-1 for the two-letter language code. \n + * For example, "ko_KR" for Korean, "en_US" for American English. + * @param[in] user_data The user data passed from the foreach function + * + * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop. + * + * @pre The function will invoke this callback. + */ typedef bool (*vc_supported_language_cb)(const char* language, void* user_data); /** -* @brief Called when the state of voice control client is changed. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* -* @param[in] previous A previous state -* @param[in] current A current state -* @param[in] user_data The user data passed from the callback registration function -* -* @pre An application registers this callback to detect changing state. -* -* @see vc_set_state_changed_cb() -*/ + * @brief Called when the state of voice control client is changed. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * + * @param[in] previous A previous state + * @param[in] current A current state + * @param[in] user_data The user data passed from the callback registration function + * + * @pre An application registers this callback to detect changing state. + * + * @see vc_set_state_changed_cb() + */ typedef void (*vc_state_changed_cb)(vc_state_e previous, vc_state_e current, void* user_data); /** -* @brief Called when the state of voice control service is changed. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* -* @param[in] previous A previous state -* @param[in] current A current state -* @param[in] user_data The user data passed from the callback registration function -* -* @pre An application registers this callback to detect changing service state. -* -* @see vc_set_service_state_changed_cb() -*/ + * @brief Called when the state of voice control service is changed. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * + * @param[in] previous A previous state + * @param[in] current A current state + * @param[in] user_data The user data passed from the callback registration function + * + * @pre An application registers this callback to detect changing service state. + * + * @see vc_set_service_state_changed_cb() + */ typedef void (*vc_service_state_changed_cb)(vc_service_state_e previous, vc_service_state_e current, void* user_data); /** -* @brief Called when error occurred. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif -* -* @param[in] reason The error type (e.g. #VC_ERROR_OUT_OF_MEMORY, #VC_ERROR_TIMED_OUT) -* @param[in] user_data The user data passed from the callback registration function -* -* @pre An application registers this callback to detect error. -* -* @see vc_set_error_cb() -*/ + * @brief Called when error occurred. + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * + * @param[in] reason The error type (e.g. #VC_ERROR_OUT_OF_MEMORY, #VC_ERROR_TIMED_OUT) + * @param[in] user_data The user data passed from the callback registration function + * + * @pre An application registers this callback to detect error. + * + * @see vc_set_error_cb() + */ typedef void (*vc_error_cb)(vc_error_e reason, void *user_data); diff --git a/include/voice_control_internal.h b/include/voice_control_internal.h new file mode 100644 index 0000000..4935a91 --- /dev/null +++ b/include/voice_control_internal.h @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2011-2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef __VOICE_CONTROL_INTERNAL_H__ +#define __VOICE_CONTROL_INTERNAL_H__ + +#include +#include + + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** + * @brief Sets command list from file. + * @since_tizen 3.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/recorder + * + * @remarks The command type is valid for #VC_COMMAND_TYPE_FOREGROUND and #VC_COMMAND_TYPE_BACKGROUND. + * Therefore, @a type is either #VC_COMMAND_TYPE_FOREGROUND or #VC_COMMAND_TYPE_BACKGROUND. \n + * In the file corresponding to @a file_path, there must be commands and command types. + * + * @param[in] file_path The command file path (absolute or relative) + * @param[in] type Command type + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_INVALID_STATE Invalid state + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state should be #VC_STATE_READY. + * + * @see vc_unset_command_list() + */ +int vc_set_command_list_from_file(const char* file_path, int type); + + +#ifdef __cplusplus +} +#endif + +/** + * @}@} + */ + +#endif /* __VOICE_CONTROL_INTERNAL_H__ */ diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index f724a9e..8e185dd 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -132,6 +132,7 @@ mkdir -p %{_libdir}/voice/vc %defattr(-,root,root,-) %{_libdir}/pkgconfig/voice-control.pc %{_includedir}/voice_control.h +%{_includedir}/voice_control_internal.h %{_includedir}/voice_control_authority.h %{_includedir}/voice_control_command.h %{_includedir}/voice_control_common.h diff --git a/server/vcd_recorder.c b/server/vcd_recorder.c index f7e7313..9ffb34c 100644 --- a/server/vcd_recorder.c +++ b/server/vcd_recorder.c @@ -50,7 +50,9 @@ static vcd_recorder_interrupt_cb g_interrupt_cb = NULL; static audio_in_h g_audio_h; +#if 0 static sound_stream_info_h g_stream_info_h; +#endif static vcp_audio_type_e g_audio_type; -- 2.7.4 From 014ddb4fe6ac5ea69f2ecc5ea6cf1c2d0da2ea91 Mon Sep 17 00:00:00 2001 From: Wonnam Jang Date: Mon, 24 Oct 2016 16:58:24 +0900 Subject: [PATCH 08/16] Check manager client is available or not when vcd start, stop, cancel Change-Id: I1e9eb235ab56bea17fc80b856618ddf6d6b07644 Signed-off-by: Wonnam Jang --- server/vcd_server.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/server/vcd_server.c b/server/vcd_server.c index 843b587..632eb4f 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -1525,6 +1525,10 @@ int vcd_server_mgr_start(vcd_recognition_mode_e recognition_mode, bool exclusive SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Current state is not ready"); return VCD_ERROR_INVALID_STATE; } + if (-1 != vcd_client_manager_get_pid()) { + SLOG(LOG_DEBUG, TAG_VCD, "[Server] Manager is NOT available."); + return VCD_ERROR_OPERATION_FAILED; + } SLOG(LOG_DEBUG, TAG_VCD, "[Server] set recognition mode = %d", recognition_mode); vcd_client_set_recognition_mode(recognition_mode); @@ -1574,6 +1578,10 @@ int vcd_server_mgr_stop() SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Current state is not recording"); return VCD_ERROR_INVALID_STATE; } + if (-1 != vcd_client_manager_get_pid()) { + SLOG(LOG_DEBUG, TAG_VCD, "[Server] Manager is NOT available."); + return VCD_ERROR_OPERATION_FAILED; + } /* 2. Stop recorder */ vcd_recorder_stop(); @@ -1599,6 +1607,10 @@ int vcd_server_mgr_cancel() SLOG(LOG_WARN, TAG_VCD, "[Server ERROR] Current state is not recording or processing"); return VCD_ERROR_INVALID_STATE; } + if (-1 != vcd_client_manager_get_pid()) { + SLOG(LOG_DEBUG, TAG_VCD, "[Server] Manager is NOT available."); + return VCD_ERROR_OPERATION_FAILED; + } if (g_restart_timer != NULL) { SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Delete restart engine timer"); -- 2.7.4 From 96adf6f4fd7a68d6780a0cc6245cd60c5fad16b5 Mon Sep 17 00:00:00 2001 From: Kwangyoun Kim Date: Fri, 28 Oct 2016 21:40:19 +0900 Subject: [PATCH 09/16] Fix foreground app check logic via focus info Change-Id: Iba5dbadf9d658e741ede8c70c41ecad192d1c452 --- CMakeLists.txt | 4 ++-- client/vc_widget.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ packaging/voice-control.spec | 1 + server/vcd_server.c | 6 +++--- 4 files changed, 50 insertions(+), 5 deletions(-) mode change 100755 => 100644 client/vc_widget.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 38fc3c6..add3b74 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,12 +42,12 @@ INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/include") INCLUDE(FindPkgConfig) IF("${_TV_PRODUCT}" STREQUAL "TRUE") pkg_check_modules(pkgs REQUIRED - aul capi-appfw-application capi-appfw-app-manager capi-base-common capi-media-audio-io capi-media-sound-manager + aul capi-appfw-application capi-appfw-app-manager capi-base-common capi-media-audio-io capi-media-sound-manager ecore-wayland capi-network-bluetooth capi-system-info cynara-client cynara-session dbus-1 db-util dlog ecore glib-2.0 json-glib-1.0 libtzplatform-config libxml-2.0 sqlite3 vconf #msfapi ) ELSE() pkg_check_modules(pkgs REQUIRED - aul capi-appfw-application capi-appfw-app-manager capi-base-common capi-media-audio-io capi-media-sound-manager + aul capi-appfw-application capi-appfw-app-manager capi-base-common capi-media-audio-io capi-media-sound-manager ecore-wayland capi-system-info cynara-client cynara-session dbus-1 db-util dlog ecore glib-2.0 json-glib-1.0 libtzplatform-config libxml-2.0 sqlite3 vconf ) ENDIF() diff --git a/client/vc_widget.c b/client/vc_widget.c old mode 100755 new mode 100644 index e7a9ed1..6714f40 --- a/client/vc_widget.c +++ b/client/vc_widget.c @@ -14,6 +14,8 @@ * limitations under the License. */ +#include +#include #include "vc_cmd_db.h" #include "vc_command.h" #include "vc_config_mgr.h" @@ -220,6 +222,33 @@ int vc_widget_deinitialize() return VC_ERROR_NONE; } +static Eina_Bool __focus_changed_cb(void *data, int type, void *event) +{ + SLOG(LOG_DEBUG, TAG_VCW, "===== Focus changed"); + + int ret; + if (ECORE_WL_EVENT_FOCUS_IN == type) { + SLOG(LOG_DEBUG, TAG_VCW, "===== Set foreground"); + ret = vc_widget_dbus_set_foreground(getpid(), true); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to set foreground (true) : %d", ret); + } + } else if (ECORE_WL_EVENT_FOCUS_OUT == type) { + SLOG(LOG_DEBUG, TAG_VCW, "===== Set background"); + ret = vc_widget_dbus_set_foreground(getpid(), false); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to set foreground (false) : %d", ret); + } + } else { + SLOG(LOG_DEBUG, TAG_VCW, "===== type(%d) is NOT valid", type); + } + + SLOG(LOG_DEBUG, TAG_VCW, "====="); + SLOG(LOG_DEBUG, TAG_VCW, ""); + + return ECORE_CALLBACK_RENEW; +} + static Eina_Bool __vc_widget_connect_daemon(void *data) { /* Send hello */ @@ -257,6 +286,21 @@ static Eina_Bool __vc_widget_connect_daemon(void *data) vc_widget_client_set_service_state(g_vc_w, (vc_service_state_e)service_state); + ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_IN, __focus_changed_cb, NULL); + ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_OUT, __focus_changed_cb, NULL); + + char appid[255] = {'\0',}; + aul_app_get_appid_bypid(getpid(), appid, sizeof(appid)); + + int status = aul_app_get_status(appid); + if (status == STATUS_FOCUS) { + SLOG(LOG_DEBUG, TAG_VCW, "===== Set foreground"); + ret = vc_widget_dbus_set_foreground(getpid(), true); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to set foreground (true) : %d", ret); + } + } + vc_widget_client_set_state(g_vc_w, VC_STATE_READY); ecore_timer_add(0, __vc_widget_notify_state_changed, g_vc_w); diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index 8e185dd..321fa0e 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -24,6 +24,7 @@ BuildRequires: pkgconfig(dbus-1) BuildRequires: pkgconfig(db-util) BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(ecore) +BuildRequires: pkgconfig(ecore-wayland) BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(json-glib-1.0) BuildRequires: pkgconfig(libtzplatform-config) diff --git a/server/vcd_server.c b/server/vcd_server.c index 632eb4f..2baf934 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -1525,7 +1525,7 @@ int vcd_server_mgr_start(vcd_recognition_mode_e recognition_mode, bool exclusive SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Current state is not ready"); return VCD_ERROR_INVALID_STATE; } - if (-1 != vcd_client_manager_get_pid()) { + if (-1 == vcd_client_manager_get_pid()) { SLOG(LOG_DEBUG, TAG_VCD, "[Server] Manager is NOT available."); return VCD_ERROR_OPERATION_FAILED; } @@ -1578,7 +1578,7 @@ int vcd_server_mgr_stop() SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Current state is not recording"); return VCD_ERROR_INVALID_STATE; } - if (-1 != vcd_client_manager_get_pid()) { + if (-1 == vcd_client_manager_get_pid()) { SLOG(LOG_DEBUG, TAG_VCD, "[Server] Manager is NOT available."); return VCD_ERROR_OPERATION_FAILED; } @@ -1607,7 +1607,7 @@ int vcd_server_mgr_cancel() SLOG(LOG_WARN, TAG_VCD, "[Server ERROR] Current state is not recording or processing"); return VCD_ERROR_INVALID_STATE; } - if (-1 != vcd_client_manager_get_pid()) { + if (-1 == vcd_client_manager_get_pid()) { SLOG(LOG_DEBUG, TAG_VCD, "[Server] Manager is NOT available."); return VCD_ERROR_OPERATION_FAILED; } -- 2.7.4 From 24f4be008ab25b1a66b6a624aad8a0dfcc6df9c6 Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Wed, 2 Nov 2016 11:30:21 +0900 Subject: [PATCH 10/16] Add descriptions for ACR and Fix dbus arg type Change-Id: I4749000ab5aea52f18096344ffab682a80bb4b3b Signed-off-by: sooyeon.kim --- client/vc_mgr_dbus.c | 6 +++--- include/voice_control_common.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/client/vc_mgr_dbus.c b/client/vc_mgr_dbus.c index a4339cb..9c70c07 100644 --- a/client/vc_mgr_dbus.c +++ b/client/vc_mgr_dbus.c @@ -221,7 +221,7 @@ static Eina_Bool vc_mgr_listener_event_callback(void* data, Ecore_Fd_Handler *fd } SLOG(LOG_DEBUG, TAG_VCM, "<<<< foreground changed : pid(%d) value(%s)", pid, value ? "true" : "false"); - + __vc_mgr_cb_set_foreground(pid, (bool)value); SLOG(LOG_DEBUG, TAG_VCM, "====="); SLOG(LOG_DEBUG, TAG_VCM, " "); @@ -1595,8 +1595,8 @@ int vc_mgr_dbus_request_start(int pid, int recognition_mode, bool exclusive_comm pid, recognition_mode, exclusive_command_option, start_by_client); } - int exclusive = exclusive_command_option; - int by = start_by_client; + int exclusive = (int)exclusive_command_option; + int by = (int)start_by_client; dbus_message_append_args(msg, DBUS_TYPE_INT32, &pid, diff --git a/include/voice_control_common.h b/include/voice_control_common.h index d8d4043..7352104 100644 --- a/include/voice_control_common.h +++ b/include/voice_control_common.h @@ -51,9 +51,9 @@ typedef enum { VC_ERROR_ITERATION_END = TIZEN_ERROR_VOICE_CONTROL | 0x016, /**< List reached end */ VC_ERROR_EMPTY = TIZEN_ERROR_VOICE_CONTROL | 0x017, /**< List empty */ VC_ERROR_SERVICE_RESET = TIZEN_ERROR_VOICE_CONTROL | 0x018, /**< Service daemon reset @if MOBILE (Since 3.0) @endif */ - VC_ERROR_IN_PROGRESS_TO_READY = TIZEN_ERROR_VOICE_CONTROL | 0x019, - VC_ERROR_IN_PROGRESS_TO_RECORDING = TIZEN_ERROR_VOICE_CONTROL | 0x020, - VC_ERROR_IN_PROGRESS_TO_PROCESSING = TIZEN_ERROR_VOICE_CONTROL | 0x021 + VC_ERROR_IN_PROGRESS_TO_READY = TIZEN_ERROR_VOICE_CONTROL | 0x019, /**< In process to ready @if MOBILE (Since 3.0) @endif */ + VC_ERROR_IN_PROGRESS_TO_RECORDING = TIZEN_ERROR_VOICE_CONTROL | 0x020, /**< In process to recording @if MOBILE (Since 3.0) @endif */ + VC_ERROR_IN_PROGRESS_TO_PROCESSING = TIZEN_ERROR_VOICE_CONTROL | 0x021 /**< In process to processing @if MOBILE (Since 3.0) @endif */ } vc_error_e; /** -- 2.7.4 From 2b449313081f7e7fd255b09cd67f9c6166a0bf36 Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Wed, 2 Nov 2016 17:21:26 +0900 Subject: [PATCH 11/16] Fix versions of new enums Change-Id: I4268e1bd9d78f14f067533bcb2b218934316090b Signed-off-by: sooyeon.kim --- common/vc_cmd_db.h | 2 +- include/voice_control_common.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/common/vc_cmd_db.h b/common/vc_cmd_db.h index c580ce2..b7a97df 100644 --- a/common/vc_cmd_db.h +++ b/common/vc_cmd_db.h @@ -40,7 +40,7 @@ typedef enum { VC_DB_ERROR_OPERATION_REJECTED = TIZEN_ERROR_VOICE_CONTROL | 0x015, /**< Operation rejected */ VC_DB_ERROR_ITERATION_END = TIZEN_ERROR_VOICE_CONTROL | 0x016, /**< List reached end */ VC_DB_ERROR_EMPTY = TIZEN_ERROR_VOICE_CONTROL | 0x017, /**< List empty */ - VC_DB_ERROR_SERVICE_RESET = TIZEN_ERROR_VOICE_CONTROL | 0x018 /**< Service daemon reset @if MOBILE (Since 3.0) @endif */ + VC_DB_ERROR_SERVICE_RESET = TIZEN_ERROR_VOICE_CONTROL | 0x018 /**< Service daemon reset (Since 3.0) */ } vc_db_error_e; typedef struct _deactivated_app_s { diff --git a/include/voice_control_common.h b/include/voice_control_common.h index 7352104..28cee37 100644 --- a/include/voice_control_common.h +++ b/include/voice_control_common.h @@ -50,10 +50,10 @@ typedef enum { VC_ERROR_OPERATION_REJECTED = TIZEN_ERROR_VOICE_CONTROL | 0x015, /**< Operation rejected */ VC_ERROR_ITERATION_END = TIZEN_ERROR_VOICE_CONTROL | 0x016, /**< List reached end */ VC_ERROR_EMPTY = TIZEN_ERROR_VOICE_CONTROL | 0x017, /**< List empty */ - VC_ERROR_SERVICE_RESET = TIZEN_ERROR_VOICE_CONTROL | 0x018, /**< Service daemon reset @if MOBILE (Since 3.0) @endif */ - VC_ERROR_IN_PROGRESS_TO_READY = TIZEN_ERROR_VOICE_CONTROL | 0x019, /**< In process to ready @if MOBILE (Since 3.0) @endif */ - VC_ERROR_IN_PROGRESS_TO_RECORDING = TIZEN_ERROR_VOICE_CONTROL | 0x020, /**< In process to recording @if MOBILE (Since 3.0) @endif */ - VC_ERROR_IN_PROGRESS_TO_PROCESSING = TIZEN_ERROR_VOICE_CONTROL | 0x021 /**< In process to processing @if MOBILE (Since 3.0) @endif */ + VC_ERROR_SERVICE_RESET = TIZEN_ERROR_VOICE_CONTROL | 0x018, /**< Service daemon reset (Since 3.0) */ + VC_ERROR_IN_PROGRESS_TO_READY = TIZEN_ERROR_VOICE_CONTROL | 0x019, /**< In process to ready (Since 3.0) */ + VC_ERROR_IN_PROGRESS_TO_RECORDING = TIZEN_ERROR_VOICE_CONTROL | 0x020, /**< In process to recording (Since 3.0) */ + VC_ERROR_IN_PROGRESS_TO_PROCESSING = TIZEN_ERROR_VOICE_CONTROL | 0x021 /**< In process to processing (Since 3.0) */ } vc_error_e; /** -- 2.7.4 From fab247c6f176db2dca6c0c7ef5eb095b07c30780 Mon Sep 17 00:00:00 2001 From: Kwangyoun Kim Date: Thu, 3 Nov 2016 09:47:44 +0900 Subject: [PATCH 12/16] Fix foreground check logic Change-Id: Iaa3669707d0ee7cc1b6820b56dd4f616ebddf0fe --- client/vc.c | 44 ++++++++++++++++++++++++++++---------------- client/vc_widget.c | 16 ++++++++++++++-- 2 files changed, 42 insertions(+), 18 deletions(-) diff --git a/client/vc.c b/client/vc.c index 46ef551..8ea8acc 100644 --- a/client/vc.c +++ b/client/vc.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -42,6 +43,9 @@ static Ecore_Timer* g_connect_timer = NULL; +static Ecore_Event_Handler* g_focus_in_handler = NULL; +static Ecore_Event_Handler* g_focus_out_handler = NULL; + static vc_h g_vc = NULL; static int g_daemon_pid = 0; @@ -233,13 +237,12 @@ static Eina_Bool __notify_auth_changed_cb(void *data) return EINA_FALSE; } -static int __vc_app_state_changed_cb(int app_state, void *data) +static Eina_Bool __focus_changed_cb(void *data, int type, void *event) { - int ret = -1; - SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] app state changed"); + SLOG(LOG_DEBUG, TAG_VCC, "===== Focus changed"); - /* Set current pid */ - if (STATUS_VISIBLE == app_state) { + int ret; + if (ECORE_WL_EVENT_FOCUS_IN == type) { SLOG(LOG_DEBUG, TAG_VCC, "===== Set foreground"); ret = vc_dbus_set_foreground(getpid(), true); if (0 != ret) { @@ -262,8 +265,8 @@ static int __vc_app_state_changed_cb(int app_state, void *data) /* notify auth changed cb */ ecore_timer_add(0, __notify_auth_changed_cb, NULL); } - } else if (STATUS_BG == app_state) { - SLOG(LOG_DEBUG, TAG_VCC, "===== Set background"); + } else if (ECORE_WL_EVENT_FOCUS_OUT == type) { + SLOG(LOG_DEBUG, TAG_VCW, "===== Set background"); ret = vc_dbus_set_foreground(getpid(), false); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set foreground (false) : %d", ret); @@ -286,13 +289,13 @@ static int __vc_app_state_changed_cb(int app_state, void *data) ecore_timer_add(0, __notify_auth_changed_cb, NULL); } } else { - SLOG(LOG_DEBUG, TAG_VCC, "===== App state is NOT valid"); + SLOG(LOG_DEBUG, TAG_VCC, "===== type(%d) is NOT valid", type); } SLOG(LOG_DEBUG, TAG_VCC, "====="); - SLOG(LOG_DEBUG, TAG_VCC, " "); + SLOG(LOG_DEBUG, TAG_VCC, ""); - return 0; + return ECORE_CALLBACK_RENEW; } int vc_initialize(void) @@ -378,6 +381,14 @@ static void __vc_internal_unprepare(void) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request finalize : %s", __vc_get_error_code(ret)); } + if (NULL != g_focus_in_handler) { + ecore_event_handler_del(g_focus_in_handler); + g_focus_in_handler = NULL; + } + if (NULL != g_focus_out_handler) { + ecore_event_handler_del(g_focus_out_handler); + g_focus_out_handler = NULL; + } ret = vc_cmd_parser_delete_file(getpid(), VC_COMMAND_TYPE_FOREGROUND); if (0 != ret) @@ -492,13 +503,14 @@ static Eina_Bool __vc_connect_daemon(void *data) g_connect_timer = NULL; - ret = aul_add_status_local_cb(__vc_app_state_changed_cb, NULL); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set app stae changed callback"); - } + g_focus_in_handler = ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_IN, __focus_changed_cb, NULL); + g_focus_out_handler = ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_OUT, __focus_changed_cb, NULL); + + char appid[255] = {'\0',}; + aul_app_get_appid_bypid(getpid(), appid, sizeof(appid)); - int status = aul_app_get_status_bypid(getpid()); - if (STATUS_FOCUS == status || STATUS_VISIBLE == status) { + int status = aul_app_get_status(appid); + if (STATUS_FOCUS == status) { SLOG(LOG_DEBUG, TAG_VCC, "===== Set foreground"); ret = vc_dbus_set_foreground(getpid(), true); if (0 != ret) { diff --git a/client/vc_widget.c b/client/vc_widget.c index 6714f40..3089ab4 100644 --- a/client/vc_widget.c +++ b/client/vc_widget.c @@ -32,6 +32,9 @@ static Ecore_Timer* g_w_connect_timer = NULL; +static Ecore_Event_Handler* g_focus_in_handler = NULL; +static Ecore_Event_Handler* g_focus_out_handler = NULL; + static Ecore_Timer* g_w_start_timer = NULL; static Ecore_Timer* g_w_tooltip_timer = NULL; @@ -162,6 +165,15 @@ static void __vc_widget_internal_unprepare() SLOG(LOG_WARN, TAG_VCW, "[ERROR] Fail to request finalize : %s", __vc_widget_get_error_code(ret)); } + if (NULL != g_focus_in_handler) { + ecore_event_handler_del(g_focus_in_handler); + g_focus_in_handler = NULL; + } + if (NULL != g_focus_out_handler) { + ecore_event_handler_del(g_focus_out_handler); + g_focus_out_handler = NULL; + } + ret = vc_cmd_parser_delete_file(getpid(), VC_COMMAND_TYPE_WIDGET); if (0 != ret) SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to delete file, type(%d), ret(%d)", VC_COMMAND_TYPE_WIDGET, ret); @@ -286,8 +298,8 @@ static Eina_Bool __vc_widget_connect_daemon(void *data) vc_widget_client_set_service_state(g_vc_w, (vc_service_state_e)service_state); - ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_IN, __focus_changed_cb, NULL); - ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_OUT, __focus_changed_cb, NULL); + g_focus_in_handler = ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_IN, __focus_changed_cb, NULL); + g_focus_out_handler = ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_OUT, __focus_changed_cb, NULL); char appid[255] = {'\0',}; aul_app_get_appid_bypid(getpid(), appid, sizeof(appid)); -- 2.7.4 From 69b680698c6e946fd93321c1a672e71e30282b8e Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Thu, 3 Nov 2016 10:49:25 +0900 Subject: [PATCH 13/16] Fix descriptions and Add documents for ACR-796 Change-Id: I2c5039dc69366223093313ff12333bff0ba91512 Signed-off-by: sooyeon.kim --- client/vc.c | 2 +- common/vc_command.c | 9 --------- common/vc_command.h | 16 --------------- doc/uix_vc_doc.h | 29 +++++++++++++++++++++++--- include/voice_control.h | 20 +++++++++--------- include/voice_control_command.h | 37 +++++++++++++++++++++++++++++++--- include/voice_control_command_expand.h | 2 +- include/voice_control_common.h | 6 +++--- 8 files changed, 76 insertions(+), 45 deletions(-) diff --git a/client/vc.c b/client/vc.c index 8ea8acc..b87cf54 100644 --- a/client/vc.c +++ b/client/vc.c @@ -2048,7 +2048,7 @@ int vc_set_invocation_name(const char* name) return ret; } -int vc_dialog(const char* disp_text, const char* utt_text, bool auto_start) +int vc_request_dialog(const char* disp_text, const char* utt_text, bool auto_start) { vc_state_e state; diff --git a/common/vc_command.c b/common/vc_command.c index c37287e..6a0c91d 100755 --- a/common/vc_command.c +++ b/common/vc_command.c @@ -931,9 +931,6 @@ int vc_cmd_get_unfixed_command(vc_cmd_h vc_command, char** command) if (0 != __vc_cmd_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } - if (0 != __vc_cmd_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } if (NULL == vc_command || NULL == command) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid handle "); @@ -1108,9 +1105,6 @@ int vc_cmd_set_format(vc_cmd_h vc_command, int format) if (0 != __vc_cmd_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } - if (0 != __vc_cmd_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } if (NULL == vc_command) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter "); @@ -1132,9 +1126,6 @@ int vc_cmd_get_format(vc_cmd_h vc_command, int* format) if (0 != __vc_cmd_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } - if (0 != __vc_cmd_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } if (NULL == vc_command || NULL == format) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter "); diff --git a/common/vc_command.h b/common/vc_command.h index c010c65..9f0bad5 100644 --- a/common/vc_command.h +++ b/common/vc_command.h @@ -162,22 +162,6 @@ int vc_cmd_set_fixed_command(vc_cmd_h vc_command, const char* fixed); int vc_cmd_get_fixed_command(vc_cmd_h vc_command, char** fixed); /** -* @brief Gets fixed command -* @since_tizen 3.0 -* -* @param[in] vc_command The command handle -* @param[out] fixed Fixed command -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_CMD_ERROR_NONE Successful -* @retval #VC_CMD_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_CMD_ERROR_NOT_SUPPORTED Not supported feature -* -* @see vc_cmd_set_unfixed_command() -*/ -int vc_cmd_get_unfixed_command(vc_cmd_h vc_command, char** command); - -/** * @brief Sets invocation name. * @since_tizen 3.0 * diff --git a/doc/uix_vc_doc.h b/doc/uix_vc_doc.h index 5cb9861..621b7de 100644 --- a/doc/uix_vc_doc.h +++ b/doc/uix_vc_doc.h @@ -40,9 +40,12 @@ * 4-3. Set command and type for command handle
* 4-4. Add command handle to command list
* 5. Set command list for recognition
- * 6. If an application wants to finish voice control,
- * 6-1. Destroy command and command list handle
- * 6-2. Deinitialize
+ * 6. Set an invocation name for an application
+ * 7. Get recognition results
+ * 8. Request the dialogue
+ * 9. If an application wants to finish voice control,
+ * 9-1. Destroy command and command list handle
+ * 9-2. Deinitialize
* * An application can obtain command handle from command list, and also get information from handle. * @@ -147,6 +150,16 @@ * * * + * vc_get_result() + * Ready + * + * + * + * vc_get_system_command_list() + * Ready + * + * + * * vc_set_command_list() * Ready * @@ -157,6 +170,16 @@ * * * + * vc_set_invocation_name() + * Ready + * + * + * + * vc_request_dialog() + * Ready + * + * + * * * vc_set_result_cb()
* vc_unset_result_cb()
diff --git a/include/voice_control.h b/include/voice_control.h index 4d9c51a..1adcfb7 100644 --- a/include/voice_control.h +++ b/include/voice_control.h @@ -269,16 +269,16 @@ int vc_get_service_state(vc_service_state_e* state); int vc_get_system_command_list(vc_cmd_list_h* vc_sys_cmd_list); /** - * @brief Sets invocation name. + * @brief Sets the invocation name. * @since_tizen 3.0 * @privlevel public * @privilege %http://tizen.org/privilege/recorder * - * @remarks Invocation name is used to activate background commands. The invocation name can be set as the application name or some words. - * For example, an application "Tizen Sample" has a background command, "Play music", and the invocation name of the application is set as "Tizen Sample". + * @remarks Invocation name is used to activate background commands. The invocation name can be the same as the application name or any other phrase. + * For example, an application "Tizen Sample" has a background command, "Play music", and the invocation name of the application is set to "Tizen Sample". * In order to activate the background command, users can say "Tizen Sample, Play music". - * The invocation name is dependent on the setting language. For example, if the setting language is "en_US"(English), the invocation name is also "en_US". - * If the setting language is "ja_JP"(Japanese) and the invocation name is "en_US", the invocation name will not be recognized. + * The invocation name is dependent on the current language. For example, if the current language is "en_US"(English), the invocation name is also "en_US". + * If the current language is "ja_JP"(Japanese) and the invocation name is "en_US", the invocation name will not be recognized. * This function should be called before vc_set_command_list(). * * @param[in] name Invocation name that an application wants to be invoked by @@ -298,16 +298,18 @@ int vc_set_invocation_name(const char* name); /** * @brief Requests to start the dialogue. - * @details Using this function, the developer can transfer texts, for starting the dialogue, to the framework. - * There are two types of texts. One is a text for displaying, and the other is that for uttering. + * @details Using this function, the developer can request starting the dialogue to the framework. + * When the developer requests the dialogue, two types of texts, @a disp_text and @a utt_text, can be sent by this function. + * @a disp_text is a text for displaying, and @a utt_text is that for uttering. * For example, if @a disp_text is "October 10th" and @a utt_text is "Today is October 10th.", "October 10th" will be displayed on the screen and "Today is October 10th." will be spoken. - * Also, the developer can set whether the dialogue restarts automatically or not, using @a auto_start. + * Also, the developer can set whether the dialogue starts automatically or not, using @a auto_start. + * If the developer sets @a auto_start as @c true, the framework will start to record next speech and continue the dialogue. * * @since_tizen 3.0 * @privlevel public * @privilege %http://tizen.org/privilege/recorder * - * @remarks If @a auto_start is @c true, the recognition will start again. In this case, 4 times can be restarted. + * @remarks If @a auto_start is @c true, the recognition will start again. In this case, it can be restarted up to 4 times. * * @param[in] disp_text Text to be displayed on the screen * @param[in] utt_text Text to be spoken diff --git a/include/voice_control_command.h b/include/voice_control_command.h index 8a7ee52..17aa455 100644 --- a/include/voice_control_command.h +++ b/include/voice_control_command.h @@ -35,6 +35,37 @@ extern "C" /** + * @brief Definition for fixed command format + * @since_tizen 3.0 + */ +#define VC_CMD_FORMAT_FIXED 0 + +/** + * @brief Definition for fixed and variable fixed command format + * @since_tizen 3.0 + */ +#define VC_CMD_FORMAT_FIXED_AND_VFIXED 1 + +/** + * @brief Definition for variable fixed and fixed command format + * @since_tizen 3.0 + */ +#define VC_CMD_FORMAT_VFIXED_AND_FIXED 2 + +/** + * @brief Definition for fixed and non-fixed command format + * @since_tizen 3.0 + */ +#define VC_CMD_FORMAT_FIXED_AND_NONFIXED 3 + +/** + * @brief Definition for non-fixed and fixed command format + * @since_tizen 3.0 + */ +#define VC_CMD_FORMAT_NONFIXED_AND_FIXED 4 + + +/** * @brief The voice command handle. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif */ @@ -168,7 +199,7 @@ int vc_cmd_list_remove(vc_cmd_list_h vc_cmd_list, vc_cmd_h vc_command); int vc_cmd_list_foreach_commands(vc_cmd_list_h vc_cmd_list, vc_cmd_list_cb callback, void* user_data); /** - * @brief Retrieves all commands on the system command list using callback function. + * @brief Retrieves all commands on the system command list using a callback function. * @since_tizen 3.0 * * @param[in] callback Callback function to invoke @@ -355,8 +386,8 @@ int vc_cmd_get_command(vc_cmd_h vc_command, char** command); * @brief Gets the unfixed command. * @since_tizen 3.0 * - * @remark After this function is successfully conducted, the @a command must be released with free() if it is not NULL. - * If the command in @a vc_command is NULL, @a command will be also NULL. + * @remark If the function succeeds, the @a command must be released with free() if it is not NULL. + * If the command of the given @a vc_command is NULL (@a vc_command is NOT NULL), @a command will be also NULL. * This function should be used for commands which have non-fixed format. * * @param[in] vc_command The command handle diff --git a/include/voice_control_command_expand.h b/include/voice_control_command_expand.h index 2714301..62d83ad 100755 --- a/include/voice_control_command_expand.h +++ b/include/voice_control_command_expand.h @@ -33,7 +33,7 @@ extern "C" * @since_tizen 3.0 */ typedef enum { - VC_CMD_FORMAT_FIXED = 0, /**< fixed command only */ + VC_CMD_FORMAT_FIXED = 0, /**< Fixed command only */ VC_CMD_FORMAT_FIXED_AND_VFIXED, /**< Fixed + variable fixed command */ VC_CMD_FORMAT_VFIXED_AND_FIXED, /**< Variable fixed + fixed command */ VC_CMD_FORMAT_FIXED_AND_NONFIXED, /**< Fixed + non fixed command */ diff --git a/include/voice_control_common.h b/include/voice_control_common.h index 28cee37..c81f5df 100644 --- a/include/voice_control_common.h +++ b/include/voice_control_common.h @@ -51,9 +51,9 @@ typedef enum { VC_ERROR_ITERATION_END = TIZEN_ERROR_VOICE_CONTROL | 0x016, /**< List reached end */ VC_ERROR_EMPTY = TIZEN_ERROR_VOICE_CONTROL | 0x017, /**< List empty */ VC_ERROR_SERVICE_RESET = TIZEN_ERROR_VOICE_CONTROL | 0x018, /**< Service daemon reset (Since 3.0) */ - VC_ERROR_IN_PROGRESS_TO_READY = TIZEN_ERROR_VOICE_CONTROL | 0x019, /**< In process to ready (Since 3.0) */ - VC_ERROR_IN_PROGRESS_TO_RECORDING = TIZEN_ERROR_VOICE_CONTROL | 0x020, /**< In process to recording (Since 3.0) */ - VC_ERROR_IN_PROGRESS_TO_PROCESSING = TIZEN_ERROR_VOICE_CONTROL | 0x021 /**< In process to processing (Since 3.0) */ + VC_ERROR_IN_PROGRESS_TO_READY = TIZEN_ERROR_VOICE_CONTROL | 0x019, /**< In progress to ready (Since 3.0) */ + VC_ERROR_IN_PROGRESS_TO_RECORDING = TIZEN_ERROR_VOICE_CONTROL | 0x020, /**< In progress to recording (Since 3.0) */ + VC_ERROR_IN_PROGRESS_TO_PROCESSING = TIZEN_ERROR_VOICE_CONTROL | 0x021 /**< In progress to processing (Since 3.0) */ } vc_error_e; /** -- 2.7.4 From 78098042809a1dcf538b751b3c320c6186d1f02b Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Wed, 9 Nov 2016 17:52:17 +0900 Subject: [PATCH 14/16] Change the names of definitions in voice_control_command.h Change-Id: I7930bf445a98c59b3a9abc0345e3d48f55c4e3d9 Signed-off-by: sooyeon.kim --- client/vc_mgr.c | 12 ++++++------ include/voice_control_command.h | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/client/vc_mgr.c b/client/vc_mgr.c index ab5c2f4..a78e2b5 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -627,12 +627,12 @@ int vc_mgr_is_command_format_supported(vc_cmd_format_e format, bool* support) } switch (format) { - case VC_CMD_FORMAT_FIXED: *support = true; break; - case VC_CMD_FORMAT_FIXED_AND_VFIXED: *support = true; break; - case VC_CMD_FORMAT_VFIXED_AND_FIXED: *support = true; break; - case VC_CMD_FORMAT_FIXED_AND_NONFIXED: *support = non_fixed_support; break; - case VC_CMD_FORMAT_NONFIXED_AND_FIXED: *support = non_fixed_support; break; - default: *support = false; break; + case VC_CMD_FORMAT_FIXED: *support = true; break; + case VC_CMD_FORMAT_FIXED_AND_VFIXED: *support = true; break; + case VC_CMD_FORMAT_VFIXED_AND_FIXED: *support = true; break; + case VC_CMD_FORMAT_FIXED_AND_NONFIXED: *support = non_fixed_support; break; + case VC_CMD_FORMAT_NONFIXED_AND_FIXED: *support = non_fixed_support; break; + default: *support = false; break; } SLOG(LOG_ERROR, TAG_VCM, "[DEBUG] Format(%d) support(%s)", format, *support ? "true" : "false"); diff --git a/include/voice_control_command.h b/include/voice_control_command.h index 17aa455..8073991 100644 --- a/include/voice_control_command.h +++ b/include/voice_control_command.h @@ -38,31 +38,31 @@ extern "C" * @brief Definition for fixed command format * @since_tizen 3.0 */ -#define VC_CMD_FORMAT_FIXED 0 +#define VC_COMMAND_FORMAT_FIXED 0 /** * @brief Definition for fixed and variable fixed command format * @since_tizen 3.0 */ -#define VC_CMD_FORMAT_FIXED_AND_VFIXED 1 +#define VC_COMMAND_FORMAT_FIXED_AND_VFIXED 1 /** * @brief Definition for variable fixed and fixed command format * @since_tizen 3.0 */ -#define VC_CMD_FORMAT_VFIXED_AND_FIXED 2 +#define VC_COMMAND_FORMAT_VFIXED_AND_FIXED 2 /** * @brief Definition for fixed and non-fixed command format * @since_tizen 3.0 */ -#define VC_CMD_FORMAT_FIXED_AND_NONFIXED 3 +#define VC_COMMAND_FORMAT_FIXED_AND_NONFIXED 3 /** * @brief Definition for non-fixed and fixed command format * @since_tizen 3.0 */ -#define VC_CMD_FORMAT_NONFIXED_AND_FIXED 4 +#define VC_COMMAND_FORMAT_NONFIXED_AND_FIXED 4 /** -- 2.7.4 From ea8f546e6a15072e769612d200e81b8cba2165fe Mon Sep 17 00:00:00 2001 From: Wonnam Jang Date: Thu, 10 Nov 2016 12:03:47 +0900 Subject: [PATCH 15/16] Fix memory leak issue Change-Id: Ic31fc6bd4f4fa49e6ffac2bb165238f1c41c5293 Signed-off-by: Wonnam Jang --- common/vc_info_parser.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/vc_info_parser.c b/common/vc_info_parser.c index 83847cf..c4fc2d4 100644 --- a/common/vc_info_parser.c +++ b/common/vc_info_parser.c @@ -191,6 +191,7 @@ int vc_info_parser_get_demandable_clients(GSList** client_list) if (NULL == temp_client) { SLOG(LOG_ERROR, vc_info_tag(), "[ERROR] Memory alloc error!!"); + xmlFreeDoc(doc); return -1; } @@ -279,6 +280,7 @@ int vc_info_parser_set_demandable_client(const char* filepath) int ret = xmlSaveFormatFile(VC_RUNTIME_INFO_DEMANDABLE_LIST, doc, 1); SLOG(LOG_DEBUG, vc_info_tag(), "Save demandable file info : %d", ret); + xmlFreeDoc(doc); return 0; } @@ -561,6 +563,7 @@ int vc_info_parser_get_client_info(GSList** client_info_list) if (NULL == client) { SLOG(LOG_ERROR, vc_info_tag(), "[ERROR] Memory alloc error!!"); + xmlFreeDoc(doc); return -1; } -- 2.7.4 From f19a02ea84329a2cdc48fb275921651b79e795ac Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Mon, 14 Nov 2016 13:51:13 +0900 Subject: [PATCH 16/16] Remove an api in voice_control_command.h Change-Id: I6da638f55fbcad17165b1f38053c21472816be5d Signed-off-by: sooyeon.kim --- include/voice_control_command.h | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/include/voice_control_command.h b/include/voice_control_command.h index 8073991..a6b48b1 100644 --- a/include/voice_control_command.h +++ b/include/voice_control_command.h @@ -199,25 +199,6 @@ int vc_cmd_list_remove(vc_cmd_list_h vc_cmd_list, vc_cmd_h vc_command); int vc_cmd_list_foreach_commands(vc_cmd_list_h vc_cmd_list, vc_cmd_list_cb callback, void* user_data); /** - * @brief Retrieves all commands on the system command list using a callback function. - * @since_tizen 3.0 - * - * @param[in] callback Callback function to invoke - * @param[in] user_data The user data to be passed to the callback function - * - * @return 0 on success, otherwise a negative error value - * @retval #VC_ERROR_NONE Successful - * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #VC_ERROR_PERMISSION_DENIED Permission denied - * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * - * @post This function invokes vc_cmd_list_cb() for each command. - * - * @see vc_cmd_list_cb() - */ -int vc_cmd_list_foreach_system_command(vc_cmd_list_cb callback, void* user_data); - -/** * @brief Moves index to first command. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * -- 2.7.4