4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
7 * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
31 #include <libxml/parser.h>
32 #include <libxml/xmlreader.h>
33 #include <libxml/xmlschemas.h>
38 #include "pkgmgr-info.h"
39 #include "pkgmgrinfo_basic.h"
40 #include "pkgmgrinfo_debug.h"
42 #include "pkgmgr_parser.h"
43 #include "pkgmgr_parser_internal.h"
44 #include "pkgmgr_parser_db.h"
49 #define LOG_TAG "PKGMGR_PARSER"
51 #define ASCII(s) (char *)s
52 #define XMLCHAR(s) (const xmlChar *)s
54 #define METADATA_PARSER_LIST SYSCONFDIR "/package-manager/parserlib/metadata/mdparser_list.txt"
55 #define METADATA_PARSER_NAME "metadataparser:"
57 #define CATEGORY_PARSER_LIST SYSCONFDIR "/package-manager/parserlib/category/category_parser_list.txt"
58 #define CATEGORY_PARSER_NAME "categoryparser:"
60 #define TAG_PARSER_LIST SYSCONFDIR "/package-manager/parserlib/tag_parser_list.txt"
61 #define TAG_PARSER_NAME "parserlib:"
63 #define PKG_TAG_LEN_MAX 128
66 #define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
68 /* plugin process_type */
70 PLUGIN_PRE_PROCESS = 0,
72 } PLUGIN_PROCESS_TYPE;
76 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label);
77 static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege);
78 static int __ps_process_privileges(xmlTextReaderPtr reader, GList **privileges);
79 static int __ps_process_allowed(xmlTextReaderPtr reader, char **allowed);
80 static int __ps_process_condition(xmlTextReaderPtr reader, char **condition);
81 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notifiation);
82 static int __ps_process_category(xmlTextReaderPtr reader, char **category);
83 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata);
84 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission);
85 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility);
86 static int __ps_process_request(xmlTextReaderPtr reader, char **request);
87 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define);
88 static int __ps_process_launchconditions(xmlTextReaderPtr reader, GList **launchconditions);
89 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare);
90 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon, uid_t uid);
91 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author);
92 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description);
93 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license);
94 static int __ps_process_appcontrol(xmlTextReaderPtr reader, GList **appcontrol);
95 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol);
96 static int __ps_process_application(xmlTextReaderPtr reader, application_x *application, int type, uid_t uid);
97 static int __next_child_element(xmlTextReaderPtr reader, int depth);
98 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx, uid_t uid);
99 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx, uid_t uid);
100 static void __str_trim(char *input);
101 static char *__get_parser_plugin(const char *type);
102 API int __is_admin();
104 static void __save_xml_attribute(xmlTextReaderPtr reader, char *attribute, char **xml_attribute, char *default_value)
106 xmlChar *attrib_val = xmlTextReaderGetAttribute(reader, XMLCHAR(attribute));
108 *xml_attribute = strdup((const char *)attrib_val);
111 if (default_value != NULL)
112 *xml_attribute = strdup(default_value);
116 static void __save_xml_lang(xmlTextReaderPtr reader, char **xml_attribute)
118 const xmlChar *attrib_val = xmlTextReaderConstXmlLang(reader);
119 if (attrib_val != NULL)
120 *xml_attribute = strdup(ASCII(attrib_val));
122 *xml_attribute = strdup(DEFAULT_LOCALE);
125 static void __save_xml_value(xmlTextReaderPtr reader, char **xml_attribute)
127 xmlTextReaderRead(reader);
128 const xmlChar *attrib_val = xmlTextReaderConstValue(reader);
131 *xml_attribute = strdup((const char *)attrib_val);
134 static void __save_xml_installed_time(manifest_x *mfx)
136 char buf[PKG_STRING_LEN_MAX] = {'\0'};
140 snprintf(buf, PKG_STRING_LEN_MAX - 1, "%d", (int)current_time);
141 val = strndup(buf, PKG_STRING_LEN_MAX - 1);
142 mfx->installed_time = val;
145 static void __save_xml_root_path(manifest_x *mfx, uid_t uid)
147 char root[PKG_STRING_LEN_MAX] = { '\0' };
153 tzplatform_set_user(uid);
154 path = tzplatform_getenv((uid == OWNER_ROOT || uid == GLOBAL_USER) ? TZ_SYS_RO_APP : TZ_USER_APP);
155 snprintf(root, PKG_STRING_LEN_MAX - 1, "%s/%s", path, mfx->package);
157 mfx->root_path = strdup(root);
159 tzplatform_reset_user();
162 static void __save_xml_default_value(manifest_x * mfx)
164 mfx->preload = strdup("False");
165 mfx->removable = strdup("True");
166 mfx->readonly = strdup("False");
167 mfx->update = strdup("False");
168 mfx->system = strdup("False");
169 mfx->installed_storage = strdup("installed_internal");
170 package = mfx->package;
173 void *__open_lib_handle(char *tag)
175 char *lib_path = NULL;
176 void *lib_handle = NULL;
178 lib_path = __get_parser_plugin(tag);
179 retvm_if(!lib_path, NULL, "lib_path get fail");
181 lib_handle = dlopen(lib_path, RTLD_LAZY);
182 retvm_if(lib_handle == NULL, NULL, "dlopen is failed lib_path[%s]", lib_path);
187 void __close_lib_handle(void *lib_handle)
192 static void __str_trim(char *input)
194 char *trim_str = input;
199 while (*input != 0) {
200 if (!isspace(*input)) {
213 uid_t uid = getuid();
222 static char * __get_tag_by_key(char *md_key)
226 if (md_key == NULL) {
227 _LOGD("md_key is NULL\n");
231 md_tag = strrchr(md_key, 47) + 1;
234 return strdup(md_tag);
237 static char *__get_metadata_parser_plugin(const char *type)
240 char buffer[1024] = { 0 };
241 char temp_path[1024] = { 0 };
245 _LOGE("invalid argument\n");
249 fp = fopen(PKG_PARSER_CONF_PATH, "r");
251 _LOGE("no matching metadata parser\n");
255 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
256 if (buffer[0] == '#')
261 if ((path = strstr(buffer, METADATA_PARSER_NAME)) != NULL) {
262 path = path + strlen(METADATA_PARSER_NAME);
267 memset(buffer, 0x00, 1024);
274 _LOGE("no matching [%s] [%s]\n", METADATA_PARSER_NAME, type);
278 snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
280 return strdup(temp_path);
283 static char *__get_category_parser_plugin(const char *type)
286 char buffer[1024] = { 0 };
287 char temp_path[1024] = { 0 };
291 _LOGE("invalid argument\n");
295 fp = fopen(PKG_PARSER_CONF_PATH, "r");
297 _LOGE("no matching metadata parser\n");
301 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
302 if (buffer[0] == '#')
307 if ((path = strstr(buffer, CATEGORY_PARSER_NAME)) != NULL) {
308 path = path + strlen(CATEGORY_PARSER_NAME);
313 memset(buffer, 0x00, 1024);
320 _LOGE("no matching [%s] [%s]\n", CATEGORY_PARSER_NAME, type);
324 snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
326 return strdup(temp_path);
329 static char *__get_parser_plugin(const char *type)
332 char buffer[1024] = { 0 };
333 char temp_path[1024] = { 0 };
337 _LOGE("invalid argument\n");
341 fp = fopen(PKG_PARSER_CONF_PATH, "r");
343 _LOGE("no matching backendlib\n");
347 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
348 if (buffer[0] == '#')
353 if ((path = strstr(buffer, PKG_PARSERLIB)) != NULL) {
354 path = path + strlen(PKG_PARSERLIB);
358 memset(buffer, 0x00, 1024);
365 _LOGE("no matching backendlib\n");
369 snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
371 return strdup(temp_path);
374 static int __ps_run_tag_parser(void *lib_handle, xmlDocPtr docPtr, const char *tag,
375 ACTION_TYPE action, const char *pkgid)
377 int (*plugin_install) (xmlDocPtr, const char *);
383 ac = "PKGMGR_PARSER_PLUGIN_INSTALL";
386 ac = "PKGMGR_PARSER_PLUGIN_UPGRADE";
388 case ACTION_UNINSTALL:
389 ac = "PKGMGR_PARSER_PLUGIN_UNINSTALL";
395 if ((plugin_install =
396 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
397 _LOGE("can not find symbol[%s] \n", ac);
401 ret = plugin_install(docPtr, pkgid);
402 _LOGD("tag parser[%s, %s] ACTION_TYPE[%d] result[%d]\n", pkgid, tag, action, ret);
408 static int __ps_run_metadata_parser(GList *md_list, const char *tag,
409 ACTION_TYPE action, const char *pkgid, const char *appid)
411 char *lib_path = NULL;
412 void *lib_handle = NULL;
413 int (*metadata_parser_plugin) (const char *, const char *, GList *);
419 ac = "PKGMGR_MDPARSER_PLUGIN_INSTALL";
422 ac = "PKGMGR_MDPARSER_PLUGIN_UPGRADE";
424 case ACTION_UNINSTALL:
425 ac = "PKGMGR_MDPARSER_PLUGIN_UNINSTALL";
431 lib_path = __get_metadata_parser_plugin(tag);
433 _LOGE("get %s parser fail\n", tag);
437 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
438 _LOGE("dlopen is failed lib_path[%s]\n", lib_path);
442 if ((metadata_parser_plugin =
443 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
444 _LOGE("can not find symbol[%s] \n", ac);
448 ret = metadata_parser_plugin(pkgid, appid, md_list);
450 _LOGD("[appid = %s, libpath = %s plugin fail\n", appid, lib_path);
452 _LOGD("[appid = %s, libpath = %s plugin success\n", appid, lib_path);
462 static int __ps_run_category_parser(GList *category_list, const char *tag,
463 ACTION_TYPE action, const char *pkgid, const char *appid)
465 char *lib_path = NULL;
466 void *lib_handle = NULL;
467 int (*category_parser_plugin) (const char *, const char *, GList *);
473 ac = "PKGMGR_CATEGORY_PARSER_PLUGIN_INSTALL";
476 ac = "PKGMGR_CATEGORY_PARSER_PLUGIN_UPGRADE";
478 case ACTION_UNINSTALL:
479 ac = "PKGMGR_CATEGORY_PARSER_PLUGIN_UNINSTALL";
485 lib_path = __get_category_parser_plugin(tag);
487 _LOGE("get %s parser fail\n", tag);
491 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
492 _LOGE("dlopen is failed lib_path[%s]\n", lib_path);
496 if ((category_parser_plugin =
497 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
498 _LOGE("can not find symbol[%s] \n", ac);
502 ret = category_parser_plugin(pkgid, appid, category_list);
504 _LOGD("[appid = %s, libpath = %s plugin fail\n", appid, lib_path);
506 _LOGD("[appid = %s, libpath = %s plugin success\n", appid, lib_path);
516 static void __metadata_parser_clear_dir_list(GList* dir_list)
519 __metadata_t* detail = NULL;
522 list = g_list_first(dir_list);
524 detail = (__metadata_t *)list->data;
527 free((void *)detail->key);
529 free((void *)detail->value);
532 list = g_list_next(list);
534 g_list_free(dir_list);
538 static void __category_parser_clear_dir_list(GList* dir_list)
541 __category_t* detail = NULL;
544 list = g_list_first(dir_list);
546 detail = (__category_t *)list->data;
549 free((void *)detail->name);
553 list = g_list_next(list);
555 g_list_free(dir_list);
559 static int __run_tag_parser_prestep(void *lib_handle, xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid)
564 if (xmlTextReaderDepth(reader) != 1) {
565 _LOGE("Node depth is not 1");
569 if (xmlTextReaderNodeType(reader) != 1) {
570 _LOGE("Node type is not 1");
574 const xmlChar *value;
575 name = xmlTextReaderConstName(reader);
577 _LOGE("TEST TEST TES\n");
578 name = BAD_CAST "--";
581 value = xmlTextReaderConstValue(reader);
583 if (xmlStrlen(value) > 40)
584 _LOGD(" %.40s...", value);
589 name = xmlTextReaderConstName(reader);
591 _LOGE("TEST TEST TES\n");
592 name = BAD_CAST "--";
595 xmlDocPtr docPtr = xmlTextReaderCurrentDoc(reader);
596 xmlDocPtr copyDocPtr = xmlCopyDoc(docPtr, 1);
597 if (copyDocPtr == NULL)
599 xmlNode *rootElement = xmlDocGetRootElement(copyDocPtr);
600 if (rootElement == NULL)
602 xmlNode *cur_node = xmlFirstElementChild(rootElement);
603 if (cur_node == NULL)
605 xmlNode *temp = xmlTextReaderExpand(reader);
608 xmlNode *next_node = NULL;
609 while (cur_node != NULL) {
610 if ((strcmp(ASCII(temp->name), ASCII(cur_node->name)) == 0) &&
611 (temp->line == cur_node->line)) {
614 next_node = xmlNextElementSibling(cur_node);
615 xmlUnlinkNode(cur_node);
616 xmlFreeNode(cur_node);
617 cur_node = next_node;
620 if (cur_node == NULL)
622 next_node = xmlNextElementSibling(cur_node);
624 cur_node->next = NULL;
625 next_node->prev = NULL;
626 xmlFreeNodeList(next_node);
627 xmlSetTreeDoc(cur_node, copyDocPtr);
629 xmlSetTreeDoc(cur_node, copyDocPtr);
632 ret = __ps_run_tag_parser(lib_handle, copyDocPtr, ASCII(name), action, pkgid);
638 static int __run_metadata_parser_prestep(manifest_x *mfx, char *md_key, ACTION_TYPE action)
642 char buffer[1024] = { 0, };
645 GList *md_tmp = NULL;
649 GList *md_list = NULL;
650 __metadata_t *md_detail = NULL;
652 md_tag = __get_tag_by_key(md_key);
653 if (md_tag == NULL) {
654 _LOGD("md_tag is NULL\n");
658 for (app_tmp = mfx->application; app_tmp; app_tmp = app_tmp->next) {
659 app = (application_x *)app_tmp->data;
662 for (md_tmp = app->metadata; md_tmp; md_tmp = md_tmp->next) {
663 md = (metadata_x *)md_tmp->data;
666 /* get glist of metadata key and value combination */
667 memset(buffer, 0x00, 1024);
668 snprintf(buffer, 1024, "%s/", md_key);
669 if ((md->key && md->value) && (strncmp(md->key, md_key, strlen(md_key)) == 0) && (strncmp(buffer, md->key, strlen(buffer)) == 0)) {
670 md_detail = (__metadata_t*) calloc(1, sizeof(__metadata_t));
671 if (md_detail == NULL) {
672 _LOGD("Memory allocation failed\n");
676 md_detail->key = strdup(md->key);
677 if (md_detail->key == NULL) {
678 _LOGD("Memory allocation failed\n");
683 md_detail->value = strdup(md->value);
684 if (md_detail->value == NULL) {
685 _LOGD("Memory allocation failed\n");
686 free((void *)md_detail->key);
691 md_list = g_list_append(md_list, (gpointer)md_detail);
696 /* send glist to parser when tags for metadata plugin parser exist. */
698 ret = __ps_run_metadata_parser(md_list, md_tag, action, mfx->package, app->appid);
700 _LOGD("metadata_parser failed[%d] for tag[%s]\n", ret, md_tag);
702 _LOGD("metadata_parser success for tag[%s]\n", md_tag);
704 __metadata_parser_clear_dir_list(md_list);
711 __metadata_parser_clear_dir_list(md_list);
719 static int __run_category_parser_prestep(manifest_x *mfx, char *category_key, ACTION_TYPE action)
723 char buffer[1024] = { 0, };
727 const char *category;
728 char *category_tag = NULL;
730 GList *category_list = NULL;
731 __category_t *category_detail = NULL;
733 category_tag = __get_tag_by_key(category_key);
734 if (category_tag == NULL) {
735 _LOGD("md_tag is NULL\n");
739 for (app_tmp = mfx->application; app_tmp; app_tmp = app_tmp->next) {
740 app = (application_x *)app_tmp->data;
743 for (category_tmp = app->category; category_tmp; category_tmp = category_tmp->next) {
744 category = (const char *)category_tmp->data;
745 /* get glist of category key and value combination */
746 memset(buffer, 0x00, 1024);
747 snprintf(buffer, 1024, "%s/", category_key);
748 if ((category) && (strncmp(category, category_key, strlen(category_key)) == 0)) {
749 category_detail = (__category_t*) calloc(1, sizeof(__category_t));
750 if (category_detail == NULL) {
751 _LOGD("Memory allocation failed\n");
755 category_detail->name = strdup(category);
756 if (category_detail->name == NULL) {
757 _LOGD("Memory allocation failed\n");
758 free(category_detail);
762 category_list = g_list_append(category_list, (gpointer)category_detail);
767 /* send glist to parser when tags for metadata plugin parser exist. */
769 ret = __ps_run_category_parser(category_list, category_tag, action, mfx->package, app->appid);
771 _LOGD("category_parser failed[%d] for tag[%s]\n", ret, category_tag);
773 _LOGD("category_parser success for tag[%s]\n", category_tag);
775 __category_parser_clear_dir_list(category_list);
776 category_list = NULL;
782 __category_parser_clear_dir_list(category_list);
790 static void __process_tag(void *lib_handle, xmlTextReaderPtr reader, ACTION_TYPE action, char *tag, const char *pkgid)
792 switch (xmlTextReaderNodeType(reader)) {
793 case XML_READER_TYPE_END_ELEMENT:
797 case XML_READER_TYPE_ELEMENT:
799 /* Elements without closing tag don't receive */
800 const xmlChar *elementName =
801 xmlTextReaderLocalName(reader);
802 if (elementName == NULL)
805 if (strcmp(tag, ASCII(elementName)) == 0) {
806 _LOGD("find : tag[%s] ACTION_TYPE[%d] pkg[%s]\n", tag, action, pkgid);
807 __run_tag_parser_prestep(lib_handle, reader, action, pkgid);
818 static int __parser_send_tag(void *lib_handle, ACTION_TYPE action, PLUGIN_PROCESS_TYPE process, const char *pkgid)
820 int (*plugin_install) (const char *);
824 if (process == PLUGIN_PRE_PROCESS) {
827 ac = "PKGMGR_PARSER_PLUGIN_PRE_INSTALL";
830 ac = "PKGMGR_PARSER_PLUGIN_PRE_UPGRADE";
832 case ACTION_UNINSTALL:
833 ac = "PKGMGR_PARSER_PLUGIN_PRE_UNINSTALL";
838 } else if (process == PLUGIN_POST_PROCESS) {
841 ac = "PKGMGR_PARSER_PLUGIN_POST_INSTALL";
844 ac = "PKGMGR_PARSER_PLUGIN_POST_UPGRADE";
846 case ACTION_UNINSTALL:
847 ac = "PKGMGR_PARSER_PLUGIN_POST_UNINSTALL";
855 if ((plugin_install =
856 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
860 ret = plugin_install(pkgid);
864 static int __next_child_element(xmlTextReaderPtr reader, int depth)
866 int ret = xmlTextReaderRead(reader);
867 int cur = xmlTextReaderDepth(reader);
870 switch (xmlTextReaderNodeType(reader)) {
871 case XML_READER_TYPE_ELEMENT:
872 if (cur == depth + 1)
875 case XML_READER_TYPE_TEXT:
876 /*text is handled by each function separately*/
877 if (cur == depth + 1)
880 case XML_READER_TYPE_END_ELEMENT:
889 ret = xmlTextReaderRead(reader);
890 cur = xmlTextReaderDepth(reader);
894 int __ps_process_tag_parser(manifest_x *mfx, const char *filename, ACTION_TYPE action)
896 xmlTextReaderPtr reader;
900 void *lib_handle = NULL;
901 char tag[PKG_STRING_LEN_MAX] = { 0 };
903 fp = fopen(TAG_PARSER_LIST, "r");
904 retvm_if(fp == NULL, PMINFO_R_ERROR, "no preload list");
906 while (fgets(tag, sizeof(tag), fp) != NULL) {
909 lib_handle = __open_lib_handle(tag);
910 if (lib_handle == NULL)
913 ret = __parser_send_tag(lib_handle, action, PLUGIN_PRE_PROCESS, mfx->package);
914 _LOGD("PLUGIN_PRE_PROCESS[%s, %s] ACTION_TYPE[%d] result[%d]\n", mfx->package, tag, action, ret);
916 docPtr = xmlReadFile(filename, NULL, 0);
917 reader = xmlReaderWalker(docPtr);
918 if (reader != NULL) {
919 ret = xmlTextReaderRead(reader);
921 __process_tag(lib_handle, reader, action, tag, mfx->package);
922 ret = xmlTextReaderRead(reader);
924 xmlFreeTextReader(reader);
927 _LOGD("%s : failed to parse", filename);
929 _LOGD("Unable to open %s", filename);
932 ret = __parser_send_tag(lib_handle, action, PLUGIN_POST_PROCESS, mfx->package);
933 _LOGD("PLUGIN_POST_PROCESS[%s, %s] ACTION_TYPE[%d] result[%d]\n", mfx->package, tag, action, ret);
935 __close_lib_handle(lib_handle);
937 memset(tag, 0x00, sizeof(tag));
946 int __ps_process_metadata_parser(manifest_x *mfx, ACTION_TYPE action)
948 fprintf(stdout, "__ps_process_metadata_parser\n");
951 char md_key[PKG_STRING_LEN_MAX] = { 0 };
953 fp = fopen(METADATA_PARSER_LIST, "r");
955 _LOGD("no preload list\n");
959 while (fgets(md_key, sizeof(md_key), fp) != NULL) {
961 ret = __run_metadata_parser_prestep(mfx, md_key, action);
972 int __ps_process_category_parser(manifest_x *mfx, ACTION_TYPE action)
976 char category_key[PKG_STRING_LEN_MAX] = { 0 };
978 fp = fopen(CATEGORY_PARSER_LIST, "r");
980 _LOGD("no category parser list\n");
984 while (fgets(category_key, sizeof(category_key), fp) != NULL) {
985 __str_trim(category_key);
986 ret = __run_category_parser_prestep(mfx, category_key, action);
997 static int __ps_process_allowed(xmlTextReaderPtr reader, char **allowed)
999 __save_xml_value(reader, allowed);
1003 static int __ps_process_condition(xmlTextReaderPtr reader, char **condition)
1005 __save_xml_attribute(reader, "name", condition, NULL);
1009 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notification)
1011 __save_xml_attribute(reader, "name", ¬ification->name, NULL);
1012 __save_xml_value(reader, ¬ification->text);
1016 static int __ps_process_category(xmlTextReaderPtr reader, char **category)
1018 __save_xml_attribute(reader, "name", category, NULL);
1022 static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege)
1024 __save_xml_attribute(reader, "type", &privilege->type, "tpk");
1025 __save_xml_value(reader, &privilege->value);
1029 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata)
1031 __save_xml_attribute(reader, "key", &metadata->key, NULL);
1032 __save_xml_attribute(reader, "value", &metadata->value, NULL);
1036 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission)
1038 __save_xml_attribute(reader, "type", &permission->type, NULL);
1039 __save_xml_value(reader, &permission->value);
1043 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility)
1045 __save_xml_attribute(reader, "name", &compatibility->name, NULL);
1046 __save_xml_value(reader, &compatibility->text);
1050 static int __ps_process_request(xmlTextReaderPtr reader, char **request)
1052 __save_xml_value(reader, request);
1056 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define)
1058 const xmlChar *node;
1063 __save_xml_attribute(reader, "path", &define->path, NULL);
1065 depth = xmlTextReaderDepth(reader);
1066 while ((ret = __next_child_element(reader, depth))) {
1067 node = xmlTextReaderConstName(reader);
1069 _LOGD("xmlTextReaderConstName value is NULL\n");
1073 if (!strcmp(ASCII(node), "allowed")) {
1075 ret = __ps_process_allowed(reader, &val);
1077 define->allowed = g_list_append(define->allowed, (gpointer)val);
1078 } else if (!strcmp(ASCII(node), "request")) {
1080 ret = __ps_process_request(reader, &val);
1082 define->request = g_list_append(define->request, (gpointer)val);
1087 _LOGD("Processing define failed\n");
1094 struct appcontrol_data {
1099 char operation[BUFSIZE];
1104 static void __ps_process_mime(gpointer data, gpointer user_data)
1106 char *mime = (char *)data;
1107 struct appcontrol_data *ad = (struct appcontrol_data *)user_data;
1108 appcontrol_x *appcontrol;
1110 snprintf(ad->mime, sizeof(ad->mime), "%s", mime);
1112 appcontrol = calloc(1, sizeof(appcontrol_x));
1113 if (strlen(ad->operation))
1114 appcontrol->operation = strdup(ad->operation);
1115 if (strlen(ad->uri))
1116 appcontrol->uri = strdup(ad->uri);
1117 appcontrol->mime = strdup(ad->mime);
1118 ad->appcontrols = g_list_append(ad->appcontrols, appcontrol);
1121 static void __ps_process_uri(gpointer data, gpointer user_data)
1123 char *uri = (char *)data;
1124 struct appcontrol_data *ad = (struct appcontrol_data *)user_data;
1125 appcontrol_x *appcontrol;
1127 snprintf(ad->uri, sizeof(ad->uri), "%s", uri);
1129 if (ad->mimes != NULL) {
1130 g_list_foreach(ad->mimes, __ps_process_mime, user_data);
1132 appcontrol = calloc(1, sizeof(appcontrol_x));
1133 if (strlen(ad->operation))
1134 appcontrol->operation = strdup(ad->operation);
1135 appcontrol->uri = strdup(ad->uri);
1136 ad->appcontrols = g_list_append(ad->appcontrols, appcontrol);
1140 static void __ps_process_operation(gpointer data, gpointer user_data)
1142 char *operation = (char *)data;
1143 struct appcontrol_data *ad = (struct appcontrol_data *)user_data;
1144 appcontrol_x *appcontrol;
1146 snprintf(ad->operation, sizeof(ad->operation), "%s", operation);
1148 if (ad->uris != NULL) {
1149 g_list_foreach(ad->uris, __ps_process_uri, user_data);
1150 } else if (ad->mimes != NULL) {
1151 g_list_foreach(ad->mimes, __ps_process_mime, user_data);
1153 appcontrol = calloc(1, sizeof(appcontrol_x));
1154 appcontrol->operation = strdup(ad->operation);
1155 ad->appcontrols = g_list_append(ad->appcontrols, appcontrol);
1159 static GList *__make_appcontrol_list(GList *operations, GList *uris, GList *mimes)
1161 struct appcontrol_data ad = {0, };
1163 ad.operations = operations;
1167 if (ad.operations == NULL)
1170 g_list_foreach(ad.operations, __ps_process_operation, (gpointer)&ad);
1172 return ad.appcontrols;
1175 static int __ps_process_appcontrol(xmlTextReaderPtr reader, GList **appcontrol)
1177 const xmlChar *node;
1181 GList *operations = NULL;
1183 GList *mimes = NULL;
1186 depth = xmlTextReaderDepth(reader);
1187 while ((ret = __next_child_element(reader, depth)) > 0) {
1188 node = xmlTextReaderConstName(reader);
1190 _LOGD("xmlTextReaderConstName value is NULL\n");
1195 if (!strcmp(ASCII(node), "operation")) {
1196 __save_xml_attribute(reader, "name", &val, NULL);
1198 operations = g_list_append(operations, (gpointer)val);
1199 _LOGD("operation processing\n");
1200 } else if (!strcmp(ASCII(node), "uri")) {
1201 __save_xml_attribute(reader, "name", &val, NULL);
1203 uris = g_list_append(uris, (gpointer)val);
1204 _LOGD("uri processing\n");
1205 } else if (!strcmp(ASCII(node), "mime")) {
1206 __save_xml_attribute(reader, "name", &val, NULL);
1208 mimes = g_list_append(mimes, (gpointer)val);
1209 _LOGD("mime processing\n");
1210 } else if (!strcmp(ASCII(node), "subapp")) {
1218 _LOGD("Processing appcontrol failed\n");
1219 g_list_free_full(operations, free);
1220 g_list_free_full(uris, free);
1221 g_list_free_full(mimes, free);
1225 result = __make_appcontrol_list(operations, uris, mimes);
1227 *appcontrol = g_list_concat(*appcontrol, result);
1231 g_list_free_full(operations, free);
1232 g_list_free_full(uris, free);
1233 g_list_free_full(mimes, free);
1238 static int __ps_process_privileges(xmlTextReaderPtr reader, GList **privileges)
1240 const xmlChar *node;
1244 depth = xmlTextReaderDepth(reader);
1245 while ((ret = __next_child_element(reader, depth))) {
1246 node = xmlTextReaderConstName(reader);
1248 _LOGD("xmlTextReaderConstName value is NULL\n");
1252 if (strcmp(ASCII(node), "privilege") == 0) {
1253 privilege_x *privilege = calloc(1, sizeof(privilege_x));
1254 if (privilege == NULL) {
1255 _LOGD("Malloc Failed\n");
1258 ret = __ps_process_privilege(reader, privilege);
1262 *privileges = g_list_append(*privileges, (gpointer)privilege);
1267 _LOGD("Processing privileges failed\n");
1274 static int __ps_process_launchconditions(xmlTextReaderPtr reader, GList **launchconditions)
1276 const xmlChar *node;
1281 depth = xmlTextReaderDepth(reader);
1282 while ((ret = __next_child_element(reader, depth))) {
1283 node = xmlTextReaderConstName(reader);
1285 _LOGD("xmlTextReaderConstName value is NULL\n");
1289 if (strcmp(ASCII(node), "condition") == 0) {
1291 ret = __ps_process_condition(reader, &val);
1293 *launchconditions = g_list_append(*launchconditions, (gpointer)val);
1297 _LOGD("Processing launchconditions failed\n");
1305 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare)
1307 const xmlChar *node;
1311 depth = xmlTextReaderDepth(reader);
1312 while ((ret = __next_child_element(reader, depth))) {
1313 node = xmlTextReaderConstName(reader);
1315 _LOGD("xmlTextReaderConstName value is NULL\n");
1319 if (!strcmp(ASCII(node), "define")) {
1320 define_x *define = calloc(1, sizeof(define_x));
1321 if (define == NULL) {
1322 _LOGD("Malloc Failed\n");
1325 datashare->define = g_list_append(datashare->define, define);
1326 ret = __ps_process_define(reader, define);
1327 } else if (!strcmp(ASCII(node), "request")) {
1329 ret = __ps_process_request(reader, &val);
1331 datashare->request = g_list_append(datashare->request, (gpointer)val);
1335 _LOGD("Processing data-share failed\n");
1342 static char *__get_icon_with_path(const char *icon, uid_t uid)
1344 char icon_with_path[BUFSIZE];
1345 const char *app_path;
1347 if (!icon || !package)
1350 /* just use absolute path */
1351 if (index(icon, '/'))
1352 return strdup(icon);
1355 if (uid == GLOBAL_USER || uid == OWNER_ROOT) {
1356 snprintf(icon_with_path, sizeof(icon_with_path),
1357 "%s%s", getIconPath(uid, true), icon);
1358 if (access(icon_with_path, F_OK) == 0)
1361 snprintf(icon_with_path, sizeof(icon_with_path),
1362 "%s%s", getIconPath(uid, false), icon);
1363 if (access(icon_with_path, F_OK) == 0)
1366 /* for backward compatibility (.../default/small/...)
1367 * this should be removed
1369 snprintf(icon_with_path, sizeof(icon_with_path),
1370 "%sdefault/small/%s",
1371 getIconPath(uid, true), icon);
1372 if (access(icon_with_path, F_OK) == 0)
1375 snprintf(icon_with_path, sizeof(icon_with_path),
1376 "%sdefault/small/%s",
1377 getIconPath(uid, false), icon);
1378 if (access(icon_with_path, F_OK) == 0)
1381 /* If doesn't exist in case of Global app,
1382 * try to get icon directly into app's directory
1384 app_path = tzplatform_getenv(TZ_SYS_RO_APP);
1386 snprintf(icon_with_path, sizeof(icon_with_path),
1387 "%s/%s/%s", app_path, package, icon);
1388 if (access(icon_with_path, F_OK) == 0)
1391 app_path = tzplatform_getenv(TZ_SYS_RW_APP);
1393 snprintf(icon_with_path, sizeof(icon_with_path),
1394 "%s/%s/%s", app_path, package, icon);
1395 if (access(icon_with_path, F_OK) == 0)
1398 tzplatform_set_user(uid);
1399 app_path = tzplatform_getenv(TZ_USER_APP);
1400 tzplatform_reset_user();
1402 snprintf(icon_with_path, sizeof(icon_with_path),
1403 "%s/%s/%s", app_path, package, icon);
1404 if (access(icon_with_path, F_OK) == 0)
1408 /* some preload package has icons at below path */
1409 snprintf(icon_with_path, sizeof(icon_with_path),
1410 "%s/%s/res/icons/%s", app_path, package, icon);
1411 if (access(icon_with_path, F_OK) == 0)
1414 /* since 2.3 tpk package */
1415 snprintf(icon_with_path, sizeof(icon_with_path),
1416 "%s/%s/shared/res/%s", app_path, package, icon);
1417 if (access(icon_with_path, F_OK) == 0)
1420 _LOGE("cannot find icon path for [%s]", icon);
1424 _LOGD("Icon path : %s ---> %s", icon, icon_with_path);
1426 return strdup(icon_with_path);
1429 static void __ps_process_tag(manifest_x * mfx, char *const tagv[])
1432 char delims[] = "=";
1433 char *ret_result = NULL;
1440 for (tag = strdup(tagv[0]); tag != NULL; ) {
1441 ret_result = strtok_r(tag, delims, &ptr);
1443 /*check tag : preload */
1444 if (strcmp(ret_result, "preload") == 0) {
1445 ret_result = strtok_r(NULL, delims, &ptr);
1446 if (strcmp(ret_result, "true") == 0) {
1447 free((void *)mfx->preload);
1448 mfx->preload = strdup("true");
1449 } else if (strcmp(ret_result, "false") == 0) {
1450 free((void *)mfx->preload);
1451 mfx->preload = strdup("false");
1453 /*check tag : removable*/
1454 } else if (strcmp(ret_result, "removable") == 0) {
1455 ret_result = strtok_r(NULL, delims, &ptr);
1456 if (strcmp(ret_result, "true") == 0) {
1457 free((void *)mfx->removable);
1458 mfx->removable = strdup("true");
1459 } else if (strcmp(ret_result, "false") == 0) {
1460 free((void *)mfx->removable);
1461 mfx->removable = strdup("false");
1463 /*check tag : not matched*/
1465 _LOGD("tag process [%s]is not defined\n", ret_result);
1469 /*check next value*/
1470 if (tagv[++i] != NULL)
1471 tag = strdup(tagv[i]);
1473 _LOGD("tag process success...\n");
1479 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon, uid_t uid)
1481 __save_xml_attribute(reader, "section", &icon->section, NULL);
1482 __save_xml_attribute(reader, "size", &icon->size, NULL);
1483 __save_xml_attribute(reader, "resolution", &icon->resolution, NULL);
1484 __save_xml_lang(reader, &icon->lang);
1486 xmlTextReaderRead(reader);
1487 char *text = ASCII(xmlTextReaderValue(reader));
1489 icon->text = __get_icon_with_path(text, uid);
1496 static int __ps_process_image(xmlTextReaderPtr reader, image_x *image)
1498 __save_xml_attribute(reader, "section", &image->section, NULL);
1499 __save_xml_lang(reader, &image->lang);
1500 __save_xml_value(reader, &image->text);
1504 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label)
1506 __save_xml_attribute(reader, "name", &label->name, NULL);
1507 __save_xml_lang(reader, &label->lang);
1508 __save_xml_value(reader, &label->text);
1513 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author)
1515 __save_xml_attribute(reader, "email", &author->email, NULL);
1516 __save_xml_attribute(reader, "href", &author->href, NULL);
1517 __save_xml_value(reader, &author->text);
1521 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description)
1523 __save_xml_lang(reader, &description->lang);
1524 __save_xml_value(reader, &description->text);
1528 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license)
1530 __save_xml_lang(reader, &license->lang);
1531 __save_xml_value(reader, &license->text);
1535 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol)
1537 __save_xml_attribute(reader, "providerid", &datacontrol->providerid, NULL);
1538 __save_xml_attribute(reader, "access", &datacontrol->access, NULL);
1539 __save_xml_attribute(reader, "type", &datacontrol->type, NULL);
1543 static int __ps_process_splashscreen(xmlTextReaderPtr reader, splashscreen_x *splashscreen)
1545 __save_xml_attribute(reader, "src", &splashscreen->src, NULL);
1546 __save_xml_attribute(reader, "type", &splashscreen->type, NULL);
1547 __save_xml_attribute(reader, "dpi", &splashscreen->dpi, NULL);
1548 __save_xml_attribute(reader, "orientation", &splashscreen->orientation, NULL);
1549 __save_xml_attribute(reader, "indicator-display", &splashscreen->indicatordisplay, NULL);
1550 __save_xml_attribute(reader, "app-control-operation", &splashscreen->operation, NULL);
1551 __save_xml_attribute(reader, "color-depth", &splashscreen->color_depth, NULL);
1555 static int __ps_process_splashscreens(xmlTextReaderPtr reader, GList **splashscreens)
1557 const xmlChar *node;
1560 splashscreen_x *splashscreen;
1562 depth = xmlTextReaderDepth(reader);
1563 while ((ret = __next_child_element(reader, depth))) {
1564 node = xmlTextReaderConstName(reader);
1566 _LOGD("xmlTextReaderConstName value is NULL\n");
1570 if (strcmp(ASCII(node), "splash-screen") == 0) {
1571 splashscreen = calloc(1, sizeof(splashscreen_x));
1572 if (splashscreen == NULL) {
1573 _LOGD("Malloc Failed\n");
1576 *splashscreens = g_list_append(*splashscreens, splashscreen);
1577 ret = __ps_process_splashscreen(reader, splashscreen);
1583 _LOGD("Processing splash-screen failed\n");
1590 static int __ps_process_application(xmlTextReaderPtr reader, application_x *application, int type, uid_t uid)
1592 const xmlChar *node;
1597 __save_xml_attribute(reader, "appid", &application->appid, NULL);
1598 retvm_if(application->appid == NULL, PM_PARSER_R_ERROR, "appid cant be NULL, appid field is mandatory\n");
1599 __save_xml_attribute(reader, "exec", &application->exec, NULL);
1600 __save_xml_attribute(reader, "nodisplay", &application->nodisplay, "false");
1601 __save_xml_attribute(reader, "multiple", &application->multiple, "false");
1602 __save_xml_attribute(reader, "type", &application->type, NULL);
1603 __save_xml_attribute(reader, "categories", &application->categories, NULL);
1604 __save_xml_attribute(reader, "extraid", &application->extraid, NULL);
1605 __save_xml_attribute(reader, "taskmanage", &application->taskmanage, "true");
1606 __save_xml_attribute(reader, "enabled", &application->enabled, "true");
1607 __save_xml_attribute(reader, "hw-acceleration", &application->hwacceleration, "default");
1608 __save_xml_attribute(reader, "screen-reader", &application->screenreader, "use-system-setting");
1609 __save_xml_attribute(reader, "mainapp", &application->mainapp, "false");
1610 __save_xml_attribute(reader, "recentimage", &application->recentimage, "false");
1611 __save_xml_attribute(reader, "launchcondition", &application->launchcondition, "false");
1612 __save_xml_attribute(reader, "indicatordisplay", &application->indicatordisplay, "true");
1613 __save_xml_attribute(reader, "portrait-effectimage", &application->portraitimg, NULL);
1614 __save_xml_attribute(reader, "landscape-effectimage", &application->landscapeimg, NULL);
1615 __save_xml_attribute(reader, "guestmode-visibility", &application->guestmode_visibility, "true");
1616 __save_xml_attribute(reader, "permission-type", &application->permission_type, "normal");
1617 __save_xml_attribute(reader, "component-type", &application->component_type, type == PMINFO_UI_APP ? "uiapp" : type == PMINFO_SVC_APP ? "svcapp" : "widgetapp");
1618 /*component_type has "svcapp" or "uiapp", if it is not, parsing manifest is fail*/
1619 retvm_if(((strcmp(application->component_type, "svcapp") != 0) && (strcmp(application->component_type, "uiapp") != 0) && (strcmp(application->component_type, "widgetapp") != 0)), PM_PARSER_R_ERROR, "invalid component_type[%s]", application->component_type);
1620 __save_xml_attribute(reader, "submode", &application->submode, "false");
1621 __save_xml_attribute(reader, "submode-mainid", &application->submode_mainid, NULL);
1622 __save_xml_attribute(reader, "process-pool", &application->process_pool, "false");
1623 __save_xml_attribute(reader, "launch_mode", &application->launch_mode, "caller");
1624 __save_xml_attribute(reader, "ui-gadget", &application->ui_gadget, "false");
1625 __save_xml_attribute(reader, "auto-restart", &application->autorestart, "false");
1626 __save_xml_attribute(reader, "on-boot", &application->onboot, "false");
1627 __save_xml_attribute(reader, "splash-screen-display", &application->splash_screen_display, "true");
1629 application->package = strdup(package);
1630 /* overwrite some attributes if the app is widgetapp */
1631 if (type == PMINFO_WIDGET_APP || type == PMINFO_WATCH_APP) {
1632 free((void *)application->nodisplay);
1633 application->nodisplay = strdup("true");
1634 free((void *)application->multiple);
1635 application->multiple = strdup("true");
1636 free((void *)application->type);
1637 application->type = strdup("capp");
1638 free((void *)application->taskmanage);
1639 application->taskmanage = strdup("false");
1640 free((void *)application->indicatordisplay);
1641 application->indicatordisplay = strdup("false");
1644 /* hw-acceleration values are changed from use-GL/not-use-GL/use-system-setting to on/off/default */
1645 if (strcmp(application->hwacceleration, "use-GL") == 0) {
1646 free((void *)application->hwacceleration);
1647 application->hwacceleration = strdup("on");
1648 } else if (strcmp(application->hwacceleration, "not-use-GL") == 0) {
1649 free((void *)application->hwacceleration);
1650 application->hwacceleration = strdup("off");
1651 } else if (strcmp(application->hwacceleration, "use-system-setting") == 0) {
1652 free((void *)application->hwacceleration);
1653 application->hwacceleration = strdup("default");
1656 depth = xmlTextReaderDepth(reader);
1657 while ((ret = __next_child_element(reader, depth))) {
1658 node = xmlTextReaderConstName(reader);
1660 _LOGD("xmlTextReaderConstName value is NULL\n");
1663 if (!strcmp(ASCII(node), "label")) {
1664 label_x *label = calloc(1, sizeof(label_x));
1665 if (label == NULL) {
1666 _LOGD("Malloc Failed\n");
1669 application->label = g_list_append(application->label, label);
1670 ret = __ps_process_label(reader, label);
1671 } else if (!strcmp(ASCII(node), "icon")) {
1672 icon_x *icon = calloc(1, sizeof(icon_x));
1674 _LOGD("Malloc Failed\n");
1677 application->icon = g_list_append(application->icon, icon);
1678 ret = __ps_process_icon(reader, icon, uid);
1679 } else if (!strcmp(ASCII(node), "image")) {
1680 image_x *image = calloc(1, sizeof(image_x));
1681 if (image == NULL) {
1682 _LOGD("Malloc Failed\n");
1685 application->image = g_list_append(application->image, image);
1686 ret = __ps_process_image(reader, image);
1687 } else if (!strcmp(ASCII(node), "category")) {
1689 ret = __ps_process_category(reader, &val);
1691 application->category = g_list_append(application->category, (gpointer)val);
1692 } else if (!strcmp(ASCII(node), "metadata")) {
1693 metadata_x *metadata = calloc(1, sizeof(metadata_x));
1694 if (metadata == NULL) {
1695 _LOGD("Malloc Failed\n");
1698 application->metadata = g_list_append(application->metadata, metadata);
1699 ret = __ps_process_metadata(reader, metadata);
1700 } else if (!strcmp(ASCII(node), "permission")) {
1701 permission_x *permission = calloc(1, sizeof(permission_x));
1702 if (permission == NULL) {
1703 _LOGD("Malloc Failed\n");
1706 application->permission = g_list_append(application->permission, permission);
1707 ret = __ps_process_permission(reader, permission);
1708 } else if (!strcmp(ASCII(node), "app-control")) {
1709 ret = __ps_process_appcontrol(reader, &application->appcontrol);
1710 } else if (!strcmp(ASCII(node), "application-service")) {
1711 ret = __ps_process_appcontrol(reader, &application->appcontrol);
1712 } else if (!strcmp(ASCII(node), "data-share")) {
1713 datashare_x *datashare = calloc(1, sizeof(datashare_x));
1714 if (datashare == NULL) {
1715 _LOGD("Malloc Failed\n");
1718 application->datashare = g_list_append(application->datashare, datashare);
1719 ret = __ps_process_datashare(reader, datashare);
1720 } else if (!strcmp(ASCII(node), "launch-conditions")) {
1721 ret = __ps_process_launchconditions(reader, &application->launchconditions);
1722 } else if (!strcmp(ASCII(node), "notification")) {
1723 notification_x *notification = calloc(1, sizeof(notification_x));
1724 if (notification == NULL) {
1725 _LOGD("Malloc Failed\n");
1728 application->notification = g_list_append(application->notification, notification);
1729 ret = __ps_process_notification(reader, notification);
1730 } else if (!strcmp(ASCII(node), "datacontrol")) {
1731 datacontrol_x *datacontrol = calloc(1, sizeof(datacontrol_x));
1732 if (datacontrol == NULL) {
1733 _LOGD("Malloc Failed\n");
1736 application->datacontrol = g_list_append(application->datacontrol, datacontrol);
1737 ret = __ps_process_datacontrol(reader, datacontrol);
1738 } else if (!strcmp(ASCII(node), "splash-screens") == 0) {
1739 ret = __ps_process_splashscreens(reader, &application->splashscreens);
1743 _LOGD("Processing application failed\n");
1751 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx, uid_t uid)
1753 _LOGD("__start_process\n");
1754 const xmlChar *node;
1758 depth = xmlTextReaderDepth(reader);
1759 while ((ret = __next_child_element(reader, depth))) {
1760 node = xmlTextReaderConstName(reader);
1762 _LOGD("xmlTextReaderConstName value is NULL\n");
1766 if (!strcmp(ASCII(node), "label")) {
1767 label_x *label = calloc(1, sizeof(label_x));
1768 if (label == NULL) {
1769 _LOGD("Malloc Failed\n");
1772 mfx->label = g_list_append(mfx->label, label);
1773 ret = __ps_process_label(reader, label);
1774 } else if (!strcmp(ASCII(node), "author")) {
1775 author_x *author = calloc(1, sizeof(author_x));
1776 if (author == NULL) {
1777 _LOGD("Malloc Failed\n");
1780 mfx->author = g_list_append(mfx->author, author);
1781 ret = __ps_process_author(reader, author);
1782 } else if (!strcmp(ASCII(node), "description")) {
1783 description_x *description = calloc(1, sizeof(description_x));
1784 if (description == NULL) {
1785 _LOGD("Malloc Failed\n");
1788 mfx->description = g_list_append(mfx->description, description);
1789 ret = __ps_process_description(reader, description);
1790 } else if (!strcmp(ASCII(node), "license")) {
1791 license_x *license = calloc(1, sizeof(license_x));
1792 if (license == NULL) {
1793 _LOGD("Malloc Failed\n");
1796 mfx->license = g_list_append(mfx->license, license);
1797 ret = __ps_process_license(reader, license);
1798 } else if (!strcmp(ASCII(node), "privileges")) {
1799 ret = __ps_process_privileges(reader, &mfx->privileges);
1800 } else if (!strcmp(ASCII(node), "ui-application")) {
1801 application_x *application = calloc(1, sizeof(application_x));
1802 if (application == NULL) {
1803 _LOGD("Malloc Failed\n");
1806 mfx->application = g_list_append(mfx->application, application);
1807 ret = __ps_process_application(reader, application, PMINFO_UI_APP, uid);
1808 } else if (!strcmp(ASCII(node), "service-application")) {
1809 application_x *application = calloc(1, sizeof(application_x));
1810 if (application == NULL) {
1811 _LOGD("Malloc Failed\n");
1814 mfx->application = g_list_append(mfx->application, application);
1815 ret = __ps_process_application(reader, application, PMINFO_SVC_APP, uid);
1816 } else if (!strcmp(ASCII(node), "widget-application")) {
1817 application_x *application = calloc(1, sizeof(application_x));
1818 if (application == NULL) {
1819 _LOGD("Malloc Failed\n");
1822 mfx->application = g_list_append(mfx->application, application);
1823 ret = __ps_process_application(reader, application, PMINFO_WIDGET_APP, uid);
1824 } else if (!strcmp(ASCII(node), "watch-application")) {
1825 application_x *application = calloc(1, sizeof(application_x));
1826 if (application == NULL) {
1827 _LOGD("Malloc Failed\n");
1830 mfx->application = g_list_append(mfx->application, application);
1831 ret = __ps_process_application(reader, application, PMINFO_WATCH_APP, uid);
1832 } else if (!strcmp(ASCII(node), "icon")) {
1833 icon_x *icon = calloc(1, sizeof(icon_x));
1835 _LOGD("Malloc Failed\n");
1838 mfx->icon = g_list_append(mfx->icon, icon);
1839 ret = __ps_process_icon(reader, icon, uid);
1840 } else if (!strcmp(ASCII(node), "compatibility")) {
1841 compatibility_x *compatibility = calloc(1, sizeof(compatibility_x));
1842 if (compatibility == NULL) {
1843 _LOGD("Malloc Failed\n");
1846 mfx->compatibility = g_list_append(mfx->compatibility, compatibility);
1847 ret = __ps_process_compatibility(reader, compatibility);
1848 } else if (!strcmp(ASCII(node), "shortcut-list")) {
1850 } else if (!strcmp(ASCII(node), "livebox")) {
1852 } else if (!strcmp(ASCII(node), "account")) {
1854 } else if (!strcmp(ASCII(node), "notifications")) {
1856 } else if (!strcmp(ASCII(node), "ime")) {
1858 } else if (!strcmp(ASCII(node), "feature")) {
1861 _LOGI("Unknown element: %s", ASCII(node));
1866 _LOGD("Processing manifest failed\n");
1873 static int __process_manifest(xmlTextReaderPtr reader, manifest_x *mfx, uid_t uid)
1875 const xmlChar *node;
1878 if ((ret = __next_child_element(reader, -1))) {
1879 node = xmlTextReaderConstName(reader);
1881 _LOGD("xmlTextReaderConstName value is NULL\n");
1885 if (!strcmp(ASCII(node), "manifest")) {
1886 __save_xml_attribute(reader, "xmlns", &mfx->ns, NULL);
1887 __save_xml_attribute(reader, "package", &mfx->package, NULL);
1888 retvm_if(mfx->package == NULL, PM_PARSER_R_ERROR, "package cant be NULL, package field is mandatory\n");
1889 __save_xml_attribute(reader, "version", &mfx->version, NULL);
1890 __save_xml_attribute(reader, "size", &mfx->package_size, NULL);
1891 __save_xml_attribute(reader, "install-location", &mfx->installlocation, "internal-only");
1892 __save_xml_attribute(reader, "type", &mfx->type, "tpk");
1893 __save_xml_attribute(reader, "root_path", &mfx->root_path, NULL);
1894 __save_xml_attribute(reader, "csc_path", &mfx->csc_path, NULL);
1895 __save_xml_attribute(reader, "appsetting", &mfx->appsetting, "false");
1896 __save_xml_attribute(reader, "storeclient-id", &mfx->storeclient_id, NULL);
1897 __save_xml_attribute(reader, "nodisplay-setting", &mfx->nodisplay_setting, "false");
1898 __save_xml_attribute(reader, "url", &mfx->package_url, NULL);
1899 __save_xml_attribute(reader, "api-version", &mfx->api_version, NULL);
1900 __save_xml_attribute(reader, "support-disable", &mfx->support_disable, "false");
1902 __save_xml_installed_time(mfx);
1903 __save_xml_root_path(mfx, uid);
1904 /*Assign default values. If required it will be overwritten in __add_preload_info()*/
1905 __save_xml_default_value(mfx);
1907 ret = __start_process(reader, mfx, uid);
1909 _LOGD("No Manifest element found\n");
1916 #define LIBAPPSVC_PATH LIB_PATH "/libappsvc.so.0"
1918 static int __ps_remove_appsvc_db(manifest_x *mfx, uid_t uid)
1920 void *lib_handle = NULL;
1921 int (*appsvc_operation) (const char *, uid_t);
1924 application_x *application;
1926 if ((lib_handle = dlopen(LIBAPPSVC_PATH, RTLD_LAZY)) == NULL) {
1927 _LOGE("dlopen is failed LIBAPPSVC_PATH[%s]\n", LIBAPPSVC_PATH);
1931 if ((appsvc_operation =
1932 dlsym(lib_handle, "appsvc_unset_defapp")) == NULL || dlerror() != NULL) {
1933 _LOGE("can not find symbol \n");
1937 for (tmp = mfx->application; tmp; tmp = tmp->next) {
1938 application = (application_x *)tmp->data;
1939 if (application == NULL)
1941 ret = appsvc_operation(application->appid, uid);
1943 _LOGE("can not operation symbol \n");
1948 dlclose(lib_handle);
1953 static int __check_preload_updated(manifest_x * mfx, const char *manifest, uid_t uid)
1955 if (!strstr(manifest, getUserManifestPath(uid,
1956 strcmp(mfx->preload, "true") == 0))) {
1957 /* if downloaded app is updated, then update tag set true*/
1959 free((void *)mfx->update);
1960 mfx->update = strdup("true");
1966 API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
1968 pkgmgrinfo_basic_free_package((package_x *)mfx);
1971 DEPRECATED API manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest)
1973 _LOGD("parsing start pkgmgr_parser_process_manifest_xml\n");
1974 xmlTextReaderPtr reader;
1975 manifest_x *mfx = NULL;
1977 reader = xmlReaderForFile(manifest, NULL, 0);
1979 mfx = malloc(sizeof(manifest_x));
1981 memset(mfx, '\0', sizeof(manifest_x));
1982 if (__process_manifest(reader, mfx, GLOBAL_USER) < 0) {
1983 _LOGD("Parsing Failed\n");
1984 pkgmgr_parser_free_manifest_xml(mfx);
1987 _LOGD("Parsing Success\n");
1989 _LOGD("Memory allocation error\n");
1991 xmlFreeTextReader(reader);
1993 _LOGD("Unable to create xml reader\n");
1999 DEPRECATED API manifest_x *pkgmgr_parser_usr_process_manifest_xml(const char *manifest, uid_t uid)
2001 _LOGD("parsing start pkgmgr_parser_usr_process_manifest_xml\n");
2002 xmlTextReaderPtr reader;
2003 manifest_x *mfx = NULL;
2005 reader = xmlReaderForFile(manifest, NULL, 0);
2007 mfx = malloc(sizeof(manifest_x));
2009 memset(mfx, '\0', sizeof(manifest_x));
2010 if (__process_manifest(reader, mfx, uid) < 0) {
2011 _LOGD("Parsing Failed\n");
2012 pkgmgr_parser_free_manifest_xml(mfx);
2015 _LOGD("Parsing Success\n");
2017 _LOGD("Memory allocation error\n");
2019 xmlFreeTextReader(reader);
2021 _LOGD("Unable to create xml reader\n");
2026 API int pkgmgr_parser_usr_update_tep(const char *pkgid, const char *tep_path, uid_t uid)
2028 return pkgmgr_parser_update_tep_info_in_usr_db(pkgid, tep_path, uid);
2031 API int pkgmgr_parser_update_tep(const char *pkgid, const char *tep_path)
2033 return pkgmgr_parser_update_tep_info_in_db(pkgid, tep_path);
2036 DEPRECATED API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
2038 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2039 _LOGD("parsing manifest for installation: %s\n", manifest);
2041 manifest_x *mfx = NULL;
2045 mfx = pkgmgr_parser_process_manifest_xml(manifest);
2046 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2048 _LOGD("Parsing Finished\n");
2050 __ps_process_tag(mfx, tagv);
2052 ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
2053 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
2055 _LOGD("DB Insert Success\n");
2057 __ps_process_tag_parser(mfx, manifest, ACTION_INSTALL);
2058 ret = __ps_process_metadata_parser(mfx, ACTION_INSTALL);
2060 _LOGD("Creating metadata parser failed\n");
2062 ret = __ps_process_category_parser(mfx, ACTION_INSTALL);
2064 _LOGD("Creating category parser failed\n");
2066 pkgmgr_parser_free_manifest_xml(mfx);
2067 _LOGD("Free Done\n");
2073 DEPRECATED API int pkgmgr_parser_parse_usr_manifest_for_installation(const char *manifest, uid_t uid, char *const tagv[])
2075 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2076 _LOGD("parsing manifest for installation: %s\n", manifest);
2077 manifest_x *mfx = NULL;
2081 mfx = pkgmgr_parser_usr_process_manifest_xml(manifest, uid);
2082 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2084 _LOGD("Parsing Finished\n");
2086 __ps_process_tag(mfx, tagv);
2088 ret = pkgmgr_parser_insert_manifest_info_in_usr_db(mfx, uid);
2089 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
2091 _LOGD("DB Insert Success\n");
2093 __ps_process_tag_parser(mfx, manifest, ACTION_INSTALL);
2094 ret = __ps_process_metadata_parser(mfx, ACTION_INSTALL);
2096 _LOGD("Creating metadata parser failed\n");
2097 ret = __ps_process_category_parser(mfx, ACTION_INSTALL);
2099 _LOGD("Creating category parser failed\n");
2101 pkgmgr_parser_free_manifest_xml(mfx);
2102 _LOGD("Free Done\n");
2108 API int pkgmgr_parser_process_manifest_x_for_installation(manifest_x* mfx)
2110 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2113 ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
2114 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
2115 _LOGD("DB Insert Success\n");
2120 API int pkgmgr_parser_process_usr_manifest_x_for_installation(manifest_x* mfx, uid_t uid)
2122 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2125 ret = pkgmgr_parser_insert_manifest_info_in_usr_db(mfx, uid);
2126 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
2127 _LOGD("DB Insert Success\n");
2132 DEPRECATED API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
2134 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2135 _LOGD("pkgmgr_parser_parse_manifest_for_upgrade parsing manifest for upgradation: %s\n", manifest);
2136 manifest_x *mfx = NULL;
2138 bool preload = false;
2139 bool system = false;
2140 char *csc_path = NULL;
2141 pkgmgrinfo_pkginfo_h handle = NULL;
2144 mfx = pkgmgr_parser_process_manifest_xml(manifest);
2145 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2147 _LOGD("Parsing Finished\n");
2148 __check_preload_updated(mfx, manifest, GLOBAL_USER);
2150 ret = pkgmgrinfo_pkginfo_get_pkginfo(mfx->package, &handle);
2151 if (ret != PMINFO_R_OK)
2152 _LOGD("pkgmgrinfo_pkginfo_get_pkginfo failed\n");
2153 ret = pkgmgrinfo_pkginfo_is_preload(handle, &preload);
2154 if (ret != PMINFO_R_OK)
2155 _LOGD("pkgmgrinfo_pkginfo_is_preload failed\n");
2158 free((void *)mfx->preload);
2159 mfx->preload = strdup("true");
2162 ret = pkgmgrinfo_pkginfo_is_system(handle, &system);
2163 if (ret != PMINFO_R_OK)
2164 _LOGD("pkgmgrinfo_pkginfo_is_system failed\n");
2166 free((void *)mfx->system);
2167 mfx->system = strdup("true");
2170 ret = pkgmgrinfo_pkginfo_get_csc_path(handle, &csc_path);
2171 if (ret != PMINFO_R_OK)
2172 _LOGD("pkgmgrinfo_pkginfo_get_csc_path failed\n");
2174 if (csc_path != NULL) {
2176 free((void *)mfx->csc_path);
2177 mfx->csc_path = strdup(csc_path);
2180 /*Delete from cert table*/
2181 ret = pkgmgrinfo_delete_certinfo(mfx->package);
2183 _LOGD("Cert Info DB Delete Failed\n");
2187 ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
2188 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
2190 _LOGD("DB Update Success\n");
2192 __ps_process_tag_parser(mfx, manifest, ACTION_UPGRADE);
2193 ret = __ps_process_metadata_parser(mfx, ACTION_UPGRADE);
2195 _LOGD("Upgrade metadata parser failed\n");
2196 ret = __ps_process_category_parser(mfx, ACTION_UPGRADE);
2198 _LOGD("Creating category parser failed\n");
2199 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
2200 pkgmgr_parser_free_manifest_xml(mfx);
2201 _LOGD("Free Done\n");
2207 DEPRECATED API int pkgmgr_parser_parse_usr_manifest_for_upgrade(const char *manifest, uid_t uid, char *const tagv[])
2209 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2210 _LOGD(" pkgmgr_parser_parse_usr_manifest_for_upgrade parsing manifest for upgradation: %s\n", manifest);
2211 manifest_x *mfx = NULL;
2213 bool preload = false;
2214 bool system = false;
2215 char *csc_path = NULL;
2216 pkgmgrinfo_pkginfo_h handle = NULL;
2219 mfx = pkgmgr_parser_usr_process_manifest_xml(manifest, uid);
2220 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2222 _LOGD("Parsing Finished\n");
2223 __check_preload_updated(mfx, manifest, uid);
2225 ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(mfx->package, uid, &handle);
2226 if (ret != PMINFO_R_OK)
2227 _LOGD("pkgmgrinfo_pkginfo_get_pkginfo failed\n");
2228 ret = pkgmgrinfo_pkginfo_is_preload(handle, &preload);
2229 if (ret != PMINFO_R_OK)
2230 _LOGD("pkgmgrinfo_pkginfo_is_preload failed\n");
2233 free((void *)mfx->preload);
2234 mfx->preload = strdup("true");
2237 ret = pkgmgrinfo_pkginfo_is_system(handle, &system);
2238 if (ret != PMINFO_R_OK)
2239 _LOGD("pkgmgrinfo_pkginfo_is_system failed\n");
2242 free((void *)mfx->system);
2243 mfx->system = strdup("true");
2246 ret = pkgmgrinfo_pkginfo_get_csc_path(handle, &csc_path);
2247 if (ret != PMINFO_R_OK)
2248 _LOGD("pkgmgrinfo_pkginfo_get_csc_path failed\n");
2249 if (csc_path != NULL) {
2251 free((void *)mfx->csc_path);
2252 mfx->csc_path = strdup(csc_path);
2255 /*Delete from cert table*/
2256 ret = pkgmgrinfo_delete_certinfo(mfx->package);
2258 _LOGD("Cert Info DB Delete Failed\n");
2262 ret = pkgmgr_parser_update_manifest_info_in_usr_db(mfx, uid);
2263 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
2264 _LOGD("DB Update Success\n");
2266 __ps_process_tag_parser(mfx, manifest, ACTION_UPGRADE);
2267 ret = __ps_process_metadata_parser(mfx, ACTION_UPGRADE);
2269 _LOGD("Upgrade metadata parser failed\n");
2270 ret = __ps_process_category_parser(mfx, ACTION_UPGRADE);
2272 _LOGD("Creating category parser failed\n");
2273 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
2274 pkgmgr_parser_free_manifest_xml(mfx);
2275 _LOGD("Free Done\n");
2281 API int pkgmgr_parser_process_manifest_x_for_upgrade(manifest_x* mfx)
2283 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2286 ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
2287 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
2288 _LOGD("DB Update Success\n");
2293 API int pkgmgr_parser_process_usr_manifest_x_for_upgrade(manifest_x* mfx, uid_t uid)
2295 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2298 ret = pkgmgr_parser_update_manifest_info_in_usr_db(mfx, uid);
2299 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
2300 _LOGD("DB Update Success\n");
2305 API int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[])
2307 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2308 _LOGD("parsing manifest for uninstallation: %s\n", manifest);
2310 manifest_x *mfx = NULL;
2313 mfx = pkgmgr_parser_process_manifest_xml(manifest);
2314 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2316 _LOGD("Parsing Finished\n");
2318 __ps_process_tag_parser(mfx, manifest, ACTION_UNINSTALL);
2320 ret = __ps_process_metadata_parser(mfx, ACTION_UNINSTALL);
2322 _LOGD("Removing metadata parser failed\n");
2324 ret = __ps_process_category_parser(mfx, ACTION_UNINSTALL);
2326 _LOGD("Creating category parser failed\n");
2328 /*Delete from cert table*/
2329 ret = pkgmgrinfo_delete_certinfo(mfx->package);
2331 _LOGD("Cert Info DB Delete Failed\n");
2335 ret = pkgmgr_parser_delete_manifest_info_from_db(mfx);
2337 _LOGD("DB Delete failed\n");
2339 _LOGD("DB Delete Success\n");
2341 pkgmgr_parser_free_manifest_xml(mfx);
2342 _LOGD("Free Done\n");
2349 API int pkgmgr_parser_parse_usr_manifest_for_uninstallation(const char *manifest, uid_t uid, char *const tagv[])
2351 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2352 _LOGD("parsing manifest for uninstallation: %s\n", manifest);
2354 manifest_x *mfx = NULL;
2357 mfx = pkgmgr_parser_usr_process_manifest_xml(manifest, uid);
2358 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2360 _LOGD("Parsing Finished\n");
2362 __ps_process_tag_parser(mfx, manifest, ACTION_UNINSTALL);
2364 ret = __ps_process_metadata_parser(mfx, ACTION_UNINSTALL);
2366 _LOGD("Removing metadata parser failed\n");
2368 ret = __ps_process_category_parser(mfx, ACTION_UNINSTALL);
2370 _LOGD("Creating category parser failed\n");
2372 /*Delete from cert table*/
2373 ret = pkgmgrinfo_delete_certinfo(mfx->package);
2375 _LOGD("Cert Info DB Delete Failed\n");
2379 ret = pkgmgr_parser_delete_manifest_info_from_usr_db(mfx, uid);
2381 _LOGD("DB Delete failed\n");
2383 _LOGD("DB Delete Success\n");
2385 ret = __ps_remove_appsvc_db(mfx, uid);
2387 _LOGD("Removing appsvc_db failed\n");
2389 _LOGD("Removing appsvc_db Success\n");
2391 pkgmgr_parser_free_manifest_xml(mfx);
2392 _LOGD("Free Done\n");
2398 API int pkgmgr_parser_process_manifest_x_for_uninstallation(manifest_x* mfx)
2400 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2403 ret = pkgmgr_parser_delete_manifest_info_from_db(mfx);
2405 _LOGD("DB Delete failed\n");
2407 _LOGD("DB Delete Success\n");
2412 API int pkgmgr_parser_process_usr_manifest_x_for_uninstallation(manifest_x* mfx, uid_t uid)
2414 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2417 ret = pkgmgr_parser_delete_manifest_info_from_usr_db(mfx, uid);
2419 _LOGD("DB Delete failed\n");
2421 _LOGD("DB Delete Success\n");
2423 ret = __ps_remove_appsvc_db(mfx, uid);
2425 _LOGD("Removing appsvc_db failed\n");
2427 _LOGD("Removing appsvc_db Success\n");
2432 #define SCHEMA_FILE SYSCONFDIR "/package-manager/preload/manifest.xsd"
2433 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
2435 if (manifest == NULL) {
2436 _LOGE("manifest file is NULL\n");
2437 return PMINFO_R_EINVAL;
2440 xmlSchemaParserCtxtPtr ctx;
2441 xmlSchemaValidCtxtPtr vctx;
2442 xmlSchemaPtr xschema;
2443 ctx = xmlSchemaNewParserCtxt(SCHEMA_FILE);
2445 _LOGE("xmlSchemaNewParserCtxt() Failed\n");
2446 return PMINFO_R_ERROR;
2448 xschema = xmlSchemaParse(ctx);
2449 if (xschema == NULL) {
2450 _LOGE("xmlSchemaParse() Failed\n");
2451 return PMINFO_R_ERROR;
2453 vctx = xmlSchemaNewValidCtxt(xschema);
2455 _LOGE("xmlSchemaNewValidCtxt() Failed\n");
2456 return PMINFO_R_ERROR;
2458 xmlSchemaSetValidErrors(vctx, (xmlSchemaValidityErrorFunc) fprintf, (xmlSchemaValidityWarningFunc) fprintf, stderr);
2459 ret = xmlSchemaValidateFile(vctx, manifest, 0);
2461 _LOGE("xmlSchemaValidateFile() failed\n");
2462 return PMINFO_R_ERROR;
2463 } else if (ret == 0) {
2464 _LOGD("Manifest is Valid\n");
2467 _LOGE("Manifest Validation Failed with error code %d\n", ret);
2468 return PMINFO_R_ERROR;