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)
605 free((void *)metadata->key);
606 metadata->key = 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;
1258 if (uiapplication->package) {
1259 free((void *)uiapplication->package);
1260 uiapplication->package = NULL;
1263 if (uiapplication->label) {
1264 label_x *label = uiapplication->label;
1265 label_x *tmp = NULL;
1266 while(label != NULL)
1269 __ps_free_label(label);
1274 if (uiapplication->icon) {
1275 icon_x *icon = uiapplication->icon;
1280 __ps_free_icon(icon);
1285 if (uiapplication->image) {
1286 image_x *image = uiapplication->image;
1287 image_x *tmp = NULL;
1288 while(image != NULL)
1291 __ps_free_image(image);
1296 if (uiapplication->appcontrol) {
1297 appcontrol_x *appcontrol = uiapplication->appcontrol;
1298 appcontrol_x *tmp = NULL;
1299 while(appcontrol != NULL)
1301 tmp = appcontrol->next;
1302 __ps_free_appcontrol(appcontrol);
1306 /*Free LaunchConditions*/
1307 if (uiapplication->launchconditions) {
1308 launchconditions_x *launchconditions = uiapplication->launchconditions;
1309 launchconditions_x *tmp = NULL;
1310 while(launchconditions != NULL)
1312 tmp = launchconditions->next;
1313 __ps_free_launchconditions(launchconditions);
1314 launchconditions = tmp;
1317 /*Free Notification*/
1318 if (uiapplication->notification) {
1319 notification_x *notification = uiapplication->notification;
1320 notification_x *tmp = NULL;
1321 while(notification != NULL)
1323 tmp = notification->next;
1324 __ps_free_notification(notification);
1329 if (uiapplication->datashare) {
1330 datashare_x *datashare = uiapplication->datashare;
1331 datashare_x *tmp = NULL;
1332 while(datashare != NULL)
1334 tmp = datashare->next;
1335 __ps_free_datashare(datashare);
1340 if (uiapplication->appsvc) {
1341 appsvc_x *appsvc = uiapplication->appsvc;
1342 appsvc_x *tmp = NULL;
1343 while(appsvc != NULL)
1346 __ps_free_appsvc(appsvc);
1351 if (uiapplication->category) {
1352 category_x *category = uiapplication->category;
1353 category_x *tmp = NULL;
1354 while(category != NULL)
1356 tmp = category->next;
1357 __ps_free_category(category);
1362 if (uiapplication->metadata) {
1363 metadata_x *metadata = uiapplication->metadata;
1364 metadata_x *tmp = NULL;
1365 while(metadata != NULL)
1367 tmp = metadata->next;
1368 __ps_free_metadata(metadata);
1373 if (uiapplication->permission) {
1374 permission_x *permission = uiapplication->permission;
1375 permission_x *tmp = NULL;
1376 while(permission != NULL)
1378 tmp = permission->next;
1379 __ps_free_permission(permission);
1383 /* _PRODUCT_LAUNCHING_ENHANCED_ START */
1384 if (uiapplication->indicatordisplay) {
1385 free((void *)uiapplication->indicatordisplay);
1386 uiapplication->indicatordisplay = NULL;
1388 if (uiapplication->portraitimg) {
1389 free((void *)uiapplication->portraitimg);
1390 uiapplication->portraitimg = NULL;
1392 if (uiapplication->landscapeimg) {
1393 free((void *)uiapplication->landscapeimg);
1394 uiapplication->landscapeimg = NULL;
1396 /* _PRODUCT_LAUNCHING_ENHANCED_ END */
1397 if (uiapplication->guestmode_visibility) {
1398 free((void *)uiapplication->guestmode_visibility);
1399 uiapplication->guestmode_visibility = NULL;
1401 free((void*)uiapplication);
1402 uiapplication = NULL;
1405 static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication)
1407 if (serviceapplication == NULL)
1409 if (serviceapplication->exec) {
1410 free((void *)serviceapplication->exec);
1411 serviceapplication->exec = NULL;
1413 if (serviceapplication->appid) {
1414 free((void *)serviceapplication->appid);
1415 serviceapplication->appid = NULL;
1417 if (serviceapplication->onboot) {
1418 free((void *)serviceapplication->onboot);
1419 serviceapplication->onboot = NULL;
1421 if (serviceapplication->autorestart) {
1422 free((void *)serviceapplication->autorestart);
1423 serviceapplication->autorestart = NULL;
1425 if (serviceapplication->type) {
1426 free((void *)serviceapplication->type);
1427 serviceapplication->type = NULL;
1429 if (serviceapplication->enabled) {
1430 free((void *)serviceapplication->enabled);
1431 serviceapplication->enabled = NULL;
1433 if (serviceapplication->package) {
1434 free((void *)serviceapplication->package);
1435 serviceapplication->package = NULL;
1438 if (serviceapplication->label) {
1439 label_x *label = serviceapplication->label;
1440 label_x *tmp = NULL;
1441 while(label != NULL)
1444 __ps_free_label(label);
1449 if (serviceapplication->icon) {
1450 icon_x *icon = serviceapplication->icon;
1455 __ps_free_icon(icon);
1460 if (serviceapplication->appcontrol) {
1461 appcontrol_x *appcontrol = serviceapplication->appcontrol;
1462 appcontrol_x *tmp = NULL;
1463 while(appcontrol != NULL)
1465 tmp = appcontrol->next;
1466 __ps_free_appcontrol(appcontrol);
1470 /*Free DataControl*/
1471 if (serviceapplication->datacontrol) {
1472 datacontrol_x *datacontrol = serviceapplication->datacontrol;
1473 datacontrol_x *tmp = NULL;
1474 while(datacontrol != NULL)
1476 tmp = datacontrol->next;
1477 __ps_free_datacontrol(datacontrol);
1481 /*Free LaunchConditions*/
1482 if (serviceapplication->launchconditions) {
1483 launchconditions_x *launchconditions = serviceapplication->launchconditions;
1484 launchconditions_x *tmp = NULL;
1485 while(launchconditions != NULL)
1487 tmp = launchconditions->next;
1488 __ps_free_launchconditions(launchconditions);
1489 launchconditions = tmp;
1492 /*Free Notification*/
1493 if (serviceapplication->notification) {
1494 notification_x *notification = serviceapplication->notification;
1495 notification_x *tmp = NULL;
1496 while(notification != NULL)
1498 tmp = notification->next;
1499 __ps_free_notification(notification);
1504 if (serviceapplication->datashare) {
1505 datashare_x *datashare = serviceapplication->datashare;
1506 datashare_x *tmp = NULL;
1507 while(datashare != NULL)
1509 tmp = datashare->next;
1510 __ps_free_datashare(datashare);
1515 if (serviceapplication->appsvc) {
1516 appsvc_x *appsvc = serviceapplication->appsvc;
1517 appsvc_x *tmp = NULL;
1518 while(appsvc != NULL)
1521 __ps_free_appsvc(appsvc);
1526 if (serviceapplication->category) {
1527 category_x *category = serviceapplication->category;
1528 category_x *tmp = NULL;
1529 while(category != NULL)
1531 tmp = category->next;
1532 __ps_free_category(category);
1537 if (serviceapplication->metadata) {
1538 metadata_x *metadata = serviceapplication->metadata;
1539 metadata_x *tmp = NULL;
1540 while(metadata != NULL)
1542 tmp = metadata->next;
1543 __ps_free_metadata(metadata);
1548 if (serviceapplication->permission) {
1549 permission_x *permission = serviceapplication->permission;
1550 permission_x *tmp = NULL;
1551 while(permission != NULL)
1553 tmp = permission->next;
1554 __ps_free_permission(permission);
1558 free((void*)serviceapplication);
1559 serviceapplication = NULL;
1562 static void __ps_free_font(font_x *font)
1567 free((void *)font->name);
1571 free((void *)font->text);
1578 static void __ps_free_theme(theme_x *theme)
1583 free((void *)theme->name);
1587 free((void *)theme->text);
1594 static void __ps_free_daemon(daemon_x *daemon)
1599 free((void *)daemon->name);
1600 daemon->name = NULL;
1603 free((void *)daemon->text);
1604 daemon->text = NULL;
1606 free((void*)daemon);
1610 static void __ps_free_ime(ime_x *ime)
1615 free((void *)ime->name);
1619 free((void *)ime->text);
1627 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed)
1629 xmlTextReaderRead(reader);
1630 if (xmlTextReaderValue(reader))
1631 allowed->text = ASCII(xmlTextReaderValue(reader));
1635 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation)
1637 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1638 operation->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1639 /* Text does not exist. Only attribute exists
1640 xmlTextReaderRead(reader);
1641 if (xmlTextReaderValue(reader))
1642 operation->text = ASCII(xmlTextReaderValue(reader));
1647 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri)
1649 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1650 uri->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1651 /* Text does not exist. Only attribute exists
1652 xmlTextReaderRead(reader);
1653 if (xmlTextReaderValue(reader))
1654 uri->text = ASCII(xmlTextReaderValue(reader));
1659 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime)
1661 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1662 mime->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_subapp(xmlTextReaderPtr reader, subapp_x *subapp)
1673 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1674 subapp->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1675 /* Text does not exist. Only attribute exists
1676 xmlTextReaderRead(reader);
1677 if (xmlTextReaderValue(reader))
1678 mime->text = ASCII(xmlTextReaderValue(reader));
1683 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition)
1685 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1686 condition->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1687 xmlTextReaderRead(reader);
1688 if (xmlTextReaderValue(reader))
1689 condition->text = ASCII(xmlTextReaderValue(reader));
1693 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notification)
1695 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1696 notification->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1697 xmlTextReaderRead(reader);
1698 if (xmlTextReaderValue(reader))
1699 notification->text = ASCII(xmlTextReaderValue(reader));
1703 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category)
1705 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1706 category->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1710 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata)
1712 if (xmlTextReaderGetAttribute(reader, XMLCHAR("key")))
1713 metadata->key = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("key")));
1714 if (xmlTextReaderGetAttribute(reader, XMLCHAR("value")))
1715 metadata->value = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("value")));
1719 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission)
1721 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
1722 permission->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
1724 xmlTextReaderRead(reader);
1725 if (xmlTextReaderValue(reader))
1726 permission->value = ASCII(xmlTextReaderValue(reader));
1730 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility)
1732 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1733 compatibility->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1734 xmlTextReaderRead(reader);
1735 if (xmlTextReaderValue(reader))
1736 compatibility->text = ASCII(xmlTextReaderValue(reader));
1740 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution)
1742 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")))
1743 resolution->mimetype = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")));
1744 if (xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")))
1745 resolution->urischeme = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")));
1749 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request)
1751 xmlTextReaderRead(reader);
1752 if (xmlTextReaderValue(reader))
1753 request->text = ASCII(xmlTextReaderValue(reader));
1757 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define)
1759 const xmlChar *node;
1762 allowed_x *tmp1 = NULL;
1763 request_x *tmp2 = NULL;
1765 if (xmlTextReaderGetAttribute(reader, XMLCHAR("path")))
1766 define->path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("path")));
1768 depth = xmlTextReaderDepth(reader);
1769 while ((ret = __next_child_element(reader, depth))) {
1770 node = xmlTextReaderConstName(reader);
1772 DBG("xmlTextReaderConstName value is NULL\n");
1776 if (!strcmp(ASCII(node), "allowed")) {
1777 allowed_x *allowed= malloc(sizeof(allowed_x));
1778 if (allowed == NULL) {
1779 DBG("Malloc Failed\n");
1782 memset(allowed, '\0', sizeof(allowed_x));
1783 LISTADD(define->allowed, allowed);
1784 ret = __ps_process_allowed(reader, allowed);
1785 } else if (!strcmp(ASCII(node), "request")) {
1786 request_x *request = malloc(sizeof(request_x));
1787 if (request == NULL) {
1788 DBG("Malloc Failed\n");
1791 memset(request, '\0', sizeof(request_x));
1792 LISTADD(define->request, request);
1793 ret = __ps_process_request(reader, request);
1797 DBG("Processing define failed\n");
1801 if (define->allowed) {
1802 LISTHEAD(define->allowed, tmp1);
1803 define->allowed = tmp1;
1805 if (define->request) {
1806 LISTHEAD(define->request, tmp2);
1807 define->request = tmp2;
1812 static int __ps_process_registry(xmlTextReaderPtr reader, registry_x *registry)
1814 /*TODO: once policy is set*/
1818 static int __ps_process_database(xmlTextReaderPtr reader, database_x *database)
1820 /*TODO: once policy is set*/
1824 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol)
1826 const xmlChar *node;
1829 operation_x *tmp1 = NULL;
1831 mime_x *tmp3 = NULL;
1832 subapp_x *tmp4 = NULL;
1834 depth = xmlTextReaderDepth(reader);
1835 while ((ret = __next_child_element(reader, depth))) {
1836 node = xmlTextReaderConstName(reader);
1838 DBG("xmlTextReaderConstName value is NULL\n");
1842 if (!strcmp(ASCII(node), "operation")) {
1843 operation_x *operation = malloc(sizeof(operation_x));
1844 if (operation == NULL) {
1845 DBG("Malloc Failed\n");
1848 memset(operation, '\0', sizeof(operation_x));
1849 LISTADD(appcontrol->operation, operation);
1850 ret = __ps_process_operation(reader, operation);
1851 DBG("operation processing\n");
1852 } else if (!strcmp(ASCII(node), "uri")) {
1853 uri_x *uri= malloc(sizeof(uri_x));
1855 DBG("Malloc Failed\n");
1858 memset(uri, '\0', sizeof(uri_x));
1859 LISTADD(appcontrol->uri, uri);
1860 ret = __ps_process_uri(reader, uri);
1861 DBG("uri processing\n");
1862 } else if (!strcmp(ASCII(node), "mime")) {
1863 mime_x *mime = malloc(sizeof(mime_x));
1865 DBG("Malloc Failed\n");
1868 memset(mime, '\0', sizeof(mime_x));
1869 LISTADD(appcontrol->mime, mime);
1870 ret = __ps_process_mime(reader, mime);
1871 DBG("mime processing\n");
1872 } else if (!strcmp(ASCII(node), "subapp")) {
1873 subapp_x *subapp = malloc(sizeof(subapp_x));
1874 if (subapp == NULL) {
1875 DBG("Malloc Failed\n");
1878 memset(subapp, '\0', sizeof(subapp_x));
1879 LISTADD(appcontrol->subapp, subapp);
1880 ret = __ps_process_subapp(reader, subapp);
1881 DBG("subapp processing\n");
1885 DBG("Processing appcontrol failed\n");
1889 if (appcontrol->operation) {
1890 LISTHEAD(appcontrol->operation, tmp1);
1891 appcontrol->operation = tmp1;
1893 if (appcontrol->uri) {
1894 LISTHEAD(appcontrol->uri, tmp2);
1895 appcontrol->uri = tmp2;
1897 if (appcontrol->mime) {
1898 LISTHEAD(appcontrol->mime, tmp3);
1899 appcontrol->mime = tmp3;
1901 if (appcontrol->subapp) {
1902 LISTHEAD(appcontrol->subapp, tmp4);
1903 appcontrol->subapp = tmp4;
1906 xmlTextReaderRead(reader);
1907 if (xmlTextReaderValue(reader))
1908 appcontrol->text = ASCII(xmlTextReaderValue(reader));
1913 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc)
1915 const xmlChar *node;
1918 operation_x *tmp1 = NULL;
1920 mime_x *tmp3 = NULL;
1921 subapp_x *tmp4 = NULL;
1923 depth = xmlTextReaderDepth(reader);
1924 while ((ret = __next_child_element(reader, depth))) {
1925 node = xmlTextReaderConstName(reader);
1927 DBG("xmlTextReaderConstName value is NULL\n");
1931 if (!strcmp(ASCII(node), "operation")) {
1932 operation_x *operation = malloc(sizeof(operation_x));
1933 if (operation == NULL) {
1934 DBG("Malloc Failed\n");
1937 memset(operation, '\0', sizeof(operation_x));
1938 LISTADD(appsvc->operation, operation);
1939 ret = __ps_process_operation(reader, operation);
1940 DBG("operation processing\n");
1941 } else if (!strcmp(ASCII(node), "uri")) {
1942 uri_x *uri= malloc(sizeof(uri_x));
1944 DBG("Malloc Failed\n");
1947 memset(uri, '\0', sizeof(uri_x));
1948 LISTADD(appsvc->uri, uri);
1949 ret = __ps_process_uri(reader, uri);
1950 DBG("uri processing\n");
1951 } else if (!strcmp(ASCII(node), "mime")) {
1952 mime_x *mime = malloc(sizeof(mime_x));
1954 DBG("Malloc Failed\n");
1957 memset(mime, '\0', sizeof(mime_x));
1958 LISTADD(appsvc->mime, mime);
1959 ret = __ps_process_mime(reader, mime);
1960 DBG("mime processing\n");
1961 } else if (!strcmp(ASCII(node), "subapp")) {
1962 subapp_x *subapp = malloc(sizeof(subapp_x));
1963 if (subapp == NULL) {
1964 DBG("Malloc Failed\n");
1967 memset(subapp, '\0', sizeof(subapp_x));
1968 LISTADD(appsvc->subapp, subapp);
1969 ret = __ps_process_subapp(reader, subapp);
1970 DBG("subapp processing\n");
1974 DBG("Processing appsvc failed\n");
1978 if (appsvc->operation) {
1979 LISTHEAD(appsvc->operation, tmp1);
1980 appsvc->operation = tmp1;
1983 LISTHEAD(appsvc->uri, tmp2);
1987 LISTHEAD(appsvc->mime, tmp3);
1988 appsvc->mime = tmp3;
1990 if (appsvc->subapp) {
1991 LISTHEAD(appsvc->subapp, tmp4);
1992 appsvc->subapp = tmp4;
1995 xmlTextReaderRead(reader);
1996 if (xmlTextReaderValue(reader))
1997 appsvc->text = ASCII(xmlTextReaderValue(reader));
2002 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions)
2004 const xmlChar *node;
2007 condition_x *tmp1 = NULL;
2009 depth = xmlTextReaderDepth(reader);
2010 while ((ret = __next_child_element(reader, depth))) {
2011 node = xmlTextReaderConstName(reader);
2013 DBG("xmlTextReaderConstName value is NULL\n");
2017 if (strcmp(ASCII(node), "condition") == 0) {
2018 condition_x *condition = malloc(sizeof(condition_x));
2019 if (condition == NULL) {
2020 DBG("Malloc Failed\n");
2023 memset(condition, '\0', sizeof(condition_x));
2024 LISTADD(launchconditions->condition, condition);
2025 ret = __ps_process_condition(reader, condition);
2029 DBG("Processing launchconditions failed\n");
2033 if (launchconditions->condition) {
2034 LISTHEAD(launchconditions->condition, tmp1);
2035 launchconditions->condition = tmp1;
2038 xmlTextReaderRead(reader);
2039 if (xmlTextReaderValue(reader))
2040 launchconditions->text = ASCII(xmlTextReaderValue(reader));
2045 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare)
2047 const xmlChar *node;
2050 define_x *tmp1 = NULL;
2051 request_x *tmp2 = NULL;
2052 depth = xmlTextReaderDepth(reader);
2053 while ((ret = __next_child_element(reader, depth))) {
2054 node = xmlTextReaderConstName(reader);
2056 DBG("xmlTextReaderConstName value is NULL\n");
2060 if (!strcmp(ASCII(node), "define")) {
2061 define_x *define= malloc(sizeof(define_x));
2062 if (define == NULL) {
2063 DBG("Malloc Failed\n");
2066 memset(define, '\0', sizeof(define_x));
2067 LISTADD(datashare->define, define);
2068 ret = __ps_process_define(reader, define);
2069 } else if (!strcmp(ASCII(node), "request")) {
2070 request_x *request= malloc(sizeof(request_x));
2071 if (request == NULL) {
2072 DBG("Malloc Failed\n");
2075 memset(request, '\0', sizeof(request_x));
2076 LISTADD(datashare->request, request);
2077 ret = __ps_process_request(reader, request);
2081 DBG("Processing data-share failed\n");
2085 if (datashare->define) {
2086 LISTHEAD(datashare->define, tmp1);
2087 datashare->define = tmp1;
2089 if (datashare->request) {
2090 LISTHEAD(datashare->request, tmp2);
2091 datashare->request = tmp2;
2096 static int __ps_process_layout(xmlTextReaderPtr reader, layout_x *layout)
2098 /*TODO: once policy is set*/
2103 __get_icon_with_path(char* icon)
2108 if (index(icon, '/') == NULL) {
2110 char* icon_with_path = NULL;
2116 theme = vconf_get_str("db/setting/theme");
2118 theme = strdup("default");
2124 len = (0x01 << 7) + strlen(icon) + strlen(package) + strlen(theme);
2125 icon_with_path = malloc(len);
2126 if(icon_with_path == NULL) {
2127 DBG("(icon_with_path == NULL) return\n");
2132 memset(icon_with_path, 0, len);
2134 snprintf(icon_with_path, len, "/opt/share/icons/%s/small/%s", theme, icon);
2136 if (access(icon_with_path, R_OK) == 0) break;
2137 snprintf(icon_with_path, len, "/usr/share/icons/%s/small/%s", theme, icon);
2138 if (access(icon_with_path, R_OK) == 0) break;
2139 DBG("cannot find icon %s", icon_with_path);
2140 snprintf(icon_with_path, len,"/opt/share/icons/default/small/%s", icon);
2141 if (access(icon_with_path, R_OK) == 0) break;
2142 snprintf(icon_with_path, len, "/usr/share/icons/default/small/%s", icon);
2143 if (access(icon_with_path, R_OK) == 0) break;
2145 /* icon path is going to be moved intto the app directory */
2146 DBGE("icon file must be moved to %s", icon_with_path);
2147 snprintf(icon_with_path, len, "/opt/apps/%s/res/icons/%s/small/%s", package, theme, icon);
2148 if (access(icon_with_path, R_OK) == 0) break;
2149 snprintf(icon_with_path, len, "/usr/apps/%s/res/icons/%s/small/%s", package, theme, icon);
2150 if (access(icon_with_path, R_OK) == 0) break;
2151 DBG("cannot find icon %s", icon_with_path);
2152 snprintf(icon_with_path, len, "/opt/apps/%s/res/icons/default/small/%s", package, icon);
2153 if (access(icon_with_path, R_OK) == 0) break;
2154 snprintf(icon_with_path, len, "/usr/apps/%s/res/icons/default/small/%s", package, icon);
2155 if (access(icon_with_path, R_OK) == 0) break;
2160 DBG("Icon path : %s ---> %s", icon, icon_with_path);
2162 return icon_with_path;
2164 char* confirmed_icon = NULL;
2166 confirmed_icon = strdup(icon);
2167 if (!confirmed_icon)
2169 return confirmed_icon;
2174 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon)
2176 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2177 icon->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2178 if (xmlTextReaderConstXmlLang(reader)) {
2179 icon->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2180 if (icon->lang == NULL)
2181 icon->lang = strdup(DEFAULT_LOCALE);
2183 icon->lang = strdup(DEFAULT_LOCALE);
2185 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
2186 icon->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
2187 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
2188 icon->size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
2189 if (xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")))
2190 icon->resolution = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")));
2191 xmlTextReaderRead(reader);
2192 if (xmlTextReaderValue(reader)) {
2193 char *text = ASCII(xmlTextReaderValue(reader));
2195 icon->text = __get_icon_with_path(text);
2203 static int __ps_process_image(xmlTextReaderPtr reader, image_x *image)
2205 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2206 image->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2207 if (xmlTextReaderConstXmlLang(reader)) {
2208 image->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2209 if (image->lang == NULL)
2210 image->lang = strdup(DEFAULT_LOCALE);
2212 image->lang = strdup(DEFAULT_LOCALE);
2214 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
2215 image->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
2216 xmlTextReaderRead(reader);
2217 if (xmlTextReaderValue(reader))
2218 image->text = ASCII(xmlTextReaderValue(reader));
2223 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label)
2225 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2226 label->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2227 if (xmlTextReaderConstXmlLang(reader)) {
2228 label->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2229 if (label->lang == NULL)
2230 label->lang = strdup(DEFAULT_LOCALE);
2232 label->lang = strdup(DEFAULT_LOCALE);
2234 xmlTextReaderRead(reader);
2235 if (xmlTextReaderValue(reader))
2236 label->text = ASCII(xmlTextReaderValue(reader));
2238 /* DBG("lable name %s\n", label->name);
2239 DBG("lable lang %s\n", label->lang);
2240 DBG("lable text %s\n", label->text);
2246 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author)
2248 if (xmlTextReaderGetAttribute(reader, XMLCHAR("email")))
2249 author->email = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("email")));
2250 if (xmlTextReaderGetAttribute(reader, XMLCHAR("href")))
2251 author->href = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("href")));
2252 if (xmlTextReaderConstXmlLang(reader)) {
2253 author->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2254 if (author->lang == NULL)
2255 author->lang = strdup(DEFAULT_LOCALE);
2257 author->lang = strdup(DEFAULT_LOCALE);
2259 xmlTextReaderRead(reader);
2260 if (xmlTextReaderValue(reader))
2261 author->text = ASCII(xmlTextReaderValue(reader));
2265 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description)
2267 if (xmlTextReaderConstXmlLang(reader)) {
2268 description->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2269 if (description->lang == NULL)
2270 description->lang = strdup(DEFAULT_LOCALE);
2272 description->lang = strdup(DEFAULT_LOCALE);
2274 xmlTextReaderRead(reader);
2275 if (xmlTextReaderValue(reader))
2276 description->text = ASCII(xmlTextReaderValue(reader));
2280 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license)
2282 if (xmlTextReaderConstXmlLang(reader)) {
2283 license->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2284 if (license->lang == NULL)
2285 license->lang = strdup(DEFAULT_LOCALE);
2287 license->lang = strdup(DEFAULT_LOCALE);
2289 xmlTextReaderRead(reader);
2290 if (xmlTextReaderValue(reader))
2291 license->text = ASCII(xmlTextReaderValue(reader));
2295 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability)
2297 const xmlChar *node;
2300 resolution_x *tmp1 = NULL;
2302 if (xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")))
2303 capability->operationid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")));
2305 depth = xmlTextReaderDepth(reader);
2306 while ((ret = __next_child_element(reader, depth))) {
2307 node = xmlTextReaderConstName(reader);
2309 DBG("xmlTextReaderConstName value is NULL\n");
2313 if (!strcmp(ASCII(node), "resolution")) {
2314 resolution_x *resolution = malloc(sizeof(resolution_x));
2315 if (resolution == NULL) {
2316 DBG("Malloc Failed\n");
2319 memset(resolution, '\0', sizeof(resolution_x));
2320 LISTADD(capability->resolution, resolution);
2321 ret = __ps_process_resolution(reader, resolution);
2325 DBG("Processing capability failed\n");
2330 if (capability->resolution) {
2331 LISTHEAD(capability->resolution, tmp1);
2332 capability->resolution = tmp1;
2338 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol)
2340 const xmlChar *node;
2343 capability_x *tmp1 = NULL;
2345 if (xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")))
2346 datacontrol->providerid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")));
2348 depth = xmlTextReaderDepth(reader);
2349 while ((ret = __next_child_element(reader, depth))) {
2350 node = xmlTextReaderConstName(reader);
2352 DBG("xmlTextReaderConstName value is NULL\n");
2356 if (!strcmp(ASCII(node), "capability")) {
2357 capability_x *capability = malloc(sizeof(capability_x));
2358 if (capability == NULL) {
2359 DBG("Malloc Failed\n");
2362 memset(capability, '\0', sizeof(capability_x));
2363 LISTADD(datacontrol->capability, capability);
2364 ret = __ps_process_capability(reader, capability);
2368 DBG("Processing datacontrol failed\n");
2373 if (datacontrol->capability) {
2374 LISTHEAD(datacontrol->capability, tmp1);
2375 datacontrol->capability = tmp1;
2381 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication)
2383 const xmlChar *node;
2386 char *newappid = NULL;
2387 label_x *tmp1 = NULL;
2388 icon_x *tmp2 = NULL;
2389 appsvc_x *tmp3 = NULL;
2390 appcontrol_x *tmp4 = NULL;
2391 launchconditions_x *tmp5 = NULL;
2392 notification_x *tmp6 = NULL;
2393 datashare_x *tmp7 = NULL;
2394 category_x *tmp8 = NULL;
2395 metadata_x *tmp9 = NULL;
2396 image_x *tmp10 = NULL;
2397 permission_x *tmp11 = NULL;
2399 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
2400 uiapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
2401 if (uiapplication->appid == NULL) {
2402 DBG("appid cant be NULL\n");
2406 DBG("appid is mandatory\n");
2410 ret = __validate_appid(package, uiapplication->appid, &newappid);
2412 DBG("appid is not proper\n");
2416 if (uiapplication->appid)
2417 free((void *)uiapplication->appid);
2418 uiapplication->appid = newappid;
2421 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
2422 uiapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
2423 if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay"))) {
2424 uiapplication->nodisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay")));
2425 if (uiapplication->nodisplay == NULL)
2426 uiapplication->nodisplay = strdup("false");
2428 uiapplication->nodisplay = strdup("false");
2430 if (xmlTextReaderGetAttribute(reader, XMLCHAR("multiple"))) {
2431 uiapplication->multiple = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("multiple")));
2432 if (uiapplication->multiple == NULL)
2433 uiapplication->multiple = strdup("false");
2435 uiapplication->multiple = strdup("false");
2437 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
2438 uiapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
2439 if (xmlTextReaderGetAttribute(reader, XMLCHAR("categories")))
2440 uiapplication->categories = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("categories")));
2441 if (xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")))
2442 uiapplication->extraid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")));
2443 if (xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage"))) {
2444 uiapplication->taskmanage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage")));
2445 if (uiapplication->taskmanage == NULL)
2446 uiapplication->taskmanage = strdup("true");
2448 uiapplication->taskmanage = strdup("true");
2450 if (xmlTextReaderGetAttribute(reader, XMLCHAR("enabled"))) {
2451 uiapplication->enabled = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("enabled")));
2452 if (uiapplication->enabled == NULL)
2453 uiapplication->enabled = strdup("true");
2455 uiapplication->enabled = strdup("true");
2457 if (xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration"))) {
2458 uiapplication->hwacceleration = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration")));
2459 if (uiapplication->hwacceleration == NULL)
2460 uiapplication->hwacceleration = strdup("use-system-setting");
2462 uiapplication->hwacceleration = strdup("use-system-setting");
2464 if (xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")))
2465 uiapplication->recentimage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")));
2466 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp"))) {
2467 uiapplication->mainapp = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp")));
2468 if (uiapplication->mainapp == NULL)
2469 uiapplication->mainapp = strdup("false");
2471 uiapplication->mainapp = strdup("false");
2473 if (xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay"))) {
2474 uiapplication->indicatordisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay")));
2475 if (uiapplication->indicatordisplay == NULL)
2476 uiapplication->indicatordisplay = strdup("true");
2478 uiapplication->indicatordisplay = strdup("true");
2480 if (xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")))
2481 uiapplication->portraitimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")));
2483 uiapplication->portraitimg = NULL;
2484 if (xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")))
2485 uiapplication->landscapeimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")));
2487 uiapplication->landscapeimg = NULL;
2488 if (xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility"))) {
2489 uiapplication->guestmode_visibility = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility")));
2490 if (uiapplication->guestmode_visibility == NULL)
2491 uiapplication->guestmode_visibility = strdup("true");
2493 uiapplication->guestmode_visibility = strdup("true");
2496 depth = xmlTextReaderDepth(reader);
2497 while ((ret = __next_child_element(reader, depth))) {
2498 node = xmlTextReaderConstName(reader);
2500 DBG("xmlTextReaderConstName value is NULL\n");
2503 if (!strcmp(ASCII(node), "label")) {
2504 label_x *label = malloc(sizeof(label_x));
2505 if (label == NULL) {
2506 DBG("Malloc Failed\n");
2509 memset(label, '\0', sizeof(label_x));
2510 LISTADD(uiapplication->label, label);
2511 ret = __ps_process_label(reader, label);
2512 } else if (!strcmp(ASCII(node), "icon")) {
2513 icon_x *icon = malloc(sizeof(icon_x));
2515 DBG("Malloc Failed\n");
2518 memset(icon, '\0', sizeof(icon_x));
2519 LISTADD(uiapplication->icon, icon);
2520 ret = __ps_process_icon(reader, icon);
2521 } else if (!strcmp(ASCII(node), "image")) {
2522 image_x *image = malloc(sizeof(image_x));
2523 if (image == NULL) {
2524 DBG("Malloc Failed\n");
2527 memset(image, '\0', sizeof(image_x));
2528 LISTADD(uiapplication->image, image);
2529 ret = __ps_process_image(reader, image);
2530 } else if (!strcmp(ASCII(node), "category")) {
2531 category_x *category = malloc(sizeof(category_x));
2532 if (category == NULL) {
2533 DBG("Malloc Failed\n");
2536 memset(category, '\0', sizeof(category_x));
2537 LISTADD(uiapplication->category, category);
2538 ret = __ps_process_category(reader, category);
2539 } else if (!strcmp(ASCII(node), "metadata")) {
2540 metadata_x *metadata = malloc(sizeof(metadata_x));
2541 if (metadata == NULL) {
2542 DBG("Malloc Failed\n");
2545 memset(metadata, '\0', sizeof(metadata_x));
2546 LISTADD(uiapplication->metadata, metadata);
2547 ret = __ps_process_metadata(reader, metadata);
2548 } else if (!strcmp(ASCII(node), "permission")) {
2549 permission_x *permission = malloc(sizeof(permission_x));
2550 if (permission == NULL) {
2551 DBG("Malloc Failed\n");
2554 memset(permission, '\0', sizeof(permission_x));
2555 LISTADD(uiapplication->permission, permission);
2556 ret = __ps_process_permission(reader, permission);
2557 } else if (!strcmp(ASCII(node), "app-control")) {
2558 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
2559 if (appcontrol == NULL) {
2560 DBG("Malloc Failed\n");
2563 memset(appcontrol, '\0', sizeof(appcontrol_x));
2564 LISTADD(uiapplication->appcontrol, appcontrol);
2565 ret = __ps_process_appcontrol(reader, appcontrol);
2566 } else if (!strcmp(ASCII(node), "application-service")) {
2567 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
2568 if (appsvc == NULL) {
2569 DBG("Malloc Failed\n");
2572 memset(appsvc, '\0', sizeof(appsvc_x));
2573 LISTADD(uiapplication->appsvc, appsvc);
2574 ret = __ps_process_appsvc(reader, appsvc);
2575 } else if (!strcmp(ASCII(node), "data-share")) {
2576 datashare_x *datashare = malloc(sizeof(datashare_x));
2577 if (datashare == NULL) {
2578 DBG("Malloc Failed\n");
2581 memset(datashare, '\0', sizeof(datashare_x));
2582 LISTADD(uiapplication->datashare, datashare);
2583 ret = __ps_process_datashare(reader, datashare);
2584 } else if (!strcmp(ASCII(node), "launch-conditions")) {
2585 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
2586 if (launchconditions == NULL) {
2587 DBG("Malloc Failed\n");
2590 memset(launchconditions, '\0', sizeof(launchconditions_x));
2591 LISTADD(uiapplication->launchconditions, launchconditions);
2592 ret = __ps_process_launchconditions(reader, launchconditions);
2593 } else if (!strcmp(ASCII(node), "notification")) {
2594 notification_x *notification = malloc(sizeof(notification_x));
2595 if (notification == NULL) {
2596 DBG("Malloc Failed\n");
2599 memset(notification, '\0', sizeof(notification_x));
2600 LISTADD(uiapplication->notification, notification);
2601 ret = __ps_process_notification(reader, notification);
2605 DBG("Processing uiapplication failed\n");
2610 if (uiapplication->label) {
2611 LISTHEAD(uiapplication->label, tmp1);
2612 uiapplication->label = tmp1;
2614 if (uiapplication->icon) {
2615 LISTHEAD(uiapplication->icon, tmp2);
2616 uiapplication->icon = tmp2;
2618 if (uiapplication->appsvc) {
2619 LISTHEAD(uiapplication->appsvc, tmp3);
2620 uiapplication->appsvc = tmp3;
2622 if (uiapplication->appcontrol) {
2623 LISTHEAD(uiapplication->appcontrol, tmp4);
2624 uiapplication->appcontrol = tmp4;
2626 if (uiapplication->launchconditions) {
2627 LISTHEAD(uiapplication->launchconditions, tmp5);
2628 uiapplication->launchconditions = tmp5;
2630 if (uiapplication->notification) {
2631 LISTHEAD(uiapplication->notification, tmp6);
2632 uiapplication->notification = tmp6;
2634 if (uiapplication->datashare) {
2635 LISTHEAD(uiapplication->datashare, tmp7);
2636 uiapplication->datashare = tmp7;
2638 if (uiapplication->category) {
2639 LISTHEAD(uiapplication->category, tmp8);
2640 uiapplication->category = tmp8;
2642 if (uiapplication->metadata) {
2643 LISTHEAD(uiapplication->metadata, tmp9);
2644 uiapplication->metadata = tmp9;
2646 if (uiapplication->image) {
2647 LISTHEAD(uiapplication->image, tmp10);
2648 uiapplication->image = tmp10;
2650 if (uiapplication->permission) {
2651 LISTHEAD(uiapplication->permission, tmp11);
2652 uiapplication->permission = tmp11;
2658 static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication)
2660 const xmlChar *node;
2663 char *newappid = NULL;
2664 label_x *tmp1 = NULL;
2665 icon_x *tmp2 = NULL;
2666 appsvc_x *tmp3 = NULL;
2667 appcontrol_x *tmp4 = NULL;
2668 datacontrol_x *tmp5 = NULL;
2669 launchconditions_x *tmp6 = NULL;
2670 notification_x *tmp7 = NULL;
2671 datashare_x *tmp8 = NULL;
2672 category_x *tmp9 = NULL;
2673 metadata_x *tmp10 = NULL;
2674 permission_x *tmp11 = NULL;
2676 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
2677 serviceapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
2678 if (serviceapplication->appid == NULL) {
2679 DBG("appid cant be NULL\n");
2683 DBG("appid is mandatory\n");
2687 ret = __validate_appid(package, serviceapplication->appid, &newappid);
2689 DBG("appid is not proper\n");
2693 if (serviceapplication->appid)
2694 free((void *)serviceapplication->appid);
2695 serviceapplication->appid = newappid;
2698 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
2699 serviceapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
2700 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
2701 serviceapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
2702 if (xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot"))) {
2703 serviceapplication->onboot = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot")));
2704 if (serviceapplication->onboot == NULL)
2705 serviceapplication->onboot = strdup("false");
2707 serviceapplication->onboot = strdup("false");
2709 if (xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart"))) {
2710 serviceapplication->autorestart = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart")));
2711 if (serviceapplication->autorestart == NULL)
2712 serviceapplication->autorestart = strdup("false");
2714 serviceapplication->autorestart = strdup("false");
2717 depth = xmlTextReaderDepth(reader);
2718 while ((ret = __next_child_element(reader, depth))) {
2719 node = xmlTextReaderConstName(reader);
2721 DBG("xmlTextReaderConstName value is NULL\n");
2725 if (!strcmp(ASCII(node), "label")) {
2726 label_x *label = malloc(sizeof(label_x));
2727 if (label == NULL) {
2728 DBG("Malloc Failed\n");
2731 memset(label, '\0', sizeof(label_x));
2732 LISTADD(serviceapplication->label, label);
2733 ret = __ps_process_label(reader, label);
2734 } else if (!strcmp(ASCII(node), "icon")) {
2735 icon_x *icon = malloc(sizeof(icon_x));
2737 DBG("Malloc Failed\n");
2740 memset(icon, '\0', sizeof(icon_x));
2741 LISTADD(serviceapplication->icon, icon);
2742 ret = __ps_process_icon(reader, icon);
2743 } else if (!strcmp(ASCII(node), "category")) {
2744 category_x *category = malloc(sizeof(category_x));
2745 if (category == NULL) {
2746 DBG("Malloc Failed\n");
2749 memset(category, '\0', sizeof(category_x));
2750 LISTADD(serviceapplication->category, category);
2751 ret = __ps_process_category(reader, category);
2752 } else if (!strcmp(ASCII(node), "metadata")) {
2753 metadata_x *metadata = malloc(sizeof(metadata_x));
2754 if (metadata == NULL) {
2755 DBG("Malloc Failed\n");
2758 memset(metadata, '\0', sizeof(metadata_x));
2759 LISTADD(serviceapplication->metadata, metadata);
2760 ret = __ps_process_metadata(reader, metadata);
2761 } else if (!strcmp(ASCII(node), "permission")) {
2762 permission_x *permission = malloc(sizeof(permission_x));
2763 if (permission == NULL) {
2764 DBG("Malloc Failed\n");
2767 memset(permission, '\0', sizeof(permission_x));
2768 LISTADD(serviceapplication->permission, permission);
2769 ret = __ps_process_permission(reader, permission);
2770 } else if (!strcmp(ASCII(node), "app-control")) {
2771 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
2772 if (appcontrol == NULL) {
2773 DBG("Malloc Failed\n");
2776 memset(appcontrol, '\0', sizeof(appcontrol_x));
2777 LISTADD(serviceapplication->appcontrol, appcontrol);
2778 ret = __ps_process_appcontrol(reader, appcontrol);
2779 } else if (!strcmp(ASCII(node), "application-service")) {
2780 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
2781 if (appsvc == NULL) {
2782 DBG("Malloc Failed\n");
2785 memset(appsvc, '\0', sizeof(appsvc_x));
2786 LISTADD(serviceapplication->appsvc, appsvc);
2787 ret = __ps_process_appsvc(reader, appsvc);
2788 } else if (!strcmp(ASCII(node), "data-share")) {
2789 datashare_x *datashare = malloc(sizeof(datashare_x));
2790 if (datashare == NULL) {
2791 DBG("Malloc Failed\n");
2794 memset(datashare, '\0', sizeof(datashare_x));
2795 LISTADD(serviceapplication->datashare, datashare);
2796 ret = __ps_process_datashare(reader, datashare);
2797 } else if (!strcmp(ASCII(node), "launch-conditions")) {
2798 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
2799 if (launchconditions == NULL) {
2800 DBG("Malloc Failed\n");
2803 memset(launchconditions, '\0', sizeof(launchconditions_x));
2804 LISTADD(serviceapplication->launchconditions, launchconditions);
2805 ret = __ps_process_launchconditions(reader, launchconditions);
2806 } else if (!strcmp(ASCII(node), "notification")) {
2807 notification_x *notification = malloc(sizeof(notification_x));
2808 if (notification == NULL) {
2809 DBG("Malloc Failed\n");
2812 memset(notification, '\0', sizeof(notification_x));
2813 LISTADD(serviceapplication->notification, notification);
2814 ret = __ps_process_notification(reader, notification);
2815 } else if (!strcmp(ASCII(node), "data-control")) {
2816 datacontrol_x *datacontrol = malloc(sizeof(datacontrol_x));
2817 if (datacontrol == NULL) {
2818 DBG("Malloc Failed\n");
2821 memset(datacontrol, '\0', sizeof(datacontrol_x));
2822 LISTADD(serviceapplication->datacontrol, datacontrol);
2823 ret = __ps_process_datacontrol(reader, datacontrol);
2827 DBG("Processing serviceapplication failed\n");
2832 if (serviceapplication->label) {
2833 LISTHEAD(serviceapplication->label, tmp1);
2834 serviceapplication->label = tmp1;
2836 if (serviceapplication->icon) {
2837 LISTHEAD(serviceapplication->icon, tmp2);
2838 serviceapplication->icon = tmp2;
2840 if (serviceapplication->appsvc) {
2841 LISTHEAD(serviceapplication->appsvc, tmp3);
2842 serviceapplication->appsvc = tmp3;
2844 if (serviceapplication->appcontrol) {
2845 LISTHEAD(serviceapplication->appcontrol, tmp4);
2846 serviceapplication->appcontrol = tmp4;
2848 if (serviceapplication->datacontrol) {
2849 LISTHEAD(serviceapplication->datacontrol, tmp5);
2850 serviceapplication->datacontrol = tmp5;
2852 if (serviceapplication->launchconditions) {
2853 LISTHEAD(serviceapplication->launchconditions, tmp6);
2854 serviceapplication->launchconditions = tmp6;
2856 if (serviceapplication->notification) {
2857 LISTHEAD(serviceapplication->notification, tmp7);
2858 serviceapplication->notification = tmp7;
2860 if (serviceapplication->datashare) {
2861 LISTHEAD(serviceapplication->datashare, tmp8);
2862 serviceapplication->datashare = tmp8;
2864 if (serviceapplication->category) {
2865 LISTHEAD(serviceapplication->category, tmp9);
2866 serviceapplication->category = tmp9;
2868 if (serviceapplication->metadata) {
2869 LISTHEAD(serviceapplication->metadata, tmp10);
2870 serviceapplication->metadata = tmp10;
2872 if (serviceapplication->permission) {
2873 LISTHEAD(serviceapplication->permission, tmp11);
2874 serviceapplication->permission = tmp11;
2880 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile)
2882 /*TODO: once policy is set*/
2886 static int __ps_process_font(xmlTextReaderPtr reader, font_x *font)
2888 /*TODO: once policy is set*/
2892 static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme)
2894 /*TODO: once policy is set*/
2898 static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon)
2900 /*TODO: once policy is set*/
2904 static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime)
2906 /*TODO: once policy is set*/
2910 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx)
2912 DBG("__start_process\n");
2913 const xmlChar *node;
2916 label_x *tmp1 = NULL;
2917 author_x *tmp2 = NULL;
2918 description_x *tmp3 = NULL;
2919 license_x *tmp4 = NULL;
2920 uiapplication_x *tmp5 = NULL;
2921 serviceapplication_x *tmp6 = NULL;
2922 daemon_x *tmp7 = NULL;
2923 theme_x *tmp8 = NULL;
2924 font_x *tmp9 = NULL;
2925 ime_x *tmp10 = NULL;
2926 icon_x *tmp11 = NULL;
2927 compatibility_x *tmp12 = NULL;
2928 deviceprofile_x *tmp13 = NULL;
2930 depth = xmlTextReaderDepth(reader);
2931 while ((ret = __next_child_element(reader, depth))) {
2932 node = xmlTextReaderConstName(reader);
2934 DBG("xmlTextReaderConstName value is NULL\n");
2938 if (!strcmp(ASCII(node), "label")) {
2939 label_x *label = malloc(sizeof(label_x));
2940 if (label == NULL) {
2941 DBG("Malloc Failed\n");
2944 memset(label, '\0', sizeof(label_x));
2945 LISTADD(mfx->label, label);
2946 ret = __ps_process_label(reader, label);
2947 } else if (!strcmp(ASCII(node), "author")) {
2948 author_x *author = malloc(sizeof(author_x));
2949 if (author == NULL) {
2950 DBG("Malloc Failed\n");
2953 memset(author, '\0', sizeof(author_x));
2954 LISTADD(mfx->author, author);
2955 ret = __ps_process_author(reader, author);
2956 } else if (!strcmp(ASCII(node), "description")) {
2957 description_x *description = malloc(sizeof(description_x));
2958 if (description == NULL) {
2959 DBG("Malloc Failed\n");
2962 memset(description, '\0', sizeof(description_x));
2963 LISTADD(mfx->description, description);
2964 ret = __ps_process_description(reader, description);
2965 } else if (!strcmp(ASCII(node), "license")) {
2966 license_x *license = malloc(sizeof(license_x));
2967 if (license == NULL) {
2968 DBG("Malloc Failed\n");
2971 memset(license, '\0', sizeof(license_x));
2972 LISTADD(mfx->license, license);
2973 ret = __ps_process_license(reader, license);
2974 } else if (!strcmp(ASCII(node), "ui-application")) {
2975 uiapplication_x *uiapplication = malloc(sizeof(uiapplication_x));
2976 if (uiapplication == NULL) {
2977 DBG("Malloc Failed\n");
2980 memset(uiapplication, '\0', sizeof(uiapplication_x));
2981 LISTADD(mfx->uiapplication, uiapplication);
2982 ret = __ps_process_uiapplication(reader, uiapplication);
2983 } else if (!strcmp(ASCII(node), "service-application")) {
2984 serviceapplication_x *serviceapplication = malloc(sizeof(serviceapplication_x));
2985 if (serviceapplication == NULL) {
2986 DBG("Malloc Failed\n");
2989 memset(serviceapplication, '\0', sizeof(serviceapplication_x));
2990 LISTADD(mfx->serviceapplication, serviceapplication);
2991 ret = __ps_process_serviceapplication(reader, serviceapplication);
2992 } else if (!strcmp(ASCII(node), "daemon")) {
2993 daemon_x *daemon = malloc(sizeof(daemon_x));
2994 if (daemon == NULL) {
2995 DBG("Malloc Failed\n");
2998 memset(daemon, '\0', sizeof(daemon_x));
2999 LISTADD(mfx->daemon, daemon);
3000 ret = __ps_process_daemon(reader, daemon);
3001 } else if (!strcmp(ASCII(node), "theme")) {
3002 theme_x *theme = malloc(sizeof(theme_x));
3003 if (theme == NULL) {
3004 DBG("Malloc Failed\n");
3007 memset(theme, '\0', sizeof(theme_x));
3008 LISTADD(mfx->theme, theme);
3009 ret = __ps_process_theme(reader, theme);
3010 } else if (!strcmp(ASCII(node), "font")) {
3011 font_x *font = malloc(sizeof(font_x));
3013 DBG("Malloc Failed\n");
3016 memset(font, '\0', sizeof(font_x));
3017 LISTADD(mfx->font, font);
3018 ret = __ps_process_font(reader, font);
3019 } else if (!strcmp(ASCII(node), "ime")) {
3020 ime_x *ime = malloc(sizeof(ime_x));
3022 DBG("Malloc Failed\n");
3025 memset(ime, '\0', sizeof(ime_x));
3026 LISTADD(mfx->ime, ime);
3027 ret = __ps_process_ime(reader, ime);
3028 } else if (!strcmp(ASCII(node), "icon")) {
3029 icon_x *icon = malloc(sizeof(icon_x));
3031 DBG("Malloc Failed\n");
3034 memset(icon, '\0', sizeof(icon_x));
3035 LISTADD(mfx->icon, icon);
3036 ret = __ps_process_icon(reader, icon);
3037 } else if (!strcmp(ASCII(node), "device-profile")) {
3038 deviceprofile_x *deviceprofile = malloc(sizeof(deviceprofile_x));
3039 if (deviceprofile == NULL) {
3040 DBG("Malloc Failed\n");
3043 memset(deviceprofile, '\0', sizeof(deviceprofile_x));
3044 LISTADD(mfx->deviceprofile, deviceprofile);
3045 ret = __ps_process_deviceprofile(reader, deviceprofile);
3046 } else if (!strcmp(ASCII(node), "compatibility")) {
3047 compatibility_x *compatibility = malloc(sizeof(compatibility_x));
3048 if (compatibility == NULL) {
3049 DBG("Malloc Failed\n");
3052 memset(compatibility, '\0', sizeof(compatibility_x));
3053 LISTADD(mfx->compatibility, compatibility);
3054 ret = __ps_process_compatibility(reader, compatibility);
3055 } else if (!strcmp(ASCII(node), "shortcut-list")) {
3057 } else if (!strcmp(ASCII(node), "livebox")) {
3059 } else if (!strcmp(ASCII(node), "account")) {
3061 } else if (!strcmp(ASCII(node), "notifications")) {
3063 } else if (!strcmp(ASCII(node), "privileges")) {
3065 } else if (!strcmp(ASCII(node), "ime")) {
3071 DBG("Processing manifest failed\n");
3076 LISTHEAD(mfx->label, tmp1);
3080 LISTHEAD(mfx->author, tmp2);
3083 if (mfx->description) {
3084 LISTHEAD(mfx->description, tmp3);
3085 mfx->description= tmp3;
3088 LISTHEAD(mfx->license, tmp4);
3091 if (mfx->uiapplication) {
3092 LISTHEAD(mfx->uiapplication, tmp5);
3093 mfx->uiapplication = tmp5;
3095 if (mfx->serviceapplication) {
3096 LISTHEAD(mfx->serviceapplication, tmp6);
3097 mfx->serviceapplication = tmp6;
3100 LISTHEAD(mfx->daemon, tmp7);
3104 LISTHEAD(mfx->theme, tmp8);
3108 LISTHEAD(mfx->font, tmp9);
3112 LISTHEAD(mfx->ime, tmp10);
3116 LISTHEAD(mfx->icon, tmp11);
3119 if (mfx->compatibility) {
3120 LISTHEAD(mfx->compatibility, tmp12);
3121 mfx->compatibility= tmp12;
3123 if (mfx->deviceprofile) {
3124 LISTHEAD(mfx->deviceprofile, tmp13);
3125 mfx->deviceprofile= tmp13;
3131 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx)
3133 const xmlChar *node;
3136 if ((ret = __next_child_element(reader, -1))) {
3137 node = xmlTextReaderConstName(reader);
3139 DBG("xmlTextReaderConstName value is NULL\n");
3143 if (!strcmp(ASCII(node), "manifest")) {
3144 if (xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")))
3145 mfx->ns = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")));
3146 if (xmlTextReaderGetAttribute(reader, XMLCHAR("package"))) {
3147 mfx->package= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("package")));
3148 if (mfx->package == NULL) {
3149 DBG("package cant be NULL\n");
3153 DBG("package field is mandatory\n");
3156 package = mfx->package;
3157 if (xmlTextReaderGetAttribute(reader, XMLCHAR("version")))
3158 mfx->version= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("version")));
3159 /*app2ext needs package size for external installation*/
3160 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
3161 mfx->package_size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
3162 if (xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")))
3163 mfx->installlocation = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")));
3164 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
3165 mfx->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
3166 if (xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")))
3167 mfx->root_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")));
3168 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting"))) {
3169 mfx->appsetting = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting")));
3170 if (mfx->appsetting == NULL)
3171 mfx->appsetting = strdup("false");
3173 mfx->appsetting = strdup("false");
3176 /*Assign default values. If required it will be overwritten in __add_preload_info()*/
3177 mfx->preload = strdup("False");
3178 mfx->removable = strdup("True");
3179 mfx->readonly = strdup("False");
3180 char buf[PKG_STRING_LEN_MAX] = {'\0'};
3182 time_t current_time;
3183 time(¤t_time);
3184 snprintf(buf, PKG_STRING_LEN_MAX - 1, "%d", current_time);
3185 val = strndup(buf, PKG_STRING_LEN_MAX - 1);
3186 mfx->installed_time = val;
3188 mfx->installed_storage= strdup("installed_internal");
3190 ret = __start_process(reader, mfx);
3192 DBG("No Manifest element found\n");
3199 #define DESKTOP_RW_PATH "/opt/share/applications/"
3200 #define DESKTOP_RO_PATH "/usr/share/applications/"
3202 static char* __convert_to_system_locale(const char *mlocale)
3204 if (mlocale == NULL)
3206 char *locale = NULL;
3207 locale = (char *)calloc(1, 6);
3209 DBGE("Malloc Failed\n");
3213 strncpy(locale, mlocale, 2);
3214 strncat(locale, "_", 1);
3215 locale[3] = toupper(mlocale[3]);
3216 locale[4] = toupper(mlocale[4]);
3220 #define LIBAIL_PATH "/usr/lib/libail.so.0"
3222 /* operation_type */
3230 static int __ail_change_info(int op, const char *appid)
3232 void *lib_handle = NULL;
3233 int (*ail_desktop_operation) (const char *);
3237 if ((lib_handle = dlopen(LIBAIL_PATH, RTLD_LAZY)) == NULL) {
3238 DBGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAIL_PATH);
3245 aop = "ail_desktop_add";
3248 aop = "ail_desktop_update";
3251 aop = "ail_desktop_remove";
3258 if ((ail_desktop_operation =
3259 dlsym(lib_handle, aop)) == NULL || dlerror() != NULL) {
3260 DBGE("can not find symbol \n");
3264 ret = ail_desktop_operation(appid);
3268 dlclose(lib_handle);
3274 /* desktop shoud be generated automatically based on manifest */
3275 /* Currently removable, taskmanage, etc fields are not considerd. it will be decided soon.*/
3276 #define BUFMAX 1024*128
3277 static int __ps_make_nativeapp_desktop(manifest_x * mfx, bool is_update)
3281 char filepath[PKG_STRING_LEN_MAX] = "";
3283 char *buftemp = NULL;
3284 char *locale = NULL;
3286 buf = (char *)calloc(1, BUFMAX);
3288 DBGE("Malloc Failed\n");
3292 buftemp = (char *)calloc(1, BUFMAX);
3294 DBGE("Malloc Failed\n");
3299 for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) {
3301 if(mfx->readonly && !strcasecmp(mfx->readonly, "True"))
3302 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RO_PATH, mfx->uiapplication->appid);
3304 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, mfx->uiapplication->appid);
3306 /* skip if desktop exists
3307 if (access(filepath, R_OK) == 0)
3311 file = fopen(filepath, "w");
3314 DBGE("Can't open %s", filepath);
3320 snprintf(buf, BUFMAX, "[Desktop Entry]\n");
3321 fwrite(buf, 1, strlen(buf), file);
3323 for( ; mfx->uiapplication->label ; mfx->uiapplication->label = mfx->uiapplication->label->next) {
3324 if(!strcmp(mfx->uiapplication->label->lang, DEFAULT_LOCALE)) {
3325 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
3327 locale = __convert_to_system_locale(mfx->uiapplication->label->lang);
3328 snprintf(buf, BUFMAX, "Name[%s]=%s\n", locale,
3329 mfx->uiapplication->label->text);
3332 fwrite(buf, 1, strlen(buf), file);
3335 if(mfx->uiapplication->label && mfx->uiapplication->label->text) {
3336 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
3337 fwrite(buf, 1, strlen(buf), file);
3340 else if(mfx->label && mfx->label->text) {
3341 snprintf(buf, BUFMAX, "Name=%s\n", mfx->label->text);
3342 fwrite(buf, 1, strlen(buf), file);
3344 snprintf(buf, BUFMAX, "Name=%s\n", mfx->package);
3345 fwrite(buf, 1, strlen(buf), file);
3350 snprintf(buf, BUFMAX, "Type=Application\n");
3351 fwrite(buf, 1, strlen(buf), file);
3353 if(mfx->uiapplication->exec) {
3354 snprintf(buf, BUFMAX, "Exec=%s\n", mfx->uiapplication->exec);
3355 fwrite(buf, 1, strlen(buf), file);
3358 if(mfx->uiapplication->icon && mfx->uiapplication->icon->text) {
3359 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->uiapplication->icon->text);
3360 fwrite(buf, 1, strlen(buf), file);
3361 } else if(mfx->icon && mfx->icon->text) {
3362 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->icon->text);
3363 fwrite(buf, 1, strlen(buf), file);
3367 snprintf(buf, BUFMAX, "Version=%s\n", mfx->version);
3368 fwrite(buf, 1, strlen(buf), file);
3371 if(mfx->uiapplication->nodisplay) {
3372 snprintf(buf, BUFMAX, "NoDisplay=%s\n", mfx->uiapplication->nodisplay);
3373 fwrite(buf, 1, strlen(buf), file);
3376 if(mfx->uiapplication->categories) {
3377 snprintf(buf, BUFMAX, "Categories=%s\n", mfx->uiapplication->categories);
3378 fwrite(buf, 1, strlen(buf), file);
3381 if(mfx->uiapplication->taskmanage && !strcasecmp(mfx->uiapplication->taskmanage, "False")) {
3382 snprintf(buf, BUFMAX, "X-TIZEN-TaskManage=False\n");
3383 fwrite(buf, 1, strlen(buf), file);
3386 if(mfx->uiapplication->enabled && !strcasecmp(mfx->uiapplication->enabled, "False")) {
3387 snprintf(buf, BUFMAX, "X-TIZEN-Enabled=False\n");
3388 fwrite(buf, 1, strlen(buf), file);
3391 if(mfx->uiapplication->hwacceleration) {
3392 snprintf(buf, BUFMAX, "Hw-Acceleration=%s\n", mfx->uiapplication->hwacceleration);
3393 fwrite(buf, 1, strlen(buf), file);
3396 if(mfx->uiapplication->multiple && !strcasecmp(mfx->uiapplication->multiple, "True")) {
3397 snprintf(buf, BUFMAX, "X-TIZEN-Multiple=True\n");
3398 fwrite(buf, 1, strlen(buf), file);
3401 if(mfx->uiapplication->extraid) {
3402 snprintf(buf, BUFMAX, "X-TIZEN-PackageID=%s\n", mfx->uiapplication->extraid);
3403 fwrite(buf, 1, strlen(buf), file);
3406 if(mfx->removable && !strcasecmp(mfx->removable, "False")) {
3407 snprintf(buf, BUFMAX, "X-TIZEN-Removable=False\n");
3408 fwrite(buf, 1, strlen(buf), file);
3412 snprintf(buf, BUFMAX, "X-TIZEN-PackageType=%s\n", mfx->type);
3413 fwrite(buf, 1, strlen(buf), file);
3416 snprintf(buf, BUFMAX, "X-TIZEN-PkgID=%s\n", mfx->package);
3417 fwrite(buf, 1, strlen(buf), file);
3420 // snprintf(buf, BUFMAX, "X-TIZEN-PackageType=rpm\n");
3421 // fwrite(buf, 1, strlen(buf), file);
3424 if(mfx->uiapplication->appsvc) {
3425 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
3426 DBG("buf[%s]\n", buf);
3429 uiapplication_x *up = mfx->uiapplication;
3430 appsvc_x *asvc = NULL;
3431 operation_x *op = NULL;
3434 subapp_x *sub = NULL;
3435 char *operation = NULL;
3438 char *subapp = NULL;
3445 op = asvc->operation;
3449 operation = op->name;
3468 strncpy(buftemp, buf, BUFMAX);
3469 snprintf(buf, BUFMAX, "%s;", buftemp);
3473 strncpy(buftemp, buf, BUFMAX);
3474 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
3475 DBG("buf[%s]\n", buf);
3480 } while(ui != NULL);
3484 }while(sub != NULL);
3497 fwrite(buf, 1, strlen(buf), file);
3499 // strncpy(buftemp, buf, BUFMAX);
3500 // snprintf(buf, BUFMAX, "%s\n", buftemp);
3501 // fwrite(buf, 1, strlen(buf), file);
3504 if(mfx->uiapplication->appcontrol) {
3505 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
3506 DBG("buf[%s]\n", buf);
3508 uiapplication_x *up = mfx->uiapplication;
3509 appcontrol_x *acontrol = NULL;
3510 operation_x *op = NULL;
3513 subapp_x *sub = NULL;
3514 char *operation = NULL;
3517 char *subapp = NULL;
3520 acontrol = up->appcontrol;
3521 while(acontrol != NULL)
3523 op = acontrol->operation;
3527 operation = op->name;
3528 mi = acontrol->mime;
3534 sub = acontrol->subapp;
3546 strncpy(buftemp, buf, BUFMAX);
3547 snprintf(buf, BUFMAX, "%s;", buftemp);
3550 strncpy(buftemp, buf, BUFMAX);
3551 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
3552 DBG("buf[%s]\n", buf);
3557 } while(ui != NULL);
3561 }while(sub != NULL);
3570 acontrol = acontrol->next;
3574 fwrite(buf, 1, strlen(buf), file);
3576 // strncpy(buftemp, buf, BUFMAX);
3577 // snprintf(buf, BUFMAX, "%s\n", buftemp);
3578 // fwrite(buf, 1, strlen(buf), file);
3587 __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid);
3589 __ail_change_info(AIL_UPDATE, mfx->uiapplication->appid);
3598 static int __ps_remove_nativeapp_desktop(manifest_x *mfx)
3600 char filepath[PKG_STRING_LEN_MAX] = "";
3603 for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) {
3604 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, mfx->uiapplication->appid);
3606 __ail_change_info(AIL_REMOVE, mfx->uiapplication->appid);
3608 ret = remove(filepath);
3616 #define MANIFEST_RO_PREFIX "/usr/share/packages/"
3617 #define PRELOAD_PACKAGE_LIST "/usr/etc/package-manager/preload/preload_list.txt"
3618 static int __add_preload_info(manifest_x * mfx, const char *manifest)
3621 char buffer[1024] = { 0 };
3624 if(strstr(manifest, MANIFEST_RO_PREFIX)) {
3625 free(mfx->readonly);
3626 mfx->readonly = strdup("True");
3629 mfx->preload = strdup("True");
3631 free(mfx->removable);
3632 mfx->removable = strdup("False");
3637 fp = fopen(PRELOAD_PACKAGE_LIST, "r");
3639 DBGE("no preload list\n");
3643 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
3644 if (buffer[0] == '#') {
3645 if(strcasestr(buffer, "RW_NORM"))
3647 else if(strcasestr(buffer, "RW_RM"))
3655 if(!strcmp(mfx->package, buffer)) {
3657 mfx->preload = strdup("True");
3659 free(mfx->readonly);
3660 mfx->readonly = strdup("False");
3661 free(mfx->removable);
3662 mfx->removable = strdup("False");
3663 } else if(state == 3){
3664 free(mfx->readonly);
3665 mfx->readonly = strdup("False");
3666 free(mfx->removable);
3667 mfx->removable = strdup("True");
3671 memset(buffer, 0x00, sizeof(buffer));
3681 API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
3686 free((void *)mfx->ns);
3690 free((void *)mfx->package);
3691 mfx->package = NULL;
3694 free((void *)mfx->version);
3695 mfx->version = NULL;
3697 if (mfx->installlocation) {
3698 free((void *)mfx->installlocation);
3699 mfx->installlocation = NULL;
3702 free((void *)mfx->preload);
3703 mfx->preload = NULL;
3705 if (mfx->readonly) {
3706 free((void *)mfx->readonly);
3707 mfx->readonly = NULL;
3709 if (mfx->removable) {
3710 free((void *)mfx->removable);
3711 mfx->removable = NULL;
3714 free((void *)mfx->update);
3718 free((void *)mfx->type);
3721 if (mfx->package_size) {
3722 free((void *)mfx->package_size);
3723 mfx->package_size = NULL;
3725 if (mfx->installed_time) {
3726 free((void *)mfx->installed_time);
3727 mfx->installed_time = NULL;
3729 if (mfx->installed_storage) {
3730 free((void *)mfx->installed_storage);
3731 mfx->installed_storage = NULL;
3733 if (mfx->storeclient_id) {
3734 free((void *)mfx->storeclient_id);
3735 mfx->storeclient_id = NULL;
3737 if (mfx->mainapp_id) {
3738 free((void *)mfx->mainapp_id);
3739 mfx->mainapp_id = NULL;
3741 if (mfx->package_url) {
3742 free((void *)mfx->package_url);
3743 mfx->package_url = NULL;
3745 if (mfx->root_path) {
3746 free((void *)mfx->root_path);
3747 mfx->root_path = NULL;
3749 if (mfx->appsetting) {
3750 free((void *)mfx->appsetting);
3751 mfx->appsetting = NULL;
3756 icon_x *icon = mfx->icon;
3761 __ps_free_icon(icon);
3767 label_x *label = mfx->label;
3768 label_x *tmp = NULL;
3769 while(label != NULL)
3772 __ps_free_label(label);
3778 author_x *author = mfx->author;
3779 author_x *tmp = NULL;
3780 while(author != NULL)
3783 __ps_free_author(author);
3787 /*Free Description*/
3788 if (mfx->description) {
3789 description_x *description = mfx->description;
3790 description_x *tmp = NULL;
3791 while(description != NULL)
3793 tmp = description->next;
3794 __ps_free_description(description);
3800 license_x *license = mfx->license;
3801 license_x *tmp = NULL;
3802 while(license != NULL)
3804 tmp = license->next;
3805 __ps_free_license(license);
3809 /*Free UiApplication*/
3810 if (mfx->uiapplication) {
3811 uiapplication_x *uiapplication = mfx->uiapplication;
3812 uiapplication_x *tmp = NULL;
3813 while(uiapplication != NULL)
3815 tmp = uiapplication->next;
3816 __ps_free_uiapplication(uiapplication);
3817 uiapplication = tmp;
3820 /*Free ServiceApplication*/
3821 if (mfx->serviceapplication) {
3822 serviceapplication_x *serviceapplication = mfx->serviceapplication;
3823 serviceapplication_x *tmp = NULL;
3824 while(serviceapplication != NULL)
3826 tmp = serviceapplication->next;
3827 __ps_free_serviceapplication(serviceapplication);
3828 serviceapplication = tmp;
3833 daemon_x *daemon = mfx->daemon;
3834 daemon_x *tmp = NULL;
3835 while(daemon != NULL)
3838 __ps_free_daemon(daemon);
3844 theme_x *theme = mfx->theme;
3845 theme_x *tmp = NULL;
3846 while(theme != NULL)
3849 __ps_free_theme(theme);
3855 font_x *font = mfx->font;
3860 __ps_free_font(font);
3866 ime_x *ime = mfx->ime;
3875 /*Free Compatibility*/
3876 if (mfx->compatibility) {
3877 compatibility_x *compatibility = mfx->compatibility;
3878 compatibility_x *tmp = NULL;
3879 while(compatibility != NULL)
3881 tmp = compatibility->next;
3882 __ps_free_compatibility(compatibility);
3883 compatibility = tmp;
3886 /*Free DeviceProfile*/
3887 if (mfx->deviceprofile) {
3888 deviceprofile_x *deviceprofile = mfx->deviceprofile;
3889 deviceprofile_x *tmp = NULL;
3890 while(deviceprofile != NULL)
3892 tmp = deviceprofile->next;
3893 __ps_free_deviceprofile(deviceprofile);
3894 deviceprofile = tmp;
3902 API manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest)
3904 DBG("parsing start\n");
3905 xmlTextReaderPtr reader;
3906 manifest_x *mfx = NULL;
3908 reader = xmlReaderForFile(manifest, NULL, 0);
3910 mfx = malloc(sizeof(manifest_x));
3912 memset(mfx, '\0', sizeof(manifest_x));
3913 if (__process_manifest(reader, mfx) < 0) {
3914 DBG("Parsing Failed\n");
3915 pkgmgr_parser_free_manifest_xml(mfx);
3918 DBG("Parsing Success\n");
3920 DBG("Memory allocation error\n");
3922 xmlFreeTextReader(reader);
3924 DBG("Unable to create xml reader\n");
3929 /* These APIs are intended to call parser directly */
3931 API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
3933 char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", NULL};
3934 if (manifest == NULL) {
3935 DBG("argument supplied is NULL\n");
3936 return PMINFO_R_EINVAL;
3938 DBG("parsing manifest for installation: %s\n", manifest);
3939 manifest_x *mfx = NULL;
3941 char roxml_check[PKG_STRING_LEN_MAX] = {'\0'};
3944 mfx = pkgmgr_parser_process_manifest_xml(manifest);
3945 DBG("Parsing Finished\n");
3947 return PMINFO_R_ERROR;
3949 __streamFile(manifest, ACTION_INSTALL, temp, mfx->package);
3950 __add_preload_info(mfx, manifest);
3951 DBG("Added preload infomation\n");
3953 snprintf(roxml_check, PKG_STRING_LEN_MAX, MANIFEST_RO_DIRECTORY "/%s.xml", mfx->package);
3954 if (access(roxml_check, F_OK) == 0)
3955 mfx->update = strdup("true");
3957 mfx->update = strdup("false");
3959 ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
3961 DBG("DB Insert failed\n");
3963 DBG("DB Insert Success\n");
3965 ret = __ps_make_nativeapp_desktop(mfx, 0);
3967 DBG("Creating desktop file failed\n");
3969 DBG("Creating desktop file Success\n");
3971 pkgmgr_parser_free_manifest_xml(mfx);
3978 API int pkgmgr_parser_create_desktop_file(manifest_x *mfx)
3982 DBG("Manifest pointer is NULL\n");
3985 ret = __ps_make_nativeapp_desktop(mfx, 0);
3987 DBG("Creating desktop file failed\n");
3989 DBG("Creating desktop file Success\n");
3994 API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
3996 char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", NULL};
3997 if (manifest == NULL) {
3998 DBG("argument supplied is NULL\n");
3999 return PMINFO_R_EINVAL;
4001 DBG("parsing manifest for upgradation: %s\n", manifest);
4002 manifest_x *mfx = NULL;
4005 mfx = pkgmgr_parser_process_manifest_xml(manifest);
4006 DBG("Parsing Finished\n");
4008 return PMINFO_R_ERROR;
4010 __streamFile(manifest, ACTION_UPGRADE, temp, mfx->package);
4011 __add_preload_info(mfx, manifest);
4012 DBG("Added preload infomation\n");
4014 mfx->update = strdup("true");
4015 ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
4017 DBG("DB Update failed\n");
4019 DBG("DB Update Success\n");
4021 ret = __ps_make_nativeapp_desktop(mfx, 1);
4023 DBG("Creating desktop file failed\n");
4025 DBG("Creating desktop file Success\n");
4027 pkgmgr_parser_free_manifest_xml(mfx);
4034 API int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[])
4036 char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", NULL};
4037 if (manifest == NULL) {
4038 DBG("argument supplied is NULL\n");
4039 return PMINFO_R_EINVAL;
4041 DBG("parsing manifest for uninstallation: %s\n", manifest);
4042 manifest_x *mfx = NULL;
4045 mfx = pkgmgr_parser_process_manifest_xml(manifest);
4046 DBG("Parsing Finished\n");
4048 return PMINFO_R_ERROR;
4050 __streamFile(manifest, ACTION_UNINSTALL, temp, mfx->package);
4051 __add_preload_info(mfx, manifest);
4052 DBG("Added preload infomation\n");
4054 ret = pkgmgr_parser_delete_manifest_info_from_db(mfx);
4056 DBG("DB Delete failed\n");
4058 DBG("DB Delete Success\n");
4060 ret = __ps_remove_nativeapp_desktop(mfx);
4062 DBG("Removing desktop file failed\n");
4064 DBG("Removing desktop file Success\n");
4066 pkgmgr_parser_free_manifest_xml(mfx);
4073 API char *pkgmgr_parser_get_manifest_file(const char *pkgid)
4075 return __pkgid_to_manifest(pkgid);
4078 API int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
4080 return __ps_run_parser(docPtr, tag, ACTION_INSTALL, pkgid);
4083 API int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgid)
4085 return __ps_run_parser(docPtr, tag, ACTION_UPGRADE, pkgid);
4088 API int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
4090 return __ps_run_parser(docPtr, tag, ACTION_UNINSTALL, pkgid);
4093 #define SCHEMA_FILE "/usr/etc/package-manager/preload/manifest.xsd"
4095 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
4097 if (manifest == NULL) {
4098 DBGE("manifest file is NULL\n");
4099 return PMINFO_R_EINVAL;
4102 xmlSchemaParserCtxtPtr ctx;
4103 xmlSchemaValidCtxtPtr vctx;
4104 xmlSchemaPtr xschema;
4105 ctx = xmlSchemaNewParserCtxt(SCHEMA_FILE);
4107 DBGE("xmlSchemaNewParserCtxt() Failed\n");
4108 return PMINFO_R_ERROR;
4110 xschema = xmlSchemaParse(ctx);
4111 if (xschema == NULL) {
4112 DBGE("xmlSchemaParse() Failed\n");
4113 return PMINFO_R_ERROR;
4115 vctx = xmlSchemaNewValidCtxt(xschema);
4117 DBGE("xmlSchemaNewValidCtxt() Failed\n");
4118 return PMINFO_R_ERROR;
4120 xmlSchemaSetValidErrors(vctx, (xmlSchemaValidityErrorFunc) fprintf, (xmlSchemaValidityWarningFunc) fprintf, stderr);
4121 ret = xmlSchemaValidateFile(vctx, manifest, 0);
4123 DBGE("xmlSchemaValidateFile() failed\n");
4124 return PMINFO_R_ERROR;
4125 } else if (ret == 0) {
4126 DBGE("Manifest is Valid\n");
4129 DBGE("Manifest Validation Failed with error code %d\n", ret);
4130 return PMINFO_R_ERROR;
4136 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
4146 DBGE("fork failed\n");
4151 int dev_null_fd = open ("/dev/null", O_RDWR);
4152 if (dev_null_fd >= 0)
4154 dup2 (dev_null_fd, 0);/*stdin*/
4155 dup2 (dev_null_fd, 1);/*stdout*/
4156 dup2 (dev_null_fd, 2);/*stderr*/
4159 if (execl("/usr/bin/xmllint", "xmllint", manifest, "--schema",
4160 SCHEMA_FILE, NULL) < 0) {
4161 DBGE("execl error\n");
4171 while ((err = waitpid(pid, &status, WNOHANG)) != pid) {
4175 DBGE("waitpid failed\n");
4181 if(WIFEXITED(status) && !WEXITSTATUS(status))