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
66 #define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
77 /* plugin process_type */
79 PLUGIN_PRE_PROCESS = 0,
81 } PLUGIN_PROCESS_TYPE;
94 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label);
95 static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege);
96 static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privileges);
97 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile);
98 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed);
99 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation);
100 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri);
101 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime);
102 static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp);
103 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition);
104 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notifiation);
105 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category);
106 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata);
107 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission);
108 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility);
109 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution);
110 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request);
111 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define);
112 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc);
113 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions);
114 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare);
115 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon, uid_t uid);
116 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author);
117 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description);
118 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability);
119 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license);
120 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol);
121 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol);
122 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication, uid_t uid);
123 static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication, uid_t uid);
124 static int __ps_process_font(xmlTextReaderPtr reader, font_x *font);
125 static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme);
126 static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon);
127 static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime);
128 static void __ps_free_label(label_x *label);
129 static void __ps_free_privilege(privilege_x *privilege);
130 static void __ps_free_privileges(privileges_x *privileges);
131 static void __ps_free_deviceprofile(deviceprofile_x * deviceprofile);
132 static void __ps_free_allowed(allowed_x *allowed);
133 static void __ps_free_operation(operation_x *operation);
134 static void __ps_free_uri(uri_x *uri);
135 static void __ps_free_mime(mime_x *mime);
136 static void __ps_free_subapp(subapp_x *subapp);
137 static void __ps_free_condition(condition_x *condition);
138 static void __ps_free_notification(notification_x *notifiation);
139 static void __ps_free_category(category_x *category);
140 static void __ps_free_metadata(metadata_x *metadata);
141 static void __ps_free_permission(permission_x *permission);
142 static void __ps_free_compatibility(compatibility_x *compatibility);
143 static void __ps_free_resolution(resolution_x *resolution);
144 static void __ps_free_request(request_x *request);
145 static void __ps_free_define(define_x *define);
146 static void __ps_free_appsvc(appsvc_x *appsvc);
147 static void __ps_free_launchconditions(launchconditions_x *launchconditions);
148 static void __ps_free_datashare(datashare_x *datashare);
149 static void __ps_free_icon(icon_x *icon);
150 static void __ps_free_author(author_x *author);
151 static void __ps_free_description(description_x *description);
152 static void __ps_free_capability(capability_x *capability);
153 static void __ps_free_license(license_x *license);
154 static void __ps_free_appcontrol(appcontrol_x *appcontrol);
155 static void __ps_free_datacontrol(datacontrol_x *datacontrol);
156 static void __ps_free_uiapplication(uiapplication_x *uiapplication);
157 static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication);
158 static void __ps_free_font(font_x *font);
159 static void __ps_free_theme(theme_x *theme);
160 static void __ps_free_daemon(daemon_x *daemon);
161 static void __ps_free_ime(ime_x *ime);
162 static char *__pkgid_to_manifest(const char *pkgid, uid_t uid);
163 static int __next_child_element(xmlTextReaderPtr reader, int depth);
164 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx, uid_t uid);
165 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx, uid_t uid);
166 static void __str_trim(char *input);
167 static char *__get_parser_plugin(const char *type);
168 static int __ps_run_parser(xmlDocPtr docPtr, const char *tag, ACTION_TYPE action, const char *pkgid);
169 static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid);
170 static void __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgid);
171 static void __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid);
172 static int __validate_appid(const char *pkgid, const char *appid, char **newappid);
173 API int __is_admin();
175 void *__open_lib_handle(char *tag)
177 char *lib_path = NULL;
178 void *lib_handle = NULL;
180 lib_path = __get_parser_plugin(tag);
181 retvm_if(!lib_path, NULL, "lib_path get fail");
183 lib_handle = dlopen(lib_path, RTLD_LAZY);
184 retvm_if(lib_handle == NULL, NULL, "dlopen is failed lib_path[%s]", lib_path);
189 void __close_lib_handle(void *lib_handle)
194 static void __str_trim(char *input)
196 char *trim_str = input;
201 while (*input != 0) {
202 if (!isspace(*input)) {
215 uid_t uid = getuid();
216 if ((uid_t) 0 == uid )
224 static int __validate_appid(const char *pkgid, const char *appid, char **newappid)
226 if (!pkgid || !appid || !newappid) {
227 _LOGD("Arg supplied is NULL\n");
230 int pkglen = strlen(pkgid);
231 int applen = strlen(appid);
235 if (strncmp(appid, ".", 1) == 0) {
236 len = pkglen + applen + 1;
237 newapp = calloc(1,len);
238 if (newapp == NULL) {
239 _LOGD("Malloc failed\n");
242 strncpy(newapp, pkgid, pkglen);
243 strncat(newapp, appid, applen);
244 _LOGD("new appid is %s\n", newapp);
248 if (applen < pkglen) {
249 _LOGD("app id is not proper\n");
251 #ifdef _VALIDATE_APPID_
257 if (!strcmp(appid, pkgid)) {
258 _LOGD("appid is proper\n");
262 else if (strncmp(appid, pkgid, pkglen) == 0) {
263 ptr = strstr(appid, pkgid);
265 if (strncmp(ptr, ".", 1) == 0) {
266 _LOGD("appid is proper\n");
271 _LOGD("appid is not proper\n");
273 #ifdef _VALIDATE_APPID_
280 _LOGD("appid is not proper\n");
282 #ifdef _VALIDATE_APPID_
291 static char * __get_tag_by_key(char *md_key)
295 if (md_key == NULL) {
296 _LOGD("md_key is NULL\n");
300 md_tag = strrchr(md_key, 47) + 1;
303 return strdup(md_tag);
306 static char *__get_metadata_parser_plugin(const char *type)
309 char buffer[1024] = { 0 };
310 char temp_path[1024] = { 0 };
314 _LOGE("invalid argument\n");
318 fp = fopen(PKG_PARSER_CONF_PATH, "r");
320 _LOGE("no matching metadata parser\n");
324 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
325 if (buffer[0] == '#')
330 if ((path = strstr(buffer, METADATA_PARSER_NAME)) != NULL) {
331 path = path + strlen(METADATA_PARSER_NAME);
336 memset(buffer, 0x00, 1024);
343 _LOGE("no matching [%s] [%s]\n", METADATA_PARSER_NAME,type);
347 snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
349 return strdup(temp_path);
352 static char *__get_category_parser_plugin(const char *type)
355 char buffer[1024] = { 0 };
356 char temp_path[1024] = { 0 };
360 _LOGE("invalid argument\n");
364 fp = fopen(PKG_PARSER_CONF_PATH, "r");
366 _LOGE("no matching metadata parser\n");
370 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
371 if (buffer[0] == '#')
376 if ((path = strstr(buffer, CATEGORY_PARSER_NAME)) != NULL) {
377 path = path + strlen(CATEGORY_PARSER_NAME);
382 memset(buffer, 0x00, 1024);
389 _LOGE("no matching [%s] [%s]\n", CATEGORY_PARSER_NAME,type);
393 snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
395 return strdup(temp_path);
398 static char *__get_parser_plugin(const char *type)
401 char buffer[1024] = { 0 };
402 char temp_path[1024] = { 0 };
406 _LOGE("invalid argument\n");
410 fp = fopen(PKG_PARSER_CONF_PATH, "r");
412 _LOGE("no matching backendlib\n");
416 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
417 if (buffer[0] == '#')
422 if ((path = strstr(buffer, PKG_PARSERLIB)) != NULL) {
423 path = path + strlen(PKG_PARSERLIB);
427 memset(buffer, 0x00, 1024);
434 _LOGE("no matching backendlib\n");
438 snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
440 return strdup(temp_path);
443 static int __ps_run_tag_parser(void *lib_handle, xmlDocPtr docPtr, const char *tag,
444 ACTION_TYPE action, const char *pkgid)
446 int (*plugin_install) (xmlDocPtr, const char *);
452 ac = "PKGMGR_PARSER_PLUGIN_INSTALL";
455 ac = "PKGMGR_PARSER_PLUGIN_UPGRADE";
457 case ACTION_UNINSTALL:
458 ac = "PKGMGR_PARSER_PLUGIN_UNINSTALL";
464 if ((plugin_install =
465 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
466 _LOGE("can not find symbol[%s] \n", ac);
470 ret = plugin_install(docPtr, pkgid);
471 _LOGD("tag parser[%s, %s] ACTION_TYPE[%d] result[%d]\n", pkgid, tag, action, ret);
477 static int __ps_run_metadata_parser(GList *md_list, const char *tag,
478 ACTION_TYPE action, const char *pkgid, const char *appid)
480 char *lib_path = NULL;
481 void *lib_handle = NULL;
482 int (*metadata_parser_plugin) (const char *, const char *, GList *);
488 ac = "PKGMGR_MDPARSER_PLUGIN_INSTALL";
491 ac = "PKGMGR_MDPARSER_PLUGIN_UPGRADE";
493 case ACTION_UNINSTALL:
494 ac = "PKGMGR_MDPARSER_PLUGIN_UNINSTALL";
500 lib_path = __get_metadata_parser_plugin(tag);
502 _LOGE("get %s parser fail\n", tag);
506 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
507 _LOGE("dlopen is failed lib_path[%s]\n", lib_path);
511 if ((metadata_parser_plugin =
512 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
513 _LOGE("can not find symbol[%s] \n",ac);
517 ret = metadata_parser_plugin(pkgid, appid, md_list);
519 _LOGD("[appid = %s, libpath = %s plugin fail\n", appid, lib_path);
521 _LOGD("[appid = %s, libpath = %s plugin success\n", appid, lib_path);
531 static int __ps_run_category_parser(GList *category_list, const char *tag,
532 ACTION_TYPE action, const char *pkgid, const char *appid)
534 char *lib_path = NULL;
535 void *lib_handle = NULL;
536 int (*category_parser_plugin) (const char *, const char *, GList *);
542 ac = "PKGMGR_CATEGORY_PARSER_PLUGIN_INSTALL";
545 ac = "PKGMGR_CATEGORY_PARSER_PLUGIN_UPGRADE";
547 case ACTION_UNINSTALL:
548 ac = "PKGMGR_CATEGORY_PARSER_PLUGIN_UNINSTALL";
554 lib_path = __get_category_parser_plugin(tag);
556 _LOGE("get %s parser fail\n", tag);
560 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
561 _LOGE("dlopen is failed lib_path[%s]\n", lib_path);
565 if ((category_parser_plugin =
566 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
567 _LOGE("can not find symbol[%s] \n",ac);
571 ret = category_parser_plugin(pkgid, appid, category_list);
573 _LOGD("[appid = %s, libpath = %s plugin fail\n", appid, lib_path);
575 _LOGD("[appid = %s, libpath = %s plugin success\n", appid, lib_path);
585 static int __ps_run_parser(xmlDocPtr docPtr, const char *tag,
586 ACTION_TYPE action, const char *pkgid)
588 char *lib_path = NULL;
589 void *lib_handle = NULL;
590 int (*plugin_install) (xmlDocPtr, const char *);
596 ac = "PKGMGR_PARSER_PLUGIN_INSTALL";
599 ac = "PKGMGR_PARSER_PLUGIN_UPGRADE";
601 case ACTION_UNINSTALL:
602 ac = "PKGMGR_PARSER_PLUGIN_UNINSTALL";
608 lib_path = __get_parser_plugin(tag);
613 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
614 _LOGE("dlopen is failed lib_path[%s]\n", lib_path);
617 if ((plugin_install =
618 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
619 _LOGE("can not find symbol[%s] \n", ac);
623 ret = plugin_install(docPtr, pkgid);
625 _LOGD("[pkgid = %s, libpath = %s plugin fail\n", pkgid, lib_path);
627 _LOGD("[pkgid = %s, libpath = %s plugin success\n", pkgid, lib_path);
637 static char *__pkgid_to_manifest(const char *pkgid, uid_t uid)
643 _LOGE("pkgid is NULL");
647 size = strlen(getUserManifestPath(uid)) + strlen(pkgid) + 10;
648 manifest = malloc(size);
649 if (manifest == NULL) {
653 memset(manifest, '\0', size);
654 snprintf(manifest, size, "%s%s.xml", getUserManifestPath(uid), pkgid);
656 if (access(manifest, F_OK)) {
657 snprintf(manifest, size, "%s%s.xml", getUserManifestPath(uid), pkgid);
663 static void __metadata_parser_clear_dir_list(GList* dir_list)
666 __metadata_t* detail = NULL;
669 list = g_list_first(dir_list);
671 detail = (__metadata_t *)list->data;
679 list = g_list_next(list);
681 g_list_free(dir_list);
685 static void __category_parser_clear_dir_list(GList* dir_list)
688 __category_t* detail = NULL;
691 list = g_list_first(dir_list);
693 detail = (__category_t *)list->data;
700 list = g_list_next(list);
702 g_list_free(dir_list);
706 static int __run_tag_parser_prestep(void *lib_handle, xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid)
711 if (xmlTextReaderDepth(reader) != 1) {
712 _LOGE("Node depth is not 1");
716 if (xmlTextReaderNodeType(reader) != 1) {
717 _LOGE("Node type is not 1");
721 const xmlChar *value;
722 name = xmlTextReaderConstName(reader);
724 _LOGE("TEST TEST TES\n");
725 name = BAD_CAST "--";
728 value = xmlTextReaderConstValue(reader);
730 if (xmlStrlen(value) > 40) {
731 _LOGD(" %.40s...", value);
737 name = xmlTextReaderConstName(reader);
739 _LOGE("TEST TEST TES\n");
740 name = BAD_CAST "--";
743 xmlDocPtr docPtr = xmlTextReaderCurrentDoc(reader);
744 xmlDocPtr copyDocPtr = xmlCopyDoc(docPtr, 1);
745 if (copyDocPtr == NULL)
747 xmlNode *rootElement = xmlDocGetRootElement(copyDocPtr);
748 if (rootElement == NULL)
750 xmlNode *cur_node = xmlFirstElementChild(rootElement);
751 if (cur_node == NULL)
753 xmlNode *temp = xmlTextReaderExpand(reader);
756 xmlNode *next_node = NULL;
757 while(cur_node != NULL) {
758 if ( (strcmp(ASCII(temp->name), ASCII(cur_node->name)) == 0) &&
759 (temp->line == cur_node->line) ) {
763 next_node = xmlNextElementSibling(cur_node);
764 xmlUnlinkNode(cur_node);
765 xmlFreeNode(cur_node);
766 cur_node = next_node;
769 if (cur_node == NULL)
771 next_node = xmlNextElementSibling(cur_node);
773 cur_node->next = NULL;
774 next_node->prev = NULL;
775 xmlFreeNodeList(next_node);
776 xmlSetTreeDoc(cur_node, copyDocPtr);
778 xmlSetTreeDoc(cur_node, copyDocPtr);
781 ret = __ps_run_tag_parser(lib_handle, copyDocPtr, ASCII(name), action, pkgid);
787 static int __run_metadata_parser_prestep (manifest_x *mfx, char *md_key, ACTION_TYPE action)
791 char buffer[1024] = { 0, };
792 uiapplication_x *up = mfx->uiapplication;
793 metadata_x *md = NULL;
796 GList *md_list = NULL;
797 __metadata_t *md_detail = NULL;
799 md_tag = __get_tag_by_key(md_key);
800 if (md_tag == NULL) {
801 _LOGD("md_tag is NULL\n");
810 //get glist of metadata key and value combination
811 memset(buffer, 0x00, 1024);
812 snprintf(buffer, 1024, "%s/", md_key);
813 if ((md->key && md->value) && (strncmp(md->key, md_key, strlen(md_key)) == 0) && (strncmp(buffer, md->key, strlen(buffer)) == 0)) {
814 md_detail = (__metadata_t*) calloc(1, sizeof(__metadata_t));
815 if (md_detail == NULL) {
816 _LOGD("Memory allocation failed\n");
820 md_detail->key = (char*) calloc(1, sizeof(char)*(strlen(md->key)+2));
821 if (md_detail->key == NULL) {
822 _LOGD("Memory allocation failed\n");
826 snprintf(md_detail->key, (strlen(md->key)+1), "%s", md->key);
828 md_detail->value = (char*) calloc(1, sizeof(char)*(strlen(md->value)+2));
829 if (md_detail->value == NULL) {
830 _LOGD("Memory allocation failed\n");
831 free(md_detail->key);
835 snprintf(md_detail->value, (strlen(md->value)+1), "%s", md->value);
837 md_list = g_list_append(md_list, (gpointer)md_detail);
843 //send glist to parser when tags for metadata plugin parser exist.
845 ret = __ps_run_metadata_parser(md_list, md_tag, action, mfx->package, up->appid);
847 _LOGD("metadata_parser failed[%d] for tag[%s]\n", ret, md_tag);
850 _LOGD("metadata_parser success for tag[%s]\n", md_tag);
853 __metadata_parser_clear_dir_list(md_list);
861 __metadata_parser_clear_dir_list(md_list);
869 static int __run_category_parser_prestep (manifest_x *mfx, char *category_key, ACTION_TYPE action)
873 char buffer[1024] = { 0, };
874 uiapplication_x *up = mfx->uiapplication;
875 category_x *category = NULL;
876 char *category_tag = NULL;
878 GList *category_list = NULL;
879 __category_t *category_detail = NULL;
881 category_tag = __get_tag_by_key(category_key);
882 if (category_tag == NULL) {
883 _LOGD("md_tag is NULL\n");
889 category = up->category;
890 while (category != NULL)
892 //get glist of category key and value combination
893 memset(buffer, 0x00, 1024);
894 snprintf(buffer, 1024, "%s/", category_key);
895 if ((category->name) && (strncmp(category->name, category_key, strlen(category_key)) == 0)) {
896 category_detail = (__category_t*) calloc(1, sizeof(__category_t));
897 if (category_detail == NULL) {
898 _LOGD("Memory allocation failed\n");
902 category_detail->name = (char*) calloc(1, sizeof(char)*(strlen(category->name)+2));
903 if (category_detail->name == NULL) {
904 _LOGD("Memory allocation failed\n");
905 free(category_detail);
908 snprintf(category_detail->name, (strlen(category->name)+1), "%s", category->name);
910 category_list = g_list_append(category_list, (gpointer)category_detail);
913 category = category->next;
916 //send glist to parser when tags for metadata plugin parser exist.
918 ret = __ps_run_category_parser(category_list, category_tag, action, mfx->package, up->appid);
920 _LOGD("category_parser failed[%d] for tag[%s]\n", ret, category_tag);
922 _LOGD("category_parser success for tag[%s]\n", category_tag);
924 __category_parser_clear_dir_list(category_list);
925 category_list = NULL;
932 __category_parser_clear_dir_list(category_list);
940 static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid)
945 // _LOGD("__run_parser_prestep");
947 if (xmlTextReaderDepth(reader) != 1) {
948 _LOGE("Node depth is not 1");
952 if (xmlTextReaderNodeType(reader) != 1) {
953 _LOGE("Node type is not 1");
957 const xmlChar *value;
958 name = xmlTextReaderConstName(reader);
960 _LOGE("TEST TEST TES\n");
961 name = BAD_CAST "--";
964 value = xmlTextReaderConstValue(reader);
965 _LOGD("%d %d %s %d %d",
966 xmlTextReaderDepth(reader),
967 xmlTextReaderNodeType(reader),
969 xmlTextReaderIsEmptyElement(reader), xmlTextReaderHasValue(reader));
972 if (xmlStrlen(value) > 40) {
973 _LOGD(" %.40s...", value);
979 name = xmlTextReaderConstName(reader);
981 _LOGE("TEST TEST TES\n");
982 name = BAD_CAST "--";
985 xmlDocPtr docPtr = xmlTextReaderCurrentDoc(reader);
986 _LOGD("docPtr->URL %s\n", (char *)docPtr->URL);
987 xmlDocPtr copyDocPtr = xmlCopyDoc(docPtr, 1);
988 if (copyDocPtr == NULL)
990 xmlNode *rootElement = xmlDocGetRootElement(copyDocPtr);
991 if (rootElement == NULL)
993 xmlNode *cur_node = xmlFirstElementChild(rootElement);
994 if (cur_node == NULL)
996 xmlNode *temp = xmlTextReaderExpand(reader);
999 xmlNode *next_node = NULL;
1000 while(cur_node != NULL) {
1001 if ( (strcmp(ASCII(temp->name), ASCII(cur_node->name)) == 0) &&
1002 (temp->line == cur_node->line) ) {
1006 next_node = xmlNextElementSibling(cur_node);
1007 xmlUnlinkNode(cur_node);
1008 xmlFreeNode(cur_node);
1009 cur_node = next_node;
1012 if (cur_node == NULL)
1014 next_node = xmlNextElementSibling(cur_node);
1016 cur_node->next = NULL;
1017 next_node->prev = NULL;
1018 xmlFreeNodeList(next_node);
1019 xmlSetTreeDoc(cur_node, copyDocPtr);
1021 xmlSetTreeDoc(cur_node, copyDocPtr);
1027 _LOGD("node type: %d, name: %s children->name: %s last->name: %s\n"
1028 "parent->name: %s next->name: %s prev->name: %s\n",
1029 cur_node->type, cur_node->name,
1030 cur_node->children ? cur_node->children->name : "NULL",
1031 cur_node->last ? cur_node->last->name : "NULL",
1032 cur_node->parent ? cur_node->parent->name : "NULL",
1033 cur_node->next ? cur_node->next->name : "NULL",
1034 cur_node->prev ? cur_node->prev->name : "NULL");
1036 FILE *fp = fopen(tzplatform_mkpath(TZ_SYS_SHARE, "test.xml"), "a");
1037 xmlDocDump(fp, copyDocPtr);
1041 ret = __ps_run_parser(copyDocPtr, ASCII(name), action, pkgid);
1048 __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgid)
1053 switch (xmlTextReaderNodeType(reader)) {
1054 case XML_READER_TYPE_END_ELEMENT:
1056 // _LOGD("XML_READER_TYPE_END_ELEMENT");
1060 case XML_READER_TYPE_ELEMENT:
1062 // Elements without closing tag don't receive
1063 // XML_READER_TYPE_END_ELEMENT event.
1065 const xmlChar *elementName =
1066 xmlTextReaderLocalName(reader);
1067 if (elementName == NULL) {
1068 // _LOGD("elementName %s\n", (char *)elementName);
1072 const xmlChar *nameSpace =
1073 xmlTextReaderConstNamespaceUri(reader);
1075 // _LOGD("nameSpace %s\n", (char *)nameSpace);
1078 _LOGD("XML_READER_TYPE_ELEMENT %s, %s\n",
1079 elementName ? elementName : "NULL",
1080 nameSpace ? nameSpace : "NULL");
1083 _LOGD("__run_parser_prestep pkgid[%s]\n", pkgid);
1084 __run_parser_prestep(reader, action, pkgid);
1088 for (tag = tagv[0]; tag; tag = tagv[++i])
1089 if (strcmp(tag, ASCII(elementName)) == 0) {
1090 _LOGD("__run_parser_prestep tag[%s] pkgid[%s]\n", tag, pkgid);
1091 __run_parser_prestep(reader,
1099 case XML_READER_TYPE_TEXT:
1100 case XML_READER_TYPE_CDATA:
1102 const xmlChar *value = xmlTextReaderConstValue(reader);
1104 // _LOGD("value %s\n", value);
1107 const xmlChar *lang = xmlTextReaderConstXmlLang(reader);
1109 // _LOGD("lang\n", lang);
1112 /* _LOGD("XML_READER_TYPE_TEXT %s, %s\n",
1113 value ? value : "NULL", lang ? lang : "NULL");
1118 // _LOGD("Ignoring Node of Type: %d", xmlTextReaderNodeType(reader));
1124 __processTag(void *lib_handle, xmlTextReaderPtr reader, ACTION_TYPE action, char *tag, const char *pkgid)
1126 switch (xmlTextReaderNodeType(reader)) {
1127 case XML_READER_TYPE_END_ELEMENT:
1131 case XML_READER_TYPE_ELEMENT:
1133 // Elements without closing tag don't receive
1134 const xmlChar *elementName =
1135 xmlTextReaderLocalName(reader);
1136 if (elementName == NULL) {
1140 if (strcmp(tag, ASCII(elementName)) == 0) {
1141 _LOGD("find : tag[%s] ACTION_TYPE[%d] pkg[%s]\n", tag, action, pkgid);
1142 __run_tag_parser_prestep(lib_handle, reader, action, pkgid);
1153 static int __parser_send_tag(void *lib_handle, ACTION_TYPE action, PLUGIN_PROCESS_TYPE process, const char *pkgid)
1155 int (*plugin_install) (const char *);
1159 if (process == PLUGIN_PRE_PROCESS) {
1161 case ACTION_INSTALL:
1162 ac = "PKGMGR_PARSER_PLUGIN_PRE_INSTALL";
1164 case ACTION_UPGRADE:
1165 ac = "PKGMGR_PARSER_PLUGIN_PRE_UPGRADE";
1167 case ACTION_UNINSTALL:
1168 ac = "PKGMGR_PARSER_PLUGIN_PRE_UNINSTALL";
1173 } else if (process == PLUGIN_POST_PROCESS) {
1175 case ACTION_INSTALL:
1176 ac = "PKGMGR_PARSER_PLUGIN_POST_INSTALL";
1178 case ACTION_UPGRADE:
1179 ac = "PKGMGR_PARSER_PLUGIN_POST_UPGRADE";
1181 case ACTION_UNINSTALL:
1182 ac = "PKGMGR_PARSER_PLUGIN_POST_UNINSTALL";
1190 if ((plugin_install =
1191 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
1195 ret = plugin_install(pkgid);
1199 static void __plugin_send_tag(const char *tag, ACTION_TYPE action, PLUGIN_PROCESS_TYPE process, const char *pkgid)
1201 char *lib_path = NULL;
1202 void *lib_handle = NULL;
1203 int (*plugin_install) (const char *);
1207 if (process == PLUGIN_PRE_PROCESS) {
1209 case ACTION_INSTALL:
1210 ac = "PKGMGR_PARSER_PLUGIN_PRE_INSTALL";
1212 case ACTION_UPGRADE:
1213 ac = "PKGMGR_PARSER_PLUGIN_PRE_UPGRADE";
1215 case ACTION_UNINSTALL:
1216 ac = "PKGMGR_PARSER_PLUGIN_PRE_UNINSTALL";
1221 } else if (process == PLUGIN_POST_PROCESS) {
1223 case ACTION_INSTALL:
1224 ac = "PKGMGR_PARSER_PLUGIN_POST_INSTALL";
1226 case ACTION_UPGRADE:
1227 ac = "PKGMGR_PARSER_PLUGIN_POST_UPGRADE";
1229 case ACTION_UNINSTALL:
1230 ac = "PKGMGR_PARSER_PLUGIN_POST_UNINSTALL";
1238 lib_path = __get_parser_plugin(tag);
1243 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
1244 _LOGE("dlopen is failed lib_path[%s] for tag[%s]\n", lib_path, tag);
1247 if ((plugin_install =
1248 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
1249 // _LOGE("can not find symbol[%s] for tag[%s] \n", ac, tag);
1253 ret = plugin_install(pkgid);
1255 _LOGD("[PLUGIN_PROCESS_TYPE[%d] pkgid=%s, tag=%s plugin fail\n", process, pkgid, tag);
1257 _LOGD("[PLUGIN_PROCESS_TYPE[%d] pkgid=%s, tag=%s plugin success\n", process, pkgid, tag);
1263 dlclose(lib_handle);
1267 __plugin_process_tag(char *const tag_list[], ACTION_TYPE action, PLUGIN_PROCESS_TYPE process, const char *pkgid)
1272 for (tag = tag_list[0]; tag; tag = tag_list[++i])
1273 __plugin_send_tag(tag, action, process, pkgid);
1278 __plugin_save_tag(xmlTextReaderPtr reader, char *const tagv[], char *tag_list[])
1282 static int pre_cnt=0;
1284 switch (xmlTextReaderNodeType(reader)) {
1285 case XML_READER_TYPE_ELEMENT:
1287 const xmlChar *elementName = xmlTextReaderLocalName(reader);
1288 if (elementName == NULL) {
1292 for (tag = tag_list[0]; tag; tag = tag_list[++i])
1293 if (strcmp(ASCII(elementName), tag) == 0) {
1297 for (tag = tagv[0]; tag; tag = tagv[++i])
1298 if (strcmp(tag, ASCII(elementName)) == 0) {
1299 tag_list[pre_cnt++] = tag;
1305 // _LOGD("Ignoring Node of Type: %d", xmlTextReaderNodeType(reader));
1311 __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid)
1313 xmlTextReaderPtr reader;
1316 __plugin_process_tag(tagv, action, PLUGIN_PRE_PROCESS, pkgid);
1318 docPtr = xmlReadFile(filename, NULL, 0);
1319 reader = xmlReaderWalker(docPtr);
1320 if (reader != NULL) {
1321 ret = xmlTextReaderRead(reader);
1323 __processNode(reader, action, tagv, pkgid);
1324 ret = xmlTextReaderRead(reader);
1326 xmlFreeTextReader(reader);
1329 _LOGD("%s : failed to parse", filename);
1332 _LOGD("Unable to open %s", filename);
1335 __plugin_process_tag(tagv, action, PLUGIN_POST_PROCESS, pkgid);
1338 static int __next_child_element(xmlTextReaderPtr reader, int depth)
1340 int ret = xmlTextReaderRead(reader);
1341 int cur = xmlTextReaderDepth(reader);
1344 switch (xmlTextReaderNodeType(reader)) {
1345 case XML_READER_TYPE_ELEMENT:
1346 if (cur == depth + 1)
1349 case XML_READER_TYPE_TEXT:
1350 /*text is handled by each function separately*/
1351 if (cur == depth + 1)
1354 case XML_READER_TYPE_END_ELEMENT:
1363 ret = xmlTextReaderRead(reader);
1364 cur = xmlTextReaderDepth(reader);
1369 static bool __check_action_fota(char *const tagv[])
1372 char delims[] = "=";
1373 char *ret_result = NULL;
1380 for (tag = strdup(tagv[0]); tag != NULL; ) {
1381 ret_result = strtok(tag, delims);
1383 /*check tag : fota is true */
1384 if (strcmp(ret_result, "fota") == 0) {
1385 ret_result = strtok(NULL, delims);
1386 if (strcmp(ret_result, "true") == 0) {
1390 _LOGD("tag process [%s]is not defined\n", ret_result);
1394 /*check next value*/
1395 if (tagv[++i] != NULL)
1396 tag = strdup(tagv[i]);
1398 _LOGD("tag process success...%d\n" , ret);
1406 static void __ps_free_category(category_x *category)
1408 if (category == NULL)
1410 if (category->name) {
1411 free((void *)category->name);
1412 category->name = NULL;
1414 free((void*)category);
1418 static void __ps_free_privilege(privilege_x *privilege)
1420 if (privilege == NULL)
1422 if (privilege->text) {
1423 free((void *)privilege->text);
1424 privilege->text = NULL;
1426 free((void*)privilege);
1430 static void __ps_free_privileges(privileges_x *privileges)
1432 if (privileges == NULL)
1435 if (privileges->privilege) {
1436 privilege_x *privilege = privileges->privilege;
1437 privilege_x *tmp = NULL;
1438 while(privilege != NULL) {
1439 tmp = privilege->next;
1440 __ps_free_privilege(privilege);
1444 free((void*)privileges);
1448 static void __ps_free_metadata(metadata_x *metadata)
1450 if (metadata == NULL)
1452 if (metadata->key) {
1453 free((void *)metadata->key);
1454 metadata->key = NULL;
1456 if (metadata->value) {
1457 free((void *)metadata->value);
1458 metadata->value = NULL;
1460 free((void*)metadata);
1464 static void __ps_free_permission(permission_x *permission)
1466 if (permission == NULL)
1468 if (permission->type) {
1469 free((void *)permission->type);
1470 permission->type = NULL;
1472 if (permission->value) {
1473 free((void *)permission->value);
1474 permission->value = NULL;
1476 free((void*)permission);
1480 static void __ps_free_icon(icon_x *icon)
1485 free((void *)icon->text);
1489 free((void *)icon->lang);
1493 free((void *)icon->name);
1496 if (icon->section) {
1497 free((void *)icon->section);
1498 icon->section = NULL;
1501 free((void *)icon->size);
1504 if (icon->resolution) {
1505 free((void *)icon->resolution);
1506 icon->resolution = NULL;
1512 static void __ps_free_image(image_x *image)
1517 free((void *)image->text);
1521 free((void *)image->lang);
1525 free((void *)image->name);
1528 if (image->section) {
1529 free((void *)image->section);
1530 image->section = NULL;
1536 static void __ps_free_operation(operation_x *operation)
1538 if (operation == NULL)
1540 if (operation->text) {
1541 free((void *)operation->text);
1542 operation->text = NULL;
1544 free((void*)operation);
1548 static void __ps_free_uri(uri_x *uri)
1553 free((void *)uri->text);
1560 static void __ps_free_mime(mime_x *mime)
1565 free((void *)mime->text);
1572 static void __ps_free_subapp(subapp_x *subapp)
1577 free((void *)subapp->text);
1578 subapp->text = NULL;
1580 free((void*)subapp);
1584 static void __ps_free_condition(condition_x *condition)
1586 if (condition == NULL)
1588 if (condition->text) {
1589 free((void *)condition->text);
1590 condition->text = NULL;
1592 if (condition->name) {
1593 free((void *)condition->name);
1594 condition->name = NULL;
1596 free((void*)condition);
1600 static void __ps_free_notification(notification_x *notification)
1602 if (notification == NULL)
1604 if (notification->text) {
1605 free((void *)notification->text);
1606 notification->text = NULL;
1608 if (notification->name) {
1609 free((void *)notification->name);
1610 notification->name = NULL;
1612 free((void*)notification);
1613 notification = NULL;
1616 static void __ps_free_compatibility(compatibility_x *compatibility)
1618 if (compatibility == NULL)
1620 if (compatibility->text) {
1621 free((void *)compatibility->text);
1622 compatibility->text = NULL;
1624 if (compatibility->name) {
1625 free((void *)compatibility->name);
1626 compatibility->name = NULL;
1628 free((void*)compatibility);
1629 compatibility = NULL;
1632 static void __ps_free_resolution(resolution_x *resolution)
1634 if (resolution == NULL)
1636 if (resolution->mimetype) {
1637 free((void *)resolution->mimetype);
1638 resolution->mimetype = NULL;
1640 if (resolution->urischeme) {
1641 free((void *)resolution->urischeme);
1642 resolution->urischeme = NULL;
1644 free((void*)resolution);
1648 static void __ps_free_capability(capability_x *capability)
1650 if (capability == NULL)
1652 if (capability->operationid) {
1653 free((void *)capability->operationid);
1654 capability->operationid = NULL;
1657 if (capability->resolution) {
1658 resolution_x *resolution = capability->resolution;
1659 resolution_x *tmp = NULL;
1660 while(resolution != NULL) {
1661 tmp = resolution->next;
1662 __ps_free_resolution(resolution);
1666 free((void*)capability);
1670 static void __ps_free_allowed(allowed_x *allowed)
1672 if (allowed == NULL)
1674 if (allowed->name) {
1675 free((void *)allowed->name);
1676 allowed->name = NULL;
1678 if (allowed->text) {
1679 free((void *)allowed->text);
1680 allowed->text = NULL;
1682 free((void*)allowed);
1686 static void __ps_free_request(request_x *request)
1688 if (request == NULL)
1690 if (request->text) {
1691 free((void *)request->text);
1692 request->text = NULL;
1694 free((void*)request);
1698 static void __ps_free_datacontrol(datacontrol_x *datacontrol)
1700 if (datacontrol == NULL)
1702 if (datacontrol->providerid) {
1703 free((void *)datacontrol->providerid);
1704 datacontrol->providerid = NULL;
1706 if (datacontrol->access) {
1707 free((void *)datacontrol->access);
1708 datacontrol->access = NULL;
1710 if (datacontrol->type) {
1711 free((void *)datacontrol->type);
1712 datacontrol->type = NULL;
1714 free((void*)datacontrol);
1718 static void __ps_free_launchconditions(launchconditions_x *launchconditions)
1720 if (launchconditions == NULL)
1722 if (launchconditions->text) {
1723 free((void *)launchconditions->text);
1724 launchconditions->text = NULL;
1727 if (launchconditions->condition) {
1728 condition_x *condition = launchconditions->condition;
1729 condition_x *tmp = NULL;
1730 while(condition != NULL) {
1731 tmp = condition->next;
1732 __ps_free_condition(condition);
1736 free((void*)launchconditions);
1737 launchconditions = NULL;
1740 static void __ps_free_appcontrol(appcontrol_x *appcontrol)
1742 if (appcontrol == NULL)
1744 if (appcontrol->text) {
1745 free((void *)appcontrol->text);
1746 appcontrol->text = NULL;
1749 if (appcontrol->operation) {
1750 operation_x *operation = appcontrol->operation;
1751 operation_x *tmp = NULL;
1752 while(operation != NULL) {
1753 tmp = operation->next;
1754 __ps_free_operation(operation);
1759 if (appcontrol->uri) {
1760 uri_x *uri = appcontrol->uri;
1762 while(uri != NULL) {
1769 if (appcontrol->mime) {
1770 mime_x *mime = appcontrol->mime;
1772 while(mime != NULL) {
1774 __ps_free_mime(mime);
1779 if (appcontrol->subapp) {
1780 subapp_x *subapp = appcontrol->subapp;
1781 subapp_x *tmp = NULL;
1782 while(subapp != NULL) {
1784 __ps_free_subapp(subapp);
1788 free((void*)appcontrol);
1792 static void __ps_free_appsvc(appsvc_x *appsvc)
1797 free((void *)appsvc->text);
1798 appsvc->text = NULL;
1801 if (appsvc->operation) {
1802 operation_x *operation = appsvc->operation;
1803 operation_x *tmp = NULL;
1804 while(operation != NULL) {
1805 tmp = operation->next;
1806 __ps_free_operation(operation);
1812 uri_x *uri = appsvc->uri;
1814 while(uri != NULL) {
1822 mime_x *mime = appsvc->mime;
1824 while(mime != NULL) {
1826 __ps_free_mime(mime);
1831 if (appsvc->subapp) {
1832 subapp_x *subapp = appsvc->subapp;
1833 subapp_x *tmp = NULL;
1834 while(subapp != NULL) {
1836 __ps_free_subapp(subapp);
1840 free((void*)appsvc);
1844 static void __ps_free_deviceprofile(deviceprofile_x *deviceprofile)
1849 static void __ps_free_define(define_x *define)
1854 free((void *)define->path);
1855 define->path = NULL;
1858 if (define->request) {
1859 request_x *request = define->request;
1860 request_x *tmp = NULL;
1861 while(request != NULL) {
1862 tmp = request->next;
1863 __ps_free_request(request);
1868 if (define->allowed) {
1869 allowed_x *allowed = define->allowed;
1870 allowed_x *tmp = NULL;
1871 while(allowed != NULL) {
1872 tmp = allowed->next;
1873 __ps_free_allowed(allowed);
1877 free((void*)define);
1881 static void __ps_free_datashare(datashare_x *datashare)
1883 if (datashare == NULL)
1886 if (datashare->define) {
1887 define_x *define = datashare->define;
1888 define_x *tmp = NULL;
1889 while(define != NULL) {
1891 __ps_free_define(define);
1896 if (datashare->request) {
1897 request_x *request = datashare->request;
1898 request_x *tmp = NULL;
1899 while(request != NULL) {
1900 tmp = request->next;
1901 __ps_free_request(request);
1905 free((void*)datashare);
1909 static void __ps_free_label(label_x *label)
1914 free((void *)label->name);
1918 free((void *)label->text);
1922 free((void *)label->lang);
1929 static void __ps_free_author(author_x *author)
1933 if (author->email) {
1934 free((void *)author->email);
1935 author->email = NULL;
1938 free((void *)author->text);
1939 author->text = NULL;
1942 free((void *)author->href);
1943 author->href = NULL;
1946 free((void *)author->lang);
1947 author->lang = NULL;
1949 free((void*)author);
1953 static void __ps_free_description(description_x *description)
1955 if (description == NULL)
1957 if (description->name) {
1958 free((void *)description->name);
1959 description->name = NULL;
1961 if (description->text) {
1962 free((void *)description->text);
1963 description->text = NULL;
1965 if (description->lang) {
1966 free((void *)description->lang);
1967 description->lang = NULL;
1969 free((void*)description);
1973 static void __ps_free_license(license_x *license)
1975 if (license == NULL)
1977 if (license->text) {
1978 free((void *)license->text);
1979 license->text = NULL;
1981 if (license->lang) {
1982 free((void *)license->lang);
1983 license->lang = NULL;
1985 free((void*)license);
1989 static void __ps_free_uiapplication(uiapplication_x *uiapplication)
1991 if (uiapplication == NULL)
1993 if (uiapplication->exec) {
1994 free((void *)uiapplication->exec);
1995 uiapplication->exec = NULL;
1997 if (uiapplication->appid) {
1998 free((void *)uiapplication->appid);
1999 uiapplication->appid = NULL;
2001 if (uiapplication->nodisplay) {
2002 free((void *)uiapplication->nodisplay);
2003 uiapplication->nodisplay = NULL;
2005 if (uiapplication->multiple) {
2006 free((void *)uiapplication->multiple);
2007 uiapplication->multiple = NULL;
2009 if (uiapplication->type) {
2010 free((void *)uiapplication->type);
2011 uiapplication->type = NULL;
2013 if (uiapplication->categories) {
2014 free((void *)uiapplication->categories);
2015 uiapplication->categories = NULL;
2017 if (uiapplication->extraid) {
2018 free((void *)uiapplication->extraid);
2019 uiapplication->extraid = NULL;
2021 if (uiapplication->taskmanage) {
2022 free((void *)uiapplication->taskmanage);
2023 uiapplication->taskmanage = NULL;
2025 if (uiapplication->enabled) {
2026 free((void *)uiapplication->enabled);
2027 uiapplication->enabled = NULL;
2029 if (uiapplication->hwacceleration) {
2030 free((void *)uiapplication->hwacceleration);
2031 uiapplication->hwacceleration = NULL;
2033 if (uiapplication->screenreader) {
2034 free((void *)uiapplication->screenreader);
2035 uiapplication->screenreader = NULL;
2037 if (uiapplication->mainapp) {
2038 free((void *)uiapplication->mainapp);
2039 uiapplication->mainapp = NULL;
2041 if (uiapplication->recentimage) {
2042 free((void *)uiapplication->recentimage);
2043 uiapplication->recentimage = NULL;
2045 if (uiapplication->package) {
2046 free((void *)uiapplication->package);
2047 uiapplication->package = NULL;
2049 if (uiapplication->launchcondition) {
2050 free((void *)uiapplication->launchcondition);
2051 uiapplication->launchcondition = NULL;
2054 if (uiapplication->label) {
2055 label_x *label = uiapplication->label;
2056 label_x *tmp = NULL;
2057 while(label != NULL) {
2059 __ps_free_label(label);
2064 if (uiapplication->icon) {
2065 icon_x *icon = uiapplication->icon;
2067 while(icon != NULL) {
2069 __ps_free_icon(icon);
2074 if (uiapplication->image) {
2075 image_x *image = uiapplication->image;
2076 image_x *tmp = NULL;
2077 while(image != NULL) {
2079 __ps_free_image(image);
2084 if (uiapplication->appcontrol) {
2085 appcontrol_x *appcontrol = uiapplication->appcontrol;
2086 appcontrol_x *tmp = NULL;
2087 while(appcontrol != NULL) {
2088 tmp = appcontrol->next;
2089 __ps_free_appcontrol(appcontrol);
2093 /*Free LaunchConditions*/
2094 if (uiapplication->launchconditions) {
2095 launchconditions_x *launchconditions = uiapplication->launchconditions;
2096 launchconditions_x *tmp = NULL;
2097 while(launchconditions != NULL) {
2098 tmp = launchconditions->next;
2099 __ps_free_launchconditions(launchconditions);
2100 launchconditions = tmp;
2103 /*Free Notification*/
2104 if (uiapplication->notification) {
2105 notification_x *notification = uiapplication->notification;
2106 notification_x *tmp = NULL;
2107 while(notification != NULL) {
2108 tmp = notification->next;
2109 __ps_free_notification(notification);
2114 if (uiapplication->datashare) {
2115 datashare_x *datashare = uiapplication->datashare;
2116 datashare_x *tmp = NULL;
2117 while(datashare != NULL) {
2118 tmp = datashare->next;
2119 __ps_free_datashare(datashare);
2124 if (uiapplication->appsvc) {
2125 appsvc_x *appsvc = uiapplication->appsvc;
2126 appsvc_x *tmp = NULL;
2127 while(appsvc != NULL) {
2129 __ps_free_appsvc(appsvc);
2134 if (uiapplication->category) {
2135 category_x *category = uiapplication->category;
2136 category_x *tmp = NULL;
2137 while(category != NULL) {
2138 tmp = category->next;
2139 __ps_free_category(category);
2144 if (uiapplication->metadata) {
2145 metadata_x *metadata = uiapplication->metadata;
2146 metadata_x *tmp = NULL;
2147 while(metadata != NULL) {
2148 tmp = metadata->next;
2149 __ps_free_metadata(metadata);
2154 if (uiapplication->permission) {
2155 permission_x *permission = uiapplication->permission;
2156 permission_x *tmp = NULL;
2157 while(permission != NULL) {
2158 tmp = permission->next;
2159 __ps_free_permission(permission);
2163 /* _PRODUCT_LAUNCHING_ENHANCED_ START */
2164 if (uiapplication->indicatordisplay) {
2165 free((void *)uiapplication->indicatordisplay);
2166 uiapplication->indicatordisplay = NULL;
2168 if (uiapplication->portraitimg) {
2169 free((void *)uiapplication->portraitimg);
2170 uiapplication->portraitimg = NULL;
2172 if (uiapplication->landscapeimg) {
2173 free((void *)uiapplication->landscapeimg);
2174 uiapplication->landscapeimg = NULL;
2176 /* _PRODUCT_LAUNCHING_ENHANCED_ END */
2177 if (uiapplication->guestmode_visibility) {
2178 free((void *)uiapplication->guestmode_visibility);
2179 uiapplication->guestmode_visibility = NULL;
2181 if (uiapplication->app_component) {
2182 free((void *)uiapplication->app_component);
2183 uiapplication->app_component = NULL;
2185 if (uiapplication->permission_type) {
2186 free((void *)uiapplication->permission_type);
2187 uiapplication->permission_type = NULL;
2189 if (uiapplication->component_type) {
2190 free((void *)uiapplication->component_type);
2191 uiapplication->component_type = NULL;
2193 if (uiapplication->preload) {
2194 free((void *)uiapplication->preload);
2195 uiapplication->preload = NULL;
2197 if (uiapplication->submode) {
2198 free((void *)uiapplication->submode);
2199 uiapplication->submode = NULL;
2201 if (uiapplication->submode_mainid) {
2202 free((void *)uiapplication->submode_mainid);
2203 uiapplication->submode_mainid = NULL;
2206 free((void*)uiapplication);
2207 uiapplication = NULL;
2210 static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication)
2212 if (serviceapplication == NULL)
2214 if (serviceapplication->exec) {
2215 free((void *)serviceapplication->exec);
2216 serviceapplication->exec = NULL;
2218 if (serviceapplication->appid) {
2219 free((void *)serviceapplication->appid);
2220 serviceapplication->appid = NULL;
2222 if (serviceapplication->onboot) {
2223 free((void *)serviceapplication->onboot);
2224 serviceapplication->onboot = NULL;
2226 if (serviceapplication->autorestart) {
2227 free((void *)serviceapplication->autorestart);
2228 serviceapplication->autorestart = NULL;
2230 if (serviceapplication->type) {
2231 free((void *)serviceapplication->type);
2232 serviceapplication->type = NULL;
2234 if (serviceapplication->enabled) {
2235 free((void *)serviceapplication->enabled);
2236 serviceapplication->enabled = NULL;
2238 if (serviceapplication->package) {
2239 free((void *)serviceapplication->package);
2240 serviceapplication->package = NULL;
2242 if (serviceapplication->permission_type) {
2243 free((void *)serviceapplication->permission_type);
2244 serviceapplication->permission_type = NULL;
2247 if (serviceapplication->label) {
2248 label_x *label = serviceapplication->label;
2249 label_x *tmp = NULL;
2250 while(label != NULL) {
2252 __ps_free_label(label);
2257 if (serviceapplication->icon) {
2258 icon_x *icon = serviceapplication->icon;
2260 while(icon != NULL) {
2262 __ps_free_icon(icon);
2267 if (serviceapplication->appcontrol) {
2268 appcontrol_x *appcontrol = serviceapplication->appcontrol;
2269 appcontrol_x *tmp = NULL;
2270 while(appcontrol != NULL) {
2271 tmp = appcontrol->next;
2272 __ps_free_appcontrol(appcontrol);
2276 /*Free DataControl*/
2277 if (serviceapplication->datacontrol) {
2278 datacontrol_x *datacontrol = serviceapplication->datacontrol;
2279 datacontrol_x *tmp = NULL;
2280 while(datacontrol != NULL) {
2281 tmp = datacontrol->next;
2282 __ps_free_datacontrol(datacontrol);
2286 /*Free LaunchConditions*/
2287 if (serviceapplication->launchconditions) {
2288 launchconditions_x *launchconditions = serviceapplication->launchconditions;
2289 launchconditions_x *tmp = NULL;
2290 while(launchconditions != NULL) {
2291 tmp = launchconditions->next;
2292 __ps_free_launchconditions(launchconditions);
2293 launchconditions = tmp;
2296 /*Free Notification*/
2297 if (serviceapplication->notification) {
2298 notification_x *notification = serviceapplication->notification;
2299 notification_x *tmp = NULL;
2300 while(notification != NULL) {
2301 tmp = notification->next;
2302 __ps_free_notification(notification);
2307 if (serviceapplication->datashare) {
2308 datashare_x *datashare = serviceapplication->datashare;
2309 datashare_x *tmp = NULL;
2310 while(datashare != NULL) {
2311 tmp = datashare->next;
2312 __ps_free_datashare(datashare);
2317 if (serviceapplication->appsvc) {
2318 appsvc_x *appsvc = serviceapplication->appsvc;
2319 appsvc_x *tmp = NULL;
2320 while(appsvc != NULL) {
2322 __ps_free_appsvc(appsvc);
2327 if (serviceapplication->category) {
2328 category_x *category = serviceapplication->category;
2329 category_x *tmp = NULL;
2330 while(category != NULL) {
2331 tmp = category->next;
2332 __ps_free_category(category);
2337 if (serviceapplication->metadata) {
2338 metadata_x *metadata = serviceapplication->metadata;
2339 metadata_x *tmp = NULL;
2340 while(metadata != NULL) {
2341 tmp = metadata->next;
2342 __ps_free_metadata(metadata);
2347 if (serviceapplication->permission) {
2348 permission_x *permission = serviceapplication->permission;
2349 permission_x *tmp = NULL;
2350 while(permission != NULL) {
2351 tmp = permission->next;
2352 __ps_free_permission(permission);
2356 free((void*)serviceapplication);
2357 serviceapplication = NULL;
2360 static void __ps_free_font(font_x *font)
2365 free((void *)font->name);
2369 free((void *)font->text);
2376 static void __ps_free_theme(theme_x *theme)
2381 free((void *)theme->name);
2385 free((void *)theme->text);
2392 static void __ps_free_daemon(daemon_x *daemon)
2397 free((void *)daemon->name);
2398 daemon->name = NULL;
2401 free((void *)daemon->text);
2402 daemon->text = NULL;
2404 free((void*)daemon);
2408 static void __ps_free_ime(ime_x *ime)
2413 free((void *)ime->name);
2417 free((void *)ime->text);
2424 int __ps_process_tag_parser(manifest_x *mfx, const char *filename, ACTION_TYPE action)
2426 xmlTextReaderPtr reader;
2430 void *lib_handle = NULL;
2431 char tag[PKG_STRING_LEN_MAX] = { 0 };
2433 fp = fopen(TAG_PARSER_LIST, "r");
2434 retvm_if(fp == NULL, PMINFO_R_ERROR, "no preload list");
2436 while (fgets(tag, sizeof(tag), fp) != NULL) {
2439 lib_handle = __open_lib_handle(tag);
2440 if (lib_handle == NULL)
2443 ret = __parser_send_tag(lib_handle, action, PLUGIN_PRE_PROCESS, mfx->package);
2444 _LOGD("PLUGIN_PRE_PROCESS[%s, %s] ACTION_TYPE[%d] result[%d]\n", mfx->package, tag, action, ret);
2446 docPtr = xmlReadFile(filename, NULL, 0);
2447 reader = xmlReaderWalker(docPtr);
2448 if (reader != NULL) {
2449 ret = xmlTextReaderRead(reader);
2451 __processTag(lib_handle, reader, action, tag, mfx->package);
2452 ret = xmlTextReaderRead(reader);
2454 xmlFreeTextReader(reader);
2457 _LOGD("%s : failed to parse", filename);
2460 _LOGD("Unable to open %s", filename);
2463 ret = __parser_send_tag(lib_handle, action, PLUGIN_POST_PROCESS, mfx->package);
2464 _LOGD("PLUGIN_POST_PROCESS[%s, %s] ACTION_TYPE[%d] result[%d]\n", mfx->package, tag, action, ret);
2466 __close_lib_handle(lib_handle);
2468 memset(tag, 0x00, sizeof(tag));
2477 int __ps_process_metadata_parser(manifest_x *mfx, ACTION_TYPE action)
2479 fprintf(stdout,"__ps_process_metadata_parser\n");
2482 char md_key[PKG_STRING_LEN_MAX] = { 0 };
2484 fp = fopen(METADATA_PARSER_LIST, "r");
2486 _LOGD("no preload list\n");
2490 while (fgets(md_key, sizeof(md_key), fp) != NULL) {
2492 ret = __run_metadata_parser_prestep(mfx, md_key, action);
2494 memset(md_key, 0x00, sizeof(md_key));
2503 int __ps_process_category_parser(manifest_x *mfx, ACTION_TYPE action)
2507 char category_key[PKG_STRING_LEN_MAX] = { 0 };
2509 fp = fopen(CATEGORY_PARSER_LIST, "r");
2511 _LOGD("no category parser list\n");
2515 while (fgets(category_key, sizeof(category_key), fp) != NULL) {
2516 __str_trim(category_key);
2517 ret = __run_category_parser_prestep(mfx, category_key, action);
2519 memset(category_key, 0x00, sizeof(category_key));
2528 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed)
2530 xmlTextReaderRead(reader);
2531 if (xmlTextReaderValue(reader))
2532 allowed->text = ASCII(xmlTextReaderValue(reader));
2536 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation)
2538 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2539 operation->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2540 /* Text does not exist. Only attribute exists
2541 xmlTextReaderRead(reader);
2542 if (xmlTextReaderValue(reader))
2543 operation->text = ASCII(xmlTextReaderValue(reader));
2548 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri)
2550 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2551 uri->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2552 /* Text does not exist. Only attribute exists
2553 xmlTextReaderRead(reader);
2554 if (xmlTextReaderValue(reader))
2555 uri->text = ASCII(xmlTextReaderValue(reader));
2560 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime)
2562 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2563 mime->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2564 /* Text does not exist. Only attribute exists
2565 xmlTextReaderRead(reader);
2566 if (xmlTextReaderValue(reader))
2567 mime->text = ASCII(xmlTextReaderValue(reader));
2572 static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp)
2574 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2575 subapp->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2576 /* Text does not exist. Only attribute exists
2577 xmlTextReaderRead(reader);
2578 if (xmlTextReaderValue(reader))
2579 mime->text = ASCII(xmlTextReaderValue(reader));
2584 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition)
2586 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2587 condition->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2588 xmlTextReaderRead(reader);
2589 if (xmlTextReaderValue(reader))
2590 condition->text = ASCII(xmlTextReaderValue(reader));
2594 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notification)
2596 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2597 notification->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2598 xmlTextReaderRead(reader);
2599 if (xmlTextReaderValue(reader))
2600 notification->text = ASCII(xmlTextReaderValue(reader));
2604 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category)
2606 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2607 category->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2611 static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege)
2613 xmlTextReaderRead(reader);
2614 if (xmlTextReaderValue(reader)) {
2615 privilege->text = ASCII(xmlTextReaderValue(reader));
2620 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata)
2622 if (xmlTextReaderGetAttribute(reader, XMLCHAR("key")))
2623 metadata->key = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("key")));
2624 if (xmlTextReaderGetAttribute(reader, XMLCHAR("value")))
2625 metadata->value = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("value")));
2629 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission)
2631 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
2632 permission->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
2634 xmlTextReaderRead(reader);
2635 if (xmlTextReaderValue(reader))
2636 permission->value = ASCII(xmlTextReaderValue(reader));
2640 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility)
2642 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2643 compatibility->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2644 xmlTextReaderRead(reader);
2645 if (xmlTextReaderValue(reader))
2646 compatibility->text = ASCII(xmlTextReaderValue(reader));
2650 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution)
2652 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")))
2653 resolution->mimetype = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")));
2654 if (xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")))
2655 resolution->urischeme = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")));
2659 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request)
2661 xmlTextReaderRead(reader);
2662 if (xmlTextReaderValue(reader))
2663 request->text = ASCII(xmlTextReaderValue(reader));
2667 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define)
2669 const xmlChar *node;
2672 allowed_x *tmp1 = NULL;
2673 request_x *tmp2 = NULL;
2675 if (xmlTextReaderGetAttribute(reader, XMLCHAR("path")))
2676 define->path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("path")));
2678 depth = xmlTextReaderDepth(reader);
2679 while ((ret = __next_child_element(reader, depth))) {
2680 node = xmlTextReaderConstName(reader);
2682 _LOGD("xmlTextReaderConstName value is NULL\n");
2686 if (!strcmp(ASCII(node), "allowed")) {
2687 allowed_x *allowed= malloc(sizeof(allowed_x));
2688 if (allowed == NULL) {
2689 _LOGD("Malloc Failed\n");
2692 memset(allowed, '\0', sizeof(allowed_x));
2693 LISTADD(define->allowed, allowed);
2694 ret = __ps_process_allowed(reader, allowed);
2695 } else if (!strcmp(ASCII(node), "request")) {
2696 request_x *request = malloc(sizeof(request_x));
2697 if (request == NULL) {
2698 _LOGD("Malloc Failed\n");
2701 memset(request, '\0', sizeof(request_x));
2702 LISTADD(define->request, request);
2703 ret = __ps_process_request(reader, request);
2707 _LOGD("Processing define failed\n");
2711 if (define->allowed) {
2712 LISTHEAD(define->allowed, tmp1);
2713 define->allowed = tmp1;
2715 if (define->request) {
2716 LISTHEAD(define->request, tmp2);
2717 define->request = tmp2;
2722 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol)
2724 const xmlChar *node;
2727 operation_x *tmp1 = NULL;
2729 mime_x *tmp3 = NULL;
2730 subapp_x *tmp4 = NULL;
2732 depth = xmlTextReaderDepth(reader);
2733 while ((ret = __next_child_element(reader, depth))) {
2734 node = xmlTextReaderConstName(reader);
2736 _LOGD("xmlTextReaderConstName value is NULL\n");
2740 if (!strcmp(ASCII(node), "operation")) {
2741 operation_x *operation = malloc(sizeof(operation_x));
2742 if (operation == NULL) {
2743 _LOGD("Malloc Failed\n");
2746 memset(operation, '\0', sizeof(operation_x));
2747 LISTADD(appcontrol->operation, operation);
2748 ret = __ps_process_operation(reader, operation);
2749 _LOGD("operation processing\n");
2750 } else if (!strcmp(ASCII(node), "uri")) {
2751 uri_x *uri= malloc(sizeof(uri_x));
2753 _LOGD("Malloc Failed\n");
2756 memset(uri, '\0', sizeof(uri_x));
2757 LISTADD(appcontrol->uri, uri);
2758 ret = __ps_process_uri(reader, uri);
2759 _LOGD("uri processing\n");
2760 } else if (!strcmp(ASCII(node), "mime")) {
2761 mime_x *mime = malloc(sizeof(mime_x));
2763 _LOGD("Malloc Failed\n");
2766 memset(mime, '\0', sizeof(mime_x));
2767 LISTADD(appcontrol->mime, mime);
2768 ret = __ps_process_mime(reader, mime);
2769 _LOGD("mime processing\n");
2770 } else if (!strcmp(ASCII(node), "subapp")) {
2771 subapp_x *subapp = malloc(sizeof(subapp_x));
2772 if (subapp == NULL) {
2773 _LOGD("Malloc Failed\n");
2776 memset(subapp, '\0', sizeof(subapp_x));
2777 LISTADD(appcontrol->subapp, subapp);
2778 ret = __ps_process_subapp(reader, subapp);
2779 _LOGD("subapp processing\n");
2783 _LOGD("Processing appcontrol failed\n");
2787 if (appcontrol->operation) {
2788 LISTHEAD(appcontrol->operation, tmp1);
2789 appcontrol->operation = tmp1;
2791 if (appcontrol->uri) {
2792 LISTHEAD(appcontrol->uri, tmp2);
2793 appcontrol->uri = tmp2;
2795 if (appcontrol->mime) {
2796 LISTHEAD(appcontrol->mime, tmp3);
2797 appcontrol->mime = tmp3;
2799 if (appcontrol->subapp) {
2800 LISTHEAD(appcontrol->subapp, tmp4);
2801 appcontrol->subapp = tmp4;
2804 xmlTextReaderRead(reader);
2805 if (xmlTextReaderValue(reader))
2806 appcontrol->text = ASCII(xmlTextReaderValue(reader));
2811 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc)
2813 const xmlChar *node;
2816 operation_x *tmp1 = NULL;
2818 mime_x *tmp3 = NULL;
2819 subapp_x *tmp4 = NULL;
2821 depth = xmlTextReaderDepth(reader);
2822 while ((ret = __next_child_element(reader, depth))) {
2823 node = xmlTextReaderConstName(reader);
2825 _LOGD("xmlTextReaderConstName value is NULL\n");
2829 if (!strcmp(ASCII(node), "operation")) {
2830 operation_x *operation = malloc(sizeof(operation_x));
2831 if (operation == NULL) {
2832 _LOGD("Malloc Failed\n");
2835 memset(operation, '\0', sizeof(operation_x));
2836 LISTADD(appsvc->operation, operation);
2837 ret = __ps_process_operation(reader, operation);
2838 _LOGD("operation processing\n");
2839 } else if (!strcmp(ASCII(node), "uri")) {
2840 uri_x *uri= malloc(sizeof(uri_x));
2842 _LOGD("Malloc Failed\n");
2845 memset(uri, '\0', sizeof(uri_x));
2846 LISTADD(appsvc->uri, uri);
2847 ret = __ps_process_uri(reader, uri);
2848 _LOGD("uri processing\n");
2849 } else if (!strcmp(ASCII(node), "mime")) {
2850 mime_x *mime = malloc(sizeof(mime_x));
2852 _LOGD("Malloc Failed\n");
2855 memset(mime, '\0', sizeof(mime_x));
2856 LISTADD(appsvc->mime, mime);
2857 ret = __ps_process_mime(reader, mime);
2858 _LOGD("mime processing\n");
2859 } else if (!strcmp(ASCII(node), "subapp")) {
2860 subapp_x *subapp = malloc(sizeof(subapp_x));
2861 if (subapp == NULL) {
2862 _LOGD("Malloc Failed\n");
2865 memset(subapp, '\0', sizeof(subapp_x));
2866 LISTADD(appsvc->subapp, subapp);
2867 ret = __ps_process_subapp(reader, subapp);
2868 _LOGD("subapp processing\n");
2872 _LOGD("Processing appsvc failed\n");
2876 if (appsvc->operation) {
2877 LISTHEAD(appsvc->operation, tmp1);
2878 appsvc->operation = tmp1;
2881 LISTHEAD(appsvc->uri, tmp2);
2885 LISTHEAD(appsvc->mime, tmp3);
2886 appsvc->mime = tmp3;
2888 if (appsvc->subapp) {
2889 LISTHEAD(appsvc->subapp, tmp4);
2890 appsvc->subapp = tmp4;
2893 xmlTextReaderRead(reader);
2894 if (xmlTextReaderValue(reader))
2895 appsvc->text = ASCII(xmlTextReaderValue(reader));
2901 static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privileges)
2903 const xmlChar *node;
2906 privilege_x *tmp1 = NULL;
2908 depth = xmlTextReaderDepth(reader);
2909 while ((ret = __next_child_element(reader, depth))) {
2910 node = xmlTextReaderConstName(reader);
2912 _LOGD("xmlTextReaderConstName value is NULL\n");
2916 if (strcmp(ASCII(node), "privilege") == 0) {
2917 privilege_x *privilege = malloc(sizeof(privilege_x));
2918 if (privilege == NULL) {
2919 _LOGD("Malloc Failed\n");
2922 memset(privilege, '\0', sizeof(privilege_x));
2923 LISTADD(privileges->privilege, privilege);
2924 ret = __ps_process_privilege(reader, privilege);
2928 _LOGD("Processing privileges failed\n");
2932 if (privileges->privilege) {
2933 LISTHEAD(privileges->privilege, tmp1);
2934 privileges->privilege = tmp1;
2939 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions)
2941 const xmlChar *node;
2944 condition_x *tmp1 = NULL;
2946 depth = xmlTextReaderDepth(reader);
2947 while ((ret = __next_child_element(reader, depth))) {
2948 node = xmlTextReaderConstName(reader);
2950 _LOGD("xmlTextReaderConstName value is NULL\n");
2954 if (strcmp(ASCII(node), "condition") == 0) {
2955 condition_x *condition = malloc(sizeof(condition_x));
2956 if (condition == NULL) {
2957 _LOGD("Malloc Failed\n");
2960 memset(condition, '\0', sizeof(condition_x));
2961 LISTADD(launchconditions->condition, condition);
2962 ret = __ps_process_condition(reader, condition);
2966 _LOGD("Processing launchconditions failed\n");
2970 if (launchconditions->condition) {
2971 LISTHEAD(launchconditions->condition, tmp1);
2972 launchconditions->condition = tmp1;
2975 xmlTextReaderRead(reader);
2976 if (xmlTextReaderValue(reader))
2977 launchconditions->text = ASCII(xmlTextReaderValue(reader));
2982 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare)
2984 const xmlChar *node;
2987 define_x *tmp1 = NULL;
2988 request_x *tmp2 = NULL;
2989 depth = xmlTextReaderDepth(reader);
2990 while ((ret = __next_child_element(reader, depth))) {
2991 node = xmlTextReaderConstName(reader);
2993 _LOGD("xmlTextReaderConstName value is NULL\n");
2997 if (!strcmp(ASCII(node), "define")) {
2998 define_x *define= malloc(sizeof(define_x));
2999 if (define == NULL) {
3000 _LOGD("Malloc Failed\n");
3003 memset(define, '\0', sizeof(define_x));
3004 LISTADD(datashare->define, define);
3005 ret = __ps_process_define(reader, define);
3006 } else if (!strcmp(ASCII(node), "request")) {
3007 request_x *request= malloc(sizeof(request_x));
3008 if (request == NULL) {
3009 _LOGD("Malloc Failed\n");
3012 memset(request, '\0', sizeof(request_x));
3013 LISTADD(datashare->request, request);
3014 ret = __ps_process_request(reader, request);
3018 _LOGD("Processing data-share failed\n");
3022 if (datashare->define) {
3023 LISTHEAD(datashare->define, tmp1);
3024 datashare->define = tmp1;
3026 if (datashare->request) {
3027 LISTHEAD(datashare->request, tmp2);
3028 datashare->request = tmp2;
3034 __get_icon_with_path(const char* icon, uid_t uid)
3039 if (index(icon, '/') == NULL) {
3041 char* icon_with_path = NULL;
3042 char *app_path = NULL;
3048 /* "db/setting/theme" is not exist */
3050 theme = vconf_get_str("db/setting/theme");
3052 theme = strdup("default");
3058 theme = strdup("default");
3061 len = (0x01 << 7) + strlen(icon) + strlen(package) + strlen(theme);
3062 icon_with_path = malloc(len);
3063 if(icon_with_path == NULL) {
3064 _LOGD("(icon_with_path == NULL) return\n");
3069 memset(icon_with_path, 0, len);
3070 if (uid != GLOBAL_USER)
3071 snprintf(icon_with_path, len, "%s%s", getIconPath(uid), icon);
3073 snprintf(icon_with_path, len, "%s%s/small/%s", getIconPath(GLOBAL_USER), theme, icon);
3074 if (access (icon_with_path, F_OK)) { //If doesn't exist in case of Global app, try to get icon directly into app's directory
3075 app_path = tzplatform_getenv(TZ_SYS_RW_APP);
3077 snprintf(icon_with_path, len, "%s/%q/res/icons/%q/small/%q", app_path, package, theme, icon);
3078 if (access (icon_with_path, F_OK))
3079 _LOGE("Cannot find icon path");
3083 _LOGD("Icon path : %s ---> %s", icon, icon_with_path);
3084 return icon_with_path;
3086 char* confirmed_icon = NULL;
3088 confirmed_icon = strdup(icon);
3089 if (!confirmed_icon)
3091 return confirmed_icon;
3095 static void __ps_process_tag(manifest_x * mfx, char *const tagv[])
3098 char delims[] = "=";
3099 char *ret_result = NULL;
3105 for (tag = strdup(tagv[0]); tag != NULL; ) {
3106 ret_result = strtok(tag, delims);
3108 /*check tag : preload */
3109 if (strcmp(ret_result, "preload") == 0) {
3110 ret_result = strtok(NULL, delims);
3111 if (strcmp(ret_result, "true") == 0) {
3112 free((void *)mfx->preload);
3113 mfx->preload = strdup("true");
3114 } else if (strcmp(ret_result, "false") == 0) {
3115 free((void *)mfx->preload);
3116 mfx->preload = strdup("false");
3118 /*check tag : removable*/
3119 } else if (strcmp(ret_result, "removable") == 0) {
3120 ret_result = strtok(NULL, delims);
3121 if (strcmp(ret_result, "true") == 0){
3122 free((void *)mfx->removable);
3123 mfx->removable = strdup("true");
3124 } else if (strcmp(ret_result, "false") == 0) {
3125 free((void *)mfx->removable);
3126 mfx->removable = strdup("false");
3128 /*check tag : not matched*/
3130 _LOGD("tag process [%s]is not defined\n", ret_result);
3134 /*check next value*/
3135 if (tagv[++i] != NULL)
3136 tag = strdup(tagv[i]);
3138 _LOGD("tag process success...\n");
3144 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon, uid_t uid)
3146 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
3147 icon->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
3148 if (xmlTextReaderConstXmlLang(reader)) {
3149 icon->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3150 if (icon->lang == NULL)
3151 icon->lang = strdup(DEFAULT_LOCALE);
3153 icon->lang = strdup(DEFAULT_LOCALE);
3155 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
3156 icon->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
3157 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
3158 icon->size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
3159 if (xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")))
3160 icon->resolution = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")));
3161 xmlTextReaderRead(reader);
3162 if (xmlTextReaderValue(reader)) {
3163 const char *text = ASCII(xmlTextReaderValue(reader));
3165 icon->text = (const char *)__get_icon_with_path(text, uid);
3173 static int __ps_process_image(xmlTextReaderPtr reader, image_x *image)
3175 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
3176 image->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
3177 if (xmlTextReaderConstXmlLang(reader)) {
3178 image->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3179 if (image->lang == NULL)
3180 image->lang = strdup(DEFAULT_LOCALE);
3182 image->lang = strdup(DEFAULT_LOCALE);
3184 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
3185 image->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
3186 xmlTextReaderRead(reader);
3187 if (xmlTextReaderValue(reader))
3188 image->text = ASCII(xmlTextReaderValue(reader));
3193 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label)
3195 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
3196 label->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
3197 if (xmlTextReaderConstXmlLang(reader)) {
3198 label->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3199 if (label->lang == NULL)
3200 label->lang = strdup(DEFAULT_LOCALE);
3202 label->lang = strdup(DEFAULT_LOCALE);
3203 xmlTextReaderRead(reader);
3204 if (xmlTextReaderValue(reader))
3205 label->text = ASCII(xmlTextReaderValue(reader));
3208 /* _LOGD("lable name %s\n", label->name);
3209 _LOGD("lable lang %s\n", label->lang);
3210 _LOGD("lable text %s\n", label->text);
3216 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author)
3218 if (xmlTextReaderGetAttribute(reader, XMLCHAR("email")))
3219 author->email = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("email")));
3220 if (xmlTextReaderGetAttribute(reader, XMLCHAR("href")))
3221 author->href = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("href")));
3222 if (xmlTextReaderConstXmlLang(reader)) {
3223 author->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3224 if (author->lang == NULL)
3225 author->lang = strdup(DEFAULT_LOCALE);
3227 author->lang = strdup(DEFAULT_LOCALE);
3229 xmlTextReaderRead(reader);
3230 if (xmlTextReaderValue(reader)) {
3231 const char *text = ASCII(xmlTextReaderValue(reader));
3232 if (*text == '\n') {
3233 author->text = NULL;
3237 author->text = ASCII(xmlTextReaderValue(reader));
3242 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description)
3244 if (xmlTextReaderConstXmlLang(reader)) {
3245 description->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3246 if (description->lang == NULL)
3247 description->lang = strdup(DEFAULT_LOCALE);
3249 description->lang = strdup(DEFAULT_LOCALE);
3251 xmlTextReaderRead(reader);
3252 if (xmlTextReaderValue(reader)) {
3253 const char *text = ASCII(xmlTextReaderValue(reader));
3254 if (*text == '\n') {
3255 description->text = NULL;
3259 description->text = ASCII(xmlTextReaderValue(reader));
3264 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license)
3266 if (xmlTextReaderConstXmlLang(reader)) {
3267 license->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3268 if (license->lang == NULL)
3269 license->lang = strdup(DEFAULT_LOCALE);
3271 license->lang = strdup(DEFAULT_LOCALE);
3273 xmlTextReaderRead(reader);
3274 if (xmlTextReaderValue(reader))
3275 license->text = ASCII(xmlTextReaderValue(reader));
3279 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability)
3281 const xmlChar *node;
3284 resolution_x *tmp1 = NULL;
3286 if (xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")))
3287 capability->operationid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")));
3289 depth = xmlTextReaderDepth(reader);
3290 while ((ret = __next_child_element(reader, depth))) {
3291 node = xmlTextReaderConstName(reader);
3293 _LOGD("xmlTextReaderConstName value is NULL\n");
3297 if (!strcmp(ASCII(node), "resolution")) {
3298 resolution_x *resolution = malloc(sizeof(resolution_x));
3299 if (resolution == NULL) {
3300 _LOGD("Malloc Failed\n");
3303 memset(resolution, '\0', sizeof(resolution_x));
3304 LISTADD(capability->resolution, resolution);
3305 ret = __ps_process_resolution(reader, resolution);
3309 _LOGD("Processing capability failed\n");
3314 if (capability->resolution) {
3315 LISTHEAD(capability->resolution, tmp1);
3316 capability->resolution = tmp1;
3322 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol)
3324 if (xmlTextReaderGetAttribute(reader, XMLCHAR("providerid")))
3325 datacontrol->providerid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("providerid")));
3326 if (xmlTextReaderGetAttribute(reader, XMLCHAR("access")))
3327 datacontrol->access = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("access")));
3328 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
3329 datacontrol->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
3334 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication, uid_t uid)
3336 const xmlChar *node;
3339 char *newappid = NULL;
3340 label_x *tmp1 = NULL;
3341 icon_x *tmp2 = NULL;
3342 appsvc_x *tmp3 = NULL;
3343 appcontrol_x *tmp4 = NULL;
3344 launchconditions_x *tmp5 = NULL;
3345 notification_x *tmp6 = NULL;
3346 datashare_x *tmp7 = NULL;
3347 category_x *tmp8 = NULL;
3348 metadata_x *tmp9 = NULL;
3349 image_x *tmp10 = NULL;
3350 permission_x *tmp11 = NULL;
3352 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
3353 uiapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
3354 if (uiapplication->appid == NULL) {
3355 _LOGD("appid cant be NULL\n");
3359 _LOGD("appid is mandatory\n");
3363 ret = __validate_appid(package, uiapplication->appid, &newappid);
3365 _LOGD("appid is not proper\n");
3369 if (uiapplication->appid)
3370 free((void *)uiapplication->appid);
3371 uiapplication->appid = newappid;
3373 uiapplication->package= strdup(package);
3375 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
3376 uiapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
3377 if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay"))) {
3378 uiapplication->nodisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay")));
3379 if (uiapplication->nodisplay == NULL)
3380 uiapplication->nodisplay = strdup("false");
3382 uiapplication->nodisplay = strdup("false");
3384 if (xmlTextReaderGetAttribute(reader, XMLCHAR("multiple"))) {
3385 uiapplication->multiple = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("multiple")));
3386 if (uiapplication->multiple == NULL)
3387 uiapplication->multiple = strdup("false");
3389 uiapplication->multiple = strdup("false");
3391 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
3392 uiapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
3393 if (xmlTextReaderGetAttribute(reader, XMLCHAR("categories")))
3394 uiapplication->categories = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("categories")));
3395 if (xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")))
3396 uiapplication->extraid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")));
3397 if (xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage"))) {
3398 uiapplication->taskmanage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage")));
3399 if (uiapplication->taskmanage == NULL)
3400 uiapplication->taskmanage = strdup("true");
3402 uiapplication->taskmanage = strdup("true");
3404 if (xmlTextReaderGetAttribute(reader, XMLCHAR("enabled"))) {
3405 uiapplication->enabled = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("enabled")));
3406 if (uiapplication->enabled == NULL)
3407 uiapplication->enabled = strdup("true");
3409 uiapplication->enabled = strdup("true");
3411 if (xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration"))) {
3412 uiapplication->hwacceleration = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration")));
3413 if (uiapplication->hwacceleration == NULL)
3414 uiapplication->hwacceleration = strdup("use-system-setting");
3416 uiapplication->hwacceleration = strdup("use-system-setting");
3418 if (xmlTextReaderGetAttribute(reader, XMLCHAR("screen-reader"))) {
3419 uiapplication->screenreader = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("screen-reader")));
3420 if (uiapplication->screenreader == NULL)
3421 uiapplication->screenreader = strdup("use-system-setting");
3423 uiapplication->screenreader = strdup("use-system-setting");
3425 if (xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")))
3426 uiapplication->recentimage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")));
3427 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp"))) {
3428 uiapplication->mainapp = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp")));
3429 if (uiapplication->mainapp == NULL)
3430 uiapplication->mainapp = strdup("false");
3432 uiapplication->mainapp = strdup("false");
3434 if (xmlTextReaderGetAttribute(reader, XMLCHAR("launchcondition"))) {
3435 uiapplication->launchcondition = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("launchcondition")));
3436 if (uiapplication->launchcondition == NULL)
3437 uiapplication->launchcondition = strdup("false");
3439 uiapplication->launchcondition = strdup("false");
3442 if (xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay"))) {
3443 uiapplication->indicatordisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay")));
3444 if (uiapplication->indicatordisplay == NULL)
3445 uiapplication->indicatordisplay = strdup("true");
3447 uiapplication->indicatordisplay = strdup("true");
3449 if (xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")))
3450 uiapplication->portraitimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")));
3452 uiapplication->portraitimg = NULL;
3453 if (xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")))
3454 uiapplication->landscapeimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")));
3456 uiapplication->landscapeimg = NULL;
3457 if (xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility"))) {
3458 uiapplication->guestmode_visibility = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility")));
3459 if (uiapplication->guestmode_visibility == NULL)
3460 uiapplication->guestmode_visibility = strdup("true");
3462 uiapplication->guestmode_visibility = strdup("true");
3464 if (xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type"))) {
3465 uiapplication->permission_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type")));
3466 if (uiapplication->permission_type == NULL)
3467 uiapplication->permission_type = strdup("normal");
3469 uiapplication->permission_type = strdup("normal");
3471 if (xmlTextReaderGetAttribute(reader, XMLCHAR("component-type"))) {
3472 uiapplication->component_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("component-type")));
3473 if (uiapplication->component_type == NULL)
3474 uiapplication->component_type = strdup("uiapp");
3476 uiapplication->component_type = strdup("uiapp");
3478 if (xmlTextReaderGetAttribute(reader, XMLCHAR("submode"))) {
3479 uiapplication->submode = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("submode")));
3480 if (uiapplication->submode == NULL)
3481 uiapplication->submode = strdup("false");
3483 uiapplication->submode = strdup("false");
3485 if (xmlTextReaderGetAttribute(reader, XMLCHAR("submode-mainid")))
3486 uiapplication->submode_mainid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("submode-mainid")));
3487 if (xmlTextReaderGetAttribute(reader, XMLCHAR("launch_mode"))) {
3488 uiapplication->launch_mode = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("launch_mode")));
3489 if (uiapplication->launch_mode == NULL)
3490 uiapplication->launch_mode = strdup("caller");
3492 uiapplication->launch_mode = strdup("caller");
3495 depth = xmlTextReaderDepth(reader);
3496 while ((ret = __next_child_element(reader, depth))) {
3497 node = xmlTextReaderConstName(reader);
3499 _LOGD("xmlTextReaderConstName value is NULL\n");
3502 if (!strcmp(ASCII(node), "label")) {
3503 label_x *label = malloc(sizeof(label_x));
3504 if (label == NULL) {
3505 _LOGD("Malloc Failed\n");
3508 memset(label, '\0', sizeof(label_x));
3509 LISTADD(uiapplication->label, label);
3510 ret = __ps_process_label(reader, label);
3511 } else if (!strcmp(ASCII(node), "icon")) {
3512 icon_x *icon = malloc(sizeof(icon_x));
3514 _LOGD("Malloc Failed\n");
3517 memset(icon, '\0', sizeof(icon_x));
3518 LISTADD(uiapplication->icon, icon);
3519 ret = __ps_process_icon(reader, icon, uid);
3520 } else if (!strcmp(ASCII(node), "image")) {
3521 image_x *image = malloc(sizeof(image_x));
3522 if (image == NULL) {
3523 _LOGD("Malloc Failed\n");
3526 memset(image, '\0', sizeof(image_x));
3527 LISTADD(uiapplication->image, image);
3528 ret = __ps_process_image(reader, image);
3529 } else if (!strcmp(ASCII(node), "category")) {
3530 category_x *category = malloc(sizeof(category_x));
3531 if (category == NULL) {
3532 _LOGD("Malloc Failed\n");
3535 memset(category, '\0', sizeof(category_x));
3536 LISTADD(uiapplication->category, category);
3537 ret = __ps_process_category(reader, category);
3538 } else if (!strcmp(ASCII(node), "metadata")) {
3539 metadata_x *metadata = malloc(sizeof(metadata_x));
3540 if (metadata == NULL) {
3541 _LOGD("Malloc Failed\n");
3544 memset(metadata, '\0', sizeof(metadata_x));
3545 LISTADD(uiapplication->metadata, metadata);
3546 ret = __ps_process_metadata(reader, metadata);
3547 } else if (!strcmp(ASCII(node), "permission")) {
3548 permission_x *permission = malloc(sizeof(permission_x));
3549 if (permission == NULL) {
3550 _LOGD("Malloc Failed\n");
3553 memset(permission, '\0', sizeof(permission_x));
3554 LISTADD(uiapplication->permission, permission);
3555 ret = __ps_process_permission(reader, permission);
3556 } else if (!strcmp(ASCII(node), "app-control")) {
3557 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
3558 if (appcontrol == NULL) {
3559 _LOGD("Malloc Failed\n");
3562 memset(appcontrol, '\0', sizeof(appcontrol_x));
3563 LISTADD(uiapplication->appcontrol, appcontrol);
3564 ret = __ps_process_appcontrol(reader, appcontrol);
3565 } else if (!strcmp(ASCII(node), "application-service")) {
3566 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
3567 if (appsvc == NULL) {
3568 _LOGD("Malloc Failed\n");
3571 memset(appsvc, '\0', sizeof(appsvc_x));
3572 LISTADD(uiapplication->appsvc, appsvc);
3573 ret = __ps_process_appsvc(reader, appsvc);
3574 } else if (!strcmp(ASCII(node), "data-share")) {
3575 datashare_x *datashare = malloc(sizeof(datashare_x));
3576 if (datashare == NULL) {
3577 _LOGD("Malloc Failed\n");
3580 memset(datashare, '\0', sizeof(datashare_x));
3581 LISTADD(uiapplication->datashare, datashare);
3582 ret = __ps_process_datashare(reader, datashare);
3583 } else if (!strcmp(ASCII(node), "launch-conditions")) {
3584 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
3585 if (launchconditions == NULL) {
3586 _LOGD("Malloc Failed\n");
3589 memset(launchconditions, '\0', sizeof(launchconditions_x));
3590 LISTADD(uiapplication->launchconditions, launchconditions);
3591 ret = __ps_process_launchconditions(reader, launchconditions);
3592 } else if (!strcmp(ASCII(node), "notification")) {
3593 notification_x *notification = malloc(sizeof(notification_x));
3594 if (notification == NULL) {
3595 _LOGD("Malloc Failed\n");
3598 memset(notification, '\0', sizeof(notification_x));
3599 LISTADD(uiapplication->notification, notification);
3600 ret = __ps_process_notification(reader, notification);
3604 _LOGD("Processing uiapplication failed\n");
3609 if (uiapplication->label) {
3610 LISTHEAD(uiapplication->label, tmp1);
3611 uiapplication->label = tmp1;
3613 if (uiapplication->icon) {
3614 LISTHEAD(uiapplication->icon, tmp2);
3615 uiapplication->icon = tmp2;
3617 if (uiapplication->appsvc) {
3618 LISTHEAD(uiapplication->appsvc, tmp3);
3619 uiapplication->appsvc = tmp3;
3621 if (uiapplication->appcontrol) {
3622 LISTHEAD(uiapplication->appcontrol, tmp4);
3623 uiapplication->appcontrol = tmp4;
3625 if (uiapplication->launchconditions) {
3626 LISTHEAD(uiapplication->launchconditions, tmp5);
3627 uiapplication->launchconditions = tmp5;
3629 if (uiapplication->notification) {
3630 LISTHEAD(uiapplication->notification, tmp6);
3631 uiapplication->notification = tmp6;
3633 if (uiapplication->datashare) {
3634 LISTHEAD(uiapplication->datashare, tmp7);
3635 uiapplication->datashare = tmp7;
3637 if (uiapplication->category) {
3638 LISTHEAD(uiapplication->category, tmp8);
3639 uiapplication->category = tmp8;
3641 if (uiapplication->metadata) {
3642 LISTHEAD(uiapplication->metadata, tmp9);
3643 uiapplication->metadata = tmp9;
3645 if (uiapplication->image) {
3646 LISTHEAD(uiapplication->image, tmp10);
3647 uiapplication->image = tmp10;
3649 if (uiapplication->permission) {
3650 LISTHEAD(uiapplication->permission, tmp11);
3651 uiapplication->permission = tmp11;
3657 static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication, uid_t uid)
3659 const xmlChar *node;
3662 char *newappid = NULL;
3663 label_x *tmp1 = NULL;
3664 icon_x *tmp2 = NULL;
3665 appsvc_x *tmp3 = NULL;
3666 appcontrol_x *tmp4 = NULL;
3667 datacontrol_x *tmp5 = NULL;
3668 launchconditions_x *tmp6 = NULL;
3669 notification_x *tmp7 = NULL;
3670 datashare_x *tmp8 = NULL;
3671 category_x *tmp9 = NULL;
3672 metadata_x *tmp10 = NULL;
3673 permission_x *tmp11 = NULL;
3675 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
3676 serviceapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
3677 if (serviceapplication->appid == NULL) {
3678 _LOGD("appid cant be NULL\n");
3682 _LOGD("appid is mandatory\n");
3686 ret = __validate_appid(package, serviceapplication->appid, &newappid);
3688 _LOGD("appid is not proper\n");
3692 if (serviceapplication->appid)
3693 free((void *)serviceapplication->appid);
3694 serviceapplication->appid = newappid;
3697 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
3698 serviceapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
3699 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
3700 serviceapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
3701 if (xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot"))) {
3702 serviceapplication->onboot = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot")));
3703 if (serviceapplication->onboot == NULL)
3704 serviceapplication->onboot = strdup("false");
3706 serviceapplication->onboot = strdup("false");
3708 if (xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart"))) {
3709 serviceapplication->autorestart = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart")));
3710 if (serviceapplication->autorestart == NULL)
3711 serviceapplication->autorestart = strdup("false");
3713 serviceapplication->autorestart = strdup("false");
3715 if (xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type"))) {
3716 serviceapplication->permission_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type")));
3717 if (serviceapplication->permission_type == NULL)
3718 serviceapplication->permission_type = strdup("normal");
3720 serviceapplication->permission_type = strdup("normal");
3723 depth = xmlTextReaderDepth(reader);
3724 while ((ret = __next_child_element(reader, depth))) {
3725 node = xmlTextReaderConstName(reader);
3727 _LOGD("xmlTextReaderConstName value is NULL\n");
3731 if (!strcmp(ASCII(node), "label")) {
3732 label_x *label = malloc(sizeof(label_x));
3733 if (label == NULL) {
3734 _LOGD("Malloc Failed\n");
3737 memset(label, '\0', sizeof(label_x));
3738 LISTADD(serviceapplication->label, label);
3739 ret = __ps_process_label(reader, label);
3740 } else if (!strcmp(ASCII(node), "icon")) {
3741 icon_x *icon = malloc(sizeof(icon_x));
3743 _LOGD("Malloc Failed\n");
3746 memset(icon, '\0', sizeof(icon_x));
3747 LISTADD(serviceapplication->icon, icon);
3748 ret = __ps_process_icon(reader, icon, uid);
3749 } else if (!strcmp(ASCII(node), "category")) {
3750 category_x *category = malloc(sizeof(category_x));
3751 if (category == NULL) {
3752 _LOGD("Malloc Failed\n");
3755 memset(category, '\0', sizeof(category_x));
3756 LISTADD(serviceapplication->category, category);
3757 ret = __ps_process_category(reader, category);
3758 } else if (!strcmp(ASCII(node), "metadata")) {
3759 metadata_x *metadata = malloc(sizeof(metadata_x));
3760 if (metadata == NULL) {
3761 _LOGD("Malloc Failed\n");
3764 memset(metadata, '\0', sizeof(metadata_x));
3765 LISTADD(serviceapplication->metadata, metadata);
3766 ret = __ps_process_metadata(reader, metadata);
3767 } else if (!strcmp(ASCII(node), "permission")) {
3768 permission_x *permission = malloc(sizeof(permission_x));
3769 if (permission == NULL) {
3770 _LOGD("Malloc Failed\n");
3773 memset(permission, '\0', sizeof(permission_x));
3774 LISTADD(serviceapplication->permission, permission);
3775 ret = __ps_process_permission(reader, permission);
3776 } else if (!strcmp(ASCII(node), "app-control")) {
3777 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
3778 if (appcontrol == NULL) {
3779 _LOGD("Malloc Failed\n");
3782 memset(appcontrol, '\0', sizeof(appcontrol_x));
3783 LISTADD(serviceapplication->appcontrol, appcontrol);
3784 ret = __ps_process_appcontrol(reader, appcontrol);
3785 } else if (!strcmp(ASCII(node), "application-service")) {
3786 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
3787 if (appsvc == NULL) {
3788 _LOGD("Malloc Failed\n");
3791 memset(appsvc, '\0', sizeof(appsvc_x));
3792 LISTADD(serviceapplication->appsvc, appsvc);
3793 ret = __ps_process_appsvc(reader, appsvc);
3794 } else if (!strcmp(ASCII(node), "data-share")) {
3795 datashare_x *datashare = malloc(sizeof(datashare_x));
3796 if (datashare == NULL) {
3797 _LOGD("Malloc Failed\n");
3800 memset(datashare, '\0', sizeof(datashare_x));
3801 LISTADD(serviceapplication->datashare, datashare);
3802 ret = __ps_process_datashare(reader, datashare);
3803 } else if (!strcmp(ASCII(node), "launch-conditions")) {
3804 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
3805 if (launchconditions == NULL) {
3806 _LOGD("Malloc Failed\n");
3809 memset(launchconditions, '\0', sizeof(launchconditions_x));
3810 LISTADD(serviceapplication->launchconditions, launchconditions);
3811 ret = __ps_process_launchconditions(reader, launchconditions);
3812 } else if (!strcmp(ASCII(node), "notification")) {
3813 notification_x *notification = malloc(sizeof(notification_x));
3814 if (notification == NULL) {
3815 _LOGD("Malloc Failed\n");
3818 memset(notification, '\0', sizeof(notification_x));
3819 LISTADD(serviceapplication->notification, notification);
3820 ret = __ps_process_notification(reader, notification);
3821 } else if (!strcmp(ASCII(node), "datacontrol")) {
3822 datacontrol_x *datacontrol = malloc(sizeof(datacontrol_x));
3823 if (datacontrol == NULL) {
3824 _LOGD("Malloc Failed\n");
3827 memset(datacontrol, '\0', sizeof(datacontrol_x));
3828 LISTADD(serviceapplication->datacontrol, datacontrol);
3829 ret = __ps_process_datacontrol(reader, datacontrol);
3833 _LOGD("Processing serviceapplication failed\n");
3838 if (serviceapplication->label) {
3839 LISTHEAD(serviceapplication->label, tmp1);
3840 serviceapplication->label = tmp1;
3842 if (serviceapplication->icon) {
3843 LISTHEAD(serviceapplication->icon, tmp2);
3844 serviceapplication->icon = tmp2;
3846 if (serviceapplication->appsvc) {
3847 LISTHEAD(serviceapplication->appsvc, tmp3);
3848 serviceapplication->appsvc = tmp3;
3850 if (serviceapplication->appcontrol) {
3851 LISTHEAD(serviceapplication->appcontrol, tmp4);
3852 serviceapplication->appcontrol = tmp4;
3854 if (serviceapplication->datacontrol) {
3855 LISTHEAD(serviceapplication->datacontrol, tmp5);
3856 serviceapplication->datacontrol = tmp5;
3858 if (serviceapplication->launchconditions) {
3859 LISTHEAD(serviceapplication->launchconditions, tmp6);
3860 serviceapplication->launchconditions = tmp6;
3862 if (serviceapplication->notification) {
3863 LISTHEAD(serviceapplication->notification, tmp7);
3864 serviceapplication->notification = tmp7;
3866 if (serviceapplication->datashare) {
3867 LISTHEAD(serviceapplication->datashare, tmp8);
3868 serviceapplication->datashare = tmp8;
3870 if (serviceapplication->category) {
3871 LISTHEAD(serviceapplication->category, tmp9);
3872 serviceapplication->category = tmp9;
3874 if (serviceapplication->metadata) {
3875 LISTHEAD(serviceapplication->metadata, tmp10);
3876 serviceapplication->metadata = tmp10;
3878 if (serviceapplication->permission) {
3879 LISTHEAD(serviceapplication->permission, tmp11);
3880 serviceapplication->permission = tmp11;
3886 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile)
3888 /*TODO: once policy is set*/
3892 static int __ps_process_font(xmlTextReaderPtr reader, font_x *font)
3894 /*TODO: once policy is set*/
3898 static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme)
3900 /*TODO: once policy is set*/
3904 static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon)
3906 /*TODO: once policy is set*/
3910 static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime)
3912 /*TODO: once policy is set*/
3916 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx, uid_t uid)
3918 _LOGD("__start_process\n");
3919 const xmlChar *node;
3922 label_x *tmp1 = NULL;
3923 author_x *tmp2 = NULL;
3924 description_x *tmp3 = NULL;
3925 license_x *tmp4 = NULL;
3926 uiapplication_x *tmp5 = NULL;
3927 serviceapplication_x *tmp6 = NULL;
3928 daemon_x *tmp7 = NULL;
3929 theme_x *tmp8 = NULL;
3930 font_x *tmp9 = NULL;
3931 ime_x *tmp10 = NULL;
3932 icon_x *tmp11 = NULL;
3933 compatibility_x *tmp12 = NULL;
3934 deviceprofile_x *tmp13 = NULL;
3935 privileges_x *tmp14 = NULL;
3937 depth = xmlTextReaderDepth(reader);
3938 while ((ret = __next_child_element(reader, depth))) {
3939 node = xmlTextReaderConstName(reader);
3941 _LOGD("xmlTextReaderConstName value is NULL\n");
3945 if (!strcmp(ASCII(node), "label")) {
3946 label_x *label = malloc(sizeof(label_x));
3947 if (label == NULL) {
3948 _LOGD("Malloc Failed\n");
3951 memset(label, '\0', sizeof(label_x));
3952 LISTADD(mfx->label, label);
3953 ret = __ps_process_label(reader, label);
3954 } else if (!strcmp(ASCII(node), "author")) {
3955 author_x *author = malloc(sizeof(author_x));
3956 if (author == NULL) {
3957 _LOGD("Malloc Failed\n");
3960 memset(author, '\0', sizeof(author_x));
3961 LISTADD(mfx->author, author);
3962 ret = __ps_process_author(reader, author);
3963 } else if (!strcmp(ASCII(node), "description")) {
3964 description_x *description = malloc(sizeof(description_x));
3965 if (description == NULL) {
3966 _LOGD("Malloc Failed\n");
3969 memset(description, '\0', sizeof(description_x));
3970 LISTADD(mfx->description, description);
3971 ret = __ps_process_description(reader, description);
3972 } else if (!strcmp(ASCII(node), "license")) {
3973 license_x *license = malloc(sizeof(license_x));
3974 if (license == NULL) {
3975 _LOGD("Malloc Failed\n");
3978 memset(license, '\0', sizeof(license_x));
3979 LISTADD(mfx->license, license);
3980 ret = __ps_process_license(reader, license);
3981 } else if (!strcmp(ASCII(node), "privileges")) {
3982 privileges_x *privileges = malloc(sizeof(privileges_x));
3983 if (privileges == NULL) {
3984 _LOGD("Malloc Failed\n");
3987 memset(privileges, '\0', sizeof(privileges_x));
3988 LISTADD(mfx->privileges, privileges);
3989 ret = __ps_process_privileges(reader, privileges);
3990 } else if (!strcmp(ASCII(node), "ui-application")) {
3991 uiapplication_x *uiapplication = malloc(sizeof(uiapplication_x));
3992 if (uiapplication == NULL) {
3993 _LOGD("Malloc Failed\n");
3996 memset(uiapplication, '\0', sizeof(uiapplication_x));
3997 LISTADD(mfx->uiapplication, uiapplication);
3998 ret = __ps_process_uiapplication(reader, uiapplication, uid);
3999 } else if (!strcmp(ASCII(node), "service-application")) {
4000 serviceapplication_x *serviceapplication = malloc(sizeof(serviceapplication_x));
4001 if (serviceapplication == NULL) {
4002 _LOGD("Malloc Failed\n");
4005 memset(serviceapplication, '\0', sizeof(serviceapplication_x));
4006 LISTADD(mfx->serviceapplication, serviceapplication);
4007 ret = __ps_process_serviceapplication(reader, serviceapplication, uid);
4008 } else if (!strcmp(ASCII(node), "daemon")) {
4009 daemon_x *daemon = malloc(sizeof(daemon_x));
4010 if (daemon == NULL) {
4011 _LOGD("Malloc Failed\n");
4014 memset(daemon, '\0', sizeof(daemon_x));
4015 LISTADD(mfx->daemon, daemon);
4016 ret = __ps_process_daemon(reader, daemon);
4017 } else if (!strcmp(ASCII(node), "theme")) {
4018 theme_x *theme = malloc(sizeof(theme_x));
4019 if (theme == NULL) {
4020 _LOGD("Malloc Failed\n");
4023 memset(theme, '\0', sizeof(theme_x));
4024 LISTADD(mfx->theme, theme);
4025 ret = __ps_process_theme(reader, theme);
4026 } else if (!strcmp(ASCII(node), "font")) {
4027 font_x *font = malloc(sizeof(font_x));
4029 _LOGD("Malloc Failed\n");
4032 memset(font, '\0', sizeof(font_x));
4033 LISTADD(mfx->font, font);
4034 ret = __ps_process_font(reader, font);
4035 } else if (!strcmp(ASCII(node), "ime")) {
4036 ime_x *ime = malloc(sizeof(ime_x));
4038 _LOGD("Malloc Failed\n");
4041 memset(ime, '\0', sizeof(ime_x));
4042 LISTADD(mfx->ime, ime);
4043 ret = __ps_process_ime(reader, ime);
4044 } else if (!strcmp(ASCII(node), "icon")) {
4045 icon_x *icon = malloc(sizeof(icon_x));
4047 _LOGD("Malloc Failed\n");
4050 memset(icon, '\0', sizeof(icon_x));
4051 LISTADD(mfx->icon, icon);
4052 ret = __ps_process_icon(reader, icon, uid);
4053 } else if (!strcmp(ASCII(node), "profile")) {
4054 deviceprofile_x *deviceprofile = malloc(sizeof(deviceprofile_x));
4055 if (deviceprofile == NULL) {
4056 _LOGD("Malloc Failed\n");
4059 memset(deviceprofile, '\0', sizeof(deviceprofile_x));
4060 LISTADD(mfx->deviceprofile, deviceprofile);
4061 ret = __ps_process_deviceprofile(reader, deviceprofile);
4062 } else if (!strcmp(ASCII(node), "compatibility")) {
4063 compatibility_x *compatibility = malloc(sizeof(compatibility_x));
4064 if (compatibility == NULL) {
4065 _LOGD("Malloc Failed\n");
4068 memset(compatibility, '\0', sizeof(compatibility_x));
4069 LISTADD(mfx->compatibility, compatibility);
4070 ret = __ps_process_compatibility(reader, compatibility);
4071 } else if (!strcmp(ASCII(node), "shortcut-list")) {
4073 } else if (!strcmp(ASCII(node), "livebox")) {
4075 } else if (!strcmp(ASCII(node), "account")) {
4077 } else if (!strcmp(ASCII(node), "notifications")) {
4079 } else if (!strcmp(ASCII(node), "ime")) {
4085 _LOGD("Processing manifest failed\n");
4090 LISTHEAD(mfx->label, tmp1);
4094 LISTHEAD(mfx->author, tmp2);
4097 if (mfx->description) {
4098 LISTHEAD(mfx->description, tmp3);
4099 mfx->description= tmp3;
4102 LISTHEAD(mfx->license, tmp4);
4105 if (mfx->uiapplication) {
4106 LISTHEAD(mfx->uiapplication, tmp5);
4107 mfx->uiapplication = tmp5;
4109 if (mfx->serviceapplication) {
4110 LISTHEAD(mfx->serviceapplication, tmp6);
4111 mfx->serviceapplication = tmp6;
4114 LISTHEAD(mfx->daemon, tmp7);
4118 LISTHEAD(mfx->theme, tmp8);
4122 LISTHEAD(mfx->font, tmp9);
4126 LISTHEAD(mfx->ime, tmp10);
4130 LISTHEAD(mfx->icon, tmp11);
4133 if (mfx->compatibility) {
4134 LISTHEAD(mfx->compatibility, tmp12);
4135 mfx->compatibility= tmp12;
4137 if (mfx->deviceprofile) {
4138 LISTHEAD(mfx->deviceprofile, tmp13);
4139 mfx->deviceprofile= tmp13;
4141 if (mfx->privileges) {
4142 LISTHEAD(mfx->privileges, tmp14);
4143 mfx->privileges = tmp14;
4148 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx, uid_t uid)
4150 const xmlChar *node;
4153 if ((ret = __next_child_element(reader, -1))) {
4154 node = xmlTextReaderConstName(reader);
4156 _LOGD("xmlTextReaderConstName value is NULL\n");
4160 if (!strcmp(ASCII(node), "manifest")) {
4161 if (xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns"))){
4162 mfx->ns = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")));
4164 if (xmlTextReaderGetAttribute(reader, XMLCHAR("package"))) {
4165 mfx->package= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("package")));
4166 if (mfx->package == NULL) {
4167 _LOGD("package cant be NULL\n");
4171 _LOGD("package field is mandatory\n");
4174 package = mfx->package;
4175 if (xmlTextReaderGetAttribute(reader, XMLCHAR("version")))
4176 mfx->version= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("version")));
4177 /*app2ext needs package size for external installation*/
4178 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
4179 mfx->package_size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
4180 if (xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")))
4181 mfx->installlocation = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")));
4182 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
4183 mfx->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
4184 if (xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")))
4185 mfx->root_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")));
4186 if (xmlTextReaderGetAttribute(reader, XMLCHAR("csc_path")))
4187 mfx->csc_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("csc_path")));
4188 if (xmlTextReaderGetAttribute(reader, XMLCHAR("main_package")))
4189 mfx->main_package = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("main_package")));
4190 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting"))) {
4191 mfx->appsetting = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting")));
4192 if (mfx->appsetting == NULL)
4193 mfx->appsetting = strdup("false");
4195 mfx->appsetting = strdup("false");
4197 if (xmlTextReaderGetAttribute(reader, XMLCHAR("storeclient-id")))
4198 mfx->storeclient_id= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("storeclient-id")));
4199 if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay-setting"))) {
4200 mfx->nodisplay_setting = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay-setting")));
4201 if (mfx->nodisplay_setting == NULL)
4202 mfx->nodisplay_setting = strdup("false");
4204 mfx->nodisplay_setting = strdup("false");
4206 if (xmlTextReaderGetAttribute(reader, XMLCHAR("url")))
4207 mfx->package_url= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("url")));
4208 /*Assign default values. If required it will be overwritten in __add_preload_info()*/
4209 mfx->preload = strdup("False");
4210 mfx->removable = strdup("True");
4211 mfx->readonly = strdup("False");
4212 mfx->update = strdup("False");
4213 mfx->system = strdup("False");
4214 char buf[PKG_STRING_LEN_MAX] = {'\0'};
4216 time_t current_time;
4217 time(¤t_time);
4218 snprintf(buf, PKG_STRING_LEN_MAX - 1, "%d", current_time);
4219 val = strndup(buf, PKG_STRING_LEN_MAX - 1);
4220 mfx->installed_time = val;
4221 mfx->installed_storage= strdup("installed_internal");
4223 ret = __start_process(reader, mfx, uid);
4225 _LOGD("No Manifest element found\n");
4232 static char* __convert_to_system_locale(const char *mlocale)
4234 if (mlocale == NULL)
4236 char *locale = NULL;
4237 locale = (char *)calloc(1, 6);
4239 _LOGE("Malloc Failed\n");
4243 strncpy(locale, mlocale, 2);
4244 strncat(locale, "_", 1);
4245 locale[3] = toupper(mlocale[3]);
4246 locale[4] = toupper(mlocale[4]);
4250 #define LIBAIL_PATH LIB_PATH "/libail.so.0"
4252 /* operation_type */
4262 static int __ail_change_info(int op, const char *appid, uid_t uid)
4264 void *lib_handle = NULL;
4268 if ((lib_handle = dlopen(LIBAIL_PATH, RTLD_LAZY)) == NULL) {
4269 _LOGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAIL_PATH);
4273 if(uid != GLOBAL_USER)
4275 int (*ail_desktop_operation) (const char *, uid_t uid);
4278 aop = "ail_usr_desktop_add";
4281 aop = "ail_usr_desktop_update";
4284 aop = "ail_usr_desktop_remove";
4287 aop = "ail_usr_desktop_clean";
4290 aop = "ail_usr_desktop_fota";
4297 if ((ail_desktop_operation =
4298 dlsym(lib_handle, aop)) == NULL || dlerror() != NULL) {
4299 _LOGE("can not find symbol \n");
4303 ret = ail_desktop_operation(appid, uid);
4305 int (*ail_desktop_operation) (const char *);
4308 aop = "ail_desktop_add";
4311 aop = "ail_desktop_update";
4314 aop = "ail_desktop_remove";
4317 aop = "ail_desktop_clean";
4320 aop = "ail_desktop_fota";
4327 if ((ail_desktop_operation =
4328 dlsym(lib_handle, aop)) == NULL || dlerror() != NULL) {
4329 _LOGE("can not find symbol \n");
4333 ret = ail_desktop_operation(appid);
4338 dlclose(lib_handle);
4343 /* desktop shoud be generated automatically based on manifest */
4344 /* Currently removable, taskmanage, etc fields are not considerd. it will be decided soon.*/
4345 #define BUFMAX 1024*128
4346 static int __ps_make_nativeapp_desktop(manifest_x * mfx, const char *manifest, ACTION_TYPE action, uid_t uid)
4350 char filepath[PKG_STRING_LEN_MAX] = "";
4352 char *buftemp = NULL;
4353 char *locale = NULL;
4355 buf = (char *)calloc(1, BUFMAX);
4357 _LOGE("Malloc Failed\n");
4361 buftemp = (char *)calloc(1, BUFMAX);
4363 _LOGE("Malloc Failed\n");
4368 if (action == ACTION_UPGRADE)
4369 __ail_change_info(AIL_CLEAN, mfx->package, uid);
4371 for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) {
4373 snprintf(filepath, sizeof(filepath),"%s%s.desktop", getUserDesktopPath(uid), mfx->uiapplication->appid);
4375 /* skip if desktop exists
4376 if (access(filepath, R_OK) == 0)
4380 file = fopen(filepath, "w");
4383 _LOGD("Can't open %s", filepath);
4389 snprintf(buf, BUFMAX, "[Desktop Entry]\n");
4390 fwrite(buf, 1, strlen(buf), file);
4392 for( ; mfx->uiapplication->label ; mfx->uiapplication->label = mfx->uiapplication->label->next) {
4393 if(!strcmp(mfx->uiapplication->label->lang, DEFAULT_LOCALE)) {
4394 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
4396 locale = __convert_to_system_locale(mfx->uiapplication->label->lang);
4397 snprintf(buf, BUFMAX, "Name[%s]=%s\n", locale,
4398 mfx->uiapplication->label->text);
4401 fwrite(buf, 1, strlen(buf), file);
4404 if(mfx->uiapplication->label && mfx->uiapplication->label->text) {
4405 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
4406 fwrite(buf, 1, strlen(buf), file);
4409 else if(mfx->label && mfx->label->text) {
4410 snprintf(buf, BUFMAX, "Name=%s\n", mfx->label->text);
4411 fwrite(buf, 1, strlen(buf), file);
4413 snprintf(buf, BUFMAX, "Name=%s\n", mfx->package);
4414 fwrite(buf, 1, strlen(buf), file);
4419 snprintf(buf, BUFMAX, "Type=Application\n");
4420 fwrite(buf, 1, strlen(buf), file);
4422 if(mfx->uiapplication->exec) {
4423 snprintf(buf, BUFMAX, "Exec=%s\n", mfx->uiapplication->exec);
4424 fwrite(buf, 1, strlen(buf), file);
4427 if(mfx->uiapplication->icon && mfx->uiapplication->icon->text) {
4428 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->uiapplication->icon->text);
4429 fwrite(buf, 1, strlen(buf), file);
4430 } else if(mfx->icon && mfx->icon->text) {
4431 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->icon->text);
4432 fwrite(buf, 1, strlen(buf), file);
4436 if(mfx->uiapplication && mfx->uiapplication->appsvc) {
4437 appsvc_x *asvc = mfx->uiapplication->appsvc;
4439 const char *mime = NULL;
4440 const char *mime_delim = "; ";
4443 strncpy(buf, "MimeType=", BUFMAX-1);
4449 _LOGD("MIME type: %s\n", mime);
4450 strncat(buf, mime, BUFMAX-strlen(buf)-1);
4452 strncat(buf, mime_delim, BUFMAX-strlen(buf)-1);
4460 _LOGD("MIME types: buf[%s]\n", buf);
4461 _LOGD("MIME count: %d\n", mime_count);
4463 fwrite(buf, 1, strlen(buf), file);
4467 snprintf(buf, BUFMAX, "Version=%s\n", mfx->version);
4468 fwrite(buf, 1, strlen(buf), file);
4471 if(mfx->uiapplication->nodisplay) {
4472 snprintf(buf, BUFMAX, "NoDisplay=%s\n", mfx->uiapplication->nodisplay);
4473 fwrite(buf, 1, strlen(buf), file);
4476 if(mfx->uiapplication->categories) {
4477 snprintf(buf, BUFMAX, "Categories=%s\n", mfx->uiapplication->categories);
4478 fwrite(buf, 1, strlen(buf), file);
4481 if(mfx->uiapplication->taskmanage && !strcasecmp(mfx->uiapplication->taskmanage, "False")) {
4482 snprintf(buf, BUFMAX, "X-TIZEN-TaskManage=False\n");
4483 fwrite(buf, 1, strlen(buf), file);
4486 if(mfx->uiapplication->enabled && !strcasecmp(mfx->uiapplication->enabled, "False")) {
4487 snprintf(buf, BUFMAX, "X-TIZEN-Enabled=False\n");
4488 fwrite(buf, 1, strlen(buf), file);
4491 if(mfx->uiapplication->hwacceleration) {
4492 snprintf(buf, BUFMAX, "Hw-Acceleration=%s\n", mfx->uiapplication->hwacceleration);
4493 fwrite(buf, 1, strlen(buf), file);
4496 if(mfx->uiapplication->multiple && !strcasecmp(mfx->uiapplication->multiple, "True")) {
4497 snprintf(buf, BUFMAX, "X-TIZEN-Multiple=True\n");
4498 fwrite(buf, 1, strlen(buf), file);
4501 if(mfx->uiapplication->extraid) {
4502 snprintf(buf, BUFMAX, "X-TIZEN-PackageID=%s\n", mfx->uiapplication->extraid);
4503 fwrite(buf, 1, strlen(buf), file);
4506 if(mfx->removable && !strcasecmp(mfx->removable, "False")) {
4507 snprintf(buf, BUFMAX, "X-TIZEN-Removable=False\n");
4508 fwrite(buf, 1, strlen(buf), file);
4512 snprintf(buf, BUFMAX, "X-TIZEN-PackageType=%s\n", mfx->type);
4513 fwrite(buf, 1, strlen(buf), file);
4516 if(mfx->uiapplication->submode && !strcasecmp(mfx->uiapplication->submode, "True")) {
4517 snprintf(buf, BUFMAX, "X-TIZEN-Submode=%s\n", mfx->uiapplication->submode);
4518 fwrite(buf, 1, strlen(buf), file);
4519 snprintf(buf, BUFMAX, "X-TIZEN-SubmodeMainid=%s\n", mfx->uiapplication->submode_mainid);
4520 fwrite(buf, 1, strlen(buf), file);
4524 snprintf(buf, BUFMAX, "X-TIZEN-PkgID=%s\n", mfx->package);
4525 fwrite(buf, 1, strlen(buf), file);
4527 if(mfx->uiapplication->appid) {
4528 snprintf(buf, BUFMAX, "X-TIZEN-AppID=%s\n", mfx->uiapplication->appid);
4529 fwrite(buf, 1, strlen(buf), file);
4534 // snprintf(buf, BUFMAX, "X-TIZEN-PackageType=rpm\n");
4535 // fwrite(buf, 1, strlen(buf), file);
4538 if(mfx->uiapplication->appsvc) {
4539 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
4540 _LOGD("buf[%s]\n", buf);
4543 uiapplication_x *up = mfx->uiapplication;
4544 appsvc_x *asvc = NULL;
4545 operation_x *op = NULL;
4548 subapp_x *sub = NULL;
4549 const char *operation = NULL;
4550 const char *mime = NULL;
4551 const char *uri = NULL;
4552 const char *subapp = NULL;
4557 while(asvc != NULL) {
4558 op = asvc->operation;
4561 operation = op->name;
4580 strncpy(buftemp, buf, BUFMAX);
4581 snprintf(buf, BUFMAX, "%s;", buftemp);
4585 strncpy(buftemp, buf, BUFMAX);
4586 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
4587 _LOGD("buf[%s]\n", buf);
4592 } while(ui != NULL);
4596 }while(sub != NULL);
4609 fwrite(buf, 1, strlen(buf), file);
4611 // strncpy(buftemp, buf, BUFMAX);
4612 // snprintf(buf, BUFMAX, "%s\n", buftemp);
4613 // fwrite(buf, 1, strlen(buf), file);
4616 if(mfx->uiapplication->appcontrol) {
4617 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
4618 _LOGD("buf[%s]\n", buf);
4620 uiapplication_x *up = mfx->uiapplication;
4621 appcontrol_x *acontrol = NULL;
4622 operation_x *op = NULL;
4625 subapp_x *sub = NULL;
4626 const char *operation = NULL;
4627 const char *mime = NULL;
4628 const char *uri = NULL;
4629 const char *subapp = NULL;
4632 acontrol = up->appcontrol;
4633 while(acontrol != NULL) {
4634 op = acontrol->operation;
4637 operation = op->name;
4638 mi = acontrol->mime;
4644 sub = acontrol->subapp;
4656 strncpy(buftemp, buf, BUFMAX);
4657 snprintf(buf, BUFMAX, "%s;", buftemp);
4660 strncpy(buftemp, buf, BUFMAX);
4661 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
4662 _LOGD("buf[%s]\n", buf);
4667 } while(ui != NULL);
4671 }while(sub != NULL);
4680 acontrol = acontrol->next;
4684 fwrite(buf, 1, strlen(buf), file);
4686 // strncpy(buftemp, buf, BUFMAX);
4687 // snprintf(buf, BUFMAX, "%s\n", buftemp);
4688 // fwrite(buf, 1, strlen(buf), file);
4695 if (action == ACTION_FOTA)
4696 __ail_change_info(AIL_FOTA, mfx->uiapplication->appid, uid);
4698 __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid, uid);
4707 static int __ps_remove_nativeapp_desktop(manifest_x *mfx, uid_t uid)
4709 char filepath[PKG_STRING_LEN_MAX] = "";
4711 uiapplication_x *uiapplication = mfx->uiapplication;
4713 for(; uiapplication; uiapplication=uiapplication->next) {
4714 snprintf(filepath, sizeof(filepath),"%s%s.desktop", getUserDesktopPath(uid), uiapplication->appid);
4716 __ail_change_info(AIL_REMOVE, uiapplication->appid, uid);
4718 ret = remove(filepath);
4726 #define LIBAPPSVC_PATH LIB_PATH "/libappsvc.so.0"
4728 static int __ps_remove_appsvc_db(manifest_x *mfx, uid_t uid)
4730 void *lib_handle = NULL;
4731 int (*appsvc_operation) (const char *, uid_t);
4733 uiapplication_x *uiapplication = mfx->uiapplication;
4735 if ((lib_handle = dlopen(LIBAPPSVC_PATH, RTLD_LAZY)) == NULL) {
4736 _LOGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAPPSVC_PATH);
4740 if ((appsvc_operation =
4741 dlsym(lib_handle, "appsvc_unset_defapp")) == NULL || dlerror() != NULL) {
4742 _LOGE("can not find symbol \n");
4746 for(; uiapplication; uiapplication=uiapplication->next) {
4747 ret = appsvc_operation(uiapplication->appid, uid);
4749 _LOGE("can not operation symbol \n");
4754 dlclose(lib_handle);
4759 #define PRELOAD_PACKAGE_LIST SYSCONFDIR "/package-manager/preload/preload_list.txt"
4760 static int __add_preload_info(manifest_x * mfx, const char *manifest, uid_t uid)
4763 char buffer[1024] = { 0 };
4766 if(strstr(manifest, getUserManifestPath(uid))) {
4767 free((void *)mfx->readonly);
4768 mfx->readonly = strdup("True");
4770 free((void *)mfx->preload);
4771 mfx->preload = strdup("True");
4773 free((void *)mfx->removable);
4774 mfx->removable = strdup("False");
4776 free((void *)mfx->system);
4777 mfx->system = strdup("True");
4782 fp = fopen(PRELOAD_PACKAGE_LIST, "r");
4784 _LOGE("no preload list\n");
4788 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
4789 if (buffer[0] == '#') {
4790 if(strcasestr(buffer, "RW_NORM"))
4792 else if(strcasestr(buffer, "RW_RM"))
4800 if(!strcmp(mfx->package, buffer)) {
4801 free((void *)mfx->preload);
4802 mfx->preload = strdup("True");
4804 free((void *)mfx->readonly);
4805 mfx->readonly = strdup("False");
4806 free((void *)mfx->removable);
4807 mfx->removable = strdup("False");
4808 } else if(state == 3){
4809 free((void *)mfx->readonly);
4810 mfx->readonly = strdup("False");
4811 free((void *)mfx->removable);
4812 mfx->removable = strdup("True");
4816 memset(buffer, 0x00, sizeof(buffer));
4825 static int __check_preload_updated(manifest_x * mfx, const char *manifest, uid_t uid)
4827 char filepath[PKG_STRING_LEN_MAX] = "";
4829 uiapplication_x *uiapplication = mfx->uiapplication;
4831 if(strstr(manifest, getUserManifestPath(uid))) {
4832 /* if preload app is updated, then remove previous desktop file on RW*/
4833 for(; uiapplication; uiapplication=uiapplication->next) {
4834 snprintf(filepath, sizeof(filepath),"%s%s.desktop", getUserDesktopPath(uid), uiapplication->appid);
4835 ret = remove(filepath);
4840 /* if downloaded app is updated, then update tag set true*/
4841 free((void *)mfx->update);
4842 mfx->update = strdup("true");
4849 API int pkgmgr_parser_create_desktop_file(manifest_x *mfx)
4853 _LOGD("Manifest pointer is NULL\n");
4856 ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_INSTALL, GLOBAL_USER);
4858 _LOGD("Creating desktop file failed\n");
4860 _LOGD("Creating desktop file Success\n");
4864 API int pkgmgr_parser_create_usr_desktop_file(manifest_x *mfx, uid_t uid)
4868 _LOGD("Manifest pointer is NULL\n");
4871 ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_INSTALL, uid);
4873 _LOGD("Creating desktop file failed\n");
4875 _LOGD("Creating desktop file Success\n");
4880 API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
4885 free((void *)mfx->ns);
4889 free((void *)mfx->package);
4890 mfx->package = NULL;
4893 free((void *)mfx->version);
4894 mfx->version = NULL;
4896 if (mfx->installlocation) {
4897 free((void *)mfx->installlocation);
4898 mfx->installlocation = NULL;
4901 free((void *)mfx->preload);
4902 mfx->preload = NULL;
4904 if (mfx->readonly) {
4905 free((void *)mfx->readonly);
4906 mfx->readonly = NULL;
4908 if (mfx->removable) {
4909 free((void *)mfx->removable);
4910 mfx->removable = NULL;
4913 free((void *)mfx->update);
4917 free((void *)mfx->system);
4921 free((void *)mfx->type);
4924 if (mfx->package_size) {
4925 free((void *)mfx->package_size);
4926 mfx->package_size = NULL;
4928 if (mfx->installed_time) {
4929 free((void *)mfx->installed_time);
4930 mfx->installed_time = NULL;
4932 if (mfx->installed_storage) {
4933 free((void *)mfx->installed_storage);
4934 mfx->installed_storage = NULL;
4936 if (mfx->storeclient_id) {
4937 free((void *)mfx->storeclient_id);
4938 mfx->storeclient_id = NULL;
4940 if (mfx->mainapp_id) {
4941 free((void *)mfx->mainapp_id);
4942 mfx->mainapp_id = NULL;
4944 if (mfx->package_url) {
4945 free((void *)mfx->package_url);
4946 mfx->package_url = NULL;
4948 if (mfx->root_path) {
4949 free((void *)mfx->root_path);
4950 mfx->root_path = NULL;
4952 if (mfx->csc_path) {
4953 free((void *)mfx->csc_path);
4954 mfx->csc_path = NULL;
4956 if (mfx->appsetting) {
4957 free((void *)mfx->appsetting);
4958 mfx->appsetting = NULL;
4960 if (mfx->nodisplay_setting) {
4961 free((void *)mfx->nodisplay_setting);
4962 mfx->nodisplay_setting = NULL;
4964 if (mfx->main_package) {
4965 free((void *)mfx->main_package);
4966 mfx->main_package = NULL;
4971 icon_x *icon = mfx->icon;
4973 while(icon != NULL) {
4975 __ps_free_icon(icon);
4981 label_x *label = mfx->label;
4982 label_x *tmp = NULL;
4983 while(label != NULL) {
4985 __ps_free_label(label);
4991 author_x *author = mfx->author;
4992 author_x *tmp = NULL;
4993 while(author != NULL) {
4995 __ps_free_author(author);
4999 /*Free Description*/
5000 if (mfx->description) {
5001 description_x *description = mfx->description;
5002 description_x *tmp = NULL;
5003 while(description != NULL) {
5004 tmp = description->next;
5005 __ps_free_description(description);
5011 license_x *license = mfx->license;
5012 license_x *tmp = NULL;
5013 while(license != NULL) {
5014 tmp = license->next;
5015 __ps_free_license(license);
5020 if (mfx->privileges) {
5021 privileges_x *privileges = mfx->privileges;
5022 privileges_x *tmp = NULL;
5023 while(privileges != NULL) {
5024 tmp = privileges->next;
5025 __ps_free_privileges(privileges);
5029 /*Free UiApplication*/
5030 if (mfx->uiapplication) {
5031 uiapplication_x *uiapplication = mfx->uiapplication;
5032 uiapplication_x *tmp = NULL;
5033 while(uiapplication != NULL) {
5034 tmp = uiapplication->next;
5035 __ps_free_uiapplication(uiapplication);
5036 uiapplication = tmp;
5039 /*Free ServiceApplication*/
5040 if (mfx->serviceapplication) {
5041 serviceapplication_x *serviceapplication = mfx->serviceapplication;
5042 serviceapplication_x *tmp = NULL;
5043 while(serviceapplication != NULL) {
5044 tmp = serviceapplication->next;
5045 __ps_free_serviceapplication(serviceapplication);
5046 serviceapplication = tmp;
5051 daemon_x *daemon = mfx->daemon;
5052 daemon_x *tmp = NULL;
5053 while(daemon != NULL) {
5055 __ps_free_daemon(daemon);
5061 theme_x *theme = mfx->theme;
5062 theme_x *tmp = NULL;
5063 while(theme != NULL) {
5065 __ps_free_theme(theme);
5071 font_x *font = mfx->font;
5073 while(font != NULL) {
5075 __ps_free_font(font);
5081 ime_x *ime = mfx->ime;
5083 while(ime != NULL) {
5089 /*Free Compatibility*/
5090 if (mfx->compatibility) {
5091 compatibility_x *compatibility = mfx->compatibility;
5092 compatibility_x *tmp = NULL;
5093 while(compatibility != NULL) {
5094 tmp = compatibility->next;
5095 __ps_free_compatibility(compatibility);
5096 compatibility = tmp;
5099 /*Free DeviceProfile*/
5100 if (mfx->deviceprofile) {
5101 deviceprofile_x *deviceprofile = mfx->deviceprofile;
5102 deviceprofile_x *tmp = NULL;
5103 while(deviceprofile != NULL) {
5104 tmp = deviceprofile->next;
5105 __ps_free_deviceprofile(deviceprofile);
5106 deviceprofile = tmp;
5114 API manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest)
5116 _LOGD("parsing start pkgmgr_parser_process_manifest_xml\n");
5117 xmlTextReaderPtr reader;
5118 manifest_x *mfx = NULL;
5120 reader = xmlReaderForFile(manifest, NULL, 0);
5122 mfx = malloc(sizeof(manifest_x));
5124 memset(mfx, '\0', sizeof(manifest_x));
5125 if (__process_manifest(reader, mfx, GLOBAL_USER) < 0) {
5126 _LOGD("Parsing Failed\n");
5127 pkgmgr_parser_free_manifest_xml(mfx);
5130 _LOGD("Parsing Success\n");
5132 _LOGD("Memory allocation error\n");
5134 xmlFreeTextReader(reader);
5136 _LOGD("Unable to create xml reader\n");
5142 API manifest_x *pkgmgr_parser_usr_process_manifest_xml(const char *manifest, uid_t uid)
5144 _LOGD("parsing start pkgmgr_parser_usr_process_manifest_xml\n");
5145 xmlTextReaderPtr reader;
5146 manifest_x *mfx = NULL;
5148 reader = xmlReaderForFile(manifest, NULL, 0);
5150 mfx = malloc(sizeof(manifest_x));
5152 memset(mfx, '\0', sizeof(manifest_x));
5153 if (__process_manifest(reader, mfx, uid) < 0) {
5154 _LOGD("Parsing Failed\n");
5155 pkgmgr_parser_free_manifest_xml(mfx);
5158 _LOGD("Parsing Success\n");
5160 _LOGD("Memory allocation error\n");
5162 xmlFreeTextReader(reader);
5164 _LOGD("Unable to create xml reader\n");
5169 /* These APIs are intended to call parser directly */
5171 API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
5173 // char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
5174 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5175 _LOGD("parsing manifest for installation: %s\n", manifest);
5177 manifest_x *mfx = NULL;
5181 mfx = pkgmgr_parser_process_manifest_xml(manifest);
5182 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5184 _LOGD("Parsing Finished\n");
5186 // __streamFile(manifest, ACTION_INSTALL, temp, mfx->package);
5187 __ps_process_tag_parser(mfx, manifest, ACTION_INSTALL);
5188 __add_preload_info(mfx, manifest, GLOBAL_USER);
5190 _LOGD("Added preload infomation\n");
5192 __ps_process_tag(mfx, tagv);
5194 ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
5195 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
5197 _LOGD("DB Insert Success\n");
5199 ret = __ps_process_metadata_parser(mfx, ACTION_INSTALL);
5201 _LOGD("Creating metadata parser failed\n");
5203 ret = __ps_process_category_parser(mfx, ACTION_INSTALL);
5205 _LOGD("Creating category parser failed\n");
5207 if (__check_action_fota(tagv))
5208 ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_FOTA, GLOBAL_USER);
5210 ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_INSTALL, GLOBAL_USER);
5213 _LOGD("Creating desktop file failed\n");
5215 _LOGD("Creating desktop file Success\n");
5217 pkgmgr_parser_free_manifest_xml(mfx);
5218 _LOGD("Free Done\n");
5223 API int pkgmgr_parser_parse_usr_manifest_for_installation(const char *manifest, uid_t uid, char *const tagv[])
5225 // char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
5226 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5227 _LOGD("parsing manifest for installation: %s\n", manifest);
5228 manifest_x *mfx = NULL;
5232 mfx = pkgmgr_parser_usr_process_manifest_xml(manifest, uid);
5233 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5235 _LOGD("Parsing Finished\n");
5236 // __streamFile(manifest, ACTION_INSTALL, temp, mfx->package);
5237 __ps_process_tag_parser(mfx, manifest, ACTION_INSTALL);
5239 __ps_process_tag(mfx, tagv);
5241 ret = pkgmgr_parser_insert_manifest_info_in_usr_db(mfx, uid);
5242 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
5244 _LOGD("DB Insert Success\n");
5245 ret = __ps_process_metadata_parser(mfx, ACTION_INSTALL);
5247 _LOGD("Creating metadata parser failed\n");
5248 ret = __ps_process_category_parser(mfx, ACTION_INSTALL);
5250 _LOGD("Creating category parser failed\n");
5252 if (__check_action_fota(tagv))
5253 ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_FOTA, uid);
5255 ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_INSTALL, uid);
5258 _LOGD("Creating desktop file failed\n");
5260 _LOGD("Creating desktop file Success\n");
5261 pkgmgr_parser_free_manifest_xml(mfx);
5262 _LOGD("Free Done\n");
5268 API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
5270 // char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
5271 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5272 _LOGD("pkgmgr_parser_parse_manifest_for_upgrade parsing manifest for upgradation: %s\n", manifest);
5273 manifest_x *mfx = NULL;
5275 bool preload = false;
5276 bool system = false;
5277 char *csc_path = NULL;
5278 pkgmgrinfo_pkginfo_h handle = NULL;
5281 mfx = pkgmgr_parser_process_manifest_xml(manifest);
5282 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5284 _LOGD("Parsing Finished\n");
5285 // __streamFile(manifest, ACTION_UPGRADE, temp, mfx->package);
5286 __ps_process_tag_parser(mfx, manifest, ACTION_UPGRADE);
5287 __add_preload_info(mfx, manifest, GLOBAL_USER);
5288 _LOGD("Added preload infomation\n");
5289 __check_preload_updated(mfx, manifest, GLOBAL_USER);
5291 ret = pkgmgrinfo_pkginfo_get_pkginfo(mfx->package, &handle);
5292 if (ret != PMINFO_R_OK)
5293 _LOGD("pkgmgrinfo_pkginfo_get_pkginfo failed\n");
5294 ret = pkgmgrinfo_pkginfo_is_preload(handle, &preload);
5295 if (ret != PMINFO_R_OK)
5296 _LOGD("pkgmgrinfo_pkginfo_is_preload failed\n");
5299 free((void *)mfx->preload);
5300 mfx->preload = strdup("true");
5303 ret = pkgmgrinfo_pkginfo_is_system(handle, &system);
5304 if (ret != PMINFO_R_OK)
5305 _LOGD("pkgmgrinfo_pkginfo_is_system failed\n");
5307 free((void *)mfx->system);
5308 mfx->system = strdup("true");
5311 ret = pkgmgrinfo_pkginfo_get_csc_path(handle, &csc_path);
5312 if (ret != PMINFO_R_OK)
5313 _LOGD("pkgmgrinfo_pkginfo_get_csc_path failed\n");
5315 if (csc_path != NULL) {
5317 free((void *)mfx->csc_path);
5318 mfx->csc_path = strdup(csc_path);
5321 ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
5322 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
5323 _LOGD("DB Update Success\n");
5324 ret = __ps_process_metadata_parser(mfx, ACTION_UPGRADE);
5326 _LOGD("Upgrade metadata parser failed\n");
5328 ret = __ps_process_category_parser(mfx, ACTION_UPGRADE);
5330 _LOGD("Creating category parser failed\n");
5331 ret = __ps_make_nativeapp_desktop(mfx, manifest, ACTION_UPGRADE, GLOBAL_USER);
5333 _LOGD("Creating desktop file failed\n");
5335 _LOGD("Creating desktop file Success\n");
5336 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
5337 pkgmgr_parser_free_manifest_xml(mfx);
5338 _LOGD("Free Done\n");
5344 API int pkgmgr_parser_parse_usr_manifest_for_upgrade(const char *manifest, uid_t uid, 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_usr_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_usr_process_manifest_xml(manifest, uid);
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 __check_preload_updated(mfx, manifest, uid);
5365 ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(mfx->package, uid, &handle);
5366 if (ret != PMINFO_R_OK)
5367 _LOGD("pkgmgrinfo_pkginfo_get_pkginfo failed\n");
5368 ret = pkgmgrinfo_pkginfo_is_preload(handle, &preload);
5369 if (ret != PMINFO_R_OK)
5370 _LOGD("pkgmgrinfo_pkginfo_is_preload failed\n");
5373 free((void *)mfx->preload);
5374 mfx->preload = strdup("true");
5377 ret = pkgmgrinfo_pkginfo_is_system(handle, &system);
5378 if (ret != PMINFO_R_OK)
5379 _LOGD("pkgmgrinfo_pkginfo_is_system failed\n");
5382 free((void *)mfx->system);
5383 mfx->system = strdup("true");
5386 ret = pkgmgrinfo_pkginfo_get_csc_path(handle, &csc_path);
5387 if (ret != PMINFO_R_OK)
5388 _LOGD("pkgmgrinfo_pkginfo_get_csc_path failed\n");
5389 if (csc_path != NULL) {
5391 free((void *)mfx->csc_path);
5392 mfx->csc_path = strdup(csc_path);
5395 ret = pkgmgr_parser_update_manifest_info_in_usr_db(mfx, uid);
5396 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
5397 _LOGD("DB Update Success\n");
5398 _LOGE("DB Update Success\n" );
5399 ret = __ps_process_metadata_parser(mfx, ACTION_UPGRADE);
5401 _LOGD("Upgrade metadata parser failed\n");
5402 ret = __ps_process_category_parser(mfx, ACTION_UPGRADE);
5404 _LOGD("Creating category parser failed\n");
5405 ret = __ps_make_nativeapp_desktop(mfx, manifest, ACTION_UPGRADE, uid);
5407 _LOGD("Creating desktop file failed\n");
5409 _LOGD("Creating desktop file Success\n");
5410 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
5411 pkgmgr_parser_free_manifest_xml(mfx);
5412 _LOGD("Free Done\n");
5418 API int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[])
5420 // char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
5421 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5422 _LOGD("parsing manifest for uninstallation: %s\n", manifest);
5424 manifest_x *mfx = NULL;
5427 mfx = pkgmgr_parser_process_manifest_xml(manifest);
5428 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5430 _LOGD("Parsing Finished\n");
5432 // __streamFile(manifest, ACTION_UNINSTALL, temp, mfx->package);
5433 __ps_process_tag_parser(mfx, manifest, ACTION_UNINSTALL);
5435 __add_preload_info(mfx, manifest, GLOBAL_USER);
5436 _LOGD("Added preload infomation\n");
5438 ret = __ps_process_metadata_parser(mfx, ACTION_UNINSTALL);
5440 _LOGD("Removing metadata parser failed\n");
5442 ret = __ps_process_category_parser(mfx, ACTION_UNINSTALL);
5444 _LOGD("Creating category parser failed\n");
5446 ret = pkgmgr_parser_delete_manifest_info_from_db(mfx);
5448 _LOGD("DB Delete failed\n");
5450 _LOGD("DB Delete Success\n");
5452 ret = __ps_remove_nativeapp_desktop(mfx, GLOBAL_USER);
5454 _LOGD("Removing desktop file failed\n");
5456 _LOGD("Removing desktop file Success\n");
5458 pkgmgr_parser_free_manifest_xml(mfx);
5459 _LOGD("Free Done\n");
5466 API int pkgmgr_parser_parse_usr_manifest_for_uninstallation(const char *manifest, uid_t uid, char *const tagv[])
5468 // char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
5469 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5470 _LOGD("parsing manifest for uninstallation: %s\n", manifest);
5472 manifest_x *mfx = NULL;
5475 mfx = pkgmgr_parser_usr_process_manifest_xml(manifest, uid);
5476 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5478 _LOGD("Parsing Finished\n");
5480 // __streamFile(manifest, ACTION_UNINSTALL, temp, mfx->package);
5481 __ps_process_tag_parser(mfx, manifest, ACTION_UNINSTALL);
5483 ret = __ps_process_metadata_parser(mfx, ACTION_UNINSTALL);
5485 _LOGD("Removing metadata parser failed\n");
5487 ret = __ps_process_category_parser(mfx, ACTION_UNINSTALL);
5489 _LOGD("Creating category parser failed\n");
5491 ret = pkgmgr_parser_delete_manifest_info_from_usr_db(mfx, uid);
5493 _LOGD("DB Delete failed\n");
5495 _LOGD("DB Delete Success\n");
5497 ret = __ps_remove_nativeapp_desktop(mfx, uid);
5499 _LOGD("Removing desktop file failed\n");
5501 _LOGD("Removing desktop file Success\n");
5503 ret = __ps_remove_appsvc_db(mfx, uid);
5505 _LOGD("Removing appsvc_db failed\n");
5507 _LOGD("Removing appsvc_db Success\n");
5509 pkgmgr_parser_free_manifest_xml(mfx);
5510 _LOGD("Free Done\n");
5516 API int pkgmgr_parser_parse_manifest_for_preload()
5518 return pkgmgr_parser_update_preload_info_in_db();
5521 API int pkgmgr_parser_parse_usr_manifest_for_preload(uid_t uid)
5523 return pkgmgr_parser_update_preload_info_in_usr_db(uid);
5527 API char *pkgmgr_parser_get_usr_manifest_file(const char *pkgid, uid_t uid)
5529 return __pkgid_to_manifest(pkgid, uid);
5532 API char *pkgmgr_parser_get_manifest_file(const char *pkgid)
5534 return __pkgid_to_manifest(pkgid, GLOBAL_USER);
5537 API int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
5539 return __ps_run_parser(docPtr, tag, ACTION_INSTALL, pkgid);
5542 API int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgid)
5544 return __ps_run_parser(docPtr, tag, ACTION_UPGRADE, pkgid);
5547 API int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
5549 return __ps_run_parser(docPtr, tag, ACTION_UNINSTALL, pkgid);
5552 #define SCHEMA_FILE SYSCONFDIR "/package-manager/preload/manifest.xsd"
5554 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
5556 if (manifest == NULL) {
5557 _LOGE("manifest file is NULL\n");
5558 return PMINFO_R_EINVAL;
5561 xmlSchemaParserCtxtPtr ctx;
5562 xmlSchemaValidCtxtPtr vctx;
5563 xmlSchemaPtr xschema;
5564 ctx = xmlSchemaNewParserCtxt(SCHEMA_FILE);
5566 _LOGE("xmlSchemaNewParserCtxt() Failed\n");
5567 return PMINFO_R_ERROR;
5569 xschema = xmlSchemaParse(ctx);
5570 if (xschema == NULL) {
5571 _LOGE("xmlSchemaParse() Failed\n");
5572 return PMINFO_R_ERROR;
5574 vctx = xmlSchemaNewValidCtxt(xschema);
5576 _LOGE("xmlSchemaNewValidCtxt() Failed\n");
5577 return PMINFO_R_ERROR;
5579 xmlSchemaSetValidErrors(vctx, (xmlSchemaValidityErrorFunc) fprintf, (xmlSchemaValidityWarningFunc) fprintf, stderr);
5580 ret = xmlSchemaValidateFile(vctx, manifest, 0);
5582 _LOGE("xmlSchemaValidateFile() failed\n");
5583 return PMINFO_R_ERROR;
5584 } else if (ret == 0) {
5585 _LOGE("Manifest is Valid\n");
5588 _LOGE("Manifest Validation Failed with error code %d\n", ret);
5589 return PMINFO_R_ERROR;
5595 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
5605 _LOGE("fork failed\n");
5610 int dev_null_fd = open ("/dev/null", O_RDWR);
5611 if (dev_null_fd >= 0)
5613 dup2 (dev_null_fd, 0);/*stdin*/
5614 dup2 (dev_null_fd, 1);/*stdout*/
5615 dup2 (dev_null_fd, 2);/*stderr*/
5618 if (execl("/usr/bin/xmllint", "xmllint", manifest, "--schema",
5619 SCHEMA_FILE, NULL) < 0) {
5620 _LOGE("execl error\n");
5630 while ((err = waitpid(pid, &status, WNOHANG)) != pid) {
5634 _LOGE("waitpid failed\n");
5640 if(WIFEXITED(status) && !WEXITSTATUS(status))