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;
1707 if (datacontrol->capability) {
1708 capability_x *capability = datacontrol->capability;
1709 capability_x *tmp = NULL;
1710 while(capability != NULL) {
1711 tmp = capability->next;
1712 __ps_free_capability(capability);
1716 free((void*)datacontrol);
1720 static void __ps_free_launchconditions(launchconditions_x *launchconditions)
1722 if (launchconditions == NULL)
1724 if (launchconditions->text) {
1725 free((void *)launchconditions->text);
1726 launchconditions->text = NULL;
1729 if (launchconditions->condition) {
1730 condition_x *condition = launchconditions->condition;
1731 condition_x *tmp = NULL;
1732 while(condition != NULL) {
1733 tmp = condition->next;
1734 __ps_free_condition(condition);
1738 free((void*)launchconditions);
1739 launchconditions = NULL;
1742 static void __ps_free_appcontrol(appcontrol_x *appcontrol)
1744 if (appcontrol == NULL)
1746 if (appcontrol->text) {
1747 free((void *)appcontrol->text);
1748 appcontrol->text = NULL;
1751 if (appcontrol->operation) {
1752 operation_x *operation = appcontrol->operation;
1753 operation_x *tmp = NULL;
1754 while(operation != NULL) {
1755 tmp = operation->next;
1756 __ps_free_operation(operation);
1761 if (appcontrol->uri) {
1762 uri_x *uri = appcontrol->uri;
1764 while(uri != NULL) {
1771 if (appcontrol->mime) {
1772 mime_x *mime = appcontrol->mime;
1774 while(mime != NULL) {
1776 __ps_free_mime(mime);
1781 if (appcontrol->subapp) {
1782 subapp_x *subapp = appcontrol->subapp;
1783 subapp_x *tmp = NULL;
1784 while(subapp != NULL) {
1786 __ps_free_subapp(subapp);
1790 free((void*)appcontrol);
1794 static void __ps_free_appsvc(appsvc_x *appsvc)
1799 free((void *)appsvc->text);
1800 appsvc->text = NULL;
1803 if (appsvc->operation) {
1804 operation_x *operation = appsvc->operation;
1805 operation_x *tmp = NULL;
1806 while(operation != NULL) {
1807 tmp = operation->next;
1808 __ps_free_operation(operation);
1814 uri_x *uri = appsvc->uri;
1816 while(uri != NULL) {
1824 mime_x *mime = appsvc->mime;
1826 while(mime != NULL) {
1828 __ps_free_mime(mime);
1833 if (appsvc->subapp) {
1834 subapp_x *subapp = appsvc->subapp;
1835 subapp_x *tmp = NULL;
1836 while(subapp != NULL) {
1838 __ps_free_subapp(subapp);
1842 free((void*)appsvc);
1846 static void __ps_free_deviceprofile(deviceprofile_x *deviceprofile)
1851 static void __ps_free_define(define_x *define)
1856 free((void *)define->path);
1857 define->path = NULL;
1860 if (define->request) {
1861 request_x *request = define->request;
1862 request_x *tmp = NULL;
1863 while(request != NULL) {
1864 tmp = request->next;
1865 __ps_free_request(request);
1870 if (define->allowed) {
1871 allowed_x *allowed = define->allowed;
1872 allowed_x *tmp = NULL;
1873 while(allowed != NULL) {
1874 tmp = allowed->next;
1875 __ps_free_allowed(allowed);
1879 free((void*)define);
1883 static void __ps_free_datashare(datashare_x *datashare)
1885 if (datashare == NULL)
1888 if (datashare->define) {
1889 define_x *define = datashare->define;
1890 define_x *tmp = NULL;
1891 while(define != NULL) {
1893 __ps_free_define(define);
1898 if (datashare->request) {
1899 request_x *request = datashare->request;
1900 request_x *tmp = NULL;
1901 while(request != NULL) {
1902 tmp = request->next;
1903 __ps_free_request(request);
1907 free((void*)datashare);
1911 static void __ps_free_label(label_x *label)
1916 free((void *)label->name);
1920 free((void *)label->text);
1924 free((void *)label->lang);
1931 static void __ps_free_author(author_x *author)
1935 if (author->email) {
1936 free((void *)author->email);
1937 author->email = NULL;
1940 free((void *)author->text);
1941 author->text = NULL;
1944 free((void *)author->href);
1945 author->href = NULL;
1948 free((void *)author->lang);
1949 author->lang = NULL;
1951 free((void*)author);
1955 static void __ps_free_description(description_x *description)
1957 if (description == NULL)
1959 if (description->name) {
1960 free((void *)description->name);
1961 description->name = NULL;
1963 if (description->text) {
1964 free((void *)description->text);
1965 description->text = NULL;
1967 if (description->lang) {
1968 free((void *)description->lang);
1969 description->lang = NULL;
1971 free((void*)description);
1975 static void __ps_free_license(license_x *license)
1977 if (license == NULL)
1979 if (license->text) {
1980 free((void *)license->text);
1981 license->text = NULL;
1983 if (license->lang) {
1984 free((void *)license->lang);
1985 license->lang = NULL;
1987 free((void*)license);
1991 static void __ps_free_uiapplication(uiapplication_x *uiapplication)
1993 if (uiapplication == NULL)
1995 if (uiapplication->exec) {
1996 free((void *)uiapplication->exec);
1997 uiapplication->exec = NULL;
1999 if (uiapplication->appid) {
2000 free((void *)uiapplication->appid);
2001 uiapplication->appid = NULL;
2003 if (uiapplication->nodisplay) {
2004 free((void *)uiapplication->nodisplay);
2005 uiapplication->nodisplay = NULL;
2007 if (uiapplication->multiple) {
2008 free((void *)uiapplication->multiple);
2009 uiapplication->multiple = NULL;
2011 if (uiapplication->type) {
2012 free((void *)uiapplication->type);
2013 uiapplication->type = NULL;
2015 if (uiapplication->categories) {
2016 free((void *)uiapplication->categories);
2017 uiapplication->categories = NULL;
2019 if (uiapplication->extraid) {
2020 free((void *)uiapplication->extraid);
2021 uiapplication->extraid = NULL;
2023 if (uiapplication->taskmanage) {
2024 free((void *)uiapplication->taskmanage);
2025 uiapplication->taskmanage = NULL;
2027 if (uiapplication->enabled) {
2028 free((void *)uiapplication->enabled);
2029 uiapplication->enabled = NULL;
2031 if (uiapplication->hwacceleration) {
2032 free((void *)uiapplication->hwacceleration);
2033 uiapplication->hwacceleration = NULL;
2035 if (uiapplication->screenreader) {
2036 free((void *)uiapplication->screenreader);
2037 uiapplication->screenreader = NULL;
2039 if (uiapplication->mainapp) {
2040 free((void *)uiapplication->mainapp);
2041 uiapplication->mainapp = NULL;
2043 if (uiapplication->recentimage) {
2044 free((void *)uiapplication->recentimage);
2045 uiapplication->recentimage = NULL;
2047 if (uiapplication->package) {
2048 free((void *)uiapplication->package);
2049 uiapplication->package = NULL;
2051 if (uiapplication->launchcondition) {
2052 free((void *)uiapplication->launchcondition);
2053 uiapplication->launchcondition = NULL;
2056 if (uiapplication->label) {
2057 label_x *label = uiapplication->label;
2058 label_x *tmp = NULL;
2059 while(label != NULL) {
2061 __ps_free_label(label);
2066 if (uiapplication->icon) {
2067 icon_x *icon = uiapplication->icon;
2069 while(icon != NULL) {
2071 __ps_free_icon(icon);
2076 if (uiapplication->image) {
2077 image_x *image = uiapplication->image;
2078 image_x *tmp = NULL;
2079 while(image != NULL) {
2081 __ps_free_image(image);
2086 if (uiapplication->appcontrol) {
2087 appcontrol_x *appcontrol = uiapplication->appcontrol;
2088 appcontrol_x *tmp = NULL;
2089 while(appcontrol != NULL) {
2090 tmp = appcontrol->next;
2091 __ps_free_appcontrol(appcontrol);
2095 /*Free LaunchConditions*/
2096 if (uiapplication->launchconditions) {
2097 launchconditions_x *launchconditions = uiapplication->launchconditions;
2098 launchconditions_x *tmp = NULL;
2099 while(launchconditions != NULL) {
2100 tmp = launchconditions->next;
2101 __ps_free_launchconditions(launchconditions);
2102 launchconditions = tmp;
2105 /*Free Notification*/
2106 if (uiapplication->notification) {
2107 notification_x *notification = uiapplication->notification;
2108 notification_x *tmp = NULL;
2109 while(notification != NULL) {
2110 tmp = notification->next;
2111 __ps_free_notification(notification);
2116 if (uiapplication->datashare) {
2117 datashare_x *datashare = uiapplication->datashare;
2118 datashare_x *tmp = NULL;
2119 while(datashare != NULL) {
2120 tmp = datashare->next;
2121 __ps_free_datashare(datashare);
2126 if (uiapplication->appsvc) {
2127 appsvc_x *appsvc = uiapplication->appsvc;
2128 appsvc_x *tmp = NULL;
2129 while(appsvc != NULL) {
2131 __ps_free_appsvc(appsvc);
2136 if (uiapplication->category) {
2137 category_x *category = uiapplication->category;
2138 category_x *tmp = NULL;
2139 while(category != NULL) {
2140 tmp = category->next;
2141 __ps_free_category(category);
2146 if (uiapplication->metadata) {
2147 metadata_x *metadata = uiapplication->metadata;
2148 metadata_x *tmp = NULL;
2149 while(metadata != NULL) {
2150 tmp = metadata->next;
2151 __ps_free_metadata(metadata);
2156 if (uiapplication->permission) {
2157 permission_x *permission = uiapplication->permission;
2158 permission_x *tmp = NULL;
2159 while(permission != NULL) {
2160 tmp = permission->next;
2161 __ps_free_permission(permission);
2165 /* _PRODUCT_LAUNCHING_ENHANCED_ START */
2166 if (uiapplication->indicatordisplay) {
2167 free((void *)uiapplication->indicatordisplay);
2168 uiapplication->indicatordisplay = NULL;
2170 if (uiapplication->portraitimg) {
2171 free((void *)uiapplication->portraitimg);
2172 uiapplication->portraitimg = NULL;
2174 if (uiapplication->landscapeimg) {
2175 free((void *)uiapplication->landscapeimg);
2176 uiapplication->landscapeimg = NULL;
2178 /* _PRODUCT_LAUNCHING_ENHANCED_ END */
2179 if (uiapplication->guestmode_visibility) {
2180 free((void *)uiapplication->guestmode_visibility);
2181 uiapplication->guestmode_visibility = NULL;
2183 if (uiapplication->app_component) {
2184 free((void *)uiapplication->app_component);
2185 uiapplication->app_component = NULL;
2187 if (uiapplication->permission_type) {
2188 free((void *)uiapplication->permission_type);
2189 uiapplication->permission_type = NULL;
2191 if (uiapplication->component_type) {
2192 free((void *)uiapplication->component_type);
2193 uiapplication->component_type = NULL;
2195 if (uiapplication->preload) {
2196 free((void *)uiapplication->preload);
2197 uiapplication->preload = NULL;
2199 if (uiapplication->submode) {
2200 free((void *)uiapplication->submode);
2201 uiapplication->submode = NULL;
2203 if (uiapplication->submode_mainid) {
2204 free((void *)uiapplication->submode_mainid);
2205 uiapplication->submode_mainid = NULL;
2208 free((void*)uiapplication);
2209 uiapplication = NULL;
2212 static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication)
2214 if (serviceapplication == NULL)
2216 if (serviceapplication->exec) {
2217 free((void *)serviceapplication->exec);
2218 serviceapplication->exec = NULL;
2220 if (serviceapplication->appid) {
2221 free((void *)serviceapplication->appid);
2222 serviceapplication->appid = NULL;
2224 if (serviceapplication->onboot) {
2225 free((void *)serviceapplication->onboot);
2226 serviceapplication->onboot = NULL;
2228 if (serviceapplication->autorestart) {
2229 free((void *)serviceapplication->autorestart);
2230 serviceapplication->autorestart = NULL;
2232 if (serviceapplication->type) {
2233 free((void *)serviceapplication->type);
2234 serviceapplication->type = NULL;
2236 if (serviceapplication->enabled) {
2237 free((void *)serviceapplication->enabled);
2238 serviceapplication->enabled = NULL;
2240 if (serviceapplication->package) {
2241 free((void *)serviceapplication->package);
2242 serviceapplication->package = NULL;
2244 if (serviceapplication->permission_type) {
2245 free((void *)serviceapplication->permission_type);
2246 serviceapplication->permission_type = NULL;
2249 if (serviceapplication->label) {
2250 label_x *label = serviceapplication->label;
2251 label_x *tmp = NULL;
2252 while(label != NULL) {
2254 __ps_free_label(label);
2259 if (serviceapplication->icon) {
2260 icon_x *icon = serviceapplication->icon;
2262 while(icon != NULL) {
2264 __ps_free_icon(icon);
2269 if (serviceapplication->appcontrol) {
2270 appcontrol_x *appcontrol = serviceapplication->appcontrol;
2271 appcontrol_x *tmp = NULL;
2272 while(appcontrol != NULL) {
2273 tmp = appcontrol->next;
2274 __ps_free_appcontrol(appcontrol);
2278 /*Free DataControl*/
2279 if (serviceapplication->datacontrol) {
2280 datacontrol_x *datacontrol = serviceapplication->datacontrol;
2281 datacontrol_x *tmp = NULL;
2282 while(datacontrol != NULL) {
2283 tmp = datacontrol->next;
2284 __ps_free_datacontrol(datacontrol);
2288 /*Free LaunchConditions*/
2289 if (serviceapplication->launchconditions) {
2290 launchconditions_x *launchconditions = serviceapplication->launchconditions;
2291 launchconditions_x *tmp = NULL;
2292 while(launchconditions != NULL) {
2293 tmp = launchconditions->next;
2294 __ps_free_launchconditions(launchconditions);
2295 launchconditions = tmp;
2298 /*Free Notification*/
2299 if (serviceapplication->notification) {
2300 notification_x *notification = serviceapplication->notification;
2301 notification_x *tmp = NULL;
2302 while(notification != NULL) {
2303 tmp = notification->next;
2304 __ps_free_notification(notification);
2309 if (serviceapplication->datashare) {
2310 datashare_x *datashare = serviceapplication->datashare;
2311 datashare_x *tmp = NULL;
2312 while(datashare != NULL) {
2313 tmp = datashare->next;
2314 __ps_free_datashare(datashare);
2319 if (serviceapplication->appsvc) {
2320 appsvc_x *appsvc = serviceapplication->appsvc;
2321 appsvc_x *tmp = NULL;
2322 while(appsvc != NULL) {
2324 __ps_free_appsvc(appsvc);
2329 if (serviceapplication->category) {
2330 category_x *category = serviceapplication->category;
2331 category_x *tmp = NULL;
2332 while(category != NULL) {
2333 tmp = category->next;
2334 __ps_free_category(category);
2339 if (serviceapplication->metadata) {
2340 metadata_x *metadata = serviceapplication->metadata;
2341 metadata_x *tmp = NULL;
2342 while(metadata != NULL) {
2343 tmp = metadata->next;
2344 __ps_free_metadata(metadata);
2349 if (serviceapplication->permission) {
2350 permission_x *permission = serviceapplication->permission;
2351 permission_x *tmp = NULL;
2352 while(permission != NULL) {
2353 tmp = permission->next;
2354 __ps_free_permission(permission);
2358 free((void*)serviceapplication);
2359 serviceapplication = NULL;
2362 static void __ps_free_font(font_x *font)
2367 free((void *)font->name);
2371 free((void *)font->text);
2378 static void __ps_free_theme(theme_x *theme)
2383 free((void *)theme->name);
2387 free((void *)theme->text);
2394 static void __ps_free_daemon(daemon_x *daemon)
2399 free((void *)daemon->name);
2400 daemon->name = NULL;
2403 free((void *)daemon->text);
2404 daemon->text = NULL;
2406 free((void*)daemon);
2410 static void __ps_free_ime(ime_x *ime)
2415 free((void *)ime->name);
2419 free((void *)ime->text);
2426 int __ps_process_tag_parser(manifest_x *mfx, const char *filename, ACTION_TYPE action)
2428 xmlTextReaderPtr reader;
2432 void *lib_handle = NULL;
2433 char tag[PKG_STRING_LEN_MAX] = { 0 };
2435 fp = fopen(TAG_PARSER_LIST, "r");
2436 retvm_if(fp == NULL, PMINFO_R_ERROR, "no preload list");
2438 while (fgets(tag, sizeof(tag), fp) != NULL) {
2441 lib_handle = __open_lib_handle(tag);
2442 if (lib_handle == NULL)
2445 ret = __parser_send_tag(lib_handle, action, PLUGIN_PRE_PROCESS, mfx->package);
2446 _LOGD("PLUGIN_PRE_PROCESS[%s, %s] ACTION_TYPE[%d] result[%d]\n", mfx->package, tag, action, ret);
2448 docPtr = xmlReadFile(filename, NULL, 0);
2449 reader = xmlReaderWalker(docPtr);
2450 if (reader != NULL) {
2451 ret = xmlTextReaderRead(reader);
2453 __processTag(lib_handle, reader, action, tag, mfx->package);
2454 ret = xmlTextReaderRead(reader);
2456 xmlFreeTextReader(reader);
2459 _LOGD("%s : failed to parse", filename);
2462 _LOGD("Unable to open %s", filename);
2465 ret = __parser_send_tag(lib_handle, action, PLUGIN_POST_PROCESS, mfx->package);
2466 _LOGD("PLUGIN_POST_PROCESS[%s, %s] ACTION_TYPE[%d] result[%d]\n", mfx->package, tag, action, ret);
2468 __close_lib_handle(lib_handle);
2470 memset(tag, 0x00, sizeof(tag));
2479 int __ps_process_metadata_parser(manifest_x *mfx, ACTION_TYPE action)
2481 fprintf(stdout,"__ps_process_metadata_parser\n");
2484 char md_key[PKG_STRING_LEN_MAX] = { 0 };
2486 fp = fopen(METADATA_PARSER_LIST, "r");
2488 _LOGD("no preload list\n");
2492 while (fgets(md_key, sizeof(md_key), fp) != NULL) {
2494 ret = __run_metadata_parser_prestep(mfx, md_key, action);
2496 memset(md_key, 0x00, sizeof(md_key));
2505 int __ps_process_category_parser(manifest_x *mfx, ACTION_TYPE action)
2509 char category_key[PKG_STRING_LEN_MAX] = { 0 };
2511 fp = fopen(CATEGORY_PARSER_LIST, "r");
2513 _LOGD("no category parser list\n");
2517 while (fgets(category_key, sizeof(category_key), fp) != NULL) {
2518 __str_trim(category_key);
2519 ret = __run_category_parser_prestep(mfx, category_key, action);
2521 memset(category_key, 0x00, sizeof(category_key));
2530 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed)
2532 xmlTextReaderRead(reader);
2533 if (xmlTextReaderValue(reader))
2534 allowed->text = ASCII(xmlTextReaderValue(reader));
2538 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation)
2540 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2541 operation->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2542 /* Text does not exist. Only attribute exists
2543 xmlTextReaderRead(reader);
2544 if (xmlTextReaderValue(reader))
2545 operation->text = ASCII(xmlTextReaderValue(reader));
2550 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri)
2552 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2553 uri->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2554 /* Text does not exist. Only attribute exists
2555 xmlTextReaderRead(reader);
2556 if (xmlTextReaderValue(reader))
2557 uri->text = ASCII(xmlTextReaderValue(reader));
2562 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime)
2564 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2565 mime->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2566 /* Text does not exist. Only attribute exists
2567 xmlTextReaderRead(reader);
2568 if (xmlTextReaderValue(reader))
2569 mime->text = ASCII(xmlTextReaderValue(reader));
2574 static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp)
2576 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2577 subapp->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2578 /* Text does not exist. Only attribute exists
2579 xmlTextReaderRead(reader);
2580 if (xmlTextReaderValue(reader))
2581 mime->text = ASCII(xmlTextReaderValue(reader));
2586 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition)
2588 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2589 condition->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2590 xmlTextReaderRead(reader);
2591 if (xmlTextReaderValue(reader))
2592 condition->text = ASCII(xmlTextReaderValue(reader));
2596 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notification)
2598 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2599 notification->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2600 xmlTextReaderRead(reader);
2601 if (xmlTextReaderValue(reader))
2602 notification->text = ASCII(xmlTextReaderValue(reader));
2606 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category)
2608 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2609 category->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2613 static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege)
2615 xmlTextReaderRead(reader);
2616 if (xmlTextReaderValue(reader)) {
2617 privilege->text = ASCII(xmlTextReaderValue(reader));
2622 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata)
2624 if (xmlTextReaderGetAttribute(reader, XMLCHAR("key")))
2625 metadata->key = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("key")));
2626 if (xmlTextReaderGetAttribute(reader, XMLCHAR("value")))
2627 metadata->value = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("value")));
2631 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission)
2633 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
2634 permission->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
2636 xmlTextReaderRead(reader);
2637 if (xmlTextReaderValue(reader))
2638 permission->value = ASCII(xmlTextReaderValue(reader));
2642 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility)
2644 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2645 compatibility->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2646 xmlTextReaderRead(reader);
2647 if (xmlTextReaderValue(reader))
2648 compatibility->text = ASCII(xmlTextReaderValue(reader));
2652 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution)
2654 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")))
2655 resolution->mimetype = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")));
2656 if (xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")))
2657 resolution->urischeme = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")));
2661 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request)
2663 xmlTextReaderRead(reader);
2664 if (xmlTextReaderValue(reader))
2665 request->text = ASCII(xmlTextReaderValue(reader));
2669 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define)
2671 const xmlChar *node;
2674 allowed_x *tmp1 = NULL;
2675 request_x *tmp2 = NULL;
2677 if (xmlTextReaderGetAttribute(reader, XMLCHAR("path")))
2678 define->path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("path")));
2680 depth = xmlTextReaderDepth(reader);
2681 while ((ret = __next_child_element(reader, depth))) {
2682 node = xmlTextReaderConstName(reader);
2684 _LOGD("xmlTextReaderConstName value is NULL\n");
2688 if (!strcmp(ASCII(node), "allowed")) {
2689 allowed_x *allowed= malloc(sizeof(allowed_x));
2690 if (allowed == NULL) {
2691 _LOGD("Malloc Failed\n");
2694 memset(allowed, '\0', sizeof(allowed_x));
2695 LISTADD(define->allowed, allowed);
2696 ret = __ps_process_allowed(reader, allowed);
2697 } else if (!strcmp(ASCII(node), "request")) {
2698 request_x *request = malloc(sizeof(request_x));
2699 if (request == NULL) {
2700 _LOGD("Malloc Failed\n");
2703 memset(request, '\0', sizeof(request_x));
2704 LISTADD(define->request, request);
2705 ret = __ps_process_request(reader, request);
2709 _LOGD("Processing define failed\n");
2713 if (define->allowed) {
2714 LISTHEAD(define->allowed, tmp1);
2715 define->allowed = tmp1;
2717 if (define->request) {
2718 LISTHEAD(define->request, tmp2);
2719 define->request = tmp2;
2724 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol)
2726 const xmlChar *node;
2729 operation_x *tmp1 = NULL;
2731 mime_x *tmp3 = NULL;
2732 subapp_x *tmp4 = NULL;
2734 depth = xmlTextReaderDepth(reader);
2735 while ((ret = __next_child_element(reader, depth))) {
2736 node = xmlTextReaderConstName(reader);
2738 _LOGD("xmlTextReaderConstName value is NULL\n");
2742 if (!strcmp(ASCII(node), "operation")) {
2743 operation_x *operation = malloc(sizeof(operation_x));
2744 if (operation == NULL) {
2745 _LOGD("Malloc Failed\n");
2748 memset(operation, '\0', sizeof(operation_x));
2749 LISTADD(appcontrol->operation, operation);
2750 ret = __ps_process_operation(reader, operation);
2751 _LOGD("operation processing\n");
2752 } else if (!strcmp(ASCII(node), "uri")) {
2753 uri_x *uri= malloc(sizeof(uri_x));
2755 _LOGD("Malloc Failed\n");
2758 memset(uri, '\0', sizeof(uri_x));
2759 LISTADD(appcontrol->uri, uri);
2760 ret = __ps_process_uri(reader, uri);
2761 _LOGD("uri processing\n");
2762 } else if (!strcmp(ASCII(node), "mime")) {
2763 mime_x *mime = malloc(sizeof(mime_x));
2765 _LOGD("Malloc Failed\n");
2768 memset(mime, '\0', sizeof(mime_x));
2769 LISTADD(appcontrol->mime, mime);
2770 ret = __ps_process_mime(reader, mime);
2771 _LOGD("mime processing\n");
2772 } else if (!strcmp(ASCII(node), "subapp")) {
2773 subapp_x *subapp = malloc(sizeof(subapp_x));
2774 if (subapp == NULL) {
2775 _LOGD("Malloc Failed\n");
2778 memset(subapp, '\0', sizeof(subapp_x));
2779 LISTADD(appcontrol->subapp, subapp);
2780 ret = __ps_process_subapp(reader, subapp);
2781 _LOGD("subapp processing\n");
2785 _LOGD("Processing appcontrol failed\n");
2789 if (appcontrol->operation) {
2790 LISTHEAD(appcontrol->operation, tmp1);
2791 appcontrol->operation = tmp1;
2793 if (appcontrol->uri) {
2794 LISTHEAD(appcontrol->uri, tmp2);
2795 appcontrol->uri = tmp2;
2797 if (appcontrol->mime) {
2798 LISTHEAD(appcontrol->mime, tmp3);
2799 appcontrol->mime = tmp3;
2801 if (appcontrol->subapp) {
2802 LISTHEAD(appcontrol->subapp, tmp4);
2803 appcontrol->subapp = tmp4;
2806 xmlTextReaderRead(reader);
2807 if (xmlTextReaderValue(reader))
2808 appcontrol->text = ASCII(xmlTextReaderValue(reader));
2813 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc)
2815 const xmlChar *node;
2818 operation_x *tmp1 = NULL;
2820 mime_x *tmp3 = NULL;
2821 subapp_x *tmp4 = NULL;
2823 depth = xmlTextReaderDepth(reader);
2824 while ((ret = __next_child_element(reader, depth))) {
2825 node = xmlTextReaderConstName(reader);
2827 _LOGD("xmlTextReaderConstName value is NULL\n");
2831 if (!strcmp(ASCII(node), "operation")) {
2832 operation_x *operation = malloc(sizeof(operation_x));
2833 if (operation == NULL) {
2834 _LOGD("Malloc Failed\n");
2837 memset(operation, '\0', sizeof(operation_x));
2838 LISTADD(appsvc->operation, operation);
2839 ret = __ps_process_operation(reader, operation);
2840 _LOGD("operation processing\n");
2841 } else if (!strcmp(ASCII(node), "uri")) {
2842 uri_x *uri= malloc(sizeof(uri_x));
2844 _LOGD("Malloc Failed\n");
2847 memset(uri, '\0', sizeof(uri_x));
2848 LISTADD(appsvc->uri, uri);
2849 ret = __ps_process_uri(reader, uri);
2850 _LOGD("uri processing\n");
2851 } else if (!strcmp(ASCII(node), "mime")) {
2852 mime_x *mime = malloc(sizeof(mime_x));
2854 _LOGD("Malloc Failed\n");
2857 memset(mime, '\0', sizeof(mime_x));
2858 LISTADD(appsvc->mime, mime);
2859 ret = __ps_process_mime(reader, mime);
2860 _LOGD("mime processing\n");
2861 } else if (!strcmp(ASCII(node), "subapp")) {
2862 subapp_x *subapp = malloc(sizeof(subapp_x));
2863 if (subapp == NULL) {
2864 _LOGD("Malloc Failed\n");
2867 memset(subapp, '\0', sizeof(subapp_x));
2868 LISTADD(appsvc->subapp, subapp);
2869 ret = __ps_process_subapp(reader, subapp);
2870 _LOGD("subapp processing\n");
2874 _LOGD("Processing appsvc failed\n");
2878 if (appsvc->operation) {
2879 LISTHEAD(appsvc->operation, tmp1);
2880 appsvc->operation = tmp1;
2883 LISTHEAD(appsvc->uri, tmp2);
2887 LISTHEAD(appsvc->mime, tmp3);
2888 appsvc->mime = tmp3;
2890 if (appsvc->subapp) {
2891 LISTHEAD(appsvc->subapp, tmp4);
2892 appsvc->subapp = tmp4;
2895 xmlTextReaderRead(reader);
2896 if (xmlTextReaderValue(reader))
2897 appsvc->text = ASCII(xmlTextReaderValue(reader));
2903 static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privileges)
2905 const xmlChar *node;
2908 privilege_x *tmp1 = NULL;
2910 depth = xmlTextReaderDepth(reader);
2911 while ((ret = __next_child_element(reader, depth))) {
2912 node = xmlTextReaderConstName(reader);
2914 _LOGD("xmlTextReaderConstName value is NULL\n");
2918 if (strcmp(ASCII(node), "privilege") == 0) {
2919 privilege_x *privilege = malloc(sizeof(privilege_x));
2920 if (privilege == NULL) {
2921 _LOGD("Malloc Failed\n");
2924 memset(privilege, '\0', sizeof(privilege_x));
2925 LISTADD(privileges->privilege, privilege);
2926 ret = __ps_process_privilege(reader, privilege);
2930 _LOGD("Processing privileges failed\n");
2934 if (privileges->privilege) {
2935 LISTHEAD(privileges->privilege, tmp1);
2936 privileges->privilege = tmp1;
2941 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions)
2943 const xmlChar *node;
2946 condition_x *tmp1 = NULL;
2948 depth = xmlTextReaderDepth(reader);
2949 while ((ret = __next_child_element(reader, depth))) {
2950 node = xmlTextReaderConstName(reader);
2952 _LOGD("xmlTextReaderConstName value is NULL\n");
2956 if (strcmp(ASCII(node), "condition") == 0) {
2957 condition_x *condition = malloc(sizeof(condition_x));
2958 if (condition == NULL) {
2959 _LOGD("Malloc Failed\n");
2962 memset(condition, '\0', sizeof(condition_x));
2963 LISTADD(launchconditions->condition, condition);
2964 ret = __ps_process_condition(reader, condition);
2968 _LOGD("Processing launchconditions failed\n");
2972 if (launchconditions->condition) {
2973 LISTHEAD(launchconditions->condition, tmp1);
2974 launchconditions->condition = tmp1;
2977 xmlTextReaderRead(reader);
2978 if (xmlTextReaderValue(reader))
2979 launchconditions->text = ASCII(xmlTextReaderValue(reader));
2984 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare)
2986 const xmlChar *node;
2989 define_x *tmp1 = NULL;
2990 request_x *tmp2 = NULL;
2991 depth = xmlTextReaderDepth(reader);
2992 while ((ret = __next_child_element(reader, depth))) {
2993 node = xmlTextReaderConstName(reader);
2995 _LOGD("xmlTextReaderConstName value is NULL\n");
2999 if (!strcmp(ASCII(node), "define")) {
3000 define_x *define= malloc(sizeof(define_x));
3001 if (define == NULL) {
3002 _LOGD("Malloc Failed\n");
3005 memset(define, '\0', sizeof(define_x));
3006 LISTADD(datashare->define, define);
3007 ret = __ps_process_define(reader, define);
3008 } else if (!strcmp(ASCII(node), "request")) {
3009 request_x *request= malloc(sizeof(request_x));
3010 if (request == NULL) {
3011 _LOGD("Malloc Failed\n");
3014 memset(request, '\0', sizeof(request_x));
3015 LISTADD(datashare->request, request);
3016 ret = __ps_process_request(reader, request);
3020 _LOGD("Processing data-share failed\n");
3024 if (datashare->define) {
3025 LISTHEAD(datashare->define, tmp1);
3026 datashare->define = tmp1;
3028 if (datashare->request) {
3029 LISTHEAD(datashare->request, tmp2);
3030 datashare->request = tmp2;
3036 __get_icon_with_path(const char* icon, uid_t uid)
3041 if (index(icon, '/') == NULL) {
3043 char* iconPath = NULL;
3044 char* icon_with_path = NULL;
3045 char *app_path = NULL;
3051 /* "db/setting/theme" is not exist */
3053 theme = vconf_get_str("db/setting/theme");
3055 theme = strdup("default");
3061 theme = strdup("default");
3064 len = (0x01 << 7) + strlen(icon) + strlen(package) + strlen(theme);
3065 icon_with_path = malloc(len);
3066 if(icon_with_path == NULL) {
3067 _LOGD("(icon_with_path == NULL) return\n");
3072 memset(icon_with_path, 0, len);
3073 if (uid != GLOBAL_USER)
3074 snprintf(icon_with_path, len, "%s%s", getIconPath(uid), icon);
3076 snprintf(icon_with_path, len, "%s%s/small/%s", getIconPath(GLOBAL_USER), theme, icon);
3077 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
3078 app_path = tzplatform_getenv(TZ_SYS_RW_APP);
3080 snprintf( len, icon_with_path, "%s/%q/res/icons/%q/small/%q", app_path , package, theme, icon);
3081 if (access (icon_with_path, F_OK))
3082 _LOGE("Cannot find icon path");
3086 _LOGD("Icon path : %s ---> %s", icon, icon_with_path);
3087 return icon_with_path;
3089 char* confirmed_icon = NULL;
3091 confirmed_icon = strdup(icon);
3092 if (!confirmed_icon)
3094 return confirmed_icon;
3098 static void __ps_process_tag(manifest_x * mfx, char *const tagv[])
3101 char delims[] = "=";
3102 char *ret_result = NULL;
3108 for (tag = strdup(tagv[0]); tag != NULL; ) {
3109 ret_result = strtok(tag, delims);
3111 /*check tag : preload */
3112 if (strcmp(ret_result, "preload") == 0) {
3113 ret_result = strtok(NULL, delims);
3114 if (strcmp(ret_result, "true") == 0) {
3115 free((void *)mfx->preload);
3116 mfx->preload = strdup("true");
3117 } else if (strcmp(ret_result, "false") == 0) {
3118 free((void *)mfx->preload);
3119 mfx->preload = strdup("false");
3121 /*check tag : removable*/
3122 } else if (strcmp(ret_result, "removable") == 0) {
3123 ret_result = strtok(NULL, delims);
3124 if (strcmp(ret_result, "true") == 0){
3125 free((void *)mfx->removable);
3126 mfx->removable = strdup("true");
3127 } else if (strcmp(ret_result, "false") == 0) {
3128 free((void *)mfx->removable);
3129 mfx->removable = strdup("false");
3131 /*check tag : not matched*/
3133 _LOGD("tag process [%s]is not defined\n", ret_result);
3137 /*check next value*/
3138 if (tagv[++i] != NULL)
3139 tag = strdup(tagv[i]);
3141 _LOGD("tag process success...\n");
3147 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon, uid_t uid)
3149 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
3150 icon->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
3151 if (xmlTextReaderConstXmlLang(reader)) {
3152 icon->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3153 if (icon->lang == NULL)
3154 icon->lang = strdup(DEFAULT_LOCALE);
3156 icon->lang = strdup(DEFAULT_LOCALE);
3158 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
3159 icon->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
3160 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
3161 icon->size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
3162 if (xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")))
3163 icon->resolution = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")));
3164 xmlTextReaderRead(reader);
3165 if (xmlTextReaderValue(reader)) {
3166 const char *text = ASCII(xmlTextReaderValue(reader));
3168 icon->text = (const char *)__get_icon_with_path(text, uid);
3176 static int __ps_process_image(xmlTextReaderPtr reader, image_x *image)
3178 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
3179 image->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
3180 if (xmlTextReaderConstXmlLang(reader)) {
3181 image->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3182 if (image->lang == NULL)
3183 image->lang = strdup(DEFAULT_LOCALE);
3185 image->lang = strdup(DEFAULT_LOCALE);
3187 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
3188 image->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
3189 xmlTextReaderRead(reader);
3190 if (xmlTextReaderValue(reader))
3191 image->text = ASCII(xmlTextReaderValue(reader));
3196 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label)
3198 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
3199 label->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
3200 if (xmlTextReaderConstXmlLang(reader)) {
3201 label->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3202 if (label->lang == NULL)
3203 label->lang = strdup(DEFAULT_LOCALE);
3205 label->lang = strdup(DEFAULT_LOCALE);
3206 xmlTextReaderRead(reader);
3207 if (xmlTextReaderValue(reader))
3208 label->text = ASCII(xmlTextReaderValue(reader));
3211 /* _LOGD("lable name %s\n", label->name);
3212 _LOGD("lable lang %s\n", label->lang);
3213 _LOGD("lable text %s\n", label->text);
3219 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author)
3221 if (xmlTextReaderGetAttribute(reader, XMLCHAR("email")))
3222 author->email = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("email")));
3223 if (xmlTextReaderGetAttribute(reader, XMLCHAR("href")))
3224 author->href = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("href")));
3225 if (xmlTextReaderConstXmlLang(reader)) {
3226 author->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3227 if (author->lang == NULL)
3228 author->lang = strdup(DEFAULT_LOCALE);
3230 author->lang = strdup(DEFAULT_LOCALE);
3232 xmlTextReaderRead(reader);
3233 if (xmlTextReaderValue(reader)) {
3234 const char *text = ASCII(xmlTextReaderValue(reader));
3235 if (*text == '\n') {
3236 author->text = NULL;
3240 author->text = ASCII(xmlTextReaderValue(reader));
3245 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description)
3247 if (xmlTextReaderConstXmlLang(reader)) {
3248 description->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3249 if (description->lang == NULL)
3250 description->lang = strdup(DEFAULT_LOCALE);
3252 description->lang = strdup(DEFAULT_LOCALE);
3254 xmlTextReaderRead(reader);
3255 if (xmlTextReaderValue(reader)) {
3256 const char *text = ASCII(xmlTextReaderValue(reader));
3257 if (*text == '\n') {
3258 description->text = NULL;
3262 description->text = ASCII(xmlTextReaderValue(reader));
3267 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license)
3269 if (xmlTextReaderConstXmlLang(reader)) {
3270 license->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3271 if (license->lang == NULL)
3272 license->lang = strdup(DEFAULT_LOCALE);
3274 license->lang = strdup(DEFAULT_LOCALE);
3276 xmlTextReaderRead(reader);
3277 if (xmlTextReaderValue(reader))
3278 license->text = ASCII(xmlTextReaderValue(reader));
3282 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability)
3284 const xmlChar *node;
3287 resolution_x *tmp1 = NULL;
3289 if (xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")))
3290 capability->operationid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")));
3292 depth = xmlTextReaderDepth(reader);
3293 while ((ret = __next_child_element(reader, depth))) {
3294 node = xmlTextReaderConstName(reader);
3296 _LOGD("xmlTextReaderConstName value is NULL\n");
3300 if (!strcmp(ASCII(node), "resolution")) {
3301 resolution_x *resolution = malloc(sizeof(resolution_x));
3302 if (resolution == NULL) {
3303 _LOGD("Malloc Failed\n");
3306 memset(resolution, '\0', sizeof(resolution_x));
3307 LISTADD(capability->resolution, resolution);
3308 ret = __ps_process_resolution(reader, resolution);
3312 _LOGD("Processing capability failed\n");
3317 if (capability->resolution) {
3318 LISTHEAD(capability->resolution, tmp1);
3319 capability->resolution = tmp1;
3325 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol)
3327 const xmlChar *node;
3330 capability_x *tmp1 = NULL;
3332 if (xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")))
3333 datacontrol->providerid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")));
3335 depth = xmlTextReaderDepth(reader);
3336 while ((ret = __next_child_element(reader, depth))) {
3337 node = xmlTextReaderConstName(reader);
3339 _LOGD("xmlTextReaderConstName value is NULL\n");
3343 if (!strcmp(ASCII(node), "capability")) {
3344 capability_x *capability = malloc(sizeof(capability_x));
3345 if (capability == NULL) {
3346 _LOGD("Malloc Failed\n");
3349 memset(capability, '\0', sizeof(capability_x));
3350 LISTADD(datacontrol->capability, capability);
3351 ret = __ps_process_capability(reader, capability);
3355 _LOGD("Processing datacontrol failed\n");
3360 if (datacontrol->capability) {
3361 LISTHEAD(datacontrol->capability, tmp1);
3362 datacontrol->capability = tmp1;
3368 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication, uid_t uid)
3370 const xmlChar *node;
3373 char *newappid = NULL;
3374 label_x *tmp1 = NULL;
3375 icon_x *tmp2 = NULL;
3376 appsvc_x *tmp3 = NULL;
3377 appcontrol_x *tmp4 = NULL;
3378 launchconditions_x *tmp5 = NULL;
3379 notification_x *tmp6 = NULL;
3380 datashare_x *tmp7 = NULL;
3381 category_x *tmp8 = NULL;
3382 metadata_x *tmp9 = NULL;
3383 image_x *tmp10 = NULL;
3384 permission_x *tmp11 = NULL;
3386 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
3387 uiapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
3388 if (uiapplication->appid == NULL) {
3389 _LOGD("appid cant be NULL\n");
3393 _LOGD("appid is mandatory\n");
3397 ret = __validate_appid(package, uiapplication->appid, &newappid);
3399 _LOGD("appid is not proper\n");
3403 if (uiapplication->appid)
3404 free((void *)uiapplication->appid);
3405 uiapplication->appid = newappid;
3407 uiapplication->package= strdup(package);
3409 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
3410 uiapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
3411 if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay"))) {
3412 uiapplication->nodisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay")));
3413 if (uiapplication->nodisplay == NULL)
3414 uiapplication->nodisplay = strdup("false");
3416 uiapplication->nodisplay = strdup("false");
3418 if (xmlTextReaderGetAttribute(reader, XMLCHAR("multiple"))) {
3419 uiapplication->multiple = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("multiple")));
3420 if (uiapplication->multiple == NULL)
3421 uiapplication->multiple = strdup("false");
3423 uiapplication->multiple = strdup("false");
3425 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
3426 uiapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
3427 if (xmlTextReaderGetAttribute(reader, XMLCHAR("categories")))
3428 uiapplication->categories = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("categories")));
3429 if (xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")))
3430 uiapplication->extraid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")));
3431 if (xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage"))) {
3432 uiapplication->taskmanage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage")));
3433 if (uiapplication->taskmanage == NULL)
3434 uiapplication->taskmanage = strdup("true");
3436 uiapplication->taskmanage = strdup("true");
3438 if (xmlTextReaderGetAttribute(reader, XMLCHAR("enabled"))) {
3439 uiapplication->enabled = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("enabled")));
3440 if (uiapplication->enabled == NULL)
3441 uiapplication->enabled = strdup("true");
3443 uiapplication->enabled = strdup("true");
3445 if (xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration"))) {
3446 uiapplication->hwacceleration = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration")));
3447 if (uiapplication->hwacceleration == NULL)
3448 uiapplication->hwacceleration = strdup("use-system-setting");
3450 uiapplication->hwacceleration = strdup("use-system-setting");
3452 if (xmlTextReaderGetAttribute(reader, XMLCHAR("screen-reader"))) {
3453 uiapplication->screenreader = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("screen-reader")));
3454 if (uiapplication->screenreader == NULL)
3455 uiapplication->screenreader = strdup("use-system-setting");
3457 uiapplication->screenreader = strdup("use-system-setting");
3459 if (xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")))
3460 uiapplication->recentimage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")));
3461 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp"))) {
3462 uiapplication->mainapp = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp")));
3463 if (uiapplication->mainapp == NULL)
3464 uiapplication->mainapp = strdup("false");
3466 uiapplication->mainapp = strdup("false");
3468 if (xmlTextReaderGetAttribute(reader, XMLCHAR("launchcondition"))) {
3469 uiapplication->launchcondition = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("launchcondition")));
3470 if (uiapplication->launchcondition == NULL)
3471 uiapplication->launchcondition = strdup("false");
3473 uiapplication->launchcondition = strdup("false");
3476 if (xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay"))) {
3477 uiapplication->indicatordisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay")));
3478 if (uiapplication->indicatordisplay == NULL)
3479 uiapplication->indicatordisplay = strdup("true");
3481 uiapplication->indicatordisplay = strdup("true");
3483 if (xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")))
3484 uiapplication->portraitimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")));
3486 uiapplication->portraitimg = NULL;
3487 if (xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")))
3488 uiapplication->landscapeimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")));
3490 uiapplication->landscapeimg = NULL;
3491 if (xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility"))) {
3492 uiapplication->guestmode_visibility = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility")));
3493 if (uiapplication->guestmode_visibility == NULL)
3494 uiapplication->guestmode_visibility = strdup("true");
3496 uiapplication->guestmode_visibility = strdup("true");
3498 if (xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type"))) {
3499 uiapplication->permission_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type")));
3500 if (uiapplication->permission_type == NULL)
3501 uiapplication->permission_type = strdup("normal");
3503 uiapplication->permission_type = strdup("normal");
3505 if (xmlTextReaderGetAttribute(reader, XMLCHAR("component-type"))) {
3506 uiapplication->component_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("component-type")));
3507 if (uiapplication->component_type == NULL)
3508 uiapplication->component_type = strdup("uiapp");
3510 uiapplication->component_type = strdup("uiapp");
3512 if (xmlTextReaderGetAttribute(reader, XMLCHAR("submode"))) {
3513 uiapplication->submode = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("submode")));
3514 if (uiapplication->submode == NULL)
3515 uiapplication->submode = strdup("false");
3517 uiapplication->submode = strdup("false");
3519 if (xmlTextReaderGetAttribute(reader, XMLCHAR("submode-mainid")))
3520 uiapplication->submode_mainid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("submode-mainid")));
3522 depth = xmlTextReaderDepth(reader);
3523 while ((ret = __next_child_element(reader, depth))) {
3524 node = xmlTextReaderConstName(reader);
3526 _LOGD("xmlTextReaderConstName value is NULL\n");
3529 if (!strcmp(ASCII(node), "label")) {
3530 label_x *label = malloc(sizeof(label_x));
3531 if (label == NULL) {
3532 _LOGD("Malloc Failed\n");
3535 memset(label, '\0', sizeof(label_x));
3536 LISTADD(uiapplication->label, label);
3537 ret = __ps_process_label(reader, label);
3538 } else if (!strcmp(ASCII(node), "icon")) {
3539 icon_x *icon = malloc(sizeof(icon_x));
3541 _LOGD("Malloc Failed\n");
3544 memset(icon, '\0', sizeof(icon_x));
3545 LISTADD(uiapplication->icon, icon);
3546 ret = __ps_process_icon(reader, icon, uid);
3547 } else if (!strcmp(ASCII(node), "image")) {
3548 image_x *image = malloc(sizeof(image_x));
3549 if (image == NULL) {
3550 _LOGD("Malloc Failed\n");
3553 memset(image, '\0', sizeof(image_x));
3554 LISTADD(uiapplication->image, image);
3555 ret = __ps_process_image(reader, image);
3556 } else if (!strcmp(ASCII(node), "category")) {
3557 category_x *category = malloc(sizeof(category_x));
3558 if (category == NULL) {
3559 _LOGD("Malloc Failed\n");
3562 memset(category, '\0', sizeof(category_x));
3563 LISTADD(uiapplication->category, category);
3564 ret = __ps_process_category(reader, category);
3565 } else if (!strcmp(ASCII(node), "metadata")) {
3566 metadata_x *metadata = malloc(sizeof(metadata_x));
3567 if (metadata == NULL) {
3568 _LOGD("Malloc Failed\n");
3571 memset(metadata, '\0', sizeof(metadata_x));
3572 LISTADD(uiapplication->metadata, metadata);
3573 ret = __ps_process_metadata(reader, metadata);
3574 } else if (!strcmp(ASCII(node), "permission")) {
3575 permission_x *permission = malloc(sizeof(permission_x));
3576 if (permission == NULL) {
3577 _LOGD("Malloc Failed\n");
3580 memset(permission, '\0', sizeof(permission_x));
3581 LISTADD(uiapplication->permission, permission);
3582 ret = __ps_process_permission(reader, permission);
3583 } else if (!strcmp(ASCII(node), "app-control")) {
3584 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
3585 if (appcontrol == NULL) {
3586 _LOGD("Malloc Failed\n");
3589 memset(appcontrol, '\0', sizeof(appcontrol_x));
3590 LISTADD(uiapplication->appcontrol, appcontrol);
3591 ret = __ps_process_appcontrol(reader, appcontrol);
3592 } else if (!strcmp(ASCII(node), "application-service")) {
3593 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
3594 if (appsvc == NULL) {
3595 _LOGD("Malloc Failed\n");
3598 memset(appsvc, '\0', sizeof(appsvc_x));
3599 LISTADD(uiapplication->appsvc, appsvc);
3600 ret = __ps_process_appsvc(reader, appsvc);
3601 } else if (!strcmp(ASCII(node), "data-share")) {
3602 datashare_x *datashare = malloc(sizeof(datashare_x));
3603 if (datashare == NULL) {
3604 _LOGD("Malloc Failed\n");
3607 memset(datashare, '\0', sizeof(datashare_x));
3608 LISTADD(uiapplication->datashare, datashare);
3609 ret = __ps_process_datashare(reader, datashare);
3610 } else if (!strcmp(ASCII(node), "launch-conditions")) {
3611 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
3612 if (launchconditions == NULL) {
3613 _LOGD("Malloc Failed\n");
3616 memset(launchconditions, '\0', sizeof(launchconditions_x));
3617 LISTADD(uiapplication->launchconditions, launchconditions);
3618 ret = __ps_process_launchconditions(reader, launchconditions);
3619 } else if (!strcmp(ASCII(node), "notification")) {
3620 notification_x *notification = malloc(sizeof(notification_x));
3621 if (notification == NULL) {
3622 _LOGD("Malloc Failed\n");
3625 memset(notification, '\0', sizeof(notification_x));
3626 LISTADD(uiapplication->notification, notification);
3627 ret = __ps_process_notification(reader, notification);
3631 _LOGD("Processing uiapplication failed\n");
3636 if (uiapplication->label) {
3637 LISTHEAD(uiapplication->label, tmp1);
3638 uiapplication->label = tmp1;
3640 if (uiapplication->icon) {
3641 LISTHEAD(uiapplication->icon, tmp2);
3642 uiapplication->icon = tmp2;
3644 if (uiapplication->appsvc) {
3645 LISTHEAD(uiapplication->appsvc, tmp3);
3646 uiapplication->appsvc = tmp3;
3648 if (uiapplication->appcontrol) {
3649 LISTHEAD(uiapplication->appcontrol, tmp4);
3650 uiapplication->appcontrol = tmp4;
3652 if (uiapplication->launchconditions) {
3653 LISTHEAD(uiapplication->launchconditions, tmp5);
3654 uiapplication->launchconditions = tmp5;
3656 if (uiapplication->notification) {
3657 LISTHEAD(uiapplication->notification, tmp6);
3658 uiapplication->notification = tmp6;
3660 if (uiapplication->datashare) {
3661 LISTHEAD(uiapplication->datashare, tmp7);
3662 uiapplication->datashare = tmp7;
3664 if (uiapplication->category) {
3665 LISTHEAD(uiapplication->category, tmp8);
3666 uiapplication->category = tmp8;
3668 if (uiapplication->metadata) {
3669 LISTHEAD(uiapplication->metadata, tmp9);
3670 uiapplication->metadata = tmp9;
3672 if (uiapplication->image) {
3673 LISTHEAD(uiapplication->image, tmp10);
3674 uiapplication->image = tmp10;
3676 if (uiapplication->permission) {
3677 LISTHEAD(uiapplication->permission, tmp11);
3678 uiapplication->permission = tmp11;
3684 static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication, uid_t uid)
3686 const xmlChar *node;
3689 char *newappid = NULL;
3690 label_x *tmp1 = NULL;
3691 icon_x *tmp2 = NULL;
3692 appsvc_x *tmp3 = NULL;
3693 appcontrol_x *tmp4 = NULL;
3694 datacontrol_x *tmp5 = NULL;
3695 launchconditions_x *tmp6 = NULL;
3696 notification_x *tmp7 = NULL;
3697 datashare_x *tmp8 = NULL;
3698 category_x *tmp9 = NULL;
3699 metadata_x *tmp10 = NULL;
3700 permission_x *tmp11 = NULL;
3702 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
3703 serviceapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
3704 if (serviceapplication->appid == NULL) {
3705 _LOGD("appid cant be NULL\n");
3709 _LOGD("appid is mandatory\n");
3713 ret = __validate_appid(package, serviceapplication->appid, &newappid);
3715 _LOGD("appid is not proper\n");
3719 if (serviceapplication->appid)
3720 free((void *)serviceapplication->appid);
3721 serviceapplication->appid = newappid;
3724 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
3725 serviceapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
3726 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
3727 serviceapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
3728 if (xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot"))) {
3729 serviceapplication->onboot = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot")));
3730 if (serviceapplication->onboot == NULL)
3731 serviceapplication->onboot = strdup("false");
3733 serviceapplication->onboot = strdup("false");
3735 if (xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart"))) {
3736 serviceapplication->autorestart = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart")));
3737 if (serviceapplication->autorestart == NULL)
3738 serviceapplication->autorestart = strdup("false");
3740 serviceapplication->autorestart = strdup("false");
3742 if (xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type"))) {
3743 serviceapplication->permission_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type")));
3744 if (serviceapplication->permission_type == NULL)
3745 serviceapplication->permission_type = strdup("normal");
3747 serviceapplication->permission_type = strdup("normal");
3750 depth = xmlTextReaderDepth(reader);
3751 while ((ret = __next_child_element(reader, depth))) {
3752 node = xmlTextReaderConstName(reader);
3754 _LOGD("xmlTextReaderConstName value is NULL\n");
3758 if (!strcmp(ASCII(node), "label")) {
3759 label_x *label = malloc(sizeof(label_x));
3760 if (label == NULL) {
3761 _LOGD("Malloc Failed\n");
3764 memset(label, '\0', sizeof(label_x));
3765 LISTADD(serviceapplication->label, label);
3766 ret = __ps_process_label(reader, label);
3767 } else if (!strcmp(ASCII(node), "icon")) {
3768 icon_x *icon = malloc(sizeof(icon_x));
3770 _LOGD("Malloc Failed\n");
3773 memset(icon, '\0', sizeof(icon_x));
3774 LISTADD(serviceapplication->icon, icon);
3775 ret = __ps_process_icon(reader, icon, uid);
3776 } else if (!strcmp(ASCII(node), "category")) {
3777 category_x *category = malloc(sizeof(category_x));
3778 if (category == NULL) {
3779 _LOGD("Malloc Failed\n");
3782 memset(category, '\0', sizeof(category_x));
3783 LISTADD(serviceapplication->category, category);
3784 ret = __ps_process_category(reader, category);
3785 } else if (!strcmp(ASCII(node), "metadata")) {
3786 metadata_x *metadata = malloc(sizeof(metadata_x));
3787 if (metadata == NULL) {
3788 _LOGD("Malloc Failed\n");
3791 memset(metadata, '\0', sizeof(metadata_x));
3792 LISTADD(serviceapplication->metadata, metadata);
3793 ret = __ps_process_metadata(reader, metadata);
3794 } else if (!strcmp(ASCII(node), "permission")) {
3795 permission_x *permission = malloc(sizeof(permission_x));
3796 if (permission == NULL) {
3797 _LOGD("Malloc Failed\n");
3800 memset(permission, '\0', sizeof(permission_x));
3801 LISTADD(serviceapplication->permission, permission);
3802 ret = __ps_process_permission(reader, permission);
3803 } else if (!strcmp(ASCII(node), "app-control")) {
3804 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
3805 if (appcontrol == NULL) {
3806 _LOGD("Malloc Failed\n");
3809 memset(appcontrol, '\0', sizeof(appcontrol_x));
3810 LISTADD(serviceapplication->appcontrol, appcontrol);
3811 ret = __ps_process_appcontrol(reader, appcontrol);
3812 } else if (!strcmp(ASCII(node), "application-service")) {
3813 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
3814 if (appsvc == NULL) {
3815 _LOGD("Malloc Failed\n");
3818 memset(appsvc, '\0', sizeof(appsvc_x));
3819 LISTADD(serviceapplication->appsvc, appsvc);
3820 ret = __ps_process_appsvc(reader, appsvc);
3821 } else if (!strcmp(ASCII(node), "data-share")) {
3822 datashare_x *datashare = malloc(sizeof(datashare_x));
3823 if (datashare == NULL) {
3824 _LOGD("Malloc Failed\n");
3827 memset(datashare, '\0', sizeof(datashare_x));
3828 LISTADD(serviceapplication->datashare, datashare);
3829 ret = __ps_process_datashare(reader, datashare);
3830 } else if (!strcmp(ASCII(node), "launch-conditions")) {
3831 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
3832 if (launchconditions == NULL) {
3833 _LOGD("Malloc Failed\n");
3836 memset(launchconditions, '\0', sizeof(launchconditions_x));
3837 LISTADD(serviceapplication->launchconditions, launchconditions);
3838 ret = __ps_process_launchconditions(reader, launchconditions);
3839 } else if (!strcmp(ASCII(node), "notification")) {
3840 notification_x *notification = malloc(sizeof(notification_x));
3841 if (notification == NULL) {
3842 _LOGD("Malloc Failed\n");
3845 memset(notification, '\0', sizeof(notification_x));
3846 LISTADD(serviceapplication->notification, notification);
3847 ret = __ps_process_notification(reader, notification);
3848 } else if (!strcmp(ASCII(node), "data-control")) {
3849 datacontrol_x *datacontrol = malloc(sizeof(datacontrol_x));
3850 if (datacontrol == NULL) {
3851 _LOGD("Malloc Failed\n");
3854 memset(datacontrol, '\0', sizeof(datacontrol_x));
3855 LISTADD(serviceapplication->datacontrol, datacontrol);
3856 ret = __ps_process_datacontrol(reader, datacontrol);
3860 _LOGD("Processing serviceapplication failed\n");
3865 if (serviceapplication->label) {
3866 LISTHEAD(serviceapplication->label, tmp1);
3867 serviceapplication->label = tmp1;
3869 if (serviceapplication->icon) {
3870 LISTHEAD(serviceapplication->icon, tmp2);
3871 serviceapplication->icon = tmp2;
3873 if (serviceapplication->appsvc) {
3874 LISTHEAD(serviceapplication->appsvc, tmp3);
3875 serviceapplication->appsvc = tmp3;
3877 if (serviceapplication->appcontrol) {
3878 LISTHEAD(serviceapplication->appcontrol, tmp4);
3879 serviceapplication->appcontrol = tmp4;
3881 if (serviceapplication->datacontrol) {
3882 LISTHEAD(serviceapplication->datacontrol, tmp5);
3883 serviceapplication->datacontrol = tmp5;
3885 if (serviceapplication->launchconditions) {
3886 LISTHEAD(serviceapplication->launchconditions, tmp6);
3887 serviceapplication->launchconditions = tmp6;
3889 if (serviceapplication->notification) {
3890 LISTHEAD(serviceapplication->notification, tmp7);
3891 serviceapplication->notification = tmp7;
3893 if (serviceapplication->datashare) {
3894 LISTHEAD(serviceapplication->datashare, tmp8);
3895 serviceapplication->datashare = tmp8;
3897 if (serviceapplication->category) {
3898 LISTHEAD(serviceapplication->category, tmp9);
3899 serviceapplication->category = tmp9;
3901 if (serviceapplication->metadata) {
3902 LISTHEAD(serviceapplication->metadata, tmp10);
3903 serviceapplication->metadata = tmp10;
3905 if (serviceapplication->permission) {
3906 LISTHEAD(serviceapplication->permission, tmp11);
3907 serviceapplication->permission = tmp11;
3913 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile)
3915 /*TODO: once policy is set*/
3919 static int __ps_process_font(xmlTextReaderPtr reader, font_x *font)
3921 /*TODO: once policy is set*/
3925 static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme)
3927 /*TODO: once policy is set*/
3931 static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon)
3933 /*TODO: once policy is set*/
3937 static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime)
3939 /*TODO: once policy is set*/
3943 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx, uid_t uid)
3945 _LOGD("__start_process\n");
3946 const xmlChar *node;
3949 label_x *tmp1 = NULL;
3950 author_x *tmp2 = NULL;
3951 description_x *tmp3 = NULL;
3952 license_x *tmp4 = NULL;
3953 uiapplication_x *tmp5 = NULL;
3954 serviceapplication_x *tmp6 = NULL;
3955 daemon_x *tmp7 = NULL;
3956 theme_x *tmp8 = NULL;
3957 font_x *tmp9 = NULL;
3958 ime_x *tmp10 = NULL;
3959 icon_x *tmp11 = NULL;
3960 compatibility_x *tmp12 = NULL;
3961 deviceprofile_x *tmp13 = NULL;
3962 privileges_x *tmp14 = NULL;
3964 depth = xmlTextReaderDepth(reader);
3966 while ((ret = __next_child_element(reader, depth))) {
3967 node = xmlTextReaderConstName(reader);
3969 _LOGD("xmlTextReaderConstName value is NULL\n");
3973 if (!strcmp(ASCII(node), "label")) {
3974 label_x *label = malloc(sizeof(label_x));
3975 if (label == NULL) {
3976 _LOGD("Malloc Failed\n");
3979 memset(label, '\0', sizeof(label_x));
3980 LISTADD(mfx->label, label);
3981 ret = __ps_process_label(reader, label);
3982 } else if (!strcmp(ASCII(node), "author")) {
3983 author_x *author = malloc(sizeof(author_x));
3984 if (author == NULL) {
3985 _LOGD("Malloc Failed\n");
3988 memset(author, '\0', sizeof(author_x));
3989 LISTADD(mfx->author, author);
3990 ret = __ps_process_author(reader, author);
3991 } else if (!strcmp(ASCII(node), "description")) {
3992 description_x *description = malloc(sizeof(description_x));
3993 if (description == NULL) {
3994 _LOGD("Malloc Failed\n");
3997 memset(description, '\0', sizeof(description_x));
3998 LISTADD(mfx->description, description);
3999 ret = __ps_process_description(reader, description);
4000 } else if (!strcmp(ASCII(node), "license")) {
4001 license_x *license = malloc(sizeof(license_x));
4002 if (license == NULL) {
4003 _LOGD("Malloc Failed\n");
4006 memset(license, '\0', sizeof(license_x));
4007 LISTADD(mfx->license, license);
4008 ret = __ps_process_license(reader, license);
4009 } else if (!strcmp(ASCII(node), "privileges")) {
4010 privileges_x *privileges = malloc(sizeof(privileges_x));
4011 if (privileges == NULL) {
4012 _LOGD("Malloc Failed\n");
4015 memset(privileges, '\0', sizeof(privileges_x));
4016 LISTADD(mfx->privileges, privileges);
4017 ret = __ps_process_privileges(reader, privileges);
4018 } else if (!strcmp(ASCII(node), "ui-application")) {
4019 uiapplication_x *uiapplication = malloc(sizeof(uiapplication_x));
4020 if (uiapplication == NULL) {
4021 _LOGD("Malloc Failed\n");
4024 memset(uiapplication, '\0', sizeof(uiapplication_x));
4025 LISTADD(mfx->uiapplication, uiapplication);
4026 ret = __ps_process_uiapplication(reader, uiapplication, uid);
4027 } else if (!strcmp(ASCII(node), "service-application")) {
4028 serviceapplication_x *serviceapplication = malloc(sizeof(serviceapplication_x));
4029 if (serviceapplication == NULL) {
4030 _LOGD("Malloc Failed\n");
4033 memset(serviceapplication, '\0', sizeof(serviceapplication_x));
4034 LISTADD(mfx->serviceapplication, serviceapplication);
4035 ret = __ps_process_serviceapplication(reader, serviceapplication, uid);
4036 } else if (!strcmp(ASCII(node), "daemon")) {
4037 daemon_x *daemon = malloc(sizeof(daemon_x));
4038 if (daemon == NULL) {
4039 _LOGD("Malloc Failed\n");
4042 memset(daemon, '\0', sizeof(daemon_x));
4043 LISTADD(mfx->daemon, daemon);
4044 ret = __ps_process_daemon(reader, daemon);
4045 } else if (!strcmp(ASCII(node), "theme")) {
4046 theme_x *theme = malloc(sizeof(theme_x));
4047 if (theme == NULL) {
4048 _LOGD("Malloc Failed\n");
4051 memset(theme, '\0', sizeof(theme_x));
4052 LISTADD(mfx->theme, theme);
4053 ret = __ps_process_theme(reader, theme);
4054 } else if (!strcmp(ASCII(node), "font")) {
4055 font_x *font = malloc(sizeof(font_x));
4057 _LOGD("Malloc Failed\n");
4060 memset(font, '\0', sizeof(font_x));
4061 LISTADD(mfx->font, font);
4062 ret = __ps_process_font(reader, font);
4063 } else if (!strcmp(ASCII(node), "ime")) {
4064 ime_x *ime = malloc(sizeof(ime_x));
4066 _LOGD("Malloc Failed\n");
4069 memset(ime, '\0', sizeof(ime_x));
4070 LISTADD(mfx->ime, ime);
4071 ret = __ps_process_ime(reader, ime);
4072 } else if (!strcmp(ASCII(node), "icon")) {
4073 icon_x *icon = malloc(sizeof(icon_x));
4075 _LOGD("Malloc Failed\n");
4078 memset(icon, '\0', sizeof(icon_x));
4079 LISTADD(mfx->icon, icon);
4080 ret = __ps_process_icon(reader, icon, uid);
4081 } else if (!strcmp(ASCII(node), "device-profile")) {
4082 deviceprofile_x *deviceprofile = malloc(sizeof(deviceprofile_x));
4083 if (deviceprofile == NULL) {
4084 _LOGD("Malloc Failed\n");
4087 memset(deviceprofile, '\0', sizeof(deviceprofile_x));
4088 LISTADD(mfx->deviceprofile, deviceprofile);
4089 ret = __ps_process_deviceprofile(reader, deviceprofile);
4090 } else if (!strcmp(ASCII(node), "compatibility")) {
4091 compatibility_x *compatibility = malloc(sizeof(compatibility_x));
4092 if (compatibility == NULL) {
4093 _LOGD("Malloc Failed\n");
4096 memset(compatibility, '\0', sizeof(compatibility_x));
4097 LISTADD(mfx->compatibility, compatibility);
4098 ret = __ps_process_compatibility(reader, compatibility);
4099 } else if (!strcmp(ASCII(node), "shortcut-list")) {
4101 } else if (!strcmp(ASCII(node), "livebox")) {
4103 } else if (!strcmp(ASCII(node), "account")) {
4105 } else if (!strcmp(ASCII(node), "notifications")) {
4107 } else if (!strcmp(ASCII(node), "ime")) {
4113 _LOGD("Processing manifest failed\n");
4118 LISTHEAD(mfx->label, tmp1);
4122 LISTHEAD(mfx->author, tmp2);
4125 if (mfx->description) {
4126 LISTHEAD(mfx->description, tmp3);
4127 mfx->description= tmp3;
4130 LISTHEAD(mfx->license, tmp4);
4133 if (mfx->uiapplication) {
4134 LISTHEAD(mfx->uiapplication, tmp5);
4135 mfx->uiapplication = tmp5;
4137 if (mfx->serviceapplication) {
4138 LISTHEAD(mfx->serviceapplication, tmp6);
4139 mfx->serviceapplication = tmp6;
4142 LISTHEAD(mfx->daemon, tmp7);
4146 LISTHEAD(mfx->theme, tmp8);
4150 LISTHEAD(mfx->font, tmp9);
4154 LISTHEAD(mfx->ime, tmp10);
4158 LISTHEAD(mfx->icon, tmp11);
4161 if (mfx->compatibility) {
4162 LISTHEAD(mfx->compatibility, tmp12);
4163 mfx->compatibility= tmp12;
4165 if (mfx->deviceprofile) {
4166 LISTHEAD(mfx->deviceprofile, tmp13);
4167 mfx->deviceprofile= tmp13;
4169 if (mfx->privileges) {
4170 LISTHEAD(mfx->privileges, tmp14);
4171 mfx->privileges = tmp14;
4176 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx, uid_t uid)
4178 const xmlChar *node;
4181 if ((ret = __next_child_element(reader, -1))) {
4182 node = xmlTextReaderConstName(reader);
4184 _LOGD("xmlTextReaderConstName value is NULL\n");
4188 if (!strcmp(ASCII(node), "manifest")) {
4189 if (xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns"))){
4190 mfx->ns = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")));
4192 if (xmlTextReaderGetAttribute(reader, XMLCHAR("package"))) {
4193 mfx->package= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("package")));
4194 if (mfx->package == NULL) {
4195 _LOGD("package cant be NULL\n");
4199 _LOGD("package field is mandatory\n");
4202 package = mfx->package;
4203 if (xmlTextReaderGetAttribute(reader, XMLCHAR("version")))
4204 mfx->version= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("version")));
4205 /*app2ext needs package size for external installation*/
4206 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
4207 mfx->package_size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
4208 if (xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")))
4209 mfx->installlocation = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")));
4210 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
4211 mfx->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
4212 if (xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")))
4213 mfx->root_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")));
4214 if (xmlTextReaderGetAttribute(reader, XMLCHAR("csc_path")))
4215 mfx->csc_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("csc_path")));
4216 if (xmlTextReaderGetAttribute(reader, XMLCHAR("main_package")))
4217 mfx->main_package = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("main_package")));
4218 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting"))) {
4219 mfx->appsetting = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting")));
4220 if (mfx->appsetting == NULL)
4221 mfx->appsetting = strdup("false");
4223 mfx->appsetting = strdup("false");
4225 if (xmlTextReaderGetAttribute(reader, XMLCHAR("storeclient-id")))
4226 mfx->storeclient_id= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("storeclient-id")));
4227 if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay-setting"))) {
4228 mfx->nodisplay_setting = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay-setting")));
4229 if (mfx->nodisplay_setting == NULL)
4230 mfx->nodisplay_setting = strdup("false");
4232 mfx->nodisplay_setting = strdup("false");
4234 if (xmlTextReaderGetAttribute(reader, XMLCHAR("url")))
4235 mfx->package_url= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("url")));
4236 /*Assign default values. If required it will be overwritten in __add_preload_info()*/
4237 mfx->preload = strdup("False");
4238 mfx->removable = strdup("True");
4239 mfx->readonly = strdup("False");
4240 mfx->update = strdup("False");
4241 mfx->system = strdup("False");
4242 char buf[PKG_STRING_LEN_MAX] = {'\0'};
4244 time_t current_time;
4245 time(¤t_time);
4246 snprintf(buf, PKG_STRING_LEN_MAX - 1, "%d", current_time);
4247 val = strndup(buf, PKG_STRING_LEN_MAX - 1);
4248 mfx->installed_time = val;
4249 mfx->installed_storage= strdup("installed_internal");
4251 ret = __start_process(reader, mfx, uid);
4253 _LOGD("No Manifest element found\n");
4260 static char* __convert_to_system_locale(const char *mlocale)
4262 if (mlocale == NULL)
4264 char *locale = NULL;
4265 locale = (char *)calloc(1, 6);
4267 _LOGE("Malloc Failed\n");
4271 strncpy(locale, mlocale, 2);
4272 strncat(locale, "_", 1);
4273 locale[3] = toupper(mlocale[3]);
4274 locale[4] = toupper(mlocale[4]);
4278 #define LIBAIL_PATH LIB_PATH "/libail.so.0"
4280 /* operation_type */
4290 static int __ail_change_info(int op, const char *appid, uid_t uid)
4292 void *lib_handle = NULL;
4296 if ((lib_handle = dlopen(LIBAIL_PATH, RTLD_LAZY)) == NULL) {
4297 _LOGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAIL_PATH);
4301 if(uid != GLOBAL_USER)
4303 int (*ail_desktop_operation) (const char *, uid_t uid);
4306 aop = "ail_usr_desktop_add";
4309 aop = "ail_usr_desktop_update";
4312 aop = "ail_usr_desktop_remove";
4315 aop = "ail_usr_desktop_clean";
4318 aop = "ail_usr_desktop_fota";
4325 if ((ail_desktop_operation =
4326 dlsym(lib_handle, aop)) == NULL || dlerror() != NULL) {
4327 _LOGE("can not find symbol \n");
4331 ret = ail_desktop_operation(appid, uid);
4333 int (*ail_desktop_operation) (const char *);
4336 aop = "ail_desktop_add";
4339 aop = "ail_desktop_update";
4342 aop = "ail_desktop_remove";
4345 aop = "ail_desktop_clean";
4348 aop = "ail_desktop_fota";
4355 if ((ail_desktop_operation =
4356 dlsym(lib_handle, aop)) == NULL || dlerror() != NULL) {
4357 _LOGE("can not find symbol \n");
4361 ret = ail_desktop_operation(appid);
4366 dlclose(lib_handle);
4371 /* desktop shoud be generated automatically based on manifest */
4372 /* Currently removable, taskmanage, etc fields are not considerd. it will be decided soon.*/
4373 #define BUFMAX 1024*128
4374 static int __ps_make_nativeapp_desktop(manifest_x * mfx, const char *manifest, ACTION_TYPE action, uid_t uid)
4378 char filepath[PKG_STRING_LEN_MAX] = "";
4380 char *buftemp = NULL;
4381 char *locale = NULL;
4383 buf = (char *)calloc(1, BUFMAX);
4385 _LOGE("Malloc Failed\n");
4389 buftemp = (char *)calloc(1, BUFMAX);
4391 _LOGE("Malloc Failed\n");
4396 if (action == ACTION_UPGRADE)
4397 __ail_change_info(AIL_CLEAN, mfx->package, uid);
4399 for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) {
4401 if (manifest != NULL) {
4402 /* skip making a deskfile and update ail, if preload app is updated */
4403 if(strstr(manifest, getUserManifestPath(uid))) {
4404 __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid, uid);
4405 _LOGE("preload app is update : skip and update ail : %s", manifest);
4410 snprintf(filepath, sizeof(filepath),"%s%s.desktop", getUserDesktopPath(uid), mfx->uiapplication->appid);
4412 /* skip if desktop exists
4413 if (access(filepath, R_OK) == 0)
4417 file = fopen(filepath, "w");
4420 _LOGD("Can't open %s", filepath);
4426 snprintf(buf, BUFMAX, "[Desktop Entry]\n");
4427 fwrite(buf, 1, strlen(buf), file);
4429 for( ; mfx->uiapplication->label ; mfx->uiapplication->label = mfx->uiapplication->label->next) {
4430 if(!strcmp(mfx->uiapplication->label->lang, DEFAULT_LOCALE)) {
4431 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
4433 locale = __convert_to_system_locale(mfx->uiapplication->label->lang);
4434 snprintf(buf, BUFMAX, "Name[%s]=%s\n", locale,
4435 mfx->uiapplication->label->text);
4438 fwrite(buf, 1, strlen(buf), file);
4441 if(mfx->uiapplication->label && mfx->uiapplication->label->text) {
4442 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
4443 fwrite(buf, 1, strlen(buf), file);
4446 else if(mfx->label && mfx->label->text) {
4447 snprintf(buf, BUFMAX, "Name=%s\n", mfx->label->text);
4448 fwrite(buf, 1, strlen(buf), file);
4450 snprintf(buf, BUFMAX, "Name=%s\n", mfx->package);
4451 fwrite(buf, 1, strlen(buf), file);
4456 snprintf(buf, BUFMAX, "Type=Application\n");
4457 fwrite(buf, 1, strlen(buf), file);
4459 if(mfx->uiapplication->exec) {
4460 snprintf(buf, BUFMAX, "Exec=%s\n", mfx->uiapplication->exec);
4461 fwrite(buf, 1, strlen(buf), file);
4464 if(mfx->uiapplication->icon && mfx->uiapplication->icon->text) {
4465 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->uiapplication->icon->text);
4466 fwrite(buf, 1, strlen(buf), file);
4467 } else if(mfx->icon && mfx->icon->text) {
4468 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->icon->text);
4469 fwrite(buf, 1, strlen(buf), file);
4473 if(mfx->uiapplication && mfx->uiapplication->appsvc) {
4474 appsvc_x *asvc = mfx->uiapplication->appsvc;
4476 const char *mime = NULL;
4477 const char *mime_delim = "; ";
4480 strncpy(buf, "MimeType=", BUFMAX-1);
4486 _LOGD("MIME type: %s\n", mime);
4487 strncat(buf, mime, BUFMAX-strlen(buf)-1);
4489 strncat(buf, mime_delim, BUFMAX-strlen(buf)-1);
4497 _LOGD("MIME types: buf[%s]\n", buf);
4498 _LOGD("MIME count: %d\n", mime_count);
4500 fwrite(buf, 1, strlen(buf), file);
4504 snprintf(buf, BUFMAX, "Version=%s\n", mfx->version);
4505 fwrite(buf, 1, strlen(buf), file);
4508 if(mfx->uiapplication->nodisplay) {
4509 snprintf(buf, BUFMAX, "NoDisplay=%s\n", mfx->uiapplication->nodisplay);
4510 fwrite(buf, 1, strlen(buf), file);
4513 if(mfx->uiapplication->categories) {
4514 snprintf(buf, BUFMAX, "Categories=%s\n", mfx->uiapplication->categories);
4515 fwrite(buf, 1, strlen(buf), file);
4518 if(mfx->uiapplication->taskmanage && !strcasecmp(mfx->uiapplication->taskmanage, "False")) {
4519 snprintf(buf, BUFMAX, "X-TIZEN-TaskManage=False\n");
4520 fwrite(buf, 1, strlen(buf), file);
4523 if(mfx->uiapplication->enabled && !strcasecmp(mfx->uiapplication->enabled, "False")) {
4524 snprintf(buf, BUFMAX, "X-TIZEN-Enabled=False\n");
4525 fwrite(buf, 1, strlen(buf), file);
4528 if(mfx->uiapplication->hwacceleration) {
4529 snprintf(buf, BUFMAX, "Hw-Acceleration=%s\n", mfx->uiapplication->hwacceleration);
4530 fwrite(buf, 1, strlen(buf), file);
4533 if(mfx->uiapplication->multiple && !strcasecmp(mfx->uiapplication->multiple, "True")) {
4534 snprintf(buf, BUFMAX, "X-TIZEN-Multiple=True\n");
4535 fwrite(buf, 1, strlen(buf), file);
4538 if(mfx->uiapplication->extraid) {
4539 snprintf(buf, BUFMAX, "X-TIZEN-PackageID=%s\n", mfx->uiapplication->extraid);
4540 fwrite(buf, 1, strlen(buf), file);
4543 if(mfx->removable && !strcasecmp(mfx->removable, "False")) {
4544 snprintf(buf, BUFMAX, "X-TIZEN-Removable=False\n");
4545 fwrite(buf, 1, strlen(buf), file);
4549 snprintf(buf, BUFMAX, "X-TIZEN-PackageType=%s\n", mfx->type);
4550 fwrite(buf, 1, strlen(buf), file);
4553 if(mfx->uiapplication->submode && !strcasecmp(mfx->uiapplication->submode, "True")) {
4554 snprintf(buf, BUFMAX, "X-TIZEN-Submode=%s\n", mfx->uiapplication->submode);
4555 fwrite(buf, 1, strlen(buf), file);
4556 snprintf(buf, BUFMAX, "X-TIZEN-SubmodeMainid=%s\n", mfx->uiapplication->submode_mainid);
4557 fwrite(buf, 1, strlen(buf), file);
4561 snprintf(buf, BUFMAX, "X-TIZEN-PkgID=%s\n", mfx->package);
4562 fwrite(buf, 1, strlen(buf), file);
4564 if(mfx->uiapplication->appid) {
4565 snprintf(buf, BUFMAX, "X-TIZEN-AppID=%s\n", mfx->uiapplication->appid);
4566 fwrite(buf, 1, strlen(buf), file);
4571 // snprintf(buf, BUFMAX, "X-TIZEN-PackageType=rpm\n");
4572 // fwrite(buf, 1, strlen(buf), file);
4575 if(mfx->uiapplication->appsvc) {
4576 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
4577 _LOGD("buf[%s]\n", buf);
4580 uiapplication_x *up = mfx->uiapplication;
4581 appsvc_x *asvc = NULL;
4582 operation_x *op = NULL;
4585 subapp_x *sub = NULL;
4586 const char *operation = NULL;
4587 const char *mime = NULL;
4588 const char *uri = NULL;
4589 const char *subapp = NULL;
4594 while(asvc != NULL) {
4595 op = asvc->operation;
4598 operation = op->name;
4617 strncpy(buftemp, buf, BUFMAX);
4618 snprintf(buf, BUFMAX, "%s;", buftemp);
4622 strncpy(buftemp, buf, BUFMAX);
4623 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
4624 _LOGD("buf[%s]\n", buf);
4629 } while(ui != NULL);
4633 }while(sub != NULL);
4646 fwrite(buf, 1, strlen(buf), file);
4648 // strncpy(buftemp, buf, BUFMAX);
4649 // snprintf(buf, BUFMAX, "%s\n", buftemp);
4650 // fwrite(buf, 1, strlen(buf), file);
4653 if(mfx->uiapplication->appcontrol) {
4654 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
4655 _LOGD("buf[%s]\n", buf);
4657 uiapplication_x *up = mfx->uiapplication;
4658 appcontrol_x *acontrol = NULL;
4659 operation_x *op = NULL;
4662 subapp_x *sub = NULL;
4663 const char *operation = NULL;
4664 const char *mime = NULL;
4665 const char *uri = NULL;
4666 const char *subapp = NULL;
4669 acontrol = up->appcontrol;
4670 while(acontrol != NULL) {
4671 op = acontrol->operation;
4674 operation = op->name;
4675 mi = acontrol->mime;
4681 sub = acontrol->subapp;
4693 strncpy(buftemp, buf, BUFMAX);
4694 snprintf(buf, BUFMAX, "%s;", buftemp);
4697 strncpy(buftemp, buf, BUFMAX);
4698 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
4699 _LOGD("buf[%s]\n", buf);
4704 } while(ui != NULL);
4708 }while(sub != NULL);
4717 acontrol = acontrol->next;
4721 fwrite(buf, 1, strlen(buf), file);
4723 // strncpy(buftemp, buf, BUFMAX);
4724 // snprintf(buf, BUFMAX, "%s\n", buftemp);
4725 // fwrite(buf, 1, strlen(buf), file);
4732 if (action == ACTION_FOTA)
4733 __ail_change_info(AIL_FOTA, mfx->uiapplication->appid, uid);
4735 __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid, uid);
4744 static int __ps_remove_nativeapp_desktop(manifest_x *mfx, uid_t uid)
4746 char filepath[PKG_STRING_LEN_MAX] = "";
4748 uiapplication_x *uiapplication = mfx->uiapplication;
4750 for(; uiapplication; uiapplication=uiapplication->next) {
4751 snprintf(filepath, sizeof(filepath),"%s%s.desktop", getUserDesktopPath(uid), uiapplication->appid);
4753 __ail_change_info(AIL_REMOVE, uiapplication->appid, uid);
4755 ret = remove(filepath);
4763 #define LIBAPPSVC_PATH LIB_PATH "/libappsvc.so.0"
4765 static int __ps_remove_appsvc_db(manifest_x *mfx)
4767 void *lib_handle = NULL;
4768 int (*appsvc_operation) (const char *);
4770 uiapplication_x *uiapplication = mfx->uiapplication;
4772 if ((lib_handle = dlopen(LIBAPPSVC_PATH, RTLD_LAZY)) == NULL) {
4773 _LOGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAPPSVC_PATH);
4777 if ((appsvc_operation =
4778 dlsym(lib_handle, "appsvc_unset_defapp")) == NULL || dlerror() != NULL) {
4779 _LOGE("can not find symbol \n");
4783 for(; uiapplication; uiapplication=uiapplication->next) {
4784 ret = appsvc_operation(uiapplication->appid);
4786 _LOGE("can not operation symbol \n");
4791 dlclose(lib_handle);
4796 #define PRELOAD_PACKAGE_LIST SYSCONFDIR "/package-manager/preload/preload_list.txt"
4797 static int __add_preload_info(manifest_x * mfx, const char *manifest, uid_t uid)
4800 char buffer[1024] = { 0 };
4803 if(strstr(manifest, getUserManifestPath(uid))) {
4804 free((void *)mfx->readonly);
4805 mfx->readonly = strdup("True");
4807 free((void *)mfx->preload);
4808 mfx->preload = strdup("True");
4810 free((void *)mfx->removable);
4811 mfx->removable = strdup("False");
4813 free((void *)mfx->system);
4814 mfx->system = strdup("True");
4819 fp = fopen(PRELOAD_PACKAGE_LIST, "r");
4821 _LOGE("no preload list\n");
4825 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
4826 if (buffer[0] == '#') {
4827 if(strcasestr(buffer, "RW_NORM"))
4829 else if(strcasestr(buffer, "RW_RM"))
4837 if(!strcmp(mfx->package, buffer)) {
4838 free((void *)mfx->preload);
4839 mfx->preload = strdup("True");
4841 free((void *)mfx->readonly);
4842 mfx->readonly = strdup("False");
4843 free((void *)mfx->removable);
4844 mfx->removable = strdup("False");
4845 } else if(state == 3){
4846 free((void *)mfx->readonly);
4847 mfx->readonly = strdup("False");
4848 free((void *)mfx->removable);
4849 mfx->removable = strdup("True");
4853 memset(buffer, 0x00, sizeof(buffer));
4862 static int __check_preload_updated(manifest_x * mfx, const char *manifest, uid_t uid)
4864 char filepath[PKG_STRING_LEN_MAX] = "";
4866 uiapplication_x *uiapplication = mfx->uiapplication;
4868 if(strstr(manifest, getUserManifestPath(uid))) {
4869 /* if preload app is updated, then remove previous desktop file on RW*/
4870 for(; uiapplication; uiapplication=uiapplication->next) {
4871 snprintf(filepath, sizeof(filepath),"%s%s.desktop", getUserDesktopPath(uid), uiapplication->appid);
4872 ret = remove(filepath);
4877 /* if downloaded app is updated, then update tag set true*/
4878 free((void *)mfx->update);
4879 mfx->update = strdup("true");
4886 API int pkgmgr_parser_create_desktop_file(manifest_x *mfx)
4890 _LOGD("Manifest pointer is NULL\n");
4893 ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_INSTALL, GLOBAL_USER);
4895 _LOGD("Creating desktop file failed\n");
4897 _LOGD("Creating desktop file Success\n");
4901 API int pkgmgr_parser_create_usr_desktop_file(manifest_x *mfx, uid_t uid)
4905 _LOGD("Manifest pointer is NULL\n");
4908 ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_INSTALL, uid);
4910 _LOGD("Creating desktop file failed\n");
4912 _LOGD("Creating desktop file Success\n");
4917 API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
4922 free((void *)mfx->ns);
4926 free((void *)mfx->package);
4927 mfx->package = NULL;
4930 free((void *)mfx->version);
4931 mfx->version = NULL;
4933 if (mfx->installlocation) {
4934 free((void *)mfx->installlocation);
4935 mfx->installlocation = NULL;
4938 free((void *)mfx->preload);
4939 mfx->preload = NULL;
4941 if (mfx->readonly) {
4942 free((void *)mfx->readonly);
4943 mfx->readonly = NULL;
4945 if (mfx->removable) {
4946 free((void *)mfx->removable);
4947 mfx->removable = NULL;
4950 free((void *)mfx->update);
4954 free((void *)mfx->system);
4958 free((void *)mfx->type);
4961 if (mfx->package_size) {
4962 free((void *)mfx->package_size);
4963 mfx->package_size = NULL;
4965 if (mfx->installed_time) {
4966 free((void *)mfx->installed_time);
4967 mfx->installed_time = NULL;
4969 if (mfx->installed_storage) {
4970 free((void *)mfx->installed_storage);
4971 mfx->installed_storage = NULL;
4973 if (mfx->storeclient_id) {
4974 free((void *)mfx->storeclient_id);
4975 mfx->storeclient_id = NULL;
4977 if (mfx->mainapp_id) {
4978 free((void *)mfx->mainapp_id);
4979 mfx->mainapp_id = NULL;
4981 if (mfx->package_url) {
4982 free((void *)mfx->package_url);
4983 mfx->package_url = NULL;
4985 if (mfx->root_path) {
4986 free((void *)mfx->root_path);
4987 mfx->root_path = NULL;
4989 if (mfx->csc_path) {
4990 free((void *)mfx->csc_path);
4991 mfx->csc_path = NULL;
4993 if (mfx->appsetting) {
4994 free((void *)mfx->appsetting);
4995 mfx->appsetting = NULL;
4997 if (mfx->nodisplay_setting) {
4998 free((void *)mfx->nodisplay_setting);
4999 mfx->nodisplay_setting = NULL;
5001 if (mfx->main_package) {
5002 free((void *)mfx->main_package);
5003 mfx->main_package = NULL;
5008 icon_x *icon = mfx->icon;
5010 while(icon != NULL) {
5012 __ps_free_icon(icon);
5018 label_x *label = mfx->label;
5019 label_x *tmp = NULL;
5020 while(label != NULL) {
5022 __ps_free_label(label);
5028 author_x *author = mfx->author;
5029 author_x *tmp = NULL;
5030 while(author != NULL) {
5032 __ps_free_author(author);
5036 /*Free Description*/
5037 if (mfx->description) {
5038 description_x *description = mfx->description;
5039 description_x *tmp = NULL;
5040 while(description != NULL) {
5041 tmp = description->next;
5042 __ps_free_description(description);
5048 license_x *license = mfx->license;
5049 license_x *tmp = NULL;
5050 while(license != NULL) {
5051 tmp = license->next;
5052 __ps_free_license(license);
5057 if (mfx->privileges) {
5058 privileges_x *privileges = mfx->privileges;
5059 privileges_x *tmp = NULL;
5060 while(privileges != NULL) {
5061 tmp = privileges->next;
5062 __ps_free_privileges(privileges);
5066 /*Free UiApplication*/
5067 if (mfx->uiapplication) {
5068 uiapplication_x *uiapplication = mfx->uiapplication;
5069 uiapplication_x *tmp = NULL;
5070 while(uiapplication != NULL) {
5071 tmp = uiapplication->next;
5072 __ps_free_uiapplication(uiapplication);
5073 uiapplication = tmp;
5076 /*Free ServiceApplication*/
5077 if (mfx->serviceapplication) {
5078 serviceapplication_x *serviceapplication = mfx->serviceapplication;
5079 serviceapplication_x *tmp = NULL;
5080 while(serviceapplication != NULL) {
5081 tmp = serviceapplication->next;
5082 __ps_free_serviceapplication(serviceapplication);
5083 serviceapplication = tmp;
5088 daemon_x *daemon = mfx->daemon;
5089 daemon_x *tmp = NULL;
5090 while(daemon != NULL) {
5092 __ps_free_daemon(daemon);
5098 theme_x *theme = mfx->theme;
5099 theme_x *tmp = NULL;
5100 while(theme != NULL) {
5102 __ps_free_theme(theme);
5108 font_x *font = mfx->font;
5110 while(font != NULL) {
5112 __ps_free_font(font);
5118 ime_x *ime = mfx->ime;
5120 while(ime != NULL) {
5126 /*Free Compatibility*/
5127 if (mfx->compatibility) {
5128 compatibility_x *compatibility = mfx->compatibility;
5129 compatibility_x *tmp = NULL;
5130 while(compatibility != NULL) {
5131 tmp = compatibility->next;
5132 __ps_free_compatibility(compatibility);
5133 compatibility = tmp;
5136 /*Free DeviceProfile*/
5137 if (mfx->deviceprofile) {
5138 deviceprofile_x *deviceprofile = mfx->deviceprofile;
5139 deviceprofile_x *tmp = NULL;
5140 while(deviceprofile != NULL) {
5141 tmp = deviceprofile->next;
5142 __ps_free_deviceprofile(deviceprofile);
5143 deviceprofile = tmp;
5151 API manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest)
5153 _LOGD("parsing start pkgmgr_parser_process_manifest_xml\n");
5154 xmlTextReaderPtr reader;
5155 manifest_x *mfx = NULL;
5157 reader = xmlReaderForFile(manifest, NULL, 0);
5159 mfx = malloc(sizeof(manifest_x));
5161 memset(mfx, '\0', sizeof(manifest_x));
5162 if (__process_manifest(reader, mfx, GLOBAL_USER) < 0) {
5163 _LOGD("Parsing Failed\n");
5164 pkgmgr_parser_free_manifest_xml(mfx);
5167 _LOGD("Parsing Success\n");
5169 _LOGD("Memory allocation error\n");
5171 xmlFreeTextReader(reader);
5173 _LOGD("Unable to create xml reader\n");
5179 API manifest_x *pkgmgr_parser_usr_process_manifest_xml(const char *manifest, uid_t uid)
5181 _LOGD("parsing start pkgmgr_parser_usr_process_manifest_xml\n");
5182 xmlTextReaderPtr reader;
5183 manifest_x *mfx = NULL;
5185 reader = xmlReaderForFile(manifest, NULL, 0);
5187 mfx = malloc(sizeof(manifest_x));
5189 memset(mfx, '\0', sizeof(manifest_x));
5190 if (__process_manifest(reader, mfx, uid) < 0) {
5191 _LOGD("Parsing Failed\n");
5192 pkgmgr_parser_free_manifest_xml(mfx);
5195 _LOGD("Parsing Success\n");
5197 _LOGD("Memory allocation error\n");
5199 xmlFreeTextReader(reader);
5201 _LOGD("Unable to create xml reader\n");
5206 /* These APIs are intended to call parser directly */
5208 API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
5210 // char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
5211 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5212 _LOGD("parsing manifest for installation: %s\n", manifest);
5214 manifest_x *mfx = NULL;
5218 mfx = pkgmgr_parser_process_manifest_xml(manifest);
5219 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5221 _LOGD("Parsing Finished\n");
5223 // __streamFile(manifest, ACTION_INSTALL, temp, mfx->package);
5224 __ps_process_tag_parser(mfx, manifest, ACTION_INSTALL);
5225 __add_preload_info(mfx, manifest, GLOBAL_USER);
5227 _LOGD("Added preload infomation\n");
5229 __ps_process_tag(mfx, tagv);
5231 ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
5232 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
5234 _LOGD("DB Insert Success\n");
5236 ret = __ps_process_metadata_parser(mfx, ACTION_INSTALL);
5238 _LOGD("Creating metadata parser failed\n");
5240 ret = __ps_process_category_parser(mfx, ACTION_INSTALL);
5242 _LOGD("Creating category parser failed\n");
5244 if (__check_action_fota(tagv))
5245 ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_FOTA, GLOBAL_USER);
5247 ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_INSTALL, GLOBAL_USER);
5250 _LOGD("Creating desktop file failed\n");
5252 _LOGD("Creating desktop file Success\n");
5254 pkgmgr_parser_free_manifest_xml(mfx);
5255 _LOGD("Free Done\n");
5260 API int pkgmgr_parser_parse_usr_manifest_for_installation(const char *manifest, uid_t uid, char *const tagv[])
5262 // char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
5263 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5264 _LOGD("parsing manifest for installation: %s\n", manifest);
5265 manifest_x *mfx = NULL;
5269 mfx = pkgmgr_parser_usr_process_manifest_xml(manifest, uid);
5270 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5272 _LOGD("Parsing Finished\n");
5273 // __streamFile(manifest, ACTION_INSTALL, temp, mfx->package);
5274 __ps_process_tag_parser(mfx, manifest, ACTION_INSTALL);
5275 __add_preload_info(mfx, manifest, uid);
5277 _LOGD("Added preload infomation\n");
5278 __ps_process_tag(mfx, tagv);
5280 ret = pkgmgr_parser_insert_manifest_info_in_usr_db(mfx, uid);
5281 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
5283 _LOGD("DB Insert Success\n");
5284 ret = __ps_process_metadata_parser(mfx, ACTION_INSTALL);
5286 _LOGD("Creating metadata parser failed\n");
5287 ret = __ps_process_category_parser(mfx, ACTION_INSTALL);
5289 _LOGD("Creating category parser failed\n");
5291 if (__check_action_fota(tagv))
5292 ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_FOTA, uid);
5294 ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_INSTALL, uid);
5297 _LOGD("Creating desktop file failed\n");
5299 _LOGD("Creating desktop file Success\n");
5300 pkgmgr_parser_free_manifest_xml(mfx);
5301 _LOGD("Free Done\n");
5307 API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
5309 // char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
5310 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5311 _LOGD("pkgmgr_parser_parse_manifest_for_upgrade parsing manifest for upgradation: %s\n", manifest);
5312 manifest_x *mfx = NULL;
5314 bool preload = false;
5315 bool system = false;
5316 char *csc_path = NULL;
5317 pkgmgrinfo_pkginfo_h handle = NULL;
5320 mfx = pkgmgr_parser_process_manifest_xml(manifest);
5321 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5323 _LOGD("Parsing Finished\n");
5324 // __streamFile(manifest, ACTION_UPGRADE, temp, mfx->package);
5325 __ps_process_tag_parser(mfx, manifest, ACTION_UPGRADE);
5326 __add_preload_info(mfx, manifest, GLOBAL_USER);
5327 _LOGD("Added preload infomation\n");
5328 __check_preload_updated(mfx, manifest, GLOBAL_USER);
5330 ret = pkgmgrinfo_pkginfo_get_pkginfo(mfx->package, &handle);
5331 if (ret != PMINFO_R_OK)
5332 _LOGD("pkgmgrinfo_pkginfo_get_pkginfo failed\n");
5333 ret = pkgmgrinfo_pkginfo_is_preload(handle, &preload);
5334 if (ret != PMINFO_R_OK)
5335 _LOGD("pkgmgrinfo_pkginfo_is_preload failed\n");
5338 free((void *)mfx->preload);
5339 mfx->preload = strdup("true");
5342 ret = pkgmgrinfo_pkginfo_is_system(handle, &system);
5343 if (ret != PMINFO_R_OK)
5344 _LOGD("pkgmgrinfo_pkginfo_is_system failed\n");
5346 free((void *)mfx->system);
5347 mfx->system = strdup("true");
5350 ret = pkgmgrinfo_pkginfo_get_csc_path(handle, &csc_path);
5351 if (ret != PMINFO_R_OK)
5352 _LOGD("pkgmgrinfo_pkginfo_get_csc_path failed\n");
5354 if (csc_path != NULL) {
5356 free((void *)mfx->csc_path);
5357 mfx->csc_path = strdup(csc_path);
5360 ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
5361 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
5362 _LOGD("DB Update Success\n");
5363 ret = __ps_process_metadata_parser(mfx, ACTION_UPGRADE);
5365 _LOGD("Upgrade metadata parser failed\n");
5367 ret = __ps_process_category_parser(mfx, ACTION_UPGRADE);
5369 _LOGD("Creating category parser failed\n");
5370 ret = __ps_make_nativeapp_desktop(mfx, manifest, ACTION_UPGRADE, GLOBAL_USER);
5372 _LOGD("Creating desktop file failed\n");
5374 _LOGD("Creating desktop file Success\n");
5375 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
5376 pkgmgr_parser_free_manifest_xml(mfx);
5377 _LOGD("Free Done\n");
5383 API int pkgmgr_parser_parse_usr_manifest_for_upgrade(const char *manifest, uid_t uid, char *const tagv[])
5385 // char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
5386 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5387 _LOGD(" pkgmgr_parser_parse_usr_manifest_for_upgrade parsing manifest for upgradation: %s\n", manifest);
5388 manifest_x *mfx = NULL;
5390 bool preload = false;
5391 bool system = false;
5392 char *csc_path = NULL;
5393 pkgmgrinfo_pkginfo_h handle = NULL;
5396 mfx = pkgmgr_parser_usr_process_manifest_xml(manifest, uid);
5397 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5399 _LOGD("Parsing Finished\n");
5400 //__streamFile(manifest, ACTION_UPGRADE, temp, mfx->package);
5401 __ps_process_tag_parser(mfx, manifest, ACTION_UPGRADE);
5402 __add_preload_info(mfx, manifest, uid);
5403 _LOGD("Added preload infomation\n");
5404 _LOGE("Added preload infomation\n");
5405 __check_preload_updated(mfx, manifest, uid);
5407 ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(mfx->package, uid, &handle);
5408 if (ret != PMINFO_R_OK)
5409 _LOGD("pkgmgrinfo_pkginfo_get_pkginfo failed\n");
5410 ret = pkgmgrinfo_pkginfo_is_preload(handle, &preload);
5411 if (ret != PMINFO_R_OK)
5412 _LOGD("pkgmgrinfo_pkginfo_is_preload failed\n");
5415 free((void *)mfx->preload);
5416 mfx->preload = strdup("true");
5419 ret = pkgmgrinfo_pkginfo_is_system(handle, &system);
5420 if (ret != PMINFO_R_OK)
5421 _LOGD("pkgmgrinfo_pkginfo_is_system failed\n");
5424 free((void *)mfx->system);
5425 mfx->system = strdup("true");
5428 ret = pkgmgrinfo_pkginfo_get_csc_path(handle, &csc_path);
5429 if (ret != PMINFO_R_OK)
5430 _LOGD("pkgmgrinfo_pkginfo_get_csc_path failed\n");
5431 if (csc_path != NULL) {
5433 free((void *)mfx->csc_path);
5434 mfx->csc_path = strdup(csc_path);
5437 ret = pkgmgr_parser_update_manifest_info_in_usr_db(mfx, uid);
5438 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
5439 _LOGD("DB Update Success\n");
5440 _LOGE("DB Update Success\n" );
5441 ret = __ps_process_metadata_parser(mfx, ACTION_UPGRADE);
5443 _LOGD("Upgrade metadata parser failed\n");
5444 ret = __ps_process_category_parser(mfx, ACTION_UPGRADE);
5446 _LOGD("Creating category parser failed\n");
5447 ret = __ps_make_nativeapp_desktop(mfx, manifest, ACTION_UPGRADE, uid);
5449 _LOGD("Creating desktop file failed\n");
5451 _LOGD("Creating desktop file Success\n");
5452 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
5453 pkgmgr_parser_free_manifest_xml(mfx);
5454 _LOGD("Free Done\n");
5460 API int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[])
5462 // char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
5463 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5464 _LOGD("parsing manifest for uninstallation: %s\n", manifest);
5466 manifest_x *mfx = NULL;
5469 mfx = pkgmgr_parser_process_manifest_xml(manifest);
5470 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5472 _LOGD("Parsing Finished\n");
5474 // __streamFile(manifest, ACTION_UNINSTALL, temp, mfx->package);
5475 __ps_process_tag_parser(mfx, manifest, ACTION_UNINSTALL);
5477 __add_preload_info(mfx, manifest, GLOBAL_USER);
5478 _LOGD("Added preload infomation\n");
5480 ret = __ps_process_metadata_parser(mfx, ACTION_UNINSTALL);
5482 _LOGD("Removing metadata parser failed\n");
5484 ret = __ps_process_category_parser(mfx, ACTION_UNINSTALL);
5486 _LOGD("Creating category parser failed\n");
5488 ret = pkgmgr_parser_delete_manifest_info_from_db(mfx);
5490 _LOGD("DB Delete failed\n");
5492 _LOGD("DB Delete Success\n");
5494 ret = __ps_remove_nativeapp_desktop(mfx, GLOBAL_USER);
5496 _LOGD("Removing desktop file failed\n");
5498 _LOGD("Removing desktop file Success\n");
5500 ret = __ps_remove_appsvc_db(mfx);
5502 _LOGD("Removing appsvc_db failed\n");
5504 _LOGD("Removing appsvc_db Success\n");
5506 pkgmgr_parser_free_manifest_xml(mfx);
5507 _LOGD("Free Done\n");
5514 API int pkgmgr_parser_parse_usr_manifest_for_uninstallation(const char *manifest, uid_t uid, char *const tagv[])
5516 // char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
5517 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5518 _LOGD("parsing manifest for uninstallation: %s\n", manifest);
5520 manifest_x *mfx = NULL;
5523 mfx = pkgmgr_parser_usr_process_manifest_xml(manifest, uid);
5524 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5526 _LOGD("Parsing Finished\n");
5528 // __streamFile(manifest, ACTION_UNINSTALL, temp, mfx->package);
5529 __ps_process_tag_parser(mfx, manifest, ACTION_UNINSTALL);
5531 __add_preload_info(mfx, manifest, uid);
5532 _LOGD("Added preload infomation\n");
5534 ret = __ps_process_metadata_parser(mfx, ACTION_UNINSTALL);
5536 _LOGD("Removing metadata parser failed\n");
5538 ret = __ps_process_category_parser(mfx, ACTION_UNINSTALL);
5540 _LOGD("Creating category parser failed\n");
5542 ret = pkgmgr_parser_delete_manifest_info_from_usr_db(mfx, uid);
5544 _LOGD("DB Delete failed\n");
5546 _LOGD("DB Delete Success\n");
5548 ret = __ps_remove_nativeapp_desktop(mfx, uid);
5550 _LOGD("Removing desktop file failed\n");
5552 _LOGD("Removing desktop file Success\n");
5554 ret = __ps_remove_appsvc_db(mfx);
5556 _LOGD("Removing appsvc_db failed\n");
5558 _LOGD("Removing appsvc_db Success\n");
5560 pkgmgr_parser_free_manifest_xml(mfx);
5561 _LOGD("Free Done\n");
5567 API int pkgmgr_parser_parse_manifest_for_preload()
5569 return pkgmgr_parser_update_preload_info_in_db();
5572 API int pkgmgr_parser_parse_usr_manifest_for_preload(uid_t uid)
5574 return pkgmgr_parser_update_preload_info_in_usr_db(uid);
5578 API char *pkgmgr_parser_get_usr_manifest_file(const char *pkgid, uid_t uid)
5580 return __pkgid_to_manifest(pkgid, uid);
5583 API char *pkgmgr_parser_get_manifest_file(const char *pkgid)
5585 return __pkgid_to_manifest(pkgid, GLOBAL_USER);
5588 API int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
5590 return __ps_run_parser(docPtr, tag, ACTION_INSTALL, pkgid);
5593 API int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgid)
5595 return __ps_run_parser(docPtr, tag, ACTION_UPGRADE, pkgid);
5598 API int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
5600 return __ps_run_parser(docPtr, tag, ACTION_UNINSTALL, pkgid);
5603 #define SCHEMA_FILE SYSCONFDIR "/package-manager/preload/manifest.xsd"
5605 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
5607 if (manifest == NULL) {
5608 _LOGE("manifest file is NULL\n");
5609 return PMINFO_R_EINVAL;
5612 xmlSchemaParserCtxtPtr ctx;
5613 xmlSchemaValidCtxtPtr vctx;
5614 xmlSchemaPtr xschema;
5615 ctx = xmlSchemaNewParserCtxt(SCHEMA_FILE);
5617 _LOGE("xmlSchemaNewParserCtxt() Failed\n");
5618 return PMINFO_R_ERROR;
5620 xschema = xmlSchemaParse(ctx);
5621 if (xschema == NULL) {
5622 _LOGE("xmlSchemaParse() Failed\n");
5623 return PMINFO_R_ERROR;
5625 vctx = xmlSchemaNewValidCtxt(xschema);
5627 _LOGE("xmlSchemaNewValidCtxt() Failed\n");
5628 return PMINFO_R_ERROR;
5630 xmlSchemaSetValidErrors(vctx, (xmlSchemaValidityErrorFunc) fprintf, (xmlSchemaValidityWarningFunc) fprintf, stderr);
5631 ret = xmlSchemaValidateFile(vctx, manifest, 0);
5633 _LOGE("xmlSchemaValidateFile() failed\n");
5634 return PMINFO_R_ERROR;
5635 } else if (ret == 0) {
5636 _LOGE("Manifest is Valid\n");
5639 _LOGE("Manifest Validation Failed with error code %d\n", ret);
5640 return PMINFO_R_ERROR;
5646 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
5656 _LOGE("fork failed\n");
5661 int dev_null_fd = open ("/dev/null", O_RDWR);
5662 if (dev_null_fd >= 0)
5664 dup2 (dev_null_fd, 0);/*stdin*/
5665 dup2 (dev_null_fd, 1);/*stdout*/
5666 dup2 (dev_null_fd, 2);/*stderr*/
5669 if (execl("/usr/bin/xmllint", "xmllint", manifest, "--schema",
5670 SCHEMA_FILE, NULL) < 0) {
5671 _LOGE("execl error\n");
5681 while ((err = waitpid(pid, &status, WNOHANG)) != pid) {
5685 _LOGE("waitpid failed\n");
5691 if(WIFEXITED(status) && !WEXITSTATUS(status))