bool multiple = false;
int res = MA_ERROR_NONE;
+ if (!app_id) {
+ LOGE("Invalid parameter");
+ return MA_ERROR_INVALID_PARAMETER;
+ }
+
res = ma_settings_is_multiple_mode(&multiple);
LOGI("multiple mode(%d)", multiple);
if (MA_ERROR_NONE != res) return res;
bool multiple = false;
int res = MA_ERROR_NONE;
+ if (!app_id) {
+ LOGE("Invalid parameter");
+ return MA_ERROR_INVALID_PARAMETER;
+ }
+
res = ma_settings_is_multiple_mode(&multiple);
LOGD("multiple mode(%d). Error(%x)", multiple, res);
if (MA_ERROR_NONE != res) return res;
- if (!multiple && app_id) {
+ if (!multiple) {
if (0 == vconf_set_str(DEFAULT_ASSISTANT_URL, app_id)) {
LOGI("appid: %s", app_id);
res = MA_ERROR_NONE;
int ma_settings_get_voice_assistant_enabled(const char* app_id, bool *enabled) {
bool multiple = false;
+
+ if (!enabled || !app_id) {
+ LOGE("Invalid parameter");
+ return MA_ERROR_INVALID_PARAMETER;
+ }
+
int res = ma_settings_is_multiple_mode(&multiple);
if (MA_ERROR_NONE != res) return res;
return MA_ERROR_NOT_SUPPORTED;
}
- if (!enabled || !app_id) {
- LOGE("Invalid parameter");
- return MA_ERROR_INVALID_PARAMETER;
- }
-
char* enabled_assistants = vconf_get_str(ENABLED_ASSISTANT_URL);
if (vconf_get_ext_errno() != VCONF_OK) {
LOGE("Operation Failed");
int ma_settings_set_voice_assistant_enabled(const char* app_id, bool enabled) {
bool multiple = false;
+ if (!app_id) {
+ LOGE("Invalid parameter");
+ return MA_ERROR_INVALID_PARAMETER;
+ }
+
int res = ma_settings_is_multiple_mode(&multiple);
if (MA_ERROR_NONE != res) return res;
LOGE("Not supported");
return MA_ERROR_NOT_SUPPORTED;
}
- if (NULL != app_id) {
- char* enabled_assistants = vconf_get_str(ENABLED_ASSISTANT_URL);
- if (enabled) {
- if (NULL != enabled_assistants) {
- char* tmp = strstr(enabled_assistants, app_id);
- if (tmp) {
- LOGE("Not supported");
- res = MA_ERROR_NOT_SUPPORTED;
+
+ char* enabled_assistants = vconf_get_str(ENABLED_ASSISTANT_URL);
+ if (enabled) {
+ if (NULL != enabled_assistants) {
+ char* tmp = strstr(enabled_assistants, app_id);
+ if (tmp) {
+ LOGE("Not supported");
+ res = MA_ERROR_NOT_SUPPORTED;
+ } else {
+ char assistants[MAX_LEN] = "";
+ snprintf(assistants, MAX_LEN, "%s%s;", enabled_assistants, app_id);
+ if (0 == vconf_set_str(ENABLED_ASSISTANT_URL, assistants)) {
+ res = MA_ERROR_NONE;
} else {
- char assistants[MAX_LEN] = "";
- snprintf(assistants, MAX_LEN, "%s%s;", enabled_assistants, app_id);
- if (0 == vconf_set_str(ENABLED_ASSISTANT_URL, assistants)) {
- res = MA_ERROR_NONE;
- } else {
- LOGE("Operation failed");
- res = MA_ERROR_OPERATION_FAILED;
- }
+ LOGE("Operation failed");
+ res = MA_ERROR_OPERATION_FAILED;
}
- } else {
- LOGE("Operation failed");
- res = MA_ERROR_OPERATION_FAILED;
}
} else {
- if (NULL != enabled_assistants) {
- char* tmp = strstr(enabled_assistants, app_id);
- if (tmp) {
- char assistants[MAX_LEN] = "";
- char old_assistants[MAX_LEN] = "";
- /*to prevent memory leak for cut the string enabled_assistants*/
- snprintf(old_assistants, MAX_LEN, "%s", enabled_assistants);
- char* rest = old_assistants;
- char* as = strtok_r(rest, ";", &rest);
- while (as) {
- if (strncmp(app_id, as, MAX_LEN)) {
- if ((strlen(as) + strlen(assistants) + 1) <= MAX_LEN) {
- strncat(assistants, as, strlen(as));
- strncat(assistants, ";", 1);
- } else {
- LOGE("Operation failed");
- res = MA_ERROR_OPERATION_FAILED;
- if (enabled_assistants) {
- free(enabled_assistants);
- }
- return res;
+ LOGE("Operation failed");
+ res = MA_ERROR_OPERATION_FAILED;
+ }
+ } else {
+ if (NULL != enabled_assistants) {
+ char* tmp = strstr(enabled_assistants, app_id);
+ if (tmp) {
+ char assistants[MAX_LEN] = "";
+ char old_assistants[MAX_LEN] = "";
+ /*to prevent memory leak for cut the string enabled_assistants*/
+ snprintf(old_assistants, MAX_LEN, "%s", enabled_assistants);
+ char* rest = old_assistants;
+ char* as = strtok_r(rest, ";", &rest);
+ while (as) {
+ if (strncmp(app_id, as, MAX_LEN)) {
+ if ((strlen(as) + strlen(assistants) + 1) <= MAX_LEN) {
+ strncat(assistants, as, strlen(as));
+ strncat(assistants, ";", 1);
+ } else {
+ LOGE("Operation failed");
+ res = MA_ERROR_OPERATION_FAILED;
+ if (enabled_assistants) {
+ free(enabled_assistants);
}
+ return res;
}
- as = strtok_r(rest, ";", &rest);
- }
- if (0 == vconf_set_str(ENABLED_ASSISTANT_URL, assistants)) {
- res = MA_ERROR_NONE;
- } else {
- LOGE("Operation failed");
- res = MA_ERROR_OPERATION_FAILED;
}
+ as = strtok_r(rest, ";", &rest);
+ }
+ if (0 == vconf_set_str(ENABLED_ASSISTANT_URL, assistants)) {
+ res = MA_ERROR_NONE;
} else {
- LOGE("Not support");
- res = MA_ERROR_NOT_SUPPORTED;
+ LOGE("Operation failed");
+ res = MA_ERROR_OPERATION_FAILED;
}
} else {
- LOGE("Operation failed");
- res = MA_ERROR_OPERATION_FAILED;
+ LOGE("Not support");
+ res = MA_ERROR_NOT_SUPPORTED;
}
+ } else {
+ LOGE("Operation failed");
+ res = MA_ERROR_OPERATION_FAILED;
}
- if (enabled_assistants) {
- free(enabled_assistants);
- }
- } else {
- LOGE("Engine not found");
- res = MA_ERROR_ENGINE_NOT_FOUND;
}
+ if (enabled_assistants) {
+ free(enabled_assistants);
+ }
+
return res;
}
bool multiple = false;
int res = MA_ERROR_NONE;
+ if (!app_id) {
+ LOGE("Invalid parameter");
+ return MA_ERROR_INVALID_PARAMETER;
+ }
+
res = ma_settings_is_multiple_mode(&multiple);
LOGD("multiple mode(%d). Error(%x)", multiple, res);
bool multiple = false;
int res = MA_ERROR_NONE;
+ if (!app_id) {
+ LOGE("Invalid parameter");
+ return MA_ERROR_INVALID_PARAMETER;
+ }
+
res = ma_settings_is_multiple_mode(&multiple);
LOGD("multiple mode(%d). Error(%x)", multiple, res);
if (MA_ERROR_NONE != res) return res;
- if (multiple && app_id) {
+ if (multiple) {
if (0 == vconf_set_str(DEFAULT_ASSISTANT_URL, app_id)) {
LOGI("Succeeded. app id(%s)", app_id);
res = MA_ERROR_NONE;
*
* @return @c 0 on success, otherwise a negative error value
* @retval #MA_ERROR_NONE Successful
+ * @retval #MA_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #MA_ERROR_OPERATION_FAILED Operation failed
*
* @param[out] multiple The current multiple mode of multi-assistant
* @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
* @retval #MA_ERROR_OPERATION_FAILED Operation failed
*
* @param[out] app_id The app id of the currently activated voice assistant
* @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
* @retval #MA_ERROR_OPERATION_FAILED Operation failed
*
* @param[in] app_id The app id of the voice assistant that need to be activated
* @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_ENGINE_NOT_FOUND Engine not found
+ * @retval #MA_ERROR_INVALID_PARAMETER Invalid parameter
*
* @param[in] app_id The app id of the voice assistant that need to be changed
* @param[in] enabled The voice assistant need to be enabled or not
* @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
* @retval #MA_ERROR_OPERATION_FAILED Operation failed
*
* @param[out] app_id The app id of the voice assistant currently set as default one
* @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
* @retval #MA_ERROR_OPERATION_FAILED Operation failed
*
* @param[in] app_id The app id of the voice assistant that need to set as default one