4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
7 * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
31 #include <libxml/parser.h>
32 #include <libxml/xmlreader.h>
33 #include <libxml/xmlschemas.h>
37 #include "pkgmgr_parser.h"
38 #include "pkgmgr_parser_internal.h"
39 #include "pkgmgr_parser_db.h"
40 #include "pkgmgr-info.h"
42 #define MANIFEST_RW_DIRECTORY "/opt/share/packages"
43 #define MANIFEST_RO_DIRECTORY "/usr/share/packages"
44 #define ASCII(s) (const char *)s
45 #define XMLCHAR(s) (const xmlChar *)s
57 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label);
58 static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege);
59 static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privileges);
60 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile);
61 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed);
62 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation);
63 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri);
64 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime);
65 static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp);
66 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition);
67 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notifiation);
68 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category);
69 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata);
70 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission);
71 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility);
72 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution);
73 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request);
74 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define);
75 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc);
76 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions);
77 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare);
78 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon);
79 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author);
80 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description);
81 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability);
82 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license);
83 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol);
84 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol);
85 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication);
86 static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication);
87 static int __ps_process_font(xmlTextReaderPtr reader, font_x *font);
88 static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme);
89 static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon);
90 static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime);
91 static void __ps_free_label(label_x *label);
92 static void __ps_free_privilege(privilege_x *privilege);
93 static void __ps_free_privileges(privileges_x *privileges);
94 static void __ps_free_deviceprofile(deviceprofile_x * deviceprofile);
95 static void __ps_free_allowed(allowed_x *allowed);
96 static void __ps_free_operation(operation_x *operation);
97 static void __ps_free_uri(uri_x *uri);
98 static void __ps_free_mime(mime_x *mime);
99 static void __ps_free_subapp(subapp_x *subapp);
100 static void __ps_free_condition(condition_x *condition);
101 static void __ps_free_notification(notification_x *notifiation);
102 static void __ps_free_category(category_x *category);
103 static void __ps_free_metadata(metadata_x *metadata);
104 static void __ps_free_permission(permission_x *permission);
105 static void __ps_free_compatibility(compatibility_x *compatibility);
106 static void __ps_free_resolution(resolution_x *resolution);
107 static void __ps_free_request(request_x *request);
108 static void __ps_free_define(define_x *define);
109 static void __ps_free_appsvc(appsvc_x *appsvc);
110 static void __ps_free_launchconditions(launchconditions_x *launchconditions);
111 static void __ps_free_datashare(datashare_x *datashare);
112 static void __ps_free_icon(icon_x *icon);
113 static void __ps_free_author(author_x *author);
114 static void __ps_free_description(description_x *description);
115 static void __ps_free_capability(capability_x *capability);
116 static void __ps_free_license(license_x *license);
117 static void __ps_free_appcontrol(appcontrol_x *appcontrol);
118 static void __ps_free_datacontrol(datacontrol_x *datacontrol);
119 static void __ps_free_uiapplication(uiapplication_x *uiapplication);
120 static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication);
121 static void __ps_free_font(font_x *font);
122 static void __ps_free_theme(theme_x *theme);
123 static void __ps_free_daemon(daemon_x *daemon);
124 static void __ps_free_ime(ime_x *ime);
125 static char *__pkgid_to_manifest(const char *pkgid);
126 static int __next_child_element(xmlTextReaderPtr reader, int depth);
127 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx);
128 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx);
129 static void __str_trim(char *input);
130 static char *__get_parser_plugin(const char *type);
131 static int __ps_run_parser(xmlDocPtr docPtr, const char *tag, ACTION_TYPE action, const char *pkgid);
132 static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid);
133 static void __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgid);
134 static void __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid);
135 static int __validate_appid(const char *pkgid, const char *appid, char **newappid);
137 static void __str_trim(char *input)
139 char *trim_str = input;
144 while (*input != 0) {
145 if (!isspace(*input)) {
156 static int __validate_appid(const char *pkgid, const char *appid, char **newappid)
158 if (!pkgid || !appid || !newappid) {
159 DBG("Arg supplied is NULL\n");
162 int pkglen = strlen(pkgid);
163 int applen = strlen(appid);
167 if (strncmp(appid, ".", 1) == 0) {
168 len = pkglen + applen + 1;
169 newapp = calloc(1,len);
170 if (newapp == NULL) {
171 DBG("Malloc failed\n");
174 strncpy(newapp, pkgid, pkglen);
175 strncat(newapp, appid, applen);
176 DBG("new appid is %s\n", newapp);
180 if (applen < pkglen) {
181 DBG("app id is not proper\n");
183 #ifdef _VALIDATE_APPID_
189 if (!strcmp(appid, pkgid)) {
190 DBG("appid is proper\n");
194 else if (strncmp(appid, pkgid, pkglen) == 0) {
195 ptr = strstr(appid, pkgid);
197 if (strncmp(ptr, ".", 1) == 0) {
198 DBG("appid is proper\n");
203 DBG("appid is not proper\n");
205 #ifdef _VALIDATE_APPID_
212 DBG("appid is not proper\n");
214 #ifdef _VALIDATE_APPID_
224 static char *__get_parser_plugin(const char *type)
227 char buffer[1024] = { 0 };
228 char temp_path[1024] = { 0 };
232 DBGE("invalid argument\n");
236 fp = fopen(PKG_PARSER_CONF_PATH, "r");
238 DBGE("no matching backendlib\n");
242 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
243 if (buffer[0] == '#')
248 if ((path = strstr(buffer, PKG_PARSERLIB)) != NULL) {
250 path = path + strlen(PKG_PARSERLIB);
256 memset(buffer, 0x00, 1024);
263 DBGE("no matching backendlib\n");
267 snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
269 return strdup(temp_path);
272 static int __ps_run_parser(xmlDocPtr docPtr, const char *tag,
273 ACTION_TYPE action, const char *pkgid)
275 char *lib_path = NULL;
276 void *lib_handle = NULL;
277 int (*plugin_install) (xmlDocPtr, const char *);
283 ac = "PKGMGR_PARSER_PLUGIN_INSTALL";
286 ac = "PKGMGR_PARSER_PLUGIN_UPGRADE";
288 case ACTION_UNINSTALL:
289 ac = "PKGMGR_PARSER_PLUGIN_UNINSTALL";
295 lib_path = __get_parser_plugin(tag);
300 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
301 DBGE("dlopen is failed lib_path[%s]\n", lib_path);
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)
351 DBG("__run_parser_prestep");
353 if (xmlTextReaderDepth(reader) != 1) {
354 DBGE("Node depth is not 1");
358 if (xmlTextReaderNodeType(reader) != 1) {
359 DBGE("Node type is not 1");
363 const xmlChar *value;
364 name = xmlTextReaderConstName(reader);
366 DBGE("TEST TEST TES\n");
367 name = BAD_CAST "--";
370 value = xmlTextReaderConstValue(reader);
371 DBG("%d %d %s %d %d",
372 xmlTextReaderDepth(reader),
373 xmlTextReaderNodeType(reader),
375 xmlTextReaderIsEmptyElement(reader), xmlTextReaderHasValue(reader));
378 DBG("ConstValue NULL");
380 if (xmlStrlen(value) > 40) {
381 DBG(" %.40s...", value);
387 name = xmlTextReaderConstName(reader);
389 DBGE("TEST TEST TES\n");
390 name = BAD_CAST "--";
393 xmlDocPtr docPtr = xmlTextReaderCurrentDoc(reader);
394 DBG("docPtr->URL %s\n", (char *)docPtr->URL);
395 xmlDocPtr copyDocPtr = xmlCopyDoc(docPtr, 1);
396 if (copyDocPtr == NULL)
398 xmlNode *rootElement = xmlDocGetRootElement(copyDocPtr);
399 if (rootElement == NULL)
401 xmlNode *cur_node = xmlFirstElementChild(rootElement);
402 if (cur_node == NULL)
404 xmlNode *temp = xmlTextReaderExpand(reader);
407 xmlNode *next_node = NULL;
408 while(cur_node != NULL) {
409 if ( (strcmp(ASCII(temp->name), ASCII(cur_node->name)) == 0) &&
410 (temp->line == cur_node->line) ) {
414 next_node = xmlNextElementSibling(cur_node);
415 xmlUnlinkNode(cur_node);
416 xmlFreeNode(cur_node);
417 cur_node = next_node;
420 if (cur_node == NULL)
422 next_node = xmlNextElementSibling(cur_node);
424 cur_node->next = NULL;
425 next_node->prev = NULL;
426 xmlFreeNodeList(next_node);
427 xmlSetTreeDoc(cur_node, copyDocPtr);
429 xmlSetTreeDoc(cur_node, copyDocPtr);
435 DBG("node type: %d, name: %s children->name: %s last->name: %s\n"
436 "parent->name: %s next->name: %s prev->name: %s\n",
437 cur_node->type, cur_node->name,
438 cur_node->children ? cur_node->children->name : "NULL",
439 cur_node->last ? cur_node->last->name : "NULL",
440 cur_node->parent ? cur_node->parent->name : "NULL",
441 cur_node->next ? cur_node->next->name : "NULL",
442 cur_node->prev ? cur_node->prev->name : "NULL");
444 FILE *fp = fopen("/opt/share/test.xml", "a");
445 xmlDocDump(fp, copyDocPtr);
450 ret = __ps_run_parser(copyDocPtr, ASCII(name), action, pkgid);
457 __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgid)
462 switch (xmlTextReaderNodeType(reader)) {
463 case XML_READER_TYPE_END_ELEMENT:
465 // DBG("XML_READER_TYPE_END_ELEMENT");
469 case XML_READER_TYPE_ELEMENT:
471 // Elements without closing tag don't receive
472 // XML_READER_TYPE_END_ELEMENT event.
474 const xmlChar *elementName =
475 xmlTextReaderLocalName(reader);
476 if (elementName == NULL) {
477 // DBG("elementName %s\n", (char *)elementName);
481 const xmlChar *nameSpace =
482 xmlTextReaderConstNamespaceUri(reader);
484 // DBG("nameSpace %s\n", (char *)nameSpace);
487 DBG("XML_READER_TYPE_ELEMENT %s, %s\n",
488 elementName ? elementName : "NULL",
489 nameSpace ? nameSpace : "NULL");
492 DBG("__run_parser_prestep pkgid[%s]\n", pkgid);
493 __run_parser_prestep(reader, action, pkgid);
497 for (tag = tagv[0]; tag; tag = tagv[++i])
498 if (strcmp(tag, ASCII(elementName)) == 0) {
499 DBG("__run_parser_prestep tag[%s] pkgid[%s]\n", tag, pkgid);
500 __run_parser_prestep(reader,
508 case XML_READER_TYPE_TEXT:
509 case XML_READER_TYPE_CDATA:
511 const xmlChar *value = xmlTextReaderConstValue(reader);
513 // DBG("value %s\n", value);
516 const xmlChar *lang = xmlTextReaderConstXmlLang(reader);
518 // DBG("lang\n", lang);
521 /* DBG("XML_READER_TYPE_TEXT %s, %s\n",
522 value ? value : "NULL", lang ? lang : "NULL");
527 // DBG("Ignoring Node of Type: %d", xmlTextReaderNodeType(reader));
533 __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid)
535 xmlTextReaderPtr reader;
539 docPtr = xmlReadFile(filename, NULL, 0);
540 reader = xmlReaderWalker(docPtr);
541 if (reader != NULL) {
542 ret = xmlTextReaderRead(reader);
544 __processNode(reader, action, tagv, pkgid);
545 ret = xmlTextReaderRead(reader);
547 xmlFreeTextReader(reader);
550 DBGE("%s : failed to parse", filename);
553 DBGE("Unable to open %s", filename);
557 static int __next_child_element(xmlTextReaderPtr reader, int depth)
559 int ret = xmlTextReaderRead(reader);
560 int cur = xmlTextReaderDepth(reader);
563 switch (xmlTextReaderNodeType(reader)) {
564 case XML_READER_TYPE_ELEMENT:
565 if (cur == depth + 1)
568 case XML_READER_TYPE_TEXT:
569 /*text is handled by each function separately*/
570 if (cur == depth + 1)
573 case XML_READER_TYPE_END_ELEMENT:
582 ret = xmlTextReaderRead(reader);
583 cur = xmlTextReaderDepth(reader);
588 static void __ps_free_category(category_x *category)
590 if (category == NULL)
592 if (category->name) {
593 free((void *)category->name);
594 category->name = NULL;
596 free((void*)category);
600 static void __ps_free_privilege(privilege_x *privilege)
602 if (privilege == NULL)
604 if (privilege->text) {
605 free((void *)privilege->text);
606 privilege->text = NULL;
608 free((void*)privilege);
612 static void __ps_free_privileges(privileges_x *privileges)
614 if (privileges == NULL)
617 if (privileges->privilege) {
618 privilege_x *privilege = privileges->privilege;
619 privilege_x *tmp = NULL;
620 while(privilege != NULL) {
621 tmp = privilege->next;
622 __ps_free_privilege(privilege);
626 free((void*)privileges);
630 static void __ps_free_metadata(metadata_x *metadata)
632 if (metadata == NULL)
635 free((void *)metadata->key);
636 metadata->key = NULL;
638 if (metadata->value) {
639 free((void *)metadata->value);
640 metadata->value = NULL;
642 free((void*)metadata);
646 static void __ps_free_permission(permission_x *permission)
648 if (permission == NULL)
650 if (permission->type) {
651 free((void *)permission->type);
652 permission->type = NULL;
654 if (permission->value) {
655 free((void *)permission->value);
656 permission->value = NULL;
658 free((void*)permission);
662 static void __ps_free_icon(icon_x *icon)
667 free((void *)icon->text);
671 free((void *)icon->lang);
675 free((void *)icon->name);
679 free((void *)icon->section);
680 icon->section = NULL;
683 free((void *)icon->size);
686 if (icon->resolution) {
687 free((void *)icon->resolution);
688 icon->resolution = NULL;
694 static void __ps_free_image(image_x *image)
699 free((void *)image->text);
703 free((void *)image->lang);
707 free((void *)image->name);
710 if (image->section) {
711 free((void *)image->section);
712 image->section = NULL;
718 static void __ps_free_operation(operation_x *operation)
720 if (operation == NULL)
722 if (operation->text) {
723 free((void *)operation->text);
724 operation->text = NULL;
726 free((void*)operation);
730 static void __ps_free_uri(uri_x *uri)
735 free((void *)uri->text);
742 static void __ps_free_mime(mime_x *mime)
747 free((void *)mime->text);
754 static void __ps_free_subapp(subapp_x *subapp)
759 free((void *)subapp->text);
766 static void __ps_free_condition(condition_x *condition)
768 if (condition == NULL)
770 if (condition->text) {
771 free((void *)condition->text);
772 condition->text = NULL;
774 if (condition->name) {
775 free((void *)condition->name);
776 condition->name = NULL;
778 free((void*)condition);
782 static void __ps_free_notification(notification_x *notification)
784 if (notification == NULL)
786 if (notification->text) {
787 free((void *)notification->text);
788 notification->text = NULL;
790 if (notification->name) {
791 free((void *)notification->name);
792 notification->name = NULL;
794 free((void*)notification);
798 static void __ps_free_compatibility(compatibility_x *compatibility)
800 if (compatibility == NULL)
802 if (compatibility->text) {
803 free((void *)compatibility->text);
804 compatibility->text = NULL;
806 if (compatibility->name) {
807 free((void *)compatibility->name);
808 compatibility->name = NULL;
810 free((void*)compatibility);
811 compatibility = NULL;
814 static void __ps_free_resolution(resolution_x *resolution)
816 if (resolution == NULL)
818 if (resolution->mimetype) {
819 free((void *)resolution->mimetype);
820 resolution->mimetype = NULL;
822 if (resolution->urischeme) {
823 free((void *)resolution->urischeme);
824 resolution->urischeme = NULL;
826 free((void*)resolution);
830 static void __ps_free_capability(capability_x *capability)
832 if (capability == NULL)
834 if (capability->operationid) {
835 free((void *)capability->operationid);
836 capability->operationid = NULL;
839 if (capability->resolution) {
840 resolution_x *resolution = capability->resolution;
841 resolution_x *tmp = NULL;
842 while(resolution != NULL) {
843 tmp = resolution->next;
844 __ps_free_resolution(resolution);
848 free((void*)capability);
852 static void __ps_free_allowed(allowed_x *allowed)
857 free((void *)allowed->name);
858 allowed->name = NULL;
861 free((void *)allowed->text);
862 allowed->text = NULL;
864 free((void*)allowed);
868 static void __ps_free_request(request_x *request)
873 free((void *)request->text);
874 request->text = NULL;
876 free((void*)request);
880 static void __ps_free_datacontrol(datacontrol_x *datacontrol)
882 if (datacontrol == NULL)
884 if (datacontrol->providerid) {
885 free((void *)datacontrol->providerid);
886 datacontrol->providerid = NULL;
889 if (datacontrol->capability) {
890 capability_x *capability = datacontrol->capability;
891 capability_x *tmp = NULL;
892 while(capability != NULL) {
893 tmp = capability->next;
894 __ps_free_capability(capability);
898 free((void*)datacontrol);
902 static void __ps_free_launchconditions(launchconditions_x *launchconditions)
904 if (launchconditions == NULL)
906 if (launchconditions->text) {
907 free((void *)launchconditions->text);
908 launchconditions->text = NULL;
911 if (launchconditions->condition) {
912 condition_x *condition = launchconditions->condition;
913 condition_x *tmp = NULL;
914 while(condition != NULL) {
915 tmp = condition->next;
916 __ps_free_condition(condition);
920 free((void*)launchconditions);
921 launchconditions = NULL;
924 static void __ps_free_appcontrol(appcontrol_x *appcontrol)
926 if (appcontrol == NULL)
928 if (appcontrol->text) {
929 free((void *)appcontrol->text);
930 appcontrol->text = NULL;
933 if (appcontrol->operation) {
934 operation_x *operation = appcontrol->operation;
935 operation_x *tmp = NULL;
936 while(operation != NULL) {
937 tmp = operation->next;
938 __ps_free_operation(operation);
943 if (appcontrol->uri) {
944 uri_x *uri = appcontrol->uri;
953 if (appcontrol->mime) {
954 mime_x *mime = appcontrol->mime;
956 while(mime != NULL) {
958 __ps_free_mime(mime);
963 if (appcontrol->subapp) {
964 subapp_x *subapp = appcontrol->subapp;
965 subapp_x *tmp = NULL;
966 while(subapp != NULL) {
968 __ps_free_subapp(subapp);
972 free((void*)appcontrol);
976 static void __ps_free_appsvc(appsvc_x *appsvc)
981 free((void *)appsvc->text);
985 if (appsvc->operation) {
986 operation_x *operation = appsvc->operation;
987 operation_x *tmp = NULL;
988 while(operation != NULL) {
989 tmp = operation->next;
990 __ps_free_operation(operation);
996 uri_x *uri = appsvc->uri;
1006 mime_x *mime = appsvc->mime;
1008 while(mime != NULL) {
1010 __ps_free_mime(mime);
1015 if (appsvc->subapp) {
1016 subapp_x *subapp = appsvc->subapp;
1017 subapp_x *tmp = NULL;
1018 while(subapp != NULL) {
1020 __ps_free_subapp(subapp);
1024 free((void*)appsvc);
1028 static void __ps_free_deviceprofile(deviceprofile_x *deviceprofile)
1033 static void __ps_free_define(define_x *define)
1038 free((void *)define->path);
1039 define->path = NULL;
1042 if (define->request) {
1043 request_x *request = define->request;
1044 request_x *tmp = NULL;
1045 while(request != NULL) {
1046 tmp = request->next;
1047 __ps_free_request(request);
1052 if (define->allowed) {
1053 allowed_x *allowed = define->allowed;
1054 allowed_x *tmp = NULL;
1055 while(allowed != NULL) {
1056 tmp = allowed->next;
1057 __ps_free_allowed(allowed);
1061 free((void*)define);
1065 static void __ps_free_datashare(datashare_x *datashare)
1067 if (datashare == NULL)
1070 if (datashare->define) {
1071 define_x *define = datashare->define;
1072 define_x *tmp = NULL;
1073 while(define != NULL) {
1075 __ps_free_define(define);
1080 if (datashare->request) {
1081 request_x *request = datashare->request;
1082 request_x *tmp = NULL;
1083 while(request != NULL) {
1084 tmp = request->next;
1085 __ps_free_request(request);
1089 free((void*)datashare);
1093 static void __ps_free_label(label_x *label)
1098 free((void *)label->name);
1102 free((void *)label->text);
1106 free((void *)label->lang);
1113 static void __ps_free_author(author_x *author)
1117 if (author->email) {
1118 free((void *)author->email);
1119 author->email = NULL;
1122 free((void *)author->text);
1123 author->text = NULL;
1126 free((void *)author->href);
1127 author->href = NULL;
1130 free((void *)author->lang);
1131 author->lang = NULL;
1133 free((void*)author);
1137 static void __ps_free_description(description_x *description)
1139 if (description == NULL)
1141 if (description->name) {
1142 free((void *)description->name);
1143 description->name = NULL;
1145 if (description->text) {
1146 free((void *)description->text);
1147 description->text = NULL;
1149 if (description->lang) {
1150 free((void *)description->lang);
1151 description->lang = NULL;
1153 free((void*)description);
1157 static void __ps_free_license(license_x *license)
1159 if (license == NULL)
1161 if (license->text) {
1162 free((void *)license->text);
1163 license->text = NULL;
1165 if (license->lang) {
1166 free((void *)license->lang);
1167 license->lang = NULL;
1169 free((void*)license);
1173 static void __ps_free_uiapplication(uiapplication_x *uiapplication)
1175 if (uiapplication == NULL)
1177 if (uiapplication->exec) {
1178 free((void *)uiapplication->exec);
1179 uiapplication->exec = NULL;
1181 if (uiapplication->appid) {
1182 free((void *)uiapplication->appid);
1183 uiapplication->appid = NULL;
1185 if (uiapplication->nodisplay) {
1186 free((void *)uiapplication->nodisplay);
1187 uiapplication->nodisplay = NULL;
1189 if (uiapplication->multiple) {
1190 free((void *)uiapplication->multiple);
1191 uiapplication->multiple = NULL;
1193 if (uiapplication->type) {
1194 free((void *)uiapplication->type);
1195 uiapplication->type = NULL;
1197 if (uiapplication->categories) {
1198 free((void *)uiapplication->categories);
1199 uiapplication->categories = NULL;
1201 if (uiapplication->extraid) {
1202 free((void *)uiapplication->extraid);
1203 uiapplication->extraid = NULL;
1205 if (uiapplication->taskmanage) {
1206 free((void *)uiapplication->taskmanage);
1207 uiapplication->taskmanage = NULL;
1209 if (uiapplication->enabled) {
1210 free((void *)uiapplication->enabled);
1211 uiapplication->enabled = NULL;
1213 if (uiapplication->hwacceleration) {
1214 free((void *)uiapplication->hwacceleration);
1215 uiapplication->hwacceleration = NULL;
1217 if (uiapplication->mainapp) {
1218 free((void *)uiapplication->mainapp);
1219 uiapplication->mainapp = NULL;
1221 if (uiapplication->recentimage) {
1222 free((void *)uiapplication->recentimage);
1223 uiapplication->recentimage = NULL;
1225 if (uiapplication->package) {
1226 free((void *)uiapplication->package);
1227 uiapplication->package = NULL;
1230 if (uiapplication->label) {
1231 label_x *label = uiapplication->label;
1232 label_x *tmp = NULL;
1233 while(label != NULL) {
1235 __ps_free_label(label);
1240 if (uiapplication->icon) {
1241 icon_x *icon = uiapplication->icon;
1243 while(icon != NULL) {
1245 __ps_free_icon(icon);
1250 if (uiapplication->image) {
1251 image_x *image = uiapplication->image;
1252 image_x *tmp = NULL;
1253 while(image != NULL) {
1255 __ps_free_image(image);
1260 if (uiapplication->appcontrol) {
1261 appcontrol_x *appcontrol = uiapplication->appcontrol;
1262 appcontrol_x *tmp = NULL;
1263 while(appcontrol != NULL) {
1264 tmp = appcontrol->next;
1265 __ps_free_appcontrol(appcontrol);
1269 /*Free LaunchConditions*/
1270 if (uiapplication->launchconditions) {
1271 launchconditions_x *launchconditions = uiapplication->launchconditions;
1272 launchconditions_x *tmp = NULL;
1273 while(launchconditions != NULL) {
1274 tmp = launchconditions->next;
1275 __ps_free_launchconditions(launchconditions);
1276 launchconditions = tmp;
1279 /*Free Notification*/
1280 if (uiapplication->notification) {
1281 notification_x *notification = uiapplication->notification;
1282 notification_x *tmp = NULL;
1283 while(notification != NULL) {
1284 tmp = notification->next;
1285 __ps_free_notification(notification);
1290 if (uiapplication->datashare) {
1291 datashare_x *datashare = uiapplication->datashare;
1292 datashare_x *tmp = NULL;
1293 while(datashare != NULL) {
1294 tmp = datashare->next;
1295 __ps_free_datashare(datashare);
1300 if (uiapplication->appsvc) {
1301 appsvc_x *appsvc = uiapplication->appsvc;
1302 appsvc_x *tmp = NULL;
1303 while(appsvc != NULL) {
1305 __ps_free_appsvc(appsvc);
1310 if (uiapplication->category) {
1311 category_x *category = uiapplication->category;
1312 category_x *tmp = NULL;
1313 while(category != NULL) {
1314 tmp = category->next;
1315 __ps_free_category(category);
1320 if (uiapplication->metadata) {
1321 metadata_x *metadata = uiapplication->metadata;
1322 metadata_x *tmp = NULL;
1323 while(metadata != NULL) {
1324 tmp = metadata->next;
1325 __ps_free_metadata(metadata);
1330 if (uiapplication->permission) {
1331 permission_x *permission = uiapplication->permission;
1332 permission_x *tmp = NULL;
1333 while(permission != NULL) {
1334 tmp = permission->next;
1335 __ps_free_permission(permission);
1339 /* _PRODUCT_LAUNCHING_ENHANCED_ START */
1340 if (uiapplication->indicatordisplay) {
1341 free((void *)uiapplication->indicatordisplay);
1342 uiapplication->indicatordisplay = NULL;
1344 if (uiapplication->portraitimg) {
1345 free((void *)uiapplication->portraitimg);
1346 uiapplication->portraitimg = NULL;
1348 if (uiapplication->landscapeimg) {
1349 free((void *)uiapplication->landscapeimg);
1350 uiapplication->landscapeimg = NULL;
1352 /* _PRODUCT_LAUNCHING_ENHANCED_ END */
1353 if (uiapplication->guestmode_visibility) {
1354 free((void *)uiapplication->guestmode_visibility);
1355 uiapplication->guestmode_visibility = NULL;
1357 free((void*)uiapplication);
1358 uiapplication = NULL;
1361 static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication)
1363 if (serviceapplication == NULL)
1365 if (serviceapplication->exec) {
1366 free((void *)serviceapplication->exec);
1367 serviceapplication->exec = NULL;
1369 if (serviceapplication->appid) {
1370 free((void *)serviceapplication->appid);
1371 serviceapplication->appid = NULL;
1373 if (serviceapplication->onboot) {
1374 free((void *)serviceapplication->onboot);
1375 serviceapplication->onboot = NULL;
1377 if (serviceapplication->autorestart) {
1378 free((void *)serviceapplication->autorestart);
1379 serviceapplication->autorestart = NULL;
1381 if (serviceapplication->type) {
1382 free((void *)serviceapplication->type);
1383 serviceapplication->type = NULL;
1385 if (serviceapplication->enabled) {
1386 free((void *)serviceapplication->enabled);
1387 serviceapplication->enabled = NULL;
1389 if (serviceapplication->package) {
1390 free((void *)serviceapplication->package);
1391 serviceapplication->package = NULL;
1394 if (serviceapplication->label) {
1395 label_x *label = serviceapplication->label;
1396 label_x *tmp = NULL;
1397 while(label != NULL) {
1399 __ps_free_label(label);
1404 if (serviceapplication->icon) {
1405 icon_x *icon = serviceapplication->icon;
1407 while(icon != NULL) {
1409 __ps_free_icon(icon);
1414 if (serviceapplication->appcontrol) {
1415 appcontrol_x *appcontrol = serviceapplication->appcontrol;
1416 appcontrol_x *tmp = NULL;
1417 while(appcontrol != NULL) {
1418 tmp = appcontrol->next;
1419 __ps_free_appcontrol(appcontrol);
1423 /*Free DataControl*/
1424 if (serviceapplication->datacontrol) {
1425 datacontrol_x *datacontrol = serviceapplication->datacontrol;
1426 datacontrol_x *tmp = NULL;
1427 while(datacontrol != NULL) {
1428 tmp = datacontrol->next;
1429 __ps_free_datacontrol(datacontrol);
1433 /*Free LaunchConditions*/
1434 if (serviceapplication->launchconditions) {
1435 launchconditions_x *launchconditions = serviceapplication->launchconditions;
1436 launchconditions_x *tmp = NULL;
1437 while(launchconditions != NULL) {
1438 tmp = launchconditions->next;
1439 __ps_free_launchconditions(launchconditions);
1440 launchconditions = tmp;
1443 /*Free Notification*/
1444 if (serviceapplication->notification) {
1445 notification_x *notification = serviceapplication->notification;
1446 notification_x *tmp = NULL;
1447 while(notification != NULL) {
1448 tmp = notification->next;
1449 __ps_free_notification(notification);
1454 if (serviceapplication->datashare) {
1455 datashare_x *datashare = serviceapplication->datashare;
1456 datashare_x *tmp = NULL;
1457 while(datashare != NULL) {
1458 tmp = datashare->next;
1459 __ps_free_datashare(datashare);
1464 if (serviceapplication->appsvc) {
1465 appsvc_x *appsvc = serviceapplication->appsvc;
1466 appsvc_x *tmp = NULL;
1467 while(appsvc != NULL) {
1469 __ps_free_appsvc(appsvc);
1474 if (serviceapplication->category) {
1475 category_x *category = serviceapplication->category;
1476 category_x *tmp = NULL;
1477 while(category != NULL) {
1478 tmp = category->next;
1479 __ps_free_category(category);
1484 if (serviceapplication->metadata) {
1485 metadata_x *metadata = serviceapplication->metadata;
1486 metadata_x *tmp = NULL;
1487 while(metadata != NULL) {
1488 tmp = metadata->next;
1489 __ps_free_metadata(metadata);
1494 if (serviceapplication->permission) {
1495 permission_x *permission = serviceapplication->permission;
1496 permission_x *tmp = NULL;
1497 while(permission != NULL) {
1498 tmp = permission->next;
1499 __ps_free_permission(permission);
1503 free((void*)serviceapplication);
1504 serviceapplication = NULL;
1507 static void __ps_free_font(font_x *font)
1512 free((void *)font->name);
1516 free((void *)font->text);
1523 static void __ps_free_theme(theme_x *theme)
1528 free((void *)theme->name);
1532 free((void *)theme->text);
1539 static void __ps_free_daemon(daemon_x *daemon)
1544 free((void *)daemon->name);
1545 daemon->name = NULL;
1548 free((void *)daemon->text);
1549 daemon->text = NULL;
1551 free((void*)daemon);
1555 static void __ps_free_ime(ime_x *ime)
1560 free((void *)ime->name);
1564 free((void *)ime->text);
1572 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed)
1574 xmlTextReaderRead(reader);
1575 if (xmlTextReaderValue(reader))
1576 allowed->text = ASCII(xmlTextReaderValue(reader));
1580 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation)
1582 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1583 operation->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1584 /* Text does not exist. Only attribute exists
1585 xmlTextReaderRead(reader);
1586 if (xmlTextReaderValue(reader))
1587 operation->text = ASCII(xmlTextReaderValue(reader));
1592 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri)
1594 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1595 uri->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1596 /* Text does not exist. Only attribute exists
1597 xmlTextReaderRead(reader);
1598 if (xmlTextReaderValue(reader))
1599 uri->text = ASCII(xmlTextReaderValue(reader));
1604 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime)
1606 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1607 mime->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1608 /* Text does not exist. Only attribute exists
1609 xmlTextReaderRead(reader);
1610 if (xmlTextReaderValue(reader))
1611 mime->text = ASCII(xmlTextReaderValue(reader));
1616 static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp)
1618 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1619 subapp->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1620 /* Text does not exist. Only attribute exists
1621 xmlTextReaderRead(reader);
1622 if (xmlTextReaderValue(reader))
1623 mime->text = ASCII(xmlTextReaderValue(reader));
1628 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition)
1630 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1631 condition->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1632 xmlTextReaderRead(reader);
1633 if (xmlTextReaderValue(reader))
1634 condition->text = ASCII(xmlTextReaderValue(reader));
1638 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notification)
1640 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1641 notification->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1642 xmlTextReaderRead(reader);
1643 if (xmlTextReaderValue(reader))
1644 notification->text = ASCII(xmlTextReaderValue(reader));
1648 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category)
1650 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1651 category->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1655 static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege)
1657 xmlTextReaderRead(reader);
1658 if (xmlTextReaderValue(reader)) {
1659 privilege->text = ASCII(xmlTextReaderValue(reader));
1664 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata)
1666 if (xmlTextReaderGetAttribute(reader, XMLCHAR("key")))
1667 metadata->key = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("key")));
1668 if (xmlTextReaderGetAttribute(reader, XMLCHAR("value")))
1669 metadata->value = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("value")));
1673 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission)
1675 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
1676 permission->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
1678 xmlTextReaderRead(reader);
1679 if (xmlTextReaderValue(reader))
1680 permission->value = ASCII(xmlTextReaderValue(reader));
1684 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility)
1686 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1687 compatibility->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1688 xmlTextReaderRead(reader);
1689 if (xmlTextReaderValue(reader))
1690 compatibility->text = ASCII(xmlTextReaderValue(reader));
1694 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution)
1696 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")))
1697 resolution->mimetype = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")));
1698 if (xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")))
1699 resolution->urischeme = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")));
1703 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request)
1705 xmlTextReaderRead(reader);
1706 if (xmlTextReaderValue(reader))
1707 request->text = ASCII(xmlTextReaderValue(reader));
1711 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define)
1713 const xmlChar *node;
1716 allowed_x *tmp1 = NULL;
1717 request_x *tmp2 = NULL;
1719 if (xmlTextReaderGetAttribute(reader, XMLCHAR("path")))
1720 define->path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("path")));
1722 depth = xmlTextReaderDepth(reader);
1723 while ((ret = __next_child_element(reader, depth))) {
1724 node = xmlTextReaderConstName(reader);
1726 DBG("xmlTextReaderConstName value is NULL\n");
1730 if (!strcmp(ASCII(node), "allowed")) {
1731 allowed_x *allowed= malloc(sizeof(allowed_x));
1732 if (allowed == NULL) {
1733 DBG("Malloc Failed\n");
1736 memset(allowed, '\0', sizeof(allowed_x));
1737 LISTADD(define->allowed, allowed);
1738 ret = __ps_process_allowed(reader, allowed);
1739 } else if (!strcmp(ASCII(node), "request")) {
1740 request_x *request = malloc(sizeof(request_x));
1741 if (request == NULL) {
1742 DBG("Malloc Failed\n");
1745 memset(request, '\0', sizeof(request_x));
1746 LISTADD(define->request, request);
1747 ret = __ps_process_request(reader, request);
1751 DBG("Processing define failed\n");
1755 if (define->allowed) {
1756 LISTHEAD(define->allowed, tmp1);
1757 define->allowed = tmp1;
1759 if (define->request) {
1760 LISTHEAD(define->request, tmp2);
1761 define->request = tmp2;
1766 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol)
1768 const xmlChar *node;
1771 operation_x *tmp1 = NULL;
1773 mime_x *tmp3 = NULL;
1774 subapp_x *tmp4 = NULL;
1776 depth = xmlTextReaderDepth(reader);
1777 while ((ret = __next_child_element(reader, depth))) {
1778 node = xmlTextReaderConstName(reader);
1780 DBG("xmlTextReaderConstName value is NULL\n");
1784 if (!strcmp(ASCII(node), "operation")) {
1785 operation_x *operation = malloc(sizeof(operation_x));
1786 if (operation == NULL) {
1787 DBG("Malloc Failed\n");
1790 memset(operation, '\0', sizeof(operation_x));
1791 LISTADD(appcontrol->operation, operation);
1792 ret = __ps_process_operation(reader, operation);
1793 DBG("operation processing\n");
1794 } else if (!strcmp(ASCII(node), "uri")) {
1795 uri_x *uri= malloc(sizeof(uri_x));
1797 DBG("Malloc Failed\n");
1800 memset(uri, '\0', sizeof(uri_x));
1801 LISTADD(appcontrol->uri, uri);
1802 ret = __ps_process_uri(reader, uri);
1803 DBG("uri processing\n");
1804 } else if (!strcmp(ASCII(node), "mime")) {
1805 mime_x *mime = malloc(sizeof(mime_x));
1807 DBG("Malloc Failed\n");
1810 memset(mime, '\0', sizeof(mime_x));
1811 LISTADD(appcontrol->mime, mime);
1812 ret = __ps_process_mime(reader, mime);
1813 DBG("mime processing\n");
1814 } else if (!strcmp(ASCII(node), "subapp")) {
1815 subapp_x *subapp = malloc(sizeof(subapp_x));
1816 if (subapp == NULL) {
1817 DBG("Malloc Failed\n");
1820 memset(subapp, '\0', sizeof(subapp_x));
1821 LISTADD(appcontrol->subapp, subapp);
1822 ret = __ps_process_subapp(reader, subapp);
1823 DBG("subapp processing\n");
1827 DBG("Processing appcontrol failed\n");
1831 if (appcontrol->operation) {
1832 LISTHEAD(appcontrol->operation, tmp1);
1833 appcontrol->operation = tmp1;
1835 if (appcontrol->uri) {
1836 LISTHEAD(appcontrol->uri, tmp2);
1837 appcontrol->uri = tmp2;
1839 if (appcontrol->mime) {
1840 LISTHEAD(appcontrol->mime, tmp3);
1841 appcontrol->mime = tmp3;
1843 if (appcontrol->subapp) {
1844 LISTHEAD(appcontrol->subapp, tmp4);
1845 appcontrol->subapp = tmp4;
1848 xmlTextReaderRead(reader);
1849 if (xmlTextReaderValue(reader))
1850 appcontrol->text = ASCII(xmlTextReaderValue(reader));
1855 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc)
1857 const xmlChar *node;
1860 operation_x *tmp1 = NULL;
1862 mime_x *tmp3 = NULL;
1863 subapp_x *tmp4 = NULL;
1865 depth = xmlTextReaderDepth(reader);
1866 while ((ret = __next_child_element(reader, depth))) {
1867 node = xmlTextReaderConstName(reader);
1869 DBG("xmlTextReaderConstName value is NULL\n");
1873 if (!strcmp(ASCII(node), "operation")) {
1874 operation_x *operation = malloc(sizeof(operation_x));
1875 if (operation == NULL) {
1876 DBG("Malloc Failed\n");
1879 memset(operation, '\0', sizeof(operation_x));
1880 LISTADD(appsvc->operation, operation);
1881 ret = __ps_process_operation(reader, operation);
1882 DBG("operation processing\n");
1883 } else if (!strcmp(ASCII(node), "uri")) {
1884 uri_x *uri= malloc(sizeof(uri_x));
1886 DBG("Malloc Failed\n");
1889 memset(uri, '\0', sizeof(uri_x));
1890 LISTADD(appsvc->uri, uri);
1891 ret = __ps_process_uri(reader, uri);
1892 DBG("uri processing\n");
1893 } else if (!strcmp(ASCII(node), "mime")) {
1894 mime_x *mime = malloc(sizeof(mime_x));
1896 DBG("Malloc Failed\n");
1899 memset(mime, '\0', sizeof(mime_x));
1900 LISTADD(appsvc->mime, mime);
1901 ret = __ps_process_mime(reader, mime);
1902 DBG("mime processing\n");
1903 } else if (!strcmp(ASCII(node), "subapp")) {
1904 subapp_x *subapp = malloc(sizeof(subapp_x));
1905 if (subapp == NULL) {
1906 DBG("Malloc Failed\n");
1909 memset(subapp, '\0', sizeof(subapp_x));
1910 LISTADD(appsvc->subapp, subapp);
1911 ret = __ps_process_subapp(reader, subapp);
1912 DBG("subapp processing\n");
1916 DBG("Processing appsvc failed\n");
1920 if (appsvc->operation) {
1921 LISTHEAD(appsvc->operation, tmp1);
1922 appsvc->operation = tmp1;
1925 LISTHEAD(appsvc->uri, tmp2);
1929 LISTHEAD(appsvc->mime, tmp3);
1930 appsvc->mime = tmp3;
1932 if (appsvc->subapp) {
1933 LISTHEAD(appsvc->subapp, tmp4);
1934 appsvc->subapp = tmp4;
1937 xmlTextReaderRead(reader);
1938 if (xmlTextReaderValue(reader))
1939 appsvc->text = ASCII(xmlTextReaderValue(reader));
1945 static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privileges)
1947 const xmlChar *node;
1950 privilege_x *tmp1 = NULL;
1952 depth = xmlTextReaderDepth(reader);
1953 while ((ret = __next_child_element(reader, depth))) {
1954 node = xmlTextReaderConstName(reader);
1956 DBG("xmlTextReaderConstName value is NULL\n");
1960 if (strcmp(ASCII(node), "privilege") == 0) {
1961 privilege_x *privilege = malloc(sizeof(privilege_x));
1962 if (privilege == NULL) {
1963 DBG("Malloc Failed\n");
1966 memset(privilege, '\0', sizeof(privilege_x));
1967 LISTADD(privileges->privilege, privilege);
1968 ret = __ps_process_privilege(reader, privilege);
1972 DBG("Processing privileges failed\n");
1976 if (privileges->privilege) {
1977 LISTHEAD(privileges->privilege, tmp1);
1978 privileges->privilege = tmp1;
1983 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions)
1985 const xmlChar *node;
1988 condition_x *tmp1 = NULL;
1990 depth = xmlTextReaderDepth(reader);
1991 while ((ret = __next_child_element(reader, depth))) {
1992 node = xmlTextReaderConstName(reader);
1994 DBG("xmlTextReaderConstName value is NULL\n");
1998 if (strcmp(ASCII(node), "condition") == 0) {
1999 condition_x *condition = malloc(sizeof(condition_x));
2000 if (condition == NULL) {
2001 DBG("Malloc Failed\n");
2004 memset(condition, '\0', sizeof(condition_x));
2005 LISTADD(launchconditions->condition, condition);
2006 ret = __ps_process_condition(reader, condition);
2010 DBG("Processing launchconditions failed\n");
2014 if (launchconditions->condition) {
2015 LISTHEAD(launchconditions->condition, tmp1);
2016 launchconditions->condition = tmp1;
2019 xmlTextReaderRead(reader);
2020 if (xmlTextReaderValue(reader))
2021 launchconditions->text = ASCII(xmlTextReaderValue(reader));
2026 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare)
2028 const xmlChar *node;
2031 define_x *tmp1 = NULL;
2032 request_x *tmp2 = NULL;
2033 depth = xmlTextReaderDepth(reader);
2034 while ((ret = __next_child_element(reader, depth))) {
2035 node = xmlTextReaderConstName(reader);
2037 DBG("xmlTextReaderConstName value is NULL\n");
2041 if (!strcmp(ASCII(node), "define")) {
2042 define_x *define= malloc(sizeof(define_x));
2043 if (define == NULL) {
2044 DBG("Malloc Failed\n");
2047 memset(define, '\0', sizeof(define_x));
2048 LISTADD(datashare->define, define);
2049 ret = __ps_process_define(reader, define);
2050 } else if (!strcmp(ASCII(node), "request")) {
2051 request_x *request= malloc(sizeof(request_x));
2052 if (request == NULL) {
2053 DBG("Malloc Failed\n");
2056 memset(request, '\0', sizeof(request_x));
2057 LISTADD(datashare->request, request);
2058 ret = __ps_process_request(reader, request);
2062 DBG("Processing data-share failed\n");
2066 if (datashare->define) {
2067 LISTHEAD(datashare->define, tmp1);
2068 datashare->define = tmp1;
2070 if (datashare->request) {
2071 LISTHEAD(datashare->request, tmp2);
2072 datashare->request = tmp2;
2078 __get_icon_with_path(const char* icon)
2083 if (index(icon, '/') == NULL) {
2085 char* icon_with_path = NULL;
2091 theme = vconf_get_str("db/setting/theme");
2093 theme = strdup("default");
2099 len = (0x01 << 7) + strlen(icon) + strlen(package) + strlen(theme);
2100 icon_with_path = malloc(len);
2101 if(icon_with_path == NULL) {
2102 DBG("(icon_with_path == NULL) return\n");
2107 memset(icon_with_path, 0, len);
2109 snprintf(icon_with_path, len, "/opt/share/icons/%s/small/%s", theme, icon);
2111 if (access(icon_with_path, R_OK) == 0) break;
2112 snprintf(icon_with_path, len, "/usr/share/icons/%s/small/%s", theme, icon);
2113 if (access(icon_with_path, R_OK) == 0) break;
2114 DBG("cannot find icon %s", icon_with_path);
2115 snprintf(icon_with_path, len,"/opt/share/icons/default/small/%s", icon);
2116 if (access(icon_with_path, R_OK) == 0) break;
2117 snprintf(icon_with_path, len, "/usr/share/icons/default/small/%s", icon);
2118 if (access(icon_with_path, R_OK) == 0) break;
2120 /* icon path is going to be moved intto the app directory */
2121 DBGE("icon file must be moved to %s", icon_with_path);
2122 snprintf(icon_with_path, len, "/opt/apps/%s/res/icons/%s/small/%s", package, theme, icon);
2123 if (access(icon_with_path, R_OK) == 0) break;
2124 snprintf(icon_with_path, len, "/usr/apps/%s/res/icons/%s/small/%s", package, theme, icon);
2125 if (access(icon_with_path, R_OK) == 0) break;
2126 DBG("cannot find icon %s", icon_with_path);
2127 snprintf(icon_with_path, len, "/opt/apps/%s/res/icons/default/small/%s", package, icon);
2128 if (access(icon_with_path, R_OK) == 0) break;
2129 snprintf(icon_with_path, len, "/usr/apps/%s/res/icons/default/small/%s", package, icon);
2130 if (access(icon_with_path, R_OK) == 0) break;
2135 DBG("Icon path : %s ---> %s", icon, icon_with_path);
2137 return icon_with_path;
2139 char* confirmed_icon = NULL;
2141 confirmed_icon = strdup(icon);
2142 if (!confirmed_icon)
2144 return confirmed_icon;
2149 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon)
2151 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2152 icon->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2153 if (xmlTextReaderConstXmlLang(reader)) {
2154 icon->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2155 if (icon->lang == NULL)
2156 icon->lang = strdup(DEFAULT_LOCALE);
2158 icon->lang = strdup(DEFAULT_LOCALE);
2160 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
2161 icon->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
2162 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
2163 icon->size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
2164 if (xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")))
2165 icon->resolution = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")));
2166 xmlTextReaderRead(reader);
2167 if (xmlTextReaderValue(reader)) {
2168 const char *text = ASCII(xmlTextReaderValue(reader));
2170 icon->text = (const char *)__get_icon_with_path(text);
2178 static int __ps_process_image(xmlTextReaderPtr reader, image_x *image)
2180 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2181 image->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2182 if (xmlTextReaderConstXmlLang(reader)) {
2183 image->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2184 if (image->lang == NULL)
2185 image->lang = strdup(DEFAULT_LOCALE);
2187 image->lang = strdup(DEFAULT_LOCALE);
2189 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
2190 image->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
2191 xmlTextReaderRead(reader);
2192 if (xmlTextReaderValue(reader))
2193 image->text = ASCII(xmlTextReaderValue(reader));
2198 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label)
2200 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2201 label->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2202 if (xmlTextReaderConstXmlLang(reader)) {
2203 label->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2204 if (label->lang == NULL)
2205 label->lang = strdup(DEFAULT_LOCALE);
2207 label->lang = strdup(DEFAULT_LOCALE);
2209 xmlTextReaderRead(reader);
2210 if (xmlTextReaderValue(reader))
2211 label->text = ASCII(xmlTextReaderValue(reader));
2213 /* DBG("lable name %s\n", label->name);
2214 DBG("lable lang %s\n", label->lang);
2215 DBG("lable text %s\n", label->text);
2221 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author)
2223 if (xmlTextReaderGetAttribute(reader, XMLCHAR("email")))
2224 author->email = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("email")));
2225 if (xmlTextReaderGetAttribute(reader, XMLCHAR("href")))
2226 author->href = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("href")));
2227 if (xmlTextReaderConstXmlLang(reader)) {
2228 author->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2229 if (author->lang == NULL)
2230 author->lang = strdup(DEFAULT_LOCALE);
2232 author->lang = strdup(DEFAULT_LOCALE);
2234 xmlTextReaderRead(reader);
2235 if (xmlTextReaderValue(reader))
2236 author->text = ASCII(xmlTextReaderValue(reader));
2240 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description)
2242 if (xmlTextReaderConstXmlLang(reader)) {
2243 description->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2244 if (description->lang == NULL)
2245 description->lang = strdup(DEFAULT_LOCALE);
2247 description->lang = strdup(DEFAULT_LOCALE);
2249 xmlTextReaderRead(reader);
2250 if (xmlTextReaderValue(reader))
2251 description->text = ASCII(xmlTextReaderValue(reader));
2255 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license)
2257 if (xmlTextReaderConstXmlLang(reader)) {
2258 license->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2259 if (license->lang == NULL)
2260 license->lang = strdup(DEFAULT_LOCALE);
2262 license->lang = strdup(DEFAULT_LOCALE);
2264 xmlTextReaderRead(reader);
2265 if (xmlTextReaderValue(reader))
2266 license->text = ASCII(xmlTextReaderValue(reader));
2270 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability)
2272 const xmlChar *node;
2275 resolution_x *tmp1 = NULL;
2277 if (xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")))
2278 capability->operationid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")));
2280 depth = xmlTextReaderDepth(reader);
2281 while ((ret = __next_child_element(reader, depth))) {
2282 node = xmlTextReaderConstName(reader);
2284 DBG("xmlTextReaderConstName value is NULL\n");
2288 if (!strcmp(ASCII(node), "resolution")) {
2289 resolution_x *resolution = malloc(sizeof(resolution_x));
2290 if (resolution == NULL) {
2291 DBG("Malloc Failed\n");
2294 memset(resolution, '\0', sizeof(resolution_x));
2295 LISTADD(capability->resolution, resolution);
2296 ret = __ps_process_resolution(reader, resolution);
2300 DBG("Processing capability failed\n");
2305 if (capability->resolution) {
2306 LISTHEAD(capability->resolution, tmp1);
2307 capability->resolution = tmp1;
2313 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol)
2315 const xmlChar *node;
2318 capability_x *tmp1 = NULL;
2320 if (xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")))
2321 datacontrol->providerid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")));
2323 depth = xmlTextReaderDepth(reader);
2324 while ((ret = __next_child_element(reader, depth))) {
2325 node = xmlTextReaderConstName(reader);
2327 DBG("xmlTextReaderConstName value is NULL\n");
2331 if (!strcmp(ASCII(node), "capability")) {
2332 capability_x *capability = malloc(sizeof(capability_x));
2333 if (capability == NULL) {
2334 DBG("Malloc Failed\n");
2337 memset(capability, '\0', sizeof(capability_x));
2338 LISTADD(datacontrol->capability, capability);
2339 ret = __ps_process_capability(reader, capability);
2343 DBG("Processing datacontrol failed\n");
2348 if (datacontrol->capability) {
2349 LISTHEAD(datacontrol->capability, tmp1);
2350 datacontrol->capability = tmp1;
2356 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication)
2358 const xmlChar *node;
2361 char *newappid = NULL;
2362 label_x *tmp1 = NULL;
2363 icon_x *tmp2 = NULL;
2364 appsvc_x *tmp3 = NULL;
2365 appcontrol_x *tmp4 = NULL;
2366 launchconditions_x *tmp5 = NULL;
2367 notification_x *tmp6 = NULL;
2368 datashare_x *tmp7 = NULL;
2369 category_x *tmp8 = NULL;
2370 metadata_x *tmp9 = NULL;
2371 image_x *tmp10 = NULL;
2372 permission_x *tmp11 = NULL;
2374 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
2375 uiapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
2376 if (uiapplication->appid == NULL) {
2377 DBG("appid cant be NULL\n");
2381 DBG("appid is mandatory\n");
2385 ret = __validate_appid(package, uiapplication->appid, &newappid);
2387 DBG("appid is not proper\n");
2391 if (uiapplication->appid)
2392 free((void *)uiapplication->appid);
2393 uiapplication->appid = newappid;
2396 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
2397 uiapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
2398 if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay"))) {
2399 uiapplication->nodisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay")));
2400 if (uiapplication->nodisplay == NULL)
2401 uiapplication->nodisplay = strdup("false");
2403 uiapplication->nodisplay = strdup("false");
2405 if (xmlTextReaderGetAttribute(reader, XMLCHAR("multiple"))) {
2406 uiapplication->multiple = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("multiple")));
2407 if (uiapplication->multiple == NULL)
2408 uiapplication->multiple = strdup("false");
2410 uiapplication->multiple = strdup("false");
2412 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
2413 uiapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
2414 if (xmlTextReaderGetAttribute(reader, XMLCHAR("categories")))
2415 uiapplication->categories = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("categories")));
2416 if (xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")))
2417 uiapplication->extraid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")));
2418 if (xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage"))) {
2419 uiapplication->taskmanage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage")));
2420 if (uiapplication->taskmanage == NULL)
2421 uiapplication->taskmanage = strdup("true");
2423 uiapplication->taskmanage = strdup("true");
2425 if (xmlTextReaderGetAttribute(reader, XMLCHAR("enabled"))) {
2426 uiapplication->enabled = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("enabled")));
2427 if (uiapplication->enabled == NULL)
2428 uiapplication->enabled = strdup("true");
2430 uiapplication->enabled = strdup("true");
2432 if (xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration"))) {
2433 uiapplication->hwacceleration = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration")));
2434 if (uiapplication->hwacceleration == NULL)
2435 uiapplication->hwacceleration = strdup("use-system-setting");
2437 uiapplication->hwacceleration = strdup("use-system-setting");
2439 if (xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")))
2440 uiapplication->recentimage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")));
2441 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp"))) {
2442 uiapplication->mainapp = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp")));
2443 if (uiapplication->mainapp == NULL)
2444 uiapplication->mainapp = strdup("false");
2446 uiapplication->mainapp = strdup("false");
2448 if (xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay"))) {
2449 uiapplication->indicatordisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay")));
2450 if (uiapplication->indicatordisplay == NULL)
2451 uiapplication->indicatordisplay = strdup("true");
2453 uiapplication->indicatordisplay = strdup("true");
2455 if (xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")))
2456 uiapplication->portraitimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")));
2458 uiapplication->portraitimg = NULL;
2459 if (xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")))
2460 uiapplication->landscapeimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")));
2462 uiapplication->landscapeimg = NULL;
2463 if (xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility"))) {
2464 uiapplication->guestmode_visibility = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility")));
2465 if (uiapplication->guestmode_visibility == NULL)
2466 uiapplication->guestmode_visibility = strdup("true");
2468 uiapplication->guestmode_visibility = strdup("true");
2471 depth = xmlTextReaderDepth(reader);
2472 while ((ret = __next_child_element(reader, depth))) {
2473 node = xmlTextReaderConstName(reader);
2475 DBG("xmlTextReaderConstName value is NULL\n");
2478 if (!strcmp(ASCII(node), "label")) {
2479 label_x *label = malloc(sizeof(label_x));
2480 if (label == NULL) {
2481 DBG("Malloc Failed\n");
2484 memset(label, '\0', sizeof(label_x));
2485 LISTADD(uiapplication->label, label);
2486 ret = __ps_process_label(reader, label);
2487 } else if (!strcmp(ASCII(node), "icon")) {
2488 icon_x *icon = malloc(sizeof(icon_x));
2490 DBG("Malloc Failed\n");
2493 memset(icon, '\0', sizeof(icon_x));
2494 LISTADD(uiapplication->icon, icon);
2495 ret = __ps_process_icon(reader, icon);
2496 } else if (!strcmp(ASCII(node), "image")) {
2497 image_x *image = malloc(sizeof(image_x));
2498 if (image == NULL) {
2499 DBG("Malloc Failed\n");
2502 memset(image, '\0', sizeof(image_x));
2503 LISTADD(uiapplication->image, image);
2504 ret = __ps_process_image(reader, image);
2505 } else if (!strcmp(ASCII(node), "category")) {
2506 category_x *category = malloc(sizeof(category_x));
2507 if (category == NULL) {
2508 DBG("Malloc Failed\n");
2511 memset(category, '\0', sizeof(category_x));
2512 LISTADD(uiapplication->category, category);
2513 ret = __ps_process_category(reader, category);
2514 } else if (!strcmp(ASCII(node), "metadata")) {
2515 metadata_x *metadata = malloc(sizeof(metadata_x));
2516 if (metadata == NULL) {
2517 DBG("Malloc Failed\n");
2520 memset(metadata, '\0', sizeof(metadata_x));
2521 LISTADD(uiapplication->metadata, metadata);
2522 ret = __ps_process_metadata(reader, metadata);
2523 } else if (!strcmp(ASCII(node), "permission")) {
2524 permission_x *permission = malloc(sizeof(permission_x));
2525 if (permission == NULL) {
2526 DBG("Malloc Failed\n");
2529 memset(permission, '\0', sizeof(permission_x));
2530 LISTADD(uiapplication->permission, permission);
2531 ret = __ps_process_permission(reader, permission);
2532 } else if (!strcmp(ASCII(node), "app-control")) {
2533 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
2534 if (appcontrol == NULL) {
2535 DBG("Malloc Failed\n");
2538 memset(appcontrol, '\0', sizeof(appcontrol_x));
2539 LISTADD(uiapplication->appcontrol, appcontrol);
2540 ret = __ps_process_appcontrol(reader, appcontrol);
2541 } else if (!strcmp(ASCII(node), "application-service")) {
2542 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
2543 if (appsvc == NULL) {
2544 DBG("Malloc Failed\n");
2547 memset(appsvc, '\0', sizeof(appsvc_x));
2548 LISTADD(uiapplication->appsvc, appsvc);
2549 ret = __ps_process_appsvc(reader, appsvc);
2550 } else if (!strcmp(ASCII(node), "data-share")) {
2551 datashare_x *datashare = malloc(sizeof(datashare_x));
2552 if (datashare == NULL) {
2553 DBG("Malloc Failed\n");
2556 memset(datashare, '\0', sizeof(datashare_x));
2557 LISTADD(uiapplication->datashare, datashare);
2558 ret = __ps_process_datashare(reader, datashare);
2559 } else if (!strcmp(ASCII(node), "launch-conditions")) {
2560 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
2561 if (launchconditions == NULL) {
2562 DBG("Malloc Failed\n");
2565 memset(launchconditions, '\0', sizeof(launchconditions_x));
2566 LISTADD(uiapplication->launchconditions, launchconditions);
2567 ret = __ps_process_launchconditions(reader, launchconditions);
2568 } else if (!strcmp(ASCII(node), "notification")) {
2569 notification_x *notification = malloc(sizeof(notification_x));
2570 if (notification == NULL) {
2571 DBG("Malloc Failed\n");
2574 memset(notification, '\0', sizeof(notification_x));
2575 LISTADD(uiapplication->notification, notification);
2576 ret = __ps_process_notification(reader, notification);
2580 DBG("Processing uiapplication failed\n");
2585 if (uiapplication->label) {
2586 LISTHEAD(uiapplication->label, tmp1);
2587 uiapplication->label = tmp1;
2589 if (uiapplication->icon) {
2590 LISTHEAD(uiapplication->icon, tmp2);
2591 uiapplication->icon = tmp2;
2593 if (uiapplication->appsvc) {
2594 LISTHEAD(uiapplication->appsvc, tmp3);
2595 uiapplication->appsvc = tmp3;
2597 if (uiapplication->appcontrol) {
2598 LISTHEAD(uiapplication->appcontrol, tmp4);
2599 uiapplication->appcontrol = tmp4;
2601 if (uiapplication->launchconditions) {
2602 LISTHEAD(uiapplication->launchconditions, tmp5);
2603 uiapplication->launchconditions = tmp5;
2605 if (uiapplication->notification) {
2606 LISTHEAD(uiapplication->notification, tmp6);
2607 uiapplication->notification = tmp6;
2609 if (uiapplication->datashare) {
2610 LISTHEAD(uiapplication->datashare, tmp7);
2611 uiapplication->datashare = tmp7;
2613 if (uiapplication->category) {
2614 LISTHEAD(uiapplication->category, tmp8);
2615 uiapplication->category = tmp8;
2617 if (uiapplication->metadata) {
2618 LISTHEAD(uiapplication->metadata, tmp9);
2619 uiapplication->metadata = tmp9;
2621 if (uiapplication->image) {
2622 LISTHEAD(uiapplication->image, tmp10);
2623 uiapplication->image = tmp10;
2625 if (uiapplication->permission) {
2626 LISTHEAD(uiapplication->permission, tmp11);
2627 uiapplication->permission = tmp11;
2633 static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication)
2635 const xmlChar *node;
2638 char *newappid = NULL;
2639 label_x *tmp1 = NULL;
2640 icon_x *tmp2 = NULL;
2641 appsvc_x *tmp3 = NULL;
2642 appcontrol_x *tmp4 = NULL;
2643 datacontrol_x *tmp5 = NULL;
2644 launchconditions_x *tmp6 = NULL;
2645 notification_x *tmp7 = NULL;
2646 datashare_x *tmp8 = NULL;
2647 category_x *tmp9 = NULL;
2648 metadata_x *tmp10 = NULL;
2649 permission_x *tmp11 = NULL;
2651 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
2652 serviceapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
2653 if (serviceapplication->appid == NULL) {
2654 DBG("appid cant be NULL\n");
2658 DBG("appid is mandatory\n");
2662 ret = __validate_appid(package, serviceapplication->appid, &newappid);
2664 DBG("appid is not proper\n");
2668 if (serviceapplication->appid)
2669 free((void *)serviceapplication->appid);
2670 serviceapplication->appid = newappid;
2673 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
2674 serviceapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
2675 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
2676 serviceapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
2677 if (xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot"))) {
2678 serviceapplication->onboot = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot")));
2679 if (serviceapplication->onboot == NULL)
2680 serviceapplication->onboot = strdup("false");
2682 serviceapplication->onboot = strdup("false");
2684 if (xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart"))) {
2685 serviceapplication->autorestart = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart")));
2686 if (serviceapplication->autorestart == NULL)
2687 serviceapplication->autorestart = strdup("false");
2689 serviceapplication->autorestart = strdup("false");
2692 depth = xmlTextReaderDepth(reader);
2693 while ((ret = __next_child_element(reader, depth))) {
2694 node = xmlTextReaderConstName(reader);
2696 DBG("xmlTextReaderConstName value is NULL\n");
2700 if (!strcmp(ASCII(node), "label")) {
2701 label_x *label = malloc(sizeof(label_x));
2702 if (label == NULL) {
2703 DBG("Malloc Failed\n");
2706 memset(label, '\0', sizeof(label_x));
2707 LISTADD(serviceapplication->label, label);
2708 ret = __ps_process_label(reader, label);
2709 } else if (!strcmp(ASCII(node), "icon")) {
2710 icon_x *icon = malloc(sizeof(icon_x));
2712 DBG("Malloc Failed\n");
2715 memset(icon, '\0', sizeof(icon_x));
2716 LISTADD(serviceapplication->icon, icon);
2717 ret = __ps_process_icon(reader, icon);
2718 } else if (!strcmp(ASCII(node), "category")) {
2719 category_x *category = malloc(sizeof(category_x));
2720 if (category == NULL) {
2721 DBG("Malloc Failed\n");
2724 memset(category, '\0', sizeof(category_x));
2725 LISTADD(serviceapplication->category, category);
2726 ret = __ps_process_category(reader, category);
2727 } else if (!strcmp(ASCII(node), "metadata")) {
2728 metadata_x *metadata = malloc(sizeof(metadata_x));
2729 if (metadata == NULL) {
2730 DBG("Malloc Failed\n");
2733 memset(metadata, '\0', sizeof(metadata_x));
2734 LISTADD(serviceapplication->metadata, metadata);
2735 ret = __ps_process_metadata(reader, metadata);
2736 } else if (!strcmp(ASCII(node), "permission")) {
2737 permission_x *permission = malloc(sizeof(permission_x));
2738 if (permission == NULL) {
2739 DBG("Malloc Failed\n");
2742 memset(permission, '\0', sizeof(permission_x));
2743 LISTADD(serviceapplication->permission, permission);
2744 ret = __ps_process_permission(reader, permission);
2745 } else if (!strcmp(ASCII(node), "app-control")) {
2746 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
2747 if (appcontrol == NULL) {
2748 DBG("Malloc Failed\n");
2751 memset(appcontrol, '\0', sizeof(appcontrol_x));
2752 LISTADD(serviceapplication->appcontrol, appcontrol);
2753 ret = __ps_process_appcontrol(reader, appcontrol);
2754 } else if (!strcmp(ASCII(node), "application-service")) {
2755 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
2756 if (appsvc == NULL) {
2757 DBG("Malloc Failed\n");
2760 memset(appsvc, '\0', sizeof(appsvc_x));
2761 LISTADD(serviceapplication->appsvc, appsvc);
2762 ret = __ps_process_appsvc(reader, appsvc);
2763 } else if (!strcmp(ASCII(node), "data-share")) {
2764 datashare_x *datashare = malloc(sizeof(datashare_x));
2765 if (datashare == NULL) {
2766 DBG("Malloc Failed\n");
2769 memset(datashare, '\0', sizeof(datashare_x));
2770 LISTADD(serviceapplication->datashare, datashare);
2771 ret = __ps_process_datashare(reader, datashare);
2772 } else if (!strcmp(ASCII(node), "launch-conditions")) {
2773 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
2774 if (launchconditions == NULL) {
2775 DBG("Malloc Failed\n");
2778 memset(launchconditions, '\0', sizeof(launchconditions_x));
2779 LISTADD(serviceapplication->launchconditions, launchconditions);
2780 ret = __ps_process_launchconditions(reader, launchconditions);
2781 } else if (!strcmp(ASCII(node), "notification")) {
2782 notification_x *notification = malloc(sizeof(notification_x));
2783 if (notification == NULL) {
2784 DBG("Malloc Failed\n");
2787 memset(notification, '\0', sizeof(notification_x));
2788 LISTADD(serviceapplication->notification, notification);
2789 ret = __ps_process_notification(reader, notification);
2790 } else if (!strcmp(ASCII(node), "data-control")) {
2791 datacontrol_x *datacontrol = malloc(sizeof(datacontrol_x));
2792 if (datacontrol == NULL) {
2793 DBG("Malloc Failed\n");
2796 memset(datacontrol, '\0', sizeof(datacontrol_x));
2797 LISTADD(serviceapplication->datacontrol, datacontrol);
2798 ret = __ps_process_datacontrol(reader, datacontrol);
2802 DBG("Processing serviceapplication failed\n");
2807 if (serviceapplication->label) {
2808 LISTHEAD(serviceapplication->label, tmp1);
2809 serviceapplication->label = tmp1;
2811 if (serviceapplication->icon) {
2812 LISTHEAD(serviceapplication->icon, tmp2);
2813 serviceapplication->icon = tmp2;
2815 if (serviceapplication->appsvc) {
2816 LISTHEAD(serviceapplication->appsvc, tmp3);
2817 serviceapplication->appsvc = tmp3;
2819 if (serviceapplication->appcontrol) {
2820 LISTHEAD(serviceapplication->appcontrol, tmp4);
2821 serviceapplication->appcontrol = tmp4;
2823 if (serviceapplication->datacontrol) {
2824 LISTHEAD(serviceapplication->datacontrol, tmp5);
2825 serviceapplication->datacontrol = tmp5;
2827 if (serviceapplication->launchconditions) {
2828 LISTHEAD(serviceapplication->launchconditions, tmp6);
2829 serviceapplication->launchconditions = tmp6;
2831 if (serviceapplication->notification) {
2832 LISTHEAD(serviceapplication->notification, tmp7);
2833 serviceapplication->notification = tmp7;
2835 if (serviceapplication->datashare) {
2836 LISTHEAD(serviceapplication->datashare, tmp8);
2837 serviceapplication->datashare = tmp8;
2839 if (serviceapplication->category) {
2840 LISTHEAD(serviceapplication->category, tmp9);
2841 serviceapplication->category = tmp9;
2843 if (serviceapplication->metadata) {
2844 LISTHEAD(serviceapplication->metadata, tmp10);
2845 serviceapplication->metadata = tmp10;
2847 if (serviceapplication->permission) {
2848 LISTHEAD(serviceapplication->permission, tmp11);
2849 serviceapplication->permission = tmp11;
2855 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile)
2857 /*TODO: once policy is set*/
2861 static int __ps_process_font(xmlTextReaderPtr reader, font_x *font)
2863 /*TODO: once policy is set*/
2867 static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme)
2869 /*TODO: once policy is set*/
2873 static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon)
2875 /*TODO: once policy is set*/
2879 static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime)
2881 /*TODO: once policy is set*/
2885 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx)
2887 DBG("__start_process\n");
2888 const xmlChar *node;
2891 label_x *tmp1 = NULL;
2892 author_x *tmp2 = NULL;
2893 description_x *tmp3 = NULL;
2894 license_x *tmp4 = NULL;
2895 uiapplication_x *tmp5 = NULL;
2896 serviceapplication_x *tmp6 = NULL;
2897 daemon_x *tmp7 = NULL;
2898 theme_x *tmp8 = NULL;
2899 font_x *tmp9 = NULL;
2900 ime_x *tmp10 = NULL;
2901 icon_x *tmp11 = NULL;
2902 compatibility_x *tmp12 = NULL;
2903 deviceprofile_x *tmp13 = NULL;
2904 privileges_x *tmp14 = NULL;
2906 depth = xmlTextReaderDepth(reader);
2907 while ((ret = __next_child_element(reader, depth))) {
2908 node = xmlTextReaderConstName(reader);
2910 DBG("xmlTextReaderConstName value is NULL\n");
2914 if (!strcmp(ASCII(node), "label")) {
2915 label_x *label = malloc(sizeof(label_x));
2916 if (label == NULL) {
2917 DBG("Malloc Failed\n");
2920 memset(label, '\0', sizeof(label_x));
2921 LISTADD(mfx->label, label);
2922 ret = __ps_process_label(reader, label);
2923 } else if (!strcmp(ASCII(node), "author")) {
2924 author_x *author = malloc(sizeof(author_x));
2925 if (author == NULL) {
2926 DBG("Malloc Failed\n");
2929 memset(author, '\0', sizeof(author_x));
2930 LISTADD(mfx->author, author);
2931 ret = __ps_process_author(reader, author);
2932 } else if (!strcmp(ASCII(node), "description")) {
2933 description_x *description = malloc(sizeof(description_x));
2934 if (description == NULL) {
2935 DBG("Malloc Failed\n");
2938 memset(description, '\0', sizeof(description_x));
2939 LISTADD(mfx->description, description);
2940 ret = __ps_process_description(reader, description);
2941 } else if (!strcmp(ASCII(node), "license")) {
2942 license_x *license = malloc(sizeof(license_x));
2943 if (license == NULL) {
2944 DBG("Malloc Failed\n");
2947 memset(license, '\0', sizeof(license_x));
2948 LISTADD(mfx->license, license);
2949 ret = __ps_process_license(reader, license);
2950 } else if (!strcmp(ASCII(node), "privileges")) {
2951 privileges_x *privileges = malloc(sizeof(privileges_x));
2952 if (privileges == NULL) {
2953 DBG("Malloc Failed\n");
2956 memset(privileges, '\0', sizeof(privileges_x));
2957 LISTADD(mfx->privileges, privileges);
2958 ret = __ps_process_privileges(reader, privileges);
2959 } else if (!strcmp(ASCII(node), "ui-application")) {
2960 uiapplication_x *uiapplication = malloc(sizeof(uiapplication_x));
2961 if (uiapplication == NULL) {
2962 DBG("Malloc Failed\n");
2965 memset(uiapplication, '\0', sizeof(uiapplication_x));
2966 LISTADD(mfx->uiapplication, uiapplication);
2967 ret = __ps_process_uiapplication(reader, uiapplication);
2968 } else if (!strcmp(ASCII(node), "service-application")) {
2969 serviceapplication_x *serviceapplication = malloc(sizeof(serviceapplication_x));
2970 if (serviceapplication == NULL) {
2971 DBG("Malloc Failed\n");
2974 memset(serviceapplication, '\0', sizeof(serviceapplication_x));
2975 LISTADD(mfx->serviceapplication, serviceapplication);
2976 ret = __ps_process_serviceapplication(reader, serviceapplication);
2977 } else if (!strcmp(ASCII(node), "daemon")) {
2978 daemon_x *daemon = malloc(sizeof(daemon_x));
2979 if (daemon == NULL) {
2980 DBG("Malloc Failed\n");
2983 memset(daemon, '\0', sizeof(daemon_x));
2984 LISTADD(mfx->daemon, daemon);
2985 ret = __ps_process_daemon(reader, daemon);
2986 } else if (!strcmp(ASCII(node), "theme")) {
2987 theme_x *theme = malloc(sizeof(theme_x));
2988 if (theme == NULL) {
2989 DBG("Malloc Failed\n");
2992 memset(theme, '\0', sizeof(theme_x));
2993 LISTADD(mfx->theme, theme);
2994 ret = __ps_process_theme(reader, theme);
2995 } else if (!strcmp(ASCII(node), "font")) {
2996 font_x *font = malloc(sizeof(font_x));
2998 DBG("Malloc Failed\n");
3001 memset(font, '\0', sizeof(font_x));
3002 LISTADD(mfx->font, font);
3003 ret = __ps_process_font(reader, font);
3004 } else if (!strcmp(ASCII(node), "ime")) {
3005 ime_x *ime = malloc(sizeof(ime_x));
3007 DBG("Malloc Failed\n");
3010 memset(ime, '\0', sizeof(ime_x));
3011 LISTADD(mfx->ime, ime);
3012 ret = __ps_process_ime(reader, ime);
3013 } else if (!strcmp(ASCII(node), "icon")) {
3014 icon_x *icon = malloc(sizeof(icon_x));
3016 DBG("Malloc Failed\n");
3019 memset(icon, '\0', sizeof(icon_x));
3020 LISTADD(mfx->icon, icon);
3021 ret = __ps_process_icon(reader, icon);
3022 } else if (!strcmp(ASCII(node), "device-profile")) {
3023 deviceprofile_x *deviceprofile = malloc(sizeof(deviceprofile_x));
3024 if (deviceprofile == NULL) {
3025 DBG("Malloc Failed\n");
3028 memset(deviceprofile, '\0', sizeof(deviceprofile_x));
3029 LISTADD(mfx->deviceprofile, deviceprofile);
3030 ret = __ps_process_deviceprofile(reader, deviceprofile);
3031 } else if (!strcmp(ASCII(node), "compatibility")) {
3032 compatibility_x *compatibility = malloc(sizeof(compatibility_x));
3033 if (compatibility == NULL) {
3034 DBG("Malloc Failed\n");
3037 memset(compatibility, '\0', sizeof(compatibility_x));
3038 LISTADD(mfx->compatibility, compatibility);
3039 ret = __ps_process_compatibility(reader, compatibility);
3040 } else if (!strcmp(ASCII(node), "shortcut-list")) {
3042 } else if (!strcmp(ASCII(node), "livebox")) {
3044 } else if (!strcmp(ASCII(node), "account")) {
3046 } else if (!strcmp(ASCII(node), "notifications")) {
3048 } else if (!strcmp(ASCII(node), "ime")) {
3054 DBG("Processing manifest failed\n");
3059 LISTHEAD(mfx->label, tmp1);
3063 LISTHEAD(mfx->author, tmp2);
3066 if (mfx->description) {
3067 LISTHEAD(mfx->description, tmp3);
3068 mfx->description= tmp3;
3071 LISTHEAD(mfx->license, tmp4);
3074 if (mfx->uiapplication) {
3075 LISTHEAD(mfx->uiapplication, tmp5);
3076 mfx->uiapplication = tmp5;
3078 if (mfx->serviceapplication) {
3079 LISTHEAD(mfx->serviceapplication, tmp6);
3080 mfx->serviceapplication = tmp6;
3083 LISTHEAD(mfx->daemon, tmp7);
3087 LISTHEAD(mfx->theme, tmp8);
3091 LISTHEAD(mfx->font, tmp9);
3095 LISTHEAD(mfx->ime, tmp10);
3099 LISTHEAD(mfx->icon, tmp11);
3102 if (mfx->compatibility) {
3103 LISTHEAD(mfx->compatibility, tmp12);
3104 mfx->compatibility= tmp12;
3106 if (mfx->deviceprofile) {
3107 LISTHEAD(mfx->deviceprofile, tmp13);
3108 mfx->deviceprofile= tmp13;
3110 if (mfx->privileges) {
3111 LISTHEAD(mfx->privileges, tmp14);
3112 mfx->privileges = tmp14;
3117 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx)
3119 const xmlChar *node;
3122 if ((ret = __next_child_element(reader, -1))) {
3123 node = xmlTextReaderConstName(reader);
3125 DBG("xmlTextReaderConstName value is NULL\n");
3129 if (!strcmp(ASCII(node), "manifest")) {
3130 if (xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")))
3131 mfx->ns = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")));
3132 if (xmlTextReaderGetAttribute(reader, XMLCHAR("package"))) {
3133 mfx->package= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("package")));
3134 if (mfx->package == NULL) {
3135 DBG("package cant be NULL\n");
3139 DBG("package field is mandatory\n");
3142 package = mfx->package;
3143 if (xmlTextReaderGetAttribute(reader, XMLCHAR("version")))
3144 mfx->version= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("version")));
3145 /*app2ext needs package size for external installation*/
3146 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
3147 mfx->package_size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
3148 if (xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")))
3149 mfx->installlocation = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")));
3150 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
3151 mfx->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
3152 if (xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")))
3153 mfx->root_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")));
3154 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting"))) {
3155 mfx->appsetting = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting")));
3156 if (mfx->appsetting == NULL)
3157 mfx->appsetting = strdup("false");
3159 mfx->appsetting = strdup("false");
3162 /*Assign default values. If required it will be overwritten in __add_preload_info()*/
3163 mfx->preload = strdup("False");
3164 mfx->removable = strdup("True");
3165 mfx->readonly = strdup("False");
3166 char buf[PKG_STRING_LEN_MAX] = {'\0'};
3168 time_t current_time;
3169 time(¤t_time);
3170 snprintf(buf, PKG_STRING_LEN_MAX - 1, "%d", current_time);
3171 val = strndup(buf, PKG_STRING_LEN_MAX - 1);
3172 mfx->installed_time = val;
3174 mfx->installed_storage= strdup("installed_internal");
3176 ret = __start_process(reader, mfx);
3178 DBG("No Manifest element found\n");
3185 #define DESKTOP_RW_PATH "/opt/share/applications/"
3186 #define DESKTOP_RO_PATH "/usr/share/applications/"
3188 static char* __convert_to_system_locale(const char *mlocale)
3190 if (mlocale == NULL)
3192 char *locale = NULL;
3193 locale = (char *)calloc(1, 6);
3195 DBGE("Malloc Failed\n");
3199 strncpy(locale, mlocale, 2);
3200 strncat(locale, "_", 1);
3201 locale[3] = toupper(mlocale[3]);
3202 locale[4] = toupper(mlocale[4]);
3206 #define LIBAIL_PATH "/usr/lib/libail.so.0"
3208 /* operation_type */
3216 static int __ail_change_info(int op, const char *appid)
3218 void *lib_handle = NULL;
3219 int (*ail_desktop_operation) (const char *);
3223 if ((lib_handle = dlopen(LIBAIL_PATH, RTLD_LAZY)) == NULL) {
3224 DBGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAIL_PATH);
3231 aop = "ail_desktop_add";
3234 aop = "ail_desktop_update";
3237 aop = "ail_desktop_remove";
3244 if ((ail_desktop_operation =
3245 dlsym(lib_handle, aop)) == NULL || dlerror() != NULL) {
3246 DBGE("can not find symbol \n");
3250 ret = ail_desktop_operation(appid);
3254 dlclose(lib_handle);
3260 /* desktop shoud be generated automatically based on manifest */
3261 /* Currently removable, taskmanage, etc fields are not considerd. it will be decided soon.*/
3262 #define BUFMAX 1024*128
3263 static int __ps_make_nativeapp_desktop(manifest_x * mfx, bool is_update)
3267 char filepath[PKG_STRING_LEN_MAX] = "";
3269 char *buftemp = NULL;
3270 char *locale = NULL;
3272 buf = (char *)calloc(1, BUFMAX);
3274 DBGE("Malloc Failed\n");
3278 buftemp = (char *)calloc(1, BUFMAX);
3280 DBGE("Malloc Failed\n");
3285 for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) {
3287 if(mfx->readonly && !strcasecmp(mfx->readonly, "True"))
3288 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RO_PATH, mfx->uiapplication->appid);
3290 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, mfx->uiapplication->appid);
3292 /* skip if desktop exists
3293 if (access(filepath, R_OK) == 0)
3297 file = fopen(filepath, "w");
3300 DBGE("Can't open %s", filepath);
3306 snprintf(buf, BUFMAX, "[Desktop Entry]\n");
3307 fwrite(buf, 1, strlen(buf), file);
3309 for( ; mfx->uiapplication->label ; mfx->uiapplication->label = mfx->uiapplication->label->next) {
3310 if(!strcmp(mfx->uiapplication->label->lang, DEFAULT_LOCALE)) {
3311 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
3313 locale = __convert_to_system_locale(mfx->uiapplication->label->lang);
3314 snprintf(buf, BUFMAX, "Name[%s]=%s\n", locale,
3315 mfx->uiapplication->label->text);
3318 fwrite(buf, 1, strlen(buf), file);
3321 if(mfx->uiapplication->label && mfx->uiapplication->label->text) {
3322 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
3323 fwrite(buf, 1, strlen(buf), file);
3326 else if(mfx->label && mfx->label->text) {
3327 snprintf(buf, BUFMAX, "Name=%s\n", mfx->label->text);
3328 fwrite(buf, 1, strlen(buf), file);
3330 snprintf(buf, BUFMAX, "Name=%s\n", mfx->package);
3331 fwrite(buf, 1, strlen(buf), file);
3336 snprintf(buf, BUFMAX, "Type=Application\n");
3337 fwrite(buf, 1, strlen(buf), file);
3339 if(mfx->uiapplication->exec) {
3340 snprintf(buf, BUFMAX, "Exec=%s\n", mfx->uiapplication->exec);
3341 fwrite(buf, 1, strlen(buf), file);
3344 if(mfx->uiapplication->icon && mfx->uiapplication->icon->text) {
3345 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->uiapplication->icon->text);
3346 fwrite(buf, 1, strlen(buf), file);
3347 } else if(mfx->icon && mfx->icon->text) {
3348 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->icon->text);
3349 fwrite(buf, 1, strlen(buf), file);
3353 snprintf(buf, BUFMAX, "Version=%s\n", mfx->version);
3354 fwrite(buf, 1, strlen(buf), file);
3357 if(mfx->uiapplication->nodisplay) {
3358 snprintf(buf, BUFMAX, "NoDisplay=%s\n", mfx->uiapplication->nodisplay);
3359 fwrite(buf, 1, strlen(buf), file);
3362 if(mfx->uiapplication->categories) {
3363 snprintf(buf, BUFMAX, "Categories=%s\n", mfx->uiapplication->categories);
3364 fwrite(buf, 1, strlen(buf), file);
3367 if(mfx->uiapplication->taskmanage && !strcasecmp(mfx->uiapplication->taskmanage, "False")) {
3368 snprintf(buf, BUFMAX, "X-TIZEN-TaskManage=False\n");
3369 fwrite(buf, 1, strlen(buf), file);
3372 if(mfx->uiapplication->enabled && !strcasecmp(mfx->uiapplication->enabled, "False")) {
3373 snprintf(buf, BUFMAX, "X-TIZEN-Enabled=False\n");
3374 fwrite(buf, 1, strlen(buf), file);
3377 if(mfx->uiapplication->hwacceleration) {
3378 snprintf(buf, BUFMAX, "Hw-Acceleration=%s\n", mfx->uiapplication->hwacceleration);
3379 fwrite(buf, 1, strlen(buf), file);
3382 if(mfx->uiapplication->multiple && !strcasecmp(mfx->uiapplication->multiple, "True")) {
3383 snprintf(buf, BUFMAX, "X-TIZEN-Multiple=True\n");
3384 fwrite(buf, 1, strlen(buf), file);
3387 if(mfx->uiapplication->extraid) {
3388 snprintf(buf, BUFMAX, "X-TIZEN-PackageID=%s\n", mfx->uiapplication->extraid);
3389 fwrite(buf, 1, strlen(buf), file);
3392 if(mfx->removable && !strcasecmp(mfx->removable, "False")) {
3393 snprintf(buf, BUFMAX, "X-TIZEN-Removable=False\n");
3394 fwrite(buf, 1, strlen(buf), file);
3398 snprintf(buf, BUFMAX, "X-TIZEN-PackageType=%s\n", mfx->type);
3399 fwrite(buf, 1, strlen(buf), file);
3402 snprintf(buf, BUFMAX, "X-TIZEN-PkgID=%s\n", mfx->package);
3403 fwrite(buf, 1, strlen(buf), file);
3406 // snprintf(buf, BUFMAX, "X-TIZEN-PackageType=rpm\n");
3407 // fwrite(buf, 1, strlen(buf), file);
3410 if(mfx->uiapplication->appsvc) {
3411 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
3412 DBG("buf[%s]\n", buf);
3415 uiapplication_x *up = mfx->uiapplication;
3416 appsvc_x *asvc = NULL;
3417 operation_x *op = NULL;
3420 subapp_x *sub = NULL;
3421 const char *operation = NULL;
3422 const char *mime = NULL;
3423 const char *uri = NULL;
3424 const char *subapp = NULL;
3429 while(asvc != NULL) {
3430 op = asvc->operation;
3433 operation = op->name;
3452 strncpy(buftemp, buf, BUFMAX);
3453 snprintf(buf, BUFMAX, "%s;", buftemp);
3457 strncpy(buftemp, buf, BUFMAX);
3458 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
3459 DBG("buf[%s]\n", buf);
3464 } while(ui != NULL);
3468 }while(sub != NULL);
3481 fwrite(buf, 1, strlen(buf), file);
3483 // strncpy(buftemp, buf, BUFMAX);
3484 // snprintf(buf, BUFMAX, "%s\n", buftemp);
3485 // fwrite(buf, 1, strlen(buf), file);
3488 if(mfx->uiapplication->appcontrol) {
3489 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
3490 DBG("buf[%s]\n", buf);
3492 uiapplication_x *up = mfx->uiapplication;
3493 appcontrol_x *acontrol = NULL;
3494 operation_x *op = NULL;
3497 subapp_x *sub = NULL;
3498 const char *operation = NULL;
3499 const char *mime = NULL;
3500 const char *uri = NULL;
3501 const char *subapp = NULL;
3504 acontrol = up->appcontrol;
3505 while(acontrol != NULL) {
3506 op = acontrol->operation;
3509 operation = op->name;
3510 mi = acontrol->mime;
3516 sub = acontrol->subapp;
3528 strncpy(buftemp, buf, BUFMAX);
3529 snprintf(buf, BUFMAX, "%s;", buftemp);
3532 strncpy(buftemp, buf, BUFMAX);
3533 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
3534 DBG("buf[%s]\n", buf);
3539 } while(ui != NULL);
3543 }while(sub != NULL);
3552 acontrol = acontrol->next;
3556 fwrite(buf, 1, strlen(buf), file);
3558 // strncpy(buftemp, buf, BUFMAX);
3559 // snprintf(buf, BUFMAX, "%s\n", buftemp);
3560 // fwrite(buf, 1, strlen(buf), file);
3569 __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid);
3571 __ail_change_info(AIL_UPDATE, mfx->uiapplication->appid);
3580 static int __ps_remove_nativeapp_desktop(manifest_x *mfx)
3582 char filepath[PKG_STRING_LEN_MAX] = "";
3585 for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) {
3586 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, mfx->uiapplication->appid);
3588 __ail_change_info(AIL_REMOVE, mfx->uiapplication->appid);
3590 ret = remove(filepath);
3598 #define MANIFEST_RO_PREFIX "/usr/share/packages/"
3599 #define PRELOAD_PACKAGE_LIST "/usr/etc/package-manager/preload/preload_list.txt"
3600 static int __add_preload_info(manifest_x * mfx, const char *manifest)
3603 char buffer[1024] = { 0 };
3606 if(strstr(manifest, MANIFEST_RO_PREFIX)) {
3607 free((void *)mfx->readonly);
3608 mfx->readonly = strdup("True");
3610 free((void *)mfx->preload);
3611 mfx->preload = strdup("True");
3613 free((void *)mfx->removable);
3614 mfx->removable = strdup("False");
3619 fp = fopen(PRELOAD_PACKAGE_LIST, "r");
3621 DBGE("no preload list\n");
3625 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
3626 if (buffer[0] == '#') {
3627 if(strcasestr(buffer, "RW_NORM"))
3629 else if(strcasestr(buffer, "RW_RM"))
3637 if(!strcmp(mfx->package, buffer)) {
3638 free((void *)mfx->preload);
3639 mfx->preload = strdup("True");
3641 free((void *)mfx->readonly);
3642 mfx->readonly = strdup("False");
3643 free((void *)mfx->removable);
3644 mfx->removable = strdup("False");
3645 } else if(state == 3){
3646 free((void *)mfx->readonly);
3647 mfx->readonly = strdup("False");
3648 free((void *)mfx->removable);
3649 mfx->removable = strdup("True");
3653 memset(buffer, 0x00, sizeof(buffer));
3663 API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
3668 free((void *)mfx->ns);
3672 free((void *)mfx->package);
3673 mfx->package = NULL;
3676 free((void *)mfx->version);
3677 mfx->version = NULL;
3679 if (mfx->installlocation) {
3680 free((void *)mfx->installlocation);
3681 mfx->installlocation = NULL;
3684 free((void *)mfx->preload);
3685 mfx->preload = NULL;
3687 if (mfx->readonly) {
3688 free((void *)mfx->readonly);
3689 mfx->readonly = NULL;
3691 if (mfx->removable) {
3692 free((void *)mfx->removable);
3693 mfx->removable = NULL;
3696 free((void *)mfx->update);
3700 free((void *)mfx->type);
3703 if (mfx->package_size) {
3704 free((void *)mfx->package_size);
3705 mfx->package_size = NULL;
3707 if (mfx->installed_time) {
3708 free((void *)mfx->installed_time);
3709 mfx->installed_time = NULL;
3711 if (mfx->installed_storage) {
3712 free((void *)mfx->installed_storage);
3713 mfx->installed_storage = NULL;
3715 if (mfx->storeclient_id) {
3716 free((void *)mfx->storeclient_id);
3717 mfx->storeclient_id = NULL;
3719 if (mfx->mainapp_id) {
3720 free((void *)mfx->mainapp_id);
3721 mfx->mainapp_id = NULL;
3723 if (mfx->package_url) {
3724 free((void *)mfx->package_url);
3725 mfx->package_url = NULL;
3727 if (mfx->root_path) {
3728 free((void *)mfx->root_path);
3729 mfx->root_path = NULL;
3731 if (mfx->appsetting) {
3732 free((void *)mfx->appsetting);
3733 mfx->appsetting = NULL;
3738 icon_x *icon = mfx->icon;
3740 while(icon != NULL) {
3742 __ps_free_icon(icon);
3748 label_x *label = mfx->label;
3749 label_x *tmp = NULL;
3750 while(label != NULL) {
3752 __ps_free_label(label);
3758 author_x *author = mfx->author;
3759 author_x *tmp = NULL;
3760 while(author != NULL) {
3762 __ps_free_author(author);
3766 /*Free Description*/
3767 if (mfx->description) {
3768 description_x *description = mfx->description;
3769 description_x *tmp = NULL;
3770 while(description != NULL) {
3771 tmp = description->next;
3772 __ps_free_description(description);
3778 license_x *license = mfx->license;
3779 license_x *tmp = NULL;
3780 while(license != NULL) {
3781 tmp = license->next;
3782 __ps_free_license(license);
3787 if (mfx->privileges) {
3788 privileges_x *privileges = mfx->privileges;
3789 privileges_x *tmp = NULL;
3790 while(privileges != NULL) {
3791 tmp = privileges->next;
3792 __ps_free_privileges(privileges);
3796 /*Free UiApplication*/
3797 if (mfx->uiapplication) {
3798 uiapplication_x *uiapplication = mfx->uiapplication;
3799 uiapplication_x *tmp = NULL;
3800 while(uiapplication != NULL) {
3801 tmp = uiapplication->next;
3802 __ps_free_uiapplication(uiapplication);
3803 uiapplication = tmp;
3806 /*Free ServiceApplication*/
3807 if (mfx->serviceapplication) {
3808 serviceapplication_x *serviceapplication = mfx->serviceapplication;
3809 serviceapplication_x *tmp = NULL;
3810 while(serviceapplication != NULL) {
3811 tmp = serviceapplication->next;
3812 __ps_free_serviceapplication(serviceapplication);
3813 serviceapplication = tmp;
3818 daemon_x *daemon = mfx->daemon;
3819 daemon_x *tmp = NULL;
3820 while(daemon != NULL) {
3822 __ps_free_daemon(daemon);
3828 theme_x *theme = mfx->theme;
3829 theme_x *tmp = NULL;
3830 while(theme != NULL) {
3832 __ps_free_theme(theme);
3838 font_x *font = mfx->font;
3840 while(font != NULL) {
3842 __ps_free_font(font);
3848 ime_x *ime = mfx->ime;
3850 while(ime != NULL) {
3856 /*Free Compatibility*/
3857 if (mfx->compatibility) {
3858 compatibility_x *compatibility = mfx->compatibility;
3859 compatibility_x *tmp = NULL;
3860 while(compatibility != NULL) {
3861 tmp = compatibility->next;
3862 __ps_free_compatibility(compatibility);
3863 compatibility = tmp;
3866 /*Free DeviceProfile*/
3867 if (mfx->deviceprofile) {
3868 deviceprofile_x *deviceprofile = mfx->deviceprofile;
3869 deviceprofile_x *tmp = NULL;
3870 while(deviceprofile != NULL) {
3871 tmp = deviceprofile->next;
3872 __ps_free_deviceprofile(deviceprofile);
3873 deviceprofile = tmp;
3881 API manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest)
3883 DBG("parsing start\n");
3884 xmlTextReaderPtr reader;
3885 manifest_x *mfx = NULL;
3887 reader = xmlReaderForFile(manifest, NULL, 0);
3889 mfx = malloc(sizeof(manifest_x));
3891 memset(mfx, '\0', sizeof(manifest_x));
3892 if (__process_manifest(reader, mfx) < 0) {
3893 DBG("Parsing Failed\n");
3894 pkgmgr_parser_free_manifest_xml(mfx);
3897 DBG("Parsing Success\n");
3899 DBG("Memory allocation error\n");
3901 xmlFreeTextReader(reader);
3903 DBG("Unable to create xml reader\n");
3908 /* These APIs are intended to call parser directly */
3910 API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
3912 char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", NULL};
3913 if (manifest == NULL) {
3914 DBG("argument supplied is NULL\n");
3915 return PMINFO_R_EINVAL;
3917 DBG("parsing manifest for installation: %s\n", manifest);
3918 manifest_x *mfx = NULL;
3920 char roxml_check[PKG_STRING_LEN_MAX] = {'\0'};
3923 mfx = pkgmgr_parser_process_manifest_xml(manifest);
3924 DBG("Parsing Finished\n");
3926 return PMINFO_R_ERROR;
3928 __streamFile(manifest, ACTION_INSTALL, temp, mfx->package);
3929 __add_preload_info(mfx, manifest);
3930 DBG("Added preload infomation\n");
3932 snprintf(roxml_check, PKG_STRING_LEN_MAX, MANIFEST_RO_DIRECTORY "/%s.xml", mfx->package);
3933 if (access(roxml_check, F_OK) == 0)
3934 mfx->update = strdup("true");
3936 mfx->update = strdup("false");
3938 ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
3940 DBG("DB Insert failed\n");
3942 DBG("DB Insert Success\n");
3944 ret = __ps_make_nativeapp_desktop(mfx, 0);
3946 DBG("Creating desktop file failed\n");
3948 DBG("Creating desktop file Success\n");
3950 pkgmgr_parser_free_manifest_xml(mfx);
3957 API int pkgmgr_parser_create_desktop_file(manifest_x *mfx)
3961 DBG("Manifest pointer is NULL\n");
3964 ret = __ps_make_nativeapp_desktop(mfx, 0);
3966 DBG("Creating desktop file failed\n");
3968 DBG("Creating desktop file Success\n");
3973 API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
3975 char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", NULL};
3976 if (manifest == NULL) {
3977 DBG("argument supplied is NULL\n");
3978 return PMINFO_R_EINVAL;
3980 DBG("parsing manifest for upgradation: %s\n", manifest);
3981 manifest_x *mfx = NULL;
3984 mfx = pkgmgr_parser_process_manifest_xml(manifest);
3985 DBG("Parsing Finished\n");
3987 return PMINFO_R_ERROR;
3989 __streamFile(manifest, ACTION_UPGRADE, temp, mfx->package);
3990 __add_preload_info(mfx, manifest);
3991 DBG("Added preload infomation\n");
3993 mfx->update = strdup("true");
3994 ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
3996 DBG("DB Update failed\n");
3998 DBG("DB Update Success\n");
4000 ret = __ps_make_nativeapp_desktop(mfx, 1);
4002 DBG("Creating desktop file failed\n");
4004 DBG("Creating desktop file Success\n");
4006 pkgmgr_parser_free_manifest_xml(mfx);
4013 API int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[])
4015 char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", NULL};
4016 if (manifest == NULL) {
4017 DBG("argument supplied is NULL\n");
4018 return PMINFO_R_EINVAL;
4020 DBG("parsing manifest for uninstallation: %s\n", manifest);
4021 manifest_x *mfx = NULL;
4024 mfx = pkgmgr_parser_process_manifest_xml(manifest);
4025 DBG("Parsing Finished\n");
4027 return PMINFO_R_ERROR;
4029 __streamFile(manifest, ACTION_UNINSTALL, temp, mfx->package);
4030 __add_preload_info(mfx, manifest);
4031 DBG("Added preload infomation\n");
4033 ret = pkgmgr_parser_delete_manifest_info_from_db(mfx);
4035 DBG("DB Delete failed\n");
4037 DBG("DB Delete Success\n");
4039 ret = __ps_remove_nativeapp_desktop(mfx);
4041 DBG("Removing desktop file failed\n");
4043 DBG("Removing desktop file Success\n");
4045 pkgmgr_parser_free_manifest_xml(mfx);
4052 API char *pkgmgr_parser_get_manifest_file(const char *pkgid)
4054 return __pkgid_to_manifest(pkgid);
4057 API int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
4059 return __ps_run_parser(docPtr, tag, ACTION_INSTALL, pkgid);
4062 API int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgid)
4064 return __ps_run_parser(docPtr, tag, ACTION_UPGRADE, pkgid);
4067 API int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
4069 return __ps_run_parser(docPtr, tag, ACTION_UNINSTALL, pkgid);
4072 #define SCHEMA_FILE "/usr/etc/package-manager/preload/manifest.xsd"
4074 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
4076 if (manifest == NULL) {
4077 DBGE("manifest file is NULL\n");
4078 return PMINFO_R_EINVAL;
4081 xmlSchemaParserCtxtPtr ctx;
4082 xmlSchemaValidCtxtPtr vctx;
4083 xmlSchemaPtr xschema;
4084 ctx = xmlSchemaNewParserCtxt(SCHEMA_FILE);
4086 DBGE("xmlSchemaNewParserCtxt() Failed\n");
4087 return PMINFO_R_ERROR;
4089 xschema = xmlSchemaParse(ctx);
4090 if (xschema == NULL) {
4091 DBGE("xmlSchemaParse() Failed\n");
4092 return PMINFO_R_ERROR;
4094 vctx = xmlSchemaNewValidCtxt(xschema);
4096 DBGE("xmlSchemaNewValidCtxt() Failed\n");
4097 return PMINFO_R_ERROR;
4099 xmlSchemaSetValidErrors(vctx, (xmlSchemaValidityErrorFunc) fprintf, (xmlSchemaValidityWarningFunc) fprintf, stderr);
4100 ret = xmlSchemaValidateFile(vctx, manifest, 0);
4102 DBGE("xmlSchemaValidateFile() failed\n");
4103 return PMINFO_R_ERROR;
4104 } else if (ret == 0) {
4105 DBGE("Manifest is Valid\n");
4108 DBGE("Manifest Validation Failed with error code %d\n", ret);
4109 return PMINFO_R_ERROR;
4115 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
4125 DBGE("fork failed\n");
4130 int dev_null_fd = open ("/dev/null", O_RDWR);
4131 if (dev_null_fd >= 0)
4133 dup2 (dev_null_fd, 0);/*stdin*/
4134 dup2 (dev_null_fd, 1);/*stdout*/
4135 dup2 (dev_null_fd, 2);/*stderr*/
4138 if (execl("/usr/bin/xmllint", "xmllint", manifest, "--schema",
4139 SCHEMA_FILE, NULL) < 0) {
4140 DBGE("execl error\n");
4150 while ((err = waitpid(pid, &status, WNOHANG)) != pid) {
4154 DBGE("waitpid failed\n");
4160 if(WIFEXITED(status) && !WEXITSTATUS(status))