int vc_config_convert_error_code(vc_config_error_e code)
{
- if (code == VC_CONFIG_ERROR_NONE) return VC_ERROR_NONE;
+ if (code == VC_CONFIG_ERROR_NONE) return VC_CONFIG_ERROR_NONE;
if (code == VC_CONFIG_ERROR_OPERATION_FAILED) return VC_ERROR_OPERATION_FAILED;
if (code == VC_CONFIG_ERROR_INVALID_PARAMETER) return VC_ERROR_INVALID_PARAMETER;
if (code == VC_CONFIG_ERROR_ENGINE_NOT_FOUND) return VC_ERROR_ENGINE_NOT_FOUND;
return VC_CONFIG_ERROR_NONE;
}
-int __vc_config_mgr_check_and_set_default_engine_id(const char* engine_id)
+static int __vc_config_mgr_check_and_set_default_engine_id(const char* engine_id)
{
if (NULL == engine_id) {
SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Input parameter is NULL");
SLOG(LOG_DEBUG, vc_config_tag(), "Default engine is changed : %s", engineId.c_str());
if (0 != vc_parser_set_engine(engineId.c_str())) {
SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to save config");
- return -1;
+ return VC_CONFIG_ERROR_OPERATION_FAILED;
}
g_VoiceControlConfig->setEngineId(engineId.c_str());
- return VC_ERROR_NONE;
+ return VC_CONFIG_ERROR_NONE;
}
-bool __vc_config_mgr_check_lang_is_valid(const char* engine_id, const char* language)
+static bool __vc_config_mgr_check_lang_is_valid(const char* engine_id, const char* language)
{
if (NULL == engine_id || NULL == language) {
SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Input parameter is NULL");
return is_language_valid;
}
-int __vc_config_mgr_select_lang(const char* engine_id, char** language)
+static int __vc_config_mgr_select_lang(const char* engine_id, char** language)
{
if (NULL == engine_id || NULL == language) {
SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Input parameter is NULL");
g_VoiceControlEngines = nullptr;
}
-int __vc_config_mgr_get_engine_info()
+static int __vc_config_mgr_get_engine_info()
{
DIR *dp = NULL;
struct dirent *dirp = NULL;
if (filesize >= 512) {
SECURE_SLOG(LOG_ERROR, vc_config_tag(), "[CONFIG ERROR] File path is too long : %s", dirp->d_name);
closedir(dp);
- return -1;
+ return VC_CONFIG_ERROR_OPERATION_FAILED;
}
memset(filepath, '\0', 512);
if (filesize >= 512) {
SECURE_SLOG(LOG_ERROR, vc_config_tag(), "[CONFIG ERROR] File path is too long : %s", dirp->d_name);
closedir(dp);
- return -1;
+ return VC_CONFIG_ERROR_OPERATION_FAILED;
}
memset(filepath, '\0', 512);
if (g_VoiceControlEngines->isEngineEmpty()) {
SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] No engine");
- return -1;
+ return VC_CONFIG_ERROR_OPERATION_FAILED;
}
- return VC_ERROR_NONE;
+ return VC_CONFIG_ERROR_NONE;
}
static Eina_Bool __vc_config_mgr_engine_config_inotify_event_callback(void* data, Ecore_Fd_Handler *fd_handler)
{
if (NULL == path) {
SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Path is NULL");
- return -1;
+ return VC_CONFIG_ERROR_INVALID_PARAMETER;
}
/* For engine directory monitoring */
vc_engine_inotify_s *ino = (vc_engine_inotify_s *)calloc(1, sizeof(vc_engine_inotify_s));
if (NULL == ino) {
SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to allocate memory");
- return -1;
+ return VC_CONFIG_ERROR_OUT_OF_MEMORY;
}
ino->dir_fd = inotify_init();
free(ino);
ino = NULL;
- return -1;
+ return VC_CONFIG_ERROR_OPERATION_FAILED;
}
ino->dir_wd = inotify_add_watch(ino->dir_fd, path, IN_CLOSE_WRITE);
SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to add watch");
free(ino);
ino = NULL;
- return -1;
+ return VC_CONFIG_ERROR_OPERATION_FAILED;
}
ino->dir_fd_handler = ecore_main_fd_handler_add(ino->dir_fd, ECORE_FD_READ, (Ecore_Fd_Cb)__vc_config_mgr_engine_config_inotify_event_callback, (void *)ino, NULL, NULL);
SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to add fd handler");
free(ino);
ino = NULL;
- return -1;
+ return VC_CONFIG_ERROR_OPERATION_FAILED;
}
/* Set non-blocking mode of file */
unique_lock<mutex> lock(g_ino_list_mutex);
g_ino_list = g_list_append(g_ino_list, ino);
- return VC_ERROR_NONE;
+ return VC_CONFIG_ERROR_NONE;
}
static int __vc_config_mgr_unregister_engine_config_updated_event()
iter = g_list_first(g_ino_list);
}
}
- return VC_ERROR_NONE;
+ return VC_CONFIG_ERROR_NONE;
}
-Eina_Bool vc_config_mgr_inotify_event_cb(void* data, Ecore_Fd_Handler *fd_handler)
+static Eina_Bool __vc_config_mgr_inotify_event_cb(void* data, Ecore_Fd_Handler *fd_handler)
{
SLOG(LOG_DEBUG, vc_config_tag(), "@@@ Config changed callback event");
value = vconf_get_str(VCONFKEY_LANGSET);
if (NULL == value) {
SLOG(LOG_ERROR, vc_config_tag(), "[Config ERROR] Fail to get display language");
- return -1;
+ return VC_CONFIG_ERROR_OPERATION_FAILED;
}
strncpy(candidate_lang, value, 5);
string default_language = g_VoiceControlConfig->getCurrentLanguage();
if (0 == default_language.compare(candidate_lang)) {
SLOG(LOG_DEBUG, vc_config_tag(), "[Config] VC language(%s) is same with display language", default_language.c_str());
- return VC_ERROR_NONE;
+ return VC_CONFIG_ERROR_NONE;
}
string default_engine_id = g_VoiceControlConfig->getEngineId();
string before_language = g_VoiceControlConfig->getCurrentLanguage();
if (0 != vc_parser_set_language(candidate_lang)) {
SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to save default language");
- return -1;
+ return VC_CONFIG_ERROR_OPERATION_FAILED;
}
g_VoiceControlConfig->setCurrentLanguage(candidate_lang);
char* tmp_language = NULL;
if (0 != __vc_config_mgr_select_lang(default_engine_id.c_str(), &tmp_language)) {
SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to select language");
- return -1;
+ return VC_CONFIG_ERROR_OPERATION_FAILED;
}
if (NULL == tmp_language) {
SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Selected language is NULL");
- return -1;
+ return VC_CONFIG_ERROR_OPERATION_FAILED;
}
string before_language = g_VoiceControlConfig->getCurrentLanguage();
if (0 != vc_parser_set_language(tmp_language)) {
free(tmp_language);
SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to save config");
- return -1;
+ return VC_CONFIG_ERROR_OPERATION_FAILED;
}
g_VoiceControlConfig->setCurrentLanguage(tmp_language);
free(tmp_language);
}
- return VC_ERROR_NONE;
+ return VC_CONFIG_ERROR_NONE;
}
-void __vc_config_language_changed_cb(keynode_t *key, void *data)
+static void __vc_config_language_changed_cb(keynode_t *key, void *data)
{
if (g_VoiceControlConfig->isAutoLanguageEnabled()) {
/* Get voice input vconf key */
ecore_thread_main_loop_end();
SLOG(LOG_DEBUG, vc_config_tag(), "[WARNING] Leave critical section");
- return VC_ERROR_NONE;
+ return VC_CONFIG_ERROR_NONE;
}
int vc_config_mgr_finalize(unsigned int uid)
if (0 < g_VoiceControlClients->removeClient(uid)) {
SLOG(LOG_DEBUG, vc_config_tag(), "[WARNING] Leave critical section");
- return VC_ERROR_NONE;
+ return VC_CONFIG_ERROR_NONE;
}
delete g_VoiceControlClients;
g_config_mgr_initialized = false;
SLOG(LOG_DEBUG, vc_config_tag(), "[Success] Finalize config");
- return VC_ERROR_NONE;
+ return VC_CONFIG_ERROR_NONE;
}
-int __vc_config_mgr_register_lang_event()
+static int __vc_config_mgr_register_lang_event()
{
if (0 == g_lang_ref_count) {
/* get file notification handler */
fd = inotify_init();
if (fd < 0) {
SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail get inotify fd");
- return -1;
+ return VC_CONFIG_ERROR_OPERATION_FAILED;
}
g_fd_lang = fd;
wd = inotify_add_watch(fd, VC_CONFIG, IN_CLOSE_WRITE);
g_wd_lang = wd;
- g_fd_handler_lang = ecore_main_fd_handler_add(fd, ECORE_FD_READ, (Ecore_Fd_Cb)vc_config_mgr_inotify_event_cb, NULL, NULL, NULL);
+ g_fd_handler_lang = ecore_main_fd_handler_add(fd, ECORE_FD_READ, (Ecore_Fd_Cb)__vc_config_mgr_inotify_event_cb, NULL, NULL, NULL);
if (NULL == g_fd_handler_lang) {
SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to get handler_noti");
- return -1;
+ return VC_CONFIG_ERROR_OPERATION_FAILED;
}
/* Set non-blocking mode of file */
}
g_lang_ref_count++;
- return VC_ERROR_NONE;
+ return VC_CONFIG_ERROR_NONE;
}
-int __vc_config_mgr_unregister_config_event()
+static int __vc_config_mgr_unregister_config_event()
{
if (0 == g_lang_ref_count) {
SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Lang ref count is 0");
vconf_ignore_key_changed(VCONFKEY_LANGSET, __vc_config_language_changed_cb);
}
- return VC_ERROR_NONE;
+ return VC_CONFIG_ERROR_NONE;
}
int vc_config_mgr_set_engine_cb(unsigned int uid, vc_config_engine_changed_cb engine_cb)
{
if (g_config_mgr_initialized.load() == false) {
SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Not initialized");
- return -1;
+ return VC_CONFIG_ERROR_INVALID_STATE;
}
if (NULL == value) {
- return -1;
+ return VC_ERROR_INVALID_PARAMETER;
}
*value = g_VoiceControlConfig->isAutoLanguageEnabled();
- return VC_ERROR_NONE;
+ return VC_CONFIG_ERROR_NONE;
}
int vc_config_mgr_set_auto_language(bool value)
{
if (g_config_mgr_initialized.load() == false) {
SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Not initialized");
- return -1;
+ return VC_CONFIG_ERROR_INVALID_STATE;
}
if (g_VoiceControlConfig->isAutoLanguageEnabled() != value) {
/* Check language is valid */
if (0 != vc_parser_set_auto_lang(value)) {
SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to save engine id");
- return -1;
+ return VC_CONFIG_ERROR_OPERATION_FAILED;
}
g_VoiceControlConfig->setAutoLanguageEnabled(value);
}
}
- return VC_ERROR_NONE;
+ return VC_CONFIG_ERROR_NONE;
}
int vc_config_mgr_get_engine_list(vc_config_supported_engine_cb callback, void* user_data)
return VC_CONFIG_ERROR_NONE;
}
-int __vc_config_set_buxtonkey(const char* engine)
+static int __vc_config_set_buxtonkey(const char* engine)
{
/* Set vconfkey */
struct buxton_client * bux_cli;
{
if (g_config_mgr_initialized.load() == false) {
SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Not initialized");
- return -1;
+ return VC_CONFIG_ERROR_INVALID_STATE;
}
if (nullptr == callback) {
return VC_CONFIG_ERROR_INVALID_PARAMETER;
}
- if (g_VoiceControlEngines->isEngineEmpty()) {
- SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] There is no engine");
- return -1;
- }
-
string default_engine_id = g_VoiceControlConfig->getEngineId();
shared_ptr<VoiceControlEngineInfo> engineInfo = g_VoiceControlEngines->getEngineInfo(default_engine_id);
if (nullptr == engineInfo) {
SLOG(LOG_ERROR, vc_config_tag(), "Fail to find engine information : %s", default_engine_id.c_str());
- return VC_CONFIG_ERROR_NONE;
+ return VC_CONFIG_ERROR_ENGINE_NOT_FOUND;
}
/* Get a first item */
}
}
- return VC_ERROR_NONE;
+ return VC_CONFIG_ERROR_NONE;
}
int vc_config_mgr_get_default_language(char** language)
{
if (g_config_mgr_initialized.load() == false) {
SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Not initialized");
- return -1;
+ return VC_CONFIG_ERROR_INVALID_STATE;
}
if (NULL == language) {
- return -1;
+ return VC_CONFIG_ERROR_INVALID_PARAMETER;
}
string default_language = g_VoiceControlConfig->getCurrentLanguage();
if (default_language.empty()) {
SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] language is NULL");
- return -1;
+ return VC_CONFIG_ERROR_OPERATION_FAILED;
}
*language = strdup(default_language.c_str());
- return VC_ERROR_NONE;
+ return VC_CONFIG_ERROR_NONE;
}
static int __vc_config_mgr_set_default_language(const char* language)
{
if (g_config_mgr_initialized.load() == false) {
SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Not initialized");
- return -1;
+ return VC_CONFIG_ERROR_INVALID_STATE;
}
if (NULL == language) {
- return -1;
+ return VC_CONFIG_ERROR_INVALID_PARAMETER;
}
/* Check language is valid */
string default_language = g_VoiceControlConfig->getCurrentLanguage();
if (default_language.empty()) {
SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] language is NULL");
- return -1;
+ return VC_CONFIG_ERROR_OPERATION_FAILED;
}
if (0 != vc_parser_set_language(language)) {
SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to save engine id");
- return -1;
+ return VC_CONFIG_ERROR_OPERATION_FAILED;
}
g_VoiceControlConfig->setCurrentLanguage(language);
- return VC_ERROR_NONE;
+ return VC_CONFIG_ERROR_NONE;
}
int vc_config_mgr_set_default_language(const char* language)
{
if (g_config_mgr_initialized.load() == false) {
SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Not initialized");
- return -1;
+ return VC_CONFIG_ERROR_INVALID_STATE;
}
if (NULL == value) {
- return -1;
+ return VC_CONFIG_ERROR_INVALID_PARAMETER;
}
*value = g_VoiceControlConfig->isEnabled();
- return VC_ERROR_NONE;
+ return VC_CONFIG_ERROR_NONE;
}
int vc_config_mgr_set_enabled(bool value)
{
if (g_config_mgr_initialized.load() == false) {
SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Not initialized");
- return -1;
+ return VC_CONFIG_ERROR_INVALID_STATE;
}
if (0 != vc_parser_set_enabled(value)) {
SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to set enabled");
- return -1;
+ return VC_CONFIG_ERROR_OPERATION_FAILED;
}
g_VoiceControlConfig->setEnabled(value);
- return VC_ERROR_NONE;
+ return VC_CONFIG_ERROR_NONE;
}
int vc_config_mgr_get_nonfixed_support(bool* value)
{
if (g_config_mgr_initialized.load() == false) {
SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Not initialized");
- return -1;
+ return VC_CONFIG_ERROR_INVALID_STATE;
}
if (NULL == value) {
SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Input parameter is NULL");
- return -1;
+ return VC_CONFIG_ERROR_INVALID_PARAMETER;
}
string default_engine_id = g_VoiceControlConfig->getEngineId();
};
*value = engineInfo->isNonFixedSupported();
- return VC_ERROR_NONE;
+ return VC_CONFIG_ERROR_NONE;
}
bool vc_config_check_default_engine_is_valid(const char* engine)
{
if (g_config_mgr_initialized.load() == false) {
SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Not initialized");
- return -1;
- }
-
- if (NULL == engine) {
return false;
}
- bool is_valid = g_VoiceControlEngines->isEngineIdValid(engine);
- return is_valid;
+ bool is_engine_valid = g_VoiceControlEngines->isEngineIdValid(engine);
+ return is_engine_valid;
}
bool vc_config_check_default_language_is_valid(const char* language)
{
if (g_config_mgr_initialized.load() == false) {
SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Not initialized");
- return -1;
+ return false;
}
if (NULL == language) {
{
if (g_config_mgr_initialized.load() == false) {
SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Not initialized");
- return -1;
+ return VC_CONFIG_ERROR_INVALID_STATE;
}
return vc_parser_set_foreground(pid, value);
{
if (g_config_mgr_initialized.load() == false) {
SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Not initialized");
- return -1;
+ return VC_CONFIG_ERROR_INVALID_STATE;
}
return vc_parser_get_foreground(pid);