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_metadata(xmlTextReaderPtr reader, metadata_x *metadata);
64 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission);
65 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility);
66 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution);
67 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request);
68 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define);
69 static int __ps_process_registry(xmlTextReaderPtr reader, registry_x *registry);
70 static int __ps_process_database(xmlTextReaderPtr reader, database_x *database);
71 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc);
72 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions);
73 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare);
74 static int __ps_process_layout(xmlTextReaderPtr reader, layout_x *layout);
75 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon);
76 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author);
77 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description);
78 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability);
79 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license);
80 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol);
81 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol);
82 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication);
83 static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication);
84 static int __ps_process_font(xmlTextReaderPtr reader, font_x *font);
85 static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme);
86 static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon);
87 static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime);
88 static void __ps_free_label(label_x *label);
89 static void __ps_free_deviceprofile(deviceprofile_x * deviceprofile);
90 static void __ps_free_allowed(allowed_x *allowed);
91 static void __ps_free_operation(operation_x *operation);
92 static void __ps_free_uri(uri_x *uri);
93 static void __ps_free_mime(mime_x *mime);
94 static void __ps_free_subapp(subapp_x *subapp);
95 static void __ps_free_condition(condition_x *condition);
96 static void __ps_free_notification(notification_x *notifiation);
97 static void __ps_free_category(category_x *category);
98 static void __ps_free_metadata(metadata_x *metadata);
99 static void __ps_free_permission(permission_x *permission);
100 static void __ps_free_compatibility(compatibility_x *compatibility);
101 static void __ps_free_resolution(resolution_x *resolution);
102 static void __ps_free_request(request_x *request);
103 static void __ps_free_define(define_x *define);
104 static void __ps_free_registry(registry_x *registry);
105 static void __ps_free_database(database_x *database);
106 static void __ps_free_appsvc(appsvc_x *appsvc);
107 static void __ps_free_launchconditions(launchconditions_x *launchconditions);
108 static void __ps_free_datashare(datashare_x *datashare);
109 static void __ps_free_layout(layout_x *layout);
110 static void __ps_free_icon(icon_x *icon);
111 static void __ps_free_author(author_x *author);
112 static void __ps_free_description(description_x *description);
113 static void __ps_free_capability(capability_x *capability);
114 static void __ps_free_license(license_x *license);
115 static void __ps_free_appcontrol(appcontrol_x *appcontrol);
116 static void __ps_free_datacontrol(datacontrol_x *datacontrol);
117 static void __ps_free_uiapplication(uiapplication_x *uiapplication);
118 static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication);
119 static void __ps_free_font(font_x *font);
120 static void __ps_free_theme(theme_x *theme);
121 static void __ps_free_daemon(daemon_x *daemon);
122 static void __ps_free_ime(ime_x *ime);
123 static char *__pkgid_to_manifest(const char *pkgid);
124 static int __next_child_element(xmlTextReaderPtr reader, int depth);
125 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx);
126 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx);
127 static void __str_trim(char *input);
128 static char *__get_parser_plugin(const char *type);
129 static int __ps_run_parser(xmlDocPtr docPtr, const char *tag, ACTION_TYPE action, const char *pkgid);
130 static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid);
131 static void __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgid);
132 static void __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid);
133 static int __validate_appid(const char *pkgid, const char *appid, char **newappid);
135 static void __str_trim(char *input)
137 char *trim_str = input;
142 while (*input != 0) {
143 if (!isspace(*input)) {
154 static int __validate_appid(const char *pkgid, const char *appid, char **newappid)
156 if (!pkgid || !appid || !newappid) {
157 DBG("Arg supplied is NULL\n");
160 int pkglen = strlen(pkgid);
161 int applen = strlen(appid);
165 if (strncmp(appid, ".", 1) == 0) {
166 len = pkglen + applen + 1;
167 newapp = calloc(1,len);
168 if (newapp == NULL) {
169 DBG("Malloc failed\n");
172 strncpy(newapp, pkgid, pkglen);
173 strncat(newapp, appid, applen);
174 DBG("new appid is %s\n", newapp);
178 if (applen < pkglen) {
179 DBG("app id is not proper\n");
181 #ifdef _VALIDATE_APPID_
187 if (!strcmp(appid, pkgid)) {
188 DBG("appid is proper\n");
192 else if (strncmp(appid, pkgid, pkglen) == 0) {
193 ptr = strstr(appid, pkgid);
195 if (strncmp(ptr, ".", 1) == 0) {
196 DBG("appid is proper\n");
201 DBG("appid is not proper\n");
203 #ifdef _VALIDATE_APPID_
210 DBG("appid is not proper\n");
212 #ifdef _VALIDATE_APPID_
222 static char *__get_parser_plugin(const char *type)
225 char buffer[1024] = { 0 };
226 char temp_path[1024] = { 0 };
227 char *lib_path = NULL;
231 DBGE("invalid argument\n");
235 fp = fopen(PKG_PARSER_CONF_PATH, "r");
237 DBGE("no matching backendlib\n");
241 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
242 if (buffer[0] == '#')
247 if ((path = strstr(buffer, PKG_PARSERLIB)) != NULL) {
249 path = path + strlen(PKG_PARSERLIB);
255 memset(buffer, 0x00, 1024);
262 DBGE("no matching backendlib\n");
266 snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
268 return strdup(temp_path);
271 static int __ps_run_parser(xmlDocPtr docPtr, const char *tag,
272 ACTION_TYPE action, const char *pkgid)
274 char *lib_path = NULL;
275 void *lib_handle = NULL;
276 int (*plugin_install) (xmlDocPtr, const char *);
282 ac = "PKGMGR_PARSER_PLUGIN_INSTALL";
285 ac = "PKGMGR_PARSER_PLUGIN_UPGRADE";
287 case ACTION_UNINSTALL:
288 ac = "PKGMGR_PARSER_PLUGIN_UNINSTALL";
294 lib_path = __get_parser_plugin(tag);
299 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
300 DBGE("dlopen is failed lib_path[%s]\n", lib_path);
304 if ((plugin_install =
305 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
306 DBGE("can not find symbol \n");
310 ret = plugin_install(docPtr, pkgid);
320 static char *__pkgid_to_manifest(const char *pkgid)
326 DBGE("pkgid is NULL");
330 size = strlen(MANIFEST_RW_DIRECTORY) + strlen(pkgid) + 10;
331 manifest = malloc(size);
332 if (manifest == NULL) {
336 memset(manifest, '\0', size);
337 snprintf(manifest, size, MANIFEST_RW_DIRECTORY "/%s.xml", pkgid);
339 if (access(manifest, F_OK)) {
340 snprintf(manifest, size, MANIFEST_RO_DIRECTORY "/%s.xml", pkgid);
346 static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid)
350 char *parser_cmd = NULL;
353 char *lib_path = NULL;
354 void *lib_handle = NULL;
355 int (*plugin_install) (xmlDocPtr);
357 DBG("__run_parser_prestep");
359 if (xmlTextReaderDepth(reader) != 1) {
360 DBGE("Node depth is not 1");
364 if (xmlTextReaderNodeType(reader) != 1) {
365 DBGE("Node type is not 1");
369 const xmlChar *value;
370 name = xmlTextReaderConstName(reader);
372 DBGE("TEST TEST TES\n");
373 name = BAD_CAST "--";
376 value = xmlTextReaderConstValue(reader);
377 DBG("%d %d %s %d %d",
378 xmlTextReaderDepth(reader),
379 xmlTextReaderNodeType(reader),
381 xmlTextReaderIsEmptyElement(reader), xmlTextReaderHasValue(reader));
384 DBG("ConstValue NULL");
386 if (xmlStrlen(value) > 40) {
387 DBG(" %.40s...", value);
393 name = xmlTextReaderConstName(reader);
395 DBGE("TEST TEST TES\n");
396 name = BAD_CAST "--";
399 xmlDocPtr docPtr = xmlTextReaderCurrentDoc(reader);
400 DBG("docPtr->URL %s\n", (char *)docPtr->URL);
401 xmlDocPtr copyDocPtr = xmlCopyDoc(docPtr, 1);
402 if (copyDocPtr == NULL)
404 xmlNode *rootElement = xmlDocGetRootElement(copyDocPtr);
405 if (rootElement == NULL)
407 xmlNode *cur_node = xmlFirstElementChild(rootElement);
408 if (cur_node == NULL)
410 xmlNode *temp = xmlTextReaderExpand(reader);
413 xmlNode *next_node = NULL;
414 while(cur_node != NULL)
416 if ( (strcmp(temp->name, cur_node->name) == 0) &&
417 (temp->line == cur_node->line) ) {
421 next_node = xmlNextElementSibling(cur_node);
422 xmlUnlinkNode(cur_node);
423 xmlFreeNode(cur_node);
424 cur_node = next_node;
427 if (cur_node == NULL)
429 next_node = xmlNextElementSibling(cur_node);
431 cur_node->next = NULL;
432 next_node->prev = NULL;
433 xmlFreeNodeList(next_node);
434 xmlSetTreeDoc(cur_node, copyDocPtr);
436 xmlSetTreeDoc(cur_node, copyDocPtr);
442 DBG("node type: %d, name: %s children->name: %s last->name: %s\n"
443 "parent->name: %s next->name: %s prev->name: %s\n",
444 cur_node->type, cur_node->name,
445 cur_node->children ? cur_node->children->name : "NULL",
446 cur_node->last ? cur_node->last->name : "NULL",
447 cur_node->parent ? cur_node->parent->name : "NULL",
448 cur_node->next ? cur_node->next->name : "NULL",
449 cur_node->prev ? cur_node->prev->name : "NULL");
451 FILE *fp = fopen("/opt/share/test.xml", "a");
452 xmlDocDump(fp, copyDocPtr);
457 ret = __ps_run_parser(copyDocPtr, name, action, pkgid);
464 __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgid)
469 switch (xmlTextReaderNodeType(reader)) {
470 case XML_READER_TYPE_END_ELEMENT:
472 // DBG("XML_READER_TYPE_END_ELEMENT");
476 case XML_READER_TYPE_ELEMENT:
478 // Elements without closing tag don't receive
479 // XML_READER_TYPE_END_ELEMENT event.
481 const xmlChar *elementName =
482 xmlTextReaderLocalName(reader);
483 if (elementName == NULL) {
484 // DBG("elementName %s\n", (char *)elementName);
488 const xmlChar *nameSpace =
489 xmlTextReaderConstNamespaceUri(reader);
491 // DBG("nameSpace %s\n", (char *)nameSpace);
494 DBG("XML_READER_TYPE_ELEMENT %s, %s\n",
495 elementName ? elementName : "NULL",
496 nameSpace ? nameSpace : "NULL");
499 DBG("__run_parser_prestep pkgid[%s]\n", pkgid);
500 __run_parser_prestep(reader, action, pkgid);
504 for (tag = tagv[0]; tag; tag = tagv[++i])
505 if (strcmp(tag, elementName) == 0) {
506 DBG("__run_parser_prestep tag[%s] pkgid[%s]\n", tag, pkgid);
507 __run_parser_prestep(reader,
515 case XML_READER_TYPE_TEXT:
516 case XML_READER_TYPE_CDATA:
518 const xmlChar *value = xmlTextReaderConstValue(reader);
520 // DBG("value %s\n", value);
523 const xmlChar *lang = xmlTextReaderConstXmlLang(reader);
525 // DBG("lang\n", lang);
528 /* DBG("XML_READER_TYPE_TEXT %s, %s\n",
529 value ? value : "NULL", lang ? lang : "NULL");
534 // DBG("Ignoring Node of Type: %d", xmlTextReaderNodeType(reader));
540 __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid)
542 xmlTextReaderPtr reader;
546 docPtr = xmlReadFile(filename, NULL, 0);
547 reader = xmlReaderWalker(docPtr);
548 if (reader != NULL) {
549 ret = xmlTextReaderRead(reader);
551 __processNode(reader, action, tagv, pkgid);
552 ret = xmlTextReaderRead(reader);
554 xmlFreeTextReader(reader);
557 DBGE("%s : failed to parse", filename);
560 DBGE("Unable to open %s", filename);
564 static int __next_child_element(xmlTextReaderPtr reader, int depth)
566 int ret = xmlTextReaderRead(reader);
567 int cur = xmlTextReaderDepth(reader);
570 switch (xmlTextReaderNodeType(reader)) {
571 case XML_READER_TYPE_ELEMENT:
572 if (cur == depth + 1)
575 case XML_READER_TYPE_TEXT:
576 /*text is handled by each function separately*/
577 if (cur == depth + 1)
580 case XML_READER_TYPE_END_ELEMENT:
589 ret = xmlTextReaderRead(reader);
590 cur = xmlTextReaderDepth(reader);
595 static void __ps_free_category(category_x *category)
597 if (category == NULL)
599 if (category->name) {
600 free((void *)category->name);
601 category->name = NULL;
603 free((void*)category);
607 static void __ps_free_metadata(metadata_x *metadata)
609 if (metadata == NULL)
611 if (metadata->name) {
612 free((void *)metadata->name);
613 metadata->name = NULL;
615 if (metadata->value) {
616 free((void *)metadata->value);
617 metadata->value = NULL;
619 free((void*)metadata);
623 static void __ps_free_permission(permission_x *permission)
625 if (permission == NULL)
627 if (permission->type) {
628 free((void *)permission->type);
629 permission->type = NULL;
631 if (permission->value) {
632 free((void *)permission->value);
633 permission->value = NULL;
635 free((void*)permission);
639 static void __ps_free_icon(icon_x *icon)
644 free((void *)icon->text);
648 free((void *)icon->lang);
652 free((void *)icon->name);
656 free((void *)icon->section);
657 icon->section = NULL;
660 free((void *)icon->size);
663 if (icon->resolution) {
664 free((void *)icon->resolution);
665 icon->resolution = NULL;
671 static void __ps_free_image(image_x *image)
676 free((void *)image->text);
680 free((void *)image->lang);
684 free((void *)image->name);
687 if (image->section) {
688 free((void *)image->section);
689 image->section = NULL;
695 static void __ps_free_operation(operation_x *operation)
697 if (operation == NULL)
699 if (operation->text) {
700 free((void *)operation->text);
701 operation->text = NULL;
703 free((void*)operation);
707 static void __ps_free_uri(uri_x *uri)
712 free((void *)uri->text);
719 static void __ps_free_mime(mime_x *mime)
724 free((void *)mime->text);
731 static void __ps_free_subapp(subapp_x *subapp)
736 free((void *)subapp->text);
743 static void __ps_free_condition(condition_x *condition)
745 if (condition == NULL)
747 if (condition->text) {
748 free((void *)condition->text);
749 condition->text = NULL;
751 if (condition->name) {
752 free((void *)condition->name);
753 condition->name = NULL;
755 free((void*)condition);
759 static void __ps_free_notification(notification_x *notification)
761 if (notification == NULL)
763 if (notification->text) {
764 free((void *)notification->text);
765 notification->text = NULL;
767 if (notification->name) {
768 free((void *)notification->name);
769 notification->name = NULL;
771 free((void*)notification);
775 static void __ps_free_compatibility(compatibility_x *compatibility)
777 if (compatibility == NULL)
779 if (compatibility->text) {
780 free((void *)compatibility->text);
781 compatibility->text = NULL;
783 if (compatibility->name) {
784 free((void *)compatibility->name);
785 compatibility->name = NULL;
787 free((void*)compatibility);
788 compatibility = NULL;
791 static void __ps_free_resolution(resolution_x *resolution)
793 if (resolution == NULL)
795 if (resolution->mimetype) {
796 free((void *)resolution->mimetype);
797 resolution->mimetype = NULL;
799 if (resolution->urischeme) {
800 free((void *)resolution->urischeme);
801 resolution->urischeme = NULL;
803 free((void*)resolution);
807 static void __ps_free_capability(capability_x *capability)
809 if (capability == NULL)
811 if (capability->operationid) {
812 free((void *)capability->operationid);
813 capability->operationid = NULL;
816 if (capability->resolution) {
817 resolution_x *resolution = capability->resolution;
818 resolution_x *tmp = NULL;
819 while(resolution != NULL)
821 tmp = resolution->next;
822 __ps_free_resolution(resolution);
826 free((void*)capability);
830 static void __ps_free_allowed(allowed_x *allowed)
835 free((void *)allowed->name);
836 allowed->name = NULL;
839 free((void *)allowed->text);
840 allowed->text = NULL;
842 free((void*)allowed);
846 static void __ps_free_request(request_x *request)
851 free((void *)request->text);
852 request->text = NULL;
854 free((void*)request);
858 static void __ps_free_datacontrol(datacontrol_x *datacontrol)
860 if (datacontrol == NULL)
862 if (datacontrol->providerid) {
863 free((void *)datacontrol->providerid);
864 datacontrol->providerid = NULL;
867 if (datacontrol->capability) {
868 capability_x *capability = datacontrol->capability;
869 capability_x *tmp = NULL;
870 while(capability != NULL)
872 tmp = capability->next;
873 __ps_free_capability(capability);
877 free((void*)datacontrol);
881 static void __ps_free_launchconditions(launchconditions_x *launchconditions)
883 if (launchconditions == NULL)
885 if (launchconditions->text) {
886 free((void *)launchconditions->text);
887 launchconditions->text = NULL;
890 if (launchconditions->condition) {
891 condition_x *condition = launchconditions->condition;
892 condition_x *tmp = NULL;
893 while(condition != NULL)
895 tmp = condition->next;
896 __ps_free_condition(condition);
900 free((void*)launchconditions);
901 launchconditions = NULL;
904 static void __ps_free_appcontrol(appcontrol_x *appcontrol)
906 if (appcontrol == NULL)
908 if (appcontrol->text) {
909 free((void *)appcontrol->text);
910 appcontrol->text = NULL;
913 if (appcontrol->operation) {
914 operation_x *operation = appcontrol->operation;
915 operation_x *tmp = NULL;
916 while(operation != NULL)
918 tmp = operation->next;
919 __ps_free_operation(operation);
924 if (appcontrol->uri) {
925 uri_x *uri = appcontrol->uri;
935 if (appcontrol->mime) {
936 mime_x *mime = appcontrol->mime;
941 __ps_free_mime(mime);
946 if (appcontrol->subapp) {
947 subapp_x *subapp = appcontrol->subapp;
948 subapp_x *tmp = NULL;
949 while(subapp != NULL)
952 __ps_free_subapp(subapp);
956 free((void*)appcontrol);
960 static void __ps_free_appsvc(appsvc_x *appsvc)
965 free((void *)appsvc->text);
969 if (appsvc->operation) {
970 operation_x *operation = appsvc->operation;
971 operation_x *tmp = NULL;
972 while(operation != NULL)
974 tmp = operation->next;
975 __ps_free_operation(operation);
981 uri_x *uri = appsvc->uri;
992 mime_x *mime = appsvc->mime;
997 __ps_free_mime(mime);
1002 if (appsvc->subapp) {
1003 subapp_x *subapp = appsvc->subapp;
1004 subapp_x *tmp = NULL;
1005 while(subapp != NULL)
1008 __ps_free_subapp(subapp);
1012 free((void*)appsvc);
1016 static void __ps_free_deviceprofile(deviceprofile_x *deviceprofile)
1021 static void __ps_free_define(define_x *define)
1026 free((void *)define->path);
1027 define->path = NULL;
1030 if (define->request) {
1031 request_x *request = define->request;
1032 request_x *tmp = NULL;
1033 while(request != NULL)
1035 tmp = request->next;
1036 __ps_free_request(request);
1041 if (define->allowed) {
1042 allowed_x *allowed = define->allowed;
1043 allowed_x *tmp = NULL;
1044 while(allowed != NULL)
1046 tmp = allowed->next;
1047 __ps_free_allowed(allowed);
1051 free((void*)define);
1055 static void __ps_free_registry(registry_x *registry)
1057 if (registry == NULL)
1059 if (registry->name) {
1060 free((void *)registry->name);
1061 registry->name = NULL;
1063 if (registry->text) {
1064 free((void *)registry->text);
1065 registry->text = NULL;
1067 free((void*)registry);
1071 static void __ps_free_database(database_x *database)
1073 if (database == NULL)
1075 if (database->name) {
1076 free((void *)database->name);
1077 database->name = NULL;
1079 if (database->text) {
1080 free((void *)database->text);
1081 database->text = NULL;
1083 free((void*)database);
1087 static void __ps_free_datashare(datashare_x *datashare)
1089 if (datashare == NULL)
1092 if (datashare->define) {
1093 define_x *define = datashare->define;
1094 define_x *tmp = NULL;
1095 while(define != NULL)
1098 __ps_free_define(define);
1103 if (datashare->request) {
1104 request_x *request = datashare->request;
1105 request_x *tmp = NULL;
1106 while(request != NULL)
1108 tmp = request->next;
1109 __ps_free_request(request);
1113 free((void*)datashare);
1117 static void __ps_free_layout(layout_x *layout)
1122 free((void *)layout->name);
1123 layout->name = NULL;
1126 free((void *)layout->text);
1127 layout->text = NULL;
1129 free((void*)layout);
1133 static void __ps_free_label(label_x *label)
1138 free((void *)label->name);
1142 free((void *)label->text);
1146 free((void *)label->lang);
1153 static void __ps_free_author(author_x *author)
1157 if (author->email) {
1158 free((void *)author->email);
1159 author->email = NULL;
1162 free((void *)author->text);
1163 author->text = NULL;
1166 free((void *)author->href);
1167 author->href = NULL;
1170 free((void *)author->lang);
1171 author->lang = NULL;
1173 free((void*)author);
1177 static void __ps_free_description(description_x *description)
1179 if (description == NULL)
1181 if (description->name) {
1182 free((void *)description->name);
1183 description->name = NULL;
1185 if (description->text) {
1186 free((void *)description->text);
1187 description->text = NULL;
1189 if (description->lang) {
1190 free((void *)description->lang);
1191 description->lang = NULL;
1193 free((void*)description);
1197 static void __ps_free_license(license_x *license)
1199 if (license == NULL)
1201 if (license->text) {
1202 free((void *)license->text);
1203 license->text = NULL;
1205 if (license->lang) {
1206 free((void *)license->lang);
1207 license->lang = NULL;
1209 free((void*)license);
1213 static void __ps_free_uiapplication(uiapplication_x *uiapplication)
1215 if (uiapplication == NULL)
1217 if (uiapplication->exec) {
1218 free((void *)uiapplication->exec);
1219 uiapplication->exec = NULL;
1221 if (uiapplication->appid) {
1222 free((void *)uiapplication->appid);
1223 uiapplication->appid = NULL;
1225 if (uiapplication->nodisplay) {
1226 free((void *)uiapplication->nodisplay);
1227 uiapplication->nodisplay = NULL;
1229 if (uiapplication->multiple) {
1230 free((void *)uiapplication->multiple);
1231 uiapplication->multiple = NULL;
1233 if (uiapplication->type) {
1234 free((void *)uiapplication->type);
1235 uiapplication->type = NULL;
1237 if (uiapplication->categories) {
1238 free((void *)uiapplication->categories);
1239 uiapplication->categories = NULL;
1241 if (uiapplication->extraid) {
1242 free((void *)uiapplication->extraid);
1243 uiapplication->extraid = NULL;
1245 if (uiapplication->taskmanage) {
1246 free((void *)uiapplication->taskmanage);
1247 uiapplication->taskmanage = NULL;
1249 if (uiapplication->enabled) {
1250 free((void *)uiapplication->enabled);
1251 uiapplication->enabled = NULL;
1253 if (uiapplication->hwacceleration) {
1254 free((void *)uiapplication->hwacceleration);
1255 uiapplication->hwacceleration = NULL;
1257 if (uiapplication->mainapp) {
1258 free((void *)uiapplication->mainapp);
1259 uiapplication->mainapp = NULL;
1261 if (uiapplication->recentimage) {
1262 free((void *)uiapplication->recentimage);
1263 uiapplication->recentimage = NULL;
1266 if (uiapplication->label) {
1267 label_x *label = uiapplication->label;
1268 label_x *tmp = NULL;
1269 while(label != NULL)
1272 __ps_free_label(label);
1277 if (uiapplication->icon) {
1278 icon_x *icon = uiapplication->icon;
1283 __ps_free_icon(icon);
1288 if (uiapplication->image) {
1289 image_x *image = uiapplication->image;
1290 image_x *tmp = NULL;
1291 while(image != NULL)
1294 __ps_free_image(image);
1299 if (uiapplication->appcontrol) {
1300 appcontrol_x *appcontrol = uiapplication->appcontrol;
1301 appcontrol_x *tmp = NULL;
1302 while(appcontrol != NULL)
1304 tmp = appcontrol->next;
1305 __ps_free_appcontrol(appcontrol);
1309 /*Free LaunchConditions*/
1310 if (uiapplication->launchconditions) {
1311 launchconditions_x *launchconditions = uiapplication->launchconditions;
1312 launchconditions_x *tmp = NULL;
1313 while(launchconditions != NULL)
1315 tmp = launchconditions->next;
1316 __ps_free_launchconditions(launchconditions);
1317 launchconditions = tmp;
1320 /*Free Notification*/
1321 if (uiapplication->notification) {
1322 notification_x *notification = uiapplication->notification;
1323 notification_x *tmp = NULL;
1324 while(notification != NULL)
1326 tmp = notification->next;
1327 __ps_free_notification(notification);
1332 if (uiapplication->datashare) {
1333 datashare_x *datashare = uiapplication->datashare;
1334 datashare_x *tmp = NULL;
1335 while(datashare != NULL)
1337 tmp = datashare->next;
1338 __ps_free_datashare(datashare);
1343 if (uiapplication->appsvc) {
1344 appsvc_x *appsvc = uiapplication->appsvc;
1345 appsvc_x *tmp = NULL;
1346 while(appsvc != NULL)
1349 __ps_free_appsvc(appsvc);
1354 if (uiapplication->category) {
1355 category_x *category = uiapplication->category;
1356 category_x *tmp = NULL;
1357 while(category != NULL)
1359 tmp = category->next;
1360 __ps_free_category(category);
1365 if (uiapplication->metadata) {
1366 metadata_x *metadata = uiapplication->metadata;
1367 metadata_x *tmp = NULL;
1368 while(metadata != NULL)
1370 tmp = metadata->next;
1371 __ps_free_metadata(metadata);
1376 if (uiapplication->permission) {
1377 permission_x *permission = uiapplication->permission;
1378 permission_x *tmp = NULL;
1379 while(permission != NULL)
1381 tmp = permission->next;
1382 __ps_free_permission(permission);
1386 /* _PRODUCT_LAUNCHING_ENHANCED_ START */
1387 if (uiapplication->indicatordisplay) {
1388 free((void *)uiapplication->indicatordisplay);
1389 uiapplication->indicatordisplay = NULL;
1391 if (uiapplication->portraitimg) {
1392 free((void *)uiapplication->portraitimg);
1393 uiapplication->portraitimg = NULL;
1395 if (uiapplication->landscapeimg) {
1396 free((void *)uiapplication->landscapeimg);
1397 uiapplication->landscapeimg = NULL;
1399 /* _PRODUCT_LAUNCHING_ENHANCED_ END */
1400 if (uiapplication->guestmode_visibility) {
1401 free((void *)uiapplication->guestmode_visibility);
1402 uiapplication->guestmode_visibility = NULL;
1404 free((void*)uiapplication);
1405 uiapplication = NULL;
1408 static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication)
1410 if (serviceapplication == NULL)
1412 if (serviceapplication->exec) {
1413 free((void *)serviceapplication->exec);
1414 serviceapplication->exec = NULL;
1416 if (serviceapplication->appid) {
1417 free((void *)serviceapplication->appid);
1418 serviceapplication->appid = NULL;
1420 if (serviceapplication->onboot) {
1421 free((void *)serviceapplication->onboot);
1422 serviceapplication->onboot = NULL;
1424 if (serviceapplication->autorestart) {
1425 free((void *)serviceapplication->autorestart);
1426 serviceapplication->autorestart = NULL;
1428 if (serviceapplication->type) {
1429 free((void *)serviceapplication->type);
1430 serviceapplication->type = NULL;
1433 if (serviceapplication->label) {
1434 label_x *label = serviceapplication->label;
1435 label_x *tmp = NULL;
1436 while(label != NULL)
1439 __ps_free_label(label);
1444 if (serviceapplication->icon) {
1445 icon_x *icon = serviceapplication->icon;
1450 __ps_free_icon(icon);
1455 if (serviceapplication->appcontrol) {
1456 appcontrol_x *appcontrol = serviceapplication->appcontrol;
1457 appcontrol_x *tmp = NULL;
1458 while(appcontrol != NULL)
1460 tmp = appcontrol->next;
1461 __ps_free_appcontrol(appcontrol);
1465 /*Free DataControl*/
1466 if (serviceapplication->datacontrol) {
1467 datacontrol_x *datacontrol = serviceapplication->datacontrol;
1468 datacontrol_x *tmp = NULL;
1469 while(datacontrol != NULL)
1471 tmp = datacontrol->next;
1472 __ps_free_datacontrol(datacontrol);
1476 /*Free LaunchConditions*/
1477 if (serviceapplication->launchconditions) {
1478 launchconditions_x *launchconditions = serviceapplication->launchconditions;
1479 launchconditions_x *tmp = NULL;
1480 while(launchconditions != NULL)
1482 tmp = launchconditions->next;
1483 __ps_free_launchconditions(launchconditions);
1484 launchconditions = tmp;
1487 /*Free Notification*/
1488 if (serviceapplication->notification) {
1489 notification_x *notification = serviceapplication->notification;
1490 notification_x *tmp = NULL;
1491 while(notification != NULL)
1493 tmp = notification->next;
1494 __ps_free_notification(notification);
1499 if (serviceapplication->datashare) {
1500 datashare_x *datashare = serviceapplication->datashare;
1501 datashare_x *tmp = NULL;
1502 while(datashare != NULL)
1504 tmp = datashare->next;
1505 __ps_free_datashare(datashare);
1510 if (serviceapplication->appsvc) {
1511 appsvc_x *appsvc = serviceapplication->appsvc;
1512 appsvc_x *tmp = NULL;
1513 while(appsvc != NULL)
1516 __ps_free_appsvc(appsvc);
1521 if (serviceapplication->category) {
1522 category_x *category = serviceapplication->category;
1523 category_x *tmp = NULL;
1524 while(category != NULL)
1526 tmp = category->next;
1527 __ps_free_category(category);
1532 if (serviceapplication->metadata) {
1533 metadata_x *metadata = serviceapplication->metadata;
1534 metadata_x *tmp = NULL;
1535 while(metadata != NULL)
1537 tmp = metadata->next;
1538 __ps_free_metadata(metadata);
1543 if (serviceapplication->permission) {
1544 permission_x *permission = serviceapplication->permission;
1545 permission_x *tmp = NULL;
1546 while(permission != NULL)
1548 tmp = permission->next;
1549 __ps_free_permission(permission);
1553 free((void*)serviceapplication);
1554 serviceapplication = NULL;
1557 static void __ps_free_font(font_x *font)
1562 free((void *)font->name);
1566 free((void *)font->text);
1573 static void __ps_free_theme(theme_x *theme)
1578 free((void *)theme->name);
1582 free((void *)theme->text);
1589 static void __ps_free_daemon(daemon_x *daemon)
1594 free((void *)daemon->name);
1595 daemon->name = NULL;
1598 free((void *)daemon->text);
1599 daemon->text = NULL;
1601 free((void*)daemon);
1605 static void __ps_free_ime(ime_x *ime)
1610 free((void *)ime->name);
1614 free((void *)ime->text);
1622 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed)
1624 xmlTextReaderRead(reader);
1625 if (xmlTextReaderValue(reader))
1626 allowed->text = ASCII(xmlTextReaderValue(reader));
1630 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation)
1632 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1633 operation->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1634 /* Text does not exist. Only attribute exists
1635 xmlTextReaderRead(reader);
1636 if (xmlTextReaderValue(reader))
1637 operation->text = ASCII(xmlTextReaderValue(reader));
1642 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri)
1644 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1645 uri->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1646 /* Text does not exist. Only attribute exists
1647 xmlTextReaderRead(reader);
1648 if (xmlTextReaderValue(reader))
1649 uri->text = ASCII(xmlTextReaderValue(reader));
1654 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime)
1656 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1657 mime->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1658 /* Text does not exist. Only attribute exists
1659 xmlTextReaderRead(reader);
1660 if (xmlTextReaderValue(reader))
1661 mime->text = ASCII(xmlTextReaderValue(reader));
1666 static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp)
1668 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1669 subapp->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1670 /* Text does not exist. Only attribute exists
1671 xmlTextReaderRead(reader);
1672 if (xmlTextReaderValue(reader))
1673 mime->text = ASCII(xmlTextReaderValue(reader));
1678 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition)
1680 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1681 condition->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1682 xmlTextReaderRead(reader);
1683 if (xmlTextReaderValue(reader))
1684 condition->text = ASCII(xmlTextReaderValue(reader));
1688 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notification)
1690 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1691 notification->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1692 xmlTextReaderRead(reader);
1693 if (xmlTextReaderValue(reader))
1694 notification->text = ASCII(xmlTextReaderValue(reader));
1698 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category)
1700 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1701 category->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1705 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata)
1707 /*name and value both should exist. If any one attribute is missing then dont parse*/
1708 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")) && xmlTextReaderGetAttribute(reader, XMLCHAR("value"))) {
1709 metadata->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1710 metadata->value = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("value")));
1715 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission)
1717 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
1718 permission->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
1720 xmlTextReaderRead(reader);
1721 if (xmlTextReaderValue(reader))
1722 permission->value = ASCII(xmlTextReaderValue(reader));
1726 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility)
1728 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1729 compatibility->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1730 xmlTextReaderRead(reader);
1731 if (xmlTextReaderValue(reader))
1732 compatibility->text = ASCII(xmlTextReaderValue(reader));
1736 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution)
1738 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")))
1739 resolution->mimetype = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")));
1740 if (xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")))
1741 resolution->urischeme = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")));
1745 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request)
1747 xmlTextReaderRead(reader);
1748 if (xmlTextReaderValue(reader))
1749 request->text = ASCII(xmlTextReaderValue(reader));
1753 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define)
1755 const xmlChar *node;
1758 allowed_x *tmp1 = NULL;
1759 request_x *tmp2 = NULL;
1761 if (xmlTextReaderGetAttribute(reader, XMLCHAR("path")))
1762 define->path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("path")));
1764 depth = xmlTextReaderDepth(reader);
1765 while ((ret = __next_child_element(reader, depth))) {
1766 node = xmlTextReaderConstName(reader);
1768 DBG("xmlTextReaderConstName value is NULL\n");
1772 if (!strcmp(ASCII(node), "allowed")) {
1773 allowed_x *allowed= malloc(sizeof(allowed_x));
1774 if (allowed == NULL) {
1775 DBG("Malloc Failed\n");
1778 memset(allowed, '\0', sizeof(allowed_x));
1779 LISTADD(define->allowed, allowed);
1780 ret = __ps_process_allowed(reader, allowed);
1781 } else if (!strcmp(ASCII(node), "request")) {
1782 request_x *request = malloc(sizeof(request_x));
1783 if (request == NULL) {
1784 DBG("Malloc Failed\n");
1787 memset(request, '\0', sizeof(request_x));
1788 LISTADD(define->request, request);
1789 ret = __ps_process_request(reader, request);
1793 DBG("Processing define failed\n");
1797 if (define->allowed) {
1798 LISTHEAD(define->allowed, tmp1);
1799 define->allowed = tmp1;
1801 if (define->request) {
1802 LISTHEAD(define->request, tmp2);
1803 define->request = tmp2;
1808 static int __ps_process_registry(xmlTextReaderPtr reader, registry_x *registry)
1810 /*TODO: once policy is set*/
1814 static int __ps_process_database(xmlTextReaderPtr reader, database_x *database)
1816 /*TODO: once policy is set*/
1820 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol)
1822 const xmlChar *node;
1825 operation_x *tmp1 = NULL;
1827 mime_x *tmp3 = NULL;
1828 subapp_x *tmp4 = NULL;
1830 depth = xmlTextReaderDepth(reader);
1831 while ((ret = __next_child_element(reader, depth))) {
1832 node = xmlTextReaderConstName(reader);
1834 DBG("xmlTextReaderConstName value is NULL\n");
1838 if (!strcmp(ASCII(node), "operation")) {
1839 operation_x *operation = malloc(sizeof(operation_x));
1840 if (operation == NULL) {
1841 DBG("Malloc Failed\n");
1844 memset(operation, '\0', sizeof(operation_x));
1845 LISTADD(appcontrol->operation, operation);
1846 ret = __ps_process_operation(reader, operation);
1847 DBG("operation processing\n");
1848 } else if (!strcmp(ASCII(node), "uri")) {
1849 uri_x *uri= malloc(sizeof(uri_x));
1851 DBG("Malloc Failed\n");
1854 memset(uri, '\0', sizeof(uri_x));
1855 LISTADD(appcontrol->uri, uri);
1856 ret = __ps_process_uri(reader, uri);
1857 DBG("uri processing\n");
1858 } else if (!strcmp(ASCII(node), "mime")) {
1859 mime_x *mime = malloc(sizeof(mime_x));
1861 DBG("Malloc Failed\n");
1864 memset(mime, '\0', sizeof(mime_x));
1865 LISTADD(appcontrol->mime, mime);
1866 ret = __ps_process_mime(reader, mime);
1867 DBG("mime processing\n");
1868 } else if (!strcmp(ASCII(node), "subapp")) {
1869 subapp_x *subapp = malloc(sizeof(subapp_x));
1870 if (subapp == NULL) {
1871 DBG("Malloc Failed\n");
1874 memset(subapp, '\0', sizeof(subapp_x));
1875 LISTADD(appcontrol->subapp, subapp);
1876 ret = __ps_process_subapp(reader, subapp);
1877 DBG("subapp processing\n");
1881 DBG("Processing appcontrol failed\n");
1885 if (appcontrol->operation) {
1886 LISTHEAD(appcontrol->operation, tmp1);
1887 appcontrol->operation = tmp1;
1889 if (appcontrol->uri) {
1890 LISTHEAD(appcontrol->uri, tmp2);
1891 appcontrol->uri = tmp2;
1893 if (appcontrol->mime) {
1894 LISTHEAD(appcontrol->mime, tmp3);
1895 appcontrol->mime = tmp3;
1897 if (appcontrol->subapp) {
1898 LISTHEAD(appcontrol->subapp, tmp4);
1899 appcontrol->subapp = tmp4;
1902 xmlTextReaderRead(reader);
1903 if (xmlTextReaderValue(reader))
1904 appcontrol->text = ASCII(xmlTextReaderValue(reader));
1909 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc)
1911 const xmlChar *node;
1914 operation_x *tmp1 = NULL;
1916 mime_x *tmp3 = NULL;
1917 subapp_x *tmp4 = NULL;
1919 depth = xmlTextReaderDepth(reader);
1920 while ((ret = __next_child_element(reader, depth))) {
1921 node = xmlTextReaderConstName(reader);
1923 DBG("xmlTextReaderConstName value is NULL\n");
1927 if (!strcmp(ASCII(node), "operation")) {
1928 operation_x *operation = malloc(sizeof(operation_x));
1929 if (operation == NULL) {
1930 DBG("Malloc Failed\n");
1933 memset(operation, '\0', sizeof(operation_x));
1934 LISTADD(appsvc->operation, operation);
1935 ret = __ps_process_operation(reader, operation);
1936 DBG("operation processing\n");
1937 } else if (!strcmp(ASCII(node), "uri")) {
1938 uri_x *uri= malloc(sizeof(uri_x));
1940 DBG("Malloc Failed\n");
1943 memset(uri, '\0', sizeof(uri_x));
1944 LISTADD(appsvc->uri, uri);
1945 ret = __ps_process_uri(reader, uri);
1946 DBG("uri processing\n");
1947 } else if (!strcmp(ASCII(node), "mime")) {
1948 mime_x *mime = malloc(sizeof(mime_x));
1950 DBG("Malloc Failed\n");
1953 memset(mime, '\0', sizeof(mime_x));
1954 LISTADD(appsvc->mime, mime);
1955 ret = __ps_process_mime(reader, mime);
1956 DBG("mime processing\n");
1957 } else if (!strcmp(ASCII(node), "subapp")) {
1958 subapp_x *subapp = malloc(sizeof(subapp_x));
1959 if (subapp == NULL) {
1960 DBG("Malloc Failed\n");
1963 memset(subapp, '\0', sizeof(subapp_x));
1964 LISTADD(appsvc->subapp, subapp);
1965 ret = __ps_process_subapp(reader, subapp);
1966 DBG("subapp processing\n");
1970 DBG("Processing appsvc failed\n");
1974 if (appsvc->operation) {
1975 LISTHEAD(appsvc->operation, tmp1);
1976 appsvc->operation = tmp1;
1979 LISTHEAD(appsvc->uri, tmp2);
1983 LISTHEAD(appsvc->mime, tmp3);
1984 appsvc->mime = tmp3;
1986 if (appsvc->subapp) {
1987 LISTHEAD(appsvc->subapp, tmp4);
1988 appsvc->subapp = tmp4;
1991 xmlTextReaderRead(reader);
1992 if (xmlTextReaderValue(reader))
1993 appsvc->text = ASCII(xmlTextReaderValue(reader));
1998 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions)
2000 const xmlChar *node;
2003 condition_x *tmp1 = NULL;
2005 depth = xmlTextReaderDepth(reader);
2006 while ((ret = __next_child_element(reader, depth))) {
2007 node = xmlTextReaderConstName(reader);
2009 DBG("xmlTextReaderConstName value is NULL\n");
2013 if (strcmp(ASCII(node), "condition") == 0) {
2014 condition_x *condition = malloc(sizeof(condition_x));
2015 if (condition == NULL) {
2016 DBG("Malloc Failed\n");
2019 memset(condition, '\0', sizeof(condition_x));
2020 LISTADD(launchconditions->condition, condition);
2021 ret = __ps_process_condition(reader, condition);
2025 DBG("Processing launchconditions failed\n");
2029 if (launchconditions->condition) {
2030 LISTHEAD(launchconditions->condition, tmp1);
2031 launchconditions->condition = tmp1;
2034 xmlTextReaderRead(reader);
2035 if (xmlTextReaderValue(reader))
2036 launchconditions->text = ASCII(xmlTextReaderValue(reader));
2041 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare)
2043 const xmlChar *node;
2046 define_x *tmp1 = NULL;
2047 request_x *tmp2 = NULL;
2048 depth = xmlTextReaderDepth(reader);
2049 while ((ret = __next_child_element(reader, depth))) {
2050 node = xmlTextReaderConstName(reader);
2052 DBG("xmlTextReaderConstName value is NULL\n");
2056 if (!strcmp(ASCII(node), "define")) {
2057 define_x *define= malloc(sizeof(define_x));
2058 if (define == NULL) {
2059 DBG("Malloc Failed\n");
2062 memset(define, '\0', sizeof(define_x));
2063 LISTADD(datashare->define, define);
2064 ret = __ps_process_define(reader, define);
2065 } else if (!strcmp(ASCII(node), "request")) {
2066 request_x *request= malloc(sizeof(request_x));
2067 if (request == NULL) {
2068 DBG("Malloc Failed\n");
2071 memset(request, '\0', sizeof(request_x));
2072 LISTADD(datashare->request, request);
2073 ret = __ps_process_request(reader, request);
2077 DBG("Processing data-share failed\n");
2081 if (datashare->define) {
2082 LISTHEAD(datashare->define, tmp1);
2083 datashare->define = tmp1;
2085 if (datashare->request) {
2086 LISTHEAD(datashare->request, tmp2);
2087 datashare->request = tmp2;
2092 static int __ps_process_layout(xmlTextReaderPtr reader, layout_x *layout)
2094 /*TODO: once policy is set*/
2099 __get_icon_with_path(char* icon)
2104 if (index(icon, '/') == NULL) {
2106 char* icon_with_path = NULL;
2112 theme = vconf_get_str("db/setting/theme");
2114 theme = strdup("default");
2120 len = (0x01 << 7) + strlen(icon) + strlen(package) + strlen(theme);
2121 icon_with_path = malloc(len);
2122 if(icon_with_path == NULL) {
2123 DBG("(icon_with_path == NULL) return\n");
2128 memset(icon_with_path, 0, len);
2130 snprintf(icon_with_path, len, "/opt/share/icons/%s/small/%s", theme, icon);
2132 if (access(icon_with_path, R_OK) == 0) break;
2133 snprintf(icon_with_path, len, "/usr/share/icons/%s/small/%s", theme, icon);
2134 if (access(icon_with_path, R_OK) == 0) break;
2135 DBG("cannot find icon %s", icon_with_path);
2136 snprintf(icon_with_path, len,"/opt/share/icons/default/small/%s", icon);
2137 if (access(icon_with_path, R_OK) == 0) break;
2138 snprintf(icon_with_path, len, "/usr/share/icons/default/small/%s", icon);
2139 if (access(icon_with_path, R_OK) == 0) break;
2141 /* icon path is going to be moved intto the app directory */
2142 DBGE("icon file must be moved to %s", icon_with_path);
2143 snprintf(icon_with_path, len, "/opt/apps/%s/res/icons/%s/small/%s", package, theme, icon);
2144 if (access(icon_with_path, R_OK) == 0) break;
2145 snprintf(icon_with_path, len, "/usr/apps/%s/res/icons/%s/small/%s", package, theme, icon);
2146 if (access(icon_with_path, R_OK) == 0) break;
2147 DBG("cannot find icon %s", icon_with_path);
2148 snprintf(icon_with_path, len, "/opt/apps/%s/res/icons/default/small/%s", package, icon);
2149 if (access(icon_with_path, R_OK) == 0) break;
2150 snprintf(icon_with_path, len, "/usr/apps/%s/res/icons/default/small/%s", package, icon);
2151 if (access(icon_with_path, R_OK) == 0) break;
2156 DBG("Icon path : %s ---> %s", icon, icon_with_path);
2158 return icon_with_path;
2160 char* confirmed_icon = NULL;
2162 confirmed_icon = strdup(icon);
2163 if (!confirmed_icon)
2165 return confirmed_icon;
2170 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon)
2172 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2173 icon->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2174 if (xmlTextReaderConstXmlLang(reader)) {
2175 icon->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2176 if (icon->lang == NULL)
2177 icon->lang = strdup(DEFAULT_LOCALE);
2179 icon->lang = strdup(DEFAULT_LOCALE);
2181 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
2182 icon->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
2183 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
2184 icon->size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
2185 if (xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")))
2186 icon->resolution = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")));
2187 xmlTextReaderRead(reader);
2188 if (xmlTextReaderValue(reader)) {
2189 char *text = ASCII(xmlTextReaderValue(reader));
2191 icon->text = __get_icon_with_path(text);
2199 static int __ps_process_image(xmlTextReaderPtr reader, image_x *image)
2201 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2202 image->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2203 if (xmlTextReaderConstXmlLang(reader)) {
2204 image->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2205 if (image->lang == NULL)
2206 image->lang = strdup(DEFAULT_LOCALE);
2208 image->lang = strdup(DEFAULT_LOCALE);
2210 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
2211 image->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
2212 xmlTextReaderRead(reader);
2213 if (xmlTextReaderValue(reader))
2214 image->text = ASCII(xmlTextReaderValue(reader));
2219 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label)
2221 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2222 label->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2223 if (xmlTextReaderConstXmlLang(reader)) {
2224 label->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2225 if (label->lang == NULL)
2226 label->lang = strdup(DEFAULT_LOCALE);
2228 label->lang = strdup(DEFAULT_LOCALE);
2230 xmlTextReaderRead(reader);
2231 if (xmlTextReaderValue(reader))
2232 label->text = ASCII(xmlTextReaderValue(reader));
2234 /* DBG("lable name %s\n", label->name);
2235 DBG("lable lang %s\n", label->lang);
2236 DBG("lable text %s\n", label->text);
2242 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author)
2244 if (xmlTextReaderGetAttribute(reader, XMLCHAR("email")))
2245 author->email = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("email")));
2246 if (xmlTextReaderGetAttribute(reader, XMLCHAR("href")))
2247 author->href = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("href")));
2248 if (xmlTextReaderConstXmlLang(reader)) {
2249 author->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2250 if (author->lang == NULL)
2251 author->lang = strdup(DEFAULT_LOCALE);
2253 author->lang = strdup(DEFAULT_LOCALE);
2255 xmlTextReaderRead(reader);
2256 if (xmlTextReaderValue(reader))
2257 author->text = ASCII(xmlTextReaderValue(reader));
2261 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description)
2263 if (xmlTextReaderConstXmlLang(reader)) {
2264 description->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2265 if (description->lang == NULL)
2266 description->lang = strdup(DEFAULT_LOCALE);
2268 description->lang = strdup(DEFAULT_LOCALE);
2270 xmlTextReaderRead(reader);
2271 if (xmlTextReaderValue(reader))
2272 description->text = ASCII(xmlTextReaderValue(reader));
2276 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license)
2278 if (xmlTextReaderConstXmlLang(reader)) {
2279 license->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2280 if (license->lang == NULL)
2281 license->lang = strdup(DEFAULT_LOCALE);
2283 license->lang = strdup(DEFAULT_LOCALE);
2285 xmlTextReaderRead(reader);
2286 if (xmlTextReaderValue(reader))
2287 license->text = ASCII(xmlTextReaderValue(reader));
2291 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability)
2293 const xmlChar *node;
2296 resolution_x *tmp1 = NULL;
2298 if (xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")))
2299 capability->operationid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")));
2301 depth = xmlTextReaderDepth(reader);
2302 while ((ret = __next_child_element(reader, depth))) {
2303 node = xmlTextReaderConstName(reader);
2305 DBG("xmlTextReaderConstName value is NULL\n");
2309 if (!strcmp(ASCII(node), "resolution")) {
2310 resolution_x *resolution = malloc(sizeof(resolution_x));
2311 if (resolution == NULL) {
2312 DBG("Malloc Failed\n");
2315 memset(resolution, '\0', sizeof(resolution_x));
2316 LISTADD(capability->resolution, resolution);
2317 ret = __ps_process_resolution(reader, resolution);
2321 DBG("Processing capability failed\n");
2326 if (capability->resolution) {
2327 LISTHEAD(capability->resolution, tmp1);
2328 capability->resolution = tmp1;
2334 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol)
2336 const xmlChar *node;
2339 capability_x *tmp1 = NULL;
2341 if (xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")))
2342 datacontrol->providerid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")));
2344 depth = xmlTextReaderDepth(reader);
2345 while ((ret = __next_child_element(reader, depth))) {
2346 node = xmlTextReaderConstName(reader);
2348 DBG("xmlTextReaderConstName value is NULL\n");
2352 if (!strcmp(ASCII(node), "capability")) {
2353 capability_x *capability = malloc(sizeof(capability_x));
2354 if (capability == NULL) {
2355 DBG("Malloc Failed\n");
2358 memset(capability, '\0', sizeof(capability_x));
2359 LISTADD(datacontrol->capability, capability);
2360 ret = __ps_process_capability(reader, capability);
2364 DBG("Processing datacontrol failed\n");
2369 if (datacontrol->capability) {
2370 LISTHEAD(datacontrol->capability, tmp1);
2371 datacontrol->capability = tmp1;
2377 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication)
2379 const xmlChar *node;
2382 char *newappid = NULL;
2383 label_x *tmp1 = NULL;
2384 icon_x *tmp2 = NULL;
2385 appsvc_x *tmp3 = NULL;
2386 appcontrol_x *tmp4 = NULL;
2387 launchconditions_x *tmp5 = NULL;
2388 notification_x *tmp6 = NULL;
2389 datashare_x *tmp7 = NULL;
2390 category_x *tmp8 = NULL;
2391 metadata_x *tmp9 = NULL;
2392 image_x *tmp10 = NULL;
2393 permission_x *tmp11 = NULL;
2395 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
2396 uiapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
2397 if (uiapplication->appid == NULL) {
2398 DBG("appid cant be NULL\n");
2402 DBG("appid is mandatory\n");
2406 ret = __validate_appid(package, uiapplication->appid, &newappid);
2408 DBG("appid is not proper\n");
2412 if (uiapplication->appid)
2413 free((void *)uiapplication->appid);
2414 uiapplication->appid = newappid;
2417 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
2418 uiapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
2419 if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay"))) {
2420 uiapplication->nodisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay")));
2421 if (uiapplication->nodisplay == NULL)
2422 uiapplication->nodisplay = strdup("false");
2424 uiapplication->nodisplay = strdup("false");
2426 if (xmlTextReaderGetAttribute(reader, XMLCHAR("multiple"))) {
2427 uiapplication->multiple = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("multiple")));
2428 if (uiapplication->multiple == NULL)
2429 uiapplication->multiple = strdup("false");
2431 uiapplication->multiple = strdup("false");
2433 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
2434 uiapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
2435 if (xmlTextReaderGetAttribute(reader, XMLCHAR("categories")))
2436 uiapplication->categories = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("categories")));
2437 if (xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")))
2438 uiapplication->extraid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")));
2439 if (xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage"))) {
2440 uiapplication->taskmanage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage")));
2441 if (uiapplication->taskmanage == NULL)
2442 uiapplication->taskmanage = strdup("true");
2444 uiapplication->taskmanage = strdup("true");
2446 if (xmlTextReaderGetAttribute(reader, XMLCHAR("enabled"))) {
2447 uiapplication->enabled = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("enabled")));
2448 if (uiapplication->enabled == NULL)
2449 uiapplication->enabled = strdup("true");
2451 uiapplication->enabled = strdup("true");
2453 if (xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration"))) {
2454 uiapplication->hwacceleration = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration")));
2455 if (uiapplication->hwacceleration == NULL)
2456 uiapplication->hwacceleration = strdup("use-system-setting");
2458 uiapplication->hwacceleration = strdup("use-system-setting");
2460 if (xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")))
2461 uiapplication->recentimage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")));
2462 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp"))) {
2463 uiapplication->mainapp = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp")));
2464 if (uiapplication->mainapp == NULL)
2465 uiapplication->mainapp = strdup("false");
2467 uiapplication->mainapp = strdup("false");
2469 if (xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay"))) {
2470 uiapplication->indicatordisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay")));
2471 if (uiapplication->indicatordisplay == NULL)
2472 uiapplication->indicatordisplay = strdup("true");
2474 uiapplication->indicatordisplay = strdup("true");
2476 if (xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")))
2477 uiapplication->portraitimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")));
2479 uiapplication->portraitimg = NULL;
2480 if (xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")))
2481 uiapplication->landscapeimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")));
2483 uiapplication->landscapeimg = NULL;
2484 if (xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility"))) {
2485 uiapplication->guestmode_visibility = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility")));
2486 if (uiapplication->guestmode_visibility == NULL)
2487 uiapplication->guestmode_visibility = strdup("true");
2489 uiapplication->guestmode_visibility = strdup("true");
2492 depth = xmlTextReaderDepth(reader);
2493 while ((ret = __next_child_element(reader, depth))) {
2494 node = xmlTextReaderConstName(reader);
2496 DBG("xmlTextReaderConstName value is NULL\n");
2499 if (!strcmp(ASCII(node), "label")) {
2500 label_x *label = malloc(sizeof(label_x));
2501 if (label == NULL) {
2502 DBG("Malloc Failed\n");
2505 memset(label, '\0', sizeof(label_x));
2506 LISTADD(uiapplication->label, label);
2507 ret = __ps_process_label(reader, label);
2508 } else if (!strcmp(ASCII(node), "icon")) {
2509 icon_x *icon = malloc(sizeof(icon_x));
2511 DBG("Malloc Failed\n");
2514 memset(icon, '\0', sizeof(icon_x));
2515 LISTADD(uiapplication->icon, icon);
2516 ret = __ps_process_icon(reader, icon);
2517 } else if (!strcmp(ASCII(node), "image")) {
2518 image_x *image = malloc(sizeof(image_x));
2519 if (image == NULL) {
2520 DBG("Malloc Failed\n");
2523 memset(image, '\0', sizeof(image_x));
2524 LISTADD(uiapplication->image, image);
2525 ret = __ps_process_image(reader, image);
2526 } else if (!strcmp(ASCII(node), "category")) {
2527 category_x *category = malloc(sizeof(category_x));
2528 if (category == NULL) {
2529 DBG("Malloc Failed\n");
2532 memset(category, '\0', sizeof(category_x));
2533 LISTADD(uiapplication->category, category);
2534 ret = __ps_process_category(reader, category);
2535 } else if (!strcmp(ASCII(node), "metadata")) {
2536 metadata_x *metadata = malloc(sizeof(metadata_x));
2537 if (metadata == NULL) {
2538 DBG("Malloc Failed\n");
2541 memset(metadata, '\0', sizeof(metadata_x));
2542 LISTADD(uiapplication->metadata, metadata);
2543 ret = __ps_process_metadata(reader, metadata);
2544 } else if (!strcmp(ASCII(node), "permission")) {
2545 permission_x *permission = malloc(sizeof(permission_x));
2546 if (permission == NULL) {
2547 DBG("Malloc Failed\n");
2550 memset(permission, '\0', sizeof(permission_x));
2551 LISTADD(uiapplication->permission, permission);
2552 ret = __ps_process_permission(reader, permission);
2553 } else if (!strcmp(ASCII(node), "app-control")) {
2554 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
2555 if (appcontrol == NULL) {
2556 DBG("Malloc Failed\n");
2559 memset(appcontrol, '\0', sizeof(appcontrol_x));
2560 LISTADD(uiapplication->appcontrol, appcontrol);
2561 ret = __ps_process_appcontrol(reader, appcontrol);
2562 } else if (!strcmp(ASCII(node), "application-service")) {
2563 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
2564 if (appsvc == NULL) {
2565 DBG("Malloc Failed\n");
2568 memset(appsvc, '\0', sizeof(appsvc_x));
2569 LISTADD(uiapplication->appsvc, appsvc);
2570 ret = __ps_process_appsvc(reader, appsvc);
2571 } else if (!strcmp(ASCII(node), "data-share")) {
2572 datashare_x *datashare = malloc(sizeof(datashare_x));
2573 if (datashare == NULL) {
2574 DBG("Malloc Failed\n");
2577 memset(datashare, '\0', sizeof(datashare_x));
2578 LISTADD(uiapplication->datashare, datashare);
2579 ret = __ps_process_datashare(reader, datashare);
2580 } else if (!strcmp(ASCII(node), "launch-conditions")) {
2581 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
2582 if (launchconditions == NULL) {
2583 DBG("Malloc Failed\n");
2586 memset(launchconditions, '\0', sizeof(launchconditions_x));
2587 LISTADD(uiapplication->launchconditions, launchconditions);
2588 ret = __ps_process_launchconditions(reader, launchconditions);
2589 } else if (!strcmp(ASCII(node), "notification")) {
2590 notification_x *notification = malloc(sizeof(notification_x));
2591 if (notification == NULL) {
2592 DBG("Malloc Failed\n");
2595 memset(notification, '\0', sizeof(notification_x));
2596 LISTADD(uiapplication->notification, notification);
2597 ret = __ps_process_notification(reader, notification);
2601 DBG("Processing uiapplication failed\n");
2606 if (uiapplication->label) {
2607 LISTHEAD(uiapplication->label, tmp1);
2608 uiapplication->label = tmp1;
2610 if (uiapplication->icon) {
2611 LISTHEAD(uiapplication->icon, tmp2);
2612 uiapplication->icon = tmp2;
2614 if (uiapplication->appsvc) {
2615 LISTHEAD(uiapplication->appsvc, tmp3);
2616 uiapplication->appsvc = tmp3;
2618 if (uiapplication->appcontrol) {
2619 LISTHEAD(uiapplication->appcontrol, tmp4);
2620 uiapplication->appcontrol = tmp4;
2622 if (uiapplication->launchconditions) {
2623 LISTHEAD(uiapplication->launchconditions, tmp5);
2624 uiapplication->launchconditions = tmp5;
2626 if (uiapplication->notification) {
2627 LISTHEAD(uiapplication->notification, tmp6);
2628 uiapplication->notification = tmp6;
2630 if (uiapplication->datashare) {
2631 LISTHEAD(uiapplication->datashare, tmp7);
2632 uiapplication->datashare = tmp7;
2634 if (uiapplication->category) {
2635 LISTHEAD(uiapplication->category, tmp8);
2636 uiapplication->category = tmp8;
2638 if (uiapplication->metadata) {
2639 LISTHEAD(uiapplication->metadata, tmp9);
2640 uiapplication->metadata = tmp9;
2642 if (uiapplication->image) {
2643 LISTHEAD(uiapplication->image, tmp10);
2644 uiapplication->image = tmp10;
2646 if (uiapplication->permission) {
2647 LISTHEAD(uiapplication->permission, tmp11);
2648 uiapplication->permission = tmp11;
2654 static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication)
2656 const xmlChar *node;
2659 char *newappid = NULL;
2660 label_x *tmp1 = NULL;
2661 icon_x *tmp2 = NULL;
2662 appsvc_x *tmp3 = NULL;
2663 appcontrol_x *tmp4 = NULL;
2664 datacontrol_x *tmp5 = NULL;
2665 launchconditions_x *tmp6 = NULL;
2666 notification_x *tmp7 = NULL;
2667 datashare_x *tmp8 = NULL;
2668 category_x *tmp9 = NULL;
2669 metadata_x *tmp10 = NULL;
2670 permission_x *tmp11 = NULL;
2672 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
2673 serviceapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
2674 if (serviceapplication->appid == NULL) {
2675 DBG("appid cant be NULL\n");
2679 DBG("appid is mandatory\n");
2683 ret = __validate_appid(package, serviceapplication->appid, &newappid);
2685 DBG("appid is not proper\n");
2689 if (serviceapplication->appid)
2690 free((void *)serviceapplication->appid);
2691 serviceapplication->appid = newappid;
2694 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
2695 serviceapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
2696 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
2697 serviceapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
2698 if (xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot"))) {
2699 serviceapplication->onboot = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot")));
2700 if (serviceapplication->onboot == NULL)
2701 serviceapplication->onboot = strdup("false");
2703 serviceapplication->onboot = strdup("false");
2705 if (xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart"))) {
2706 serviceapplication->autorestart = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart")));
2707 if (serviceapplication->autorestart == NULL)
2708 serviceapplication->autorestart = strdup("false");
2710 serviceapplication->autorestart = strdup("false");
2713 depth = xmlTextReaderDepth(reader);
2714 while ((ret = __next_child_element(reader, depth))) {
2715 node = xmlTextReaderConstName(reader);
2717 DBG("xmlTextReaderConstName value is NULL\n");
2721 if (!strcmp(ASCII(node), "label")) {
2722 label_x *label = malloc(sizeof(label_x));
2723 if (label == NULL) {
2724 DBG("Malloc Failed\n");
2727 memset(label, '\0', sizeof(label_x));
2728 LISTADD(serviceapplication->label, label);
2729 ret = __ps_process_label(reader, label);
2730 } else if (!strcmp(ASCII(node), "icon")) {
2731 icon_x *icon = malloc(sizeof(icon_x));
2733 DBG("Malloc Failed\n");
2736 memset(icon, '\0', sizeof(icon_x));
2737 LISTADD(serviceapplication->icon, icon);
2738 ret = __ps_process_icon(reader, icon);
2739 } else if (!strcmp(ASCII(node), "category")) {
2740 category_x *category = malloc(sizeof(category_x));
2741 if (category == NULL) {
2742 DBG("Malloc Failed\n");
2745 memset(category, '\0', sizeof(category_x));
2746 LISTADD(serviceapplication->category, category);
2747 ret = __ps_process_category(reader, category);
2748 } else if (!strcmp(ASCII(node), "metadata")) {
2749 metadata_x *metadata = malloc(sizeof(metadata_x));
2750 if (metadata == NULL) {
2751 DBG("Malloc Failed\n");
2754 memset(metadata, '\0', sizeof(metadata_x));
2755 LISTADD(serviceapplication->metadata, metadata);
2756 ret = __ps_process_metadata(reader, metadata);
2757 } else if (!strcmp(ASCII(node), "permission")) {
2758 permission_x *permission = malloc(sizeof(permission_x));
2759 if (permission == NULL) {
2760 DBG("Malloc Failed\n");
2763 memset(permission, '\0', sizeof(permission_x));
2764 LISTADD(serviceapplication->permission, permission);
2765 ret = __ps_process_permission(reader, permission);
2766 } else if (!strcmp(ASCII(node), "app-control")) {
2767 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
2768 if (appcontrol == NULL) {
2769 DBG("Malloc Failed\n");
2772 memset(appcontrol, '\0', sizeof(appcontrol_x));
2773 LISTADD(serviceapplication->appcontrol, appcontrol);
2774 ret = __ps_process_appcontrol(reader, appcontrol);
2775 } else if (!strcmp(ASCII(node), "application-service")) {
2776 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
2777 if (appsvc == NULL) {
2778 DBG("Malloc Failed\n");
2781 memset(appsvc, '\0', sizeof(appsvc_x));
2782 LISTADD(serviceapplication->appsvc, appsvc);
2783 ret = __ps_process_appsvc(reader, appsvc);
2784 } else if (!strcmp(ASCII(node), "data-share")) {
2785 datashare_x *datashare = malloc(sizeof(datashare_x));
2786 if (datashare == NULL) {
2787 DBG("Malloc Failed\n");
2790 memset(datashare, '\0', sizeof(datashare_x));
2791 LISTADD(serviceapplication->datashare, datashare);
2792 ret = __ps_process_datashare(reader, datashare);
2793 } else if (!strcmp(ASCII(node), "launch-conditions")) {
2794 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
2795 if (launchconditions == NULL) {
2796 DBG("Malloc Failed\n");
2799 memset(launchconditions, '\0', sizeof(launchconditions_x));
2800 LISTADD(serviceapplication->launchconditions, launchconditions);
2801 ret = __ps_process_launchconditions(reader, launchconditions);
2802 } else if (!strcmp(ASCII(node), "notification")) {
2803 notification_x *notification = malloc(sizeof(notification_x));
2804 if (notification == NULL) {
2805 DBG("Malloc Failed\n");
2808 memset(notification, '\0', sizeof(notification_x));
2809 LISTADD(serviceapplication->notification, notification);
2810 ret = __ps_process_notification(reader, notification);
2811 } else if (!strcmp(ASCII(node), "data-control")) {
2812 datacontrol_x *datacontrol = malloc(sizeof(datacontrol_x));
2813 if (datacontrol == NULL) {
2814 DBG("Malloc Failed\n");
2817 memset(datacontrol, '\0', sizeof(datacontrol_x));
2818 LISTADD(serviceapplication->datacontrol, datacontrol);
2819 ret = __ps_process_datacontrol(reader, datacontrol);
2823 DBG("Processing serviceapplication failed\n");
2828 if (serviceapplication->label) {
2829 LISTHEAD(serviceapplication->label, tmp1);
2830 serviceapplication->label = tmp1;
2832 if (serviceapplication->icon) {
2833 LISTHEAD(serviceapplication->icon, tmp2);
2834 serviceapplication->icon = tmp2;
2836 if (serviceapplication->appsvc) {
2837 LISTHEAD(serviceapplication->appsvc, tmp3);
2838 serviceapplication->appsvc = tmp3;
2840 if (serviceapplication->appcontrol) {
2841 LISTHEAD(serviceapplication->appcontrol, tmp4);
2842 serviceapplication->appcontrol = tmp4;
2844 if (serviceapplication->datacontrol) {
2845 LISTHEAD(serviceapplication->datacontrol, tmp5);
2846 serviceapplication->datacontrol = tmp5;
2848 if (serviceapplication->launchconditions) {
2849 LISTHEAD(serviceapplication->launchconditions, tmp6);
2850 serviceapplication->launchconditions = tmp6;
2852 if (serviceapplication->notification) {
2853 LISTHEAD(serviceapplication->notification, tmp7);
2854 serviceapplication->notification = tmp7;
2856 if (serviceapplication->datashare) {
2857 LISTHEAD(serviceapplication->datashare, tmp8);
2858 serviceapplication->datashare = tmp8;
2860 if (serviceapplication->category) {
2861 LISTHEAD(serviceapplication->category, tmp9);
2862 serviceapplication->category = tmp9;
2864 if (serviceapplication->metadata) {
2865 LISTHEAD(serviceapplication->metadata, tmp10);
2866 serviceapplication->metadata = tmp10;
2868 if (serviceapplication->permission) {
2869 LISTHEAD(serviceapplication->permission, tmp11);
2870 serviceapplication->permission = tmp11;
2876 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile)
2878 /*TODO: once policy is set*/
2882 static int __ps_process_font(xmlTextReaderPtr reader, font_x *font)
2884 /*TODO: once policy is set*/
2888 static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme)
2890 /*TODO: once policy is set*/
2894 static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon)
2896 /*TODO: once policy is set*/
2900 static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime)
2902 /*TODO: once policy is set*/
2906 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx)
2908 DBG("__start_process\n");
2909 const xmlChar *node;
2912 label_x *tmp1 = NULL;
2913 author_x *tmp2 = NULL;
2914 description_x *tmp3 = NULL;
2915 license_x *tmp4 = NULL;
2916 uiapplication_x *tmp5 = NULL;
2917 serviceapplication_x *tmp6 = NULL;
2918 daemon_x *tmp7 = NULL;
2919 theme_x *tmp8 = NULL;
2920 font_x *tmp9 = NULL;
2921 ime_x *tmp10 = NULL;
2922 icon_x *tmp11 = NULL;
2923 compatibility_x *tmp12 = NULL;
2924 deviceprofile_x *tmp13 = NULL;
2926 depth = xmlTextReaderDepth(reader);
2927 while ((ret = __next_child_element(reader, depth))) {
2928 node = xmlTextReaderConstName(reader);
2930 DBG("xmlTextReaderConstName value is NULL\n");
2934 if (!strcmp(ASCII(node), "label")) {
2935 label_x *label = malloc(sizeof(label_x));
2936 if (label == NULL) {
2937 DBG("Malloc Failed\n");
2940 memset(label, '\0', sizeof(label_x));
2941 LISTADD(mfx->label, label);
2942 ret = __ps_process_label(reader, label);
2943 } else if (!strcmp(ASCII(node), "author")) {
2944 author_x *author = malloc(sizeof(author_x));
2945 if (author == NULL) {
2946 DBG("Malloc Failed\n");
2949 memset(author, '\0', sizeof(author_x));
2950 LISTADD(mfx->author, author);
2951 ret = __ps_process_author(reader, author);
2952 } else if (!strcmp(ASCII(node), "description")) {
2953 description_x *description = malloc(sizeof(description_x));
2954 if (description == NULL) {
2955 DBG("Malloc Failed\n");
2958 memset(description, '\0', sizeof(description_x));
2959 LISTADD(mfx->description, description);
2960 ret = __ps_process_description(reader, description);
2961 } else if (!strcmp(ASCII(node), "license")) {
2962 license_x *license = malloc(sizeof(license_x));
2963 if (license == NULL) {
2964 DBG("Malloc Failed\n");
2967 memset(license, '\0', sizeof(license_x));
2968 LISTADD(mfx->license, license);
2969 ret = __ps_process_license(reader, license);
2970 } else if (!strcmp(ASCII(node), "ui-application")) {
2971 uiapplication_x *uiapplication = malloc(sizeof(uiapplication_x));
2972 if (uiapplication == NULL) {
2973 DBG("Malloc Failed\n");
2976 memset(uiapplication, '\0', sizeof(uiapplication_x));
2977 LISTADD(mfx->uiapplication, uiapplication);
2978 ret = __ps_process_uiapplication(reader, uiapplication);
2979 } else if (!strcmp(ASCII(node), "service-application")) {
2980 serviceapplication_x *serviceapplication = malloc(sizeof(serviceapplication_x));
2981 if (serviceapplication == NULL) {
2982 DBG("Malloc Failed\n");
2985 memset(serviceapplication, '\0', sizeof(serviceapplication_x));
2986 LISTADD(mfx->serviceapplication, serviceapplication);
2987 ret = __ps_process_serviceapplication(reader, serviceapplication);
2988 } else if (!strcmp(ASCII(node), "daemon")) {
2989 daemon_x *daemon = malloc(sizeof(daemon_x));
2990 if (daemon == NULL) {
2991 DBG("Malloc Failed\n");
2994 memset(daemon, '\0', sizeof(daemon_x));
2995 LISTADD(mfx->daemon, daemon);
2996 ret = __ps_process_daemon(reader, daemon);
2997 } else if (!strcmp(ASCII(node), "theme")) {
2998 theme_x *theme = malloc(sizeof(theme_x));
2999 if (theme == NULL) {
3000 DBG("Malloc Failed\n");
3003 memset(theme, '\0', sizeof(theme_x));
3004 LISTADD(mfx->theme, theme);
3005 ret = __ps_process_theme(reader, theme);
3006 } else if (!strcmp(ASCII(node), "font")) {
3007 font_x *font = malloc(sizeof(font_x));
3009 DBG("Malloc Failed\n");
3012 memset(font, '\0', sizeof(font_x));
3013 LISTADD(mfx->font, font);
3014 ret = __ps_process_font(reader, font);
3015 } else if (!strcmp(ASCII(node), "ime")) {
3016 ime_x *ime = malloc(sizeof(ime_x));
3018 DBG("Malloc Failed\n");
3021 memset(ime, '\0', sizeof(ime_x));
3022 LISTADD(mfx->ime, ime);
3023 ret = __ps_process_ime(reader, ime);
3024 } else if (!strcmp(ASCII(node), "icon")) {
3025 icon_x *icon = malloc(sizeof(icon_x));
3027 DBG("Malloc Failed\n");
3030 memset(icon, '\0', sizeof(icon_x));
3031 LISTADD(mfx->icon, icon);
3032 ret = __ps_process_icon(reader, icon);
3033 } else if (!strcmp(ASCII(node), "device-profile")) {
3034 deviceprofile_x *deviceprofile = malloc(sizeof(deviceprofile_x));
3035 if (deviceprofile == NULL) {
3036 DBG("Malloc Failed\n");
3039 memset(deviceprofile, '\0', sizeof(deviceprofile_x));
3040 LISTADD(mfx->deviceprofile, deviceprofile);
3041 ret = __ps_process_deviceprofile(reader, deviceprofile);
3042 } else if (!strcmp(ASCII(node), "compatibility")) {
3043 compatibility_x *compatibility = malloc(sizeof(compatibility_x));
3044 if (compatibility == NULL) {
3045 DBG("Malloc Failed\n");
3048 memset(compatibility, '\0', sizeof(compatibility_x));
3049 LISTADD(mfx->compatibility, compatibility);
3050 ret = __ps_process_compatibility(reader, compatibility);
3051 } else if (!strcmp(ASCII(node), "shortcut-list")) {
3053 } else if (!strcmp(ASCII(node), "livebox")) {
3055 } else if (!strcmp(ASCII(node), "account")) {
3057 } else if (!strcmp(ASCII(node), "notifications")) {
3063 DBG("Processing manifest failed\n");
3068 LISTHEAD(mfx->label, tmp1);
3072 LISTHEAD(mfx->author, tmp2);
3075 if (mfx->description) {
3076 LISTHEAD(mfx->description, tmp3);
3077 mfx->description= tmp3;
3080 LISTHEAD(mfx->license, tmp4);
3083 if (mfx->uiapplication) {
3084 LISTHEAD(mfx->uiapplication, tmp5);
3085 mfx->uiapplication = tmp5;
3087 if (mfx->serviceapplication) {
3088 LISTHEAD(mfx->serviceapplication, tmp6);
3089 mfx->serviceapplication = tmp6;
3092 LISTHEAD(mfx->daemon, tmp7);
3096 LISTHEAD(mfx->theme, tmp8);
3100 LISTHEAD(mfx->font, tmp9);
3104 LISTHEAD(mfx->ime, tmp10);
3108 LISTHEAD(mfx->icon, tmp11);
3111 if (mfx->compatibility) {
3112 LISTHEAD(mfx->compatibility, tmp12);
3113 mfx->compatibility= tmp12;
3115 if (mfx->deviceprofile) {
3116 LISTHEAD(mfx->deviceprofile, tmp13);
3117 mfx->deviceprofile= tmp13;
3123 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx)
3125 const xmlChar *node;
3128 if ((ret = __next_child_element(reader, -1))) {
3129 node = xmlTextReaderConstName(reader);
3131 DBG("xmlTextReaderConstName value is NULL\n");
3135 if (!strcmp(ASCII(node), "manifest")) {
3136 if (xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")))
3137 mfx->ns = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")));
3138 if (xmlTextReaderGetAttribute(reader, XMLCHAR("package"))) {
3139 mfx->package= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("package")));
3140 if (mfx->package == NULL) {
3141 DBG("package cant be NULL\n");
3145 DBG("package field is mandatory\n");
3148 package = mfx->package;
3149 if (xmlTextReaderGetAttribute(reader, XMLCHAR("version")))
3150 mfx->version= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("version")));
3151 /*app2ext needs package size for external installation*/
3152 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
3153 mfx->package_size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
3154 if (xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")))
3155 mfx->installlocation = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")));
3156 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
3157 mfx->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
3158 if (xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")))
3159 mfx->root_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")));
3161 /*Assign default values. If required it will be overwritten in __add_preload_info()*/
3162 mfx->preload = strdup("False");
3163 mfx->removable = strdup("True");
3164 mfx->readonly = strdup("False");
3165 char buf[PKG_STRING_LEN_MAX] = {'\0'};
3167 time_t current_time;
3168 time(¤t_time);
3169 snprintf(buf, PKG_STRING_LEN_MAX - 1, "%d", current_time);
3170 val = strndup(buf, PKG_STRING_LEN_MAX - 1);
3171 mfx->installed_time = val;
3173 ret = __start_process(reader, mfx);
3175 DBG("No Manifest element found\n");
3182 #define DESKTOP_RW_PATH "/opt/share/applications/"
3183 #define DESKTOP_RO_PATH "/usr/share/applications/"
3185 static char* __convert_to_system_locale(const char *mlocale)
3187 if (mlocale == NULL)
3189 char *locale = NULL;
3190 locale = (char *)calloc(1, 6);
3192 DBGE("Malloc Failed\n");
3196 strncpy(locale, mlocale, 2);
3197 strncat(locale, "_", 1);
3198 locale[3] = toupper(mlocale[3]);
3199 locale[4] = toupper(mlocale[4]);
3203 #define LIBAIL_PATH "/usr/lib/libail.so.0"
3205 /* operation_type */
3213 static int __ail_change_info(int op, const char *appid)
3215 void *lib_handle = NULL;
3216 int (*ail_desktop_operation) (const char *);
3220 if ((lib_handle = dlopen(LIBAIL_PATH, RTLD_LAZY)) == NULL) {
3221 DBGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAIL_PATH);
3228 aop = "ail_desktop_add";
3231 aop = "ail_desktop_update";
3234 aop = "ail_desktop_remove";
3241 if ((ail_desktop_operation =
3242 dlsym(lib_handle, aop)) == NULL || dlerror() != NULL) {
3243 DBGE("can not find symbol \n");
3247 ret = ail_desktop_operation(appid);
3251 dlclose(lib_handle);
3257 /* desktop shoud be generated automatically based on manifest */
3258 /* Currently removable, taskmanage, etc fields are not considerd. it will be decided soon.*/
3259 #define BUFMAX 1024*128
3260 static int __ps_make_nativeapp_desktop(manifest_x * mfx, bool is_update)
3264 char filepath[PKG_STRING_LEN_MAX] = "";
3266 char *buftemp = NULL;
3267 char *locale = NULL;
3269 buf = (char *)calloc(1, BUFMAX);
3271 DBGE("Malloc Failed\n");
3275 buftemp = (char *)calloc(1, BUFMAX);
3277 DBGE("Malloc Failed\n");
3282 for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) {
3284 if(mfx->readonly && !strcasecmp(mfx->readonly, "True"))
3285 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RO_PATH, mfx->uiapplication->appid);
3287 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, mfx->uiapplication->appid);
3289 /* skip if desktop exists
3290 if (access(filepath, R_OK) == 0)
3294 file = fopen(filepath, "w");
3297 DBGE("Can't open %s", filepath);
3303 snprintf(buf, BUFMAX, "[Desktop Entry]\n");
3304 fwrite(buf, 1, strlen(buf), file);
3306 for( ; mfx->uiapplication->label ; mfx->uiapplication->label = mfx->uiapplication->label->next) {
3307 if(!strcmp(mfx->uiapplication->label->lang, DEFAULT_LOCALE)) {
3308 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
3310 locale = __convert_to_system_locale(mfx->uiapplication->label->lang);
3311 snprintf(buf, BUFMAX, "Name[%s]=%s\n", locale,
3312 mfx->uiapplication->label->text);
3315 fwrite(buf, 1, strlen(buf), file);
3318 if(mfx->uiapplication->label && mfx->uiapplication->label->text) {
3319 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
3320 fwrite(buf, 1, strlen(buf), file);
3323 else if(mfx->label && mfx->label->text) {
3324 snprintf(buf, BUFMAX, "Name=%s\n", mfx->label->text);
3325 fwrite(buf, 1, strlen(buf), file);
3327 snprintf(buf, BUFMAX, "Name=%s\n", mfx->package);
3328 fwrite(buf, 1, strlen(buf), file);
3333 snprintf(buf, BUFMAX, "Type=Application\n");
3334 fwrite(buf, 1, strlen(buf), file);
3336 if(mfx->uiapplication->exec) {
3337 snprintf(buf, BUFMAX, "Exec=%s\n", mfx->uiapplication->exec);
3338 fwrite(buf, 1, strlen(buf), file);
3341 if(mfx->uiapplication->icon && mfx->uiapplication->icon->text) {
3342 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->uiapplication->icon->text);
3343 fwrite(buf, 1, strlen(buf), file);
3344 } else if(mfx->icon && mfx->icon->text) {
3345 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->icon->text);
3346 fwrite(buf, 1, strlen(buf), file);
3350 snprintf(buf, BUFMAX, "Version=%s\n", mfx->version);
3351 fwrite(buf, 1, strlen(buf), file);
3354 if(mfx->uiapplication->nodisplay) {
3355 snprintf(buf, BUFMAX, "NoDisplay=%s\n", mfx->uiapplication->nodisplay);
3356 fwrite(buf, 1, strlen(buf), file);
3359 if(mfx->uiapplication->categories) {
3360 snprintf(buf, BUFMAX, "Categories=%s\n", mfx->uiapplication->categories);
3361 fwrite(buf, 1, strlen(buf), file);
3364 if(mfx->uiapplication->taskmanage && !strcasecmp(mfx->uiapplication->taskmanage, "False")) {
3365 snprintf(buf, BUFMAX, "X-TIZEN-TaskManage=False\n");
3366 fwrite(buf, 1, strlen(buf), file);
3369 if(mfx->uiapplication->enabled && !strcasecmp(mfx->uiapplication->enabled, "False")) {
3370 snprintf(buf, BUFMAX, "X-TIZEN-Enabled=False\n");
3371 fwrite(buf, 1, strlen(buf), file);
3374 if(mfx->uiapplication->hwacceleration) {
3375 snprintf(buf, BUFMAX, "Hw-Acceleration=%s\n", mfx->uiapplication->hwacceleration);
3376 fwrite(buf, 1, strlen(buf), file);
3379 if(mfx->uiapplication->multiple && !strcasecmp(mfx->uiapplication->multiple, "True")) {
3380 snprintf(buf, BUFMAX, "X-TIZEN-Multiple=True\n");
3381 fwrite(buf, 1, strlen(buf), file);
3384 if(mfx->uiapplication->extraid) {
3385 snprintf(buf, BUFMAX, "X-TIZEN-PackageID=%s\n", mfx->uiapplication->extraid);
3386 fwrite(buf, 1, strlen(buf), file);
3389 if(mfx->removable && !strcasecmp(mfx->removable, "False")) {
3390 snprintf(buf, BUFMAX, "X-TIZEN-Removable=False\n");
3391 fwrite(buf, 1, strlen(buf), file);
3395 snprintf(buf, BUFMAX, "X-TIZEN-PackageType=%s\n", mfx->type);
3396 fwrite(buf, 1, strlen(buf), file);
3399 snprintf(buf, BUFMAX, "X-TIZEN-PkgID=%s\n", mfx->package);
3400 fwrite(buf, 1, strlen(buf), file);
3403 // snprintf(buf, BUFMAX, "X-TIZEN-PackageType=rpm\n");
3404 // fwrite(buf, 1, strlen(buf), file);
3407 if(mfx->uiapplication->appsvc) {
3408 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
3409 DBG("buf[%s]\n", buf);
3412 uiapplication_x *up = mfx->uiapplication;
3413 appsvc_x *asvc = NULL;
3414 operation_x *op = NULL;
3417 subapp_x *sub = NULL;
3419 char query[PKG_STRING_LEN_MAX] = {'\0'};
3420 char *operation = NULL;
3423 char *subapp = NULL;
3430 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;
3500 char query[PKG_STRING_LEN_MAX] = {'\0'};
3501 char *operation = NULL;
3504 char *subapp = NULL;
3507 acontrol = up->appcontrol;
3508 while(acontrol != NULL)
3510 op = acontrol->operation;
3514 operation = op->name;
3515 mi = acontrol->mime;
3521 sub = acontrol->subapp;
3533 strncpy(buftemp, buf, BUFMAX);
3534 snprintf(buf, BUFMAX, "%s;", buftemp);
3537 strncpy(buftemp, buf, BUFMAX);
3538 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
3539 DBG("buf[%s]\n", buf);
3544 } while(ui != NULL);
3548 }while(sub != NULL);
3557 acontrol = acontrol->next;
3561 fwrite(buf, 1, strlen(buf), file);
3563 // strncpy(buftemp, buf, BUFMAX);
3564 // snprintf(buf, BUFMAX, "%s\n", buftemp);
3565 // fwrite(buf, 1, strlen(buf), file);
3574 __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid);
3576 __ail_change_info(AIL_UPDATE, mfx->uiapplication->appid);
3585 static int __ps_remove_nativeapp_desktop(manifest_x *mfx)
3587 char filepath[PKG_STRING_LEN_MAX] = "";
3590 for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) {
3591 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, mfx->uiapplication->appid);
3593 __ail_change_info(AIL_REMOVE, mfx->uiapplication->appid);
3595 ret = remove(filepath);
3603 #define MANIFEST_RO_PREFIX "/usr/share/packages/"
3604 #define PRELOAD_PACKAGE_LIST "/usr/etc/package-manager/preload/preload_list.txt"
3605 static int __add_preload_info(manifest_x * mfx, const char *manifest)
3608 char buffer[1024] = { 0 };
3611 if(strstr(manifest, MANIFEST_RO_PREFIX)) {
3612 free(mfx->readonly);
3613 mfx->readonly = strdup("True");
3616 mfx->preload = strdup("True");
3618 free(mfx->removable);
3619 mfx->removable = strdup("False");
3624 fp = fopen(PRELOAD_PACKAGE_LIST, "r");
3626 DBGE("no preload list\n");
3630 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
3631 if (buffer[0] == '#') {
3632 if(strcasestr(buffer, "RW_NORM"))
3634 else if(strcasestr(buffer, "RW_RM"))
3642 if(!strcmp(mfx->package, buffer)) {
3644 mfx->preload = strdup("True");
3646 free(mfx->readonly);
3647 mfx->readonly = strdup("False");
3648 free(mfx->removable);
3649 mfx->removable = strdup("False");
3650 } else if(state == 3){
3651 free(mfx->readonly);
3652 mfx->readonly = strdup("False");
3653 free(mfx->removable);
3654 mfx->removable = strdup("True");
3658 memset(buffer, 0x00, sizeof(buffer));
3668 API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
3673 free((void *)mfx->ns);
3677 free((void *)mfx->package);
3678 mfx->package = NULL;
3681 free((void *)mfx->version);
3682 mfx->version = NULL;
3684 if (mfx->installlocation) {
3685 free((void *)mfx->installlocation);
3686 mfx->installlocation = NULL;
3689 free((void *)mfx->preload);
3690 mfx->preload = NULL;
3692 if (mfx->readonly) {
3693 free((void *)mfx->readonly);
3694 mfx->readonly = NULL;
3696 if (mfx->removable) {
3697 free((void *)mfx->removable);
3698 mfx->removable = NULL;
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->storeclient_id) {
3713 free((void *)mfx->storeclient_id);
3714 mfx->storeclient_id = NULL;
3716 if (mfx->mainapp_id) {
3717 free((void *)mfx->mainapp_id);
3718 mfx->mainapp_id = NULL;
3720 if (mfx->package_url) {
3721 free((void *)mfx->package_url);
3722 mfx->package_url = NULL;
3724 if (mfx->root_path) {
3725 free((void *)mfx->root_path);
3726 mfx->root_path = NULL;
3731 icon_x *icon = mfx->icon;
3736 __ps_free_icon(icon);
3742 label_x *label = mfx->label;
3743 label_x *tmp = NULL;
3744 while(label != NULL)
3747 __ps_free_label(label);
3753 author_x *author = mfx->author;
3754 author_x *tmp = NULL;
3755 while(author != NULL)
3758 __ps_free_author(author);
3762 /*Free Description*/
3763 if (mfx->description) {
3764 description_x *description = mfx->description;
3765 description_x *tmp = NULL;
3766 while(description != NULL)
3768 tmp = description->next;
3769 __ps_free_description(description);
3775 license_x *license = mfx->license;
3776 license_x *tmp = NULL;
3777 while(license != NULL)
3779 tmp = license->next;
3780 __ps_free_license(license);
3784 /*Free UiApplication*/
3785 if (mfx->uiapplication) {
3786 uiapplication_x *uiapplication = mfx->uiapplication;
3787 uiapplication_x *tmp = NULL;
3788 while(uiapplication != NULL)
3790 tmp = uiapplication->next;
3791 __ps_free_uiapplication(uiapplication);
3792 uiapplication = tmp;
3795 /*Free ServiceApplication*/
3796 if (mfx->serviceapplication) {
3797 serviceapplication_x *serviceapplication = mfx->serviceapplication;
3798 serviceapplication_x *tmp = NULL;
3799 while(serviceapplication != NULL)
3801 tmp = serviceapplication->next;
3802 __ps_free_serviceapplication(serviceapplication);
3803 serviceapplication = tmp;
3808 daemon_x *daemon = mfx->daemon;
3809 daemon_x *tmp = NULL;
3810 while(daemon != NULL)
3813 __ps_free_daemon(daemon);
3819 theme_x *theme = mfx->theme;
3820 theme_x *tmp = NULL;
3821 while(theme != NULL)
3824 __ps_free_theme(theme);
3830 font_x *font = mfx->font;
3835 __ps_free_font(font);
3841 ime_x *ime = mfx->ime;
3850 /*Free Compatibility*/
3851 if (mfx->compatibility) {
3852 compatibility_x *compatibility = mfx->compatibility;
3853 compatibility_x *tmp = NULL;
3854 while(compatibility != NULL)
3856 tmp = compatibility->next;
3857 __ps_free_compatibility(compatibility);
3858 compatibility = tmp;
3861 /*Free DeviceProfile*/
3862 if (mfx->deviceprofile) {
3863 deviceprofile_x *deviceprofile = mfx->deviceprofile;
3864 deviceprofile_x *tmp = NULL;
3865 while(deviceprofile != NULL)
3867 tmp = deviceprofile->next;
3868 __ps_free_deviceprofile(deviceprofile);
3869 deviceprofile = tmp;
3877 API manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest)
3879 DBG("parsing start\n");
3880 xmlTextReaderPtr reader;
3881 manifest_x *mfx = NULL;
3883 reader = xmlReaderForFile(manifest, NULL, 0);
3885 mfx = malloc(sizeof(manifest_x));
3887 memset(mfx, '\0', sizeof(manifest_x));
3888 if (__process_manifest(reader, mfx) < 0) {
3889 DBG("Parsing Failed\n");
3890 pkgmgr_parser_free_manifest_xml(mfx);
3893 DBG("Parsing Success\n");
3895 DBG("Memory allocation error\n");
3897 xmlFreeTextReader(reader);
3899 DBG("Unable to create xml reader\n");
3904 /* These APIs are intended to call parser directly */
3906 API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
3908 char *temp[] = {"shortcut-list", "livebox", "account", "notifications", NULL};
3909 if (manifest == NULL) {
3910 DBG("argument supplied is NULL\n");
3911 return PMINFO_R_EINVAL;
3913 DBG("parsing manifest for installation: %s\n", manifest);
3914 manifest_x *mfx = NULL;
3917 mfx = pkgmgr_parser_process_manifest_xml(manifest);
3918 DBG("Parsing Finished\n");
3920 return PMINFO_R_ERROR;
3922 __streamFile(manifest, ACTION_INSTALL, temp, mfx->package);
3923 __add_preload_info(mfx, manifest);
3924 DBG("Added preload infomation\n");
3925 ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
3927 DBG("DB Insert failed\n");
3929 DBG("DB Insert Success\n");
3931 ret = __ps_make_nativeapp_desktop(mfx, 0);
3933 DBG("Creating desktop file failed\n");
3935 DBG("Creating desktop file Success\n");
3937 pkgmgr_parser_free_manifest_xml(mfx);
3944 API int pkgmgr_parser_create_desktop_file(manifest_x *mfx)
3948 DBG("Manifest pointer is NULL\n");
3951 ret = __ps_make_nativeapp_desktop(mfx, 0);
3953 DBG("Creating desktop file failed\n");
3955 DBG("Creating desktop file Success\n");
3960 API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
3962 char *temp[] = {"shortcut-list", "livebox", "account", "notifications", NULL};
3963 if (manifest == NULL) {
3964 DBG("argument supplied is NULL\n");
3965 return PMINFO_R_EINVAL;
3967 DBG("parsing manifest for upgradation: %s\n", manifest);
3968 manifest_x *mfx = NULL;
3971 mfx = pkgmgr_parser_process_manifest_xml(manifest);
3972 DBG("Parsing Finished\n");
3974 return PMINFO_R_ERROR;
3976 __streamFile(manifest, ACTION_UPGRADE, temp, mfx->package);
3977 __add_preload_info(mfx, manifest);
3978 DBG("Added preload infomation\n");
3979 ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
3981 DBG("DB Update failed\n");
3983 DBG("DB Update Success\n");
3985 ret = __ps_make_nativeapp_desktop(mfx, 1);
3987 DBG("Creating desktop file failed\n");
3989 DBG("Creating desktop file Success\n");
3991 pkgmgr_parser_free_manifest_xml(mfx);
3998 API int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[])
4000 char *temp[] = {"shortcut-list", "livebox", "account", "notifications", NULL};
4001 if (manifest == NULL) {
4002 DBG("argument supplied is NULL\n");
4003 return PMINFO_R_EINVAL;
4005 DBG("parsing manifest for uninstallation: %s\n", manifest);
4006 manifest_x *mfx = NULL;
4009 mfx = pkgmgr_parser_process_manifest_xml(manifest);
4010 DBG("Parsing Finished\n");
4012 return PMINFO_R_ERROR;
4014 __streamFile(manifest, ACTION_UNINSTALL, temp, mfx->package);
4015 __add_preload_info(mfx, manifest);
4016 DBG("Added preload infomation\n");
4018 ret = pkgmgr_parser_delete_manifest_info_from_db(mfx);
4020 DBG("DB Delete failed\n");
4022 DBG("DB Delete Success\n");
4024 ret = __ps_remove_nativeapp_desktop(mfx);
4026 DBG("Removing desktop file failed\n");
4028 DBG("Removing desktop file Success\n");
4030 pkgmgr_parser_free_manifest_xml(mfx);
4037 API char *pkgmgr_parser_get_manifest_file(const char *pkgid)
4039 return __pkgid_to_manifest(pkgid);
4042 API int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
4044 return __ps_run_parser(docPtr, tag, ACTION_INSTALL, pkgid);
4047 API int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgid)
4049 return __ps_run_parser(docPtr, tag, ACTION_UPGRADE, pkgid);
4052 API int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
4054 return __ps_run_parser(docPtr, tag, ACTION_UNINSTALL, pkgid);
4057 #define SCHEMA_FILE "/usr/etc/package-manager/preload/manifest.xsd"
4059 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
4061 if (manifest == NULL) {
4062 DBGE("manifest file is NULL\n");
4063 return PMINFO_R_EINVAL;
4066 xmlSchemaParserCtxtPtr ctx;
4067 xmlSchemaValidCtxtPtr vctx;
4068 xmlSchemaPtr xschema;
4069 ctx = xmlSchemaNewParserCtxt(SCHEMA_FILE);
4071 DBGE("xmlSchemaNewParserCtxt() Failed\n");
4072 return PMINFO_R_ERROR;
4074 xschema = xmlSchemaParse(ctx);
4075 if (xschema == NULL) {
4076 DBGE("xmlSchemaParse() Failed\n");
4077 return PMINFO_R_ERROR;
4079 vctx = xmlSchemaNewValidCtxt(xschema);
4081 DBGE("xmlSchemaNewValidCtxt() Failed\n");
4082 return PMINFO_R_ERROR;
4084 xmlSchemaSetValidErrors(vctx, (xmlSchemaValidityErrorFunc) fprintf, (xmlSchemaValidityWarningFunc) fprintf, stderr);
4085 ret = xmlSchemaValidateFile(vctx, manifest, 0);
4087 DBGE("xmlSchemaValidateFile() failed\n");
4088 return PMINFO_R_ERROR;
4089 } else if (ret == 0) {
4090 DBGE("Manifest is Valid\n");
4093 DBGE("Manifest Validation Failed with error code %d\n", ret);
4094 return PMINFO_R_ERROR;
4100 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
4110 DBGE("fork failed\n");
4115 int dev_null_fd = open ("/dev/null", O_RDWR);
4116 if (dev_null_fd >= 0)
4118 dup2 (dev_null_fd, 0);/*stdin*/
4119 dup2 (dev_null_fd, 1);/*stdout*/
4120 dup2 (dev_null_fd, 2);/*stderr*/
4123 if (execl("/usr/bin/xmllint", "xmllint", manifest, "--schema",
4124 SCHEMA_FILE, NULL) < 0) {
4125 DBGE("execl error\n");
4135 while ((err = waitpid(pid, &status, WNOHANG)) != pid) {
4139 DBGE("waitpid failed\n");
4145 if(WIFEXITED(status) && !WEXITSTATUS(status))