4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
7 * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
31 #include <libxml/parser.h>
32 #include <libxml/xmlreader.h>
33 #include <libxml/xmlschemas.h>
37 #include "pkgmgr_parser.h"
38 #include "pkgmgr_parser_internal.h"
39 #include "pkgmgr_parser_db.h"
40 #include "pkgmgr-info.h"
42 #define MANIFEST_RW_DIRECTORY "/opt/share/packages"
43 #define MANIFEST_RO_DIRECTORY "/usr/share/packages"
44 #define ASCII(s) (const char *)s
45 #define XMLCHAR(s) (const xmlChar *)s
47 #define MDPARSER_LIST "/usr/etc/package-manager/parserlib/metadata/mdparser_list.txt"
48 #define MDPARSER_NAME "mdparser:"
65 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label);
66 static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege);
67 static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privileges);
68 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile);
69 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed);
70 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation);
71 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri);
72 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime);
73 static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp);
74 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition);
75 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notifiation);
76 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category);
77 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata);
78 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission);
79 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility);
80 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution);
81 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request);
82 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define);
83 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc);
84 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions);
85 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare);
86 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon);
87 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author);
88 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description);
89 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability);
90 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license);
91 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol);
92 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol);
93 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication);
94 static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication);
95 static int __ps_process_font(xmlTextReaderPtr reader, font_x *font);
96 static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme);
97 static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon);
98 static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime);
99 static void __ps_free_label(label_x *label);
100 static void __ps_free_privilege(privilege_x *privilege);
101 static void __ps_free_privileges(privileges_x *privileges);
102 static void __ps_free_deviceprofile(deviceprofile_x * deviceprofile);
103 static void __ps_free_allowed(allowed_x *allowed);
104 static void __ps_free_operation(operation_x *operation);
105 static void __ps_free_uri(uri_x *uri);
106 static void __ps_free_mime(mime_x *mime);
107 static void __ps_free_subapp(subapp_x *subapp);
108 static void __ps_free_condition(condition_x *condition);
109 static void __ps_free_notification(notification_x *notifiation);
110 static void __ps_free_category(category_x *category);
111 static void __ps_free_metadata(metadata_x *metadata);
112 static void __ps_free_permission(permission_x *permission);
113 static void __ps_free_compatibility(compatibility_x *compatibility);
114 static void __ps_free_resolution(resolution_x *resolution);
115 static void __ps_free_request(request_x *request);
116 static void __ps_free_define(define_x *define);
117 static void __ps_free_appsvc(appsvc_x *appsvc);
118 static void __ps_free_launchconditions(launchconditions_x *launchconditions);
119 static void __ps_free_datashare(datashare_x *datashare);
120 static void __ps_free_icon(icon_x *icon);
121 static void __ps_free_author(author_x *author);
122 static void __ps_free_description(description_x *description);
123 static void __ps_free_capability(capability_x *capability);
124 static void __ps_free_license(license_x *license);
125 static void __ps_free_appcontrol(appcontrol_x *appcontrol);
126 static void __ps_free_datacontrol(datacontrol_x *datacontrol);
127 static void __ps_free_uiapplication(uiapplication_x *uiapplication);
128 static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication);
129 static void __ps_free_font(font_x *font);
130 static void __ps_free_theme(theme_x *theme);
131 static void __ps_free_daemon(daemon_x *daemon);
132 static void __ps_free_ime(ime_x *ime);
133 static char *__pkgid_to_manifest(const char *pkgid);
134 static int __next_child_element(xmlTextReaderPtr reader, int depth);
135 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx);
136 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx);
137 static void __str_trim(char *input);
138 static char *__get_parser_plugin(const char *type);
139 static int __ps_run_parser(xmlDocPtr docPtr, const char *tag, ACTION_TYPE action, const char *pkgid);
140 static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid);
141 static void __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgid);
142 static void __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid);
143 static int __validate_appid(const char *pkgid, const char *appid, char **newappid);
145 static void __str_trim(char *input)
147 char *trim_str = input;
152 while (*input != 0) {
153 if (!isspace(*input)) {
164 static int __validate_appid(const char *pkgid, const char *appid, char **newappid)
166 if (!pkgid || !appid || !newappid) {
167 DBG("Arg supplied is NULL\n");
170 int pkglen = strlen(pkgid);
171 int applen = strlen(appid);
175 if (strncmp(appid, ".", 1) == 0) {
176 len = pkglen + applen + 1;
177 newapp = calloc(1,len);
178 if (newapp == NULL) {
179 DBG("Malloc failed\n");
182 strncpy(newapp, pkgid, pkglen);
183 strncat(newapp, appid, applen);
184 DBG("new appid is %s\n", newapp);
188 if (applen < pkglen) {
189 DBG("app id is not proper\n");
191 #ifdef _VALIDATE_APPID_
197 if (!strcmp(appid, pkgid)) {
198 DBG("appid is proper\n");
202 else if (strncmp(appid, pkgid, pkglen) == 0) {
203 ptr = strstr(appid, pkgid);
205 if (strncmp(ptr, ".", 1) == 0) {
206 DBG("appid is proper\n");
211 DBG("appid is not proper\n");
213 #ifdef _VALIDATE_APPID_
220 DBG("appid is not proper\n");
222 #ifdef _VALIDATE_APPID_
231 static char * __get_tag_by_key(char *md_key)
235 if (md_key == NULL) {
236 DBG("md_key is NULL\n");
240 md_tag = strrchr(md_key, 47) + 1;
243 return strdup(md_tag);
246 static char *__get_mdparser_plugin(const char *type)
249 char buffer[1024] = { 0 };
250 char temp_path[1024] = { 0 };
254 DBGE("invalid argument\n");
258 fp = fopen(PKG_PARSER_CONF_PATH, "r");
260 DBGE("no matching mdparser\n");
264 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
265 if (buffer[0] == '#')
270 if ((path = strstr(buffer, MDPARSER_NAME)) != NULL) {
271 path = path + strlen(MDPARSER_NAME);
276 memset(buffer, 0x00, 1024);
283 DBGE("no matching backendlib\n");
287 snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
289 return strdup(temp_path);
292 static char *__get_parser_plugin(const char *type)
295 char buffer[1024] = { 0 };
296 char temp_path[1024] = { 0 };
300 DBGE("invalid argument\n");
304 fp = fopen(PKG_PARSER_CONF_PATH, "r");
306 DBGE("no matching backendlib\n");
310 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
311 if (buffer[0] == '#')
316 if ((path = strstr(buffer, PKG_PARSERLIB)) != NULL) {
318 path = path + strlen(PKG_PARSERLIB);
324 memset(buffer, 0x00, 1024);
331 DBGE("no matching backendlib\n");
335 snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
336 DBG("[%s]\n", temp_path);
338 return strdup(temp_path);
341 static int __ps_run_mdparser(GList *md_list, const char *tag,
342 ACTION_TYPE action, const char *pkgid, const char *appid)
344 char *lib_path = NULL;
345 void *lib_handle = NULL;
346 int (*mdparser_plugin) (const char *, const char *, GList *);
352 ac = "PKGMGR_MDPARSER_PLUGIN_INSTALL";
355 ac = "PKGMGR_MDPARSER_PLUGIN_UPGRADE";
357 case ACTION_UNINSTALL:
358 ac = "PKGMGR_MDPARSER_PLUGIN_UNINSTALL";
364 lib_path = __get_mdparser_plugin(tag);
366 DBGE("__get_mdparser_plugin fail\n");
370 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
371 DBGE("dlopen is failed lib_path[%s]\n", lib_path);
375 if ((mdparser_plugin =
376 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
377 DBGE("can not find symbol \n");
381 ret = mdparser_plugin(pkgid, appid, md_list);
383 DBGE("[appid = %s, libpath = %s] plugin fail\n", appid, lib_path);
385 DBGE("[appid = %s, libpath = %s] plugin success\n", appid, lib_path);
395 static int __ps_run_parser(xmlDocPtr docPtr, const char *tag,
396 ACTION_TYPE action, const char *pkgid)
398 char *lib_path = NULL;
399 void *lib_handle = NULL;
400 int (*plugin_install) (xmlDocPtr, const char *);
406 ac = "PKGMGR_PARSER_PLUGIN_INSTALL";
409 ac = "PKGMGR_PARSER_PLUGIN_UPGRADE";
411 case ACTION_UNINSTALL:
412 ac = "PKGMGR_PARSER_PLUGIN_UNINSTALL";
418 lib_path = __get_parser_plugin(tag);
423 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
424 DBGE("dlopen is failed lib_path[%s]\n", lib_path);
427 if ((plugin_install =
428 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
429 DBGE("can not find symbol \n");
433 ret = plugin_install(docPtr, pkgid);
443 static char *__pkgid_to_manifest(const char *pkgid)
449 DBGE("pkgid is NULL");
453 size = strlen(MANIFEST_RW_DIRECTORY) + strlen(pkgid) + 10;
454 manifest = malloc(size);
455 if (manifest == NULL) {
459 memset(manifest, '\0', size);
460 snprintf(manifest, size, MANIFEST_RW_DIRECTORY "/%s.xml", pkgid);
462 if (access(manifest, F_OK)) {
463 snprintf(manifest, size, MANIFEST_RO_DIRECTORY "/%s.xml", pkgid);
469 static void __mdparser_clear_dir_list(GList* dir_list)
472 __metadata_t* detail = NULL;
475 list = g_list_first(dir_list);
477 detail = (__metadata_t *)list->data;
485 list = g_list_next(list);
487 g_list_free(dir_list);
491 static int __run_mdparser_prestep (manifest_x *mfx, char *md_key, ACTION_TYPE action)
495 char buffer[1024] = { 0, };
496 uiapplication_x *up = mfx->uiapplication;
497 metadata_x *md = NULL;
500 GList *md_list = NULL;
501 __metadata_t *md_detail = NULL;
503 md_tag = __get_tag_by_key(md_key);
504 if (md_tag == NULL) {
505 DBG("md_tag is NULL\n");
508 DBG("md_tag = %s\n", md_tag);
515 //get glist of meatdata key and value combination
516 memset(buffer, 0x00, 1024);
517 snprintf(buffer, 1024, "%s/", md_key);
518 if ((md->key && md->value) && (strncmp(md->key, md_key, strlen(md_key)) == 0) && (strncmp(buffer, md->key, strlen(buffer)) == 0)) {
519 md_detail = (__metadata_t*) calloc(1, sizeof(__metadata_t));
520 if (md_detail == NULL) {
521 DBG("Memory allocation failed\n");
525 md_detail->key = (char*) calloc(1, sizeof(char)*(strlen(md->key)+2));
526 if (md_detail->key == NULL) {
527 DBG("Memory allocation failed\n");
531 snprintf(md_detail->key, (strlen(md->key)+1), "%s", md->key);
533 md_detail->value = (char*) calloc(1, sizeof(char)*(strlen(md->value)+2));
534 if (md_detail->value == NULL) {
535 DBG("Memory allocation failed\n");
536 free(md_detail->key);
540 snprintf(md_detail->value, (strlen(md->value)+1), "%s", md->value);
542 md_list = g_list_append(md_list, (gpointer)md_detail);
548 //send glist to parser when tags for metadata plugin parser exist.
550 ret = __ps_run_mdparser(md_list, md_tag, action, mfx->package, up->appid);
552 DBG("mdparser failed[%d]\n", ret);
554 DBG("mdparser success, done[%d]\n", ret);
556 __mdparser_clear_dir_list(md_list);
564 __mdparser_clear_dir_list(md_list);
572 static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid)
577 DBG("__run_parser_prestep");
579 if (xmlTextReaderDepth(reader) != 1) {
580 DBGE("Node depth is not 1");
584 if (xmlTextReaderNodeType(reader) != 1) {
585 DBGE("Node type is not 1");
589 const xmlChar *value;
590 name = xmlTextReaderConstName(reader);
592 DBGE("TEST TEST TES\n");
593 name = BAD_CAST "--";
596 value = xmlTextReaderConstValue(reader);
597 DBG("%d %d %s %d %d",
598 xmlTextReaderDepth(reader),
599 xmlTextReaderNodeType(reader),
601 xmlTextReaderIsEmptyElement(reader), xmlTextReaderHasValue(reader));
604 DBG("ConstValue NULL");
606 if (xmlStrlen(value) > 40) {
607 DBG(" %.40s...", value);
613 name = xmlTextReaderConstName(reader);
615 DBGE("TEST TEST TES\n");
616 name = BAD_CAST "--";
619 xmlDocPtr docPtr = xmlTextReaderCurrentDoc(reader);
620 DBG("docPtr->URL %s\n", (char *)docPtr->URL);
621 xmlDocPtr copyDocPtr = xmlCopyDoc(docPtr, 1);
622 if (copyDocPtr == NULL)
624 xmlNode *rootElement = xmlDocGetRootElement(copyDocPtr);
625 if (rootElement == NULL)
627 xmlNode *cur_node = xmlFirstElementChild(rootElement);
628 if (cur_node == NULL)
630 xmlNode *temp = xmlTextReaderExpand(reader);
633 xmlNode *next_node = NULL;
634 while(cur_node != NULL) {
635 if ( (strcmp(ASCII(temp->name), ASCII(cur_node->name)) == 0) &&
636 (temp->line == cur_node->line) ) {
640 next_node = xmlNextElementSibling(cur_node);
641 xmlUnlinkNode(cur_node);
642 xmlFreeNode(cur_node);
643 cur_node = next_node;
646 if (cur_node == NULL)
648 next_node = xmlNextElementSibling(cur_node);
650 cur_node->next = NULL;
651 next_node->prev = NULL;
652 xmlFreeNodeList(next_node);
653 xmlSetTreeDoc(cur_node, copyDocPtr);
655 xmlSetTreeDoc(cur_node, copyDocPtr);
661 DBG("node type: %d, name: %s children->name: %s last->name: %s\n"
662 "parent->name: %s next->name: %s prev->name: %s\n",
663 cur_node->type, cur_node->name,
664 cur_node->children ? cur_node->children->name : "NULL",
665 cur_node->last ? cur_node->last->name : "NULL",
666 cur_node->parent ? cur_node->parent->name : "NULL",
667 cur_node->next ? cur_node->next->name : "NULL",
668 cur_node->prev ? cur_node->prev->name : "NULL");
670 FILE *fp = fopen("/opt/share/test.xml", "a");
671 xmlDocDump(fp, copyDocPtr);
676 ret = __ps_run_parser(copyDocPtr, ASCII(name), action, pkgid);
683 __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgid)
688 switch (xmlTextReaderNodeType(reader)) {
689 case XML_READER_TYPE_END_ELEMENT:
691 // DBG("XML_READER_TYPE_END_ELEMENT");
695 case XML_READER_TYPE_ELEMENT:
697 // Elements without closing tag don't receive
698 // XML_READER_TYPE_END_ELEMENT event.
700 const xmlChar *elementName =
701 xmlTextReaderLocalName(reader);
702 if (elementName == NULL) {
703 // DBG("elementName %s\n", (char *)elementName);
707 const xmlChar *nameSpace =
708 xmlTextReaderConstNamespaceUri(reader);
710 // DBG("nameSpace %s\n", (char *)nameSpace);
713 DBG("XML_READER_TYPE_ELEMENT %s, %s\n",
714 elementName ? elementName : "NULL",
715 nameSpace ? nameSpace : "NULL");
718 DBG("__run_parser_prestep pkgid[%s]\n", pkgid);
719 __run_parser_prestep(reader, action, pkgid);
723 for (tag = tagv[0]; tag; tag = tagv[++i])
724 if (strcmp(tag, ASCII(elementName)) == 0) {
725 DBG("__run_parser_prestep tag[%s] pkgid[%s]\n", tag, pkgid);
726 __run_parser_prestep(reader,
734 case XML_READER_TYPE_TEXT:
735 case XML_READER_TYPE_CDATA:
737 const xmlChar *value = xmlTextReaderConstValue(reader);
739 // DBG("value %s\n", value);
742 const xmlChar *lang = xmlTextReaderConstXmlLang(reader);
744 // DBG("lang\n", lang);
747 /* DBG("XML_READER_TYPE_TEXT %s, %s\n",
748 value ? value : "NULL", lang ? lang : "NULL");
753 // DBG("Ignoring Node of Type: %d", xmlTextReaderNodeType(reader));
759 __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid)
761 xmlTextReaderPtr reader;
765 docPtr = xmlReadFile(filename, NULL, 0);
766 reader = xmlReaderWalker(docPtr);
767 if (reader != NULL) {
768 ret = xmlTextReaderRead(reader);
770 __processNode(reader, action, tagv, pkgid);
771 ret = xmlTextReaderRead(reader);
773 xmlFreeTextReader(reader);
776 DBGE("%s : failed to parse", filename);
779 DBGE("Unable to open %s", filename);
783 static int __next_child_element(xmlTextReaderPtr reader, int depth)
785 int ret = xmlTextReaderRead(reader);
786 int cur = xmlTextReaderDepth(reader);
789 switch (xmlTextReaderNodeType(reader)) {
790 case XML_READER_TYPE_ELEMENT:
791 if (cur == depth + 1)
794 case XML_READER_TYPE_TEXT:
795 /*text is handled by each function separately*/
796 if (cur == depth + 1)
799 case XML_READER_TYPE_END_ELEMENT:
808 ret = xmlTextReaderRead(reader);
809 cur = xmlTextReaderDepth(reader);
814 static void __ps_free_category(category_x *category)
816 if (category == NULL)
818 if (category->name) {
819 free((void *)category->name);
820 category->name = NULL;
822 free((void*)category);
826 static void __ps_free_privilege(privilege_x *privilege)
828 if (privilege == NULL)
830 if (privilege->text) {
831 free((void *)privilege->text);
832 privilege->text = NULL;
834 free((void*)privilege);
838 static void __ps_free_privileges(privileges_x *privileges)
840 if (privileges == NULL)
843 if (privileges->privilege) {
844 privilege_x *privilege = privileges->privilege;
845 privilege_x *tmp = NULL;
846 while(privilege != NULL) {
847 tmp = privilege->next;
848 __ps_free_privilege(privilege);
852 free((void*)privileges);
856 static void __ps_free_metadata(metadata_x *metadata)
858 if (metadata == NULL)
861 free((void *)metadata->key);
862 metadata->key = NULL;
864 if (metadata->value) {
865 free((void *)metadata->value);
866 metadata->value = NULL;
868 free((void*)metadata);
872 static void __ps_free_permission(permission_x *permission)
874 if (permission == NULL)
876 if (permission->type) {
877 free((void *)permission->type);
878 permission->type = NULL;
880 if (permission->value) {
881 free((void *)permission->value);
882 permission->value = NULL;
884 free((void*)permission);
888 static void __ps_free_icon(icon_x *icon)
893 free((void *)icon->text);
897 free((void *)icon->lang);
901 free((void *)icon->name);
905 free((void *)icon->section);
906 icon->section = NULL;
909 free((void *)icon->size);
912 if (icon->resolution) {
913 free((void *)icon->resolution);
914 icon->resolution = NULL;
920 static void __ps_free_image(image_x *image)
925 free((void *)image->text);
929 free((void *)image->lang);
933 free((void *)image->name);
936 if (image->section) {
937 free((void *)image->section);
938 image->section = NULL;
944 static void __ps_free_operation(operation_x *operation)
946 if (operation == NULL)
948 if (operation->text) {
949 free((void *)operation->text);
950 operation->text = NULL;
952 free((void*)operation);
956 static void __ps_free_uri(uri_x *uri)
961 free((void *)uri->text);
968 static void __ps_free_mime(mime_x *mime)
973 free((void *)mime->text);
980 static void __ps_free_subapp(subapp_x *subapp)
985 free((void *)subapp->text);
992 static void __ps_free_condition(condition_x *condition)
994 if (condition == NULL)
996 if (condition->text) {
997 free((void *)condition->text);
998 condition->text = NULL;
1000 if (condition->name) {
1001 free((void *)condition->name);
1002 condition->name = NULL;
1004 free((void*)condition);
1008 static void __ps_free_notification(notification_x *notification)
1010 if (notification == NULL)
1012 if (notification->text) {
1013 free((void *)notification->text);
1014 notification->text = NULL;
1016 if (notification->name) {
1017 free((void *)notification->name);
1018 notification->name = NULL;
1020 free((void*)notification);
1021 notification = NULL;
1024 static void __ps_free_compatibility(compatibility_x *compatibility)
1026 if (compatibility == NULL)
1028 if (compatibility->text) {
1029 free((void *)compatibility->text);
1030 compatibility->text = NULL;
1032 if (compatibility->name) {
1033 free((void *)compatibility->name);
1034 compatibility->name = NULL;
1036 free((void*)compatibility);
1037 compatibility = NULL;
1040 static void __ps_free_resolution(resolution_x *resolution)
1042 if (resolution == NULL)
1044 if (resolution->mimetype) {
1045 free((void *)resolution->mimetype);
1046 resolution->mimetype = NULL;
1048 if (resolution->urischeme) {
1049 free((void *)resolution->urischeme);
1050 resolution->urischeme = NULL;
1052 free((void*)resolution);
1056 static void __ps_free_capability(capability_x *capability)
1058 if (capability == NULL)
1060 if (capability->operationid) {
1061 free((void *)capability->operationid);
1062 capability->operationid = NULL;
1065 if (capability->resolution) {
1066 resolution_x *resolution = capability->resolution;
1067 resolution_x *tmp = NULL;
1068 while(resolution != NULL) {
1069 tmp = resolution->next;
1070 __ps_free_resolution(resolution);
1074 free((void*)capability);
1078 static void __ps_free_allowed(allowed_x *allowed)
1080 if (allowed == NULL)
1082 if (allowed->name) {
1083 free((void *)allowed->name);
1084 allowed->name = NULL;
1086 if (allowed->text) {
1087 free((void *)allowed->text);
1088 allowed->text = NULL;
1090 free((void*)allowed);
1094 static void __ps_free_request(request_x *request)
1096 if (request == NULL)
1098 if (request->text) {
1099 free((void *)request->text);
1100 request->text = NULL;
1102 free((void*)request);
1106 static void __ps_free_datacontrol(datacontrol_x *datacontrol)
1108 if (datacontrol == NULL)
1110 if (datacontrol->providerid) {
1111 free((void *)datacontrol->providerid);
1112 datacontrol->providerid = NULL;
1115 if (datacontrol->capability) {
1116 capability_x *capability = datacontrol->capability;
1117 capability_x *tmp = NULL;
1118 while(capability != NULL) {
1119 tmp = capability->next;
1120 __ps_free_capability(capability);
1124 free((void*)datacontrol);
1128 static void __ps_free_launchconditions(launchconditions_x *launchconditions)
1130 if (launchconditions == NULL)
1132 if (launchconditions->text) {
1133 free((void *)launchconditions->text);
1134 launchconditions->text = NULL;
1137 if (launchconditions->condition) {
1138 condition_x *condition = launchconditions->condition;
1139 condition_x *tmp = NULL;
1140 while(condition != NULL) {
1141 tmp = condition->next;
1142 __ps_free_condition(condition);
1146 free((void*)launchconditions);
1147 launchconditions = NULL;
1150 static void __ps_free_appcontrol(appcontrol_x *appcontrol)
1152 if (appcontrol == NULL)
1154 if (appcontrol->text) {
1155 free((void *)appcontrol->text);
1156 appcontrol->text = NULL;
1159 if (appcontrol->operation) {
1160 operation_x *operation = appcontrol->operation;
1161 operation_x *tmp = NULL;
1162 while(operation != NULL) {
1163 tmp = operation->next;
1164 __ps_free_operation(operation);
1169 if (appcontrol->uri) {
1170 uri_x *uri = appcontrol->uri;
1172 while(uri != NULL) {
1179 if (appcontrol->mime) {
1180 mime_x *mime = appcontrol->mime;
1182 while(mime != NULL) {
1184 __ps_free_mime(mime);
1189 if (appcontrol->subapp) {
1190 subapp_x *subapp = appcontrol->subapp;
1191 subapp_x *tmp = NULL;
1192 while(subapp != NULL) {
1194 __ps_free_subapp(subapp);
1198 free((void*)appcontrol);
1202 static void __ps_free_appsvc(appsvc_x *appsvc)
1207 free((void *)appsvc->text);
1208 appsvc->text = NULL;
1211 if (appsvc->operation) {
1212 operation_x *operation = appsvc->operation;
1213 operation_x *tmp = NULL;
1214 while(operation != NULL) {
1215 tmp = operation->next;
1216 __ps_free_operation(operation);
1222 uri_x *uri = appsvc->uri;
1224 while(uri != NULL) {
1232 mime_x *mime = appsvc->mime;
1234 while(mime != NULL) {
1236 __ps_free_mime(mime);
1241 if (appsvc->subapp) {
1242 subapp_x *subapp = appsvc->subapp;
1243 subapp_x *tmp = NULL;
1244 while(subapp != NULL) {
1246 __ps_free_subapp(subapp);
1250 free((void*)appsvc);
1254 static void __ps_free_deviceprofile(deviceprofile_x *deviceprofile)
1259 static void __ps_free_define(define_x *define)
1264 free((void *)define->path);
1265 define->path = NULL;
1268 if (define->request) {
1269 request_x *request = define->request;
1270 request_x *tmp = NULL;
1271 while(request != NULL) {
1272 tmp = request->next;
1273 __ps_free_request(request);
1278 if (define->allowed) {
1279 allowed_x *allowed = define->allowed;
1280 allowed_x *tmp = NULL;
1281 while(allowed != NULL) {
1282 tmp = allowed->next;
1283 __ps_free_allowed(allowed);
1287 free((void*)define);
1291 static void __ps_free_datashare(datashare_x *datashare)
1293 if (datashare == NULL)
1296 if (datashare->define) {
1297 define_x *define = datashare->define;
1298 define_x *tmp = NULL;
1299 while(define != NULL) {
1301 __ps_free_define(define);
1306 if (datashare->request) {
1307 request_x *request = datashare->request;
1308 request_x *tmp = NULL;
1309 while(request != NULL) {
1310 tmp = request->next;
1311 __ps_free_request(request);
1315 free((void*)datashare);
1319 static void __ps_free_label(label_x *label)
1324 free((void *)label->name);
1328 free((void *)label->text);
1332 free((void *)label->lang);
1339 static void __ps_free_author(author_x *author)
1343 if (author->email) {
1344 free((void *)author->email);
1345 author->email = NULL;
1348 free((void *)author->text);
1349 author->text = NULL;
1352 free((void *)author->href);
1353 author->href = NULL;
1356 free((void *)author->lang);
1357 author->lang = NULL;
1359 free((void*)author);
1363 static void __ps_free_description(description_x *description)
1365 if (description == NULL)
1367 if (description->name) {
1368 free((void *)description->name);
1369 description->name = NULL;
1371 if (description->text) {
1372 free((void *)description->text);
1373 description->text = NULL;
1375 if (description->lang) {
1376 free((void *)description->lang);
1377 description->lang = NULL;
1379 free((void*)description);
1383 static void __ps_free_license(license_x *license)
1385 if (license == NULL)
1387 if (license->text) {
1388 free((void *)license->text);
1389 license->text = NULL;
1391 if (license->lang) {
1392 free((void *)license->lang);
1393 license->lang = NULL;
1395 free((void*)license);
1399 static void __ps_free_uiapplication(uiapplication_x *uiapplication)
1401 if (uiapplication == NULL)
1403 if (uiapplication->exec) {
1404 free((void *)uiapplication->exec);
1405 uiapplication->exec = NULL;
1407 if (uiapplication->appid) {
1408 free((void *)uiapplication->appid);
1409 uiapplication->appid = NULL;
1411 if (uiapplication->nodisplay) {
1412 free((void *)uiapplication->nodisplay);
1413 uiapplication->nodisplay = NULL;
1415 if (uiapplication->multiple) {
1416 free((void *)uiapplication->multiple);
1417 uiapplication->multiple = NULL;
1419 if (uiapplication->type) {
1420 free((void *)uiapplication->type);
1421 uiapplication->type = NULL;
1423 if (uiapplication->categories) {
1424 free((void *)uiapplication->categories);
1425 uiapplication->categories = NULL;
1427 if (uiapplication->extraid) {
1428 free((void *)uiapplication->extraid);
1429 uiapplication->extraid = NULL;
1431 if (uiapplication->taskmanage) {
1432 free((void *)uiapplication->taskmanage);
1433 uiapplication->taskmanage = NULL;
1435 if (uiapplication->enabled) {
1436 free((void *)uiapplication->enabled);
1437 uiapplication->enabled = NULL;
1439 if (uiapplication->hwacceleration) {
1440 free((void *)uiapplication->hwacceleration);
1441 uiapplication->hwacceleration = NULL;
1443 if (uiapplication->screenreader) {
1444 free((void *)uiapplication->screenreader);
1445 uiapplication->screenreader = NULL;
1447 if (uiapplication->mainapp) {
1448 free((void *)uiapplication->mainapp);
1449 uiapplication->mainapp = NULL;
1451 if (uiapplication->recentimage) {
1452 free((void *)uiapplication->recentimage);
1453 uiapplication->recentimage = NULL;
1455 if (uiapplication->package) {
1456 free((void *)uiapplication->package);
1457 uiapplication->package = NULL;
1459 if (uiapplication->launchcondition) {
1460 free((void *)uiapplication->launchcondition);
1461 uiapplication->launchcondition = NULL;
1464 if (uiapplication->label) {
1465 label_x *label = uiapplication->label;
1466 label_x *tmp = NULL;
1467 while(label != NULL) {
1469 __ps_free_label(label);
1474 if (uiapplication->icon) {
1475 icon_x *icon = uiapplication->icon;
1477 while(icon != NULL) {
1479 __ps_free_icon(icon);
1484 if (uiapplication->image) {
1485 image_x *image = uiapplication->image;
1486 image_x *tmp = NULL;
1487 while(image != NULL) {
1489 __ps_free_image(image);
1494 if (uiapplication->appcontrol) {
1495 appcontrol_x *appcontrol = uiapplication->appcontrol;
1496 appcontrol_x *tmp = NULL;
1497 while(appcontrol != NULL) {
1498 tmp = appcontrol->next;
1499 __ps_free_appcontrol(appcontrol);
1503 /*Free LaunchConditions*/
1504 if (uiapplication->launchconditions) {
1505 launchconditions_x *launchconditions = uiapplication->launchconditions;
1506 launchconditions_x *tmp = NULL;
1507 while(launchconditions != NULL) {
1508 tmp = launchconditions->next;
1509 __ps_free_launchconditions(launchconditions);
1510 launchconditions = tmp;
1513 /*Free Notification*/
1514 if (uiapplication->notification) {
1515 notification_x *notification = uiapplication->notification;
1516 notification_x *tmp = NULL;
1517 while(notification != NULL) {
1518 tmp = notification->next;
1519 __ps_free_notification(notification);
1524 if (uiapplication->datashare) {
1525 datashare_x *datashare = uiapplication->datashare;
1526 datashare_x *tmp = NULL;
1527 while(datashare != NULL) {
1528 tmp = datashare->next;
1529 __ps_free_datashare(datashare);
1534 if (uiapplication->appsvc) {
1535 appsvc_x *appsvc = uiapplication->appsvc;
1536 appsvc_x *tmp = NULL;
1537 while(appsvc != NULL) {
1539 __ps_free_appsvc(appsvc);
1544 if (uiapplication->category) {
1545 category_x *category = uiapplication->category;
1546 category_x *tmp = NULL;
1547 while(category != NULL) {
1548 tmp = category->next;
1549 __ps_free_category(category);
1554 if (uiapplication->metadata) {
1555 metadata_x *metadata = uiapplication->metadata;
1556 metadata_x *tmp = NULL;
1557 while(metadata != NULL) {
1558 tmp = metadata->next;
1559 __ps_free_metadata(metadata);
1564 if (uiapplication->permission) {
1565 permission_x *permission = uiapplication->permission;
1566 permission_x *tmp = NULL;
1567 while(permission != NULL) {
1568 tmp = permission->next;
1569 __ps_free_permission(permission);
1573 /* _PRODUCT_LAUNCHING_ENHANCED_ START */
1574 if (uiapplication->indicatordisplay) {
1575 free((void *)uiapplication->indicatordisplay);
1576 uiapplication->indicatordisplay = NULL;
1578 if (uiapplication->portraitimg) {
1579 free((void *)uiapplication->portraitimg);
1580 uiapplication->portraitimg = NULL;
1582 if (uiapplication->landscapeimg) {
1583 free((void *)uiapplication->landscapeimg);
1584 uiapplication->landscapeimg = NULL;
1586 /* _PRODUCT_LAUNCHING_ENHANCED_ END */
1587 if (uiapplication->guestmode_visibility) {
1588 free((void *)uiapplication->guestmode_visibility);
1589 uiapplication->guestmode_visibility = NULL;
1591 if (uiapplication->app_component) {
1592 free((void *)uiapplication->app_component);
1593 uiapplication->app_component = NULL;
1595 if (uiapplication->permission_type) {
1596 free((void *)uiapplication->permission_type);
1597 uiapplication->permission_type = NULL;
1599 if (uiapplication->component_type) {
1600 free((void *)uiapplication->component_type);
1601 uiapplication->component_type = NULL;
1603 if (uiapplication->preload) {
1604 free((void *)uiapplication->preload);
1605 uiapplication->preload = NULL;
1607 if (uiapplication->submode) {
1608 free((void *)uiapplication->submode);
1609 uiapplication->submode = NULL;
1611 if (uiapplication->submode_mainid) {
1612 free((void *)uiapplication->submode_mainid);
1613 uiapplication->submode_mainid = NULL;
1616 free((void*)uiapplication);
1617 uiapplication = NULL;
1620 static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication)
1622 if (serviceapplication == NULL)
1624 if (serviceapplication->exec) {
1625 free((void *)serviceapplication->exec);
1626 serviceapplication->exec = NULL;
1628 if (serviceapplication->appid) {
1629 free((void *)serviceapplication->appid);
1630 serviceapplication->appid = NULL;
1632 if (serviceapplication->onboot) {
1633 free((void *)serviceapplication->onboot);
1634 serviceapplication->onboot = NULL;
1636 if (serviceapplication->autorestart) {
1637 free((void *)serviceapplication->autorestart);
1638 serviceapplication->autorestart = NULL;
1640 if (serviceapplication->type) {
1641 free((void *)serviceapplication->type);
1642 serviceapplication->type = NULL;
1644 if (serviceapplication->enabled) {
1645 free((void *)serviceapplication->enabled);
1646 serviceapplication->enabled = NULL;
1648 if (serviceapplication->package) {
1649 free((void *)serviceapplication->package);
1650 serviceapplication->package = NULL;
1652 if (serviceapplication->permission_type) {
1653 free((void *)serviceapplication->permission_type);
1654 serviceapplication->permission_type = NULL;
1657 if (serviceapplication->label) {
1658 label_x *label = serviceapplication->label;
1659 label_x *tmp = NULL;
1660 while(label != NULL) {
1662 __ps_free_label(label);
1667 if (serviceapplication->icon) {
1668 icon_x *icon = serviceapplication->icon;
1670 while(icon != NULL) {
1672 __ps_free_icon(icon);
1677 if (serviceapplication->appcontrol) {
1678 appcontrol_x *appcontrol = serviceapplication->appcontrol;
1679 appcontrol_x *tmp = NULL;
1680 while(appcontrol != NULL) {
1681 tmp = appcontrol->next;
1682 __ps_free_appcontrol(appcontrol);
1686 /*Free DataControl*/
1687 if (serviceapplication->datacontrol) {
1688 datacontrol_x *datacontrol = serviceapplication->datacontrol;
1689 datacontrol_x *tmp = NULL;
1690 while(datacontrol != NULL) {
1691 tmp = datacontrol->next;
1692 __ps_free_datacontrol(datacontrol);
1696 /*Free LaunchConditions*/
1697 if (serviceapplication->launchconditions) {
1698 launchconditions_x *launchconditions = serviceapplication->launchconditions;
1699 launchconditions_x *tmp = NULL;
1700 while(launchconditions != NULL) {
1701 tmp = launchconditions->next;
1702 __ps_free_launchconditions(launchconditions);
1703 launchconditions = tmp;
1706 /*Free Notification*/
1707 if (serviceapplication->notification) {
1708 notification_x *notification = serviceapplication->notification;
1709 notification_x *tmp = NULL;
1710 while(notification != NULL) {
1711 tmp = notification->next;
1712 __ps_free_notification(notification);
1717 if (serviceapplication->datashare) {
1718 datashare_x *datashare = serviceapplication->datashare;
1719 datashare_x *tmp = NULL;
1720 while(datashare != NULL) {
1721 tmp = datashare->next;
1722 __ps_free_datashare(datashare);
1727 if (serviceapplication->appsvc) {
1728 appsvc_x *appsvc = serviceapplication->appsvc;
1729 appsvc_x *tmp = NULL;
1730 while(appsvc != NULL) {
1732 __ps_free_appsvc(appsvc);
1737 if (serviceapplication->category) {
1738 category_x *category = serviceapplication->category;
1739 category_x *tmp = NULL;
1740 while(category != NULL) {
1741 tmp = category->next;
1742 __ps_free_category(category);
1747 if (serviceapplication->metadata) {
1748 metadata_x *metadata = serviceapplication->metadata;
1749 metadata_x *tmp = NULL;
1750 while(metadata != NULL) {
1751 tmp = metadata->next;
1752 __ps_free_metadata(metadata);
1757 if (serviceapplication->permission) {
1758 permission_x *permission = serviceapplication->permission;
1759 permission_x *tmp = NULL;
1760 while(permission != NULL) {
1761 tmp = permission->next;
1762 __ps_free_permission(permission);
1766 free((void*)serviceapplication);
1767 serviceapplication = NULL;
1770 static void __ps_free_font(font_x *font)
1775 free((void *)font->name);
1779 free((void *)font->text);
1786 static void __ps_free_theme(theme_x *theme)
1791 free((void *)theme->name);
1795 free((void *)theme->text);
1802 static void __ps_free_daemon(daemon_x *daemon)
1807 free((void *)daemon->name);
1808 daemon->name = NULL;
1811 free((void *)daemon->text);
1812 daemon->text = NULL;
1814 free((void*)daemon);
1818 static void __ps_free_ime(ime_x *ime)
1823 free((void *)ime->name);
1827 free((void *)ime->text);
1834 int __ps_process_mdparser(manifest_x *mfx, ACTION_TYPE action)
1838 char md_key[PKG_STRING_LEN_MAX] = { 0 };
1840 fp = fopen(MDPARSER_LIST, "r");
1842 DBG("no preload list\n");
1846 while (fgets(md_key, sizeof(md_key), fp) != NULL) {
1848 DBG("md_key = %s\n", md_key);
1850 ret = __run_mdparser_prestep(mfx, md_key, action);
1852 memset(md_key, 0x00, sizeof(md_key));
1861 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed)
1863 xmlTextReaderRead(reader);
1864 if (xmlTextReaderValue(reader))
1865 allowed->text = ASCII(xmlTextReaderValue(reader));
1869 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation)
1871 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1872 operation->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1873 /* Text does not exist. Only attribute exists
1874 xmlTextReaderRead(reader);
1875 if (xmlTextReaderValue(reader))
1876 operation->text = ASCII(xmlTextReaderValue(reader));
1881 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri)
1883 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1884 uri->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1885 /* Text does not exist. Only attribute exists
1886 xmlTextReaderRead(reader);
1887 if (xmlTextReaderValue(reader))
1888 uri->text = ASCII(xmlTextReaderValue(reader));
1893 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime)
1895 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1896 mime->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1897 /* Text does not exist. Only attribute exists
1898 xmlTextReaderRead(reader);
1899 if (xmlTextReaderValue(reader))
1900 mime->text = ASCII(xmlTextReaderValue(reader));
1905 static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp)
1907 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1908 subapp->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1909 /* Text does not exist. Only attribute exists
1910 xmlTextReaderRead(reader);
1911 if (xmlTextReaderValue(reader))
1912 mime->text = ASCII(xmlTextReaderValue(reader));
1917 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition)
1919 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1920 condition->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1921 xmlTextReaderRead(reader);
1922 if (xmlTextReaderValue(reader))
1923 condition->text = ASCII(xmlTextReaderValue(reader));
1927 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notification)
1929 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1930 notification->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1931 xmlTextReaderRead(reader);
1932 if (xmlTextReaderValue(reader))
1933 notification->text = ASCII(xmlTextReaderValue(reader));
1937 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category)
1939 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1940 category->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1944 static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege)
1946 xmlTextReaderRead(reader);
1947 if (xmlTextReaderValue(reader)) {
1948 privilege->text = ASCII(xmlTextReaderValue(reader));
1953 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata)
1955 if (xmlTextReaderGetAttribute(reader, XMLCHAR("key")))
1956 metadata->key = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("key")));
1957 if (xmlTextReaderGetAttribute(reader, XMLCHAR("value")))
1958 metadata->value = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("value")));
1962 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission)
1964 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
1965 permission->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
1967 xmlTextReaderRead(reader);
1968 if (xmlTextReaderValue(reader))
1969 permission->value = ASCII(xmlTextReaderValue(reader));
1973 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility)
1975 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1976 compatibility->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1977 xmlTextReaderRead(reader);
1978 if (xmlTextReaderValue(reader))
1979 compatibility->text = ASCII(xmlTextReaderValue(reader));
1983 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution)
1985 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")))
1986 resolution->mimetype = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")));
1987 if (xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")))
1988 resolution->urischeme = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")));
1992 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request)
1994 xmlTextReaderRead(reader);
1995 if (xmlTextReaderValue(reader))
1996 request->text = ASCII(xmlTextReaderValue(reader));
2000 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define)
2002 const xmlChar *node;
2005 allowed_x *tmp1 = NULL;
2006 request_x *tmp2 = NULL;
2008 if (xmlTextReaderGetAttribute(reader, XMLCHAR("path")))
2009 define->path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("path")));
2011 depth = xmlTextReaderDepth(reader);
2012 while ((ret = __next_child_element(reader, depth))) {
2013 node = xmlTextReaderConstName(reader);
2015 DBG("xmlTextReaderConstName value is NULL\n");
2019 if (!strcmp(ASCII(node), "allowed")) {
2020 allowed_x *allowed= malloc(sizeof(allowed_x));
2021 if (allowed == NULL) {
2022 DBG("Malloc Failed\n");
2025 memset(allowed, '\0', sizeof(allowed_x));
2026 LISTADD(define->allowed, allowed);
2027 ret = __ps_process_allowed(reader, allowed);
2028 } else if (!strcmp(ASCII(node), "request")) {
2029 request_x *request = malloc(sizeof(request_x));
2030 if (request == NULL) {
2031 DBG("Malloc Failed\n");
2034 memset(request, '\0', sizeof(request_x));
2035 LISTADD(define->request, request);
2036 ret = __ps_process_request(reader, request);
2040 DBG("Processing define failed\n");
2044 if (define->allowed) {
2045 LISTHEAD(define->allowed, tmp1);
2046 define->allowed = tmp1;
2048 if (define->request) {
2049 LISTHEAD(define->request, tmp2);
2050 define->request = tmp2;
2055 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol)
2057 const xmlChar *node;
2060 operation_x *tmp1 = NULL;
2062 mime_x *tmp3 = NULL;
2063 subapp_x *tmp4 = NULL;
2065 depth = xmlTextReaderDepth(reader);
2066 while ((ret = __next_child_element(reader, depth))) {
2067 node = xmlTextReaderConstName(reader);
2069 DBG("xmlTextReaderConstName value is NULL\n");
2073 if (!strcmp(ASCII(node), "operation")) {
2074 operation_x *operation = malloc(sizeof(operation_x));
2075 if (operation == NULL) {
2076 DBG("Malloc Failed\n");
2079 memset(operation, '\0', sizeof(operation_x));
2080 LISTADD(appcontrol->operation, operation);
2081 ret = __ps_process_operation(reader, operation);
2082 DBG("operation processing\n");
2083 } else if (!strcmp(ASCII(node), "uri")) {
2084 uri_x *uri= malloc(sizeof(uri_x));
2086 DBG("Malloc Failed\n");
2089 memset(uri, '\0', sizeof(uri_x));
2090 LISTADD(appcontrol->uri, uri);
2091 ret = __ps_process_uri(reader, uri);
2092 DBG("uri processing\n");
2093 } else if (!strcmp(ASCII(node), "mime")) {
2094 mime_x *mime = malloc(sizeof(mime_x));
2096 DBG("Malloc Failed\n");
2099 memset(mime, '\0', sizeof(mime_x));
2100 LISTADD(appcontrol->mime, mime);
2101 ret = __ps_process_mime(reader, mime);
2102 DBG("mime processing\n");
2103 } else if (!strcmp(ASCII(node), "subapp")) {
2104 subapp_x *subapp = malloc(sizeof(subapp_x));
2105 if (subapp == NULL) {
2106 DBG("Malloc Failed\n");
2109 memset(subapp, '\0', sizeof(subapp_x));
2110 LISTADD(appcontrol->subapp, subapp);
2111 ret = __ps_process_subapp(reader, subapp);
2112 DBG("subapp processing\n");
2116 DBG("Processing appcontrol failed\n");
2120 if (appcontrol->operation) {
2121 LISTHEAD(appcontrol->operation, tmp1);
2122 appcontrol->operation = tmp1;
2124 if (appcontrol->uri) {
2125 LISTHEAD(appcontrol->uri, tmp2);
2126 appcontrol->uri = tmp2;
2128 if (appcontrol->mime) {
2129 LISTHEAD(appcontrol->mime, tmp3);
2130 appcontrol->mime = tmp3;
2132 if (appcontrol->subapp) {
2133 LISTHEAD(appcontrol->subapp, tmp4);
2134 appcontrol->subapp = tmp4;
2137 xmlTextReaderRead(reader);
2138 if (xmlTextReaderValue(reader))
2139 appcontrol->text = ASCII(xmlTextReaderValue(reader));
2144 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc)
2146 const xmlChar *node;
2149 operation_x *tmp1 = NULL;
2151 mime_x *tmp3 = NULL;
2152 subapp_x *tmp4 = NULL;
2154 depth = xmlTextReaderDepth(reader);
2155 while ((ret = __next_child_element(reader, depth))) {
2156 node = xmlTextReaderConstName(reader);
2158 DBG("xmlTextReaderConstName value is NULL\n");
2162 if (!strcmp(ASCII(node), "operation")) {
2163 operation_x *operation = malloc(sizeof(operation_x));
2164 if (operation == NULL) {
2165 DBG("Malloc Failed\n");
2168 memset(operation, '\0', sizeof(operation_x));
2169 LISTADD(appsvc->operation, operation);
2170 ret = __ps_process_operation(reader, operation);
2171 DBG("operation processing\n");
2172 } else if (!strcmp(ASCII(node), "uri")) {
2173 uri_x *uri= malloc(sizeof(uri_x));
2175 DBG("Malloc Failed\n");
2178 memset(uri, '\0', sizeof(uri_x));
2179 LISTADD(appsvc->uri, uri);
2180 ret = __ps_process_uri(reader, uri);
2181 DBG("uri processing\n");
2182 } else if (!strcmp(ASCII(node), "mime")) {
2183 mime_x *mime = malloc(sizeof(mime_x));
2185 DBG("Malloc Failed\n");
2188 memset(mime, '\0', sizeof(mime_x));
2189 LISTADD(appsvc->mime, mime);
2190 ret = __ps_process_mime(reader, mime);
2191 DBG("mime processing\n");
2192 } else if (!strcmp(ASCII(node), "subapp")) {
2193 subapp_x *subapp = malloc(sizeof(subapp_x));
2194 if (subapp == NULL) {
2195 DBG("Malloc Failed\n");
2198 memset(subapp, '\0', sizeof(subapp_x));
2199 LISTADD(appsvc->subapp, subapp);
2200 ret = __ps_process_subapp(reader, subapp);
2201 DBG("subapp processing\n");
2205 DBG("Processing appsvc failed\n");
2209 if (appsvc->operation) {
2210 LISTHEAD(appsvc->operation, tmp1);
2211 appsvc->operation = tmp1;
2214 LISTHEAD(appsvc->uri, tmp2);
2218 LISTHEAD(appsvc->mime, tmp3);
2219 appsvc->mime = tmp3;
2221 if (appsvc->subapp) {
2222 LISTHEAD(appsvc->subapp, tmp4);
2223 appsvc->subapp = tmp4;
2226 xmlTextReaderRead(reader);
2227 if (xmlTextReaderValue(reader))
2228 appsvc->text = ASCII(xmlTextReaderValue(reader));
2234 static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privileges)
2236 const xmlChar *node;
2239 privilege_x *tmp1 = NULL;
2241 depth = xmlTextReaderDepth(reader);
2242 while ((ret = __next_child_element(reader, depth))) {
2243 node = xmlTextReaderConstName(reader);
2245 DBG("xmlTextReaderConstName value is NULL\n");
2249 if (strcmp(ASCII(node), "privilege") == 0) {
2250 privilege_x *privilege = malloc(sizeof(privilege_x));
2251 if (privilege == NULL) {
2252 DBG("Malloc Failed\n");
2255 memset(privilege, '\0', sizeof(privilege_x));
2256 LISTADD(privileges->privilege, privilege);
2257 ret = __ps_process_privilege(reader, privilege);
2261 DBG("Processing privileges failed\n");
2265 if (privileges->privilege) {
2266 LISTHEAD(privileges->privilege, tmp1);
2267 privileges->privilege = tmp1;
2272 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions)
2274 const xmlChar *node;
2277 condition_x *tmp1 = NULL;
2279 depth = xmlTextReaderDepth(reader);
2280 while ((ret = __next_child_element(reader, depth))) {
2281 node = xmlTextReaderConstName(reader);
2283 DBG("xmlTextReaderConstName value is NULL\n");
2287 if (strcmp(ASCII(node), "condition") == 0) {
2288 condition_x *condition = malloc(sizeof(condition_x));
2289 if (condition == NULL) {
2290 DBG("Malloc Failed\n");
2293 memset(condition, '\0', sizeof(condition_x));
2294 LISTADD(launchconditions->condition, condition);
2295 ret = __ps_process_condition(reader, condition);
2299 DBG("Processing launchconditions failed\n");
2303 if (launchconditions->condition) {
2304 LISTHEAD(launchconditions->condition, tmp1);
2305 launchconditions->condition = tmp1;
2308 xmlTextReaderRead(reader);
2309 if (xmlTextReaderValue(reader))
2310 launchconditions->text = ASCII(xmlTextReaderValue(reader));
2315 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare)
2317 const xmlChar *node;
2320 define_x *tmp1 = NULL;
2321 request_x *tmp2 = NULL;
2322 depth = xmlTextReaderDepth(reader);
2323 while ((ret = __next_child_element(reader, depth))) {
2324 node = xmlTextReaderConstName(reader);
2326 DBG("xmlTextReaderConstName value is NULL\n");
2330 if (!strcmp(ASCII(node), "define")) {
2331 define_x *define= malloc(sizeof(define_x));
2332 if (define == NULL) {
2333 DBG("Malloc Failed\n");
2336 memset(define, '\0', sizeof(define_x));
2337 LISTADD(datashare->define, define);
2338 ret = __ps_process_define(reader, define);
2339 } else if (!strcmp(ASCII(node), "request")) {
2340 request_x *request= malloc(sizeof(request_x));
2341 if (request == NULL) {
2342 DBG("Malloc Failed\n");
2345 memset(request, '\0', sizeof(request_x));
2346 LISTADD(datashare->request, request);
2347 ret = __ps_process_request(reader, request);
2351 DBG("Processing data-share failed\n");
2355 if (datashare->define) {
2356 LISTHEAD(datashare->define, tmp1);
2357 datashare->define = tmp1;
2359 if (datashare->request) {
2360 LISTHEAD(datashare->request, tmp2);
2361 datashare->request = tmp2;
2367 __get_icon_with_path(const char* icon)
2372 if (index(icon, '/') == NULL) {
2374 char* icon_with_path = NULL;
2380 theme = vconf_get_str("db/setting/theme");
2382 theme = strdup("default");
2388 len = (0x01 << 7) + strlen(icon) + strlen(package) + strlen(theme);
2389 icon_with_path = malloc(len);
2390 if(icon_with_path == NULL) {
2391 DBG("(icon_with_path == NULL) return\n");
2396 memset(icon_with_path, 0, len);
2398 snprintf(icon_with_path, len, "/opt/share/icons/%s/small/%s", theme, icon);
2400 if (access(icon_with_path, R_OK) == 0) break;
2401 snprintf(icon_with_path, len, "/usr/share/icons/%s/small/%s", theme, icon);
2402 if (access(icon_with_path, R_OK) == 0) break;
2403 DBG("cannot find icon %s", icon_with_path);
2404 snprintf(icon_with_path, len,"/opt/share/icons/default/small/%s", icon);
2405 if (access(icon_with_path, R_OK) == 0) break;
2406 snprintf(icon_with_path, len, "/usr/share/icons/default/small/%s", icon);
2407 if (access(icon_with_path, R_OK) == 0) break;
2409 /* icon path is going to be moved intto the app directory */
2410 DBGE("icon file must be moved to %s", icon_with_path);
2411 snprintf(icon_with_path, len, "/opt/apps/%s/res/icons/%s/small/%s", package, theme, icon);
2412 if (access(icon_with_path, R_OK) == 0) break;
2413 snprintf(icon_with_path, len, "/usr/apps/%s/res/icons/%s/small/%s", package, theme, icon);
2414 if (access(icon_with_path, R_OK) == 0) break;
2415 DBG("cannot find icon %s", icon_with_path);
2416 snprintf(icon_with_path, len, "/opt/apps/%s/res/icons/default/small/%s", package, icon);
2417 if (access(icon_with_path, R_OK) == 0) break;
2418 snprintf(icon_with_path, len, "/usr/apps/%s/res/icons/default/small/%s", package, icon);
2419 if (access(icon_with_path, R_OK) == 0) break;
2420 snprintf(icon_with_path, len, "/usr/ug/res/images/%s/%s", package, icon);
2421 if (access(icon_with_path, R_OK) == 0) break;
2426 DBG("Icon path : %s ---> %s", icon, icon_with_path);
2428 return icon_with_path;
2430 char* confirmed_icon = NULL;
2432 confirmed_icon = strdup(icon);
2433 if (!confirmed_icon)
2435 return confirmed_icon;
2439 static void __ps_process_tag(manifest_x * mfx, char *const tagv[])
2442 char delims[] = "=";
2443 char *ret_result = NULL;
2449 for (tag = strdup(tagv[0]); tag != NULL; ) {
2450 ret_result = strtok(tag, delims);
2452 /*check tag : preload */
2453 if (strcmp(ret_result, "preload") == 0) {
2454 ret_result = strtok(NULL, delims);
2455 if (strcmp(ret_result, "true") == 0) {
2456 free((void *)mfx->preload);
2457 mfx->preload = strdup("true");
2458 } else if (strcmp(ret_result, "false") == 0) {
2459 free((void *)mfx->preload);
2460 mfx->preload = strdup("false");
2462 /*check tag : removable*/
2463 } else if (strcmp(ret_result, "removable") == 0) {
2464 ret_result = strtok(NULL, delims);
2465 if (strcmp(ret_result, "true") == 0){
2466 free((void *)mfx->removable);
2467 mfx->removable = strdup("true");
2468 } else if (strcmp(ret_result, "false") == 0) {
2469 free((void *)mfx->removable);
2470 mfx->removable = strdup("false");
2472 /*check tag : not matched*/
2474 DBG("tag process [%s]is not defined\n", ret_result);
2478 /*check next value*/
2479 if (tagv[++i] != NULL)
2480 tag = strdup(tagv[i]);
2482 DBG("tag process success...\n");
2488 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon)
2490 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2491 icon->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2492 if (xmlTextReaderConstXmlLang(reader)) {
2493 icon->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2494 if (icon->lang == NULL)
2495 icon->lang = strdup(DEFAULT_LOCALE);
2497 icon->lang = strdup(DEFAULT_LOCALE);
2499 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
2500 icon->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
2501 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
2502 icon->size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
2503 if (xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")))
2504 icon->resolution = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")));
2505 xmlTextReaderRead(reader);
2506 if (xmlTextReaderValue(reader)) {
2507 const char *text = ASCII(xmlTextReaderValue(reader));
2509 icon->text = (const char *)__get_icon_with_path(text);
2517 static int __ps_process_image(xmlTextReaderPtr reader, image_x *image)
2519 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2520 image->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2521 if (xmlTextReaderConstXmlLang(reader)) {
2522 image->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2523 if (image->lang == NULL)
2524 image->lang = strdup(DEFAULT_LOCALE);
2526 image->lang = strdup(DEFAULT_LOCALE);
2528 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
2529 image->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
2530 xmlTextReaderRead(reader);
2531 if (xmlTextReaderValue(reader))
2532 image->text = ASCII(xmlTextReaderValue(reader));
2537 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label)
2539 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2540 label->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2541 if (xmlTextReaderConstXmlLang(reader)) {
2542 label->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2543 if (label->lang == NULL)
2544 label->lang = strdup(DEFAULT_LOCALE);
2546 label->lang = strdup(DEFAULT_LOCALE);
2548 xmlTextReaderRead(reader);
2549 if (xmlTextReaderValue(reader))
2550 label->text = ASCII(xmlTextReaderValue(reader));
2552 /* DBG("lable name %s\n", label->name);
2553 DBG("lable lang %s\n", label->lang);
2554 DBG("lable text %s\n", label->text);
2560 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author)
2562 if (xmlTextReaderGetAttribute(reader, XMLCHAR("email")))
2563 author->email = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("email")));
2564 if (xmlTextReaderGetAttribute(reader, XMLCHAR("href")))
2565 author->href = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("href")));
2566 if (xmlTextReaderConstXmlLang(reader)) {
2567 author->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2568 if (author->lang == NULL)
2569 author->lang = strdup(DEFAULT_LOCALE);
2571 author->lang = strdup(DEFAULT_LOCALE);
2573 xmlTextReaderRead(reader);
2574 if (xmlTextReaderValue(reader))
2575 author->text = ASCII(xmlTextReaderValue(reader));
2579 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description)
2581 if (xmlTextReaderConstXmlLang(reader)) {
2582 description->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2583 if (description->lang == NULL)
2584 description->lang = strdup(DEFAULT_LOCALE);
2586 description->lang = strdup(DEFAULT_LOCALE);
2588 xmlTextReaderRead(reader);
2589 if (xmlTextReaderValue(reader))
2590 description->text = ASCII(xmlTextReaderValue(reader));
2594 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license)
2596 if (xmlTextReaderConstXmlLang(reader)) {
2597 license->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2598 if (license->lang == NULL)
2599 license->lang = strdup(DEFAULT_LOCALE);
2601 license->lang = strdup(DEFAULT_LOCALE);
2603 xmlTextReaderRead(reader);
2604 if (xmlTextReaderValue(reader))
2605 license->text = ASCII(xmlTextReaderValue(reader));
2609 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability)
2611 const xmlChar *node;
2614 resolution_x *tmp1 = NULL;
2616 if (xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")))
2617 capability->operationid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")));
2619 depth = xmlTextReaderDepth(reader);
2620 while ((ret = __next_child_element(reader, depth))) {
2621 node = xmlTextReaderConstName(reader);
2623 DBG("xmlTextReaderConstName value is NULL\n");
2627 if (!strcmp(ASCII(node), "resolution")) {
2628 resolution_x *resolution = malloc(sizeof(resolution_x));
2629 if (resolution == NULL) {
2630 DBG("Malloc Failed\n");
2633 memset(resolution, '\0', sizeof(resolution_x));
2634 LISTADD(capability->resolution, resolution);
2635 ret = __ps_process_resolution(reader, resolution);
2639 DBG("Processing capability failed\n");
2644 if (capability->resolution) {
2645 LISTHEAD(capability->resolution, tmp1);
2646 capability->resolution = tmp1;
2652 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol)
2654 const xmlChar *node;
2657 capability_x *tmp1 = NULL;
2659 if (xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")))
2660 datacontrol->providerid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")));
2662 depth = xmlTextReaderDepth(reader);
2663 while ((ret = __next_child_element(reader, depth))) {
2664 node = xmlTextReaderConstName(reader);
2666 DBG("xmlTextReaderConstName value is NULL\n");
2670 if (!strcmp(ASCII(node), "capability")) {
2671 capability_x *capability = malloc(sizeof(capability_x));
2672 if (capability == NULL) {
2673 DBG("Malloc Failed\n");
2676 memset(capability, '\0', sizeof(capability_x));
2677 LISTADD(datacontrol->capability, capability);
2678 ret = __ps_process_capability(reader, capability);
2682 DBG("Processing datacontrol failed\n");
2687 if (datacontrol->capability) {
2688 LISTHEAD(datacontrol->capability, tmp1);
2689 datacontrol->capability = tmp1;
2695 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication)
2697 const xmlChar *node;
2700 char *newappid = NULL;
2701 label_x *tmp1 = NULL;
2702 icon_x *tmp2 = NULL;
2703 appsvc_x *tmp3 = NULL;
2704 appcontrol_x *tmp4 = NULL;
2705 launchconditions_x *tmp5 = NULL;
2706 notification_x *tmp6 = NULL;
2707 datashare_x *tmp7 = NULL;
2708 category_x *tmp8 = NULL;
2709 metadata_x *tmp9 = NULL;
2710 image_x *tmp10 = NULL;
2711 permission_x *tmp11 = NULL;
2713 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
2714 uiapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
2715 if (uiapplication->appid == NULL) {
2716 DBG("appid cant be NULL\n");
2720 DBG("appid is mandatory\n");
2724 ret = __validate_appid(package, uiapplication->appid, &newappid);
2726 DBG("appid is not proper\n");
2730 if (uiapplication->appid)
2731 free((void *)uiapplication->appid);
2732 uiapplication->appid = newappid;
2734 uiapplication->package= strdup(package);
2736 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
2737 uiapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
2738 if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay"))) {
2739 uiapplication->nodisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay")));
2740 if (uiapplication->nodisplay == NULL)
2741 uiapplication->nodisplay = strdup("false");
2743 uiapplication->nodisplay = strdup("false");
2745 if (xmlTextReaderGetAttribute(reader, XMLCHAR("multiple"))) {
2746 uiapplication->multiple = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("multiple")));
2747 if (uiapplication->multiple == NULL)
2748 uiapplication->multiple = strdup("false");
2750 uiapplication->multiple = strdup("false");
2752 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
2753 uiapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
2754 if (xmlTextReaderGetAttribute(reader, XMLCHAR("categories")))
2755 uiapplication->categories = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("categories")));
2756 if (xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")))
2757 uiapplication->extraid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")));
2758 if (xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage"))) {
2759 uiapplication->taskmanage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage")));
2760 if (uiapplication->taskmanage == NULL)
2761 uiapplication->taskmanage = strdup("true");
2763 uiapplication->taskmanage = strdup("true");
2765 if (xmlTextReaderGetAttribute(reader, XMLCHAR("enabled"))) {
2766 uiapplication->enabled = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("enabled")));
2767 if (uiapplication->enabled == NULL)
2768 uiapplication->enabled = strdup("true");
2770 uiapplication->enabled = strdup("true");
2772 if (xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration"))) {
2773 uiapplication->hwacceleration = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration")));
2774 if (uiapplication->hwacceleration == NULL)
2775 uiapplication->hwacceleration = strdup("use-system-setting");
2777 uiapplication->hwacceleration = strdup("use-system-setting");
2779 if (xmlTextReaderGetAttribute(reader, XMLCHAR("screen-reader"))) {
2780 uiapplication->screenreader = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("screen-reader")));
2781 if (uiapplication->screenreader == NULL)
2782 uiapplication->screenreader = strdup("use-system-setting");
2784 uiapplication->screenreader = strdup("use-system-setting");
2786 if (xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")))
2787 uiapplication->recentimage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")));
2788 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp"))) {
2789 uiapplication->mainapp = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp")));
2790 if (uiapplication->mainapp == NULL)
2791 uiapplication->mainapp = strdup("false");
2793 uiapplication->mainapp = strdup("false");
2795 if (xmlTextReaderGetAttribute(reader, XMLCHAR("launchcondition"))) {
2796 uiapplication->launchcondition = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("launchcondition")));
2797 if (uiapplication->launchcondition == NULL)
2798 uiapplication->launchcondition = strdup("false");
2800 uiapplication->launchcondition = strdup("false");
2803 if (xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay"))) {
2804 uiapplication->indicatordisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay")));
2805 if (uiapplication->indicatordisplay == NULL)
2806 uiapplication->indicatordisplay = strdup("true");
2808 uiapplication->indicatordisplay = strdup("true");
2810 if (xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")))
2811 uiapplication->portraitimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")));
2813 uiapplication->portraitimg = NULL;
2814 if (xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")))
2815 uiapplication->landscapeimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")));
2817 uiapplication->landscapeimg = NULL;
2818 if (xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility"))) {
2819 uiapplication->guestmode_visibility = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility")));
2820 if (uiapplication->guestmode_visibility == NULL)
2821 uiapplication->guestmode_visibility = strdup("true");
2823 uiapplication->guestmode_visibility = strdup("true");
2825 if (xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type"))) {
2826 uiapplication->permission_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type")));
2827 if (uiapplication->permission_type == NULL)
2828 uiapplication->permission_type = strdup("normal");
2830 uiapplication->permission_type = strdup("normal");
2832 if (xmlTextReaderGetAttribute(reader, XMLCHAR("component-type"))) {
2833 uiapplication->component_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("component-type")));
2834 if (uiapplication->component_type == NULL)
2835 uiapplication->component_type = strdup("uiapp");
2837 uiapplication->component_type = strdup("uiapp");
2839 if (xmlTextReaderGetAttribute(reader, XMLCHAR("submode"))) {
2840 uiapplication->submode = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("submode")));
2841 if (uiapplication->submode == NULL)
2842 uiapplication->submode = strdup("false");
2844 uiapplication->submode = strdup("false");
2846 if (xmlTextReaderGetAttribute(reader, XMLCHAR("submode-mainid")))
2847 uiapplication->submode_mainid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("submode-mainid")));
2849 depth = xmlTextReaderDepth(reader);
2850 while ((ret = __next_child_element(reader, depth))) {
2851 node = xmlTextReaderConstName(reader);
2853 DBG("xmlTextReaderConstName value is NULL\n");
2856 if (!strcmp(ASCII(node), "label")) {
2857 label_x *label = malloc(sizeof(label_x));
2858 if (label == NULL) {
2859 DBG("Malloc Failed\n");
2862 memset(label, '\0', sizeof(label_x));
2863 LISTADD(uiapplication->label, label);
2864 ret = __ps_process_label(reader, label);
2865 } else if (!strcmp(ASCII(node), "icon")) {
2866 icon_x *icon = malloc(sizeof(icon_x));
2868 DBG("Malloc Failed\n");
2871 memset(icon, '\0', sizeof(icon_x));
2872 LISTADD(uiapplication->icon, icon);
2873 ret = __ps_process_icon(reader, icon);
2874 } else if (!strcmp(ASCII(node), "image")) {
2875 image_x *image = malloc(sizeof(image_x));
2876 if (image == NULL) {
2877 DBG("Malloc Failed\n");
2880 memset(image, '\0', sizeof(image_x));
2881 LISTADD(uiapplication->image, image);
2882 ret = __ps_process_image(reader, image);
2883 } else if (!strcmp(ASCII(node), "category")) {
2884 category_x *category = malloc(sizeof(category_x));
2885 if (category == NULL) {
2886 DBG("Malloc Failed\n");
2889 memset(category, '\0', sizeof(category_x));
2890 LISTADD(uiapplication->category, category);
2891 ret = __ps_process_category(reader, category);
2892 } else if (!strcmp(ASCII(node), "metadata")) {
2893 metadata_x *metadata = malloc(sizeof(metadata_x));
2894 if (metadata == NULL) {
2895 DBG("Malloc Failed\n");
2898 memset(metadata, '\0', sizeof(metadata_x));
2899 LISTADD(uiapplication->metadata, metadata);
2900 ret = __ps_process_metadata(reader, metadata);
2901 } else if (!strcmp(ASCII(node), "permission")) {
2902 permission_x *permission = malloc(sizeof(permission_x));
2903 if (permission == NULL) {
2904 DBG("Malloc Failed\n");
2907 memset(permission, '\0', sizeof(permission_x));
2908 LISTADD(uiapplication->permission, permission);
2909 ret = __ps_process_permission(reader, permission);
2910 } else if (!strcmp(ASCII(node), "app-control")) {
2911 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
2912 if (appcontrol == NULL) {
2913 DBG("Malloc Failed\n");
2916 memset(appcontrol, '\0', sizeof(appcontrol_x));
2917 LISTADD(uiapplication->appcontrol, appcontrol);
2918 ret = __ps_process_appcontrol(reader, appcontrol);
2919 } else if (!strcmp(ASCII(node), "application-service")) {
2920 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
2921 if (appsvc == NULL) {
2922 DBG("Malloc Failed\n");
2925 memset(appsvc, '\0', sizeof(appsvc_x));
2926 LISTADD(uiapplication->appsvc, appsvc);
2927 ret = __ps_process_appsvc(reader, appsvc);
2928 } else if (!strcmp(ASCII(node), "data-share")) {
2929 datashare_x *datashare = malloc(sizeof(datashare_x));
2930 if (datashare == NULL) {
2931 DBG("Malloc Failed\n");
2934 memset(datashare, '\0', sizeof(datashare_x));
2935 LISTADD(uiapplication->datashare, datashare);
2936 ret = __ps_process_datashare(reader, datashare);
2937 } else if (!strcmp(ASCII(node), "launch-conditions")) {
2938 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
2939 if (launchconditions == NULL) {
2940 DBG("Malloc Failed\n");
2943 memset(launchconditions, '\0', sizeof(launchconditions_x));
2944 LISTADD(uiapplication->launchconditions, launchconditions);
2945 ret = __ps_process_launchconditions(reader, launchconditions);
2946 } else if (!strcmp(ASCII(node), "notification")) {
2947 notification_x *notification = malloc(sizeof(notification_x));
2948 if (notification == NULL) {
2949 DBG("Malloc Failed\n");
2952 memset(notification, '\0', sizeof(notification_x));
2953 LISTADD(uiapplication->notification, notification);
2954 ret = __ps_process_notification(reader, notification);
2958 DBG("Processing uiapplication failed\n");
2963 if (uiapplication->label) {
2964 LISTHEAD(uiapplication->label, tmp1);
2965 uiapplication->label = tmp1;
2967 if (uiapplication->icon) {
2968 LISTHEAD(uiapplication->icon, tmp2);
2969 uiapplication->icon = tmp2;
2971 if (uiapplication->appsvc) {
2972 LISTHEAD(uiapplication->appsvc, tmp3);
2973 uiapplication->appsvc = tmp3;
2975 if (uiapplication->appcontrol) {
2976 LISTHEAD(uiapplication->appcontrol, tmp4);
2977 uiapplication->appcontrol = tmp4;
2979 if (uiapplication->launchconditions) {
2980 LISTHEAD(uiapplication->launchconditions, tmp5);
2981 uiapplication->launchconditions = tmp5;
2983 if (uiapplication->notification) {
2984 LISTHEAD(uiapplication->notification, tmp6);
2985 uiapplication->notification = tmp6;
2987 if (uiapplication->datashare) {
2988 LISTHEAD(uiapplication->datashare, tmp7);
2989 uiapplication->datashare = tmp7;
2991 if (uiapplication->category) {
2992 LISTHEAD(uiapplication->category, tmp8);
2993 uiapplication->category = tmp8;
2995 if (uiapplication->metadata) {
2996 LISTHEAD(uiapplication->metadata, tmp9);
2997 uiapplication->metadata = tmp9;
2999 if (uiapplication->image) {
3000 LISTHEAD(uiapplication->image, tmp10);
3001 uiapplication->image = tmp10;
3003 if (uiapplication->permission) {
3004 LISTHEAD(uiapplication->permission, tmp11);
3005 uiapplication->permission = tmp11;
3011 static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication)
3013 const xmlChar *node;
3016 char *newappid = NULL;
3017 label_x *tmp1 = NULL;
3018 icon_x *tmp2 = NULL;
3019 appsvc_x *tmp3 = NULL;
3020 appcontrol_x *tmp4 = NULL;
3021 datacontrol_x *tmp5 = NULL;
3022 launchconditions_x *tmp6 = NULL;
3023 notification_x *tmp7 = NULL;
3024 datashare_x *tmp8 = NULL;
3025 category_x *tmp9 = NULL;
3026 metadata_x *tmp10 = NULL;
3027 permission_x *tmp11 = NULL;
3029 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
3030 serviceapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
3031 if (serviceapplication->appid == NULL) {
3032 DBG("appid cant be NULL\n");
3036 DBG("appid is mandatory\n");
3040 ret = __validate_appid(package, serviceapplication->appid, &newappid);
3042 DBG("appid is not proper\n");
3046 if (serviceapplication->appid)
3047 free((void *)serviceapplication->appid);
3048 serviceapplication->appid = newappid;
3051 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
3052 serviceapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
3053 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
3054 serviceapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
3055 if (xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot"))) {
3056 serviceapplication->onboot = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot")));
3057 if (serviceapplication->onboot == NULL)
3058 serviceapplication->onboot = strdup("false");
3060 serviceapplication->onboot = strdup("false");
3062 if (xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart"))) {
3063 serviceapplication->autorestart = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart")));
3064 if (serviceapplication->autorestart == NULL)
3065 serviceapplication->autorestart = strdup("false");
3067 serviceapplication->autorestart = strdup("false");
3069 if (xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type"))) {
3070 serviceapplication->permission_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type")));
3071 if (serviceapplication->permission_type == NULL)
3072 serviceapplication->permission_type = strdup("normal");
3074 serviceapplication->permission_type = strdup("normal");
3077 depth = xmlTextReaderDepth(reader);
3078 while ((ret = __next_child_element(reader, depth))) {
3079 node = xmlTextReaderConstName(reader);
3081 DBG("xmlTextReaderConstName value is NULL\n");
3085 if (!strcmp(ASCII(node), "label")) {
3086 label_x *label = malloc(sizeof(label_x));
3087 if (label == NULL) {
3088 DBG("Malloc Failed\n");
3091 memset(label, '\0', sizeof(label_x));
3092 LISTADD(serviceapplication->label, label);
3093 ret = __ps_process_label(reader, label);
3094 } else if (!strcmp(ASCII(node), "icon")) {
3095 icon_x *icon = malloc(sizeof(icon_x));
3097 DBG("Malloc Failed\n");
3100 memset(icon, '\0', sizeof(icon_x));
3101 LISTADD(serviceapplication->icon, icon);
3102 ret = __ps_process_icon(reader, icon);
3103 } else if (!strcmp(ASCII(node), "category")) {
3104 category_x *category = malloc(sizeof(category_x));
3105 if (category == NULL) {
3106 DBG("Malloc Failed\n");
3109 memset(category, '\0', sizeof(category_x));
3110 LISTADD(serviceapplication->category, category);
3111 ret = __ps_process_category(reader, category);
3112 } else if (!strcmp(ASCII(node), "metadata")) {
3113 metadata_x *metadata = malloc(sizeof(metadata_x));
3114 if (metadata == NULL) {
3115 DBG("Malloc Failed\n");
3118 memset(metadata, '\0', sizeof(metadata_x));
3119 LISTADD(serviceapplication->metadata, metadata);
3120 ret = __ps_process_metadata(reader, metadata);
3121 } else if (!strcmp(ASCII(node), "permission")) {
3122 permission_x *permission = malloc(sizeof(permission_x));
3123 if (permission == NULL) {
3124 DBG("Malloc Failed\n");
3127 memset(permission, '\0', sizeof(permission_x));
3128 LISTADD(serviceapplication->permission, permission);
3129 ret = __ps_process_permission(reader, permission);
3130 } else if (!strcmp(ASCII(node), "app-control")) {
3131 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
3132 if (appcontrol == NULL) {
3133 DBG("Malloc Failed\n");
3136 memset(appcontrol, '\0', sizeof(appcontrol_x));
3137 LISTADD(serviceapplication->appcontrol, appcontrol);
3138 ret = __ps_process_appcontrol(reader, appcontrol);
3139 } else if (!strcmp(ASCII(node), "application-service")) {
3140 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
3141 if (appsvc == NULL) {
3142 DBG("Malloc Failed\n");
3145 memset(appsvc, '\0', sizeof(appsvc_x));
3146 LISTADD(serviceapplication->appsvc, appsvc);
3147 ret = __ps_process_appsvc(reader, appsvc);
3148 } else if (!strcmp(ASCII(node), "data-share")) {
3149 datashare_x *datashare = malloc(sizeof(datashare_x));
3150 if (datashare == NULL) {
3151 DBG("Malloc Failed\n");
3154 memset(datashare, '\0', sizeof(datashare_x));
3155 LISTADD(serviceapplication->datashare, datashare);
3156 ret = __ps_process_datashare(reader, datashare);
3157 } else if (!strcmp(ASCII(node), "launch-conditions")) {
3158 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
3159 if (launchconditions == NULL) {
3160 DBG("Malloc Failed\n");
3163 memset(launchconditions, '\0', sizeof(launchconditions_x));
3164 LISTADD(serviceapplication->launchconditions, launchconditions);
3165 ret = __ps_process_launchconditions(reader, launchconditions);
3166 } else if (!strcmp(ASCII(node), "notification")) {
3167 notification_x *notification = malloc(sizeof(notification_x));
3168 if (notification == NULL) {
3169 DBG("Malloc Failed\n");
3172 memset(notification, '\0', sizeof(notification_x));
3173 LISTADD(serviceapplication->notification, notification);
3174 ret = __ps_process_notification(reader, notification);
3175 } else if (!strcmp(ASCII(node), "data-control")) {
3176 datacontrol_x *datacontrol = malloc(sizeof(datacontrol_x));
3177 if (datacontrol == NULL) {
3178 DBG("Malloc Failed\n");
3181 memset(datacontrol, '\0', sizeof(datacontrol_x));
3182 LISTADD(serviceapplication->datacontrol, datacontrol);
3183 ret = __ps_process_datacontrol(reader, datacontrol);
3187 DBG("Processing serviceapplication failed\n");
3192 if (serviceapplication->label) {
3193 LISTHEAD(serviceapplication->label, tmp1);
3194 serviceapplication->label = tmp1;
3196 if (serviceapplication->icon) {
3197 LISTHEAD(serviceapplication->icon, tmp2);
3198 serviceapplication->icon = tmp2;
3200 if (serviceapplication->appsvc) {
3201 LISTHEAD(serviceapplication->appsvc, tmp3);
3202 serviceapplication->appsvc = tmp3;
3204 if (serviceapplication->appcontrol) {
3205 LISTHEAD(serviceapplication->appcontrol, tmp4);
3206 serviceapplication->appcontrol = tmp4;
3208 if (serviceapplication->datacontrol) {
3209 LISTHEAD(serviceapplication->datacontrol, tmp5);
3210 serviceapplication->datacontrol = tmp5;
3212 if (serviceapplication->launchconditions) {
3213 LISTHEAD(serviceapplication->launchconditions, tmp6);
3214 serviceapplication->launchconditions = tmp6;
3216 if (serviceapplication->notification) {
3217 LISTHEAD(serviceapplication->notification, tmp7);
3218 serviceapplication->notification = tmp7;
3220 if (serviceapplication->datashare) {
3221 LISTHEAD(serviceapplication->datashare, tmp8);
3222 serviceapplication->datashare = tmp8;
3224 if (serviceapplication->category) {
3225 LISTHEAD(serviceapplication->category, tmp9);
3226 serviceapplication->category = tmp9;
3228 if (serviceapplication->metadata) {
3229 LISTHEAD(serviceapplication->metadata, tmp10);
3230 serviceapplication->metadata = tmp10;
3232 if (serviceapplication->permission) {
3233 LISTHEAD(serviceapplication->permission, tmp11);
3234 serviceapplication->permission = tmp11;
3240 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile)
3242 /*TODO: once policy is set*/
3246 static int __ps_process_font(xmlTextReaderPtr reader, font_x *font)
3248 /*TODO: once policy is set*/
3252 static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme)
3254 /*TODO: once policy is set*/
3258 static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon)
3260 /*TODO: once policy is set*/
3264 static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime)
3266 /*TODO: once policy is set*/
3270 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx)
3272 DBG("__start_process\n");
3273 const xmlChar *node;
3276 label_x *tmp1 = NULL;
3277 author_x *tmp2 = NULL;
3278 description_x *tmp3 = NULL;
3279 license_x *tmp4 = NULL;
3280 uiapplication_x *tmp5 = NULL;
3281 serviceapplication_x *tmp6 = NULL;
3282 daemon_x *tmp7 = NULL;
3283 theme_x *tmp8 = NULL;
3284 font_x *tmp9 = NULL;
3285 ime_x *tmp10 = NULL;
3286 icon_x *tmp11 = NULL;
3287 compatibility_x *tmp12 = NULL;
3288 deviceprofile_x *tmp13 = NULL;
3289 privileges_x *tmp14 = NULL;
3291 depth = xmlTextReaderDepth(reader);
3292 while ((ret = __next_child_element(reader, depth))) {
3293 node = xmlTextReaderConstName(reader);
3295 DBG("xmlTextReaderConstName value is NULL\n");
3299 if (!strcmp(ASCII(node), "label")) {
3300 label_x *label = malloc(sizeof(label_x));
3301 if (label == NULL) {
3302 DBG("Malloc Failed\n");
3305 memset(label, '\0', sizeof(label_x));
3306 LISTADD(mfx->label, label);
3307 ret = __ps_process_label(reader, label);
3308 } else if (!strcmp(ASCII(node), "author")) {
3309 author_x *author = malloc(sizeof(author_x));
3310 if (author == NULL) {
3311 DBG("Malloc Failed\n");
3314 memset(author, '\0', sizeof(author_x));
3315 LISTADD(mfx->author, author);
3316 ret = __ps_process_author(reader, author);
3317 } else if (!strcmp(ASCII(node), "description")) {
3318 description_x *description = malloc(sizeof(description_x));
3319 if (description == NULL) {
3320 DBG("Malloc Failed\n");
3323 memset(description, '\0', sizeof(description_x));
3324 LISTADD(mfx->description, description);
3325 ret = __ps_process_description(reader, description);
3326 } else if (!strcmp(ASCII(node), "license")) {
3327 license_x *license = malloc(sizeof(license_x));
3328 if (license == NULL) {
3329 DBG("Malloc Failed\n");
3332 memset(license, '\0', sizeof(license_x));
3333 LISTADD(mfx->license, license);
3334 ret = __ps_process_license(reader, license);
3335 } else if (!strcmp(ASCII(node), "privileges")) {
3336 privileges_x *privileges = malloc(sizeof(privileges_x));
3337 if (privileges == NULL) {
3338 DBG("Malloc Failed\n");
3341 memset(privileges, '\0', sizeof(privileges_x));
3342 LISTADD(mfx->privileges, privileges);
3343 ret = __ps_process_privileges(reader, privileges);
3344 } else if (!strcmp(ASCII(node), "ui-application")) {
3345 uiapplication_x *uiapplication = malloc(sizeof(uiapplication_x));
3346 if (uiapplication == NULL) {
3347 DBG("Malloc Failed\n");
3350 memset(uiapplication, '\0', sizeof(uiapplication_x));
3351 LISTADD(mfx->uiapplication, uiapplication);
3352 ret = __ps_process_uiapplication(reader, uiapplication);
3353 } else if (!strcmp(ASCII(node), "service-application")) {
3354 serviceapplication_x *serviceapplication = malloc(sizeof(serviceapplication_x));
3355 if (serviceapplication == NULL) {
3356 DBG("Malloc Failed\n");
3359 memset(serviceapplication, '\0', sizeof(serviceapplication_x));
3360 LISTADD(mfx->serviceapplication, serviceapplication);
3361 ret = __ps_process_serviceapplication(reader, serviceapplication);
3362 } else if (!strcmp(ASCII(node), "daemon")) {
3363 daemon_x *daemon = malloc(sizeof(daemon_x));
3364 if (daemon == NULL) {
3365 DBG("Malloc Failed\n");
3368 memset(daemon, '\0', sizeof(daemon_x));
3369 LISTADD(mfx->daemon, daemon);
3370 ret = __ps_process_daemon(reader, daemon);
3371 } else if (!strcmp(ASCII(node), "theme")) {
3372 theme_x *theme = malloc(sizeof(theme_x));
3373 if (theme == NULL) {
3374 DBG("Malloc Failed\n");
3377 memset(theme, '\0', sizeof(theme_x));
3378 LISTADD(mfx->theme, theme);
3379 ret = __ps_process_theme(reader, theme);
3380 } else if (!strcmp(ASCII(node), "font")) {
3381 font_x *font = malloc(sizeof(font_x));
3383 DBG("Malloc Failed\n");
3386 memset(font, '\0', sizeof(font_x));
3387 LISTADD(mfx->font, font);
3388 ret = __ps_process_font(reader, font);
3389 } else if (!strcmp(ASCII(node), "ime")) {
3390 ime_x *ime = malloc(sizeof(ime_x));
3392 DBG("Malloc Failed\n");
3395 memset(ime, '\0', sizeof(ime_x));
3396 LISTADD(mfx->ime, ime);
3397 ret = __ps_process_ime(reader, ime);
3398 } else if (!strcmp(ASCII(node), "icon")) {
3399 icon_x *icon = malloc(sizeof(icon_x));
3401 DBG("Malloc Failed\n");
3404 memset(icon, '\0', sizeof(icon_x));
3405 LISTADD(mfx->icon, icon);
3406 ret = __ps_process_icon(reader, icon);
3407 } else if (!strcmp(ASCII(node), "device-profile")) {
3408 deviceprofile_x *deviceprofile = malloc(sizeof(deviceprofile_x));
3409 if (deviceprofile == NULL) {
3410 DBG("Malloc Failed\n");
3413 memset(deviceprofile, '\0', sizeof(deviceprofile_x));
3414 LISTADD(mfx->deviceprofile, deviceprofile);
3415 ret = __ps_process_deviceprofile(reader, deviceprofile);
3416 } else if (!strcmp(ASCII(node), "compatibility")) {
3417 compatibility_x *compatibility = malloc(sizeof(compatibility_x));
3418 if (compatibility == NULL) {
3419 DBG("Malloc Failed\n");
3422 memset(compatibility, '\0', sizeof(compatibility_x));
3423 LISTADD(mfx->compatibility, compatibility);
3424 ret = __ps_process_compatibility(reader, compatibility);
3425 } else if (!strcmp(ASCII(node), "shortcut-list")) {
3427 } else if (!strcmp(ASCII(node), "livebox")) {
3429 } else if (!strcmp(ASCII(node), "account")) {
3431 } else if (!strcmp(ASCII(node), "notifications")) {
3433 } else if (!strcmp(ASCII(node), "ime")) {
3439 DBG("Processing manifest failed\n");
3444 LISTHEAD(mfx->label, tmp1);
3448 LISTHEAD(mfx->author, tmp2);
3451 if (mfx->description) {
3452 LISTHEAD(mfx->description, tmp3);
3453 mfx->description= tmp3;
3456 LISTHEAD(mfx->license, tmp4);
3459 if (mfx->uiapplication) {
3460 LISTHEAD(mfx->uiapplication, tmp5);
3461 mfx->uiapplication = tmp5;
3463 if (mfx->serviceapplication) {
3464 LISTHEAD(mfx->serviceapplication, tmp6);
3465 mfx->serviceapplication = tmp6;
3468 LISTHEAD(mfx->daemon, tmp7);
3472 LISTHEAD(mfx->theme, tmp8);
3476 LISTHEAD(mfx->font, tmp9);
3480 LISTHEAD(mfx->ime, tmp10);
3484 LISTHEAD(mfx->icon, tmp11);
3487 if (mfx->compatibility) {
3488 LISTHEAD(mfx->compatibility, tmp12);
3489 mfx->compatibility= tmp12;
3491 if (mfx->deviceprofile) {
3492 LISTHEAD(mfx->deviceprofile, tmp13);
3493 mfx->deviceprofile= tmp13;
3495 if (mfx->privileges) {
3496 LISTHEAD(mfx->privileges, tmp14);
3497 mfx->privileges = tmp14;
3502 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx)
3504 const xmlChar *node;
3507 if ((ret = __next_child_element(reader, -1))) {
3508 node = xmlTextReaderConstName(reader);
3510 DBG("xmlTextReaderConstName value is NULL\n");
3514 if (!strcmp(ASCII(node), "manifest")) {
3515 if (xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")))
3516 mfx->ns = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")));
3517 if (xmlTextReaderGetAttribute(reader, XMLCHAR("package"))) {
3518 mfx->package= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("package")));
3519 if (mfx->package == NULL) {
3520 DBG("package cant be NULL\n");
3524 DBG("package field is mandatory\n");
3527 package = mfx->package;
3528 if (xmlTextReaderGetAttribute(reader, XMLCHAR("version")))
3529 mfx->version= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("version")));
3530 /*app2ext needs package size for external installation*/
3531 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
3532 mfx->package_size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
3533 if (xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")))
3534 mfx->installlocation = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")));
3535 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
3536 mfx->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
3537 if (xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")))
3538 mfx->root_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")));
3539 if (xmlTextReaderGetAttribute(reader, XMLCHAR("csc_path")))
3540 mfx->csc_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("csc_path")));
3541 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting"))) {
3542 mfx->appsetting = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting")));
3543 if (mfx->appsetting == NULL)
3544 mfx->appsetting = strdup("false");
3546 mfx->appsetting = strdup("false");
3548 if (xmlTextReaderGetAttribute(reader, XMLCHAR("storeclient-id")))
3549 mfx->storeclient_id= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("storeclient-id")));
3550 if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay-setting"))) {
3551 mfx->nodisplay_setting = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay-setting")));
3552 if (mfx->nodisplay_setting == NULL)
3553 mfx->nodisplay_setting = strdup("false");
3555 mfx->nodisplay_setting = strdup("false");
3557 if (xmlTextReaderGetAttribute(reader, XMLCHAR("url")))
3558 mfx->package_url= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("url")));
3560 /*Assign default values. If required it will be overwritten in __add_preload_info()*/
3561 mfx->preload = strdup("False");
3562 mfx->removable = strdup("True");
3563 mfx->readonly = strdup("False");
3564 mfx->update = strdup("False");
3565 char buf[PKG_STRING_LEN_MAX] = {'\0'};
3567 time_t current_time;
3568 time(¤t_time);
3569 snprintf(buf, PKG_STRING_LEN_MAX - 1, "%d", current_time);
3570 val = strndup(buf, PKG_STRING_LEN_MAX - 1);
3571 mfx->installed_time = val;
3573 mfx->installed_storage= strdup("installed_internal");
3575 ret = __start_process(reader, mfx);
3577 DBG("No Manifest element found\n");
3584 #define DESKTOP_RW_PATH "/opt/share/applications/"
3585 #define DESKTOP_RO_PATH "/usr/share/applications/"
3586 #define MANIFEST_RO_PREFIX "/usr/share/packages/"
3588 static char* __convert_to_system_locale(const char *mlocale)
3590 if (mlocale == NULL)
3592 char *locale = NULL;
3593 locale = (char *)calloc(1, 6);
3595 DBGE("Malloc Failed\n");
3599 strncpy(locale, mlocale, 2);
3600 strncat(locale, "_", 1);
3601 locale[3] = toupper(mlocale[3]);
3602 locale[4] = toupper(mlocale[4]);
3606 #define LIBAIL_PATH "/usr/lib/libail.so.0"
3608 /* operation_type */
3617 static int __ail_change_info(int op, const char *appid)
3619 void *lib_handle = NULL;
3620 int (*ail_desktop_operation) (const char *);
3624 if ((lib_handle = dlopen(LIBAIL_PATH, RTLD_LAZY)) == NULL) {
3625 DBGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAIL_PATH);
3632 aop = "ail_desktop_add";
3635 aop = "ail_desktop_update";
3638 aop = "ail_desktop_remove";
3641 aop = "ail_desktop_clean";
3648 if ((ail_desktop_operation =
3649 dlsym(lib_handle, aop)) == NULL || dlerror() != NULL) {
3650 DBGE("can not find symbol \n");
3654 ret = ail_desktop_operation(appid);
3658 dlclose(lib_handle);
3664 /* desktop shoud be generated automatically based on manifest */
3665 /* Currently removable, taskmanage, etc fields are not considerd. it will be decided soon.*/
3666 #define BUFMAX 1024*128
3667 static int __ps_make_nativeapp_desktop(manifest_x * mfx, const char *manifest, bool is_update)
3671 char filepath[PKG_STRING_LEN_MAX] = "";
3673 char *buftemp = NULL;
3674 char *locale = NULL;
3676 buf = (char *)calloc(1, BUFMAX);
3678 DBGE("Malloc Failed\n");
3682 buftemp = (char *)calloc(1, BUFMAX);
3684 DBGE("Malloc Failed\n");
3690 __ail_change_info(AIL_CLEAN, mfx->package);
3692 for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) {
3694 if (manifest != NULL) {
3695 /* skip making a deskfile and update ail, if preload app is updated */
3696 if(strstr(manifest, MANIFEST_RO_PREFIX)) {
3697 __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid);
3698 DBGE("preload app is update : skip and update ail : %s", manifest);
3703 if(mfx->readonly && !strcasecmp(mfx->readonly, "True"))
3704 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RO_PATH, mfx->uiapplication->appid);
3706 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, mfx->uiapplication->appid);
3708 /* skip if desktop exists
3709 if (access(filepath, R_OK) == 0)
3713 file = fopen(filepath, "w");
3716 DBGE("Can't open %s", filepath);
3722 snprintf(buf, BUFMAX, "[Desktop Entry]\n");
3723 fwrite(buf, 1, strlen(buf), file);
3725 for( ; mfx->uiapplication->label ; mfx->uiapplication->label = mfx->uiapplication->label->next) {
3726 if(!strcmp(mfx->uiapplication->label->lang, DEFAULT_LOCALE)) {
3727 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
3729 locale = __convert_to_system_locale(mfx->uiapplication->label->lang);
3730 snprintf(buf, BUFMAX, "Name[%s]=%s\n", locale,
3731 mfx->uiapplication->label->text);
3734 fwrite(buf, 1, strlen(buf), file);
3737 if(mfx->uiapplication->label && mfx->uiapplication->label->text) {
3738 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
3739 fwrite(buf, 1, strlen(buf), file);
3742 else if(mfx->label && mfx->label->text) {
3743 snprintf(buf, BUFMAX, "Name=%s\n", mfx->label->text);
3744 fwrite(buf, 1, strlen(buf), file);
3746 snprintf(buf, BUFMAX, "Name=%s\n", mfx->package);
3747 fwrite(buf, 1, strlen(buf), file);
3752 snprintf(buf, BUFMAX, "Type=Application\n");
3753 fwrite(buf, 1, strlen(buf), file);
3755 if(mfx->uiapplication->exec) {
3756 snprintf(buf, BUFMAX, "Exec=%s\n", mfx->uiapplication->exec);
3757 fwrite(buf, 1, strlen(buf), file);
3760 if(mfx->uiapplication->icon && mfx->uiapplication->icon->text) {
3761 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->uiapplication->icon->text);
3762 fwrite(buf, 1, strlen(buf), file);
3763 } else if(mfx->icon && mfx->icon->text) {
3764 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->icon->text);
3765 fwrite(buf, 1, strlen(buf), file);
3769 if(mfx->uiapplication && mfx->uiapplication->appsvc) {
3770 appsvc_x *asvc = mfx->uiapplication->appsvc;
3772 const char *mime = NULL;
3773 const char *mime_delim = "; ";
3776 strncpy(buf, "MimeType=", BUFMAX-1);
3782 DBG("MIME type: %s\n", mime);
3783 strncat(buf, mime, BUFMAX-strlen(buf)-1);
3785 strncat(buf, mime_delim, BUFMAX-strlen(buf)-1);
3793 DBG("MIME types: buf[%s]\n", buf);
3794 DBG("MIME count: %d\n", mime_count);
3796 fwrite(buf, 1, strlen(buf), file);
3800 snprintf(buf, BUFMAX, "Version=%s\n", mfx->version);
3801 fwrite(buf, 1, strlen(buf), file);
3804 if(mfx->uiapplication->nodisplay) {
3805 snprintf(buf, BUFMAX, "NoDisplay=%s\n", mfx->uiapplication->nodisplay);
3806 fwrite(buf, 1, strlen(buf), file);
3809 if(mfx->uiapplication->categories) {
3810 snprintf(buf, BUFMAX, "Categories=%s\n", mfx->uiapplication->categories);
3811 fwrite(buf, 1, strlen(buf), file);
3814 if(mfx->uiapplication->taskmanage && !strcasecmp(mfx->uiapplication->taskmanage, "False")) {
3815 snprintf(buf, BUFMAX, "X-TIZEN-TaskManage=False\n");
3816 fwrite(buf, 1, strlen(buf), file);
3819 if(mfx->uiapplication->enabled && !strcasecmp(mfx->uiapplication->enabled, "False")) {
3820 snprintf(buf, BUFMAX, "X-TIZEN-Enabled=False\n");
3821 fwrite(buf, 1, strlen(buf), file);
3824 if(mfx->uiapplication->hwacceleration) {
3825 snprintf(buf, BUFMAX, "Hw-Acceleration=%s\n", mfx->uiapplication->hwacceleration);
3826 fwrite(buf, 1, strlen(buf), file);
3829 if(mfx->uiapplication->multiple && !strcasecmp(mfx->uiapplication->multiple, "True")) {
3830 snprintf(buf, BUFMAX, "X-TIZEN-Multiple=True\n");
3831 fwrite(buf, 1, strlen(buf), file);
3834 if(mfx->uiapplication->extraid) {
3835 snprintf(buf, BUFMAX, "X-TIZEN-PackageID=%s\n", mfx->uiapplication->extraid);
3836 fwrite(buf, 1, strlen(buf), file);
3839 if(mfx->removable && !strcasecmp(mfx->removable, "False")) {
3840 snprintf(buf, BUFMAX, "X-TIZEN-Removable=False\n");
3841 fwrite(buf, 1, strlen(buf), file);
3845 snprintf(buf, BUFMAX, "X-TIZEN-PackageType=%s\n", mfx->type);
3846 fwrite(buf, 1, strlen(buf), file);
3849 snprintf(buf, BUFMAX, "X-TIZEN-PkgID=%s\n", mfx->package);
3850 fwrite(buf, 1, strlen(buf), file);
3853 // snprintf(buf, BUFMAX, "X-TIZEN-PackageType=rpm\n");
3854 // fwrite(buf, 1, strlen(buf), file);
3857 if(mfx->uiapplication->appsvc) {
3858 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
3859 DBG("buf[%s]\n", buf);
3862 uiapplication_x *up = mfx->uiapplication;
3863 appsvc_x *asvc = NULL;
3864 operation_x *op = NULL;
3867 subapp_x *sub = NULL;
3868 const char *operation = NULL;
3869 const char *mime = NULL;
3870 const char *uri = NULL;
3871 const char *subapp = NULL;
3876 while(asvc != NULL) {
3877 op = asvc->operation;
3880 operation = op->name;
3899 strncpy(buftemp, buf, BUFMAX);
3900 snprintf(buf, BUFMAX, "%s;", buftemp);
3904 strncpy(buftemp, buf, BUFMAX);
3905 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
3906 DBG("buf[%s]\n", buf);
3911 } while(ui != NULL);
3915 }while(sub != NULL);
3928 fwrite(buf, 1, strlen(buf), file);
3930 // strncpy(buftemp, buf, BUFMAX);
3931 // snprintf(buf, BUFMAX, "%s\n", buftemp);
3932 // fwrite(buf, 1, strlen(buf), file);
3935 if(mfx->uiapplication->appcontrol) {
3936 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
3937 DBG("buf[%s]\n", buf);
3939 uiapplication_x *up = mfx->uiapplication;
3940 appcontrol_x *acontrol = NULL;
3941 operation_x *op = NULL;
3944 subapp_x *sub = NULL;
3945 const char *operation = NULL;
3946 const char *mime = NULL;
3947 const char *uri = NULL;
3948 const char *subapp = NULL;
3951 acontrol = up->appcontrol;
3952 while(acontrol != NULL) {
3953 op = acontrol->operation;
3956 operation = op->name;
3957 mi = acontrol->mime;
3963 sub = acontrol->subapp;
3975 strncpy(buftemp, buf, BUFMAX);
3976 snprintf(buf, BUFMAX, "%s;", buftemp);
3979 strncpy(buftemp, buf, BUFMAX);
3980 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
3981 DBG("buf[%s]\n", buf);
3986 } while(ui != NULL);
3990 }while(sub != NULL);
3999 acontrol = acontrol->next;
4003 fwrite(buf, 1, strlen(buf), file);
4005 // strncpy(buftemp, buf, BUFMAX);
4006 // snprintf(buf, BUFMAX, "%s\n", buftemp);
4007 // fwrite(buf, 1, strlen(buf), file);
4015 __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid);
4024 static int __ps_remove_nativeapp_desktop(manifest_x *mfx)
4026 char filepath[PKG_STRING_LEN_MAX] = "";
4028 uiapplication_x *uiapplication = mfx->uiapplication;
4030 for(; uiapplication; uiapplication=uiapplication->next) {
4031 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, uiapplication->appid);
4033 __ail_change_info(AIL_REMOVE, uiapplication->appid);
4035 ret = remove(filepath);
4043 #define LIBAPPSVC_PATH "/usr/lib/libappsvc.so.0"
4045 static int __ps_remove_appsvc_db(manifest_x *mfx)
4047 void *lib_handle = NULL;
4048 int (*appsvc_operation) (const char *);
4050 uiapplication_x *uiapplication = mfx->uiapplication;
4052 if ((lib_handle = dlopen(LIBAPPSVC_PATH, RTLD_LAZY)) == NULL) {
4053 DBGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAPPSVC_PATH);
4057 if ((appsvc_operation =
4058 dlsym(lib_handle, "appsvc_unset_defapp")) == NULL || dlerror() != NULL) {
4059 DBGE("can not find symbol \n");
4063 for(; uiapplication; uiapplication=uiapplication->next) {
4064 ret = appsvc_operation(uiapplication->appid);
4066 DBGE("can not operation symbol \n");
4071 dlclose(lib_handle);
4076 #define PRELOAD_PACKAGE_LIST "/usr/etc/package-manager/preload/preload_list.txt"
4077 static int __add_preload_info(manifest_x * mfx, const char *manifest)
4080 char buffer[1024] = { 0 };
4083 if(strstr(manifest, MANIFEST_RO_PREFIX)) {
4084 free((void *)mfx->readonly);
4085 mfx->readonly = strdup("True");
4087 free((void *)mfx->preload);
4088 mfx->preload = strdup("True");
4090 free((void *)mfx->removable);
4091 mfx->removable = strdup("False");
4096 fp = fopen(PRELOAD_PACKAGE_LIST, "r");
4098 DBGE("no preload list\n");
4102 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
4103 if (buffer[0] == '#') {
4104 if(strcasestr(buffer, "RW_NORM"))
4106 else if(strcasestr(buffer, "RW_RM"))
4114 if(!strcmp(mfx->package, buffer)) {
4115 free((void *)mfx->preload);
4116 mfx->preload = strdup("True");
4118 free((void *)mfx->readonly);
4119 mfx->readonly = strdup("False");
4120 free((void *)mfx->removable);
4121 mfx->removable = strdup("False");
4122 } else if(state == 3){
4123 free((void *)mfx->readonly);
4124 mfx->readonly = strdup("False");
4125 free((void *)mfx->removable);
4126 mfx->removable = strdup("True");
4130 memset(buffer, 0x00, sizeof(buffer));
4139 static int __check_preload_updated(manifest_x * mfx, const char *manifest)
4141 char filepath[PKG_STRING_LEN_MAX] = "";
4143 uiapplication_x *uiapplication = mfx->uiapplication;
4145 if(strstr(manifest, MANIFEST_RO_PREFIX)) {
4146 /* if preload app is updated, then remove previous desktop file on RW*/
4147 for(; uiapplication; uiapplication=uiapplication->next) {
4148 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, uiapplication->appid);
4149 ret = remove(filepath);
4154 /* if downloaded app is updated, then update tag set true*/
4155 free((void *)mfx->update);
4156 mfx->update = strdup("true");
4163 API int pkgmgr_parser_create_desktop_file(manifest_x *mfx)
4167 DBG("Manifest pointer is NULL\n");
4170 ret = __ps_make_nativeapp_desktop(mfx, NULL, 0);
4172 DBG("Creating desktop file failed\n");
4174 DBG("Creating desktop file Success\n");
4178 API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
4183 free((void *)mfx->ns);
4187 free((void *)mfx->package);
4188 mfx->package = NULL;
4191 free((void *)mfx->version);
4192 mfx->version = NULL;
4194 if (mfx->installlocation) {
4195 free((void *)mfx->installlocation);
4196 mfx->installlocation = NULL;
4199 free((void *)mfx->preload);
4200 mfx->preload = NULL;
4202 if (mfx->readonly) {
4203 free((void *)mfx->readonly);
4204 mfx->readonly = NULL;
4206 if (mfx->removable) {
4207 free((void *)mfx->removable);
4208 mfx->removable = NULL;
4211 free((void *)mfx->update);
4215 free((void *)mfx->type);
4218 if (mfx->package_size) {
4219 free((void *)mfx->package_size);
4220 mfx->package_size = NULL;
4222 if (mfx->installed_time) {
4223 free((void *)mfx->installed_time);
4224 mfx->installed_time = NULL;
4226 if (mfx->installed_storage) {
4227 free((void *)mfx->installed_storage);
4228 mfx->installed_storage = NULL;
4230 if (mfx->storeclient_id) {
4231 free((void *)mfx->storeclient_id);
4232 mfx->storeclient_id = NULL;
4234 if (mfx->mainapp_id) {
4235 free((void *)mfx->mainapp_id);
4236 mfx->mainapp_id = NULL;
4238 if (mfx->package_url) {
4239 free((void *)mfx->package_url);
4240 mfx->package_url = NULL;
4242 if (mfx->root_path) {
4243 free((void *)mfx->root_path);
4244 mfx->root_path = NULL;
4246 if (mfx->csc_path) {
4247 free((void *)mfx->csc_path);
4248 mfx->csc_path = NULL;
4250 if (mfx->appsetting) {
4251 free((void *)mfx->appsetting);
4252 mfx->appsetting = NULL;
4254 if (mfx->nodisplay_setting) {
4255 free((void *)mfx->nodisplay_setting);
4256 mfx->nodisplay_setting = NULL;
4261 icon_x *icon = mfx->icon;
4263 while(icon != NULL) {
4265 __ps_free_icon(icon);
4271 label_x *label = mfx->label;
4272 label_x *tmp = NULL;
4273 while(label != NULL) {
4275 __ps_free_label(label);
4281 author_x *author = mfx->author;
4282 author_x *tmp = NULL;
4283 while(author != NULL) {
4285 __ps_free_author(author);
4289 /*Free Description*/
4290 if (mfx->description) {
4291 description_x *description = mfx->description;
4292 description_x *tmp = NULL;
4293 while(description != NULL) {
4294 tmp = description->next;
4295 __ps_free_description(description);
4301 license_x *license = mfx->license;
4302 license_x *tmp = NULL;
4303 while(license != NULL) {
4304 tmp = license->next;
4305 __ps_free_license(license);
4310 if (mfx->privileges) {
4311 privileges_x *privileges = mfx->privileges;
4312 privileges_x *tmp = NULL;
4313 while(privileges != NULL) {
4314 tmp = privileges->next;
4315 __ps_free_privileges(privileges);
4319 /*Free UiApplication*/
4320 if (mfx->uiapplication) {
4321 uiapplication_x *uiapplication = mfx->uiapplication;
4322 uiapplication_x *tmp = NULL;
4323 while(uiapplication != NULL) {
4324 tmp = uiapplication->next;
4325 __ps_free_uiapplication(uiapplication);
4326 uiapplication = tmp;
4329 /*Free ServiceApplication*/
4330 if (mfx->serviceapplication) {
4331 serviceapplication_x *serviceapplication = mfx->serviceapplication;
4332 serviceapplication_x *tmp = NULL;
4333 while(serviceapplication != NULL) {
4334 tmp = serviceapplication->next;
4335 __ps_free_serviceapplication(serviceapplication);
4336 serviceapplication = tmp;
4341 daemon_x *daemon = mfx->daemon;
4342 daemon_x *tmp = NULL;
4343 while(daemon != NULL) {
4345 __ps_free_daemon(daemon);
4351 theme_x *theme = mfx->theme;
4352 theme_x *tmp = NULL;
4353 while(theme != NULL) {
4355 __ps_free_theme(theme);
4361 font_x *font = mfx->font;
4363 while(font != NULL) {
4365 __ps_free_font(font);
4371 ime_x *ime = mfx->ime;
4373 while(ime != NULL) {
4379 /*Free Compatibility*/
4380 if (mfx->compatibility) {
4381 compatibility_x *compatibility = mfx->compatibility;
4382 compatibility_x *tmp = NULL;
4383 while(compatibility != NULL) {
4384 tmp = compatibility->next;
4385 __ps_free_compatibility(compatibility);
4386 compatibility = tmp;
4389 /*Free DeviceProfile*/
4390 if (mfx->deviceprofile) {
4391 deviceprofile_x *deviceprofile = mfx->deviceprofile;
4392 deviceprofile_x *tmp = NULL;
4393 while(deviceprofile != NULL) {
4394 tmp = deviceprofile->next;
4395 __ps_free_deviceprofile(deviceprofile);
4396 deviceprofile = tmp;
4404 API manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest)
4406 DBG("parsing start\n");
4407 xmlTextReaderPtr reader;
4408 manifest_x *mfx = NULL;
4410 reader = xmlReaderForFile(manifest, NULL, 0);
4412 mfx = malloc(sizeof(manifest_x));
4414 memset(mfx, '\0', sizeof(manifest_x));
4415 if (__process_manifest(reader, mfx) < 0) {
4416 DBG("Parsing Failed\n");
4417 pkgmgr_parser_free_manifest_xml(mfx);
4420 DBG("Parsing Success\n");
4422 DBG("Memory allocation error\n");
4424 xmlFreeTextReader(reader);
4426 DBG("Unable to create xml reader\n");
4431 /* These APIs are intended to call parser directly */
4433 API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
4435 char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
4436 if (manifest == NULL) {
4437 DBG("argument supplied is NULL\n");
4438 return PMINFO_R_EINVAL;
4440 DBG("parsing manifest for installation: %s\n", manifest);
4441 manifest_x *mfx = NULL;
4443 char roxml_check[PKG_STRING_LEN_MAX] = {'\0'};
4446 mfx = pkgmgr_parser_process_manifest_xml(manifest);
4447 DBG("Parsing Finished\n");
4449 return PMINFO_R_ERROR;
4451 __streamFile(manifest, ACTION_INSTALL, temp, mfx->package);
4452 __add_preload_info(mfx, manifest);
4453 DBG("Added preload infomation\n");
4455 __ps_process_tag(mfx, tagv);
4457 ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
4459 DBG("DB Insert failed\n");
4461 DBG("DB Insert Success\n");
4463 ret = __ps_process_mdparser(mfx, ACTION_INSTALL);
4465 DBG("Creating metadata parser failed\n");
4467 ret = __ps_make_nativeapp_desktop(mfx, NULL, 0);
4469 DBG("Creating desktop file failed\n");
4471 DBG("Creating desktop file Success\n");
4473 pkgmgr_parser_free_manifest_xml(mfx);
4480 API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
4482 char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
4483 if (manifest == NULL) {
4484 DBG("argument supplied is NULL\n");
4485 return PMINFO_R_EINVAL;
4487 DBG("parsing manifest for upgradation: %s\n", manifest);
4488 manifest_x *mfx = NULL;
4490 bool preload = false;
4491 char *csc_path = NULL;
4492 pkgmgrinfo_pkginfo_h handle = NULL;
4495 mfx = pkgmgr_parser_process_manifest_xml(manifest);
4496 DBG("Parsing Finished\n");
4498 return PMINFO_R_ERROR;
4500 __streamFile(manifest, ACTION_UPGRADE, temp, mfx->package);
4501 __add_preload_info(mfx, manifest);
4502 DBG("Added preload infomation\n");
4503 __check_preload_updated(mfx, manifest);
4505 ret = pkgmgrinfo_pkginfo_get_pkginfo(mfx->package, &handle);
4506 if (ret != PMINFO_R_OK)
4507 DBG("pkgmgrinfo_pkginfo_get_pkginfo failed\n");
4509 ret = pkgmgrinfo_pkginfo_is_preload(handle, &preload);
4510 if (ret != PMINFO_R_OK)
4511 DBG("pkgmgrinfo_pkginfo_is_preload failed\n");
4514 free((void *)mfx->preload);
4515 mfx->preload = strdup("true");
4518 ret = pkgmgrinfo_pkginfo_get_csc_path(handle, &csc_path);
4519 if (ret != PMINFO_R_OK)
4520 DBG("pkgmgrinfo_pkginfo_get_csc_path failed\n");
4522 if (csc_path != NULL) {
4524 free((void *)mfx->csc_path);
4525 mfx->csc_path = strdup(csc_path);
4528 ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
4530 DBG("DB Update failed\n");
4532 DBG("DB Update Success\n");
4534 ret = __ps_process_mdparser(mfx, ACTION_UPGRADE);
4536 DBG("Upgrade metadata parser failed\n");
4538 ret = __ps_make_nativeapp_desktop(mfx, manifest, 1);
4540 DBG("Creating desktop file failed\n");
4542 DBG("Creating desktop file Success\n");
4544 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
4545 pkgmgr_parser_free_manifest_xml(mfx);
4552 API int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[])
4554 char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
4555 if (manifest == NULL) {
4556 DBG("argument supplied is NULL\n");
4557 return PMINFO_R_EINVAL;
4559 DBG("parsing manifest for uninstallation: %s\n", manifest);
4560 manifest_x *mfx = NULL;
4563 mfx = pkgmgr_parser_process_manifest_xml(manifest);
4564 DBG("Parsing Finished\n");
4566 return PMINFO_R_ERROR;
4568 __streamFile(manifest, ACTION_UNINSTALL, temp, mfx->package);
4569 __add_preload_info(mfx, manifest);
4570 DBG("Added preload infomation\n");
4572 ret = __ps_process_mdparser(mfx, ACTION_UNINSTALL);
4574 DBG("Removing metadata parser failed\n");
4576 ret = pkgmgr_parser_delete_manifest_info_from_db(mfx);
4578 DBG("DB Delete failed\n");
4580 DBG("DB Delete Success\n");
4582 ret = __ps_remove_nativeapp_desktop(mfx);
4584 DBG("Removing desktop file failed\n");
4586 DBG("Removing desktop file Success\n");
4588 ret = __ps_remove_appsvc_db(mfx);
4590 DBG("Removing appsvc_db failed\n");
4592 DBG("Removing appsvc_db Success\n");
4594 pkgmgr_parser_free_manifest_xml(mfx);
4601 API int pkgmgr_parser_parse_manifest_for_preload()
4603 return pkgmgr_parser_update_preload_info_in_db();
4606 API char *pkgmgr_parser_get_manifest_file(const char *pkgid)
4608 return __pkgid_to_manifest(pkgid);
4611 API int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
4613 return __ps_run_parser(docPtr, tag, ACTION_INSTALL, pkgid);
4616 API int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgid)
4618 return __ps_run_parser(docPtr, tag, ACTION_UPGRADE, pkgid);
4621 API int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
4623 return __ps_run_parser(docPtr, tag, ACTION_UNINSTALL, pkgid);
4626 #define SCHEMA_FILE "/usr/etc/package-manager/preload/manifest.xsd"
4628 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
4630 if (manifest == NULL) {
4631 DBGE("manifest file is NULL\n");
4632 return PMINFO_R_EINVAL;
4635 xmlSchemaParserCtxtPtr ctx;
4636 xmlSchemaValidCtxtPtr vctx;
4637 xmlSchemaPtr xschema;
4638 ctx = xmlSchemaNewParserCtxt(SCHEMA_FILE);
4640 DBGE("xmlSchemaNewParserCtxt() Failed\n");
4641 return PMINFO_R_ERROR;
4643 xschema = xmlSchemaParse(ctx);
4644 if (xschema == NULL) {
4645 DBGE("xmlSchemaParse() Failed\n");
4646 return PMINFO_R_ERROR;
4648 vctx = xmlSchemaNewValidCtxt(xschema);
4650 DBGE("xmlSchemaNewValidCtxt() Failed\n");
4651 return PMINFO_R_ERROR;
4653 xmlSchemaSetValidErrors(vctx, (xmlSchemaValidityErrorFunc) fprintf, (xmlSchemaValidityWarningFunc) fprintf, stderr);
4654 ret = xmlSchemaValidateFile(vctx, manifest, 0);
4656 DBGE("xmlSchemaValidateFile() failed\n");
4657 return PMINFO_R_ERROR;
4658 } else if (ret == 0) {
4659 DBGE("Manifest is Valid\n");
4662 DBGE("Manifest Validation Failed with error code %d\n", ret);
4663 return PMINFO_R_ERROR;
4669 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
4679 DBGE("fork failed\n");
4684 int dev_null_fd = open ("/dev/null", O_RDWR);
4685 if (dev_null_fd >= 0)
4687 dup2 (dev_null_fd, 0);/*stdin*/
4688 dup2 (dev_null_fd, 1);/*stdout*/
4689 dup2 (dev_null_fd, 2);/*stderr*/
4692 if (execl("/usr/bin/xmllint", "xmllint", manifest, "--schema",
4693 SCHEMA_FILE, NULL) < 0) {
4694 DBGE("execl error\n");
4704 while ((err = waitpid(pid, &status, WNOHANG)) != pid) {
4708 DBGE("waitpid failed\n");
4714 if(WIFEXITED(status) && !WEXITSTATUS(status))