Rollback of changing engine-info directories and file mod 28/282528/1 accepted/tizen_7.0_unified_hotfix tizen_7.0_hotfix accepted/tizen/7.0/unified/hotfix/20221116.110226 accepted/tizen/unified/20221006.065321 accepted/tizen/unified/20221006.065358 tizen_7.0_m2_release
authorsooyeon <sooyeon.kim@samsung.com>
Wed, 5 Oct 2022 05:40:36 +0000 (14:40 +0900)
committersooyeon <sooyeon.kim@samsung.com>
Wed, 5 Oct 2022 05:40:58 +0000 (14:40 +0900)
Change-Id: If455a705207a310818345fa121d159b907998d62
Signed-off-by: sooyeon <sooyeon.kim@samsung.com>
common/tts_config_mgr.c
common/tts_config_parser.c
common/tts_defs.h
engine-parser/src/tts-engine-language-pack-parser.c
engine-parser/src/tts-engine-parser.c
packaging/tts.spec

index cbe7da8..4d50896 100644 (file)
@@ -1128,7 +1128,6 @@ 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);
@@ -1138,6 +1137,16 @@ 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);
index 8d495b9..a0ba63e 100644 (file)
@@ -553,13 +553,13 @@ int tts_parser_load_config(void)
                        usleep(10000);
 
                        if (TTS_RETRY_COUNT == retry_count) {
-                               SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Save result : %d, err(%d)", ret, errno);
+                               SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Save result : %d", ret);
                                return -1;
                        }
                } while (0 != ret);
 
                /* Set mode */
-               if (0 > chmod(TTS_CONFIG, 0644)) {
+               if (0 > chmod(TTS_CONFIG, 0600)) {
                        SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Fail to change file mode : %d", ret);
                }
 
@@ -663,7 +663,7 @@ int tts_parser_copy_xml(const char* original, const char* destination)
        }
 
        /* Set mode */
