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:"
50 #define CATEGORY_PARSER_LIST "/usr/etc/package-manager/parserlib/category/category_parser_list.txt"
51 #define CATEGORY_PARSER_NAME "categoryparser:"
53 #define PKG_TAG_LEN_MAX 128
63 /* plugin process_type */
65 PLUGIN_PRE_PROCESS = 0,
67 } PLUGIN_PROCESS_TYPE;
80 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label);
81 static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege);
82 static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privileges);
83 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile);
84 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed);
85 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation);
86 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri);
87 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime);
88 static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp);
89 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition);
90 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notifiation);
91 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category);
92 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata);
93 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission);
94 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility);
95 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution);
96 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request);
97 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define);
98 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc);
99 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions);
100 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare);
101 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon);
102 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author);
103 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description);
104 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability);
105 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license);
106 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol);
107 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol);
108 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication);
109 static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication);
110 static int __ps_process_font(xmlTextReaderPtr reader, font_x *font);
111 static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme);
112 static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon);
113 static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime);
114 static void __ps_free_label(label_x *label);
115 static void __ps_free_privilege(privilege_x *privilege);
116 static void __ps_free_privileges(privileges_x *privileges);
117 static void __ps_free_deviceprofile(deviceprofile_x * deviceprofile);
118 static void __ps_free_allowed(allowed_x *allowed);
119 static void __ps_free_operation(operation_x *operation);
120 static void __ps_free_uri(uri_x *uri);
121 static void __ps_free_mime(mime_x *mime);
122 static void __ps_free_subapp(subapp_x *subapp);
123 static void __ps_free_condition(condition_x *condition);
124 static void __ps_free_notification(notification_x *notifiation);
125 static void __ps_free_category(category_x *category);
126 static void __ps_free_metadata(metadata_x *metadata);
127 static void __ps_free_permission(permission_x *permission);
128 static void __ps_free_compatibility(compatibility_x *compatibility);
129 static void __ps_free_resolution(resolution_x *resolution);
130 static void __ps_free_request(request_x *request);
131 static void __ps_free_define(define_x *define);
132 static void __ps_free_appsvc(appsvc_x *appsvc);
133 static void __ps_free_launchconditions(launchconditions_x *launchconditions);
134 static void __ps_free_datashare(datashare_x *datashare);
135 static void __ps_free_icon(icon_x *icon);
136 static void __ps_free_author(author_x *author);
137 static void __ps_free_description(description_x *description);
138 static void __ps_free_capability(capability_x *capability);
139 static void __ps_free_license(license_x *license);
140 static void __ps_free_appcontrol(appcontrol_x *appcontrol);
141 static void __ps_free_datacontrol(datacontrol_x *datacontrol);
142 static void __ps_free_uiapplication(uiapplication_x *uiapplication);
143 static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication);
144 static void __ps_free_font(font_x *font);
145 static void __ps_free_theme(theme_x *theme);
146 static void __ps_free_daemon(daemon_x *daemon);
147 static void __ps_free_ime(ime_x *ime);
148 static char *__pkgid_to_manifest(const char *pkgid);
149 static int __next_child_element(xmlTextReaderPtr reader, int depth);
150 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx);
151 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx);
152 static void __str_trim(char *input);
153 static char *__get_parser_plugin(const char *type);
154 static int __ps_run_parser(xmlDocPtr docPtr, const char *tag, ACTION_TYPE action, const char *pkgid);
155 static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid);
156 static void __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgid);
157 static void __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid);
158 static int __validate_appid(const char *pkgid, const char *appid, char **newappid);
160 static void __str_trim(char *input)
162 char *trim_str = input;
167 while (*input != 0) {
168 if (!isspace(*input)) {
179 static int __validate_appid(const char *pkgid, const char *appid, char **newappid)
181 if (!pkgid || !appid || !newappid) {
182 DBG("Arg supplied is NULL\n");
185 int pkglen = strlen(pkgid);
186 int applen = strlen(appid);
190 if (strncmp(appid, ".", 1) == 0) {
191 len = pkglen + applen + 1;
192 newapp = calloc(1,len);
193 if (newapp == NULL) {
194 DBG("Malloc failed\n");
197 strncpy(newapp, pkgid, pkglen);
198 strncat(newapp, appid, applen);
199 DBG("new appid is %s\n", newapp);
203 if (applen < pkglen) {
204 DBG("app id is not proper\n");
206 #ifdef _VALIDATE_APPID_
212 if (!strcmp(appid, pkgid)) {
213 DBG("appid is proper\n");
217 else if (strncmp(appid, pkgid, pkglen) == 0) {
218 ptr = strstr(appid, pkgid);
220 if (strncmp(ptr, ".", 1) == 0) {
221 DBG("appid is proper\n");
226 DBG("appid is not proper\n");
228 #ifdef _VALIDATE_APPID_
235 DBG("appid is not proper\n");
237 #ifdef _VALIDATE_APPID_
246 static char * __get_tag_by_key(char *md_key)
250 if (md_key == NULL) {
251 DBG("md_key is NULL\n");
255 md_tag = strrchr(md_key, 47) + 1;
258 return strdup(md_tag);
261 static char *__get_mdparser_plugin(const char *type)
264 char buffer[1024] = { 0 };
265 char temp_path[1024] = { 0 };
269 DBGE("invalid argument\n");
273 fp = fopen(PKG_PARSER_CONF_PATH, "r");
275 DBGE("no matching mdparser\n");
279 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
280 if (buffer[0] == '#')
285 if ((path = strstr(buffer, MDPARSER_NAME)) != NULL) {
286 path = path + strlen(MDPARSER_NAME);
291 memset(buffer, 0x00, 1024);
298 DBGE("no matching [%s] [%s]\n", MDPARSER_NAME,type);
302 snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
304 return strdup(temp_path);
307 static char *__get_category_parser_plugin(const char *type)
310 char buffer[1024] = { 0 };
311 char temp_path[1024] = { 0 };
315 DBGE("invalid argument\n");
319 fp = fopen(PKG_PARSER_CONF_PATH, "r");
321 DBGE("no matching mdparser\n");
325 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
326 if (buffer[0] == '#')
331 if ((path = strstr(buffer, CATEGORY_PARSER_NAME)) != NULL) {
332 path = path + strlen(CATEGORY_PARSER_NAME);
337 memset(buffer, 0x00, 1024);
344 DBGE("no matching [%s] [%s]\n", CATEGORY_PARSER_NAME,type);
348 snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
350 return strdup(temp_path);
353 static char *__get_parser_plugin(const char *type)
356 char buffer[1024] = { 0 };
357 char temp_path[1024] = { 0 };
361 DBGE("invalid argument\n");
365 fp = fopen(PKG_PARSER_CONF_PATH, "r");
367 DBGE("no matching backendlib\n");
371 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
372 if (buffer[0] == '#')
377 if ((path = strstr(buffer, PKG_PARSERLIB)) != NULL) {
378 path = path + strlen(PKG_PARSERLIB);
382 memset(buffer, 0x00, 1024);
389 DBGE("no matching backendlib\n");
393 snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
395 return strdup(temp_path);
398 static int __ps_run_mdparser(GList *md_list, const char *tag,
399 ACTION_TYPE action, const char *pkgid, const char *appid)
401 char *lib_path = NULL;
402 void *lib_handle = NULL;
403 int (*mdparser_plugin) (const char *, const char *, GList *);
409 ac = "PKGMGR_MDPARSER_PLUGIN_INSTALL";
412 ac = "PKGMGR_MDPARSER_PLUGIN_UPGRADE";
414 case ACTION_UNINSTALL:
415 ac = "PKGMGR_MDPARSER_PLUGIN_UNINSTALL";
421 lib_path = __get_mdparser_plugin(tag);
423 DBGE("get %s parser fail\n", tag);
427 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
428 DBGE("dlopen is failed lib_path[%s]\n", lib_path);
432 if ((mdparser_plugin =
433 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
434 DBGE("can not find symbol[%s] \n",ac);
438 ret = mdparser_plugin(pkgid, appid, md_list);
440 DBG("[appid = %s, libpath = %s plugin fail\n", appid, lib_path);
442 DBG("[appid = %s, libpath = %s plugin success\n", appid, lib_path);
452 static int __ps_run_category_parser(GList *category_list, const char *tag,
453 ACTION_TYPE action, const char *pkgid, const char *appid)
455 char *lib_path = NULL;
456 void *lib_handle = NULL;
457 int (*category_parser_plugin) (const char *, const char *, GList *);
463 ac = "PKGMGR_CATEGORY_PARSER_PLUGIN_INSTALL";
466 ac = "PKGMGR_CATEGORY_PARSER_PLUGIN_UPGRADE";
468 case ACTION_UNINSTALL:
469 ac = "PKGMGR_CATEGORY_PARSER_PLUGIN_UNINSTALL";
475 lib_path = __get_category_parser_plugin(tag);
477 DBGE("get %s parser fail\n", tag);
481 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
482 DBGE("dlopen is failed lib_path[%s]\n", lib_path);
486 if ((category_parser_plugin =
487 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
488 DBGE("can not find symbol[%s] \n",ac);
492 ret = category_parser_plugin(pkgid, appid, category_list);
494 DBG("[appid = %s, libpath = %s plugin fail\n", appid, lib_path);
496 DBG("[appid = %s, libpath = %s plugin success\n", appid, lib_path);
506 static int __ps_run_parser(xmlDocPtr docPtr, const char *tag,
507 ACTION_TYPE action, const char *pkgid)
509 char *lib_path = NULL;
510 void *lib_handle = NULL;
511 int (*plugin_install) (xmlDocPtr, const char *);
517 ac = "PKGMGR_PARSER_PLUGIN_INSTALL";
520 ac = "PKGMGR_PARSER_PLUGIN_UPGRADE";
522 case ACTION_UNINSTALL:
523 ac = "PKGMGR_PARSER_PLUGIN_UNINSTALL";
529 lib_path = __get_parser_plugin(tag);
534 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
535 DBGE("dlopen is failed lib_path[%s]\n", lib_path);
538 if ((plugin_install =
539 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
540 DBGE("can not find symbol[%s] \n", ac);
544 ret = plugin_install(docPtr, pkgid);
546 DBG("[pkgid = %s, libpath = %s plugin fail\n", pkgid, lib_path);
548 DBG("[pkgid = %s, libpath = %s plugin success\n", pkgid, lib_path);
558 static char *__pkgid_to_manifest(const char *pkgid)
564 DBGE("pkgid is NULL");
568 size = strlen(MANIFEST_RW_DIRECTORY) + strlen(pkgid) + 10;
569 manifest = malloc(size);
570 if (manifest == NULL) {
574 memset(manifest, '\0', size);
575 snprintf(manifest, size, MANIFEST_RW_DIRECTORY "/%s.xml", pkgid);
577 if (access(manifest, F_OK)) {
578 snprintf(manifest, size, MANIFEST_RO_DIRECTORY "/%s.xml", pkgid);
584 static void __mdparser_clear_dir_list(GList* dir_list)
587 __metadata_t* detail = NULL;
590 list = g_list_first(dir_list);
592 detail = (__metadata_t *)list->data;
600 list = g_list_next(list);
602 g_list_free(dir_list);
606 static void __category_parser_clear_dir_list(GList* dir_list)
609 __category_t* detail = NULL;
612 list = g_list_first(dir_list);
614 detail = (__category_t *)list->data;
621 list = g_list_next(list);
623 g_list_free(dir_list);
627 static int __run_mdparser_prestep (manifest_x *mfx, char *md_key, ACTION_TYPE action)
631 char buffer[1024] = { 0, };
632 uiapplication_x *up = mfx->uiapplication;
633 metadata_x *md = NULL;
636 GList *md_list = NULL;
637 __metadata_t *md_detail = NULL;
639 md_tag = __get_tag_by_key(md_key);
640 if (md_tag == NULL) {
641 DBG("md_tag is NULL\n");
650 //get glist of meatdata key and value combination
651 memset(buffer, 0x00, 1024);
652 snprintf(buffer, 1024, "%s/", md_key);
653 if ((md->key && md->value) && (strncmp(md->key, md_key, strlen(md_key)) == 0) && (strncmp(buffer, md->key, strlen(buffer)) == 0)) {
654 md_detail = (__metadata_t*) calloc(1, sizeof(__metadata_t));
655 if (md_detail == NULL) {
656 DBG("Memory allocation failed\n");
660 md_detail->key = (char*) calloc(1, sizeof(char)*(strlen(md->key)+2));
661 if (md_detail->key == NULL) {
662 DBG("Memory allocation failed\n");
666 snprintf(md_detail->key, (strlen(md->key)+1), "%s", md->key);
668 md_detail->value = (char*) calloc(1, sizeof(char)*(strlen(md->value)+2));
669 if (md_detail->value == NULL) {
670 DBG("Memory allocation failed\n");
671 free(md_detail->key);
675 snprintf(md_detail->value, (strlen(md->value)+1), "%s", md->value);
677 md_list = g_list_append(md_list, (gpointer)md_detail);
683 //send glist to parser when tags for metadata plugin parser exist.
685 ret = __ps_run_mdparser(md_list, md_tag, action, mfx->package, up->appid);
687 DBG("mdparser failed[%d] for tag[%s]\n", ret, md_tag);
689 DBG("mdparser success for tag[%s]\n", md_tag);
691 __mdparser_clear_dir_list(md_list);
699 __mdparser_clear_dir_list(md_list);
707 static int __run_category_parser_prestep (manifest_x *mfx, char *category_key, ACTION_TYPE action)
711 char buffer[1024] = { 0, };
712 uiapplication_x *up = mfx->uiapplication;
713 category_x *category = NULL;
714 char *category_tag = NULL;
716 GList *category_list = NULL;
717 __category_t *category_detail = NULL;
719 category_tag = __get_tag_by_key(category_key);
720 if (category_tag == NULL) {
721 DBG("md_tag is NULL\n");
727 category = up->category;
728 while (category != NULL)
730 //get glist of meatdata key and value combination
731 memset(buffer, 0x00, 1024);
732 snprintf(buffer, 1024, "%s/", category_key);
733 if ((category->name) && (strncmp(category->name, category_key, strlen(category_key)) == 0)) {
734 category_detail = (__category_t*) calloc(1, sizeof(__category_t));
735 if (category_detail == NULL) {
736 DBG("Memory allocation failed\n");
740 category_detail->name = (char*) calloc(1, sizeof(char)*(strlen(category->name)+2));
741 if (category_detail->name == NULL) {
742 DBG("Memory allocation failed\n");
743 free(category_detail);
746 snprintf(category_detail->name, (strlen(category->name)+1), "%s", category->name);
748 category_list = g_list_append(category_list, (gpointer)category_detail);
751 category = category->next;
754 //send glist to parser when tags for metadata plugin parser exist.
756 ret = __ps_run_category_parser(category_list, category_tag, action, mfx->package, up->appid);
758 DBG("category_parser failed[%d] for tag[%s]\n", ret, category_tag);
760 DBG("category_parser success for tag[%s]\n", category_tag);
762 __category_parser_clear_dir_list(category_list);
763 category_list = NULL;
770 __category_parser_clear_dir_list(category_list);
778 static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid)
783 DBG("__run_parser_prestep");
785 if (xmlTextReaderDepth(reader) != 1) {
786 DBGE("Node depth is not 1");
790 if (xmlTextReaderNodeType(reader) != 1) {
791 DBGE("Node type is not 1");
795 const xmlChar *value;
796 name = xmlTextReaderConstName(reader);
798 DBGE("TEST TEST TES\n");
799 name = BAD_CAST "--";
802 value = xmlTextReaderConstValue(reader);
803 DBG("%d %d %s %d %d",
804 xmlTextReaderDepth(reader),
805 xmlTextReaderNodeType(reader),
807 xmlTextReaderIsEmptyElement(reader), xmlTextReaderHasValue(reader));
810 DBG("ConstValue NULL");
812 if (xmlStrlen(value) > 40) {
813 DBG(" %.40s...", value);
819 name = xmlTextReaderConstName(reader);
821 DBGE("TEST TEST TES\n");
822 name = BAD_CAST "--";
825 xmlDocPtr docPtr = xmlTextReaderCurrentDoc(reader);
826 DBG("docPtr->URL %s\n", (char *)docPtr->URL);
827 xmlDocPtr copyDocPtr = xmlCopyDoc(docPtr, 1);
828 if (copyDocPtr == NULL)
830 xmlNode *rootElement = xmlDocGetRootElement(copyDocPtr);
831 if (rootElement == NULL)
833 xmlNode *cur_node = xmlFirstElementChild(rootElement);
834 if (cur_node == NULL)
836 xmlNode *temp = xmlTextReaderExpand(reader);
839 xmlNode *next_node = NULL;
840 while(cur_node != NULL) {
841 if ( (strcmp(ASCII(temp->name), ASCII(cur_node->name)) == 0) &&
842 (temp->line == cur_node->line) ) {
846 next_node = xmlNextElementSibling(cur_node);
847 xmlUnlinkNode(cur_node);
848 xmlFreeNode(cur_node);
849 cur_node = next_node;
852 if (cur_node == NULL)
854 next_node = xmlNextElementSibling(cur_node);
856 cur_node->next = NULL;
857 next_node->prev = NULL;
858 xmlFreeNodeList(next_node);
859 xmlSetTreeDoc(cur_node, copyDocPtr);
861 xmlSetTreeDoc(cur_node, copyDocPtr);
867 DBG("node type: %d, name: %s children->name: %s last->name: %s\n"
868 "parent->name: %s next->name: %s prev->name: %s\n",
869 cur_node->type, cur_node->name,
870 cur_node->children ? cur_node->children->name : "NULL",
871 cur_node->last ? cur_node->last->name : "NULL",
872 cur_node->parent ? cur_node->parent->name : "NULL",
873 cur_node->next ? cur_node->next->name : "NULL",
874 cur_node->prev ? cur_node->prev->name : "NULL");
876 FILE *fp = fopen("/opt/share/test.xml", "a");
877 xmlDocDump(fp, copyDocPtr);
882 ret = __ps_run_parser(copyDocPtr, ASCII(name), action, pkgid);
889 __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgid)
894 switch (xmlTextReaderNodeType(reader)) {
895 case XML_READER_TYPE_END_ELEMENT:
897 // DBG("XML_READER_TYPE_END_ELEMENT");
901 case XML_READER_TYPE_ELEMENT:
903 // Elements without closing tag don't receive
904 // XML_READER_TYPE_END_ELEMENT event.
906 const xmlChar *elementName =
907 xmlTextReaderLocalName(reader);
908 if (elementName == NULL) {
909 // DBG("elementName %s\n", (char *)elementName);
913 const xmlChar *nameSpace =
914 xmlTextReaderConstNamespaceUri(reader);
916 // DBG("nameSpace %s\n", (char *)nameSpace);
919 DBG("XML_READER_TYPE_ELEMENT %s, %s\n",
920 elementName ? elementName : "NULL",
921 nameSpace ? nameSpace : "NULL");
924 DBG("__run_parser_prestep pkgid[%s]\n", pkgid);
925 __run_parser_prestep(reader, action, pkgid);
929 for (tag = tagv[0]; tag; tag = tagv[++i])
930 if (strcmp(tag, ASCII(elementName)) == 0) {
931 DBG("__run_parser_prestep tag[%s] pkgid[%s]\n", tag, pkgid);
932 __run_parser_prestep(reader,
940 case XML_READER_TYPE_TEXT:
941 case XML_READER_TYPE_CDATA:
943 const xmlChar *value = xmlTextReaderConstValue(reader);
945 // DBG("value %s\n", value);
948 const xmlChar *lang = xmlTextReaderConstXmlLang(reader);
950 // DBG("lang\n", lang);
953 /* DBG("XML_READER_TYPE_TEXT %s, %s\n",
954 value ? value : "NULL", lang ? lang : "NULL");
959 // DBG("Ignoring Node of Type: %d", xmlTextReaderNodeType(reader));
964 static void __plugin_send_tag(const char *tag, ACTION_TYPE action, PLUGIN_PROCESS_TYPE process, const char *pkgid)
966 char *lib_path = NULL;
967 void *lib_handle = NULL;
968 int (*plugin_install) (const char *);
972 if (process == PLUGIN_PRE_PROCESS) {
975 ac = "PKGMGR_PARSER_PLUGIN_PRE_INSTALL";
978 ac = "PKGMGR_PARSER_PLUGIN_PRE_UPGRADE";
980 case ACTION_UNINSTALL:
981 ac = "PKGMGR_PARSER_PLUGIN_PRE_UNINSTALL";
986 } else if (process == PLUGIN_POST_PROCESS) {
989 ac = "PKGMGR_PARSER_PLUGIN_POST_INSTALL";
992 ac = "PKGMGR_PARSER_PLUGIN_POST_UPGRADE";
994 case ACTION_UNINSTALL:
995 ac = "PKGMGR_PARSER_PLUGIN_POST_UNINSTALL";
1003 lib_path = __get_parser_plugin(tag);
1008 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
1009 DBGE("dlopen is failed lib_path[%s] for tag[%s]\n", lib_path, tag);
1012 if ((plugin_install =
1013 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
1014 DBGE("can not find symbol[%s] for tag[%s] \n", ac, tag);
1018 ret = plugin_install(pkgid);
1020 DBG("[PLUGIN_PROCESS_TYPE[%d] pkgid=%s, tag=%s plugin fail\n", process, pkgid, tag);
1022 DBG("[PLUGIN_PROCESS_TYPE[%d] pkgid=%s, tag=%s plugin success\n", process, pkgid, tag);
1028 dlclose(lib_handle);
1032 __plugin_process_tag(char *const tag_list[], ACTION_TYPE action, PLUGIN_PROCESS_TYPE process, const char *pkgid)
1037 for (tag = tag_list[0]; tag; tag = tag_list[++i])
1038 __plugin_send_tag(tag, action, process, pkgid);
1043 __plugin_save_tag(xmlTextReaderPtr reader, char *const tagv[], char *tag_list[])
1047 static int pre_cnt=0;
1049 switch (xmlTextReaderNodeType(reader)) {
1050 case XML_READER_TYPE_ELEMENT:
1052 const xmlChar *elementName = xmlTextReaderLocalName(reader);
1053 if (elementName == NULL) {
1057 for (tag = tag_list[0]; tag; tag = tag_list[++i])
1058 if (strcmp(ASCII(elementName), tag) == 0) {
1062 for (tag = tagv[0]; tag; tag = tagv[++i])
1063 if (strcmp(tag, ASCII(elementName)) == 0) {
1064 tag_list[pre_cnt++] = tag;
1070 // DBG("Ignoring Node of Type: %d", xmlTextReaderNodeType(reader));
1076 __plugin_find_tag(const char *filename, char *const tagv[], char *tag_list[])
1078 xmlTextReaderPtr reader;
1082 docPtr = xmlReadFile(filename, NULL, 0);
1083 reader = xmlReaderWalker(docPtr);
1084 if (reader != NULL) {
1085 ret = xmlTextReaderRead(reader);
1087 __plugin_save_tag(reader, tagv, tag_list);
1088 ret = xmlTextReaderRead(reader);
1090 xmlFreeTextReader(reader);
1093 DBG("xmlReaderWalker fail");
1096 DBG("xmlReaderWalker fail");
1101 __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid)
1103 xmlTextReaderPtr reader;
1106 char *tag_list[PKG_TAG_LEN_MAX] = {'\0'};
1108 __plugin_find_tag(filename, tagv, tag_list);
1109 __plugin_process_tag(tag_list, action, PLUGIN_PRE_PROCESS, pkgid);
1111 docPtr = xmlReadFile(filename, NULL, 0);
1112 reader = xmlReaderWalker(docPtr);
1113 if (reader != NULL) {
1114 ret = xmlTextReaderRead(reader);
1116 __processNode(reader, action, tagv, pkgid);
1117 ret = xmlTextReaderRead(reader);
1119 xmlFreeTextReader(reader);
1122 DBGE("%s : failed to parse", filename);
1125 DBGE("Unable to open %s", filename);
1128 __plugin_process_tag(tag_list, action, PLUGIN_POST_PROCESS, pkgid);
1131 static int __next_child_element(xmlTextReaderPtr reader, int depth)
1133 int ret = xmlTextReaderRead(reader);
1134 int cur = xmlTextReaderDepth(reader);
1137 switch (xmlTextReaderNodeType(reader)) {
1138 case XML_READER_TYPE_ELEMENT:
1139 if (cur == depth + 1)
1142 case XML_READER_TYPE_TEXT:
1143 /*text is handled by each function separately*/
1144 if (cur == depth + 1)
1147 case XML_READER_TYPE_END_ELEMENT:
1156 ret = xmlTextReaderRead(reader);
1157 cur = xmlTextReaderDepth(reader);
1162 static void __ps_free_category(category_x *category)
1164 if (category == NULL)
1166 if (category->name) {
1167 free((void *)category->name);
1168 category->name = NULL;
1170 free((void*)category);
1174 static void __ps_free_privilege(privilege_x *privilege)
1176 if (privilege == NULL)
1178 if (privilege->text) {
1179 free((void *)privilege->text);
1180 privilege->text = NULL;
1182 free((void*)privilege);
1186 static void __ps_free_privileges(privileges_x *privileges)
1188 if (privileges == NULL)
1191 if (privileges->privilege) {
1192 privilege_x *privilege = privileges->privilege;
1193 privilege_x *tmp = NULL;
1194 while(privilege != NULL) {
1195 tmp = privilege->next;
1196 __ps_free_privilege(privilege);
1200 free((void*)privileges);
1204 static void __ps_free_metadata(metadata_x *metadata)
1206 if (metadata == NULL)
1208 if (metadata->key) {
1209 free((void *)metadata->key);
1210 metadata->key = NULL;
1212 if (metadata->value) {
1213 free((void *)metadata->value);
1214 metadata->value = NULL;
1216 free((void*)metadata);
1220 static void __ps_free_permission(permission_x *permission)
1222 if (permission == NULL)
1224 if (permission->type) {
1225 free((void *)permission->type);
1226 permission->type = NULL;
1228 if (permission->value) {
1229 free((void *)permission->value);
1230 permission->value = NULL;
1232 free((void*)permission);
1236 static void __ps_free_icon(icon_x *icon)
1241 free((void *)icon->text);
1245 free((void *)icon->lang);
1249 free((void *)icon->name);
1252 if (icon->section) {
1253 free((void *)icon->section);
1254 icon->section = NULL;
1257 free((void *)icon->size);
1260 if (icon->resolution) {
1261 free((void *)icon->resolution);
1262 icon->resolution = NULL;
1268 static void __ps_free_image(image_x *image)
1273 free((void *)image->text);
1277 free((void *)image->lang);
1281 free((void *)image->name);
1284 if (image->section) {
1285 free((void *)image->section);
1286 image->section = NULL;
1292 static void __ps_free_operation(operation_x *operation)
1294 if (operation == NULL)
1296 if (operation->text) {
1297 free((void *)operation->text);
1298 operation->text = NULL;
1300 free((void*)operation);
1304 static void __ps_free_uri(uri_x *uri)
1309 free((void *)uri->text);
1316 static void __ps_free_mime(mime_x *mime)
1321 free((void *)mime->text);
1328 static void __ps_free_subapp(subapp_x *subapp)
1333 free((void *)subapp->text);
1334 subapp->text = NULL;
1336 free((void*)subapp);
1340 static void __ps_free_condition(condition_x *condition)
1342 if (condition == NULL)
1344 if (condition->text) {
1345 free((void *)condition->text);
1346 condition->text = NULL;
1348 if (condition->name) {
1349 free((void *)condition->name);
1350 condition->name = NULL;
1352 free((void*)condition);
1356 static void __ps_free_notification(notification_x *notification)
1358 if (notification == NULL)
1360 if (notification->text) {
1361 free((void *)notification->text);
1362 notification->text = NULL;
1364 if (notification->name) {
1365 free((void *)notification->name);
1366 notification->name = NULL;
1368 free((void*)notification);
1369 notification = NULL;
1372 static void __ps_free_compatibility(compatibility_x *compatibility)
1374 if (compatibility == NULL)
1376 if (compatibility->text) {
1377 free((void *)compatibility->text);
1378 compatibility->text = NULL;
1380 if (compatibility->name) {
1381 free((void *)compatibility->name);
1382 compatibility->name = NULL;
1384 free((void*)compatibility);
1385 compatibility = NULL;
1388 static void __ps_free_resolution(resolution_x *resolution)
1390 if (resolution == NULL)
1392 if (resolution->mimetype) {
1393 free((void *)resolution->mimetype);
1394 resolution->mimetype = NULL;
1396 if (resolution->urischeme) {
1397 free((void *)resolution->urischeme);
1398 resolution->urischeme = NULL;
1400 free((void*)resolution);
1404 static void __ps_free_capability(capability_x *capability)
1406 if (capability == NULL)
1408 if (capability->operationid) {
1409 free((void *)capability->operationid);
1410 capability->operationid = NULL;
1413 if (capability->resolution) {
1414 resolution_x *resolution = capability->resolution;
1415 resolution_x *tmp = NULL;
1416 while(resolution != NULL) {
1417 tmp = resolution->next;
1418 __ps_free_resolution(resolution);
1422 free((void*)capability);
1426 static void __ps_free_allowed(allowed_x *allowed)
1428 if (allowed == NULL)
1430 if (allowed->name) {
1431 free((void *)allowed->name);
1432 allowed->name = NULL;
1434 if (allowed->text) {
1435 free((void *)allowed->text);
1436 allowed->text = NULL;
1438 free((void*)allowed);
1442 static void __ps_free_request(request_x *request)
1444 if (request == NULL)
1446 if (request->text) {
1447 free((void *)request->text);
1448 request->text = NULL;
1450 free((void*)request);
1454 static void __ps_free_datacontrol(datacontrol_x *datacontrol)
1456 if (datacontrol == NULL)
1458 if (datacontrol->providerid) {
1459 free((void *)datacontrol->providerid);
1460 datacontrol->providerid = NULL;
1463 if (datacontrol->capability) {
1464 capability_x *capability = datacontrol->capability;
1465 capability_x *tmp = NULL;
1466 while(capability != NULL) {
1467 tmp = capability->next;
1468 __ps_free_capability(capability);
1472 free((void*)datacontrol);
1476 static void __ps_free_launchconditions(launchconditions_x *launchconditions)
1478 if (launchconditions == NULL)
1480 if (launchconditions->text) {
1481 free((void *)launchconditions->text);
1482 launchconditions->text = NULL;
1485 if (launchconditions->condition) {
1486 condition_x *condition = launchconditions->condition;
1487 condition_x *tmp = NULL;
1488 while(condition != NULL) {
1489 tmp = condition->next;
1490 __ps_free_condition(condition);
1494 free((void*)launchconditions);
1495 launchconditions = NULL;
1498 static void __ps_free_appcontrol(appcontrol_x *appcontrol)
1500 if (appcontrol == NULL)
1502 if (appcontrol->text) {
1503 free((void *)appcontrol->text);
1504 appcontrol->text = NULL;
1507 if (appcontrol->operation) {
1508 operation_x *operation = appcontrol->operation;
1509 operation_x *tmp = NULL;
1510 while(operation != NULL) {
1511 tmp = operation->next;
1512 __ps_free_operation(operation);
1517 if (appcontrol->uri) {
1518 uri_x *uri = appcontrol->uri;
1520 while(uri != NULL) {
1527 if (appcontrol->mime) {
1528 mime_x *mime = appcontrol->mime;
1530 while(mime != NULL) {
1532 __ps_free_mime(mime);
1537 if (appcontrol->subapp) {
1538 subapp_x *subapp = appcontrol->subapp;
1539 subapp_x *tmp = NULL;
1540 while(subapp != NULL) {
1542 __ps_free_subapp(subapp);
1546 free((void*)appcontrol);
1550 static void __ps_free_appsvc(appsvc_x *appsvc)
1555 free((void *)appsvc->text);
1556 appsvc->text = NULL;
1559 if (appsvc->operation) {
1560 operation_x *operation = appsvc->operation;
1561 operation_x *tmp = NULL;
1562 while(operation != NULL) {
1563 tmp = operation->next;
1564 __ps_free_operation(operation);
1570 uri_x *uri = appsvc->uri;
1572 while(uri != NULL) {
1580 mime_x *mime = appsvc->mime;
1582 while(mime != NULL) {
1584 __ps_free_mime(mime);
1589 if (appsvc->subapp) {
1590 subapp_x *subapp = appsvc->subapp;
1591 subapp_x *tmp = NULL;
1592 while(subapp != NULL) {
1594 __ps_free_subapp(subapp);
1598 free((void*)appsvc);
1602 static void __ps_free_deviceprofile(deviceprofile_x *deviceprofile)
1607 static void __ps_free_define(define_x *define)
1612 free((void *)define->path);
1613 define->path = NULL;
1616 if (define->request) {
1617 request_x *request = define->request;
1618 request_x *tmp = NULL;
1619 while(request != NULL) {
1620 tmp = request->next;
1621 __ps_free_request(request);
1626 if (define->allowed) {
1627 allowed_x *allowed = define->allowed;
1628 allowed_x *tmp = NULL;
1629 while(allowed != NULL) {
1630 tmp = allowed->next;
1631 __ps_free_allowed(allowed);
1635 free((void*)define);
1639 static void __ps_free_datashare(datashare_x *datashare)
1641 if (datashare == NULL)
1644 if (datashare->define) {
1645 define_x *define = datashare->define;
1646 define_x *tmp = NULL;
1647 while(define != NULL) {
1649 __ps_free_define(define);
1654 if (datashare->request) {
1655 request_x *request = datashare->request;
1656 request_x *tmp = NULL;
1657 while(request != NULL) {
1658 tmp = request->next;
1659 __ps_free_request(request);
1663 free((void*)datashare);
1667 static void __ps_free_label(label_x *label)
1672 free((void *)label->name);
1676 free((void *)label->text);
1680 free((void *)label->lang);
1687 static void __ps_free_author(author_x *author)
1691 if (author->email) {
1692 free((void *)author->email);
1693 author->email = NULL;
1696 free((void *)author->text);
1697 author->text = NULL;
1700 free((void *)author->href);
1701 author->href = NULL;
1704 free((void *)author->lang);
1705 author->lang = NULL;
1707 free((void*)author);
1711 static void __ps_free_description(description_x *description)
1713 if (description == NULL)
1715 if (description->name) {
1716 free((void *)description->name);
1717 description->name = NULL;
1719 if (description->text) {
1720 free((void *)description->text);
1721 description->text = NULL;
1723 if (description->lang) {
1724 free((void *)description->lang);
1725 description->lang = NULL;
1727 free((void*)description);
1731 static void __ps_free_license(license_x *license)
1733 if (license == NULL)
1735 if (license->text) {
1736 free((void *)license->text);
1737 license->text = NULL;
1739 if (license->lang) {
1740 free((void *)license->lang);
1741 license->lang = NULL;
1743 free((void*)license);
1747 static void __ps_free_uiapplication(uiapplication_x *uiapplication)
1749 if (uiapplication == NULL)
1751 if (uiapplication->exec) {
1752 free((void *)uiapplication->exec);
1753 uiapplication->exec = NULL;
1755 if (uiapplication->appid) {
1756 free((void *)uiapplication->appid);
1757 uiapplication->appid = NULL;
1759 if (uiapplication->nodisplay) {
1760 free((void *)uiapplication->nodisplay);
1761 uiapplication->nodisplay = NULL;
1763 if (uiapplication->multiple) {
1764 free((void *)uiapplication->multiple);
1765 uiapplication->multiple = NULL;
1767 if (uiapplication->type) {
1768 free((void *)uiapplication->type);
1769 uiapplication->type = NULL;
1771 if (uiapplication->categories) {
1772 free((void *)uiapplication->categories);
1773 uiapplication->categories = NULL;
1775 if (uiapplication->extraid) {
1776 free((void *)uiapplication->extraid);
1777 uiapplication->extraid = NULL;
1779 if (uiapplication->taskmanage) {
1780 free((void *)uiapplication->taskmanage);
1781 uiapplication->taskmanage = NULL;
1783 if (uiapplication->enabled) {
1784 free((void *)uiapplication->enabled);
1785 uiapplication->enabled = NULL;
1787 if (uiapplication->hwacceleration) {
1788 free((void *)uiapplication->hwacceleration);
1789 uiapplication->hwacceleration = NULL;
1791 if (uiapplication->screenreader) {
1792 free((void *)uiapplication->screenreader);
1793 uiapplication->screenreader = NULL;
1795 if (uiapplication->mainapp) {
1796 free((void *)uiapplication->mainapp);
1797 uiapplication->mainapp = NULL;
1799 if (uiapplication->recentimage) {
1800 free((void *)uiapplication->recentimage);
1801 uiapplication->recentimage = NULL;
1803 if (uiapplication->package) {
1804 free((void *)uiapplication->package);
1805 uiapplication->package = NULL;
1807 if (uiapplication->launchcondition) {
1808 free((void *)uiapplication->launchcondition);
1809 uiapplication->launchcondition = NULL;
1812 if (uiapplication->label) {
1813 label_x *label = uiapplication->label;
1814 label_x *tmp = NULL;
1815 while(label != NULL) {
1817 __ps_free_label(label);
1822 if (uiapplication->icon) {
1823 icon_x *icon = uiapplication->icon;
1825 while(icon != NULL) {
1827 __ps_free_icon(icon);
1832 if (uiapplication->image) {
1833 image_x *image = uiapplication->image;
1834 image_x *tmp = NULL;
1835 while(image != NULL) {
1837 __ps_free_image(image);
1842 if (uiapplication->appcontrol) {
1843 appcontrol_x *appcontrol = uiapplication->appcontrol;
1844 appcontrol_x *tmp = NULL;
1845 while(appcontrol != NULL) {
1846 tmp = appcontrol->next;
1847 __ps_free_appcontrol(appcontrol);
1851 /*Free LaunchConditions*/
1852 if (uiapplication->launchconditions) {
1853 launchconditions_x *launchconditions = uiapplication->launchconditions;
1854 launchconditions_x *tmp = NULL;
1855 while(launchconditions != NULL) {
1856 tmp = launchconditions->next;
1857 __ps_free_launchconditions(launchconditions);
1858 launchconditions = tmp;
1861 /*Free Notification*/
1862 if (uiapplication->notification) {
1863 notification_x *notification = uiapplication->notification;
1864 notification_x *tmp = NULL;
1865 while(notification != NULL) {
1866 tmp = notification->next;
1867 __ps_free_notification(notification);
1872 if (uiapplication->datashare) {
1873 datashare_x *datashare = uiapplication->datashare;
1874 datashare_x *tmp = NULL;
1875 while(datashare != NULL) {
1876 tmp = datashare->next;
1877 __ps_free_datashare(datashare);
1882 if (uiapplication->appsvc) {
1883 appsvc_x *appsvc = uiapplication->appsvc;
1884 appsvc_x *tmp = NULL;
1885 while(appsvc != NULL) {
1887 __ps_free_appsvc(appsvc);
1892 if (uiapplication->category) {
1893 category_x *category = uiapplication->category;
1894 category_x *tmp = NULL;
1895 while(category != NULL) {
1896 tmp = category->next;
1897 __ps_free_category(category);
1902 if (uiapplication->metadata) {
1903 metadata_x *metadata = uiapplication->metadata;
1904 metadata_x *tmp = NULL;
1905 while(metadata != NULL) {
1906 tmp = metadata->next;
1907 __ps_free_metadata(metadata);
1912 if (uiapplication->permission) {
1913 permission_x *permission = uiapplication->permission;
1914 permission_x *tmp = NULL;
1915 while(permission != NULL) {
1916 tmp = permission->next;
1917 __ps_free_permission(permission);
1921 /* _PRODUCT_LAUNCHING_ENHANCED_ START */
1922 if (uiapplication->indicatordisplay) {
1923 free((void *)uiapplication->indicatordisplay);
1924 uiapplication->indicatordisplay = NULL;
1926 if (uiapplication->portraitimg) {
1927 free((void *)uiapplication->portraitimg);
1928 uiapplication->portraitimg = NULL;
1930 if (uiapplication->landscapeimg) {
1931 free((void *)uiapplication->landscapeimg);
1932 uiapplication->landscapeimg = NULL;
1934 /* _PRODUCT_LAUNCHING_ENHANCED_ END */
1935 if (uiapplication->guestmode_visibility) {
1936 free((void *)uiapplication->guestmode_visibility);
1937 uiapplication->guestmode_visibility = NULL;
1939 if (uiapplication->app_component) {
1940 free((void *)uiapplication->app_component);
1941 uiapplication->app_component = NULL;
1943 if (uiapplication->permission_type) {
1944 free((void *)uiapplication->permission_type);
1945 uiapplication->permission_type = NULL;
1947 if (uiapplication->component_type) {
1948 free((void *)uiapplication->component_type);
1949 uiapplication->component_type = NULL;
1951 if (uiapplication->preload) {
1952 free((void *)uiapplication->preload);
1953 uiapplication->preload = NULL;
1955 if (uiapplication->submode) {
1956 free((void *)uiapplication->submode);
1957 uiapplication->submode = NULL;
1959 if (uiapplication->submode_mainid) {
1960 free((void *)uiapplication->submode_mainid);
1961 uiapplication->submode_mainid = NULL;
1964 free((void*)uiapplication);
1965 uiapplication = NULL;
1968 static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication)
1970 if (serviceapplication == NULL)
1972 if (serviceapplication->exec) {
1973 free((void *)serviceapplication->exec);
1974 serviceapplication->exec = NULL;
1976 if (serviceapplication->appid) {
1977 free((void *)serviceapplication->appid);
1978 serviceapplication->appid = NULL;
1980 if (serviceapplication->onboot) {
1981 free((void *)serviceapplication->onboot);
1982 serviceapplication->onboot = NULL;
1984 if (serviceapplication->autorestart) {
1985 free((void *)serviceapplication->autorestart);
1986 serviceapplication->autorestart = NULL;
1988 if (serviceapplication->type) {
1989 free((void *)serviceapplication->type);
1990 serviceapplication->type = NULL;
1992 if (serviceapplication->enabled) {
1993 free((void *)serviceapplication->enabled);
1994 serviceapplication->enabled = NULL;
1996 if (serviceapplication->package) {
1997 free((void *)serviceapplication->package);
1998 serviceapplication->package = NULL;
2000 if (serviceapplication->permission_type) {
2001 free((void *)serviceapplication->permission_type);
2002 serviceapplication->permission_type = NULL;
2005 if (serviceapplication->label) {
2006 label_x *label = serviceapplication->label;
2007 label_x *tmp = NULL;
2008 while(label != NULL) {
2010 __ps_free_label(label);
2015 if (serviceapplication->icon) {
2016 icon_x *icon = serviceapplication->icon;
2018 while(icon != NULL) {
2020 __ps_free_icon(icon);
2025 if (serviceapplication->appcontrol) {
2026 appcontrol_x *appcontrol = serviceapplication->appcontrol;
2027 appcontrol_x *tmp = NULL;
2028 while(appcontrol != NULL) {
2029 tmp = appcontrol->next;
2030 __ps_free_appcontrol(appcontrol);
2034 /*Free DataControl*/
2035 if (serviceapplication->datacontrol) {
2036 datacontrol_x *datacontrol = serviceapplication->datacontrol;
2037 datacontrol_x *tmp = NULL;
2038 while(datacontrol != NULL) {
2039 tmp = datacontrol->next;
2040 __ps_free_datacontrol(datacontrol);
2044 /*Free LaunchConditions*/
2045 if (serviceapplication->launchconditions) {
2046 launchconditions_x *launchconditions = serviceapplication->launchconditions;
2047 launchconditions_x *tmp = NULL;
2048 while(launchconditions != NULL) {
2049 tmp = launchconditions->next;
2050 __ps_free_launchconditions(launchconditions);
2051 launchconditions = tmp;
2054 /*Free Notification*/
2055 if (serviceapplication->notification) {
2056 notification_x *notification = serviceapplication->notification;
2057 notification_x *tmp = NULL;
2058 while(notification != NULL) {
2059 tmp = notification->next;
2060 __ps_free_notification(notification);
2065 if (serviceapplication->datashare) {
2066 datashare_x *datashare = serviceapplication->datashare;
2067 datashare_x *tmp = NULL;
2068 while(datashare != NULL) {
2069 tmp = datashare->next;
2070 __ps_free_datashare(datashare);
2075 if (serviceapplication->appsvc) {
2076 appsvc_x *appsvc = serviceapplication->appsvc;
2077 appsvc_x *tmp = NULL;
2078 while(appsvc != NULL) {
2080 __ps_free_appsvc(appsvc);
2085 if (serviceapplication->category) {
2086 category_x *category = serviceapplication->category;
2087 category_x *tmp = NULL;
2088 while(category != NULL) {
2089 tmp = category->next;
2090 __ps_free_category(category);
2095 if (serviceapplication->metadata) {
2096 metadata_x *metadata = serviceapplication->metadata;
2097 metadata_x *tmp = NULL;
2098 while(metadata != NULL) {
2099 tmp = metadata->next;
2100 __ps_free_metadata(metadata);
2105 if (serviceapplication->permission) {
2106 permission_x *permission = serviceapplication->permission;
2107 permission_x *tmp = NULL;
2108 while(permission != NULL) {
2109 tmp = permission->next;
2110 __ps_free_permission(permission);
2114 free((void*)serviceapplication);
2115 serviceapplication = NULL;
2118 static void __ps_free_font(font_x *font)
2123 free((void *)font->name);
2127 free((void *)font->text);
2134 static void __ps_free_theme(theme_x *theme)
2139 free((void *)theme->name);
2143 free((void *)theme->text);
2150 static void __ps_free_daemon(daemon_x *daemon)
2155 free((void *)daemon->name);
2156 daemon->name = NULL;
2159 free((void *)daemon->text);
2160 daemon->text = NULL;
2162 free((void*)daemon);
2166 static void __ps_free_ime(ime_x *ime)
2171 free((void *)ime->name);
2175 free((void *)ime->text);
2182 int __ps_process_mdparser(manifest_x *mfx, ACTION_TYPE action)
2186 char md_key[PKG_STRING_LEN_MAX] = { 0 };
2188 fp = fopen(MDPARSER_LIST, "r");
2190 DBG("no preload list\n");
2194 while (fgets(md_key, sizeof(md_key), fp) != NULL) {
2196 ret = __run_mdparser_prestep(mfx, md_key, action);
2198 memset(md_key, 0x00, sizeof(md_key));
2207 int __ps_process_category_parser(manifest_x *mfx, ACTION_TYPE action)
2211 char category_key[PKG_STRING_LEN_MAX] = { 0 };
2213 fp = fopen(CATEGORY_PARSER_LIST, "r");
2215 DBG("no category parser list\n");
2219 while (fgets(category_key, sizeof(category_key), fp) != NULL) {
2220 __str_trim(category_key);
2221 ret = __run_category_parser_prestep(mfx, category_key, action);
2223 memset(category_key, 0x00, sizeof(category_key));
2232 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed)
2234 xmlTextReaderRead(reader);
2235 if (xmlTextReaderValue(reader))
2236 allowed->text = ASCII(xmlTextReaderValue(reader));
2240 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation)
2242 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2243 operation->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2244 /* Text does not exist. Only attribute exists
2245 xmlTextReaderRead(reader);
2246 if (xmlTextReaderValue(reader))
2247 operation->text = ASCII(xmlTextReaderValue(reader));
2252 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri)
2254 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2255 uri->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2256 /* Text does not exist. Only attribute exists
2257 xmlTextReaderRead(reader);
2258 if (xmlTextReaderValue(reader))
2259 uri->text = ASCII(xmlTextReaderValue(reader));
2264 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime)
2266 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2267 mime->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2268 /* Text does not exist. Only attribute exists
2269 xmlTextReaderRead(reader);
2270 if (xmlTextReaderValue(reader))
2271 mime->text = ASCII(xmlTextReaderValue(reader));
2276 static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp)
2278 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2279 subapp->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2280 /* Text does not exist. Only attribute exists
2281 xmlTextReaderRead(reader);
2282 if (xmlTextReaderValue(reader))
2283 mime->text = ASCII(xmlTextReaderValue(reader));
2288 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition)
2290 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2291 condition->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2292 xmlTextReaderRead(reader);
2293 if (xmlTextReaderValue(reader))
2294 condition->text = ASCII(xmlTextReaderValue(reader));
2298 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notification)
2300 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2301 notification->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2302 xmlTextReaderRead(reader);
2303 if (xmlTextReaderValue(reader))
2304 notification->text = ASCII(xmlTextReaderValue(reader));
2308 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category)
2310 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2311 category->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2315 static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege)
2317 xmlTextReaderRead(reader);
2318 if (xmlTextReaderValue(reader)) {
2319 privilege->text = ASCII(xmlTextReaderValue(reader));
2324 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata)
2326 if (xmlTextReaderGetAttribute(reader, XMLCHAR("key")))
2327 metadata->key = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("key")));
2328 if (xmlTextReaderGetAttribute(reader, XMLCHAR("value")))
2329 metadata->value = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("value")));
2333 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission)
2335 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
2336 permission->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
2338 xmlTextReaderRead(reader);
2339 if (xmlTextReaderValue(reader))
2340 permission->value = ASCII(xmlTextReaderValue(reader));
2344 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility)
2346 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2347 compatibility->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2348 xmlTextReaderRead(reader);
2349 if (xmlTextReaderValue(reader))
2350 compatibility->text = ASCII(xmlTextReaderValue(reader));
2354 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution)
2356 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")))
2357 resolution->mimetype = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")));
2358 if (xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")))
2359 resolution->urischeme = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")));
2363 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request)
2365 xmlTextReaderRead(reader);
2366 if (xmlTextReaderValue(reader))
2367 request->text = ASCII(xmlTextReaderValue(reader));
2371 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define)
2373 const xmlChar *node;
2376 allowed_x *tmp1 = NULL;
2377 request_x *tmp2 = NULL;
2379 if (xmlTextReaderGetAttribute(reader, XMLCHAR("path")))
2380 define->path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("path")));
2382 depth = xmlTextReaderDepth(reader);
2383 while ((ret = __next_child_element(reader, depth))) {
2384 node = xmlTextReaderConstName(reader);
2386 DBG("xmlTextReaderConstName value is NULL\n");
2390 if (!strcmp(ASCII(node), "allowed")) {
2391 allowed_x *allowed= malloc(sizeof(allowed_x));
2392 if (allowed == NULL) {
2393 DBG("Malloc Failed\n");
2396 memset(allowed, '\0', sizeof(allowed_x));
2397 LISTADD(define->allowed, allowed);
2398 ret = __ps_process_allowed(reader, allowed);
2399 } else if (!strcmp(ASCII(node), "request")) {
2400 request_x *request = malloc(sizeof(request_x));
2401 if (request == NULL) {
2402 DBG("Malloc Failed\n");
2405 memset(request, '\0', sizeof(request_x));
2406 LISTADD(define->request, request);
2407 ret = __ps_process_request(reader, request);
2411 DBG("Processing define failed\n");
2415 if (define->allowed) {
2416 LISTHEAD(define->allowed, tmp1);
2417 define->allowed = tmp1;
2419 if (define->request) {
2420 LISTHEAD(define->request, tmp2);
2421 define->request = tmp2;
2426 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol)
2428 const xmlChar *node;
2431 operation_x *tmp1 = NULL;
2433 mime_x *tmp3 = NULL;
2434 subapp_x *tmp4 = NULL;
2436 depth = xmlTextReaderDepth(reader);
2437 while ((ret = __next_child_element(reader, depth))) {
2438 node = xmlTextReaderConstName(reader);
2440 DBG("xmlTextReaderConstName value is NULL\n");
2444 if (!strcmp(ASCII(node), "operation")) {
2445 operation_x *operation = malloc(sizeof(operation_x));
2446 if (operation == NULL) {
2447 DBG("Malloc Failed\n");
2450 memset(operation, '\0', sizeof(operation_x));
2451 LISTADD(appcontrol->operation, operation);
2452 ret = __ps_process_operation(reader, operation);
2453 DBG("operation processing\n");
2454 } else if (!strcmp(ASCII(node), "uri")) {
2455 uri_x *uri= malloc(sizeof(uri_x));
2457 DBG("Malloc Failed\n");
2460 memset(uri, '\0', sizeof(uri_x));
2461 LISTADD(appcontrol->uri, uri);
2462 ret = __ps_process_uri(reader, uri);
2463 DBG("uri processing\n");
2464 } else if (!strcmp(ASCII(node), "mime")) {
2465 mime_x *mime = malloc(sizeof(mime_x));
2467 DBG("Malloc Failed\n");
2470 memset(mime, '\0', sizeof(mime_x));
2471 LISTADD(appcontrol->mime, mime);
2472 ret = __ps_process_mime(reader, mime);
2473 DBG("mime processing\n");
2474 } else if (!strcmp(ASCII(node), "subapp")) {
2475 subapp_x *subapp = malloc(sizeof(subapp_x));
2476 if (subapp == NULL) {
2477 DBG("Malloc Failed\n");
2480 memset(subapp, '\0', sizeof(subapp_x));
2481 LISTADD(appcontrol->subapp, subapp);
2482 ret = __ps_process_subapp(reader, subapp);
2483 DBG("subapp processing\n");
2487 DBG("Processing appcontrol failed\n");
2491 if (appcontrol->operation) {
2492 LISTHEAD(appcontrol->operation, tmp1);
2493 appcontrol->operation = tmp1;
2495 if (appcontrol->uri) {
2496 LISTHEAD(appcontrol->uri, tmp2);
2497 appcontrol->uri = tmp2;
2499 if (appcontrol->mime) {
2500 LISTHEAD(appcontrol->mime, tmp3);
2501 appcontrol->mime = tmp3;
2503 if (appcontrol->subapp) {
2504 LISTHEAD(appcontrol->subapp, tmp4);
2505 appcontrol->subapp = tmp4;
2508 xmlTextReaderRead(reader);
2509 if (xmlTextReaderValue(reader))
2510 appcontrol->text = ASCII(xmlTextReaderValue(reader));
2515 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc)
2517 const xmlChar *node;
2520 operation_x *tmp1 = NULL;
2522 mime_x *tmp3 = NULL;
2523 subapp_x *tmp4 = NULL;
2525 depth = xmlTextReaderDepth(reader);
2526 while ((ret = __next_child_element(reader, depth))) {
2527 node = xmlTextReaderConstName(reader);
2529 DBG("xmlTextReaderConstName value is NULL\n");
2533 if (!strcmp(ASCII(node), "operation")) {
2534 operation_x *operation = malloc(sizeof(operation_x));
2535 if (operation == NULL) {
2536 DBG("Malloc Failed\n");
2539 memset(operation, '\0', sizeof(operation_x));
2540 LISTADD(appsvc->operation, operation);
2541 ret = __ps_process_operation(reader, operation);
2542 DBG("operation processing\n");
2543 } else if (!strcmp(ASCII(node), "uri")) {
2544 uri_x *uri= malloc(sizeof(uri_x));
2546 DBG("Malloc Failed\n");
2549 memset(uri, '\0', sizeof(uri_x));
2550 LISTADD(appsvc->uri, uri);
2551 ret = __ps_process_uri(reader, uri);
2552 DBG("uri processing\n");
2553 } else if (!strcmp(ASCII(node), "mime")) {
2554 mime_x *mime = malloc(sizeof(mime_x));
2556 DBG("Malloc Failed\n");
2559 memset(mime, '\0', sizeof(mime_x));
2560 LISTADD(appsvc->mime, mime);
2561 ret = __ps_process_mime(reader, mime);
2562 DBG("mime processing\n");
2563 } else if (!strcmp(ASCII(node), "subapp")) {
2564 subapp_x *subapp = malloc(sizeof(subapp_x));
2565 if (subapp == NULL) {
2566 DBG("Malloc Failed\n");
2569 memset(subapp, '\0', sizeof(subapp_x));
2570 LISTADD(appsvc->subapp, subapp);
2571 ret = __ps_process_subapp(reader, subapp);
2572 DBG("subapp processing\n");
2576 DBG("Processing appsvc failed\n");
2580 if (appsvc->operation) {
2581 LISTHEAD(appsvc->operation, tmp1);
2582 appsvc->operation = tmp1;
2585 LISTHEAD(appsvc->uri, tmp2);
2589 LISTHEAD(appsvc->mime, tmp3);
2590 appsvc->mime = tmp3;
2592 if (appsvc->subapp) {
2593 LISTHEAD(appsvc->subapp, tmp4);
2594 appsvc->subapp = tmp4;
2597 xmlTextReaderRead(reader);
2598 if (xmlTextReaderValue(reader))
2599 appsvc->text = ASCII(xmlTextReaderValue(reader));
2605 static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privileges)
2607 const xmlChar *node;
2610 privilege_x *tmp1 = NULL;
2612 depth = xmlTextReaderDepth(reader);
2613 while ((ret = __next_child_element(reader, depth))) {
2614 node = xmlTextReaderConstName(reader);
2616 DBG("xmlTextReaderConstName value is NULL\n");
2620 if (strcmp(ASCII(node), "privilege") == 0) {
2621 privilege_x *privilege = malloc(sizeof(privilege_x));
2622 if (privilege == NULL) {
2623 DBG("Malloc Failed\n");
2626 memset(privilege, '\0', sizeof(privilege_x));
2627 LISTADD(privileges->privilege, privilege);
2628 ret = __ps_process_privilege(reader, privilege);
2632 DBG("Processing privileges failed\n");
2636 if (privileges->privilege) {
2637 LISTHEAD(privileges->privilege, tmp1);
2638 privileges->privilege = tmp1;
2643 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions)
2645 const xmlChar *node;
2648 condition_x *tmp1 = NULL;
2650 depth = xmlTextReaderDepth(reader);
2651 while ((ret = __next_child_element(reader, depth))) {
2652 node = xmlTextReaderConstName(reader);
2654 DBG("xmlTextReaderConstName value is NULL\n");
2658 if (strcmp(ASCII(node), "condition") == 0) {
2659 condition_x *condition = malloc(sizeof(condition_x));
2660 if (condition == NULL) {
2661 DBG("Malloc Failed\n");
2664 memset(condition, '\0', sizeof(condition_x));
2665 LISTADD(launchconditions->condition, condition);
2666 ret = __ps_process_condition(reader, condition);
2670 DBG("Processing launchconditions failed\n");
2674 if (launchconditions->condition) {
2675 LISTHEAD(launchconditions->condition, tmp1);
2676 launchconditions->condition = tmp1;
2679 xmlTextReaderRead(reader);
2680 if (xmlTextReaderValue(reader))
2681 launchconditions->text = ASCII(xmlTextReaderValue(reader));
2686 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare)
2688 const xmlChar *node;
2691 define_x *tmp1 = NULL;
2692 request_x *tmp2 = NULL;
2693 depth = xmlTextReaderDepth(reader);
2694 while ((ret = __next_child_element(reader, depth))) {
2695 node = xmlTextReaderConstName(reader);
2697 DBG("xmlTextReaderConstName value is NULL\n");
2701 if (!strcmp(ASCII(node), "define")) {
2702 define_x *define= malloc(sizeof(define_x));
2703 if (define == NULL) {
2704 DBG("Malloc Failed\n");
2707 memset(define, '\0', sizeof(define_x));
2708 LISTADD(datashare->define, define);
2709 ret = __ps_process_define(reader, define);
2710 } else if (!strcmp(ASCII(node), "request")) {
2711 request_x *request= malloc(sizeof(request_x));
2712 if (request == NULL) {
2713 DBG("Malloc Failed\n");
2716 memset(request, '\0', sizeof(request_x));
2717 LISTADD(datashare->request, request);
2718 ret = __ps_process_request(reader, request);
2722 DBG("Processing data-share failed\n");
2726 if (datashare->define) {
2727 LISTHEAD(datashare->define, tmp1);
2728 datashare->define = tmp1;
2730 if (datashare->request) {
2731 LISTHEAD(datashare->request, tmp2);
2732 datashare->request = tmp2;
2738 __get_icon_with_path(const char* icon)
2743 if (index(icon, '/') == NULL) {
2745 char* icon_with_path = NULL;
2751 theme = vconf_get_str("db/setting/theme");
2753 theme = strdup("default");
2759 len = (0x01 << 7) + strlen(icon) + strlen(package) + strlen(theme);
2760 icon_with_path = malloc(len);
2761 if(icon_with_path == NULL) {
2762 DBG("(icon_with_path == NULL) return\n");
2767 memset(icon_with_path, 0, len);
2769 snprintf(icon_with_path, len, "/opt/share/icons/%s/small/%s", theme, icon);
2771 if (access(icon_with_path, R_OK) == 0) break;
2772 snprintf(icon_with_path, len, "/usr/share/icons/%s/small/%s", theme, icon);
2773 if (access(icon_with_path, R_OK) == 0) break;
2774 DBG("cannot find icon %s", icon_with_path);
2775 snprintf(icon_with_path, len,"/opt/share/icons/default/small/%s", icon);
2776 if (access(icon_with_path, R_OK) == 0) break;
2777 snprintf(icon_with_path, len, "/usr/share/icons/default/small/%s", icon);
2778 if (access(icon_with_path, R_OK) == 0) break;
2780 /* icon path is going to be moved intto the app directory */
2781 DBGE("icon file must be moved to %s", icon_with_path);
2782 snprintf(icon_with_path, len, "/opt/apps/%s/res/icons/%s/small/%s", package, theme, icon);
2783 if (access(icon_with_path, R_OK) == 0) break;
2784 snprintf(icon_with_path, len, "/usr/apps/%s/res/icons/%s/small/%s", package, theme, icon);
2785 if (access(icon_with_path, R_OK) == 0) break;
2786 DBG("cannot find icon %s", icon_with_path);
2787 snprintf(icon_with_path, len, "/opt/apps/%s/res/icons/default/small/%s", package, icon);
2788 if (access(icon_with_path, R_OK) == 0) break;
2789 snprintf(icon_with_path, len, "/usr/apps/%s/res/icons/default/small/%s", package, icon);
2790 if (access(icon_with_path, R_OK) == 0) break;
2791 snprintf(icon_with_path, len, "/usr/ug/res/images/%s/%s", package, icon);
2792 if (access(icon_with_path, R_OK) == 0) break;
2797 DBG("Icon path : %s ---> %s", icon, icon_with_path);
2799 return icon_with_path;
2801 char* confirmed_icon = NULL;
2803 confirmed_icon = strdup(icon);
2804 if (!confirmed_icon)
2806 return confirmed_icon;
2810 static void __ps_process_tag(manifest_x * mfx, char *const tagv[])
2813 char delims[] = "=";
2814 char *ret_result = NULL;
2820 for (tag = strdup(tagv[0]); tag != NULL; ) {
2821 ret_result = strtok(tag, delims);
2823 /*check tag : preload */
2824 if (strcmp(ret_result, "preload") == 0) {
2825 ret_result = strtok(NULL, delims);
2826 if (strcmp(ret_result, "true") == 0) {
2827 free((void *)mfx->preload);
2828 mfx->preload = strdup("true");
2829 } else if (strcmp(ret_result, "false") == 0) {
2830 free((void *)mfx->preload);
2831 mfx->preload = strdup("false");
2833 /*check tag : removable*/
2834 } else if (strcmp(ret_result, "removable") == 0) {
2835 ret_result = strtok(NULL, delims);
2836 if (strcmp(ret_result, "true") == 0){
2837 free((void *)mfx->removable);
2838 mfx->removable = strdup("true");
2839 } else if (strcmp(ret_result, "false") == 0) {
2840 free((void *)mfx->removable);
2841 mfx->removable = strdup("false");
2843 /*check tag : not matched*/
2845 DBG("tag process [%s]is not defined\n", ret_result);
2849 /*check next value*/
2850 if (tagv[++i] != NULL)
2851 tag = strdup(tagv[i]);
2853 DBG("tag process success...\n");
2859 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon)
2861 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2862 icon->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2863 if (xmlTextReaderConstXmlLang(reader)) {
2864 icon->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2865 if (icon->lang == NULL)
2866 icon->lang = strdup(DEFAULT_LOCALE);
2868 icon->lang = strdup(DEFAULT_LOCALE);
2870 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
2871 icon->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
2872 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
2873 icon->size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
2874 if (xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")))
2875 icon->resolution = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")));
2876 xmlTextReaderRead(reader);
2877 if (xmlTextReaderValue(reader)) {
2878 const char *text = ASCII(xmlTextReaderValue(reader));
2880 icon->text = (const char *)__get_icon_with_path(text);
2888 static int __ps_process_image(xmlTextReaderPtr reader, image_x *image)
2890 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2891 image->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2892 if (xmlTextReaderConstXmlLang(reader)) {
2893 image->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2894 if (image->lang == NULL)
2895 image->lang = strdup(DEFAULT_LOCALE);
2897 image->lang = strdup(DEFAULT_LOCALE);
2899 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
2900 image->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
2901 xmlTextReaderRead(reader);
2902 if (xmlTextReaderValue(reader))
2903 image->text = ASCII(xmlTextReaderValue(reader));
2908 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label)
2910 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2911 label->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2912 if (xmlTextReaderConstXmlLang(reader)) {
2913 label->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2914 if (label->lang == NULL)
2915 label->lang = strdup(DEFAULT_LOCALE);
2917 label->lang = strdup(DEFAULT_LOCALE);
2919 xmlTextReaderRead(reader);
2920 if (xmlTextReaderValue(reader))
2921 label->text = ASCII(xmlTextReaderValue(reader));
2923 /* DBG("lable name %s\n", label->name);
2924 DBG("lable lang %s\n", label->lang);
2925 DBG("lable text %s\n", label->text);
2931 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author)
2933 if (xmlTextReaderGetAttribute(reader, XMLCHAR("email")))
2934 author->email = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("email")));
2935 if (xmlTextReaderGetAttribute(reader, XMLCHAR("href")))
2936 author->href = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("href")));
2937 if (xmlTextReaderConstXmlLang(reader)) {
2938 author->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2939 if (author->lang == NULL)
2940 author->lang = strdup(DEFAULT_LOCALE);
2942 author->lang = strdup(DEFAULT_LOCALE);
2944 xmlTextReaderRead(reader);
2945 if (xmlTextReaderValue(reader)) {
2946 const char *text = ASCII(xmlTextReaderValue(reader));
2947 if (*text == '\n') {
2948 author->text = NULL;
2952 author->text = ASCII(xmlTextReaderValue(reader));
2957 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description)
2959 if (xmlTextReaderConstXmlLang(reader)) {
2960 description->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2961 if (description->lang == NULL)
2962 description->lang = strdup(DEFAULT_LOCALE);
2964 description->lang = strdup(DEFAULT_LOCALE);
2966 xmlTextReaderRead(reader);
2967 if (xmlTextReaderValue(reader)) {
2968 const char *text = ASCII(xmlTextReaderValue(reader));
2969 if (*text == '\n') {
2970 description->text = NULL;
2974 description->text = ASCII(xmlTextReaderValue(reader));
2979 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license)
2981 if (xmlTextReaderConstXmlLang(reader)) {
2982 license->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2983 if (license->lang == NULL)
2984 license->lang = strdup(DEFAULT_LOCALE);
2986 license->lang = strdup(DEFAULT_LOCALE);
2988 xmlTextReaderRead(reader);
2989 if (xmlTextReaderValue(reader))
2990 license->text = ASCII(xmlTextReaderValue(reader));
2994 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability)
2996 const xmlChar *node;
2999 resolution_x *tmp1 = NULL;
3001 if (xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")))
3002 capability->operationid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")));
3004 depth = xmlTextReaderDepth(reader);
3005 while ((ret = __next_child_element(reader, depth))) {
3006 node = xmlTextReaderConstName(reader);
3008 DBG("xmlTextReaderConstName value is NULL\n");
3012 if (!strcmp(ASCII(node), "resolution")) {
3013 resolution_x *resolution = malloc(sizeof(resolution_x));
3014 if (resolution == NULL) {
3015 DBG("Malloc Failed\n");
3018 memset(resolution, '\0', sizeof(resolution_x));
3019 LISTADD(capability->resolution, resolution);
3020 ret = __ps_process_resolution(reader, resolution);
3024 DBG("Processing capability failed\n");
3029 if (capability->resolution) {
3030 LISTHEAD(capability->resolution, tmp1);
3031 capability->resolution = tmp1;
3037 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol)
3039 const xmlChar *node;
3042 capability_x *tmp1 = NULL;
3044 if (xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")))
3045 datacontrol->providerid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")));
3047 depth = xmlTextReaderDepth(reader);
3048 while ((ret = __next_child_element(reader, depth))) {
3049 node = xmlTextReaderConstName(reader);
3051 DBG("xmlTextReaderConstName value is NULL\n");
3055 if (!strcmp(ASCII(node), "capability")) {
3056 capability_x *capability = malloc(sizeof(capability_x));
3057 if (capability == NULL) {
3058 DBG("Malloc Failed\n");
3061 memset(capability, '\0', sizeof(capability_x));
3062 LISTADD(datacontrol->capability, capability);
3063 ret = __ps_process_capability(reader, capability);
3067 DBG("Processing datacontrol failed\n");
3072 if (datacontrol->capability) {
3073 LISTHEAD(datacontrol->capability, tmp1);
3074 datacontrol->capability = tmp1;
3080 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication)
3082 const xmlChar *node;
3085 char *newappid = NULL;
3086 label_x *tmp1 = NULL;
3087 icon_x *tmp2 = NULL;
3088 appsvc_x *tmp3 = NULL;
3089 appcontrol_x *tmp4 = NULL;
3090 launchconditions_x *tmp5 = NULL;
3091 notification_x *tmp6 = NULL;
3092 datashare_x *tmp7 = NULL;
3093 category_x *tmp8 = NULL;
3094 metadata_x *tmp9 = NULL;
3095 image_x *tmp10 = NULL;
3096 permission_x *tmp11 = NULL;
3098 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
3099 uiapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
3100 if (uiapplication->appid == NULL) {
3101 DBG("appid cant be NULL\n");
3105 DBG("appid is mandatory\n");
3109 ret = __validate_appid(package, uiapplication->appid, &newappid);
3111 DBG("appid is not proper\n");
3115 if (uiapplication->appid)
3116 free((void *)uiapplication->appid);
3117 uiapplication->appid = newappid;
3119 uiapplication->package= strdup(package);
3121 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
3122 uiapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
3123 if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay"))) {
3124 uiapplication->nodisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay")));
3125 if (uiapplication->nodisplay == NULL)
3126 uiapplication->nodisplay = strdup("false");
3128 uiapplication->nodisplay = strdup("false");
3130 if (xmlTextReaderGetAttribute(reader, XMLCHAR("multiple"))) {
3131 uiapplication->multiple = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("multiple")));
3132 if (uiapplication->multiple == NULL)
3133 uiapplication->multiple = strdup("false");
3135 uiapplication->multiple = strdup("false");
3137 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
3138 uiapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
3139 if (xmlTextReaderGetAttribute(reader, XMLCHAR("categories")))
3140 uiapplication->categories = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("categories")));
3141 if (xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")))
3142 uiapplication->extraid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")));
3143 if (xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage"))) {
3144 uiapplication->taskmanage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage")));
3145 if (uiapplication->taskmanage == NULL)
3146 uiapplication->taskmanage = strdup("true");
3148 uiapplication->taskmanage = strdup("true");
3150 if (xmlTextReaderGetAttribute(reader, XMLCHAR("enabled"))) {
3151 uiapplication->enabled = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("enabled")));
3152 if (uiapplication->enabled == NULL)
3153 uiapplication->enabled = strdup("true");
3155 uiapplication->enabled = strdup("true");
3157 if (xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration"))) {
3158 uiapplication->hwacceleration = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration")));
3159 if (uiapplication->hwacceleration == NULL)
3160 uiapplication->hwacceleration = strdup("use-system-setting");
3162 uiapplication->hwacceleration = strdup("use-system-setting");
3164 if (xmlTextReaderGetAttribute(reader, XMLCHAR("screen-reader"))) {
3165 uiapplication->screenreader = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("screen-reader")));
3166 if (uiapplication->screenreader == NULL)
3167 uiapplication->screenreader = strdup("use-system-setting");
3169 uiapplication->screenreader = strdup("use-system-setting");
3171 if (xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")))
3172 uiapplication->recentimage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")));
3173 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp"))) {
3174 uiapplication->mainapp = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp")));
3175 if (uiapplication->mainapp == NULL)
3176 uiapplication->mainapp = strdup("false");
3178 uiapplication->mainapp = strdup("false");
3180 if (xmlTextReaderGetAttribute(reader, XMLCHAR("launchcondition"))) {
3181 uiapplication->launchcondition = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("launchcondition")));
3182 if (uiapplication->launchcondition == NULL)
3183 uiapplication->launchcondition = strdup("false");
3185 uiapplication->launchcondition = strdup("false");
3188 if (xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay"))) {
3189 uiapplication->indicatordisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay")));
3190 if (uiapplication->indicatordisplay == NULL)
3191 uiapplication->indicatordisplay = strdup("true");
3193 uiapplication->indicatordisplay = strdup("true");
3195 if (xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")))
3196 uiapplication->portraitimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")));
3198 uiapplication->portraitimg = NULL;
3199 if (xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")))
3200 uiapplication->landscapeimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")));
3202 uiapplication->landscapeimg = NULL;
3203 if (xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility"))) {
3204 uiapplication->guestmode_visibility = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility")));
3205 if (uiapplication->guestmode_visibility == NULL)
3206 uiapplication->guestmode_visibility = strdup("true");
3208 uiapplication->guestmode_visibility = strdup("true");
3210 if (xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type"))) {
3211 uiapplication->permission_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type")));
3212 if (uiapplication->permission_type == NULL)
3213 uiapplication->permission_type = strdup("normal");
3215 uiapplication->permission_type = strdup("normal");
3217 if (xmlTextReaderGetAttribute(reader, XMLCHAR("component-type"))) {
3218 uiapplication->component_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("component-type")));
3219 if (uiapplication->component_type == NULL)
3220 uiapplication->component_type = strdup("uiapp");
3222 uiapplication->component_type = strdup("uiapp");
3224 if (xmlTextReaderGetAttribute(reader, XMLCHAR("submode"))) {
3225 uiapplication->submode = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("submode")));
3226 if (uiapplication->submode == NULL)
3227 uiapplication->submode = strdup("false");
3229 uiapplication->submode = strdup("false");
3231 if (xmlTextReaderGetAttribute(reader, XMLCHAR("submode-mainid")))
3232 uiapplication->submode_mainid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("submode-mainid")));
3234 depth = xmlTextReaderDepth(reader);
3235 while ((ret = __next_child_element(reader, depth))) {
3236 node = xmlTextReaderConstName(reader);
3238 DBG("xmlTextReaderConstName value is NULL\n");
3241 if (!strcmp(ASCII(node), "label")) {
3242 label_x *label = malloc(sizeof(label_x));
3243 if (label == NULL) {
3244 DBG("Malloc Failed\n");
3247 memset(label, '\0', sizeof(label_x));
3248 LISTADD(uiapplication->label, label);
3249 ret = __ps_process_label(reader, label);
3250 } else if (!strcmp(ASCII(node), "icon")) {
3251 icon_x *icon = malloc(sizeof(icon_x));
3253 DBG("Malloc Failed\n");
3256 memset(icon, '\0', sizeof(icon_x));
3257 LISTADD(uiapplication->icon, icon);
3258 ret = __ps_process_icon(reader, icon);
3259 } else if (!strcmp(ASCII(node), "image")) {
3260 image_x *image = malloc(sizeof(image_x));
3261 if (image == NULL) {
3262 DBG("Malloc Failed\n");
3265 memset(image, '\0', sizeof(image_x));
3266 LISTADD(uiapplication->image, image);
3267 ret = __ps_process_image(reader, image);
3268 } else if (!strcmp(ASCII(node), "category")) {
3269 category_x *category = malloc(sizeof(category_x));
3270 if (category == NULL) {
3271 DBG("Malloc Failed\n");
3274 memset(category, '\0', sizeof(category_x));
3275 LISTADD(uiapplication->category, category);
3276 ret = __ps_process_category(reader, category);
3277 } else if (!strcmp(ASCII(node), "metadata")) {
3278 metadata_x *metadata = malloc(sizeof(metadata_x));
3279 if (metadata == NULL) {
3280 DBG("Malloc Failed\n");
3283 memset(metadata, '\0', sizeof(metadata_x));
3284 LISTADD(uiapplication->metadata, metadata);
3285 ret = __ps_process_metadata(reader, metadata);
3286 } else if (!strcmp(ASCII(node), "permission")) {
3287 permission_x *permission = malloc(sizeof(permission_x));
3288 if (permission == NULL) {
3289 DBG("Malloc Failed\n");
3292 memset(permission, '\0', sizeof(permission_x));
3293 LISTADD(uiapplication->permission, permission);
3294 ret = __ps_process_permission(reader, permission);
3295 } else if (!strcmp(ASCII(node), "app-control")) {
3296 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
3297 if (appcontrol == NULL) {
3298 DBG("Malloc Failed\n");
3301 memset(appcontrol, '\0', sizeof(appcontrol_x));
3302 LISTADD(uiapplication->appcontrol, appcontrol);
3303 ret = __ps_process_appcontrol(reader, appcontrol);
3304 } else if (!strcmp(ASCII(node), "application-service")) {
3305 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
3306 if (appsvc == NULL) {
3307 DBG("Malloc Failed\n");
3310 memset(appsvc, '\0', sizeof(appsvc_x));
3311 LISTADD(uiapplication->appsvc, appsvc);
3312 ret = __ps_process_appsvc(reader, appsvc);
3313 } else if (!strcmp(ASCII(node), "data-share")) {
3314 datashare_x *datashare = malloc(sizeof(datashare_x));
3315 if (datashare == NULL) {
3316 DBG("Malloc Failed\n");
3319 memset(datashare, '\0', sizeof(datashare_x));
3320 LISTADD(uiapplication->datashare, datashare);
3321 ret = __ps_process_datashare(reader, datashare);
3322 } else if (!strcmp(ASCII(node), "launch-conditions")) {
3323 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
3324 if (launchconditions == NULL) {
3325 DBG("Malloc Failed\n");
3328 memset(launchconditions, '\0', sizeof(launchconditions_x));
3329 LISTADD(uiapplication->launchconditions, launchconditions);
3330 ret = __ps_process_launchconditions(reader, launchconditions);
3331 } else if (!strcmp(ASCII(node), "notification")) {
3332 notification_x *notification = malloc(sizeof(notification_x));
3333 if (notification == NULL) {
3334 DBG("Malloc Failed\n");
3337 memset(notification, '\0', sizeof(notification_x));
3338 LISTADD(uiapplication->notification, notification);
3339 ret = __ps_process_notification(reader, notification);
3343 DBG("Processing uiapplication failed\n");
3348 if (uiapplication->label) {
3349 LISTHEAD(uiapplication->label, tmp1);
3350 uiapplication->label = tmp1;
3352 if (uiapplication->icon) {
3353 LISTHEAD(uiapplication->icon, tmp2);
3354 uiapplication->icon = tmp2;
3356 if (uiapplication->appsvc) {
3357 LISTHEAD(uiapplication->appsvc, tmp3);
3358 uiapplication->appsvc = tmp3;
3360 if (uiapplication->appcontrol) {
3361 LISTHEAD(uiapplication->appcontrol, tmp4);
3362 uiapplication->appcontrol = tmp4;
3364 if (uiapplication->launchconditions) {
3365 LISTHEAD(uiapplication->launchconditions, tmp5);
3366 uiapplication->launchconditions = tmp5;
3368 if (uiapplication->notification) {
3369 LISTHEAD(uiapplication->notification, tmp6);
3370 uiapplication->notification = tmp6;
3372 if (uiapplication->datashare) {
3373 LISTHEAD(uiapplication->datashare, tmp7);
3374 uiapplication->datashare = tmp7;
3376 if (uiapplication->category) {
3377 LISTHEAD(uiapplication->category, tmp8);
3378 uiapplication->category = tmp8;
3380 if (uiapplication->metadata) {
3381 LISTHEAD(uiapplication->metadata, tmp9);
3382 uiapplication->metadata = tmp9;
3384 if (uiapplication->image) {
3385 LISTHEAD(uiapplication->image, tmp10);
3386 uiapplication->image = tmp10;
3388 if (uiapplication->permission) {
3389 LISTHEAD(uiapplication->permission, tmp11);
3390 uiapplication->permission = tmp11;
3396 static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication)
3398 const xmlChar *node;
3401 char *newappid = NULL;
3402 label_x *tmp1 = NULL;
3403 icon_x *tmp2 = NULL;
3404 appsvc_x *tmp3 = NULL;
3405 appcontrol_x *tmp4 = NULL;
3406 datacontrol_x *tmp5 = NULL;
3407 launchconditions_x *tmp6 = NULL;
3408 notification_x *tmp7 = NULL;
3409 datashare_x *tmp8 = NULL;
3410 category_x *tmp9 = NULL;
3411 metadata_x *tmp10 = NULL;
3412 permission_x *tmp11 = NULL;
3414 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
3415 serviceapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
3416 if (serviceapplication->appid == NULL) {
3417 DBG("appid cant be NULL\n");
3421 DBG("appid is mandatory\n");
3425 ret = __validate_appid(package, serviceapplication->appid, &newappid);
3427 DBG("appid is not proper\n");
3431 if (serviceapplication->appid)
3432 free((void *)serviceapplication->appid);
3433 serviceapplication->appid = newappid;
3436 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
3437 serviceapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
3438 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
3439 serviceapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
3440 if (xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot"))) {
3441 serviceapplication->onboot = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot")));
3442 if (serviceapplication->onboot == NULL)
3443 serviceapplication->onboot = strdup("false");
3445 serviceapplication->onboot = strdup("false");
3447 if (xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart"))) {
3448 serviceapplication->autorestart = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart")));
3449 if (serviceapplication->autorestart == NULL)
3450 serviceapplication->autorestart = strdup("false");
3452 serviceapplication->autorestart = strdup("false");
3454 if (xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type"))) {
3455 serviceapplication->permission_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type")));
3456 if (serviceapplication->permission_type == NULL)
3457 serviceapplication->permission_type = strdup("normal");
3459 serviceapplication->permission_type = strdup("normal");
3462 depth = xmlTextReaderDepth(reader);
3463 while ((ret = __next_child_element(reader, depth))) {
3464 node = xmlTextReaderConstName(reader);
3466 DBG("xmlTextReaderConstName value is NULL\n");
3470 if (!strcmp(ASCII(node), "label")) {
3471 label_x *label = malloc(sizeof(label_x));
3472 if (label == NULL) {
3473 DBG("Malloc Failed\n");
3476 memset(label, '\0', sizeof(label_x));
3477 LISTADD(serviceapplication->label, label);
3478 ret = __ps_process_label(reader, label);
3479 } else if (!strcmp(ASCII(node), "icon")) {
3480 icon_x *icon = malloc(sizeof(icon_x));
3482 DBG("Malloc Failed\n");
3485 memset(icon, '\0', sizeof(icon_x));
3486 LISTADD(serviceapplication->icon, icon);
3487 ret = __ps_process_icon(reader, icon);
3488 } else if (!strcmp(ASCII(node), "category")) {
3489 category_x *category = malloc(sizeof(category_x));
3490 if (category == NULL) {
3491 DBG("Malloc Failed\n");
3494 memset(category, '\0', sizeof(category_x));
3495 LISTADD(serviceapplication->category, category);
3496 ret = __ps_process_category(reader, category);
3497 } else if (!strcmp(ASCII(node), "metadata")) {
3498 metadata_x *metadata = malloc(sizeof(metadata_x));
3499 if (metadata == NULL) {
3500 DBG("Malloc Failed\n");
3503 memset(metadata, '\0', sizeof(metadata_x));
3504 LISTADD(serviceapplication->metadata, metadata);
3505 ret = __ps_process_metadata(reader, metadata);
3506 } else if (!strcmp(ASCII(node), "permission")) {
3507 permission_x *permission = malloc(sizeof(permission_x));
3508 if (permission == NULL) {
3509 DBG("Malloc Failed\n");
3512 memset(permission, '\0', sizeof(permission_x));
3513 LISTADD(serviceapplication->permission, permission);
3514 ret = __ps_process_permission(reader, permission);
3515 } else if (!strcmp(ASCII(node), "app-control")) {
3516 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
3517 if (appcontrol == NULL) {
3518 DBG("Malloc Failed\n");
3521 memset(appcontrol, '\0', sizeof(appcontrol_x));
3522 LISTADD(serviceapplication->appcontrol, appcontrol);
3523 ret = __ps_process_appcontrol(reader, appcontrol);
3524 } else if (!strcmp(ASCII(node), "application-service")) {
3525 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
3526 if (appsvc == NULL) {
3527 DBG("Malloc Failed\n");
3530 memset(appsvc, '\0', sizeof(appsvc_x));
3531 LISTADD(serviceapplication->appsvc, appsvc);
3532 ret = __ps_process_appsvc(reader, appsvc);
3533 } else if (!strcmp(ASCII(node), "data-share")) {
3534 datashare_x *datashare = malloc(sizeof(datashare_x));
3535 if (datashare == NULL) {
3536 DBG("Malloc Failed\n");
3539 memset(datashare, '\0', sizeof(datashare_x));
3540 LISTADD(serviceapplication->datashare, datashare);
3541 ret = __ps_process_datashare(reader, datashare);
3542 } else if (!strcmp(ASCII(node), "launch-conditions")) {
3543 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
3544 if (launchconditions == NULL) {
3545 DBG("Malloc Failed\n");
3548 memset(launchconditions, '\0', sizeof(launchconditions_x));
3549 LISTADD(serviceapplication->launchconditions, launchconditions);
3550 ret = __ps_process_launchconditions(reader, launchconditions);
3551 } else if (!strcmp(ASCII(node), "notification")) {
3552 notification_x *notification = malloc(sizeof(notification_x));
3553 if (notification == NULL) {
3554 DBG("Malloc Failed\n");
3557 memset(notification, '\0', sizeof(notification_x));
3558 LISTADD(serviceapplication->notification, notification);
3559 ret = __ps_process_notification(reader, notification);
3560 } else if (!strcmp(ASCII(node), "data-control")) {
3561 datacontrol_x *datacontrol = malloc(sizeof(datacontrol_x));
3562 if (datacontrol == NULL) {
3563 DBG("Malloc Failed\n");
3566 memset(datacontrol, '\0', sizeof(datacontrol_x));
3567 LISTADD(serviceapplication->datacontrol, datacontrol);
3568 ret = __ps_process_datacontrol(reader, datacontrol);
3572 DBG("Processing serviceapplication failed\n");
3577 if (serviceapplication->label) {
3578 LISTHEAD(serviceapplication->label, tmp1);
3579 serviceapplication->label = tmp1;
3581 if (serviceapplication->icon) {
3582 LISTHEAD(serviceapplication->icon, tmp2);
3583 serviceapplication->icon = tmp2;
3585 if (serviceapplication->appsvc) {
3586 LISTHEAD(serviceapplication->appsvc, tmp3);
3587 serviceapplication->appsvc = tmp3;
3589 if (serviceapplication->appcontrol) {
3590 LISTHEAD(serviceapplication->appcontrol, tmp4);
3591 serviceapplication->appcontrol = tmp4;
3593 if (serviceapplication->datacontrol) {
3594 LISTHEAD(serviceapplication->datacontrol, tmp5);
3595 serviceapplication->datacontrol = tmp5;
3597 if (serviceapplication->launchconditions) {
3598 LISTHEAD(serviceapplication->launchconditions, tmp6);
3599 serviceapplication->launchconditions = tmp6;
3601 if (serviceapplication->notification) {
3602 LISTHEAD(serviceapplication->notification, tmp7);
3603 serviceapplication->notification = tmp7;
3605 if (serviceapplication->datashare) {
3606 LISTHEAD(serviceapplication->datashare, tmp8);
3607 serviceapplication->datashare = tmp8;
3609 if (serviceapplication->category) {
3610 LISTHEAD(serviceapplication->category, tmp9);
3611 serviceapplication->category = tmp9;
3613 if (serviceapplication->metadata) {
3614 LISTHEAD(serviceapplication->metadata, tmp10);
3615 serviceapplication->metadata = tmp10;
3617 if (serviceapplication->permission) {
3618 LISTHEAD(serviceapplication->permission, tmp11);
3619 serviceapplication->permission = tmp11;
3625 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile)
3627 /*TODO: once policy is set*/
3631 static int __ps_process_font(xmlTextReaderPtr reader, font_x *font)
3633 /*TODO: once policy is set*/
3637 static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme)
3639 /*TODO: once policy is set*/
3643 static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon)
3645 /*TODO: once policy is set*/
3649 static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime)
3651 /*TODO: once policy is set*/
3655 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx)
3657 DBG("__start_process\n");
3658 const xmlChar *node;
3661 label_x *tmp1 = NULL;
3662 author_x *tmp2 = NULL;
3663 description_x *tmp3 = NULL;
3664 license_x *tmp4 = NULL;
3665 uiapplication_x *tmp5 = NULL;
3666 serviceapplication_x *tmp6 = NULL;
3667 daemon_x *tmp7 = NULL;
3668 theme_x *tmp8 = NULL;
3669 font_x *tmp9 = NULL;
3670 ime_x *tmp10 = NULL;
3671 icon_x *tmp11 = NULL;
3672 compatibility_x *tmp12 = NULL;
3673 deviceprofile_x *tmp13 = NULL;
3674 privileges_x *tmp14 = NULL;
3676 depth = xmlTextReaderDepth(reader);
3677 while ((ret = __next_child_element(reader, depth))) {
3678 node = xmlTextReaderConstName(reader);
3680 DBG("xmlTextReaderConstName value is NULL\n");
3684 if (!strcmp(ASCII(node), "label")) {
3685 label_x *label = malloc(sizeof(label_x));
3686 if (label == NULL) {
3687 DBG("Malloc Failed\n");
3690 memset(label, '\0', sizeof(label_x));
3691 LISTADD(mfx->label, label);
3692 ret = __ps_process_label(reader, label);
3693 } else if (!strcmp(ASCII(node), "author")) {
3694 author_x *author = malloc(sizeof(author_x));
3695 if (author == NULL) {
3696 DBG("Malloc Failed\n");
3699 memset(author, '\0', sizeof(author_x));
3700 LISTADD(mfx->author, author);
3701 ret = __ps_process_author(reader, author);
3702 } else if (!strcmp(ASCII(node), "description")) {
3703 description_x *description = malloc(sizeof(description_x));
3704 if (description == NULL) {
3705 DBG("Malloc Failed\n");
3708 memset(description, '\0', sizeof(description_x));
3709 LISTADD(mfx->description, description);
3710 ret = __ps_process_description(reader, description);
3711 } else if (!strcmp(ASCII(node), "license")) {
3712 license_x *license = malloc(sizeof(license_x));
3713 if (license == NULL) {
3714 DBG("Malloc Failed\n");
3717 memset(license, '\0', sizeof(license_x));
3718 LISTADD(mfx->license, license);
3719 ret = __ps_process_license(reader, license);
3720 } else if (!strcmp(ASCII(node), "privileges")) {
3721 privileges_x *privileges = malloc(sizeof(privileges_x));
3722 if (privileges == NULL) {
3723 DBG("Malloc Failed\n");
3726 memset(privileges, '\0', sizeof(privileges_x));
3727 LISTADD(mfx->privileges, privileges);
3728 ret = __ps_process_privileges(reader, privileges);
3729 } else if (!strcmp(ASCII(node), "ui-application")) {
3730 uiapplication_x *uiapplication = malloc(sizeof(uiapplication_x));
3731 if (uiapplication == NULL) {
3732 DBG("Malloc Failed\n");
3735 memset(uiapplication, '\0', sizeof(uiapplication_x));
3736 LISTADD(mfx->uiapplication, uiapplication);
3737 ret = __ps_process_uiapplication(reader, uiapplication);
3738 } else if (!strcmp(ASCII(node), "service-application")) {
3739 serviceapplication_x *serviceapplication = malloc(sizeof(serviceapplication_x));
3740 if (serviceapplication == NULL) {
3741 DBG("Malloc Failed\n");
3744 memset(serviceapplication, '\0', sizeof(serviceapplication_x));
3745 LISTADD(mfx->serviceapplication, serviceapplication);
3746 ret = __ps_process_serviceapplication(reader, serviceapplication);
3747 } else if (!strcmp(ASCII(node), "daemon")) {
3748 daemon_x *daemon = malloc(sizeof(daemon_x));
3749 if (daemon == NULL) {
3750 DBG("Malloc Failed\n");
3753 memset(daemon, '\0', sizeof(daemon_x));
3754 LISTADD(mfx->daemon, daemon);
3755 ret = __ps_process_daemon(reader, daemon);
3756 } else if (!strcmp(ASCII(node), "theme")) {
3757 theme_x *theme = malloc(sizeof(theme_x));
3758 if (theme == NULL) {
3759 DBG("Malloc Failed\n");
3762 memset(theme, '\0', sizeof(theme_x));
3763 LISTADD(mfx->theme, theme);
3764 ret = __ps_process_theme(reader, theme);
3765 } else if (!strcmp(ASCII(node), "font")) {
3766 font_x *font = malloc(sizeof(font_x));
3768 DBG("Malloc Failed\n");
3771 memset(font, '\0', sizeof(font_x));
3772 LISTADD(mfx->font, font);
3773 ret = __ps_process_font(reader, font);
3774 } else if (!strcmp(ASCII(node), "ime")) {
3775 ime_x *ime = malloc(sizeof(ime_x));
3777 DBG("Malloc Failed\n");
3780 memset(ime, '\0', sizeof(ime_x));
3781 LISTADD(mfx->ime, ime);
3782 ret = __ps_process_ime(reader, ime);
3783 } else if (!strcmp(ASCII(node), "icon")) {
3784 icon_x *icon = malloc(sizeof(icon_x));
3786 DBG("Malloc Failed\n");
3789 memset(icon, '\0', sizeof(icon_x));
3790 LISTADD(mfx->icon, icon);
3791 ret = __ps_process_icon(reader, icon);
3792 } else if (!strcmp(ASCII(node), "device-profile")) {
3793 deviceprofile_x *deviceprofile = malloc(sizeof(deviceprofile_x));
3794 if (deviceprofile == NULL) {
3795 DBG("Malloc Failed\n");
3798 memset(deviceprofile, '\0', sizeof(deviceprofile_x));
3799 LISTADD(mfx->deviceprofile, deviceprofile);
3800 ret = __ps_process_deviceprofile(reader, deviceprofile);
3801 } else if (!strcmp(ASCII(node), "compatibility")) {
3802 compatibility_x *compatibility = malloc(sizeof(compatibility_x));
3803 if (compatibility == NULL) {
3804 DBG("Malloc Failed\n");
3807 memset(compatibility, '\0', sizeof(compatibility_x));
3808 LISTADD(mfx->compatibility, compatibility);
3809 ret = __ps_process_compatibility(reader, compatibility);
3810 } else if (!strcmp(ASCII(node), "shortcut-list")) {
3812 } else if (!strcmp(ASCII(node), "livebox")) {
3814 } else if (!strcmp(ASCII(node), "account")) {
3816 } else if (!strcmp(ASCII(node), "notifications")) {
3818 } else if (!strcmp(ASCII(node), "ime")) {
3824 DBG("Processing manifest failed\n");
3829 LISTHEAD(mfx->label, tmp1);
3833 LISTHEAD(mfx->author, tmp2);
3836 if (mfx->description) {
3837 LISTHEAD(mfx->description, tmp3);
3838 mfx->description= tmp3;
3841 LISTHEAD(mfx->license, tmp4);
3844 if (mfx->uiapplication) {
3845 LISTHEAD(mfx->uiapplication, tmp5);
3846 mfx->uiapplication = tmp5;
3848 if (mfx->serviceapplication) {
3849 LISTHEAD(mfx->serviceapplication, tmp6);
3850 mfx->serviceapplication = tmp6;
3853 LISTHEAD(mfx->daemon, tmp7);
3857 LISTHEAD(mfx->theme, tmp8);
3861 LISTHEAD(mfx->font, tmp9);
3865 LISTHEAD(mfx->ime, tmp10);
3869 LISTHEAD(mfx->icon, tmp11);
3872 if (mfx->compatibility) {
3873 LISTHEAD(mfx->compatibility, tmp12);
3874 mfx->compatibility= tmp12;
3876 if (mfx->deviceprofile) {
3877 LISTHEAD(mfx->deviceprofile, tmp13);
3878 mfx->deviceprofile= tmp13;
3880 if (mfx->privileges) {
3881 LISTHEAD(mfx->privileges, tmp14);
3882 mfx->privileges = tmp14;
3887 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx)
3889 const xmlChar *node;
3892 if ((ret = __next_child_element(reader, -1))) {
3893 node = xmlTextReaderConstName(reader);
3895 DBG("xmlTextReaderConstName value is NULL\n");
3899 if (!strcmp(ASCII(node), "manifest")) {
3900 if (xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")))
3901 mfx->ns = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")));
3902 if (xmlTextReaderGetAttribute(reader, XMLCHAR("package"))) {
3903 mfx->package= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("package")));
3904 if (mfx->package == NULL) {
3905 DBG("package cant be NULL\n");
3909 DBG("package field is mandatory\n");
3912 package = mfx->package;
3913 if (xmlTextReaderGetAttribute(reader, XMLCHAR("version")))
3914 mfx->version= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("version")));
3915 /*app2ext needs package size for external installation*/
3916 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
3917 mfx->package_size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
3918 if (xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")))
3919 mfx->installlocation = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")));
3920 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
3921 mfx->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
3922 if (xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")))
3923 mfx->root_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")));
3924 if (xmlTextReaderGetAttribute(reader, XMLCHAR("csc_path")))
3925 mfx->csc_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("csc_path")));
3926 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting"))) {
3927 mfx->appsetting = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting")));
3928 if (mfx->appsetting == NULL)
3929 mfx->appsetting = strdup("false");
3931 mfx->appsetting = strdup("false");
3933 if (xmlTextReaderGetAttribute(reader, XMLCHAR("storeclient-id")))
3934 mfx->storeclient_id= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("storeclient-id")));
3935 if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay-setting"))) {
3936 mfx->nodisplay_setting = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay-setting")));
3937 if (mfx->nodisplay_setting == NULL)
3938 mfx->nodisplay_setting = strdup("false");
3940 mfx->nodisplay_setting = strdup("false");
3942 if (xmlTextReaderGetAttribute(reader, XMLCHAR("url")))
3943 mfx->package_url= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("url")));
3945 /*Assign default values. If required it will be overwritten in __add_preload_info()*/
3946 mfx->preload = strdup("False");
3947 mfx->removable = strdup("True");
3948 mfx->readonly = strdup("False");
3949 mfx->update = strdup("False");
3950 mfx->system = strdup("False");
3951 char buf[PKG_STRING_LEN_MAX] = {'\0'};
3953 time_t current_time;
3954 time(¤t_time);
3955 snprintf(buf, PKG_STRING_LEN_MAX - 1, "%d", current_time);
3956 val = strndup(buf, PKG_STRING_LEN_MAX - 1);
3957 mfx->installed_time = val;
3959 mfx->installed_storage= strdup("installed_internal");
3961 ret = __start_process(reader, mfx);
3963 DBG("No Manifest element found\n");
3970 #define DESKTOP_RW_PATH "/opt/share/applications/"
3971 #define DESKTOP_RO_PATH "/usr/share/applications/"
3972 #define MANIFEST_RO_PREFIX "/usr/share/packages/"
3974 static char* __convert_to_system_locale(const char *mlocale)
3976 if (mlocale == NULL)
3978 char *locale = NULL;
3979 locale = (char *)calloc(1, 6);
3981 DBGE("Malloc Failed\n");
3985 strncpy(locale, mlocale, 2);
3986 strncat(locale, "_", 1);
3987 locale[3] = toupper(mlocale[3]);
3988 locale[4] = toupper(mlocale[4]);
3992 #define LIBAIL_PATH "/usr/lib/libail.so.0"
3994 /* operation_type */
4003 static int __ail_change_info(int op, const char *appid)
4005 void *lib_handle = NULL;
4006 int (*ail_desktop_operation) (const char *);
4010 if ((lib_handle = dlopen(LIBAIL_PATH, RTLD_LAZY)) == NULL) {
4011 DBGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAIL_PATH);
4018 aop = "ail_desktop_add";
4021 aop = "ail_desktop_update";
4024 aop = "ail_desktop_remove";
4027 aop = "ail_desktop_clean";
4034 if ((ail_desktop_operation =
4035 dlsym(lib_handle, aop)) == NULL || dlerror() != NULL) {
4036 DBGE("can not find symbol \n");
4040 ret = ail_desktop_operation(appid);
4044 dlclose(lib_handle);
4050 /* desktop shoud be generated automatically based on manifest */
4051 /* Currently removable, taskmanage, etc fields are not considerd. it will be decided soon.*/
4052 #define BUFMAX 1024*128
4053 static int __ps_make_nativeapp_desktop(manifest_x * mfx, const char *manifest, bool is_update)
4057 char filepath[PKG_STRING_LEN_MAX] = "";
4059 char *buftemp = NULL;
4060 char *locale = NULL;
4062 buf = (char *)calloc(1, BUFMAX);
4064 DBGE("Malloc Failed\n");
4068 buftemp = (char *)calloc(1, BUFMAX);
4070 DBGE("Malloc Failed\n");
4076 __ail_change_info(AIL_CLEAN, mfx->package);
4078 for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) {
4080 if (manifest != NULL) {
4081 /* skip making a deskfile and update ail, if preload app is updated */
4082 if(strstr(manifest, MANIFEST_RO_PREFIX)) {
4083 __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid);
4084 DBGE("preload app is update : skip and update ail : %s", manifest);
4089 if(mfx->readonly && !strcasecmp(mfx->readonly, "True"))
4090 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RO_PATH, mfx->uiapplication->appid);
4092 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, mfx->uiapplication->appid);
4094 /* skip if desktop exists
4095 if (access(filepath, R_OK) == 0)
4099 file = fopen(filepath, "w");
4102 DBGE("Can't open %s", filepath);
4108 snprintf(buf, BUFMAX, "[Desktop Entry]\n");
4109 fwrite(buf, 1, strlen(buf), file);
4111 for( ; mfx->uiapplication->label ; mfx->uiapplication->label = mfx->uiapplication->label->next) {
4112 if(!strcmp(mfx->uiapplication->label->lang, DEFAULT_LOCALE)) {
4113 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
4115 locale = __convert_to_system_locale(mfx->uiapplication->label->lang);
4116 snprintf(buf, BUFMAX, "Name[%s]=%s\n", locale,
4117 mfx->uiapplication->label->text);
4120 fwrite(buf, 1, strlen(buf), file);
4123 if(mfx->uiapplication->label && mfx->uiapplication->label->text) {
4124 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
4125 fwrite(buf, 1, strlen(buf), file);
4128 else if(mfx->label && mfx->label->text) {
4129 snprintf(buf, BUFMAX, "Name=%s\n", mfx->label->text);
4130 fwrite(buf, 1, strlen(buf), file);
4132 snprintf(buf, BUFMAX, "Name=%s\n", mfx->package);
4133 fwrite(buf, 1, strlen(buf), file);
4138 snprintf(buf, BUFMAX, "Type=Application\n");
4139 fwrite(buf, 1, strlen(buf), file);
4141 if(mfx->uiapplication->exec) {
4142 snprintf(buf, BUFMAX, "Exec=%s\n", mfx->uiapplication->exec);
4143 fwrite(buf, 1, strlen(buf), file);
4146 if(mfx->uiapplication->icon && mfx->uiapplication->icon->text) {
4147 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->uiapplication->icon->text);
4148 fwrite(buf, 1, strlen(buf), file);
4149 } else if(mfx->icon && mfx->icon->text) {
4150 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->icon->text);
4151 fwrite(buf, 1, strlen(buf), file);
4155 if(mfx->uiapplication && mfx->uiapplication->appsvc) {
4156 appsvc_x *asvc = mfx->uiapplication->appsvc;
4158 const char *mime = NULL;
4159 const char *mime_delim = "; ";
4162 strncpy(buf, "MimeType=", BUFMAX-1);
4168 DBG("MIME type: %s\n", mime);
4169 strncat(buf, mime, BUFMAX-strlen(buf)-1);
4171 strncat(buf, mime_delim, BUFMAX-strlen(buf)-1);
4179 DBG("MIME types: buf[%s]\n", buf);
4180 DBG("MIME count: %d\n", mime_count);
4182 fwrite(buf, 1, strlen(buf), file);
4186 snprintf(buf, BUFMAX, "Version=%s\n", mfx->version);
4187 fwrite(buf, 1, strlen(buf), file);
4190 if(mfx->uiapplication->nodisplay) {
4191 snprintf(buf, BUFMAX, "NoDisplay=%s\n", mfx->uiapplication->nodisplay);
4192 fwrite(buf, 1, strlen(buf), file);
4195 if(mfx->uiapplication->categories) {
4196 snprintf(buf, BUFMAX, "Categories=%s\n", mfx->uiapplication->categories);
4197 fwrite(buf, 1, strlen(buf), file);
4200 if(mfx->uiapplication->taskmanage && !strcasecmp(mfx->uiapplication->taskmanage, "False")) {
4201 snprintf(buf, BUFMAX, "X-TIZEN-TaskManage=False\n");
4202 fwrite(buf, 1, strlen(buf), file);
4205 if(mfx->uiapplication->enabled && !strcasecmp(mfx->uiapplication->enabled, "False")) {
4206 snprintf(buf, BUFMAX, "X-TIZEN-Enabled=False\n");
4207 fwrite(buf, 1, strlen(buf), file);
4210 if(mfx->uiapplication->hwacceleration) {
4211 snprintf(buf, BUFMAX, "Hw-Acceleration=%s\n", mfx->uiapplication->hwacceleration);
4212 fwrite(buf, 1, strlen(buf), file);
4215 if(mfx->uiapplication->multiple && !strcasecmp(mfx->uiapplication->multiple, "True")) {
4216 snprintf(buf, BUFMAX, "X-TIZEN-Multiple=True\n");
4217 fwrite(buf, 1, strlen(buf), file);
4220 if(mfx->uiapplication->extraid) {
4221 snprintf(buf, BUFMAX, "X-TIZEN-PackageID=%s\n", mfx->uiapplication->extraid);
4222 fwrite(buf, 1, strlen(buf), file);
4225 if(mfx->removable && !strcasecmp(mfx->removable, "False")) {
4226 snprintf(buf, BUFMAX, "X-TIZEN-Removable=False\n");
4227 fwrite(buf, 1, strlen(buf), file);
4231 snprintf(buf, BUFMAX, "X-TIZEN-PackageType=%s\n", mfx->type);
4232 fwrite(buf, 1, strlen(buf), file);
4235 snprintf(buf, BUFMAX, "X-TIZEN-PkgID=%s\n", mfx->package);
4236 fwrite(buf, 1, strlen(buf), file);
4239 // snprintf(buf, BUFMAX, "X-TIZEN-PackageType=rpm\n");
4240 // fwrite(buf, 1, strlen(buf), file);
4243 if(mfx->uiapplication->appsvc) {
4244 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
4245 DBG("buf[%s]\n", buf);
4248 uiapplication_x *up = mfx->uiapplication;
4249 appsvc_x *asvc = NULL;
4250 operation_x *op = NULL;
4253 subapp_x *sub = NULL;
4254 const char *operation = NULL;
4255 const char *mime = NULL;
4256 const char *uri = NULL;
4257 const char *subapp = NULL;
4262 while(asvc != NULL) {
4263 op = asvc->operation;
4266 operation = op->name;
4285 strncpy(buftemp, buf, BUFMAX);
4286 snprintf(buf, BUFMAX, "%s;", buftemp);
4290 strncpy(buftemp, buf, BUFMAX);
4291 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
4292 DBG("buf[%s]\n", buf);
4297 } while(ui != NULL);
4301 }while(sub != NULL);
4314 fwrite(buf, 1, strlen(buf), file);
4316 // strncpy(buftemp, buf, BUFMAX);
4317 // snprintf(buf, BUFMAX, "%s\n", buftemp);
4318 // fwrite(buf, 1, strlen(buf), file);
4321 if(mfx->uiapplication->appcontrol) {
4322 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
4323 DBG("buf[%s]\n", buf);
4325 uiapplication_x *up = mfx->uiapplication;
4326 appcontrol_x *acontrol = NULL;
4327 operation_x *op = NULL;
4330 subapp_x *sub = NULL;
4331 const char *operation = NULL;
4332 const char *mime = NULL;
4333 const char *uri = NULL;
4334 const char *subapp = NULL;
4337 acontrol = up->appcontrol;
4338 while(acontrol != NULL) {
4339 op = acontrol->operation;
4342 operation = op->name;
4343 mi = acontrol->mime;
4349 sub = acontrol->subapp;
4361 strncpy(buftemp, buf, BUFMAX);
4362 snprintf(buf, BUFMAX, "%s;", buftemp);
4365 strncpy(buftemp, buf, BUFMAX);
4366 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
4367 DBG("buf[%s]\n", buf);
4372 } while(ui != NULL);
4376 }while(sub != NULL);
4385 acontrol = acontrol->next;
4389 fwrite(buf, 1, strlen(buf), file);
4391 // strncpy(buftemp, buf, BUFMAX);
4392 // snprintf(buf, BUFMAX, "%s\n", buftemp);
4393 // fwrite(buf, 1, strlen(buf), file);
4401 __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid);
4410 static int __ps_remove_nativeapp_desktop(manifest_x *mfx)
4412 char filepath[PKG_STRING_LEN_MAX] = "";
4414 uiapplication_x *uiapplication = mfx->uiapplication;
4416 for(; uiapplication; uiapplication=uiapplication->next) {
4417 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, uiapplication->appid);
4419 __ail_change_info(AIL_REMOVE, uiapplication->appid);
4421 ret = remove(filepath);
4429 #define LIBAPPSVC_PATH "/usr/lib/libappsvc.so.0"
4431 static int __ps_remove_appsvc_db(manifest_x *mfx)
4433 void *lib_handle = NULL;
4434 int (*appsvc_operation) (const char *);
4436 uiapplication_x *uiapplication = mfx->uiapplication;
4438 if ((lib_handle = dlopen(LIBAPPSVC_PATH, RTLD_LAZY)) == NULL) {
4439 DBGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAPPSVC_PATH);
4443 if ((appsvc_operation =
4444 dlsym(lib_handle, "appsvc_unset_defapp")) == NULL || dlerror() != NULL) {
4445 DBGE("can not find symbol \n");
4449 for(; uiapplication; uiapplication=uiapplication->next) {
4450 ret = appsvc_operation(uiapplication->appid);
4452 DBGE("can not operation symbol \n");
4457 dlclose(lib_handle);
4462 #define PRELOAD_PACKAGE_LIST "/usr/etc/package-manager/preload/preload_list.txt"
4463 static int __add_preload_info(manifest_x * mfx, const char *manifest)
4466 char buffer[1024] = { 0 };
4469 if(strstr(manifest, MANIFEST_RO_PREFIX)) {
4470 free((void *)mfx->readonly);
4471 mfx->readonly = strdup("True");
4473 free((void *)mfx->preload);
4474 mfx->preload = strdup("True");
4476 free((void *)mfx->removable);
4477 mfx->removable = strdup("False");
4479 free((void *)mfx->system);
4480 mfx->system = strdup("True");
4485 fp = fopen(PRELOAD_PACKAGE_LIST, "r");
4487 DBGE("no preload list\n");
4491 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
4492 if (buffer[0] == '#') {
4493 if(strcasestr(buffer, "RW_NORM"))
4495 else if(strcasestr(buffer, "RW_RM"))
4503 if(!strcmp(mfx->package, buffer)) {
4504 free((void *)mfx->preload);
4505 mfx->preload = strdup("True");
4507 free((void *)mfx->readonly);
4508 mfx->readonly = strdup("False");
4509 free((void *)mfx->removable);
4510 mfx->removable = strdup("False");
4511 } else if(state == 3){
4512 free((void *)mfx->readonly);
4513 mfx->readonly = strdup("False");
4514 free((void *)mfx->removable);
4515 mfx->removable = strdup("True");
4519 memset(buffer, 0x00, sizeof(buffer));
4528 static int __check_preload_updated(manifest_x * mfx, const char *manifest)
4530 char filepath[PKG_STRING_LEN_MAX] = "";
4532 uiapplication_x *uiapplication = mfx->uiapplication;
4534 if(strstr(manifest, MANIFEST_RO_PREFIX)) {
4535 /* if preload app is updated, then remove previous desktop file on RW*/
4536 for(; uiapplication; uiapplication=uiapplication->next) {
4537 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, uiapplication->appid);
4538 ret = remove(filepath);
4543 /* if downloaded app is updated, then update tag set true*/
4544 free((void *)mfx->update);
4545 mfx->update = strdup("true");
4552 API int pkgmgr_parser_create_desktop_file(manifest_x *mfx)
4556 DBG("Manifest pointer is NULL\n");
4559 ret = __ps_make_nativeapp_desktop(mfx, NULL, 0);
4561 DBG("Creating desktop file failed\n");
4563 DBG("Creating desktop file Success\n");
4567 API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
4572 free((void *)mfx->ns);
4576 free((void *)mfx->package);
4577 mfx->package = NULL;
4580 free((void *)mfx->version);
4581 mfx->version = NULL;
4583 if (mfx->installlocation) {
4584 free((void *)mfx->installlocation);
4585 mfx->installlocation = NULL;
4588 free((void *)mfx->preload);
4589 mfx->preload = NULL;
4591 if (mfx->readonly) {
4592 free((void *)mfx->readonly);
4593 mfx->readonly = NULL;
4595 if (mfx->removable) {
4596 free((void *)mfx->removable);
4597 mfx->removable = NULL;
4600 free((void *)mfx->update);
4604 free((void *)mfx->system);
4608 free((void *)mfx->type);
4611 if (mfx->package_size) {
4612 free((void *)mfx->package_size);
4613 mfx->package_size = NULL;
4615 if (mfx->installed_time) {
4616 free((void *)mfx->installed_time);
4617 mfx->installed_time = NULL;
4619 if (mfx->installed_storage) {
4620 free((void *)mfx->installed_storage);
4621 mfx->installed_storage = NULL;
4623 if (mfx->storeclient_id) {
4624 free((void *)mfx->storeclient_id);
4625 mfx->storeclient_id = NULL;
4627 if (mfx->mainapp_id) {
4628 free((void *)mfx->mainapp_id);
4629 mfx->mainapp_id = NULL;
4631 if (mfx->package_url) {
4632 free((void *)mfx->package_url);
4633 mfx->package_url = NULL;
4635 if (mfx->root_path) {
4636 free((void *)mfx->root_path);
4637 mfx->root_path = NULL;
4639 if (mfx->csc_path) {
4640 free((void *)mfx->csc_path);
4641 mfx->csc_path = NULL;
4643 if (mfx->appsetting) {
4644 free((void *)mfx->appsetting);
4645 mfx->appsetting = NULL;
4647 if (mfx->nodisplay_setting) {
4648 free((void *)mfx->nodisplay_setting);
4649 mfx->nodisplay_setting = NULL;
4654 icon_x *icon = mfx->icon;
4656 while(icon != NULL) {
4658 __ps_free_icon(icon);
4664 label_x *label = mfx->label;
4665 label_x *tmp = NULL;
4666 while(label != NULL) {
4668 __ps_free_label(label);
4674 author_x *author = mfx->author;
4675 author_x *tmp = NULL;
4676 while(author != NULL) {
4678 __ps_free_author(author);
4682 /*Free Description*/
4683 if (mfx->description) {
4684 description_x *description = mfx->description;
4685 description_x *tmp = NULL;
4686 while(description != NULL) {
4687 tmp = description->next;
4688 __ps_free_description(description);
4694 license_x *license = mfx->license;
4695 license_x *tmp = NULL;
4696 while(license != NULL) {
4697 tmp = license->next;
4698 __ps_free_license(license);
4703 if (mfx->privileges) {
4704 privileges_x *privileges = mfx->privileges;
4705 privileges_x *tmp = NULL;
4706 while(privileges != NULL) {
4707 tmp = privileges->next;
4708 __ps_free_privileges(privileges);
4712 /*Free UiApplication*/
4713 if (mfx->uiapplication) {
4714 uiapplication_x *uiapplication = mfx->uiapplication;
4715 uiapplication_x *tmp = NULL;
4716 while(uiapplication != NULL) {
4717 tmp = uiapplication->next;
4718 __ps_free_uiapplication(uiapplication);
4719 uiapplication = tmp;
4722 /*Free ServiceApplication*/
4723 if (mfx->serviceapplication) {
4724 serviceapplication_x *serviceapplication = mfx->serviceapplication;
4725 serviceapplication_x *tmp = NULL;
4726 while(serviceapplication != NULL) {
4727 tmp = serviceapplication->next;
4728 __ps_free_serviceapplication(serviceapplication);
4729 serviceapplication = tmp;
4734 daemon_x *daemon = mfx->daemon;
4735 daemon_x *tmp = NULL;
4736 while(daemon != NULL) {
4738 __ps_free_daemon(daemon);
4744 theme_x *theme = mfx->theme;
4745 theme_x *tmp = NULL;
4746 while(theme != NULL) {
4748 __ps_free_theme(theme);
4754 font_x *font = mfx->font;
4756 while(font != NULL) {
4758 __ps_free_font(font);
4764 ime_x *ime = mfx->ime;
4766 while(ime != NULL) {
4772 /*Free Compatibility*/
4773 if (mfx->compatibility) {
4774 compatibility_x *compatibility = mfx->compatibility;
4775 compatibility_x *tmp = NULL;
4776 while(compatibility != NULL) {
4777 tmp = compatibility->next;
4778 __ps_free_compatibility(compatibility);
4779 compatibility = tmp;
4782 /*Free DeviceProfile*/
4783 if (mfx->deviceprofile) {
4784 deviceprofile_x *deviceprofile = mfx->deviceprofile;
4785 deviceprofile_x *tmp = NULL;
4786 while(deviceprofile != NULL) {
4787 tmp = deviceprofile->next;
4788 __ps_free_deviceprofile(deviceprofile);
4789 deviceprofile = tmp;
4797 API manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest)
4799 DBG("parsing start\n");
4800 xmlTextReaderPtr reader;
4801 manifest_x *mfx = NULL;
4803 reader = xmlReaderForFile(manifest, NULL, 0);
4805 mfx = malloc(sizeof(manifest_x));
4807 memset(mfx, '\0', sizeof(manifest_x));
4808 if (__process_manifest(reader, mfx) < 0) {
4809 DBG("Parsing Failed\n");
4810 pkgmgr_parser_free_manifest_xml(mfx);
4813 DBG("Parsing Success\n");
4815 DBG("Memory allocation error\n");
4817 xmlFreeTextReader(reader);
4819 DBG("Unable to create xml reader\n");
4824 /* These APIs are intended to call parser directly */
4826 API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
4828 char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
4829 if (manifest == NULL) {
4830 DBG("argument supplied is NULL\n");
4831 return PMINFO_R_EINVAL;
4833 DBG("parsing manifest for installation: %s\n", manifest);
4834 manifest_x *mfx = NULL;
4836 char roxml_check[PKG_STRING_LEN_MAX] = {'\0'};
4839 mfx = pkgmgr_parser_process_manifest_xml(manifest);
4840 DBG("Parsing Finished\n");
4842 return PMINFO_R_ERROR;
4844 __streamFile(manifest, ACTION_INSTALL, temp, mfx->package);
4845 __add_preload_info(mfx, manifest);
4846 DBG("Added preload infomation\n");
4848 __ps_process_tag(mfx, tagv);
4850 ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
4852 DBG("DB Insert failed\n");
4854 DBG("DB Insert Success\n");
4856 ret = __ps_process_mdparser(mfx, ACTION_INSTALL);
4858 DBG("Creating metadata parser failed\n");
4860 ret = __ps_process_category_parser(mfx, ACTION_INSTALL);
4862 DBG("Creating category parser failed\n");
4864 ret = __ps_make_nativeapp_desktop(mfx, NULL, 0);
4866 DBG("Creating desktop file failed\n");
4868 DBG("Creating desktop file Success\n");
4870 pkgmgr_parser_free_manifest_xml(mfx);
4877 API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
4879 char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
4880 if (manifest == NULL) {
4881 DBG("argument supplied is NULL\n");
4882 return PMINFO_R_EINVAL;
4884 DBG("parsing manifest for upgradation: %s\n", manifest);
4885 manifest_x *mfx = NULL;
4887 bool preload = false;
4888 bool system = false;
4889 char *csc_path = NULL;
4890 pkgmgrinfo_pkginfo_h handle = NULL;
4893 mfx = pkgmgr_parser_process_manifest_xml(manifest);
4894 DBG("Parsing Finished\n");
4896 return PMINFO_R_ERROR;
4898 __streamFile(manifest, ACTION_UPGRADE, temp, mfx->package);
4899 __add_preload_info(mfx, manifest);
4900 DBG("Added preload infomation\n");
4901 __check_preload_updated(mfx, manifest);
4903 ret = pkgmgrinfo_pkginfo_get_pkginfo(mfx->package, &handle);
4904 if (ret != PMINFO_R_OK)
4905 DBG("pkgmgrinfo_pkginfo_get_pkginfo failed\n");
4907 ret = pkgmgrinfo_pkginfo_is_preload(handle, &preload);
4908 if (ret != PMINFO_R_OK)
4909 DBG("pkgmgrinfo_pkginfo_is_preload failed\n");
4912 free((void *)mfx->preload);
4913 mfx->preload = strdup("true");
4916 ret = pkgmgrinfo_pkginfo_is_system(handle, &system);
4917 if (ret != PMINFO_R_OK)
4918 DBG("pkgmgrinfo_pkginfo_is_system failed\n");
4921 free((void *)mfx->system);
4922 mfx->system = strdup("true");
4925 ret = pkgmgrinfo_pkginfo_get_csc_path(handle, &csc_path);
4926 if (ret != PMINFO_R_OK)
4927 DBG("pkgmgrinfo_pkginfo_get_csc_path failed\n");
4929 if (csc_path != NULL) {
4931 free((void *)mfx->csc_path);
4932 mfx->csc_path = strdup(csc_path);
4935 ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
4937 DBG("DB Update failed\n");
4939 DBG("DB Update Success\n");
4941 ret = __ps_process_mdparser(mfx, ACTION_UPGRADE);
4943 DBG("Upgrade metadata parser failed\n");
4945 ret = __ps_process_category_parser(mfx, ACTION_UPGRADE);
4947 DBG("Creating category parser failed\n");
4949 ret = __ps_make_nativeapp_desktop(mfx, manifest, 1);
4951 DBG("Creating desktop file failed\n");
4953 DBG("Creating desktop file Success\n");
4955 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
4956 pkgmgr_parser_free_manifest_xml(mfx);
4963 API int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[])
4965 char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
4966 if (manifest == NULL) {
4967 DBG("argument supplied is NULL\n");
4968 return PMINFO_R_EINVAL;
4970 DBG("parsing manifest for uninstallation: %s\n", manifest);
4971 manifest_x *mfx = NULL;
4974 mfx = pkgmgr_parser_process_manifest_xml(manifest);
4975 DBG("Parsing Finished\n");
4977 return PMINFO_R_ERROR;
4979 __streamFile(manifest, ACTION_UNINSTALL, temp, mfx->package);
4980 __add_preload_info(mfx, manifest);
4981 DBG("Added preload infomation\n");
4983 ret = __ps_process_mdparser(mfx, ACTION_UNINSTALL);
4985 DBG("Removing metadata parser failed\n");
4987 ret = __ps_process_category_parser(mfx, ACTION_UNINSTALL);
4989 DBG("Creating category parser failed\n");
4991 ret = pkgmgr_parser_delete_manifest_info_from_db(mfx);
4993 DBG("DB Delete failed\n");
4995 DBG("DB Delete Success\n");
4997 ret = __ps_remove_nativeapp_desktop(mfx);
4999 DBG("Removing desktop file failed\n");
5001 DBG("Removing desktop file Success\n");
5003 ret = __ps_remove_appsvc_db(mfx);
5005 DBG("Removing appsvc_db failed\n");
5007 DBG("Removing appsvc_db Success\n");
5009 pkgmgr_parser_free_manifest_xml(mfx);
5016 API int pkgmgr_parser_parse_manifest_for_preload()
5018 return pkgmgr_parser_update_preload_info_in_db();
5021 API char *pkgmgr_parser_get_manifest_file(const char *pkgid)
5023 return __pkgid_to_manifest(pkgid);
5026 API int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
5028 return __ps_run_parser(docPtr, tag, ACTION_INSTALL, pkgid);
5031 API int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgid)
5033 return __ps_run_parser(docPtr, tag, ACTION_UPGRADE, pkgid);
5036 API int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
5038 return __ps_run_parser(docPtr, tag, ACTION_UNINSTALL, pkgid);
5041 #define SCHEMA_FILE "/usr/etc/package-manager/preload/manifest.xsd"
5043 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
5045 if (manifest == NULL) {
5046 DBGE("manifest file is NULL\n");
5047 return PMINFO_R_EINVAL;
5050 xmlSchemaParserCtxtPtr ctx;
5051 xmlSchemaValidCtxtPtr vctx;
5052 xmlSchemaPtr xschema;
5053 ctx = xmlSchemaNewParserCtxt(SCHEMA_FILE);
5055 DBGE("xmlSchemaNewParserCtxt() Failed\n");
5056 return PMINFO_R_ERROR;
5058 xschema = xmlSchemaParse(ctx);
5059 if (xschema == NULL) {
5060 DBGE("xmlSchemaParse() Failed\n");
5061 return PMINFO_R_ERROR;
5063 vctx = xmlSchemaNewValidCtxt(xschema);
5065 DBGE("xmlSchemaNewValidCtxt() Failed\n");
5066 return PMINFO_R_ERROR;
5068 xmlSchemaSetValidErrors(vctx, (xmlSchemaValidityErrorFunc) fprintf, (xmlSchemaValidityWarningFunc) fprintf, stderr);
5069 ret = xmlSchemaValidateFile(vctx, manifest, 0);
5071 DBGE("xmlSchemaValidateFile() failed\n");
5072 return PMINFO_R_ERROR;
5073 } else if (ret == 0) {
5074 DBGE("Manifest is Valid\n");
5077 DBGE("Manifest Validation Failed with error code %d\n", ret);
5078 return PMINFO_R_ERROR;
5084 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
5094 DBGE("fork failed\n");
5099 int dev_null_fd = open ("/dev/null", O_RDWR);
5100 if (dev_null_fd >= 0)
5102 dup2 (dev_null_fd, 0);/*stdin*/
5103 dup2 (dev_null_fd, 1);/*stdout*/
5104 dup2 (dev_null_fd, 2);/*stderr*/
5107 if (execl("/usr/bin/xmllint", "xmllint", manifest, "--schema",
5108 SCHEMA_FILE, NULL) < 0) {
5109 DBGE("execl error\n");
5119 while ((err = waitpid(pid, &status, WNOHANG)) != pid) {
5123 DBGE("waitpid failed\n");
5129 if(WIFEXITED(status) && !WEXITSTATUS(status))