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.
27 #include <libxml/parser.h>
28 #include <libxml/xmlreader.h>
29 #include <libxml/xmlschemas.h>
33 #include "pkgmgr_parser.h"
34 #include "pkgmgr_parser_internal.h"
35 #include "pkgmgr_parser_db.h"
36 #include "pkgmgr-info.h"
38 #define MANIFEST_RW_DIRECTORY "/opt/share/packages"
39 #define MANIFEST_RO_DIRECTORY "/usr/share/packages"
40 #define ASCII(s) (const char *)s
41 #define XMLCHAR(s) (const xmlChar *)s
53 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label);
54 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile);
55 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed);
56 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation);
57 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri);
58 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime);
59 static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp);
60 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition);
61 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notifiation);
62 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category);
63 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility);
64 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution);
65 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request);
66 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define);
67 static int __ps_process_registry(xmlTextReaderPtr reader, registry_x *registry);
68 static int __ps_process_database(xmlTextReaderPtr reader, database_x *database);
69 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc);
70 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions);
71 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare);
72 static int __ps_process_layout(xmlTextReaderPtr reader, layout_x *layout);
73 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon);
74 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author);
75 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description);
76 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability);
77 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license);
78 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol);
79 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol);
80 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication);
81 static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication);
82 static int __ps_process_font(xmlTextReaderPtr reader, font_x *font);
83 static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme);
84 static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon);
85 static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime);
86 static void __ps_free_label(label_x *label);
87 static void __ps_free_deviceprofile(deviceprofile_x * deviceprofile);
88 static void __ps_free_allowed(allowed_x *allowed);
89 static void __ps_free_operation(operation_x *operation);
90 static void __ps_free_uri(uri_x *uri);
91 static void __ps_free_mime(mime_x *mime);
92 static void __ps_free_subapp(subapp_x *subapp);
93 static void __ps_free_condition(condition_x *condition);
94 static void __ps_free_notification(notification_x *notifiation);
95 static void __ps_free_category(category_x *category);
96 static void __ps_free_compatibility(compatibility_x *compatibility);
97 static void __ps_free_resolution(resolution_x *resolution);
98 static void __ps_free_request(request_x *request);
99 static void __ps_free_define(define_x *define);
100 static void __ps_free_registry(registry_x *registry);
101 static void __ps_free_database(database_x *database);
102 static void __ps_free_appsvc(appsvc_x *appsvc);
103 static void __ps_free_launchconditions(launchconditions_x *launchconditions);
104 static void __ps_free_datashare(datashare_x *datashare);
105 static void __ps_free_layout(layout_x *layout);
106 static void __ps_free_icon(icon_x *icon);
107 static void __ps_free_author(author_x *author);
108 static void __ps_free_description(description_x *description);
109 static void __ps_free_capability(capability_x *capability);
110 static void __ps_free_license(license_x *license);
111 static void __ps_free_appcontrol(appcontrol_x *appcontrol);
112 static void __ps_free_datacontrol(datacontrol_x *datacontrol);
113 static void __ps_free_uiapplication(uiapplication_x *uiapplication);
114 static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication);
115 static void __ps_free_font(font_x *font);
116 static void __ps_free_theme(theme_x *theme);
117 static void __ps_free_daemon(daemon_x *daemon);
118 static void __ps_free_ime(ime_x *ime);
119 static char *__pkgid_to_manifest(const char *pkgid);
120 static int __next_child_element(xmlTextReaderPtr reader, int depth);
121 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx);
122 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx);
123 static void __str_trim(char *input);
124 static char *__get_parser_plugin(const char *type);
125 static int __ps_run_parser(xmlDocPtr docPtr, const char *tag, ACTION_TYPE action, const char *pkgid);
126 static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid);
127 static void __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgid);
128 static void __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid);
129 static int __validate_appid(const char *pkgid, const char *appid, char **newappid);
131 static void __str_trim(char *input)
133 char *trim_str = input;
138 while (*input != 0) {
139 if (!isspace(*input)) {
150 static int __validate_appid(const char *pkgid, const char *appid, char **newappid)
152 if (!pkgid || !appid || !newappid) {
153 DBG("Arg supplied is NULL\n");
156 int pkglen = strlen(pkgid);
157 int applen = strlen(appid);
161 if (strncmp(appid, ".", 1) == 0) {
162 len = pkglen + applen + 1;
163 newapp = calloc(1,len);
164 if (newapp == NULL) {
165 DBG("Malloc failed\n");
168 strncpy(newapp, pkgid, pkglen);
169 strncat(newapp, appid, applen);
170 DBG("new appid is %s\n", newapp);
174 if (applen < pkglen) {
175 DBG("app id is not proper\n");
177 #ifdef _VALIDATE_APPID_
183 if (!strcmp(appid, pkgid)) {
184 DBG("appid is proper\n");
188 else if (strncmp(appid, pkgid, pkglen) == 0) {
189 ptr = strstr(appid, pkgid);
191 if (strncmp(ptr, ".", 1) == 0) {
192 DBG("appid is proper\n");
197 DBG("appid is not proper\n");
199 #ifdef _VALIDATE_APPID_
206 DBG("appid is not proper\n");
208 #ifdef _VALIDATE_APPID_
218 static char *__get_parser_plugin(const char *type)
221 char buffer[1024] = { 0 };
222 char temp_path[1024] = { 0 };
223 char *lib_path = NULL;
227 DBGE("invalid argument\n");
231 fp = fopen(PKG_PARSER_CONF_PATH, "r");
233 DBGE("no matching backendlib\n");
237 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
238 if (buffer[0] == '#')
243 if ((path = strstr(buffer, PKG_PARSERLIB)) != NULL) {
245 path = path + strlen(PKG_PARSERLIB);
251 memset(buffer, 0x00, 1024);
258 DBGE("no matching backendlib\n");
262 snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
264 return strdup(temp_path);
267 static int __ps_run_parser(xmlDocPtr docPtr, const char *tag,
268 ACTION_TYPE action, const char *pkgid)
270 char *lib_path = NULL;
271 void *lib_handle = NULL;
272 int (*plugin_install) (xmlDocPtr, const char *);
278 ac = "PKGMGR_PARSER_PLUGIN_INSTALL";
281 ac = "PKGMGR_PARSER_PLUGIN_UPGRADE";
283 case ACTION_UNINSTALL:
284 ac = "PKGMGR_PARSER_PLUGIN_UNINSTALL";
290 lib_path = __get_parser_plugin(tag);
295 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
296 DBGE("dlopen is failed lib_path[%s]\n", lib_path);
300 if ((plugin_install =
301 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
302 DBGE("can not find symbol \n");
306 ret = plugin_install(docPtr, pkgid);
316 static char *__pkgid_to_manifest(const char *pkgid)
322 DBGE("pkgid is NULL");
326 size = strlen(MANIFEST_RW_DIRECTORY) + strlen(pkgid) + 10;
327 manifest = malloc(size);
328 if (manifest == NULL) {
332 memset(manifest, '\0', size);
333 snprintf(manifest, size, MANIFEST_RW_DIRECTORY "/%s.xml", pkgid);
335 if (access(manifest, F_OK)) {
336 snprintf(manifest, size, MANIFEST_RO_DIRECTORY "/%s.xml", pkgid);
342 static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid)
346 char *parser_cmd = NULL;
349 char *lib_path = NULL;
350 void *lib_handle = NULL;
351 int (*plugin_install) (xmlDocPtr);
353 DBG("__run_parser_prestep");
355 if (xmlTextReaderDepth(reader) != 1) {
356 DBGE("Node depth is not 1");
360 if (xmlTextReaderNodeType(reader) != 1) {
361 DBGE("Node type is not 1");
365 const xmlChar *value;
366 name = xmlTextReaderConstName(reader);
368 DBGE("TEST TEST TES\n");
369 name = BAD_CAST "--";
372 value = xmlTextReaderConstValue(reader);
373 DBG("%d %d %s %d %d",
374 xmlTextReaderDepth(reader),
375 xmlTextReaderNodeType(reader),
377 xmlTextReaderIsEmptyElement(reader), xmlTextReaderHasValue(reader));
380 DBG("ConstValue NULL");
382 if (xmlStrlen(value) > 40) {
383 DBG(" %.40s...", value);
389 name = xmlTextReaderConstName(reader);
391 DBGE("TEST TEST TES\n");
392 name = BAD_CAST "--";
395 xmlDocPtr docPtr = xmlTextReaderCurrentDoc(reader);
396 DBG("docPtr->URL %s\n", (char *)docPtr->URL);
397 xmlDocPtr copyDocPtr = xmlCopyDoc(docPtr, 1);
398 if (copyDocPtr == NULL)
400 xmlNode *rootElement = xmlDocGetRootElement(copyDocPtr);
401 if (rootElement == NULL)
403 xmlNode *cur_node = xmlFirstElementChild(rootElement);
404 if (cur_node == NULL)
406 xmlNode *temp = xmlTextReaderExpand(reader);
409 xmlNode *next_node = NULL;
410 while(cur_node != NULL)
412 if ( (strcmp(temp->name, cur_node->name) == 0) &&
413 (temp->line == cur_node->line) ) {
417 next_node = xmlNextElementSibling(cur_node);
418 xmlUnlinkNode(cur_node);
419 xmlFreeNode(cur_node);
420 cur_node = next_node;
423 if (cur_node == NULL)
425 next_node = xmlNextElementSibling(cur_node);
427 cur_node->next = NULL;
428 next_node->prev = NULL;
429 xmlFreeNodeList(next_node);
430 xmlSetTreeDoc(cur_node, copyDocPtr);
432 xmlSetTreeDoc(cur_node, copyDocPtr);
438 DBG("node type: %d, name: %s children->name: %s last->name: %s\n"
439 "parent->name: %s next->name: %s prev->name: %s\n",
440 cur_node->type, cur_node->name,
441 cur_node->children ? cur_node->children->name : "NULL",
442 cur_node->last ? cur_node->last->name : "NULL",
443 cur_node->parent ? cur_node->parent->name : "NULL",
444 cur_node->next ? cur_node->next->name : "NULL",
445 cur_node->prev ? cur_node->prev->name : "NULL");
447 FILE *fp = fopen("/opt/share/test.xml", "a");
448 xmlDocDump(fp, copyDocPtr);
453 ret = __ps_run_parser(copyDocPtr, name, action, pkgid);
460 __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgid)
465 switch (xmlTextReaderNodeType(reader)) {
466 case XML_READER_TYPE_END_ELEMENT:
468 // DBG("XML_READER_TYPE_END_ELEMENT");
472 case XML_READER_TYPE_ELEMENT:
474 // Elements without closing tag don't receive
475 // XML_READER_TYPE_END_ELEMENT event.
477 const xmlChar *elementName =
478 xmlTextReaderLocalName(reader);
479 if (elementName == NULL) {
480 // DBG("elementName %s\n", (char *)elementName);
484 const xmlChar *nameSpace =
485 xmlTextReaderConstNamespaceUri(reader);
487 // DBG("nameSpace %s\n", (char *)nameSpace);
490 DBG("XML_READER_TYPE_ELEMENT %s, %s\n",
491 elementName ? elementName : "NULL",
492 nameSpace ? nameSpace : "NULL");
495 DBG("__run_parser_prestep pkgid[%s]\n", pkgid);
496 __run_parser_prestep(reader, action, pkgid);
500 for (tag = tagv[0]; tag; tag = tagv[++i])
501 if (strcmp(tag, elementName) == 0) {
502 DBG("__run_parser_prestep tag[%s] pkgid[%s]\n", tag, pkgid);
503 __run_parser_prestep(reader,
511 case XML_READER_TYPE_TEXT:
512 case XML_READER_TYPE_CDATA:
514 const xmlChar *value = xmlTextReaderConstValue(reader);
516 // DBG("value %s\n", value);
519 const xmlChar *lang = xmlTextReaderConstXmlLang(reader);
521 // DBG("lang\n", lang);
524 /* DBG("XML_READER_TYPE_TEXT %s, %s\n",
525 value ? value : "NULL", lang ? lang : "NULL");
530 // DBG("Ignoring Node of Type: %d", xmlTextReaderNodeType(reader));
536 __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid)
538 xmlTextReaderPtr reader;
542 docPtr = xmlReadFile(filename, NULL, 0);
543 reader = xmlReaderWalker(docPtr);
544 if (reader != NULL) {
545 ret = xmlTextReaderRead(reader);
547 __processNode(reader, action, tagv, pkgid);
548 ret = xmlTextReaderRead(reader);
550 xmlFreeTextReader(reader);
553 DBGE("%s : failed to parse", filename);
556 DBGE("Unable to open %s", filename);
560 static int __next_child_element(xmlTextReaderPtr reader, int depth)
562 int ret = xmlTextReaderRead(reader);
563 int cur = xmlTextReaderDepth(reader);
566 switch (xmlTextReaderNodeType(reader)) {
567 case XML_READER_TYPE_ELEMENT:
568 if (cur == depth + 1)
571 case XML_READER_TYPE_TEXT:
572 /*text is handled by each function separately*/
573 if (cur == depth + 1)
576 case XML_READER_TYPE_END_ELEMENT:
585 ret = xmlTextReaderRead(reader);
586 cur = xmlTextReaderDepth(reader);
591 static void __ps_free_category(category_x *category)
593 if (category == NULL)
595 if (category->name) {
596 free((void *)category->name);
597 category->name = NULL;
599 free((void*)category);
603 static void __ps_free_icon(icon_x *icon)
608 free((void *)icon->text);
612 free((void *)icon->lang);
616 free((void *)icon->name);
620 free((void *)icon->section);
621 icon->section = NULL;
624 free((void *)icon->size);
627 if (icon->resolution) {
628 free((void *)icon->resolution);
629 icon->resolution = NULL;
635 static void __ps_free_operation(operation_x *operation)
637 if (operation == NULL)
639 if (operation->text) {
640 free((void *)operation->text);
641 operation->text = NULL;
643 free((void*)operation);
647 static void __ps_free_uri(uri_x *uri)
652 free((void *)uri->text);
659 static void __ps_free_mime(mime_x *mime)
664 free((void *)mime->text);
671 static void __ps_free_subapp(subapp_x *subapp)
676 free((void *)subapp->text);
683 static void __ps_free_condition(condition_x *condition)
685 if (condition == NULL)
687 if (condition->text) {
688 free((void *)condition->text);
689 condition->text = NULL;
691 if (condition->name) {
692 free((void *)condition->name);
693 condition->name = NULL;
695 free((void*)condition);
699 static void __ps_free_notification(notification_x *notification)
701 if (notification == NULL)
703 if (notification->text) {
704 free((void *)notification->text);
705 notification->text = NULL;
707 if (notification->name) {
708 free((void *)notification->name);
709 notification->name = NULL;
711 free((void*)notification);
715 static void __ps_free_compatibility(compatibility_x *compatibility)
717 if (compatibility == NULL)
719 if (compatibility->text) {
720 free((void *)compatibility->text);
721 compatibility->text = NULL;
723 if (compatibility->name) {
724 free((void *)compatibility->name);
725 compatibility->name = NULL;
727 free((void*)compatibility);
728 compatibility = NULL;
731 static void __ps_free_resolution(resolution_x *resolution)
733 if (resolution == NULL)
735 if (resolution->mimetype) {
736 free((void *)resolution->mimetype);
737 resolution->mimetype = NULL;
739 if (resolution->urischeme) {
740 free((void *)resolution->urischeme);
741 resolution->urischeme = NULL;
743 free((void*)resolution);
747 static void __ps_free_capability(capability_x *capability)
749 if (capability == NULL)
751 if (capability->operationid) {
752 free((void *)capability->operationid);
753 capability->operationid = NULL;
756 if (capability->resolution) {
757 resolution_x *resolution = capability->resolution;
758 resolution_x *tmp = NULL;
759 while(resolution != NULL)
761 tmp = resolution->next;
762 __ps_free_resolution(resolution);
766 free((void*)capability);
770 static void __ps_free_allowed(allowed_x *allowed)
775 free((void *)allowed->name);
776 allowed->name = NULL;
779 free((void *)allowed->text);
780 allowed->text = NULL;
782 free((void*)allowed);
786 static void __ps_free_request(request_x *request)
791 free((void *)request->text);
792 request->text = NULL;
794 free((void*)request);
798 static void __ps_free_datacontrol(datacontrol_x *datacontrol)
800 if (datacontrol == NULL)
802 if (datacontrol->providerid) {
803 free((void *)datacontrol->providerid);
804 datacontrol->providerid = NULL;
807 if (datacontrol->capability) {
808 capability_x *capability = datacontrol->capability;
809 capability_x *tmp = NULL;
810 while(capability != NULL)
812 tmp = capability->next;
813 __ps_free_capability(capability);
817 free((void*)datacontrol);
821 static void __ps_free_launchconditions(launchconditions_x *launchconditions)
823 if (launchconditions == NULL)
825 if (launchconditions->text) {
826 free((void *)launchconditions->text);
827 launchconditions->text = NULL;
830 if (launchconditions->condition) {
831 condition_x *condition = launchconditions->condition;
832 condition_x *tmp = NULL;
833 while(condition != NULL)
835 tmp = condition->next;
836 __ps_free_condition(condition);
840 free((void*)launchconditions);
841 launchconditions = NULL;
844 static void __ps_free_appcontrol(appcontrol_x *appcontrol)
846 if (appcontrol == NULL)
848 if (appcontrol->text) {
849 free((void *)appcontrol->text);
850 appcontrol->text = NULL;
853 if (appcontrol->operation) {
854 operation_x *operation = appcontrol->operation;
855 operation_x *tmp = NULL;
856 while(operation != NULL)
858 tmp = operation->next;
859 __ps_free_operation(operation);
864 if (appcontrol->uri) {
865 uri_x *uri = appcontrol->uri;
875 if (appcontrol->mime) {
876 mime_x *mime = appcontrol->mime;
881 __ps_free_mime(mime);
886 if (appcontrol->subapp) {
887 subapp_x *subapp = appcontrol->subapp;
888 subapp_x *tmp = NULL;
889 while(subapp != NULL)
892 __ps_free_subapp(subapp);
896 free((void*)appcontrol);
900 static void __ps_free_appsvc(appsvc_x *appsvc)
905 free((void *)appsvc->text);
909 if (appsvc->operation) {
910 operation_x *operation = appsvc->operation;
911 operation_x *tmp = NULL;
912 while(operation != NULL)
914 tmp = operation->next;
915 __ps_free_operation(operation);
921 uri_x *uri = appsvc->uri;
932 mime_x *mime = appsvc->mime;
937 __ps_free_mime(mime);
942 if (appsvc->subapp) {
943 subapp_x *subapp = appsvc->subapp;
944 subapp_x *tmp = NULL;
945 while(subapp != NULL)
948 __ps_free_subapp(subapp);
956 static void __ps_free_deviceprofile(deviceprofile_x *deviceprofile)
961 static void __ps_free_define(define_x *define)
966 free((void *)define->path);
970 if (define->request) {
971 request_x *request = define->request;
972 request_x *tmp = NULL;
973 while(request != NULL)
976 __ps_free_request(request);
981 if (define->allowed) {
982 allowed_x *allowed = define->allowed;
983 allowed_x *tmp = NULL;
984 while(allowed != NULL)
987 __ps_free_allowed(allowed);
995 static void __ps_free_registry(registry_x *registry)
997 if (registry == NULL)
999 if (registry->name) {
1000 free((void *)registry->name);
1001 registry->name = NULL;
1003 if (registry->text) {
1004 free((void *)registry->text);
1005 registry->text = NULL;
1007 free((void*)registry);
1011 static void __ps_free_database(database_x *database)
1013 if (database == NULL)
1015 if (database->name) {
1016 free((void *)database->name);
1017 database->name = NULL;
1019 if (database->text) {
1020 free((void *)database->text);
1021 database->text = NULL;
1023 free((void*)database);
1027 static void __ps_free_datashare(datashare_x *datashare)
1029 if (datashare == NULL)
1032 if (datashare->define) {
1033 define_x *define = datashare->define;
1034 define_x *tmp = NULL;
1035 while(define != NULL)
1038 __ps_free_define(define);
1043 if (datashare->request) {
1044 request_x *request = datashare->request;
1045 request_x *tmp = NULL;
1046 while(request != NULL)
1048 tmp = request->next;
1049 __ps_free_request(request);
1053 free((void*)datashare);
1057 static void __ps_free_layout(layout_x *layout)
1062 free((void *)layout->name);
1063 layout->name = NULL;
1066 free((void *)layout->text);
1067 layout->text = NULL;
1069 free((void*)layout);
1073 static void __ps_free_label(label_x *label)
1078 free((void *)label->name);
1082 free((void *)label->text);
1086 free((void *)label->lang);
1093 static void __ps_free_author(author_x *author)
1097 if (author->email) {
1098 free((void *)author->email);
1099 author->email = NULL;
1102 free((void *)author->text);
1103 author->text = NULL;
1106 free((void *)author->href);
1107 author->href = NULL;
1110 free((void *)author->lang);
1111 author->lang = NULL;
1113 free((void*)author);
1117 static void __ps_free_description(description_x *description)
1119 if (description == NULL)
1121 if (description->name) {
1122 free((void *)description->name);
1123 description->name = NULL;
1125 if (description->text) {
1126 free((void *)description->text);
1127 description->text = NULL;
1129 if (description->lang) {
1130 free((void *)description->lang);
1131 description->lang = NULL;
1133 free((void*)description);
1137 static void __ps_free_license(license_x *license)
1139 if (license == NULL)
1141 if (license->text) {
1142 free((void *)license->text);
1143 license->text = NULL;
1145 if (license->lang) {
1146 free((void *)license->lang);
1147 license->lang = NULL;
1149 free((void*)license);
1153 static void __ps_free_uiapplication(uiapplication_x *uiapplication)
1155 if (uiapplication == NULL)
1157 if (uiapplication->exec) {
1158 free((void *)uiapplication->exec);
1159 uiapplication->exec = NULL;
1161 if (uiapplication->appid) {
1162 free((void *)uiapplication->appid);
1163 uiapplication->appid = NULL;
1165 if (uiapplication->nodisplay) {
1166 free((void *)uiapplication->nodisplay);
1167 uiapplication->nodisplay = NULL;
1169 if (uiapplication->multiple) {
1170 free((void *)uiapplication->multiple);
1171 uiapplication->multiple = NULL;
1173 if (uiapplication->type) {
1174 free((void *)uiapplication->type);
1175 uiapplication->type = NULL;
1177 if (uiapplication->categories) {
1178 free((void *)uiapplication->categories);
1179 uiapplication->categories = NULL;
1181 if (uiapplication->extraid) {
1182 free((void *)uiapplication->extraid);
1183 uiapplication->extraid = NULL;
1185 if (uiapplication->taskmanage) {
1186 free((void *)uiapplication->taskmanage);
1187 uiapplication->taskmanage = NULL;
1189 if (uiapplication->hwacceleration) {
1190 free((void *)uiapplication->hwacceleration);
1191 uiapplication->hwacceleration = NULL;
1193 if (uiapplication->mainapp) {
1194 free((void *)uiapplication->mainapp);
1195 uiapplication->mainapp = NULL;
1197 if (uiapplication->recentimage) {
1198 free((void *)uiapplication->recentimage);
1199 uiapplication->recentimage = NULL;
1202 if (uiapplication->label) {
1203 label_x *label = uiapplication->label;
1204 label_x *tmp = NULL;
1205 while(label != NULL)
1208 __ps_free_label(label);
1213 if (uiapplication->icon) {
1214 icon_x *icon = uiapplication->icon;
1219 __ps_free_icon(icon);
1224 if (uiapplication->appcontrol) {
1225 appcontrol_x *appcontrol = uiapplication->appcontrol;
1226 appcontrol_x *tmp = NULL;
1227 while(appcontrol != NULL)
1229 tmp = appcontrol->next;
1230 __ps_free_appcontrol(appcontrol);
1234 /*Free LaunchConditions*/
1235 if (uiapplication->launchconditions) {
1236 launchconditions_x *launchconditions = uiapplication->launchconditions;
1237 launchconditions_x *tmp = NULL;
1238 while(launchconditions != NULL)
1240 tmp = launchconditions->next;
1241 __ps_free_launchconditions(launchconditions);
1242 launchconditions = tmp;
1245 /*Free Notification*/
1246 if (uiapplication->notification) {
1247 notification_x *notification = uiapplication->notification;
1248 notification_x *tmp = NULL;
1249 while(notification != NULL)
1251 tmp = notification->next;
1252 __ps_free_notification(notification);
1257 if (uiapplication->datashare) {
1258 datashare_x *datashare = uiapplication->datashare;
1259 datashare_x *tmp = NULL;
1260 while(datashare != NULL)
1262 tmp = datashare->next;
1263 __ps_free_datashare(datashare);
1268 if (uiapplication->appsvc) {
1269 appsvc_x *appsvc = uiapplication->appsvc;
1270 appsvc_x *tmp = NULL;
1271 while(appsvc != NULL)
1274 __ps_free_appsvc(appsvc);
1279 if (uiapplication->category) {
1280 category_x *category = uiapplication->category;
1281 category_x *tmp = NULL;
1282 while(category != NULL)
1284 tmp = category->next;
1285 __ps_free_category(category);
1289 free((void*)uiapplication);
1290 uiapplication = NULL;
1293 static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication)
1295 if (serviceapplication == NULL)
1297 if (serviceapplication->exec) {
1298 free((void *)serviceapplication->exec);
1299 serviceapplication->exec = NULL;
1301 if (serviceapplication->appid) {
1302 free((void *)serviceapplication->appid);
1303 serviceapplication->appid = NULL;
1305 if (serviceapplication->onboot) {
1306 free((void *)serviceapplication->onboot);
1307 serviceapplication->onboot = NULL;
1309 if (serviceapplication->autorestart) {
1310 free((void *)serviceapplication->autorestart);
1311 serviceapplication->autorestart = NULL;
1313 if (serviceapplication->type) {
1314 free((void *)serviceapplication->type);
1315 serviceapplication->type = NULL;
1318 if (serviceapplication->label) {
1319 label_x *label = serviceapplication->label;
1320 label_x *tmp = NULL;
1321 while(label != NULL)
1324 __ps_free_label(label);
1329 if (serviceapplication->icon) {
1330 icon_x *icon = serviceapplication->icon;
1335 __ps_free_icon(icon);
1340 if (serviceapplication->appcontrol) {
1341 appcontrol_x *appcontrol = serviceapplication->appcontrol;
1342 appcontrol_x *tmp = NULL;
1343 while(appcontrol != NULL)
1345 tmp = appcontrol->next;
1346 __ps_free_appcontrol(appcontrol);
1350 /*Free DataControl*/
1351 if (serviceapplication->datacontrol) {
1352 datacontrol_x *datacontrol = serviceapplication->datacontrol;
1353 datacontrol_x *tmp = NULL;
1354 while(datacontrol != NULL)
1356 tmp = datacontrol->next;
1357 __ps_free_datacontrol(datacontrol);
1361 /*Free LaunchConditions*/
1362 if (serviceapplication->launchconditions) {
1363 launchconditions_x *launchconditions = serviceapplication->launchconditions;
1364 launchconditions_x *tmp = NULL;
1365 while(launchconditions != NULL)
1367 tmp = launchconditions->next;
1368 __ps_free_launchconditions(launchconditions);
1369 launchconditions = tmp;
1372 /*Free Notification*/
1373 if (serviceapplication->notification) {
1374 notification_x *notification = serviceapplication->notification;
1375 notification_x *tmp = NULL;
1376 while(notification != NULL)
1378 tmp = notification->next;
1379 __ps_free_notification(notification);
1384 if (serviceapplication->datashare) {
1385 datashare_x *datashare = serviceapplication->datashare;
1386 datashare_x *tmp = NULL;
1387 while(datashare != NULL)
1389 tmp = datashare->next;
1390 __ps_free_datashare(datashare);
1395 if (serviceapplication->appsvc) {
1396 appsvc_x *appsvc = serviceapplication->appsvc;
1397 appsvc_x *tmp = NULL;
1398 while(appsvc != NULL)
1401 __ps_free_appsvc(appsvc);
1406 if (serviceapplication->category) {
1407 category_x *category = serviceapplication->category;
1408 category_x *tmp = NULL;
1409 while(category != NULL)
1411 tmp = category->next;
1412 __ps_free_category(category);
1416 free((void*)serviceapplication);
1417 serviceapplication = NULL;
1420 static void __ps_free_font(font_x *font)
1425 free((void *)font->name);
1429 free((void *)font->text);
1436 static void __ps_free_theme(theme_x *theme)
1441 free((void *)theme->name);
1445 free((void *)theme->text);
1452 static void __ps_free_daemon(daemon_x *daemon)
1457 free((void *)daemon->name);
1458 daemon->name = NULL;
1461 free((void *)daemon->text);
1462 daemon->text = NULL;
1464 free((void*)daemon);
1468 static void __ps_free_ime(ime_x *ime)
1473 free((void *)ime->name);
1477 free((void *)ime->text);
1485 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed)
1487 xmlTextReaderRead(reader);
1488 if (xmlTextReaderValue(reader))
1489 allowed->text = ASCII(xmlTextReaderValue(reader));
1493 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation)
1495 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1496 operation->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1497 /* Text does not exist. Only attribute exists
1498 xmlTextReaderRead(reader);
1499 if (xmlTextReaderValue(reader))
1500 operation->text = ASCII(xmlTextReaderValue(reader));
1505 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri)
1507 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1508 uri->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1509 /* Text does not exist. Only attribute exists
1510 xmlTextReaderRead(reader);
1511 if (xmlTextReaderValue(reader))
1512 uri->text = ASCII(xmlTextReaderValue(reader));
1517 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime)
1519 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1520 mime->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1521 /* Text does not exist. Only attribute exists
1522 xmlTextReaderRead(reader);
1523 if (xmlTextReaderValue(reader))
1524 mime->text = ASCII(xmlTextReaderValue(reader));
1529 static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp)
1531 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1532 subapp->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1533 /* Text does not exist. Only attribute exists
1534 xmlTextReaderRead(reader);
1535 if (xmlTextReaderValue(reader))
1536 mime->text = ASCII(xmlTextReaderValue(reader));
1541 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition)
1543 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1544 condition->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1545 xmlTextReaderRead(reader);
1546 if (xmlTextReaderValue(reader))
1547 condition->text = ASCII(xmlTextReaderValue(reader));
1551 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notification)
1553 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1554 notification->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1555 xmlTextReaderRead(reader);
1556 if (xmlTextReaderValue(reader))
1557 notification->text = ASCII(xmlTextReaderValue(reader));
1561 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category)
1563 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1564 category->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1568 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility)
1570 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1571 compatibility->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1572 xmlTextReaderRead(reader);
1573 if (xmlTextReaderValue(reader))
1574 compatibility->text = ASCII(xmlTextReaderValue(reader));
1578 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution)
1580 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")))
1581 resolution->mimetype = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")));
1582 if (xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")))
1583 resolution->urischeme = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")));
1587 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request)
1589 xmlTextReaderRead(reader);
1590 if (xmlTextReaderValue(reader))
1591 request->text = ASCII(xmlTextReaderValue(reader));
1595 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define)
1597 const xmlChar *node;
1600 allowed_x *tmp1 = NULL;
1601 request_x *tmp2 = NULL;
1603 if (xmlTextReaderGetAttribute(reader, XMLCHAR("path")))
1604 define->path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("path")));
1606 depth = xmlTextReaderDepth(reader);
1607 while ((ret = __next_child_element(reader, depth))) {
1608 node = xmlTextReaderConstName(reader);
1610 DBG("xmlTextReaderConstName value is NULL\n");
1614 if (!strcmp(ASCII(node), "allowed")) {
1615 allowed_x *allowed= malloc(sizeof(allowed_x));
1616 if (allowed == NULL) {
1617 DBG("Malloc Failed\n");
1620 memset(allowed, '\0', sizeof(allowed_x));
1621 LISTADD(define->allowed, allowed);
1622 ret = __ps_process_allowed(reader, allowed);
1623 } else if (!strcmp(ASCII(node), "request")) {
1624 request_x *request = malloc(sizeof(request_x));
1625 if (request == NULL) {
1626 DBG("Malloc Failed\n");
1629 memset(request, '\0', sizeof(request_x));
1630 LISTADD(define->request, request);
1631 ret = __ps_process_request(reader, request);
1635 DBG("Processing define failed\n");
1639 if (define->allowed) {
1640 LISTHEAD(define->allowed, tmp1);
1641 define->allowed = tmp1;
1643 if (define->request) {
1644 LISTHEAD(define->request, tmp2);
1645 define->request = tmp2;
1650 static int __ps_process_registry(xmlTextReaderPtr reader, registry_x *registry)
1652 /*TODO: once policy is set*/
1656 static int __ps_process_database(xmlTextReaderPtr reader, database_x *database)
1658 /*TODO: once policy is set*/
1662 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol)
1664 const xmlChar *node;
1667 operation_x *tmp1 = NULL;
1669 mime_x *tmp3 = NULL;
1670 subapp_x *tmp4 = NULL;
1672 depth = xmlTextReaderDepth(reader);
1673 while ((ret = __next_child_element(reader, depth))) {
1674 node = xmlTextReaderConstName(reader);
1676 DBG("xmlTextReaderConstName value is NULL\n");
1680 if (!strcmp(ASCII(node), "operation")) {
1681 operation_x *operation = malloc(sizeof(operation_x));
1682 if (operation == NULL) {
1683 DBG("Malloc Failed\n");
1686 memset(operation, '\0', sizeof(operation_x));
1687 LISTADD(appcontrol->operation, operation);
1688 ret = __ps_process_operation(reader, operation);
1689 DBG("operation processing\n");
1690 } else if (!strcmp(ASCII(node), "uri")) {
1691 uri_x *uri= malloc(sizeof(uri_x));
1693 DBG("Malloc Failed\n");
1696 memset(uri, '\0', sizeof(uri_x));
1697 LISTADD(appcontrol->uri, uri);
1698 ret = __ps_process_uri(reader, uri);
1699 DBG("uri processing\n");
1700 } else if (!strcmp(ASCII(node), "mime")) {
1701 mime_x *mime = malloc(sizeof(mime_x));
1703 DBG("Malloc Failed\n");
1706 memset(mime, '\0', sizeof(mime_x));
1707 LISTADD(appcontrol->mime, mime);
1708 ret = __ps_process_mime(reader, mime);
1709 DBG("mime processing\n");
1710 } else if (!strcmp(ASCII(node), "subapp")) {
1711 subapp_x *subapp = malloc(sizeof(subapp_x));
1712 if (subapp == NULL) {
1713 DBG("Malloc Failed\n");
1716 memset(subapp, '\0', sizeof(subapp_x));
1717 LISTADD(appcontrol->subapp, subapp);
1718 ret = __ps_process_subapp(reader, subapp);
1719 DBG("subapp processing\n");
1723 DBG("Processing appcontrol failed\n");
1727 if (appcontrol->operation) {
1728 LISTHEAD(appcontrol->operation, tmp1);
1729 appcontrol->operation = tmp1;
1731 if (appcontrol->uri) {
1732 LISTHEAD(appcontrol->uri, tmp2);
1733 appcontrol->uri = tmp2;
1735 if (appcontrol->mime) {
1736 LISTHEAD(appcontrol->mime, tmp3);
1737 appcontrol->mime = tmp3;
1739 if (appcontrol->subapp) {
1740 LISTHEAD(appcontrol->subapp, tmp4);
1741 appcontrol->subapp = tmp4;
1744 xmlTextReaderRead(reader);
1745 if (xmlTextReaderValue(reader))
1746 appcontrol->text = ASCII(xmlTextReaderValue(reader));
1751 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc)
1753 const xmlChar *node;
1756 operation_x *tmp1 = NULL;
1758 mime_x *tmp3 = NULL;
1759 subapp_x *tmp4 = NULL;
1761 depth = xmlTextReaderDepth(reader);
1762 while ((ret = __next_child_element(reader, depth))) {
1763 node = xmlTextReaderConstName(reader);
1765 DBG("xmlTextReaderConstName value is NULL\n");
1769 if (!strcmp(ASCII(node), "operation")) {
1770 operation_x *operation = malloc(sizeof(operation_x));
1771 if (operation == NULL) {
1772 DBG("Malloc Failed\n");
1775 memset(operation, '\0', sizeof(operation_x));
1776 LISTADD(appsvc->operation, operation);
1777 ret = __ps_process_operation(reader, operation);
1778 DBG("operation processing\n");
1779 } else if (!strcmp(ASCII(node), "uri")) {
1780 uri_x *uri= malloc(sizeof(uri_x));
1782 DBG("Malloc Failed\n");
1785 memset(uri, '\0', sizeof(uri_x));
1786 LISTADD(appsvc->uri, uri);
1787 ret = __ps_process_uri(reader, uri);
1788 DBG("uri processing\n");
1789 } else if (!strcmp(ASCII(node), "mime")) {
1790 mime_x *mime = malloc(sizeof(mime_x));
1792 DBG("Malloc Failed\n");
1795 memset(mime, '\0', sizeof(mime_x));
1796 LISTADD(appsvc->mime, mime);
1797 ret = __ps_process_mime(reader, mime);
1798 DBG("mime processing\n");
1799 } else if (!strcmp(ASCII(node), "subapp")) {
1800 subapp_x *subapp = malloc(sizeof(subapp_x));
1801 if (subapp == NULL) {
1802 DBG("Malloc Failed\n");
1805 memset(subapp, '\0', sizeof(subapp_x));
1806 LISTADD(appsvc->subapp, subapp);
1807 ret = __ps_process_subapp(reader, subapp);
1808 DBG("subapp processing\n");
1812 DBG("Processing appsvc failed\n");
1816 if (appsvc->operation) {
1817 LISTHEAD(appsvc->operation, tmp1);
1818 appsvc->operation = tmp1;
1821 LISTHEAD(appsvc->uri, tmp2);
1825 LISTHEAD(appsvc->mime, tmp3);
1826 appsvc->mime = tmp3;
1828 if (appsvc->subapp) {
1829 LISTHEAD(appsvc->subapp, tmp4);
1830 appsvc->subapp = tmp4;
1833 xmlTextReaderRead(reader);
1834 if (xmlTextReaderValue(reader))
1835 appsvc->text = ASCII(xmlTextReaderValue(reader));
1840 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions)
1842 const xmlChar *node;
1845 condition_x *tmp1 = NULL;
1847 depth = xmlTextReaderDepth(reader);
1848 while ((ret = __next_child_element(reader, depth))) {
1849 node = xmlTextReaderConstName(reader);
1851 DBG("xmlTextReaderConstName value is NULL\n");
1855 if (strcmp(ASCII(node), "condition") == 0) {
1856 condition_x *condition = malloc(sizeof(condition_x));
1857 if (condition == NULL) {
1858 DBG("Malloc Failed\n");
1861 memset(condition, '\0', sizeof(condition_x));
1862 LISTADD(launchconditions->condition, condition);
1863 ret = __ps_process_condition(reader, condition);
1867 DBG("Processing launchconditions failed\n");
1871 if (launchconditions->condition) {
1872 LISTHEAD(launchconditions->condition, tmp1);
1873 launchconditions->condition = tmp1;
1876 xmlTextReaderRead(reader);
1877 if (xmlTextReaderValue(reader))
1878 launchconditions->text = ASCII(xmlTextReaderValue(reader));
1883 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare)
1885 const xmlChar *node;
1888 define_x *tmp1 = NULL;
1889 request_x *tmp2 = NULL;
1890 depth = xmlTextReaderDepth(reader);
1891 while ((ret = __next_child_element(reader, depth))) {
1892 node = xmlTextReaderConstName(reader);
1894 DBG("xmlTextReaderConstName value is NULL\n");
1898 if (!strcmp(ASCII(node), "define")) {
1899 define_x *define= malloc(sizeof(define_x));
1900 if (define == NULL) {
1901 DBG("Malloc Failed\n");
1904 memset(define, '\0', sizeof(define_x));
1905 LISTADD(datashare->define, define);
1906 ret = __ps_process_define(reader, define);
1907 } else if (!strcmp(ASCII(node), "request")) {
1908 request_x *request= malloc(sizeof(request_x));
1909 if (request == NULL) {
1910 DBG("Malloc Failed\n");
1913 memset(request, '\0', sizeof(request_x));
1914 LISTADD(datashare->request, request);
1915 ret = __ps_process_request(reader, request);
1919 DBG("Processing data-share failed\n");
1923 if (datashare->define) {
1924 LISTHEAD(datashare->define, tmp1);
1925 datashare->define = tmp1;
1927 if (datashare->request) {
1928 LISTHEAD(datashare->request, tmp2);
1929 datashare->request = tmp2;
1934 static int __ps_process_layout(xmlTextReaderPtr reader, layout_x *layout)
1936 /*TODO: once policy is set*/
1941 __get_icon_with_path(char* icon)
1946 if (index(icon, '/') == NULL) {
1948 char* icon_with_path = NULL;
1954 theme = vconf_get_str("db/setting/theme");
1956 theme = strdup("default");
1962 len = (0x01 << 7) + strlen(icon) + strlen(package) + strlen(theme);
1963 icon_with_path = malloc(len);
1964 if(icon_with_path == NULL) {
1965 DBG("(icon_with_path == NULL) return\n");
1970 memset(icon_with_path, 0, len);
1972 snprintf(icon_with_path, len, "/opt/share/icons/%s/small/%s", theme, icon);
1974 if (access(icon_with_path, R_OK) == 0) break;
1975 snprintf(icon_with_path, len, "/usr/share/icons/%s/small/%s", theme, icon);
1976 if (access(icon_with_path, R_OK) == 0) break;
1977 DBG("cannot find icon %s", icon_with_path);
1978 snprintf(icon_with_path, len,"/opt/share/icons/default/small/%s", icon);
1979 if (access(icon_with_path, R_OK) == 0) break;
1980 snprintf(icon_with_path, len, "/usr/share/icons/default/small/%s", icon);
1981 if (access(icon_with_path, R_OK) == 0) break;
1983 /* icon path is going to be moved intto the app directory */
1984 DBGE("icon file must be moved to %s", icon_with_path);
1985 snprintf(icon_with_path, len, "/opt/apps/%s/res/icons/%s/small/%s", package, theme, icon);
1986 if (access(icon_with_path, R_OK) == 0) break;
1987 snprintf(icon_with_path, len, "/usr/apps/%s/res/icons/%s/small/%s", package, theme, icon);
1988 if (access(icon_with_path, R_OK) == 0) break;
1989 DBG("cannot find icon %s", icon_with_path);
1990 snprintf(icon_with_path, len, "/opt/apps/%s/res/icons/default/small/%s", package, icon);
1991 if (access(icon_with_path, R_OK) == 0) break;
1992 snprintf(icon_with_path, len, "/usr/apps/%s/res/icons/default/small/%s", package, icon);
1993 if (access(icon_with_path, R_OK) == 0) break;
1998 DBG("Icon path : %s ---> %s", icon, icon_with_path);
2000 return icon_with_path;
2002 char* confirmed_icon = NULL;
2004 confirmed_icon = strdup(icon);
2005 if (!confirmed_icon)
2007 return confirmed_icon;
2012 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon)
2014 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2015 icon->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2016 if (xmlTextReaderConstXmlLang(reader)) {
2017 icon->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2018 if (icon->lang == NULL)
2019 icon->lang = strdup(DEFAULT_LOCALE);
2021 icon->lang = strdup(DEFAULT_LOCALE);
2023 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
2024 icon->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
2025 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
2026 icon->size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
2027 if (xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")))
2028 icon->resolution = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")));
2029 xmlTextReaderRead(reader);
2030 if (xmlTextReaderValue(reader)) {
2031 char *text = ASCII(xmlTextReaderValue(reader));
2033 icon->text = __get_icon_with_path(text);
2041 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label)
2043 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2044 label->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2045 if (xmlTextReaderConstXmlLang(reader)) {
2046 label->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2047 if (label->lang == NULL)
2048 label->lang = strdup(DEFAULT_LOCALE);
2050 label->lang = strdup(DEFAULT_LOCALE);
2052 xmlTextReaderRead(reader);
2053 if (xmlTextReaderValue(reader))
2054 label->text = ASCII(xmlTextReaderValue(reader));
2056 /* DBG("lable name %s\n", label->name);
2057 DBG("lable lang %s\n", label->lang);
2058 DBG("lable text %s\n", label->text);
2064 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author)
2066 if (xmlTextReaderGetAttribute(reader, XMLCHAR("email")))
2067 author->email = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("email")));
2068 if (xmlTextReaderGetAttribute(reader, XMLCHAR("href")))
2069 author->href = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("href")));
2070 if (xmlTextReaderConstXmlLang(reader)) {
2071 author->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2072 if (author->lang == NULL)
2073 author->lang = strdup(DEFAULT_LOCALE);
2075 author->lang = strdup(DEFAULT_LOCALE);
2077 xmlTextReaderRead(reader);
2078 if (xmlTextReaderValue(reader))
2079 author->text = ASCII(xmlTextReaderValue(reader));
2083 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description)
2085 if (xmlTextReaderConstXmlLang(reader)) {
2086 description->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2087 if (description->lang == NULL)
2088 description->lang = strdup(DEFAULT_LOCALE);
2090 description->lang = strdup(DEFAULT_LOCALE);
2092 xmlTextReaderRead(reader);
2093 if (xmlTextReaderValue(reader))
2094 description->text = ASCII(xmlTextReaderValue(reader));
2098 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license)
2100 if (xmlTextReaderConstXmlLang(reader)) {
2101 license->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2102 if (license->lang == NULL)
2103 license->lang = strdup(DEFAULT_LOCALE);
2105 license->lang = strdup(DEFAULT_LOCALE);
2107 xmlTextReaderRead(reader);
2108 if (xmlTextReaderValue(reader))
2109 license->text = ASCII(xmlTextReaderValue(reader));
2113 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability)
2115 const xmlChar *node;
2118 resolution_x *tmp1 = NULL;
2120 if (xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")))
2121 capability->operationid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")));
2123 depth = xmlTextReaderDepth(reader);
2124 while ((ret = __next_child_element(reader, depth))) {
2125 node = xmlTextReaderConstName(reader);
2127 DBG("xmlTextReaderConstName value is NULL\n");
2131 if (!strcmp(ASCII(node), "resolution")) {
2132 resolution_x *resolution = malloc(sizeof(resolution_x));
2133 if (resolution == NULL) {
2134 DBG("Malloc Failed\n");
2137 memset(resolution, '\0', sizeof(resolution_x));
2138 LISTADD(capability->resolution, resolution);
2139 ret = __ps_process_resolution(reader, resolution);
2143 DBG("Processing capability failed\n");
2148 if (capability->resolution) {
2149 LISTHEAD(capability->resolution, tmp1);
2150 capability->resolution = tmp1;
2156 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol)
2158 const xmlChar *node;
2161 capability_x *tmp1 = NULL;
2163 if (xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")))
2164 datacontrol->providerid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")));
2166 depth = xmlTextReaderDepth(reader);
2167 while ((ret = __next_child_element(reader, depth))) {
2168 node = xmlTextReaderConstName(reader);
2170 DBG("xmlTextReaderConstName value is NULL\n");
2174 if (!strcmp(ASCII(node), "capability")) {
2175 capability_x *capability = malloc(sizeof(capability_x));
2176 if (capability == NULL) {
2177 DBG("Malloc Failed\n");
2180 memset(capability, '\0', sizeof(capability_x));
2181 LISTADD(datacontrol->capability, capability);
2182 ret = __ps_process_capability(reader, capability);
2186 DBG("Processing datacontrol failed\n");
2191 if (datacontrol->capability) {
2192 LISTHEAD(datacontrol->capability, tmp1);
2193 datacontrol->capability = tmp1;
2199 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication)
2201 const xmlChar *node;
2204 char *newappid = NULL;
2205 label_x *tmp1 = NULL;
2206 icon_x *tmp2 = NULL;
2207 appsvc_x *tmp3 = NULL;
2208 appcontrol_x *tmp4 = NULL;
2209 launchconditions_x *tmp5 = NULL;
2210 notification_x *tmp6 = NULL;
2211 datashare_x *tmp7 = NULL;
2212 category_x *tmp8 = NULL;
2214 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
2215 uiapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
2216 if (uiapplication->appid == NULL) {
2217 DBG("appid cant be NULL\n");
2221 DBG("appid is mandatory\n");
2225 ret = __validate_appid(package, uiapplication->appid, &newappid);
2227 DBG("appid is not proper\n");
2231 if (uiapplication->appid)
2232 free((void *)uiapplication->appid);
2233 uiapplication->appid = newappid;
2236 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
2237 uiapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
2238 if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay"))) {
2239 uiapplication->nodisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay")));
2240 if (uiapplication->nodisplay == NULL)
2241 uiapplication->nodisplay = strdup("false");
2243 uiapplication->nodisplay = strdup("false");
2245 if (xmlTextReaderGetAttribute(reader, XMLCHAR("multiple"))) {
2246 uiapplication->multiple = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("multiple")));
2247 if (uiapplication->multiple == NULL)
2248 uiapplication->multiple = strdup("false");
2250 uiapplication->multiple = strdup("false");
2252 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
2253 uiapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
2254 if (xmlTextReaderGetAttribute(reader, XMLCHAR("categories")))
2255 uiapplication->categories = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("categories")));
2256 if (xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")))
2257 uiapplication->extraid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")));
2258 if (xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage"))) {
2259 uiapplication->taskmanage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage")));
2260 if (uiapplication->taskmanage == NULL)
2261 uiapplication->taskmanage = strdup("true");
2263 uiapplication->taskmanage = strdup("true");
2265 if (xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration"))) {
2266 uiapplication->hwacceleration = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration")));
2267 if (uiapplication->hwacceleration == NULL)
2268 uiapplication->hwacceleration = strdup("use-system-setting");
2270 uiapplication->hwacceleration = strdup("use-system-setting");
2272 if (xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")))
2273 uiapplication->recentimage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")));
2274 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp"))) {
2275 uiapplication->mainapp = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp")));
2276 if (uiapplication->mainapp == NULL)
2277 uiapplication->mainapp = strdup("false");
2279 uiapplication->mainapp = strdup("false");
2282 depth = xmlTextReaderDepth(reader);
2283 while ((ret = __next_child_element(reader, depth))) {
2284 node = xmlTextReaderConstName(reader);
2286 DBG("xmlTextReaderConstName value is NULL\n");
2289 if (!strcmp(ASCII(node), "label")) {
2290 label_x *label = malloc(sizeof(label_x));
2291 if (label == NULL) {
2292 DBG("Malloc Failed\n");
2295 memset(label, '\0', sizeof(label_x));
2296 LISTADD(uiapplication->label, label);
2297 ret = __ps_process_label(reader, label);
2298 } else if (!strcmp(ASCII(node), "icon")) {
2299 icon_x *icon = malloc(sizeof(icon_x));
2301 DBG("Malloc Failed\n");
2304 memset(icon, '\0', sizeof(icon_x));
2305 LISTADD(uiapplication->icon, icon);
2306 ret = __ps_process_icon(reader, icon);
2307 } else if (!strcmp(ASCII(node), "category")) {
2308 category_x *category = malloc(sizeof(category_x));
2309 if (category == NULL) {
2310 DBG("Malloc Failed\n");
2313 memset(category, '\0', sizeof(category_x));
2314 LISTADD(uiapplication->category, category);
2315 ret = __ps_process_category(reader, category);
2316 } else if (!strcmp(ASCII(node), "app-control")) {
2317 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
2318 if (appcontrol == NULL) {
2319 DBG("Malloc Failed\n");
2322 memset(appcontrol, '\0', sizeof(appcontrol_x));
2323 LISTADD(uiapplication->appcontrol, appcontrol);
2324 ret = __ps_process_appcontrol(reader, appcontrol);
2325 } else if (!strcmp(ASCII(node), "application-service")) {
2326 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
2327 if (appsvc == NULL) {
2328 DBG("Malloc Failed\n");
2331 memset(appsvc, '\0', sizeof(appsvc_x));
2332 LISTADD(uiapplication->appsvc, appsvc);
2333 ret = __ps_process_appsvc(reader, appsvc);
2334 } else if (!strcmp(ASCII(node), "data-share")) {
2335 datashare_x *datashare = malloc(sizeof(datashare_x));
2336 if (datashare == NULL) {
2337 DBG("Malloc Failed\n");
2340 memset(datashare, '\0', sizeof(datashare_x));
2341 LISTADD(uiapplication->datashare, datashare);
2342 ret = __ps_process_datashare(reader, datashare);
2343 } else if (!strcmp(ASCII(node), "launch-conditions")) {
2344 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
2345 if (launchconditions == NULL) {
2346 DBG("Malloc Failed\n");
2349 memset(launchconditions, '\0', sizeof(launchconditions_x));
2350 LISTADD(uiapplication->launchconditions, launchconditions);
2351 ret = __ps_process_launchconditions(reader, launchconditions);
2352 } else if (!strcmp(ASCII(node), "notification")) {
2353 notification_x *notification = malloc(sizeof(notification_x));
2354 if (notification == NULL) {
2355 DBG("Malloc Failed\n");
2358 memset(notification, '\0', sizeof(notification_x));
2359 LISTADD(uiapplication->notification, notification);
2360 ret = __ps_process_notification(reader, notification);
2364 DBG("Processing uiapplication failed\n");
2369 if (uiapplication->label) {
2370 LISTHEAD(uiapplication->label, tmp1);
2371 uiapplication->label = tmp1;
2373 if (uiapplication->icon) {
2374 LISTHEAD(uiapplication->icon, tmp2);
2375 uiapplication->icon = tmp2;
2377 if (uiapplication->appsvc) {
2378 LISTHEAD(uiapplication->appsvc, tmp3);
2379 uiapplication->appsvc = tmp3;
2381 if (uiapplication->appcontrol) {
2382 LISTHEAD(uiapplication->appcontrol, tmp4);
2383 uiapplication->appcontrol = tmp4;
2385 if (uiapplication->launchconditions) {
2386 LISTHEAD(uiapplication->launchconditions, tmp5);
2387 uiapplication->launchconditions = tmp5;
2389 if (uiapplication->notification) {
2390 LISTHEAD(uiapplication->notification, tmp6);
2391 uiapplication->notification = tmp6;
2393 if (uiapplication->datashare) {
2394 LISTHEAD(uiapplication->datashare, tmp7);
2395 uiapplication->datashare = tmp7;
2397 if (uiapplication->category) {
2398 LISTHEAD(uiapplication->category, tmp8);
2399 uiapplication->category = tmp8;
2405 static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication)
2407 const xmlChar *node;
2410 char *newappid = NULL;
2411 label_x *tmp1 = NULL;
2412 icon_x *tmp2 = NULL;
2413 appsvc_x *tmp3 = NULL;
2414 appcontrol_x *tmp4 = NULL;
2415 datacontrol_x *tmp5 = NULL;
2416 launchconditions_x *tmp6 = NULL;
2417 notification_x *tmp7 = NULL;
2418 datashare_x *tmp8 = NULL;
2419 category_x *tmp9 = NULL;
2421 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
2422 serviceapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
2423 if (serviceapplication->appid == NULL) {
2424 DBG("appid cant be NULL\n");
2428 DBG("appid is mandatory\n");
2432 ret = __validate_appid(package, serviceapplication->appid, &newappid);
2434 DBG("appid is not proper\n");
2438 if (serviceapplication->appid)
2439 free((void *)serviceapplication->appid);
2440 serviceapplication->appid = newappid;
2443 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
2444 serviceapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
2445 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
2446 serviceapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
2447 if (xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot"))) {
2448 serviceapplication->onboot = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot")));
2449 if (serviceapplication->onboot == NULL)
2450 serviceapplication->onboot = strdup("false");
2452 serviceapplication->onboot = strdup("false");
2454 if (xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart"))) {
2455 serviceapplication->autorestart = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart")));
2456 if (serviceapplication->autorestart == NULL)
2457 serviceapplication->autorestart = strdup("false");
2459 serviceapplication->autorestart = strdup("false");
2462 depth = xmlTextReaderDepth(reader);
2463 while ((ret = __next_child_element(reader, depth))) {
2464 node = xmlTextReaderConstName(reader);
2466 DBG("xmlTextReaderConstName value is NULL\n");
2470 if (!strcmp(ASCII(node), "label")) {
2471 label_x *label = malloc(sizeof(label_x));
2472 if (label == NULL) {
2473 DBG("Malloc Failed\n");
2476 memset(label, '\0', sizeof(label_x));
2477 LISTADD(serviceapplication->label, label);
2478 ret = __ps_process_label(reader, label);
2479 } else if (!strcmp(ASCII(node), "icon")) {
2480 icon_x *icon = malloc(sizeof(icon_x));
2482 DBG("Malloc Failed\n");
2485 memset(icon, '\0', sizeof(icon_x));
2486 LISTADD(serviceapplication->icon, icon);
2487 ret = __ps_process_icon(reader, icon);
2488 } else if (!strcmp(ASCII(node), "category")) {
2489 category_x *category = malloc(sizeof(category_x));
2490 if (category == NULL) {
2491 DBG("Malloc Failed\n");
2494 memset(category, '\0', sizeof(category_x));
2495 LISTADD(serviceapplication->category, category);
2496 ret = __ps_process_category(reader, category);
2497 } else if (!strcmp(ASCII(node), "app-control")) {
2498 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
2499 if (appcontrol == NULL) {
2500 DBG("Malloc Failed\n");
2503 memset(appcontrol, '\0', sizeof(appcontrol_x));
2504 LISTADD(serviceapplication->appcontrol, appcontrol);
2505 ret = __ps_process_appcontrol(reader, appcontrol);
2506 } else if (!strcmp(ASCII(node), "application-service")) {
2507 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
2508 if (appsvc == NULL) {
2509 DBG("Malloc Failed\n");
2512 memset(appsvc, '\0', sizeof(appsvc_x));
2513 LISTADD(serviceapplication->appsvc, appsvc);
2514 ret = __ps_process_appsvc(reader, appsvc);
2515 } else if (!strcmp(ASCII(node), "data-share")) {
2516 datashare_x *datashare = malloc(sizeof(datashare_x));
2517 if (datashare == NULL) {
2518 DBG("Malloc Failed\n");
2521 memset(datashare, '\0', sizeof(datashare_x));
2522 LISTADD(serviceapplication->datashare, datashare);
2523 ret = __ps_process_datashare(reader, datashare);
2524 } else if (!strcmp(ASCII(node), "launch-conditions")) {
2525 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
2526 if (launchconditions == NULL) {
2527 DBG("Malloc Failed\n");
2530 memset(launchconditions, '\0', sizeof(launchconditions_x));
2531 LISTADD(serviceapplication->launchconditions, launchconditions);
2532 ret = __ps_process_launchconditions(reader, launchconditions);
2533 } else if (!strcmp(ASCII(node), "notification")) {
2534 notification_x *notification = malloc(sizeof(notification_x));
2535 if (notification == NULL) {
2536 DBG("Malloc Failed\n");
2539 memset(notification, '\0', sizeof(notification_x));
2540 LISTADD(serviceapplication->notification, notification);
2541 ret = __ps_process_notification(reader, notification);
2542 } else if (!strcmp(ASCII(node), "data-control")) {
2543 datacontrol_x *datacontrol = malloc(sizeof(datacontrol_x));
2544 if (datacontrol == NULL) {
2545 DBG("Malloc Failed\n");
2548 memset(datacontrol, '\0', sizeof(datacontrol_x));
2549 LISTADD(serviceapplication->datacontrol, datacontrol);
2550 ret = __ps_process_datacontrol(reader, datacontrol);
2554 DBG("Processing serviceapplication failed\n");
2559 if (serviceapplication->label) {
2560 LISTHEAD(serviceapplication->label, tmp1);
2561 serviceapplication->label = tmp1;
2563 if (serviceapplication->icon) {
2564 LISTHEAD(serviceapplication->icon, tmp2);
2565 serviceapplication->icon = tmp2;
2567 if (serviceapplication->appsvc) {
2568 LISTHEAD(serviceapplication->appsvc, tmp3);
2569 serviceapplication->appsvc = tmp3;
2571 if (serviceapplication->appcontrol) {
2572 LISTHEAD(serviceapplication->appcontrol, tmp4);
2573 serviceapplication->appcontrol = tmp4;
2575 if (serviceapplication->datacontrol) {
2576 LISTHEAD(serviceapplication->datacontrol, tmp5);
2577 serviceapplication->datacontrol = tmp5;
2579 if (serviceapplication->launchconditions) {
2580 LISTHEAD(serviceapplication->launchconditions, tmp6);
2581 serviceapplication->launchconditions = tmp6;
2583 if (serviceapplication->notification) {
2584 LISTHEAD(serviceapplication->notification, tmp7);
2585 serviceapplication->notification = tmp7;
2587 if (serviceapplication->datashare) {
2588 LISTHEAD(serviceapplication->datashare, tmp8);
2589 serviceapplication->datashare = tmp8;
2591 if (serviceapplication->category) {
2592 LISTHEAD(serviceapplication->category, tmp9);
2593 serviceapplication->category = tmp9;
2599 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile)
2601 /*TODO: once policy is set*/
2605 static int __ps_process_font(xmlTextReaderPtr reader, font_x *font)
2607 /*TODO: once policy is set*/
2611 static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme)
2613 /*TODO: once policy is set*/
2617 static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon)
2619 /*TODO: once policy is set*/
2623 static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime)
2625 /*TODO: once policy is set*/
2629 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx)
2631 DBG("__start_process\n");
2632 const xmlChar *node;
2635 label_x *tmp1 = NULL;
2636 author_x *tmp2 = NULL;
2637 description_x *tmp3 = NULL;
2638 license_x *tmp4 = NULL;
2639 uiapplication_x *tmp5 = NULL;
2640 serviceapplication_x *tmp6 = NULL;
2641 daemon_x *tmp7 = NULL;
2642 theme_x *tmp8 = NULL;
2643 font_x *tmp9 = NULL;
2644 ime_x *tmp10 = NULL;
2645 icon_x *tmp11 = NULL;
2646 compatibility_x *tmp12 = NULL;
2647 deviceprofile_x *tmp13 = NULL;
2649 depth = xmlTextReaderDepth(reader);
2650 while ((ret = __next_child_element(reader, depth))) {
2651 node = xmlTextReaderConstName(reader);
2653 DBG("xmlTextReaderConstName value is NULL\n");
2657 if (!strcmp(ASCII(node), "label")) {
2658 label_x *label = malloc(sizeof(label_x));
2659 if (label == NULL) {
2660 DBG("Malloc Failed\n");
2663 memset(label, '\0', sizeof(label_x));
2664 LISTADD(mfx->label, label);
2665 ret = __ps_process_label(reader, label);
2666 } else if (!strcmp(ASCII(node), "author")) {
2667 author_x *author = malloc(sizeof(author_x));
2668 if (author == NULL) {
2669 DBG("Malloc Failed\n");
2672 memset(author, '\0', sizeof(author_x));
2673 LISTADD(mfx->author, author);
2674 ret = __ps_process_author(reader, author);
2675 } else if (!strcmp(ASCII(node), "description")) {
2676 description_x *description = malloc(sizeof(description_x));
2677 if (description == NULL) {
2678 DBG("Malloc Failed\n");
2681 memset(description, '\0', sizeof(description_x));
2682 LISTADD(mfx->description, description);
2683 ret = __ps_process_description(reader, description);
2684 } else if (!strcmp(ASCII(node), "license")) {
2685 license_x *license = malloc(sizeof(license_x));
2686 if (license == NULL) {
2687 DBG("Malloc Failed\n");
2690 memset(license, '\0', sizeof(license_x));
2691 LISTADD(mfx->license, license);
2692 ret = __ps_process_license(reader, license);
2693 } else if (!strcmp(ASCII(node), "ui-application")) {
2694 uiapplication_x *uiapplication = malloc(sizeof(uiapplication_x));
2695 if (uiapplication == NULL) {
2696 DBG("Malloc Failed\n");
2699 memset(uiapplication, '\0', sizeof(uiapplication_x));
2700 LISTADD(mfx->uiapplication, uiapplication);
2701 ret = __ps_process_uiapplication(reader, uiapplication);
2702 } else if (!strcmp(ASCII(node), "service-application")) {
2703 serviceapplication_x *serviceapplication = malloc(sizeof(serviceapplication_x));
2704 if (serviceapplication == NULL) {
2705 DBG("Malloc Failed\n");
2708 memset(serviceapplication, '\0', sizeof(serviceapplication_x));
2709 LISTADD(mfx->serviceapplication, serviceapplication);
2710 ret = __ps_process_serviceapplication(reader, serviceapplication);
2711 } else if (!strcmp(ASCII(node), "daemon")) {
2712 daemon_x *daemon = malloc(sizeof(daemon_x));
2713 if (daemon == NULL) {
2714 DBG("Malloc Failed\n");
2717 memset(daemon, '\0', sizeof(daemon_x));
2718 LISTADD(mfx->daemon, daemon);
2719 ret = __ps_process_daemon(reader, daemon);
2720 } else if (!strcmp(ASCII(node), "theme")) {
2721 theme_x *theme = malloc(sizeof(theme_x));
2722 if (theme == NULL) {
2723 DBG("Malloc Failed\n");
2726 memset(theme, '\0', sizeof(theme_x));
2727 LISTADD(mfx->theme, theme);
2728 ret = __ps_process_theme(reader, theme);
2729 } else if (!strcmp(ASCII(node), "font")) {
2730 font_x *font = malloc(sizeof(font_x));
2732 DBG("Malloc Failed\n");
2735 memset(font, '\0', sizeof(font_x));
2736 LISTADD(mfx->font, font);
2737 ret = __ps_process_font(reader, font);
2738 } else if (!strcmp(ASCII(node), "ime")) {
2739 ime_x *ime = malloc(sizeof(ime_x));
2741 DBG("Malloc Failed\n");
2744 memset(ime, '\0', sizeof(ime_x));
2745 LISTADD(mfx->ime, ime);
2746 ret = __ps_process_ime(reader, ime);
2747 } else if (!strcmp(ASCII(node), "icon")) {
2748 icon_x *icon = malloc(sizeof(icon_x));
2750 DBG("Malloc Failed\n");
2753 memset(icon, '\0', sizeof(icon_x));
2754 LISTADD(mfx->icon, icon);
2755 ret = __ps_process_icon(reader, icon);
2756 } else if (!strcmp(ASCII(node), "device-profile")) {
2757 deviceprofile_x *deviceprofile = malloc(sizeof(deviceprofile_x));
2758 if (deviceprofile == NULL) {
2759 DBG("Malloc Failed\n");
2762 memset(deviceprofile, '\0', sizeof(deviceprofile_x));
2763 LISTADD(mfx->deviceprofile, deviceprofile);
2764 ret = __ps_process_deviceprofile(reader, deviceprofile);
2765 } else if (!strcmp(ASCII(node), "compatibility")) {
2766 compatibility_x *compatibility = malloc(sizeof(compatibility_x));
2767 if (compatibility == NULL) {
2768 DBG("Malloc Failed\n");
2771 memset(compatibility, '\0', sizeof(compatibility_x));
2772 LISTADD(mfx->compatibility, compatibility);
2773 ret = __ps_process_compatibility(reader, compatibility);
2774 } else if (!strcmp(ASCII(node), "shortcut-list")) {
2776 } else if (!strcmp(ASCII(node), "livebox")) {
2778 } else if (!strcmp(ASCII(node), "Accounts")) {
2780 } else if (!strcmp(ASCII(node), "account")) {
2786 DBG("Processing manifest failed\n");
2791 LISTHEAD(mfx->label, tmp1);
2795 LISTHEAD(mfx->author, tmp2);
2798 if (mfx->description) {
2799 LISTHEAD(mfx->description, tmp3);
2800 mfx->description= tmp3;
2803 LISTHEAD(mfx->license, tmp4);
2806 if (mfx->uiapplication) {
2807 LISTHEAD(mfx->uiapplication, tmp5);
2808 mfx->uiapplication = tmp5;
2810 if (mfx->serviceapplication) {
2811 LISTHEAD(mfx->serviceapplication, tmp6);
2812 mfx->serviceapplication = tmp6;
2815 LISTHEAD(mfx->daemon, tmp7);
2819 LISTHEAD(mfx->theme, tmp8);
2823 LISTHEAD(mfx->font, tmp9);
2827 LISTHEAD(mfx->ime, tmp10);
2831 LISTHEAD(mfx->icon, tmp11);
2834 if (mfx->compatibility) {
2835 LISTHEAD(mfx->compatibility, tmp12);
2836 mfx->compatibility= tmp12;
2838 if (mfx->deviceprofile) {
2839 LISTHEAD(mfx->deviceprofile, tmp13);
2840 mfx->deviceprofile= tmp13;
2846 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx)
2848 const xmlChar *node;
2851 if ((ret = __next_child_element(reader, -1))) {
2852 node = xmlTextReaderConstName(reader);
2854 DBG("xmlTextReaderConstName value is NULL\n");
2858 if (!strcmp(ASCII(node), "manifest")) {
2859 if (xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")))
2860 mfx->ns = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")));
2861 if (xmlTextReaderGetAttribute(reader, XMLCHAR("package"))) {
2862 mfx->package= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("package")));
2863 if (mfx->package == NULL) {
2864 DBG("package cant be NULL\n");
2868 DBG("package field is mandatory\n");
2871 package = mfx->package;
2872 if (xmlTextReaderGetAttribute(reader, XMLCHAR("version")))
2873 mfx->version= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("version")));
2874 /*app2ext needs package size for external installation*/
2875 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
2876 mfx->package_size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
2877 if (xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")))
2878 mfx->installlocation = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")));
2879 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
2880 mfx->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
2881 /*Assign default values. If required it will be overwritten in __add_preload_info()*/
2882 mfx->preload = strdup("False");
2883 mfx->removable = strdup("True");
2884 mfx->readonly = strdup("False");
2885 char buf[PKG_STRING_LEN_MAX] = {'\0'};
2887 time_t current_time;
2888 time(¤t_time);
2889 snprintf(buf, PKG_STRING_LEN_MAX - 1, "%d", current_time);
2890 val = strndup(buf, PKG_STRING_LEN_MAX - 1);
2891 mfx->installed_time = val;
2893 ret = __start_process(reader, mfx);
2895 DBG("No Manifest element found\n");
2902 #define DESKTOP_RW_PATH "/opt/share/applications/"
2903 #define DESKTOP_RO_PATH "/usr/share/applications/"
2905 static char* __convert_to_system_locale(const char *mlocale)
2907 if (mlocale == NULL)
2909 char *locale = NULL;
2910 locale = (char *)calloc(1, 6);
2912 DBGE("Malloc Failed\n");
2916 strncpy(locale, mlocale, 2);
2917 strncat(locale, "_", 1);
2918 locale[3] = toupper(mlocale[3]);
2919 locale[4] = toupper(mlocale[4]);
2924 /* desktop shoud be generated automatically based on manifest */
2925 /* Currently removable, taskmanage, etc fields are not considerd. it will be decided soon.*/
2926 #define BUFMAX 1024*128
2927 static int __ps_make_nativeapp_desktop(manifest_x * mfx)
2931 char filepath[PKG_STRING_LEN_MAX] = "";
2933 char *buftemp = NULL;
2934 char *locale = NULL;
2936 buf = (char *)calloc(1, BUFMAX);
2938 DBGE("Malloc Failed\n");
2942 buftemp = (char *)calloc(1, BUFMAX);
2944 DBGE("Malloc Failed\n");
2949 for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) {
2951 if(mfx->readonly && !strcasecmp(mfx->readonly, "True"))
2952 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RO_PATH, mfx->uiapplication->appid);
2954 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, mfx->uiapplication->appid);
2956 /* skip if desktop exists
2957 if (access(filepath, R_OK) == 0)
2961 file = fopen(filepath, "w");
2964 DBGE("Can't open %s", filepath);
2970 snprintf(buf, BUFMAX, "[Desktop Entry]\n");
2971 fwrite(buf, 1, strlen(buf), file);
2973 for( ; mfx->uiapplication->label ; mfx->uiapplication->label = mfx->uiapplication->label->next) {
2974 if(!strcmp(mfx->uiapplication->label->lang, DEFAULT_LOCALE)) {
2975 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
2977 locale = __convert_to_system_locale(mfx->uiapplication->label->lang);
2978 snprintf(buf, BUFMAX, "Name[%s]=%s\n", locale,
2979 mfx->uiapplication->label->text);
2982 fwrite(buf, 1, strlen(buf), file);
2985 if(mfx->uiapplication->label && mfx->uiapplication->label->text) {
2986 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
2987 fwrite(buf, 1, strlen(buf), file);
2990 else if(mfx->label && mfx->label->text) {
2991 snprintf(buf, BUFMAX, "Name=%s\n", mfx->label->text);
2992 fwrite(buf, 1, strlen(buf), file);
2994 snprintf(buf, BUFMAX, "Name=%s\n", mfx->package);
2995 fwrite(buf, 1, strlen(buf), file);
3000 snprintf(buf, BUFMAX, "Type=Application\n");
3001 fwrite(buf, 1, strlen(buf), file);
3003 if(mfx->uiapplication->exec) {
3004 snprintf(buf, BUFMAX, "Exec=%s\n", mfx->uiapplication->exec);
3005 fwrite(buf, 1, strlen(buf), file);
3008 if(mfx->uiapplication->icon && mfx->uiapplication->icon->text) {
3009 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->uiapplication->icon->text);
3010 fwrite(buf, 1, strlen(buf), file);
3011 } else if(mfx->icon && mfx->icon->text) {
3012 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->icon->text);
3013 fwrite(buf, 1, strlen(buf), file);
3017 snprintf(buf, BUFMAX, "Version=%s\n", mfx->version);
3018 fwrite(buf, 1, strlen(buf), file);
3021 if(mfx->uiapplication->nodisplay) {
3022 snprintf(buf, BUFMAX, "NoDisplay=%s\n", mfx->uiapplication->nodisplay);
3023 fwrite(buf, 1, strlen(buf), file);
3026 if(mfx->uiapplication->categories) {
3027 snprintf(buf, BUFMAX, "Categories=%s\n", mfx->uiapplication->categories);
3028 fwrite(buf, 1, strlen(buf), file);
3031 if(mfx->uiapplication->taskmanage && !strcasecmp(mfx->uiapplication->taskmanage, "False")) {
3032 snprintf(buf, BUFMAX, "X-TIZEN-TaskManage=False\n");
3033 fwrite(buf, 1, strlen(buf), file);
3036 if(mfx->uiapplication->hwacceleration) {
3037 snprintf(buf, BUFMAX, "Hw-Acceleration=%s\n", mfx->uiapplication->hwacceleration);
3038 fwrite(buf, 1, strlen(buf), file);
3041 if(mfx->uiapplication->multiple && !strcasecmp(mfx->uiapplication->multiple, "True")) {
3042 snprintf(buf, BUFMAX, "X-TIZEN-Multiple=True\n");
3043 fwrite(buf, 1, strlen(buf), file);
3046 if(mfx->uiapplication->extraid) {
3047 snprintf(buf, BUFMAX, "X-TIZEN-PackageID=%s\n", mfx->uiapplication->extraid);
3048 fwrite(buf, 1, strlen(buf), file);
3051 if(mfx->removable && !strcasecmp(mfx->removable, "False")) {
3052 snprintf(buf, BUFMAX, "X-TIZEN-Removable=False\n");
3053 fwrite(buf, 1, strlen(buf), file);
3057 snprintf(buf, BUFMAX, "X-TIZEN-PackageType=%s\n", mfx->type);
3058 fwrite(buf, 1, strlen(buf), file);
3061 snprintf(buf, BUFMAX, "X-TIZEN-PkgID=%s\n", mfx->package);
3062 fwrite(buf, 1, strlen(buf), file);
3065 // snprintf(buf, BUFMAX, "X-TIZEN-PackageType=rpm\n");
3066 // fwrite(buf, 1, strlen(buf), file);
3069 if(mfx->uiapplication->appsvc) {
3070 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
3071 DBG("buf[%s]\n", buf);
3074 uiapplication_x *up = mfx->uiapplication;
3075 appsvc_x *asvc = NULL;
3076 operation_x *op = NULL;
3079 subapp_x *sub = NULL;
3081 char query[PKG_STRING_LEN_MAX] = {'\0'};
3082 char *operation = NULL;
3085 char *subapp = NULL;
3092 op = asvc->operation;
3096 operation = op->name;
3115 strncpy(buftemp, buf, BUFMAX);
3116 snprintf(buf, BUFMAX, "%s;", buftemp);
3120 strncpy(buftemp, buf, BUFMAX);
3121 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
3122 DBG("buf[%s]\n", buf);
3127 } while(ui != NULL);
3131 }while(sub != NULL);
3144 fwrite(buf, 1, strlen(buf), file);
3146 // strncpy(buftemp, buf, BUFMAX);
3147 // snprintf(buf, BUFMAX, "%s\n", buftemp);
3148 // fwrite(buf, 1, strlen(buf), file);
3151 if(mfx->uiapplication->appcontrol) {
3152 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
3153 DBG("buf[%s]\n", buf);
3155 uiapplication_x *up = mfx->uiapplication;
3156 appcontrol_x *acontrol = NULL;
3157 operation_x *op = NULL;
3160 subapp_x *sub = NULL;
3162 char query[PKG_STRING_LEN_MAX] = {'\0'};
3163 char *operation = NULL;
3166 char *subapp = NULL;
3169 acontrol = up->appcontrol;
3170 while(acontrol != NULL)
3172 op = acontrol->operation;
3176 operation = op->name;
3177 mi = acontrol->mime;
3183 sub = acontrol->subapp;
3195 strncpy(buftemp, buf, BUFMAX);
3196 snprintf(buf, BUFMAX, "%s;", buftemp);
3199 strncpy(buftemp, buf, BUFMAX);
3200 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
3201 DBG("buf[%s]\n", buf);
3206 } while(ui != NULL);
3210 }while(sub != NULL);
3219 acontrol = acontrol->next;
3223 fwrite(buf, 1, strlen(buf), file);
3225 // strncpy(buftemp, buf, BUFMAX);
3226 // snprintf(buf, BUFMAX, "%s\n", buftemp);
3227 // fwrite(buf, 1, strlen(buf), file);
3242 static int __ps_remove_nativeapp_desktop(manifest_x *mfx)
3244 char filepath[PKG_STRING_LEN_MAX] = "";
3247 for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) {
3248 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, mfx->uiapplication->appid);
3250 ret = remove(filepath);
3258 #define MANIFEST_RO_PREFIX "/usr/share/packages/"
3259 #define PRELOAD_PACKAGE_LIST "/usr/etc/package-manager/preload/preload_list.txt"
3260 static int __add_preload_info(manifest_x * mfx, const char *manifest)
3263 char buffer[1024] = { 0 };
3266 if(strstr(manifest, MANIFEST_RO_PREFIX)) {
3267 free(mfx->readonly);
3268 mfx->readonly = strdup("True");
3271 mfx->preload = strdup("True");
3273 free(mfx->removable);
3274 mfx->removable = strdup("False");
3279 fp = fopen(PRELOAD_PACKAGE_LIST, "r");
3281 DBGE("no preload list\n");
3285 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
3286 if (buffer[0] == '#') {
3287 if(strcasestr(buffer, "RW_NORM"))
3289 else if(strcasestr(buffer, "RW_RM"))
3297 if(!strcmp(mfx->package, buffer)) {
3299 mfx->preload = strdup("True");
3301 free(mfx->readonly);
3302 mfx->readonly = strdup("False");
3303 free(mfx->removable);
3304 mfx->removable = strdup("False");
3305 } else if(state == 3){
3306 free(mfx->readonly);
3307 mfx->readonly = strdup("False");
3308 free(mfx->removable);
3309 mfx->removable = strdup("True");
3313 memset(buffer, 0x00, sizeof(buffer));
3323 API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
3328 free((void *)mfx->ns);
3332 free((void *)mfx->package);
3333 mfx->package = NULL;
3336 free((void *)mfx->version);
3337 mfx->version = NULL;
3339 if (mfx->installlocation) {
3340 free((void *)mfx->installlocation);
3341 mfx->installlocation = NULL;
3344 free((void *)mfx->preload);
3345 mfx->preload = NULL;
3347 if (mfx->readonly) {
3348 free((void *)mfx->readonly);
3349 mfx->readonly = NULL;
3351 if (mfx->removable) {
3352 free((void *)mfx->removable);
3353 mfx->removable = NULL;
3356 free((void *)mfx->type);
3359 if (mfx->installed_time) {
3360 free((void *)mfx->installed_time);
3361 mfx->installed_time = NULL;
3363 if (mfx->storeclient_id) {
3364 free((void *)mfx->storeclient_id);
3365 mfx->storeclient_id = NULL;
3367 if (mfx->mainapp_id) {
3368 free((void *)mfx->mainapp_id);
3369 mfx->mainapp_id = NULL;
3371 if (mfx->package_url) {
3372 free((void *)mfx->package_url);
3373 mfx->package_url = NULL;
3378 icon_x *icon = mfx->icon;
3383 __ps_free_icon(icon);
3389 label_x *label = mfx->label;
3390 label_x *tmp = NULL;
3391 while(label != NULL)
3394 __ps_free_label(label);
3400 author_x *author = mfx->author;
3401 author_x *tmp = NULL;
3402 while(author != NULL)
3405 __ps_free_author(author);
3409 /*Free Description*/
3410 if (mfx->description) {
3411 description_x *description = mfx->description;
3412 description_x *tmp = NULL;
3413 while(description != NULL)
3415 tmp = description->next;
3416 __ps_free_description(description);
3422 license_x *license = mfx->license;
3423 license_x *tmp = NULL;
3424 while(license != NULL)
3426 tmp = license->next;
3427 __ps_free_license(license);
3431 /*Free UiApplication*/
3432 if (mfx->uiapplication) {
3433 uiapplication_x *uiapplication = mfx->uiapplication;
3434 uiapplication_x *tmp = NULL;
3435 while(uiapplication != NULL)
3437 tmp = uiapplication->next;
3438 __ps_free_uiapplication(uiapplication);
3439 uiapplication = tmp;
3442 /*Free ServiceApplication*/
3443 if (mfx->serviceapplication) {
3444 serviceapplication_x *serviceapplication = mfx->serviceapplication;
3445 serviceapplication_x *tmp = NULL;
3446 while(serviceapplication != NULL)
3448 tmp = serviceapplication->next;
3449 __ps_free_serviceapplication(serviceapplication);
3450 serviceapplication = tmp;
3455 daemon_x *daemon = mfx->daemon;
3456 daemon_x *tmp = NULL;
3457 while(daemon != NULL)
3460 __ps_free_daemon(daemon);
3466 theme_x *theme = mfx->theme;
3467 theme_x *tmp = NULL;
3468 while(theme != NULL)
3471 __ps_free_theme(theme);
3477 font_x *font = mfx->font;
3482 __ps_free_font(font);
3488 ime_x *ime = mfx->ime;
3497 /*Free Compatibility*/
3498 if (mfx->compatibility) {
3499 compatibility_x *compatibility = mfx->compatibility;
3500 compatibility_x *tmp = NULL;
3501 while(compatibility != NULL)
3503 tmp = compatibility->next;
3504 __ps_free_compatibility(compatibility);
3505 compatibility = tmp;
3508 /*Free DeviceProfile*/
3509 if (mfx->deviceprofile) {
3510 deviceprofile_x *deviceprofile = mfx->deviceprofile;
3511 deviceprofile_x *tmp = NULL;
3512 while(deviceprofile != NULL)
3514 tmp = deviceprofile->next;
3515 __ps_free_deviceprofile(deviceprofile);
3516 deviceprofile = tmp;
3524 API manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest)
3526 DBG("parsing start\n");
3527 xmlTextReaderPtr reader;
3528 manifest_x *mfx = NULL;
3530 reader = xmlReaderForFile(manifest, NULL, 0);
3532 mfx = malloc(sizeof(manifest_x));
3534 memset(mfx, '\0', sizeof(manifest_x));
3535 if (__process_manifest(reader, mfx) < 0) {
3536 DBG("Parsing Failed\n");
3537 pkgmgr_parser_free_manifest_xml(mfx);
3540 DBG("Parsing Success\n");
3542 DBG("Memory allocation error\n");
3544 xmlFreeTextReader(reader);
3546 DBG("Unable to create xml reader\n");
3551 /* These APIs are intended to call parser directly */
3553 API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
3555 char *temp[] = {"shortcut-list", "livebox", "Accounts", "account", NULL};
3556 if (manifest == NULL) {
3557 DBG("argument supplied is NULL\n");
3558 return PMINFO_R_EINVAL;
3560 DBG("parsing manifest for installation: %s\n", manifest);
3561 manifest_x *mfx = NULL;
3564 mfx = pkgmgr_parser_process_manifest_xml(manifest);
3565 DBG("Parsing Finished\n");
3567 return PMINFO_R_ERROR;
3569 __streamFile(manifest, ACTION_INSTALL, temp, mfx->package);
3570 __add_preload_info(mfx, manifest);
3571 DBG("Added preload infomation\n");
3572 ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
3574 DBG("DB Insert failed\n");
3576 DBG("DB Insert Success\n");
3578 ret = __ps_make_nativeapp_desktop(mfx);
3580 DBG("Creating desktop file failed\n");
3582 DBG("Creating desktop file Success\n");
3584 pkgmgr_parser_free_manifest_xml(mfx);
3591 API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
3593 char *temp[] = {"shortcut-list", "livebox", "Accounts", "account", NULL};
3594 if (manifest == NULL) {
3595 DBG("argument supplied is NULL\n");
3596 return PMINFO_R_EINVAL;
3598 DBG("parsing manifest for upgradation: %s\n", manifest);
3599 manifest_x *mfx = NULL;
3602 mfx = pkgmgr_parser_process_manifest_xml(manifest);
3603 DBG("Parsing Finished\n");
3605 return PMINFO_R_ERROR;
3607 __streamFile(manifest, ACTION_UPGRADE, temp, mfx->package);
3608 __add_preload_info(mfx, manifest);
3609 DBG("Added preload infomation\n");
3610 ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
3612 DBG("DB Update failed\n");
3614 DBG("DB Update Success\n");
3616 ret = __ps_make_nativeapp_desktop(mfx);
3618 DBG("Creating desktop file failed\n");
3620 DBG("Creating desktop file Success\n");
3622 pkgmgr_parser_free_manifest_xml(mfx);
3629 API int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[])
3631 char *temp[] = {"shortcut-list", "livebox", "Accounts", "account", NULL};
3632 if (manifest == NULL) {
3633 DBG("argument supplied is NULL\n");
3634 return PMINFO_R_EINVAL;
3636 DBG("parsing manifest for uninstallation: %s\n", manifest);
3637 manifest_x *mfx = NULL;
3640 mfx = pkgmgr_parser_process_manifest_xml(manifest);
3641 DBG("Parsing Finished\n");
3643 return PMINFO_R_ERROR;
3645 __streamFile(manifest, ACTION_UNINSTALL, temp, mfx->package);
3646 __add_preload_info(mfx, manifest);
3647 DBG("Added preload infomation\n");
3649 ret = pkgmgr_parser_delete_manifest_info_from_db(mfx);
3651 DBG("DB Delete failed\n");
3653 DBG("DB Delete Success\n");
3655 ret = __ps_remove_nativeapp_desktop(mfx);
3657 DBG("Removing desktop file failed\n");
3659 DBG("Removing desktop file Success\n");
3661 pkgmgr_parser_free_manifest_xml(mfx);
3668 API char *pkgmgr_parser_get_manifest_file(const char *pkgid)
3670 return __pkgid_to_manifest(pkgid);
3673 API int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
3675 return __ps_run_parser(docPtr, tag, ACTION_INSTALL, pkgid);
3678 API int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgid)
3680 return __ps_run_parser(docPtr, tag, ACTION_UPGRADE, pkgid);
3683 API int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
3685 return __ps_run_parser(docPtr, tag, ACTION_UNINSTALL, pkgid);
3688 #define SCHEMA_FILE "/usr/etc/package-manager/preload/manifest.xsd"
3690 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
3692 if (manifest == NULL) {
3693 DBGE("manifest file is NULL\n");
3694 return PMINFO_R_EINVAL;
3697 xmlSchemaParserCtxtPtr ctx;
3698 xmlSchemaValidCtxtPtr vctx;
3699 xmlSchemaPtr xschema;
3700 ctx = xmlSchemaNewParserCtxt(SCHEMA_FILE);
3702 DBGE("xmlSchemaNewParserCtxt() Failed\n");
3703 return PMINFO_R_ERROR;
3705 xschema = xmlSchemaParse(ctx);
3706 if (xschema == NULL) {
3707 DBGE("xmlSchemaParse() Failed\n");
3708 return PMINFO_R_ERROR;
3710 vctx = xmlSchemaNewValidCtxt(xschema);
3712 DBGE("xmlSchemaNewValidCtxt() Failed\n");
3713 return PMINFO_R_ERROR;
3715 xmlSchemaSetValidErrors(vctx, (xmlSchemaValidityErrorFunc) fprintf, (xmlSchemaValidityWarningFunc) fprintf, stderr);
3716 ret = xmlSchemaValidateFile(vctx, manifest, 0);
3718 DBGE("xmlSchemaValidateFile() failed\n");
3719 return PMINFO_R_ERROR;
3720 } else if (ret == 0) {
3721 DBGE("Manifest is Valid\n");
3724 DBGE("Manifest Validation Failed with error code %d\n", ret);
3725 return PMINFO_R_ERROR;
3731 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
3741 DBGE("fork failed\n");
3746 int dev_null_fd = open ("/dev/null", O_RDWR);
3747 if (dev_null_fd >= 0)
3749 dup2 (dev_null_fd, 0);/*stdin*/
3750 dup2 (dev_null_fd, 1);/*stdout*/
3751 dup2 (dev_null_fd, 2);/*stderr*/
3754 if (execl("/usr/bin/xmllint", "xmllint", manifest, "--schema",
3755 SCHEMA_FILE, NULL) < 0) {
3756 DBGE("execl error\n");
3766 while ((err = waitpid(pid, &status, WNOHANG)) != pid) {
3770 DBGE("waitpid failed\n");
3776 if(WIFEXITED(status) && !WEXITSTATUS(status))