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>
28 #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 "stt-engine-parser"
46 #define STT_TAG_ENGINE_BASE "stt-engine"
47 #define STT_TAG_ENGINE_NAME "name"
48 #define STT_TAG_ENGINE_ID "id"
49 #define STT_TAG_ENGINE_SETTING "setting"
50 #define STT_TAG_ENGINE_LANGUAGE_SET "languages"
51 #define STT_TAG_ENGINE_LANGUAGE "lang"
52 #define STT_TAG_ENGINE_SILENCE_DETECTION_SUPPORT "silence-detection-support"
53 #define STT_TAG_ENGINE_CREDENTIAL "credential"
55 #define STT_CONFIG_BASE tzplatform_mkpath(tzplatform_getid("TZ_USER_HOME"), "share/.voice")
56 #define STT_HOME tzplatform_mkpath(tzplatform_getid("TZ_USER_HOME"), "share/.voice/stt")
57 #define STT_ENGINE_BASE tzplatform_mkpath(tzplatform_getid("TZ_USER_HOME"), "share/.voice/stt/1.0")
58 #define STT_ENGINE_INFO tzplatform_mkpath(tzplatform_getid("TZ_USER_SHARE"), ".voice/stt/1.0/engine-info")
60 #define STT_GLOBAL_CONFIG_BASE "/etc/skel/share/.voice"
61 #define STT_GLOBAL_HOME "/etc/skel/share/.voice/stt"
62 #define STT_GLOBAL_ENGINE_BASE "/etc/skel/share/.voice/stt/1.0"
63 #define STT_GLOBAL_ENGINE_INFO "/etc/skel/share/.voice/stt/1.0/engine-info"
65 #define STT_METADATA_LANGUAGE "http://tizen.org/metadata/stt-engine/language"
66 #define STT_METADATA_SILENCE_DETECTION "http://tizen.org/metadata/stt-engine/silence-detection"
67 #define STT_METADATA_CREDENTIAL_REQUIRED "http://tizen.org/metadata/stt-engine/credential-required"
68 #define STT_METADATA_ENGINE_SETTING "http://tizen.org/metadata/stt-engine/setting"
69 #define STT_METADATA_ENGINE_NAME "http://tizen.org/metadata/stt-engine/name"
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;
93 static int __create_engine_info_xml(const char *pkgid)
95 LOGD("=== Create engine info doc");
96 g_doc = xmlNewDoc((xmlChar*)"1.0");
98 LOGE("[ERROR] Fail to new doc");
105 static int __save_engine_info_xml(const char *pkgid, gchar *ut, uid_t uid, gid_t gid)
107 LOGD("=== Save engine info doc");
108 char *dir_config_base = NULL;
109 char *dir_home = NULL;
110 char *dir_engine_base = NULL;
111 char *dir_engine_info = NULL;
113 if (NULL == ut || (NULL != ut && 0 == strcmp(ut, "none"))) {
114 LOGE("[ERROR] Usertype is NONE");
118 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(STT_GLOBAL_CONFIG_BASE);
126 dir_home = strdup(STT_GLOBAL_HOME);
127 dir_engine_base = strdup(STT_GLOBAL_ENGINE_BASE);
128 dir_engine_info = strdup(STT_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)
154 LOGD("[DEBUG] dir_engine_info(%s)", dir_engine_info);
156 /* Make directories */
158 // if (0 != access(dir_config_base, F_OK)) {
159 fd = open(dir_config_base, O_DIRECTORY);
161 LOGE("[INFO] No directory : %s, errno : %d", dir_config_base, errno);
162 if (0 != mkdir(dir_config_base, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
163 LOGE("[ERROR] Fail to make directory : %s, errno : %d", dir_config_base, errno);
164 FREE(dir_config_base)
166 FREE(dir_engine_base)
167 FREE(dir_engine_info)
170 LOGD("Success to make directory : %s", dir_config_base);
171 if (0 != chown(dir_config_base, tmp_uid, tmp_gid)) {
172 LOGD("[ERROR] Fail to change user and group, errno : %d", errno);
174 LOGD("[DEBUG] Success to change user and group");
181 // if (0 != access(dir_home, F_OK)) {
182 fd = open(dir_home, O_DIRECTORY);
184 LOGE("[INFO] No directory : %s, errno : %d", dir_home, errno);
185 if (0 != mkdir(dir_home, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
186 LOGE("[ERROR] Fail to make directory : %s, errno : %d", dir_home, errno);
187 FREE(dir_config_base)
189 FREE(dir_engine_base)
190 FREE(dir_engine_info)
193 LOGD("Success to make directory : %s", dir_home);
194 if (0 != chown(dir_home, tmp_uid, tmp_gid)) {
195 LOGD("[ERROR] Fail to change user and group, errno : %d", errno);
197 LOGD("[DEBUG] Success to change user and group");
204 // if (0 != access(dir_engine_base, F_OK)) {
205 fd = open(dir_engine_base, O_DIRECTORY);
207 LOGE("[INFO] No directory : %s, errno : %d", dir_engine_base, errno);
208 if (0 != mkdir(dir_engine_base, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
209 LOGE("[ERROR] Fail to make directory : %s, errno : %d", dir_engine_base, errno);
210 FREE(dir_config_base)
212 FREE(dir_engine_base)
213 FREE(dir_engine_info)
216 LOGD("Success to make directory : %s", dir_engine_base);
217 if (0 != chown(dir_engine_base, tmp_uid, tmp_gid)) {
218 LOGD("[ERROR] Fail to change user and group, errno : %d", errno);
220 LOGD("[DEBUG] Success to change user and group");
227 // if (0 != access(dir_engine_info, F_OK)) {
228 fd = open(dir_engine_info, O_DIRECTORY);
230 LOGE("[INFO] No directory : %s, errno : %d", dir_engine_info, errno);
231 if (0 != mkdir(dir_engine_info, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
232 LOGE("[ERROR] Fail to make directory : %s, errno : %d", dir_engine_info, errno);
233 FREE(dir_config_base)
235 FREE(dir_engine_base)
236 FREE(dir_engine_info)
239 LOGD("Success to make directory : %s", dir_engine_info);
240 if (0 != chown(dir_engine_info, tmp_uid, tmp_gid)) {
241 LOGD("[ERROR] Fail to change user and group, errno : %d", errno);
243 LOGD("[DEBUG] Success to change user and group");
250 char path[256] = {'\0',};
251 snprintf(path, 256, "%s/%s.xml", dir_engine_info, pkgid);
252 int ret = xmlSaveFormatFile(path, g_doc, 1);
253 LOGD("xmlSaveFile (%d)", ret);
255 if (0 != chown(path, tmp_uid, tmp_gid)) {
256 LOGD("[ERROR] Fail to change user and group");
258 LOGD("[DEBUG] Success to change user and group");
262 FREE(dir_config_base)
264 FREE(dir_engine_base)
265 FREE(dir_engine_info)
272 static int __remove_engine_info_xml(const char *pkgid, gchar *ut, uid_t uid)
274 LOGD("=== Remove engine info doc");
275 char *dir_engine_info = NULL;
277 if (NULL == ut || (NULL != ut && 0 == strcmp(ut, "none"))) {
278 LOGE("[ERROR] Usertype is NONE");
282 uid_t globalapp_uid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
284 LOGD("uid(%d)", uid);
286 if (globalapp_uid == uid) {
288 dir_engine_info = strdup(STT_GLOBAL_ENGINE_INFO);
290 /* User app, Guest app, Security app */
291 if (NULL != g_dir_engine_info)
292 dir_engine_info = strdup(g_dir_engine_info);
295 if (NULL == dir_engine_info) {
296 LOGE("[ERROR] Fail to allocate memory");
300 LOGD("[DEBUG] dir_engine_info(%s)", dir_engine_info);
302 char path[256] = {'\0',};
303 snprintf(path, 256, "%s/%s.xml", dir_engine_info, pkgid);
304 if (0 == access(path, F_OK)) {
305 LOGD("Remove engine info xml(%s)", path);
306 if (0 != remove(path)) {
307 LOGE("[ERROR] Fail to emove engine info xml(%s)", path);
311 FREE(dir_engine_info)
318 static void __insert_language_from_metadata(xmlNodePtr root, const char *language)
320 LOGD("==== Insert language");
323 if (NULL == root || NULL == language) {
324 LOGE("Invalid parameter, root(%p), language(%s)", root, language);
328 char *tmp_lang, *tmp_free;
329 tmp_free = tmp_lang = strdup(language);
330 xmlNodePtr languages_node = NULL;
331 xmlNodePtr lang_node = NULL;
333 languages_node = xmlNewNode(NULL, (const xmlChar*)STT_TAG_ENGINE_LANGUAGE_SET);
335 lang = strsep(&tmp_lang, ",");
336 while (NULL != lang) {
337 LOGD("lang (%s)", lang);
338 lang_node = xmlNewNode(NULL, (const xmlChar*)STT_TAG_ENGINE_LANGUAGE);
339 xmlNodeSetContent(lang_node, (const xmlChar*)lang);
340 xmlAddChild(languages_node, lang_node);
341 lang = strsep(&tmp_lang, ",");
343 xmlAddChild(root, languages_node);
348 static int __write_metadata_inxml(const char *pkgid, const char *appid, GList *list)
353 __create_engine_info_xml(pkgid);
355 xmlNodePtr root = NULL;
356 xmlNodePtr cur = NULL;
358 root = xmlNewNode(NULL, (const xmlChar*)STT_TAG_ENGINE_BASE);
361 LOGE("[ERROR] Fail to get new node");
362 // xmlFreeDoc(g_doc);
365 xmlDocSetRootElement(g_doc, root);
367 iter = g_list_first(list);
368 while (NULL != iter) {
369 md = (metadata *)iter->data;
370 if (NULL != md && NULL != md->key && NULL != md->value) {
371 LOGD(" - key(%s) value(%s)", md->key, md->value);
372 if (!strcmp(md->key, STT_METADATA_LANGUAGE)) {
373 __insert_language_from_metadata(root, md->value);
374 } else if (!strcmp(md->key, STT_METADATA_SILENCE_DETECTION)) {
375 cur = xmlNewNode(NULL, (const xmlChar*)STT_TAG_ENGINE_SILENCE_DETECTION_SUPPORT);
376 xmlNodeSetContent(cur, (const xmlChar*)md->value);
377 xmlAddChild(root, cur);
378 } else if (!strcmp(md->key, STT_METADATA_CREDENTIAL_REQUIRED)) {
379 cur = xmlNewNode(NULL, (const xmlChar*)STT_TAG_ENGINE_CREDENTIAL);
380 xmlNodeSetContent(cur, (const xmlChar*)md->value);
381 xmlAddChild(root, cur);
382 } else if (!strcmp(md->key, STT_METADATA_ENGINE_SETTING)) {
383 cur = xmlNewNode(NULL, (const xmlChar*)STT_TAG_ENGINE_SETTING);
384 xmlNodeSetContent(cur, (const xmlChar*)md->value);
385 xmlAddChild(root, cur);
386 } else if (!strcmp(md->key, STT_METADATA_ENGINE_NAME)) {
387 cur = xmlNewNode(NULL, (const xmlChar*)STT_TAG_ENGINE_NAME);
388 xmlNodeSetContent(cur, (const xmlChar*)md->value);
389 xmlAddChild(root, cur);
391 LOGW("[WARNING] Unknown metadata type");
394 iter = g_list_next(iter);
397 cur = xmlNewNode(NULL, (const xmlChar*)STT_TAG_ENGINE_ID);
398 xmlNodeSetContent(cur, (const xmlChar*)appid);
399 xmlAddChild(root, cur);
406 int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgid, const char *appid, GList *list)
408 LOGD("METADATA INSTALL");
409 LOGD("pkgid(%s) appid(%s) list(%d)", pkgid, appid, g_list_length(list));
412 ret = pkgmgr_installer_info_get_target_uid(&g_uid);
414 LOGE("[ERROR] Fail to get target uid");
417 LOGD("uid(%d)", g_uid);
418 printf("[Parser Debug][DEBUG] uid(%d)", g_uid);
421 uid_t globalapp_uid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
422 if (globalapp_uid == g_uid) {
423 g_user_type = g_strdup("admin");
425 g_guser = gum_user_get_sync(g_uid, FALSE);
426 if (NULL == g_guser) {
427 LOGE("[ERROR] g_guser is NULL");
431 g_object_get(G_OBJECT(g_guser), "gid", &g_gid, NULL);
432 g_object_get(G_OBJECT(g_guser), "usertype", &g_ut, NULL);
433 g_user_type = g_strdup(gum_user_type_to_string(g_ut));
436 if (NULL == g_user_type) {
437 LOGE("[ERROR] Fail to allocate memory");
438 if (NULL != g_guser) {
439 g_object_unref(g_guser);
445 if (0 == strcmp(g_user_type, "none")) {
446 /* GUM_USERTYPE_NONE */
447 LOGE("[ERROR] Fail to get target uid");
448 g_object_unref(g_guser);
454 if (globalapp_uid == g_uid) {
455 /* global directory */
456 LOGD("[DEBUG] usertype: %s", g_user_type);
457 if (0 >= g_list_length(list)) {
458 LOGE("[ERROR] No Engine Metadata");
463 if (0 != __write_metadata_inxml(pkgid, appid, list)) {
464 LOGE("[ERROR] Fail to write metadata in the xml");
470 /* Save in /etc/skel/share/ */
471 g_dir_config_base = strdup(STT_GLOBAL_CONFIG_BASE);
472 g_dir_home = strdup(STT_GLOBAL_HOME);
473 g_dir_engine_base = strdup(STT_GLOBAL_ENGINE_BASE);
474 g_dir_engine_info = strdup(STT_GLOBAL_ENGINE_INFO);
476 if (NULL == g_dir_config_base || NULL == g_dir_home || NULL == g_dir_engine_base || NULL == g_dir_engine_info) {
477 LOGE("[ERROR] Fail to allocate memory");
478 FREE(g_dir_config_base)
480 FREE(g_dir_engine_base)
481 FREE(g_dir_engine_info)
487 if (0 != __save_engine_info_xml(pkgid, g_user_type, g_uid, g_gid)) {
488 LOGE("[ERROR] Fail to make engine info file");
494 /* Get user data by using libgum */
496 GumUserService *gus = NULL;
497 GumUserList *users = NULL;
498 GumUserList *iter = NULL;
499 GumUser *user = NULL;
501 GumUserType gumut = GUM_USERTYPE_NONE;
502 gchar *user_type = NULL;
506 gchar *home_dir = NULL;
508 gus = gum_user_service_create_sync(TRUE);
510 LOGE("Failed to create gum user service");
515 query = g_strsplit("admin,normal", ",", -1);
517 users = gum_user_service_get_user_list_sync(gus, (const gchar *const *)query);
528 /* Make new user list */
531 while (iter != NULL) {
532 user = (GumUser*) iter->data;
533 g_object_get(G_OBJECT(user), "uid", &uid, NULL);
536 g_object_get(G_OBJECT(user), "gid", &gid, NULL);
537 g_object_get(G_OBJECT(user), "homedir", &home_dir, NULL);
538 g_object_get(G_OBJECT(user), "usertype", &gumut, NULL);
539 user_type = g_strdup(gum_user_type_to_string(gumut));
540 if (NULL == user_type) {
541 gum_user_service_list_free(users);
548 LOGD("[DEBUG] user info");
549 if (NULL != home_dir) {
550 LOGD("[DEBUG] uid(%d), gid(%d), user_type(%s), home_dir(%s)", uid, gid, user_type, home_dir);
552 g_dir_config_base = (char*)calloc(strlen(home_dir) + 14, sizeof(char));
553 g_dir_home = (char*)calloc(strlen(home_dir) + 18, sizeof(char));
554 g_dir_engine_base = (char*)calloc(strlen(home_dir) + 22, sizeof(char));
555 g_dir_engine_info = (char*)calloc(strlen(home_dir) + 34, sizeof(char));
557 if (NULL == g_dir_config_base || NULL == g_dir_home || NULL == g_dir_engine_base || NULL == g_dir_engine_info) {
558 LOGE("[ERROR] Fail to allocate memory");
559 FREE(g_dir_config_base)
561 FREE(g_dir_engine_base)
562 FREE(g_dir_engine_info)
563 gum_user_service_list_free(users);
570 snprintf(g_dir_config_base, strlen(home_dir) + 14, "%s/share/.voice", home_dir);
571 snprintf(g_dir_home, strlen(home_dir) + 18, "%s/share/.voice/stt", home_dir);
572 snprintf(g_dir_engine_base, strlen(home_dir) + 22, "%s/share/.voice/stt/1.0", home_dir);
573 snprintf(g_dir_engine_info, strlen(home_dir) + 34, "%s/share/.voice/stt/1.0/engine-info", home_dir);
575 LOGD("[DEBUG] g_dir_engine_info(%s)", g_dir_engine_info);
577 if (0 != __save_engine_info_xml(pkgid, user_type, uid, gid)) {
578 LOGE("[ERROR] Fail to make engine info file");
581 FREE(g_dir_config_base)
583 FREE(g_dir_engine_base)
584 FREE(g_dir_engine_info)
590 iter = g_list_next(iter);
593 gum_user_service_list_free(users);
598 LOGD("[DEBUG] usertype: %s", g_user_type);
600 ret = tzplatform_set_user(g_uid);
602 LOGE("[ERROR] Invalid uid");
603 g_object_unref(g_guser);
608 LOGD("TZ_USER_HOME: %s", tzplatform_mkstr(TZ_USER_HOME, "/"));
609 printf("[Parser Debug][DEBUG] TZ_USER_HOME: %s", tzplatform_mkstr(TZ_USER_HOME, "/"));
612 if (0 >= g_list_length(list)) {
613 LOGE("[ERROR] No Engine Metadata");
614 g_object_unref(g_guser);
620 if (0 != __write_metadata_inxml(pkgid, appid, list)) {
621 LOGE("[ERROR] Fail to write metadata in the xml");
623 g_object_unref(g_guser);
629 g_dir_config_base = strdup(STT_CONFIG_BASE);
630 g_dir_home = strdup(STT_HOME);
631 g_dir_engine_base = strdup(STT_ENGINE_BASE);
632 g_dir_engine_info = strdup(STT_ENGINE_INFO);
634 if (NULL == g_dir_config_base || NULL == g_dir_home || NULL == g_dir_engine_base || NULL == g_dir_engine_info) {
635 LOGE("[ERROR] Fail to allocate memory");
636 FREE(g_dir_config_base)
638 FREE(g_dir_engine_base)
639 FREE(g_dir_engine_info)
641 g_object_unref(g_guser);
647 if (0 != __save_engine_info_xml(pkgid, g_user_type, g_uid, g_gid)) {
648 LOGE("[ERROR] Fail to make engine info file");
650 if (NULL != g_guser) {
651 g_object_unref(g_guser);
660 if (NULL != g_guser) {
661 g_object_unref(g_guser);
666 FREE(g_dir_config_base)
668 FREE(g_dir_engine_base)
669 FREE(g_dir_engine_info)
675 int PKGMGR_MDPARSER_PLUGIN_UNINSTALL(const char *pkgid, const char *appid, GList *list)
677 LOGD("METADATA UNINSTALL");
678 LOGD("pkgid(%s) appid(%s) list(%d)", pkgid, appid, g_list_length(list));
681 ret = pkgmgr_installer_info_get_target_uid(&g_uid);
683 LOGE("[ERROR] Fail to get target uid");
686 LOGD("uid(%d)", g_uid);
687 printf("[Parser Debug][DEBUG] uid(%d)", g_uid);
690 uid_t globalapp_uid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
691 if (globalapp_uid == g_uid) {
692 g_user_type = g_strdup("admin");
694 g_guser = gum_user_get_sync(g_uid, FALSE);
695 if (NULL == g_guser) {
696 LOGE("[ERROR] g_guser is NULL");
700 g_object_get(G_OBJECT(g_guser), "usertype", &g_ut, NULL);
701 g_user_type = g_strdup(gum_user_type_to_string(g_ut));
704 if (NULL == g_user_type) {
705 LOGE("[ERROR] Fail to allocate memory");
706 if (NULL != g_guser) {
707 g_object_unref(g_guser);
713 if (0 == strcmp(g_user_type, "none")) {
714 /* GUM_USERTYPE_NONE */
715 LOGE("[ERROR] Fail to get target uid");
716 g_object_unref(g_guser);
722 if (globalapp_uid == g_uid) {
723 /* global directory */
724 LOGD("[DEBUG] usertype: %s", g_user_type);
726 /* Remove files in /etc/skel/share/ */
727 g_dir_engine_info = strdup(STT_GLOBAL_ENGINE_INFO);
728 if (NULL == g_dir_engine_info) {
729 LOGE("[ERROR] Fail to allocate memory");
734 if (0 != __remove_engine_info_xml(pkgid, g_user_type, g_uid)) {
735 LOGE("[ERROR] Fail to remove engine info file");
738 /* Get user data by using libgum */
740 GumUserService *gus = NULL;
741 GumUserList *users = NULL;
742 GumUserList *iter = NULL;
743 GumUser *user = NULL;
745 GumUserType gumut = GUM_USERTYPE_NONE;
746 gchar *user_type = NULL;
749 gchar *home_dir = NULL;
751 GList *md_iter = NULL;
754 gus = gum_user_service_create_sync(TRUE);
756 LOGE("Failed to create gum user service");
761 query = g_strsplit("admin,normal", ",", -1);
763 users = gum_user_service_get_user_list_sync(gus, (const gchar *const *)query);
774 /* Make new user list */
777 while (iter != NULL) {
778 user = (GumUser*) iter->data;
779 g_object_get(G_OBJECT(user), "uid", &uid, NULL);
781 g_object_get(G_OBJECT(user), "homedir", &home_dir, NULL);
782 g_object_get(G_OBJECT(user), "usertype", &gumut, NULL);
783 user_type = g_strdup(gum_user_type_to_string(gumut));
784 if (NULL == user_type) {
785 gum_user_service_list_free(users);
792 if (NULL != home_dir) {
793 g_dir_engine_info = (char*)calloc(strlen(home_dir) + 34, sizeof(char));
794 if (NULL == g_dir_engine_info) {
795 gum_user_service_list_free(users);
803 snprintf(g_dir_engine_info, strlen(home_dir) + 34, "%s/share/.voice/stt/1.0/engine-info", home_dir);
805 md_iter = g_list_first(list);
806 while (NULL != md_iter) {
807 md = (metadata *)md_iter->data;
808 LOGD(" - key(%s) value(%s)", md->key, md->value);
809 md_iter = g_list_next(md_iter);
812 if (0 != __remove_engine_info_xml(pkgid, user_type, uid)) {
813 LOGE("[ERROR] Fail to remove engine info file");
817 G_FREE(g_dir_engine_info)
821 LOGD("Finish release memory");
822 iter = g_list_next(iter);
823 LOGD("Finish next iter");
826 gum_user_service_list_free(users);
831 LOGD("[DEBUG] usertype: %s", g_user_type);
833 ret = tzplatform_set_user(g_uid);
835 LOGE("[ERROR] Invalid uid");
836 g_object_unref(g_guser);
841 LOGD("TZ_USER_HOME: %s", tzplatform_mkstr(TZ_USER_HOME, "/"));
842 printf("[Parser Debug][DEBUG] TZ_USER_HOME: %s", tzplatform_mkstr(TZ_USER_HOME, "/"));
845 g_dir_engine_info = strdup(STT_ENGINE_INFO);
846 if (NULL == g_dir_engine_info) {
847 LOGE("[ERROR] Fail to allocate memory");
848 g_object_unref(g_guser);
854 if (0 != __remove_engine_info_xml(pkgid, g_user_type, g_uid)) {
855 LOGE("[ERROR] Fail to remove engine info file");
860 if (NULL != g_guser) {
861 g_object_unref(g_guser);
866 FREE(g_dir_engine_info)
873 int PKGMGR_MDPARSER_PLUGIN_UPGRADE(const char *pkgid, const char *appid, GList *list)
875 LOGD("METADATA UPGRADE");
876 LOGD("pkgid(%s) appid(%s) list(%d)", pkgid, appid, g_list_length(list));
878 PKGMGR_MDPARSER_PLUGIN_UNINSTALL(pkgid, appid, list);
879 PKGMGR_MDPARSER_PLUGIN_INSTALL(pkgid, appid, list);