2 // Copyright (c) 2016 Samsung Electronics Co., Ltd.
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
17 #include <app_manager.h>
21 #include <libxml/parser.h>
22 #include <libxml/tree.h>
23 #include <pkgmgr-info.h>
24 #include <pkgmgr_installer_info.h>
27 #include <sys/types.h>
29 #include <tzplatform_config.h>
30 #include <systemd/sd-login.h>
32 #include <gum/gum-user.h>
33 #include <gum/gum-user-service.h>
34 #include <gum/common/gum-user-types.h>
36 /* Define EXPORT_API */
38 #define EXPORT_API __attribute__((visibility("default")))
44 #define LOG_TAG "tts-engine-parser"
46 #define TTS_TAG_ENGINE_BASE "tts-engine"
47 #define TTS_TAG_ENGINE_NAME "name"
48 #define TTS_TAG_ENGINE_ID "id"
49 #define TTS_TAG_ENGINE_SETTING "setting"
50 #define TTS_TAG_ENGINE_VOICE_SET "voices"
51 #define TTS_TAG_ENGINE_VOICE "voice"
52 #define TTS_TAG_ENGINE_VOICE_TYPE "type"
53 #define TTS_TAG_ENGINE_PITCH_SUPPORT "pitch-support"
54 #define TTS_TAG_ENGINE_CREDENTIAL "credential"
56 #define TTS_CONFIG_BASE tzplatform_mkpath(TZ_USER_HOME, "share/.voice")
57 #define TTS_HOME tzplatform_mkpath(TZ_USER_HOME, "share/.voice/tts")
58 #define TTS_ENGINE_BASE tzplatform_mkpath(TZ_USER_HOME, "share/.voice/tts/1.0")
59 #define TTS_ENGINE_INFO tzplatform_mkpath(TZ_USER_SHARE, ".voice/tts/1.0/engine-info")
61 #define TTS_GLOBAL_CONFIG_BASE "/etc/skel/share/.voice"
62 #define TTS_GLOBAL_HOME "/etc/skel/share/.voice/tts"
63 #define TTS_GLOBAL_ENGINE_BASE "/etc/skel/share/.voice/tts/1.0"
64 #define TTS_GLOBAL_ENGINE_INFO "/etc/skel/share/.voice/tts/1.0/engine-info"
66 #define TTS_METADATA_NAME "http://tizen.org/metadata/tts-engine/name"
67 #define TTS_METADATA_LANGUAGE "http://tizen.org/metadata/tts-engine/language"
68 #define TTS_METADATA_CREDENTIAL_REQUIRED "http://tizen.org/metadata/tts-engine/credential-required"
69 #define TTS_METADATA_SETTING "http://tizen.org/metadata/tts-engine/setting"
72 #define FREE(x) { if (NULL != x) { free(x); x = NULL; } }
73 #define G_FREE(x) { if (NULL != x) { g_free(x); x = NULL; } }
75 typedef struct metadata {
80 static xmlDocPtr g_doc;
81 GumUser *g_guser = NULL;
82 uid_t g_uid = 301; // app_fw
83 gid_t g_gid = 301; // app_fw
84 GumUserType g_ut = GUM_USERTYPE_NONE;
85 gchar *g_user_type = NULL;
87 char *g_dir_config_base = NULL;
88 char *g_dir_home = NULL;
89 char *g_dir_engine_base = NULL;
90 char *g_dir_engine_info = NULL;
92 static int __create_engine_info_xml(const char *pkgid)
94 LOGD("=== Create engine info doc");
95 g_doc = xmlNewDoc((xmlChar*)"1.0");
97 LOGE("[ERROR] Fail to new doc");
104 static int __save_engine_info_xml(const char *pkgid, gchar *ut, uid_t uid, gid_t gid)
106 LOGD("=== Save engine info doc");
107 char *dir_config_base = NULL;
108 char *dir_home = NULL;
109 char *dir_engine_base = NULL;
110 char *dir_engine_info = NULL;
112 if (NULL == ut || (NULL != ut && 0 == strcmp(ut, "none"))) {
113 LOGE("[ERROR] Usertype is NONE");
117 uid_t globalapp_uid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
121 LOGD("uid(%d)", uid);
123 if (globalapp_uid == uid) {
125 dir_config_base = strdup(TTS_GLOBAL_CONFIG_BASE);
126 dir_home = strdup(TTS_GLOBAL_HOME);
127 dir_engine_base = strdup(TTS_GLOBAL_ENGINE_BASE);
128 dir_engine_info = strdup(TTS_GLOBAL_ENGINE_INFO);
129 tmp_uid = 301; // app_fw
130 tmp_gid = 301; // app_fw
132 /* User app, Guest app, Security app */
133 if (NULL != g_dir_config_base)
134 dir_config_base = strdup(g_dir_config_base);
135 if (NULL != g_dir_home)
136 dir_home = strdup(g_dir_home);
137 if (NULL != g_dir_engine_base)
138 dir_engine_base = strdup(g_dir_engine_base);
139 if (NULL != g_dir_engine_info)
140 dir_engine_info = strdup(g_dir_engine_info);
145 if (NULL == dir_config_base || NULL == dir_home || NULL == dir_engine_base || NULL == dir_engine_info) {
146 LOGE("[ERROR] Fail to allocate memory");
147 FREE(dir_config_base)
149 FREE(dir_engine_base)
150 FREE(dir_engine_info)
155 LOGD("[DEBUG] dir_engine_info(%s)", dir_engine_info);
158 /* Make directories */
160 // if (0 != access(dir_config_base, F_OK)) {
161 fd = open(dir_config_base, O_DIRECTORY);
163 LOGE("[INFO] No directory : %s, errno : %d", dir_config_base, errno);
164 if (0 != mkdir(dir_config_base, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
165 LOGE("[ERROR] Fail to make directory : %s, errno : %d", dir_config_base, errno);
166 FREE(dir_config_base)
168 FREE(dir_engine_base)
169 FREE(dir_engine_info)
172 LOGD("Success to make directory : %s", dir_config_base);
173 if (0 != chown(dir_config_base, tmp_uid, tmp_gid)) {
174 LOGD("[ERROR] Fail to change user and group, errno : %d", errno);
176 LOGD("[DEBUG] Success to change user and group");
183 // if (0 != access(dir_home, F_OK)) {
184 fd = open(dir_home, O_DIRECTORY);
186 LOGE("[INFO] No directory : %s, errno : %d", dir_home, errno);
187 if (0 != mkdir(dir_home, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
188 LOGE("[ERROR] Fail to make directory : %s, errno : %d", dir_home, errno);
189 FREE(dir_config_base)
191 FREE(dir_engine_base)
192 FREE(dir_engine_info)
195 LOGD("Success to make directory : %s", dir_home);
196 if (0 != chown(dir_home, tmp_uid, tmp_gid)) {
197 LOGD("[ERROR] Fail to change user and group, errno : %d", errno);
199 LOGD("[DEBUG] Success to change user and group");
206 // if (0 != access(dir_engine_base, F_OK)) {
207 fd = open(dir_engine_base, O_DIRECTORY);
209 LOGE("[INFO] No directory : %s, errno : %d", dir_engine_base, errno);
210 if (0 != mkdir(dir_engine_base, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
211 LOGE("[ERROR] Fail to make directory : %s, errno : %d", dir_engine_base, errno);
212 FREE(dir_config_base)
214 FREE(dir_engine_base)
215 FREE(dir_engine_info)
218 LOGD("Success to make directory : %s", dir_engine_base);
219 if (0 != chown(dir_engine_base, tmp_uid, tmp_gid)) {
220 LOGD("[ERROR] Fail to change user and group, errno : %d", errno);
222 LOGD("[DEBUG] Success to change user and group");
229 // if (0 != access(dir_engine_info, F_OK)) {
230 fd = open(dir_engine_info, O_DIRECTORY);
232 LOGE("[INFO] No directory : %s, errno : %d", dir_engine_info, errno);
233 if (0 != mkdir(dir_engine_info, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
234 LOGE("[ERROR] Fail to make directory : %s, errno : %d", dir_engine_info, errno);
235 FREE(dir_config_base)
237 FREE(dir_engine_base)
238 FREE(dir_engine_info)
241 LOGD("Success to make directory : %s", dir_engine_info);
242 if (0 != chown(dir_engine_info, tmp_uid, tmp_gid)) {
243 LOGD("[ERROR] Fail to change user and group, errno : %d", errno);
245 LOGD("[DEBUG] Success to change user and group");
253 char path[256] = {'\0',};
254 snprintf(path, 256, "%s/%s.xml", dir_engine_info, pkgid);
255 int ret = xmlSaveFormatFile(path, g_doc, 1);
256 LOGD("xmlSaveFile (%d)", ret);
258 if (0 != chown(path, tmp_uid, tmp_gid)) {
259 LOGD("[ERROR] Fail to change user and group");
261 LOGD("[DEBUG] Success to change user and group");
265 FREE(dir_config_base)
267 FREE(dir_engine_base)
268 FREE(dir_engine_info)
274 static int __remove_engine_info_xml(const char *pkgid, gchar *ut, uid_t uid)
276 LOGD("=== Remove engine info doc");
278 char *dir_engine_info = NULL;
280 if (NULL == ut || (NULL != ut && 0 == strcmp(ut, "none"))) {
281 LOGE("[ERROR] Usertype is NONE");
285 uid_t globalapp_uid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
287 LOGD("uid(%d)", uid);
289 if (globalapp_uid == uid) {
291 dir_engine_info = strdup(TTS_GLOBAL_ENGINE_INFO);
293 /* User app, Guest app, Security app */
294 if (NULL != g_dir_engine_info)
295 dir_engine_info = strdup(g_dir_engine_info);
298 if (NULL == dir_engine_info) {
299 LOGE("[ERROR] Fail to allocate memory");
303 LOGD("[DEBUG] dir_engine_info(%s)", dir_engine_info);
306 char path[256] = {'\0',};
307 snprintf(path, 256, "%s/%s.xml", dir_engine_info, pkgid);
308 if (0 == access(path, F_OK)) {
309 LOGD("Remove engine info xml(%s)", path);
310 if (0 != remove(path)) {
311 LOGE("[ERROR] Fail to Remove engine info xml(%s)", path);
315 FREE(dir_engine_info)
321 static void __insert_language_from_metadata(xmlNodePtr root, const char *language)
323 LOGD("==== Insert language");
327 if (NULL == root || NULL == language) {
328 LOGE("Invalid parameter, root(%p), language(%s)", root, language);
332 char *tmp_lang = NULL;
333 char *tmp_free = NULL;
334 tmp_free = tmp_lang = strdup(language);
335 if (NULL == tmp_lang) {
336 LOGE("Fail to memory allocation");
339 xmlNodePtr voices_node = NULL;
340 xmlNodePtr voice_node = NULL;
342 voices_node = xmlNewNode(NULL, (const xmlChar*)TTS_TAG_ENGINE_VOICE_SET);
344 voice = strsep(&tmp_lang, ",");
345 while (NULL != voice) {
346 LOGD("voice (%s)", voice);
347 voice_node = xmlNewNode(NULL, (const xmlChar*)TTS_TAG_ENGINE_VOICE);
348 lang = strsep(&voice, ":");
349 LOGD("lang (%s)", lang);
350 type = strsep(&voice, " ");
351 LOGD("type (%s)", type);
352 xmlSetProp(voice_node, (const xmlChar*)TTS_TAG_ENGINE_VOICE_TYPE, (const xmlChar*)type);
353 xmlNodeSetContent(voice_node, (const xmlChar*)lang);
354 xmlAddChild(voices_node, voice_node);
355 voice = strsep(&tmp_lang, ",");
357 xmlAddChild(root, voices_node);
362 static int __write_metadata_inxml(const char *pkgid, const char *appid, GList *list)
367 __create_engine_info_xml(pkgid);
369 xmlNodePtr root = NULL;
370 xmlNodePtr cur = NULL;
372 root = xmlNewNode(NULL, (const xmlChar*)TTS_TAG_ENGINE_BASE);
374 LOGE("[ERROR] Fail to get new node");
375 // xmlFreeDoc(g_doc);
378 xmlDocSetRootElement(g_doc, root);
381 // cur = xmlNewNode(NULL, (const xmlChar*)TTS_TAG_ENGINE_NAME);
382 // xmlNodeSetContent(cur, (const xmlChar*)pkgid);
383 // xmlAddChild(root, cur);
386 iter = g_list_first(list);
387 while (NULL != iter) {
388 md = (metadata *)iter->data;
389 if (NULL != md && NULL != md->key) {
390 LOGD(" - key(%s) value(%s)", md->key, md->value);
391 if (!strcmp(md->key, TTS_METADATA_LANGUAGE)) {
392 __insert_language_from_metadata(root, md->value);
393 } else if (!strcmp(md->key, TTS_METADATA_CREDENTIAL_REQUIRED)) {
394 cur = xmlNewNode(NULL, (const xmlChar*)TTS_TAG_ENGINE_CREDENTIAL);
395 xmlNodeSetContent(cur, (const xmlChar*)md->value);
396 xmlAddChild(root, cur);
397 } else if (!strcmp(md->key, TTS_METADATA_SETTING)) {
398 cur = xmlNewNode(NULL, (const xmlChar*)TTS_TAG_ENGINE_SETTING);
399 xmlNodeSetContent(cur, (const xmlChar*)md->value);
400 xmlAddChild(root, cur);
401 } else if (!strcmp(md->key, TTS_METADATA_NAME)) {
402 cur = xmlNewNode(NULL, (const xmlChar*)TTS_TAG_ENGINE_NAME);
403 xmlNodeSetContent(cur, (const xmlChar*)md->value);
404 xmlAddChild(root, cur);
406 LOGW("[WARNING] Unknown metadata type");
409 iter = g_list_next(iter);
412 cur = xmlNewNode(NULL, (const xmlChar*)TTS_TAG_ENGINE_ID);
413 xmlNodeSetContent(cur, (const xmlChar*)pkgid);
414 xmlAddChild(root, cur);
423 int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgid, const char *appid, GList *list)
425 LOGD("METADATA INSTALL");
426 LOGD("pkgid(%s) appid(%s) list(%d)", pkgid, appid, g_list_length(list));
429 ret = pkgmgr_installer_info_get_target_uid(&g_uid);
431 LOGE("[ERROR] Fail to get target uid");
434 LOGD("uid(%d)", g_uid);
435 printf("[Parser Debug][DEBUG] uid(%d)", g_uid);
438 uid_t globalapp_uid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
439 if (globalapp_uid == g_uid) {
440 g_user_type = g_strdup("admin");
442 g_guser = gum_user_get_sync(g_uid, FALSE);
443 if (NULL == g_guser) {
444 LOGE("[ERROR] g_guser is NULL");
448 g_object_get(G_OBJECT(g_guser), "gid", &g_gid, NULL);
449 g_object_get(G_OBJECT(g_guser), "usertype", &g_ut, NULL);
450 g_user_type = g_strdup(gum_user_type_to_string(g_ut));
453 if (NULL == g_user_type) {
454 LOGE("[ERROR] Fail to allocate memory");
455 if (NULL != g_guser) {
456 g_object_unref(g_guser);
462 if (0 == strcmp(g_user_type, "none")) {
463 /* GUM_USERTYPE_NONE */
464 LOGE("[ERROR] Fail to get target uid");
465 g_object_unref(g_guser);
471 if (globalapp_uid == g_uid) {
472 /* global directory */
473 LOGD("[DEBUG] usertype: %s", g_user_type);
474 if (0 >= g_list_length(list)) {
475 LOGE("[ERROR] No Engine Metadata");
480 if (0 != __write_metadata_inxml(pkgid, appid, list)) {
481 LOGE("[ERROR] Fail to write metadata in the xml");
487 /* Save in /etc/skel/share/ */
488 g_dir_config_base = strdup(TTS_GLOBAL_CONFIG_BASE);
489 g_dir_home = strdup(TTS_GLOBAL_HOME);
490 g_dir_engine_base = strdup(TTS_GLOBAL_ENGINE_BASE);
491 g_dir_engine_info = strdup(TTS_GLOBAL_ENGINE_INFO);
493 if (NULL == g_dir_config_base || NULL == g_dir_home || NULL == g_dir_engine_base || NULL == g_dir_engine_info) {
494 LOGE("[ERROR] Fail to allocate memory");
495 FREE(g_dir_config_base)
497 FREE(g_dir_engine_base)
498 FREE(g_dir_engine_info)
505 if (0 != __save_engine_info_xml(pkgid, g_user_type, g_uid, g_gid)) {
506 LOGE("[ERROR] Fail to make engine info file");
512 /* Get user data by using libgum */
514 GumUserService *gus = NULL;
515 GumUserList *users = NULL;
516 GumUserList *iter = NULL;
517 GumUser *user = NULL;
519 GumUserType gumut = GUM_USERTYPE_NONE;
520 gchar *user_type = NULL;
524 gchar *home_dir = NULL;
526 gus = gum_user_service_create_sync(TRUE);
528 LOGE("Failed to create gum user service");
533 query = g_strsplit("admin,normal", ",", -1);
535 users = gum_user_service_get_user_list_sync(gus, (const gchar *const *)query);
539 LOGE("Failed to get gum user list");
546 /* Make new user list */
549 while (iter != NULL) {
550 user = (GumUser*) iter->data;
551 g_object_get(G_OBJECT(user), "uid", &uid, NULL);
554 g_object_get(G_OBJECT(user), "gid", &gid, NULL);
555 g_object_get(G_OBJECT(user), "homedir", &home_dir, NULL);
556 g_object_get(G_OBJECT(user), "usertype", &gumut, NULL);
557 user_type = g_strdup(gum_user_type_to_string(gumut));
558 if (NULL == user_type) {
559 gum_user_service_list_free(users);
566 LOGD("[DEBUG] user info");
567 if (NULL != home_dir) {
568 LOGD("[DEBUG] uid(%d), gid(%d), user_type(%s), home_dir(%s)", uid, gid, user_type, home_dir);
570 g_dir_config_base = (char*)calloc(strlen(home_dir) + 14, sizeof(char));
571 g_dir_home = (char*)calloc(strlen(home_dir) + 18, sizeof(char));
572 g_dir_engine_base = (char*)calloc(strlen(home_dir) + 22, sizeof(char));
573 g_dir_engine_info = (char*)calloc(strlen(home_dir) + 34, sizeof(char));
575 if (NULL == g_dir_config_base || NULL == g_dir_home || NULL == g_dir_engine_base || NULL == g_dir_engine_info) {
576 LOGE("[ERROR] Fail to allocate memory");
577 FREE(g_dir_config_base)
579 FREE(g_dir_engine_base)
580 FREE(g_dir_engine_info)
581 gum_user_service_list_free(users);
588 snprintf(g_dir_config_base, strlen(home_dir) + 14, "%s/share/.voice", home_dir);
589 snprintf(g_dir_home, strlen(home_dir) + 18, "%s/share/.voice/tts", home_dir);
590 snprintf(g_dir_engine_base, strlen(home_dir) + 22, "%s/share/.voice/tts/1.0", home_dir);
591 snprintf(g_dir_engine_info, strlen(home_dir) + 34, "%s/share/.voice/tts/1.0/engine-info", home_dir);
593 LOGD("[DEBUG] g_dir_engine_info(%s)", g_dir_engine_info);
595 if (0 != __save_engine_info_xml(pkgid, user_type, uid, gid)) {
596 LOGE("[ERROR] Fail to make engine info file");
599 FREE(g_dir_config_base)
601 FREE(g_dir_engine_base)
602 FREE(g_dir_engine_info)
608 iter = g_list_next(iter);
611 gum_user_service_list_free(users);
616 LOGD("[DEBUG] usertype: %s", g_user_type);
618 ret = tzplatform_set_user(g_uid);
620 LOGE("[ERROR] Invalid uid");
621 g_object_unref(g_guser);
626 LOGD("TZ_USER_HOME: %s", tzplatform_mkstr(TZ_USER_HOME, "/"));
627 printf("[Parser Debug][DEBUG] TZ_USER_HOME: %s", tzplatform_mkstr(TZ_USER_HOME, "/"));
630 if (0 >= g_list_length(list)) {
631 LOGE("[ERROR] No Engine Metadata");
632 g_object_unref(g_guser);
638 if (0 != __write_metadata_inxml(pkgid, appid, list)) {
639 LOGE("[ERROR] Fail to write metadata in the xml");
641 g_object_unref(g_guser);
647 g_dir_config_base = strdup(TTS_CONFIG_BASE);
648 g_dir_home = strdup(TTS_HOME);
649 g_dir_engine_base = strdup(TTS_ENGINE_BASE);
650 g_dir_engine_info = strdup(TTS_ENGINE_INFO);
652 if (NULL == g_dir_config_base || NULL == g_dir_home || NULL == g_dir_engine_base || NULL == g_dir_engine_info) {
653 LOGE("[ERROR] Fail to allocate memory");
654 FREE(g_dir_config_base)
656 FREE(g_dir_engine_base)
657 FREE(g_dir_engine_info)
659 g_object_unref(g_guser);
665 if (0 != __save_engine_info_xml(pkgid, g_user_type, g_uid, g_gid)) {
666 LOGE("[ERROR] Fail to make engine info file");
668 if (NULL != g_guser) {
669 g_object_unref(g_guser);
678 if (NULL != g_guser) {
679 g_object_unref(g_guser);
684 FREE(g_dir_config_base)
686 FREE(g_dir_engine_base)
687 FREE(g_dir_engine_info)
693 int PKGMGR_MDPARSER_PLUGIN_UNINSTALL(const char *pkgid, const char *appid, GList *list)
695 LOGD("METADATA UNINSTALL");
696 LOGD("pkgid(%s) appid(%s) list(%d)", pkgid, appid, g_list_length(list));
699 ret = pkgmgr_installer_info_get_target_uid(&g_uid);
701 LOGE("[ERROR] Fail to get target uid");
704 LOGD("uid(%d)", g_uid);
705 printf("[Parser Debug][DEBUG] uid(%d)", g_uid);
708 uid_t globalapp_uid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
709 if (globalapp_uid == g_uid) {
710 g_user_type = g_strdup("admin");
712 g_guser = gum_user_get_sync(g_uid, FALSE);
713 if (NULL == g_guser) {
714 LOGE("[ERROR] g_guser is NULL");
718 g_object_get(G_OBJECT(g_guser), "usertype", &g_ut, NULL);
719 g_user_type = g_strdup(gum_user_type_to_string(g_ut));
722 if (NULL == g_user_type) {
723 LOGE("[ERROR] Fail to allocate memory");
724 if (NULL != g_guser) {
725 g_object_unref(g_guser);
731 if (0 == strcmp(g_user_type, "none")) {
732 /* GUM_USERTYPE_NONE */
733 LOGE("[ERROR] Fail to get target uid");
734 g_object_unref(g_guser);
740 if (globalapp_uid == g_uid) {
741 /* global directory */
742 LOGD("[DEBUG] usertype: %s", g_user_type);
744 /* Remove files in /etc/skel/share/ */
745 g_dir_engine_info = strdup(TTS_GLOBAL_ENGINE_INFO);
746 if (NULL == g_dir_engine_info) {
747 LOGE("[ERROR] Fail to allocate memory");
752 if (0 != __remove_engine_info_xml(pkgid, g_user_type, g_uid)) {
753 LOGE("[ERROR] Fail to remove engine info file");
756 /* Get user data by using libgum */
758 GumUserService *gus = NULL;
759 GumUserList *users = NULL;
760 GumUserList *iter = NULL;
761 GumUser *user = NULL;
763 GumUserType gumut = GUM_USERTYPE_NONE;
764 gchar *user_type = NULL;
767 gchar *home_dir = NULL;
769 GList *md_iter = NULL;
772 gus = gum_user_service_create_sync(TRUE);
774 LOGE("Failed to create gum user service");
779 query = g_strsplit("admin,normal", ",", -1);
781 users = gum_user_service_get_user_list_sync(gus, (const gchar *const *)query);
785 LOGE("Failed to get gum user list");
792 /* Make new user list */
795 while (iter != NULL) {
796 user = (GumUser*) iter->data;
797 g_object_get(G_OBJECT(user), "uid", &uid, NULL);
799 g_object_get(G_OBJECT(user), "homedir", &home_dir, NULL);
800 g_object_get(G_OBJECT(user), "usertype", &gumut, NULL);
801 user_type = g_strdup(gum_user_type_to_string(gumut));
802 if (NULL == user_type) {
803 gum_user_service_list_free(users);
810 if (NULL != home_dir) {
811 g_dir_engine_info = (char*)calloc(strlen(home_dir) + 34, sizeof(char));
812 if (NULL == g_dir_engine_info) {
813 gum_user_service_list_free(users);
821 snprintf(g_dir_engine_info, strlen(home_dir) + 34, "%s/share/.voice/tts/1.0/engine-info", home_dir);
823 md_iter = g_list_first(list);
824 while (NULL != md_iter) {
825 md = (metadata *)md_iter->data;
826 LOGD(" - key(%s) value(%s)", md->key, md->value);
827 md_iter = g_list_next(md_iter);
830 if (0 != __remove_engine_info_xml(pkgid, user_type, uid)) {
831 LOGE("[ERROR] Fail to remove engine info file");
835 FREE(g_dir_engine_info)
839 LOGD("Finish release memory");
840 iter = g_list_next(iter);
841 LOGD("Finish next iter");
844 gum_user_service_list_free(users);
849 LOGD("[DEBUG] usertype: %s", g_user_type);
851 ret = tzplatform_set_user(g_uid);
853 LOGE("[ERROR] Invalid uid");
854 g_object_unref(g_guser);
859 LOGD("TZ_USER_HOME: %s", tzplatform_mkstr(TZ_USER_HOME, "/"));
860 printf("[Parser Debug][DEBUG] TZ_USER_HOME: %s", tzplatform_mkstr(TZ_USER_HOME, "/"));
863 g_dir_engine_info = strdup(TTS_ENGINE_INFO);
864 if (NULL == g_dir_engine_info) {
865 LOGE("[ERROR] Fail to allocate memory");
866 g_object_unref(g_guser);
872 if (0 != __remove_engine_info_xml(pkgid, g_user_type, g_uid)) {
873 LOGE("[ERROR] Fail to remove engine info file");
878 if (NULL != g_guser) {
879 g_object_unref(g_guser);
884 FREE(g_dir_engine_info)
891 int PKGMGR_MDPARSER_PLUGIN_UPGRADE(const char *pkgid, const char *appid, GList *list)
893 LOGD("METADATA UPGRADE");
894 LOGD("pkgid(%s) appid(%s) list(%d)", pkgid, appid, g_list_length(list));
896 PKGMGR_MDPARSER_PLUGIN_UNINSTALL(pkgid, appid, list);
897 PKGMGR_MDPARSER_PLUGIN_INSTALL(pkgid, appid, list);