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, char **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, char **privilege)
1024 __save_xml_value(reader, privilege);
1028 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata)
1030 __save_xml_attribute(reader, "key", &metadata->key, NULL);
1031 __save_xml_attribute(reader, "value", &metadata->value, NULL);
1035 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission)
1037 __save_xml_attribute(reader, "type", &permission->type, NULL);
1038 __save_xml_value(reader, &permission->value);
1042 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility)
1044 __save_xml_attribute(reader, "name", &compatibility->name, NULL);
1045 __save_xml_value(reader, &compatibility->text);
1049 static int __ps_process_request(xmlTextReaderPtr reader, char **request)
1051 __save_xml_value(reader, request);
1055 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define)
1057 const xmlChar *node;
1062 __save_xml_attribute(reader, "path", &define->path, NULL);
1064 depth = xmlTextReaderDepth(reader);
1065 while ((ret = __next_child_element(reader, depth))) {
1066 node = xmlTextReaderConstName(reader);
1068 _LOGD("xmlTextReaderConstName value is NULL\n");
1072 if (!strcmp(ASCII(node), "allowed")) {
1074 ret = __ps_process_allowed(reader, &val);
1076 define->allowed = g_list_append(define->allowed, (gpointer)val);
1077 } else if (!strcmp(ASCII(node), "request")) {
1079 ret = __ps_process_request(reader, &val);
1081 define->request = g_list_append(define->request, (gpointer)val);
1086 _LOGD("Processing define failed\n");
1093 struct appcontrol_data {
1098 char operation[BUFSIZE];
1103 static void __ps_process_mime(gpointer data, gpointer user_data)
1105 char *mime = (char *)data;
1106 struct appcontrol_data *ad = (struct appcontrol_data *)user_data;
1107 appcontrol_x *appcontrol;
1109 snprintf(ad->mime, sizeof(ad->mime), "%s", mime);
1111 appcontrol = calloc(1, sizeof(appcontrol_x));
1112 if (strlen(ad->operation))
1113 appcontrol->operation = strdup(ad->operation);
1114 if (strlen(ad->uri))
1115 appcontrol->uri = strdup(ad->uri);
1116 appcontrol->mime = strdup(ad->mime);
1117 ad->appcontrols = g_list_append(ad->appcontrols, appcontrol);
1120 static void __ps_process_uri(gpointer data, gpointer user_data)
1122 char *uri = (char *)data;
1123 struct appcontrol_data *ad = (struct appcontrol_data *)user_data;
1124 appcontrol_x *appcontrol;
1126 snprintf(ad->uri, sizeof(ad->uri), "%s", uri);
1128 if (ad->mimes != NULL) {
1129 g_list_foreach(ad->mimes, __ps_process_mime, user_data);
1131 appcontrol = calloc(1, sizeof(appcontrol_x));
1132 if (strlen(ad->operation))
1133 appcontrol->operation = strdup(ad->operation);
1134 appcontrol->uri = strdup(ad->uri);
1135 ad->appcontrols = g_list_append(ad->appcontrols, appcontrol);
1139 static void __ps_process_operation(gpointer data, gpointer user_data)
1141 char *operation = (char *)data;
1142 struct appcontrol_data *ad = (struct appcontrol_data *)user_data;
1143 appcontrol_x *appcontrol;
1145 snprintf(ad->operation, sizeof(ad->operation), "%s", operation);
1147 if (ad->uris != NULL) {
1148 g_list_foreach(ad->uris, __ps_process_uri, user_data);
1149 } else if (ad->mimes != NULL) {
1150 g_list_foreach(ad->mimes, __ps_process_mime, user_data);
1152 appcontrol = calloc(1, sizeof(appcontrol_x));
1153 appcontrol->operation = strdup(ad->operation);
1154 ad->appcontrols = g_list_append(ad->appcontrols, appcontrol);
1158 static GList *__make_appcontrol_list(GList *operations, GList *uris, GList *mimes)
1160 struct appcontrol_data ad = {0, };
1162 ad.operations = operations;
1166 if (ad.operations == NULL)
1169 g_list_foreach(ad.operations, __ps_process_operation, (gpointer)&ad);
1171 return ad.appcontrols;
1174 static int __ps_process_appcontrol(xmlTextReaderPtr reader, GList **appcontrol)
1176 const xmlChar *node;
1180 GList *operations = NULL;
1182 GList *mimes = NULL;
1185 depth = xmlTextReaderDepth(reader);
1186 while ((ret = __next_child_element(reader, depth)) > 0) {
1187 node = xmlTextReaderConstName(reader);
1189 _LOGD("xmlTextReaderConstName value is NULL\n");
1194 if (!strcmp(ASCII(node), "operation")) {
1195 __save_xml_attribute(reader, "name", &val, NULL);
1197 operations = g_list_append(operations, (gpointer)val);
1198 _LOGD("operation processing\n");
1199 } else if (!strcmp(ASCII(node), "uri")) {
1200 __save_xml_attribute(reader, "name", &val, NULL);
1202 uris = g_list_append(uris, (gpointer)val);
1203 _LOGD("uri processing\n");
1204 } else if (!strcmp(ASCII(node), "mime")) {
1205 __save_xml_attribute(reader, "name", &val, NULL);
1207 mimes = g_list_append(mimes, (gpointer)val);
1208 _LOGD("mime processing\n");
1209 } else if (!strcmp(ASCII(node), "subapp")) {
1217 _LOGD("Processing appcontrol failed\n");
1218 g_list_free_full(operations, free);
1219 g_list_free_full(uris, free);
1220 g_list_free_full(mimes, free);
1224 result = __make_appcontrol_list(operations, uris, mimes);
1226 *appcontrol = g_list_concat(*appcontrol, result);
1230 g_list_free_full(operations, free);
1231 g_list_free_full(uris, free);
1232 g_list_free_full(mimes, free);
1237 static int __ps_process_privileges(xmlTextReaderPtr reader, GList **privileges)
1239 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) {
1254 ret = __ps_process_privilege(reader, &val);
1256 *privileges = g_list_append(*privileges, (gpointer)val);
1260 _LOGD("Processing privileges failed\n");
1267 static int __ps_process_launchconditions(xmlTextReaderPtr reader, GList **launchconditions)
1269 const xmlChar *node;
1274 depth = xmlTextReaderDepth(reader);
1275 while ((ret = __next_child_element(reader, depth))) {
1276 node = xmlTextReaderConstName(reader);
1278 _LOGD("xmlTextReaderConstName value is NULL\n");
1282 if (strcmp(ASCII(node), "condition") == 0) {
1284 ret = __ps_process_condition(reader, &val);
1286 *launchconditions = g_list_append(*launchconditions, (gpointer)val);
1290 _LOGD("Processing launchconditions failed\n");
1298 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare)
1300 const xmlChar *node;
1304 depth = xmlTextReaderDepth(reader);
1305 while ((ret = __next_child_element(reader, depth))) {
1306 node = xmlTextReaderConstName(reader);
1308 _LOGD("xmlTextReaderConstName value is NULL\n");
1312 if (!strcmp(ASCII(node), "define")) {
1313 define_x *define = calloc(1, sizeof(define_x));
1314 if (define == NULL) {
1315 _LOGD("Malloc Failed\n");
1318 datashare->define = g_list_append(datashare->define, define);
1319 ret = __ps_process_define(reader, define);
1320 } else if (!strcmp(ASCII(node), "request")) {
1322 ret = __ps_process_request(reader, &val);
1324 datashare->request = g_list_append(datashare->request, (gpointer)val);
1328 _LOGD("Processing data-share failed\n");
1335 static char *__get_icon_with_path(const char *icon, uid_t uid)
1337 char icon_with_path[BUFSIZE];
1338 const char *app_path;
1340 if (!icon || !package)
1343 /* just use absolute path */
1344 if (index(icon, '/'))
1345 return strdup(icon);
1348 snprintf(icon_with_path, sizeof(icon_with_path), "%s%s",
1349 getIconPath(uid, true), icon);
1350 if (access(icon_with_path, F_OK) == 0)
1353 snprintf(icon_with_path, sizeof(icon_with_path), "%s%s",
1354 getIconPath(uid, false), icon);
1355 if (access(icon_with_path, F_OK) == 0)
1358 /* for backward compatibility (.../default/small/...)
1359 * this should be removed
1361 snprintf(icon_with_path, sizeof(icon_with_path),
1362 "%sdefault/small/%s",
1363 getIconPath(uid, true), icon);
1364 if (access(icon_with_path, F_OK) == 0)
1367 snprintf(icon_with_path, sizeof(icon_with_path),
1368 "%sdefault/small/%s",
1369 getIconPath(uid, false), icon);
1370 if (access(icon_with_path, F_OK) == 0)
1373 /* If doesn't exist in case of Global app,
1374 * try to get icon directly into app's directory
1376 if (uid == GLOBAL_USER || uid == OWNER_ROOT) {
1377 app_path = tzplatform_getenv(TZ_SYS_RO_APP);
1379 snprintf(icon_with_path, sizeof(icon_with_path),
1380 "%s/%s/%s", app_path, package, icon);
1381 if (access(icon_with_path, F_OK) == 0)
1384 app_path = tzplatform_getenv(TZ_SYS_RW_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 tzplatform_set_user(uid);
1392 app_path = tzplatform_getenv(TZ_USER_APP);
1393 tzplatform_reset_user();
1395 snprintf(icon_with_path, sizeof(icon_with_path),
1396 "%s/%s/%s", app_path, package, icon);
1397 if (access(icon_with_path, F_OK) == 0)
1401 /* some preload package has icons at below path */
1402 snprintf(icon_with_path, sizeof(icon_with_path),
1403 "%s/%s/res/icons/%s", app_path, package, icon);
1404 if (access(icon_with_path, F_OK) == 0)
1407 /* since 2.3 tpk package */
1408 snprintf(icon_with_path, sizeof(icon_with_path),
1409 "%s/%s/shared/res/%s", app_path, package, icon);
1410 if (access(icon_with_path, F_OK) == 0)
1413 _LOGE("cannot find icon path for [%s]", icon);
1417 _LOGD("Icon path : %s ---> %s", icon, icon_with_path);
1419 return strdup(icon_with_path);
1422 static void __ps_process_tag(manifest_x * mfx, char *const tagv[])
1425 char delims[] = "=";
1426 char *ret_result = NULL;
1433 for (tag = strdup(tagv[0]); tag != NULL; ) {
1434 ret_result = strtok_r(tag, delims, &ptr);
1436 /*check tag : preload */
1437 if (strcmp(ret_result, "preload") == 0) {
1438 ret_result = strtok_r(NULL, delims, &ptr);
1439 if (strcmp(ret_result, "true") == 0) {
1440 free((void *)mfx->preload);
1441 mfx->preload = strdup("true");
1442 } else if (strcmp(ret_result, "false") == 0) {
1443 free((void *)mfx->preload);
1444 mfx->preload = strdup("false");
1446 /*check tag : removable*/
1447 } else if (strcmp(ret_result, "removable") == 0) {
1448 ret_result = strtok_r(NULL, delims, &ptr);
1449 if (strcmp(ret_result, "true") == 0) {
1450 free((void *)mfx->removable);
1451 mfx->removable = strdup("true");
1452 } else if (strcmp(ret_result, "false") == 0) {
1453 free((void *)mfx->removable);
1454 mfx->removable = strdup("false");
1456 /*check tag : not matched*/
1458 _LOGD("tag process [%s]is not defined\n", ret_result);
1462 /*check next value*/
1463 if (tagv[++i] != NULL)
1464 tag = strdup(tagv[i]);
1466 _LOGD("tag process success...\n");
1472 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon, uid_t uid)
1474 __save_xml_attribute(reader, "section", &icon->section, NULL);
1475 __save_xml_attribute(reader, "size", &icon->size, NULL);
1476 __save_xml_attribute(reader, "resolution", &icon->resolution, NULL);
1477 __save_xml_lang(reader, &icon->lang);
1479 xmlTextReaderRead(reader);
1480 char *text = ASCII(xmlTextReaderValue(reader));
1482 icon->text = __get_icon_with_path(text, uid);
1489 static int __ps_process_image(xmlTextReaderPtr reader, image_x *image)
1491 __save_xml_attribute(reader, "section", &image->section, NULL);
1492 __save_xml_lang(reader, &image->lang);
1493 __save_xml_value(reader, &image->text);
1497 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label)
1499 __save_xml_attribute(reader, "name", &label->name, NULL);
1500 __save_xml_lang(reader, &label->lang);
1501 __save_xml_value(reader, &label->text);
1506 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author)
1508 __save_xml_attribute(reader, "email", &author->email, NULL);
1509 __save_xml_attribute(reader, "href", &author->href, NULL);
1510 __save_xml_value(reader, &author->text);
1514 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description)
1516 __save_xml_lang(reader, &description->lang);
1517 __save_xml_value(reader, &description->text);
1521 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license)
1523 __save_xml_lang(reader, &license->lang);
1524 __save_xml_value(reader, &license->text);
1528 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol)
1530 __save_xml_attribute(reader, "providerid", &datacontrol->providerid, NULL);
1531 __save_xml_attribute(reader, "access", &datacontrol->access, NULL);
1532 __save_xml_attribute(reader, "type", &datacontrol->type, NULL);
1536 static int __ps_process_splashscreen(xmlTextReaderPtr reader, splashscreen_x *splashscreen)
1538 __save_xml_attribute(reader, "src", &splashscreen->src, NULL);
1539 __save_xml_attribute(reader, "type", &splashscreen->type, NULL);
1540 __save_xml_attribute(reader, "dpi", &splashscreen->dpi, NULL);
1541 __save_xml_attribute(reader, "orientation", &splashscreen->orientation, NULL);
1542 __save_xml_attribute(reader, "indicator-display", &splashscreen->indicatordisplay, NULL);
1543 __save_xml_attribute(reader, "app-control-operation", &splashscreen->operation, NULL);
1544 __save_xml_attribute(reader, "color-depth", &splashscreen->color_depth, NULL);
1548 static int __ps_process_splashscreens(xmlTextReaderPtr reader, GList **splashscreens)
1550 const xmlChar *node;
1553 splashscreen_x *splashscreen;
1555 depth = xmlTextReaderDepth(reader);
1556 while ((ret = __next_child_element(reader, depth))) {
1557 node = xmlTextReaderConstName(reader);
1559 _LOGD("xmlTextReaderConstName value is NULL\n");
1563 if (strcmp(ASCII(node), "splash-screen") == 0) {
1564 splashscreen = calloc(1, sizeof(splashscreen_x));
1565 if (splashscreen == NULL) {
1566 _LOGD("Malloc Failed\n");
1569 *splashscreens = g_list_append(*splashscreens, splashscreen);
1570 ret = __ps_process_splashscreen(reader, splashscreen);
1576 _LOGD("Processing splash-screen failed\n");
1583 static int __ps_process_application(xmlTextReaderPtr reader, application_x *application, int type, uid_t uid)
1585 const xmlChar *node;
1590 __save_xml_attribute(reader, "appid", &application->appid, NULL);
1591 retvm_if(application->appid == NULL, PM_PARSER_R_ERROR, "appid cant be NULL, appid field is mandatory\n");
1592 __save_xml_attribute(reader, "exec", &application->exec, NULL);
1593 __save_xml_attribute(reader, "nodisplay", &application->nodisplay, "false");
1594 __save_xml_attribute(reader, "multiple", &application->multiple, "false");
1595 __save_xml_attribute(reader, "type", &application->type, NULL);
1596 __save_xml_attribute(reader, "categories", &application->categories, NULL);
1597 __save_xml_attribute(reader, "extraid", &application->extraid, NULL);
1598 __save_xml_attribute(reader, "taskmanage", &application->taskmanage, "true");
1599 __save_xml_attribute(reader, "enabled", &application->enabled, "true");
1600 __save_xml_attribute(reader, "hw-acceleration", &application->hwacceleration, "default");
1601 __save_xml_attribute(reader, "screen-reader", &application->screenreader, "use-system-setting");
1602 __save_xml_attribute(reader, "mainapp", &application->mainapp, "false");
1603 __save_xml_attribute(reader, "recentimage", &application->recentimage, "false");
1604 __save_xml_attribute(reader, "launchcondition", &application->launchcondition, "false");
1605 __save_xml_attribute(reader, "indicatordisplay", &application->indicatordisplay, "true");
1606 __save_xml_attribute(reader, "portrait-effectimage", &application->portraitimg, NULL);
1607 __save_xml_attribute(reader, "landscape-effectimage", &application->landscapeimg, NULL);
1608 __save_xml_attribute(reader, "guestmode-visibility", &application->guestmode_visibility, "true");
1609 __save_xml_attribute(reader, "permission-type", &application->permission_type, "normal");
1610 __save_xml_attribute(reader, "component-type", &application->component_type, type == PMINFO_UI_APP ? "uiapp" : type == PMINFO_SVC_APP ? "svcapp" : "widgetapp");
1611 /*component_type has "svcapp" or "uiapp", if it is not, parsing manifest is fail*/
1612 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);
1613 __save_xml_attribute(reader, "submode", &application->submode, "false");
1614 __save_xml_attribute(reader, "submode-mainid", &application->submode_mainid, NULL);
1615 __save_xml_attribute(reader, "process-pool", &application->process_pool, "false");
1616 __save_xml_attribute(reader, "launch_mode", &application->launch_mode, "caller");
1617 __save_xml_attribute(reader, "ui-gadget", &application->ui_gadget, "false");
1618 __save_xml_attribute(reader, "auto-restart", &application->autorestart, "false");
1619 __save_xml_attribute(reader, "on-boot", &application->onboot, "false");
1620 __save_xml_attribute(reader, "splash-screen-display", &application->splash_screen_display, "true");
1622 application->package = strdup(package);
1623 /* overwrite some attributes if the app is widgetapp */
1624 if (type == PMINFO_WIDGET_APP || type == PMINFO_WATCH_APP) {
1625 free((void *)application->nodisplay);
1626 application->nodisplay = strdup("true");
1627 free((void *)application->multiple);
1628 application->multiple = strdup("true");
1629 free((void *)application->type);
1630 application->type = strdup("capp");
1631 free((void *)application->taskmanage);
1632 application->taskmanage = strdup("false");
1633 free((void *)application->indicatordisplay);
1634 application->indicatordisplay = strdup("false");
1637 /* hw-acceleration values are changed from use-GL/not-use-GL/use-system-setting to on/off/default */
1638 if (strcmp(application->hwacceleration, "use-GL") == 0) {
1639 free((void *)application->hwacceleration);
1640 application->hwacceleration = strdup("on");
1641 } else if (strcmp(application->hwacceleration, "not-use-GL") == 0) {
1642 free((void *)application->hwacceleration);
1643 application->hwacceleration = strdup("off");
1644 } else if (strcmp(application->hwacceleration, "use-system-setting") == 0) {
1645 free((void *)application->hwacceleration);
1646 application->hwacceleration = strdup("default");
1649 depth = xmlTextReaderDepth(reader);
1650 while ((ret = __next_child_element(reader, depth))) {
1651 node = xmlTextReaderConstName(reader);
1653 _LOGD("xmlTextReaderConstName value is NULL\n");
1656 if (!strcmp(ASCII(node), "label")) {
1657 label_x *label = calloc(1, sizeof(label_x));
1658 if (label == NULL) {
1659 _LOGD("Malloc Failed\n");
1662 application->label = g_list_append(application->label, label);
1663 ret = __ps_process_label(reader, label);
1664 } else if (!strcmp(ASCII(node), "icon")) {
1665 icon_x *icon = calloc(1, sizeof(icon_x));
1667 _LOGD("Malloc Failed\n");
1670 application->icon = g_list_append(application->icon, icon);
1671 ret = __ps_process_icon(reader, icon, uid);
1672 } else if (!strcmp(ASCII(node), "image")) {
1673 image_x *image = calloc(1, sizeof(image_x));
1674 if (image == NULL) {
1675 _LOGD("Malloc Failed\n");
1678 application->image = g_list_append(application->image, image);
1679 ret = __ps_process_image(reader, image);
1680 } else if (!strcmp(ASCII(node), "category")) {
1682 ret = __ps_process_category(reader, &val);
1684 application->category = g_list_append(application->category, (gpointer)val);
1685 } else if (!strcmp(ASCII(node), "metadata")) {
1686 metadata_x *metadata = calloc(1, sizeof(metadata_x));
1687 if (metadata == NULL) {
1688 _LOGD("Malloc Failed\n");
1691 application->metadata = g_list_append(application->metadata, metadata);
1692 ret = __ps_process_metadata(reader, metadata);
1693 } else if (!strcmp(ASCII(node), "permission")) {
1694 permission_x *permission = calloc(1, sizeof(permission_x));
1695 if (permission == NULL) {
1696 _LOGD("Malloc Failed\n");
1699 application->permission = g_list_append(application->permission, permission);
1700 ret = __ps_process_permission(reader, permission);
1701 } else if (!strcmp(ASCII(node), "app-control")) {
1702 ret = __ps_process_appcontrol(reader, &application->appcontrol);
1703 } else if (!strcmp(ASCII(node), "application-service")) {
1704 ret = __ps_process_appcontrol(reader, &application->appcontrol);
1705 } else if (!strcmp(ASCII(node), "data-share")) {
1706 datashare_x *datashare = calloc(1, sizeof(datashare_x));
1707 if (datashare == NULL) {
1708 _LOGD("Malloc Failed\n");
1711 application->datashare = g_list_append(application->datashare, datashare);
1712 ret = __ps_process_datashare(reader, datashare);
1713 } else if (!strcmp(ASCII(node), "launch-conditions")) {
1714 ret = __ps_process_launchconditions(reader, &application->launchconditions);
1715 } else if (!strcmp(ASCII(node), "notification")) {
1716 notification_x *notification = calloc(1, sizeof(notification_x));
1717 if (notification == NULL) {
1718 _LOGD("Malloc Failed\n");
1721 application->notification = g_list_append(application->notification, notification);
1722 ret = __ps_process_notification(reader, notification);
1723 } else if (!strcmp(ASCII(node), "datacontrol")) {
1724 datacontrol_x *datacontrol = calloc(1, sizeof(datacontrol_x));
1725 if (datacontrol == NULL) {
1726 _LOGD("Malloc Failed\n");
1729 application->datacontrol = g_list_append(application->datacontrol, datacontrol);
1730 ret = __ps_process_datacontrol(reader, datacontrol);
1731 } else if (!strcmp(ASCII(node), "splash-screens") == 0) {
1732 ret = __ps_process_splashscreens(reader, &application->splashscreens);
1736 _LOGD("Processing application failed\n");
1744 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx, uid_t uid)
1746 _LOGD("__start_process\n");
1747 const xmlChar *node;
1751 depth = xmlTextReaderDepth(reader);
1752 while ((ret = __next_child_element(reader, depth))) {
1753 node = xmlTextReaderConstName(reader);
1755 _LOGD("xmlTextReaderConstName value is NULL\n");
1759 if (!strcmp(ASCII(node), "label")) {
1760 label_x *label = calloc(1, sizeof(label_x));
1761 if (label == NULL) {
1762 _LOGD("Malloc Failed\n");
1765 mfx->label = g_list_append(mfx->label, label);
1766 ret = __ps_process_label(reader, label);
1767 } else if (!strcmp(ASCII(node), "author")) {
1768 author_x *author = calloc(1, sizeof(author_x));
1769 if (author == NULL) {
1770 _LOGD("Malloc Failed\n");
1773 mfx->author = g_list_append(mfx->author, author);
1774 ret = __ps_process_author(reader, author);
1775 } else if (!strcmp(ASCII(node), "description")) {
1776 description_x *description = calloc(1, sizeof(description_x));
1777 if (description == NULL) {
1778 _LOGD("Malloc Failed\n");
1781 mfx->description = g_list_append(mfx->description, description);
1782 ret = __ps_process_description(reader, description);
1783 } else if (!strcmp(ASCII(node), "license")) {
1784 license_x *license = calloc(1, sizeof(license_x));
1785 if (license == NULL) {
1786 _LOGD("Malloc Failed\n");
1789 mfx->license = g_list_append(mfx->license, license);
1790 ret = __ps_process_license(reader, license);
1791 } else if (!strcmp(ASCII(node), "privileges")) {
1792 ret = __ps_process_privileges(reader, &mfx->privileges);
1793 } else if (!strcmp(ASCII(node), "ui-application")) {
1794 application_x *application = calloc(1, sizeof(application_x));
1795 if (application == NULL) {
1796 _LOGD("Malloc Failed\n");
1799 mfx->application = g_list_append(mfx->application, application);
1800 ret = __ps_process_application(reader, application, PMINFO_UI_APP, uid);
1801 } else if (!strcmp(ASCII(node), "service-application")) {
1802 application_x *application = calloc(1, sizeof(application_x));
1803 if (application == NULL) {
1804 _LOGD("Malloc Failed\n");
1807 mfx->application = g_list_append(mfx->application, application);
1808 ret = __ps_process_application(reader, application, PMINFO_SVC_APP, uid);
1809 } else if (!strcmp(ASCII(node), "widget-application")) {
1810 application_x *application = calloc(1, sizeof(application_x));
1811 if (application == NULL) {
1812 _LOGD("Malloc Failed\n");
1815 mfx->application = g_list_append(mfx->application, application);
1816 ret = __ps_process_application(reader, application, PMINFO_WIDGET_APP, uid);
1817 } else if (!strcmp(ASCII(node), "watch-application")) {
1818 application_x *application = calloc(1, sizeof(application_x));
1819 if (application == NULL) {
1820 _LOGD("Malloc Failed\n");
1823 mfx->application = g_list_append(mfx->application, application);
1824 ret = __ps_process_application(reader, application, PMINFO_WATCH_APP, uid);
1825 } else if (!strcmp(ASCII(node), "icon")) {
1826 icon_x *icon = calloc(1, sizeof(icon_x));
1828 _LOGD("Malloc Failed\n");
1831 mfx->icon = g_list_append(mfx->icon, icon);
1832 ret = __ps_process_icon(reader, icon, uid);
1833 } else if (!strcmp(ASCII(node), "compatibility")) {
1834 compatibility_x *compatibility = calloc(1, sizeof(compatibility_x));
1835 if (compatibility == NULL) {
1836 _LOGD("Malloc Failed\n");
1839 mfx->compatibility = g_list_append(mfx->compatibility, compatibility);
1840 ret = __ps_process_compatibility(reader, compatibility);
1841 } else if (!strcmp(ASCII(node), "shortcut-list")) {
1843 } else if (!strcmp(ASCII(node), "livebox")) {
1845 } else if (!strcmp(ASCII(node), "account")) {
1847 } else if (!strcmp(ASCII(node), "notifications")) {
1849 } else if (!strcmp(ASCII(node), "ime")) {
1851 } else if (!strcmp(ASCII(node), "feature")) {
1854 _LOGI("Unknown element: %s", ASCII(node));
1859 _LOGD("Processing manifest failed\n");
1866 static int __process_manifest(xmlTextReaderPtr reader, manifest_x *mfx, uid_t uid)
1868 const xmlChar *node;
1871 if ((ret = __next_child_element(reader, -1))) {
1872 node = xmlTextReaderConstName(reader);
1874 _LOGD("xmlTextReaderConstName value is NULL\n");
1878 if (!strcmp(ASCII(node), "manifest")) {
1879 __save_xml_attribute(reader, "xmlns", &mfx->ns, NULL);
1880 __save_xml_attribute(reader, "package", &mfx->package, NULL);
1881 retvm_if(mfx->package == NULL, PM_PARSER_R_ERROR, "package cant be NULL, package field is mandatory\n");
1882 __save_xml_attribute(reader, "version", &mfx->version, NULL);
1883 __save_xml_attribute(reader, "size", &mfx->package_size, NULL);
1884 __save_xml_attribute(reader, "install-location", &mfx->installlocation, "internal-only");
1885 __save_xml_attribute(reader, "type", &mfx->type, "tpk");
1886 __save_xml_attribute(reader, "root_path", &mfx->root_path, NULL);
1887 __save_xml_attribute(reader, "csc_path", &mfx->csc_path, NULL);
1888 __save_xml_attribute(reader, "appsetting", &mfx->appsetting, "false");
1889 __save_xml_attribute(reader, "storeclient-id", &mfx->storeclient_id, NULL);
1890 __save_xml_attribute(reader, "nodisplay-setting", &mfx->nodisplay_setting, "false");
1891 __save_xml_attribute(reader, "url", &mfx->package_url, NULL);
1892 __save_xml_attribute(reader, "api-version", &mfx->api_version, NULL);
1893 __save_xml_attribute(reader, "support-disable", &mfx->support_disable, "false");
1895 __save_xml_installed_time(mfx);
1896 __save_xml_root_path(mfx, uid);
1897 /*Assign default values. If required it will be overwritten in __add_preload_info()*/
1898 __save_xml_default_value(mfx);
1900 ret = __start_process(reader, mfx, uid);
1902 _LOGD("No Manifest element found\n");
1909 #define LIBAPPSVC_PATH LIB_PATH "/libappsvc.so.0"
1911 static int __ps_remove_appsvc_db(manifest_x *mfx, uid_t uid)
1913 void *lib_handle = NULL;
1914 int (*appsvc_operation) (const char *, uid_t);
1917 application_x *application;
1919 if ((lib_handle = dlopen(LIBAPPSVC_PATH, RTLD_LAZY)) == NULL) {
1920 _LOGE("dlopen is failed LIBAPPSVC_PATH[%s]\n", LIBAPPSVC_PATH);
1924 if ((appsvc_operation =
1925 dlsym(lib_handle, "appsvc_unset_defapp")) == NULL || dlerror() != NULL) {
1926 _LOGE("can not find symbol \n");
1930 for (tmp = mfx->application; tmp; tmp = tmp->next) {
1931 application = (application_x *)tmp->data;
1932 if (application == NULL)
1934 ret = appsvc_operation(application->appid, uid);
1936 _LOGE("can not operation symbol \n");
1941 dlclose(lib_handle);
1946 static int __check_preload_updated(manifest_x * mfx, const char *manifest, uid_t uid)
1948 if (!strstr(manifest, getUserManifestPath(uid,
1949 strcmp(mfx->preload, "true") == 0))) {
1950 /* if downloaded app is updated, then update tag set true*/
1952 free((void *)mfx->update);
1953 mfx->update = strdup("true");
1959 API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
1961 pkgmgrinfo_basic_free_package((package_x *)mfx);
1964 DEPRECATED API manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest)
1966 _LOGD("parsing start pkgmgr_parser_process_manifest_xml\n");
1967 xmlTextReaderPtr reader;
1968 manifest_x *mfx = NULL;
1970 reader = xmlReaderForFile(manifest, NULL, 0);
1972 mfx = malloc(sizeof(manifest_x));
1974 memset(mfx, '\0', sizeof(manifest_x));
1975 if (__process_manifest(reader, mfx, GLOBAL_USER) < 0) {
1976 _LOGD("Parsing Failed\n");
1977 pkgmgr_parser_free_manifest_xml(mfx);
1980 _LOGD("Parsing Success\n");
1982 _LOGD("Memory allocation error\n");
1984 xmlFreeTextReader(reader);
1986 _LOGD("Unable to create xml reader\n");
1992 DEPRECATED API manifest_x *pkgmgr_parser_usr_process_manifest_xml(const char *manifest, uid_t uid)
1994 _LOGD("parsing start pkgmgr_parser_usr_process_manifest_xml\n");
1995 xmlTextReaderPtr reader;
1996 manifest_x *mfx = NULL;
1998 reader = xmlReaderForFile(manifest, NULL, 0);
2000 mfx = malloc(sizeof(manifest_x));
2002 memset(mfx, '\0', sizeof(manifest_x));
2003 if (__process_manifest(reader, mfx, uid) < 0) {
2004 _LOGD("Parsing Failed\n");
2005 pkgmgr_parser_free_manifest_xml(mfx);
2008 _LOGD("Parsing Success\n");
2010 _LOGD("Memory allocation error\n");
2012 xmlFreeTextReader(reader);
2014 _LOGD("Unable to create xml reader\n");
2019 API int pkgmgr_parser_usr_update_tep(const char *pkgid, const char *tep_path, uid_t uid)
2021 return pkgmgr_parser_update_tep_info_in_usr_db(pkgid, tep_path, uid);
2024 API int pkgmgr_parser_update_tep(const char *pkgid, const char *tep_path)
2026 return pkgmgr_parser_update_tep_info_in_db(pkgid, tep_path);
2029 DEPRECATED API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
2031 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2032 _LOGD("parsing manifest for installation: %s\n", manifest);
2034 manifest_x *mfx = NULL;
2038 mfx = pkgmgr_parser_process_manifest_xml(manifest);
2039 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2041 _LOGD("Parsing Finished\n");
2043 __ps_process_tag(mfx, tagv);
2045 ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
2046 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
2048 _LOGD("DB Insert Success\n");
2050 __ps_process_tag_parser(mfx, manifest, ACTION_INSTALL);
2051 ret = __ps_process_metadata_parser(mfx, ACTION_INSTALL);
2053 _LOGD("Creating metadata parser failed\n");
2055 ret = __ps_process_category_parser(mfx, ACTION_INSTALL);
2057 _LOGD("Creating category parser failed\n");
2059 pkgmgr_parser_free_manifest_xml(mfx);
2060 _LOGD("Free Done\n");
2066 DEPRECATED API int pkgmgr_parser_parse_usr_manifest_for_installation(const char *manifest, uid_t uid, char *const tagv[])
2068 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2069 _LOGD("parsing manifest for installation: %s\n", manifest);
2070 manifest_x *mfx = NULL;
2074 mfx = pkgmgr_parser_usr_process_manifest_xml(manifest, uid);
2075 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2077 _LOGD("Parsing Finished\n");
2079 __ps_process_tag(mfx, tagv);
2081 ret = pkgmgr_parser_insert_manifest_info_in_usr_db(mfx, uid);
2082 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
2084 _LOGD("DB Insert Success\n");
2086 __ps_process_tag_parser(mfx, manifest, ACTION_INSTALL);
2087 ret = __ps_process_metadata_parser(mfx, ACTION_INSTALL);
2089 _LOGD("Creating metadata parser failed\n");
2090 ret = __ps_process_category_parser(mfx, ACTION_INSTALL);
2092 _LOGD("Creating category parser failed\n");
2094 pkgmgr_parser_free_manifest_xml(mfx);
2095 _LOGD("Free Done\n");
2101 API int pkgmgr_parser_process_manifest_x_for_installation(manifest_x* mfx, const char *manifest)
2103 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2104 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2105 _LOGD("processing manifest_x for installation: %s\n", manifest);
2108 ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
2109 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
2110 _LOGD("DB Insert Success\n");
2115 API int pkgmgr_parser_process_usr_manifest_x_for_installation(manifest_x* mfx, const char *manifest, uid_t uid)
2117 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2118 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2119 _LOGD("processing manifest_x for installation: %s\n", manifest);
2122 ret = pkgmgr_parser_insert_manifest_info_in_usr_db(mfx, uid);
2123 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
2124 _LOGD("DB Insert Success\n");
2129 DEPRECATED API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
2131 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2132 _LOGD("pkgmgr_parser_parse_manifest_for_upgrade parsing manifest for upgradation: %s\n", manifest);
2133 manifest_x *mfx = NULL;
2135 bool preload = false;
2136 bool system = false;
2137 char *csc_path = NULL;
2138 pkgmgrinfo_pkginfo_h handle = NULL;
2141 mfx = pkgmgr_parser_process_manifest_xml(manifest);
2142 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2144 _LOGD("Parsing Finished\n");
2145 __check_preload_updated(mfx, manifest, GLOBAL_USER);
2147 ret = pkgmgrinfo_pkginfo_get_pkginfo(mfx->package, &handle);
2148 if (ret != PMINFO_R_OK)
2149 _LOGD("pkgmgrinfo_pkginfo_get_pkginfo failed\n");
2150 ret = pkgmgrinfo_pkginfo_is_preload(handle, &preload);
2151 if (ret != PMINFO_R_OK)
2152 _LOGD("pkgmgrinfo_pkginfo_is_preload failed\n");
2155 free((void *)mfx->preload);
2156 mfx->preload = strdup("true");
2159 ret = pkgmgrinfo_pkginfo_is_system(handle, &system);
2160 if (ret != PMINFO_R_OK)
2161 _LOGD("pkgmgrinfo_pkginfo_is_system failed\n");
2163 free((void *)mfx->system);
2164 mfx->system = strdup("true");
2167 ret = pkgmgrinfo_pkginfo_get_csc_path(handle, &csc_path);
2168 if (ret != PMINFO_R_OK)
2169 _LOGD("pkgmgrinfo_pkginfo_get_csc_path failed\n");
2171 if (csc_path != NULL) {
2173 free((void *)mfx->csc_path);
2174 mfx->csc_path = strdup(csc_path);
2177 /*Delete from cert table*/
2178 ret = pkgmgrinfo_delete_certinfo(mfx->package);
2180 _LOGD("Cert Info DB Delete Failed\n");
2184 ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
2185 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
2187 _LOGD("DB Update Success\n");
2189 __ps_process_tag_parser(mfx, manifest, ACTION_UPGRADE);
2190 ret = __ps_process_metadata_parser(mfx, ACTION_UPGRADE);
2192 _LOGD("Upgrade metadata parser failed\n");
2193 ret = __ps_process_category_parser(mfx, ACTION_UPGRADE);
2195 _LOGD("Creating category parser failed\n");
2196 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
2197 pkgmgr_parser_free_manifest_xml(mfx);
2198 _LOGD("Free Done\n");
2204 DEPRECATED API int pkgmgr_parser_parse_usr_manifest_for_upgrade(const char *manifest, uid_t uid, char *const tagv[])
2206 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2207 _LOGD(" pkgmgr_parser_parse_usr_manifest_for_upgrade parsing manifest for upgradation: %s\n", manifest);
2208 manifest_x *mfx = NULL;
2210 bool preload = false;
2211 bool system = false;
2212 char *csc_path = NULL;
2213 pkgmgrinfo_pkginfo_h handle = NULL;
2216 mfx = pkgmgr_parser_usr_process_manifest_xml(manifest, uid);
2217 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2219 _LOGD("Parsing Finished\n");
2220 __check_preload_updated(mfx, manifest, uid);
2222 ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(mfx->package, uid, &handle);
2223 if (ret != PMINFO_R_OK)
2224 _LOGD("pkgmgrinfo_pkginfo_get_pkginfo failed\n");
2225 ret = pkgmgrinfo_pkginfo_is_preload(handle, &preload);
2226 if (ret != PMINFO_R_OK)
2227 _LOGD("pkgmgrinfo_pkginfo_is_preload failed\n");
2230 free((void *)mfx->preload);
2231 mfx->preload = strdup("true");
2234 ret = pkgmgrinfo_pkginfo_is_system(handle, &system);
2235 if (ret != PMINFO_R_OK)
2236 _LOGD("pkgmgrinfo_pkginfo_is_system failed\n");
2239 free((void *)mfx->system);
2240 mfx->system = strdup("true");
2243 ret = pkgmgrinfo_pkginfo_get_csc_path(handle, &csc_path);
2244 if (ret != PMINFO_R_OK)
2245 _LOGD("pkgmgrinfo_pkginfo_get_csc_path failed\n");
2246 if (csc_path != NULL) {
2248 free((void *)mfx->csc_path);
2249 mfx->csc_path = strdup(csc_path);
2252 /*Delete from cert table*/
2253 ret = pkgmgrinfo_delete_certinfo(mfx->package);
2255 _LOGD("Cert Info DB Delete Failed\n");
2259 ret = pkgmgr_parser_update_manifest_info_in_usr_db(mfx, uid);
2260 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
2261 _LOGD("DB Update Success\n");
2263 __ps_process_tag_parser(mfx, manifest, ACTION_UPGRADE);
2264 ret = __ps_process_metadata_parser(mfx, ACTION_UPGRADE);
2266 _LOGD("Upgrade metadata parser failed\n");
2267 ret = __ps_process_category_parser(mfx, ACTION_UPGRADE);
2269 _LOGD("Creating category parser failed\n");
2270 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
2271 pkgmgr_parser_free_manifest_xml(mfx);
2272 _LOGD("Free Done\n");
2278 API int pkgmgr_parser_process_manifest_x_for_upgrade(manifest_x* mfx, const char *manifest)
2280 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2281 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2282 _LOGD("pkgmgr_parser_process_manifest_x_for_upgrade parsing manifest for upgradation: %s\n", manifest);
2285 ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
2286 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
2287 _LOGD("DB Update Success\n");
2292 API int pkgmgr_parser_process_usr_manifest_x_for_upgrade(manifest_x* mfx, const char *manifest, uid_t uid)
2294 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2295 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2296 _LOGD(" pkgmgr_parser_process_usr_manifest_x_for_upgrade parsing manifest for upgradation: %s\n", manifest);
2299 ret = pkgmgr_parser_update_manifest_info_in_usr_db(mfx, uid);
2300 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
2301 _LOGD("DB Update Success\n");
2306 API int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[])
2308 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2309 _LOGD("parsing manifest for uninstallation: %s\n", manifest);
2311 manifest_x *mfx = NULL;
2314 mfx = pkgmgr_parser_process_manifest_xml(manifest);
2315 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2317 _LOGD("Parsing Finished\n");
2319 __ps_process_tag_parser(mfx, manifest, ACTION_UNINSTALL);
2321 ret = __ps_process_metadata_parser(mfx, ACTION_UNINSTALL);
2323 _LOGD("Removing metadata parser failed\n");
2325 ret = __ps_process_category_parser(mfx, ACTION_UNINSTALL);
2327 _LOGD("Creating category parser failed\n");
2329 /*Delete from cert table*/
2330 ret = pkgmgrinfo_delete_certinfo(mfx->package);
2332 _LOGD("Cert Info DB Delete Failed\n");
2336 ret = pkgmgr_parser_delete_manifest_info_from_db(mfx);
2338 _LOGD("DB Delete failed\n");
2340 _LOGD("DB Delete Success\n");
2342 pkgmgr_parser_free_manifest_xml(mfx);
2343 _LOGD("Free Done\n");
2350 API int pkgmgr_parser_parse_usr_manifest_for_uninstallation(const char *manifest, uid_t uid, char *const tagv[])
2352 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2353 _LOGD("parsing manifest for uninstallation: %s\n", manifest);
2355 manifest_x *mfx = NULL;
2358 mfx = pkgmgr_parser_usr_process_manifest_xml(manifest, uid);
2359 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2361 _LOGD("Parsing Finished\n");
2363 __ps_process_tag_parser(mfx, manifest, ACTION_UNINSTALL);
2365 ret = __ps_process_metadata_parser(mfx, ACTION_UNINSTALL);
2367 _LOGD("Removing metadata parser failed\n");
2369 ret = __ps_process_category_parser(mfx, ACTION_UNINSTALL);
2371 _LOGD("Creating category parser failed\n");
2373 /*Delete from cert table*/
2374 ret = pkgmgrinfo_delete_certinfo(mfx->package);
2376 _LOGD("Cert Info DB Delete Failed\n");
2380 ret = pkgmgr_parser_delete_manifest_info_from_usr_db(mfx, uid);
2382 _LOGD("DB Delete failed\n");
2384 _LOGD("DB Delete Success\n");
2386 ret = __ps_remove_appsvc_db(mfx, uid);
2388 _LOGD("Removing appsvc_db failed\n");
2390 _LOGD("Removing appsvc_db Success\n");
2392 pkgmgr_parser_free_manifest_xml(mfx);
2393 _LOGD("Free Done\n");
2399 API int pkgmgr_parser_process_manifest_x_for_uninstallation(manifest_x* mfx, const char *manifest)
2401 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2402 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2403 _LOGD("processing manifest_x for uninstallation: %s\n", manifest);
2406 ret = pkgmgr_parser_delete_manifest_info_from_db(mfx);
2408 _LOGD("DB Delete failed\n");
2410 _LOGD("DB Delete Success\n");
2415 API int pkgmgr_parser_process_usr_manifest_x_for_uninstallation(manifest_x* mfx, const char *manifest, uid_t uid)
2417 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2418 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
2419 _LOGD("processing manifest_x for uninstallation: %s\n", manifest);
2423 ret = pkgmgr_parser_delete_manifest_info_from_usr_db(mfx, uid);
2425 _LOGD("DB Delete failed\n");
2427 _LOGD("DB Delete Success\n");
2429 ret = __ps_remove_appsvc_db(mfx, uid);
2431 _LOGD("Removing appsvc_db failed\n");
2433 _LOGD("Removing appsvc_db Success\n");
2438 #define SCHEMA_FILE SYSCONFDIR "/package-manager/preload/manifest.xsd"
2439 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
2441 if (manifest == NULL) {
2442 _LOGE("manifest file is NULL\n");
2443 return PMINFO_R_EINVAL;
2446 xmlSchemaParserCtxtPtr ctx;
2447 xmlSchemaValidCtxtPtr vctx;
2448 xmlSchemaPtr xschema;
2449 ctx = xmlSchemaNewParserCtxt(SCHEMA_FILE);
2451 _LOGE("xmlSchemaNewParserCtxt() Failed\n");
2452 return PMINFO_R_ERROR;
2454 xschema = xmlSchemaParse(ctx);
2455 if (xschema == NULL) {
2456 _LOGE("xmlSchemaParse() Failed\n");
2457 return PMINFO_R_ERROR;
2459 vctx = xmlSchemaNewValidCtxt(xschema);
2461 _LOGE("xmlSchemaNewValidCtxt() Failed\n");
2462 return PMINFO_R_ERROR;
2464 xmlSchemaSetValidErrors(vctx, (xmlSchemaValidityErrorFunc) fprintf, (xmlSchemaValidityWarningFunc) fprintf, stderr);
2465 ret = xmlSchemaValidateFile(vctx, manifest, 0);
2467 _LOGE("xmlSchemaValidateFile() failed\n");
2468 return PMINFO_R_ERROR;
2469 } else if (ret == 0) {
2470 _LOGD("Manifest is Valid\n");
2473 _LOGE("Manifest Validation Failed with error code %d\n", ret);
2474 return PMINFO_R_ERROR;