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>
38 #include "pkgmgr_parser.h"
39 #include "pkgmgr_parser_internal.h"
40 #include "pkgmgr_parser_db.h"
41 #include "pkgmgr-info.h"
42 #include "pkgmgr_parser_signature.h"
43 #include "pkgmgr-info-debug.h"
48 #define LOG_TAG "PKGMGR_PARSER"
50 #define ASCII(s) (const char *)s
51 #define XMLCHAR(s) (const xmlChar *)s
53 //#define METADATA_PARSER_LIST SYSCONFDIR "/package-manager/parserlib/metadata/metadata_parser_list.txt"
54 #define METADATA_PARSER_LIST SYSCONFDIR "/package-manager/parserlib/metadata/mdparser_list.txt"
55 #define METADATA_PARSER_NAME "metadataparser:"
57 #define CATEGORY_PARSER_LIST SYSCONFDIR "/package-manager/parserlib/category/category_parser_list.txt"
58 #define CATEGORY_PARSER_NAME "categoryparser:"
60 #define TAG_PARSER_LIST SYSCONFDIR "/package-manager/parserlib/tag_parser_list.txt"
61 #define TAG_PARSER_NAME "parserlib:"
63 #define PKG_TAG_LEN_MAX 128
76 /* plugin process_type */
78 PLUGIN_PRE_PROCESS = 0,
80 } PLUGIN_PROCESS_TYPE;
93 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label);
94 static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege);
95 static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privileges);
96 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile);
97 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed);
98 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation);
99 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri);
100 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime);
101 static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp);
102 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition);
103 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notifiation);
104 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category);
105 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata);
106 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission);
107 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility);
108 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution);
109 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request);
110 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define);
111 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc);
112 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions);
113 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare);
114 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon, uid_t uid);
115 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author);
116 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description);
117 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability);
118 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license);
119 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol);
120 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol);
121 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication, uid_t uid);
122 static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication, uid_t uid);
123 static int __ps_process_font(xmlTextReaderPtr reader, font_x *font);
124 static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme);
125 static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon);
126 static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime);
127 static void __ps_free_label(label_x *label);
128 static void __ps_free_privilege(privilege_x *privilege);
129 static void __ps_free_privileges(privileges_x *privileges);
130 static void __ps_free_deviceprofile(deviceprofile_x * deviceprofile);
131 static void __ps_free_allowed(allowed_x *allowed);
132 static void __ps_free_operation(operation_x *operation);
133 static void __ps_free_uri(uri_x *uri);
134 static void __ps_free_mime(mime_x *mime);
135 static void __ps_free_subapp(subapp_x *subapp);
136 static void __ps_free_condition(condition_x *condition);
137 static void __ps_free_notification(notification_x *notifiation);
138 static void __ps_free_category(category_x *category);
139 static void __ps_free_metadata(metadata_x *metadata);
140 static void __ps_free_permission(permission_x *permission);
141 static void __ps_free_compatibility(compatibility_x *compatibility);
142 static void __ps_free_resolution(resolution_x *resolution);
143 static void __ps_free_request(request_x *request);
144 static void __ps_free_define(define_x *define);
145 static void __ps_free_appsvc(appsvc_x *appsvc);
146 static void __ps_free_launchconditions(launchconditions_x *launchconditions);
147 static void __ps_free_datashare(datashare_x *datashare);
148 static void __ps_free_icon(icon_x *icon);
149 static void __ps_free_author(author_x *author);
150 static void __ps_free_description(description_x *description);
151 static void __ps_free_capability(capability_x *capability);
152 static void __ps_free_license(license_x *license);
153 static void __ps_free_appcontrol(appcontrol_x *appcontrol);
154 static void __ps_free_datacontrol(datacontrol_x *datacontrol);
155 static void __ps_free_uiapplication(uiapplication_x *uiapplication);
156 static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication);
157 static void __ps_free_font(font_x *font);
158 static void __ps_free_theme(theme_x *theme);
159 static void __ps_free_daemon(daemon_x *daemon);
160 static void __ps_free_ime(ime_x *ime);
161 static char *__pkgid_to_manifest(const char *pkgid, uid_t uid);
162 static int __next_child_element(xmlTextReaderPtr reader, int depth);
163 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx, uid_t uid);
164 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx, uid_t uid);
165 static void __str_trim(char *input);
166 static char *__get_parser_plugin(const char *type);
167 static int __ps_run_parser(xmlDocPtr docPtr, const char *tag, ACTION_TYPE action, const char *pkgid);
168 static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid);
169 static void __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgid);
170 static void __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid);
171 static int __validate_appid(const char *pkgid, const char *appid, char **newappid);
172 API int __is_admin();
174 void *__open_lib_handle(char *tag)
176 char *lib_path = NULL;
177 void *lib_handle = NULL;
179 lib_path = __get_parser_plugin(tag);
180 retvm_if(!lib_path, NULL, "lib_path get fail");
182 lib_handle = dlopen(lib_path, RTLD_LAZY);
183 retvm_if(lib_handle == NULL, NULL, "dlopen is failed lib_path[%s]", lib_path);
188 void __close_lib_handle(void *lib_handle)
193 static void __str_trim(char *input)
195 char *trim_str = input;
200 while (*input != 0) {
201 if (!isspace(*input)) {
214 uid_t uid = getuid();
215 if ((uid_t) 0 == uid )
223 static int __validate_appid(const char *pkgid, const char *appid, char **newappid)
225 if (!pkgid || !appid || !newappid) {
226 _LOGD("Arg supplied is NULL\n");
229 int pkglen = strlen(pkgid);
230 int applen = strlen(appid);
234 if (strncmp(appid, ".", 1) == 0) {
235 len = pkglen + applen + 1;
236 newapp = calloc(1,len);
237 if (newapp == NULL) {
238 _LOGD("Malloc failed\n");
241 strncpy(newapp, pkgid, pkglen);
242 strncat(newapp, appid, applen);
243 _LOGD("new appid is %s\n", newapp);
247 if (applen < pkglen) {
248 _LOGD("app id is not proper\n");
250 #ifdef _VALIDATE_APPID_
256 if (!strcmp(appid, pkgid)) {
257 _LOGD("appid is proper\n");
261 else if (strncmp(appid, pkgid, pkglen) == 0) {
262 ptr = strstr(appid, pkgid);
264 if (strncmp(ptr, ".", 1) == 0) {
265 _LOGD("appid is proper\n");
270 _LOGD("appid is not proper\n");
272 #ifdef _VALIDATE_APPID_
279 _LOGD("appid is not proper\n");
281 #ifdef _VALIDATE_APPID_
290 static char * __get_tag_by_key(char *md_key)
294 if (md_key == NULL) {
295 _LOGD("md_key is NULL\n");
299 md_tag = strrchr(md_key, 47) + 1;
302 return strdup(md_tag);
305 static char *__get_metadata_parser_plugin(const char *type)
308 char buffer[1024] = { 0 };
309 char temp_path[1024] = { 0 };
313 _LOGE("invalid argument\n");
317 fp = fopen(PKG_PARSER_CONF_PATH, "r");
319 _LOGE("no matching metadata parser\n");
323 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
324 if (buffer[0] == '#')
329 if ((path = strstr(buffer, METADATA_PARSER_NAME)) != NULL) {
330 path = path + strlen(METADATA_PARSER_NAME);
335 memset(buffer, 0x00, 1024);
342 _LOGE("no matching [%s] [%s]\n", METADATA_PARSER_NAME,type);
346 snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
348 return strdup(temp_path);
351 static char *__get_category_parser_plugin(const char *type)
354 char buffer[1024] = { 0 };
355 char temp_path[1024] = { 0 };
359 _LOGE("invalid argument\n");
363 fp = fopen(PKG_PARSER_CONF_PATH, "r");
365 _LOGE("no matching metadata parser\n");
369 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
370 if (buffer[0] == '#')
375 if ((path = strstr(buffer, CATEGORY_PARSER_NAME)) != NULL) {
376 path = path + strlen(CATEGORY_PARSER_NAME);
381 memset(buffer, 0x00, 1024);
388 _LOGE("no matching [%s] [%s]\n", CATEGORY_PARSER_NAME,type);
392 snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
394 return strdup(temp_path);
397 static char *__get_parser_plugin(const char *type)
400 char buffer[1024] = { 0 };
401 char temp_path[1024] = { 0 };
405 _LOGE("invalid argument\n");
409 fp = fopen(PKG_PARSER_CONF_PATH, "r");
411 _LOGE("no matching backendlib\n");
415 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
416 if (buffer[0] == '#')
421 if ((path = strstr(buffer, PKG_PARSERLIB)) != NULL) {
422 path = path + strlen(PKG_PARSERLIB);
426 memset(buffer, 0x00, 1024);
433 _LOGE("no matching backendlib\n");
437 snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
439 return strdup(temp_path);
442 static int __ps_run_tag_parser(void *lib_handle, xmlDocPtr docPtr, const char *tag,
443 ACTION_TYPE action, const char *pkgid)
445 int (*plugin_install) (xmlDocPtr, const char *);
451 ac = "PKGMGR_PARSER_PLUGIN_INSTALL";
454 ac = "PKGMGR_PARSER_PLUGIN_UPGRADE";
456 case ACTION_UNINSTALL:
457 ac = "PKGMGR_PARSER_PLUGIN_UNINSTALL";
463 if ((plugin_install =
464 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
465 _LOGE("can not find symbol[%s] \n", ac);
469 ret = plugin_install(docPtr, pkgid);
470 _LOGD("tag parser[%s, %s] ACTION_TYPE[%d] result[%d]\n", pkgid, tag, action, ret);
476 static int __ps_run_metadata_parser(GList *md_list, const char *tag,
477 ACTION_TYPE action, const char *pkgid, const char *appid)
479 char *lib_path = NULL;
480 void *lib_handle = NULL;
481 int (*metadata_parser_plugin) (const char *, const char *, GList *);
487 ac = "PKGMGR_MDPARSER_PLUGIN_INSTALL";
490 ac = "PKGMGR_MDPARSER_PLUGIN_UPGRADE";
492 case ACTION_UNINSTALL:
493 ac = "PKGMGR_MDPARSER_PLUGIN_UNINSTALL";
499 lib_path = __get_metadata_parser_plugin(tag);
501 _LOGE("get %s parser fail\n", tag);
505 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
506 _LOGE("dlopen is failed lib_path[%s]\n", lib_path);
510 if ((metadata_parser_plugin =
511 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
512 _LOGE("can not find symbol[%s] \n",ac);
516 ret = metadata_parser_plugin(pkgid, appid, md_list);
518 _LOGD("[appid = %s, libpath = %s plugin fail\n", appid, lib_path);
520 _LOGD("[appid = %s, libpath = %s plugin success\n", appid, lib_path);
530 static int __ps_run_category_parser(GList *category_list, const char *tag,
531 ACTION_TYPE action, const char *pkgid, const char *appid)
533 char *lib_path = NULL;
534 void *lib_handle = NULL;
535 int (*category_parser_plugin) (const char *, const char *, GList *);
541 ac = "PKGMGR_CATEGORY_PARSER_PLUGIN_INSTALL";
544 ac = "PKGMGR_CATEGORY_PARSER_PLUGIN_UPGRADE";
546 case ACTION_UNINSTALL:
547 ac = "PKGMGR_CATEGORY_PARSER_PLUGIN_UNINSTALL";
553 lib_path = __get_category_parser_plugin(tag);
555 _LOGE("get %s parser fail\n", tag);
559 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
560 _LOGE("dlopen is failed lib_path[%s]\n", lib_path);
564 if ((category_parser_plugin =
565 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
566 _LOGE("can not find symbol[%s] \n",ac);
570 ret = category_parser_plugin(pkgid, appid, category_list);
572 _LOGD("[appid = %s, libpath = %s plugin fail\n", appid, lib_path);
574 _LOGD("[appid = %s, libpath = %s plugin success\n", appid, lib_path);
584 static int __ps_run_parser(xmlDocPtr docPtr, const char *tag,
585 ACTION_TYPE action, const char *pkgid)
587 char *lib_path = NULL;
588 void *lib_handle = NULL;
589 int (*plugin_install) (xmlDocPtr, const char *);
595 ac = "PKGMGR_PARSER_PLUGIN_INSTALL";
598 ac = "PKGMGR_PARSER_PLUGIN_UPGRADE";
600 case ACTION_UNINSTALL:
601 ac = "PKGMGR_PARSER_PLUGIN_UNINSTALL";
607 lib_path = __get_parser_plugin(tag);
612 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
613 _LOGE("dlopen is failed lib_path[%s]\n", lib_path);
616 if ((plugin_install =
617 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
618 _LOGE("can not find symbol[%s] \n", ac);
622 ret = plugin_install(docPtr, pkgid);
624 _LOGD("[pkgid = %s, libpath = %s plugin fail\n", pkgid, lib_path);
626 _LOGD("[pkgid = %s, libpath = %s plugin success\n", pkgid, lib_path);
636 static char *__pkgid_to_manifest(const char *pkgid, uid_t uid)
642 _LOGE("pkgid is NULL");
646 size = strlen(getUserManifestPath(uid)) + strlen(pkgid) + 10;
647 manifest = malloc(size);
648 if (manifest == NULL) {
652 memset(manifest, '\0', size);
653 snprintf(manifest, size, "%s/%s.xml", getUserManifestPath(uid), pkgid);
655 if (access(manifest, F_OK)) {
656 snprintf(manifest, size, "%s/%s.xml", getUserManifestPath(uid), pkgid);
662 static void __metadata_parser_clear_dir_list(GList* dir_list)
665 __metadata_t* detail = NULL;
668 list = g_list_first(dir_list);
670 detail = (__metadata_t *)list->data;
678 list = g_list_next(list);
680 g_list_free(dir_list);
684 static void __category_parser_clear_dir_list(GList* dir_list)
687 __category_t* detail = NULL;
690 list = g_list_first(dir_list);
692 detail = (__category_t *)list->data;
699 list = g_list_next(list);
701 g_list_free(dir_list);
705 static int __run_tag_parser_prestep(void *lib_handle, xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid)
710 if (xmlTextReaderDepth(reader) != 1) {
711 _LOGE("Node depth is not 1");
715 if (xmlTextReaderNodeType(reader) != 1) {
716 _LOGE("Node type is not 1");
720 const xmlChar *value;
721 name = xmlTextReaderConstName(reader);
723 _LOGE("TEST TEST TES\n");
724 name = BAD_CAST "--";
727 value = xmlTextReaderConstValue(reader);
729 if (xmlStrlen(value) > 40) {
730 _LOGD(" %.40s...", value);
736 name = xmlTextReaderConstName(reader);
738 _LOGE("TEST TEST TES\n");
739 name = BAD_CAST "--";
742 xmlDocPtr docPtr = xmlTextReaderCurrentDoc(reader);
743 xmlDocPtr copyDocPtr = xmlCopyDoc(docPtr, 1);
744 if (copyDocPtr == NULL)
746 xmlNode *rootElement = xmlDocGetRootElement(copyDocPtr);
747 if (rootElement == NULL)
749 xmlNode *cur_node = xmlFirstElementChild(rootElement);
750 if (cur_node == NULL)
752 xmlNode *temp = xmlTextReaderExpand(reader);
755 xmlNode *next_node = NULL;
756 while(cur_node != NULL) {
757 if ( (strcmp(ASCII(temp->name), ASCII(cur_node->name)) == 0) &&
758 (temp->line == cur_node->line) ) {
762 next_node = xmlNextElementSibling(cur_node);
763 xmlUnlinkNode(cur_node);
764 xmlFreeNode(cur_node);
765 cur_node = next_node;
768 if (cur_node == NULL)
770 next_node = xmlNextElementSibling(cur_node);
772 cur_node->next = NULL;
773 next_node->prev = NULL;
774 xmlFreeNodeList(next_node);
775 xmlSetTreeDoc(cur_node, copyDocPtr);
777 xmlSetTreeDoc(cur_node, copyDocPtr);
780 ret = __ps_run_tag_parser(lib_handle, copyDocPtr, ASCII(name), action, pkgid);
786 static int __run_metadata_parser_prestep (manifest_x *mfx, char *md_key, ACTION_TYPE action)
790 char buffer[1024] = { 0, };
791 uiapplication_x *up = mfx->uiapplication;
792 metadata_x *md = NULL;
795 GList *md_list = NULL;
796 __metadata_t *md_detail = NULL;
798 md_tag = __get_tag_by_key(md_key);
799 if (md_tag == NULL) {
800 _LOGD("md_tag is NULL\n");
809 //get glist of metadata key and value combination
810 memset(buffer, 0x00, 1024);
811 snprintf(buffer, 1024, "%s/", md_key);
812 if ((md->key && md->value) && (strncmp(md->key, md_key, strlen(md_key)) == 0) && (strncmp(buffer, md->key, strlen(buffer)) == 0)) {
813 md_detail = (__metadata_t*) calloc(1, sizeof(__metadata_t));
814 if (md_detail == NULL) {
815 _LOGD("Memory allocation failed\n");
819 md_detail->key = (char*) calloc(1, sizeof(char)*(strlen(md->key)+2));
820 if (md_detail->key == NULL) {
821 _LOGD("Memory allocation failed\n");
825 snprintf(md_detail->key, (strlen(md->key)+1), "%s", md->key);
827 md_detail->value = (char*) calloc(1, sizeof(char)*(strlen(md->value)+2));
828 if (md_detail->value == NULL) {
829 _LOGD("Memory allocation failed\n");
830 free(md_detail->key);
834 snprintf(md_detail->value, (strlen(md->value)+1), "%s", md->value);
836 md_list = g_list_append(md_list, (gpointer)md_detail);
842 //send glist to parser when tags for metadata plugin parser exist.
844 ret = __ps_run_metadata_parser(md_list, md_tag, action, mfx->package, up->appid);
846 _LOGD("metadata_parser failed[%d] for tag[%s]\n", ret, md_tag);
849 _LOGD("metadata_parser success for tag[%s]\n", md_tag);
852 __metadata_parser_clear_dir_list(md_list);
860 __metadata_parser_clear_dir_list(md_list);
868 static int __run_category_parser_prestep (manifest_x *mfx, char *category_key, ACTION_TYPE action)
872 char buffer[1024] = { 0, };
873 uiapplication_x *up = mfx->uiapplication;
874 category_x *category = NULL;
875 char *category_tag = NULL;
877 GList *category_list = NULL;
878 __category_t *category_detail = NULL;
880 category_tag = __get_tag_by_key(category_key);
881 if (category_tag == NULL) {
882 _LOGD("md_tag is NULL\n");
888 category = up->category;
889 while (category != NULL)
891 //get glist of category key and value combination
892 memset(buffer, 0x00, 1024);
893 snprintf(buffer, 1024, "%s/", category_key);
894 if ((category->name) && (strncmp(category->name, category_key, strlen(category_key)) == 0)) {
895 category_detail = (__category_t*) calloc(1, sizeof(__category_t));
896 if (category_detail == NULL) {
897 _LOGD("Memory allocation failed\n");
901 category_detail->name = (char*) calloc(1, sizeof(char)*(strlen(category->name)+2));
902 if (category_detail->name == NULL) {
903 _LOGD("Memory allocation failed\n");
904 free(category_detail);
907 snprintf(category_detail->name, (strlen(category->name)+1), "%s", category->name);
909 category_list = g_list_append(category_list, (gpointer)category_detail);
912 category = category->next;
915 //send glist to parser when tags for metadata plugin parser exist.
917 ret = __ps_run_category_parser(category_list, category_tag, action, mfx->package, up->appid);
919 _LOGD("category_parser failed[%d] for tag[%s]\n", ret, category_tag);
921 _LOGD("category_parser success for tag[%s]\n", category_tag);
923 __category_parser_clear_dir_list(category_list);
924 category_list = NULL;
931 __category_parser_clear_dir_list(category_list);
939 static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid)
944 // _LOGD("__run_parser_prestep");
946 if (xmlTextReaderDepth(reader) != 1) {
947 _LOGE("Node depth is not 1");
951 if (xmlTextReaderNodeType(reader) != 1) {
952 _LOGE("Node type is not 1");
956 const xmlChar *value;
957 name = xmlTextReaderConstName(reader);
959 _LOGE("TEST TEST TES\n");
960 name = BAD_CAST "--";
963 value = xmlTextReaderConstValue(reader);
964 _LOGD("%d %d %s %d %d",
965 xmlTextReaderDepth(reader),
966 xmlTextReaderNodeType(reader),
968 xmlTextReaderIsEmptyElement(reader), xmlTextReaderHasValue(reader));
971 if (xmlStrlen(value) > 40) {
972 _LOGD(" %.40s...", value);
978 name = xmlTextReaderConstName(reader);
980 _LOGE("TEST TEST TES\n");
981 name = BAD_CAST "--";
984 xmlDocPtr docPtr = xmlTextReaderCurrentDoc(reader);
985 _LOGD("docPtr->URL %s\n", (char *)docPtr->URL);
986 xmlDocPtr copyDocPtr = xmlCopyDoc(docPtr, 1);
987 if (copyDocPtr == NULL)
989 xmlNode *rootElement = xmlDocGetRootElement(copyDocPtr);
990 if (rootElement == NULL)
992 xmlNode *cur_node = xmlFirstElementChild(rootElement);
993 if (cur_node == NULL)
995 xmlNode *temp = xmlTextReaderExpand(reader);
998 xmlNode *next_node = NULL;
999 while(cur_node != NULL) {
1000 if ( (strcmp(ASCII(temp->name), ASCII(cur_node->name)) == 0) &&
1001 (temp->line == cur_node->line) ) {
1005 next_node = xmlNextElementSibling(cur_node);
1006 xmlUnlinkNode(cur_node);
1007 xmlFreeNode(cur_node);
1008 cur_node = next_node;
1011 if (cur_node == NULL)
1013 next_node = xmlNextElementSibling(cur_node);
1015 cur_node->next = NULL;
1016 next_node->prev = NULL;
1017 xmlFreeNodeList(next_node);
1018 xmlSetTreeDoc(cur_node, copyDocPtr);
1020 xmlSetTreeDoc(cur_node, copyDocPtr);
1026 _LOGD("node type: %d, name: %s children->name: %s last->name: %s\n"
1027 "parent->name: %s next->name: %s prev->name: %s\n",
1028 cur_node->type, cur_node->name,
1029 cur_node->children ? cur_node->children->name : "NULL",
1030 cur_node->last ? cur_node->last->name : "NULL",
1031 cur_node->parent ? cur_node->parent->name : "NULL",
1032 cur_node->next ? cur_node->next->name : "NULL",
1033 cur_node->prev ? cur_node->prev->name : "NULL");
1035 FILE *fp = fopen(tzplatform_mkpath(TZ_SYS_SHARE, "test.xml"), "a");
1036 xmlDocDump(fp, copyDocPtr);
1040 ret = __ps_run_parser(copyDocPtr, ASCII(name), action, pkgid);
1047 __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgid)
1052 switch (xmlTextReaderNodeType(reader)) {
1053 case XML_READER_TYPE_END_ELEMENT:
1055 // _LOGD("XML_READER_TYPE_END_ELEMENT");
1059 case XML_READER_TYPE_ELEMENT:
1061 // Elements without closing tag don't receive
1062 // XML_READER_TYPE_END_ELEMENT event.
1064 const xmlChar *elementName =
1065 xmlTextReaderLocalName(reader);
1066 if (elementName == NULL) {
1067 // _LOGD("elementName %s\n", (char *)elementName);
1071 const xmlChar *nameSpace =
1072 xmlTextReaderConstNamespaceUri(reader);
1074 // _LOGD("nameSpace %s\n", (char *)nameSpace);
1077 _LOGD("XML_READER_TYPE_ELEMENT %s, %s\n",
1078 elementName ? elementName : "NULL",
1079 nameSpace ? nameSpace : "NULL");
1082 _LOGD("__run_parser_prestep pkgid[%s]\n", pkgid);
1083 __run_parser_prestep(reader, action, pkgid);
1087 for (tag = tagv[0]; tag; tag = tagv[++i])
1088 if (strcmp(tag, ASCII(elementName)) == 0) {
1089 _LOGD("__run_parser_prestep tag[%s] pkgid[%s]\n", tag, pkgid);
1090 __run_parser_prestep(reader,
1098 case XML_READER_TYPE_TEXT:
1099 case XML_READER_TYPE_CDATA:
1101 const xmlChar *value = xmlTextReaderConstValue(reader);
1103 // _LOGD("value %s\n", value);
1106 const xmlChar *lang = xmlTextReaderConstXmlLang(reader);
1108 // _LOGD("lang\n", lang);
1111 /* _LOGD("XML_READER_TYPE_TEXT %s, %s\n",
1112 value ? value : "NULL", lang ? lang : "NULL");
1117 // _LOGD("Ignoring Node of Type: %d", xmlTextReaderNodeType(reader));
1123 __processTag(void *lib_handle, xmlTextReaderPtr reader, ACTION_TYPE action, char *tag, const char *pkgid)
1125 switch (xmlTextReaderNodeType(reader)) {
1126 case XML_READER_TYPE_END_ELEMENT:
1130 case XML_READER_TYPE_ELEMENT:
1132 // Elements without closing tag don't receive
1133 const xmlChar *elementName =
1134 xmlTextReaderLocalName(reader);
1135 if (elementName == NULL) {
1139 if (strcmp(tag, ASCII(elementName)) == 0) {
1140 _LOGD("find : tag[%s] ACTION_TYPE[%d] pkg[%s]\n", tag, action, pkgid);
1141 __run_tag_parser_prestep(lib_handle, reader, action, pkgid);
1152 static int __parser_send_tag(void *lib_handle, ACTION_TYPE action, PLUGIN_PROCESS_TYPE process, const char *pkgid)
1154 int (*plugin_install) (const char *);
1158 if (process == PLUGIN_PRE_PROCESS) {
1160 case ACTION_INSTALL:
1161 ac = "PKGMGR_PARSER_PLUGIN_PRE_INSTALL";
1163 case ACTION_UPGRADE:
1164 ac = "PKGMGR_PARSER_PLUGIN_PRE_UPGRADE";
1166 case ACTION_UNINSTALL:
1167 ac = "PKGMGR_PARSER_PLUGIN_PRE_UNINSTALL";
1172 } else if (process == PLUGIN_POST_PROCESS) {
1174 case ACTION_INSTALL:
1175 ac = "PKGMGR_PARSER_PLUGIN_POST_INSTALL";
1177 case ACTION_UPGRADE:
1178 ac = "PKGMGR_PARSER_PLUGIN_POST_UPGRADE";
1180 case ACTION_UNINSTALL:
1181 ac = "PKGMGR_PARSER_PLUGIN_POST_UNINSTALL";
1189 if ((plugin_install =
1190 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
1194 ret = plugin_install(pkgid);
1198 static void __plugin_send_tag(const char *tag, ACTION_TYPE action, PLUGIN_PROCESS_TYPE process, const char *pkgid)
1200 char *lib_path = NULL;
1201 void *lib_handle = NULL;
1202 int (*plugin_install) (const char *);
1206 if (process == PLUGIN_PRE_PROCESS) {
1208 case ACTION_INSTALL:
1209 ac = "PKGMGR_PARSER_PLUGIN_PRE_INSTALL";
1211 case ACTION_UPGRADE:
1212 ac = "PKGMGR_PARSER_PLUGIN_PRE_UPGRADE";
1214 case ACTION_UNINSTALL:
1215 ac = "PKGMGR_PARSER_PLUGIN_PRE_UNINSTALL";
1220 } else if (process == PLUGIN_POST_PROCESS) {
1222 case ACTION_INSTALL:
1223 ac = "PKGMGR_PARSER_PLUGIN_POST_INSTALL";
1225 case ACTION_UPGRADE:
1226 ac = "PKGMGR_PARSER_PLUGIN_POST_UPGRADE";
1228 case ACTION_UNINSTALL:
1229 ac = "PKGMGR_PARSER_PLUGIN_POST_UNINSTALL";
1237 lib_path = __get_parser_plugin(tag);
1242 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
1243 _LOGE("dlopen is failed lib_path[%s] for tag[%s]\n", lib_path, tag);
1246 if ((plugin_install =
1247 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
1248 // _LOGE("can not find symbol[%s] for tag[%s] \n", ac, tag);
1252 ret = plugin_install(pkgid);
1254 _LOGD("[PLUGIN_PROCESS_TYPE[%d] pkgid=%s, tag=%s plugin fail\n", process, pkgid, tag);
1256 _LOGD("[PLUGIN_PROCESS_TYPE[%d] pkgid=%s, tag=%s plugin success\n", process, pkgid, tag);
1262 dlclose(lib_handle);
1266 __plugin_process_tag(char *const tag_list[], ACTION_TYPE action, PLUGIN_PROCESS_TYPE process, const char *pkgid)
1271 for (tag = tag_list[0]; tag; tag = tag_list[++i])
1272 __plugin_send_tag(tag, action, process, pkgid);
1277 __plugin_save_tag(xmlTextReaderPtr reader, char *const tagv[], char *tag_list[])
1281 static int pre_cnt=0;
1283 switch (xmlTextReaderNodeType(reader)) {
1284 case XML_READER_TYPE_ELEMENT:
1286 const xmlChar *elementName = xmlTextReaderLocalName(reader);
1287 if (elementName == NULL) {
1291 for (tag = tag_list[0]; tag; tag = tag_list[++i])
1292 if (strcmp(ASCII(elementName), tag) == 0) {
1296 for (tag = tagv[0]; tag; tag = tagv[++i])
1297 if (strcmp(tag, ASCII(elementName)) == 0) {
1298 tag_list[pre_cnt++] = tag;
1304 // _LOGD("Ignoring Node of Type: %d", xmlTextReaderNodeType(reader));
1310 __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid)
1312 xmlTextReaderPtr reader;
1315 __plugin_process_tag(tagv, action, PLUGIN_PRE_PROCESS, pkgid);
1317 docPtr = xmlReadFile(filename, NULL, 0);
1318 reader = xmlReaderWalker(docPtr);
1319 if (reader != NULL) {
1320 ret = xmlTextReaderRead(reader);
1322 __processNode(reader, action, tagv, pkgid);
1323 ret = xmlTextReaderRead(reader);
1325 xmlFreeTextReader(reader);
1328 _LOGD("%s : failed to parse", filename);
1331 _LOGD("Unable to open %s", filename);
1334 __plugin_process_tag(tagv, action, PLUGIN_POST_PROCESS, pkgid);
1337 static int __next_child_element(xmlTextReaderPtr reader, int depth)
1339 int ret = xmlTextReaderRead(reader);
1340 int cur = xmlTextReaderDepth(reader);
1343 switch (xmlTextReaderNodeType(reader)) {
1344 case XML_READER_TYPE_ELEMENT:
1345 if (cur == depth + 1)
1348 case XML_READER_TYPE_TEXT:
1349 /*text is handled by each function separately*/
1350 if (cur == depth + 1)
1353 case XML_READER_TYPE_END_ELEMENT:
1362 ret = xmlTextReaderRead(reader);
1363 cur = xmlTextReaderDepth(reader);
1368 static bool __check_action_fota(char *const tagv[])
1371 char delims[] = "=";
1372 char *ret_result = NULL;
1379 for (tag = strdup(tagv[0]); tag != NULL; ) {
1380 ret_result = strtok(tag, delims);
1382 /*check tag : fota is true */
1383 if (strcmp(ret_result, "fota") == 0) {
1384 ret_result = strtok(NULL, delims);
1385 if (strcmp(ret_result, "true") == 0) {
1389 _LOGD("tag process [%s]is not defined\n", ret_result);
1393 /*check next value*/
1394 if (tagv[++i] != NULL)
1395 tag = strdup(tagv[i]);
1397 _LOGD("tag process success...%d\n" , ret);
1405 static void __ps_free_category(category_x *category)
1407 if (category == NULL)
1409 if (category->name) {
1410 free((void *)category->name);
1411 category->name = NULL;
1413 free((void*)category);
1417 static void __ps_free_privilege(privilege_x *privilege)
1419 if (privilege == NULL)
1421 if (privilege->text) {
1422 free((void *)privilege->text);
1423 privilege->text = NULL;
1425 free((void*)privilege);
1429 static void __ps_free_privileges(privileges_x *privileges)
1431 if (privileges == NULL)
1434 if (privileges->privilege) {
1435 privilege_x *privilege = privileges->privilege;
1436 privilege_x *tmp = NULL;
1437 while(privilege != NULL) {
1438 tmp = privilege->next;
1439 __ps_free_privilege(privilege);
1443 free((void*)privileges);
1447 static void __ps_free_metadata(metadata_x *metadata)
1449 if (metadata == NULL)
1451 if (metadata->key) {
1452 free((void *)metadata->key);
1453 metadata->key = NULL;
1455 if (metadata->value) {
1456 free((void *)metadata->value);
1457 metadata->value = NULL;
1459 free((void*)metadata);
1463 static void __ps_free_permission(permission_x *permission)
1465 if (permission == NULL)
1467 if (permission->type) {
1468 free((void *)permission->type);
1469 permission->type = NULL;
1471 if (permission->value) {
1472 free((void *)permission->value);
1473 permission->value = NULL;
1475 free((void*)permission);
1479 static void __ps_free_icon(icon_x *icon)
1484 free((void *)icon->text);
1488 free((void *)icon->lang);
1492 free((void *)icon->name);
1495 if (icon->section) {
1496 free((void *)icon->section);
1497 icon->section = NULL;
1500 free((void *)icon->size);
1503 if (icon->resolution) {
1504 free((void *)icon->resolution);
1505 icon->resolution = NULL;
1511 static void __ps_free_image(image_x *image)
1516 free((void *)image->text);
1520 free((void *)image->lang);
1524 free((void *)image->name);
1527 if (image->section) {
1528 free((void *)image->section);
1529 image->section = NULL;
1535 static void __ps_free_operation(operation_x *operation)
1537 if (operation == NULL)
1539 if (operation->text) {
1540 free((void *)operation->text);
1541 operation->text = NULL;
1543 free((void*)operation);
1547 static void __ps_free_uri(uri_x *uri)
1552 free((void *)uri->text);
1559 static void __ps_free_mime(mime_x *mime)
1564 free((void *)mime->text);
1571 static void __ps_free_subapp(subapp_x *subapp)
1576 free((void *)subapp->text);
1577 subapp->text = NULL;
1579 free((void*)subapp);
1583 static void __ps_free_condition(condition_x *condition)
1585 if (condition == NULL)
1587 if (condition->text) {
1588 free((void *)condition->text);
1589 condition->text = NULL;
1591 if (condition->name) {
1592 free((void *)condition->name);
1593 condition->name = NULL;
1595 free((void*)condition);
1599 static void __ps_free_notification(notification_x *notification)
1601 if (notification == NULL)
1603 if (notification->text) {
1604 free((void *)notification->text);
1605 notification->text = NULL;
1607 if (notification->name) {
1608 free((void *)notification->name);
1609 notification->name = NULL;
1611 free((void*)notification);
1612 notification = NULL;
1615 static void __ps_free_compatibility(compatibility_x *compatibility)
1617 if (compatibility == NULL)
1619 if (compatibility->text) {
1620 free((void *)compatibility->text);
1621 compatibility->text = NULL;
1623 if (compatibility->name) {
1624 free((void *)compatibility->name);
1625 compatibility->name = NULL;
1627 free((void*)compatibility);
1628 compatibility = NULL;
1631 static void __ps_free_resolution(resolution_x *resolution)
1633 if (resolution == NULL)
1635 if (resolution->mimetype) {
1636 free((void *)resolution->mimetype);
1637 resolution->mimetype = NULL;
1639 if (resolution->urischeme) {
1640 free((void *)resolution->urischeme);
1641 resolution->urischeme = NULL;
1643 free((void*)resolution);
1647 static void __ps_free_capability(capability_x *capability)
1649 if (capability == NULL)
1651 if (capability->operationid) {
1652 free((void *)capability->operationid);
1653 capability->operationid = NULL;
1656 if (capability->resolution) {
1657 resolution_x *resolution = capability->resolution;
1658 resolution_x *tmp = NULL;
1659 while(resolution != NULL) {
1660 tmp = resolution->next;
1661 __ps_free_resolution(resolution);
1665 free((void*)capability);
1669 static void __ps_free_allowed(allowed_x *allowed)
1671 if (allowed == NULL)
1673 if (allowed->name) {
1674 free((void *)allowed->name);
1675 allowed->name = NULL;
1677 if (allowed->text) {
1678 free((void *)allowed->text);
1679 allowed->text = NULL;
1681 free((void*)allowed);
1685 static void __ps_free_request(request_x *request)
1687 if (request == NULL)
1689 if (request->text) {
1690 free((void *)request->text);
1691 request->text = NULL;
1693 free((void*)request);
1697 static void __ps_free_datacontrol(datacontrol_x *datacontrol)
1699 if (datacontrol == NULL)
1701 if (datacontrol->providerid) {
1702 free((void *)datacontrol->providerid);
1703 datacontrol->providerid = NULL;
1706 if (datacontrol->capability) {
1707 capability_x *capability = datacontrol->capability;
1708 capability_x *tmp = NULL;
1709 while(capability != NULL) {
1710 tmp = capability->next;
1711 __ps_free_capability(capability);
1715 free((void*)datacontrol);
1719 static void __ps_free_launchconditions(launchconditions_x *launchconditions)
1721 if (launchconditions == NULL)
1723 if (launchconditions->text) {
1724 free((void *)launchconditions->text);
1725 launchconditions->text = NULL;
1728 if (launchconditions->condition) {
1729 condition_x *condition = launchconditions->condition;
1730 condition_x *tmp = NULL;
1731 while(condition != NULL) {
1732 tmp = condition->next;
1733 __ps_free_condition(condition);
1737 free((void*)launchconditions);
1738 launchconditions = NULL;
1741 static void __ps_free_appcontrol(appcontrol_x *appcontrol)
1743 if (appcontrol == NULL)
1745 if (appcontrol->text) {
1746 free((void *)appcontrol->text);
1747 appcontrol->text = NULL;
1750 if (appcontrol->operation) {
1751 operation_x *operation = appcontrol->operation;
1752 operation_x *tmp = NULL;
1753 while(operation != NULL) {
1754 tmp = operation->next;
1755 __ps_free_operation(operation);
1760 if (appcontrol->uri) {
1761 uri_x *uri = appcontrol->uri;
1763 while(uri != NULL) {
1770 if (appcontrol->mime) {
1771 mime_x *mime = appcontrol->mime;
1773 while(mime != NULL) {
1775 __ps_free_mime(mime);
1780 if (appcontrol->subapp) {
1781 subapp_x *subapp = appcontrol->subapp;
1782 subapp_x *tmp = NULL;
1783 while(subapp != NULL) {
1785 __ps_free_subapp(subapp);
1789 free((void*)appcontrol);
1793 static void __ps_free_appsvc(appsvc_x *appsvc)
1798 free((void *)appsvc->text);
1799 appsvc->text = NULL;
1802 if (appsvc->operation) {
1803 operation_x *operation = appsvc->operation;
1804 operation_x *tmp = NULL;
1805 while(operation != NULL) {
1806 tmp = operation->next;
1807 __ps_free_operation(operation);
1813 uri_x *uri = appsvc->uri;
1815 while(uri != NULL) {
1823 mime_x *mime = appsvc->mime;
1825 while(mime != NULL) {
1827 __ps_free_mime(mime);
1832 if (appsvc->subapp) {
1833 subapp_x *subapp = appsvc->subapp;
1834 subapp_x *tmp = NULL;
1835 while(subapp != NULL) {
1837 __ps_free_subapp(subapp);
1841 free((void*)appsvc);
1845 static void __ps_free_deviceprofile(deviceprofile_x *deviceprofile)
1850 static void __ps_free_define(define_x *define)
1855 free((void *)define->path);
1856 define->path = NULL;
1859 if (define->request) {
1860 request_x *request = define->request;
1861 request_x *tmp = NULL;
1862 while(request != NULL) {
1863 tmp = request->next;
1864 __ps_free_request(request);
1869 if (define->allowed) {
1870 allowed_x *allowed = define->allowed;
1871 allowed_x *tmp = NULL;
1872 while(allowed != NULL) {
1873 tmp = allowed->next;
1874 __ps_free_allowed(allowed);
1878 free((void*)define);
1882 static void __ps_free_datashare(datashare_x *datashare)
1884 if (datashare == NULL)
1887 if (datashare->define) {
1888 define_x *define = datashare->define;
1889 define_x *tmp = NULL;
1890 while(define != NULL) {
1892 __ps_free_define(define);
1897 if (datashare->request) {
1898 request_x *request = datashare->request;
1899 request_x *tmp = NULL;
1900 while(request != NULL) {
1901 tmp = request->next;
1902 __ps_free_request(request);
1906 free((void*)datashare);
1910 static void __ps_free_label(label_x *label)
1915 free((void *)label->name);
1919 free((void *)label->text);
1923 free((void *)label->lang);
1930 static void __ps_free_author(author_x *author)
1934 if (author->email) {
1935 free((void *)author->email);
1936 author->email = NULL;
1939 free((void *)author->text);
1940 author->text = NULL;
1943 free((void *)author->href);
1944 author->href = NULL;
1947 free((void *)author->lang);
1948 author->lang = NULL;
1950 free((void*)author);
1954 static void __ps_free_description(description_x *description)
1956 if (description == NULL)
1958 if (description->name) {
1959 free((void *)description->name);
1960 description->name = NULL;
1962 if (description->text) {
1963 free((void *)description->text);
1964 description->text = NULL;
1966 if (description->lang) {
1967 free((void *)description->lang);
1968 description->lang = NULL;
1970 free((void*)description);
1974 static void __ps_free_license(license_x *license)
1976 if (license == NULL)
1978 if (license->text) {
1979 free((void *)license->text);
1980 license->text = NULL;
1982 if (license->lang) {
1983 free((void *)license->lang);
1984 license->lang = NULL;
1986 free((void*)license);
1990 static void __ps_free_uiapplication(uiapplication_x *uiapplication)
1992 if (uiapplication == NULL)
1994 if (uiapplication->exec) {
1995 free((void *)uiapplication->exec);
1996 uiapplication->exec = NULL;
1998 if (uiapplication->appid) {
1999 free((void *)uiapplication->appid);
2000 uiapplication->appid = NULL;
2002 if (uiapplication->nodisplay) {
2003 free((void *)uiapplication->nodisplay);
2004 uiapplication->nodisplay = NULL;
2006 if (uiapplication->multiple) {
2007 free((void *)uiapplication->multiple);
2008 uiapplication->multiple = NULL;
2010 if (uiapplication->type) {
2011 free((void *)uiapplication->type);
2012 uiapplication->type = NULL;
2014 if (uiapplication->categories) {
2015 free((void *)uiapplication->categories);
2016 uiapplication->categories = NULL;
2018 if (uiapplication->extraid) {
2019 free((void *)uiapplication->extraid);
2020 uiapplication->extraid = NULL;
2022 if (uiapplication->taskmanage) {
2023 free((void *)uiapplication->taskmanage);
2024 uiapplication->taskmanage = NULL;
2026 if (uiapplication->enabled) {
2027 free((void *)uiapplication->enabled);
2028 uiapplication->enabled = NULL;
2030 if (uiapplication->hwacceleration) {
2031 free((void *)uiapplication->hwacceleration);
2032 uiapplication->hwacceleration = NULL;
2034 if (uiapplication->screenreader) {
2035 free((void *)uiapplication->screenreader);
2036 uiapplication->screenreader = NULL;
2038 if (uiapplication->mainapp) {
2039 free((void *)uiapplication->mainapp);
2040 uiapplication->mainapp = NULL;
2042 if (uiapplication->recentimage) {
2043 free((void *)uiapplication->recentimage);
2044 uiapplication->recentimage = NULL;
2046 if (uiapplication->package) {
2047 free((void *)uiapplication->package);
2048 uiapplication->package = NULL;
2050 if (uiapplication->launchcondition) {
2051 free((void *)uiapplication->launchcondition);
2052 uiapplication->launchcondition = NULL;
2055 if (uiapplication->label) {
2056 label_x *label = uiapplication->label;
2057 label_x *tmp = NULL;
2058 while(label != NULL) {
2060 __ps_free_label(label);
2065 if (uiapplication->icon) {
2066 icon_x *icon = uiapplication->icon;
2068 while(icon != NULL) {
2070 __ps_free_icon(icon);
2075 if (uiapplication->image) {
2076 image_x *image = uiapplication->image;
2077 image_x *tmp = NULL;
2078 while(image != NULL) {
2080 __ps_free_image(image);
2085 if (uiapplication->appcontrol) {
2086 appcontrol_x *appcontrol = uiapplication->appcontrol;
2087 appcontrol_x *tmp = NULL;
2088 while(appcontrol != NULL) {
2089 tmp = appcontrol->next;
2090 __ps_free_appcontrol(appcontrol);
2094 /*Free LaunchConditions*/
2095 if (uiapplication->launchconditions) {
2096 launchconditions_x *launchconditions = uiapplication->launchconditions;
2097 launchconditions_x *tmp = NULL;
2098 while(launchconditions != NULL) {
2099 tmp = launchconditions->next;
2100 __ps_free_launchconditions(launchconditions);
2101 launchconditions = tmp;
2104 /*Free Notification*/
2105 if (uiapplication->notification) {
2106 notification_x *notification = uiapplication->notification;
2107 notification_x *tmp = NULL;
2108 while(notification != NULL) {
2109 tmp = notification->next;
2110 __ps_free_notification(notification);
2115 if (uiapplication->datashare) {
2116 datashare_x *datashare = uiapplication->datashare;
2117 datashare_x *tmp = NULL;
2118 while(datashare != NULL) {
2119 tmp = datashare->next;
2120 __ps_free_datashare(datashare);
2125 if (uiapplication->appsvc) {
2126 appsvc_x *appsvc = uiapplication->appsvc;
2127 appsvc_x *tmp = NULL;
2128 while(appsvc != NULL) {
2130 __ps_free_appsvc(appsvc);
2135 if (uiapplication->category) {
2136 category_x *category = uiapplication->category;
2137 category_x *tmp = NULL;
2138 while(category != NULL) {
2139 tmp = category->next;
2140 __ps_free_category(category);
2145 if (uiapplication->metadata) {
2146 metadata_x *metadata = uiapplication->metadata;
2147 metadata_x *tmp = NULL;
2148 while(metadata != NULL) {
2149 tmp = metadata->next;
2150 __ps_free_metadata(metadata);
2155 if (uiapplication->permission) {
2156 permission_x *permission = uiapplication->permission;
2157 permission_x *tmp = NULL;
2158 while(permission != NULL) {
2159 tmp = permission->next;
2160 __ps_free_permission(permission);
2164 /* _PRODUCT_LAUNCHING_ENHANCED_ START */
2165 if (uiapplication->indicatordisplay) {
2166 free((void *)uiapplication->indicatordisplay);
2167 uiapplication->indicatordisplay = NULL;
2169 if (uiapplication->portraitimg) {
2170 free((void *)uiapplication->portraitimg);
2171 uiapplication->portraitimg = NULL;
2173 if (uiapplication->landscapeimg) {
2174 free((void *)uiapplication->landscapeimg);
2175 uiapplication->landscapeimg = NULL;
2177 /* _PRODUCT_LAUNCHING_ENHANCED_ END */
2178 if (uiapplication->guestmode_visibility) {
2179 free((void *)uiapplication->guestmode_visibility);
2180 uiapplication->guestmode_visibility = NULL;
2182 if (uiapplication->app_component) {
2183 free((void *)uiapplication->app_component);
2184 uiapplication->app_component = NULL;
2186 if (uiapplication->permission_type) {
2187 free((void *)uiapplication->permission_type);
2188 uiapplication->permission_type = NULL;
2190 if (uiapplication->component_type) {
2191 free((void *)uiapplication->component_type);
2192 uiapplication->component_type = NULL;
2194 if (uiapplication->preload) {
2195 free((void *)uiapplication->preload);
2196 uiapplication->preload = NULL;
2198 if (uiapplication->submode) {
2199 free((void *)uiapplication->submode);
2200 uiapplication->submode = NULL;
2202 if (uiapplication->submode_mainid) {
2203 free((void *)uiapplication->submode_mainid);
2204 uiapplication->submode_mainid = NULL;
2207 free((void*)uiapplication);
2208 uiapplication = NULL;
2211 static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication)
2213 if (serviceapplication == NULL)
2215 if (serviceapplication->exec) {
2216 free((void *)serviceapplication->exec);
2217 serviceapplication->exec = NULL;
2219 if (serviceapplication->appid) {
2220 free((void *)serviceapplication->appid);
2221 serviceapplication->appid = NULL;
2223 if (serviceapplication->onboot) {
2224 free((void *)serviceapplication->onboot);
2225 serviceapplication->onboot = NULL;
2227 if (serviceapplication->autorestart) {
2228 free((void *)serviceapplication->autorestart);
2229 serviceapplication->autorestart = NULL;
2231 if (serviceapplication->type) {
2232 free((void *)serviceapplication->type);
2233 serviceapplication->type = NULL;
2235 if (serviceapplication->enabled) {
2236 free((void *)serviceapplication->enabled);
2237 serviceapplication->enabled = NULL;
2239 if (serviceapplication->package) {
2240 free((void *)serviceapplication->package);
2241 serviceapplication->package = NULL;
2243 if (serviceapplication->permission_type) {
2244 free((void *)serviceapplication->permission_type);
2245 serviceapplication->permission_type = NULL;
2248 if (serviceapplication->label) {
2249 label_x *label = serviceapplication->label;
2250 label_x *tmp = NULL;
2251 while(label != NULL) {
2253 __ps_free_label(label);
2258 if (serviceapplication->icon) {
2259 icon_x *icon = serviceapplication->icon;
2261 while(icon != NULL) {
2263 __ps_free_icon(icon);
2268 if (serviceapplication->appcontrol) {
2269 appcontrol_x *appcontrol = serviceapplication->appcontrol;
2270 appcontrol_x *tmp = NULL;
2271 while(appcontrol != NULL) {
2272 tmp = appcontrol->next;
2273 __ps_free_appcontrol(appcontrol);
2277 /*Free DataControl*/
2278 if (serviceapplication->datacontrol) {
2279 datacontrol_x *datacontrol = serviceapplication->datacontrol;
2280 datacontrol_x *tmp = NULL;
2281 while(datacontrol != NULL) {
2282 tmp = datacontrol->next;
2283 __ps_free_datacontrol(datacontrol);
2287 /*Free LaunchConditions*/
2288 if (serviceapplication->launchconditions) {
2289 launchconditions_x *launchconditions = serviceapplication->launchconditions;
2290 launchconditions_x *tmp = NULL;
2291 while(launchconditions != NULL) {
2292 tmp = launchconditions->next;
2293 __ps_free_launchconditions(launchconditions);
2294 launchconditions = tmp;
2297 /*Free Notification*/
2298 if (serviceapplication->notification) {
2299 notification_x *notification = serviceapplication->notification;
2300 notification_x *tmp = NULL;
2301 while(notification != NULL) {
2302 tmp = notification->next;
2303 __ps_free_notification(notification);
2308 if (serviceapplication->datashare) {
2309 datashare_x *datashare = serviceapplication->datashare;
2310 datashare_x *tmp = NULL;
2311 while(datashare != NULL) {
2312 tmp = datashare->next;
2313 __ps_free_datashare(datashare);
2318 if (serviceapplication->appsvc) {
2319 appsvc_x *appsvc = serviceapplication->appsvc;
2320 appsvc_x *tmp = NULL;
2321 while(appsvc != NULL) {
2323 __ps_free_appsvc(appsvc);
2328 if (serviceapplication->category) {
2329 category_x *category = serviceapplication->category;
2330 category_x *tmp = NULL;
2331 while(category != NULL) {
2332 tmp = category->next;
2333 __ps_free_category(category);
2338 if (serviceapplication->metadata) {
2339 metadata_x *metadata = serviceapplication->metadata;
2340 metadata_x *tmp = NULL;
2341 while(metadata != NULL) {
2342 tmp = metadata->next;
2343 __ps_free_metadata(metadata);
2348 if (serviceapplication->permission) {
2349 permission_x *permission = serviceapplication->permission;
2350 permission_x *tmp = NULL;
2351 while(permission != NULL) {
2352 tmp = permission->next;
2353 __ps_free_permission(permission);
2357 free((void*)serviceapplication);
2358 serviceapplication = NULL;
2361 static void __ps_free_font(font_x *font)
2366 free((void *)font->name);
2370 free((void *)font->text);
2377 static void __ps_free_theme(theme_x *theme)
2382 free((void *)theme->name);
2386 free((void *)theme->text);
2393 static void __ps_free_daemon(daemon_x *daemon)
2398 free((void *)daemon->name);
2399 daemon->name = NULL;
2402 free((void *)daemon->text);
2403 daemon->text = NULL;
2405 free((void*)daemon);
2409 static void __ps_free_ime(ime_x *ime)
2414 free((void *)ime->name);
2418 free((void *)ime->text);
2425 int __ps_process_tag_parser(manifest_x *mfx, const char *filename, ACTION_TYPE action)
2427 xmlTextReaderPtr reader;
2431 void *lib_handle = NULL;
2432 char tag[PKG_STRING_LEN_MAX] = { 0 };
2434 fp = fopen(TAG_PARSER_LIST, "r");
2435 retvm_if(fp == NULL, PMINFO_R_ERROR, "no preload list");
2437 while (fgets(tag, sizeof(tag), fp) != NULL) {
2440 lib_handle = __open_lib_handle(tag);
2441 if (lib_handle == NULL)
2444 ret = __parser_send_tag(lib_handle, action, PLUGIN_PRE_PROCESS, mfx->package);
2445 _LOGD("PLUGIN_PRE_PROCESS[%s, %s] ACTION_TYPE[%d] result[%d]\n", mfx->package, tag, action, ret);
2447 docPtr = xmlReadFile(filename, NULL, 0);
2448 reader = xmlReaderWalker(docPtr);
2449 if (reader != NULL) {
2450 ret = xmlTextReaderRead(reader);
2452 __processTag(lib_handle, reader, action, tag, mfx->package);
2453 ret = xmlTextReaderRead(reader);
2455 xmlFreeTextReader(reader);
2458 _LOGD("%s : failed to parse", filename);
2461 _LOGD("Unable to open %s", filename);
2464 ret = __parser_send_tag(lib_handle, action, PLUGIN_POST_PROCESS, mfx->package);
2465 _LOGD("PLUGIN_POST_PROCESS[%s, %s] ACTION_TYPE[%d] result[%d]\n", mfx->package, tag, action, ret);
2467 __close_lib_handle(lib_handle);
2469 memset(tag, 0x00, sizeof(tag));
2478 int __ps_process_metadata_parser(manifest_x *mfx, ACTION_TYPE action)
2480 fprintf(stdout,"__ps_process_metadata_parser\n");
2483 char md_key[PKG_STRING_LEN_MAX] = { 0 };
2485 fp = fopen(METADATA_PARSER_LIST, "r");
2487 _LOGD("no preload list\n");
2491 while (fgets(md_key, sizeof(md_key), fp) != NULL) {
2493 ret = __run_metadata_parser_prestep(mfx, md_key, action);
2495 memset(md_key, 0x00, sizeof(md_key));
2504 int __ps_process_category_parser(manifest_x *mfx, ACTION_TYPE action)
2508 char category_key[PKG_STRING_LEN_MAX] = { 0 };
2510 fp = fopen(CATEGORY_PARSER_LIST, "r");
2512 _LOGD("no category parser list\n");
2516 while (fgets(category_key, sizeof(category_key), fp) != NULL) {
2517 __str_trim(category_key);
2518 ret = __run_category_parser_prestep(mfx, category_key, action);
2520 memset(category_key, 0x00, sizeof(category_key));
2529 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed)
2531 xmlTextReaderRead(reader);
2532 if (xmlTextReaderValue(reader))
2533 allowed->text = ASCII(xmlTextReaderValue(reader));
2537 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation)
2539 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2540 operation->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2541 /* Text does not exist. Only attribute exists
2542 xmlTextReaderRead(reader);
2543 if (xmlTextReaderValue(reader))
2544 operation->text = ASCII(xmlTextReaderValue(reader));
2549 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri)
2551 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2552 uri->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2553 /* Text does not exist. Only attribute exists
2554 xmlTextReaderRead(reader);
2555 if (xmlTextReaderValue(reader))
2556 uri->text = ASCII(xmlTextReaderValue(reader));
2561 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime)
2563 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2564 mime->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2565 /* Text does not exist. Only attribute exists
2566 xmlTextReaderRead(reader);
2567 if (xmlTextReaderValue(reader))
2568 mime->text = ASCII(xmlTextReaderValue(reader));
2573 static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp)
2575 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2576 subapp->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2577 /* Text does not exist. Only attribute exists
2578 xmlTextReaderRead(reader);
2579 if (xmlTextReaderValue(reader))
2580 mime->text = ASCII(xmlTextReaderValue(reader));
2585 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition)
2587 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2588 condition->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2589 xmlTextReaderRead(reader);
2590 if (xmlTextReaderValue(reader))
2591 condition->text = ASCII(xmlTextReaderValue(reader));
2595 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notification)
2597 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2598 notification->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2599 xmlTextReaderRead(reader);
2600 if (xmlTextReaderValue(reader))
2601 notification->text = ASCII(xmlTextReaderValue(reader));
2605 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category)
2607 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2608 category->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2612 static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege)
2614 xmlTextReaderRead(reader);
2615 if (xmlTextReaderValue(reader)) {
2616 privilege->text = ASCII(xmlTextReaderValue(reader));
2621 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata)
2623 if (xmlTextReaderGetAttribute(reader, XMLCHAR("key")))
2624 metadata->key = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("key")));
2625 if (xmlTextReaderGetAttribute(reader, XMLCHAR("value")))
2626 metadata->value = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("value")));
2630 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission)
2632 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
2633 permission->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
2635 xmlTextReaderRead(reader);
2636 if (xmlTextReaderValue(reader))
2637 permission->value = ASCII(xmlTextReaderValue(reader));
2641 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility)
2643 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2644 compatibility->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2645 xmlTextReaderRead(reader);
2646 if (xmlTextReaderValue(reader))
2647 compatibility->text = ASCII(xmlTextReaderValue(reader));
2651 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution)
2653 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")))
2654 resolution->mimetype = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")));
2655 if (xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")))
2656 resolution->urischeme = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")));
2660 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request)
2662 xmlTextReaderRead(reader);
2663 if (xmlTextReaderValue(reader))
2664 request->text = ASCII(xmlTextReaderValue(reader));
2668 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define)
2670 const xmlChar *node;
2673 allowed_x *tmp1 = NULL;
2674 request_x *tmp2 = NULL;
2676 if (xmlTextReaderGetAttribute(reader, XMLCHAR("path")))
2677 define->path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("path")));
2679 depth = xmlTextReaderDepth(reader);
2680 while ((ret = __next_child_element(reader, depth))) {
2681 node = xmlTextReaderConstName(reader);
2683 _LOGD("xmlTextReaderConstName value is NULL\n");
2687 if (!strcmp(ASCII(node), "allowed")) {
2688 allowed_x *allowed= malloc(sizeof(allowed_x));
2689 if (allowed == NULL) {
2690 _LOGD("Malloc Failed\n");
2693 memset(allowed, '\0', sizeof(allowed_x));
2694 LISTADD(define->allowed, allowed);
2695 ret = __ps_process_allowed(reader, allowed);
2696 } else if (!strcmp(ASCII(node), "request")) {
2697 request_x *request = malloc(sizeof(request_x));
2698 if (request == NULL) {
2699 _LOGD("Malloc Failed\n");
2702 memset(request, '\0', sizeof(request_x));
2703 LISTADD(define->request, request);
2704 ret = __ps_process_request(reader, request);
2708 _LOGD("Processing define failed\n");
2712 if (define->allowed) {
2713 LISTHEAD(define->allowed, tmp1);
2714 define->allowed = tmp1;
2716 if (define->request) {
2717 LISTHEAD(define->request, tmp2);
2718 define->request = tmp2;
2723 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol)
2725 const xmlChar *node;
2728 operation_x *tmp1 = NULL;
2730 mime_x *tmp3 = NULL;
2731 subapp_x *tmp4 = NULL;
2733 depth = xmlTextReaderDepth(reader);
2734 while ((ret = __next_child_element(reader, depth))) {
2735 node = xmlTextReaderConstName(reader);
2737 _LOGD("xmlTextReaderConstName value is NULL\n");
2741 if (!strcmp(ASCII(node), "operation")) {
2742 operation_x *operation = malloc(sizeof(operation_x));
2743 if (operation == NULL) {
2744 _LOGD("Malloc Failed\n");
2747 memset(operation, '\0', sizeof(operation_x));
2748 LISTADD(appcontrol->operation, operation);
2749 ret = __ps_process_operation(reader, operation);
2750 _LOGD("operation processing\n");
2751 } else if (!strcmp(ASCII(node), "uri")) {
2752 uri_x *uri= malloc(sizeof(uri_x));
2754 _LOGD("Malloc Failed\n");
2757 memset(uri, '\0', sizeof(uri_x));
2758 LISTADD(appcontrol->uri, uri);
2759 ret = __ps_process_uri(reader, uri);
2760 _LOGD("uri processing\n");
2761 } else if (!strcmp(ASCII(node), "mime")) {
2762 mime_x *mime = malloc(sizeof(mime_x));
2764 _LOGD("Malloc Failed\n");
2767 memset(mime, '\0', sizeof(mime_x));
2768 LISTADD(appcontrol->mime, mime);
2769 ret = __ps_process_mime(reader, mime);
2770 _LOGD("mime processing\n");
2771 } else if (!strcmp(ASCII(node), "subapp")) {
2772 subapp_x *subapp = malloc(sizeof(subapp_x));
2773 if (subapp == NULL) {
2774 _LOGD("Malloc Failed\n");
2777 memset(subapp, '\0', sizeof(subapp_x));
2778 LISTADD(appcontrol->subapp, subapp);
2779 ret = __ps_process_subapp(reader, subapp);
2780 _LOGD("subapp processing\n");
2784 _LOGD("Processing appcontrol failed\n");
2788 if (appcontrol->operation) {
2789 LISTHEAD(appcontrol->operation, tmp1);
2790 appcontrol->operation = tmp1;
2792 if (appcontrol->uri) {
2793 LISTHEAD(appcontrol->uri, tmp2);
2794 appcontrol->uri = tmp2;
2796 if (appcontrol->mime) {
2797 LISTHEAD(appcontrol->mime, tmp3);
2798 appcontrol->mime = tmp3;
2800 if (appcontrol->subapp) {
2801 LISTHEAD(appcontrol->subapp, tmp4);
2802 appcontrol->subapp = tmp4;
2805 xmlTextReaderRead(reader);
2806 if (xmlTextReaderValue(reader))
2807 appcontrol->text = ASCII(xmlTextReaderValue(reader));
2812 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc)
2814 const xmlChar *node;
2817 operation_x *tmp1 = NULL;
2819 mime_x *tmp3 = NULL;
2820 subapp_x *tmp4 = NULL;
2822 depth = xmlTextReaderDepth(reader);
2823 while ((ret = __next_child_element(reader, depth))) {
2824 node = xmlTextReaderConstName(reader);
2826 _LOGD("xmlTextReaderConstName value is NULL\n");
2830 if (!strcmp(ASCII(node), "operation")) {
2831 operation_x *operation = malloc(sizeof(operation_x));
2832 if (operation == NULL) {
2833 _LOGD("Malloc Failed\n");
2836 memset(operation, '\0', sizeof(operation_x));
2837 LISTADD(appsvc->operation, operation);
2838 ret = __ps_process_operation(reader, operation);
2839 _LOGD("operation processing\n");
2840 } else if (!strcmp(ASCII(node), "uri")) {
2841 uri_x *uri= malloc(sizeof(uri_x));
2843 _LOGD("Malloc Failed\n");
2846 memset(uri, '\0', sizeof(uri_x));
2847 LISTADD(appsvc->uri, uri);
2848 ret = __ps_process_uri(reader, uri);
2849 _LOGD("uri processing\n");
2850 } else if (!strcmp(ASCII(node), "mime")) {
2851 mime_x *mime = malloc(sizeof(mime_x));
2853 _LOGD("Malloc Failed\n");
2856 memset(mime, '\0', sizeof(mime_x));
2857 LISTADD(appsvc->mime, mime);
2858 ret = __ps_process_mime(reader, mime);
2859 _LOGD("mime processing\n");
2860 } else if (!strcmp(ASCII(node), "subapp")) {
2861 subapp_x *subapp = malloc(sizeof(subapp_x));
2862 if (subapp == NULL) {
2863 _LOGD("Malloc Failed\n");
2866 memset(subapp, '\0', sizeof(subapp_x));
2867 LISTADD(appsvc->subapp, subapp);
2868 ret = __ps_process_subapp(reader, subapp);
2869 _LOGD("subapp processing\n");
2873 _LOGD("Processing appsvc failed\n");
2877 if (appsvc->operation) {
2878 LISTHEAD(appsvc->operation, tmp1);
2879 appsvc->operation = tmp1;
2882 LISTHEAD(appsvc->uri, tmp2);
2886 LISTHEAD(appsvc->mime, tmp3);
2887 appsvc->mime = tmp3;
2889 if (appsvc->subapp) {
2890 LISTHEAD(appsvc->subapp, tmp4);
2891 appsvc->subapp = tmp4;
2894 xmlTextReaderRead(reader);
2895 if (xmlTextReaderValue(reader))
2896 appsvc->text = ASCII(xmlTextReaderValue(reader));
2902 static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privileges)
2904 const xmlChar *node;
2907 privilege_x *tmp1 = NULL;
2909 depth = xmlTextReaderDepth(reader);
2910 while ((ret = __next_child_element(reader, depth))) {
2911 node = xmlTextReaderConstName(reader);
2913 _LOGD("xmlTextReaderConstName value is NULL\n");
2917 if (strcmp(ASCII(node), "privilege") == 0) {
2918 privilege_x *privilege = malloc(sizeof(privilege_x));
2919 if (privilege == NULL) {
2920 _LOGD("Malloc Failed\n");
2923 memset(privilege, '\0', sizeof(privilege_x));
2924 LISTADD(privileges->privilege, privilege);
2925 ret = __ps_process_privilege(reader, privilege);
2929 _LOGD("Processing privileges failed\n");
2933 if (privileges->privilege) {
2934 LISTHEAD(privileges->privilege, tmp1);
2935 privileges->privilege = tmp1;
2940 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions)
2942 const xmlChar *node;
2945 condition_x *tmp1 = NULL;
2947 depth = xmlTextReaderDepth(reader);
2948 while ((ret = __next_child_element(reader, depth))) {
2949 node = xmlTextReaderConstName(reader);
2951 _LOGD("xmlTextReaderConstName value is NULL\n");
2955 if (strcmp(ASCII(node), "condition") == 0) {
2956 condition_x *condition = malloc(sizeof(condition_x));
2957 if (condition == NULL) {
2958 _LOGD("Malloc Failed\n");
2961 memset(condition, '\0', sizeof(condition_x));
2962 LISTADD(launchconditions->condition, condition);
2963 ret = __ps_process_condition(reader, condition);
2967 _LOGD("Processing launchconditions failed\n");
2971 if (launchconditions->condition) {
2972 LISTHEAD(launchconditions->condition, tmp1);
2973 launchconditions->condition = tmp1;
2976 xmlTextReaderRead(reader);
2977 if (xmlTextReaderValue(reader))
2978 launchconditions->text = ASCII(xmlTextReaderValue(reader));
2983 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare)
2985 const xmlChar *node;
2988 define_x *tmp1 = NULL;
2989 request_x *tmp2 = NULL;
2990 depth = xmlTextReaderDepth(reader);
2991 while ((ret = __next_child_element(reader, depth))) {
2992 node = xmlTextReaderConstName(reader);
2994 _LOGD("xmlTextReaderConstName value is NULL\n");
2998 if (!strcmp(ASCII(node), "define")) {
2999 define_x *define= malloc(sizeof(define_x));
3000 if (define == NULL) {
3001 _LOGD("Malloc Failed\n");
3004 memset(define, '\0', sizeof(define_x));
3005 LISTADD(datashare->define, define);
3006 ret = __ps_process_define(reader, define);
3007 } else if (!strcmp(ASCII(node), "request")) {
3008 request_x *request= malloc(sizeof(request_x));
3009 if (request == NULL) {
3010 _LOGD("Malloc Failed\n");
3013 memset(request, '\0', sizeof(request_x));
3014 LISTADD(datashare->request, request);
3015 ret = __ps_process_request(reader, request);
3019 _LOGD("Processing data-share failed\n");
3023 if (datashare->define) {
3024 LISTHEAD(datashare->define, tmp1);
3025 datashare->define = tmp1;
3027 if (datashare->request) {
3028 LISTHEAD(datashare->request, tmp2);
3029 datashare->request = tmp2;
3035 __get_icon_with_path(const char* icon, uid_t uid)
3040 if (index(icon, '/') == NULL) {
3042 char* iconPath = NULL;
3043 char* icon_with_path = NULL;
3049 /* "db/setting/theme" is not exist */
3051 theme = vconf_get_str("db/setting/theme");
3053 theme = strdup("default");
3059 theme = strdup("default");
3062 len = (0x01 << 7) + strlen(icon) + strlen(package) + strlen(theme);
3063 icon_with_path = malloc(len);
3064 if(icon_with_path == NULL) {
3065 _LOGD("(icon_with_path == NULL) return\n");
3070 memset(icon_with_path, 0, len);
3071 //--------------------------------------------------------------
3072 //workaround to bypass segfault when we use geticon function
3074 if(uid != GLOBAL_USER)
3075 iconPath = tzplatform_getenv(TZ_USER_ICONS);
3077 iconPath = tzplatform_getenv(TZ_SYS_RW_ICONS);
3078 if(access(iconPath, F_OK)) {
3079 struct group *grpinfo = NULL;
3080 const char *name = "users";
3083 mkdir(iconPath, S_IRWXU | S_IRGRP | S_IXGRP | S_IXOTH);
3084 grpinfo = getgrnam(name);
3086 _LOGD("getgrnam(users) returns NULL !");
3088 ret = chown(iconPath, uid, grpinfo->gr_gid);
3090 strerror_r(errno, buf, sizeof(buf));
3091 _LOGD("FAIL : chown %s %d.%d, because %s", iconPath, uid, grpinfo->gr_gid, buf);
3095 if(iconPath == NULL)
3096 _LOGD("Icon path error: %s ",iconPath );
3098 snprintf(icon_with_path, len, "%s/%s/small/%s", iconPath, theme, icon);
3101 if (access(icon_with_path, R_OK) == 0) break;
3102 snprintf(icon_with_path, len, "%s/%s/small/%s", tzplatform_getenv(TZ_SYS_RO_ICONS), theme, icon);
3103 if (access(icon_with_path, R_OK) == 0) break;
3104 _LOGD("cannot find icon %s", icon_with_path);
3105 snprintf(icon_with_path, len,"%s/default/small/%s", iconPath, icon);
3106 if (access(icon_with_path, R_OK) == 0) break;
3107 snprintf(icon_with_path, len, "%s/icons/default/small/%s", tzplatform_getenv(TZ_SYS_RO_ICONS), icon);
3108 if (access(icon_with_path, R_OK) == 0) break;
3110 /* icon path is going to be moved intto the app directory */
3111 _LOGE("icon file must be moved to %s", icon_with_path);
3112 snprintf(icon_with_path, len, "%s/%s/res/icons/%s/small/%s", tzplatform_getenv(TZ_SYS_RW_APP), package, theme, icon);
3113 if (access(icon_with_path, R_OK) == 0) break;
3114 snprintf(icon_with_path, len, "%s/%s/res/icons/%s/small/%s", tzplatform_getenv(TZ_SYS_RO_APP), package, theme, icon);
3115 if (access(icon_with_path, R_OK) == 0) break;
3116 _LOGD("cannot find icon %s", icon_with_path);
3117 snprintf(icon_with_path, len, "%s/%s/res/icons/default/small/%s", tzplatform_getenv(TZ_SYS_RW_APP), package, icon);
3118 if (access(icon_with_path, R_OK) == 0) break;
3119 snprintf(icon_with_path, len, "%s/res/icons/default/small/%s", tzplatform_getenv(TZ_SYS_RO_APP), package, icon);
3120 if (access(icon_with_path, R_OK) == 0) break;
3121 snprintf(icon_with_path, len, "%s/res/images/%s/%s", tzplatform_getenv(TZ_SYS_RO_UG), package, icon);
3122 if (access(icon_with_path, R_OK) == 0) break;
3127 _LOGD("Icon path : %s ---> %s", icon, icon_with_path);
3129 return icon_with_path;
3131 char* confirmed_icon = NULL;
3133 confirmed_icon = strdup(icon);
3134 if (!confirmed_icon)
3136 return confirmed_icon;
3140 static void __ps_process_tag(manifest_x * mfx, char *const tagv[])
3143 char delims[] = "=";
3144 char *ret_result = NULL;
3150 for (tag = strdup(tagv[0]); tag != NULL; ) {
3151 ret_result = strtok(tag, delims);
3153 /*check tag : preload */
3154 if (strcmp(ret_result, "preload") == 0) {
3155 ret_result = strtok(NULL, delims);
3156 if (strcmp(ret_result, "true") == 0) {
3157 free((void *)mfx->preload);
3158 mfx->preload = strdup("true");
3159 } else if (strcmp(ret_result, "false") == 0) {
3160 free((void *)mfx->preload);
3161 mfx->preload = strdup("false");
3163 /*check tag : removable*/
3164 } else if (strcmp(ret_result, "removable") == 0) {
3165 ret_result = strtok(NULL, delims);
3166 if (strcmp(ret_result, "true") == 0){
3167 free((void *)mfx->removable);
3168 mfx->removable = strdup("true");
3169 } else if (strcmp(ret_result, "false") == 0) {
3170 free((void *)mfx->removable);
3171 mfx->removable = strdup("false");
3173 /*check tag : not matched*/
3175 _LOGD("tag process [%s]is not defined\n", ret_result);
3179 /*check next value*/
3180 if (tagv[++i] != NULL)
3181 tag = strdup(tagv[i]);
3183 _LOGD("tag process success...\n");
3189 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon, uid_t uid)
3191 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
3192 icon->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
3193 if (xmlTextReaderConstXmlLang(reader)) {
3194 icon->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3195 if (icon->lang == NULL)
3196 icon->lang = strdup(DEFAULT_LOCALE);
3198 icon->lang = strdup(DEFAULT_LOCALE);
3200 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
3201 icon->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
3202 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
3203 icon->size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
3204 if (xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")))
3205 icon->resolution = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")));
3206 xmlTextReaderRead(reader);
3207 if (xmlTextReaderValue(reader)) {
3208 const char *text = ASCII(xmlTextReaderValue(reader));
3210 icon->text = (const char *)__get_icon_with_path(text, uid);
3218 static int __ps_process_image(xmlTextReaderPtr reader, image_x *image)
3220 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
3221 image->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
3222 if (xmlTextReaderConstXmlLang(reader)) {
3223 image->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3224 if (image->lang == NULL)
3225 image->lang = strdup(DEFAULT_LOCALE);
3227 image->lang = strdup(DEFAULT_LOCALE);
3229 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
3230 image->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
3231 xmlTextReaderRead(reader);
3232 if (xmlTextReaderValue(reader))
3233 image->text = ASCII(xmlTextReaderValue(reader));
3238 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label)
3240 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
3241 label->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
3242 if (xmlTextReaderConstXmlLang(reader)) {
3243 label->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3244 if (label->lang == NULL)
3245 label->lang = strdup(DEFAULT_LOCALE);
3247 label->lang = strdup(DEFAULT_LOCALE);
3248 xmlTextReaderRead(reader);
3249 if (xmlTextReaderValue(reader))
3250 label->text = ASCII(xmlTextReaderValue(reader));
3253 /* _LOGD("lable name %s\n", label->name);
3254 _LOGD("lable lang %s\n", label->lang);
3255 _LOGD("lable text %s\n", label->text);
3261 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author)
3263 if (xmlTextReaderGetAttribute(reader, XMLCHAR("email")))
3264 author->email = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("email")));
3265 if (xmlTextReaderGetAttribute(reader, XMLCHAR("href")))
3266 author->href = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("href")));
3267 if (xmlTextReaderConstXmlLang(reader)) {
3268 author->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3269 if (author->lang == NULL)
3270 author->lang = strdup(DEFAULT_LOCALE);
3272 author->lang = strdup(DEFAULT_LOCALE);
3274 xmlTextReaderRead(reader);
3275 if (xmlTextReaderValue(reader)) {
3276 const char *text = ASCII(xmlTextReaderValue(reader));
3277 if (*text == '\n') {
3278 author->text = NULL;
3282 author->text = ASCII(xmlTextReaderValue(reader));
3287 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description)
3289 if (xmlTextReaderConstXmlLang(reader)) {
3290 description->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3291 if (description->lang == NULL)
3292 description->lang = strdup(DEFAULT_LOCALE);
3294 description->lang = strdup(DEFAULT_LOCALE);
3296 xmlTextReaderRead(reader);
3297 if (xmlTextReaderValue(reader)) {
3298 const char *text = ASCII(xmlTextReaderValue(reader));
3299 if (*text == '\n') {
3300 description->text = NULL;
3304 description->text = ASCII(xmlTextReaderValue(reader));
3309 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license)
3311 if (xmlTextReaderConstXmlLang(reader)) {
3312 license->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3313 if (license->lang == NULL)
3314 license->lang = strdup(DEFAULT_LOCALE);
3316 license->lang = strdup(DEFAULT_LOCALE);
3318 xmlTextReaderRead(reader);
3319 if (xmlTextReaderValue(reader))
3320 license->text = ASCII(xmlTextReaderValue(reader));
3324 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability)
3326 const xmlChar *node;
3329 resolution_x *tmp1 = NULL;
3331 if (xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")))
3332 capability->operationid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")));
3334 depth = xmlTextReaderDepth(reader);
3335 while ((ret = __next_child_element(reader, depth))) {
3336 node = xmlTextReaderConstName(reader);
3338 _LOGD("xmlTextReaderConstName value is NULL\n");
3342 if (!strcmp(ASCII(node), "resolution")) {
3343 resolution_x *resolution = malloc(sizeof(resolution_x));
3344 if (resolution == NULL) {
3345 _LOGD("Malloc Failed\n");
3348 memset(resolution, '\0', sizeof(resolution_x));
3349 LISTADD(capability->resolution, resolution);
3350 ret = __ps_process_resolution(reader, resolution);
3354 _LOGD("Processing capability failed\n");
3359 if (capability->resolution) {
3360 LISTHEAD(capability->resolution, tmp1);
3361 capability->resolution = tmp1;
3367 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol)
3369 const xmlChar *node;
3372 capability_x *tmp1 = NULL;
3374 if (xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")))
3375 datacontrol->providerid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")));
3377 depth = xmlTextReaderDepth(reader);
3378 while ((ret = __next_child_element(reader, depth))) {
3379 node = xmlTextReaderConstName(reader);
3381 _LOGD("xmlTextReaderConstName value is NULL\n");
3385 if (!strcmp(ASCII(node), "capability")) {
3386 capability_x *capability = malloc(sizeof(capability_x));
3387 if (capability == NULL) {
3388 _LOGD("Malloc Failed\n");
3391 memset(capability, '\0', sizeof(capability_x));
3392 LISTADD(datacontrol->capability, capability);
3393 ret = __ps_process_capability(reader, capability);
3397 _LOGD("Processing datacontrol failed\n");
3402 if (datacontrol->capability) {
3403 LISTHEAD(datacontrol->capability, tmp1);
3404 datacontrol->capability = tmp1;
3410 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication, uid_t uid)
3412 fprintf(stdout, "__ps_process_uiapplication\n");
3413 const xmlChar *node;
3416 char *newappid = NULL;
3417 label_x *tmp1 = NULL;
3418 icon_x *tmp2 = NULL;
3419 appsvc_x *tmp3 = NULL;
3420 appcontrol_x *tmp4 = NULL;
3421 launchconditions_x *tmp5 = NULL;
3422 notification_x *tmp6 = NULL;
3423 datashare_x *tmp7 = NULL;
3424 category_x *tmp8 = NULL;
3425 metadata_x *tmp9 = NULL;
3426 image_x *tmp10 = NULL;
3427 permission_x *tmp11 = NULL;
3429 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
3430 uiapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
3431 if (uiapplication->appid == NULL) {
3432 _LOGD("appid cant be NULL\n");
3436 _LOGD("appid is mandatory\n");
3440 ret = __validate_appid(package, uiapplication->appid, &newappid);
3442 _LOGD("appid is not proper\n");
3446 if (uiapplication->appid)
3447 free((void *)uiapplication->appid);
3448 uiapplication->appid = newappid;
3450 uiapplication->package= strdup(package);
3452 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
3453 uiapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
3454 if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay"))) {
3455 uiapplication->nodisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay")));
3456 if (uiapplication->nodisplay == NULL)
3457 uiapplication->nodisplay = strdup("false");
3459 uiapplication->nodisplay = strdup("false");
3461 if (xmlTextReaderGetAttribute(reader, XMLCHAR("multiple"))) {
3462 uiapplication->multiple = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("multiple")));
3463 if (uiapplication->multiple == NULL)
3464 uiapplication->multiple = strdup("false");
3466 uiapplication->multiple = strdup("false");
3468 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
3469 uiapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
3470 if (xmlTextReaderGetAttribute(reader, XMLCHAR("categories")))
3471 uiapplication->categories = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("categories")));
3472 if (xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")))
3473 uiapplication->extraid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")));
3474 if (xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage"))) {
3475 uiapplication->taskmanage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage")));
3476 if (uiapplication->taskmanage == NULL)
3477 uiapplication->taskmanage = strdup("true");
3479 uiapplication->taskmanage = strdup("true");
3481 if (xmlTextReaderGetAttribute(reader, XMLCHAR("enabled"))) {
3482 uiapplication->enabled = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("enabled")));
3483 if (uiapplication->enabled == NULL)
3484 uiapplication->enabled = strdup("true");
3486 uiapplication->enabled = strdup("true");
3488 if (xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration"))) {
3489 uiapplication->hwacceleration = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration")));
3490 if (uiapplication->hwacceleration == NULL)
3491 uiapplication->hwacceleration = strdup("use-system-setting");
3493 uiapplication->hwacceleration = strdup("use-system-setting");
3495 if (xmlTextReaderGetAttribute(reader, XMLCHAR("screen-reader"))) {
3496 uiapplication->screenreader = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("screen-reader")));
3497 if (uiapplication->screenreader == NULL)
3498 uiapplication->screenreader = strdup("use-system-setting");
3500 uiapplication->screenreader = strdup("use-system-setting");
3502 if (xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")))
3503 uiapplication->recentimage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")));
3504 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp"))) {
3505 uiapplication->mainapp = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp")));
3506 if (uiapplication->mainapp == NULL)
3507 uiapplication->mainapp = strdup("false");
3509 uiapplication->mainapp = strdup("false");
3511 if (xmlTextReaderGetAttribute(reader, XMLCHAR("launchcondition"))) {
3512 uiapplication->launchcondition = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("launchcondition")));
3513 if (uiapplication->launchcondition == NULL)
3514 uiapplication->launchcondition = strdup("false");
3516 uiapplication->launchcondition = strdup("false");
3519 if (xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay"))) {
3520 uiapplication->indicatordisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay")));
3521 if (uiapplication->indicatordisplay == NULL)
3522 uiapplication->indicatordisplay = strdup("true");
3524 uiapplication->indicatordisplay = strdup("true");
3526 if (xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")))
3527 uiapplication->portraitimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")));
3529 uiapplication->portraitimg = NULL;
3530 if (xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")))
3531 uiapplication->landscapeimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")));
3533 uiapplication->landscapeimg = NULL;
3534 if (xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility"))) {
3535 uiapplication->guestmode_visibility = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility")));
3536 if (uiapplication->guestmode_visibility == NULL)
3537 uiapplication->guestmode_visibility = strdup("true");
3539 uiapplication->guestmode_visibility = strdup("true");
3541 if (xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type"))) {
3542 uiapplication->permission_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type")));
3543 if (uiapplication->permission_type == NULL)
3544 uiapplication->permission_type = strdup("normal");
3546 uiapplication->permission_type = strdup("normal");
3548 if (xmlTextReaderGetAttribute(reader, XMLCHAR("component-type"))) {
3549 uiapplication->component_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("component-type")));
3550 if (uiapplication->component_type == NULL)
3551 uiapplication->component_type = strdup("uiapp");
3553 uiapplication->component_type = strdup("uiapp");
3555 if (xmlTextReaderGetAttribute(reader, XMLCHAR("submode"))) {
3556 uiapplication->submode = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("submode")));
3557 if (uiapplication->submode == NULL)
3558 uiapplication->submode = strdup("false");
3560 uiapplication->submode = strdup("false");
3562 if (xmlTextReaderGetAttribute(reader, XMLCHAR("submode-mainid")))
3563 uiapplication->submode_mainid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("submode-mainid")));
3565 depth = xmlTextReaderDepth(reader);
3566 while ((ret = __next_child_element(reader, depth))) {
3567 node = xmlTextReaderConstName(reader);
3569 _LOGD("xmlTextReaderConstName value is NULL\n");
3572 if (!strcmp(ASCII(node), "label")) {
3573 label_x *label = malloc(sizeof(label_x));
3574 if (label == NULL) {
3575 _LOGD("Malloc Failed\n");
3578 memset(label, '\0', sizeof(label_x));
3579 LISTADD(uiapplication->label, label);
3580 ret = __ps_process_label(reader, label);
3581 } else if (!strcmp(ASCII(node), "icon")) {
3582 icon_x *icon = malloc(sizeof(icon_x));
3584 _LOGD("Malloc Failed\n");
3587 memset(icon, '\0', sizeof(icon_x));
3588 LISTADD(uiapplication->icon, icon);
3589 ret = __ps_process_icon(reader, icon, uid);
3590 } else if (!strcmp(ASCII(node), "image")) {
3591 image_x *image = malloc(sizeof(image_x));
3592 if (image == NULL) {
3593 _LOGD("Malloc Failed\n");
3596 memset(image, '\0', sizeof(image_x));
3597 LISTADD(uiapplication->image, image);
3598 ret = __ps_process_image(reader, image);
3599 } else if (!strcmp(ASCII(node), "category")) {
3600 category_x *category = malloc(sizeof(category_x));
3601 if (category == NULL) {
3602 _LOGD("Malloc Failed\n");
3605 memset(category, '\0', sizeof(category_x));
3606 LISTADD(uiapplication->category, category);
3607 ret = __ps_process_category(reader, category);
3608 } else if (!strcmp(ASCII(node), "metadata")) {
3609 metadata_x *metadata = malloc(sizeof(metadata_x));
3610 if (metadata == NULL) {
3611 _LOGD("Malloc Failed\n");
3614 memset(metadata, '\0', sizeof(metadata_x));
3615 LISTADD(uiapplication->metadata, metadata);
3616 ret = __ps_process_metadata(reader, metadata);
3617 } else if (!strcmp(ASCII(node), "permission")) {
3618 permission_x *permission = malloc(sizeof(permission_x));
3619 if (permission == NULL) {
3620 _LOGD("Malloc Failed\n");
3623 memset(permission, '\0', sizeof(permission_x));
3624 LISTADD(uiapplication->permission, permission);
3625 ret = __ps_process_permission(reader, permission);
3626 } else if (!strcmp(ASCII(node), "app-control")) {
3627 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
3628 if (appcontrol == NULL) {
3629 _LOGD("Malloc Failed\n");
3632 memset(appcontrol, '\0', sizeof(appcontrol_x));
3633 LISTADD(uiapplication->appcontrol, appcontrol);
3634 ret = __ps_process_appcontrol(reader, appcontrol);
3635 } else if (!strcmp(ASCII(node), "application-service")) {
3636 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
3637 if (appsvc == NULL) {
3638 _LOGD("Malloc Failed\n");
3641 memset(appsvc, '\0', sizeof(appsvc_x));
3642 LISTADD(uiapplication->appsvc, appsvc);
3643 ret = __ps_process_appsvc(reader, appsvc);
3644 } else if (!strcmp(ASCII(node), "data-share")) {
3645 datashare_x *datashare = malloc(sizeof(datashare_x));
3646 if (datashare == NULL) {
3647 _LOGD("Malloc Failed\n");
3650 memset(datashare, '\0', sizeof(datashare_x));
3651 LISTADD(uiapplication->datashare, datashare);
3652 ret = __ps_process_datashare(reader, datashare);
3653 } else if (!strcmp(ASCII(node), "launch-conditions")) {
3654 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
3655 if (launchconditions == NULL) {
3656 _LOGD("Malloc Failed\n");
3659 memset(launchconditions, '\0', sizeof(launchconditions_x));
3660 LISTADD(uiapplication->launchconditions, launchconditions);
3661 ret = __ps_process_launchconditions(reader, launchconditions);
3662 } else if (!strcmp(ASCII(node), "notification")) {
3663 notification_x *notification = malloc(sizeof(notification_x));
3664 if (notification == NULL) {
3665 _LOGD("Malloc Failed\n");
3668 memset(notification, '\0', sizeof(notification_x));
3669 LISTADD(uiapplication->notification, notification);
3670 ret = __ps_process_notification(reader, notification);
3674 _LOGD("Processing uiapplication failed\n");
3679 if (uiapplication->label) {
3680 LISTHEAD(uiapplication->label, tmp1);
3681 uiapplication->label = tmp1;
3683 if (uiapplication->icon) {
3684 LISTHEAD(uiapplication->icon, tmp2);
3685 uiapplication->icon = tmp2;
3687 if (uiapplication->appsvc) {
3688 LISTHEAD(uiapplication->appsvc, tmp3);
3689 uiapplication->appsvc = tmp3;
3691 if (uiapplication->appcontrol) {
3692 LISTHEAD(uiapplication->appcontrol, tmp4);
3693 uiapplication->appcontrol = tmp4;
3695 if (uiapplication->launchconditions) {
3696 LISTHEAD(uiapplication->launchconditions, tmp5);
3697 uiapplication->launchconditions = tmp5;
3699 if (uiapplication->notification) {
3700 LISTHEAD(uiapplication->notification, tmp6);
3701 uiapplication->notification = tmp6;
3703 if (uiapplication->datashare) {
3704 LISTHEAD(uiapplication->datashare, tmp7);
3705 uiapplication->datashare = tmp7;
3707 if (uiapplication->category) {
3708 LISTHEAD(uiapplication->category, tmp8);
3709 uiapplication->category = tmp8;
3711 if (uiapplication->metadata) {
3712 LISTHEAD(uiapplication->metadata, tmp9);
3713 uiapplication->metadata = tmp9;
3715 if (uiapplication->image) {
3716 LISTHEAD(uiapplication->image, tmp10);
3717 uiapplication->image = tmp10;
3719 if (uiapplication->permission) {
3720 LISTHEAD(uiapplication->permission, tmp11);
3721 uiapplication->permission = tmp11;
3727 static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication, uid_t uid)
3729 fprintf(stdout, "__ps_process_serviceapplication\n");
3730 const xmlChar *node;
3733 char *newappid = NULL;
3734 label_x *tmp1 = NULL;
3735 icon_x *tmp2 = NULL;
3736 appsvc_x *tmp3 = NULL;
3737 appcontrol_x *tmp4 = NULL;
3738 datacontrol_x *tmp5 = NULL;
3739 launchconditions_x *tmp6 = NULL;
3740 notification_x *tmp7 = NULL;
3741 datashare_x *tmp8 = NULL;
3742 category_x *tmp9 = NULL;
3743 metadata_x *tmp10 = NULL;
3744 permission_x *tmp11 = NULL;
3746 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
3747 serviceapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
3748 if (serviceapplication->appid == NULL) {
3749 _LOGD("appid cant be NULL\n");
3753 _LOGD("appid is mandatory\n");
3757 ret = __validate_appid(package, serviceapplication->appid, &newappid);
3759 _LOGD("appid is not proper\n");
3763 if (serviceapplication->appid)
3764 free((void *)serviceapplication->appid);
3765 serviceapplication->appid = newappid;
3768 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
3769 serviceapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
3770 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
3771 serviceapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
3772 if (xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot"))) {
3773 serviceapplication->onboot = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot")));
3774 if (serviceapplication->onboot == NULL)
3775 serviceapplication->onboot = strdup("false");
3777 serviceapplication->onboot = strdup("false");
3779 if (xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart"))) {
3780 serviceapplication->autorestart = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart")));
3781 if (serviceapplication->autorestart == NULL)
3782 serviceapplication->autorestart = strdup("false");
3784 serviceapplication->autorestart = strdup("false");
3786 if (xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type"))) {
3787 serviceapplication->permission_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type")));
3788 if (serviceapplication->permission_type == NULL)
3789 serviceapplication->permission_type = strdup("normal");
3791 serviceapplication->permission_type = strdup("normal");
3794 depth = xmlTextReaderDepth(reader);
3795 while ((ret = __next_child_element(reader, depth))) {
3796 node = xmlTextReaderConstName(reader);
3798 _LOGD("xmlTextReaderConstName value is NULL\n");
3802 if (!strcmp(ASCII(node), "label")) {
3803 label_x *label = malloc(sizeof(label_x));
3804 if (label == NULL) {
3805 _LOGD("Malloc Failed\n");
3808 memset(label, '\0', sizeof(label_x));
3809 LISTADD(serviceapplication->label, label);
3810 ret = __ps_process_label(reader, label);
3811 } else if (!strcmp(ASCII(node), "icon")) {
3812 icon_x *icon = malloc(sizeof(icon_x));
3814 _LOGD("Malloc Failed\n");
3817 memset(icon, '\0', sizeof(icon_x));
3818 LISTADD(serviceapplication->icon, icon);
3819 ret = __ps_process_icon(reader, icon, uid);
3820 } else if (!strcmp(ASCII(node), "category")) {
3821 category_x *category = malloc(sizeof(category_x));
3822 if (category == NULL) {
3823 _LOGD("Malloc Failed\n");
3826 memset(category, '\0', sizeof(category_x));
3827 LISTADD(serviceapplication->category, category);
3828 ret = __ps_process_category(reader, category);
3829 } else if (!strcmp(ASCII(node), "metadata")) {
3830 metadata_x *metadata = malloc(sizeof(metadata_x));
3831 if (metadata == NULL) {
3832 _LOGD("Malloc Failed\n");
3835 memset(metadata, '\0', sizeof(metadata_x));
3836 LISTADD(serviceapplication->metadata, metadata);
3837 ret = __ps_process_metadata(reader, metadata);
3838 } else if (!strcmp(ASCII(node), "permission")) {
3839 permission_x *permission = malloc(sizeof(permission_x));
3840 if (permission == NULL) {
3841 _LOGD("Malloc Failed\n");
3844 memset(permission, '\0', sizeof(permission_x));
3845 LISTADD(serviceapplication->permission, permission);
3846 ret = __ps_process_permission(reader, permission);
3847 } else if (!strcmp(ASCII(node), "app-control")) {
3848 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
3849 if (appcontrol == NULL) {
3850 _LOGD("Malloc Failed\n");
3853 memset(appcontrol, '\0', sizeof(appcontrol_x));
3854 LISTADD(serviceapplication->appcontrol, appcontrol);
3855 ret = __ps_process_appcontrol(reader, appcontrol);
3856 } else if (!strcmp(ASCII(node), "application-service")) {
3857 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
3858 if (appsvc == NULL) {
3859 _LOGD("Malloc Failed\n");
3862 memset(appsvc, '\0', sizeof(appsvc_x));
3863 LISTADD(serviceapplication->appsvc, appsvc);
3864 ret = __ps_process_appsvc(reader, appsvc);
3865 } else if (!strcmp(ASCII(node), "data-share")) {
3866 datashare_x *datashare = malloc(sizeof(datashare_x));
3867 if (datashare == NULL) {
3868 _LOGD("Malloc Failed\n");
3871 memset(datashare, '\0', sizeof(datashare_x));
3872 LISTADD(serviceapplication->datashare, datashare);
3873 ret = __ps_process_datashare(reader, datashare);
3874 } else if (!strcmp(ASCII(node), "launch-conditions")) {
3875 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
3876 if (launchconditions == NULL) {
3877 _LOGD("Malloc Failed\n");
3880 memset(launchconditions, '\0', sizeof(launchconditions_x));
3881 LISTADD(serviceapplication->launchconditions, launchconditions);
3882 ret = __ps_process_launchconditions(reader, launchconditions);
3883 } else if (!strcmp(ASCII(node), "notification")) {
3884 notification_x *notification = malloc(sizeof(notification_x));
3885 if (notification == NULL) {
3886 _LOGD("Malloc Failed\n");
3889 memset(notification, '\0', sizeof(notification_x));
3890 LISTADD(serviceapplication->notification, notification);
3891 ret = __ps_process_notification(reader, notification);
3892 } else if (!strcmp(ASCII(node), "data-control")) {
3893 datacontrol_x *datacontrol = malloc(sizeof(datacontrol_x));
3894 if (datacontrol == NULL) {
3895 _LOGD("Malloc Failed\n");
3898 memset(datacontrol, '\0', sizeof(datacontrol_x));
3899 LISTADD(serviceapplication->datacontrol, datacontrol);
3900 ret = __ps_process_datacontrol(reader, datacontrol);
3904 _LOGD("Processing serviceapplication failed\n");
3909 if (serviceapplication->label) {
3910 LISTHEAD(serviceapplication->label, tmp1);
3911 serviceapplication->label = tmp1;
3913 if (serviceapplication->icon) {
3914 LISTHEAD(serviceapplication->icon, tmp2);
3915 serviceapplication->icon = tmp2;
3917 if (serviceapplication->appsvc) {
3918 LISTHEAD(serviceapplication->appsvc, tmp3);
3919 serviceapplication->appsvc = tmp3;
3921 if (serviceapplication->appcontrol) {
3922 LISTHEAD(serviceapplication->appcontrol, tmp4);
3923 serviceapplication->appcontrol = tmp4;
3925 if (serviceapplication->datacontrol) {
3926 LISTHEAD(serviceapplication->datacontrol, tmp5);
3927 serviceapplication->datacontrol = tmp5;
3929 if (serviceapplication->launchconditions) {
3930 LISTHEAD(serviceapplication->launchconditions, tmp6);
3931 serviceapplication->launchconditions = tmp6;
3933 if (serviceapplication->notification) {
3934 LISTHEAD(serviceapplication->notification, tmp7);
3935 serviceapplication->notification = tmp7;
3937 if (serviceapplication->datashare) {
3938 LISTHEAD(serviceapplication->datashare, tmp8);
3939 serviceapplication->datashare = tmp8;
3941 if (serviceapplication->category) {
3942 LISTHEAD(serviceapplication->category, tmp9);
3943 serviceapplication->category = tmp9;
3945 if (serviceapplication->metadata) {
3946 LISTHEAD(serviceapplication->metadata, tmp10);
3947 serviceapplication->metadata = tmp10;
3949 if (serviceapplication->permission) {
3950 LISTHEAD(serviceapplication->permission, tmp11);
3951 serviceapplication->permission = tmp11;
3957 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile)
3959 /*TODO: once policy is set*/
3963 static int __ps_process_font(xmlTextReaderPtr reader, font_x *font)
3965 /*TODO: once policy is set*/
3969 static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme)
3971 /*TODO: once policy is set*/
3975 static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon)
3977 /*TODO: once policy is set*/
3981 static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime)
3983 /*TODO: once policy is set*/
3987 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx, uid_t uid)
3989 _LOGD("__start_process\n");
3990 const xmlChar *node;
3993 label_x *tmp1 = NULL;
3994 author_x *tmp2 = NULL;
3995 description_x *tmp3 = NULL;
3996 license_x *tmp4 = NULL;
3997 uiapplication_x *tmp5 = NULL;
3998 serviceapplication_x *tmp6 = NULL;
3999 daemon_x *tmp7 = NULL;
4000 theme_x *tmp8 = NULL;
4001 font_x *tmp9 = NULL;
4002 ime_x *tmp10 = NULL;
4003 icon_x *tmp11 = NULL;
4004 compatibility_x *tmp12 = NULL;
4005 deviceprofile_x *tmp13 = NULL;
4006 privileges_x *tmp14 = NULL;
4008 depth = xmlTextReaderDepth(reader);
4010 while ((ret = __next_child_element(reader, depth))) {
4011 node = xmlTextReaderConstName(reader);
4013 _LOGD("xmlTextReaderConstName value is NULL\n");
4017 if (!strcmp(ASCII(node), "label")) {
4018 label_x *label = malloc(sizeof(label_x));
4019 if (label == NULL) {
4020 _LOGD("Malloc Failed\n");
4023 memset(label, '\0', sizeof(label_x));
4024 LISTADD(mfx->label, label);
4025 ret = __ps_process_label(reader, label);
4026 } else if (!strcmp(ASCII(node), "author")) {
4027 author_x *author = malloc(sizeof(author_x));
4028 if (author == NULL) {
4029 _LOGD("Malloc Failed\n");
4032 memset(author, '\0', sizeof(author_x));
4033 LISTADD(mfx->author, author);
4034 ret = __ps_process_author(reader, author);
4035 } else if (!strcmp(ASCII(node), "description")) {
4036 description_x *description = malloc(sizeof(description_x));
4037 if (description == NULL) {
4038 _LOGD("Malloc Failed\n");
4041 memset(description, '\0', sizeof(description_x));
4042 LISTADD(mfx->description, description);
4043 ret = __ps_process_description(reader, description);
4044 } else if (!strcmp(ASCII(node), "license")) {
4045 license_x *license = malloc(sizeof(license_x));
4046 if (license == NULL) {
4047 _LOGD("Malloc Failed\n");
4050 memset(license, '\0', sizeof(license_x));
4051 LISTADD(mfx->license, license);
4052 ret = __ps_process_license(reader, license);
4053 } else if (!strcmp(ASCII(node), "privileges")) {
4054 privileges_x *privileges = malloc(sizeof(privileges_x));
4055 if (privileges == NULL) {
4056 _LOGD("Malloc Failed\n");
4059 memset(privileges, '\0', sizeof(privileges_x));
4060 LISTADD(mfx->privileges, privileges);
4061 ret = __ps_process_privileges(reader, privileges);
4062 } else if (!strcmp(ASCII(node), "ui-application")) {
4063 uiapplication_x *uiapplication = malloc(sizeof(uiapplication_x));
4064 if (uiapplication == NULL) {
4065 _LOGD("Malloc Failed\n");
4068 memset(uiapplication, '\0', sizeof(uiapplication_x));
4069 LISTADD(mfx->uiapplication, uiapplication);
4070 ret = __ps_process_uiapplication(reader, uiapplication, uid);
4071 } else if (!strcmp(ASCII(node), "service-application")) {
4072 serviceapplication_x *serviceapplication = malloc(sizeof(serviceapplication_x));
4073 if (serviceapplication == NULL) {
4074 _LOGD("Malloc Failed\n");
4077 memset(serviceapplication, '\0', sizeof(serviceapplication_x));
4078 LISTADD(mfx->serviceapplication, serviceapplication);
4079 ret = __ps_process_serviceapplication(reader, serviceapplication, uid);
4080 } else if (!strcmp(ASCII(node), "daemon")) {
4081 daemon_x *daemon = malloc(sizeof(daemon_x));
4082 if (daemon == NULL) {
4083 _LOGD("Malloc Failed\n");
4086 memset(daemon, '\0', sizeof(daemon_x));
4087 LISTADD(mfx->daemon, daemon);
4088 ret = __ps_process_daemon(reader, daemon);
4089 } else if (!strcmp(ASCII(node), "theme")) {
4090 theme_x *theme = malloc(sizeof(theme_x));
4091 if (theme == NULL) {
4092 _LOGD("Malloc Failed\n");
4095 memset(theme, '\0', sizeof(theme_x));
4096 LISTADD(mfx->theme, theme);
4097 ret = __ps_process_theme(reader, theme);
4098 } else if (!strcmp(ASCII(node), "font")) {
4099 font_x *font = malloc(sizeof(font_x));
4101 _LOGD("Malloc Failed\n");
4104 memset(font, '\0', sizeof(font_x));
4105 LISTADD(mfx->font, font);
4106 ret = __ps_process_font(reader, font);
4107 } else if (!strcmp(ASCII(node), "ime")) {
4108 ime_x *ime = malloc(sizeof(ime_x));
4110 _LOGD("Malloc Failed\n");
4113 memset(ime, '\0', sizeof(ime_x));
4114 LISTADD(mfx->ime, ime);
4115 ret = __ps_process_ime(reader, ime);
4116 } else if (!strcmp(ASCII(node), "icon")) {
4117 icon_x *icon = malloc(sizeof(icon_x));
4119 _LOGD("Malloc Failed\n");
4122 memset(icon, '\0', sizeof(icon_x));
4123 LISTADD(mfx->icon, icon);
4124 ret = __ps_process_icon(reader, icon, uid);
4125 } else if (!strcmp(ASCII(node), "device-profile")) {
4126 deviceprofile_x *deviceprofile = malloc(sizeof(deviceprofile_x));
4127 if (deviceprofile == NULL) {
4128 _LOGD("Malloc Failed\n");
4131 memset(deviceprofile, '\0', sizeof(deviceprofile_x));
4132 LISTADD(mfx->deviceprofile, deviceprofile);
4133 ret = __ps_process_deviceprofile(reader, deviceprofile);
4134 } else if (!strcmp(ASCII(node), "compatibility")) {
4135 compatibility_x *compatibility = malloc(sizeof(compatibility_x));
4136 if (compatibility == NULL) {
4137 _LOGD("Malloc Failed\n");
4140 memset(compatibility, '\0', sizeof(compatibility_x));
4141 LISTADD(mfx->compatibility, compatibility);
4142 ret = __ps_process_compatibility(reader, compatibility);
4143 } else if (!strcmp(ASCII(node), "shortcut-list")) {
4145 } else if (!strcmp(ASCII(node), "livebox")) {
4147 } else if (!strcmp(ASCII(node), "account")) {
4149 } else if (!strcmp(ASCII(node), "notifications")) {
4151 } else if (!strcmp(ASCII(node), "ime")) {
4157 _LOGD("Processing manifest failed\n");
4162 LISTHEAD(mfx->label, tmp1);
4166 LISTHEAD(mfx->author, tmp2);
4169 if (mfx->description) {
4170 LISTHEAD(mfx->description, tmp3);
4171 mfx->description= tmp3;
4174 LISTHEAD(mfx->license, tmp4);
4177 if (mfx->uiapplication) {
4178 LISTHEAD(mfx->uiapplication, tmp5);
4179 mfx->uiapplication = tmp5;
4181 if (mfx->serviceapplication) {
4182 LISTHEAD(mfx->serviceapplication, tmp6);
4183 mfx->serviceapplication = tmp6;
4186 LISTHEAD(mfx->daemon, tmp7);
4190 LISTHEAD(mfx->theme, tmp8);
4194 LISTHEAD(mfx->font, tmp9);
4198 LISTHEAD(mfx->ime, tmp10);
4202 LISTHEAD(mfx->icon, tmp11);
4205 if (mfx->compatibility) {
4206 LISTHEAD(mfx->compatibility, tmp12);
4207 mfx->compatibility= tmp12;
4209 if (mfx->deviceprofile) {
4210 LISTHEAD(mfx->deviceprofile, tmp13);
4211 mfx->deviceprofile= tmp13;
4213 if (mfx->privileges) {
4214 LISTHEAD(mfx->privileges, tmp14);
4215 mfx->privileges = tmp14;
4220 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx, uid_t uid)
4222 const xmlChar *node;
4225 if ((ret = __next_child_element(reader, -1))) {
4226 node = xmlTextReaderConstName(reader);
4228 _LOGD("xmlTextReaderConstName value is NULL\n");
4232 if (!strcmp(ASCII(node), "manifest")) {
4233 if (xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns"))){
4234 mfx->ns = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")));
4236 if (xmlTextReaderGetAttribute(reader, XMLCHAR("package"))) {
4237 mfx->package= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("package")));
4238 if (mfx->package == NULL) {
4239 _LOGD("package cant be NULL\n");
4243 _LOGD("package field is mandatory\n");
4246 package = mfx->package;
4247 if (xmlTextReaderGetAttribute(reader, XMLCHAR("version")))
4248 mfx->version= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("version")));
4249 /*app2ext needs package size for external installation*/
4250 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
4251 mfx->package_size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
4252 if (xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")))
4253 mfx->installlocation = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")));
4254 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
4255 mfx->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
4256 if (xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")))
4257 mfx->root_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")));
4258 if (xmlTextReaderGetAttribute(reader, XMLCHAR("csc_path")))
4259 mfx->csc_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("csc_path")));
4260 if (xmlTextReaderGetAttribute(reader, XMLCHAR("main_package")))
4261 mfx->main_package = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("main_package")));
4262 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting"))) {
4263 mfx->appsetting = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting")));
4264 if (mfx->appsetting == NULL)
4265 mfx->appsetting = strdup("false");
4267 mfx->appsetting = strdup("false");
4269 if (xmlTextReaderGetAttribute(reader, XMLCHAR("storeclient-id")))
4270 mfx->storeclient_id= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("storeclient-id")));
4271 if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay-setting"))) {
4272 mfx->nodisplay_setting = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay-setting")));
4273 if (mfx->nodisplay_setting == NULL)
4274 mfx->nodisplay_setting = strdup("false");
4276 mfx->nodisplay_setting = strdup("false");
4278 if (xmlTextReaderGetAttribute(reader, XMLCHAR("url")))
4279 mfx->package_url= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("url")));
4280 /*Assign default values. If required it will be overwritten in __add_preload_info()*/
4281 mfx->preload = strdup("False");
4282 mfx->removable = strdup("True");
4283 mfx->readonly = strdup("False");
4284 mfx->update = strdup("False");
4285 mfx->system = strdup("False");
4286 char buf[PKG_STRING_LEN_MAX] = {'\0'};
4288 time_t current_time;
4289 time(¤t_time);
4290 snprintf(buf, PKG_STRING_LEN_MAX - 1, "%d", current_time);
4291 val = strndup(buf, PKG_STRING_LEN_MAX - 1);
4292 mfx->installed_time = val;
4293 mfx->installed_storage= strdup("installed_internal");
4295 ret = __start_process(reader, mfx, uid);
4297 _LOGD("No Manifest element found\n");
4304 static char* __convert_to_system_locale(const char *mlocale)
4306 if (mlocale == NULL)
4308 char *locale = NULL;
4309 locale = (char *)calloc(1, 6);
4311 _LOGE("Malloc Failed\n");
4315 strncpy(locale, mlocale, 2);
4316 strncat(locale, "_", 1);
4317 locale[3] = toupper(mlocale[3]);
4318 locale[4] = toupper(mlocale[4]);
4322 #define LIBAIL_PATH LIB_PATH "/libail.so.0"
4324 /* operation_type */
4334 static int __ail_change_info(int op, const char *appid, uid_t uid)
4336 void *lib_handle = NULL;
4340 if ((lib_handle = dlopen(LIBAIL_PATH, RTLD_LAZY)) == NULL) {
4341 _LOGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAIL_PATH);
4345 if(uid != GLOBAL_USER)
4347 int (*ail_desktop_operation) (const char *, uid_t uid);
4350 aop = "ail_usr_desktop_add";
4353 aop = "ail_usr_desktop_update";
4356 aop = "ail_usr_desktop_remove";
4359 aop = "ail_usr_desktop_clean";
4362 aop = "ail_usr_desktop_fota";
4369 if ((ail_desktop_operation =
4370 dlsym(lib_handle, aop)) == NULL || dlerror() != NULL) {
4371 _LOGE("can not find symbol \n");
4375 ret = ail_desktop_operation(appid, uid);
4377 int (*ail_desktop_operation) (const char *);
4380 aop = "ail_desktop_add";
4383 aop = "ail_desktop_update";
4386 aop = "ail_desktop_remove";
4389 aop = "ail_desktop_clean";
4392 aop = "ail_desktop_fota";
4399 if ((ail_desktop_operation =
4400 dlsym(lib_handle, aop)) == NULL || dlerror() != NULL) {
4401 _LOGE("can not find symbol \n");
4405 ret = ail_desktop_operation(appid);
4410 dlclose(lib_handle);
4415 /* desktop shoud be generated automatically based on manifest */
4416 /* Currently removable, taskmanage, etc fields are not considerd. it will be decided soon.*/
4417 #define BUFMAX 1024*128
4418 static int __ps_make_nativeapp_desktop(manifest_x * mfx, const char *manifest, ACTION_TYPE action, uid_t uid)
4422 char filepath[PKG_STRING_LEN_MAX] = "";
4424 char *buftemp = NULL;
4425 char *locale = NULL;
4427 buf = (char *)calloc(1, BUFMAX);
4429 _LOGE("Malloc Failed\n");
4433 buftemp = (char *)calloc(1, BUFMAX);
4435 _LOGE("Malloc Failed\n");
4440 if (action == ACTION_UPGRADE)
4441 __ail_change_info(AIL_CLEAN, mfx->package, uid);
4443 for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) {
4445 if (manifest != NULL) {
4446 /* skip making a deskfile and update ail, if preload app is updated */
4447 if(strstr(manifest, getUserManifestPath(uid))) {
4448 __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid, uid);
4449 _LOGE("preload app is update : skip and update ail : %s", manifest);
4454 snprintf(filepath, sizeof(filepath),"%s%s.desktop", getUserDesktopPath(uid), mfx->uiapplication->appid);
4456 /* skip if desktop exists
4457 if (access(filepath, R_OK) == 0)
4461 file = fopen(filepath, "w");
4464 _LOGD("Can't open %s", filepath);
4470 snprintf(buf, BUFMAX, "[Desktop Entry]\n");
4471 fwrite(buf, 1, strlen(buf), file);
4473 for( ; mfx->uiapplication->label ; mfx->uiapplication->label = mfx->uiapplication->label->next) {
4474 if(!strcmp(mfx->uiapplication->label->lang, DEFAULT_LOCALE)) {
4475 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
4477 locale = __convert_to_system_locale(mfx->uiapplication->label->lang);
4478 snprintf(buf, BUFMAX, "Name[%s]=%s\n", locale,
4479 mfx->uiapplication->label->text);
4482 fwrite(buf, 1, strlen(buf), file);
4485 if(mfx->uiapplication->label && mfx->uiapplication->label->text) {
4486 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
4487 fwrite(buf, 1, strlen(buf), file);
4490 else if(mfx->label && mfx->label->text) {
4491 snprintf(buf, BUFMAX, "Name=%s\n", mfx->label->text);
4492 fwrite(buf, 1, strlen(buf), file);
4494 snprintf(buf, BUFMAX, "Name=%s\n", mfx->package);
4495 fwrite(buf, 1, strlen(buf), file);
4500 snprintf(buf, BUFMAX, "Type=Application\n");
4501 fwrite(buf, 1, strlen(buf), file);
4503 if(mfx->uiapplication->exec) {
4504 snprintf(buf, BUFMAX, "Exec=%s\n", mfx->uiapplication->exec);
4505 fwrite(buf, 1, strlen(buf), file);
4508 if(mfx->uiapplication->icon && mfx->uiapplication->icon->text) {
4509 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->uiapplication->icon->text);
4510 fwrite(buf, 1, strlen(buf), file);
4511 } else if(mfx->icon && mfx->icon->text) {
4512 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->icon->text);
4513 fwrite(buf, 1, strlen(buf), file);
4517 if(mfx->uiapplication && mfx->uiapplication->appsvc) {
4518 appsvc_x *asvc = mfx->uiapplication->appsvc;
4520 const char *mime = NULL;
4521 const char *mime_delim = "; ";
4524 strncpy(buf, "MimeType=", BUFMAX-1);
4530 _LOGD("MIME type: %s\n", mime);
4531 strncat(buf, mime, BUFMAX-strlen(buf)-1);
4533 strncat(buf, mime_delim, BUFMAX-strlen(buf)-1);
4541 _LOGD("MIME types: buf[%s]\n", buf);
4542 _LOGD("MIME count: %d\n", mime_count);
4544 fwrite(buf, 1, strlen(buf), file);
4548 snprintf(buf, BUFMAX, "Version=%s\n", mfx->version);
4549 fwrite(buf, 1, strlen(buf), file);
4552 if(mfx->uiapplication->nodisplay) {
4553 snprintf(buf, BUFMAX, "NoDisplay=%s\n", mfx->uiapplication->nodisplay);
4554 fwrite(buf, 1, strlen(buf), file);
4557 if(mfx->uiapplication->categories) {
4558 snprintf(buf, BUFMAX, "Categories=%s\n", mfx->uiapplication->categories);
4559 fwrite(buf, 1, strlen(buf), file);
4562 if(mfx->uiapplication->taskmanage && !strcasecmp(mfx->uiapplication->taskmanage, "False")) {
4563 snprintf(buf, BUFMAX, "X-TIZEN-TaskManage=False\n");
4564 fwrite(buf, 1, strlen(buf), file);
4567 if(mfx->uiapplication->enabled && !strcasecmp(mfx->uiapplication->enabled, "False")) {
4568 snprintf(buf, BUFMAX, "X-TIZEN-Enabled=False\n");
4569 fwrite(buf, 1, strlen(buf), file);
4572 if(mfx->uiapplication->hwacceleration) {
4573 snprintf(buf, BUFMAX, "Hw-Acceleration=%s\n", mfx->uiapplication->hwacceleration);
4574 fwrite(buf, 1, strlen(buf), file);
4577 if(mfx->uiapplication->multiple && !strcasecmp(mfx->uiapplication->multiple, "True")) {
4578 snprintf(buf, BUFMAX, "X-TIZEN-Multiple=True\n");
4579 fwrite(buf, 1, strlen(buf), file);
4582 if(mfx->uiapplication->extraid) {
4583 snprintf(buf, BUFMAX, "X-TIZEN-PackageID=%s\n", mfx->uiapplication->extraid);
4584 fwrite(buf, 1, strlen(buf), file);
4587 if(mfx->removable && !strcasecmp(mfx->removable, "False")) {
4588 snprintf(buf, BUFMAX, "X-TIZEN-Removable=False\n");
4589 fwrite(buf, 1, strlen(buf), file);
4593 snprintf(buf, BUFMAX, "X-TIZEN-PackageType=%s\n", mfx->type);
4594 fwrite(buf, 1, strlen(buf), file);
4597 if(mfx->uiapplication->submode && !strcasecmp(mfx->uiapplication->submode, "True")) {
4598 snprintf(buf, BUFMAX, "X-TIZEN-Submode=%s\n", mfx->uiapplication->submode);
4599 fwrite(buf, 1, strlen(buf), file);
4600 snprintf(buf, BUFMAX, "X-TIZEN-SubmodeMainid=%s\n", mfx->uiapplication->submode_mainid);
4601 fwrite(buf, 1, strlen(buf), file);
4604 snprintf(buf, BUFMAX, "X-TIZEN-PkgID=%s\n", mfx->package);
4605 fwrite(buf, 1, strlen(buf), file);
4608 // snprintf(buf, BUFMAX, "X-TIZEN-PackageType=rpm\n");
4609 // fwrite(buf, 1, strlen(buf), file);
4612 if(mfx->uiapplication->appsvc) {
4613 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
4614 _LOGD("buf[%s]\n", buf);
4617 uiapplication_x *up = mfx->uiapplication;
4618 appsvc_x *asvc = NULL;
4619 operation_x *op = NULL;
4622 subapp_x *sub = NULL;
4623 const char *operation = NULL;
4624 const char *mime = NULL;
4625 const char *uri = NULL;
4626 const char *subapp = NULL;
4631 while(asvc != NULL) {
4632 op = asvc->operation;
4635 operation = op->name;
4654 strncpy(buftemp, buf, BUFMAX);
4655 snprintf(buf, BUFMAX, "%s;", buftemp);
4659 strncpy(buftemp, buf, BUFMAX);
4660 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
4661 _LOGD("buf[%s]\n", buf);
4666 } while(ui != NULL);
4670 }while(sub != NULL);
4683 fwrite(buf, 1, strlen(buf), file);
4685 // strncpy(buftemp, buf, BUFMAX);
4686 // snprintf(buf, BUFMAX, "%s\n", buftemp);
4687 // fwrite(buf, 1, strlen(buf), file);
4690 if(mfx->uiapplication->appcontrol) {
4691 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
4692 _LOGD("buf[%s]\n", buf);
4694 uiapplication_x *up = mfx->uiapplication;
4695 appcontrol_x *acontrol = NULL;
4696 operation_x *op = NULL;
4699 subapp_x *sub = NULL;
4700 const char *operation = NULL;
4701 const char *mime = NULL;
4702 const char *uri = NULL;
4703 const char *subapp = NULL;
4706 acontrol = up->appcontrol;
4707 while(acontrol != NULL) {
4708 op = acontrol->operation;
4711 operation = op->name;
4712 mi = acontrol->mime;
4718 sub = acontrol->subapp;
4730 strncpy(buftemp, buf, BUFMAX);
4731 snprintf(buf, BUFMAX, "%s;", buftemp);
4734 strncpy(buftemp, buf, BUFMAX);
4735 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
4736 _LOGD("buf[%s]\n", buf);
4741 } while(ui != NULL);
4745 }while(sub != NULL);
4754 acontrol = acontrol->next;
4758 fwrite(buf, 1, strlen(buf), file);
4760 // strncpy(buftemp, buf, BUFMAX);
4761 // snprintf(buf, BUFMAX, "%s\n", buftemp);
4762 // fwrite(buf, 1, strlen(buf), file);
4769 if (action == ACTION_FOTA)
4770 __ail_change_info(AIL_FOTA, mfx->uiapplication->appid, uid);
4772 __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid, uid);
4781 static int __ps_remove_nativeapp_desktop(manifest_x *mfx, uid_t uid)
4783 char filepath[PKG_STRING_LEN_MAX] = "";
4785 uiapplication_x *uiapplication = mfx->uiapplication;
4787 for(; uiapplication; uiapplication=uiapplication->next) {
4788 snprintf(filepath, sizeof(filepath),"%s%s.desktop", getUserDesktopPath(uid), uiapplication->appid);
4790 __ail_change_info(AIL_REMOVE, uiapplication->appid, uid);
4792 ret = remove(filepath);
4800 #define LIBAPPSVC_PATH LIB_PATH "/libappsvc.so.0"
4802 static int __ps_remove_appsvc_db(manifest_x *mfx)
4804 void *lib_handle = NULL;
4805 int (*appsvc_operation) (const char *);
4807 uiapplication_x *uiapplication = mfx->uiapplication;
4809 if ((lib_handle = dlopen(LIBAPPSVC_PATH, RTLD_LAZY)) == NULL) {
4810 _LOGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAPPSVC_PATH);
4814 if ((appsvc_operation =
4815 dlsym(lib_handle, "appsvc_unset_defapp")) == NULL || dlerror() != NULL) {
4816 _LOGE("can not find symbol \n");
4820 for(; uiapplication; uiapplication=uiapplication->next) {
4821 ret = appsvc_operation(uiapplication->appid);
4823 _LOGE("can not operation symbol \n");
4828 dlclose(lib_handle);
4833 #define PRELOAD_PACKAGE_LIST SYSCONFDIR "/package-manager/preload/preload_list.txt"
4834 static int __add_preload_info(manifest_x * mfx, const char *manifest, uid_t uid)
4837 char buffer[1024] = { 0 };
4840 if(strstr(manifest, getUserManifestPath(uid))) {
4841 free((void *)mfx->readonly);
4842 mfx->readonly = strdup("True");
4844 free((void *)mfx->preload);
4845 mfx->preload = strdup("True");
4847 free((void *)mfx->removable);
4848 mfx->removable = strdup("False");
4850 free((void *)mfx->system);
4851 mfx->system = strdup("True");
4856 fp = fopen(PRELOAD_PACKAGE_LIST, "r");
4858 _LOGE("no preload list\n");
4862 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
4863 if (buffer[0] == '#') {
4864 if(strcasestr(buffer, "RW_NORM"))
4866 else if(strcasestr(buffer, "RW_RM"))
4874 if(!strcmp(mfx->package, buffer)) {
4875 free((void *)mfx->preload);
4876 mfx->preload = strdup("True");
4878 free((void *)mfx->readonly);
4879 mfx->readonly = strdup("False");
4880 free((void *)mfx->removable);
4881 mfx->removable = strdup("False");
4882 } else if(state == 3){
4883 free((void *)mfx->readonly);
4884 mfx->readonly = strdup("False");
4885 free((void *)mfx->removable);
4886 mfx->removable = strdup("True");
4890 memset(buffer, 0x00, sizeof(buffer));
4899 static int __check_preload_updated(manifest_x * mfx, const char *manifest, uid_t uid)
4901 char filepath[PKG_STRING_LEN_MAX] = "";
4903 uiapplication_x *uiapplication = mfx->uiapplication;
4905 if(strstr(manifest, getUserManifestPath(uid))) {
4906 /* if preload app is updated, then remove previous desktop file on RW*/
4907 for(; uiapplication; uiapplication=uiapplication->next) {
4908 snprintf(filepath, sizeof(filepath),"%s%s.desktop", getUserDesktopPath(uid), uiapplication->appid);
4909 ret = remove(filepath);
4914 /* if downloaded app is updated, then update tag set true*/
4915 free((void *)mfx->update);
4916 mfx->update = strdup("true");
4923 API int pkgmgr_parser_create_desktop_file(manifest_x *mfx)
4927 _LOGD("Manifest pointer is NULL\n");
4930 ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_INSTALL, GLOBAL_USER);
4932 _LOGD("Creating desktop file failed\n");
4934 _LOGD("Creating desktop file Success\n");
4938 API int pkgmgr_parser_create_usr_desktop_file(manifest_x *mfx, uid_t uid)
4942 _LOGD("Manifest pointer is NULL\n");
4945 ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_INSTALL, uid);
4947 _LOGD("Creating desktop file failed\n");
4949 _LOGD("Creating desktop file Success\n");
4954 API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
4959 free((void *)mfx->ns);
4963 free((void *)mfx->package);
4964 mfx->package = NULL;
4967 free((void *)mfx->version);
4968 mfx->version = NULL;
4970 if (mfx->installlocation) {
4971 free((void *)mfx->installlocation);
4972 mfx->installlocation = NULL;
4975 free((void *)mfx->preload);
4976 mfx->preload = NULL;
4978 if (mfx->readonly) {
4979 free((void *)mfx->readonly);
4980 mfx->readonly = NULL;
4982 if (mfx->removable) {
4983 free((void *)mfx->removable);
4984 mfx->removable = NULL;
4987 free((void *)mfx->update);
4991 free((void *)mfx->system);
4995 free((void *)mfx->type);
4998 if (mfx->package_size) {
4999 free((void *)mfx->package_size);
5000 mfx->package_size = NULL;
5002 if (mfx->installed_time) {
5003 free((void *)mfx->installed_time);
5004 mfx->installed_time = NULL;
5006 if (mfx->installed_storage) {
5007 free((void *)mfx->installed_storage);
5008 mfx->installed_storage = NULL;
5010 if (mfx->storeclient_id) {
5011 free((void *)mfx->storeclient_id);
5012 mfx->storeclient_id = NULL;
5014 if (mfx->mainapp_id) {
5015 free((void *)mfx->mainapp_id);
5016 mfx->mainapp_id = NULL;
5018 if (mfx->package_url) {
5019 free((void *)mfx->package_url);
5020 mfx->package_url = NULL;
5022 if (mfx->root_path) {
5023 free((void *)mfx->root_path);
5024 mfx->root_path = NULL;
5026 if (mfx->csc_path) {
5027 free((void *)mfx->csc_path);
5028 mfx->csc_path = NULL;
5030 if (mfx->appsetting) {
5031 free((void *)mfx->appsetting);
5032 mfx->appsetting = NULL;
5034 if (mfx->nodisplay_setting) {
5035 free((void *)mfx->nodisplay_setting);
5036 mfx->nodisplay_setting = NULL;
5038 if (mfx->main_package) {
5039 free((void *)mfx->main_package);
5040 mfx->main_package = NULL;
5045 icon_x *icon = mfx->icon;
5047 while(icon != NULL) {
5049 __ps_free_icon(icon);
5055 label_x *label = mfx->label;
5056 label_x *tmp = NULL;
5057 while(label != NULL) {
5059 __ps_free_label(label);
5065 author_x *author = mfx->author;
5066 author_x *tmp = NULL;
5067 while(author != NULL) {
5069 __ps_free_author(author);
5073 /*Free Description*/
5074 if (mfx->description) {
5075 description_x *description = mfx->description;
5076 description_x *tmp = NULL;
5077 while(description != NULL) {
5078 tmp = description->next;
5079 __ps_free_description(description);
5085 license_x *license = mfx->license;
5086 license_x *tmp = NULL;
5087 while(license != NULL) {
5088 tmp = license->next;
5089 __ps_free_license(license);
5094 if (mfx->privileges) {
5095 privileges_x *privileges = mfx->privileges;
5096 privileges_x *tmp = NULL;
5097 while(privileges != NULL) {
5098 tmp = privileges->next;
5099 __ps_free_privileges(privileges);
5103 /*Free UiApplication*/
5104 if (mfx->uiapplication) {
5105 uiapplication_x *uiapplication = mfx->uiapplication;
5106 uiapplication_x *tmp = NULL;
5107 while(uiapplication != NULL) {
5108 tmp = uiapplication->next;
5109 __ps_free_uiapplication(uiapplication);
5110 uiapplication = tmp;
5113 /*Free ServiceApplication*/
5114 if (mfx->serviceapplication) {
5115 serviceapplication_x *serviceapplication = mfx->serviceapplication;
5116 serviceapplication_x *tmp = NULL;
5117 while(serviceapplication != NULL) {
5118 tmp = serviceapplication->next;
5119 __ps_free_serviceapplication(serviceapplication);
5120 serviceapplication = tmp;
5125 daemon_x *daemon = mfx->daemon;
5126 daemon_x *tmp = NULL;
5127 while(daemon != NULL) {
5129 __ps_free_daemon(daemon);
5135 theme_x *theme = mfx->theme;
5136 theme_x *tmp = NULL;
5137 while(theme != NULL) {
5139 __ps_free_theme(theme);
5145 font_x *font = mfx->font;
5147 while(font != NULL) {
5149 __ps_free_font(font);
5155 ime_x *ime = mfx->ime;
5157 while(ime != NULL) {
5163 /*Free Compatibility*/
5164 if (mfx->compatibility) {
5165 compatibility_x *compatibility = mfx->compatibility;
5166 compatibility_x *tmp = NULL;
5167 while(compatibility != NULL) {
5168 tmp = compatibility->next;
5169 __ps_free_compatibility(compatibility);
5170 compatibility = tmp;
5173 /*Free DeviceProfile*/
5174 if (mfx->deviceprofile) {
5175 deviceprofile_x *deviceprofile = mfx->deviceprofile;
5176 deviceprofile_x *tmp = NULL;
5177 while(deviceprofile != NULL) {
5178 tmp = deviceprofile->next;
5179 __ps_free_deviceprofile(deviceprofile);
5180 deviceprofile = tmp;
5188 API manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest)
5190 _LOGD("parsing start pkgmgr_parser_process_manifest_xml\n");
5191 xmlTextReaderPtr reader;
5192 manifest_x *mfx = NULL;
5194 reader = xmlReaderForFile(manifest, NULL, 0);
5196 mfx = malloc(sizeof(manifest_x));
5198 memset(mfx, '\0', sizeof(manifest_x));
5199 if (__process_manifest(reader, mfx, GLOBAL_USER) < 0) {
5200 _LOGD("Parsing Failed\n");
5201 pkgmgr_parser_free_manifest_xml(mfx);
5204 _LOGD("Parsing Success\n");
5206 _LOGD("Memory allocation error\n");
5208 xmlFreeTextReader(reader);
5210 _LOGD("Unable to create xml reader\n");
5216 API manifest_x *pkgmgr_parser_usr_process_manifest_xml(const char *manifest, uid_t uid)
5218 _LOGD("parsing start pkgmgr_parser_usr_process_manifest_xml\n");
5219 xmlTextReaderPtr reader;
5220 manifest_x *mfx = NULL;
5222 reader = xmlReaderForFile(manifest, NULL, 0);
5224 mfx = malloc(sizeof(manifest_x));
5226 memset(mfx, '\0', sizeof(manifest_x));
5227 if (__process_manifest(reader, mfx, uid) < 0) {
5228 _LOGD("Parsing Failed\n");
5229 pkgmgr_parser_free_manifest_xml(mfx);
5232 _LOGD("Parsing Success\n");
5234 _LOGD("Memory allocation error\n");
5236 xmlFreeTextReader(reader);
5238 _LOGD("Unable to create xml reader\n");
5243 /* These APIs are intended to call parser directly */
5245 API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
5247 // char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
5248 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5249 _LOGD("parsing manifest for installation: %s\n", manifest);
5251 manifest_x *mfx = NULL;
5255 mfx = pkgmgr_parser_process_manifest_xml(manifest);
5256 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5258 _LOGD("Parsing Finished\n");
5260 // __streamFile(manifest, ACTION_INSTALL, temp, mfx->package);
5261 __ps_process_tag_parser(mfx, manifest, ACTION_INSTALL);
5262 __add_preload_info(mfx, manifest, GLOBAL_USER);
5264 _LOGD("Added preload infomation\n");
5266 __ps_process_tag(mfx, tagv);
5268 ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
5269 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
5271 _LOGD("DB Insert Success\n");
5273 ret = __ps_process_metadata_parser(mfx, ACTION_INSTALL);
5275 _LOGD("Creating metadata parser failed\n");
5277 ret = __ps_process_category_parser(mfx, ACTION_INSTALL);
5279 _LOGD("Creating category parser failed\n");
5281 if (__check_action_fota(tagv))
5282 ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_FOTA, GLOBAL_USER);
5284 ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_INSTALL, GLOBAL_USER);
5287 _LOGD("Creating desktop file failed\n");
5289 _LOGD("Creating desktop file Success\n");
5291 pkgmgr_parser_free_manifest_xml(mfx);
5292 _LOGD("Free Done\n");
5297 API int pkgmgr_parser_parse_usr_manifest_for_installation(const char *manifest, uid_t uid, char *const tagv[])
5299 // char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
5300 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5301 _LOGD("parsing manifest for installation: %s\n", manifest);
5302 manifest_x *mfx = NULL;
5306 mfx = pkgmgr_parser_usr_process_manifest_xml(manifest, uid);
5307 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5309 _LOGD("Parsing Finished\n");
5310 // __streamFile(manifest, ACTION_INSTALL, temp, mfx->package);
5311 __ps_process_tag_parser(mfx, manifest, ACTION_INSTALL);
5312 __add_preload_info(mfx, manifest, uid);
5314 _LOGD("Added preload infomation\n");
5315 __ps_process_tag(mfx, tagv);
5317 ret = pkgmgr_parser_insert_manifest_info_in_usr_db(mfx, uid);
5318 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
5320 _LOGD("DB Insert Success\n");
5321 ret = __ps_process_metadata_parser(mfx, ACTION_INSTALL);
5323 _LOGD("Creating metadata parser failed\n");
5324 ret = __ps_process_category_parser(mfx, ACTION_INSTALL);
5326 _LOGD("Creating category parser failed\n");
5328 if (__check_action_fota(tagv))
5329 ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_FOTA, uid);
5331 ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_INSTALL, uid);
5334 _LOGD("Creating desktop file failed\n");
5336 _LOGD("Creating desktop file Success\n");
5337 pkgmgr_parser_free_manifest_xml(mfx);
5338 _LOGD("Free Done\n");
5344 API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
5346 // char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
5347 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5348 _LOGD("pkgmgr_parser_parse_manifest_for_upgrade parsing manifest for upgradation: %s\n", manifest);
5349 manifest_x *mfx = NULL;
5351 bool preload = false;
5352 bool system = false;
5353 char *csc_path = NULL;
5354 pkgmgrinfo_pkginfo_h handle = NULL;
5357 mfx = pkgmgr_parser_process_manifest_xml(manifest);
5358 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5360 _LOGD("Parsing Finished\n");
5361 // __streamFile(manifest, ACTION_UPGRADE, temp, mfx->package);
5362 __ps_process_tag_parser(mfx, manifest, ACTION_UPGRADE);
5363 __add_preload_info(mfx, manifest, GLOBAL_USER);
5364 _LOGD("Added preload infomation\n");
5365 __check_preload_updated(mfx, manifest, GLOBAL_USER);
5367 ret = pkgmgrinfo_pkginfo_get_pkginfo(mfx->package, &handle);
5368 if (ret != PMINFO_R_OK)
5369 _LOGD("pkgmgrinfo_pkginfo_get_pkginfo failed\n");
5370 ret = pkgmgrinfo_pkginfo_is_preload(handle, &preload);
5371 if (ret != PMINFO_R_OK)
5372 _LOGD("pkgmgrinfo_pkginfo_is_preload failed\n");
5375 free((void *)mfx->preload);
5376 mfx->preload = strdup("true");
5379 ret = pkgmgrinfo_pkginfo_is_system(handle, &system);
5380 if (ret != PMINFO_R_OK)
5381 _LOGD("pkgmgrinfo_pkginfo_is_system failed\n");
5383 free((void *)mfx->system);
5384 mfx->system = strdup("true");
5387 ret = pkgmgrinfo_pkginfo_get_csc_path(handle, &csc_path);
5388 if (ret != PMINFO_R_OK)
5389 _LOGD("pkgmgrinfo_pkginfo_get_csc_path failed\n");
5391 if (csc_path != NULL) {
5393 free((void *)mfx->csc_path);
5394 mfx->csc_path = strdup(csc_path);
5397 ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
5398 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
5399 _LOGD("DB Update Success\n");
5400 ret = __ps_process_metadata_parser(mfx, ACTION_UPGRADE);
5402 _LOGD("Upgrade metadata parser failed\n");
5404 ret = __ps_process_category_parser(mfx, ACTION_UPGRADE);
5406 _LOGD("Creating category parser failed\n");
5407 ret = __ps_make_nativeapp_desktop(mfx, manifest, ACTION_UPGRADE, GLOBAL_USER);
5409 _LOGD("Creating desktop file failed\n");
5411 _LOGD("Creating desktop file Success\n");
5412 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
5413 pkgmgr_parser_free_manifest_xml(mfx);
5414 _LOGD("Free Done\n");
5420 API int pkgmgr_parser_parse_usr_manifest_for_upgrade(const char *manifest, uid_t uid, char *const tagv[])
5422 // char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
5423 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5424 _LOGD(" pkgmgr_parser_parse_usr_manifest_for_upgrade parsing manifest for upgradation: %s\n", manifest);
5425 manifest_x *mfx = NULL;
5427 bool preload = false;
5428 bool system = false;
5429 char *csc_path = NULL;
5430 pkgmgrinfo_pkginfo_h handle = NULL;
5433 mfx = pkgmgr_parser_usr_process_manifest_xml(manifest, uid);
5434 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5436 _LOGD("Parsing Finished\n");
5437 //__streamFile(manifest, ACTION_UPGRADE, temp, mfx->package);
5438 __ps_process_tag_parser(mfx, manifest, ACTION_UPGRADE);
5439 __add_preload_info(mfx, manifest, uid);
5440 _LOGD("Added preload infomation\n");
5441 _LOGE("Added preload infomation\n");
5442 __check_preload_updated(mfx, manifest, uid);
5444 ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(mfx->package, uid, &handle);
5445 if (ret != PMINFO_R_OK)
5446 _LOGD("pkgmgrinfo_pkginfo_get_pkginfo failed\n");
5447 ret = pkgmgrinfo_pkginfo_is_preload(handle, &preload);
5448 if (ret != PMINFO_R_OK)
5449 _LOGD("pkgmgrinfo_pkginfo_is_preload failed\n");
5452 free((void *)mfx->preload);
5453 mfx->preload = strdup("true");
5456 ret = pkgmgrinfo_pkginfo_is_system(handle, &system);
5457 if (ret != PMINFO_R_OK)
5458 _LOGD("pkgmgrinfo_pkginfo_is_system failed\n");
5461 free((void *)mfx->system);
5462 mfx->system = strdup("true");
5465 ret = pkgmgrinfo_pkginfo_get_csc_path(handle, &csc_path);
5466 if (ret != PMINFO_R_OK)
5467 _LOGD("pkgmgrinfo_pkginfo_get_csc_path failed\n");
5468 if (csc_path != NULL) {
5470 free((void *)mfx->csc_path);
5471 mfx->csc_path = strdup(csc_path);
5474 ret = pkgmgr_parser_update_manifest_info_in_usr_db(mfx, uid);
5475 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
5476 _LOGD("DB Update Success\n");
5477 _LOGE("DB Update Success\n" );
5478 ret = __ps_process_metadata_parser(mfx, ACTION_UPGRADE);
5480 _LOGD("Upgrade metadata parser failed\n");
5481 ret = __ps_process_category_parser(mfx, ACTION_UPGRADE);
5483 _LOGD("Creating category parser failed\n");
5484 ret = __ps_make_nativeapp_desktop(mfx, manifest, ACTION_UPGRADE, GLOBAL_USER);
5486 _LOGD("Creating desktop file failed\n");
5488 _LOGD("Creating desktop file Success\n");
5489 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
5490 pkgmgr_parser_free_manifest_xml(mfx);
5491 _LOGD("Free Done\n");
5497 API int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[])
5499 // char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
5500 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5501 _LOGD("parsing manifest for uninstallation: %s\n", manifest);
5503 manifest_x *mfx = NULL;
5506 mfx = pkgmgr_parser_process_manifest_xml(manifest);
5507 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5509 _LOGD("Parsing Finished\n");
5511 // __streamFile(manifest, ACTION_UNINSTALL, temp, mfx->package);
5512 __ps_process_tag_parser(mfx, manifest, ACTION_UNINSTALL);
5514 __add_preload_info(mfx, manifest, GLOBAL_USER);
5515 _LOGD("Added preload infomation\n");
5517 ret = __ps_process_metadata_parser(mfx, ACTION_UNINSTALL);
5519 _LOGD("Removing metadata parser failed\n");
5521 ret = __ps_process_category_parser(mfx, ACTION_UNINSTALL);
5523 _LOGD("Creating category parser failed\n");
5525 ret = pkgmgr_parser_delete_manifest_info_from_db(mfx);
5527 _LOGD("DB Delete failed\n");
5529 _LOGD("DB Delete Success\n");
5531 ret = __ps_remove_nativeapp_desktop(mfx, GLOBAL_USER);
5533 _LOGD("Removing desktop file failed\n");
5535 _LOGD("Removing desktop file Success\n");
5537 ret = __ps_remove_appsvc_db(mfx);
5539 _LOGD("Removing appsvc_db failed\n");
5541 _LOGD("Removing appsvc_db Success\n");
5543 pkgmgr_parser_free_manifest_xml(mfx);
5544 _LOGD("Free Done\n");
5551 API int pkgmgr_parser_parse_usr_manifest_for_uninstallation(const char *manifest, uid_t uid, char *const tagv[])
5553 // char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
5554 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5555 _LOGD("parsing manifest for uninstallation: %s\n", manifest);
5557 manifest_x *mfx = NULL;
5560 mfx = pkgmgr_parser_usr_process_manifest_xml(manifest, uid);
5561 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5563 _LOGD("Parsing Finished\n");
5565 // __streamFile(manifest, ACTION_UNINSTALL, temp, mfx->package);
5566 __ps_process_tag_parser(mfx, manifest, ACTION_UNINSTALL);
5568 __add_preload_info(mfx, manifest, GLOBAL_USER);
5569 _LOGD("Added preload infomation\n");
5571 ret = __ps_process_metadata_parser(mfx, ACTION_UNINSTALL);
5573 _LOGD("Removing metadata parser failed\n");
5575 ret = __ps_process_category_parser(mfx, ACTION_UNINSTALL);
5577 _LOGD("Creating category parser failed\n");
5579 ret = pkgmgr_parser_delete_manifest_info_from_usr_db(mfx, uid);
5581 _LOGD("DB Delete failed\n");
5583 _LOGD("DB Delete Success\n");
5585 ret = __ps_remove_nativeapp_desktop(mfx, uid);
5587 _LOGD("Removing desktop file failed\n");
5589 _LOGD("Removing desktop file Success\n");
5591 ret = __ps_remove_appsvc_db(mfx);
5593 _LOGD("Removing appsvc_db failed\n");
5595 _LOGD("Removing appsvc_db Success\n");
5597 pkgmgr_parser_free_manifest_xml(mfx);
5598 _LOGD("Free Done\n");
5604 API int pkgmgr_parser_parse_manifest_for_preload()
5606 return pkgmgr_parser_update_preload_info_in_db();
5609 API int pkgmgr_parser_parse_usr_manifest_for_preload(uid_t uid)
5611 return pkgmgr_parser_update_preload_info_in_usr_db(uid);
5615 API char *pkgmgr_parser_get_usr_manifest_file(const char *pkgid, uid_t uid)
5617 return __pkgid_to_manifest(pkgid, uid);
5620 API char *pkgmgr_parser_get_manifest_file(const char *pkgid)
5622 return __pkgid_to_manifest(pkgid, GLOBAL_USER);
5625 API int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
5627 return __ps_run_parser(docPtr, tag, ACTION_INSTALL, pkgid);
5630 API int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgid)
5632 return __ps_run_parser(docPtr, tag, ACTION_UPGRADE, pkgid);
5635 API int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
5637 return __ps_run_parser(docPtr, tag, ACTION_UNINSTALL, pkgid);
5640 #define SCHEMA_FILE SYSCONFDIR "/package-manager/preload/manifest.xsd"
5642 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
5644 if (manifest == NULL) {
5645 _LOGE("manifest file is NULL\n");
5646 return PMINFO_R_EINVAL;
5649 xmlSchemaParserCtxtPtr ctx;
5650 xmlSchemaValidCtxtPtr vctx;
5651 xmlSchemaPtr xschema;
5652 ctx = xmlSchemaNewParserCtxt(SCHEMA_FILE);
5654 _LOGE("xmlSchemaNewParserCtxt() Failed\n");
5655 return PMINFO_R_ERROR;
5657 xschema = xmlSchemaParse(ctx);
5658 if (xschema == NULL) {
5659 _LOGE("xmlSchemaParse() Failed\n");
5660 return PMINFO_R_ERROR;
5662 vctx = xmlSchemaNewValidCtxt(xschema);
5664 _LOGE("xmlSchemaNewValidCtxt() Failed\n");
5665 return PMINFO_R_ERROR;
5667 xmlSchemaSetValidErrors(vctx, (xmlSchemaValidityErrorFunc) fprintf, (xmlSchemaValidityWarningFunc) fprintf, stderr);
5668 ret = xmlSchemaValidateFile(vctx, manifest, 0);
5670 _LOGE("xmlSchemaValidateFile() failed\n");
5671 return PMINFO_R_ERROR;
5672 } else if (ret == 0) {
5673 _LOGE("Manifest is Valid\n");
5676 _LOGE("Manifest Validation Failed with error code %d\n", ret);
5677 return PMINFO_R_ERROR;
5683 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
5693 _LOGE("fork failed\n");
5698 int dev_null_fd = open ("/dev/null", O_RDWR);
5699 if (dev_null_fd >= 0)
5701 dup2 (dev_null_fd, 0);/*stdin*/
5702 dup2 (dev_null_fd, 1);/*stdout*/
5703 dup2 (dev_null_fd, 2);/*stderr*/
5706 if (execl("/usr/bin/xmllint", "xmllint", manifest, "--schema",
5707 SCHEMA_FILE, NULL) < 0) {
5708 _LOGE("execl error\n");
5718 while ((err = waitpid(pid, &status, WNOHANG)) != pid) {
5722 _LOGE("waitpid failed\n");
5728 if(WIFEXITED(status) && !WEXITSTATUS(status))