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->mainapp) {
1444 free((void *)uiapplication->mainapp);
1445 uiapplication->mainapp = NULL;
1447 if (uiapplication->recentimage) {
1448 free((void *)uiapplication->recentimage);
1449 uiapplication->recentimage = NULL;
1451 if (uiapplication->package) {
1452 free((void *)uiapplication->package);
1453 uiapplication->package = NULL;
1455 if (uiapplication->launchcondition) {
1456 free((void *)uiapplication->launchcondition);
1457 uiapplication->launchcondition = NULL;
1460 if (uiapplication->label) {
1461 label_x *label = uiapplication->label;
1462 label_x *tmp = NULL;
1463 while(label != NULL) {
1465 __ps_free_label(label);
1470 if (uiapplication->icon) {
1471 icon_x *icon = uiapplication->icon;
1473 while(icon != NULL) {
1475 __ps_free_icon(icon);
1480 if (uiapplication->image) {
1481 image_x *image = uiapplication->image;
1482 image_x *tmp = NULL;
1483 while(image != NULL) {
1485 __ps_free_image(image);
1490 if (uiapplication->appcontrol) {
1491 appcontrol_x *appcontrol = uiapplication->appcontrol;
1492 appcontrol_x *tmp = NULL;
1493 while(appcontrol != NULL) {
1494 tmp = appcontrol->next;
1495 __ps_free_appcontrol(appcontrol);
1499 /*Free LaunchConditions*/
1500 if (uiapplication->launchconditions) {
1501 launchconditions_x *launchconditions = uiapplication->launchconditions;
1502 launchconditions_x *tmp = NULL;
1503 while(launchconditions != NULL) {
1504 tmp = launchconditions->next;
1505 __ps_free_launchconditions(launchconditions);
1506 launchconditions = tmp;
1509 /*Free Notification*/
1510 if (uiapplication->notification) {
1511 notification_x *notification = uiapplication->notification;
1512 notification_x *tmp = NULL;
1513 while(notification != NULL) {
1514 tmp = notification->next;
1515 __ps_free_notification(notification);
1520 if (uiapplication->datashare) {
1521 datashare_x *datashare = uiapplication->datashare;
1522 datashare_x *tmp = NULL;
1523 while(datashare != NULL) {
1524 tmp = datashare->next;
1525 __ps_free_datashare(datashare);
1530 if (uiapplication->appsvc) {
1531 appsvc_x *appsvc = uiapplication->appsvc;
1532 appsvc_x *tmp = NULL;
1533 while(appsvc != NULL) {
1535 __ps_free_appsvc(appsvc);
1540 if (uiapplication->category) {
1541 category_x *category = uiapplication->category;
1542 category_x *tmp = NULL;
1543 while(category != NULL) {
1544 tmp = category->next;
1545 __ps_free_category(category);
1550 if (uiapplication->metadata) {
1551 metadata_x *metadata = uiapplication->metadata;
1552 metadata_x *tmp = NULL;
1553 while(metadata != NULL) {
1554 tmp = metadata->next;
1555 __ps_free_metadata(metadata);
1560 if (uiapplication->permission) {
1561 permission_x *permission = uiapplication->permission;
1562 permission_x *tmp = NULL;
1563 while(permission != NULL) {
1564 tmp = permission->next;
1565 __ps_free_permission(permission);
1569 /* _PRODUCT_LAUNCHING_ENHANCED_ START */
1570 if (uiapplication->indicatordisplay) {
1571 free((void *)uiapplication->indicatordisplay);
1572 uiapplication->indicatordisplay = NULL;
1574 if (uiapplication->portraitimg) {
1575 free((void *)uiapplication->portraitimg);
1576 uiapplication->portraitimg = NULL;
1578 if (uiapplication->landscapeimg) {
1579 free((void *)uiapplication->landscapeimg);
1580 uiapplication->landscapeimg = NULL;
1582 /* _PRODUCT_LAUNCHING_ENHANCED_ END */
1583 if (uiapplication->guestmode_visibility) {
1584 free((void *)uiapplication->guestmode_visibility);
1585 uiapplication->guestmode_visibility = NULL;
1587 if (uiapplication->app_component) {
1588 free((void *)uiapplication->app_component);
1589 uiapplication->app_component = NULL;
1591 if (uiapplication->permission_type) {
1592 free((void *)uiapplication->permission_type);
1593 uiapplication->permission_type = NULL;
1595 if (uiapplication->component_type) {
1596 free((void *)uiapplication->component_type);
1597 uiapplication->component_type = NULL;
1599 if (uiapplication->preload) {
1600 free((void *)uiapplication->preload);
1601 uiapplication->preload = NULL;
1603 if (uiapplication->submode) {
1604 free((void *)uiapplication->submode);
1605 uiapplication->submode = NULL;
1607 if (uiapplication->submode_mainid) {
1608 free((void *)uiapplication->submode_mainid);
1609 uiapplication->submode_mainid = NULL;
1612 free((void*)uiapplication);
1613 uiapplication = NULL;
1616 static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication)
1618 if (serviceapplication == NULL)
1620 if (serviceapplication->exec) {
1621 free((void *)serviceapplication->exec);
1622 serviceapplication->exec = NULL;
1624 if (serviceapplication->appid) {
1625 free((void *)serviceapplication->appid);
1626 serviceapplication->appid = NULL;
1628 if (serviceapplication->onboot) {
1629 free((void *)serviceapplication->onboot);
1630 serviceapplication->onboot = NULL;
1632 if (serviceapplication->autorestart) {
1633 free((void *)serviceapplication->autorestart);
1634 serviceapplication->autorestart = NULL;
1636 if (serviceapplication->type) {
1637 free((void *)serviceapplication->type);
1638 serviceapplication->type = NULL;
1640 if (serviceapplication->enabled) {
1641 free((void *)serviceapplication->enabled);
1642 serviceapplication->enabled = NULL;
1644 if (serviceapplication->package) {
1645 free((void *)serviceapplication->package);
1646 serviceapplication->package = NULL;
1648 if (serviceapplication->permission_type) {
1649 free((void *)serviceapplication->permission_type);
1650 serviceapplication->permission_type = NULL;
1653 if (serviceapplication->label) {
1654 label_x *label = serviceapplication->label;
1655 label_x *tmp = NULL;
1656 while(label != NULL) {
1658 __ps_free_label(label);
1663 if (serviceapplication->icon) {
1664 icon_x *icon = serviceapplication->icon;
1666 while(icon != NULL) {
1668 __ps_free_icon(icon);
1673 if (serviceapplication->appcontrol) {
1674 appcontrol_x *appcontrol = serviceapplication->appcontrol;
1675 appcontrol_x *tmp = NULL;
1676 while(appcontrol != NULL) {
1677 tmp = appcontrol->next;
1678 __ps_free_appcontrol(appcontrol);
1682 /*Free DataControl*/
1683 if (serviceapplication->datacontrol) {
1684 datacontrol_x *datacontrol = serviceapplication->datacontrol;
1685 datacontrol_x *tmp = NULL;
1686 while(datacontrol != NULL) {
1687 tmp = datacontrol->next;
1688 __ps_free_datacontrol(datacontrol);
1692 /*Free LaunchConditions*/
1693 if (serviceapplication->launchconditions) {
1694 launchconditions_x *launchconditions = serviceapplication->launchconditions;
1695 launchconditions_x *tmp = NULL;
1696 while(launchconditions != NULL) {
1697 tmp = launchconditions->next;
1698 __ps_free_launchconditions(launchconditions);
1699 launchconditions = tmp;
1702 /*Free Notification*/
1703 if (serviceapplication->notification) {
1704 notification_x *notification = serviceapplication->notification;
1705 notification_x *tmp = NULL;
1706 while(notification != NULL) {
1707 tmp = notification->next;
1708 __ps_free_notification(notification);
1713 if (serviceapplication->datashare) {
1714 datashare_x *datashare = serviceapplication->datashare;
1715 datashare_x *tmp = NULL;
1716 while(datashare != NULL) {
1717 tmp = datashare->next;
1718 __ps_free_datashare(datashare);
1723 if (serviceapplication->appsvc) {
1724 appsvc_x *appsvc = serviceapplication->appsvc;
1725 appsvc_x *tmp = NULL;
1726 while(appsvc != NULL) {
1728 __ps_free_appsvc(appsvc);
1733 if (serviceapplication->category) {
1734 category_x *category = serviceapplication->category;
1735 category_x *tmp = NULL;
1736 while(category != NULL) {
1737 tmp = category->next;
1738 __ps_free_category(category);
1743 if (serviceapplication->metadata) {
1744 metadata_x *metadata = serviceapplication->metadata;
1745 metadata_x *tmp = NULL;
1746 while(metadata != NULL) {
1747 tmp = metadata->next;
1748 __ps_free_metadata(metadata);
1753 if (serviceapplication->permission) {
1754 permission_x *permission = serviceapplication->permission;
1755 permission_x *tmp = NULL;
1756 while(permission != NULL) {
1757 tmp = permission->next;
1758 __ps_free_permission(permission);
1762 free((void*)serviceapplication);
1763 serviceapplication = NULL;
1766 static void __ps_free_font(font_x *font)
1771 free((void *)font->name);
1775 free((void *)font->text);
1782 static void __ps_free_theme(theme_x *theme)
1787 free((void *)theme->name);
1791 free((void *)theme->text);
1798 static void __ps_free_daemon(daemon_x *daemon)
1803 free((void *)daemon->name);
1804 daemon->name = NULL;
1807 free((void *)daemon->text);
1808 daemon->text = NULL;
1810 free((void*)daemon);
1814 static void __ps_free_ime(ime_x *ime)
1819 free((void *)ime->name);
1823 free((void *)ime->text);
1830 int __ps_process_mdparser(manifest_x *mfx, ACTION_TYPE action)
1834 char md_key[PKG_STRING_LEN_MAX] = { 0 };
1836 fp = fopen(MDPARSER_LIST, "r");
1838 DBG("no preload list\n");
1842 while (fgets(md_key, sizeof(md_key), fp) != NULL) {
1844 DBG("md_key = %s\n", md_key);
1846 ret = __run_mdparser_prestep(mfx, md_key, action);
1848 memset(md_key, 0x00, sizeof(md_key));
1857 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed)
1859 xmlTextReaderRead(reader);
1860 if (xmlTextReaderValue(reader))
1861 allowed->text = ASCII(xmlTextReaderValue(reader));
1865 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation)
1867 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1868 operation->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1869 /* Text does not exist. Only attribute exists
1870 xmlTextReaderRead(reader);
1871 if (xmlTextReaderValue(reader))
1872 operation->text = ASCII(xmlTextReaderValue(reader));
1877 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri)
1879 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1880 uri->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1881 /* Text does not exist. Only attribute exists
1882 xmlTextReaderRead(reader);
1883 if (xmlTextReaderValue(reader))
1884 uri->text = ASCII(xmlTextReaderValue(reader));
1889 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime)
1891 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1892 mime->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1893 /* Text does not exist. Only attribute exists
1894 xmlTextReaderRead(reader);
1895 if (xmlTextReaderValue(reader))
1896 mime->text = ASCII(xmlTextReaderValue(reader));
1901 static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp)
1903 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1904 subapp->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1905 /* Text does not exist. Only attribute exists
1906 xmlTextReaderRead(reader);
1907 if (xmlTextReaderValue(reader))
1908 mime->text = ASCII(xmlTextReaderValue(reader));
1913 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition)
1915 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1916 condition->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1917 xmlTextReaderRead(reader);
1918 if (xmlTextReaderValue(reader))
1919 condition->text = ASCII(xmlTextReaderValue(reader));
1923 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notification)
1925 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1926 notification->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1927 xmlTextReaderRead(reader);
1928 if (xmlTextReaderValue(reader))
1929 notification->text = ASCII(xmlTextReaderValue(reader));
1933 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category)
1935 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1936 category->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1940 static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege)
1942 xmlTextReaderRead(reader);
1943 if (xmlTextReaderValue(reader)) {
1944 privilege->text = ASCII(xmlTextReaderValue(reader));
1949 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata)
1951 if (xmlTextReaderGetAttribute(reader, XMLCHAR("key")))
1952 metadata->key = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("key")));
1953 if (xmlTextReaderGetAttribute(reader, XMLCHAR("value")))
1954 metadata->value = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("value")));
1958 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission)
1960 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
1961 permission->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
1963 xmlTextReaderRead(reader);
1964 if (xmlTextReaderValue(reader))
1965 permission->value = ASCII(xmlTextReaderValue(reader));
1969 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility)
1971 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
1972 compatibility->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
1973 xmlTextReaderRead(reader);
1974 if (xmlTextReaderValue(reader))
1975 compatibility->text = ASCII(xmlTextReaderValue(reader));
1979 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution)
1981 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")))
1982 resolution->mimetype = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")));
1983 if (xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")))
1984 resolution->urischeme = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")));
1988 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request)
1990 xmlTextReaderRead(reader);
1991 if (xmlTextReaderValue(reader))
1992 request->text = ASCII(xmlTextReaderValue(reader));
1996 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define)
1998 const xmlChar *node;
2001 allowed_x *tmp1 = NULL;
2002 request_x *tmp2 = NULL;
2004 if (xmlTextReaderGetAttribute(reader, XMLCHAR("path")))
2005 define->path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("path")));
2007 depth = xmlTextReaderDepth(reader);
2008 while ((ret = __next_child_element(reader, depth))) {
2009 node = xmlTextReaderConstName(reader);
2011 DBG("xmlTextReaderConstName value is NULL\n");
2015 if (!strcmp(ASCII(node), "allowed")) {
2016 allowed_x *allowed= malloc(sizeof(allowed_x));
2017 if (allowed == NULL) {
2018 DBG("Malloc Failed\n");
2021 memset(allowed, '\0', sizeof(allowed_x));
2022 LISTADD(define->allowed, allowed);
2023 ret = __ps_process_allowed(reader, allowed);
2024 } else if (!strcmp(ASCII(node), "request")) {
2025 request_x *request = malloc(sizeof(request_x));
2026 if (request == NULL) {
2027 DBG("Malloc Failed\n");
2030 memset(request, '\0', sizeof(request_x));
2031 LISTADD(define->request, request);
2032 ret = __ps_process_request(reader, request);
2036 DBG("Processing define failed\n");
2040 if (define->allowed) {
2041 LISTHEAD(define->allowed, tmp1);
2042 define->allowed = tmp1;
2044 if (define->request) {
2045 LISTHEAD(define->request, tmp2);
2046 define->request = tmp2;
2051 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol)
2053 const xmlChar *node;
2056 operation_x *tmp1 = NULL;
2058 mime_x *tmp3 = NULL;
2059 subapp_x *tmp4 = NULL;
2061 depth = xmlTextReaderDepth(reader);
2062 while ((ret = __next_child_element(reader, depth))) {
2063 node = xmlTextReaderConstName(reader);
2065 DBG("xmlTextReaderConstName value is NULL\n");
2069 if (!strcmp(ASCII(node), "operation")) {
2070 operation_x *operation = malloc(sizeof(operation_x));
2071 if (operation == NULL) {
2072 DBG("Malloc Failed\n");
2075 memset(operation, '\0', sizeof(operation_x));
2076 LISTADD(appcontrol->operation, operation);
2077 ret = __ps_process_operation(reader, operation);
2078 DBG("operation processing\n");
2079 } else if (!strcmp(ASCII(node), "uri")) {
2080 uri_x *uri= malloc(sizeof(uri_x));
2082 DBG("Malloc Failed\n");
2085 memset(uri, '\0', sizeof(uri_x));
2086 LISTADD(appcontrol->uri, uri);
2087 ret = __ps_process_uri(reader, uri);
2088 DBG("uri processing\n");
2089 } else if (!strcmp(ASCII(node), "mime")) {
2090 mime_x *mime = malloc(sizeof(mime_x));
2092 DBG("Malloc Failed\n");
2095 memset(mime, '\0', sizeof(mime_x));
2096 LISTADD(appcontrol->mime, mime);
2097 ret = __ps_process_mime(reader, mime);
2098 DBG("mime processing\n");
2099 } else if (!strcmp(ASCII(node), "subapp")) {
2100 subapp_x *subapp = malloc(sizeof(subapp_x));
2101 if (subapp == NULL) {
2102 DBG("Malloc Failed\n");
2105 memset(subapp, '\0', sizeof(subapp_x));
2106 LISTADD(appcontrol->subapp, subapp);
2107 ret = __ps_process_subapp(reader, subapp);
2108 DBG("subapp processing\n");
2112 DBG("Processing appcontrol failed\n");
2116 if (appcontrol->operation) {
2117 LISTHEAD(appcontrol->operation, tmp1);
2118 appcontrol->operation = tmp1;
2120 if (appcontrol->uri) {
2121 LISTHEAD(appcontrol->uri, tmp2);
2122 appcontrol->uri = tmp2;
2124 if (appcontrol->mime) {
2125 LISTHEAD(appcontrol->mime, tmp3);
2126 appcontrol->mime = tmp3;
2128 if (appcontrol->subapp) {
2129 LISTHEAD(appcontrol->subapp, tmp4);
2130 appcontrol->subapp = tmp4;
2133 xmlTextReaderRead(reader);
2134 if (xmlTextReaderValue(reader))
2135 appcontrol->text = ASCII(xmlTextReaderValue(reader));
2140 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc)
2142 const xmlChar *node;
2145 operation_x *tmp1 = NULL;
2147 mime_x *tmp3 = NULL;
2148 subapp_x *tmp4 = NULL;
2150 depth = xmlTextReaderDepth(reader);
2151 while ((ret = __next_child_element(reader, depth))) {
2152 node = xmlTextReaderConstName(reader);
2154 DBG("xmlTextReaderConstName value is NULL\n");
2158 if (!strcmp(ASCII(node), "operation")) {
2159 operation_x *operation = malloc(sizeof(operation_x));
2160 if (operation == NULL) {
2161 DBG("Malloc Failed\n");
2164 memset(operation, '\0', sizeof(operation_x));
2165 LISTADD(appsvc->operation, operation);
2166 ret = __ps_process_operation(reader, operation);
2167 DBG("operation processing\n");
2168 } else if (!strcmp(ASCII(node), "uri")) {
2169 uri_x *uri= malloc(sizeof(uri_x));
2171 DBG("Malloc Failed\n");
2174 memset(uri, '\0', sizeof(uri_x));
2175 LISTADD(appsvc->uri, uri);
2176 ret = __ps_process_uri(reader, uri);
2177 DBG("uri processing\n");
2178 } else if (!strcmp(ASCII(node), "mime")) {
2179 mime_x *mime = malloc(sizeof(mime_x));
2181 DBG("Malloc Failed\n");
2184 memset(mime, '\0', sizeof(mime_x));
2185 LISTADD(appsvc->mime, mime);
2186 ret = __ps_process_mime(reader, mime);
2187 DBG("mime processing\n");
2188 } else if (!strcmp(ASCII(node), "subapp")) {
2189 subapp_x *subapp = malloc(sizeof(subapp_x));
2190 if (subapp == NULL) {
2191 DBG("Malloc Failed\n");
2194 memset(subapp, '\0', sizeof(subapp_x));
2195 LISTADD(appsvc->subapp, subapp);
2196 ret = __ps_process_subapp(reader, subapp);
2197 DBG("subapp processing\n");
2201 DBG("Processing appsvc failed\n");
2205 if (appsvc->operation) {
2206 LISTHEAD(appsvc->operation, tmp1);
2207 appsvc->operation = tmp1;
2210 LISTHEAD(appsvc->uri, tmp2);
2214 LISTHEAD(appsvc->mime, tmp3);
2215 appsvc->mime = tmp3;
2217 if (appsvc->subapp) {
2218 LISTHEAD(appsvc->subapp, tmp4);
2219 appsvc->subapp = tmp4;
2222 xmlTextReaderRead(reader);
2223 if (xmlTextReaderValue(reader))
2224 appsvc->text = ASCII(xmlTextReaderValue(reader));
2230 static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privileges)
2232 const xmlChar *node;
2235 privilege_x *tmp1 = NULL;
2237 depth = xmlTextReaderDepth(reader);
2238 while ((ret = __next_child_element(reader, depth))) {
2239 node = xmlTextReaderConstName(reader);
2241 DBG("xmlTextReaderConstName value is NULL\n");
2245 if (strcmp(ASCII(node), "privilege") == 0) {
2246 privilege_x *privilege = malloc(sizeof(privilege_x));
2247 if (privilege == NULL) {
2248 DBG("Malloc Failed\n");
2251 memset(privilege, '\0', sizeof(privilege_x));
2252 LISTADD(privileges->privilege, privilege);
2253 ret = __ps_process_privilege(reader, privilege);
2257 DBG("Processing privileges failed\n");
2261 if (privileges->privilege) {
2262 LISTHEAD(privileges->privilege, tmp1);
2263 privileges->privilege = tmp1;
2268 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions)
2270 const xmlChar *node;
2273 condition_x *tmp1 = NULL;
2275 depth = xmlTextReaderDepth(reader);
2276 while ((ret = __next_child_element(reader, depth))) {
2277 node = xmlTextReaderConstName(reader);
2279 DBG("xmlTextReaderConstName value is NULL\n");
2283 if (strcmp(ASCII(node), "condition") == 0) {
2284 condition_x *condition = malloc(sizeof(condition_x));
2285 if (condition == NULL) {
2286 DBG("Malloc Failed\n");
2289 memset(condition, '\0', sizeof(condition_x));
2290 LISTADD(launchconditions->condition, condition);
2291 ret = __ps_process_condition(reader, condition);
2295 DBG("Processing launchconditions failed\n");
2299 if (launchconditions->condition) {
2300 LISTHEAD(launchconditions->condition, tmp1);
2301 launchconditions->condition = tmp1;
2304 xmlTextReaderRead(reader);
2305 if (xmlTextReaderValue(reader))
2306 launchconditions->text = ASCII(xmlTextReaderValue(reader));
2311 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare)
2313 const xmlChar *node;
2316 define_x *tmp1 = NULL;
2317 request_x *tmp2 = NULL;
2318 depth = xmlTextReaderDepth(reader);
2319 while ((ret = __next_child_element(reader, depth))) {
2320 node = xmlTextReaderConstName(reader);
2322 DBG("xmlTextReaderConstName value is NULL\n");
2326 if (!strcmp(ASCII(node), "define")) {
2327 define_x *define= malloc(sizeof(define_x));
2328 if (define == NULL) {
2329 DBG("Malloc Failed\n");
2332 memset(define, '\0', sizeof(define_x));
2333 LISTADD(datashare->define, define);
2334 ret = __ps_process_define(reader, define);
2335 } else if (!strcmp(ASCII(node), "request")) {
2336 request_x *request= malloc(sizeof(request_x));
2337 if (request == NULL) {
2338 DBG("Malloc Failed\n");
2341 memset(request, '\0', sizeof(request_x));
2342 LISTADD(datashare->request, request);
2343 ret = __ps_process_request(reader, request);
2347 DBG("Processing data-share failed\n");
2351 if (datashare->define) {
2352 LISTHEAD(datashare->define, tmp1);
2353 datashare->define = tmp1;
2355 if (datashare->request) {
2356 LISTHEAD(datashare->request, tmp2);
2357 datashare->request = tmp2;
2363 __get_icon_with_path(const char* icon)
2368 if (index(icon, '/') == NULL) {
2370 char* icon_with_path = NULL;
2376 theme = vconf_get_str("db/setting/theme");
2378 theme = strdup("default");
2384 len = (0x01 << 7) + strlen(icon) + strlen(package) + strlen(theme);
2385 icon_with_path = malloc(len);
2386 if(icon_with_path == NULL) {
2387 DBG("(icon_with_path == NULL) return\n");
2392 memset(icon_with_path, 0, len);
2394 snprintf(icon_with_path, len, "/opt/share/icons/%s/small/%s", theme, icon);
2396 if (access(icon_with_path, R_OK) == 0) break;
2397 snprintf(icon_with_path, len, "/usr/share/icons/%s/small/%s", theme, icon);
2398 if (access(icon_with_path, R_OK) == 0) break;
2399 DBG("cannot find icon %s", icon_with_path);
2400 snprintf(icon_with_path, len,"/opt/share/icons/default/small/%s", icon);
2401 if (access(icon_with_path, R_OK) == 0) break;
2402 snprintf(icon_with_path, len, "/usr/share/icons/default/small/%s", icon);
2403 if (access(icon_with_path, R_OK) == 0) break;
2405 /* icon path is going to be moved intto the app directory */
2406 DBGE("icon file must be moved to %s", icon_with_path);
2407 snprintf(icon_with_path, len, "/opt/apps/%s/res/icons/%s/small/%s", package, theme, icon);
2408 if (access(icon_with_path, R_OK) == 0) break;
2409 snprintf(icon_with_path, len, "/usr/apps/%s/res/icons/%s/small/%s", package, theme, icon);
2410 if (access(icon_with_path, R_OK) == 0) break;
2411 DBG("cannot find icon %s", icon_with_path);
2412 snprintf(icon_with_path, len, "/opt/apps/%s/res/icons/default/small/%s", package, icon);
2413 if (access(icon_with_path, R_OK) == 0) break;
2414 snprintf(icon_with_path, len, "/usr/apps/%s/res/icons/default/small/%s", package, icon);
2415 if (access(icon_with_path, R_OK) == 0) break;
2416 snprintf(icon_with_path, len, "/usr/ug/res/images/%s/%s", package, icon);
2417 if (access(icon_with_path, R_OK) == 0) break;
2422 DBG("Icon path : %s ---> %s", icon, icon_with_path);
2424 return icon_with_path;
2426 char* confirmed_icon = NULL;
2428 confirmed_icon = strdup(icon);
2429 if (!confirmed_icon)
2431 return confirmed_icon;
2435 static void __ps_process_tag(manifest_x * mfx, char *const tagv[])
2438 char delims[] = "=";
2439 char *ret_result = NULL;
2445 for (tag = strdup(tagv[0]); tag != NULL; ) {
2446 ret_result = strtok(tag, delims);
2448 /*check tag : preload */
2449 if (strcmp(ret_result, "preload") == 0) {
2450 ret_result = strtok(NULL, delims);
2451 if (strcmp(ret_result, "true") == 0) {
2452 free((void *)mfx->preload);
2453 mfx->preload = strdup("true");
2454 } else if (strcmp(ret_result, "false") == 0) {
2455 free((void *)mfx->preload);
2456 mfx->preload = strdup("false");
2458 /*check tag : removable*/
2459 } else if (strcmp(ret_result, "removable") == 0) {
2460 ret_result = strtok(NULL, delims);
2461 if (strcmp(ret_result, "true") == 0){
2462 free((void *)mfx->removable);
2463 mfx->removable = strdup("true");
2464 } else if (strcmp(ret_result, "false") == 0) {
2465 free((void *)mfx->removable);
2466 mfx->removable = strdup("false");
2468 /*check tag : not matched*/
2470 DBG("tag process [%s]is not defined\n", ret_result);
2474 /*check next value*/
2475 if (tagv[++i] != NULL)
2476 tag = strdup(tagv[i]);
2478 DBG("tag process success...\n");
2484 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon)
2486 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2487 icon->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2488 if (xmlTextReaderConstXmlLang(reader)) {
2489 icon->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2490 if (icon->lang == NULL)
2491 icon->lang = strdup(DEFAULT_LOCALE);
2493 icon->lang = strdup(DEFAULT_LOCALE);
2495 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
2496 icon->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
2497 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
2498 icon->size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
2499 if (xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")))
2500 icon->resolution = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")));
2501 xmlTextReaderRead(reader);
2502 if (xmlTextReaderValue(reader)) {
2503 const char *text = ASCII(xmlTextReaderValue(reader));
2505 icon->text = (const char *)__get_icon_with_path(text);
2513 static int __ps_process_image(xmlTextReaderPtr reader, image_x *image)
2515 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2516 image->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2517 if (xmlTextReaderConstXmlLang(reader)) {
2518 image->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2519 if (image->lang == NULL)
2520 image->lang = strdup(DEFAULT_LOCALE);
2522 image->lang = strdup(DEFAULT_LOCALE);
2524 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
2525 image->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
2526 xmlTextReaderRead(reader);
2527 if (xmlTextReaderValue(reader))
2528 image->text = ASCII(xmlTextReaderValue(reader));
2533 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label)
2535 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2536 label->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2537 if (xmlTextReaderConstXmlLang(reader)) {
2538 label->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2539 if (label->lang == NULL)
2540 label->lang = strdup(DEFAULT_LOCALE);
2542 label->lang = strdup(DEFAULT_LOCALE);
2544 xmlTextReaderRead(reader);
2545 if (xmlTextReaderValue(reader))
2546 label->text = ASCII(xmlTextReaderValue(reader));
2548 /* DBG("lable name %s\n", label->name);
2549 DBG("lable lang %s\n", label->lang);
2550 DBG("lable text %s\n", label->text);
2556 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author)
2558 if (xmlTextReaderGetAttribute(reader, XMLCHAR("email")))
2559 author->email = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("email")));
2560 if (xmlTextReaderGetAttribute(reader, XMLCHAR("href")))
2561 author->href = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("href")));
2562 if (xmlTextReaderConstXmlLang(reader)) {
2563 author->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2564 if (author->lang == NULL)
2565 author->lang = strdup(DEFAULT_LOCALE);
2567 author->lang = strdup(DEFAULT_LOCALE);
2569 xmlTextReaderRead(reader);
2570 if (xmlTextReaderValue(reader))
2571 author->text = ASCII(xmlTextReaderValue(reader));
2575 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description)
2577 if (xmlTextReaderConstXmlLang(reader)) {
2578 description->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2579 if (description->lang == NULL)
2580 description->lang = strdup(DEFAULT_LOCALE);
2582 description->lang = strdup(DEFAULT_LOCALE);
2584 xmlTextReaderRead(reader);
2585 if (xmlTextReaderValue(reader))
2586 description->text = ASCII(xmlTextReaderValue(reader));
2590 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license)
2592 if (xmlTextReaderConstXmlLang(reader)) {
2593 license->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2594 if (license->lang == NULL)
2595 license->lang = strdup(DEFAULT_LOCALE);
2597 license->lang = strdup(DEFAULT_LOCALE);
2599 xmlTextReaderRead(reader);
2600 if (xmlTextReaderValue(reader))
2601 license->text = ASCII(xmlTextReaderValue(reader));
2605 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability)
2607 const xmlChar *node;
2610 resolution_x *tmp1 = NULL;
2612 if (xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")))
2613 capability->operationid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")));
2615 depth = xmlTextReaderDepth(reader);
2616 while ((ret = __next_child_element(reader, depth))) {
2617 node = xmlTextReaderConstName(reader);
2619 DBG("xmlTextReaderConstName value is NULL\n");
2623 if (!strcmp(ASCII(node), "resolution")) {
2624 resolution_x *resolution = malloc(sizeof(resolution_x));
2625 if (resolution == NULL) {
2626 DBG("Malloc Failed\n");
2629 memset(resolution, '\0', sizeof(resolution_x));
2630 LISTADD(capability->resolution, resolution);
2631 ret = __ps_process_resolution(reader, resolution);
2635 DBG("Processing capability failed\n");
2640 if (capability->resolution) {
2641 LISTHEAD(capability->resolution, tmp1);
2642 capability->resolution = tmp1;
2648 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol)
2650 const xmlChar *node;
2653 capability_x *tmp1 = NULL;
2655 if (xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")))
2656 datacontrol->providerid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")));
2658 depth = xmlTextReaderDepth(reader);
2659 while ((ret = __next_child_element(reader, depth))) {
2660 node = xmlTextReaderConstName(reader);
2662 DBG("xmlTextReaderConstName value is NULL\n");
2666 if (!strcmp(ASCII(node), "capability")) {
2667 capability_x *capability = malloc(sizeof(capability_x));
2668 if (capability == NULL) {
2669 DBG("Malloc Failed\n");
2672 memset(capability, '\0', sizeof(capability_x));
2673 LISTADD(datacontrol->capability, capability);
2674 ret = __ps_process_capability(reader, capability);
2678 DBG("Processing datacontrol failed\n");
2683 if (datacontrol->capability) {
2684 LISTHEAD(datacontrol->capability, tmp1);
2685 datacontrol->capability = tmp1;
2691 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication)
2693 const xmlChar *node;
2696 char *newappid = NULL;
2697 label_x *tmp1 = NULL;
2698 icon_x *tmp2 = NULL;
2699 appsvc_x *tmp3 = NULL;
2700 appcontrol_x *tmp4 = NULL;
2701 launchconditions_x *tmp5 = NULL;
2702 notification_x *tmp6 = NULL;
2703 datashare_x *tmp7 = NULL;
2704 category_x *tmp8 = NULL;
2705 metadata_x *tmp9 = NULL;
2706 image_x *tmp10 = NULL;
2707 permission_x *tmp11 = NULL;
2709 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
2710 uiapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
2711 if (uiapplication->appid == NULL) {
2712 DBG("appid cant be NULL\n");
2716 DBG("appid is mandatory\n");
2720 ret = __validate_appid(package, uiapplication->appid, &newappid);
2722 DBG("appid is not proper\n");
2726 if (uiapplication->appid)
2727 free((void *)uiapplication->appid);
2728 uiapplication->appid = newappid;
2730 uiapplication->package= strdup(package);
2732 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
2733 uiapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
2734 if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay"))) {
2735 uiapplication->nodisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay")));
2736 if (uiapplication->nodisplay == NULL)
2737 uiapplication->nodisplay = strdup("false");
2739 uiapplication->nodisplay = strdup("false");
2741 if (xmlTextReaderGetAttribute(reader, XMLCHAR("multiple"))) {
2742 uiapplication->multiple = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("multiple")));
2743 if (uiapplication->multiple == NULL)
2744 uiapplication->multiple = strdup("false");
2746 uiapplication->multiple = strdup("false");
2748 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
2749 uiapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
2750 if (xmlTextReaderGetAttribute(reader, XMLCHAR("categories")))
2751 uiapplication->categories = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("categories")));
2752 if (xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")))
2753 uiapplication->extraid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")));
2754 if (xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage"))) {
2755 uiapplication->taskmanage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage")));
2756 if (uiapplication->taskmanage == NULL)
2757 uiapplication->taskmanage = strdup("true");
2759 uiapplication->taskmanage = strdup("true");
2761 if (xmlTextReaderGetAttribute(reader, XMLCHAR("enabled"))) {
2762 uiapplication->enabled = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("enabled")));
2763 if (uiapplication->enabled == NULL)
2764 uiapplication->enabled = strdup("true");
2766 uiapplication->enabled = strdup("true");
2768 if (xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration"))) {
2769 uiapplication->hwacceleration = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration")));
2770 if (uiapplication->hwacceleration == NULL)
2771 uiapplication->hwacceleration = strdup("use-system-setting");
2773 uiapplication->hwacceleration = strdup("use-system-setting");
2775 if (xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")))
2776 uiapplication->recentimage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")));
2777 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp"))) {
2778 uiapplication->mainapp = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp")));
2779 if (uiapplication->mainapp == NULL)
2780 uiapplication->mainapp = strdup("false");
2782 uiapplication->mainapp = strdup("false");
2784 if (xmlTextReaderGetAttribute(reader, XMLCHAR("launchcondition"))) {
2785 uiapplication->launchcondition = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("launchcondition")));
2786 if (uiapplication->launchcondition == NULL)
2787 uiapplication->launchcondition = strdup("false");
2789 uiapplication->launchcondition = strdup("false");
2792 if (xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay"))) {
2793 uiapplication->indicatordisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay")));
2794 if (uiapplication->indicatordisplay == NULL)
2795 uiapplication->indicatordisplay = strdup("true");
2797 uiapplication->indicatordisplay = strdup("true");
2799 if (xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")))
2800 uiapplication->portraitimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")));
2802 uiapplication->portraitimg = NULL;
2803 if (xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")))
2804 uiapplication->landscapeimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")));
2806 uiapplication->landscapeimg = NULL;
2807 if (xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility"))) {
2808 uiapplication->guestmode_visibility = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility")));
2809 if (uiapplication->guestmode_visibility == NULL)
2810 uiapplication->guestmode_visibility = strdup("true");
2812 uiapplication->guestmode_visibility = strdup("true");
2814 if (xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type"))) {
2815 uiapplication->permission_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type")));
2816 if (uiapplication->permission_type == NULL)
2817 uiapplication->permission_type = strdup("normal");
2819 uiapplication->permission_type = strdup("normal");
2821 if (xmlTextReaderGetAttribute(reader, XMLCHAR("component-type"))) {
2822 uiapplication->component_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("component-type")));
2823 if (uiapplication->component_type == NULL)
2824 uiapplication->component_type = strdup("uiapp");
2826 uiapplication->component_type = strdup("uiapp");
2828 if (xmlTextReaderGetAttribute(reader, XMLCHAR("submode"))) {
2829 uiapplication->submode = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("submode")));
2830 if (uiapplication->submode == NULL)
2831 uiapplication->submode = strdup("false");
2833 uiapplication->submode = strdup("false");
2835 if (xmlTextReaderGetAttribute(reader, XMLCHAR("submode-mainid")))
2836 uiapplication->submode_mainid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("submode-mainid")));
2838 depth = xmlTextReaderDepth(reader);
2839 while ((ret = __next_child_element(reader, depth))) {
2840 node = xmlTextReaderConstName(reader);
2842 DBG("xmlTextReaderConstName value is NULL\n");
2845 if (!strcmp(ASCII(node), "label")) {
2846 label_x *label = malloc(sizeof(label_x));
2847 if (label == NULL) {
2848 DBG("Malloc Failed\n");
2851 memset(label, '\0', sizeof(label_x));
2852 LISTADD(uiapplication->label, label);
2853 ret = __ps_process_label(reader, label);
2854 } else if (!strcmp(ASCII(node), "icon")) {
2855 icon_x *icon = malloc(sizeof(icon_x));
2857 DBG("Malloc Failed\n");
2860 memset(icon, '\0', sizeof(icon_x));
2861 LISTADD(uiapplication->icon, icon);
2862 ret = __ps_process_icon(reader, icon);
2863 } else if (!strcmp(ASCII(node), "image")) {
2864 image_x *image = malloc(sizeof(image_x));
2865 if (image == NULL) {
2866 DBG("Malloc Failed\n");
2869 memset(image, '\0', sizeof(image_x));
2870 LISTADD(uiapplication->image, image);
2871 ret = __ps_process_image(reader, image);
2872 } else if (!strcmp(ASCII(node), "category")) {
2873 category_x *category = malloc(sizeof(category_x));
2874 if (category == NULL) {
2875 DBG("Malloc Failed\n");
2878 memset(category, '\0', sizeof(category_x));
2879 LISTADD(uiapplication->category, category);
2880 ret = __ps_process_category(reader, category);
2881 } else if (!strcmp(ASCII(node), "metadata")) {
2882 metadata_x *metadata = malloc(sizeof(metadata_x));
2883 if (metadata == NULL) {
2884 DBG("Malloc Failed\n");
2887 memset(metadata, '\0', sizeof(metadata_x));
2888 LISTADD(uiapplication->metadata, metadata);
2889 ret = __ps_process_metadata(reader, metadata);
2890 } else if (!strcmp(ASCII(node), "permission")) {
2891 permission_x *permission = malloc(sizeof(permission_x));
2892 if (permission == NULL) {
2893 DBG("Malloc Failed\n");
2896 memset(permission, '\0', sizeof(permission_x));
2897 LISTADD(uiapplication->permission, permission);
2898 ret = __ps_process_permission(reader, permission);
2899 } else if (!strcmp(ASCII(node), "app-control")) {
2900 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
2901 if (appcontrol == NULL) {
2902 DBG("Malloc Failed\n");
2905 memset(appcontrol, '\0', sizeof(appcontrol_x));
2906 LISTADD(uiapplication->appcontrol, appcontrol);
2907 ret = __ps_process_appcontrol(reader, appcontrol);
2908 } else if (!strcmp(ASCII(node), "application-service")) {
2909 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
2910 if (appsvc == NULL) {
2911 DBG("Malloc Failed\n");
2914 memset(appsvc, '\0', sizeof(appsvc_x));
2915 LISTADD(uiapplication->appsvc, appsvc);
2916 ret = __ps_process_appsvc(reader, appsvc);
2917 } else if (!strcmp(ASCII(node), "data-share")) {
2918 datashare_x *datashare = malloc(sizeof(datashare_x));
2919 if (datashare == NULL) {
2920 DBG("Malloc Failed\n");
2923 memset(datashare, '\0', sizeof(datashare_x));
2924 LISTADD(uiapplication->datashare, datashare);
2925 ret = __ps_process_datashare(reader, datashare);
2926 } else if (!strcmp(ASCII(node), "launch-conditions")) {
2927 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
2928 if (launchconditions == NULL) {
2929 DBG("Malloc Failed\n");
2932 memset(launchconditions, '\0', sizeof(launchconditions_x));
2933 LISTADD(uiapplication->launchconditions, launchconditions);
2934 ret = __ps_process_launchconditions(reader, launchconditions);
2935 } else if (!strcmp(ASCII(node), "notification")) {
2936 notification_x *notification = malloc(sizeof(notification_x));
2937 if (notification == NULL) {
2938 DBG("Malloc Failed\n");
2941 memset(notification, '\0', sizeof(notification_x));
2942 LISTADD(uiapplication->notification, notification);
2943 ret = __ps_process_notification(reader, notification);
2947 DBG("Processing uiapplication failed\n");
2952 if (uiapplication->label) {
2953 LISTHEAD(uiapplication->label, tmp1);
2954 uiapplication->label = tmp1;
2956 if (uiapplication->icon) {
2957 LISTHEAD(uiapplication->icon, tmp2);
2958 uiapplication->icon = tmp2;
2960 if (uiapplication->appsvc) {
2961 LISTHEAD(uiapplication->appsvc, tmp3);
2962 uiapplication->appsvc = tmp3;
2964 if (uiapplication->appcontrol) {
2965 LISTHEAD(uiapplication->appcontrol, tmp4);
2966 uiapplication->appcontrol = tmp4;
2968 if (uiapplication->launchconditions) {
2969 LISTHEAD(uiapplication->launchconditions, tmp5);
2970 uiapplication->launchconditions = tmp5;
2972 if (uiapplication->notification) {
2973 LISTHEAD(uiapplication->notification, tmp6);
2974 uiapplication->notification = tmp6;
2976 if (uiapplication->datashare) {
2977 LISTHEAD(uiapplication->datashare, tmp7);
2978 uiapplication->datashare = tmp7;
2980 if (uiapplication->category) {
2981 LISTHEAD(uiapplication->category, tmp8);
2982 uiapplication->category = tmp8;
2984 if (uiapplication->metadata) {
2985 LISTHEAD(uiapplication->metadata, tmp9);
2986 uiapplication->metadata = tmp9;
2988 if (uiapplication->image) {
2989 LISTHEAD(uiapplication->image, tmp10);
2990 uiapplication->image = tmp10;
2992 if (uiapplication->permission) {
2993 LISTHEAD(uiapplication->permission, tmp11);
2994 uiapplication->permission = tmp11;
3000 static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication)
3002 const xmlChar *node;
3005 char *newappid = NULL;
3006 label_x *tmp1 = NULL;
3007 icon_x *tmp2 = NULL;
3008 appsvc_x *tmp3 = NULL;
3009 appcontrol_x *tmp4 = NULL;
3010 datacontrol_x *tmp5 = NULL;
3011 launchconditions_x *tmp6 = NULL;
3012 notification_x *tmp7 = NULL;
3013 datashare_x *tmp8 = NULL;
3014 category_x *tmp9 = NULL;
3015 metadata_x *tmp10 = NULL;
3016 permission_x *tmp11 = NULL;
3018 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
3019 serviceapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
3020 if (serviceapplication->appid == NULL) {
3021 DBG("appid cant be NULL\n");
3025 DBG("appid is mandatory\n");
3029 ret = __validate_appid(package, serviceapplication->appid, &newappid);
3031 DBG("appid is not proper\n");
3035 if (serviceapplication->appid)
3036 free((void *)serviceapplication->appid);
3037 serviceapplication->appid = newappid;
3040 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
3041 serviceapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
3042 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
3043 serviceapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
3044 if (xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot"))) {
3045 serviceapplication->onboot = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot")));
3046 if (serviceapplication->onboot == NULL)
3047 serviceapplication->onboot = strdup("false");
3049 serviceapplication->onboot = strdup("false");
3051 if (xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart"))) {
3052 serviceapplication->autorestart = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart")));
3053 if (serviceapplication->autorestart == NULL)
3054 serviceapplication->autorestart = strdup("false");
3056 serviceapplication->autorestart = strdup("false");
3058 if (xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type"))) {
3059 serviceapplication->permission_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type")));
3060 if (serviceapplication->permission_type == NULL)
3061 serviceapplication->permission_type = strdup("normal");
3063 serviceapplication->permission_type = strdup("normal");
3066 depth = xmlTextReaderDepth(reader);
3067 while ((ret = __next_child_element(reader, depth))) {
3068 node = xmlTextReaderConstName(reader);
3070 DBG("xmlTextReaderConstName value is NULL\n");
3074 if (!strcmp(ASCII(node), "label")) {
3075 label_x *label = malloc(sizeof(label_x));
3076 if (label == NULL) {
3077 DBG("Malloc Failed\n");
3080 memset(label, '\0', sizeof(label_x));
3081 LISTADD(serviceapplication->label, label);
3082 ret = __ps_process_label(reader, label);
3083 } else if (!strcmp(ASCII(node), "icon")) {
3084 icon_x *icon = malloc(sizeof(icon_x));
3086 DBG("Malloc Failed\n");
3089 memset(icon, '\0', sizeof(icon_x));
3090 LISTADD(serviceapplication->icon, icon);
3091 ret = __ps_process_icon(reader, icon);
3092 } else if (!strcmp(ASCII(node), "category")) {
3093 category_x *category = malloc(sizeof(category_x));
3094 if (category == NULL) {
3095 DBG("Malloc Failed\n");
3098 memset(category, '\0', sizeof(category_x));
3099 LISTADD(serviceapplication->category, category);
3100 ret = __ps_process_category(reader, category);
3101 } else if (!strcmp(ASCII(node), "metadata")) {
3102 metadata_x *metadata = malloc(sizeof(metadata_x));
3103 if (metadata == NULL) {
3104 DBG("Malloc Failed\n");
3107 memset(metadata, '\0', sizeof(metadata_x));
3108 LISTADD(serviceapplication->metadata, metadata);
3109 ret = __ps_process_metadata(reader, metadata);
3110 } else if (!strcmp(ASCII(node), "permission")) {
3111 permission_x *permission = malloc(sizeof(permission_x));
3112 if (permission == NULL) {
3113 DBG("Malloc Failed\n");
3116 memset(permission, '\0', sizeof(permission_x));
3117 LISTADD(serviceapplication->permission, permission);
3118 ret = __ps_process_permission(reader, permission);
3119 } else if (!strcmp(ASCII(node), "app-control")) {
3120 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
3121 if (appcontrol == NULL) {
3122 DBG("Malloc Failed\n");
3125 memset(appcontrol, '\0', sizeof(appcontrol_x));
3126 LISTADD(serviceapplication->appcontrol, appcontrol);
3127 ret = __ps_process_appcontrol(reader, appcontrol);
3128 } else if (!strcmp(ASCII(node), "application-service")) {
3129 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
3130 if (appsvc == NULL) {
3131 DBG("Malloc Failed\n");
3134 memset(appsvc, '\0', sizeof(appsvc_x));
3135 LISTADD(serviceapplication->appsvc, appsvc);
3136 ret = __ps_process_appsvc(reader, appsvc);
3137 } else if (!strcmp(ASCII(node), "data-share")) {
3138 datashare_x *datashare = malloc(sizeof(datashare_x));
3139 if (datashare == NULL) {
3140 DBG("Malloc Failed\n");
3143 memset(datashare, '\0', sizeof(datashare_x));
3144 LISTADD(serviceapplication->datashare, datashare);
3145 ret = __ps_process_datashare(reader, datashare);
3146 } else if (!strcmp(ASCII(node), "launch-conditions")) {
3147 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
3148 if (launchconditions == NULL) {
3149 DBG("Malloc Failed\n");
3152 memset(launchconditions, '\0', sizeof(launchconditions_x));
3153 LISTADD(serviceapplication->launchconditions, launchconditions);
3154 ret = __ps_process_launchconditions(reader, launchconditions);
3155 } else if (!strcmp(ASCII(node), "notification")) {
3156 notification_x *notification = malloc(sizeof(notification_x));
3157 if (notification == NULL) {
3158 DBG("Malloc Failed\n");
3161 memset(notification, '\0', sizeof(notification_x));
3162 LISTADD(serviceapplication->notification, notification);
3163 ret = __ps_process_notification(reader, notification);
3164 } else if (!strcmp(ASCII(node), "data-control")) {
3165 datacontrol_x *datacontrol = malloc(sizeof(datacontrol_x));
3166 if (datacontrol == NULL) {
3167 DBG("Malloc Failed\n");
3170 memset(datacontrol, '\0', sizeof(datacontrol_x));
3171 LISTADD(serviceapplication->datacontrol, datacontrol);
3172 ret = __ps_process_datacontrol(reader, datacontrol);
3176 DBG("Processing serviceapplication failed\n");
3181 if (serviceapplication->label) {
3182 LISTHEAD(serviceapplication->label, tmp1);
3183 serviceapplication->label = tmp1;
3185 if (serviceapplication->icon) {
3186 LISTHEAD(serviceapplication->icon, tmp2);
3187 serviceapplication->icon = tmp2;
3189 if (serviceapplication->appsvc) {
3190 LISTHEAD(serviceapplication->appsvc, tmp3);
3191 serviceapplication->appsvc = tmp3;
3193 if (serviceapplication->appcontrol) {
3194 LISTHEAD(serviceapplication->appcontrol, tmp4);
3195 serviceapplication->appcontrol = tmp4;
3197 if (serviceapplication->datacontrol) {
3198 LISTHEAD(serviceapplication->datacontrol, tmp5);
3199 serviceapplication->datacontrol = tmp5;
3201 if (serviceapplication->launchconditions) {
3202 LISTHEAD(serviceapplication->launchconditions, tmp6);
3203 serviceapplication->launchconditions = tmp6;
3205 if (serviceapplication->notification) {
3206 LISTHEAD(serviceapplication->notification, tmp7);
3207 serviceapplication->notification = tmp7;
3209 if (serviceapplication->datashare) {
3210 LISTHEAD(serviceapplication->datashare, tmp8);
3211 serviceapplication->datashare = tmp8;
3213 if (serviceapplication->category) {
3214 LISTHEAD(serviceapplication->category, tmp9);
3215 serviceapplication->category = tmp9;
3217 if (serviceapplication->metadata) {
3218 LISTHEAD(serviceapplication->metadata, tmp10);
3219 serviceapplication->metadata = tmp10;
3221 if (serviceapplication->permission) {
3222 LISTHEAD(serviceapplication->permission, tmp11);
3223 serviceapplication->permission = tmp11;
3229 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile)
3231 /*TODO: once policy is set*/
3235 static int __ps_process_font(xmlTextReaderPtr reader, font_x *font)
3237 /*TODO: once policy is set*/
3241 static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme)
3243 /*TODO: once policy is set*/
3247 static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon)
3249 /*TODO: once policy is set*/
3253 static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime)
3255 /*TODO: once policy is set*/
3259 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx)
3261 DBG("__start_process\n");
3262 const xmlChar *node;
3265 label_x *tmp1 = NULL;
3266 author_x *tmp2 = NULL;
3267 description_x *tmp3 = NULL;
3268 license_x *tmp4 = NULL;
3269 uiapplication_x *tmp5 = NULL;
3270 serviceapplication_x *tmp6 = NULL;
3271 daemon_x *tmp7 = NULL;
3272 theme_x *tmp8 = NULL;
3273 font_x *tmp9 = NULL;
3274 ime_x *tmp10 = NULL;
3275 icon_x *tmp11 = NULL;
3276 compatibility_x *tmp12 = NULL;
3277 deviceprofile_x *tmp13 = NULL;
3278 privileges_x *tmp14 = NULL;
3280 depth = xmlTextReaderDepth(reader);
3281 while ((ret = __next_child_element(reader, depth))) {
3282 node = xmlTextReaderConstName(reader);
3284 DBG("xmlTextReaderConstName value is NULL\n");
3288 if (!strcmp(ASCII(node), "label")) {
3289 label_x *label = malloc(sizeof(label_x));
3290 if (label == NULL) {
3291 DBG("Malloc Failed\n");
3294 memset(label, '\0', sizeof(label_x));
3295 LISTADD(mfx->label, label);
3296 ret = __ps_process_label(reader, label);
3297 } else if (!strcmp(ASCII(node), "author")) {
3298 author_x *author = malloc(sizeof(author_x));
3299 if (author == NULL) {
3300 DBG("Malloc Failed\n");
3303 memset(author, '\0', sizeof(author_x));
3304 LISTADD(mfx->author, author);
3305 ret = __ps_process_author(reader, author);
3306 } else if (!strcmp(ASCII(node), "description")) {
3307 description_x *description = malloc(sizeof(description_x));
3308 if (description == NULL) {
3309 DBG("Malloc Failed\n");
3312 memset(description, '\0', sizeof(description_x));
3313 LISTADD(mfx->description, description);
3314 ret = __ps_process_description(reader, description);
3315 } else if (!strcmp(ASCII(node), "license")) {
3316 license_x *license = malloc(sizeof(license_x));
3317 if (license == NULL) {
3318 DBG("Malloc Failed\n");
3321 memset(license, '\0', sizeof(license_x));
3322 LISTADD(mfx->license, license);
3323 ret = __ps_process_license(reader, license);
3324 } else if (!strcmp(ASCII(node), "privileges")) {
3325 privileges_x *privileges = malloc(sizeof(privileges_x));
3326 if (privileges == NULL) {
3327 DBG("Malloc Failed\n");
3330 memset(privileges, '\0', sizeof(privileges_x));
3331 LISTADD(mfx->privileges, privileges);
3332 ret = __ps_process_privileges(reader, privileges);
3333 } else if (!strcmp(ASCII(node), "ui-application")) {
3334 uiapplication_x *uiapplication = malloc(sizeof(uiapplication_x));
3335 if (uiapplication == NULL) {
3336 DBG("Malloc Failed\n");
3339 memset(uiapplication, '\0', sizeof(uiapplication_x));
3340 LISTADD(mfx->uiapplication, uiapplication);
3341 ret = __ps_process_uiapplication(reader, uiapplication);
3342 } else if (!strcmp(ASCII(node), "service-application")) {
3343 serviceapplication_x *serviceapplication = malloc(sizeof(serviceapplication_x));
3344 if (serviceapplication == NULL) {
3345 DBG("Malloc Failed\n");
3348 memset(serviceapplication, '\0', sizeof(serviceapplication_x));
3349 LISTADD(mfx->serviceapplication, serviceapplication);
3350 ret = __ps_process_serviceapplication(reader, serviceapplication);
3351 } else if (!strcmp(ASCII(node), "daemon")) {
3352 daemon_x *daemon = malloc(sizeof(daemon_x));
3353 if (daemon == NULL) {
3354 DBG("Malloc Failed\n");
3357 memset(daemon, '\0', sizeof(daemon_x));
3358 LISTADD(mfx->daemon, daemon);
3359 ret = __ps_process_daemon(reader, daemon);
3360 } else if (!strcmp(ASCII(node), "theme")) {
3361 theme_x *theme = malloc(sizeof(theme_x));
3362 if (theme == NULL) {
3363 DBG("Malloc Failed\n");
3366 memset(theme, '\0', sizeof(theme_x));
3367 LISTADD(mfx->theme, theme);
3368 ret = __ps_process_theme(reader, theme);
3369 } else if (!strcmp(ASCII(node), "font")) {
3370 font_x *font = malloc(sizeof(font_x));
3372 DBG("Malloc Failed\n");
3375 memset(font, '\0', sizeof(font_x));
3376 LISTADD(mfx->font, font);
3377 ret = __ps_process_font(reader, font);
3378 } else if (!strcmp(ASCII(node), "ime")) {
3379 ime_x *ime = malloc(sizeof(ime_x));
3381 DBG("Malloc Failed\n");
3384 memset(ime, '\0', sizeof(ime_x));
3385 LISTADD(mfx->ime, ime);
3386 ret = __ps_process_ime(reader, ime);
3387 } else if (!strcmp(ASCII(node), "icon")) {
3388 icon_x *icon = malloc(sizeof(icon_x));
3390 DBG("Malloc Failed\n");
3393 memset(icon, '\0', sizeof(icon_x));
3394 LISTADD(mfx->icon, icon);
3395 ret = __ps_process_icon(reader, icon);
3396 } else if (!strcmp(ASCII(node), "device-profile")) {
3397 deviceprofile_x *deviceprofile = malloc(sizeof(deviceprofile_x));
3398 if (deviceprofile == NULL) {
3399 DBG("Malloc Failed\n");
3402 memset(deviceprofile, '\0', sizeof(deviceprofile_x));
3403 LISTADD(mfx->deviceprofile, deviceprofile);
3404 ret = __ps_process_deviceprofile(reader, deviceprofile);
3405 } else if (!strcmp(ASCII(node), "compatibility")) {
3406 compatibility_x *compatibility = malloc(sizeof(compatibility_x));
3407 if (compatibility == NULL) {
3408 DBG("Malloc Failed\n");
3411 memset(compatibility, '\0', sizeof(compatibility_x));
3412 LISTADD(mfx->compatibility, compatibility);
3413 ret = __ps_process_compatibility(reader, compatibility);
3414 } else if (!strcmp(ASCII(node), "shortcut-list")) {
3416 } else if (!strcmp(ASCII(node), "livebox")) {
3418 } else if (!strcmp(ASCII(node), "account")) {
3420 } else if (!strcmp(ASCII(node), "notifications")) {
3422 } else if (!strcmp(ASCII(node), "ime")) {
3428 DBG("Processing manifest failed\n");
3433 LISTHEAD(mfx->label, tmp1);
3437 LISTHEAD(mfx->author, tmp2);
3440 if (mfx->description) {
3441 LISTHEAD(mfx->description, tmp3);
3442 mfx->description= tmp3;
3445 LISTHEAD(mfx->license, tmp4);
3448 if (mfx->uiapplication) {
3449 LISTHEAD(mfx->uiapplication, tmp5);
3450 mfx->uiapplication = tmp5;
3452 if (mfx->serviceapplication) {
3453 LISTHEAD(mfx->serviceapplication, tmp6);
3454 mfx->serviceapplication = tmp6;
3457 LISTHEAD(mfx->daemon, tmp7);
3461 LISTHEAD(mfx->theme, tmp8);
3465 LISTHEAD(mfx->font, tmp9);
3469 LISTHEAD(mfx->ime, tmp10);
3473 LISTHEAD(mfx->icon, tmp11);
3476 if (mfx->compatibility) {
3477 LISTHEAD(mfx->compatibility, tmp12);
3478 mfx->compatibility= tmp12;
3480 if (mfx->deviceprofile) {
3481 LISTHEAD(mfx->deviceprofile, tmp13);
3482 mfx->deviceprofile= tmp13;
3484 if (mfx->privileges) {
3485 LISTHEAD(mfx->privileges, tmp14);
3486 mfx->privileges = tmp14;
3491 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx)
3493 const xmlChar *node;
3496 if ((ret = __next_child_element(reader, -1))) {
3497 node = xmlTextReaderConstName(reader);
3499 DBG("xmlTextReaderConstName value is NULL\n");
3503 if (!strcmp(ASCII(node), "manifest")) {
3504 if (xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")))
3505 mfx->ns = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")));
3506 if (xmlTextReaderGetAttribute(reader, XMLCHAR("package"))) {
3507 mfx->package= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("package")));
3508 if (mfx->package == NULL) {
3509 DBG("package cant be NULL\n");
3513 DBG("package field is mandatory\n");
3516 package = mfx->package;
3517 if (xmlTextReaderGetAttribute(reader, XMLCHAR("version")))
3518 mfx->version= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("version")));
3519 /*app2ext needs package size for external installation*/
3520 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
3521 mfx->package_size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
3522 if (xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")))
3523 mfx->installlocation = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")));
3524 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
3525 mfx->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
3526 if (xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")))
3527 mfx->root_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")));
3528 if (xmlTextReaderGetAttribute(reader, XMLCHAR("csc_path")))
3529 mfx->csc_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("csc_path")));
3530 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting"))) {
3531 mfx->appsetting = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting")));
3532 if (mfx->appsetting == NULL)
3533 mfx->appsetting = strdup("false");
3535 mfx->appsetting = strdup("false");
3537 if (xmlTextReaderGetAttribute(reader, XMLCHAR("storeclient-id")))
3538 mfx->storeclient_id= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("storeclient-id")));
3539 if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay-setting"))) {
3540 mfx->nodisplay_setting = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay-setting")));
3541 if (mfx->nodisplay_setting == NULL)
3542 mfx->nodisplay_setting = strdup("false");
3544 mfx->nodisplay_setting = strdup("false");
3546 if (xmlTextReaderGetAttribute(reader, XMLCHAR("url")))
3547 mfx->package_url= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("url")));
3549 /*Assign default values. If required it will be overwritten in __add_preload_info()*/
3550 mfx->preload = strdup("False");
3551 mfx->removable = strdup("True");
3552 mfx->readonly = strdup("False");
3553 mfx->update = strdup("False");
3554 char buf[PKG_STRING_LEN_MAX] = {'\0'};
3556 time_t current_time;
3557 time(¤t_time);
3558 snprintf(buf, PKG_STRING_LEN_MAX - 1, "%d", current_time);
3559 val = strndup(buf, PKG_STRING_LEN_MAX - 1);
3560 mfx->installed_time = val;
3562 mfx->installed_storage= strdup("installed_internal");
3564 ret = __start_process(reader, mfx);
3566 DBG("No Manifest element found\n");
3573 #define DESKTOP_RW_PATH "/opt/share/applications/"
3574 #define DESKTOP_RO_PATH "/usr/share/applications/"
3575 #define MANIFEST_RO_PREFIX "/usr/share/packages/"
3577 static char* __convert_to_system_locale(const char *mlocale)
3579 if (mlocale == NULL)
3581 char *locale = NULL;
3582 locale = (char *)calloc(1, 6);
3584 DBGE("Malloc Failed\n");
3588 strncpy(locale, mlocale, 2);
3589 strncat(locale, "_", 1);
3590 locale[3] = toupper(mlocale[3]);
3591 locale[4] = toupper(mlocale[4]);
3595 #define LIBAIL_PATH "/usr/lib/libail.so.0"
3597 /* operation_type */
3606 static int __ail_change_info(int op, const char *appid)
3608 void *lib_handle = NULL;
3609 int (*ail_desktop_operation) (const char *);
3613 if ((lib_handle = dlopen(LIBAIL_PATH, RTLD_LAZY)) == NULL) {
3614 DBGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAIL_PATH);
3621 aop = "ail_desktop_add";
3624 aop = "ail_desktop_update";
3627 aop = "ail_desktop_remove";
3630 aop = "ail_desktop_clean";
3637 if ((ail_desktop_operation =
3638 dlsym(lib_handle, aop)) == NULL || dlerror() != NULL) {
3639 DBGE("can not find symbol \n");
3643 ret = ail_desktop_operation(appid);
3647 dlclose(lib_handle);
3653 /* desktop shoud be generated automatically based on manifest */
3654 /* Currently removable, taskmanage, etc fields are not considerd. it will be decided soon.*/
3655 #define BUFMAX 1024*128
3656 static int __ps_make_nativeapp_desktop(manifest_x * mfx, const char *manifest, bool is_update)
3660 char filepath[PKG_STRING_LEN_MAX] = "";
3662 char *buftemp = NULL;
3663 char *locale = NULL;
3665 buf = (char *)calloc(1, BUFMAX);
3667 DBGE("Malloc Failed\n");
3671 buftemp = (char *)calloc(1, BUFMAX);
3673 DBGE("Malloc Failed\n");
3679 __ail_change_info(AIL_CLEAN, mfx->package);
3681 for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) {
3683 if (manifest != NULL) {
3684 /* skip making a deskfile and update ail, if preload app is updated */
3685 if(strstr(manifest, MANIFEST_RO_PREFIX)) {
3686 __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid);
3687 DBGE("preload app is update : skip and update ail : %s", manifest);
3692 if(mfx->readonly && !strcasecmp(mfx->readonly, "True"))
3693 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RO_PATH, mfx->uiapplication->appid);
3695 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, mfx->uiapplication->appid);
3697 /* skip if desktop exists
3698 if (access(filepath, R_OK) == 0)
3702 file = fopen(filepath, "w");
3705 DBGE("Can't open %s", filepath);
3711 snprintf(buf, BUFMAX, "[Desktop Entry]\n");
3712 fwrite(buf, 1, strlen(buf), file);
3714 for( ; mfx->uiapplication->label ; mfx->uiapplication->label = mfx->uiapplication->label->next) {
3715 if(!strcmp(mfx->uiapplication->label->lang, DEFAULT_LOCALE)) {
3716 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
3718 locale = __convert_to_system_locale(mfx->uiapplication->label->lang);
3719 snprintf(buf, BUFMAX, "Name[%s]=%s\n", locale,
3720 mfx->uiapplication->label->text);
3723 fwrite(buf, 1, strlen(buf), file);
3726 if(mfx->uiapplication->label && mfx->uiapplication->label->text) {
3727 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
3728 fwrite(buf, 1, strlen(buf), file);
3731 else if(mfx->label && mfx->label->text) {
3732 snprintf(buf, BUFMAX, "Name=%s\n", mfx->label->text);
3733 fwrite(buf, 1, strlen(buf), file);
3735 snprintf(buf, BUFMAX, "Name=%s\n", mfx->package);
3736 fwrite(buf, 1, strlen(buf), file);
3741 snprintf(buf, BUFMAX, "Type=Application\n");
3742 fwrite(buf, 1, strlen(buf), file);
3744 if(mfx->uiapplication->exec) {
3745 snprintf(buf, BUFMAX, "Exec=%s\n", mfx->uiapplication->exec);
3746 fwrite(buf, 1, strlen(buf), file);
3749 if(mfx->uiapplication->icon && mfx->uiapplication->icon->text) {
3750 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->uiapplication->icon->text);
3751 fwrite(buf, 1, strlen(buf), file);
3752 } else if(mfx->icon && mfx->icon->text) {
3753 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->icon->text);
3754 fwrite(buf, 1, strlen(buf), file);
3758 if(mfx->uiapplication && mfx->uiapplication->appsvc) {
3759 appsvc_x *asvc = mfx->uiapplication->appsvc;
3761 const char *mime = NULL;
3762 const char *mime_delim = "; ";
3765 strncpy(buf, "MimeType=", BUFMAX-1);
3771 DBG("MIME type: %s\n", mime);
3772 strncat(buf, mime, BUFMAX-strlen(buf)-1);
3774 strncat(buf, mime_delim, BUFMAX-strlen(buf)-1);
3782 DBG("MIME types: buf[%s]\n", buf);
3783 DBG("MIME count: %d\n", mime_count);
3785 fwrite(buf, 1, strlen(buf), file);
3789 snprintf(buf, BUFMAX, "Version=%s\n", mfx->version);
3790 fwrite(buf, 1, strlen(buf), file);
3793 if(mfx->uiapplication->nodisplay) {
3794 snprintf(buf, BUFMAX, "NoDisplay=%s\n", mfx->uiapplication->nodisplay);
3795 fwrite(buf, 1, strlen(buf), file);
3798 if(mfx->uiapplication->categories) {
3799 snprintf(buf, BUFMAX, "Categories=%s\n", mfx->uiapplication->categories);
3800 fwrite(buf, 1, strlen(buf), file);
3803 if(mfx->uiapplication->taskmanage && !strcasecmp(mfx->uiapplication->taskmanage, "False")) {
3804 snprintf(buf, BUFMAX, "X-TIZEN-TaskManage=False\n");
3805 fwrite(buf, 1, strlen(buf), file);
3808 if(mfx->uiapplication->enabled && !strcasecmp(mfx->uiapplication->enabled, "False")) {
3809 snprintf(buf, BUFMAX, "X-TIZEN-Enabled=False\n");
3810 fwrite(buf, 1, strlen(buf), file);
3813 if(mfx->uiapplication->hwacceleration) {
3814 snprintf(buf, BUFMAX, "Hw-Acceleration=%s\n", mfx->uiapplication->hwacceleration);
3815 fwrite(buf, 1, strlen(buf), file);
3818 if(mfx->uiapplication->multiple && !strcasecmp(mfx->uiapplication->multiple, "True")) {
3819 snprintf(buf, BUFMAX, "X-TIZEN-Multiple=True\n");
3820 fwrite(buf, 1, strlen(buf), file);
3823 if(mfx->uiapplication->extraid) {
3824 snprintf(buf, BUFMAX, "X-TIZEN-PackageID=%s\n", mfx->uiapplication->extraid);
3825 fwrite(buf, 1, strlen(buf), file);
3828 if(mfx->removable && !strcasecmp(mfx->removable, "False")) {
3829 snprintf(buf, BUFMAX, "X-TIZEN-Removable=False\n");
3830 fwrite(buf, 1, strlen(buf), file);
3834 snprintf(buf, BUFMAX, "X-TIZEN-PackageType=%s\n", mfx->type);
3835 fwrite(buf, 1, strlen(buf), file);
3838 snprintf(buf, BUFMAX, "X-TIZEN-PkgID=%s\n", mfx->package);
3839 fwrite(buf, 1, strlen(buf), file);
3842 // snprintf(buf, BUFMAX, "X-TIZEN-PackageType=rpm\n");
3843 // fwrite(buf, 1, strlen(buf), file);
3846 if(mfx->uiapplication->appsvc) {
3847 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
3848 DBG("buf[%s]\n", buf);
3851 uiapplication_x *up = mfx->uiapplication;
3852 appsvc_x *asvc = NULL;
3853 operation_x *op = NULL;
3856 subapp_x *sub = NULL;
3857 const char *operation = NULL;
3858 const char *mime = NULL;
3859 const char *uri = NULL;
3860 const char *subapp = NULL;
3865 while(asvc != NULL) {
3866 op = asvc->operation;
3869 operation = op->name;
3888 strncpy(buftemp, buf, BUFMAX);
3889 snprintf(buf, BUFMAX, "%s;", buftemp);
3893 strncpy(buftemp, buf, BUFMAX);
3894 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
3895 DBG("buf[%s]\n", buf);
3900 } while(ui != NULL);
3904 }while(sub != NULL);
3917 fwrite(buf, 1, strlen(buf), file);
3919 // strncpy(buftemp, buf, BUFMAX);
3920 // snprintf(buf, BUFMAX, "%s\n", buftemp);
3921 // fwrite(buf, 1, strlen(buf), file);
3924 if(mfx->uiapplication->appcontrol) {
3925 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
3926 DBG("buf[%s]\n", buf);
3928 uiapplication_x *up = mfx->uiapplication;
3929 appcontrol_x *acontrol = NULL;
3930 operation_x *op = NULL;
3933 subapp_x *sub = NULL;
3934 const char *operation = NULL;
3935 const char *mime = NULL;
3936 const char *uri = NULL;
3937 const char *subapp = NULL;
3940 acontrol = up->appcontrol;
3941 while(acontrol != NULL) {
3942 op = acontrol->operation;
3945 operation = op->name;
3946 mi = acontrol->mime;
3952 sub = acontrol->subapp;
3964 strncpy(buftemp, buf, BUFMAX);
3965 snprintf(buf, BUFMAX, "%s;", buftemp);
3968 strncpy(buftemp, buf, BUFMAX);
3969 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
3970 DBG("buf[%s]\n", buf);
3975 } while(ui != NULL);
3979 }while(sub != NULL);
3988 acontrol = acontrol->next;
3992 fwrite(buf, 1, strlen(buf), file);
3994 // strncpy(buftemp, buf, BUFMAX);
3995 // snprintf(buf, BUFMAX, "%s\n", buftemp);
3996 // fwrite(buf, 1, strlen(buf), file);
4004 __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid);
4013 static int __ps_remove_nativeapp_desktop(manifest_x *mfx)
4015 char filepath[PKG_STRING_LEN_MAX] = "";
4017 uiapplication_x *uiapplication = mfx->uiapplication;
4019 for(; uiapplication; uiapplication=uiapplication->next) {
4020 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, uiapplication->appid);
4022 __ail_change_info(AIL_REMOVE, uiapplication->appid);
4024 ret = remove(filepath);
4032 #define LIBAPPSVC_PATH "/usr/lib/libappsvc.so.0"
4034 static int __ps_remove_appsvc_db(manifest_x *mfx)
4036 void *lib_handle = NULL;
4037 int (*appsvc_operation) (const char *);
4039 uiapplication_x *uiapplication = mfx->uiapplication;
4041 if ((lib_handle = dlopen(LIBAPPSVC_PATH, RTLD_LAZY)) == NULL) {
4042 DBGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAPPSVC_PATH);
4046 if ((appsvc_operation =
4047 dlsym(lib_handle, "appsvc_unset_defapp")) == NULL || dlerror() != NULL) {
4048 DBGE("can not find symbol \n");
4052 for(; uiapplication; uiapplication=uiapplication->next) {
4053 ret = appsvc_operation(uiapplication->appid);
4055 DBGE("can not operation symbol \n");
4060 dlclose(lib_handle);
4065 #define PRELOAD_PACKAGE_LIST "/usr/etc/package-manager/preload/preload_list.txt"
4066 static int __add_preload_info(manifest_x * mfx, const char *manifest)
4069 char buffer[1024] = { 0 };
4072 if(strstr(manifest, MANIFEST_RO_PREFIX)) {
4073 free((void *)mfx->readonly);
4074 mfx->readonly = strdup("True");
4076 free((void *)mfx->preload);
4077 mfx->preload = strdup("True");
4079 free((void *)mfx->removable);
4080 mfx->removable = strdup("False");
4085 fp = fopen(PRELOAD_PACKAGE_LIST, "r");
4087 DBGE("no preload list\n");
4091 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
4092 if (buffer[0] == '#') {
4093 if(strcasestr(buffer, "RW_NORM"))
4095 else if(strcasestr(buffer, "RW_RM"))
4103 if(!strcmp(mfx->package, buffer)) {
4104 free((void *)mfx->preload);
4105 mfx->preload = strdup("True");
4107 free((void *)mfx->readonly);
4108 mfx->readonly = strdup("False");
4109 free((void *)mfx->removable);
4110 mfx->removable = strdup("False");
4111 } else if(state == 3){
4112 free((void *)mfx->readonly);
4113 mfx->readonly = strdup("False");
4114 free((void *)mfx->removable);
4115 mfx->removable = strdup("True");
4119 memset(buffer, 0x00, sizeof(buffer));
4128 static int __check_preload_updated(manifest_x * mfx, const char *manifest)
4130 char filepath[PKG_STRING_LEN_MAX] = "";
4132 uiapplication_x *uiapplication = mfx->uiapplication;
4134 if(strstr(manifest, MANIFEST_RO_PREFIX)) {
4135 /* if preload app is updated, then remove previous desktop file on RW*/
4136 for(; uiapplication; uiapplication=uiapplication->next) {
4137 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, uiapplication->appid);
4138 ret = remove(filepath);
4143 /* if downloaded app is updated, then update tag set true*/
4144 free((void *)mfx->update);
4145 mfx->update = strdup("true");
4152 API int pkgmgr_parser_create_desktop_file(manifest_x *mfx)
4156 DBG("Manifest pointer is NULL\n");
4159 ret = __ps_make_nativeapp_desktop(mfx, NULL, 0);
4161 DBG("Creating desktop file failed\n");
4163 DBG("Creating desktop file Success\n");
4167 API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
4172 free((void *)mfx->ns);
4176 free((void *)mfx->package);
4177 mfx->package = NULL;
4180 free((void *)mfx->version);
4181 mfx->version = NULL;
4183 if (mfx->installlocation) {
4184 free((void *)mfx->installlocation);
4185 mfx->installlocation = NULL;
4188 free((void *)mfx->preload);
4189 mfx->preload = NULL;
4191 if (mfx->readonly) {
4192 free((void *)mfx->readonly);
4193 mfx->readonly = NULL;
4195 if (mfx->removable) {
4196 free((void *)mfx->removable);
4197 mfx->removable = NULL;
4200 free((void *)mfx->update);
4204 free((void *)mfx->type);
4207 if (mfx->package_size) {
4208 free((void *)mfx->package_size);
4209 mfx->package_size = NULL;
4211 if (mfx->installed_time) {
4212 free((void *)mfx->installed_time);
4213 mfx->installed_time = NULL;
4215 if (mfx->installed_storage) {
4216 free((void *)mfx->installed_storage);
4217 mfx->installed_storage = NULL;
4219 if (mfx->storeclient_id) {
4220 free((void *)mfx->storeclient_id);
4221 mfx->storeclient_id = NULL;
4223 if (mfx->mainapp_id) {
4224 free((void *)mfx->mainapp_id);
4225 mfx->mainapp_id = NULL;
4227 if (mfx->package_url) {
4228 free((void *)mfx->package_url);
4229 mfx->package_url = NULL;
4231 if (mfx->root_path) {
4232 free((void *)mfx->root_path);
4233 mfx->root_path = NULL;
4235 if (mfx->csc_path) {
4236 free((void *)mfx->csc_path);
4237 mfx->csc_path = NULL;
4239 if (mfx->appsetting) {
4240 free((void *)mfx->appsetting);
4241 mfx->appsetting = NULL;
4243 if (mfx->nodisplay_setting) {
4244 free((void *)mfx->nodisplay_setting);
4245 mfx->nodisplay_setting = NULL;
4250 icon_x *icon = mfx->icon;
4252 while(icon != NULL) {
4254 __ps_free_icon(icon);
4260 label_x *label = mfx->label;
4261 label_x *tmp = NULL;
4262 while(label != NULL) {
4264 __ps_free_label(label);
4270 author_x *author = mfx->author;
4271 author_x *tmp = NULL;
4272 while(author != NULL) {
4274 __ps_free_author(author);
4278 /*Free Description*/
4279 if (mfx->description) {
4280 description_x *description = mfx->description;
4281 description_x *tmp = NULL;
4282 while(description != NULL) {
4283 tmp = description->next;
4284 __ps_free_description(description);
4290 license_x *license = mfx->license;
4291 license_x *tmp = NULL;
4292 while(license != NULL) {
4293 tmp = license->next;
4294 __ps_free_license(license);
4299 if (mfx->privileges) {
4300 privileges_x *privileges = mfx->privileges;
4301 privileges_x *tmp = NULL;
4302 while(privileges != NULL) {
4303 tmp = privileges->next;
4304 __ps_free_privileges(privileges);
4308 /*Free UiApplication*/
4309 if (mfx->uiapplication) {
4310 uiapplication_x *uiapplication = mfx->uiapplication;
4311 uiapplication_x *tmp = NULL;
4312 while(uiapplication != NULL) {
4313 tmp = uiapplication->next;
4314 __ps_free_uiapplication(uiapplication);
4315 uiapplication = tmp;
4318 /*Free ServiceApplication*/
4319 if (mfx->serviceapplication) {
4320 serviceapplication_x *serviceapplication = mfx->serviceapplication;
4321 serviceapplication_x *tmp = NULL;
4322 while(serviceapplication != NULL) {
4323 tmp = serviceapplication->next;
4324 __ps_free_serviceapplication(serviceapplication);
4325 serviceapplication = tmp;
4330 daemon_x *daemon = mfx->daemon;
4331 daemon_x *tmp = NULL;
4332 while(daemon != NULL) {
4334 __ps_free_daemon(daemon);
4340 theme_x *theme = mfx->theme;
4341 theme_x *tmp = NULL;
4342 while(theme != NULL) {
4344 __ps_free_theme(theme);
4350 font_x *font = mfx->font;
4352 while(font != NULL) {
4354 __ps_free_font(font);
4360 ime_x *ime = mfx->ime;
4362 while(ime != NULL) {
4368 /*Free Compatibility*/
4369 if (mfx->compatibility) {
4370 compatibility_x *compatibility = mfx->compatibility;
4371 compatibility_x *tmp = NULL;
4372 while(compatibility != NULL) {
4373 tmp = compatibility->next;
4374 __ps_free_compatibility(compatibility);
4375 compatibility = tmp;
4378 /*Free DeviceProfile*/
4379 if (mfx->deviceprofile) {
4380 deviceprofile_x *deviceprofile = mfx->deviceprofile;
4381 deviceprofile_x *tmp = NULL;
4382 while(deviceprofile != NULL) {
4383 tmp = deviceprofile->next;
4384 __ps_free_deviceprofile(deviceprofile);
4385 deviceprofile = tmp;
4393 API manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest)
4395 DBG("parsing start\n");
4396 xmlTextReaderPtr reader;
4397 manifest_x *mfx = NULL;
4399 reader = xmlReaderForFile(manifest, NULL, 0);
4401 mfx = malloc(sizeof(manifest_x));
4403 memset(mfx, '\0', sizeof(manifest_x));
4404 if (__process_manifest(reader, mfx) < 0) {
4405 DBG("Parsing Failed\n");
4406 pkgmgr_parser_free_manifest_xml(mfx);
4409 DBG("Parsing Success\n");
4411 DBG("Memory allocation error\n");
4413 xmlFreeTextReader(reader);
4415 DBG("Unable to create xml reader\n");
4420 /* These APIs are intended to call parser directly */
4422 API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
4424 char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
4425 if (manifest == NULL) {
4426 DBG("argument supplied is NULL\n");
4427 return PMINFO_R_EINVAL;
4429 DBG("parsing manifest for installation: %s\n", manifest);
4430 manifest_x *mfx = NULL;
4432 char roxml_check[PKG_STRING_LEN_MAX] = {'\0'};
4435 mfx = pkgmgr_parser_process_manifest_xml(manifest);
4436 DBG("Parsing Finished\n");
4438 return PMINFO_R_ERROR;
4440 __streamFile(manifest, ACTION_INSTALL, temp, mfx->package);
4441 __add_preload_info(mfx, manifest);
4442 DBG("Added preload infomation\n");
4444 __ps_process_tag(mfx, tagv);
4446 ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
4448 DBG("DB Insert failed\n");
4450 DBG("DB Insert Success\n");
4452 ret = __ps_process_mdparser(mfx, ACTION_INSTALL);
4454 DBG("Creating metadata parser failed\n");
4456 ret = __ps_make_nativeapp_desktop(mfx, NULL, 0);
4458 DBG("Creating desktop file failed\n");
4460 DBG("Creating desktop file Success\n");
4462 pkgmgr_parser_free_manifest_xml(mfx);
4469 API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
4471 char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
4472 if (manifest == NULL) {
4473 DBG("argument supplied is NULL\n");
4474 return PMINFO_R_EINVAL;
4476 DBG("parsing manifest for upgradation: %s\n", manifest);
4477 manifest_x *mfx = NULL;
4479 bool preload = false;
4480 char *csc_path = NULL;
4481 pkgmgrinfo_pkginfo_h handle = NULL;
4484 mfx = pkgmgr_parser_process_manifest_xml(manifest);
4485 DBG("Parsing Finished\n");
4487 return PMINFO_R_ERROR;
4489 __streamFile(manifest, ACTION_UPGRADE, temp, mfx->package);
4490 __add_preload_info(mfx, manifest);
4491 DBG("Added preload infomation\n");
4492 __check_preload_updated(mfx, manifest);
4494 ret = pkgmgrinfo_pkginfo_get_pkginfo(mfx->package, &handle);
4495 if (ret != PMINFO_R_OK)
4496 DBG("pkgmgrinfo_pkginfo_get_pkginfo failed\n");
4498 ret = pkgmgrinfo_pkginfo_is_preload(handle, &preload);
4499 if (ret != PMINFO_R_OK)
4500 DBG("pkgmgrinfo_pkginfo_is_preload failed\n");
4503 free((void *)mfx->preload);
4504 mfx->preload = strdup("true");
4507 ret = pkgmgrinfo_pkginfo_get_csc_path(handle, &csc_path);
4508 if (ret != PMINFO_R_OK)
4509 DBG("pkgmgrinfo_pkginfo_get_csc_path failed\n");
4511 if (csc_path != NULL) {
4513 free((void *)mfx->csc_path);
4514 mfx->csc_path = strdup(csc_path);
4517 ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
4519 DBG("DB Update failed\n");
4521 DBG("DB Update Success\n");
4523 ret = __ps_process_mdparser(mfx, ACTION_UPGRADE);
4525 DBG("Upgrade metadata parser failed\n");
4527 ret = __ps_make_nativeapp_desktop(mfx, manifest, 1);
4529 DBG("Creating desktop file failed\n");
4531 DBG("Creating desktop file Success\n");
4533 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
4534 pkgmgr_parser_free_manifest_xml(mfx);
4541 API int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[])
4543 char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
4544 if (manifest == NULL) {
4545 DBG("argument supplied is NULL\n");
4546 return PMINFO_R_EINVAL;
4548 DBG("parsing manifest for uninstallation: %s\n", manifest);
4549 manifest_x *mfx = NULL;
4552 mfx = pkgmgr_parser_process_manifest_xml(manifest);
4553 DBG("Parsing Finished\n");
4555 return PMINFO_R_ERROR;
4557 __streamFile(manifest, ACTION_UNINSTALL, temp, mfx->package);
4558 __add_preload_info(mfx, manifest);
4559 DBG("Added preload infomation\n");
4561 ret = __ps_process_mdparser(mfx, ACTION_UNINSTALL);
4563 DBG("Removing metadata parser failed\n");
4565 ret = pkgmgr_parser_delete_manifest_info_from_db(mfx);
4567 DBG("DB Delete failed\n");
4569 DBG("DB Delete Success\n");
4571 ret = __ps_remove_nativeapp_desktop(mfx);
4573 DBG("Removing desktop file failed\n");
4575 DBG("Removing desktop file Success\n");
4577 ret = __ps_remove_appsvc_db(mfx);
4579 DBG("Removing appsvc_db failed\n");
4581 DBG("Removing appsvc_db Success\n");
4583 pkgmgr_parser_free_manifest_xml(mfx);
4590 API int pkgmgr_parser_parse_manifest_for_preload()
4592 return pkgmgr_parser_update_preload_info_in_db();
4595 API char *pkgmgr_parser_get_manifest_file(const char *pkgid)
4597 return __pkgid_to_manifest(pkgid);
4600 API int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
4602 return __ps_run_parser(docPtr, tag, ACTION_INSTALL, pkgid);
4605 API int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgid)
4607 return __ps_run_parser(docPtr, tag, ACTION_UPGRADE, pkgid);
4610 API int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
4612 return __ps_run_parser(docPtr, tag, ACTION_UNINSTALL, pkgid);
4615 #define SCHEMA_FILE "/usr/etc/package-manager/preload/manifest.xsd"
4617 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
4619 if (manifest == NULL) {
4620 DBGE("manifest file is NULL\n");
4621 return PMINFO_R_EINVAL;
4624 xmlSchemaParserCtxtPtr ctx;
4625 xmlSchemaValidCtxtPtr vctx;
4626 xmlSchemaPtr xschema;
4627 ctx = xmlSchemaNewParserCtxt(SCHEMA_FILE);
4629 DBGE("xmlSchemaNewParserCtxt() Failed\n");
4630 return PMINFO_R_ERROR;
4632 xschema = xmlSchemaParse(ctx);
4633 if (xschema == NULL) {
4634 DBGE("xmlSchemaParse() Failed\n");
4635 return PMINFO_R_ERROR;
4637 vctx = xmlSchemaNewValidCtxt(xschema);
4639 DBGE("xmlSchemaNewValidCtxt() Failed\n");
4640 return PMINFO_R_ERROR;
4642 xmlSchemaSetValidErrors(vctx, (xmlSchemaValidityErrorFunc) fprintf, (xmlSchemaValidityWarningFunc) fprintf, stderr);
4643 ret = xmlSchemaValidateFile(vctx, manifest, 0);
4645 DBGE("xmlSchemaValidateFile() failed\n");
4646 return PMINFO_R_ERROR;
4647 } else if (ret == 0) {
4648 DBGE("Manifest is Valid\n");
4651 DBGE("Manifest Validation Failed with error code %d\n", ret);
4652 return PMINFO_R_ERROR;
4658 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
4668 DBGE("fork failed\n");
4673 int dev_null_fd = open ("/dev/null", O_RDWR);
4674 if (dev_null_fd >= 0)
4676 dup2 (dev_null_fd, 0);/*stdin*/
4677 dup2 (dev_null_fd, 1);/*stdout*/
4678 dup2 (dev_null_fd, 2);/*stderr*/
4681 if (execl("/usr/bin/xmllint", "xmllint", manifest, "--schema",
4682 SCHEMA_FILE, NULL) < 0) {
4683 DBGE("execl error\n");
4693 while ((err = waitpid(pid, &status, WNOHANG)) != pid) {
4697 DBGE("waitpid failed\n");
4703 if(WIFEXITED(status) && !WEXITSTATUS(status))