From: sooyeon Date: Fri, 26 Aug 2022 02:39:43 +0000 (+0900) Subject: Change directories of tts-config file and engine-info file X-Git-Tag: accepted/tizen/unified/20220922.062106~3^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ad90b3d12904909b03c06a225c9d661407537ddd;p=platform%2Fcore%2Fuifw%2Ftts.git Change directories of tts-config file and engine-info file - Issue: In case of root daemon, it cannot access tts-config file and engine-info file, because they are installed in user directories respectively. - Solution: We move tts-config file and engine-info file to global user data (/opt/usr/data) to make both root daemon and users access the files. Change-Id: I7379846bbf54539eb3d81b3bb91e32b8103f94e5 Signed-off-by: sooyeon --- diff --git a/common/tts_config_mgr.c b/common/tts_config_mgr.c index f244d789..17034951 100644 --- a/common/tts_config_mgr.c +++ b/common/tts_config_mgr.c @@ -1128,6 +1128,7 @@ int tts_config_mgr_initialize(unsigned int uid, tts_config_client_type_e client_ } if (0 != access(TTS_HOME, F_OK)) { + SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Fail to access (%d)", errno); if (0 != mkdir(TTS_HOME, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) { SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Fail to make directory : %s", TTS_HOME); __tts_config_release_client(uid); @@ -1137,16 +1138,6 @@ int tts_config_mgr_initialize(unsigned int uid, tts_config_client_type_e client_ } } - if (0 != access(TTS_DOWNLOAD_BASE, F_OK)) { - if (0 != mkdir(TTS_DOWNLOAD_BASE, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) { - SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Fail to make directory : %s", TTS_DOWNLOAD_BASE); - __tts_config_release_client(uid); - return TTS_CONFIG_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_TTSCONFIG, "Success to make directory : %s", TTS_DOWNLOAD_BASE); - } - } - if (0 != access(TTS_DOWNLOAD_ENGINE_INFO, F_OK)) { if (0 != mkdir(TTS_DOWNLOAD_ENGINE_INFO, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) { SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Fail to make directory : %s", TTS_DOWNLOAD_ENGINE_INFO); diff --git a/common/tts_config_parser.c b/common/tts_config_parser.c index a0ba63ed..35494f6f 100644 --- a/common/tts_config_parser.c +++ b/common/tts_config_parser.c @@ -553,7 +553,7 @@ int tts_parser_load_config(void) usleep(10000); if (TTS_RETRY_COUNT == retry_count) { - SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Save result : %d", ret); + SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Save result : %d, err(%d)", ret, errno); return -1; } } while (0 != ret); diff --git a/common/tts_defs.h b/common/tts_defs.h index 196e2e35..0959ac58 100644 --- a/common/tts_defs.h +++ b/common/tts_defs.h @@ -94,17 +94,18 @@ extern "C" { * Defines for configuration *******************************************************************************************/ -#define TTS_CONFIG_BASE tzplatform_mkpath(tzplatform_getid("TZ_USER_HOME"), "/share/.voice") -#define TTS_CONFIG tzplatform_mkpath(tzplatform_getid("TZ_USER_HOME"), "/share/.voice/tts-config.xml") +#define TTS_CONFIG_BASE tzplatform_mkpath(tzplatform_getid("TZ_SYS_GLOBALUSER_DATA"), ".voice") +#define TTS_CONFIG tzplatform_mkpath(tzplatform_getid("TZ_SYS_GLOBALUSER_DATA"), ".voice/tts-config.xml") #define TTS_DEFAULT_CONFIG tzplatform_mkpath(tzplatform_getid("TZ_SYS_RO_SHARE"), "/voice/tts/1.0/tts-config.xml") #define TTS_DEFAULT_ENGINE tzplatform_mkpath(tzplatform_getid("TZ_SYS_RO_SHARE"), "/voice/tts/1.0/engine") #define TTS_DEFAULT_ENGINE_INFO tzplatform_mkpath(tzplatform_getid("TZ_SYS_RO_SHARE"), "/voice/tts/1.0/engine-info") #define TTS_DEFAULT_ENGINE_SETTING tzplatform_mkpath(tzplatform_getid("TZ_SYS_RO_SHARE"), "/voice/tts/1.0/engine-setting") -#define TTS_HOME tzplatform_mkpath(tzplatform_getid("TZ_USER_HOME"), "/share/.voice/tts") -#define TTS_DOWNLOAD_BASE tzplatform_mkpath(tzplatform_getid("TZ_USER_HOME"), "/share/.voice/tts/1.0") -#define TTS_DOWNLOAD_ENGINE_INFO tzplatform_mkpath(tzplatform_getid("TZ_USER_HOME"), "share/.voice/tts/1.0/engine-info") +#define TTS_HOME tzplatform_mkpath(tzplatform_getid("TZ_SYS_GLOBALUSER_DATA"), ".voice/tts") +#define TTS_DOWNLOAD_ENGINE_INFO tzplatform_mkpath(tzplatform_getid("TZ_SYS_GLOBALUSER_DATA"), ".voice/tts/engine-info") + + #define TTS_BASE_LANGUAGE "en_US" diff --git a/engine-parser/src/tts-engine-parser.c b/engine-parser/src/tts-engine-parser.c index 9328a870..366e42a5 100644 --- a/engine-parser/src/tts-engine-parser.c +++ b/engine-parser/src/tts-engine-parser.c @@ -55,17 +55,12 @@ #define TTS_TAG_VOICE_BASE "tts-voice" -#define TTS_CONFIG_BASE tzplatform_mkpath(tzplatform_getid("TZ_USER_HOME"), "share/.voice") -#define TTS_HOME tzplatform_mkpath(tzplatform_getid("TZ_USER_HOME"), "share/.voice/tts") -#define TTS_ENGINE_BASE tzplatform_mkpath(tzplatform_getid("TZ_USER_HOME"), "share/.voice/tts/1.0") -#define TTS_ENGINE_INFO tzplatform_mkpath(tzplatform_getid("TZ_USER_SHARE"), ".voice/tts/1.0/engine-info") - #define TTS_VOICE_INFO tzplatform_mkpath(tzplatform_getid("TZ_SYS_RO_SHARE"), "voice/tts/1.0/tts-voice.xml") -#define TTS_GLOBAL_CONFIG_BASE "/etc/skel/share/.voice" -#define TTS_GLOBAL_HOME "/etc/skel/share/.voice/tts" -#define TTS_GLOBAL_ENGINE_BASE "/etc/skel/share/.voice/tts/1.0" -#define TTS_GLOBAL_ENGINE_INFO "/etc/skel/share/.voice/tts/1.0/engine-info" +#define TTS_GLOBAL_CONFIG_BASE tzplatform_mkpath(tzplatform_getid("TZ_SYS_GLOBALUSER_DATA"), ".voice") +#define TTS_GLOBAL_HOME tzplatform_mkpath(tzplatform_getid("TZ_SYS_GLOBALUSER_DATA"), ".voice/tts") +#define TTS_GLOBAL_ENGINE_INFO tzplatform_mkpath(tzplatform_getid("TZ_SYS_GLOBALUSER_DATA"), ".voice/tts/engine-info") + #define TTS_METADATA_NAME "http://tizen.org/metadata/tts-engine/name" #define TTS_METADATA_LANGUAGE "http://tizen.org/metadata/tts-engine/language" @@ -103,7 +98,6 @@ static gchar *g_user_type = NULL; static char *g_dir_config_base = NULL; static char *g_dir_home = NULL; -static char *g_dir_engine_base = NULL; static char *g_dir_engine_info = NULL; static GSList *g_voice_info_list = NULL; @@ -125,7 +119,6 @@ static int __save_engine_info_xml(const char *pkgid, gchar *ut, uid_t uid, gid_t LOGD("@@@ Save engine info doc"); char *dir_config_base = NULL; char *dir_home = NULL; - char *dir_engine_base = NULL; char *dir_engine_info = NULL; if (NULL == ut || (NULL != ut && 0 == strcmp(ut, "none"))) { @@ -133,39 +126,22 @@ static int __save_engine_info_xml(const char *pkgid, gchar *ut, uid_t uid, gid_t return -1; } - uid_t globalapp_uid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER); uid_t tmp_uid = 0; gid_t tmp_gid = 0; LOGD("uid(%u)", uid); - if (globalapp_uid == uid) { - /* Global app */ - dir_config_base = strdup(TTS_GLOBAL_CONFIG_BASE); - dir_home = strdup(TTS_GLOBAL_HOME); - dir_engine_base = strdup(TTS_GLOBAL_ENGINE_BASE); - dir_engine_info = strdup(TTS_GLOBAL_ENGINE_INFO); - tmp_uid = 301; // app_fw - tmp_gid = 301; // app_fw - } else { - /* User app, Guest app, Security app */ - if (NULL != g_dir_config_base) - dir_config_base = strdup(g_dir_config_base); - if (NULL != g_dir_home) - dir_home = strdup(g_dir_home); - if (NULL != g_dir_engine_base) - dir_engine_base = strdup(g_dir_engine_base); - if (NULL != g_dir_engine_info) - dir_engine_info = strdup(g_dir_engine_info); - tmp_uid = uid; - tmp_gid = gid; - } + dir_config_base = strdup(TTS_GLOBAL_CONFIG_BASE); + dir_home = strdup(TTS_GLOBAL_HOME); + dir_engine_info = strdup(TTS_GLOBAL_ENGINE_INFO); + tmp_uid = 301; // app_fw + tmp_gid = 301; // app_fw + - if (NULL == dir_config_base || NULL == dir_home || NULL == dir_engine_base || NULL == dir_engine_info) { + if (NULL == dir_config_base || NULL == dir_home || NULL == dir_engine_info) { LOGE("[ERROR] Fail to allocate memory"); FREE(dir_config_base) FREE(dir_home) - FREE(dir_engine_base) FREE(dir_engine_info) return -1; @@ -184,7 +160,6 @@ static int __save_engine_info_xml(const char *pkgid, gchar *ut, uid_t uid, gid_t LOGE("[ERROR] Fail to make directory : %s, errno : %d", dir_config_base, errno); FREE(dir_config_base) FREE(dir_home) - FREE(dir_engine_base) FREE(dir_engine_info) return -1; } else { @@ -207,7 +182,6 @@ static int __save_engine_info_xml(const char *pkgid, gchar *ut, uid_t uid, gid_t LOGE("[ERROR] Fail to make directory : %s, errno : %d", dir_home, errno); FREE(dir_config_base) FREE(dir_home) - FREE(dir_engine_base) FREE(dir_engine_info) return -1; } else { @@ -222,29 +196,6 @@ static int __save_engine_info_xml(const char *pkgid, gchar *ut, uid_t uid, gid_t close(fd); } -// if (0 != access(dir_engine_base, F_OK)) { - fd = open(dir_engine_base, O_DIRECTORY); - if (-1 == fd) { - LOGE("[INFO] No directory : %s, errno : %d", dir_engine_base, errno); - if (0 != mkdir(dir_engine_base, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) { - LOGE("[ERROR] Fail to make directory : %s, errno : %d", dir_engine_base, errno); - FREE(dir_config_base) - FREE(dir_home) - FREE(dir_engine_base) - FREE(dir_engine_info) - return -1; - } else { - LOGD("Success to make directory : %s", dir_engine_base); - if (0 != chown(dir_engine_base, tmp_uid, tmp_gid)) { - LOGD("[ERROR] Fail to change user and group, errno : %d", errno); - } else { - LOGD("[DEBUG] Success to change user and group"); - } - } - } else { - close(fd); - } - // if (0 != access(dir_engine_info, F_OK)) { fd = open(dir_engine_info, O_DIRECTORY); if (-1 == fd) { @@ -253,7 +204,6 @@ static int __save_engine_info_xml(const char *pkgid, gchar *ut, uid_t uid, gid_t LOGE("[ERROR] Fail to make directory : %s, errno : %d", dir_engine_info, errno); FREE(dir_config_base) FREE(dir_home) - FREE(dir_engine_base) FREE(dir_engine_info) return -1; } else { @@ -283,7 +233,6 @@ static int __save_engine_info_xml(const char *pkgid, gchar *ut, uid_t uid, gid_t FREE(dir_config_base) FREE(dir_home) - FREE(dir_engine_base) FREE(dir_engine_info) LOGD("@@@"); @@ -301,18 +250,11 @@ static int __remove_engine_info_xml(const char *pkgid, gchar *ut, uid_t uid) return -1; } - uid_t globalapp_uid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER); + // uid_t globalapp_uid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER); LOGD("uid(%u)", uid); - if (globalapp_uid == uid) { - /* Global app */ - dir_engine_info = strdup(TTS_GLOBAL_ENGINE_INFO); - } else { - /* User app, Guest app, Security app */ - if (NULL != g_dir_engine_info) - dir_engine_info = strdup(g_dir_engine_info); - } + dir_engine_info = strdup(TTS_GLOBAL_ENGINE_INFO); if (NULL == dir_engine_info) { LOGE("[ERROR] Fail to allocate memory"); @@ -642,34 +584,6 @@ static int __get_global_user_type(uid_t globalapp_uid) return 0; } -static int __get_user_list(GumUserService **gus, GumUserList **users) -{ - if (NULL == gus || NULL == users) { - return -1; - } - - GumUserService *temp_gus = NULL; - GumUserList *temp_users = NULL; - - temp_gus = gum_user_service_create_sync(TRUE); - if (!temp_gus) { - LOGE("Failed to create gum user service"); - return -1; - } - - gchar **query = g_strsplit("admin,normal", ",", -1); - temp_users = gum_user_service_get_user_list_sync(temp_gus, (const gchar *const *)query); - g_strfreev(query); - - if (!temp_users) { - LOGD("NO users"); - } - - *gus = temp_gus; - *users = temp_users; - return 0; -} - EXPORT_API int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgid, const char *appid, GList *list) { @@ -689,187 +603,45 @@ int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgid, const char *appid, GList * return -1; } - if (globalapp_uid == g_uid) { - /* global directory */ - LOGD("[DEBUG] usertype: %s", g_user_type); - if (0 >= g_list_length(list)) { - LOGE("[ERROR] No Engine Metadata"); - G_FREE(g_user_type) - return 0; - } - - if (0 != __write_metadata_inxml(pkgid, appid, list)) { - LOGE("[ERROR] Fail to write metadata in the xml"); - xmlFreeDoc(g_doc); - G_FREE(g_user_type) - return -1; - } - - /* Save in /etc/skel/share/ */ - g_dir_config_base = strdup(TTS_GLOBAL_CONFIG_BASE); - g_dir_home = strdup(TTS_GLOBAL_HOME); - g_dir_engine_base = strdup(TTS_GLOBAL_ENGINE_BASE); - g_dir_engine_info = strdup(TTS_GLOBAL_ENGINE_INFO); - - if (NULL == g_dir_config_base || NULL == g_dir_home || NULL == g_dir_engine_base || NULL == g_dir_engine_info) { - LOGE("[ERROR] Fail to allocate memory"); - FREE(g_dir_config_base) - FREE(g_dir_home) - FREE(g_dir_engine_base) - FREE(g_dir_engine_info) - - xmlFreeDoc(g_doc); - G_FREE(g_user_type) - return -1; - } - - if (0 != __save_engine_info_xml(pkgid, g_user_type, g_uid, g_gid)) { - LOGE("[ERROR] Fail to make engine info file"); - xmlFreeDoc(g_doc); - G_FREE(g_user_type) - return -1; - } - - /* Get user data by using libgum */ - - GumUserService *gus = NULL; - GumUserList *users = NULL; - - if (0 != __get_user_list(&gus, &users)) { - G_FREE(g_user_type) - return -1; - } - - /* Make new user list */ - GumUserList *iter = users; - while (iter != NULL) { - GumUser *user = (GumUser*) iter->data; - gchar *user_type = __get_user_type(user); - if (NULL == user_type) { - gum_user_service_list_free(users); - g_object_unref(gus); - gus = NULL; - return -1; - } - - gchar *home_dir = NULL; - g_object_get(G_OBJECT(user), "homedir", &home_dir, NULL); - LOGD("[DEBUG] user info"); - if (NULL != home_dir) { - uid_t uid; - gid_t gid; - g_object_get(G_OBJECT(user), "uid", &uid, NULL); - g_object_get(G_OBJECT(user), "gid", &gid, NULL); - LOGD("[DEBUG] uid(%u), gid(%u), user_type(%s), home_dir(%s)", uid, gid, user_type, home_dir); - - FREE(g_dir_config_base); - FREE(g_dir_home); - FREE(g_dir_engine_base); - FREE(g_dir_engine_info); - - g_dir_config_base = (char*)calloc(strlen(home_dir) + 14, sizeof(char)); - g_dir_home = (char*)calloc(strlen(home_dir) + 18, sizeof(char)); - g_dir_engine_base = (char*)calloc(strlen(home_dir) + 22, sizeof(char)); - g_dir_engine_info = (char*)calloc(strlen(home_dir) + 34, sizeof(char)); - - if (NULL == g_dir_config_base || NULL == g_dir_home || NULL == g_dir_engine_base || NULL == g_dir_engine_info) { - LOGE("[ERROR] Fail to allocate memory"); - FREE(g_dir_config_base) - FREE(g_dir_home) - FREE(g_dir_engine_base) - FREE(g_dir_engine_info) - gum_user_service_list_free(users); - g_object_unref(gus); - gus = NULL; - G_FREE(user_type) - G_FREE(home_dir) - return -1; - } - snprintf(g_dir_config_base, strlen(home_dir) + 14, "%s/share/.voice", home_dir); - snprintf(g_dir_home, strlen(home_dir) + 18, "%s/share/.voice/tts", home_dir); - snprintf(g_dir_engine_base, strlen(home_dir) + 22, "%s/share/.voice/tts/1.0", home_dir); - snprintf(g_dir_engine_info, strlen(home_dir) + 34, "%s/share/.voice/tts/1.0/engine-info", home_dir); - - LOGD("[DEBUG] g_dir_engine_info(%s)", g_dir_engine_info); - - if (0 != __save_engine_info_xml(pkgid, user_type, uid, gid)) { - LOGE("[ERROR] Fail to make engine info file"); - } - - } - - G_FREE(home_dir) - G_FREE(user_type) - iter = g_list_next(iter); - } + /* global directory */ + LOGD("[DEBUG] usertype: %s", g_user_type); + if (0 >= g_list_length(list)) { + LOGE("[ERROR] No Engine Metadata"); + G_FREE(g_user_type) + return 0; + } - if (users) { - gum_user_service_list_free(users); - } - g_object_unref(gus); - gus = NULL; - } else { - /* user directory */ - LOGD("[DEBUG] usertype: %s", g_user_type); - - if (0 > tzplatform_set_user(g_uid)) { - LOGE("[ERROR] Invalid uid"); - g_object_unref(g_guser); - g_guser = NULL; - G_FREE(g_user_type) - return 0; - } else { - LOGD("TZ_USER_HOME: %s", tzplatform_mkstr(TZ_USER_HOME, "/")); - printf("[Parser Debug][DEBUG] TZ_USER_HOME: %s", tzplatform_mkstr(TZ_USER_HOME, "/")); - } + if (0 != __write_metadata_inxml(pkgid, appid, list)) { + LOGE("[ERROR] Fail to write metadata in the xml"); + xmlFreeDoc(g_doc); + G_FREE(g_user_type) + return -1; + } - if (0 >= g_list_length(list)) { - LOGE("[ERROR] No Engine Metadata"); - g_object_unref(g_guser); - g_guser = NULL; - G_FREE(g_user_type) - return 0; - } + /* Save in /opt/usr/data/ */ + g_dir_config_base = strdup(TTS_GLOBAL_CONFIG_BASE); + g_dir_home = strdup(TTS_GLOBAL_HOME); + g_dir_engine_info = strdup(TTS_GLOBAL_ENGINE_INFO); - if (0 != __write_metadata_inxml(pkgid, appid, list)) { - LOGE("[ERROR] Fail to write metadata in the xml"); - xmlFreeDoc(g_doc); - g_object_unref(g_guser); - g_guser = NULL; - G_FREE(g_user_type) - return -1; - } + if (NULL == g_dir_config_base || NULL == g_dir_home || NULL == g_dir_engine_info) { + LOGE("[ERROR] Fail to allocate memory"); + FREE(g_dir_config_base) + FREE(g_dir_home) + FREE(g_dir_engine_info) - g_dir_config_base = strdup(TTS_CONFIG_BASE); - g_dir_home = strdup(TTS_HOME); - g_dir_engine_base = strdup(TTS_ENGINE_BASE); - g_dir_engine_info = strdup(TTS_ENGINE_INFO); - - if (NULL == g_dir_config_base || NULL == g_dir_home || NULL == g_dir_engine_base || NULL == g_dir_engine_info) { - LOGE("[ERROR] Fail to allocate memory"); - FREE(g_dir_config_base) - FREE(g_dir_home) - FREE(g_dir_engine_base) - FREE(g_dir_engine_info) - xmlFreeDoc(g_doc); - g_object_unref(g_guser); - g_guser = NULL; - G_FREE(g_user_type) - return -1; - } + xmlFreeDoc(g_doc); + G_FREE(g_user_type) + return -1; + } - if (0 != __save_engine_info_xml(pkgid, g_user_type, g_uid, g_gid)) { - LOGE("[ERROR] Fail to make engine info file"); - xmlFreeDoc(g_doc); - if (NULL != g_guser) { - g_object_unref(g_guser); - g_guser = NULL; - } - G_FREE(g_user_type) - return -1; - } + if (0 != __save_engine_info_xml(pkgid, g_user_type, g_uid, g_gid)) { + LOGE("[ERROR] Fail to make engine info file"); + xmlFreeDoc(g_doc); + G_FREE(g_user_type) + return -1; } + xmlFreeDoc(g_doc); if (NULL != g_guser) { g_object_unref(g_guser); @@ -879,7 +651,6 @@ int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgid, const char *appid, GList * FREE(g_dir_config_base) FREE(g_dir_home) - FREE(g_dir_engine_base) FREE(g_dir_engine_info) return 0; @@ -904,117 +675,22 @@ int PKGMGR_MDPARSER_PLUGIN_UNINSTALL(const char *pkgid, const char *appid, GList return -1; } - if (globalapp_uid == g_uid) { - /* global directory */ - LOGD("[DEBUG] usertype: %s", g_user_type); - - /* Remove files in /etc/skel/share/ */ - g_dir_engine_info = strdup(TTS_GLOBAL_ENGINE_INFO); - if (NULL == g_dir_engine_info) { - LOGE("[ERROR] Fail to allocate memory"); - G_FREE(g_user_type) - return -1; - } - - if (0 != __remove_engine_info_xml(pkgid, g_user_type, g_uid)) { - LOGE("[ERROR] Fail to remove engine info file"); - } - - /* Get user data by using libgum */ + /* global directory */ + LOGD("[DEBUG] usertype: %s", g_user_type); - GumUserService *gus = NULL; - GumUserList *users = NULL; - - if (0 != __get_user_list(&gus, &users)) { - G_FREE(g_user_type) - return -1; - } - - /* Make new user list */ - GumUserList *iter = users; - while (iter != NULL) { - GumUser *user = (GumUser*) iter->data; - gchar *user_type = __get_user_type(user); - if (NULL == user_type) { - gum_user_service_list_free(users); - g_object_unref(gus); - gus = NULL; - return -1; - } - - gchar *home_dir = NULL; - g_object_get(G_OBJECT(user), "homedir", &home_dir, NULL); - if (NULL != home_dir) { - FREE(g_dir_engine_info); - g_dir_engine_info = (char*)calloc(strlen(home_dir) + 34, sizeof(char)); - if (NULL == g_dir_engine_info) { - gum_user_service_list_free(users); - G_FREE(home_dir) - g_object_unref(gus); - gus = NULL; - G_FREE(user_type) - return -1; - } - - snprintf(g_dir_engine_info, strlen(home_dir) + 34, "%s/share/.voice/tts/1.0/engine-info", home_dir); - - GList *md_iter = g_list_first(list); - while (NULL != md_iter) { - metadata *md = (metadata *)md_iter->data; - LOGD(" - key(%s) value(%s)", md->key, md->value); - md_iter = g_list_next(md_iter); - } - - uid_t uid; - g_object_get(G_OBJECT(user), "uid", &uid, NULL); - if (0 != __remove_engine_info_xml(pkgid, user_type, uid)) { - LOGE("[ERROR] Fail to remove engine info file"); - } - - } - - G_FREE(home_dir) - G_FREE(user_type) - - LOGD("Finish release memory"); - iter = g_list_next(iter); - LOGD("Finish next iter"); - } - - if (users) { - gum_user_service_list_free(users); - } - g_object_unref(gus); - gus = NULL; - } else { - /* user directory */ - LOGD("[DEBUG] usertype: %s", g_user_type); - - if (0 > tzplatform_set_user(g_uid)) { - LOGE("[ERROR] Invalid uid"); - g_object_unref(g_guser); - g_guser = NULL; - G_FREE(g_user_type) - return -1; - } else { - LOGD("TZ_USER_HOME: %s", tzplatform_mkstr(TZ_USER_HOME, "/")); - printf("[Parser Debug][DEBUG] TZ_USER_HOME: %s", tzplatform_mkstr(TZ_USER_HOME, "/")); - } - - g_dir_engine_info = strdup(TTS_ENGINE_INFO); - if (NULL == g_dir_engine_info) { - LOGE("[ERROR] Fail to allocate memory"); - g_object_unref(g_guser); - g_guser = NULL; - G_FREE(g_user_type) - return -1; - } + /* Remove files in /opt/usr/data/ */ + g_dir_engine_info = strdup(TTS_GLOBAL_ENGINE_INFO); + if (NULL == g_dir_engine_info) { + LOGE("[ERROR] Fail to allocate memory"); + G_FREE(g_user_type) + return -1; + } - if (0 != __remove_engine_info_xml(pkgid, g_user_type, g_uid)) { - LOGE("[ERROR] Fail to remove engine info file"); - } + if (0 != __remove_engine_info_xml(pkgid, g_user_type, g_uid)) { + LOGE("[ERROR] Fail to remove engine info file"); } + if (NULL != g_guser) { g_object_unref(g_guser); g_guser = NULL; diff --git a/packaging/tts.spec b/packaging/tts.spec index d0f2bac2..f7efa9e8 100644 --- a/packaging/tts.spec +++ b/packaging/tts.spec @@ -192,6 +192,11 @@ mkdir -p %{_libdir}/voice mkdir -p %{TZ_SYS_RO_SHARE}/voice/test +mkdir -p -m 0775 %{TZ_SYS_GLOBALUSER_DATA}/.voice +chsmack -t %{TZ_SYS_GLOBALUSER_DATA}/.voice +chsmack -a "User::App::Shared" %{TZ_SYS_GLOBALUSER_DATA}/.voice +mkdir -p %{TZ_SYS_GLOBALUSER_DATA}/.voice/tts/engine-info +chown -R ui_fw:users %{TZ_SYS_GLOBALUSER_DATA}/.voice %postun -p /sbin/ldconfig