Add API to get the assistant's name and enable status 86/203986/5
authorXie Ligang <ligang0.xie@samsung.com>
Thu, 18 Apr 2019 09:18:16 +0000 (17:18 +0800)
committerXie Ligang <ligang0.xie@samsung.com>
Fri, 19 Apr 2019 00:57:38 +0000 (08:57 +0800)
Change-Id: I7abe249d8245dcef0db68d26018aa902faa558dd
Signed-off-by: Xie Ligang <ligang0.xie@samsung.com>
client/ma.c
include/multi_assistant.h

index 0f201d8ef9d625b85789e8bf1f7fdf2f56b06f6c..33e4e87b2110bc861e63a03e07208bb9dba7554d 100644 (file)
@@ -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
index c033390e92096c6af07d96eb01d311de1b245c27..903f8d73019ce299b7be6e6df6d86c325cc068ef 100644 (file)
@@ -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