From: Sangyoon Jang Date: Fri, 12 Feb 2016 05:58:47 +0000 (+0900) Subject: Remove resource manager related codes and files X-Git-Tag: accepted/tizen/common/20160217.170720^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F80%2F59280%2F2;p=platform%2Fcore%2Fappfw%2Fpkgmgr-info.git Remove resource manager related codes and files These are moved to aul. Change-Id: I5ad95227c964c5b6f2a48d60d3830a2ea5a4e05b Signed-off-by: Sangyoon Jang --- diff --git a/CMakeLists.txt b/CMakeLists.txt index cf0770a..d6b1e3f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,8 +45,7 @@ ADD_LIBRARY(pkgmgr-info SHARED src/pkgmgrinfo_pkginfo.c src/pkgmgrinfo_appinfo.c src/pkgmgrinfo_basic.c - src/pkgmgrinfo_private.c - src/pkgmgrinfo_resource.c) + src/pkgmgrinfo_private.c) SET_TARGET_PROPERTIES(pkgmgr-info PROPERTIES SOVERSION ${MAJORVER}) SET_TARGET_PROPERTIES(pkgmgr-info PROPERTIES VERSION ${FULLVER}) @@ -63,7 +62,6 @@ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-info.pc DESTINATION ${LIB_INSTA INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/pkgmgr-info.h DESTINATION include) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/pkgmgrinfo_type.h DESTINATION include) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/pkgmgrinfo_basic.h DESTINATION include) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/pkgmgrinfo_resource.h DESTINATION include) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/parser_path.conf DESTINATION ${SYSCONFDIR}/package-manager/) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mdparser_list.txt DESTINATION ${SYSCONFDIR}/package-manager/parserlib/metadata) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/category_parser_list.txt DESTINATION ${SYSCONFDIR}/package-manager/parserlib/category) diff --git a/packaging/pkgmgr-info.spec b/packaging/pkgmgr-info.spec index 22864a6..84672f4 100644 --- a/packaging/pkgmgr-info.spec +++ b/packaging/pkgmgr-info.spec @@ -81,7 +81,6 @@ cp LICENSE %{buildroot}/usr/share/license/%{name}-parser %{_includedir}/pkgmgr-info.h %{_includedir}/pkgmgrinfo_type.h %{_includedir}/pkgmgrinfo_basic.h -%{_includedir}/pkgmgrinfo_resource.h %{_libdir}/pkgconfig/pkgmgr-info.pc %{_libdir}/libpkgmgr-info.so @@ -91,7 +90,6 @@ cp LICENSE %{buildroot}/usr/share/license/%{name}-parser %{_libdir}/libpkgmgr_parser.so.* %config %{_sysconfdir}/package-manager/preload/manifest.xsd %config %{_sysconfdir}/package-manager/preload/xml.xsd -%config %{_sysconfdir}/package-manager/preload/res.xsd %config %{_sysconfdir}/package-manager/parser_path.conf %config %{_sysconfdir}/package-manager/parserlib/metadata/mdparser_list.txt %config %{_sysconfdir}/package-manager/parserlib/category/category_parser_list.txt @@ -103,6 +101,5 @@ cp LICENSE %{buildroot}/usr/share/license/%{name}-parser %defattr(-,root,root,-) %{_includedir}/pkgmgr/pkgmgr_parser.h %{_includedir}/pkgmgr/pkgmgr_parser_db.h -%{_includedir}/pkgmgr/pkgmgr_parser_resource.h %{_libdir}/pkgconfig/pkgmgr-parser.pc %{_libdir}/libpkgmgr_parser.so diff --git a/parser/CMakeLists.txt b/parser/CMakeLists.txt index f2b387a..4209a99 100644 --- a/parser/CMakeLists.txt +++ b/parser/CMakeLists.txt @@ -45,7 +45,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) ## pkgmgr_parser object (by sewook.park) # This library is for installer backend -add_library(pkgmgr_parser SHARED pkgmgr_parser.c pkgmgr_parser_db.c pkgmgr_parser_resource.c) +add_library(pkgmgr_parser SHARED pkgmgr_parser.c pkgmgr_parser_db.c) #add_library(pkgmgr_parser SHARED pkgmgr_parser.c) set_target_properties(pkgmgr_parser PROPERTIES SOVERSION ${VERSION_MAJOR}) set_target_properties(pkgmgr_parser PROPERTIES VERSION ${VERSION}) @@ -56,7 +56,6 @@ target_link_libraries(pkgmgr_parser ${parser_pkgs_LDFLAGS}) configure_file(pkgmgr-parser.pc.in ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-parser.pc @ONLY) configure_file(manifest.xsd.in manifest.xsd @ONLY) configure_file(xml.xsd.in xml.xsd @ONLY) -configure_file(res.xsd.in res.xsd @ONLY) ## Install INSTALL(TARGETS @@ -70,12 +69,8 @@ INSTALL(FILES pkgmgr_parser_db.h DESTINATION include/pkgmgr) INSTALL(FILES - pkgmgr_parser_resource.h - DESTINATION include/pkgmgr) -INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-parser.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/manifest.xsd DESTINATION ${SYSCONFDIR}/package-manager/preload/) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/xml.xsd DESTINATION ${SYSCONFDIR}/package-manager/preload/) -INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/res.xsd DESTINATION ${SYSCONFDIR}/package-manager/preload/) diff --git a/parser/pkgmgr_parser_resource.c b/parser/pkgmgr_parser_resource.c deleted file mode 100644 index 84f9bce..0000000 --- a/parser/pkgmgr_parser_resource.c +++ /dev/null @@ -1,446 +0,0 @@ -/* - * pkgmgr-info - * - * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Jayoun Lee , Sewook Park , - * Jaeho Lee , Shobhit Srivastava - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "pkgmgr-info.h" -#include "pkgmgrinfo_debug.h" -#include "pkgmgr_parser.h" -#include "pkgmgr_parser_resource.h" -#ifdef LOG_TAG -#undef LOG_TAG -#endif - -#define LOG_TAG "PKGMGR_PARSER" - -#define XMLCHAR(s) (const xmlChar *)s -#define ASCII(s) (char *)s - -#define FREE_AND_NULL(ptr) do { \ - if (ptr) { \ - free((void *)ptr); \ - ptr = NULL; \ - } \ - } while (0) - - -#define RSC_XML_QUALIFIER "res" -#define RSC_GROUP_NAME_SEPERATOR '-' -#define RSC_GROUP "group" -#define RSC_GROUP_ATTR_FOLDER "folder" -#define RSC_GROUP_ATTR_TYPE "type" -#define RSC_NODE "node" -#define RSC_MANIFEST_SCHEMA_FILE "/etc/package-manager/preload/res.xsd" - -static int __next_child_element(xmlTextReaderPtr reader, int depth) -{ - int ret = xmlTextReaderRead(reader); - int cur = xmlTextReaderDepth(reader); - while (ret == 1) { - switch (xmlTextReaderNodeType(reader)) { - case XML_READER_TYPE_ELEMENT: - if (cur == depth + 1) - return 1; - break; - case XML_READER_TYPE_TEXT: - /*text is handled by each function separately*/ - if (cur == depth + 1) - return 0; - break; - case XML_READER_TYPE_END_ELEMENT: - if (cur == depth) - return 0; - break; - default: - if (cur <= depth) - return 0; - break; - } - ret = xmlTextReaderRead(reader); - cur = xmlTextReaderDepth(reader); - } - return ret; -} - -static void _free_node_list(gpointer data) -{ - resource_node_t *tmp_node = (resource_node_t *)data; - - if (tmp_node == NULL) { - _LOGE("node list's element is NULL"); - return; - } - - FREE_AND_NULL(tmp_node->folder); - if (tmp_node->attr != NULL) { - bundle_free(tmp_node->attr); - tmp_node->attr = NULL; - } -} - -static void _free_group_list(gpointer data) -{ - resource_group_t *tmp_group = (resource_group_t *)data; - - if (tmp_group == NULL) { - _LOGE("group list's element is NULL"); - return; - } - - FREE_AND_NULL(tmp_group->folder); - FREE_AND_NULL(tmp_group->type); - - g_list_free_full(tmp_group->node_list, (GDestroyNotify)_free_node_list); -} - -static void __save_resource_attribute_into_bundle(xmlTextReaderPtr reader, char *attribute, bundle **b) -{ - xmlChar *attr_val = xmlTextReaderGetAttribute(reader, XMLCHAR(attribute)); - - if (attr_val) - bundle_add_str(*b, attribute, (char *)attr_val); -} - -static void __save_resource_attribute(xmlTextReaderPtr reader, char *attribute, char **xml_attribute, char *default_value) -{ - xmlChar *attrib_val = xmlTextReaderGetAttribute(reader, XMLCHAR(attribute)); - - if (attrib_val) - *xml_attribute = strdup(ASCII(attrib_val)); - else { - if (default_value != NULL) - *xml_attribute = strdup(default_value); - } -} - - -static void __psp_process_node(xmlTextReaderPtr reader, resource_node_t **res_node) -{ - char *node_folder = NULL; - - __save_resource_attribute(reader, "folder", &node_folder, NULL); - bundle *b = NULL; - (*res_node)->folder = node_folder; - - /*retrieve node's attribute and put it into bundle*/ - b = bundle_create(); - - __save_resource_attribute_into_bundle(reader, RSC_NODE_ATTR_SCREEN_DPI, &b); - __save_resource_attribute_into_bundle(reader, RSC_NODE_ATTR_SCREEN_DPI_RANGE, &b); - __save_resource_attribute_into_bundle(reader, RSC_NODE_ATTR_SCREEN_WIDTH_RANGE, &b); - __save_resource_attribute_into_bundle(reader, RSC_NODE_ATTR_SCREEN_LARGE, &b); - __save_resource_attribute_into_bundle(reader, RSC_NODE_ATTR_SCREEN_BPP, &b); - __save_resource_attribute_into_bundle(reader, RSC_NODE_ATTR_PLATFORM_VER, &b); - __save_resource_attribute_into_bundle(reader, RSC_NODE_ATTR_LANGUAGE, &b); - - (*res_node)->attr = b; -} - -static int __psp_process_group(xmlTextReaderPtr reader, resource_group_t **res_group, char *group_type) -{ - int depth = -1; - int ret = -1; - resource_group_t *tmp_group = NULL; - resource_node_t *res_node = NULL; - const xmlChar *node; - char *folder = NULL; - - if (reader == NULL || *res_group == NULL || group_type == NULL) { - _LOGE("invalid parameter"); - return PMINFO_R_EINVAL; - } - - tmp_group = *res_group; - /*handle group's own attribute*/ - __save_resource_attribute(reader, RSC_GROUP_ATTR_FOLDER, &folder, NULL); - tmp_group->folder = folder; - tmp_group->type = group_type; - - depth = xmlTextReaderDepth(reader); - while ((ret = __next_child_element(reader, depth))) { - node = xmlTextReaderConstName(reader); - if (!node) { - _LOGE("xmlTextReaderConstName value is NULL"); - return PMINFO_R_ERROR; - } - - res_node = NULL; - if (!strcmp(ASCII(node), RSC_NODE)) { - res_node = malloc(sizeof(resource_node_t)); - if (res_node == NULL) { - _LOGE("malloc failed"); - return -1; - } - tmp_group->node_list = g_list_append(tmp_group->node_list, res_node); - __psp_process_node(reader, &res_node); - } else { - _LOGE("unidentified node has found[%s]", ASCII(node)); - return PMINFO_R_ERROR; - } - } - return ret; -} - -static int __is_group(char *node, char **type) -{ - char *tmp = NULL; - - if (node == NULL) { - _LOGE("node is null"); - return PMINFO_R_EINVAL; - } - - tmp = strchr(node, RSC_GROUP_NAME_SEPERATOR); - tmp = tmp + 1; /*remove dash seperator*/ - if (!strcmp(tmp, PKGMGR_RSC_GROUP_TYPE_IMAGE)) - *type = strdup(tmp); - else if (!strcmp(tmp, PKGMGR_RSC_GROUP_TYPE_LAYOUT)) - *type = strdup(tmp); - else if (!strcmp(tmp, PKGMGR_RSC_GROUP_TYPE_SOUND)) - *type = strdup(tmp); - else if (!strcmp(tmp, PKGMGR_RSC_GROUP_TYPE_BIN)) - *type = strdup(tmp); - else - return PMINFO_R_ERROR; - - if (*type == NULL) { - _LOGE("strdup failed with node[%s]", node); - return PMINFO_R_ERROR; - } - - return PMINFO_R_OK; -} - -static int __start_resource_process(xmlTextReaderPtr reader, GList **list) -{ - GList *tmp_list = NULL; - const xmlChar *node; - char *group_type = NULL; - int ret = -1; - int depth = -1; - resource_group_t *res_group = NULL; - - if (reader == NULL) { - _LOGE("reader is null"); - return PMINFO_R_EINVAL; - } - - depth = xmlTextReaderDepth(reader); - while ((ret = __next_child_element(reader, depth))) { - node = xmlTextReaderConstName(reader); - if (!node) { - _LOGE("xmlTextReaderConstName value is null"); - return -1; - } - - group_type = NULL; - ret = __is_group(ASCII(node), &group_type); - if (ret) { - _LOGE("unidentified node[%s] has found with error[%d]", ASCII(node), ret); - goto err; - } - res_group = NULL; - res_group = malloc(sizeof(resource_group_t)); - if (res_group == NULL) { - _LOGE("malloc failed"); - ret = PMINFO_R_ERROR; - goto err; - } - memset(res_group, '\0', sizeof(resource_group_t)); - tmp_list = g_list_append(tmp_list, res_group); - ret = __psp_process_group(reader, &res_group, group_type); - if (ret != 0) { - _LOGE("resource group processing failed"); - ret = PMINFO_R_ERROR; - goto err; - } - } - - *list = g_list_first(tmp_list); - return ret; - -err: - FREE_AND_NULL(group_type); - FREE_AND_NULL(res_group); - g_list_free_full(tmp_list, _free_group_list); - - return ret; -} - -static int __process_resource_manifest(xmlTextReaderPtr reader, resource_data_t *data) -{ - const xmlChar *node; - int ret = PMINFO_R_ERROR; - - if (reader == NULL) - return PMINFO_R_ERROR; - - ret = __next_child_element(reader, -1); - if (ret) { - node = xmlTextReaderConstName(reader); - retvm_if(!node, PMINFO_R_ERROR, "xmlTextReaderConstName value is NULL\n"); - - if (!strcmp(ASCII(node), RSC_XML_QUALIFIER)) { - ret = __start_resource_process(reader, &data->group_list); - if (data->group_list == NULL) - _LOGE("__process_resource_manifest about to end but group list is null[%d]", ret); - } else { - _LOGE("no manifest element[res] has found"); - return PMINFO_R_ERROR; - } - } - return ret; -} - -static resource_data_t *_pkgmgr_resource_parser_process_manifest_xml(const char *manifest) -{ - xmlTextReaderPtr reader; - resource_data_t *rsc_data = NULL; - - reader = xmlReaderForFile(manifest, NULL, 0); - if (reader) { - rsc_data = malloc(sizeof(resource_data_t)); - if (rsc_data == NULL) { - _LOGE("memory allocation failed"); - return NULL; - } - - memset(rsc_data, '\0', sizeof(resource_data_t)); - if (__process_resource_manifest(reader, rsc_data) < 0) { - _LOGE("parsing failed with given manifest[%s]", manifest); - if (pkgmgr_resource_parser_close(rsc_data) != 0) - _LOGE("closing failed"); - FREE_AND_NULL(rsc_data); - } else - _LOGE("parsing succeed"); - - xmlFreeTextReader(reader); - } else { - _LOGE("creating xmlreader failed"); - FREE_AND_NULL(rsc_data); - } - return rsc_data; -} - -API int pkgmgr_resource_parser_open(const char *fname, resource_data_t **data) -{ - resource_data_t *rsc_data = NULL; - int ret = PMINFO_R_ERROR; - - if (fname == NULL || access(fname, R_OK) != 0) { - _LOGE("filename is null or cannot access file"); - return PMINFO_R_EINVAL; - } - xmlInitParser(); - rsc_data = _pkgmgr_resource_parser_process_manifest_xml(fname); - if (rsc_data == NULL) { - _LOGE("parsing failed"); - goto catch; - } - - rsc_data->package = NULL; - - *data = rsc_data; - ret = PMINFO_R_OK; -catch: - xmlCleanupParser(); - return ret; -} - -API int pkgmgr_resource_parser_close(resource_data_t *data) -{ - if (data == NULL) { - _LOGE("parameter is NULL"); - return PMINFO_R_EINVAL; - } - - FREE_AND_NULL(data->package); - g_list_free_full(data->group_list, (GDestroyNotify)_free_group_list); - - return PMINFO_R_OK; -} - -API int pkgmgr_resource_parser_check_xml_validation(const char *xmlfile) -{ - if (xmlfile == NULL) { - _LOGE("manifest file is NULL\n"); - return PM_PARSER_R_EINVAL; - } - int ret = PM_PARSER_R_OK; - xmlSchemaParserCtxtPtr ctx = NULL; - xmlSchemaValidCtxtPtr vctx = NULL; - xmlSchemaPtr xschema = NULL; - ctx = xmlSchemaNewParserCtxt(RSC_MANIFEST_SCHEMA_FILE); - if (ctx == NULL) { - _LOGE("xmlSchemaNewParserCtxt() Failed\n"); - return PM_PARSER_R_ERROR; - } - xschema = xmlSchemaParse(ctx); - if (xschema == NULL) { - _LOGE("xmlSchemaParse() Failed\n"); - ret = PM_PARSER_R_ERROR; - goto cleanup; - } - vctx = xmlSchemaNewValidCtxt(xschema); - if (vctx == NULL) { - _LOGE("xmlSchemaNewValidCtxt() Failed\n"); - return PM_PARSER_R_ERROR; - } - xmlSchemaSetValidErrors(vctx, (xmlSchemaValidityErrorFunc) fprintf, (xmlSchemaValidityWarningFunc) fprintf, stderr); - ret = xmlSchemaValidateFile(vctx, xmlfile, 0); - if (ret == -1) { - _LOGE("xmlSchemaValidateFile() failed\n"); - ret = PM_PARSER_R_ERROR; - goto cleanup; - } else if (ret == 0) { - _LOGE("Manifest is Valid\n"); - ret = PM_PARSER_R_OK; - goto cleanup; - } else { - _LOGE("Manifest Validation Failed with error code %d\n", ret); - ret = PM_PARSER_R_ERROR; - goto cleanup; - } - -cleanup: - if(vctx != NULL) - xmlSchemaFreeValidCtxt(vctx); - - if(ctx != NULL) - xmlSchemaFreeParserCtxt(ctx); - - if(xschema != NULL) - xmlSchemaFree(xschema); - - return ret; -} diff --git a/parser/pkgmgr_parser_resource.h b/parser/pkgmgr_parser_resource.h deleted file mode 100644 index 002285a..0000000 --- a/parser/pkgmgr_parser_resource.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef __PKGMGR_PARSER_RESOURCE_H_ -#define __PKGMGR_PARSER_RESOURCE_H_ - -#include -#include -#include "pkgmgr_parser.h" -#include "pkgmgrinfo_resource.h" - -#define PKGMGR_RSC_GROUP_TYPE_IMAGE "image" -#define PKGMGR_RSC_GROUP_TYPE_LAYOUT "layout" -#define PKGMGR_RSC_GROUP_TYPE_SOUND "sound" -#define PKGMGR_RSC_GROUP_TYPE_BIN "bin" - -#define RSC_NODE_ATTR_SCREEN_DPI "screen-dpi" -#define RSC_NODE_ATTR_SCREEN_DPI_RANGE "screen-dpi-range" -#define RSC_NODE_ATTR_SCREEN_WIDTH_RANGE "screen-width-range" -#define RSC_NODE_ATTR_SCREEN_LARGE "screen-large" -#define RSC_NODE_ATTR_SCREEN_BPP "screen-bpp" -#define RSC_NODE_ATTR_PLATFORM_VER "platform-version" -#define RSC_NODE_ATTR_LANGUAGE "language" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @fn int *pkgmgr_resource_parser_open(const char *fname, resource_data_t **data) - * @brief This API initialize parses res.xml which identified by fname and package and put it into data. - * - * @par This API is for package-manager installer backends. - * @par Sync (or) Async : Synchronous API - * - * @param[in] fname pointer to xml filename - * @param[out]data pointer of pointer to resource_data type structure. - * @return 0 on succeed and -1 on failure, -2 on invalid parameter - */ -API int pkgmgr_resource_parser_open(const char *fname, resource_data_t **data); - -/** - * @fn int pkgmgr_resource_parser_close(resource_data_t data) - * @brief This API frees given data and its own variables - * - * @par This API is for package-manager installer backends. - * @par Sync (or) Async : Synchronous API - * - * @param[in] data structure of resource_data_t - * @return 0 on succeed and -1 on failure, -2 on invalid parameter - */ -API int pkgmgr_resource_parser_close(resource_data_t *data); - -/** - * @fn int pkgmgr_resource_parser_check_xml_validation(const char *xmlfile) - * @brief This API will validates given resource manifest file - * - * @par This API is for package-manager installer backends. - * @par Sync (or) Async : Synchronous API - * - * @param[in] manifest manifest filepath to be validated - * @return 0 on succeed and -1 on failure, -2 on invalid parameter - */ -API int pkgmgr_resource_parser_check_xml_validation(const char *xmlfile); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/parser/res.xsd.in b/parser/res.xsd.in deleted file mode 100644 index fed6b3f..0000000 --- a/parser/res.xsd.in +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/pkgmgrinfo_resource.c b/src/pkgmgrinfo_resource.c deleted file mode 100644 index 101e29d..0000000 --- a/src/pkgmgrinfo_resource.c +++ /dev/null @@ -1,12 +0,0 @@ -#include "pkgmgr_parser_resource.h" - -API int pkgmgrinfo_resource_open(const char *filepath, resource_data_t **data) -{ - return pkgmgr_resource_parser_open(filepath, data); -} - -API int pkgmgrinfo_resource_close(resource_data_t *data) -{ - return pkgmgr_resource_parser_close(data); -} -