4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
7 * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
31 #include <libxml/parser.h>
32 #include <libxml/xmlreader.h>
33 #include <libxml/xmlschemas.h>
38 #include "pkgmgr_parser.h"
39 #include "pkgmgr_parser_internal.h"
40 #include "pkgmgr_parser_db.h"
41 #include "pkgmgr-info.h"
42 #include "pkgmgr_parser_signature.h"
43 #include "pkgmgr-info-debug.h"
44 #include "pkgmgr_parser_plugin.h"
49 #define LOG_TAG "PKGMGR_PARSER"
51 #define MANIFEST_RW_DIRECTORY "/opt/share/packages"
52 #define MANIFEST_RO_DIRECTORY "/usr/share/packages"
53 #define ASCII(s) (const char *)s
54 #define XMLCHAR(s) (const xmlChar *)s
55 #define BUFMAX 1024*128
59 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label);
60 static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege);
61 static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privileges);
62 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile);
63 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed);
64 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation);
65 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri);
66 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime);
67 static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp);
68 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition);
69 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notifiation);
70 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category);
71 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata);
72 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission);
73 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility);
74 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution);
75 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request);
76 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define);
77 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc);
78 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions);
79 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare);
80 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon);
81 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author);
82 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description);
83 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability);
84 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license);
85 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol);
86 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol);
87 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication);
88 static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication);
89 static int __ps_process_font(xmlTextReaderPtr reader, font_x *font);
90 static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme);
91 static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon);
92 static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime);
93 static void __ps_free_label(label_x *label);
94 static void __ps_free_privilege(privilege_x *privilege);
95 static void __ps_free_privileges(privileges_x *privileges);
96 static void __ps_free_deviceprofile(deviceprofile_x * deviceprofile);
97 static void __ps_free_allowed(allowed_x *allowed);
98 static void __ps_free_operation(operation_x *operation);
99 static void __ps_free_uri(uri_x *uri);
100 static void __ps_free_mime(mime_x *mime);
101 static void __ps_free_subapp(subapp_x *subapp);
102 static void __ps_free_condition(condition_x *condition);
103 static void __ps_free_notification(notification_x *notifiation);
104 static void __ps_free_category(category_x *category);
105 static void __ps_free_metadata(metadata_x *metadata);
106 static void __ps_free_permission(permission_x *permission);
107 static void __ps_free_compatibility(compatibility_x *compatibility);
108 static void __ps_free_resolution(resolution_x *resolution);
109 static void __ps_free_request(request_x *request);
110 static void __ps_free_define(define_x *define);
111 static void __ps_free_appsvc(appsvc_x *appsvc);
112 static void __ps_free_launchconditions(launchconditions_x *launchconditions);
113 static void __ps_free_datashare(datashare_x *datashare);
114 static void __ps_free_icon(icon_x *icon);
115 static void __ps_free_author(author_x *author);
116 static void __ps_free_description(description_x *description);
117 static void __ps_free_capability(capability_x *capability);
118 static void __ps_free_license(license_x *license);
119 static void __ps_free_appcontrol(appcontrol_x *appcontrol);
120 static void __ps_free_datacontrol(datacontrol_x *datacontrol);
121 static void __ps_free_uiapplication(uiapplication_x *uiapplication);
122 static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication);
123 static void __ps_free_font(font_x *font);
124 static void __ps_free_theme(theme_x *theme);
125 static void __ps_free_daemon(daemon_x *daemon);
126 static void __ps_free_ime(ime_x *ime);
127 static char *__pkgid_to_manifest(const char *pkgid);
128 static int __next_child_element(xmlTextReaderPtr reader, int depth);
129 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx);
130 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx);
131 static void __str_trim(char *input);
132 static int __validate_appid(const char *pkgid, const char *appid, char **newappid);
134 static void __str_trim(char *input)
136 char *trim_str = input;
141 while (*input != 0) {
142 if (!isspace(*input)) {
153 static int __validate_appid(const char *pkgid, const char *appid, char **newappid)
155 if (!pkgid || !appid || !newappid) {
156 _LOGD("Arg supplied is NULL\n");
159 int pkglen = strlen(pkgid);
160 int applen = strlen(appid);
164 if (strncmp(appid, ".", 1) == 0) {
165 len = pkglen + applen + 1;
166 newapp = calloc(1,len);
167 if (newapp == NULL) {
168 _LOGD("Malloc failed\n");
171 strncpy(newapp, pkgid, pkglen);
172 strncat(newapp, appid, applen);
173 _LOGD("new appid is %s\n", newapp);
177 if (applen < pkglen) {
178 _LOGD("app id is not proper\n");
180 #ifdef _VALIDATE_APPID_
186 if (!strcmp(appid, pkgid)) {
187 _LOGD("appid is proper\n");
191 else if (strncmp(appid, pkgid, pkglen) == 0) {
192 ptr = strstr(appid, pkgid);
194 if (strncmp(ptr, ".", 1) == 0) {
195 _LOGD("appid is proper\n");
200 _LOGD("appid is not proper\n");
202 #ifdef _VALIDATE_APPID_
209 _LOGD("appid is not proper\n");
211 #ifdef _VALIDATE_APPID_
220 static char *__pkgid_to_manifest(const char *pkgid)
226 _LOGE("pkgid is NULL");
230 size = strlen(MANIFEST_RW_DIRECTORY) + strlen(pkgid) + 10;
231 manifest = malloc(size);
232 if (manifest == NULL) {
236 memset(manifest, '\0', size);
237 snprintf(manifest, size, MANIFEST_RW_DIRECTORY "/%s.xml", pkgid);
239 if (access(manifest, F_OK)) {
240 snprintf(manifest, size, MANIFEST_RO_DIRECTORY "/%s.xml", pkgid);
246 static int __next_child_element(xmlTextReaderPtr reader, int depth)
248 int ret = xmlTextReaderRead(reader);
249 int cur = xmlTextReaderDepth(reader);
252 switch (xmlTextReaderNodeType(reader)) {
253 case XML_READER_TYPE_ELEMENT:
254 if (cur == depth + 1)
257 case XML_READER_TYPE_TEXT:
258 /*text is handled by each function separately*/
259 if (cur == depth + 1)
262 case XML_READER_TYPE_END_ELEMENT:
271 ret = xmlTextReaderRead(reader);
272 cur = xmlTextReaderDepth(reader);
277 static bool __check_action_fota(char *const tagv[])
281 char *ret_result = NULL;
288 for (tag = strdup(tagv[0]); tag != NULL; ) {
289 ret_result = strtok(tag, delims);
291 /*check tag : fota is true */
292 if (strcmp(ret_result, "fota") == 0) {
293 ret_result = strtok(NULL, delims);
294 if (strcmp(ret_result, "true") == 0) {
298 _LOGD("tag process [%s]is not defined\n", ret_result);
303 if (tagv[++i] != NULL)
304 tag = strdup(tagv[i]);
306 _LOGD("tag process success...%d\n" , ret);
314 static void __ps_free_category(category_x *category)
316 if (category == NULL)
318 if (category->name) {
319 free((void *)category->name);
320 category->name = NULL;
322 free((void*)category);
326 static void __ps_free_privilege(privilege_x *privilege)
328 if (privilege == NULL)
330 if (privilege->text) {
331 free((void *)privilege->text);
332 privilege->text = NULL;
334 free((void*)privilege);
338 static void __ps_free_privileges(privileges_x *privileges)
340 if (privileges == NULL)
343 if (privileges->privilege) {
344 privilege_x *privilege = privileges->privilege;
345 privilege_x *tmp = NULL;
346 while(privilege != NULL) {
347 tmp = privilege->next;
348 __ps_free_privilege(privilege);
352 free((void*)privileges);
356 static void __ps_free_metadata(metadata_x *metadata)
358 if (metadata == NULL)
361 free((void *)metadata->key);
362 metadata->key = NULL;
364 if (metadata->value) {
365 free((void *)metadata->value);
366 metadata->value = NULL;
368 free((void*)metadata);
372 static void __ps_free_permission(permission_x *permission)
374 if (permission == NULL)
376 if (permission->type) {
377 free((void *)permission->type);
378 permission->type = NULL;
380 if (permission->value) {
381 free((void *)permission->value);
382 permission->value = NULL;
384 free((void*)permission);
388 static void __ps_free_icon(icon_x *icon)
393 free((void *)icon->text);
397 free((void *)icon->lang);
401 free((void *)icon->name);
405 free((void *)icon->section);
406 icon->section = NULL;
409 free((void *)icon->size);
412 if (icon->resolution) {
413 free((void *)icon->resolution);
414 icon->resolution = NULL;
420 static void __ps_free_image(image_x *image)
425 free((void *)image->text);
429 free((void *)image->lang);
433 free((void *)image->name);
436 if (image->section) {
437 free((void *)image->section);
438 image->section = NULL;
444 static void __ps_free_operation(operation_x *operation)
446 if (operation == NULL)
448 if (operation->text) {
449 free((void *)operation->text);
450 operation->text = NULL;
452 free((void*)operation);
456 static void __ps_free_uri(uri_x *uri)
461 free((void *)uri->text);
468 static void __ps_free_mime(mime_x *mime)
473 free((void *)mime->text);
480 static void __ps_free_subapp(subapp_x *subapp)
485 free((void *)subapp->text);
492 static void __ps_free_condition(condition_x *condition)
494 if (condition == NULL)
496 if (condition->text) {
497 free((void *)condition->text);
498 condition->text = NULL;
500 if (condition->name) {
501 free((void *)condition->name);
502 condition->name = NULL;
504 free((void*)condition);
508 static void __ps_free_notification(notification_x *notification)
510 if (notification == NULL)
512 if (notification->text) {
513 free((void *)notification->text);
514 notification->text = NULL;
516 if (notification->name) {
517 free((void *)notification->name);
518 notification->name = NULL;
520 free((void*)notification);
524 static void __ps_free_compatibility(compatibility_x *compatibility)
526 if (compatibility == NULL)
528 if (compatibility->text) {
529 free((void *)compatibility->text);
530 compatibility->text = NULL;
532 if (compatibility->name) {
533 free((void *)compatibility->name);
534 compatibility->name = NULL;
536 free((void*)compatibility);
537 compatibility = NULL;
540 static void __ps_free_resolution(resolution_x *resolution)
542 if (resolution == NULL)
544 if (resolution->mimetype) {
545 free((void *)resolution->mimetype);
546 resolution->mimetype = NULL;
548 if (resolution->urischeme) {
549 free((void *)resolution->urischeme);
550 resolution->urischeme = NULL;
552 free((void*)resolution);
556 static void __ps_free_capability(capability_x *capability)
558 if (capability == NULL)
560 if (capability->operationid) {
561 free((void *)capability->operationid);
562 capability->operationid = NULL;
565 if (capability->resolution) {
566 resolution_x *resolution = capability->resolution;
567 resolution_x *tmp = NULL;
568 while(resolution != NULL) {
569 tmp = resolution->next;
570 __ps_free_resolution(resolution);
574 free((void*)capability);
578 static void __ps_free_allowed(allowed_x *allowed)
583 free((void *)allowed->name);
584 allowed->name = NULL;
587 free((void *)allowed->text);
588 allowed->text = NULL;
590 free((void*)allowed);
594 static void __ps_free_request(request_x *request)
599 free((void *)request->text);
600 request->text = NULL;
602 free((void*)request);
606 static void __ps_free_datacontrol(datacontrol_x *datacontrol)
608 if (datacontrol == NULL)
610 if (datacontrol->providerid) {
611 free((void *)datacontrol->providerid);
612 datacontrol->providerid = NULL;
615 if (datacontrol->capability) {
616 capability_x *capability = datacontrol->capability;
617 capability_x *tmp = NULL;
618 while(capability != NULL) {
619 tmp = capability->next;
620 __ps_free_capability(capability);
624 free((void*)datacontrol);
628 static void __ps_free_launchconditions(launchconditions_x *launchconditions)
630 if (launchconditions == NULL)
632 if (launchconditions->text) {
633 free((void *)launchconditions->text);
634 launchconditions->text = NULL;
637 if (launchconditions->condition) {
638 condition_x *condition = launchconditions->condition;
639 condition_x *tmp = NULL;
640 while(condition != NULL) {
641 tmp = condition->next;
642 __ps_free_condition(condition);
646 free((void*)launchconditions);
647 launchconditions = NULL;
650 static void __ps_free_appcontrol(appcontrol_x *appcontrol)
652 if (appcontrol == NULL)
654 if (appcontrol->text) {
655 free((void *)appcontrol->text);
656 appcontrol->text = NULL;
659 if (appcontrol->operation) {
660 operation_x *operation = appcontrol->operation;
661 operation_x *tmp = NULL;
662 while(operation != NULL) {
663 tmp = operation->next;
664 __ps_free_operation(operation);
669 if (appcontrol->uri) {
670 uri_x *uri = appcontrol->uri;
679 if (appcontrol->mime) {
680 mime_x *mime = appcontrol->mime;
682 while(mime != NULL) {
684 __ps_free_mime(mime);
689 if (appcontrol->subapp) {
690 subapp_x *subapp = appcontrol->subapp;
691 subapp_x *tmp = NULL;
692 while(subapp != NULL) {
694 __ps_free_subapp(subapp);
698 free((void*)appcontrol);
702 static void __ps_free_appsvc(appsvc_x *appsvc)
707 free((void *)appsvc->text);
711 if (appsvc->operation) {
712 operation_x *operation = appsvc->operation;
713 operation_x *tmp = NULL;
714 while(operation != NULL) {
715 tmp = operation->next;
716 __ps_free_operation(operation);
722 uri_x *uri = appsvc->uri;
732 mime_x *mime = appsvc->mime;
734 while(mime != NULL) {
736 __ps_free_mime(mime);
741 if (appsvc->subapp) {
742 subapp_x *subapp = appsvc->subapp;
743 subapp_x *tmp = NULL;
744 while(subapp != NULL) {
746 __ps_free_subapp(subapp);
754 static void __ps_free_deviceprofile(deviceprofile_x *deviceprofile)
759 static void __ps_free_define(define_x *define)
764 free((void *)define->path);
768 if (define->request) {
769 request_x *request = define->request;
770 request_x *tmp = NULL;
771 while(request != NULL) {
773 __ps_free_request(request);
778 if (define->allowed) {
779 allowed_x *allowed = define->allowed;
780 allowed_x *tmp = NULL;
781 while(allowed != NULL) {
783 __ps_free_allowed(allowed);
791 static void __ps_free_datashare(datashare_x *datashare)
793 if (datashare == NULL)
796 if (datashare->define) {
797 define_x *define = datashare->define;
798 define_x *tmp = NULL;
799 while(define != NULL) {
801 __ps_free_define(define);
806 if (datashare->request) {
807 request_x *request = datashare->request;
808 request_x *tmp = NULL;
809 while(request != NULL) {
811 __ps_free_request(request);
815 free((void*)datashare);
819 static void __ps_free_label(label_x *label)
824 free((void *)label->name);
828 free((void *)label->text);
832 free((void *)label->lang);
839 static void __ps_free_author(author_x *author)
844 free((void *)author->email);
845 author->email = NULL;
848 free((void *)author->text);
852 free((void *)author->href);
856 free((void *)author->lang);
863 static void __ps_free_description(description_x *description)
865 if (description == NULL)
867 if (description->name) {
868 free((void *)description->name);
869 description->name = NULL;
871 if (description->text) {
872 free((void *)description->text);
873 description->text = NULL;
875 if (description->lang) {
876 free((void *)description->lang);
877 description->lang = NULL;
879 free((void*)description);
883 static void __ps_free_license(license_x *license)
888 free((void *)license->text);
889 license->text = NULL;
892 free((void *)license->lang);
893 license->lang = NULL;
895 free((void*)license);
899 static void __ps_free_uiapplication(uiapplication_x *uiapplication)
901 if (uiapplication == NULL)
903 if (uiapplication->exec) {
904 free((void *)uiapplication->exec);
905 uiapplication->exec = NULL;
907 if (uiapplication->appid) {
908 free((void *)uiapplication->appid);
909 uiapplication->appid = NULL;
911 if (uiapplication->nodisplay) {
912 free((void *)uiapplication->nodisplay);
913 uiapplication->nodisplay = NULL;
915 if (uiapplication->multiple) {
916 free((void *)uiapplication->multiple);
917 uiapplication->multiple = NULL;
919 if (uiapplication->type) {
920 free((void *)uiapplication->type);
921 uiapplication->type = NULL;
923 if (uiapplication->categories) {
924 free((void *)uiapplication->categories);
925 uiapplication->categories = NULL;
927 if (uiapplication->extraid) {
928 free((void *)uiapplication->extraid);
929 uiapplication->extraid = NULL;
931 if (uiapplication->taskmanage) {
932 free((void *)uiapplication->taskmanage);
933 uiapplication->taskmanage = NULL;
935 if (uiapplication->enabled) {
936 free((void *)uiapplication->enabled);
937 uiapplication->enabled = NULL;
939 if (uiapplication->hwacceleration) {
940 free((void *)uiapplication->hwacceleration);
941 uiapplication->hwacceleration = NULL;
943 if (uiapplication->screenreader) {
944 free((void *)uiapplication->screenreader);
945 uiapplication->screenreader = NULL;
947 if (uiapplication->mainapp) {
948 free((void *)uiapplication->mainapp);
949 uiapplication->mainapp = NULL;
951 if (uiapplication->recentimage) {
952 free((void *)uiapplication->recentimage);
953 uiapplication->recentimage = NULL;
955 if (uiapplication->package) {
956 free((void *)uiapplication->package);
957 uiapplication->package = NULL;
959 if (uiapplication->launchcondition) {
960 free((void *)uiapplication->launchcondition);
961 uiapplication->launchcondition = NULL;
964 if (uiapplication->label) {
965 label_x *label = uiapplication->label;
967 while(label != NULL) {
969 __ps_free_label(label);
974 if (uiapplication->icon) {
975 icon_x *icon = uiapplication->icon;
977 while(icon != NULL) {
979 __ps_free_icon(icon);
984 if (uiapplication->image) {
985 image_x *image = uiapplication->image;
987 while(image != NULL) {
989 __ps_free_image(image);
994 if (uiapplication->appcontrol) {
995 appcontrol_x *appcontrol = uiapplication->appcontrol;
996 appcontrol_x *tmp = NULL;
997 while(appcontrol != NULL) {
998 tmp = appcontrol->next;
999 __ps_free_appcontrol(appcontrol);
1003 /*Free LaunchConditions*/
1004 if (uiapplication->launchconditions) {
1005 launchconditions_x *launchconditions = uiapplication->launchconditions;
1006 launchconditions_x *tmp = NULL;
1007 while(launchconditions != NULL) {
1008 tmp = launchconditions->next;
1009 __ps_free_launchconditions(launchconditions);
1010 launchconditions = tmp;
1013 /*Free Notification*/
1014 if (uiapplication->notification) {
1015 notification_x *notification = uiapplication->notification;
1016 notification_x *tmp = NULL;
1017 while(notification != NULL) {
1018 tmp = notification->next;
1019 __ps_free_notification(notification);
1024 if (uiapplication->datashare) {
1025 datashare_x *datashare = uiapplication->datashare;
1026 datashare_x *tmp = NULL;
1027 while(datashare != NULL) {
1028 tmp = datashare->next;
1029 __ps_free_datashare(datashare);
1034 if (uiapplication->appsvc) {
1035 appsvc_x *appsvc = uiapplication->appsvc;
1036 appsvc_x *tmp = NULL;
1037 while(appsvc != NULL) {
1039 __ps_free_appsvc(appsvc);
1044 if (uiapplication->category) {
1045 category_x *category = uiapplication->category;
1046 category_x *tmp = NULL;
1047 while(category != NULL) {
1048 tmp = category->next;
1049 __ps_free_category(category);
1054 if (uiapplication->metadata) {
1055 metadata_x *metadata = uiapplication->metadata;
1056 metadata_x *tmp = NULL;
1057 while(metadata != NULL) {
1058 tmp = metadata->next;
1059 __ps_free_metadata(metadata);
1064 if (uiapplication->permission) {
1065 permission_x *permission = uiapplication->permission;
1066 permission_x *tmp = NULL;
1067 while(permission != NULL) {
1068 tmp = permission->next;
1069 __ps_free_permission(permission);
1073 /* _PRODUCT_LAUNCHING_ENHANCED_ START */
1074 if (uiapplication->indicatordisplay) {
1075 free((void *)uiapplication->indicatordisplay);
1076 uiapplication->indicatordisplay = NULL;
1078 if (uiapplication->portraitimg) {
1079 free((void *)uiapplication->portraitimg);
1080 uiapplication->portraitimg = NULL;
1082 if (uiapplication->landscapeimg) {
1083 free((void *)uiapplication->landscapeimg);
1084 uiapplication->landscapeimg = NULL;
1086 /* _PRODUCT_LAUNCHING_ENHANCED_ END */
1087 if (uiapplication->guestmode_visibility) {
1088 free((void *)uiapplication->guestmode_visibility);
1089 uiapplication->guestmode_visibility = NULL;
1091 if (uiapplication->app_component) {
1092 free((void *)uiapplication->app_component);
1093 uiapplication->app_component = NULL;
1095 if (uiapplication->permission_type) {
1096 free((void *)uiapplication->permission_type);
1097 uiapplication->permission_type = NULL;
1099 if (uiapplication->component_type) {
1100 free((void *)uiapplication->component_type);
1101 uiapplication->component_type = NULL;
1103 if (uiapplication->preload) {
1104 free((void *)uiapplication->preload);
1105 uiapplication->preload = NULL;
1107 if (uiapplication->submode) {
1108 free((void *)uiapplication->submode);
1109 uiapplication->submode = NULL;
1111 if (uiapplication->submode_mainid) {
1112 free((void *)uiapplication->submode_mainid);
1113 uiapplication->submode_mainid = NULL;
1115 if (uiapplication->installed_storage) {
1116 free((void *)uiapplication->installed_storage);
1117 uiapplication->installed_storage = NULL;
1119 if (uiapplication->process_pool) {
1120 free((void *)uiapplication->process_pool);
1121 uiapplication->process_pool = NULL;
1123 if (uiapplication->autorestart) {
1124 free((void *)uiapplication->autorestart);
1125 uiapplication->autorestart = NULL;
1127 if (uiapplication->onboot) {
1128 free((void *)uiapplication->onboot);
1129 uiapplication->onboot = NULL;
1132 free((void*)uiapplication);
1133 uiapplication = NULL;
1136 static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication)
1138 if (serviceapplication == NULL)
1140 if (serviceapplication->exec) {
1141 free((void *)serviceapplication->exec);
1142 serviceapplication->exec = NULL;
1144 if (serviceapplication->appid) {
1145 free((void *)serviceapplication->appid);
1146 serviceapplication->appid = NULL;
1148 if (serviceapplication->onboot) {
1149 free((void *)serviceapplication->onboot);
1150 serviceapplication->onboot = NULL;
1152 if (serviceapplication->autorestart) {
1153 free((void *)serviceapplication->autorestart);
1154 serviceapplication->autorestart = NULL;
1156 if (serviceapplication->type) {
1157 free((void *)serviceapplication->type);
1158 serviceapplication->type = NULL;
1160 if (serviceapplication->enabled) {
1161 free((void *)serviceapplication->enabled);
1162 serviceapplication->enabled = NULL;
1164 if (serviceapplication->package) {
1165 free((void *)serviceapplication->package);
1166 serviceapplication->package = NULL;
1168 if (serviceapplication->permission_type) {
1169 free((void *)serviceapplication->permission_type);
1170 serviceapplication->permission_type = NULL;
1173 if (serviceapplication->label) {
1174 label_x *label = serviceapplication->label;
1175 label_x *tmp = NULL;
1176 while(label != NULL) {
1178 __ps_free_label(label);
1183 if (serviceapplication->icon) {
1184 icon_x *icon = serviceapplication->icon;
1186 while(icon != NULL) {
1188 __ps_free_icon(icon);
1193 if (serviceapplication->appcontrol) {
1194 appcontrol_x *appcontrol = serviceapplication->appcontrol;
1195 appcontrol_x *tmp = NULL;
1196 while(appcontrol != NULL) {
1197 tmp = appcontrol->next;
1198 __ps_free_appcontrol(appcontrol);
1202 /*Free DataControl*/
1203 if (serviceapplication->datacontrol) {
1204 datacontrol_x *datacontrol = serviceapplication->datacontrol;
1205 datacontrol_x *tmp = NULL;
1206 while(datacontrol != NULL) {
1207 tmp = datacontrol->next;
1208 __ps_free_datacontrol(datacontrol);
1212 /*Free LaunchConditions*/
1213 if (serviceapplication->launchconditions) {
1214 launchconditions_x *launchconditions = serviceapplication->launchconditions;
1215 launchconditions_x *tmp = NULL;
1216 while(launchconditions != NULL) {
1217 tmp = launchconditions->next;
1218 __ps_free_launchconditions(launchconditions);
1219 launchconditions = tmp;
1222 /*Free Notification*/
1223 if (serviceapplication->notification) {
1224 notification_x *notification = serviceapplication->notification;
1225 notification_x *tmp = NULL;
1226 while(notification != NULL) {
1227 tmp = notification->next;
1228 __ps_free_notification(notification);
1233 if (serviceapplication->datashare) {
1234 datashare_x *datashare = serviceapplication->datashare;
1235 datashare_x *tmp = NULL;
1236 while(datashare != NULL) {
1237 tmp = datashare->next;
1238 __ps_free_datashare(datashare);
1243 if (serviceapplication->appsvc) {
1244 appsvc_x *appsvc = serviceapplication->appsvc;
1245 appsvc_x *tmp = NULL;
1246 while(appsvc != NULL) {
1248 __ps_free_appsvc(appsvc);
1253 if (serviceapplication->category) {
1254 category_x *category = serviceapplication->category;
1255 category_x *tmp = NULL;
1256 while(category != NULL) {
1257 tmp = category->next;
1258 __ps_free_category(category);
1263 if (serviceapplication->metadata) {
1264 metadata_x *metadata = serviceapplication->metadata;
1265 metadata_x *tmp = NULL;
1266 while(metadata != NULL) {
1267 tmp = metadata->next;
1268 __ps_free_metadata(metadata);
1273 if (serviceapplication->permission) {
1274 permission_x *permission = serviceapplication->permission;
1275 permission_x *tmp = NULL;
1276 while(permission != NULL) {
1277 tmp = permission->next;
1278 __ps_free_permission(permission);
1282 free((void*)serviceapplication);
1283 serviceapplication = NULL;
1286 static void __ps_free_font(font_x *font)
1291 free((void *)font->name);
1295 free((void *)font->text);
1302 static void __ps_free_theme(theme_x *theme)
1307 free((void *)theme->name);
1311 free((void *)theme->text);
1318 static void __ps_free_daemon(daemon_x *daemon)
1323 free((void *)daemon->name);
1324 daemon->name = NULL;
1327 free((void *)daemon->text);
1328 daemon->text = NULL;
1330 free((void*)daemon);
1334 static void __ps_free_ime(ime_x *ime)
1339 free((void *)ime->name);
1343 free((void *)ime->text);
1350 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed)
1352 xmlTextReaderRead(reader);
1353 if (xmlTextReaderValue(reader))
1354 allowed->text = ASCII(xmlTextReaderValue(reader));
1358 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation)
1360 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1361 operation->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1362 /* Text does not exist. Only attribute exists
1363 xmlTextReaderRead(reader);
1364 if (xmlTextReaderValue(reader))
1365 operation->text = ASCII(xmlTextReaderValue(reader));
1370 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri)
1372 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1373 uri->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1374 /* Text does not exist. Only attribute exists
1375 xmlTextReaderRead(reader);
1376 if (xmlTextReaderValue(reader))
1377 uri->text = ASCII(xmlTextReaderValue(reader));
1382 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime)
1384 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1385 mime->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1386 /* Text does not exist. Only attribute exists
1387 xmlTextReaderRead(reader);
1388 if (xmlTextReaderValue(reader))
1389 mime->text = ASCII(xmlTextReaderValue(reader));
1394 static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp)
1396 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1397 subapp->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1398 /* Text does not exist. Only attribute exists
1399 xmlTextReaderRead(reader);
1400 if (xmlTextReaderValue(reader))
1401 mime->text = ASCII(xmlTextReaderValue(reader));
1406 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition)
1408 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1409 condition->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1410 xmlTextReaderRead(reader);
1411 if (xmlTextReaderValue(reader))
1412 condition->text = ASCII(xmlTextReaderValue(reader));
1416 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notification)
1418 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1419 notification->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1420 xmlTextReaderRead(reader);
1421 if (xmlTextReaderValue(reader))
1422 notification->text = ASCII(xmlTextReaderValue(reader));
1426 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category)
1428 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1429 category->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1433 static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege)
1435 xmlTextReaderRead(reader);
1436 if (xmlTextReaderValue(reader)) {
1437 privilege->text = ASCII(xmlTextReaderValue(reader));
1442 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata)
1444 if (xmlTextReaderGetAttribute(reader, XMLCHAR("key")))
1445 metadata->key = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("key")));
1446 if (xmlTextReaderGetAttribute(reader, XMLCHAR("value")))
1447 metadata->value = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("value")));
1451 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission)
1453 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
1454 permission->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
1456 xmlTextReaderRead(reader);
1457 if (xmlTextReaderValue(reader))
1458 permission->value = ASCII(xmlTextReaderValue(reader));
1462 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility)
1464 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1465 compatibility->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1466 xmlTextReaderRead(reader);
1467 if (xmlTextReaderValue(reader))
1468 compatibility->text = ASCII(xmlTextReaderValue(reader));
1472 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution)
1474 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")))
1475 resolution->mimetype = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")));
1476 if (xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")))
1477 resolution->urischeme = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")));
1481 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request)
1483 xmlTextReaderRead(reader);
1484 if (xmlTextReaderValue(reader))
1485 request->text = ASCII(xmlTextReaderValue(reader));
1489 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define)
1491 const xmlChar *node;
1494 allowed_x *tmp1 = NULL;
1495 request_x *tmp2 = NULL;
1497 if (xmlTextReaderGetAttribute(reader, XMLCHAR("path")))
1498 define->path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("path")));
1500 depth = xmlTextReaderDepth(reader);
1501 while ((ret = __next_child_element(reader, depth))) {
1502 node = xmlTextReaderConstName(reader);
1504 _LOGD("xmlTextReaderConstName value is NULL\n");
1508 if (!strcmp(ASCII(node), "allowed")) {
1509 allowed_x *allowed= malloc(sizeof(allowed_x));
1510 if (allowed == NULL) {
1511 _LOGD("Malloc Failed\n");
1514 memset(allowed, '\0', sizeof(allowed_x));
1515 LISTADD(define->allowed, allowed);
1516 ret = __ps_process_allowed(reader, allowed);
1517 } else if (!strcmp(ASCII(node), "request")) {
1518 request_x *request = malloc(sizeof(request_x));
1519 if (request == NULL) {
1520 _LOGD("Malloc Failed\n");
1523 memset(request, '\0', sizeof(request_x));
1524 LISTADD(define->request, request);
1525 ret = __ps_process_request(reader, request);
1529 _LOGD("Processing define failed\n");
1533 if (define->allowed) {
1534 LISTHEAD(define->allowed, tmp1);
1535 define->allowed = tmp1;
1537 if (define->request) {
1538 LISTHEAD(define->request, tmp2);
1539 define->request = tmp2;
1544 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol)
1546 const xmlChar *node;
1549 operation_x *tmp1 = NULL;
1551 mime_x *tmp3 = NULL;
1552 subapp_x *tmp4 = NULL;
1554 depth = xmlTextReaderDepth(reader);
1555 while ((ret = __next_child_element(reader, depth))) {
1556 node = xmlTextReaderConstName(reader);
1558 _LOGD("xmlTextReaderConstName value is NULL\n");
1562 if (!strcmp(ASCII(node), "operation")) {
1563 operation_x *operation = malloc(sizeof(operation_x));
1564 if (operation == NULL) {
1565 _LOGD("Malloc Failed\n");
1568 memset(operation, '\0', sizeof(operation_x));
1569 LISTADD(appcontrol->operation, operation);
1570 ret = __ps_process_operation(reader, operation);
1571 _LOGD("operation processing\n");
1572 } else if (!strcmp(ASCII(node), "uri")) {
1573 uri_x *uri= malloc(sizeof(uri_x));
1575 _LOGD("Malloc Failed\n");
1578 memset(uri, '\0', sizeof(uri_x));
1579 LISTADD(appcontrol->uri, uri);
1580 ret = __ps_process_uri(reader, uri);
1581 _LOGD("uri processing\n");
1582 } else if (!strcmp(ASCII(node), "mime")) {
1583 mime_x *mime = malloc(sizeof(mime_x));
1585 _LOGD("Malloc Failed\n");
1588 memset(mime, '\0', sizeof(mime_x));
1589 LISTADD(appcontrol->mime, mime);
1590 ret = __ps_process_mime(reader, mime);
1591 _LOGD("mime processing\n");
1592 } else if (!strcmp(ASCII(node), "subapp")) {
1593 subapp_x *subapp = malloc(sizeof(subapp_x));
1594 if (subapp == NULL) {
1595 _LOGD("Malloc Failed\n");
1598 memset(subapp, '\0', sizeof(subapp_x));
1599 LISTADD(appcontrol->subapp, subapp);
1600 ret = __ps_process_subapp(reader, subapp);
1601 _LOGD("subapp processing\n");
1605 _LOGD("Processing appcontrol failed\n");
1609 if (appcontrol->operation) {
1610 LISTHEAD(appcontrol->operation, tmp1);
1611 appcontrol->operation = tmp1;
1613 if (appcontrol->uri) {
1614 LISTHEAD(appcontrol->uri, tmp2);
1615 appcontrol->uri = tmp2;
1617 if (appcontrol->mime) {
1618 LISTHEAD(appcontrol->mime, tmp3);
1619 appcontrol->mime = tmp3;
1621 if (appcontrol->subapp) {
1622 LISTHEAD(appcontrol->subapp, tmp4);
1623 appcontrol->subapp = tmp4;
1626 xmlTextReaderRead(reader);
1627 if (xmlTextReaderValue(reader))
1628 appcontrol->text = ASCII(xmlTextReaderValue(reader));
1633 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc)
1635 const xmlChar *node;
1638 operation_x *tmp1 = NULL;
1640 mime_x *tmp3 = NULL;
1641 subapp_x *tmp4 = NULL;
1643 depth = xmlTextReaderDepth(reader);
1644 while ((ret = __next_child_element(reader, depth))) {
1645 node = xmlTextReaderConstName(reader);
1647 _LOGD("xmlTextReaderConstName value is NULL\n");
1651 if (!strcmp(ASCII(node), "operation")) {
1652 operation_x *operation = malloc(sizeof(operation_x));
1653 if (operation == NULL) {
1654 _LOGD("Malloc Failed\n");
1657 memset(operation, '\0', sizeof(operation_x));
1658 LISTADD(appsvc->operation, operation);
1659 ret = __ps_process_operation(reader, operation);
1660 _LOGD("operation processing\n");
1661 } else if (!strcmp(ASCII(node), "uri")) {
1662 uri_x *uri= malloc(sizeof(uri_x));
1664 _LOGD("Malloc Failed\n");
1667 memset(uri, '\0', sizeof(uri_x));
1668 LISTADD(appsvc->uri, uri);
1669 ret = __ps_process_uri(reader, uri);
1670 _LOGD("uri processing\n");
1671 } else if (!strcmp(ASCII(node), "mime")) {
1672 mime_x *mime = malloc(sizeof(mime_x));
1674 _LOGD("Malloc Failed\n");
1677 memset(mime, '\0', sizeof(mime_x));
1678 LISTADD(appsvc->mime, mime);
1679 ret = __ps_process_mime(reader, mime);
1680 _LOGD("mime processing\n");
1681 } else if (!strcmp(ASCII(node), "subapp")) {
1682 subapp_x *subapp = malloc(sizeof(subapp_x));
1683 if (subapp == NULL) {
1684 _LOGD("Malloc Failed\n");
1687 memset(subapp, '\0', sizeof(subapp_x));
1688 LISTADD(appsvc->subapp, subapp);
1689 ret = __ps_process_subapp(reader, subapp);
1690 _LOGD("subapp processing\n");
1694 _LOGD("Processing appsvc failed\n");
1698 if (appsvc->operation) {
1699 LISTHEAD(appsvc->operation, tmp1);
1700 appsvc->operation = tmp1;
1703 LISTHEAD(appsvc->uri, tmp2);
1707 LISTHEAD(appsvc->mime, tmp3);
1708 appsvc->mime = tmp3;
1710 if (appsvc->subapp) {
1711 LISTHEAD(appsvc->subapp, tmp4);
1712 appsvc->subapp = tmp4;
1715 xmlTextReaderRead(reader);
1716 if (xmlTextReaderValue(reader))
1717 appsvc->text = ASCII(xmlTextReaderValue(reader));
1723 static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privileges)
1725 const xmlChar *node;
1728 privilege_x *tmp1 = NULL;
1730 depth = xmlTextReaderDepth(reader);
1731 while ((ret = __next_child_element(reader, depth))) {
1732 node = xmlTextReaderConstName(reader);
1734 _LOGD("xmlTextReaderConstName value is NULL\n");
1738 if (strcmp(ASCII(node), "privilege") == 0) {
1739 privilege_x *privilege = malloc(sizeof(privilege_x));
1740 if (privilege == NULL) {
1741 _LOGD("Malloc Failed\n");
1744 memset(privilege, '\0', sizeof(privilege_x));
1745 LISTADD(privileges->privilege, privilege);
1746 ret = __ps_process_privilege(reader, privilege);
1750 _LOGD("Processing privileges failed\n");
1754 if (privileges->privilege) {
1755 LISTHEAD(privileges->privilege, tmp1);
1756 privileges->privilege = tmp1;
1761 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions)
1763 const xmlChar *node;
1766 condition_x *tmp1 = NULL;
1768 depth = xmlTextReaderDepth(reader);
1769 while ((ret = __next_child_element(reader, depth))) {
1770 node = xmlTextReaderConstName(reader);
1772 _LOGD("xmlTextReaderConstName value is NULL\n");
1776 if (strcmp(ASCII(node), "condition") == 0) {
1777 condition_x *condition = malloc(sizeof(condition_x));
1778 if (condition == NULL) {
1779 _LOGD("Malloc Failed\n");
1782 memset(condition, '\0', sizeof(condition_x));
1783 LISTADD(launchconditions->condition, condition);
1784 ret = __ps_process_condition(reader, condition);
1788 _LOGD("Processing launchconditions failed\n");
1792 if (launchconditions->condition) {
1793 LISTHEAD(launchconditions->condition, tmp1);
1794 launchconditions->condition = tmp1;
1797 xmlTextReaderRead(reader);
1798 if (xmlTextReaderValue(reader))
1799 launchconditions->text = ASCII(xmlTextReaderValue(reader));
1804 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare)
1806 const xmlChar *node;
1809 define_x *tmp1 = NULL;
1810 request_x *tmp2 = NULL;
1811 depth = xmlTextReaderDepth(reader);
1812 while ((ret = __next_child_element(reader, depth))) {
1813 node = xmlTextReaderConstName(reader);
1815 _LOGD("xmlTextReaderConstName value is NULL\n");
1819 if (!strcmp(ASCII(node), "define")) {
1820 define_x *define= malloc(sizeof(define_x));
1821 if (define == NULL) {
1822 _LOGD("Malloc Failed\n");
1825 memset(define, '\0', sizeof(define_x));
1826 LISTADD(datashare->define, define);
1827 ret = __ps_process_define(reader, define);
1828 } else if (!strcmp(ASCII(node), "request")) {
1829 request_x *request= malloc(sizeof(request_x));
1830 if (request == NULL) {
1831 _LOGD("Malloc Failed\n");
1834 memset(request, '\0', sizeof(request_x));
1835 LISTADD(datashare->request, request);
1836 ret = __ps_process_request(reader, request);
1840 _LOGD("Processing data-share failed\n");
1844 if (datashare->define) {
1845 LISTHEAD(datashare->define, tmp1);
1846 datashare->define = tmp1;
1848 if (datashare->request) {
1849 LISTHEAD(datashare->request, tmp2);
1850 datashare->request = tmp2;
1856 __get_icon_with_path(const char* icon)
1861 if (index(icon, '/') == NULL) {
1863 char* icon_with_path = NULL;
1869 /* "db/setting/theme" is not exist */
1871 theme = vconf_get_str("db/setting/theme");
1873 theme = strdup("default");
1879 theme = strdup("default");
1882 len = (0x01 << 7) + strlen(icon) + strlen(package) + strlen(theme);
1883 icon_with_path = malloc(len);
1884 if(icon_with_path == NULL) {
1885 _LOGD("(icon_with_path == NULL) return\n");
1890 memset(icon_with_path, 0, len);
1891 snprintf(icon_with_path, len, "/opt/usr/apps/%s/shared/res/icons/default/small/%s", package, icon);
1893 if (access(icon_with_path, R_OK) == 0) break;
1894 snprintf(icon_with_path, len, "/opt/share/icons/%s/small/%s", theme, icon);
1895 if (access(icon_with_path, R_OK) == 0) break;
1896 snprintf(icon_with_path, len, "/usr/share/icons/%s/small/%s", theme, icon);
1897 if (access(icon_with_path, R_OK) == 0) break;
1898 _LOGD("cannot find icon %s", icon_with_path);
1899 snprintf(icon_with_path, len,"/opt/share/icons/default/small/%s", icon);
1900 if (access(icon_with_path, R_OK) == 0) break;
1901 snprintf(icon_with_path, len, "/usr/share/icons/default/small/%s", icon);
1902 if (access(icon_with_path, R_OK) == 0) break;
1904 /* icon path is going to be moved intto the app directory */
1905 snprintf(icon_with_path, len, "/usr/apps/%s/shared/res/icons/default/small/%s", package, icon);
1906 if (access(icon_with_path, R_OK) == 0) break;
1907 snprintf(icon_with_path, len, "/opt/apps/%s/res/icons/%s/small/%s", package, theme, icon);
1908 if (access(icon_with_path, R_OK) == 0) break;
1909 snprintf(icon_with_path, len, "/usr/apps/%s/res/icons/%s/small/%s", package, theme, icon);
1910 if (access(icon_with_path, R_OK) == 0) break;
1911 _LOGD("cannot find icon %s", icon_with_path);
1912 snprintf(icon_with_path, len, "/opt/apps/%s/res/icons/default/small/%s", package, icon);
1913 if (access(icon_with_path, R_OK) == 0) break;
1914 snprintf(icon_with_path, len, "/usr/apps/%s/res/icons/default/small/%s", package, icon);
1915 if (access(icon_with_path, R_OK) == 0) break;
1916 snprintf(icon_with_path, len, "/usr/ug/res/images/%s/%s", package, icon);
1917 if (access(icon_with_path, R_OK) == 0) break;
1922 _LOGD("Icon path : %s ---> %s", icon, icon_with_path);
1924 return icon_with_path;
1926 char* confirmed_icon = NULL;
1928 confirmed_icon = strdup(icon);
1929 if (!confirmed_icon)
1931 return confirmed_icon;
1935 static void __ps_process_tag(manifest_x * mfx, char *const tagv[])
1938 char delims[] = "=";
1939 char *ret_result = NULL;
1945 for (tag = strdup(tagv[0]); tag != NULL; ) {
1946 ret_result = strtok(tag, delims);
1948 /*check tag : preload */
1949 if (strcmp(ret_result, "preload") == 0) {
1950 ret_result = strtok(NULL, delims);
1951 if (strcmp(ret_result, "true") == 0) {
1952 free((void *)mfx->preload);
1953 mfx->preload = strdup("true");
1954 } else if (strcmp(ret_result, "false") == 0) {
1955 free((void *)mfx->preload);
1956 mfx->preload = strdup("false");
1958 /*check tag : removable*/
1959 } else if (strcmp(ret_result, "removable") == 0) {
1960 ret_result = strtok(NULL, delims);
1961 if (strcmp(ret_result, "true") == 0){
1962 free((void *)mfx->removable);
1963 mfx->removable = strdup("true");
1964 } else if (strcmp(ret_result, "false") == 0) {
1965 free((void *)mfx->removable);
1966 mfx->removable = strdup("false");
1968 /*check tag : not matched*/
1970 _LOGD("tag process [%s]is not defined\n", ret_result);
1974 /*check next value*/
1975 if (tagv[++i] != NULL)
1976 tag = strdup(tagv[i]);
1978 /*update tag : system*/
1979 if ((strcmp(mfx->preload,"true")==0) && (strcmp(mfx->removable,"false")==0)){
1980 free((void *)mfx->system);
1981 mfx->system = strdup("true");
1983 _LOGD("tag process success...\n");
1989 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon)
1991 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1992 icon->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1993 if (xmlTextReaderConstXmlLang(reader)) {
1994 icon->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
1995 if (icon->lang == NULL)
1996 icon->lang = strdup(DEFAULT_LOCALE);
1998 icon->lang = strdup(DEFAULT_LOCALE);
2000 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
2001 icon->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
2002 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
2003 icon->size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
2004 if (xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")))
2005 icon->resolution = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")));
2006 xmlTextReaderRead(reader);
2007 if (xmlTextReaderValue(reader)) {
2008 const char *text = ASCII(xmlTextReaderValue(reader));
2010 icon->text = (const char *)__get_icon_with_path(text);
2018 static int __ps_process_image(xmlTextReaderPtr reader, image_x *image)
2020 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2021 image->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2022 if (xmlTextReaderConstXmlLang(reader)) {
2023 image->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2024 if (image->lang == NULL)
2025 image->lang = strdup(DEFAULT_LOCALE);
2027 image->lang = strdup(DEFAULT_LOCALE);
2029 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
2030 image->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
2031 xmlTextReaderRead(reader);
2032 if (xmlTextReaderValue(reader))
2033 image->text = ASCII(xmlTextReaderValue(reader));
2038 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label)
2040 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2041 label->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2042 if (xmlTextReaderConstXmlLang(reader)) {
2043 label->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2044 if (label->lang == NULL)
2045 label->lang = strdup(DEFAULT_LOCALE);
2047 label->lang = strdup(DEFAULT_LOCALE);
2049 xmlTextReaderRead(reader);
2050 if (xmlTextReaderValue(reader))
2051 label->text = ASCII(xmlTextReaderValue(reader));
2053 /* _LOGD("lable name %s\n", label->name);
2054 _LOGD("lable lang %s\n", label->lang);
2055 _LOGD("lable text %s\n", label->text);
2061 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author)
2063 if (xmlTextReaderGetAttribute(reader, XMLCHAR("email")))
2064 author->email = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("email")));
2065 if (xmlTextReaderGetAttribute(reader, XMLCHAR("href")))
2066 author->href = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("href")));
2067 if (xmlTextReaderConstXmlLang(reader)) {
2068 author->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2069 if (author->lang == NULL)
2070 author->lang = strdup(DEFAULT_LOCALE);
2072 author->lang = strdup(DEFAULT_LOCALE);
2074 xmlTextReaderRead(reader);
2075 if (xmlTextReaderValue(reader)) {
2076 const char *text = ASCII(xmlTextReaderValue(reader));
2077 if (*text == '\n') {
2078 author->text = NULL;
2082 author->text = ASCII(xmlTextReaderValue(reader));
2087 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description)
2089 if (xmlTextReaderConstXmlLang(reader)) {
2090 description->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2091 if (description->lang == NULL)
2092 description->lang = strdup(DEFAULT_LOCALE);
2094 description->lang = strdup(DEFAULT_LOCALE);
2096 xmlTextReaderRead(reader);
2097 if (xmlTextReaderValue(reader)) {
2098 const char *text = ASCII(xmlTextReaderValue(reader));
2099 if (*text == '\n') {
2100 description->text = NULL;
2104 description->text = ASCII(xmlTextReaderValue(reader));
2109 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license)
2111 if (xmlTextReaderConstXmlLang(reader)) {
2112 license->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2113 if (license->lang == NULL)
2114 license->lang = strdup(DEFAULT_LOCALE);
2116 license->lang = strdup(DEFAULT_LOCALE);
2118 xmlTextReaderRead(reader);
2119 if (xmlTextReaderValue(reader))
2120 license->text = ASCII(xmlTextReaderValue(reader));
2124 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability)
2126 const xmlChar *node;
2129 resolution_x *tmp1 = NULL;
2131 if (xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")))
2132 capability->operationid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")));
2134 depth = xmlTextReaderDepth(reader);
2135 while ((ret = __next_child_element(reader, depth))) {
2136 node = xmlTextReaderConstName(reader);
2138 _LOGD("xmlTextReaderConstName value is NULL\n");
2142 if (!strcmp(ASCII(node), "resolution")) {
2143 resolution_x *resolution = malloc(sizeof(resolution_x));
2144 if (resolution == NULL) {
2145 _LOGD("Malloc Failed\n");
2148 memset(resolution, '\0', sizeof(resolution_x));
2149 LISTADD(capability->resolution, resolution);
2150 ret = __ps_process_resolution(reader, resolution);
2154 _LOGD("Processing capability failed\n");
2159 if (capability->resolution) {
2160 LISTHEAD(capability->resolution, tmp1);
2161 capability->resolution = tmp1;
2167 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol)
2169 const xmlChar *node;
2172 capability_x *tmp1 = NULL;
2174 if (xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")))
2175 datacontrol->providerid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")));
2177 depth = xmlTextReaderDepth(reader);
2178 while ((ret = __next_child_element(reader, depth))) {
2179 node = xmlTextReaderConstName(reader);
2181 _LOGD("xmlTextReaderConstName value is NULL\n");
2185 if (!strcmp(ASCII(node), "capability")) {
2186 capability_x *capability = malloc(sizeof(capability_x));
2187 if (capability == NULL) {
2188 _LOGD("Malloc Failed\n");
2191 memset(capability, '\0', sizeof(capability_x));
2192 LISTADD(datacontrol->capability, capability);
2193 ret = __ps_process_capability(reader, capability);
2197 _LOGD("Processing datacontrol failed\n");
2202 if (datacontrol->capability) {
2203 LISTHEAD(datacontrol->capability, tmp1);
2204 datacontrol->capability = tmp1;
2210 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication)
2212 const xmlChar *node;
2215 char *newappid = NULL;
2216 label_x *tmp1 = NULL;
2217 icon_x *tmp2 = NULL;
2218 appsvc_x *tmp3 = NULL;
2219 appcontrol_x *tmp4 = NULL;
2220 launchconditions_x *tmp5 = NULL;
2221 notification_x *tmp6 = NULL;
2222 datashare_x *tmp7 = NULL;
2223 category_x *tmp8 = NULL;
2224 metadata_x *tmp9 = NULL;
2225 image_x *tmp10 = NULL;
2226 permission_x *tmp11 = NULL;
2228 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
2229 uiapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
2230 if (uiapplication->appid == NULL) {
2231 _LOGD("appid cant be NULL\n");
2235 _LOGD("appid is mandatory\n");
2239 ret = __validate_appid(package, uiapplication->appid, &newappid);
2241 _LOGD("appid is not proper\n");
2245 if (uiapplication->appid)
2246 free((void *)uiapplication->appid);
2247 uiapplication->appid = newappid;
2249 uiapplication->package= strdup(package);
2251 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
2252 uiapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
2253 if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay"))) {
2254 uiapplication->nodisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay")));
2255 if (uiapplication->nodisplay == NULL)
2256 uiapplication->nodisplay = strdup("false");
2258 uiapplication->nodisplay = strdup("false");
2260 if (xmlTextReaderGetAttribute(reader, XMLCHAR("multiple"))) {
2261 uiapplication->multiple = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("multiple")));
2262 if (uiapplication->multiple == NULL)
2263 uiapplication->multiple = strdup("false");
2265 uiapplication->multiple = strdup("false");
2267 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
2268 uiapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
2269 if (xmlTextReaderGetAttribute(reader, XMLCHAR("categories")))
2270 uiapplication->categories = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("categories")));
2271 if (xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")))
2272 uiapplication->extraid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")));
2273 if (xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage"))) {
2274 uiapplication->taskmanage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage")));
2275 if (uiapplication->taskmanage == NULL)
2276 uiapplication->taskmanage = strdup("true");
2278 uiapplication->taskmanage = strdup("true");
2280 if (xmlTextReaderGetAttribute(reader, XMLCHAR("enabled"))) {
2281 uiapplication->enabled = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("enabled")));
2282 if (uiapplication->enabled == NULL)
2283 uiapplication->enabled = strdup("true");
2285 uiapplication->enabled = strdup("true");
2287 if (xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration"))) {
2288 uiapplication->hwacceleration = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration")));
2289 if (uiapplication->hwacceleration == NULL)
2290 uiapplication->hwacceleration = strdup("use-system-setting");
2292 uiapplication->hwacceleration = strdup("use-system-setting");
2294 if (xmlTextReaderGetAttribute(reader, XMLCHAR("screen-reader"))) {
2295 uiapplication->screenreader = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("screen-reader")));
2296 if (uiapplication->screenreader == NULL)
2297 uiapplication->screenreader = strdup("use-system-setting");
2299 uiapplication->screenreader = strdup("use-system-setting");
2301 if (xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")))
2302 uiapplication->recentimage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")));
2303 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp"))) {
2304 uiapplication->mainapp = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp")));
2305 if (uiapplication->mainapp == NULL)
2306 uiapplication->mainapp = strdup("false");
2308 uiapplication->mainapp = strdup("false");
2310 if (xmlTextReaderGetAttribute(reader, XMLCHAR("launchcondition"))) {
2311 uiapplication->launchcondition = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("launchcondition")));
2312 if (uiapplication->launchcondition == NULL)
2313 uiapplication->launchcondition = strdup("false");
2315 uiapplication->launchcondition = strdup("false");
2318 if (xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay"))) {
2319 uiapplication->indicatordisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay")));
2320 if (uiapplication->indicatordisplay == NULL)
2321 uiapplication->indicatordisplay = strdup("true");
2323 uiapplication->indicatordisplay = strdup("true");
2325 if (xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")))
2326 uiapplication->portraitimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")));
2328 uiapplication->portraitimg = NULL;
2329 if (xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")))
2330 uiapplication->landscapeimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")));
2332 uiapplication->landscapeimg = NULL;
2333 if (xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility"))) {
2334 uiapplication->guestmode_visibility = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility")));
2335 if (uiapplication->guestmode_visibility == NULL)
2336 uiapplication->guestmode_visibility = strdup("true");
2338 uiapplication->guestmode_visibility = strdup("true");
2340 if (xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type"))) {
2341 uiapplication->permission_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type")));
2342 if (uiapplication->permission_type == NULL)
2343 uiapplication->permission_type = strdup("normal");
2345 uiapplication->permission_type = strdup("normal");
2347 if (xmlTextReaderGetAttribute(reader, XMLCHAR("component-type"))) {
2348 uiapplication->component_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("component-type")));
2349 if (uiapplication->component_type == NULL) {
2350 uiapplication->component_type = strdup("uiapp");
2352 /*component_type has "svcapp" or "uiapp", if it is not, parsing manifest is fail*/
2353 if (strcmp(uiapplication->component_type, "svcapp") != 0) {
2354 if (strcmp(uiapplication->component_type, "uiapp") != 0) {
2355 _LOGD("invalid component_type[%s]\n", uiapplication->component_type);
2361 uiapplication->component_type = strdup("uiapp");
2363 if (xmlTextReaderGetAttribute(reader, XMLCHAR("submode"))) {
2364 uiapplication->submode = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("submode")));
2365 if (uiapplication->submode == NULL)
2366 uiapplication->submode = strdup("false");
2368 uiapplication->submode = strdup("false");
2370 if (xmlTextReaderGetAttribute(reader, XMLCHAR("submode-mainid")))
2371 uiapplication->submode_mainid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("submode-mainid")));
2372 if (xmlTextReaderGetAttribute(reader, XMLCHAR("process-pool"))) {
2373 uiapplication->process_pool= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("process-pool")));
2374 if (uiapplication->process_pool == NULL)
2375 uiapplication->process_pool = strdup("false");
2377 uiapplication->process_pool = strdup("false");
2379 if (xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart"))) {
2380 uiapplication->autorestart= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart")));
2381 if (uiapplication->autorestart == NULL)
2382 uiapplication->autorestart = strdup("false");
2384 uiapplication->autorestart = strdup("false");
2386 if (xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot"))) {
2387 uiapplication->onboot= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot")));
2388 if (uiapplication->onboot == NULL)
2389 uiapplication->onboot = strdup("false");
2391 uiapplication->onboot = strdup("false");
2394 depth = xmlTextReaderDepth(reader);
2395 while ((ret = __next_child_element(reader, depth))) {
2396 node = xmlTextReaderConstName(reader);
2398 _LOGD("xmlTextReaderConstName value is NULL\n");
2401 if (!strcmp(ASCII(node), "label")) {
2402 label_x *label = malloc(sizeof(label_x));
2403 if (label == NULL) {
2404 _LOGD("Malloc Failed\n");
2407 memset(label, '\0', sizeof(label_x));
2408 LISTADD(uiapplication->label, label);
2409 ret = __ps_process_label(reader, label);
2410 } else if (!strcmp(ASCII(node), "icon")) {
2411 icon_x *icon = malloc(sizeof(icon_x));
2413 _LOGD("Malloc Failed\n");
2416 memset(icon, '\0', sizeof(icon_x));
2417 LISTADD(uiapplication->icon, icon);
2418 ret = __ps_process_icon(reader, icon);
2419 } else if (!strcmp(ASCII(node), "image")) {
2420 image_x *image = malloc(sizeof(image_x));
2421 if (image == NULL) {
2422 _LOGD("Malloc Failed\n");
2425 memset(image, '\0', sizeof(image_x));
2426 LISTADD(uiapplication->image, image);
2427 ret = __ps_process_image(reader, image);
2428 } else if (!strcmp(ASCII(node), "category")) {
2429 category_x *category = malloc(sizeof(category_x));
2430 if (category == NULL) {
2431 _LOGD("Malloc Failed\n");
2434 memset(category, '\0', sizeof(category_x));
2435 LISTADD(uiapplication->category, category);
2436 ret = __ps_process_category(reader, category);
2437 } else if (!strcmp(ASCII(node), "metadata")) {
2438 metadata_x *metadata = malloc(sizeof(metadata_x));
2439 if (metadata == NULL) {
2440 _LOGD("Malloc Failed\n");
2443 memset(metadata, '\0', sizeof(metadata_x));
2444 LISTADD(uiapplication->metadata, metadata);
2445 ret = __ps_process_metadata(reader, metadata);
2446 } else if (!strcmp(ASCII(node), "permission")) {
2447 permission_x *permission = malloc(sizeof(permission_x));
2448 if (permission == NULL) {
2449 _LOGD("Malloc Failed\n");
2452 memset(permission, '\0', sizeof(permission_x));
2453 LISTADD(uiapplication->permission, permission);
2454 ret = __ps_process_permission(reader, permission);
2455 } else if (!strcmp(ASCII(node), "app-control")) {
2456 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
2457 if (appcontrol == NULL) {
2458 _LOGD("Malloc Failed\n");
2461 memset(appcontrol, '\0', sizeof(appcontrol_x));
2462 LISTADD(uiapplication->appcontrol, appcontrol);
2463 ret = __ps_process_appcontrol(reader, appcontrol);
2464 } else if (!strcmp(ASCII(node), "application-service")) {
2465 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
2466 if (appsvc == NULL) {
2467 _LOGD("Malloc Failed\n");
2470 memset(appsvc, '\0', sizeof(appsvc_x));
2471 LISTADD(uiapplication->appsvc, appsvc);
2472 ret = __ps_process_appsvc(reader, appsvc);
2473 } else if (!strcmp(ASCII(node), "data-share")) {
2474 datashare_x *datashare = malloc(sizeof(datashare_x));
2475 if (datashare == NULL) {
2476 _LOGD("Malloc Failed\n");
2479 memset(datashare, '\0', sizeof(datashare_x));
2480 LISTADD(uiapplication->datashare, datashare);
2481 ret = __ps_process_datashare(reader, datashare);
2482 } else if (!strcmp(ASCII(node), "launch-conditions")) {
2483 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
2484 if (launchconditions == NULL) {
2485 _LOGD("Malloc Failed\n");
2488 memset(launchconditions, '\0', sizeof(launchconditions_x));
2489 LISTADD(uiapplication->launchconditions, launchconditions);
2490 ret = __ps_process_launchconditions(reader, launchconditions);
2491 } else if (!strcmp(ASCII(node), "notification")) {
2492 notification_x *notification = malloc(sizeof(notification_x));
2493 if (notification == NULL) {
2494 _LOGD("Malloc Failed\n");
2497 memset(notification, '\0', sizeof(notification_x));
2498 LISTADD(uiapplication->notification, notification);
2499 ret = __ps_process_notification(reader, notification);
2503 _LOGD("Processing uiapplication failed\n");
2508 if (uiapplication->label) {
2509 LISTHEAD(uiapplication->label, tmp1);
2510 uiapplication->label = tmp1;
2512 if (uiapplication->icon) {
2513 LISTHEAD(uiapplication->icon, tmp2);
2514 uiapplication->icon = tmp2;
2516 if (uiapplication->appsvc) {
2517 LISTHEAD(uiapplication->appsvc, tmp3);
2518 uiapplication->appsvc = tmp3;
2520 if (uiapplication->appcontrol) {
2521 LISTHEAD(uiapplication->appcontrol, tmp4);
2522 uiapplication->appcontrol = tmp4;
2524 if (uiapplication->launchconditions) {
2525 LISTHEAD(uiapplication->launchconditions, tmp5);
2526 uiapplication->launchconditions = tmp5;
2528 if (uiapplication->notification) {
2529 LISTHEAD(uiapplication->notification, tmp6);
2530 uiapplication->notification = tmp6;
2532 if (uiapplication->datashare) {
2533 LISTHEAD(uiapplication->datashare, tmp7);
2534 uiapplication->datashare = tmp7;
2536 if (uiapplication->category) {
2537 LISTHEAD(uiapplication->category, tmp8);
2538 uiapplication->category = tmp8;
2540 if (uiapplication->metadata) {
2541 LISTHEAD(uiapplication->metadata, tmp9);
2542 uiapplication->metadata = tmp9;
2544 if (uiapplication->image) {
2545 LISTHEAD(uiapplication->image, tmp10);
2546 uiapplication->image = tmp10;
2548 if (uiapplication->permission) {
2549 LISTHEAD(uiapplication->permission, tmp11);
2550 uiapplication->permission = tmp11;
2556 static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication)
2558 const xmlChar *node;
2561 char *newappid = NULL;
2562 label_x *tmp1 = NULL;
2563 icon_x *tmp2 = NULL;
2564 appsvc_x *tmp3 = NULL;
2565 appcontrol_x *tmp4 = NULL;
2566 datacontrol_x *tmp5 = NULL;
2567 launchconditions_x *tmp6 = NULL;
2568 notification_x *tmp7 = NULL;
2569 datashare_x *tmp8 = NULL;
2570 category_x *tmp9 = NULL;
2571 metadata_x *tmp10 = NULL;
2572 permission_x *tmp11 = NULL;
2574 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
2575 serviceapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
2576 if (serviceapplication->appid == NULL) {
2577 _LOGD("appid cant be NULL\n");
2581 _LOGD("appid is mandatory\n");
2585 ret = __validate_appid(package, serviceapplication->appid, &newappid);
2587 _LOGD("appid is not proper\n");
2591 if (serviceapplication->appid)
2592 free((void *)serviceapplication->appid);
2593 serviceapplication->appid = newappid;
2596 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
2597 serviceapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
2598 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
2599 serviceapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
2600 if (xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot"))) {
2601 serviceapplication->onboot = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot")));
2602 if (serviceapplication->onboot == NULL)
2603 serviceapplication->onboot = strdup("false");
2605 serviceapplication->onboot = strdup("false");
2607 if (xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart"))) {
2608 serviceapplication->autorestart = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart")));
2609 if (serviceapplication->autorestart == NULL)
2610 serviceapplication->autorestart = strdup("false");
2612 serviceapplication->autorestart = strdup("false");
2614 if (xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type"))) {
2615 serviceapplication->permission_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type")));
2616 if (serviceapplication->permission_type == NULL)
2617 serviceapplication->permission_type = strdup("normal");
2619 serviceapplication->permission_type = strdup("normal");
2622 depth = xmlTextReaderDepth(reader);
2623 while ((ret = __next_child_element(reader, depth))) {
2624 node = xmlTextReaderConstName(reader);
2626 _LOGD("xmlTextReaderConstName value is NULL\n");
2630 if (!strcmp(ASCII(node), "label")) {
2631 label_x *label = malloc(sizeof(label_x));
2632 if (label == NULL) {
2633 _LOGD("Malloc Failed\n");
2636 memset(label, '\0', sizeof(label_x));
2637 LISTADD(serviceapplication->label, label);
2638 ret = __ps_process_label(reader, label);
2639 } else if (!strcmp(ASCII(node), "icon")) {
2640 icon_x *icon = malloc(sizeof(icon_x));
2642 _LOGD("Malloc Failed\n");
2645 memset(icon, '\0', sizeof(icon_x));
2646 LISTADD(serviceapplication->icon, icon);
2647 ret = __ps_process_icon(reader, icon);
2648 } else if (!strcmp(ASCII(node), "category")) {
2649 category_x *category = malloc(sizeof(category_x));
2650 if (category == NULL) {
2651 _LOGD("Malloc Failed\n");
2654 memset(category, '\0', sizeof(category_x));
2655 LISTADD(serviceapplication->category, category);
2656 ret = __ps_process_category(reader, category);
2657 } else if (!strcmp(ASCII(node), "metadata")) {
2658 metadata_x *metadata = malloc(sizeof(metadata_x));
2659 if (metadata == NULL) {
2660 _LOGD("Malloc Failed\n");
2663 memset(metadata, '\0', sizeof(metadata_x));
2664 LISTADD(serviceapplication->metadata, metadata);
2665 ret = __ps_process_metadata(reader, metadata);
2666 } else if (!strcmp(ASCII(node), "permission")) {
2667 permission_x *permission = malloc(sizeof(permission_x));
2668 if (permission == NULL) {
2669 _LOGD("Malloc Failed\n");
2672 memset(permission, '\0', sizeof(permission_x));
2673 LISTADD(serviceapplication->permission, permission);
2674 ret = __ps_process_permission(reader, permission);
2675 } else if (!strcmp(ASCII(node), "app-control")) {
2676 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
2677 if (appcontrol == NULL) {
2678 _LOGD("Malloc Failed\n");
2681 memset(appcontrol, '\0', sizeof(appcontrol_x));
2682 LISTADD(serviceapplication->appcontrol, appcontrol);
2683 ret = __ps_process_appcontrol(reader, appcontrol);
2684 } else if (!strcmp(ASCII(node), "application-service")) {
2685 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
2686 if (appsvc == NULL) {
2687 _LOGD("Malloc Failed\n");
2690 memset(appsvc, '\0', sizeof(appsvc_x));
2691 LISTADD(serviceapplication->appsvc, appsvc);
2692 ret = __ps_process_appsvc(reader, appsvc);
2693 } else if (!strcmp(ASCII(node), "data-share")) {
2694 datashare_x *datashare = malloc(sizeof(datashare_x));
2695 if (datashare == NULL) {
2696 _LOGD("Malloc Failed\n");
2699 memset(datashare, '\0', sizeof(datashare_x));
2700 LISTADD(serviceapplication->datashare, datashare);
2701 ret = __ps_process_datashare(reader, datashare);
2702 } else if (!strcmp(ASCII(node), "launch-conditions")) {
2703 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
2704 if (launchconditions == NULL) {
2705 _LOGD("Malloc Failed\n");
2708 memset(launchconditions, '\0', sizeof(launchconditions_x));
2709 LISTADD(serviceapplication->launchconditions, launchconditions);
2710 ret = __ps_process_launchconditions(reader, launchconditions);
2711 } else if (!strcmp(ASCII(node), "notification")) {
2712 notification_x *notification = malloc(sizeof(notification_x));
2713 if (notification == NULL) {
2714 _LOGD("Malloc Failed\n");
2717 memset(notification, '\0', sizeof(notification_x));
2718 LISTADD(serviceapplication->notification, notification);
2719 ret = __ps_process_notification(reader, notification);
2720 } else if (!strcmp(ASCII(node), "data-control")) {
2721 datacontrol_x *datacontrol = malloc(sizeof(datacontrol_x));
2722 if (datacontrol == NULL) {
2723 _LOGD("Malloc Failed\n");
2726 memset(datacontrol, '\0', sizeof(datacontrol_x));
2727 LISTADD(serviceapplication->datacontrol, datacontrol);
2728 ret = __ps_process_datacontrol(reader, datacontrol);
2732 _LOGD("Processing serviceapplication failed\n");
2737 if (serviceapplication->label) {
2738 LISTHEAD(serviceapplication->label, tmp1);
2739 serviceapplication->label = tmp1;
2741 if (serviceapplication->icon) {
2742 LISTHEAD(serviceapplication->icon, tmp2);
2743 serviceapplication->icon = tmp2;
2745 if (serviceapplication->appsvc) {
2746 LISTHEAD(serviceapplication->appsvc, tmp3);
2747 serviceapplication->appsvc = tmp3;
2749 if (serviceapplication->appcontrol) {
2750 LISTHEAD(serviceapplication->appcontrol, tmp4);
2751 serviceapplication->appcontrol = tmp4;
2753 if (serviceapplication->datacontrol) {
2754 LISTHEAD(serviceapplication->datacontrol, tmp5);
2755 serviceapplication->datacontrol = tmp5;
2757 if (serviceapplication->launchconditions) {
2758 LISTHEAD(serviceapplication->launchconditions, tmp6);
2759 serviceapplication->launchconditions = tmp6;
2761 if (serviceapplication->notification) {
2762 LISTHEAD(serviceapplication->notification, tmp7);
2763 serviceapplication->notification = tmp7;
2765 if (serviceapplication->datashare) {
2766 LISTHEAD(serviceapplication->datashare, tmp8);
2767 serviceapplication->datashare = tmp8;
2769 if (serviceapplication->category) {
2770 LISTHEAD(serviceapplication->category, tmp9);
2771 serviceapplication->category = tmp9;
2773 if (serviceapplication->metadata) {
2774 LISTHEAD(serviceapplication->metadata, tmp10);
2775 serviceapplication->metadata = tmp10;
2777 if (serviceapplication->permission) {
2778 LISTHEAD(serviceapplication->permission, tmp11);
2779 serviceapplication->permission = tmp11;
2785 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile)
2787 /*TODO: once policy is set*/
2791 static int __ps_process_font(xmlTextReaderPtr reader, font_x *font)
2793 /*TODO: once policy is set*/
2797 static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme)
2799 /*TODO: once policy is set*/
2803 static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon)
2805 /*TODO: once policy is set*/
2809 static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime)
2811 /*TODO: once policy is set*/
2815 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx)
2817 _LOGD("__start_process\n");
2818 const xmlChar *node;
2821 label_x *tmp1 = NULL;
2822 author_x *tmp2 = NULL;
2823 description_x *tmp3 = NULL;
2824 license_x *tmp4 = NULL;
2825 uiapplication_x *tmp5 = NULL;
2826 serviceapplication_x *tmp6 = NULL;
2827 daemon_x *tmp7 = NULL;
2828 theme_x *tmp8 = NULL;
2829 font_x *tmp9 = NULL;
2830 ime_x *tmp10 = NULL;
2831 icon_x *tmp11 = NULL;
2832 compatibility_x *tmp12 = NULL;
2833 deviceprofile_x *tmp13 = NULL;
2834 privileges_x *tmp14 = NULL;
2836 depth = xmlTextReaderDepth(reader);
2837 while ((ret = __next_child_element(reader, depth))) {
2838 node = xmlTextReaderConstName(reader);
2840 _LOGD("xmlTextReaderConstName value is NULL\n");
2844 if (!strcmp(ASCII(node), "label")) {
2845 label_x *label = malloc(sizeof(label_x));
2846 if (label == NULL) {
2847 _LOGD("Malloc Failed\n");
2850 memset(label, '\0', sizeof(label_x));
2851 LISTADD(mfx->label, label);
2852 ret = __ps_process_label(reader, label);
2853 } else if (!strcmp(ASCII(node), "author")) {
2854 author_x *author = malloc(sizeof(author_x));
2855 if (author == NULL) {
2856 _LOGD("Malloc Failed\n");
2859 memset(author, '\0', sizeof(author_x));
2860 LISTADD(mfx->author, author);
2861 ret = __ps_process_author(reader, author);
2862 } else if (!strcmp(ASCII(node), "description")) {
2863 description_x *description = malloc(sizeof(description_x));
2864 if (description == NULL) {
2865 _LOGD("Malloc Failed\n");
2868 memset(description, '\0', sizeof(description_x));
2869 LISTADD(mfx->description, description);
2870 ret = __ps_process_description(reader, description);
2871 } else if (!strcmp(ASCII(node), "license")) {
2872 license_x *license = malloc(sizeof(license_x));
2873 if (license == NULL) {
2874 _LOGD("Malloc Failed\n");
2877 memset(license, '\0', sizeof(license_x));
2878 LISTADD(mfx->license, license);
2879 ret = __ps_process_license(reader, license);
2880 } else if (!strcmp(ASCII(node), "privileges")) {
2881 privileges_x *privileges = malloc(sizeof(privileges_x));
2882 if (privileges == NULL) {
2883 _LOGD("Malloc Failed\n");
2886 memset(privileges, '\0', sizeof(privileges_x));
2887 LISTADD(mfx->privileges, privileges);
2888 ret = __ps_process_privileges(reader, privileges);
2889 } else if (!strcmp(ASCII(node), "ui-application")) {
2890 uiapplication_x *uiapplication = malloc(sizeof(uiapplication_x));
2891 if (uiapplication == NULL) {
2892 _LOGD("Malloc Failed\n");
2895 memset(uiapplication, '\0', sizeof(uiapplication_x));
2896 LISTADD(mfx->uiapplication, uiapplication);
2897 ret = __ps_process_uiapplication(reader, uiapplication);
2898 } else if (!strcmp(ASCII(node), "service-application")) {
2899 serviceapplication_x *serviceapplication = malloc(sizeof(serviceapplication_x));
2900 if (serviceapplication == NULL) {
2901 _LOGD("Malloc Failed\n");
2904 memset(serviceapplication, '\0', sizeof(serviceapplication_x));
2905 LISTADD(mfx->serviceapplication, serviceapplication);
2906 ret = __ps_process_serviceapplication(reader, serviceapplication);
2907 } else if (!strcmp(ASCII(node), "daemon")) {
2908 daemon_x *daemon = malloc(sizeof(daemon_x));
2909 if (daemon == NULL) {
2910 _LOGD("Malloc Failed\n");
2913 memset(daemon, '\0', sizeof(daemon_x));
2914 LISTADD(mfx->daemon, daemon);
2915 ret = __ps_process_daemon(reader, daemon);
2916 } else if (!strcmp(ASCII(node), "theme")) {
2917 theme_x *theme = malloc(sizeof(theme_x));
2918 if (theme == NULL) {
2919 _LOGD("Malloc Failed\n");
2922 memset(theme, '\0', sizeof(theme_x));
2923 LISTADD(mfx->theme, theme);
2924 ret = __ps_process_theme(reader, theme);
2925 } else if (!strcmp(ASCII(node), "font")) {
2926 font_x *font = malloc(sizeof(font_x));
2928 _LOGD("Malloc Failed\n");
2931 memset(font, '\0', sizeof(font_x));
2932 LISTADD(mfx->font, font);
2933 ret = __ps_process_font(reader, font);
2934 } else if (!strcmp(ASCII(node), "ime")) {
2935 ime_x *ime = malloc(sizeof(ime_x));
2937 _LOGD("Malloc Failed\n");
2940 memset(ime, '\0', sizeof(ime_x));
2941 LISTADD(mfx->ime, ime);
2942 ret = __ps_process_ime(reader, ime);
2943 } else if (!strcmp(ASCII(node), "icon")) {
2944 icon_x *icon = malloc(sizeof(icon_x));
2946 _LOGD("Malloc Failed\n");
2949 memset(icon, '\0', sizeof(icon_x));
2950 LISTADD(mfx->icon, icon);
2951 ret = __ps_process_icon(reader, icon);
2952 } else if (!strcmp(ASCII(node), "device-profile")) {
2953 deviceprofile_x *deviceprofile = malloc(sizeof(deviceprofile_x));
2954 if (deviceprofile == NULL) {
2955 _LOGD("Malloc Failed\n");
2958 memset(deviceprofile, '\0', sizeof(deviceprofile_x));
2959 LISTADD(mfx->deviceprofile, deviceprofile);
2960 ret = __ps_process_deviceprofile(reader, deviceprofile);
2961 } else if (!strcmp(ASCII(node), "compatibility")) {
2962 compatibility_x *compatibility = malloc(sizeof(compatibility_x));
2963 if (compatibility == NULL) {
2964 _LOGD("Malloc Failed\n");
2967 memset(compatibility, '\0', sizeof(compatibility_x));
2968 LISTADD(mfx->compatibility, compatibility);
2969 ret = __ps_process_compatibility(reader, compatibility);
2970 } else if (!strcmp(ASCII(node), "shortcut-list")) {
2972 } else if (!strcmp(ASCII(node), "livebox")) {
2974 } else if (!strcmp(ASCII(node), "account")) {
2976 } else if (!strcmp(ASCII(node), "notifications")) {
2978 } else if (!strcmp(ASCII(node), "ime")) {
2984 _LOGD("Processing manifest failed\n");
2989 LISTHEAD(mfx->label, tmp1);
2993 LISTHEAD(mfx->author, tmp2);
2996 if (mfx->description) {
2997 LISTHEAD(mfx->description, tmp3);
2998 mfx->description= tmp3;
3001 LISTHEAD(mfx->license, tmp4);
3004 if (mfx->uiapplication) {
3005 LISTHEAD(mfx->uiapplication, tmp5);
3006 mfx->uiapplication = tmp5;
3008 if (mfx->serviceapplication) {
3009 LISTHEAD(mfx->serviceapplication, tmp6);
3010 mfx->serviceapplication = tmp6;
3013 LISTHEAD(mfx->daemon, tmp7);
3017 LISTHEAD(mfx->theme, tmp8);
3021 LISTHEAD(mfx->font, tmp9);
3025 LISTHEAD(mfx->ime, tmp10);
3029 LISTHEAD(mfx->icon, tmp11);
3032 if (mfx->compatibility) {
3033 LISTHEAD(mfx->compatibility, tmp12);
3034 mfx->compatibility= tmp12;
3036 if (mfx->deviceprofile) {
3037 LISTHEAD(mfx->deviceprofile, tmp13);
3038 mfx->deviceprofile= tmp13;
3040 if (mfx->privileges) {
3041 LISTHEAD(mfx->privileges, tmp14);
3042 mfx->privileges = tmp14;
3047 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx)
3049 const xmlChar *node;
3052 if ((ret = __next_child_element(reader, -1))) {
3053 node = xmlTextReaderConstName(reader);
3055 _LOGD("xmlTextReaderConstName value is NULL\n");
3059 if (!strcmp(ASCII(node), "manifest")) {
3060 if (xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")))
3061 mfx->ns = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")));
3062 if (xmlTextReaderGetAttribute(reader, XMLCHAR("package"))) {
3063 mfx->package= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("package")));
3064 if (mfx->package == NULL) {
3065 _LOGD("package cant be NULL\n");
3069 _LOGD("package field is mandatory\n");
3072 package = mfx->package;
3073 if (xmlTextReaderGetAttribute(reader, XMLCHAR("version")))
3074 mfx->version= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("version")));
3075 /*app2ext needs package size for external installation*/
3076 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
3077 mfx->package_size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
3078 if (xmlTextReaderGetAttribute(reader, XMLCHAR("install-location"))) {
3079 mfx->installlocation = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")));
3080 if (mfx->installlocation == NULL)
3081 mfx->installlocation = strdup("internal-only");
3083 mfx->installlocation = strdup("internal-only");
3085 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
3086 mfx->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
3087 if (xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")))
3088 mfx->root_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")));
3089 if (xmlTextReaderGetAttribute(reader, XMLCHAR("csc_path")))
3090 mfx->csc_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("csc_path")));
3091 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting"))) {
3092 mfx->appsetting = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting")));
3093 if (mfx->appsetting == NULL)
3094 mfx->appsetting = strdup("false");
3096 mfx->appsetting = strdup("false");
3098 if (xmlTextReaderGetAttribute(reader, XMLCHAR("storeclient-id")))
3099 mfx->storeclient_id= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("storeclient-id")));
3100 if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay-setting"))) {
3101 mfx->nodisplay_setting = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay-setting")));
3102 if (mfx->nodisplay_setting == NULL)
3103 mfx->nodisplay_setting = strdup("false");
3105 mfx->nodisplay_setting = strdup("false");
3107 if (xmlTextReaderGetAttribute(reader, XMLCHAR("url")))
3108 mfx->package_url= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("url")));
3110 /*Assign default values. If required it will be overwritten in __add_preload_info()*/
3111 mfx->preload = strdup("False");
3112 mfx->removable = strdup("True");
3113 mfx->readonly = strdup("False");
3114 mfx->update = strdup("False");
3115 mfx->system = strdup("False");
3116 char buf[PKG_STRING_LEN_MAX] = {'\0'};
3118 time_t current_time;
3119 time(¤t_time);
3120 snprintf(buf, PKG_STRING_LEN_MAX - 1, "%d", (int)current_time);
3121 val = strndup(buf, PKG_STRING_LEN_MAX - 1);
3122 mfx->installed_time = val;
3124 mfx->installed_storage= strdup("installed_internal");
3126 ret = __start_process(reader, mfx);
3128 _LOGD("No Manifest element found\n");
3136 static char* __convert_to_system_locale(const char *mlocale)
3138 if (mlocale == NULL)
3140 char *locale = NULL;
3141 locale = (char *)calloc(1, 6);
3143 _LOGE("Malloc Failed\n");
3147 strncpy(locale, mlocale, 2);
3148 strncat(locale, "_", 1);
3149 locale[3] = toupper(mlocale[3]);
3150 locale[4] = toupper(mlocale[4]);
3154 static int __ail_change_info(int op, const char *appid)
3156 void *lib_handle = NULL;
3157 int (*ail_desktop_operation) (const char *);
3161 if ((lib_handle = dlopen(LIBAIL_PATH, RTLD_LAZY)) == NULL) {
3162 _LOGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAIL_PATH);
3169 aop = "ail_desktop_add";
3172 aop = "ail_desktop_update";
3175 aop = "ail_desktop_remove";
3178 aop = "ail_desktop_clean";
3181 aop = "ail_desktop_fota";
3188 if ((ail_desktop_operation =
3189 dlsym(lib_handle, aop)) == NULL || dlerror() != NULL) {
3190 _LOGE("can not find symbol \n");
3194 ret = ail_desktop_operation(appid);
3198 dlclose(lib_handle);
3204 /* desktop shoud be generated automatically based on manifest */
3205 /* Currently removable, taskmanage, etc fields are not considerd. it will be decided soon.*/
3206 static int __ps_make_nativeapp_desktop(manifest_x * mfx, const char *manifest, ACTION_TYPE action)
3210 char filepath[PKG_STRING_LEN_MAX] = "";
3212 char *buftemp = NULL;
3213 char *locale = NULL;
3215 buf = (char *)calloc(1, BUFMAX);
3217 _LOGE("Malloc Failed\n");
3221 buftemp = (char *)calloc(1, BUFMAX);
3223 _LOGE("Malloc Failed\n");
3228 if (action == ACTION_UPGRADE)
3229 __ail_change_info(AIL_CLEAN, mfx->package);
3231 for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) {
3233 if (manifest != NULL) {
3234 /* skip making a deskfile and update ail, if preload app is updated */
3235 if(strstr(manifest, MANIFEST_RO_PREFIX)) {
3236 __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid);
3237 _LOGE("preload app is update : skip and update ail : %s", manifest);
3242 if(mfx->readonly && !strcasecmp(mfx->readonly, "True"))
3243 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RO_PATH, mfx->uiapplication->appid);
3245 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, mfx->uiapplication->appid);
3247 /* skip if desktop exists
3248 if (access(filepath, R_OK) == 0)
3252 file = fopen(filepath, "w");
3255 _LOGS("Can't open %s", filepath);
3261 snprintf(buf, BUFMAX, "[Desktop Entry]\n");
3262 fwrite(buf, 1, strlen(buf), file);
3264 for( ; mfx->uiapplication->label ; mfx->uiapplication->label = mfx->uiapplication->label->next) {
3265 if(!strcmp(mfx->uiapplication->label->lang, DEFAULT_LOCALE)) {
3266 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
3268 locale = __convert_to_system_locale(mfx->uiapplication->label->lang);
3269 snprintf(buf, BUFMAX, "Name[%s]=%s\n", locale,
3270 mfx->uiapplication->label->text);
3273 fwrite(buf, 1, strlen(buf), file);
3276 if(mfx->uiapplication->label && mfx->uiapplication->label->text) {
3277 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
3278 fwrite(buf, 1, strlen(buf), file);
3281 else if(mfx->label && mfx->label->text) {
3282 snprintf(buf, BUFMAX, "Name=%s\n", mfx->label->text);
3283 fwrite(buf, 1, strlen(buf), file);
3285 snprintf(buf, BUFMAX, "Name=%s\n", mfx->package);
3286 fwrite(buf, 1, strlen(buf), file);
3291 snprintf(buf, BUFMAX, "Type=Application\n");
3292 fwrite(buf, 1, strlen(buf), file);
3294 if(mfx->uiapplication->exec) {
3295 snprintf(buf, BUFMAX, "Exec=%s\n", mfx->uiapplication->exec);
3296 fwrite(buf, 1, strlen(buf), file);
3299 if(mfx->uiapplication->icon && mfx->uiapplication->icon->text) {
3300 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->uiapplication->icon->text);
3301 fwrite(buf, 1, strlen(buf), file);
3302 } else if(mfx->icon && mfx->icon->text) {
3303 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->icon->text);
3304 fwrite(buf, 1, strlen(buf), file);
3308 if(mfx->uiapplication && mfx->uiapplication->appsvc) {
3309 appsvc_x *asvc = mfx->uiapplication->appsvc;
3311 const char *mime = NULL;
3312 const char *mime_delim = "; ";
3315 strncpy(buf, "MimeType=", BUFMAX-1);
3321 _LOGD("MIME type: %s\n", mime);
3322 strncat(buf, mime, BUFMAX-strlen(buf)-1);
3324 strncat(buf, mime_delim, BUFMAX-strlen(buf)-1);
3332 _LOGD("MIME types: buf[%s]\n", buf);
3333 _LOGD("MIME count: %d\n", mime_count);
3335 fwrite(buf, 1, strlen(buf), file);
3339 snprintf(buf, BUFMAX, "Version=%s\n", mfx->version);
3340 fwrite(buf, 1, strlen(buf), file);
3343 if(mfx->uiapplication->nodisplay) {
3344 snprintf(buf, BUFMAX, "NoDisplay=%s\n", mfx->uiapplication->nodisplay);
3345 fwrite(buf, 1, strlen(buf), file);
3348 if(mfx->uiapplication->categories) {
3349 snprintf(buf, BUFMAX, "Categories=%s\n", mfx->uiapplication->categories);
3350 fwrite(buf, 1, strlen(buf), file);
3353 if(mfx->uiapplication->taskmanage && !strcasecmp(mfx->uiapplication->taskmanage, "False")) {
3354 snprintf(buf, BUFMAX, "X-TIZEN-TaskManage=False\n");
3355 fwrite(buf, 1, strlen(buf), file);
3358 if(mfx->uiapplication->enabled && !strcasecmp(mfx->uiapplication->enabled, "False")) {
3359 snprintf(buf, BUFMAX, "X-TIZEN-Enabled=False\n");
3360 fwrite(buf, 1, strlen(buf), file);
3363 if(mfx->uiapplication->hwacceleration) {
3364 snprintf(buf, BUFMAX, "Hw-Acceleration=%s\n", mfx->uiapplication->hwacceleration);
3365 fwrite(buf, 1, strlen(buf), file);
3368 if(mfx->uiapplication->multiple && !strcasecmp(mfx->uiapplication->multiple, "True")) {
3369 snprintf(buf, BUFMAX, "X-TIZEN-Multiple=True\n");
3370 fwrite(buf, 1, strlen(buf), file);
3373 if(mfx->uiapplication->extraid) {
3374 snprintf(buf, BUFMAX, "X-TIZEN-PackageID=%s\n", mfx->uiapplication->extraid);
3375 fwrite(buf, 1, strlen(buf), file);
3378 if(mfx->removable && !strcasecmp(mfx->removable, "False")) {
3379 snprintf(buf, BUFMAX, "X-TIZEN-Removable=False\n");
3380 fwrite(buf, 1, strlen(buf), file);
3384 snprintf(buf, BUFMAX, "X-TIZEN-PackageType=%s\n", mfx->type);
3385 fwrite(buf, 1, strlen(buf), file);
3388 if(mfx->uiapplication->submode && !strcasecmp(mfx->uiapplication->submode, "True")) {
3389 snprintf(buf, BUFMAX, "X-TIZEN-Submode=%s\n", mfx->uiapplication->submode);
3390 fwrite(buf, 1, strlen(buf), file);
3391 snprintf(buf, BUFMAX, "X-TIZEN-SubmodeMainid=%s\n", mfx->uiapplication->submode_mainid);
3392 fwrite(buf, 1, strlen(buf), file);
3395 snprintf(buf, BUFMAX, "X-TIZEN-PkgID=%s\n", mfx->package);
3396 fwrite(buf, 1, strlen(buf), file);
3399 snprintf(buf, BUFMAX, "X-TIZEN-InstalledStorage=%s\n", mfx->installed_storage);
3400 fwrite(buf, 1, strlen(buf), file);
3402 // snprintf(buf, BUFMAX, "X-TIZEN-PackageType=rpm\n");
3403 // fwrite(buf, 1, strlen(buf), file);
3406 if(mfx->uiapplication->appsvc) {
3407 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
3408 _LOGD("buf[%s]\n", buf);
3411 uiapplication_x *up = mfx->uiapplication;
3412 appsvc_x *asvc = NULL;
3413 operation_x *op = NULL;
3416 subapp_x *sub = NULL;
3417 const char *operation = NULL;
3418 const char *mime = NULL;
3419 const char *uri = NULL;
3420 const char *subapp = NULL;
3425 while(asvc != NULL) {
3426 op = asvc->operation;
3429 operation = op->name;
3448 strncpy(buftemp, buf, BUFMAX);
3449 snprintf(buf, BUFMAX, "%s;", buftemp);
3453 strncpy(buftemp, buf, BUFMAX);
3454 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
3455 _LOGD("buf[%s]\n", buf);
3460 } while(ui != NULL);
3464 }while(sub != NULL);
3477 fwrite(buf, 1, strlen(buf), file);
3479 // strncpy(buftemp, buf, BUFMAX);
3480 // snprintf(buf, BUFMAX, "%s\n", buftemp);
3481 // fwrite(buf, 1, strlen(buf), file);
3484 if(mfx->uiapplication->appcontrol) {
3485 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
3486 _LOGD("buf[%s]\n", buf);
3488 uiapplication_x *up = mfx->uiapplication;
3489 appcontrol_x *acontrol = NULL;
3490 operation_x *op = NULL;
3493 subapp_x *sub = NULL;
3494 const char *operation = NULL;
3495 const char *mime = NULL;
3496 const char *uri = NULL;
3497 const char *subapp = NULL;
3500 acontrol = up->appcontrol;
3501 while(acontrol != NULL) {
3502 op = acontrol->operation;
3505 operation = op->name;
3506 mi = acontrol->mime;
3512 sub = acontrol->subapp;
3524 strncpy(buftemp, buf, BUFMAX);
3525 snprintf(buf, BUFMAX, "%s;", buftemp);
3528 strncpy(buftemp, buf, BUFMAX);
3529 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
3530 _LOGD("buf[%s]\n", buf);
3535 } while(ui != NULL);
3539 }while(sub != NULL);
3548 acontrol = acontrol->next;
3552 fwrite(buf, 1, strlen(buf), file);
3554 // strncpy(buftemp, buf, BUFMAX);
3555 // snprintf(buf, BUFMAX, "%s\n", buftemp);
3556 // fwrite(buf, 1, strlen(buf), file);
3563 if (action == ACTION_FOTA)
3564 __ail_change_info(AIL_FOTA, mfx->uiapplication->appid);
3566 __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid);
3575 static int __ps_remove_nativeapp_desktop(manifest_x *mfx)
3577 char filepath[PKG_STRING_LEN_MAX] = "";
3579 uiapplication_x *uiapplication = mfx->uiapplication;
3581 for(; uiapplication; uiapplication=uiapplication->next) {
3582 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, uiapplication->appid);
3584 __ail_change_info(AIL_REMOVE, uiapplication->appid);
3586 ret = remove(filepath);
3594 static int __add_preload_info(manifest_x * mfx, const char *manifest)
3597 char buffer[1024] = { 0 };
3600 if(strstr(manifest, MANIFEST_RO_PREFIX)) {
3601 free((void *)mfx->readonly);
3602 mfx->readonly = strdup("True");
3604 free((void *)mfx->preload);
3605 mfx->preload = strdup("True");
3607 free((void *)mfx->removable);
3608 mfx->removable = strdup("False");
3610 free((void *)mfx->system);
3611 mfx->system = strdup("True");
3616 fp = fopen(PRELOAD_PACKAGE_LIST, "r");
3618 _LOGE("no preload list\n");
3622 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
3623 if (buffer[0] == '#') {
3624 if(strcasestr(buffer, "RW_NORM"))
3626 else if(strcasestr(buffer, "RW_RM"))
3634 if(!strcmp(mfx->package, buffer)) {
3635 free((void *)mfx->preload);
3636 mfx->preload = strdup("True");
3638 free((void *)mfx->readonly);
3639 mfx->readonly = strdup("False");
3640 free((void *)mfx->removable);
3641 mfx->removable = strdup("False");
3642 } else if(state == 3){
3643 free((void *)mfx->readonly);
3644 mfx->readonly = strdup("False");
3645 free((void *)mfx->removable);
3646 mfx->removable = strdup("True");
3650 memset(buffer, 0x00, sizeof(buffer));
3659 static int __check_preload_updated(manifest_x * mfx, const char *manifest)
3661 char filepath[PKG_STRING_LEN_MAX] = "";
3663 uiapplication_x *uiapplication = mfx->uiapplication;
3665 if(strstr(manifest, MANIFEST_RO_PREFIX)) {
3666 /* if preload app is updated, then remove previous desktop file on RW*/
3667 for(; uiapplication; uiapplication=uiapplication->next) {
3668 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, uiapplication->appid);
3669 ret = remove(filepath);
3674 /* if downloaded app is updated, then update tag set true*/
3675 free((void *)mfx->update);
3676 mfx->update = strdup("true");
3682 static int __get_appid_list(const char *pkgid, void *user_data)
3689 sqlite3_stmt *stmt = NULL;
3690 sqlite3 *pkgmgr_parser_db;
3692 char *query = sqlite3_mprintf("select app_id from package_app_info where package=%Q", pkgid);
3694 ret = sqlite3_open("/opt/dbspace/.pkgmgr_parser.db", &pkgmgr_parser_db);
3695 if (ret != SQLITE_OK) {
3696 _LOGE("open fail\n");
3697 sqlite3_free(query);
3700 ret = sqlite3_prepare_v2(pkgmgr_parser_db, query, strlen(query), &stmt, NULL);
3701 if (ret != SQLITE_OK) {
3702 _LOGE("prepare_v2 fail\n");
3703 sqlite3_close(pkgmgr_parser_db);
3704 sqlite3_free(query);
3708 cols = sqlite3_column_count(stmt);
3711 ret = sqlite3_step(stmt);
3712 if(ret == SQLITE_ROW) {
3713 for(col = 0; col < cols; col++)
3715 appid = (char*)sqlite3_column_text(stmt, col);
3716 _LOGS("success find appid[%s]\n", appid);
3717 (*(GList**)user_data) = g_list_append((*(GList**)user_data), g_strdup(appid));
3724 sqlite3_finalize(stmt);
3725 sqlite3_close(pkgmgr_parser_db);
3726 sqlite3_free(query);
3730 void __call_uninstall_plugin(const char *pkgid, GList *appid_list)
3735 if (pkgid == NULL) {
3736 _LOGD("pkgid is null\n");
3740 tmp_list = appid_list;
3741 _pkgmgr_parser_plugin_open_db();
3743 _pkgmgr_parser_plugin_uninstall_plugin(PKGMGR_PARSER_PLUGIN_TAG, pkgid, pkgid);
3746 appid = (char *)tmp_list->data;
3748 _pkgmgr_parser_plugin_uninstall_plugin(PKGMGR_PARSER_PLUGIN_METADATA, pkgid, appid);
3749 _pkgmgr_parser_plugin_uninstall_plugin(PKGMGR_PARSER_PLUGIN_CATEGORY, pkgid, appid);
3751 tmp_list = g_list_next(tmp_list);
3754 _pkgmgr_parser_plugin_close_db();
3757 static int __delete_pkgid_info_for_uninstallation(const char *pkgid)
3759 retvm_if(pkgid == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
3763 GList *appid_list = NULL;
3764 char filepath[PKG_STRING_LEN_MAX] = "";
3766 _LOGD("Start uninstall for pkgid : delete pkgid[%s]\n", pkgid);
3769 ret = __get_appid_list(pkgid, &appid_list);
3770 retvm_if(ret < 0, PMINFO_R_ERROR, "Fail to get app_list");
3772 _LOGD("call plugin uninstall\n");
3774 /*call plugin uninstall*/
3775 __call_uninstall_plugin(pkgid, appid_list);
3777 /* delete pkgmgr db */
3778 ret = pkgmgr_parser_delete_pkgid_info_from_db(pkgid);
3780 _LOGD("DB pkgid info Delete failed\n");
3782 _LOGD("DB pkgid info Delete Success\n");
3784 /* delete desktop file*/
3785 while (appid_list) {
3786 appid = (char *)appid_list->data;
3788 _LOGD("Delete appid[%s] info from db\n", appid);
3790 ret = pkgmgr_parser_delete_appid_info_from_db(appid);
3792 _LOGD("DB appid info Delete failed\n");
3794 _LOGD("DB appid info Delete Success\n");
3796 ret = __ail_change_info(AIL_REMOVE, appid);
3798 _LOGD("AIL_REMOVE failed\n");
3800 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, appid);
3801 if (access(filepath, R_OK) == 0) {
3802 ret = remove(filepath);
3804 _LOGD("remove failed\n");
3807 appid_list = g_list_next(appid_list);
3810 g_list_free(appid_list);
3812 _LOGD("Finish : uninstall for pkgid\n");
3817 API int pkgmgr_parser_check_mdm_policy_for_uninstallation(const char *manifest)
3819 int ret = PMINFO_R_OK;
3820 manifest_x *mfx = NULL;
3822 mfx = pkgmgr_parser_process_manifest_xml(manifest);
3823 retvm_if(mfx == NULL, PMINFO_R_OK, "argument supplied is NULL");
3825 ret = __ps_check_mdm_policy(mfx, ACTION_UNINSTALL);
3827 _LOGE("pkg[%s] violate mdm policy.", mfx->package);
3829 pkgmgr_parser_free_manifest_xml(mfx);
3834 API int pkgmgr_parser_create_desktop_file(manifest_x *mfx)
3838 _LOGD("Manifest pointer is NULL\n");
3841 ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_INSTALL);
3843 _LOGD("Creating desktop file failed\n");
3845 _LOGD("Creating desktop file Success\n");
3849 API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
3854 free((void *)mfx->ns);
3858 free((void *)mfx->package);
3859 mfx->package = NULL;
3862 free((void *)mfx->version);
3863 mfx->version = NULL;
3865 if (mfx->installlocation) {
3866 free((void *)mfx->installlocation);
3867 mfx->installlocation = NULL;
3870 free((void *)mfx->preload);
3871 mfx->preload = NULL;
3873 if (mfx->readonly) {
3874 free((void *)mfx->readonly);
3875 mfx->readonly = NULL;
3877 if (mfx->removable) {
3878 free((void *)mfx->removable);
3879 mfx->removable = NULL;
3882 free((void *)mfx->update);
3886 free((void *)mfx->system);
3890 free((void *)mfx->type);
3893 if (mfx->package_size) {
3894 free((void *)mfx->package_size);
3895 mfx->package_size = NULL;
3897 if (mfx->package_total_size) {
3898 free((void *)mfx->package_total_size);
3899 mfx->package_total_size = NULL;
3901 if (mfx->package_data_size) {
3902 free((void *)mfx->package_data_size);
3903 mfx->package_data_size = NULL;
3905 if (mfx->installed_time) {
3906 free((void *)mfx->installed_time);
3907 mfx->installed_time = NULL;
3909 if (mfx->installed_storage) {
3910 free((void *)mfx->installed_storage);
3911 mfx->installed_storage = NULL;
3913 if (mfx->storeclient_id) {
3914 free((void *)mfx->storeclient_id);
3915 mfx->storeclient_id = NULL;
3917 if (mfx->mainapp_id) {
3918 free((void *)mfx->mainapp_id);
3919 mfx->mainapp_id = NULL;
3921 if (mfx->package_url) {
3922 free((void *)mfx->package_url);
3923 mfx->package_url = NULL;
3925 if (mfx->root_path) {
3926 free((void *)mfx->root_path);
3927 mfx->root_path = NULL;
3929 if (mfx->csc_path) {
3930 free((void *)mfx->csc_path);
3931 mfx->csc_path = NULL;
3933 if (mfx->appsetting) {
3934 free((void *)mfx->appsetting);
3935 mfx->appsetting = NULL;
3937 if (mfx->nodisplay_setting) {
3938 free((void *)mfx->nodisplay_setting);
3939 mfx->nodisplay_setting = NULL;
3944 icon_x *icon = mfx->icon;
3946 while(icon != NULL) {
3948 __ps_free_icon(icon);
3954 label_x *label = mfx->label;
3955 label_x *tmp = NULL;
3956 while(label != NULL) {
3958 __ps_free_label(label);
3964 author_x *author = mfx->author;
3965 author_x *tmp = NULL;
3966 while(author != NULL) {
3968 __ps_free_author(author);
3972 /*Free Description*/
3973 if (mfx->description) {
3974 description_x *description = mfx->description;
3975 description_x *tmp = NULL;
3976 while(description != NULL) {
3977 tmp = description->next;
3978 __ps_free_description(description);
3984 license_x *license = mfx->license;
3985 license_x *tmp = NULL;
3986 while(license != NULL) {
3987 tmp = license->next;
3988 __ps_free_license(license);
3993 if (mfx->privileges) {
3994 privileges_x *privileges = mfx->privileges;
3995 privileges_x *tmp = NULL;
3996 while(privileges != NULL) {
3997 tmp = privileges->next;
3998 __ps_free_privileges(privileges);
4002 /*Free UiApplication*/
4003 if (mfx->uiapplication) {
4004 uiapplication_x *uiapplication = mfx->uiapplication;
4005 uiapplication_x *tmp = NULL;
4006 while(uiapplication != NULL) {
4007 tmp = uiapplication->next;
4008 __ps_free_uiapplication(uiapplication);
4009 uiapplication = tmp;
4012 /*Free ServiceApplication*/
4013 if (mfx->serviceapplication) {
4014 serviceapplication_x *serviceapplication = mfx->serviceapplication;
4015 serviceapplication_x *tmp = NULL;
4016 while(serviceapplication != NULL) {
4017 tmp = serviceapplication->next;
4018 __ps_free_serviceapplication(serviceapplication);
4019 serviceapplication = tmp;
4024 daemon_x *daemon = mfx->daemon;
4025 daemon_x *tmp = NULL;
4026 while(daemon != NULL) {
4028 __ps_free_daemon(daemon);
4034 theme_x *theme = mfx->theme;
4035 theme_x *tmp = NULL;
4036 while(theme != NULL) {
4038 __ps_free_theme(theme);
4044 font_x *font = mfx->font;
4046 while(font != NULL) {
4048 __ps_free_font(font);
4054 ime_x *ime = mfx->ime;
4056 while(ime != NULL) {
4062 /*Free Compatibility*/
4063 if (mfx->compatibility) {
4064 compatibility_x *compatibility = mfx->compatibility;
4065 compatibility_x *tmp = NULL;
4066 while(compatibility != NULL) {
4067 tmp = compatibility->next;
4068 __ps_free_compatibility(compatibility);
4069 compatibility = tmp;
4072 /*Free DeviceProfile*/
4073 if (mfx->deviceprofile) {
4074 deviceprofile_x *deviceprofile = mfx->deviceprofile;
4075 deviceprofile_x *tmp = NULL;
4076 while(deviceprofile != NULL) {
4077 tmp = deviceprofile->next;
4078 __ps_free_deviceprofile(deviceprofile);
4079 deviceprofile = tmp;
4087 API manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest)
4089 _LOGD("parsing start\n");
4090 xmlTextReaderPtr reader;
4091 manifest_x *mfx = NULL;
4093 reader = xmlReaderForFile(manifest, NULL, 0);
4095 mfx = malloc(sizeof(manifest_x));
4097 memset(mfx, '\0', sizeof(manifest_x));
4098 if (__process_manifest(reader, mfx) < 0) {
4099 _LOGD("Parsing Failed\n");
4100 pkgmgr_parser_free_manifest_xml(mfx);
4103 _LOGD("Parsing Success\n");
4105 _LOGD("Memory allocation error\n");
4107 xmlFreeTextReader(reader);
4109 _LOGD("Unable to create xml reader\n");
4114 /* These APIs are intended to call parser directly */
4116 API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
4118 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
4119 _LOGD("parsing manifest for installation: %s\n", manifest);
4121 manifest_x *mfx = NULL;
4125 mfx = pkgmgr_parser_process_manifest_xml(manifest);
4126 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
4128 _LOGD("Parsing Finished\n");
4130 ret = __ps_check_mdm_policy(mfx, ACTION_INSTALL);
4131 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "pkg[%s] violate mdm policy.", mfx->package);
4133 __add_preload_info(mfx, manifest);
4135 _LOGD("Added preload infomation\n");
4137 __ps_process_tag(mfx, tagv);
4139 ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
4141 ret = __delete_pkgid_info_for_uninstallation(mfx->package);
4142 ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
4143 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
4146 _LOGD("DB Insert Success\n");
4148 _pkgmgr_parser_plugin_process_plugin(mfx, manifest, ACTION_INSTALL);
4150 if (__check_action_fota(tagv))
4151 ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_FOTA);
4153 ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_INSTALL);
4156 _LOGD("Creating desktop file failed\n");
4158 _LOGD("Creating desktop file Success\n");
4160 pkgmgr_parser_free_manifest_xml(mfx);
4161 _LOGD("Free Done\n");
4167 API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
4169 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
4170 _LOGD("parsing manifest for upgradation: %s\n", manifest);
4172 manifest_x *mfx = NULL;
4174 bool preload = false;
4175 bool system = false;
4176 char *csc_path = NULL;
4177 pkgmgrinfo_pkginfo_h handle = NULL;
4180 mfx = pkgmgr_parser_process_manifest_xml(manifest);
4181 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
4183 _LOGD("Parsing Finished\n");
4185 __add_preload_info(mfx, manifest);
4186 _LOGD("Added preload infomation\n");
4187 __check_preload_updated(mfx, manifest);
4189 ret = pkgmgrinfo_pkginfo_get_pkginfo(mfx->package, &handle);
4190 if (ret != PMINFO_R_OK)
4191 _LOGD("pkgmgrinfo_pkginfo_get_pkginfo failed\n");
4193 ret = pkgmgrinfo_pkginfo_is_preload(handle, &preload);
4194 if (ret != PMINFO_R_OK)
4195 _LOGD("pkgmgrinfo_pkginfo_is_preload failed\n");
4198 free((void *)mfx->preload);
4199 mfx->preload = strdup("true");
4202 ret = pkgmgrinfo_pkginfo_is_system(handle, &system);
4203 if (ret != PMINFO_R_OK)
4204 _LOGD("pkgmgrinfo_pkginfo_is_system failed\n");
4207 free((void *)mfx->system);
4208 mfx->system = strdup("true");
4211 ret = pkgmgrinfo_pkginfo_get_csc_path(handle, &csc_path);
4212 if (ret != PMINFO_R_OK)
4213 _LOGD("pkgmgrinfo_pkginfo_get_csc_path failed\n");
4215 if (csc_path != NULL) {
4217 free((void *)mfx->csc_path);
4218 mfx->csc_path = strdup(csc_path);
4221 ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
4222 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
4223 _LOGD("DB Update Success\n");
4225 _pkgmgr_parser_plugin_process_plugin(mfx, manifest, ACTION_UPGRADE);
4227 ret = __ps_make_nativeapp_desktop(mfx, manifest, ACTION_UPGRADE);
4229 _LOGD("Creating desktop file failed\n");
4231 _LOGD("Creating desktop file Success\n");
4233 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
4234 pkgmgr_parser_free_manifest_xml(mfx);
4235 _LOGD("Free Done\n");
4241 API int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[])
4243 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
4245 manifest_x *mfx = NULL;
4247 if (!strstr(manifest, ".xml")) {
4248 _LOGD("manifest is pkgid[%s]\n", manifest);
4249 ret = __delete_pkgid_info_for_uninstallation(manifest);
4251 _LOGD("__delete_manifest_for_fota failed\n");
4256 _LOGD("parsing manifest for uninstallation: %s\n", manifest);
4259 mfx = pkgmgr_parser_process_manifest_xml(manifest);
4260 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
4262 _LOGD("Parsing Finished\n");
4264 ret = __ps_check_mdm_policy(mfx, ACTION_UNINSTALL);
4265 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "pkg[%s] violate mdm policy.", mfx->package);
4267 __add_preload_info(mfx, manifest);
4268 _LOGD("Added preload infomation\n");
4270 _pkgmgr_parser_plugin_process_plugin(mfx, manifest, ACTION_UNINSTALL);
4272 ret = pkgmgr_parser_delete_manifest_info_from_db(mfx);
4274 _LOGD("DB Delete failed\n");
4276 _LOGD("DB Delete Success\n");
4278 ret = __ps_remove_nativeapp_desktop(mfx);
4280 _LOGD("Removing desktop file failed\n");
4282 _LOGD("Removing desktop file Success\n");
4284 pkgmgr_parser_free_manifest_xml(mfx);
4285 _LOGD("Free Done\n");
4291 API int pkgmgr_parser_parse_manifest_for_preload()
4293 return pkgmgr_parser_update_preload_info_in_db();
4296 API char *pkgmgr_parser_get_manifest_file(const char *pkgid)
4298 return __pkgid_to_manifest(pkgid);
4301 API int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
4303 return __ps_run_parser(docPtr, tag, ACTION_INSTALL, pkgid);
4306 API int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgid)
4308 return __ps_run_parser(docPtr, tag, ACTION_UPGRADE, pkgid);
4311 API int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
4313 return __ps_run_parser(docPtr, tag, ACTION_UNINSTALL, pkgid);
4316 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
4318 if (manifest == NULL) {
4319 _LOGE("manifest file is NULL\n");
4320 return PMINFO_R_EINVAL;
4323 xmlSchemaParserCtxtPtr ctx;
4324 xmlSchemaValidCtxtPtr vctx;
4325 xmlSchemaPtr xschema;
4326 ctx = xmlSchemaNewParserCtxt(SCHEMA_FILE);
4328 _LOGE("xmlSchemaNewParserCtxt() Failed\n");
4329 return PMINFO_R_ERROR;
4331 xschema = xmlSchemaParse(ctx);
4332 if (xschema == NULL) {
4333 _LOGE("xmlSchemaParse() Failed\n");
4334 return PMINFO_R_ERROR;
4336 vctx = xmlSchemaNewValidCtxt(xschema);
4338 _LOGE("xmlSchemaNewValidCtxt() Failed\n");
4339 return PMINFO_R_ERROR;
4341 xmlSchemaSetValidErrors(vctx, (xmlSchemaValidityErrorFunc) fprintf, (xmlSchemaValidityWarningFunc) fprintf, stderr);
4342 ret = xmlSchemaValidateFile(vctx, manifest, 0);
4344 _LOGE("xmlSchemaValidateFile() failed\n");
4345 return PMINFO_R_ERROR;
4346 } else if (ret == 0) {
4347 _LOGE("Manifest is Valid\n");
4350 _LOGE("Manifest Validation Failed with error code %d\n", ret);
4351 return PMINFO_R_ERROR;
4356 API int pkgmgr_parser_insert_disabled_pkg(const char *pkgid, char *const tagv[])
4358 retvm_if(pkgid == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
4360 char *manifest = NULL;
4361 manifest_x *mfx = NULL;
4364 _LOGD("parsing manifest for installation: %s\n", pkgid);
4366 manifest = pkgmgr_parser_get_manifest_file(pkgid);
4367 if (manifest == NULL) {
4368 _LOGE("can not get the manifest.xml\n");
4373 mfx = pkgmgr_parser_process_manifest_xml(manifest);
4374 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
4376 _LOGD("Parsing Finished\n");
4378 __add_preload_info(mfx, manifest);
4380 _LOGD("Added preload infomation\n");
4382 ret = pkgmgr_parser_insert_disabled_pkg_info_in_db(mfx);
4383 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
4385 _LOGD("DB Insert Success\n");
4387 pkgmgr_parser_free_manifest_xml(mfx);
4388 _LOGD("Free Done\n");
4394 API int pkgmgr_parser_delete_disabled_pkg(const char *pkgid, char *const tagv[])
4396 retvm_if(pkgid == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
4400 _LOGD("Start uninstall for pkgid : delete pkgid[%s]\n", pkgid);
4402 /* delete pkgmgr db */
4403 ret = pkgmgr_parser_delete_disabled_pkgid_info_from_db(pkgid);
4405 _LOGD("DB pkgid info Delete failed\n");
4407 _LOGD("DB pkgid info Delete Success\n");
4409 _LOGD("Finish : uninstall for pkgid\n");