4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
7 * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
31 #include <libxml/parser.h>
32 #include <libxml/xmlreader.h>
33 #include <libxml/xmlschemas.h>
37 #include "pkgmgr_parser.h"
38 #include "pkgmgr_parser_internal.h"
39 #include "pkgmgr_parser_db.h"
40 #include "pkgmgr-info.h"
42 #define MANIFEST_RW_DIRECTORY "/opt/share/packages"
43 #define MANIFEST_RO_DIRECTORY "/usr/share/packages"
44 #define ASCII(s) (const char *)s
45 #define XMLCHAR(s) (const xmlChar *)s
57 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label);
58 static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege);
59 static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privileges);
60 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile);
61 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed);
62 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation);
63 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri);
64 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime);
65 static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp);
66 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition);
67 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notifiation);
68 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category);
69 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata);
70 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission);
71 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility);
72 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution);
73 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request);
74 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define);
75 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc);
76 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions);
77 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare);
78 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon);
79 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author);
80 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description);
81 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability);
82 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license);
83 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol);
84 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol);
85 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication);
86 static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication);
87 static int __ps_process_font(xmlTextReaderPtr reader, font_x *font);
88 static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme);
89 static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon);
90 static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime);
91 static void __ps_free_label(label_x *label);
92 static void __ps_free_privilege(privilege_x *privilege);
93 static void __ps_free_privileges(privileges_x *privileges);
94 static void __ps_free_deviceprofile(deviceprofile_x * deviceprofile);
95 static void __ps_free_allowed(allowed_x *allowed);
96 static void __ps_free_operation(operation_x *operation);
97 static void __ps_free_uri(uri_x *uri);
98 static void __ps_free_mime(mime_x *mime);
99 static void __ps_free_subapp(subapp_x *subapp);
100 static void __ps_free_condition(condition_x *condition);
101 static void __ps_free_notification(notification_x *notifiation);
102 static void __ps_free_category(category_x *category);
103 static void __ps_free_metadata(metadata_x *metadata);
104 static void __ps_free_permission(permission_x *permission);
105 static void __ps_free_compatibility(compatibility_x *compatibility);
106 static void __ps_free_resolution(resolution_x *resolution);
107 static void __ps_free_request(request_x *request);
108 static void __ps_free_define(define_x *define);
109 static void __ps_free_appsvc(appsvc_x *appsvc);
110 static void __ps_free_launchconditions(launchconditions_x *launchconditions);
111 static void __ps_free_datashare(datashare_x *datashare);
112 static void __ps_free_icon(icon_x *icon);
113 static void __ps_free_author(author_x *author);
114 static void __ps_free_description(description_x *description);
115 static void __ps_free_capability(capability_x *capability);
116 static void __ps_free_license(license_x *license);
117 static void __ps_free_appcontrol(appcontrol_x *appcontrol);
118 static void __ps_free_datacontrol(datacontrol_x *datacontrol);
119 static void __ps_free_uiapplication(uiapplication_x *uiapplication);
120 static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication);
121 static void __ps_free_font(font_x *font);
122 static void __ps_free_theme(theme_x *theme);
123 static void __ps_free_daemon(daemon_x *daemon);
124 static void __ps_free_ime(ime_x *ime);
125 static char *__pkgid_to_manifest(const char *pkgid);
126 static int __next_child_element(xmlTextReaderPtr reader, int depth);
127 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx);
128 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx);
129 static void __str_trim(char *input);
130 static char *__get_parser_plugin(const char *type);
131 static int __ps_run_parser(xmlDocPtr docPtr, const char *tag, ACTION_TYPE action, const char *pkgid);
132 static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid);
133 static void __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgid);
134 static void __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid);
135 static int __validate_appid(const char *pkgid, const char *appid, char **newappid);
137 static void __str_trim(char *input)
139 char *trim_str = input;
144 while (*input != 0) {
145 if (!isspace(*input)) {
156 static int __validate_appid(const char *pkgid, const char *appid, char **newappid)
158 if (!pkgid || !appid || !newappid) {
159 DBG("Arg supplied is NULL\n");
162 int pkglen = strlen(pkgid);
163 int applen = strlen(appid);
167 if (strncmp(appid, ".", 1) == 0) {
168 len = pkglen + applen + 1;
169 newapp = calloc(1,len);
170 if (newapp == NULL) {
171 DBG("Malloc failed\n");
174 strncpy(newapp, pkgid, pkglen);
175 strncat(newapp, appid, applen);
176 DBG("new appid is %s\n", newapp);
180 if (applen < pkglen) {
181 DBG("app id is not proper\n");
183 #ifdef _VALIDATE_APPID_
189 if (!strcmp(appid, pkgid)) {
190 DBG("appid is proper\n");
194 else if (strncmp(appid, pkgid, pkglen) == 0) {
195 ptr = strstr(appid, pkgid);
197 if (strncmp(ptr, ".", 1) == 0) {
198 DBG("appid is proper\n");
203 DBG("appid is not proper\n");
205 #ifdef _VALIDATE_APPID_
212 DBG("appid is not proper\n");
214 #ifdef _VALIDATE_APPID_
224 static char *__get_parser_plugin(const char *type)
227 char buffer[1024] = { 0 };
228 char temp_path[1024] = { 0 };
232 DBGE("invalid argument\n");
236 fp = fopen(PKG_PARSER_CONF_PATH, "r");
238 DBGE("no matching backendlib\n");
242 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
243 if (buffer[0] == '#')
248 if ((path = strstr(buffer, PKG_PARSERLIB)) != NULL) {
250 path = path + strlen(PKG_PARSERLIB);
256 memset(buffer, 0x00, 1024);
263 DBGE("no matching backendlib\n");
267 snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
269 return strdup(temp_path);
272 static int __ps_run_parser(xmlDocPtr docPtr, const char *tag,
273 ACTION_TYPE action, const char *pkgid)
275 char *lib_path = NULL;
276 void *lib_handle = NULL;
277 int (*plugin_install) (xmlDocPtr, const char *);
283 ac = "PKGMGR_PARSER_PLUGIN_INSTALL";
286 ac = "PKGMGR_PARSER_PLUGIN_UPGRADE";
288 case ACTION_UNINSTALL:
289 ac = "PKGMGR_PARSER_PLUGIN_UNINSTALL";
295 lib_path = __get_parser_plugin(tag);
300 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
301 DBGE("dlopen is failed lib_path[%s]\n", lib_path);
305 if ((plugin_install =
306 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
307 DBGE("can not find symbol \n");
311 ret = plugin_install(docPtr, pkgid);
321 static char *__pkgid_to_manifest(const char *pkgid)
327 DBGE("pkgid is NULL");
331 size = strlen(MANIFEST_RW_DIRECTORY) + strlen(pkgid) + 10;
332 manifest = malloc(size);
333 if (manifest == NULL) {
337 memset(manifest, '\0', size);
338 snprintf(manifest, size, MANIFEST_RW_DIRECTORY "/%s.xml", pkgid);
340 if (access(manifest, F_OK)) {
341 snprintf(manifest, size, MANIFEST_RO_DIRECTORY "/%s.xml", pkgid);
347 static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid)
352 DBG("__run_parser_prestep");
354 if (xmlTextReaderDepth(reader) != 1) {
355 DBGE("Node depth is not 1");
359 if (xmlTextReaderNodeType(reader) != 1) {
360 DBGE("Node type is not 1");
364 const xmlChar *value;
365 name = xmlTextReaderConstName(reader);
367 DBGE("TEST TEST TES\n");
368 name = BAD_CAST "--";
371 value = xmlTextReaderConstValue(reader);
372 DBG("%d %d %s %d %d",
373 xmlTextReaderDepth(reader),
374 xmlTextReaderNodeType(reader),
376 xmlTextReaderIsEmptyElement(reader), xmlTextReaderHasValue(reader));
379 DBG("ConstValue NULL");
381 if (xmlStrlen(value) > 40) {
382 DBG(" %.40s...", value);
388 name = xmlTextReaderConstName(reader);
390 DBGE("TEST TEST TES\n");
391 name = BAD_CAST "--";
394 xmlDocPtr docPtr = xmlTextReaderCurrentDoc(reader);
395 DBG("docPtr->URL %s\n", (char *)docPtr->URL);
396 xmlDocPtr copyDocPtr = xmlCopyDoc(docPtr, 1);
397 if (copyDocPtr == NULL)
399 xmlNode *rootElement = xmlDocGetRootElement(copyDocPtr);
400 if (rootElement == NULL)
402 xmlNode *cur_node = xmlFirstElementChild(rootElement);
403 if (cur_node == NULL)
405 xmlNode *temp = xmlTextReaderExpand(reader);
408 xmlNode *next_node = NULL;
409 while(cur_node != NULL) {
410 if ( (strcmp(ASCII(temp->name), ASCII(cur_node->name)) == 0) &&
411 (temp->line == cur_node->line) ) {
415 next_node = xmlNextElementSibling(cur_node);
416 xmlUnlinkNode(cur_node);
417 xmlFreeNode(cur_node);
418 cur_node = next_node;
421 if (cur_node == NULL)
423 next_node = xmlNextElementSibling(cur_node);
425 cur_node->next = NULL;
426 next_node->prev = NULL;
427 xmlFreeNodeList(next_node);
428 xmlSetTreeDoc(cur_node, copyDocPtr);
430 xmlSetTreeDoc(cur_node, copyDocPtr);
436 DBG("node type: %d, name: %s children->name: %s last->name: %s\n"
437 "parent->name: %s next->name: %s prev->name: %s\n",
438 cur_node->type, cur_node->name,
439 cur_node->children ? cur_node->children->name : "NULL",
440 cur_node->last ? cur_node->last->name : "NULL",
441 cur_node->parent ? cur_node->parent->name : "NULL",
442 cur_node->next ? cur_node->next->name : "NULL",
443 cur_node->prev ? cur_node->prev->name : "NULL");
445 FILE *fp = fopen("/opt/share/test.xml", "a");
446 xmlDocDump(fp, copyDocPtr);
451 ret = __ps_run_parser(copyDocPtr, ASCII(name), action, pkgid);
458 __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgid)
463 switch (xmlTextReaderNodeType(reader)) {
464 case XML_READER_TYPE_END_ELEMENT:
466 // DBG("XML_READER_TYPE_END_ELEMENT");
470 case XML_READER_TYPE_ELEMENT:
472 // Elements without closing tag don't receive
473 // XML_READER_TYPE_END_ELEMENT event.
475 const xmlChar *elementName =
476 xmlTextReaderLocalName(reader);
477 if (elementName == NULL) {
478 // DBG("elementName %s\n", (char *)elementName);
482 const xmlChar *nameSpace =
483 xmlTextReaderConstNamespaceUri(reader);
485 // DBG("nameSpace %s\n", (char *)nameSpace);
488 DBG("XML_READER_TYPE_ELEMENT %s, %s\n",
489 elementName ? elementName : "NULL",
490 nameSpace ? nameSpace : "NULL");
493 DBG("__run_parser_prestep pkgid[%s]\n", pkgid);
494 __run_parser_prestep(reader, action, pkgid);
498 for (tag = tagv[0]; tag; tag = tagv[++i])
499 if (strcmp(tag, ASCII(elementName)) == 0) {
500 DBG("__run_parser_prestep tag[%s] pkgid[%s]\n", tag, pkgid);
501 __run_parser_prestep(reader,
509 case XML_READER_TYPE_TEXT:
510 case XML_READER_TYPE_CDATA:
512 const xmlChar *value = xmlTextReaderConstValue(reader);
514 // DBG("value %s\n", value);
517 const xmlChar *lang = xmlTextReaderConstXmlLang(reader);
519 // DBG("lang\n", lang);
522 /* DBG("XML_READER_TYPE_TEXT %s, %s\n",
523 value ? value : "NULL", lang ? lang : "NULL");
528 // DBG("Ignoring Node of Type: %d", xmlTextReaderNodeType(reader));
534 __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid)
536 xmlTextReaderPtr reader;
540 docPtr = xmlReadFile(filename, NULL, 0);
541 reader = xmlReaderWalker(docPtr);
542 if (reader != NULL) {
543 ret = xmlTextReaderRead(reader);
545 __processNode(reader, action, tagv, pkgid);
546 ret = xmlTextReaderRead(reader);
548 xmlFreeTextReader(reader);
551 DBGE("%s : failed to parse", filename);
554 DBGE("Unable to open %s", filename);
558 static int __next_child_element(xmlTextReaderPtr reader, int depth)
560 int ret = xmlTextReaderRead(reader);
561 int cur = xmlTextReaderDepth(reader);
564 switch (xmlTextReaderNodeType(reader)) {
565 case XML_READER_TYPE_ELEMENT:
566 if (cur == depth + 1)
569 case XML_READER_TYPE_TEXT:
570 /*text is handled by each function separately*/
571 if (cur == depth + 1)
574 case XML_READER_TYPE_END_ELEMENT:
583 ret = xmlTextReaderRead(reader);
584 cur = xmlTextReaderDepth(reader);
589 static void __ps_free_category(category_x *category)
591 if (category == NULL)
593 if (category->name) {
594 free((void *)category->name);
595 category->name = NULL;
597 free((void*)category);
601 static void __ps_free_privilege(privilege_x *privilege)
603 if (privilege == NULL)
605 if (privilege->text) {
606 free((void *)privilege->text);
607 privilege->text = NULL;
609 free((void*)privilege);
613 static void __ps_free_privileges(privileges_x *privileges)
615 if (privileges == NULL)
618 if (privileges->privilege) {
619 privilege_x *privilege = privileges->privilege;
620 privilege_x *tmp = NULL;
621 while(privilege != NULL) {
622 tmp = privilege->next;
623 __ps_free_privilege(privilege);
627 free((void*)privileges);
631 static void __ps_free_metadata(metadata_x *metadata)
633 if (metadata == NULL)
636 free((void *)metadata->key);
637 metadata->key = NULL;
639 if (metadata->value) {
640 free((void *)metadata->value);
641 metadata->value = NULL;
643 free((void*)metadata);
647 static void __ps_free_permission(permission_x *permission)
649 if (permission == NULL)
651 if (permission->type) {
652 free((void *)permission->type);
653 permission->type = NULL;
655 if (permission->value) {
656 free((void *)permission->value);
657 permission->value = NULL;
659 free((void*)permission);
663 static void __ps_free_icon(icon_x *icon)
668 free((void *)icon->text);
672 free((void *)icon->lang);
676 free((void *)icon->name);
680 free((void *)icon->section);
681 icon->section = NULL;
684 free((void *)icon->size);
687 if (icon->resolution) {
688 free((void *)icon->resolution);
689 icon->resolution = NULL;
695 static void __ps_free_image(image_x *image)
700 free((void *)image->text);
704 free((void *)image->lang);
708 free((void *)image->name);
711 if (image->section) {
712 free((void *)image->section);
713 image->section = NULL;
719 static void __ps_free_operation(operation_x *operation)
721 if (operation == NULL)
723 if (operation->text) {
724 free((void *)operation->text);
725 operation->text = NULL;
727 free((void*)operation);
731 static void __ps_free_uri(uri_x *uri)
736 free((void *)uri->text);
743 static void __ps_free_mime(mime_x *mime)
748 free((void *)mime->text);
755 static void __ps_free_subapp(subapp_x *subapp)
760 free((void *)subapp->text);
767 static void __ps_free_condition(condition_x *condition)
769 if (condition == NULL)
771 if (condition->text) {
772 free((void *)condition->text);
773 condition->text = NULL;
775 if (condition->name) {
776 free((void *)condition->name);
777 condition->name = NULL;
779 free((void*)condition);
783 static void __ps_free_notification(notification_x *notification)
785 if (notification == NULL)
787 if (notification->text) {
788 free((void *)notification->text);
789 notification->text = NULL;
791 if (notification->name) {
792 free((void *)notification->name);
793 notification->name = NULL;
795 free((void*)notification);
799 static void __ps_free_compatibility(compatibility_x *compatibility)
801 if (compatibility == NULL)
803 if (compatibility->text) {
804 free((void *)compatibility->text);
805 compatibility->text = NULL;
807 if (compatibility->name) {
808 free((void *)compatibility->name);
809 compatibility->name = NULL;
811 free((void*)compatibility);
812 compatibility = NULL;
815 static void __ps_free_resolution(resolution_x *resolution)
817 if (resolution == NULL)
819 if (resolution->mimetype) {
820 free((void *)resolution->mimetype);
821 resolution->mimetype = NULL;
823 if (resolution->urischeme) {
824 free((void *)resolution->urischeme);
825 resolution->urischeme = NULL;
827 free((void*)resolution);
831 static void __ps_free_capability(capability_x *capability)
833 if (capability == NULL)
835 if (capability->operationid) {
836 free((void *)capability->operationid);
837 capability->operationid = NULL;
840 if (capability->resolution) {
841 resolution_x *resolution = capability->resolution;
842 resolution_x *tmp = NULL;
843 while(resolution != NULL) {
844 tmp = resolution->next;
845 __ps_free_resolution(resolution);
849 free((void*)capability);
853 static void __ps_free_allowed(allowed_x *allowed)
858 free((void *)allowed->name);
859 allowed->name = NULL;
862 free((void *)allowed->text);
863 allowed->text = NULL;
865 free((void*)allowed);
869 static void __ps_free_request(request_x *request)
874 free((void *)request->text);
875 request->text = NULL;
877 free((void*)request);
881 static void __ps_free_datacontrol(datacontrol_x *datacontrol)
883 if (datacontrol == NULL)
885 if (datacontrol->providerid) {
886 free((void *)datacontrol->providerid);
887 datacontrol->providerid = NULL;
890 if (datacontrol->capability) {
891 capability_x *capability = datacontrol->capability;
892 capability_x *tmp = NULL;
893 while(capability != NULL) {
894 tmp = capability->next;
895 __ps_free_capability(capability);
899 free((void*)datacontrol);
903 static void __ps_free_launchconditions(launchconditions_x *launchconditions)
905 if (launchconditions == NULL)
907 if (launchconditions->text) {
908 free((void *)launchconditions->text);
909 launchconditions->text = NULL;
912 if (launchconditions->condition) {
913 condition_x *condition = launchconditions->condition;
914 condition_x *tmp = NULL;
915 while(condition != NULL) {
916 tmp = condition->next;
917 __ps_free_condition(condition);
921 free((void*)launchconditions);
922 launchconditions = NULL;
925 static void __ps_free_appcontrol(appcontrol_x *appcontrol)
927 if (appcontrol == NULL)
929 if (appcontrol->text) {
930 free((void *)appcontrol->text);
931 appcontrol->text = NULL;
934 if (appcontrol->operation) {
935 operation_x *operation = appcontrol->operation;
936 operation_x *tmp = NULL;
937 while(operation != NULL) {
938 tmp = operation->next;
939 __ps_free_operation(operation);
944 if (appcontrol->uri) {
945 uri_x *uri = appcontrol->uri;
954 if (appcontrol->mime) {
955 mime_x *mime = appcontrol->mime;
957 while(mime != NULL) {
959 __ps_free_mime(mime);
964 if (appcontrol->subapp) {
965 subapp_x *subapp = appcontrol->subapp;
966 subapp_x *tmp = NULL;
967 while(subapp != NULL) {
969 __ps_free_subapp(subapp);
973 free((void*)appcontrol);
977 static void __ps_free_appsvc(appsvc_x *appsvc)
982 free((void *)appsvc->text);
986 if (appsvc->operation) {
987 operation_x *operation = appsvc->operation;
988 operation_x *tmp = NULL;
989 while(operation != NULL) {
990 tmp = operation->next;
991 __ps_free_operation(operation);
997 uri_x *uri = appsvc->uri;
1007 mime_x *mime = appsvc->mime;
1009 while(mime != NULL) {
1011 __ps_free_mime(mime);
1016 if (appsvc->subapp) {
1017 subapp_x *subapp = appsvc->subapp;
1018 subapp_x *tmp = NULL;
1019 while(subapp != NULL) {
1021 __ps_free_subapp(subapp);
1025 free((void*)appsvc);
1029 static void __ps_free_deviceprofile(deviceprofile_x *deviceprofile)
1034 static void __ps_free_define(define_x *define)
1039 free((void *)define->path);
1040 define->path = NULL;
1043 if (define->request) {
1044 request_x *request = define->request;
1045 request_x *tmp = NULL;
1046 while(request != NULL) {
1047 tmp = request->next;
1048 __ps_free_request(request);
1053 if (define->allowed) {
1054 allowed_x *allowed = define->allowed;
1055 allowed_x *tmp = NULL;
1056 while(allowed != NULL) {
1057 tmp = allowed->next;
1058 __ps_free_allowed(allowed);
1062 free((void*)define);
1066 static void __ps_free_datashare(datashare_x *datashare)
1068 if (datashare == NULL)
1071 if (datashare->define) {
1072 define_x *define = datashare->define;
1073 define_x *tmp = NULL;
1074 while(define != NULL) {
1076 __ps_free_define(define);
1081 if (datashare->request) {
1082 request_x *request = datashare->request;
1083 request_x *tmp = NULL;
1084 while(request != NULL) {
1085 tmp = request->next;
1086 __ps_free_request(request);
1090 free((void*)datashare);
1094 static void __ps_free_label(label_x *label)
1099 free((void *)label->name);
1103 free((void *)label->text);
1107 free((void *)label->lang);
1114 static void __ps_free_author(author_x *author)
1118 if (author->email) {
1119 free((void *)author->email);
1120 author->email = NULL;
1123 free((void *)author->text);
1124 author->text = NULL;
1127 free((void *)author->href);
1128 author->href = NULL;
1131 free((void *)author->lang);
1132 author->lang = NULL;
1134 free((void*)author);
1138 static void __ps_free_description(description_x *description)
1140 if (description == NULL)
1142 if (description->name) {
1143 free((void *)description->name);
1144 description->name = NULL;
1146 if (description->text) {
1147 free((void *)description->text);
1148 description->text = NULL;
1150 if (description->lang) {
1151 free((void *)description->lang);
1152 description->lang = NULL;
1154 free((void*)description);
1158 static void __ps_free_license(license_x *license)
1160 if (license == NULL)
1162 if (license->text) {
1163 free((void *)license->text);
1164 license->text = NULL;
1166 if (license->lang) {
1167 free((void *)license->lang);
1168 license->lang = NULL;
1170 free((void*)license);
1174 static void __ps_free_uiapplication(uiapplication_x *uiapplication)
1176 if (uiapplication == NULL)
1178 if (uiapplication->exec) {
1179 free((void *)uiapplication->exec);
1180 uiapplication->exec = NULL;
1182 if (uiapplication->appid) {
1183 free((void *)uiapplication->appid);
1184 uiapplication->appid = NULL;
1186 if (uiapplication->nodisplay) {
1187 free((void *)uiapplication->nodisplay);
1188 uiapplication->nodisplay = NULL;
1190 if (uiapplication->multiple) {
1191 free((void *)uiapplication->multiple);
1192 uiapplication->multiple = NULL;
1194 if (uiapplication->type) {
1195 free((void *)uiapplication->type);
1196 uiapplication->type = NULL;
1198 if (uiapplication->categories) {
1199 free((void *)uiapplication->categories);
1200 uiapplication->categories = NULL;
1202 if (uiapplication->extraid) {
1203 free((void *)uiapplication->extraid);
1204 uiapplication->extraid = NULL;
1206 if (uiapplication->taskmanage) {
1207 free((void *)uiapplication->taskmanage);
1208 uiapplication->taskmanage = NULL;
1210 if (uiapplication->enabled) {
1211 free((void *)uiapplication->enabled);
1212 uiapplication->enabled = NULL;
1214 if (uiapplication->hwacceleration) {
1215 free((void *)uiapplication->hwacceleration);
1216 uiapplication->hwacceleration = NULL;
1218 if (uiapplication->mainapp) {
1219 free((void *)uiapplication->mainapp);
1220 uiapplication->mainapp = NULL;
1222 if (uiapplication->recentimage) {
1223 free((void *)uiapplication->recentimage);
1224 uiapplication->recentimage = NULL;
1226 if (uiapplication->package) {
1227 free((void *)uiapplication->package);
1228 uiapplication->package = NULL;
1231 if (uiapplication->label) {
1232 label_x *label = uiapplication->label;
1233 label_x *tmp = NULL;
1234 while(label != NULL) {
1236 __ps_free_label(label);
1241 if (uiapplication->icon) {
1242 icon_x *icon = uiapplication->icon;
1244 while(icon != NULL) {
1246 __ps_free_icon(icon);
1251 if (uiapplication->image) {
1252 image_x *image = uiapplication->image;
1253 image_x *tmp = NULL;
1254 while(image != NULL) {
1256 __ps_free_image(image);
1261 if (uiapplication->appcontrol) {
1262 appcontrol_x *appcontrol = uiapplication->appcontrol;
1263 appcontrol_x *tmp = NULL;
1264 while(appcontrol != NULL) {
1265 tmp = appcontrol->next;
1266 __ps_free_appcontrol(appcontrol);
1270 /*Free LaunchConditions*/
1271 if (uiapplication->launchconditions) {
1272 launchconditions_x *launchconditions = uiapplication->launchconditions;
1273 launchconditions_x *tmp = NULL;
1274 while(launchconditions != NULL) {
1275 tmp = launchconditions->next;
1276 __ps_free_launchconditions(launchconditions);
1277 launchconditions = tmp;
1280 /*Free Notification*/
1281 if (uiapplication->notification) {
1282 notification_x *notification = uiapplication->notification;
1283 notification_x *tmp = NULL;
1284 while(notification != NULL) {
1285 tmp = notification->next;
1286 __ps_free_notification(notification);
1291 if (uiapplication->datashare) {
1292 datashare_x *datashare = uiapplication->datashare;
1293 datashare_x *tmp = NULL;
1294 while(datashare != NULL) {
1295 tmp = datashare->next;
1296 __ps_free_datashare(datashare);
1301 if (uiapplication->appsvc) {
1302 appsvc_x *appsvc = uiapplication->appsvc;
1303 appsvc_x *tmp = NULL;
1304 while(appsvc != NULL) {
1306 __ps_free_appsvc(appsvc);
1311 if (uiapplication->category) {
1312 category_x *category = uiapplication->category;
1313 category_x *tmp = NULL;
1314 while(category != NULL) {
1315 tmp = category->next;
1316 __ps_free_category(category);
1321 if (uiapplication->metadata) {
1322 metadata_x *metadata = uiapplication->metadata;
1323 metadata_x *tmp = NULL;
1324 while(metadata != NULL) {
1325 tmp = metadata->next;
1326 __ps_free_metadata(metadata);
1331 if (uiapplication->permission) {
1332 permission_x *permission = uiapplication->permission;
1333 permission_x *tmp = NULL;
1334 while(permission != NULL) {
1335 tmp = permission->next;
1336 __ps_free_permission(permission);
1340 /* _PRODUCT_LAUNCHING_ENHANCED_ START */
1341 if (uiapplication->indicatordisplay) {
1342 free((void *)uiapplication->indicatordisplay);
1343 uiapplication->indicatordisplay = NULL;
1345 if (uiapplication->portraitimg) {
1346 free((void *)uiapplication->portraitimg);
1347 uiapplication->portraitimg = NULL;
1349 if (uiapplication->landscapeimg) {
1350 free((void *)uiapplication->landscapeimg);
1351 uiapplication->landscapeimg = NULL;
1353 /* _PRODUCT_LAUNCHING_ENHANCED_ END */
1354 if (uiapplication->guestmode_visibility) {
1355 free((void *)uiapplication->guestmode_visibility);
1356 uiapplication->guestmode_visibility = NULL;
1358 free((void*)uiapplication);
1359 uiapplication = NULL;
1362 static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication)
1364 if (serviceapplication == NULL)
1366 if (serviceapplication->exec) {
1367 free((void *)serviceapplication->exec);
1368 serviceapplication->exec = NULL;
1370 if (serviceapplication->appid) {
1371 free((void *)serviceapplication->appid);
1372 serviceapplication->appid = NULL;
1374 if (serviceapplication->onboot) {
1375 free((void *)serviceapplication->onboot);
1376 serviceapplication->onboot = NULL;
1378 if (serviceapplication->autorestart) {
1379 free((void *)serviceapplication->autorestart);
1380 serviceapplication->autorestart = NULL;
1382 if (serviceapplication->type) {
1383 free((void *)serviceapplication->type);
1384 serviceapplication->type = NULL;
1386 if (serviceapplication->enabled) {
1387 free((void *)serviceapplication->enabled);
1388 serviceapplication->enabled = NULL;
1390 if (serviceapplication->package) {
1391 free((void *)serviceapplication->package);
1392 serviceapplication->package = NULL;
1395 if (serviceapplication->label) {
1396 label_x *label = serviceapplication->label;
1397 label_x *tmp = NULL;
1398 while(label != NULL) {
1400 __ps_free_label(label);
1405 if (serviceapplication->icon) {
1406 icon_x *icon = serviceapplication->icon;
1408 while(icon != NULL) {
1410 __ps_free_icon(icon);
1415 if (serviceapplication->appcontrol) {
1416 appcontrol_x *appcontrol = serviceapplication->appcontrol;
1417 appcontrol_x *tmp = NULL;
1418 while(appcontrol != NULL) {
1419 tmp = appcontrol->next;
1420 __ps_free_appcontrol(appcontrol);
1424 /*Free DataControl*/
1425 if (serviceapplication->datacontrol) {
1426 datacontrol_x *datacontrol = serviceapplication->datacontrol;
1427 datacontrol_x *tmp = NULL;
1428 while(datacontrol != NULL) {
1429 tmp = datacontrol->next;
1430 __ps_free_datacontrol(datacontrol);
1434 /*Free LaunchConditions*/
1435 if (serviceapplication->launchconditions) {
1436 launchconditions_x *launchconditions = serviceapplication->launchconditions;
1437 launchconditions_x *tmp = NULL;
1438 while(launchconditions != NULL) {
1439 tmp = launchconditions->next;
1440 __ps_free_launchconditions(launchconditions);
1441 launchconditions = tmp;
1444 /*Free Notification*/
1445 if (serviceapplication->notification) {
1446 notification_x *notification = serviceapplication->notification;
1447 notification_x *tmp = NULL;
1448 while(notification != NULL) {
1449 tmp = notification->next;
1450 __ps_free_notification(notification);
1455 if (serviceapplication->datashare) {
1456 datashare_x *datashare = serviceapplication->datashare;
1457 datashare_x *tmp = NULL;
1458 while(datashare != NULL) {
1459 tmp = datashare->next;
1460 __ps_free_datashare(datashare);
1465 if (serviceapplication->appsvc) {
1466 appsvc_x *appsvc = serviceapplication->appsvc;
1467 appsvc_x *tmp = NULL;
1468 while(appsvc != NULL) {
1470 __ps_free_appsvc(appsvc);
1475 if (serviceapplication->category) {
1476 category_x *category = serviceapplication->category;
1477 category_x *tmp = NULL;
1478 while(category != NULL) {
1479 tmp = category->next;
1480 __ps_free_category(category);
1485 if (serviceapplication->metadata) {
1486 metadata_x *metadata = serviceapplication->metadata;
1487 metadata_x *tmp = NULL;
1488 while(metadata != NULL) {
1489 tmp = metadata->next;
1490 __ps_free_metadata(metadata);
1495 if (serviceapplication->permission) {
1496 permission_x *permission = serviceapplication->permission;
1497 permission_x *tmp = NULL;
1498 while(permission != NULL) {
1499 tmp = permission->next;
1500 __ps_free_permission(permission);
1504 free((void*)serviceapplication);
1505 serviceapplication = NULL;
1508 static void __ps_free_font(font_x *font)
1513 free((void *)font->name);
1517 free((void *)font->text);
1524 static void __ps_free_theme(theme_x *theme)
1529 free((void *)theme->name);
1533 free((void *)theme->text);
1540 static void __ps_free_daemon(daemon_x *daemon)
1545 free((void *)daemon->name);
1546 daemon->name = NULL;
1549 free((void *)daemon->text);
1550 daemon->text = NULL;
1552 free((void*)daemon);
1556 static void __ps_free_ime(ime_x *ime)
1561 free((void *)ime->name);
1565 free((void *)ime->text);
1573 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed)
1575 xmlTextReaderRead(reader);
1576 if (xmlTextReaderValue(reader))
1577 allowed->text = ASCII(xmlTextReaderValue(reader));
1581 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation)
1583 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1584 operation->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1585 /* Text does not exist. Only attribute exists
1586 xmlTextReaderRead(reader);
1587 if (xmlTextReaderValue(reader))
1588 operation->text = ASCII(xmlTextReaderValue(reader));
1593 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri)
1595 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1596 uri->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1597 /* Text does not exist. Only attribute exists
1598 xmlTextReaderRead(reader);
1599 if (xmlTextReaderValue(reader))
1600 uri->text = ASCII(xmlTextReaderValue(reader));
1605 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime)
1607 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1608 mime->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1609 /* Text does not exist. Only attribute exists
1610 xmlTextReaderRead(reader);
1611 if (xmlTextReaderValue(reader))
1612 mime->text = ASCII(xmlTextReaderValue(reader));
1617 static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp)
1619 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1620 subapp->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1621 /* Text does not exist. Only attribute exists
1622 xmlTextReaderRead(reader);
1623 if (xmlTextReaderValue(reader))
1624 mime->text = ASCII(xmlTextReaderValue(reader));
1629 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition)
1631 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1632 condition->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1633 xmlTextReaderRead(reader);
1634 if (xmlTextReaderValue(reader))
1635 condition->text = ASCII(xmlTextReaderValue(reader));
1639 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notification)
1641 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1642 notification->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1643 xmlTextReaderRead(reader);
1644 if (xmlTextReaderValue(reader))
1645 notification->text = ASCII(xmlTextReaderValue(reader));
1649 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category)
1651 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1652 category->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1656 static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege)
1658 xmlTextReaderRead(reader);
1659 if (xmlTextReaderValue(reader)) {
1660 privilege->text = ASCII(xmlTextReaderValue(reader));
1665 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata)
1667 if (xmlTextReaderGetAttribute(reader, XMLCHAR("key")))
1668 metadata->key = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("key")));
1669 if (xmlTextReaderGetAttribute(reader, XMLCHAR("value")))
1670 metadata->value = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("value")));
1674 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission)
1676 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
1677 permission->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
1679 xmlTextReaderRead(reader);
1680 if (xmlTextReaderValue(reader))
1681 permission->value = ASCII(xmlTextReaderValue(reader));
1685 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility)
1687 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1688 compatibility->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1689 xmlTextReaderRead(reader);
1690 if (xmlTextReaderValue(reader))
1691 compatibility->text = ASCII(xmlTextReaderValue(reader));
1695 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution)
1697 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")))
1698 resolution->mimetype = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")));
1699 if (xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")))
1700 resolution->urischeme = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")));
1704 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request)
1706 xmlTextReaderRead(reader);
1707 if (xmlTextReaderValue(reader))
1708 request->text = ASCII(xmlTextReaderValue(reader));
1712 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define)
1714 const xmlChar *node;
1717 allowed_x *tmp1 = NULL;
1718 request_x *tmp2 = NULL;
1720 if (xmlTextReaderGetAttribute(reader, XMLCHAR("path")))
1721 define->path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("path")));
1723 depth = xmlTextReaderDepth(reader);
1724 while ((ret = __next_child_element(reader, depth))) {
1725 node = xmlTextReaderConstName(reader);
1727 DBG("xmlTextReaderConstName value is NULL\n");
1731 if (!strcmp(ASCII(node), "allowed")) {
1732 allowed_x *allowed= malloc(sizeof(allowed_x));
1733 if (allowed == NULL) {
1734 DBG("Malloc Failed\n");
1737 memset(allowed, '\0', sizeof(allowed_x));
1738 LISTADD(define->allowed, allowed);
1739 ret = __ps_process_allowed(reader, allowed);
1740 } else if (!strcmp(ASCII(node), "request")) {
1741 request_x *request = malloc(sizeof(request_x));
1742 if (request == NULL) {
1743 DBG("Malloc Failed\n");
1746 memset(request, '\0', sizeof(request_x));
1747 LISTADD(define->request, request);
1748 ret = __ps_process_request(reader, request);
1752 DBG("Processing define failed\n");
1756 if (define->allowed) {
1757 LISTHEAD(define->allowed, tmp1);
1758 define->allowed = tmp1;
1760 if (define->request) {
1761 LISTHEAD(define->request, tmp2);
1762 define->request = tmp2;
1767 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol)
1769 const xmlChar *node;
1772 operation_x *tmp1 = NULL;
1774 mime_x *tmp3 = NULL;
1775 subapp_x *tmp4 = NULL;
1777 depth = xmlTextReaderDepth(reader);
1778 while ((ret = __next_child_element(reader, depth))) {
1779 node = xmlTextReaderConstName(reader);
1781 DBG("xmlTextReaderConstName value is NULL\n");
1785 if (!strcmp(ASCII(node), "operation")) {
1786 operation_x *operation = malloc(sizeof(operation_x));
1787 if (operation == NULL) {
1788 DBG("Malloc Failed\n");
1791 memset(operation, '\0', sizeof(operation_x));
1792 LISTADD(appcontrol->operation, operation);
1793 ret = __ps_process_operation(reader, operation);
1794 DBG("operation processing\n");
1795 } else if (!strcmp(ASCII(node), "uri")) {
1796 uri_x *uri= malloc(sizeof(uri_x));
1798 DBG("Malloc Failed\n");
1801 memset(uri, '\0', sizeof(uri_x));
1802 LISTADD(appcontrol->uri, uri);
1803 ret = __ps_process_uri(reader, uri);
1804 DBG("uri processing\n");
1805 } else if (!strcmp(ASCII(node), "mime")) {
1806 mime_x *mime = malloc(sizeof(mime_x));
1808 DBG("Malloc Failed\n");
1811 memset(mime, '\0', sizeof(mime_x));
1812 LISTADD(appcontrol->mime, mime);
1813 ret = __ps_process_mime(reader, mime);
1814 DBG("mime processing\n");
1815 } else if (!strcmp(ASCII(node), "subapp")) {
1816 subapp_x *subapp = malloc(sizeof(subapp_x));
1817 if (subapp == NULL) {
1818 DBG("Malloc Failed\n");
1821 memset(subapp, '\0', sizeof(subapp_x));
1822 LISTADD(appcontrol->subapp, subapp);
1823 ret = __ps_process_subapp(reader, subapp);
1824 DBG("subapp processing\n");
1828 DBG("Processing appcontrol failed\n");
1832 if (appcontrol->operation) {
1833 LISTHEAD(appcontrol->operation, tmp1);
1834 appcontrol->operation = tmp1;
1836 if (appcontrol->uri) {
1837 LISTHEAD(appcontrol->uri, tmp2);
1838 appcontrol->uri = tmp2;
1840 if (appcontrol->mime) {
1841 LISTHEAD(appcontrol->mime, tmp3);
1842 appcontrol->mime = tmp3;
1844 if (appcontrol->subapp) {
1845 LISTHEAD(appcontrol->subapp, tmp4);
1846 appcontrol->subapp = tmp4;
1849 xmlTextReaderRead(reader);
1850 if (xmlTextReaderValue(reader))
1851 appcontrol->text = ASCII(xmlTextReaderValue(reader));
1856 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc)
1858 const xmlChar *node;
1861 operation_x *tmp1 = NULL;
1863 mime_x *tmp3 = NULL;
1864 subapp_x *tmp4 = NULL;
1866 depth = xmlTextReaderDepth(reader);
1867 while ((ret = __next_child_element(reader, depth))) {
1868 node = xmlTextReaderConstName(reader);
1870 DBG("xmlTextReaderConstName value is NULL\n");
1874 if (!strcmp(ASCII(node), "operation")) {
1875 operation_x *operation = malloc(sizeof(operation_x));
1876 if (operation == NULL) {
1877 DBG("Malloc Failed\n");
1880 memset(operation, '\0', sizeof(operation_x));
1881 LISTADD(appsvc->operation, operation);
1882 ret = __ps_process_operation(reader, operation);
1883 DBG("operation processing\n");
1884 } else if (!strcmp(ASCII(node), "uri")) {
1885 uri_x *uri= malloc(sizeof(uri_x));
1887 DBG("Malloc Failed\n");
1890 memset(uri, '\0', sizeof(uri_x));
1891 LISTADD(appsvc->uri, uri);
1892 ret = __ps_process_uri(reader, uri);
1893 DBG("uri processing\n");
1894 } else if (!strcmp(ASCII(node), "mime")) {
1895 mime_x *mime = malloc(sizeof(mime_x));
1897 DBG("Malloc Failed\n");
1900 memset(mime, '\0', sizeof(mime_x));
1901 LISTADD(appsvc->mime, mime);
1902 ret = __ps_process_mime(reader, mime);
1903 DBG("mime processing\n");
1904 } else if (!strcmp(ASCII(node), "subapp")) {
1905 subapp_x *subapp = malloc(sizeof(subapp_x));
1906 if (subapp == NULL) {
1907 DBG("Malloc Failed\n");
1910 memset(subapp, '\0', sizeof(subapp_x));
1911 LISTADD(appsvc->subapp, subapp);
1912 ret = __ps_process_subapp(reader, subapp);
1913 DBG("subapp processing\n");
1917 DBG("Processing appsvc failed\n");
1921 if (appsvc->operation) {
1922 LISTHEAD(appsvc->operation, tmp1);
1923 appsvc->operation = tmp1;
1926 LISTHEAD(appsvc->uri, tmp2);
1930 LISTHEAD(appsvc->mime, tmp3);
1931 appsvc->mime = tmp3;
1933 if (appsvc->subapp) {
1934 LISTHEAD(appsvc->subapp, tmp4);
1935 appsvc->subapp = tmp4;
1938 xmlTextReaderRead(reader);
1939 if (xmlTextReaderValue(reader))
1940 appsvc->text = ASCII(xmlTextReaderValue(reader));
1946 static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privileges)
1948 const xmlChar *node;
1951 privilege_x *tmp1 = NULL;
1953 depth = xmlTextReaderDepth(reader);
1954 while ((ret = __next_child_element(reader, depth))) {
1955 node = xmlTextReaderConstName(reader);
1957 DBG("xmlTextReaderConstName value is NULL\n");
1961 if (strcmp(ASCII(node), "privilege") == 0) {
1962 privilege_x *privilege = malloc(sizeof(privilege_x));
1963 if (privilege == NULL) {
1964 DBG("Malloc Failed\n");
1967 memset(privilege, '\0', sizeof(privilege_x));
1968 LISTADD(privileges->privilege, privilege);
1969 ret = __ps_process_privilege(reader, privilege);
1973 DBG("Processing privileges failed\n");
1977 if (privileges->privilege) {
1978 LISTHEAD(privileges->privilege, tmp1);
1979 privileges->privilege = tmp1;
1984 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions)
1986 const xmlChar *node;
1989 condition_x *tmp1 = NULL;
1991 depth = xmlTextReaderDepth(reader);
1992 while ((ret = __next_child_element(reader, depth))) {
1993 node = xmlTextReaderConstName(reader);
1995 DBG("xmlTextReaderConstName value is NULL\n");
1999 if (strcmp(ASCII(node), "condition") == 0) {
2000 condition_x *condition = malloc(sizeof(condition_x));
2001 if (condition == NULL) {
2002 DBG("Malloc Failed\n");
2005 memset(condition, '\0', sizeof(condition_x));
2006 LISTADD(launchconditions->condition, condition);
2007 ret = __ps_process_condition(reader, condition);
2011 DBG("Processing launchconditions failed\n");
2015 if (launchconditions->condition) {
2016 LISTHEAD(launchconditions->condition, tmp1);
2017 launchconditions->condition = tmp1;
2020 xmlTextReaderRead(reader);
2021 if (xmlTextReaderValue(reader))
2022 launchconditions->text = ASCII(xmlTextReaderValue(reader));
2027 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare)
2029 const xmlChar *node;
2032 define_x *tmp1 = NULL;
2033 request_x *tmp2 = NULL;
2034 depth = xmlTextReaderDepth(reader);
2035 while ((ret = __next_child_element(reader, depth))) {
2036 node = xmlTextReaderConstName(reader);
2038 DBG("xmlTextReaderConstName value is NULL\n");
2042 if (!strcmp(ASCII(node), "define")) {
2043 define_x *define= malloc(sizeof(define_x));
2044 if (define == NULL) {
2045 DBG("Malloc Failed\n");
2048 memset(define, '\0', sizeof(define_x));
2049 LISTADD(datashare->define, define);
2050 ret = __ps_process_define(reader, define);
2051 } else if (!strcmp(ASCII(node), "request")) {
2052 request_x *request= malloc(sizeof(request_x));
2053 if (request == NULL) {
2054 DBG("Malloc Failed\n");
2057 memset(request, '\0', sizeof(request_x));
2058 LISTADD(datashare->request, request);
2059 ret = __ps_process_request(reader, request);
2063 DBG("Processing data-share failed\n");
2067 if (datashare->define) {
2068 LISTHEAD(datashare->define, tmp1);
2069 datashare->define = tmp1;
2071 if (datashare->request) {
2072 LISTHEAD(datashare->request, tmp2);
2073 datashare->request = tmp2;
2079 __get_icon_with_path(const char* icon)
2084 if (index(icon, '/') == NULL) {
2086 char* icon_with_path = NULL;
2092 theme = vconf_get_str("db/setting/theme");
2094 theme = strdup("default");
2100 len = (0x01 << 7) + strlen(icon) + strlen(package) + strlen(theme);
2101 icon_with_path = malloc(len);
2102 if(icon_with_path == NULL) {
2103 DBG("(icon_with_path == NULL) return\n");
2108 memset(icon_with_path, 0, len);
2110 snprintf(icon_with_path, len, "/opt/share/icons/%s/small/%s", theme, icon);
2112 if (access(icon_with_path, R_OK) == 0) break;
2113 snprintf(icon_with_path, len, "/usr/share/icons/%s/small/%s", theme, icon);
2114 if (access(icon_with_path, R_OK) == 0) break;
2115 DBG("cannot find icon %s", icon_with_path);
2116 snprintf(icon_with_path, len,"/opt/share/icons/default/small/%s", icon);
2117 if (access(icon_with_path, R_OK) == 0) break;
2118 snprintf(icon_with_path, len, "/usr/share/icons/default/small/%s", icon);
2119 if (access(icon_with_path, R_OK) == 0) break;
2121 /* icon path is going to be moved intto the app directory */
2122 DBGE("icon file must be moved to %s", icon_with_path);
2123 snprintf(icon_with_path, len, "/opt/apps/%s/res/icons/%s/small/%s", package, theme, icon);
2124 if (access(icon_with_path, R_OK) == 0) break;
2125 snprintf(icon_with_path, len, "/usr/apps/%s/res/icons/%s/small/%s", package, theme, icon);
2126 if (access(icon_with_path, R_OK) == 0) break;
2127 DBG("cannot find icon %s", icon_with_path);
2128 snprintf(icon_with_path, len, "/opt/apps/%s/res/icons/default/small/%s", package, icon);
2129 if (access(icon_with_path, R_OK) == 0) break;
2130 snprintf(icon_with_path, len, "/usr/apps/%s/res/icons/default/small/%s", package, icon);
2131 if (access(icon_with_path, R_OK) == 0) break;
2136 DBG("Icon path : %s ---> %s", icon, icon_with_path);
2138 return icon_with_path;
2140 char* confirmed_icon = NULL;
2142 confirmed_icon = strdup(icon);
2143 if (!confirmed_icon)
2145 return confirmed_icon;
2150 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon)
2152 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2153 icon->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2154 if (xmlTextReaderConstXmlLang(reader)) {
2155 icon->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2156 if (icon->lang == NULL)
2157 icon->lang = strdup(DEFAULT_LOCALE);
2159 icon->lang = strdup(DEFAULT_LOCALE);
2161 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
2162 icon->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
2163 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
2164 icon->size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
2165 if (xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")))
2166 icon->resolution = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")));
2167 xmlTextReaderRead(reader);
2168 if (xmlTextReaderValue(reader)) {
2169 const char *text = ASCII(xmlTextReaderValue(reader));
2171 icon->text = (const char *)__get_icon_with_path(text);
2179 static int __ps_process_image(xmlTextReaderPtr reader, image_x *image)
2181 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2182 image->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2183 if (xmlTextReaderConstXmlLang(reader)) {
2184 image->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2185 if (image->lang == NULL)
2186 image->lang = strdup(DEFAULT_LOCALE);
2188 image->lang = strdup(DEFAULT_LOCALE);
2190 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
2191 image->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
2192 xmlTextReaderRead(reader);
2193 if (xmlTextReaderValue(reader))
2194 image->text = ASCII(xmlTextReaderValue(reader));
2199 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label)
2201 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2202 label->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2203 if (xmlTextReaderConstXmlLang(reader)) {
2204 label->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2205 if (label->lang == NULL)
2206 label->lang = strdup(DEFAULT_LOCALE);
2208 label->lang = strdup(DEFAULT_LOCALE);
2210 xmlTextReaderRead(reader);
2211 if (xmlTextReaderValue(reader))
2212 label->text = ASCII(xmlTextReaderValue(reader));
2214 /* DBG("lable name %s\n", label->name);
2215 DBG("lable lang %s\n", label->lang);
2216 DBG("lable text %s\n", label->text);
2222 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author)
2224 if (xmlTextReaderGetAttribute(reader, XMLCHAR("email")))
2225 author->email = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("email")));
2226 if (xmlTextReaderGetAttribute(reader, XMLCHAR("href")))
2227 author->href = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("href")));
2228 if (xmlTextReaderConstXmlLang(reader)) {
2229 author->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2230 if (author->lang == NULL)
2231 author->lang = strdup(DEFAULT_LOCALE);
2233 author->lang = strdup(DEFAULT_LOCALE);
2235 xmlTextReaderRead(reader);
2236 if (xmlTextReaderValue(reader))
2237 author->text = ASCII(xmlTextReaderValue(reader));
2241 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description)
2243 if (xmlTextReaderConstXmlLang(reader)) {
2244 description->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2245 if (description->lang == NULL)
2246 description->lang = strdup(DEFAULT_LOCALE);
2248 description->lang = strdup(DEFAULT_LOCALE);
2250 xmlTextReaderRead(reader);
2251 if (xmlTextReaderValue(reader))
2252 description->text = ASCII(xmlTextReaderValue(reader));
2256 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license)
2258 if (xmlTextReaderConstXmlLang(reader)) {
2259 license->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2260 if (license->lang == NULL)
2261 license->lang = strdup(DEFAULT_LOCALE);
2263 license->lang = strdup(DEFAULT_LOCALE);
2265 xmlTextReaderRead(reader);
2266 if (xmlTextReaderValue(reader))
2267 license->text = ASCII(xmlTextReaderValue(reader));
2271 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability)
2273 const xmlChar *node;
2276 resolution_x *tmp1 = NULL;
2278 if (xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")))
2279 capability->operationid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")));
2281 depth = xmlTextReaderDepth(reader);
2282 while ((ret = __next_child_element(reader, depth))) {
2283 node = xmlTextReaderConstName(reader);
2285 DBG("xmlTextReaderConstName value is NULL\n");
2289 if (!strcmp(ASCII(node), "resolution")) {
2290 resolution_x *resolution = malloc(sizeof(resolution_x));
2291 if (resolution == NULL) {
2292 DBG("Malloc Failed\n");
2295 memset(resolution, '\0', sizeof(resolution_x));
2296 LISTADD(capability->resolution, resolution);
2297 ret = __ps_process_resolution(reader, resolution);
2301 DBG("Processing capability failed\n");
2306 if (capability->resolution) {
2307 LISTHEAD(capability->resolution, tmp1);
2308 capability->resolution = tmp1;
2314 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol)
2316 const xmlChar *node;
2319 capability_x *tmp1 = NULL;
2321 if (xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")))
2322 datacontrol->providerid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")));
2324 depth = xmlTextReaderDepth(reader);
2325 while ((ret = __next_child_element(reader, depth))) {
2326 node = xmlTextReaderConstName(reader);
2328 DBG("xmlTextReaderConstName value is NULL\n");
2332 if (!strcmp(ASCII(node), "capability")) {
2333 capability_x *capability = malloc(sizeof(capability_x));
2334 if (capability == NULL) {
2335 DBG("Malloc Failed\n");
2338 memset(capability, '\0', sizeof(capability_x));
2339 LISTADD(datacontrol->capability, capability);
2340 ret = __ps_process_capability(reader, capability);
2344 DBG("Processing datacontrol failed\n");
2349 if (datacontrol->capability) {
2350 LISTHEAD(datacontrol->capability, tmp1);
2351 datacontrol->capability = tmp1;
2357 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication)
2359 const xmlChar *node;
2362 char *newappid = NULL;
2363 label_x *tmp1 = NULL;
2364 icon_x *tmp2 = NULL;
2365 appsvc_x *tmp3 = NULL;
2366 appcontrol_x *tmp4 = NULL;
2367 launchconditions_x *tmp5 = NULL;
2368 notification_x *tmp6 = NULL;
2369 datashare_x *tmp7 = NULL;
2370 category_x *tmp8 = NULL;
2371 metadata_x *tmp9 = NULL;
2372 image_x *tmp10 = NULL;
2373 permission_x *tmp11 = NULL;
2375 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
2376 uiapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
2377 if (uiapplication->appid == NULL) {
2378 DBG("appid cant be NULL\n");
2382 DBG("appid is mandatory\n");
2386 ret = __validate_appid(package, uiapplication->appid, &newappid);
2388 DBG("appid is not proper\n");
2392 if (uiapplication->appid)
2393 free((void *)uiapplication->appid);
2394 uiapplication->appid = newappid;
2397 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
2398 uiapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
2399 if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay"))) {
2400 uiapplication->nodisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay")));
2401 if (uiapplication->nodisplay == NULL)
2402 uiapplication->nodisplay = strdup("false");
2404 uiapplication->nodisplay = strdup("false");
2406 if (xmlTextReaderGetAttribute(reader, XMLCHAR("multiple"))) {
2407 uiapplication->multiple = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("multiple")));
2408 if (uiapplication->multiple == NULL)
2409 uiapplication->multiple = strdup("false");
2411 uiapplication->multiple = strdup("false");
2413 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
2414 uiapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
2415 if (xmlTextReaderGetAttribute(reader, XMLCHAR("categories")))
2416 uiapplication->categories = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("categories")));
2417 if (xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")))
2418 uiapplication->extraid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")));
2419 if (xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage"))) {
2420 uiapplication->taskmanage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage")));
2421 if (uiapplication->taskmanage == NULL)
2422 uiapplication->taskmanage = strdup("true");
2424 uiapplication->taskmanage = strdup("true");
2426 if (xmlTextReaderGetAttribute(reader, XMLCHAR("enabled"))) {
2427 uiapplication->enabled = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("enabled")));
2428 if (uiapplication->enabled == NULL)
2429 uiapplication->enabled = strdup("true");
2431 uiapplication->enabled = strdup("true");
2433 if (xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration"))) {
2434 uiapplication->hwacceleration = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration")));
2435 if (uiapplication->hwacceleration == NULL)
2436 uiapplication->hwacceleration = strdup("use-system-setting");
2438 uiapplication->hwacceleration = strdup("use-system-setting");
2440 if (xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")))
2441 uiapplication->recentimage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")));
2442 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp"))) {
2443 uiapplication->mainapp = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp")));
2444 if (uiapplication->mainapp == NULL)
2445 uiapplication->mainapp = strdup("false");
2447 uiapplication->mainapp = strdup("false");
2449 if (xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay"))) {
2450 uiapplication->indicatordisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay")));
2451 if (uiapplication->indicatordisplay == NULL)
2452 uiapplication->indicatordisplay = strdup("true");
2454 uiapplication->indicatordisplay = strdup("true");
2456 if (xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")))
2457 uiapplication->portraitimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")));
2459 uiapplication->portraitimg = NULL;
2460 if (xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")))
2461 uiapplication->landscapeimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")));
2463 uiapplication->landscapeimg = NULL;
2464 if (xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility"))) {
2465 uiapplication->guestmode_visibility = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility")));
2466 if (uiapplication->guestmode_visibility == NULL)
2467 uiapplication->guestmode_visibility = strdup("true");
2469 uiapplication->guestmode_visibility = strdup("true");
2472 depth = xmlTextReaderDepth(reader);
2473 while ((ret = __next_child_element(reader, depth))) {
2474 node = xmlTextReaderConstName(reader);
2476 DBG("xmlTextReaderConstName value is NULL\n");
2479 if (!strcmp(ASCII(node), "label")) {
2480 label_x *label = malloc(sizeof(label_x));
2481 if (label == NULL) {
2482 DBG("Malloc Failed\n");
2485 memset(label, '\0', sizeof(label_x));
2486 LISTADD(uiapplication->label, label);
2487 ret = __ps_process_label(reader, label);
2488 } else if (!strcmp(ASCII(node), "icon")) {
2489 icon_x *icon = malloc(sizeof(icon_x));
2491 DBG("Malloc Failed\n");
2494 memset(icon, '\0', sizeof(icon_x));
2495 LISTADD(uiapplication->icon, icon);
2496 ret = __ps_process_icon(reader, icon);
2497 } else if (!strcmp(ASCII(node), "image")) {
2498 image_x *image = malloc(sizeof(image_x));
2499 if (image == NULL) {
2500 DBG("Malloc Failed\n");
2503 memset(image, '\0', sizeof(image_x));
2504 LISTADD(uiapplication->image, image);
2505 ret = __ps_process_image(reader, image);
2506 } else if (!strcmp(ASCII(node), "category")) {
2507 category_x *category = malloc(sizeof(category_x));
2508 if (category == NULL) {
2509 DBG("Malloc Failed\n");
2512 memset(category, '\0', sizeof(category_x));
2513 LISTADD(uiapplication->category, category);
2514 ret = __ps_process_category(reader, category);
2515 } else if (!strcmp(ASCII(node), "metadata")) {
2516 metadata_x *metadata = malloc(sizeof(metadata_x));
2517 if (metadata == NULL) {
2518 DBG("Malloc Failed\n");
2521 memset(metadata, '\0', sizeof(metadata_x));
2522 LISTADD(uiapplication->metadata, metadata);
2523 ret = __ps_process_metadata(reader, metadata);
2524 } else if (!strcmp(ASCII(node), "permission")) {
2525 permission_x *permission = malloc(sizeof(permission_x));
2526 if (permission == NULL) {
2527 DBG("Malloc Failed\n");
2530 memset(permission, '\0', sizeof(permission_x));
2531 LISTADD(uiapplication->permission, permission);
2532 ret = __ps_process_permission(reader, permission);
2533 } else if (!strcmp(ASCII(node), "app-control")) {
2534 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
2535 if (appcontrol == NULL) {
2536 DBG("Malloc Failed\n");
2539 memset(appcontrol, '\0', sizeof(appcontrol_x));
2540 LISTADD(uiapplication->appcontrol, appcontrol);
2541 ret = __ps_process_appcontrol(reader, appcontrol);
2542 } else if (!strcmp(ASCII(node), "application-service")) {
2543 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
2544 if (appsvc == NULL) {
2545 DBG("Malloc Failed\n");
2548 memset(appsvc, '\0', sizeof(appsvc_x));
2549 LISTADD(uiapplication->appsvc, appsvc);
2550 ret = __ps_process_appsvc(reader, appsvc);
2551 } else if (!strcmp(ASCII(node), "data-share")) {
2552 datashare_x *datashare = malloc(sizeof(datashare_x));
2553 if (datashare == NULL) {
2554 DBG("Malloc Failed\n");
2557 memset(datashare, '\0', sizeof(datashare_x));
2558 LISTADD(uiapplication->datashare, datashare);
2559 ret = __ps_process_datashare(reader, datashare);
2560 } else if (!strcmp(ASCII(node), "launch-conditions")) {
2561 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
2562 if (launchconditions == NULL) {
2563 DBG("Malloc Failed\n");
2566 memset(launchconditions, '\0', sizeof(launchconditions_x));
2567 LISTADD(uiapplication->launchconditions, launchconditions);
2568 ret = __ps_process_launchconditions(reader, launchconditions);
2569 } else if (!strcmp(ASCII(node), "notification")) {
2570 notification_x *notification = malloc(sizeof(notification_x));
2571 if (notification == NULL) {
2572 DBG("Malloc Failed\n");
2575 memset(notification, '\0', sizeof(notification_x));
2576 LISTADD(uiapplication->notification, notification);
2577 ret = __ps_process_notification(reader, notification);
2581 DBG("Processing uiapplication failed\n");
2586 if (uiapplication->label) {
2587 LISTHEAD(uiapplication->label, tmp1);
2588 uiapplication->label = tmp1;
2590 if (uiapplication->icon) {
2591 LISTHEAD(uiapplication->icon, tmp2);
2592 uiapplication->icon = tmp2;
2594 if (uiapplication->appsvc) {
2595 LISTHEAD(uiapplication->appsvc, tmp3);
2596 uiapplication->appsvc = tmp3;
2598 if (uiapplication->appcontrol) {
2599 LISTHEAD(uiapplication->appcontrol, tmp4);
2600 uiapplication->appcontrol = tmp4;
2602 if (uiapplication->launchconditions) {
2603 LISTHEAD(uiapplication->launchconditions, tmp5);
2604 uiapplication->launchconditions = tmp5;
2606 if (uiapplication->notification) {
2607 LISTHEAD(uiapplication->notification, tmp6);
2608 uiapplication->notification = tmp6;
2610 if (uiapplication->datashare) {
2611 LISTHEAD(uiapplication->datashare, tmp7);
2612 uiapplication->datashare = tmp7;
2614 if (uiapplication->category) {
2615 LISTHEAD(uiapplication->category, tmp8);
2616 uiapplication->category = tmp8;
2618 if (uiapplication->metadata) {
2619 LISTHEAD(uiapplication->metadata, tmp9);
2620 uiapplication->metadata = tmp9;
2622 if (uiapplication->image) {
2623 LISTHEAD(uiapplication->image, tmp10);
2624 uiapplication->image = tmp10;
2626 if (uiapplication->permission) {
2627 LISTHEAD(uiapplication->permission, tmp11);
2628 uiapplication->permission = tmp11;
2634 static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication)
2636 const xmlChar *node;
2639 char *newappid = NULL;
2640 label_x *tmp1 = NULL;
2641 icon_x *tmp2 = NULL;
2642 appsvc_x *tmp3 = NULL;
2643 appcontrol_x *tmp4 = NULL;
2644 datacontrol_x *tmp5 = NULL;
2645 launchconditions_x *tmp6 = NULL;
2646 notification_x *tmp7 = NULL;
2647 datashare_x *tmp8 = NULL;
2648 category_x *tmp9 = NULL;
2649 metadata_x *tmp10 = NULL;
2650 permission_x *tmp11 = NULL;
2652 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
2653 serviceapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
2654 if (serviceapplication->appid == NULL) {
2655 DBG("appid cant be NULL\n");
2659 DBG("appid is mandatory\n");
2663 ret = __validate_appid(package, serviceapplication->appid, &newappid);
2665 DBG("appid is not proper\n");
2669 if (serviceapplication->appid)
2670 free((void *)serviceapplication->appid);
2671 serviceapplication->appid = newappid;
2674 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
2675 serviceapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
2676 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
2677 serviceapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
2678 if (xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot"))) {
2679 serviceapplication->onboot = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot")));
2680 if (serviceapplication->onboot == NULL)
2681 serviceapplication->onboot = strdup("false");
2683 serviceapplication->onboot = strdup("false");
2685 if (xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart"))) {
2686 serviceapplication->autorestart = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart")));
2687 if (serviceapplication->autorestart == NULL)
2688 serviceapplication->autorestart = strdup("false");
2690 serviceapplication->autorestart = strdup("false");
2693 depth = xmlTextReaderDepth(reader);
2694 while ((ret = __next_child_element(reader, depth))) {
2695 node = xmlTextReaderConstName(reader);
2697 DBG("xmlTextReaderConstName value is NULL\n");
2701 if (!strcmp(ASCII(node), "label")) {
2702 label_x *label = malloc(sizeof(label_x));
2703 if (label == NULL) {
2704 DBG("Malloc Failed\n");
2707 memset(label, '\0', sizeof(label_x));
2708 LISTADD(serviceapplication->label, label);
2709 ret = __ps_process_label(reader, label);
2710 } else if (!strcmp(ASCII(node), "icon")) {
2711 icon_x *icon = malloc(sizeof(icon_x));
2713 DBG("Malloc Failed\n");
2716 memset(icon, '\0', sizeof(icon_x));
2717 LISTADD(serviceapplication->icon, icon);
2718 ret = __ps_process_icon(reader, icon);
2719 } else if (!strcmp(ASCII(node), "category")) {
2720 category_x *category = malloc(sizeof(category_x));
2721 if (category == NULL) {
2722 DBG("Malloc Failed\n");
2725 memset(category, '\0', sizeof(category_x));
2726 LISTADD(serviceapplication->category, category);
2727 ret = __ps_process_category(reader, category);
2728 } else if (!strcmp(ASCII(node), "metadata")) {
2729 metadata_x *metadata = malloc(sizeof(metadata_x));
2730 if (metadata == NULL) {
2731 DBG("Malloc Failed\n");
2734 memset(metadata, '\0', sizeof(metadata_x));
2735 LISTADD(serviceapplication->metadata, metadata);
2736 ret = __ps_process_metadata(reader, metadata);
2737 } else if (!strcmp(ASCII(node), "permission")) {
2738 permission_x *permission = malloc(sizeof(permission_x));
2739 if (permission == NULL) {
2740 DBG("Malloc Failed\n");
2743 memset(permission, '\0', sizeof(permission_x));
2744 LISTADD(serviceapplication->permission, permission);
2745 ret = __ps_process_permission(reader, permission);
2746 } else if (!strcmp(ASCII(node), "app-control")) {
2747 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
2748 if (appcontrol == NULL) {
2749 DBG("Malloc Failed\n");
2752 memset(appcontrol, '\0', sizeof(appcontrol_x));
2753 LISTADD(serviceapplication->appcontrol, appcontrol);
2754 ret = __ps_process_appcontrol(reader, appcontrol);
2755 } else if (!strcmp(ASCII(node), "application-service")) {
2756 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
2757 if (appsvc == NULL) {
2758 DBG("Malloc Failed\n");
2761 memset(appsvc, '\0', sizeof(appsvc_x));
2762 LISTADD(serviceapplication->appsvc, appsvc);
2763 ret = __ps_process_appsvc(reader, appsvc);
2764 } else if (!strcmp(ASCII(node), "data-share")) {
2765 datashare_x *datashare = malloc(sizeof(datashare_x));
2766 if (datashare == NULL) {
2767 DBG("Malloc Failed\n");
2770 memset(datashare, '\0', sizeof(datashare_x));
2771 LISTADD(serviceapplication->datashare, datashare);
2772 ret = __ps_process_datashare(reader, datashare);
2773 } else if (!strcmp(ASCII(node), "launch-conditions")) {
2774 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
2775 if (launchconditions == NULL) {
2776 DBG("Malloc Failed\n");
2779 memset(launchconditions, '\0', sizeof(launchconditions_x));
2780 LISTADD(serviceapplication->launchconditions, launchconditions);
2781 ret = __ps_process_launchconditions(reader, launchconditions);
2782 } else if (!strcmp(ASCII(node), "notification")) {
2783 notification_x *notification = malloc(sizeof(notification_x));
2784 if (notification == NULL) {
2785 DBG("Malloc Failed\n");
2788 memset(notification, '\0', sizeof(notification_x));
2789 LISTADD(serviceapplication->notification, notification);
2790 ret = __ps_process_notification(reader, notification);
2791 } else if (!strcmp(ASCII(node), "data-control")) {
2792 datacontrol_x *datacontrol = malloc(sizeof(datacontrol_x));
2793 if (datacontrol == NULL) {
2794 DBG("Malloc Failed\n");
2797 memset(datacontrol, '\0', sizeof(datacontrol_x));
2798 LISTADD(serviceapplication->datacontrol, datacontrol);
2799 ret = __ps_process_datacontrol(reader, datacontrol);
2803 DBG("Processing serviceapplication failed\n");
2808 if (serviceapplication->label) {
2809 LISTHEAD(serviceapplication->label, tmp1);
2810 serviceapplication->label = tmp1;
2812 if (serviceapplication->icon) {
2813 LISTHEAD(serviceapplication->icon, tmp2);
2814 serviceapplication->icon = tmp2;
2816 if (serviceapplication->appsvc) {
2817 LISTHEAD(serviceapplication->appsvc, tmp3);
2818 serviceapplication->appsvc = tmp3;
2820 if (serviceapplication->appcontrol) {
2821 LISTHEAD(serviceapplication->appcontrol, tmp4);
2822 serviceapplication->appcontrol = tmp4;
2824 if (serviceapplication->datacontrol) {
2825 LISTHEAD(serviceapplication->datacontrol, tmp5);
2826 serviceapplication->datacontrol = tmp5;
2828 if (serviceapplication->launchconditions) {
2829 LISTHEAD(serviceapplication->launchconditions, tmp6);
2830 serviceapplication->launchconditions = tmp6;
2832 if (serviceapplication->notification) {
2833 LISTHEAD(serviceapplication->notification, tmp7);
2834 serviceapplication->notification = tmp7;
2836 if (serviceapplication->datashare) {
2837 LISTHEAD(serviceapplication->datashare, tmp8);
2838 serviceapplication->datashare = tmp8;
2840 if (serviceapplication->category) {
2841 LISTHEAD(serviceapplication->category, tmp9);
2842 serviceapplication->category = tmp9;
2844 if (serviceapplication->metadata) {
2845 LISTHEAD(serviceapplication->metadata, tmp10);
2846 serviceapplication->metadata = tmp10;
2848 if (serviceapplication->permission) {
2849 LISTHEAD(serviceapplication->permission, tmp11);
2850 serviceapplication->permission = tmp11;
2856 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile)
2858 /*TODO: once policy is set*/
2862 static int __ps_process_font(xmlTextReaderPtr reader, font_x *font)
2864 /*TODO: once policy is set*/
2868 static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme)
2870 /*TODO: once policy is set*/
2874 static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon)
2876 /*TODO: once policy is set*/
2880 static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime)
2882 /*TODO: once policy is set*/
2886 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx)
2888 DBG("__start_process\n");
2889 const xmlChar *node;
2892 label_x *tmp1 = NULL;
2893 author_x *tmp2 = NULL;
2894 description_x *tmp3 = NULL;
2895 license_x *tmp4 = NULL;
2896 uiapplication_x *tmp5 = NULL;
2897 serviceapplication_x *tmp6 = NULL;
2898 daemon_x *tmp7 = NULL;
2899 theme_x *tmp8 = NULL;
2900 font_x *tmp9 = NULL;
2901 ime_x *tmp10 = NULL;
2902 icon_x *tmp11 = NULL;
2903 compatibility_x *tmp12 = NULL;
2904 deviceprofile_x *tmp13 = NULL;
2905 privileges_x *tmp14 = NULL;
2907 depth = xmlTextReaderDepth(reader);
2908 while ((ret = __next_child_element(reader, depth))) {
2909 node = xmlTextReaderConstName(reader);
2911 DBG("xmlTextReaderConstName value is NULL\n");
2915 if (!strcmp(ASCII(node), "label")) {
2916 label_x *label = malloc(sizeof(label_x));
2917 if (label == NULL) {
2918 DBG("Malloc Failed\n");
2921 memset(label, '\0', sizeof(label_x));
2922 LISTADD(mfx->label, label);
2923 ret = __ps_process_label(reader, label);
2924 } else if (!strcmp(ASCII(node), "author")) {
2925 author_x *author = malloc(sizeof(author_x));
2926 if (author == NULL) {
2927 DBG("Malloc Failed\n");
2930 memset(author, '\0', sizeof(author_x));
2931 LISTADD(mfx->author, author);
2932 ret = __ps_process_author(reader, author);
2933 } else if (!strcmp(ASCII(node), "description")) {
2934 description_x *description = malloc(sizeof(description_x));
2935 if (description == NULL) {
2936 DBG("Malloc Failed\n");
2939 memset(description, '\0', sizeof(description_x));
2940 LISTADD(mfx->description, description);
2941 ret = __ps_process_description(reader, description);
2942 } else if (!strcmp(ASCII(node), "license")) {
2943 license_x *license = malloc(sizeof(license_x));
2944 if (license == NULL) {
2945 DBG("Malloc Failed\n");
2948 memset(license, '\0', sizeof(license_x));
2949 LISTADD(mfx->license, license);
2950 ret = __ps_process_license(reader, license);
2951 } else if (!strcmp(ASCII(node), "privileges")) {
2952 privileges_x *privileges = malloc(sizeof(privileges_x));
2953 if (privileges == NULL) {
2954 DBG("Malloc Failed\n");
2957 memset(privileges, '\0', sizeof(privileges_x));
2958 LISTADD(mfx->privileges, privileges);
2959 ret = __ps_process_privileges(reader, privileges);
2960 } else if (!strcmp(ASCII(node), "ui-application")) {
2961 uiapplication_x *uiapplication = malloc(sizeof(uiapplication_x));
2962 if (uiapplication == NULL) {
2963 DBG("Malloc Failed\n");
2966 memset(uiapplication, '\0', sizeof(uiapplication_x));
2967 LISTADD(mfx->uiapplication, uiapplication);
2968 ret = __ps_process_uiapplication(reader, uiapplication);
2969 } else if (!strcmp(ASCII(node), "service-application")) {
2970 serviceapplication_x *serviceapplication = malloc(sizeof(serviceapplication_x));
2971 if (serviceapplication == NULL) {
2972 DBG("Malloc Failed\n");
2975 memset(serviceapplication, '\0', sizeof(serviceapplication_x));
2976 LISTADD(mfx->serviceapplication, serviceapplication);
2977 ret = __ps_process_serviceapplication(reader, serviceapplication);
2978 } else if (!strcmp(ASCII(node), "daemon")) {
2979 daemon_x *daemon = malloc(sizeof(daemon_x));
2980 if (daemon == NULL) {
2981 DBG("Malloc Failed\n");
2984 memset(daemon, '\0', sizeof(daemon_x));
2985 LISTADD(mfx->daemon, daemon);
2986 ret = __ps_process_daemon(reader, daemon);
2987 } else if (!strcmp(ASCII(node), "theme")) {
2988 theme_x *theme = malloc(sizeof(theme_x));
2989 if (theme == NULL) {
2990 DBG("Malloc Failed\n");
2993 memset(theme, '\0', sizeof(theme_x));
2994 LISTADD(mfx->theme, theme);
2995 ret = __ps_process_theme(reader, theme);
2996 } else if (!strcmp(ASCII(node), "font")) {
2997 font_x *font = malloc(sizeof(font_x));
2999 DBG("Malloc Failed\n");
3002 memset(font, '\0', sizeof(font_x));
3003 LISTADD(mfx->font, font);
3004 ret = __ps_process_font(reader, font);
3005 } else if (!strcmp(ASCII(node), "ime")) {
3006 ime_x *ime = malloc(sizeof(ime_x));
3008 DBG("Malloc Failed\n");
3011 memset(ime, '\0', sizeof(ime_x));
3012 LISTADD(mfx->ime, ime);
3013 ret = __ps_process_ime(reader, ime);
3014 } else if (!strcmp(ASCII(node), "icon")) {
3015 icon_x *icon = malloc(sizeof(icon_x));
3017 DBG("Malloc Failed\n");
3020 memset(icon, '\0', sizeof(icon_x));
3021 LISTADD(mfx->icon, icon);
3022 ret = __ps_process_icon(reader, icon);
3023 } else if (!strcmp(ASCII(node), "device-profile")) {
3024 deviceprofile_x *deviceprofile = malloc(sizeof(deviceprofile_x));
3025 if (deviceprofile == NULL) {
3026 DBG("Malloc Failed\n");
3029 memset(deviceprofile, '\0', sizeof(deviceprofile_x));
3030 LISTADD(mfx->deviceprofile, deviceprofile);
3031 ret = __ps_process_deviceprofile(reader, deviceprofile);
3032 } else if (!strcmp(ASCII(node), "compatibility")) {
3033 compatibility_x *compatibility = malloc(sizeof(compatibility_x));
3034 if (compatibility == NULL) {
3035 DBG("Malloc Failed\n");
3038 memset(compatibility, '\0', sizeof(compatibility_x));
3039 LISTADD(mfx->compatibility, compatibility);
3040 ret = __ps_process_compatibility(reader, compatibility);
3041 } else if (!strcmp(ASCII(node), "shortcut-list")) {
3043 } else if (!strcmp(ASCII(node), "livebox")) {
3045 } else if (!strcmp(ASCII(node), "account")) {
3047 } else if (!strcmp(ASCII(node), "notifications")) {
3049 } else if (!strcmp(ASCII(node), "ime")) {
3055 DBG("Processing manifest failed\n");
3060 LISTHEAD(mfx->label, tmp1);
3064 LISTHEAD(mfx->author, tmp2);
3067 if (mfx->description) {
3068 LISTHEAD(mfx->description, tmp3);
3069 mfx->description= tmp3;
3072 LISTHEAD(mfx->license, tmp4);
3075 if (mfx->uiapplication) {
3076 LISTHEAD(mfx->uiapplication, tmp5);
3077 mfx->uiapplication = tmp5;
3079 if (mfx->serviceapplication) {
3080 LISTHEAD(mfx->serviceapplication, tmp6);
3081 mfx->serviceapplication = tmp6;
3084 LISTHEAD(mfx->daemon, tmp7);
3088 LISTHEAD(mfx->theme, tmp8);
3092 LISTHEAD(mfx->font, tmp9);
3096 LISTHEAD(mfx->ime, tmp10);
3100 LISTHEAD(mfx->icon, tmp11);
3103 if (mfx->compatibility) {
3104 LISTHEAD(mfx->compatibility, tmp12);
3105 mfx->compatibility= tmp12;
3107 if (mfx->deviceprofile) {
3108 LISTHEAD(mfx->deviceprofile, tmp13);
3109 mfx->deviceprofile= tmp13;
3111 if (mfx->privileges) {
3112 LISTHEAD(mfx->privileges, tmp14);
3113 mfx->privileges = tmp14;
3118 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx)
3120 const xmlChar *node;
3123 if ((ret = __next_child_element(reader, -1))) {
3124 node = xmlTextReaderConstName(reader);
3126 DBG("xmlTextReaderConstName value is NULL\n");
3130 if (!strcmp(ASCII(node), "manifest")) {
3131 if (xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")))
3132 mfx->ns = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")));
3133 if (xmlTextReaderGetAttribute(reader, XMLCHAR("package"))) {
3134 mfx->package= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("package")));
3135 if (mfx->package == NULL) {
3136 DBG("package cant be NULL\n");
3140 DBG("package field is mandatory\n");
3143 package = mfx->package;
3144 if (xmlTextReaderGetAttribute(reader, XMLCHAR("version")))
3145 mfx->version= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("version")));
3146 /*app2ext needs package size for external installation*/
3147 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
3148 mfx->package_size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
3149 if (xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")))
3150 mfx->installlocation = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")));
3151 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
3152 mfx->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
3153 if (xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")))
3154 mfx->root_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")));
3155 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting"))) {
3156 mfx->appsetting = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting")));
3157 if (mfx->appsetting == NULL)
3158 mfx->appsetting = strdup("false");
3160 mfx->appsetting = strdup("false");
3163 /*Assign default values. If required it will be overwritten in __add_preload_info()*/
3164 mfx->preload = strdup("False");
3165 mfx->removable = strdup("True");
3166 mfx->readonly = strdup("False");
3167 char buf[PKG_STRING_LEN_MAX] = {'\0'};
3169 time_t current_time;
3170 time(¤t_time);
3171 snprintf(buf, PKG_STRING_LEN_MAX - 1, "%d", current_time);
3172 val = strndup(buf, PKG_STRING_LEN_MAX - 1);
3173 mfx->installed_time = val;
3175 mfx->installed_storage= strdup("installed_internal");
3177 ret = __start_process(reader, mfx);
3179 DBG("No Manifest element found\n");
3186 #define DESKTOP_RW_PATH "/opt/share/applications/"
3187 #define DESKTOP_RO_PATH "/usr/share/applications/"
3189 static char* __convert_to_system_locale(const char *mlocale)
3191 if (mlocale == NULL)
3193 char *locale = NULL;
3194 locale = (char *)calloc(1, 6);
3196 DBGE("Malloc Failed\n");
3200 strncpy(locale, mlocale, 2);
3201 strncat(locale, "_", 1);
3202 locale[3] = toupper(mlocale[3]);
3203 locale[4] = toupper(mlocale[4]);
3207 #define LIBAIL_PATH "/usr/lib/libail.so.0"
3209 /* operation_type */
3217 static int __ail_change_info(int op, const char *appid)
3219 void *lib_handle = NULL;
3220 int (*ail_desktop_operation) (const char *);
3224 if ((lib_handle = dlopen(LIBAIL_PATH, RTLD_LAZY)) == NULL) {
3225 DBGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAIL_PATH);
3232 aop = "ail_desktop_add";
3235 aop = "ail_desktop_update";
3238 aop = "ail_desktop_remove";
3245 if ((ail_desktop_operation =
3246 dlsym(lib_handle, aop)) == NULL || dlerror() != NULL) {
3247 DBGE("can not find symbol \n");
3251 ret = ail_desktop_operation(appid);
3255 dlclose(lib_handle);
3261 /* desktop shoud be generated automatically based on manifest */
3262 /* Currently removable, taskmanage, etc fields are not considerd. it will be decided soon.*/
3263 #define BUFMAX 1024*128
3264 static int __ps_make_nativeapp_desktop(manifest_x * mfx, bool is_update)
3268 char filepath[PKG_STRING_LEN_MAX] = "";
3270 char *buftemp = NULL;
3271 char *locale = NULL;
3273 buf = (char *)calloc(1, BUFMAX);
3275 DBGE("Malloc Failed\n");
3279 buftemp = (char *)calloc(1, BUFMAX);
3281 DBGE("Malloc Failed\n");
3286 for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) {
3288 if(mfx->readonly && !strcasecmp(mfx->readonly, "True"))
3289 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RO_PATH, mfx->uiapplication->appid);
3291 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, mfx->uiapplication->appid);
3293 /* skip if desktop exists
3294 if (access(filepath, R_OK) == 0)
3298 file = fopen(filepath, "w");
3301 DBGE("Can't open %s", filepath);
3307 snprintf(buf, BUFMAX, "[Desktop Entry]\n");
3308 fwrite(buf, 1, strlen(buf), file);
3310 for( ; mfx->uiapplication->label ; mfx->uiapplication->label = mfx->uiapplication->label->next) {
3311 if(!strcmp(mfx->uiapplication->label->lang, DEFAULT_LOCALE)) {
3312 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
3314 locale = __convert_to_system_locale(mfx->uiapplication->label->lang);
3315 snprintf(buf, BUFMAX, "Name[%s]=%s\n", locale,
3316 mfx->uiapplication->label->text);
3319 fwrite(buf, 1, strlen(buf), file);
3322 if(mfx->uiapplication->label && mfx->uiapplication->label->text) {
3323 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
3324 fwrite(buf, 1, strlen(buf), file);
3327 else if(mfx->label && mfx->label->text) {
3328 snprintf(buf, BUFMAX, "Name=%s\n", mfx->label->text);
3329 fwrite(buf, 1, strlen(buf), file);
3331 snprintf(buf, BUFMAX, "Name=%s\n", mfx->package);
3332 fwrite(buf, 1, strlen(buf), file);
3337 snprintf(buf, BUFMAX, "Type=Application\n");
3338 fwrite(buf, 1, strlen(buf), file);
3340 if(mfx->uiapplication->exec) {
3341 snprintf(buf, BUFMAX, "Exec=%s\n", mfx->uiapplication->exec);
3342 fwrite(buf, 1, strlen(buf), file);
3345 if(mfx->uiapplication->icon && mfx->uiapplication->icon->text) {
3346 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->uiapplication->icon->text);
3347 fwrite(buf, 1, strlen(buf), file);
3348 } else if(mfx->icon && mfx->icon->text) {
3349 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->icon->text);
3350 fwrite(buf, 1, strlen(buf), file);
3354 snprintf(buf, BUFMAX, "Version=%s\n", mfx->version);
3355 fwrite(buf, 1, strlen(buf), file);
3358 if(mfx->uiapplication->nodisplay) {
3359 snprintf(buf, BUFMAX, "NoDisplay=%s\n", mfx->uiapplication->nodisplay);
3360 fwrite(buf, 1, strlen(buf), file);
3363 if(mfx->uiapplication->categories) {
3364 snprintf(buf, BUFMAX, "Categories=%s\n", mfx->uiapplication->categories);
3365 fwrite(buf, 1, strlen(buf), file);
3368 if(mfx->uiapplication->taskmanage && !strcasecmp(mfx->uiapplication->taskmanage, "False")) {
3369 snprintf(buf, BUFMAX, "X-TIZEN-TaskManage=False\n");
3370 fwrite(buf, 1, strlen(buf), file);
3373 if(mfx->uiapplication->enabled && !strcasecmp(mfx->uiapplication->enabled, "False")) {
3374 snprintf(buf, BUFMAX, "X-TIZEN-Enabled=False\n");
3375 fwrite(buf, 1, strlen(buf), file);
3378 if(mfx->uiapplication->hwacceleration) {
3379 snprintf(buf, BUFMAX, "Hw-Acceleration=%s\n", mfx->uiapplication->hwacceleration);
3380 fwrite(buf, 1, strlen(buf), file);
3383 if(mfx->uiapplication->multiple && !strcasecmp(mfx->uiapplication->multiple, "True")) {
3384 snprintf(buf, BUFMAX, "X-TIZEN-Multiple=True\n");
3385 fwrite(buf, 1, strlen(buf), file);
3388 if(mfx->uiapplication->extraid) {
3389 snprintf(buf, BUFMAX, "X-TIZEN-PackageID=%s\n", mfx->uiapplication->extraid);
3390 fwrite(buf, 1, strlen(buf), file);
3393 if(mfx->removable && !strcasecmp(mfx->removable, "False")) {
3394 snprintf(buf, BUFMAX, "X-TIZEN-Removable=False\n");
3395 fwrite(buf, 1, strlen(buf), file);
3399 snprintf(buf, BUFMAX, "X-TIZEN-PackageType=%s\n", mfx->type);
3400 fwrite(buf, 1, strlen(buf), file);
3403 snprintf(buf, BUFMAX, "X-TIZEN-PkgID=%s\n", mfx->package);
3404 fwrite(buf, 1, strlen(buf), file);
3407 // snprintf(buf, BUFMAX, "X-TIZEN-PackageType=rpm\n");
3408 // fwrite(buf, 1, strlen(buf), file);
3411 if(mfx->uiapplication->appsvc) {
3412 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
3413 DBG("buf[%s]\n", buf);
3416 uiapplication_x *up = mfx->uiapplication;
3417 appsvc_x *asvc = NULL;
3418 operation_x *op = NULL;
3421 subapp_x *sub = NULL;
3422 const char *operation = NULL;
3423 const char *mime = NULL;
3424 const char *uri = NULL;
3425 const char *subapp = NULL;
3430 while(asvc != NULL) {
3431 op = asvc->operation;
3434 operation = op->name;
3453 strncpy(buftemp, buf, BUFMAX);
3454 snprintf(buf, BUFMAX, "%s;", buftemp);
3458 strncpy(buftemp, buf, BUFMAX);
3459 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
3460 DBG("buf[%s]\n", buf);
3465 } while(ui != NULL);
3469 }while(sub != NULL);
3482 fwrite(buf, 1, strlen(buf), file);
3484 // strncpy(buftemp, buf, BUFMAX);
3485 // snprintf(buf, BUFMAX, "%s\n", buftemp);
3486 // fwrite(buf, 1, strlen(buf), file);
3489 if(mfx->uiapplication->appcontrol) {
3490 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
3491 DBG("buf[%s]\n", buf);
3493 uiapplication_x *up = mfx->uiapplication;
3494 appcontrol_x *acontrol = NULL;
3495 operation_x *op = NULL;
3498 subapp_x *sub = NULL;
3499 const char *operation = NULL;
3500 const char *mime = NULL;
3501 const char *uri = NULL;
3502 const char *subapp = NULL;
3505 acontrol = up->appcontrol;
3506 while(acontrol != NULL) {
3507 op = acontrol->operation;
3510 operation = op->name;
3511 mi = acontrol->mime;
3517 sub = acontrol->subapp;
3529 strncpy(buftemp, buf, BUFMAX);
3530 snprintf(buf, BUFMAX, "%s;", buftemp);
3533 strncpy(buftemp, buf, BUFMAX);
3534 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
3535 DBG("buf[%s]\n", buf);
3540 } while(ui != NULL);
3544 }while(sub != NULL);
3553 acontrol = acontrol->next;
3557 fwrite(buf, 1, strlen(buf), file);
3559 // strncpy(buftemp, buf, BUFMAX);
3560 // snprintf(buf, BUFMAX, "%s\n", buftemp);
3561 // fwrite(buf, 1, strlen(buf), file);
3570 __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid);
3572 __ail_change_info(AIL_UPDATE, mfx->uiapplication->appid);
3581 static int __ps_remove_nativeapp_desktop(manifest_x *mfx)
3583 char filepath[PKG_STRING_LEN_MAX] = "";
3586 for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) {
3587 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, mfx->uiapplication->appid);
3589 __ail_change_info(AIL_REMOVE, mfx->uiapplication->appid);
3591 ret = remove(filepath);
3599 #define MANIFEST_RO_PREFIX "/usr/share/packages/"
3600 #define PRELOAD_PACKAGE_LIST "/usr/etc/package-manager/preload/preload_list.txt"
3601 static int __add_preload_info(manifest_x * mfx, const char *manifest)
3604 char buffer[1024] = { 0 };
3607 if(strstr(manifest, MANIFEST_RO_PREFIX)) {
3608 free((void *)mfx->readonly);
3609 mfx->readonly = strdup("True");
3611 free((void *)mfx->preload);
3612 mfx->preload = strdup("True");
3614 free((void *)mfx->removable);
3615 mfx->removable = strdup("False");
3620 fp = fopen(PRELOAD_PACKAGE_LIST, "r");
3622 DBGE("no preload list\n");
3626 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
3627 if (buffer[0] == '#') {
3628 if(strcasestr(buffer, "RW_NORM"))
3630 else if(strcasestr(buffer, "RW_RM"))
3638 if(!strcmp(mfx->package, buffer)) {
3639 free((void *)mfx->preload);
3640 mfx->preload = strdup("True");
3642 free((void *)mfx->readonly);
3643 mfx->readonly = strdup("False");
3644 free((void *)mfx->removable);
3645 mfx->removable = strdup("False");
3646 } else if(state == 3){
3647 free((void *)mfx->readonly);
3648 mfx->readonly = strdup("False");
3649 free((void *)mfx->removable);
3650 mfx->removable = strdup("True");
3654 memset(buffer, 0x00, sizeof(buffer));
3664 API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
3669 free((void *)mfx->ns);
3673 free((void *)mfx->package);
3674 mfx->package = NULL;
3677 free((void *)mfx->version);
3678 mfx->version = NULL;
3680 if (mfx->installlocation) {
3681 free((void *)mfx->installlocation);
3682 mfx->installlocation = NULL;
3685 free((void *)mfx->preload);
3686 mfx->preload = NULL;
3688 if (mfx->readonly) {
3689 free((void *)mfx->readonly);
3690 mfx->readonly = NULL;
3692 if (mfx->removable) {
3693 free((void *)mfx->removable);
3694 mfx->removable = NULL;
3697 free((void *)mfx->update);
3701 free((void *)mfx->type);
3704 if (mfx->package_size) {
3705 free((void *)mfx->package_size);
3706 mfx->package_size = NULL;
3708 if (mfx->installed_time) {
3709 free((void *)mfx->installed_time);
3710 mfx->installed_time = NULL;
3712 if (mfx->installed_storage) {
3713 free((void *)mfx->installed_storage);
3714 mfx->installed_storage = NULL;
3716 if (mfx->storeclient_id) {
3717 free((void *)mfx->storeclient_id);
3718 mfx->storeclient_id = NULL;
3720 if (mfx->mainapp_id) {
3721 free((void *)mfx->mainapp_id);
3722 mfx->mainapp_id = NULL;
3724 if (mfx->package_url) {
3725 free((void *)mfx->package_url);
3726 mfx->package_url = NULL;
3728 if (mfx->root_path) {
3729 free((void *)mfx->root_path);
3730 mfx->root_path = NULL;
3732 if (mfx->appsetting) {
3733 free((void *)mfx->appsetting);
3734 mfx->appsetting = NULL;
3739 icon_x *icon = mfx->icon;
3741 while(icon != NULL) {
3743 __ps_free_icon(icon);
3749 label_x *label = mfx->label;
3750 label_x *tmp = NULL;
3751 while(label != NULL) {
3753 __ps_free_label(label);
3759 author_x *author = mfx->author;
3760 author_x *tmp = NULL;
3761 while(author != NULL) {
3763 __ps_free_author(author);
3767 /*Free Description*/
3768 if (mfx->description) {
3769 description_x *description = mfx->description;
3770 description_x *tmp = NULL;
3771 while(description != NULL) {
3772 tmp = description->next;
3773 __ps_free_description(description);
3779 license_x *license = mfx->license;
3780 license_x *tmp = NULL;
3781 while(license != NULL) {
3782 tmp = license->next;
3783 __ps_free_license(license);
3788 if (mfx->privileges) {
3789 privileges_x *privileges = mfx->privileges;
3790 privileges_x *tmp = NULL;
3791 while(privileges != NULL) {
3792 tmp = privileges->next;
3793 __ps_free_privileges(privileges);
3797 /*Free UiApplication*/
3798 if (mfx->uiapplication) {
3799 uiapplication_x *uiapplication = mfx->uiapplication;
3800 uiapplication_x *tmp = NULL;
3801 while(uiapplication != NULL) {
3802 tmp = uiapplication->next;
3803 __ps_free_uiapplication(uiapplication);
3804 uiapplication = tmp;
3807 /*Free ServiceApplication*/
3808 if (mfx->serviceapplication) {
3809 serviceapplication_x *serviceapplication = mfx->serviceapplication;
3810 serviceapplication_x *tmp = NULL;
3811 while(serviceapplication != NULL) {
3812 tmp = serviceapplication->next;
3813 __ps_free_serviceapplication(serviceapplication);
3814 serviceapplication = tmp;
3819 daemon_x *daemon = mfx->daemon;
3820 daemon_x *tmp = NULL;
3821 while(daemon != NULL) {
3823 __ps_free_daemon(daemon);
3829 theme_x *theme = mfx->theme;
3830 theme_x *tmp = NULL;
3831 while(theme != NULL) {
3833 __ps_free_theme(theme);
3839 font_x *font = mfx->font;
3841 while(font != NULL) {
3843 __ps_free_font(font);
3849 ime_x *ime = mfx->ime;
3851 while(ime != NULL) {
3857 /*Free Compatibility*/
3858 if (mfx->compatibility) {
3859 compatibility_x *compatibility = mfx->compatibility;
3860 compatibility_x *tmp = NULL;
3861 while(compatibility != NULL) {
3862 tmp = compatibility->next;
3863 __ps_free_compatibility(compatibility);
3864 compatibility = tmp;
3867 /*Free DeviceProfile*/
3868 if (mfx->deviceprofile) {
3869 deviceprofile_x *deviceprofile = mfx->deviceprofile;
3870 deviceprofile_x *tmp = NULL;
3871 while(deviceprofile != NULL) {
3872 tmp = deviceprofile->next;
3873 __ps_free_deviceprofile(deviceprofile);
3874 deviceprofile = tmp;
3882 API manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest)
3884 DBG("parsing start\n");
3885 xmlTextReaderPtr reader;
3886 manifest_x *mfx = NULL;
3888 reader = xmlReaderForFile(manifest, NULL, 0);
3890 mfx = malloc(sizeof(manifest_x));
3892 memset(mfx, '\0', sizeof(manifest_x));
3893 if (__process_manifest(reader, mfx) < 0) {
3894 DBG("Parsing Failed\n");
3895 pkgmgr_parser_free_manifest_xml(mfx);
3898 DBG("Parsing Success\n");
3900 DBG("Memory allocation error\n");
3902 xmlFreeTextReader(reader);
3904 DBG("Unable to create xml reader\n");
3909 /* These APIs are intended to call parser directly */
3911 API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
3913 char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", NULL};
3914 if (manifest == NULL) {
3915 DBG("argument supplied is NULL\n");
3916 return PMINFO_R_EINVAL;
3918 DBG("parsing manifest for installation: %s\n", manifest);
3919 manifest_x *mfx = NULL;
3921 char roxml_check[PKG_STRING_LEN_MAX] = {'\0'};
3924 mfx = pkgmgr_parser_process_manifest_xml(manifest);
3925 DBG("Parsing Finished\n");
3927 return PMINFO_R_ERROR;
3929 __streamFile(manifest, ACTION_INSTALL, temp, mfx->package);
3930 __add_preload_info(mfx, manifest);
3931 DBG("Added preload infomation\n");
3933 snprintf(roxml_check, PKG_STRING_LEN_MAX, MANIFEST_RO_DIRECTORY "/%s.xml", mfx->package);
3934 if (access(roxml_check, F_OK) == 0)
3935 mfx->update = strdup("true");
3937 mfx->update = strdup("false");
3939 ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
3941 DBG("DB Insert failed\n");
3943 DBG("DB Insert Success\n");
3945 ret = __ps_make_nativeapp_desktop(mfx, 0);
3947 DBG("Creating desktop file failed\n");
3949 DBG("Creating desktop file Success\n");
3951 pkgmgr_parser_free_manifest_xml(mfx);
3958 API int pkgmgr_parser_create_desktop_file(manifest_x *mfx)
3962 DBG("Manifest pointer is NULL\n");
3965 ret = __ps_make_nativeapp_desktop(mfx, 0);
3967 DBG("Creating desktop file failed\n");
3969 DBG("Creating desktop file Success\n");
3974 API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
3976 char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", NULL};
3977 if (manifest == NULL) {
3978 DBG("argument supplied is NULL\n");
3979 return PMINFO_R_EINVAL;
3981 DBG("parsing manifest for upgradation: %s\n", manifest);
3982 manifest_x *mfx = NULL;
3985 mfx = pkgmgr_parser_process_manifest_xml(manifest);
3986 DBG("Parsing Finished\n");
3988 return PMINFO_R_ERROR;
3990 __streamFile(manifest, ACTION_UPGRADE, temp, mfx->package);
3991 __add_preload_info(mfx, manifest);
3992 DBG("Added preload infomation\n");
3994 mfx->update = strdup("true");
3995 ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
3997 DBG("DB Update failed\n");
3999 DBG("DB Update Success\n");
4001 ret = __ps_make_nativeapp_desktop(mfx, 1);
4003 DBG("Creating desktop file failed\n");
4005 DBG("Creating desktop file Success\n");
4007 pkgmgr_parser_free_manifest_xml(mfx);
4014 API int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[])
4016 char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", NULL};
4017 if (manifest == NULL) {
4018 DBG("argument supplied is NULL\n");
4019 return PMINFO_R_EINVAL;
4021 DBG("parsing manifest for uninstallation: %s\n", manifest);
4022 manifest_x *mfx = NULL;
4025 mfx = pkgmgr_parser_process_manifest_xml(manifest);
4026 DBG("Parsing Finished\n");
4028 return PMINFO_R_ERROR;
4030 __streamFile(manifest, ACTION_UNINSTALL, temp, mfx->package);
4031 __add_preload_info(mfx, manifest);
4032 DBG("Added preload infomation\n");
4034 ret = pkgmgr_parser_delete_manifest_info_from_db(mfx);
4036 DBG("DB Delete failed\n");
4038 DBG("DB Delete Success\n");
4040 ret = __ps_remove_nativeapp_desktop(mfx);
4042 DBG("Removing desktop file failed\n");
4044 DBG("Removing desktop file Success\n");
4046 pkgmgr_parser_free_manifest_xml(mfx);
4053 API char *pkgmgr_parser_get_manifest_file(const char *pkgid)
4055 return __pkgid_to_manifest(pkgid);
4058 API int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
4060 return __ps_run_parser(docPtr, tag, ACTION_INSTALL, pkgid);
4063 API int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgid)
4065 return __ps_run_parser(docPtr, tag, ACTION_UPGRADE, pkgid);
4068 API int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
4070 return __ps_run_parser(docPtr, tag, ACTION_UNINSTALL, pkgid);
4073 #define SCHEMA_FILE "/usr/etc/package-manager/preload/manifest.xsd"
4075 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
4077 if (manifest == NULL) {
4078 DBGE("manifest file is NULL\n");
4079 return PMINFO_R_EINVAL;
4082 xmlSchemaParserCtxtPtr ctx;
4083 xmlSchemaValidCtxtPtr vctx;
4084 xmlSchemaPtr xschema;
4085 ctx = xmlSchemaNewParserCtxt(SCHEMA_FILE);
4087 DBGE("xmlSchemaNewParserCtxt() Failed\n");
4088 return PMINFO_R_ERROR;
4090 xschema = xmlSchemaParse(ctx);
4091 if (xschema == NULL) {
4092 DBGE("xmlSchemaParse() Failed\n");
4093 return PMINFO_R_ERROR;
4095 vctx = xmlSchemaNewValidCtxt(xschema);
4097 DBGE("xmlSchemaNewValidCtxt() Failed\n");
4098 return PMINFO_R_ERROR;
4100 xmlSchemaSetValidErrors(vctx, (xmlSchemaValidityErrorFunc) fprintf, (xmlSchemaValidityWarningFunc) fprintf, stderr);
4101 ret = xmlSchemaValidateFile(vctx, manifest, 0);
4103 DBGE("xmlSchemaValidateFile() failed\n");
4104 return PMINFO_R_ERROR;
4105 } else if (ret == 0) {
4106 DBGE("Manifest is Valid\n");
4109 DBGE("Manifest Validation Failed with error code %d\n", ret);
4110 return PMINFO_R_ERROR;
4116 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
4126 DBGE("fork failed\n");
4131 int dev_null_fd = open ("/dev/null", O_RDWR);
4132 if (dev_null_fd >= 0)
4134 dup2 (dev_null_fd, 0);/*stdin*/
4135 dup2 (dev_null_fd, 1);/*stdout*/
4136 dup2 (dev_null_fd, 2);/*stderr*/
4139 if (execl("/usr/bin/xmllint", "xmllint", manifest, "--schema",
4140 SCHEMA_FILE, NULL) < 0) {
4141 DBGE("execl error\n");
4151 while ((err = waitpid(pid, &status, WNOHANG)) != pid) {
4155 DBGE("waitpid failed\n");
4161 if(WIFEXITED(status) && !WEXITSTATUS(status))