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_parser.h"
39 #include "pkgmgr_parser_internal.h"
40 #include "pkgmgr_parser_db.h"
41 #include "pkgmgr-info.h"
42 #include "pkgmgr_parser_signature.h"
43 #include "pkgmgr-info-debug.h"
48 #define LOG_TAG "PKGMGR_PARSER"
50 #define ASCII(s) (const char *)s
51 #define XMLCHAR(s) (const xmlChar *)s
53 //#define METADATA_PARSER_LIST SYSCONFDIR "/package-manager/parserlib/metadata/metadata_parser_list.txt"
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)
77 /* plugin process_type */
79 PLUGIN_PRE_PROCESS = 0,
81 } PLUGIN_PROCESS_TYPE;
94 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label);
95 static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege);
96 static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privileges);
97 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile);
98 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed);
99 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation);
100 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri);
101 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime);
102 static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp);
103 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition);
104 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notifiation);
105 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category);
106 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata);
107 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission);
108 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility);
109 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution);
110 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request);
111 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define);
112 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc);
113 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions);
114 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare);
115 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon, uid_t uid);
116 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author);
117 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description);
118 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability);
119 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license);
120 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol);
121 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol);
122 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication, uid_t uid);
123 static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication, uid_t uid);
124 static int __ps_process_font(xmlTextReaderPtr reader, font_x *font);
125 static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme);
126 static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon);
127 static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime);
128 static void __ps_free_label(label_x *label);
129 static void __ps_free_privilege(privilege_x *privilege);
130 static void __ps_free_privileges(privileges_x *privileges);
131 static void __ps_free_deviceprofile(deviceprofile_x * deviceprofile);
132 static void __ps_free_allowed(allowed_x *allowed);
133 static void __ps_free_operation(operation_x *operation);
134 static void __ps_free_uri(uri_x *uri);
135 static void __ps_free_mime(mime_x *mime);
136 static void __ps_free_subapp(subapp_x *subapp);
137 static void __ps_free_condition(condition_x *condition);
138 static void __ps_free_notification(notification_x *notifiation);
139 static void __ps_free_category(category_x *category);
140 static void __ps_free_metadata(metadata_x *metadata);
141 static void __ps_free_permission(permission_x *permission);
142 static void __ps_free_compatibility(compatibility_x *compatibility);
143 static void __ps_free_resolution(resolution_x *resolution);
144 static void __ps_free_request(request_x *request);
145 static void __ps_free_define(define_x *define);
146 static void __ps_free_appsvc(appsvc_x *appsvc);
147 static void __ps_free_launchconditions(launchconditions_x *launchconditions);
148 static void __ps_free_datashare(datashare_x *datashare);
149 static void __ps_free_icon(icon_x *icon);
150 static void __ps_free_author(author_x *author);
151 static void __ps_free_description(description_x *description);
152 static void __ps_free_capability(capability_x *capability);
153 static void __ps_free_license(license_x *license);
154 static void __ps_free_appcontrol(appcontrol_x *appcontrol);
155 static void __ps_free_datacontrol(datacontrol_x *datacontrol);
156 static void __ps_free_uiapplication(uiapplication_x *uiapplication);
157 static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication);
158 static void __ps_free_font(font_x *font);
159 static void __ps_free_theme(theme_x *theme);
160 static void __ps_free_daemon(daemon_x *daemon);
161 static void __ps_free_ime(ime_x *ime);
162 static char *__pkgid_to_manifest(const char *pkgid, uid_t uid);
163 static int __next_child_element(xmlTextReaderPtr reader, int depth);
164 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx, uid_t uid);
165 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx, uid_t uid);
166 static void __str_trim(char *input);
167 static char *__get_parser_plugin(const char *type);
168 static int __ps_run_parser(xmlDocPtr docPtr, const char *tag, ACTION_TYPE action, const char *pkgid);
169 static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid);
170 static void __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgid);
171 static void __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid);
172 static int __validate_appid(const char *pkgid, const char *appid, char **newappid);
173 API int __is_admin();
175 void *__open_lib_handle(char *tag)
177 char *lib_path = NULL;
178 void *lib_handle = NULL;
180 lib_path = __get_parser_plugin(tag);
181 retvm_if(!lib_path, NULL, "lib_path get fail");
183 lib_handle = dlopen(lib_path, RTLD_LAZY);
184 retvm_if(lib_handle == NULL, NULL, "dlopen is failed lib_path[%s]", lib_path);
189 void __close_lib_handle(void *lib_handle)
194 static void __str_trim(char *input)
196 char *trim_str = input;
201 while (*input != 0) {
202 if (!isspace(*input)) {
215 uid_t uid = getuid();
216 if ((uid_t) 0 == uid )
224 static int __validate_appid(const char *pkgid, const char *appid, char **newappid)
226 if (!pkgid || !appid || !newappid) {
227 _LOGD("Arg supplied is NULL\n");
230 int pkglen = strlen(pkgid);
231 int applen = strlen(appid);
235 if (strncmp(appid, ".", 1) == 0) {
236 len = pkglen + applen + 1;
237 newapp = calloc(1,len);
238 if (newapp == NULL) {
239 _LOGD("Malloc failed\n");
242 strncpy(newapp, pkgid, pkglen);
243 strncat(newapp, appid, applen);
244 _LOGD("new appid is %s\n", newapp);
248 if (applen < pkglen) {
249 _LOGD("app id is not proper\n");
251 #ifdef _VALIDATE_APPID_
257 if (!strcmp(appid, pkgid)) {
258 _LOGD("appid is proper\n");
262 else if (strncmp(appid, pkgid, pkglen) == 0) {
263 ptr = strstr(appid, pkgid);
265 if (strncmp(ptr, ".", 1) == 0) {
266 _LOGD("appid is proper\n");
271 _LOGD("appid is not proper\n");
273 #ifdef _VALIDATE_APPID_
280 _LOGD("appid is not proper\n");
282 #ifdef _VALIDATE_APPID_
291 static char * __get_tag_by_key(char *md_key)
295 if (md_key == NULL) {
296 _LOGD("md_key is NULL\n");
300 md_tag = strrchr(md_key, 47) + 1;
303 return strdup(md_tag);
306 static char *__get_metadata_parser_plugin(const char *type)
309 char buffer[1024] = { 0 };
310 char temp_path[1024] = { 0 };
314 _LOGE("invalid argument\n");
318 fp = fopen(PKG_PARSER_CONF_PATH, "r");
320 _LOGE("no matching metadata parser\n");
324 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
325 if (buffer[0] == '#')
330 if ((path = strstr(buffer, METADATA_PARSER_NAME)) != NULL) {
331 path = path + strlen(METADATA_PARSER_NAME);
336 memset(buffer, 0x00, 1024);
343 _LOGE("no matching [%s] [%s]\n", METADATA_PARSER_NAME,type);
347 snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
349 return strdup(temp_path);
352 static char *__get_category_parser_plugin(const char *type)
355 char buffer[1024] = { 0 };
356 char temp_path[1024] = { 0 };
360 _LOGE("invalid argument\n");
364 fp = fopen(PKG_PARSER_CONF_PATH, "r");
366 _LOGE("no matching metadata parser\n");
370 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
371 if (buffer[0] == '#')
376 if ((path = strstr(buffer, CATEGORY_PARSER_NAME)) != NULL) {
377 path = path + strlen(CATEGORY_PARSER_NAME);
382 memset(buffer, 0x00, 1024);
389 _LOGE("no matching [%s] [%s]\n", CATEGORY_PARSER_NAME,type);
393 snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
395 return strdup(temp_path);
398 static char *__get_parser_plugin(const char *type)
401 char buffer[1024] = { 0 };
402 char temp_path[1024] = { 0 };
406 _LOGE("invalid argument\n");
410 fp = fopen(PKG_PARSER_CONF_PATH, "r");
412 _LOGE("no matching backendlib\n");
416 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
417 if (buffer[0] == '#')
422 if ((path = strstr(buffer, PKG_PARSERLIB)) != NULL) {
423 path = path + strlen(PKG_PARSERLIB);
427 memset(buffer, 0x00, 1024);
434 _LOGE("no matching backendlib\n");
438 snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
440 return strdup(temp_path);
443 static int __ps_run_tag_parser(void *lib_handle, xmlDocPtr docPtr, const char *tag,
444 ACTION_TYPE action, const char *pkgid)
446 int (*plugin_install) (xmlDocPtr, const char *);
452 ac = "PKGMGR_PARSER_PLUGIN_INSTALL";
455 ac = "PKGMGR_PARSER_PLUGIN_UPGRADE";
457 case ACTION_UNINSTALL:
458 ac = "PKGMGR_PARSER_PLUGIN_UNINSTALL";
464 if ((plugin_install =
465 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
466 _LOGE("can not find symbol[%s] \n", ac);
470 ret = plugin_install(docPtr, pkgid);
471 _LOGD("tag parser[%s, %s] ACTION_TYPE[%d] result[%d]\n", pkgid, tag, action, ret);
477 static int __ps_run_metadata_parser(GList *md_list, const char *tag,
478 ACTION_TYPE action, const char *pkgid, const char *appid)
480 char *lib_path = NULL;
481 void *lib_handle = NULL;
482 int (*metadata_parser_plugin) (const char *, const char *, GList *);
488 ac = "PKGMGR_MDPARSER_PLUGIN_INSTALL";
491 ac = "PKGMGR_MDPARSER_PLUGIN_UPGRADE";
493 case ACTION_UNINSTALL:
494 ac = "PKGMGR_MDPARSER_PLUGIN_UNINSTALL";
500 lib_path = __get_metadata_parser_plugin(tag);
502 _LOGE("get %s parser fail\n", tag);
506 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
507 _LOGE("dlopen is failed lib_path[%s]\n", lib_path);
511 if ((metadata_parser_plugin =
512 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
513 _LOGE("can not find symbol[%s] \n",ac);
517 ret = metadata_parser_plugin(pkgid, appid, md_list);
519 _LOGD("[appid = %s, libpath = %s plugin fail\n", appid, lib_path);
521 _LOGD("[appid = %s, libpath = %s plugin success\n", appid, lib_path);
531 static int __ps_run_category_parser(GList *category_list, const char *tag,
532 ACTION_TYPE action, const char *pkgid, const char *appid)
534 char *lib_path = NULL;
535 void *lib_handle = NULL;
536 int (*category_parser_plugin) (const char *, const char *, GList *);
542 ac = "PKGMGR_CATEGORY_PARSER_PLUGIN_INSTALL";
545 ac = "PKGMGR_CATEGORY_PARSER_PLUGIN_UPGRADE";
547 case ACTION_UNINSTALL:
548 ac = "PKGMGR_CATEGORY_PARSER_PLUGIN_UNINSTALL";
554 lib_path = __get_category_parser_plugin(tag);
556 _LOGE("get %s parser fail\n", tag);
560 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
561 _LOGE("dlopen is failed lib_path[%s]\n", lib_path);
565 if ((category_parser_plugin =
566 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
567 _LOGE("can not find symbol[%s] \n",ac);
571 ret = category_parser_plugin(pkgid, appid, category_list);
573 _LOGD("[appid = %s, libpath = %s plugin fail\n", appid, lib_path);
575 _LOGD("[appid = %s, libpath = %s plugin success\n", appid, lib_path);
585 static int __ps_run_parser(xmlDocPtr docPtr, const char *tag,
586 ACTION_TYPE action, const char *pkgid)
588 char *lib_path = NULL;
589 void *lib_handle = NULL;
590 int (*plugin_install) (xmlDocPtr, const char *);
596 ac = "PKGMGR_PARSER_PLUGIN_INSTALL";
599 ac = "PKGMGR_PARSER_PLUGIN_UPGRADE";
601 case ACTION_UNINSTALL:
602 ac = "PKGMGR_PARSER_PLUGIN_UNINSTALL";
608 lib_path = __get_parser_plugin(tag);
613 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
614 _LOGE("dlopen is failed lib_path[%s]\n", lib_path);
617 if ((plugin_install =
618 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
619 _LOGE("can not find symbol[%s] \n", ac);
623 ret = plugin_install(docPtr, pkgid);
625 _LOGD("[pkgid = %s, libpath = %s plugin fail\n", pkgid, lib_path);
627 _LOGD("[pkgid = %s, libpath = %s plugin success\n", pkgid, lib_path);
637 static char *__pkgid_to_manifest(const char *pkgid, uid_t uid)
643 _LOGE("pkgid is NULL");
647 size = strlen(getUserManifestPath(uid)) + strlen(pkgid) + 10;
648 manifest = malloc(size);
649 if (manifest == NULL) {
653 memset(manifest, '\0', size);
654 snprintf(manifest, size, "%s%s.xml", getUserManifestPath(uid), pkgid);
656 if (access(manifest, F_OK)) {
657 snprintf(manifest, size, "%s%s.xml", getUserManifestPath(uid), pkgid);
663 static void __metadata_parser_clear_dir_list(GList* dir_list)
666 __metadata_t* detail = NULL;
669 list = g_list_first(dir_list);
671 detail = (__metadata_t *)list->data;
679 list = g_list_next(list);
681 g_list_free(dir_list);
685 static void __category_parser_clear_dir_list(GList* dir_list)
688 __category_t* detail = NULL;
691 list = g_list_first(dir_list);
693 detail = (__category_t *)list->data;
700 list = g_list_next(list);
702 g_list_free(dir_list);
706 static int __run_tag_parser_prestep(void *lib_handle, xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid)
711 if (xmlTextReaderDepth(reader) != 1) {
712 _LOGE("Node depth is not 1");
716 if (xmlTextReaderNodeType(reader) != 1) {
717 _LOGE("Node type is not 1");
721 const xmlChar *value;
722 name = xmlTextReaderConstName(reader);
724 _LOGE("TEST TEST TES\n");
725 name = BAD_CAST "--";
728 value = xmlTextReaderConstValue(reader);
730 if (xmlStrlen(value) > 40) {
731 _LOGD(" %.40s...", value);
737 name = xmlTextReaderConstName(reader);
739 _LOGE("TEST TEST TES\n");
740 name = BAD_CAST "--";
743 xmlDocPtr docPtr = xmlTextReaderCurrentDoc(reader);
744 xmlDocPtr copyDocPtr = xmlCopyDoc(docPtr, 1);
745 if (copyDocPtr == NULL)
747 xmlNode *rootElement = xmlDocGetRootElement(copyDocPtr);
748 if (rootElement == NULL)
750 xmlNode *cur_node = xmlFirstElementChild(rootElement);
751 if (cur_node == NULL)
753 xmlNode *temp = xmlTextReaderExpand(reader);
756 xmlNode *next_node = NULL;
757 while(cur_node != NULL) {
758 if ( (strcmp(ASCII(temp->name), ASCII(cur_node->name)) == 0) &&
759 (temp->line == cur_node->line) ) {
763 next_node = xmlNextElementSibling(cur_node);
764 xmlUnlinkNode(cur_node);
765 xmlFreeNode(cur_node);
766 cur_node = next_node;
769 if (cur_node == NULL)
771 next_node = xmlNextElementSibling(cur_node);
773 cur_node->next = NULL;
774 next_node->prev = NULL;
775 xmlFreeNodeList(next_node);
776 xmlSetTreeDoc(cur_node, copyDocPtr);
778 xmlSetTreeDoc(cur_node, copyDocPtr);
781 ret = __ps_run_tag_parser(lib_handle, copyDocPtr, ASCII(name), action, pkgid);
787 static int __run_metadata_parser_prestep (manifest_x *mfx, char *md_key, ACTION_TYPE action)
791 char buffer[1024] = { 0, };
792 uiapplication_x *up = mfx->uiapplication;
793 metadata_x *md = NULL;
796 GList *md_list = NULL;
797 __metadata_t *md_detail = NULL;
799 md_tag = __get_tag_by_key(md_key);
800 if (md_tag == NULL) {
801 _LOGD("md_tag is NULL\n");
810 //get glist of metadata key and value combination
811 memset(buffer, 0x00, 1024);
812 snprintf(buffer, 1024, "%s/", md_key);
813 if ((md->key && md->value) && (strncmp(md->key, md_key, strlen(md_key)) == 0) && (strncmp(buffer, md->key, strlen(buffer)) == 0)) {
814 md_detail = (__metadata_t*) calloc(1, sizeof(__metadata_t));
815 if (md_detail == NULL) {
816 _LOGD("Memory allocation failed\n");
820 md_detail->key = (char*) calloc(1, sizeof(char)*(strlen(md->key)+2));
821 if (md_detail->key == NULL) {
822 _LOGD("Memory allocation failed\n");
826 snprintf(md_detail->key, (strlen(md->key)+1), "%s", md->key);
828 md_detail->value = (char*) calloc(1, sizeof(char)*(strlen(md->value)+2));
829 if (md_detail->value == NULL) {
830 _LOGD("Memory allocation failed\n");
831 free(md_detail->key);
835 snprintf(md_detail->value, (strlen(md->value)+1), "%s", md->value);
837 md_list = g_list_append(md_list, (gpointer)md_detail);
843 //send glist to parser when tags for metadata plugin parser exist.
845 ret = __ps_run_metadata_parser(md_list, md_tag, action, mfx->package, up->appid);
847 _LOGD("metadata_parser failed[%d] for tag[%s]\n", ret, md_tag);
850 _LOGD("metadata_parser success for tag[%s]\n", md_tag);
853 __metadata_parser_clear_dir_list(md_list);
861 __metadata_parser_clear_dir_list(md_list);
869 static int __run_category_parser_prestep (manifest_x *mfx, char *category_key, ACTION_TYPE action)
873 char buffer[1024] = { 0, };
874 uiapplication_x *up = mfx->uiapplication;
875 category_x *category = NULL;
876 char *category_tag = NULL;
878 GList *category_list = NULL;
879 __category_t *category_detail = NULL;
881 category_tag = __get_tag_by_key(category_key);
882 if (category_tag == NULL) {
883 _LOGD("md_tag is NULL\n");
889 category = up->category;
890 while (category != NULL)
892 //get glist of category key and value combination
893 memset(buffer, 0x00, 1024);
894 snprintf(buffer, 1024, "%s/", category_key);
895 if ((category->name) && (strncmp(category->name, category_key, strlen(category_key)) == 0)) {
896 category_detail = (__category_t*) calloc(1, sizeof(__category_t));
897 if (category_detail == NULL) {
898 _LOGD("Memory allocation failed\n");
902 category_detail->name = (char*) calloc(1, sizeof(char)*(strlen(category->name)+2));
903 if (category_detail->name == NULL) {
904 _LOGD("Memory allocation failed\n");
905 free(category_detail);
908 snprintf(category_detail->name, (strlen(category->name)+1), "%s", category->name);
910 category_list = g_list_append(category_list, (gpointer)category_detail);
913 category = category->next;
916 //send glist to parser when tags for metadata plugin parser exist.
918 ret = __ps_run_category_parser(category_list, category_tag, action, mfx->package, up->appid);
920 _LOGD("category_parser failed[%d] for tag[%s]\n", ret, category_tag);
922 _LOGD("category_parser success for tag[%s]\n", category_tag);
924 __category_parser_clear_dir_list(category_list);
925 category_list = NULL;
932 __category_parser_clear_dir_list(category_list);
940 static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid)
945 // _LOGD("__run_parser_prestep");
947 if (xmlTextReaderDepth(reader) != 1) {
948 _LOGE("Node depth is not 1");
952 if (xmlTextReaderNodeType(reader) != 1) {
953 _LOGE("Node type is not 1");
957 const xmlChar *value;
958 name = xmlTextReaderConstName(reader);
960 _LOGE("TEST TEST TES\n");
961 name = BAD_CAST "--";
964 value = xmlTextReaderConstValue(reader);
965 _LOGD("%d %d %s %d %d",
966 xmlTextReaderDepth(reader),
967 xmlTextReaderNodeType(reader),
969 xmlTextReaderIsEmptyElement(reader), xmlTextReaderHasValue(reader));
972 if (xmlStrlen(value) > 40) {
973 _LOGD(" %.40s...", value);
979 name = xmlTextReaderConstName(reader);
981 _LOGE("TEST TEST TES\n");
982 name = BAD_CAST "--";
985 xmlDocPtr docPtr = xmlTextReaderCurrentDoc(reader);
986 _LOGD("docPtr->URL %s\n", (char *)docPtr->URL);
987 xmlDocPtr copyDocPtr = xmlCopyDoc(docPtr, 1);
988 if (copyDocPtr == NULL)
990 xmlNode *rootElement = xmlDocGetRootElement(copyDocPtr);
991 if (rootElement == NULL)
993 xmlNode *cur_node = xmlFirstElementChild(rootElement);
994 if (cur_node == NULL)
996 xmlNode *temp = xmlTextReaderExpand(reader);
999 xmlNode *next_node = NULL;
1000 while(cur_node != NULL) {
1001 if ( (strcmp(ASCII(temp->name), ASCII(cur_node->name)) == 0) &&
1002 (temp->line == cur_node->line) ) {
1006 next_node = xmlNextElementSibling(cur_node);
1007 xmlUnlinkNode(cur_node);
1008 xmlFreeNode(cur_node);
1009 cur_node = next_node;
1012 if (cur_node == NULL)
1014 next_node = xmlNextElementSibling(cur_node);
1016 cur_node->next = NULL;
1017 next_node->prev = NULL;
1018 xmlFreeNodeList(next_node);
1019 xmlSetTreeDoc(cur_node, copyDocPtr);
1021 xmlSetTreeDoc(cur_node, copyDocPtr);
1027 _LOGD("node type: %d, name: %s children->name: %s last->name: %s\n"
1028 "parent->name: %s next->name: %s prev->name: %s\n",
1029 cur_node->type, cur_node->name,
1030 cur_node->children ? cur_node->children->name : "NULL",
1031 cur_node->last ? cur_node->last->name : "NULL",
1032 cur_node->parent ? cur_node->parent->name : "NULL",
1033 cur_node->next ? cur_node->next->name : "NULL",
1034 cur_node->prev ? cur_node->prev->name : "NULL");
1036 FILE *fp = fopen(tzplatform_mkpath(TZ_SYS_SHARE, "test.xml"), "a");
1037 xmlDocDump(fp, copyDocPtr);
1041 ret = __ps_run_parser(copyDocPtr, ASCII(name), action, pkgid);
1048 __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgid)
1053 switch (xmlTextReaderNodeType(reader)) {
1054 case XML_READER_TYPE_END_ELEMENT:
1056 // _LOGD("XML_READER_TYPE_END_ELEMENT");
1060 case XML_READER_TYPE_ELEMENT:
1062 // Elements without closing tag don't receive
1063 // XML_READER_TYPE_END_ELEMENT event.
1065 const xmlChar *elementName =
1066 xmlTextReaderLocalName(reader);
1067 if (elementName == NULL) {
1068 // _LOGD("elementName %s\n", (char *)elementName);
1072 const xmlChar *nameSpace =
1073 xmlTextReaderConstNamespaceUri(reader);
1075 // _LOGD("nameSpace %s\n", (char *)nameSpace);
1078 _LOGD("XML_READER_TYPE_ELEMENT %s, %s\n",
1079 elementName ? elementName : "NULL",
1080 nameSpace ? nameSpace : "NULL");
1083 _LOGD("__run_parser_prestep pkgid[%s]\n", pkgid);
1084 __run_parser_prestep(reader, action, pkgid);
1088 for (tag = tagv[0]; tag; tag = tagv[++i])
1089 if (strcmp(tag, ASCII(elementName)) == 0) {
1090 _LOGD("__run_parser_prestep tag[%s] pkgid[%s]\n", tag, pkgid);
1091 __run_parser_prestep(reader,
1099 case XML_READER_TYPE_TEXT:
1100 case XML_READER_TYPE_CDATA:
1102 const xmlChar *value = xmlTextReaderConstValue(reader);
1104 // _LOGD("value %s\n", value);
1107 const xmlChar *lang = xmlTextReaderConstXmlLang(reader);
1109 // _LOGD("lang\n", lang);
1112 /* _LOGD("XML_READER_TYPE_TEXT %s, %s\n",
1113 value ? value : "NULL", lang ? lang : "NULL");
1118 // _LOGD("Ignoring Node of Type: %d", xmlTextReaderNodeType(reader));
1124 __processTag(void *lib_handle, xmlTextReaderPtr reader, ACTION_TYPE action, char *tag, const char *pkgid)
1126 switch (xmlTextReaderNodeType(reader)) {
1127 case XML_READER_TYPE_END_ELEMENT:
1131 case XML_READER_TYPE_ELEMENT:
1133 // Elements without closing tag don't receive
1134 const xmlChar *elementName =
1135 xmlTextReaderLocalName(reader);
1136 if (elementName == NULL) {
1140 if (strcmp(tag, ASCII(elementName)) == 0) {
1141 _LOGD("find : tag[%s] ACTION_TYPE[%d] pkg[%s]\n", tag, action, pkgid);
1142 __run_tag_parser_prestep(lib_handle, reader, action, pkgid);
1153 static int __parser_send_tag(void *lib_handle, ACTION_TYPE action, PLUGIN_PROCESS_TYPE process, const char *pkgid)
1155 int (*plugin_install) (const char *);
1159 if (process == PLUGIN_PRE_PROCESS) {
1161 case ACTION_INSTALL:
1162 ac = "PKGMGR_PARSER_PLUGIN_PRE_INSTALL";
1164 case ACTION_UPGRADE:
1165 ac = "PKGMGR_PARSER_PLUGIN_PRE_UPGRADE";
1167 case ACTION_UNINSTALL:
1168 ac = "PKGMGR_PARSER_PLUGIN_PRE_UNINSTALL";
1173 } else if (process == PLUGIN_POST_PROCESS) {
1175 case ACTION_INSTALL:
1176 ac = "PKGMGR_PARSER_PLUGIN_POST_INSTALL";
1178 case ACTION_UPGRADE:
1179 ac = "PKGMGR_PARSER_PLUGIN_POST_UPGRADE";
1181 case ACTION_UNINSTALL:
1182 ac = "PKGMGR_PARSER_PLUGIN_POST_UNINSTALL";
1190 if ((plugin_install =
1191 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
1195 ret = plugin_install(pkgid);
1199 static void __plugin_send_tag(const char *tag, ACTION_TYPE action, PLUGIN_PROCESS_TYPE process, const char *pkgid)
1201 char *lib_path = NULL;
1202 void *lib_handle = NULL;
1203 int (*plugin_install) (const char *);
1207 if (process == PLUGIN_PRE_PROCESS) {
1209 case ACTION_INSTALL:
1210 ac = "PKGMGR_PARSER_PLUGIN_PRE_INSTALL";
1212 case ACTION_UPGRADE:
1213 ac = "PKGMGR_PARSER_PLUGIN_PRE_UPGRADE";
1215 case ACTION_UNINSTALL:
1216 ac = "PKGMGR_PARSER_PLUGIN_PRE_UNINSTALL";
1221 } else if (process == PLUGIN_POST_PROCESS) {
1223 case ACTION_INSTALL:
1224 ac = "PKGMGR_PARSER_PLUGIN_POST_INSTALL";
1226 case ACTION_UPGRADE:
1227 ac = "PKGMGR_PARSER_PLUGIN_POST_UPGRADE";
1229 case ACTION_UNINSTALL:
1230 ac = "PKGMGR_PARSER_PLUGIN_POST_UNINSTALL";
1238 lib_path = __get_parser_plugin(tag);
1243 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
1244 _LOGE("dlopen is failed lib_path[%s] for tag[%s]\n", lib_path, tag);
1247 if ((plugin_install =
1248 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
1249 // _LOGE("can not find symbol[%s] for tag[%s] \n", ac, tag);
1253 ret = plugin_install(pkgid);
1255 _LOGD("[PLUGIN_PROCESS_TYPE[%d] pkgid=%s, tag=%s plugin fail\n", process, pkgid, tag);
1257 _LOGD("[PLUGIN_PROCESS_TYPE[%d] pkgid=%s, tag=%s plugin success\n", process, pkgid, tag);
1263 dlclose(lib_handle);
1267 __plugin_process_tag(char *const tag_list[], ACTION_TYPE action, PLUGIN_PROCESS_TYPE process, const char *pkgid)
1272 for (tag = tag_list[0]; tag; tag = tag_list[++i])
1273 __plugin_send_tag(tag, action, process, pkgid);
1278 __plugin_save_tag(xmlTextReaderPtr reader, char *const tagv[], char *tag_list[])
1282 static int pre_cnt=0;
1284 switch (xmlTextReaderNodeType(reader)) {
1285 case XML_READER_TYPE_ELEMENT:
1287 const xmlChar *elementName = xmlTextReaderLocalName(reader);
1288 if (elementName == NULL) {
1292 for (tag = tag_list[0]; tag; tag = tag_list[++i])
1293 if (strcmp(ASCII(elementName), tag) == 0) {
1297 for (tag = tagv[0]; tag; tag = tagv[++i])
1298 if (strcmp(tag, ASCII(elementName)) == 0) {
1299 tag_list[pre_cnt++] = tag;
1305 // _LOGD("Ignoring Node of Type: %d", xmlTextReaderNodeType(reader));
1311 __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid)
1313 xmlTextReaderPtr reader;
1316 __plugin_process_tag(tagv, action, PLUGIN_PRE_PROCESS, pkgid);
1318 docPtr = xmlReadFile(filename, NULL, 0);
1319 reader = xmlReaderWalker(docPtr);
1320 if (reader != NULL) {
1321 ret = xmlTextReaderRead(reader);
1323 __processNode(reader, action, tagv, pkgid);
1324 ret = xmlTextReaderRead(reader);
1326 xmlFreeTextReader(reader);
1329 _LOGD("%s : failed to parse", filename);
1332 _LOGD("Unable to open %s", filename);
1335 __plugin_process_tag(tagv, action, PLUGIN_POST_PROCESS, pkgid);
1338 static int __next_child_element(xmlTextReaderPtr reader, int depth)
1340 int ret = xmlTextReaderRead(reader);
1341 int cur = xmlTextReaderDepth(reader);
1344 switch (xmlTextReaderNodeType(reader)) {
1345 case XML_READER_TYPE_ELEMENT:
1346 if (cur == depth + 1)
1349 case XML_READER_TYPE_TEXT:
1350 /*text is handled by each function separately*/
1351 if (cur == depth + 1)
1354 case XML_READER_TYPE_END_ELEMENT:
1363 ret = xmlTextReaderRead(reader);
1364 cur = xmlTextReaderDepth(reader);
1369 static bool __check_action_fota(char *const tagv[])
1372 char delims[] = "=";
1373 char *ret_result = NULL;
1380 for (tag = strdup(tagv[0]); tag != NULL; ) {
1381 ret_result = strtok(tag, delims);
1383 /*check tag : fota is true */
1384 if (strcmp(ret_result, "fota") == 0) {
1385 ret_result = strtok(NULL, delims);
1386 if (strcmp(ret_result, "true") == 0) {
1390 _LOGD("tag process [%s]is not defined\n", ret_result);
1394 /*check next value*/
1395 if (tagv[++i] != NULL)
1396 tag = strdup(tagv[i]);
1398 _LOGD("tag process success...%d\n" , ret);
1406 static void __ps_free_category(category_x *category)
1408 if (category == NULL)
1410 if (category->name) {
1411 free((void *)category->name);
1412 category->name = NULL;
1414 free((void*)category);
1418 static void __ps_free_privilege(privilege_x *privilege)
1420 if (privilege == NULL)
1422 if (privilege->text) {
1423 free((void *)privilege->text);
1424 privilege->text = NULL;
1426 free((void*)privilege);
1430 static void __ps_free_privileges(privileges_x *privileges)
1432 if (privileges == NULL)
1435 if (privileges->privilege) {
1436 privilege_x *privilege = privileges->privilege;
1437 privilege_x *tmp = NULL;
1438 while(privilege != NULL) {
1439 tmp = privilege->next;
1440 __ps_free_privilege(privilege);
1444 free((void*)privileges);
1448 static void __ps_free_metadata(metadata_x *metadata)
1450 if (metadata == NULL)
1452 if (metadata->key) {
1453 free((void *)metadata->key);
1454 metadata->key = NULL;
1456 if (metadata->value) {
1457 free((void *)metadata->value);
1458 metadata->value = NULL;
1460 free((void*)metadata);
1464 static void __ps_free_permission(permission_x *permission)
1466 if (permission == NULL)
1468 if (permission->type) {
1469 free((void *)permission->type);
1470 permission->type = NULL;
1472 if (permission->value) {
1473 free((void *)permission->value);
1474 permission->value = NULL;
1476 free((void*)permission);
1480 static void __ps_free_icon(icon_x *icon)
1485 free((void *)icon->text);
1489 free((void *)icon->lang);
1493 free((void *)icon->name);
1496 if (icon->section) {
1497 free((void *)icon->section);
1498 icon->section = NULL;
1501 free((void *)icon->size);
1504 if (icon->resolution) {
1505 free((void *)icon->resolution);
1506 icon->resolution = NULL;
1512 static void __ps_free_image(image_x *image)
1517 free((void *)image->text);
1521 free((void *)image->lang);
1525 free((void *)image->name);
1528 if (image->section) {
1529 free((void *)image->section);
1530 image->section = NULL;
1536 static void __ps_free_operation(operation_x *operation)
1538 if (operation == NULL)
1540 if (operation->text) {
1541 free((void *)operation->text);
1542 operation->text = NULL;
1544 free((void*)operation);
1548 static void __ps_free_uri(uri_x *uri)
1553 free((void *)uri->text);
1560 static void __ps_free_mime(mime_x *mime)
1565 free((void *)mime->text);
1572 static void __ps_free_subapp(subapp_x *subapp)
1577 free((void *)subapp->text);
1578 subapp->text = NULL;
1580 free((void*)subapp);
1584 static void __ps_free_condition(condition_x *condition)
1586 if (condition == NULL)
1588 if (condition->text) {
1589 free((void *)condition->text);
1590 condition->text = NULL;
1592 if (condition->name) {
1593 free((void *)condition->name);
1594 condition->name = NULL;
1596 free((void*)condition);
1600 static void __ps_free_notification(notification_x *notification)
1602 if (notification == NULL)
1604 if (notification->text) {
1605 free((void *)notification->text);
1606 notification->text = NULL;
1608 if (notification->name) {
1609 free((void *)notification->name);
1610 notification->name = NULL;
1612 free((void*)notification);
1613 notification = NULL;
1616 static void __ps_free_compatibility(compatibility_x *compatibility)
1618 if (compatibility == NULL)
1620 if (compatibility->text) {
1621 free((void *)compatibility->text);
1622 compatibility->text = NULL;
1624 if (compatibility->name) {
1625 free((void *)compatibility->name);
1626 compatibility->name = NULL;
1628 free((void*)compatibility);
1629 compatibility = NULL;
1632 static void __ps_free_resolution(resolution_x *resolution)
1634 if (resolution == NULL)
1636 if (resolution->mimetype) {
1637 free((void *)resolution->mimetype);
1638 resolution->mimetype = NULL;
1640 if (resolution->urischeme) {
1641 free((void *)resolution->urischeme);
1642 resolution->urischeme = NULL;
1644 free((void*)resolution);
1648 static void __ps_free_capability(capability_x *capability)
1650 if (capability == NULL)
1652 if (capability->operationid) {
1653 free((void *)capability->operationid);
1654 capability->operationid = NULL;
1657 if (capability->resolution) {
1658 resolution_x *resolution = capability->resolution;
1659 resolution_x *tmp = NULL;
1660 while(resolution != NULL) {
1661 tmp = resolution->next;
1662 __ps_free_resolution(resolution);
1666 free((void*)capability);
1670 static void __ps_free_allowed(allowed_x *allowed)
1672 if (allowed == NULL)
1674 if (allowed->name) {
1675 free((void *)allowed->name);
1676 allowed->name = NULL;
1678 if (allowed->text) {
1679 free((void *)allowed->text);
1680 allowed->text = NULL;
1682 free((void*)allowed);
1686 static void __ps_free_request(request_x *request)
1688 if (request == NULL)
1690 if (request->text) {
1691 free((void *)request->text);
1692 request->text = NULL;
1694 free((void*)request);
1698 static void __ps_free_datacontrol(datacontrol_x *datacontrol)
1700 if (datacontrol == NULL)
1702 if (datacontrol->providerid) {
1703 free((void *)datacontrol->providerid);
1704 datacontrol->providerid = NULL;
1706 if (datacontrol->access) {
1707 free((void *)datacontrol->access);
1708 datacontrol->access = NULL;
1710 if (datacontrol->type) {
1711 free((void *)datacontrol->type);
1712 datacontrol->type = NULL;
1714 free((void*)datacontrol);
1718 static void __ps_free_launchconditions(launchconditions_x *launchconditions)
1720 if (launchconditions == NULL)
1722 if (launchconditions->text) {
1723 free((void *)launchconditions->text);
1724 launchconditions->text = NULL;
1727 if (launchconditions->condition) {
1728 condition_x *condition = launchconditions->condition;
1729 condition_x *tmp = NULL;
1730 while(condition != NULL) {
1731 tmp = condition->next;
1732 __ps_free_condition(condition);
1736 free((void*)launchconditions);
1737 launchconditions = NULL;
1740 static void __ps_free_appcontrol(appcontrol_x *appcontrol)
1742 if (appcontrol == NULL)
1745 if (appcontrol->operation)
1746 free(appcontrol->operation);
1748 if (appcontrol->uri)
1749 free(appcontrol->uri);
1751 if (appcontrol->mime)
1752 free(appcontrol->mime);
1753 free((void*)appcontrol);
1757 static void __ps_free_appsvc(appsvc_x *appsvc)
1762 free((void *)appsvc->text);
1763 appsvc->text = NULL;
1766 if (appsvc->operation) {
1767 operation_x *operation = appsvc->operation;
1768 operation_x *tmp = NULL;
1769 while(operation != NULL) {
1770 tmp = operation->next;
1771 __ps_free_operation(operation);
1777 uri_x *uri = appsvc->uri;
1779 while(uri != NULL) {
1787 mime_x *mime = appsvc->mime;
1789 while(mime != NULL) {
1791 __ps_free_mime(mime);
1796 if (appsvc->subapp) {
1797 subapp_x *subapp = appsvc->subapp;
1798 subapp_x *tmp = NULL;
1799 while(subapp != NULL) {
1801 __ps_free_subapp(subapp);
1805 free((void*)appsvc);
1809 static void __ps_free_deviceprofile(deviceprofile_x *deviceprofile)
1814 static void __ps_free_define(define_x *define)
1819 free((void *)define->path);
1820 define->path = NULL;
1823 if (define->request) {
1824 request_x *request = define->request;
1825 request_x *tmp = NULL;
1826 while(request != NULL) {
1827 tmp = request->next;
1828 __ps_free_request(request);
1833 if (define->allowed) {
1834 allowed_x *allowed = define->allowed;
1835 allowed_x *tmp = NULL;
1836 while(allowed != NULL) {
1837 tmp = allowed->next;
1838 __ps_free_allowed(allowed);
1842 free((void*)define);
1846 static void __ps_free_datashare(datashare_x *datashare)
1848 if (datashare == NULL)
1851 if (datashare->define) {
1852 define_x *define = datashare->define;
1853 define_x *tmp = NULL;
1854 while(define != NULL) {
1856 __ps_free_define(define);
1861 if (datashare->request) {
1862 request_x *request = datashare->request;
1863 request_x *tmp = NULL;
1864 while(request != NULL) {
1865 tmp = request->next;
1866 __ps_free_request(request);
1870 free((void*)datashare);
1874 static void __ps_free_label(label_x *label)
1879 free((void *)label->name);
1883 free((void *)label->text);
1887 free((void *)label->lang);
1894 static void __ps_free_author(author_x *author)
1898 if (author->email) {
1899 free((void *)author->email);
1900 author->email = NULL;
1903 free((void *)author->text);
1904 author->text = NULL;
1907 free((void *)author->href);
1908 author->href = NULL;
1911 free((void *)author->lang);
1912 author->lang = NULL;
1914 free((void*)author);
1918 static void __ps_free_description(description_x *description)
1920 if (description == NULL)
1922 if (description->name) {
1923 free((void *)description->name);
1924 description->name = NULL;
1926 if (description->text) {
1927 free((void *)description->text);
1928 description->text = NULL;
1930 if (description->lang) {
1931 free((void *)description->lang);
1932 description->lang = NULL;
1934 free((void*)description);
1938 static void __ps_free_license(license_x *license)
1940 if (license == NULL)
1942 if (license->text) {
1943 free((void *)license->text);
1944 license->text = NULL;
1946 if (license->lang) {
1947 free((void *)license->lang);
1948 license->lang = NULL;
1950 free((void*)license);
1954 static void __ps_free_uiapplication(uiapplication_x *uiapplication)
1956 if (uiapplication == NULL)
1958 if (uiapplication->exec) {
1959 free((void *)uiapplication->exec);
1960 uiapplication->exec = NULL;
1962 if (uiapplication->appid) {
1963 free((void *)uiapplication->appid);
1964 uiapplication->appid = NULL;
1966 if (uiapplication->nodisplay) {
1967 free((void *)uiapplication->nodisplay);
1968 uiapplication->nodisplay = NULL;
1970 if (uiapplication->multiple) {
1971 free((void *)uiapplication->multiple);
1972 uiapplication->multiple = NULL;
1974 if (uiapplication->type) {
1975 free((void *)uiapplication->type);
1976 uiapplication->type = NULL;
1978 if (uiapplication->categories) {
1979 free((void *)uiapplication->categories);
1980 uiapplication->categories = NULL;
1982 if (uiapplication->extraid) {
1983 free((void *)uiapplication->extraid);
1984 uiapplication->extraid = NULL;
1986 if (uiapplication->taskmanage) {
1987 free((void *)uiapplication->taskmanage);
1988 uiapplication->taskmanage = NULL;
1990 if (uiapplication->enabled) {
1991 free((void *)uiapplication->enabled);
1992 uiapplication->enabled = NULL;
1994 if (uiapplication->hwacceleration) {
1995 free((void *)uiapplication->hwacceleration);
1996 uiapplication->hwacceleration = NULL;
1998 if (uiapplication->screenreader) {
1999 free((void *)uiapplication->screenreader);
2000 uiapplication->screenreader = NULL;
2002 if (uiapplication->mainapp) {
2003 free((void *)uiapplication->mainapp);
2004 uiapplication->mainapp = NULL;
2006 if (uiapplication->recentimage) {
2007 free((void *)uiapplication->recentimage);
2008 uiapplication->recentimage = NULL;
2010 if (uiapplication->package) {
2011 free((void *)uiapplication->package);
2012 uiapplication->package = NULL;
2014 if (uiapplication->launchcondition) {
2015 free((void *)uiapplication->launchcondition);
2016 uiapplication->launchcondition = NULL;
2019 if (uiapplication->label) {
2020 label_x *label = uiapplication->label;
2021 label_x *tmp = NULL;
2022 while(label != NULL) {
2024 __ps_free_label(label);
2029 if (uiapplication->icon) {
2030 icon_x *icon = uiapplication->icon;
2032 while(icon != NULL) {
2034 __ps_free_icon(icon);
2039 if (uiapplication->image) {
2040 image_x *image = uiapplication->image;
2041 image_x *tmp = NULL;
2042 while(image != NULL) {
2044 __ps_free_image(image);
2049 if (uiapplication->appcontrol) {
2050 appcontrol_x *appcontrol = uiapplication->appcontrol;
2051 appcontrol_x *tmp = NULL;
2052 while(appcontrol != NULL) {
2053 tmp = appcontrol->next;
2054 __ps_free_appcontrol(appcontrol);
2058 /*Free LaunchConditions*/
2059 if (uiapplication->launchconditions) {
2060 launchconditions_x *launchconditions = uiapplication->launchconditions;
2061 launchconditions_x *tmp = NULL;
2062 while(launchconditions != NULL) {
2063 tmp = launchconditions->next;
2064 __ps_free_launchconditions(launchconditions);
2065 launchconditions = tmp;
2068 /*Free Notification*/
2069 if (uiapplication->notification) {
2070 notification_x *notification = uiapplication->notification;
2071 notification_x *tmp = NULL;
2072 while(notification != NULL) {
2073 tmp = notification->next;
2074 __ps_free_notification(notification);
2079 if (uiapplication->datashare) {
2080 datashare_x *datashare = uiapplication->datashare;
2081 datashare_x *tmp = NULL;
2082 while(datashare != NULL) {
2083 tmp = datashare->next;
2084 __ps_free_datashare(datashare);
2089 if (uiapplication->appsvc) {
2090 appsvc_x *appsvc = uiapplication->appsvc;
2091 appsvc_x *tmp = NULL;
2092 while(appsvc != NULL) {
2094 __ps_free_appsvc(appsvc);
2099 if (uiapplication->category) {
2100 category_x *category = uiapplication->category;
2101 category_x *tmp = NULL;
2102 while(category != NULL) {
2103 tmp = category->next;
2104 __ps_free_category(category);
2109 if (uiapplication->metadata) {
2110 metadata_x *metadata = uiapplication->metadata;
2111 metadata_x *tmp = NULL;
2112 while(metadata != NULL) {
2113 tmp = metadata->next;
2114 __ps_free_metadata(metadata);
2119 if (uiapplication->permission) {
2120 permission_x *permission = uiapplication->permission;
2121 permission_x *tmp = NULL;
2122 while(permission != NULL) {
2123 tmp = permission->next;
2124 __ps_free_permission(permission);
2128 /*Free DataControl*/
2129 if (uiapplication->datacontrol) {
2130 datacontrol_x *datacontrol = uiapplication->datacontrol;
2131 datacontrol_x *tmp = NULL;
2132 while(datacontrol != NULL) {
2133 tmp = datacontrol->next;
2134 __ps_free_datacontrol(datacontrol);
2138 /* _PRODUCT_LAUNCHING_ENHANCED_ START */
2139 if (uiapplication->indicatordisplay) {
2140 free((void *)uiapplication->indicatordisplay);
2141 uiapplication->indicatordisplay = NULL;
2143 if (uiapplication->portraitimg) {
2144 free((void *)uiapplication->portraitimg);
2145 uiapplication->portraitimg = NULL;
2147 if (uiapplication->landscapeimg) {
2148 free((void *)uiapplication->landscapeimg);
2149 uiapplication->landscapeimg = NULL;
2151 /* _PRODUCT_LAUNCHING_ENHANCED_ END */
2152 if (uiapplication->guestmode_visibility) {
2153 free((void *)uiapplication->guestmode_visibility);
2154 uiapplication->guestmode_visibility = NULL;
2156 if (uiapplication->app_component) {
2157 free((void *)uiapplication->app_component);
2158 uiapplication->app_component = NULL;
2160 if (uiapplication->permission_type) {
2161 free((void *)uiapplication->permission_type);
2162 uiapplication->permission_type = NULL;
2164 if (uiapplication->component_type) {
2165 free((void *)uiapplication->component_type);
2166 uiapplication->component_type = NULL;
2168 if (uiapplication->preload) {
2169 free((void *)uiapplication->preload);
2170 uiapplication->preload = NULL;
2172 if (uiapplication->submode) {
2173 free((void *)uiapplication->submode);
2174 uiapplication->submode = NULL;
2176 if (uiapplication->submode_mainid) {
2177 free((void *)uiapplication->submode_mainid);
2178 uiapplication->submode_mainid = NULL;
2181 free((void*)uiapplication);
2182 uiapplication = NULL;
2185 static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication)
2187 if (serviceapplication == NULL)
2189 if (serviceapplication->exec) {
2190 free((void *)serviceapplication->exec);
2191 serviceapplication->exec = NULL;
2193 if (serviceapplication->appid) {
2194 free((void *)serviceapplication->appid);
2195 serviceapplication->appid = NULL;
2197 if (serviceapplication->onboot) {
2198 free((void *)serviceapplication->onboot);
2199 serviceapplication->onboot = NULL;
2201 if (serviceapplication->autorestart) {
2202 free((void *)serviceapplication->autorestart);
2203 serviceapplication->autorestart = NULL;
2205 if (serviceapplication->type) {
2206 free((void *)serviceapplication->type);
2207 serviceapplication->type = NULL;
2209 if (serviceapplication->enabled) {
2210 free((void *)serviceapplication->enabled);
2211 serviceapplication->enabled = NULL;
2213 if (serviceapplication->package) {
2214 free((void *)serviceapplication->package);
2215 serviceapplication->package = NULL;
2217 if (serviceapplication->permission_type) {
2218 free((void *)serviceapplication->permission_type);
2219 serviceapplication->permission_type = NULL;
2222 if (serviceapplication->label) {
2223 label_x *label = serviceapplication->label;
2224 label_x *tmp = NULL;
2225 while(label != NULL) {
2227 __ps_free_label(label);
2232 if (serviceapplication->icon) {
2233 icon_x *icon = serviceapplication->icon;
2235 while(icon != NULL) {
2237 __ps_free_icon(icon);
2242 if (serviceapplication->appcontrol) {
2243 appcontrol_x *appcontrol = serviceapplication->appcontrol;
2244 appcontrol_x *tmp = NULL;
2245 while(appcontrol != NULL) {
2246 tmp = appcontrol->next;
2247 __ps_free_appcontrol(appcontrol);
2251 /*Free DataControl*/
2252 if (serviceapplication->datacontrol) {
2253 datacontrol_x *datacontrol = serviceapplication->datacontrol;
2254 datacontrol_x *tmp = NULL;
2255 while(datacontrol != NULL) {
2256 tmp = datacontrol->next;
2257 __ps_free_datacontrol(datacontrol);
2261 /*Free LaunchConditions*/
2262 if (serviceapplication->launchconditions) {
2263 launchconditions_x *launchconditions = serviceapplication->launchconditions;
2264 launchconditions_x *tmp = NULL;
2265 while(launchconditions != NULL) {
2266 tmp = launchconditions->next;
2267 __ps_free_launchconditions(launchconditions);
2268 launchconditions = tmp;
2271 /*Free Notification*/
2272 if (serviceapplication->notification) {
2273 notification_x *notification = serviceapplication->notification;
2274 notification_x *tmp = NULL;
2275 while(notification != NULL) {
2276 tmp = notification->next;
2277 __ps_free_notification(notification);
2282 if (serviceapplication->datashare) {
2283 datashare_x *datashare = serviceapplication->datashare;
2284 datashare_x *tmp = NULL;
2285 while(datashare != NULL) {
2286 tmp = datashare->next;
2287 __ps_free_datashare(datashare);
2292 if (serviceapplication->appsvc) {
2293 appsvc_x *appsvc = serviceapplication->appsvc;
2294 appsvc_x *tmp = NULL;
2295 while(appsvc != NULL) {
2297 __ps_free_appsvc(appsvc);
2302 if (serviceapplication->category) {
2303 category_x *category = serviceapplication->category;
2304 category_x *tmp = NULL;
2305 while(category != NULL) {
2306 tmp = category->next;
2307 __ps_free_category(category);
2312 if (serviceapplication->metadata) {
2313 metadata_x *metadata = serviceapplication->metadata;
2314 metadata_x *tmp = NULL;
2315 while(metadata != NULL) {
2316 tmp = metadata->next;
2317 __ps_free_metadata(metadata);
2322 if (serviceapplication->permission) {
2323 permission_x *permission = serviceapplication->permission;
2324 permission_x *tmp = NULL;
2325 while(permission != NULL) {
2326 tmp = permission->next;
2327 __ps_free_permission(permission);
2331 free((void*)serviceapplication);
2332 serviceapplication = NULL;
2335 static void __ps_free_font(font_x *font)
2340 free((void *)font->name);
2344 free((void *)font->text);
2351 static void __ps_free_theme(theme_x *theme)
2356 free((void *)theme->name);
2360 free((void *)theme->text);
2367 static void __ps_free_daemon(daemon_x *daemon)
2372 free((void *)daemon->name);
2373 daemon->name = NULL;
2376 free((void *)daemon->text);
2377 daemon->text = NULL;
2379 free((void*)daemon);
2383 static void __ps_free_ime(ime_x *ime)
2388 free((void *)ime->name);
2392 free((void *)ime->text);
2399 int __ps_process_tag_parser(manifest_x *mfx, const char *filename, ACTION_TYPE action)
2401 xmlTextReaderPtr reader;
2405 void *lib_handle = NULL;
2406 char tag[PKG_STRING_LEN_MAX] = { 0 };
2408 fp = fopen(TAG_PARSER_LIST, "r");
2409 retvm_if(fp == NULL, PMINFO_R_ERROR, "no preload list");
2411 while (fgets(tag, sizeof(tag), fp) != NULL) {
2414 lib_handle = __open_lib_handle(tag);
2415 if (lib_handle == NULL)
2418 ret = __parser_send_tag(lib_handle, action, PLUGIN_PRE_PROCESS, mfx->package);
2419 _LOGD("PLUGIN_PRE_PROCESS[%s, %s] ACTION_TYPE[%d] result[%d]\n", mfx->package, tag, action, ret);
2421 docPtr = xmlReadFile(filename, NULL, 0);
2422 reader = xmlReaderWalker(docPtr);
2423 if (reader != NULL) {
2424 ret = xmlTextReaderRead(reader);
2426 __processTag(lib_handle, reader, action, tag, mfx->package);
2427 ret = xmlTextReaderRead(reader);
2429 xmlFreeTextReader(reader);
2432 _LOGD("%s : failed to parse", filename);
2435 _LOGD("Unable to open %s", filename);
2438 ret = __parser_send_tag(lib_handle, action, PLUGIN_POST_PROCESS, mfx->package);
2439 _LOGD("PLUGIN_POST_PROCESS[%s, %s] ACTION_TYPE[%d] result[%d]\n", mfx->package, tag, action, ret);
2441 __close_lib_handle(lib_handle);
2443 memset(tag, 0x00, sizeof(tag));
2452 int __ps_process_metadata_parser(manifest_x *mfx, ACTION_TYPE action)
2454 fprintf(stdout,"__ps_process_metadata_parser\n");
2457 char md_key[PKG_STRING_LEN_MAX] = { 0 };
2459 fp = fopen(METADATA_PARSER_LIST, "r");
2461 _LOGD("no preload list\n");
2465 while (fgets(md_key, sizeof(md_key), fp) != NULL) {
2467 ret = __run_metadata_parser_prestep(mfx, md_key, action);
2469 memset(md_key, 0x00, sizeof(md_key));
2478 int __ps_process_category_parser(manifest_x *mfx, ACTION_TYPE action)
2482 char category_key[PKG_STRING_LEN_MAX] = { 0 };
2484 fp = fopen(CATEGORY_PARSER_LIST, "r");
2486 _LOGD("no category parser list\n");
2490 while (fgets(category_key, sizeof(category_key), fp) != NULL) {
2491 __str_trim(category_key);
2492 ret = __run_category_parser_prestep(mfx, category_key, action);
2494 memset(category_key, 0x00, sizeof(category_key));
2503 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed)
2505 xmlTextReaderRead(reader);
2506 if (xmlTextReaderValue(reader))
2507 allowed->text = ASCII(xmlTextReaderValue(reader));
2511 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation)
2513 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2514 operation->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2515 /* Text does not exist. Only attribute exists
2516 xmlTextReaderRead(reader);
2517 if (xmlTextReaderValue(reader))
2518 operation->text = ASCII(xmlTextReaderValue(reader));
2523 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri)
2525 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2526 uri->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2527 /* Text does not exist. Only attribute exists
2528 xmlTextReaderRead(reader);
2529 if (xmlTextReaderValue(reader))
2530 uri->text = ASCII(xmlTextReaderValue(reader));
2535 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime)
2537 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2538 mime->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2539 /* Text does not exist. Only attribute exists
2540 xmlTextReaderRead(reader);
2541 if (xmlTextReaderValue(reader))
2542 mime->text = ASCII(xmlTextReaderValue(reader));
2547 static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp)
2549 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2550 subapp->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2551 /* Text does not exist. Only attribute exists
2552 xmlTextReaderRead(reader);
2553 if (xmlTextReaderValue(reader))
2554 mime->text = ASCII(xmlTextReaderValue(reader));
2559 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition)
2561 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2562 condition->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2563 xmlTextReaderRead(reader);
2564 if (xmlTextReaderValue(reader))
2565 condition->text = ASCII(xmlTextReaderValue(reader));
2569 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notification)
2571 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2572 notification->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2573 xmlTextReaderRead(reader);
2574 if (xmlTextReaderValue(reader))
2575 notification->text = ASCII(xmlTextReaderValue(reader));
2579 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category)
2581 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2582 category->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2586 static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege)
2588 xmlTextReaderRead(reader);
2589 if (xmlTextReaderValue(reader)) {
2590 privilege->text = ASCII(xmlTextReaderValue(reader));
2595 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata)
2597 if (xmlTextReaderGetAttribute(reader, XMLCHAR("key")))
2598 metadata->key = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("key")));
2599 if (xmlTextReaderGetAttribute(reader, XMLCHAR("value")))
2600 metadata->value = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("value")));
2604 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission)
2606 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
2607 permission->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
2609 xmlTextReaderRead(reader);
2610 if (xmlTextReaderValue(reader))
2611 permission->value = ASCII(xmlTextReaderValue(reader));
2615 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility)
2617 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2618 compatibility->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2619 xmlTextReaderRead(reader);
2620 if (xmlTextReaderValue(reader))
2621 compatibility->text = ASCII(xmlTextReaderValue(reader));
2625 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution)
2627 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")))
2628 resolution->mimetype = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")));
2629 if (xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")))
2630 resolution->urischeme = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")));
2634 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request)
2636 xmlTextReaderRead(reader);
2637 if (xmlTextReaderValue(reader))
2638 request->text = ASCII(xmlTextReaderValue(reader));
2642 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define)
2644 const xmlChar *node;
2647 allowed_x *tmp1 = NULL;
2648 request_x *tmp2 = NULL;
2650 if (xmlTextReaderGetAttribute(reader, XMLCHAR("path")))
2651 define->path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("path")));
2653 depth = xmlTextReaderDepth(reader);
2654 while ((ret = __next_child_element(reader, depth))) {
2655 node = xmlTextReaderConstName(reader);
2657 _LOGD("xmlTextReaderConstName value is NULL\n");
2661 if (!strcmp(ASCII(node), "allowed")) {
2662 allowed_x *allowed= malloc(sizeof(allowed_x));
2663 if (allowed == NULL) {
2664 _LOGD("Malloc Failed\n");
2667 memset(allowed, '\0', sizeof(allowed_x));
2668 LISTADD(define->allowed, allowed);
2669 ret = __ps_process_allowed(reader, allowed);
2670 } else if (!strcmp(ASCII(node), "request")) {
2671 request_x *request = malloc(sizeof(request_x));
2672 if (request == NULL) {
2673 _LOGD("Malloc Failed\n");
2676 memset(request, '\0', sizeof(request_x));
2677 LISTADD(define->request, request);
2678 ret = __ps_process_request(reader, request);
2682 _LOGD("Processing define failed\n");
2686 if (define->allowed) {
2687 LISTHEAD(define->allowed, tmp1);
2688 define->allowed = tmp1;
2690 if (define->request) {
2691 LISTHEAD(define->request, tmp2);
2692 define->request = tmp2;
2697 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol)
2699 const xmlChar *node;
2703 depth = xmlTextReaderDepth(reader);
2704 while ((ret = __next_child_element(reader, depth))) {
2705 node = xmlTextReaderConstName(reader);
2707 _LOGD("xmlTextReaderConstName value is NULL\n");
2711 if (!strcmp(ASCII(node), "operation")) {
2712 appcontrol->operation = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2713 _LOGD("operation processing\n");
2714 } else if (!strcmp(ASCII(node), "uri")) {
2715 appcontrol->uri = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2716 _LOGD("uri processing\n");
2717 } else if (!strcmp(ASCII(node), "mime")) {
2718 appcontrol->mime = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2719 _LOGD("mime processing\n");
2723 _LOGD("Processing appcontrol failed\n");
2731 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc)
2733 const xmlChar *node;
2736 operation_x *tmp1 = NULL;
2738 mime_x *tmp3 = NULL;
2739 subapp_x *tmp4 = NULL;
2741 depth = xmlTextReaderDepth(reader);
2742 while ((ret = __next_child_element(reader, depth))) {
2743 node = xmlTextReaderConstName(reader);
2745 _LOGD("xmlTextReaderConstName value is NULL\n");
2749 if (!strcmp(ASCII(node), "operation")) {
2750 operation_x *operation = malloc(sizeof(operation_x));
2751 if (operation == NULL) {
2752 _LOGD("Malloc Failed\n");
2755 memset(operation, '\0', sizeof(operation_x));
2756 LISTADD(appsvc->operation, operation);
2757 ret = __ps_process_operation(reader, operation);
2758 _LOGD("operation processing\n");
2759 } else if (!strcmp(ASCII(node), "uri")) {
2760 uri_x *uri= malloc(sizeof(uri_x));
2762 _LOGD("Malloc Failed\n");
2765 memset(uri, '\0', sizeof(uri_x));
2766 LISTADD(appsvc->uri, uri);
2767 ret = __ps_process_uri(reader, uri);
2768 _LOGD("uri processing\n");
2769 } else if (!strcmp(ASCII(node), "mime")) {
2770 mime_x *mime = malloc(sizeof(mime_x));
2772 _LOGD("Malloc Failed\n");
2775 memset(mime, '\0', sizeof(mime_x));
2776 LISTADD(appsvc->mime, mime);
2777 ret = __ps_process_mime(reader, mime);
2778 _LOGD("mime processing\n");
2779 } else if (!strcmp(ASCII(node), "subapp")) {
2780 subapp_x *subapp = malloc(sizeof(subapp_x));
2781 if (subapp == NULL) {
2782 _LOGD("Malloc Failed\n");
2785 memset(subapp, '\0', sizeof(subapp_x));
2786 LISTADD(appsvc->subapp, subapp);
2787 ret = __ps_process_subapp(reader, subapp);
2788 _LOGD("subapp processing\n");
2792 _LOGD("Processing appsvc failed\n");
2796 if (appsvc->operation) {
2797 LISTHEAD(appsvc->operation, tmp1);
2798 appsvc->operation = tmp1;
2801 LISTHEAD(appsvc->uri, tmp2);
2805 LISTHEAD(appsvc->mime, tmp3);
2806 appsvc->mime = tmp3;
2808 if (appsvc->subapp) {
2809 LISTHEAD(appsvc->subapp, tmp4);
2810 appsvc->subapp = tmp4;
2813 xmlTextReaderRead(reader);
2814 if (xmlTextReaderValue(reader))
2815 appsvc->text = ASCII(xmlTextReaderValue(reader));
2821 static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privileges)
2823 const xmlChar *node;
2826 privilege_x *tmp1 = NULL;
2828 depth = xmlTextReaderDepth(reader);
2829 while ((ret = __next_child_element(reader, depth))) {
2830 node = xmlTextReaderConstName(reader);
2832 _LOGD("xmlTextReaderConstName value is NULL\n");
2836 if (strcmp(ASCII(node), "privilege") == 0) {
2837 privilege_x *privilege = malloc(sizeof(privilege_x));
2838 if (privilege == NULL) {
2839 _LOGD("Malloc Failed\n");
2842 memset(privilege, '\0', sizeof(privilege_x));
2843 LISTADD(privileges->privilege, privilege);
2844 ret = __ps_process_privilege(reader, privilege);
2848 _LOGD("Processing privileges failed\n");
2852 if (privileges->privilege) {
2853 LISTHEAD(privileges->privilege, tmp1);
2854 privileges->privilege = tmp1;
2859 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions)
2861 const xmlChar *node;
2864 condition_x *tmp1 = NULL;
2866 depth = xmlTextReaderDepth(reader);
2867 while ((ret = __next_child_element(reader, depth))) {
2868 node = xmlTextReaderConstName(reader);
2870 _LOGD("xmlTextReaderConstName value is NULL\n");
2874 if (strcmp(ASCII(node), "condition") == 0) {
2875 condition_x *condition = malloc(sizeof(condition_x));
2876 if (condition == NULL) {
2877 _LOGD("Malloc Failed\n");
2880 memset(condition, '\0', sizeof(condition_x));
2881 LISTADD(launchconditions->condition, condition);
2882 ret = __ps_process_condition(reader, condition);
2886 _LOGD("Processing launchconditions failed\n");
2890 if (launchconditions->condition) {
2891 LISTHEAD(launchconditions->condition, tmp1);
2892 launchconditions->condition = tmp1;
2895 xmlTextReaderRead(reader);
2896 if (xmlTextReaderValue(reader))
2897 launchconditions->text = ASCII(xmlTextReaderValue(reader));
2902 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare)
2904 const xmlChar *node;
2907 define_x *tmp1 = NULL;
2908 request_x *tmp2 = NULL;
2909 depth = xmlTextReaderDepth(reader);
2910 while ((ret = __next_child_element(reader, depth))) {
2911 node = xmlTextReaderConstName(reader);
2913 _LOGD("xmlTextReaderConstName value is NULL\n");
2917 if (!strcmp(ASCII(node), "define")) {
2918 define_x *define= malloc(sizeof(define_x));
2919 if (define == NULL) {
2920 _LOGD("Malloc Failed\n");
2923 memset(define, '\0', sizeof(define_x));
2924 LISTADD(datashare->define, define);
2925 ret = __ps_process_define(reader, define);
2926 } else if (!strcmp(ASCII(node), "request")) {
2927 request_x *request= malloc(sizeof(request_x));
2928 if (request == NULL) {
2929 _LOGD("Malloc Failed\n");
2932 memset(request, '\0', sizeof(request_x));
2933 LISTADD(datashare->request, request);
2934 ret = __ps_process_request(reader, request);
2938 _LOGD("Processing data-share failed\n");
2942 if (datashare->define) {
2943 LISTHEAD(datashare->define, tmp1);
2944 datashare->define = tmp1;
2946 if (datashare->request) {
2947 LISTHEAD(datashare->request, tmp2);
2948 datashare->request = tmp2;
2954 __get_icon_with_path(const char* icon, uid_t uid)
2959 if (index(icon, '/') == NULL) {
2961 char* icon_with_path = NULL;
2962 char *app_path = NULL;
2968 /* "db/setting/theme" is not exist */
2970 theme = vconf_get_str("db/setting/theme");
2972 theme = strdup("default");
2978 theme = strdup("default");
2981 len = (0x01 << 7) + strlen(icon) + strlen(package) + strlen(theme);
2982 icon_with_path = malloc(len);
2983 if(icon_with_path == NULL) {
2984 _LOGD("(icon_with_path == NULL) return\n");
2989 memset(icon_with_path, 0, len);
2990 if (uid != GLOBAL_USER)
2991 snprintf(icon_with_path, len, "%s%s", getIconPath(uid), icon);
2993 snprintf(icon_with_path, len, "%s%s/small/%s", getIconPath(GLOBAL_USER), theme, icon);
2994 if (access (icon_with_path, F_OK)) { //If doesn't exist in case of Global app, try to get icon directly into app's directory
2995 app_path = tzplatform_getenv(TZ_SYS_RW_APP);
2997 snprintf(icon_with_path, len, "%s/%q/res/icons/%q/small/%q", app_path, package, theme, icon);
2998 if (access (icon_with_path, F_OK))
2999 _LOGE("Cannot find icon path");
3003 _LOGD("Icon path : %s ---> %s", icon, icon_with_path);
3004 return icon_with_path;
3006 char* confirmed_icon = NULL;
3008 confirmed_icon = strdup(icon);
3009 if (!confirmed_icon)
3011 return confirmed_icon;
3015 static void __ps_process_tag(manifest_x * mfx, char *const tagv[])
3018 char delims[] = "=";
3019 char *ret_result = NULL;
3025 for (tag = strdup(tagv[0]); tag != NULL; ) {
3026 ret_result = strtok(tag, delims);
3028 /*check tag : preload */
3029 if (strcmp(ret_result, "preload") == 0) {
3030 ret_result = strtok(NULL, delims);
3031 if (strcmp(ret_result, "true") == 0) {
3032 free((void *)mfx->preload);
3033 mfx->preload = strdup("true");
3034 } else if (strcmp(ret_result, "false") == 0) {
3035 free((void *)mfx->preload);
3036 mfx->preload = strdup("false");
3038 /*check tag : removable*/
3039 } else if (strcmp(ret_result, "removable") == 0) {
3040 ret_result = strtok(NULL, delims);
3041 if (strcmp(ret_result, "true") == 0){
3042 free((void *)mfx->removable);
3043 mfx->removable = strdup("true");
3044 } else if (strcmp(ret_result, "false") == 0) {
3045 free((void *)mfx->removable);
3046 mfx->removable = strdup("false");
3048 /*check tag : not matched*/
3050 _LOGD("tag process [%s]is not defined\n", ret_result);
3054 /*check next value*/
3055 if (tagv[++i] != NULL)
3056 tag = strdup(tagv[i]);
3058 _LOGD("tag process success...\n");
3064 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon, uid_t uid)
3066 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
3067 icon->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
3068 if (xmlTextReaderConstXmlLang(reader)) {
3069 icon->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3070 if (icon->lang == NULL)
3071 icon->lang = strdup(DEFAULT_LOCALE);
3073 icon->lang = strdup(DEFAULT_LOCALE);
3075 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
3076 icon->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
3077 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
3078 icon->size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
3079 if (xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")))
3080 icon->resolution = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")));
3081 xmlTextReaderRead(reader);
3082 if (xmlTextReaderValue(reader)) {
3083 const char *text = ASCII(xmlTextReaderValue(reader));
3085 icon->text = (const char *)__get_icon_with_path(text, uid);
3093 static int __ps_process_image(xmlTextReaderPtr reader, image_x *image)
3095 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
3096 image->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
3097 if (xmlTextReaderConstXmlLang(reader)) {
3098 image->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3099 if (image->lang == NULL)
3100 image->lang = strdup(DEFAULT_LOCALE);
3102 image->lang = strdup(DEFAULT_LOCALE);
3104 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
3105 image->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
3106 xmlTextReaderRead(reader);
3107 if (xmlTextReaderValue(reader))
3108 image->text = ASCII(xmlTextReaderValue(reader));
3113 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label)
3115 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
3116 label->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
3117 if (xmlTextReaderConstXmlLang(reader)) {
3118 label->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3119 if (label->lang == NULL)
3120 label->lang = strdup(DEFAULT_LOCALE);
3122 label->lang = strdup(DEFAULT_LOCALE);
3123 xmlTextReaderRead(reader);
3124 if (xmlTextReaderValue(reader))
3125 label->text = ASCII(xmlTextReaderValue(reader));
3128 /* _LOGD("lable name %s\n", label->name);
3129 _LOGD("lable lang %s\n", label->lang);
3130 _LOGD("lable text %s\n", label->text);
3136 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author)
3138 if (xmlTextReaderGetAttribute(reader, XMLCHAR("email")))
3139 author->email = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("email")));
3140 if (xmlTextReaderGetAttribute(reader, XMLCHAR("href")))
3141 author->href = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("href")));
3142 if (xmlTextReaderConstXmlLang(reader)) {
3143 author->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3144 if (author->lang == NULL)
3145 author->lang = strdup(DEFAULT_LOCALE);
3147 author->lang = strdup(DEFAULT_LOCALE);
3149 xmlTextReaderRead(reader);
3150 if (xmlTextReaderValue(reader)) {
3151 const char *text = ASCII(xmlTextReaderValue(reader));
3152 if (*text == '\n') {
3153 author->text = NULL;
3157 author->text = ASCII(xmlTextReaderValue(reader));
3162 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description)
3164 if (xmlTextReaderConstXmlLang(reader)) {
3165 description->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3166 if (description->lang == NULL)
3167 description->lang = strdup(DEFAULT_LOCALE);
3169 description->lang = strdup(DEFAULT_LOCALE);
3171 xmlTextReaderRead(reader);
3172 if (xmlTextReaderValue(reader)) {
3173 const char *text = ASCII(xmlTextReaderValue(reader));
3174 if (*text == '\n') {
3175 description->text = NULL;
3179 description->text = ASCII(xmlTextReaderValue(reader));
3184 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license)
3186 if (xmlTextReaderConstXmlLang(reader)) {
3187 license->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3188 if (license->lang == NULL)
3189 license->lang = strdup(DEFAULT_LOCALE);
3191 license->lang = strdup(DEFAULT_LOCALE);
3193 xmlTextReaderRead(reader);
3194 if (xmlTextReaderValue(reader))
3195 license->text = ASCII(xmlTextReaderValue(reader));
3199 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability)
3201 const xmlChar *node;
3204 resolution_x *tmp1 = NULL;
3206 if (xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")))
3207 capability->operationid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")));
3209 depth = xmlTextReaderDepth(reader);
3210 while ((ret = __next_child_element(reader, depth))) {
3211 node = xmlTextReaderConstName(reader);
3213 _LOGD("xmlTextReaderConstName value is NULL\n");
3217 if (!strcmp(ASCII(node), "resolution")) {
3218 resolution_x *resolution = malloc(sizeof(resolution_x));
3219 if (resolution == NULL) {
3220 _LOGD("Malloc Failed\n");
3223 memset(resolution, '\0', sizeof(resolution_x));
3224 LISTADD(capability->resolution, resolution);
3225 ret = __ps_process_resolution(reader, resolution);
3229 _LOGD("Processing capability failed\n");
3234 if (capability->resolution) {
3235 LISTHEAD(capability->resolution, tmp1);
3236 capability->resolution = tmp1;
3242 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol)
3244 if (xmlTextReaderGetAttribute(reader, XMLCHAR("providerid")))
3245 datacontrol->providerid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("providerid")));
3246 if (xmlTextReaderGetAttribute(reader, XMLCHAR("access")))
3247 datacontrol->access = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("access")));
3248 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
3249 datacontrol->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
3254 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication, uid_t uid)
3256 const xmlChar *node;
3259 char *newappid = NULL;
3260 label_x *tmp1 = NULL;
3261 icon_x *tmp2 = NULL;
3262 appsvc_x *tmp3 = NULL;
3263 appcontrol_x *tmp4 = NULL;
3264 launchconditions_x *tmp5 = NULL;
3265 notification_x *tmp6 = NULL;
3266 datashare_x *tmp7 = NULL;
3267 category_x *tmp8 = NULL;
3268 metadata_x *tmp9 = NULL;
3269 image_x *tmp10 = NULL;
3270 permission_x *tmp11 = NULL;
3271 datacontrol_x *tmp12 = NULL;
3273 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
3274 uiapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
3275 if (uiapplication->appid == NULL) {
3276 _LOGD("appid cant be NULL\n");
3280 _LOGD("appid is mandatory\n");
3284 ret = __validate_appid(package, uiapplication->appid, &newappid);
3286 _LOGD("appid is not proper\n");
3290 if (uiapplication->appid)
3291 free((void *)uiapplication->appid);
3292 uiapplication->appid = newappid;
3294 uiapplication->package= strdup(package);
3296 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
3297 uiapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
3298 if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay"))) {
3299 uiapplication->nodisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay")));
3300 if (uiapplication->nodisplay == NULL)
3301 uiapplication->nodisplay = strdup("false");
3303 uiapplication->nodisplay = strdup("false");
3305 if (xmlTextReaderGetAttribute(reader, XMLCHAR("multiple"))) {
3306 uiapplication->multiple = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("multiple")));
3307 if (uiapplication->multiple == NULL)
3308 uiapplication->multiple = strdup("false");
3310 uiapplication->multiple = strdup("false");
3312 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
3313 uiapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
3314 if (xmlTextReaderGetAttribute(reader, XMLCHAR("categories")))
3315 uiapplication->categories = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("categories")));
3316 if (xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")))
3317 uiapplication->extraid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")));
3318 if (xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage"))) {
3319 uiapplication->taskmanage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage")));
3320 if (uiapplication->taskmanage == NULL)
3321 uiapplication->taskmanage = strdup("true");
3323 uiapplication->taskmanage = strdup("true");
3325 if (xmlTextReaderGetAttribute(reader, XMLCHAR("enabled"))) {
3326 uiapplication->enabled = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("enabled")));
3327 if (uiapplication->enabled == NULL)
3328 uiapplication->enabled = strdup("true");
3330 uiapplication->enabled = strdup("true");
3332 if (xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration"))) {
3333 uiapplication->hwacceleration = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration")));
3334 if (uiapplication->hwacceleration == NULL)
3335 uiapplication->hwacceleration = strdup("use-system-setting");
3337 uiapplication->hwacceleration = strdup("use-system-setting");
3339 if (xmlTextReaderGetAttribute(reader, XMLCHAR("screen-reader"))) {
3340 uiapplication->screenreader = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("screen-reader")));
3341 if (uiapplication->screenreader == NULL)
3342 uiapplication->screenreader = strdup("use-system-setting");
3344 uiapplication->screenreader = strdup("use-system-setting");
3346 if (xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")))
3347 uiapplication->recentimage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")));
3348 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp"))) {
3349 uiapplication->mainapp = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp")));
3350 if (uiapplication->mainapp == NULL)
3351 uiapplication->mainapp = strdup("false");
3353 uiapplication->mainapp = strdup("false");
3355 if (xmlTextReaderGetAttribute(reader, XMLCHAR("launchcondition"))) {
3356 uiapplication->launchcondition = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("launchcondition")));
3357 if (uiapplication->launchcondition == NULL)
3358 uiapplication->launchcondition = strdup("false");
3360 uiapplication->launchcondition = strdup("false");
3363 if (xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay"))) {
3364 uiapplication->indicatordisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay")));
3365 if (uiapplication->indicatordisplay == NULL)
3366 uiapplication->indicatordisplay = strdup("true");
3368 uiapplication->indicatordisplay = strdup("true");
3370 if (xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")))
3371 uiapplication->portraitimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")));
3373 uiapplication->portraitimg = NULL;
3374 if (xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")))
3375 uiapplication->landscapeimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")));
3377 uiapplication->landscapeimg = NULL;
3378 if (xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility"))) {
3379 uiapplication->guestmode_visibility = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility")));
3380 if (uiapplication->guestmode_visibility == NULL)
3381 uiapplication->guestmode_visibility = strdup("true");
3383 uiapplication->guestmode_visibility = strdup("true");
3385 if (xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type"))) {
3386 uiapplication->permission_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type")));
3387 if (uiapplication->permission_type == NULL)
3388 uiapplication->permission_type = strdup("normal");
3390 uiapplication->permission_type = strdup("normal");
3392 if (xmlTextReaderGetAttribute(reader, XMLCHAR("component-type"))) {
3393 uiapplication->component_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("component-type")));
3394 if (uiapplication->component_type == NULL)
3395 uiapplication->component_type = strdup("uiapp");
3397 uiapplication->component_type = strdup("uiapp");
3399 if (xmlTextReaderGetAttribute(reader, XMLCHAR("submode"))) {
3400 uiapplication->submode = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("submode")));
3401 if (uiapplication->submode == NULL)
3402 uiapplication->submode = strdup("false");
3404 uiapplication->submode = strdup("false");
3406 if (xmlTextReaderGetAttribute(reader, XMLCHAR("submode-mainid")))
3407 uiapplication->submode_mainid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("submode-mainid")));
3408 if (xmlTextReaderGetAttribute(reader, XMLCHAR("launch_mode"))) {
3409 uiapplication->launch_mode = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("launch_mode")));
3410 if (uiapplication->launch_mode == NULL)
3411 uiapplication->launch_mode = strdup("caller");
3413 uiapplication->launch_mode = strdup("caller");
3416 depth = xmlTextReaderDepth(reader);
3417 while ((ret = __next_child_element(reader, depth))) {
3418 node = xmlTextReaderConstName(reader);
3420 _LOGD("xmlTextReaderConstName value is NULL\n");
3423 if (!strcmp(ASCII(node), "label")) {
3424 label_x *label = malloc(sizeof(label_x));
3425 if (label == NULL) {
3426 _LOGD("Malloc Failed\n");
3429 memset(label, '\0', sizeof(label_x));
3430 LISTADD(uiapplication->label, label);
3431 ret = __ps_process_label(reader, label);
3432 } else if (!strcmp(ASCII(node), "icon")) {
3433 icon_x *icon = malloc(sizeof(icon_x));
3435 _LOGD("Malloc Failed\n");
3438 memset(icon, '\0', sizeof(icon_x));
3439 LISTADD(uiapplication->icon, icon);
3440 ret = __ps_process_icon(reader, icon, uid);
3441 } else if (!strcmp(ASCII(node), "image")) {
3442 image_x *image = malloc(sizeof(image_x));
3443 if (image == NULL) {
3444 _LOGD("Malloc Failed\n");
3447 memset(image, '\0', sizeof(image_x));
3448 LISTADD(uiapplication->image, image);
3449 ret = __ps_process_image(reader, image);
3450 } else if (!strcmp(ASCII(node), "category")) {
3451 category_x *category = malloc(sizeof(category_x));
3452 if (category == NULL) {
3453 _LOGD("Malloc Failed\n");
3456 memset(category, '\0', sizeof(category_x));
3457 LISTADD(uiapplication->category, category);
3458 ret = __ps_process_category(reader, category);
3459 } else if (!strcmp(ASCII(node), "metadata")) {
3460 metadata_x *metadata = malloc(sizeof(metadata_x));
3461 if (metadata == NULL) {
3462 _LOGD("Malloc Failed\n");
3465 memset(metadata, '\0', sizeof(metadata_x));
3466 LISTADD(uiapplication->metadata, metadata);
3467 ret = __ps_process_metadata(reader, metadata);
3468 } else if (!strcmp(ASCII(node), "permission")) {
3469 permission_x *permission = malloc(sizeof(permission_x));
3470 if (permission == NULL) {
3471 _LOGD("Malloc Failed\n");
3474 memset(permission, '\0', sizeof(permission_x));
3475 LISTADD(uiapplication->permission, permission);
3476 ret = __ps_process_permission(reader, permission);
3477 } else if (!strcmp(ASCII(node), "app-control")) {
3478 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
3479 if (appcontrol == NULL) {
3480 _LOGD("Malloc Failed\n");
3483 memset(appcontrol, '\0', sizeof(appcontrol_x));
3484 LISTADD(uiapplication->appcontrol, appcontrol);
3485 ret = __ps_process_appcontrol(reader, appcontrol);
3486 } else if (!strcmp(ASCII(node), "application-service")) {
3487 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
3488 if (appsvc == NULL) {
3489 _LOGD("Malloc Failed\n");
3492 memset(appsvc, '\0', sizeof(appsvc_x));
3493 LISTADD(uiapplication->appsvc, appsvc);
3494 ret = __ps_process_appsvc(reader, appsvc);
3495 } else if (!strcmp(ASCII(node), "data-share")) {
3496 datashare_x *datashare = malloc(sizeof(datashare_x));
3497 if (datashare == NULL) {
3498 _LOGD("Malloc Failed\n");
3501 memset(datashare, '\0', sizeof(datashare_x));
3502 LISTADD(uiapplication->datashare, datashare);
3503 ret = __ps_process_datashare(reader, datashare);
3504 } else if (!strcmp(ASCII(node), "launch-conditions")) {
3505 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
3506 if (launchconditions == NULL) {
3507 _LOGD("Malloc Failed\n");
3510 memset(launchconditions, '\0', sizeof(launchconditions_x));
3511 LISTADD(uiapplication->launchconditions, launchconditions);
3512 ret = __ps_process_launchconditions(reader, launchconditions);
3513 } else if (!strcmp(ASCII(node), "notification")) {
3514 notification_x *notification = malloc(sizeof(notification_x));
3515 if (notification == NULL) {
3516 _LOGD("Malloc Failed\n");
3519 memset(notification, '\0', sizeof(notification_x));
3520 LISTADD(uiapplication->notification, notification);
3521 ret = __ps_process_notification(reader, notification);
3522 } else if (!strcmp(ASCII(node), "datacontrol")) {
3523 datacontrol_x *datacontrol = malloc(sizeof(datacontrol_x));
3524 if (datacontrol == NULL) {
3525 _LOGD("Malloc Failed\n");
3528 memset(datacontrol, '\0', sizeof(datacontrol_x));
3529 LISTADD(uiapplication->datacontrol, datacontrol);
3530 ret = __ps_process_datacontrol(reader, datacontrol);
3534 _LOGD("Processing uiapplication failed\n");
3539 if (uiapplication->label) {
3540 LISTHEAD(uiapplication->label, tmp1);
3541 uiapplication->label = tmp1;
3543 if (uiapplication->icon) {
3544 LISTHEAD(uiapplication->icon, tmp2);
3545 uiapplication->icon = tmp2;
3547 if (uiapplication->appsvc) {
3548 LISTHEAD(uiapplication->appsvc, tmp3);
3549 uiapplication->appsvc = tmp3;
3551 if (uiapplication->appcontrol) {
3552 LISTHEAD(uiapplication->appcontrol, tmp4);
3553 uiapplication->appcontrol = tmp4;
3555 if (uiapplication->launchconditions) {
3556 LISTHEAD(uiapplication->launchconditions, tmp5);
3557 uiapplication->launchconditions = tmp5;
3559 if (uiapplication->notification) {
3560 LISTHEAD(uiapplication->notification, tmp6);
3561 uiapplication->notification = tmp6;
3563 if (uiapplication->datashare) {
3564 LISTHEAD(uiapplication->datashare, tmp7);
3565 uiapplication->datashare = tmp7;
3567 if (uiapplication->category) {
3568 LISTHEAD(uiapplication->category, tmp8);
3569 uiapplication->category = tmp8;
3571 if (uiapplication->metadata) {
3572 LISTHEAD(uiapplication->metadata, tmp9);
3573 uiapplication->metadata = tmp9;
3575 if (uiapplication->image) {
3576 LISTHEAD(uiapplication->image, tmp10);
3577 uiapplication->image = tmp10;
3579 if (uiapplication->permission) {
3580 LISTHEAD(uiapplication->permission, tmp11);
3581 uiapplication->permission = tmp11;
3583 if (uiapplication->datacontrol) {
3584 LISTHEAD(uiapplication->datacontrol, tmp12);
3585 uiapplication->datacontrol = tmp12;
3591 static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication, uid_t uid)
3593 const xmlChar *node;
3596 char *newappid = NULL;
3597 label_x *tmp1 = NULL;
3598 icon_x *tmp2 = NULL;
3599 appsvc_x *tmp3 = NULL;
3600 appcontrol_x *tmp4 = NULL;
3601 datacontrol_x *tmp5 = NULL;
3602 launchconditions_x *tmp6 = NULL;
3603 notification_x *tmp7 = NULL;
3604 datashare_x *tmp8 = NULL;
3605 category_x *tmp9 = NULL;
3606 metadata_x *tmp10 = NULL;
3607 permission_x *tmp11 = NULL;
3609 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
3610 serviceapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
3611 if (serviceapplication->appid == NULL) {
3612 _LOGD("appid cant be NULL\n");
3616 _LOGD("appid is mandatory\n");
3620 ret = __validate_appid(package, serviceapplication->appid, &newappid);
3622 _LOGD("appid is not proper\n");
3626 if (serviceapplication->appid)
3627 free((void *)serviceapplication->appid);
3628 serviceapplication->appid = newappid;
3631 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
3632 serviceapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
3633 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
3634 serviceapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
3635 if (xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot"))) {
3636 serviceapplication->onboot = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot")));
3637 if (serviceapplication->onboot == NULL)
3638 serviceapplication->onboot = strdup("false");
3640 serviceapplication->onboot = strdup("false");
3642 if (xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart"))) {
3643 serviceapplication->autorestart = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart")));
3644 if (serviceapplication->autorestart == NULL)
3645 serviceapplication->autorestart = strdup("false");
3647 serviceapplication->autorestart = strdup("false");
3649 if (xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type"))) {
3650 serviceapplication->permission_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type")));
3651 if (serviceapplication->permission_type == NULL)
3652 serviceapplication->permission_type = strdup("normal");
3654 serviceapplication->permission_type = strdup("normal");
3657 depth = xmlTextReaderDepth(reader);
3658 while ((ret = __next_child_element(reader, depth))) {
3659 node = xmlTextReaderConstName(reader);
3661 _LOGD("xmlTextReaderConstName value is NULL\n");
3665 if (!strcmp(ASCII(node), "label")) {
3666 label_x *label = malloc(sizeof(label_x));
3667 if (label == NULL) {
3668 _LOGD("Malloc Failed\n");
3671 memset(label, '\0', sizeof(label_x));
3672 LISTADD(serviceapplication->label, label);
3673 ret = __ps_process_label(reader, label);
3674 } else if (!strcmp(ASCII(node), "icon")) {
3675 icon_x *icon = malloc(sizeof(icon_x));
3677 _LOGD("Malloc Failed\n");
3680 memset(icon, '\0', sizeof(icon_x));
3681 LISTADD(serviceapplication->icon, icon);
3682 ret = __ps_process_icon(reader, icon, uid);
3683 } else if (!strcmp(ASCII(node), "category")) {
3684 category_x *category = malloc(sizeof(category_x));
3685 if (category == NULL) {
3686 _LOGD("Malloc Failed\n");
3689 memset(category, '\0', sizeof(category_x));
3690 LISTADD(serviceapplication->category, category);
3691 ret = __ps_process_category(reader, category);
3692 } else if (!strcmp(ASCII(node), "metadata")) {
3693 metadata_x *metadata = malloc(sizeof(metadata_x));
3694 if (metadata == NULL) {
3695 _LOGD("Malloc Failed\n");
3698 memset(metadata, '\0', sizeof(metadata_x));
3699 LISTADD(serviceapplication->metadata, metadata);
3700 ret = __ps_process_metadata(reader, metadata);
3701 } else if (!strcmp(ASCII(node), "permission")) {
3702 permission_x *permission = malloc(sizeof(permission_x));
3703 if (permission == NULL) {
3704 _LOGD("Malloc Failed\n");
3707 memset(permission, '\0', sizeof(permission_x));
3708 LISTADD(serviceapplication->permission, permission);
3709 ret = __ps_process_permission(reader, permission);
3710 } else if (!strcmp(ASCII(node), "app-control")) {
3711 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
3712 if (appcontrol == NULL) {
3713 _LOGD("Malloc Failed\n");
3716 memset(appcontrol, '\0', sizeof(appcontrol_x));
3717 LISTADD(serviceapplication->appcontrol, appcontrol);
3718 ret = __ps_process_appcontrol(reader, appcontrol);
3719 } else if (!strcmp(ASCII(node), "application-service")) {
3720 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
3721 if (appsvc == NULL) {
3722 _LOGD("Malloc Failed\n");
3725 memset(appsvc, '\0', sizeof(appsvc_x));
3726 LISTADD(serviceapplication->appsvc, appsvc);
3727 ret = __ps_process_appsvc(reader, appsvc);
3728 } else if (!strcmp(ASCII(node), "data-share")) {
3729 datashare_x *datashare = malloc(sizeof(datashare_x));
3730 if (datashare == NULL) {
3731 _LOGD("Malloc Failed\n");
3734 memset(datashare, '\0', sizeof(datashare_x));
3735 LISTADD(serviceapplication->datashare, datashare);
3736 ret = __ps_process_datashare(reader, datashare);
3737 } else if (!strcmp(ASCII(node), "launch-conditions")) {
3738 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
3739 if (launchconditions == NULL) {
3740 _LOGD("Malloc Failed\n");
3743 memset(launchconditions, '\0', sizeof(launchconditions_x));
3744 LISTADD(serviceapplication->launchconditions, launchconditions);
3745 ret = __ps_process_launchconditions(reader, launchconditions);
3746 } else if (!strcmp(ASCII(node), "notification")) {
3747 notification_x *notification = malloc(sizeof(notification_x));
3748 if (notification == NULL) {
3749 _LOGD("Malloc Failed\n");
3752 memset(notification, '\0', sizeof(notification_x));
3753 LISTADD(serviceapplication->notification, notification);
3754 ret = __ps_process_notification(reader, notification);
3755 } else if (!strcmp(ASCII(node), "datacontrol")) {
3756 datacontrol_x *datacontrol = malloc(sizeof(datacontrol_x));
3757 if (datacontrol == NULL) {
3758 _LOGD("Malloc Failed\n");
3761 memset(datacontrol, '\0', sizeof(datacontrol_x));
3762 LISTADD(serviceapplication->datacontrol, datacontrol);
3763 ret = __ps_process_datacontrol(reader, datacontrol);
3767 _LOGD("Processing serviceapplication failed\n");
3772 if (serviceapplication->label) {
3773 LISTHEAD(serviceapplication->label, tmp1);
3774 serviceapplication->label = tmp1;
3776 if (serviceapplication->icon) {
3777 LISTHEAD(serviceapplication->icon, tmp2);
3778 serviceapplication->icon = tmp2;
3780 if (serviceapplication->appsvc) {
3781 LISTHEAD(serviceapplication->appsvc, tmp3);
3782 serviceapplication->appsvc = tmp3;
3784 if (serviceapplication->appcontrol) {
3785 LISTHEAD(serviceapplication->appcontrol, tmp4);
3786 serviceapplication->appcontrol = tmp4;
3788 if (serviceapplication->datacontrol) {
3789 LISTHEAD(serviceapplication->datacontrol, tmp5);
3790 serviceapplication->datacontrol = tmp5;
3792 if (serviceapplication->launchconditions) {
3793 LISTHEAD(serviceapplication->launchconditions, tmp6);
3794 serviceapplication->launchconditions = tmp6;
3796 if (serviceapplication->notification) {
3797 LISTHEAD(serviceapplication->notification, tmp7);
3798 serviceapplication->notification = tmp7;
3800 if (serviceapplication->datashare) {
3801 LISTHEAD(serviceapplication->datashare, tmp8);
3802 serviceapplication->datashare = tmp8;
3804 if (serviceapplication->category) {
3805 LISTHEAD(serviceapplication->category, tmp9);
3806 serviceapplication->category = tmp9;
3808 if (serviceapplication->metadata) {
3809 LISTHEAD(serviceapplication->metadata, tmp10);
3810 serviceapplication->metadata = tmp10;
3812 if (serviceapplication->permission) {
3813 LISTHEAD(serviceapplication->permission, tmp11);
3814 serviceapplication->permission = tmp11;
3820 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile)
3822 /*TODO: once policy is set*/
3826 static int __ps_process_font(xmlTextReaderPtr reader, font_x *font)
3828 /*TODO: once policy is set*/
3832 static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme)
3834 /*TODO: once policy is set*/
3838 static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon)
3840 /*TODO: once policy is set*/
3844 static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime)
3846 /*TODO: once policy is set*/
3850 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx, uid_t uid)
3852 _LOGD("__start_process\n");
3853 const xmlChar *node;
3856 label_x *tmp1 = NULL;
3857 author_x *tmp2 = NULL;
3858 description_x *tmp3 = NULL;
3859 license_x *tmp4 = NULL;
3860 uiapplication_x *tmp5 = NULL;
3861 serviceapplication_x *tmp6 = NULL;
3862 daemon_x *tmp7 = NULL;
3863 theme_x *tmp8 = NULL;
3864 font_x *tmp9 = NULL;
3865 ime_x *tmp10 = NULL;
3866 icon_x *tmp11 = NULL;
3867 compatibility_x *tmp12 = NULL;
3868 deviceprofile_x *tmp13 = NULL;
3869 privileges_x *tmp14 = NULL;
3871 depth = xmlTextReaderDepth(reader);
3872 while ((ret = __next_child_element(reader, depth))) {
3873 node = xmlTextReaderConstName(reader);
3875 _LOGD("xmlTextReaderConstName value is NULL\n");
3879 if (!strcmp(ASCII(node), "label")) {
3880 label_x *label = malloc(sizeof(label_x));
3881 if (label == NULL) {
3882 _LOGD("Malloc Failed\n");
3885 memset(label, '\0', sizeof(label_x));
3886 LISTADD(mfx->label, label);
3887 ret = __ps_process_label(reader, label);
3888 } else if (!strcmp(ASCII(node), "author")) {
3889 author_x *author = malloc(sizeof(author_x));
3890 if (author == NULL) {
3891 _LOGD("Malloc Failed\n");
3894 memset(author, '\0', sizeof(author_x));
3895 LISTADD(mfx->author, author);
3896 ret = __ps_process_author(reader, author);
3897 } else if (!strcmp(ASCII(node), "description")) {
3898 description_x *description = malloc(sizeof(description_x));
3899 if (description == NULL) {
3900 _LOGD("Malloc Failed\n");
3903 memset(description, '\0', sizeof(description_x));
3904 LISTADD(mfx->description, description);
3905 ret = __ps_process_description(reader, description);
3906 } else if (!strcmp(ASCII(node), "license")) {
3907 license_x *license = malloc(sizeof(license_x));
3908 if (license == NULL) {
3909 _LOGD("Malloc Failed\n");
3912 memset(license, '\0', sizeof(license_x));
3913 LISTADD(mfx->license, license);
3914 ret = __ps_process_license(reader, license);
3915 } else if (!strcmp(ASCII(node), "privileges")) {
3916 privileges_x *privileges = malloc(sizeof(privileges_x));
3917 if (privileges == NULL) {
3918 _LOGD("Malloc Failed\n");
3921 memset(privileges, '\0', sizeof(privileges_x));
3922 LISTADD(mfx->privileges, privileges);
3923 ret = __ps_process_privileges(reader, privileges);
3924 } else if (!strcmp(ASCII(node), "ui-application")) {
3925 uiapplication_x *uiapplication = malloc(sizeof(uiapplication_x));
3926 if (uiapplication == NULL) {
3927 _LOGD("Malloc Failed\n");
3930 memset(uiapplication, '\0', sizeof(uiapplication_x));
3931 LISTADD(mfx->uiapplication, uiapplication);
3932 ret = __ps_process_uiapplication(reader, uiapplication, uid);
3933 } else if (!strcmp(ASCII(node), "service-application")) {
3934 serviceapplication_x *serviceapplication = malloc(sizeof(serviceapplication_x));
3935 if (serviceapplication == NULL) {
3936 _LOGD("Malloc Failed\n");
3939 memset(serviceapplication, '\0', sizeof(serviceapplication_x));
3940 LISTADD(mfx->serviceapplication, serviceapplication);
3941 ret = __ps_process_serviceapplication(reader, serviceapplication, uid);
3942 } else if (!strcmp(ASCII(node), "daemon")) {
3943 daemon_x *daemon = malloc(sizeof(daemon_x));
3944 if (daemon == NULL) {
3945 _LOGD("Malloc Failed\n");
3948 memset(daemon, '\0', sizeof(daemon_x));
3949 LISTADD(mfx->daemon, daemon);
3950 ret = __ps_process_daemon(reader, daemon);
3951 } else if (!strcmp(ASCII(node), "theme")) {
3952 theme_x *theme = malloc(sizeof(theme_x));
3953 if (theme == NULL) {
3954 _LOGD("Malloc Failed\n");
3957 memset(theme, '\0', sizeof(theme_x));
3958 LISTADD(mfx->theme, theme);
3959 ret = __ps_process_theme(reader, theme);
3960 } else if (!strcmp(ASCII(node), "font")) {
3961 font_x *font = malloc(sizeof(font_x));
3963 _LOGD("Malloc Failed\n");
3966 memset(font, '\0', sizeof(font_x));
3967 LISTADD(mfx->font, font);
3968 ret = __ps_process_font(reader, font);
3969 } else if (!strcmp(ASCII(node), "ime")) {
3970 ime_x *ime = malloc(sizeof(ime_x));
3972 _LOGD("Malloc Failed\n");
3975 memset(ime, '\0', sizeof(ime_x));
3976 LISTADD(mfx->ime, ime);
3977 ret = __ps_process_ime(reader, ime);
3978 } else if (!strcmp(ASCII(node), "icon")) {
3979 icon_x *icon = malloc(sizeof(icon_x));
3981 _LOGD("Malloc Failed\n");
3984 memset(icon, '\0', sizeof(icon_x));
3985 LISTADD(mfx->icon, icon);
3986 ret = __ps_process_icon(reader, icon, uid);
3987 } else if (!strcmp(ASCII(node), "profile")) {
3988 deviceprofile_x *deviceprofile = malloc(sizeof(deviceprofile_x));
3989 if (deviceprofile == NULL) {
3990 _LOGD("Malloc Failed\n");
3993 memset(deviceprofile, '\0', sizeof(deviceprofile_x));
3994 LISTADD(mfx->deviceprofile, deviceprofile);
3995 ret = __ps_process_deviceprofile(reader, deviceprofile);
3996 } else if (!strcmp(ASCII(node), "compatibility")) {
3997 compatibility_x *compatibility = malloc(sizeof(compatibility_x));
3998 if (compatibility == NULL) {
3999 _LOGD("Malloc Failed\n");
4002 memset(compatibility, '\0', sizeof(compatibility_x));
4003 LISTADD(mfx->compatibility, compatibility);
4004 ret = __ps_process_compatibility(reader, compatibility);
4005 } else if (!strcmp(ASCII(node), "shortcut-list")) {
4007 } else if (!strcmp(ASCII(node), "livebox")) {
4009 } else if (!strcmp(ASCII(node), "account")) {
4011 } else if (!strcmp(ASCII(node), "notifications")) {
4013 } else if (!strcmp(ASCII(node), "ime")) {
4019 _LOGD("Processing manifest failed\n");
4024 LISTHEAD(mfx->label, tmp1);
4028 LISTHEAD(mfx->author, tmp2);
4031 if (mfx->description) {
4032 LISTHEAD(mfx->description, tmp3);
4033 mfx->description= tmp3;
4036 LISTHEAD(mfx->license, tmp4);
4039 if (mfx->uiapplication) {
4040 LISTHEAD(mfx->uiapplication, tmp5);
4041 mfx->uiapplication = tmp5;
4043 if (mfx->serviceapplication) {
4044 LISTHEAD(mfx->serviceapplication, tmp6);
4045 mfx->serviceapplication = tmp6;
4048 LISTHEAD(mfx->daemon, tmp7);
4052 LISTHEAD(mfx->theme, tmp8);
4056 LISTHEAD(mfx->font, tmp9);
4060 LISTHEAD(mfx->ime, tmp10);
4064 LISTHEAD(mfx->icon, tmp11);
4067 if (mfx->compatibility) {
4068 LISTHEAD(mfx->compatibility, tmp12);
4069 mfx->compatibility= tmp12;
4071 if (mfx->deviceprofile) {
4072 LISTHEAD(mfx->deviceprofile, tmp13);
4073 mfx->deviceprofile= tmp13;
4075 if (mfx->privileges) {
4076 LISTHEAD(mfx->privileges, tmp14);
4077 mfx->privileges = tmp14;
4082 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx, uid_t uid)
4084 const xmlChar *node;
4087 if ((ret = __next_child_element(reader, -1))) {
4088 node = xmlTextReaderConstName(reader);
4090 _LOGD("xmlTextReaderConstName value is NULL\n");
4094 if (!strcmp(ASCII(node), "manifest")) {
4095 if (xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns"))){
4096 mfx->ns = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")));
4098 if (xmlTextReaderGetAttribute(reader, XMLCHAR("package"))) {
4099 mfx->package= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("package")));
4100 if (mfx->package == NULL) {
4101 _LOGD("package cant be NULL\n");
4105 _LOGD("package field is mandatory\n");
4108 package = mfx->package;
4109 if (xmlTextReaderGetAttribute(reader, XMLCHAR("version")))
4110 mfx->version= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("version")));
4111 /*app2ext needs package size for external installation*/
4112 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
4113 mfx->package_size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
4114 if (xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")))
4115 mfx->installlocation = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")));
4116 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
4117 mfx->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
4118 if (xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")))
4119 mfx->root_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")));
4120 if (xmlTextReaderGetAttribute(reader, XMLCHAR("csc_path")))
4121 mfx->csc_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("csc_path")));
4122 if (xmlTextReaderGetAttribute(reader, XMLCHAR("main_package")))
4123 mfx->main_package = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("main_package")));
4124 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting"))) {
4125 mfx->appsetting = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting")));
4126 if (mfx->appsetting == NULL)
4127 mfx->appsetting = strdup("false");
4129 mfx->appsetting = strdup("false");
4131 if (xmlTextReaderGetAttribute(reader, XMLCHAR("storeclient-id")))
4132 mfx->storeclient_id= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("storeclient-id")));
4133 if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay-setting"))) {
4134 mfx->nodisplay_setting = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay-setting")));
4135 if (mfx->nodisplay_setting == NULL)
4136 mfx->nodisplay_setting = strdup("false");
4138 mfx->nodisplay_setting = strdup("false");
4140 if (xmlTextReaderGetAttribute(reader, XMLCHAR("url")))
4141 mfx->package_url= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("url")));
4142 /*Assign default values. If required it will be overwritten in __add_preload_info()*/
4143 mfx->preload = strdup("False");
4144 mfx->removable = strdup("True");
4145 mfx->readonly = strdup("False");
4146 mfx->update = strdup("False");
4147 mfx->system = strdup("False");
4148 char buf[PKG_STRING_LEN_MAX] = {'\0'};
4150 time_t current_time;
4151 time(¤t_time);
4152 snprintf(buf, PKG_STRING_LEN_MAX - 1, "%d", current_time);
4153 val = strndup(buf, PKG_STRING_LEN_MAX - 1);
4154 mfx->installed_time = val;
4155 mfx->installed_storage= strdup("installed_internal");
4157 ret = __start_process(reader, mfx, uid);
4159 _LOGD("No Manifest element found\n");
4166 static char* __convert_to_system_locale(const char *mlocale)
4168 if (mlocale == NULL)
4170 char *locale = NULL;
4171 locale = (char *)calloc(1, 6);
4173 _LOGE("Malloc Failed\n");
4177 strncpy(locale, mlocale, 2);
4178 strncat(locale, "_", 1);
4179 locale[3] = toupper(mlocale[3]);
4180 locale[4] = toupper(mlocale[4]);
4184 #define LIBAPPSVC_PATH LIB_PATH "/libappsvc.so.0"
4186 static int __ps_remove_appsvc_db(manifest_x *mfx, uid_t uid)
4188 void *lib_handle = NULL;
4189 int (*appsvc_operation) (const char *, uid_t);
4191 uiapplication_x *uiapplication = mfx->uiapplication;
4193 if ((lib_handle = dlopen(LIBAPPSVC_PATH, RTLD_LAZY)) == NULL) {
4194 _LOGE("dlopen is failed LIBAPPSVC_PATH[%s]\n", LIBAPPSVC_PATH);
4198 if ((appsvc_operation =
4199 dlsym(lib_handle, "appsvc_unset_defapp")) == NULL || dlerror() != NULL) {
4200 _LOGE("can not find symbol \n");
4204 for(; uiapplication; uiapplication=uiapplication->next) {
4205 ret = appsvc_operation(uiapplication->appid, uid);
4207 _LOGE("can not operation symbol \n");
4212 dlclose(lib_handle);
4217 #define PRELOAD_PACKAGE_LIST SYSCONFDIR "/package-manager/preload/preload_list.txt"
4218 static int __add_preload_info(manifest_x * mfx, const char *manifest, uid_t uid)
4221 char buffer[1024] = { 0 };
4224 if(strstr(manifest, getUserManifestPath(uid))) {
4225 free((void *)mfx->readonly);
4226 mfx->readonly = strdup("True");
4228 free((void *)mfx->preload);
4229 mfx->preload = strdup("True");
4231 free((void *)mfx->removable);
4232 mfx->removable = strdup("False");
4234 free((void *)mfx->system);
4235 mfx->system = strdup("True");
4240 fp = fopen(PRELOAD_PACKAGE_LIST, "r");
4242 _LOGE("no preload list\n");
4246 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
4247 if (buffer[0] == '#') {
4248 if(strcasestr(buffer, "RW_NORM"))
4250 else if(strcasestr(buffer, "RW_RM"))
4258 if(!strcmp(mfx->package, buffer)) {
4259 free((void *)mfx->preload);
4260 mfx->preload = strdup("True");
4262 free((void *)mfx->readonly);
4263 mfx->readonly = strdup("False");
4264 free((void *)mfx->removable);
4265 mfx->removable = strdup("False");
4266 } else if(state == 3){
4267 free((void *)mfx->readonly);
4268 mfx->readonly = strdup("False");
4269 free((void *)mfx->removable);
4270 mfx->removable = strdup("True");
4274 memset(buffer, 0x00, sizeof(buffer));
4283 static int __check_preload_updated(manifest_x * mfx, const char *manifest, uid_t uid)
4285 if (!strstr(manifest, getUserManifestPath(uid))) {
4286 /* if downloaded app is updated, then update tag set true*/
4288 free((void *)mfx->update);
4289 mfx->update = strdup("true");
4296 API int pkgmgr_parser_create_desktop_file(manifest_x *mfx)
4298 /* desktop file is no longer used */
4302 API int pkgmgr_parser_create_usr_desktop_file(manifest_x *mfx, uid_t uid)
4304 /* desktop file is no longer used */
4309 API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
4314 free((void *)mfx->ns);
4318 free((void *)mfx->package);
4319 mfx->package = NULL;
4322 free((void *)mfx->version);
4323 mfx->version = NULL;
4325 if (mfx->installlocation) {
4326 free((void *)mfx->installlocation);
4327 mfx->installlocation = NULL;
4330 free((void *)mfx->preload);
4331 mfx->preload = NULL;
4333 if (mfx->readonly) {
4334 free((void *)mfx->readonly);
4335 mfx->readonly = NULL;
4337 if (mfx->removable) {
4338 free((void *)mfx->removable);
4339 mfx->removable = NULL;
4342 free((void *)mfx->update);
4346 free((void *)mfx->system);
4350 free((void *)mfx->type);
4353 if (mfx->package_size) {
4354 free((void *)mfx->package_size);
4355 mfx->package_size = NULL;
4357 if (mfx->installed_time) {
4358 free((void *)mfx->installed_time);
4359 mfx->installed_time = NULL;
4361 if (mfx->installed_storage) {
4362 free((void *)mfx->installed_storage);
4363 mfx->installed_storage = NULL;
4365 if (mfx->storeclient_id) {
4366 free((void *)mfx->storeclient_id);
4367 mfx->storeclient_id = NULL;
4369 if (mfx->mainapp_id) {
4370 free((void *)mfx->mainapp_id);
4371 mfx->mainapp_id = NULL;
4373 if (mfx->package_url) {
4374 free((void *)mfx->package_url);
4375 mfx->package_url = NULL;
4377 if (mfx->root_path) {
4378 free((void *)mfx->root_path);
4379 mfx->root_path = NULL;
4381 if (mfx->csc_path) {
4382 free((void *)mfx->csc_path);
4383 mfx->csc_path = NULL;
4385 if (mfx->appsetting) {
4386 free((void *)mfx->appsetting);
4387 mfx->appsetting = NULL;
4389 if (mfx->nodisplay_setting) {
4390 free((void *)mfx->nodisplay_setting);
4391 mfx->nodisplay_setting = NULL;
4393 if (mfx->main_package) {
4394 free((void *)mfx->main_package);
4395 mfx->main_package = NULL;
4400 icon_x *icon = mfx->icon;
4402 while(icon != NULL) {
4404 __ps_free_icon(icon);
4410 label_x *label = mfx->label;
4411 label_x *tmp = NULL;
4412 while(label != NULL) {
4414 __ps_free_label(label);
4420 author_x *author = mfx->author;
4421 author_x *tmp = NULL;
4422 while(author != NULL) {
4424 __ps_free_author(author);
4428 /*Free Description*/
4429 if (mfx->description) {
4430 description_x *description = mfx->description;
4431 description_x *tmp = NULL;
4432 while(description != NULL) {
4433 tmp = description->next;
4434 __ps_free_description(description);
4440 license_x *license = mfx->license;
4441 license_x *tmp = NULL;
4442 while(license != NULL) {
4443 tmp = license->next;
4444 __ps_free_license(license);
4449 if (mfx->privileges) {
4450 privileges_x *privileges = mfx->privileges;
4451 privileges_x *tmp = NULL;
4452 while(privileges != NULL) {
4453 tmp = privileges->next;
4454 __ps_free_privileges(privileges);
4458 /*Free UiApplication*/
4459 if (mfx->uiapplication) {
4460 uiapplication_x *uiapplication = mfx->uiapplication;
4461 uiapplication_x *tmp = NULL;
4462 while(uiapplication != NULL) {
4463 tmp = uiapplication->next;
4464 __ps_free_uiapplication(uiapplication);
4465 uiapplication = tmp;
4468 /*Free ServiceApplication*/
4469 if (mfx->serviceapplication) {
4470 serviceapplication_x *serviceapplication = mfx->serviceapplication;
4471 serviceapplication_x *tmp = NULL;
4472 while(serviceapplication != NULL) {
4473 tmp = serviceapplication->next;
4474 __ps_free_serviceapplication(serviceapplication);
4475 serviceapplication = tmp;
4480 daemon_x *daemon = mfx->daemon;
4481 daemon_x *tmp = NULL;
4482 while(daemon != NULL) {
4484 __ps_free_daemon(daemon);
4490 theme_x *theme = mfx->theme;
4491 theme_x *tmp = NULL;
4492 while(theme != NULL) {
4494 __ps_free_theme(theme);
4500 font_x *font = mfx->font;
4502 while(font != NULL) {
4504 __ps_free_font(font);
4510 ime_x *ime = mfx->ime;
4512 while(ime != NULL) {
4518 /*Free Compatibility*/
4519 if (mfx->compatibility) {
4520 compatibility_x *compatibility = mfx->compatibility;
4521 compatibility_x *tmp = NULL;
4522 while(compatibility != NULL) {
4523 tmp = compatibility->next;
4524 __ps_free_compatibility(compatibility);
4525 compatibility = tmp;
4528 /*Free DeviceProfile*/
4529 if (mfx->deviceprofile) {
4530 deviceprofile_x *deviceprofile = mfx->deviceprofile;
4531 deviceprofile_x *tmp = NULL;
4532 while(deviceprofile != NULL) {
4533 tmp = deviceprofile->next;
4534 __ps_free_deviceprofile(deviceprofile);
4535 deviceprofile = tmp;
4543 API manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest)
4545 _LOGD("parsing start pkgmgr_parser_process_manifest_xml\n");
4546 xmlTextReaderPtr reader;
4547 manifest_x *mfx = NULL;
4549 reader = xmlReaderForFile(manifest, NULL, 0);
4551 mfx = malloc(sizeof(manifest_x));
4553 memset(mfx, '\0', sizeof(manifest_x));
4554 if (__process_manifest(reader, mfx, GLOBAL_USER) < 0) {
4555 _LOGD("Parsing Failed\n");
4556 pkgmgr_parser_free_manifest_xml(mfx);
4559 _LOGD("Parsing Success\n");
4561 _LOGD("Memory allocation error\n");
4563 xmlFreeTextReader(reader);
4565 _LOGD("Unable to create xml reader\n");
4571 API manifest_x *pkgmgr_parser_usr_process_manifest_xml(const char *manifest, uid_t uid)
4573 _LOGD("parsing start pkgmgr_parser_usr_process_manifest_xml\n");
4574 xmlTextReaderPtr reader;
4575 manifest_x *mfx = NULL;
4577 reader = xmlReaderForFile(manifest, NULL, 0);
4579 mfx = malloc(sizeof(manifest_x));
4581 memset(mfx, '\0', sizeof(manifest_x));
4582 if (__process_manifest(reader, mfx, uid) < 0) {
4583 _LOGD("Parsing Failed\n");
4584 pkgmgr_parser_free_manifest_xml(mfx);
4587 _LOGD("Parsing Success\n");
4589 _LOGD("Memory allocation error\n");
4591 xmlFreeTextReader(reader);
4593 _LOGD("Unable to create xml reader\n");
4598 /* These APIs are intended to call parser directly */
4600 API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
4602 // char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
4603 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
4604 _LOGD("parsing manifest for installation: %s\n", manifest);
4606 manifest_x *mfx = NULL;
4610 mfx = pkgmgr_parser_process_manifest_xml(manifest);
4611 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
4613 _LOGD("Parsing Finished\n");
4615 // __streamFile(manifest, ACTION_INSTALL, temp, mfx->package);
4616 __ps_process_tag_parser(mfx, manifest, ACTION_INSTALL);
4617 __add_preload_info(mfx, manifest, GLOBAL_USER);
4619 _LOGD("Added preload infomation\n");
4621 __ps_process_tag(mfx, tagv);
4623 ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
4624 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
4626 _LOGD("DB Insert Success\n");
4628 ret = __ps_process_metadata_parser(mfx, ACTION_INSTALL);
4630 _LOGD("Creating metadata parser failed\n");
4632 ret = __ps_process_category_parser(mfx, ACTION_INSTALL);
4634 _LOGD("Creating category parser failed\n");
4636 pkgmgr_parser_free_manifest_xml(mfx);
4637 _LOGD("Free Done\n");
4642 API int pkgmgr_parser_parse_usr_manifest_for_installation(const char *manifest, uid_t uid, char *const tagv[])
4644 // char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
4645 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
4646 _LOGD("parsing manifest for installation: %s\n", manifest);
4647 manifest_x *mfx = NULL;
4651 mfx = pkgmgr_parser_usr_process_manifest_xml(manifest, uid);
4652 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
4654 _LOGD("Parsing Finished\n");
4655 // __streamFile(manifest, ACTION_INSTALL, temp, mfx->package);
4656 __ps_process_tag_parser(mfx, manifest, ACTION_INSTALL);
4658 __ps_process_tag(mfx, tagv);
4660 ret = pkgmgr_parser_insert_manifest_info_in_usr_db(mfx, uid);
4661 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
4663 _LOGD("DB Insert Success\n");
4664 ret = __ps_process_metadata_parser(mfx, ACTION_INSTALL);
4666 _LOGD("Creating metadata parser failed\n");
4667 ret = __ps_process_category_parser(mfx, ACTION_INSTALL);
4669 _LOGD("Creating category parser failed\n");
4671 pkgmgr_parser_free_manifest_xml(mfx);
4672 _LOGD("Free Done\n");
4678 API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
4680 // char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
4681 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
4682 _LOGD("pkgmgr_parser_parse_manifest_for_upgrade parsing manifest for upgradation: %s\n", manifest);
4683 manifest_x *mfx = NULL;
4685 bool preload = false;
4686 bool system = false;
4687 char *csc_path = NULL;
4688 pkgmgrinfo_pkginfo_h handle = NULL;
4691 mfx = pkgmgr_parser_process_manifest_xml(manifest);
4692 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
4694 _LOGD("Parsing Finished\n");
4695 // __streamFile(manifest, ACTION_UPGRADE, temp, mfx->package);
4696 __ps_process_tag_parser(mfx, manifest, ACTION_UPGRADE);
4697 __add_preload_info(mfx, manifest, GLOBAL_USER);
4698 _LOGD("Added preload infomation\n");
4699 __check_preload_updated(mfx, manifest, GLOBAL_USER);
4701 ret = pkgmgrinfo_pkginfo_get_pkginfo(mfx->package, &handle);
4702 if (ret != PMINFO_R_OK)
4703 _LOGD("pkgmgrinfo_pkginfo_get_pkginfo failed\n");
4704 ret = pkgmgrinfo_pkginfo_is_preload(handle, &preload);
4705 if (ret != PMINFO_R_OK)
4706 _LOGD("pkgmgrinfo_pkginfo_is_preload failed\n");
4709 free((void *)mfx->preload);
4710 mfx->preload = strdup("true");
4713 ret = pkgmgrinfo_pkginfo_is_system(handle, &system);
4714 if (ret != PMINFO_R_OK)
4715 _LOGD("pkgmgrinfo_pkginfo_is_system failed\n");
4717 free((void *)mfx->system);
4718 mfx->system = strdup("true");
4721 ret = pkgmgrinfo_pkginfo_get_csc_path(handle, &csc_path);
4722 if (ret != PMINFO_R_OK)
4723 _LOGD("pkgmgrinfo_pkginfo_get_csc_path failed\n");
4725 if (csc_path != NULL) {
4727 free((void *)mfx->csc_path);
4728 mfx->csc_path = strdup(csc_path);
4731 ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
4732 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
4733 _LOGD("DB Update Success\n");
4734 ret = __ps_process_metadata_parser(mfx, ACTION_UPGRADE);
4736 _LOGD("Upgrade metadata parser failed\n");
4738 ret = __ps_process_category_parser(mfx, ACTION_UPGRADE);
4740 _LOGD("Creating category parser failed\n");
4741 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
4742 pkgmgr_parser_free_manifest_xml(mfx);
4743 _LOGD("Free Done\n");
4749 API int pkgmgr_parser_parse_usr_manifest_for_upgrade(const char *manifest, uid_t uid, char *const tagv[])
4751 // char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
4752 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
4753 _LOGD(" pkgmgr_parser_parse_usr_manifest_for_upgrade parsing manifest for upgradation: %s\n", manifest);
4754 manifest_x *mfx = NULL;
4756 bool preload = false;
4757 bool system = false;
4758 char *csc_path = NULL;
4759 pkgmgrinfo_pkginfo_h handle = NULL;
4762 mfx = pkgmgr_parser_usr_process_manifest_xml(manifest, uid);
4763 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
4765 _LOGD("Parsing Finished\n");
4766 //__streamFile(manifest, ACTION_UPGRADE, temp, mfx->package);
4767 __ps_process_tag_parser(mfx, manifest, ACTION_UPGRADE);
4768 __check_preload_updated(mfx, manifest, uid);
4770 ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(mfx->package, uid, &handle);
4771 if (ret != PMINFO_R_OK)
4772 _LOGD("pkgmgrinfo_pkginfo_get_pkginfo failed\n");
4773 ret = pkgmgrinfo_pkginfo_is_preload(handle, &preload);
4774 if (ret != PMINFO_R_OK)
4775 _LOGD("pkgmgrinfo_pkginfo_is_preload failed\n");
4778 free((void *)mfx->preload);
4779 mfx->preload = strdup("true");
4782 ret = pkgmgrinfo_pkginfo_is_system(handle, &system);
4783 if (ret != PMINFO_R_OK)
4784 _LOGD("pkgmgrinfo_pkginfo_is_system failed\n");
4787 free((void *)mfx->system);
4788 mfx->system = strdup("true");
4791 ret = pkgmgrinfo_pkginfo_get_csc_path(handle, &csc_path);
4792 if (ret != PMINFO_R_OK)
4793 _LOGD("pkgmgrinfo_pkginfo_get_csc_path failed\n");
4794 if (csc_path != NULL) {
4796 free((void *)mfx->csc_path);
4797 mfx->csc_path = strdup(csc_path);
4800 ret = pkgmgr_parser_update_manifest_info_in_usr_db(mfx, uid);
4801 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
4802 _LOGD("DB Update Success\n");
4803 _LOGE("DB Update Success\n" );
4804 ret = __ps_process_metadata_parser(mfx, ACTION_UPGRADE);
4806 _LOGD("Upgrade metadata parser failed\n");
4807 ret = __ps_process_category_parser(mfx, ACTION_UPGRADE);
4809 _LOGD("Creating category parser failed\n");
4810 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
4811 pkgmgr_parser_free_manifest_xml(mfx);
4812 _LOGD("Free Done\n");
4818 API int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[])
4820 // char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
4821 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
4822 _LOGD("parsing manifest for uninstallation: %s\n", manifest);
4824 manifest_x *mfx = NULL;
4827 mfx = pkgmgr_parser_process_manifest_xml(manifest);
4828 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
4830 _LOGD("Parsing Finished\n");
4832 // __streamFile(manifest, ACTION_UNINSTALL, temp, mfx->package);
4833 __ps_process_tag_parser(mfx, manifest, ACTION_UNINSTALL);
4835 __add_preload_info(mfx, manifest, GLOBAL_USER);
4836 _LOGD("Added preload infomation\n");
4838 ret = __ps_process_metadata_parser(mfx, ACTION_UNINSTALL);
4840 _LOGD("Removing metadata parser failed\n");
4842 ret = __ps_process_category_parser(mfx, ACTION_UNINSTALL);
4844 _LOGD("Creating category parser failed\n");
4846 ret = pkgmgr_parser_delete_manifest_info_from_db(mfx);
4848 _LOGD("DB Delete failed\n");
4850 _LOGD("DB Delete Success\n");
4852 pkgmgr_parser_free_manifest_xml(mfx);
4853 _LOGD("Free Done\n");
4860 API int pkgmgr_parser_parse_usr_manifest_for_uninstallation(const char *manifest, uid_t uid, char *const tagv[])
4862 // char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
4863 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
4864 _LOGD("parsing manifest for uninstallation: %s\n", manifest);
4866 manifest_x *mfx = NULL;
4869 mfx = pkgmgr_parser_usr_process_manifest_xml(manifest, uid);
4870 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
4872 _LOGD("Parsing Finished\n");
4874 // __streamFile(manifest, ACTION_UNINSTALL, temp, mfx->package);
4875 __ps_process_tag_parser(mfx, manifest, ACTION_UNINSTALL);
4877 ret = __ps_process_metadata_parser(mfx, ACTION_UNINSTALL);
4879 _LOGD("Removing metadata parser failed\n");
4881 ret = __ps_process_category_parser(mfx, ACTION_UNINSTALL);
4883 _LOGD("Creating category parser failed\n");
4885 ret = pkgmgr_parser_delete_manifest_info_from_usr_db(mfx, uid);
4887 _LOGD("DB Delete failed\n");
4889 _LOGD("DB Delete Success\n");
4891 ret = __ps_remove_appsvc_db(mfx, uid);
4893 _LOGD("Removing appsvc_db failed\n");
4895 _LOGD("Removing appsvc_db Success\n");
4897 pkgmgr_parser_free_manifest_xml(mfx);
4898 _LOGD("Free Done\n");
4904 API int pkgmgr_parser_parse_manifest_for_preload()
4906 return pkgmgr_parser_update_preload_info_in_db();
4909 API int pkgmgr_parser_parse_usr_manifest_for_preload(uid_t uid)
4911 return pkgmgr_parser_update_preload_info_in_usr_db(uid);
4915 API char *pkgmgr_parser_get_usr_manifest_file(const char *pkgid, uid_t uid)
4917 return __pkgid_to_manifest(pkgid, uid);
4920 API char *pkgmgr_parser_get_manifest_file(const char *pkgid)
4922 return __pkgid_to_manifest(pkgid, GLOBAL_USER);
4925 API int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
4927 return __ps_run_parser(docPtr, tag, ACTION_INSTALL, pkgid);
4930 API int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgid)
4932 return __ps_run_parser(docPtr, tag, ACTION_UPGRADE, pkgid);
4935 API int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
4937 return __ps_run_parser(docPtr, tag, ACTION_UNINSTALL, pkgid);
4940 #define SCHEMA_FILE SYSCONFDIR "/package-manager/preload/manifest.xsd"
4942 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
4944 if (manifest == NULL) {
4945 _LOGE("manifest file is NULL\n");
4946 return PMINFO_R_EINVAL;
4949 xmlSchemaParserCtxtPtr ctx;
4950 xmlSchemaValidCtxtPtr vctx;
4951 xmlSchemaPtr xschema;
4952 ctx = xmlSchemaNewParserCtxt(SCHEMA_FILE);
4954 _LOGE("xmlSchemaNewParserCtxt() Failed\n");
4955 return PMINFO_R_ERROR;
4957 xschema = xmlSchemaParse(ctx);
4958 if (xschema == NULL) {
4959 _LOGE("xmlSchemaParse() Failed\n");
4960 return PMINFO_R_ERROR;
4962 vctx = xmlSchemaNewValidCtxt(xschema);
4964 _LOGE("xmlSchemaNewValidCtxt() Failed\n");
4965 return PMINFO_R_ERROR;
4967 xmlSchemaSetValidErrors(vctx, (xmlSchemaValidityErrorFunc) fprintf, (xmlSchemaValidityWarningFunc) fprintf, stderr);
4968 ret = xmlSchemaValidateFile(vctx, manifest, 0);
4970 _LOGE("xmlSchemaValidateFile() failed\n");
4971 return PMINFO_R_ERROR;
4972 } else if (ret == 0) {
4973 _LOGE("Manifest is Valid\n");
4976 _LOGE("Manifest Validation Failed with error code %d\n", ret);
4977 return PMINFO_R_ERROR;
4983 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
4993 _LOGE("fork failed\n");
4998 int dev_null_fd = open ("/dev/null", O_RDWR);
4999 if (dev_null_fd >= 0)
5001 dup2 (dev_null_fd, 0);/*stdin*/
5002 dup2 (dev_null_fd, 1);/*stdout*/
5003 dup2 (dev_null_fd, 2);/*stderr*/
5006 if (execl("/usr/bin/xmllint", "xmllint", manifest, "--schema",
5007 SCHEMA_FILE, NULL) < 0) {
5008 _LOGE("execl error\n");
5018 while ((err = waitpid(pid, &status, WNOHANG)) != pid) {
5022 _LOGE("waitpid failed\n");
5028 if(WIFEXITED(status) && !WEXITSTATUS(status))