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 PKG_TAG_LEN_MAX 128
60 /* plugin process_type */
62 PLUGIN_PRE_PROCESS = 0,
64 } PLUGIN_PROCESS_TYPE;
73 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label);
74 static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege);
75 static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privileges);
76 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile);
77 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed);
78 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation);
79 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri);
80 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime);
81 static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp);
82 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition);
83 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notifiation);
84 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category);
85 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata);
86 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission);
87 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility);
88 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution);
89 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request);
90 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define);
91 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc);
92 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions);
93 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare);
94 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon);
95 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author);
96 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description);
97 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability);
98 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license);
99 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol);
100 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol);
101 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication);
102 static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication);
103 static int __ps_process_font(xmlTextReaderPtr reader, font_x *font);
104 static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme);
105 static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon);
106 static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime);
107 static void __ps_free_label(label_x *label);
108 static void __ps_free_privilege(privilege_x *privilege);
109 static void __ps_free_privileges(privileges_x *privileges);
110 static void __ps_free_deviceprofile(deviceprofile_x * deviceprofile);
111 static void __ps_free_allowed(allowed_x *allowed);
112 static void __ps_free_operation(operation_x *operation);
113 static void __ps_free_uri(uri_x *uri);
114 static void __ps_free_mime(mime_x *mime);
115 static void __ps_free_subapp(subapp_x *subapp);
116 static void __ps_free_condition(condition_x *condition);
117 static void __ps_free_notification(notification_x *notifiation);
118 static void __ps_free_category(category_x *category);
119 static void __ps_free_metadata(metadata_x *metadata);
120 static void __ps_free_permission(permission_x *permission);
121 static void __ps_free_compatibility(compatibility_x *compatibility);
122 static void __ps_free_resolution(resolution_x *resolution);
123 static void __ps_free_request(request_x *request);
124 static void __ps_free_define(define_x *define);
125 static void __ps_free_appsvc(appsvc_x *appsvc);
126 static void __ps_free_launchconditions(launchconditions_x *launchconditions);
127 static void __ps_free_datashare(datashare_x *datashare);
128 static void __ps_free_icon(icon_x *icon);
129 static void __ps_free_author(author_x *author);
130 static void __ps_free_description(description_x *description);
131 static void __ps_free_capability(capability_x *capability);
132 static void __ps_free_license(license_x *license);
133 static void __ps_free_appcontrol(appcontrol_x *appcontrol);
134 static void __ps_free_datacontrol(datacontrol_x *datacontrol);
135 static void __ps_free_uiapplication(uiapplication_x *uiapplication);
136 static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication);
137 static void __ps_free_font(font_x *font);
138 static void __ps_free_theme(theme_x *theme);
139 static void __ps_free_daemon(daemon_x *daemon);
140 static void __ps_free_ime(ime_x *ime);
141 static char *__pkgid_to_manifest(const char *pkgid);
142 static int __next_child_element(xmlTextReaderPtr reader, int depth);
143 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx);
144 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx);
145 static void __str_trim(char *input);
146 static char *__get_parser_plugin(const char *type);
147 static int __ps_run_parser(xmlDocPtr docPtr, const char *tag, ACTION_TYPE action, const char *pkgid);
148 static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid);
149 static void __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgid);
150 static void __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid);
151 static int __validate_appid(const char *pkgid, const char *appid, char **newappid);
153 static void __str_trim(char *input)
155 char *trim_str = input;
160 while (*input != 0) {
161 if (!isspace(*input)) {
172 static int __validate_appid(const char *pkgid, const char *appid, char **newappid)
174 if (!pkgid || !appid || !newappid) {
175 DBG("Arg supplied is NULL\n");
178 int pkglen = strlen(pkgid);
179 int applen = strlen(appid);
183 if (strncmp(appid, ".", 1) == 0) {
184 len = pkglen + applen + 1;
185 newapp = calloc(1,len);
186 if (newapp == NULL) {
187 DBG("Malloc failed\n");
190 strncpy(newapp, pkgid, pkglen);
191 strncat(newapp, appid, applen);
192 DBG("new appid is %s\n", newapp);
196 if (applen < pkglen) {
197 DBG("app id is not proper\n");
199 #ifdef _VALIDATE_APPID_
205 if (!strcmp(appid, pkgid)) {
206 DBG("appid is proper\n");
210 else if (strncmp(appid, pkgid, pkglen) == 0) {
211 ptr = strstr(appid, pkgid);
213 if (strncmp(ptr, ".", 1) == 0) {
214 DBG("appid is proper\n");
219 DBG("appid is not proper\n");
221 #ifdef _VALIDATE_APPID_
228 DBG("appid is not proper\n");
230 #ifdef _VALIDATE_APPID_
239 static char * __get_tag_by_key(char *md_key)
243 if (md_key == NULL) {
244 DBG("md_key is NULL\n");
248 md_tag = strrchr(md_key, 47) + 1;
251 return strdup(md_tag);
254 static char *__get_mdparser_plugin(const char *type)
257 char buffer[1024] = { 0 };
258 char temp_path[1024] = { 0 };
262 DBGE("invalid argument\n");
266 fp = fopen(PKG_PARSER_CONF_PATH, "r");
268 DBGE("no matching mdparser\n");
272 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
273 if (buffer[0] == '#')
278 if ((path = strstr(buffer, MDPARSER_NAME)) != NULL) {
279 path = path + strlen(MDPARSER_NAME);
284 memset(buffer, 0x00, 1024);
291 DBGE("no matching backendlib\n");
295 snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
297 return strdup(temp_path);
300 static char *__get_parser_plugin(const char *type)
303 char buffer[1024] = { 0 };
304 char temp_path[1024] = { 0 };
308 DBGE("invalid argument\n");
312 fp = fopen(PKG_PARSER_CONF_PATH, "r");
314 DBGE("no matching backendlib\n");
318 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
319 if (buffer[0] == '#')
324 if ((path = strstr(buffer, PKG_PARSERLIB)) != NULL) {
325 path = path + strlen(PKG_PARSERLIB);
329 memset(buffer, 0x00, 1024);
336 DBGE("no matching backendlib\n");
340 snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
341 DBG("[%s]\n", temp_path);
343 return strdup(temp_path);
346 static int __ps_run_mdparser(GList *md_list, const char *tag,
347 ACTION_TYPE action, const char *pkgid, const char *appid)
349 char *lib_path = NULL;
350 void *lib_handle = NULL;
351 int (*mdparser_plugin) (const char *, const char *, GList *);
357 ac = "PKGMGR_MDPARSER_PLUGIN_INSTALL";
360 ac = "PKGMGR_MDPARSER_PLUGIN_UPGRADE";
362 case ACTION_UNINSTALL:
363 ac = "PKGMGR_MDPARSER_PLUGIN_UNINSTALL";
369 lib_path = __get_mdparser_plugin(tag);
371 DBGE("__get_mdparser_plugin fail\n");
375 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
376 DBGE("dlopen is failed lib_path[%s]\n", lib_path);
380 if ((mdparser_plugin =
381 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
382 DBGE("can not find symbol[%s] \n",ac);
386 ret = mdparser_plugin(pkgid, appid, md_list);
388 DBG("[appid = %s, libpath = %s plugin fail\n", appid, lib_path);
390 DBG("[appid = %s, libpath = %s plugin success\n", appid, lib_path);
400 static int __ps_run_parser(xmlDocPtr docPtr, const char *tag,
401 ACTION_TYPE action, const char *pkgid)
403 char *lib_path = NULL;
404 void *lib_handle = NULL;
405 int (*plugin_install) (xmlDocPtr, const char *);
411 ac = "PKGMGR_PARSER_PLUGIN_INSTALL";
414 ac = "PKGMGR_PARSER_PLUGIN_UPGRADE";
416 case ACTION_UNINSTALL:
417 ac = "PKGMGR_PARSER_PLUGIN_UNINSTALL";
423 lib_path = __get_parser_plugin(tag);
428 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
429 DBGE("dlopen is failed lib_path[%s]\n", lib_path);
432 if ((plugin_install =
433 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
434 DBGE("can not find symbol[%s] \n", ac);
438 ret = plugin_install(docPtr, pkgid);
440 DBG("[pkgid = %s, libpath = %s plugin fail\n", pkgid, lib_path);
442 DBG("[pkgid = %s, libpath = %s plugin success\n", pkgid, lib_path);
452 static char *__pkgid_to_manifest(const char *pkgid)
458 DBGE("pkgid is NULL");
462 size = strlen(MANIFEST_RW_DIRECTORY) + strlen(pkgid) + 10;
463 manifest = malloc(size);
464 if (manifest == NULL) {
468 memset(manifest, '\0', size);
469 snprintf(manifest, size, MANIFEST_RW_DIRECTORY "/%s.xml", pkgid);
471 if (access(manifest, F_OK)) {
472 snprintf(manifest, size, MANIFEST_RO_DIRECTORY "/%s.xml", pkgid);
478 static void __mdparser_clear_dir_list(GList* dir_list)
481 __metadata_t* detail = NULL;
484 list = g_list_first(dir_list);
486 detail = (__metadata_t *)list->data;
494 list = g_list_next(list);
496 g_list_free(dir_list);
500 static int __run_mdparser_prestep (manifest_x *mfx, char *md_key, ACTION_TYPE action)
504 char buffer[1024] = { 0, };
505 uiapplication_x *up = mfx->uiapplication;
506 metadata_x *md = NULL;
509 GList *md_list = NULL;
510 __metadata_t *md_detail = NULL;
512 md_tag = __get_tag_by_key(md_key);
513 if (md_tag == NULL) {
514 DBG("md_tag is NULL\n");
517 DBG("md_tag = %s\n", md_tag);
524 //get glist of meatdata key and value combination
525 memset(buffer, 0x00, 1024);
526 snprintf(buffer, 1024, "%s/", md_key);
527 if ((md->key && md->value) && (strncmp(md->key, md_key, strlen(md_key)) == 0) && (strncmp(buffer, md->key, strlen(buffer)) == 0)) {
528 md_detail = (__metadata_t*) calloc(1, sizeof(__metadata_t));
529 if (md_detail == NULL) {
530 DBG("Memory allocation failed\n");
534 md_detail->key = (char*) calloc(1, sizeof(char)*(strlen(md->key)+2));
535 if (md_detail->key == NULL) {
536 DBG("Memory allocation failed\n");
540 snprintf(md_detail->key, (strlen(md->key)+1), "%s", md->key);
542 md_detail->value = (char*) calloc(1, sizeof(char)*(strlen(md->value)+2));
543 if (md_detail->value == NULL) {
544 DBG("Memory allocation failed\n");
545 free(md_detail->key);
549 snprintf(md_detail->value, (strlen(md->value)+1), "%s", md->value);
551 md_list = g_list_append(md_list, (gpointer)md_detail);
557 //send glist to parser when tags for metadata plugin parser exist.
559 ret = __ps_run_mdparser(md_list, md_tag, action, mfx->package, up->appid);
561 DBG("mdparser failed[%d]\n", ret);
563 DBG("mdparser success, done[%d]\n", ret);
565 __mdparser_clear_dir_list(md_list);
573 __mdparser_clear_dir_list(md_list);
581 static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid)
586 DBG("__run_parser_prestep");
588 if (xmlTextReaderDepth(reader) != 1) {
589 DBGE("Node depth is not 1");
593 if (xmlTextReaderNodeType(reader) != 1) {
594 DBGE("Node type is not 1");
598 const xmlChar *value;
599 name = xmlTextReaderConstName(reader);
601 DBGE("TEST TEST TES\n");
602 name = BAD_CAST "--";
605 value = xmlTextReaderConstValue(reader);
606 DBG("%d %d %s %d %d",
607 xmlTextReaderDepth(reader),
608 xmlTextReaderNodeType(reader),
610 xmlTextReaderIsEmptyElement(reader), xmlTextReaderHasValue(reader));
613 DBG("ConstValue NULL");
615 if (xmlStrlen(value) > 40) {
616 DBG(" %.40s...", value);
622 name = xmlTextReaderConstName(reader);
624 DBGE("TEST TEST TES\n");
625 name = BAD_CAST "--";
628 xmlDocPtr docPtr = xmlTextReaderCurrentDoc(reader);
629 DBG("docPtr->URL %s\n", (char *)docPtr->URL);
630 xmlDocPtr copyDocPtr = xmlCopyDoc(docPtr, 1);
631 if (copyDocPtr == NULL)
633 xmlNode *rootElement = xmlDocGetRootElement(copyDocPtr);
634 if (rootElement == NULL)
636 xmlNode *cur_node = xmlFirstElementChild(rootElement);
637 if (cur_node == NULL)
639 xmlNode *temp = xmlTextReaderExpand(reader);
642 xmlNode *next_node = NULL;
643 while(cur_node != NULL) {
644 if ( (strcmp(ASCII(temp->name), ASCII(cur_node->name)) == 0) &&
645 (temp->line == cur_node->line) ) {
649 next_node = xmlNextElementSibling(cur_node);
650 xmlUnlinkNode(cur_node);
651 xmlFreeNode(cur_node);
652 cur_node = next_node;
655 if (cur_node == NULL)
657 next_node = xmlNextElementSibling(cur_node);
659 cur_node->next = NULL;
660 next_node->prev = NULL;
661 xmlFreeNodeList(next_node);
662 xmlSetTreeDoc(cur_node, copyDocPtr);
664 xmlSetTreeDoc(cur_node, copyDocPtr);
670 DBG("node type: %d, name: %s children->name: %s last->name: %s\n"
671 "parent->name: %s next->name: %s prev->name: %s\n",
672 cur_node->type, cur_node->name,
673 cur_node->children ? cur_node->children->name : "NULL",
674 cur_node->last ? cur_node->last->name : "NULL",
675 cur_node->parent ? cur_node->parent->name : "NULL",
676 cur_node->next ? cur_node->next->name : "NULL",
677 cur_node->prev ? cur_node->prev->name : "NULL");
679 FILE *fp = fopen("/opt/share/test.xml", "a");
680 xmlDocDump(fp, copyDocPtr);
685 ret = __ps_run_parser(copyDocPtr, ASCII(name), action, pkgid);
692 __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgid)
697 switch (xmlTextReaderNodeType(reader)) {
698 case XML_READER_TYPE_END_ELEMENT:
700 // DBG("XML_READER_TYPE_END_ELEMENT");
704 case XML_READER_TYPE_ELEMENT:
706 // Elements without closing tag don't receive
707 // XML_READER_TYPE_END_ELEMENT event.
709 const xmlChar *elementName =
710 xmlTextReaderLocalName(reader);
711 if (elementName == NULL) {
712 // DBG("elementName %s\n", (char *)elementName);
716 const xmlChar *nameSpace =
717 xmlTextReaderConstNamespaceUri(reader);
719 // DBG("nameSpace %s\n", (char *)nameSpace);
722 DBG("XML_READER_TYPE_ELEMENT %s, %s\n",
723 elementName ? elementName : "NULL",
724 nameSpace ? nameSpace : "NULL");
727 DBG("__run_parser_prestep pkgid[%s]\n", pkgid);
728 __run_parser_prestep(reader, action, pkgid);
732 for (tag = tagv[0]; tag; tag = tagv[++i])
733 if (strcmp(tag, ASCII(elementName)) == 0) {
734 DBG("__run_parser_prestep tag[%s] pkgid[%s]\n", tag, pkgid);
735 __run_parser_prestep(reader,
743 case XML_READER_TYPE_TEXT:
744 case XML_READER_TYPE_CDATA:
746 const xmlChar *value = xmlTextReaderConstValue(reader);
748 // DBG("value %s\n", value);
751 const xmlChar *lang = xmlTextReaderConstXmlLang(reader);
753 // DBG("lang\n", lang);
756 /* DBG("XML_READER_TYPE_TEXT %s, %s\n",
757 value ? value : "NULL", lang ? lang : "NULL");
762 // DBG("Ignoring Node of Type: %d", xmlTextReaderNodeType(reader));
767 static void __plugin_send_tag(const char *tag, ACTION_TYPE action, PLUGIN_PROCESS_TYPE process, const char *pkgid)
769 char *lib_path = NULL;
770 void *lib_handle = NULL;
771 int (*plugin_install) (const char *);
775 if (process == PLUGIN_PRE_PROCESS) {
778 ac = "PKGMGR_PARSER_PLUGIN_PRE_INSTALL";
781 ac = "PKGMGR_PARSER_PLUGIN_PRE_UPGRADE";
783 case ACTION_UNINSTALL:
784 ac = "PKGMGR_PARSER_PLUGIN_PRE_UNINSTALL";
789 } else if (process == PLUGIN_POST_PROCESS) {
792 ac = "PKGMGR_PARSER_PLUGIN_POST_INSTALL";
795 ac = "PKGMGR_PARSER_PLUGIN_POST_UPGRADE";
797 case ACTION_UNINSTALL:
798 ac = "PKGMGR_PARSER_PLUGIN_POST_UNINSTALL";
806 lib_path = __get_parser_plugin(tag);
811 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
812 DBGE("dlopen is failed lib_path[%s]\n", lib_path);
815 if ((plugin_install =
816 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
817 DBGE("can not find symbol[%s] \n", ac);
821 ret = plugin_install(pkgid);
823 DBG("[PLUGIN_PROCESS_TYPE[%d] pkgid=%s, tag=%s plugin fail\n", process, pkgid, tag);
825 DBG("[PLUGIN_PROCESS_TYPE[%d] pkgid=%s, tag=%s plugin success\n", process, pkgid, tag);
835 __plugin_process_tag(char *const tag_list[], ACTION_TYPE action, PLUGIN_PROCESS_TYPE process, const char *pkgid)
840 for (tag = tag_list[0]; tag; tag = tag_list[++i])
841 __plugin_send_tag(tag, action, process, pkgid);
846 __plugin_save_tag(xmlTextReaderPtr reader, char *const tagv[], char *tag_list[])
850 static int pre_cnt=0;
852 switch (xmlTextReaderNodeType(reader)) {
853 case XML_READER_TYPE_ELEMENT:
855 const xmlChar *elementName = xmlTextReaderLocalName(reader);
856 if (elementName == NULL) {
860 for (tag = tag_list[0]; tag; tag = tag_list[++i])
861 if (strcmp(ASCII(elementName), tag) == 0) {
865 for (tag = tagv[0]; tag; tag = tagv[++i])
866 if (strcmp(tag, ASCII(elementName)) == 0) {
867 tag_list[pre_cnt++] = tag;
873 // DBG("Ignoring Node of Type: %d", xmlTextReaderNodeType(reader));
879 __plugin_find_tag(const char *filename, char *const tagv[], char *tag_list[])
881 xmlTextReaderPtr reader;
885 docPtr = xmlReadFile(filename, NULL, 0);
886 reader = xmlReaderWalker(docPtr);
887 if (reader != NULL) {
888 ret = xmlTextReaderRead(reader);
890 __plugin_save_tag(reader, tagv, tag_list);
891 ret = xmlTextReaderRead(reader);
893 xmlFreeTextReader(reader);
896 DBG("xmlReaderWalker fail");
899 DBG("xmlReaderWalker fail");
904 __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid)
906 xmlTextReaderPtr reader;
909 char *tag_list[PKG_TAG_LEN_MAX] = {'\0'};
911 __plugin_find_tag(filename, tagv, tag_list);
912 __plugin_process_tag(tag_list, action, PLUGIN_PRE_PROCESS, pkgid);
914 docPtr = xmlReadFile(filename, NULL, 0);
915 reader = xmlReaderWalker(docPtr);
916 if (reader != NULL) {
917 ret = xmlTextReaderRead(reader);
919 __processNode(reader, action, tagv, pkgid);
920 ret = xmlTextReaderRead(reader);
922 xmlFreeTextReader(reader);
925 DBGE("%s : failed to parse", filename);
928 DBGE("Unable to open %s", filename);
931 __plugin_process_tag(tag_list, action, PLUGIN_POST_PROCESS, pkgid);
934 static int __next_child_element(xmlTextReaderPtr reader, int depth)
936 int ret = xmlTextReaderRead(reader);
937 int cur = xmlTextReaderDepth(reader);
940 switch (xmlTextReaderNodeType(reader)) {
941 case XML_READER_TYPE_ELEMENT:
942 if (cur == depth + 1)
945 case XML_READER_TYPE_TEXT:
946 /*text is handled by each function separately*/
947 if (cur == depth + 1)
950 case XML_READER_TYPE_END_ELEMENT:
959 ret = xmlTextReaderRead(reader);
960 cur = xmlTextReaderDepth(reader);
965 static void __ps_free_category(category_x *category)
967 if (category == NULL)
969 if (category->name) {
970 free((void *)category->name);
971 category->name = NULL;
973 free((void*)category);
977 static void __ps_free_privilege(privilege_x *privilege)
979 if (privilege == NULL)
981 if (privilege->text) {
982 free((void *)privilege->text);
983 privilege->text = NULL;
985 free((void*)privilege);
989 static void __ps_free_privileges(privileges_x *privileges)
991 if (privileges == NULL)
994 if (privileges->privilege) {
995 privilege_x *privilege = privileges->privilege;
996 privilege_x *tmp = NULL;
997 while(privilege != NULL) {
998 tmp = privilege->next;
999 __ps_free_privilege(privilege);
1003 free((void*)privileges);
1007 static void __ps_free_metadata(metadata_x *metadata)
1009 if (metadata == NULL)
1011 if (metadata->key) {
1012 free((void *)metadata->key);
1013 metadata->key = NULL;
1015 if (metadata->value) {
1016 free((void *)metadata->value);
1017 metadata->value = NULL;
1019 free((void*)metadata);
1023 static void __ps_free_permission(permission_x *permission)
1025 if (permission == NULL)
1027 if (permission->type) {
1028 free((void *)permission->type);
1029 permission->type = NULL;
1031 if (permission->value) {
1032 free((void *)permission->value);
1033 permission->value = NULL;
1035 free((void*)permission);
1039 static void __ps_free_icon(icon_x *icon)
1044 free((void *)icon->text);
1048 free((void *)icon->lang);
1052 free((void *)icon->name);
1055 if (icon->section) {
1056 free((void *)icon->section);
1057 icon->section = NULL;
1060 free((void *)icon->size);
1063 if (icon->resolution) {
1064 free((void *)icon->resolution);
1065 icon->resolution = NULL;
1071 static void __ps_free_image(image_x *image)
1076 free((void *)image->text);
1080 free((void *)image->lang);
1084 free((void *)image->name);
1087 if (image->section) {
1088 free((void *)image->section);
1089 image->section = NULL;
1095 static void __ps_free_operation(operation_x *operation)
1097 if (operation == NULL)
1099 if (operation->text) {
1100 free((void *)operation->text);
1101 operation->text = NULL;
1103 free((void*)operation);
1107 static void __ps_free_uri(uri_x *uri)
1112 free((void *)uri->text);
1119 static void __ps_free_mime(mime_x *mime)
1124 free((void *)mime->text);
1131 static void __ps_free_subapp(subapp_x *subapp)
1136 free((void *)subapp->text);
1137 subapp->text = NULL;
1139 free((void*)subapp);
1143 static void __ps_free_condition(condition_x *condition)
1145 if (condition == NULL)
1147 if (condition->text) {
1148 free((void *)condition->text);
1149 condition->text = NULL;
1151 if (condition->name) {
1152 free((void *)condition->name);
1153 condition->name = NULL;
1155 free((void*)condition);
1159 static void __ps_free_notification(notification_x *notification)
1161 if (notification == NULL)
1163 if (notification->text) {
1164 free((void *)notification->text);
1165 notification->text = NULL;
1167 if (notification->name) {
1168 free((void *)notification->name);
1169 notification->name = NULL;
1171 free((void*)notification);
1172 notification = NULL;
1175 static void __ps_free_compatibility(compatibility_x *compatibility)
1177 if (compatibility == NULL)
1179 if (compatibility->text) {
1180 free((void *)compatibility->text);
1181 compatibility->text = NULL;
1183 if (compatibility->name) {
1184 free((void *)compatibility->name);
1185 compatibility->name = NULL;
1187 free((void*)compatibility);
1188 compatibility = NULL;
1191 static void __ps_free_resolution(resolution_x *resolution)
1193 if (resolution == NULL)
1195 if (resolution->mimetype) {
1196 free((void *)resolution->mimetype);
1197 resolution->mimetype = NULL;
1199 if (resolution->urischeme) {
1200 free((void *)resolution->urischeme);
1201 resolution->urischeme = NULL;
1203 free((void*)resolution);
1207 static void __ps_free_capability(capability_x *capability)
1209 if (capability == NULL)
1211 if (capability->operationid) {
1212 free((void *)capability->operationid);
1213 capability->operationid = NULL;
1216 if (capability->resolution) {
1217 resolution_x *resolution = capability->resolution;
1218 resolution_x *tmp = NULL;
1219 while(resolution != NULL) {
1220 tmp = resolution->next;
1221 __ps_free_resolution(resolution);
1225 free((void*)capability);
1229 static void __ps_free_allowed(allowed_x *allowed)
1231 if (allowed == NULL)
1233 if (allowed->name) {
1234 free((void *)allowed->name);
1235 allowed->name = NULL;
1237 if (allowed->text) {
1238 free((void *)allowed->text);
1239 allowed->text = NULL;
1241 free((void*)allowed);
1245 static void __ps_free_request(request_x *request)
1247 if (request == NULL)
1249 if (request->text) {
1250 free((void *)request->text);
1251 request->text = NULL;
1253 free((void*)request);
1257 static void __ps_free_datacontrol(datacontrol_x *datacontrol)
1259 if (datacontrol == NULL)
1261 if (datacontrol->providerid) {
1262 free((void *)datacontrol->providerid);
1263 datacontrol->providerid = NULL;
1266 if (datacontrol->capability) {
1267 capability_x *capability = datacontrol->capability;
1268 capability_x *tmp = NULL;
1269 while(capability != NULL) {
1270 tmp = capability->next;
1271 __ps_free_capability(capability);
1275 free((void*)datacontrol);
1279 static void __ps_free_launchconditions(launchconditions_x *launchconditions)
1281 if (launchconditions == NULL)
1283 if (launchconditions->text) {
1284 free((void *)launchconditions->text);
1285 launchconditions->text = NULL;
1288 if (launchconditions->condition) {
1289 condition_x *condition = launchconditions->condition;
1290 condition_x *tmp = NULL;
1291 while(condition != NULL) {
1292 tmp = condition->next;
1293 __ps_free_condition(condition);
1297 free((void*)launchconditions);
1298 launchconditions = NULL;
1301 static void __ps_free_appcontrol(appcontrol_x *appcontrol)
1303 if (appcontrol == NULL)
1305 if (appcontrol->text) {
1306 free((void *)appcontrol->text);
1307 appcontrol->text = NULL;
1310 if (appcontrol->operation) {
1311 operation_x *operation = appcontrol->operation;
1312 operation_x *tmp = NULL;
1313 while(operation != NULL) {
1314 tmp = operation->next;
1315 __ps_free_operation(operation);
1320 if (appcontrol->uri) {
1321 uri_x *uri = appcontrol->uri;
1323 while(uri != NULL) {
1330 if (appcontrol->mime) {
1331 mime_x *mime = appcontrol->mime;
1333 while(mime != NULL) {
1335 __ps_free_mime(mime);
1340 if (appcontrol->subapp) {
1341 subapp_x *subapp = appcontrol->subapp;
1342 subapp_x *tmp = NULL;
1343 while(subapp != NULL) {
1345 __ps_free_subapp(subapp);
1349 free((void*)appcontrol);
1353 static void __ps_free_appsvc(appsvc_x *appsvc)
1358 free((void *)appsvc->text);
1359 appsvc->text = NULL;
1362 if (appsvc->operation) {
1363 operation_x *operation = appsvc->operation;
1364 operation_x *tmp = NULL;
1365 while(operation != NULL) {
1366 tmp = operation->next;
1367 __ps_free_operation(operation);
1373 uri_x *uri = appsvc->uri;
1375 while(uri != NULL) {
1383 mime_x *mime = appsvc->mime;
1385 while(mime != NULL) {
1387 __ps_free_mime(mime);
1392 if (appsvc->subapp) {
1393 subapp_x *subapp = appsvc->subapp;
1394 subapp_x *tmp = NULL;
1395 while(subapp != NULL) {
1397 __ps_free_subapp(subapp);
1401 free((void*)appsvc);
1405 static void __ps_free_deviceprofile(deviceprofile_x *deviceprofile)
1410 static void __ps_free_define(define_x *define)
1415 free((void *)define->path);
1416 define->path = NULL;
1419 if (define->request) {
1420 request_x *request = define->request;
1421 request_x *tmp = NULL;
1422 while(request != NULL) {
1423 tmp = request->next;
1424 __ps_free_request(request);
1429 if (define->allowed) {
1430 allowed_x *allowed = define->allowed;
1431 allowed_x *tmp = NULL;
1432 while(allowed != NULL) {
1433 tmp = allowed->next;
1434 __ps_free_allowed(allowed);
1438 free((void*)define);
1442 static void __ps_free_datashare(datashare_x *datashare)
1444 if (datashare == NULL)
1447 if (datashare->define) {
1448 define_x *define = datashare->define;
1449 define_x *tmp = NULL;
1450 while(define != NULL) {
1452 __ps_free_define(define);
1457 if (datashare->request) {
1458 request_x *request = datashare->request;
1459 request_x *tmp = NULL;
1460 while(request != NULL) {
1461 tmp = request->next;
1462 __ps_free_request(request);
1466 free((void*)datashare);
1470 static void __ps_free_label(label_x *label)
1475 free((void *)label->name);
1479 free((void *)label->text);
1483 free((void *)label->lang);
1490 static void __ps_free_author(author_x *author)
1494 if (author->email) {
1495 free((void *)author->email);
1496 author->email = NULL;
1499 free((void *)author->text);
1500 author->text = NULL;
1503 free((void *)author->href);
1504 author->href = NULL;
1507 free((void *)author->lang);
1508 author->lang = NULL;
1510 free((void*)author);
1514 static void __ps_free_description(description_x *description)
1516 if (description == NULL)
1518 if (description->name) {
1519 free((void *)description->name);
1520 description->name = NULL;
1522 if (description->text) {
1523 free((void *)description->text);
1524 description->text = NULL;
1526 if (description->lang) {
1527 free((void *)description->lang);
1528 description->lang = NULL;
1530 free((void*)description);
1534 static void __ps_free_license(license_x *license)
1536 if (license == NULL)
1538 if (license->text) {
1539 free((void *)license->text);
1540 license->text = NULL;
1542 if (license->lang) {
1543 free((void *)license->lang);
1544 license->lang = NULL;
1546 free((void*)license);
1550 static void __ps_free_uiapplication(uiapplication_x *uiapplication)
1552 if (uiapplication == NULL)
1554 if (uiapplication->exec) {
1555 free((void *)uiapplication->exec);
1556 uiapplication->exec = NULL;
1558 if (uiapplication->appid) {
1559 free((void *)uiapplication->appid);
1560 uiapplication->appid = NULL;
1562 if (uiapplication->nodisplay) {
1563 free((void *)uiapplication->nodisplay);
1564 uiapplication->nodisplay = NULL;
1566 if (uiapplication->multiple) {
1567 free((void *)uiapplication->multiple);
1568 uiapplication->multiple = NULL;
1570 if (uiapplication->type) {
1571 free((void *)uiapplication->type);
1572 uiapplication->type = NULL;
1574 if (uiapplication->categories) {
1575 free((void *)uiapplication->categories);
1576 uiapplication->categories = NULL;
1578 if (uiapplication->extraid) {
1579 free((void *)uiapplication->extraid);
1580 uiapplication->extraid = NULL;
1582 if (uiapplication->taskmanage) {
1583 free((void *)uiapplication->taskmanage);
1584 uiapplication->taskmanage = NULL;
1586 if (uiapplication->enabled) {
1587 free((void *)uiapplication->enabled);
1588 uiapplication->enabled = NULL;
1590 if (uiapplication->hwacceleration) {
1591 free((void *)uiapplication->hwacceleration);
1592 uiapplication->hwacceleration = NULL;
1594 if (uiapplication->screenreader) {
1595 free((void *)uiapplication->screenreader);
1596 uiapplication->screenreader = NULL;
1598 if (uiapplication->mainapp) {
1599 free((void *)uiapplication->mainapp);
1600 uiapplication->mainapp = NULL;
1602 if (uiapplication->recentimage) {
1603 free((void *)uiapplication->recentimage);
1604 uiapplication->recentimage = NULL;
1606 if (uiapplication->package) {
1607 free((void *)uiapplication->package);
1608 uiapplication->package = NULL;
1610 if (uiapplication->launchcondition) {
1611 free((void *)uiapplication->launchcondition);
1612 uiapplication->launchcondition = NULL;
1615 if (uiapplication->label) {
1616 label_x *label = uiapplication->label;
1617 label_x *tmp = NULL;
1618 while(label != NULL) {
1620 __ps_free_label(label);
1625 if (uiapplication->icon) {
1626 icon_x *icon = uiapplication->icon;
1628 while(icon != NULL) {
1630 __ps_free_icon(icon);
1635 if (uiapplication->image) {
1636 image_x *image = uiapplication->image;
1637 image_x *tmp = NULL;
1638 while(image != NULL) {
1640 __ps_free_image(image);
1645 if (uiapplication->appcontrol) {
1646 appcontrol_x *appcontrol = uiapplication->appcontrol;
1647 appcontrol_x *tmp = NULL;
1648 while(appcontrol != NULL) {
1649 tmp = appcontrol->next;
1650 __ps_free_appcontrol(appcontrol);
1654 /*Free LaunchConditions*/
1655 if (uiapplication->launchconditions) {
1656 launchconditions_x *launchconditions = uiapplication->launchconditions;
1657 launchconditions_x *tmp = NULL;
1658 while(launchconditions != NULL) {
1659 tmp = launchconditions->next;
1660 __ps_free_launchconditions(launchconditions);
1661 launchconditions = tmp;
1664 /*Free Notification*/
1665 if (uiapplication->notification) {
1666 notification_x *notification = uiapplication->notification;
1667 notification_x *tmp = NULL;
1668 while(notification != NULL) {
1669 tmp = notification->next;
1670 __ps_free_notification(notification);
1675 if (uiapplication->datashare) {
1676 datashare_x *datashare = uiapplication->datashare;
1677 datashare_x *tmp = NULL;
1678 while(datashare != NULL) {
1679 tmp = datashare->next;
1680 __ps_free_datashare(datashare);
1685 if (uiapplication->appsvc) {
1686 appsvc_x *appsvc = uiapplication->appsvc;
1687 appsvc_x *tmp = NULL;
1688 while(appsvc != NULL) {
1690 __ps_free_appsvc(appsvc);
1695 if (uiapplication->category) {
1696 category_x *category = uiapplication->category;
1697 category_x *tmp = NULL;
1698 while(category != NULL) {
1699 tmp = category->next;
1700 __ps_free_category(category);
1705 if (uiapplication->metadata) {
1706 metadata_x *metadata = uiapplication->metadata;
1707 metadata_x *tmp = NULL;
1708 while(metadata != NULL) {
1709 tmp = metadata->next;
1710 __ps_free_metadata(metadata);
1715 if (uiapplication->permission) {
1716 permission_x *permission = uiapplication->permission;
1717 permission_x *tmp = NULL;
1718 while(permission != NULL) {
1719 tmp = permission->next;
1720 __ps_free_permission(permission);
1724 /* _PRODUCT_LAUNCHING_ENHANCED_ START */
1725 if (uiapplication->indicatordisplay) {
1726 free((void *)uiapplication->indicatordisplay);
1727 uiapplication->indicatordisplay = NULL;
1729 if (uiapplication->portraitimg) {
1730 free((void *)uiapplication->portraitimg);
1731 uiapplication->portraitimg = NULL;
1733 if (uiapplication->landscapeimg) {
1734 free((void *)uiapplication->landscapeimg);
1735 uiapplication->landscapeimg = NULL;
1737 /* _PRODUCT_LAUNCHING_ENHANCED_ END */
1738 if (uiapplication->guestmode_visibility) {
1739 free((void *)uiapplication->guestmode_visibility);
1740 uiapplication->guestmode_visibility = NULL;
1742 if (uiapplication->app_component) {
1743 free((void *)uiapplication->app_component);
1744 uiapplication->app_component = NULL;
1746 if (uiapplication->permission_type) {
1747 free((void *)uiapplication->permission_type);
1748 uiapplication->permission_type = NULL;
1750 if (uiapplication->component_type) {
1751 free((void *)uiapplication->component_type);
1752 uiapplication->component_type = NULL;
1754 if (uiapplication->preload) {
1755 free((void *)uiapplication->preload);
1756 uiapplication->preload = NULL;
1758 if (uiapplication->submode) {
1759 free((void *)uiapplication->submode);
1760 uiapplication->submode = NULL;
1762 if (uiapplication->submode_mainid) {
1763 free((void *)uiapplication->submode_mainid);
1764 uiapplication->submode_mainid = NULL;
1767 free((void*)uiapplication);
1768 uiapplication = NULL;
1771 static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication)
1773 if (serviceapplication == NULL)
1775 if (serviceapplication->exec) {
1776 free((void *)serviceapplication->exec);
1777 serviceapplication->exec = NULL;
1779 if (serviceapplication->appid) {
1780 free((void *)serviceapplication->appid);
1781 serviceapplication->appid = NULL;
1783 if (serviceapplication->onboot) {
1784 free((void *)serviceapplication->onboot);
1785 serviceapplication->onboot = NULL;
1787 if (serviceapplication->autorestart) {
1788 free((void *)serviceapplication->autorestart);
1789 serviceapplication->autorestart = NULL;
1791 if (serviceapplication->type) {
1792 free((void *)serviceapplication->type);
1793 serviceapplication->type = NULL;
1795 if (serviceapplication->enabled) {
1796 free((void *)serviceapplication->enabled);
1797 serviceapplication->enabled = NULL;
1799 if (serviceapplication->package) {
1800 free((void *)serviceapplication->package);
1801 serviceapplication->package = NULL;
1803 if (serviceapplication->permission_type) {
1804 free((void *)serviceapplication->permission_type);
1805 serviceapplication->permission_type = NULL;
1808 if (serviceapplication->label) {
1809 label_x *label = serviceapplication->label;
1810 label_x *tmp = NULL;
1811 while(label != NULL) {
1813 __ps_free_label(label);
1818 if (serviceapplication->icon) {
1819 icon_x *icon = serviceapplication->icon;
1821 while(icon != NULL) {
1823 __ps_free_icon(icon);
1828 if (serviceapplication->appcontrol) {
1829 appcontrol_x *appcontrol = serviceapplication->appcontrol;
1830 appcontrol_x *tmp = NULL;
1831 while(appcontrol != NULL) {
1832 tmp = appcontrol->next;
1833 __ps_free_appcontrol(appcontrol);
1837 /*Free DataControl*/
1838 if (serviceapplication->datacontrol) {
1839 datacontrol_x *datacontrol = serviceapplication->datacontrol;
1840 datacontrol_x *tmp = NULL;
1841 while(datacontrol != NULL) {
1842 tmp = datacontrol->next;
1843 __ps_free_datacontrol(datacontrol);
1847 /*Free LaunchConditions*/
1848 if (serviceapplication->launchconditions) {
1849 launchconditions_x *launchconditions = serviceapplication->launchconditions;
1850 launchconditions_x *tmp = NULL;
1851 while(launchconditions != NULL) {
1852 tmp = launchconditions->next;
1853 __ps_free_launchconditions(launchconditions);
1854 launchconditions = tmp;
1857 /*Free Notification*/
1858 if (serviceapplication->notification) {
1859 notification_x *notification = serviceapplication->notification;
1860 notification_x *tmp = NULL;
1861 while(notification != NULL) {
1862 tmp = notification->next;
1863 __ps_free_notification(notification);
1868 if (serviceapplication->datashare) {
1869 datashare_x *datashare = serviceapplication->datashare;
1870 datashare_x *tmp = NULL;
1871 while(datashare != NULL) {
1872 tmp = datashare->next;
1873 __ps_free_datashare(datashare);
1878 if (serviceapplication->appsvc) {
1879 appsvc_x *appsvc = serviceapplication->appsvc;
1880 appsvc_x *tmp = NULL;
1881 while(appsvc != NULL) {
1883 __ps_free_appsvc(appsvc);
1888 if (serviceapplication->category) {
1889 category_x *category = serviceapplication->category;
1890 category_x *tmp = NULL;
1891 while(category != NULL) {
1892 tmp = category->next;
1893 __ps_free_category(category);
1898 if (serviceapplication->metadata) {
1899 metadata_x *metadata = serviceapplication->metadata;
1900 metadata_x *tmp = NULL;
1901 while(metadata != NULL) {
1902 tmp = metadata->next;
1903 __ps_free_metadata(metadata);
1908 if (serviceapplication->permission) {
1909 permission_x *permission = serviceapplication->permission;
1910 permission_x *tmp = NULL;
1911 while(permission != NULL) {
1912 tmp = permission->next;
1913 __ps_free_permission(permission);
1917 free((void*)serviceapplication);
1918 serviceapplication = NULL;
1921 static void __ps_free_font(font_x *font)
1926 free((void *)font->name);
1930 free((void *)font->text);
1937 static void __ps_free_theme(theme_x *theme)
1942 free((void *)theme->name);
1946 free((void *)theme->text);
1953 static void __ps_free_daemon(daemon_x *daemon)
1958 free((void *)daemon->name);
1959 daemon->name = NULL;
1962 free((void *)daemon->text);
1963 daemon->text = NULL;
1965 free((void*)daemon);
1969 static void __ps_free_ime(ime_x *ime)
1974 free((void *)ime->name);
1978 free((void *)ime->text);
1985 int __ps_process_mdparser(manifest_x *mfx, ACTION_TYPE action)
1989 char md_key[PKG_STRING_LEN_MAX] = { 0 };
1991 fp = fopen(MDPARSER_LIST, "r");
1993 DBG("no preload list\n");
1997 while (fgets(md_key, sizeof(md_key), fp) != NULL) {
1999 DBG("md_key = %s\n", md_key);
2001 ret = __run_mdparser_prestep(mfx, md_key, action);
2003 memset(md_key, 0x00, sizeof(md_key));
2012 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed)
2014 xmlTextReaderRead(reader);
2015 if (xmlTextReaderValue(reader))
2016 allowed->text = ASCII(xmlTextReaderValue(reader));
2020 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation)
2022 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2023 operation->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2024 /* Text does not exist. Only attribute exists
2025 xmlTextReaderRead(reader);
2026 if (xmlTextReaderValue(reader))
2027 operation->text = ASCII(xmlTextReaderValue(reader));
2032 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri)
2034 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2035 uri->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2036 /* Text does not exist. Only attribute exists
2037 xmlTextReaderRead(reader);
2038 if (xmlTextReaderValue(reader))
2039 uri->text = ASCII(xmlTextReaderValue(reader));
2044 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime)
2046 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2047 mime->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2048 /* Text does not exist. Only attribute exists
2049 xmlTextReaderRead(reader);
2050 if (xmlTextReaderValue(reader))
2051 mime->text = ASCII(xmlTextReaderValue(reader));
2056 static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp)
2058 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2059 subapp->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2060 /* Text does not exist. Only attribute exists
2061 xmlTextReaderRead(reader);
2062 if (xmlTextReaderValue(reader))
2063 mime->text = ASCII(xmlTextReaderValue(reader));
2068 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition)
2070 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2071 condition->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2072 xmlTextReaderRead(reader);
2073 if (xmlTextReaderValue(reader))
2074 condition->text = ASCII(xmlTextReaderValue(reader));
2078 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notification)
2080 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2081 notification->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2082 xmlTextReaderRead(reader);
2083 if (xmlTextReaderValue(reader))
2084 notification->text = ASCII(xmlTextReaderValue(reader));
2088 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category)
2090 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2091 category->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2095 static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege)
2097 xmlTextReaderRead(reader);
2098 if (xmlTextReaderValue(reader)) {
2099 privilege->text = ASCII(xmlTextReaderValue(reader));
2104 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata)
2106 if (xmlTextReaderGetAttribute(reader, XMLCHAR("key")))
2107 metadata->key = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("key")));
2108 if (xmlTextReaderGetAttribute(reader, XMLCHAR("value")))
2109 metadata->value = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("value")));
2113 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission)
2115 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
2116 permission->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
2118 xmlTextReaderRead(reader);
2119 if (xmlTextReaderValue(reader))
2120 permission->value = ASCII(xmlTextReaderValue(reader));
2124 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility)
2126 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2127 compatibility->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2128 xmlTextReaderRead(reader);
2129 if (xmlTextReaderValue(reader))
2130 compatibility->text = ASCII(xmlTextReaderValue(reader));
2134 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution)
2136 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")))
2137 resolution->mimetype = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")));
2138 if (xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")))
2139 resolution->urischeme = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")));
2143 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request)
2145 xmlTextReaderRead(reader);
2146 if (xmlTextReaderValue(reader))
2147 request->text = ASCII(xmlTextReaderValue(reader));
2151 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define)
2153 const xmlChar *node;
2156 allowed_x *tmp1 = NULL;
2157 request_x *tmp2 = NULL;
2159 if (xmlTextReaderGetAttribute(reader, XMLCHAR("path")))
2160 define->path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("path")));
2162 depth = xmlTextReaderDepth(reader);
2163 while ((ret = __next_child_element(reader, depth))) {
2164 node = xmlTextReaderConstName(reader);
2166 DBG("xmlTextReaderConstName value is NULL\n");
2170 if (!strcmp(ASCII(node), "allowed")) {
2171 allowed_x *allowed= malloc(sizeof(allowed_x));
2172 if (allowed == NULL) {
2173 DBG("Malloc Failed\n");
2176 memset(allowed, '\0', sizeof(allowed_x));
2177 LISTADD(define->allowed, allowed);
2178 ret = __ps_process_allowed(reader, allowed);
2179 } else if (!strcmp(ASCII(node), "request")) {
2180 request_x *request = malloc(sizeof(request_x));
2181 if (request == NULL) {
2182 DBG("Malloc Failed\n");
2185 memset(request, '\0', sizeof(request_x));
2186 LISTADD(define->request, request);
2187 ret = __ps_process_request(reader, request);
2191 DBG("Processing define failed\n");
2195 if (define->allowed) {
2196 LISTHEAD(define->allowed, tmp1);
2197 define->allowed = tmp1;
2199 if (define->request) {
2200 LISTHEAD(define->request, tmp2);
2201 define->request = tmp2;
2206 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol)
2208 const xmlChar *node;
2211 operation_x *tmp1 = NULL;
2213 mime_x *tmp3 = NULL;
2214 subapp_x *tmp4 = NULL;
2216 depth = xmlTextReaderDepth(reader);
2217 while ((ret = __next_child_element(reader, depth))) {
2218 node = xmlTextReaderConstName(reader);
2220 DBG("xmlTextReaderConstName value is NULL\n");
2224 if (!strcmp(ASCII(node), "operation")) {
2225 operation_x *operation = malloc(sizeof(operation_x));
2226 if (operation == NULL) {
2227 DBG("Malloc Failed\n");
2230 memset(operation, '\0', sizeof(operation_x));
2231 LISTADD(appcontrol->operation, operation);
2232 ret = __ps_process_operation(reader, operation);
2233 DBG("operation processing\n");
2234 } else if (!strcmp(ASCII(node), "uri")) {
2235 uri_x *uri= malloc(sizeof(uri_x));
2237 DBG("Malloc Failed\n");
2240 memset(uri, '\0', sizeof(uri_x));
2241 LISTADD(appcontrol->uri, uri);
2242 ret = __ps_process_uri(reader, uri);
2243 DBG("uri processing\n");
2244 } else if (!strcmp(ASCII(node), "mime")) {
2245 mime_x *mime = malloc(sizeof(mime_x));
2247 DBG("Malloc Failed\n");
2250 memset(mime, '\0', sizeof(mime_x));
2251 LISTADD(appcontrol->mime, mime);
2252 ret = __ps_process_mime(reader, mime);
2253 DBG("mime processing\n");
2254 } else if (!strcmp(ASCII(node), "subapp")) {
2255 subapp_x *subapp = malloc(sizeof(subapp_x));
2256 if (subapp == NULL) {
2257 DBG("Malloc Failed\n");
2260 memset(subapp, '\0', sizeof(subapp_x));
2261 LISTADD(appcontrol->subapp, subapp);
2262 ret = __ps_process_subapp(reader, subapp);
2263 DBG("subapp processing\n");
2267 DBG("Processing appcontrol failed\n");
2271 if (appcontrol->operation) {
2272 LISTHEAD(appcontrol->operation, tmp1);
2273 appcontrol->operation = tmp1;
2275 if (appcontrol->uri) {
2276 LISTHEAD(appcontrol->uri, tmp2);
2277 appcontrol->uri = tmp2;
2279 if (appcontrol->mime) {
2280 LISTHEAD(appcontrol->mime, tmp3);
2281 appcontrol->mime = tmp3;
2283 if (appcontrol->subapp) {
2284 LISTHEAD(appcontrol->subapp, tmp4);
2285 appcontrol->subapp = tmp4;
2288 xmlTextReaderRead(reader);
2289 if (xmlTextReaderValue(reader))
2290 appcontrol->text = ASCII(xmlTextReaderValue(reader));
2295 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc)
2297 const xmlChar *node;
2300 operation_x *tmp1 = NULL;
2302 mime_x *tmp3 = NULL;
2303 subapp_x *tmp4 = NULL;
2305 depth = xmlTextReaderDepth(reader);
2306 while ((ret = __next_child_element(reader, depth))) {
2307 node = xmlTextReaderConstName(reader);
2309 DBG("xmlTextReaderConstName value is NULL\n");
2313 if (!strcmp(ASCII(node), "operation")) {
2314 operation_x *operation = malloc(sizeof(operation_x));
2315 if (operation == NULL) {
2316 DBG("Malloc Failed\n");
2319 memset(operation, '\0', sizeof(operation_x));
2320 LISTADD(appsvc->operation, operation);
2321 ret = __ps_process_operation(reader, operation);
2322 DBG("operation processing\n");
2323 } else if (!strcmp(ASCII(node), "uri")) {
2324 uri_x *uri= malloc(sizeof(uri_x));
2326 DBG("Malloc Failed\n");
2329 memset(uri, '\0', sizeof(uri_x));
2330 LISTADD(appsvc->uri, uri);
2331 ret = __ps_process_uri(reader, uri);
2332 DBG("uri processing\n");
2333 } else if (!strcmp(ASCII(node), "mime")) {
2334 mime_x *mime = malloc(sizeof(mime_x));
2336 DBG("Malloc Failed\n");
2339 memset(mime, '\0', sizeof(mime_x));
2340 LISTADD(appsvc->mime, mime);
2341 ret = __ps_process_mime(reader, mime);
2342 DBG("mime processing\n");
2343 } else if (!strcmp(ASCII(node), "subapp")) {
2344 subapp_x *subapp = malloc(sizeof(subapp_x));
2345 if (subapp == NULL) {
2346 DBG("Malloc Failed\n");
2349 memset(subapp, '\0', sizeof(subapp_x));
2350 LISTADD(appsvc->subapp, subapp);
2351 ret = __ps_process_subapp(reader, subapp);
2352 DBG("subapp processing\n");
2356 DBG("Processing appsvc failed\n");
2360 if (appsvc->operation) {
2361 LISTHEAD(appsvc->operation, tmp1);
2362 appsvc->operation = tmp1;
2365 LISTHEAD(appsvc->uri, tmp2);
2369 LISTHEAD(appsvc->mime, tmp3);
2370 appsvc->mime = tmp3;
2372 if (appsvc->subapp) {
2373 LISTHEAD(appsvc->subapp, tmp4);
2374 appsvc->subapp = tmp4;
2377 xmlTextReaderRead(reader);
2378 if (xmlTextReaderValue(reader))
2379 appsvc->text = ASCII(xmlTextReaderValue(reader));
2385 static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privileges)
2387 const xmlChar *node;
2390 privilege_x *tmp1 = NULL;
2392 depth = xmlTextReaderDepth(reader);
2393 while ((ret = __next_child_element(reader, depth))) {
2394 node = xmlTextReaderConstName(reader);
2396 DBG("xmlTextReaderConstName value is NULL\n");
2400 if (strcmp(ASCII(node), "privilege") == 0) {
2401 privilege_x *privilege = malloc(sizeof(privilege_x));
2402 if (privilege == NULL) {
2403 DBG("Malloc Failed\n");
2406 memset(privilege, '\0', sizeof(privilege_x));
2407 LISTADD(privileges->privilege, privilege);
2408 ret = __ps_process_privilege(reader, privilege);
2412 DBG("Processing privileges failed\n");
2416 if (privileges->privilege) {
2417 LISTHEAD(privileges->privilege, tmp1);
2418 privileges->privilege = tmp1;
2423 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions)
2425 const xmlChar *node;
2428 condition_x *tmp1 = NULL;
2430 depth = xmlTextReaderDepth(reader);
2431 while ((ret = __next_child_element(reader, depth))) {
2432 node = xmlTextReaderConstName(reader);
2434 DBG("xmlTextReaderConstName value is NULL\n");
2438 if (strcmp(ASCII(node), "condition") == 0) {
2439 condition_x *condition = malloc(sizeof(condition_x));
2440 if (condition == NULL) {
2441 DBG("Malloc Failed\n");
2444 memset(condition, '\0', sizeof(condition_x));
2445 LISTADD(launchconditions->condition, condition);
2446 ret = __ps_process_condition(reader, condition);
2450 DBG("Processing launchconditions failed\n");
2454 if (launchconditions->condition) {
2455 LISTHEAD(launchconditions->condition, tmp1);
2456 launchconditions->condition = tmp1;
2459 xmlTextReaderRead(reader);
2460 if (xmlTextReaderValue(reader))
2461 launchconditions->text = ASCII(xmlTextReaderValue(reader));
2466 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare)
2468 const xmlChar *node;
2471 define_x *tmp1 = NULL;
2472 request_x *tmp2 = NULL;
2473 depth = xmlTextReaderDepth(reader);
2474 while ((ret = __next_child_element(reader, depth))) {
2475 node = xmlTextReaderConstName(reader);
2477 DBG("xmlTextReaderConstName value is NULL\n");
2481 if (!strcmp(ASCII(node), "define")) {
2482 define_x *define= malloc(sizeof(define_x));
2483 if (define == NULL) {
2484 DBG("Malloc Failed\n");
2487 memset(define, '\0', sizeof(define_x));
2488 LISTADD(datashare->define, define);
2489 ret = __ps_process_define(reader, define);
2490 } else if (!strcmp(ASCII(node), "request")) {
2491 request_x *request= malloc(sizeof(request_x));
2492 if (request == NULL) {
2493 DBG("Malloc Failed\n");
2496 memset(request, '\0', sizeof(request_x));
2497 LISTADD(datashare->request, request);
2498 ret = __ps_process_request(reader, request);
2502 DBG("Processing data-share failed\n");
2506 if (datashare->define) {
2507 LISTHEAD(datashare->define, tmp1);
2508 datashare->define = tmp1;
2510 if (datashare->request) {
2511 LISTHEAD(datashare->request, tmp2);
2512 datashare->request = tmp2;
2518 __get_icon_with_path(const char* icon)
2523 if (index(icon, '/') == NULL) {
2525 char* icon_with_path = NULL;
2531 theme = vconf_get_str("db/setting/theme");
2533 theme = strdup("default");
2539 len = (0x01 << 7) + strlen(icon) + strlen(package) + strlen(theme);
2540 icon_with_path = malloc(len);
2541 if(icon_with_path == NULL) {
2542 DBG("(icon_with_path == NULL) return\n");
2547 memset(icon_with_path, 0, len);
2549 snprintf(icon_with_path, len, "/opt/share/icons/%s/small/%s", theme, icon);
2551 if (access(icon_with_path, R_OK) == 0) break;
2552 snprintf(icon_with_path, len, "/usr/share/icons/%s/small/%s", theme, icon);
2553 if (access(icon_with_path, R_OK) == 0) break;
2554 DBG("cannot find icon %s", icon_with_path);
2555 snprintf(icon_with_path, len,"/opt/share/icons/default/small/%s", icon);
2556 if (access(icon_with_path, R_OK) == 0) break;
2557 snprintf(icon_with_path, len, "/usr/share/icons/default/small/%s", icon);
2558 if (access(icon_with_path, R_OK) == 0) break;
2560 /* icon path is going to be moved intto the app directory */
2561 DBGE("icon file must be moved to %s", icon_with_path);
2562 snprintf(icon_with_path, len, "/opt/apps/%s/res/icons/%s/small/%s", package, theme, icon);
2563 if (access(icon_with_path, R_OK) == 0) break;
2564 snprintf(icon_with_path, len, "/usr/apps/%s/res/icons/%s/small/%s", package, theme, icon);
2565 if (access(icon_with_path, R_OK) == 0) break;
2566 DBG("cannot find icon %s", icon_with_path);
2567 snprintf(icon_with_path, len, "/opt/apps/%s/res/icons/default/small/%s", package, icon);
2568 if (access(icon_with_path, R_OK) == 0) break;
2569 snprintf(icon_with_path, len, "/usr/apps/%s/res/icons/default/small/%s", package, icon);
2570 if (access(icon_with_path, R_OK) == 0) break;
2571 snprintf(icon_with_path, len, "/usr/ug/res/images/%s/%s", package, icon);
2572 if (access(icon_with_path, R_OK) == 0) break;
2577 DBG("Icon path : %s ---> %s", icon, icon_with_path);
2579 return icon_with_path;
2581 char* confirmed_icon = NULL;
2583 confirmed_icon = strdup(icon);
2584 if (!confirmed_icon)
2586 return confirmed_icon;
2590 static void __ps_process_tag(manifest_x * mfx, char *const tagv[])
2593 char delims[] = "=";
2594 char *ret_result = NULL;
2600 for (tag = strdup(tagv[0]); tag != NULL; ) {
2601 ret_result = strtok(tag, delims);
2603 /*check tag : preload */
2604 if (strcmp(ret_result, "preload") == 0) {
2605 ret_result = strtok(NULL, delims);
2606 if (strcmp(ret_result, "true") == 0) {
2607 free((void *)mfx->preload);
2608 mfx->preload = strdup("true");
2609 } else if (strcmp(ret_result, "false") == 0) {
2610 free((void *)mfx->preload);
2611 mfx->preload = strdup("false");
2613 /*check tag : removable*/
2614 } else if (strcmp(ret_result, "removable") == 0) {
2615 ret_result = strtok(NULL, delims);
2616 if (strcmp(ret_result, "true") == 0){
2617 free((void *)mfx->removable);
2618 mfx->removable = strdup("true");
2619 } else if (strcmp(ret_result, "false") == 0) {
2620 free((void *)mfx->removable);
2621 mfx->removable = strdup("false");
2623 /*check tag : not matched*/
2625 DBG("tag process [%s]is not defined\n", ret_result);
2629 /*check next value*/
2630 if (tagv[++i] != NULL)
2631 tag = strdup(tagv[i]);
2633 DBG("tag process success...\n");
2639 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon)
2641 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2642 icon->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2643 if (xmlTextReaderConstXmlLang(reader)) {
2644 icon->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2645 if (icon->lang == NULL)
2646 icon->lang = strdup(DEFAULT_LOCALE);
2648 icon->lang = strdup(DEFAULT_LOCALE);
2650 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
2651 icon->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
2652 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
2653 icon->size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
2654 if (xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")))
2655 icon->resolution = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")));
2656 xmlTextReaderRead(reader);
2657 if (xmlTextReaderValue(reader)) {
2658 const char *text = ASCII(xmlTextReaderValue(reader));
2660 icon->text = (const char *)__get_icon_with_path(text);
2668 static int __ps_process_image(xmlTextReaderPtr reader, image_x *image)
2670 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2671 image->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2672 if (xmlTextReaderConstXmlLang(reader)) {
2673 image->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2674 if (image->lang == NULL)
2675 image->lang = strdup(DEFAULT_LOCALE);
2677 image->lang = strdup(DEFAULT_LOCALE);
2679 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
2680 image->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
2681 xmlTextReaderRead(reader);
2682 if (xmlTextReaderValue(reader))
2683 image->text = ASCII(xmlTextReaderValue(reader));
2688 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label)
2690 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2691 label->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2692 if (xmlTextReaderConstXmlLang(reader)) {
2693 label->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2694 if (label->lang == NULL)
2695 label->lang = strdup(DEFAULT_LOCALE);
2697 label->lang = strdup(DEFAULT_LOCALE);
2699 xmlTextReaderRead(reader);
2700 if (xmlTextReaderValue(reader))
2701 label->text = ASCII(xmlTextReaderValue(reader));
2703 /* DBG("lable name %s\n", label->name);
2704 DBG("lable lang %s\n", label->lang);
2705 DBG("lable text %s\n", label->text);
2711 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author)
2713 if (xmlTextReaderGetAttribute(reader, XMLCHAR("email")))
2714 author->email = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("email")));
2715 if (xmlTextReaderGetAttribute(reader, XMLCHAR("href")))
2716 author->href = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("href")));
2717 if (xmlTextReaderConstXmlLang(reader)) {
2718 author->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2719 if (author->lang == NULL)
2720 author->lang = strdup(DEFAULT_LOCALE);
2722 author->lang = strdup(DEFAULT_LOCALE);
2724 xmlTextReaderRead(reader);
2725 if (xmlTextReaderValue(reader)) {
2726 const char *text = ASCII(xmlTextReaderValue(reader));
2727 if (*text == '\n') {
2728 author->text = NULL;
2732 author->text = ASCII(xmlTextReaderValue(reader));
2737 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description)
2739 if (xmlTextReaderConstXmlLang(reader)) {
2740 description->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2741 if (description->lang == NULL)
2742 description->lang = strdup(DEFAULT_LOCALE);
2744 description->lang = strdup(DEFAULT_LOCALE);
2746 xmlTextReaderRead(reader);
2747 if (xmlTextReaderValue(reader)) {
2748 const char *text = ASCII(xmlTextReaderValue(reader));
2749 if (*text == '\n') {
2750 description->text = NULL;
2754 description->text = ASCII(xmlTextReaderValue(reader));
2759 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license)
2761 if (xmlTextReaderConstXmlLang(reader)) {
2762 license->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2763 if (license->lang == NULL)
2764 license->lang = strdup(DEFAULT_LOCALE);
2766 license->lang = strdup(DEFAULT_LOCALE);
2768 xmlTextReaderRead(reader);
2769 if (xmlTextReaderValue(reader))
2770 license->text = ASCII(xmlTextReaderValue(reader));
2774 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability)
2776 const xmlChar *node;
2779 resolution_x *tmp1 = NULL;
2781 if (xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")))
2782 capability->operationid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")));
2784 depth = xmlTextReaderDepth(reader);
2785 while ((ret = __next_child_element(reader, depth))) {
2786 node = xmlTextReaderConstName(reader);
2788 DBG("xmlTextReaderConstName value is NULL\n");
2792 if (!strcmp(ASCII(node), "resolution")) {
2793 resolution_x *resolution = malloc(sizeof(resolution_x));
2794 if (resolution == NULL) {
2795 DBG("Malloc Failed\n");
2798 memset(resolution, '\0', sizeof(resolution_x));
2799 LISTADD(capability->resolution, resolution);
2800 ret = __ps_process_resolution(reader, resolution);
2804 DBG("Processing capability failed\n");
2809 if (capability->resolution) {
2810 LISTHEAD(capability->resolution, tmp1);
2811 capability->resolution = tmp1;
2817 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol)
2819 const xmlChar *node;
2822 capability_x *tmp1 = NULL;
2824 if (xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")))
2825 datacontrol->providerid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")));
2827 depth = xmlTextReaderDepth(reader);
2828 while ((ret = __next_child_element(reader, depth))) {
2829 node = xmlTextReaderConstName(reader);
2831 DBG("xmlTextReaderConstName value is NULL\n");
2835 if (!strcmp(ASCII(node), "capability")) {
2836 capability_x *capability = malloc(sizeof(capability_x));
2837 if (capability == NULL) {
2838 DBG("Malloc Failed\n");
2841 memset(capability, '\0', sizeof(capability_x));
2842 LISTADD(datacontrol->capability, capability);
2843 ret = __ps_process_capability(reader, capability);
2847 DBG("Processing datacontrol failed\n");
2852 if (datacontrol->capability) {
2853 LISTHEAD(datacontrol->capability, tmp1);
2854 datacontrol->capability = tmp1;
2860 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication)
2862 const xmlChar *node;
2865 char *newappid = NULL;
2866 label_x *tmp1 = NULL;
2867 icon_x *tmp2 = NULL;
2868 appsvc_x *tmp3 = NULL;
2869 appcontrol_x *tmp4 = NULL;
2870 launchconditions_x *tmp5 = NULL;
2871 notification_x *tmp6 = NULL;
2872 datashare_x *tmp7 = NULL;
2873 category_x *tmp8 = NULL;
2874 metadata_x *tmp9 = NULL;
2875 image_x *tmp10 = NULL;
2876 permission_x *tmp11 = NULL;
2878 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
2879 uiapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
2880 if (uiapplication->appid == NULL) {
2881 DBG("appid cant be NULL\n");
2885 DBG("appid is mandatory\n");
2889 ret = __validate_appid(package, uiapplication->appid, &newappid);
2891 DBG("appid is not proper\n");
2895 if (uiapplication->appid)
2896 free((void *)uiapplication->appid);
2897 uiapplication->appid = newappid;
2899 uiapplication->package= strdup(package);
2901 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
2902 uiapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
2903 if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay"))) {
2904 uiapplication->nodisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay")));
2905 if (uiapplication->nodisplay == NULL)
2906 uiapplication->nodisplay = strdup("false");
2908 uiapplication->nodisplay = strdup("false");
2910 if (xmlTextReaderGetAttribute(reader, XMLCHAR("multiple"))) {
2911 uiapplication->multiple = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("multiple")));
2912 if (uiapplication->multiple == NULL)
2913 uiapplication->multiple = strdup("false");
2915 uiapplication->multiple = strdup("false");
2917 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
2918 uiapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
2919 if (xmlTextReaderGetAttribute(reader, XMLCHAR("categories")))
2920 uiapplication->categories = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("categories")));
2921 if (xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")))
2922 uiapplication->extraid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")));
2923 if (xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage"))) {
2924 uiapplication->taskmanage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage")));
2925 if (uiapplication->taskmanage == NULL)
2926 uiapplication->taskmanage = strdup("true");
2928 uiapplication->taskmanage = strdup("true");
2930 if (xmlTextReaderGetAttribute(reader, XMLCHAR("enabled"))) {
2931 uiapplication->enabled = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("enabled")));
2932 if (uiapplication->enabled == NULL)
2933 uiapplication->enabled = strdup("true");
2935 uiapplication->enabled = strdup("true");
2937 if (xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration"))) {
2938 uiapplication->hwacceleration = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration")));
2939 if (uiapplication->hwacceleration == NULL)
2940 uiapplication->hwacceleration = strdup("use-system-setting");
2942 uiapplication->hwacceleration = strdup("use-system-setting");
2944 if (xmlTextReaderGetAttribute(reader, XMLCHAR("screen-reader"))) {
2945 uiapplication->screenreader = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("screen-reader")));
2946 if (uiapplication->screenreader == NULL)
2947 uiapplication->screenreader = strdup("use-system-setting");
2949 uiapplication->screenreader = strdup("use-system-setting");
2951 if (xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")))
2952 uiapplication->recentimage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")));
2953 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp"))) {
2954 uiapplication->mainapp = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp")));
2955 if (uiapplication->mainapp == NULL)
2956 uiapplication->mainapp = strdup("false");
2958 uiapplication->mainapp = strdup("false");
2960 if (xmlTextReaderGetAttribute(reader, XMLCHAR("launchcondition"))) {
2961 uiapplication->launchcondition = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("launchcondition")));
2962 if (uiapplication->launchcondition == NULL)
2963 uiapplication->launchcondition = strdup("false");
2965 uiapplication->launchcondition = strdup("false");
2968 if (xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay"))) {
2969 uiapplication->indicatordisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay")));
2970 if (uiapplication->indicatordisplay == NULL)
2971 uiapplication->indicatordisplay = strdup("true");
2973 uiapplication->indicatordisplay = strdup("true");
2975 if (xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")))
2976 uiapplication->portraitimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")));
2978 uiapplication->portraitimg = NULL;
2979 if (xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")))
2980 uiapplication->landscapeimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")));
2982 uiapplication->landscapeimg = NULL;
2983 if (xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility"))) {
2984 uiapplication->guestmode_visibility = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility")));
2985 if (uiapplication->guestmode_visibility == NULL)
2986 uiapplication->guestmode_visibility = strdup("true");
2988 uiapplication->guestmode_visibility = strdup("true");
2990 if (xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type"))) {
2991 uiapplication->permission_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type")));
2992 if (uiapplication->permission_type == NULL)
2993 uiapplication->permission_type = strdup("normal");
2995 uiapplication->permission_type = strdup("normal");
2997 if (xmlTextReaderGetAttribute(reader, XMLCHAR("component-type"))) {
2998 uiapplication->component_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("component-type")));
2999 if (uiapplication->component_type == NULL)
3000 uiapplication->component_type = strdup("uiapp");
3002 uiapplication->component_type = strdup("uiapp");
3004 if (xmlTextReaderGetAttribute(reader, XMLCHAR("submode"))) {
3005 uiapplication->submode = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("submode")));
3006 if (uiapplication->submode == NULL)
3007 uiapplication->submode = strdup("false");
3009 uiapplication->submode = strdup("false");
3011 if (xmlTextReaderGetAttribute(reader, XMLCHAR("submode-mainid")))
3012 uiapplication->submode_mainid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("submode-mainid")));
3014 depth = xmlTextReaderDepth(reader);
3015 while ((ret = __next_child_element(reader, depth))) {
3016 node = xmlTextReaderConstName(reader);
3018 DBG("xmlTextReaderConstName value is NULL\n");
3021 if (!strcmp(ASCII(node), "label")) {
3022 label_x *label = malloc(sizeof(label_x));
3023 if (label == NULL) {
3024 DBG("Malloc Failed\n");
3027 memset(label, '\0', sizeof(label_x));
3028 LISTADD(uiapplication->label, label);
3029 ret = __ps_process_label(reader, label);
3030 } else if (!strcmp(ASCII(node), "icon")) {
3031 icon_x *icon = malloc(sizeof(icon_x));
3033 DBG("Malloc Failed\n");
3036 memset(icon, '\0', sizeof(icon_x));
3037 LISTADD(uiapplication->icon, icon);
3038 ret = __ps_process_icon(reader, icon);
3039 } else if (!strcmp(ASCII(node), "image")) {
3040 image_x *image = malloc(sizeof(image_x));
3041 if (image == NULL) {
3042 DBG("Malloc Failed\n");
3045 memset(image, '\0', sizeof(image_x));
3046 LISTADD(uiapplication->image, image);
3047 ret = __ps_process_image(reader, image);
3048 } else if (!strcmp(ASCII(node), "category")) {
3049 category_x *category = malloc(sizeof(category_x));
3050 if (category == NULL) {
3051 DBG("Malloc Failed\n");
3054 memset(category, '\0', sizeof(category_x));
3055 LISTADD(uiapplication->category, category);
3056 ret = __ps_process_category(reader, category);
3057 } else if (!strcmp(ASCII(node), "metadata")) {
3058 metadata_x *metadata = malloc(sizeof(metadata_x));
3059 if (metadata == NULL) {
3060 DBG("Malloc Failed\n");
3063 memset(metadata, '\0', sizeof(metadata_x));
3064 LISTADD(uiapplication->metadata, metadata);
3065 ret = __ps_process_metadata(reader, metadata);
3066 } else if (!strcmp(ASCII(node), "permission")) {
3067 permission_x *permission = malloc(sizeof(permission_x));
3068 if (permission == NULL) {
3069 DBG("Malloc Failed\n");
3072 memset(permission, '\0', sizeof(permission_x));
3073 LISTADD(uiapplication->permission, permission);
3074 ret = __ps_process_permission(reader, permission);
3075 } else if (!strcmp(ASCII(node), "app-control")) {
3076 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
3077 if (appcontrol == NULL) {
3078 DBG("Malloc Failed\n");
3081 memset(appcontrol, '\0', sizeof(appcontrol_x));
3082 LISTADD(uiapplication->appcontrol, appcontrol);
3083 ret = __ps_process_appcontrol(reader, appcontrol);
3084 } else if (!strcmp(ASCII(node), "application-service")) {
3085 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
3086 if (appsvc == NULL) {
3087 DBG("Malloc Failed\n");
3090 memset(appsvc, '\0', sizeof(appsvc_x));
3091 LISTADD(uiapplication->appsvc, appsvc);
3092 ret = __ps_process_appsvc(reader, appsvc);
3093 } else if (!strcmp(ASCII(node), "data-share")) {
3094 datashare_x *datashare = malloc(sizeof(datashare_x));
3095 if (datashare == NULL) {
3096 DBG("Malloc Failed\n");
3099 memset(datashare, '\0', sizeof(datashare_x));
3100 LISTADD(uiapplication->datashare, datashare);
3101 ret = __ps_process_datashare(reader, datashare);
3102 } else if (!strcmp(ASCII(node), "launch-conditions")) {
3103 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
3104 if (launchconditions == NULL) {
3105 DBG("Malloc Failed\n");
3108 memset(launchconditions, '\0', sizeof(launchconditions_x));
3109 LISTADD(uiapplication->launchconditions, launchconditions);
3110 ret = __ps_process_launchconditions(reader, launchconditions);
3111 } else if (!strcmp(ASCII(node), "notification")) {
3112 notification_x *notification = malloc(sizeof(notification_x));
3113 if (notification == NULL) {
3114 DBG("Malloc Failed\n");
3117 memset(notification, '\0', sizeof(notification_x));
3118 LISTADD(uiapplication->notification, notification);
3119 ret = __ps_process_notification(reader, notification);
3123 DBG("Processing uiapplication failed\n");
3128 if (uiapplication->label) {
3129 LISTHEAD(uiapplication->label, tmp1);
3130 uiapplication->label = tmp1;
3132 if (uiapplication->icon) {
3133 LISTHEAD(uiapplication->icon, tmp2);
3134 uiapplication->icon = tmp2;
3136 if (uiapplication->appsvc) {
3137 LISTHEAD(uiapplication->appsvc, tmp3);
3138 uiapplication->appsvc = tmp3;
3140 if (uiapplication->appcontrol) {
3141 LISTHEAD(uiapplication->appcontrol, tmp4);
3142 uiapplication->appcontrol = tmp4;
3144 if (uiapplication->launchconditions) {
3145 LISTHEAD(uiapplication->launchconditions, tmp5);
3146 uiapplication->launchconditions = tmp5;
3148 if (uiapplication->notification) {
3149 LISTHEAD(uiapplication->notification, tmp6);
3150 uiapplication->notification = tmp6;
3152 if (uiapplication->datashare) {
3153 LISTHEAD(uiapplication->datashare, tmp7);
3154 uiapplication->datashare = tmp7;
3156 if (uiapplication->category) {
3157 LISTHEAD(uiapplication->category, tmp8);
3158 uiapplication->category = tmp8;
3160 if (uiapplication->metadata) {
3161 LISTHEAD(uiapplication->metadata, tmp9);
3162 uiapplication->metadata = tmp9;
3164 if (uiapplication->image) {
3165 LISTHEAD(uiapplication->image, tmp10);
3166 uiapplication->image = tmp10;
3168 if (uiapplication->permission) {
3169 LISTHEAD(uiapplication->permission, tmp11);
3170 uiapplication->permission = tmp11;
3176 static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication)
3178 const xmlChar *node;
3181 char *newappid = NULL;
3182 label_x *tmp1 = NULL;
3183 icon_x *tmp2 = NULL;
3184 appsvc_x *tmp3 = NULL;
3185 appcontrol_x *tmp4 = NULL;
3186 datacontrol_x *tmp5 = NULL;
3187 launchconditions_x *tmp6 = NULL;
3188 notification_x *tmp7 = NULL;
3189 datashare_x *tmp8 = NULL;
3190 category_x *tmp9 = NULL;
3191 metadata_x *tmp10 = NULL;
3192 permission_x *tmp11 = NULL;
3194 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
3195 serviceapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
3196 if (serviceapplication->appid == NULL) {
3197 DBG("appid cant be NULL\n");
3201 DBG("appid is mandatory\n");
3205 ret = __validate_appid(package, serviceapplication->appid, &newappid);
3207 DBG("appid is not proper\n");
3211 if (serviceapplication->appid)
3212 free((void *)serviceapplication->appid);
3213 serviceapplication->appid = newappid;
3216 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
3217 serviceapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
3218 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
3219 serviceapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
3220 if (xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot"))) {
3221 serviceapplication->onboot = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot")));
3222 if (serviceapplication->onboot == NULL)
3223 serviceapplication->onboot = strdup("false");
3225 serviceapplication->onboot = strdup("false");
3227 if (xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart"))) {
3228 serviceapplication->autorestart = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart")));
3229 if (serviceapplication->autorestart == NULL)
3230 serviceapplication->autorestart = strdup("false");
3232 serviceapplication->autorestart = strdup("false");
3234 if (xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type"))) {
3235 serviceapplication->permission_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type")));
3236 if (serviceapplication->permission_type == NULL)
3237 serviceapplication->permission_type = strdup("normal");
3239 serviceapplication->permission_type = strdup("normal");
3242 depth = xmlTextReaderDepth(reader);
3243 while ((ret = __next_child_element(reader, depth))) {
3244 node = xmlTextReaderConstName(reader);
3246 DBG("xmlTextReaderConstName value is NULL\n");
3250 if (!strcmp(ASCII(node), "label")) {
3251 label_x *label = malloc(sizeof(label_x));
3252 if (label == NULL) {
3253 DBG("Malloc Failed\n");
3256 memset(label, '\0', sizeof(label_x));
3257 LISTADD(serviceapplication->label, label);
3258 ret = __ps_process_label(reader, label);
3259 } else if (!strcmp(ASCII(node), "icon")) {
3260 icon_x *icon = malloc(sizeof(icon_x));
3262 DBG("Malloc Failed\n");
3265 memset(icon, '\0', sizeof(icon_x));
3266 LISTADD(serviceapplication->icon, icon);
3267 ret = __ps_process_icon(reader, icon);
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(serviceapplication->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(serviceapplication->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(serviceapplication->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(serviceapplication->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(serviceapplication->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(serviceapplication->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(serviceapplication->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(serviceapplication->notification, notification);
3339 ret = __ps_process_notification(reader, notification);
3340 } else if (!strcmp(ASCII(node), "data-control")) {
3341 datacontrol_x *datacontrol = malloc(sizeof(datacontrol_x));
3342 if (datacontrol == NULL) {
3343 DBG("Malloc Failed\n");
3346 memset(datacontrol, '\0', sizeof(datacontrol_x));
3347 LISTADD(serviceapplication->datacontrol, datacontrol);
3348 ret = __ps_process_datacontrol(reader, datacontrol);
3352 DBG("Processing serviceapplication failed\n");
3357 if (serviceapplication->label) {
3358 LISTHEAD(serviceapplication->label, tmp1);
3359 serviceapplication->label = tmp1;
3361 if (serviceapplication->icon) {
3362 LISTHEAD(serviceapplication->icon, tmp2);
3363 serviceapplication->icon = tmp2;
3365 if (serviceapplication->appsvc) {
3366 LISTHEAD(serviceapplication->appsvc, tmp3);
3367 serviceapplication->appsvc = tmp3;
3369 if (serviceapplication->appcontrol) {
3370 LISTHEAD(serviceapplication->appcontrol, tmp4);
3371 serviceapplication->appcontrol = tmp4;
3373 if (serviceapplication->datacontrol) {
3374 LISTHEAD(serviceapplication->datacontrol, tmp5);
3375 serviceapplication->datacontrol = tmp5;
3377 if (serviceapplication->launchconditions) {
3378 LISTHEAD(serviceapplication->launchconditions, tmp6);
3379 serviceapplication->launchconditions = tmp6;
3381 if (serviceapplication->notification) {
3382 LISTHEAD(serviceapplication->notification, tmp7);
3383 serviceapplication->notification = tmp7;
3385 if (serviceapplication->datashare) {
3386 LISTHEAD(serviceapplication->datashare, tmp8);
3387 serviceapplication->datashare = tmp8;
3389 if (serviceapplication->category) {
3390 LISTHEAD(serviceapplication->category, tmp9);
3391 serviceapplication->category = tmp9;
3393 if (serviceapplication->metadata) {
3394 LISTHEAD(serviceapplication->metadata, tmp10);
3395 serviceapplication->metadata = tmp10;
3397 if (serviceapplication->permission) {
3398 LISTHEAD(serviceapplication->permission, tmp11);
3399 serviceapplication->permission = tmp11;
3405 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile)
3407 /*TODO: once policy is set*/
3411 static int __ps_process_font(xmlTextReaderPtr reader, font_x *font)
3413 /*TODO: once policy is set*/
3417 static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme)
3419 /*TODO: once policy is set*/
3423 static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon)
3425 /*TODO: once policy is set*/
3429 static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime)
3431 /*TODO: once policy is set*/
3435 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx)
3437 DBG("__start_process\n");
3438 const xmlChar *node;
3441 label_x *tmp1 = NULL;
3442 author_x *tmp2 = NULL;
3443 description_x *tmp3 = NULL;
3444 license_x *tmp4 = NULL;
3445 uiapplication_x *tmp5 = NULL;
3446 serviceapplication_x *tmp6 = NULL;
3447 daemon_x *tmp7 = NULL;
3448 theme_x *tmp8 = NULL;
3449 font_x *tmp9 = NULL;
3450 ime_x *tmp10 = NULL;
3451 icon_x *tmp11 = NULL;
3452 compatibility_x *tmp12 = NULL;
3453 deviceprofile_x *tmp13 = NULL;
3454 privileges_x *tmp14 = NULL;
3456 depth = xmlTextReaderDepth(reader);
3457 while ((ret = __next_child_element(reader, depth))) {
3458 node = xmlTextReaderConstName(reader);
3460 DBG("xmlTextReaderConstName value is NULL\n");
3464 if (!strcmp(ASCII(node), "label")) {
3465 label_x *label = malloc(sizeof(label_x));
3466 if (label == NULL) {
3467 DBG("Malloc Failed\n");
3470 memset(label, '\0', sizeof(label_x));
3471 LISTADD(mfx->label, label);
3472 ret = __ps_process_label(reader, label);
3473 } else if (!strcmp(ASCII(node), "author")) {
3474 author_x *author = malloc(sizeof(author_x));
3475 if (author == NULL) {
3476 DBG("Malloc Failed\n");
3479 memset(author, '\0', sizeof(author_x));
3480 LISTADD(mfx->author, author);
3481 ret = __ps_process_author(reader, author);
3482 } else if (!strcmp(ASCII(node), "description")) {
3483 description_x *description = malloc(sizeof(description_x));
3484 if (description == NULL) {
3485 DBG("Malloc Failed\n");
3488 memset(description, '\0', sizeof(description_x));
3489 LISTADD(mfx->description, description);
3490 ret = __ps_process_description(reader, description);
3491 } else if (!strcmp(ASCII(node), "license")) {
3492 license_x *license = malloc(sizeof(license_x));
3493 if (license == NULL) {
3494 DBG("Malloc Failed\n");
3497 memset(license, '\0', sizeof(license_x));
3498 LISTADD(mfx->license, license);
3499 ret = __ps_process_license(reader, license);
3500 } else if (!strcmp(ASCII(node), "privileges")) {
3501 privileges_x *privileges = malloc(sizeof(privileges_x));
3502 if (privileges == NULL) {
3503 DBG("Malloc Failed\n");
3506 memset(privileges, '\0', sizeof(privileges_x));
3507 LISTADD(mfx->privileges, privileges);
3508 ret = __ps_process_privileges(reader, privileges);
3509 } else if (!strcmp(ASCII(node), "ui-application")) {
3510 uiapplication_x *uiapplication = malloc(sizeof(uiapplication_x));
3511 if (uiapplication == NULL) {
3512 DBG("Malloc Failed\n");
3515 memset(uiapplication, '\0', sizeof(uiapplication_x));
3516 LISTADD(mfx->uiapplication, uiapplication);
3517 ret = __ps_process_uiapplication(reader, uiapplication);
3518 } else if (!strcmp(ASCII(node), "service-application")) {
3519 serviceapplication_x *serviceapplication = malloc(sizeof(serviceapplication_x));
3520 if (serviceapplication == NULL) {
3521 DBG("Malloc Failed\n");
3524 memset(serviceapplication, '\0', sizeof(serviceapplication_x));
3525 LISTADD(mfx->serviceapplication, serviceapplication);
3526 ret = __ps_process_serviceapplication(reader, serviceapplication);
3527 } else if (!strcmp(ASCII(node), "daemon")) {
3528 daemon_x *daemon = malloc(sizeof(daemon_x));
3529 if (daemon == NULL) {
3530 DBG("Malloc Failed\n");
3533 memset(daemon, '\0', sizeof(daemon_x));
3534 LISTADD(mfx->daemon, daemon);
3535 ret = __ps_process_daemon(reader, daemon);
3536 } else if (!strcmp(ASCII(node), "theme")) {
3537 theme_x *theme = malloc(sizeof(theme_x));
3538 if (theme == NULL) {
3539 DBG("Malloc Failed\n");
3542 memset(theme, '\0', sizeof(theme_x));
3543 LISTADD(mfx->theme, theme);
3544 ret = __ps_process_theme(reader, theme);
3545 } else if (!strcmp(ASCII(node), "font")) {
3546 font_x *font = malloc(sizeof(font_x));
3548 DBG("Malloc Failed\n");
3551 memset(font, '\0', sizeof(font_x));
3552 LISTADD(mfx->font, font);
3553 ret = __ps_process_font(reader, font);
3554 } else if (!strcmp(ASCII(node), "ime")) {
3555 ime_x *ime = malloc(sizeof(ime_x));
3557 DBG("Malloc Failed\n");
3560 memset(ime, '\0', sizeof(ime_x));
3561 LISTADD(mfx->ime, ime);
3562 ret = __ps_process_ime(reader, ime);
3563 } else if (!strcmp(ASCII(node), "icon")) {
3564 icon_x *icon = malloc(sizeof(icon_x));
3566 DBG("Malloc Failed\n");
3569 memset(icon, '\0', sizeof(icon_x));
3570 LISTADD(mfx->icon, icon);
3571 ret = __ps_process_icon(reader, icon);
3572 } else if (!strcmp(ASCII(node), "device-profile")) {
3573 deviceprofile_x *deviceprofile = malloc(sizeof(deviceprofile_x));
3574 if (deviceprofile == NULL) {
3575 DBG("Malloc Failed\n");
3578 memset(deviceprofile, '\0', sizeof(deviceprofile_x));
3579 LISTADD(mfx->deviceprofile, deviceprofile);
3580 ret = __ps_process_deviceprofile(reader, deviceprofile);
3581 } else if (!strcmp(ASCII(node), "compatibility")) {
3582 compatibility_x *compatibility = malloc(sizeof(compatibility_x));
3583 if (compatibility == NULL) {
3584 DBG("Malloc Failed\n");
3587 memset(compatibility, '\0', sizeof(compatibility_x));
3588 LISTADD(mfx->compatibility, compatibility);
3589 ret = __ps_process_compatibility(reader, compatibility);
3590 } else if (!strcmp(ASCII(node), "shortcut-list")) {
3592 } else if (!strcmp(ASCII(node), "livebox")) {
3594 } else if (!strcmp(ASCII(node), "account")) {
3596 } else if (!strcmp(ASCII(node), "notifications")) {
3598 } else if (!strcmp(ASCII(node), "ime")) {
3604 DBG("Processing manifest failed\n");
3609 LISTHEAD(mfx->label, tmp1);
3613 LISTHEAD(mfx->author, tmp2);
3616 if (mfx->description) {
3617 LISTHEAD(mfx->description, tmp3);
3618 mfx->description= tmp3;
3621 LISTHEAD(mfx->license, tmp4);
3624 if (mfx->uiapplication) {
3625 LISTHEAD(mfx->uiapplication, tmp5);
3626 mfx->uiapplication = tmp5;
3628 if (mfx->serviceapplication) {
3629 LISTHEAD(mfx->serviceapplication, tmp6);
3630 mfx->serviceapplication = tmp6;
3633 LISTHEAD(mfx->daemon, tmp7);
3637 LISTHEAD(mfx->theme, tmp8);
3641 LISTHEAD(mfx->font, tmp9);
3645 LISTHEAD(mfx->ime, tmp10);
3649 LISTHEAD(mfx->icon, tmp11);
3652 if (mfx->compatibility) {
3653 LISTHEAD(mfx->compatibility, tmp12);
3654 mfx->compatibility= tmp12;
3656 if (mfx->deviceprofile) {
3657 LISTHEAD(mfx->deviceprofile, tmp13);
3658 mfx->deviceprofile= tmp13;
3660 if (mfx->privileges) {
3661 LISTHEAD(mfx->privileges, tmp14);
3662 mfx->privileges = tmp14;
3667 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx)
3669 const xmlChar *node;
3672 if ((ret = __next_child_element(reader, -1))) {
3673 node = xmlTextReaderConstName(reader);
3675 DBG("xmlTextReaderConstName value is NULL\n");
3679 if (!strcmp(ASCII(node), "manifest")) {
3680 if (xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")))
3681 mfx->ns = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")));
3682 if (xmlTextReaderGetAttribute(reader, XMLCHAR("package"))) {
3683 mfx->package= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("package")));
3684 if (mfx->package == NULL) {
3685 DBG("package cant be NULL\n");
3689 DBG("package field is mandatory\n");
3692 package = mfx->package;
3693 if (xmlTextReaderGetAttribute(reader, XMLCHAR("version")))
3694 mfx->version= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("version")));
3695 /*app2ext needs package size for external installation*/
3696 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
3697 mfx->package_size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
3698 if (xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")))
3699 mfx->installlocation = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")));
3700 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
3701 mfx->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
3702 if (xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")))
3703 mfx->root_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")));
3704 if (xmlTextReaderGetAttribute(reader, XMLCHAR("csc_path")))
3705 mfx->csc_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("csc_path")));
3706 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting"))) {
3707 mfx->appsetting = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting")));
3708 if (mfx->appsetting == NULL)
3709 mfx->appsetting = strdup("false");
3711 mfx->appsetting = strdup("false");
3713 if (xmlTextReaderGetAttribute(reader, XMLCHAR("storeclient-id")))
3714 mfx->storeclient_id= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("storeclient-id")));
3715 if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay-setting"))) {
3716 mfx->nodisplay_setting = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay-setting")));
3717 if (mfx->nodisplay_setting == NULL)
3718 mfx->nodisplay_setting = strdup("false");
3720 mfx->nodisplay_setting = strdup("false");
3722 if (xmlTextReaderGetAttribute(reader, XMLCHAR("url")))
3723 mfx->package_url= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("url")));
3725 /*Assign default values. If required it will be overwritten in __add_preload_info()*/
3726 mfx->preload = strdup("False");
3727 mfx->removable = strdup("True");
3728 mfx->readonly = strdup("False");
3729 mfx->update = strdup("False");
3730 char buf[PKG_STRING_LEN_MAX] = {'\0'};
3732 time_t current_time;
3733 time(¤t_time);
3734 snprintf(buf, PKG_STRING_LEN_MAX - 1, "%d", current_time);
3735 val = strndup(buf, PKG_STRING_LEN_MAX - 1);
3736 mfx->installed_time = val;
3738 mfx->installed_storage= strdup("installed_internal");
3740 ret = __start_process(reader, mfx);
3742 DBG("No Manifest element found\n");
3749 #define DESKTOP_RW_PATH "/opt/share/applications/"
3750 #define DESKTOP_RO_PATH "/usr/share/applications/"
3751 #define MANIFEST_RO_PREFIX "/usr/share/packages/"
3753 static char* __convert_to_system_locale(const char *mlocale)
3755 if (mlocale == NULL)
3757 char *locale = NULL;
3758 locale = (char *)calloc(1, 6);
3760 DBGE("Malloc Failed\n");
3764 strncpy(locale, mlocale, 2);
3765 strncat(locale, "_", 1);
3766 locale[3] = toupper(mlocale[3]);
3767 locale[4] = toupper(mlocale[4]);
3771 #define LIBAIL_PATH "/usr/lib/libail.so.0"
3773 /* operation_type */
3782 static int __ail_change_info(int op, const char *appid)
3784 void *lib_handle = NULL;
3785 int (*ail_desktop_operation) (const char *);
3789 if ((lib_handle = dlopen(LIBAIL_PATH, RTLD_LAZY)) == NULL) {
3790 DBGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAIL_PATH);
3797 aop = "ail_desktop_add";
3800 aop = "ail_desktop_update";
3803 aop = "ail_desktop_remove";
3806 aop = "ail_desktop_clean";
3813 if ((ail_desktop_operation =
3814 dlsym(lib_handle, aop)) == NULL || dlerror() != NULL) {
3815 DBGE("can not find symbol \n");
3819 ret = ail_desktop_operation(appid);
3823 dlclose(lib_handle);
3829 /* desktop shoud be generated automatically based on manifest */
3830 /* Currently removable, taskmanage, etc fields are not considerd. it will be decided soon.*/
3831 #define BUFMAX 1024*128
3832 static int __ps_make_nativeapp_desktop(manifest_x * mfx, const char *manifest, bool is_update)
3836 char filepath[PKG_STRING_LEN_MAX] = "";
3838 char *buftemp = NULL;
3839 char *locale = NULL;
3841 buf = (char *)calloc(1, BUFMAX);
3843 DBGE("Malloc Failed\n");
3847 buftemp = (char *)calloc(1, BUFMAX);
3849 DBGE("Malloc Failed\n");
3855 __ail_change_info(AIL_CLEAN, mfx->package);
3857 for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) {
3859 if (manifest != NULL) {
3860 /* skip making a deskfile and update ail, if preload app is updated */
3861 if(strstr(manifest, MANIFEST_RO_PREFIX)) {
3862 __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid);
3863 DBGE("preload app is update : skip and update ail : %s", manifest);
3868 if(mfx->readonly && !strcasecmp(mfx->readonly, "True"))
3869 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RO_PATH, mfx->uiapplication->appid);
3871 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, mfx->uiapplication->appid);
3873 /* skip if desktop exists
3874 if (access(filepath, R_OK) == 0)
3878 file = fopen(filepath, "w");
3881 DBGE("Can't open %s", filepath);
3887 snprintf(buf, BUFMAX, "[Desktop Entry]\n");
3888 fwrite(buf, 1, strlen(buf), file);
3890 for( ; mfx->uiapplication->label ; mfx->uiapplication->label = mfx->uiapplication->label->next) {
3891 if(!strcmp(mfx->uiapplication->label->lang, DEFAULT_LOCALE)) {
3892 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
3894 locale = __convert_to_system_locale(mfx->uiapplication->label->lang);
3895 snprintf(buf, BUFMAX, "Name[%s]=%s\n", locale,
3896 mfx->uiapplication->label->text);
3899 fwrite(buf, 1, strlen(buf), file);
3902 if(mfx->uiapplication->label && mfx->uiapplication->label->text) {
3903 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
3904 fwrite(buf, 1, strlen(buf), file);
3907 else if(mfx->label && mfx->label->text) {
3908 snprintf(buf, BUFMAX, "Name=%s\n", mfx->label->text);
3909 fwrite(buf, 1, strlen(buf), file);
3911 snprintf(buf, BUFMAX, "Name=%s\n", mfx->package);
3912 fwrite(buf, 1, strlen(buf), file);
3917 snprintf(buf, BUFMAX, "Type=Application\n");
3918 fwrite(buf, 1, strlen(buf), file);
3920 if(mfx->uiapplication->exec) {
3921 snprintf(buf, BUFMAX, "Exec=%s\n", mfx->uiapplication->exec);
3922 fwrite(buf, 1, strlen(buf), file);
3925 if(mfx->uiapplication->icon && mfx->uiapplication->icon->text) {
3926 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->uiapplication->icon->text);
3927 fwrite(buf, 1, strlen(buf), file);
3928 } else if(mfx->icon && mfx->icon->text) {
3929 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->icon->text);
3930 fwrite(buf, 1, strlen(buf), file);
3934 if(mfx->uiapplication && mfx->uiapplication->appsvc) {
3935 appsvc_x *asvc = mfx->uiapplication->appsvc;
3937 const char *mime = NULL;
3938 const char *mime_delim = "; ";
3941 strncpy(buf, "MimeType=", BUFMAX-1);
3947 DBG("MIME type: %s\n", mime);
3948 strncat(buf, mime, BUFMAX-strlen(buf)-1);
3950 strncat(buf, mime_delim, BUFMAX-strlen(buf)-1);
3958 DBG("MIME types: buf[%s]\n", buf);
3959 DBG("MIME count: %d\n", mime_count);
3961 fwrite(buf, 1, strlen(buf), file);
3965 snprintf(buf, BUFMAX, "Version=%s\n", mfx->version);
3966 fwrite(buf, 1, strlen(buf), file);
3969 if(mfx->uiapplication->nodisplay) {
3970 snprintf(buf, BUFMAX, "NoDisplay=%s\n", mfx->uiapplication->nodisplay);
3971 fwrite(buf, 1, strlen(buf), file);
3974 if(mfx->uiapplication->categories) {
3975 snprintf(buf, BUFMAX, "Categories=%s\n", mfx->uiapplication->categories);
3976 fwrite(buf, 1, strlen(buf), file);
3979 if(mfx->uiapplication->taskmanage && !strcasecmp(mfx->uiapplication->taskmanage, "False")) {
3980 snprintf(buf, BUFMAX, "X-TIZEN-TaskManage=False\n");
3981 fwrite(buf, 1, strlen(buf), file);
3984 if(mfx->uiapplication->enabled && !strcasecmp(mfx->uiapplication->enabled, "False")) {
3985 snprintf(buf, BUFMAX, "X-TIZEN-Enabled=False\n");
3986 fwrite(buf, 1, strlen(buf), file);
3989 if(mfx->uiapplication->hwacceleration) {
3990 snprintf(buf, BUFMAX, "Hw-Acceleration=%s\n", mfx->uiapplication->hwacceleration);
3991 fwrite(buf, 1, strlen(buf), file);
3994 if(mfx->uiapplication->multiple && !strcasecmp(mfx->uiapplication->multiple, "True")) {
3995 snprintf(buf, BUFMAX, "X-TIZEN-Multiple=True\n");
3996 fwrite(buf, 1, strlen(buf), file);
3999 if(mfx->uiapplication->extraid) {
4000 snprintf(buf, BUFMAX, "X-TIZEN-PackageID=%s\n", mfx->uiapplication->extraid);
4001 fwrite(buf, 1, strlen(buf), file);
4004 if(mfx->removable && !strcasecmp(mfx->removable, "False")) {
4005 snprintf(buf, BUFMAX, "X-TIZEN-Removable=False\n");
4006 fwrite(buf, 1, strlen(buf), file);
4010 snprintf(buf, BUFMAX, "X-TIZEN-PackageType=%s\n", mfx->type);
4011 fwrite(buf, 1, strlen(buf), file);
4014 snprintf(buf, BUFMAX, "X-TIZEN-PkgID=%s\n", mfx->package);
4015 fwrite(buf, 1, strlen(buf), file);
4018 // snprintf(buf, BUFMAX, "X-TIZEN-PackageType=rpm\n");
4019 // fwrite(buf, 1, strlen(buf), file);
4022 if(mfx->uiapplication->appsvc) {
4023 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
4024 DBG("buf[%s]\n", buf);
4027 uiapplication_x *up = mfx->uiapplication;
4028 appsvc_x *asvc = NULL;
4029 operation_x *op = NULL;
4032 subapp_x *sub = NULL;
4033 const char *operation = NULL;
4034 const char *mime = NULL;
4035 const char *uri = NULL;
4036 const char *subapp = NULL;
4041 while(asvc != NULL) {
4042 op = asvc->operation;
4045 operation = op->name;
4064 strncpy(buftemp, buf, BUFMAX);
4065 snprintf(buf, BUFMAX, "%s;", buftemp);
4069 strncpy(buftemp, buf, BUFMAX);
4070 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
4071 DBG("buf[%s]\n", buf);
4076 } while(ui != NULL);
4080 }while(sub != NULL);
4093 fwrite(buf, 1, strlen(buf), file);
4095 // strncpy(buftemp, buf, BUFMAX);
4096 // snprintf(buf, BUFMAX, "%s\n", buftemp);
4097 // fwrite(buf, 1, strlen(buf), file);
4100 if(mfx->uiapplication->appcontrol) {
4101 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
4102 DBG("buf[%s]\n", buf);
4104 uiapplication_x *up = mfx->uiapplication;
4105 appcontrol_x *acontrol = NULL;
4106 operation_x *op = NULL;
4109 subapp_x *sub = NULL;
4110 const char *operation = NULL;
4111 const char *mime = NULL;
4112 const char *uri = NULL;
4113 const char *subapp = NULL;
4116 acontrol = up->appcontrol;
4117 while(acontrol != NULL) {
4118 op = acontrol->operation;
4121 operation = op->name;
4122 mi = acontrol->mime;
4128 sub = acontrol->subapp;
4140 strncpy(buftemp, buf, BUFMAX);
4141 snprintf(buf, BUFMAX, "%s;", buftemp);
4144 strncpy(buftemp, buf, BUFMAX);
4145 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
4146 DBG("buf[%s]\n", buf);
4151 } while(ui != NULL);
4155 }while(sub != NULL);
4164 acontrol = acontrol->next;
4168 fwrite(buf, 1, strlen(buf), file);
4170 // strncpy(buftemp, buf, BUFMAX);
4171 // snprintf(buf, BUFMAX, "%s\n", buftemp);
4172 // fwrite(buf, 1, strlen(buf), file);
4180 __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid);
4189 static int __ps_remove_nativeapp_desktop(manifest_x *mfx)
4191 char filepath[PKG_STRING_LEN_MAX] = "";
4193 uiapplication_x *uiapplication = mfx->uiapplication;
4195 for(; uiapplication; uiapplication=uiapplication->next) {
4196 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, uiapplication->appid);
4198 __ail_change_info(AIL_REMOVE, uiapplication->appid);
4200 ret = remove(filepath);
4208 #define LIBAPPSVC_PATH "/usr/lib/libappsvc.so.0"
4210 static int __ps_remove_appsvc_db(manifest_x *mfx)
4212 void *lib_handle = NULL;
4213 int (*appsvc_operation) (const char *);
4215 uiapplication_x *uiapplication = mfx->uiapplication;
4217 if ((lib_handle = dlopen(LIBAPPSVC_PATH, RTLD_LAZY)) == NULL) {
4218 DBGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAPPSVC_PATH);
4222 if ((appsvc_operation =
4223 dlsym(lib_handle, "appsvc_unset_defapp")) == NULL || dlerror() != NULL) {
4224 DBGE("can not find symbol \n");
4228 for(; uiapplication; uiapplication=uiapplication->next) {
4229 ret = appsvc_operation(uiapplication->appid);
4231 DBGE("can not operation symbol \n");
4236 dlclose(lib_handle);
4241 #define PRELOAD_PACKAGE_LIST "/usr/etc/package-manager/preload/preload_list.txt"
4242 static int __add_preload_info(manifest_x * mfx, const char *manifest)
4245 char buffer[1024] = { 0 };
4248 if(strstr(manifest, MANIFEST_RO_PREFIX)) {
4249 free((void *)mfx->readonly);
4250 mfx->readonly = strdup("True");
4252 free((void *)mfx->preload);
4253 mfx->preload = strdup("True");
4255 free((void *)mfx->removable);
4256 mfx->removable = strdup("False");
4261 fp = fopen(PRELOAD_PACKAGE_LIST, "r");
4263 DBGE("no preload list\n");
4267 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
4268 if (buffer[0] == '#') {
4269 if(strcasestr(buffer, "RW_NORM"))
4271 else if(strcasestr(buffer, "RW_RM"))
4279 if(!strcmp(mfx->package, buffer)) {
4280 free((void *)mfx->preload);
4281 mfx->preload = strdup("True");
4283 free((void *)mfx->readonly);
4284 mfx->readonly = strdup("False");
4285 free((void *)mfx->removable);
4286 mfx->removable = strdup("False");
4287 } else if(state == 3){
4288 free((void *)mfx->readonly);
4289 mfx->readonly = strdup("False");
4290 free((void *)mfx->removable);
4291 mfx->removable = strdup("True");
4295 memset(buffer, 0x00, sizeof(buffer));
4304 static int __check_preload_updated(manifest_x * mfx, const char *manifest)
4306 char filepath[PKG_STRING_LEN_MAX] = "";
4308 uiapplication_x *uiapplication = mfx->uiapplication;
4310 if(strstr(manifest, MANIFEST_RO_PREFIX)) {
4311 /* if preload app is updated, then remove previous desktop file on RW*/
4312 for(; uiapplication; uiapplication=uiapplication->next) {
4313 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, uiapplication->appid);
4314 ret = remove(filepath);
4319 /* if downloaded app is updated, then update tag set true*/
4320 free((void *)mfx->update);
4321 mfx->update = strdup("true");
4328 API int pkgmgr_parser_create_desktop_file(manifest_x *mfx)
4332 DBG("Manifest pointer is NULL\n");
4335 ret = __ps_make_nativeapp_desktop(mfx, NULL, 0);
4337 DBG("Creating desktop file failed\n");
4339 DBG("Creating desktop file Success\n");
4343 API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
4348 free((void *)mfx->ns);
4352 free((void *)mfx->package);
4353 mfx->package = NULL;
4356 free((void *)mfx->version);
4357 mfx->version = NULL;
4359 if (mfx->installlocation) {
4360 free((void *)mfx->installlocation);
4361 mfx->installlocation = NULL;
4364 free((void *)mfx->preload);
4365 mfx->preload = NULL;
4367 if (mfx->readonly) {
4368 free((void *)mfx->readonly);
4369 mfx->readonly = NULL;
4371 if (mfx->removable) {
4372 free((void *)mfx->removable);
4373 mfx->removable = NULL;
4376 free((void *)mfx->update);
4380 free((void *)mfx->type);
4383 if (mfx->package_size) {
4384 free((void *)mfx->package_size);
4385 mfx->package_size = NULL;
4387 if (mfx->installed_time) {
4388 free((void *)mfx->installed_time);
4389 mfx->installed_time = NULL;
4391 if (mfx->installed_storage) {
4392 free((void *)mfx->installed_storage);
4393 mfx->installed_storage = NULL;
4395 if (mfx->storeclient_id) {
4396 free((void *)mfx->storeclient_id);
4397 mfx->storeclient_id = NULL;
4399 if (mfx->mainapp_id) {
4400 free((void *)mfx->mainapp_id);
4401 mfx->mainapp_id = NULL;
4403 if (mfx->package_url) {
4404 free((void *)mfx->package_url);
4405 mfx->package_url = NULL;
4407 if (mfx->root_path) {
4408 free((void *)mfx->root_path);
4409 mfx->root_path = NULL;
4411 if (mfx->csc_path) {
4412 free((void *)mfx->csc_path);
4413 mfx->csc_path = NULL;
4415 if (mfx->appsetting) {
4416 free((void *)mfx->appsetting);
4417 mfx->appsetting = NULL;
4419 if (mfx->nodisplay_setting) {
4420 free((void *)mfx->nodisplay_setting);
4421 mfx->nodisplay_setting = NULL;
4426 icon_x *icon = mfx->icon;
4428 while(icon != NULL) {
4430 __ps_free_icon(icon);
4436 label_x *label = mfx->label;
4437 label_x *tmp = NULL;
4438 while(label != NULL) {
4440 __ps_free_label(label);
4446 author_x *author = mfx->author;
4447 author_x *tmp = NULL;
4448 while(author != NULL) {
4450 __ps_free_author(author);
4454 /*Free Description*/
4455 if (mfx->description) {
4456 description_x *description = mfx->description;
4457 description_x *tmp = NULL;
4458 while(description != NULL) {
4459 tmp = description->next;
4460 __ps_free_description(description);
4466 license_x *license = mfx->license;
4467 license_x *tmp = NULL;
4468 while(license != NULL) {
4469 tmp = license->next;
4470 __ps_free_license(license);
4475 if (mfx->privileges) {
4476 privileges_x *privileges = mfx->privileges;
4477 privileges_x *tmp = NULL;
4478 while(privileges != NULL) {
4479 tmp = privileges->next;
4480 __ps_free_privileges(privileges);
4484 /*Free UiApplication*/
4485 if (mfx->uiapplication) {
4486 uiapplication_x *uiapplication = mfx->uiapplication;
4487 uiapplication_x *tmp = NULL;
4488 while(uiapplication != NULL) {
4489 tmp = uiapplication->next;
4490 __ps_free_uiapplication(uiapplication);
4491 uiapplication = tmp;
4494 /*Free ServiceApplication*/
4495 if (mfx->serviceapplication) {
4496 serviceapplication_x *serviceapplication = mfx->serviceapplication;
4497 serviceapplication_x *tmp = NULL;
4498 while(serviceapplication != NULL) {
4499 tmp = serviceapplication->next;
4500 __ps_free_serviceapplication(serviceapplication);
4501 serviceapplication = tmp;
4506 daemon_x *daemon = mfx->daemon;
4507 daemon_x *tmp = NULL;
4508 while(daemon != NULL) {
4510 __ps_free_daemon(daemon);
4516 theme_x *theme = mfx->theme;
4517 theme_x *tmp = NULL;
4518 while(theme != NULL) {
4520 __ps_free_theme(theme);
4526 font_x *font = mfx->font;
4528 while(font != NULL) {
4530 __ps_free_font(font);
4536 ime_x *ime = mfx->ime;
4538 while(ime != NULL) {
4544 /*Free Compatibility*/
4545 if (mfx->compatibility) {
4546 compatibility_x *compatibility = mfx->compatibility;
4547 compatibility_x *tmp = NULL;
4548 while(compatibility != NULL) {
4549 tmp = compatibility->next;
4550 __ps_free_compatibility(compatibility);
4551 compatibility = tmp;
4554 /*Free DeviceProfile*/
4555 if (mfx->deviceprofile) {
4556 deviceprofile_x *deviceprofile = mfx->deviceprofile;
4557 deviceprofile_x *tmp = NULL;
4558 while(deviceprofile != NULL) {
4559 tmp = deviceprofile->next;
4560 __ps_free_deviceprofile(deviceprofile);
4561 deviceprofile = tmp;
4569 API manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest)
4571 DBG("parsing start\n");
4572 xmlTextReaderPtr reader;
4573 manifest_x *mfx = NULL;
4575 reader = xmlReaderForFile(manifest, NULL, 0);
4577 mfx = malloc(sizeof(manifest_x));
4579 memset(mfx, '\0', sizeof(manifest_x));
4580 if (__process_manifest(reader, mfx) < 0) {
4581 DBG("Parsing Failed\n");
4582 pkgmgr_parser_free_manifest_xml(mfx);
4585 DBG("Parsing Success\n");
4587 DBG("Memory allocation error\n");
4589 xmlFreeTextReader(reader);
4591 DBG("Unable to create xml reader\n");
4596 /* These APIs are intended to call parser directly */
4598 API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
4600 char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
4601 if (manifest == NULL) {
4602 DBG("argument supplied is NULL\n");
4603 return PMINFO_R_EINVAL;
4605 DBG("parsing manifest for installation: %s\n", manifest);
4606 manifest_x *mfx = NULL;
4608 char roxml_check[PKG_STRING_LEN_MAX] = {'\0'};
4611 mfx = pkgmgr_parser_process_manifest_xml(manifest);
4612 DBG("Parsing Finished\n");
4614 return PMINFO_R_ERROR;
4616 __streamFile(manifest, ACTION_INSTALL, temp, mfx->package);
4617 __add_preload_info(mfx, manifest);
4618 DBG("Added preload infomation\n");
4620 __ps_process_tag(mfx, tagv);
4622 ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
4624 DBG("DB Insert failed\n");
4626 DBG("DB Insert Success\n");
4628 ret = __ps_process_mdparser(mfx, ACTION_INSTALL);
4630 DBG("Creating metadata parser failed\n");
4632 ret = __ps_make_nativeapp_desktop(mfx, NULL, 0);
4634 DBG("Creating desktop file failed\n");
4636 DBG("Creating desktop file Success\n");
4638 pkgmgr_parser_free_manifest_xml(mfx);
4645 API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
4647 char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
4648 if (manifest == NULL) {
4649 DBG("argument supplied is NULL\n");
4650 return PMINFO_R_EINVAL;
4652 DBG("parsing manifest for upgradation: %s\n", manifest);
4653 manifest_x *mfx = NULL;
4655 bool preload = false;
4656 char *csc_path = NULL;
4657 pkgmgrinfo_pkginfo_h handle = NULL;
4660 mfx = pkgmgr_parser_process_manifest_xml(manifest);
4661 DBG("Parsing Finished\n");
4663 return PMINFO_R_ERROR;
4665 __streamFile(manifest, ACTION_UPGRADE, temp, mfx->package);
4666 __add_preload_info(mfx, manifest);
4667 DBG("Added preload infomation\n");
4668 __check_preload_updated(mfx, manifest);
4670 ret = pkgmgrinfo_pkginfo_get_pkginfo(mfx->package, &handle);
4671 if (ret != PMINFO_R_OK)
4672 DBG("pkgmgrinfo_pkginfo_get_pkginfo failed\n");
4674 ret = pkgmgrinfo_pkginfo_is_preload(handle, &preload);
4675 if (ret != PMINFO_R_OK)
4676 DBG("pkgmgrinfo_pkginfo_is_preload failed\n");
4679 free((void *)mfx->preload);
4680 mfx->preload = strdup("true");
4683 ret = pkgmgrinfo_pkginfo_get_csc_path(handle, &csc_path);
4684 if (ret != PMINFO_R_OK)
4685 DBG("pkgmgrinfo_pkginfo_get_csc_path failed\n");
4687 if (csc_path != NULL) {
4689 free((void *)mfx->csc_path);
4690 mfx->csc_path = strdup(csc_path);
4693 ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
4695 DBG("DB Update failed\n");
4697 DBG("DB Update Success\n");
4699 ret = __ps_process_mdparser(mfx, ACTION_UPGRADE);
4701 DBG("Upgrade metadata parser failed\n");
4703 ret = __ps_make_nativeapp_desktop(mfx, manifest, 1);
4705 DBG("Creating desktop file failed\n");
4707 DBG("Creating desktop file Success\n");
4709 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
4710 pkgmgr_parser_free_manifest_xml(mfx);
4717 API int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[])
4719 char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
4720 if (manifest == NULL) {
4721 DBG("argument supplied is NULL\n");
4722 return PMINFO_R_EINVAL;
4724 DBG("parsing manifest for uninstallation: %s\n", manifest);
4725 manifest_x *mfx = NULL;
4728 mfx = pkgmgr_parser_process_manifest_xml(manifest);
4729 DBG("Parsing Finished\n");
4731 return PMINFO_R_ERROR;
4733 __streamFile(manifest, ACTION_UNINSTALL, temp, mfx->package);
4734 __add_preload_info(mfx, manifest);
4735 DBG("Added preload infomation\n");
4737 ret = __ps_process_mdparser(mfx, ACTION_UNINSTALL);
4739 DBG("Removing metadata parser failed\n");
4741 ret = pkgmgr_parser_delete_manifest_info_from_db(mfx);
4743 DBG("DB Delete failed\n");
4745 DBG("DB Delete Success\n");
4747 ret = __ps_remove_nativeapp_desktop(mfx);
4749 DBG("Removing desktop file failed\n");
4751 DBG("Removing desktop file Success\n");
4753 ret = __ps_remove_appsvc_db(mfx);
4755 DBG("Removing appsvc_db failed\n");
4757 DBG("Removing appsvc_db Success\n");
4759 pkgmgr_parser_free_manifest_xml(mfx);
4766 API int pkgmgr_parser_parse_manifest_for_preload()
4768 return pkgmgr_parser_update_preload_info_in_db();
4771 API char *pkgmgr_parser_get_manifest_file(const char *pkgid)
4773 return __pkgid_to_manifest(pkgid);
4776 API int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
4778 return __ps_run_parser(docPtr, tag, ACTION_INSTALL, pkgid);
4781 API int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgid)
4783 return __ps_run_parser(docPtr, tag, ACTION_UPGRADE, pkgid);
4786 API int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
4788 return __ps_run_parser(docPtr, tag, ACTION_UNINSTALL, pkgid);
4791 #define SCHEMA_FILE "/usr/etc/package-manager/preload/manifest.xsd"
4793 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
4795 if (manifest == NULL) {
4796 DBGE("manifest file is NULL\n");
4797 return PMINFO_R_EINVAL;
4800 xmlSchemaParserCtxtPtr ctx;
4801 xmlSchemaValidCtxtPtr vctx;
4802 xmlSchemaPtr xschema;
4803 ctx = xmlSchemaNewParserCtxt(SCHEMA_FILE);
4805 DBGE("xmlSchemaNewParserCtxt() Failed\n");
4806 return PMINFO_R_ERROR;
4808 xschema = xmlSchemaParse(ctx);
4809 if (xschema == NULL) {
4810 DBGE("xmlSchemaParse() Failed\n");
4811 return PMINFO_R_ERROR;
4813 vctx = xmlSchemaNewValidCtxt(xschema);
4815 DBGE("xmlSchemaNewValidCtxt() Failed\n");
4816 return PMINFO_R_ERROR;
4818 xmlSchemaSetValidErrors(vctx, (xmlSchemaValidityErrorFunc) fprintf, (xmlSchemaValidityWarningFunc) fprintf, stderr);
4819 ret = xmlSchemaValidateFile(vctx, manifest, 0);
4821 DBGE("xmlSchemaValidateFile() failed\n");
4822 return PMINFO_R_ERROR;
4823 } else if (ret == 0) {
4824 DBGE("Manifest is Valid\n");
4827 DBGE("Manifest Validation Failed with error code %d\n", ret);
4828 return PMINFO_R_ERROR;
4834 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
4844 DBGE("fork failed\n");
4849 int dev_null_fd = open ("/dev/null", O_RDWR);
4850 if (dev_null_fd >= 0)
4852 dup2 (dev_null_fd, 0);/*stdin*/
4853 dup2 (dev_null_fd, 1);/*stdout*/
4854 dup2 (dev_null_fd, 2);/*stderr*/
4857 if (execl("/usr/bin/xmllint", "xmllint", manifest, "--schema",
4858 SCHEMA_FILE, NULL) < 0) {
4859 DBGE("execl error\n");
4869 while ((err = waitpid(pid, &status, WNOHANG)) != pid) {
4873 DBGE("waitpid failed\n");
4879 if(WIFEXITED(status) && !WEXITSTATUS(status))