From: Xie Ligang Date: Thu, 18 Apr 2019 09:18:16 +0000 (+0800) Subject: Add API to get the assistant's name and enable status X-Git-Tag: submit/tizen/20190424.111132~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F86%2F203986%2F5;p=platform%2Fcore%2Fuifw%2Fmulti-assistant.git Add API to get the assistant's name and enable status Change-Id: I7abe249d8245dcef0db68d26018aa902faa558dd Signed-off-by: Xie Ligang --- diff --git a/client/ma.c b/client/ma.c index 0f201d8..33e4e87 100644 --- a/client/ma.c +++ b/client/ma.c @@ -39,7 +39,6 @@ typedef struct{ char app_id[MAX_ASSISTANT_INFO_STR_LEN]; char name[MAX_ASSISTANT_INFO_STR_LEN]; int cnt_lang; - bool enabled; }assistant_info_t; static assistant_info_t __assistant_info[MAX_ASSISTANT_NUM]; @@ -1351,12 +1350,13 @@ int ma_unset_wakeup_engine_command_cb(void) } bool __get_assistant_enable_status(const char* app_id, char* assistants) { - char* temp = strtok(assistants, ";"); + char* str_ptr = NULL; + char* temp = strtok_r(assistants, ";", &str_ptr); while(temp) { if (!strncmp(app_id, temp, MAX_ASSISTANT_INFO_STR_LEN)) { return true; } - temp = strtok(NULL, ";"); + temp = strtok_r(NULL, ";", &str_ptr); } return false; } @@ -1374,7 +1374,6 @@ int __get_assistant_info_cb(const char* app_id, const char* name, strncpy(__assistant_info[_assistant_info_index].name, name, MAX_ASSISTANT_INFO_STR_LEN); __assistant_info[_assistant_info_index].name[MAX_ASSISTANT_INFO_STR_LEN - 1] = '\0'; __assistant_info[_assistant_info_index].cnt_lang = cnt_lang; - __assistant_info[_assistant_info_index].enabled = __get_assistant_enable_status(app_id, vconf_get_str(APPID_URL));; _assistant_info_index++; } else { return -1; @@ -1403,12 +1402,32 @@ int ma_assistant_info_foreach_assistants(ma_assistant_info_list_cb callback, voi return res; } -int ma_assistant_info_get_app_id(ma_assistant_info_h handle, char **app_id) { - if (NULL == handle) +int ma_assistant_info_get_app_id(ma_assistant_info_h handle, char** app_id) { + if (NULL == handle || NULL == app_id) return MA_ERROR_INVALID_PARAMETER; assistant_info_t* info = (assistant_info_t*)handle; if (NULL == info->app_id) return MA_ERROR_NOT_SUPPORTED; *app_id = (char*)info->app_id; return MA_ERROR_NONE; +} + +int ma_assistant_info_get_enabled_status(ma_assistant_info_h handle, bool* status) { + if (NULL == handle || NULL == status) + return MA_ERROR_INVALID_PARAMETER; + assistant_info_t* info = (assistant_info_t*)handle; + if (NULL == info->app_id) + return MA_ERROR_NOT_SUPPORTED; + *status = __get_assistant_enable_status(info->app_id, vconf_get_str(APPID_URL)); + return MA_ERROR_NONE; +} + +int ma_assistant_info_get_name(ma_assistant_info_h handle, char** name) { + if (NULL == handle || NULL == name) + return MA_ERROR_INVALID_PARAMETER; + assistant_info_t* info = (assistant_info_t*)handle; + if (NULL == info->name) + return MA_ERROR_NOT_SUPPORTED; + *name = (char*)info->name; + return MA_ERROR_NONE; } \ No newline at end of file diff --git a/include/multi_assistant.h b/include/multi_assistant.h index c033390..903f8d7 100644 --- a/include/multi_assistant.h +++ b/include/multi_assistant.h @@ -503,7 +503,7 @@ int ma_assistant_info_foreach_assistants(ma_assistant_info_list_cb callback, voi * @since_tizen 5.5 * * @remarks You must not release @a app_id using free(). - * @param[in] handle The handle to the assistant's information + * @param[in] handle The handle to the assistant's information * @param[in] app_id The application ID of the given assistant handle * * @return @c 0 on success, otherwise a negative error value @@ -511,7 +511,37 @@ int ma_assistant_info_foreach_assistants(ma_assistant_info_list_cb callback, voi * @retval #MA_ERROR_NOT_SUPPORTED Not supported * @retval #MA_ERROR_INVALID_PARAMETER Invalid parameter */ -int ma_assistant_info_get_app_id(ma_assistant_info_h handle, char **app_id); +int ma_assistant_info_get_app_id(ma_assistant_info_h handle, char** app_id); + +/** + * @brief Retreives app id of the specific handle. + * @since_tizen 5.5 + * + * @remarks You must not release @a app_id using free(). + * @param[in] handle The handle to the assistant's information + * @param[in] status The enable status of the given assistant handle + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MA_ERROR_NONE Successful + * @retval #MA_ERROR_NOT_SUPPORTED Not supported + * @retval #MA_ERROR_INVALID_PARAMETER Invalid parameter + */ +int ma_assistant_info_get_enabled_status(ma_assistant_info_h handle, bool* status); + +/** + * @brief Retreives app id of the specific handle. + * @since_tizen 5.5 + * + * @remarks You must not release @a app_id using free(). + * @param[in] handle The handle to the assistant's information + * @param[in] name The application name of the given assistant handle + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MA_ERROR_NONE Successful + * @retval #MA_ERROR_NOT_SUPPORTED Not supported + * @retval #MA_ERROR_INVALID_PARAMETER Invalid parameter + */ +int ma_assistant_info_get_name(ma_assistant_info_h handle, char** name); #ifdef __cplusplus } #endif