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>
39 #include "pkgmgr_parser.h"
40 #include "pkgmgr_parser_internal.h"
41 #include "pkgmgr_parser_db.h"
42 #include "pkgmgr-info.h"
43 #include "pkgmgr_parser_signature.h"
44 #include "pkgmgr-info-debug.h"
49 #define LOG_TAG "PKGMGR_PARSER"
51 #define MANIFEST_RW_DIRECTORY tzplatform_getenv(TZ_SYS_RW_PACKAGES)
52 #define MANIFEST_RO_DIRECTORY tzplatform_getenv(TZ_SYS_RO_PACKAGES)
53 #define ASCII(s) (const char *)s
54 #define XMLCHAR(s) (const xmlChar *)s
56 #define METADATA_PARSER_LIST SYSCONFDIR "/package-manager/parserlib/metadata/metadata_parser_list.txt"
57 #define METADATA_PARSER_NAME "metadataparser:"
59 #define CATEGORY_PARSER_LIST SYSCONFDIR "/package-manager/parserlib/category/category_parser_list.txt"
60 #define CATEGORY_PARSER_NAME "categoryparser:"
62 #define TAG_PARSER_LIST SYSCONFDIR "/package-manager/parserlib/tag_parser_list.txt"
63 #define TAG_PARSER_NAME "parserlib:"
65 #define PKG_TAG_LEN_MAX 128
78 /* plugin process_type */
80 PLUGIN_PRE_PROCESS = 0,
82 } PLUGIN_PROCESS_TYPE;
95 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label);
96 static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege);
97 static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privileges);
98 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile);
99 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed);
100 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation);
101 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri);
102 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime);
103 static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp);
104 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition);
105 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notifiation);
106 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category);
107 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata);
108 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission);
109 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility);
110 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution);
111 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request);
112 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define);
113 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc);
114 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions);
115 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare);
116 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon);
117 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author);
118 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description);
119 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability);
120 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license);
121 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol);
122 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol);
123 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication);
124 static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication);
125 static int __ps_process_font(xmlTextReaderPtr reader, font_x *font);
126 static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme);
127 static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon);
128 static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime);
129 static void __ps_free_label(label_x *label);
130 static void __ps_free_privilege(privilege_x *privilege);
131 static void __ps_free_privileges(privileges_x *privileges);
132 static void __ps_free_deviceprofile(deviceprofile_x * deviceprofile);
133 static void __ps_free_allowed(allowed_x *allowed);
134 static void __ps_free_operation(operation_x *operation);
135 static void __ps_free_uri(uri_x *uri);
136 static void __ps_free_mime(mime_x *mime);
137 static void __ps_free_subapp(subapp_x *subapp);
138 static void __ps_free_condition(condition_x *condition);
139 static void __ps_free_notification(notification_x *notifiation);
140 static void __ps_free_category(category_x *category);
141 static void __ps_free_metadata(metadata_x *metadata);
142 static void __ps_free_permission(permission_x *permission);
143 static void __ps_free_compatibility(compatibility_x *compatibility);
144 static void __ps_free_resolution(resolution_x *resolution);
145 static void __ps_free_request(request_x *request);
146 static void __ps_free_define(define_x *define);
147 static void __ps_free_appsvc(appsvc_x *appsvc);
148 static void __ps_free_launchconditions(launchconditions_x *launchconditions);
149 static void __ps_free_datashare(datashare_x *datashare);
150 static void __ps_free_icon(icon_x *icon);
151 static void __ps_free_author(author_x *author);
152 static void __ps_free_description(description_x *description);
153 static void __ps_free_capability(capability_x *capability);
154 static void __ps_free_license(license_x *license);
155 static void __ps_free_appcontrol(appcontrol_x *appcontrol);
156 static void __ps_free_datacontrol(datacontrol_x *datacontrol);
157 static void __ps_free_uiapplication(uiapplication_x *uiapplication);
158 static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication);
159 static void __ps_free_font(font_x *font);
160 static void __ps_free_theme(theme_x *theme);
161 static void __ps_free_daemon(daemon_x *daemon);
162 static void __ps_free_ime(ime_x *ime);
163 static char *__pkgid_to_manifest(const char *pkgid);
164 static int __next_child_element(xmlTextReaderPtr reader, int depth);
165 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx);
166 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx);
167 static void __str_trim(char *input);
168 static char *__get_parser_plugin(const char *type);
169 static int __ps_run_parser(xmlDocPtr docPtr, const char *tag, ACTION_TYPE action, const char *pkgid);
170 static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid);
171 static void __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgid);
172 static void __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid);
173 static int __validate_appid(const char *pkgid, const char *appid, char **newappid);
174 static int __is_admin();
176 API char *getUserDBLabel(void)
180 result = strdup("System");
182 result = strdup("User");
186 API char *getUserPkgParserDBPath(void)
188 return getUserPkgParserDBPathUID(getuid());
191 API char *getUserPkgParserDBPathUID(uid_t uid)
196 result = tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_parser.db");
200 const char *name = "users";
201 struct passwd *userinfo = NULL;
202 struct group *grpinfo = NULL;
204 userinfo = getpwuid(uid);
206 _LOGE("getpwuid(%d) returns NULL !", uid);
208 grpinfo = getgrnam(name);
210 _LOGE("getgrnam(users) returns NULL !");
212 // Compare git_t type and not group name
213 if (grpinfo->gr_gid != userinfo->pw_gid)
214 _LOGE("UID [%d] does not belong to 'users' group!", uid);
216 result = userinfo->pw_dir;
217 strcat(result,"/.applications/dbspace/.pkgmgr_parser.db");
222 API char *getUserPkgParserJournalDBPath(void)
226 result = tzplatform_mkpath(TZ_USER_HOME, ".applications/dbspace/.pkgmgr_parser-journal.db");
228 result = tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_parser.db-journal");
232 API char *getUserPkgCertDBPath(void)
236 result = tzplatform_mkpath(TZ_USER_HOME, ".applications/dbspace/.pkgmgr_cert.db");
238 result = tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_cert.db");
242 API char *getUserPkgCertJournalDBPath(void)
246 result = tzplatform_mkpath(TZ_USER_HOME, ".applications/dbspace/.pkgmgr_cert-journal.db");
248 result = tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_cert-journal.db");
252 void *__open_lib_handle(char *tag)
254 char *lib_path = NULL;
255 void *lib_handle = NULL;
257 lib_path = __get_parser_plugin(tag);
258 retvm_if(!lib_path, NULL, "lib_path get fail");
260 lib_handle = dlopen(lib_path, RTLD_LAZY);
261 retvm_if(lib_handle == NULL, NULL, "dlopen is failed lib_path[%s]", lib_path);
266 void __close_lib_handle(void *lib_handle)
271 static void __str_trim(char *input)
273 char *trim_str = input;
278 while (*input != 0) {
279 if (!isspace(*input)) {
290 static int __is_admin()
292 uid_t uid = getuid();
293 if ((uid_t) 0 == uid )
301 static int __validate_appid(const char *pkgid, const char *appid, char **newappid)
303 if (!pkgid || !appid || !newappid) {
304 _LOGD("Arg supplied is NULL\n");
307 int pkglen = strlen(pkgid);
308 int applen = strlen(appid);
312 if (strncmp(appid, ".", 1) == 0) {
313 len = pkglen + applen + 1;
314 newapp = calloc(1,len);
315 if (newapp == NULL) {
316 _LOGD("Malloc failed\n");
319 strncpy(newapp, pkgid, pkglen);
320 strncat(newapp, appid, applen);
321 _LOGD("new appid is %s\n", newapp);
325 if (applen < pkglen) {
326 _LOGD("app id is not proper\n");
328 #ifdef _VALIDATE_APPID_
334 if (!strcmp(appid, pkgid)) {
335 _LOGD("appid is proper\n");
339 else if (strncmp(appid, pkgid, pkglen) == 0) {
340 ptr = strstr(appid, pkgid);
342 if (strncmp(ptr, ".", 1) == 0) {
343 _LOGD("appid is proper\n");
348 _LOGD("appid is not proper\n");
350 #ifdef _VALIDATE_APPID_
357 _LOGD("appid is not proper\n");
359 #ifdef _VALIDATE_APPID_
368 static char * __get_tag_by_key(char *md_key)
372 if (md_key == NULL) {
373 _LOGD("md_key is NULL\n");
377 md_tag = strrchr(md_key, 47) + 1;
380 return strdup(md_tag);
383 static char *__get_metadata_parser_plugin(const char *type)
386 char buffer[1024] = { 0 };
387 char temp_path[1024] = { 0 };
391 _LOGE("invalid argument\n");
395 fp = fopen(PKG_PARSER_CONF_PATH, "r");
397 _LOGE("no matching metadata parser\n");
401 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
402 if (buffer[0] == '#')
407 if ((path = strstr(buffer, METADATA_PARSER_NAME)) != NULL) {
408 path = path + strlen(METADATA_PARSER_NAME);
413 memset(buffer, 0x00, 1024);
420 _LOGE("no matching [%s] [%s]\n", METADATA_PARSER_NAME,type);
424 snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
426 return strdup(temp_path);
429 static char *__get_category_parser_plugin(const char *type)
432 char buffer[1024] = { 0 };
433 char temp_path[1024] = { 0 };
437 _LOGE("invalid argument\n");
441 fp = fopen(PKG_PARSER_CONF_PATH, "r");
443 _LOGE("no matching metadata parser\n");
447 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
448 if (buffer[0] == '#')
453 if ((path = strstr(buffer, CATEGORY_PARSER_NAME)) != NULL) {
454 path = path + strlen(CATEGORY_PARSER_NAME);
459 memset(buffer, 0x00, 1024);
466 _LOGE("no matching [%s] [%s]\n", CATEGORY_PARSER_NAME,type);
470 snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
472 return strdup(temp_path);
475 static char *__get_parser_plugin(const char *type)
478 char buffer[1024] = { 0 };
479 char temp_path[1024] = { 0 };
483 _LOGE("invalid argument\n");
487 fp = fopen(PKG_PARSER_CONF_PATH, "r");
489 _LOGE("no matching backendlib\n");
493 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
494 if (buffer[0] == '#')
499 if ((path = strstr(buffer, PKG_PARSERLIB)) != NULL) {
500 path = path + strlen(PKG_PARSERLIB);
504 memset(buffer, 0x00, 1024);
511 _LOGE("no matching backendlib\n");
515 snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
517 return strdup(temp_path);
520 static int __ps_run_tag_parser(void *lib_handle, xmlDocPtr docPtr, const char *tag,
521 ACTION_TYPE action, const char *pkgid)
523 int (*plugin_install) (xmlDocPtr, const char *);
529 ac = "PKGMGR_PARSER_PLUGIN_INSTALL";
532 ac = "PKGMGR_PARSER_PLUGIN_UPGRADE";
534 case ACTION_UNINSTALL:
535 ac = "PKGMGR_PARSER_PLUGIN_UNINSTALL";
541 if ((plugin_install =
542 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
543 _LOGE("can not find symbol[%s] \n", ac);
547 ret = plugin_install(docPtr, pkgid);
548 _LOGD("tag parser[%s, %s] ACTION_TYPE[%d] result[%d]\n", pkgid, tag, action, ret);
554 static int __ps_run_metadata_parser(GList *md_list, const char *tag,
555 ACTION_TYPE action, const char *pkgid, const char *appid)
557 char *lib_path = NULL;
558 void *lib_handle = NULL;
559 int (*metadata_parser_plugin) (const char *, const char *, GList *);
565 ac = "PKGMGR_MDPARSER_PLUGIN_INSTALL";
568 ac = "PKGMGR_MDPARSER_PLUGIN_UPGRADE";
570 case ACTION_UNINSTALL:
571 ac = "PKGMGR_MDPARSER_PLUGIN_UNINSTALL";
577 lib_path = __get_metadata_parser_plugin(tag);
579 _LOGE("get %s parser fail\n", tag);
583 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
584 _LOGE("dlopen is failed lib_path[%s]\n", lib_path);
588 if ((metadata_parser_plugin =
589 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
590 _LOGE("can not find symbol[%s] \n",ac);
594 ret = metadata_parser_plugin(pkgid, appid, md_list);
596 _LOGD("[appid = %s, libpath = %s plugin fail\n", appid, lib_path);
598 _LOGD("[appid = %s, libpath = %s plugin success\n", appid, lib_path);
608 static int __ps_run_category_parser(GList *category_list, const char *tag,
609 ACTION_TYPE action, const char *pkgid, const char *appid)
611 char *lib_path = NULL;
612 void *lib_handle = NULL;
613 int (*category_parser_plugin) (const char *, const char *, GList *);
619 ac = "PKGMGR_CATEGORY_PARSER_PLUGIN_INSTALL";
622 ac = "PKGMGR_CATEGORY_PARSER_PLUGIN_UPGRADE";
624 case ACTION_UNINSTALL:
625 ac = "PKGMGR_CATEGORY_PARSER_PLUGIN_UNINSTALL";
631 lib_path = __get_category_parser_plugin(tag);
633 _LOGE("get %s parser fail\n", tag);
637 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
638 _LOGE("dlopen is failed lib_path[%s]\n", lib_path);
642 if ((category_parser_plugin =
643 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
644 _LOGE("can not find symbol[%s] \n",ac);
648 ret = category_parser_plugin(pkgid, appid, category_list);
650 _LOGD("[appid = %s, libpath = %s plugin fail\n", appid, lib_path);
652 _LOGD("[appid = %s, libpath = %s plugin success\n", appid, lib_path);
662 static int __ps_run_parser(xmlDocPtr docPtr, const char *tag,
663 ACTION_TYPE action, const char *pkgid)
665 char *lib_path = NULL;
666 void *lib_handle = NULL;
667 int (*plugin_install) (xmlDocPtr, const char *);
673 ac = "PKGMGR_PARSER_PLUGIN_INSTALL";
676 ac = "PKGMGR_PARSER_PLUGIN_UPGRADE";
678 case ACTION_UNINSTALL:
679 ac = "PKGMGR_PARSER_PLUGIN_UNINSTALL";
685 lib_path = __get_parser_plugin(tag);
690 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
691 _LOGE("dlopen is failed lib_path[%s]\n", lib_path);
694 if ((plugin_install =
695 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
696 _LOGE("can not find symbol[%s] \n", ac);
700 ret = plugin_install(docPtr, pkgid);
702 _LOGD("[pkgid = %s, libpath = %s plugin fail\n", pkgid, lib_path);
704 _LOGD("[pkgid = %s, libpath = %s plugin success\n", pkgid, lib_path);
714 static char *__pkgid_to_manifest(const char *pkgid)
720 _LOGE("pkgid is NULL");
724 size = strlen(MANIFEST_RW_DIRECTORY) + strlen(pkgid) + 10;
725 manifest = malloc(size);
726 if (manifest == NULL) {
730 memset(manifest, '\0', size);
731 snprintf(manifest, size, "%s/%s.xml", MANIFEST_RW_DIRECTORY, pkgid);
733 if (access(manifest, F_OK)) {
734 snprintf(manifest, size, "%s/%s.xml", MANIFEST_RO_DIRECTORY, pkgid);
740 static void __metadata_parser_clear_dir_list(GList* dir_list)
743 __metadata_t* detail = NULL;
746 list = g_list_first(dir_list);
748 detail = (__metadata_t *)list->data;
756 list = g_list_next(list);
758 g_list_free(dir_list);
762 static void __category_parser_clear_dir_list(GList* dir_list)
765 __category_t* detail = NULL;
768 list = g_list_first(dir_list);
770 detail = (__category_t *)list->data;
777 list = g_list_next(list);
779 g_list_free(dir_list);
783 static int __run_tag_parser_prestep(void *lib_handle, xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid)
788 if (xmlTextReaderDepth(reader) != 1) {
789 _LOGE("Node depth is not 1");
793 if (xmlTextReaderNodeType(reader) != 1) {
794 _LOGE("Node type is not 1");
798 const xmlChar *value;
799 name = xmlTextReaderConstName(reader);
801 _LOGE("TEST TEST TES\n");
802 name = BAD_CAST "--";
805 value = xmlTextReaderConstValue(reader);
807 if (xmlStrlen(value) > 40) {
808 _LOGD(" %.40s...", value);
814 name = xmlTextReaderConstName(reader);
816 _LOGE("TEST TEST TES\n");
817 name = BAD_CAST "--";
820 xmlDocPtr docPtr = xmlTextReaderCurrentDoc(reader);
821 xmlDocPtr copyDocPtr = xmlCopyDoc(docPtr, 1);
822 if (copyDocPtr == NULL)
824 xmlNode *rootElement = xmlDocGetRootElement(copyDocPtr);
825 if (rootElement == NULL)
827 xmlNode *cur_node = xmlFirstElementChild(rootElement);
828 if (cur_node == NULL)
830 xmlNode *temp = xmlTextReaderExpand(reader);
833 xmlNode *next_node = NULL;
834 while(cur_node != NULL) {
835 if ( (strcmp(ASCII(temp->name), ASCII(cur_node->name)) == 0) &&
836 (temp->line == cur_node->line) ) {
840 next_node = xmlNextElementSibling(cur_node);
841 xmlUnlinkNode(cur_node);
842 xmlFreeNode(cur_node);
843 cur_node = next_node;
846 if (cur_node == NULL)
848 next_node = xmlNextElementSibling(cur_node);
850 cur_node->next = NULL;
851 next_node->prev = NULL;
852 xmlFreeNodeList(next_node);
853 xmlSetTreeDoc(cur_node, copyDocPtr);
855 xmlSetTreeDoc(cur_node, copyDocPtr);
858 ret = __ps_run_tag_parser(lib_handle, copyDocPtr, ASCII(name), action, pkgid);
864 static int __run_metadata_parser_prestep (manifest_x *mfx, char *md_key, ACTION_TYPE action)
868 char buffer[1024] = { 0, };
869 uiapplication_x *up = mfx->uiapplication;
870 metadata_x *md = NULL;
873 GList *md_list = NULL;
874 __metadata_t *md_detail = NULL;
876 md_tag = __get_tag_by_key(md_key);
877 if (md_tag == NULL) {
878 _LOGD("md_tag is NULL\n");
887 //get glist of metadata key and value combination
888 memset(buffer, 0x00, 1024);
889 snprintf(buffer, 1024, "%s/", md_key);
890 if ((md->key && md->value) && (strncmp(md->key, md_key, strlen(md_key)) == 0) && (strncmp(buffer, md->key, strlen(buffer)) == 0)) {
891 md_detail = (__metadata_t*) calloc(1, sizeof(__metadata_t));
892 if (md_detail == NULL) {
893 _LOGD("Memory allocation failed\n");
897 md_detail->key = (char*) calloc(1, sizeof(char)*(strlen(md->key)+2));
898 if (md_detail->key == NULL) {
899 _LOGD("Memory allocation failed\n");
903 snprintf(md_detail->key, (strlen(md->key)+1), "%s", md->key);
905 md_detail->value = (char*) calloc(1, sizeof(char)*(strlen(md->value)+2));
906 if (md_detail->value == NULL) {
907 _LOGD("Memory allocation failed\n");
908 free(md_detail->key);
912 snprintf(md_detail->value, (strlen(md->value)+1), "%s", md->value);
914 md_list = g_list_append(md_list, (gpointer)md_detail);
920 //send glist to parser when tags for metadata plugin parser exist.
922 ret = __ps_run_metadata_parser(md_list, md_tag, action, mfx->package, up->appid);
924 _LOGD("metadata_parser failed[%d] for tag[%s]\n", ret, md_tag);
926 _LOGD("metadata_parser success for tag[%s]\n", md_tag);
928 __metadata_parser_clear_dir_list(md_list);
936 __metadata_parser_clear_dir_list(md_list);
944 static int __run_category_parser_prestep (manifest_x *mfx, char *category_key, ACTION_TYPE action)
948 char buffer[1024] = { 0, };
949 uiapplication_x *up = mfx->uiapplication;
950 category_x *category = NULL;
951 char *category_tag = NULL;
953 GList *category_list = NULL;
954 __category_t *category_detail = NULL;
956 category_tag = __get_tag_by_key(category_key);
957 if (category_tag == NULL) {
958 _LOGD("md_tag is NULL\n");
964 category = up->category;
965 while (category != NULL)
967 //get glist of category key and value combination
968 memset(buffer, 0x00, 1024);
969 snprintf(buffer, 1024, "%s/", category_key);
970 if ((category->name) && (strncmp(category->name, category_key, strlen(category_key)) == 0)) {
971 category_detail = (__category_t*) calloc(1, sizeof(__category_t));
972 if (category_detail == NULL) {
973 _LOGD("Memory allocation failed\n");
977 category_detail->name = (char*) calloc(1, sizeof(char)*(strlen(category->name)+2));
978 if (category_detail->name == NULL) {
979 _LOGD("Memory allocation failed\n");
980 free(category_detail);
983 snprintf(category_detail->name, (strlen(category->name)+1), "%s", category->name);
985 category_list = g_list_append(category_list, (gpointer)category_detail);
988 category = category->next;
991 //send glist to parser when tags for metadata plugin parser exist.
993 ret = __ps_run_category_parser(category_list, category_tag, action, mfx->package, up->appid);
995 _LOGD("category_parser failed[%d] for tag[%s]\n", ret, category_tag);
997 _LOGD("category_parser success for tag[%s]\n", category_tag);
999 __category_parser_clear_dir_list(category_list);
1000 category_list = NULL;
1007 __category_parser_clear_dir_list(category_list);
1015 static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid)
1018 const xmlChar *name;
1020 // _LOGD("__run_parser_prestep");
1022 if (xmlTextReaderDepth(reader) != 1) {
1023 _LOGE("Node depth is not 1");
1027 if (xmlTextReaderNodeType(reader) != 1) {
1028 _LOGE("Node type is not 1");
1032 const xmlChar *value;
1033 name = xmlTextReaderConstName(reader);
1035 _LOGE("TEST TEST TES\n");
1036 name = BAD_CAST "--";
1039 value = xmlTextReaderConstValue(reader);
1040 _LOGD("%d %d %s %d %d",
1041 xmlTextReaderDepth(reader),
1042 xmlTextReaderNodeType(reader),
1044 xmlTextReaderIsEmptyElement(reader), xmlTextReaderHasValue(reader));
1046 if (value != NULL) {
1047 if (xmlStrlen(value) > 40) {
1048 _LOGD(" %.40s...", value);
1050 _LOGD(" %s", value);
1054 name = xmlTextReaderConstName(reader);
1056 _LOGE("TEST TEST TES\n");
1057 name = BAD_CAST "--";
1060 xmlDocPtr docPtr = xmlTextReaderCurrentDoc(reader);
1061 _LOGD("docPtr->URL %s\n", (char *)docPtr->URL);
1062 xmlDocPtr copyDocPtr = xmlCopyDoc(docPtr, 1);
1063 if (copyDocPtr == NULL)
1065 xmlNode *rootElement = xmlDocGetRootElement(copyDocPtr);
1066 if (rootElement == NULL)
1068 xmlNode *cur_node = xmlFirstElementChild(rootElement);
1069 if (cur_node == NULL)
1071 xmlNode *temp = xmlTextReaderExpand(reader);
1074 xmlNode *next_node = NULL;
1075 while(cur_node != NULL) {
1076 if ( (strcmp(ASCII(temp->name), ASCII(cur_node->name)) == 0) &&
1077 (temp->line == cur_node->line) ) {
1081 next_node = xmlNextElementSibling(cur_node);
1082 xmlUnlinkNode(cur_node);
1083 xmlFreeNode(cur_node);
1084 cur_node = next_node;
1087 if (cur_node == NULL)
1089 next_node = xmlNextElementSibling(cur_node);
1091 cur_node->next = NULL;
1092 next_node->prev = NULL;
1093 xmlFreeNodeList(next_node);
1094 xmlSetTreeDoc(cur_node, copyDocPtr);
1096 xmlSetTreeDoc(cur_node, copyDocPtr);
1102 _LOGD("node type: %d, name: %s children->name: %s last->name: %s\n"
1103 "parent->name: %s next->name: %s prev->name: %s\n",
1104 cur_node->type, cur_node->name,
1105 cur_node->children ? cur_node->children->name : "NULL",
1106 cur_node->last ? cur_node->last->name : "NULL",
1107 cur_node->parent ? cur_node->parent->name : "NULL",
1108 cur_node->next ? cur_node->next->name : "NULL",
1109 cur_node->prev ? cur_node->prev->name : "NULL");
1111 FILE *fp = fopen("/opt/share/test.xml", "a");
1112 xmlDocDump(fp, copyDocPtr);
1117 ret = __ps_run_parser(copyDocPtr, ASCII(name), action, pkgid);
1124 __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgid)
1129 switch (xmlTextReaderNodeType(reader)) {
1130 case XML_READER_TYPE_END_ELEMENT:
1132 // _LOGD("XML_READER_TYPE_END_ELEMENT");
1136 case XML_READER_TYPE_ELEMENT:
1138 // Elements without closing tag don't receive
1139 // XML_READER_TYPE_END_ELEMENT event.
1141 const xmlChar *elementName =
1142 xmlTextReaderLocalName(reader);
1143 if (elementName == NULL) {
1144 // _LOGD("elementName %s\n", (char *)elementName);
1148 const xmlChar *nameSpace =
1149 xmlTextReaderConstNamespaceUri(reader);
1151 // _LOGD("nameSpace %s\n", (char *)nameSpace);
1154 _LOGD("XML_READER_TYPE_ELEMENT %s, %s\n",
1155 elementName ? elementName : "NULL",
1156 nameSpace ? nameSpace : "NULL");
1159 _LOGD("__run_parser_prestep pkgid[%s]\n", pkgid);
1160 __run_parser_prestep(reader, action, pkgid);
1164 for (tag = tagv[0]; tag; tag = tagv[++i])
1165 if (strcmp(tag, ASCII(elementName)) == 0) {
1166 _LOGD("__run_parser_prestep tag[%s] pkgid[%s]\n", tag, pkgid);
1167 __run_parser_prestep(reader,
1175 case XML_READER_TYPE_TEXT:
1176 case XML_READER_TYPE_CDATA:
1178 const xmlChar *value = xmlTextReaderConstValue(reader);
1180 // _LOGD("value %s\n", value);
1183 const xmlChar *lang = xmlTextReaderConstXmlLang(reader);
1185 // _LOGD("lang\n", lang);
1188 /* _LOGD("XML_READER_TYPE_TEXT %s, %s\n",
1189 value ? value : "NULL", lang ? lang : "NULL");
1194 // _LOGD("Ignoring Node of Type: %d", xmlTextReaderNodeType(reader));
1200 __processTag(void *lib_handle, xmlTextReaderPtr reader, ACTION_TYPE action, char *tag, const char *pkgid)
1202 switch (xmlTextReaderNodeType(reader)) {
1203 case XML_READER_TYPE_END_ELEMENT:
1207 case XML_READER_TYPE_ELEMENT:
1209 // Elements without closing tag don't receive
1210 const xmlChar *elementName =
1211 xmlTextReaderLocalName(reader);
1212 if (elementName == NULL) {
1216 if (strcmp(tag, ASCII(elementName)) == 0) {
1217 _LOGD("find : tag[%s] ACTION_TYPE[%d] pkg[%s]\n", tag, action, pkgid);
1218 __run_tag_parser_prestep(lib_handle, reader, action, pkgid);
1229 static int __parser_send_tag(void *lib_handle, ACTION_TYPE action, PLUGIN_PROCESS_TYPE process, const char *pkgid)
1231 int (*plugin_install) (const char *);
1235 if (process == PLUGIN_PRE_PROCESS) {
1237 case ACTION_INSTALL:
1238 ac = "PKGMGR_PARSER_PLUGIN_PRE_INSTALL";
1240 case ACTION_UPGRADE:
1241 ac = "PKGMGR_PARSER_PLUGIN_PRE_UPGRADE";
1243 case ACTION_UNINSTALL:
1244 ac = "PKGMGR_PARSER_PLUGIN_PRE_UNINSTALL";
1249 } else if (process == PLUGIN_POST_PROCESS) {
1251 case ACTION_INSTALL:
1252 ac = "PKGMGR_PARSER_PLUGIN_POST_INSTALL";
1254 case ACTION_UPGRADE:
1255 ac = "PKGMGR_PARSER_PLUGIN_POST_UPGRADE";
1257 case ACTION_UNINSTALL:
1258 ac = "PKGMGR_PARSER_PLUGIN_POST_UNINSTALL";
1266 if ((plugin_install =
1267 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
1271 ret = plugin_install(pkgid);
1275 static void __plugin_send_tag(const char *tag, ACTION_TYPE action, PLUGIN_PROCESS_TYPE process, const char *pkgid)
1277 char *lib_path = NULL;
1278 void *lib_handle = NULL;
1279 int (*plugin_install) (const char *);
1283 if (process == PLUGIN_PRE_PROCESS) {
1285 case ACTION_INSTALL:
1286 ac = "PKGMGR_PARSER_PLUGIN_PRE_INSTALL";
1288 case ACTION_UPGRADE:
1289 ac = "PKGMGR_PARSER_PLUGIN_PRE_UPGRADE";
1291 case ACTION_UNINSTALL:
1292 ac = "PKGMGR_PARSER_PLUGIN_PRE_UNINSTALL";
1297 } else if (process == PLUGIN_POST_PROCESS) {
1299 case ACTION_INSTALL:
1300 ac = "PKGMGR_PARSER_PLUGIN_POST_INSTALL";
1302 case ACTION_UPGRADE:
1303 ac = "PKGMGR_PARSER_PLUGIN_POST_UPGRADE";
1305 case ACTION_UNINSTALL:
1306 ac = "PKGMGR_PARSER_PLUGIN_POST_UNINSTALL";
1314 lib_path = __get_parser_plugin(tag);
1319 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
1320 _LOGE("dlopen is failed lib_path[%s] for tag[%s]\n", lib_path, tag);
1323 if ((plugin_install =
1324 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
1325 // _LOGE("can not find symbol[%s] for tag[%s] \n", ac, tag);
1329 ret = plugin_install(pkgid);
1331 _LOGD("[PLUGIN_PROCESS_TYPE[%d] pkgid=%s, tag=%s plugin fail\n", process, pkgid, tag);
1333 _LOGD("[PLUGIN_PROCESS_TYPE[%d] pkgid=%s, tag=%s plugin success\n", process, pkgid, tag);
1339 dlclose(lib_handle);
1343 __plugin_process_tag(char *const tag_list[], ACTION_TYPE action, PLUGIN_PROCESS_TYPE process, const char *pkgid)
1348 for (tag = tag_list[0]; tag; tag = tag_list[++i])
1349 __plugin_send_tag(tag, action, process, pkgid);
1354 __plugin_save_tag(xmlTextReaderPtr reader, char *const tagv[], char *tag_list[])
1358 static int pre_cnt=0;
1360 switch (xmlTextReaderNodeType(reader)) {
1361 case XML_READER_TYPE_ELEMENT:
1363 const xmlChar *elementName = xmlTextReaderLocalName(reader);
1364 if (elementName == NULL) {
1368 for (tag = tag_list[0]; tag; tag = tag_list[++i])
1369 if (strcmp(ASCII(elementName), tag) == 0) {
1373 for (tag = tagv[0]; tag; tag = tagv[++i])
1374 if (strcmp(tag, ASCII(elementName)) == 0) {
1375 tag_list[pre_cnt++] = tag;
1381 // _LOGD("Ignoring Node of Type: %d", xmlTextReaderNodeType(reader));
1387 __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid)
1389 xmlTextReaderPtr reader;
1392 __plugin_process_tag(tagv, action, PLUGIN_PRE_PROCESS, pkgid);
1394 docPtr = xmlReadFile(filename, NULL, 0);
1395 reader = xmlReaderWalker(docPtr);
1396 if (reader != NULL) {
1397 ret = xmlTextReaderRead(reader);
1399 __processNode(reader, action, tagv, pkgid);
1400 ret = xmlTextReaderRead(reader);
1402 xmlFreeTextReader(reader);
1405 _LOGD("%s : failed to parse", filename);
1408 _LOGD("Unable to open %s", filename);
1411 __plugin_process_tag(tagv, action, PLUGIN_POST_PROCESS, pkgid);
1414 static int __next_child_element(xmlTextReaderPtr reader, int depth)
1416 int ret = xmlTextReaderRead(reader);
1417 int cur = xmlTextReaderDepth(reader);
1420 switch (xmlTextReaderNodeType(reader)) {
1421 case XML_READER_TYPE_ELEMENT:
1422 if (cur == depth + 1)
1425 case XML_READER_TYPE_TEXT:
1426 /*text is handled by each function separately*/
1427 if (cur == depth + 1)
1430 case XML_READER_TYPE_END_ELEMENT:
1439 ret = xmlTextReaderRead(reader);
1440 cur = xmlTextReaderDepth(reader);
1445 static bool __check_action_fota(char *const tagv[])
1448 char delims[] = "=";
1449 char *ret_result = NULL;
1456 for (tag = strdup(tagv[0]); tag != NULL; ) {
1457 ret_result = strtok(tag, delims);
1459 /*check tag : fota is true */
1460 if (strcmp(ret_result, "fota") == 0) {
1461 ret_result = strtok(NULL, delims);
1462 if (strcmp(ret_result, "true") == 0) {
1466 _LOGD("tag process [%s]is not defined\n", ret_result);
1470 /*check next value*/
1471 if (tagv[++i] != NULL)
1472 tag = strdup(tagv[i]);
1474 _LOGD("tag process success...%d\n" , ret);
1482 static void __ps_free_category(category_x *category)
1484 if (category == NULL)
1486 if (category->name) {
1487 free((void *)category->name);
1488 category->name = NULL;
1490 free((void*)category);
1494 static void __ps_free_privilege(privilege_x *privilege)
1496 if (privilege == NULL)
1498 if (privilege->text) {
1499 free((void *)privilege->text);
1500 privilege->text = NULL;
1502 free((void*)privilege);
1506 static void __ps_free_privileges(privileges_x *privileges)
1508 if (privileges == NULL)
1511 if (privileges->privilege) {
1512 privilege_x *privilege = privileges->privilege;
1513 privilege_x *tmp = NULL;
1514 while(privilege != NULL) {
1515 tmp = privilege->next;
1516 __ps_free_privilege(privilege);
1520 free((void*)privileges);
1524 static void __ps_free_metadata(metadata_x *metadata)
1526 if (metadata == NULL)
1528 if (metadata->key) {
1529 free((void *)metadata->key);
1530 metadata->key = NULL;
1532 if (metadata->value) {
1533 free((void *)metadata->value);
1534 metadata->value = NULL;
1536 free((void*)metadata);
1540 static void __ps_free_permission(permission_x *permission)
1542 if (permission == NULL)
1544 if (permission->type) {
1545 free((void *)permission->type);
1546 permission->type = NULL;
1548 if (permission->value) {
1549 free((void *)permission->value);
1550 permission->value = NULL;
1552 free((void*)permission);
1556 static void __ps_free_icon(icon_x *icon)
1561 free((void *)icon->text);
1565 free((void *)icon->lang);
1569 free((void *)icon->name);
1572 if (icon->section) {
1573 free((void *)icon->section);
1574 icon->section = NULL;
1577 free((void *)icon->size);
1580 if (icon->resolution) {
1581 free((void *)icon->resolution);
1582 icon->resolution = NULL;
1588 static void __ps_free_image(image_x *image)
1593 free((void *)image->text);
1597 free((void *)image->lang);
1601 free((void *)image->name);
1604 if (image->section) {
1605 free((void *)image->section);
1606 image->section = NULL;
1612 static void __ps_free_operation(operation_x *operation)
1614 if (operation == NULL)
1616 if (operation->text) {
1617 free((void *)operation->text);
1618 operation->text = NULL;
1620 free((void*)operation);
1624 static void __ps_free_uri(uri_x *uri)
1629 free((void *)uri->text);
1636 static void __ps_free_mime(mime_x *mime)
1641 free((void *)mime->text);
1648 static void __ps_free_subapp(subapp_x *subapp)
1653 free((void *)subapp->text);
1654 subapp->text = NULL;
1656 free((void*)subapp);
1660 static void __ps_free_condition(condition_x *condition)
1662 if (condition == NULL)
1664 if (condition->text) {
1665 free((void *)condition->text);
1666 condition->text = NULL;
1668 if (condition->name) {
1669 free((void *)condition->name);
1670 condition->name = NULL;
1672 free((void*)condition);
1676 static void __ps_free_notification(notification_x *notification)
1678 if (notification == NULL)
1680 if (notification->text) {
1681 free((void *)notification->text);
1682 notification->text = NULL;
1684 if (notification->name) {
1685 free((void *)notification->name);
1686 notification->name = NULL;
1688 free((void*)notification);
1689 notification = NULL;
1692 static void __ps_free_compatibility(compatibility_x *compatibility)
1694 if (compatibility == NULL)
1696 if (compatibility->text) {
1697 free((void *)compatibility->text);
1698 compatibility->text = NULL;
1700 if (compatibility->name) {
1701 free((void *)compatibility->name);
1702 compatibility->name = NULL;
1704 free((void*)compatibility);
1705 compatibility = NULL;
1708 static void __ps_free_resolution(resolution_x *resolution)
1710 if (resolution == NULL)
1712 if (resolution->mimetype) {
1713 free((void *)resolution->mimetype);
1714 resolution->mimetype = NULL;
1716 if (resolution->urischeme) {
1717 free((void *)resolution->urischeme);
1718 resolution->urischeme = NULL;
1720 free((void*)resolution);
1724 static void __ps_free_capability(capability_x *capability)
1726 if (capability == NULL)
1728 if (capability->operationid) {
1729 free((void *)capability->operationid);
1730 capability->operationid = NULL;
1733 if (capability->resolution) {
1734 resolution_x *resolution = capability->resolution;
1735 resolution_x *tmp = NULL;
1736 while(resolution != NULL) {
1737 tmp = resolution->next;
1738 __ps_free_resolution(resolution);
1742 free((void*)capability);
1746 static void __ps_free_allowed(allowed_x *allowed)
1748 if (allowed == NULL)
1750 if (allowed->name) {
1751 free((void *)allowed->name);
1752 allowed->name = NULL;
1754 if (allowed->text) {
1755 free((void *)allowed->text);
1756 allowed->text = NULL;
1758 free((void*)allowed);
1762 static void __ps_free_request(request_x *request)
1764 if (request == NULL)
1766 if (request->text) {
1767 free((void *)request->text);
1768 request->text = NULL;
1770 free((void*)request);
1774 static void __ps_free_datacontrol(datacontrol_x *datacontrol)
1776 if (datacontrol == NULL)
1778 if (datacontrol->providerid) {
1779 free((void *)datacontrol->providerid);
1780 datacontrol->providerid = NULL;
1783 if (datacontrol->capability) {
1784 capability_x *capability = datacontrol->capability;
1785 capability_x *tmp = NULL;
1786 while(capability != NULL) {
1787 tmp = capability->next;
1788 __ps_free_capability(capability);
1792 free((void*)datacontrol);
1796 static void __ps_free_launchconditions(launchconditions_x *launchconditions)
1798 if (launchconditions == NULL)
1800 if (launchconditions->text) {
1801 free((void *)launchconditions->text);
1802 launchconditions->text = NULL;
1805 if (launchconditions->condition) {
1806 condition_x *condition = launchconditions->condition;
1807 condition_x *tmp = NULL;
1808 while(condition != NULL) {
1809 tmp = condition->next;
1810 __ps_free_condition(condition);
1814 free((void*)launchconditions);
1815 launchconditions = NULL;
1818 static void __ps_free_appcontrol(appcontrol_x *appcontrol)
1820 if (appcontrol == NULL)
1822 if (appcontrol->text) {
1823 free((void *)appcontrol->text);
1824 appcontrol->text = NULL;
1827 if (appcontrol->operation) {
1828 operation_x *operation = appcontrol->operation;
1829 operation_x *tmp = NULL;
1830 while(operation != NULL) {
1831 tmp = operation->next;
1832 __ps_free_operation(operation);
1837 if (appcontrol->uri) {
1838 uri_x *uri = appcontrol->uri;
1840 while(uri != NULL) {
1847 if (appcontrol->mime) {
1848 mime_x *mime = appcontrol->mime;
1850 while(mime != NULL) {
1852 __ps_free_mime(mime);
1857 if (appcontrol->subapp) {
1858 subapp_x *subapp = appcontrol->subapp;
1859 subapp_x *tmp = NULL;
1860 while(subapp != NULL) {
1862 __ps_free_subapp(subapp);
1866 free((void*)appcontrol);
1870 static void __ps_free_appsvc(appsvc_x *appsvc)
1875 free((void *)appsvc->text);
1876 appsvc->text = NULL;
1879 if (appsvc->operation) {
1880 operation_x *operation = appsvc->operation;
1881 operation_x *tmp = NULL;
1882 while(operation != NULL) {
1883 tmp = operation->next;
1884 __ps_free_operation(operation);
1890 uri_x *uri = appsvc->uri;
1892 while(uri != NULL) {
1900 mime_x *mime = appsvc->mime;
1902 while(mime != NULL) {
1904 __ps_free_mime(mime);
1909 if (appsvc->subapp) {
1910 subapp_x *subapp = appsvc->subapp;
1911 subapp_x *tmp = NULL;
1912 while(subapp != NULL) {
1914 __ps_free_subapp(subapp);
1918 free((void*)appsvc);
1922 static void __ps_free_deviceprofile(deviceprofile_x *deviceprofile)
1927 static void __ps_free_define(define_x *define)
1932 free((void *)define->path);
1933 define->path = NULL;
1936 if (define->request) {
1937 request_x *request = define->request;
1938 request_x *tmp = NULL;
1939 while(request != NULL) {
1940 tmp = request->next;
1941 __ps_free_request(request);
1946 if (define->allowed) {
1947 allowed_x *allowed = define->allowed;
1948 allowed_x *tmp = NULL;
1949 while(allowed != NULL) {
1950 tmp = allowed->next;
1951 __ps_free_allowed(allowed);
1955 free((void*)define);
1959 static void __ps_free_datashare(datashare_x *datashare)
1961 if (datashare == NULL)
1964 if (datashare->define) {
1965 define_x *define = datashare->define;
1966 define_x *tmp = NULL;
1967 while(define != NULL) {
1969 __ps_free_define(define);
1974 if (datashare->request) {
1975 request_x *request = datashare->request;
1976 request_x *tmp = NULL;
1977 while(request != NULL) {
1978 tmp = request->next;
1979 __ps_free_request(request);
1983 free((void*)datashare);
1987 static void __ps_free_label(label_x *label)
1992 free((void *)label->name);
1996 free((void *)label->text);
2000 free((void *)label->lang);
2007 static void __ps_free_author(author_x *author)
2011 if (author->email) {
2012 free((void *)author->email);
2013 author->email = NULL;
2016 free((void *)author->text);
2017 author->text = NULL;
2020 free((void *)author->href);
2021 author->href = NULL;
2024 free((void *)author->lang);
2025 author->lang = NULL;
2027 free((void*)author);
2031 static void __ps_free_description(description_x *description)
2033 if (description == NULL)
2035 if (description->name) {
2036 free((void *)description->name);
2037 description->name = NULL;
2039 if (description->text) {
2040 free((void *)description->text);
2041 description->text = NULL;
2043 if (description->lang) {
2044 free((void *)description->lang);
2045 description->lang = NULL;
2047 free((void*)description);
2051 static void __ps_free_license(license_x *license)
2053 if (license == NULL)
2055 if (license->text) {
2056 free((void *)license->text);
2057 license->text = NULL;
2059 if (license->lang) {
2060 free((void *)license->lang);
2061 license->lang = NULL;
2063 free((void*)license);
2067 static void __ps_free_uiapplication(uiapplication_x *uiapplication)
2069 if (uiapplication == NULL)
2071 if (uiapplication->exec) {
2072 free((void *)uiapplication->exec);
2073 uiapplication->exec = NULL;
2075 if (uiapplication->appid) {
2076 free((void *)uiapplication->appid);
2077 uiapplication->appid = NULL;
2079 if (uiapplication->nodisplay) {
2080 free((void *)uiapplication->nodisplay);
2081 uiapplication->nodisplay = NULL;
2083 if (uiapplication->multiple) {
2084 free((void *)uiapplication->multiple);
2085 uiapplication->multiple = NULL;
2087 if (uiapplication->type) {
2088 free((void *)uiapplication->type);
2089 uiapplication->type = NULL;
2091 if (uiapplication->categories) {
2092 free((void *)uiapplication->categories);
2093 uiapplication->categories = NULL;
2095 if (uiapplication->extraid) {
2096 free((void *)uiapplication->extraid);
2097 uiapplication->extraid = NULL;
2099 if (uiapplication->taskmanage) {
2100 free((void *)uiapplication->taskmanage);
2101 uiapplication->taskmanage = NULL;
2103 if (uiapplication->enabled) {
2104 free((void *)uiapplication->enabled);
2105 uiapplication->enabled = NULL;
2107 if (uiapplication->hwacceleration) {
2108 free((void *)uiapplication->hwacceleration);
2109 uiapplication->hwacceleration = NULL;
2111 if (uiapplication->screenreader) {
2112 free((void *)uiapplication->screenreader);
2113 uiapplication->screenreader = NULL;
2115 if (uiapplication->mainapp) {
2116 free((void *)uiapplication->mainapp);
2117 uiapplication->mainapp = NULL;
2119 if (uiapplication->recentimage) {
2120 free((void *)uiapplication->recentimage);
2121 uiapplication->recentimage = NULL;
2123 if (uiapplication->package) {
2124 free((void *)uiapplication->package);
2125 uiapplication->package = NULL;
2127 if (uiapplication->launchcondition) {
2128 free((void *)uiapplication->launchcondition);
2129 uiapplication->launchcondition = NULL;
2132 if (uiapplication->label) {
2133 label_x *label = uiapplication->label;
2134 label_x *tmp = NULL;
2135 while(label != NULL) {
2137 __ps_free_label(label);
2142 if (uiapplication->icon) {
2143 icon_x *icon = uiapplication->icon;
2145 while(icon != NULL) {
2147 __ps_free_icon(icon);
2152 if (uiapplication->image) {
2153 image_x *image = uiapplication->image;
2154 image_x *tmp = NULL;
2155 while(image != NULL) {
2157 __ps_free_image(image);
2162 if (uiapplication->appcontrol) {
2163 appcontrol_x *appcontrol = uiapplication->appcontrol;
2164 appcontrol_x *tmp = NULL;
2165 while(appcontrol != NULL) {
2166 tmp = appcontrol->next;
2167 __ps_free_appcontrol(appcontrol);
2171 /*Free LaunchConditions*/
2172 if (uiapplication->launchconditions) {
2173 launchconditions_x *launchconditions = uiapplication->launchconditions;
2174 launchconditions_x *tmp = NULL;
2175 while(launchconditions != NULL) {
2176 tmp = launchconditions->next;
2177 __ps_free_launchconditions(launchconditions);
2178 launchconditions = tmp;
2181 /*Free Notification*/
2182 if (uiapplication->notification) {
2183 notification_x *notification = uiapplication->notification;
2184 notification_x *tmp = NULL;
2185 while(notification != NULL) {
2186 tmp = notification->next;
2187 __ps_free_notification(notification);
2192 if (uiapplication->datashare) {
2193 datashare_x *datashare = uiapplication->datashare;
2194 datashare_x *tmp = NULL;
2195 while(datashare != NULL) {
2196 tmp = datashare->next;
2197 __ps_free_datashare(datashare);
2202 if (uiapplication->appsvc) {
2203 appsvc_x *appsvc = uiapplication->appsvc;
2204 appsvc_x *tmp = NULL;
2205 while(appsvc != NULL) {
2207 __ps_free_appsvc(appsvc);
2212 if (uiapplication->category) {
2213 category_x *category = uiapplication->category;
2214 category_x *tmp = NULL;
2215 while(category != NULL) {
2216 tmp = category->next;
2217 __ps_free_category(category);
2222 if (uiapplication->metadata) {
2223 metadata_x *metadata = uiapplication->metadata;
2224 metadata_x *tmp = NULL;
2225 while(metadata != NULL) {
2226 tmp = metadata->next;
2227 __ps_free_metadata(metadata);
2232 if (uiapplication->permission) {
2233 permission_x *permission = uiapplication->permission;
2234 permission_x *tmp = NULL;
2235 while(permission != NULL) {
2236 tmp = permission->next;
2237 __ps_free_permission(permission);
2241 /* _PRODUCT_LAUNCHING_ENHANCED_ START */
2242 if (uiapplication->indicatordisplay) {
2243 free((void *)uiapplication->indicatordisplay);
2244 uiapplication->indicatordisplay = NULL;
2246 if (uiapplication->portraitimg) {
2247 free((void *)uiapplication->portraitimg);
2248 uiapplication->portraitimg = NULL;
2250 if (uiapplication->landscapeimg) {
2251 free((void *)uiapplication->landscapeimg);
2252 uiapplication->landscapeimg = NULL;
2254 /* _PRODUCT_LAUNCHING_ENHANCED_ END */
2255 if (uiapplication->guestmode_visibility) {
2256 free((void *)uiapplication->guestmode_visibility);
2257 uiapplication->guestmode_visibility = NULL;
2259 if (uiapplication->app_component) {
2260 free((void *)uiapplication->app_component);
2261 uiapplication->app_component = NULL;
2263 if (uiapplication->permission_type) {
2264 free((void *)uiapplication->permission_type);
2265 uiapplication->permission_type = NULL;
2267 if (uiapplication->component_type) {
2268 free((void *)uiapplication->component_type);
2269 uiapplication->component_type = NULL;
2271 if (uiapplication->preload) {
2272 free((void *)uiapplication->preload);
2273 uiapplication->preload = NULL;
2275 if (uiapplication->submode) {
2276 free((void *)uiapplication->submode);
2277 uiapplication->submode = NULL;
2279 if (uiapplication->submode_mainid) {
2280 free((void *)uiapplication->submode_mainid);
2281 uiapplication->submode_mainid = NULL;
2284 free((void*)uiapplication);
2285 uiapplication = NULL;
2288 static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication)
2290 if (serviceapplication == NULL)
2292 if (serviceapplication->exec) {
2293 free((void *)serviceapplication->exec);
2294 serviceapplication->exec = NULL;
2296 if (serviceapplication->appid) {
2297 free((void *)serviceapplication->appid);
2298 serviceapplication->appid = NULL;
2300 if (serviceapplication->onboot) {
2301 free((void *)serviceapplication->onboot);
2302 serviceapplication->onboot = NULL;
2304 if (serviceapplication->autorestart) {
2305 free((void *)serviceapplication->autorestart);
2306 serviceapplication->autorestart = NULL;
2308 if (serviceapplication->type) {
2309 free((void *)serviceapplication->type);
2310 serviceapplication->type = NULL;
2312 if (serviceapplication->enabled) {
2313 free((void *)serviceapplication->enabled);
2314 serviceapplication->enabled = NULL;
2316 if (serviceapplication->package) {
2317 free((void *)serviceapplication->package);
2318 serviceapplication->package = NULL;
2320 if (serviceapplication->permission_type) {
2321 free((void *)serviceapplication->permission_type);
2322 serviceapplication->permission_type = NULL;
2325 if (serviceapplication->label) {
2326 label_x *label = serviceapplication->label;
2327 label_x *tmp = NULL;
2328 while(label != NULL) {
2330 __ps_free_label(label);
2335 if (serviceapplication->icon) {
2336 icon_x *icon = serviceapplication->icon;
2338 while(icon != NULL) {
2340 __ps_free_icon(icon);
2345 if (serviceapplication->appcontrol) {
2346 appcontrol_x *appcontrol = serviceapplication->appcontrol;
2347 appcontrol_x *tmp = NULL;
2348 while(appcontrol != NULL) {
2349 tmp = appcontrol->next;
2350 __ps_free_appcontrol(appcontrol);
2354 /*Free DataControl*/
2355 if (serviceapplication->datacontrol) {
2356 datacontrol_x *datacontrol = serviceapplication->datacontrol;
2357 datacontrol_x *tmp = NULL;
2358 while(datacontrol != NULL) {
2359 tmp = datacontrol->next;
2360 __ps_free_datacontrol(datacontrol);
2364 /*Free LaunchConditions*/
2365 if (serviceapplication->launchconditions) {
2366 launchconditions_x *launchconditions = serviceapplication->launchconditions;
2367 launchconditions_x *tmp = NULL;
2368 while(launchconditions != NULL) {
2369 tmp = launchconditions->next;
2370 __ps_free_launchconditions(launchconditions);
2371 launchconditions = tmp;
2374 /*Free Notification*/
2375 if (serviceapplication->notification) {
2376 notification_x *notification = serviceapplication->notification;
2377 notification_x *tmp = NULL;
2378 while(notification != NULL) {
2379 tmp = notification->next;
2380 __ps_free_notification(notification);
2385 if (serviceapplication->datashare) {
2386 datashare_x *datashare = serviceapplication->datashare;
2387 datashare_x *tmp = NULL;
2388 while(datashare != NULL) {
2389 tmp = datashare->next;
2390 __ps_free_datashare(datashare);
2395 if (serviceapplication->appsvc) {
2396 appsvc_x *appsvc = serviceapplication->appsvc;
2397 appsvc_x *tmp = NULL;
2398 while(appsvc != NULL) {
2400 __ps_free_appsvc(appsvc);
2405 if (serviceapplication->category) {
2406 category_x *category = serviceapplication->category;
2407 category_x *tmp = NULL;
2408 while(category != NULL) {
2409 tmp = category->next;
2410 __ps_free_category(category);
2415 if (serviceapplication->metadata) {
2416 metadata_x *metadata = serviceapplication->metadata;
2417 metadata_x *tmp = NULL;
2418 while(metadata != NULL) {
2419 tmp = metadata->next;
2420 __ps_free_metadata(metadata);
2425 if (serviceapplication->permission) {
2426 permission_x *permission = serviceapplication->permission;
2427 permission_x *tmp = NULL;
2428 while(permission != NULL) {
2429 tmp = permission->next;
2430 __ps_free_permission(permission);
2434 free((void*)serviceapplication);
2435 serviceapplication = NULL;
2438 static void __ps_free_font(font_x *font)
2443 free((void *)font->name);
2447 free((void *)font->text);
2454 static void __ps_free_theme(theme_x *theme)
2459 free((void *)theme->name);
2463 free((void *)theme->text);
2470 static void __ps_free_daemon(daemon_x *daemon)
2475 free((void *)daemon->name);
2476 daemon->name = NULL;
2479 free((void *)daemon->text);
2480 daemon->text = NULL;
2482 free((void*)daemon);
2486 static void __ps_free_ime(ime_x *ime)
2491 free((void *)ime->name);
2495 free((void *)ime->text);
2502 int __ps_process_tag_parser(manifest_x *mfx, const char *filename, ACTION_TYPE action)
2504 xmlTextReaderPtr reader;
2508 void *lib_handle = NULL;
2509 char tag[PKG_STRING_LEN_MAX] = { 0 };
2511 fp = fopen(TAG_PARSER_LIST, "r");
2512 retvm_if(fp == NULL, PMINFO_R_ERROR, "no preload list");
2514 while (fgets(tag, sizeof(tag), fp) != NULL) {
2517 lib_handle = __open_lib_handle(tag);
2518 if (lib_handle == NULL)
2521 ret = __parser_send_tag(lib_handle, action, PLUGIN_PRE_PROCESS, mfx->package);
2522 _LOGD("PLUGIN_PRE_PROCESS[%s, %s] ACTION_TYPE[%d] result[%d]\n", mfx->package, tag, action, ret);
2524 docPtr = xmlReadFile(filename, NULL, 0);
2525 reader = xmlReaderWalker(docPtr);
2526 if (reader != NULL) {
2527 ret = xmlTextReaderRead(reader);
2529 __processTag(lib_handle, reader, action, tag, mfx->package);
2530 ret = xmlTextReaderRead(reader);
2532 xmlFreeTextReader(reader);
2535 _LOGD("%s : failed to parse", filename);
2538 _LOGD("Unable to open %s", filename);
2541 ret = __parser_send_tag(lib_handle, action, PLUGIN_POST_PROCESS, mfx->package);
2542 _LOGD("PLUGIN_POST_PROCESS[%s, %s] ACTION_TYPE[%d] result[%d]\n", mfx->package, tag, action, ret);
2544 __close_lib_handle(lib_handle);
2546 memset(tag, 0x00, sizeof(tag));
2555 int __ps_process_metadata_parser(manifest_x *mfx, ACTION_TYPE action)
2559 char md_key[PKG_STRING_LEN_MAX] = { 0 };
2561 fp = fopen(METADATA_PARSER_LIST, "r");
2563 _LOGD("no preload list\n");
2567 while (fgets(md_key, sizeof(md_key), fp) != NULL) {
2569 ret = __run_metadata_parser_prestep(mfx, md_key, action);
2571 memset(md_key, 0x00, sizeof(md_key));
2580 int __ps_process_category_parser(manifest_x *mfx, ACTION_TYPE action)
2584 char category_key[PKG_STRING_LEN_MAX] = { 0 };
2586 fp = fopen(CATEGORY_PARSER_LIST, "r");
2588 _LOGD("no category parser list\n");
2592 while (fgets(category_key, sizeof(category_key), fp) != NULL) {
2593 __str_trim(category_key);
2594 ret = __run_category_parser_prestep(mfx, category_key, action);
2596 memset(category_key, 0x00, sizeof(category_key));
2605 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed)
2607 xmlTextReaderRead(reader);
2608 if (xmlTextReaderValue(reader))
2609 allowed->text = ASCII(xmlTextReaderValue(reader));
2613 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation)
2615 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2616 operation->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2617 /* Text does not exist. Only attribute exists
2618 xmlTextReaderRead(reader);
2619 if (xmlTextReaderValue(reader))
2620 operation->text = ASCII(xmlTextReaderValue(reader));
2625 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri)
2627 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2628 uri->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2629 /* Text does not exist. Only attribute exists
2630 xmlTextReaderRead(reader);
2631 if (xmlTextReaderValue(reader))
2632 uri->text = ASCII(xmlTextReaderValue(reader));
2637 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime)
2639 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2640 mime->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2641 /* Text does not exist. Only attribute exists
2642 xmlTextReaderRead(reader);
2643 if (xmlTextReaderValue(reader))
2644 mime->text = ASCII(xmlTextReaderValue(reader));
2649 static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp)
2651 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2652 subapp->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2653 /* Text does not exist. Only attribute exists
2654 xmlTextReaderRead(reader);
2655 if (xmlTextReaderValue(reader))
2656 mime->text = ASCII(xmlTextReaderValue(reader));
2661 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition)
2663 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2664 condition->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2665 xmlTextReaderRead(reader);
2666 if (xmlTextReaderValue(reader))
2667 condition->text = ASCII(xmlTextReaderValue(reader));
2671 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notification)
2673 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2674 notification->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2675 xmlTextReaderRead(reader);
2676 if (xmlTextReaderValue(reader))
2677 notification->text = ASCII(xmlTextReaderValue(reader));
2681 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category)
2683 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2684 category->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2688 static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege)
2690 xmlTextReaderRead(reader);
2691 if (xmlTextReaderValue(reader)) {
2692 privilege->text = ASCII(xmlTextReaderValue(reader));
2697 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata)
2699 if (xmlTextReaderGetAttribute(reader, XMLCHAR("key")))
2700 metadata->key = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("key")));
2701 if (xmlTextReaderGetAttribute(reader, XMLCHAR("value")))
2702 metadata->value = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("value")));
2706 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission)
2708 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
2709 permission->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
2711 xmlTextReaderRead(reader);
2712 if (xmlTextReaderValue(reader))
2713 permission->value = ASCII(xmlTextReaderValue(reader));
2717 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility)
2719 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2720 compatibility->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2721 xmlTextReaderRead(reader);
2722 if (xmlTextReaderValue(reader))
2723 compatibility->text = ASCII(xmlTextReaderValue(reader));
2727 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution)
2729 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")))
2730 resolution->mimetype = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")));
2731 if (xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")))
2732 resolution->urischeme = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")));
2736 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request)
2738 xmlTextReaderRead(reader);
2739 if (xmlTextReaderValue(reader))
2740 request->text = ASCII(xmlTextReaderValue(reader));
2744 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define)
2746 const xmlChar *node;
2749 allowed_x *tmp1 = NULL;
2750 request_x *tmp2 = NULL;
2752 if (xmlTextReaderGetAttribute(reader, XMLCHAR("path")))
2753 define->path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("path")));
2755 depth = xmlTextReaderDepth(reader);
2756 while ((ret = __next_child_element(reader, depth))) {
2757 node = xmlTextReaderConstName(reader);
2759 _LOGD("xmlTextReaderConstName value is NULL\n");
2763 if (!strcmp(ASCII(node), "allowed")) {
2764 allowed_x *allowed= malloc(sizeof(allowed_x));
2765 if (allowed == NULL) {
2766 _LOGD("Malloc Failed\n");
2769 memset(allowed, '\0', sizeof(allowed_x));
2770 LISTADD(define->allowed, allowed);
2771 ret = __ps_process_allowed(reader, allowed);
2772 } else if (!strcmp(ASCII(node), "request")) {
2773 request_x *request = malloc(sizeof(request_x));
2774 if (request == NULL) {
2775 _LOGD("Malloc Failed\n");
2778 memset(request, '\0', sizeof(request_x));
2779 LISTADD(define->request, request);
2780 ret = __ps_process_request(reader, request);
2784 _LOGD("Processing define failed\n");
2788 if (define->allowed) {
2789 LISTHEAD(define->allowed, tmp1);
2790 define->allowed = tmp1;
2792 if (define->request) {
2793 LISTHEAD(define->request, tmp2);
2794 define->request = tmp2;
2799 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol)
2801 const xmlChar *node;
2804 operation_x *tmp1 = NULL;
2806 mime_x *tmp3 = NULL;
2807 subapp_x *tmp4 = NULL;
2809 depth = xmlTextReaderDepth(reader);
2810 while ((ret = __next_child_element(reader, depth))) {
2811 node = xmlTextReaderConstName(reader);
2813 _LOGD("xmlTextReaderConstName value is NULL\n");
2817 if (!strcmp(ASCII(node), "operation")) {
2818 operation_x *operation = malloc(sizeof(operation_x));
2819 if (operation == NULL) {
2820 _LOGD("Malloc Failed\n");
2823 memset(operation, '\0', sizeof(operation_x));
2824 LISTADD(appcontrol->operation, operation);
2825 ret = __ps_process_operation(reader, operation);
2826 _LOGD("operation processing\n");
2827 } else if (!strcmp(ASCII(node), "uri")) {
2828 uri_x *uri= malloc(sizeof(uri_x));
2830 _LOGD("Malloc Failed\n");
2833 memset(uri, '\0', sizeof(uri_x));
2834 LISTADD(appcontrol->uri, uri);
2835 ret = __ps_process_uri(reader, uri);
2836 _LOGD("uri processing\n");
2837 } else if (!strcmp(ASCII(node), "mime")) {
2838 mime_x *mime = malloc(sizeof(mime_x));
2840 _LOGD("Malloc Failed\n");
2843 memset(mime, '\0', sizeof(mime_x));
2844 LISTADD(appcontrol->mime, mime);
2845 ret = __ps_process_mime(reader, mime);
2846 _LOGD("mime processing\n");
2847 } else if (!strcmp(ASCII(node), "subapp")) {
2848 subapp_x *subapp = malloc(sizeof(subapp_x));
2849 if (subapp == NULL) {
2850 _LOGD("Malloc Failed\n");
2853 memset(subapp, '\0', sizeof(subapp_x));
2854 LISTADD(appcontrol->subapp, subapp);
2855 ret = __ps_process_subapp(reader, subapp);
2856 _LOGD("subapp processing\n");
2860 _LOGD("Processing appcontrol failed\n");
2864 if (appcontrol->operation) {
2865 LISTHEAD(appcontrol->operation, tmp1);
2866 appcontrol->operation = tmp1;
2868 if (appcontrol->uri) {
2869 LISTHEAD(appcontrol->uri, tmp2);
2870 appcontrol->uri = tmp2;
2872 if (appcontrol->mime) {
2873 LISTHEAD(appcontrol->mime, tmp3);
2874 appcontrol->mime = tmp3;
2876 if (appcontrol->subapp) {
2877 LISTHEAD(appcontrol->subapp, tmp4);
2878 appcontrol->subapp = tmp4;
2881 xmlTextReaderRead(reader);
2882 if (xmlTextReaderValue(reader))
2883 appcontrol->text = ASCII(xmlTextReaderValue(reader));
2888 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc)
2890 const xmlChar *node;
2893 operation_x *tmp1 = NULL;
2895 mime_x *tmp3 = NULL;
2896 subapp_x *tmp4 = NULL;
2898 depth = xmlTextReaderDepth(reader);
2899 while ((ret = __next_child_element(reader, depth))) {
2900 node = xmlTextReaderConstName(reader);
2902 _LOGD("xmlTextReaderConstName value is NULL\n");
2906 if (!strcmp(ASCII(node), "operation")) {
2907 operation_x *operation = malloc(sizeof(operation_x));
2908 if (operation == NULL) {
2909 _LOGD("Malloc Failed\n");
2912 memset(operation, '\0', sizeof(operation_x));
2913 LISTADD(appsvc->operation, operation);
2914 ret = __ps_process_operation(reader, operation);
2915 _LOGD("operation processing\n");
2916 } else if (!strcmp(ASCII(node), "uri")) {
2917 uri_x *uri= malloc(sizeof(uri_x));
2919 _LOGD("Malloc Failed\n");
2922 memset(uri, '\0', sizeof(uri_x));
2923 LISTADD(appsvc->uri, uri);
2924 ret = __ps_process_uri(reader, uri);
2925 _LOGD("uri processing\n");
2926 } else if (!strcmp(ASCII(node), "mime")) {
2927 mime_x *mime = malloc(sizeof(mime_x));
2929 _LOGD("Malloc Failed\n");
2932 memset(mime, '\0', sizeof(mime_x));
2933 LISTADD(appsvc->mime, mime);
2934 ret = __ps_process_mime(reader, mime);
2935 _LOGD("mime processing\n");
2936 } else if (!strcmp(ASCII(node), "subapp")) {
2937 subapp_x *subapp = malloc(sizeof(subapp_x));
2938 if (subapp == NULL) {
2939 _LOGD("Malloc Failed\n");
2942 memset(subapp, '\0', sizeof(subapp_x));
2943 LISTADD(appsvc->subapp, subapp);
2944 ret = __ps_process_subapp(reader, subapp);
2945 _LOGD("subapp processing\n");
2949 _LOGD("Processing appsvc failed\n");
2953 if (appsvc->operation) {
2954 LISTHEAD(appsvc->operation, tmp1);
2955 appsvc->operation = tmp1;
2958 LISTHEAD(appsvc->uri, tmp2);
2962 LISTHEAD(appsvc->mime, tmp3);
2963 appsvc->mime = tmp3;
2965 if (appsvc->subapp) {
2966 LISTHEAD(appsvc->subapp, tmp4);
2967 appsvc->subapp = tmp4;
2970 xmlTextReaderRead(reader);
2971 if (xmlTextReaderValue(reader))
2972 appsvc->text = ASCII(xmlTextReaderValue(reader));
2978 static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privileges)
2980 const xmlChar *node;
2983 privilege_x *tmp1 = NULL;
2985 depth = xmlTextReaderDepth(reader);
2986 while ((ret = __next_child_element(reader, depth))) {
2987 node = xmlTextReaderConstName(reader);
2989 _LOGD("xmlTextReaderConstName value is NULL\n");
2993 if (strcmp(ASCII(node), "privilege") == 0) {
2994 privilege_x *privilege = malloc(sizeof(privilege_x));
2995 if (privilege == NULL) {
2996 _LOGD("Malloc Failed\n");
2999 memset(privilege, '\0', sizeof(privilege_x));
3000 LISTADD(privileges->privilege, privilege);
3001 ret = __ps_process_privilege(reader, privilege);
3005 _LOGD("Processing privileges failed\n");
3009 if (privileges->privilege) {
3010 LISTHEAD(privileges->privilege, tmp1);
3011 privileges->privilege = tmp1;
3016 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions)
3018 const xmlChar *node;
3021 condition_x *tmp1 = NULL;
3023 depth = xmlTextReaderDepth(reader);
3024 while ((ret = __next_child_element(reader, depth))) {
3025 node = xmlTextReaderConstName(reader);
3027 _LOGD("xmlTextReaderConstName value is NULL\n");
3031 if (strcmp(ASCII(node), "condition") == 0) {
3032 condition_x *condition = malloc(sizeof(condition_x));
3033 if (condition == NULL) {
3034 _LOGD("Malloc Failed\n");
3037 memset(condition, '\0', sizeof(condition_x));
3038 LISTADD(launchconditions->condition, condition);
3039 ret = __ps_process_condition(reader, condition);
3043 _LOGD("Processing launchconditions failed\n");
3047 if (launchconditions->condition) {
3048 LISTHEAD(launchconditions->condition, tmp1);
3049 launchconditions->condition = tmp1;
3052 xmlTextReaderRead(reader);
3053 if (xmlTextReaderValue(reader))
3054 launchconditions->text = ASCII(xmlTextReaderValue(reader));
3059 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare)
3061 const xmlChar *node;
3064 define_x *tmp1 = NULL;
3065 request_x *tmp2 = NULL;
3066 depth = xmlTextReaderDepth(reader);
3067 while ((ret = __next_child_element(reader, depth))) {
3068 node = xmlTextReaderConstName(reader);
3070 _LOGD("xmlTextReaderConstName value is NULL\n");
3074 if (!strcmp(ASCII(node), "define")) {
3075 define_x *define= malloc(sizeof(define_x));
3076 if (define == NULL) {
3077 _LOGD("Malloc Failed\n");
3080 memset(define, '\0', sizeof(define_x));
3081 LISTADD(datashare->define, define);
3082 ret = __ps_process_define(reader, define);
3083 } else if (!strcmp(ASCII(node), "request")) {
3084 request_x *request= malloc(sizeof(request_x));
3085 if (request == NULL) {
3086 _LOGD("Malloc Failed\n");
3089 memset(request, '\0', sizeof(request_x));
3090 LISTADD(datashare->request, request);
3091 ret = __ps_process_request(reader, request);
3095 _LOGD("Processing data-share failed\n");
3099 if (datashare->define) {
3100 LISTHEAD(datashare->define, tmp1);
3101 datashare->define = tmp1;
3103 if (datashare->request) {
3104 LISTHEAD(datashare->request, tmp2);
3105 datashare->request = tmp2;
3111 __get_icon_with_path(const char* icon)
3116 if (index(icon, '/') == NULL) {
3118 char* icon_with_path = NULL;
3124 /* "db/setting/theme" is not exist */
3126 theme = vconf_get_str("db/setting/theme");
3128 theme = strdup("default");
3134 theme = strdup("default");
3137 len = (0x01 << 7) + strlen(icon) + strlen(package) + strlen(theme);
3138 icon_with_path = malloc(len);
3139 if(icon_with_path == NULL) {
3140 _LOGD("(icon_with_path == NULL) return\n");
3145 memset(icon_with_path, 0, len);
3147 snprintf(icon_with_path, len, "/opt/share/icons/%s/small/%s", theme, icon);
3149 if (access(icon_with_path, R_OK) == 0) break;
3150 snprintf(icon_with_path, len, "/usr/share/icons/%s/small/%s", theme, icon);
3151 if (access(icon_with_path, R_OK) == 0) break;
3152 _LOGD("cannot find icon %s", icon_with_path);
3153 snprintf(icon_with_path, len,"/opt/share/icons/default/small/%s", icon);
3154 if (access(icon_with_path, R_OK) == 0) break;
3155 snprintf(icon_with_path, len, "/usr/share/icons/default/small/%s", icon);
3156 if (access(icon_with_path, R_OK) == 0) break;
3158 /* icon path is going to be moved intto the app directory */
3159 _LOGE("icon file must be moved to %s", icon_with_path);
3160 snprintf(icon_with_path, len, "/opt/apps/%s/res/icons/%s/small/%s", package, theme, icon);
3161 if (access(icon_with_path, R_OK) == 0) break;
3162 snprintf(icon_with_path, len, "/usr/apps/%s/res/icons/%s/small/%s", package, theme, icon);
3163 if (access(icon_with_path, R_OK) == 0) break;
3164 _LOGD("cannot find icon %s", icon_with_path);
3165 snprintf(icon_with_path, len, "/opt/apps/%s/res/icons/default/small/%s", package, icon);
3166 if (access(icon_with_path, R_OK) == 0) break;
3167 snprintf(icon_with_path, len, "/usr/apps/%s/res/icons/default/small/%s", package, icon);
3168 if (access(icon_with_path, R_OK) == 0) break;
3169 snprintf(icon_with_path, len, "/usr/ug/res/images/%s/%s", package, icon);
3170 if (access(icon_with_path, R_OK) == 0) break;
3175 _LOGD("Icon path : %s ---> %s", icon, icon_with_path);
3177 return icon_with_path;
3179 char* confirmed_icon = NULL;
3181 confirmed_icon = strdup(icon);
3182 if (!confirmed_icon)
3184 return confirmed_icon;
3188 static void __ps_process_tag(manifest_x * mfx, char *const tagv[])
3191 char delims[] = "=";
3192 char *ret_result = NULL;
3198 for (tag = strdup(tagv[0]); tag != NULL; ) {
3199 ret_result = strtok(tag, delims);
3201 /*check tag : preload */
3202 if (strcmp(ret_result, "preload") == 0) {
3203 ret_result = strtok(NULL, delims);
3204 if (strcmp(ret_result, "true") == 0) {
3205 free((void *)mfx->preload);
3206 mfx->preload = strdup("true");
3207 } else if (strcmp(ret_result, "false") == 0) {
3208 free((void *)mfx->preload);
3209 mfx->preload = strdup("false");
3211 /*check tag : removable*/
3212 } else if (strcmp(ret_result, "removable") == 0) {
3213 ret_result = strtok(NULL, delims);
3214 if (strcmp(ret_result, "true") == 0){
3215 free((void *)mfx->removable);
3216 mfx->removable = strdup("true");
3217 } else if (strcmp(ret_result, "false") == 0) {
3218 free((void *)mfx->removable);
3219 mfx->removable = strdup("false");
3221 /*check tag : not matched*/
3223 _LOGD("tag process [%s]is not defined\n", ret_result);
3227 /*check next value*/
3228 if (tagv[++i] != NULL)
3229 tag = strdup(tagv[i]);
3231 _LOGD("tag process success...\n");
3237 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon)
3239 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
3240 icon->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
3241 if (xmlTextReaderConstXmlLang(reader)) {
3242 icon->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3243 if (icon->lang == NULL)
3244 icon->lang = strdup(DEFAULT_LOCALE);
3246 icon->lang = strdup(DEFAULT_LOCALE);
3248 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
3249 icon->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
3250 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
3251 icon->size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
3252 if (xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")))
3253 icon->resolution = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")));
3254 xmlTextReaderRead(reader);
3255 if (xmlTextReaderValue(reader)) {
3256 const char *text = ASCII(xmlTextReaderValue(reader));
3258 icon->text = (const char *)__get_icon_with_path(text);
3266 static int __ps_process_image(xmlTextReaderPtr reader, image_x *image)
3268 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
3269 image->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
3270 if (xmlTextReaderConstXmlLang(reader)) {
3271 image->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3272 if (image->lang == NULL)
3273 image->lang = strdup(DEFAULT_LOCALE);
3275 image->lang = strdup(DEFAULT_LOCALE);
3277 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
3278 image->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
3279 xmlTextReaderRead(reader);
3280 if (xmlTextReaderValue(reader))
3281 image->text = ASCII(xmlTextReaderValue(reader));
3286 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label)
3288 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
3289 label->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
3290 if (xmlTextReaderConstXmlLang(reader)) {
3291 label->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3292 if (label->lang == NULL)
3293 label->lang = strdup(DEFAULT_LOCALE);
3295 label->lang = strdup(DEFAULT_LOCALE);
3297 xmlTextReaderRead(reader);
3298 if (xmlTextReaderValue(reader))
3299 label->text = ASCII(xmlTextReaderValue(reader));
3301 /* _LOGD("lable name %s\n", label->name);
3302 _LOGD("lable lang %s\n", label->lang);
3303 _LOGD("lable text %s\n", label->text);
3309 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author)
3311 if (xmlTextReaderGetAttribute(reader, XMLCHAR("email")))
3312 author->email = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("email")));
3313 if (xmlTextReaderGetAttribute(reader, XMLCHAR("href")))
3314 author->href = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("href")));
3315 if (xmlTextReaderConstXmlLang(reader)) {
3316 author->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3317 if (author->lang == NULL)
3318 author->lang = strdup(DEFAULT_LOCALE);
3320 author->lang = strdup(DEFAULT_LOCALE);
3322 xmlTextReaderRead(reader);
3323 if (xmlTextReaderValue(reader)) {
3324 const char *text = ASCII(xmlTextReaderValue(reader));
3325 if (*text == '\n') {
3326 author->text = NULL;
3330 author->text = ASCII(xmlTextReaderValue(reader));
3335 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description)
3337 if (xmlTextReaderConstXmlLang(reader)) {
3338 description->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3339 if (description->lang == NULL)
3340 description->lang = strdup(DEFAULT_LOCALE);
3342 description->lang = strdup(DEFAULT_LOCALE);
3344 xmlTextReaderRead(reader);
3345 if (xmlTextReaderValue(reader)) {
3346 const char *text = ASCII(xmlTextReaderValue(reader));
3347 if (*text == '\n') {
3348 description->text = NULL;
3352 description->text = ASCII(xmlTextReaderValue(reader));
3357 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license)
3359 if (xmlTextReaderConstXmlLang(reader)) {
3360 license->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
3361 if (license->lang == NULL)
3362 license->lang = strdup(DEFAULT_LOCALE);
3364 license->lang = strdup(DEFAULT_LOCALE);
3366 xmlTextReaderRead(reader);
3367 if (xmlTextReaderValue(reader))
3368 license->text = ASCII(xmlTextReaderValue(reader));
3372 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability)
3374 const xmlChar *node;
3377 resolution_x *tmp1 = NULL;
3379 if (xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")))
3380 capability->operationid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")));
3382 depth = xmlTextReaderDepth(reader);
3383 while ((ret = __next_child_element(reader, depth))) {
3384 node = xmlTextReaderConstName(reader);
3386 _LOGD("xmlTextReaderConstName value is NULL\n");
3390 if (!strcmp(ASCII(node), "resolution")) {
3391 resolution_x *resolution = malloc(sizeof(resolution_x));
3392 if (resolution == NULL) {
3393 _LOGD("Malloc Failed\n");
3396 memset(resolution, '\0', sizeof(resolution_x));
3397 LISTADD(capability->resolution, resolution);
3398 ret = __ps_process_resolution(reader, resolution);
3402 _LOGD("Processing capability failed\n");
3407 if (capability->resolution) {
3408 LISTHEAD(capability->resolution, tmp1);
3409 capability->resolution = tmp1;
3415 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol)
3417 const xmlChar *node;
3420 capability_x *tmp1 = NULL;
3422 if (xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")))
3423 datacontrol->providerid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")));
3425 depth = xmlTextReaderDepth(reader);
3426 while ((ret = __next_child_element(reader, depth))) {
3427 node = xmlTextReaderConstName(reader);
3429 _LOGD("xmlTextReaderConstName value is NULL\n");
3433 if (!strcmp(ASCII(node), "capability")) {
3434 capability_x *capability = malloc(sizeof(capability_x));
3435 if (capability == NULL) {
3436 _LOGD("Malloc Failed\n");
3439 memset(capability, '\0', sizeof(capability_x));
3440 LISTADD(datacontrol->capability, capability);
3441 ret = __ps_process_capability(reader, capability);
3445 _LOGD("Processing datacontrol failed\n");
3450 if (datacontrol->capability) {
3451 LISTHEAD(datacontrol->capability, tmp1);
3452 datacontrol->capability = tmp1;
3458 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication)
3460 const xmlChar *node;
3463 char *newappid = NULL;
3464 label_x *tmp1 = NULL;
3465 icon_x *tmp2 = NULL;
3466 appsvc_x *tmp3 = NULL;
3467 appcontrol_x *tmp4 = NULL;
3468 launchconditions_x *tmp5 = NULL;
3469 notification_x *tmp6 = NULL;
3470 datashare_x *tmp7 = NULL;
3471 category_x *tmp8 = NULL;
3472 metadata_x *tmp9 = NULL;
3473 image_x *tmp10 = NULL;
3474 permission_x *tmp11 = NULL;
3476 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
3477 uiapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
3478 if (uiapplication->appid == NULL) {
3479 _LOGD("appid cant be NULL\n");
3483 _LOGD("appid is mandatory\n");
3487 ret = __validate_appid(package, uiapplication->appid, &newappid);
3489 _LOGD("appid is not proper\n");
3493 if (uiapplication->appid)
3494 free((void *)uiapplication->appid);
3495 uiapplication->appid = newappid;
3497 uiapplication->package= strdup(package);
3499 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
3500 uiapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
3501 if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay"))) {
3502 uiapplication->nodisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay")));
3503 if (uiapplication->nodisplay == NULL)
3504 uiapplication->nodisplay = strdup("false");
3506 uiapplication->nodisplay = strdup("false");
3508 if (xmlTextReaderGetAttribute(reader, XMLCHAR("multiple"))) {
3509 uiapplication->multiple = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("multiple")));
3510 if (uiapplication->multiple == NULL)
3511 uiapplication->multiple = strdup("false");
3513 uiapplication->multiple = strdup("false");
3515 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
3516 uiapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
3517 if (xmlTextReaderGetAttribute(reader, XMLCHAR("categories")))
3518 uiapplication->categories = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("categories")));
3519 if (xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")))
3520 uiapplication->extraid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")));
3521 if (xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage"))) {
3522 uiapplication->taskmanage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage")));
3523 if (uiapplication->taskmanage == NULL)
3524 uiapplication->taskmanage = strdup("true");
3526 uiapplication->taskmanage = strdup("true");
3528 if (xmlTextReaderGetAttribute(reader, XMLCHAR("enabled"))) {
3529 uiapplication->enabled = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("enabled")));
3530 if (uiapplication->enabled == NULL)
3531 uiapplication->enabled = strdup("true");
3533 uiapplication->enabled = strdup("true");
3535 if (xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration"))) {
3536 uiapplication->hwacceleration = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration")));
3537 if (uiapplication->hwacceleration == NULL)
3538 uiapplication->hwacceleration = strdup("use-system-setting");
3540 uiapplication->hwacceleration = strdup("use-system-setting");
3542 if (xmlTextReaderGetAttribute(reader, XMLCHAR("screen-reader"))) {
3543 uiapplication->screenreader = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("screen-reader")));
3544 if (uiapplication->screenreader == NULL)
3545 uiapplication->screenreader = strdup("use-system-setting");
3547 uiapplication->screenreader = strdup("use-system-setting");
3549 if (xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")))
3550 uiapplication->recentimage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")));
3551 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp"))) {
3552 uiapplication->mainapp = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp")));
3553 if (uiapplication->mainapp == NULL)
3554 uiapplication->mainapp = strdup("false");
3556 uiapplication->mainapp = strdup("false");
3558 if (xmlTextReaderGetAttribute(reader, XMLCHAR("launchcondition"))) {
3559 uiapplication->launchcondition = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("launchcondition")));
3560 if (uiapplication->launchcondition == NULL)
3561 uiapplication->launchcondition = strdup("false");
3563 uiapplication->launchcondition = strdup("false");
3566 if (xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay"))) {
3567 uiapplication->indicatordisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay")));
3568 if (uiapplication->indicatordisplay == NULL)
3569 uiapplication->indicatordisplay = strdup("true");
3571 uiapplication->indicatordisplay = strdup("true");
3573 if (xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")))
3574 uiapplication->portraitimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")));
3576 uiapplication->portraitimg = NULL;
3577 if (xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")))
3578 uiapplication->landscapeimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")));
3580 uiapplication->landscapeimg = NULL;
3581 if (xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility"))) {
3582 uiapplication->guestmode_visibility = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility")));
3583 if (uiapplication->guestmode_visibility == NULL)
3584 uiapplication->guestmode_visibility = strdup("true");
3586 uiapplication->guestmode_visibility = strdup("true");
3588 if (xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type"))) {
3589 uiapplication->permission_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type")));
3590 if (uiapplication->permission_type == NULL)
3591 uiapplication->permission_type = strdup("normal");
3593 uiapplication->permission_type = strdup("normal");
3595 if (xmlTextReaderGetAttribute(reader, XMLCHAR("component-type"))) {
3596 uiapplication->component_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("component-type")));
3597 if (uiapplication->component_type == NULL)
3598 uiapplication->component_type = strdup("uiapp");
3600 uiapplication->component_type = strdup("uiapp");
3602 if (xmlTextReaderGetAttribute(reader, XMLCHAR("submode"))) {
3603 uiapplication->submode = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("submode")));
3604 if (uiapplication->submode == NULL)
3605 uiapplication->submode = strdup("false");
3607 uiapplication->submode = strdup("false");
3609 if (xmlTextReaderGetAttribute(reader, XMLCHAR("submode-mainid")))
3610 uiapplication->submode_mainid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("submode-mainid")));
3612 depth = xmlTextReaderDepth(reader);
3613 while ((ret = __next_child_element(reader, depth))) {
3614 node = xmlTextReaderConstName(reader);
3616 _LOGD("xmlTextReaderConstName value is NULL\n");
3619 if (!strcmp(ASCII(node), "label")) {
3620 label_x *label = malloc(sizeof(label_x));
3621 if (label == NULL) {
3622 _LOGD("Malloc Failed\n");
3625 memset(label, '\0', sizeof(label_x));
3626 LISTADD(uiapplication->label, label);
3627 ret = __ps_process_label(reader, label);
3628 } else if (!strcmp(ASCII(node), "icon")) {
3629 icon_x *icon = malloc(sizeof(icon_x));
3631 _LOGD("Malloc Failed\n");
3634 memset(icon, '\0', sizeof(icon_x));
3635 LISTADD(uiapplication->icon, icon);
3636 ret = __ps_process_icon(reader, icon);
3637 } else if (!strcmp(ASCII(node), "image")) {
3638 image_x *image = malloc(sizeof(image_x));
3639 if (image == NULL) {
3640 _LOGD("Malloc Failed\n");
3643 memset(image, '\0', sizeof(image_x));
3644 LISTADD(uiapplication->image, image);
3645 ret = __ps_process_image(reader, image);
3646 } else if (!strcmp(ASCII(node), "category")) {
3647 category_x *category = malloc(sizeof(category_x));
3648 if (category == NULL) {
3649 _LOGD("Malloc Failed\n");
3652 memset(category, '\0', sizeof(category_x));
3653 LISTADD(uiapplication->category, category);
3654 ret = __ps_process_category(reader, category);
3655 } else if (!strcmp(ASCII(node), "metadata")) {
3656 metadata_x *metadata = malloc(sizeof(metadata_x));
3657 if (metadata == NULL) {
3658 _LOGD("Malloc Failed\n");
3661 memset(metadata, '\0', sizeof(metadata_x));
3662 LISTADD(uiapplication->metadata, metadata);
3663 ret = __ps_process_metadata(reader, metadata);
3664 } else if (!strcmp(ASCII(node), "permission")) {
3665 permission_x *permission = malloc(sizeof(permission_x));
3666 if (permission == NULL) {
3667 _LOGD("Malloc Failed\n");
3670 memset(permission, '\0', sizeof(permission_x));
3671 LISTADD(uiapplication->permission, permission);
3672 ret = __ps_process_permission(reader, permission);
3673 } else if (!strcmp(ASCII(node), "app-control")) {
3674 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
3675 if (appcontrol == NULL) {
3676 _LOGD("Malloc Failed\n");
3679 memset(appcontrol, '\0', sizeof(appcontrol_x));
3680 LISTADD(uiapplication->appcontrol, appcontrol);
3681 ret = __ps_process_appcontrol(reader, appcontrol);
3682 } else if (!strcmp(ASCII(node), "application-service")) {
3683 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
3684 if (appsvc == NULL) {
3685 _LOGD("Malloc Failed\n");
3688 memset(appsvc, '\0', sizeof(appsvc_x));
3689 LISTADD(uiapplication->appsvc, appsvc);
3690 ret = __ps_process_appsvc(reader, appsvc);
3691 } else if (!strcmp(ASCII(node), "data-share")) {
3692 datashare_x *datashare = malloc(sizeof(datashare_x));
3693 if (datashare == NULL) {
3694 _LOGD("Malloc Failed\n");
3697 memset(datashare, '\0', sizeof(datashare_x));
3698 LISTADD(uiapplication->datashare, datashare);
3699 ret = __ps_process_datashare(reader, datashare);
3700 } else if (!strcmp(ASCII(node), "launch-conditions")) {
3701 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
3702 if (launchconditions == NULL) {
3703 _LOGD("Malloc Failed\n");
3706 memset(launchconditions, '\0', sizeof(launchconditions_x));
3707 LISTADD(uiapplication->launchconditions, launchconditions);
3708 ret = __ps_process_launchconditions(reader, launchconditions);
3709 } else if (!strcmp(ASCII(node), "notification")) {
3710 notification_x *notification = malloc(sizeof(notification_x));
3711 if (notification == NULL) {
3712 _LOGD("Malloc Failed\n");
3715 memset(notification, '\0', sizeof(notification_x));
3716 LISTADD(uiapplication->notification, notification);
3717 ret = __ps_process_notification(reader, notification);
3721 _LOGD("Processing uiapplication failed\n");
3726 if (uiapplication->label) {
3727 LISTHEAD(uiapplication->label, tmp1);
3728 uiapplication->label = tmp1;
3730 if (uiapplication->icon) {
3731 LISTHEAD(uiapplication->icon, tmp2);
3732 uiapplication->icon = tmp2;
3734 if (uiapplication->appsvc) {
3735 LISTHEAD(uiapplication->appsvc, tmp3);
3736 uiapplication->appsvc = tmp3;
3738 if (uiapplication->appcontrol) {
3739 LISTHEAD(uiapplication->appcontrol, tmp4);
3740 uiapplication->appcontrol = tmp4;
3742 if (uiapplication->launchconditions) {
3743 LISTHEAD(uiapplication->launchconditions, tmp5);
3744 uiapplication->launchconditions = tmp5;
3746 if (uiapplication->notification) {
3747 LISTHEAD(uiapplication->notification, tmp6);
3748 uiapplication->notification = tmp6;
3750 if (uiapplication->datashare) {
3751 LISTHEAD(uiapplication->datashare, tmp7);
3752 uiapplication->datashare = tmp7;
3754 if (uiapplication->category) {
3755 LISTHEAD(uiapplication->category, tmp8);
3756 uiapplication->category = tmp8;
3758 if (uiapplication->metadata) {
3759 LISTHEAD(uiapplication->metadata, tmp9);
3760 uiapplication->metadata = tmp9;
3762 if (uiapplication->image) {
3763 LISTHEAD(uiapplication->image, tmp10);
3764 uiapplication->image = tmp10;
3766 if (uiapplication->permission) {
3767 LISTHEAD(uiapplication->permission, tmp11);
3768 uiapplication->permission = tmp11;
3774 static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication)
3776 const xmlChar *node;
3779 char *newappid = NULL;
3780 label_x *tmp1 = NULL;
3781 icon_x *tmp2 = NULL;
3782 appsvc_x *tmp3 = NULL;
3783 appcontrol_x *tmp4 = NULL;
3784 datacontrol_x *tmp5 = NULL;
3785 launchconditions_x *tmp6 = NULL;
3786 notification_x *tmp7 = NULL;
3787 datashare_x *tmp8 = NULL;
3788 category_x *tmp9 = NULL;
3789 metadata_x *tmp10 = NULL;
3790 permission_x *tmp11 = NULL;
3792 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
3793 serviceapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
3794 if (serviceapplication->appid == NULL) {
3795 _LOGD("appid cant be NULL\n");
3799 _LOGD("appid is mandatory\n");
3803 ret = __validate_appid(package, serviceapplication->appid, &newappid);
3805 _LOGD("appid is not proper\n");
3809 if (serviceapplication->appid)
3810 free((void *)serviceapplication->appid);
3811 serviceapplication->appid = newappid;
3814 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
3815 serviceapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
3816 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
3817 serviceapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
3818 if (xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot"))) {
3819 serviceapplication->onboot = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot")));
3820 if (serviceapplication->onboot == NULL)
3821 serviceapplication->onboot = strdup("false");
3823 serviceapplication->onboot = strdup("false");
3825 if (xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart"))) {
3826 serviceapplication->autorestart = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart")));
3827 if (serviceapplication->autorestart == NULL)
3828 serviceapplication->autorestart = strdup("false");
3830 serviceapplication->autorestart = strdup("false");
3832 if (xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type"))) {
3833 serviceapplication->permission_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type")));
3834 if (serviceapplication->permission_type == NULL)
3835 serviceapplication->permission_type = strdup("normal");
3837 serviceapplication->permission_type = strdup("normal");
3840 depth = xmlTextReaderDepth(reader);
3841 while ((ret = __next_child_element(reader, depth))) {
3842 node = xmlTextReaderConstName(reader);
3844 _LOGD("xmlTextReaderConstName value is NULL\n");
3848 if (!strcmp(ASCII(node), "label")) {
3849 label_x *label = malloc(sizeof(label_x));
3850 if (label == NULL) {
3851 _LOGD("Malloc Failed\n");
3854 memset(label, '\0', sizeof(label_x));
3855 LISTADD(serviceapplication->label, label);
3856 ret = __ps_process_label(reader, label);
3857 } else if (!strcmp(ASCII(node), "icon")) {
3858 icon_x *icon = malloc(sizeof(icon_x));
3860 _LOGD("Malloc Failed\n");
3863 memset(icon, '\0', sizeof(icon_x));
3864 LISTADD(serviceapplication->icon, icon);
3865 ret = __ps_process_icon(reader, icon);
3866 } else if (!strcmp(ASCII(node), "category")) {
3867 category_x *category = malloc(sizeof(category_x));
3868 if (category == NULL) {
3869 _LOGD("Malloc Failed\n");
3872 memset(category, '\0', sizeof(category_x));
3873 LISTADD(serviceapplication->category, category);
3874 ret = __ps_process_category(reader, category);
3875 } else if (!strcmp(ASCII(node), "metadata")) {
3876 metadata_x *metadata = malloc(sizeof(metadata_x));
3877 if (metadata == NULL) {
3878 _LOGD("Malloc Failed\n");
3881 memset(metadata, '\0', sizeof(metadata_x));
3882 LISTADD(serviceapplication->metadata, metadata);
3883 ret = __ps_process_metadata(reader, metadata);
3884 } else if (!strcmp(ASCII(node), "permission")) {
3885 permission_x *permission = malloc(sizeof(permission_x));
3886 if (permission == NULL) {
3887 _LOGD("Malloc Failed\n");
3890 memset(permission, '\0', sizeof(permission_x));
3891 LISTADD(serviceapplication->permission, permission);
3892 ret = __ps_process_permission(reader, permission);
3893 } else if (!strcmp(ASCII(node), "app-control")) {
3894 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
3895 if (appcontrol == NULL) {
3896 _LOGD("Malloc Failed\n");
3899 memset(appcontrol, '\0', sizeof(appcontrol_x));
3900 LISTADD(serviceapplication->appcontrol, appcontrol);
3901 ret = __ps_process_appcontrol(reader, appcontrol);
3902 } else if (!strcmp(ASCII(node), "application-service")) {
3903 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
3904 if (appsvc == NULL) {
3905 _LOGD("Malloc Failed\n");
3908 memset(appsvc, '\0', sizeof(appsvc_x));
3909 LISTADD(serviceapplication->appsvc, appsvc);
3910 ret = __ps_process_appsvc(reader, appsvc);
3911 } else if (!strcmp(ASCII(node), "data-share")) {
3912 datashare_x *datashare = malloc(sizeof(datashare_x));
3913 if (datashare == NULL) {
3914 _LOGD("Malloc Failed\n");
3917 memset(datashare, '\0', sizeof(datashare_x));
3918 LISTADD(serviceapplication->datashare, datashare);
3919 ret = __ps_process_datashare(reader, datashare);
3920 } else if (!strcmp(ASCII(node), "launch-conditions")) {
3921 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
3922 if (launchconditions == NULL) {
3923 _LOGD("Malloc Failed\n");
3926 memset(launchconditions, '\0', sizeof(launchconditions_x));
3927 LISTADD(serviceapplication->launchconditions, launchconditions);
3928 ret = __ps_process_launchconditions(reader, launchconditions);
3929 } else if (!strcmp(ASCII(node), "notification")) {
3930 notification_x *notification = malloc(sizeof(notification_x));
3931 if (notification == NULL) {
3932 _LOGD("Malloc Failed\n");
3935 memset(notification, '\0', sizeof(notification_x));
3936 LISTADD(serviceapplication->notification, notification);
3937 ret = __ps_process_notification(reader, notification);
3938 } else if (!strcmp(ASCII(node), "data-control")) {
3939 datacontrol_x *datacontrol = malloc(sizeof(datacontrol_x));
3940 if (datacontrol == NULL) {
3941 _LOGD("Malloc Failed\n");
3944 memset(datacontrol, '\0', sizeof(datacontrol_x));
3945 LISTADD(serviceapplication->datacontrol, datacontrol);
3946 ret = __ps_process_datacontrol(reader, datacontrol);
3950 _LOGD("Processing serviceapplication failed\n");
3955 if (serviceapplication->label) {
3956 LISTHEAD(serviceapplication->label, tmp1);
3957 serviceapplication->label = tmp1;
3959 if (serviceapplication->icon) {
3960 LISTHEAD(serviceapplication->icon, tmp2);
3961 serviceapplication->icon = tmp2;
3963 if (serviceapplication->appsvc) {
3964 LISTHEAD(serviceapplication->appsvc, tmp3);
3965 serviceapplication->appsvc = tmp3;
3967 if (serviceapplication->appcontrol) {
3968 LISTHEAD(serviceapplication->appcontrol, tmp4);
3969 serviceapplication->appcontrol = tmp4;
3971 if (serviceapplication->datacontrol) {
3972 LISTHEAD(serviceapplication->datacontrol, tmp5);
3973 serviceapplication->datacontrol = tmp5;
3975 if (serviceapplication->launchconditions) {
3976 LISTHEAD(serviceapplication->launchconditions, tmp6);
3977 serviceapplication->launchconditions = tmp6;
3979 if (serviceapplication->notification) {
3980 LISTHEAD(serviceapplication->notification, tmp7);
3981 serviceapplication->notification = tmp7;
3983 if (serviceapplication->datashare) {
3984 LISTHEAD(serviceapplication->datashare, tmp8);
3985 serviceapplication->datashare = tmp8;
3987 if (serviceapplication->category) {
3988 LISTHEAD(serviceapplication->category, tmp9);
3989 serviceapplication->category = tmp9;
3991 if (serviceapplication->metadata) {
3992 LISTHEAD(serviceapplication->metadata, tmp10);
3993 serviceapplication->metadata = tmp10;
3995 if (serviceapplication->permission) {
3996 LISTHEAD(serviceapplication->permission, tmp11);
3997 serviceapplication->permission = tmp11;
4003 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile)
4005 /*TODO: once policy is set*/
4009 static int __ps_process_font(xmlTextReaderPtr reader, font_x *font)
4011 /*TODO: once policy is set*/
4015 static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme)
4017 /*TODO: once policy is set*/
4021 static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon)
4023 /*TODO: once policy is set*/
4027 static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime)
4029 /*TODO: once policy is set*/
4033 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx)
4035 _LOGD("__start_process\n");
4036 const xmlChar *node;
4039 label_x *tmp1 = NULL;
4040 author_x *tmp2 = NULL;
4041 description_x *tmp3 = NULL;
4042 license_x *tmp4 = NULL;
4043 uiapplication_x *tmp5 = NULL;
4044 serviceapplication_x *tmp6 = NULL;
4045 daemon_x *tmp7 = NULL;
4046 theme_x *tmp8 = NULL;
4047 font_x *tmp9 = NULL;
4048 ime_x *tmp10 = NULL;
4049 icon_x *tmp11 = NULL;
4050 compatibility_x *tmp12 = NULL;
4051 deviceprofile_x *tmp13 = NULL;
4052 privileges_x *tmp14 = NULL;
4054 depth = xmlTextReaderDepth(reader);
4055 while ((ret = __next_child_element(reader, depth))) {
4056 node = xmlTextReaderConstName(reader);
4058 _LOGD("xmlTextReaderConstName value is NULL\n");
4062 if (!strcmp(ASCII(node), "label")) {
4063 label_x *label = malloc(sizeof(label_x));
4064 if (label == NULL) {
4065 _LOGD("Malloc Failed\n");
4068 memset(label, '\0', sizeof(label_x));
4069 LISTADD(mfx->label, label);
4070 ret = __ps_process_label(reader, label);
4071 } else if (!strcmp(ASCII(node), "author")) {
4072 author_x *author = malloc(sizeof(author_x));
4073 if (author == NULL) {
4074 _LOGD("Malloc Failed\n");
4077 memset(author, '\0', sizeof(author_x));
4078 LISTADD(mfx->author, author);
4079 ret = __ps_process_author(reader, author);
4080 } else if (!strcmp(ASCII(node), "description")) {
4081 description_x *description = malloc(sizeof(description_x));
4082 if (description == NULL) {
4083 _LOGD("Malloc Failed\n");
4086 memset(description, '\0', sizeof(description_x));
4087 LISTADD(mfx->description, description);
4088 ret = __ps_process_description(reader, description);
4089 } else if (!strcmp(ASCII(node), "license")) {
4090 license_x *license = malloc(sizeof(license_x));
4091 if (license == NULL) {
4092 _LOGD("Malloc Failed\n");
4095 memset(license, '\0', sizeof(license_x));
4096 LISTADD(mfx->license, license);
4097 ret = __ps_process_license(reader, license);
4098 } else if (!strcmp(ASCII(node), "privileges")) {
4099 privileges_x *privileges = malloc(sizeof(privileges_x));
4100 if (privileges == NULL) {
4101 _LOGD("Malloc Failed\n");
4104 memset(privileges, '\0', sizeof(privileges_x));
4105 LISTADD(mfx->privileges, privileges);
4106 ret = __ps_process_privileges(reader, privileges);
4107 } else if (!strcmp(ASCII(node), "ui-application")) {
4108 uiapplication_x *uiapplication = malloc(sizeof(uiapplication_x));
4109 if (uiapplication == NULL) {
4110 _LOGD("Malloc Failed\n");
4113 memset(uiapplication, '\0', sizeof(uiapplication_x));
4114 LISTADD(mfx->uiapplication, uiapplication);
4115 ret = __ps_process_uiapplication(reader, uiapplication);
4116 } else if (!strcmp(ASCII(node), "service-application")) {
4117 serviceapplication_x *serviceapplication = malloc(sizeof(serviceapplication_x));
4118 if (serviceapplication == NULL) {
4119 _LOGD("Malloc Failed\n");
4122 memset(serviceapplication, '\0', sizeof(serviceapplication_x));
4123 LISTADD(mfx->serviceapplication, serviceapplication);
4124 ret = __ps_process_serviceapplication(reader, serviceapplication);
4125 } else if (!strcmp(ASCII(node), "daemon")) {
4126 daemon_x *daemon = malloc(sizeof(daemon_x));
4127 if (daemon == NULL) {
4128 _LOGD("Malloc Failed\n");
4131 memset(daemon, '\0', sizeof(daemon_x));
4132 LISTADD(mfx->daemon, daemon);
4133 ret = __ps_process_daemon(reader, daemon);
4134 } else if (!strcmp(ASCII(node), "theme")) {
4135 theme_x *theme = malloc(sizeof(theme_x));
4136 if (theme == NULL) {
4137 _LOGD("Malloc Failed\n");
4140 memset(theme, '\0', sizeof(theme_x));
4141 LISTADD(mfx->theme, theme);
4142 ret = __ps_process_theme(reader, theme);
4143 } else if (!strcmp(ASCII(node), "font")) {
4144 font_x *font = malloc(sizeof(font_x));
4146 _LOGD("Malloc Failed\n");
4149 memset(font, '\0', sizeof(font_x));
4150 LISTADD(mfx->font, font);
4151 ret = __ps_process_font(reader, font);
4152 } else if (!strcmp(ASCII(node), "ime")) {
4153 ime_x *ime = malloc(sizeof(ime_x));
4155 _LOGD("Malloc Failed\n");
4158 memset(ime, '\0', sizeof(ime_x));
4159 LISTADD(mfx->ime, ime);
4160 ret = __ps_process_ime(reader, ime);
4161 } else if (!strcmp(ASCII(node), "icon")) {
4162 icon_x *icon = malloc(sizeof(icon_x));
4164 _LOGD("Malloc Failed\n");
4167 memset(icon, '\0', sizeof(icon_x));
4168 LISTADD(mfx->icon, icon);
4169 ret = __ps_process_icon(reader, icon);
4170 } else if (!strcmp(ASCII(node), "device-profile")) {
4171 deviceprofile_x *deviceprofile = malloc(sizeof(deviceprofile_x));
4172 if (deviceprofile == NULL) {
4173 _LOGD("Malloc Failed\n");
4176 memset(deviceprofile, '\0', sizeof(deviceprofile_x));
4177 LISTADD(mfx->deviceprofile, deviceprofile);
4178 ret = __ps_process_deviceprofile(reader, deviceprofile);
4179 } else if (!strcmp(ASCII(node), "compatibility")) {
4180 compatibility_x *compatibility = malloc(sizeof(compatibility_x));
4181 if (compatibility == NULL) {
4182 _LOGD("Malloc Failed\n");
4185 memset(compatibility, '\0', sizeof(compatibility_x));
4186 LISTADD(mfx->compatibility, compatibility);
4187 ret = __ps_process_compatibility(reader, compatibility);
4188 } else if (!strcmp(ASCII(node), "shortcut-list")) {
4190 } else if (!strcmp(ASCII(node), "livebox")) {
4192 } else if (!strcmp(ASCII(node), "account")) {
4194 } else if (!strcmp(ASCII(node), "notifications")) {
4196 } else if (!strcmp(ASCII(node), "ime")) {
4202 _LOGD("Processing manifest failed\n");
4207 LISTHEAD(mfx->label, tmp1);
4211 LISTHEAD(mfx->author, tmp2);
4214 if (mfx->description) {
4215 LISTHEAD(mfx->description, tmp3);
4216 mfx->description= tmp3;
4219 LISTHEAD(mfx->license, tmp4);
4222 if (mfx->uiapplication) {
4223 LISTHEAD(mfx->uiapplication, tmp5);
4224 mfx->uiapplication = tmp5;
4226 if (mfx->serviceapplication) {
4227 LISTHEAD(mfx->serviceapplication, tmp6);
4228 mfx->serviceapplication = tmp6;
4231 LISTHEAD(mfx->daemon, tmp7);
4235 LISTHEAD(mfx->theme, tmp8);
4239 LISTHEAD(mfx->font, tmp9);
4243 LISTHEAD(mfx->ime, tmp10);
4247 LISTHEAD(mfx->icon, tmp11);
4250 if (mfx->compatibility) {
4251 LISTHEAD(mfx->compatibility, tmp12);
4252 mfx->compatibility= tmp12;
4254 if (mfx->deviceprofile) {
4255 LISTHEAD(mfx->deviceprofile, tmp13);
4256 mfx->deviceprofile= tmp13;
4258 if (mfx->privileges) {
4259 LISTHEAD(mfx->privileges, tmp14);
4260 mfx->privileges = tmp14;
4265 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx)
4267 const xmlChar *node;
4270 if ((ret = __next_child_element(reader, -1))) {
4271 node = xmlTextReaderConstName(reader);
4273 _LOGD("xmlTextReaderConstName value is NULL\n");
4277 if (!strcmp(ASCII(node), "manifest")) {
4278 if (xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")))
4279 mfx->ns = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")));
4280 if (xmlTextReaderGetAttribute(reader, XMLCHAR("package"))) {
4281 mfx->package= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("package")));
4282 if (mfx->package == NULL) {
4283 _LOGD("package cant be NULL\n");
4287 _LOGD("package field is mandatory\n");
4290 package = mfx->package;
4291 if (xmlTextReaderGetAttribute(reader, XMLCHAR("version")))
4292 mfx->version= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("version")));
4293 /*app2ext needs package size for external installation*/
4294 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
4295 mfx->package_size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
4296 if (xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")))
4297 mfx->installlocation = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")));
4298 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
4299 mfx->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
4300 if (xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")))
4301 mfx->root_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")));
4302 if (xmlTextReaderGetAttribute(reader, XMLCHAR("csc_path")))
4303 mfx->csc_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("csc_path")));
4304 if (xmlTextReaderGetAttribute(reader, XMLCHAR("main_package")))
4305 mfx->main_package = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("main_package")));
4306 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting"))) {
4307 mfx->appsetting = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting")));
4308 if (mfx->appsetting == NULL)
4309 mfx->appsetting = strdup("false");
4311 mfx->appsetting = strdup("false");
4313 if (xmlTextReaderGetAttribute(reader, XMLCHAR("storeclient-id")))
4314 mfx->storeclient_id= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("storeclient-id")));
4315 if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay-setting"))) {
4316 mfx->nodisplay_setting = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay-setting")));
4317 if (mfx->nodisplay_setting == NULL)
4318 mfx->nodisplay_setting = strdup("false");
4320 mfx->nodisplay_setting = strdup("false");
4322 if (xmlTextReaderGetAttribute(reader, XMLCHAR("url")))
4323 mfx->package_url= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("url")));
4325 /*Assign default values. If required it will be overwritten in __add_preload_info()*/
4326 mfx->preload = strdup("False");
4327 mfx->removable = strdup("True");
4328 mfx->readonly = strdup("False");
4329 mfx->update = strdup("False");
4330 mfx->system = strdup("False");
4331 char buf[PKG_STRING_LEN_MAX] = {'\0'};
4333 time_t current_time;
4334 time(¤t_time);
4335 snprintf(buf, PKG_STRING_LEN_MAX - 1, "%d", current_time);
4336 val = strndup(buf, PKG_STRING_LEN_MAX - 1);
4337 mfx->installed_time = val;
4339 mfx->installed_storage= strdup("installed_internal");
4341 ret = __start_process(reader, mfx);
4343 _LOGD("No Manifest element found\n");
4350 static const char* getUserDesktopPath(void)
4352 const char* desktop_path;
4355 desktop_path = tzplatform_mkpath(TZ_USER_HOME, ".applications/desktop/");
4359 desktop_path = tzplatform_mkpath(TZ_SYS_RW_DESKTOP_APP, "/");
4362 _LOGD("uid: [%d] / desktop_path: [%s]\n", getuid(), desktop_path);
4363 return desktop_path;
4366 static const char* getUserManifestPath(void)
4368 const char* manifest_path;
4371 manifest_path = tzplatform_mkpath(TZ_USER_HOME, ".config/xwalk-service/applications/");
4375 manifest_path = tzplatform_mkpath(TZ_SYS_RW_PACKAGES, "/");
4378 _LOGD("uid: [%d] / manifest_path: [%s]\n", getuid(), manifest_path);
4379 return manifest_path;
4382 static char* __convert_to_system_locale(const char *mlocale)
4384 if (mlocale == NULL)
4386 char *locale = NULL;
4387 locale = (char *)calloc(1, 6);
4389 _LOGE("Malloc Failed\n");
4393 strncpy(locale, mlocale, 2);
4394 strncat(locale, "_", 1);
4395 locale[3] = toupper(mlocale[3]);
4396 locale[4] = toupper(mlocale[4]);
4400 #define LIBAIL_PATH LIB_PATH "/libail.so.0"
4402 /* operation_type */
4412 static int __ail_change_info(int op, const char *appid)
4414 void *lib_handle = NULL;
4415 int (*ail_desktop_operation) (const char *);
4419 if ((lib_handle = dlopen(LIBAIL_PATH, RTLD_LAZY)) == NULL) {
4420 _LOGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAIL_PATH);
4427 aop = "ail_desktop_add";
4430 aop = "ail_desktop_update";
4433 aop = "ail_desktop_remove";
4436 aop = "ail_desktop_clean";
4439 aop = "ail_desktop_fota";
4446 if ((ail_desktop_operation =
4447 dlsym(lib_handle, aop)) == NULL || dlerror() != NULL) {
4448 _LOGE("can not find symbol \n");
4452 ret = ail_desktop_operation(appid);
4456 dlclose(lib_handle);
4462 /* desktop shoud be generated automatically based on manifest */
4463 /* Currently removable, taskmanage, etc fields are not considerd. it will be decided soon.*/
4464 #define BUFMAX 1024*128
4465 static int __ps_make_nativeapp_desktop(manifest_x * mfx, const char *manifest, ACTION_TYPE action)
4469 char filepath[PKG_STRING_LEN_MAX] = "";
4471 char *buftemp = NULL;
4472 char *locale = NULL;
4474 buf = (char *)calloc(1, BUFMAX);
4476 _LOGE("Malloc Failed\n");
4480 buftemp = (char *)calloc(1, BUFMAX);
4482 _LOGE("Malloc Failed\n");
4487 if (action == ACTION_UPGRADE)
4488 __ail_change_info(AIL_CLEAN, mfx->package);
4490 for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) {
4492 if (manifest != NULL) {
4493 /* skip making a deskfile and update ail, if preload app is updated */
4494 if(strstr(manifest, getUserManifestPath())) {
4495 __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid);
4496 _LOGE("preload app is update : skip and update ail : %s", manifest);
4501 snprintf(filepath, sizeof(filepath),"%s%s.desktop", getUserDesktopPath(), mfx->uiapplication->appid);
4503 /* skip if desktop exists
4504 if (access(filepath, R_OK) == 0)
4508 file = fopen(filepath, "w");
4511 _LOGD("Can't open %s", filepath);
4517 snprintf(buf, BUFMAX, "[Desktop Entry]\n");
4518 fwrite(buf, 1, strlen(buf), file);
4520 for( ; mfx->uiapplication->label ; mfx->uiapplication->label = mfx->uiapplication->label->next) {
4521 if(!strcmp(mfx->uiapplication->label->lang, DEFAULT_LOCALE)) {
4522 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
4524 locale = __convert_to_system_locale(mfx->uiapplication->label->lang);
4525 snprintf(buf, BUFMAX, "Name[%s]=%s\n", locale,
4526 mfx->uiapplication->label->text);
4529 fwrite(buf, 1, strlen(buf), file);
4532 if(mfx->uiapplication->label && mfx->uiapplication->label->text) {
4533 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
4534 fwrite(buf, 1, strlen(buf), file);
4537 else if(mfx->label && mfx->label->text) {
4538 snprintf(buf, BUFMAX, "Name=%s\n", mfx->label->text);
4539 fwrite(buf, 1, strlen(buf), file);
4541 snprintf(buf, BUFMAX, "Name=%s\n", mfx->package);
4542 fwrite(buf, 1, strlen(buf), file);
4547 snprintf(buf, BUFMAX, "Type=Application\n");
4548 fwrite(buf, 1, strlen(buf), file);
4550 if(mfx->uiapplication->exec) {
4551 snprintf(buf, BUFMAX, "Exec=%s\n", mfx->uiapplication->exec);
4552 fwrite(buf, 1, strlen(buf), file);
4555 if(mfx->uiapplication->icon && mfx->uiapplication->icon->text) {
4556 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->uiapplication->icon->text);
4557 fwrite(buf, 1, strlen(buf), file);
4558 } else if(mfx->icon && mfx->icon->text) {
4559 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->icon->text);
4560 fwrite(buf, 1, strlen(buf), file);
4564 if(mfx->uiapplication && mfx->uiapplication->appsvc) {
4565 appsvc_x *asvc = mfx->uiapplication->appsvc;
4567 const char *mime = NULL;
4568 const char *mime_delim = "; ";
4571 strncpy(buf, "MimeType=", BUFMAX-1);
4577 _LOGD("MIME type: %s\n", mime);
4578 strncat(buf, mime, BUFMAX-strlen(buf)-1);
4580 strncat(buf, mime_delim, BUFMAX-strlen(buf)-1);
4588 _LOGD("MIME types: buf[%s]\n", buf);
4589 _LOGD("MIME count: %d\n", mime_count);
4591 fwrite(buf, 1, strlen(buf), file);
4595 snprintf(buf, BUFMAX, "Version=%s\n", mfx->version);
4596 fwrite(buf, 1, strlen(buf), file);
4599 if(mfx->uiapplication->nodisplay) {
4600 snprintf(buf, BUFMAX, "NoDisplay=%s\n", mfx->uiapplication->nodisplay);
4601 fwrite(buf, 1, strlen(buf), file);
4604 if(mfx->uiapplication->categories) {
4605 snprintf(buf, BUFMAX, "Categories=%s\n", mfx->uiapplication->categories);
4606 fwrite(buf, 1, strlen(buf), file);
4609 if(mfx->uiapplication->taskmanage && !strcasecmp(mfx->uiapplication->taskmanage, "False")) {
4610 snprintf(buf, BUFMAX, "X-TIZEN-TaskManage=False\n");
4611 fwrite(buf, 1, strlen(buf), file);
4614 if(mfx->uiapplication->enabled && !strcasecmp(mfx->uiapplication->enabled, "False")) {
4615 snprintf(buf, BUFMAX, "X-TIZEN-Enabled=False\n");
4616 fwrite(buf, 1, strlen(buf), file);
4619 if(mfx->uiapplication->hwacceleration) {
4620 snprintf(buf, BUFMAX, "Hw-Acceleration=%s\n", mfx->uiapplication->hwacceleration);
4621 fwrite(buf, 1, strlen(buf), file);
4624 if(mfx->uiapplication->multiple && !strcasecmp(mfx->uiapplication->multiple, "True")) {
4625 snprintf(buf, BUFMAX, "X-TIZEN-Multiple=True\n");
4626 fwrite(buf, 1, strlen(buf), file);
4629 if(mfx->uiapplication->extraid) {
4630 snprintf(buf, BUFMAX, "X-TIZEN-PackageID=%s\n", mfx->uiapplication->extraid);
4631 fwrite(buf, 1, strlen(buf), file);
4634 if(mfx->removable && !strcasecmp(mfx->removable, "False")) {
4635 snprintf(buf, BUFMAX, "X-TIZEN-Removable=False\n");
4636 fwrite(buf, 1, strlen(buf), file);
4640 snprintf(buf, BUFMAX, "X-TIZEN-PackageType=%s\n", mfx->type);
4641 fwrite(buf, 1, strlen(buf), file);
4644 if(mfx->uiapplication->submode && !strcasecmp(mfx->uiapplication->submode, "True")) {
4645 snprintf(buf, BUFMAX, "X-TIZEN-Submode=%s\n", mfx->uiapplication->submode);
4646 fwrite(buf, 1, strlen(buf), file);
4647 snprintf(buf, BUFMAX, "X-TIZEN-SubmodeMainid=%s\n", mfx->uiapplication->submode_mainid);
4648 fwrite(buf, 1, strlen(buf), file);
4651 snprintf(buf, BUFMAX, "X-TIZEN-PkgID=%s\n", mfx->package);
4652 fwrite(buf, 1, strlen(buf), file);
4655 // snprintf(buf, BUFMAX, "X-TIZEN-PackageType=rpm\n");
4656 // fwrite(buf, 1, strlen(buf), file);
4659 if(mfx->uiapplication->appsvc) {
4660 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
4661 _LOGD("buf[%s]\n", buf);
4664 uiapplication_x *up = mfx->uiapplication;
4665 appsvc_x *asvc = NULL;
4666 operation_x *op = NULL;
4669 subapp_x *sub = NULL;
4670 const char *operation = NULL;
4671 const char *mime = NULL;
4672 const char *uri = NULL;
4673 const char *subapp = NULL;
4678 while(asvc != NULL) {
4679 op = asvc->operation;
4682 operation = op->name;
4701 strncpy(buftemp, buf, BUFMAX);
4702 snprintf(buf, BUFMAX, "%s;", buftemp);
4706 strncpy(buftemp, buf, BUFMAX);
4707 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
4708 _LOGD("buf[%s]\n", buf);
4713 } while(ui != NULL);
4717 }while(sub != NULL);
4730 fwrite(buf, 1, strlen(buf), file);
4732 // strncpy(buftemp, buf, BUFMAX);
4733 // snprintf(buf, BUFMAX, "%s\n", buftemp);
4734 // fwrite(buf, 1, strlen(buf), file);
4737 if(mfx->uiapplication->appcontrol) {
4738 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
4739 _LOGD("buf[%s]\n", buf);
4741 uiapplication_x *up = mfx->uiapplication;
4742 appcontrol_x *acontrol = NULL;
4743 operation_x *op = NULL;
4746 subapp_x *sub = NULL;
4747 const char *operation = NULL;
4748 const char *mime = NULL;
4749 const char *uri = NULL;
4750 const char *subapp = NULL;
4753 acontrol = up->appcontrol;
4754 while(acontrol != NULL) {
4755 op = acontrol->operation;
4758 operation = op->name;
4759 mi = acontrol->mime;
4765 sub = acontrol->subapp;
4777 strncpy(buftemp, buf, BUFMAX);
4778 snprintf(buf, BUFMAX, "%s;", buftemp);
4781 strncpy(buftemp, buf, BUFMAX);
4782 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
4783 _LOGD("buf[%s]\n", buf);
4788 } while(ui != NULL);
4792 }while(sub != NULL);
4801 acontrol = acontrol->next;
4805 fwrite(buf, 1, strlen(buf), file);
4807 // strncpy(buftemp, buf, BUFMAX);
4808 // snprintf(buf, BUFMAX, "%s\n", buftemp);
4809 // fwrite(buf, 1, strlen(buf), file);
4816 if (action == ACTION_FOTA)
4817 __ail_change_info(AIL_FOTA, mfx->uiapplication->appid);
4819 __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid);
4828 static int __ps_remove_nativeapp_desktop(manifest_x *mfx)
4830 char filepath[PKG_STRING_LEN_MAX] = "";
4832 uiapplication_x *uiapplication = mfx->uiapplication;
4834 for(; uiapplication; uiapplication=uiapplication->next) {
4835 snprintf(filepath, sizeof(filepath),"%s%s.desktop", getUserDesktopPath(), uiapplication->appid);
4837 __ail_change_info(AIL_REMOVE, uiapplication->appid);
4839 ret = remove(filepath);
4847 #define LIBAPPSVC_PATH LIB_PATH "/libappsvc.so.0"
4849 static int __ps_remove_appsvc_db(manifest_x *mfx)
4851 void *lib_handle = NULL;
4852 int (*appsvc_operation) (const char *);
4854 uiapplication_x *uiapplication = mfx->uiapplication;
4856 if ((lib_handle = dlopen(LIBAPPSVC_PATH, RTLD_LAZY)) == NULL) {
4857 _LOGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAPPSVC_PATH);
4861 if ((appsvc_operation =
4862 dlsym(lib_handle, "appsvc_unset_defapp")) == NULL || dlerror() != NULL) {
4863 _LOGE("can not find symbol \n");
4867 for(; uiapplication; uiapplication=uiapplication->next) {
4868 ret = appsvc_operation(uiapplication->appid);
4870 _LOGE("can not operation symbol \n");
4875 dlclose(lib_handle);
4880 #define PRELOAD_PACKAGE_LIST SYSCONFDIR "/package-manager/preload/preload_list.txt"
4881 static int __add_preload_info(manifest_x * mfx, const char *manifest)
4884 char buffer[1024] = { 0 };
4887 if(strstr(manifest, getUserManifestPath())) {
4888 free((void *)mfx->readonly);
4889 mfx->readonly = strdup("True");
4891 free((void *)mfx->preload);
4892 mfx->preload = strdup("True");
4894 free((void *)mfx->removable);
4895 mfx->removable = strdup("False");
4897 free((void *)mfx->system);
4898 mfx->system = strdup("True");
4903 fp = fopen(PRELOAD_PACKAGE_LIST, "r");
4905 _LOGE("no preload list\n");
4909 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
4910 if (buffer[0] == '#') {
4911 if(strcasestr(buffer, "RW_NORM"))
4913 else if(strcasestr(buffer, "RW_RM"))
4921 if(!strcmp(mfx->package, buffer)) {
4922 free((void *)mfx->preload);
4923 mfx->preload = strdup("True");
4925 free((void *)mfx->readonly);
4926 mfx->readonly = strdup("False");
4927 free((void *)mfx->removable);
4928 mfx->removable = strdup("False");
4929 } else if(state == 3){
4930 free((void *)mfx->readonly);
4931 mfx->readonly = strdup("False");
4932 free((void *)mfx->removable);
4933 mfx->removable = strdup("True");
4937 memset(buffer, 0x00, sizeof(buffer));
4946 static int __check_preload_updated(manifest_x * mfx, const char *manifest)
4948 char filepath[PKG_STRING_LEN_MAX] = "";
4950 uiapplication_x *uiapplication = mfx->uiapplication;
4952 if(strstr(manifest, getUserManifestPath())) {
4953 /* if preload app is updated, then remove previous desktop file on RW*/
4954 for(; uiapplication; uiapplication=uiapplication->next) {
4955 snprintf(filepath, sizeof(filepath),"%s%s.desktop", getUserDesktopPath(), uiapplication->appid);
4956 ret = remove(filepath);
4961 /* if downloaded app is updated, then update tag set true*/
4962 free((void *)mfx->update);
4963 mfx->update = strdup("true");
4970 API int pkgmgr_parser_create_desktop_file(manifest_x *mfx)
4974 _LOGD("Manifest pointer is NULL\n");
4977 ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_INSTALL);
4979 _LOGD("Creating desktop file failed\n");
4981 _LOGD("Creating desktop file Success\n");
4985 API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
4990 free((void *)mfx->ns);
4994 free((void *)mfx->package);
4995 mfx->package = NULL;
4998 free((void *)mfx->version);
4999 mfx->version = NULL;
5001 if (mfx->installlocation) {
5002 free((void *)mfx->installlocation);
5003 mfx->installlocation = NULL;
5006 free((void *)mfx->preload);
5007 mfx->preload = NULL;
5009 if (mfx->readonly) {
5010 free((void *)mfx->readonly);
5011 mfx->readonly = NULL;
5013 if (mfx->removable) {
5014 free((void *)mfx->removable);
5015 mfx->removable = NULL;
5018 free((void *)mfx->update);
5022 free((void *)mfx->system);
5026 free((void *)mfx->type);
5029 if (mfx->package_size) {
5030 free((void *)mfx->package_size);
5031 mfx->package_size = NULL;
5033 if (mfx->installed_time) {
5034 free((void *)mfx->installed_time);
5035 mfx->installed_time = NULL;
5037 if (mfx->installed_storage) {
5038 free((void *)mfx->installed_storage);
5039 mfx->installed_storage = NULL;
5041 if (mfx->storeclient_id) {
5042 free((void *)mfx->storeclient_id);
5043 mfx->storeclient_id = NULL;
5045 if (mfx->mainapp_id) {
5046 free((void *)mfx->mainapp_id);
5047 mfx->mainapp_id = NULL;
5049 if (mfx->package_url) {
5050 free((void *)mfx->package_url);
5051 mfx->package_url = NULL;
5053 if (mfx->root_path) {
5054 free((void *)mfx->root_path);
5055 mfx->root_path = NULL;
5057 if (mfx->csc_path) {
5058 free((void *)mfx->csc_path);
5059 mfx->csc_path = NULL;
5061 if (mfx->appsetting) {
5062 free((void *)mfx->appsetting);
5063 mfx->appsetting = NULL;
5065 if (mfx->nodisplay_setting) {
5066 free((void *)mfx->nodisplay_setting);
5067 mfx->nodisplay_setting = NULL;
5069 if (mfx->main_package) {
5070 free((void *)mfx->main_package);
5071 mfx->main_package = NULL;
5076 icon_x *icon = mfx->icon;
5078 while(icon != NULL) {
5080 __ps_free_icon(icon);
5086 label_x *label = mfx->label;
5087 label_x *tmp = NULL;
5088 while(label != NULL) {
5090 __ps_free_label(label);
5096 author_x *author = mfx->author;
5097 author_x *tmp = NULL;
5098 while(author != NULL) {
5100 __ps_free_author(author);
5104 /*Free Description*/
5105 if (mfx->description) {
5106 description_x *description = mfx->description;
5107 description_x *tmp = NULL;
5108 while(description != NULL) {
5109 tmp = description->next;
5110 __ps_free_description(description);
5116 license_x *license = mfx->license;
5117 license_x *tmp = NULL;
5118 while(license != NULL) {
5119 tmp = license->next;
5120 __ps_free_license(license);
5125 if (mfx->privileges) {
5126 privileges_x *privileges = mfx->privileges;
5127 privileges_x *tmp = NULL;
5128 while(privileges != NULL) {
5129 tmp = privileges->next;
5130 __ps_free_privileges(privileges);
5134 /*Free UiApplication*/
5135 if (mfx->uiapplication) {
5136 uiapplication_x *uiapplication = mfx->uiapplication;
5137 uiapplication_x *tmp = NULL;
5138 while(uiapplication != NULL) {
5139 tmp = uiapplication->next;
5140 __ps_free_uiapplication(uiapplication);
5141 uiapplication = tmp;
5144 /*Free ServiceApplication*/
5145 if (mfx->serviceapplication) {
5146 serviceapplication_x *serviceapplication = mfx->serviceapplication;
5147 serviceapplication_x *tmp = NULL;
5148 while(serviceapplication != NULL) {
5149 tmp = serviceapplication->next;
5150 __ps_free_serviceapplication(serviceapplication);
5151 serviceapplication = tmp;
5156 daemon_x *daemon = mfx->daemon;
5157 daemon_x *tmp = NULL;
5158 while(daemon != NULL) {
5160 __ps_free_daemon(daemon);
5166 theme_x *theme = mfx->theme;
5167 theme_x *tmp = NULL;
5168 while(theme != NULL) {
5170 __ps_free_theme(theme);
5176 font_x *font = mfx->font;
5178 while(font != NULL) {
5180 __ps_free_font(font);
5186 ime_x *ime = mfx->ime;
5188 while(ime != NULL) {
5194 /*Free Compatibility*/
5195 if (mfx->compatibility) {
5196 compatibility_x *compatibility = mfx->compatibility;
5197 compatibility_x *tmp = NULL;
5198 while(compatibility != NULL) {
5199 tmp = compatibility->next;
5200 __ps_free_compatibility(compatibility);
5201 compatibility = tmp;
5204 /*Free DeviceProfile*/
5205 if (mfx->deviceprofile) {
5206 deviceprofile_x *deviceprofile = mfx->deviceprofile;
5207 deviceprofile_x *tmp = NULL;
5208 while(deviceprofile != NULL) {
5209 tmp = deviceprofile->next;
5210 __ps_free_deviceprofile(deviceprofile);
5211 deviceprofile = tmp;
5219 API manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest)
5221 _LOGD("parsing start\n");
5222 xmlTextReaderPtr reader;
5223 manifest_x *mfx = NULL;
5225 reader = xmlReaderForFile(manifest, NULL, 0);
5227 mfx = malloc(sizeof(manifest_x));
5229 memset(mfx, '\0', sizeof(manifest_x));
5230 if (__process_manifest(reader, mfx) < 0) {
5231 _LOGD("Parsing Failed\n");
5232 pkgmgr_parser_free_manifest_xml(mfx);
5235 _LOGD("Parsing Success\n");
5237 _LOGD("Memory allocation error\n");
5239 xmlFreeTextReader(reader);
5241 _LOGD("Unable to create xml reader\n");
5246 /* These APIs are intended to call parser directly */
5248 API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
5250 // char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
5251 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5252 _LOGD("parsing manifest for installation: %s\n", manifest);
5254 manifest_x *mfx = NULL;
5258 mfx = pkgmgr_parser_process_manifest_xml(manifest);
5259 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5261 _LOGD("Parsing Finished\n");
5263 // __streamFile(manifest, ACTION_INSTALL, temp, mfx->package);
5264 __ps_process_tag_parser(mfx, manifest, ACTION_INSTALL);
5265 __add_preload_info(mfx, manifest);
5267 _LOGD("Added preload infomation\n");
5269 __ps_process_tag(mfx, tagv);
5271 ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
5272 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
5274 _LOGD("DB Insert Success\n");
5276 ret = __ps_process_metadata_parser(mfx, ACTION_INSTALL);
5278 _LOGD("Creating metadata parser failed\n");
5280 ret = __ps_process_category_parser(mfx, ACTION_INSTALL);
5282 _LOGD("Creating category parser failed\n");
5284 if (__check_action_fota(tagv))
5285 ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_FOTA);
5287 ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_INSTALL);
5290 _LOGD("Creating desktop file failed\n");
5292 _LOGD("Creating desktop file Success\n");
5294 pkgmgr_parser_free_manifest_xml(mfx);
5295 _LOGD("Free Done\n");
5301 API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
5303 // char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
5304 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5305 _LOGD("parsing manifest for upgradation: %s\n", manifest);
5307 manifest_x *mfx = NULL;
5309 bool preload = false;
5310 bool system = false;
5311 char *csc_path = NULL;
5312 pkgmgrinfo_pkginfo_h handle = NULL;
5315 mfx = pkgmgr_parser_process_manifest_xml(manifest);
5316 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5318 _LOGD("Parsing Finished\n");
5320 // __streamFile(manifest, ACTION_UPGRADE, temp, mfx->package);
5321 __ps_process_tag_parser(mfx, manifest, ACTION_UPGRADE);
5322 __add_preload_info(mfx, manifest);
5323 _LOGD("Added preload infomation\n");
5324 __check_preload_updated(mfx, manifest);
5326 ret = pkgmgrinfo_pkginfo_get_pkginfo(mfx->package, &handle);
5327 if (ret != PMINFO_R_OK)
5328 _LOGD("pkgmgrinfo_pkginfo_get_pkginfo failed\n");
5330 ret = pkgmgrinfo_pkginfo_is_preload(handle, &preload);
5331 if (ret != PMINFO_R_OK)
5332 _LOGD("pkgmgrinfo_pkginfo_is_preload failed\n");
5335 free((void *)mfx->preload);
5336 mfx->preload = strdup("true");
5339 ret = pkgmgrinfo_pkginfo_is_system(handle, &system);
5340 if (ret != PMINFO_R_OK)
5341 _LOGD("pkgmgrinfo_pkginfo_is_system failed\n");
5344 free((void *)mfx->system);
5345 mfx->system = strdup("true");
5348 ret = pkgmgrinfo_pkginfo_get_csc_path(handle, &csc_path);
5349 if (ret != PMINFO_R_OK)
5350 _LOGD("pkgmgrinfo_pkginfo_get_csc_path failed\n");
5352 if (csc_path != NULL) {
5354 free((void *)mfx->csc_path);
5355 mfx->csc_path = strdup(csc_path);
5358 ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
5359 retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
5360 _LOGD("DB Update Success\n");
5362 ret = __ps_process_metadata_parser(mfx, ACTION_UPGRADE);
5364 _LOGD("Upgrade metadata parser failed\n");
5366 ret = __ps_process_category_parser(mfx, ACTION_UPGRADE);
5368 _LOGD("Creating category parser failed\n");
5370 ret = __ps_make_nativeapp_desktop(mfx, manifest, ACTION_UPGRADE);
5372 _LOGD("Creating desktop file failed\n");
5374 _LOGD("Creating desktop file Success\n");
5376 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
5377 pkgmgr_parser_free_manifest_xml(mfx);
5378 _LOGD("Free Done\n");
5384 API int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[])
5386 // char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
5387 retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5388 _LOGD("parsing manifest for uninstallation: %s\n", manifest);
5390 manifest_x *mfx = NULL;
5393 mfx = pkgmgr_parser_process_manifest_xml(manifest);
5394 retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
5396 _LOGD("Parsing Finished\n");
5398 // __streamFile(manifest, ACTION_UNINSTALL, temp, mfx->package);
5399 __ps_process_tag_parser(mfx, manifest, ACTION_UNINSTALL);
5401 __add_preload_info(mfx, manifest);
5402 _LOGD("Added preload infomation\n");
5404 ret = __ps_process_metadata_parser(mfx, ACTION_UNINSTALL);
5406 _LOGD("Removing metadata parser failed\n");
5408 ret = __ps_process_category_parser(mfx, ACTION_UNINSTALL);
5410 _LOGD("Creating category parser failed\n");
5412 ret = pkgmgr_parser_delete_manifest_info_from_db(mfx);
5414 _LOGD("DB Delete failed\n");
5416 _LOGD("DB Delete Success\n");
5418 ret = __ps_remove_nativeapp_desktop(mfx);
5420 _LOGD("Removing desktop file failed\n");
5422 _LOGD("Removing desktop file Success\n");
5424 ret = __ps_remove_appsvc_db(mfx);
5426 _LOGD("Removing appsvc_db failed\n");
5428 _LOGD("Removing appsvc_db Success\n");
5430 pkgmgr_parser_free_manifest_xml(mfx);
5431 _LOGD("Free Done\n");
5437 API int pkgmgr_parser_parse_manifest_for_preload()
5439 return pkgmgr_parser_update_preload_info_in_db();
5442 API char *pkgmgr_parser_get_manifest_file(const char *pkgid)
5444 return __pkgid_to_manifest(pkgid);
5447 API int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
5449 return __ps_run_parser(docPtr, tag, ACTION_INSTALL, pkgid);
5452 API int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgid)
5454 return __ps_run_parser(docPtr, tag, ACTION_UPGRADE, pkgid);
5457 API int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
5459 return __ps_run_parser(docPtr, tag, ACTION_UNINSTALL, pkgid);
5462 #define SCHEMA_FILE SYSCONFDIR "/package-manager/preload/manifest.xsd"
5464 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
5466 if (manifest == NULL) {
5467 _LOGE("manifest file is NULL\n");
5468 return PMINFO_R_EINVAL;
5471 xmlSchemaParserCtxtPtr ctx;
5472 xmlSchemaValidCtxtPtr vctx;
5473 xmlSchemaPtr xschema;
5474 ctx = xmlSchemaNewParserCtxt(SCHEMA_FILE);
5476 _LOGE("xmlSchemaNewParserCtxt() Failed\n");
5477 return PMINFO_R_ERROR;
5479 xschema = xmlSchemaParse(ctx);
5480 if (xschema == NULL) {
5481 _LOGE("xmlSchemaParse() Failed\n");
5482 return PMINFO_R_ERROR;
5484 vctx = xmlSchemaNewValidCtxt(xschema);
5486 _LOGE("xmlSchemaNewValidCtxt() Failed\n");
5487 return PMINFO_R_ERROR;
5489 xmlSchemaSetValidErrors(vctx, (xmlSchemaValidityErrorFunc) fprintf, (xmlSchemaValidityWarningFunc) fprintf, stderr);
5490 ret = xmlSchemaValidateFile(vctx, manifest, 0);
5492 _LOGE("xmlSchemaValidateFile() failed\n");
5493 return PMINFO_R_ERROR;
5494 } else if (ret == 0) {
5495 _LOGE("Manifest is Valid\n");
5498 _LOGE("Manifest Validation Failed with error code %d\n", ret);
5499 return PMINFO_R_ERROR;
5505 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
5515 _LOGE("fork failed\n");
5520 int dev_null_fd = open ("/dev/null", O_RDWR);
5521 if (dev_null_fd >= 0)
5523 dup2 (dev_null_fd, 0);/*stdin*/
5524 dup2 (dev_null_fd, 1);/*stdout*/
5525 dup2 (dev_null_fd, 2);/*stderr*/
5528 if (execl("/usr/bin/xmllint", "xmllint", manifest, "--schema",
5529 SCHEMA_FILE, NULL) < 0) {
5530 _LOGE("execl error\n");
5540 while ((err = waitpid(pid, &status, WNOHANG)) != pid) {
5544 _LOGE("waitpid failed\n");
5550 if(WIFEXITED(status) && !WEXITSTATUS(status))