4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
7 * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
31 #include <libxml/parser.h>
32 #include <libxml/xmlreader.h>
33 #include <libxml/xmlschemas.h>
38 #include "pkgmgr_parser.h"
39 #include "pkgmgr_parser_internal.h"
40 #include "pkgmgr_parser_db.h"
41 #include "pkgmgr-info.h"
43 #define MANIFEST_RW_DIRECTORY "/opt/share/packages"
44 #define MANIFEST_RO_DIRECTORY "/usr/share/packages"
45 #define ASCII(s) (const char *)s
46 #define XMLCHAR(s) (const xmlChar *)s
48 #define PRELOAD_PACKAGE_LIST "/usr/etc/package-manager/preload/preload_list.txt"
49 #define SCHEMA_FILE "/usr/etc/package-manager/preload/manifest.xsd"
51 #define MDPARSER_LIST "/usr/etc/package-manager/parserlib/metadata/mdparser_list.txt"
52 #define MDPARSER_NAME "mdparser:"
54 #define SMACK_LIST "/usr/etc/package-manager/pkgmgr_smack_list.txt"
56 #define BUFMAX 1024*128
59 #define APP_OWNER_ID 5000
60 #define APP_GROUP_ID 5000
62 #define LIBAPPSVC_PATH "/usr/lib/libappsvc.so.0"
63 #define LIBAIL_PATH "/usr/lib/libail.so.0"
64 #define DESKTOP_RW_PATH "/opt/share/applications/"
65 #define DESKTOP_RO_PATH "/usr/share/applications/"
66 #define MANIFEST_RO_PREFIX "/usr/share/packages/"
100 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label);
101 static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege);
102 static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privileges);
103 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile);
104 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed);
105 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation);
106 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri);
107 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime);
108 static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp);
109 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition);
110 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notifiation);
111 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category);
112 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata);
113 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission);
114 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility);
115 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution);
116 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request);
117 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define);
118 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc);
119 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions);
120 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare);
121 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon);
122 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author);
123 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description);
124 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability);
125 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license);
126 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol);
127 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol);
128 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication);
129 static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication);
130 static int __ps_process_font(xmlTextReaderPtr reader, font_x *font);
131 static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme);
132 static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon);
133 static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime);
134 static void __ps_free_label(label_x *label);
135 static void __ps_free_privilege(privilege_x *privilege);
136 static void __ps_free_privileges(privileges_x *privileges);
137 static void __ps_free_deviceprofile(deviceprofile_x * deviceprofile);
138 static void __ps_free_allowed(allowed_x *allowed);
139 static void __ps_free_operation(operation_x *operation);
140 static void __ps_free_uri(uri_x *uri);
141 static void __ps_free_mime(mime_x *mime);
142 static void __ps_free_subapp(subapp_x *subapp);
143 static void __ps_free_condition(condition_x *condition);
144 static void __ps_free_notification(notification_x *notifiation);
145 static void __ps_free_category(category_x *category);
146 static void __ps_free_metadata(metadata_x *metadata);
147 static void __ps_free_permission(permission_x *permission);
148 static void __ps_free_compatibility(compatibility_x *compatibility);
149 static void __ps_free_resolution(resolution_x *resolution);
150 static void __ps_free_request(request_x *request);
151 static void __ps_free_define(define_x *define);
152 static void __ps_free_appsvc(appsvc_x *appsvc);
153 static void __ps_free_launchconditions(launchconditions_x *launchconditions);
154 static void __ps_free_datashare(datashare_x *datashare);
155 static void __ps_free_icon(icon_x *icon);
156 static void __ps_free_author(author_x *author);
157 static void __ps_free_description(description_x *description);
158 static void __ps_free_capability(capability_x *capability);
159 static void __ps_free_license(license_x *license);
160 static void __ps_free_appcontrol(appcontrol_x *appcontrol);
161 static void __ps_free_datacontrol(datacontrol_x *datacontrol);
162 static void __ps_free_uiapplication(uiapplication_x *uiapplication);
163 static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication);
164 static void __ps_free_font(font_x *font);
165 static void __ps_free_theme(theme_x *theme);
166 static void __ps_free_daemon(daemon_x *daemon);
167 static void __ps_free_ime(ime_x *ime);
168 static char *__pkgid_to_manifest(const char *pkgid);
169 static int __next_child_element(xmlTextReaderPtr reader, int depth);
170 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx);
171 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx);
172 static void __str_trim(char *input);
173 static char *__get_parser_plugin(const char *type);
174 static int __ps_run_parser(xmlDocPtr docPtr, const char *tag, ACTION_TYPE action, const char *pkgid);
175 static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid);
176 static void __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgid);
177 static void __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid);
178 static int __validate_appid(const char *pkgid, const char *appid, char **newappid);
180 static int __is_dir(char *dirname)
182 struct stat stFileInfo;
183 stat(dirname, &stFileInfo);
184 if (S_ISDIR(stFileInfo.st_mode)) {
190 static void __apply_shared_privileges(char *pkgname, int flag)
192 char dirpath[BUFF_SIZE] = {'\0'};
193 /*execute privilege APIs. The APIs should not fail*/
194 pkgmgr_parser_privilege_register_package(pkgname);
197 /*home dir. Dont setup path but change smack access to "_" */
198 snprintf(dirpath, BUFF_SIZE, "/usr/apps/%s", pkgname);
199 if (__is_dir(dirpath))
200 pkgmgr_parser_privilege_change_smack_label(dirpath, "_", 0);/*0 is SMACK_LABEL_ACCESS*/
201 memset(dirpath, '\0', BUFF_SIZE);
202 snprintf(dirpath, BUFF_SIZE, "/opt/usr/apps/%s", pkgname);
203 if (__is_dir(dirpath))
204 pkgmgr_parser_privilege_change_smack_label(dirpath, "_", 0);/*0 is SMACK_LABEL_ACCESS*/
205 memset(dirpath, '\0', BUFF_SIZE);
207 /*/shared dir. Dont setup path but change smack access to "_" */
208 snprintf(dirpath, BUFF_SIZE, "/usr/apps/%s/shared", pkgname);
209 if (__is_dir(dirpath))
210 pkgmgr_parser_privilege_change_smack_label(dirpath, "_", 0);/*0 is SMACK_LABEL_ACCESS*/
211 memset(dirpath, '\0', BUFF_SIZE);
212 snprintf(dirpath, BUFF_SIZE, "/opt/usr/apps/%s/shared", pkgname);
213 if (__is_dir(dirpath))
214 pkgmgr_parser_privilege_change_smack_label(dirpath, "_", 0);/*0 is SMACK_LABEL_ACCESS*/
215 memset(dirpath, '\0', BUFF_SIZE);
217 /*/shared/res dir. setup path */
219 snprintf(dirpath, BUFF_SIZE, "/usr/apps/%s/shared/res", pkgname);
221 snprintf(dirpath, BUFF_SIZE, "/opt/usr/apps/%s/shared/res", pkgname);
222 if (__is_dir(dirpath))
223 pkgmgr_parser_privilege_setup_path(pkgname, dirpath, RPM_PATH_PUBLIC_RO, NULL);
224 memset(dirpath, '\0', BUFF_SIZE);
226 /*/shared/data dir. setup path and change group to 'app'*/
228 snprintf(dirpath, BUFF_SIZE, "/usr/apps/%s/shared/data", pkgname);
230 snprintf(dirpath, BUFF_SIZE, "/opt/usr/apps/%s/shared/data", pkgname);
231 if (__is_dir(dirpath)) {
232 chown(dirpath, APP_OWNER_ID, APP_GROUP_ID);
233 pkgmgr_parser_privilege_setup_path(pkgname, dirpath, RPM_PATH_PUBLIC_RO, NULL);
235 memset(dirpath, '\0', BUFF_SIZE);
237 snprintf(dirpath, BUFF_SIZE, "/opt/usr/apps/%s/shared/data", pkgname);
239 snprintf(dirpath, BUFF_SIZE, "/usr/apps/%s/shared/data", pkgname);
240 if (__is_dir(dirpath))
241 chown(dirpath, APP_OWNER_ID, APP_GROUP_ID);
242 pkgmgr_parser_privilege_setup_path(pkgname, dirpath, RPM_PATH_PUBLIC_RO, NULL);
247 static void __str_trim(char *input)
249 char *trim_str = input;
254 while (*input != 0) {
255 if (!isspace(*input)) {
266 static int __validate_appid(const char *pkgid, const char *appid, char **newappid)
268 if (!pkgid || !appid || !newappid) {
269 DBG("Arg supplied is NULL\n");
272 int pkglen = strlen(pkgid);
273 int applen = strlen(appid);
277 if (strncmp(appid, ".", 1) == 0) {
278 len = pkglen + applen + 1;
279 newapp = calloc(1,len);
280 if (newapp == NULL) {
281 DBG("Malloc failed\n");
284 strncpy(newapp, pkgid, pkglen);
285 strncat(newapp, appid, applen);
286 DBG("new appid is %s\n", newapp);
290 if (applen < pkglen) {
291 DBG("app id is not proper\n");
293 #ifdef _VALIDATE_APPID_
299 if (!strcmp(appid, pkgid)) {
300 DBG("appid is proper\n");
304 else if (strncmp(appid, pkgid, pkglen) == 0) {
305 ptr = strstr(appid, pkgid);
307 if (strncmp(ptr, ".", 1) == 0) {
308 DBG("appid is proper\n");
313 DBG("appid is not proper\n");
315 #ifdef _VALIDATE_APPID_
322 DBG("appid is not proper\n");
324 #ifdef _VALIDATE_APPID_
333 static char * __get_tag_by_key(char *md_key)
337 if (md_key == NULL) {
338 DBG("md_key is NULL\n");
342 md_tag = strrchr(md_key, 47) + 1;
345 return strdup(md_tag);
348 static char *__get_mdparser_plugin(const char *type)
351 char buffer[1024] = { 0 };
352 char temp_path[1024] = { 0 };
356 DBGE("invalid argument\n");
360 fp = fopen(PKG_PARSER_CONF_PATH, "r");
362 DBGE("no matching mdparser\n");
366 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
367 if (buffer[0] == '#')
372 if ((path = strstr(buffer, MDPARSER_NAME)) != NULL) {
373 path = path + strlen(MDPARSER_NAME);
378 memset(buffer, 0x00, 1024);
385 DBGE("no matching backendlib\n");
389 snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
391 return strdup(temp_path);
394 static char *__get_parser_plugin(const char *type)
397 char buffer[1024] = { 0 };
398 char temp_path[1024] = { 0 };
402 DBGE("invalid argument\n");
406 fp = fopen(PKG_PARSER_CONF_PATH, "r");
408 DBGE("no matching backendlib\n");
412 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
413 if (buffer[0] == '#')
418 if ((path = strstr(buffer, PKG_PARSERLIB)) != NULL) {
420 path = path + strlen(PKG_PARSERLIB);
426 memset(buffer, 0x00, 1024);
433 DBGE("no matching backendlib\n");
437 snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
438 DBG("[%s]\n", temp_path);
440 return strdup(temp_path);
443 static int __ps_run_mdparser(GList *md_list, const char *tag,
444 ACTION_TYPE action, const char *pkgid, const char *appid)
446 char *lib_path = NULL;
447 void *lib_handle = NULL;
448 int (*mdparser_plugin) (const char *, const char *, GList *);
454 ac = "PKGMGR_MDPARSER_PLUGIN_INSTALL";
457 ac = "PKGMGR_MDPARSER_PLUGIN_UPGRADE";
459 case ACTION_UNINSTALL:
460 ac = "PKGMGR_MDPARSER_PLUGIN_UNINSTALL";
466 lib_path = __get_mdparser_plugin(tag);
468 DBGE("__get_mdparser_plugin fail\n");
472 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
473 DBGE("dlopen is failed lib_path[%s]\n", lib_path);
477 if ((mdparser_plugin =
478 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
479 DBGE("can not find symbol \n");
483 ret = mdparser_plugin(pkgid, appid, md_list);
485 DBGE("[appid = %s, libpath = %s] plugin fail\n", appid, lib_path);
487 DBGE("[appid = %s, libpath = %s] plugin success\n", appid, lib_path);
497 static int __ps_run_parser(xmlDocPtr docPtr, const char *tag,
498 ACTION_TYPE action, const char *pkgid)
500 char *lib_path = NULL;
501 void *lib_handle = NULL;
502 int (*plugin_install) (xmlDocPtr, const char *);
508 ac = "PKGMGR_PARSER_PLUGIN_INSTALL";
511 ac = "PKGMGR_PARSER_PLUGIN_UPGRADE";
513 case ACTION_UNINSTALL:
514 ac = "PKGMGR_PARSER_PLUGIN_UNINSTALL";
520 lib_path = __get_parser_plugin(tag);
525 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
526 DBGE("dlopen is failed lib_path[%s]\n", lib_path);
529 if ((plugin_install =
530 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
531 DBGE("can not find symbol \n");
535 ret = plugin_install(docPtr, pkgid);
545 static char *__pkgid_to_manifest(const char *pkgid)
551 DBGE("pkgid is NULL");
555 size = strlen(MANIFEST_RW_DIRECTORY) + strlen(pkgid) + 10;
556 manifest = malloc(size);
557 if (manifest == NULL) {
561 memset(manifest, '\0', size);
562 snprintf(manifest, size, MANIFEST_RW_DIRECTORY "/%s.xml", pkgid);
564 if (access(manifest, F_OK)) {
565 snprintf(manifest, size, MANIFEST_RO_DIRECTORY "/%s.xml", pkgid);
571 static void __mdparser_clear_dir_list(GList* dir_list)
574 __metadata_t* detail = NULL;
577 list = g_list_first(dir_list);
579 detail = (__metadata_t *)list->data;
587 list = g_list_next(list);
589 g_list_free(dir_list);
593 static int __run_mdparser_prestep (manifest_x *mfx, char *md_key, ACTION_TYPE action)
597 char buffer[1024] = { 0, };
598 uiapplication_x *up = mfx->uiapplication;
599 metadata_x *md = NULL;
602 GList *md_list = NULL;
603 __metadata_t *md_detail = NULL;
605 md_tag = __get_tag_by_key(md_key);
606 if (md_tag == NULL) {
607 DBG("md_tag is NULL\n");
610 DBG("md_tag = %s\n", md_tag);
617 //get glist of meatdata key and value combination
618 memset(buffer, 0x00, 1024);
619 snprintf(buffer, 1024, "%s/", md_key);
620 if ((md->key && md->value) && (strncmp(md->key, md_key, strlen(md_key)) == 0) && (strncmp(buffer, md->key, strlen(buffer)) == 0)) {
621 md_detail = (__metadata_t*) calloc(1, sizeof(__metadata_t));
622 if (md_detail == NULL) {
623 DBG("Memory allocation failed\n");
627 md_detail->key = (char*) calloc(1, sizeof(char)*(strlen(md->key)+2));
628 if (md_detail->key == NULL) {
629 DBG("Memory allocation failed\n");
633 snprintf(md_detail->key, (strlen(md->key)+1), "%s", md->key);
635 md_detail->value = (char*) calloc(1, sizeof(char)*(strlen(md->value)+2));
636 if (md_detail->value == NULL) {
637 DBG("Memory allocation failed\n");
638 free(md_detail->key);
642 snprintf(md_detail->value, (strlen(md->value)+1), "%s", md->value);
644 md_list = g_list_append(md_list, (gpointer)md_detail);
650 //send glist to parser when tags for metadata plugin parser exist.
652 ret = __ps_run_mdparser(md_list, md_tag, action, mfx->package, up->appid);
654 DBG("mdparser failed[%d]\n", ret);
656 DBG("mdparser success, done[%d]\n", ret);
658 __mdparser_clear_dir_list(md_list);
666 __mdparser_clear_dir_list(md_list);
674 static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid)
679 DBG("__run_parser_prestep");
681 if (xmlTextReaderDepth(reader) != 1) {
682 DBGE("Node depth is not 1");
686 if (xmlTextReaderNodeType(reader) != 1) {
687 DBGE("Node type is not 1");
691 const xmlChar *value;
692 name = xmlTextReaderConstName(reader);
694 DBGE("TEST TEST TES\n");
695 name = BAD_CAST "--";
698 value = xmlTextReaderConstValue(reader);
699 DBG("%d %d %s %d %d",
700 xmlTextReaderDepth(reader),
701 xmlTextReaderNodeType(reader),
703 xmlTextReaderIsEmptyElement(reader), xmlTextReaderHasValue(reader));
706 DBG("ConstValue NULL");
708 if (xmlStrlen(value) > 40) {
709 DBG(" %.40s...", value);
715 name = xmlTextReaderConstName(reader);
717 DBGE("TEST TEST TES\n");
718 name = BAD_CAST "--";
721 xmlDocPtr docPtr = xmlTextReaderCurrentDoc(reader);
722 DBG("docPtr->URL %s\n", (char *)docPtr->URL);
723 xmlDocPtr copyDocPtr = xmlCopyDoc(docPtr, 1);
724 if (copyDocPtr == NULL)
726 xmlNode *rootElement = xmlDocGetRootElement(copyDocPtr);
727 if (rootElement == NULL)
729 xmlNode *cur_node = xmlFirstElementChild(rootElement);
730 if (cur_node == NULL)
732 xmlNode *temp = xmlTextReaderExpand(reader);
735 xmlNode *next_node = NULL;
736 while(cur_node != NULL) {
737 if ( (strcmp(ASCII(temp->name), ASCII(cur_node->name)) == 0) &&
738 (temp->line == cur_node->line) ) {
742 next_node = xmlNextElementSibling(cur_node);
743 xmlUnlinkNode(cur_node);
744 xmlFreeNode(cur_node);
745 cur_node = next_node;
748 if (cur_node == NULL)
750 next_node = xmlNextElementSibling(cur_node);
752 cur_node->next = NULL;
753 next_node->prev = NULL;
754 xmlFreeNodeList(next_node);
755 xmlSetTreeDoc(cur_node, copyDocPtr);
757 xmlSetTreeDoc(cur_node, copyDocPtr);
763 DBG("node type: %d, name: %s children->name: %s last->name: %s\n"
764 "parent->name: %s next->name: %s prev->name: %s\n",
765 cur_node->type, cur_node->name,
766 cur_node->children ? cur_node->children->name : "NULL",
767 cur_node->last ? cur_node->last->name : "NULL",
768 cur_node->parent ? cur_node->parent->name : "NULL",
769 cur_node->next ? cur_node->next->name : "NULL",
770 cur_node->prev ? cur_node->prev->name : "NULL");
772 FILE *fp = fopen("/opt/share/test.xml", "a");
773 xmlDocDump(fp, copyDocPtr);
778 ret = __ps_run_parser(copyDocPtr, ASCII(name), action, pkgid);
785 __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgid)
790 switch (xmlTextReaderNodeType(reader)) {
791 case XML_READER_TYPE_END_ELEMENT:
793 // DBG("XML_READER_TYPE_END_ELEMENT");
797 case XML_READER_TYPE_ELEMENT:
799 // Elements without closing tag don't receive
800 // XML_READER_TYPE_END_ELEMENT event.
802 const xmlChar *elementName =
803 xmlTextReaderLocalName(reader);
804 if (elementName == NULL) {
805 // DBG("elementName %s\n", (char *)elementName);
809 const xmlChar *nameSpace =
810 xmlTextReaderConstNamespaceUri(reader);
812 // DBG("nameSpace %s\n", (char *)nameSpace);
815 DBG("XML_READER_TYPE_ELEMENT %s, %s\n",
816 elementName ? elementName : "NULL",
817 nameSpace ? nameSpace : "NULL");
820 DBG("__run_parser_prestep pkgid[%s]\n", pkgid);
821 __run_parser_prestep(reader, action, pkgid);
825 for (tag = tagv[0]; tag; tag = tagv[++i])
826 if (strcmp(tag, ASCII(elementName)) == 0) {
827 DBG("__run_parser_prestep tag[%s] pkgid[%s]\n", tag, pkgid);
828 __run_parser_prestep(reader,
836 case XML_READER_TYPE_TEXT:
837 case XML_READER_TYPE_CDATA:
839 const xmlChar *value = xmlTextReaderConstValue(reader);
841 // DBG("value %s\n", value);
844 const xmlChar *lang = xmlTextReaderConstXmlLang(reader);
846 // DBG("lang\n", lang);
849 /* DBG("XML_READER_TYPE_TEXT %s, %s\n",
850 value ? value : "NULL", lang ? lang : "NULL");
855 // DBG("Ignoring Node of Type: %d", xmlTextReaderNodeType(reader));
861 __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid)
863 xmlTextReaderPtr reader;
867 docPtr = xmlReadFile(filename, NULL, 0);
868 reader = xmlReaderWalker(docPtr);
869 if (reader != NULL) {
870 ret = xmlTextReaderRead(reader);
872 __processNode(reader, action, tagv, pkgid);
873 ret = xmlTextReaderRead(reader);
875 xmlFreeTextReader(reader);
878 DBGE("%s : failed to parse", filename);
881 DBGE("Unable to open %s", filename);
885 static int __next_child_element(xmlTextReaderPtr reader, int depth)
887 int ret = xmlTextReaderRead(reader);
888 int cur = xmlTextReaderDepth(reader);
891 switch (xmlTextReaderNodeType(reader)) {
892 case XML_READER_TYPE_ELEMENT:
893 if (cur == depth + 1)
896 case XML_READER_TYPE_TEXT:
897 /*text is handled by each function separately*/
898 if (cur == depth + 1)
901 case XML_READER_TYPE_END_ELEMENT:
910 ret = xmlTextReaderRead(reader);
911 cur = xmlTextReaderDepth(reader);
916 static void __ps_free_category(category_x *category)
918 if (category == NULL)
920 if (category->name) {
921 free((void *)category->name);
922 category->name = NULL;
924 free((void*)category);
928 static void __ps_free_privilege(privilege_x *privilege)
930 if (privilege == NULL)
932 if (privilege->text) {
933 free((void *)privilege->text);
934 privilege->text = NULL;
936 free((void*)privilege);
940 static void __ps_free_privileges(privileges_x *privileges)
942 if (privileges == NULL)
945 if (privileges->privilege) {
946 privilege_x *privilege = privileges->privilege;
947 privilege_x *tmp = NULL;
948 while(privilege != NULL) {
949 tmp = privilege->next;
950 __ps_free_privilege(privilege);
954 free((void*)privileges);
958 static void __ps_free_metadata(metadata_x *metadata)
960 if (metadata == NULL)
963 free((void *)metadata->key);
964 metadata->key = NULL;
966 if (metadata->value) {
967 free((void *)metadata->value);
968 metadata->value = NULL;
970 free((void*)metadata);
974 static void __ps_free_permission(permission_x *permission)
976 if (permission == NULL)
978 if (permission->type) {
979 free((void *)permission->type);
980 permission->type = NULL;
982 if (permission->value) {
983 free((void *)permission->value);
984 permission->value = NULL;
986 free((void*)permission);
990 static void __ps_free_icon(icon_x *icon)
995 free((void *)icon->text);
999 free((void *)icon->lang);
1003 free((void *)icon->name);
1006 if (icon->section) {
1007 free((void *)icon->section);
1008 icon->section = NULL;
1011 free((void *)icon->size);
1014 if (icon->resolution) {
1015 free((void *)icon->resolution);
1016 icon->resolution = NULL;
1022 static void __ps_free_image(image_x *image)
1027 free((void *)image->text);
1031 free((void *)image->lang);
1035 free((void *)image->name);
1038 if (image->section) {
1039 free((void *)image->section);
1040 image->section = NULL;
1046 static void __ps_free_operation(operation_x *operation)
1048 if (operation == NULL)
1050 if (operation->text) {
1051 free((void *)operation->text);
1052 operation->text = NULL;
1054 free((void*)operation);
1058 static void __ps_free_uri(uri_x *uri)
1063 free((void *)uri->text);
1070 static void __ps_free_mime(mime_x *mime)
1075 free((void *)mime->text);
1082 static void __ps_free_subapp(subapp_x *subapp)
1087 free((void *)subapp->text);
1088 subapp->text = NULL;
1090 free((void*)subapp);
1094 static void __ps_free_condition(condition_x *condition)
1096 if (condition == NULL)
1098 if (condition->text) {
1099 free((void *)condition->text);
1100 condition->text = NULL;
1102 if (condition->name) {
1103 free((void *)condition->name);
1104 condition->name = NULL;
1106 free((void*)condition);
1110 static void __ps_free_notification(notification_x *notification)
1112 if (notification == NULL)
1114 if (notification->text) {
1115 free((void *)notification->text);
1116 notification->text = NULL;
1118 if (notification->name) {
1119 free((void *)notification->name);
1120 notification->name = NULL;
1122 free((void*)notification);
1123 notification = NULL;
1126 static void __ps_free_compatibility(compatibility_x *compatibility)
1128 if (compatibility == NULL)
1130 if (compatibility->text) {
1131 free((void *)compatibility->text);
1132 compatibility->text = NULL;
1134 if (compatibility->name) {
1135 free((void *)compatibility->name);
1136 compatibility->name = NULL;
1138 free((void*)compatibility);
1139 compatibility = NULL;
1142 static void __ps_free_resolution(resolution_x *resolution)
1144 if (resolution == NULL)
1146 if (resolution->mimetype) {
1147 free((void *)resolution->mimetype);
1148 resolution->mimetype = NULL;
1150 if (resolution->urischeme) {
1151 free((void *)resolution->urischeme);
1152 resolution->urischeme = NULL;
1154 free((void*)resolution);
1158 static void __ps_free_capability(capability_x *capability)
1160 if (capability == NULL)
1162 if (capability->operationid) {
1163 free((void *)capability->operationid);
1164 capability->operationid = NULL;
1167 if (capability->resolution) {
1168 resolution_x *resolution = capability->resolution;
1169 resolution_x *tmp = NULL;
1170 while(resolution != NULL) {
1171 tmp = resolution->next;
1172 __ps_free_resolution(resolution);
1176 free((void*)capability);
1180 static void __ps_free_allowed(allowed_x *allowed)
1182 if (allowed == NULL)
1184 if (allowed->name) {
1185 free((void *)allowed->name);
1186 allowed->name = NULL;
1188 if (allowed->text) {
1189 free((void *)allowed->text);
1190 allowed->text = NULL;
1192 free((void*)allowed);
1196 static void __ps_free_request(request_x *request)
1198 if (request == NULL)
1200 if (request->text) {
1201 free((void *)request->text);
1202 request->text = NULL;
1204 free((void*)request);
1208 static void __ps_free_datacontrol(datacontrol_x *datacontrol)
1210 if (datacontrol == NULL)
1212 if (datacontrol->providerid) {
1213 free((void *)datacontrol->providerid);
1214 datacontrol->providerid = NULL;
1217 if (datacontrol->capability) {
1218 capability_x *capability = datacontrol->capability;
1219 capability_x *tmp = NULL;
1220 while(capability != NULL) {
1221 tmp = capability->next;
1222 __ps_free_capability(capability);
1226 free((void*)datacontrol);
1230 static void __ps_free_launchconditions(launchconditions_x *launchconditions)
1232 if (launchconditions == NULL)
1234 if (launchconditions->text) {
1235 free((void *)launchconditions->text);
1236 launchconditions->text = NULL;
1239 if (launchconditions->condition) {
1240 condition_x *condition = launchconditions->condition;
1241 condition_x *tmp = NULL;
1242 while(condition != NULL) {
1243 tmp = condition->next;
1244 __ps_free_condition(condition);
1248 free((void*)launchconditions);
1249 launchconditions = NULL;
1252 static void __ps_free_appcontrol(appcontrol_x *appcontrol)
1254 if (appcontrol == NULL)
1256 if (appcontrol->text) {
1257 free((void *)appcontrol->text);
1258 appcontrol->text = NULL;
1261 if (appcontrol->operation) {
1262 operation_x *operation = appcontrol->operation;
1263 operation_x *tmp = NULL;
1264 while(operation != NULL) {
1265 tmp = operation->next;
1266 __ps_free_operation(operation);
1271 if (appcontrol->uri) {
1272 uri_x *uri = appcontrol->uri;
1274 while(uri != NULL) {
1281 if (appcontrol->mime) {
1282 mime_x *mime = appcontrol->mime;
1284 while(mime != NULL) {
1286 __ps_free_mime(mime);
1291 if (appcontrol->subapp) {
1292 subapp_x *subapp = appcontrol->subapp;
1293 subapp_x *tmp = NULL;
1294 while(subapp != NULL) {
1296 __ps_free_subapp(subapp);
1300 free((void*)appcontrol);
1304 static void __ps_free_appsvc(appsvc_x *appsvc)
1309 free((void *)appsvc->text);
1310 appsvc->text = NULL;
1313 if (appsvc->operation) {
1314 operation_x *operation = appsvc->operation;
1315 operation_x *tmp = NULL;
1316 while(operation != NULL) {
1317 tmp = operation->next;
1318 __ps_free_operation(operation);
1324 uri_x *uri = appsvc->uri;
1326 while(uri != NULL) {
1334 mime_x *mime = appsvc->mime;
1336 while(mime != NULL) {
1338 __ps_free_mime(mime);
1343 if (appsvc->subapp) {
1344 subapp_x *subapp = appsvc->subapp;
1345 subapp_x *tmp = NULL;
1346 while(subapp != NULL) {
1348 __ps_free_subapp(subapp);
1352 free((void*)appsvc);
1356 static void __ps_free_deviceprofile(deviceprofile_x *deviceprofile)
1361 static void __ps_free_define(define_x *define)
1366 free((void *)define->path);
1367 define->path = NULL;
1370 if (define->request) {
1371 request_x *request = define->request;
1372 request_x *tmp = NULL;
1373 while(request != NULL) {
1374 tmp = request->next;
1375 __ps_free_request(request);
1380 if (define->allowed) {
1381 allowed_x *allowed = define->allowed;
1382 allowed_x *tmp = NULL;
1383 while(allowed != NULL) {
1384 tmp = allowed->next;
1385 __ps_free_allowed(allowed);
1389 free((void*)define);
1393 static void __ps_free_datashare(datashare_x *datashare)
1395 if (datashare == NULL)
1398 if (datashare->define) {
1399 define_x *define = datashare->define;
1400 define_x *tmp = NULL;
1401 while(define != NULL) {
1403 __ps_free_define(define);
1408 if (datashare->request) {
1409 request_x *request = datashare->request;
1410 request_x *tmp = NULL;
1411 while(request != NULL) {
1412 tmp = request->next;
1413 __ps_free_request(request);
1417 free((void*)datashare);
1421 static void __ps_free_label(label_x *label)
1426 free((void *)label->name);
1430 free((void *)label->text);
1434 free((void *)label->lang);
1441 static void __ps_free_author(author_x *author)
1445 if (author->email) {
1446 free((void *)author->email);
1447 author->email = NULL;
1450 free((void *)author->text);
1451 author->text = NULL;
1454 free((void *)author->href);
1455 author->href = NULL;
1458 free((void *)author->lang);
1459 author->lang = NULL;
1461 free((void*)author);
1465 static void __ps_free_description(description_x *description)
1467 if (description == NULL)
1469 if (description->name) {
1470 free((void *)description->name);
1471 description->name = NULL;
1473 if (description->text) {
1474 free((void *)description->text);
1475 description->text = NULL;
1477 if (description->lang) {
1478 free((void *)description->lang);
1479 description->lang = NULL;
1481 free((void*)description);
1485 static void __ps_free_license(license_x *license)
1487 if (license == NULL)
1489 if (license->text) {
1490 free((void *)license->text);
1491 license->text = NULL;
1493 if (license->lang) {
1494 free((void *)license->lang);
1495 license->lang = NULL;
1497 free((void*)license);
1501 static void __ps_free_uiapplication(uiapplication_x *uiapplication)
1503 if (uiapplication == NULL)
1505 if (uiapplication->exec) {
1506 free((void *)uiapplication->exec);
1507 uiapplication->exec = NULL;
1509 if (uiapplication->appid) {
1510 free((void *)uiapplication->appid);
1511 uiapplication->appid = NULL;
1513 if (uiapplication->nodisplay) {
1514 free((void *)uiapplication->nodisplay);
1515 uiapplication->nodisplay = NULL;
1517 if (uiapplication->multiple) {
1518 free((void *)uiapplication->multiple);
1519 uiapplication->multiple = NULL;
1521 if (uiapplication->type) {
1522 free((void *)uiapplication->type);
1523 uiapplication->type = NULL;
1525 if (uiapplication->categories) {
1526 free((void *)uiapplication->categories);
1527 uiapplication->categories = NULL;
1529 if (uiapplication->extraid) {
1530 free((void *)uiapplication->extraid);
1531 uiapplication->extraid = NULL;
1533 if (uiapplication->taskmanage) {
1534 free((void *)uiapplication->taskmanage);
1535 uiapplication->taskmanage = NULL;
1537 if (uiapplication->enabled) {
1538 free((void *)uiapplication->enabled);
1539 uiapplication->enabled = NULL;
1541 if (uiapplication->hwacceleration) {
1542 free((void *)uiapplication->hwacceleration);
1543 uiapplication->hwacceleration = NULL;
1545 if (uiapplication->mainapp) {
1546 free((void *)uiapplication->mainapp);
1547 uiapplication->mainapp = NULL;
1549 if (uiapplication->recentimage) {
1550 free((void *)uiapplication->recentimage);
1551 uiapplication->recentimage = NULL;
1553 if (uiapplication->package) {
1554 free((void *)uiapplication->package);
1555 uiapplication->package = NULL;
1557 if (uiapplication->launchcondition) {
1558 free((void *)uiapplication->launchcondition);
1559 uiapplication->launchcondition = NULL;
1562 if (uiapplication->label) {
1563 label_x *label = uiapplication->label;
1564 label_x *tmp = NULL;
1565 while(label != NULL) {
1567 __ps_free_label(label);
1572 if (uiapplication->icon) {
1573 icon_x *icon = uiapplication->icon;
1575 while(icon != NULL) {
1577 __ps_free_icon(icon);
1582 if (uiapplication->image) {
1583 image_x *image = uiapplication->image;
1584 image_x *tmp = NULL;
1585 while(image != NULL) {
1587 __ps_free_image(image);
1592 if (uiapplication->appcontrol) {
1593 appcontrol_x *appcontrol = uiapplication->appcontrol;
1594 appcontrol_x *tmp = NULL;
1595 while(appcontrol != NULL) {
1596 tmp = appcontrol->next;
1597 __ps_free_appcontrol(appcontrol);
1601 /*Free LaunchConditions*/
1602 if (uiapplication->launchconditions) {
1603 launchconditions_x *launchconditions = uiapplication->launchconditions;
1604 launchconditions_x *tmp = NULL;
1605 while(launchconditions != NULL) {
1606 tmp = launchconditions->next;
1607 __ps_free_launchconditions(launchconditions);
1608 launchconditions = tmp;
1611 /*Free Notification*/
1612 if (uiapplication->notification) {
1613 notification_x *notification = uiapplication->notification;
1614 notification_x *tmp = NULL;
1615 while(notification != NULL) {
1616 tmp = notification->next;
1617 __ps_free_notification(notification);
1622 if (uiapplication->datashare) {
1623 datashare_x *datashare = uiapplication->datashare;
1624 datashare_x *tmp = NULL;
1625 while(datashare != NULL) {
1626 tmp = datashare->next;
1627 __ps_free_datashare(datashare);
1632 if (uiapplication->appsvc) {
1633 appsvc_x *appsvc = uiapplication->appsvc;
1634 appsvc_x *tmp = NULL;
1635 while(appsvc != NULL) {
1637 __ps_free_appsvc(appsvc);
1642 if (uiapplication->category) {
1643 category_x *category = uiapplication->category;
1644 category_x *tmp = NULL;
1645 while(category != NULL) {
1646 tmp = category->next;
1647 __ps_free_category(category);
1652 if (uiapplication->metadata) {
1653 metadata_x *metadata = uiapplication->metadata;
1654 metadata_x *tmp = NULL;
1655 while(metadata != NULL) {
1656 tmp = metadata->next;
1657 __ps_free_metadata(metadata);
1662 if (uiapplication->permission) {
1663 permission_x *permission = uiapplication->permission;
1664 permission_x *tmp = NULL;
1665 while(permission != NULL) {
1666 tmp = permission->next;
1667 __ps_free_permission(permission);
1671 /* _PRODUCT_LAUNCHING_ENHANCED_ START */
1672 if (uiapplication->indicatordisplay) {
1673 free((void *)uiapplication->indicatordisplay);
1674 uiapplication->indicatordisplay = NULL;
1676 if (uiapplication->portraitimg) {
1677 free((void *)uiapplication->portraitimg);
1678 uiapplication->portraitimg = NULL;
1680 if (uiapplication->landscapeimg) {
1681 free((void *)uiapplication->landscapeimg);
1682 uiapplication->landscapeimg = NULL;
1684 /* _PRODUCT_LAUNCHING_ENHANCED_ END */
1685 if (uiapplication->guestmode_visibility) {
1686 free((void *)uiapplication->guestmode_visibility);
1687 uiapplication->guestmode_visibility = NULL;
1689 if (uiapplication->app_component) {
1690 free((void *)uiapplication->app_component);
1691 uiapplication->app_component = NULL;
1693 if (uiapplication->permission_type) {
1694 free((void *)uiapplication->permission_type);
1695 uiapplication->permission_type = NULL;
1697 if (uiapplication->component_type) {
1698 free((void *)uiapplication->component_type);
1699 uiapplication->component_type = NULL;
1701 if (uiapplication->preload) {
1702 free((void *)uiapplication->preload);
1703 uiapplication->preload = NULL;
1705 if (uiapplication->submode) {
1706 free((void *)uiapplication->submode);
1707 uiapplication->submode = NULL;
1709 if (uiapplication->submode_mainid) {
1710 free((void *)uiapplication->submode_mainid);
1711 uiapplication->submode_mainid = NULL;
1714 free((void*)uiapplication);
1715 uiapplication = NULL;
1718 static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication)
1720 if (serviceapplication == NULL)
1722 if (serviceapplication->exec) {
1723 free((void *)serviceapplication->exec);
1724 serviceapplication->exec = NULL;
1726 if (serviceapplication->appid) {
1727 free((void *)serviceapplication->appid);
1728 serviceapplication->appid = NULL;
1730 if (serviceapplication->onboot) {
1731 free((void *)serviceapplication->onboot);
1732 serviceapplication->onboot = NULL;
1734 if (serviceapplication->autorestart) {
1735 free((void *)serviceapplication->autorestart);
1736 serviceapplication->autorestart = NULL;
1738 if (serviceapplication->type) {
1739 free((void *)serviceapplication->type);
1740 serviceapplication->type = NULL;
1742 if (serviceapplication->enabled) {
1743 free((void *)serviceapplication->enabled);
1744 serviceapplication->enabled = NULL;
1746 if (serviceapplication->package) {
1747 free((void *)serviceapplication->package);
1748 serviceapplication->package = NULL;
1750 if (serviceapplication->permission_type) {
1751 free((void *)serviceapplication->permission_type);
1752 serviceapplication->permission_type = NULL;
1755 if (serviceapplication->label) {
1756 label_x *label = serviceapplication->label;
1757 label_x *tmp = NULL;
1758 while(label != NULL) {
1760 __ps_free_label(label);
1765 if (serviceapplication->icon) {
1766 icon_x *icon = serviceapplication->icon;
1768 while(icon != NULL) {
1770 __ps_free_icon(icon);
1775 if (serviceapplication->appcontrol) {
1776 appcontrol_x *appcontrol = serviceapplication->appcontrol;
1777 appcontrol_x *tmp = NULL;
1778 while(appcontrol != NULL) {
1779 tmp = appcontrol->next;
1780 __ps_free_appcontrol(appcontrol);
1784 /*Free DataControl*/
1785 if (serviceapplication->datacontrol) {
1786 datacontrol_x *datacontrol = serviceapplication->datacontrol;
1787 datacontrol_x *tmp = NULL;
1788 while(datacontrol != NULL) {
1789 tmp = datacontrol->next;
1790 __ps_free_datacontrol(datacontrol);
1794 /*Free LaunchConditions*/
1795 if (serviceapplication->launchconditions) {
1796 launchconditions_x *launchconditions = serviceapplication->launchconditions;
1797 launchconditions_x *tmp = NULL;
1798 while(launchconditions != NULL) {
1799 tmp = launchconditions->next;
1800 __ps_free_launchconditions(launchconditions);
1801 launchconditions = tmp;
1804 /*Free Notification*/
1805 if (serviceapplication->notification) {
1806 notification_x *notification = serviceapplication->notification;
1807 notification_x *tmp = NULL;
1808 while(notification != NULL) {
1809 tmp = notification->next;
1810 __ps_free_notification(notification);
1815 if (serviceapplication->datashare) {
1816 datashare_x *datashare = serviceapplication->datashare;
1817 datashare_x *tmp = NULL;
1818 while(datashare != NULL) {
1819 tmp = datashare->next;
1820 __ps_free_datashare(datashare);
1825 if (serviceapplication->appsvc) {
1826 appsvc_x *appsvc = serviceapplication->appsvc;
1827 appsvc_x *tmp = NULL;
1828 while(appsvc != NULL) {
1830 __ps_free_appsvc(appsvc);
1835 if (serviceapplication->category) {
1836 category_x *category = serviceapplication->category;
1837 category_x *tmp = NULL;
1838 while(category != NULL) {
1839 tmp = category->next;
1840 __ps_free_category(category);
1845 if (serviceapplication->metadata) {
1846 metadata_x *metadata = serviceapplication->metadata;
1847 metadata_x *tmp = NULL;
1848 while(metadata != NULL) {
1849 tmp = metadata->next;
1850 __ps_free_metadata(metadata);
1855 if (serviceapplication->permission) {
1856 permission_x *permission = serviceapplication->permission;
1857 permission_x *tmp = NULL;
1858 while(permission != NULL) {
1859 tmp = permission->next;
1860 __ps_free_permission(permission);
1864 free((void*)serviceapplication);
1865 serviceapplication = NULL;
1868 static void __ps_free_font(font_x *font)
1873 free((void *)font->name);
1877 free((void *)font->text);
1884 static void __ps_free_theme(theme_x *theme)
1889 free((void *)theme->name);
1893 free((void *)theme->text);
1900 static void __ps_free_daemon(daemon_x *daemon)
1905 free((void *)daemon->name);
1906 daemon->name = NULL;
1909 free((void *)daemon->text);
1910 daemon->text = NULL;
1912 free((void*)daemon);
1916 static void __ps_free_ime(ime_x *ime)
1921 free((void *)ime->name);
1925 free((void *)ime->text);
1932 static void __ps_apply_shared_privileges(manifest_x * mfx, const char *manifest)
1936 if(strstr(manifest, MANIFEST_RO_PREFIX))
1941 if ((strcmp(mfx->type,"tpk")!=0) || (strcmp(mfx->type,"wgt")!=0)){
1942 DBG("rpm pkg is detected, apply smack\n");
1943 __apply_shared_privileges(mfx->package, home_dir);
1947 static void __ps_process_smack()
1950 char pkgid[PKG_STRING_LEN_MAX] = { 0 };
1952 fp = fopen(SMACK_LIST, "r");
1954 DBG("no preload list\n");
1958 while (fgets(pkgid, sizeof(pkgid), fp) != NULL) {
1960 DBG("pkgid = %s\n", pkgid);
1962 __apply_shared_privileges(pkgid,0);
1964 memset(pkgid, 0x00, sizeof(pkgid));
1973 int __ps_process_mdparser(manifest_x *mfx, ACTION_TYPE action)
1977 char md_key[PKG_STRING_LEN_MAX] = { 0 };
1979 fp = fopen(MDPARSER_LIST, "r");
1981 DBG("no preload list\n");
1985 while (fgets(md_key, sizeof(md_key), fp) != NULL) {
1987 DBG("md_key = %s\n", md_key);
1989 ret = __run_mdparser_prestep(mfx, md_key, action);
1991 memset(md_key, 0x00, sizeof(md_key));
2000 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed)
2002 xmlTextReaderRead(reader);
2003 if (xmlTextReaderValue(reader))
2004 allowed->text = ASCII(xmlTextReaderValue(reader));
2008 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation)
2010 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2011 operation->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2012 /* Text does not exist. Only attribute exists
2013 xmlTextReaderRead(reader);
2014 if (xmlTextReaderValue(reader))
2015 operation->text = ASCII(xmlTextReaderValue(reader));
2020 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri)
2022 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2023 uri->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2024 /* Text does not exist. Only attribute exists
2025 xmlTextReaderRead(reader);
2026 if (xmlTextReaderValue(reader))
2027 uri->text = ASCII(xmlTextReaderValue(reader));
2032 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime)
2034 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2035 mime->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2036 /* Text does not exist. Only attribute exists
2037 xmlTextReaderRead(reader);
2038 if (xmlTextReaderValue(reader))
2039 mime->text = ASCII(xmlTextReaderValue(reader));
2044 static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp)
2046 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2047 subapp->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2048 /* Text does not exist. Only attribute exists
2049 xmlTextReaderRead(reader);
2050 if (xmlTextReaderValue(reader))
2051 mime->text = ASCII(xmlTextReaderValue(reader));
2056 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition)
2058 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2059 condition->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2060 xmlTextReaderRead(reader);
2061 if (xmlTextReaderValue(reader))
2062 condition->text = ASCII(xmlTextReaderValue(reader));
2066 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notification)
2068 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2069 notification->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2070 xmlTextReaderRead(reader);
2071 if (xmlTextReaderValue(reader))
2072 notification->text = ASCII(xmlTextReaderValue(reader));
2076 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category)
2078 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2079 category->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2083 static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege)
2085 xmlTextReaderRead(reader);
2086 if (xmlTextReaderValue(reader)) {
2087 privilege->text = ASCII(xmlTextReaderValue(reader));
2092 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata)
2094 if (xmlTextReaderGetAttribute(reader, XMLCHAR("key")))
2095 metadata->key = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("key")));
2096 if (xmlTextReaderGetAttribute(reader, XMLCHAR("value")))
2097 metadata->value = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("value")));
2101 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission)
2103 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
2104 permission->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
2106 xmlTextReaderRead(reader);
2107 if (xmlTextReaderValue(reader))
2108 permission->value = ASCII(xmlTextReaderValue(reader));
2112 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility)
2114 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2115 compatibility->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2116 xmlTextReaderRead(reader);
2117 if (xmlTextReaderValue(reader))
2118 compatibility->text = ASCII(xmlTextReaderValue(reader));
2122 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution)
2124 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")))
2125 resolution->mimetype = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")));
2126 if (xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")))
2127 resolution->urischeme = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")));
2131 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request)
2133 xmlTextReaderRead(reader);
2134 if (xmlTextReaderValue(reader))
2135 request->text = ASCII(xmlTextReaderValue(reader));
2139 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define)
2141 const xmlChar *node;
2144 allowed_x *tmp1 = NULL;
2145 request_x *tmp2 = NULL;
2147 if (xmlTextReaderGetAttribute(reader, XMLCHAR("path")))
2148 define->path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("path")));
2150 depth = xmlTextReaderDepth(reader);
2151 while ((ret = __next_child_element(reader, depth))) {
2152 node = xmlTextReaderConstName(reader);
2154 DBG("xmlTextReaderConstName value is NULL\n");
2158 if (!strcmp(ASCII(node), "allowed")) {
2159 allowed_x *allowed= malloc(sizeof(allowed_x));
2160 if (allowed == NULL) {
2161 DBG("Malloc Failed\n");
2164 memset(allowed, '\0', sizeof(allowed_x));
2165 LISTADD(define->allowed, allowed);
2166 ret = __ps_process_allowed(reader, allowed);
2167 } else if (!strcmp(ASCII(node), "request")) {
2168 request_x *request = malloc(sizeof(request_x));
2169 if (request == NULL) {
2170 DBG("Malloc Failed\n");
2173 memset(request, '\0', sizeof(request_x));
2174 LISTADD(define->request, request);
2175 ret = __ps_process_request(reader, request);
2179 DBG("Processing define failed\n");
2183 if (define->allowed) {
2184 LISTHEAD(define->allowed, tmp1);
2185 define->allowed = tmp1;
2187 if (define->request) {
2188 LISTHEAD(define->request, tmp2);
2189 define->request = tmp2;
2194 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol)
2196 const xmlChar *node;
2199 operation_x *tmp1 = NULL;
2201 mime_x *tmp3 = NULL;
2202 subapp_x *tmp4 = NULL;
2204 depth = xmlTextReaderDepth(reader);
2205 while ((ret = __next_child_element(reader, depth))) {
2206 node = xmlTextReaderConstName(reader);
2208 DBG("xmlTextReaderConstName value is NULL\n");
2212 if (!strcmp(ASCII(node), "operation")) {
2213 operation_x *operation = malloc(sizeof(operation_x));
2214 if (operation == NULL) {
2215 DBG("Malloc Failed\n");
2218 memset(operation, '\0', sizeof(operation_x));
2219 LISTADD(appcontrol->operation, operation);
2220 ret = __ps_process_operation(reader, operation);
2221 DBG("operation processing\n");
2222 } else if (!strcmp(ASCII(node), "uri")) {
2223 uri_x *uri= malloc(sizeof(uri_x));
2225 DBG("Malloc Failed\n");
2228 memset(uri, '\0', sizeof(uri_x));
2229 LISTADD(appcontrol->uri, uri);
2230 ret = __ps_process_uri(reader, uri);
2231 DBG("uri processing\n");
2232 } else if (!strcmp(ASCII(node), "mime")) {
2233 mime_x *mime = malloc(sizeof(mime_x));
2235 DBG("Malloc Failed\n");
2238 memset(mime, '\0', sizeof(mime_x));
2239 LISTADD(appcontrol->mime, mime);
2240 ret = __ps_process_mime(reader, mime);
2241 DBG("mime processing\n");
2242 } else if (!strcmp(ASCII(node), "subapp")) {
2243 subapp_x *subapp = malloc(sizeof(subapp_x));
2244 if (subapp == NULL) {
2245 DBG("Malloc Failed\n");
2248 memset(subapp, '\0', sizeof(subapp_x));
2249 LISTADD(appcontrol->subapp, subapp);
2250 ret = __ps_process_subapp(reader, subapp);
2251 DBG("subapp processing\n");
2255 DBG("Processing appcontrol failed\n");
2259 if (appcontrol->operation) {
2260 LISTHEAD(appcontrol->operation, tmp1);
2261 appcontrol->operation = tmp1;
2263 if (appcontrol->uri) {
2264 LISTHEAD(appcontrol->uri, tmp2);
2265 appcontrol->uri = tmp2;
2267 if (appcontrol->mime) {
2268 LISTHEAD(appcontrol->mime, tmp3);
2269 appcontrol->mime = tmp3;
2271 if (appcontrol->subapp) {
2272 LISTHEAD(appcontrol->subapp, tmp4);
2273 appcontrol->subapp = tmp4;
2276 xmlTextReaderRead(reader);
2277 if (xmlTextReaderValue(reader))
2278 appcontrol->text = ASCII(xmlTextReaderValue(reader));
2283 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc)
2285 const xmlChar *node;
2288 operation_x *tmp1 = NULL;
2290 mime_x *tmp3 = NULL;
2291 subapp_x *tmp4 = NULL;
2293 depth = xmlTextReaderDepth(reader);
2294 while ((ret = __next_child_element(reader, depth))) {
2295 node = xmlTextReaderConstName(reader);
2297 DBG("xmlTextReaderConstName value is NULL\n");
2301 if (!strcmp(ASCII(node), "operation")) {
2302 operation_x *operation = malloc(sizeof(operation_x));
2303 if (operation == NULL) {
2304 DBG("Malloc Failed\n");
2307 memset(operation, '\0', sizeof(operation_x));
2308 LISTADD(appsvc->operation, operation);
2309 ret = __ps_process_operation(reader, operation);
2310 DBG("operation processing\n");
2311 } else if (!strcmp(ASCII(node), "uri")) {
2312 uri_x *uri= malloc(sizeof(uri_x));
2314 DBG("Malloc Failed\n");
2317 memset(uri, '\0', sizeof(uri_x));
2318 LISTADD(appsvc->uri, uri);
2319 ret = __ps_process_uri(reader, uri);
2320 DBG("uri processing\n");
2321 } else if (!strcmp(ASCII(node), "mime")) {
2322 mime_x *mime = malloc(sizeof(mime_x));
2324 DBG("Malloc Failed\n");
2327 memset(mime, '\0', sizeof(mime_x));
2328 LISTADD(appsvc->mime, mime);
2329 ret = __ps_process_mime(reader, mime);
2330 DBG("mime processing\n");
2331 } else if (!strcmp(ASCII(node), "subapp")) {
2332 subapp_x *subapp = malloc(sizeof(subapp_x));
2333 if (subapp == NULL) {
2334 DBG("Malloc Failed\n");
2337 memset(subapp, '\0', sizeof(subapp_x));
2338 LISTADD(appsvc->subapp, subapp);
2339 ret = __ps_process_subapp(reader, subapp);
2340 DBG("subapp processing\n");
2344 DBG("Processing appsvc failed\n");
2348 if (appsvc->operation) {
2349 LISTHEAD(appsvc->operation, tmp1);
2350 appsvc->operation = tmp1;
2353 LISTHEAD(appsvc->uri, tmp2);
2357 LISTHEAD(appsvc->mime, tmp3);
2358 appsvc->mime = tmp3;
2360 if (appsvc->subapp) {
2361 LISTHEAD(appsvc->subapp, tmp4);
2362 appsvc->subapp = tmp4;
2365 xmlTextReaderRead(reader);
2366 if (xmlTextReaderValue(reader))
2367 appsvc->text = ASCII(xmlTextReaderValue(reader));
2373 static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privileges)
2375 const xmlChar *node;
2378 privilege_x *tmp1 = NULL;
2380 depth = xmlTextReaderDepth(reader);
2381 while ((ret = __next_child_element(reader, depth))) {
2382 node = xmlTextReaderConstName(reader);
2384 DBG("xmlTextReaderConstName value is NULL\n");
2388 if (strcmp(ASCII(node), "privilege") == 0) {
2389 privilege_x *privilege = malloc(sizeof(privilege_x));
2390 if (privilege == NULL) {
2391 DBG("Malloc Failed\n");
2394 memset(privilege, '\0', sizeof(privilege_x));
2395 LISTADD(privileges->privilege, privilege);
2396 ret = __ps_process_privilege(reader, privilege);
2400 DBG("Processing privileges failed\n");
2404 if (privileges->privilege) {
2405 LISTHEAD(privileges->privilege, tmp1);
2406 privileges->privilege = tmp1;
2411 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions)
2413 const xmlChar *node;
2416 condition_x *tmp1 = NULL;
2418 depth = xmlTextReaderDepth(reader);
2419 while ((ret = __next_child_element(reader, depth))) {
2420 node = xmlTextReaderConstName(reader);
2422 DBG("xmlTextReaderConstName value is NULL\n");
2426 if (strcmp(ASCII(node), "condition") == 0) {
2427 condition_x *condition = malloc(sizeof(condition_x));
2428 if (condition == NULL) {
2429 DBG("Malloc Failed\n");
2432 memset(condition, '\0', sizeof(condition_x));
2433 LISTADD(launchconditions->condition, condition);
2434 ret = __ps_process_condition(reader, condition);
2438 DBG("Processing launchconditions failed\n");
2442 if (launchconditions->condition) {
2443 LISTHEAD(launchconditions->condition, tmp1);
2444 launchconditions->condition = tmp1;
2447 xmlTextReaderRead(reader);
2448 if (xmlTextReaderValue(reader))
2449 launchconditions->text = ASCII(xmlTextReaderValue(reader));
2454 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare)
2456 const xmlChar *node;
2459 define_x *tmp1 = NULL;
2460 request_x *tmp2 = NULL;
2461 depth = xmlTextReaderDepth(reader);
2462 while ((ret = __next_child_element(reader, depth))) {
2463 node = xmlTextReaderConstName(reader);
2465 DBG("xmlTextReaderConstName value is NULL\n");
2469 if (!strcmp(ASCII(node), "define")) {
2470 define_x *define= malloc(sizeof(define_x));
2471 if (define == NULL) {
2472 DBG("Malloc Failed\n");
2475 memset(define, '\0', sizeof(define_x));
2476 LISTADD(datashare->define, define);
2477 ret = __ps_process_define(reader, define);
2478 } else if (!strcmp(ASCII(node), "request")) {
2479 request_x *request= malloc(sizeof(request_x));
2480 if (request == NULL) {
2481 DBG("Malloc Failed\n");
2484 memset(request, '\0', sizeof(request_x));
2485 LISTADD(datashare->request, request);
2486 ret = __ps_process_request(reader, request);
2490 DBG("Processing data-share failed\n");
2494 if (datashare->define) {
2495 LISTHEAD(datashare->define, tmp1);
2496 datashare->define = tmp1;
2498 if (datashare->request) {
2499 LISTHEAD(datashare->request, tmp2);
2500 datashare->request = tmp2;
2506 __get_icon_with_path(const char* icon)
2511 if (index(icon, '/') == NULL) {
2513 char* icon_with_path = NULL;
2519 theme = vconf_get_str("db/setting/theme");
2521 theme = strdup("default");
2527 len = (0x01 << 7) + strlen(icon) + strlen(package) + strlen(theme);
2528 icon_with_path = malloc(len);
2529 if(icon_with_path == NULL) {
2530 DBG("(icon_with_path == NULL) return\n");
2535 memset(icon_with_path, 0, len);
2537 snprintf(icon_with_path, len, "/opt/share/icons/%s/small/%s", theme, icon);
2539 if (access(icon_with_path, R_OK) == 0) break;
2540 snprintf(icon_with_path, len, "/usr/share/icons/%s/small/%s", theme, icon);
2541 if (access(icon_with_path, R_OK) == 0) break;
2542 DBG("cannot find icon %s", icon_with_path);
2543 snprintf(icon_with_path, len,"/opt/share/icons/default/small/%s", icon);
2544 if (access(icon_with_path, R_OK) == 0) break;
2545 snprintf(icon_with_path, len, "/usr/share/icons/default/small/%s", icon);
2546 if (access(icon_with_path, R_OK) == 0) break;
2548 /* icon path is going to be moved intto the app directory */
2549 DBGE("icon file must be moved to %s", icon_with_path);
2550 snprintf(icon_with_path, len, "/opt/apps/%s/res/icons/%s/small/%s", package, theme, icon);
2551 if (access(icon_with_path, R_OK) == 0) break;
2552 snprintf(icon_with_path, len, "/usr/apps/%s/res/icons/%s/small/%s", package, theme, icon);
2553 if (access(icon_with_path, R_OK) == 0) break;
2554 DBG("cannot find icon %s", icon_with_path);
2555 snprintf(icon_with_path, len, "/opt/apps/%s/res/icons/default/small/%s", package, icon);
2556 if (access(icon_with_path, R_OK) == 0) break;
2557 snprintf(icon_with_path, len, "/usr/apps/%s/res/icons/default/small/%s", package, icon);
2558 if (access(icon_with_path, R_OK) == 0) break;
2559 snprintf(icon_with_path, len, "/usr/ug/res/images/%s/%s", package, icon);
2560 if (access(icon_with_path, R_OK) == 0) break;
2565 DBG("Icon path : %s ---> %s", icon, icon_with_path);
2567 return icon_with_path;
2569 char* confirmed_icon = NULL;
2571 confirmed_icon = strdup(icon);
2572 if (!confirmed_icon)
2574 return confirmed_icon;
2578 static void __ps_process_tag(manifest_x * mfx, char *const tagv[])
2581 char delims[] = "=";
2582 char *ret_result = NULL;
2588 for (tag = strdup(tagv[0]); tag != NULL; ) {
2589 ret_result = strtok(tag, delims);
2591 /*check tag : preload */
2592 if (strcmp(ret_result, "preload") == 0) {
2593 ret_result = strtok(NULL, delims);
2594 if (strcmp(ret_result, "true") == 0) {
2595 free((void *)mfx->preload);
2596 mfx->preload = strdup("true");
2597 } else if (strcmp(ret_result, "false") == 0) {
2598 free((void *)mfx->preload);
2599 mfx->preload = strdup("false");
2601 /*check tag : removable*/
2602 } else if (strcmp(ret_result, "removable") == 0) {
2603 ret_result = strtok(NULL, delims);
2604 if (strcmp(ret_result, "true") == 0){
2605 free((void *)mfx->removable);
2606 mfx->removable = strdup("true");
2607 } else if (strcmp(ret_result, "false") == 0) {
2608 free((void *)mfx->removable);
2609 mfx->removable = strdup("false");
2611 /*check tag : not matched*/
2613 DBG("tag process [%s]is not defined\n", ret_result);
2617 /*check next value*/
2618 if (tagv[++i] != NULL)
2619 tag = strdup(tagv[i]);
2621 DBG("tag process success...\n");
2627 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon)
2629 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2630 icon->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2631 if (xmlTextReaderConstXmlLang(reader)) {
2632 icon->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2633 if (icon->lang == NULL)
2634 icon->lang = strdup(DEFAULT_LOCALE);
2636 icon->lang = strdup(DEFAULT_LOCALE);
2638 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
2639 icon->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
2640 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
2641 icon->size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
2642 if (xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")))
2643 icon->resolution = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")));
2644 xmlTextReaderRead(reader);
2645 if (xmlTextReaderValue(reader)) {
2646 const char *text = ASCII(xmlTextReaderValue(reader));
2648 icon->text = (const char *)__get_icon_with_path(text);
2656 static int __ps_process_image(xmlTextReaderPtr reader, image_x *image)
2658 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2659 image->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2660 if (xmlTextReaderConstXmlLang(reader)) {
2661 image->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2662 if (image->lang == NULL)
2663 image->lang = strdup(DEFAULT_LOCALE);
2665 image->lang = strdup(DEFAULT_LOCALE);
2667 if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
2668 image->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
2669 xmlTextReaderRead(reader);
2670 if (xmlTextReaderValue(reader))
2671 image->text = ASCII(xmlTextReaderValue(reader));
2676 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label)
2678 if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
2679 label->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
2680 if (xmlTextReaderConstXmlLang(reader)) {
2681 label->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2682 if (label->lang == NULL)
2683 label->lang = strdup(DEFAULT_LOCALE);
2685 label->lang = strdup(DEFAULT_LOCALE);
2687 xmlTextReaderRead(reader);
2688 if (xmlTextReaderValue(reader))
2689 label->text = ASCII(xmlTextReaderValue(reader));
2691 /* DBG("lable name %s\n", label->name);
2692 DBG("lable lang %s\n", label->lang);
2693 DBG("lable text %s\n", label->text);
2699 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author)
2701 if (xmlTextReaderGetAttribute(reader, XMLCHAR("email")))
2702 author->email = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("email")));
2703 if (xmlTextReaderGetAttribute(reader, XMLCHAR("href")))
2704 author->href = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("href")));
2705 if (xmlTextReaderConstXmlLang(reader)) {
2706 author->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2707 if (author->lang == NULL)
2708 author->lang = strdup(DEFAULT_LOCALE);
2710 author->lang = strdup(DEFAULT_LOCALE);
2712 xmlTextReaderRead(reader);
2713 if (xmlTextReaderValue(reader))
2714 author->text = ASCII(xmlTextReaderValue(reader));
2718 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description)
2720 if (xmlTextReaderConstXmlLang(reader)) {
2721 description->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2722 if (description->lang == NULL)
2723 description->lang = strdup(DEFAULT_LOCALE);
2725 description->lang = strdup(DEFAULT_LOCALE);
2727 xmlTextReaderRead(reader);
2728 if (xmlTextReaderValue(reader))
2729 description->text = ASCII(xmlTextReaderValue(reader));
2733 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license)
2735 if (xmlTextReaderConstXmlLang(reader)) {
2736 license->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
2737 if (license->lang == NULL)
2738 license->lang = strdup(DEFAULT_LOCALE);
2740 license->lang = strdup(DEFAULT_LOCALE);
2742 xmlTextReaderRead(reader);
2743 if (xmlTextReaderValue(reader))
2744 license->text = ASCII(xmlTextReaderValue(reader));
2748 static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability)
2750 const xmlChar *node;
2753 resolution_x *tmp1 = NULL;
2755 if (xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")))
2756 capability->operationid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")));
2758 depth = xmlTextReaderDepth(reader);
2759 while ((ret = __next_child_element(reader, depth))) {
2760 node = xmlTextReaderConstName(reader);
2762 DBG("xmlTextReaderConstName value is NULL\n");
2766 if (!strcmp(ASCII(node), "resolution")) {
2767 resolution_x *resolution = malloc(sizeof(resolution_x));
2768 if (resolution == NULL) {
2769 DBG("Malloc Failed\n");
2772 memset(resolution, '\0', sizeof(resolution_x));
2773 LISTADD(capability->resolution, resolution);
2774 ret = __ps_process_resolution(reader, resolution);
2778 DBG("Processing capability failed\n");
2783 if (capability->resolution) {
2784 LISTHEAD(capability->resolution, tmp1);
2785 capability->resolution = tmp1;
2791 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol)
2793 const xmlChar *node;
2796 capability_x *tmp1 = NULL;
2798 if (xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")))
2799 datacontrol->providerid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")));
2801 depth = xmlTextReaderDepth(reader);
2802 while ((ret = __next_child_element(reader, depth))) {
2803 node = xmlTextReaderConstName(reader);
2805 DBG("xmlTextReaderConstName value is NULL\n");
2809 if (!strcmp(ASCII(node), "capability")) {
2810 capability_x *capability = malloc(sizeof(capability_x));
2811 if (capability == NULL) {
2812 DBG("Malloc Failed\n");
2815 memset(capability, '\0', sizeof(capability_x));
2816 LISTADD(datacontrol->capability, capability);
2817 ret = __ps_process_capability(reader, capability);
2821 DBG("Processing datacontrol failed\n");
2826 if (datacontrol->capability) {
2827 LISTHEAD(datacontrol->capability, tmp1);
2828 datacontrol->capability = tmp1;
2834 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication)
2836 const xmlChar *node;
2839 char *newappid = NULL;
2840 label_x *tmp1 = NULL;
2841 icon_x *tmp2 = NULL;
2842 appsvc_x *tmp3 = NULL;
2843 appcontrol_x *tmp4 = NULL;
2844 launchconditions_x *tmp5 = NULL;
2845 notification_x *tmp6 = NULL;
2846 datashare_x *tmp7 = NULL;
2847 category_x *tmp8 = NULL;
2848 metadata_x *tmp9 = NULL;
2849 image_x *tmp10 = NULL;
2850 permission_x *tmp11 = NULL;
2852 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
2853 uiapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
2854 if (uiapplication->appid == NULL) {
2855 DBG("appid cant be NULL\n");
2859 DBG("appid is mandatory\n");
2863 ret = __validate_appid(package, uiapplication->appid, &newappid);
2865 DBG("appid is not proper\n");
2869 if (uiapplication->appid)
2870 free((void *)uiapplication->appid);
2871 uiapplication->appid = newappid;
2873 uiapplication->package= strdup(package);
2875 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
2876 uiapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
2877 if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay"))) {
2878 uiapplication->nodisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay")));
2879 if (uiapplication->nodisplay == NULL)
2880 uiapplication->nodisplay = strdup("false");
2882 uiapplication->nodisplay = strdup("false");
2884 if (xmlTextReaderGetAttribute(reader, XMLCHAR("multiple"))) {
2885 uiapplication->multiple = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("multiple")));
2886 if (uiapplication->multiple == NULL)
2887 uiapplication->multiple = strdup("false");
2889 uiapplication->multiple = strdup("false");
2891 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
2892 uiapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
2893 if (xmlTextReaderGetAttribute(reader, XMLCHAR("categories")))
2894 uiapplication->categories = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("categories")));
2895 if (xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")))
2896 uiapplication->extraid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")));
2897 if (xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage"))) {
2898 uiapplication->taskmanage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage")));
2899 if (uiapplication->taskmanage == NULL)
2900 uiapplication->taskmanage = strdup("true");
2902 uiapplication->taskmanage = strdup("true");
2904 if (xmlTextReaderGetAttribute(reader, XMLCHAR("enabled"))) {
2905 uiapplication->enabled = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("enabled")));
2906 if (uiapplication->enabled == NULL)
2907 uiapplication->enabled = strdup("true");
2909 uiapplication->enabled = strdup("true");
2911 if (xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration"))) {
2912 uiapplication->hwacceleration = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration")));
2913 if (uiapplication->hwacceleration == NULL)
2914 uiapplication->hwacceleration = strdup("use-system-setting");
2916 uiapplication->hwacceleration = strdup("use-system-setting");
2918 if (xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")))
2919 uiapplication->recentimage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")));
2920 if (xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp"))) {
2921 uiapplication->mainapp = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp")));
2922 if (uiapplication->mainapp == NULL)
2923 uiapplication->mainapp = strdup("false");
2925 uiapplication->mainapp = strdup("false");
2927 if (xmlTextReaderGetAttribute(reader, XMLCHAR("launchcondition"))) {
2928 uiapplication->launchcondition = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("launchcondition")));
2929 if (uiapplication->launchcondition == NULL)
2930 uiapplication->launchcondition = strdup("false");
2932 uiapplication->launchcondition = strdup("false");
2935 if (xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay"))) {
2936 uiapplication->indicatordisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay")));
2937 if (uiapplication->indicatordisplay == NULL)
2938 uiapplication->indicatordisplay = strdup("true");
2940 uiapplication->indicatordisplay = strdup("true");
2942 if (xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")))
2943 uiapplication->portraitimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")));
2945 uiapplication->portraitimg = NULL;
2946 if (xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")))
2947 uiapplication->landscapeimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")));
2949 uiapplication->landscapeimg = NULL;
2950 if (xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility"))) {
2951 uiapplication->guestmode_visibility = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility")));
2952 if (uiapplication->guestmode_visibility == NULL)
2953 uiapplication->guestmode_visibility = strdup("true");
2955 uiapplication->guestmode_visibility = strdup("true");
2957 if (xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type"))) {
2958 uiapplication->permission_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type")));
2959 if (uiapplication->permission_type == NULL)
2960 uiapplication->permission_type = strdup("normal");
2962 uiapplication->permission_type = strdup("normal");
2964 if (xmlTextReaderGetAttribute(reader, XMLCHAR("component-type"))) {
2965 uiapplication->component_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("component-type")));
2966 if (uiapplication->component_type == NULL)
2967 uiapplication->component_type = strdup("uiapp");
2969 uiapplication->component_type = strdup("uiapp");
2971 if (xmlTextReaderGetAttribute(reader, XMLCHAR("submode"))) {
2972 uiapplication->submode = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("submode")));
2973 if (uiapplication->submode == NULL)
2974 uiapplication->submode = strdup("false");
2976 uiapplication->submode = strdup("false");
2978 if (xmlTextReaderGetAttribute(reader, XMLCHAR("submode-mainid")))
2979 uiapplication->submode_mainid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("submode-mainid")));
2981 depth = xmlTextReaderDepth(reader);
2982 while ((ret = __next_child_element(reader, depth))) {
2983 node = xmlTextReaderConstName(reader);
2985 DBG("xmlTextReaderConstName value is NULL\n");
2988 if (!strcmp(ASCII(node), "label")) {
2989 label_x *label = malloc(sizeof(label_x));
2990 if (label == NULL) {
2991 DBG("Malloc Failed\n");
2994 memset(label, '\0', sizeof(label_x));
2995 LISTADD(uiapplication->label, label);
2996 ret = __ps_process_label(reader, label);
2997 } else if (!strcmp(ASCII(node), "icon")) {
2998 icon_x *icon = malloc(sizeof(icon_x));
3000 DBG("Malloc Failed\n");
3003 memset(icon, '\0', sizeof(icon_x));
3004 LISTADD(uiapplication->icon, icon);
3005 ret = __ps_process_icon(reader, icon);
3006 } else if (!strcmp(ASCII(node), "image")) {
3007 image_x *image = malloc(sizeof(image_x));
3008 if (image == NULL) {
3009 DBG("Malloc Failed\n");
3012 memset(image, '\0', sizeof(image_x));
3013 LISTADD(uiapplication->image, image);
3014 ret = __ps_process_image(reader, image);
3015 } else if (!strcmp(ASCII(node), "category")) {
3016 category_x *category = malloc(sizeof(category_x));
3017 if (category == NULL) {
3018 DBG("Malloc Failed\n");
3021 memset(category, '\0', sizeof(category_x));
3022 LISTADD(uiapplication->category, category);
3023 ret = __ps_process_category(reader, category);
3024 } else if (!strcmp(ASCII(node), "metadata")) {
3025 metadata_x *metadata = malloc(sizeof(metadata_x));
3026 if (metadata == NULL) {
3027 DBG("Malloc Failed\n");
3030 memset(metadata, '\0', sizeof(metadata_x));
3031 LISTADD(uiapplication->metadata, metadata);
3032 ret = __ps_process_metadata(reader, metadata);
3033 } else if (!strcmp(ASCII(node), "permission")) {
3034 permission_x *permission = malloc(sizeof(permission_x));
3035 if (permission == NULL) {
3036 DBG("Malloc Failed\n");
3039 memset(permission, '\0', sizeof(permission_x));
3040 LISTADD(uiapplication->permission, permission);
3041 ret = __ps_process_permission(reader, permission);
3042 } else if (!strcmp(ASCII(node), "app-control")) {
3043 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
3044 if (appcontrol == NULL) {
3045 DBG("Malloc Failed\n");
3048 memset(appcontrol, '\0', sizeof(appcontrol_x));
3049 LISTADD(uiapplication->appcontrol, appcontrol);
3050 ret = __ps_process_appcontrol(reader, appcontrol);
3051 } else if (!strcmp(ASCII(node), "application-service")) {
3052 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
3053 if (appsvc == NULL) {
3054 DBG("Malloc Failed\n");
3057 memset(appsvc, '\0', sizeof(appsvc_x));
3058 LISTADD(uiapplication->appsvc, appsvc);
3059 ret = __ps_process_appsvc(reader, appsvc);
3060 } else if (!strcmp(ASCII(node), "data-share")) {
3061 datashare_x *datashare = malloc(sizeof(datashare_x));
3062 if (datashare == NULL) {
3063 DBG("Malloc Failed\n");
3066 memset(datashare, '\0', sizeof(datashare_x));
3067 LISTADD(uiapplication->datashare, datashare);
3068 ret = __ps_process_datashare(reader, datashare);
3069 } else if (!strcmp(ASCII(node), "launch-conditions")) {
3070 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
3071 if (launchconditions == NULL) {
3072 DBG("Malloc Failed\n");
3075 memset(launchconditions, '\0', sizeof(launchconditions_x));
3076 LISTADD(uiapplication->launchconditions, launchconditions);
3077 ret = __ps_process_launchconditions(reader, launchconditions);
3078 } else if (!strcmp(ASCII(node), "notification")) {
3079 notification_x *notification = malloc(sizeof(notification_x));
3080 if (notification == NULL) {
3081 DBG("Malloc Failed\n");
3084 memset(notification, '\0', sizeof(notification_x));
3085 LISTADD(uiapplication->notification, notification);
3086 ret = __ps_process_notification(reader, notification);
3090 DBG("Processing uiapplication failed\n");
3095 if (uiapplication->label) {
3096 LISTHEAD(uiapplication->label, tmp1);
3097 uiapplication->label = tmp1;
3099 if (uiapplication->icon) {
3100 LISTHEAD(uiapplication->icon, tmp2);
3101 uiapplication->icon = tmp2;
3103 if (uiapplication->appsvc) {
3104 LISTHEAD(uiapplication->appsvc, tmp3);
3105 uiapplication->appsvc = tmp3;
3107 if (uiapplication->appcontrol) {
3108 LISTHEAD(uiapplication->appcontrol, tmp4);
3109 uiapplication->appcontrol = tmp4;
3111 if (uiapplication->launchconditions) {
3112 LISTHEAD(uiapplication->launchconditions, tmp5);
3113 uiapplication->launchconditions = tmp5;
3115 if (uiapplication->notification) {
3116 LISTHEAD(uiapplication->notification, tmp6);
3117 uiapplication->notification = tmp6;
3119 if (uiapplication->datashare) {
3120 LISTHEAD(uiapplication->datashare, tmp7);
3121 uiapplication->datashare = tmp7;
3123 if (uiapplication->category) {
3124 LISTHEAD(uiapplication->category, tmp8);
3125 uiapplication->category = tmp8;
3127 if (uiapplication->metadata) {
3128 LISTHEAD(uiapplication->metadata, tmp9);
3129 uiapplication->metadata = tmp9;
3131 if (uiapplication->image) {
3132 LISTHEAD(uiapplication->image, tmp10);
3133 uiapplication->image = tmp10;
3135 if (uiapplication->permission) {
3136 LISTHEAD(uiapplication->permission, tmp11);
3137 uiapplication->permission = tmp11;
3143 static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication)
3145 const xmlChar *node;
3148 char *newappid = NULL;
3149 label_x *tmp1 = NULL;
3150 icon_x *tmp2 = NULL;
3151 appsvc_x *tmp3 = NULL;
3152 appcontrol_x *tmp4 = NULL;
3153 datacontrol_x *tmp5 = NULL;
3154 launchconditions_x *tmp6 = NULL;
3155 notification_x *tmp7 = NULL;
3156 datashare_x *tmp8 = NULL;
3157 category_x *tmp9 = NULL;
3158 metadata_x *tmp10 = NULL;
3159 permission_x *tmp11 = NULL;
3161 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
3162 serviceapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
3163 if (serviceapplication->appid == NULL) {
3164 DBG("appid cant be NULL\n");
3168 DBG("appid is mandatory\n");
3172 ret = __validate_appid(package, serviceapplication->appid, &newappid);
3174 DBG("appid is not proper\n");
3178 if (serviceapplication->appid)
3179 free((void *)serviceapplication->appid);
3180 serviceapplication->appid = newappid;
3183 if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
3184 serviceapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
3185 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
3186 serviceapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
3187 if (xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot"))) {
3188 serviceapplication->onboot = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot")));
3189 if (serviceapplication->onboot == NULL)
3190 serviceapplication->onboot = strdup("false");
3192 serviceapplication->onboot = strdup("false");
3194 if (xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart"))) {
3195 serviceapplication->autorestart = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart")));
3196 if (serviceapplication->autorestart == NULL)
3197 serviceapplication->autorestart = strdup("false");
3199 serviceapplication->autorestart = strdup("false");
3201 if (xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type"))) {
3202 serviceapplication->permission_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type")));
3203 if (serviceapplication->permission_type == NULL)
3204 serviceapplication->permission_type = strdup("normal");
3206 serviceapplication->permission_type = strdup("normal");
3209 depth = xmlTextReaderDepth(reader);
3210 while ((ret = __next_child_element(reader, depth))) {
3211 node = xmlTextReaderConstName(reader);
3213 DBG("xmlTextReaderConstName value is NULL\n");
3217 if (!strcmp(ASCII(node), "label")) {
3218 label_x *label = malloc(sizeof(label_x));
3219 if (label == NULL) {
3220 DBG("Malloc Failed\n");
3223 memset(label, '\0', sizeof(label_x));
3224 LISTADD(serviceapplication->label, label);
3225 ret = __ps_process_label(reader, label);
3226 } else if (!strcmp(ASCII(node), "icon")) {
3227 icon_x *icon = malloc(sizeof(icon_x));
3229 DBG("Malloc Failed\n");
3232 memset(icon, '\0', sizeof(icon_x));
3233 LISTADD(serviceapplication->icon, icon);
3234 ret = __ps_process_icon(reader, icon);
3235 } else if (!strcmp(ASCII(node), "category")) {
3236 category_x *category = malloc(sizeof(category_x));
3237 if (category == NULL) {
3238 DBG("Malloc Failed\n");
3241 memset(category, '\0', sizeof(category_x));
3242 LISTADD(serviceapplication->category, category);
3243 ret = __ps_process_category(reader, category);
3244 } else if (!strcmp(ASCII(node), "metadata")) {
3245 metadata_x *metadata = malloc(sizeof(metadata_x));
3246 if (metadata == NULL) {
3247 DBG("Malloc Failed\n");
3250 memset(metadata, '\0', sizeof(metadata_x));
3251 LISTADD(serviceapplication->metadata, metadata);
3252 ret = __ps_process_metadata(reader, metadata);
3253 } else if (!strcmp(ASCII(node), "permission")) {
3254 permission_x *permission = malloc(sizeof(permission_x));
3255 if (permission == NULL) {
3256 DBG("Malloc Failed\n");
3259 memset(permission, '\0', sizeof(permission_x));
3260 LISTADD(serviceapplication->permission, permission);
3261 ret = __ps_process_permission(reader, permission);
3262 } else if (!strcmp(ASCII(node), "app-control")) {
3263 appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
3264 if (appcontrol == NULL) {
3265 DBG("Malloc Failed\n");
3268 memset(appcontrol, '\0', sizeof(appcontrol_x));
3269 LISTADD(serviceapplication->appcontrol, appcontrol);
3270 ret = __ps_process_appcontrol(reader, appcontrol);
3271 } else if (!strcmp(ASCII(node), "application-service")) {
3272 appsvc_x *appsvc = malloc(sizeof(appsvc_x));
3273 if (appsvc == NULL) {
3274 DBG("Malloc Failed\n");
3277 memset(appsvc, '\0', sizeof(appsvc_x));
3278 LISTADD(serviceapplication->appsvc, appsvc);
3279 ret = __ps_process_appsvc(reader, appsvc);
3280 } else if (!strcmp(ASCII(node), "data-share")) {
3281 datashare_x *datashare = malloc(sizeof(datashare_x));
3282 if (datashare == NULL) {
3283 DBG("Malloc Failed\n");
3286 memset(datashare, '\0', sizeof(datashare_x));
3287 LISTADD(serviceapplication->datashare, datashare);
3288 ret = __ps_process_datashare(reader, datashare);
3289 } else if (!strcmp(ASCII(node), "launch-conditions")) {
3290 launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
3291 if (launchconditions == NULL) {
3292 DBG("Malloc Failed\n");
3295 memset(launchconditions, '\0', sizeof(launchconditions_x));
3296 LISTADD(serviceapplication->launchconditions, launchconditions);
3297 ret = __ps_process_launchconditions(reader, launchconditions);
3298 } else if (!strcmp(ASCII(node), "notification")) {
3299 notification_x *notification = malloc(sizeof(notification_x));
3300 if (notification == NULL) {
3301 DBG("Malloc Failed\n");
3304 memset(notification, '\0', sizeof(notification_x));
3305 LISTADD(serviceapplication->notification, notification);
3306 ret = __ps_process_notification(reader, notification);
3307 } else if (!strcmp(ASCII(node), "data-control")) {
3308 datacontrol_x *datacontrol = malloc(sizeof(datacontrol_x));
3309 if (datacontrol == NULL) {
3310 DBG("Malloc Failed\n");
3313 memset(datacontrol, '\0', sizeof(datacontrol_x));
3314 LISTADD(serviceapplication->datacontrol, datacontrol);
3315 ret = __ps_process_datacontrol(reader, datacontrol);
3319 DBG("Processing serviceapplication failed\n");
3324 if (serviceapplication->label) {
3325 LISTHEAD(serviceapplication->label, tmp1);
3326 serviceapplication->label = tmp1;
3328 if (serviceapplication->icon) {
3329 LISTHEAD(serviceapplication->icon, tmp2);
3330 serviceapplication->icon = tmp2;
3332 if (serviceapplication->appsvc) {
3333 LISTHEAD(serviceapplication->appsvc, tmp3);
3334 serviceapplication->appsvc = tmp3;
3336 if (serviceapplication->appcontrol) {
3337 LISTHEAD(serviceapplication->appcontrol, tmp4);
3338 serviceapplication->appcontrol = tmp4;
3340 if (serviceapplication->datacontrol) {
3341 LISTHEAD(serviceapplication->datacontrol, tmp5);
3342 serviceapplication->datacontrol = tmp5;
3344 if (serviceapplication->launchconditions) {
3345 LISTHEAD(serviceapplication->launchconditions, tmp6);
3346 serviceapplication->launchconditions = tmp6;
3348 if (serviceapplication->notification) {
3349 LISTHEAD(serviceapplication->notification, tmp7);
3350 serviceapplication->notification = tmp7;
3352 if (serviceapplication->datashare) {
3353 LISTHEAD(serviceapplication->datashare, tmp8);
3354 serviceapplication->datashare = tmp8;
3356 if (serviceapplication->category) {
3357 LISTHEAD(serviceapplication->category, tmp9);
3358 serviceapplication->category = tmp9;
3360 if (serviceapplication->metadata) {
3361 LISTHEAD(serviceapplication->metadata, tmp10);
3362 serviceapplication->metadata = tmp10;
3364 if (serviceapplication->permission) {
3365 LISTHEAD(serviceapplication->permission, tmp11);
3366 serviceapplication->permission = tmp11;
3372 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile)
3374 /*TODO: once policy is set*/
3378 static int __ps_process_font(xmlTextReaderPtr reader, font_x *font)
3380 /*TODO: once policy is set*/
3384 static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme)
3386 /*TODO: once policy is set*/
3390 static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon)
3392 /*TODO: once policy is set*/
3396 static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime)
3398 /*TODO: once policy is set*/
3402 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx)
3404 DBG("__start_process\n");
3405 const xmlChar *node;
3408 label_x *tmp1 = NULL;
3409 author_x *tmp2 = NULL;
3410 description_x *tmp3 = NULL;
3411 license_x *tmp4 = NULL;
3412 uiapplication_x *tmp5 = NULL;
3413 serviceapplication_x *tmp6 = NULL;
3414 daemon_x *tmp7 = NULL;
3415 theme_x *tmp8 = NULL;
3416 font_x *tmp9 = NULL;
3417 ime_x *tmp10 = NULL;
3418 icon_x *tmp11 = NULL;
3419 compatibility_x *tmp12 = NULL;
3420 deviceprofile_x *tmp13 = NULL;
3421 privileges_x *tmp14 = NULL;
3423 depth = xmlTextReaderDepth(reader);
3424 while ((ret = __next_child_element(reader, depth))) {
3425 node = xmlTextReaderConstName(reader);
3427 DBG("xmlTextReaderConstName value is NULL\n");
3431 if (!strcmp(ASCII(node), "label")) {
3432 label_x *label = malloc(sizeof(label_x));
3433 if (label == NULL) {
3434 DBG("Malloc Failed\n");
3437 memset(label, '\0', sizeof(label_x));
3438 LISTADD(mfx->label, label);
3439 ret = __ps_process_label(reader, label);
3440 } else if (!strcmp(ASCII(node), "author")) {
3441 author_x *author = malloc(sizeof(author_x));
3442 if (author == NULL) {
3443 DBG("Malloc Failed\n");
3446 memset(author, '\0', sizeof(author_x));
3447 LISTADD(mfx->author, author);
3448 ret = __ps_process_author(reader, author);
3449 } else if (!strcmp(ASCII(node), "description")) {
3450 description_x *description = malloc(sizeof(description_x));
3451 if (description == NULL) {
3452 DBG("Malloc Failed\n");
3455 memset(description, '\0', sizeof(description_x));
3456 LISTADD(mfx->description, description);
3457 ret = __ps_process_description(reader, description);
3458 } else if (!strcmp(ASCII(node), "license")) {
3459 license_x *license = malloc(sizeof(license_x));
3460 if (license == NULL) {
3461 DBG("Malloc Failed\n");
3464 memset(license, '\0', sizeof(license_x));
3465 LISTADD(mfx->license, license);
3466 ret = __ps_process_license(reader, license);
3467 } else if (!strcmp(ASCII(node), "privileges")) {
3468 privileges_x *privileges = malloc(sizeof(privileges_x));
3469 if (privileges == NULL) {
3470 DBG("Malloc Failed\n");
3473 memset(privileges, '\0', sizeof(privileges_x));
3474 LISTADD(mfx->privileges, privileges);
3475 ret = __ps_process_privileges(reader, privileges);
3476 } else if (!strcmp(ASCII(node), "ui-application")) {
3477 uiapplication_x *uiapplication = malloc(sizeof(uiapplication_x));
3478 if (uiapplication == NULL) {
3479 DBG("Malloc Failed\n");
3482 memset(uiapplication, '\0', sizeof(uiapplication_x));
3483 LISTADD(mfx->uiapplication, uiapplication);
3484 ret = __ps_process_uiapplication(reader, uiapplication);
3485 } else if (!strcmp(ASCII(node), "service-application")) {
3486 serviceapplication_x *serviceapplication = malloc(sizeof(serviceapplication_x));
3487 if (serviceapplication == NULL) {
3488 DBG("Malloc Failed\n");
3491 memset(serviceapplication, '\0', sizeof(serviceapplication_x));
3492 LISTADD(mfx->serviceapplication, serviceapplication);
3493 ret = __ps_process_serviceapplication(reader, serviceapplication);
3494 } else if (!strcmp(ASCII(node), "daemon")) {
3495 daemon_x *daemon = malloc(sizeof(daemon_x));
3496 if (daemon == NULL) {
3497 DBG("Malloc Failed\n");
3500 memset(daemon, '\0', sizeof(daemon_x));
3501 LISTADD(mfx->daemon, daemon);
3502 ret = __ps_process_daemon(reader, daemon);
3503 } else if (!strcmp(ASCII(node), "theme")) {
3504 theme_x *theme = malloc(sizeof(theme_x));
3505 if (theme == NULL) {
3506 DBG("Malloc Failed\n");
3509 memset(theme, '\0', sizeof(theme_x));
3510 LISTADD(mfx->theme, theme);
3511 ret = __ps_process_theme(reader, theme);
3512 } else if (!strcmp(ASCII(node), "font")) {
3513 font_x *font = malloc(sizeof(font_x));
3515 DBG("Malloc Failed\n");
3518 memset(font, '\0', sizeof(font_x));
3519 LISTADD(mfx->font, font);
3520 ret = __ps_process_font(reader, font);
3521 } else if (!strcmp(ASCII(node), "ime")) {
3522 ime_x *ime = malloc(sizeof(ime_x));
3524 DBG("Malloc Failed\n");
3527 memset(ime, '\0', sizeof(ime_x));
3528 LISTADD(mfx->ime, ime);
3529 ret = __ps_process_ime(reader, ime);
3530 } else if (!strcmp(ASCII(node), "icon")) {
3531 icon_x *icon = malloc(sizeof(icon_x));
3533 DBG("Malloc Failed\n");
3536 memset(icon, '\0', sizeof(icon_x));
3537 LISTADD(mfx->icon, icon);
3538 ret = __ps_process_icon(reader, icon);
3539 } else if (!strcmp(ASCII(node), "device-profile")) {
3540 deviceprofile_x *deviceprofile = malloc(sizeof(deviceprofile_x));
3541 if (deviceprofile == NULL) {
3542 DBG("Malloc Failed\n");
3545 memset(deviceprofile, '\0', sizeof(deviceprofile_x));
3546 LISTADD(mfx->deviceprofile, deviceprofile);
3547 ret = __ps_process_deviceprofile(reader, deviceprofile);
3548 } else if (!strcmp(ASCII(node), "compatibility")) {
3549 compatibility_x *compatibility = malloc(sizeof(compatibility_x));
3550 if (compatibility == NULL) {
3551 DBG("Malloc Failed\n");
3554 memset(compatibility, '\0', sizeof(compatibility_x));
3555 LISTADD(mfx->compatibility, compatibility);
3556 ret = __ps_process_compatibility(reader, compatibility);
3557 } else if (!strcmp(ASCII(node), "shortcut-list")) {
3559 } else if (!strcmp(ASCII(node), "livebox")) {
3561 } else if (!strcmp(ASCII(node), "account")) {
3563 } else if (!strcmp(ASCII(node), "notifications")) {
3565 } else if (!strcmp(ASCII(node), "ime")) {
3571 DBG("Processing manifest failed\n");
3576 LISTHEAD(mfx->label, tmp1);
3580 LISTHEAD(mfx->author, tmp2);
3583 if (mfx->description) {
3584 LISTHEAD(mfx->description, tmp3);
3585 mfx->description= tmp3;
3588 LISTHEAD(mfx->license, tmp4);
3591 if (mfx->uiapplication) {
3592 LISTHEAD(mfx->uiapplication, tmp5);
3593 mfx->uiapplication = tmp5;
3595 if (mfx->serviceapplication) {
3596 LISTHEAD(mfx->serviceapplication, tmp6);
3597 mfx->serviceapplication = tmp6;
3600 LISTHEAD(mfx->daemon, tmp7);
3604 LISTHEAD(mfx->theme, tmp8);
3608 LISTHEAD(mfx->font, tmp9);
3612 LISTHEAD(mfx->ime, tmp10);
3616 LISTHEAD(mfx->icon, tmp11);
3619 if (mfx->compatibility) {
3620 LISTHEAD(mfx->compatibility, tmp12);
3621 mfx->compatibility= tmp12;
3623 if (mfx->deviceprofile) {
3624 LISTHEAD(mfx->deviceprofile, tmp13);
3625 mfx->deviceprofile= tmp13;
3627 if (mfx->privileges) {
3628 LISTHEAD(mfx->privileges, tmp14);
3629 mfx->privileges = tmp14;
3634 static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx)
3636 const xmlChar *node;
3639 if ((ret = __next_child_element(reader, -1))) {
3640 node = xmlTextReaderConstName(reader);
3642 DBG("xmlTextReaderConstName value is NULL\n");
3646 if (!strcmp(ASCII(node), "manifest")) {
3647 if (xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")))
3648 mfx->ns = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")));
3649 if (xmlTextReaderGetAttribute(reader, XMLCHAR("package"))) {
3650 mfx->package= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("package")));
3651 if (mfx->package == NULL) {
3652 DBG("package cant be NULL\n");
3656 DBG("package field is mandatory\n");
3659 package = mfx->package;
3660 if (xmlTextReaderGetAttribute(reader, XMLCHAR("version")))
3661 mfx->version= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("version")));
3662 /*app2ext needs package size for external installation*/
3663 if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
3664 mfx->package_size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
3665 if (xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")))
3666 mfx->installlocation = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")));
3667 if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
3668 mfx->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
3669 if (xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")))
3670 mfx->root_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")));
3671 if (xmlTextReaderGetAttribute(reader, XMLCHAR("csc_path")))
3672 mfx->csc_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("csc_path")));
3673 if (xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting"))) {
3674 mfx->appsetting = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting")));
3675 if (mfx->appsetting == NULL)
3676 mfx->appsetting = strdup("false");
3678 mfx->appsetting = strdup("false");
3680 if (xmlTextReaderGetAttribute(reader, XMLCHAR("storeclient-id")))
3681 mfx->storeclient_id= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("storeclient-id")));
3682 if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay-setting"))) {
3683 mfx->nodisplay_setting = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay-setting")));
3684 if (mfx->nodisplay_setting == NULL)
3685 mfx->nodisplay_setting = strdup("false");
3687 mfx->nodisplay_setting = strdup("false");
3689 if (xmlTextReaderGetAttribute(reader, XMLCHAR("url")))
3690 mfx->package_url= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("url")));
3692 /*Assign default values. If required it will be overwritten in __add_preload_info()*/
3693 mfx->preload = strdup("False");
3694 mfx->removable = strdup("True");
3695 mfx->readonly = strdup("False");
3696 mfx->update = strdup("False");
3697 char buf[PKG_STRING_LEN_MAX] = {'\0'};
3699 time_t current_time;
3700 time(¤t_time);
3701 snprintf(buf, PKG_STRING_LEN_MAX - 1, "%d", current_time);
3702 val = strndup(buf, PKG_STRING_LEN_MAX - 1);
3703 mfx->installed_time = val;
3705 mfx->installed_storage= strdup("installed_internal");
3707 ret = __start_process(reader, mfx);
3709 DBG("No Manifest element found\n");
3716 static char* __convert_to_system_locale(const char *mlocale)
3718 if (mlocale == NULL)
3720 char *locale = NULL;
3721 locale = (char *)calloc(1, 6);
3723 DBGE("Malloc Failed\n");
3727 strncpy(locale, mlocale, 2);
3728 strncat(locale, "_", 1);
3729 locale[3] = toupper(mlocale[3]);
3730 locale[4] = toupper(mlocale[4]);
3734 static int __ail_change_info(int op, const char *appid)
3736 void *lib_handle = NULL;
3737 int (*ail_desktop_operation) (const char *);
3741 if ((lib_handle = dlopen(LIBAIL_PATH, RTLD_LAZY)) == NULL) {
3742 DBGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAIL_PATH);
3749 aop = "ail_desktop_add";
3752 aop = "ail_desktop_update";
3755 aop = "ail_desktop_remove";
3758 aop = "ail_desktop_clean";
3765 if ((ail_desktop_operation =
3766 dlsym(lib_handle, aop)) == NULL || dlerror() != NULL) {
3767 DBGE("can not find symbol \n");
3771 ret = ail_desktop_operation(appid);
3775 dlclose(lib_handle);
3781 /* desktop shoud be generated automatically based on manifest */
3782 /* Currently removable, taskmanage, etc fields are not considerd. it will be decided soon.*/
3783 static int __ps_make_nativeapp_desktop(manifest_x * mfx, const char *manifest, bool is_update)
3787 char filepath[PKG_STRING_LEN_MAX] = "";
3789 char *buftemp = NULL;
3790 char *locale = NULL;
3792 buf = (char *)calloc(1, BUFMAX);
3794 DBGE("Malloc Failed\n");
3798 buftemp = (char *)calloc(1, BUFMAX);
3800 DBGE("Malloc Failed\n");
3806 __ail_change_info(AIL_CLEAN, mfx->package);
3808 for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) {
3810 if (manifest != NULL) {
3811 /* skip making a deskfile and update ail, if preload app is updated */
3812 if(strstr(manifest, MANIFEST_RO_PREFIX)) {
3813 __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid);
3814 DBGE("preload app is update : skip and update ail : %s", manifest);
3819 if(mfx->readonly && !strcasecmp(mfx->readonly, "True"))
3820 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RO_PATH, mfx->uiapplication->appid);
3822 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, mfx->uiapplication->appid);
3824 /* skip if desktop exists
3825 if (access(filepath, R_OK) == 0)
3829 file = fopen(filepath, "w");
3832 DBGE("Can't open %s", filepath);
3838 snprintf(buf, BUFMAX, "[Desktop Entry]\n");
3839 fwrite(buf, 1, strlen(buf), file);
3841 for( ; mfx->uiapplication->label ; mfx->uiapplication->label = mfx->uiapplication->label->next) {
3842 if(!strcmp(mfx->uiapplication->label->lang, DEFAULT_LOCALE)) {
3843 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
3845 locale = __convert_to_system_locale(mfx->uiapplication->label->lang);
3846 snprintf(buf, BUFMAX, "Name[%s]=%s\n", locale,
3847 mfx->uiapplication->label->text);
3850 fwrite(buf, 1, strlen(buf), file);
3853 if(mfx->uiapplication->label && mfx->uiapplication->label->text) {
3854 snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
3855 fwrite(buf, 1, strlen(buf), file);
3858 else if(mfx->label && mfx->label->text) {
3859 snprintf(buf, BUFMAX, "Name=%s\n", mfx->label->text);
3860 fwrite(buf, 1, strlen(buf), file);
3862 snprintf(buf, BUFMAX, "Name=%s\n", mfx->package);
3863 fwrite(buf, 1, strlen(buf), file);
3868 snprintf(buf, BUFMAX, "Type=Application\n");
3869 fwrite(buf, 1, strlen(buf), file);
3871 if(mfx->uiapplication->exec) {
3872 snprintf(buf, BUFMAX, "Exec=%s\n", mfx->uiapplication->exec);
3873 fwrite(buf, 1, strlen(buf), file);
3876 if(mfx->uiapplication->icon && mfx->uiapplication->icon->text) {
3877 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->uiapplication->icon->text);
3878 fwrite(buf, 1, strlen(buf), file);
3879 } else if(mfx->icon && mfx->icon->text) {
3880 snprintf(buf, BUFMAX, "Icon=%s\n", mfx->icon->text);
3881 fwrite(buf, 1, strlen(buf), file);
3885 if(mfx->uiapplication && mfx->uiapplication->appsvc) {
3886 appsvc_x *asvc = mfx->uiapplication->appsvc;
3888 const char *mime = NULL;
3889 const char *mime_delim = "; ";
3892 strncpy(buf, "MimeType=", BUFMAX-1);
3898 DBG("MIME type: %s\n", mime);
3899 strncat(buf, mime, BUFMAX-strlen(buf)-1);
3901 strncat(buf, mime_delim, BUFMAX-strlen(buf)-1);
3909 DBG("MIME types: buf[%s]\n", buf);
3910 DBG("MIME count: %d\n", mime_count);
3912 fwrite(buf, 1, strlen(buf), file);
3916 snprintf(buf, BUFMAX, "Version=%s\n", mfx->version);
3917 fwrite(buf, 1, strlen(buf), file);
3920 if(mfx->uiapplication->nodisplay) {
3921 snprintf(buf, BUFMAX, "NoDisplay=%s\n", mfx->uiapplication->nodisplay);
3922 fwrite(buf, 1, strlen(buf), file);
3925 if(mfx->uiapplication->categories) {
3926 snprintf(buf, BUFMAX, "Categories=%s\n", mfx->uiapplication->categories);
3927 fwrite(buf, 1, strlen(buf), file);
3930 if(mfx->uiapplication->taskmanage && !strcasecmp(mfx->uiapplication->taskmanage, "False")) {
3931 snprintf(buf, BUFMAX, "X-TIZEN-TaskManage=False\n");
3932 fwrite(buf, 1, strlen(buf), file);
3935 if(mfx->uiapplication->enabled && !strcasecmp(mfx->uiapplication->enabled, "False")) {
3936 snprintf(buf, BUFMAX, "X-TIZEN-Enabled=False\n");
3937 fwrite(buf, 1, strlen(buf), file);
3940 if(mfx->uiapplication->hwacceleration) {
3941 snprintf(buf, BUFMAX, "Hw-Acceleration=%s\n", mfx->uiapplication->hwacceleration);
3942 fwrite(buf, 1, strlen(buf), file);
3945 if(mfx->uiapplication->multiple && !strcasecmp(mfx->uiapplication->multiple, "True")) {
3946 snprintf(buf, BUFMAX, "X-TIZEN-Multiple=True\n");
3947 fwrite(buf, 1, strlen(buf), file);
3950 if(mfx->uiapplication->extraid) {
3951 snprintf(buf, BUFMAX, "X-TIZEN-PackageID=%s\n", mfx->uiapplication->extraid);
3952 fwrite(buf, 1, strlen(buf), file);
3955 if(mfx->removable && !strcasecmp(mfx->removable, "False")) {
3956 snprintf(buf, BUFMAX, "X-TIZEN-Removable=False\n");
3957 fwrite(buf, 1, strlen(buf), file);
3961 snprintf(buf, BUFMAX, "X-TIZEN-PackageType=%s\n", mfx->type);
3962 fwrite(buf, 1, strlen(buf), file);
3965 snprintf(buf, BUFMAX, "X-TIZEN-PkgID=%s\n", mfx->package);
3966 fwrite(buf, 1, strlen(buf), file);
3969 // snprintf(buf, BUFMAX, "X-TIZEN-PackageType=rpm\n");
3970 // fwrite(buf, 1, strlen(buf), file);
3973 if(mfx->uiapplication->appsvc) {
3974 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
3975 DBG("buf[%s]\n", buf);
3978 uiapplication_x *up = mfx->uiapplication;
3979 appsvc_x *asvc = NULL;
3980 operation_x *op = NULL;
3983 subapp_x *sub = NULL;
3984 const char *operation = NULL;
3985 const char *mime = NULL;
3986 const char *uri = NULL;
3987 const char *subapp = NULL;
3992 while(asvc != NULL) {
3993 op = asvc->operation;
3996 operation = op->name;
4015 strncpy(buftemp, buf, BUFMAX);
4016 snprintf(buf, BUFMAX, "%s;", buftemp);
4020 strncpy(buftemp, buf, BUFMAX);
4021 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
4022 DBG("buf[%s]\n", buf);
4027 } while(ui != NULL);
4031 }while(sub != NULL);
4044 fwrite(buf, 1, strlen(buf), file);
4046 // strncpy(buftemp, buf, BUFMAX);
4047 // snprintf(buf, BUFMAX, "%s\n", buftemp);
4048 // fwrite(buf, 1, strlen(buf), file);
4051 if(mfx->uiapplication->appcontrol) {
4052 snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
4053 DBG("buf[%s]\n", buf);
4055 uiapplication_x *up = mfx->uiapplication;
4056 appcontrol_x *acontrol = NULL;
4057 operation_x *op = NULL;
4060 subapp_x *sub = NULL;
4061 const char *operation = NULL;
4062 const char *mime = NULL;
4063 const char *uri = NULL;
4064 const char *subapp = NULL;
4067 acontrol = up->appcontrol;
4068 while(acontrol != NULL) {
4069 op = acontrol->operation;
4072 operation = op->name;
4073 mi = acontrol->mime;
4079 sub = acontrol->subapp;
4091 strncpy(buftemp, buf, BUFMAX);
4092 snprintf(buf, BUFMAX, "%s;", buftemp);
4095 strncpy(buftemp, buf, BUFMAX);
4096 snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
4097 DBG("buf[%s]\n", buf);
4102 } while(ui != NULL);
4106 }while(sub != NULL);
4115 acontrol = acontrol->next;
4119 fwrite(buf, 1, strlen(buf), file);
4121 // strncpy(buftemp, buf, BUFMAX);
4122 // snprintf(buf, BUFMAX, "%s\n", buftemp);
4123 // fwrite(buf, 1, strlen(buf), file);
4131 __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid);
4140 static int __ps_remove_nativeapp_desktop(manifest_x *mfx)
4142 char filepath[PKG_STRING_LEN_MAX] = "";
4144 uiapplication_x *uiapplication = mfx->uiapplication;
4146 for(; uiapplication; uiapplication=uiapplication->next) {
4147 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, uiapplication->appid);
4149 __ail_change_info(AIL_REMOVE, uiapplication->appid);
4151 ret = remove(filepath);
4159 static int __ps_remove_appsvc_db(manifest_x *mfx)
4161 void *lib_handle = NULL;
4162 int (*appsvc_operation) (const char *);
4164 uiapplication_x *uiapplication = mfx->uiapplication;
4166 if ((lib_handle = dlopen(LIBAPPSVC_PATH, RTLD_LAZY)) == NULL) {
4167 DBGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAPPSVC_PATH);
4171 if ((appsvc_operation =
4172 dlsym(lib_handle, "appsvc_unset_defapp")) == NULL || dlerror() != NULL) {
4173 DBGE("can not find symbol \n");
4177 for(; uiapplication; uiapplication=uiapplication->next) {
4178 ret = appsvc_operation(uiapplication->appid);
4180 DBGE("can not operation symbol \n");
4185 dlclose(lib_handle);
4190 static int __add_preload_info(manifest_x * mfx, const char *manifest)
4193 char buffer[1024] = { 0 };
4196 if(strstr(manifest, MANIFEST_RO_PREFIX)) {
4197 free((void *)mfx->readonly);
4198 mfx->readonly = strdup("True");
4200 free((void *)mfx->preload);
4201 mfx->preload = strdup("True");
4203 free((void *)mfx->removable);
4204 mfx->removable = strdup("False");
4209 fp = fopen(PRELOAD_PACKAGE_LIST, "r");
4211 DBGE("no preload list\n");
4215 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
4216 if (buffer[0] == '#') {
4217 if(strcasestr(buffer, "RW_NORM"))
4219 else if(strcasestr(buffer, "RW_RM"))
4227 if(!strcmp(mfx->package, buffer)) {
4228 free((void *)mfx->preload);
4229 mfx->preload = strdup("True");
4231 free((void *)mfx->readonly);
4232 mfx->readonly = strdup("False");
4233 free((void *)mfx->removable);
4234 mfx->removable = strdup("False");
4235 } else if(state == 3){
4236 free((void *)mfx->readonly);
4237 mfx->readonly = strdup("False");
4238 free((void *)mfx->removable);
4239 mfx->removable = strdup("True");
4243 memset(buffer, 0x00, sizeof(buffer));
4252 static int __check_preload_updated(manifest_x * mfx, const char *manifest)
4254 char filepath[PKG_STRING_LEN_MAX] = "";
4256 uiapplication_x *uiapplication = mfx->uiapplication;
4258 if(strstr(manifest, MANIFEST_RO_PREFIX)) {
4259 /* if preload app is updated, then remove previous desktop file on RW*/
4260 for(; uiapplication; uiapplication=uiapplication->next) {
4261 snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, uiapplication->appid);
4262 ret = remove(filepath);
4267 /* if downloaded app is updated, then update tag set true*/
4268 free((void *)mfx->update);
4269 mfx->update = strdup("true");
4276 API int pkgmgr_parser_create_desktop_file(manifest_x *mfx)
4280 DBG("Manifest pointer is NULL\n");
4283 ret = __ps_make_nativeapp_desktop(mfx, NULL, 0);
4285 DBG("Creating desktop file failed\n");
4287 DBG("Creating desktop file Success\n");
4291 API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
4296 free((void *)mfx->ns);
4300 free((void *)mfx->package);
4301 mfx->package = NULL;
4304 free((void *)mfx->version);
4305 mfx->version = NULL;
4307 if (mfx->installlocation) {
4308 free((void *)mfx->installlocation);
4309 mfx->installlocation = NULL;
4312 free((void *)mfx->preload);
4313 mfx->preload = NULL;
4315 if (mfx->readonly) {
4316 free((void *)mfx->readonly);
4317 mfx->readonly = NULL;
4319 if (mfx->removable) {
4320 free((void *)mfx->removable);
4321 mfx->removable = NULL;
4324 free((void *)mfx->update);
4328 free((void *)mfx->type);
4331 if (mfx->package_size) {
4332 free((void *)mfx->package_size);
4333 mfx->package_size = NULL;
4335 if (mfx->installed_time) {
4336 free((void *)mfx->installed_time);
4337 mfx->installed_time = NULL;
4339 if (mfx->installed_storage) {
4340 free((void *)mfx->installed_storage);
4341 mfx->installed_storage = NULL;
4343 if (mfx->storeclient_id) {
4344 free((void *)mfx->storeclient_id);
4345 mfx->storeclient_id = NULL;
4347 if (mfx->mainapp_id) {
4348 free((void *)mfx->mainapp_id);
4349 mfx->mainapp_id = NULL;
4351 if (mfx->package_url) {
4352 free((void *)mfx->package_url);
4353 mfx->package_url = NULL;
4355 if (mfx->root_path) {
4356 free((void *)mfx->root_path);
4357 mfx->root_path = NULL;
4359 if (mfx->csc_path) {
4360 free((void *)mfx->csc_path);
4361 mfx->csc_path = NULL;
4363 if (mfx->appsetting) {
4364 free((void *)mfx->appsetting);
4365 mfx->appsetting = NULL;
4367 if (mfx->nodisplay_setting) {
4368 free((void *)mfx->nodisplay_setting);
4369 mfx->nodisplay_setting = NULL;
4374 icon_x *icon = mfx->icon;
4376 while(icon != NULL) {
4378 __ps_free_icon(icon);
4384 label_x *label = mfx->label;
4385 label_x *tmp = NULL;
4386 while(label != NULL) {
4388 __ps_free_label(label);
4394 author_x *author = mfx->author;
4395 author_x *tmp = NULL;
4396 while(author != NULL) {
4398 __ps_free_author(author);
4402 /*Free Description*/
4403 if (mfx->description) {
4404 description_x *description = mfx->description;
4405 description_x *tmp = NULL;
4406 while(description != NULL) {
4407 tmp = description->next;
4408 __ps_free_description(description);
4414 license_x *license = mfx->license;
4415 license_x *tmp = NULL;
4416 while(license != NULL) {
4417 tmp = license->next;
4418 __ps_free_license(license);
4423 if (mfx->privileges) {
4424 privileges_x *privileges = mfx->privileges;
4425 privileges_x *tmp = NULL;
4426 while(privileges != NULL) {
4427 tmp = privileges->next;
4428 __ps_free_privileges(privileges);
4432 /*Free UiApplication*/
4433 if (mfx->uiapplication) {
4434 uiapplication_x *uiapplication = mfx->uiapplication;
4435 uiapplication_x *tmp = NULL;
4436 while(uiapplication != NULL) {
4437 tmp = uiapplication->next;
4438 __ps_free_uiapplication(uiapplication);
4439 uiapplication = tmp;
4442 /*Free ServiceApplication*/
4443 if (mfx->serviceapplication) {
4444 serviceapplication_x *serviceapplication = mfx->serviceapplication;
4445 serviceapplication_x *tmp = NULL;
4446 while(serviceapplication != NULL) {
4447 tmp = serviceapplication->next;
4448 __ps_free_serviceapplication(serviceapplication);
4449 serviceapplication = tmp;
4454 daemon_x *daemon = mfx->daemon;
4455 daemon_x *tmp = NULL;
4456 while(daemon != NULL) {
4458 __ps_free_daemon(daemon);
4464 theme_x *theme = mfx->theme;
4465 theme_x *tmp = NULL;
4466 while(theme != NULL) {
4468 __ps_free_theme(theme);
4474 font_x *font = mfx->font;
4476 while(font != NULL) {
4478 __ps_free_font(font);
4484 ime_x *ime = mfx->ime;
4486 while(ime != NULL) {
4492 /*Free Compatibility*/
4493 if (mfx->compatibility) {
4494 compatibility_x *compatibility = mfx->compatibility;
4495 compatibility_x *tmp = NULL;
4496 while(compatibility != NULL) {
4497 tmp = compatibility->next;
4498 __ps_free_compatibility(compatibility);
4499 compatibility = tmp;
4502 /*Free DeviceProfile*/
4503 if (mfx->deviceprofile) {
4504 deviceprofile_x *deviceprofile = mfx->deviceprofile;
4505 deviceprofile_x *tmp = NULL;
4506 while(deviceprofile != NULL) {
4507 tmp = deviceprofile->next;
4508 __ps_free_deviceprofile(deviceprofile);
4509 deviceprofile = tmp;
4517 API manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest)
4519 DBG("parsing start\n");
4520 xmlTextReaderPtr reader;
4521 manifest_x *mfx = NULL;
4523 reader = xmlReaderForFile(manifest, NULL, 0);
4525 mfx = malloc(sizeof(manifest_x));
4527 memset(mfx, '\0', sizeof(manifest_x));
4528 if (__process_manifest(reader, mfx) < 0) {
4529 DBG("Parsing Failed\n");
4530 pkgmgr_parser_free_manifest_xml(mfx);
4533 DBG("Parsing Success\n");
4535 DBG("Memory allocation error\n");
4537 xmlFreeTextReader(reader);
4539 DBG("Unable to create xml reader\n");
4544 /* These APIs are intended to call parser directly */
4546 API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
4548 char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
4549 if (manifest == NULL) {
4550 DBG("argument supplied is NULL\n");
4551 return PMINFO_R_EINVAL;
4553 DBG("parsing manifest for installation: %s\n", manifest);
4554 manifest_x *mfx = NULL;
4556 char roxml_check[PKG_STRING_LEN_MAX] = {'\0'};
4559 mfx = pkgmgr_parser_process_manifest_xml(manifest);
4560 DBG("Parsing Finished\n");
4562 return PMINFO_R_ERROR;
4564 __streamFile(manifest, ACTION_INSTALL, temp, mfx->package);
4565 __add_preload_info(mfx, manifest);
4566 DBG("Added preload infomation\n");
4568 __ps_process_tag(mfx, tagv);
4570 ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
4572 DBG("DB Insert failed\n");
4574 DBG("DB Insert Success\n");
4576 ret = __ps_process_mdparser(mfx, ACTION_INSTALL);
4578 DBG("Creating metadata parser failed\n");
4580 ret = __ps_make_nativeapp_desktop(mfx, NULL, 0);
4582 DBG("Creating desktop file failed\n");
4584 DBG("Creating desktop file Success\n");
4586 __ps_apply_shared_privileges(mfx, manifest);
4588 pkgmgr_parser_free_manifest_xml(mfx);
4595 API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
4597 char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
4598 if (manifest == NULL) {
4599 DBG("argument supplied is NULL\n");
4600 return PMINFO_R_EINVAL;
4602 DBG("parsing manifest for upgradation: %s\n", manifest);
4603 manifest_x *mfx = NULL;
4605 bool preload = false;
4606 char *csc_path = NULL;
4607 pkgmgrinfo_pkginfo_h handle = NULL;
4610 mfx = pkgmgr_parser_process_manifest_xml(manifest);
4611 DBG("Parsing Finished\n");
4613 return PMINFO_R_ERROR;
4615 __streamFile(manifest, ACTION_UPGRADE, temp, mfx->package);
4616 __add_preload_info(mfx, manifest);
4617 DBG("Added preload infomation\n");
4618 __check_preload_updated(mfx, manifest);
4620 ret = pkgmgrinfo_pkginfo_get_pkginfo(mfx->package, &handle);
4621 if (ret != PMINFO_R_OK)
4622 DBG("pkgmgrinfo_pkginfo_get_pkginfo failed\n");
4624 ret = pkgmgrinfo_pkginfo_is_preload(handle, &preload);
4625 if (ret != PMINFO_R_OK)
4626 DBG("pkgmgrinfo_pkginfo_is_preload failed\n");
4629 free((void *)mfx->preload);
4630 mfx->preload = strdup("true");
4633 ret = pkgmgrinfo_pkginfo_get_csc_path(handle, &csc_path);
4634 if (ret != PMINFO_R_OK)
4635 DBG("pkgmgrinfo_pkginfo_get_csc_path failed\n");
4637 if (csc_path != NULL) {
4639 free((void *)mfx->csc_path);
4640 mfx->csc_path = strdup(csc_path);
4643 ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
4645 DBG("DB Update failed\n");
4647 DBG("DB Update Success\n");
4649 ret = __ps_process_mdparser(mfx, ACTION_UPGRADE);
4651 DBG("Upgrade metadata parser failed\n");
4653 ret = __ps_make_nativeapp_desktop(mfx, manifest, 1);
4655 DBG("Creating desktop file failed\n");
4657 DBG("Creating desktop file Success\n");
4659 __ps_apply_shared_privileges(mfx, manifest);
4661 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
4662 pkgmgr_parser_free_manifest_xml(mfx);
4669 API int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[])
4671 char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
4672 if (manifest == NULL) {
4673 DBG("argument supplied is NULL\n");
4674 return PMINFO_R_EINVAL;
4676 DBG("parsing manifest for uninstallation: %s\n", manifest);
4677 manifest_x *mfx = NULL;
4680 mfx = pkgmgr_parser_process_manifest_xml(manifest);
4681 DBG("Parsing Finished\n");
4683 return PMINFO_R_ERROR;
4685 __streamFile(manifest, ACTION_UNINSTALL, temp, mfx->package);
4686 __add_preload_info(mfx, manifest);
4687 DBG("Added preload infomation\n");
4689 ret = __ps_process_mdparser(mfx, ACTION_UNINSTALL);
4691 DBG("Removing metadata parser failed\n");
4693 ret = pkgmgr_parser_delete_manifest_info_from_db(mfx);
4695 DBG("DB Delete failed\n");
4697 DBG("DB Delete Success\n");
4699 ret = __ps_remove_nativeapp_desktop(mfx);
4701 DBG("Removing desktop file failed\n");
4703 DBG("Removing desktop file Success\n");
4705 ret = __ps_remove_appsvc_db(mfx);
4707 DBG("Removing appsvc_db failed\n");
4709 DBG("Removing appsvc_db Success\n");
4711 pkgmgr_parser_free_manifest_xml(mfx);
4718 API int pkgmgr_parser_parse_manifest_for_preload()
4720 __ps_process_smack();
4722 return pkgmgr_parser_update_preload_info_in_db();
4725 API char *pkgmgr_parser_get_manifest_file(const char *pkgid)
4727 return __pkgid_to_manifest(pkgid);
4730 API int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
4732 return __ps_run_parser(docPtr, tag, ACTION_INSTALL, pkgid);
4735 API int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgid)
4737 return __ps_run_parser(docPtr, tag, ACTION_UPGRADE, pkgid);
4740 API int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
4742 return __ps_run_parser(docPtr, tag, ACTION_UNINSTALL, pkgid);
4746 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
4748 if (manifest == NULL) {
4749 DBGE("manifest file is NULL\n");
4750 return PMINFO_R_EINVAL;
4753 xmlSchemaParserCtxtPtr ctx;
4754 xmlSchemaValidCtxtPtr vctx;
4755 xmlSchemaPtr xschema;
4756 ctx = xmlSchemaNewParserCtxt(SCHEMA_FILE);
4758 DBGE("xmlSchemaNewParserCtxt() Failed\n");
4759 return PMINFO_R_ERROR;
4761 xschema = xmlSchemaParse(ctx);
4762 if (xschema == NULL) {
4763 DBGE("xmlSchemaParse() Failed\n");
4764 return PMINFO_R_ERROR;
4766 vctx = xmlSchemaNewValidCtxt(xschema);
4768 DBGE("xmlSchemaNewValidCtxt() Failed\n");
4769 return PMINFO_R_ERROR;
4771 xmlSchemaSetValidErrors(vctx, (xmlSchemaValidityErrorFunc) fprintf, (xmlSchemaValidityWarningFunc) fprintf, stderr);
4772 ret = xmlSchemaValidateFile(vctx, manifest, 0);
4774 DBGE("xmlSchemaValidateFile() failed\n");
4775 return PMINFO_R_ERROR;
4776 } else if (ret == 0) {
4777 DBGE("Manifest is Valid\n");
4780 DBGE("Manifest Validation Failed with error code %d\n", ret);
4781 return PMINFO_R_ERROR;
4787 API int pkgmgr_parser_check_manifest_validation(const char *manifest)
4797 DBGE("fork failed\n");
4802 int dev_null_fd = open ("/dev/null", O_RDWR);
4803 if (dev_null_fd >= 0)
4805 dup2 (dev_null_fd, 0);/*stdin*/
4806 dup2 (dev_null_fd, 1);/*stdout*/
4807 dup2 (dev_null_fd, 2);/*stderr*/
4810 if (execl("/usr/bin/xmllint", "xmllint", manifest, "--schema",
4811 SCHEMA_FILE, NULL) < 0) {
4812 DBGE("execl error\n");
4822 while ((err = waitpid(pid, &status, WNOHANG)) != pid) {
4826 DBGE("waitpid failed\n");
4832 if(WIFEXITED(status) && !WEXITSTATUS(status))