4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
7 * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
27 #include <libxml/parser.h>
28 #include <libxml/xmlreader.h>
29 #include <libxml/xmlschemas.h>
33 #include "pkgmgr_parser.h"
34 #include "pkgmgr_parser_internal.h"
35 #include "pkgmgr_parser_db.h"
36 #include "pkgmgr-info.h"
38 #define MANIFEST_RW_DIRECTORY "/opt/share/packages"
39 #define MANIFEST_RO_DIRECTORY "/usr/share/packages"
40 #define ASCII(s) (const char *)s
41 #define XMLCHAR(s) (const xmlChar *)s
53 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label);
54 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile);
55 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed);
56 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation);
57 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri);
58 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime);
59 static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp);
60 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition);
61 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notifiation);
62 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category);
63 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata);
64 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission);
65 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility);
66 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution);
67 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request);
68 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define);
69 static int __ps_process_registry(xmlTextReaderPtr reader, registry_x *registry);
70 static int __ps_process_database(xmlTextReaderPtr reader, database_x *database);
71 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc);
72 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions);
73 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare);
74 static int __ps_process_layout(xmlTextReaderPtr reader, layout_x *layout);
75 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon);
76 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author);
77 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description);
78 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability);
79 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license);
80 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol);
81 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol);
82 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication);
83 static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication);
84 static int __ps_process_font(xmlTextReaderPtr reader, font_x *font);
85 static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme);
86 static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon);
87 static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime);
88 static void __ps_free_label(label_x *label);
89 static void __ps_free_deviceprofile(deviceprofile_x * deviceprofile);
90 static void __ps_free_allowed(allowed_x *allowed);
91 static void __ps_free_operation(operation_x *operation);
92 static void __ps_free_uri(uri_x *uri);
93 static void __ps_free_mime(mime_x *mime);
94 static void __ps_free_subapp(subapp_x *subapp);
95 static void __ps_free_condition(condition_x *condition);
96 static void __ps_free_notification(notification_x *notifiation);
97 static void __ps_free_category(category_x *category);
98 static void __ps_free_metadata(metadata_x *metadata);
99 static void __ps_free_permission(permission_x *permission);
100 static void __ps_free_compatibility(compatibility_x *compatibility);
101 static void __ps_free_resolution(resolution_x *resolution);
102 static void __ps_free_request(request_x *request);
103 static void __ps_free_define(define_x *define);
104 static void __ps_free_registry(registry_x *registry);
105 static void __ps_free_database(database_x *database);
106 static void __ps_free_appsvc(appsvc_x *appsvc);
107 static void __ps_free_launchconditions(launchconditions_x *launchconditions);
108 static void __ps_free_datashare(datashare_x *datashare);
109 static void __ps_free_layout(layout_x *layout);
110 static void __ps_free_icon(icon_x *icon);
111 static void __ps_free_author(author_x *author);
112 static void __ps_free_description(description_x *description);
113 static void __ps_free_capability(capability_x *capability);
114 static void __ps_free_license(license_x *license);
115 static void __ps_free_appcontrol(appcontrol_x *appcontrol);
116 static void __ps_free_datacontrol(datacontrol_x *datacontrol);
117 static void __ps_free_uiapplication(uiapplication_x *uiapplication);
118 static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication);
119 static void __ps_free_font(font_x *font);
120 static void __ps_free_theme(theme_x *theme);
121 static void __ps_free_daemon(daemon_x *daemon);
122 static void __ps_free_ime(ime_x *ime);
123 static char *__pkgid_to_manifest(const char *pkgid);
124 static int __next_child_element(xmlTextReaderPtr reader, int depth);
125 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx);
126 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx);
127 static void __str_trim(char *input);
128 static char *__get_parser_plugin(const char *type);
129 static int __ps_run_parser(xmlDocPtr docPtr, const char *tag, ACTION_TYPE action, const char *pkgid);
130 static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid);
131 static void __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgid);
132 static void __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid);
133 static int __validate_appid(const char *pkgid, const char *appid, char **newappid);
135 static void __str_trim(char *input)
137 char *trim_str = input;
142 while (*input != 0) {
143 if (!isspace(*input)) {
154 static int __validate_appid(const char *pkgid, const char *appid, char **newappid)
156 if (!pkgid || !appid || !newappid) {
157 DBG("Arg supplied is NULL\n");
160 int pkglen = strlen(pkgid);
161 int applen = strlen(appid);
165 if (strncmp(appid, ".", 1) == 0) {
166 len = pkglen + applen + 1;
167 newapp = calloc(1,len);
168 if (newapp == NULL) {
169 DBG("Malloc failed\n");
172 strncpy(newapp, pkgid, pkglen);
173 strncat(newapp, appid, applen);
174 DBG("new appid is %s\n", newapp);
178 if (applen < pkglen) {
179 DBG("app id is not proper\n");
181 #ifdef _VALIDATE_APPID_
187 if (!strcmp(appid, pkgid)) {
188 DBG("appid is proper\n");
192 else if (strncmp(appid, pkgid, pkglen) == 0) {
193 ptr = strstr(appid, pkgid);
195 if (strncmp(ptr, ".", 1) == 0) {
196 DBG("appid is proper\n");
201 DBG("appid is not proper\n");
203 #ifdef _VALIDATE_APPID_
210 DBG("appid is not proper\n");
212 #ifdef _VALIDATE_APPID_
222 static char *__get_parser_plugin(const char *type)
225 char buffer[1024] = { 0 };
226 char temp_path[1024] = { 0 };
230 DBGE("invalid argument\n");
234 fp = fopen(PKG_PARSER_CONF_PATH, "r");
236 DBGE("no matching backendlib\n");
240 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
241 if (buffer[0] == '#')
246 if ((path = strstr(buffer, PKG_PARSERLIB)) != NULL) {
248 path = path + strlen(PKG_PARSERLIB);
254 memset(buffer, 0x00, 1024);
261 DBGE("no matching backendlib\n");
265 snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
267 return strdup(temp_path);
270 static int __ps_run_parser(xmlDocPtr docPtr, const char *tag,
271 ACTION_TYPE action, const char *pkgid)
273 char *lib_path = NULL;
274 void *lib_handle = NULL;
275 int (*plugin_install) (xmlDocPtr, const char *);
281 ac = "PKGMGR_PARSER_PLUGIN_INSTALL";
284 ac = "PKGMGR_PARSER_PLUGIN_UPGRADE";
286 case ACTION_UNINSTALL:
287 ac = "PKGMGR_PARSER_PLUGIN_UNINSTALL";
293 lib_path = __get_parser_plugin(tag);
298 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
299 DBGE("dlopen is failed lib_path[%s]\n", lib_path);
303 if ((plugin_install =
304 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
305 DBGE("can not find symbol \n");
309 ret = plugin_install(docPtr, pkgid);
319 static char *__pkgid_to_manifest(const char *pkgid)
325 DBGE("pkgid is NULL");
329 size = strlen(MANIFEST_RW_DIRECTORY) + strlen(pkgid) + 10;
330 manifest = malloc(size);
331 if (manifest == NULL) {
335 memset(manifest, '\0', size);
336 snprintf(manifest, size, MANIFEST_RW_DIRECTORY "/%s.xml", pkgid);
338 if (access(manifest, F_OK)) {
339 snprintf(manifest, size, MANIFEST_RO_DIRECTORY "/%s.xml", pkgid);
345 static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid)
350 DBG("__run_parser_prestep");
352 if (xmlTextReaderDepth(reader) != 1) {
353 DBGE("Node depth is not 1");
357 if (xmlTextReaderNodeType(reader) != 1) {
358 DBGE("Node type is not 1");
362 const xmlChar *value;
363 name = xmlTextReaderConstName(reader);
365 DBGE("TEST TEST TES\n");
366 name = BAD_CAST "--";
369 value = xmlTextReaderConstValue(reader);
370 DBG("%d %d %s %d %d",
371 xmlTextReaderDepth(reader),
372 xmlTextReaderNodeType(reader),
374 xmlTextReaderIsEmptyElement(reader), xmlTextReaderHasValue(reader));
377 DBG("ConstValue NULL");
379 if (xmlStrlen(value) > 40) {
380 DBG(" %.40s...", value);
386 name = xmlTextReaderConstName(reader);
388 DBGE("TEST TEST TES\n");
389 name = BAD_CAST "--";
392 xmlDocPtr docPtr = xmlTextReaderCurrentDoc(reader);
393 DBG("docPtr->URL %s\n", (char *)docPtr->URL);
394 xmlDocPtr copyDocPtr = xmlCopyDoc(docPtr, 1);
395 if (copyDocPtr == NULL)
397 xmlNode *rootElement = xmlDocGetRootElement(copyDocPtr);
398 if (rootElement == NULL)
400 xmlNode *cur_node = xmlFirstElementChild(rootElement);
401 if (cur_node == NULL)
403 xmlNode *temp = xmlTextReaderExpand(reader);
406 xmlNode *next_node = NULL;
407 while(cur_node != NULL)
409 if ( (strcmp(temp->name, cur_node->name) == 0) &&
410 (temp->line == cur_node->line) ) {
414 next_node = xmlNextElementSibling(cur_node);
415 xmlUnlinkNode(cur_node);
416 xmlFreeNode(cur_node);
417 cur_node = next_node;
420 if (cur_node == NULL)
422 next_node = xmlNextElementSibling(cur_node);
424 cur_node->next = NULL;
425 next_node->prev = NULL;
426 xmlFreeNodeList(next_node);
427 xmlSetTreeDoc(cur_node, copyDocPtr);
429 xmlSetTreeDoc(cur_node, copyDocPtr);
435 DBG("node type: %d, name: %s children->name: %s last->name: %s\n"
436 "parent->name: %s next->name: %s prev->name: %s\n",
437 cur_node->type, cur_node->name,
438 cur_node->children ? cur_node->children->name : "NULL",
439 cur_node->last ? cur_node->last->name : "NULL",
440 cur_node->parent ? cur_node->parent->name : "NULL",
441 cur_node->next ? cur_node->next->name : "NULL",
442 cur_node->prev ? cur_node->prev->name : "NULL");
444 FILE *fp = fopen("/opt/share/test.xml", "a");
445 xmlDocDump(fp, copyDocPtr);
450 ret = __ps_run_parser(copyDocPtr, name, action, pkgid);
457 __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgid)
462 switch (xmlTextReaderNodeType(reader)) {
463 case XML_READER_TYPE_END_ELEMENT:
465 // DBG("XML_READER_TYPE_END_ELEMENT");
469 case XML_READER_TYPE_ELEMENT:
471 // Elements without closing tag don't receive
472 // XML_READER_TYPE_END_ELEMENT event.
474 const xmlChar *elementName =
475 xmlTextReaderLocalName(reader);
476 if (elementName == NULL) {
477 // DBG("elementName %s\n", (char *)elementName);
481 const xmlChar *nameSpace =
482 xmlTextReaderConstNamespaceUri(reader);
484 // DBG("nameSpace %s\n", (char *)nameSpace);
487 DBG("XML_READER_TYPE_ELEMENT %s, %s\n",
488 elementName ? elementName : "NULL",
489 nameSpace ? nameSpace : "NULL");
492 DBG("__run_parser_prestep pkgid[%s]\n", pkgid);
493 __run_parser_prestep(reader, action, pkgid);
497 for (tag = tagv[0]; tag; tag = tagv[++i])
498 if (strcmp(tag, elementName) == 0) {
499 DBG("__run_parser_prestep tag[%s] pkgid[%s]\n", tag, pkgid);
500 __run_parser_prestep(reader,
508 case XML_READER_TYPE_TEXT:
509 case XML_READER_TYPE_CDATA:
511 const xmlChar *value = xmlTextReaderConstValue(reader);
513 // DBG("value %s\n", value);
516 const xmlChar *lang = xmlTextReaderConstXmlLang(reader);
518 // DBG("lang\n", lang);
521 /* DBG("XML_READER_TYPE_TEXT %s, %s\n",
522 value ? value : "NULL", lang ? lang : "NULL");
527 // DBG("Ignoring Node of Type: %d", xmlTextReaderNodeType(reader));
533 __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid)
535 xmlTextReaderPtr reader;
539 docPtr = xmlReadFile(filename, NULL, 0);
540 reader = xmlReaderWalker(docPtr);
541 if (reader != NULL) {
542 ret = xmlTextReaderRead(reader);
544 __processNode(reader, action, tagv, pkgid);
545 ret = xmlTextReaderRead(reader);
547 xmlFreeTextReader(reader);
550 DBGE("%s : failed to parse", filename);
553 DBGE("Unable to open %s", filename);
557 static int __next_child_element(xmlTextReaderPtr reader, int depth)
559 int ret = xmlTextReaderRead(reader);
560 int cur = xmlTextReaderDepth(reader);
563 switch (xmlTextReaderNodeType(reader)) {
564 case XML_READER_TYPE_ELEMENT:
565 if (cur == depth + 1)
568 case XML_READER_TYPE_TEXT:
569 /*text is handled by each function separately*/
570 if (cur == depth + 1)
573 case XML_READER_TYPE_END_ELEMENT:
582 ret = xmlTextReaderRead(reader);
583 cur = xmlTextReaderDepth(reader);
588 static void __ps_free_category(category_x *category)
590 if (category == NULL)
592 if (category->name) {
593 free((void *)category->name);
594 category->name = NULL;
596 free((void*)category);
600 static void __ps_free_metadata(metadata_x *metadata)
602 if (metadata == NULL)
604 if (metadata->name) {
605 free((void *)metadata->name);
606 metadata->name = NULL;
608 if (metadata->value) {
609 free((void *)metadata->value);
610 metadata->value = NULL;
612 free((void*)metadata);
616 static void __ps_free_permission(permission_x *permission)
618 if (permission == NULL)
620 if (permission->type) {
621 free((void *)permission->type);
622 permission->type = NULL;
624 if (permission->value) {
625 free((void *)permission->value);
626 permission->value = NULL;
628 free((void*)permission);
632 static void __ps_free_icon(icon_x *icon)
637 free((void *)icon->text);
641 free((void *)icon->lang);
645 free((void *)icon->name);
649 free((void *)icon->section);
650 icon->section = NULL;
653 free((void *)icon->size);
656 if (icon->resolution) {
657 free((void *)icon->resolution);
658 icon->resolution = NULL;
664 static void __ps_free_image(image_x *image)
669 free((void *)image->text);
673 free((void *)image->lang);
677 free((void *)image->name);
680 if (image->section) {
681 free((void *)image->section);
682 image->section = NULL;
688 static void __ps_free_operation(operation_x *operation)
690 if (operation == NULL)
692 if (operation->text) {
693 free((void *)operation->text);
694 operation->text = NULL;
696 free((void*)operation);
700 static void __ps_free_uri(uri_x *uri)
705 free((void *)uri->text);
712 static void __ps_free_mime(mime_x *mime)
717 free((void *)mime->text);
724 static void __ps_free_subapp(subapp_x *subapp)
729 free((void *)subapp->text);
736 static void __ps_free_condition(condition_x *condition)
738 if (condition == NULL)
740 if (condition->text) {
741 free((void *)condition->text);
742 condition->text = NULL;
744 if (condition->name) {
745 free((void *)condition->name);
746 condition->name = NULL;
748 free((void*)condition);
752 static void __ps_free_notification(notification_x *notification)
754 if (notification == NULL)
756 if (notification->text) {
757 free((void *)notification->text);
758 notification->text = NULL;
760 if (notification->name) {
761 free((void *)notification->name);
762 notification->name = NULL;
764 free((void*)notification);
768 static void __ps_free_compatibility(compatibility_x *compatibility)
770 if (compatibility == NULL)
772 if (compatibility->text) {
773 free((void *)compatibility->text);
774 compatibility->text = NULL;
776 if (compatibility->name) {
777 free((void *)compatibility->name);
778 compatibility->name = NULL;
780 free((void*)compatibility);
781 compatibility = NULL;
784 static void __ps_free_resolution(resolution_x *resolution)
786 if (resolution == NULL)
788 if (resolution->mimetype) {
789 free((void *)resolution->mimetype);
790 resolution->mimetype = NULL;
792 if (resolution->urischeme) {
793 free((void *)resolution->urischeme);
794 resolution->urischeme = NULL;
796 free((void*)resolution);
800 static void __ps_free_capability(capability_x *capability)
802 if (capability == NULL)
804 if (capability->operationid) {
805 free((void *)capability->operationid);
806 capability->operationid = NULL;
809 if (capability->resolution) {
810 resolution_x *resolution = capability->resolution;
811 resolution_x *tmp = NULL;
812 while(resolution != NULL)
814 tmp = resolution->next;
815 __ps_free_resolution(resolution);
819 free((void*)capability);
823 static void __ps_free_allowed(allowed_x *allowed)
828 free((void *)allowed->name);
829 allowed->name = NULL;
832 free((void *)allowed->text);
833 allowed->text = NULL;
835 free((void*)allowed);
839 static void __ps_free_request(request_x *request)
844 free((void *)request->text);
845 request->text = NULL;
847 free((void*)request);
851 static void __ps_free_datacontrol(datacontrol_x *datacontrol)
853 if (datacontrol == NULL)
855 if (datacontrol->providerid) {
856 free((void *)datacontrol->providerid);
857 datacontrol->providerid = NULL;
860 if (datacontrol->capability) {
861 capability_x *capability = datacontrol->capability;
862 capability_x *tmp = NULL;
863 while(capability != NULL)
865 tmp = capability->next;
866 __ps_free_capability(capability);
870 free((void*)datacontrol);
874 static void __ps_free_launchconditions(launchconditions_x *launchconditions)
876 if (launchconditions == NULL)
878 if (launchconditions->text) {
879 free((void *)launchconditions->text);
880 launchconditions->text = NULL;
883 if (launchconditions->condition) {
884 condition_x *condition = launchconditions->condition;
885 condition_x *tmp = NULL;
886 while(condition != NULL)
888 tmp = condition->next;
889 __ps_free_condition(condition);
893 free((void*)launchconditions);
894 launchconditions = NULL;
897 static void __ps_free_appcontrol(appcontrol_x *appcontrol)
899 if (appcontrol == NULL)
901 if (appcontrol->text) {
902 free((void *)appcontrol->text);
903 appcontrol->text = NULL;
906 if (appcontrol->operation) {
907 operation_x *operation = appcontrol->operation;
908 operation_x *tmp = NULL;
909 while(operation != NULL)
911 tmp = operation->next;
912 __ps_free_operation(operation);
917 if (appcontrol->uri) {
918 uri_x *uri = appcontrol->uri;
928 if (appcontrol->mime) {
929 mime_x *mime = appcontrol->mime;
934 __ps_free_mime(mime);
939 if (appcontrol->subapp) {
940 subapp_x *subapp = appcontrol->subapp;
941 subapp_x *tmp = NULL;
942 while(subapp != NULL)
945 __ps_free_subapp(subapp);
949 free((void*)appcontrol);
953 static void __ps_free_appsvc(appsvc_x *appsvc)
958 free((void *)appsvc->text);
962 if (appsvc->operation) {
963 operation_x *operation = appsvc->operation;
964 operation_x *tmp = NULL;
965 while(operation != NULL)
967 tmp = operation->next;
968 __ps_free_operation(operation);
974 uri_x *uri = appsvc->uri;
985 mime_x *mime = appsvc->mime;
990 __ps_free_mime(mime);
995 if (appsvc->subapp) {
996 subapp_x *subapp = appsvc->subapp;
997 subapp_x *tmp = NULL;
998 while(subapp != NULL)
1001 __ps_free_subapp(subapp);
1005 free((void*)appsvc);
1009 static void __ps_free_deviceprofile(deviceprofile_x *deviceprofile)
1014 static void __ps_free_define(define_x *define)
1019 free((void *)define->path);
1020 define->path = NULL;
1023 if (define->request) {
1024 request_x *request = define->request;
1025 request_x *tmp = NULL;
1026 while(request != NULL)
1028 tmp = request->next;
1029 __ps_free_request(request);
1034 if (define->allowed) {
1035 allowed_x *allowed = define->allowed;
1036 allowed_x *tmp = NULL;
1037 while(allowed != NULL)
1039 tmp = allowed->next;
1040 __ps_free_allowed(allowed);
1044 free((void*)define);
1048 static void __ps_free_registry(registry_x *registry)
1050 if (registry == NULL)
1052 if (registry->name) {
1053 free((void *)registry->name);
1054 registry->name = NULL;
1056 if (registry->text) {
1057 free((void *)registry->text);
1058 registry->text = NULL;
1060 free((void*)registry);
1064 static void __ps_free_database(database_x *database)
1066 if (database == NULL)
1068 if (database->name) {
1069 free((void *)database->name);
1070 database->name = NULL;
1072 if (database->text) {
1073 free((void *)database->text);
1074 database->text = NULL;
1076 free((void*)database);
1080 static void __ps_free_datashare(datashare_x *datashare)
1082 if (datashare == NULL)
1085 if (datashare->define) {
1086 define_x *define = datashare->define;
1087 define_x *tmp = NULL;
1088 while(define != NULL)
1091 __ps_free_define(define);
1096 if (datashare->request) {
1097 request_x *request = datashare->request;
1098 request_x *tmp = NULL;
1099 while(request != NULL)
1101 tmp = request->next;
1102 __ps_free_request(request);
1106 free((void*)datashare);
1110 static void __ps_free_layout(layout_x *layout)
1115 free((void *)layout->name);
1116 layout->name = NULL;
1119 free((void *)layout->text);
1120 layout->text = NULL;
1122 free((void*)layout);
1126 static void __ps_free_label(label_x *label)
1131 free((void *)label->name);
1135 free((void *)label->text);
1139 free((void *)label->lang);
1146 static void __ps_free_author(author_x *author)
1150 if (author->email) {
1151 free((void *)author->email);
1152 author->email = NULL;
1155 free((void *)author->text);
1156 author->text = NULL;
1159 free((void *)author->href);
1160 author->href = NULL;
1163 free((void *)author->lang);
1164 author->lang = NULL;
1166 free((void*)author);
1170 static void __ps_free_description(description_x *description)
1172 if (description == NULL)
1174 if (description->name) {
1175 free((void *)description->name);
1176 description->name = NULL;
1178 if (description->text) {
1179 free((void *)description->text);
1180 description->text = NULL;
1182 if (description->lang) {
1183 free((void *)description->lang);
1184 description->lang = NULL;
1186 free((void*)description);
1190 static void __ps_free_license(license_x *license)
1192 if (license == NULL)
1194 if (license->text) {
1195 free((void *)license->text);
1196 license->text = NULL;
1198 if (license->lang) {
1199 free((void *)license->lang);
1200 license->lang = NULL;
1202 free((void*)license);
1206 static void __ps_free_uiapplication(uiapplication_x *uiapplication)
1208 if (uiapplication == NULL)
1210 if (uiapplication->exec) {
1211 free((void *)uiapplication->exec);
1212 uiapplication->exec = NULL;
1214 if (uiapplication->appid) {
1215 free((void *)uiapplication->appid);
1216 uiapplication->appid = NULL;
1218 if (uiapplication->nodisplay) {
1219 free((void *)uiapplication->nodisplay);
1220 uiapplication->nodisplay = NULL;
1222 if (uiapplication->multiple) {
1223 free((void *)uiapplication->multiple);
1224 uiapplication->multiple = NULL;
1226 if (uiapplication->type) {
1227 free((void *)uiapplication->type);
1228 uiapplication->type = NULL;
1230 if (uiapplication->categories) {
1231 free((void *)uiapplication->categories);
1232 uiapplication->categories = NULL;
1234 if (uiapplication->extraid) {
1235 free((void *)uiapplication->extraid);
1236 uiapplication->extraid = NULL;
1238 if (uiapplication->taskmanage) {
1239 free((void *)uiapplication->taskmanage);
1240 uiapplication->taskmanage = NULL;
1242 if (uiapplication->enabled) {
1243 free((void *)uiapplication->enabled);
1244 uiapplication->enabled = NULL;
1246 if (uiapplication->hwacceleration) {
1247 free((void *)uiapplication->hwacceleration);
1248 uiapplication->hwacceleration = NULL;
1250 if (uiapplication->mainapp) {
1251 free((void *)uiapplication->mainapp);
1252 uiapplication->mainapp = NULL;
1254 if (uiapplication->recentimage) {
1255 free((void *)uiapplication->recentimage);
1256 uiapplication->recentimage = NULL;
1259 if (uiapplication->label) {
1260 label_x *label = uiapplication->label;
1261 label_x *tmp = NULL;
1262 while(label != NULL)
1265 __ps_free_label(label);
1270 if (uiapplication->icon) {
1271 icon_x *icon = uiapplication->icon;
1276 __ps_free_icon(icon);
1281 if (uiapplication->image) {
1282 image_x *image = uiapplication->image;
1283 image_x *tmp = NULL;
1284 while(image != NULL)
1287 __ps_free_image(image);
1292 if (uiapplication->appcontrol) {
1293 appcontrol_x *appcontrol = uiapplication->appcontrol;
1294 appcontrol_x *tmp = NULL;
1295 while(appcontrol != NULL)
1297 tmp = appcontrol->next;
1298 __ps_free_appcontrol(appcontrol);
1302 /*Free LaunchConditions*/
1303 if (uiapplication->launchconditions) {
1304 launchconditions_x *launchconditions = uiapplication->launchconditions;
1305 launchconditions_x *tmp = NULL;
1306 while(launchconditions != NULL)
1308 tmp = launchconditions->next;
1309 __ps_free_launchconditions(launchconditions);
1310 launchconditions = tmp;
1313 /*Free Notification*/
1314 if (uiapplication->notification) {
1315 notification_x *notification = uiapplication->notification;
1316 notification_x *tmp = NULL;
1317 while(notification != NULL)
1319 tmp = notification->next;
1320 __ps_free_notification(notification);
1325 if (uiapplication->datashare) {
1326 datashare_x *datashare = uiapplication->datashare;
1327 datashare_x *tmp = NULL;
1328 while(datashare != NULL)
1330 tmp = datashare->next;
1331 __ps_free_datashare(datashare);
1336 if (uiapplication->appsvc) {
1337 appsvc_x *appsvc = uiapplication->appsvc;
1338 appsvc_x *tmp = NULL;
1339 while(appsvc != NULL)
1342 __ps_free_appsvc(appsvc);
1347 if (uiapplication->category) {
1348 category_x *category = uiapplication->category;
1349 category_x *tmp = NULL;
1350 while(category != NULL)
1352 tmp = category->next;
1353 __ps_free_category(category);
1358 if (uiapplication->metadata) {
1359 metadata_x *metadata = uiapplication->metadata;
1360 metadata_x *tmp = NULL;
1361 while(metadata != NULL)
1363 tmp = metadata->next;
1364 __ps_free_metadata(metadata);
1369 if (uiapplication->permission) {
1370 permission_x *permission = uiapplication->permission;
1371 permission_x *tmp = NULL;
1372 while(permission != NULL)
1374 tmp = permission->next;
1375 __ps_free_permission(permission);
1379 /* _PRODUCT_LAUNCHING_ENHANCED_ START */
1380 if (uiapplication->indicatordisplay) {
1381 free((void *)uiapplication->indicatordisplay);
1382 uiapplication->indicatordisplay = NULL;
1384 if (uiapplication->portraitimg) {
1385 free((void *)uiapplication->portraitimg);
1386 uiapplication->portraitimg = NULL;
1388 if (uiapplication->landscapeimg) {
1389 free((void *)uiapplication->landscapeimg);
1390 uiapplication->landscapeimg = NULL;
1392 /* _PRODUCT_LAUNCHING_ENHANCED_ END */
1393 if (uiapplication->guestmode_visibility) {
1394 free((void *)uiapplication->guestmode_visibility);
1395 uiapplication->guestmode_visibility = NULL;
1397 free((void*)uiapplication);
1398 uiapplication = NULL;
1401 static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication)
1403 if (serviceapplication == NULL)
1405 if (serviceapplication->exec) {
1406 free((void *)serviceapplication->exec);
1407 serviceapplication->exec = NULL;
1409 if (serviceapplication->appid) {
1410 free((void *)serviceapplication->appid);
1411 serviceapplication->appid = NULL;
1413 if (serviceapplication->onboot) {
1414 free((void *)serviceapplication->onboot);
1415 serviceapplication->onboot = NULL;
1417 if (serviceapplication->autorestart) {
1418 free((void *)serviceapplication->autorestart);
1419 serviceapplication->autorestart = NULL;
1421 if (serviceapplication->type) {
1422 free((void *)serviceapplication->type);
1423 serviceapplication->type = NULL;
1426 if (serviceapplication->label) {
1427 label_x *label = serviceapplication->label;
1428 label_x *tmp = NULL;
1429 while(label != NULL)
1432 __ps_free_label(label);
1437 if (serviceapplication->icon) {
1438 icon_x *icon = serviceapplication->icon;
1443 __ps_free_icon(icon);
1448 if (serviceapplication->appcontrol) {
1449 appcontrol_x *appcontrol = serviceapplication->appcontrol;
1450 appcontrol_x *tmp = NULL;
1451 while(appcontrol != NULL)
1453 tmp = appcontrol->next;
1454 __ps_free_appcontrol(appcontrol);
1458 /*Free DataControl*/
1459 if (serviceapplication->datacontrol) {
1460 datacontrol_x *datacontrol = serviceapplication->datacontrol;
1461 datacontrol_x *tmp = NULL;
1462 while(datacontrol != NULL)
1464 tmp = datacontrol->next;
1465 __ps_free_datacontrol(datacontrol);
1469 /*Free LaunchConditions*/
1470 if (serviceapplication->launchconditions) {
1471 launchconditions_x *launchconditions = serviceapplication->launchconditions;
1472 launchconditions_x *tmp = NULL;
1473 while(launchconditions != NULL)
1475 tmp = launchconditions->next;
1476 __ps_free_launchconditions(launchconditions);
1477 launchconditions = tmp;
1480 /*Free Notification*/
1481 if (serviceapplication->notification) {
1482 notification_x *notification = serviceapplication->notification;
1483 notification_x *tmp = NULL;
1484 while(notification != NULL)
1486 tmp = notification->next;
1487 __ps_free_notification(notification);
1492 if (serviceapplication->datashare) {
1493 datashare_x *datashare = serviceapplication->datashare;
1494 datashare_x *tmp = NULL;
1495 while(datashare != NULL)
1497 tmp = datashare->next;
1498 __ps_free_datashare(datashare);
1503 if (serviceapplication->appsvc) {
1504 appsvc_x *appsvc = serviceapplication->appsvc;
1505 appsvc_x *tmp = NULL;
1506 while(appsvc != NULL)
1509 __ps_free_appsvc(appsvc);
1514 if (serviceapplication->category) {
1515 category_x *category = serviceapplication->category;
1516 category_x *tmp = NULL;
1517 while(category != NULL)
1519 tmp = category->next;
1520 __ps_free_category(category);
1525 if (serviceapplication->metadata) {
1526 metadata_x *metadata = serviceapplication->metadata;
1527 metadata_x *tmp = NULL;
1528 while(metadata != NULL)
1530 tmp = metadata->next;
1531 __ps_free_metadata(metadata);
1536 if (serviceapplication->permission) {
1537 permission_x *permission = serviceapplication->permission;
1538 permission_x *tmp = NULL;
1539 while(permission != NULL)
1541 tmp = permission->next;
1542 __ps_free_permission(permission);
1546 free((void*)serviceapplication);
1547 serviceapplication = NULL;
1550 static void __ps_free_font(font_x *font)
1555 free((void *)font->name);
1559 free((void *)font->text);
1566 static void __ps_free_theme(theme_x *theme)
1571 free((void *)theme->name);
1575 free((void *)theme->text);
1582 static void __ps_free_daemon(daemon_x *daemon)
1587 free((void *)daemon->name);
1588 daemon->name = NULL;
1591 free((void *)daemon->text);
1592 daemon->text = NULL;
1594 free((void*)daemon);
1598 static void __ps_free_ime(ime_x *ime)
1603 free((void *)ime->name);
1607 free((void *)ime->text);
1615 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed)
1617 xmlTextReaderRead(reader);
1618 if (xmlTextReaderValue(reader))
1619 allowed->text = ASCII(xmlTextReaderValue(reader));
1623 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation)
1625 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1626 operation->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1627 /* Text does not exist. Only attribute exists
1628 xmlTextReaderRead(reader);
1629 if (xmlTextReaderValue(reader))
1630 operation->text = ASCII(xmlTextReaderValue(reader));
1635 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri)
1637 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1638 uri->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1639 /* Text does not exist. Only attribute exists
1640 xmlTextReaderRead(reader);
1641 if (xmlTextReaderValue(reader))
1642 uri->text = ASCII(xmlTextReaderValue(reader));
1647 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime)
1649 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1650 mime->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1651 /* Text does not exist. Only attribute exists
1652 xmlTextReaderRead(reader);
1653 if (xmlTextReaderValue(reader))
1654 mime->text = ASCII(xmlTextReaderValue(reader));
1659 static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp)
1661 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1662 subapp->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1663 /* Text does not exist. Only attribute exists
1664 xmlTextReaderRead(reader);
1665 if (xmlTextReaderValue(reader))
1666 mime->text = ASCII(xmlTextReaderValue(reader));
1671 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition)
1673 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1674 condition->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1675 xmlTextReaderRead(reader);
1676 if (xmlTextReaderValue(reader))
1677 condition->text = ASCII(xmlTextReaderValue(reader));
1681 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notification)
1683 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1684 notification->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1685 xmlTextReaderRead(reader);
1686 if (xmlTextReaderValue(reader))
1687 notification->text = ASCII(xmlTextReaderValue(reader));
1691 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category)
1693 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1694 category->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1698 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata)
1700 /*name and value both should exist. If any one attribute is missing then dont parse*/
1701 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")) && xmlTextReaderGetAttribute(reader, XMLCHAR("value"))) {
1702 metadata->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1703 metadata->value = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("value")));
1708 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission)
1710 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
1711 permission->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
1713 xmlTextReaderRead(reader);
1714 if (xmlTextReaderValue(reader))
1715 permission->value = ASCII(xmlTextReaderValue(reader));
1719 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility)
1721 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1722 compatibility->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1723 xmlTextReaderRead(reader);
1724 if (xmlTextReaderValue(reader))
1725 compatibility->text = ASCII(xmlTextReaderValue(reader));
1729 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution)
1731 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")))
1732 resolution->mimetype = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")));
1733 if (xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")))
1734 resolution->urischeme = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")));
1738 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request)
1740 xmlTextReaderRead(reader);
1741 if (xmlTextReaderValue(reader))
1742 request->text = ASCII(xmlTextReaderValue(reader));
1746 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define)
1748 const xmlChar *node;
1751 allowed_x *tmp1 = NULL;
1752 request_x *tmp2 = NULL;
1754 if (xmlTextReaderGetAttribute(reader, XMLCHAR("path")))
1755 define->path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("path")));
1757 depth = xmlTextReaderDepth(reader);
1758 while ((ret = __next_child_element(reader, depth))) {
1759 node = xmlTextReaderConstName(reader);
1761 DBG("xmlTextReaderConstName value is NULL\n");
1765 if (!strcmp(ASCII(node), "allowed")) {
1766 allowed_x *allowed= malloc(sizeof(allowed_x));
1767 if (allowed == NULL) {
1768 DBG("Malloc Failed\n");
1771 memset(allowed, '\0', sizeof(allowed_x));
1772 LISTADD(define->allowed, allowed);
1773 ret = __ps_process_allowed(reader, allowed);
1774 } else if (!strcmp(ASCII(node), "request")) {
1775 request_x *request = malloc(sizeof(request_x));
1776 if (request == NULL) {
1777 DBG("Malloc Failed\n");
1780 memset(request, '\0', sizeof(request_x));
1781 LISTADD(define->request, request);
1782 ret = __ps_process_request(reader, request);
1786 DBG("Processing define failed\n");
1790 if (define->allowed) {
1791 LISTHEAD(define->allowed, tmp1);
1792 define->allowed = tmp1;
1794 if (define->request) {
1795 LISTHEAD(define->request, tmp2);
1796 define->request = tmp2;
1801 static int __ps_process_registry(xmlTextReaderPtr reader, registry_x *registry)
1803 /*TODO: once policy is set*/
1807 static int __ps_process_database(xmlTextReaderPtr reader, database_x *database)
1809 /*TODO: once policy is set*/
1813 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol)
1815 const xmlChar *node;
1818 operation_x *tmp1 = NULL;
1820 mime_x *tmp3 = NULL;
1821 subapp_x *tmp4 = NULL;
1823 depth = xmlTextReaderDepth(reader);
1824 while ((ret = __next_child_element(reader, depth))) {
1825 node = xmlTextReaderConstName(reader);
1827 DBG("xmlTextReaderConstName value is NULL\n");
1831 if (!strcmp(ASCII(node), "operation")) {
1832 operation_x *operation = malloc(sizeof(operation_x));
1833 if (operation == NULL) {
1834 DBG("Malloc Failed\n");
1837 memset(operation, '\0', sizeof(operation_x));
1838 LISTADD(appcontrol->operation, operation);
1839 ret = __ps_process_operation(reader, operation);
1840 DBG("operation processing\n");
1841 } else if (!strcmp(ASCII(node), "uri")) {
1842 uri_x *uri= malloc(sizeof(uri_x));
1844 DBG("Malloc Failed\n");
1847 memset(uri, '\0', sizeof(uri_x));
1848 LISTADD(appcontrol->uri, uri);
1849 ret = __ps_process_uri(reader, uri);
1850 DBG("uri processing\n");
1851 } else if (!strcmp(ASCII(node), "mime")) {
1852 mime_x *mime = malloc(sizeof(mime_x));
1854 DBG("Malloc Failed\n");
1857 memset(mime, '\0', sizeof(mime_x));
1858 LISTADD(appcontrol->mime, mime);
1859 ret = __ps_process_mime(reader, mime);
1860 DBG("mime processing\n");
1861 } else if (!strcmp(ASCII(node), "subapp")) {
1862 subapp_x *subapp = malloc(sizeof(subapp_x));
1863 if (subapp == NULL) {
1864 DBG("Malloc Failed\n");
1867 memset(subapp, '\0', sizeof(subapp_x));
1868 LISTADD(appcontrol->subapp, subapp);
1869 ret = __ps_process_subapp(reader, subapp);
1870 DBG("subapp processing\n");
1874 DBG("Processing appcontrol failed\n");
1878 if (appcontrol->operation) {
1879 LISTHEAD(appcontrol->operation, tmp1);
1880 appcontrol->operation = tmp1;
1882 if (appcontrol->uri) {
1883 LISTHEAD(appcontrol->uri, tmp2);
1884 appcontrol->uri = tmp2;
1886 if (appcontrol->mime) {
1887 LISTHEAD(appcontrol->mime, tmp3);
1888 appcontrol->mime = tmp3;
1890 if (appcontrol->subapp) {
1891 LISTHEAD(appcontrol->subapp, tmp4);
1892 appcontrol->subapp = tmp4;
1895 xmlTextReaderRead(reader);
1896 if (xmlTextReaderValue(reader))
1897 appcontrol->text = ASCII(xmlTextReaderValue(reader));
1902 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc)
1904 const xmlChar *node;
1907 operation_x *tmp1 = NULL;
1909 mime_x *tmp3 = NULL;
1910 subapp_x *tmp4 = NULL;
1912 depth = xmlTextReaderDepth(reader);
1913 while ((ret = __next_child_element(reader, depth))) {
1914 node = xmlTextReaderConstName(reader);
1916 DBG("xmlTextReaderConstName value is NULL\n");
1920 if (!strcmp(ASCII(node), "operation")) {
1921 operation_x *operation = malloc(sizeof(operation_x));
1922 if (operation == NULL) {
1923 DBG("Malloc Failed\n");
1926 memset(operation, '\0', sizeof(operation_x));
1927 LISTADD(appsvc->operation, operation);
1928 ret = __ps_process_operation(reader, operation);
1929 DBG("operation processing\n");
1930 } else if (!strcmp(ASCII(node), "uri")) {
1931 uri_x *uri= malloc(sizeof(uri_x));
1933 DBG("Malloc Failed\n");
1936 memset(uri, '\0', sizeof(uri_x));
1937 LISTADD(appsvc->uri, uri);
1938 ret = __ps_process_uri(reader, uri);
1939 DBG("uri processing\n");
1940 } else if (!strcmp(ASCII(node), "mime")) {
1941 mime_x *mime = malloc(sizeof(mime_x));
1943 DBG("Malloc Failed\n");
1946 memset(mime, '\0', sizeof(mime_x));
1947 LISTADD(appsvc->mime, mime);
1948 ret = __ps_process_mime(reader, mime);
1949 DBG("mime processing\n");
1950 } else if (!strcmp(ASCII(node), "subapp")) {
1951 subapp_x *subapp = malloc(sizeof(subapp_x));
1952 if (subapp == NULL) {
1953 DBG("Malloc Failed\n");
1956 memset(subapp, '\0', sizeof(subapp_x));
1957 LISTADD(appsvc->subapp, subapp);
1958 ret = __ps_process_subapp(reader, subapp);
1959 DBG("subapp processing\n");
1963 DBG("Processing appsvc failed\n");
1967 if (appsvc->operation) {
1968 LISTHEAD(appsvc->operation, tmp1);
1969 appsvc->operation = tmp1;
1972 LISTHEAD(appsvc->uri, tmp2);
1976 LISTHEAD(appsvc->mime, tmp3);
1977 appsvc->mime = tmp3;
1979 if (appsvc->subapp) {
1980 LISTHEAD(appsvc->subapp, tmp4);
1981 appsvc->subapp = tmp4;
1984 xmlTextReaderRead(reader);
1985 if (xmlTextReaderValue(reader))
1986 appsvc->text = ASCII(xmlTextReaderValue(reader));
1991 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions)
1993 const xmlChar *node;
1996 condition_x *tmp1 = NULL;
1998 depth = xmlTextReaderDepth(reader);
1999 while ((ret = __next_child_element(reader, depth))) {
2000 node = xmlTextReaderConstName(reader);
2002 DBG("xmlTextReaderConstName value is NULL\n");
2006 if (strcmp(ASCII(node), "condition") == 0) {
2007 condition_x *condition = malloc(sizeof(condition_x));
2008 if (condition == NULL) {
2009 DBG("Malloc Failed\n");
2012 memset(condition, '\0', sizeof(condition_x));
2013 LISTADD(launchconditions->condition, condition);
2014 ret = __ps_process_condition(reader, condition);
2018 DBG("Processing launchconditions failed\n");
2022 if (launchconditions->condition) {
2023 LISTHEAD(launchconditions->condition, tmp1);
2024 launchconditions->condition = tmp1;
2027 xmlTextReaderRead(reader);
2028 if (xmlTextReaderValue(reader))
2029 launchconditions->text = ASCII(xmlTextReaderValue(reader));
2034 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare)
2036 const xmlChar *node;
2039 define_x *tmp1 = NULL;
2040 request_x *tmp2 = NULL;
2041 depth = xmlTextReaderDepth(reader);
2042 while ((ret = __next_child_element(reader, depth))) {
2043 node = xmlTextReaderConstName(reader);
2045 DBG("xmlTextReaderConstName value is NULL\n");
2049 if (!strcmp(ASCII(node), "define")) {
2050 define_x *define= malloc(sizeof(define_x));
2051 if (define == NULL) {
2052 DBG("Malloc Failed\n");
2055 memset(define, '\0', sizeof(define_x));
2056 LISTADD(datashare->define, define);
2057 ret = __ps_process_define(reader, define);
2058 } else if (!strcmp(ASCII(node), "request")) {
2059 request_x *request= malloc(sizeof(request_x));
2060 if (request == NULL) {
2061 DBG("Malloc Failed\n");
2064 memset(request, '\0', sizeof(request_x));
2065 LISTADD(datashare->request, request);
2066 ret = __ps_process_request(reader, request);
2070 DBG("Processing data-share failed\n");
2074 if (datashare->define) {
2075 LISTHEAD(datashare->define, tmp1);
2076 datashare->define = tmp1;
2078 if (datashare->request) {
2079 LISTHEAD(datashare->request, tmp2);
2080 datashare->request = tmp2;
2085 static int __ps_process_layout(xmlTextReaderPtr reader, layout_x *layout)
2087 /*TODO: once policy is set*/
2092 __get_icon_with_path(char* icon)
2097 if (index(icon, '/') == NULL) {
2099 char* icon_with_path = NULL;
2105 theme = vconf_get_str("db/setting/theme");
2107 theme = strdup("default");
2113 len = (0x01 << 7) + strlen(icon) + strlen(package) + strlen(theme);
2114 icon_with_path = malloc(len);
2115 if(icon_with_path == NULL) {
2116 DBG("(icon_with_path == NULL) return\n");
2121 memset(icon_with_path, 0, len);
2123 snprintf(icon_with_path, len, "/opt/share/icons/%s/small/%s", theme, icon);
2125 if (access(icon_with_path, R_OK) == 0) break;
2126 snprintf(icon_with_path, len, "/usr/share/icons/%s/small/%s", theme, icon);
2127 if (access(icon_with_path, R_OK) == 0) break;
2128 DBG("cannot find icon %s", icon_with_path);
2129 snprintf(icon_with_path, len,"/opt/share/icons/default/small/%s", icon);
2130 if (access(icon_with_path, R_OK) == 0) break;
2131 snprintf(icon_with_path, len, "/usr/share/icons/default/small/%s", icon);
2132 if (access(icon_with_path, R_OK) == 0) break;
2134 /* icon path is going to be moved intto the app directory */
2135 DBGE("icon file must be moved to %s", icon_with_path);
2136 snprintf(icon_with_path, len, "/opt/apps/%s/res/icons/%s/small/%s", package, theme, icon);
2137 if (access(icon_with_path, R_OK) == 0) break;
2138 snprintf(icon_with_path, len, "/usr/apps/%s/res/icons/%s/small/%s", package, theme, icon);
2139 if (access(icon_with_path, R_OK) == 0) break;
2140 DBG("cannot find icon %s", icon_with_path);
2141 snprintf(icon_with_path, len, "/opt/apps/%s/res/icons/default/small/%s", package, icon);
2142 if (access(icon_with_path, R_OK) == 0) break;
2143 snprintf(icon_with_path, len, "/usr/apps/%s/res/icons/default/small/%s", package, icon);
2144 if (access(icon_with_path, R_OK) == 0) break;
2149 DBG("Icon path : %s ---> %s", icon, icon_with_path);
2151 return icon_with_path;
2153 char* confirmed_icon = NULL;
2155 confirmed_icon = strdup(icon);
2156 if (!confirmed_icon)
2158 return confirmed_icon;
2163 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon)
2165 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2166 icon->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2167 if (xmlTextReaderConstXmlLang(reader)) {
2168 icon->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2169 if (icon->lang == NULL)
2170 icon->lang = strdup(DEFAULT_LOCALE);
2172 icon->lang = strdup(DEFAULT_LOCALE);
2174 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
2175 icon->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
2176 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
2177 icon->size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
2178 if (xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")))
2179 icon->resolution = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")));
2180 xmlTextReaderRead(reader);
2181 if (xmlTextReaderValue(reader)) {
2182 char *text = ASCII(xmlTextReaderValue(reader));
2184 icon->text = __get_icon_with_path(text);
2192 static int __ps_process_image(xmlTextReaderPtr reader, image_x *image)
2194 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2195 image->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2196 if (xmlTextReaderConstXmlLang(reader)) {
2197 image->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2198 if (image->lang == NULL)
2199 image->lang = strdup(DEFAULT_LOCALE);
2201 image->lang = strdup(DEFAULT_LOCALE);
2203 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
2204 image->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
2205 xmlTextReaderRead(reader);
2206 if (xmlTextReaderValue(reader))
2207 image->text = ASCII(xmlTextReaderValue(reader));
2212 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label)
2214 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2215 label->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2216 if (xmlTextReaderConstXmlLang(reader)) {
2217 label->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2218 if (label->lang == NULL)
2219 label->lang = strdup(DEFAULT_LOCALE);
2221 label->lang = strdup(DEFAULT_LOCALE);
2223 xmlTextReaderRead(reader);
2224 if (xmlTextReaderValue(reader))
2225 label->text = ASCII(xmlTextReaderValue(reader));
2227 /* DBG("lable name %s\n", label->name);
2228 DBG("lable lang %s\n", label->lang);
2229 DBG("lable text %s\n", label->text);
2235 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author)
2237 if (xmlTextReaderGetAttribute(reader, XMLCHAR("email")))
2238 author->email = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("email")));
2239 if (xmlTextReaderGetAttribute(reader, XMLCHAR("href")))
2240 author->href = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("href")));
2241 if (xmlTextReaderConstXmlLang(reader)) {
2242 author->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2243 if (author->lang == NULL)
2244 author->lang = strdup(DEFAULT_LOCALE);
2246 author->lang = strdup(DEFAULT_LOCALE);
2248 xmlTextReaderRead(reader);
2249 if (xmlTextReaderValue(reader))
2250 author->text = ASCII(xmlTextReaderValue(reader));
2254 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description)
2256 if (xmlTextReaderConstXmlLang(reader)) {
2257 description->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2258 if (description->lang == NULL)
2259 description->lang = strdup(DEFAULT_LOCALE);
2261 description->lang = strdup(DEFAULT_LOCALE);
2263 xmlTextReaderRead(reader);
2264 if (xmlTextReaderValue(reader))
2265 description->text = ASCII(xmlTextReaderValue(reader));
2269 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license)
2271 if (xmlTextReaderConstXmlLang(reader)) {
2272 license->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2273 if (license->lang == NULL)
2274 license->lang = strdup(DEFAULT_LOCALE);
2276 license->lang = strdup(DEFAULT_LOCALE);
2278 xmlTextReaderRead(reader);
2279 if (xmlTextReaderValue(reader))
2280 license->text = ASCII(xmlTextReaderValue(reader));
2284 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability)
2286 const xmlChar *node;
2289 resolution_x *tmp1 = NULL;
2291 if (xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")))
2292 capability->operationid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")));
2294 depth = xmlTextReaderDepth(reader);
2295 while ((ret = __next_child_element(reader, depth))) {
2296 node = xmlTextReaderConstName(reader);
2298 DBG("xmlTextReaderConstName value is NULL\n");
2302 if (!strcmp(ASCII(node), "resolution")) {
2303 resolution_x *resolution = malloc(sizeof(resolution_x));
2304 if (resolution == NULL) {
2305 DBG("Malloc Failed\n");
2308 memset(resolution, '\0', sizeof(resolution_x));
2309 LISTADD(capability->resolution, resolution);
2310 ret = __ps_process_resolution(reader, resolution);
2314 DBG("Processing capability failed\n");
2319 if (capability->resolution) {
2320 LISTHEAD(capability->resolution, tmp1);
2321 capability->resolution = tmp1;
2327 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol)
2329 const xmlChar *node;
2332 capability_x *tmp1 = NULL;
2334 if (xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")))
2335 datacontrol->providerid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")));
2337 depth = xmlTextReaderDepth(reader);
2338 while ((ret = __next_child_element(reader, depth))) {
2339 node = xmlTextReaderConstName(reader);
2341 DBG("xmlTextReaderConstName value is NULL\n");
2345 if (!strcmp(ASCII(node), "capability")) {
2346 capability_x *capability = malloc(sizeof(capability_x));
2347 if (capability == NULL) {
2348 DBG("Malloc Failed\n");
2351 memset(capability, '\0', sizeof(capability_x));
2352 LISTADD(datacontrol->capability, capability);
2353 ret = __ps_process_capability(reader, capability);
2357 DBG("Processing datacontrol failed\n");
2362 if (datacontrol->capability) {
2363 LISTHEAD(datacontrol->capability, tmp1);
2364 datacontrol->capability = tmp1;
2370 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication)
2372 const xmlChar *node;
2375 char *newappid = NULL;
2376 label_x *tmp1 = NULL;
2377 icon_x *tmp2 = NULL;
2378 appsvc_x *tmp3 = NULL;
2379 appcontrol_x *tmp4 = NULL;
2380 launchconditions_x *tmp5 = NULL;
2381 notification_x *tmp6 = NULL;
2382 datashare_x *tmp7 = NULL;
2383 category_x *tmp8 = NULL;
2384 metadata_x *tmp9 = NULL;
2385 image_x *tmp10 = NULL;
2386 permission_x *tmp11 = NULL;
2388 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
2389 uiapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
2390 if (uiapplication->appid == NULL) {
2391 DBG("appid cant be NULL\n");
2395 DBG("appid is mandatory\n");
2399 ret = __validate_appid(package, uiapplication->appid, &newappid);
2401 DBG("appid is not proper\n");
2405 if (uiapplication->appid)
2406 free((void *)uiapplication->appid);
2407 uiapplication->appid = newappid;
2410 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
2411 uiapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
2412 if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay"))) {
2413 uiapplication->nodisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay")));
2414 if (uiapplication->nodisplay == NULL)
2415 uiapplication->nodisplay = strdup("false");
2417 uiapplication->nodisplay = strdup("false");
2419 if (xmlTextReaderGetAttribute(reader, XMLCHAR("multiple"))) {
2420 uiapplication->multiple = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("multiple")));
2421 if (uiapplication->multiple == NULL)
2422 uiapplication->multiple = strdup("false");
2424 uiapplication->multiple = strdup("false");
2426 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
2427 uiapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
2428 if (xmlTextReaderGetAttribute(reader, XMLCHAR("categories")))
2429 uiapplication->categories = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("categories")));
2430 if (xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")))
2431 uiapplication->extraid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")));
2432 if (xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage"))) {
2433 uiapplication->taskmanage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage")));
2434 if (uiapplication->taskmanage == NULL)
2435 uiapplication->taskmanage = strdup("true");
2437 uiapplication->taskmanage = strdup("true");
2439 if (xmlTextReaderGetAttribute(reader, XMLCHAR("enabled"))) {
2440 uiapplication->enabled = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("enabled")));
2441 if (uiapplication->enabled == NULL)
2442 uiapplication->enabled = strdup("true");
2444 uiapplication->enabled = strdup("true");
2446 if (xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration"))) {
2447 uiapplication->hwacceleration = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration")));
2448 if (uiapplication->hwacceleration == NULL)
2449 uiapplication->hwacceleration = strdup("use-system-setting");
2451 uiapplication->hwacceleration = strdup("use-system-setting");
2453 if (xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")))
2454 uiapplication->recentimage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")));
2455 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp"))) {
2456 uiapplication->mainapp = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp")));
2457 if (uiapplication->mainapp == NULL)
2458 uiapplication->mainapp = strdup("false");
2460 uiapplication->mainapp = strdup("false");
2462 if (xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay"))) {
2463 uiapplication->indicatordisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay")));
2464 if (uiapplication->indicatordisplay == NULL)
2465 uiapplication->indicatordisplay = strdup("true");
2467 uiapplication->indicatordisplay = strdup("true");
2469 if (xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")))
2470 uiapplication->portraitimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")));
2472 uiapplication->portraitimg = NULL;
2473 if (xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")))
2474 uiapplication->landscapeimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")));
2476 uiapplication->landscapeimg = NULL;
2477 if (xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility"))) {
2478 uiapplication->guestmode_visibility = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility")));
2479 if (uiapplication->guestmode_visibility == NULL)
2480 uiapplication->guestmode_visibility = strdup("true");
2482 uiapplication->guestmode_visibility = strdup("true");
2485 depth = xmlTextReaderDepth(reader);
2486 while ((ret = __next_child_element(reader, depth))) {
2487 node = xmlTextReaderConstName(reader);
2489 DBG("xmlTextReaderConstName value is NULL\n");
2492 if (!strcmp(ASCII(node), "label")) {
2493 label_x *label = malloc(sizeof(label_x));
2494 if (label == NULL) {
2495 DBG("Malloc Failed\n");
2498 memset(label, '\0', sizeof(label_x));
2499 LISTADD(uiapplication->label, label);
2500 ret = __ps_process_label(reader, label);
2501 } else if (!strcmp(ASCII(node), "icon")) {
2502 icon_x *icon = malloc(sizeof(icon_x));
2504 DBG("Malloc Failed\n");
2507 memset(icon, '\0', sizeof(icon_x));
2508 LISTADD(uiapplication->icon, icon);
2509 ret = __ps_process_icon(reader, icon);
2510 } else if (!strcmp(ASCII(node), "image")) {
2511 image_x *image = malloc(sizeof(image_x));
2512 if (image == NULL) {
2513 DBG("Malloc Failed\n");
2516 memset(image, '\0', sizeof(image_x));
2517 LISTADD(uiapplication->image, image);
2518 ret = __ps_process_image(reader, image);
2519 } else if (!strcmp(ASCII(node), "category")) {
2520 category_x *category = malloc(sizeof(category_x));
2521 if (category == NULL) {
2522 DBG("Malloc Failed\n");
2525 memset(category, '\0', sizeof(category_x));
2526 LISTADD(uiapplication->category, category);
2527 ret = __ps_process_category(reader, category);
2528 } else if (!strcmp(ASCII(node), "metadata")) {
2529 metadata_x *metadata = malloc(sizeof(metadata_x));
2530 if (metadata == NULL) {
2531 DBG("Malloc Failed\n");
2534 memset(metadata, '\0', sizeof(metadata_x));
2535 LISTADD(uiapplication->metadata, metadata);
2536 ret = __ps_process_metadata(reader, metadata);
2537 } else if (!strcmp(ASCII(node), "permission")) {
2538 permission_x *permission = malloc(sizeof(permission_x));
2539 if (permission == NULL) {
2540 DBG("Malloc Failed\n");
2543 memset(permission, '\0', sizeof(permission_x));
2544 LISTADD(uiapplication->permission, permission);
2545 ret = __ps_process_permission(reader, permission);
2546 } else if (!strcmp(ASCII(node), "app-control")) {
2547 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
2548 if (appcontrol == NULL) {
2549 DBG("Malloc Failed\n");
2552 memset(appcontrol, '\0', sizeof(appcontrol_x));
2553 LISTADD(uiapplication->appcontrol, appcontrol);
2554 ret = __ps_process_appcontrol(reader, appcontrol);
2555 } else if (!strcmp(ASCII(node), "application-service")) {
2556 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
2557 if (appsvc == NULL) {
2558 DBG("Malloc Failed\n");
2561 memset(appsvc, '\0', sizeof(appsvc_x));
2562 LISTADD(uiapplication->appsvc, appsvc);
2563 ret = __ps_process_appsvc(reader, appsvc);
2564 } else if (!strcmp(ASCII(node), "data-share")) {
2565 datashare_x *datashare = malloc(sizeof(datashare_x));
2566 if (datashare == NULL) {
2567 DBG("Malloc Failed\n");
2570 memset(datashare, '\0', sizeof(datashare_x));
2571 LISTADD(uiapplication->datashare, datashare);
2572 ret = __ps_process_datashare(reader, datashare);
2573 } else if (!strcmp(ASCII(node), "launch-conditions")) {
2574 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
2575 if (launchconditions == NULL) {
2576 DBG("Malloc Failed\n");
2579 memset(launchconditions, '\0', sizeof(launchconditions_x));
2580 LISTADD(uiapplication->launchconditions, launchconditions);
2581 ret = __ps_process_launchconditions(reader, launchconditions);
2582 } else if (!strcmp(ASCII(node), "notification")) {
2583 notification_x *notification = malloc(sizeof(notification_x));
2584 if (notification == NULL) {
2585 DBG("Malloc Failed\n");
2588 memset(notification, '\0', sizeof(notification_x));
2589 LISTADD(uiapplication->notification, notification);
2590 ret = __ps_process_notification(reader, notification);
2594 DBG("Processing uiapplication failed\n");
2599 if (uiapplication->label) {
2600 LISTHEAD(uiapplication->label, tmp1);
2601 uiapplication->label = tmp1;
2603 if (uiapplication->icon) {
2604 LISTHEAD(uiapplication->icon, tmp2);
2605 uiapplication->icon = tmp2;
2607 if (uiapplication->appsvc) {
2608 LISTHEAD(uiapplication->appsvc, tmp3);
2609 uiapplication->appsvc = tmp3;
2611 if (uiapplication->appcontrol) {
2612 LISTHEAD(uiapplication->appcontrol, tmp4);
2613 uiapplication->appcontrol = tmp4;
2615 if (uiapplication->launchconditions) {
2616 LISTHEAD(uiapplication->launchconditions, tmp5);
2617 uiapplication->launchconditions = tmp5;
2619 if (uiapplication->notification) {
2620 LISTHEAD(uiapplication->notification, tmp6);
2621 uiapplication->notification = tmp6;
2623 if (uiapplication->datashare) {
2624 LISTHEAD(uiapplication->datashare, tmp7);
2625 uiapplication->datashare = tmp7;
2627 if (uiapplication->category) {
2628 LISTHEAD(uiapplication->category, tmp8);
2629 uiapplication->category = tmp8;
2631 if (uiapplication->metadata) {
2632 LISTHEAD(uiapplication->metadata, tmp9);
2633 uiapplication->metadata = tmp9;
2635 if (uiapplication->image) {
2636 LISTHEAD(uiapplication->image, tmp10);
2637 uiapplication->image = tmp10;
2639 if (uiapplication->permission) {
2640 LISTHEAD(uiapplication->permission, tmp11);
2641 uiapplication->permission = tmp11;
2647 static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication)
2649 const xmlChar *node;
2652 char *newappid = NULL;
2653 label_x *tmp1 = NULL;
2654 icon_x *tmp2 = NULL;
2655 appsvc_x *tmp3 = NULL;
2656 appcontrol_x *tmp4 = NULL;
2657 datacontrol_x *tmp5 = NULL;
2658 launchconditions_x *tmp6 = NULL;
2659 notification_x *tmp7 = NULL;
2660 datashare_x *tmp8 = NULL;
2661 category_x *tmp9 = NULL;
2662 metadata_x *tmp10 = NULL;
2663 permission_x *tmp11 = NULL;
2665 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
2666 serviceapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
2667 if (serviceapplication->appid == NULL) {
2668 DBG("appid cant be NULL\n");
2672 DBG("appid is mandatory\n");
2676 ret = __validate_appid(package, serviceapplication->appid, &newappid);
2678 DBG("appid is not proper\n");
2682 if (serviceapplication->appid)
2683 free((void *)serviceapplication->appid);
2684 serviceapplication->appid = newappid;
2687 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
2688 serviceapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
2689 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
2690 serviceapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
2691 if (xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot"))) {
2692 serviceapplication->onboot = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot")));
2693 if (serviceapplication->onboot == NULL)
2694 serviceapplication->onboot = strdup("false");
2696 serviceapplication->onboot = strdup("false");
2698 if (xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart"))) {
2699 serviceapplication->autorestart = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart")));
2700 if (serviceapplication->autorestart == NULL)
2701 serviceapplication->autorestart = strdup("false");
2703 serviceapplication->autorestart = strdup("false");
2706 depth = xmlTextReaderDepth(reader);
2707 while ((ret = __next_child_element(reader, depth))) {
2708 node = xmlTextReaderConstName(reader);
2710 DBG("xmlTextReaderConstName value is NULL\n");
2714 if (!strcmp(ASCII(node), "label")) {
2715 label_x *label = malloc(sizeof(label_x));
2716 if (label == NULL) {
2717 DBG("Malloc Failed\n");
2720 memset(label, '\0', sizeof(label_x));
2721 LISTADD(serviceapplication->label, label);
2722 ret = __ps_process_label(reader, label);
2723 } else if (!strcmp(ASCII(node), "icon")) {
2724 icon_x *icon = malloc(sizeof(icon_x));
2726 DBG("Malloc Failed\n");
2729 memset(icon, '\0', sizeof(icon_x));
2730 LISTADD(serviceapplication->icon, icon);
2731 ret = __ps_process_icon(reader, icon);
2732 } else if (!strcmp(ASCII(node), "category")) {
2733 category_x *category = malloc(sizeof(category_x));
2734 if (category == NULL) {
2735 DBG("Malloc Failed\n");
2738 memset(category, '\0', sizeof(category_x));
2739 LISTADD(serviceapplication->category, category);
2740 ret = __ps_process_category(reader, category);
2741 } else if (!strcmp(ASCII(node), "metadata")) {
2742 metadata_x *metadata = malloc(sizeof(metadata_x));
2743 if (metadata == NULL) {
2744 DBG("Malloc Failed\n");
2747 memset(metadata, '\0', sizeof(metadata_x));
2748 LISTADD(serviceapplication->metadata, metadata);
2749 ret = __ps_process_metadata(reader, metadata);
2750 } else if (!strcmp(ASCII(node), "permission")) {
2751 permission_x *permission = malloc(sizeof(permission_x));
2752 if (permission == NULL) {
2753 DBG("Malloc Failed\n");
2756 memset(permission, '\0', sizeof(permission_x));
2757 LISTADD(serviceapplication->permission, permission);
2758 ret = __ps_process_permission(reader, permission);
2759 } else if (!strcmp(ASCII(node), "app-control")) {
2760 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
2761 if (appcontrol == NULL) {
2762 DBG("Malloc Failed\n");
2765 memset(appcontrol, '\0', sizeof(appcontrol_x));
2766 LISTADD(serviceapplication->appcontrol, appcontrol);
2767 ret = __ps_process_appcontrol(reader, appcontrol);
2768 } else if (!strcmp(ASCII(node), "application-service")) {
2769 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
2770 if (appsvc == NULL) {
2771 DBG("Malloc Failed\n");
2774 memset(appsvc, '\0', sizeof(appsvc_x));
2775 LISTADD(serviceapplication->appsvc, appsvc);
2776 ret = __ps_process_appsvc(reader, appsvc);
2777 } else if (!strcmp(ASCII(node), "data-share")) {
2778 datashare_x *datashare = malloc(sizeof(datashare_x));
2779 if (datashare == NULL) {
2780 DBG("Malloc Failed\n");
2783 memset(datashare, '\0', sizeof(datashare_x));
2784 LISTADD(serviceapplication->datashare, datashare);
2785 ret = __ps_process_datashare(reader, datashare);
2786 } else if (!strcmp(ASCII(node), "launch-conditions")) {
2787 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
2788 if (launchconditions == NULL) {
2789 DBG("Malloc Failed\n");
2792 memset(launchconditions, '\0', sizeof(launchconditions_x));
2793 LISTADD(serviceapplication->launchconditions, launchconditions);
2794 ret = __ps_process_launchconditions(reader, launchconditions);
2795 } else if (!strcmp(ASCII(node), "notification")) {
2796 notification_x *notification = malloc(sizeof(notification_x));
2797 if (notification == NULL) {
2798 DBG("Malloc Failed\n");
2801 memset(notification, '\0', sizeof(notification_x));
2802 LISTADD(serviceapplication->notification, notification);
2803 ret = __ps_process_notification(reader, notification);
2804 } else if (!strcmp(ASCII(node), "data-control")) {
2805 datacontrol_x *datacontrol = malloc(sizeof(datacontrol_x));
2806 if (datacontrol == NULL) {
2807 DBG("Malloc Failed\n");
2810 memset(datacontrol, '\0', sizeof(datacontrol_x));
2811 LISTADD(serviceapplication->datacontrol, datacontrol);
2812 ret = __ps_process_datacontrol(reader, datacontrol);
2816 DBG("Processing serviceapplication failed\n");
2821 if (serviceapplication->label) {
2822 LISTHEAD(serviceapplication->label, tmp1);
2823 serviceapplication->label = tmp1;
2825 if (serviceapplication->icon) {
2826 LISTHEAD(serviceapplication->icon, tmp2);
2827 serviceapplication->icon = tmp2;
2829 if (serviceapplication->appsvc) {
2830 LISTHEAD(serviceapplication->appsvc, tmp3);
2831 serviceapplication->appsvc = tmp3;
2833 if (serviceapplication->appcontrol) {
2834 LISTHEAD(serviceapplication->appcontrol, tmp4);
2835 serviceapplication->appcontrol = tmp4;
2837 if (serviceapplication->datacontrol) {
2838 LISTHEAD(serviceapplication->datacontrol, tmp5);
2839 serviceapplication->datacontrol = tmp5;
2841 if (serviceapplication->launchconditions) {
2842 LISTHEAD(serviceapplication->launchconditions, tmp6);
2843 serviceapplication->launchconditions = tmp6;
2845 if (serviceapplication->notification) {
2846 LISTHEAD(serviceapplication->notification, tmp7);
2847 serviceapplication->notification = tmp7;
2849 if (serviceapplication->datashare) {
2850 LISTHEAD(serviceapplication->datashare, tmp8);
2851 serviceapplication->datashare = tmp8;
2853 if (serviceapplication->category) {
2854 LISTHEAD(serviceapplication->category, tmp9);
2855 serviceapplication->category = tmp9;
2857 if (serviceapplication->metadata) {
2858 LISTHEAD(serviceapplication->metadata, tmp10);
2859 serviceapplication->metadata = tmp10;
2861 if (serviceapplication->permission) {
2862 LISTHEAD(serviceapplication->permission, tmp11);
2863 serviceapplication->permission = tmp11;
2869 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile)
2871 /*TODO: once policy is set*/
2875 static int __ps_process_font(xmlTextReaderPtr reader, font_x *font)
2877 /*TODO: once policy is set*/
2881 static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme)
2883 /*TODO: once policy is set*/
2887 static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon)
2889 /*TODO: once policy is set*/
2893 static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime)
2895 /*TODO: once policy is set*/
2899 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx)
2901 DBG("__start_process\n");
2902 const xmlChar *node;
2905 label_x *tmp1 = NULL;
2906 author_x *tmp2 = NULL;
2907 description_x *tmp3 = NULL;
2908 license_x *tmp4 = NULL;
2909 uiapplication_x *tmp5 = NULL;
2910 serviceapplication_x *tmp6 = NULL;
2911 daemon_x *tmp7 = NULL;
2912 theme_x *tmp8 = NULL;
2913 font_x *tmp9 = NULL;
2914 ime_x *tmp10 = NULL;
2915 icon_x *tmp11 = NULL;
2916 compatibility_x *tmp12 = NULL;
2917 deviceprofile_x *tmp13 = NULL;
2919 depth = xmlTextReaderDepth(reader);
2920 while ((ret = __next_child_element(reader, depth))) {
2921 node = xmlTextReaderConstName(reader);
2923 DBG("xmlTextReaderConstName value is NULL\n");
2927 if (!strcmp(ASCII(node), "label")) {
2928 label_x *label = malloc(sizeof(label_x));
2929 if (label == NULL) {
2930 DBG("Malloc Failed\n");
2933 memset(label, '\0', sizeof(label_x));
2934 LISTADD(mfx->label, label);
2935 ret = __ps_process_label(reader, label);
2936 } else if (!strcmp(ASCII(node), "author")) {
2937 author_x *author = malloc(sizeof(author_x));
2938 if (author == NULL) {
2939 DBG("Malloc Failed\n");
2942 memset(author, '\0', sizeof(author_x));
2943 LISTADD(mfx->author, author);
2944 ret = __ps_process_author(reader, author);
2945 } else if (!strcmp(ASCII(node), "description")) {
2946 description_x *description = malloc(sizeof(description_x));
2947 if (description == NULL) {
2948 DBG("Malloc Failed\n");
2951 memset(description, '\0', sizeof(description_x));
2952 LISTADD(mfx->description, description);
2953 ret = __ps_process_description(reader, description);
2954 } else if (!strcmp(ASCII(node), "license")) {
2955 license_x *license = malloc(sizeof(license_x));
2956 if (license == NULL) {
2957 DBG("Malloc Failed\n");
2960 memset(license, '\0', sizeof(license_x));
2961 LISTADD(mfx->license, license);
2962 ret = __ps_process_license(reader, license);
2963 } else if (!strcmp(ASCII(node), "ui-application")) {
2964 uiapplication_x *uiapplication = malloc(sizeof(uiapplication_x));
2965 if (uiapplication == NULL) {
2966 DBG("Malloc Failed\n");
2969 memset(uiapplication, '\0', sizeof(uiapplication_x));
2970 LISTADD(mfx->uiapplication, uiapplication);
2971 ret = __ps_process_uiapplication(reader, uiapplication);
2972 } else if (!strcmp(ASCII(node), "service-application")) {
2973 serviceapplication_x *serviceapplication = malloc(sizeof(serviceapplication_x));
2974 if (serviceapplication == NULL) {
2975 DBG("Malloc Failed\n");
2978 memset(serviceapplication, '\0', sizeof(serviceapplication_x));
2979 LISTADD(mfx->serviceapplication, serviceapplication);
2980 ret = __ps_process_serviceapplication(reader, serviceapplication);
2981 } else if (!strcmp(ASCII(node), "daemon")) {
2982 daemon_x *daemon = malloc(sizeof(daemon_x));
2983 if (daemon == NULL) {
2984 DBG("Malloc Failed\n");
2987 memset(daemon, '\0', sizeof(daemon_x));
2988 LISTADD(mfx->daemon, daemon);
2989 ret = __ps_process_daemon(reader, daemon);
2990 } else if (!strcmp(ASCII(node), "theme")) {
2991 theme_x *theme = malloc(sizeof(theme_x));
2992 if (theme == NULL) {
2993 DBG("Malloc Failed\n");
2996 memset(theme, '\0', sizeof(theme_x));
2997 LISTADD(mfx->theme, theme);
2998 ret = __ps_process_theme(reader, theme);
2999 } else if (!strcmp(ASCII(node), "font")) {
3000 font_x *font = malloc(sizeof(font_x));
3002 DBG("Malloc Failed\n");
3005 memset(font, '\0', sizeof(font_x));
3006 LISTADD(mfx->font, font);
3007 ret = __ps_process_font(reader, font);
3008 } else if (!strcmp(ASCII(node), "ime")) {
3009 ime_x *ime = malloc(sizeof(ime_x));
3011 DBG("Malloc Failed\n");
3014 memset(ime, '\0', sizeof(ime_x));
3015 LISTADD(mfx->ime, ime);
3016 ret = __ps_process_ime(reader, ime);
3017 } else if (!strcmp(ASCII(node), "icon")) {
3018 icon_x *icon = malloc(sizeof(icon_x));
3020 DBG("Malloc Failed\n");
3023 memset(icon, '\0', sizeof(icon_x));
3024 LISTADD(mfx->icon, icon);
3025 ret = __ps_process_icon(reader, icon);
3026 } else if (!strcmp(ASCII(node), "device-profile")) {
3027 deviceprofile_x *deviceprofile = malloc(sizeof(deviceprofile_x));
3028 if (deviceprofile == NULL) {
3029 DBG("Malloc Failed\n");
3032 memset(deviceprofile, '\0', sizeof(deviceprofile_x));
3033 LISTADD(mfx->deviceprofile, deviceprofile);
3034 ret = __ps_process_deviceprofile(reader, deviceprofile);
3035 } else if (!strcmp(ASCII(node), "compatibility")) {
3036 compatibility_x *compatibility = malloc(sizeof(compatibility_x));
3037 if (compatibility == NULL) {
3038 DBG("Malloc Failed\n");
3041 memset(compatibility, '\0', sizeof(compatibility_x));
3042 LISTADD(mfx->compatibility, compatibility);
3043 ret = __ps_process_compatibility(reader, compatibility);
3044 } else if (!strcmp(ASCII(node), "shortcut-list")) {
3046 } else if (!strcmp(ASCII(node), "livebox")) {
3048 } else if (!strcmp(ASCII(node), "account")) {
3050 } else if (!strcmp(ASCII(node), "notifications")) {
3056 DBG("Processing manifest failed\n");
3061 LISTHEAD(mfx->label, tmp1);
3065 LISTHEAD(mfx->author, tmp2);
3068 if (mfx->description) {
3069 LISTHEAD(mfx->description, tmp3);
3070 mfx->description= tmp3;
3073 LISTHEAD(mfx->license, tmp4);
3076 if (mfx->uiapplication) {
3077 LISTHEAD(mfx->uiapplication, tmp5);
3078 mfx->uiapplication = tmp5;
3080 if (mfx->serviceapplication) {
3081 LISTHEAD(mfx->serviceapplication, tmp6);
3082 mfx->serviceapplication = tmp6;
3085 LISTHEAD(mfx->daemon, tmp7);
3089 LISTHEAD(mfx->theme, tmp8);
3093 LISTHEAD(mfx->font, tmp9);
3097 LISTHEAD(mfx->ime, tmp10);
3101 LISTHEAD(mfx->icon, tmp11);
3104 if (mfx->compatibility) {
3105 LISTHEAD(mfx->compatibility, tmp12);
3106 mfx->compatibility= tmp12;
3108 if (mfx->deviceprofile) {
3109 LISTHEAD(mfx->deviceprofile, tmp13);
3110 mfx->deviceprofile= tmp13;
3116 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx)
3118 const xmlChar *node;
3121 if ((ret = __next_child_element(reader, -1))) {
3122 node = xmlTextReaderConstName(reader);
3124 DBG("xmlTextReaderConstName value is NULL\n");
3128 if (!strcmp(ASCII(node), "manifest")) {
3129 if (xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")))
3130 mfx->ns = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")));
3131 if (xmlTextReaderGetAttribute(reader, XMLCHAR("package"))) {
3132 mfx->package= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("package")));
3133 if (mfx->package == NULL) {
3134 DBG("package cant be NULL\n");
3138 DBG("package field is mandatory\n");
3141 package = mfx->package;
3142 if (xmlTextReaderGetAttribute(reader, XMLCHAR("version")))
3143 mfx->version= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("version")));
3144 /*app2ext needs package size for external installation*/
3145 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
3146 mfx->package_size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
3147 if (xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")))
3148 mfx->installlocation = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")));
3149 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
3150 mfx->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
3151 if (xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")))
3152 mfx->root_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")));
3153 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting"))) {
3154 mfx->appsetting = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting")));
3155 if (mfx->appsetting == NULL)
3156 mfx->appsetting = strdup("false");
3158 mfx->appsetting = strdup("false");
3161 /*Assign default values. If required it will be overwritten in __add_preload_info()*/
3162 mfx->preload = strdup("False");
3163 mfx->removable = strdup("True");
3164 mfx->readonly = strdup("False");
3165 char buf[PKG_STRING_LEN_MAX] = {'\0'};
3167 time_t current_time;
3168 time(¤t_time);
3169 snprintf(buf, PKG_STRING_LEN_MAX - 1, "%d", current_time);
3170 val = strndup(buf, PKG_STRING_LEN_MAX - 1);
3171 mfx->installed_time = val;
3173 mfx->installed_storage= strdup("installed_internal");
3175 ret = __start_process(reader, mfx);
3177 DBG("No Manifest element found\n");
3184 #define DESKTOP_RW_PATH "/opt/share/applications/"
3185 #define DESKTOP_RO_PATH "/usr/share/applications/"
3187 static char* __convert_to_system_locale(const char *mlocale)
3189 if (mlocale == NULL)
3191 char *locale = NULL;
3192 locale = (char *)calloc(1, 6);
3194 DBGE("Malloc Failed\n");
3198 strncpy(locale, mlocale, 2);
3199 strncat(locale, "_", 1);
3200 locale[3] = toupper(mlocale[3]);
3201 locale[4] = toupper(mlocale[4]);
3205 #define LIBAIL_PATH "/usr/lib/libail.so.0"
3207 /* operation_type */
3215 static int __ail_change_info(int op, const char *appid)
3217 void *lib_handle = NULL;
3218 int (*ail_desktop_operation) (const char *);
3222 if ((lib_handle = dlopen(LIBAIL_PATH, RTLD_LAZY)) == NULL) {
3223 DBGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAIL_PATH);
3230 aop = "ail_desktop_add";
3233 aop = "ail_desktop_update";
3236 aop = "ail_desktop_remove";
3243 if ((ail_desktop_operation =
3244 dlsym(lib_handle, aop)) == NULL || dlerror() != NULL) {
3245 DBGE("can not find symbol \n");
3249 ret = ail_desktop_operation(appid);
3253 dlclose(lib_handle);
3259 /* desktop shoud be generated automatically based on manifest */
3260 /* Currently removable, taskmanage, etc fields are not considerd. it will be decided soon.*/
3261 #define BUFMAX 1024*128
3262 static int __ps_make_nativeapp_desktop(manifest_x * mfx, bool is_update)
3266 char filepath[PKG_STRING_LEN_MAX] = "";
3268 char *buftemp = NULL;
3269 char *locale = NULL;
3271 buf = (char *)calloc(1, BUFMAX);
3273 DBGE("Malloc Failed\n");
3277 buftemp = (char *)calloc(1, BUFMAX);
3279 DBGE("Malloc Failed\n");
3284 for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) {
3286 if(mfx->readonly && !strcasecmp(mfx->readonly, "True"))
3287 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RO_PATH, mfx->uiapplication->appid);
3289 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, mfx->uiapplication->appid);
3291 /* skip if desktop exists
3292 if (access(filepath, R_OK) == 0)
3296 file = fopen(filepath, "w");
3299 DBGE("Can't open %s", filepath);
3305 snprintf(buf, BUFMAX, "[Desktop Entry]\n");
3306 fwrite(buf, 1, strlen(buf), file);
3308 for( ; mfx->uiapplication->label ; mfx->uiapplication->label = mfx->uiapplication->label->next) {
3309 if(!strcmp(mfx->uiapplication->label->lang, DEFAULT_LOCALE)) {
3310 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
3312 locale = __convert_to_system_locale(mfx->uiapplication->label->lang);
3313 snprintf(buf, BUFMAX, "Name[%s]=%s\n", locale,
3314 mfx->uiapplication->label->text);
3317 fwrite(buf, 1, strlen(buf), file);
3320 if(mfx->uiapplication->label && mfx->uiapplication->label->text) {
3321 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
3322 fwrite(buf, 1, strlen(buf), file);
3325 else if(mfx->label && mfx->label->text) {
3326 snprintf(buf, BUFMAX, "Name=%s\n", mfx->label->text);
3327 fwrite(buf, 1, strlen(buf), file);
3329 snprintf(buf, BUFMAX, "Name=%s\n", mfx->package);
3330 fwrite(buf, 1, strlen(buf), file);
3335 snprintf(buf, BUFMAX, "Type=Application\n");
3336 fwrite(buf, 1, strlen(buf), file);
3338 if(mfx->uiapplication->exec) {
3339 snprintf(buf, BUFMAX, "Exec=%s\n", mfx->uiapplication->exec);
3340 fwrite(buf, 1, strlen(buf), file);
3343 if(mfx->uiapplication->icon && mfx->uiapplication->icon->text) {
3344 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->uiapplication->icon->text);
3345 fwrite(buf, 1, strlen(buf), file);
3346 } else if(mfx->icon && mfx->icon->text) {
3347 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->icon->text);
3348 fwrite(buf, 1, strlen(buf), file);
3352 snprintf(buf, BUFMAX, "Version=%s\n", mfx->version);
3353 fwrite(buf, 1, strlen(buf), file);
3356 if(mfx->uiapplication->nodisplay) {
3357 snprintf(buf, BUFMAX, "NoDisplay=%s\n", mfx->uiapplication->nodisplay);
3358 fwrite(buf, 1, strlen(buf), file);
3361 if(mfx->uiapplication->categories) {
3362 snprintf(buf, BUFMAX, "Categories=%s\n", mfx->uiapplication->categories);
3363 fwrite(buf, 1, strlen(buf), file);
3366 if(mfx->uiapplication->taskmanage && !strcasecmp(mfx->uiapplication->taskmanage, "False")) {
3367 snprintf(buf, BUFMAX, "X-TIZEN-TaskManage=False\n");
3368 fwrite(buf, 1, strlen(buf), file);
3371 if(mfx->uiapplication->enabled && !strcasecmp(mfx->uiapplication->enabled, "False")) {
3372 snprintf(buf, BUFMAX, "X-TIZEN-Enabled=False\n");
3373 fwrite(buf, 1, strlen(buf), file);
3376 if(mfx->uiapplication->hwacceleration) {
3377 snprintf(buf, BUFMAX, "Hw-Acceleration=%s\n", mfx->uiapplication->hwacceleration);
3378 fwrite(buf, 1, strlen(buf), file);
3381 if(mfx->uiapplication->multiple && !strcasecmp(mfx->uiapplication->multiple, "True")) {
3382 snprintf(buf, BUFMAX, "X-TIZEN-Multiple=True\n");
3383 fwrite(buf, 1, strlen(buf), file);
3386 if(mfx->uiapplication->extraid) {
3387 snprintf(buf, BUFMAX, "X-TIZEN-PackageID=%s\n", mfx->uiapplication->extraid);
3388 fwrite(buf, 1, strlen(buf), file);
3391 if(mfx->removable && !strcasecmp(mfx->removable, "False")) {
3392 snprintf(buf, BUFMAX, "X-TIZEN-Removable=False\n");
3393 fwrite(buf, 1, strlen(buf), file);
3397 snprintf(buf, BUFMAX, "X-TIZEN-PackageType=%s\n", mfx->type);
3398 fwrite(buf, 1, strlen(buf), file);
3401 snprintf(buf, BUFMAX, "X-TIZEN-PkgID=%s\n", mfx->package);
3402 fwrite(buf, 1, strlen(buf), file);
3405 // snprintf(buf, BUFMAX, "X-TIZEN-PackageType=rpm\n");
3406 // fwrite(buf, 1, strlen(buf), file);
3409 if(mfx->uiapplication->appsvc) {
3410 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
3411 DBG("buf[%s]\n", buf);
3414 uiapplication_x *up = mfx->uiapplication;
3415 appsvc_x *asvc = NULL;
3416 operation_x *op = NULL;
3419 subapp_x *sub = NULL;
3420 char *operation = NULL;
3423 char *subapp = NULL;
3430 op = asvc->operation;
3434 operation = op->name;
3453 strncpy(buftemp, buf, BUFMAX);
3454 snprintf(buf, BUFMAX, "%s;", buftemp);
3458 strncpy(buftemp, buf, BUFMAX);
3459 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
3460 DBG("buf[%s]\n", buf);
3465 } while(ui != NULL);
3469 }while(sub != NULL);
3482 fwrite(buf, 1, strlen(buf), file);
3484 // strncpy(buftemp, buf, BUFMAX);
3485 // snprintf(buf, BUFMAX, "%s\n", buftemp);
3486 // fwrite(buf, 1, strlen(buf), file);
3489 if(mfx->uiapplication->appcontrol) {
3490 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
3491 DBG("buf[%s]\n", buf);
3493 uiapplication_x *up = mfx->uiapplication;
3494 appcontrol_x *acontrol = NULL;
3495 operation_x *op = NULL;
3498 subapp_x *sub = NULL;
3499 char *operation = NULL;
3502 char *subapp = NULL;
3505 acontrol = up->appcontrol;
3506 while(acontrol != NULL)
3508 op = acontrol->operation;
3512 operation = op->name;
3513 mi = acontrol->mime;
3519 sub = acontrol->subapp;
3531 strncpy(buftemp, buf, BUFMAX);
3532 snprintf(buf, BUFMAX, "%s;", buftemp);
3535 strncpy(buftemp, buf, BUFMAX);
3536 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
3537 DBG("buf[%s]\n", buf);
3542 } while(ui != NULL);
3546 }while(sub != NULL);
3555 acontrol = acontrol->next;
3559 fwrite(buf, 1, strlen(buf), file);
3561 // strncpy(buftemp, buf, BUFMAX);
3562 // snprintf(buf, BUFMAX, "%s\n", buftemp);
3563 // fwrite(buf, 1, strlen(buf), file);
3572 __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid);
3574 __ail_change_info(AIL_UPDATE, mfx->uiapplication->appid);
3583 static int __ps_remove_nativeapp_desktop(manifest_x *mfx)
3585 char filepath[PKG_STRING_LEN_MAX] = "";
3588 for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) {
3589 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, mfx->uiapplication->appid);
3591 __ail_change_info(AIL_REMOVE, mfx->uiapplication->appid);
3593 ret = remove(filepath);
3601 #define MANIFEST_RO_PREFIX "/usr/share/packages/"
3602 #define PRELOAD_PACKAGE_LIST "/usr/etc/package-manager/preload/preload_list.txt"
3603 static int __add_preload_info(manifest_x * mfx, const char *manifest)
3606 char buffer[1024] = { 0 };
3609 if(strstr(manifest, MANIFEST_RO_PREFIX)) {
3610 free(mfx->readonly);
3611 mfx->readonly = strdup("True");
3614 mfx->preload = strdup("True");
3616 free(mfx->removable);
3617 mfx->removable = strdup("False");
3622 fp = fopen(PRELOAD_PACKAGE_LIST, "r");
3624 DBGE("no preload list\n");
3628 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
3629 if (buffer[0] == '#') {
3630 if(strcasestr(buffer, "RW_NORM"))
3632 else if(strcasestr(buffer, "RW_RM"))
3640 if(!strcmp(mfx->package, buffer)) {
3642 mfx->preload = strdup("True");
3644 free(mfx->readonly);
3645 mfx->readonly = strdup("False");
3646 free(mfx->removable);
3647 mfx->removable = strdup("False");
3648 } else if(state == 3){
3649 free(mfx->readonly);
3650 mfx->readonly = strdup("False");
3651 free(mfx->removable);
3652 mfx->removable = strdup("True");
3656 memset(buffer, 0x00, sizeof(buffer));
3666 API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
3671 free((void *)mfx->ns);
3675 free((void *)mfx->package);
3676 mfx->package = NULL;
3679 free((void *)mfx->version);
3680 mfx->version = NULL;
3682 if (mfx->installlocation) {
3683 free((void *)mfx->installlocation);
3684 mfx->installlocation = NULL;
3687 free((void *)mfx->preload);
3688 mfx->preload = NULL;
3690 if (mfx->readonly) {
3691 free((void *)mfx->readonly);
3692 mfx->readonly = NULL;
3694 if (mfx->removable) {
3695 free((void *)mfx->removable);
3696 mfx->removable = NULL;
3699 free((void *)mfx->update);
3703 free((void *)mfx->type);
3706 if (mfx->package_size) {
3707 free((void *)mfx->package_size);
3708 mfx->package_size = NULL;
3710 if (mfx->installed_time) {
3711 free((void *)mfx->installed_time);
3712 mfx->installed_time = NULL;
3714 if (mfx->installed_storage) {
3715 free((void *)mfx->installed_storage);
3716 mfx->installed_storage = NULL;
3718 if (mfx->storeclient_id) {
3719 free((void *)mfx->storeclient_id);
3720 mfx->storeclient_id = NULL;
3722 if (mfx->mainapp_id) {
3723 free((void *)mfx->mainapp_id);
3724 mfx->mainapp_id = NULL;
3726 if (mfx->package_url) {
3727 free((void *)mfx->package_url);
3728 mfx->package_url = NULL;
3730 if (mfx->root_path) {
3731 free((void *)mfx->root_path);
3732 mfx->root_path = NULL;
3734 if (mfx->appsetting) {
3735 free((void *)mfx->appsetting);
3736 mfx->appsetting = NULL;
3741 icon_x *icon = mfx->icon;
3746 __ps_free_icon(icon);
3752 label_x *label = mfx->label;
3753 label_x *tmp = NULL;
3754 while(label != NULL)
3757 __ps_free_label(label);
3763 author_x *author = mfx->author;
3764 author_x *tmp = NULL;
3765 while(author != NULL)
3768 __ps_free_author(author);
3772 /*Free Description*/
3773 if (mfx->description) {
3774 description_x *description = mfx->description;
3775 description_x *tmp = NULL;
3776 while(description != NULL)
3778 tmp = description->next;
3779 __ps_free_description(description);
3785 license_x *license = mfx->license;
3786 license_x *tmp = NULL;
3787 while(license != NULL)
3789 tmp = license->next;
3790 __ps_free_license(license);
3794 /*Free UiApplication*/
3795 if (mfx->uiapplication) {
3796 uiapplication_x *uiapplication = mfx->uiapplication;
3797 uiapplication_x *tmp = NULL;
3798 while(uiapplication != NULL)
3800 tmp = uiapplication->next;
3801 __ps_free_uiapplication(uiapplication);
3802 uiapplication = tmp;
3805 /*Free ServiceApplication*/
3806 if (mfx->serviceapplication) {
3807 serviceapplication_x *serviceapplication = mfx->serviceapplication;
3808 serviceapplication_x *tmp = NULL;
3809 while(serviceapplication != NULL)
3811 tmp = serviceapplication->next;
3812 __ps_free_serviceapplication(serviceapplication);
3813 serviceapplication = tmp;
3818 daemon_x *daemon = mfx->daemon;
3819 daemon_x *tmp = NULL;
3820 while(daemon != NULL)
3823 __ps_free_daemon(daemon);
3829 theme_x *theme = mfx->theme;
3830 theme_x *tmp = NULL;
3831 while(theme != NULL)
3834 __ps_free_theme(theme);
3840 font_x *font = mfx->font;
3845 __ps_free_font(font);
3851 ime_x *ime = mfx->ime;
3860 /*Free Compatibility*/
3861 if (mfx->compatibility) {
3862 compatibility_x *compatibility = mfx->compatibility;
3863 compatibility_x *tmp = NULL;
3864 while(compatibility != NULL)
3866 tmp = compatibility->next;
3867 __ps_free_compatibility(compatibility);
3868 compatibility = tmp;
3871 /*Free DeviceProfile*/
3872 if (mfx->deviceprofile) {
3873 deviceprofile_x *deviceprofile = mfx->deviceprofile;
3874 deviceprofile_x *tmp = NULL;
3875 while(deviceprofile != NULL)
3877 tmp = deviceprofile->next;
3878 __ps_free_deviceprofile(deviceprofile);
3879 deviceprofile = tmp;
3887 API manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest)
3889 DBG("parsing start\n");
3890 xmlTextReaderPtr reader;
3891 manifest_x *mfx = NULL;
3893 reader = xmlReaderForFile(manifest, NULL, 0);
3895 mfx = malloc(sizeof(manifest_x));
3897 memset(mfx, '\0', sizeof(manifest_x));
3898 if (__process_manifest(reader, mfx) < 0) {
3899 DBG("Parsing Failed\n");
3900 pkgmgr_parser_free_manifest_xml(mfx);
3903 DBG("Parsing Success\n");
3905 DBG("Memory allocation error\n");
3907 xmlFreeTextReader(reader);
3909 DBG("Unable to create xml reader\n");
3914 /* These APIs are intended to call parser directly */
3916 API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
3918 char *temp[] = {"shortcut-list", "livebox", "account", "notifications", NULL};
3919 if (manifest == NULL) {
3920 DBG("argument supplied is NULL\n");
3921 return PMINFO_R_EINVAL;
3923 DBG("parsing manifest for installation: %s\n", manifest);
3924 manifest_x *mfx = NULL;
3926 char roxml_check[PKG_STRING_LEN_MAX] = {'\0'};
3929 mfx = pkgmgr_parser_process_manifest_xml(manifest);
3930 DBG("Parsing Finished\n");
3932 return PMINFO_R_ERROR;
3934 __streamFile(manifest, ACTION_INSTALL, temp, mfx->package);
3935 __add_preload_info(mfx, manifest);
3936 DBG("Added preload infomation\n");
3938 snprintf(roxml_check, PKG_STRING_LEN_MAX, MANIFEST_RO_DIRECTORY "/%s.xml", mfx->package);
3939 if (access(roxml_check, F_OK) == 0)
3940 mfx->update = strdup("true");
3942 mfx->update = strdup("false");
3944 ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
3946 DBG("DB Insert failed\n");
3948 DBG("DB Insert Success\n");
3950 ret = __ps_make_nativeapp_desktop(mfx, 0);
3952 DBG("Creating desktop file failed\n");
3954 DBG("Creating desktop file Success\n");
3956 pkgmgr_parser_free_manifest_xml(mfx);
3963 API int pkgmgr_parser_create_desktop_file(manifest_x *mfx)
3967 DBG("Manifest pointer is NULL\n");
3970 ret = __ps_make_nativeapp_desktop(mfx, 0);
3972 DBG("Creating desktop file failed\n");
3974 DBG("Creating desktop file Success\n");
3979 API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
3981 char *temp[] = {"shortcut-list", "livebox", "account", "notifications", NULL};
3982 if (manifest == NULL) {
3983 DBG("argument supplied is NULL\n");
3984 return PMINFO_R_EINVAL;
3986 DBG("parsing manifest for upgradation: %s\n", manifest);
3987 manifest_x *mfx = NULL;
3990 mfx = pkgmgr_parser_process_manifest_xml(manifest);
3991 DBG("Parsing Finished\n");
3993 return PMINFO_R_ERROR;
3995 __streamFile(manifest, ACTION_UPGRADE, temp, mfx->package);
3996 __add_preload_info(mfx, manifest);
3997 DBG("Added preload infomation\n");
3999 mfx->update = strdup("true");
4000 ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
4002 DBG("DB Update failed\n");
4004 DBG("DB Update Success\n");
4006 ret = __ps_make_nativeapp_desktop(mfx, 1);
4008 DBG("Creating desktop file failed\n");
4010 DBG("Creating desktop file Success\n");
4012 pkgmgr_parser_free_manifest_xml(mfx);
4019 API int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[])
4021 char *temp[] = {"shortcut-list", "livebox", "account", "notifications", NULL};
4022 if (manifest == NULL) {
4023 DBG("argument supplied is NULL\n");
4024 return PMINFO_R_EINVAL;
4026 DBG("parsing manifest for uninstallation: %s\n", manifest);
4027 manifest_x *mfx = NULL;
4030 mfx = pkgmgr_parser_process_manifest_xml(manifest);
4031 DBG("Parsing Finished\n");
4033 return PMINFO_R_ERROR;
4035 __streamFile(manifest, ACTION_UNINSTALL, temp, mfx->package);
4036 __add_preload_info(mfx, manifest);
4037 DBG("Added preload infomation\n");
4039 ret = pkgmgr_parser_delete_manifest_info_from_db(mfx);
4041 DBG("DB Delete failed\n");
4043 DBG("DB Delete Success\n");
4045 ret = __ps_remove_nativeapp_desktop(mfx);
4047 DBG("Removing desktop file failed\n");
4049 DBG("Removing desktop file Success\n");
4051 pkgmgr_parser_free_manifest_xml(mfx);
4058 API char *pkgmgr_parser_get_manifest_file(const char *pkgid)
4060 return __pkgid_to_manifest(pkgid);
4063 API int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
4065 return __ps_run_parser(docPtr, tag, ACTION_INSTALL, pkgid);
4068 API int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgid)
4070 return __ps_run_parser(docPtr, tag, ACTION_UPGRADE, pkgid);
4073 API int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
4075 return __ps_run_parser(docPtr, tag, ACTION_UNINSTALL, pkgid);
4078 #define SCHEMA_FILE "/usr/etc/package-manager/preload/manifest.xsd"
4080 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
4082 if (manifest == NULL) {
4083 DBGE("manifest file is NULL\n");
4084 return PMINFO_R_EINVAL;
4087 xmlSchemaParserCtxtPtr ctx;
4088 xmlSchemaValidCtxtPtr vctx;
4089 xmlSchemaPtr xschema;
4090 ctx = xmlSchemaNewParserCtxt(SCHEMA_FILE);
4092 DBGE("xmlSchemaNewParserCtxt() Failed\n");
4093 return PMINFO_R_ERROR;
4095 xschema = xmlSchemaParse(ctx);
4096 if (xschema == NULL) {
4097 DBGE("xmlSchemaParse() Failed\n");
4098 return PMINFO_R_ERROR;
4100 vctx = xmlSchemaNewValidCtxt(xschema);
4102 DBGE("xmlSchemaNewValidCtxt() Failed\n");
4103 return PMINFO_R_ERROR;
4105 xmlSchemaSetValidErrors(vctx, (xmlSchemaValidityErrorFunc) fprintf, (xmlSchemaValidityWarningFunc) fprintf, stderr);
4106 ret = xmlSchemaValidateFile(vctx, manifest, 0);
4108 DBGE("xmlSchemaValidateFile() failed\n");
4109 return PMINFO_R_ERROR;
4110 } else if (ret == 0) {
4111 DBGE("Manifest is Valid\n");
4114 DBGE("Manifest Validation Failed with error code %d\n", ret);
4115 return PMINFO_R_ERROR;
4121 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
4131 DBGE("fork failed\n");
4136 int dev_null_fd = open ("/dev/null", O_RDWR);
4137 if (dev_null_fd >= 0)
4139 dup2 (dev_null_fd, 0);/*stdin*/
4140 dup2 (dev_null_fd, 1);/*stdout*/
4141 dup2 (dev_null_fd, 2);/*stderr*/
4144 if (execl("/usr/bin/xmllint", "xmllint", manifest, "--schema",
4145 SCHEMA_FILE, NULL) < 0) {
4146 DBGE("execl error\n");
4156 while ((err = waitpid(pid, &status, WNOHANG)) != pid) {
4160 DBGE("waitpid failed\n");
4166 if(WIFEXITED(status) && !WEXITSTATUS(status))