4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
7 * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
31 #include <libxml/parser.h>
32 #include <libxml/xmlreader.h>
33 #include <libxml/xmlschemas.h>
37 #include <journal/appcore.h>
39 #include "pkgmgr_parser.h"
40 #include "pkgmgr_parser_internal.h"
41 #include "pkgmgr_parser_db.h"
42 #include "pkgmgr_parser_db_util.h"
43 #include "pkgmgr_parser_signature.h"
44 #include "pkgmgr_parser_plugin.h"
46 #include "pkgmgrinfo_debug.h"
51 #define LOG_TAG "PKGMGR_PARSER"
53 #define MANIFEST_RW_DIRECTORY "/opt/share/packages"
54 #define MANIFEST_RO_DIRECTORY "/usr/share/packages"
55 #define ASCII(s) (const char *)s
56 #define XMLCHAR(s) (const xmlChar *)s
61 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label);
62 static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege);
63 static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privileges);
64 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile);
65 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed);
66 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation);
67 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri);
68 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime);
69 static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp);
70 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition);
71 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notifiation);
72 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category);
73 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata);
74 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission);
75 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility);
76 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution);
77 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request);
78 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define);
79 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc);
80 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions);
81 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare);
82 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon);
83 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author);
84 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description);
85 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability);
86 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license);
87 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol);
88 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication);
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 char *__pkgid_to_manifest(const char *pkgid);
94 static int __next_child_element(xmlTextReaderPtr reader, int depth);
95 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx);
96 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx);
100 static void __save_xml_attribute(xmlTextReaderPtr reader, char *attribute, const char **xml_attribute, char *default_value)
102 xmlChar *attrib_val = xmlTextReaderGetAttribute(reader, XMLCHAR(attribute));
104 *xml_attribute = ASCII(attrib_val);
106 if (default_value != NULL) {
107 *xml_attribute = strdup(default_value);
112 static void __save_xml_lang(xmlTextReaderPtr reader, const char **xml_attribute)
114 const xmlChar *attrib_val = xmlTextReaderConstXmlLang(reader);
115 if (attrib_val != NULL) {
116 *xml_attribute = strdup(ASCII(attrib_val));
118 *xml_attribute = strdup(DEFAULT_LOCALE);
122 static void __save_xml_value(xmlTextReaderPtr reader, const char **xml_attribute)
124 xmlTextReaderRead(reader);
125 xmlChar *attrib_val = xmlTextReaderValue(reader);
128 *xml_attribute = ASCII(attrib_val);
132 static void __save_xml_supportmode(xmlTextReaderPtr reader, manifest_x * mfx)
134 xmlChar *attrib_val = xmlTextReaderGetAttribute(reader, XMLCHAR("support-mode"));
137 char buffer[10] = {'\0'};
139 if (strstr(ASCII(attrib_val), "ultra-power-saving")) {
140 temp_mode |= PMINFO_SUPPORT_MODE_ULTRA_POWER_SAVING; // PMINFO_MODE_PROP_ULTRA_POWER_SAVING 0x00000001
142 if (strstr(ASCII(attrib_val), "cool-down")) {
143 temp_mode |= PMINFO_SUPPORT_MODE_COOL_DOWN; // PMINFO_MODE_PROP_COOL_DOWN 0x00000002
145 if (strstr(ASCII(attrib_val), "screen-reader")) {
146 temp_mode |= PMINFO_SUPPORT_MODE_SCREEN_READER; // PMINFO_MODE_PROP_SCREEN_READER 0x00000004
148 sprintf(buffer, "%d", temp_mode);
149 mfx->support_mode = strdup(buffer);
152 mfx->support_mode = strdup("0");
156 static void __save_xml_supportfeature(const char *metadata_key, uiapplication_x *uiapplication)
160 char buffer[PKG_STRING_LEN_MAX] = {'\0'};
162 if (uiapplication->support_feature) {
163 temp_mode = atoi(uiapplication->support_feature);
164 FREE_AND_NULL(uiapplication->support_feature);
167 if (strcmp(metadata_key, "http://developer.samsung.com/tizen/metadata/multiwindow") == 0) {
168 temp_mode |= PMINFO_SUPPORT_FEATURE_MULTI_WINDOW;
169 } else if (strcmp(metadata_key, "http://developer.samsung.com/tizen/metadata/oomtermination") == 0) {
170 temp_mode |= PMINFO_SUPPORT_FEATURE_OOM_TERMINATION;
171 } else if (strcmp(metadata_key, "http://developer.samsung.com/tizen/metadata/largememory") == 0) {
172 temp_mode |= PMINFO_SUPPORT_FEATURE_LARGE_MEMORY;
175 sprintf(buffer, "%d", temp_mode);
176 uiapplication->support_feature = strdup(buffer);
178 uiapplication->support_feature = strdup("0");
182 static void __save_xml_installedtime(manifest_x * mfx)
184 char buf[PKG_STRING_LEN_MAX] = {'\0'};
188 snprintf(buf, PKG_STRING_LEN_MAX - 1, "%d", (int)current_time);
189 val = strndup(buf, PKG_STRING_LEN_MAX - 1);
190 mfx->installed_time = val;
193 static void __save_xml_defaultvalue(manifest_x * mfx)
195 mfx->preload = strdup("False");
196 mfx->removable = strdup("True");
197 mfx->readonly = strdup("False");
198 mfx->update = strdup("False");
199 mfx->system = strdup("False");
200 mfx->installed_storage= strdup("installed_internal");
201 package = mfx->package;
204 static char *__pkgid_to_manifest(const char *pkgid)
210 _LOGE("pkgid is NULL");
214 size = strlen(MANIFEST_RW_DIRECTORY) + strlen(pkgid) + 10;
215 manifest = malloc(size);
216 if (manifest == NULL) {
220 memset(manifest, '\0', size);
221 snprintf(manifest, size, MANIFEST_RW_DIRECTORY "/%s.xml", pkgid);
223 if (access(manifest, F_OK)) {
224 snprintf(manifest, size, MANIFEST_RO_DIRECTORY "/%s.xml", pkgid);
230 static int __next_child_element(xmlTextReaderPtr reader, int depth)
232 int ret = xmlTextReaderRead(reader);
233 int cur = xmlTextReaderDepth(reader);
236 switch (xmlTextReaderNodeType(reader)) {
237 case XML_READER_TYPE_ELEMENT:
238 if (cur == depth + 1)
241 case XML_READER_TYPE_TEXT:
242 /*text is handled by each function separately*/
243 if (cur == depth + 1)
246 case XML_READER_TYPE_END_ELEMENT:
255 ret = xmlTextReaderRead(reader);
256 cur = xmlTextReaderDepth(reader);
261 static int __check_action_fota(char *const tagv[])
265 char *ret_result = NULL;
267 int ret = PM_PARSER_R_ERROR;
272 for (tag = strdup(tagv[0]); tag != NULL; ) {
273 ret_result = strtok(tag, delims);
275 /*check tag : fota is true */
276 if (strcmp(ret_result, "fota") == 0) {
277 ret_result = strtok(NULL, delims);
278 if (strcmp(ret_result, "true") == 0) {
279 ret = PM_PARSER_R_OK;
282 _LOGD("tag process [%s]is not defined\n", ret_result);
287 if (tagv[++i] != NULL)
288 tag = strdup(tagv[i]);
290 _LOGD("tag process success...%d\n" , ret);
298 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed)
300 __save_xml_value(reader, &allowed->text);
304 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation)
306 __save_xml_attribute(reader, "name", &operation->name, NULL);
307 /* Text does not exist. Only attribute exists
308 xmlTextReaderRead(reader);
309 if (xmlTextReaderValue(reader))
310 operation->text = ASCII(xmlTextReaderValue(reader));
315 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri)
317 __save_xml_attribute(reader, "name", &uri->name, NULL);
318 /* Text does not exist. Only attribute exists
319 xmlTextReaderRead(reader);
320 if (xmlTextReaderValue(reader))
321 uri->text = ASCII(xmlTextReaderValue(reader));
326 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime)
328 __save_xml_attribute(reader, "name", &mime->name, NULL);
329 /* Text does not exist. Only attribute exists
330 xmlTextReaderRead(reader);
331 if (xmlTextReaderValue(reader))
332 mime->text = ASCII(xmlTextReaderValue(reader));
337 static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp)
339 __save_xml_attribute(reader, "name", &subapp->name, NULL);
340 /* Text does not exist. Only attribute exists
341 xmlTextReaderRead(reader);
342 if (xmlTextReaderValue(reader))
343 mime->text = ASCII(xmlTextReaderValue(reader));
348 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition)
350 __save_xml_attribute(reader, "name", &condition->name, NULL);
351 __save_xml_value(reader, &condition->text);
355 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notification)
357 __save_xml_attribute(reader, "name", ¬ification->name, NULL);
358 __save_xml_value(reader, ¬ification->text);
362 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category)
364 __save_xml_attribute(reader, "name", &category->name, NULL);
368 static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege)
370 __save_xml_value(reader, &privilege->text);
374 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata)
376 __save_xml_attribute(reader, "key", &metadata->key, NULL);
377 __save_xml_attribute(reader, "value", &metadata->value, NULL);
381 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission)
383 __save_xml_attribute(reader, "type", &permission->type, NULL);
384 __save_xml_value(reader, &permission->value);
389 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility)
391 __save_xml_attribute(reader, "name", &compatibility->name, NULL);
392 __save_xml_value(reader, &compatibility->text);
397 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution)
399 __save_xml_attribute(reader, "mime-type", &resolution->mimetype, NULL);
400 __save_xml_attribute(reader, "uri-scheme", &resolution->urischeme, NULL);
404 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request)
406 __save_xml_value(reader, &request->text);
411 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define)
416 allowed_x *tmp1 = NULL;
417 request_x *tmp2 = NULL;
419 __save_xml_attribute(reader, "path", &define->path, NULL);
421 depth = xmlTextReaderDepth(reader);
422 while ((ret = __next_child_element(reader, depth))) {
423 node = xmlTextReaderConstName(reader);
425 _LOGD("xmlTextReaderConstName value is NULL\n");
429 if (!strcmp(ASCII(node), "allowed")) {
430 allowed_x *allowed= malloc(sizeof(allowed_x));
431 if (allowed == NULL) {
432 _LOGD("Malloc Failed\n");
435 memset(allowed, '\0', sizeof(allowed_x));
436 LISTADD(define->allowed, allowed);
437 ret = __ps_process_allowed(reader, allowed);
438 } else if (!strcmp(ASCII(node), "request")) {
439 request_x *request = malloc(sizeof(request_x));
440 if (request == NULL) {
441 _LOGD("Malloc Failed\n");
444 memset(request, '\0', sizeof(request_x));
445 LISTADD(define->request, request);
446 ret = __ps_process_request(reader, request);
450 _LOGD("Processing define failed\n");
455 SAFE_LISTHEAD(define->allowed, tmp1);
456 SAFE_LISTHEAD(define->request, tmp2);
461 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc)
466 operation_x *tmp1 = NULL;
469 subapp_x *tmp4 = NULL;
471 depth = xmlTextReaderDepth(reader);
472 while ((ret = __next_child_element(reader, depth))) {
473 node = xmlTextReaderConstName(reader);
475 _LOGD("xmlTextReaderConstName value is NULL\n");
479 if (!strcmp(ASCII(node), "operation")) {
480 operation_x *operation = malloc(sizeof(operation_x));
481 if (operation == NULL) {
482 _LOGD("Malloc Failed\n");
485 memset(operation, '\0', sizeof(operation_x));
486 LISTADD(appsvc->operation, operation);
487 ret = __ps_process_operation(reader, operation);
488 _LOGD("operation processing\n");
489 } else if (!strcmp(ASCII(node), "uri")) {
490 uri_x *uri= malloc(sizeof(uri_x));
492 _LOGD("Malloc Failed\n");
495 memset(uri, '\0', sizeof(uri_x));
496 LISTADD(appsvc->uri, uri);
497 ret = __ps_process_uri(reader, uri);
498 _LOGD("uri processing\n");
499 } else if (!strcmp(ASCII(node), "mime")) {
500 mime_x *mime = malloc(sizeof(mime_x));
502 _LOGD("Malloc Failed\n");
505 memset(mime, '\0', sizeof(mime_x));
506 LISTADD(appsvc->mime, mime);
507 ret = __ps_process_mime(reader, mime);
508 _LOGD("mime processing\n");
509 } else if (!strcmp(ASCII(node), "subapp")) {
510 subapp_x *subapp = malloc(sizeof(subapp_x));
511 if (subapp == NULL) {
512 _LOGD("Malloc Failed\n");
515 memset(subapp, '\0', sizeof(subapp_x));
516 LISTADD(appsvc->subapp, subapp);
517 ret = __ps_process_subapp(reader, subapp);
518 _LOGD("subapp processing\n");
522 _LOGD("Processing appsvc failed\n");
527 SAFE_LISTHEAD(appsvc->operation, tmp1);
528 SAFE_LISTHEAD(appsvc->uri, tmp2);
529 SAFE_LISTHEAD(appsvc->mime, tmp3);
530 SAFE_LISTHEAD(appsvc->subapp, tmp4);
532 __save_xml_value(reader, &appsvc->text);
538 static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privileges)
543 privilege_x *tmp1 = NULL;
545 depth = xmlTextReaderDepth(reader);
546 while ((ret = __next_child_element(reader, depth))) {
547 node = xmlTextReaderConstName(reader);
549 _LOGD("xmlTextReaderConstName value is NULL\n");
553 if (strcmp(ASCII(node), "privilege") == 0) {
554 privilege_x *privilege = malloc(sizeof(privilege_x));
555 if (privilege == NULL) {
556 _LOGD("Malloc Failed\n");
559 memset(privilege, '\0', sizeof(privilege_x));
560 LISTADD(privileges->privilege, privilege);
561 ret = __ps_process_privilege(reader, privilege);
565 _LOGD("Processing privileges failed\n");
569 SAFE_LISTHEAD(privileges->privilege, tmp1);
573 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions)
578 condition_x *tmp1 = NULL;
580 depth = xmlTextReaderDepth(reader);
581 while ((ret = __next_child_element(reader, depth))) {
582 node = xmlTextReaderConstName(reader);
584 _LOGD("xmlTextReaderConstName value is NULL\n");
588 if (strcmp(ASCII(node), "condition") == 0) {
589 condition_x *condition = malloc(sizeof(condition_x));
590 if (condition == NULL) {
591 _LOGD("Malloc Failed\n");
594 memset(condition, '\0', sizeof(condition_x));
595 LISTADD(launchconditions->condition, condition);
596 ret = __ps_process_condition(reader, condition);
600 _LOGD("Processing launchconditions failed\n");
605 SAFE_LISTHEAD(launchconditions->condition, tmp1);
607 __save_xml_value(reader, &launchconditions->text);
612 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare)
617 define_x *tmp1 = NULL;
618 request_x *tmp2 = NULL;
619 depth = xmlTextReaderDepth(reader);
620 while ((ret = __next_child_element(reader, depth))) {
621 node = xmlTextReaderConstName(reader);
623 _LOGD("xmlTextReaderConstName value is NULL\n");
627 if (!strcmp(ASCII(node), "define")) {
628 define_x *define= malloc(sizeof(define_x));
629 if (define == NULL) {
630 _LOGD("Malloc Failed\n");
633 memset(define, '\0', sizeof(define_x));
634 LISTADD(datashare->define, define);
635 ret = __ps_process_define(reader, define);
636 } else if (!strcmp(ASCII(node), "request")) {
637 request_x *request= malloc(sizeof(request_x));
638 if (request == NULL) {
639 _LOGD("Malloc Failed\n");
642 memset(request, '\0', sizeof(request_x));
643 LISTADD(datashare->request, request);
644 ret = __ps_process_request(reader, request);
648 _LOGD("Processing data-share failed\n");
653 SAFE_LISTHEAD(datashare->define, tmp1);
654 SAFE_LISTHEAD(datashare->request, tmp2);
660 __get_icon_with_path(const char* icon)
665 if (index(icon, '/') == NULL) {
667 char* icon_with_path = NULL;
673 theme = strdup("default");
675 _LOGE("@malloc failed!!!");
679 len = (0x01 << 7) + strlen(icon) + strlen(package) + strlen(theme);
680 icon_with_path = malloc(len);
681 if(icon_with_path == NULL) {
682 _LOGD("(icon_with_path == NULL) return\n");
683 FREE_AND_NULL(theme);
687 memset(icon_with_path, 0, len);
688 snprintf(icon_with_path, len, "/opt/usr/apps/%s/shared/res/icons/default/small/%s", package, icon);
690 if (access(icon_with_path, R_OK) == 0) break;
691 snprintf(icon_with_path, len, "/opt/share/icons/%s/small/%s", theme, icon);
692 if (access(icon_with_path, R_OK) == 0) break;
693 snprintf(icon_with_path, len, "/usr/share/icons/%s/small/%s", theme, icon);
694 if (access(icon_with_path, R_OK) == 0) break;
695 snprintf(icon_with_path, len,"/opt/share/icons/default/small/%s", icon);
696 if (access(icon_with_path, R_OK) == 0) break;
697 snprintf(icon_with_path, len, "/usr/share/icons/default/small/%s", icon);
698 if (access(icon_with_path, R_OK) == 0) break;
700 /* icon path is going to be moved intto the app directory */
701 snprintf(icon_with_path, len, "/usr/apps/%s/shared/res/icons/default/small/%s", package, icon);
702 if (access(icon_with_path, R_OK) == 0) break;
703 snprintf(icon_with_path, len, "/opt/apps/%s/res/icons/%s/small/%s", package, theme, icon);
704 if (access(icon_with_path, R_OK) == 0) break;
705 snprintf(icon_with_path, len, "/usr/apps/%s/res/icons/%s/small/%s", package, theme, icon);
706 if (access(icon_with_path, R_OK) == 0) break;
707 snprintf(icon_with_path, len, "/opt/apps/%s/res/icons/default/small/%s", package, icon);
708 if (access(icon_with_path, R_OK) == 0) break;
709 snprintf(icon_with_path, len, "/usr/apps/%s/res/icons/default/small/%s", package, icon);
710 if (access(icon_with_path, R_OK) == 0) break;
711 snprintf(icon_with_path, len, "/usr/ug/res/images/%s/%s", package, icon);
712 if (access(icon_with_path, R_OK) == 0) break;
715 FREE_AND_NULL(theme);
717 /* If icon is not exist, return NULL */
718 if (access(icon_with_path, R_OK) != 0) {
719 _LOGE("Icon is not exist");
720 FREE_AND_NULL(icon_with_path);
723 _LOGD("Icon path : %s ---> %s", icon, icon_with_path);
724 return icon_with_path;
727 char* confirmed_icon = NULL;
729 confirmed_icon = strdup(icon);
732 return confirmed_icon;
736 static void __ps_process_tag(manifest_x * mfx, char *const tagv[])
740 char *ret_result = NULL;
746 for (tag = strdup(tagv[0]); tag != NULL; ) {
747 ret_result = strtok(tag, delims);
749 /*check tag : preload */
750 if (strcmp(ret_result, "preload") == 0) {
751 ret_result = strtok(NULL, delims);
752 if (strcmp(ret_result, "true") == 0) {
753 FREE_AND_NULL(mfx->preload);
754 mfx->preload = strdup("true");
755 } else if (strcmp(ret_result, "false") == 0) {
756 FREE_AND_NULL(mfx->preload);
757 mfx->preload = strdup("false");
759 /*check tag : removable*/
760 } else if (strcmp(ret_result, "removable") == 0) {
761 ret_result = strtok(NULL, delims);
762 if (strcmp(ret_result, "true") == 0){
763 FREE_AND_NULL(mfx->removable);
764 mfx->removable = strdup("true");
765 } else if (strcmp(ret_result, "false") == 0) {
766 FREE_AND_NULL(mfx->removable);
767 mfx->removable = strdup("false");
769 /*check tag : not matched*/
771 _LOGD("tag process [%s]is not defined\n", ret_result);
776 if (tagv[++i] != NULL)
777 tag = strdup(tagv[i]);
779 /*update tag : system*/
780 if ((strcmp(mfx->preload,"true")==0) && (strcmp(mfx->removable,"false")==0)){
781 FREE_AND_NULL(mfx->system);
782 mfx->system = strdup("true");
784 _LOGD("tag process success...\n");
790 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon)
792 __save_xml_attribute(reader, "name", &icon->name, NULL);
793 __save_xml_attribute(reader, "section", &icon->section, NULL);
794 __save_xml_attribute(reader, "size", &icon->size, NULL);
795 __save_xml_attribute(reader, "resolution", &icon->resolution, NULL);
796 __save_xml_lang(reader, &icon->lang);
798 xmlTextReaderRead(reader);
799 const char *text = ASCII(xmlTextReaderValue(reader));
801 icon->text = (const char *)__get_icon_with_path(text);
808 static int __ps_process_image(xmlTextReaderPtr reader, image_x *image)
810 __save_xml_attribute(reader, "name", &image->name, NULL);
811 __save_xml_attribute(reader, "section", &image->section, NULL);
812 __save_xml_lang(reader, &image->lang);
813 __save_xml_value(reader, &image->text);
818 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label)
820 __save_xml_attribute(reader, "name", &label->name, NULL);
821 __save_xml_lang(reader, &label->lang);
822 __save_xml_value(reader, &label->text);
824 /* _LOGD("lable name %s\n", label->name);
825 _LOGD("lable lang %s\n", label->lang);
826 _LOGD("lable text %s\n", label->text);
832 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author)
834 __save_xml_attribute(reader, "email", &author->email, NULL);
835 __save_xml_attribute(reader, "href", &author->href, NULL);
836 __save_xml_lang(reader, &author->lang);
837 __save_xml_value(reader, &author->text);
842 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description)
844 __save_xml_lang(reader, &description->lang);
845 __save_xml_value(reader, &description->text);
850 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license)
852 __save_xml_lang(reader, &license->lang);
853 __save_xml_value(reader, &license->text);
858 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability)
863 resolution_x *tmp1 = NULL;
865 __save_xml_attribute(reader, "operation-id", &capability->operationid, NULL);
867 depth = xmlTextReaderDepth(reader);
868 while ((ret = __next_child_element(reader, depth))) {
869 node = xmlTextReaderConstName(reader);
871 _LOGD("xmlTextReaderConstName value is NULL\n");
875 if (!strcmp(ASCII(node), "resolution")) {
876 resolution_x *resolution = malloc(sizeof(resolution_x));
877 if (resolution == NULL) {
878 _LOGD("Malloc Failed\n");
881 memset(resolution, '\0', sizeof(resolution_x));
882 LISTADD(capability->resolution, resolution);
883 ret = __ps_process_resolution(reader, resolution);
887 _LOGD("Processing capability failed\n");
892 SAFE_LISTHEAD(capability->resolution, tmp1);
897 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol)
899 __save_xml_attribute(reader, "providerid", &datacontrol->providerid, NULL);
900 __save_xml_attribute(reader, "access", &datacontrol->access, NULL);
901 __save_xml_attribute(reader, "type", &datacontrol->type, NULL);
906 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication)
911 label_x *tmp1 = NULL;
913 appsvc_x *tmp3 = NULL;
914 launchconditions_x *tmp4 = NULL;
915 notification_x *tmp5 = NULL;
916 datashare_x *tmp6 = NULL;
917 category_x *tmp7 = NULL;
918 metadata_x *tmp8 = NULL;
919 image_x *tmp9 = NULL;
920 permission_x *tmp10 = NULL;
921 datacontrol_x *tmp11 = NULL;
923 __save_xml_attribute(reader, "appid", &uiapplication->appid, NULL);
924 retvm_if(uiapplication->appid == NULL, PM_PARSER_R_ERROR, "appid cant be NULL, appid field is mandatory\n");
925 __save_xml_attribute(reader, "exec", &uiapplication->exec, NULL);
926 __save_xml_attribute(reader, "nodisplay", &uiapplication->nodisplay, "false");
927 __save_xml_attribute(reader, "multiple", &uiapplication->multiple, "false");
928 __save_xml_attribute(reader, "type", &uiapplication->type, NULL);
929 __save_xml_attribute(reader, "categories", &uiapplication->categories, NULL);
930 __save_xml_attribute(reader, "extraid", &uiapplication->extraid, NULL);
931 __save_xml_attribute(reader, "taskmanage", &uiapplication->taskmanage, "true");
932 __save_xml_attribute(reader, "enabled", &uiapplication->enabled, "true");
933 __save_xml_attribute(reader, "hw-acceleration", &uiapplication->hwacceleration, "use-system-setting");
934 __save_xml_attribute(reader, "screen-reader", &uiapplication->screenreader, "use-system-setting");
935 __save_xml_attribute(reader, "mainapp", &uiapplication->mainapp, "false");
936 __save_xml_attribute(reader, "recentimage", &uiapplication->recentimage, "false");
937 __save_xml_attribute(reader, "launchcondition", &uiapplication->launchcondition, "false");
938 __save_xml_attribute(reader, "indicatordisplay", &uiapplication->indicatordisplay, "true");
939 __save_xml_attribute(reader, "portrait-effectimage", &uiapplication->portraitimg, NULL);
940 __save_xml_attribute(reader, "landscape-effectimage", &uiapplication->landscapeimg, NULL);
941 __save_xml_attribute(reader, "effectimage-type", &uiapplication->effectimage_type, "image");
942 __save_xml_attribute(reader, "guestmode-visibility", &uiapplication->guestmode_visibility, "true");
943 __save_xml_attribute(reader, "permission-type", &uiapplication->permission_type, "normal");
944 __save_xml_attribute(reader, "component-type", &uiapplication->component_type, "uiapp");
945 /*component_type has "svcapp" or "uiapp", if it is not, parsing manifest is fail*/
946 retvm_if(((strcmp(uiapplication->component_type, "svcapp") != 0) && (strcmp(uiapplication->component_type, "uiapp") != 0)), PM_PARSER_R_ERROR, "invalid component_type[%s]\n", uiapplication->component_type);
947 __save_xml_attribute(reader, "submode", &uiapplication->submode, "false");
948 __save_xml_attribute(reader, "submode-mainid", &uiapplication->submode_mainid, NULL);
949 __save_xml_attribute(reader, "process-pool", &uiapplication->process_pool, "false");
950 __save_xml_attribute(reader, "auto-restart", &uiapplication->autorestart, "false");
951 __save_xml_attribute(reader, "on-boot", &uiapplication->onboot, "false");
952 __save_xml_attribute(reader, "multi-instance", &uiapplication->multi_instance, "false");
953 __save_xml_attribute(reader, "multi-instance-mainid", &uiapplication->multi_instance_mainid, NULL);
954 __save_xml_attribute(reader, "ui-gadget", &uiapplication->ui_gadget, "false");
955 uiapplication->multi_window = strdup("false");
956 uiapplication->package= strdup(package);
958 depth = xmlTextReaderDepth(reader);
959 while ((ret = __next_child_element(reader, depth))) {
960 node = xmlTextReaderConstName(reader);
962 _LOGD("xmlTextReaderConstName value is NULL\n");
965 if (!strcmp(ASCII(node), "label")) {
966 label_x *label = malloc(sizeof(label_x));
968 _LOGD("Malloc Failed\n");
971 memset(label, '\0', sizeof(label_x));
972 LISTADD(uiapplication->label, label);
973 ret = __ps_process_label(reader, label);
974 } else if (!strcmp(ASCII(node), "icon")) {
975 icon_x *icon = malloc(sizeof(icon_x));
977 _LOGD("Malloc Failed\n");
980 memset(icon, '\0', sizeof(icon_x));
981 LISTADD(uiapplication->icon, icon);
982 ret = __ps_process_icon(reader, icon);
983 } else if (!strcmp(ASCII(node), "image")) {
984 image_x *image = malloc(sizeof(image_x));
986 _LOGD("Malloc Failed\n");
989 memset(image, '\0', sizeof(image_x));
990 LISTADD(uiapplication->image, image);
991 ret = __ps_process_image(reader, image);
992 } else if (!strcmp(ASCII(node), "category")) {
993 category_x *category = malloc(sizeof(category_x));
994 if (category == NULL) {
995 _LOGD("Malloc Failed\n");
998 memset(category, '\0', sizeof(category_x));
999 LISTADD(uiapplication->category, category);
1000 ret = __ps_process_category(reader, category);
1001 } else if (!strcmp(ASCII(node), "metadata")) {
1002 metadata_x *metadata = malloc(sizeof(metadata_x));
1003 if (metadata == NULL) {
1004 _LOGD("Malloc Failed\n");
1007 memset(metadata, '\0', sizeof(metadata_x));
1008 LISTADD(uiapplication->metadata, metadata);
1009 ret = __ps_process_metadata(reader, metadata);
1010 // multiwindow check
1011 if (strcmp(metadata->key, "http://developer.samsung.com/tizen/metadata/multiwindow") == 0)
1012 FREE_AND_STRDUP("true", uiapplication->multi_window);
1014 __save_xml_supportfeature(metadata->key, uiapplication);
1015 } else if (!strcmp(ASCII(node), "permission")) {
1016 permission_x *permission = malloc(sizeof(permission_x));
1017 if (permission == NULL) {
1018 _LOGD("Malloc Failed\n");
1021 memset(permission, '\0', sizeof(permission_x));
1022 LISTADD(uiapplication->permission, permission);
1023 ret = __ps_process_permission(reader, permission);
1024 } else if (!strcmp(ASCII(node), "application-service")) {
1025 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
1026 if (appsvc == NULL) {
1027 _LOGD("Malloc Failed\n");
1030 memset(appsvc, '\0', sizeof(appsvc_x));
1031 LISTADD(uiapplication->appsvc, appsvc);
1032 ret = __ps_process_appsvc(reader, appsvc);
1033 } else if (!strcmp(ASCII(node), "app-control")) {
1034 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
1035 if (appsvc == NULL) {
1036 _LOGD("Malloc Failed\n");
1039 memset(appsvc, '\0', sizeof(appsvc_x));
1040 LISTADD(uiapplication->appsvc, appsvc);
1041 ret = __ps_process_appsvc(reader, appsvc);
1042 } else if (!strcmp(ASCII(node), "data-share")) {
1043 datashare_x *datashare = malloc(sizeof(datashare_x));
1044 if (datashare == NULL) {
1045 _LOGD("Malloc Failed\n");
1048 memset(datashare, '\0', sizeof(datashare_x));
1049 LISTADD(uiapplication->datashare, datashare);
1050 ret = __ps_process_datashare(reader, datashare);
1051 } else if (!strcmp(ASCII(node), "launch-conditions")) {
1052 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
1053 if (launchconditions == NULL) {
1054 _LOGD("Malloc Failed\n");
1057 memset(launchconditions, '\0', sizeof(launchconditions_x));
1058 LISTADD(uiapplication->launchconditions, launchconditions);
1059 ret = __ps_process_launchconditions(reader, launchconditions);
1060 } else if (!strcmp(ASCII(node), "notification")) {
1061 notification_x *notification = malloc(sizeof(notification_x));
1062 if (notification == NULL) {
1063 _LOGD("Malloc Failed\n");
1066 memset(notification, '\0', sizeof(notification_x));
1067 LISTADD(uiapplication->notification, notification);
1068 ret = __ps_process_notification(reader, notification);
1069 } else if (!strcmp(ASCII(node), "datacontrol")) {
1070 datacontrol_x *datacontrol = malloc(sizeof(datacontrol_x));
1071 if (datacontrol == NULL) {
1072 _LOGD("Malloc Failed\n");
1075 memset(datacontrol, '\0', sizeof(datacontrol_x));
1076 LISTADD(uiapplication->datacontrol, datacontrol);
1077 ret = __ps_process_datacontrol(reader, datacontrol);
1081 _LOGD("Processing uiapplication failed\n");
1086 SAFE_LISTHEAD(uiapplication->label, tmp1);
1087 SAFE_LISTHEAD(uiapplication->icon, tmp2);
1088 SAFE_LISTHEAD(uiapplication->appsvc, tmp3);
1089 SAFE_LISTHEAD(uiapplication->launchconditions, tmp4);
1090 SAFE_LISTHEAD(uiapplication->notification, tmp5);
1091 SAFE_LISTHEAD(uiapplication->datashare, tmp6);
1092 SAFE_LISTHEAD(uiapplication->category, tmp7);
1093 SAFE_LISTHEAD(uiapplication->metadata, tmp8);
1094 SAFE_LISTHEAD(uiapplication->image, tmp9);
1095 SAFE_LISTHEAD(uiapplication->permission, tmp10);
1096 SAFE_LISTHEAD(uiapplication->datacontrol, tmp11);
1101 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile)
1103 /*TODO: once policy is set*/
1104 __save_xml_attribute(reader, "name", &deviceprofile->name, NULL);
1108 static int __ps_process_font(xmlTextReaderPtr reader, font_x *font)
1110 /*TODO: once policy is set*/
1114 static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme)
1116 /*TODO: once policy is set*/
1120 static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon)
1122 /*TODO: once policy is set*/
1126 static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime)
1128 /*TODO: once policy is set*/
1132 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx)
1134 _LOGD("__start_process\n");
1135 const xmlChar *node;
1138 label_x *tmp1 = NULL;
1139 author_x *tmp2 = NULL;
1140 description_x *tmp3 = NULL;
1141 license_x *tmp4 = NULL;
1142 uiapplication_x *tmp5 = NULL;
1143 daemon_x *tmp6 = NULL;
1144 theme_x *tmp7 = NULL;
1145 font_x *tmp8 = NULL;
1147 icon_x *tmp10 = NULL;
1148 compatibility_x *tmp11 = NULL;
1149 deviceprofile_x *tmp12 = NULL;
1150 privileges_x *tmp13 = NULL;
1152 depth = xmlTextReaderDepth(reader);
1153 while ((ret = __next_child_element(reader, depth))) {
1154 node = xmlTextReaderConstName(reader);
1156 _LOGD("xmlTextReaderConstName value is NULL\n");
1160 if (!strcmp(ASCII(node), "label")) {
1161 label_x *label = malloc(sizeof(label_x));
1162 if (label == NULL) {
1163 _LOGD("Malloc Failed\n");
1166 memset(label, '\0', sizeof(label_x));
1167 LISTADD(mfx->label, label);
1168 ret = __ps_process_label(reader, label);
1169 } else if (!strcmp(ASCII(node), "author")) {
1170 author_x *author = malloc(sizeof(author_x));
1171 if (author == NULL) {
1172 _LOGD("Malloc Failed\n");
1175 memset(author, '\0', sizeof(author_x));
1176 LISTADD(mfx->author, author);
1177 ret = __ps_process_author(reader, author);
1178 } else if (!strcmp(ASCII(node), "description")) {
1179 description_x *description = malloc(sizeof(description_x));
1180 if (description == NULL) {
1181 _LOGD("Malloc Failed\n");
1184 memset(description, '\0', sizeof(description_x));
1185 LISTADD(mfx->description, description);
1186 ret = __ps_process_description(reader, description);
1187 } else if (!strcmp(ASCII(node), "license")) {
1188 license_x *license = malloc(sizeof(license_x));
1189 if (license == NULL) {
1190 _LOGD("Malloc Failed\n");
1193 memset(license, '\0', sizeof(license_x));
1194 LISTADD(mfx->license, license);
1195 ret = __ps_process_license(reader, license);
1196 } else if (!strcmp(ASCII(node), "privileges")) {
1197 privileges_x *privileges = malloc(sizeof(privileges_x));
1198 if (privileges == NULL) {
1199 _LOGD("Malloc Failed\n");
1202 memset(privileges, '\0', sizeof(privileges_x));
1203 LISTADD(mfx->privileges, privileges);
1204 ret = __ps_process_privileges(reader, privileges);
1205 } else if (!strcmp(ASCII(node), "ui-application")) {
1206 uiapplication_x *uiapplication = malloc(sizeof(uiapplication_x));
1207 if (uiapplication == NULL) {
1208 _LOGD("Malloc Failed\n");
1211 memset(uiapplication, '\0', sizeof(uiapplication_x));
1212 LISTADD(mfx->uiapplication, uiapplication);
1213 ret = __ps_process_uiapplication(reader, uiapplication);
1214 } else if (!strcmp(ASCII(node), "service-application")) {
1215 uiapplication_x *uiapplication = malloc(sizeof(uiapplication_x));
1216 if (uiapplication == NULL) {
1217 _LOGD("Malloc Failed\n");
1220 memset(uiapplication, '\0', sizeof(uiapplication_x));
1221 LISTADD(mfx->uiapplication, uiapplication);
1222 ret = __ps_process_uiapplication(reader, uiapplication);
1223 FREE_AND_STRDUP("svcapp", uiapplication->component_type);
1224 } else if (!strcmp(ASCII(node), "daemon")) {
1225 daemon_x *daemon = malloc(sizeof(daemon_x));
1226 if (daemon == NULL) {
1227 _LOGD("Malloc Failed\n");
1230 memset(daemon, '\0', sizeof(daemon_x));
1231 LISTADD(mfx->daemon, daemon);
1232 ret = __ps_process_daemon(reader, daemon);
1233 } else if (!strcmp(ASCII(node), "theme")) {
1234 theme_x *theme = malloc(sizeof(theme_x));
1235 if (theme == NULL) {
1236 _LOGD("Malloc Failed\n");
1239 memset(theme, '\0', sizeof(theme_x));
1240 LISTADD(mfx->theme, theme);
1241 ret = __ps_process_theme(reader, theme);
1242 } else if (!strcmp(ASCII(node), "font")) {
1243 font_x *font = malloc(sizeof(font_x));
1245 _LOGD("Malloc Failed\n");
1248 memset(font, '\0', sizeof(font_x));
1249 LISTADD(mfx->font, font);
1250 ret = __ps_process_font(reader, font);
1251 } else if (!strcmp(ASCII(node), "ime")) {
1252 ime_x *ime = malloc(sizeof(ime_x));
1254 _LOGD("Malloc Failed\n");
1257 memset(ime, '\0', sizeof(ime_x));
1258 LISTADD(mfx->ime, ime);
1259 ret = __ps_process_ime(reader, ime);
1260 } else if (!strcmp(ASCII(node), "icon")) {
1261 icon_x *icon = malloc(sizeof(icon_x));
1263 _LOGD("Malloc Failed\n");
1266 memset(icon, '\0', sizeof(icon_x));
1267 LISTADD(mfx->icon, icon);
1268 ret = __ps_process_icon(reader, icon);
1269 } else if (!strcmp(ASCII(node), "profile")) {
1270 deviceprofile_x *deviceprofile = malloc(sizeof(deviceprofile_x));
1271 if (deviceprofile == NULL) {
1272 _LOGD("Malloc Failed\n");
1275 memset(deviceprofile, '\0', sizeof(deviceprofile_x));
1276 LISTADD(mfx->deviceprofile, deviceprofile);
1277 ret = __ps_process_deviceprofile(reader, deviceprofile);
1278 } else if (!strcmp(ASCII(node), "compatibility")) {
1279 compatibility_x *compatibility = malloc(sizeof(compatibility_x));
1280 if (compatibility == NULL) {
1281 _LOGD("Malloc Failed\n");
1284 memset(compatibility, '\0', sizeof(compatibility_x));
1285 LISTADD(mfx->compatibility, compatibility);
1286 ret = __ps_process_compatibility(reader, compatibility);
1287 } else if (!strcmp(ASCII(node), "shortcut-list")) {
1289 } else if (!strcmp(ASCII(node), "livebox")) { /**< @todo will be deprecated soon */
1291 } else if (!strcmp(ASCII(node), "dynamicbox")) {
1293 } else if (!strcmp(ASCII(node), "account")) {
1295 } else if (!strcmp(ASCII(node), "notifications")) {
1297 } else if (!strcmp(ASCII(node), "ime")) {
1303 _LOGD("Processing manifest failed\n");
1308 SAFE_LISTHEAD(mfx->label, tmp1);
1309 SAFE_LISTHEAD(mfx->author, tmp2);
1310 SAFE_LISTHEAD(mfx->description, tmp3);
1311 SAFE_LISTHEAD(mfx->license, tmp4);
1312 SAFE_LISTHEAD(mfx->uiapplication, tmp5);
1313 SAFE_LISTHEAD(mfx->daemon, tmp6);
1314 SAFE_LISTHEAD(mfx->theme, tmp7);
1315 SAFE_LISTHEAD(mfx->font, tmp8);
1316 SAFE_LISTHEAD(mfx->ime, tmp9);
1317 SAFE_LISTHEAD(mfx->icon, tmp10);
1318 SAFE_LISTHEAD(mfx->compatibility, tmp11);
1319 SAFE_LISTHEAD(mfx->deviceprofile, tmp12);
1320 SAFE_LISTHEAD(mfx->privileges, tmp13);
1325 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx)
1327 const xmlChar *node;
1330 if ((ret = __next_child_element(reader, -1))) {
1331 node = xmlTextReaderConstName(reader);
1332 retvm_if(!node, PM_PARSER_R_ERROR, "xmlTextReaderConstName value is NULL\n");
1334 if (!strcmp(ASCII(node), "manifest")) {
1335 __save_xml_attribute(reader, "xmlns", &mfx->ns, NULL);
1336 __save_xml_attribute(reader, "package", &mfx->package, NULL);
1337 retvm_if(mfx->package == NULL, PM_PARSER_R_ERROR, "package cant be NULL, package field is mandatory\n");
1338 __save_xml_attribute(reader, "version", &mfx->version, NULL);
1339 __save_xml_attribute(reader, "size", &mfx->package_size, NULL);
1340 __save_xml_attribute(reader, "install-location", &mfx->installlocation, "internal-only");
1341 __save_xml_attribute(reader, "type", &mfx->type, NULL);
1342 __save_xml_attribute(reader, "root_path", &mfx->root_path, NULL);
1343 __save_xml_attribute(reader, "csc_path", &mfx->csc_path, NULL);
1344 __save_xml_attribute(reader, "appsetting", &mfx->appsetting, "false");
1345 __save_xml_attribute(reader, "storeclient-id", &mfx->storeclient_id, NULL);
1346 __save_xml_attribute(reader, "nodisplay-setting", &mfx->nodisplay_setting, "false");
1347 __save_xml_attribute(reader, "url", &mfx->package_url, NULL);
1348 __save_xml_attribute(reader, "support-disable", &mfx->support_disable, "false");
1349 __save_xml_attribute(reader, "mother-package", &mfx->mother_package, "false");
1352 if (xmlTextReaderGetAttribute(reader, XMLCHAR("support-reset"))) {
1353 mfx->support_reset = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("support-reset")));
1354 mfx->use_reset = strdup("false");
1356 mfx->use_reset = strdup("true");
1359 __save_xml_supportmode(reader, mfx);
1360 __save_xml_installedtime(mfx);
1361 __save_xml_defaultvalue(mfx);
1363 ret = __start_process(reader, mfx);
1365 _LOGD("No Manifest element found\n");
1373 static char* __convert_to_system_locale(const char *mlocale)
1375 if (mlocale == NULL)
1377 char *locale = NULL;
1378 locale = (char *)calloc(1, 6);
1380 _LOGE("Malloc Failed\n");
1384 strncpy(locale, mlocale, 2);
1385 strncat(locale, "_", 1);
1386 locale[3] = toupper(mlocale[3]);
1387 locale[4] = toupper(mlocale[4]);
1391 static int __ail_change_info(int op, const char *appid)
1393 void *lib_handle = NULL;
1394 int (*ail_desktop_operation) (const char *);
1398 if ((lib_handle = dlopen(LIBAIL_PATH, RTLD_LAZY)) == NULL) {
1399 _LOGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAIL_PATH);
1406 aop = "ail_desktop_add";
1409 aop = "ail_desktop_update";
1412 aop = "ail_desktop_remove";
1415 aop = "ail_desktop_clean";
1418 aop = "ail_desktop_fota";
1425 if ((ail_desktop_operation =
1426 dlsym(lib_handle, aop)) == NULL || dlerror() != NULL) {
1427 _LOGE("can not find symbol \n");
1431 ret = ail_desktop_operation(appid);
1435 dlclose(lib_handle);
1441 /* desktop shoud be generated automatically based on manifest */
1442 /* Currently removable, taskmanage, etc fields are not considerd. it will be decided soon.*/
1443 static int __ps_make_nativeapp_desktop(manifest_x * mfx, const char *manifest, ACTION_TYPE action)
1447 char filepath[PKG_STRING_LEN_MAX] = "";
1449 char *buftemp = NULL;
1450 char *locale = NULL;
1452 buf = (char *)calloc(1, BUFMAX);
1454 _LOGE("Malloc Failed\n");
1458 buftemp = (char *)calloc(1, BUFMAX);
1460 _LOGE("Malloc Failed\n");
1465 if (action == ACTION_UPGRADE)
1466 __ail_change_info(AIL_CLEAN, mfx->package);
1468 for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) {
1470 if (manifest != NULL) {
1471 /* skip making a deskfile and update ail, if preload app is updated */
1472 if(strstr(manifest, MANIFEST_RO_PREFIX)) {
1473 __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid);
1474 _LOGE("preload app is update : skip and update ail : %s", manifest);
1479 if(mfx->readonly && !strcasecmp(mfx->readonly, "True"))
1480 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RO_PATH, mfx->uiapplication->appid);
1482 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, mfx->uiapplication->appid);
1484 /* skip if desktop exists
1485 if (access(filepath, R_OK) == 0)
1489 file = fopen(filepath, "w");
1492 _LOGS("Can't open %s", filepath);
1494 FREE_AND_NULL(buftemp);
1498 snprintf(buf, BUFMAX, "[Desktop Entry]\n");
1499 fwrite(buf, 1, strlen(buf), file);
1501 for( ; mfx->uiapplication->label ; mfx->uiapplication->label = mfx->uiapplication->label->next) {
1502 if(!strcmp(mfx->uiapplication->label->lang, DEFAULT_LOCALE)) {
1503 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
1505 locale = __convert_to_system_locale(mfx->uiapplication->label->lang);
1506 snprintf(buf, BUFMAX, "Name[%s]=%s\n", locale,
1507 mfx->uiapplication->label->text);
1508 FREE_AND_NULL(locale);
1510 fwrite(buf, 1, strlen(buf), file);
1513 if(mfx->uiapplication->label && mfx->uiapplication->label->text) {
1514 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
1515 fwrite(buf, 1, strlen(buf), file);
1518 else if(mfx->label && mfx->label->text) {
1519 snprintf(buf, BUFMAX, "Name=%s\n", mfx->label->text);
1520 fwrite(buf, 1, strlen(buf), file);
1522 snprintf(buf, BUFMAX, "Name=%s\n", mfx->package);
1523 fwrite(buf, 1, strlen(buf), file);
1528 snprintf(buf, BUFMAX, "Type=Application\n");
1529 fwrite(buf, 1, strlen(buf), file);
1531 if(mfx->uiapplication->exec) {
1532 snprintf(buf, BUFMAX, "Exec=%s\n", mfx->uiapplication->exec);
1533 fwrite(buf, 1, strlen(buf), file);
1536 if(mfx->uiapplication->icon && mfx->uiapplication->icon->text) {
1537 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->uiapplication->icon->text);
1538 fwrite(buf, 1, strlen(buf), file);
1539 } else if(mfx->icon && mfx->icon->text) {
1540 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->icon->text);
1541 fwrite(buf, 1, strlen(buf), file);
1545 if(mfx->uiapplication && mfx->uiapplication->appsvc) {
1546 appsvc_x *asvc = mfx->uiapplication->appsvc;
1548 const char *mime = NULL;
1549 const char *mime_delim = "; ";
1552 strncpy(buf, "MimeType=", BUFMAX-1);
1558 _LOGD("MIME type: %s\n", mime);
1559 strncat(buf, mime, BUFMAX-strlen(buf)-1);
1561 strncat(buf, mime_delim, BUFMAX-strlen(buf)-1);
1569 _LOGD("MIME types: buf[%s]\n", buf);
1570 _LOGD("MIME count: %d\n", mime_count);
1572 fwrite(buf, 1, strlen(buf), file);
1576 snprintf(buf, BUFMAX, "Version=%s\n", mfx->version);
1577 fwrite(buf, 1, strlen(buf), file);
1580 if(mfx->uiapplication->nodisplay) {
1581 snprintf(buf, BUFMAX, "NoDisplay=%s\n", mfx->uiapplication->nodisplay);
1582 fwrite(buf, 1, strlen(buf), file);
1585 if(mfx->uiapplication->categories) {
1586 snprintf(buf, BUFMAX, "Categories=%s\n", mfx->uiapplication->categories);
1587 fwrite(buf, 1, strlen(buf), file);
1590 if(mfx->uiapplication->taskmanage && !strcasecmp(mfx->uiapplication->taskmanage, "False")) {
1591 snprintf(buf, BUFMAX, "X-TIZEN-TaskManage=False\n");
1592 fwrite(buf, 1, strlen(buf), file);
1595 if(mfx->uiapplication->enabled && !strcasecmp(mfx->uiapplication->enabled, "False")) {
1596 snprintf(buf, BUFMAX, "X-TIZEN-Enabled=False\n");
1597 fwrite(buf, 1, strlen(buf), file);
1600 if(mfx->uiapplication->hwacceleration) {
1601 snprintf(buf, BUFMAX, "Hw-Acceleration=%s\n", mfx->uiapplication->hwacceleration);
1602 fwrite(buf, 1, strlen(buf), file);
1605 if(mfx->uiapplication->multiple && !strcasecmp(mfx->uiapplication->multiple, "True")) {
1606 snprintf(buf, BUFMAX, "X-TIZEN-Multiple=True\n");
1607 fwrite(buf, 1, strlen(buf), file);
1610 if(mfx->uiapplication->extraid) {
1611 snprintf(buf, BUFMAX, "X-TIZEN-PackageID=%s\n", mfx->uiapplication->extraid);
1612 fwrite(buf, 1, strlen(buf), file);
1615 if(mfx->removable && !strcasecmp(mfx->removable, "False")) {
1616 snprintf(buf, BUFMAX, "X-TIZEN-Removable=False\n");
1617 fwrite(buf, 1, strlen(buf), file);
1621 snprintf(buf, BUFMAX, "X-TIZEN-PackageType=%s\n", mfx->type);
1622 fwrite(buf, 1, strlen(buf), file);
1625 if(mfx->uiapplication->submode && !strcasecmp(mfx->uiapplication->submode, "True")) {
1626 snprintf(buf, BUFMAX, "X-TIZEN-Submode=%s\n", mfx->uiapplication->submode);
1627 fwrite(buf, 1, strlen(buf), file);
1628 snprintf(buf, BUFMAX, "X-TIZEN-SubmodeMainid=%s\n", mfx->uiapplication->submode_mainid);
1629 fwrite(buf, 1, strlen(buf), file);
1632 snprintf(buf, BUFMAX, "X-TIZEN-PkgID=%s\n", mfx->package);
1633 fwrite(buf, 1, strlen(buf), file);
1636 snprintf(buf, BUFMAX, "X-TIZEN-InstalledStorage=%s\n", mfx->installed_storage);
1637 fwrite(buf, 1, strlen(buf), file);
1639 // snprintf(buf, BUFMAX, "X-TIZEN-PackageType=rpm\n");
1640 // fwrite(buf, 1, strlen(buf), file);
1643 if(mfx->uiapplication->appsvc) {
1644 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
1645 _LOGD("buf[%s]\n", buf);
1648 uiapplication_x *up = mfx->uiapplication;
1649 appsvc_x *asvc = NULL;
1650 operation_x *op = NULL;
1653 subapp_x *sub = NULL;
1654 const char *operation = NULL;
1655 const char *mime = NULL;
1656 const char *uri = NULL;
1657 const char *subapp = NULL;
1662 while(asvc != NULL) {
1663 op = asvc->operation;
1666 operation = op->name;
1685 strncpy(buftemp, buf, BUFMAX);
1686 snprintf(buf, BUFMAX, "%s;", buftemp);
1690 strncpy(buftemp, buf, BUFMAX);
1691 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
1692 _LOGD("buf[%s]\n", buf);
1697 } while(ui != NULL);
1701 }while(sub != NULL);
1714 fwrite(buf, 1, strlen(buf), file);
1716 // strncpy(buftemp, buf, BUFMAX);
1717 // snprintf(buf, BUFMAX, "%s\n", buftemp);
1718 // fwrite(buf, 1, strlen(buf), file);
1725 if (action == ACTION_FOTA)
1726 __ail_change_info(AIL_FOTA, mfx->uiapplication->appid);
1728 __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid);
1732 FREE_AND_NULL(buftemp);
1737 static int __ps_remove_nativeapp_desktop(manifest_x *mfx)
1739 char filepath[PKG_STRING_LEN_MAX] = "";
1741 uiapplication_x *uiapplication = mfx->uiapplication;
1743 for(; uiapplication; uiapplication=uiapplication->next) {
1744 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, uiapplication->appid);
1746 __ail_change_info(AIL_REMOVE, uiapplication->appid);
1748 ret = remove(filepath);
1756 void __add_preload_info(manifest_x * mfx, const char *manifest)
1758 if(strstr(manifest, MANIFEST_RO_PREFIX)) {
1759 FREE_AND_NULL(mfx->readonly);
1760 mfx->readonly = strdup("True");
1762 FREE_AND_NULL(mfx->preload);
1763 mfx->preload = strdup("True");
1765 FREE_AND_NULL(mfx->removable);
1766 mfx->removable = strdup("False");
1768 FREE_AND_NULL(mfx->system);
1769 mfx->system = strdup("True");
1773 static int __check_preload_updated(manifest_x * mfx, const char *manifest)
1775 char filepath[PKG_STRING_LEN_MAX] = "";
1777 uiapplication_x *uiapplication = mfx->uiapplication;
1779 if(strstr(manifest, MANIFEST_RO_PREFIX)) {
1780 /* if preload app is updated, then remove previous desktop file on RW*/
1781 for(; uiapplication; uiapplication=uiapplication->next) {
1782 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, uiapplication->appid);
1783 ret = remove(filepath);
1788 /* if downloaded app is updated, then update tag set true*/
1789 FREE_AND_NULL(mfx->update);
1790 mfx->update = strdup("true");
1796 static int __get_appid_list(const char *pkgid, void *user_data)
1803 sqlite3_stmt *stmt = NULL;
1804 sqlite3 *pkgmgr_parser_db;
1806 char *query = sqlite3_mprintf("select app_id from package_app_info where package=%Q", pkgid);
1808 ret = db_util_open(PKGMGR_PARSER_DB_FILE, &pkgmgr_parser_db, 0);
1809 if (ret != SQLITE_OK) {
1810 _LOGE("open fail\n");
1811 sqlite3_free(query);
1814 ret = sqlite3_prepare_v2(pkgmgr_parser_db, query, strlen(query), &stmt, NULL);
1815 if (ret != SQLITE_OK) {
1816 _LOGE("prepare_v2 fail\n");
1817 sqlite3_close(pkgmgr_parser_db);
1818 sqlite3_free(query);
1822 cols = sqlite3_column_count(stmt);
1825 ret = sqlite3_step(stmt);
1826 if(ret == SQLITE_ROW) {
1827 for(col = 0; col < cols; col++)
1829 appid = (char*)sqlite3_column_text(stmt, col);
1830 _LOGS("success find appid[%s]\n", appid);
1831 (*(GList**)user_data) = g_list_append((*(GList**)user_data), g_strdup(appid));
1838 sqlite3_finalize(stmt);
1839 sqlite3_close(pkgmgr_parser_db);
1840 sqlite3_free(query);
1844 void __call_uninstall_plugin(const char *pkgid, GList *appid_list)
1849 if (pkgid == NULL) {
1850 _LOGD("pkgid is null\n");
1854 tmp_list = appid_list;
1855 _pkgmgr_parser_plugin_open_db();
1857 _pkgmgr_parser_plugin_uninstall_plugin(PKGMGR_PARSER_PLUGIN_TAG, pkgid, pkgid);
1860 appid = (char *)tmp_list->data;
1862 _pkgmgr_parser_plugin_uninstall_plugin(PKGMGR_PARSER_PLUGIN_METADATA, pkgid, appid);
1863 _pkgmgr_parser_plugin_uninstall_plugin(PKGMGR_PARSER_PLUGIN_CATEGORY, pkgid, appid);
1865 tmp_list = g_list_next(tmp_list);
1868 _pkgmgr_parser_plugin_close_db();
1871 static int __delete_pkgid_info_for_uninstallation(const char *pkgid)
1873 retvm_if(pkgid == NULL, PM_PARSER_R_ERROR, "argument supplied is NULL");
1877 GList *appid_list = NULL;
1879 char filepath[PKG_STRING_LEN_MAX] = "";
1881 _LOGD("Start uninstall for pkgid : delete pkgid[%s]\n", pkgid);
1884 ret = __get_appid_list(pkgid, &appid_list);
1885 retvm_if(ret < 0, PM_PARSER_R_ERROR, "Fail to get app_list");
1887 _LOGD("call plugin uninstall\n");
1889 /*call plugin uninstall*/
1890 __call_uninstall_plugin(pkgid, appid_list);
1892 /* delete pkgmgr db */
1893 ret = pkgmgr_parser_delete_pkgid_info_from_db(pkgid);
1895 _LOGD("DB pkgid info Delete failed\n");
1897 _LOGD("DB pkgid info Delete Success\n");
1899 /* delete desktop file*/
1902 appid = (char *)tmp->data;
1904 _LOGD("Delete appid[%s] info from db\n", appid);
1906 ret = pkgmgr_parser_delete_appid_info_from_db(appid);
1908 _LOGD("DB appid info Delete failed\n");
1910 _LOGD("DB appid info Delete Success\n");
1912 ret = __ail_change_info(AIL_REMOVE, appid);
1914 _LOGD("AIL_REMOVE failed\n");
1916 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, appid);
1917 if (access(filepath, R_OK) == 0) {
1918 ret = remove(filepath);
1920 _LOGD("remove failed\n");
1924 tmp = g_list_next(tmp);
1927 g_list_free(appid_list);
1929 _LOGD("Finish : uninstall for pkgid\n");
1931 return PM_PARSER_R_OK;
1934 static int __pkgmgr_db_check_update_condition(manifest_x *mfx)
1937 char *preload = NULL;
1938 char *system = NULL;
1939 char *csc_path = NULL;
1940 char *installed_storage = NULL;
1941 sqlite3_stmt *stmt = NULL;
1942 sqlite3 *pkgmgr_parser_db;
1945 ret = _pkgmgr_db_open(PKGMGR_PARSER_DB_FILE, &pkgmgr_parser_db);
1946 retvm_if(ret != PM_PARSER_R_OK, PM_PARSER_R_ERROR, "_pkgmgr_db_open failed\n");
1948 query = sqlite3_mprintf("select package_preload from package_info where package=%Q", mfx->package);
1950 ret = _pkgmgr_db_prepare(pkgmgr_parser_db, query, &stmt);
1951 tryvm_if(ret != PM_PARSER_R_OK, ret = PM_PARSER_R_ERROR, "_pkgmgr_db_prepare failed[%s]\n", query);
1953 ret = _pkgmgr_db_step(stmt);
1954 tryvm_if(ret != PM_PARSER_R_OK, ret = PM_PARSER_R_ERROR, "_pkgmgr_db_step failed\n");
1956 ret = _pkgmgr_db_get_str(stmt, 0, &preload);
1957 tryvm_if(ret != PM_PARSER_R_OK, ret = PM_PARSER_R_ERROR, "_pkgmgr_db_get_str failed\n");
1959 if (strcasecmp(preload, "true") == 0) {
1960 FREE_AND_NULL(mfx->preload);
1961 mfx->preload = strdup("true");
1964 _pkgmgr_db_finalize(stmt);
1965 sqlite3_free(query);
1967 query = sqlite3_mprintf("select package_system from package_info where package=%Q", mfx->package);
1969 ret = _pkgmgr_db_prepare(pkgmgr_parser_db, query, &stmt);
1970 tryvm_if(ret != PM_PARSER_R_OK, ret = PM_PARSER_R_ERROR, "_pkgmgr_db_prepare failed[%s]\n", query);
1972 ret = _pkgmgr_db_step(stmt);
1973 tryvm_if(ret != PM_PARSER_R_OK, ret = PM_PARSER_R_ERROR, "_pkgmgr_db_step failed\n");
1975 ret = _pkgmgr_db_get_str(stmt, 0, &system);
1976 tryvm_if(ret != PM_PARSER_R_OK, ret = PM_PARSER_R_ERROR, "_pkgmgr_db_get_str failed\n");
1978 if (strcasecmp(system, "true") == 0) {
1979 FREE_AND_NULL(mfx->system);
1980 mfx->system = strdup("true");
1983 _pkgmgr_db_finalize(stmt);
1984 sqlite3_free(query);
1986 query = sqlite3_mprintf("select csc_path from package_info where package=%Q", mfx->package);
1988 ret = _pkgmgr_db_prepare(pkgmgr_parser_db, query, &stmt);
1989 tryvm_if(ret != PM_PARSER_R_OK, ret = PM_PARSER_R_ERROR, "_pkgmgr_db_prepare failed[%s]\n", query);
1991 ret = _pkgmgr_db_step(stmt);
1992 tryvm_if(ret != PM_PARSER_R_OK, ret = PM_PARSER_R_ERROR, "_pkgmgr_db_step failed\n");
1994 ret = _pkgmgr_db_get_str(stmt, 0, &csc_path);
1995 tryvm_if(ret != PM_PARSER_R_OK, ret = PM_PARSER_R_ERROR, "_pkgmgr_db_get_str failed\n");
1997 if (csc_path != NULL) {
1999 FREE_AND_NULL(mfx->csc_path);
2000 mfx->csc_path = strdup(csc_path);
2003 _pkgmgr_db_finalize(stmt);
2004 sqlite3_free(query);
2006 query = sqlite3_mprintf("select installed_storage from package_info where package=%Q", mfx->package);
2008 ret = _pkgmgr_db_prepare(pkgmgr_parser_db, query, &stmt);
2009 tryvm_if(ret != PM_PARSER_R_OK, ret = PM_PARSER_R_ERROR, "_pkgmgr_db_prepare failed[%s]\n", query);
2011 ret = _pkgmgr_db_step(stmt);
2012 tryvm_if(ret != PM_PARSER_R_OK, ret = PM_PARSER_R_ERROR, "_pkgmgr_db_step failed\n");
2014 ret = _pkgmgr_db_get_str(stmt, 0, &installed_storage);
2015 tryvm_if(ret != PM_PARSER_R_OK, ret = PM_PARSER_R_ERROR, "_pkgmgr_db_get_str failed\n");
2017 if (strcasecmp(installed_storage, "installed_external") == 0) {
2018 FREE_AND_NULL(mfx->installed_storage);
2019 mfx->installed_storage = strdup("installed_external");
2022 ret = PM_PARSER_R_OK;
2026 sqlite3_free(query);
2027 _pkgmgr_db_finalize(stmt);
2028 _pkgmgr_db_close(pkgmgr_parser_db);
2033 static int __pkgmgr_db_check_disable_condition(manifest_x *mfx)
2036 char *package_disable = NULL;
2037 sqlite3_stmt *stmt = NULL;
2038 sqlite3 *pkgmgr_parser_db;
2041 ret = _pkgmgr_db_open(PKGMGR_PARSER_DB_FILE, &pkgmgr_parser_db);
2042 retvm_if(ret != PM_PARSER_R_OK, PM_PARSER_R_ERROR, "_pkgmgr_db_open failed\n");
2044 query = sqlite3_mprintf("select package_disable from package_info where package=%Q", mfx->package);
2046 ret = _pkgmgr_db_prepare(pkgmgr_parser_db, query, &stmt);
2047 tryvm_if(ret != PM_PARSER_R_OK, ret = PM_PARSER_R_ERROR, "_pkgmgr_db_prepare failed[%s]\n", query);
2049 ret = _pkgmgr_db_step(stmt);
2050 tryvm_if(ret != PM_PARSER_R_OK, ret = PM_PARSER_R_ERROR, "_pkgmgr_db_step failed\n");
2052 ret = _pkgmgr_db_get_str(stmt, 0, &package_disable);
2053 tryvm_if(ret != PM_PARSER_R_OK, ret = PM_PARSER_R_ERROR, "_pkgmgr_db_get_str failed\n");
2055 if (strcasecmp(package_disable, "true") == 0) {
2063 sqlite3_free(query);
2064 _pkgmgr_db_finalize(stmt);
2065 _pkgmgr_db_close(pkgmgr_parser_db);
2070 API int pkgmgr_parser_check_mdm_policy_for_uninstallation(const char *manifest)
2072 int ret = PM_PARSER_R_OK;
2073 manifest_x *mfx = NULL;
2075 mfx = pkgmgr_parser_process_manifest_xml(manifest);
2076 retvm_if(mfx == NULL, PM_PARSER_R_OK, "argument supplied is NULL");
2078 ret = __ps_check_mdm_policy(mfx, ACTION_UNINSTALL);
2080 _LOGE("pkg[%s] violate mdm policy.", mfx->package);
2082 pkgmgr_parser_free_manifest_xml(mfx);
2087 API int pkgmgr_parser_create_desktop_file(manifest_x *mfx)
2091 _LOGD("Manifest pointer is NULL\n");
2094 ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_INSTALL);
2096 _LOGD("Creating desktop file failed\n");
2098 _LOGD("Creating desktop file Success\n");
2102 API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
2104 _pkgmgrinfo_basic_free_manifest_x(mfx);
2107 API manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest)
2109 _LOGD("parsing start\n");
2110 xmlTextReaderPtr reader;
2111 manifest_x *mfx = NULL;
2113 reader = xmlReaderForFile(manifest, NULL, 0);
2115 mfx = malloc(sizeof(manifest_x));
2117 memset(mfx, '\0', sizeof(manifest_x));
2118 if (__process_manifest(reader, mfx) < 0) {
2119 _LOGD("Parsing Failed\n");
2120 pkgmgr_parser_free_manifest_xml(mfx);
2123 _LOGD("Parsing Success\n");
2125 _LOGD("Memory allocation error\n");
2127 xmlFreeTextReader(reader);
2129 _LOGD("Unable to create xml reader\n");
2134 /* These APIs are intended to call parser directly */
2136 API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
2138 retvm_if(manifest == NULL, PM_PARSER_R_ERROR, "argument supplied is NULL");
2139 _LOGD("parsing manifest for installation: %s\n", manifest);
2141 manifest_x *mfx = NULL;
2146 mfx = pkgmgr_parser_process_manifest_xml(manifest);
2147 retvm_if(mfx == NULL, PM_PARSER_R_ERROR, "argument supplied is NULL");
2149 _LOGD("Parsing Finished\n");
2151 _LOGD("Generating the hash for manifest");
2152 hash = pkgmgrinfo_basic_generate_hash_for_file(manifest);
2155 _LOGD("Hash for [%s] file is [%s]\n",manifest,hash);
2158 ret = __ps_check_mdm_policy(mfx, ACTION_INSTALL);
2159 tryvm_if(ret == PM_PARSER_R_ERROR, ret = PM_PARSER_R_ERROR, "pkg[%s] violate mdm policy.", mfx->package);
2161 __add_preload_info(mfx, manifest);
2163 _LOGD("Added preload infomation\n");
2165 __ps_process_tag(mfx, tagv);
2167 ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
2169 ret = __delete_pkgid_info_for_uninstallation(mfx->package);
2170 ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
2171 retvm_if(ret == PM_PARSER_R_ERROR, PM_PARSER_R_ERROR, "DB Insert failed");
2174 _LOGD("DB Insert Success\n");
2176 _pkgmgr_parser_plugin_process_plugin(mfx, manifest, ACTION_INSTALL);
2178 ret = __check_action_fota(tagv);
2179 tryvm_if(ret == PM_PARSER_R_OK, ret = PM_PARSER_R_OK, "fota install called, dont need desktop generation\n");
2181 ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_INSTALL);
2184 _LOGD("Creating desktop file failed\n");
2186 _LOGD("Creating desktop file Success\n");
2190 pkgmgr_parser_free_manifest_xml(mfx);
2191 _LOGD("Free Done\n");
2194 return PM_PARSER_R_OK;
2197 API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
2199 retvm_if(manifest == NULL, PM_PARSER_R_ERROR, "argument supplied is NULL");
2200 _LOGD("parsing manifest for upgradation: %s\n", manifest);
2202 manifest_x *mfx = NULL;
2204 int package_disabled = 0;
2208 mfx = pkgmgr_parser_process_manifest_xml(manifest);
2209 retvm_if(mfx == NULL, PM_PARSER_R_ERROR, "argument supplied is NULL");
2211 _LOGD("Parsing Finished\n");
2213 _LOGD("Generating the hash for manifest");
2214 hash = pkgmgrinfo_basic_generate_hash_for_file(manifest);
2217 _LOGD("Hash for [%s] file is [%s]\n",manifest,hash);
2220 __add_preload_info(mfx, manifest);
2221 _LOGD("Added preload infomation\n");
2222 __check_preload_updated(mfx, manifest);
2224 if (__pkgmgr_db_check_disable_condition(mfx) == 1) {
2225 _LOGD("pkgid[%s] is disabed\n", mfx->package);
2226 package_disabled = 1;
2229 ret = __pkgmgr_db_check_update_condition(mfx);
2231 _LOGD("__pkgmgr_db_check_update_condition failed\n");
2233 ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
2234 retvm_if(ret == PM_PARSER_R_ERROR, PM_PARSER_R_ERROR, "DB Insert failed");
2235 _LOGD("DB Update Success\n");
2237 if (package_disabled == 1) {
2238 ret = pkgmgr_parser_disable_pkg(mfx->package, NULL);
2239 tryvm_if(ret != PM_PARSER_R_OK, ret = PM_PARSER_R_ERROR, "disable_pkg failed[%s]\n", mfx->package);
2242 _pkgmgr_parser_plugin_process_plugin(mfx, manifest, ACTION_UPGRADE);
2244 ret = __check_action_fota(tagv);
2245 tryvm_if(ret == PM_PARSER_R_OK, ret = PM_PARSER_R_OK, "fota install called, dont need desktop generation\n");
2247 ret = __ps_make_nativeapp_desktop(mfx, manifest, ACTION_UPGRADE);
2249 _LOGD("Creating desktop file failed\n");
2251 _LOGD("Creating desktop file Success\n");
2254 journal_appcore_app_updated(mfx->package);
2256 pkgmgr_parser_free_manifest_xml(mfx);
2257 _LOGD("Free Done\n");
2260 return PM_PARSER_R_OK;
2263 API int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[])
2265 retvm_if(manifest == NULL, PM_PARSER_R_ERROR, "argument supplied is NULL");
2267 manifest_x *mfx = NULL;
2269 if (!strstr(manifest, ".xml")) {
2270 _LOGD("manifest is pkgid[%s]\n", manifest);
2271 ret = __delete_pkgid_info_for_uninstallation(manifest);
2273 _LOGD("__delete_manifest_for_fota failed\n");
2275 return PM_PARSER_R_OK;
2278 _LOGD("parsing manifest for uninstallation: %s\n", manifest);
2281 mfx = pkgmgr_parser_process_manifest_xml(manifest);
2282 retvm_if(mfx == NULL, PM_PARSER_R_ERROR, "argument supplied is NULL");
2284 _LOGD("Parsing Finished\n");
2286 ret = __ps_check_mdm_policy(mfx, ACTION_UNINSTALL);
2287 retvm_if(ret == PM_PARSER_R_ERROR, PM_PARSER_R_ERROR, "pkg[%s] violate mdm policy.", mfx->package);
2289 __add_preload_info(mfx, manifest);
2290 _LOGD("Added preload infomation\n");
2292 _pkgmgr_parser_plugin_process_plugin(mfx, manifest, ACTION_UNINSTALL);
2294 ret = pkgmgr_parser_delete_manifest_info_from_db(mfx);
2296 _LOGD("DB Delete failed\n");
2298 _LOGD("DB Delete Success\n");
2300 ret = __ps_remove_nativeapp_desktop(mfx);
2302 _LOGD("Removing desktop file failed\n");
2304 _LOGD("Removing desktop file Success\n");
2306 pkgmgr_parser_free_manifest_xml(mfx);
2307 _LOGD("Free Done\n");
2310 return PM_PARSER_R_OK;
2313 API int pkgmgr_parser_parse_manifest_for_preload()
2315 return pkgmgr_parser_update_preload_info_in_db();
2318 API char *pkgmgr_parser_get_manifest_file(const char *pkgid)
2320 return __pkgid_to_manifest(pkgid);
2323 API int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
2325 return __ps_run_parser(docPtr, tag, ACTION_INSTALL, pkgid);
2328 API int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgid)
2330 return __ps_run_parser(docPtr, tag, ACTION_UPGRADE, pkgid);
2333 API int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
2335 return __ps_run_parser(docPtr, tag, ACTION_UNINSTALL, pkgid);
2338 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
2340 if (manifest == NULL) {
2341 _LOGE("manifest file is NULL\n");
2342 return PM_PARSER_R_EINVAL;
2344 int ret = PM_PARSER_R_OK;
2345 xmlSchemaParserCtxtPtr ctx = NULL;
2346 xmlSchemaValidCtxtPtr vctx = NULL;
2347 xmlSchemaPtr xschema = NULL;
2348 ctx = xmlSchemaNewParserCtxt(SCHEMA_FILE);
2350 _LOGE("xmlSchemaNewParserCtxt() Failed\n");
2351 return PM_PARSER_R_ERROR;
2353 xschema = xmlSchemaParse(ctx);
2354 if (xschema == NULL) {
2355 _LOGE("xmlSchemaParse() Failed\n");
2356 ret = PM_PARSER_R_ERROR;
2359 vctx = xmlSchemaNewValidCtxt(xschema);
2361 _LOGE("xmlSchemaNewValidCtxt() Failed\n");
2362 return PM_PARSER_R_ERROR;
2364 xmlSchemaSetValidErrors(vctx, (xmlSchemaValidityErrorFunc) fprintf, (xmlSchemaValidityWarningFunc) fprintf, stderr);
2365 ret = xmlSchemaValidateFile(vctx, manifest, 0);
2367 _LOGE("xmlSchemaValidateFile() failed\n");
2368 ret = PM_PARSER_R_ERROR;
2370 } else if (ret == 0) {
2371 _LOGE("Manifest is Valid\n");
2372 ret = PM_PARSER_R_OK;
2375 _LOGE("Manifest Validation Failed with error code %d\n", ret);
2376 ret = PM_PARSER_R_ERROR;
2382 xmlSchemaFreeValidCtxt(vctx);
2385 xmlSchemaFreeParserCtxt(ctx);
2388 xmlSchemaFree(xschema);
2393 API int pkgmgr_parser_enable_pkg(const char *pkgid, char *const tagv[])
2395 retvm_if(pkgid == NULL, PM_PARSER_R_ERROR, "pkgid is NULL.");
2398 char *manifest = NULL;
2399 manifest_x *mfx = NULL;
2401 ret = pkgmgr_parser_update_enabled_pkg_info_in_db(pkgid);
2403 _LOGD("pkgmgr_parser_update_enabled_pkg_info_in_db(%s) failed.\n", pkgid);
2405 _LOGD("pkgmgr_parser_update_enabled_pkg_info_in_db(%s) succeed.\n", pkgid);
2407 manifest = __pkgid_to_manifest(pkgid);
2408 retvm_if(manifest == NULL, PM_PARSER_R_ERROR, "manifest of pkgid(%s) is NULL.", pkgid);
2411 mfx = pkgmgr_parser_process_manifest_xml(manifest);
2412 tryvm_if(mfx == NULL, ret = PM_PARSER_R_ERROR, "process_manifest_xml(%s) failed\n", pkgid);
2414 _pkgmgr_parser_plugin_process_plugin(mfx, manifest, ACTION_INSTALL);
2416 ret = PM_PARSER_R_OK;
2420 pkgmgr_parser_free_manifest_xml(mfx);
2430 API int pkgmgr_parser_disable_pkg(const char *pkgid, char *const tagv[])
2432 retvm_if(pkgid == NULL, PM_PARSER_R_ERROR, "pkgid is NULL.");
2435 GList *appid_list = NULL;
2438 ret = __get_appid_list(pkgid, &appid_list);
2439 retvm_if(ret < 0, PM_PARSER_R_ERROR, "Fail to get app_list");
2441 _LOGD("call plugin uninstall\n");
2443 /*call plugin uninstall*/
2444 __call_uninstall_plugin(pkgid, appid_list);
2446 ret = pkgmgr_parser_update_disabled_pkg_info_in_db(pkgid);
2448 _LOGD("pkgmgr_parser_update_disabled_pkg_info_in_db(%s) failed.\n", pkgid);
2450 _LOGD("pkgmgr_parser_update_disabled_pkg_info_in_db(%s) succeed.\n", pkgid);
2452 g_list_free(appid_list);
2454 return PM_PARSER_R_OK;
2457 /* update aliasid entry in package-app-aliasid */
2458 API int pkgmgr_parser_insert_app_aliasid(void )
2460 return pkgmgr_parser_insert_app_aliasid_info_in_db();
2463 API int pkgmgr_parser_update_app_aliasid(void )
2465 return pkgmgr_parser_update_app_aliasid_info_in_db();