#include <unistd.h>
#include <sys/inotify.h>
#include <vconf.h>
+#include <buxton2.h>
#include "stt_config_mgr.h"
#include "stt_defs.h"
static void __get_engine_list(const char* directory)
{
DIR *dp = NULL;
- int ret = -1;
- struct dirent entry;
struct dirent *dirp = NULL;
if (NULL == directory) {
SLOG(LOG_ERROR, stt_tag(), "[Directory ERROR] Directory is NULL");
return;
+ } else {
+ SLOG(LOG_DEBUG, stt_tag(), "[Directory DEBUG] Directory: %s", directory);
}
dp = opendir(directory);
if (NULL != dp) {
do {
- ret = readdir_r(dp, &entry, &dirp);
- if (0 != ret) {
- SLOG(LOG_ERROR, stt_tag(), "[File ERROR] Fail to read directory");
- break;
- }
+ dirp = readdir(dp);
if (NULL != dirp) {
if (!strcmp(".", dirp->d_name) || !strcmp("..", dirp->d_name))
char* filepath = NULL;
int filesize;
- filesize = strlen(STT_DEFAULT_ENGINE_INFO) + strlen(dirp->d_name) + 5;
+ filesize = strlen(directory) + strlen(dirp->d_name) + 5;
filepath = (char*)calloc(filesize, sizeof(char));
if (NULL != filepath) {
continue;
}
+ SLOG(LOG_DEBUG, stt_tag(), "[File DEBUG] File path: %s", filepath);
+
if (0 == stt_parser_get_engine_info(filepath, &info)) {
g_engine_list = g_slist_append(g_engine_list, info);
}
return STT_CONFIG_ERROR_NONE;
}
+int __stt_config_set_buxtonkey(const char* engine)
+{
+ /* Set vconfkey */
+ struct buxton_client * bux_cli;
+ struct buxton_layer * bux_layer;
+ struct buxton_value * bux_val;
+
+ int ret = buxton_open(&bux_cli, NULL, NULL);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, stt_tag(), "[DBUS-BUXTON2] Fail to open buxton client, ret(%d)", ret);
+ return STT_CONFIG_ERROR_OPERATION_FAILED;
+ }
+ bux_layer = buxton_create_layer("system");
+ if (NULL == bux_layer) {
+ SLOG(LOG_ERROR, stt_tag(), "[DBUS-BUXTON2] buxton_create_layer FAIL");
+ buxton_close(bux_cli);
+ bux_cli = NULL;
+ return STT_CONFIG_ERROR_OPERATION_FAILED;
+ }
+ bux_val = buxton_value_create_string(engine);
+ if (NULL == bux_val) {
+ SLOG(LOG_ERROR, stt_tag(), "[DBUS-BUXTON2] buxton_value_create_string FAIL");
+ buxton_free_layer(bux_layer);
+ buxton_close(bux_cli);
+ bux_layer = NULL;
+ bux_cli = NULL;
+ return STT_CONFIG_ERROR_OPERATION_FAILED;
+ } else {
+ SLOG(LOG_DEBUG, stt_tag(), "[DBUS-BUXTON2] layer: %s", buxton_layer_get_name(bux_layer));
+ }
+
+ ret = buxton_set_value_sync(bux_cli, bux_layer, STT_ENGINE_DB_DEFAULT, bux_val);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, stt_tag(), "[DBUS-BUXTON2] Fail to set value sync, ret(%d)", ret);
+ buxton_value_free(bux_val);
+ buxton_free_layer(bux_layer);
+ buxton_close(bux_cli);
+
+ bux_cli = NULL;
+ bux_layer = NULL;
+ bux_val = NULL;
+ return STT_CONFIG_ERROR_OPERATION_FAILED;
+ }
+ SLOG(LOG_DEBUG, stt_tag(), "[DBUS-BUXTON2] buxton_set_value_sync: %s", STT_ENGINE_DB_DEFAULT);
+
+ buxton_value_free(bux_val);
+ buxton_free_layer(bux_layer);
+ buxton_close(bux_cli);
+
+ bux_cli = NULL;
+ bux_layer = NULL;
+ bux_val = NULL;
+
+ return STT_CONFIG_ERROR_NONE;
+}
+
int stt_config_mgr_set_engine(const char* engine)
{
if (0 >= g_slist_length(g_config_client_list)) {
SLOG(LOG_DEBUG, stt_tag(), "New engine id : %s", engine);
+ int ret = __stt_config_set_buxtonkey(engine);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, stt_tag(), "[ERROR] set buxtonkey Failed!!!");
+ return ret;
+ }
+
GSList *iter = NULL;
stt_engine_info_s *engine_info = NULL;
bool is_valid_engine = false;
ret = stt_parser_get_time_info(&temp_time);
if (0 != ret) {
SLOG(LOG_WARN, stt_tag(), "[WARNING] Fail to get time info : %d", ret);
- return STT_CONFIG_ERROR_OPERATION_FAILED;
+ return STT_CONFIG_ERROR_NONE;
}
GSList *iter = NULL;