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 /* For multi-user support */
38 #include <tzplatform_config.h>
40 #include "pkgmgr_parser.h"
41 #include "pkgmgr_parser_internal.h"
42 #include "pkgmgr_parser_db.h"
43 #include "pkgmgr-info.h"
44 #include "pkgmgr_parser_signature.h"
45 #include "pkgmgr-info-debug.h"
50 #define LOG_TAG "PKGMGR_PARSER"
52 #define MANIFEST_RW_DIRECTORY tzplatform_getenv(TZ_SYS_RW_PACKAGES)
53 #define MANIFEST_RO_DIRECTORY tzplatform_getenv(TZ_SYS_RO_PACKAGES)
54 #define ASCII(s) (const char *)s
55 #define XMLCHAR(s) (const xmlChar *)s
57 #define METADATA_PARSER_LIST SYSCONFDIR "/package-manager/parserlib/metadata/metadata_parser_list.txt"
58 #define METADATA_PARSER_NAME "metadataparser:"
60 #define CATEGORY_PARSER_LIST SYSCONFDIR "/package-manager/parserlib/category/category_parser_list.txt"
61 #define CATEGORY_PARSER_NAME "categoryparser:"
63 #define TAG_PARSER_LIST SYSCONFDIR "/package-manager/parserlib/tag_parser_list.txt"
64 #define TAG_PARSER_NAME "parserlib:"
66 #define PKG_TAG_LEN_MAX 128
77 /* plugin process_type */
79 PLUGIN_PRE_PROCESS = 0,
81 } PLUGIN_PROCESS_TYPE;
94 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label);
95 static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege);
96 static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privileges);
97 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile);
98 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed);
99 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation);
100 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri);
101 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime);
102 static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp);
103 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition);
104 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notifiation);
105 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category);
106 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata);
107 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission);
108 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility);
109 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution);
110 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request);
111 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define);
112 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc);
113 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions);
114 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare);
115 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon);
116 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author);
117 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description);
118 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability);
119 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license);
120 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol);
121 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol);
122 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication);
123 static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication);
124 static int __ps_process_font(xmlTextReaderPtr reader, font_x *font);
125 static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme);
126 static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon);
127 static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime);
128 static void __ps_free_label(label_x *label);
129 static void __ps_free_privilege(privilege_x *privilege);
130 static void __ps_free_privileges(privileges_x *privileges);
131 static void __ps_free_deviceprofile(deviceprofile_x * deviceprofile);
132 static void __ps_free_allowed(allowed_x *allowed);
133 static void __ps_free_operation(operation_x *operation);
134 static void __ps_free_uri(uri_x *uri);
135 static void __ps_free_mime(mime_x *mime);
136 static void __ps_free_subapp(subapp_x *subapp);
137 static void __ps_free_condition(condition_x *condition);
138 static void __ps_free_notification(notification_x *notifiation);
139 static void __ps_free_category(category_x *category);
140 static void __ps_free_metadata(metadata_x *metadata);
141 static void __ps_free_permission(permission_x *permission);
142 static void __ps_free_compatibility(compatibility_x *compatibility);
143 static void __ps_free_resolution(resolution_x *resolution);
144 static void __ps_free_request(request_x *request);
145 static void __ps_free_define(define_x *define);
146 static void __ps_free_appsvc(appsvc_x *appsvc);
147 static void __ps_free_launchconditions(launchconditions_x *launchconditions);
148 static void __ps_free_datashare(datashare_x *datashare);
149 static void __ps_free_icon(icon_x *icon);
150 static void __ps_free_author(author_x *author);
151 static void __ps_free_description(description_x *description);
152 static void __ps_free_capability(capability_x *capability);
153 static void __ps_free_license(license_x *license);
154 static void __ps_free_appcontrol(appcontrol_x *appcontrol);
155 static void __ps_free_datacontrol(datacontrol_x *datacontrol);
156 static void __ps_free_uiapplication(uiapplication_x *uiapplication);
157 static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication);
158 static void __ps_free_font(font_x *font);
159 static void __ps_free_theme(theme_x *theme);
160 static void __ps_free_daemon(daemon_x *daemon);
161 static void __ps_free_ime(ime_x *ime);
162 static char *__pkgid_to_manifest(const char *pkgid);
163 static int __next_child_element(xmlTextReaderPtr reader, int depth);
164 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx);
165 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx);
166 static void __str_trim(char *input);
167 static char *__get_parser_plugin(const char *type);
168 static int __ps_run_parser(xmlDocPtr docPtr, const char *tag, ACTION_TYPE action, const char *pkgid);
169 static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid);
170 static void __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgid);
171 static void __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid);
172 static int __validate_appid(const char *pkgid, const char *appid, char **newappid);
174 void *__open_lib_handle(char *tag)
176 char *lib_path = NULL;
177 void *lib_handle = NULL;
179 lib_path = __get_parser_plugin(tag);
180 retvm_if(!lib_path, NULL, "lib_path get fail");
182 lib_handle = dlopen(lib_path, RTLD_LAZY);
183 retvm_if(lib_handle == NULL, NULL, "dlopen is failed lib_path[%s]", lib_path);
188 void __close_lib_handle(void *lib_handle)
193 static void __str_trim(char *input)
195 char *trim_str = input;
200 while (*input != 0) {
201 if (!isspace(*input)) {
212 static int __validate_appid(const char *pkgid, const char *appid, char **newappid)
214 if (!pkgid || !appid || !newappid) {
215 _LOGD("Arg supplied is NULL\n");
218 int pkglen = strlen(pkgid);
219 int applen = strlen(appid);
223 if (strncmp(appid, ".", 1) == 0) {
224 len = pkglen + applen + 1;
225 newapp = calloc(1,len);
226 if (newapp == NULL) {
227 _LOGD("Malloc failed\n");
230 strncpy(newapp, pkgid, pkglen);
231 strncat(newapp, appid, applen);
232 _LOGD("new appid is %s\n", newapp);
236 if (applen < pkglen) {
237 _LOGD("app id is not proper\n");
239 #ifdef _VALIDATE_APPID_
245 if (!strcmp(appid, pkgid)) {
246 _LOGD("appid is proper\n");
250 else if (strncmp(appid, pkgid, pkglen) == 0) {
251 ptr = strstr(appid, pkgid);
253 if (strncmp(ptr, ".", 1) == 0) {
254 _LOGD("appid is proper\n");
259 _LOGD("appid is not proper\n");
261 #ifdef _VALIDATE_APPID_
268 _LOGD("appid is not proper\n");
270 #ifdef _VALIDATE_APPID_
279 static char * __get_tag_by_key(char *md_key)
283 if (md_key == NULL) {
284 _LOGD("md_key is NULL\n");
288 md_tag = strrchr(md_key, 47) + 1;
291 return strdup(md_tag);
294 static char *__get_metadata_parser_plugin(const char *type)
297 char buffer[1024] = { 0 };
298 char temp_path[1024] = { 0 };
302 _LOGE("invalid argument\n");
306 fp = fopen(PKG_PARSER_CONF_PATH, "r");
308 _LOGE("no matching metadata parser\n");
312 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
313 if (buffer[0] == '#')
318 if ((path = strstr(buffer, METADATA_PARSER_NAME)) != NULL) {
319 path = path + strlen(METADATA_PARSER_NAME);
324 memset(buffer, 0x00, 1024);
331 _LOGE("no matching [%s] [%s]\n", METADATA_PARSER_NAME,type);
335 snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
337 return strdup(temp_path);
340 static char *__get_category_parser_plugin(const char *type)
343 char buffer[1024] = { 0 };
344 char temp_path[1024] = { 0 };
348 _LOGE("invalid argument\n");
352 fp = fopen(PKG_PARSER_CONF_PATH, "r");
354 _LOGE("no matching metadata parser\n");
358 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
359 if (buffer[0] == '#')
364 if ((path = strstr(buffer, CATEGORY_PARSER_NAME)) != NULL) {
365 path = path + strlen(CATEGORY_PARSER_NAME);
370 memset(buffer, 0x00, 1024);
377 _LOGE("no matching [%s] [%s]\n", CATEGORY_PARSER_NAME,type);
381 snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
383 return strdup(temp_path);
386 static char *__get_parser_plugin(const char *type)
389 char buffer[1024] = { 0 };
390 char temp_path[1024] = { 0 };
394 _LOGE("invalid argument\n");
398 fp = fopen(PKG_PARSER_CONF_PATH, "r");
400 _LOGE("no matching backendlib\n");
404 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
405 if (buffer[0] == '#')
410 if ((path = strstr(buffer, PKG_PARSERLIB)) != NULL) {
411 path = path + strlen(PKG_PARSERLIB);
415 memset(buffer, 0x00, 1024);
422 _LOGE("no matching backendlib\n");
426 snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
428 return strdup(temp_path);
431 static int __ps_run_tag_parser(void *lib_handle, xmlDocPtr docPtr, const char *tag,
432 ACTION_TYPE action, const char *pkgid)
434 int (*plugin_install) (xmlDocPtr, const char *);
440 ac = "PKGMGR_PARSER_PLUGIN_INSTALL";
443 ac = "PKGMGR_PARSER_PLUGIN_UPGRADE";
445 case ACTION_UNINSTALL:
446 ac = "PKGMGR_PARSER_PLUGIN_UNINSTALL";
452 if ((plugin_install =
453 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
454 _LOGE("can not find symbol[%s] \n", ac);
458 ret = plugin_install(docPtr, pkgid);
459 _LOGD("tag parser[%s, %s] ACTION_TYPE[%d] result[%d]\n", pkgid, tag, action, ret);
465 static int __ps_run_metadata_parser(GList *md_list, const char *tag,
466 ACTION_TYPE action, const char *pkgid, const char *appid)
468 char *lib_path = NULL;
469 void *lib_handle = NULL;
470 int (*metadata_parser_plugin) (const char *, const char *, GList *);
476 ac = "PKGMGR_MDPARSER_PLUGIN_INSTALL";
479 ac = "PKGMGR_MDPARSER_PLUGIN_UPGRADE";
481 case ACTION_UNINSTALL:
482 ac = "PKGMGR_MDPARSER_PLUGIN_UNINSTALL";
488 lib_path = __get_metadata_parser_plugin(tag);
490 _LOGE("get %s parser fail\n", tag);
494 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
495 _LOGE("dlopen is failed lib_path[%s]\n", lib_path);
499 if ((metadata_parser_plugin =
500 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
501 _LOGE("can not find symbol[%s] \n",ac);
505 ret = metadata_parser_plugin(pkgid, appid, md_list);
507 _LOGD("[appid = %s, libpath = %s plugin fail\n", appid, lib_path);
509 _LOGD("[appid = %s, libpath = %s plugin success\n", appid, lib_path);
519 static int __ps_run_category_parser(GList *category_list, const char *tag,
520 ACTION_TYPE action, const char *pkgid, const char *appid)
522 char *lib_path = NULL;
523 void *lib_handle = NULL;
524 int (*category_parser_plugin) (const char *, const char *, GList *);
530 ac = "PKGMGR_CATEGORY_PARSER_PLUGIN_INSTALL";
533 ac = "PKGMGR_CATEGORY_PARSER_PLUGIN_UPGRADE";
535 case ACTION_UNINSTALL:
536 ac = "PKGMGR_CATEGORY_PARSER_PLUGIN_UNINSTALL";
542 lib_path = __get_category_parser_plugin(tag);
544 _LOGE("get %s parser fail\n", tag);
548 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
549 _LOGE("dlopen is failed lib_path[%s]\n", lib_path);
553 if ((category_parser_plugin =
554 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
555 _LOGE("can not find symbol[%s] \n",ac);
559 ret = category_parser_plugin(pkgid, appid, category_list);
561 _LOGD("[appid = %s, libpath = %s plugin fail\n", appid, lib_path);
563 _LOGD("[appid = %s, libpath = %s plugin success\n", appid, lib_path);
573 static int __ps_run_parser(xmlDocPtr docPtr, const char *tag,
574 ACTION_TYPE action, const char *pkgid)
576 char *lib_path = NULL;
577 void *lib_handle = NULL;
578 int (*plugin_install) (xmlDocPtr, const char *);
584 ac = "PKGMGR_PARSER_PLUGIN_INSTALL";
587 ac = "PKGMGR_PARSER_PLUGIN_UPGRADE";
589 case ACTION_UNINSTALL:
590 ac = "PKGMGR_PARSER_PLUGIN_UNINSTALL";
596 lib_path = __get_parser_plugin(tag);
601 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
602 _LOGE("dlopen is failed lib_path[%s]\n", lib_path);
605 if ((plugin_install =
606 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
607 _LOGE("can not find symbol[%s] \n", ac);
611 ret = plugin_install(docPtr, pkgid);
613 _LOGD("[pkgid = %s, libpath = %s plugin fail\n", pkgid, lib_path);
615 _LOGD("[pkgid = %s, libpath = %s plugin success\n", pkgid, lib_path);
625 static char *__pkgid_to_manifest(const char *pkgid)
631 _LOGE("pkgid is NULL");
635 size = strlen(MANIFEST_RW_DIRECTORY) + strlen(pkgid) + 10;
636 manifest = malloc(size);
637 if (manifest == NULL) {
641 memset(manifest, '\0', size);
642 snprintf(manifest, size, "%s/%s.xml", MANIFEST_RW_DIRECTORY, pkgid);
644 if (access(manifest, F_OK)) {
645 snprintf(manifest, size, "%s/%s.xml", MANIFEST_RO_DIRECTORY, pkgid);
651 static void __metadata_parser_clear_dir_list(GList* dir_list)
654 __metadata_t* detail = NULL;
657 list = g_list_first(dir_list);
659 detail = (__metadata_t *)list->data;
667 list = g_list_next(list);
669 g_list_free(dir_list);
673 static void __category_parser_clear_dir_list(GList* dir_list)
676 __category_t* detail = NULL;
679 list = g_list_first(dir_list);
681 detail = (__category_t *)list->data;
688 list = g_list_next(list);
690 g_list_free(dir_list);
694 static int __run_tag_parser_prestep(void *lib_handle, xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid)
699 if (xmlTextReaderDepth(reader) != 1) {
700 _LOGE("Node depth is not 1");
704 if (xmlTextReaderNodeType(reader) != 1) {
705 _LOGE("Node type is not 1");
709 const xmlChar *value;
710 name = xmlTextReaderConstName(reader);
712 _LOGE("TEST TEST TES\n");
713 name = BAD_CAST "--";
716 value = xmlTextReaderConstValue(reader);
718 if (xmlStrlen(value) > 40) {
719 _LOGD(" %.40s...", value);
725 name = xmlTextReaderConstName(reader);
727 _LOGE("TEST TEST TES\n");
728 name = BAD_CAST "--";
731 xmlDocPtr docPtr = xmlTextReaderCurrentDoc(reader);
732 xmlDocPtr copyDocPtr = xmlCopyDoc(docPtr, 1);
733 if (copyDocPtr == NULL)
735 xmlNode *rootElement = xmlDocGetRootElement(copyDocPtr);
736 if (rootElement == NULL)
738 xmlNode *cur_node = xmlFirstElementChild(rootElement);
739 if (cur_node == NULL)
741 xmlNode *temp = xmlTextReaderExpand(reader);
744 xmlNode *next_node = NULL;
745 while(cur_node != NULL) {
746 if ( (strcmp(ASCII(temp->name), ASCII(cur_node->name)) == 0) &&
747 (temp->line == cur_node->line) ) {
751 next_node = xmlNextElementSibling(cur_node);
752 xmlUnlinkNode(cur_node);
753 xmlFreeNode(cur_node);
754 cur_node = next_node;
757 if (cur_node == NULL)
759 next_node = xmlNextElementSibling(cur_node);
761 cur_node->next = NULL;
762 next_node->prev = NULL;
763 xmlFreeNodeList(next_node);
764 xmlSetTreeDoc(cur_node, copyDocPtr);
766 xmlSetTreeDoc(cur_node, copyDocPtr);
769 ret = __ps_run_tag_parser(lib_handle, copyDocPtr, ASCII(name), action, pkgid);
775 static int __run_metadata_parser_prestep (manifest_x *mfx, char *md_key, ACTION_TYPE action)
779 char buffer[1024] = { 0, };
780 uiapplication_x *up = mfx->uiapplication;
781 metadata_x *md = NULL;
784 GList *md_list = NULL;
785 __metadata_t *md_detail = NULL;
787 md_tag = __get_tag_by_key(md_key);
788 if (md_tag == NULL) {
789 _LOGD("md_tag is NULL\n");
798 //get glist of metadata key and value combination
799 memset(buffer, 0x00, 1024);
800 snprintf(buffer, 1024, "%s/", md_key);
801 if ((md->key && md->value) && (strncmp(md->key, md_key, strlen(md_key)) == 0) && (strncmp(buffer, md->key, strlen(buffer)) == 0)) {
802 md_detail = (__metadata_t*) calloc(1, sizeof(__metadata_t));
803 if (md_detail == NULL) {
804 _LOGD("Memory allocation failed\n");
808 md_detail->key = (char*) calloc(1, sizeof(char)*(strlen(md->key)+2));
809 if (md_detail->key == NULL) {
810 _LOGD("Memory allocation failed\n");
814 snprintf(md_detail->key, (strlen(md->key)+1), "%s", md->key);
816 md_detail->value = (char*) calloc(1, sizeof(char)*(strlen(md->value)+2));
817 if (md_detail->value == NULL) {
818 _LOGD("Memory allocation failed\n");
819 free(md_detail->key);
823 snprintf(md_detail->value, (strlen(md->value)+1), "%s", md->value);
825 md_list = g_list_append(md_list, (gpointer)md_detail);
831 //send glist to parser when tags for metadata plugin parser exist.
833 ret = __ps_run_metadata_parser(md_list, md_tag, action, mfx->package, up->appid);
835 _LOGD("metadata_parser failed[%d] for tag[%s]\n", ret, md_tag);
837 _LOGD("metadata_parser success for tag[%s]\n", md_tag);
839 __metadata_parser_clear_dir_list(md_list);
847 __metadata_parser_clear_dir_list(md_list);
855 static int __run_category_parser_prestep (manifest_x *mfx, char *category_key, ACTION_TYPE action)
859 char buffer[1024] = { 0, };
860 uiapplication_x *up = mfx->uiapplication;
861 category_x *category = NULL;
862 char *category_tag = NULL;
864 GList *category_list = NULL;
865 __category_t *category_detail = NULL;
867 category_tag = __get_tag_by_key(category_key);
868 if (category_tag == NULL) {
869 _LOGD("md_tag is NULL\n");
875 category = up->category;
876 while (category != NULL)
878 //get glist of category key and value combination
879 memset(buffer, 0x00, 1024);
880 snprintf(buffer, 1024, "%s/", category_key);
881 if ((category->name) && (strncmp(category->name, category_key, strlen(category_key)) == 0)) {
882 category_detail = (__category_t*) calloc(1, sizeof(__category_t));
883 if (category_detail == NULL) {
884 _LOGD("Memory allocation failed\n");
888 category_detail->name = (char*) calloc(1, sizeof(char)*(strlen(category->name)+2));
889 if (category_detail->name == NULL) {
890 _LOGD("Memory allocation failed\n");
891 free(category_detail);
894 snprintf(category_detail->name, (strlen(category->name)+1), "%s", category->name);
896 category_list = g_list_append(category_list, (gpointer)category_detail);
899 category = category->next;
902 //send glist to parser when tags for metadata plugin parser exist.
904 ret = __ps_run_category_parser(category_list, category_tag, action, mfx->package, up->appid);
906 _LOGD("category_parser failed[%d] for tag[%s]\n", ret, category_tag);
908 _LOGD("category_parser success for tag[%s]\n", category_tag);
910 __category_parser_clear_dir_list(category_list);
911 category_list = NULL;
918 __category_parser_clear_dir_list(category_list);
926 static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid)
931 // _LOGD("__run_parser_prestep");
933 if (xmlTextReaderDepth(reader) != 1) {
934 _LOGE("Node depth is not 1");
938 if (xmlTextReaderNodeType(reader) != 1) {
939 _LOGE("Node type is not 1");
943 const xmlChar *value;
944 name = xmlTextReaderConstName(reader);
946 _LOGE("TEST TEST TES\n");
947 name = BAD_CAST "--";
950 value = xmlTextReaderConstValue(reader);
951 _LOGD("%d %d %s %d %d",
952 xmlTextReaderDepth(reader),
953 xmlTextReaderNodeType(reader),
955 xmlTextReaderIsEmptyElement(reader), xmlTextReaderHasValue(reader));
958 if (xmlStrlen(value) > 40) {
959 _LOGD(" %.40s...", value);
965 name = xmlTextReaderConstName(reader);
967 _LOGE("TEST TEST TES\n");
968 name = BAD_CAST "--";
971 xmlDocPtr docPtr = xmlTextReaderCurrentDoc(reader);
972 _LOGD("docPtr->URL %s\n", (char *)docPtr->URL);
973 xmlDocPtr copyDocPtr = xmlCopyDoc(docPtr, 1);
974 if (copyDocPtr == NULL)
976 xmlNode *rootElement = xmlDocGetRootElement(copyDocPtr);
977 if (rootElement == NULL)
979 xmlNode *cur_node = xmlFirstElementChild(rootElement);
980 if (cur_node == NULL)
982 xmlNode *temp = xmlTextReaderExpand(reader);
985 xmlNode *next_node = NULL;
986 while(cur_node != NULL) {
987 if ( (strcmp(ASCII(temp->name), ASCII(cur_node->name)) == 0) &&
988 (temp->line == cur_node->line) ) {
992 next_node = xmlNextElementSibling(cur_node);
993 xmlUnlinkNode(cur_node);
994 xmlFreeNode(cur_node);
995 cur_node = next_node;
998 if (cur_node == NULL)
1000 next_node = xmlNextElementSibling(cur_node);
1002 cur_node->next = NULL;
1003 next_node->prev = NULL;
1004 xmlFreeNodeList(next_node);
1005 xmlSetTreeDoc(cur_node, copyDocPtr);
1007 xmlSetTreeDoc(cur_node, copyDocPtr);
1013 _LOGD("node type: %d, name: %s children->name: %s last->name: %s\n"
1014 "parent->name: %s next->name: %s prev->name: %s\n",
1015 cur_node->type, cur_node->name,
1016 cur_node->children ? cur_node->children->name : "NULL",
1017 cur_node->last ? cur_node->last->name : "NULL",
1018 cur_node->parent ? cur_node->parent->name : "NULL",
1019 cur_node->next ? cur_node->next->name : "NULL",
1020 cur_node->prev ? cur_node->prev->name : "NULL");
1022 FILE *fp = fopen("/opt/share/test.xml", "a");
1023 xmlDocDump(fp, copyDocPtr);
1028 ret = __ps_run_parser(copyDocPtr, ASCII(name), action, pkgid);
1035 __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgid)
1040 switch (xmlTextReaderNodeType(reader)) {
1041 case XML_READER_TYPE_END_ELEMENT:
1043 // _LOGD("XML_READER_TYPE_END_ELEMENT");
1047 case XML_READER_TYPE_ELEMENT:
1049 // Elements without closing tag don't receive
1050 // XML_READER_TYPE_END_ELEMENT event.
1052 const xmlChar *elementName =
1053 xmlTextReaderLocalName(reader);
1054 if (elementName == NULL) {
1055 // _LOGD("elementName %s\n", (char *)elementName);
1059 const xmlChar *nameSpace =
1060 xmlTextReaderConstNamespaceUri(reader);
1062 // _LOGD("nameSpace %s\n", (char *)nameSpace);
1065 _LOGD("XML_READER_TYPE_ELEMENT %s, %s\n",
1066 elementName ? elementName : "NULL",
1067 nameSpace ? nameSpace : "NULL");
1070 _LOGD("__run_parser_prestep pkgid[%s]\n", pkgid);
1071 __run_parser_prestep(reader, action, pkgid);
1075 for (tag = tagv[0]; tag; tag = tagv[++i])
1076 if (strcmp(tag, ASCII(elementName)) == 0) {
1077 _LOGD("__run_parser_prestep tag[%s] pkgid[%s]\n", tag, pkgid);
1078 __run_parser_prestep(reader,
1086 case XML_READER_TYPE_TEXT:
1087 case XML_READER_TYPE_CDATA:
1089 const xmlChar *value = xmlTextReaderConstValue(reader);
1091 // _LOGD("value %s\n", value);
1094 const xmlChar *lang = xmlTextReaderConstXmlLang(reader);
1096 // _LOGD("lang\n", lang);
1099 /* _LOGD("XML_READER_TYPE_TEXT %s, %s\n",
1100 value ? value : "NULL", lang ? lang : "NULL");
1105 // _LOGD("Ignoring Node of Type: %d", xmlTextReaderNodeType(reader));
1111 __processTag(void *lib_handle, xmlTextReaderPtr reader, ACTION_TYPE action, char *tag, const char *pkgid)
1113 switch (xmlTextReaderNodeType(reader)) {
1114 case XML_READER_TYPE_END_ELEMENT:
1118 case XML_READER_TYPE_ELEMENT:
1120 // Elements without closing tag don't receive
1121 const xmlChar *elementName =
1122 xmlTextReaderLocalName(reader);
1123 if (elementName == NULL) {
1127 if (strcmp(tag, ASCII(elementName)) == 0) {
1128 _LOGD("find : tag[%s] ACTION_TYPE[%d] pkg[%s]\n", tag, action, pkgid);
1129 __run_tag_parser_prestep(lib_handle, reader, action, pkgid);
1140 static int __parser_send_tag(void *lib_handle, ACTION_TYPE action, PLUGIN_PROCESS_TYPE process, const char *pkgid)
1142 int (*plugin_install) (const char *);
1146 if (process == PLUGIN_PRE_PROCESS) {
1148 case ACTION_INSTALL:
1149 ac = "PKGMGR_PARSER_PLUGIN_PRE_INSTALL";
1151 case ACTION_UPGRADE:
1152 ac = "PKGMGR_PARSER_PLUGIN_PRE_UPGRADE";
1154 case ACTION_UNINSTALL:
1155 ac = "PKGMGR_PARSER_PLUGIN_PRE_UNINSTALL";
1160 } else if (process == PLUGIN_POST_PROCESS) {
1162 case ACTION_INSTALL:
1163 ac = "PKGMGR_PARSER_PLUGIN_POST_INSTALL";
1165 case ACTION_UPGRADE:
1166 ac = "PKGMGR_PARSER_PLUGIN_POST_UPGRADE";
1168 case ACTION_UNINSTALL:
1169 ac = "PKGMGR_PARSER_PLUGIN_POST_UNINSTALL";
1177 if ((plugin_install =
1178 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
1182 ret = plugin_install(pkgid);
1186 static void __plugin_send_tag(const char *tag, ACTION_TYPE action, PLUGIN_PROCESS_TYPE process, const char *pkgid)
1188 char *lib_path = NULL;
1189 void *lib_handle = NULL;
1190 int (*plugin_install) (const char *);
1194 if (process == PLUGIN_PRE_PROCESS) {
1196 case ACTION_INSTALL:
1197 ac = "PKGMGR_PARSER_PLUGIN_PRE_INSTALL";
1199 case ACTION_UPGRADE:
1200 ac = "PKGMGR_PARSER_PLUGIN_PRE_UPGRADE";
1202 case ACTION_UNINSTALL:
1203 ac = "PKGMGR_PARSER_PLUGIN_PRE_UNINSTALL";
1208 } else if (process == PLUGIN_POST_PROCESS) {
1210 case ACTION_INSTALL:
1211 ac = "PKGMGR_PARSER_PLUGIN_POST_INSTALL";
1213 case ACTION_UPGRADE:
1214 ac = "PKGMGR_PARSER_PLUGIN_POST_UPGRADE";
1216 case ACTION_UNINSTALL:
1217 ac = "PKGMGR_PARSER_PLUGIN_POST_UNINSTALL";
1225 lib_path = __get_parser_plugin(tag);
1230 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
1231 _LOGE("dlopen is failed lib_path[%s] for tag[%s]\n", lib_path, tag);
1234 if ((plugin_install =
1235 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
1236 // _LOGE("can not find symbol[%s] for tag[%s] \n", ac, tag);
1240 ret = plugin_install(pkgid);
1242 _LOGD("[PLUGIN_PROCESS_TYPE[%d] pkgid=%s, tag=%s plugin fail\n", process, pkgid, tag);
1244 _LOGD("[PLUGIN_PROCESS_TYPE[%d] pkgid=%s, tag=%s plugin success\n", process, pkgid, tag);
1250 dlclose(lib_handle);
1254 __plugin_process_tag(char *const tag_list[], ACTION_TYPE action, PLUGIN_PROCESS_TYPE process, const char *pkgid)
1259 for (tag = tag_list[0]; tag; tag = tag_list[++i])
1260 __plugin_send_tag(tag, action, process, pkgid);
1265 __plugin_save_tag(xmlTextReaderPtr reader, char *const tagv[], char *tag_list[])
1269 static int pre_cnt=0;
1271 switch (xmlTextReaderNodeType(reader)) {
1272 case XML_READER_TYPE_ELEMENT:
1274 const xmlChar *elementName = xmlTextReaderLocalName(reader);
1275 if (elementName == NULL) {
1279 for (tag = tag_list[0]; tag; tag = tag_list[++i])
1280 if (strcmp(ASCII(elementName), tag) == 0) {
1284 for (tag = tagv[0]; tag; tag = tagv[++i])
1285 if (strcmp(tag, ASCII(elementName)) == 0) {
1286 tag_list[pre_cnt++] = tag;
1292 // _LOGD("Ignoring Node of Type: %d", xmlTextReaderNodeType(reader));
1298 __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid)
1300 xmlTextReaderPtr reader;
1303 __plugin_process_tag(tagv, action, PLUGIN_PRE_PROCESS, pkgid);
1305 docPtr = xmlReadFile(filename, NULL, 0);
1306 reader = xmlReaderWalker(docPtr);
1307 if (reader != NULL) {
1308 ret = xmlTextReaderRead(reader);
1310 __processNode(reader, action, tagv, pkgid);
1311 ret = xmlTextReaderRead(reader);
1313 xmlFreeTextReader(reader);
1316 _LOGD("%s : failed to parse", filename);
1319 _LOGD("Unable to open %s", filename);
1322 __plugin_process_tag(tagv, action, PLUGIN_POST_PROCESS, pkgid);
1325 static int __next_child_element(xmlTextReaderPtr reader, int depth)
1327 int ret = xmlTextReaderRead(reader);
1328 int cur = xmlTextReaderDepth(reader);
1331 switch (xmlTextReaderNodeType(reader)) {
1332 case XML_READER_TYPE_ELEMENT:
1333 if (cur == depth + 1)
1336 case XML_READER_TYPE_TEXT:
1337 /*text is handled by each function separately*/
1338 if (cur == depth + 1)
1341 case XML_READER_TYPE_END_ELEMENT:
1350 ret = xmlTextReaderRead(reader);
1351 cur = xmlTextReaderDepth(reader);
1356 static bool __check_action_fota(char *const tagv[])
1359 char delims[] = "=";
1360 char *ret_result = NULL;
1367 for (tag = strdup(tagv[0]); tag != NULL; ) {
1368 ret_result = strtok(tag, delims);
1370 /*check tag : fota is true */
1371 if (strcmp(ret_result, "fota") == 0) {
1372 ret_result = strtok(NULL, delims);
1373 if (strcmp(ret_result, "true") == 0) {
1377 _LOGD("tag process [%s]is not defined\n", ret_result);
1381 /*check next value*/
1382 if (tagv[++i] != NULL)
1383 tag = strdup(tagv[i]);
1385 _LOGD("tag process success...%d\n" , ret);
1393 static void __ps_free_category(category_x *category)
1395 if (category == NULL)
1397 if (category->name) {
1398 free((void *)category->name);
1399 category->name = NULL;
1401 free((void*)category);
1405 static void __ps_free_privilege(privilege_x *privilege)
1407 if (privilege == NULL)
1409 if (privilege->text) {
1410 free((void *)privilege->text);
1411 privilege->text = NULL;
1413 free((void*)privilege);
1417 static void __ps_free_privileges(privileges_x *privileges)
1419 if (privileges == NULL)
1422 if (privileges->privilege) {
1423 privilege_x *privilege = privileges->privilege;
1424 privilege_x *tmp = NULL;
1425 while(privilege != NULL) {
1426 tmp = privilege->next;
1427 __ps_free_privilege(privilege);
1431 free((void*)privileges);
1435 static void __ps_free_metadata(metadata_x *metadata)
1437 if (metadata == NULL)
1439 if (metadata->key) {
1440 free((void *)metadata->key);
1441 metadata->key = NULL;
1443 if (metadata->value) {
1444 free((void *)metadata->value);
1445 metadata->value = NULL;
1447 free((void*)metadata);
1451 static void __ps_free_permission(permission_x *permission)
1453 if (permission == NULL)
1455 if (permission->type) {
1456 free((void *)permission->type);
1457 permission->type = NULL;
1459 if (permission->value) {
1460 free((void *)permission->value);
1461 permission->value = NULL;
1463 free((void*)permission);
1467 static void __ps_free_icon(icon_x *icon)
1472 free((void *)icon->text);
1476 free((void *)icon->lang);
1480 free((void *)icon->name);
1483 if (icon->section) {
1484 free((void *)icon->section);
1485 icon->section = NULL;
1488 free((void *)icon->size);
1491 if (icon->resolution) {
1492 free((void *)icon->resolution);
1493 icon->resolution = NULL;
1499 static void __ps_free_image(image_x *image)
1504 free((void *)image->text);
1508 free((void *)image->lang);
1512 free((void *)image->name);
1515 if (image->section) {
1516 free((void *)image->section);
1517 image->section = NULL;
1523 static void __ps_free_operation(operation_x *operation)
1525 if (operation == NULL)
1527 if (operation->text) {
1528 free((void *)operation->text);
1529 operation->text = NULL;
1531 free((void*)operation);
1535 static void __ps_free_uri(uri_x *uri)
1540 free((void *)uri->text);
1547 static void __ps_free_mime(mime_x *mime)
1552 free((void *)mime->text);
1559 static void __ps_free_subapp(subapp_x *subapp)
1564 free((void *)subapp->text);
1565 subapp->text = NULL;
1567 free((void*)subapp);
1571 static void __ps_free_condition(condition_x *condition)
1573 if (condition == NULL)
1575 if (condition->text) {
1576 free((void *)condition->text);
1577 condition->text = NULL;
1579 if (condition->name) {
1580 free((void *)condition->name);
1581 condition->name = NULL;
1583 free((void*)condition);
1587 static void __ps_free_notification(notification_x *notification)
1589 if (notification == NULL)
1591 if (notification->text) {
1592 free((void *)notification->text);
1593 notification->text = NULL;
1595 if (notification->name) {
1596 free((void *)notification->name);
1597 notification->name = NULL;
1599 free((void*)notification);
1600 notification = NULL;
1603 static void __ps_free_compatibility(compatibility_x *compatibility)
1605 if (compatibility == NULL)
1607 if (compatibility->text) {
1608 free((void *)compatibility->text);
1609 compatibility->text = NULL;
1611 if (compatibility->name) {
1612 free((void *)compatibility->name);
1613 compatibility->name = NULL;
1615 free((void*)compatibility);
1616 compatibility = NULL;
1619 static void __ps_free_resolution(resolution_x *resolution)
1621 if (resolution == NULL)
1623 if (resolution->mimetype) {
1624 free((void *)resolution->mimetype);
1625 resolution->mimetype = NULL;
1627 if (resolution->urischeme) {
1628 free((void *)resolution->urischeme);
1629 resolution->urischeme = NULL;
1631 free((void*)resolution);
1635 static void __ps_free_capability(capability_x *capability)
1637 if (capability == NULL)
1639 if (capability->operationid) {
1640 free((void *)capability->operationid);
1641 capability->operationid = NULL;
1644 if (capability->resolution) {
1645 resolution_x *resolution = capability->resolution;
1646 resolution_x *tmp = NULL;
1647 while(resolution != NULL) {
1648 tmp = resolution->next;
1649 __ps_free_resolution(resolution);
1653 free((void*)capability);
1657 static void __ps_free_allowed(allowed_x *allowed)
1659 if (allowed == NULL)
1661 if (allowed->name) {
1662 free((void *)allowed->name);
1663 allowed->name = NULL;
1665 if (allowed->text) {
1666 free((void *)allowed->text);
1667 allowed->text = NULL;
1669 free((void*)allowed);
1673 static void __ps_free_request(request_x *request)
1675 if (request == NULL)
1677 if (request->text) {
1678 free((void *)request->text);
1679 request->text = NULL;
1681 free((void*)request);
1685 static void __ps_free_datacontrol(datacontrol_x *datacontrol)
1687 if (datacontrol == NULL)
1689 if (datacontrol->providerid) {
1690 free((void *)datacontrol->providerid);
1691 datacontrol->providerid = NULL;
1694 if (datacontrol->capability) {
1695 capability_x *capability = datacontrol->capability;
1696 capability_x *tmp = NULL;
1697 while(capability != NULL) {
1698 tmp = capability->next;
1699 __ps_free_capability(capability);
1703 free((void*)datacontrol);
1707 static void __ps_free_launchconditions(launchconditions_x *launchconditions)
1709 if (launchconditions == NULL)
1711 if (launchconditions->text) {
1712 free((void *)launchconditions->text);
1713 launchconditions->text = NULL;
1716 if (launchconditions->condition) {
1717 condition_x *condition = launchconditions->condition;
1718 condition_x *tmp = NULL;
1719 while(condition != NULL) {
1720 tmp = condition->next;
1721 __ps_free_condition(condition);
1725 free((void*)launchconditions);
1726 launchconditions = NULL;
1729 static void __ps_free_appcontrol(appcontrol_x *appcontrol)
1731 if (appcontrol == NULL)
1733 if (appcontrol->text) {
1734 free((void *)appcontrol->text);
1735 appcontrol->text = NULL;
1738 if (appcontrol->operation) {
1739 operation_x *operation = appcontrol->operation;
1740 operation_x *tmp = NULL;
1741 while(operation != NULL) {
1742 tmp = operation->next;
1743 __ps_free_operation(operation);
1748 if (appcontrol->uri) {
1749 uri_x *uri = appcontrol->uri;
1751 while(uri != NULL) {
1758 if (appcontrol->mime) {
1759 mime_x *mime = appcontrol->mime;
1761 while(mime != NULL) {
1763 __ps_free_mime(mime);
1768 if (appcontrol->subapp) {
1769 subapp_x *subapp = appcontrol->subapp;
1770 subapp_x *tmp = NULL;
1771 while(subapp != NULL) {
1773 __ps_free_subapp(subapp);
1777 free((void*)appcontrol);
1781 static void __ps_free_appsvc(appsvc_x *appsvc)
1786 free((void *)appsvc->text);
1787 appsvc->text = NULL;
1790 if (appsvc->operation) {
1791 operation_x *operation = appsvc->operation;
1792 operation_x *tmp = NULL;
1793 while(operation != NULL) {
1794 tmp = operation->next;
1795 __ps_free_operation(operation);
1801 uri_x *uri = appsvc->uri;
1803 while(uri != NULL) {
1811 mime_x *mime = appsvc->mime;
1813 while(mime != NULL) {
1815 __ps_free_mime(mime);
1820 if (appsvc->subapp) {
1821 subapp_x *subapp = appsvc->subapp;
1822 subapp_x *tmp = NULL;
1823 while(subapp != NULL) {
1825 __ps_free_subapp(subapp);
1829 free((void*)appsvc);
1833 static void __ps_free_deviceprofile(deviceprofile_x *deviceprofile)
1838 static void __ps_free_define(define_x *define)
1843 free((void *)define->path);
1844 define->path = NULL;
1847 if (define->request) {
1848 request_x *request = define->request;
1849 request_x *tmp = NULL;
1850 while(request != NULL) {
1851 tmp = request->next;
1852 __ps_free_request(request);
1857 if (define->allowed) {
1858 allowed_x *allowed = define->allowed;
1859 allowed_x *tmp = NULL;
1860 while(allowed != NULL) {
1861 tmp = allowed->next;
1862 __ps_free_allowed(allowed);
1866 free((void*)define);
1870 static void __ps_free_datashare(datashare_x *datashare)
1872 if (datashare == NULL)
1875 if (datashare->define) {
1876 define_x *define = datashare->define;
1877 define_x *tmp = NULL;
1878 while(define != NULL) {
1880 __ps_free_define(define);
1885 if (datashare->request) {
1886 request_x *request = datashare->request;
1887 request_x *tmp = NULL;
1888 while(request != NULL) {
1889 tmp = request->next;
1890 __ps_free_request(request);
1894 free((void*)datashare);
1898 static void __ps_free_label(label_x *label)
1903 free((void *)label->name);
1907 free((void *)label->text);
1911 free((void *)label->lang);
1918 static void __ps_free_author(author_x *author)
1922 if (author->email) {
1923 free((void *)author->email);
1924 author->email = NULL;
1927 free((void *)author->text);
1928 author->text = NULL;
1931 free((void *)author->href);
1932 author->href = NULL;
1935 free((void *)author->lang);
1936 author->lang = NULL;
1938 free((void*)author);
1942 static void __ps_free_description(description_x *description)
1944 if (description == NULL)
1946 if (description->name) {
1947 free((void *)description->name);
1948 description->name = NULL;
1950 if (description->text) {
1951 free((void *)description->text);
1952 description->text = NULL;
1954 if (description->lang) {
1955 free((void *)description->lang);
1956 description->lang = NULL;
1958 free((void*)description);
1962 static void __ps_free_license(license_x *license)
1964 if (license == NULL)
1966 if (license->text) {
1967 free((void *)license->text);
1968 license->text = NULL;
1970 if (license->lang) {
1971 free((void *)license->lang);
1972 license->lang = NULL;
1974 free((void*)license);
1978 static void __ps_free_uiapplication(uiapplication_x *uiapplication)
1980 if (uiapplication == NULL)
1982 if (uiapplication->exec) {
1983 free((void *)uiapplication->exec);
1984 uiapplication->exec = NULL;
1986 if (uiapplication->appid) {
1987 free((void *)uiapplication->appid);
1988 uiapplication->appid = NULL;
1990 if (uiapplication->nodisplay) {
1991 free((void *)uiapplication->nodisplay);
1992 uiapplication->nodisplay = NULL;
1994 if (uiapplication->multiple) {
1995 free((void *)uiapplication->multiple);
1996 uiapplication->multiple = NULL;
1998 if (uiapplication->type) {
1999 free((void *)uiapplication->type);
2000 uiapplication->type = NULL;
2002 if (uiapplication->categories) {
2003 free((void *)uiapplication->categories);
2004 uiapplication->categories = NULL;
2006 if (uiapplication->extraid) {
2007 free((void *)uiapplication->extraid);
2008 uiapplication->extraid = NULL;
2010 if (uiapplication->taskmanage) {
2011 free((void *)uiapplication->taskmanage);
2012 uiapplication->taskmanage = NULL;
2014 if (uiapplication->enabled) {
2015 free((void *)uiapplication->enabled);
2016 uiapplication->enabled = NULL;
2018 if (uiapplication->hwacceleration) {
2019 free((void *)uiapplication->hwacceleration);
2020 uiapplication->hwacceleration = NULL;
2022 if (uiapplication->screenreader) {
2023 free((void *)uiapplication->screenreader);
2024 uiapplication->screenreader = NULL;
2026 if (uiapplication->mainapp) {
2027 free((void *)uiapplication->mainapp);
2028 uiapplication->mainapp = NULL;
2030 if (uiapplication->recentimage) {
2031 free((void *)uiapplication->recentimage);
2032 uiapplication->recentimage = NULL;
2034 if (uiapplication->package) {
2035 free((void *)uiapplication->package);
2036 uiapplication->package = NULL;
2038 if (uiapplication->launchcondition) {
2039 free((void *)uiapplication->launchcondition);
2040 uiapplication->launchcondition = NULL;
2043 if (uiapplication->label) {
2044 label_x *label = uiapplication->label;
2045 label_x *tmp = NULL;
2046 while(label != NULL) {
2048 __ps_free_label(label);
2053 if (uiapplication->icon) {
2054 icon_x *icon = uiapplication->icon;
2056 while(icon != NULL) {
2058 __ps_free_icon(icon);
2063 if (uiapplication->image) {
2064 image_x *image = uiapplication->image;
2065 image_x *tmp = NULL;
2066 while(image != NULL) {
2068 __ps_free_image(image);
2073 if (uiapplication->appcontrol) {
2074 appcontrol_x *appcontrol = uiapplication->appcontrol;
2075 appcontrol_x *tmp = NULL;
2076 while(appcontrol != NULL) {
2077 tmp = appcontrol->next;
2078 __ps_free_appcontrol(appcontrol);
2082 /*Free LaunchConditions*/
2083 if (uiapplication->launchconditions) {
2084 launchconditions_x *launchconditions = uiapplication->launchconditions;
2085 launchconditions_x *tmp = NULL;
2086 while(launchconditions != NULL) {
2087 tmp = launchconditions->next;
2088 __ps_free_launchconditions(launchconditions);
2089 launchconditions = tmp;
2092 /*Free Notification*/
2093 if (uiapplication->notification) {
2094 notification_x *notification = uiapplication->notification;
2095 notification_x *tmp = NULL;
2096 while(notification != NULL) {
2097 tmp = notification->next;
2098 __ps_free_notification(notification);
2103 if (uiapplication->datashare) {
2104 datashare_x *datashare = uiapplication->datashare;
2105 datashare_x *tmp = NULL;
2106 while(datashare != NULL) {
2107 tmp = datashare->next;
2108 __ps_free_datashare(datashare);
2113 if (uiapplication->appsvc) {
2114 appsvc_x *appsvc = uiapplication->appsvc;
2115 appsvc_x *tmp = NULL;
2116 while(appsvc != NULL) {
2118 __ps_free_appsvc(appsvc);
2123 if (uiapplication->category) {
2124 category_x *category = uiapplication->category;
2125 category_x *tmp = NULL;
2126 while(category != NULL) {
2127 tmp = category->next;
2128 __ps_free_category(category);
2133 if (uiapplication->metadata) {
2134 metadata_x *metadata = uiapplication->metadata;
2135 metadata_x *tmp = NULL;
2136 while(metadata != NULL) {
2137 tmp = metadata->next;
2138 __ps_free_metadata(metadata);
2143 if (uiapplication->permission) {
2144 permission_x *permission = uiapplication->permission;
2145 permission_x *tmp = NULL;
2146 while(permission != NULL) {
2147 tmp = permission->next;
2148 __ps_free_permission(permission);
2152 /* _PRODUCT_LAUNCHING_ENHANCED_ START */
2153 if (uiapplication->indicatordisplay) {
2154 free((void *)uiapplication->indicatordisplay);
2155 uiapplication->indicatordisplay = NULL;
2157 if (uiapplication->portraitimg) {
2158 free((void *)uiapplication->portraitimg);
2159 uiapplication->portraitimg = NULL;
2161 if (uiapplication->landscapeimg) {
2162 free((void *)uiapplication->landscapeimg);
2163 uiapplication->landscapeimg = NULL;
2165 /* _PRODUCT_LAUNCHING_ENHANCED_ END */
2166 if (uiapplication->guestmode_visibility) {
2167 free((void *)uiapplication->guestmode_visibility);
2168 uiapplication->guestmode_visibility = NULL;
2170 if (uiapplication->app_component) {
2171 free((void *)uiapplication->app_component);
2172 uiapplication->app_component = NULL;
2174 if (uiapplication->permission_type) {
2175 free((void *)uiapplication->permission_type);
2176 uiapplication->permission_type = NULL;
2178 if (uiapplication->component_type) {
2179 free((void *)uiapplication->component_type);
2180 uiapplication->component_type = NULL;
2182 if (uiapplication->preload) {
2183 free((void *)uiapplication->preload);
2184 uiapplication->preload = NULL;
2186 if (uiapplication->submode) {
2187 free((void *)uiapplication->submode);
2188 uiapplication->submode = NULL;
2190 if (uiapplication->submode_mainid) {
2191 free((void *)uiapplication->submode_mainid);
2192 uiapplication->submode_mainid = NULL;
2195 free((void*)uiapplication);
2196 uiapplication = NULL;
2199 static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication)
2201 if (serviceapplication == NULL)
2203 if (serviceapplication->exec) {
2204 free((void *)serviceapplication->exec);
2205 serviceapplication->exec = NULL;
2207 if (serviceapplication->appid) {
2208 free((void *)serviceapplication->appid);
2209 serviceapplication->appid = NULL;
2211 if (serviceapplication->onboot) {
2212 free((void *)serviceapplication->onboot);
2213 serviceapplication->onboot = NULL;
2215 if (serviceapplication->autorestart) {
2216 free((void *)serviceapplication->autorestart);
2217 serviceapplication->autorestart = NULL;
2219 if (serviceapplication->type) {
2220 free((void *)serviceapplication->type);
2221 serviceapplication->type = NULL;
2223 if (serviceapplication->enabled) {
2224 free((void *)serviceapplication->enabled);
2225 serviceapplication->enabled = NULL;
2227 if (serviceapplication->package) {
2228 free((void *)serviceapplication->package);
2229 serviceapplication->package = NULL;
2231 if (serviceapplication->permission_type) {
2232 free((void *)serviceapplication->permission_type);
2233 serviceapplication->permission_type = NULL;
2236 if (serviceapplication->label) {
2237 label_x *label = serviceapplication->label;
2238 label_x *tmp = NULL;
2239 while(label != NULL) {
2241 __ps_free_label(label);
2246 if (serviceapplication->icon) {
2247 icon_x *icon = serviceapplication->icon;
2249 while(icon != NULL) {
2251 __ps_free_icon(icon);
2256 if (serviceapplication->appcontrol) {
2257 appcontrol_x *appcontrol = serviceapplication->appcontrol;
2258 appcontrol_x *tmp = NULL;
2259 while(appcontrol != NULL) {
2260 tmp = appcontrol->next;
2261 __ps_free_appcontrol(appcontrol);
2265 /*Free DataControl*/
2266 if (serviceapplication->datacontrol) {
2267 datacontrol_x *datacontrol = serviceapplication->datacontrol;
2268 datacontrol_x *tmp = NULL;
2269 while(datacontrol != NULL) {
2270 tmp = datacontrol->next;
2271 __ps_free_datacontrol(datacontrol);
2275 /*Free LaunchConditions*/
2276 if (serviceapplication->launchconditions) {
2277 launchconditions_x *launchconditions = serviceapplication->launchconditions;
2278 launchconditions_x *tmp = NULL;
2279 while(launchconditions != NULL) {
2280 tmp = launchconditions->next;
2281 __ps_free_launchconditions(launchconditions);
2282 launchconditions = tmp;
2285 /*Free Notification*/
2286 if (serviceapplication->notification) {
2287 notification_x *notification = serviceapplication->notification;
2288 notification_x *tmp = NULL;
2289 while(notification != NULL) {
2290 tmp = notification->next;
2291 __ps_free_notification(notification);
2296 if (serviceapplication->datashare) {
2297 datashare_x *datashare = serviceapplication->datashare;
2298 datashare_x *tmp = NULL;
2299 while(datashare != NULL) {
2300 tmp = datashare->next;
2301 __ps_free_datashare(datashare);
2306 if (serviceapplication->appsvc) {
2307 appsvc_x *appsvc = serviceapplication->appsvc;
2308 appsvc_x *tmp = NULL;
2309 while(appsvc != NULL) {
2311 __ps_free_appsvc(appsvc);
2316 if (serviceapplication->category) {
2317 category_x *category = serviceapplication->category;
2318 category_x *tmp = NULL;
2319 while(category != NULL) {
2320 tmp = category->next;
2321 __ps_free_category(category);
2326 if (serviceapplication->metadata) {
2327 metadata_x *metadata = serviceapplication->metadata;
2328 metadata_x *tmp = NULL;
2329 while(metadata != NULL) {
2330 tmp = metadata->next;
2331 __ps_free_metadata(metadata);
2336 if (serviceapplication->permission) {
2337 permission_x *permission = serviceapplication->permission;
2338 permission_x *tmp = NULL;
2339 while(permission != NULL) {
2340 tmp = permission->next;
2341 __ps_free_permission(permission);
2345 free((void*)serviceapplication);
2346 serviceapplication = NULL;
2349 static void __ps_free_font(font_x *font)
2354 free((void *)font->name);
2358 free((void *)font->text);
2365 static void __ps_free_theme(theme_x *theme)
2370 free((void *)theme->name);
2374 free((void *)theme->text);
2381 static void __ps_free_daemon(daemon_x *daemon)
2386 free((void *)daemon->name);
2387 daemon->name = NULL;
2390 free((void *)daemon->text);
2391 daemon->text = NULL;
2393 free((void*)daemon);
2397 static void __ps_free_ime(ime_x *ime)
2402 free((void *)ime->name);
2406 free((void *)ime->text);
2413 int __ps_process_tag_parser(manifest_x *mfx, const char *filename, ACTION_TYPE action)
2415 xmlTextReaderPtr reader;
2419 void *lib_handle = NULL;
2420 char tag[PKG_STRING_LEN_MAX] = { 0 };
2422 fp = fopen(TAG_PARSER_LIST, "r");
2423 retvm_if(fp == NULL, PMINFO_R_ERROR, "no preload list");
2425 while (fgets(tag, sizeof(tag), fp) != NULL) {
2428 lib_handle = __open_lib_handle(tag);
2429 if (lib_handle == NULL)
2432 ret = __parser_send_tag(lib_handle, action, PLUGIN_PRE_PROCESS, mfx->package);
2433 _LOGD("PLUGIN_PRE_PROCESS[%s, %s] ACTION_TYPE[%d] result[%d]\n", mfx->package, tag, action, ret);
2435 docPtr = xmlReadFile(filename, NULL, 0);
2436 reader = xmlReaderWalker(docPtr);
2437 if (reader != NULL) {
2438 ret = xmlTextReaderRead(reader);
2440 __processTag(lib_handle, reader, action, tag, mfx->package);
2441 ret = xmlTextReaderRead(reader);
2443 xmlFreeTextReader(reader);
2446 _LOGD("%s : failed to parse", filename);
2449 _LOGD("Unable to open %s", filename);
2452 ret = __parser_send_tag(lib_handle, action, PLUGIN_POST_PROCESS, mfx->package);
2453 _LOGD("PLUGIN_POST_PROCESS[%s, %s] ACTION_TYPE[%d] result[%d]\n", mfx->package, tag, action, ret);
2455 __close_lib_handle(lib_handle);
2457 memset(tag, 0x00, sizeof(tag));
2466 int __ps_process_metadata_parser(manifest_x *mfx, ACTION_TYPE action)
2470 char md_key[PKG_STRING_LEN_MAX] = { 0 };
2472 fp = fopen(METADATA_PARSER_LIST, "r");
2474 _LOGD("no preload list\n");
2478 while (fgets(md_key, sizeof(md_key), fp) != NULL) {
2480 ret = __run_metadata_parser_prestep(mfx, md_key, action);
2482 memset(md_key, 0x00, sizeof(md_key));
2491 int __ps_process_category_parser(manifest_x *mfx, ACTION_TYPE action)
2495 char category_key[PKG_STRING_LEN_MAX] = { 0 };
2497 fp = fopen(CATEGORY_PARSER_LIST, "r");
2499 _LOGD("no category parser list\n");
2503 while (fgets(category_key, sizeof(category_key), fp) != NULL) {
2504 __str_trim(category_key);
2505 ret = __run_category_parser_prestep(mfx, category_key, action);
2507 memset(category_key, 0x00, sizeof(category_key));
2516 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed)
2518 xmlTextReaderRead(reader);
2519 if (xmlTextReaderValue(reader))
2520 allowed->text = ASCII(xmlTextReaderValue(reader));
2524 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation)
2526 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2527 operation->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2528 /* Text does not exist. Only attribute exists
2529 xmlTextReaderRead(reader);
2530 if (xmlTextReaderValue(reader))
2531 operation->text = ASCII(xmlTextReaderValue(reader));
2536 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri)
2538 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2539 uri->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2540 /* Text does not exist. Only attribute exists
2541 xmlTextReaderRead(reader);
2542 if (xmlTextReaderValue(reader))
2543 uri->text = ASCII(xmlTextReaderValue(reader));
2548 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime)
2550 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2551 mime->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2552 /* Text does not exist. Only attribute exists
2553 xmlTextReaderRead(reader);
2554 if (xmlTextReaderValue(reader))
2555 mime->text = ASCII(xmlTextReaderValue(reader));
2560 static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp)
2562 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2563 subapp->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2564 /* Text does not exist. Only attribute exists
2565 xmlTextReaderRead(reader);
2566 if (xmlTextReaderValue(reader))
2567 mime->text = ASCII(xmlTextReaderValue(reader));
2572 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition)
2574 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2575 condition->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2576 xmlTextReaderRead(reader);
2577 if (xmlTextReaderValue(reader))
2578 condition->text = ASCII(xmlTextReaderValue(reader));
2582 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notification)
2584 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2585 notification->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2586 xmlTextReaderRead(reader);
2587 if (xmlTextReaderValue(reader))
2588 notification->text = ASCII(xmlTextReaderValue(reader));
2592 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category)
2594 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2595 category->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2599 static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege)
2601 xmlTextReaderRead(reader);
2602 if (xmlTextReaderValue(reader)) {
2603 privilege->text = ASCII(xmlTextReaderValue(reader));
2608 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata)
2610 if (xmlTextReaderGetAttribute(reader, XMLCHAR("key")))
2611 metadata->key = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("key")));
2612 if (xmlTextReaderGetAttribute(reader, XMLCHAR("value")))
2613 metadata->value = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("value")));
2617 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission)
2619 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
2620 permission->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
2622 xmlTextReaderRead(reader);
2623 if (xmlTextReaderValue(reader))
2624 permission->value = ASCII(xmlTextReaderValue(reader));
2628 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility)
2630 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2631 compatibility->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2632 xmlTextReaderRead(reader);
2633 if (xmlTextReaderValue(reader))
2634 compatibility->text = ASCII(xmlTextReaderValue(reader));
2638 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution)
2640 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")))
2641 resolution->mimetype = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")));
2642 if (xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")))
2643 resolution->urischeme = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")));
2647 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request)
2649 xmlTextReaderRead(reader);
2650 if (xmlTextReaderValue(reader))
2651 request->text = ASCII(xmlTextReaderValue(reader));
2655 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define)
2657 const xmlChar *node;
2660 allowed_x *tmp1 = NULL;
2661 request_x *tmp2 = NULL;
2663 if (xmlTextReaderGetAttribute(reader, XMLCHAR("path")))
2664 define->path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("path")));
2666 depth = xmlTextReaderDepth(reader);
2667 while ((ret = __next_child_element(reader, depth))) {
2668 node = xmlTextReaderConstName(reader);
2670 _LOGD("xmlTextReaderConstName value is NULL\n");
2674 if (!strcmp(ASCII(node), "allowed")) {
2675 allowed_x *allowed= malloc(sizeof(allowed_x));
2676 if (allowed == NULL) {
2677 _LOGD("Malloc Failed\n");
2680 memset(allowed, '\0', sizeof(allowed_x));
2681 LISTADD(define->allowed, allowed);
2682 ret = __ps_process_allowed(reader, allowed);
2683 } else if (!strcmp(ASCII(node), "request")) {
2684 request_x *request = malloc(sizeof(request_x));
2685 if (request == NULL) {
2686 _LOGD("Malloc Failed\n");
2689 memset(request, '\0', sizeof(request_x));
2690 LISTADD(define->request, request);
2691 ret = __ps_process_request(reader, request);
2695 _LOGD("Processing define failed\n");
2699 if (define->allowed) {
2700 LISTHEAD(define->allowed, tmp1);
2701 define->allowed = tmp1;
2703 if (define->request) {
2704 LISTHEAD(define->request, tmp2);
2705 define->request = tmp2;
2710 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol)
2712 const xmlChar *node;
2715 operation_x *tmp1 = NULL;
2717 mime_x *tmp3 = NULL;
2718 subapp_x *tmp4 = NULL;
2720 depth = xmlTextReaderDepth(reader);
2721 while ((ret = __next_child_element(reader, depth))) {
2722 node = xmlTextReaderConstName(reader);
2724 _LOGD("xmlTextReaderConstName value is NULL\n");
2728 if (!strcmp(ASCII(node), "operation")) {
2729 operation_x *operation = malloc(sizeof(operation_x));
2730 if (operation == NULL) {
2731 _LOGD("Malloc Failed\n");
2734 memset(operation, '\0', sizeof(operation_x));
2735 LISTADD(appcontrol->operation, operation);
2736 ret = __ps_process_operation(reader, operation);
2737 _LOGD("operation processing\n");
2738 } else if (!strcmp(ASCII(node), "uri")) {
2739 uri_x *uri= malloc(sizeof(uri_x));
2741 _LOGD("Malloc Failed\n");
2744 memset(uri, '\0', sizeof(uri_x));
2745 LISTADD(appcontrol->uri, uri);
2746 ret = __ps_process_uri(reader, uri);
2747 _LOGD("uri processing\n");
2748 } else if (!strcmp(ASCII(node), "mime")) {
2749 mime_x *mime = malloc(sizeof(mime_x));
2751 _LOGD("Malloc Failed\n");
2754 memset(mime, '\0', sizeof(mime_x));
2755 LISTADD(appcontrol->mime, mime);
2756 ret = __ps_process_mime(reader, mime);
2757 _LOGD("mime processing\n");
2758 } else if (!strcmp(ASCII(node), "subapp")) {
2759 subapp_x *subapp = malloc(sizeof(subapp_x));
2760 if (subapp == NULL) {
2761 _LOGD("Malloc Failed\n");
2764 memset(subapp, '\0', sizeof(subapp_x));
2765 LISTADD(appcontrol->subapp, subapp);
2766 ret = __ps_process_subapp(reader, subapp);
2767 _LOGD("subapp processing\n");
2771 _LOGD("Processing appcontrol failed\n");
2775 if (appcontrol->operation) {
2776 LISTHEAD(appcontrol->operation, tmp1);
2777 appcontrol->operation = tmp1;
2779 if (appcontrol->uri) {
2780 LISTHEAD(appcontrol->uri, tmp2);
2781 appcontrol->uri = tmp2;
2783 if (appcontrol->mime) {
2784 LISTHEAD(appcontrol->mime, tmp3);
2785 appcontrol->mime = tmp3;
2787 if (appcontrol->subapp) {
2788 LISTHEAD(appcontrol->subapp, tmp4);
2789 appcontrol->subapp = tmp4;
2792 xmlTextReaderRead(reader);
2793 if (xmlTextReaderValue(reader))
2794 appcontrol->text = ASCII(xmlTextReaderValue(reader));
2799 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc)
2801 const xmlChar *node;
2804 operation_x *tmp1 = NULL;
2806 mime_x *tmp3 = NULL;
2807 subapp_x *tmp4 = NULL;
2809 depth = xmlTextReaderDepth(reader);
2810 while ((ret = __next_child_element(reader, depth))) {
2811 node = xmlTextReaderConstName(reader);
2813 _LOGD("xmlTextReaderConstName value is NULL\n");
2817 if (!strcmp(ASCII(node), "operation")) {
2818 operation_x *operation = malloc(sizeof(operation_x));
2819 if (operation == NULL) {
2820 _LOGD("Malloc Failed\n");
2823 memset(operation, '\0', sizeof(operation_x));
2824 LISTADD(appsvc->operation, operation);
2825 ret = __ps_process_operation(reader, operation);
2826 _LOGD("operation processing\n");
2827 } else if (!strcmp(ASCII(node), "uri")) {
2828 uri_x *uri= malloc(sizeof(uri_x));
2830 _LOGD("Malloc Failed\n");
2833 memset(uri, '\0', sizeof(uri_x));
2834 LISTADD(appsvc->uri, uri);
2835 ret = __ps_process_uri(reader, uri);
2836 _LOGD("uri processing\n");
2837 } else if (!strcmp(ASCII(node), "mime")) {
2838 mime_x *mime = malloc(sizeof(mime_x));
2840 _LOGD("Malloc Failed\n");
2843 memset(mime, '\0', sizeof(mime_x));
2844 LISTADD(appsvc->mime, mime);
2845 ret = __ps_process_mime(reader, mime);
2846 _LOGD("mime processing\n");
2847 } else if (!strcmp(ASCII(node), "subapp")) {
2848 subapp_x *subapp = malloc(sizeof(subapp_x));
2849 if (subapp == NULL) {
2850 _LOGD("Malloc Failed\n");
2853 memset(subapp, '\0', sizeof(subapp_x));
2854 LISTADD(appsvc->subapp, subapp);
2855 ret = __ps_process_subapp(reader, subapp);
2856 _LOGD("subapp processing\n");
2860 _LOGD("Processing appsvc failed\n");
2864 if (appsvc->operation) {
2865 LISTHEAD(appsvc->operation, tmp1);
2866 appsvc->operation = tmp1;
2869 LISTHEAD(appsvc->uri, tmp2);
2873 LISTHEAD(appsvc->mime, tmp3);
2874 appsvc->mime = tmp3;
2876 if (appsvc->subapp) {
2877 LISTHEAD(appsvc->subapp, tmp4);
2878 appsvc->subapp = tmp4;
2881 xmlTextReaderRead(reader);
2882 if (xmlTextReaderValue(reader))
2883 appsvc->text = ASCII(xmlTextReaderValue(reader));
2889 static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privileges)
2891 const xmlChar *node;
2894 privilege_x *tmp1 = NULL;
2896 depth = xmlTextReaderDepth(reader);
2897 while ((ret = __next_child_element(reader, depth))) {
2898 node = xmlTextReaderConstName(reader);
2900 _LOGD("xmlTextReaderConstName value is NULL\n");
2904 if (strcmp(ASCII(node), "privilege") == 0) {
2905 privilege_x *privilege = malloc(sizeof(privilege_x));
2906 if (privilege == NULL) {
2907 _LOGD("Malloc Failed\n");
2910 memset(privilege, '\0', sizeof(privilege_x));
2911 LISTADD(privileges->privilege, privilege);
2912 ret = __ps_process_privilege(reader, privilege);
2916 _LOGD("Processing privileges failed\n");
2920 if (privileges->privilege) {
2921 LISTHEAD(privileges->privilege, tmp1);
2922 privileges->privilege = tmp1;
2927 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions)
2929 const xmlChar *node;
2932 condition_x *tmp1 = NULL;
2934 depth = xmlTextReaderDepth(reader);
2935 while ((ret = __next_child_element(reader, depth))) {
2936 node = xmlTextReaderConstName(reader);
2938 _LOGD("xmlTextReaderConstName value is NULL\n");
2942 if (strcmp(ASCII(node), "condition") == 0) {
2943 condition_x *condition = malloc(sizeof(condition_x));
2944 if (condition == NULL) {
2945 _LOGD("Malloc Failed\n");
2948 memset(condition, '\0', sizeof(condition_x));
2949 LISTADD(launchconditions->condition, condition);
2950 ret = __ps_process_condition(reader, condition);
2954 _LOGD("Processing launchconditions failed\n");
2958 if (launchconditions->condition) {
2959 LISTHEAD(launchconditions->condition, tmp1);
2960 launchconditions->condition = tmp1;
2963 xmlTextReaderRead(reader);
2964 if (xmlTextReaderValue(reader))
2965 launchconditions->text = ASCII(xmlTextReaderValue(reader));
2970 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare)
2972 const xmlChar *node;
2975 define_x *tmp1 = NULL;
2976 request_x *tmp2 = NULL;
2977 depth = xmlTextReaderDepth(reader);
2978 while ((ret = __next_child_element(reader, depth))) {
2979 node = xmlTextReaderConstName(reader);
2981 _LOGD("xmlTextReaderConstName value is NULL\n");
2985 if (!strcmp(ASCII(node), "define")) {
2986 define_x *define= malloc(sizeof(define_x));
2987 if (define == NULL) {
2988 _LOGD("Malloc Failed\n");
2991 memset(define, '\0', sizeof(define_x));
2992 LISTADD(datashare->define, define);
2993 ret = __ps_process_define(reader, define);
2994 } else if (!strcmp(ASCII(node), "request")) {
2995 request_x *request= malloc(sizeof(request_x));
2996 if (request == NULL) {
2997 _LOGD("Malloc Failed\n");
3000 memset(request, '\0', sizeof(request_x));
3001 LISTADD(datashare->request, request);
3002 ret = __ps_process_request(reader, request);
3006 _LOGD("Processing data-share failed\n");
3010 if (datashare->define) {
3011 LISTHEAD(datashare->define, tmp1);
3012 datashare->define = tmp1;
3014 if (datashare->request) {
3015 LISTHEAD(datashare->request, tmp2);
3016 datashare->request = tmp2;
3022 __get_icon_with_path(const char* icon)
3027 if (index(icon, '/') == NULL) {
3029 char* icon_with_path = NULL;
3035 /* "db/setting/theme" is not exist */
3037 theme = vconf_get_str("db/setting/theme");
3039 theme = strdup("default");
3045 theme = strdup("default");
3048 len = (0x01 << 7) + strlen(icon) + strlen(package) + strlen(theme);
3049 icon_with_path = malloc(len);
3050 if(icon_with_path == NULL) {
3051 _LOGD("(icon_with_path == NULL) return\n");
3056 memset(icon_with_path, 0, len);
3058 snprintf(icon_with_path, len, "/opt/share/icons/%s/small/%s", theme, icon);
3060 if (access(icon_with_path, R_OK) == 0) break;
3061 snprintf(icon_with_path, len, "/usr/share/icons/%s/small/%s", theme, icon);
3062 if (access(icon_with_path, R_OK) == 0) break;
3063 _LOGD("cannot find icon %s", icon_with_path);
3064 snprintf(icon_with_path, len,"/opt/share/icons/default/small/%s", icon);
3065 if (access(icon_with_path, R_OK) == 0) break;
3066 snprintf(icon_with_path, len, "/usr/share/icons/default/small/%s", icon);
3067 if (access(icon_with_path, R_OK) == 0) break;
3069 /* icon path is going to be moved intto the app directory */
3070 _LOGE("icon file must be moved to %s", icon_with_path);
3071 snprintf(icon_with_path, len, "/opt/apps/%s/res/icons/%s/small/%s", package, theme, icon);
3072 if (access(icon_with_path, R_OK) == 0) break;
3073 snprintf(icon_with_path, len, "/usr/apps/%s/res/icons/%s/small/%s", package, theme, icon);
3074 if (access(icon_with_path, R_OK) == 0) break;
3075 _LOGD("cannot find icon %s", icon_with_path);
3076 snprintf(icon_with_path, len, "/opt/apps/%s/res/icons/default/small/%s", package, icon);
3077 if (access(icon_with_path, R_OK) == 0) break;
3078 snprintf(icon_with_path, len, "/usr/apps/%s/res/icons/default/small/%s", package, icon);
3079 if (access(icon_with_path, R_OK) == 0) break;
3080 snprintf(icon_with_path, len, "/usr/ug/res/images/%s/%s", package, icon);
3081 if (access(icon_with_path, R_OK) == 0) break;
3086 _LOGD("Icon path : %s ---> %s", icon, icon_with_path);
3088 return icon_with_path;
3090 char* confirmed_icon = NULL;
3092 confirmed_icon = strdup(icon);
3093 if (!confirmed_icon)
3095 return confirmed_icon;
3099 static void __ps_process_tag(manifest_x * mfx, char *const tagv[])
3102 char delims[] = "=";
3103 char *ret_result = NULL;
3109 for (tag = strdup(tagv[0]); tag != NULL; ) {
3110 ret_result = strtok(tag, delims);
3112 /*check tag : preload */
3113 if (strcmp(ret_result, "preload") == 0) {
3114 ret_result = strtok(NULL, delims);
3115 if (strcmp(ret_result, "true") == 0) {
3116 free((void *)mfx->preload);
3117 mfx->preload = strdup("true");
3118 } else if (strcmp(ret_result, "false") == 0) {
3119 free((void *)mfx->preload);
3120 mfx->preload = strdup("false");
3122 /*check tag : removable*/
3123 } else if (strcmp(ret_result, "removable") == 0) {
3124 ret_result = strtok(NULL, delims);
3125 if (strcmp(ret_result, "true") == 0){
3126 free((void *)mfx->removable);
3127 mfx->removable = strdup("true");
3128 } else if (strcmp(ret_result, "false") == 0) {
3129 free((void *)mfx->removable);
3130 mfx->removable = strdup("false");
3132 /*check tag : not matched*/
3134 _LOGD("tag process [%s]is not defined\n", ret_result);
3138 /*check next value*/
3139 if (tagv[++i] != NULL)
3140 tag = strdup(tagv[i]);
3142 _LOGD("tag process success...\n");
3148 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon)
3150 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
3151 icon->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
3152 if (xmlTextReaderConstXmlLang(reader)) {
3153 icon->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3154 if (icon->lang == NULL)
3155 icon->lang = strdup(DEFAULT_LOCALE);
3157 icon->lang = strdup(DEFAULT_LOCALE);
3159 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
3160 icon->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
3161 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
3162 icon->size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
3163 if (xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")))
3164 icon->resolution = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")));
3165 xmlTextReaderRead(reader);
3166 if (xmlTextReaderValue(reader)) {
3167 const char *text = ASCII(xmlTextReaderValue(reader));
3169 icon->text = (const char *)__get_icon_with_path(text);
3177 static int __ps_process_image(xmlTextReaderPtr reader, image_x *image)
3179 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
3180 image->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
3181 if (xmlTextReaderConstXmlLang(reader)) {
3182 image->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3183 if (image->lang == NULL)
3184 image->lang = strdup(DEFAULT_LOCALE);
3186 image->lang = strdup(DEFAULT_LOCALE);
3188 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
3189 image->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
3190 xmlTextReaderRead(reader);
3191 if (xmlTextReaderValue(reader))
3192 image->text = ASCII(xmlTextReaderValue(reader));
3197 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label)
3199 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
3200 label->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
3201 if (xmlTextReaderConstXmlLang(reader)) {
3202 label->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3203 if (label->lang == NULL)
3204 label->lang = strdup(DEFAULT_LOCALE);
3206 label->lang = strdup(DEFAULT_LOCALE);
3208 xmlTextReaderRead(reader);
3209 if (xmlTextReaderValue(reader))
3210 label->text = ASCII(xmlTextReaderValue(reader));
3212 /* _LOGD("lable name %s\n", label->name);
3213 _LOGD("lable lang %s\n", label->lang);
3214 _LOGD("lable text %s\n", label->text);
3220 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author)
3222 if (xmlTextReaderGetAttribute(reader, XMLCHAR("email")))
3223 author->email = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("email")));
3224 if (xmlTextReaderGetAttribute(reader, XMLCHAR("href")))
3225 author->href = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("href")));
3226 if (xmlTextReaderConstXmlLang(reader)) {
3227 author->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3228 if (author->lang == NULL)
3229 author->lang = strdup(DEFAULT_LOCALE);
3231 author->lang = strdup(DEFAULT_LOCALE);
3233 xmlTextReaderRead(reader);
3234 if (xmlTextReaderValue(reader)) {
3235 const char *text = ASCII(xmlTextReaderValue(reader));
3236 if (*text == '\n') {
3237 author->text = NULL;
3241 author->text = ASCII(xmlTextReaderValue(reader));
3246 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description)
3248 if (xmlTextReaderConstXmlLang(reader)) {
3249 description->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3250 if (description->lang == NULL)
3251 description->lang = strdup(DEFAULT_LOCALE);
3253 description->lang = strdup(DEFAULT_LOCALE);
3255 xmlTextReaderRead(reader);
3256 if (xmlTextReaderValue(reader)) {
3257 const char *text = ASCII(xmlTextReaderValue(reader));
3258 if (*text == '\n') {
3259 description->text = NULL;
3263 description->text = ASCII(xmlTextReaderValue(reader));
3268 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license)
3270 if (xmlTextReaderConstXmlLang(reader)) {
3271 license->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3272 if (license->lang == NULL)
3273 license->lang = strdup(DEFAULT_LOCALE);
3275 license->lang = strdup(DEFAULT_LOCALE);
3277 xmlTextReaderRead(reader);
3278 if (xmlTextReaderValue(reader))
3279 license->text = ASCII(xmlTextReaderValue(reader));
3283 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability)
3285 const xmlChar *node;
3288 resolution_x *tmp1 = NULL;
3290 if (xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")))
3291 capability->operationid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")));
3293 depth = xmlTextReaderDepth(reader);
3294 while ((ret = __next_child_element(reader, depth))) {
3295 node = xmlTextReaderConstName(reader);
3297 _LOGD("xmlTextReaderConstName value is NULL\n");
3301 if (!strcmp(ASCII(node), "resolution")) {
3302 resolution_x *resolution = malloc(sizeof(resolution_x));
3303 if (resolution == NULL) {
3304 _LOGD("Malloc Failed\n");
3307 memset(resolution, '\0', sizeof(resolution_x));
3308 LISTADD(capability->resolution, resolution);
3309 ret = __ps_process_resolution(reader, resolution);
3313 _LOGD("Processing capability failed\n");
3318 if (capability->resolution) {
3319 LISTHEAD(capability->resolution, tmp1);
3320 capability->resolution = tmp1;
3326 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol)
3328 const xmlChar *node;
3331 capability_x *tmp1 = NULL;
3333 if (xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")))
3334 datacontrol->providerid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")));
3336 depth = xmlTextReaderDepth(reader);
3337 while ((ret = __next_child_element(reader, depth))) {
3338 node = xmlTextReaderConstName(reader);
3340 _LOGD("xmlTextReaderConstName value is NULL\n");
3344 if (!strcmp(ASCII(node), "capability")) {
3345 capability_x *capability = malloc(sizeof(capability_x));
3346 if (capability == NULL) {
3347 _LOGD("Malloc Failed\n");
3350 memset(capability, '\0', sizeof(capability_x));
3351 LISTADD(datacontrol->capability, capability);
3352 ret = __ps_process_capability(reader, capability);
3356 _LOGD("Processing datacontrol failed\n");
3361 if (datacontrol->capability) {
3362 LISTHEAD(datacontrol->capability, tmp1);
3363 datacontrol->capability = tmp1;
3369 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication)
3371 const xmlChar *node;
3374 char *newappid = NULL;
3375 label_x *tmp1 = NULL;
3376 icon_x *tmp2 = NULL;
3377 appsvc_x *tmp3 = NULL;
3378 appcontrol_x *tmp4 = NULL;
3379 launchconditions_x *tmp5 = NULL;
3380 notification_x *tmp6 = NULL;
3381 datashare_x *tmp7 = NULL;
3382 category_x *tmp8 = NULL;
3383 metadata_x *tmp9 = NULL;
3384 image_x *tmp10 = NULL;
3385 permission_x *tmp11 = NULL;
3387 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
3388 uiapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
3389 if (uiapplication->appid == NULL) {
3390 _LOGD("appid cant be NULL\n");
3394 _LOGD("appid is mandatory\n");
3398 ret = __validate_appid(package, uiapplication->appid, &newappid);
3400 _LOGD("appid is not proper\n");
3404 if (uiapplication->appid)
3405 free((void *)uiapplication->appid);
3406 uiapplication->appid = newappid;
3408 uiapplication->package= strdup(package);
3410 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
3411 uiapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
3412 if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay"))) {
3413 uiapplication->nodisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay")));
3414 if (uiapplication->nodisplay == NULL)
3415 uiapplication->nodisplay = strdup("false");
3417 uiapplication->nodisplay = strdup("false");
3419 if (xmlTextReaderGetAttribute(reader, XMLCHAR("multiple"))) {
3420 uiapplication->multiple = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("multiple")));
3421 if (uiapplication->multiple == NULL)
3422 uiapplication->multiple = strdup("false");
3424 uiapplication->multiple = strdup("false");
3426 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
3427 uiapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
3428 if (xmlTextReaderGetAttribute(reader, XMLCHAR("categories")))
3429 uiapplication->categories = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("categories")));
3430 if (xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")))
3431 uiapplication->extraid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")));
3432 if (xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage"))) {
3433 uiapplication->taskmanage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage")));
3434 if (uiapplication->taskmanage == NULL)
3435 uiapplication->taskmanage = strdup("true");
3437 uiapplication->taskmanage = strdup("true");
3439 if (xmlTextReaderGetAttribute(reader, XMLCHAR("enabled"))) {
3440 uiapplication->enabled = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("enabled")));
3441 if (uiapplication->enabled == NULL)
3442 uiapplication->enabled = strdup("true");
3444 uiapplication->enabled = strdup("true");
3446 if (xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration"))) {
3447 uiapplication->hwacceleration = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration")));
3448 if (uiapplication->hwacceleration == NULL)
3449 uiapplication->hwacceleration = strdup("use-system-setting");
3451 uiapplication->hwacceleration = strdup("use-system-setting");
3453 if (xmlTextReaderGetAttribute(reader, XMLCHAR("screen-reader"))) {
3454 uiapplication->screenreader = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("screen-reader")));
3455 if (uiapplication->screenreader == NULL)
3456 uiapplication->screenreader = strdup("use-system-setting");
3458 uiapplication->screenreader = strdup("use-system-setting");
3460 if (xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")))
3461 uiapplication->recentimage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")));
3462 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp"))) {
3463 uiapplication->mainapp = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp")));
3464 if (uiapplication->mainapp == NULL)
3465 uiapplication->mainapp = strdup("false");
3467 uiapplication->mainapp = strdup("false");
3469 if (xmlTextReaderGetAttribute(reader, XMLCHAR("launchcondition"))) {
3470 uiapplication->launchcondition = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("launchcondition")));
3471 if (uiapplication->launchcondition == NULL)
3472 uiapplication->launchcondition = strdup("false");
3474 uiapplication->launchcondition = strdup("false");
3477 if (xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay"))) {
3478 uiapplication->indicatordisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay")));
3479 if (uiapplication->indicatordisplay == NULL)
3480 uiapplication->indicatordisplay = strdup("true");
3482 uiapplication->indicatordisplay = strdup("true");
3484 if (xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")))
3485 uiapplication->portraitimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")));
3487 uiapplication->portraitimg = NULL;
3488 if (xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")))
3489 uiapplication->landscapeimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")));
3491 uiapplication->landscapeimg = NULL;
3492 if (xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility"))) {
3493 uiapplication->guestmode_visibility = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility")));
3494 if (uiapplication->guestmode_visibility == NULL)
3495 uiapplication->guestmode_visibility = strdup("true");
3497 uiapplication->guestmode_visibility = strdup("true");
3499 if (xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type"))) {
3500 uiapplication->permission_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type")));
3501 if (uiapplication->permission_type == NULL)
3502 uiapplication->permission_type = strdup("normal");
3504 uiapplication->permission_type = strdup("normal");
3506 if (xmlTextReaderGetAttribute(reader, XMLCHAR("component-type"))) {
3507 uiapplication->component_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("component-type")));
3508 if (uiapplication->component_type == NULL)
3509 uiapplication->component_type = strdup("uiapp");
3511 uiapplication->component_type = strdup("uiapp");
3513 if (xmlTextReaderGetAttribute(reader, XMLCHAR("submode"))) {
3514 uiapplication->submode = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("submode")));
3515 if (uiapplication->submode == NULL)
3516 uiapplication->submode = strdup("false");
3518 uiapplication->submode = strdup("false");
3520 if (xmlTextReaderGetAttribute(reader, XMLCHAR("submode-mainid")))
3521 uiapplication->submode_mainid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("submode-mainid")));
3523 depth = xmlTextReaderDepth(reader);
3524 while ((ret = __next_child_element(reader, depth))) {
3525 node = xmlTextReaderConstName(reader);
3527 _LOGD("xmlTextReaderConstName value is NULL\n");
3530 if (!strcmp(ASCII(node), "label")) {
3531 label_x *label = malloc(sizeof(label_x));
3532 if (label == NULL) {
3533 _LOGD("Malloc Failed\n");
3536 memset(label, '\0', sizeof(label_x));
3537 LISTADD(uiapplication->label, label);
3538 ret = __ps_process_label(reader, label);
3539 } else if (!strcmp(ASCII(node), "icon")) {
3540 icon_x *icon = malloc(sizeof(icon_x));
3542 _LOGD("Malloc Failed\n");
3545 memset(icon, '\0', sizeof(icon_x));
3546 LISTADD(uiapplication->icon, icon);
3547 ret = __ps_process_icon(reader, icon);
3548 } else if (!strcmp(ASCII(node), "image")) {
3549 image_x *image = malloc(sizeof(image_x));
3550 if (image == NULL) {
3551 _LOGD("Malloc Failed\n");
3554 memset(image, '\0', sizeof(image_x));
3555 LISTADD(uiapplication->image, image);
3556 ret = __ps_process_image(reader, image);
3557 } else if (!strcmp(ASCII(node), "category")) {
3558 category_x *category = malloc(sizeof(category_x));
3559 if (category == NULL) {
3560 _LOGD("Malloc Failed\n");
3563 memset(category, '\0', sizeof(category_x));
3564 LISTADD(uiapplication->category, category);
3565 ret = __ps_process_category(reader, category);
3566 } else if (!strcmp(ASCII(node), "metadata")) {
3567 metadata_x *metadata = malloc(sizeof(metadata_x));
3568 if (metadata == NULL) {
3569 _LOGD("Malloc Failed\n");
3572 memset(metadata, '\0', sizeof(metadata_x));
3573 LISTADD(uiapplication->metadata, metadata);
3574 ret = __ps_process_metadata(reader, metadata);
3575 } else if (!strcmp(ASCII(node), "permission")) {
3576 permission_x *permission = malloc(sizeof(permission_x));
3577 if (permission == NULL) {
3578 _LOGD("Malloc Failed\n");
3581 memset(permission, '\0', sizeof(permission_x));
3582 LISTADD(uiapplication->permission, permission);
3583 ret = __ps_process_permission(reader, permission);
3584 } else if (!strcmp(ASCII(node), "app-control")) {
3585 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
3586 if (appcontrol == NULL) {
3587 _LOGD("Malloc Failed\n");
3590 memset(appcontrol, '\0', sizeof(appcontrol_x));
3591 LISTADD(uiapplication->appcontrol, appcontrol);
3592 ret = __ps_process_appcontrol(reader, appcontrol);
3593 } else if (!strcmp(ASCII(node), "application-service")) {
3594 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
3595 if (appsvc == NULL) {
3596 _LOGD("Malloc Failed\n");
3599 memset(appsvc, '\0', sizeof(appsvc_x));
3600 LISTADD(uiapplication->appsvc, appsvc);
3601 ret = __ps_process_appsvc(reader, appsvc);
3602 } else if (!strcmp(ASCII(node), "data-share")) {
3603 datashare_x *datashare = malloc(sizeof(datashare_x));
3604 if (datashare == NULL) {
3605 _LOGD("Malloc Failed\n");
3608 memset(datashare, '\0', sizeof(datashare_x));
3609 LISTADD(uiapplication->datashare, datashare);
3610 ret = __ps_process_datashare(reader, datashare);
3611 } else if (!strcmp(ASCII(node), "launch-conditions")) {
3612 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
3613 if (launchconditions == NULL) {
3614 _LOGD("Malloc Failed\n");
3617 memset(launchconditions, '\0', sizeof(launchconditions_x));
3618 LISTADD(uiapplication->launchconditions, launchconditions);
3619 ret = __ps_process_launchconditions(reader, launchconditions);
3620 } else if (!strcmp(ASCII(node), "notification")) {
3621 notification_x *notification = malloc(sizeof(notification_x));
3622 if (notification == NULL) {
3623 _LOGD("Malloc Failed\n");
3626 memset(notification, '\0', sizeof(notification_x));
3627 LISTADD(uiapplication->notification, notification);
3628 ret = __ps_process_notification(reader, notification);
3632 _LOGD("Processing uiapplication failed\n");
3637 if (uiapplication->label) {
3638 LISTHEAD(uiapplication->label, tmp1);
3639 uiapplication->label = tmp1;
3641 if (uiapplication->icon) {
3642 LISTHEAD(uiapplication->icon, tmp2);
3643 uiapplication->icon = tmp2;
3645 if (uiapplication->appsvc) {
3646 LISTHEAD(uiapplication->appsvc, tmp3);
3647 uiapplication->appsvc = tmp3;
3649 if (uiapplication->appcontrol) {
3650 LISTHEAD(uiapplication->appcontrol, tmp4);
3651 uiapplication->appcontrol = tmp4;
3653 if (uiapplication->launchconditions) {
3654 LISTHEAD(uiapplication->launchconditions, tmp5);
3655 uiapplication->launchconditions = tmp5;
3657 if (uiapplication->notification) {
3658 LISTHEAD(uiapplication->notification, tmp6);
3659 uiapplication->notification = tmp6;
3661 if (uiapplication->datashare) {
3662 LISTHEAD(uiapplication->datashare, tmp7);
3663 uiapplication->datashare = tmp7;
3665 if (uiapplication->category) {
3666 LISTHEAD(uiapplication->category, tmp8);
3667 uiapplication->category = tmp8;
3669 if (uiapplication->metadata) {
3670 LISTHEAD(uiapplication->metadata, tmp9);
3671 uiapplication->metadata = tmp9;
3673 if (uiapplication->image) {
3674 LISTHEAD(uiapplication->image, tmp10);
3675 uiapplication->image = tmp10;
3677 if (uiapplication->permission) {
3678 LISTHEAD(uiapplication->permission, tmp11);
3679 uiapplication->permission = tmp11;
3685 static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication)
3687 const xmlChar *node;
3690 char *newappid = NULL;
3691 label_x *tmp1 = NULL;
3692 icon_x *tmp2 = NULL;
3693 appsvc_x *tmp3 = NULL;
3694 appcontrol_x *tmp4 = NULL;
3695 datacontrol_x *tmp5 = NULL;
3696 launchconditions_x *tmp6 = NULL;
3697 notification_x *tmp7 = NULL;
3698 datashare_x *tmp8 = NULL;
3699 category_x *tmp9 = NULL;
3700 metadata_x *tmp10 = NULL;
3701 permission_x *tmp11 = NULL;
3703 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
3704 serviceapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
3705 if (serviceapplication->appid == NULL) {
3706 _LOGD("appid cant be NULL\n");
3710 _LOGD("appid is mandatory\n");
3714 ret = __validate_appid(package, serviceapplication->appid, &newappid);
3716 _LOGD("appid is not proper\n");
3720 if (serviceapplication->appid)
3721 free((void *)serviceapplication->appid);
3722 serviceapplication->appid = newappid;
3725 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
3726 serviceapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
3727 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
3728 serviceapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
3729 if (xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot"))) {
3730 serviceapplication->onboot = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot")));
3731 if (serviceapplication->onboot == NULL)
3732 serviceapplication->onboot = strdup("false");
3734 serviceapplication->onboot = strdup("false");
3736 if (xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart"))) {
3737 serviceapplication->autorestart = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart")));
3738 if (serviceapplication->autorestart == NULL)
3739 serviceapplication->autorestart = strdup("false");
3741 serviceapplication->autorestart = strdup("false");
3743 if (xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type"))) {
3744 serviceapplication->permission_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type")));
3745 if (serviceapplication->permission_type == NULL)
3746 serviceapplication->permission_type = strdup("normal");
3748 serviceapplication->permission_type = strdup("normal");
3751 depth = xmlTextReaderDepth(reader);
3752 while ((ret = __next_child_element(reader, depth))) {
3753 node = xmlTextReaderConstName(reader);
3755 _LOGD("xmlTextReaderConstName value is NULL\n");
3759 if (!strcmp(ASCII(node), "label")) {
3760 label_x *label = malloc(sizeof(label_x));
3761 if (label == NULL) {
3762 _LOGD("Malloc Failed\n");
3765 memset(label, '\0', sizeof(label_x));
3766 LISTADD(serviceapplication->label, label);
3767 ret = __ps_process_label(reader, label);
3768 } else if (!strcmp(ASCII(node), "icon")) {
3769 icon_x *icon = malloc(sizeof(icon_x));
3771 _LOGD("Malloc Failed\n");
3774 memset(icon, '\0', sizeof(icon_x));
3775 LISTADD(serviceapplication->icon, icon);
3776 ret = __ps_process_icon(reader, icon);
3777 } else if (!strcmp(ASCII(node), "category")) {
3778 category_x *category = malloc(sizeof(category_x));
3779 if (category == NULL) {
3780 _LOGD("Malloc Failed\n");
3783 memset(category, '\0', sizeof(category_x));
3784 LISTADD(serviceapplication->category, category);
3785 ret = __ps_process_category(reader, category);
3786 } else if (!strcmp(ASCII(node), "metadata")) {
3787 metadata_x *metadata = malloc(sizeof(metadata_x));
3788 if (metadata == NULL) {
3789 _LOGD("Malloc Failed\n");
3792 memset(metadata, '\0', sizeof(metadata_x));
3793 LISTADD(serviceapplication->metadata, metadata);
3794 ret = __ps_process_metadata(reader, metadata);
3795 } else if (!strcmp(ASCII(node), "permission")) {
3796 permission_x *permission = malloc(sizeof(permission_x));
3797 if (permission == NULL) {
3798 _LOGD("Malloc Failed\n");
3801 memset(permission, '\0', sizeof(permission_x));
3802 LISTADD(serviceapplication->permission, permission);
3803 ret = __ps_process_permission(reader, permission);
3804 } else if (!strcmp(ASCII(node), "app-control")) {
3805 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
3806 if (appcontrol == NULL) {
3807 _LOGD("Malloc Failed\n");
3810 memset(appcontrol, '\0', sizeof(appcontrol_x));
3811 LISTADD(serviceapplication->appcontrol, appcontrol);
3812 ret = __ps_process_appcontrol(reader, appcontrol);
3813 } else if (!strcmp(ASCII(node), "application-service")) {
3814 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
3815 if (appsvc == NULL) {
3816 _LOGD("Malloc Failed\n");
3819 memset(appsvc, '\0', sizeof(appsvc_x));
3820 LISTADD(serviceapplication->appsvc, appsvc);
3821 ret = __ps_process_appsvc(reader, appsvc);
3822 } else if (!strcmp(ASCII(node), "data-share")) {
3823 datashare_x *datashare = malloc(sizeof(datashare_x));
3824 if (datashare == NULL) {
3825 _LOGD("Malloc Failed\n");
3828 memset(datashare, '\0', sizeof(datashare_x));
3829 LISTADD(serviceapplication->datashare, datashare);
3830 ret = __ps_process_datashare(reader, datashare);
3831 } else if (!strcmp(ASCII(node), "launch-conditions")) {
3832 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
3833 if (launchconditions == NULL) {
3834 _LOGD("Malloc Failed\n");
3837 memset(launchconditions, '\0', sizeof(launchconditions_x));
3838 LISTADD(serviceapplication->launchconditions, launchconditions);
3839 ret = __ps_process_launchconditions(reader, launchconditions);
3840 } else if (!strcmp(ASCII(node), "notification")) {
3841 notification_x *notification = malloc(sizeof(notification_x));
3842 if (notification == NULL) {
3843 _LOGD("Malloc Failed\n");
3846 memset(notification, '\0', sizeof(notification_x));
3847 LISTADD(serviceapplication->notification, notification);
3848 ret = __ps_process_notification(reader, notification);
3849 } else if (!strcmp(ASCII(node), "data-control")) {
3850 datacontrol_x *datacontrol = malloc(sizeof(datacontrol_x));
3851 if (datacontrol == NULL) {
3852 _LOGD("Malloc Failed\n");
3855 memset(datacontrol, '\0', sizeof(datacontrol_x));
3856 LISTADD(serviceapplication->datacontrol, datacontrol);
3857 ret = __ps_process_datacontrol(reader, datacontrol);
3861 _LOGD("Processing serviceapplication failed\n");
3866 if (serviceapplication->label) {
3867 LISTHEAD(serviceapplication->label, tmp1);
3868 serviceapplication->label = tmp1;
3870 if (serviceapplication->icon) {
3871 LISTHEAD(serviceapplication->icon, tmp2);
3872 serviceapplication->icon = tmp2;
3874 if (serviceapplication->appsvc) {
3875 LISTHEAD(serviceapplication->appsvc, tmp3);
3876 serviceapplication->appsvc = tmp3;
3878 if (serviceapplication->appcontrol) {
3879 LISTHEAD(serviceapplication->appcontrol, tmp4);
3880 serviceapplication->appcontrol = tmp4;
3882 if (serviceapplication->datacontrol) {
3883 LISTHEAD(serviceapplication->datacontrol, tmp5);
3884 serviceapplication->datacontrol = tmp5;
3886 if (serviceapplication->launchconditions) {
3887 LISTHEAD(serviceapplication->launchconditions, tmp6);
3888 serviceapplication->launchconditions = tmp6;
3890 if (serviceapplication->notification) {
3891 LISTHEAD(serviceapplication->notification, tmp7);
3892 serviceapplication->notification = tmp7;
3894 if (serviceapplication->datashare) {
3895 LISTHEAD(serviceapplication->datashare, tmp8);
3896 serviceapplication->datashare = tmp8;
3898 if (serviceapplication->category) {
3899 LISTHEAD(serviceapplication->category, tmp9);
3900 serviceapplication->category = tmp9;
3902 if (serviceapplication->metadata) {
3903 LISTHEAD(serviceapplication->metadata, tmp10);
3904 serviceapplication->metadata = tmp10;
3906 if (serviceapplication->permission) {
3907 LISTHEAD(serviceapplication->permission, tmp11);
3908 serviceapplication->permission = tmp11;
3914 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile)
3916 /*TODO: once policy is set*/
3920 static int __ps_process_font(xmlTextReaderPtr reader, font_x *font)
3922 /*TODO: once policy is set*/
3926 static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme)
3928 /*TODO: once policy is set*/
3932 static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon)
3934 /*TODO: once policy is set*/
3938 static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime)
3940 /*TODO: once policy is set*/
3944 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx)
3946 _LOGD("__start_process\n");
3947 const xmlChar *node;
3950 label_x *tmp1 = NULL;
3951 author_x *tmp2 = NULL;
3952 description_x *tmp3 = NULL;
3953 license_x *tmp4 = NULL;
3954 uiapplication_x *tmp5 = NULL;
3955 serviceapplication_x *tmp6 = NULL;
3956 daemon_x *tmp7 = NULL;
3957 theme_x *tmp8 = NULL;
3958 font_x *tmp9 = NULL;
3959 ime_x *tmp10 = NULL;
3960 icon_x *tmp11 = NULL;
3961 compatibility_x *tmp12 = NULL;
3962 deviceprofile_x *tmp13 = NULL;
3963 privileges_x *tmp14 = NULL;
3965 depth = xmlTextReaderDepth(reader);
3966 while ((ret = __next_child_element(reader, depth))) {
3967 node = xmlTextReaderConstName(reader);
3969 _LOGD("xmlTextReaderConstName value is NULL\n");
3973 if (!strcmp(ASCII(node), "label")) {
3974 label_x *label = malloc(sizeof(label_x));
3975 if (label == NULL) {
3976 _LOGD("Malloc Failed\n");
3979 memset(label, '\0', sizeof(label_x));
3980 LISTADD(mfx->label, label);
3981 ret = __ps_process_label(reader, label);
3982 } else if (!strcmp(ASCII(node), "author")) {
3983 author_x *author = malloc(sizeof(author_x));
3984 if (author == NULL) {
3985 _LOGD("Malloc Failed\n");
3988 memset(author, '\0', sizeof(author_x));
3989 LISTADD(mfx->author, author);
3990 ret = __ps_process_author(reader, author);
3991 } else if (!strcmp(ASCII(node), "description")) {
3992 description_x *description = malloc(sizeof(description_x));
3993 if (description == NULL) {
3994 _LOGD("Malloc Failed\n");
3997 memset(description, '\0', sizeof(description_x));
3998 LISTADD(mfx->description, description);
3999 ret = __ps_process_description(reader, description);
4000 } else if (!strcmp(ASCII(node), "license")) {
4001 license_x *license = malloc(sizeof(license_x));
4002 if (license == NULL) {
4003 _LOGD("Malloc Failed\n");
4006 memset(license, '\0', sizeof(license_x));
4007 LISTADD(mfx->license, license);
4008 ret = __ps_process_license(reader, license);
4009 } else if (!strcmp(ASCII(node), "privileges")) {
4010 privileges_x *privileges = malloc(sizeof(privileges_x));
4011 if (privileges == NULL) {
4012 _LOGD("Malloc Failed\n");
4015 memset(privileges, '\0', sizeof(privileges_x));
4016 LISTADD(mfx->privileges, privileges);
4017 ret = __ps_process_privileges(reader, privileges);
4018 } else if (!strcmp(ASCII(node), "ui-application")) {
4019 uiapplication_x *uiapplication = malloc(sizeof(uiapplication_x));
4020 if (uiapplication == NULL) {
4021 _LOGD("Malloc Failed\n");
4024 memset(uiapplication, '\0', sizeof(uiapplication_x));
4025 LISTADD(mfx->uiapplication, uiapplication);
4026 ret = __ps_process_uiapplication(reader, uiapplication);
4027 } else if (!strcmp(ASCII(node), "service-application")) {
4028 serviceapplication_x *serviceapplication = malloc(sizeof(serviceapplication_x));
4029 if (serviceapplication == NULL) {
4030 _LOGD("Malloc Failed\n");
4033 memset(serviceapplication, '\0', sizeof(serviceapplication_x));
4034 LISTADD(mfx->serviceapplication, serviceapplication);
4035 ret = __ps_process_serviceapplication(reader, serviceapplication);
4036 } else if (!strcmp(ASCII(node), "daemon")) {
4037 daemon_x *daemon = malloc(sizeof(daemon_x));
4038 if (daemon == NULL) {
4039 _LOGD("Malloc Failed\n");
4042 memset(daemon, '\0', sizeof(daemon_x));
4043 LISTADD(mfx->daemon, daemon);
4044 ret = __ps_process_daemon(reader, daemon);
4045 } else if (!strcmp(ASCII(node), "theme")) {
4046 theme_x *theme = malloc(sizeof(theme_x));
4047 if (theme == NULL) {
4048 _LOGD("Malloc Failed\n");
4051 memset(theme, '\0', sizeof(theme_x));
4052 LISTADD(mfx->theme, theme);
4053 ret = __ps_process_theme(reader, theme);
4054 } else if (!strcmp(ASCII(node), "font")) {
4055 font_x *font = malloc(sizeof(font_x));
4057 _LOGD("Malloc Failed\n");
4060 memset(font, '\0', sizeof(font_x));
4061 LISTADD(mfx->font, font);
4062 ret = __ps_process_font(reader, font);
4063 } else if (!strcmp(ASCII(node), "ime")) {
4064 ime_x *ime = malloc(sizeof(ime_x));
4066 _LOGD("Malloc Failed\n");
4069 memset(ime, '\0', sizeof(ime_x));
4070 LISTADD(mfx->ime, ime);
4071 ret = __ps_process_ime(reader, ime);
4072 } else if (!strcmp(ASCII(node), "icon")) {
4073 icon_x *icon = malloc(sizeof(icon_x));
4075 _LOGD("Malloc Failed\n");
4078 memset(icon, '\0', sizeof(icon_x));
4079 LISTADD(mfx->icon, icon);
4080 ret = __ps_process_icon(reader, icon);
4081 } else if (!strcmp(ASCII(node), "device-profile")) {
4082 deviceprofile_x *deviceprofile = malloc(sizeof(deviceprofile_x));
4083 if (deviceprofile == NULL) {
4084 _LOGD("Malloc Failed\n");
4087 memset(deviceprofile, '\0', sizeof(deviceprofile_x));
4088 LISTADD(mfx->deviceprofile, deviceprofile);
4089 ret = __ps_process_deviceprofile(reader, deviceprofile);
4090 } else if (!strcmp(ASCII(node), "compatibility")) {
4091 compatibility_x *compatibility = malloc(sizeof(compatibility_x));
4092 if (compatibility == NULL) {
4093 _LOGD("Malloc Failed\n");
4096 memset(compatibility, '\0', sizeof(compatibility_x));
4097 LISTADD(mfx->compatibility, compatibility);
4098 ret = __ps_process_compatibility(reader, compatibility);
4099 } else if (!strcmp(ASCII(node), "shortcut-list")) {
4101 } else if (!strcmp(ASCII(node), "livebox")) {
4103 } else if (!strcmp(ASCII(node), "account")) {
4105 } else if (!strcmp(ASCII(node), "notifications")) {
4107 } else if (!strcmp(ASCII(node), "ime")) {
4113 _LOGD("Processing manifest failed\n");
4118 LISTHEAD(mfx->label, tmp1);
4122 LISTHEAD(mfx->author, tmp2);
4125 if (mfx->description) {
4126 LISTHEAD(mfx->description, tmp3);
4127 mfx->description= tmp3;
4130 LISTHEAD(mfx->license, tmp4);
4133 if (mfx->uiapplication) {
4134 LISTHEAD(mfx->uiapplication, tmp5);
4135 mfx->uiapplication = tmp5;
4137 if (mfx->serviceapplication) {
4138 LISTHEAD(mfx->serviceapplication, tmp6);
4139 mfx->serviceapplication = tmp6;
4142 LISTHEAD(mfx->daemon, tmp7);
4146 LISTHEAD(mfx->theme, tmp8);
4150 LISTHEAD(mfx->font, tmp9);
4154 LISTHEAD(mfx->ime, tmp10);
4158 LISTHEAD(mfx->icon, tmp11);
4161 if (mfx->compatibility) {
4162 LISTHEAD(mfx->compatibility, tmp12);
4163 mfx->compatibility= tmp12;
4165 if (mfx->deviceprofile) {
4166 LISTHEAD(mfx->deviceprofile, tmp13);
4167 mfx->deviceprofile= tmp13;
4169 if (mfx->privileges) {
4170 LISTHEAD(mfx->privileges, tmp14);
4171 mfx->privileges = tmp14;
4176 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx)
4178 const xmlChar *node;
4181 if ((ret = __next_child_element(reader, -1))) {
4182 node = xmlTextReaderConstName(reader);
4184 _LOGD("xmlTextReaderConstName value is NULL\n");
4188 if (!strcmp(ASCII(node), "manifest")) {
4189 if (xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")))
4190 mfx->ns = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")));
4191 if (xmlTextReaderGetAttribute(reader, XMLCHAR("package"))) {
4192 mfx->package= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("package")));
4193 if (mfx->package == NULL) {
4194 _LOGD("package cant be NULL\n");
4198 _LOGD("package field is mandatory\n");
4201 package = mfx->package;
4202 if (xmlTextReaderGetAttribute(reader, XMLCHAR("version")))
4203 mfx->version= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("version")));
4204 /*app2ext needs package size for external installation*/
4205 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
4206 mfx->package_size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
4207 if (xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")))
4208 mfx->installlocation = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")));
4209 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
4210 mfx->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
4211 if (xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")))
4212 mfx->root_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")));
4213 if (xmlTextReaderGetAttribute(reader, XMLCHAR("csc_path")))
4214 mfx->csc_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("csc_path")));
4215 if (xmlTextReaderGetAttribute(reader, XMLCHAR("main_package")))
4216 mfx->main_package = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("main_package")));
4217 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting"))) {
4218 mfx->appsetting = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting")));
4219 if (mfx->appsetting == NULL)
4220 mfx->appsetting = strdup("false");
4222 mfx->appsetting = strdup("false");
4224 if (xmlTextReaderGetAttribute(reader, XMLCHAR("storeclient-id")))
4225 mfx->storeclient_id= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("storeclient-id")));
4226 if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay-setting"))) {
4227 mfx->nodisplay_setting = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay-setting")));
4228 if (mfx->nodisplay_setting == NULL)
4229 mfx->nodisplay_setting = strdup("false");
4231 mfx->nodisplay_setting = strdup("false");
4233 if (xmlTextReaderGetAttribute(reader, XMLCHAR("url")))
4234 mfx->package_url= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("url")));
4236 /*Assign default values. If required it will be overwritten in __add_preload_info()*/
4237 mfx->preload = strdup("False");
4238 mfx->removable = strdup("True");
4239 mfx->readonly = strdup("False");
4240 mfx->update = strdup("False");
4241 mfx->system = strdup("False");
4242 char buf[PKG_STRING_LEN_MAX] = {'\0'};
4244 time_t current_time;
4245 time(¤t_time);
4246 snprintf(buf, PKG_STRING_LEN_MAX - 1, "%d", current_time);
4247 val = strndup(buf, PKG_STRING_LEN_MAX - 1);
4248 mfx->installed_time = val;
4250 mfx->installed_storage= strdup("installed_internal");
4252 ret = __start_process(reader, mfx);
4254 _LOGD("No Manifest element found\n");
4261 #define DESKTOP_RW_PATH tzplatform_mkpath(TZ_SYS_SHARE, "applications/")
4262 #define DESKTOP_RO_PATH "/usr/share/applications/"
4263 #define MANIFEST_RO_PREFIX "/usr/share/packages/"
4265 static char* __convert_to_system_locale(const char *mlocale)
4267 if (mlocale == NULL)
4269 char *locale = NULL;
4270 locale = (char *)calloc(1, 6);
4272 _LOGE("Malloc Failed\n");
4276 strncpy(locale, mlocale, 2);
4277 strncat(locale, "_", 1);
4278 locale[3] = toupper(mlocale[3]);
4279 locale[4] = toupper(mlocale[4]);
4283 #define LIBAIL_PATH LIB_PATH "/libail.so.0"
4285 /* operation_type */
4295 static int __ail_change_info(int op, const char *appid)
4297 void *lib_handle = NULL;
4298 int (*ail_desktop_operation) (const char *);
4302 if ((lib_handle = dlopen(LIBAIL_PATH, RTLD_LAZY)) == NULL) {
4303 _LOGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAIL_PATH);
4310 aop = "ail_desktop_add";
4313 aop = "ail_desktop_update";
4316 aop = "ail_desktop_remove";
4319 aop = "ail_desktop_clean";
4322 aop = "ail_desktop_fota";
4329 if ((ail_desktop_operation =
4330 dlsym(lib_handle, aop)) == NULL || dlerror() != NULL) {
4331 _LOGE("can not find symbol \n");
4335 ret = ail_desktop_operation(appid);
4339 dlclose(lib_handle);
4345 /* desktop shoud be generated automatically based on manifest */
4346 /* Currently removable, taskmanage, etc fields are not considerd. it will be decided soon.*/
4347 #define BUFMAX 1024*128
4348 static int __ps_make_nativeapp_desktop(manifest_x * mfx, const char *manifest, ACTION_TYPE action)
4352 char filepath[PKG_STRING_LEN_MAX] = "";
4354 char *buftemp = NULL;
4355 char *locale = NULL;
4357 buf = (char *)calloc(1, BUFMAX);
4359 _LOGE("Malloc Failed\n");
4363 buftemp = (char *)calloc(1, BUFMAX);
4365 _LOGE("Malloc Failed\n");
4370 if (action == ACTION_UPGRADE)
4371 __ail_change_info(AIL_CLEAN, mfx->package);
4373 for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) {
4375 if (manifest != NULL) {
4376 /* skip making a deskfile and update ail, if preload app is updated */
4377 if(strstr(manifest, MANIFEST_RO_PREFIX)) {
4378 __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid);
4379 _LOGE("preload app is update : skip and update ail : %s", manifest);
4384 if(mfx->readonly && !strcasecmp(mfx->readonly, "True"))
4385 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RO_PATH, mfx->uiapplication->appid);
4387 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, mfx->uiapplication->appid);
4389 /* skip if desktop exists
4390 if (access(filepath, R_OK) == 0)
4394 file = fopen(filepath, "w");
4397 _LOGD("Can't open %s", filepath);
4403 snprintf(buf, BUFMAX, "[Desktop Entry]\n");
4404 fwrite(buf, 1, strlen(buf), file);
4406 for( ; mfx->uiapplication->label ; mfx->uiapplication->label = mfx->uiapplication->label->next) {
4407 if(!strcmp(mfx->uiapplication->label->lang, DEFAULT_LOCALE)) {
4408 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
4410 locale = __convert_to_system_locale(mfx->uiapplication->label->lang);
4411 snprintf(buf, BUFMAX, "Name[%s]=%s\n", locale,
4412 mfx->uiapplication->label->text);
4415 fwrite(buf, 1, strlen(buf), file);
4418 if(mfx->uiapplication->label && mfx->uiapplication->label->text) {
4419 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
4420 fwrite(buf, 1, strlen(buf), file);
4423 else if(mfx->label && mfx->label->text) {
4424 snprintf(buf, BUFMAX, "Name=%s\n", mfx->label->text);
4425 fwrite(buf, 1, strlen(buf), file);
4427 snprintf(buf, BUFMAX, "Name=%s\n", mfx->package);
4428 fwrite(buf, 1, strlen(buf), file);
4433 snprintf(buf, BUFMAX, "Type=Application\n");
4434 fwrite(buf, 1, strlen(buf), file);
4436 if(mfx->uiapplication->exec) {
4437 snprintf(buf, BUFMAX, "Exec=%s\n", mfx->uiapplication->exec);
4438 fwrite(buf, 1, strlen(buf), file);
4441 if(mfx->uiapplication->icon && mfx->uiapplication->icon->text) {
4442 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->uiapplication->icon->text);
4443 fwrite(buf, 1, strlen(buf), file);
4444 } else if(mfx->icon && mfx->icon->text) {
4445 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->icon->text);
4446 fwrite(buf, 1, strlen(buf), file);
4450 if(mfx->uiapplication && mfx->uiapplication->appsvc) {
4451 appsvc_x *asvc = mfx->uiapplication->appsvc;
4453 const char *mime = NULL;
4454 const char *mime_delim = "; ";
4457 strncpy(buf, "MimeType=", BUFMAX-1);
4463 _LOGD("MIME type: %s\n", mime);
4464 strncat(buf, mime, BUFMAX-strlen(buf)-1);
4466 strncat(buf, mime_delim, BUFMAX-strlen(buf)-1);
4474 _LOGD("MIME types: buf[%s]\n", buf);
4475 _LOGD("MIME count: %d\n", mime_count);
4477 fwrite(buf, 1, strlen(buf), file);
4481 snprintf(buf, BUFMAX, "Version=%s\n", mfx->version);
4482 fwrite(buf, 1, strlen(buf), file);
4485 if(mfx->uiapplication->nodisplay) {
4486 snprintf(buf, BUFMAX, "NoDisplay=%s\n", mfx->uiapplication->nodisplay);
4487 fwrite(buf, 1, strlen(buf), file);
4490 if(mfx->uiapplication->categories) {
4491 snprintf(buf, BUFMAX, "Categories=%s\n", mfx->uiapplication->categories);
4492 fwrite(buf, 1, strlen(buf), file);
4495 if(mfx->uiapplication->taskmanage && !strcasecmp(mfx->uiapplication->taskmanage, "False")) {
4496 snprintf(buf, BUFMAX, "X-TIZEN-TaskManage=False\n");
4497 fwrite(buf, 1, strlen(buf), file);
4500 if(mfx->uiapplication->enabled && !strcasecmp(mfx->uiapplication->enabled, "False")) {
4501 snprintf(buf, BUFMAX, "X-TIZEN-Enabled=False\n");
4502 fwrite(buf, 1, strlen(buf), file);
4505 if(mfx->uiapplication->hwacceleration) {
4506 snprintf(buf, BUFMAX, "Hw-Acceleration=%s\n", mfx->uiapplication->hwacceleration);
4507 fwrite(buf, 1, strlen(buf), file);
4510 if(mfx->uiapplication->multiple && !strcasecmp(mfx->uiapplication->multiple, "True")) {
4511 snprintf(buf, BUFMAX, "X-TIZEN-Multiple=True\n");
4512 fwrite(buf, 1, strlen(buf), file);
4515 if(mfx->uiapplication->extraid) {
4516 snprintf(buf, BUFMAX, "X-TIZEN-PackageID=%s\n", mfx->uiapplication->extraid);
4517 fwrite(buf, 1, strlen(buf), file);
4520 if(mfx->removable && !strcasecmp(mfx->removable, "False")) {
4521 snprintf(buf, BUFMAX, "X-TIZEN-Removable=False\n");
4522 fwrite(buf, 1, strlen(buf), file);
4526 snprintf(buf, BUFMAX, "X-TIZEN-PackageType=%s\n", mfx->type);
4527 fwrite(buf, 1, strlen(buf), file);
4530 if(mfx->uiapplication->submode && !strcasecmp(mfx->uiapplication->submode, "True")) {
4531 snprintf(buf, BUFMAX, "X-TIZEN-Submode=%s\n", mfx->uiapplication->submode);
4532 fwrite(buf, 1, strlen(buf), file);
4533 snprintf(buf, BUFMAX, "X-TIZEN-SubmodeMainid=%s\n", mfx->uiapplication->submode_mainid);
4534 fwrite(buf, 1, strlen(buf), file);
4537 snprintf(buf, BUFMAX, "X-TIZEN-PkgID=%s\n", mfx->package);
4538 fwrite(buf, 1, strlen(buf), file);
4541 // snprintf(buf, BUFMAX, "X-TIZEN-PackageType=rpm\n");
4542 // fwrite(buf, 1, strlen(buf), file);
4545 if(mfx->uiapplication->appsvc) {
4546 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
4547 _LOGD("buf[%s]\n", buf);
4550 uiapplication_x *up = mfx->uiapplication;
4551 appsvc_x *asvc = NULL;
4552 operation_x *op = NULL;
4555 subapp_x *sub = NULL;
4556 const char *operation = NULL;
4557 const char *mime = NULL;
4558 const char *uri = NULL;
4559 const char *subapp = NULL;
4564 while(asvc != NULL) {
4565 op = asvc->operation;
4568 operation = op->name;
4587 strncpy(buftemp, buf, BUFMAX);
4588 snprintf(buf, BUFMAX, "%s;", buftemp);
4592 strncpy(buftemp, buf, BUFMAX);
4593 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
4594 _LOGD("buf[%s]\n", buf);
4599 } while(ui != NULL);
4603 }while(sub != NULL);
4616 fwrite(buf, 1, strlen(buf), file);
4618 // strncpy(buftemp, buf, BUFMAX);
4619 // snprintf(buf, BUFMAX, "%s\n", buftemp);
4620 // fwrite(buf, 1, strlen(buf), file);
4623 if(mfx->uiapplication->appcontrol) {
4624 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
4625 _LOGD("buf[%s]\n", buf);
4627 uiapplication_x *up = mfx->uiapplication;
4628 appcontrol_x *acontrol = NULL;
4629 operation_x *op = NULL;
4632 subapp_x *sub = NULL;
4633 const char *operation = NULL;
4634 const char *mime = NULL;
4635 const char *uri = NULL;
4636 const char *subapp = NULL;
4639 acontrol = up->appcontrol;
4640 while(acontrol != NULL) {
4641 op = acontrol->operation;
4644 operation = op->name;
4645 mi = acontrol->mime;
4651 sub = acontrol->subapp;
4663 strncpy(buftemp, buf, BUFMAX);
4664 snprintf(buf, BUFMAX, "%s;", buftemp);
4667 strncpy(buftemp, buf, BUFMAX);
4668 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
4669 _LOGD("buf[%s]\n", buf);
4674 } while(ui != NULL);
4678 }while(sub != NULL);
4687 acontrol = acontrol->next;
4691 fwrite(buf, 1, strlen(buf), file);
4693 // strncpy(buftemp, buf, BUFMAX);
4694 // snprintf(buf, BUFMAX, "%s\n", buftemp);
4695 // fwrite(buf, 1, strlen(buf), file);
4702 if (action == ACTION_FOTA)
4703 __ail_change_info(AIL_FOTA, mfx->uiapplication->appid);
4705 __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid);
4714 static int __ps_remove_nativeapp_desktop(manifest_x *mfx)
4716 char filepath[PKG_STRING_LEN_MAX] = "";
4718 uiapplication_x *uiapplication = mfx->uiapplication;
4720 for(; uiapplication; uiapplication=uiapplication->next) {
4721 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, uiapplication->appid);
4723 __ail_change_info(AIL_REMOVE, uiapplication->appid);
4725 ret = remove(filepath);
4733 #define LIBAPPSVC_PATH LIB_PATH "/libappsvc.so.0"
4735 static int __ps_remove_appsvc_db(manifest_x *mfx)
4737 void *lib_handle = NULL;
4738 int (*appsvc_operation) (const char *);
4740 uiapplication_x *uiapplication = mfx->uiapplication;
4742 if ((lib_handle = dlopen(LIBAPPSVC_PATH, RTLD_LAZY)) == NULL) {
4743 _LOGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAPPSVC_PATH);
4747 if ((appsvc_operation =
4748 dlsym(lib_handle, "appsvc_unset_defapp")) == NULL || dlerror() != NULL) {
4749 _LOGE("can not find symbol \n");
4753 for(; uiapplication; uiapplication=uiapplication->next) {
4754 ret = appsvc_operation(uiapplication->appid);
4756 _LOGE("can not operation symbol \n");
4761 dlclose(lib_handle);
4766 #define PRELOAD_PACKAGE_LIST SYSCONFDIR "/package-manager/preload/preload_list.txt"
4767 static int __add_preload_info(manifest_x * mfx, const char *manifest)
4770 char buffer[1024] = { 0 };
4773 if(strstr(manifest, MANIFEST_RO_PREFIX)) {
4774 free((void *)mfx->readonly);
4775 mfx->readonly = strdup("True");
4777 free((void *)mfx->preload);
4778 mfx->preload = strdup("True");
4780 free((void *)mfx->removable);
4781 mfx->removable = strdup("False");
4783 free((void *)mfx->system);
4784 mfx->system = strdup("True");
4789 fp = fopen(PRELOAD_PACKAGE_LIST, "r");
4791 _LOGE("no preload list\n");
4795 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
4796 if (buffer[0] == '#') {
4797 if(strcasestr(buffer, "RW_NORM"))
4799 else if(strcasestr(buffer, "RW_RM"))
4807 if(!strcmp(mfx->package, buffer)) {
4808 free((void *)mfx->preload);
4809 mfx->preload = strdup("True");
4811 free((void *)mfx->readonly);
4812 mfx->readonly = strdup("False");
4813 free((void *)mfx->removable);
4814 mfx->removable = strdup("False");
4815 } else if(state == 3){
4816 free((void *)mfx->readonly);
4817 mfx->readonly = strdup("False");
4818 free((void *)mfx->removable);
4819 mfx->removable = strdup("True");
4823 memset(buffer, 0x00, sizeof(buffer));
4832 static int __check_preload_updated(manifest_x * mfx, const char *manifest)
4834 char filepath[PKG_STRING_LEN_MAX] = "";
4836 uiapplication_x *uiapplication = mfx->uiapplication;
4838 if(strstr(manifest, MANIFEST_RO_PREFIX)) {
4839 /* if preload app is updated, then remove previous desktop file on RW*/
4840 for(; uiapplication; uiapplication=uiapplication->next) {
4841 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, uiapplication->appid);
4842 ret = remove(filepath);
4847 /* if downloaded app is updated, then update tag set true*/
4848 free((void *)mfx->update);
4849 mfx->update = strdup("true");
4856 API int pkgmgr_parser_create_desktop_file(manifest_x *mfx)
4860 _LOGD("Manifest pointer is NULL\n");
4863 ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_INSTALL);
4865 _LOGD("Creating desktop file failed\n");
4867 _LOGD("Creating desktop file Success\n");
4871 API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
4876 free((void *)mfx->ns);
4880 free((void *)mfx->package);
4881 mfx->package = NULL;
4884 free((void *)mfx->version);
4885 mfx->version = NULL;
4887 if (mfx->installlocation) {
4888 free((void *)mfx->installlocation);
4889 mfx->installlocation = NULL;
4892 free((void *)mfx->preload);
4893 mfx->preload = NULL;
4895 if (mfx->readonly) {
4896 free((void *)mfx->readonly);
4897 mfx->readonly = NULL;
4899 if (mfx->removable) {
4900 free((void *)mfx->removable);
4901 mfx->removable = NULL;
4904 free((void *)mfx->update);
4908 free((void *)mfx->system);
4912 free((void *)mfx->type);
4915 if (mfx->package_size) {
4916 free((void *)mfx->package_size);
4917 mfx->package_size = NULL;
4919 if (mfx->installed_time) {
4920 free((void *)mfx->installed_time);
4921 mfx->installed_time = NULL;
4923 if (mfx->installed_storage) {
4924 free((void *)mfx->installed_storage);
4925 mfx->installed_storage = NULL;
4927 if (mfx->storeclient_id) {
4928 free((void *)mfx->storeclient_id);
4929 mfx->storeclient_id = NULL;
4931 if (mfx->mainapp_id) {
4932 free((void *)mfx->mainapp_id);
4933 mfx->mainapp_id = NULL;
4935 if (mfx->package_url) {
4936 free((void *)mfx->package_url);
4937 mfx->package_url = NULL;
4939 if (mfx->root_path) {
4940 free((void *)mfx->root_path);
4941 mfx->root_path = NULL;
4943 if (mfx->csc_path) {
4944 free((void *)mfx->csc_path);
4945 mfx->csc_path = NULL;
4947 if (mfx->appsetting) {
4948 free((void *)mfx->appsetting);
4949 mfx->appsetting = NULL;
4951 if (mfx->nodisplay_setting) {
4952 free((void *)mfx->nodisplay_setting);
4953 mfx->nodisplay_setting = NULL;
4955 if (mfx->main_package) {
4956 free((void *)mfx->main_package);
4957 mfx->main_package = NULL;
4962 icon_x *icon = mfx->icon;
4964 while(icon != NULL) {
4966 __ps_free_icon(icon);
4972 label_x *label = mfx->label;
4973 label_x *tmp = NULL;
4974 while(label != NULL) {
4976 __ps_free_label(label);
4982 author_x *author = mfx->author;
4983 author_x *tmp = NULL;
4984 while(author != NULL) {
4986 __ps_free_author(author);
4990 /*Free Description*/
4991 if (mfx->description) {
4992 description_x *description = mfx->description;
4993 description_x *tmp = NULL;
4994 while(description != NULL) {
4995 tmp = description->next;
4996 __ps_free_description(description);
5002 license_x *license = mfx->license;
5003 license_x *tmp = NULL;
5004 while(license != NULL) {
5005 tmp = license->next;
5006 __ps_free_license(license);
5011 if (mfx->privileges) {
5012 privileges_x *privileges = mfx->privileges;
5013 privileges_x *tmp = NULL;
5014 while(privileges != NULL) {
5015 tmp = privileges->next;
5016 __ps_free_privileges(privileges);
5020 /*Free UiApplication*/
5021 if (mfx->uiapplication) {
5022 uiapplication_x *uiapplication = mfx->uiapplication;
5023 uiapplication_x *tmp = NULL;
5024 while(uiapplication != NULL) {
5025 tmp = uiapplication->next;
5026 __ps_free_uiapplication(uiapplication);
5027 uiapplication = tmp;
5030 /*Free ServiceApplication*/
5031 if (mfx->serviceapplication) {
5032 serviceapplication_x *serviceapplication = mfx->serviceapplication;
5033 serviceapplication_x *tmp = NULL;
5034 while(serviceapplication != NULL) {
5035 tmp = serviceapplication->next;
5036 __ps_free_serviceapplication(serviceapplication);
5037 serviceapplication = tmp;
5042 daemon_x *daemon = mfx->daemon;
5043 daemon_x *tmp = NULL;
5044 while(daemon != NULL) {
5046 __ps_free_daemon(daemon);
5052 theme_x *theme = mfx->theme;
5053 theme_x *tmp = NULL;
5054 while(theme != NULL) {
5056 __ps_free_theme(theme);
5062 font_x *font = mfx->font;
5064 while(font != NULL) {
5066 __ps_free_font(font);
5072 ime_x *ime = mfx->ime;
5074 while(ime != NULL) {
5080 /*Free Compatibility*/
5081 if (mfx->compatibility) {
5082 compatibility_x *compatibility = mfx->compatibility;
5083 compatibility_x *tmp = NULL;
5084 while(compatibility != NULL) {
5085 tmp = compatibility->next;
5086 __ps_free_compatibility(compatibility);
5087 compatibility = tmp;
5090 /*Free DeviceProfile*/
5091 if (mfx->deviceprofile) {
5092 deviceprofile_x *deviceprofile = mfx->deviceprofile;
5093 deviceprofile_x *tmp = NULL;
5094 while(deviceprofile != NULL) {
5095 tmp = deviceprofile->next;
5096 __ps_free_deviceprofile(deviceprofile);
5097 deviceprofile = tmp;
5105 API manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest)
5107 _LOGD("parsing start\n");
5108 xmlTextReaderPtr reader;
5109 manifest_x *mfx = NULL;
5111 reader = xmlReaderForFile(manifest, NULL, 0);
5113 mfx = malloc(sizeof(manifest_x));
5115 memset(mfx, '\0', sizeof(manifest_x));
5116 if (__process_manifest(reader, mfx) < 0) {
5117 _LOGD("Parsing Failed\n");
5118 pkgmgr_parser_free_manifest_xml(mfx);
5121 _LOGD("Parsing Success\n");
5123 _LOGD("Memory allocation error\n");
5125 xmlFreeTextReader(reader);
5127 _LOGD("Unable to create xml reader\n");
5132 /* These APIs are intended to call parser directly */
5134 API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
5136 // char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
5137 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5138 _LOGD("parsing manifest for installation: %s\n", manifest);
5140 manifest_x *mfx = NULL;
5144 mfx = pkgmgr_parser_process_manifest_xml(manifest);
5145 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5147 _LOGD("Parsing Finished\n");
5149 // __streamFile(manifest, ACTION_INSTALL, temp, mfx->package);
5150 __ps_process_tag_parser(mfx, manifest, ACTION_INSTALL);
5151 __add_preload_info(mfx, manifest);
5153 _LOGD("Added preload infomation\n");
5155 __ps_process_tag(mfx, tagv);
5157 ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
5158 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
5160 _LOGD("DB Insert Success\n");
5162 ret = __ps_process_metadata_parser(mfx, ACTION_INSTALL);
5164 _LOGD("Creating metadata parser failed\n");
5166 ret = __ps_process_category_parser(mfx, ACTION_INSTALL);
5168 _LOGD("Creating category parser failed\n");
5170 if (__check_action_fota(tagv))
5171 ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_FOTA);
5173 ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_INSTALL);
5176 _LOGD("Creating desktop file failed\n");
5178 _LOGD("Creating desktop file Success\n");
5180 pkgmgr_parser_free_manifest_xml(mfx);
5181 _LOGD("Free Done\n");
5187 API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
5189 // char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
5190 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5191 _LOGD("parsing manifest for upgradation: %s\n", manifest);
5193 manifest_x *mfx = NULL;
5195 bool preload = false;
5196 bool system = false;
5197 char *csc_path = NULL;
5198 pkgmgrinfo_pkginfo_h handle = NULL;
5201 mfx = pkgmgr_parser_process_manifest_xml(manifest);
5202 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5204 _LOGD("Parsing Finished\n");
5206 // __streamFile(manifest, ACTION_UPGRADE, temp, mfx->package);
5207 __ps_process_tag_parser(mfx, manifest, ACTION_UPGRADE);
5208 __add_preload_info(mfx, manifest);
5209 _LOGD("Added preload infomation\n");
5210 __check_preload_updated(mfx, manifest);
5212 ret = pkgmgrinfo_pkginfo_get_pkginfo(mfx->package, &handle);
5213 if (ret != PMINFO_R_OK)
5214 _LOGD("pkgmgrinfo_pkginfo_get_pkginfo failed\n");
5216 ret = pkgmgrinfo_pkginfo_is_preload(handle, &preload);
5217 if (ret != PMINFO_R_OK)
5218 _LOGD("pkgmgrinfo_pkginfo_is_preload failed\n");
5221 free((void *)mfx->preload);
5222 mfx->preload = strdup("true");
5225 ret = pkgmgrinfo_pkginfo_is_system(handle, &system);
5226 if (ret != PMINFO_R_OK)
5227 _LOGD("pkgmgrinfo_pkginfo_is_system failed\n");
5230 free((void *)mfx->system);
5231 mfx->system = strdup("true");
5234 ret = pkgmgrinfo_pkginfo_get_csc_path(handle, &csc_path);
5235 if (ret != PMINFO_R_OK)
5236 _LOGD("pkgmgrinfo_pkginfo_get_csc_path failed\n");
5238 if (csc_path != NULL) {
5240 free((void *)mfx->csc_path);
5241 mfx->csc_path = strdup(csc_path);
5244 ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
5245 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
5246 _LOGD("DB Update Success\n");
5248 ret = __ps_process_metadata_parser(mfx, ACTION_UPGRADE);
5250 _LOGD("Upgrade metadata parser failed\n");
5252 ret = __ps_process_category_parser(mfx, ACTION_UPGRADE);
5254 _LOGD("Creating category parser failed\n");
5256 ret = __ps_make_nativeapp_desktop(mfx, manifest, ACTION_UPGRADE);
5258 _LOGD("Creating desktop file failed\n");
5260 _LOGD("Creating desktop file Success\n");
5262 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
5263 pkgmgr_parser_free_manifest_xml(mfx);
5264 _LOGD("Free Done\n");
5270 API int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[])
5272 // char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
5273 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5274 _LOGD("parsing manifest for uninstallation: %s\n", manifest);
5276 manifest_x *mfx = NULL;
5279 mfx = pkgmgr_parser_process_manifest_xml(manifest);
5280 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5282 _LOGD("Parsing Finished\n");
5284 // __streamFile(manifest, ACTION_UNINSTALL, temp, mfx->package);
5285 __ps_process_tag_parser(mfx, manifest, ACTION_UNINSTALL);
5287 __add_preload_info(mfx, manifest);
5288 _LOGD("Added preload infomation\n");
5290 ret = __ps_process_metadata_parser(mfx, ACTION_UNINSTALL);
5292 _LOGD("Removing metadata parser failed\n");
5294 ret = __ps_process_category_parser(mfx, ACTION_UNINSTALL);
5296 _LOGD("Creating category parser failed\n");
5298 ret = pkgmgr_parser_delete_manifest_info_from_db(mfx);
5300 _LOGD("DB Delete failed\n");
5302 _LOGD("DB Delete Success\n");
5304 ret = __ps_remove_nativeapp_desktop(mfx);
5306 _LOGD("Removing desktop file failed\n");
5308 _LOGD("Removing desktop file Success\n");
5310 ret = __ps_remove_appsvc_db(mfx);
5312 _LOGD("Removing appsvc_db failed\n");
5314 _LOGD("Removing appsvc_db Success\n");
5316 pkgmgr_parser_free_manifest_xml(mfx);
5317 _LOGD("Free Done\n");
5323 API int pkgmgr_parser_parse_manifest_for_preload()
5325 return pkgmgr_parser_update_preload_info_in_db();
5328 API char *pkgmgr_parser_get_manifest_file(const char *pkgid)
5330 return __pkgid_to_manifest(pkgid);
5333 API int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
5335 return __ps_run_parser(docPtr, tag, ACTION_INSTALL, pkgid);
5338 API int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgid)
5340 return __ps_run_parser(docPtr, tag, ACTION_UPGRADE, pkgid);
5343 API int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
5345 return __ps_run_parser(docPtr, tag, ACTION_UNINSTALL, pkgid);
5348 #define SCHEMA_FILE SYSCONFDIR "/package-manager/preload/manifest.xsd"
5350 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
5352 if (manifest == NULL) {
5353 _LOGE("manifest file is NULL\n");
5354 return PMINFO_R_EINVAL;
5357 xmlSchemaParserCtxtPtr ctx;
5358 xmlSchemaValidCtxtPtr vctx;
5359 xmlSchemaPtr xschema;
5360 ctx = xmlSchemaNewParserCtxt(SCHEMA_FILE);
5362 _LOGE("xmlSchemaNewParserCtxt() Failed\n");
5363 return PMINFO_R_ERROR;
5365 xschema = xmlSchemaParse(ctx);
5366 if (xschema == NULL) {
5367 _LOGE("xmlSchemaParse() Failed\n");
5368 return PMINFO_R_ERROR;
5370 vctx = xmlSchemaNewValidCtxt(xschema);
5372 _LOGE("xmlSchemaNewValidCtxt() Failed\n");
5373 return PMINFO_R_ERROR;
5375 xmlSchemaSetValidErrors(vctx, (xmlSchemaValidityErrorFunc) fprintf, (xmlSchemaValidityWarningFunc) fprintf, stderr);
5376 ret = xmlSchemaValidateFile(vctx, manifest, 0);
5378 _LOGE("xmlSchemaValidateFile() failed\n");
5379 return PMINFO_R_ERROR;
5380 } else if (ret == 0) {
5381 _LOGE("Manifest is Valid\n");
5384 _LOGE("Manifest Validation Failed with error code %d\n", ret);
5385 return PMINFO_R_ERROR;
5391 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
5401 _LOGE("fork failed\n");
5406 int dev_null_fd = open ("/dev/null", O_RDWR);
5407 if (dev_null_fd >= 0)
5409 dup2 (dev_null_fd, 0);/*stdin*/
5410 dup2 (dev_null_fd, 1);/*stdout*/
5411 dup2 (dev_null_fd, 2);/*stderr*/
5414 if (execl("/usr/bin/xmllint", "xmllint", manifest, "--schema",
5415 SCHEMA_FILE, NULL) < 0) {
5416 _LOGE("execl error\n");
5426 while ((err = waitpid(pid, &status, WNOHANG)) != pid) {
5430 _LOGE("waitpid failed\n");
5436 if(WIFEXITED(status) && !WEXITSTATUS(status))