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>
37 #include "pkgmgr_parser.h"
38 #include "pkgmgr_parser_internal.h"
39 #include "pkgmgr_parser_db.h"
40 #include "pkgmgr-info.h"
41 #include "pkgmgr_parser_signature.h"
42 #include "pkgmgr-info-debug.h"
47 #define LOG_TAG "PKGMGR_PARSER"
49 #define MANIFEST_RW_DIRECTORY "/opt/share/packages"
50 #define MANIFEST_RO_DIRECTORY "/usr/share/packages"
51 #define ASCII(s) (const char *)s
52 #define XMLCHAR(s) (const xmlChar *)s
54 #define METADATA_PARSER_LIST SYSCONFDIR "/package-manager/parserlib/metadata/metadata_parser_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
74 /* plugin process_type */
76 PLUGIN_PRE_PROCESS = 0,
78 } PLUGIN_PROCESS_TYPE;
91 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label);
92 static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege);
93 static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privileges);
94 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile);
95 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed);
96 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation);
97 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri);
98 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime);
99 static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp);
100 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition);
101 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notifiation);
102 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category);
103 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata);
104 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission);
105 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility);
106 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution);
107 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request);
108 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define);
109 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc);
110 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions);
111 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare);
112 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon);
113 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author);
114 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description);
115 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability);
116 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license);
117 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol);
118 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol);
119 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication);
120 static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication);
121 static int __ps_process_font(xmlTextReaderPtr reader, font_x *font);
122 static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme);
123 static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon);
124 static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime);
125 static void __ps_free_label(label_x *label);
126 static void __ps_free_privilege(privilege_x *privilege);
127 static void __ps_free_privileges(privileges_x *privileges);
128 static void __ps_free_deviceprofile(deviceprofile_x * deviceprofile);
129 static void __ps_free_allowed(allowed_x *allowed);
130 static void __ps_free_operation(operation_x *operation);
131 static void __ps_free_uri(uri_x *uri);
132 static void __ps_free_mime(mime_x *mime);
133 static void __ps_free_subapp(subapp_x *subapp);
134 static void __ps_free_condition(condition_x *condition);
135 static void __ps_free_notification(notification_x *notifiation);
136 static void __ps_free_category(category_x *category);
137 static void __ps_free_metadata(metadata_x *metadata);
138 static void __ps_free_permission(permission_x *permission);
139 static void __ps_free_compatibility(compatibility_x *compatibility);
140 static void __ps_free_resolution(resolution_x *resolution);
141 static void __ps_free_request(request_x *request);
142 static void __ps_free_define(define_x *define);
143 static void __ps_free_appsvc(appsvc_x *appsvc);
144 static void __ps_free_launchconditions(launchconditions_x *launchconditions);
145 static void __ps_free_datashare(datashare_x *datashare);
146 static void __ps_free_icon(icon_x *icon);
147 static void __ps_free_author(author_x *author);
148 static void __ps_free_description(description_x *description);
149 static void __ps_free_capability(capability_x *capability);
150 static void __ps_free_license(license_x *license);
151 static void __ps_free_appcontrol(appcontrol_x *appcontrol);
152 static void __ps_free_datacontrol(datacontrol_x *datacontrol);
153 static void __ps_free_uiapplication(uiapplication_x *uiapplication);
154 static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication);
155 static void __ps_free_font(font_x *font);
156 static void __ps_free_theme(theme_x *theme);
157 static void __ps_free_daemon(daemon_x *daemon);
158 static void __ps_free_ime(ime_x *ime);
159 static char *__pkgid_to_manifest(const char *pkgid);
160 static int __next_child_element(xmlTextReaderPtr reader, int depth);
161 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx);
162 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx);
163 static void __str_trim(char *input);
164 static char *__get_parser_plugin(const char *type);
165 static int __ps_run_parser(xmlDocPtr docPtr, const char *tag, ACTION_TYPE action, const char *pkgid);
166 static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid);
167 static void __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgid);
168 static void __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid);
169 static int __validate_appid(const char *pkgid, const char *appid, char **newappid);
171 void *__open_lib_handle(char *tag)
173 char *lib_path = NULL;
174 void *lib_handle = NULL;
176 lib_path = __get_parser_plugin(tag);
177 retvm_if(!lib_path, NULL, "lib_path get fail");
179 lib_handle = dlopen(lib_path, RTLD_LAZY);
180 retvm_if(lib_handle == NULL, NULL, "dlopen is failed lib_path[%s]", lib_path);
185 void __close_lib_handle(void *lib_handle)
190 static void __str_trim(char *input)
192 char *trim_str = input;
197 while (*input != 0) {
198 if (!isspace(*input)) {
209 static int __validate_appid(const char *pkgid, const char *appid, char **newappid)
211 if (!pkgid || !appid || !newappid) {
212 _LOGD("Arg supplied is NULL\n");
215 int pkglen = strlen(pkgid);
216 int applen = strlen(appid);
220 if (strncmp(appid, ".", 1) == 0) {
221 len = pkglen + applen + 1;
222 newapp = calloc(1,len);
223 if (newapp == NULL) {
224 _LOGD("Malloc failed\n");
227 strncpy(newapp, pkgid, pkglen);
228 strncat(newapp, appid, applen);
229 _LOGD("new appid is %s\n", newapp);
233 if (applen < pkglen) {
234 _LOGD("app id is not proper\n");
236 #ifdef _VALIDATE_APPID_
242 if (!strcmp(appid, pkgid)) {
243 _LOGD("appid is proper\n");
247 else if (strncmp(appid, pkgid, pkglen) == 0) {
248 ptr = strstr(appid, pkgid);
250 if (strncmp(ptr, ".", 1) == 0) {
251 _LOGD("appid is proper\n");
256 _LOGD("appid is not proper\n");
258 #ifdef _VALIDATE_APPID_
265 _LOGD("appid is not proper\n");
267 #ifdef _VALIDATE_APPID_
276 static char * __get_tag_by_key(char *md_key)
280 if (md_key == NULL) {
281 _LOGD("md_key is NULL\n");
285 md_tag = strrchr(md_key, 47) + 1;
288 return strdup(md_tag);
291 static char *__get_metadata_parser_plugin(const char *type)
294 char buffer[1024] = { 0 };
295 char temp_path[1024] = { 0 };
299 _LOGE("invalid argument\n");
303 fp = fopen(PKG_PARSER_CONF_PATH, "r");
305 _LOGE("no matching metadata parser\n");
309 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
310 if (buffer[0] == '#')
315 if ((path = strstr(buffer, METADATA_PARSER_NAME)) != NULL) {
316 path = path + strlen(METADATA_PARSER_NAME);
321 memset(buffer, 0x00, 1024);
328 _LOGE("no matching [%s] [%s]\n", METADATA_PARSER_NAME,type);
332 snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
334 return strdup(temp_path);
337 static char *__get_category_parser_plugin(const char *type)
340 char buffer[1024] = { 0 };
341 char temp_path[1024] = { 0 };
345 _LOGE("invalid argument\n");
349 fp = fopen(PKG_PARSER_CONF_PATH, "r");
351 _LOGE("no matching metadata parser\n");
355 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
356 if (buffer[0] == '#')
361 if ((path = strstr(buffer, CATEGORY_PARSER_NAME)) != NULL) {
362 path = path + strlen(CATEGORY_PARSER_NAME);
367 memset(buffer, 0x00, 1024);
374 _LOGE("no matching [%s] [%s]\n", CATEGORY_PARSER_NAME,type);
378 snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
380 return strdup(temp_path);
383 static char *__get_parser_plugin(const char *type)
386 char buffer[1024] = { 0 };
387 char temp_path[1024] = { 0 };
391 _LOGE("invalid argument\n");
395 fp = fopen(PKG_PARSER_CONF_PATH, "r");
397 _LOGE("no matching backendlib\n");
401 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
402 if (buffer[0] == '#')
407 if ((path = strstr(buffer, PKG_PARSERLIB)) != NULL) {
408 path = path + strlen(PKG_PARSERLIB);
412 memset(buffer, 0x00, 1024);
419 _LOGE("no matching backendlib\n");
423 snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
425 return strdup(temp_path);
428 static int __ps_run_tag_parser(void *lib_handle, xmlDocPtr docPtr, const char *tag,
429 ACTION_TYPE action, const char *pkgid)
431 int (*plugin_install) (xmlDocPtr, const char *);
437 ac = "PKGMGR_PARSER_PLUGIN_INSTALL";
440 ac = "PKGMGR_PARSER_PLUGIN_UPGRADE";
442 case ACTION_UNINSTALL:
443 ac = "PKGMGR_PARSER_PLUGIN_UNINSTALL";
449 if ((plugin_install =
450 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
451 _LOGE("can not find symbol[%s] \n", ac);
455 ret = plugin_install(docPtr, pkgid);
456 _LOGD("tag parser[%s, %s] ACTION_TYPE[%d] result[%d]\n", pkgid, tag, action, ret);
462 static int __ps_run_metadata_parser(GList *md_list, const char *tag,
463 ACTION_TYPE action, const char *pkgid, const char *appid)
465 char *lib_path = NULL;
466 void *lib_handle = NULL;
467 int (*metadata_parser_plugin) (const char *, const char *, GList *);
473 ac = "PKGMGR_MDPARSER_PLUGIN_INSTALL";
476 ac = "PKGMGR_MDPARSER_PLUGIN_UPGRADE";
478 case ACTION_UNINSTALL:
479 ac = "PKGMGR_MDPARSER_PLUGIN_UNINSTALL";
485 lib_path = __get_metadata_parser_plugin(tag);
487 _LOGE("get %s parser fail\n", tag);
491 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
492 _LOGE("dlopen is failed lib_path[%s]\n", lib_path);
496 if ((metadata_parser_plugin =
497 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
498 _LOGE("can not find symbol[%s] \n",ac);
502 ret = metadata_parser_plugin(pkgid, appid, md_list);
504 _LOGD("[appid = %s, libpath = %s plugin fail\n", appid, lib_path);
506 _LOGD("[appid = %s, libpath = %s plugin success\n", appid, lib_path);
516 static int __ps_run_category_parser(GList *category_list, const char *tag,
517 ACTION_TYPE action, const char *pkgid, const char *appid)
519 char *lib_path = NULL;
520 void *lib_handle = NULL;
521 int (*category_parser_plugin) (const char *, const char *, GList *);
527 ac = "PKGMGR_CATEGORY_PARSER_PLUGIN_INSTALL";
530 ac = "PKGMGR_CATEGORY_PARSER_PLUGIN_UPGRADE";
532 case ACTION_UNINSTALL:
533 ac = "PKGMGR_CATEGORY_PARSER_PLUGIN_UNINSTALL";
539 lib_path = __get_category_parser_plugin(tag);
541 _LOGE("get %s parser fail\n", tag);
545 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
546 _LOGE("dlopen is failed lib_path[%s]\n", lib_path);
550 if ((category_parser_plugin =
551 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
552 _LOGE("can not find symbol[%s] \n",ac);
556 ret = category_parser_plugin(pkgid, appid, category_list);
558 _LOGD("[appid = %s, libpath = %s plugin fail\n", appid, lib_path);
560 _LOGD("[appid = %s, libpath = %s plugin success\n", appid, lib_path);
570 static int __ps_run_parser(xmlDocPtr docPtr, const char *tag,
571 ACTION_TYPE action, const char *pkgid)
573 char *lib_path = NULL;
574 void *lib_handle = NULL;
575 int (*plugin_install) (xmlDocPtr, const char *);
581 ac = "PKGMGR_PARSER_PLUGIN_INSTALL";
584 ac = "PKGMGR_PARSER_PLUGIN_UPGRADE";
586 case ACTION_UNINSTALL:
587 ac = "PKGMGR_PARSER_PLUGIN_UNINSTALL";
593 lib_path = __get_parser_plugin(tag);
598 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
599 _LOGE("dlopen is failed lib_path[%s]\n", lib_path);
602 if ((plugin_install =
603 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
604 _LOGE("can not find symbol[%s] \n", ac);
608 ret = plugin_install(docPtr, pkgid);
610 _LOGD("[pkgid = %s, libpath = %s plugin fail\n", pkgid, lib_path);
612 _LOGD("[pkgid = %s, libpath = %s plugin success\n", pkgid, lib_path);
622 static char *__pkgid_to_manifest(const char *pkgid)
628 _LOGE("pkgid is NULL");
632 size = strlen(MANIFEST_RW_DIRECTORY) + strlen(pkgid) + 10;
633 manifest = malloc(size);
634 if (manifest == NULL) {
638 memset(manifest, '\0', size);
639 snprintf(manifest, size, MANIFEST_RW_DIRECTORY "/%s.xml", pkgid);
641 if (access(manifest, F_OK)) {
642 snprintf(manifest, size, MANIFEST_RO_DIRECTORY "/%s.xml", pkgid);
648 static void __metadata_parser_clear_dir_list(GList* dir_list)
651 __metadata_t* detail = NULL;
654 list = g_list_first(dir_list);
656 detail = (__metadata_t *)list->data;
664 list = g_list_next(list);
666 g_list_free(dir_list);
670 static void __category_parser_clear_dir_list(GList* dir_list)
673 __category_t* detail = NULL;
676 list = g_list_first(dir_list);
678 detail = (__category_t *)list->data;
685 list = g_list_next(list);
687 g_list_free(dir_list);
691 static int __run_tag_parser_prestep(void *lib_handle, xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid)
696 if (xmlTextReaderDepth(reader) != 1) {
697 _LOGE("Node depth is not 1");
701 if (xmlTextReaderNodeType(reader) != 1) {
702 _LOGE("Node type is not 1");
706 const xmlChar *value;
707 name = xmlTextReaderConstName(reader);
709 _LOGE("TEST TEST TES\n");
710 name = BAD_CAST "--";
713 value = xmlTextReaderConstValue(reader);
715 if (xmlStrlen(value) > 40) {
716 _LOGD(" %.40s...", value);
722 name = xmlTextReaderConstName(reader);
724 _LOGE("TEST TEST TES\n");
725 name = BAD_CAST "--";
728 xmlDocPtr docPtr = xmlTextReaderCurrentDoc(reader);
729 xmlDocPtr copyDocPtr = xmlCopyDoc(docPtr, 1);
730 if (copyDocPtr == NULL)
732 xmlNode *rootElement = xmlDocGetRootElement(copyDocPtr);
733 if (rootElement == NULL)
735 xmlNode *cur_node = xmlFirstElementChild(rootElement);
736 if (cur_node == NULL)
738 xmlNode *temp = xmlTextReaderExpand(reader);
741 xmlNode *next_node = NULL;
742 while(cur_node != NULL) {
743 if ( (strcmp(ASCII(temp->name), ASCII(cur_node->name)) == 0) &&
744 (temp->line == cur_node->line) ) {
748 next_node = xmlNextElementSibling(cur_node);
749 xmlUnlinkNode(cur_node);
750 xmlFreeNode(cur_node);
751 cur_node = next_node;
754 if (cur_node == NULL)
756 next_node = xmlNextElementSibling(cur_node);
758 cur_node->next = NULL;
759 next_node->prev = NULL;
760 xmlFreeNodeList(next_node);
761 xmlSetTreeDoc(cur_node, copyDocPtr);
763 xmlSetTreeDoc(cur_node, copyDocPtr);
766 ret = __ps_run_tag_parser(lib_handle, copyDocPtr, ASCII(name), action, pkgid);
772 static int __run_metadata_parser_prestep (manifest_x *mfx, char *md_key, ACTION_TYPE action)
776 char buffer[1024] = { 0, };
777 uiapplication_x *up = mfx->uiapplication;
778 metadata_x *md = NULL;
781 GList *md_list = NULL;
782 __metadata_t *md_detail = NULL;
784 md_tag = __get_tag_by_key(md_key);
785 if (md_tag == NULL) {
786 _LOGD("md_tag is NULL\n");
795 //get glist of metadata key and value combination
796 memset(buffer, 0x00, 1024);
797 snprintf(buffer, 1024, "%s/", md_key);
798 if ((md->key && md->value) && (strncmp(md->key, md_key, strlen(md_key)) == 0) && (strncmp(buffer, md->key, strlen(buffer)) == 0)) {
799 md_detail = (__metadata_t*) calloc(1, sizeof(__metadata_t));
800 if (md_detail == NULL) {
801 _LOGD("Memory allocation failed\n");
805 md_detail->key = (char*) calloc(1, sizeof(char)*(strlen(md->key)+2));
806 if (md_detail->key == NULL) {
807 _LOGD("Memory allocation failed\n");
811 snprintf(md_detail->key, (strlen(md->key)+1), "%s", md->key);
813 md_detail->value = (char*) calloc(1, sizeof(char)*(strlen(md->value)+2));
814 if (md_detail->value == NULL) {
815 _LOGD("Memory allocation failed\n");
816 free(md_detail->key);
820 snprintf(md_detail->value, (strlen(md->value)+1), "%s", md->value);
822 md_list = g_list_append(md_list, (gpointer)md_detail);
828 //send glist to parser when tags for metadata plugin parser exist.
830 ret = __ps_run_metadata_parser(md_list, md_tag, action, mfx->package, up->appid);
832 _LOGD("metadata_parser failed[%d] for tag[%s]\n", ret, md_tag);
834 _LOGD("metadata_parser success for tag[%s]\n", md_tag);
836 __metadata_parser_clear_dir_list(md_list);
844 __metadata_parser_clear_dir_list(md_list);
852 static int __run_category_parser_prestep (manifest_x *mfx, char *category_key, ACTION_TYPE action)
856 char buffer[1024] = { 0, };
857 uiapplication_x *up = mfx->uiapplication;
858 category_x *category = NULL;
859 char *category_tag = NULL;
861 GList *category_list = NULL;
862 __category_t *category_detail = NULL;
864 category_tag = __get_tag_by_key(category_key);
865 if (category_tag == NULL) {
866 _LOGD("md_tag is NULL\n");
872 category = up->category;
873 while (category != NULL)
875 //get glist of category key and value combination
876 memset(buffer, 0x00, 1024);
877 snprintf(buffer, 1024, "%s/", category_key);
878 if ((category->name) && (strncmp(category->name, category_key, strlen(category_key)) == 0)) {
879 category_detail = (__category_t*) calloc(1, sizeof(__category_t));
880 if (category_detail == NULL) {
881 _LOGD("Memory allocation failed\n");
885 category_detail->name = (char*) calloc(1, sizeof(char)*(strlen(category->name)+2));
886 if (category_detail->name == NULL) {
887 _LOGD("Memory allocation failed\n");
888 free(category_detail);
891 snprintf(category_detail->name, (strlen(category->name)+1), "%s", category->name);
893 category_list = g_list_append(category_list, (gpointer)category_detail);
896 category = category->next;
899 //send glist to parser when tags for metadata plugin parser exist.
901 ret = __ps_run_category_parser(category_list, category_tag, action, mfx->package, up->appid);
903 _LOGD("category_parser failed[%d] for tag[%s]\n", ret, category_tag);
905 _LOGD("category_parser success for tag[%s]\n", category_tag);
907 __category_parser_clear_dir_list(category_list);
908 category_list = NULL;
915 __category_parser_clear_dir_list(category_list);
923 static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid)
928 // _LOGD("__run_parser_prestep");
930 if (xmlTextReaderDepth(reader) != 1) {
931 _LOGE("Node depth is not 1");
935 if (xmlTextReaderNodeType(reader) != 1) {
936 _LOGE("Node type is not 1");
940 const xmlChar *value;
941 name = xmlTextReaderConstName(reader);
943 _LOGE("TEST TEST TES\n");
944 name = BAD_CAST "--";
947 value = xmlTextReaderConstValue(reader);
948 _LOGD("%d %d %s %d %d",
949 xmlTextReaderDepth(reader),
950 xmlTextReaderNodeType(reader),
952 xmlTextReaderIsEmptyElement(reader), xmlTextReaderHasValue(reader));
955 if (xmlStrlen(value) > 40) {
956 _LOGD(" %.40s...", value);
962 name = xmlTextReaderConstName(reader);
964 _LOGE("TEST TEST TES\n");
965 name = BAD_CAST "--";
968 xmlDocPtr docPtr = xmlTextReaderCurrentDoc(reader);
969 _LOGD("docPtr->URL %s\n", (char *)docPtr->URL);
970 xmlDocPtr copyDocPtr = xmlCopyDoc(docPtr, 1);
971 if (copyDocPtr == NULL)
973 xmlNode *rootElement = xmlDocGetRootElement(copyDocPtr);
974 if (rootElement == NULL)
976 xmlNode *cur_node = xmlFirstElementChild(rootElement);
977 if (cur_node == NULL)
979 xmlNode *temp = xmlTextReaderExpand(reader);
982 xmlNode *next_node = NULL;
983 while(cur_node != NULL) {
984 if ( (strcmp(ASCII(temp->name), ASCII(cur_node->name)) == 0) &&
985 (temp->line == cur_node->line) ) {
989 next_node = xmlNextElementSibling(cur_node);
990 xmlUnlinkNode(cur_node);
991 xmlFreeNode(cur_node);
992 cur_node = next_node;
995 if (cur_node == NULL)
997 next_node = xmlNextElementSibling(cur_node);
999 cur_node->next = NULL;
1000 next_node->prev = NULL;
1001 xmlFreeNodeList(next_node);
1002 xmlSetTreeDoc(cur_node, copyDocPtr);
1004 xmlSetTreeDoc(cur_node, copyDocPtr);
1010 _LOGD("node type: %d, name: %s children->name: %s last->name: %s\n"
1011 "parent->name: %s next->name: %s prev->name: %s\n",
1012 cur_node->type, cur_node->name,
1013 cur_node->children ? cur_node->children->name : "NULL",
1014 cur_node->last ? cur_node->last->name : "NULL",
1015 cur_node->parent ? cur_node->parent->name : "NULL",
1016 cur_node->next ? cur_node->next->name : "NULL",
1017 cur_node->prev ? cur_node->prev->name : "NULL");
1019 FILE *fp = fopen("/opt/share/test.xml", "a");
1020 xmlDocDump(fp, copyDocPtr);
1025 ret = __ps_run_parser(copyDocPtr, ASCII(name), action, pkgid);
1032 __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgid)
1037 switch (xmlTextReaderNodeType(reader)) {
1038 case XML_READER_TYPE_END_ELEMENT:
1040 // _LOGD("XML_READER_TYPE_END_ELEMENT");
1044 case XML_READER_TYPE_ELEMENT:
1046 // Elements without closing tag don't receive
1047 // XML_READER_TYPE_END_ELEMENT event.
1049 const xmlChar *elementName =
1050 xmlTextReaderLocalName(reader);
1051 if (elementName == NULL) {
1052 // _LOGD("elementName %s\n", (char *)elementName);
1056 const xmlChar *nameSpace =
1057 xmlTextReaderConstNamespaceUri(reader);
1059 // _LOGD("nameSpace %s\n", (char *)nameSpace);
1062 _LOGD("XML_READER_TYPE_ELEMENT %s, %s\n",
1063 elementName ? elementName : "NULL",
1064 nameSpace ? nameSpace : "NULL");
1067 _LOGD("__run_parser_prestep pkgid[%s]\n", pkgid);
1068 __run_parser_prestep(reader, action, pkgid);
1072 for (tag = tagv[0]; tag; tag = tagv[++i])
1073 if (strcmp(tag, ASCII(elementName)) == 0) {
1074 _LOGD("__run_parser_prestep tag[%s] pkgid[%s]\n", tag, pkgid);
1075 __run_parser_prestep(reader,
1083 case XML_READER_TYPE_TEXT:
1084 case XML_READER_TYPE_CDATA:
1086 const xmlChar *value = xmlTextReaderConstValue(reader);
1088 // _LOGD("value %s\n", value);
1091 const xmlChar *lang = xmlTextReaderConstXmlLang(reader);
1093 // _LOGD("lang\n", lang);
1096 /* _LOGD("XML_READER_TYPE_TEXT %s, %s\n",
1097 value ? value : "NULL", lang ? lang : "NULL");
1102 // _LOGD("Ignoring Node of Type: %d", xmlTextReaderNodeType(reader));
1108 __processTag(void *lib_handle, xmlTextReaderPtr reader, ACTION_TYPE action, char *tag, const char *pkgid)
1110 switch (xmlTextReaderNodeType(reader)) {
1111 case XML_READER_TYPE_END_ELEMENT:
1115 case XML_READER_TYPE_ELEMENT:
1117 // Elements without closing tag don't receive
1118 const xmlChar *elementName =
1119 xmlTextReaderLocalName(reader);
1120 if (elementName == NULL) {
1124 if (strcmp(tag, ASCII(elementName)) == 0) {
1125 _LOGD("find : tag[%s] ACTION_TYPE[%d] pkg[%s]\n", tag, action, pkgid);
1126 __run_tag_parser_prestep(lib_handle, reader, action, pkgid);
1137 static int __parser_send_tag(void *lib_handle, ACTION_TYPE action, PLUGIN_PROCESS_TYPE process, const char *pkgid)
1139 int (*plugin_install) (const char *);
1143 if (process == PLUGIN_PRE_PROCESS) {
1145 case ACTION_INSTALL:
1146 ac = "PKGMGR_PARSER_PLUGIN_PRE_INSTALL";
1148 case ACTION_UPGRADE:
1149 ac = "PKGMGR_PARSER_PLUGIN_PRE_UPGRADE";
1151 case ACTION_UNINSTALL:
1152 ac = "PKGMGR_PARSER_PLUGIN_PRE_UNINSTALL";
1157 } else if (process == PLUGIN_POST_PROCESS) {
1159 case ACTION_INSTALL:
1160 ac = "PKGMGR_PARSER_PLUGIN_POST_INSTALL";
1162 case ACTION_UPGRADE:
1163 ac = "PKGMGR_PARSER_PLUGIN_POST_UPGRADE";
1165 case ACTION_UNINSTALL:
1166 ac = "PKGMGR_PARSER_PLUGIN_POST_UNINSTALL";
1174 if ((plugin_install =
1175 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
1179 ret = plugin_install(pkgid);
1183 static void __plugin_send_tag(const char *tag, ACTION_TYPE action, PLUGIN_PROCESS_TYPE process, const char *pkgid)
1185 char *lib_path = NULL;
1186 void *lib_handle = NULL;
1187 int (*plugin_install) (const char *);
1191 if (process == PLUGIN_PRE_PROCESS) {
1193 case ACTION_INSTALL:
1194 ac = "PKGMGR_PARSER_PLUGIN_PRE_INSTALL";
1196 case ACTION_UPGRADE:
1197 ac = "PKGMGR_PARSER_PLUGIN_PRE_UPGRADE";
1199 case ACTION_UNINSTALL:
1200 ac = "PKGMGR_PARSER_PLUGIN_PRE_UNINSTALL";
1205 } else if (process == PLUGIN_POST_PROCESS) {
1207 case ACTION_INSTALL:
1208 ac = "PKGMGR_PARSER_PLUGIN_POST_INSTALL";
1210 case ACTION_UPGRADE:
1211 ac = "PKGMGR_PARSER_PLUGIN_POST_UPGRADE";
1213 case ACTION_UNINSTALL:
1214 ac = "PKGMGR_PARSER_PLUGIN_POST_UNINSTALL";
1222 lib_path = __get_parser_plugin(tag);
1227 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
1228 _LOGE("dlopen is failed lib_path[%s] for tag[%s]\n", lib_path, tag);
1231 if ((plugin_install =
1232 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
1233 // _LOGE("can not find symbol[%s] for tag[%s] \n", ac, tag);
1237 ret = plugin_install(pkgid);
1239 _LOGD("[PLUGIN_PROCESS_TYPE[%d] pkgid=%s, tag=%s plugin fail\n", process, pkgid, tag);
1241 _LOGD("[PLUGIN_PROCESS_TYPE[%d] pkgid=%s, tag=%s plugin success\n", process, pkgid, tag);
1247 dlclose(lib_handle);
1251 __plugin_process_tag(char *const tag_list[], ACTION_TYPE action, PLUGIN_PROCESS_TYPE process, const char *pkgid)
1256 for (tag = tag_list[0]; tag; tag = tag_list[++i])
1257 __plugin_send_tag(tag, action, process, pkgid);
1262 __plugin_save_tag(xmlTextReaderPtr reader, char *const tagv[], char *tag_list[])
1266 static int pre_cnt=0;
1268 switch (xmlTextReaderNodeType(reader)) {
1269 case XML_READER_TYPE_ELEMENT:
1271 const xmlChar *elementName = xmlTextReaderLocalName(reader);
1272 if (elementName == NULL) {
1276 for (tag = tag_list[0]; tag; tag = tag_list[++i])
1277 if (strcmp(ASCII(elementName), tag) == 0) {
1281 for (tag = tagv[0]; tag; tag = tagv[++i])
1282 if (strcmp(tag, ASCII(elementName)) == 0) {
1283 tag_list[pre_cnt++] = tag;
1289 // _LOGD("Ignoring Node of Type: %d", xmlTextReaderNodeType(reader));
1295 __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid)
1297 xmlTextReaderPtr reader;
1300 __plugin_process_tag(tagv, action, PLUGIN_PRE_PROCESS, pkgid);
1302 docPtr = xmlReadFile(filename, NULL, 0);
1303 reader = xmlReaderWalker(docPtr);
1304 if (reader != NULL) {
1305 ret = xmlTextReaderRead(reader);
1307 __processNode(reader, action, tagv, pkgid);
1308 ret = xmlTextReaderRead(reader);
1310 xmlFreeTextReader(reader);
1313 _LOGD("%s : failed to parse", filename);
1316 _LOGD("Unable to open %s", filename);
1319 __plugin_process_tag(tagv, action, PLUGIN_POST_PROCESS, pkgid);
1322 static int __next_child_element(xmlTextReaderPtr reader, int depth)
1324 int ret = xmlTextReaderRead(reader);
1325 int cur = xmlTextReaderDepth(reader);
1328 switch (xmlTextReaderNodeType(reader)) {
1329 case XML_READER_TYPE_ELEMENT:
1330 if (cur == depth + 1)
1333 case XML_READER_TYPE_TEXT:
1334 /*text is handled by each function separately*/
1335 if (cur == depth + 1)
1338 case XML_READER_TYPE_END_ELEMENT:
1347 ret = xmlTextReaderRead(reader);
1348 cur = xmlTextReaderDepth(reader);
1353 static bool __check_action_fota(char *const tagv[])
1356 char delims[] = "=";
1357 char *ret_result = NULL;
1364 for (tag = strdup(tagv[0]); tag != NULL; ) {
1365 ret_result = strtok(tag, delims);
1367 /*check tag : fota is true */
1368 if (strcmp(ret_result, "fota") == 0) {
1369 ret_result = strtok(NULL, delims);
1370 if (strcmp(ret_result, "true") == 0) {
1374 _LOGD("tag process [%s]is not defined\n", ret_result);
1378 /*check next value*/
1379 if (tagv[++i] != NULL)
1380 tag = strdup(tagv[i]);
1382 _LOGD("tag process success...%d\n" , ret);
1390 static void __ps_free_category(category_x *category)
1392 if (category == NULL)
1394 if (category->name) {
1395 free((void *)category->name);
1396 category->name = NULL;
1398 free((void*)category);
1402 static void __ps_free_privilege(privilege_x *privilege)
1404 if (privilege == NULL)
1406 if (privilege->text) {
1407 free((void *)privilege->text);
1408 privilege->text = NULL;
1410 free((void*)privilege);
1414 static void __ps_free_privileges(privileges_x *privileges)
1416 if (privileges == NULL)
1419 if (privileges->privilege) {
1420 privilege_x *privilege = privileges->privilege;
1421 privilege_x *tmp = NULL;
1422 while(privilege != NULL) {
1423 tmp = privilege->next;
1424 __ps_free_privilege(privilege);
1428 free((void*)privileges);
1432 static void __ps_free_metadata(metadata_x *metadata)
1434 if (metadata == NULL)
1436 if (metadata->key) {
1437 free((void *)metadata->key);
1438 metadata->key = NULL;
1440 if (metadata->value) {
1441 free((void *)metadata->value);
1442 metadata->value = NULL;
1444 free((void*)metadata);
1448 static void __ps_free_permission(permission_x *permission)
1450 if (permission == NULL)
1452 if (permission->type) {
1453 free((void *)permission->type);
1454 permission->type = NULL;
1456 if (permission->value) {
1457 free((void *)permission->value);
1458 permission->value = NULL;
1460 free((void*)permission);
1464 static void __ps_free_icon(icon_x *icon)
1469 free((void *)icon->text);
1473 free((void *)icon->lang);
1477 free((void *)icon->name);
1480 if (icon->section) {
1481 free((void *)icon->section);
1482 icon->section = NULL;
1485 free((void *)icon->size);
1488 if (icon->resolution) {
1489 free((void *)icon->resolution);
1490 icon->resolution = NULL;
1496 static void __ps_free_image(image_x *image)
1501 free((void *)image->text);
1505 free((void *)image->lang);
1509 free((void *)image->name);
1512 if (image->section) {
1513 free((void *)image->section);
1514 image->section = NULL;
1520 static void __ps_free_operation(operation_x *operation)
1522 if (operation == NULL)
1524 if (operation->text) {
1525 free((void *)operation->text);
1526 operation->text = NULL;
1528 free((void*)operation);
1532 static void __ps_free_uri(uri_x *uri)
1537 free((void *)uri->text);
1544 static void __ps_free_mime(mime_x *mime)
1549 free((void *)mime->text);
1556 static void __ps_free_subapp(subapp_x *subapp)
1561 free((void *)subapp->text);
1562 subapp->text = NULL;
1564 free((void*)subapp);
1568 static void __ps_free_condition(condition_x *condition)
1570 if (condition == NULL)
1572 if (condition->text) {
1573 free((void *)condition->text);
1574 condition->text = NULL;
1576 if (condition->name) {
1577 free((void *)condition->name);
1578 condition->name = NULL;
1580 free((void*)condition);
1584 static void __ps_free_notification(notification_x *notification)
1586 if (notification == NULL)
1588 if (notification->text) {
1589 free((void *)notification->text);
1590 notification->text = NULL;
1592 if (notification->name) {
1593 free((void *)notification->name);
1594 notification->name = NULL;
1596 free((void*)notification);
1597 notification = NULL;
1600 static void __ps_free_compatibility(compatibility_x *compatibility)
1602 if (compatibility == NULL)
1604 if (compatibility->text) {
1605 free((void *)compatibility->text);
1606 compatibility->text = NULL;
1608 if (compatibility->name) {
1609 free((void *)compatibility->name);
1610 compatibility->name = NULL;
1612 free((void*)compatibility);
1613 compatibility = NULL;
1616 static void __ps_free_resolution(resolution_x *resolution)
1618 if (resolution == NULL)
1620 if (resolution->mimetype) {
1621 free((void *)resolution->mimetype);
1622 resolution->mimetype = NULL;
1624 if (resolution->urischeme) {
1625 free((void *)resolution->urischeme);
1626 resolution->urischeme = NULL;
1628 free((void*)resolution);
1632 static void __ps_free_capability(capability_x *capability)
1634 if (capability == NULL)
1636 if (capability->operationid) {
1637 free((void *)capability->operationid);
1638 capability->operationid = NULL;
1641 if (capability->resolution) {
1642 resolution_x *resolution = capability->resolution;
1643 resolution_x *tmp = NULL;
1644 while(resolution != NULL) {
1645 tmp = resolution->next;
1646 __ps_free_resolution(resolution);
1650 free((void*)capability);
1654 static void __ps_free_allowed(allowed_x *allowed)
1656 if (allowed == NULL)
1658 if (allowed->name) {
1659 free((void *)allowed->name);
1660 allowed->name = NULL;
1662 if (allowed->text) {
1663 free((void *)allowed->text);
1664 allowed->text = NULL;
1666 free((void*)allowed);
1670 static void __ps_free_request(request_x *request)
1672 if (request == NULL)
1674 if (request->text) {
1675 free((void *)request->text);
1676 request->text = NULL;
1678 free((void*)request);
1682 static void __ps_free_datacontrol(datacontrol_x *datacontrol)
1684 if (datacontrol == NULL)
1686 if (datacontrol->providerid) {
1687 free((void *)datacontrol->providerid);
1688 datacontrol->providerid = NULL;
1691 if (datacontrol->capability) {
1692 capability_x *capability = datacontrol->capability;
1693 capability_x *tmp = NULL;
1694 while(capability != NULL) {
1695 tmp = capability->next;
1696 __ps_free_capability(capability);
1700 free((void*)datacontrol);
1704 static void __ps_free_launchconditions(launchconditions_x *launchconditions)
1706 if (launchconditions == NULL)
1708 if (launchconditions->text) {
1709 free((void *)launchconditions->text);
1710 launchconditions->text = NULL;
1713 if (launchconditions->condition) {
1714 condition_x *condition = launchconditions->condition;
1715 condition_x *tmp = NULL;
1716 while(condition != NULL) {
1717 tmp = condition->next;
1718 __ps_free_condition(condition);
1722 free((void*)launchconditions);
1723 launchconditions = NULL;
1726 static void __ps_free_appcontrol(appcontrol_x *appcontrol)
1728 if (appcontrol == NULL)
1730 if (appcontrol->text) {
1731 free((void *)appcontrol->text);
1732 appcontrol->text = NULL;
1735 if (appcontrol->operation) {
1736 operation_x *operation = appcontrol->operation;
1737 operation_x *tmp = NULL;
1738 while(operation != NULL) {
1739 tmp = operation->next;
1740 __ps_free_operation(operation);
1745 if (appcontrol->uri) {
1746 uri_x *uri = appcontrol->uri;
1748 while(uri != NULL) {
1755 if (appcontrol->mime) {
1756 mime_x *mime = appcontrol->mime;
1758 while(mime != NULL) {
1760 __ps_free_mime(mime);
1765 if (appcontrol->subapp) {
1766 subapp_x *subapp = appcontrol->subapp;
1767 subapp_x *tmp = NULL;
1768 while(subapp != NULL) {
1770 __ps_free_subapp(subapp);
1774 free((void*)appcontrol);
1778 static void __ps_free_appsvc(appsvc_x *appsvc)
1783 free((void *)appsvc->text);
1784 appsvc->text = NULL;
1787 if (appsvc->operation) {
1788 operation_x *operation = appsvc->operation;
1789 operation_x *tmp = NULL;
1790 while(operation != NULL) {
1791 tmp = operation->next;
1792 __ps_free_operation(operation);
1798 uri_x *uri = appsvc->uri;
1800 while(uri != NULL) {
1808 mime_x *mime = appsvc->mime;
1810 while(mime != NULL) {
1812 __ps_free_mime(mime);
1817 if (appsvc->subapp) {
1818 subapp_x *subapp = appsvc->subapp;
1819 subapp_x *tmp = NULL;
1820 while(subapp != NULL) {
1822 __ps_free_subapp(subapp);
1826 free((void*)appsvc);
1830 static void __ps_free_deviceprofile(deviceprofile_x *deviceprofile)
1835 static void __ps_free_define(define_x *define)
1840 free((void *)define->path);
1841 define->path = NULL;
1844 if (define->request) {
1845 request_x *request = define->request;
1846 request_x *tmp = NULL;
1847 while(request != NULL) {
1848 tmp = request->next;
1849 __ps_free_request(request);
1854 if (define->allowed) {
1855 allowed_x *allowed = define->allowed;
1856 allowed_x *tmp = NULL;
1857 while(allowed != NULL) {
1858 tmp = allowed->next;
1859 __ps_free_allowed(allowed);
1863 free((void*)define);
1867 static void __ps_free_datashare(datashare_x *datashare)
1869 if (datashare == NULL)
1872 if (datashare->define) {
1873 define_x *define = datashare->define;
1874 define_x *tmp = NULL;
1875 while(define != NULL) {
1877 __ps_free_define(define);
1882 if (datashare->request) {
1883 request_x *request = datashare->request;
1884 request_x *tmp = NULL;
1885 while(request != NULL) {
1886 tmp = request->next;
1887 __ps_free_request(request);
1891 free((void*)datashare);
1895 static void __ps_free_label(label_x *label)
1900 free((void *)label->name);
1904 free((void *)label->text);
1908 free((void *)label->lang);
1915 static void __ps_free_author(author_x *author)
1919 if (author->email) {
1920 free((void *)author->email);
1921 author->email = NULL;
1924 free((void *)author->text);
1925 author->text = NULL;
1928 free((void *)author->href);
1929 author->href = NULL;
1932 free((void *)author->lang);
1933 author->lang = NULL;
1935 free((void*)author);
1939 static void __ps_free_description(description_x *description)
1941 if (description == NULL)
1943 if (description->name) {
1944 free((void *)description->name);
1945 description->name = NULL;
1947 if (description->text) {
1948 free((void *)description->text);
1949 description->text = NULL;
1951 if (description->lang) {
1952 free((void *)description->lang);
1953 description->lang = NULL;
1955 free((void*)description);
1959 static void __ps_free_license(license_x *license)
1961 if (license == NULL)
1963 if (license->text) {
1964 free((void *)license->text);
1965 license->text = NULL;
1967 if (license->lang) {
1968 free((void *)license->lang);
1969 license->lang = NULL;
1971 free((void*)license);
1975 static void __ps_free_uiapplication(uiapplication_x *uiapplication)
1977 if (uiapplication == NULL)
1979 if (uiapplication->exec) {
1980 free((void *)uiapplication->exec);
1981 uiapplication->exec = NULL;
1983 if (uiapplication->appid) {
1984 free((void *)uiapplication->appid);
1985 uiapplication->appid = NULL;
1987 if (uiapplication->nodisplay) {
1988 free((void *)uiapplication->nodisplay);
1989 uiapplication->nodisplay = NULL;
1991 if (uiapplication->multiple) {
1992 free((void *)uiapplication->multiple);
1993 uiapplication->multiple = NULL;
1995 if (uiapplication->type) {
1996 free((void *)uiapplication->type);
1997 uiapplication->type = NULL;
1999 if (uiapplication->categories) {
2000 free((void *)uiapplication->categories);
2001 uiapplication->categories = NULL;
2003 if (uiapplication->extraid) {
2004 free((void *)uiapplication->extraid);
2005 uiapplication->extraid = NULL;
2007 if (uiapplication->taskmanage) {
2008 free((void *)uiapplication->taskmanage);
2009 uiapplication->taskmanage = NULL;
2011 if (uiapplication->enabled) {
2012 free((void *)uiapplication->enabled);
2013 uiapplication->enabled = NULL;
2015 if (uiapplication->hwacceleration) {
2016 free((void *)uiapplication->hwacceleration);
2017 uiapplication->hwacceleration = NULL;
2019 if (uiapplication->screenreader) {
2020 free((void *)uiapplication->screenreader);
2021 uiapplication->screenreader = NULL;
2023 if (uiapplication->mainapp) {
2024 free((void *)uiapplication->mainapp);
2025 uiapplication->mainapp = NULL;
2027 if (uiapplication->recentimage) {
2028 free((void *)uiapplication->recentimage);
2029 uiapplication->recentimage = NULL;
2031 if (uiapplication->package) {
2032 free((void *)uiapplication->package);
2033 uiapplication->package = NULL;
2035 if (uiapplication->launchcondition) {
2036 free((void *)uiapplication->launchcondition);
2037 uiapplication->launchcondition = NULL;
2040 if (uiapplication->label) {
2041 label_x *label = uiapplication->label;
2042 label_x *tmp = NULL;
2043 while(label != NULL) {
2045 __ps_free_label(label);
2050 if (uiapplication->icon) {
2051 icon_x *icon = uiapplication->icon;
2053 while(icon != NULL) {
2055 __ps_free_icon(icon);
2060 if (uiapplication->image) {
2061 image_x *image = uiapplication->image;
2062 image_x *tmp = NULL;
2063 while(image != NULL) {
2065 __ps_free_image(image);
2070 if (uiapplication->appcontrol) {
2071 appcontrol_x *appcontrol = uiapplication->appcontrol;
2072 appcontrol_x *tmp = NULL;
2073 while(appcontrol != NULL) {
2074 tmp = appcontrol->next;
2075 __ps_free_appcontrol(appcontrol);
2079 /*Free LaunchConditions*/
2080 if (uiapplication->launchconditions) {
2081 launchconditions_x *launchconditions = uiapplication->launchconditions;
2082 launchconditions_x *tmp = NULL;
2083 while(launchconditions != NULL) {
2084 tmp = launchconditions->next;
2085 __ps_free_launchconditions(launchconditions);
2086 launchconditions = tmp;
2089 /*Free Notification*/
2090 if (uiapplication->notification) {
2091 notification_x *notification = uiapplication->notification;
2092 notification_x *tmp = NULL;
2093 while(notification != NULL) {
2094 tmp = notification->next;
2095 __ps_free_notification(notification);
2100 if (uiapplication->datashare) {
2101 datashare_x *datashare = uiapplication->datashare;
2102 datashare_x *tmp = NULL;
2103 while(datashare != NULL) {
2104 tmp = datashare->next;
2105 __ps_free_datashare(datashare);
2110 if (uiapplication->appsvc) {
2111 appsvc_x *appsvc = uiapplication->appsvc;
2112 appsvc_x *tmp = NULL;
2113 while(appsvc != NULL) {
2115 __ps_free_appsvc(appsvc);
2120 if (uiapplication->category) {
2121 category_x *category = uiapplication->category;
2122 category_x *tmp = NULL;
2123 while(category != NULL) {
2124 tmp = category->next;
2125 __ps_free_category(category);
2130 if (uiapplication->metadata) {
2131 metadata_x *metadata = uiapplication->metadata;
2132 metadata_x *tmp = NULL;
2133 while(metadata != NULL) {
2134 tmp = metadata->next;
2135 __ps_free_metadata(metadata);
2140 if (uiapplication->permission) {
2141 permission_x *permission = uiapplication->permission;
2142 permission_x *tmp = NULL;
2143 while(permission != NULL) {
2144 tmp = permission->next;
2145 __ps_free_permission(permission);
2149 /* _PRODUCT_LAUNCHING_ENHANCED_ START */
2150 if (uiapplication->indicatordisplay) {
2151 free((void *)uiapplication->indicatordisplay);
2152 uiapplication->indicatordisplay = NULL;
2154 if (uiapplication->portraitimg) {
2155 free((void *)uiapplication->portraitimg);
2156 uiapplication->portraitimg = NULL;
2158 if (uiapplication->landscapeimg) {
2159 free((void *)uiapplication->landscapeimg);
2160 uiapplication->landscapeimg = NULL;
2162 /* _PRODUCT_LAUNCHING_ENHANCED_ END */
2163 if (uiapplication->guestmode_visibility) {
2164 free((void *)uiapplication->guestmode_visibility);
2165 uiapplication->guestmode_visibility = NULL;
2167 if (uiapplication->app_component) {
2168 free((void *)uiapplication->app_component);
2169 uiapplication->app_component = NULL;
2171 if (uiapplication->permission_type) {
2172 free((void *)uiapplication->permission_type);
2173 uiapplication->permission_type = NULL;
2175 if (uiapplication->component_type) {
2176 free((void *)uiapplication->component_type);
2177 uiapplication->component_type = NULL;
2179 if (uiapplication->preload) {
2180 free((void *)uiapplication->preload);
2181 uiapplication->preload = NULL;
2183 if (uiapplication->submode) {
2184 free((void *)uiapplication->submode);
2185 uiapplication->submode = NULL;
2187 if (uiapplication->submode_mainid) {
2188 free((void *)uiapplication->submode_mainid);
2189 uiapplication->submode_mainid = NULL;
2192 free((void*)uiapplication);
2193 uiapplication = NULL;
2196 static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication)
2198 if (serviceapplication == NULL)
2200 if (serviceapplication->exec) {
2201 free((void *)serviceapplication->exec);
2202 serviceapplication->exec = NULL;
2204 if (serviceapplication->appid) {
2205 free((void *)serviceapplication->appid);
2206 serviceapplication->appid = NULL;
2208 if (serviceapplication->onboot) {
2209 free((void *)serviceapplication->onboot);
2210 serviceapplication->onboot = NULL;
2212 if (serviceapplication->autorestart) {
2213 free((void *)serviceapplication->autorestart);
2214 serviceapplication->autorestart = NULL;
2216 if (serviceapplication->type) {
2217 free((void *)serviceapplication->type);
2218 serviceapplication->type = NULL;
2220 if (serviceapplication->enabled) {
2221 free((void *)serviceapplication->enabled);
2222 serviceapplication->enabled = NULL;
2224 if (serviceapplication->package) {
2225 free((void *)serviceapplication->package);
2226 serviceapplication->package = NULL;
2228 if (serviceapplication->permission_type) {
2229 free((void *)serviceapplication->permission_type);
2230 serviceapplication->permission_type = NULL;
2233 if (serviceapplication->label) {
2234 label_x *label = serviceapplication->label;
2235 label_x *tmp = NULL;
2236 while(label != NULL) {
2238 __ps_free_label(label);
2243 if (serviceapplication->icon) {
2244 icon_x *icon = serviceapplication->icon;
2246 while(icon != NULL) {
2248 __ps_free_icon(icon);
2253 if (serviceapplication->appcontrol) {
2254 appcontrol_x *appcontrol = serviceapplication->appcontrol;
2255 appcontrol_x *tmp = NULL;
2256 while(appcontrol != NULL) {
2257 tmp = appcontrol->next;
2258 __ps_free_appcontrol(appcontrol);
2262 /*Free DataControl*/
2263 if (serviceapplication->datacontrol) {
2264 datacontrol_x *datacontrol = serviceapplication->datacontrol;
2265 datacontrol_x *tmp = NULL;
2266 while(datacontrol != NULL) {
2267 tmp = datacontrol->next;
2268 __ps_free_datacontrol(datacontrol);
2272 /*Free LaunchConditions*/
2273 if (serviceapplication->launchconditions) {
2274 launchconditions_x *launchconditions = serviceapplication->launchconditions;
2275 launchconditions_x *tmp = NULL;
2276 while(launchconditions != NULL) {
2277 tmp = launchconditions->next;
2278 __ps_free_launchconditions(launchconditions);
2279 launchconditions = tmp;
2282 /*Free Notification*/
2283 if (serviceapplication->notification) {
2284 notification_x *notification = serviceapplication->notification;
2285 notification_x *tmp = NULL;
2286 while(notification != NULL) {
2287 tmp = notification->next;
2288 __ps_free_notification(notification);
2293 if (serviceapplication->datashare) {
2294 datashare_x *datashare = serviceapplication->datashare;
2295 datashare_x *tmp = NULL;
2296 while(datashare != NULL) {
2297 tmp = datashare->next;
2298 __ps_free_datashare(datashare);
2303 if (serviceapplication->appsvc) {
2304 appsvc_x *appsvc = serviceapplication->appsvc;
2305 appsvc_x *tmp = NULL;
2306 while(appsvc != NULL) {
2308 __ps_free_appsvc(appsvc);
2313 if (serviceapplication->category) {
2314 category_x *category = serviceapplication->category;
2315 category_x *tmp = NULL;
2316 while(category != NULL) {
2317 tmp = category->next;
2318 __ps_free_category(category);
2323 if (serviceapplication->metadata) {
2324 metadata_x *metadata = serviceapplication->metadata;
2325 metadata_x *tmp = NULL;
2326 while(metadata != NULL) {
2327 tmp = metadata->next;
2328 __ps_free_metadata(metadata);
2333 if (serviceapplication->permission) {
2334 permission_x *permission = serviceapplication->permission;
2335 permission_x *tmp = NULL;
2336 while(permission != NULL) {
2337 tmp = permission->next;
2338 __ps_free_permission(permission);
2342 free((void*)serviceapplication);
2343 serviceapplication = NULL;
2346 static void __ps_free_font(font_x *font)
2351 free((void *)font->name);
2355 free((void *)font->text);
2362 static void __ps_free_theme(theme_x *theme)
2367 free((void *)theme->name);
2371 free((void *)theme->text);
2378 static void __ps_free_daemon(daemon_x *daemon)
2383 free((void *)daemon->name);
2384 daemon->name = NULL;
2387 free((void *)daemon->text);
2388 daemon->text = NULL;
2390 free((void*)daemon);
2394 static void __ps_free_ime(ime_x *ime)
2399 free((void *)ime->name);
2403 free((void *)ime->text);
2410 int __ps_process_tag_parser(manifest_x *mfx, const char *filename, ACTION_TYPE action)
2412 xmlTextReaderPtr reader;
2416 void *lib_handle = NULL;
2417 char tag[PKG_STRING_LEN_MAX] = { 0 };
2419 fp = fopen(TAG_PARSER_LIST, "r");
2420 retvm_if(fp == NULL, PMINFO_R_ERROR, "no preload list");
2422 while (fgets(tag, sizeof(tag), fp) != NULL) {
2425 lib_handle = __open_lib_handle(tag);
2426 if (lib_handle == NULL)
2429 ret = __parser_send_tag(lib_handle, action, PLUGIN_PRE_PROCESS, mfx->package);
2430 _LOGD("PLUGIN_PRE_PROCESS[%s, %s] ACTION_TYPE[%d] result[%d]\n", mfx->package, tag, action, ret);
2432 docPtr = xmlReadFile(filename, NULL, 0);
2433 reader = xmlReaderWalker(docPtr);
2434 if (reader != NULL) {
2435 ret = xmlTextReaderRead(reader);
2437 __processTag(lib_handle, reader, action, tag, mfx->package);
2438 ret = xmlTextReaderRead(reader);
2440 xmlFreeTextReader(reader);
2443 _LOGD("%s : failed to parse", filename);
2446 _LOGD("Unable to open %s", filename);
2449 ret = __parser_send_tag(lib_handle, action, PLUGIN_POST_PROCESS, mfx->package);
2450 _LOGD("PLUGIN_POST_PROCESS[%s, %s] ACTION_TYPE[%d] result[%d]\n", mfx->package, tag, action, ret);
2452 __close_lib_handle(lib_handle);
2454 memset(tag, 0x00, sizeof(tag));
2463 int __ps_process_metadata_parser(manifest_x *mfx, ACTION_TYPE action)
2467 char md_key[PKG_STRING_LEN_MAX] = { 0 };
2469 fp = fopen(METADATA_PARSER_LIST, "r");
2471 _LOGD("no preload list\n");
2475 while (fgets(md_key, sizeof(md_key), fp) != NULL) {
2477 ret = __run_metadata_parser_prestep(mfx, md_key, action);
2479 memset(md_key, 0x00, sizeof(md_key));
2488 int __ps_process_category_parser(manifest_x *mfx, ACTION_TYPE action)
2492 char category_key[PKG_STRING_LEN_MAX] = { 0 };
2494 fp = fopen(CATEGORY_PARSER_LIST, "r");
2496 _LOGD("no category parser list\n");
2500 while (fgets(category_key, sizeof(category_key), fp) != NULL) {
2501 __str_trim(category_key);
2502 ret = __run_category_parser_prestep(mfx, category_key, action);
2504 memset(category_key, 0x00, sizeof(category_key));
2513 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed)
2515 xmlTextReaderRead(reader);
2516 if (xmlTextReaderValue(reader))
2517 allowed->text = ASCII(xmlTextReaderValue(reader));
2521 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation)
2523 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2524 operation->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2525 /* Text does not exist. Only attribute exists
2526 xmlTextReaderRead(reader);
2527 if (xmlTextReaderValue(reader))
2528 operation->text = ASCII(xmlTextReaderValue(reader));
2533 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri)
2535 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2536 uri->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2537 /* Text does not exist. Only attribute exists
2538 xmlTextReaderRead(reader);
2539 if (xmlTextReaderValue(reader))
2540 uri->text = ASCII(xmlTextReaderValue(reader));
2545 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime)
2547 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2548 mime->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2549 /* Text does not exist. Only attribute exists
2550 xmlTextReaderRead(reader);
2551 if (xmlTextReaderValue(reader))
2552 mime->text = ASCII(xmlTextReaderValue(reader));
2557 static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp)
2559 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2560 subapp->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2561 /* Text does not exist. Only attribute exists
2562 xmlTextReaderRead(reader);
2563 if (xmlTextReaderValue(reader))
2564 mime->text = ASCII(xmlTextReaderValue(reader));
2569 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition)
2571 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2572 condition->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2573 xmlTextReaderRead(reader);
2574 if (xmlTextReaderValue(reader))
2575 condition->text = ASCII(xmlTextReaderValue(reader));
2579 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notification)
2581 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2582 notification->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2583 xmlTextReaderRead(reader);
2584 if (xmlTextReaderValue(reader))
2585 notification->text = ASCII(xmlTextReaderValue(reader));
2589 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category)
2591 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2592 category->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2596 static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege)
2598 xmlTextReaderRead(reader);
2599 if (xmlTextReaderValue(reader)) {
2600 privilege->text = ASCII(xmlTextReaderValue(reader));
2605 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata)
2607 if (xmlTextReaderGetAttribute(reader, XMLCHAR("key")))
2608 metadata->key = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("key")));
2609 if (xmlTextReaderGetAttribute(reader, XMLCHAR("value")))
2610 metadata->value = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("value")));
2614 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission)
2616 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
2617 permission->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
2619 xmlTextReaderRead(reader);
2620 if (xmlTextReaderValue(reader))
2621 permission->value = ASCII(xmlTextReaderValue(reader));
2625 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility)
2627 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2628 compatibility->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2629 xmlTextReaderRead(reader);
2630 if (xmlTextReaderValue(reader))
2631 compatibility->text = ASCII(xmlTextReaderValue(reader));
2635 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution)
2637 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")))
2638 resolution->mimetype = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")));
2639 if (xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")))
2640 resolution->urischeme = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")));
2644 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request)
2646 xmlTextReaderRead(reader);
2647 if (xmlTextReaderValue(reader))
2648 request->text = ASCII(xmlTextReaderValue(reader));
2652 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define)
2654 const xmlChar *node;
2657 allowed_x *tmp1 = NULL;
2658 request_x *tmp2 = NULL;
2660 if (xmlTextReaderGetAttribute(reader, XMLCHAR("path")))
2661 define->path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("path")));
2663 depth = xmlTextReaderDepth(reader);
2664 while ((ret = __next_child_element(reader, depth))) {
2665 node = xmlTextReaderConstName(reader);
2667 _LOGD("xmlTextReaderConstName value is NULL\n");
2671 if (!strcmp(ASCII(node), "allowed")) {
2672 allowed_x *allowed= malloc(sizeof(allowed_x));
2673 if (allowed == NULL) {
2674 _LOGD("Malloc Failed\n");
2677 memset(allowed, '\0', sizeof(allowed_x));
2678 LISTADD(define->allowed, allowed);
2679 ret = __ps_process_allowed(reader, allowed);
2680 } else if (!strcmp(ASCII(node), "request")) {
2681 request_x *request = malloc(sizeof(request_x));
2682 if (request == NULL) {
2683 _LOGD("Malloc Failed\n");
2686 memset(request, '\0', sizeof(request_x));
2687 LISTADD(define->request, request);
2688 ret = __ps_process_request(reader, request);
2692 _LOGD("Processing define failed\n");
2696 if (define->allowed) {
2697 LISTHEAD(define->allowed, tmp1);
2698 define->allowed = tmp1;
2700 if (define->request) {
2701 LISTHEAD(define->request, tmp2);
2702 define->request = tmp2;
2707 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol)
2709 const xmlChar *node;
2712 operation_x *tmp1 = NULL;
2714 mime_x *tmp3 = NULL;
2715 subapp_x *tmp4 = NULL;
2717 depth = xmlTextReaderDepth(reader);
2718 while ((ret = __next_child_element(reader, depth))) {
2719 node = xmlTextReaderConstName(reader);
2721 _LOGD("xmlTextReaderConstName value is NULL\n");
2725 if (!strcmp(ASCII(node), "operation")) {
2726 operation_x *operation = malloc(sizeof(operation_x));
2727 if (operation == NULL) {
2728 _LOGD("Malloc Failed\n");
2731 memset(operation, '\0', sizeof(operation_x));
2732 LISTADD(appcontrol->operation, operation);
2733 ret = __ps_process_operation(reader, operation);
2734 _LOGD("operation processing\n");
2735 } else if (!strcmp(ASCII(node), "uri")) {
2736 uri_x *uri= malloc(sizeof(uri_x));
2738 _LOGD("Malloc Failed\n");
2741 memset(uri, '\0', sizeof(uri_x));
2742 LISTADD(appcontrol->uri, uri);
2743 ret = __ps_process_uri(reader, uri);
2744 _LOGD("uri processing\n");
2745 } else if (!strcmp(ASCII(node), "mime")) {
2746 mime_x *mime = malloc(sizeof(mime_x));
2748 _LOGD("Malloc Failed\n");
2751 memset(mime, '\0', sizeof(mime_x));
2752 LISTADD(appcontrol->mime, mime);
2753 ret = __ps_process_mime(reader, mime);
2754 _LOGD("mime processing\n");
2755 } else if (!strcmp(ASCII(node), "subapp")) {
2756 subapp_x *subapp = malloc(sizeof(subapp_x));
2757 if (subapp == NULL) {
2758 _LOGD("Malloc Failed\n");
2761 memset(subapp, '\0', sizeof(subapp_x));
2762 LISTADD(appcontrol->subapp, subapp);
2763 ret = __ps_process_subapp(reader, subapp);
2764 _LOGD("subapp processing\n");
2768 _LOGD("Processing appcontrol failed\n");
2772 if (appcontrol->operation) {
2773 LISTHEAD(appcontrol->operation, tmp1);
2774 appcontrol->operation = tmp1;
2776 if (appcontrol->uri) {
2777 LISTHEAD(appcontrol->uri, tmp2);
2778 appcontrol->uri = tmp2;
2780 if (appcontrol->mime) {
2781 LISTHEAD(appcontrol->mime, tmp3);
2782 appcontrol->mime = tmp3;
2784 if (appcontrol->subapp) {
2785 LISTHEAD(appcontrol->subapp, tmp4);
2786 appcontrol->subapp = tmp4;
2789 xmlTextReaderRead(reader);
2790 if (xmlTextReaderValue(reader))
2791 appcontrol->text = ASCII(xmlTextReaderValue(reader));
2796 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc)
2798 const xmlChar *node;
2801 operation_x *tmp1 = NULL;
2803 mime_x *tmp3 = NULL;
2804 subapp_x *tmp4 = NULL;
2806 depth = xmlTextReaderDepth(reader);
2807 while ((ret = __next_child_element(reader, depth))) {
2808 node = xmlTextReaderConstName(reader);
2810 _LOGD("xmlTextReaderConstName value is NULL\n");
2814 if (!strcmp(ASCII(node), "operation")) {
2815 operation_x *operation = malloc(sizeof(operation_x));
2816 if (operation == NULL) {
2817 _LOGD("Malloc Failed\n");
2820 memset(operation, '\0', sizeof(operation_x));
2821 LISTADD(appsvc->operation, operation);
2822 ret = __ps_process_operation(reader, operation);
2823 _LOGD("operation processing\n");
2824 } else if (!strcmp(ASCII(node), "uri")) {
2825 uri_x *uri= malloc(sizeof(uri_x));
2827 _LOGD("Malloc Failed\n");
2830 memset(uri, '\0', sizeof(uri_x));
2831 LISTADD(appsvc->uri, uri);
2832 ret = __ps_process_uri(reader, uri);
2833 _LOGD("uri processing\n");
2834 } else if (!strcmp(ASCII(node), "mime")) {
2835 mime_x *mime = malloc(sizeof(mime_x));
2837 _LOGD("Malloc Failed\n");
2840 memset(mime, '\0', sizeof(mime_x));
2841 LISTADD(appsvc->mime, mime);
2842 ret = __ps_process_mime(reader, mime);
2843 _LOGD("mime processing\n");
2844 } else if (!strcmp(ASCII(node), "subapp")) {
2845 subapp_x *subapp = malloc(sizeof(subapp_x));
2846 if (subapp == NULL) {
2847 _LOGD("Malloc Failed\n");
2850 memset(subapp, '\0', sizeof(subapp_x));
2851 LISTADD(appsvc->subapp, subapp);
2852 ret = __ps_process_subapp(reader, subapp);
2853 _LOGD("subapp processing\n");
2857 _LOGD("Processing appsvc failed\n");
2861 if (appsvc->operation) {
2862 LISTHEAD(appsvc->operation, tmp1);
2863 appsvc->operation = tmp1;
2866 LISTHEAD(appsvc->uri, tmp2);
2870 LISTHEAD(appsvc->mime, tmp3);
2871 appsvc->mime = tmp3;
2873 if (appsvc->subapp) {
2874 LISTHEAD(appsvc->subapp, tmp4);
2875 appsvc->subapp = tmp4;
2878 xmlTextReaderRead(reader);
2879 if (xmlTextReaderValue(reader))
2880 appsvc->text = ASCII(xmlTextReaderValue(reader));
2886 static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privileges)
2888 const xmlChar *node;
2891 privilege_x *tmp1 = NULL;
2893 depth = xmlTextReaderDepth(reader);
2894 while ((ret = __next_child_element(reader, depth))) {
2895 node = xmlTextReaderConstName(reader);
2897 _LOGD("xmlTextReaderConstName value is NULL\n");
2901 if (strcmp(ASCII(node), "privilege") == 0) {
2902 privilege_x *privilege = malloc(sizeof(privilege_x));
2903 if (privilege == NULL) {
2904 _LOGD("Malloc Failed\n");
2907 memset(privilege, '\0', sizeof(privilege_x));
2908 LISTADD(privileges->privilege, privilege);
2909 ret = __ps_process_privilege(reader, privilege);
2913 _LOGD("Processing privileges failed\n");
2917 if (privileges->privilege) {
2918 LISTHEAD(privileges->privilege, tmp1);
2919 privileges->privilege = tmp1;
2924 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions)
2926 const xmlChar *node;
2929 condition_x *tmp1 = NULL;
2931 depth = xmlTextReaderDepth(reader);
2932 while ((ret = __next_child_element(reader, depth))) {
2933 node = xmlTextReaderConstName(reader);
2935 _LOGD("xmlTextReaderConstName value is NULL\n");
2939 if (strcmp(ASCII(node), "condition") == 0) {
2940 condition_x *condition = malloc(sizeof(condition_x));
2941 if (condition == NULL) {
2942 _LOGD("Malloc Failed\n");
2945 memset(condition, '\0', sizeof(condition_x));
2946 LISTADD(launchconditions->condition, condition);
2947 ret = __ps_process_condition(reader, condition);
2951 _LOGD("Processing launchconditions failed\n");
2955 if (launchconditions->condition) {
2956 LISTHEAD(launchconditions->condition, tmp1);
2957 launchconditions->condition = tmp1;
2960 xmlTextReaderRead(reader);
2961 if (xmlTextReaderValue(reader))
2962 launchconditions->text = ASCII(xmlTextReaderValue(reader));
2967 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare)
2969 const xmlChar *node;
2972 define_x *tmp1 = NULL;
2973 request_x *tmp2 = NULL;
2974 depth = xmlTextReaderDepth(reader);
2975 while ((ret = __next_child_element(reader, depth))) {
2976 node = xmlTextReaderConstName(reader);
2978 _LOGD("xmlTextReaderConstName value is NULL\n");
2982 if (!strcmp(ASCII(node), "define")) {
2983 define_x *define= malloc(sizeof(define_x));
2984 if (define == NULL) {
2985 _LOGD("Malloc Failed\n");
2988 memset(define, '\0', sizeof(define_x));
2989 LISTADD(datashare->define, define);
2990 ret = __ps_process_define(reader, define);
2991 } else if (!strcmp(ASCII(node), "request")) {
2992 request_x *request= malloc(sizeof(request_x));
2993 if (request == NULL) {
2994 _LOGD("Malloc Failed\n");
2997 memset(request, '\0', sizeof(request_x));
2998 LISTADD(datashare->request, request);
2999 ret = __ps_process_request(reader, request);
3003 _LOGD("Processing data-share failed\n");
3007 if (datashare->define) {
3008 LISTHEAD(datashare->define, tmp1);
3009 datashare->define = tmp1;
3011 if (datashare->request) {
3012 LISTHEAD(datashare->request, tmp2);
3013 datashare->request = tmp2;
3019 __get_icon_with_path(const char* icon)
3024 if (index(icon, '/') == NULL) {
3026 char* icon_with_path = NULL;
3032 /* "db/setting/theme" is not exist */
3034 theme = vconf_get_str("db/setting/theme");
3036 theme = strdup("default");
3042 theme = strdup("default");
3045 len = (0x01 << 7) + strlen(icon) + strlen(package) + strlen(theme);
3046 icon_with_path = malloc(len);
3047 if(icon_with_path == NULL) {
3048 _LOGD("(icon_with_path == NULL) return\n");
3053 memset(icon_with_path, 0, len);
3055 snprintf(icon_with_path, len, "/opt/share/icons/%s/small/%s", theme, icon);
3057 if (access(icon_with_path, R_OK) == 0) break;
3058 snprintf(icon_with_path, len, "/usr/share/icons/%s/small/%s", theme, icon);
3059 if (access(icon_with_path, R_OK) == 0) break;
3060 _LOGD("cannot find icon %s", icon_with_path);
3061 snprintf(icon_with_path, len,"/opt/share/icons/default/small/%s", icon);
3062 if (access(icon_with_path, R_OK) == 0) break;
3063 snprintf(icon_with_path, len, "/usr/share/icons/default/small/%s", icon);
3064 if (access(icon_with_path, R_OK) == 0) break;
3066 /* icon path is going to be moved intto the app directory */
3067 _LOGE("icon file must be moved to %s", icon_with_path);
3068 snprintf(icon_with_path, len, "/opt/apps/%s/res/icons/%s/small/%s", package, theme, icon);
3069 if (access(icon_with_path, R_OK) == 0) break;
3070 snprintf(icon_with_path, len, "/usr/apps/%s/res/icons/%s/small/%s", package, theme, icon);
3071 if (access(icon_with_path, R_OK) == 0) break;
3072 _LOGD("cannot find icon %s", icon_with_path);
3073 snprintf(icon_with_path, len, "/opt/apps/%s/res/icons/default/small/%s", package, icon);
3074 if (access(icon_with_path, R_OK) == 0) break;
3075 snprintf(icon_with_path, len, "/usr/apps/%s/res/icons/default/small/%s", package, icon);
3076 if (access(icon_with_path, R_OK) == 0) break;
3077 snprintf(icon_with_path, len, "/usr/ug/res/images/%s/%s", package, icon);
3078 if (access(icon_with_path, R_OK) == 0) break;
3083 _LOGD("Icon path : %s ---> %s", icon, icon_with_path);
3085 return icon_with_path;
3087 char* confirmed_icon = NULL;
3089 confirmed_icon = strdup(icon);
3090 if (!confirmed_icon)
3092 return confirmed_icon;
3096 static void __ps_process_tag(manifest_x * mfx, char *const tagv[])
3099 char delims[] = "=";
3100 char *ret_result = NULL;
3106 for (tag = strdup(tagv[0]); tag != NULL; ) {
3107 ret_result = strtok(tag, delims);
3109 /*check tag : preload */
3110 if (strcmp(ret_result, "preload") == 0) {
3111 ret_result = strtok(NULL, delims);
3112 if (strcmp(ret_result, "true") == 0) {
3113 free((void *)mfx->preload);
3114 mfx->preload = strdup("true");
3115 } else if (strcmp(ret_result, "false") == 0) {
3116 free((void *)mfx->preload);
3117 mfx->preload = strdup("false");
3119 /*check tag : removable*/
3120 } else if (strcmp(ret_result, "removable") == 0) {
3121 ret_result = strtok(NULL, delims);
3122 if (strcmp(ret_result, "true") == 0){
3123 free((void *)mfx->removable);
3124 mfx->removable = strdup("true");
3125 } else if (strcmp(ret_result, "false") == 0) {
3126 free((void *)mfx->removable);
3127 mfx->removable = strdup("false");
3129 /*check tag : not matched*/
3131 _LOGD("tag process [%s]is not defined\n", ret_result);
3135 /*check next value*/
3136 if (tagv[++i] != NULL)
3137 tag = strdup(tagv[i]);
3139 _LOGD("tag process success...\n");
3145 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon)
3147 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
3148 icon->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
3149 if (xmlTextReaderConstXmlLang(reader)) {
3150 icon->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3151 if (icon->lang == NULL)
3152 icon->lang = strdup(DEFAULT_LOCALE);
3154 icon->lang = strdup(DEFAULT_LOCALE);
3156 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
3157 icon->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
3158 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
3159 icon->size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
3160 if (xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")))
3161 icon->resolution = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")));
3162 xmlTextReaderRead(reader);
3163 if (xmlTextReaderValue(reader)) {
3164 const char *text = ASCII(xmlTextReaderValue(reader));
3166 icon->text = (const char *)__get_icon_with_path(text);
3174 static int __ps_process_image(xmlTextReaderPtr reader, image_x *image)
3176 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
3177 image->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
3178 if (xmlTextReaderConstXmlLang(reader)) {
3179 image->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3180 if (image->lang == NULL)
3181 image->lang = strdup(DEFAULT_LOCALE);
3183 image->lang = strdup(DEFAULT_LOCALE);
3185 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
3186 image->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
3187 xmlTextReaderRead(reader);
3188 if (xmlTextReaderValue(reader))
3189 image->text = ASCII(xmlTextReaderValue(reader));
3194 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label)
3196 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
3197 label->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
3198 if (xmlTextReaderConstXmlLang(reader)) {
3199 label->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3200 if (label->lang == NULL)
3201 label->lang = strdup(DEFAULT_LOCALE);
3203 label->lang = strdup(DEFAULT_LOCALE);
3205 xmlTextReaderRead(reader);
3206 if (xmlTextReaderValue(reader))
3207 label->text = ASCII(xmlTextReaderValue(reader));
3209 /* _LOGD("lable name %s\n", label->name);
3210 _LOGD("lable lang %s\n", label->lang);
3211 _LOGD("lable text %s\n", label->text);
3217 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author)
3219 if (xmlTextReaderGetAttribute(reader, XMLCHAR("email")))
3220 author->email = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("email")));
3221 if (xmlTextReaderGetAttribute(reader, XMLCHAR("href")))
3222 author->href = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("href")));
3223 if (xmlTextReaderConstXmlLang(reader)) {
3224 author->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3225 if (author->lang == NULL)
3226 author->lang = strdup(DEFAULT_LOCALE);
3228 author->lang = strdup(DEFAULT_LOCALE);
3230 xmlTextReaderRead(reader);
3231 if (xmlTextReaderValue(reader)) {
3232 const char *text = ASCII(xmlTextReaderValue(reader));
3233 if (*text == '\n') {
3234 author->text = NULL;
3238 author->text = ASCII(xmlTextReaderValue(reader));
3243 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description)
3245 if (xmlTextReaderConstXmlLang(reader)) {
3246 description->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3247 if (description->lang == NULL)
3248 description->lang = strdup(DEFAULT_LOCALE);
3250 description->lang = strdup(DEFAULT_LOCALE);
3252 xmlTextReaderRead(reader);
3253 if (xmlTextReaderValue(reader)) {
3254 const char *text = ASCII(xmlTextReaderValue(reader));
3255 if (*text == '\n') {
3256 description->text = NULL;
3260 description->text = ASCII(xmlTextReaderValue(reader));
3265 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license)
3267 if (xmlTextReaderConstXmlLang(reader)) {
3268 license->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3269 if (license->lang == NULL)
3270 license->lang = strdup(DEFAULT_LOCALE);
3272 license->lang = strdup(DEFAULT_LOCALE);
3274 xmlTextReaderRead(reader);
3275 if (xmlTextReaderValue(reader))
3276 license->text = ASCII(xmlTextReaderValue(reader));
3280 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability)
3282 const xmlChar *node;
3285 resolution_x *tmp1 = NULL;
3287 if (xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")))
3288 capability->operationid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")));
3290 depth = xmlTextReaderDepth(reader);
3291 while ((ret = __next_child_element(reader, depth))) {
3292 node = xmlTextReaderConstName(reader);
3294 _LOGD("xmlTextReaderConstName value is NULL\n");
3298 if (!strcmp(ASCII(node), "resolution")) {
3299 resolution_x *resolution = malloc(sizeof(resolution_x));
3300 if (resolution == NULL) {
3301 _LOGD("Malloc Failed\n");
3304 memset(resolution, '\0', sizeof(resolution_x));
3305 LISTADD(capability->resolution, resolution);
3306 ret = __ps_process_resolution(reader, resolution);
3310 _LOGD("Processing capability failed\n");
3315 if (capability->resolution) {
3316 LISTHEAD(capability->resolution, tmp1);
3317 capability->resolution = tmp1;
3323 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol)
3325 const xmlChar *node;
3328 capability_x *tmp1 = NULL;
3330 if (xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")))
3331 datacontrol->providerid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")));
3333 depth = xmlTextReaderDepth(reader);
3334 while ((ret = __next_child_element(reader, depth))) {
3335 node = xmlTextReaderConstName(reader);
3337 _LOGD("xmlTextReaderConstName value is NULL\n");
3341 if (!strcmp(ASCII(node), "capability")) {
3342 capability_x *capability = malloc(sizeof(capability_x));
3343 if (capability == NULL) {
3344 _LOGD("Malloc Failed\n");
3347 memset(capability, '\0', sizeof(capability_x));
3348 LISTADD(datacontrol->capability, capability);
3349 ret = __ps_process_capability(reader, capability);
3353 _LOGD("Processing datacontrol failed\n");
3358 if (datacontrol->capability) {
3359 LISTHEAD(datacontrol->capability, tmp1);
3360 datacontrol->capability = tmp1;
3366 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication)
3368 const xmlChar *node;
3371 char *newappid = NULL;
3372 label_x *tmp1 = NULL;
3373 icon_x *tmp2 = NULL;
3374 appsvc_x *tmp3 = NULL;
3375 appcontrol_x *tmp4 = NULL;
3376 launchconditions_x *tmp5 = NULL;
3377 notification_x *tmp6 = NULL;
3378 datashare_x *tmp7 = NULL;
3379 category_x *tmp8 = NULL;
3380 metadata_x *tmp9 = NULL;
3381 image_x *tmp10 = NULL;
3382 permission_x *tmp11 = NULL;
3384 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
3385 uiapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
3386 if (uiapplication->appid == NULL) {
3387 _LOGD("appid cant be NULL\n");
3391 _LOGD("appid is mandatory\n");
3395 ret = __validate_appid(package, uiapplication->appid, &newappid);
3397 _LOGD("appid is not proper\n");
3401 if (uiapplication->appid)
3402 free((void *)uiapplication->appid);
3403 uiapplication->appid = newappid;
3405 uiapplication->package= strdup(package);
3407 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
3408 uiapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
3409 if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay"))) {
3410 uiapplication->nodisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay")));
3411 if (uiapplication->nodisplay == NULL)
3412 uiapplication->nodisplay = strdup("false");
3414 uiapplication->nodisplay = strdup("false");
3416 if (xmlTextReaderGetAttribute(reader, XMLCHAR("multiple"))) {
3417 uiapplication->multiple = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("multiple")));
3418 if (uiapplication->multiple == NULL)
3419 uiapplication->multiple = strdup("false");
3421 uiapplication->multiple = strdup("false");
3423 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
3424 uiapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
3425 if (xmlTextReaderGetAttribute(reader, XMLCHAR("categories")))
3426 uiapplication->categories = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("categories")));
3427 if (xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")))
3428 uiapplication->extraid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")));
3429 if (xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage"))) {
3430 uiapplication->taskmanage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage")));
3431 if (uiapplication->taskmanage == NULL)
3432 uiapplication->taskmanage = strdup("true");
3434 uiapplication->taskmanage = strdup("true");
3436 if (xmlTextReaderGetAttribute(reader, XMLCHAR("enabled"))) {
3437 uiapplication->enabled = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("enabled")));
3438 if (uiapplication->enabled == NULL)
3439 uiapplication->enabled = strdup("true");
3441 uiapplication->enabled = strdup("true");
3443 if (xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration"))) {
3444 uiapplication->hwacceleration = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration")));
3445 if (uiapplication->hwacceleration == NULL)
3446 uiapplication->hwacceleration = strdup("use-system-setting");
3448 uiapplication->hwacceleration = strdup("use-system-setting");
3450 if (xmlTextReaderGetAttribute(reader, XMLCHAR("screen-reader"))) {
3451 uiapplication->screenreader = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("screen-reader")));
3452 if (uiapplication->screenreader == NULL)
3453 uiapplication->screenreader = strdup("use-system-setting");
3455 uiapplication->screenreader = strdup("use-system-setting");
3457 if (xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")))
3458 uiapplication->recentimage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")));
3459 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp"))) {
3460 uiapplication->mainapp = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp")));
3461 if (uiapplication->mainapp == NULL)
3462 uiapplication->mainapp = strdup("false");
3464 uiapplication->mainapp = strdup("false");
3466 if (xmlTextReaderGetAttribute(reader, XMLCHAR("launchcondition"))) {
3467 uiapplication->launchcondition = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("launchcondition")));
3468 if (uiapplication->launchcondition == NULL)
3469 uiapplication->launchcondition = strdup("false");
3471 uiapplication->launchcondition = strdup("false");
3474 if (xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay"))) {
3475 uiapplication->indicatordisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay")));
3476 if (uiapplication->indicatordisplay == NULL)
3477 uiapplication->indicatordisplay = strdup("true");
3479 uiapplication->indicatordisplay = strdup("true");
3481 if (xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")))
3482 uiapplication->portraitimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")));
3484 uiapplication->portraitimg = NULL;
3485 if (xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")))
3486 uiapplication->landscapeimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")));
3488 uiapplication->landscapeimg = NULL;
3489 if (xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility"))) {
3490 uiapplication->guestmode_visibility = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility")));
3491 if (uiapplication->guestmode_visibility == NULL)
3492 uiapplication->guestmode_visibility = strdup("true");
3494 uiapplication->guestmode_visibility = strdup("true");
3496 if (xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type"))) {
3497 uiapplication->permission_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type")));
3498 if (uiapplication->permission_type == NULL)
3499 uiapplication->permission_type = strdup("normal");
3501 uiapplication->permission_type = strdup("normal");
3503 if (xmlTextReaderGetAttribute(reader, XMLCHAR("component-type"))) {
3504 uiapplication->component_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("component-type")));
3505 if (uiapplication->component_type == NULL)
3506 uiapplication->component_type = strdup("uiapp");
3508 uiapplication->component_type = strdup("uiapp");
3510 if (xmlTextReaderGetAttribute(reader, XMLCHAR("submode"))) {
3511 uiapplication->submode = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("submode")));
3512 if (uiapplication->submode == NULL)
3513 uiapplication->submode = strdup("false");
3515 uiapplication->submode = strdup("false");
3517 if (xmlTextReaderGetAttribute(reader, XMLCHAR("submode-mainid")))
3518 uiapplication->submode_mainid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("submode-mainid")));
3520 depth = xmlTextReaderDepth(reader);
3521 while ((ret = __next_child_element(reader, depth))) {
3522 node = xmlTextReaderConstName(reader);
3524 _LOGD("xmlTextReaderConstName value is NULL\n");
3527 if (!strcmp(ASCII(node), "label")) {
3528 label_x *label = malloc(sizeof(label_x));
3529 if (label == NULL) {
3530 _LOGD("Malloc Failed\n");
3533 memset(label, '\0', sizeof(label_x));
3534 LISTADD(uiapplication->label, label);
3535 ret = __ps_process_label(reader, label);
3536 } else if (!strcmp(ASCII(node), "icon")) {
3537 icon_x *icon = malloc(sizeof(icon_x));
3539 _LOGD("Malloc Failed\n");
3542 memset(icon, '\0', sizeof(icon_x));
3543 LISTADD(uiapplication->icon, icon);
3544 ret = __ps_process_icon(reader, icon);
3545 } else if (!strcmp(ASCII(node), "image")) {
3546 image_x *image = malloc(sizeof(image_x));
3547 if (image == NULL) {
3548 _LOGD("Malloc Failed\n");
3551 memset(image, '\0', sizeof(image_x));
3552 LISTADD(uiapplication->image, image);
3553 ret = __ps_process_image(reader, image);
3554 } else if (!strcmp(ASCII(node), "category")) {
3555 category_x *category = malloc(sizeof(category_x));
3556 if (category == NULL) {
3557 _LOGD("Malloc Failed\n");
3560 memset(category, '\0', sizeof(category_x));
3561 LISTADD(uiapplication->category, category);
3562 ret = __ps_process_category(reader, category);
3563 } else if (!strcmp(ASCII(node), "metadata")) {
3564 metadata_x *metadata = malloc(sizeof(metadata_x));
3565 if (metadata == NULL) {
3566 _LOGD("Malloc Failed\n");
3569 memset(metadata, '\0', sizeof(metadata_x));
3570 LISTADD(uiapplication->metadata, metadata);
3571 ret = __ps_process_metadata(reader, metadata);
3572 } else if (!strcmp(ASCII(node), "permission")) {
3573 permission_x *permission = malloc(sizeof(permission_x));
3574 if (permission == NULL) {
3575 _LOGD("Malloc Failed\n");
3578 memset(permission, '\0', sizeof(permission_x));
3579 LISTADD(uiapplication->permission, permission);
3580 ret = __ps_process_permission(reader, permission);
3581 } else if (!strcmp(ASCII(node), "app-control")) {
3582 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
3583 if (appcontrol == NULL) {
3584 _LOGD("Malloc Failed\n");
3587 memset(appcontrol, '\0', sizeof(appcontrol_x));
3588 LISTADD(uiapplication->appcontrol, appcontrol);
3589 ret = __ps_process_appcontrol(reader, appcontrol);
3590 } else if (!strcmp(ASCII(node), "application-service")) {
3591 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
3592 if (appsvc == NULL) {
3593 _LOGD("Malloc Failed\n");
3596 memset(appsvc, '\0', sizeof(appsvc_x));
3597 LISTADD(uiapplication->appsvc, appsvc);
3598 ret = __ps_process_appsvc(reader, appsvc);
3599 } else if (!strcmp(ASCII(node), "data-share")) {
3600 datashare_x *datashare = malloc(sizeof(datashare_x));
3601 if (datashare == NULL) {
3602 _LOGD("Malloc Failed\n");
3605 memset(datashare, '\0', sizeof(datashare_x));
3606 LISTADD(uiapplication->datashare, datashare);
3607 ret = __ps_process_datashare(reader, datashare);
3608 } else if (!strcmp(ASCII(node), "launch-conditions")) {
3609 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
3610 if (launchconditions == NULL) {
3611 _LOGD("Malloc Failed\n");
3614 memset(launchconditions, '\0', sizeof(launchconditions_x));
3615 LISTADD(uiapplication->launchconditions, launchconditions);
3616 ret = __ps_process_launchconditions(reader, launchconditions);
3617 } else if (!strcmp(ASCII(node), "notification")) {
3618 notification_x *notification = malloc(sizeof(notification_x));
3619 if (notification == NULL) {
3620 _LOGD("Malloc Failed\n");
3623 memset(notification, '\0', sizeof(notification_x));
3624 LISTADD(uiapplication->notification, notification);
3625 ret = __ps_process_notification(reader, notification);
3629 _LOGD("Processing uiapplication failed\n");
3634 if (uiapplication->label) {
3635 LISTHEAD(uiapplication->label, tmp1);
3636 uiapplication->label = tmp1;
3638 if (uiapplication->icon) {
3639 LISTHEAD(uiapplication->icon, tmp2);
3640 uiapplication->icon = tmp2;
3642 if (uiapplication->appsvc) {
3643 LISTHEAD(uiapplication->appsvc, tmp3);
3644 uiapplication->appsvc = tmp3;
3646 if (uiapplication->appcontrol) {
3647 LISTHEAD(uiapplication->appcontrol, tmp4);
3648 uiapplication->appcontrol = tmp4;
3650 if (uiapplication->launchconditions) {
3651 LISTHEAD(uiapplication->launchconditions, tmp5);
3652 uiapplication->launchconditions = tmp5;
3654 if (uiapplication->notification) {
3655 LISTHEAD(uiapplication->notification, tmp6);
3656 uiapplication->notification = tmp6;
3658 if (uiapplication->datashare) {
3659 LISTHEAD(uiapplication->datashare, tmp7);
3660 uiapplication->datashare = tmp7;
3662 if (uiapplication->category) {
3663 LISTHEAD(uiapplication->category, tmp8);
3664 uiapplication->category = tmp8;
3666 if (uiapplication->metadata) {
3667 LISTHEAD(uiapplication->metadata, tmp9);
3668 uiapplication->metadata = tmp9;
3670 if (uiapplication->image) {
3671 LISTHEAD(uiapplication->image, tmp10);
3672 uiapplication->image = tmp10;
3674 if (uiapplication->permission) {
3675 LISTHEAD(uiapplication->permission, tmp11);
3676 uiapplication->permission = tmp11;
3682 static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication)
3684 const xmlChar *node;
3687 char *newappid = NULL;
3688 label_x *tmp1 = NULL;
3689 icon_x *tmp2 = NULL;
3690 appsvc_x *tmp3 = NULL;
3691 appcontrol_x *tmp4 = NULL;
3692 datacontrol_x *tmp5 = NULL;
3693 launchconditions_x *tmp6 = NULL;
3694 notification_x *tmp7 = NULL;
3695 datashare_x *tmp8 = NULL;
3696 category_x *tmp9 = NULL;
3697 metadata_x *tmp10 = NULL;
3698 permission_x *tmp11 = NULL;
3700 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
3701 serviceapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
3702 if (serviceapplication->appid == NULL) {
3703 _LOGD("appid cant be NULL\n");
3707 _LOGD("appid is mandatory\n");
3711 ret = __validate_appid(package, serviceapplication->appid, &newappid);
3713 _LOGD("appid is not proper\n");
3717 if (serviceapplication->appid)
3718 free((void *)serviceapplication->appid);
3719 serviceapplication->appid = newappid;
3722 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
3723 serviceapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
3724 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
3725 serviceapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
3726 if (xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot"))) {
3727 serviceapplication->onboot = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot")));
3728 if (serviceapplication->onboot == NULL)
3729 serviceapplication->onboot = strdup("false");
3731 serviceapplication->onboot = strdup("false");
3733 if (xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart"))) {
3734 serviceapplication->autorestart = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart")));
3735 if (serviceapplication->autorestart == NULL)
3736 serviceapplication->autorestart = strdup("false");
3738 serviceapplication->autorestart = strdup("false");
3740 if (xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type"))) {
3741 serviceapplication->permission_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type")));
3742 if (serviceapplication->permission_type == NULL)
3743 serviceapplication->permission_type = strdup("normal");
3745 serviceapplication->permission_type = strdup("normal");
3748 depth = xmlTextReaderDepth(reader);
3749 while ((ret = __next_child_element(reader, depth))) {
3750 node = xmlTextReaderConstName(reader);
3752 _LOGD("xmlTextReaderConstName value is NULL\n");
3756 if (!strcmp(ASCII(node), "label")) {
3757 label_x *label = malloc(sizeof(label_x));
3758 if (label == NULL) {
3759 _LOGD("Malloc Failed\n");
3762 memset(label, '\0', sizeof(label_x));
3763 LISTADD(serviceapplication->label, label);
3764 ret = __ps_process_label(reader, label);
3765 } else if (!strcmp(ASCII(node), "icon")) {
3766 icon_x *icon = malloc(sizeof(icon_x));
3768 _LOGD("Malloc Failed\n");
3771 memset(icon, '\0', sizeof(icon_x));
3772 LISTADD(serviceapplication->icon, icon);
3773 ret = __ps_process_icon(reader, icon);
3774 } else if (!strcmp(ASCII(node), "category")) {
3775 category_x *category = malloc(sizeof(category_x));
3776 if (category == NULL) {
3777 _LOGD("Malloc Failed\n");
3780 memset(category, '\0', sizeof(category_x));
3781 LISTADD(serviceapplication->category, category);
3782 ret = __ps_process_category(reader, category);
3783 } else if (!strcmp(ASCII(node), "metadata")) {
3784 metadata_x *metadata = malloc(sizeof(metadata_x));
3785 if (metadata == NULL) {
3786 _LOGD("Malloc Failed\n");
3789 memset(metadata, '\0', sizeof(metadata_x));
3790 LISTADD(serviceapplication->metadata, metadata);
3791 ret = __ps_process_metadata(reader, metadata);
3792 } else if (!strcmp(ASCII(node), "permission")) {
3793 permission_x *permission = malloc(sizeof(permission_x));
3794 if (permission == NULL) {
3795 _LOGD("Malloc Failed\n");
3798 memset(permission, '\0', sizeof(permission_x));
3799 LISTADD(serviceapplication->permission, permission);
3800 ret = __ps_process_permission(reader, permission);
3801 } else if (!strcmp(ASCII(node), "app-control")) {
3802 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
3803 if (appcontrol == NULL) {
3804 _LOGD("Malloc Failed\n");
3807 memset(appcontrol, '\0', sizeof(appcontrol_x));
3808 LISTADD(serviceapplication->appcontrol, appcontrol);
3809 ret = __ps_process_appcontrol(reader, appcontrol);
3810 } else if (!strcmp(ASCII(node), "application-service")) {
3811 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
3812 if (appsvc == NULL) {
3813 _LOGD("Malloc Failed\n");
3816 memset(appsvc, '\0', sizeof(appsvc_x));
3817 LISTADD(serviceapplication->appsvc, appsvc);
3818 ret = __ps_process_appsvc(reader, appsvc);
3819 } else if (!strcmp(ASCII(node), "data-share")) {
3820 datashare_x *datashare = malloc(sizeof(datashare_x));
3821 if (datashare == NULL) {
3822 _LOGD("Malloc Failed\n");
3825 memset(datashare, '\0', sizeof(datashare_x));
3826 LISTADD(serviceapplication->datashare, datashare);
3827 ret = __ps_process_datashare(reader, datashare);
3828 } else if (!strcmp(ASCII(node), "launch-conditions")) {
3829 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
3830 if (launchconditions == NULL) {
3831 _LOGD("Malloc Failed\n");
3834 memset(launchconditions, '\0', sizeof(launchconditions_x));
3835 LISTADD(serviceapplication->launchconditions, launchconditions);
3836 ret = __ps_process_launchconditions(reader, launchconditions);
3837 } else if (!strcmp(ASCII(node), "notification")) {
3838 notification_x *notification = malloc(sizeof(notification_x));
3839 if (notification == NULL) {
3840 _LOGD("Malloc Failed\n");
3843 memset(notification, '\0', sizeof(notification_x));
3844 LISTADD(serviceapplication->notification, notification);
3845 ret = __ps_process_notification(reader, notification);
3846 } else if (!strcmp(ASCII(node), "data-control")) {
3847 datacontrol_x *datacontrol = malloc(sizeof(datacontrol_x));
3848 if (datacontrol == NULL) {
3849 _LOGD("Malloc Failed\n");
3852 memset(datacontrol, '\0', sizeof(datacontrol_x));
3853 LISTADD(serviceapplication->datacontrol, datacontrol);
3854 ret = __ps_process_datacontrol(reader, datacontrol);
3858 _LOGD("Processing serviceapplication failed\n");
3863 if (serviceapplication->label) {
3864 LISTHEAD(serviceapplication->label, tmp1);
3865 serviceapplication->label = tmp1;
3867 if (serviceapplication->icon) {
3868 LISTHEAD(serviceapplication->icon, tmp2);
3869 serviceapplication->icon = tmp2;
3871 if (serviceapplication->appsvc) {
3872 LISTHEAD(serviceapplication->appsvc, tmp3);
3873 serviceapplication->appsvc = tmp3;
3875 if (serviceapplication->appcontrol) {
3876 LISTHEAD(serviceapplication->appcontrol, tmp4);
3877 serviceapplication->appcontrol = tmp4;
3879 if (serviceapplication->datacontrol) {
3880 LISTHEAD(serviceapplication->datacontrol, tmp5);
3881 serviceapplication->datacontrol = tmp5;
3883 if (serviceapplication->launchconditions) {
3884 LISTHEAD(serviceapplication->launchconditions, tmp6);
3885 serviceapplication->launchconditions = tmp6;
3887 if (serviceapplication->notification) {
3888 LISTHEAD(serviceapplication->notification, tmp7);
3889 serviceapplication->notification = tmp7;
3891 if (serviceapplication->datashare) {
3892 LISTHEAD(serviceapplication->datashare, tmp8);
3893 serviceapplication->datashare = tmp8;
3895 if (serviceapplication->category) {
3896 LISTHEAD(serviceapplication->category, tmp9);
3897 serviceapplication->category = tmp9;
3899 if (serviceapplication->metadata) {
3900 LISTHEAD(serviceapplication->metadata, tmp10);
3901 serviceapplication->metadata = tmp10;
3903 if (serviceapplication->permission) {
3904 LISTHEAD(serviceapplication->permission, tmp11);
3905 serviceapplication->permission = tmp11;
3911 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile)
3913 /*TODO: once policy is set*/
3917 static int __ps_process_font(xmlTextReaderPtr reader, font_x *font)
3919 /*TODO: once policy is set*/
3923 static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme)
3925 /*TODO: once policy is set*/
3929 static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon)
3931 /*TODO: once policy is set*/
3935 static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime)
3937 /*TODO: once policy is set*/
3941 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx)
3943 _LOGD("__start_process\n");
3944 const xmlChar *node;
3947 label_x *tmp1 = NULL;
3948 author_x *tmp2 = NULL;
3949 description_x *tmp3 = NULL;
3950 license_x *tmp4 = NULL;
3951 uiapplication_x *tmp5 = NULL;
3952 serviceapplication_x *tmp6 = NULL;
3953 daemon_x *tmp7 = NULL;
3954 theme_x *tmp8 = NULL;
3955 font_x *tmp9 = NULL;
3956 ime_x *tmp10 = NULL;
3957 icon_x *tmp11 = NULL;
3958 compatibility_x *tmp12 = NULL;
3959 deviceprofile_x *tmp13 = NULL;
3960 privileges_x *tmp14 = NULL;
3962 depth = xmlTextReaderDepth(reader);
3963 while ((ret = __next_child_element(reader, depth))) {
3964 node = xmlTextReaderConstName(reader);
3966 _LOGD("xmlTextReaderConstName value is NULL\n");
3970 if (!strcmp(ASCII(node), "label")) {
3971 label_x *label = malloc(sizeof(label_x));
3972 if (label == NULL) {
3973 _LOGD("Malloc Failed\n");
3976 memset(label, '\0', sizeof(label_x));
3977 LISTADD(mfx->label, label);
3978 ret = __ps_process_label(reader, label);
3979 } else if (!strcmp(ASCII(node), "author")) {
3980 author_x *author = malloc(sizeof(author_x));
3981 if (author == NULL) {
3982 _LOGD("Malloc Failed\n");
3985 memset(author, '\0', sizeof(author_x));
3986 LISTADD(mfx->author, author);
3987 ret = __ps_process_author(reader, author);
3988 } else if (!strcmp(ASCII(node), "description")) {
3989 description_x *description = malloc(sizeof(description_x));
3990 if (description == NULL) {
3991 _LOGD("Malloc Failed\n");
3994 memset(description, '\0', sizeof(description_x));
3995 LISTADD(mfx->description, description);
3996 ret = __ps_process_description(reader, description);
3997 } else if (!strcmp(ASCII(node), "license")) {
3998 license_x *license = malloc(sizeof(license_x));
3999 if (license == NULL) {
4000 _LOGD("Malloc Failed\n");
4003 memset(license, '\0', sizeof(license_x));
4004 LISTADD(mfx->license, license);
4005 ret = __ps_process_license(reader, license);
4006 } else if (!strcmp(ASCII(node), "privileges")) {
4007 privileges_x *privileges = malloc(sizeof(privileges_x));
4008 if (privileges == NULL) {
4009 _LOGD("Malloc Failed\n");
4012 memset(privileges, '\0', sizeof(privileges_x));
4013 LISTADD(mfx->privileges, privileges);
4014 ret = __ps_process_privileges(reader, privileges);
4015 } else if (!strcmp(ASCII(node), "ui-application")) {
4016 uiapplication_x *uiapplication = malloc(sizeof(uiapplication_x));
4017 if (uiapplication == NULL) {
4018 _LOGD("Malloc Failed\n");
4021 memset(uiapplication, '\0', sizeof(uiapplication_x));
4022 LISTADD(mfx->uiapplication, uiapplication);
4023 ret = __ps_process_uiapplication(reader, uiapplication);
4024 } else if (!strcmp(ASCII(node), "service-application")) {
4025 serviceapplication_x *serviceapplication = malloc(sizeof(serviceapplication_x));
4026 if (serviceapplication == NULL) {
4027 _LOGD("Malloc Failed\n");
4030 memset(serviceapplication, '\0', sizeof(serviceapplication_x));
4031 LISTADD(mfx->serviceapplication, serviceapplication);
4032 ret = __ps_process_serviceapplication(reader, serviceapplication);
4033 } else if (!strcmp(ASCII(node), "daemon")) {
4034 daemon_x *daemon = malloc(sizeof(daemon_x));
4035 if (daemon == NULL) {
4036 _LOGD("Malloc Failed\n");
4039 memset(daemon, '\0', sizeof(daemon_x));
4040 LISTADD(mfx->daemon, daemon);
4041 ret = __ps_process_daemon(reader, daemon);
4042 } else if (!strcmp(ASCII(node), "theme")) {
4043 theme_x *theme = malloc(sizeof(theme_x));
4044 if (theme == NULL) {
4045 _LOGD("Malloc Failed\n");
4048 memset(theme, '\0', sizeof(theme_x));
4049 LISTADD(mfx->theme, theme);
4050 ret = __ps_process_theme(reader, theme);
4051 } else if (!strcmp(ASCII(node), "font")) {
4052 font_x *font = malloc(sizeof(font_x));
4054 _LOGD("Malloc Failed\n");
4057 memset(font, '\0', sizeof(font_x));
4058 LISTADD(mfx->font, font);
4059 ret = __ps_process_font(reader, font);
4060 } else if (!strcmp(ASCII(node), "ime")) {
4061 ime_x *ime = malloc(sizeof(ime_x));
4063 _LOGD("Malloc Failed\n");
4066 memset(ime, '\0', sizeof(ime_x));
4067 LISTADD(mfx->ime, ime);
4068 ret = __ps_process_ime(reader, ime);
4069 } else if (!strcmp(ASCII(node), "icon")) {
4070 icon_x *icon = malloc(sizeof(icon_x));
4072 _LOGD("Malloc Failed\n");
4075 memset(icon, '\0', sizeof(icon_x));
4076 LISTADD(mfx->icon, icon);
4077 ret = __ps_process_icon(reader, icon);
4078 } else if (!strcmp(ASCII(node), "device-profile")) {
4079 deviceprofile_x *deviceprofile = malloc(sizeof(deviceprofile_x));
4080 if (deviceprofile == NULL) {
4081 _LOGD("Malloc Failed\n");
4084 memset(deviceprofile, '\0', sizeof(deviceprofile_x));
4085 LISTADD(mfx->deviceprofile, deviceprofile);
4086 ret = __ps_process_deviceprofile(reader, deviceprofile);
4087 } else if (!strcmp(ASCII(node), "compatibility")) {
4088 compatibility_x *compatibility = malloc(sizeof(compatibility_x));
4089 if (compatibility == NULL) {
4090 _LOGD("Malloc Failed\n");
4093 memset(compatibility, '\0', sizeof(compatibility_x));
4094 LISTADD(mfx->compatibility, compatibility);
4095 ret = __ps_process_compatibility(reader, compatibility);
4096 } else if (!strcmp(ASCII(node), "shortcut-list")) {
4098 } else if (!strcmp(ASCII(node), "livebox")) {
4100 } else if (!strcmp(ASCII(node), "account")) {
4102 } else if (!strcmp(ASCII(node), "notifications")) {
4104 } else if (!strcmp(ASCII(node), "ime")) {
4110 _LOGD("Processing manifest failed\n");
4115 LISTHEAD(mfx->label, tmp1);
4119 LISTHEAD(mfx->author, tmp2);
4122 if (mfx->description) {
4123 LISTHEAD(mfx->description, tmp3);
4124 mfx->description= tmp3;
4127 LISTHEAD(mfx->license, tmp4);
4130 if (mfx->uiapplication) {
4131 LISTHEAD(mfx->uiapplication, tmp5);
4132 mfx->uiapplication = tmp5;
4134 if (mfx->serviceapplication) {
4135 LISTHEAD(mfx->serviceapplication, tmp6);
4136 mfx->serviceapplication = tmp6;
4139 LISTHEAD(mfx->daemon, tmp7);
4143 LISTHEAD(mfx->theme, tmp8);
4147 LISTHEAD(mfx->font, tmp9);
4151 LISTHEAD(mfx->ime, tmp10);
4155 LISTHEAD(mfx->icon, tmp11);
4158 if (mfx->compatibility) {
4159 LISTHEAD(mfx->compatibility, tmp12);
4160 mfx->compatibility= tmp12;
4162 if (mfx->deviceprofile) {
4163 LISTHEAD(mfx->deviceprofile, tmp13);
4164 mfx->deviceprofile= tmp13;
4166 if (mfx->privileges) {
4167 LISTHEAD(mfx->privileges, tmp14);
4168 mfx->privileges = tmp14;
4173 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx)
4175 const xmlChar *node;
4178 if ((ret = __next_child_element(reader, -1))) {
4179 node = xmlTextReaderConstName(reader);
4181 _LOGD("xmlTextReaderConstName value is NULL\n");
4185 if (!strcmp(ASCII(node), "manifest")) {
4186 if (xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")))
4187 mfx->ns = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")));
4188 if (xmlTextReaderGetAttribute(reader, XMLCHAR("package"))) {
4189 mfx->package= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("package")));
4190 if (mfx->package == NULL) {
4191 _LOGD("package cant be NULL\n");
4195 _LOGD("package field is mandatory\n");
4198 package = mfx->package;
4199 if (xmlTextReaderGetAttribute(reader, XMLCHAR("version")))
4200 mfx->version= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("version")));
4201 /*app2ext needs package size for external installation*/
4202 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
4203 mfx->package_size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
4204 if (xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")))
4205 mfx->installlocation = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")));
4206 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
4207 mfx->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
4208 if (xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")))
4209 mfx->root_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")));
4210 if (xmlTextReaderGetAttribute(reader, XMLCHAR("csc_path")))
4211 mfx->csc_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("csc_path")));
4212 if (xmlTextReaderGetAttribute(reader, XMLCHAR("main_package")))
4213 mfx->main_package = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("main_package")));
4214 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting"))) {
4215 mfx->appsetting = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting")));
4216 if (mfx->appsetting == NULL)
4217 mfx->appsetting = strdup("false");
4219 mfx->appsetting = strdup("false");
4221 if (xmlTextReaderGetAttribute(reader, XMLCHAR("storeclient-id")))
4222 mfx->storeclient_id= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("storeclient-id")));
4223 if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay-setting"))) {
4224 mfx->nodisplay_setting = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay-setting")));
4225 if (mfx->nodisplay_setting == NULL)
4226 mfx->nodisplay_setting = strdup("false");
4228 mfx->nodisplay_setting = strdup("false");
4230 if (xmlTextReaderGetAttribute(reader, XMLCHAR("url")))
4231 mfx->package_url= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("url")));
4233 /*Assign default values. If required it will be overwritten in __add_preload_info()*/
4234 mfx->preload = strdup("False");
4235 mfx->removable = strdup("True");
4236 mfx->readonly = strdup("False");
4237 mfx->update = strdup("False");
4238 mfx->system = strdup("False");
4239 char buf[PKG_STRING_LEN_MAX] = {'\0'};
4241 time_t current_time;
4242 time(¤t_time);
4243 snprintf(buf, PKG_STRING_LEN_MAX - 1, "%d", current_time);
4244 val = strndup(buf, PKG_STRING_LEN_MAX - 1);
4245 mfx->installed_time = val;
4247 mfx->installed_storage= strdup("installed_internal");
4249 ret = __start_process(reader, mfx);
4251 _LOGD("No Manifest element found\n");
4258 #define DESKTOP_RW_PATH "/opt/share/applications/"
4259 #define DESKTOP_RO_PATH "/usr/share/applications/"
4260 #define MANIFEST_RO_PREFIX "/usr/share/packages/"
4262 static char* __convert_to_system_locale(const char *mlocale)
4264 if (mlocale == NULL)
4266 char *locale = NULL;
4267 locale = (char *)calloc(1, 6);
4269 _LOGE("Malloc Failed\n");
4273 strncpy(locale, mlocale, 2);
4274 strncat(locale, "_", 1);
4275 locale[3] = toupper(mlocale[3]);
4276 locale[4] = toupper(mlocale[4]);
4280 #define LIBAIL_PATH LIB_PATH "/libail.so.0"
4282 /* operation_type */
4292 static int __ail_change_info(int op, const char *appid)
4294 void *lib_handle = NULL;
4295 int (*ail_desktop_operation) (const char *);
4299 if ((lib_handle = dlopen(LIBAIL_PATH, RTLD_LAZY)) == NULL) {
4300 _LOGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAIL_PATH);
4307 aop = "ail_desktop_add";
4310 aop = "ail_desktop_update";
4313 aop = "ail_desktop_remove";
4316 aop = "ail_desktop_clean";
4319 aop = "ail_desktop_fota";
4326 if ((ail_desktop_operation =
4327 dlsym(lib_handle, aop)) == NULL || dlerror() != NULL) {
4328 _LOGE("can not find symbol \n");
4332 ret = ail_desktop_operation(appid);
4336 dlclose(lib_handle);
4342 /* desktop shoud be generated automatically based on manifest */
4343 /* Currently removable, taskmanage, etc fields are not considerd. it will be decided soon.*/
4344 #define BUFMAX 1024*128
4345 static int __ps_make_nativeapp_desktop(manifest_x * mfx, const char *manifest, ACTION_TYPE action)
4349 char filepath[PKG_STRING_LEN_MAX] = "";
4351 char *buftemp = NULL;
4352 char *locale = NULL;
4354 buf = (char *)calloc(1, BUFMAX);
4356 _LOGE("Malloc Failed\n");
4360 buftemp = (char *)calloc(1, BUFMAX);
4362 _LOGE("Malloc Failed\n");
4367 if (action == ACTION_UPGRADE)
4368 __ail_change_info(AIL_CLEAN, mfx->package);
4370 for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) {
4372 if (manifest != NULL) {
4373 /* skip making a deskfile and update ail, if preload app is updated */
4374 if(strstr(manifest, MANIFEST_RO_PREFIX)) {
4375 __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid);
4376 _LOGE("preload app is update : skip and update ail : %s", manifest);
4381 if(mfx->readonly && !strcasecmp(mfx->readonly, "True"))
4382 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RO_PATH, mfx->uiapplication->appid);
4384 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, mfx->uiapplication->appid);
4386 /* skip if desktop exists
4387 if (access(filepath, R_OK) == 0)
4391 file = fopen(filepath, "w");
4394 _LOGD("Can't open %s", filepath);
4400 snprintf(buf, BUFMAX, "[Desktop Entry]\n");
4401 fwrite(buf, 1, strlen(buf), file);
4403 for( ; mfx->uiapplication->label ; mfx->uiapplication->label = mfx->uiapplication->label->next) {
4404 if(!strcmp(mfx->uiapplication->label->lang, DEFAULT_LOCALE)) {
4405 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
4407 locale = __convert_to_system_locale(mfx->uiapplication->label->lang);
4408 snprintf(buf, BUFMAX, "Name[%s]=%s\n", locale,
4409 mfx->uiapplication->label->text);
4412 fwrite(buf, 1, strlen(buf), file);
4415 if(mfx->uiapplication->label && mfx->uiapplication->label->text) {
4416 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
4417 fwrite(buf, 1, strlen(buf), file);
4420 else if(mfx->label && mfx->label->text) {
4421 snprintf(buf, BUFMAX, "Name=%s\n", mfx->label->text);
4422 fwrite(buf, 1, strlen(buf), file);
4424 snprintf(buf, BUFMAX, "Name=%s\n", mfx->package);
4425 fwrite(buf, 1, strlen(buf), file);
4430 snprintf(buf, BUFMAX, "Type=Application\n");
4431 fwrite(buf, 1, strlen(buf), file);
4433 if(mfx->uiapplication->exec) {
4434 snprintf(buf, BUFMAX, "Exec=%s\n", mfx->uiapplication->exec);
4435 fwrite(buf, 1, strlen(buf), file);
4438 if(mfx->uiapplication->icon && mfx->uiapplication->icon->text) {
4439 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->uiapplication->icon->text);
4440 fwrite(buf, 1, strlen(buf), file);
4441 } else if(mfx->icon && mfx->icon->text) {
4442 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->icon->text);
4443 fwrite(buf, 1, strlen(buf), file);
4447 if(mfx->uiapplication && mfx->uiapplication->appsvc) {
4448 appsvc_x *asvc = mfx->uiapplication->appsvc;
4450 const char *mime = NULL;
4451 const char *mime_delim = "; ";
4454 strncpy(buf, "MimeType=", BUFMAX-1);
4460 _LOGD("MIME type: %s\n", mime);
4461 strncat(buf, mime, BUFMAX-strlen(buf)-1);
4463 strncat(buf, mime_delim, BUFMAX-strlen(buf)-1);
4471 _LOGD("MIME types: buf[%s]\n", buf);
4472 _LOGD("MIME count: %d\n", mime_count);
4474 fwrite(buf, 1, strlen(buf), file);
4478 snprintf(buf, BUFMAX, "Version=%s\n", mfx->version);
4479 fwrite(buf, 1, strlen(buf), file);
4482 if(mfx->uiapplication->nodisplay) {
4483 snprintf(buf, BUFMAX, "NoDisplay=%s\n", mfx->uiapplication->nodisplay);
4484 fwrite(buf, 1, strlen(buf), file);
4487 if(mfx->uiapplication->categories) {
4488 snprintf(buf, BUFMAX, "Categories=%s\n", mfx->uiapplication->categories);
4489 fwrite(buf, 1, strlen(buf), file);
4492 if(mfx->uiapplication->taskmanage && !strcasecmp(mfx->uiapplication->taskmanage, "False")) {
4493 snprintf(buf, BUFMAX, "X-TIZEN-TaskManage=False\n");
4494 fwrite(buf, 1, strlen(buf), file);
4497 if(mfx->uiapplication->enabled && !strcasecmp(mfx->uiapplication->enabled, "False")) {
4498 snprintf(buf, BUFMAX, "X-TIZEN-Enabled=False\n");
4499 fwrite(buf, 1, strlen(buf), file);
4502 if(mfx->uiapplication->hwacceleration) {
4503 snprintf(buf, BUFMAX, "Hw-Acceleration=%s\n", mfx->uiapplication->hwacceleration);
4504 fwrite(buf, 1, strlen(buf), file);
4507 if(mfx->uiapplication->multiple && !strcasecmp(mfx->uiapplication->multiple, "True")) {
4508 snprintf(buf, BUFMAX, "X-TIZEN-Multiple=True\n");
4509 fwrite(buf, 1, strlen(buf), file);
4512 if(mfx->uiapplication->extraid) {
4513 snprintf(buf, BUFMAX, "X-TIZEN-PackageID=%s\n", mfx->uiapplication->extraid);
4514 fwrite(buf, 1, strlen(buf), file);
4517 if(mfx->removable && !strcasecmp(mfx->removable, "False")) {
4518 snprintf(buf, BUFMAX, "X-TIZEN-Removable=False\n");
4519 fwrite(buf, 1, strlen(buf), file);
4523 snprintf(buf, BUFMAX, "X-TIZEN-PackageType=%s\n", mfx->type);
4524 fwrite(buf, 1, strlen(buf), file);
4527 if(mfx->uiapplication->submode && !strcasecmp(mfx->uiapplication->submode, "True")) {
4528 snprintf(buf, BUFMAX, "X-TIZEN-Submode=%s\n", mfx->uiapplication->submode);
4529 fwrite(buf, 1, strlen(buf), file);
4530 snprintf(buf, BUFMAX, "X-TIZEN-SubmodeMainid=%s\n", mfx->uiapplication->submode_mainid);
4531 fwrite(buf, 1, strlen(buf), file);
4534 snprintf(buf, BUFMAX, "X-TIZEN-PkgID=%s\n", mfx->package);
4535 fwrite(buf, 1, strlen(buf), file);
4538 // snprintf(buf, BUFMAX, "X-TIZEN-PackageType=rpm\n");
4539 // fwrite(buf, 1, strlen(buf), file);
4542 if(mfx->uiapplication->appsvc) {
4543 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
4544 _LOGD("buf[%s]\n", buf);
4547 uiapplication_x *up = mfx->uiapplication;
4548 appsvc_x *asvc = NULL;
4549 operation_x *op = NULL;
4552 subapp_x *sub = NULL;
4553 const char *operation = NULL;
4554 const char *mime = NULL;
4555 const char *uri = NULL;
4556 const char *subapp = NULL;
4561 while(asvc != NULL) {
4562 op = asvc->operation;
4565 operation = op->name;
4584 strncpy(buftemp, buf, BUFMAX);
4585 snprintf(buf, BUFMAX, "%s;", buftemp);
4589 strncpy(buftemp, buf, BUFMAX);
4590 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
4591 _LOGD("buf[%s]\n", buf);
4596 } while(ui != NULL);
4600 }while(sub != NULL);
4613 fwrite(buf, 1, strlen(buf), file);
4615 // strncpy(buftemp, buf, BUFMAX);
4616 // snprintf(buf, BUFMAX, "%s\n", buftemp);
4617 // fwrite(buf, 1, strlen(buf), file);
4620 if(mfx->uiapplication->appcontrol) {
4621 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
4622 _LOGD("buf[%s]\n", buf);
4624 uiapplication_x *up = mfx->uiapplication;
4625 appcontrol_x *acontrol = NULL;
4626 operation_x *op = NULL;
4629 subapp_x *sub = NULL;
4630 const char *operation = NULL;
4631 const char *mime = NULL;
4632 const char *uri = NULL;
4633 const char *subapp = NULL;
4636 acontrol = up->appcontrol;
4637 while(acontrol != NULL) {
4638 op = acontrol->operation;
4641 operation = op->name;
4642 mi = acontrol->mime;
4648 sub = acontrol->subapp;
4660 strncpy(buftemp, buf, BUFMAX);
4661 snprintf(buf, BUFMAX, "%s;", buftemp);
4664 strncpy(buftemp, buf, BUFMAX);
4665 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
4666 _LOGD("buf[%s]\n", buf);
4671 } while(ui != NULL);
4675 }while(sub != NULL);
4684 acontrol = acontrol->next;
4688 fwrite(buf, 1, strlen(buf), file);
4690 // strncpy(buftemp, buf, BUFMAX);
4691 // snprintf(buf, BUFMAX, "%s\n", buftemp);
4692 // fwrite(buf, 1, strlen(buf), file);
4699 if (action == ACTION_FOTA)
4700 __ail_change_info(AIL_FOTA, mfx->uiapplication->appid);
4702 __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid);
4711 static int __ps_remove_nativeapp_desktop(manifest_x *mfx)
4713 char filepath[PKG_STRING_LEN_MAX] = "";
4715 uiapplication_x *uiapplication = mfx->uiapplication;
4717 for(; uiapplication; uiapplication=uiapplication->next) {
4718 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, uiapplication->appid);
4720 __ail_change_info(AIL_REMOVE, uiapplication->appid);
4722 ret = remove(filepath);
4730 #define LIBAPPSVC_PATH LIB_PATH "/libappsvc.so.0"
4732 static int __ps_remove_appsvc_db(manifest_x *mfx)
4734 void *lib_handle = NULL;
4735 int (*appsvc_operation) (const char *);
4737 uiapplication_x *uiapplication = mfx->uiapplication;
4739 if ((lib_handle = dlopen(LIBAPPSVC_PATH, RTLD_LAZY)) == NULL) {
4740 _LOGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAPPSVC_PATH);
4744 if ((appsvc_operation =
4745 dlsym(lib_handle, "appsvc_unset_defapp")) == NULL || dlerror() != NULL) {
4746 _LOGE("can not find symbol \n");
4750 for(; uiapplication; uiapplication=uiapplication->next) {
4751 ret = appsvc_operation(uiapplication->appid);
4753 _LOGE("can not operation symbol \n");
4758 dlclose(lib_handle);
4763 #define PRELOAD_PACKAGE_LIST SYSCONFDIR "/package-manager/preload/preload_list.txt"
4764 static int __add_preload_info(manifest_x * mfx, const char *manifest)
4767 char buffer[1024] = { 0 };
4770 if(strstr(manifest, MANIFEST_RO_PREFIX)) {
4771 free((void *)mfx->readonly);
4772 mfx->readonly = strdup("True");
4774 free((void *)mfx->preload);
4775 mfx->preload = strdup("True");
4777 free((void *)mfx->removable);
4778 mfx->removable = strdup("False");
4780 free((void *)mfx->system);
4781 mfx->system = strdup("True");
4786 fp = fopen(PRELOAD_PACKAGE_LIST, "r");
4788 _LOGE("no preload list\n");
4792 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
4793 if (buffer[0] == '#') {
4794 if(strcasestr(buffer, "RW_NORM"))
4796 else if(strcasestr(buffer, "RW_RM"))
4804 if(!strcmp(mfx->package, buffer)) {
4805 free((void *)mfx->preload);
4806 mfx->preload = strdup("True");
4808 free((void *)mfx->readonly);
4809 mfx->readonly = strdup("False");
4810 free((void *)mfx->removable);
4811 mfx->removable = strdup("False");
4812 } else if(state == 3){
4813 free((void *)mfx->readonly);
4814 mfx->readonly = strdup("False");
4815 free((void *)mfx->removable);
4816 mfx->removable = strdup("True");
4820 memset(buffer, 0x00, sizeof(buffer));
4829 static int __check_preload_updated(manifest_x * mfx, const char *manifest)
4831 char filepath[PKG_STRING_LEN_MAX] = "";
4833 uiapplication_x *uiapplication = mfx->uiapplication;
4835 if(strstr(manifest, MANIFEST_RO_PREFIX)) {
4836 /* if preload app is updated, then remove previous desktop file on RW*/
4837 for(; uiapplication; uiapplication=uiapplication->next) {
4838 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, uiapplication->appid);
4839 ret = remove(filepath);
4844 /* if downloaded app is updated, then update tag set true*/
4845 free((void *)mfx->update);
4846 mfx->update = strdup("true");
4853 API int pkgmgr_parser_create_desktop_file(manifest_x *mfx)
4857 _LOGD("Manifest pointer is NULL\n");
4860 ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_INSTALL);
4862 _LOGD("Creating desktop file failed\n");
4864 _LOGD("Creating desktop file Success\n");
4868 API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
4873 free((void *)mfx->ns);
4877 free((void *)mfx->package);
4878 mfx->package = NULL;
4881 free((void *)mfx->version);
4882 mfx->version = NULL;
4884 if (mfx->installlocation) {
4885 free((void *)mfx->installlocation);
4886 mfx->installlocation = NULL;
4889 free((void *)mfx->preload);
4890 mfx->preload = NULL;
4892 if (mfx->readonly) {
4893 free((void *)mfx->readonly);
4894 mfx->readonly = NULL;
4896 if (mfx->removable) {
4897 free((void *)mfx->removable);
4898 mfx->removable = NULL;
4901 free((void *)mfx->update);
4905 free((void *)mfx->system);
4909 free((void *)mfx->type);
4912 if (mfx->package_size) {
4913 free((void *)mfx->package_size);
4914 mfx->package_size = NULL;
4916 if (mfx->installed_time) {
4917 free((void *)mfx->installed_time);
4918 mfx->installed_time = NULL;
4920 if (mfx->installed_storage) {
4921 free((void *)mfx->installed_storage);
4922 mfx->installed_storage = NULL;
4924 if (mfx->storeclient_id) {
4925 free((void *)mfx->storeclient_id);
4926 mfx->storeclient_id = NULL;
4928 if (mfx->mainapp_id) {
4929 free((void *)mfx->mainapp_id);
4930 mfx->mainapp_id = NULL;
4932 if (mfx->package_url) {
4933 free((void *)mfx->package_url);
4934 mfx->package_url = NULL;
4936 if (mfx->root_path) {
4937 free((void *)mfx->root_path);
4938 mfx->root_path = NULL;
4940 if (mfx->csc_path) {
4941 free((void *)mfx->csc_path);
4942 mfx->csc_path = NULL;
4944 if (mfx->appsetting) {
4945 free((void *)mfx->appsetting);
4946 mfx->appsetting = NULL;
4948 if (mfx->nodisplay_setting) {
4949 free((void *)mfx->nodisplay_setting);
4950 mfx->nodisplay_setting = NULL;
4952 if (mfx->main_package) {
4953 free((void *)mfx->main_package);
4954 mfx->main_package = NULL;
4959 icon_x *icon = mfx->icon;
4961 while(icon != NULL) {
4963 __ps_free_icon(icon);
4969 label_x *label = mfx->label;
4970 label_x *tmp = NULL;
4971 while(label != NULL) {
4973 __ps_free_label(label);
4979 author_x *author = mfx->author;
4980 author_x *tmp = NULL;
4981 while(author != NULL) {
4983 __ps_free_author(author);
4987 /*Free Description*/
4988 if (mfx->description) {
4989 description_x *description = mfx->description;
4990 description_x *tmp = NULL;
4991 while(description != NULL) {
4992 tmp = description->next;
4993 __ps_free_description(description);
4999 license_x *license = mfx->license;
5000 license_x *tmp = NULL;
5001 while(license != NULL) {
5002 tmp = license->next;
5003 __ps_free_license(license);
5008 if (mfx->privileges) {
5009 privileges_x *privileges = mfx->privileges;
5010 privileges_x *tmp = NULL;
5011 while(privileges != NULL) {
5012 tmp = privileges->next;
5013 __ps_free_privileges(privileges);
5017 /*Free UiApplication*/
5018 if (mfx->uiapplication) {
5019 uiapplication_x *uiapplication = mfx->uiapplication;
5020 uiapplication_x *tmp = NULL;
5021 while(uiapplication != NULL) {
5022 tmp = uiapplication->next;
5023 __ps_free_uiapplication(uiapplication);
5024 uiapplication = tmp;
5027 /*Free ServiceApplication*/
5028 if (mfx->serviceapplication) {
5029 serviceapplication_x *serviceapplication = mfx->serviceapplication;
5030 serviceapplication_x *tmp = NULL;
5031 while(serviceapplication != NULL) {
5032 tmp = serviceapplication->next;
5033 __ps_free_serviceapplication(serviceapplication);
5034 serviceapplication = tmp;
5039 daemon_x *daemon = mfx->daemon;
5040 daemon_x *tmp = NULL;
5041 while(daemon != NULL) {
5043 __ps_free_daemon(daemon);
5049 theme_x *theme = mfx->theme;
5050 theme_x *tmp = NULL;
5051 while(theme != NULL) {
5053 __ps_free_theme(theme);
5059 font_x *font = mfx->font;
5061 while(font != NULL) {
5063 __ps_free_font(font);
5069 ime_x *ime = mfx->ime;
5071 while(ime != NULL) {
5077 /*Free Compatibility*/
5078 if (mfx->compatibility) {
5079 compatibility_x *compatibility = mfx->compatibility;
5080 compatibility_x *tmp = NULL;
5081 while(compatibility != NULL) {
5082 tmp = compatibility->next;
5083 __ps_free_compatibility(compatibility);
5084 compatibility = tmp;
5087 /*Free DeviceProfile*/
5088 if (mfx->deviceprofile) {
5089 deviceprofile_x *deviceprofile = mfx->deviceprofile;
5090 deviceprofile_x *tmp = NULL;
5091 while(deviceprofile != NULL) {
5092 tmp = deviceprofile->next;
5093 __ps_free_deviceprofile(deviceprofile);
5094 deviceprofile = tmp;
5102 API manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest)
5104 _LOGD("parsing start\n");
5105 xmlTextReaderPtr reader;
5106 manifest_x *mfx = NULL;
5108 reader = xmlReaderForFile(manifest, NULL, 0);
5110 mfx = malloc(sizeof(manifest_x));
5112 memset(mfx, '\0', sizeof(manifest_x));
5113 if (__process_manifest(reader, mfx) < 0) {
5114 _LOGD("Parsing Failed\n");
5115 pkgmgr_parser_free_manifest_xml(mfx);
5118 _LOGD("Parsing Success\n");
5120 _LOGD("Memory allocation error\n");
5122 xmlFreeTextReader(reader);
5124 _LOGD("Unable to create xml reader\n");
5129 /* These APIs are intended to call parser directly */
5131 API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
5133 // char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
5134 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5135 _LOGD("parsing manifest for installation: %s\n", manifest);
5137 manifest_x *mfx = NULL;
5141 mfx = pkgmgr_parser_process_manifest_xml(manifest);
5142 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5144 _LOGD("Parsing Finished\n");
5146 // __streamFile(manifest, ACTION_INSTALL, temp, mfx->package);
5147 __ps_process_tag_parser(mfx, manifest, ACTION_INSTALL);
5148 __add_preload_info(mfx, manifest);
5150 _LOGD("Added preload infomation\n");
5152 __ps_process_tag(mfx, tagv);
5154 ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
5155 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
5157 _LOGD("DB Insert Success\n");
5159 ret = __ps_process_metadata_parser(mfx, ACTION_INSTALL);
5161 _LOGD("Creating metadata parser failed\n");
5163 ret = __ps_process_category_parser(mfx, ACTION_INSTALL);
5165 _LOGD("Creating category parser failed\n");
5167 if (__check_action_fota(tagv))
5168 ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_FOTA);
5170 ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_INSTALL);
5173 _LOGD("Creating desktop file failed\n");
5175 _LOGD("Creating desktop file Success\n");
5177 pkgmgr_parser_free_manifest_xml(mfx);
5178 _LOGD("Free Done\n");
5184 API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
5186 // char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
5187 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5188 _LOGD("parsing manifest for upgradation: %s\n", manifest);
5190 manifest_x *mfx = NULL;
5192 bool preload = false;
5193 bool system = false;
5194 char *csc_path = NULL;
5195 pkgmgrinfo_pkginfo_h handle = NULL;
5198 mfx = pkgmgr_parser_process_manifest_xml(manifest);
5199 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5201 _LOGD("Parsing Finished\n");
5203 // __streamFile(manifest, ACTION_UPGRADE, temp, mfx->package);
5204 __ps_process_tag_parser(mfx, manifest, ACTION_UPGRADE);
5205 __add_preload_info(mfx, manifest);
5206 _LOGD("Added preload infomation\n");
5207 __check_preload_updated(mfx, manifest);
5209 ret = pkgmgrinfo_pkginfo_get_pkginfo(mfx->package, &handle);
5210 if (ret != PMINFO_R_OK)
5211 _LOGD("pkgmgrinfo_pkginfo_get_pkginfo failed\n");
5213 ret = pkgmgrinfo_pkginfo_is_preload(handle, &preload);
5214 if (ret != PMINFO_R_OK)
5215 _LOGD("pkgmgrinfo_pkginfo_is_preload failed\n");
5218 free((void *)mfx->preload);
5219 mfx->preload = strdup("true");
5222 ret = pkgmgrinfo_pkginfo_is_system(handle, &system);
5223 if (ret != PMINFO_R_OK)
5224 _LOGD("pkgmgrinfo_pkginfo_is_system failed\n");
5227 free((void *)mfx->system);
5228 mfx->system = strdup("true");
5231 ret = pkgmgrinfo_pkginfo_get_csc_path(handle, &csc_path);
5232 if (ret != PMINFO_R_OK)
5233 _LOGD("pkgmgrinfo_pkginfo_get_csc_path failed\n");
5235 if (csc_path != NULL) {
5237 free((void *)mfx->csc_path);
5238 mfx->csc_path = strdup(csc_path);
5241 ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
5242 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
5243 _LOGD("DB Update Success\n");
5245 ret = __ps_process_metadata_parser(mfx, ACTION_UPGRADE);
5247 _LOGD("Upgrade metadata parser failed\n");
5249 ret = __ps_process_category_parser(mfx, ACTION_UPGRADE);
5251 _LOGD("Creating category parser failed\n");
5253 ret = __ps_make_nativeapp_desktop(mfx, manifest, ACTION_UPGRADE);
5255 _LOGD("Creating desktop file failed\n");
5257 _LOGD("Creating desktop file Success\n");
5259 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
5260 pkgmgr_parser_free_manifest_xml(mfx);
5261 _LOGD("Free Done\n");
5267 API int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[])
5269 // char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
5270 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5271 _LOGD("parsing manifest for uninstallation: %s\n", manifest);
5273 manifest_x *mfx = NULL;
5276 mfx = pkgmgr_parser_process_manifest_xml(manifest);
5277 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5279 _LOGD("Parsing Finished\n");
5281 // __streamFile(manifest, ACTION_UNINSTALL, temp, mfx->package);
5282 __ps_process_tag_parser(mfx, manifest, ACTION_UNINSTALL);
5284 __add_preload_info(mfx, manifest);
5285 _LOGD("Added preload infomation\n");
5287 ret = __ps_process_metadata_parser(mfx, ACTION_UNINSTALL);
5289 _LOGD("Removing metadata parser failed\n");
5291 ret = __ps_process_category_parser(mfx, ACTION_UNINSTALL);
5293 _LOGD("Creating category parser failed\n");
5295 ret = pkgmgr_parser_delete_manifest_info_from_db(mfx);
5297 _LOGD("DB Delete failed\n");
5299 _LOGD("DB Delete Success\n");
5301 ret = __ps_remove_nativeapp_desktop(mfx);
5303 _LOGD("Removing desktop file failed\n");
5305 _LOGD("Removing desktop file Success\n");
5307 ret = __ps_remove_appsvc_db(mfx);
5309 _LOGD("Removing appsvc_db failed\n");
5311 _LOGD("Removing appsvc_db Success\n");
5313 pkgmgr_parser_free_manifest_xml(mfx);
5314 _LOGD("Free Done\n");
5320 API int pkgmgr_parser_parse_manifest_for_preload()
5322 return pkgmgr_parser_update_preload_info_in_db();
5325 API char *pkgmgr_parser_get_manifest_file(const char *pkgid)
5327 return __pkgid_to_manifest(pkgid);
5330 API int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
5332 return __ps_run_parser(docPtr, tag, ACTION_INSTALL, pkgid);
5335 API int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgid)
5337 return __ps_run_parser(docPtr, tag, ACTION_UPGRADE, pkgid);
5340 API int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
5342 return __ps_run_parser(docPtr, tag, ACTION_UNINSTALL, pkgid);
5345 #define SCHEMA_FILE SYSCONFDIR "/package-manager/preload/manifest.xsd"
5347 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
5349 if (manifest == NULL) {
5350 _LOGE("manifest file is NULL\n");
5351 return PMINFO_R_EINVAL;
5354 xmlSchemaParserCtxtPtr ctx;
5355 xmlSchemaValidCtxtPtr vctx;
5356 xmlSchemaPtr xschema;
5357 ctx = xmlSchemaNewParserCtxt(SCHEMA_FILE);
5359 _LOGE("xmlSchemaNewParserCtxt() Failed\n");
5360 return PMINFO_R_ERROR;
5362 xschema = xmlSchemaParse(ctx);
5363 if (xschema == NULL) {
5364 _LOGE("xmlSchemaParse() Failed\n");
5365 return PMINFO_R_ERROR;
5367 vctx = xmlSchemaNewValidCtxt(xschema);
5369 _LOGE("xmlSchemaNewValidCtxt() Failed\n");
5370 return PMINFO_R_ERROR;
5372 xmlSchemaSetValidErrors(vctx, (xmlSchemaValidityErrorFunc) fprintf, (xmlSchemaValidityWarningFunc) fprintf, stderr);
5373 ret = xmlSchemaValidateFile(vctx, manifest, 0);
5375 _LOGE("xmlSchemaValidateFile() failed\n");
5376 return PMINFO_R_ERROR;
5377 } else if (ret == 0) {
5378 _LOGE("Manifest is Valid\n");
5381 _LOGE("Manifest Validation Failed with error code %d\n", ret);
5382 return PMINFO_R_ERROR;
5388 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
5398 _LOGE("fork failed\n");
5403 int dev_null_fd = open ("/dev/null", O_RDWR);
5404 if (dev_null_fd >= 0)
5406 dup2 (dev_null_fd, 0);/*stdin*/
5407 dup2 (dev_null_fd, 1);/*stdout*/
5408 dup2 (dev_null_fd, 2);/*stderr*/
5411 if (execl("/usr/bin/xmllint", "xmllint", manifest, "--schema",
5412 SCHEMA_FILE, NULL) < 0) {
5413 _LOGE("execl error\n");
5423 while ((err = waitpid(pid, &status, WNOHANG)) != pid) {
5427 _LOGE("waitpid failed\n");
5433 if(WIFEXITED(status) && !WEXITSTATUS(status))