-       if (0 > chmod(destination, 0644)) {
+       if (0 > chmod(destination, 0600)) {
                SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Fail to change file mode : %d", ret);
        }
 
index 0959ac5..196e2e3 100644 (file)
@@ -94,18 +94,17 @@ extern "C" {
 * Defines for configuration
 *******************************************************************************************/
 
-#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_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_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_SYS_GLOBALUSER_DATA"), ".voice/tts")
-#define TTS_DOWNLOAD_ENGINE_INFO               tzplatform_mkpath(tzplatform_getid("TZ_SYS_GLOBALUSER_DATA"), ".voice/tts/engine-info")
-
-
+#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_BASE_LANGUAGE              "en_US"
 
index 2199bc3..19507b7 100644 (file)
 #define TTS_TAG_ENGINE_VOICE                   "voice"
 #define TTS_TAG_ENGINE_VOICE_TYPE              "type"
 
-#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_CONFIG_BASE                tzplatform_mkpath(TZ_USER_HOME, "share/.voice")
+#define TTS_HOME               tzplatform_mkpath(TZ_USER_HOME, "share/.voice/tts")
+#define TTS_ENGINE_BASE                tzplatform_mkpath(TZ_USER_HOME, "share/.voice/tts/1.0")
+#define TTS_ENGINE_INFO                tzplatform_mkpath(TZ_USER_SHARE, ".voice/tts/1.0/engine-info")
 
 #define TTS_METADATA_LANGUAGE  "http://tizen.org/metadata/tts-engine-language-pack/language"
 
@@ -72,35 +73,44 @@ static int __save_engine_info_xml(const char *pkgid)
        LOGD("=== Save engine info doc");
 
        /* Make directories */
-       if (0 != access(TTS_GLOBAL_CONFIG_BASE, F_OK)) {
-               if (0 != mkdir(TTS_GLOBAL_CONFIG_BASE, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
-                       LOGE("[ERROR] Fail to make directory : %s", TTS_GLOBAL_CONFIG_BASE);
+       if (0 != access(TTS_CONFIG_BASE, F_OK)) {
+               if (0 != mkdir(TTS_CONFIG_BASE, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
+                       LOGE("[ERROR] Fail to make directory : %s", TTS_CONFIG_BASE);
                        return -1;
                } else {
-                       LOGD("Success to make directory : %s", TTS_GLOBAL_CONFIG_BASE);
+                       LOGD("Success to make directory : %s", TTS_CONFIG_BASE);
                }
        }
 
-       if (0 != access(TTS_GLOBAL_HOME, F_OK)) {
-               if (0 != mkdir(TTS_GLOBAL_HOME, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
-                       LOGE("[ERROR] Fail to make directory : %s", TTS_GLOBAL_HOME);
+       if (0 != access(TTS_HOME, F_OK)) {
+               if (0 != mkdir(TTS_HOME, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
+                       LOGE("[ERROR] Fail to make directory : %s", TTS_HOME);
                        return -1;
                } else {
-                       LOGD("Success to make directory : %s", TTS_GLOBAL_HOME);
+                       LOGD("Success to make directory : %s", TTS_HOME);
                }
        }
 
-       if (0 != access(TTS_GLOBAL_ENGINE_INFO, F_OK)) {
-               if (0 != mkdir(TTS_GLOBAL_ENGINE_INFO, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
-                       LOGE("[ERROR] Fail to make directory : %s", TTS_GLOBAL_ENGINE_INFO);
+       if (0 != access(TTS_ENGINE_BASE, F_OK)) {
+               if (0 != mkdir(TTS_ENGINE_BASE, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
+                       LOGE("[ERROR] Fail to make directory : %s", TTS_ENGINE_BASE);
                        return -1;
                } else {
-                       LOGD("Success to make directory : %s", TTS_GLOBAL_ENGINE_INFO);
+                       LOGD("Success to make directory : %s", TTS_ENGINE_BASE);
+               }
+       }
+
+       if (0 != access(TTS_ENGINE_INFO, F_OK)) {
+               if (0 != mkdir(TTS_ENGINE_INFO, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
+                       LOGE("[ERROR] Fail to make directory : %s", TTS_ENGINE_INFO);
+                       return -1;
+               } else {
+                       LOGD("Success to make directory : %s", TTS_ENGINE_INFO);
                }
        }
 
        char path[256] = {'\0',};
-       snprintf(path, 256, "%s/%s.xml", TTS_GLOBAL_ENGINE_INFO, pkgid);
+       snprintf(path, 256, "%s/%s.xml", TTS_ENGINE_INFO, pkgid);
        int ret = xmlSaveFormatFile(path, g_doc, 1);
        LOGD("xmlSaveFile (%d)", ret);
        LOGD("===");
@@ -111,7 +121,7 @@ static int __remove_engine_info_xml(const char *pkgid)
 {
        LOGD("=== Remove engine info doc");
        char path[256] = {'\0',};
-       snprintf(path, 256, "%s/%s.xml", TTS_GLOBAL_ENGINE_INFO, pkgid);
+       snprintf(path, 256, "%s/%s.xml", TTS_ENGINE_INFO, pkgid);
        if (0 == access(path, F_OK)) {
                LOGD("Remove engine info xml(%s)", path);
                remove(path);
index 366e42a..a629373 100644 (file)
 
 #define TTS_TAG_VOICE_BASE                     "tts-voice"
 
-#define TTS_VOICE_INFO tzplatform_mkpath(tzplatform_getid("TZ_SYS_RO_SHARE"), "voice/tts/1.0/tts-voice.xml")
+#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_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_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_METADATA_NAME                      "http://tizen.org/metadata/tts-engine/name"
 #define TTS_METADATA_LANGUAGE                  "http://tizen.org/metadata/tts-engine/language"
@@ -98,6 +103,7 @@ 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;
@@ -119,6 +125,7 @@ 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"))) {
@@ -126,22 +133,39 @@ 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;
+       }
 
-
-       if (NULL == dir_config_base || NULL == dir_home || NULL == dir_engine_info) {
+       if (NULL == dir_config_base || NULL == dir_home || NULL == dir_engine_base || 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;
@@ -160,6 +184,7 @@ 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 {
@@ -182,6 +207,7 @@ 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 {
@@ -196,6 +222,29 @@ 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) {
@@ -204,6 +253,7 @@ 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 {
@@ -233,6 +283,7 @@ 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("@@@");
@@ -250,11 +301,18 @@ 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);
+       }
 
        if (NULL == dir_engine_info) {
                LOGE("[ERROR] Fail to allocate memory");
@@ -584,6 +642,34 @@ 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)
 {
@@ -603,6 +689,7 @@ 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)) {
@@ -618,15 +705,17 @@ int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgid, const char *appid, GList *
                return -1;
        }
 
-       /* Save in /opt/usr/data/ */
+               /* 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_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);
@@ -641,6 +730,145 @@ int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgid, const char *appid, GList *
                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);
+               }
+
+               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 >= g_list_length(list)) {
+                       LOGE("[ERROR] No Engine Metadata");
+                       g_object_unref(g_guser);
+                       g_guser = NULL;
+                       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_object_unref(g_guser);
+                       g_guser = NULL;
+                       G_FREE(g_user_type)
+                       return -1;
+               }
+
+               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;
+               }
+
+               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;
+               }
+       }
 
        xmlFreeDoc(g_doc);
        if (NULL != g_guser) {
@@ -651,6 +879,7 @@ 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;
@@ -675,10 +904,11 @@ 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 /opt/usr/data/ */
+               /* 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");
@@ -690,6 +920,100 @@ int PKGMGR_MDPARSER_PLUGIN_UNINSTALL(const char *pkgid, const char *appid, GList
                LOGE("[ERROR] Fail to remove engine info file");
        }
 
+               /* 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);
+                       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;
+               }
+
+               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);
index 2fc6764..6580bac 100644 (file)
@@ -192,11 +192,6 @@ 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