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 *);
286 ac = "PKGMGR_PARSER_PLUGIN_INSTALL";
289 ac = "PKGMGR_PARSER_PLUGIN_UPGRADE";
291 case ACTION_UNINSTALL:
292 ac = "PKGMGR_PARSER_PLUGIN_UNINSTALL";
298 lib_path = __get_parser_plugin(tag);
306 DBGE("fork() failed\n");
310 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
311 DBGE("dlopen is failed lib_path[%s]\n", lib_path);
314 if ((plugin_install =
315 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
316 DBGE("can not find symbol \n");
321 ret = plugin_install(docPtr, pkgid);
328 w = waitpid(cpid, &status, WUNTRACED | WCONTINUED);
330 DBGE("waitpid() failed\n");
333 } while (!WIFEXITED(status) && !WIFSIGNALED(status));
334 if (WIFEXITED(status))
335 ret = WEXITSTATUS(status);
336 else if (WIFSIGNALED(status))
337 ret = WTERMSIG(status);
340 DBGE("Child exit status=%d\n", ret);
349 static char *__pkgid_to_manifest(const char *pkgid)
355 DBGE("pkgid is NULL");
359 size = strlen(MANIFEST_RW_DIRECTORY) + strlen(pkgid) + 10;
360 manifest = malloc(size);
361 if (manifest == NULL) {
365 memset(manifest, '\0', size);
366 snprintf(manifest, size, MANIFEST_RW_DIRECTORY "/%s.xml", pkgid);
368 if (access(manifest, F_OK)) {
369 snprintf(manifest, size, MANIFEST_RO_DIRECTORY "/%s.xml", pkgid);
375 static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid)
380 DBG("__run_parser_prestep");
382 if (xmlTextReaderDepth(reader) != 1) {
383 DBGE("Node depth is not 1");
387 if (xmlTextReaderNodeType(reader) != 1) {
388 DBGE("Node type is not 1");
392 const xmlChar *value;
393 name = xmlTextReaderConstName(reader);
395 DBGE("TEST TEST TES\n");
396 name = BAD_CAST "--";
399 value = xmlTextReaderConstValue(reader);
400 DBG("%d %d %s %d %d",
401 xmlTextReaderDepth(reader),
402 xmlTextReaderNodeType(reader),
404 xmlTextReaderIsEmptyElement(reader), xmlTextReaderHasValue(reader));
407 DBG("ConstValue NULL");
409 if (xmlStrlen(value) > 40) {
410 DBG(" %.40s...", value);
416 name = xmlTextReaderConstName(reader);
418 DBGE("TEST TEST TES\n");
419 name = BAD_CAST "--";
422 xmlDocPtr docPtr = xmlTextReaderCurrentDoc(reader);
423 DBG("docPtr->URL %s\n", (char *)docPtr->URL);
424 xmlDocPtr copyDocPtr = xmlCopyDoc(docPtr, 1);
425 if (copyDocPtr == NULL)
427 xmlNode *rootElement = xmlDocGetRootElement(copyDocPtr);
428 if (rootElement == NULL)
430 xmlNode *cur_node = xmlFirstElementChild(rootElement);
431 if (cur_node == NULL)
433 xmlNode *temp = xmlTextReaderExpand(reader);
436 xmlNode *next_node = NULL;
437 while(cur_node != NULL) {
438 if ( (strcmp(ASCII(temp->name), ASCII(cur_node->name)) == 0) &&
439 (temp->line == cur_node->line) ) {
443 next_node = xmlNextElementSibling(cur_node);
444 xmlUnlinkNode(cur_node);
445 xmlFreeNode(cur_node);
446 cur_node = next_node;
449 if (cur_node == NULL)
451 next_node = xmlNextElementSibling(cur_node);
453 cur_node->next = NULL;
454 next_node->prev = NULL;
455 xmlFreeNodeList(next_node);
456 xmlSetTreeDoc(cur_node, copyDocPtr);
458 xmlSetTreeDoc(cur_node, copyDocPtr);
464 DBG("node type: %d, name: %s children->name: %s last->name: %s\n"
465 "parent->name: %s next->name: %s prev->name: %s\n",
466 cur_node->type, cur_node->name,
467 cur_node->children ? cur_node->children->name : "NULL",
468 cur_node->last ? cur_node->last->name : "NULL",
469 cur_node->parent ? cur_node->parent->name : "NULL",
470 cur_node->next ? cur_node->next->name : "NULL",
471 cur_node->prev ? cur_node->prev->name : "NULL");
473 FILE *fp = fopen("/opt/share/test.xml", "a");
474 xmlDocDump(fp, copyDocPtr);
479 ret = __ps_run_parser(copyDocPtr, ASCII(name), action, pkgid);
486 __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgid)
491 switch (xmlTextReaderNodeType(reader)) {
492 case XML_READER_TYPE_END_ELEMENT:
494 // DBG("XML_READER_TYPE_END_ELEMENT");
498 case XML_READER_TYPE_ELEMENT:
500 // Elements without closing tag don't receive
501 // XML_READER_TYPE_END_ELEMENT event.
503 const xmlChar *elementName =
504 xmlTextReaderLocalName(reader);
505 if (elementName == NULL) {
506 // DBG("elementName %s\n", (char *)elementName);
510 const xmlChar *nameSpace =
511 xmlTextReaderConstNamespaceUri(reader);
513 // DBG("nameSpace %s\n", (char *)nameSpace);
516 DBG("XML_READER_TYPE_ELEMENT %s, %s\n",
517 elementName ? elementName : "NULL",
518 nameSpace ? nameSpace : "NULL");
521 DBG("__run_parser_prestep pkgid[%s]\n", pkgid);
522 __run_parser_prestep(reader, action, pkgid);
526 for (tag = tagv[0]; tag; tag = tagv[++i])
527 if (strcmp(tag, ASCII(elementName)) == 0) {
528 DBG("__run_parser_prestep tag[%s] pkgid[%s]\n", tag, pkgid);
529 __run_parser_prestep(reader,
537 case XML_READER_TYPE_TEXT:
538 case XML_READER_TYPE_CDATA:
540 const xmlChar *value = xmlTextReaderConstValue(reader);
542 // DBG("value %s\n", value);
545 const xmlChar *lang = xmlTextReaderConstXmlLang(reader);
547 // DBG("lang\n", lang);
550 /* DBG("XML_READER_TYPE_TEXT %s, %s\n",
551 value ? value : "NULL", lang ? lang : "NULL");
556 // DBG("Ignoring Node of Type: %d", xmlTextReaderNodeType(reader));
562 __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid)
564 xmlTextReaderPtr reader;
568 docPtr = xmlReadFile(filename, NULL, 0);
569 reader = xmlReaderWalker(docPtr);
570 if (reader != NULL) {
571 ret = xmlTextReaderRead(reader);
573 __processNode(reader, action, tagv, pkgid);
574 ret = xmlTextReaderRead(reader);
576 xmlFreeTextReader(reader);
579 DBGE("%s : failed to parse", filename);
582 DBGE("Unable to open %s", filename);
586 static int __next_child_element(xmlTextReaderPtr reader, int depth)
588 int ret = xmlTextReaderRead(reader);
589 int cur = xmlTextReaderDepth(reader);
592 switch (xmlTextReaderNodeType(reader)) {
593 case XML_READER_TYPE_ELEMENT:
594 if (cur == depth + 1)
597 case XML_READER_TYPE_TEXT:
598 /*text is handled by each function separately*/
599 if (cur == depth + 1)
602 case XML_READER_TYPE_END_ELEMENT:
611 ret = xmlTextReaderRead(reader);
612 cur = xmlTextReaderDepth(reader);
617 static void __ps_free_category(category_x *category)
619 if (category == NULL)
621 if (category->name) {
622 free((void *)category->name);
623 category->name = NULL;
625 free((void*)category);
629 static void __ps_free_privilege(privilege_x *privilege)
631 if (privilege == NULL)
633 if (privilege->text) {
634 free((void *)privilege->text);
635 privilege->text = NULL;
637 free((void*)privilege);
641 static void __ps_free_privileges(privileges_x *privileges)
643 if (privileges == NULL)
646 if (privileges->privilege) {
647 privilege_x *privilege = privileges->privilege;
648 privilege_x *tmp = NULL;
649 while(privilege != NULL) {
650 tmp = privilege->next;
651 __ps_free_privilege(privilege);
655 free((void*)privileges);
659 static void __ps_free_metadata(metadata_x *metadata)
661 if (metadata == NULL)
664 free((void *)metadata->key);
665 metadata->key = NULL;
667 if (metadata->value) {
668 free((void *)metadata->value);
669 metadata->value = NULL;
671 free((void*)metadata);
675 static void __ps_free_permission(permission_x *permission)
677 if (permission == NULL)
679 if (permission->type) {
680 free((void *)permission->type);
681 permission->type = NULL;
683 if (permission->value) {
684 free((void *)permission->value);
685 permission->value = NULL;
687 free((void*)permission);
691 static void __ps_free_icon(icon_x *icon)
696 free((void *)icon->text);
700 free((void *)icon->lang);
704 free((void *)icon->name);
708 free((void *)icon->section);
709 icon->section = NULL;
712 free((void *)icon->size);
715 if (icon->resolution) {
716 free((void *)icon->resolution);
717 icon->resolution = NULL;
723 static void __ps_free_image(image_x *image)
728 free((void *)image->text);
732 free((void *)image->lang);
736 free((void *)image->name);
739 if (image->section) {
740 free((void *)image->section);
741 image->section = NULL;
747 static void __ps_free_operation(operation_x *operation)
749 if (operation == NULL)
751 if (operation->text) {
752 free((void *)operation->text);
753 operation->text = NULL;
755 free((void*)operation);
759 static void __ps_free_uri(uri_x *uri)
764 free((void *)uri->text);
771 static void __ps_free_mime(mime_x *mime)
776 free((void *)mime->text);
783 static void __ps_free_subapp(subapp_x *subapp)
788 free((void *)subapp->text);
795 static void __ps_free_condition(condition_x *condition)
797 if (condition == NULL)
799 if (condition->text) {
800 free((void *)condition->text);
801 condition->text = NULL;
803 if (condition->name) {
804 free((void *)condition->name);
805 condition->name = NULL;
807 free((void*)condition);
811 static void __ps_free_notification(notification_x *notification)
813 if (notification == NULL)
815 if (notification->text) {
816 free((void *)notification->text);
817 notification->text = NULL;
819 if (notification->name) {
820 free((void *)notification->name);
821 notification->name = NULL;
823 free((void*)notification);
827 static void __ps_free_compatibility(compatibility_x *compatibility)
829 if (compatibility == NULL)
831 if (compatibility->text) {
832 free((void *)compatibility->text);
833 compatibility->text = NULL;
835 if (compatibility->name) {
836 free((void *)compatibility->name);
837 compatibility->name = NULL;
839 free((void*)compatibility);
840 compatibility = NULL;
843 static void __ps_free_resolution(resolution_x *resolution)
845 if (resolution == NULL)
847 if (resolution->mimetype) {
848 free((void *)resolution->mimetype);
849 resolution->mimetype = NULL;
851 if (resolution->urischeme) {
852 free((void *)resolution->urischeme);
853 resolution->urischeme = NULL;
855 free((void*)resolution);
859 static void __ps_free_capability(capability_x *capability)
861 if (capability == NULL)
863 if (capability->operationid) {
864 free((void *)capability->operationid);
865 capability->operationid = NULL;
868 if (capability->resolution) {
869 resolution_x *resolution = capability->resolution;
870 resolution_x *tmp = NULL;
871 while(resolution != NULL) {
872 tmp = resolution->next;
873 __ps_free_resolution(resolution);
877 free((void*)capability);
881 static void __ps_free_allowed(allowed_x *allowed)
886 free((void *)allowed->name);
887 allowed->name = NULL;
890 free((void *)allowed->text);
891 allowed->text = NULL;
893 free((void*)allowed);
897 static void __ps_free_request(request_x *request)
902 free((void *)request->text);
903 request->text = NULL;
905 free((void*)request);
909 static void __ps_free_datacontrol(datacontrol_x *datacontrol)
911 if (datacontrol == NULL)
913 if (datacontrol->providerid) {
914 free((void *)datacontrol->providerid);
915 datacontrol->providerid = NULL;
918 if (datacontrol->capability) {
919 capability_x *capability = datacontrol->capability;
920 capability_x *tmp = NULL;
921 while(capability != NULL) {
922 tmp = capability->next;
923 __ps_free_capability(capability);
927 free((void*)datacontrol);
931 static void __ps_free_launchconditions(launchconditions_x *launchconditions)
933 if (launchconditions == NULL)
935 if (launchconditions->text) {
936 free((void *)launchconditions->text);
937 launchconditions->text = NULL;
940 if (launchconditions->condition) {
941 condition_x *condition = launchconditions->condition;
942 condition_x *tmp = NULL;
943 while(condition != NULL) {
944 tmp = condition->next;
945 __ps_free_condition(condition);
949 free((void*)launchconditions);
950 launchconditions = NULL;
953 static void __ps_free_appcontrol(appcontrol_x *appcontrol)
955 if (appcontrol == NULL)
957 if (appcontrol->text) {
958 free((void *)appcontrol->text);
959 appcontrol->text = NULL;
962 if (appcontrol->operation) {
963 operation_x *operation = appcontrol->operation;
964 operation_x *tmp = NULL;
965 while(operation != NULL) {
966 tmp = operation->next;
967 __ps_free_operation(operation);
972 if (appcontrol->uri) {
973 uri_x *uri = appcontrol->uri;
982 if (appcontrol->mime) {
983 mime_x *mime = appcontrol->mime;
985 while(mime != NULL) {
987 __ps_free_mime(mime);
992 if (appcontrol->subapp) {
993 subapp_x *subapp = appcontrol->subapp;
994 subapp_x *tmp = NULL;
995 while(subapp != NULL) {
997 __ps_free_subapp(subapp);
1001 free((void*)appcontrol);
1005 static void __ps_free_appsvc(appsvc_x *appsvc)
1010 free((void *)appsvc->text);
1011 appsvc->text = NULL;
1014 if (appsvc->operation) {
1015 operation_x *operation = appsvc->operation;
1016 operation_x *tmp = NULL;
1017 while(operation != NULL) {
1018 tmp = operation->next;
1019 __ps_free_operation(operation);
1025 uri_x *uri = appsvc->uri;
1027 while(uri != NULL) {
1035 mime_x *mime = appsvc->mime;
1037 while(mime != NULL) {
1039 __ps_free_mime(mime);
1044 if (appsvc->subapp) {
1045 subapp_x *subapp = appsvc->subapp;
1046 subapp_x *tmp = NULL;
1047 while(subapp != NULL) {
1049 __ps_free_subapp(subapp);
1053 free((void*)appsvc);
1057 static void __ps_free_deviceprofile(deviceprofile_x *deviceprofile)
1062 static void __ps_free_define(define_x *define)
1067 free((void *)define->path);
1068 define->path = NULL;
1071 if (define->request) {
1072 request_x *request = define->request;
1073 request_x *tmp = NULL;
1074 while(request != NULL) {
1075 tmp = request->next;
1076 __ps_free_request(request);
1081 if (define->allowed) {
1082 allowed_x *allowed = define->allowed;
1083 allowed_x *tmp = NULL;
1084 while(allowed != NULL) {
1085 tmp = allowed->next;
1086 __ps_free_allowed(allowed);
1090 free((void*)define);
1094 static void __ps_free_datashare(datashare_x *datashare)
1096 if (datashare == NULL)
1099 if (datashare->define) {
1100 define_x *define = datashare->define;
1101 define_x *tmp = NULL;
1102 while(define != NULL) {
1104 __ps_free_define(define);
1109 if (datashare->request) {
1110 request_x *request = datashare->request;
1111 request_x *tmp = NULL;
1112 while(request != NULL) {
1113 tmp = request->next;
1114 __ps_free_request(request);
1118 free((void*)datashare);
1122 static void __ps_free_label(label_x *label)
1127 free((void *)label->name);
1131 free((void *)label->text);
1135 free((void *)label->lang);
1142 static void __ps_free_author(author_x *author)
1146 if (author->email) {
1147 free((void *)author->email);
1148 author->email = NULL;
1151 free((void *)author->text);
1152 author->text = NULL;
1155 free((void *)author->href);
1156 author->href = NULL;
1159 free((void *)author->lang);
1160 author->lang = NULL;
1162 free((void*)author);
1166 static void __ps_free_description(description_x *description)
1168 if (description == NULL)
1170 if (description->name) {
1171 free((void *)description->name);
1172 description->name = NULL;
1174 if (description->text) {
1175 free((void *)description->text);
1176 description->text = NULL;
1178 if (description->lang) {
1179 free((void *)description->lang);
1180 description->lang = NULL;
1182 free((void*)description);
1186 static void __ps_free_license(license_x *license)
1188 if (license == NULL)
1190 if (license->text) {
1191 free((void *)license->text);
1192 license->text = NULL;
1194 if (license->lang) {
1195 free((void *)license->lang);
1196 license->lang = NULL;
1198 free((void*)license);
1202 static void __ps_free_uiapplication(uiapplication_x *uiapplication)
1204 if (uiapplication == NULL)
1206 if (uiapplication->exec) {
1207 free((void *)uiapplication->exec);
1208 uiapplication->exec = NULL;
1210 if (uiapplication->appid) {
1211 free((void *)uiapplication->appid);
1212 uiapplication->appid = NULL;
1214 if (uiapplication->nodisplay) {
1215 free((void *)uiapplication->nodisplay);
1216 uiapplication->nodisplay = NULL;
1218 if (uiapplication->multiple) {
1219 free((void *)uiapplication->multiple);
1220 uiapplication->multiple = NULL;
1222 if (uiapplication->type) {
1223 free((void *)uiapplication->type);
1224 uiapplication->type = NULL;
1226 if (uiapplication->categories) {
1227 free((void *)uiapplication->categories);
1228 uiapplication->categories = NULL;
1230 if (uiapplication->extraid) {
1231 free((void *)uiapplication->extraid);
1232 uiapplication->extraid = NULL;
1234 if (uiapplication->taskmanage) {
1235 free((void *)uiapplication->taskmanage);
1236 uiapplication->taskmanage = NULL;
1238 if (uiapplication->enabled) {
1239 free((void *)uiapplication->enabled);
1240 uiapplication->enabled = NULL;
1242 if (uiapplication->hwacceleration) {
1243 free((void *)uiapplication->hwacceleration);
1244 uiapplication->hwacceleration = NULL;
1246 if (uiapplication->mainapp) {
1247 free((void *)uiapplication->mainapp);
1248 uiapplication->mainapp = NULL;
1250 if (uiapplication->recentimage) {
1251 free((void *)uiapplication->recentimage);
1252 uiapplication->recentimage = NULL;
1254 if (uiapplication->package) {
1255 free((void *)uiapplication->package);
1256 uiapplication->package = NULL;
1259 if (uiapplication->label) {
1260 label_x *label = uiapplication->label;
1261 label_x *tmp = NULL;
1262 while(label != NULL) {
1264 __ps_free_label(label);
1269 if (uiapplication->icon) {
1270 icon_x *icon = uiapplication->icon;
1272 while(icon != NULL) {
1274 __ps_free_icon(icon);
1279 if (uiapplication->image) {
1280 image_x *image = uiapplication->image;
1281 image_x *tmp = NULL;
1282 while(image != NULL) {
1284 __ps_free_image(image);
1289 if (uiapplication->appcontrol) {
1290 appcontrol_x *appcontrol = uiapplication->appcontrol;
1291 appcontrol_x *tmp = NULL;
1292 while(appcontrol != NULL) {
1293 tmp = appcontrol->next;
1294 __ps_free_appcontrol(appcontrol);
1298 /*Free LaunchConditions*/
1299 if (uiapplication->launchconditions) {
1300 launchconditions_x *launchconditions = uiapplication->launchconditions;
1301 launchconditions_x *tmp = NULL;
1302 while(launchconditions != NULL) {
1303 tmp = launchconditions->next;
1304 __ps_free_launchconditions(launchconditions);
1305 launchconditions = tmp;
1308 /*Free Notification*/
1309 if (uiapplication->notification) {
1310 notification_x *notification = uiapplication->notification;
1311 notification_x *tmp = NULL;
1312 while(notification != NULL) {
1313 tmp = notification->next;
1314 __ps_free_notification(notification);
1319 if (uiapplication->datashare) {
1320 datashare_x *datashare = uiapplication->datashare;
1321 datashare_x *tmp = NULL;
1322 while(datashare != NULL) {
1323 tmp = datashare->next;
1324 __ps_free_datashare(datashare);
1329 if (uiapplication->appsvc) {
1330 appsvc_x *appsvc = uiapplication->appsvc;
1331 appsvc_x *tmp = NULL;
1332 while(appsvc != NULL) {
1334 __ps_free_appsvc(appsvc);
1339 if (uiapplication->category) {
1340 category_x *category = uiapplication->category;
1341 category_x *tmp = NULL;
1342 while(category != NULL) {
1343 tmp = category->next;
1344 __ps_free_category(category);
1349 if (uiapplication->metadata) {
1350 metadata_x *metadata = uiapplication->metadata;
1351 metadata_x *tmp = NULL;
1352 while(metadata != NULL) {
1353 tmp = metadata->next;
1354 __ps_free_metadata(metadata);
1359 if (uiapplication->permission) {
1360 permission_x *permission = uiapplication->permission;
1361 permission_x *tmp = NULL;
1362 while(permission != NULL) {
1363 tmp = permission->next;
1364 __ps_free_permission(permission);
1368 /* _PRODUCT_LAUNCHING_ENHANCED_ START */
1369 if (uiapplication->indicatordisplay) {
1370 free((void *)uiapplication->indicatordisplay);
1371 uiapplication->indicatordisplay = NULL;
1373 if (uiapplication->portraitimg) {
1374 free((void *)uiapplication->portraitimg);
1375 uiapplication->portraitimg = NULL;
1377 if (uiapplication->landscapeimg) {
1378 free((void *)uiapplication->landscapeimg);
1379 uiapplication->landscapeimg = NULL;
1381 /* _PRODUCT_LAUNCHING_ENHANCED_ END */
1382 if (uiapplication->guestmode_visibility) {
1383 free((void *)uiapplication->guestmode_visibility);
1384 uiapplication->guestmode_visibility = NULL;
1386 free((void*)uiapplication);
1387 uiapplication = NULL;
1390 static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication)
1392 if (serviceapplication == NULL)
1394 if (serviceapplication->exec) {
1395 free((void *)serviceapplication->exec);
1396 serviceapplication->exec = NULL;
1398 if (serviceapplication->appid) {
1399 free((void *)serviceapplication->appid);
1400 serviceapplication->appid = NULL;
1402 if (serviceapplication->onboot) {
1403 free((void *)serviceapplication->onboot);
1404 serviceapplication->onboot = NULL;
1406 if (serviceapplication->autorestart) {
1407 free((void *)serviceapplication->autorestart);
1408 serviceapplication->autorestart = NULL;
1410 if (serviceapplication->type) {
1411 free((void *)serviceapplication->type);
1412 serviceapplication->type = NULL;
1414 if (serviceapplication->enabled) {
1415 free((void *)serviceapplication->enabled);
1416 serviceapplication->enabled = NULL;
1418 if (serviceapplication->package) {
1419 free((void *)serviceapplication->package);
1420 serviceapplication->package = NULL;
1423 if (serviceapplication->label) {
1424 label_x *label = serviceapplication->label;
1425 label_x *tmp = NULL;
1426 while(label != NULL) {
1428 __ps_free_label(label);
1433 if (serviceapplication->icon) {
1434 icon_x *icon = serviceapplication->icon;
1436 while(icon != NULL) {
1438 __ps_free_icon(icon);
1443 if (serviceapplication->appcontrol) {
1444 appcontrol_x *appcontrol = serviceapplication->appcontrol;
1445 appcontrol_x *tmp = NULL;
1446 while(appcontrol != NULL) {
1447 tmp = appcontrol->next;
1448 __ps_free_appcontrol(appcontrol);
1452 /*Free DataControl*/
1453 if (serviceapplication->datacontrol) {
1454 datacontrol_x *datacontrol = serviceapplication->datacontrol;
1455 datacontrol_x *tmp = NULL;
1456 while(datacontrol != NULL) {
1457 tmp = datacontrol->next;
1458 __ps_free_datacontrol(datacontrol);
1462 /*Free LaunchConditions*/
1463 if (serviceapplication->launchconditions) {
1464 launchconditions_x *launchconditions = serviceapplication->launchconditions;
1465 launchconditions_x *tmp = NULL;
1466 while(launchconditions != NULL) {
1467 tmp = launchconditions->next;
1468 __ps_free_launchconditions(launchconditions);
1469 launchconditions = tmp;
1472 /*Free Notification*/
1473 if (serviceapplication->notification) {
1474 notification_x *notification = serviceapplication->notification;
1475 notification_x *tmp = NULL;
1476 while(notification != NULL) {
1477 tmp = notification->next;
1478 __ps_free_notification(notification);
1483 if (serviceapplication->datashare) {
1484 datashare_x *datashare = serviceapplication->datashare;
1485 datashare_x *tmp = NULL;
1486 while(datashare != NULL) {
1487 tmp = datashare->next;
1488 __ps_free_datashare(datashare);
1493 if (serviceapplication->appsvc) {
1494 appsvc_x *appsvc = serviceapplication->appsvc;
1495 appsvc_x *tmp = NULL;
1496 while(appsvc != NULL) {
1498 __ps_free_appsvc(appsvc);
1503 if (serviceapplication->category) {
1504 category_x *category = serviceapplication->category;
1505 category_x *tmp = NULL;
1506 while(category != NULL) {
1507 tmp = category->next;
1508 __ps_free_category(category);
1513 if (serviceapplication->metadata) {
1514 metadata_x *metadata = serviceapplication->metadata;
1515 metadata_x *tmp = NULL;
1516 while(metadata != NULL) {
1517 tmp = metadata->next;
1518 __ps_free_metadata(metadata);
1523 if (serviceapplication->permission) {
1524 permission_x *permission = serviceapplication->permission;
1525 permission_x *tmp = NULL;
1526 while(permission != NULL) {
1527 tmp = permission->next;
1528 __ps_free_permission(permission);
1532 free((void*)serviceapplication);
1533 serviceapplication = NULL;
1536 static void __ps_free_font(font_x *font)
1541 free((void *)font->name);
1545 free((void *)font->text);
1552 static void __ps_free_theme(theme_x *theme)
1557 free((void *)theme->name);
1561 free((void *)theme->text);
1568 static void __ps_free_daemon(daemon_x *daemon)
1573 free((void *)daemon->name);
1574 daemon->name = NULL;
1577 free((void *)daemon->text);
1578 daemon->text = NULL;
1580 free((void*)daemon);
1584 static void __ps_free_ime(ime_x *ime)
1589 free((void *)ime->name);
1593 free((void *)ime->text);
1601 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed)
1603 xmlTextReaderRead(reader);
1604 if (xmlTextReaderValue(reader))
1605 allowed->text = ASCII(xmlTextReaderValue(reader));
1609 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation)
1611 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1612 operation->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1613 /* Text does not exist. Only attribute exists
1614 xmlTextReaderRead(reader);
1615 if (xmlTextReaderValue(reader))
1616 operation->text = ASCII(xmlTextReaderValue(reader));
1621 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri)
1623 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1624 uri->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1625 /* Text does not exist. Only attribute exists
1626 xmlTextReaderRead(reader);
1627 if (xmlTextReaderValue(reader))
1628 uri->text = ASCII(xmlTextReaderValue(reader));
1633 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime)
1635 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1636 mime->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1637 /* Text does not exist. Only attribute exists
1638 xmlTextReaderRead(reader);
1639 if (xmlTextReaderValue(reader))
1640 mime->text = ASCII(xmlTextReaderValue(reader));
1645 static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp)
1647 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1648 subapp->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1649 /* Text does not exist. Only attribute exists
1650 xmlTextReaderRead(reader);
1651 if (xmlTextReaderValue(reader))
1652 mime->text = ASCII(xmlTextReaderValue(reader));
1657 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition)
1659 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1660 condition->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1661 xmlTextReaderRead(reader);
1662 if (xmlTextReaderValue(reader))
1663 condition->text = ASCII(xmlTextReaderValue(reader));
1667 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notification)
1669 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1670 notification->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1671 xmlTextReaderRead(reader);
1672 if (xmlTextReaderValue(reader))
1673 notification->text = ASCII(xmlTextReaderValue(reader));
1677 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category)
1679 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1680 category->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1684 static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege)
1686 xmlTextReaderRead(reader);
1687 if (xmlTextReaderValue(reader)) {
1688 privilege->text = ASCII(xmlTextReaderValue(reader));
1693 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata)
1695 if (xmlTextReaderGetAttribute(reader, XMLCHAR("key")))
1696 metadata->key = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("key")));
1697 if (xmlTextReaderGetAttribute(reader, XMLCHAR("value")))
1698 metadata->value = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("value")));
1702 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission)
1704 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
1705 permission->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
1707 xmlTextReaderRead(reader);
1708 if (xmlTextReaderValue(reader))
1709 permission->value = ASCII(xmlTextReaderValue(reader));
1713 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility)
1715 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1716 compatibility->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1717 xmlTextReaderRead(reader);
1718 if (xmlTextReaderValue(reader))
1719 compatibility->text = ASCII(xmlTextReaderValue(reader));
1723 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution)
1725 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")))
1726 resolution->mimetype = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")));
1727 if (xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")))
1728 resolution->urischeme = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")));
1732 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request)
1734 xmlTextReaderRead(reader);
1735 if (xmlTextReaderValue(reader))
1736 request->text = ASCII(xmlTextReaderValue(reader));
1740 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define)
1742 const xmlChar *node;
1745 allowed_x *tmp1 = NULL;
1746 request_x *tmp2 = NULL;
1748 if (xmlTextReaderGetAttribute(reader, XMLCHAR("path")))
1749 define->path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("path")));
1751 depth = xmlTextReaderDepth(reader);
1752 while ((ret = __next_child_element(reader, depth))) {
1753 node = xmlTextReaderConstName(reader);
1755 DBG("xmlTextReaderConstName value is NULL\n");
1759 if (!strcmp(ASCII(node), "allowed")) {
1760 allowed_x *allowed= malloc(sizeof(allowed_x));
1761 if (allowed == NULL) {
1762 DBG("Malloc Failed\n");
1765 memset(allowed, '\0', sizeof(allowed_x));
1766 LISTADD(define->allowed, allowed);
1767 ret = __ps_process_allowed(reader, allowed);
1768 } else if (!strcmp(ASCII(node), "request")) {
1769 request_x *request = malloc(sizeof(request_x));
1770 if (request == NULL) {
1771 DBG("Malloc Failed\n");
1774 memset(request, '\0', sizeof(request_x));
1775 LISTADD(define->request, request);
1776 ret = __ps_process_request(reader, request);
1780 DBG("Processing define failed\n");
1784 if (define->allowed) {
1785 LISTHEAD(define->allowed, tmp1);
1786 define->allowed = tmp1;
1788 if (define->request) {
1789 LISTHEAD(define->request, tmp2);
1790 define->request = tmp2;
1795 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol)
1797 const xmlChar *node;
1800 operation_x *tmp1 = NULL;
1802 mime_x *tmp3 = NULL;
1803 subapp_x *tmp4 = NULL;
1805 depth = xmlTextReaderDepth(reader);
1806 while ((ret = __next_child_element(reader, depth))) {
1807 node = xmlTextReaderConstName(reader);
1809 DBG("xmlTextReaderConstName value is NULL\n");
1813 if (!strcmp(ASCII(node), "operation")) {
1814 operation_x *operation = malloc(sizeof(operation_x));
1815 if (operation == NULL) {
1816 DBG("Malloc Failed\n");
1819 memset(operation, '\0', sizeof(operation_x));
1820 LISTADD(appcontrol->operation, operation);
1821 ret = __ps_process_operation(reader, operation);
1822 DBG("operation processing\n");
1823 } else if (!strcmp(ASCII(node), "uri")) {
1824 uri_x *uri= malloc(sizeof(uri_x));
1826 DBG("Malloc Failed\n");
1829 memset(uri, '\0', sizeof(uri_x));
1830 LISTADD(appcontrol->uri, uri);
1831 ret = __ps_process_uri(reader, uri);
1832 DBG("uri processing\n");
1833 } else if (!strcmp(ASCII(node), "mime")) {
1834 mime_x *mime = malloc(sizeof(mime_x));
1836 DBG("Malloc Failed\n");
1839 memset(mime, '\0', sizeof(mime_x));
1840 LISTADD(appcontrol->mime, mime);
1841 ret = __ps_process_mime(reader, mime);
1842 DBG("mime processing\n");
1843 } else if (!strcmp(ASCII(node), "subapp")) {
1844 subapp_x *subapp = malloc(sizeof(subapp_x));
1845 if (subapp == NULL) {
1846 DBG("Malloc Failed\n");
1849 memset(subapp, '\0', sizeof(subapp_x));
1850 LISTADD(appcontrol->subapp, subapp);
1851 ret = __ps_process_subapp(reader, subapp);
1852 DBG("subapp processing\n");
1856 DBG("Processing appcontrol failed\n");
1860 if (appcontrol->operation) {
1861 LISTHEAD(appcontrol->operation, tmp1);
1862 appcontrol->operation = tmp1;
1864 if (appcontrol->uri) {
1865 LISTHEAD(appcontrol->uri, tmp2);
1866 appcontrol->uri = tmp2;
1868 if (appcontrol->mime) {
1869 LISTHEAD(appcontrol->mime, tmp3);
1870 appcontrol->mime = tmp3;
1872 if (appcontrol->subapp) {
1873 LISTHEAD(appcontrol->subapp, tmp4);
1874 appcontrol->subapp = tmp4;
1877 xmlTextReaderRead(reader);
1878 if (xmlTextReaderValue(reader))
1879 appcontrol->text = ASCII(xmlTextReaderValue(reader));
1884 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc)
1886 const xmlChar *node;
1889 operation_x *tmp1 = NULL;
1891 mime_x *tmp3 = NULL;
1892 subapp_x *tmp4 = NULL;
1894 depth = xmlTextReaderDepth(reader);
1895 while ((ret = __next_child_element(reader, depth))) {
1896 node = xmlTextReaderConstName(reader);
1898 DBG("xmlTextReaderConstName value is NULL\n");
1902 if (!strcmp(ASCII(node), "operation")) {
1903 operation_x *operation = malloc(sizeof(operation_x));
1904 if (operation == NULL) {
1905 DBG("Malloc Failed\n");
1908 memset(operation, '\0', sizeof(operation_x));
1909 LISTADD(appsvc->operation, operation);
1910 ret = __ps_process_operation(reader, operation);
1911 DBG("operation processing\n");
1912 } else if (!strcmp(ASCII(node), "uri")) {
1913 uri_x *uri= malloc(sizeof(uri_x));
1915 DBG("Malloc Failed\n");
1918 memset(uri, '\0', sizeof(uri_x));
1919 LISTADD(appsvc->uri, uri);
1920 ret = __ps_process_uri(reader, uri);
1921 DBG("uri processing\n");
1922 } else if (!strcmp(ASCII(node), "mime")) {
1923 mime_x *mime = malloc(sizeof(mime_x));
1925 DBG("Malloc Failed\n");
1928 memset(mime, '\0', sizeof(mime_x));
1929 LISTADD(appsvc->mime, mime);
1930 ret = __ps_process_mime(reader, mime);
1931 DBG("mime processing\n");
1932 } else if (!strcmp(ASCII(node), "subapp")) {
1933 subapp_x *subapp = malloc(sizeof(subapp_x));
1934 if (subapp == NULL) {
1935 DBG("Malloc Failed\n");
1938 memset(subapp, '\0', sizeof(subapp_x));
1939 LISTADD(appsvc->subapp, subapp);
1940 ret = __ps_process_subapp(reader, subapp);
1941 DBG("subapp processing\n");
1945 DBG("Processing appsvc failed\n");
1949 if (appsvc->operation) {
1950 LISTHEAD(appsvc->operation, tmp1);
1951 appsvc->operation = tmp1;
1954 LISTHEAD(appsvc->uri, tmp2);
1958 LISTHEAD(appsvc->mime, tmp3);
1959 appsvc->mime = tmp3;
1961 if (appsvc->subapp) {
1962 LISTHEAD(appsvc->subapp, tmp4);
1963 appsvc->subapp = tmp4;
1966 xmlTextReaderRead(reader);
1967 if (xmlTextReaderValue(reader))
1968 appsvc->text = ASCII(xmlTextReaderValue(reader));
1974 static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privileges)
1976 const xmlChar *node;
1979 privilege_x *tmp1 = NULL;
1981 depth = xmlTextReaderDepth(reader);
1982 while ((ret = __next_child_element(reader, depth))) {
1983 node = xmlTextReaderConstName(reader);
1985 DBG("xmlTextReaderConstName value is NULL\n");
1989 if (strcmp(ASCII(node), "privilege") == 0) {
1990 privilege_x *privilege = malloc(sizeof(privilege_x));
1991 if (privilege == NULL) {
1992 DBG("Malloc Failed\n");
1995 memset(privilege, '\0', sizeof(privilege_x));
1996 LISTADD(privileges->privilege, privilege);
1997 ret = __ps_process_privilege(reader, privilege);
2001 DBG("Processing privileges failed\n");
2005 if (privileges->privilege) {
2006 LISTHEAD(privileges->privilege, tmp1);
2007 privileges->privilege = tmp1;
2012 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions)
2014 const xmlChar *node;
2017 condition_x *tmp1 = NULL;
2019 depth = xmlTextReaderDepth(reader);
2020 while ((ret = __next_child_element(reader, depth))) {
2021 node = xmlTextReaderConstName(reader);
2023 DBG("xmlTextReaderConstName value is NULL\n");
2027 if (strcmp(ASCII(node), "condition") == 0) {
2028 condition_x *condition = malloc(sizeof(condition_x));
2029 if (condition == NULL) {
2030 DBG("Malloc Failed\n");
2033 memset(condition, '\0', sizeof(condition_x));
2034 LISTADD(launchconditions->condition, condition);
2035 ret = __ps_process_condition(reader, condition);
2039 DBG("Processing launchconditions failed\n");
2043 if (launchconditions->condition) {
2044 LISTHEAD(launchconditions->condition, tmp1);
2045 launchconditions->condition = tmp1;
2048 xmlTextReaderRead(reader);
2049 if (xmlTextReaderValue(reader))
2050 launchconditions->text = ASCII(xmlTextReaderValue(reader));
2055 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare)
2057 const xmlChar *node;
2060 define_x *tmp1 = NULL;
2061 request_x *tmp2 = NULL;
2062 depth = xmlTextReaderDepth(reader);
2063 while ((ret = __next_child_element(reader, depth))) {
2064 node = xmlTextReaderConstName(reader);
2066 DBG("xmlTextReaderConstName value is NULL\n");
2070 if (!strcmp(ASCII(node), "define")) {
2071 define_x *define= malloc(sizeof(define_x));
2072 if (define == NULL) {
2073 DBG("Malloc Failed\n");
2076 memset(define, '\0', sizeof(define_x));
2077 LISTADD(datashare->define, define);
2078 ret = __ps_process_define(reader, define);
2079 } else if (!strcmp(ASCII(node), "request")) {
2080 request_x *request= malloc(sizeof(request_x));
2081 if (request == NULL) {
2082 DBG("Malloc Failed\n");
2085 memset(request, '\0', sizeof(request_x));
2086 LISTADD(datashare->request, request);
2087 ret = __ps_process_request(reader, request);
2091 DBG("Processing data-share failed\n");
2095 if (datashare->define) {
2096 LISTHEAD(datashare->define, tmp1);
2097 datashare->define = tmp1;
2099 if (datashare->request) {
2100 LISTHEAD(datashare->request, tmp2);
2101 datashare->request = tmp2;
2107 __get_icon_with_path(const char* icon)
2112 if (index(icon, '/') == NULL) {
2114 char* icon_with_path = NULL;
2120 theme = vconf_get_str("db/setting/theme");
2122 theme = strdup("default");
2128 len = (0x01 << 7) + strlen(icon) + strlen(package) + strlen(theme);
2129 icon_with_path = malloc(len);
2130 if(icon_with_path == NULL) {
2131 DBG("(icon_with_path == NULL) return\n");
2136 memset(icon_with_path, 0, len);
2138 snprintf(icon_with_path, len, "/opt/share/icons/%s/small/%s", theme, icon);
2140 if (access(icon_with_path, R_OK) == 0) break;
2141 snprintf(icon_with_path, len, "/usr/share/icons/%s/small/%s", theme, icon);
2142 if (access(icon_with_path, R_OK) == 0) break;
2143 DBG("cannot find icon %s", icon_with_path);
2144 snprintf(icon_with_path, len,"/opt/share/icons/default/small/%s", icon);
2145 if (access(icon_with_path, R_OK) == 0) break;
2146 snprintf(icon_with_path, len, "/usr/share/icons/default/small/%s", icon);
2147 if (access(icon_with_path, R_OK) == 0) break;
2149 /* icon path is going to be moved intto the app directory */
2150 DBGE("icon file must be moved to %s", icon_with_path);
2151 snprintf(icon_with_path, len, "/opt/apps/%s/res/icons/%s/small/%s", package, theme, icon);
2152 if (access(icon_with_path, R_OK) == 0) break;
2153 snprintf(icon_with_path, len, "/usr/apps/%s/res/icons/%s/small/%s", package, theme, icon);
2154 if (access(icon_with_path, R_OK) == 0) break;
2155 DBG("cannot find icon %s", icon_with_path);
2156 snprintf(icon_with_path, len, "/opt/apps/%s/res/icons/default/small/%s", package, icon);
2157 if (access(icon_with_path, R_OK) == 0) break;
2158 snprintf(icon_with_path, len, "/usr/apps/%s/res/icons/default/small/%s", package, icon);
2159 if (access(icon_with_path, R_OK) == 0) break;
2164 DBG("Icon path : %s ---> %s", icon, icon_with_path);
2166 return icon_with_path;
2168 char* confirmed_icon = NULL;
2170 confirmed_icon = strdup(icon);
2171 if (!confirmed_icon)
2173 return confirmed_icon;
2178 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon)
2180 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2181 icon->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2182 if (xmlTextReaderConstXmlLang(reader)) {
2183 icon->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2184 if (icon->lang == NULL)
2185 icon->lang = strdup(DEFAULT_LOCALE);
2187 icon->lang = strdup(DEFAULT_LOCALE);
2189 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
2190 icon->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
2191 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
2192 icon->size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
2193 if (xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")))
2194 icon->resolution = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")));
2195 xmlTextReaderRead(reader);
2196 if (xmlTextReaderValue(reader)) {
2197 const char *text = ASCII(xmlTextReaderValue(reader));
2199 icon->text = (const char *)__get_icon_with_path(text);
2207 static int __ps_process_image(xmlTextReaderPtr reader, image_x *image)
2209 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2210 image->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2211 if (xmlTextReaderConstXmlLang(reader)) {
2212 image->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2213 if (image->lang == NULL)
2214 image->lang = strdup(DEFAULT_LOCALE);
2216 image->lang = strdup(DEFAULT_LOCALE);
2218 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
2219 image->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
2220 xmlTextReaderRead(reader);
2221 if (xmlTextReaderValue(reader))
2222 image->text = ASCII(xmlTextReaderValue(reader));
2227 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label)
2229 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2230 label->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2231 if (xmlTextReaderConstXmlLang(reader)) {
2232 label->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2233 if (label->lang == NULL)
2234 label->lang = strdup(DEFAULT_LOCALE);
2236 label->lang = strdup(DEFAULT_LOCALE);
2238 xmlTextReaderRead(reader);
2239 if (xmlTextReaderValue(reader))
2240 label->text = ASCII(xmlTextReaderValue(reader));
2242 /* DBG("lable name %s\n", label->name);
2243 DBG("lable lang %s\n", label->lang);
2244 DBG("lable text %s\n", label->text);
2250 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author)
2252 if (xmlTextReaderGetAttribute(reader, XMLCHAR("email")))
2253 author->email = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("email")));
2254 if (xmlTextReaderGetAttribute(reader, XMLCHAR("href")))
2255 author->href = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("href")));
2256 if (xmlTextReaderConstXmlLang(reader)) {
2257 author->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2258 if (author->lang == NULL)
2259 author->lang = strdup(DEFAULT_LOCALE);
2261 author->lang = strdup(DEFAULT_LOCALE);
2263 xmlTextReaderRead(reader);
2264 if (xmlTextReaderValue(reader))
2265 author->text = ASCII(xmlTextReaderValue(reader));
2269 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description)
2271 if (xmlTextReaderConstXmlLang(reader)) {
2272 description->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2273 if (description->lang == NULL)
2274 description->lang = strdup(DEFAULT_LOCALE);
2276 description->lang = strdup(DEFAULT_LOCALE);
2278 xmlTextReaderRead(reader);
2279 if (xmlTextReaderValue(reader))
2280 description->text = ASCII(xmlTextReaderValue(reader));
2284 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license)
2286 if (xmlTextReaderConstXmlLang(reader)) {
2287 license->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2288 if (license->lang == NULL)
2289 license->lang = strdup(DEFAULT_LOCALE);
2291 license->lang = strdup(DEFAULT_LOCALE);
2293 xmlTextReaderRead(reader);
2294 if (xmlTextReaderValue(reader))
2295 license->text = ASCII(xmlTextReaderValue(reader));
2299 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability)
2301 const xmlChar *node;
2304 resolution_x *tmp1 = NULL;
2306 if (xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")))
2307 capability->operationid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")));
2309 depth = xmlTextReaderDepth(reader);
2310 while ((ret = __next_child_element(reader, depth))) {
2311 node = xmlTextReaderConstName(reader);
2313 DBG("xmlTextReaderConstName value is NULL\n");
2317 if (!strcmp(ASCII(node), "resolution")) {
2318 resolution_x *resolution = malloc(sizeof(resolution_x));
2319 if (resolution == NULL) {
2320 DBG("Malloc Failed\n");
2323 memset(resolution, '\0', sizeof(resolution_x));
2324 LISTADD(capability->resolution, resolution);
2325 ret = __ps_process_resolution(reader, resolution);
2329 DBG("Processing capability failed\n");
2334 if (capability->resolution) {
2335 LISTHEAD(capability->resolution, tmp1);
2336 capability->resolution = tmp1;
2342 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol)
2344 const xmlChar *node;
2347 capability_x *tmp1 = NULL;
2349 if (xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")))
2350 datacontrol->providerid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")));
2352 depth = xmlTextReaderDepth(reader);
2353 while ((ret = __next_child_element(reader, depth))) {
2354 node = xmlTextReaderConstName(reader);
2356 DBG("xmlTextReaderConstName value is NULL\n");
2360 if (!strcmp(ASCII(node), "capability")) {
2361 capability_x *capability = malloc(sizeof(capability_x));
2362 if (capability == NULL) {
2363 DBG("Malloc Failed\n");
2366 memset(capability, '\0', sizeof(capability_x));
2367 LISTADD(datacontrol->capability, capability);
2368 ret = __ps_process_capability(reader, capability);
2372 DBG("Processing datacontrol failed\n");
2377 if (datacontrol->capability) {
2378 LISTHEAD(datacontrol->capability, tmp1);
2379 datacontrol->capability = tmp1;
2385 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication)
2387 const xmlChar *node;
2390 char *newappid = NULL;
2391 label_x *tmp1 = NULL;
2392 icon_x *tmp2 = NULL;
2393 appsvc_x *tmp3 = NULL;
2394 appcontrol_x *tmp4 = NULL;
2395 launchconditions_x *tmp5 = NULL;
2396 notification_x *tmp6 = NULL;
2397 datashare_x *tmp7 = NULL;
2398 category_x *tmp8 = NULL;
2399 metadata_x *tmp9 = NULL;
2400 image_x *tmp10 = NULL;
2401 permission_x *tmp11 = NULL;
2403 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
2404 uiapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
2405 if (uiapplication->appid == NULL) {
2406 DBG("appid cant be NULL\n");
2410 DBG("appid is mandatory\n");
2414 ret = __validate_appid(package, uiapplication->appid, &newappid);
2416 DBG("appid is not proper\n");
2420 if (uiapplication->appid)
2421 free((void *)uiapplication->appid);
2422 uiapplication->appid = newappid;
2425 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
2426 uiapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
2427 if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay"))) {
2428 uiapplication->nodisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay")));
2429 if (uiapplication->nodisplay == NULL)
2430 uiapplication->nodisplay = strdup("false");
2432 uiapplication->nodisplay = strdup("false");
2434 if (xmlTextReaderGetAttribute(reader, XMLCHAR("multiple"))) {
2435 uiapplication->multiple = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("multiple")));
2436 if (uiapplication->multiple == NULL)
2437 uiapplication->multiple = strdup("false");
2439 uiapplication->multiple = strdup("false");
2441 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
2442 uiapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
2443 if (xmlTextReaderGetAttribute(reader, XMLCHAR("categories")))
2444 uiapplication->categories = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("categories")));
2445 if (xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")))
2446 uiapplication->extraid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")));
2447 if (xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage"))) {
2448 uiapplication->taskmanage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage")));
2449 if (uiapplication->taskmanage == NULL)
2450 uiapplication->taskmanage = strdup("true");
2452 uiapplication->taskmanage = strdup("true");
2454 if (xmlTextReaderGetAttribute(reader, XMLCHAR("enabled"))) {
2455 uiapplication->enabled = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("enabled")));
2456 if (uiapplication->enabled == NULL)
2457 uiapplication->enabled = strdup("true");
2459 uiapplication->enabled = strdup("true");
2461 if (xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration"))) {
2462 uiapplication->hwacceleration = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration")));
2463 if (uiapplication->hwacceleration == NULL)
2464 uiapplication->hwacceleration = strdup("use-system-setting");
2466 uiapplication->hwacceleration = strdup("use-system-setting");
2468 if (xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")))
2469 uiapplication->recentimage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")));
2470 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp"))) {
2471 uiapplication->mainapp = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp")));
2472 if (uiapplication->mainapp == NULL)
2473 uiapplication->mainapp = strdup("false");
2475 uiapplication->mainapp = strdup("false");
2477 if (xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay"))) {
2478 uiapplication->indicatordisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay")));
2479 if (uiapplication->indicatordisplay == NULL)
2480 uiapplication->indicatordisplay = strdup("true");
2482 uiapplication->indicatordisplay = strdup("true");
2484 if (xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")))
2485 uiapplication->portraitimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")));
2487 uiapplication->portraitimg = NULL;
2488 if (xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")))
2489 uiapplication->landscapeimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")));
2491 uiapplication->landscapeimg = NULL;
2492 if (xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility"))) {
2493 uiapplication->guestmode_visibility = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility")));
2494 if (uiapplication->guestmode_visibility == NULL)
2495 uiapplication->guestmode_visibility = strdup("true");
2497 uiapplication->guestmode_visibility = strdup("true");
2500 depth = xmlTextReaderDepth(reader);
2501 while ((ret = __next_child_element(reader, depth))) {
2502 node = xmlTextReaderConstName(reader);
2504 DBG("xmlTextReaderConstName value is NULL\n");
2507 if (!strcmp(ASCII(node), "label")) {
2508 label_x *label = malloc(sizeof(label_x));
2509 if (label == NULL) {
2510 DBG("Malloc Failed\n");
2513 memset(label, '\0', sizeof(label_x));
2514 LISTADD(uiapplication->label, label);
2515 ret = __ps_process_label(reader, label);
2516 } else if (!strcmp(ASCII(node), "icon")) {
2517 icon_x *icon = malloc(sizeof(icon_x));
2519 DBG("Malloc Failed\n");
2522 memset(icon, '\0', sizeof(icon_x));
2523 LISTADD(uiapplication->icon, icon);
2524 ret = __ps_process_icon(reader, icon);
2525 } else if (!strcmp(ASCII(node), "image")) {
2526 image_x *image = malloc(sizeof(image_x));
2527 if (image == NULL) {
2528 DBG("Malloc Failed\n");
2531 memset(image, '\0', sizeof(image_x));
2532 LISTADD(uiapplication->image, image);
2533 ret = __ps_process_image(reader, image);
2534 } else if (!strcmp(ASCII(node), "category")) {
2535 category_x *category = malloc(sizeof(category_x));
2536 if (category == NULL) {
2537 DBG("Malloc Failed\n");
2540 memset(category, '\0', sizeof(category_x));
2541 LISTADD(uiapplication->category, category);
2542 ret = __ps_process_category(reader, category);
2543 } else if (!strcmp(ASCII(node), "metadata")) {
2544 metadata_x *metadata = malloc(sizeof(metadata_x));
2545 if (metadata == NULL) {
2546 DBG("Malloc Failed\n");
2549 memset(metadata, '\0', sizeof(metadata_x));
2550 LISTADD(uiapplication->metadata, metadata);
2551 ret = __ps_process_metadata(reader, metadata);
2552 } else if (!strcmp(ASCII(node), "permission")) {
2553 permission_x *permission = malloc(sizeof(permission_x));
2554 if (permission == NULL) {
2555 DBG("Malloc Failed\n");
2558 memset(permission, '\0', sizeof(permission_x));
2559 LISTADD(uiapplication->permission, permission);
2560 ret = __ps_process_permission(reader, permission);
2561 } else if (!strcmp(ASCII(node), "app-control")) {
2562 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
2563 if (appcontrol == NULL) {
2564 DBG("Malloc Failed\n");
2567 memset(appcontrol, '\0', sizeof(appcontrol_x));
2568 LISTADD(uiapplication->appcontrol, appcontrol);
2569 ret = __ps_process_appcontrol(reader, appcontrol);
2570 } else if (!strcmp(ASCII(node), "application-service")) {
2571 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
2572 if (appsvc == NULL) {
2573 DBG("Malloc Failed\n");
2576 memset(appsvc, '\0', sizeof(appsvc_x));
2577 LISTADD(uiapplication->appsvc, appsvc);
2578 ret = __ps_process_appsvc(reader, appsvc);
2579 } else if (!strcmp(ASCII(node), "data-share")) {
2580 datashare_x *datashare = malloc(sizeof(datashare_x));
2581 if (datashare == NULL) {
2582 DBG("Malloc Failed\n");
2585 memset(datashare, '\0', sizeof(datashare_x));
2586 LISTADD(uiapplication->datashare, datashare);
2587 ret = __ps_process_datashare(reader, datashare);
2588 } else if (!strcmp(ASCII(node), "launch-conditions")) {
2589 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
2590 if (launchconditions == NULL) {
2591 DBG("Malloc Failed\n");
2594 memset(launchconditions, '\0', sizeof(launchconditions_x));
2595 LISTADD(uiapplication->launchconditions, launchconditions);
2596 ret = __ps_process_launchconditions(reader, launchconditions);
2597 } else if (!strcmp(ASCII(node), "notification")) {
2598 notification_x *notification = malloc(sizeof(notification_x));
2599 if (notification == NULL) {
2600 DBG("Malloc Failed\n");
2603 memset(notification, '\0', sizeof(notification_x));
2604 LISTADD(uiapplication->notification, notification);
2605 ret = __ps_process_notification(reader, notification);
2609 DBG("Processing uiapplication failed\n");
2614 if (uiapplication->label) {
2615 LISTHEAD(uiapplication->label, tmp1);
2616 uiapplication->label = tmp1;
2618 if (uiapplication->icon) {
2619 LISTHEAD(uiapplication->icon, tmp2);
2620 uiapplication->icon = tmp2;
2622 if (uiapplication->appsvc) {
2623 LISTHEAD(uiapplication->appsvc, tmp3);
2624 uiapplication->appsvc = tmp3;
2626 if (uiapplication->appcontrol) {
2627 LISTHEAD(uiapplication->appcontrol, tmp4);
2628 uiapplication->appcontrol = tmp4;
2630 if (uiapplication->launchconditions) {
2631 LISTHEAD(uiapplication->launchconditions, tmp5);
2632 uiapplication->launchconditions = tmp5;
2634 if (uiapplication->notification) {
2635 LISTHEAD(uiapplication->notification, tmp6);
2636 uiapplication->notification = tmp6;
2638 if (uiapplication->datashare) {
2639 LISTHEAD(uiapplication->datashare, tmp7);
2640 uiapplication->datashare = tmp7;
2642 if (uiapplication->category) {
2643 LISTHEAD(uiapplication->category, tmp8);
2644 uiapplication->category = tmp8;
2646 if (uiapplication->metadata) {
2647 LISTHEAD(uiapplication->metadata, tmp9);
2648 uiapplication->metadata = tmp9;
2650 if (uiapplication->image) {
2651 LISTHEAD(uiapplication->image, tmp10);
2652 uiapplication->image = tmp10;
2654 if (uiapplication->permission) {
2655 LISTHEAD(uiapplication->permission, tmp11);
2656 uiapplication->permission = tmp11;
2662 static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication)
2664 const xmlChar *node;
2667 char *newappid = NULL;
2668 label_x *tmp1 = NULL;
2669 icon_x *tmp2 = NULL;
2670 appsvc_x *tmp3 = NULL;
2671 appcontrol_x *tmp4 = NULL;
2672 datacontrol_x *tmp5 = NULL;
2673 launchconditions_x *tmp6 = NULL;
2674 notification_x *tmp7 = NULL;
2675 datashare_x *tmp8 = NULL;
2676 category_x *tmp9 = NULL;
2677 metadata_x *tmp10 = NULL;
2678 permission_x *tmp11 = NULL;
2680 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
2681 serviceapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
2682 if (serviceapplication->appid == NULL) {
2683 DBG("appid cant be NULL\n");
2687 DBG("appid is mandatory\n");
2691 ret = __validate_appid(package, serviceapplication->appid, &newappid);
2693 DBG("appid is not proper\n");
2697 if (serviceapplication->appid)
2698 free((void *)serviceapplication->appid);
2699 serviceapplication->appid = newappid;
2702 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
2703 serviceapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
2704 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
2705 serviceapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
2706 if (xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot"))) {
2707 serviceapplication->onboot = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot")));
2708 if (serviceapplication->onboot == NULL)
2709 serviceapplication->onboot = strdup("false");
2711 serviceapplication->onboot = strdup("false");
2713 if (xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart"))) {
2714 serviceapplication->autorestart = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart")));
2715 if (serviceapplication->autorestart == NULL)
2716 serviceapplication->autorestart = strdup("false");
2718 serviceapplication->autorestart = strdup("false");
2721 depth = xmlTextReaderDepth(reader);
2722 while ((ret = __next_child_element(reader, depth))) {
2723 node = xmlTextReaderConstName(reader);
2725 DBG("xmlTextReaderConstName value is NULL\n");
2729 if (!strcmp(ASCII(node), "label")) {
2730 label_x *label = malloc(sizeof(label_x));
2731 if (label == NULL) {
2732 DBG("Malloc Failed\n");
2735 memset(label, '\0', sizeof(label_x));
2736 LISTADD(serviceapplication->label, label);
2737 ret = __ps_process_label(reader, label);
2738 } else if (!strcmp(ASCII(node), "icon")) {
2739 icon_x *icon = malloc(sizeof(icon_x));
2741 DBG("Malloc Failed\n");
2744 memset(icon, '\0', sizeof(icon_x));
2745 LISTADD(serviceapplication->icon, icon);
2746 ret = __ps_process_icon(reader, icon);
2747 } else if (!strcmp(ASCII(node), "category")) {
2748 category_x *category = malloc(sizeof(category_x));
2749 if (category == NULL) {
2750 DBG("Malloc Failed\n");
2753 memset(category, '\0', sizeof(category_x));
2754 LISTADD(serviceapplication->category, category);
2755 ret = __ps_process_category(reader, category);
2756 } else if (!strcmp(ASCII(node), "metadata")) {
2757 metadata_x *metadata = malloc(sizeof(metadata_x));
2758 if (metadata == NULL) {
2759 DBG("Malloc Failed\n");
2762 memset(metadata, '\0', sizeof(metadata_x));
2763 LISTADD(serviceapplication->metadata, metadata);
2764 ret = __ps_process_metadata(reader, metadata);
2765 } else if (!strcmp(ASCII(node), "permission")) {
2766 permission_x *permission = malloc(sizeof(permission_x));
2767 if (permission == NULL) {
2768 DBG("Malloc Failed\n");
2771 memset(permission, '\0', sizeof(permission_x));
2772 LISTADD(serviceapplication->permission, permission);
2773 ret = __ps_process_permission(reader, permission);
2774 } else if (!strcmp(ASCII(node), "app-control")) {
2775 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
2776 if (appcontrol == NULL) {
2777 DBG("Malloc Failed\n");
2780 memset(appcontrol, '\0', sizeof(appcontrol_x));
2781 LISTADD(serviceapplication->appcontrol, appcontrol);
2782 ret = __ps_process_appcontrol(reader, appcontrol);
2783 } else if (!strcmp(ASCII(node), "application-service")) {
2784 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
2785 if (appsvc == NULL) {
2786 DBG("Malloc Failed\n");
2789 memset(appsvc, '\0', sizeof(appsvc_x));
2790 LISTADD(serviceapplication->appsvc, appsvc);
2791 ret = __ps_process_appsvc(reader, appsvc);
2792 } else if (!strcmp(ASCII(node), "data-share")) {
2793 datashare_x *datashare = malloc(sizeof(datashare_x));
2794 if (datashare == NULL) {
2795 DBG("Malloc Failed\n");
2798 memset(datashare, '\0', sizeof(datashare_x));
2799 LISTADD(serviceapplication->datashare, datashare);
2800 ret = __ps_process_datashare(reader, datashare);
2801 } else if (!strcmp(ASCII(node), "launch-conditions")) {
2802 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
2803 if (launchconditions == NULL) {
2804 DBG("Malloc Failed\n");
2807 memset(launchconditions, '\0', sizeof(launchconditions_x));
2808 LISTADD(serviceapplication->launchconditions, launchconditions);
2809 ret = __ps_process_launchconditions(reader, launchconditions);
2810 } else if (!strcmp(ASCII(node), "notification")) {
2811 notification_x *notification = malloc(sizeof(notification_x));
2812 if (notification == NULL) {
2813 DBG("Malloc Failed\n");
2816 memset(notification, '\0', sizeof(notification_x));
2817 LISTADD(serviceapplication->notification, notification);
2818 ret = __ps_process_notification(reader, notification);
2819 } else if (!strcmp(ASCII(node), "data-control")) {
2820 datacontrol_x *datacontrol = malloc(sizeof(datacontrol_x));
2821 if (datacontrol == NULL) {
2822 DBG("Malloc Failed\n");
2825 memset(datacontrol, '\0', sizeof(datacontrol_x));
2826 LISTADD(serviceapplication->datacontrol, datacontrol);
2827 ret = __ps_process_datacontrol(reader, datacontrol);
2831 DBG("Processing serviceapplication failed\n");
2836 if (serviceapplication->label) {
2837 LISTHEAD(serviceapplication->label, tmp1);
2838 serviceapplication->label = tmp1;
2840 if (serviceapplication->icon) {
2841 LISTHEAD(serviceapplication->icon, tmp2);
2842 serviceapplication->icon = tmp2;
2844 if (serviceapplication->appsvc) {
2845 LISTHEAD(serviceapplication->appsvc, tmp3);
2846 serviceapplication->appsvc = tmp3;
2848 if (serviceapplication->appcontrol) {
2849 LISTHEAD(serviceapplication->appcontrol, tmp4);
2850 serviceapplication->appcontrol = tmp4;
2852 if (serviceapplication->datacontrol) {
2853 LISTHEAD(serviceapplication->datacontrol, tmp5);
2854 serviceapplication->datacontrol = tmp5;
2856 if (serviceapplication->launchconditions) {
2857 LISTHEAD(serviceapplication->launchconditions, tmp6);
2858 serviceapplication->launchconditions = tmp6;
2860 if (serviceapplication->notification) {
2861 LISTHEAD(serviceapplication->notification, tmp7);
2862 serviceapplication->notification = tmp7;
2864 if (serviceapplication->datashare) {
2865 LISTHEAD(serviceapplication->datashare, tmp8);
2866 serviceapplication->datashare = tmp8;
2868 if (serviceapplication->category) {
2869 LISTHEAD(serviceapplication->category, tmp9);
2870 serviceapplication->category = tmp9;
2872 if (serviceapplication->metadata) {
2873 LISTHEAD(serviceapplication->metadata, tmp10);
2874 serviceapplication->metadata = tmp10;
2876 if (serviceapplication->permission) {
2877 LISTHEAD(serviceapplication->permission, tmp11);
2878 serviceapplication->permission = tmp11;
2884 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile)
2886 /*TODO: once policy is set*/
2890 static int __ps_process_font(xmlTextReaderPtr reader, font_x *font)
2892 /*TODO: once policy is set*/
2896 static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme)
2898 /*TODO: once policy is set*/
2902 static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon)
2904 /*TODO: once policy is set*/
2908 static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime)
2910 /*TODO: once policy is set*/
2914 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx)
2916 DBG("__start_process\n");
2917 const xmlChar *node;
2920 label_x *tmp1 = NULL;
2921 author_x *tmp2 = NULL;
2922 description_x *tmp3 = NULL;
2923 license_x *tmp4 = NULL;
2924 uiapplication_x *tmp5 = NULL;
2925 serviceapplication_x *tmp6 = NULL;
2926 daemon_x *tmp7 = NULL;
2927 theme_x *tmp8 = NULL;
2928 font_x *tmp9 = NULL;
2929 ime_x *tmp10 = NULL;
2930 icon_x *tmp11 = NULL;
2931 compatibility_x *tmp12 = NULL;
2932 deviceprofile_x *tmp13 = NULL;
2933 privileges_x *tmp14 = NULL;
2935 depth = xmlTextReaderDepth(reader);
2936 while ((ret = __next_child_element(reader, depth))) {
2937 node = xmlTextReaderConstName(reader);
2939 DBG("xmlTextReaderConstName value is NULL\n");
2943 if (!strcmp(ASCII(node), "label")) {
2944 label_x *label = malloc(sizeof(label_x));
2945 if (label == NULL) {
2946 DBG("Malloc Failed\n");
2949 memset(label, '\0', sizeof(label_x));
2950 LISTADD(mfx->label, label);
2951 ret = __ps_process_label(reader, label);
2952 } else if (!strcmp(ASCII(node), "author")) {
2953 author_x *author = malloc(sizeof(author_x));
2954 if (author == NULL) {
2955 DBG("Malloc Failed\n");
2958 memset(author, '\0', sizeof(author_x));
2959 LISTADD(mfx->author, author);
2960 ret = __ps_process_author(reader, author);
2961 } else if (!strcmp(ASCII(node), "description")) {
2962 description_x *description = malloc(sizeof(description_x));
2963 if (description == NULL) {
2964 DBG("Malloc Failed\n");
2967 memset(description, '\0', sizeof(description_x));
2968 LISTADD(mfx->description, description);
2969 ret = __ps_process_description(reader, description);
2970 } else if (!strcmp(ASCII(node), "license")) {
2971 license_x *license = malloc(sizeof(license_x));
2972 if (license == NULL) {
2973 DBG("Malloc Failed\n");
2976 memset(license, '\0', sizeof(license_x));
2977 LISTADD(mfx->license, license);
2978 ret = __ps_process_license(reader, license);
2979 } else if (!strcmp(ASCII(node), "privileges")) {
2980 privileges_x *privileges = malloc(sizeof(privileges_x));
2981 if (privileges == NULL) {
2982 DBG("Malloc Failed\n");
2985 memset(privileges, '\0', sizeof(privileges_x));
2986 LISTADD(mfx->privileges, privileges);
2987 ret = __ps_process_privileges(reader, privileges);
2988 } else if (!strcmp(ASCII(node), "ui-application")) {
2989 uiapplication_x *uiapplication = malloc(sizeof(uiapplication_x));
2990 if (uiapplication == NULL) {
2991 DBG("Malloc Failed\n");
2994 memset(uiapplication, '\0', sizeof(uiapplication_x));
2995 LISTADD(mfx->uiapplication, uiapplication);
2996 ret = __ps_process_uiapplication(reader, uiapplication);
2997 } else if (!strcmp(ASCII(node), "service-application")) {
2998 serviceapplication_x *serviceapplication = malloc(sizeof(serviceapplication_x));
2999 if (serviceapplication == NULL) {
3000 DBG("Malloc Failed\n");
3003 memset(serviceapplication, '\0', sizeof(serviceapplication_x));
3004 LISTADD(mfx->serviceapplication, serviceapplication);
3005 ret = __ps_process_serviceapplication(reader, serviceapplication);
3006 } else if (!strcmp(ASCII(node), "daemon")) {
3007 daemon_x *daemon = malloc(sizeof(daemon_x));
3008 if (daemon == NULL) {
3009 DBG("Malloc Failed\n");
3012 memset(daemon, '\0', sizeof(daemon_x));
3013 LISTADD(mfx->daemon, daemon);
3014 ret = __ps_process_daemon(reader, daemon);
3015 } else if (!strcmp(ASCII(node), "theme")) {
3016 theme_x *theme = malloc(sizeof(theme_x));
3017 if (theme == NULL) {
3018 DBG("Malloc Failed\n");
3021 memset(theme, '\0', sizeof(theme_x));
3022 LISTADD(mfx->theme, theme);
3023 ret = __ps_process_theme(reader, theme);
3024 } else if (!strcmp(ASCII(node), "font")) {
3025 font_x *font = malloc(sizeof(font_x));
3027 DBG("Malloc Failed\n");
3030 memset(font, '\0', sizeof(font_x));
3031 LISTADD(mfx->font, font);
3032 ret = __ps_process_font(reader, font);
3033 } else if (!strcmp(ASCII(node), "ime")) {
3034 ime_x *ime = malloc(sizeof(ime_x));
3036 DBG("Malloc Failed\n");
3039 memset(ime, '\0', sizeof(ime_x));
3040 LISTADD(mfx->ime, ime);
3041 ret = __ps_process_ime(reader, ime);
3042 } else if (!strcmp(ASCII(node), "icon")) {
3043 icon_x *icon = malloc(sizeof(icon_x));
3045 DBG("Malloc Failed\n");
3048 memset(icon, '\0', sizeof(icon_x));
3049 LISTADD(mfx->icon, icon);
3050 ret = __ps_process_icon(reader, icon);
3051 } else if (!strcmp(ASCII(node), "device-profile")) {
3052 deviceprofile_x *deviceprofile = malloc(sizeof(deviceprofile_x));
3053 if (deviceprofile == NULL) {
3054 DBG("Malloc Failed\n");
3057 memset(deviceprofile, '\0', sizeof(deviceprofile_x));
3058 LISTADD(mfx->deviceprofile, deviceprofile);
3059 ret = __ps_process_deviceprofile(reader, deviceprofile);
3060 } else if (!strcmp(ASCII(node), "compatibility")) {
3061 compatibility_x *compatibility = malloc(sizeof(compatibility_x));
3062 if (compatibility == NULL) {
3063 DBG("Malloc Failed\n");
3066 memset(compatibility, '\0', sizeof(compatibility_x));
3067 LISTADD(mfx->compatibility, compatibility);
3068 ret = __ps_process_compatibility(reader, compatibility);
3069 } else if (!strcmp(ASCII(node), "shortcut-list")) {
3071 } else if (!strcmp(ASCII(node), "livebox")) {
3073 } else if (!strcmp(ASCII(node), "account")) {
3075 } else if (!strcmp(ASCII(node), "notifications")) {
3077 } else if (!strcmp(ASCII(node), "ime")) {
3083 DBG("Processing manifest failed\n");
3088 LISTHEAD(mfx->label, tmp1);
3092 LISTHEAD(mfx->author, tmp2);
3095 if (mfx->description) {
3096 LISTHEAD(mfx->description, tmp3);
3097 mfx->description= tmp3;
3100 LISTHEAD(mfx->license, tmp4);
3103 if (mfx->uiapplication) {
3104 LISTHEAD(mfx->uiapplication, tmp5);
3105 mfx->uiapplication = tmp5;
3107 if (mfx->serviceapplication) {
3108 LISTHEAD(mfx->serviceapplication, tmp6);
3109 mfx->serviceapplication = tmp6;
3112 LISTHEAD(mfx->daemon, tmp7);
3116 LISTHEAD(mfx->theme, tmp8);
3120 LISTHEAD(mfx->font, tmp9);
3124 LISTHEAD(mfx->ime, tmp10);
3128 LISTHEAD(mfx->icon, tmp11);
3131 if (mfx->compatibility) {
3132 LISTHEAD(mfx->compatibility, tmp12);
3133 mfx->compatibility= tmp12;
3135 if (mfx->deviceprofile) {
3136 LISTHEAD(mfx->deviceprofile, tmp13);
3137 mfx->deviceprofile= tmp13;
3139 if (mfx->privileges) {
3140 LISTHEAD(mfx->privileges, tmp14);
3141 mfx->privileges = tmp14;
3146 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx)
3148 const xmlChar *node;
3151 if ((ret = __next_child_element(reader, -1))) {
3152 node = xmlTextReaderConstName(reader);
3154 DBG("xmlTextReaderConstName value is NULL\n");
3158 if (!strcmp(ASCII(node), "manifest")) {
3159 if (xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")))
3160 mfx->ns = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")));
3161 if (xmlTextReaderGetAttribute(reader, XMLCHAR("package"))) {
3162 mfx->package= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("package")));
3163 if (mfx->package == NULL) {
3164 DBG("package cant be NULL\n");
3168 DBG("package field is mandatory\n");
3171 package = mfx->package;
3172 if (xmlTextReaderGetAttribute(reader, XMLCHAR("version")))
3173 mfx->version= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("version")));
3174 /*app2ext needs package size for external installation*/
3175 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
3176 mfx->package_size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
3177 if (xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")))
3178 mfx->installlocation = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")));
3179 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
3180 mfx->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
3181 if (xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")))
3182 mfx->root_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")));
3183 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting"))) {
3184 mfx->appsetting = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting")));
3185 if (mfx->appsetting == NULL)
3186 mfx->appsetting = strdup("false");
3188 mfx->appsetting = strdup("false");
3191 /*Assign default values. If required it will be overwritten in __add_preload_info()*/
3192 mfx->preload = strdup("False");
3193 mfx->removable = strdup("True");
3194 mfx->readonly = strdup("False");
3195 char buf[PKG_STRING_LEN_MAX] = {'\0'};
3197 time_t current_time;
3198 time(¤t_time);
3199 snprintf(buf, PKG_STRING_LEN_MAX - 1, "%d", current_time);
3200 val = strndup(buf, PKG_STRING_LEN_MAX - 1);
3201 mfx->installed_time = val;
3203 mfx->installed_storage= strdup("installed_internal");
3205 ret = __start_process(reader, mfx);
3207 DBG("No Manifest element found\n");
3214 #define DESKTOP_RW_PATH "/opt/share/applications/"
3215 #define DESKTOP_RO_PATH "/usr/share/applications/"
3217 static char* __convert_to_system_locale(const char *mlocale)
3219 if (mlocale == NULL)
3221 char *locale = NULL;
3222 locale = (char *)calloc(1, 6);
3224 DBGE("Malloc Failed\n");
3228 strncpy(locale, mlocale, 2);
3229 strncat(locale, "_", 1);
3230 locale[3] = toupper(mlocale[3]);
3231 locale[4] = toupper(mlocale[4]);
3235 #define LIBAIL_PATH "/usr/lib/libail.so.0"
3237 /* operation_type */
3245 static int __ail_change_info(int op, const char *appid)
3247 void *lib_handle = NULL;
3248 int (*ail_desktop_operation) (const char *);
3252 if ((lib_handle = dlopen(LIBAIL_PATH, RTLD_LAZY)) == NULL) {
3253 DBGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAIL_PATH);
3260 aop = "ail_desktop_add";
3263 aop = "ail_desktop_update";
3266 aop = "ail_desktop_remove";
3273 if ((ail_desktop_operation =
3274 dlsym(lib_handle, aop)) == NULL || dlerror() != NULL) {
3275 DBGE("can not find symbol \n");
3279 ret = ail_desktop_operation(appid);
3283 dlclose(lib_handle);
3289 /* desktop shoud be generated automatically based on manifest */
3290 /* Currently removable, taskmanage, etc fields are not considerd. it will be decided soon.*/
3291 #define BUFMAX 1024*128
3292 static int __ps_make_nativeapp_desktop(manifest_x * mfx, bool is_update)
3296 char filepath[PKG_STRING_LEN_MAX] = "";
3298 char *buftemp = NULL;
3299 char *locale = NULL;
3301 buf = (char *)calloc(1, BUFMAX);
3303 DBGE("Malloc Failed\n");
3307 buftemp = (char *)calloc(1, BUFMAX);
3309 DBGE("Malloc Failed\n");
3314 for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) {
3316 if(mfx->readonly && !strcasecmp(mfx->readonly, "True"))
3317 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RO_PATH, mfx->uiapplication->appid);
3319 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, mfx->uiapplication->appid);
3321 /* skip if desktop exists
3322 if (access(filepath, R_OK) == 0)
3326 file = fopen(filepath, "w");
3329 DBGE("Can't open %s", filepath);
3335 snprintf(buf, BUFMAX, "[Desktop Entry]\n");
3336 fwrite(buf, 1, strlen(buf), file);
3338 for( ; mfx->uiapplication->label ; mfx->uiapplication->label = mfx->uiapplication->label->next) {
3339 if(!strcmp(mfx->uiapplication->label->lang, DEFAULT_LOCALE)) {
3340 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
3342 locale = __convert_to_system_locale(mfx->uiapplication->label->lang);
3343 snprintf(buf, BUFMAX, "Name[%s]=%s\n", locale,
3344 mfx->uiapplication->label->text);
3347 fwrite(buf, 1, strlen(buf), file);
3350 if(mfx->uiapplication->label && mfx->uiapplication->label->text) {
3351 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
3352 fwrite(buf, 1, strlen(buf), file);
3355 else if(mfx->label && mfx->label->text) {
3356 snprintf(buf, BUFMAX, "Name=%s\n", mfx->label->text);
3357 fwrite(buf, 1, strlen(buf), file);
3359 snprintf(buf, BUFMAX, "Name=%s\n", mfx->package);
3360 fwrite(buf, 1, strlen(buf), file);
3365 snprintf(buf, BUFMAX, "Type=Application\n");
3366 fwrite(buf, 1, strlen(buf), file);
3368 if(mfx->uiapplication->exec) {
3369 snprintf(buf, BUFMAX, "Exec=%s\n", mfx->uiapplication->exec);
3370 fwrite(buf, 1, strlen(buf), file);
3373 if(mfx->uiapplication->icon && mfx->uiapplication->icon->text) {
3374 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->uiapplication->icon->text);
3375 fwrite(buf, 1, strlen(buf), file);
3376 } else if(mfx->icon && mfx->icon->text) {
3377 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->icon->text);
3378 fwrite(buf, 1, strlen(buf), file);
3382 snprintf(buf, BUFMAX, "Version=%s\n", mfx->version);
3383 fwrite(buf, 1, strlen(buf), file);
3386 if(mfx->uiapplication->nodisplay) {
3387 snprintf(buf, BUFMAX, "NoDisplay=%s\n", mfx->uiapplication->nodisplay);
3388 fwrite(buf, 1, strlen(buf), file);
3391 if(mfx->uiapplication->categories) {
3392 snprintf(buf, BUFMAX, "Categories=%s\n", mfx->uiapplication->categories);
3393 fwrite(buf, 1, strlen(buf), file);
3396 if(mfx->uiapplication->taskmanage && !strcasecmp(mfx->uiapplication->taskmanage, "False")) {
3397 snprintf(buf, BUFMAX, "X-TIZEN-TaskManage=False\n");
3398 fwrite(buf, 1, strlen(buf), file);
3401 if(mfx->uiapplication->enabled && !strcasecmp(mfx->uiapplication->enabled, "False")) {
3402 snprintf(buf, BUFMAX, "X-TIZEN-Enabled=False\n");
3403 fwrite(buf, 1, strlen(buf), file);
3406 if(mfx->uiapplication->hwacceleration) {
3407 snprintf(buf, BUFMAX, "Hw-Acceleration=%s\n", mfx->uiapplication->hwacceleration);
3408 fwrite(buf, 1, strlen(buf), file);
3411 if(mfx->uiapplication->multiple && !strcasecmp(mfx->uiapplication->multiple, "True")) {
3412 snprintf(buf, BUFMAX, "X-TIZEN-Multiple=True\n");
3413 fwrite(buf, 1, strlen(buf), file);
3416 if(mfx->uiapplication->extraid) {
3417 snprintf(buf, BUFMAX, "X-TIZEN-PackageID=%s\n", mfx->uiapplication->extraid);
3418 fwrite(buf, 1, strlen(buf), file);
3421 if(mfx->removable && !strcasecmp(mfx->removable, "False")) {
3422 snprintf(buf, BUFMAX, "X-TIZEN-Removable=False\n");
3423 fwrite(buf, 1, strlen(buf), file);
3427 snprintf(buf, BUFMAX, "X-TIZEN-PackageType=%s\n", mfx->type);
3428 fwrite(buf, 1, strlen(buf), file);
3431 snprintf(buf, BUFMAX, "X-TIZEN-PkgID=%s\n", mfx->package);
3432 fwrite(buf, 1, strlen(buf), file);
3435 // snprintf(buf, BUFMAX, "X-TIZEN-PackageType=rpm\n");
3436 // fwrite(buf, 1, strlen(buf), file);
3439 if(mfx->uiapplication->appsvc) {
3440 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
3441 DBG("buf[%s]\n", buf);
3444 uiapplication_x *up = mfx->uiapplication;
3445 appsvc_x *asvc = NULL;
3446 operation_x *op = NULL;
3449 subapp_x *sub = NULL;
3450 const char *operation = NULL;
3451 const char *mime = NULL;
3452 const char *uri = NULL;
3453 const char *subapp = NULL;
3458 while(asvc != NULL) {
3459 op = asvc->operation;
3462 operation = op->name;
3481 strncpy(buftemp, buf, BUFMAX);
3482 snprintf(buf, BUFMAX, "%s;", buftemp);
3486 strncpy(buftemp, buf, BUFMAX);
3487 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
3488 DBG("buf[%s]\n", buf);
3493 } while(ui != NULL);
3497 }while(sub != NULL);
3510 fwrite(buf, 1, strlen(buf), file);
3512 // strncpy(buftemp, buf, BUFMAX);
3513 // snprintf(buf, BUFMAX, "%s\n", buftemp);
3514 // fwrite(buf, 1, strlen(buf), file);
3517 if(mfx->uiapplication->appcontrol) {
3518 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
3519 DBG("buf[%s]\n", buf);
3521 uiapplication_x *up = mfx->uiapplication;
3522 appcontrol_x *acontrol = NULL;
3523 operation_x *op = NULL;
3526 subapp_x *sub = NULL;
3527 const char *operation = NULL;
3528 const char *mime = NULL;
3529 const char *uri = NULL;
3530 const char *subapp = NULL;
3533 acontrol = up->appcontrol;
3534 while(acontrol != NULL) {
3535 op = acontrol->operation;
3538 operation = op->name;
3539 mi = acontrol->mime;
3545 sub = acontrol->subapp;
3557 strncpy(buftemp, buf, BUFMAX);
3558 snprintf(buf, BUFMAX, "%s;", buftemp);
3561 strncpy(buftemp, buf, BUFMAX);
3562 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
3563 DBG("buf[%s]\n", buf);
3568 } while(ui != NULL);
3572 }while(sub != NULL);
3581 acontrol = acontrol->next;
3585 fwrite(buf, 1, strlen(buf), file);
3587 // strncpy(buftemp, buf, BUFMAX);
3588 // snprintf(buf, BUFMAX, "%s\n", buftemp);
3589 // fwrite(buf, 1, strlen(buf), file);
3598 __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid);
3600 __ail_change_info(AIL_UPDATE, mfx->uiapplication->appid);
3609 static int __ps_remove_nativeapp_desktop(manifest_x *mfx)
3611 char filepath[PKG_STRING_LEN_MAX] = "";
3614 for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) {
3615 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, mfx->uiapplication->appid);
3617 __ail_change_info(AIL_REMOVE, mfx->uiapplication->appid);
3619 ret = remove(filepath);
3627 #define MANIFEST_RO_PREFIX "/usr/share/packages/"
3628 #define PRELOAD_PACKAGE_LIST "/usr/etc/package-manager/preload/preload_list.txt"
3629 static int __add_preload_info(manifest_x * mfx, const char *manifest)
3632 char buffer[1024] = { 0 };
3635 if(strstr(manifest, MANIFEST_RO_PREFIX)) {
3636 free((void *)mfx->readonly);
3637 mfx->readonly = strdup("True");
3639 free((void *)mfx->preload);
3640 mfx->preload = strdup("True");
3642 free((void *)mfx->removable);
3643 mfx->removable = strdup("False");
3648 fp = fopen(PRELOAD_PACKAGE_LIST, "r");
3650 DBGE("no preload list\n");
3654 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
3655 if (buffer[0] == '#') {
3656 if(strcasestr(buffer, "RW_NORM"))
3658 else if(strcasestr(buffer, "RW_RM"))
3666 if(!strcmp(mfx->package, buffer)) {
3667 free((void *)mfx->preload);
3668 mfx->preload = strdup("True");
3670 free((void *)mfx->readonly);
3671 mfx->readonly = strdup("False");
3672 free((void *)mfx->removable);
3673 mfx->removable = strdup("False");
3674 } else if(state == 3){
3675 free((void *)mfx->readonly);
3676 mfx->readonly = strdup("False");
3677 free((void *)mfx->removable);
3678 mfx->removable = strdup("True");
3682 memset(buffer, 0x00, sizeof(buffer));
3692 API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
3697 free((void *)mfx->ns);
3701 free((void *)mfx->package);
3702 mfx->package = NULL;
3705 free((void *)mfx->version);
3706 mfx->version = NULL;
3708 if (mfx->installlocation) {
3709 free((void *)mfx->installlocation);
3710 mfx->installlocation = NULL;
3713 free((void *)mfx->preload);
3714 mfx->preload = NULL;
3716 if (mfx->readonly) {
3717 free((void *)mfx->readonly);
3718 mfx->readonly = NULL;
3720 if (mfx->removable) {
3721 free((void *)mfx->removable);
3722 mfx->removable = NULL;
3725 free((void *)mfx->update);
3729 free((void *)mfx->type);
3732 if (mfx->package_size) {
3733 free((void *)mfx->package_size);
3734 mfx->package_size = NULL;
3736 if (mfx->installed_time) {
3737 free((void *)mfx->installed_time);
3738 mfx->installed_time = NULL;
3740 if (mfx->installed_storage) {
3741 free((void *)mfx->installed_storage);
3742 mfx->installed_storage = NULL;
3744 if (mfx->storeclient_id) {
3745 free((void *)mfx->storeclient_id);
3746 mfx->storeclient_id = NULL;
3748 if (mfx->mainapp_id) {
3749 free((void *)mfx->mainapp_id);
3750 mfx->mainapp_id = NULL;
3752 if (mfx->package_url) {
3753 free((void *)mfx->package_url);
3754 mfx->package_url = NULL;
3756 if (mfx->root_path) {
3757 free((void *)mfx->root_path);
3758 mfx->root_path = NULL;
3760 if (mfx->appsetting) {
3761 free((void *)mfx->appsetting);
3762 mfx->appsetting = NULL;
3767 icon_x *icon = mfx->icon;
3769 while(icon != NULL) {
3771 __ps_free_icon(icon);
3777 label_x *label = mfx->label;
3778 label_x *tmp = NULL;
3779 while(label != NULL) {
3781 __ps_free_label(label);
3787 author_x *author = mfx->author;
3788 author_x *tmp = NULL;
3789 while(author != NULL) {
3791 __ps_free_author(author);
3795 /*Free Description*/
3796 if (mfx->description) {
3797 description_x *description = mfx->description;
3798 description_x *tmp = NULL;
3799 while(description != NULL) {
3800 tmp = description->next;
3801 __ps_free_description(description);
3807 license_x *license = mfx->license;
3808 license_x *tmp = NULL;
3809 while(license != NULL) {
3810 tmp = license->next;
3811 __ps_free_license(license);
3816 if (mfx->privileges) {
3817 privileges_x *privileges = mfx->privileges;
3818 privileges_x *tmp = NULL;
3819 while(privileges != NULL) {
3820 tmp = privileges->next;
3821 __ps_free_privileges(privileges);
3825 /*Free UiApplication*/
3826 if (mfx->uiapplication) {
3827 uiapplication_x *uiapplication = mfx->uiapplication;
3828 uiapplication_x *tmp = NULL;
3829 while(uiapplication != NULL) {
3830 tmp = uiapplication->next;
3831 __ps_free_uiapplication(uiapplication);
3832 uiapplication = tmp;
3835 /*Free ServiceApplication*/
3836 if (mfx->serviceapplication) {
3837 serviceapplication_x *serviceapplication = mfx->serviceapplication;
3838 serviceapplication_x *tmp = NULL;
3839 while(serviceapplication != NULL) {
3840 tmp = serviceapplication->next;
3841 __ps_free_serviceapplication(serviceapplication);
3842 serviceapplication = tmp;
3847 daemon_x *daemon = mfx->daemon;
3848 daemon_x *tmp = NULL;
3849 while(daemon != NULL) {
3851 __ps_free_daemon(daemon);
3857 theme_x *theme = mfx->theme;
3858 theme_x *tmp = NULL;
3859 while(theme != NULL) {
3861 __ps_free_theme(theme);
3867 font_x *font = mfx->font;
3869 while(font != NULL) {
3871 __ps_free_font(font);
3877 ime_x *ime = mfx->ime;
3879 while(ime != NULL) {
3885 /*Free Compatibility*/
3886 if (mfx->compatibility) {
3887 compatibility_x *compatibility = mfx->compatibility;
3888 compatibility_x *tmp = NULL;
3889 while(compatibility != NULL) {
3890 tmp = compatibility->next;
3891 __ps_free_compatibility(compatibility);
3892 compatibility = tmp;
3895 /*Free DeviceProfile*/
3896 if (mfx->deviceprofile) {
3897 deviceprofile_x *deviceprofile = mfx->deviceprofile;
3898 deviceprofile_x *tmp = NULL;
3899 while(deviceprofile != NULL) {
3900 tmp = deviceprofile->next;
3901 __ps_free_deviceprofile(deviceprofile);
3902 deviceprofile = tmp;
3910 API manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest)
3912 DBG("parsing start\n");
3913 xmlTextReaderPtr reader;
3914 manifest_x *mfx = NULL;
3916 reader = xmlReaderForFile(manifest, NULL, 0);
3918 mfx = malloc(sizeof(manifest_x));
3920 memset(mfx, '\0', sizeof(manifest_x));
3921 if (__process_manifest(reader, mfx) < 0) {
3922 DBG("Parsing Failed\n");
3923 pkgmgr_parser_free_manifest_xml(mfx);
3926 DBG("Parsing Success\n");
3928 DBG("Memory allocation error\n");
3930 xmlFreeTextReader(reader);
3932 DBG("Unable to create xml reader\n");
3937 /* These APIs are intended to call parser directly */
3939 API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
3941 char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", NULL};
3942 if (manifest == NULL) {
3943 DBG("argument supplied is NULL\n");
3944 return PMINFO_R_EINVAL;
3946 DBG("parsing manifest for installation: %s\n", manifest);
3947 manifest_x *mfx = NULL;
3949 char roxml_check[PKG_STRING_LEN_MAX] = {'\0'};
3952 mfx = pkgmgr_parser_process_manifest_xml(manifest);
3953 DBG("Parsing Finished\n");
3955 return PMINFO_R_ERROR;
3957 __streamFile(manifest, ACTION_INSTALL, temp, mfx->package);
3958 __add_preload_info(mfx, manifest);
3959 DBG("Added preload infomation\n");
3961 snprintf(roxml_check, PKG_STRING_LEN_MAX, MANIFEST_RO_DIRECTORY "/%s.xml", mfx->package);
3962 if (access(roxml_check, F_OK) == 0)
3963 mfx->update = strdup("true");
3965 mfx->update = strdup("false");
3967 ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
3969 DBG("DB Insert failed\n");
3971 DBG("DB Insert Success\n");
3973 ret = __ps_make_nativeapp_desktop(mfx, 0);
3975 DBG("Creating desktop file failed\n");
3977 DBG("Creating desktop file Success\n");
3979 pkgmgr_parser_free_manifest_xml(mfx);
3986 API int pkgmgr_parser_create_desktop_file(manifest_x *mfx)
3990 DBG("Manifest pointer is NULL\n");
3993 ret = __ps_make_nativeapp_desktop(mfx, 0);
3995 DBG("Creating desktop file failed\n");
3997 DBG("Creating desktop file Success\n");
4002 API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
4004 char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", NULL};
4005 if (manifest == NULL) {
4006 DBG("argument supplied is NULL\n");
4007 return PMINFO_R_EINVAL;
4009 DBG("parsing manifest for upgradation: %s\n", manifest);
4010 manifest_x *mfx = NULL;
4013 mfx = pkgmgr_parser_process_manifest_xml(manifest);
4014 DBG("Parsing Finished\n");
4016 return PMINFO_R_ERROR;
4018 __streamFile(manifest, ACTION_UPGRADE, temp, mfx->package);
4019 __add_preload_info(mfx, manifest);
4020 DBG("Added preload infomation\n");
4022 mfx->update = strdup("true");
4023 ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
4025 DBG("DB Update failed\n");
4027 DBG("DB Update Success\n");
4029 ret = __ps_make_nativeapp_desktop(mfx, 1);
4031 DBG("Creating desktop file failed\n");
4033 DBG("Creating desktop file Success\n");
4035 pkgmgr_parser_free_manifest_xml(mfx);
4042 API int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[])
4044 char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", NULL};
4045 if (manifest == NULL) {
4046 DBG("argument supplied is NULL\n");
4047 return PMINFO_R_EINVAL;
4049 DBG("parsing manifest for uninstallation: %s\n", manifest);
4050 manifest_x *mfx = NULL;
4053 mfx = pkgmgr_parser_process_manifest_xml(manifest);
4054 DBG("Parsing Finished\n");
4056 return PMINFO_R_ERROR;
4058 __streamFile(manifest, ACTION_UNINSTALL, temp, mfx->package);
4059 __add_preload_info(mfx, manifest);
4060 DBG("Added preload infomation\n");
4062 ret = pkgmgr_parser_delete_manifest_info_from_db(mfx);
4064 DBG("DB Delete failed\n");
4066 DBG("DB Delete Success\n");
4068 ret = __ps_remove_nativeapp_desktop(mfx);
4070 DBG("Removing desktop file failed\n");
4072 DBG("Removing desktop file Success\n");
4074 pkgmgr_parser_free_manifest_xml(mfx);
4081 API char *pkgmgr_parser_get_manifest_file(const char *pkgid)
4083 return __pkgid_to_manifest(pkgid);
4086 API int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
4088 return __ps_run_parser(docPtr, tag, ACTION_INSTALL, pkgid);
4091 API int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgid)
4093 return __ps_run_parser(docPtr, tag, ACTION_UPGRADE, pkgid);
4096 API int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
4098 return __ps_run_parser(docPtr, tag, ACTION_UNINSTALL, pkgid);
4101 #define SCHEMA_FILE "/usr/etc/package-manager/preload/manifest.xsd"
4103 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
4105 if (manifest == NULL) {
4106 DBGE("manifest file is NULL\n");
4107 return PMINFO_R_EINVAL;
4110 xmlSchemaParserCtxtPtr ctx;
4111 xmlSchemaValidCtxtPtr vctx;
4112 xmlSchemaPtr xschema;
4113 ctx = xmlSchemaNewParserCtxt(SCHEMA_FILE);
4115 DBGE("xmlSchemaNewParserCtxt() Failed\n");
4116 return PMINFO_R_ERROR;
4118 xschema = xmlSchemaParse(ctx);
4119 if (xschema == NULL) {
4120 DBGE("xmlSchemaParse() Failed\n");
4121 return PMINFO_R_ERROR;
4123 vctx = xmlSchemaNewValidCtxt(xschema);
4125 DBGE("xmlSchemaNewValidCtxt() Failed\n");
4126 return PMINFO_R_ERROR;
4128 xmlSchemaSetValidErrors(vctx, (xmlSchemaValidityErrorFunc) fprintf, (xmlSchemaValidityWarningFunc) fprintf, stderr);
4129 ret = xmlSchemaValidateFile(vctx, manifest, 0);
4131 DBGE("xmlSchemaValidateFile() failed\n");
4132 return PMINFO_R_ERROR;
4133 } else if (ret == 0) {
4134 DBGE("Manifest is Valid\n");
4137 DBGE("Manifest Validation Failed with error code %d\n", ret);
4138 return PMINFO_R_ERROR;
4144 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
4154 DBGE("fork failed\n");
4159 int dev_null_fd = open ("/dev/null", O_RDWR);
4160 if (dev_null_fd >= 0)
4162 dup2 (dev_null_fd, 0);/*stdin*/
4163 dup2 (dev_null_fd, 1);/*stdout*/
4164 dup2 (dev_null_fd, 2);/*stderr*/
4167 if (execl("/usr/bin/xmllint", "xmllint", manifest, "--schema",
4168 SCHEMA_FILE, NULL) < 0) {
4169 DBGE("execl error\n");
4179 while ((err = waitpid(pid, &status, WNOHANG)) != pid) {
4183 DBGE("waitpid failed\n");
4189 if(WIFEXITED(status) && !WEXITSTATUS(status))