From: Sewook Park Date: Tue, 21 Aug 2012 11:48:54 +0000 (+0900) Subject: Upload Tizen2.0 source X-Git-Tag: 2.0_alpha~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1b11dc1f408dc71d8ca6b862f18915ed201fc9c1;p=platform%2Fcore%2Fappfw%2Fslp-pkgmgr.git Upload Tizen2.0 source --- diff --git a/CMakeLists.txt b/CMakeLists.txt old mode 100644 new mode 100755 index 853ea9a..40bbbfe --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,10 +20,10 @@ SET(INCLUDEDIR "\${prefix}/include") set(CMAKE_SKIP_BUILD_RPATH true) #Verbose -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/comm) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/comm ${CMAKE_SOURCE_DIR}/parser) INCLUDE(FindPkgConfig) -pkg_check_modules(pkgs REQUIRED security-server dlog elementary evas ecore appcore-efl ecore-x ail ecore-file) +pkg_check_modules(pkgs REQUIRED security-server dlog elementary evas ecore appcore-efl ecore-x ail ecore-file libxml-2.0) FOREACH(flag ${pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") @@ -54,13 +54,14 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") ################## ## build comm libraries add_subdirectory(comm) +add_subdirectory(parser) add_subdirectory(tool) add_subdirectory(types) ################################################################################################### ## for libpkgmgr-client.so (library) SET(PKGMGR_CLIENT "pkgmgr-client") -SET(libpkgmgr-client_SOURCES ${pm_c_src_dir}/pkgmgr-info.c ${pm_c_src_dir}/pkgmgr-internal.c ${pm_c_src_dir}/pkgmgr.c) +SET(libpkgmgr-client_SOURCES ${pm_c_src_dir}/pkgmgr-info.c ${pm_c_src_dir}/pkgmgr-dbinfo.c ${pm_c_src_dir}/pkgmgr-internal.c ${pm_c_src_dir}/pkgmgr.c) SET(libpkgmgr-client_LDFLAGS " -module -avoid-version ") SET(libpkgmgr-client_CFLAGS " ${CFLAGS} -fPIC -I${pm_c_inc_dir} -I${pm_inc_dir} -I${pm_t_inc_dir} ${debug_type}") @@ -68,7 +69,7 @@ ADD_LIBRARY(${PKGMGR_CLIENT} SHARED ${libpkgmgr-client_SOURCES}) SET_TARGET_PROPERTIES(${PKGMGR_CLIENT} PROPERTIES SOVERSION ${VERSION_MAJOR}) SET_TARGET_PROPERTIES(${PKGMGR_CLIENT} PROPERTIES VERSION ${VERSION}) SET_TARGET_PROPERTIES(${PKGMGR_CLIENT} PROPERTIES COMPILE_FLAGS "${libpkgmgr-client_CFLAGS}") -TARGET_LINK_LIBRARIES(${PKGMGR_CLIENT} pkgmgr_installer_client pkgmgr_installer_status_broadcast_server ${libpkgs_LDFLAGS}) +TARGET_LINK_LIBRARIES(${PKGMGR_CLIENT} pkgmgr_installer_client pkgmgr_installer_status_broadcast_server pkgmgr_parser ${libpkgs_LDFLAGS}) ################################################################################################### ################################################################################################### diff --git a/client/include/package-manager.h b/client/include/package-manager.h index f886599..ce0d825 100755 --- a/client/include/package-manager.h +++ b/client/include/package-manager.h @@ -51,6 +51,7 @@ #define __PKG_MANAGER_H__ #include +#include #ifdef __cplusplus @@ -112,12 +113,13 @@ typedef enum _pkgmgr_return_val { /** @} */ /** - * @defgroup pkg_operate APIs to install /uninstall / application + * @defgroup pkg_operate APIs to install /uninstall / activate application * @ingroup pkgmgr * @brief - * APIs to install /uninstall / application + * APIs to install /uninstall / activate application * - Install application using application package filepath * - Uninstall application using application package name + * - Activate application using application package name * */ @@ -126,6 +128,10 @@ typedef enum _pkgmgr_return_val { * @addtogroup pkg_operate * @{ */ + +typedef void* pkgmgr_pkginfo_h; +typedef void* pkgmgr_appinfo_h; + typedef int (*pkgmgr_iter_fn)(const char* pkg_type, const char* pkg_name, const char* version, void *data); @@ -133,6 +139,9 @@ typedef int (*pkgmgr_handler)(int req_id, const char *pkg_type, const char *pkg_name, const char *key, const char *val, const void *pmsg, void *data); +typedef int (*pkgmgr_info_app_list_cb ) (const pkgmgr_appinfo_h handle, + const char *appid, void *user_data); + typedef void pkgmgr_client; @@ -147,6 +156,16 @@ typedef enum { PM_QUIET }pkgmgr_mode; +typedef enum { + PM_LOCATION_INTERNAL = 0, + PM_LOCATION_EXTERNAL +}pkgmgr_install_location; + +typedef enum { + PM_UI_APP, + PM_SVC_APP +}pkgmgr_app_component; + /** * @brief This API creates pkgmgr client. * @@ -215,6 +234,38 @@ int pkgmgr_client_uninstall(pkgmgr_client *pc, const char *pkg_type, pkgmgr_handler event_cb, void *data); /** + * @brief This API activates package. + * + * This API is for package-manager client application.\n + * + * @param[in] pc pkgmgr_client + * @param[in] pkg_type package type + * @param[in] pkg_name package name + * @return request_id (>0) if success, error code(<0) if fail\n + * @retval PKGMGR_R_OK success + * @retval PKGMGR_R_EINVAL invalid argument + * @retval PKGMGR_R_ECOMM communication error +*/ +int pkgmgr_client_activate(pkgmgr_client *pc, const char *pkg_type, + const char *pkg_name); + +/** + * @brief This API deactivates package. + * + * This API is for package-manager client application.\n + * + * @param[in] pc pkgmgr_client + * @param[in] pkg_type package type + * @param[in] pkg_name package name + * @return request_id (>0) if success, error code(<0) if fail\n + * @retval PKGMGR_R_OK success + * @retval PKGMGR_R_EINVAL invalid argument + * @retval PKGMGR_R_ECOMM communication error +*/ +int pkgmgr_client_deactivate(pkgmgr_client *pc, const char *pkg_type, + const char *pkg_name); + +/** * @brief This API deletes application's private data. * * This API is for package-manager client application.\n @@ -305,6 +356,18 @@ typedef void pkgmgr_info; pkgmgr_info * pkgmgr_info_new(const char *pkg_type, const char *pkg_name); /** + * @brief This API gets the package's information. + * + * This API is for package-manager client application.\n + * + * @param[in] pkg_type package type for the package to get infomation + * @param[in] pkg_path package file path to get infomation + * @return package entry pointer if success, NULL if fail\n +*/ +pkgmgr_info * pkgmgr_info_new_from_file(const char *pkg_type, + const char *pkg_path); + +/** * @brief This API get package information value * * This API is for package-manager client application.\n @@ -324,9 +387,295 @@ char * pkgmgr_info_get_string(pkgmgr_info * pkg_info, const char *key); * @return 0 if success, error code(<0) if fail\n */ int pkgmgr_info_free(pkgmgr_info * pkg_info); -/** @} */ +/** + * @brief This API get package info entry from db + * + * This API is for package-manager client application.\n + * + * @param[in] pkg_name pointer to package name + * @param[out] handle pointer to the package info handle. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo(const char *pkg_name, pkgmgr_pkginfo_h *handle); + +/** + * @brief This API gets type of the given package. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to package info handle + * @param[out] type to hold package type. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_type(pkgmgr_pkginfo_h handle, char **type); +/** + * @brief This API gets version of the given package. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to package info handle + * @param[out] version to hold package version. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_version(pkgmgr_pkginfo_h handle, char **version); + +/** + * @brief This API gets install location of the given package. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to package info handle + * @param[out] location to hold install location. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_install_location(pkgmgr_pkginfo_h handle, pkgmgr_install_location *location); + +/** + * @brief This API gets label of the given package. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to package info handle + * @param[out] label to hold package label. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_label(pkgmgr_pkginfo_h handle, char **label); + +/** + * @brief This API gets icon of the given package. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to package info handle + * @param[out] icon to hold package icon. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_icon(pkgmgr_pkginfo_h handle, char **icon); + +/** + * @brief This API gets desription of the given package. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to package info handle + * @param[out] description to hold package description. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_descriptioon(pkgmgr_pkginfo_h handle, char **description); + +/** + * @brief This API gets author's name of the given package. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to package info handle + * @param[out] author_name to hold author's name. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_author_name(pkgmgr_pkginfo_h handle, char **author_name); + +/** + * @brief This API gets author's email of the given package. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to package info handle + * @param[out] author_email to hold author's email id. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_author_email(pkgmgr_pkginfo_h handle, char **author_email); + +/** + * @brief This API gets author's href of the given package. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to package info handle + * @param[out] author_href to hold author's href. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_author_href(pkgmgr_pkginfo_h handle, char **author_href); + +/** + * @brief This API gets removable of the given package. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to package info handle + * @param[out] removable to hold removable value. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_removable(pkgmgr_pkginfo_h handle, bool *removable); + +/** + * @brief This API gets preload of the given package. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to package info handle + * @param[out] preload to hold preload value + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_preload(pkgmgr_pkginfo_h handle, bool *preload); + +/** + * @brief This API gets readonly value of the given package. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to package info handle + * @param[out] readonly to hold readonly value + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_readonly(pkgmgr_pkginfo_h handle, bool *readonly); + +/** + * @brief This API gets list of ui-application/service application of the given package. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to package info handle + * @param[in] component application component type. + * @param[in] app_func application's callback function. + * @param[in] user_data user data to be passed to callback function + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_info_app(pkgmgr_pkginfo_h handle, pkgmgr_app_component component, + pkgmgr_info_app_list_cb app_func, void *user_data); + +/** + * @brief This API gets list of installed applications. + * + * This API is for package-manager client application.\n + * + * @param[in] iter_fn iteration function for list + * @param[in] user_data user data to be passed to callback function + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_info_list(pkgmgr_iter_fn iter_fn, void *user_data); + + +/** + * @brief This API destroy the pacakge info handle + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to package info handle + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_destroy_pkginfo(pkgmgr_pkginfo_h handle); + +/** + * @brief This API gets application info entry from db. + * + * This API is for package-manager client application.\n + * + * @param[in] appid application id + * @param[out] handle pointer to app info handle + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_appinfo(const char *appid, pkgmgr_appinfo_h *handle); + +/** + * @brief This API gets exec of the given appid. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to app info handle + * @param[out] exec to hold exec value + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_exec(pkgmgr_appinfo_h handle, char **exec); + +/** + * @brief This API gets component type of the given appid. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to app info handle + * @param[out] component to hold component value + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_component(pkgmgr_appinfo_h handle, char **component); + +/** + * @brief This API gets app type of the given appid. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to app info handle + * @param[out] app_type to hold the apptype. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_apptype(pkgmgr_appinfo_h handle, char **app_type); + +/** + * @brief This API gets nodisplay value of the given appid. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to app info handle + * @param[out] nodisplay to hold the nodisplay value + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_nodisplay(pkgmgr_appinfo_h handle, bool *nodisplay); + +/** + * @brief This API gets multiple value of the given appid. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to app info handle + * @param[out] multiple to hold the multiple value + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_multiple(pkgmgr_appinfo_h handle, bool *multiple); + +/** + * @brief This API gets taskmanage value of the given appid. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to app info handle + * @param[out] taskmanage to hold the taskmanage value + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_taskmanage(pkgmgr_appinfo_h handle, bool *taskmanage); + +/** + * @brief This API gets onboot value of the given appid. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to app info handle + * @param[out] onboot to hold the onboot value + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_onboot(pkgmgr_appinfo_h handle, bool *onboot); + +/** + * @brief This API gets autorestart value of the given appid. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to app info handle + * @param[out] autorestart to hold the autorestart value + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_autorestart(pkgmgr_appinfo_h handle, bool *autorestart); + +/** + * @brief This API destroy the appinfo handle. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to app info handle + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_destroy_appinfo(pkgmgr_appinfo_h handle); +/** @} */ #ifdef __cplusplus } diff --git a/client/include/pkgmgr-dbinfo.h b/client/include/pkgmgr-dbinfo.h new file mode 100755 index 0000000..a5baf98 --- /dev/null +++ b/client/include/pkgmgr-dbinfo.h @@ -0,0 +1,208 @@ +/* + * slp-pkgmgr + * + * Copyright (c) 2000 - 2011 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. + * + */ + + +/** + * @file pkgmgr-dbinfo.h + * @author Shobhit Srivastava + * @version 0.1 + * @brief This file declares db set API for backend installers + * + * @addtogroup APPLICATION_FRAMEWORK + * @{ + * + * @defgroup PackageManager + * @section Header to use them: + * @code + * #include "pkgmgr-dbinfo.h" + * @endcode + * + * @addtogroup PackageManager + * @{ + */ + +#ifndef __PKGMGR_DBINFO_H__ +#define __PKGMGR_DBINFO_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef DEPRECATED +#define DEPRECATED __attribute__ ((__deprecated__)) +#endif + +typedef enum { + INSTALL_INTERNAL = 0, + INSTALL_EXTERNAL, +} INSTALL_LOCATION; + +typedef void* pkgmgr_pkgdbinfo_h; + +/** + * @brief This API creates package info handle to set info in the db. + * + * This API is for backend installers.\n + * + * @param[in] pkg_name package name. + * @param[out] handle package info handle. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_create_pkgdbinfo(const char *pkg_name, pkgmgr_pkgdbinfo_h *handle); + +/** + * @brief This API sets the package type in DB. + * + * This API is for backend installers.\n + * + * @param[in] handle package info handle. + * @param[in] type package type. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_set_type_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *type); + +/** + * @brief This API sets the package version in DB. + * + * This API is for backend installers.\n + * + * @param[in] handle package info handle. + * @param[in] version package version. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_set_version_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *version); + +/** + * @brief This API sets install location in DB + * + * This API is for backend installers.\n + * + * @param[in] handle package info handle. + * @param[in] location install location. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_set_install_location_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, INSTALL_LOCATION location); + +/** + * @brief This API sets label in DB. + * + * This API is for backend installers.\n + * + * @param[in] handle package info handle. + * @param[in] label label text. + * @param[in] locale locale (NULL for default). + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_set_label_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *label, const char *locale); + +/** + * @brief This API sets icon in DB. + * + * This API is for backend installers.\n + * + * @param[in] handle package info handle. + * @param[in] icon icon name. + * @param[in] locale locale (NULL for default). + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_set_icon_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *icon, const char *locale); + +/** + * @brief This API sets description in DB. + * + * This API is for backend installers.\n + * + * @param[in] handle package info handle. + * @param[in] description description of the package. + * @param[in] locale locale (NULL for default). + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_set_description_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *description, const char *locale); + +/** + * @brief This API sets author's name, email, href in DB. + * + * This API is for backend installers.\n + * + * @param[in] handle package info handle. + * @param[in] author_name author' name. + * @param[in] author_email author's email. + * @param[in] author_href author's href. + * @param[in] locale locale (NULL for default). + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_set_author_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *author_name, + const char *author_email, const char *author_href, const char *locale); + +/** + * @brief This API sets removable in DB. + * + * This API is for backend installers.\n + * + * @param[in] handle package info handle. + * @param[in] removable removable (0 | 1) + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_set_removable_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, int removable); + +/** + * @brief This API sets preload in DB. + * + * This API is for backend installers.\n + * + * @param[in] handle package info handle. + * @param[in] preload preload (0 | 1) + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_set_preload_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, int preload); + +/** + * @brief This API save pakage info entry into the db. + * + * This API is for backend installers.\n + * + * @param[in] handle package info handle. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_save_pkgdbinfo(pkgmgr_pkgdbinfo_h handle); + +/** + * @brief This API destroy pakage info handle and free the resources. + * + * This API is for backend installers.\n + * + * @param[in] handle package info handle. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_destroy_pkgdbinfo(pkgmgr_pkgdbinfo_h handle); + +#ifdef __cplusplus +} +#endif +#endif /* __PKGMGR_DBINFO_H__ */ +/** + * @} + * @} + */ + diff --git a/client/include/pkgmgr-internal.h b/client/include/pkgmgr-internal.h index 5779015..200ad1b 100755 --- a/client/include/pkgmgr-internal.h +++ b/client/include/pkgmgr-internal.h @@ -39,6 +39,7 @@ #define PKG_FRONTEND "frontend:" #define PKG_BACKEND "backend:" #define PKG_BACKENDLIB "backendlib:" +#define PKG_PARSERLIB "parserlib:" #define PKG_CONF_PATH "/usr/etc/package-manager/pkg_path.conf" #define PKG_STATUS "STATUS" diff --git a/client/src/pkgmgr-dbinfo.c b/client/src/pkgmgr-dbinfo.c new file mode 100755 index 0000000..97355a2 --- /dev/null +++ b/client/src/pkgmgr-dbinfo.c @@ -0,0 +1,345 @@ +/* + * slp-pkgmgr + * + * Copyright (c) 2000 - 2011 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 "package-manager.h" +#include "package-manager-types.h" +#include "pkgmgr-internal.h" +#include "pkgmgr-api.h" +#include "pkgmgr_parser.h" +#include "pkgmgr-dbinfo.h" + +API int pkgmgr_create_pkgdbinfo(const char *pkg_name, pkgmgr_pkgdbinfo_h *handle) +{ + if (!pkg_name || !handle) { + _LOGE("Argument supplied is NULL\n"); + return PKGMGR_R_EINVAL; + } + manifest_x *mfx = NULL; + mfx = calloc(1, sizeof(manifest_x)); + if (!mfx) { + _LOGE("Malloc Failed\n"); + return PKGMGR_R_ERROR; + } + mfx->package = strdup(pkg_name); + *handle = (void *)mfx; + return PKGMGR_R_OK; +} + +API int pkgmgr_set_type_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *type) +{ + if (!type || !handle) { + _LOGE("Argument supplied is NULL\n"); + return PKGMGR_R_EINVAL; + } + int len = strlen(type); + manifest_x *mfx = (manifest_x *)handle; + if (len > PKG_TYPE_STRING_LEN_MAX) { + _LOGE("pkg type length exceeds the max limit\n"); + return PKGMGR_R_EINVAL; + } + if (mfx->type == NULL) + mfx->type = strndup(type, PKG_TYPE_STRING_LEN_MAX); + else + mfx->type = type; + + return PKGMGR_R_OK; +} + +API int pkgmgr_set_version_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *version) +{ + if (!version || !handle) { + _LOGE("Argument supplied is NULL\n"); + return PKGMGR_R_EINVAL; + } + int len = strlen(version); + manifest_x *mfx = (manifest_x *)handle; + if (len > PKG_VERSION_STRING_LEN_MAX) { + _LOGE("pkg version length exceeds the max limit\n"); + return PKGMGR_R_EINVAL; + } + if (mfx->version == NULL) + mfx->version = strndup(version, PKG_VERSION_STRING_LEN_MAX); + else + mfx->version = version; + + return PKGMGR_R_OK; +} + +API int pkgmgr_set_install_location_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, INSTALL_LOCATION location) +{ + if (!handle) { + _LOGE("Argument supplied is NULL\n"); + return PKGMGR_R_EINVAL; + } + if (location < 0 || location > 1) { + _LOGE("Argument supplied is invalid\n"); + return PKGMGR_R_EINVAL; + } + manifest_x *mfx = (manifest_x *)handle; + if (mfx->installlocation == NULL) { + mfx->installlocation = (char *)calloc(1, strlen("prefer-external")); + if (mfx->installlocation == NULL) { + _LOGE("Malloc Failed\n"); + return PKGMGR_R_ERROR; + } + } + if (location == INSTALL_INTERNAL) { + strcpy(mfx->installlocation, "internal-only"); + } else if (location == INSTALL_EXTERNAL) { + strcpy(mfx->installlocation, "prefer-external"); + } else { + _LOGE("Invalid location type\n"); + return PKGMGR_R_ERROR; + } + return PKGMGR_R_OK; +} + +API int pkgmgr_set_label_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *label_txt, const char *locale) +{ + if (!handle || !label_txt) { + _LOGE("Argument supplied is NULL\n"); + return PKGMGR_R_EINVAL; + } + int len = strlen(label_txt); + manifest_x *mfx = (manifest_x *)handle; + if (len > PKG_VALUE_STRING_LEN_MAX) { + _LOGE("label length exceeds the max limit\n"); + return PKGMGR_R_EINVAL; + } + label_x *label = calloc(1, sizeof(label_x)); + if (label == NULL) { + _LOGE("Malloc Failed\n"); + return PKGMGR_R_ERROR; + } + LISTADD(mfx->label, label); + if (locale) + mfx->label->lang = strdup(locale); + else + mfx->label->lang = strdup(DEFAULT_LOCALE); + mfx->label->text = strdup(label_txt); + + return PKGMGR_R_OK; +} + +API int pkgmgr_set_icon_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *icon_txt, const char *locale) +{ + if (!handle || !icon_txt) { + _LOGE("Argument supplied is NULL\n"); + return PKGMGR_R_EINVAL; + } + int len = strlen(icon_txt); + manifest_x *mfx = (manifest_x *)handle; + if (len > PKG_VALUE_STRING_LEN_MAX) { + _LOGE("icon length exceeds the max limit\n"); + return PKGMGR_R_EINVAL; + } + icon_x *icon = calloc(1, sizeof(icon_x)); + if (icon == NULL) { + _LOGE("Malloc Failed\n"); + return PKGMGR_R_ERROR; + } + LISTADD(mfx->icon, icon); + if (locale) + mfx->icon->lang = strdup(locale); + else + mfx->icon->lang = strdup(DEFAULT_LOCALE); + mfx->icon->text = strdup(icon_txt); + + return PKGMGR_R_OK; +} + +API int pkgmgr_set_description_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *desc_txt, const char *locale) +{ + if (!handle || !desc_txt) { + _LOGE("Argument supplied is NULL\n"); + return PKGMGR_R_EINVAL; + } + int len = strlen(desc_txt); + manifest_x *mfx = (manifest_x *)handle; + if (len > PKG_VALUE_STRING_LEN_MAX) { + _LOGE("description length exceeds the max limit\n"); + return PKGMGR_R_EINVAL; + } + description_x *description = calloc(1, sizeof(description_x)); + if (description == NULL) { + _LOGE("Malloc Failed\n"); + return PKGMGR_R_ERROR; + } + LISTADD(mfx->description, description); + if (locale) + mfx->description->lang = strdup(locale); + else + mfx->description->lang = strdup(DEFAULT_LOCALE); + mfx->description->text = strdup(desc_txt); + + return PKGMGR_R_OK; +} + +API int pkgmgr_set_author_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *author_name, + const char *author_email, const char *author_href, const char *locale) +{ + if (!handle) { + _LOGE("Argument supplied is NULL\n"); + return PKGMGR_R_EINVAL; + } + manifest_x *mfx = (manifest_x *)handle; + author_x *author = calloc(1, sizeof(author_x)); + if (author == NULL) { + _LOGE("Malloc Failed\n"); + return PKGMGR_R_ERROR; + } + LISTADD(mfx->author, author); + if (author_name) + mfx->author->text = strdup(author_name); + if (author_email) + mfx->author->email = strdup(author_email); + if (author_href) + mfx->author->href = strdup(author_href); + if (locale) + mfx->author->lang = strdup(locale); + else + mfx->author->lang = strdup(DEFAULT_LOCALE); + return PKGMGR_R_OK; +} + +API int pkgmgr_set_removable_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, int removable) +{ + if (!handle) { + _LOGE("Argument supplied is NULL\n"); + return PKGMGR_R_EINVAL; + } + if (removable < 0 || removable > 1) { + _LOGE("Argument supplied is invalid\n"); + return PKGMGR_R_EINVAL; + } + manifest_x *mfx = (manifest_x *)handle; + if (mfx->removable == NULL) { + mfx->removable = (char *)calloc(1, strlen("false")); + if (mfx->removable == NULL) { + _LOGE("Malloc Failed\n"); + return PKGMGR_R_ERROR; + } + } + if (removable == 0) { + strcpy(mfx->removable, "false"); + } else if (removable == 1) { + strcpy(mfx->removable, "true"); + } else { + _LOGE("Invalid removable type\n"); + return PKGMGR_R_ERROR; + } + PKGMGR_R_OK; +} + +API int pkgmgr_set_preload_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, int preload) +{ + if (!handle) { + _LOGE("Argument supplied is NULL\n"); + return PKGMGR_R_EINVAL; + } + if (preload < 0 || preload > 1) { + _LOGE("Argument supplied is invalid\n"); + return PKGMGR_R_EINVAL; + } + manifest_x *mfx = (manifest_x *)handle; + if (mfx->preload == NULL) { + mfx->preload = (char *)calloc(1, strlen("false")); + if (mfx->preload == NULL) { + _LOGE("Malloc Failed\n"); + return PKGMGR_R_ERROR; + } + } + if (preload == 0) { + strcpy(mfx->preload, "false"); + } else if (preload == 1) { + strcpy(mfx->preload, "true"); + } else { + _LOGE("Invalid preload type\n"); + return PKGMGR_R_ERROR; + } + PKGMGR_R_OK; +} + +API int pkgmgr_save_pkgdbinfo(pkgmgr_pkgdbinfo_h handle) +{ + if (!handle) { + _LOGE("Argument supplied is NULL\n"); + return PKGMGR_R_EINVAL; + } + int ret = 0; + manifest_x *mfx = NULL; + label_x *tmp1 = NULL; + icon_x *tmp2 = NULL; + description_x *tmp3 = NULL; + author_x *tmp4 = NULL; + mfx = (manifest_x *)handle; + /*First move to head of all list pointers*/ + if (mfx->label) { + LISTHEAD(mfx->label, tmp1); + mfx->label = tmp1; + } + if (mfx->icon) { + LISTHEAD(mfx->icon, tmp2); + mfx->icon = tmp2; + } + if (mfx->description) { + LISTHEAD(mfx->description, tmp3); + mfx->description= tmp3; + } + if (mfx->author) { + LISTHEAD(mfx->author, tmp4); + mfx->author = tmp4; + } + ret = pkgmgr_parser_insert_manifest_info_in_db(mfx); + if (ret == 0) { + _LOGE("Successfully stored info in DB\n"); + return PKGMGR_R_OK; + } else { + _LOGE("Failed to store info in DB\n"); + return PKGMGR_R_ERROR; + } +} + +API int pkgmgr_destroy_pkgdbinfo(pkgmgr_pkgdbinfo_h handle) +{ + if (!handle) { + _LOGE("Argument supplied is NULL\n"); + return PKGMGR_R_EINVAL; + } + manifest_x *mfx = NULL; + mfx = (manifest_x *)handle; + pkgmgr_parser_free_manifest_xml(mfx); + return PKGMGR_R_OK; +} + diff --git a/client/src/pkgmgr.c b/client/src/pkgmgr.c index 8302f67..7c35f14 100755 --- a/client/src/pkgmgr.c +++ b/client/src/pkgmgr.c @@ -31,14 +31,20 @@ #include #include #include +#include +#include #include "package-manager.h" #include "pkgmgr-internal.h" #include "pkgmgr-info.h" #include "pkgmgr-api.h" #include "comm_client.h" +#include "pkgmgr_parser.h" #include "comm_status_broadcast_server.h" +#define MANIFEST_DB "/opt/dbspace/.pkgmgr_parser.db" +#define MAX_QUERY_LEN 4096 + static int _get_request_id() { static int internal_req_id = 1; @@ -83,6 +89,417 @@ typedef struct _iter_data { void *data; } iter_data; +typedef struct _pkgmgr_pkginfo_x { + int pkg_handle_id; + manifest_x *manifest_info; +} pkgmgr_pkginfo_x; + +typedef struct _pkgmgr_appinfo_x { + int app_handle_id; + char *app_component; + uiapplication_x *uiapp_info; + serviceapplication_x *svcapp_info; +} pkgmgr_appinfo_x; + +char *pkgtype = "rpm"; +sqlite3 *manifest_db = NULL; + +static int __open_manifest_db(); +static int __exec_pkginfo_query(char *query, void *data); +static int __exec_appinfo_query(char *query, void *data); +static int __pkginfo_cb(void *data, int ncols, char **coltxt, char **colname); +static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname); +static int __validate_cb(void *data, int ncols, char **coltxt, char **colname); +static int __uiapp_list_cb(void *data, int ncols, char **coltxt, char **colname); +static int __svcapp_list_cb(void *data, int ncols, char **coltxt, char **colname); +static int __pkg_list_cb(void *data, int ncols, char **coltxt, char **colname); +static int __pkgmgr_appinfo_new_handle_id(); +static int __pkgmgr_pkginfo_new_handle_id(); +static void __cleanup_pkginfo(pkgmgr_pkginfo_x *data); +static void __cleanup_appinfo(pkgmgr_appinfo_x *data); +static char* __convert_system_locale_to_manifest_locale(char *syslocale); + +static int __pkgmgr_pkginfo_new_handle_id() +{ + static int pkginfo_handle_id = 0; + return pkginfo_handle_id++; +} + +static int __pkgmgr_appinfo_new_handle_id() +{ + static int appinfo_handle_id = 0; + return appinfo_handle_id++; +} + +static char* __convert_system_locale_to_manifest_locale(char *syslocale) +{ + if (syslocale == NULL) + return strdup(DEFAULT_LOCALE); + char *locale = NULL; + locale = (char *)calloc(1, 6); + if (!locale) { + _LOGE("Malloc Failed\n"); + return NULL; + } + strncpy(locale, syslocale, 2); + strncat(locale, "-", 1); + locale[3] = syslocale[3] + 32; + locale[4] = syslocale[4] + 32; + return locale; +} + +static void __cleanup_pkginfo(pkgmgr_pkginfo_x *data) +{ + if (data == NULL) + return; + pkgmgr_parser_free_manifest_xml(data->manifest_info); + free((void *)data); + data = NULL; + return; +} + +static void __cleanup_appinfo(pkgmgr_appinfo_x *data) +{ + if (data == NULL) + return; + if (data->app_component) { + free((void *)data->app_component); + data->app_component = NULL; + } + manifest_x *mfx = calloc(1, sizeof(manifest_x)); + mfx->uiapplication = data->uiapp_info; + mfx->serviceapplication = data->svcapp_info; + pkgmgr_parser_free_manifest_xml(mfx); + free((void *)data); + data = NULL; + return; +} + +static int __open_manifest_db() +{ + int ret = -1; + if (access(MANIFEST_DB, F_OK) == 0) { + ret = + db_util_open_with_options(MANIFEST_DB, &manifest_db, + SQLITE_OPEN_READONLY, NULL); + if (ret != SQLITE_OK) { + _LOGE("connect db [%s] failed!\n", MANIFEST_DB); + return -1; + } + return 0; + } + _LOGE("Manifest DB does not exists !!\n"); + return -1; +} + +static int __pkg_list_cb(void *data, int ncols, char **coltxt, char **colname) +{ + char *pkg_name = NULL; + char *pkg_type = NULL; + char *pkg_version = NULL; + int i = 0; + iter_data *udata = (iter_data *)data; + for(i = 0; i < ncols; i++) + { + if (strcmp(colname[i], "package") == 0) { + if (coltxt[i]) + pkg_name = strdup(coltxt[i]); + } else if (strcmp(colname[i], "package_type") == 0) { + if (coltxt[i]) + pkg_type = strdup(coltxt[i]); + } else if (strcmp(colname[i], "package_version") == 0 ){ + if (coltxt[i]) + pkg_version = strdup(coltxt[i]); + } else + continue; + } + udata->iter_fn(pkg_type, pkg_name, pkg_version, udata->data); + if (pkg_name) { + free(pkg_name); + pkg_name = NULL; + } + if (pkg_type) { + free(pkg_type); + pkg_type = NULL; + } + if (pkg_version) { + free(pkg_version); + pkg_version = NULL; + } + return 0; +} + +static int __uiapp_list_cb(void *data, int ncols, char **coltxt, char **colname) +{ + pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data; + int i = 0; + uiapplication_x *uiapp = NULL; + uiapp = calloc(1, sizeof(uiapplication_x)); + LISTADD(info->manifest_info->uiapplication, uiapp); + for(i = 0; i < ncols; i++) + { + if (strcmp(colname[i], "app_id") == 0) { + if (coltxt[i]) + info->manifest_info->uiapplication->appid = strdup(coltxt[i]); + else + info->manifest_info->uiapplication->appid = NULL; + } else if (strcmp(colname[i], "app_exec") == 0) { + if (coltxt[i]) + info->manifest_info->uiapplication->exec = strdup(coltxt[i]); + else + info->manifest_info->uiapplication->exec = NULL; + } else if (strcmp(colname[i], "app_type") == 0 ){ + if (coltxt[i]) + info->manifest_info->uiapplication->type = strdup(coltxt[i]); + else + info->manifest_info->uiapplication->type = NULL; + } else if (strcmp(colname[i], "app_nodisplay") == 0 ){ + if (coltxt[i]) + info->manifest_info->uiapplication->nodisplay = strdup(coltxt[i]); + else + info->manifest_info->uiapplication->nodisplay = NULL; + } else if (strcmp(colname[i], "app_multiple") == 0 ){ + if (coltxt[i]) + info->manifest_info->uiapplication->multiple = strdup(coltxt[i]); + else + info->manifest_info->uiapplication->multiple = NULL; + } else if (strcmp(colname[i], "app_taskmanage") == 0 ){ + if (coltxt[i]) + info->manifest_info->uiapplication->taskmanage = strdup(coltxt[i]); + else + info->manifest_info->uiapplication->taskmanage = NULL; + } else + continue; + } + return 0; +} + +static int __svcapp_list_cb(void *data, int ncols, char **coltxt, char **colname) +{ + pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data; + int i = 0; + serviceapplication_x *svcapp = NULL; + svcapp = calloc(1, sizeof(serviceapplication_x)); + LISTADD(info->manifest_info->serviceapplication, svcapp); + for(i = 0; i < ncols; i++) + { + if (strcmp(colname[i], "app_id") == 0) { + if (coltxt[i]) + info->manifest_info->serviceapplication->appid = strdup(coltxt[i]); + else + info->manifest_info->serviceapplication->appid = NULL; + } else if (strcmp(colname[i], "app_exec") == 0) { + if (coltxt[i]) + info->manifest_info->serviceapplication->exec = strdup(coltxt[i]); + else + info->manifest_info->serviceapplication->exec = NULL; + } else if (strcmp(colname[i], "app_type") == 0 ){ + if (coltxt[i]) + info->manifest_info->serviceapplication->type = strdup(coltxt[i]); + else + info->manifest_info->serviceapplication->type = NULL; + } else if (strcmp(colname[i], "app_onboot") == 0 ){ + if (coltxt[i]) + info->manifest_info->serviceapplication->onboot = strdup(coltxt[i]); + else + info->manifest_info->serviceapplication->onboot = NULL; + } else if (strcmp(colname[i], "app_autorestart") == 0 ){ + if (coltxt[i]) + info->manifest_info->serviceapplication->autorestart = strdup(coltxt[i]); + else + info->manifest_info->serviceapplication->autorestart = NULL; + } else + continue; + } + return 0; +} + +static int __validate_cb(void *data, int ncols, char **coltxt, char **colname) +{ + int *p = (int*)data; + *p = atoi(coltxt[0]); + _LOGE("exist value is %d\n", *p); + return 0; +} + +static int __pkginfo_cb(void *data, int ncols, char **coltxt, char **colname) +{ + pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data; + int i = 0; + author_x *author = NULL; + icon_x *icon = NULL; + label_x *label = NULL; + description_x *description = NULL; + + author = calloc(1, sizeof(author_x)); + LISTADD(info->manifest_info->author, author); + icon = calloc(1, sizeof(icon_x)); + LISTADD(info->manifest_info->icon, icon); + label = calloc(1, sizeof(label_x)); + LISTADD(info->manifest_info->label, label); + description = calloc(1, sizeof(description_x)); + LISTADD(info->manifest_info->description, description); + for(i = 0; i < ncols; i++) + { + if (strcmp(colname[i], "package_version") == 0) { + if (coltxt[i]) + info->manifest_info->version = strdup(coltxt[i]); + else + info->manifest_info->version = NULL; + } else if (strcmp(colname[i], "package_type") == 0) { + if (coltxt[i]) + info->manifest_info->type = strdup(coltxt[i]); + else + info->manifest_info->type = NULL; + } else if (strcmp(colname[i], "install_location") == 0) { + if (coltxt[i]) + info->manifest_info->installlocation = strdup(coltxt[i]); + else + info->manifest_info->installlocation = NULL; + } else if (strcmp(colname[i], "author_email") == 0 ){ + if (coltxt[i]) + info->manifest_info->author->email = strdup(coltxt[i]); + else + info->manifest_info->author->email = NULL; + } else if (strcmp(colname[i], "author_href") == 0 ){ + if (coltxt[i]) + info->manifest_info->author->href = strdup(coltxt[i]); + else + info->manifest_info->author->href = NULL; + } else if (strcmp(colname[i], "package_label") == 0 ){ + if (coltxt[i]) + info->manifest_info->label->text = strdup(coltxt[i]); + else + info->manifest_info->label->text = NULL; + } else if (strcmp(colname[i], "package_icon") == 0 ){ + if (coltxt[i]) + info->manifest_info->icon->name = strdup(coltxt[i]); + else + info->manifest_info->icon->name = NULL; + } else if (strcmp(colname[i], "package_description") == 0 ){ + if (coltxt[i]) + info->manifest_info->description->text = strdup(coltxt[i]); + else + info->manifest_info->description->text = NULL; + } else if (strcmp(colname[i], "package_author") == 0 ){ + if (coltxt[i]) + info->manifest_info->author->text = strdup(coltxt[i]); + else + info->manifest_info->author->text = NULL; + } else if (strcmp(colname[i], "package_removable") == 0 ){ + if (coltxt[i]) + info->manifest_info->removable = strdup(coltxt[i]); + else + info->manifest_info->removable = NULL; + } else if (strcmp(colname[i], "package_preload") == 0 ){ + if (coltxt[i]) + info->manifest_info->preload = strdup(coltxt[i]); + else + info->manifest_info->preload = NULL; + } else if (strcmp(colname[i], "package_readonly") == 0 ){ + if (coltxt[i]) + info->manifest_info->readonly = strdup(coltxt[i]); + else + info->manifest_info->readonly = NULL; + } else if (strcmp(colname[i], "package_locale") == 0 ){ + if (coltxt[i]) { + info->manifest_info->author->lang = strdup(coltxt[i]); + info->manifest_info->icon->lang = strdup(coltxt[i]); + info->manifest_info->label->lang = strdup(coltxt[i]); + info->manifest_info->description->lang = strdup(coltxt[i]); + } + else { + info->manifest_info->author->lang = NULL; + info->manifest_info->icon->lang = NULL; + info->manifest_info->label->lang = NULL; + info->manifest_info->description->lang = NULL; + } + } else + continue; + } + return 0; +} + +static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname) +{ + pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)data; + int i = 0; + for(i = 0; i < ncols; i++) + { + if (strcmp(colname[i], "app_exec") == 0) { + if (coltxt[i]) + info->uiapp_info->exec = strdup(coltxt[i]); + else + info->uiapp_info->exec = NULL; + } else if (strcmp(colname[i], "app_component") == 0) { + if (coltxt[i]) + info->app_component = strdup(coltxt[i]); + else + info->app_component = NULL; + } else if (strcmp(colname[i], "app_nodisplay") == 0) { + if (coltxt[i]) + info->uiapp_info->nodisplay = strdup(coltxt[i]); + else + info->uiapp_info->nodisplay = NULL; + } else if (strcmp(colname[i], "app_type") == 0 ){ + if (coltxt[i]) + info->uiapp_info->type = strdup(coltxt[i]); + else + info->uiapp_info->type = NULL; + } else if (strcmp(colname[i], "app_multiple") == 0 ){ + if (coltxt[i]) + info->uiapp_info->multiple = strdup(coltxt[i]); + else + info->uiapp_info->multiple = NULL; + } else if (strcmp(colname[i], "app_onboot") == 0 ){ + if (coltxt[i]) + info->svcapp_info->onboot = strdup(coltxt[i]); + else + info->svcapp_info->onboot = NULL; + } else if (strcmp(colname[i], "app_autorestart") == 0 ){ + if (coltxt[i]) + info->svcapp_info->autorestart = strdup(coltxt[i]); + else + info->svcapp_info->autorestart = NULL; + } else if (strcmp(colname[i], "app_taskmanage") == 0 ){ + if (coltxt[i]) + info->uiapp_info->taskmanage = strdup(coltxt[i]); + else + info->uiapp_info->taskmanage = NULL; + } else + continue; + } + return 0; +} + +static int __exec_pkginfo_query(char *query, void *data) +{ + char *error_message = NULL; + if (SQLITE_OK != + sqlite3_exec(manifest_db, query, __pkginfo_cb, data, &error_message)) { + _LOGE("Don't execute query = %s error message = %s\n", query, + error_message); + sqlite3_free(error_message); + return -1; + } + sqlite3_free(error_message); + return 0; +} + +static int __exec_appinfo_query(char *query, void *data) +{ + char *error_message = NULL; + if (SQLITE_OK != + sqlite3_exec(manifest_db, query, __appinfo_cb, data, &error_message)) { + _LOGE("Don't execute query = %s error message = %s\n", query, + error_message); + sqlite3_free(error_message); + return -1; + } + sqlite3_free(error_message); + return 0; +} + static void __add_op_cbinfo(pkgmgr_client_t * pc, int request_id, const char *req_key, pkgmgr_handler event_cb, void *data) @@ -580,7 +997,7 @@ API int pkgmgr_client_install(pkgmgr_client * pc, const char *pkg_type, /* 6. request install */ ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_INSTALLER, pkgtype, pkg_path, - args, cookie, 0); + args, cookie, 1); if (ret < 0) { _LOGE("request failed, ret=%d\n", ret); @@ -724,7 +1141,7 @@ API int pkgmgr_client_uninstall(pkgmgr_client *pc, const char *pkg_type, /* 6. request install */ ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_INSTALLER, pkgtype, pkg_name, - args, cookie, 0); + args, cookie, 1); if (ret < 0) { _LOGE("request failed, ret=%d\n", ret); @@ -743,6 +1160,106 @@ API int pkgmgr_client_uninstall(pkgmgr_client *pc, const char *pkg_type, return req_id; } +API int pkgmgr_client_activate(pkgmgr_client * pc, const char *pkg_type, + const char *pkg_name) +{ + const char *pkgtype; + char *req_key; + char *cookie = NULL; + int ret; + /* Check for NULL value of pc */ + if (pc == NULL) { + _LOGD("package manager client handle is NULL\n"); + return PKGMGR_R_EINVAL; + } + pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc; + + /* 0. check the pc type */ + if (mpc->ctype != PC_REQUEST) + return PKGMGR_R_EINVAL; + + /* 1. check argument */ + if (pkg_name == NULL) + return PKGMGR_R_EINVAL; + + if (pkg_type == NULL) { + pkgtype = _get_pkg_type_from_desktop_file(pkg_name); + if (pkgtype == NULL) + return PKGMGR_R_EINVAL; + } else + pkgtype = pkg_type; + + if (strlen(pkg_name) >= PKG_STRING_LEN_MAX) + return PKGMGR_R_EINVAL; + + /* 2. generate req_key */ + req_key = __get_req_key(pkg_name); + + /* 3. request activate */ + ret = comm_client_request(mpc->info.request.cc, req_key, + COMM_REQ_TO_ACTIVATOR, pkgtype, + pkg_name, "1", cookie, 1); + if (ret < 0) { + _LOGE("request failed, ret=%d\n", ret); + free(req_key); + return PKGMGR_R_ECOMM; + } + + free(req_key); + + return PKGMGR_R_OK; +} + +API int pkgmgr_client_deactivate(pkgmgr_client *pc, const char *pkg_type, + const char *pkg_name) +{ + const char *pkgtype; + char *req_key; + char *cookie = NULL; + int ret; + /* Check for NULL value of pc */ + if (pc == NULL) { + _LOGD("package manager client handle is NULL\n"); + return PKGMGR_R_EINVAL; + } + pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc; + + /* 0. check the pc type */ + if (mpc->ctype != PC_REQUEST) + return PKGMGR_R_EINVAL; + + /* 1. check argument */ + if (pkg_name == NULL) + return PKGMGR_R_EINVAL; + + if (pkg_type == NULL) { + pkgtype = _get_pkg_type_from_desktop_file(pkg_name); + if (pkgtype == NULL) + return PKGMGR_R_EINVAL; + } else + pkgtype = pkg_type; + + if (strlen(pkg_name) >= PKG_STRING_LEN_MAX) + return PKGMGR_R_EINVAL; + + /* 2. generate req_key */ + req_key = __get_req_key(pkg_name); + + /* 3. request activate */ + ret = comm_client_request(mpc->info.request.cc, req_key, + COMM_REQ_TO_ACTIVATOR, pkgtype, + pkg_name, "0", cookie, 1); + if (ret < 0) { + _LOGE("request failed, ret=%d\n", ret); + free(req_key); + return PKGMGR_R_ECOMM; + } + + free(req_key); + + return PKGMGR_R_OK; +} + API int pkgmgr_client_clear_user_data(pkgmgr_client *pc, const char *pkg_type, const char *pkg_name, pkgmgr_mode mode) { @@ -1120,3 +1637,934 @@ API int pkgmgr_info_free(pkgmgr_info * pkg_info) return 0; } + +API int pkgmgr_get_pkginfo_type(pkgmgr_pkginfo_h handle, char **type) +{ + if (handle == NULL) { + _LOGE("pkginfo handle is NULL\n"); + return PKGMGR_R_EINVAL; + } + if (type == NULL) { + _LOGE("Argument supplied to hold return value is NULL\n"); + return PKGMGR_R_EINVAL; + } + pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle; + if (info->manifest_info->type) + *type = info->manifest_info->type; + else + *type = pkgtype; + return PKGMGR_R_OK; +} + +API int pkgmgr_get_pkginfo_version(pkgmgr_pkginfo_h handle, char **version) +{ + if (handle == NULL) { + _LOGE("pkginfo handle is NULL\n"); + return PKGMGR_R_EINVAL; + } + if (version == NULL) { + _LOGE("Argument supplied to hold return value is NULL\n"); + return PKGMGR_R_EINVAL; + } + pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle; + *version = (char *)info->manifest_info->version; + return PKGMGR_R_OK; +} + +API int pkgmgr_get_pkginfo_install_location(pkgmgr_pkginfo_h handle, pkgmgr_install_location *location) +{ + if (handle == NULL) { + _LOGE("pkginfo handle is NULL\n"); + return PKGMGR_R_EINVAL; + } + if (location == NULL) { + _LOGE("Argument supplied to hold return value is NULL\n"); + return PKGMGR_R_EINVAL; + } + char *val = NULL; + pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle; + val = (char *)info->manifest_info->installlocation; + if (val) { + if (strcmp(val, "internal-only") == 0) + *location = 0; + else if (strcmp(val, "prefer-external") == 0) + *location = 1; + else + *location = 1; + } + return PKGMGR_R_OK; +} + +API int pkgmgr_get_pkginfo_icon(pkgmgr_pkginfo_h handle, char **icon) +{ + if (handle == NULL) { + _LOGE("pkginfo handle is NULL\n"); + return PKGMGR_R_EINVAL; + } + if (icon == NULL) { + _LOGE("Argument supplied to hold return value is NULL\n"); + return PKGMGR_R_EINVAL; + } + char *syslocale = NULL; + char *locale = NULL; + char *save = NULL; + icon_x *ptr = NULL; + syslocale = vconf_get_str(VCONFKEY_LANGSET); + if (syslocale == NULL) { + _LOGE("current locale is NULL\n"); + return PKGMGR_R_EINVAL; + } + locale = __convert_system_locale_to_manifest_locale(syslocale); + if (locale == NULL) { + _LOGE("manifest locale is NULL\n"); + return PKGMGR_R_EINVAL; + } + save = locale; + *icon = NULL; + pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle; + for(ptr = info->manifest_info->icon; ptr != NULL; ptr = ptr->next) + { + if (ptr->lang) { + if (strcmp(ptr->lang, locale) == 0) { + *icon = (char *)ptr->name; + if (strcmp(*icon, "(null)") == 0) { + locale = DEFAULT_LOCALE; + continue; + } else + break; + } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) { + *icon = (char *)ptr->text; + break; + } + } + } + if (syslocale) { + free(syslocale); + syslocale = NULL; + } + locale = save; + if (locale) { + free(locale); + locale = NULL; + } + return PKGMGR_R_OK; +} + +API int pkgmgr_get_pkginfo_label(pkgmgr_pkginfo_h handle, char **label) +{ + if (handle == NULL) { + _LOGE("pkginfo handle is NULL\n"); + return PKGMGR_R_EINVAL; + } + if (label == NULL) { + _LOGE("Argument supplied to hold return value is NULL\n"); + return PKGMGR_R_EINVAL; + } + char *syslocale = NULL; + char *locale = NULL; + char *save = NULL; + label_x *ptr = NULL; + syslocale = vconf_get_str(VCONFKEY_LANGSET); + if (syslocale == NULL) { + _LOGE("current locale is NULL\n"); + return PKGMGR_R_EINVAL; + } + locale = __convert_system_locale_to_manifest_locale(syslocale); + if (locale == NULL) { + _LOGE("manifest locale is NULL\n"); + return PKGMGR_R_EINVAL; + } + save = locale; + *label = NULL; + pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle; + for(ptr = info->manifest_info->label; ptr != NULL; ptr = ptr->next) + { + if (ptr->lang) { + if (strcmp(ptr->lang, locale) == 0) { + *label = (char *)ptr->text; + if (strcmp(*label, "(null)") == 0) { + locale = DEFAULT_LOCALE; + continue; + } else + break; + } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) { + *label = (char *)ptr->text; + break; + } + } + } + if (syslocale) { + free(syslocale); + syslocale = NULL; + } + locale = save; + if (locale) { + free(locale); + locale = NULL; + } + return PKGMGR_R_OK; +} + +API int pkgmgr_get_pkginfo_description(pkgmgr_pkginfo_h handle, char **description) +{ + if (handle == NULL) { + _LOGE("pkginfo handle is NULL\n"); + return PKGMGR_R_EINVAL; + } + if (description == NULL) { + _LOGE("Argument supplied to hold return value is NULL\n"); + return PKGMGR_R_EINVAL; + } + char *syslocale = NULL; + char *locale = NULL; + char *save = NULL; + description_x *ptr = NULL; + syslocale = vconf_get_str(VCONFKEY_LANGSET); + if (syslocale == NULL) { + _LOGE("current locale is NULL\n"); + return PKGMGR_R_EINVAL; + } + locale = __convert_system_locale_to_manifest_locale(syslocale); + if (locale == NULL) { + _LOGE("manifest locale is NULL\n"); + return PKGMGR_R_EINVAL; + } + save = locale; + *description = NULL; + pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle; + for(ptr = info->manifest_info->description; ptr != NULL; ptr = ptr->next) + { + if (ptr->lang) { + if (strcmp(ptr->lang, locale) == 0) { + *description = (char *)ptr->text; + if (strcmp(*description, "(null)") == 0) { + locale = DEFAULT_LOCALE; + continue; + } else + break; + } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) { + *description = (char *)ptr->text; + break; + } + } + } + if (syslocale) { + free(syslocale); + syslocale = NULL; + } + locale = save; + if (locale) { + free(locale); + locale = NULL; + } + return PKGMGR_R_OK; +} + +API int pkgmgr_get_pkginfo_author_name(pkgmgr_pkginfo_h handle, char **author_name) +{ + if (handle == NULL) { + _LOGE("pkginfo handle is NULL\n"); + return PKGMGR_R_EINVAL; + } + if (author_name == NULL) { + _LOGE("Argument supplied to hold return value is NULL\n"); + return PKGMGR_R_EINVAL; + } + char *syslocale = NULL; + char *locale = NULL; + char *save = NULL; + author_x *ptr = NULL; + syslocale = vconf_get_str(VCONFKEY_LANGSET); + if (syslocale == NULL) { + _LOGE("current locale is NULL\n"); + return PKGMGR_R_EINVAL; + } + locale = __convert_system_locale_to_manifest_locale(syslocale); + if (locale == NULL) { + _LOGE("manifest locale is NULL\n"); + return PKGMGR_R_EINVAL; + } + save = locale; + *author_name = NULL; + pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle; + for(ptr = info->manifest_info->author; ptr != NULL; ptr = ptr->next) + { + if (ptr->lang) { + if (strcmp(ptr->lang, locale) == 0) { + *author_name = (char *)ptr->text; + if (strcmp(*author_name, "(null)") == 0) { + locale = DEFAULT_LOCALE; + continue; + } else + break; + } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) { + *author_name = (char *)ptr->text; + break; + } + } + } + if (syslocale) { + free(syslocale); + syslocale = NULL; + } + locale = save; + if (locale) { + free(locale); + locale = NULL; + } + return PKGMGR_R_OK; +} + +API int pkgmgr_get_pkginfo_author_email(pkgmgr_pkginfo_h handle, char **author_email) +{ + if (handle == NULL) { + _LOGE("pkginfo handle is NULL\n"); + return PKGMGR_R_EINVAL; + } + if (author_email == NULL) { + _LOGE("Argument supplied to hold return value is NULL\n"); + return PKGMGR_R_EINVAL; + } + pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle; + *author_email = (char *)info->manifest_info->author->email; + return PKGMGR_R_OK; +} + +API int pkgmgr_get_pkginfo_author_href(pkgmgr_pkginfo_h handle, char **author_href) +{ + if (handle == NULL) { + _LOGE("pkginfo handle is NULL\n"); + return PKGMGR_R_EINVAL; + } + if (author_href == NULL) { + _LOGE("Argument supplied to hold return value is NULL\n"); + return PKGMGR_R_EINVAL; + } + pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle; + *author_href = (char *)info->manifest_info->author->href; + return PKGMGR_R_OK; +} + +API int pkgmgr_get_pkginfo_removable(pkgmgr_pkginfo_h handle, bool *removable) +{ + if (handle == NULL) { + _LOGE("pkginfo handle is NULL\n"); + return PKGMGR_R_EINVAL; + } + if (removable == NULL) { + _LOGE("Argument supplied to hold return value is NULL\n"); + return PKGMGR_R_EINVAL; + } + char *val = NULL; + pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle; + val = (char *)info->manifest_info->removable; + if (val) { + if (strcasecmp(val, "true") == 0) + *removable = 1; + else if (strcasecmp(val, "false") == 0) + *removable = 0; + else + *removable = 1; + } + return PKGMGR_R_OK; +} + +API int pkgmgr_get_pkginfo_preload(pkgmgr_pkginfo_h handle, bool *preload) +{ + if (handle == NULL) { + _LOGE("pkginfo handle is NULL\n"); + return PKGMGR_R_EINVAL; + } + if (preload == NULL) { + _LOGE("Argument supplied to hold return value is NULL\n"); + return PKGMGR_R_EINVAL; + } + char *val = NULL; + pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle; + val = (char *)info->manifest_info->preload; + if (val) { + if (strcasecmp(val, "true") == 0) + *preload = 1; + else if (strcasecmp(val, "false") == 0) + *preload = 0; + else + *preload = 0; + } + return PKGMGR_R_OK; +} + +API int pkgmgr_get_pkginfo_readonly(pkgmgr_pkginfo_h handle, bool *readonly) +{ + if (handle == NULL) { + _LOGE("pkginfo handle is NULL\n"); + return PKGMGR_R_EINVAL; + } + if (readonly == NULL) { + _LOGE("Argument supplied to hold return value is NULL\n"); + return PKGMGR_R_EINVAL; + } + char *val = NULL; + pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle; + val = (char *)info->manifest_info->readonly; + if (val) { + if (strcasecmp(val, "true") == 0) + *readonly = 1; + else if (strcasecmp(val, "false") == 0) + *readonly = 0; + else + *readonly = 0; + } + return PKGMGR_R_OK; +} + + +API int pkgmgr_get_pkginfo_exec(pkgmgr_appinfo_h handle, char **exec) +{ + if (handle == NULL) { + _LOGE("appinfo handle is NULL\n"); + return PKGMGR_R_EINVAL; + } + if (exec == NULL) { + _LOGE("Argument supplied to hold return value is NULL\n"); + return PKGMGR_R_EINVAL; + } + pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle; + if (info->app_component) { + if (strcasecmp(info->app_component, "uiapp") == 0) + *exec = (char *)info->uiapp_info->exec; + if (strcasecmp(info->app_component, "svcapp") == 0) + *exec = (char *)info->svcapp_info->exec; + } + return PKGMGR_R_OK; +} + +API int pkgmgr_get_pkginfo_component(pkgmgr_appinfo_h handle, char **component) +{ + if (handle == NULL) { + _LOGE("appinfo handle is NULL\n"); + return PKGMGR_R_EINVAL; + } + if (component == NULL) { + _LOGE("Argument supplied to hold return value is NULL\n"); + return PKGMGR_R_EINVAL; + } + pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle; + *component = (char *)info->app_component; + return PKGMGR_R_OK; +} + +API int pkgmgr_get_pkginfo_apptype(pkgmgr_appinfo_h handle, char **app_type) +{ + if (handle == NULL) { + _LOGE("appinfo handle is NULL\n"); + return PKGMGR_R_EINVAL; + } + if (app_type == NULL) { + _LOGE("Argument supplied to hold return value is NULL\n"); + return PKGMGR_R_EINVAL; + } + pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle; + if (info->app_component) { + if (strcasecmp(info->app_component, "uiapp") == 0) + *app_type = (char *)info->uiapp_info->type; + if (strcasecmp(info->app_component, "svcapp") == 0) + *app_type = (char *)info->svcapp_info->type; + } + return PKGMGR_R_OK; +} + +API int pkgmgr_get_pkginfo_nodisplay(pkgmgr_appinfo_h handle, bool *nodisplay) +{ + if (handle == NULL) { + _LOGE("appinfo handle is NULL\n"); + return PKGMGR_R_EINVAL; + } + if (nodisplay == NULL) { + _LOGE("Argument supplied to hold return value is NULL\n"); + return PKGMGR_R_EINVAL; + } + char *val = NULL; + pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle; + val = (char *)info->uiapp_info->nodisplay; + if (val) { + if (strcasecmp(val, "true") == 0) + *nodisplay = 1; + else if (strcasecmp(val, "false") == 0) + *nodisplay = 0; + else + *nodisplay = 0; + } + return PKGMGR_R_OK; +} + +API int pkgmgr_get_pkginfo_multiple(pkgmgr_appinfo_h handle, bool *multiple) +{ + if (handle == NULL) { + _LOGE("appinfo handle is NULL\n"); + return PKGMGR_R_EINVAL; + } + if (multiple == NULL) { + _LOGE("Argument supplied to hold return value is NULL\n"); + return PKGMGR_R_EINVAL; + } + char *val = NULL; + pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle; + val = (char *)info->uiapp_info->multiple; + if (val) { + if (strcasecmp(val, "true") == 0) + *multiple = 1; + else if (strcasecmp(val, "false") == 0) + *multiple = 0; + else + *multiple = 0; + } + return PKGMGR_R_OK; +} + +API int pkgmgr_get_pkginfo_onboot(pkgmgr_appinfo_h handle, bool *onboot) +{ + if (handle == NULL) { + _LOGE("appinfo handle is NULL\n"); + return PKGMGR_R_EINVAL; + } + if (onboot == NULL) { + _LOGE("Argument supplied to hold return value is NULL\n"); + return PKGMGR_R_EINVAL; + } + char *val = NULL; + pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle; + val = (char *)info->svcapp_info->onboot; + if (val) { + if (strcasecmp(val, "true") == 0) + *onboot = 1; + else if (strcasecmp(val, "false") == 0) + *onboot = 0; + else + *onboot = 0; + } + return PKGMGR_R_OK; +} + +API int pkgmgr_get_pkginfo_autorestart(pkgmgr_appinfo_h handle, bool *autorestart) +{ + if (handle == NULL) { + _LOGE("appinfo handle is NULL\n"); + return PKGMGR_R_EINVAL; + } + if (autorestart == NULL) { + _LOGE("Argument supplied to hold return value is NULL\n"); + return PKGMGR_R_EINVAL; + } + char *val = NULL; + pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle; + val = (char *)info->svcapp_info->autorestart; + if (val) { + if (strcasecmp(val, "true") == 0) + *autorestart = 1; + else if (strcasecmp(val, "false") == 0) + *autorestart = 0; + else + *autorestart = 0; + } + return PKGMGR_R_OK; +} + +API int pkgmgr_get_pkginfo_taskmanage(pkgmgr_appinfo_h handle, bool *taskmanage) +{ + if (handle == NULL) { + _LOGE("appinfo handle is NULL\n"); + return PKGMGR_R_EINVAL; + } + if (taskmanage == NULL) { + _LOGE("Argument supplied to hold return value is NULL\n"); + return PKGMGR_R_EINVAL; + } + char *val = NULL; + pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle; + val = (char *)info->uiapp_info->taskmanage; + if (val) { + if (strcasecmp(val, "true") == 0) + *taskmanage = 1; + else if (strcasecmp(val, "false") == 0) + *taskmanage = 0; + else + *taskmanage = 0; + } + return PKGMGR_R_OK; +} + +API int pkgmgr_get_pkginfo(const char *pkg_name, pkgmgr_pkginfo_h *handle) +{ + if (pkg_name == NULL) { + _LOGE("package name is NULL\n"); + return PKGMGR_R_EINVAL; + } + if (handle == NULL) { + _LOGE("Argument supplied to hold return value is NULL\n"); + return PKGMGR_R_EINVAL; + } + pkgmgr_pkginfo_x *pkginfo = NULL; + char *error_message = NULL; + int ret = PKGMGR_R_OK; + char query[MAX_QUERY_LEN] = {'\0'}; + char *syslocale = NULL; + char *locale = NULL; + int exist = 0; + label_x *tmp1 = NULL; + icon_x *tmp2 = NULL; + description_x *tmp3 = NULL; + author_x *tmp4 = NULL; + + /*validate pkgname*/ + ret = __open_manifest_db(); + if (ret == -1) { + _LOGE("Fail to open manifest DB\n"); + ret = PKGMGR_R_ERROR; + goto err; + } + snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_info where package='%s')", pkg_name); + if (SQLITE_OK != + sqlite3_exec(manifest_db, query, __validate_cb, (void *)&exist, &error_message)) { + _LOGE("Don't execute query = %s error message = %s\n", query, + error_message); + sqlite3_free(error_message); + sqlite3_close(manifest_db); + return PKGMGR_R_ERROR; + } + if (exist == 0) { + _LOGE("Package not found in DB\n"); + ret = PKGMGR_R_ERROR; + goto err; + } + + syslocale = vconf_get_str(VCONFKEY_LANGSET); + if (syslocale == NULL) { + _LOGE("current locale is NULL\n"); + ret = PKGMGR_R_ERROR; + goto err; + } + locale = __convert_system_locale_to_manifest_locale(syslocale); + if (locale == NULL) { + _LOGE("manifest locale is NULL\n"); + ret = PKGMGR_R_EINVAL; + goto err; + } + pkginfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x)); + if (pkginfo == NULL) { + _LOGE("Failed to allocate memory for pkginfo\n"); + return PKGMGR_R_ERROR; + } + pkginfo->pkg_handle_id = __pkgmgr_pkginfo_new_handle_id(); + pkginfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x)); + if (pkginfo->manifest_info == NULL) { + _LOGE("Failed to allocate memory for manifest info\n"); + ret = PKGMGR_R_ERROR; + goto err; + } + pkginfo->manifest_info->package = strdup(pkg_name); + /*populate manifest_info from DB*/ + snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkg_name); + ret = __exec_pkginfo_query(query, (void *)pkginfo); + if (ret == -1) { + _LOGE("Package Info DB Information retrieval failed\n"); + ret = PKGMGR_R_ERROR; + goto err; + } + memset(query, '\0', MAX_QUERY_LEN); + snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \ + " package='%s' and package_locale='%s'", pkg_name, locale); + ret = __exec_pkginfo_query(query, (void *)pkginfo); + if (ret == -1) { + _LOGE("Package Info DB Information retrieval failed\n"); + ret = PKGMGR_R_ERROR; + goto err; + } + /*Also store the values corresponding to default locales*/ + memset(query, '\0', MAX_QUERY_LEN); + snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \ + " package='%s' and package_locale='%s'", pkg_name, DEFAULT_LOCALE); + ret = __exec_pkginfo_query(query, (void *)pkginfo); + if (ret == -1) { + _LOGE("Package Info DB Information retrieval failed\n"); + ret = PKGMGR_R_ERROR; + goto err; + } + if (pkginfo->manifest_info->label) { + LISTHEAD(pkginfo->manifest_info->label, tmp1); + pkginfo->manifest_info->label = tmp1; + } + if (pkginfo->manifest_info->icon) { + LISTHEAD(pkginfo->manifest_info->icon, tmp2); + pkginfo->manifest_info->icon = tmp2; + } + if (pkginfo->manifest_info->description) { + LISTHEAD(pkginfo->manifest_info->description, tmp3); + pkginfo->manifest_info->description = tmp3; + } + if (pkginfo->manifest_info->author) { + LISTHEAD(pkginfo->manifest_info->author, tmp4); + pkginfo->manifest_info->author = tmp4; + } + *handle = (void *)pkginfo; + sqlite3_close(manifest_db); + if (syslocale) { + free(syslocale); + syslocale = NULL; + } + if (locale) { + free(locale); + locale = NULL; + } + return PKGMGR_R_OK; + +err: + *handle = NULL; + __cleanup_pkginfo(pkginfo); + sqlite3_close(manifest_db); + if (syslocale) { + free(syslocale); + syslocale = NULL; + } + if (locale) { + free(locale); + locale = NULL; + } + return ret; +} + +API int pkgmgr_get_info_list(pkgmgr_iter_fn iter_fn, void *user_data) +{ + if (iter_fn == NULL) { + _LOGE("callback function is NULL\n"); + return PKGMGR_R_EINVAL; + } + char *error_message = NULL; + int ret = -1; + char query[MAX_QUERY_LEN] = {'\0'}; + + ret = __open_manifest_db(); + if (ret == -1) { + _LOGE("Fail to open manifest DB\n"); + return PKGMGR_R_ERROR; + } + iter_data *udata = calloc(1, sizeof(iter_data)); + if (udata == NULL) { + _LOGE("calloc failed"); + sqlite3_close(manifest_db); + return PKGMGR_R_ERROR; + } + udata->iter_fn = iter_fn; + udata->data = user_data; + snprintf(query, MAX_QUERY_LEN, "select * from package_info"); + if (SQLITE_OK != + sqlite3_exec(manifest_db, query, __pkg_list_cb, (void *)udata, &error_message)) { + _LOGE("Don't execute query = %s error message = %s\n", query, + error_message); + sqlite3_free(error_message); + sqlite3_close(manifest_db); + return PKGMGR_R_ERROR; + } + sqlite3_close(manifest_db); + return PKGMGR_R_OK; +} + +API int pkgmgr_get_info_app(pkgmgr_pkginfo_h handle, pkgmgr_app_component component, + pkgmgr_info_app_list_cb app_func, void *user_data) +{ + if (handle == NULL) { + _LOGE("pkginfo handle is NULL\n"); + return PKGMGR_R_EINVAL; + } + if (app_func == NULL) { + _LOGE("callback pointer is NULL\n"); + return PKGMGR_R_EINVAL; + } + if (component != PM_UI_APP && component != PM_SVC_APP) { + _LOGE("Invalid App Component Type\n"); + return PKGMGR_R_EINVAL; + } + char *error_message = NULL; + int ret = -1; + char query[MAX_QUERY_LEN] = {'\0'}; + pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle; + pkgmgr_appinfo_x *appinfo = NULL; + + appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x)); + if (appinfo == NULL) { + _LOGE("Failed to allocate memory for appinfo\n"); + return PKGMGR_R_ERROR; + } + if (component == PM_UI_APP) + appinfo->app_component = strdup("uiapp"); + if (component == PM_SVC_APP) + appinfo->app_component = strdup("svcapp"); + ret = __open_manifest_db(); + if (ret == -1) { + _LOGE("Fail to open manifest DB\n"); + return PKGMGR_R_ERROR; + } + snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where package='%s' and app_component='%s'", info->manifest_info->package, appinfo->app_component); + switch(component) { + case PM_UI_APP: + if (SQLITE_OK != + sqlite3_exec(manifest_db, query, __uiapp_list_cb, (void *)info, &error_message)) { + _LOGE("Don't execute query = %s error message = %s\n", query, + error_message); + sqlite3_free(error_message); + sqlite3_close(manifest_db); + return PKGMGR_R_ERROR; + } + uiapplication_x *tmp = NULL; + if (info->manifest_info->uiapplication) { + LISTHEAD(info->manifest_info->uiapplication, tmp); + info->manifest_info->uiapplication = tmp; + } + /*If the callback func return < 0 we break and no more call back is called*/ + while(tmp != NULL) + { + appinfo->uiapp_info = tmp; + ret = app_func((void *)appinfo, tmp->appid, user_data); + if (ret < 0) + break; + tmp = tmp->next; + } + break; + case PM_SVC_APP: + if (SQLITE_OK != + sqlite3_exec(manifest_db, query, __svcapp_list_cb, (void *)info, &error_message)) { + _LOGE("Don't execute query = %s error message = %s\n", query, + error_message); + sqlite3_free(error_message); + sqlite3_close(manifest_db); + return PKGMGR_R_ERROR; + } + serviceapplication_x *tmp1 = NULL; + if (info->manifest_info->serviceapplication) { + LISTHEAD(info->manifest_info->serviceapplication, tmp1); + info->manifest_info->serviceapplication = tmp1; + } + /*If the callback func return < 0 we break and no more call back is called*/ + while(tmp1 != NULL) + { + appinfo->svcapp_info = tmp1; + ret = app_func((void *)appinfo, tmp1->appid, user_data); + if (ret < 0) + break; + tmp1 = tmp1->next; + } + break; + default: + _LOGE("Invalid App Component Type\n"); + break; + } + + if (appinfo->app_component) { + free(appinfo->app_component); + appinfo->app_component = NULL; + } + if (appinfo) { + free(appinfo); + appinfo = NULL; + } + sqlite3_close(manifest_db); + return PKGMGR_R_OK; +} + +API int pkgmgr_destroy_pkginfo(pkgmgr_pkginfo_h handle) +{ + if (handle == NULL) { + _LOGE("pkginfo handle is NULL\n"); + return PKGMGR_R_EINVAL; + } + pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle; + __cleanup_pkginfo(info); + return PKGMGR_R_OK; +} + +API int pkgmgr_get_appinfo(const char *appid, pkgmgr_appinfo_h *handle) +{ + if (appid == NULL) { + _LOGE("appid is NULL\n"); + return PKGMGR_R_EINVAL; + } + if (handle == NULL) { + _LOGE("Argument supplied to hold return value is NULL\n"); + return PKGMGR_R_EINVAL; + } + pkgmgr_appinfo_x *appinfo = NULL; + char *error_message = NULL; + int ret = -1; + int exist = 0; + char query[MAX_QUERY_LEN] = {'\0'}; + + /*Validate appid*/ + ret = __open_manifest_db(); + if (ret == -1) { + _LOGE("Fail to open manifest DB\n"); + ret = PKGMGR_R_ERROR; + goto err; + } + snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", appid); + if (SQLITE_OK != + sqlite3_exec(manifest_db, query, __validate_cb, (void *)&exist, &error_message)) { + _LOGE("Don't execute query = %s error message = %s\n", query, + error_message); + sqlite3_free(error_message); + sqlite3_close(manifest_db); + return PKGMGR_R_ERROR; + } + if (exist == 0) { + _LOGE("Appid not found in DB\n"); + ret = PKGMGR_R_ERROR; + goto err; + } + + appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x)); + if (appinfo == NULL) { + _LOGE("Failed to allocate memory for appinfo\n"); + return PKGMGR_R_ERROR; + } + appinfo->app_handle_id = __pkgmgr_appinfo_new_handle_id(); + appinfo->uiapp_info = (uiapplication_x *)calloc(1, sizeof(uiapplication_x)); + if (appinfo->uiapp_info == NULL) { + _LOGE("Failed to allocate memory for uiapp info\n"); + ret = PKGMGR_R_ERROR; + goto err; + } + + appinfo->svcapp_info = (serviceapplication_x *)calloc(1, sizeof(serviceapplication_x)); + if (appinfo->svcapp_info == NULL) { + _LOGE("Failed to allocate memory for svcapp info\n"); + ret = PKGMGR_R_ERROR; + goto err; + } + + /*populate uiapp_info from DB*/ + snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' ", appid); + ret = __exec_appinfo_query(query, (void *)appinfo); + if (ret == -1) { + _LOGE("App Info DB Information retrieval failed\n"); + ret = PKGMGR_R_ERROR; + goto err; + } + + *handle = (void*)appinfo; + sqlite3_close(manifest_db); + return PKGMGR_R_OK; +err: + *handle = NULL; + __cleanup_appinfo(appinfo); + sqlite3_close(manifest_db); + return ret; +} + +API int pkgmgr_destroy_appinfo(pkgmgr_appinfo_h handle) +{ + if (handle == NULL) { + _LOGE("appinfo handle is NULL\n"); + return PKGMGR_R_EINVAL; + } + pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle; + __cleanup_appinfo(info); + return PKGMGR_R_OK; +} diff --git a/comm/comm_client.h b/comm/comm_client.h index 7c5cbcd..26ef214 100755 --- a/comm/comm_client.h +++ b/comm/comm_client.h @@ -28,8 +28,7 @@ #define __COMM_CLIENT_H__ #include "comm_config.h" -#include -#include +#include #include enum { diff --git a/comm/comm_client_dbus.c b/comm/comm_client_dbus.c index 2bb65d6..ca7a5e8 100755 --- a/comm/comm_client_dbus.c +++ b/comm/comm_client_dbus.c @@ -149,7 +149,7 @@ comm_client *comm_client_new(void) /* Connect to dbus */ dbus_error_init(&err); - cc->conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err); + cc->conn = dbus_bus_get_private(DBUS_BUS_SYSTEM, &err); if (dbus_error_is_set(&err)) { ERR("dbus connection error (%s)", err.message); dbus_error_free(&err); @@ -198,6 +198,7 @@ int comm_client_free(comm_client *cc) /* _free_sig_cb_data(cc->sig_cb_data); */ } + dbus_connection_close(cc->conn); dbus_connection_unref(cc->conn); free(cc); @@ -263,7 +264,7 @@ comm_client_request( /* Send message */ if (is_block == 1){ if(!dbus_connection_send_with_reply_and_block(cc->conn, msg, - 1200, NULL)) { + 5000, NULL)) { r = COMM_RET_NOMEM; goto ERROR_CLEANUP; } diff --git a/debian/changelog b/debian/changelog index a5c1e7f..060f11e 100755 --- a/debian/changelog +++ b/debian/changelog @@ -1,7 +1,1078 @@ +slp-pkgmgr (0.1.122) unstable; urgency=low + + * Applied manifest + * Git: slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.122 + + -- Sewook Park Wed, 25 Jul 2012 19:11:44 +0900 + +slp-pkgmgr (0.1.115) unstable; urgency=low + + * Fixed bug when backend installer exits with failure + * Git: slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.115 + + -- Sewook Park Mon, 21 May 2012 21:12:04 +0900 + +slp-pkgmgr (0.1.114) unstable; urgency=low + + * Fixed server hang issue on pressing NO in popup + * Git: slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.114 + + -- Sewook Park Mon, 07 May 2012 15:34:45 +0900 + +slp-pkgmgr (0.1.113) unstable; urgency=low + + * Implemented multiple queue support + * Git: slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.113 + + -- Sewook Park Fri, 20 Apr 2012 10:51:58 +0900 + +slp-pkgmgr (0.1.112) unstable; urgency=low + + * Fixed activate/deactivate feature + * Git: slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.112 + + -- Sewook Park Tue, 03 Apr 2012 20:39:45 +0900 + slp-pkgmgr (0.1.111) unstable; urgency=low - * Initial Release. - * Git: pkgs/s/slp-pkgmgr + * Fixed pkgmgr-install desktop to support rpm + * Git: slp/pkgs/s/slp-pkgmgr * Tag: slp-pkgmgr_0.1.111 -- Sewook Park Fri, 30 Mar 2012 11:50:01 +0900 + +slp-pkgmgr (0.1.110) unstable; urgency=low + + * Fixed popup UI bug + * Git: slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.110 + + -- Sewook Park Fri, 23 Mar 2012 19:06:13 +0900 + +slp-pkgmgr (0.1.109) unstable; urgency=low + + * Fixed compile warnings + * Git: slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.109 + + -- Sewook Park Tue, 20 Mar 2012 15:36:02 +0900 + +slp-pkgmgr (0.1.108) unstable; urgency=low + + * Fixed desktop file + * Git: slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.108 + + -- Sewook Park Fri, 16 Mar 2012 21:35:27 +0900 + +slp-pkgmgr (0.1.107) unstable; urgency=low + + * Fixed bug for elementary modification + * Git: slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.107 + + -- Sewook Park Thu, 15 Mar 2012 15:04:39 +0900 + +slp-pkgmgr (0.1.106) unstable; urgency=low + + * Fixed code for elementary 1.0 release + * Git: slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.106 + + -- Sewook Park Tue, 13 Mar 2012 17:52:30 +0900 + +slp-pkgmgr (0.1.105) unstable; urgency=low + + * Support Appsvc for pkgmgr-install + * Git: slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.105 + + -- Sewook Park Mon, 27 Feb 2012 21:34:10 +0900 + +slp-pkgmgr (0.1.104) unstable; urgency=low + + * Added clear_user_data API + * Git: slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.104 + + -- Sewook Park Wed, 25 Jan 2012 17:47:26 +0900 + +slp-pkgmgr (0.1.103) unstable; urgency=low + + * Added Pkgmgr TC and fixed issues + * Git: slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.103 + + -- Sewook Park Mon, 26 Dec 2011 19:06:00 +0900 + +slp-pkgmgr (0.1.102) unstable; urgency=low + + * Removed README file + * Git: slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.102 + + -- Sewook Park Thu, 22 Dec 2011 20:19:24 +0900 + +slp-pkgmgr (0.1.101) unstable; urgency=low + + * Fixed pkgmgr_info_new bug + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.101 + + -- Sewook Park Thu, 22 Dec 2011 17:27:37 +0900 + +slp-pkgmgr (0.1.100) unstable; urgency=low + + * Fixed package activate/deactivate + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.100 + + -- Sewook Park Tue, 13 Dec 2011 19:51:00 +0900 + +slp-pkgmgr (0.1.99) unstable; urgency=low + + * Added ecore_init() due to ecore internal logic change + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.99 + + -- Sewook Park Fri, 09 Dec 2011 10:17:31 +0900 + +slp-pkgmgr (0.1.98) unstable; urgency=low + + * Cleanup code + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.98 + + -- Sewook Park Tue, 06 Dec 2011 16:31:23 +0900 + +slp-pkgmgr (0.1.97) unstable; urgency=low + + * Updated changelog + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.97 + + -- Sewook Park Mon, 05 Dec 2011 16:05:30 +0900 + +slp-pkgmgr (0.1.96) unstable; urgency=low + + * Fix pkgcmd exit code according to the installation result for SDK support + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.96 + + -- Sewook Park Thu, 24 Nov 2011 15:12:31 +0900 + +slp-pkgmgr (0.1.95) unstable; urgency=low + + * Fixed gcc warnings, Klockwork issues and regression test issues + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.95 + + -- Sewook Park Wed, 09 Nov 2011 15:45:40 +0900 + +slp-pkgmgr (0.1.94) unstable; urgency=low + + * Changed Boilerplate as per the guideline + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.94 + + -- Sewook Park Mon, 07 Nov 2011 18:30:37 +0900 + +slp-pkgmgr (0.1.93) unstable; urgency=low + + * Apply AIL update in pkgmgr + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.93 + + -- Sewook Park Mon, 31 Oct 2011 15:37:21 +0900 + +slp-pkgmgr (0.1.92) unstable; urgency=low + + * Fix prevent bug + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.92 + + -- Sewook Park Wed, 26 Oct 2011 20:54:24 +0900 + +slp-pkgmgr (0.1.91) unstable; urgency=low + + * Fix package_manager_pkg_detail_info_t + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.91 + + -- Sewook Park Thu, 20 Oct 2011 21:26:13 +0900 + +slp-pkgmgr (0.1.90) unstable; urgency=low + + * Apply localization string + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.90 + + -- Sewook Park Tue, 18 Oct 2011 17:40:10 +0900 + +slp-pkgmgr (0.1.89) unstable; urgency=low + + * Add app_size in package_manager_pkg_detail_info_t + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.89 + + -- Sewook Park Tue, 18 Oct 2011 11:54:56 +0900 + +slp-pkgmgr (0.1.88) unstable; urgency=low + + * Fix string + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.88 + + -- Sewook Park Fri, 14 Oct 2011 10:49:17 +0900 + +slp-pkgmgr (0.1.87) unstable; urgency=low + + * set elm_scale + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.87 + + -- Sewook Park Wed, 12 Oct 2011 13:06:20 +0900 + +slp-pkgmgr (0.1.86) unstable; urgency=low + + * Fix pkgmgr-install inteface to use bundle_import_from_argv() + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.86 + + -- Sewook Park Fri, 07 Oct 2011 16:31:00 +0900 + +slp-pkgmgr (0.1.85) unstable; urgency=low + + * Remove unnecessary define + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.85 + + -- Sewook Park Wed, 05 Oct 2011 15:47:42 +0900 + +slp-pkgmgr (0.1.84) unstable; urgency=low + + * Terminate application before uninstalling + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.84 + + -- Sewook Park Wed, 28 Sep 2011 11:06:58 +0900 + +slp-pkgmgr (0.1.83) unstable; urgency=low + + * Fixed server bug while creating popup + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.83 + + -- Sewook Park Fri, 23 Sep 2011 14:36:43 +0900 + +slp-pkgmgr (0.1.82) unstable; urgency=low + + * Remove old API + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.82 + + -- Sewook Park Thu, 22 Sep 2011 12:25:55 +0900 + +slp-pkgmgr (0.1.81) unstable; urgency=low + + * Remove old AIL structure + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.81 + + -- Sewook Park Wed, 21 Sep 2011 18:00:00 +0900 + +slp-pkgmgr (0.1.80) unstable; urgency=low + + * Fix callback unresistering + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.80 + + -- Sewook Park Tue, 20 Sep 2011 20:09:45 +0900 + +slp-pkgmgr (0.1.79) unstable; urgency=low + + * Fix bug - pkgmgr-client/server + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.79 + + -- Sewook Park Mon, 19 Sep 2011 19:05:37 +0900 + +slp-pkgmgr (0.1.78) unstable; urgency=low + + * Fix prevent defects + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.78 + + -- Sewook Park Tue, 06 Sep 2011 11:12:54 +0900 + +slp-pkgmgr (0.1.77) unstable; urgency=low + + * Use name instead of pkg_name on uninstallation + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.77 + + -- Sewook Park Mon, 05 Sep 2011 16:15:54 +0900 + +slp-pkgmgr (0.1.76) unstable; urgency=low + + * Fix bug + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.76 + + -- Sewook Park Mon, 29 Aug 2011 15:17:47 +0900 + +slp-pkgmgr (0.1.75) unstable; urgency=low + + * Apply new API + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.75 + + -- Sewook Park Thu, 25 Aug 2011 21:08:35 +0900 + +slp-pkgmgr (0.1.74) unstable; urgency=low + + * Fixed Prevent Issues + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.74 + + -- Sewook Park Wed, 24 Aug 2011 20:12:30 +0900 + +slp-pkgmgr (0.1.73) unstable; urgency=low + + * Fix for AIL exception + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.73 + + -- Sewook Park Tue, 23 Aug 2011 17:12:30 +0900 + +slp-pkgmgr (0.1.72) unstable; urgency=low + + * Cleanup code + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.72 + + -- Sewook Park Fri, 19 Aug 2011 11:46:33 +0900 + +slp-pkgmgr (0.1.71) unstable; urgency=low + + * Add info type + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.71 + + -- Sewook Park Thu, 18 Aug 2011 18:40:30 +0900 + +slp-pkgmgr (0.1.70) unstable; urgency=low + + * Add optional_id in package_manager_pkg_detail_info_t + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.70 + + -- Sewook Park Wed, 10 Aug 2011 19:18:52 +0900 + +slp-pkgmgr (0.1.69) unstable; urgency=low + + * Apply new AIL API + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.69 + + -- Sewook Park Tue, 09 Aug 2011 14:25:09 +0900 + +slp-pkgmgr (0.1.68) unstable; urgency=low + + * Apply code cleanup + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.68 + + -- Sewook Park Mon, 01 Aug 2011 19:32:38 +0900 + +slp-pkgmgr (0.1.67) unstable; urgency=low + + * Apply Boilerplate + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.67 + + -- Sewook Park Wed, 13 Jul 2011 17:33:40 +0900 + +slp-pkgmgr (0.1.66) unstable; urgency=low + + * Cleanup code + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.66 + + -- Sewook Park Tue, 05 Jul 2011 17:59:59 +0900 + +slp-pkgmgr (0.1.65) unstable; urgency=low + + * Cleanup control file + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.65 + + -- Sewook Park Mon, 04 Jul 2011 20:25:20 +0900 + +slp-pkgmgr (0.1.64) unstable; urgency=low + + * Cleanup code + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.64 + + -- Sewook Park Tue, 28 Jun 2011 19:40:17 +0900 + +slp-pkgmgr (0.1.63) unstable; urgency=low + + * Cleanup code + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.63 + + -- Sewook Park Fri, 24 Jun 2011 19:09:13 +0900 + +slp-pkgmgr (0.1.62) unstable; urgency=low + + * Fix prevent defect + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.62 + + -- Sewook Park Mon, 20 Jun 2011 14:37:43 +0900 + +slp-pkgmgr (0.1.61) unstable; urgency=low + + * Change popup type to modal + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.61 + + -- Sewook Park Mon, 06 Jun 2011 12:59:16 +0900 + +slp-pkgmgr (0.1.60) unstable; urgency=low + + * Apply ail + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.60 + + -- Sewook Park Wed, 18 May 2011 20:25:58 +0900 + +slp-pkgmgr (0.1.59) unstable; urgency=low + + * Fix build error - CMakeLists.txt + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.59 + + -- Sewook Park Wed, 18 May 2011 14:31:49 +0900 + +slp-pkgmgr (0.1.58) unstable; urgency=low + + * Move pkgmgr-tool pkgmgr-install to libpkgmgr-client-0 + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.58 + + -- Sewook Park Tue, 17 May 2011 20:41:15 +0900 + +slp-pkgmgr (0.1.57) unstable; urgency=low + + * Fix argument handling - to include # character + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.57 + + -- Sewook Park Mon, 16 May 2011 20:56:26 +0900 + +slp-pkgmgr (0.1.56) unstable; urgency=low + + * Fix popup problem + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.56 + + -- Sewook Park Wed, 11 May 2011 16:18:05 +0900 + +slp-pkgmgr (0.1.55) unstable; urgency=low + + * Fix popup problem + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.55 + + -- Sewook Park Wed, 11 May 2011 16:11:00 +0900 + +slp-pkgmgr (0.1.54) unstable; urgency=low + + * Fix getting type in pkgmgr-client + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.54 + + -- Sewook Park Mon, 25 Apr 2011 21:26:31 +0900 + +slp-pkgmgr (0.1.53) unstable; urgency=low + + * Fix bug in pkgmgr-client + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.53 + + -- Sewook Park Mon, 18 Apr 2011 18:38:26 +0900 + +slp-pkgmgr (0.1.52) unstable; urgency=low + + * Fix item name in desktop file: X-SLP-PackageType + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.52 + + -- Youmin Ha Fri, 15 Apr 2011 10:50:01 +0900 + +slp-pkgmgr (0.1.51) unstable; urgency=low + + * Read pkg_type from desktop file when uninstall + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.51 + + -- Youmin Ha Thu, 14 Apr 2011 14:40:41 +0900 + +slp-pkgmgr (0.1.50) unstable; urgency=low + + * Fix pkgmgr-tool + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.50 + + -- Sewook Park Mon, 04 Apr 2011 21:35:36 +0900 + +slp-pkgmgr (0.1.49) unstable; urgency=low + + * Fix build error and popup string + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.49 + + -- Sewook Park Sat, 02 Apr 2011 17:22:23 +0900 + +slp-pkgmgr (0.1.48) unstable; urgency=low + + * Change popup handling in pkgmgr + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.48 + + -- Sewook Park Fri, 01 Apr 2011 17:05:28 +0900 + +slp-pkgmgr (0.1.47) unstable; urgency=low + + * Add function body for get_license_path() + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.47 + + -- Youmin Ha Wed, 16 Mar 2011 18:40:02 +0900 + +slp-pkgmgr (0.1.46) unstable; urgency=low + + * Add api: pkgmgr_installer_get_license_path() + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.46 + + -- Youmin Ha Mon, 14 Mar 2011 17:15:43 +0900 + +slp-pkgmgr (0.1.45) unstable; urgency=low + + * Add license parameter on package_manager_install_application_with_type() + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.45 + + -- Sewook Park Thu, 10 Mar 2011 13:54:27 +0900 + +slp-pkgmgr (0.1.44) unstable; urgency=low + + * Apply 2sec wait in pkgmgr-install + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.44 + + -- Youmin Ha Tue, 08 Mar 2011 15:14:10 +0900 +slp-pkgmgr (0.1.43) unstable; urgency=low + + * Fix mime bugs + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.43 + + -- Youmin Ha Fri, 04 Mar 2011 09:20:23 +0900 + +slp-pkgmgr (0.1.42) unstable; urgency=low + + * Fix for argument which has white space + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.42 + + -- Sewook Park Fri, 04 Mar 2011 01:42:07 +0900 + +slp-pkgmgr (0.1.41) unstable; urgency=low + + * Fix pkgmgr-server.postinst -exclude updaet-mime-database + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.41 + + -- Sewook Park Thu, 03 Mar 2011 23:07:08 +0900 + +slp-pkgmgr (0.1.40) unstable; urgency=low + + * Fix MAX_PKG_TYPE_LEN to 128 + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.40 + + -- Sewook Park Thu, 03 Mar 2011 21:54:45 +0900 + +slp-pkgmgr (0.1.39-1) unstable; urgency=low + + * Fix header to pass api review (no code change) + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.39-1 + + -- Youmin Ha Thu, 03 Mar 2011 20:27:45 +0900 + +slp-pkgmgr (0.1.39) unstable; urgency=low + + * Support wgt mime type, Fix build error + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.39 + + -- Youmin Ha Thu, 03 Mar 2011 18:53:17 +0900 + +slp-pkgmgr (0.1.38) unstable; urgency=low + + * Fix trivial bug + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.38 + + -- Sewook Park Thu, 03 Mar 2011 16:45:07 +0900 + +slp-pkgmgr (0.1.37) unstable; urgency=low + + * Change pkgmgr architecture + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.37 + + -- Sewook7.park Thu, 03 Mar 2011 15:36:33 +0900 + +slp-pkgmgr (0.1.36-2) unstable; urgency=low + + * Rollback + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.36-2 + + -- Sewook Park Sat, 26 Feb 2011 16:06:20 +0900 + +slp-pkgmgr (0.1.36) unstable; urgency=low + + * Add install_with_license API + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.36 + + -- Sewook Park Sat, 26 Feb 2011 14:48:31 +0900 + +slp-pkgmgr (0.1.35) unstable; urgency=low + + * Install pkgmgr-tool into the binary package, to be used with SDK + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.35 + + -- Youmin Ha Tue, 22 Feb 2011 16:45:32 +0900 + +slp-pkgmgr (0.1.34) unstable; urgency=low + + * fix pkgmgr_tool + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.34 + + -- Sewook Park Fri, 18 Feb 2011 13:40:52 +0900 + +slp-pkgmgr (0.1.33) unstable; urgency=low + + * check argument length (Found by prevent) + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.33 + + -- Sewook Park Wed, 16 Feb 2011 20:17:13 +0900 + +slp-pkgmgr (0.1.32) unstable; urgency=low + + * Add null check to pkgmgr_server (Found by prevent) + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.32 + + -- Youmin Ha Wed, 16 Feb 2011 14:36:34 +0900 + +slp-pkgmgr (0.1.31) unstable; urgency=low + + * pkgmgr_tool fix + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.31 + + -- Sewook Park Wed, 02 Feb 2011 15:29:27 +0900 + +slp-pkgmgr (0.1.30) unstable; urgency=low + + * Prevent bug fix + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.30 + + -- Sewook Park Wed, 26 Jan 2011 10:24:51 +0900 + +slp-pkgmgr (0.1.29) unstable; urgency=low + + * fix the return value of comm_client_free() + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.29 + + -- Sewook Park Tue, 18 Jan 2011 15:09:56 +0900 + +slp-pkgmgr (0.1.28) unstable; urgency=low + + * Change pkgmgr structure + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.28 + + -- Sewook Park Fri, 14 Jan 2011 14:05:22 +0900 + +slp-pkgmgr (0.1.27-1) unstable; urgency=low + + * upload + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.27-1 + + -- Youmin Ha Wed, 29 Dec 2010 15:21:11 +0900 + +slp-pkgmgr (0.1.27) unstable; urgency=low + + * Initialize gerror variable to NULL, to avoid error from + g_shell_parse_argv() + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.27 + + -- Youmin Ha Wed, 29 Dec 2010 14:45:33 +0900 + +slp-pkgmgr (0.1.26) unstable; urgency=low + + * fix pkgmgr_tool + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.26 + + -- root Tue, 21 Dec 2010 19:50:57 +0900 + +slp-pkgmgr (0.1.25) unstable; urgency=low + + * fix pkgmgr_client bug - resource free of result_callback + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.25 + + -- Sewook Park Mon, 20 Dec 2010 21:17:19 +0900 + +slp-pkgmgr (0.1.24) unstable; urgency=low + + * Apply new dbus-based comm_client library. (Known bugs are fixed) + Avoid BS fron opengl, by unsetting ELM_ENGINE environnent variable. + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.24 + + -- Youmin Ha Sat, 18 Dec 2010 16:44:23 +0900 + +slp-pkgmgr (0.1.23-2) unstable; urgency=low + + * fix control + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.23-2 + + -- root Mon, 13 Dec 2010 15:07:17 +0900 + +slp-pkgmgr (0.1.23-1) unstable; urgency=low + + * add aul on control + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.23-1 + + -- root Mon, 13 Dec 2010 13:42:50 +0900 + +slp-pkgmgr (0.1.23) unstable; urgency=low + + * add pkgmgr_client API - package_manager_install_application_with_type() + * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.23 + + -- Sewook Park Fri, 10 Dec 2010 17:14:31 +0900 + +slp-pkgmgr (0.1.22) unstable; urgency=low + + * fix pkgmgr_client for system package + * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.22 + + -- root Mon, 06 Dec 2010 12:13:00 +0900 + +slp-pkgmgr (0.1.21) unstable; urgency=low + + * fix bugs in pkgmgr_client + * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.21 + + -- Sewook Park Fri, 03 Dec 2010 17:48:14 +0900 + +slp-pkgmgr (0.1.20) unstable; urgency=low + + * fix bugs in comm_client + * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.20 + + -- Youmin Ha Fri, 03 Dec 2010 15:13:52 +0900 + +slp-pkgmgr (0.1.19) unstable; urgency=low + + * fix pkgmgr_client - bug fix, pkg_info + * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.19 + + -- root Wed, 01 Dec 2010 20:04:10 +0900 + +slp-pkgmgr (0.1.18) unstable; urgency=low + + * NULL check on pkg_name in comm_client_request() + * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.18 + + -- Youmin Ha Wed, 24 Nov 2010 21:28:17 +0900 + +slp-pkgmgr (0.1.17) unstable; urgency=low + + * fix pkgmgr_tool bug, add LOG_TAG + * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.17 + + -- root Wed, 24 Nov 2010 19:46:41 +0900 + +slp-pkgmgr (0.1.16) unstable; urgency=low + + * fix pkgmgr-client bug + * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.16 + + -- root Thu, 18 Nov 2010 14:52:42 +0900 + +slp-pkgmgr (0.1.15) unstable; urgency=low + + * remove pkgmgr_frontend_test, pkgmgr_backend_test + * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.15 + + -- root Fri, 12 Nov 2010 14:15:47 +0900 + +slp-pkgmgr (0.1.14-2) unstable; urgency=low + + * fix pkgmgr-client log + * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.14-2 + + -- root Thu, 11 Nov 2010 14:02:25 +0900 + +slp-pkgmgr (0.1.14-1) unstable; urgency=low + + * fix pkgmgr-client + * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.14-1 + + -- root Thu, 11 Nov 2010 11:51:15 +0900 + +slp-pkgmgr (0.1.14) unstable; urgency=low + + * fix pkgmgr-client + * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.14 + + -- root Wed, 10 Nov 2010 14:29:37 +0900 + +slp-pkgmgr (0.1.13) unstable; urgency=low + + * add activator facility + * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.13 + + -- Kidong Kim Wed, 10 Nov 2010 10:39:59 +0900 + +slp-pkgmgr (0.1.12) unstable; urgency=low + + * fix package dependency + * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.12 + + -- Youmin Ha Wed, 10 Nov 2010 09:13:23 +0900 + +slp-pkgmgr (0.1.11) unstable; urgency=low + + * re-versioning + * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.11 + + -- Youmin Ha Tue, 09 Nov 2010 18:08:06 +0900 + +slp-pkgmgr (0.1.10-4) unstable; urgency=low + + * fix shared libs' dependencies + * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.10-4 + + -- Youmin Ha Tue, 09 Nov 2010 18:03:25 +0900 + +slp-pkgmgr (0.1.10-3) unstable; urgency=low + + * Fix build error + * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.10-3 + + -- root Tue, 09 Nov 2010 16:17:42 +0900 + +slp-pkgmgr (0.1.10-2) unstable; urgency=low + + * Fix pkgmgr-client & pkgmgr-server + * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.10-2 + + -- root Tue, 09 Nov 2010 14:15:58 +0900 + +slp-pkgmgr (0.1.10-1) unstable; urgency=low + + * Fix pc files + * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.10-1 + + -- Youmin Ha Tue, 09 Nov 2010 11:29:28 +0900 + +slp-pkgmgr (0.1.10) unstable; urgency=low + + * Free comm_client in libpkgmgr_client.so + * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.10 + + -- root Mon, 08 Nov 2010 20:30:37 +0900 + +slp-pkgmgr (0.1.9) unstable; urgency=low + + * Make comm* libs to shared libs + * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.9 + + -- Youmin Ha Mon, 08 Nov 2010 15:20:42 +0900 + +slp-pkgmgr (0.1.8-1) unstable; urgency=low + + * fix PG + * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.8-1 + + -- Youmin Ha Mon, 08 Nov 2010 10:46:06 +0900 + +slp-pkgmgr (0.1.8) unstable; urgency=low + + * fix client - get_list + * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.8 + + -- root Wed, 03 Nov 2010 12:03:16 +0900 + +slp-pkgmgr (0.1.7) unstable; urgency=low + + * add listen/broadcast API + * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.7 + + -- Youmin Ha Thu, 28 Oct 2010 17:15:11 +0900 + +slp-pkgmgr (0.1.6) unstable; urgency=low + + * fix PMS code, which generates argv for backend + * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.6 + + -- Youmin Ha Wed, 27 Oct 2010 19:46:57 +0900 + +slp-pkgmgr (0.1.5) unstable; urgency=low + + * if PMS_STANDALONE env_var is set, PMS doens't stop. + * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.5 + + -- Youmin Ha Wed, 27 Oct 2010 17:51:03 +0900 + +slp-pkgmgr (0.1.4) unstable; urgency=low + + * fix auto-activation + * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.4 + + -- Youmin Ha Wed, 27 Oct 2010 17:41:54 +0900 + +slp-pkgmgr (0.1.3) unstable; urgency=low + + * apply new dbus service/path/interface, fix bug + * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.3 + + -- Youmin Ha Tue, 26 Oct 2010 12:23:54 +0900 + +slp-pkgmgr (0.1.2-1) unstable; urgency=low + + * fix pc file + * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.2-1 + + -- Youmin Ha Sat, 23 Oct 2010 13:37:57 +0900 + +slp-pkgmgr (0.1.2) unstable; urgency=low + + * fix bug in pkgmgr-server + * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.2 + + -- Youmin Ha Wed, 20 Oct 2010 16:38:58 +0900 + +slp-pkgmgr (0.1.1-5) unstable; urgency=low + + * install comm_config.h + * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.1-5 + + -- Youmin Ha Mon, 18 Oct 2010 20:45:10 +0900 + +slp-pkgmgr (0.1.1-4) unstable; urgency=low + + * Fix build flags + * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.1-4 + + -- Youmin Ha Mon, 18 Oct 2010 20:19:57 +0900 + +slp-pkgmgr (0.1.1-3) unstable; urgency=low + + * change max pkg name length + * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.1-3 + + -- Kidong Kim Mon, 18 Oct 2010 19:42:01 +0900 + +slp-pkgmgr (0.1.1-2) unstable; urgency=low + + * fix wrong version of dependent package + * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.1-2 + + -- Youmin Ha Mon, 18 Oct 2010 19:22:14 +0900 + +slp-pkgmgr (0.1.1-1) unstable; urgency=low + + * fix build-dependency + * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.1-1 + + -- Youmin Ha Mon, 18 Oct 2010 18:07:37 +0900 + +slp-pkgmgr (0.1.1) unstable; urgency=low + + * Release first version + * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr + * Tag: slp-pkgmgr_0.1.1 + + -- Youmin Ha Mon, 18 Oct 2010 18:07:37 +0900 + +slp-pkgmgr (0.1.0) unstable; urgency=low + + * Initial Release. + + -- Kidong Kim Thu, 16 Sep 2010 09:31:11 +0900 diff --git a/debian/control b/debian/control index d24df68..7a32791 100755 --- a/debian/control +++ b/debian/control @@ -1,20 +1,20 @@ Source: slp-pkgmgr Priority: extra Maintainer: Sewook Park , Youmin Ha -Build-Depends: debhelper (>= 5), autotools-dev, libsecurity-server-client-dev, libdbus-1-dev, libdbus-glib-1-dev, libecore-dev, dlog-dev, libaul-1-dev, libail-0-dev, libappcore-efl-dev +Build-Depends: debhelper (>= 5), autotools-dev, libsecurity-server-client-dev, libdbus-1-dev, libdbus-glib-1-dev, libecore-dev, dlog-dev, libaul-1-dev, libail-0-dev, libappcore-efl-dev, libxml2-dev Standards-Version: 3.7.2 Section: base Package: libpkgmgr-client-dev Section: libdevel Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, libpkgmgr-client-0 (= ${Source-Version}), libecore-dev, libsecurity-server-client-dev, libaul-1-dev, libail-0-dev, libpkgmgr-types-dev(>= ${Source-Version}), libpkgmgr-installer-dev (>= ${Source-Version}) +Depends: ${shlibs:Depends}, ${misc:Depends}, libpkgmgr-client-0 (= ${Source-Version}), libecore-dev, libsecurity-server-client-dev, libaul-1-dev, libail-0-dev, libpkgmgr-types-dev(>= ${Source-Version}), libpkgmgr-installer-dev (>= ${Source-Version}), libpkgmgr-parser-dev (>= ${Source-Version}) Description: Package Manager client library develpoment package Package: libpkgmgr-client-0 Section: libs Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, libpkgmgr-installer (>= ${Source-Version}), pkgmgr-server (>= ${Source-Version}) +Depends: ${shlibs:Depends}, ${misc:Depends}, libpkgmgr-installer (>= ${Source-Version}), libpkgmgr-parser (>= ${Source-Version}), pkgmgr-server (>= ${Source-Version}) Description: Packager Manager client library package Package: pkgmgr-server @@ -33,7 +33,7 @@ Package: libpkgmgr-installer Section: libs Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} -Description: Library for installer frontend/backend. +Description: Library for installer backend. Package: libpkgmgr-installer-dev Section: libdevel @@ -41,6 +41,18 @@ Architecture: any Depends: libpkgmgr-installer (= ${Source-Version}), Description: Dev package for libpkgmgr-installer +Package: libpkgmgr-parser +Section: libs +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Parser Library for installer backend. + +Package: libpkgmgr-parser-dev +Section: libdevel +Architecture: any +Depends: libpkgmgr-parser (= ${Source-Version}), +Description: Dev package for libpkgmgr-parser + Package: libpkgmgr-types-dev Section: libdevel Architecture: any diff --git a/debian/libpkgmgr-client-0.install.in b/debian/libpkgmgr-client-0.install.in index 86624b8..e2ebbc7 100755 --- a/debian/libpkgmgr-client-0.install.in +++ b/debian/libpkgmgr-client-0.install.in @@ -2,5 +2,5 @@ @PREFIX@/etc/package-manager/pkg_path.conf @PREFIX@/bin/pkgcmd @PREFIX@/bin/pkgmgr-install -/opt/share/applications/*.desktop +@PREFIX@/share/applications/*.desktop @PREFIX@/share/mime/packages/*.xml diff --git a/include/package-manager-plugin.h b/include/package-manager-plugin.h deleted file mode 120000 index f50bb1f..0000000 --- a/include/package-manager-plugin.h +++ /dev/null @@ -1 +0,0 @@ -../types/include/package-manager-plugin.h \ No newline at end of file diff --git a/include/package-manager-plugin.h b/include/package-manager-plugin.h new file mode 100755 index 0000000..50bf5c7 --- /dev/null +++ b/include/package-manager-plugin.h @@ -0,0 +1,69 @@ +/* + * slp-pkgmgr + * + * Copyright (c) 2000 - 2011 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. + * + */ + + + + + + + + + +#ifndef __PKG_MANAGER_PLUGIN_H__ +#define __PKG_MANAGER_PLUGIN_H__ + +#include "package-manager-types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void (*_pkg_plugin_unload) (void); +typedef int (*_pkg_plugin_pkg_is_installed) (const char *pkg_name); +typedef int (*_pkg_plugin_get_installed_pkg_list) (const char *category, + const char *option, + package_manager_pkg_info_t + **list, int *count); +typedef int (*_pkg_plugin_get_pkg_detail_info) (const char *pkg_name, + package_manager_pkg_detail_info_t + *pkg_detail_info); +typedef int (*_pkg_plugin_get_pkg_detail_info_from_package) (const char + *pkg_path, + package_manager_pkg_detail_info_t + *pkg_detail_info); + +typedef struct _pkg_plugin_set { +char pkg_type[PKG_TYPE_STRING_LEN_MAX]; +void *plugin_handle; +_pkg_plugin_unload plugin_on_unload; +_pkg_plugin_pkg_is_installed pkg_is_installed; +_pkg_plugin_get_installed_pkg_list get_installed_pkg_list; +_pkg_plugin_get_pkg_detail_info get_pkg_detail_info; +_pkg_plugin_get_pkg_detail_info_from_package +get_pkg_detail_info_from_package; +} pkg_plugin_set; + +#ifdef __cplusplus +} +#endif + +#endif /* __PKG_MANAGER_PLUGIN_H__ */ diff --git a/include/package-manager-types.h b/include/package-manager-types.h deleted file mode 120000 index 6667546..0000000 --- a/include/package-manager-types.h +++ /dev/null @@ -1 +0,0 @@ -../types/include/package-manager-types.h \ No newline at end of file diff --git a/include/package-manager-types.h b/include/package-manager-types.h new file mode 100755 index 0000000..39f9600 --- /dev/null +++ b/include/package-manager-types.h @@ -0,0 +1,120 @@ +/* + * slp-pkgmgr + * + * Copyright (c) 2000 - 2011 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. + * + */ + + + + + + + + + +/** + * @file package-manager-types.h + * @author Sewook Park + * @version 0.1 + * @brief This file declares slp-pkgmgr-types + * + * @addtogroup APPLICATION_FRAMEWORK + * @{ + * + * @defgroup pacakge_manager_type + * @section Header to use them: + * @code + * #include "package-manager-types.h" + * @endcode + * + * @addtogroup pacakge_manager_type + * @{ + */ + +#ifndef __PKG_MANAGER_TYPES_H__ +#define __PKG_MANAGER_TYPES_H__ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @mainpage + * + * This is package manager + * + * Packaeg manager is used to install/uninstall the packages.\n + * package includes dpkg, java, widget, etc. and it can be added\n + * Security is considered on current package manager\n + * + */ + +/** + * @file package-manager.h + * @brief Package Manager header + * + * Generated by Sewook Park + */ + +#define PKG_TYPE_STRING_LEN_MAX 128 +#define PKG_NAME_STRING_LEN_MAX 128 +#define PKG_VERSION_STRING_LEN_MAX 128 +#define PKG_VALUE_STRING_LEN_MAX 512 +#define PKG_URL_STRING_LEN_MAX 1024 + +/** + *@brief application's structure retrieved by package-manager + */ +typedef struct _package_manager_pkg_info_t { + char pkg_type[PKG_TYPE_STRING_LEN_MAX]; + char pkg_name[PKG_NAME_STRING_LEN_MAX]; + char version[PKG_VERSION_STRING_LEN_MAX]; + struct _package_manager_pkg_info_t *next; +} package_manager_pkg_info_t; + +typedef struct _package_manager_pkg_detail_info_t { + char pkg_type[PKG_TYPE_STRING_LEN_MAX]; + char pkg_name[PKG_NAME_STRING_LEN_MAX]; + char version[PKG_VERSION_STRING_LEN_MAX]; + char pkg_description[PKG_VALUE_STRING_LEN_MAX]; + char min_platform_version[PKG_VERSION_STRING_LEN_MAX]; + time_t installed_time; /* installed time it must be GMT+0 time */ + int installed_size; /* installed total size */ + int app_size; /* installed app size */ + int data_size; /* data size which is made on run time */ + char optional_id[PKG_NAME_STRING_LEN_MAX]; /*package ID if exists */ + void *pkg_optional_info; +} package_manager_pkg_detail_info_t; + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* __PKG_MANAGER_TYPES_H__ */ +/** + * @} + * @} + */ + diff --git a/include/package-manager.h b/include/package-manager.h deleted file mode 120000 index 2318292..0000000 --- a/include/package-manager.h +++ /dev/null @@ -1 +0,0 @@ -../client/include/package-manager.h \ No newline at end of file diff --git a/include/package-manager.h b/include/package-manager.h new file mode 100755 index 0000000..ce0d825 --- /dev/null +++ b/include/package-manager.h @@ -0,0 +1,688 @@ +/* + * slp-pkgmgr + * + * Copyright (c) 2000 - 2011 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. + * + */ + + + + + + + + + +/** + * @file package-manager.h + * @author Sewook Park + * @version 0.1 + * @brief This file declares API of slp-pkgmgr library + * + * @addtogroup APPLICATION_FRAMEWORK + * @{ + * + * @defgroup PackageManager + * @section Header to use them: + * @code + * #include "package-manager.h" + * @endcode + * + * @addtogroup PackageManager + * @{ + */ + +#ifndef __PKG_MANAGER_H__ +#define __PKG_MANAGER_H__ + +#include +#include + + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef DEPRECATED +#define DEPRECATED __attribute__ ((__deprecated__)) +#endif + +/** + * @mainpage + * + * This is package manager + * + * Packaeg manager is used to install/uninstall the packages.\n + * package includes dpkg, java, widget, etc. and it can be added\n + * Security is considered on current package manager\n + * + */ + +/** + * @file package-manager.h + * @brief Package Manager header + * + * Generated by Sewook Park + */ + + + +/** + * @addtogroup PackageManager + * @{ + */ + +/** + * @brief pkgmgr info types. + */ +#define PKGMGR_INFO_STR_PKGTYPE "pkg_type" +#define PKGMGR_INFO_STR_PKGNAME "pkg_name" +#define PKGMGR_INFO_STR_VERSION "version" +#define PKGMGR_INFO_STR_INSTALLED_SIZE "installed_size" +#define PKGMGR_INFO_STR_DATA_SIZE "data_size" +#define PKGMGR_INFO_STR_APP_SIZE "app_size" +#define PKGMGR_INFO_STR_INSTALLED_TIME "installed_time" +/** @} */ + + +/** + * @brief Return values in pkgmgr. + */ +typedef enum _pkgmgr_return_val { + PKGMGR_R_ETIMEOUT = -4, /**< Timeout */ + PKGMGR_R_EINVAL = -3, /**< Invalid argument */ + PKGMGR_R_ECOMM = -2, /**< Comunication Error */ + PKGMGR_R_ERROR = -1, /**< General error */ + PKGMGR_R_OK = 0 /**< General success */ +} pkgmgr_return_val; +/** @} */ + +/** + * @defgroup pkg_operate APIs to install /uninstall / activate application + * @ingroup pkgmgr + * @brief + * APIs to install /uninstall / activate application + * - Install application using application package filepath + * - Uninstall application using application package name + * - Activate application using application package name + * + */ + + +/** + * @addtogroup pkg_operate + * @{ + */ + +typedef void* pkgmgr_pkginfo_h; +typedef void* pkgmgr_appinfo_h; + +typedef int (*pkgmgr_iter_fn)(const char* pkg_type, const char* pkg_name, + const char* version, void *data); + +typedef int (*pkgmgr_handler)(int req_id, const char *pkg_type, + const char *pkg_name, const char *key, + const char *val, const void *pmsg, void *data); + +typedef int (*pkgmgr_info_app_list_cb ) (const pkgmgr_appinfo_h handle, + const char *appid, void *user_data); + + +typedef void pkgmgr_client; + +typedef enum { + PC_REQUEST = 0, + PC_LISTENING, + PC_BROADCAST, +}client_type; + +typedef enum { + PM_DEFAULT, + PM_QUIET +}pkgmgr_mode; + +typedef enum { + PM_LOCATION_INTERNAL = 0, + PM_LOCATION_EXTERNAL +}pkgmgr_install_location; + +typedef enum { + PM_UI_APP, + PM_SVC_APP +}pkgmgr_app_component; + +/** + * @brief This API creates pkgmgr client. + * + * This API is for package-manager client application.\n + * + * @param[in] ctype client type - PC_REQUEST, PC_LISTENING, PC_BROADCAST + * @return pkgmgr_client object + * @retval NULL on failure creating an object +*/ +pkgmgr_client *pkgmgr_client_new(client_type ctype); + +/** + * @brief This API deletes pkgmgr client. + * + * This API is for package-manager client application.\n + * + * @param[in] pc pkgmgr_client + * @return Operation result; + * @retval PKGMGR_R_OK success + * @retval PKGMGR_R_EINVAL invalid argument + * @retval PKGMGR_R_ERROR internal error +*/ +int pkgmgr_client_free(pkgmgr_client *pc); + +/** + * @brief This API installs package. + * + * This API is for package-manager client application.\n + * + * @param[in] pc pkgmgr_client + * @param[in] pkg_type package type + * @param[in] descriptor_path full path that descriptor is located + * @param[in] pkg_path full path that package file is located + * @param[in] optional_file optional file which is used for installation + * @param[in] mode installation mode - PM_DEFAULT, PM_QUIET + * @param[in] event_cb user callback + * @param[in] data user data + * @return request_id (>0) if success, error code(<0) if fail\n + * @retval PKGMGR_R_OK success + * @retval PKGMGR_R_EINVAL invalid argument + * @retval PKGMGR_R_ECOMM communication error +*/ +int pkgmgr_client_install(pkgmgr_client *pc, const char *pkg_type, + const char *descriptor_path, const char *pkg_path, + const char *optional_file, pkgmgr_mode mode, + pkgmgr_handler event_cb, void *data); + +/** + * @brief This API uninstalls package. + * + * This API is for package-manager client application.\n + * + * @param[in] pc pkgmgr_client + * @param[in] pkg_type package type + * @param[in] pkg_name package name + * @param[in] mode installation mode - PM_DEFAULT, PM_QUIET + * @param[in] event_cb user callback + * @param[in] data user data + * @return request_id (>0), error code(<0) if fail\n + * @retval PKGMGR_R_OK success + * @retval PKGMGR_R_EINVAL invalid argument + * @retval PKGMGR_R_ECOMM communication error +*/ +int pkgmgr_client_uninstall(pkgmgr_client *pc, const char *pkg_type, + const char *pkg_name, pkgmgr_mode mode, + pkgmgr_handler event_cb, void *data); + +/** + * @brief This API activates package. + * + * This API is for package-manager client application.\n + * + * @param[in] pc pkgmgr_client + * @param[in] pkg_type package type + * @param[in] pkg_name package name + * @return request_id (>0) if success, error code(<0) if fail\n + * @retval PKGMGR_R_OK success + * @retval PKGMGR_R_EINVAL invalid argument + * @retval PKGMGR_R_ECOMM communication error +*/ +int pkgmgr_client_activate(pkgmgr_client *pc, const char *pkg_type, + const char *pkg_name); + +/** + * @brief This API deactivates package. + * + * This API is for package-manager client application.\n + * + * @param[in] pc pkgmgr_client + * @param[in] pkg_type package type + * @param[in] pkg_name package name + * @return request_id (>0) if success, error code(<0) if fail\n + * @retval PKGMGR_R_OK success + * @retval PKGMGR_R_EINVAL invalid argument + * @retval PKGMGR_R_ECOMM communication error +*/ +int pkgmgr_client_deactivate(pkgmgr_client *pc, const char *pkg_type, + const char *pkg_name); + +/** + * @brief This API deletes application's private data. + * + * This API is for package-manager client application.\n + * + * @param[in] pc pkgmgr_client + * @param[in] pkg_type package type + * @param[in] pkg_name package name + * @param[in] mode installation mode - PM_DEFAULT, PM_QUIET + * @return request_id (>0) if success, error code(<0) if fail\n + * @retval PKGMGR_R_OK success + * @retval PKGMGR_R_EINVAL invalid argument + * @retval PKGMGR_R_ECOMM communication error +*/ +int pkgmgr_client_clear_user_data(pkgmgr_client *pc, const char *pkg_type, + const char *pkg_name, pkgmgr_mode mode); + +/** + * @brief This API request to listen the pkgmgr's broadcasting + * + * This API is for package-manager client application.\n + * + * @param[in] pc pkgmgr_client + * @param[in] event_cb user callback + * @param[in] data user data + * @return request_id (>0) if success, error code(<0) if fail\n + * @retval PKGMGR_R_OK success + * @retval PKGMGR_R_EINVAL invalid argument +*/ +int pkgmgr_client_listen_status(pkgmgr_client *pc, pkgmgr_handler event_cb, + void *data); + +/** + * @brief This API broadcasts pkgmgr's status + * + * This API is for package-manager client application.\n + * + * @param[in] pc pkgmgr_client + * @param[in] pkg_type package type + * @param[in] pkg_name package name + * @param[in] key key to broadcast + * @param[in] val value to broadcast + * @return 0 if success, error code(<0) if fail\n + * @retval PKGMGR_R_OK success + * @retval PKGMGR_R_EINVAL invalid argument +*/ +int pkgmgr_client_broadcast_status(pkgmgr_client *pc, const char *pkg_type, + const char *pkg_name, const char *key, + const char *val); + +/** + * @brief This API provides package list + * + * This API is for package-manager client application.\n + * + * @param[in] iter_fn iteration function for list + * @param[in] data user data + * @return 0 if success, error code(<0) if fail\n + * @retval PKGMGR_R_OK success + * @retval PKGMGR_R_EINVAL invalid argument + * @retval PKGMGR_R_ERROR internal error +*/ +int pkgmgr_get_pkg_list(pkgmgr_iter_fn iter_fn, void *data); +/** @} */ + +/** + * @defgroup pkg_list APIs to get package information + * @ingroup pkgmgr + * @brief + * API to get package information +*/ + +/** + * @addtogroup pkg_list + * @{ + */ + +typedef void pkgmgr_info; + +/** + * @brief This API gets the package's information. + * + * This API is for package-manager client application.\n + * + * @param[in] pkg_type package type for the package to get infomation + * @param[in] pkg_name package name for the package to get infomation + * @return package entry pointer if success, NULL if fail\n +*/ +pkgmgr_info * pkgmgr_info_new(const char *pkg_type, const char *pkg_name); + +/** + * @brief This API gets the package's information. + * + * This API is for package-manager client application.\n + * + * @param[in] pkg_type package type for the package to get infomation + * @param[in] pkg_path package file path to get infomation + * @return package entry pointer if success, NULL if fail\n +*/ +pkgmgr_info * pkgmgr_info_new_from_file(const char *pkg_type, + const char *pkg_path); + +/** + * @brief This API get package information value + * + * This API is for package-manager client application.\n + * + * @param[in] pkg_info pointer for package info entry + * @param[in] key key for package info field + * @return string value if success, NULL if fail\n +*/ +char * pkgmgr_info_get_string(pkgmgr_info * pkg_info, const char *key); + +/** + * @brief This API get package information value + * + * This API is for package-manager client application.\n + * + * @param[in] pkg_info pointer for package info entry + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_info_free(pkgmgr_info * pkg_info); + +/** + * @brief This API get package info entry from db + * + * This API is for package-manager client application.\n + * + * @param[in] pkg_name pointer to package name + * @param[out] handle pointer to the package info handle. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo(const char *pkg_name, pkgmgr_pkginfo_h *handle); + +/** + * @brief This API gets type of the given package. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to package info handle + * @param[out] type to hold package type. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_type(pkgmgr_pkginfo_h handle, char **type); + +/** + * @brief This API gets version of the given package. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to package info handle + * @param[out] version to hold package version. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_version(pkgmgr_pkginfo_h handle, char **version); + +/** + * @brief This API gets install location of the given package. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to package info handle + * @param[out] location to hold install location. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_install_location(pkgmgr_pkginfo_h handle, pkgmgr_install_location *location); + +/** + * @brief This API gets label of the given package. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to package info handle + * @param[out] label to hold package label. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_label(pkgmgr_pkginfo_h handle, char **label); + +/** + * @brief This API gets icon of the given package. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to package info handle + * @param[out] icon to hold package icon. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_icon(pkgmgr_pkginfo_h handle, char **icon); + +/** + * @brief This API gets desription of the given package. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to package info handle + * @param[out] description to hold package description. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_descriptioon(pkgmgr_pkginfo_h handle, char **description); + +/** + * @brief This API gets author's name of the given package. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to package info handle + * @param[out] author_name to hold author's name. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_author_name(pkgmgr_pkginfo_h handle, char **author_name); + +/** + * @brief This API gets author's email of the given package. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to package info handle + * @param[out] author_email to hold author's email id. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_author_email(pkgmgr_pkginfo_h handle, char **author_email); + +/** + * @brief This API gets author's href of the given package. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to package info handle + * @param[out] author_href to hold author's href. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_author_href(pkgmgr_pkginfo_h handle, char **author_href); + +/** + * @brief This API gets removable of the given package. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to package info handle + * @param[out] removable to hold removable value. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_removable(pkgmgr_pkginfo_h handle, bool *removable); + +/** + * @brief This API gets preload of the given package. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to package info handle + * @param[out] preload to hold preload value + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_preload(pkgmgr_pkginfo_h handle, bool *preload); + +/** + * @brief This API gets readonly value of the given package. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to package info handle + * @param[out] readonly to hold readonly value + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_readonly(pkgmgr_pkginfo_h handle, bool *readonly); + +/** + * @brief This API gets list of ui-application/service application of the given package. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to package info handle + * @param[in] component application component type. + * @param[in] app_func application's callback function. + * @param[in] user_data user data to be passed to callback function + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_info_app(pkgmgr_pkginfo_h handle, pkgmgr_app_component component, + pkgmgr_info_app_list_cb app_func, void *user_data); + +/** + * @brief This API gets list of installed applications. + * + * This API is for package-manager client application.\n + * + * @param[in] iter_fn iteration function for list + * @param[in] user_data user data to be passed to callback function + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_info_list(pkgmgr_iter_fn iter_fn, void *user_data); + + +/** + * @brief This API destroy the pacakge info handle + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to package info handle + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_destroy_pkginfo(pkgmgr_pkginfo_h handle); + +/** + * @brief This API gets application info entry from db. + * + * This API is for package-manager client application.\n + * + * @param[in] appid application id + * @param[out] handle pointer to app info handle + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_appinfo(const char *appid, pkgmgr_appinfo_h *handle); + +/** + * @brief This API gets exec of the given appid. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to app info handle + * @param[out] exec to hold exec value + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_exec(pkgmgr_appinfo_h handle, char **exec); + +/** + * @brief This API gets component type of the given appid. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to app info handle + * @param[out] component to hold component value + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_component(pkgmgr_appinfo_h handle, char **component); + +/** + * @brief This API gets app type of the given appid. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to app info handle + * @param[out] app_type to hold the apptype. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_apptype(pkgmgr_appinfo_h handle, char **app_type); + +/** + * @brief This API gets nodisplay value of the given appid. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to app info handle + * @param[out] nodisplay to hold the nodisplay value + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_nodisplay(pkgmgr_appinfo_h handle, bool *nodisplay); + +/** + * @brief This API gets multiple value of the given appid. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to app info handle + * @param[out] multiple to hold the multiple value + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_multiple(pkgmgr_appinfo_h handle, bool *multiple); + +/** + * @brief This API gets taskmanage value of the given appid. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to app info handle + * @param[out] taskmanage to hold the taskmanage value + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_taskmanage(pkgmgr_appinfo_h handle, bool *taskmanage); + +/** + * @brief This API gets onboot value of the given appid. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to app info handle + * @param[out] onboot to hold the onboot value + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_onboot(pkgmgr_appinfo_h handle, bool *onboot); + +/** + * @brief This API gets autorestart value of the given appid. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to app info handle + * @param[out] autorestart to hold the autorestart value + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_get_pkginfo_autorestart(pkgmgr_appinfo_h handle, bool *autorestart); + +/** + * @brief This API destroy the appinfo handle. + * + * This API is for package-manager client application.\n + * + * @param[in] handle pointer to app info handle + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_destroy_appinfo(pkgmgr_appinfo_h handle); +/** @} */ + +#ifdef __cplusplus +} +#endif +#endif /* __PKG_MANAGER_H__ */ +/** + * @} + * @} + */ + diff --git a/include/pkgmgr-dbinfo.h b/include/pkgmgr-dbinfo.h new file mode 100755 index 0000000..a5baf98 --- /dev/null +++ b/include/pkgmgr-dbinfo.h @@ -0,0 +1,208 @@ +/* + * slp-pkgmgr + * + * Copyright (c) 2000 - 2011 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. + * + */ + + +/** + * @file pkgmgr-dbinfo.h + * @author Shobhit Srivastava + * @version 0.1 + * @brief This file declares db set API for backend installers + * + * @addtogroup APPLICATION_FRAMEWORK + * @{ + * + * @defgroup PackageManager + * @section Header to use them: + * @code + * #include "pkgmgr-dbinfo.h" + * @endcode + * + * @addtogroup PackageManager + * @{ + */ + +#ifndef __PKGMGR_DBINFO_H__ +#define __PKGMGR_DBINFO_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef DEPRECATED +#define DEPRECATED __attribute__ ((__deprecated__)) +#endif + +typedef enum { + INSTALL_INTERNAL = 0, + INSTALL_EXTERNAL, +} INSTALL_LOCATION; + +typedef void* pkgmgr_pkgdbinfo_h; + +/** + * @brief This API creates package info handle to set info in the db. + * + * This API is for backend installers.\n + * + * @param[in] pkg_name package name. + * @param[out] handle package info handle. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_create_pkgdbinfo(const char *pkg_name, pkgmgr_pkgdbinfo_h *handle); + +/** + * @brief This API sets the package type in DB. + * + * This API is for backend installers.\n + * + * @param[in] handle package info handle. + * @param[in] type package type. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_set_type_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *type); + +/** + * @brief This API sets the package version in DB. + * + * This API is for backend installers.\n + * + * @param[in] handle package info handle. + * @param[in] version package version. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_set_version_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *version); + +/** + * @brief This API sets install location in DB + * + * This API is for backend installers.\n + * + * @param[in] handle package info handle. + * @param[in] location install location. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_set_install_location_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, INSTALL_LOCATION location); + +/** + * @brief This API sets label in DB. + * + * This API is for backend installers.\n + * + * @param[in] handle package info handle. + * @param[in] label label text. + * @param[in] locale locale (NULL for default). + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_set_label_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *label, const char *locale); + +/** + * @brief This API sets icon in DB. + * + * This API is for backend installers.\n + * + * @param[in] handle package info handle. + * @param[in] icon icon name. + * @param[in] locale locale (NULL for default). + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_set_icon_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *icon, const char *locale); + +/** + * @brief This API sets description in DB. + * + * This API is for backend installers.\n + * + * @param[in] handle package info handle. + * @param[in] description description of the package. + * @param[in] locale locale (NULL for default). + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_set_description_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *description, const char *locale); + +/** + * @brief This API sets author's name, email, href in DB. + * + * This API is for backend installers.\n + * + * @param[in] handle package info handle. + * @param[in] author_name author' name. + * @param[in] author_email author's email. + * @param[in] author_href author's href. + * @param[in] locale locale (NULL for default). + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_set_author_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *author_name, + const char *author_email, const char *author_href, const char *locale); + +/** + * @brief This API sets removable in DB. + * + * This API is for backend installers.\n + * + * @param[in] handle package info handle. + * @param[in] removable removable (0 | 1) + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_set_removable_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, int removable); + +/** + * @brief This API sets preload in DB. + * + * This API is for backend installers.\n + * + * @param[in] handle package info handle. + * @param[in] preload preload (0 | 1) + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_set_preload_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, int preload); + +/** + * @brief This API save pakage info entry into the db. + * + * This API is for backend installers.\n + * + * @param[in] handle package info handle. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_save_pkgdbinfo(pkgmgr_pkgdbinfo_h handle); + +/** + * @brief This API destroy pakage info handle and free the resources. + * + * This API is for backend installers.\n + * + * @param[in] handle package info handle. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_destroy_pkgdbinfo(pkgmgr_pkgdbinfo_h handle); + +#ifdef __cplusplus +} +#endif +#endif /* __PKGMGR_DBINFO_H__ */ +/** + * @} + * @} + */ + diff --git a/installers/sample/CMakeLists.txt b/installers/sample/CMakeLists.txt index 791a981..334be60 100755 --- a/installers/sample/CMakeLists.txt +++ b/installers/sample/CMakeLists.txt @@ -1,5 +1,9 @@ include(FindPkgConfig) -pkg_check_modules(security_pkgs security-server) +pkg_check_modules(parser_pkgs REQUIRED dlog libxml-2.0) + +foreach(flag ${parser_pkgs_CFLAGS}) + set(parser_pkgs_CFLAGS_str "${parser_pkgs_CFLAGS_str} ${flag}") +endforeach() add_executable(pkgmgr_backend_sample sample_backend.c) @@ -8,6 +12,11 @@ target_link_libraries(pkgmgr_backend_sample pkgmgr_installer) add_library(pkgmgr_backend_lib_sample SHARED sample_backendlib.c) +add_library(pkgmgr_parser_lib_sample SHARED + sample_parserlib.c) +set_target_properties(pkgmgr_parser_lib_sample PROPERTIES COMPILE_FLAGS "${parser_pkgs_CFLAGS_str}") +target_link_libraries(pkgmgr_parser_lib_sample ${parser_pkgs_LDFLAGS}) + install(TARGETS pkgmgr_backend_sample DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE) @@ -16,3 +25,8 @@ install(TARGETS pkgmgr_backend_lib_sample DESTINATION lib COMPONENT RuntimeLibraries PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE) + +install(TARGETS pkgmgr_parser_lib_sample + DESTINATION lib + COMPONENT RuntimeLibraries + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE) diff --git a/installers/sample/sample_parserlib.c b/installers/sample/sample_parserlib.c new file mode 100755 index 0000000..f42a7de --- /dev/null +++ b/installers/sample/sample_parserlib.c @@ -0,0 +1,87 @@ +/* + * slp-pkgmgr + * + * Copyright (c) 2000 - 2011 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. + * + */ + + + + + +/* sample_parserlib.c + * test package + */ + +#include +#include +#include + +/* debug output */ +#include +#undef LOG_TAG +#define LOG_TAG "PKGMGR_PARSER" + +#define DBGE(fmt, arg...) LOGE("[%s,%d] "fmt, __FUNCTION__, __LINE__, ##arg) +#define DBGI(fmt, arg...) LOGD("[%s,%d] "fmt, __FUNCTION__, __LINE__, ##arg) + + +static void +print_element_names(xmlNode * a_node) +{ + xmlNode *cur_node = NULL; + + for (cur_node = a_node; cur_node; cur_node = cur_node->next) { + if (cur_node->type == XML_ELEMENT_NODE) { + DBGI("node type: Element, name: %s\n", cur_node->name); + } + + print_element_names(cur_node->children); + } +} + + +__attribute__ ((visibility("default"))) +int PKGMGR_PARSER_PLUGIN_INSTALL(xmlDocPtr docPtr) +{ + xmlNode *root_element = NULL; + + xmlTextReaderPtr reader = xmlReaderWalker(docPtr); + if(reader != NULL) { + int ret = xmlTextReaderRead(reader); + while(ret == 1) { + const xmlChar *name; + name = xmlTextReaderConstName(reader); + DBGI("name %s", name?name:"NULL"); + ret = xmlTextReaderRead(reader); + } + xmlFreeTextReader(reader); + + if(ret != 0) { + DBGE("failed to parse"); + } + } + + /*Get the root element node */ + root_element = xmlFirstElementChild(xmlDocGetRootElement(docPtr)); + + print_element_names(root_element); + + return 0; +} + diff --git a/packaging/pkgmgr.spec b/packaging/pkgmgr.spec index 0843254..c234f7e 100755 --- a/packaging/pkgmgr.spec +++ b/packaging/pkgmgr.spec @@ -1,6 +1,7 @@ +#sbs-git:slp/pkgs/s/slp-pkgmgr pkgmgr 0.1.103 29b53909a5d6e8728429f0a188177eac691cb6ce Name: pkgmgr Summary: Packager Manager client library package -Version: 0.1.111 +Version: 0.1.136 Release: 1 Group: System/Libraries License: Apache License, Version 2.0 @@ -15,6 +16,7 @@ BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(aul) BuildRequires: pkgconfig(ail) BuildRequires: pkgconfig(appcore-efl) +BuildRequires: pkgconfig(libxml-2.0) %description @@ -65,8 +67,25 @@ Requires: %{name} = %{version}-%{release} %description installer-devel Dev package for libpkgmgr-installer for packaging. +%package parser +Summary: Library for manifest parser +Group: TO_BE/FILLED_IN +Requires: %{name} = %{version}-%{release} +Requires(post): /sbin/ldconfig +Requires(postun): /sbin/ldconfig + +%description parser +Library for manifest parser + +%package parser-devel +Summary: Dev package for libpkgmgr-parser +Group: TO_BE/FILLED_IN +Requires: %{name} = %{version}-%{release} + +%description parser-devel +Dev package for libpkgmgr-parser %package types-devel -Summary: Package Manager client types develpoment package +Summary: Package Manager manifest parser develpoment package Group: TO_BE/FILLED_IN Requires: %{name} = %{version}-%{release} @@ -90,8 +109,8 @@ rm -rf %{buildroot} %post /sbin/ldconfig -mkdir -p /usr/etc/package-manager/frontend mkdir -p /usr/etc/package-manager/backend +mkdir -p /usr/etc/package-manager/backendlib # For pkgmgr-install: # Update mime database to support package mime types @@ -113,6 +132,8 @@ mkdir -p /usr/etc/package-manager/server %files %defattr(-,root,root,-) %{_bindir}/pkgcmd +%{_bindir}/pkginfo +%{_bindir}/pkg_initdb %exclude %{_bindir}/pkgmgr_backend_sample %exclude %{_includedir}/pkgmgr/comm_client.h %exclude %{_includedir}/pkgmgr/comm_config.h @@ -126,7 +147,8 @@ mkdir -p /usr/etc/package-manager/server %{_datadir}/mime/packages/mime.wac.xml %{_bindir}/pkgmgr-install %{_libdir}/libpkgmgr-client.so.* -/opt/share/applications/org.tizen.pkgmgr-install.desktop +%{_datadir}/applications/org.tizen.pkgmgr-install.desktop +%{_datadir}/packages/org.tizen.pkgmgr-install.xml %files client-devel %defattr(-,root,root,-) @@ -156,6 +178,22 @@ mkdir -p /usr/etc/package-manager/server %{_libdir}/libpkgmgr_installer_client.so %{_libdir}/libpkgmgr_installer_status_broadcast_server.so +%files parser +%defattr(-,root,root,-) +%{_libdir}/libpkgmgr_parser.so.* +%{_prefix}/etc/package-manager/preload/preload_list.txt +%{_prefix}/etc/package-manager/preload/manifest.xsd +%{_prefix}/etc/package-manager/preload/xml.xsd +%{_libdir}/libpkgmgr_parser_lib_sample.so + +%files parser-devel +%defattr(-,root,root,-) +%{_includedir}/pkgmgr/pkgmgr_parser.h +%{_libdir}/pkgconfig/pkgmgr-parser.pc +%{_libdir}/libpkgmgr_parser.so + + + %files types-devel %defattr(-,root,root,-) %{_includedir}/package-manager-types.h diff --git a/parser/CMakeLists.txt b/parser/CMakeLists.txt new file mode 100755 index 0000000..345198c --- /dev/null +++ b/parser/CMakeLists.txt @@ -0,0 +1,74 @@ +### Description +# Communication modules for pkg-mgr client lib and server process +# By Youmin Ha + +cmake_minimum_required(VERSION 2.6) +#set(CMAKE_SKIP_BUILD_RPATH true) +set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true) + + +### Versioning +if(DEFINED ${VERSION}) + message("VERSION: ${VERSION}") +else() + message("VERSION is not defined. set it as 0.1.0") + set(VERSION 0.1.0) +endif() +if(DEFINED ${VERSION_MAJOR}) + message("VERSION_MAJOR: ${VERSION_MAJOR}") +else() + message( "VERSION_MAJOR is not defined. set it as 0") + set(VERSION_MAJOR 0) +endif() +message(STATUS "version/major : ${VERSION} / ${VERSION_MAJOR}") + +### Get required CFLAGS, LDFLAGS from pkg-config + +include(FindPkgConfig) +pkg_check_modules(parser_pkgs REQUIRED dlog libxml-2.0 glib-2.0 sqlite3 db-util) + +foreach(flag ${parser_pkgs_CFLAGS}) + set(parser_pkgs_CFLAGS_str "${parser_pkgs_CFLAGS_str} ${flag}") +endforeach() + +## Additional flag +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden") +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -Wall") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") + +### Set current binary dir to be included (for generated *.h files) +include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/client/include) + +### Build modules + +## pkgmgr_parser object (by sewook.park) +# This library is for installer backend +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}) +set_target_properties(pkgmgr_parser PROPERTIES COMPILE_FLAGS "${parser_pkgs_CFLAGS_str}") +target_link_libraries(pkgmgr_parser ${parser_pkgs_LDFLAGS}) + +### Create pc file +configure_file(pkgmgr-parser.pc.in ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-parser.pc @ONLY) +configure_file(preload_list.txt.in preload_list.txt @ONLY) +configure_file(manifest.xsd.in manifest.xsd @ONLY) +configure_file(xml.xsd.in xml.xsd @ONLY) + +## Install +INSTALL(TARGETS + pkgmgr_parser + DESTINATION lib + COMPONENT RuntimeLibraries) +INSTALL(FILES + pkgmgr_parser.h + DESTINATION include/pkgmgr) + +INSTALL(FILES + ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-parser.pc + DESTINATION lib/pkgconfig) + +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/preload_list.txt DESTINATION ${PREFIX}/etc/package-manager/preload/) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/manifest.xsd DESTINATION ${PREFIX}/etc/package-manager/preload/) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/xml.xsd DESTINATION ${PREFIX}/etc/package-manager/preload/) diff --git a/parser/build.sh b/parser/build.sh new file mode 100755 index 0000000..8cb600c --- /dev/null +++ b/parser/build.sh @@ -0,0 +1,30 @@ + +#export CFLAGS="" +#export LDFLAGS="" + +cd `dirname $0` + +PREFIX=/usr + +rm -rf cmake_tmp +mkdir -p cmake_tmp +cd cmake_tmp + +CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" cmake .. -DCMAKE_INSTALL_PREFIX=${PREFIX} && +make && + +# test +{ + export LD_LIBRARY_PATH=`pwd` + cd test +# ./test_comm_client & +# ./test_comm_status_broadcast_server +# ./test_comm_socket && + ./test_pkgmgr_installer +} +if [ "$?" == "0" ]; then + echo "Test done." +else + echo "Test failed!" +fi + diff --git a/parser/manifest.xsd.in b/parser/manifest.xsd.in new file mode 100755 index 0000000..2448080 --- /dev/null +++ b/parser/manifest.xsd.in @@ -0,0 +1,172 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/parser/pkgmgr-parser.pc.in b/parser/pkgmgr-parser.pc.in new file mode 100755 index 0000000..71947db --- /dev/null +++ b/parser/pkgmgr-parser.pc.in @@ -0,0 +1,16 @@ +# +# Copyright (c) 2008 ~ 2010 Samsung Electronics Co., Ltd. +# All rights reserved. +# + +prefix=@PREFIX@ +exec_prefix=@EXEC_PREFIX@ +libdir=@LIBDIR@ +includedir=@INCLUDEDIR@ + +Name: package manager parser library +Description: SLP package manager's installer lib for each backends +Version: @VERSION@ +Requires: libxml-2.0 +Libs: -L${libdir} -lpkgmgr_parser +Cflags: -I${includedir}/pkgmgr diff --git a/parser/pkgmgr_parser.c b/parser/pkgmgr_parser.c new file mode 100755 index 0000000..715ac70 --- /dev/null +++ b/parser/pkgmgr_parser.c @@ -0,0 +1,4580 @@ +/* + * slp-pkgmgr + * + * Copyright (c) 2000 - 2011 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 "pkgmgr-internal.h" +#include "pkgmgr_parser.h" +#include "pkgmgr_parser_internal.h" +#include "pkgmgr_parser_db.h" +#include "package-manager.h" + +#define MANIFEST_RW_DIRECTORY "/opt/share/packages" +#define MANIFEST_RO_DIRECTORY "/usr/share/packages" +#define ASCII(s) (const char *)s +#define XMLCHAR(s) (const xmlChar *)s + +/* operation_type */ +typedef enum { + ACTION_INSTALL = 0, + ACTION_UPGRADE, + ACTION_UNINSTALL, + ACTION_MAX +} ACTION_TYPE; + +char *package; + +static int __ps_process_content(xmlTextReaderPtr reader, content_x *content); +static int __ps_process_control(xmlTextReaderPtr reader, control_x *control); +static int __ps_process_group(xmlTextReaderPtr reader, group_x *group); +static int __ps_process_livebox(xmlTextReaderPtr reader, livebox_x *livebox); +static int __ps_process_pd(xmlTextReaderPtr reader, pd_x *pd); +static int __ps_process_label(xmlTextReaderPtr reader, label_x *label); +static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile); +static int __ps_process_timeout(xmlTextReaderPtr reader, timeout_x *timeout); +static int __ps_process_network(xmlTextReaderPtr reader, network_x *network); +static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed); +static int __ps_process_period(xmlTextReaderPtr reader, period_x *period); +static int __ps_process_autolaunch(xmlTextReaderPtr reader, autolaunch_x *autolaunch); +static int __ps_process_file(xmlTextReaderPtr reader, file_x *file); +static int __ps_process_size(xmlTextReaderPtr reader, size_x *size); +static int __ps_process_grp(xmlTextReaderPtr reader, grp_x *grp); +static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation); +static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri); +static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime); +static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition); +static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notifiation); +static int __ps_process_category(xmlTextReaderPtr reader, category_x *category); +static int __ps_process_security(xmlTextReaderPtr reader, security_x *security); +static int __ps_process_libexec(xmlTextReaderPtr reader, libexec_x *libexec); +static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility); +static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution); +static int __ps_process_request(xmlTextReaderPtr reader, request_x *request); +static int __ps_process_define(xmlTextReaderPtr reader, define_x *define); +static int __ps_process_registry(xmlTextReaderPtr reader, registry_x *registry); +static int __ps_process_database(xmlTextReaderPtr reader, database_x *database); +static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc); +static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions); +static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare); +static int __ps_process_layout(xmlTextReaderPtr reader, layout_x *layout); +static int __ps_process_cluster(xmlTextReaderPtr reader, cluster_x *cluster); +static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon); +static int __ps_process_lbox(xmlTextReaderPtr reader, lbox_x *lbox); +static int __ps_process_author(xmlTextReaderPtr reader, author_x *author); +static int __ps_process_description(xmlTextReaderPtr reader, description_x *description); +static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability); +static int __ps_process_license(xmlTextReaderPtr reader, license_x *license); +static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol); +static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol); +static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication); +static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication); +static int __ps_process_font(xmlTextReaderPtr reader, font_x *font); +static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme); +static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon); +static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime); +static void __ps_free_content(content_x *content); +static void __ps_free_control(control_x *control); +static void __ps_free_group(group_x *group); +static void __ps_free_livebox(livebox_x *livebox); +static void __ps_free_pd(pd_x *pd); +static void __ps_free_label(label_x *label); +static void __ps_free_deviceprofile(deviceprofile_x * deviceprofile); +static void __ps_free_timeout(timeout_x *timeout); +static void __ps_free_network(network_x *network); +static void __ps_free_allowed(allowed_x *allowed); +static void __ps_free_period(period_x *period); +static void __ps_free_autolaunch(autolaunch_x *autolaunch); +static void __ps_free_file(file_x *file); +static void __ps_free_size(size_x *size); +static void __ps_free_grp(grp_x *grp); +static void __ps_free_operation(operation_x *operation); +static void __ps_free_uri(uri_x *uri); +static void __ps_free_mime(mime_x *mime); +static void __ps_free_condition(condition_x *condition); +static void __ps_free_notification(notification_x *notifiation); +static void __ps_free_category(category_x *category); +static void __ps_free_security(security_x *security); +static void __ps_free_libexec(libexec_x *libexec); +static void __ps_free_compatibility(compatibility_x *compatibility); +static void __ps_free_resolution(resolution_x *resolution); +static void __ps_free_request(request_x *request); +static void __ps_free_define(define_x *define); +static void __ps_free_registry(registry_x *registry); +static void __ps_free_database(database_x *database); +static void __ps_free_appsvc(appsvc_x *appsvc); +static void __ps_free_launchconditions(launchconditions_x *launchconditions); +static void __ps_free_datashare(datashare_x *datashare); +static void __ps_free_layout(layout_x *layout); +static void __ps_free_cluster(cluster_x *cluster); +static void __ps_free_icon(icon_x *icon); +static void __ps_free_lbox(lbox_x *lbox); +static void __ps_free_author(author_x *author); +static void __ps_free_description(description_x *description); +static void __ps_free_capability(capability_x *capability); +static void __ps_free_license(license_x *license); +static void __ps_free_appcontrol(appcontrol_x *appcontrol); +static void __ps_free_datacontrol(datacontrol_x *datacontrol); +static void __ps_free_uiapplication(uiapplication_x *uiapplication); +static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication); +static void __ps_free_font(font_x *font); +static void __ps_free_theme(theme_x *theme); +static void __ps_free_daemon(daemon_x *daemon); +static void __ps_free_ime(ime_x *ime); +static char *__pkgname_to_manifest(const char *pkgname); +static int __next_child_element(xmlTextReaderPtr reader, int depth); +static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx); +static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx); +static void __str_trim(char *input); +static char *__get_parser_plugin(const char *type); +static int __ps_run_parser(xmlDocPtr docPtr, const char *tag, ACTION_TYPE action, const char *pkgname); +static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgname); +static void __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgname); +static void __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgname); +static int __validate_appid(const char *pkgname, const char *appid, char **newappid); + +static void __str_trim(char *input) +{ + char *trim_str = input; + + if (input == NULL) + return; + + while (*input != 0) { + if (!isspace(*input)) { + *trim_str = *input; + trim_str++; + } + input++; + } + + *trim_str = 0; + return; +} + +static int __validate_appid(const char *pkgname, const char *appid, char **newappid) +{ + if (!pkgname || !appid || !newappid) { + DBG("Arg supplied is NULL\n"); + return -1; + } + int pkglen = strlen(pkgname); + int applen = strlen(appid); + char *ptr = NULL; + char *newapp = NULL; + int len = 0; + if (strncmp(appid, ".", 1) == 0) { + len = pkglen + applen + 1; + newapp = calloc(1,len); + if (newapp == NULL) { + DBG("Malloc failed\n"); + return -1; + } + strncpy(newapp, pkgname, pkglen); + strncat(newapp, appid, applen); + DBG("new appid is %s\n", newapp); + *newappid = newapp; + return 0; + } + if (applen < pkglen) { + DBG("app id is not proper\n"); + *newappid = NULL; +#ifdef _VALIDATE_APPID_ + return -1; +#else + return 0; +#endif + } + if (!strcmp(appid, pkgname)) { + DBG("appid is proper\n"); + *newappid = NULL; + return 0; + } + else if (strncmp(appid, pkgname, pkglen) == 0) { + ptr = strstr(appid, pkgname); + ptr = ptr + pkglen; + if (strncmp(ptr, ".", 1) == 0) { + DBG("appid is proper\n"); + *newappid = NULL; + return 0; + } + else { + DBG("appid is not proper\n"); + *newappid = NULL; +#ifdef _VALIDATE_APPID_ + return -1; +#else + return 0; +#endif + } + } else { + DBG("appid is not proper\n"); + *newappid = NULL; +#ifdef _VALIDATE_APPID_ + return -1; +#else + return 0; +#endif + } + return 0; +} + + +static char *__get_parser_plugin(const char *type) +{ + FILE *fp = NULL; + char buffer[1024] = { 0 }; + char temp_path[1024] = { 0 }; + char *lib_path = NULL; + char *path = NULL; + + if (type == NULL) { + _LOGE("invalid argument\n"); + return NULL; + } + + fp = fopen(PKG_CONF_PATH, "r"); + if (fp == NULL) { + _LOGE("no matching backendlib\n"); + return NULL; + } + + while (fgets(buffer, sizeof(buffer), fp) != NULL) { + if (buffer[0] == '#') + continue; + + __str_trim(buffer); + + if ((path = strstr(buffer, PKG_PARSERLIB)) != NULL) { + _LOGD("[%s]\n", path); + path = path + strlen(PKG_PARSERLIB); + _LOGD("[%s]\n", path); + + break; + } + + memset(buffer, 0x00, 1024); + } + + if (fp != NULL) + fclose(fp); + + if (path == NULL) { + _LOGE("no matching backendlib\n"); + return NULL; + } + + snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type); + + return strdup(temp_path); +} + +static int __ps_run_parser(xmlDocPtr docPtr, const char *tag, + ACTION_TYPE action, const char *pkgname) +{ + char *lib_path = NULL; + void *lib_handle = NULL; + int (*plugin_install) (xmlDocPtr, const char *); + int ret = -1; + char *ac; + + switch (action) { + case ACTION_INSTALL: + ac = "PKGMGR_PARSER_PLUGIN_INSTALL"; + break; + case ACTION_UPGRADE: + ac = "PKGMGR_PARSER_PLUGIN_UPGRADE"; + break; + case ACTION_UNINSTALL: + ac = "PKGMGR_PARSER_PLUGIN_UNINSTALL"; + break; + default: + goto END; + } + + lib_path = __get_parser_plugin(tag); + if (!lib_path) { + goto END; + } + + if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) { + _LOGE("dlopen is failed lib_path[%s]\n", lib_path); + goto END; + } + + if ((plugin_install = + dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) { + _LOGE("can not find symbol \n"); + goto END; + } + + ret = plugin_install(docPtr, pkgname); + + END: + if (lib_path) + free(lib_path); + if (lib_handle) + dlclose(lib_handle); + return ret; +} + +static char *__pkgname_to_manifest(const char *pkgname) +{ + char *manifest; + int size; + + if (pkgname == NULL) { + DBGE("pkgname is NULL"); + return NULL; + } + + size = strlen(MANIFEST_RW_DIRECTORY) + strlen(pkgname) + 10; + manifest = malloc(size); + if (manifest == NULL) { + DBGE("No memory"); + return NULL; + } + + snprintf(manifest, size, MANIFEST_RW_DIRECTORY "/%s.xml", pkgname); + + if (access(manifest, F_OK)) { + snprintf(manifest, size, MANIFEST_RO_DIRECTORY "/%s.xml", pkgname); + } + + return manifest; +} + +static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgname) +{ + int nLoop = 0; + int pid = 0; + char *parser_cmd = NULL; + int ret = -1; + const xmlChar *name; + char *lib_path = NULL; + void *lib_handle = NULL; + int (*plugin_install) (xmlDocPtr); + + DBG("__run_parser_prestep"); + + if (xmlTextReaderDepth(reader) != 1) { + DBGE("Node depth is not 1"); + goto END; + } + + if (!xmlTextReaderHasAttributes(reader)) { + DBGE("No attributes"); + goto END; + } + + if (xmlTextReaderNodeType(reader) != 1) { + DBGE("Node type is not 1"); + goto END; + } + + const xmlChar *value; + name = xmlTextReaderConstName(reader); + if (name == NULL) { + DBGE("TEST TEST TES\n"); + name = BAD_CAST "--"; + } + + value = xmlTextReaderConstValue(reader); + DBG("%d %d %s %d %d", + xmlTextReaderDepth(reader), + xmlTextReaderNodeType(reader), + name, + xmlTextReaderIsEmptyElement(reader), xmlTextReaderHasValue(reader)); + + if (value == NULL) { + DBG("ConstValue NULL"); + } else { + if (xmlStrlen(value) > 40) { + DBG(" %.40s...", value); + } else { + DBG(" %s", value); + } + } + + name = xmlTextReaderConstName(reader); + if (name == NULL) { + DBGE("TEST TEST TES\n"); + name = BAD_CAST "--"; + } + + xmlDocPtr docPtr = xmlTextReaderCurrentDoc(reader); + DBG("docPtr->URL %s\n", (char *)docPtr->URL); + xmlDocPtr copyDocPtr = xmlCopyDoc(docPtr, 1); + if (copyDocPtr == NULL) + return -1; + xmlNode *rootElement = xmlDocGetRootElement(copyDocPtr); + if (rootElement == NULL) + return -1; + xmlNode *cur_node = xmlFirstElementChild(rootElement); + if (cur_node == NULL) + return -1; + xmlNode *next_node = NULL; + next_node = xmlNextElementSibling(cur_node); + if (next_node) { + cur_node->next = NULL; + next_node->prev = NULL; + xmlFreeNodeList(next_node); + xmlSetTreeDoc(cur_node, copyDocPtr); + } else + xmlSetTreeDoc(cur_node, copyDocPtr); + +#ifdef __DEBUG__ + +//#else + DBG("node type: %d, name: %s children->name: %s last->name: %s\n" + "parent->name: %s next->name: %s prev->name: %s\n", + cur_node->type, cur_node->name, + cur_node->children ? cur_node->children->name : "NULL", + cur_node->last ? cur_node->last->name : "NULL", + cur_node->parent ? cur_node->parent->name : "NULL", + cur_node->next ? cur_node->next->name : "NULL", + cur_node->prev ? cur_node->prev->name : "NULL"); + + FILE *fp = fopen("/opt/share/test.xml", "a"); + xmlDocDump(fp, copyDocPtr); + fprintf(fp, "\n"); + fclose(fp); +#endif + + ret = __ps_run_parser(copyDocPtr, name, action, pkgname); + + END: + + return ret; +} + +static void +__processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgname) +{ + char *tag = NULL; + int i = 0; + + switch (xmlTextReaderNodeType(reader)) { + case XML_READER_TYPE_END_ELEMENT: + { + // DBG("XML_READER_TYPE_END_ELEMENT"); + break; + } + + case XML_READER_TYPE_ELEMENT: + { + // Elements without closing tag don't receive + // XML_READER_TYPE_END_ELEMENT event. + + const xmlChar *elementName = + xmlTextReaderLocalName(reader); + if (elementName) { +// DBG("elementName %s\n", (char *)elementName); + } + + const xmlChar *nameSpace = + xmlTextReaderConstNamespaceUri(reader); + if (nameSpace) { +// DBG("nameSpace %s\n", (char *)nameSpace); + } +/* + DBG("XML_READER_TYPE_ELEMENT %s, %s\n", + elementName ? elementName : "NULL", + nameSpace ? nameSpace : "NULL"); +*/ + if (tagv == NULL) { + DBG("__run_parser_prestep pkgname[%s]\n", pkgname); + __run_parser_prestep(reader, action, pkgname); + } + else { + i = 0; + for (tag = tagv[0]; tag; tag = tagv[++i]) + if (strcmp(tag, elementName) == 0) { + DBG("__run_parser_prestep tag[%s] pkgname[%s]\n", tag, pkgname); + __run_parser_prestep(reader, + action, pkgname); + break; + } + } + + break; + } + case XML_READER_TYPE_TEXT: + case XML_READER_TYPE_CDATA: + { + const xmlChar *value = xmlTextReaderConstValue(reader); + if (value) { +// DBG("value %s\n", value); + } + + const xmlChar *lang = xmlTextReaderConstXmlLang(reader); + if (lang) { +// DBG("lang\n", lang); + } + +/* DBG("XML_READER_TYPE_TEXT %s, %s\n", + value ? value : "NULL", lang ? lang : "NULL"); +*/ + break; + } + default: +// DBG("Ignoring Node of Type: %d", xmlTextReaderNodeType(reader)); + break; + } +} + +static void +__streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgname) +{ + xmlTextReaderPtr reader; + int ret; + + reader = xmlReaderForFile(filename, NULL, 0); + if (reader != NULL) { + ret = xmlTextReaderRead(reader); + while (ret == 1) { + __processNode(reader, action, tagv, pkgname); + ret = xmlTextReaderRead(reader); + } + xmlFreeTextReader(reader); + + if (ret != 0) { + DBGE("%s : failed to parse", filename); + } + } else { + DBGE("Unable to open %s", filename); + } +} + +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 __ps_free_timeout(timeout_x *timeout) +{ + if (timeout == NULL) + return; + if (timeout->text) { + free((void *)timeout->text); + timeout->text = NULL; + } + free((void*)timeout); + timeout = NULL; +} + +static void __ps_free_network(network_x *network) +{ + if (network == NULL) + return; + if (network->text) { + free((void *)network->text); + network->text = NULL; + } + free((void*)network); + network = NULL; +} + +static void __ps_free_period(period_x *period) +{ + if (period == NULL) + return; + if (period->text) { + free((void *)period->text); + period->text = NULL; + } + free((void*)period); + period = NULL; +} + +static void __ps_free_autolaunch(autolaunch_x *autolaunch) +{ + if (autolaunch == NULL) + return; + if (autolaunch->text) { + free((void *)autolaunch->text); + autolaunch->text = NULL; + } + free((void*)autolaunch); + autolaunch = NULL; +} + +static void __ps_free_category(category_x *category) +{ + if (category == NULL) + return; + if (category->name) { + free((void *)category->name); + category->name = NULL; + } + free((void*)category); + category = NULL; +} + +static void __ps_free_security(security_x *security) +{ + if (security == NULL) + return; + if (security->isolate) { + free((void *)security->isolate); + security->isolate = NULL; + } + free((void*)security); + security = NULL; +} + +static void __ps_free_libexec(libexec_x *libexec) +{ + if (libexec == NULL) + return; + if (libexec->text) { + free((void *)libexec->text); + libexec->text = NULL; + } + free((void*)libexec); + libexec = NULL; +} + +static void __ps_free_file(file_x *file) +{ + if (file == NULL) + return; + if (file->text) { + free((void *)file->text); + file->text = NULL; + } + free((void*)file); + file = NULL; +} + +static void __ps_free_size(size_x *size) +{ + if (size == NULL) + return; + if (size->text) { + free((void *)size->text); + size->text = NULL; + } + free((void*)size); + size = NULL; +} + +static void __ps_free_grp(grp_x *grp) +{ + if (grp == NULL) + return; + if (grp->text) { + free((void *)grp->text); + grp->text = NULL; + } + free((void*)grp); + grp = NULL; +} + +static void __ps_free_icon(icon_x *icon) +{ + if (icon == NULL) + return; + if (icon->text) { + free((void *)icon->text); + icon->text = NULL; + } + if (icon->lang) { + free((void *)icon->lang); + icon->lang = NULL; + } + if (icon->name) { + free((void *)icon->name); + icon->name= NULL; + } + if (icon->section) { + free((void *)icon->section); + icon->section = NULL; + } + if (icon->size) { + free((void *)icon->size); + icon->size = NULL; + } + free((void*)icon); + icon = NULL; +} + +static void __ps_free_operation(operation_x *operation) +{ + if (operation == NULL) + return; + if (operation->text) { + free((void *)operation->text); + operation->text = NULL; + } + free((void*)operation); + operation = NULL; +} + +static void __ps_free_uri(uri_x *uri) +{ + if (uri == NULL) + return; + if (uri->text) { + free((void *)uri->text); + uri->text = NULL; + } + free((void*)uri); + uri = NULL; +} + +static void __ps_free_mime(mime_x *mime) +{ + if (mime == NULL) + return; + if (mime->text) { + free((void *)mime->text); + mime->text = NULL; + } + free((void*)mime); + mime = NULL; +} + +static void __ps_free_condition(condition_x *condition) +{ + if (condition == NULL) + return; + if (condition->text) { + free((void *)condition->text); + condition->text = NULL; + } + if (condition->name) { + free((void *)condition->name); + condition->name = NULL; + } + free((void*)condition); + condition = NULL; +} + +static void __ps_free_notification(notification_x *notification) +{ + if (notification == NULL) + return; + if (notification->text) { + free((void *)notification->text); + notification->text = NULL; + } + if (notification->name) { + free((void *)notification->name); + notification->name = NULL; + } + free((void*)notification); + notification = NULL; +} + +static void __ps_free_compatibility(compatibility_x *compatibility) +{ + if (compatibility == NULL) + return; + if (compatibility->text) { + free((void *)compatibility->text); + compatibility->text = NULL; + } + if (compatibility->name) { + free((void *)compatibility->name); + compatibility->name = NULL; + } + free((void*)compatibility); + compatibility = NULL; +} + +static void __ps_free_resolution(resolution_x *resolution) +{ + if (resolution == NULL) + return; + if (resolution->mimetype) { + free((void *)resolution->mimetype); + resolution->mimetype = NULL; + } + if (resolution->urischeme) { + free((void *)resolution->urischeme); + resolution->urischeme = NULL; + } + free((void*)resolution); + resolution = NULL; +} + +static void __ps_free_capability(capability_x *capability) +{ + if (capability == NULL) + return; + if (capability->operationid) { + free((void *)capability->operationid); + capability->operationid = NULL; + } + /*Free Resolution*/ + if (capability->resolution) { + resolution_x *resolution = capability->resolution; + resolution_x *tmp = NULL; + while(resolution != NULL) + { + tmp = resolution->next; + __ps_free_resolution(resolution); + resolution = tmp; + } + } + free((void*)capability); + capability = NULL; +} + +static void __ps_free_allowed(allowed_x *allowed) +{ + if (allowed == NULL) + return; + if (allowed->name) { + free((void *)allowed->name); + allowed->name = NULL; + } + if (allowed->text) { + free((void *)allowed->text); + allowed->text = NULL; + } + free((void*)allowed); + allowed = NULL; +} + +static void __ps_free_request(request_x *request) +{ + if (request == NULL) + return; + if (request->text) { + free((void *)request->text); + request->text = NULL; + } + free((void*)request); + request = NULL; +} + +static void __ps_free_cluster(cluster_x *cluster) +{ + if (cluster == NULL) + return; + if (cluster->name) { + free((void *)cluster->name); + cluster->name = NULL; + } + /*Free Category*/ + if (cluster->category) { + category_x *category = cluster->category; + category_x *tmp = NULL; + while(category != NULL) + { + tmp = category->next; + __ps_free_category(category); + category = tmp; + } + } + free((void*)cluster); + cluster = NULL; +} + +static void __ps_free_appcontrol(appcontrol_x *appcontrol) +{ + if (appcontrol == NULL) + return; + if (appcontrol->providerid) { + free((void *)appcontrol->providerid); + appcontrol->providerid = NULL; + } + if (appcontrol->category) { + free((void *)appcontrol->category); + appcontrol->category = NULL; + } + /*Free Capability*/ + if (appcontrol->capability) { + capability_x *capability = appcontrol->capability; + capability_x *tmp = NULL; + while(capability != NULL) + { + tmp = capability->next; + __ps_free_capability(capability); + capability = tmp; + } + } + free((void*)appcontrol); + appcontrol = NULL; +} + +static void __ps_free_datacontrol(datacontrol_x *datacontrol) +{ + if (datacontrol == NULL) + return; + if (datacontrol->providerid) { + free((void *)datacontrol->providerid); + datacontrol->providerid = NULL; + } + /*Free Capability*/ + if (datacontrol->capability) { + capability_x *capability = datacontrol->capability; + capability_x *tmp = NULL; + while(capability != NULL) + { + tmp = capability->next; + __ps_free_capability(capability); + capability = tmp; + } + } + free((void*)datacontrol); + datacontrol = NULL; +} + +static void __ps_free_launchconditions(launchconditions_x *launchconditions) +{ + if (launchconditions == NULL) + return; + if (launchconditions->text) { + free((void *)launchconditions->text); + launchconditions->text = NULL; + } + /*Free Condition*/ + if (launchconditions->condition) { + condition_x *condition = launchconditions->condition; + condition_x *tmp = NULL; + while(condition != NULL) + { + tmp = condition->next; + __ps_free_condition(condition); + condition = tmp; + } + } + free((void*)launchconditions); + launchconditions = NULL; +} + +static void __ps_free_appsvc(appsvc_x *appsvc) +{ + if (appsvc == NULL) + return; + if (appsvc->text) { + free((void *)appsvc->text); + appsvc->text = NULL; + } + /*Free Operation*/ + if (appsvc->operation) { + operation_x *operation = appsvc->operation; + operation_x *tmp = NULL; + while(operation != NULL) + { + tmp = operation->next; + __ps_free_operation(operation); + operation = tmp; + } + } + /*Free Uri*/ + if (appsvc->uri) { + uri_x *uri = appsvc->uri; + uri_x *tmp = NULL; + while(uri != NULL) + { + tmp = uri->next; + __ps_free_uri(uri); + uri = tmp; + } + } + /*Free Mime*/ + if (appsvc->mime) { + mime_x *mime = appsvc->mime; + mime_x *tmp = NULL; + while(mime != NULL) + { + tmp = mime->next; + __ps_free_mime(mime); + mime = tmp; + } + } + free((void*)appsvc); + appsvc = NULL; +} + +static void __ps_free_deviceprofile(deviceprofile_x *deviceprofile) +{ + return; +} + + + +static void __ps_free_define(define_x *define) +{ + if (define == NULL) + return; + if (define->path) { + free((void *)define->path); + define->path = NULL; + } + /*Free Request*/ + if (define->request) { + request_x *request = define->request; + request_x *tmp = NULL; + while(request != NULL) + { + tmp = request->next; + __ps_free_request(request); + request = tmp; + } + } + /*Free Allowed*/ + if (define->allowed) { + allowed_x *allowed = define->allowed; + allowed_x *tmp = NULL; + while(allowed != NULL) + { + tmp = allowed->next; + __ps_free_allowed(allowed); + allowed = tmp; + } + } + free((void*)define); + define = NULL; +} + +static void __ps_free_registry(registry_x *registry) +{ + if (registry == NULL) + return; + if (registry->name) { + free((void *)registry->name); + registry->name = NULL; + } + if (registry->text) { + free((void *)registry->text); + registry->text = NULL; + } + free((void*)registry); + registry = NULL; +} + +static void __ps_free_database(database_x *database) +{ + if (database == NULL) + return; + if (database->name) { + free((void *)database->name); + database->name = NULL; + } + if (database->text) { + free((void *)database->text); + database->text = NULL; + } + free((void*)database); + database = NULL; +} + +static void __ps_free_datashare(datashare_x *datashare) +{ + if (datashare == NULL) + return; + /*Free Define*/ + if (datashare->define) { + define_x *define = datashare->define; + define_x *tmp = NULL; + while(define != NULL) + { + tmp = define->next; + __ps_free_define(define); + define = tmp; + } + } + /*Free Request*/ + if (datashare->request) { + request_x *request = datashare->request; + request_x *tmp = NULL; + while(request != NULL) + { + tmp = request->next; + __ps_free_request(request); + request = tmp; + } + } + free((void*)datashare); + datashare = NULL; +} + +static void __ps_free_layout(layout_x *layout) +{ + if (layout == NULL) + return; + if (layout->name) { + free((void *)layout->name); + layout->name = NULL; + } + if (layout->text) { + free((void *)layout->text); + layout->text = NULL; + } + free((void*)layout); + layout = NULL; +} + +static void __ps_free_control(control_x *control) +{ + if (control == NULL) + return; + /*Free Timeout*/ + if (control->timeout) { + timeout_x *timeout = control->timeout; + timeout_x *tmp = NULL; + while(timeout != NULL) + { + tmp = timeout->next; + __ps_free_timeout(timeout); + timeout = tmp; + } + } + /*Free Period*/ + if (control->period) { + period_x *period = control->period; + period_x *tmp = NULL; + while(period != NULL) + { + tmp = period->next; + __ps_free_period(period); + period = tmp; + } + } + /*Free Network*/ + if (control->network) { + network_x *network = control->network; + network_x *tmp = NULL; + while(network != NULL) + { + tmp = network->next; + __ps_free_network(network); + network = tmp; + } + } + /*Free Autolaunch*/ + if (control->autolaunch) { + autolaunch_x *autolaunch = control->autolaunch; + autolaunch_x *tmp = NULL; + while(autolaunch != NULL) + { + tmp = autolaunch->next; + __ps_free_autolaunch(autolaunch); + autolaunch = tmp; + } + } + free((void*)control); + control = NULL; +} + +static void __ps_free_pd(pd_x *pd) +{ + if (pd == NULL) + return; + if (pd->type) { + free((void *)pd->type); + pd->type = NULL; + } + if (pd->language) { + free((void *)pd->language); + pd->language = NULL; + } + /*Free File*/ + if (pd->file) { + file_x *file = pd->file; + file_x *tmp = NULL; + while(file != NULL) + { + tmp = file->next; + __ps_free_file(file); + file = tmp; + } + } + /*Free Group*/ + if (pd->grp) { + grp_x *grp = pd->grp; + grp_x *tmp = NULL; + while(grp != NULL) + { + tmp = grp->next; + __ps_free_grp(grp); + grp = tmp; + } + } + /*Free Size*/ + if (pd->size) { + size_x *size = pd->size; + size_x *tmp = NULL; + while(size != NULL) + { + tmp = size->next; + __ps_free_size(size); + size = tmp; + } + } + free((void*)pd); + pd = NULL; +} + +static void __ps_free_lbox(lbox_x *lbox) +{ + if (lbox == NULL) + return; + if (lbox->type) { + free((void*)lbox->type); + lbox->type = NULL; + } + /*Free Size*/ + if (lbox->size) { + size_x *size = lbox->size; + size_x *tmp = NULL; + while(size != NULL) + { + tmp = size->next; + __ps_free_size(size); + size = tmp; + } + } + free((void*)lbox); + lbox = NULL; +} + +static void __ps_free_content(content_x *content) +{ + if (content == NULL) + return; + /*Free Livebox*/ + if (content->lbox) { + lbox_x *lbox = content->lbox; + lbox_x *tmp = NULL; + while(lbox != NULL) + { + tmp = lbox->next; + __ps_free_lbox(lbox); + lbox = tmp; + } + } + /*Free Pd*/ + if (content->pd) { + pd_x *pd = content->pd; + pd_x *tmp = NULL; + while(pd != NULL) + { + tmp = pd->next; + __ps_free_pd(pd); + pd = tmp; + } + } + free((void*)content); + content = NULL; +} + +static void __ps_free_group(group_x *group) +{ + if (group == NULL) + return; + /*Free Cluster*/ + if (group->cluster) { + cluster_x *cluster = group->cluster; + cluster_x *tmp = NULL; + while(cluster != NULL) + { + tmp = cluster->next; + __ps_free_cluster(cluster); + cluster = tmp; + } + } + free((void*)group); + group = NULL; +} + +static void __ps_free_livebox(livebox_x *livebox) +{ + if (livebox == NULL) + return; + if (livebox->abi) { + free((void *)livebox->abi); + livebox->abi= NULL; + } + if (livebox->application) { + free((void *)livebox->application); + livebox->application = NULL; + } + if (livebox->type) { + free((void *)livebox->type); + livebox->type = NULL; + } + /*Free Icon*/ + if (livebox->icon) { + icon_x *icon = livebox->icon; + icon_x *tmp = NULL; + while(icon != NULL) + { + tmp = icon->next; + __ps_free_icon(icon); + icon = tmp; + } + } + /*Free Label*/ + if (livebox->label) { + label_x *label = livebox->label; + label_x *tmp = NULL; + while(label != NULL) + { + tmp = label->next; + __ps_free_label(label); + label = tmp; + } + } + /*Free Libexec*/ + if (livebox->libexec) { + libexec_x *libexec = livebox->libexec; + libexec_x *tmp = NULL; + while(libexec != NULL) + { + tmp = libexec->next; + __ps_free_libexec(libexec); + libexec = tmp; + } + } + /*Free Control*/ + if (livebox->control) { + control_x *control = livebox->control; + control_x *tmp = NULL; + while(control != NULL) + { + tmp = control->next; + __ps_free_control(control); + control = tmp; + } + } + /*Free Content*/ + if (livebox->content) { + content_x *content = livebox->content; + content_x *tmp = NULL; + while(content != NULL) + { + tmp = content->next; + __ps_free_content(content); + content = tmp; + } + } + /*Free Group*/ + if (livebox->group) { + group_x *group = livebox->group; + group_x *tmp = NULL; + while(group != NULL) + { + tmp = group->next; + __ps_free_group(group); + group = tmp; + } + } + /*Free Security*/ + if (livebox->security) { + security_x *security = livebox->security; + security_x *tmp = NULL; + while(security != NULL) + { + tmp = security->next; + __ps_free_security(security); + security = tmp; + } + } + /*Free Size*/ + if (livebox->size) { + size_x *size = livebox->size; + size_x *tmp = NULL; + while(size != NULL) + { + tmp = size->next; + __ps_free_size(size); + size = tmp; + } + } + free((void*)livebox); + livebox = NULL; +} + +static void __ps_free_label(label_x *label) +{ + if (label == NULL) + return; + if (label->name) { + free((void *)label->name); + label->name = NULL; + } + if (label->text) { + free((void *)label->text); + label->text = NULL; + } + if (label->lang) { + free((void *)label->lang); + label->lang= NULL; + } + free((void*)label); + label = NULL; +} + +static void __ps_free_author(author_x *author) +{ + if (author == NULL) + return; + if (author->email) { + free((void *)author->email); + author->email = NULL; + } + if (author->text) { + free((void *)author->text); + author->text = NULL; + } + if (author->href) { + free((void *)author->href); + author->href = NULL; + } + if (author->lang) { + free((void *)author->lang); + author->lang = NULL; + } + free((void*)author); + author = NULL; +} + +static void __ps_free_description(description_x *description) +{ + if (description == NULL) + return; + if (description->name) { + free((void *)description->name); + description->name = NULL; + } + if (description->text) { + free((void *)description->text); + description->text = NULL; + } + if (description->lang) { + free((void *)description->lang); + description->lang = NULL; + } + free((void*)description); + description = NULL; +} + +static void __ps_free_license(license_x *license) +{ + if (license == NULL) + return; + if (license->text) { + free((void *)license->text); + license->text = NULL; + } + if (license->lang) { + free((void *)license->lang); + license->lang = NULL; + } + free((void*)license); + license = NULL; +} + +static void __ps_free_uiapplication(uiapplication_x *uiapplication) +{ + if (uiapplication == NULL) + return; + if (uiapplication->exec) { + free((void *)uiapplication->exec); + uiapplication->exec = NULL; + } + if (uiapplication->appid) { + free((void *)uiapplication->appid); + uiapplication->appid = NULL; + } + if (uiapplication->nodisplay) { + free((void *)uiapplication->nodisplay); + uiapplication->nodisplay = NULL; + } + if (uiapplication->multiple) { + free((void *)uiapplication->multiple); + uiapplication->multiple = NULL; + } + if (uiapplication->type) { + free((void *)uiapplication->type); + uiapplication->type = NULL; + } + if (uiapplication->categories) { + free((void *)uiapplication->categories); + uiapplication->categories = NULL; + } + if (uiapplication->extraid) { + free((void *)uiapplication->extraid); + uiapplication->extraid = NULL; + } + if (uiapplication->taskmanage) { + free((void *)uiapplication->taskmanage); + uiapplication->taskmanage = NULL; + } + /*Free Label*/ + if (uiapplication->label) { + label_x *label = uiapplication->label; + label_x *tmp = NULL; + while(label != NULL) + { + tmp = label->next; + __ps_free_label(label); + label = tmp; + } + } + /*Free Icon*/ + if (uiapplication->icon) { + icon_x *icon = uiapplication->icon; + icon_x *tmp = NULL; + while(icon != NULL) + { + tmp = icon->next; + __ps_free_icon(icon); + icon = tmp; + } + } + /*Free AppControl*/ + if (uiapplication->appcontrol) { + appcontrol_x *appcontrol = uiapplication->appcontrol; + appcontrol_x *tmp = NULL; + while(appcontrol != NULL) + { + tmp = appcontrol->next; + __ps_free_appcontrol(appcontrol); + appcontrol = tmp; + } + } + /*Free LaunchConditions*/ + if (uiapplication->launchconditions) { + launchconditions_x *launchconditions = uiapplication->launchconditions; + launchconditions_x *tmp = NULL; + while(launchconditions != NULL) + { + tmp = launchconditions->next; + __ps_free_launchconditions(launchconditions); + launchconditions = tmp; + } + } + /*Free Notification*/ + if (uiapplication->notification) { + notification_x *notification = uiapplication->notification; + notification_x *tmp = NULL; + while(notification != NULL) + { + tmp = notification->next; + __ps_free_notification(notification); + notification = tmp; + } + } + /*Free DataShare*/ + if (uiapplication->datashare) { + datashare_x *datashare = uiapplication->datashare; + datashare_x *tmp = NULL; + while(datashare != NULL) + { + tmp = datashare->next; + __ps_free_datashare(datashare); + datashare = tmp; + } + } + /*Free AppSvc*/ + if (uiapplication->appsvc) { + appsvc_x *appsvc = uiapplication->appsvc; + appsvc_x *tmp = NULL; + while(appsvc != NULL) + { + tmp = appsvc->next; + __ps_free_appsvc(appsvc); + appsvc = tmp; + } + } + free((void*)uiapplication); + uiapplication = NULL; +} + +static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication) +{ + if (serviceapplication == NULL) + return; + if (serviceapplication->exec) { + free((void *)serviceapplication->exec); + serviceapplication->exec = NULL; + } + if (serviceapplication->appid) { + free((void *)serviceapplication->appid); + serviceapplication->appid = NULL; + } + if (serviceapplication->onboot) { + free((void *)serviceapplication->onboot); + serviceapplication->onboot = NULL; + } + if (serviceapplication->autorestart) { + free((void *)serviceapplication->autorestart); + serviceapplication->autorestart = NULL; + } + if (serviceapplication->type) { + free((void *)serviceapplication->type); + serviceapplication->type = NULL; + } + /*Free Label*/ + if (serviceapplication->label) { + label_x *label = serviceapplication->label; + label_x *tmp = NULL; + while(label != NULL) + { + tmp = label->next; + __ps_free_label(label); + label = tmp; + } + } + /*Free Icon*/ + if (serviceapplication->icon) { + icon_x *icon = serviceapplication->icon; + icon_x *tmp = NULL; + while(icon != NULL) + { + tmp = icon->next; + __ps_free_icon(icon); + icon = tmp; + } + } + /*Free AppControl*/ + if (serviceapplication->appcontrol) { + appcontrol_x *appcontrol = serviceapplication->appcontrol; + appcontrol_x *tmp = NULL; + while(appcontrol != NULL) + { + tmp = appcontrol->next; + __ps_free_appcontrol(appcontrol); + appcontrol = tmp; + } + } + /*Free DataControl*/ + if (serviceapplication->datacontrol) { + datacontrol_x *datacontrol = serviceapplication->datacontrol; + datacontrol_x *tmp = NULL; + while(datacontrol != NULL) + { + tmp = datacontrol->next; + __ps_free_datacontrol(datacontrol); + datacontrol = tmp; + } + } + /*Free LaunchConditions*/ + if (serviceapplication->launchconditions) { + launchconditions_x *launchconditions = serviceapplication->launchconditions; + launchconditions_x *tmp = NULL; + while(launchconditions != NULL) + { + tmp = launchconditions->next; + __ps_free_launchconditions(launchconditions); + launchconditions = tmp; + } + } + /*Free Notification*/ + if (serviceapplication->notification) { + notification_x *notification = serviceapplication->notification; + notification_x *tmp = NULL; + while(notification != NULL) + { + tmp = notification->next; + __ps_free_notification(notification); + notification = tmp; + } + } + /*Free DataShare*/ + if (serviceapplication->datashare) { + datashare_x *datashare = serviceapplication->datashare; + datashare_x *tmp = NULL; + while(datashare != NULL) + { + tmp = datashare->next; + __ps_free_datashare(datashare); + datashare = tmp; + } + } + /*Free AppSvc*/ + if (serviceapplication->appsvc) { + appsvc_x *appsvc = serviceapplication->appsvc; + appsvc_x *tmp = NULL; + while(appsvc != NULL) + { + tmp = appsvc->next; + __ps_free_appsvc(appsvc); + appsvc = tmp; + } + } + free((void*)serviceapplication); + serviceapplication = NULL; +} + +static void __ps_free_font(font_x *font) +{ + if (font == NULL) + return; + if (font->name) { + free((void *)font->name); + font->name = NULL; + } + if (font->text) { + free((void *)font->text); + font->text = NULL; + } + free((void*)font); + font = NULL; +} + +static void __ps_free_theme(theme_x *theme) +{ + if (theme == NULL) + return; + if (theme->name) { + free((void *)theme->name); + theme->name = NULL; + } + if (theme->text) { + free((void *)theme->text); + theme->text = NULL; + } + free((void*)theme); + theme = NULL; +} + +static void __ps_free_daemon(daemon_x *daemon) +{ + if (daemon == NULL) + return; + if (daemon->name) { + free((void *)daemon->name); + daemon->name = NULL; + } + if (daemon->text) { + free((void *)daemon->text); + daemon->text = NULL; + } + free((void*)daemon); + daemon = NULL; +} + +static void __ps_free_ime(ime_x *ime) +{ + if (ime == NULL) + return; + if (ime->name) { + free((void *)ime->name); + ime->name = NULL; + } + if (ime->text) { + free((void *)ime->text); + ime->text = NULL; + } + free((void*)ime); + ime = NULL; +} + + +static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed) +{ + xmlTextReaderRead(reader); + if (xmlTextReaderValue(reader)) + allowed->text = ASCII(xmlTextReaderValue(reader)); + return 0; +} + +static int __ps_process_timeout(xmlTextReaderPtr reader, timeout_x *timeout) +{ + xmlTextReaderRead(reader); + if (xmlTextReaderValue(reader)) + timeout->text = ASCII(xmlTextReaderValue(reader)); + return 0; +} + +static int __ps_process_network(xmlTextReaderPtr reader, network_x *network) +{ + xmlTextReaderRead(reader); + if (xmlTextReaderValue(reader)) + network->text = ASCII(xmlTextReaderValue(reader)); + return 0; +} + +static int __ps_process_period(xmlTextReaderPtr reader, period_x *period) +{ + xmlTextReaderRead(reader); + if (xmlTextReaderValue(reader)) + period->text = ASCII(xmlTextReaderValue(reader)); + return 0; +} + +static int __ps_process_autolaunch(xmlTextReaderPtr reader, autolaunch_x *autolaunch) +{ + xmlTextReaderRead(reader); + if (xmlTextReaderValue(reader)) + autolaunch->text = ASCII(xmlTextReaderValue(reader)); + return 0; +} + +static int __ps_process_file(xmlTextReaderPtr reader, file_x *file) +{ + xmlTextReaderRead(reader); + if (xmlTextReaderValue(reader)) + file->text = ASCII(xmlTextReaderValue(reader)); + return 0; +} + +static int __ps_process_size(xmlTextReaderPtr reader, size_x *size) +{ + xmlTextReaderRead(reader); + if (xmlTextReaderValue(reader)) + size->text = ASCII(xmlTextReaderValue(reader)); + return 0; +} + +static int __ps_process_grp(xmlTextReaderPtr reader, grp_x *grp) +{ + xmlTextReaderRead(reader); + if (xmlTextReaderValue(reader)) + grp->text = ASCII(xmlTextReaderValue(reader)); + return 0; +} + +static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation) +{ + if (xmlTextReaderGetAttribute(reader, XMLCHAR("name"))) + operation->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name"))); + xmlTextReaderRead(reader); + if (xmlTextReaderValue(reader)) + operation->text = ASCII(xmlTextReaderValue(reader)); + return 0; +} + +static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri) +{ + if (xmlTextReaderGetAttribute(reader, XMLCHAR("name"))) + uri->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name"))); + xmlTextReaderRead(reader); + if (xmlTextReaderValue(reader)) + uri->text = ASCII(xmlTextReaderValue(reader)); + return 0; +} + +static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime) +{ + if (xmlTextReaderGetAttribute(reader, XMLCHAR("name"))) + mime->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name"))); + xmlTextReaderRead(reader); + if (xmlTextReaderValue(reader)) + mime->text = ASCII(xmlTextReaderValue(reader)); + return 0; +} + +static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition) +{ + if (xmlTextReaderGetAttribute(reader, XMLCHAR("name"))) + condition->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name"))); + xmlTextReaderRead(reader); + if (xmlTextReaderValue(reader)) + condition->text = ASCII(xmlTextReaderValue(reader)); + return 0; +} + +static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notification) +{ + if (xmlTextReaderGetAttribute(reader, XMLCHAR("name"))) + notification->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name"))); + xmlTextReaderRead(reader); + if (xmlTextReaderValue(reader)) + notification->text = ASCII(xmlTextReaderValue(reader)); + return 0; +} + +static int __ps_process_category(xmlTextReaderPtr reader, category_x *category) +{ + if (xmlTextReaderGetAttribute(reader, XMLCHAR("name"))) + category->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name"))); + return 0; +} + +static int __ps_process_security(xmlTextReaderPtr reader, security_x *security) +{ + if (xmlTextReaderGetAttribute(reader, XMLCHAR("isolate"))) + security->isolate = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("isolate"))); + return 0; +} + +static int __ps_process_libexec(xmlTextReaderPtr reader, libexec_x *libexec) +{ + xmlTextReaderRead(reader); + if (xmlTextReaderValue(reader)) + libexec->text = ASCII(xmlTextReaderValue(reader)); + return 0; +} + +static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility) +{ + if (xmlTextReaderGetAttribute(reader, XMLCHAR("name"))) + compatibility->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name"))); + xmlTextReaderRead(reader); + if (xmlTextReaderValue(reader)) + compatibility->text = ASCII(xmlTextReaderValue(reader)); + return 0; +} + +static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution) +{ + if (xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type"))) + resolution->mimetype = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type"))); + if (xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme"))) + resolution->urischeme = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme"))); + return 0; +} + +static int __ps_process_request(xmlTextReaderPtr reader, request_x *request) +{ + xmlTextReaderRead(reader); + if (xmlTextReaderValue(reader)) + request->text = ASCII(xmlTextReaderValue(reader)); + return 0; +} + +static int __ps_process_define(xmlTextReaderPtr reader, define_x *define) +{ + const xmlChar *node; + int ret = -1; + int depth = -1; + allowed_x *tmp1 = NULL; + request_x *tmp2 = NULL; + + if (xmlTextReaderGetAttribute(reader, XMLCHAR("path"))) + define->path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("path"))); + + depth = xmlTextReaderDepth(reader); + while ((ret = __next_child_element(reader, depth))) { + node = xmlTextReaderConstName(reader); + if (!node) { + DBG("xmlTextReaderConstName value is NULL\n"); + return -1; + } + + if (!strcmp(ASCII(node), "allowed")) { + allowed_x *allowed= malloc(sizeof(allowed_x)); + if (allowed == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(allowed, '\0', sizeof(allowed_x)); + if (allowed) { + LISTADD(define->allowed, allowed); + ret = + __ps_process_allowed(reader, allowed); + } else + return -1; + } else if (!strcmp(ASCII(node), "request")) { + request_x *request = malloc(sizeof(request_x)); + if (request == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(request, '\0', sizeof(request_x)); + if (request) { + LISTADD(define->request, request); + ret = + __ps_process_request(reader, request); + } else + return -1; + } else + return -1; + if (ret < 0) { + DBG("Processing define failed\n"); + return ret; + } + } + if (define->allowed) { + LISTHEAD(define->allowed, tmp1); + define->allowed = tmp1; + } + if (define->request) { + LISTHEAD(define->request, tmp2); + define->request = tmp2; + } + return ret; +} + +static int __ps_process_registry(xmlTextReaderPtr reader, registry_x *registry) +{ + /*TODO: once policy is set*/ + return 0; +} + +static int __ps_process_database(xmlTextReaderPtr reader, database_x *database) +{ + /*TODO: once policy is set*/ + return 0; +} + +static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc) +{ + const xmlChar *node; + int ret = -1; + int depth = -1; + operation_x *tmp1 = NULL; + uri_x *tmp2 = NULL; + mime_x *tmp3 = NULL; + + depth = xmlTextReaderDepth(reader); + while ((ret = __next_child_element(reader, depth))) { + node = xmlTextReaderConstName(reader); + if (!node) { + DBG("xmlTextReaderConstName value is NULL\n"); + return -1; + } + + if (!strcmp(ASCII(node), "operation")) { + operation_x *operation = malloc(sizeof(operation_x)); + if (operation == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(operation, '\0', sizeof(operation_x)); + if (operation) { + LISTADD(appsvc->operation, operation); + ret = + __ps_process_operation(reader, operation); + + DBG("operation processing\n"); + } else + return -1; + } else if (!strcmp(ASCII(node), "uri")) { + uri_x *uri= malloc(sizeof(uri_x)); + if (uri == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(uri, '\0', sizeof(uri_x)); + if (uri) { + LISTADD(appsvc->uri, uri); + ret = + __ps_process_uri(reader, uri); + + DBG("uri processing\n"); + } else + return -1; + } else if (!strcmp(ASCII(node), "mime")) { + mime_x *mime = malloc(sizeof(mime_x)); + if (mime == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(mime, '\0', sizeof(mime_x)); + if (mime) { + LISTADD(appsvc->mime, mime); + ret = + __ps_process_mime(reader, mime); + + DBG("mime processing\n"); + } else + return -1; + } else + return -1; + if (ret < 0) { + DBG("Processing appsvc failed\n"); + return ret; + } + } + if (appsvc->operation) { + LISTHEAD(appsvc->operation, tmp1); + appsvc->operation = tmp1; + } + if (appsvc->uri) { + LISTHEAD(appsvc->uri, tmp2); + appsvc->uri = tmp2; + } + if (appsvc->mime) { + LISTHEAD(appsvc->mime, tmp3); + appsvc->mime = tmp3; + } + + xmlTextReaderRead(reader); + if (xmlTextReaderValue(reader)) + appsvc->text = ASCII(xmlTextReaderValue(reader)); + + return ret; +} + +static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions) +{ + const xmlChar *node; + int ret = -1; + int depth = -1; + condition_x *tmp1 = NULL; + + depth = xmlTextReaderDepth(reader); + while ((ret = __next_child_element(reader, depth))) { + node = xmlTextReaderConstName(reader); + if (!node) { + DBG("xmlTextReaderConstName value is NULL\n"); + return -1; + } + + if (strcmp(ASCII(node), "condition") == 0) { + condition_x *condition = malloc(sizeof(condition_x)); + if (condition == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(condition, '\0', sizeof(condition_x)); + if (condition) { + LISTADD(launchconditions->condition, condition); + ret = + __ps_process_condition(reader, condition); + } else + return -1; + } else + return -1; + if (ret < 0) { + DBG("Processing launchconditions failed\n"); + return ret; + } + } + if (launchconditions->condition) { + LISTHEAD(launchconditions->condition, tmp1); + launchconditions->condition = tmp1; + } + + xmlTextReaderRead(reader); + if (xmlTextReaderValue(reader)) + launchconditions->text = ASCII(xmlTextReaderValue(reader)); + + return ret; +} + +static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare) +{ + const xmlChar *node; + int ret = -1; + int depth = -1; + define_x *tmp1 = NULL; + request_x *tmp2 = NULL; + depth = xmlTextReaderDepth(reader); + while ((ret = __next_child_element(reader, depth))) { + node = xmlTextReaderConstName(reader); + if (!node) { + DBG("xmlTextReaderConstName value is NULL\n"); + return -1; + } + + if (!strcmp(ASCII(node), "define")) { + define_x *define= malloc(sizeof(define_x)); + if (define == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(define, '\0', sizeof(define_x)); + if (define) { + LISTADD(datashare->define, define); + ret = + __ps_process_define(reader, define); + } else + return -1; + } else if (!strcmp(ASCII(node), "request")) { + request_x *request= malloc(sizeof(request_x)); + if (request == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(request, '\0', sizeof(request_x)); + if (request) { + LISTADD(datashare->request, request); + ret = + __ps_process_request(reader, request); + } else + return -1; + } else + return -1; + if (ret < 0) { + DBG("Processing data-share failed\n"); + return ret; + } + } + if (datashare->define) { + LISTHEAD(datashare->define, tmp1); + datashare->define = tmp1; + } + if (datashare->request) { + LISTHEAD(datashare->request, tmp2); + datashare->request = tmp2; + } + return ret; +} + +static int __ps_process_layout(xmlTextReaderPtr reader, layout_x *layout) +{ + /*TODO: once policy is set*/ + return 0; +} + +static int __ps_process_cluster(xmlTextReaderPtr reader, cluster_x *cluster) +{ + const xmlChar *node; + int ret = -1; + int depth = -1; + category_x *tmp1 = NULL; + + if (xmlTextReaderGetAttribute(reader, XMLCHAR("name"))) + cluster->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name"))); + + depth = xmlTextReaderDepth(reader); + while ((ret = __next_child_element(reader, depth))) { + node = xmlTextReaderConstName(reader); + if (!node) { + DBG("xmlTextReaderConstName value is NULL\n"); + return -1; + } + + if (!strcmp(ASCII(node), "category")) { + category_x *category = malloc(sizeof(category_x)); + if (category == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(category, '\0', sizeof(category_x)); + if (category) { + LISTADD(cluster->category, category); + ret = + __ps_process_category(reader, category); + } else + return -1; + } else + return -1; + if (ret < 0) { + DBG("Processing category failed\n"); + return ret; + } + } + if (cluster->category) { + LISTHEAD(cluster->category, tmp1); + cluster->category = tmp1; + } + + return ret; +} + +static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon) +{ + if (xmlTextReaderGetAttribute(reader, XMLCHAR("name"))) + icon->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name"))); + if (xmlTextReaderConstXmlLang(reader)) { + icon->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader))); + if (icon->lang == NULL) + icon->lang = strdup(DEFAULT_LOCALE); + } else { + icon->lang = strdup(DEFAULT_LOCALE); + } + if (xmlTextReaderGetAttribute(reader, XMLCHAR("section"))) + icon->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section"))); + if (xmlTextReaderGetAttribute(reader, XMLCHAR("size"))) + icon->size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size"))); + xmlTextReaderRead(reader); + if (xmlTextReaderValue(reader)) + icon->text = ASCII(xmlTextReaderValue(reader)); + + return 0; +} + +static int __ps_process_lbox(xmlTextReaderPtr reader, lbox_x *lbox) +{ + const xmlChar *node; + int ret = -1; + int depth = -1; + size_x *tmp1 = NULL; + if (xmlTextReaderGetAttribute(reader, XMLCHAR("type"))) + lbox->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type"))); + + depth = xmlTextReaderDepth(reader); + while ((ret = __next_child_element(reader, depth))) { + node = xmlTextReaderConstName(reader); + if (!node) { + DBG("xmlTextReaderConstName value is NULL\n"); + return -1; + } + if (!strcmp(ASCII(node), "size")) { + size_x *size= malloc(sizeof(size_x)); + if (size == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(size, '\0', sizeof(size_x)); + if (size) { + LISTADD(lbox->size, size); + ret = + __ps_process_size(reader, size); + } else + return -1; + } else + return -1; + if (ret < 0) { + DBG("Processing lbox failed\n"); + return ret; + } + } + + if (lbox->size) { + LISTHEAD(lbox->size, tmp1); + lbox->size = tmp1; + } + + return ret; +} + +static int __ps_process_pd(xmlTextReaderPtr reader, pd_x *pd) +{ + const xmlChar *node; + int ret = -1; + int depth = -1; + file_x *tmp1 = NULL; + grp_x *tmp2 = NULL; + size_x *tmp3 = NULL; + + if (xmlTextReaderGetAttribute(reader, XMLCHAR("type"))) + pd->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type"))); + if (xmlTextReaderGetAttribute(reader, XMLCHAR("language"))) + pd->language = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("language"))); + + depth = xmlTextReaderDepth(reader); + while ((ret = __next_child_element(reader, depth))) { + node = xmlTextReaderConstName(reader); + if (!node) { + DBG("xmlTextReaderConstName value is NULL\n"); + return -1; + } + if (!strcmp(ASCII(node), "file")) { + file_x *file = malloc(sizeof(file_x)); + if (file == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(file, '\0', sizeof(file_x)); + if (file) { + LISTADD(pd->file, file); + ret = + __ps_process_file(reader, file); + } else + return -1; + } else if (!strcmp(ASCII(node), "group")) { + grp_x *grp = malloc(sizeof(grp_x)); + if (grp == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(grp, '\0', sizeof(grp_x)); + if (grp) { + LISTADD(pd->grp, grp); + ret = + __ps_process_grp(reader, grp); + } else + return -1; + } else if (!strcmp(ASCII(node), "size")) { + size_x *size = malloc(sizeof(size_x)); + if (size == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(size, '\0', sizeof(size_x)); + if (size) { + LISTADD(pd->size, size); + ret = + __ps_process_size(reader, size); + } else + return -1; + } else + return -1; + if (ret < 0) { + DBG("Processing pd failed\n"); + return ret; + } + } + + if (pd->file) { + LISTHEAD(pd->file, tmp1); + pd->file = tmp1; + } + if (pd->grp) { + LISTHEAD(pd->grp, tmp2); + pd->grp = tmp2; + } + if (pd->size) { + LISTHEAD(pd->size , tmp3); + pd->size = tmp3; + } + + return ret; +} + +static int __ps_process_content(xmlTextReaderPtr reader, content_x *content) +{ + DBG("CONTENT\n"); + const xmlChar *node; + int ret = -1; + int depth = -1; + lbox_x *tmp1 = NULL; + pd_x *tmp2 = NULL; + + depth = xmlTextReaderDepth(reader); + while ((ret = __next_child_element(reader, depth))) { + node = xmlTextReaderConstName(reader); + if (!node) { + DBG("xmlTextReaderConstName value is NULL\n"); + return -1; + } + + if (!strcmp(ASCII(node), "livebox")) { + lbox_x *lbox = malloc(sizeof(lbox_x)); + if (lbox == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(lbox, '\0', sizeof(lbox_x)); + if (lbox) { + LISTADD(content->lbox, lbox); + ret = + __ps_process_lbox(reader, lbox); + } else + return -1; + } else if (!strcmp(ASCII(node), "pd")) { + pd_x *pd = malloc(sizeof(pd_x)); + if (pd == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(pd, '\0', sizeof(pd_x)); + if (pd) { + LISTADD(content->pd, pd); + ret = + __ps_process_pd(reader, pd); + } else + return -1; + } else + return -1; + if (ret < 0) { + DBG("Processing content failed\n"); + return ret; + } + } + + if (content->lbox) { + LISTHEAD(content->lbox, tmp1); + content->lbox = tmp1; + } + if (content->pd) { + LISTHEAD(content->pd, tmp2); + content->pd = tmp2; + } + + return ret; + +} + +static int __ps_process_control(xmlTextReaderPtr reader, control_x *control) +{ + const xmlChar *node; + int ret = -1; + int depth = -1; + timeout_x *tmp1 = NULL; + network_x *tmp2 = NULL; + period_x *tmp3 = NULL; + autolaunch_x *tmp4 = NULL; + + depth = xmlTextReaderDepth(reader); + while ((ret = __next_child_element(reader, depth))) { + node = xmlTextReaderConstName(reader); + if (!node) { + DBG("xmlTextReaderConstName value is NULL\n"); + return -1; + } + + if (!strcmp(ASCII(node), "timeout")) { + timeout_x *timeout = malloc(sizeof(timeout_x)); + if (timeout == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(timeout, '\0', sizeof(timeout_x)); + if (timeout) { + LISTADD(control->timeout, timeout); + ret = + __ps_process_timeout(reader, timeout); + } else + return -1; + } else if (!strcmp(ASCII(node), "network")) { + network_x *network = malloc(sizeof(network_x)); + if (network == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(network, '\0', sizeof(network_x)); + if (network) { + LISTADD(control->network, network); + ret = + __ps_process_network(reader, network); + } else + return -1; + } else if (!strcmp(ASCII(node), "period")) { + period_x *period = malloc(sizeof(period_x)); + if (period == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(period, '\0', sizeof(period_x)); + if (period) { + LISTADD(control->period, period); + ret = + __ps_process_period(reader, period); + } else + return -1; + } else if (!strcmp(ASCII(node), "autolaunch")) { + autolaunch_x *autolaunch = malloc(sizeof(autolaunch_x)); + if (autolaunch == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(autolaunch, '\0', sizeof(autolaunch_x)); + if (autolaunch) { + LISTADD(control->autolaunch, autolaunch); + ret = + __ps_process_autolaunch(reader, autolaunch); + } else + return -1; + } else + return -1; + if (ret < 0) { + DBG("Processing control failed\n"); + return ret; + } + } + + if (control->timeout) { + LISTHEAD(control->timeout, tmp1); + control->timeout = tmp1; + } + if (control->network) { + LISTHEAD(control->network, tmp2); + control->network = tmp2; + } + if (control->period) { + LISTHEAD(control->period, tmp3); + control->period = tmp3; + } + if (control->autolaunch) { + LISTHEAD(control->autolaunch, tmp4); + control->autolaunch = tmp4; + } + + return ret; +} + +static int __ps_process_group(xmlTextReaderPtr reader, group_x *group) +{ + const xmlChar *node; + int ret = -1; + int depth = -1; + cluster_x *tmp1 = NULL; + depth = xmlTextReaderDepth(reader); + while ((ret = __next_child_element(reader, depth))) { + node = xmlTextReaderConstName(reader); + if (!node) { + DBG("xmlTextReaderConstName value is NULL\n"); + return -1; + } + + if (!strcmp(ASCII(node), "cluster")) { + cluster_x *cluster = malloc(sizeof(cluster_x)); + if (cluster == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(cluster, '\0', sizeof(cluster_x)); + if (cluster) { + LISTADD(group->cluster, cluster); + ret = + __ps_process_cluster(reader, cluster); + } else + return -1; + } else + return -1; + if (ret < 0) { + DBG("Processing group failed\n"); + return ret; + } + } + + if (group->cluster) { + LISTHEAD(group->cluster, tmp1); + group->cluster = tmp1; + } + + return ret; +} + +static int __ps_process_livebox(xmlTextReaderPtr reader, livebox_x *livebox) +{ + const xmlChar *node; + int ret = -1; + int depth = -1; + icon_x *tmp1 = NULL; + label_x *tmp2 = NULL; + libexec_x *tmp3 = NULL; + control_x *tmp4 = NULL; + content_x *tmp5 = NULL; + group_x *tmp6 = NULL; + security_x *tmp7 = NULL; + size_x *tmp8 = NULL; + if (xmlTextReaderGetAttribute(reader, XMLCHAR("application"))) + livebox->application = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("application"))); + if (xmlTextReaderGetAttribute(reader, XMLCHAR("abi"))) + livebox->abi = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("abi"))); + if (xmlTextReaderGetAttribute(reader, XMLCHAR("type"))) + livebox->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type"))); + + depth = xmlTextReaderDepth(reader); + while ((ret = __next_child_element(reader, depth))) { + node = xmlTextReaderConstName(reader); + if (!node) { + DBG("xmlTextReaderConstName value is NULL\n"); + return -1; + } + + if (!strcmp(ASCII(node), "label")) { + label_x *label = malloc(sizeof(label_x)); + if (label == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(label, '\0', sizeof(label_x)); + if (label) { + LISTADD(livebox->label, label); + ret = + __ps_process_label(reader, label); + } else + return -1; + } else if (!strcmp(ASCII(node), "icon")) { + icon_x *icon = malloc(sizeof(icon_x)); + if (icon == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(icon, '\0', sizeof(icon_x)); + if (icon) { + LISTADD(livebox->icon, icon); + ret = + __ps_process_icon(reader, icon); + } else + return -1; + } else if (!strcmp(ASCII(node), "libexec")) { + libexec_x *libexec = malloc(sizeof(libexec_x)); + if (libexec == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(libexec, '\0', sizeof(libexec_x)); + if (libexec) { + LISTADD(livebox->libexec, libexec); + ret = + __ps_process_libexec(reader, libexec); + } else + return -1; + }else if (!strcmp(ASCII(node), "control")) { + control_x *control = malloc(sizeof(control_x)); + if (control == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(control, '\0', sizeof(control_x)); + if (control) { + LISTADD(livebox->control, control); + ret = + __ps_process_control(reader, control); + } else + return -1; + } else if (!strcmp(ASCII(node), "content")) { + content_x *content= malloc(sizeof(content_x)); + if (content == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(content, '\0', sizeof(content_x)); + if (content) { + LISTADD(livebox->content, content); + ret = + __ps_process_content(reader, content); + } else + return -1; + } else if (!strcmp(ASCII(node), "group")) { + group_x *group= malloc(sizeof(group_x)); + if (group == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(group, '\0', sizeof(group_x)); + if (group) { + LISTADD(livebox->group, group); + ret = + __ps_process_group(reader, group); + } else + return -1; + } else if (!strcmp(ASCII(node), "security")) { + security_x *security= malloc(sizeof(security_x)); + if (security == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(security, '\0', sizeof(security_x)); + if (security) { + LISTADD(livebox->security, security); + ret = + __ps_process_security(reader, security); + } else + return -1; + } else if (!strcmp(ASCII(node), "size")) { + size_x *size= malloc(sizeof(size_x)); + if (size == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(size, '\0', sizeof(size_x)); + if (size) { + LISTADD(livebox->size, size); + ret = + __ps_process_size(reader, size); + } else + return -1; + } else + return -1; + if (ret < 0) { + DBG("Processing livebox failed\n"); + return ret; + } + } + + if (livebox->icon) { + LISTHEAD(livebox->icon, tmp1); + livebox->icon = tmp1; + } + if (livebox->label) { + LISTHEAD(livebox->label, tmp2); + livebox->label = tmp2; + } + if (livebox->libexec) { + LISTHEAD(livebox->libexec, tmp3); + livebox->libexec = tmp3; + } + if (livebox->control) { + LISTHEAD(livebox->control, tmp4); + livebox->control = tmp4; + } + if (livebox->content) { + LISTHEAD(livebox->content, tmp5); + livebox->content = tmp5; + } + if (livebox->group) { + LISTHEAD(livebox->group, tmp6); + livebox->group = tmp6; + } + if (livebox->security) { + LISTHEAD(livebox->security, tmp7); + livebox->security = tmp7; + } + if (livebox->size) { + LISTHEAD(livebox->size, tmp8); + livebox->size = tmp8; + } + + return ret; +} + +static int __ps_process_label(xmlTextReaderPtr reader, label_x *label) +{ + if (xmlTextReaderGetAttribute(reader, XMLCHAR("name"))) + label->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name"))); + if (xmlTextReaderConstXmlLang(reader)) { + label->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader))); + if (label->lang == NULL) + label->lang = strdup(DEFAULT_LOCALE); + } else { + label->lang = strdup(DEFAULT_LOCALE); + } + xmlTextReaderRead(reader); + if (xmlTextReaderValue(reader)) + label->text = ASCII(xmlTextReaderValue(reader)); + +/* DBG("lable name %s\n", label->name); + DBG("lable lang %s\n", label->lang); + DBG("lable text %s\n", label->text); +*/ + return 0; + +} + +static int __ps_process_author(xmlTextReaderPtr reader, author_x *author) +{ + if (xmlTextReaderGetAttribute(reader, XMLCHAR("email"))) + author->email = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("email"))); + if (xmlTextReaderGetAttribute(reader, XMLCHAR("href"))) + author->href = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("href"))); + if (xmlTextReaderConstXmlLang(reader)) { + author->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader))); + if (author->lang == NULL) + author->lang = strdup(DEFAULT_LOCALE); + } else { + author->lang = strdup(DEFAULT_LOCALE); + } + xmlTextReaderRead(reader); + if (xmlTextReaderValue(reader)) + author->text = ASCII(xmlTextReaderValue(reader)); + return 0; +} + +static int __ps_process_description(xmlTextReaderPtr reader, description_x *description) +{ + if (xmlTextReaderConstXmlLang(reader)) { + description->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader))); + if (description->lang == NULL) + description->lang = strdup(DEFAULT_LOCALE); + } else { + description->lang = strdup(DEFAULT_LOCALE); + } + xmlTextReaderRead(reader); + if (xmlTextReaderValue(reader)) + description->text = ASCII(xmlTextReaderValue(reader)); + return 0; +} + +static int __ps_process_license(xmlTextReaderPtr reader, license_x *license) +{ + if (xmlTextReaderConstXmlLang(reader)) { + license->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader))); + if (license->lang == NULL) + license->lang = strdup(DEFAULT_LOCALE); + } else { + license->lang = strdup(DEFAULT_LOCALE); + } + xmlTextReaderRead(reader); + if (xmlTextReaderValue(reader)) + license->text = ASCII(xmlTextReaderValue(reader)); + return 0; +} + +static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability) +{ + const xmlChar *node; + int ret = -1; + int depth = -1; + resolution_x *tmp1 = NULL; + + if (xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id"))) + capability->operationid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id"))); + + depth = xmlTextReaderDepth(reader); + while ((ret = __next_child_element(reader, depth))) { + node = xmlTextReaderConstName(reader); + if (!node) { + DBG("xmlTextReaderConstName value is NULL\n"); + return -1; + } + + if (!strcmp(ASCII(node), "resolution")) { + resolution_x *resolution = malloc(sizeof(resolution_x)); + if (resolution == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(resolution, '\0', sizeof(resolution_x)); + if (resolution) { + LISTADD(capability->resolution, resolution); + ret = + __ps_process_resolution(reader, resolution); + } else + return -1; + } else + return -1; + if (ret < 0) { + DBG("Processing capability failed\n"); + return ret; + } + } + + if (capability->resolution) { + LISTHEAD(capability->resolution, tmp1); + capability->resolution = tmp1; + } + + return ret; +} + +static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol) +{ + const xmlChar *node; + int ret = -1; + int depth = -1; + capability_x *tmp1 = NULL; + + if (xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id"))) + appcontrol->providerid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id"))); + if (xmlTextReaderGetAttribute(reader, XMLCHAR("category"))) + appcontrol->category = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("category"))); + + depth = xmlTextReaderDepth(reader); + while ((ret = __next_child_element(reader, depth))) { + node = xmlTextReaderConstName(reader); + if (!node) { + DBG("xmlTextReaderConstName value is NULL\n"); + return -1; + } + + if (!strcmp(ASCII(node), "capability")) { + capability_x *capability = malloc(sizeof(capability_x)); + if (capability == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(capability, '\0', sizeof(capability_x)); + if (capability) { + LISTADD(appcontrol->capability, capability); + ret = + __ps_process_capability(reader, capability); + } else + return -1; + } else + return -1; + if (ret < 0) { + DBG("Processing appcontrol failed\n"); + return ret; + } + } + + if (appcontrol->capability) { + LISTHEAD(appcontrol->capability, tmp1); + appcontrol->capability = tmp1; + } + + return ret; +} + +static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol) +{ + const xmlChar *node; + int ret = -1; + int depth = -1; + capability_x *tmp1 = NULL; + + if (xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id"))) + datacontrol->providerid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id"))); + + depth = xmlTextReaderDepth(reader); + while ((ret = __next_child_element(reader, depth))) { + node = xmlTextReaderConstName(reader); + if (!node) { + DBG("xmlTextReaderConstName value is NULL\n"); + return -1; + } + + if (!strcmp(ASCII(node), "capability")) { + capability_x *capability = malloc(sizeof(capability_x)); + if (capability == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(capability, '\0', sizeof(capability_x)); + if (capability) { + LISTADD(datacontrol->capability, capability); + ret = + __ps_process_capability(reader, capability); + } else + return -1; + } else + return -1; + if (ret < 0) { + DBG("Processing datacontrol failed\n"); + return ret; + } + } + + if (datacontrol->capability) { + LISTHEAD(datacontrol->capability, tmp1); + datacontrol->capability = tmp1; + } + + return ret; +} + +static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication) +{ + const xmlChar *node; + int ret = -1; + int depth = -1; + char *newappid = NULL; + label_x *tmp1 = NULL; + icon_x *tmp2 = NULL; + appsvc_x *tmp3 = NULL; + appcontrol_x *tmp4 = NULL; + launchconditions_x *tmp5 = NULL; + notification_x *tmp6 = NULL; + datashare_x *tmp7 = NULL; + + if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) { + uiapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))); + if (uiapplication->appid == NULL) { + DBG("appid cant be NULL\n"); + return -1; + } + } else { + DBG("appid is mandatory\n"); + return -1; + } + /*check appid*/ + ret = __validate_appid(package, uiapplication->appid, &newappid); + if (ret == -1) { + DBG("appid is not proper\n"); + return -1; + } else { + if (newappid) { + if (uiapplication->appid) + free((void *)uiapplication->appid); + uiapplication->appid = newappid; + } + } + if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec"))) + uiapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec"))); + if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay"))) { + uiapplication->nodisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay"))); + if (uiapplication->nodisplay == NULL) + uiapplication->nodisplay = strdup("false"); + } else { + uiapplication->nodisplay = strdup("false"); + } + if (xmlTextReaderGetAttribute(reader, XMLCHAR("multiple"))) { + uiapplication->multiple = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("multiple"))); + if (uiapplication->multiple == NULL) + uiapplication->multiple = strdup("false"); + } else { + uiapplication->multiple = strdup("false"); + } + if (xmlTextReaderGetAttribute(reader, XMLCHAR("type"))) + uiapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type"))); + if (xmlTextReaderGetAttribute(reader, XMLCHAR("categories"))) + uiapplication->categories = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("categories"))); + if (xmlTextReaderGetAttribute(reader, XMLCHAR("extraid"))) + uiapplication->extraid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("extraid"))); + if (xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage"))) { + uiapplication->taskmanage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage"))); + if (uiapplication->taskmanage == NULL) + uiapplication->taskmanage = strdup("true"); + } else { + uiapplication->taskmanage = strdup("true"); + } + + depth = xmlTextReaderDepth(reader); + while ((ret = __next_child_element(reader, depth))) { + node = xmlTextReaderConstName(reader); + if (!node) { + DBG("xmlTextReaderConstName value is NULL\n"); + return -1; + } + if (!strcmp(ASCII(node), "label")) { + label_x *label = malloc(sizeof(label_x)); + if (label == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(label, '\0', sizeof(label_x)); + if (label) { + LISTADD(uiapplication->label, label); + ret = + __ps_process_label(reader, label); + + DBG("label processing\n"); + } else + return -1; + } else if (!strcmp(ASCII(node), "icon")) { + icon_x *icon = malloc(sizeof(icon_x)); + if (icon == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(icon, '\0', sizeof(icon_x)); + if (icon) { + LISTADD(uiapplication->icon, icon); + ret = + __ps_process_icon(reader, icon); + } else + return -1; + } else if (!strcmp(ASCII(node), "app-control")) { + appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x)); + if (appcontrol == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(appcontrol, '\0', sizeof(appcontrol_x)); + if (appcontrol) { + LISTADD(uiapplication->appcontrol, appcontrol); + ret = + __ps_process_appcontrol(reader, appcontrol); + } else + return -1; + } else if (!strcmp(ASCII(node), "application-service")) { + DBG("appsvc processing start\n"); + + appsvc_x *appsvc = malloc(sizeof(appsvc_x)); + if (appsvc == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(appsvc, '\0', sizeof(appsvc_x)); + if (appsvc) { + LISTADD(uiapplication->appsvc, appsvc); + ret = + __ps_process_appsvc(reader, appsvc); + + DBG("appsvc processing end\n"); + } else + return -1; + } else if (!strcmp(ASCII(node), "data-share")) { + datashare_x *datashare = malloc(sizeof(datashare_x)); + if (datashare == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(datashare, '\0', sizeof(datashare_x)); + if (datashare) { + LISTADD(uiapplication->datashare, datashare); + ret = + __ps_process_datashare(reader, datashare); + } else + return -1; + } else if (!strcmp(ASCII(node), "launch-conditions")) { + launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x)); + if (launchconditions == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(launchconditions, '\0', sizeof(launchconditions_x)); + if (launchconditions) { + LISTADD(uiapplication->launchconditions, launchconditions); + ret = + __ps_process_launchconditions(reader, launchconditions); + } else + return -1; + } else if (!strcmp(ASCII(node), "notification")) { + notification_x *notification = malloc(sizeof(notification_x)); + if (notification == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(notification, '\0', sizeof(notification_x)); + if (notification) { + LISTADD(uiapplication->notification, notification); + ret = + __ps_process_notification(reader, notification); + } else + return -1; + } else + return -1; + if (ret < 0) { + DBG("Processing uiapplication failed\n"); + return ret; + } + } + + if (uiapplication->label) { + LISTHEAD(uiapplication->label, tmp1); + uiapplication->label = tmp1; + } + if (uiapplication->icon) { + LISTHEAD(uiapplication->icon, tmp2); + uiapplication->icon = tmp2; + } + if (uiapplication->appsvc) { + LISTHEAD(uiapplication->appsvc, tmp3); + uiapplication->appsvc = tmp3; + } + if (uiapplication->appcontrol) { + LISTHEAD(uiapplication->appcontrol, tmp4); + uiapplication->appcontrol = tmp4; + } + if (uiapplication->launchconditions) { + LISTHEAD(uiapplication->launchconditions, tmp5); + uiapplication->launchconditions = tmp5; + } + if (uiapplication->notification) { + LISTHEAD(uiapplication->notification, tmp6); + uiapplication->notification = tmp6; + } + if (uiapplication->datashare) { + LISTHEAD(uiapplication->datashare, tmp7); + uiapplication->datashare = tmp7; + } + + return ret; +} + +static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication) +{ + const xmlChar *node; + int ret = -1; + int depth = -1; + char *newappid = NULL; + label_x *tmp1 = NULL; + icon_x *tmp2 = NULL; + appsvc_x *tmp3 = NULL; + appcontrol_x *tmp4 = NULL; + datacontrol_x *tmp5 = NULL; + launchconditions_x *tmp6 = NULL; + notification_x *tmp7 = NULL; + datashare_x *tmp8 = NULL; + + if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) { + serviceapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))); + if (serviceapplication->appid == NULL) { + DBG("appid cant be NULL\n"); + return -1; + } + } else { + DBG("appid is mandatory\n"); + return -1; + } + /*check appid*/ + ret = __validate_appid(package, serviceapplication->appid, &newappid); + if (ret == -1) { + DBG("appid is not proper\n"); + return -1; + } else { + if (newappid) { + if (serviceapplication->appid) + free((void *)serviceapplication->appid); + serviceapplication->appid = newappid; + } + } + if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec"))) + serviceapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec"))); + if (xmlTextReaderGetAttribute(reader, XMLCHAR("type"))) + serviceapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type"))); + if (xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot"))) { + serviceapplication->onboot = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot"))); + if (serviceapplication->onboot == NULL) + serviceapplication->onboot = strdup("false"); + } else { + serviceapplication->onboot = strdup("false"); + } + if (xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart"))) { + serviceapplication->autorestart = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart"))); + if (serviceapplication->autorestart == NULL) + serviceapplication->autorestart = strdup("false"); + } else { + serviceapplication->autorestart = strdup("false"); + } + + depth = xmlTextReaderDepth(reader); + while ((ret = __next_child_element(reader, depth))) { + node = xmlTextReaderConstName(reader); + if (!node) { + DBG("xmlTextReaderConstName value is NULL\n"); + return -1; + } + + if (!strcmp(ASCII(node), "label")) { + label_x *label = malloc(sizeof(label_x)); + if (label == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(label, '\0', sizeof(label_x)); + if (label) { + LISTADD(serviceapplication->label, label); + ret = + __ps_process_label(reader, label); + } else + return -1; + } else if (!strcmp(ASCII(node), "icon")) { + icon_x *icon = malloc(sizeof(icon_x)); + if (icon == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(icon, '\0', sizeof(icon_x)); + if (icon) { + LISTADD(serviceapplication->icon, icon); + ret = + __ps_process_icon(reader, icon); + } else + return -1; + } else if (!strcmp(ASCII(node), "app-control")) { + appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x)); + if (appcontrol == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(appcontrol, '\0', sizeof(appcontrol_x)); + if (appcontrol) { + LISTADD(serviceapplication->appcontrol, appcontrol); + ret = + __ps_process_appcontrol(reader, appcontrol); + } else + return -1; + } else if (!strcmp(ASCII(node), "application-service")) { + appsvc_x *appsvc = malloc(sizeof(appsvc_x)); + if (appsvc == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(appsvc, '\0', sizeof(appsvc_x)); + if (appsvc) { + LISTADD(serviceapplication->appsvc, appsvc); + ret = + __ps_process_appsvc(reader, appsvc); + } else + return -1; + } else if (!strcmp(ASCII(node), "data-share")) { + datashare_x *datashare = malloc(sizeof(datashare_x)); + if (datashare == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(datashare, '\0', sizeof(datashare_x)); + if (datashare) { + LISTADD(serviceapplication->datashare, datashare); + ret = + __ps_process_datashare(reader, datashare); + } else + return -1; + } else if (!strcmp(ASCII(node), "launch-conditions")) { + launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x)); + if (launchconditions == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(launchconditions, '\0', sizeof(launchconditions_x)); + if (launchconditions) { + LISTADD(serviceapplication->launchconditions, launchconditions); + ret = + __ps_process_launchconditions(reader, launchconditions); + } else + return -1; + } else if (!strcmp(ASCII(node), "notification")) { + notification_x *notification = malloc(sizeof(notification_x)); + if (notification == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(notification, '\0', sizeof(notification_x)); + if (notification) { + LISTADD(serviceapplication->notification, notification); + ret = + __ps_process_notification(reader, notification); + } else + return -1; + } else if (!strcmp(ASCII(node), "data-control")) { + datacontrol_x *datacontrol = malloc(sizeof(datacontrol_x)); + if (datacontrol == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(datacontrol, '\0', sizeof(datacontrol_x)); + if (datacontrol) { + LISTADD(serviceapplication->datacontrol, datacontrol); + ret = + __ps_process_datacontrol(reader, datacontrol); + } else + return -1; + } else + return -1; + if (ret < 0) { + DBG("Processing serviceapplication failed\n"); + return ret; + } + } + + if (serviceapplication->label) { + LISTHEAD(serviceapplication->label, tmp1); + serviceapplication->label = tmp1; + } + if (serviceapplication->icon) { + LISTHEAD(serviceapplication->icon, tmp2); + serviceapplication->icon = tmp2; + } + if (serviceapplication->appsvc) { + LISTHEAD(serviceapplication->appsvc, tmp3); + serviceapplication->appsvc = tmp3; + } + if (serviceapplication->appcontrol) { + LISTHEAD(serviceapplication->appcontrol, tmp4); + serviceapplication->appcontrol = tmp4; + } + if (serviceapplication->datacontrol) { + LISTHEAD(serviceapplication->datacontrol, tmp5); + serviceapplication->datacontrol = tmp5; + } + if (serviceapplication->launchconditions) { + LISTHEAD(serviceapplication->launchconditions, tmp6); + serviceapplication->launchconditions = tmp6; + } + if (serviceapplication->notification) { + LISTHEAD(serviceapplication->notification, tmp7); + serviceapplication->notification = tmp7; + } + if (serviceapplication->datashare) { + LISTHEAD(serviceapplication->datashare, tmp8); + serviceapplication->datashare = tmp8; + } + + return ret; +} + +static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile) +{ + /*TODO: once policy is set*/ + return 0; +} + +static int __ps_process_font(xmlTextReaderPtr reader, font_x *font) +{ + /*TODO: once policy is set*/ + return 0; +} + +static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme) +{ + /*TODO: once policy is set*/ + return 0; +} + +static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon) +{ + /*TODO: once policy is set*/ + return 0; +} + +static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime) +{ + /*TODO: once policy is set*/ + return 0; +} + +static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx) +{ + DBG("__start_process\n"); + const xmlChar *node; + int ret = -1; + int depth = -1; + label_x *tmp1 = NULL; + author_x *tmp2 = NULL; + description_x *tmp3 = NULL; + license_x *tmp4 = NULL; + uiapplication_x *tmp5 = NULL; + serviceapplication_x *tmp6 = NULL; + daemon_x *tmp7 = NULL; + theme_x *tmp8 = NULL; + font_x *tmp9 = NULL; + ime_x *tmp10 = NULL; + livebox_x *tmp11 = NULL; + icon_x *tmp12 = NULL; + compatibility_x *tmp13 = NULL; + deviceprofile_x *tmp14 = NULL; + + depth = xmlTextReaderDepth(reader); + while ((ret = __next_child_element(reader, depth))) { + node = xmlTextReaderConstName(reader); + if (!node) { + DBG("xmlTextReaderConstName value is NULL\n"); + return -1; + } + + if (!strcmp(ASCII(node), "label")) { + label_x *label = malloc(sizeof(label_x)); + if (label == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(label, '\0', sizeof(label_x)); + if (label) { + LISTADD(mfx->label, label); + ret = + __ps_process_label(reader, label); + } else + return -1; + } else if (!strcmp(ASCII(node), "author")) { + author_x *author = malloc(sizeof(author_x)); + if (author == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(author, '\0', sizeof(author_x)); + if (author) { + LISTADD(mfx->author, author); + ret = + __ps_process_author(reader, author); + } else + return -1; + } else if (!strcmp(ASCII(node), "description")) { + description_x *description = malloc(sizeof(description_x)); + if (description == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(description, '\0', sizeof(description_x)); + if (description) { + LISTADD(mfx->description, description); + ret = + __ps_process_description(reader, description); + } else + return -1; + } else if (!strcmp(ASCII(node), "license")) { + license_x *license = malloc(sizeof(license_x)); + if (license == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(license, '\0', sizeof(license_x)); + if (license) { + LISTADD(mfx->license, license); + ret = + __ps_process_license(reader, license); + } else + return -1; + } else if (!strcmp(ASCII(node), "ui-application")) { + uiapplication_x *uiapplication = malloc(sizeof(uiapplication_x)); + if (uiapplication == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(uiapplication, '\0', sizeof(uiapplication_x)); + if (uiapplication) { + LISTADD(mfx->uiapplication, uiapplication); + ret = + __ps_process_uiapplication(reader, uiapplication); + } else + return -1; + } else if (!strcmp(ASCII(node), "service-application")) { + serviceapplication_x *serviceapplication = malloc(sizeof(serviceapplication_x)); + if (serviceapplication == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(serviceapplication, '\0', sizeof(serviceapplication_x)); + if (serviceapplication) { + LISTADD(mfx->serviceapplication, serviceapplication); + ret = + __ps_process_serviceapplication(reader, serviceapplication); + } else + return -1; + } else if (!strcmp(ASCII(node), "daemon")) { + daemon_x *daemon = malloc(sizeof(daemon_x)); + if (daemon == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(daemon, '\0', sizeof(daemon_x)); + if (daemon) { + LISTADD(mfx->daemon, daemon); + ret = + __ps_process_daemon(reader, daemon); + } else + return -1; + } else if (!strcmp(ASCII(node), "theme")) { + theme_x *theme = malloc(sizeof(theme_x)); + if (theme == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(theme, '\0', sizeof(theme_x)); + if (theme) { + LISTADD(mfx->theme, theme); + ret = + __ps_process_theme(reader, theme); + } else + return -1; + } else if (!strcmp(ASCII(node), "font")) { + font_x *font = malloc(sizeof(font_x)); + if (font == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(font, '\0', sizeof(font_x)); + if (font) { + LISTADD(mfx->font, font); + ret = + __ps_process_font(reader, font); + } else + return -1; + } else if (!strcmp(ASCII(node), "ime")) { + ime_x *ime = malloc(sizeof(ime_x)); + if (ime == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(ime, '\0', sizeof(ime_x)); + if (ime) { + LISTADD(mfx->ime, ime); + ret = + __ps_process_ime(reader, ime); + } else + return -1; + } else if (!strcmp(ASCII(node), "livebox")) { + livebox_x *livebox = malloc(sizeof(livebox_x)); + if (livebox == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(livebox, '\0', sizeof(livebox_x)); + if (livebox) { + LISTADD(mfx->livebox, livebox); + ret = + __ps_process_livebox(reader, livebox); + } else + return -1; + } else if (!strcmp(ASCII(node), "icon")) { + icon_x *icon = malloc(sizeof(icon_x)); + if (icon == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(icon, '\0', sizeof(icon_x)); + if (icon) { + LISTADD(mfx->icon, icon); + ret = + __ps_process_icon(reader, icon); + } else + return -1; + } else if (!strcmp(ASCII(node), "device-profile")) { + deviceprofile_x *deviceprofile = malloc(sizeof(deviceprofile_x)); + if (deviceprofile == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(deviceprofile, '\0', sizeof(deviceprofile_x)); + if (deviceprofile) { + LISTADD(mfx->deviceprofile, deviceprofile); + ret = + __ps_process_deviceprofile(reader, deviceprofile); + } else + return -1; + } else if (!strcmp(ASCII(node), "compatibility")) { + compatibility_x *compatibility = malloc(sizeof(compatibility_x)); + if (compatibility == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(compatibility, '\0', sizeof(compatibility_x)); + if (compatibility) { + LISTADD(mfx->compatibility, compatibility); + ret = + __ps_process_compatibility(reader, compatibility); + } else + return -1; + } else if (!strcmp(ASCII(node), "shortcuts")) { + return 0; + } else + return -1; + + if (ret < 0) { + DBG("Processing manifest failed\n"); + return ret; + } + } + if (mfx->label) { + LISTHEAD(mfx->label, tmp1); + mfx->label = tmp1; + } + if (mfx->author) { + LISTHEAD(mfx->author, tmp2); + mfx->author = tmp2; + } + if (mfx->description) { + LISTHEAD(mfx->description, tmp3); + mfx->description= tmp3; + } + if (mfx->license) { + LISTHEAD(mfx->license, tmp4); + mfx->license= tmp4; + } + if (mfx->uiapplication) { + LISTHEAD(mfx->uiapplication, tmp5); + mfx->uiapplication = tmp5; + } + if (mfx->serviceapplication) { + LISTHEAD(mfx->serviceapplication, tmp6); + mfx->serviceapplication = tmp6; + } + if (mfx->daemon) { + LISTHEAD(mfx->daemon, tmp7); + mfx->daemon= tmp7; + } + if (mfx->theme) { + LISTHEAD(mfx->theme, tmp8); + mfx->theme= tmp8; + } + if (mfx->font) { + LISTHEAD(mfx->font, tmp9); + mfx->font= tmp9; + } + if (mfx->ime) { + LISTHEAD(mfx->ime, tmp10); + mfx->ime= tmp10; + } + if (mfx->livebox) { + LISTHEAD(mfx->livebox, tmp11); + mfx->livebox= tmp11; + } + if (mfx->icon) { + LISTHEAD(mfx->icon, tmp12); + mfx->icon= tmp12; + } + if (mfx->compatibility) { + LISTHEAD(mfx->compatibility, tmp13); + mfx->compatibility= tmp13; + } + if (mfx->deviceprofile) { + LISTHEAD(mfx->deviceprofile, tmp14); + mfx->deviceprofile= tmp14; + } + + return ret; +} + +static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx) +{ + const xmlChar *node; + int ret = -1; + + if ((ret = __next_child_element(reader, -1))) { + node = xmlTextReaderConstName(reader); + if (!node) { + DBG("xmlTextReaderConstName value is NULL\n"); + return -1; + } + + if (!strcmp(ASCII(node), "manifest")) { + if (xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns"))) + mfx->ns = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns"))); + if (xmlTextReaderGetAttribute(reader, XMLCHAR("package"))) { + mfx->package= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("package"))); + if (mfx->package == NULL) { + DBG("package cant be NULL\n"); + return -1; + } + } else { + DBG("package field is mandatory\n"); + return -1; + } + package = mfx->package; + if (xmlTextReaderGetAttribute(reader, XMLCHAR("version"))) + mfx->version= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("version"))); + if (xmlTextReaderGetAttribute(reader, XMLCHAR("install-location"))) + mfx->installlocation = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("install-location"))); + if (xmlTextReaderGetAttribute(reader, XMLCHAR("type"))) + mfx->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type"))); + /*Assign default values. If required it will be overwritten in __add_preload_info()*/ + mfx->preload = strdup("False"); + mfx->removable = strdup("True"); + mfx->readonly = strdup("False"); + + ret = __start_process(reader, mfx); + } else { + DBG("No Manifest element found\n"); + return -1; + } + } + return ret; +} + +#define DESKTOP_RW_PATH "/opt/share/applications/" +#define DESKTOP_RO_PATH "/usr/share/applications/" + +static char* __convert_to_system_locale(const char *mlocale) +{ + if (mlocale == NULL) + return NULL; + char *locale = NULL; + locale = (char *)calloc(1, 6); + if (!locale) { + _LOGE("Malloc Failed\n"); + return NULL; + } + + strncpy(locale, mlocale, 2); + strncat(locale, "_", 1); + locale[3] = toupper(mlocale[3]); + locale[4] = toupper(mlocale[4]); + return locale; +} + + +/* desktop shoud be generated automatically based on manifest */ +/* Currently removable, taskmanage, etc fields are not considerd. it will be decided soon.*/ +static int __ps_make_nativeapp_desktop(manifest_x * mfx) +{ + FILE* file = NULL; + int fd = 0; + char filepath[PKG_STRING_LEN_MAX] = ""; + char buf[4096] = ""; + char buftemp[4096] = ""; + + for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) { + + if(mfx->readonly && !strcasecmp(mfx->readonly, "True")) + snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RO_PATH, mfx->uiapplication->appid); + else + snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, mfx->uiapplication->appid); + + /* skip if desktop exists + if (access(filepath, R_OK) == 0) + continue; + */ + + file = fopen(filepath, "w"); + if(file == NULL) + { + _LOGE("Can't open %s", filepath); + return -1; + } + + snprintf(buf, sizeof(buf), "[Desktop Entry]\n"); + fwrite(buf, 1, strlen(buf), file); + + for( ; mfx->uiapplication->label ; mfx->uiapplication->label = mfx->uiapplication->label->next) { + if(!strcmp(mfx->uiapplication->label->lang, DEFAULT_LOCALE)) { + snprintf(buf, sizeof(buf), "Name=%s\n", mfx->uiapplication->label->text); + } else { + snprintf(buf, sizeof(buf), "Name[%s]=%s\n", + __convert_to_system_locale(mfx->uiapplication->label->lang), + mfx->uiapplication->label->text); + } + fwrite(buf, 1, strlen(buf), file); + } + + if(mfx->uiapplication->label && mfx->uiapplication->label->text) { + snprintf(buf, sizeof(buf), "Name=%s\n", mfx->uiapplication->label->text); + fwrite(buf, 1, strlen(buf), file); + } +/* + else if(mfx->label && mfx->label->text) { + snprintf(buf, sizeof(buf), "Name=%s\n", mfx->label->text); + fwrite(buf, 1, strlen(buf), file); + } else { + snprintf(buf, sizeof(buf), "Name=%s\n", mfx->package); + fwrite(buf, 1, strlen(buf), file); + } +*/ + + + snprintf(buf, sizeof(buf), "Type=Application\n"); + fwrite(buf, 1, strlen(buf), file); + + if(mfx->uiapplication->exec) { + snprintf(buf, sizeof(buf), "Exec=%s\n", mfx->uiapplication->exec); + fwrite(buf, 1, strlen(buf), file); + } + + if(mfx->uiapplication->icon && mfx->uiapplication->icon->text) { + snprintf(buf, sizeof(buf), "Icon=%s\n", mfx->uiapplication->icon->text); + fwrite(buf, 1, strlen(buf), file); + } else if(mfx->icon && mfx->icon->text) { + snprintf(buf, sizeof(buf), "Icon=%s\n", mfx->icon->text); + fwrite(buf, 1, strlen(buf), file); + } + + if(mfx->version) { + snprintf(buf, sizeof(buf), "Version=%s\n", mfx->version); + fwrite(buf, 1, strlen(buf), file); + } + + if(mfx->uiapplication->nodisplay) { + snprintf(buf, sizeof(buf), "NoDisplay=%s\n", mfx->uiapplication->nodisplay); + fwrite(buf, 1, strlen(buf), file); + } + + if(mfx->uiapplication->categories) { + snprintf(buf, sizeof(buf), "Categories=%s\n", mfx->uiapplication->categories); + fwrite(buf, 1, strlen(buf), file); + } + + if(mfx->uiapplication->taskmanage && !strcasecmp(mfx->uiapplication->taskmanage, "False")) { + snprintf(buf, sizeof(buf), "X-TIZEN-TaskManage=False\n"); + fwrite(buf, 1, strlen(buf), file); + } + + if(mfx->uiapplication->multiple && !strcasecmp(mfx->uiapplication->multiple, "True")) { + snprintf(buf, sizeof(buf), "X-TIZEN-Multiple=True\n"); + fwrite(buf, 1, strlen(buf), file); + } + + if(mfx->uiapplication->extraid) { + snprintf(buf, sizeof(buf), "X-TIZEN-PackageID=%s\n", mfx->uiapplication->extraid); + fwrite(buf, 1, strlen(buf), file); + } + + if(mfx->removable && !strcasecmp(mfx->removable, "False")) { + snprintf(buf, sizeof(buf), "X-TIZEN-Removable=False\n"); + fwrite(buf, 1, strlen(buf), file); + } + + if(mfx->type) { + snprintf(buf, sizeof(buf), "X-TIZEN-PackageType=%s\n", mfx->type); + fwrite(buf, 1, strlen(buf), file); + } + +// snprintf(buf, sizeof(buf), "X-TIZEN-PackageType=rpm\n"); +// fwrite(buf, 1, strlen(buf), file); + + + if(mfx->uiapplication->appsvc) { + snprintf(buf, sizeof(buf), "X-TIZEN-Svc="); + DBG("buf[%s]\n", buf); + + + uiapplication_x *up = mfx->uiapplication; + appsvc_x *asvc = NULL; + operation_x *op = NULL; + mime_x *mi = NULL; + uri_x *ui = NULL; + int ret = -1; + char query[PKG_STRING_LEN_MAX] = {'\0'}; + char *operation = NULL; + char *mime = NULL; + char *uri = NULL; + int i = 0; + + + asvc = up->appsvc; + while(asvc != NULL) + { + op = asvc->operation; + while(op != NULL) + { + if (op) + operation = op->name; + mi = asvc->mime; + + do + { + if (mi) + mime = mi->name; + ui = asvc->uri; + do + { + if (ui) + uri = ui->name; + + if(i++ > 0) { + strncpy(buftemp, buf, sizeof(buftemp)); + snprintf(buf, sizeof(buf), "%s;", buftemp); + } + + strncpy(buftemp, buf, sizeof(buftemp)); + snprintf(buf, sizeof(buf), "%s%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL"); + DBG("buf[%s]\n", buf); + + if (ui) + ui = ui->next; + uri = NULL; + } while(ui != NULL); + if (mi) + mi = mi->next; + mime = NULL; + }while(mi != NULL); + if (op) + op = op->next; + operation = NULL; + } + asvc = asvc->next; + } + + + fwrite(buf, 1, strlen(buf), file); + +// strncpy(buftemp, buf, sizeof(buftemp)); +// snprintf(buf, sizeof(buf), "%s\n", buftemp); +// fwrite(buf, 1, strlen(buf), file); + } + + fd = fileno(file); + fdatasync(fd); + fclose(file); + } + + return 0; +} + +static int __ps_remove_nativeapp_desktop(manifest_x *mfx) +{ + char filepath[PKG_STRING_LEN_MAX] = ""; + + for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) { + snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, mfx->uiapplication->appid); + + remove(filepath); + } + + return 0; +} + +#define MANIFEST_RO_PREFIX "/usr/share/packages/" +#define PRELOAD_PACKAGE_LIST "/usr/etc/package-manager/preload/preload_list.txt" +static int __add_preload_info(manifest_x * mfx, const char *manifest) +{ + FILE *fp = NULL; + char buffer[1024] = { 0 }; + int state = 0; + + if(strstr(manifest, MANIFEST_RO_PREFIX)) { + free(mfx->readonly); + mfx->readonly = strdup("True"); + + free(mfx->preload); + mfx->preload = strdup("True"); + + free(mfx->removable); + mfx->removable = strdup("False"); + + return 0; + } + + fp = fopen(PRELOAD_PACKAGE_LIST, "r"); + if (fp == NULL) { + _LOGE("no preload list\n"); + return -1; + } + + while (fgets(buffer, sizeof(buffer), fp) != NULL) { + if (buffer[0] == '#') { + if(strcasestr(buffer, "RW_NORM")) + state = 2; + else if(strcasestr(buffer, "RW_RM")) + state = 3; + else + continue; + } + + __str_trim(buffer); + + if(!strcmp(mfx->package, buffer)) { + free(mfx->preload); + mfx->preload = strdup("True"); + if(state == 2){ + free(mfx->readonly); + mfx->readonly = strdup("False"); + free(mfx->removable); + mfx->removable = strdup("False"); + } else if(state == 3){ + free(mfx->readonly); + mfx->readonly = strdup("False"); + free(mfx->removable); + mfx->removable = strdup("True"); + } + } + + memset(buffer, 0x00, sizeof(buffer)); + } + + if (fp != NULL) + fclose(fp); + + return 0; +} + + +API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx) +{ + if (mfx == NULL) + return; + if (mfx->ns) { + free((void *)mfx->ns); + mfx->ns = NULL; + } + if (mfx->package) { + free((void *)mfx->package); + mfx->package = NULL; + } + if (mfx->version) { + free((void *)mfx->version); + mfx->version = NULL; + } + if (mfx->installlocation) { + free((void *)mfx->installlocation); + mfx->installlocation = NULL; + } + if (mfx->preload) { + free((void *)mfx->preload); + mfx->preload = NULL; + } + if (mfx->readonly) { + free((void *)mfx->readonly); + mfx->readonly = NULL; + } + if (mfx->removable) { + free((void *)mfx->removable); + mfx->removable = NULL; + } + if (mfx->type) { + free((void *)mfx->type); + mfx->type = NULL; + } + + /*Free Icon*/ + if (mfx->icon) { + icon_x *icon = mfx->icon; + icon_x *tmp = NULL; + while(icon != NULL) + { + tmp = icon->next; + __ps_free_icon(icon); + icon = tmp; + } + } + /*Free Label*/ + if (mfx->label) { + label_x *label = mfx->label; + label_x *tmp = NULL; + while(label != NULL) + { + tmp = label->next; + __ps_free_label(label); + label = tmp; + } + } + /*Free Author*/ + if (mfx->author) { + author_x *author = mfx->author; + author_x *tmp = NULL; + while(author != NULL) + { + tmp = author->next; + __ps_free_author(author); + author = tmp; + } + } + /*Free Description*/ + if (mfx->description) { + description_x *description = mfx->description; + description_x *tmp = NULL; + while(description != NULL) + { + tmp = description->next; + __ps_free_description(description); + description = tmp; + } + } + /*Free License*/ + if (mfx->license) { + license_x *license = mfx->license; + license_x *tmp = NULL; + while(license != NULL) + { + tmp = license->next; + __ps_free_license(license); + license = tmp; + } + } + /*Free UiApplication*/ + if (mfx->uiapplication) { + uiapplication_x *uiapplication = mfx->uiapplication; + uiapplication_x *tmp = NULL; + while(uiapplication != NULL) + { + tmp = uiapplication->next; + __ps_free_uiapplication(uiapplication); + uiapplication = tmp; + } + } + /*Free ServiceApplication*/ + if (mfx->serviceapplication) { + serviceapplication_x *serviceapplication = mfx->serviceapplication; + serviceapplication_x *tmp = NULL; + while(serviceapplication != NULL) + { + tmp = serviceapplication->next; + __ps_free_serviceapplication(serviceapplication); + serviceapplication = tmp; + } + } + /*Free Daemon*/ + if (mfx->daemon) { + daemon_x *daemon = mfx->daemon; + daemon_x *tmp = NULL; + while(daemon != NULL) + { + tmp = daemon->next; + __ps_free_daemon(daemon); + daemon = tmp; + } + } + /*Free Theme*/ + if (mfx->theme) { + theme_x *theme = mfx->theme; + theme_x *tmp = NULL; + while(theme != NULL) + { + tmp = theme->next; + __ps_free_theme(theme); + theme = tmp; + } + } + /*Free Font*/ + if (mfx->font) { + font_x *font = mfx->font; + font_x *tmp = NULL; + while(font != NULL) + { + tmp = font->next; + __ps_free_font(font); + font = tmp; + } + } + /*Free Ime*/ + if (mfx->ime) { + ime_x *ime = mfx->ime; + ime_x *tmp = NULL; + while(ime != NULL) + { + tmp = ime->next; + __ps_free_ime(ime); + ime = tmp; + } + } + /*Free Livebox*/ + if (mfx->livebox) { + livebox_x *livebox = mfx->livebox; + livebox_x *tmp = NULL; + while(livebox != NULL) + { + tmp = livebox->next; + __ps_free_livebox(livebox); + livebox = tmp; + } + } + /*Free Compatibility*/ + if (mfx->compatibility) { + compatibility_x *compatibility = mfx->compatibility; + compatibility_x *tmp = NULL; + while(compatibility != NULL) + { + tmp = compatibility->next; + __ps_free_compatibility(compatibility); + compatibility = tmp; + } + } + /*Free DeviceProfile*/ + if (mfx->deviceprofile) { + deviceprofile_x *deviceprofile = mfx->deviceprofile; + deviceprofile_x *tmp = NULL; + while(deviceprofile != NULL) + { + tmp = deviceprofile->next; + __ps_free_deviceprofile(deviceprofile); + deviceprofile = tmp; + } + } + free((void*)mfx); + mfx = NULL; + return; +} + +manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest) +{ + DBG("parsing start\n"); + xmlTextReaderPtr reader; + manifest_x *mfx = NULL; + + reader = xmlReaderForFile(manifest, NULL, 0); + if (reader) { + mfx = malloc(sizeof(manifest_x)); + if (mfx) { + memset(mfx, '\0', sizeof(manifest_x)); + if (__process_manifest(reader, mfx) < 0) { + DBG("Parsing Failed\n"); + pkgmgr_parser_free_manifest_xml(mfx); + mfx = NULL; + } else + DBG("Parsing Success\n"); + } else { + DBG("Memory allocation error\n"); + } + xmlFreeTextReader(reader); + } else { + DBG("Unable to create xml reader\n"); + } + return mfx; +} + +/* These APIs are intended to call parser directly */ + +API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[]) +{ + char *temp[] = {"shortcuts", NULL}; + if (manifest == NULL) { + DBG("argument supplied is NULL\n"); + return -1; + } + DBG("parsing manifest for installation: %s\n", manifest); + manifest_x *mfx = NULL; + int ret = -1; + xmlInitParser(); + mfx = pkgmgr_parser_process_manifest_xml(manifest); + DBG("Parsing Finished\n"); + if (mfx) { + __streamFile(manifest, ACTION_INSTALL, temp, mfx->package); + __add_preload_info(mfx, manifest); + DBG("Added preload infomation\n"); + ret = pkgmgr_parser_insert_manifest_info_in_db(mfx); + if (ret == -1) + DBG("DB Insert failed\n"); + else + DBG("DB Insert Success\n"); + + ret = __ps_make_nativeapp_desktop(mfx); + if (ret == -1) + DBG("Creating desktop file failed\n"); + else + DBG("Creating desktop file Success\n"); + } else + DBG("mfx is NULL\n"); + + pkgmgr_parser_free_manifest_xml(mfx); + DBG("Free Done\n"); + xmlCleanupParser(); + + return 0; +} + +API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[]) +{ + char *temp[] = {"shortcuts", NULL}; + if (manifest == NULL) { + DBG("argument supplied is NULL\n"); + return -1; + } + DBG("parsing manifest for upgradation: %s\n", manifest); + manifest_x *mfx = NULL; + int ret = -1; + xmlInitParser(); + mfx = pkgmgr_parser_process_manifest_xml(manifest); + DBG("Parsing Finished\n"); + + if (mfx) { + __streamFile(manifest, ACTION_UPGRADE, temp, mfx->package); + __add_preload_info(mfx, manifest); + DBG("Added preload infomation\n"); + ret = pkgmgr_parser_update_manifest_info_in_db(mfx); + if (ret == -1) + DBG("DB Update failed\n"); + else + DBG("DB Update Success\n"); + + ret = __ps_make_nativeapp_desktop(mfx); + if (ret == -1) + DBG("Creating desktop file failed\n"); + else + DBG("Creating desktop file Success\n"); + } + pkgmgr_parser_free_manifest_xml(mfx); + DBG("Free Done\n"); + xmlCleanupParser(); + + return 0; +} + +API int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[]) +{ + char *temp[] = {"shortcuts", NULL}; + if (manifest == NULL) { + DBG("argument supplied is NULL\n"); + return -1; + } + DBG("parsing manifest for uninstallation: %s\n", manifest); + manifest_x *mfx = NULL; + int ret = -1; + xmlInitParser(); + mfx = pkgmgr_parser_process_manifest_xml(manifest); + DBG("Parsing Finished\n"); + + if (mfx) { + __streamFile(manifest, ACTION_UNINSTALL, temp, mfx->package); + __add_preload_info(mfx, manifest); + DBG("Added preload infomation\n"); + + ret = pkgmgr_parser_delete_manifest_info_from_db(mfx); + if (ret == -1) + DBG("DB Delete failed\n"); + else + DBG("DB Delete Success\n"); + + ret = __ps_remove_nativeapp_desktop(mfx); + if (ret == -1) + DBG("Removing desktop file failed\n"); + else + DBG("Removing desktop file Success\n"); + } + pkgmgr_parser_free_manifest_xml(mfx); + DBG("Free Done\n"); + xmlCleanupParser(); + + return 0; +} + +API char *pkgmgr_parser_get_manifest_file(const char *pkgname) +{ + return __pkgname_to_manifest(pkgname); +} + +API int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgname) +{ + return __ps_run_parser(docPtr, tag, ACTION_INSTALL, pkgname); +} + +API int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgname) +{ + return __ps_run_parser(docPtr, tag, ACTION_UPGRADE, pkgname); +} + +API int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgname) +{ + return __ps_run_parser(docPtr, tag, ACTION_UNINSTALL, pkgname); +} + +#define SCHEMA_FILE "/usr/etc/package-manager/preload/manifest.xsd" +#if 1 +API int pkgmgr_parser_check_manifest_validation(const char *manifest) +{ + if (manifest == NULL) { + DBGE("manifest file is NULL\n"); + return PKGMGR_R_EINVAL; + } + int ret = -1; + xmlSchemaParserCtxtPtr ctx; + xmlSchemaValidCtxtPtr vctx; + xmlSchemaPtr xschema; + ctx = xmlSchemaNewParserCtxt(SCHEMA_FILE); + if (ctx == NULL) { + DBGE("xmlSchemaNewParserCtxt() Failed\n"); + return PKGMGR_R_ERROR; + } + xschema = xmlSchemaParse(ctx); + if (xschema == NULL) { + DBGE("xmlSchemaParse() Failed\n"); + return PKGMGR_R_ERROR; + } + vctx = xmlSchemaNewValidCtxt(xschema); + if (vctx == NULL) { + DBGE("xmlSchemaNewValidCtxt() Failed\n"); + return PKGMGR_R_ERROR; + } + xmlSchemaSetValidErrors(vctx, (xmlSchemaValidityErrorFunc) fprintf, (xmlSchemaValidityWarningFunc) fprintf, stderr); + ret = xmlSchemaValidateFile(vctx, manifest, 0); + if (ret == -1) { + DBGE("xmlSchemaValidateFile() failed\n"); + return PKGMGR_R_ERROR; + } else if (ret == 0) { + DBGE("Manifest is Valid\n"); + return PKGMGR_R_OK; + } else { + DBGE("Manifest Validation Failed with error code %d\n", ret); + return PKGMGR_R_ERROR; + } + return PKGMGR_R_OK; +} + +#else +API int pkgmgr_parser_check_manifest_validation(const char *manifest) +{ + int err = 0; + int status = 0; + pid_t pid; + + pid = fork(); + + switch (pid) { + case -1: + DBGE("fork failed\n"); + return -1; + case 0: + /* child */ + { + int dev_null_fd = open ("/dev/null", O_RDWR); + if (dev_null_fd >= 0) + { + dup2 (dev_null_fd, 0);/*stdin*/ + dup2 (dev_null_fd, 1);/*stdout*/ + dup2 (dev_null_fd, 2);/*stderr*/ + } + + if (execl("/usr/bin/xmllint", "xmllint", manifest, "--schema", + SCHEMA_FILE, NULL) < 0) { + DBGE("execl error\n"); + } + + _exit(100); + } + default: + /* parent */ + break; + } + + while ((err = waitpid(pid, &status, WNOHANG)) != pid) { + if (err < 0) { + if (errno == EINTR) + continue; + DBGE("waitpid failed\n"); + return -1; + } + } + + + if(WIFEXITED(status) && !WEXITSTATUS(status)) + return 0; + else + return -1; +} +#endif diff --git a/parser/pkgmgr_parser.h b/parser/pkgmgr_parser.h new file mode 100755 index 0000000..4cd1c5b --- /dev/null +++ b/parser/pkgmgr_parser.h @@ -0,0 +1,538 @@ +/* + * slp-pkgmgr + * + * Copyright (c) 2000 - 2011 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. + * + */ + +#ifndef __PKGMGR_PARSER_H__ +#define __PKGMGR_PARSER_H__ + +/** + * @file pkgmgr_parser.h + * @author Sewook Park , Shobhit Srivastava + * @version 0.1 + * @brief This file declares API of pkgmgr_parser + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif +#define DEFAULT_LOCALE "No Locale" +/** + * List definitions. + * All lists are doubly-linked, the last element is stored to list pointer, + * which means that lists must be looped using the prev pointer, or by + * calling LISTHEAD first to go to start in order to use the next pointer. + */ +#define LISTADD(list, node) \ + do { \ + (node)->prev = (list); \ + if (list) (node)->next = (list)->next; \ + else (node)->next = NULL; \ + if (list) (list)->next = (node); \ + (list) = (node); \ + } while (0); + +#define NODEADD(node1, node2) \ + do { \ + (node2)->prev = (node1); \ + (node2)->next = (node1)->next; \ + if ((node1)->next) (node1)->next->prev = (node2); \ + (node1)->next = (node2); \ + } while (0); + +#define LISTCAT(list, first, last) \ + if ((first) && (last)) { \ + (first)->prev = (list); \ + (list) = (last); \ + } + +#define LISTDEL(list, node) \ + do { \ + if ((node)->prev) (node)->prev->next = (node)->next; \ + if ((node)->next) (node)->next->prev = (node)->prev; \ + if (!((node)->prev) && !((node)->next)) (list) = NULL; \ + } while (0); + +#define LISTHEAD(list, node) \ + for ((node) = (list); (node)->prev; (node) = (node)->prev); +#define LISTTAIL(list, node) \ + for ((node) = (list); (node)->next; (node) = (node)->next); + +typedef struct icon_x { + const char *name; + const char *text; + const char *lang; + const char *section; + const char *size; + struct icon_x *prev; + struct icon_x *next; +} icon_x; + +typedef struct allowed_x { + const char *name; + const char *text; + struct allowed_x *prev; + struct allowed_x *next; +} allowed_x; + +typedef struct request_x { + const char *text; + struct request_x *prev; + struct request_x *next; +} request_x; + +typedef struct define_x { + const char *path; + struct allowed_x *allowed; + struct request_x *request; + struct define_x *prev; + struct define_x *next; +} define_x; + +typedef struct timeout_x { + const char *text; + struct timeout_x *prev; + struct timeout_x *next; +} timeout_x; + +typedef struct network_x { + const char *text; + struct network_x *prev; + struct network_x *next; +} network_x; + +typedef struct period_x { + const char *text; + struct period_x *prev; + struct period_x *next; +} period_x; + +typedef struct autolaunch_x { + const char *text; + struct autolaunch_x *prev; + struct autolaunch_x *next; +} autolaunch_x; + +typedef struct file_x { + const char *text; + struct file_x *prev; + struct file_x *next; +} file_x; + +typedef struct size_x { + const char *text; + struct size_x *prev; + struct size_x *next; +} size_x; + + +typedef struct datashare_x { + struct define_x *define; + struct request_x *request; + struct datashare_x *prev; + struct datashare_x *next; +} datashare_x; + +typedef struct description_x { + const char *name; + const char *text; + const char *lang; + struct description_x *prev; + struct description_x *next; +} description_x; + +typedef struct registry_x { + const char *name; + const char *text; + struct registry_x *prev; + struct registry_x *next; +} registry_x; + +typedef struct database_x { + const char *name; + const char *text; + struct database_x *prev; + struct database_x *next; +} database_x; + +typedef struct layout_x { + const char *name; + const char *text; + struct layout_x *prev; + struct layout_x *next; +} layout_x; + +typedef struct label_x { + const char *name; + const char *text; + const char *lang; + struct label_x *prev; + struct label_x *next; +} label_x; + +typedef struct author_x { + const char *email; + const char *href; + const char *text; + const char *lang; + struct author_x *prev; + struct author_x *next; +} author_x; + +typedef struct license_x { + const char *text; + const char *lang; + struct license_x *prev; + struct license_x *next; +} license_x; + +typedef struct operation_x { + const char *name; + const char *text; + struct operation_x *prev; + struct operation_x *next; +} operation_x; + +typedef struct uri_x { + const char *name; + const char *text; + struct uri_x *prev; + struct uri_x *next; +} uri_x; + +typedef struct mime_x { + const char *name; + const char *text; + struct mime_x *prev; + struct mime_x *next; +} mime_x; + +typedef struct condition_x { + const char *name; + const char *text; + struct condition_x *prev; + struct condition_x *next; +} condition_x; + +typedef struct notification_x { + const char *name; + const char *text; + struct notification_x *prev; + struct notification_x *next; +} notification_x; + +typedef struct appsvc_x { + const char *text; + struct operation_x *operation; + struct uri_x *uri; + struct mime_x *mime; + struct appsvc_x *prev; + struct appsvc_x *next; +} appsvc_x; + +typedef struct launchconditions_x { + const char *text; + struct condition_x *condition; + struct launchconditions_x *prev; + struct launchconditions_x *next; +} launchconditions_x; + + +typedef struct compatibility_x { + const char *name; + const char *text; + struct compatibility_x *prev; + struct compatibility_x *next; +}compatibility_x; + +typedef struct deviceprofile_x { + const char *name; + const char *text; + struct deviceprofile_x *prev; + struct deviceprofile_x *next; +}deviceprofile_x; + +typedef struct resolution_x { + const char *mimetype; + const char *urischeme; + struct resolution_x *prev; + struct resolution_x *next; +} resolution_x; + +typedef struct capability_x { + const char *operationid; + const char *access; + struct resolution_x *resolution; + struct capability_x *prev; + struct capability_x *next; +} capability_x; + +typedef struct appcontrol_x { + const char *providerid; + const char *category; + struct capability_x *capability; + struct appcontrol_x *prev; + struct appcontrol_x *next; +} appcontrol_x; + +typedef struct datacontrol_x { + const char *providerid; + struct capability_x *capability; + struct datacontrol_x *prev; + struct datacontrol_x *next; +} datacontrol_x; + +typedef struct uiapplication_x { + const char *appid; + const char *exec; + const char *nodisplay; + const char *multiple; + const char *taskmanage; + const char *type; + const char *categories; + const char *extraid; + struct label_x *label; + struct icon_x *icon; + struct appsvc_x *appsvc; + struct appcontrol_x *appcontrol; + struct launchconditions_x *launchconditions; + struct notification_x *notification; + struct datashare_x *datashare; + struct uiapplication_x *prev; + struct uiapplication_x *next; +} uiapplication_x; + +typedef struct serviceapplication_x { + const char *appid; + const char *exec; + const char *onboot; + const char *autorestart; + const char *type; + struct label_x *label; + struct icon_x *icon; + struct appsvc_x *appsvc; + struct appcontrol_x *appcontrol; + struct datacontrol_x *datacontrol; + struct launchconditions_x *launchconditions; + struct notification_x *notification; + struct datashare_x *datashare; + struct serviceapplication_x *prev; + struct serviceapplication_x *next; +} serviceapplication_x; + +typedef struct daemon_x { + const char *name; + const char *text; + struct daemon_x *prev; + struct daemon_x *next; +} daemon_x; + +typedef struct theme_x { + const char *name; + const char *text; + struct theme_x *prev; + struct theme_x *next; +} theme_x; + +typedef struct font_x { + const char *name; + const char *text; + struct font_x *prev; + struct font_x *next; +} font_x; + +typedef struct ime_x { + const char *name; + const char *text; + struct ime_x *prev; + struct ime_x *next; +} ime_x; + +typedef struct category_x{ + const char *name; + struct category_x *prev; + struct category_x *next; +} category_x; + +typedef struct cluster_x{ + const char *name; + struct category_x *category; + struct cluster_x *prev; + struct cluster_x *next; +} cluster_x; + +typedef struct group_x{ + struct cluster_x *cluster; + struct group_x *prev; + struct group_x *next; +} group_x; + +typedef struct grp_x{ + const char *text; + struct grp_x *prev; + struct grp_x *next; +} grp_x; + +typedef struct security_x{ + const char *isolate; + struct security_x *prev; + struct security_x *next; +} security_x; + +typedef struct libexec_x{ + const char *text; + struct libexec_x *prev; + struct libexec_x *next; +} libexec_x; + +typedef struct lbox_x{ + const char *type; + struct size_x *size; + struct lbox_x *prev; + struct lbox_x *next; +} lbox_x; + +typedef struct pd_x { + const char *type; + const char *language; + struct file_x *file; + struct grp_x *grp; + struct size_x *size; + struct pd_x *prev; + struct pd_x *next; +} pd_x; + +typedef struct control_x { + struct timeout_x *timeout; + struct period_x *period; + struct network_x *network; + struct autolaunch_x *autolaunch; + struct control_x *prev; + struct control_x *next; +} control_x; + +typedef struct content_x { + struct lbox_x *lbox; + struct pd_x *pd; + struct content_x *prev; + struct content_x *next; +} content_x; + + +typedef struct livebox_x { + const char *application; + const char *abi; + const char *type; + struct icon_x *icon; + struct label_x *label; + struct libexec_x *libexec; + struct control_x *control; + struct content_x *content; + struct group_x *group; + struct security_x *security; + struct size_x *size; + struct livebox_x *prev; + struct livebox_x *next; +} livebox_x; + +typedef struct manifest_x { + const char *package; + const char *version; + const char *installlocation;; + const char *ns; + const char *removable; + const char *preload; + const char *readonly; + const char *type; + struct icon_x *icon; + struct label_x *label; + struct author_x *author; + struct description_x *description; + struct license_x *license; + struct uiapplication_x *uiapplication; + struct serviceapplication_x *serviceapplication; + struct daemon_x *daemon; + struct theme_x *theme; + struct font_x *font; + struct ime_x *ime; + struct livebox_x *livebox; + struct compatibility_x *compatibility; + struct deviceprofile_x *deviceprofile; +} manifest_x; + +/* These APIs are for installer backends */ + +/** + * @brief routine to get the manifest file from pkgname. + * @param[in] pkgname, the application package name + * @return: on sucess it returns the manifest file path, on failure it returns NULL + */ +char *pkgmgr_parser_get_manifest_file(const char *pkgname); + +/** + * @brief routine to parse the manifest file after installation + * @param[in] manifest, the application manifest file path + * @return: on sucess it returns 0, on failure it returns -1 + */ +int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[]); + +/** + * @brief routine to parse the manifest file after upgradation + * @param[in] manifest, the application manifest file path + * @return: on sucess it returns 0, on failure it returns -1 + */ +int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[]); + +/** + * @brief routine to parse the manifest file after uninstallation + * @param[in] manifest, the application manifest file path + * @return: on sucess it returns 0, on failure it returns -1 + */ +int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[]); + +/** + * @check validation for manifest + * @param[in] manifest, the application manifest file path + * @return: on sucess it returns 0, on failure it returns -1 + */ +int pkgmgr_parser_check_manifest_validation(const char *manifest); + +/** + * @brief routine to free the manifest pointer obtained after parsing + * @param[in] mfx, the pointer to manifest structure + */ +void pkgmgr_parser_free_manifest_xml(manifest_x *mfx); +manifest_x *pkgmr_parser_process_manifest_xml(const char *manifest); + +/* These APIs are intended to call parser directly */ +typedef int (*ps_iter_fn) (const char *tag, int type, void *userdata); + +int pkgmgr_parser_has_parser(const char *tag, int *type); +int pkgmgr_parser_get_list(ps_iter_fn iter_fn, void *data); +int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgname); +int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgname); +int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgname); + +#ifdef __cplusplus +} +#endif +#endif /* __PKGMGR_PARSER_H__ */ diff --git a/parser/pkgmgr_parser_db.c b/parser/pkgmgr_parser_db.c new file mode 100755 index 0000000..f2eb702 --- /dev/null +++ b/parser/pkgmgr_parser_db.c @@ -0,0 +1,1307 @@ +/* + * slp-pkgmgr + * + * Copyright (c) 2000 - 2011 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 "pkgmgr_parser_internal.h" +#include "pkgmgr_parser_db.h" +#include "pkgmgr-api.h" + +#define PKGMGR_PARSER_DB_FILE "/opt/dbspace/.pkgmgr_parser.db" +#define MAX_QUERY_LEN 4096 +sqlite3 *pkgmgr_parser_db; +GList *pkglocale = NULL; +GList *applocale = NULL; +char *prev = NULL; + +#define QUERY_CREATE_TABLE_PACKAGE_INFO "create table if not exists package_info " \ + "(package text primary key not null, " \ + "package_type text DEFAULT 'rpm', " \ + "package_version text, " \ + "install_location text, " \ + "package_removable text DEFAULT 'true', " \ + "package_preload text DEFAULT 'false', " \ + "package_readonly text DEFAULT 'false', " \ + "author_name text, " \ + "author_email text, " \ + "author_href text)" + +#define QUERY_CREATE_TABLE_PACKAGE_LOCALIZED_INFO "create table if not exists package_localized_info " \ + "(package text not null, " \ + "package_locale text DEFAULT 'No Locale', " \ + "package_label text, " \ + "package_icon text, " \ + "package_description text, " \ + "package_license text, " \ + "package_author, " \ + "PRIMARY KEY(package, package_locale), " \ + "FOREIGN KEY(package) " \ + "REFERENCES package_info(package) " \ + "ON DELETE CASCADE)" + +#define QUERY_CREATE_TABLE_PACKAGE_APP_INFO "create table if not exists package_app_info " \ + "(app_id text primary key not null, " \ + "app_component text, " \ + "app_exec text, " \ + "app_nodisplay text DEFAULT 'false', " \ + "app_type text, " \ + "app_onboot text DEFAULT 'false', " \ + "app_multiple text DEFAULT 'false', " \ + "app_autorestart text DEFAULT 'false', " \ + "app_taskmanage text DEFAULT 'false', " \ + "package text not null, " \ + "FOREIGN KEY(package) " \ + "REFERENCES package_info(package) " \ + "ON DELETE CASCADE)" + +#define QUERY_CREATE_TABLE_PACKAGE_APP_LOCALIZED_INFO "create table if not exists package_app_localized_info " \ + "(app_id text not null, " \ + "app_locale text DEFAULT 'No Locale', " \ + "app_label text, " \ + "app_icon text, " \ + "PRIMARY KEY(app_id,app_locale) " \ + "FOREIGN KEY(app_id) " \ + "REFERENCES package_app_info(app_id) " \ + "ON DELETE CASCADE)" + +#define QUERY_CREATE_TABLE_PACKAGE_APP_APP_SVC "create table if not exists package_app_app_svc " \ + "(app_id text not null, " \ + "operation text not null, " \ + "uri_scheme text, " \ + "mime_type text, " \ + "PRIMARY KEY(app_id,operation,uri_scheme,mime_type) " \ + "FOREIGN KEY(app_id) " \ + "REFERENCES package_app_info(app_id) " \ + "ON DELETE CASCADE)" + +#define QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_ALLOWED "create table if not exists package_app_share_allowed " \ + "(app_id text not null, " \ + "data_share_path text not null, " \ + "data_share_allowed text not null, " \ + "PRIMARY KEY(app_id,data_share_path,data_share_allowed) " \ + "FOREIGN KEY(app_id) " \ + "REFERENCES package_app_info(app_id) " \ + "ON DELETE CASCADE)" + +#define QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_REQUEST "create table if not exists package_app_share_request " \ + "(app_id text not null, " \ + "data_share_request text not null, " \ + "PRIMARY KEY(app_id,data_share_request) " \ + "FOREIGN KEY(app_id) " \ + "REFERENCES package_app_info(app_id) " \ + "ON DELETE CASCADE)" + +static int __insert_uiapplication_info(manifest_x *mfx); +static int __insert_serviceapplication_info(manifest_x *mfx); +static int __insert_uiapplication_appsvc_info(manifest_x *mfx); +static int __insert_serviceapplication_appsvc_info(manifest_x *mfx); +static int __insert_uiapplication_share_allowed_info(manifest_x *mfx); +static int __insert_serviceapplication_share_allowed_info(manifest_x *mfx); +static int __insert_uiapplication_share_request_info(manifest_x *mfx); +static int __insert_serviceapplication_share_request_info(manifest_x *mfx); +static void __insert_serviceapplication_locale_info(gpointer data, gpointer userdata); +static void __insert_uiapplication_locale_info(gpointer data, gpointer userdata); +static void __insert_pkglocale_info(gpointer data, gpointer userdata); +static int __insert_manifest_info_in_db(manifest_x *mfx); +static int __update_manifest_info_in_db(manifest_x *mfx); +static int __delete_manifest_info_from_db(manifest_x *mfx); +static int __initialize_package_info_db(); +static int __initialize_package_localized_info_db(); +static int __initialize_package_app_info_db(); +static int __initialize_package_app_localized_info_db(); +static int __initialize_package_app_app_svc_db(); +static int __initialize_package_app_share_allowed_db(); +static int __initialize_package_app_share_request_db(); +static int __exec_query(char *query); +static void __extract_data(gpointer data, label_x *lbl, license_x *lcn, icon_x *icn, description_x *dcn, author_x *ath, + char **label, char **license, char **icon, char **description, char **author); + +static gint __comparefunc(gconstpointer a, gconstpointer b, gpointer userdata); +static void __trimfunc1(gpointer data, gpointer userdata); +static void __trimfunc2(gpointer data, gpointer userdata); +static GList *__create_locale_list(GList *locale, label_x *lbl, license_x *lcn, icon_x *icn, description_x *dcn, author_x *ath); + +static int __initialize_package_info_db() +{ + char *error_message = NULL; + if (SQLITE_OK != + sqlite3_exec(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_INFO, + NULL, NULL, &error_message)) { + DBG("Don't execute query = %s error message = %s\n", + QUERY_CREATE_TABLE_PACKAGE_INFO, error_message); + sqlite3_free(error_message); + return -1; + } + sqlite3_free(error_message); + return 0; +} + +static int __initialize_package_localized_info_db() +{ + char *error_message = NULL; + if (SQLITE_OK != + sqlite3_exec(pkgmgr_parser_db, + QUERY_CREATE_TABLE_PACKAGE_LOCALIZED_INFO, NULL, NULL, + &error_message)) { + DBG("Don't execute query = %s error message = %s\n", + QUERY_CREATE_TABLE_PACKAGE_LOCALIZED_INFO, + error_message); + sqlite3_free(error_message); + return -1; + } + sqlite3_free(error_message); + return 0; +} + +static int __initialize_package_app_info_db() +{ + char *error_message = NULL; + if (SQLITE_OK != + sqlite3_exec(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_INFO, + NULL, NULL, &error_message)) { + DBG("Don't execute query = %s error message = %s\n", + QUERY_CREATE_TABLE_PACKAGE_APP_INFO, error_message); + sqlite3_free(error_message); + return -1; + } + sqlite3_free(error_message); + return 0; +} + +static int __initialize_package_app_localized_info_db() +{ + char *error_message = NULL; + if (SQLITE_OK != + sqlite3_exec(pkgmgr_parser_db, + QUERY_CREATE_TABLE_PACKAGE_APP_LOCALIZED_INFO, NULL, + NULL, &error_message)) { + DBG("Don't execute query = %s error message = %s\n", + QUERY_CREATE_TABLE_PACKAGE_APP_LOCALIZED_INFO, + error_message); + sqlite3_free(error_message); + return -1; + } + sqlite3_free(error_message); + return 0; +} + +static int __initialize_package_app_app_svc_db() +{ + char *error_message = NULL; + if (SQLITE_OK != + sqlite3_exec(pkgmgr_parser_db, + QUERY_CREATE_TABLE_PACKAGE_APP_APP_SVC, NULL, NULL, + &error_message)) { + DBG("Don't execute query = %s error message = %s\n", + QUERY_CREATE_TABLE_PACKAGE_APP_APP_SVC, error_message); + sqlite3_free(error_message); + return -1; + } + sqlite3_free(error_message); + return 0; +} + +static int __initialize_package_app_share_allowed_db() +{ + char *error_message = NULL; + if (SQLITE_OK != + sqlite3_exec(pkgmgr_parser_db, + QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_ALLOWED, NULL, + NULL, &error_message)) { + DBG("Don't execute query = %s error message = %s\n", + QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_ALLOWED, + error_message); + sqlite3_free(error_message); + return -1; + } + sqlite3_free(error_message); + return 0; +} + +static int __initialize_package_app_share_request_db() +{ + char *error_message = NULL; + if (SQLITE_OK != + sqlite3_exec(pkgmgr_parser_db, + QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_REQUEST, NULL, + NULL, &error_message)) { + DBG("Don't execute query = %s error message = %s\n", + QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_REQUEST, + error_message); + sqlite3_free(error_message); + return -1; + } + sqlite3_free(error_message); + return 0; +} + +static int __exec_query(char *query) +{ + char *error_message = NULL; + if (SQLITE_OK != + sqlite3_exec(pkgmgr_parser_db, query, NULL, NULL, &error_message)) { + DBG("Don't execute query = %s error message = %s\n", query, + error_message); + sqlite3_free(error_message); + return -1; + } + sqlite3_free(error_message); + return 0; +} +static GList *__create_locale_list(GList *locale, label_x *lbl, license_x *lcn, icon_x *icn, description_x *dcn, author_x *ath) +{ + + while(lbl != NULL) + { + if (lbl->lang) + locale = g_list_insert_sorted_with_data(locale, (gpointer)lbl->lang, __comparefunc, NULL); + lbl = lbl->next; + } + while(lcn != NULL) + { + if (lcn->lang) + locale = g_list_insert_sorted_with_data(locale, (gpointer)lcn->lang, __comparefunc, NULL); + lcn = lcn->next; + } + while(icn != NULL) + { + if (icn->lang) + locale = g_list_insert_sorted_with_data(locale, (gpointer)icn->lang, __comparefunc, NULL); + icn = icn->next; + } + while(dcn != NULL) + { + if (dcn->lang) + locale = g_list_insert_sorted_with_data(locale, (gpointer)dcn->lang, __comparefunc, NULL); + dcn = dcn->next; + } + while(ath != NULL) + { + if (ath->lang) + locale = g_list_insert_sorted_with_data(locale, (gpointer)ath->lang, __comparefunc, NULL); + ath = ath->next; + } + return locale; + +} + +static void __printfunc(gpointer data, gpointer userdata) +{ + DBG("%s ", (char*)data); +} + +static void __trimfunc1(gpointer data, gpointer userdata) +{ + if (prev) { + if (strcmp((char *)data, prev) == 0) { + pkglocale = g_list_remove(pkglocale, data); + } else + prev = (char *)data; + } + else + prev = (char *)data; +} + +static void __trimfunc2(gpointer data, gpointer userdata) +{ + if (prev) { + if (strcmp((char *)data, prev) == 0) { + applocale = g_list_remove(applocale, data); + } else + prev = (char *)data; + } + else + prev = (char *)data; +} + +static gint __comparefunc(gconstpointer a, gconstpointer b, gpointer userdata) +{ + if (a == NULL || b == NULL) + return 0; + if (strcmp((char*)a, (char*)b) == 0) + return 0; + if (strcmp((char*)a, (char*)b) < 0) + return -1; + if (strcmp((char*)a, (char*)b) > 0) + return 1; +} + +static void __extract_data(gpointer data, label_x *lbl, license_x *lcn, icon_x *icn, description_x *dcn, author_x *ath, + char **label, char **license, char **icon, char **description, char **author) +{ + while(lbl != NULL) + { + if (lbl->lang) { + if (strcmp(lbl->lang, (char *)data) == 0) { + *label = (char*)lbl->text; + break; + } + } + lbl = lbl->next; + } + while(lcn != NULL) + { + if (lcn->lang) { + if (strcmp(lcn->lang, (char *)data) == 0) { + *license = (char*)lcn->text; + break; + } + } + lcn = lcn->next; + } + while(icn != NULL) + { + if (icn->lang) { + if (strcmp(icn->lang, (char *)data) == 0) { + *icon = (char*)icn->text; + break; + } + } + icn = icn->next; + } + while(dcn != NULL) + { + if (dcn->lang) { + if (strcmp(dcn->lang, (char *)data) == 0) { + *description = (char*)dcn->text; + break; + } + } + dcn = dcn->next; + } + while(ath != NULL) + { + if (ath->lang) { + if (strcmp(ath->lang, (char *)data) == 0) { + *author = (char*)ath->text; + break; + } + } + ath = ath->next; + } + +} + +static void __insert_pkglocale_info(gpointer data, gpointer userdata) +{ + int ret = -1; + char *label = NULL; + char *icon = NULL; + char *description = NULL; + char *license = NULL; + char *author = NULL; + char query[MAX_QUERY_LEN] = {'\0'}; + + manifest_x *mfx = (manifest_x *)userdata; + label_x *lbl = mfx->label; + license_x *lcn = mfx->license; + icon_x *icn = mfx->icon; + description_x *dcn = mfx->description; + author_x *ath = mfx->author; + + __extract_data(data, lbl, lcn, icn, dcn, ath, &label, &license, &icon, &description, &author); + if (!label && !description && !icon && !license && !author) + return; + snprintf(query, MAX_QUERY_LEN, "insert into package_localized_info(package, package_locale, " \ + "package_label, package_icon, package_description, package_license, package_author) values " \ + "('%s', '%s', '%s', '%s', '%s', '%s', '%s')", mfx->package, (char*)data, + label, icon, description, license, author); + ret = __exec_query(query); + if (ret == -1) + DBG("Package Localized Info DB Insert failed\n"); +} + +static void __insert_uiapplication_locale_info(gpointer data, gpointer userdata) +{ + int ret = -1; + char *label = NULL; + char *icon = NULL; + char query[MAX_QUERY_LEN] = {'\0'}; + + uiapplication_x *up = (uiapplication_x*)userdata; + label_x *lbl = up->label; + icon_x *icn = up->icon; + + __extract_data(data, lbl, NULL, icn, NULL, NULL, &label, NULL, &icon, NULL, NULL); + if (!label && !icon) + return; + snprintf(query, MAX_QUERY_LEN, "insert into package_app_localized_info(app_id, app_locale, " \ + "app_label, app_icon) values " \ + "('%s', '%s', '%s', '%s')", up->appid, (char*)data, + label, icon); + ret = __exec_query(query); + if (ret == -1) + DBG("Package UiApp Localized Info DB Insert failed\n"); + +} + +static void __insert_serviceapplication_locale_info(gpointer data, gpointer userdata) +{ + int ret = -1; + char *icon = NULL; + char *label = NULL; + char query[MAX_QUERY_LEN] = {'\0'}; + + serviceapplication_x *sp = (serviceapplication_x*)userdata; + label_x *lbl = sp->label; + icon_x *icn = sp->icon; + + __extract_data(data, lbl, NULL, icn, NULL, NULL, &label, NULL, &icon, NULL, NULL); + if (!icon && !label) + return; + snprintf(query, MAX_QUERY_LEN, "insert into package_app_localized_info(app_id, app_locale, " \ + "app_label, app_icon) values " \ + "('%s', '%s', '%s', '%s')", sp->appid, (char*)data, + label, icon); + ret = __exec_query(query); + if (ret == -1) + DBG("Package ServiceApp Localized Info DB Insert failed\n"); +} + +static int __insert_uiapplication_info(manifest_x *mfx) +{ + uiapplication_x *up = mfx->uiapplication; + int ret = -1; + char query[MAX_QUERY_LEN] = {'\0'}; + while(up != NULL) + { + snprintf(query, MAX_QUERY_LEN, + "insert into package_app_info(app_id, app_component, app_exec, app_nodisplay, app_type, app_onboot, " \ + "app_multiple, app_autorestart, app_taskmanage, package) " \ + "values('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",\ + up->appid, "uiapp", up->exec, up->nodisplay, up->type, "\0", up->multiple, + "\0", up->taskmanage, mfx->package); + ret = __exec_query(query); + if (ret == -1) { + DBG("Package UiApp Info DB Insert Failed\n"); + return -1; + } + up = up->next; + memset(query, '\0', MAX_QUERY_LEN); + } + return 0; +} + +static int __insert_uiapplication_appsvc_info(manifest_x *mfx) +{ + uiapplication_x *up = mfx->uiapplication; + appsvc_x *asvc = NULL; + operation_x *op = NULL; + mime_x *mi = NULL; + uri_x *ui = NULL; + int ret = -1; + char query[MAX_QUERY_LEN] = {'\0'}; + char *operation = NULL; + char *mime = NULL; + char *uri = NULL; + while(up != NULL) + { + asvc = up->appsvc; + while(asvc != NULL) + { + op = asvc->operation; + while(op != NULL) + { + if (op) + operation = op->name; + mi = asvc->mime; + + do + { + if (mi) + mime = mi->name; + ui = asvc->uri; + do + { + if (ui) + uri = ui->name; + snprintf(query, MAX_QUERY_LEN, + "insert into package_app_app_svc(app_id, operation, uri_scheme, mime_type) " \ + "values('%s', '%s', '%s', '%s')",\ + up->appid, operation, uri, mime); + ret = __exec_query(query); + if (ret == -1) { + DBG("Package UiApp AppSvc DB Insert Failed\n"); + return -1; + } + memset(query, '\0', MAX_QUERY_LEN); + if (ui) + ui = ui->next; + uri = NULL; + } while(ui != NULL); + if (mi) + mi = mi->next; + mime = NULL; + }while(mi != NULL); + if (op) + op = op->next; + operation = NULL; + } + asvc = asvc->next; + } + up = up->next; + } + return 0; +} + +static int __insert_uiapplication_share_request_info(manifest_x *mfx) +{ + uiapplication_x *up = mfx->uiapplication; + datashare_x *ds = NULL; + request_x *rq = NULL; + int ret = -1; + char query[MAX_QUERY_LEN] = {'\0'}; + while(up != NULL) + { + ds = up->datashare; + while(ds != NULL) + { + rq = ds->request; + while(rq != NULL) + { + snprintf(query, MAX_QUERY_LEN, + "insert into package_app_share_request(app_id, data_share_request) " \ + "values('%s', '%s')",\ + up->appid, rq->text); + ret = __exec_query(query); + if (ret == -1) { + DBG("Package UiApp Share Request DB Insert Failed\n"); + return -1; + } + memset(query, '\0', MAX_QUERY_LEN); + rq = rq->next; + } + ds = ds->next; + } + up = up->next; + } + return 0; +} + +static int __insert_uiapplication_share_allowed_info(manifest_x *mfx) +{ + uiapplication_x *up = mfx->uiapplication; + datashare_x *ds = NULL; + define_x *df = NULL; + allowed_x *al = NULL; + int ret = -1; + char query[MAX_QUERY_LEN] = {'\0'}; + while(up != NULL) + { + ds = up->datashare; + while(ds != NULL) + { + df = ds->define; + while(df != NULL) + { + al = df->allowed; + while(al != NULL) + { + snprintf(query, MAX_QUERY_LEN, + "insert into package_app_share_allowed(app_id, data_share_path, data_share_allowed) " \ + "values('%s', '%s', '%s')",\ + up->appid, df->path, al->text); + ret = __exec_query(query); + if (ret == -1) { + DBG("Package UiApp Share Allowed DB Insert Failed\n"); + return -1; + } + memset(query, '\0', MAX_QUERY_LEN); + al = al->next; + } + df = df->next; + } + ds = ds->next; + } + up = up->next; + } + return 0; +} + +static int __insert_serviceapplication_info(manifest_x *mfx) +{ + serviceapplication_x *sp = mfx->serviceapplication; + int ret = -1; + char query[MAX_QUERY_LEN] = {'\0'}; + while(sp != NULL) + { + snprintf(query, MAX_QUERY_LEN, + "insert into package_app_info(app_id, app_component, app_exec, app_nodisplay, app_type, app_onboot, " \ + "app_multiple, app_autorestart, package) " \ + "values('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",\ + sp->appid, "svcapp", sp->exec, "\0", sp->type, sp->onboot, "\0", + sp->autorestart, mfx->package); + ret = __exec_query(query); + if (ret == -1) { + DBG("Package ServiceApp Info DB Insert Failed\n"); + return -1; + } + sp = sp->next; + memset(query, '\0', MAX_QUERY_LEN); + } + return 0; +} + +static int __insert_serviceapplication_appsvc_info(manifest_x *mfx) +{ + serviceapplication_x *sp = mfx->serviceapplication; + appsvc_x *asvc = NULL; + int ret = -1; + char query[MAX_QUERY_LEN] = {'\0'}; + operation_x *op = NULL; + mime_x *mi = NULL; + uri_x *ui = NULL; + char *operation = NULL; + char *mime = NULL; + char *uri = NULL; + while(sp != NULL) + { + asvc = sp->appsvc; + while(asvc != NULL) + { + op = asvc->operation; + while(op != NULL) + { + if (op) + operation = op->name; + mi = asvc->mime; + do + { + if (mi) + mime = mi->name; + ui = asvc->uri; + do + { + if (ui) + uri = ui->name; + snprintf(query, MAX_QUERY_LEN, + "insert into package_app_app_svc(app_id, operation, uri_scheme, mime_type) " \ + "values('%s', '%s', '%s', '%s')",\ + sp->appid, operation, uri, mime); + ret = __exec_query(query); + if (ret == -1) { + DBG("Package UiApp AppSvc DB Insert Failed\n"); + return -1; + } + memset(query, '\0', MAX_QUERY_LEN); + if (ui) + ui = ui->next; + uri = NULL; + } while(ui != NULL); + if (mi) + mi = mi->next; + mime = NULL; + }while(mi != NULL); + if (op) + op = op->next; + operation = NULL; + } + asvc = asvc->next; + } + sp = sp->next; + } + return 0; +} + + + +static int __insert_serviceapplication_share_request_info(manifest_x *mfx) +{ + serviceapplication_x *sp = mfx->serviceapplication; + datashare_x *ds = NULL; + request_x *rq = NULL; + int ret = -1; + char query[MAX_QUERY_LEN] = {'\0'}; + while(sp != NULL) + { + ds = sp->datashare; + while(ds != NULL) + { + rq = ds->request; + while(rq != NULL) + { + snprintf(query, MAX_QUERY_LEN, + "insert into package_app_share_request(app_id, data_share_request) " \ + "values('%s', '%s')",\ + sp->appid, rq->text); + ret = __exec_query(query); + if (ret == -1) { + DBG("Package ServiceApp Share Request DB Insert Failed\n"); + return -1; + } + memset(query, '\0', MAX_QUERY_LEN); + rq = rq->next; + } + ds = ds->next; + } + sp = sp->next; + } + return 0; +} + + + +static int __insert_serviceapplication_share_allowed_info(manifest_x *mfx) +{ + serviceapplication_x *sp = mfx->serviceapplication; + datashare_x *ds = NULL; + define_x *df = NULL; + allowed_x *al = NULL; + int ret = -1; + char query[MAX_QUERY_LEN] = {'\0'}; + while(sp != NULL) + { + ds = sp->datashare; + while(ds != NULL) + { + df = ds->define; + while(df != NULL) + { + al = df->allowed; + while(al != NULL) + { + snprintf(query, MAX_QUERY_LEN, + "insert into package_app_share_allowed(app_id, data_share_path, data_share_allowed) " \ + "values('%s', '%s', '%s')",\ + sp->appid, df->path, al->text); + ret = __exec_query(query); + if (ret == -1) { + DBG("Package App Share Allowed DB Insert Failed\n"); + return -1; + } + memset(query, '\0', MAX_QUERY_LEN); + al = al->next; + } + df = df->next; + } + ds = ds->next; + } + sp = sp->next; + } + return 0; +} + +static int __insert_manifest_info_in_db(manifest_x *mfx) +{ + label_x *lbl = mfx->label; + license_x *lcn = mfx->license; + icon_x *icn = mfx->icon; + description_x *dcn = mfx->description; + author_x *ath = mfx->author; + uiapplication_x *up = mfx->uiapplication; + serviceapplication_x *sp = mfx->serviceapplication; + char query[MAX_QUERY_LEN] = { '\0' }; + int ret = -1; + char *type = NULL; + char *auth_name = NULL; + char *auth_email = NULL; + char *auth_href = NULL; + if (ath) { + if (ath->text) + auth_name = ath->text; + if (ath->email) + auth_email = ath->email; + if (ath->href) + auth_href = ath->href; + } + + /*Insert in the package_info DB*/ + if (mfx->type) + type = strdup(mfx->type); + else + type = strdup("rpm"); + snprintf(query, MAX_QUERY_LEN, + "insert into package_info(package, package_type, package_version, install_location, " \ + "package_removable, package_preload, package_readonly, author_name, author_email, author_href) " \ + "values('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",\ + mfx->package, type, mfx->version, mfx->installlocation, mfx->removable, mfx->preload, + mfx->readonly, auth_name, auth_email, auth_href); + ret = __exec_query(query); + if (ret == -1) { + DBG("Package Info DB Insert Failed\n"); + if (type) { + free(type); + type = NULL; + } + return -1; + } + if (type) { + free(type); + type = NULL; + } + /*Insert the package locale and app locale info */ + pkglocale = __create_locale_list(pkglocale, lbl, lcn, icn, dcn, ath); + g_list_foreach(pkglocale, __trimfunc1, NULL); + prev = NULL; + + while(up != NULL) + { + applocale = __create_locale_list(applocale, up->label, NULL, up->icon, NULL, NULL); + up = up->next; + } + while(sp != NULL) + { + applocale = __create_locale_list(applocale, sp->label, NULL, sp->icon, NULL, NULL); + sp = sp->next; + } + g_list_foreach(applocale, __trimfunc2, NULL); + prev = NULL; + + /*g_list_foreach(pkglocale, __printfunc, NULL);*/ + /*DBG("\n");*/ + /*g_list_foreach(applocale, __printfunc, NULL);*/ + + /*package locale info*/ + g_list_foreach(pkglocale, __insert_pkglocale_info, (gpointer)mfx); + /*native app locale info*/ + up = mfx->uiapplication; + while(up != NULL) + { + g_list_foreach(applocale, __insert_uiapplication_locale_info, (gpointer)up); + up = up->next; + } + /*agent app locale info*/ + sp = mfx->serviceapplication; + while(sp != NULL) + { + g_list_foreach(applocale, __insert_serviceapplication_locale_info, (gpointer)sp); + sp = sp->next; + } + + g_list_free(pkglocale); + pkglocale = NULL; + g_list_free(applocale); + applocale = NULL; + + + /*Insert in the package_app_info DB*/ + ret = __insert_uiapplication_info(mfx); + if (ret == -1) + return -1; + ret = __insert_serviceapplication_info(mfx); + if (ret == -1) + return -1; + + /*Insert in the package_app_app_svc DB*/ + ret = __insert_uiapplication_appsvc_info(mfx); + if (ret == -1) + return -1; + ret = __insert_serviceapplication_appsvc_info(mfx); + if (ret == -1) + return -1; + + /*Insert in the package_app_share_allowed DB*/ + ret = __insert_uiapplication_share_allowed_info(mfx); + if (ret == -1) + return -1; + ret = __insert_serviceapplication_share_allowed_info(mfx); + if (ret == -1) + return -1; + + /*Insert in the package_app_share_request DB*/ + ret = __insert_uiapplication_share_request_info(mfx); + if (ret == -1) + return -1; + ret = __insert_serviceapplication_share_request_info(mfx); + if (ret == -1) + return -1; + + return 0; + +} + +static int __delete_manifest_info_from_db(manifest_x *mfx) +{ + char query[MAX_QUERY_LEN] = { '\0' }; + int ret = -1; + uiapplication_x *up = mfx->uiapplication; + serviceapplication_x *sp = mfx->serviceapplication; + + /*Delete from Package Info DB*/ + snprintf(query, MAX_QUERY_LEN, + "delete from package_info where package='%s'", mfx->package); + ret = __exec_query(query); + if (ret == -1) { + DBG("Package Info DB Delete Failed\n"); + return -1; + } + memset(query, '\0', MAX_QUERY_LEN); + + /*Delete from Package Localized Info*/ + snprintf(query, MAX_QUERY_LEN, + "delete from package_localized_info where package='%s'", mfx->package); + ret = __exec_query(query); + if (ret == -1) { + DBG("Package Localized Info DB Delete Failed\n"); + return -1; + } + memset(query, '\0', MAX_QUERY_LEN); + + /*Delete from Package App Info*/ + while(up != NULL) + { + snprintf(query, MAX_QUERY_LEN, + "delete from package_app_info where app_id='%s'", up->appid); + ret = __exec_query(query); + if (ret == -1) { + DBG("Package App Info DB Delete Failed\n"); + return -1; + } + memset(query, '\0', MAX_QUERY_LEN); + up = up->next; + } + while(sp != NULL) + { + snprintf(query, MAX_QUERY_LEN, + "delete from package_app_info where app_id='%s'", sp->appid); + ret = __exec_query(query); + if (ret == -1) { + DBG("Package App Info DB Delete Failed\n"); + return -1; + } + memset(query, '\0', MAX_QUERY_LEN); + sp = sp->next; + } + + /*Delete from Package App Localized Info*/ + up = mfx->uiapplication; + sp = mfx->serviceapplication; + while(up != NULL) + { + snprintf(query, MAX_QUERY_LEN, + "delete from package_app_localized_info where app_id='%s'", up->appid); + ret = __exec_query(query); + if (ret == -1) { + DBG("Package App Localized Info DB Delete Failed\n"); + return -1; + } + memset(query, '\0', MAX_QUERY_LEN); + up = up->next; + } + while(sp != NULL) + { + snprintf(query, MAX_QUERY_LEN, + "delete from package_app_localized_info where app_id='%s'", sp->appid); + ret = __exec_query(query); + if (ret == -1) { + DBG("Package App Localized Info DB Delete Failed\n"); + return -1; + } + memset(query, '\0', MAX_QUERY_LEN); + sp = sp->next; + } + + /*Delete from Package App App-Svc*/ + up = mfx->uiapplication; + sp = mfx->serviceapplication; + while(up != NULL) + { + snprintf(query, MAX_QUERY_LEN, + "delete from package_app_app_svc where app_id='%s'", up->appid); + ret = __exec_query(query); + if (ret == -1) { + DBG("Package App App-Svc DB Delete Failed\n"); + return -1; + } + memset(query, '\0', MAX_QUERY_LEN); + up = up->next; + } + while(sp != NULL) + { + snprintf(query, MAX_QUERY_LEN, + "delete from package_app_app_svc where app_id='%s'", sp->appid); + ret = __exec_query(query); + if (ret == -1) { + DBG("Package App App-Svc DB Delete Failed\n"); + return -1; + } + memset(query, '\0', MAX_QUERY_LEN); + sp = sp->next; + } + + /*Delete from Package App Share Allowed*/ + up = mfx->uiapplication; + sp = mfx->serviceapplication; + while(up != NULL) + { + snprintf(query, MAX_QUERY_LEN, + "delete from package_app_share_allowed where app_id='%s'", up->appid); + ret = __exec_query(query); + if (ret == -1) { + DBG("Package App Share Allowed DB Delete Failed\n"); + return -1; + } + memset(query, '\0', MAX_QUERY_LEN); + up = up->next; + } + while(sp != NULL) + { + snprintf(query, MAX_QUERY_LEN, + "delete from package_app_share_allowed where app_id='%s'", sp->appid); + ret = __exec_query(query); + if (ret == -1) { + DBG("Package App Share Allowed DB Delete Failed\n"); + return -1; + } + memset(query, '\0', MAX_QUERY_LEN); + sp = sp->next; + } + + /*Delete from Package App Share Request*/ + up = mfx->uiapplication; + sp = mfx->serviceapplication; + while(up != NULL) + { + snprintf(query, MAX_QUERY_LEN, + "delete from package_app_share_request where app_id='%s'", up->appid); + ret = __exec_query(query); + if (ret == -1) { + DBG("Package App Share Request DB Delete Failed\n"); + return -1; + } + memset(query, '\0', MAX_QUERY_LEN); + up = up->next; + } + while(sp != NULL) + { + snprintf(query, MAX_QUERY_LEN, + "delete from package_app_share_request where app_id='%s'", sp->appid); + ret = __exec_query(query); + if (ret == -1) { + DBG("Package App Share Request DB Delete Failed\n"); + return -1; + } + memset(query, '\0', MAX_QUERY_LEN); + sp = sp->next; + } + return 0; +} + + +int pkgmgr_parser_initialize_db() +{ + int ret = -1; + ret = __initialize_package_info_db(); + if (ret == -1) { + DBG("package info DB initialization failed\n"); + return ret; + } + ret = __initialize_package_localized_info_db(); + if (ret == -1) { + DBG("package localized info DB initialization failed\n"); + return ret; + } + ret = __initialize_package_app_info_db(); + if (ret == -1) { + DBG("package app info DB initialization failed\n"); + return ret; + } + ret = __initialize_package_app_localized_info_db(); + if (ret == -1) { + DBG("package app localized info DB initialization failed\n"); + return ret; + } + ret = __initialize_package_app_app_svc_db(); + if (ret == -1) { + DBG("package app app svc DB initialization failed\n"); + return ret; + } + ret = __initialize_package_app_share_allowed_db(); + if (ret == -1) { + DBG("package app share allowed DB initialization failed\n"); + return ret; + } + ret = __initialize_package_app_share_request_db(); + if (ret == -1) { + DBG("package app share request DB initialization failed\n"); + return ret; + } + return 0; +} + +int pkgmgr_parser_check_and_create_db() +{ + int ret = -1; + if (access(PKGMGR_PARSER_DB_FILE, F_OK) == 0) { + ret = + db_util_open(PKGMGR_PARSER_DB_FILE, &pkgmgr_parser_db, + DB_UTIL_REGISTER_HOOK_METHOD); + if (ret != SQLITE_OK) { + DBG("connect db [%s] failed!\n", + PKGMGR_PARSER_DB_FILE); + return -1; + } + return 0; + } + DBG("Pkgmgr DB does not exists. Create one!!\n"); + + ret = + db_util_open(PKGMGR_PARSER_DB_FILE, &pkgmgr_parser_db, + DB_UTIL_REGISTER_HOOK_METHOD); + + if (ret != SQLITE_OK) { + DBG("connect db [%s] failed!\n", PKGMGR_PARSER_DB_FILE); + return -1; + } + return 0; +} + +API int pkgmgr_parser_insert_manifest_info_in_db(manifest_x *mfx) +{ + if (mfx == NULL) { + DBG("manifest pointer is NULL\n"); + return -1; + } + int ret = -1; + ret = pkgmgr_parser_check_and_create_db(); + if (ret == -1) { + DBG("Failed to open DB\n"); + return ret; + } + ret = pkgmgr_parser_initialize_db(); + if (ret == -1) + return ret; + /*Begin transaction*/ + ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL); + if (ret != SQLITE_OK) { + DBG("Failed to begin transaction\n"); + sqlite3_close(pkgmgr_parser_db); + return -1; + } + DBG("Transaction Begin\n"); + ret = __insert_manifest_info_in_db(mfx); + if (ret == -1) { + DBG("Insert into DB failed. Rollback now\n"); + sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL); + sqlite3_close(pkgmgr_parser_db); + return -1; + } + /*Commit transaction*/ + ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL); + if (ret != SQLITE_OK) { + DBG("Failed to commit transaction. Rollback now\n"); + sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL); + sqlite3_close(pkgmgr_parser_db); + return -1; + } + DBG("Transaction Commit and End\n"); + sqlite3_close(pkgmgr_parser_db); + return 0; +} + +API int pkgmgr_parser_update_manifest_info_in_db(manifest_x *mfx) +{ + if (mfx == NULL) { + DBG("manifest pointer is NULL\n"); + return -1; + } + int ret = -1; + ret = pkgmgr_parser_check_and_create_db(); + if (ret == -1) { + DBG("Failed to open DB\n"); + return ret; + } + ret = pkgmgr_parser_initialize_db(); + if (ret == -1) + return ret; + + /*Begin transaction*/ + ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL); + if (ret != SQLITE_OK) { + DBG("Failed to begin transaction\n"); + sqlite3_close(pkgmgr_parser_db); + return -1; + } + DBG("Transaction Begin\n"); + ret = __delete_manifest_info_from_db(mfx); + if (ret == -1) { + DBG("Delete from DB failed. Rollback now\n"); + sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL); + sqlite3_close(pkgmgr_parser_db); + return -1; + } + ret = __insert_manifest_info_in_db(mfx); + if (ret == -1) { + DBG("Insert into DB failed. Rollback now\n"); + sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL); + sqlite3_close(pkgmgr_parser_db); + return -1; + } + + /*Commit transaction*/ + ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL); + if (ret != SQLITE_OK) { + DBG("Failed to commit transaction. Rollback now\n"); + sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL); + sqlite3_close(pkgmgr_parser_db); + return -1; + } + DBG("Transaction Commit and End\n"); + sqlite3_close(pkgmgr_parser_db); + return 0; +} + +API int pkgmgr_parser_delete_manifest_info_from_db(manifest_x *mfx) +{ + if (mfx == NULL) { + DBG("manifest pointer is NULL\n"); + return -1; + } + int ret = -1; + ret = pkgmgr_parser_check_and_create_db(); + if (ret == -1) { + DBG("Failed to open DB\n"); + return ret; + } + /*Begin transaction*/ + ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL); + if (ret != SQLITE_OK) { + DBG("Failed to begin transaction\n"); + sqlite3_close(pkgmgr_parser_db); + return -1; + } + DBG("Transaction Begin\n"); + ret = __delete_manifest_info_from_db(mfx); + if (ret == -1) { + DBG("Delete from DB failed. Rollback now\n"); + sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL); + sqlite3_close(pkgmgr_parser_db); + return -1; + } + /*Commit transaction*/ + ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL); + if (ret != SQLITE_OK) { + DBG("Failed to commit transaction, Rollback now\n"); + sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL); + sqlite3_close(pkgmgr_parser_db); + return -1; + } + DBG("Transaction Commit and End\n"); + sqlite3_close(pkgmgr_parser_db); + return 0; +} diff --git a/parser/pkgmgr_parser_db.h b/parser/pkgmgr_parser_db.h new file mode 100755 index 0000000..c25b96c --- /dev/null +++ b/parser/pkgmgr_parser_db.h @@ -0,0 +1,86 @@ +/* + * slp-pkgmgr + * + * Copyright (c) 2000 - 2011 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. + * + */ + + +/** + * @file pkgmgr_parser_db.h + * @author Shobhit Srivastava + * @version 0.1 + * @brief This file declares API to store/retrieve manifest data in DB + * + * @addtogroup APPLICATION_FRAMEWORK + * @{ + * + * @defgroup PackageManager + * @section Header to use them: + * @code + * #include "pkgmgr_parser_db.h" + * @endcode + * + * @addtogroup PackageManager + * @{ + */ + +#ifndef __PKGMGR_PARSER_DB_H__ +#define __PKGMGR_PARSER_DB_H__ + +#ifdef __cplusplus +extern "C" { +#endif +#include "pkgmgr_parser.h" + +/** + * @brief This API insert the parsed manifest info in db. + * + * @param[in] mfx pointer to manifest info. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_parser_insert_manifest_info_in_db(manifest_x *mfx); + +/** + * @brief This API update the parsed manifest info in db. + * + * @param[in] mfx pointer to manifest info. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_parser_update_manifest_info_in_db(manifest_x *mfx); + +/** + * @brief This API delete the parsed manifest info from db. + * + * @param[in] mfx pointer to manifest info. + * @return 0 if success, error code(<0) if fail\n +*/ +int pkgmgr_parser_delete_manifest_info_from_db(manifest_x *mfx); +/** @} */ + +int pkgmgr_parser_check_and_create_db(); +int pkgmgr_parser_initialize_db(); + +#ifdef __cplusplus +} +#endif +#endif /* __PKGMGR_PARSER_DB_H__ */ +/** + * @} + * @} + */ diff --git a/parser/pkgmgr_parser_internal.h b/parser/pkgmgr_parser_internal.h new file mode 100755 index 0000000..fcc92d3 --- /dev/null +++ b/parser/pkgmgr_parser_internal.h @@ -0,0 +1,59 @@ +/* + * slp-pkgmgr + * + * Copyright (c) 2000 - 2011 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. + * + */ + + + + + +#ifndef __PKGMGR_PARSER_INTERNAL_H__ +#define __PKGMGR_PARSER_INTERNAL_H__ + + +/* debug output */ +#if defined(NDEBUG) +#define DBG(fmt, args...) +#define __SET_DBG_OUTPUT(fp) +#elif defined(PRINT) +#include +FILE *___log = NULL; +#define DBG(fmt, args...) \ + {if (!___log) ___log = stderr; \ + fprintf(___log, "[DBG:PMS]%s:%d:%s(): " fmt "\n",\ + basename(__FILE__), __LINE__, __func__, ##args); fflush(___log); } +#define __SET_DBG_OUTPUT(fp) \ + (___log = fp) +#else +#include +#undef LOG_TAG +#define LOG_TAG "PKGMGR_PARSER" + +#define DBGE(fmt, arg...) LOGE("[%s,%d] "fmt, __FUNCTION__, __LINE__, ##arg) +#define DBG(fmt, arg...) LOGD("[%s,%d] "fmt, __FUNCTION__, __LINE__, ##arg) +#endif + + +#ifndef API +#define API __attribute__ ((visibility("default"))) +#endif + + +#endif /* __PKGMGR_PARSER_INTERNAL_H__ */ diff --git a/parser/preload_list.txt.in b/parser/preload_list.txt.in new file mode 100755 index 0000000..c3cdf09 --- /dev/null +++ b/parser/preload_list.txt.in @@ -0,0 +1,85 @@ +#RW_NORM +org.tizen.ag-hello +org.tizen.app-tray +org.tizen.bluetooth-share-ui +org.tizen.bluetooth +org.tizen.browser +org.tizen.bt-appsvc +org.tizen.bt-syspopup +org.tizen.calculator +org.tizen.calendar-viewer +org.tizen.calendar +org.tizen.call-eq-analyzer +org.tizen.call +org.tizen.camera-app +org.tizen.ciss +org.tizen.clock +org.tizen.cluster-home +org.tizen.contacts-viewer +org.tizen.contacts +org.tizen.dailybriefing-accuweather +org.tizen.dailybriefing-agent +org.tizen.dailybriefing-apnews +org.tizen.dailybriefing-yfinance +org.tizen.data-provider-slave +org.tizen.download-provider +org.tizen.draglock +org.tizen.eas-appsvc +org.tizen.email +org.tizen.ereader +org.tizen.facebook-service +org.tizen.facebook +org.tizen.fileshare-service +org.tizen.fm-radio +org.tizen.gallery +org.tizen.idle-lock +org.tizen.image-editor +org.tizen.image-viewer +org.tizen.keystrings +org.tizen.kies-via-wifi +org.tizen.livebox-3d-lock +org.tizen.lowbat-syspopup +org.tizen.lowmem-syspopup +org.tizen.mdm-app +org.tizen.mdm-syspopup +org.tizen.memo +org.tizen.menu-screen +org.tizen.message +org.tizen.mobileprint +org.tizen.msg-ui-class0 +org.tizen.music-player +org.tizen.myfile +org.tizen.nfc-app +org.tizen.phone-lock +org.tizen.phone +org.tizen.picasa +org.tizen.poweroff-syspopup +org.tizen.pwlock +org.tizen.ring +org.tizen.setting +org.tizen.smartsearch +org.tizen.sound-player +org.tizen.system-panel +org.tizen.taskmgr +org.tizen.tethering +org.tizen.tickernoti-syspopup +org.tizen.usb-printer-detector +org.tizen.usbotg-syspopup +org.tizen.voicerecorder +org.tizen.volume +org.tizen.vtmain +org.tizen.wifi-direct-popup +org.tizen.wifi-direct-ugapp +org.tizen.youtube +activesync-ui +org.tizen.aospd00043#osp-app-service +org.tizen.cp7ipabg4k#osp-channel-service +org.tizen.57r43275q7#osp-connectivity-service +org.tizen.q7097a278m#osp-privilege-service +org.tizen.800ij447xl#osp-location-service +org.tizen.70lsyzhkse#osp-certmgr-service +org.tizen.nas9xepmna#osp-context-service + +#RW_RM +org.tizen.video-player +org.tizen.spotify diff --git a/parser/xml.xsd.in b/parser/xml.xsd.in new file mode 100755 index 0000000..855c21c --- /dev/null +++ b/parser/xml.xsd.in @@ -0,0 +1,5 @@ + + + + + diff --git a/pkg_path.conf.in b/pkg_path.conf.in old mode 100644 new mode 100755 index 55e8c53..765ce77 --- a/pkg_path.conf.in +++ b/pkg_path.conf.in @@ -1,6 +1,7 @@ # usage -# frontend:directory_path # backend:directory_path -frontend:/usr/etc/package-manager/frontend/ +# backendlib:directory_path +# parserlib:directory_path backend:/usr/etc/package-manager/backend/ -backendlib:/usr/etc/package-manager/backendlib/ \ No newline at end of file +backendlib:/usr/etc/package-manager/backendlib/ +parserlib:/usr/etc/package-manager/parserlib/ diff --git a/server/include/pkgmgr-server.h b/server/include/pkgmgr-server.h index e3ea298..7d73d44 100755 --- a/server/include/pkgmgr-server.h +++ b/server/include/pkgmgr-server.h @@ -49,6 +49,12 @@ typedef struct { char cookie[MAX_COOKIE_LEN]; } pm_dbus_msg; +typedef struct backend_info_t { + int pid; + char pkgtype[MAX_PKG_TYPE_LEN]; + char pkgname[MAX_PKG_NAME_LEN]; + char args[MAX_PKG_ARGS_LEN]; +}backend_info; struct pm_inotify_paths_t { int wd; diff --git a/server/include/pm-queue.h b/server/include/pm-queue.h index 2237c2d..930c247 100755 --- a/server/include/pm-queue.h +++ b/server/include/pm-queue.h @@ -37,14 +37,22 @@ typedef struct _pm_queue_data { struct _pm_queue_data *next; } pm_queue_data; -void _pm_queue_init(); -void _pm_queue_push(pm_dbus_msg item); -pm_dbus_msg _pm_queue_pop(); +typedef struct queue_info_map_t { + char pkgtype[MAX_PKG_TYPE_LEN]; + char backend[MAX_PKG_NAME_LEN]; + int queue_slot; + pm_queue_data *head; +} queue_info_map; + +int _pm_queue_init(); +int _pm_queue_push(pm_dbus_msg item); +/*position specifies the queue from which to pop request*/ +pm_dbus_msg _pm_queue_pop(int position); pm_dbus_msg _pm_queue_get_head(); void _pm_queue_final(); void _pm_queue_delete(pm_dbus_msg item); pm_queue_data *_add_node(); void _save_queue_status(pm_dbus_msg item, char *status); -void _print_queue(); +void _print_queue(int position); #endif /* _PM_QUEUE_H_ */ diff --git a/server/src/pkgmgr-server.c b/server/src/pkgmgr-server.c index 9527efb..07b4d61 100755 --- a/server/src/pkgmgr-server.c +++ b/server/src/pkgmgr-server.c @@ -85,6 +85,30 @@ static int drawing_popup = 0; /* 0 means that pkgmgr-server has no popup now */ * before the db is updated. */ int ail_db_update = 1; +/* +8 bit value to represent maximum 8 backends. +Each bit position corresponds to a queue slot which +is dynamically determined. +*/ +char backend_busy = 0; +/* +8 bit value to represent quiet mode operation for maximum 8 backends +1->quiet 0->non-quiet +Each bit position corresponds to a queue slot which +is dynamically determined. +*/ +char backend_mode = 63; /*00111111*/ +extern int num_of_backends; + +backend_info *begin; +extern queue_info_map *start; +extern int entries; +int pos = 0; +/*To store info in case of backend crash*/ +char pname[MAX_PKG_NAME_LEN] = {'\0'}; +char ptype[MAX_PKG_TYPE_LEN] = {'\0'}; +char args[MAX_PKG_ARGS_LEN] = {'\0'}; + GMainLoop *mainloop = NULL; @@ -111,14 +135,71 @@ typedef struct pm_desktop_notifier_t pm_desktop_notifier; pm_desktop_notifier desktop_notifier; pm_inotify_paths paths[DESKTOP_FILE_DIRS_NUM]; - +static int __check_backend_status_for_exit(); +static int __check_queue_status_for_exit(); +static int __check_backend_mode(); +static int __is_backend_busy(int position); +static void __set_backend_busy(int position); +static void __set_backend_free(int position); +static int __is_backend_mode_quiet(int position); +static void __set_backend_mode(int position); +static void __unset_backend_mode(int position); static void response_cb1(void *data, Evas_Object *notify, void *event_info); static void response_cb2(void *data, Evas_Object *notify, void *event_info); static int create_popup(struct appdata *ad); static void sighandler(int signo); +static int __get_position_from_pkg_type(char *pkgtype); gboolean queue_job(void *data); +gboolean send_fail_signal(void *data); +gboolean exit_server(void *data); static Eina_Bool __directory_notify(void *data, Ecore_Fd_Handler *fd_handler); +/* To check whether a particular backend is free/busy*/ +static int __is_backend_busy(int position) +{ + return backend_busy & 1<pkgtype, pkgtype, MAX_PKG_TYPE_LEN)) + return ptr->queue_slot; + else + ptr++; + + } +} + static Eina_Bool __directory_notify(void *data, Ecore_Fd_Handler *fd_handler) { ail_db_update = 0; @@ -186,7 +267,8 @@ static Eina_Bool __directory_notify(void *data, Ecore_Fd_Handler *fd_handler) continue; cut = strstr(package, ".desktop"); - *cut = '\0'; + if (cut) + *cut = '\0'; DBG("Package : %s\n", package); /* add & update */ @@ -231,7 +313,8 @@ static void response_cb1(void *data, Evas_Object *notify, void *event_info) { struct appdata *ad = (struct appdata *)data; - + int p = 0; + int ret = 0; DBG("start of response_cb()\n"); /* YES */ @@ -254,15 +337,17 @@ void response_cb1(void *data, Evas_Object *notify, void *event_info) DBG("pkg_type = [%s]\n", ad->item->pkg_type); - _pm_queue_push(*(ad->item)); + ret = _pm_queue_push(*(ad->item)); + p = __get_position_from_pkg_type(ad->item->pkg_type); + __unset_backend_mode(p); /* Free resource */ free(ad->item); evas_object_del(ad->notify); evas_object_del(ad->win); /***************/ - - g_idle_add(queue_job, NULL); + if (ret == 0) + g_idle_add(queue_job, NULL); DBG("end of response_cb()\n"); @@ -274,6 +359,7 @@ void response_cb1(void *data, Evas_Object *notify, void *event_info) static void response_cb2(void *data, Evas_Object *notify, void *event_info) { + int p = 0; struct appdata *ad = (struct appdata *)data; DBG("start of response_cb()\n"); @@ -307,14 +393,17 @@ void response_cb2(void *data, Evas_Object *notify, void *event_info) "cancel"); pkgmgr_installer_free(pi); + p = __get_position_from_pkg_type(ad->item->pkg_type); + __set_backend_mode(p); /* Free resource */ free(ad->item); evas_object_del(ad->notify); evas_object_del(ad->win); /***************/ - - g_idle_add(queue_job, NULL); + /* queue_job should be called for every request that is pushed + into queue. In "NO" case, request is not pushed so no need of + calling queue_job*/ DBG("end of response_cb()\n"); @@ -494,18 +583,73 @@ int create_popup(struct appdata *ad) return 0; } +gboolean send_fail_signal(void *data) +{ + DBG("send_fail_signal start\n"); + gboolean ret_parse; + gint argcp; + gchar **argvp; + GError *gerr = NULL; + pkgmgr_installer *pi; + pi = pkgmgr_installer_new(); + if (!pi) { + DBG("Failure in creating the pkgmgr_installer object"); + return FALSE; + } + ret_parse = g_shell_parse_argv(args, + &argcp, &argvp, &gerr); + if (FALSE == ret_parse) { + DBG("Failed to split args: %s", args); + DBG("messsage: %s", gerr->message); + pkgmgr_installer_free(pi); + return FALSE; + } + + pkgmgr_installer_receive_request(pi, argcp, argvp); + pkgmgr_installer_send_signal(pi, ptype, pname, "end", "fail"); + pkgmgr_installer_free(pi); + return FALSE; +} + static void sighandler(int signo) { int status; - pid_t pid; - - while ((pid = waitpid(-1, &status, WNOHANG)) > 0) { - DBG("child exit [%d]\n", pid); + pid_t cpid; + int i = 0; + backend_info *ptr = NULL; + ptr = begin; + + while ((cpid = waitpid(-1, &status, WNOHANG)) > 0) { + DBG("child exit [%d]\n", cpid); + if (WIFEXITED(status)) { + DBG("child NORMAL exit [%d]\n", cpid); + for(i = 0; i < num_of_backends; i++) + { + if (cpid == (ptr + i)->pid) { + __set_backend_free(i); + __set_backend_mode(i); + break; + } + } + } + else if (WIFSIGNALED(status)) { + DBG("child SIGNALED exit [%d]\n", cpid); + /*get the pkgname and pkgtype to send fail signal*/ + for(i = 0; i < num_of_backends; i++) + { + if (cpid == (ptr + i)->pid) { + __set_backend_free(i); + __set_backend_mode(i); + strncpy(pname, (ptr + i)->pkgname, MAX_PKG_NAME_LEN); + strncpy(ptype, (ptr + i)->pkgtype, MAX_PKG_TYPE_LEN); + strncpy(args, (ptr + i)->args, MAX_PKG_ARGS_LEN); + g_idle_add(send_fail_signal, NULL); + break; + } + } + } } - g_idle_add(queue_job, NULL); - - backend_flag = 0; } void req_cb(void *cb_data, const char *req_id, const int req_type, @@ -514,6 +658,7 @@ void req_cb(void *cb_data, const char *req_id, const int req_type, { static int sig_reg = 0; int err = -1; + int p = 0; DBG(">> in callback >> Got request: [%s] [%d] [%s] [%s] [%s] [%s]", req_id, req_type, pkg_type, pkg_name, args, cookie); @@ -541,6 +686,8 @@ void req_cb(void *cb_data, const char *req_id, const int req_type, DBG("signal: SIGCHLD failed\n"); } else DBG("signal: SIGCHLD succeed\n"); + if (g_timeout_add_seconds(2, exit_server, NULL)) + DBG("g_timeout_add_seconds() Added to Main Loop"); sig_reg = 1; } @@ -558,15 +705,20 @@ void req_cb(void *cb_data, const char *req_id, const int req_type, ((quiet = strstr(args, " '-q'")) && (quiet[strlen(quiet)] == '\0'))) { /* quiet mode */ - _pm_queue_push(*item); + err = _pm_queue_push(*item); + p = __get_position_from_pkg_type(item->pkg_type); + __set_backend_mode(p); /* Free resource */ free(item); - - g_idle_add(queue_job, NULL); + if (err == 0) + g_idle_add(queue_job, NULL); *ret = COMM_RET_OK; } else { /* non quiet mode */ - if (drawing_popup == 0 && backend_flag == 0) { + p = __get_position_from_pkg_type(item->pkg_type); + if (drawing_popup == 0 && + !__is_backend_busy(p) && + __check_backend_mode()) { /* if there is no popup */ ad->item = item; @@ -588,41 +740,54 @@ void req_cb(void *cb_data, const char *req_id, const int req_type, if (err != 0) { *ret = COMM_RET_ERROR; DBG("create popup failed\n"); - queue_job(NULL); - return; + /*queue_job(NULL);*/ + goto err; } else { *ret = COMM_RET_OK; } } else { + DBG("info drawing_popup:%d, __is_backend_busy(p):%d, __check_backend_mode():%d\n", + drawing_popup, __is_backend_busy(p), __check_backend_mode()); /* if popup is already being drawn */ free(item); *ret = COMM_RET_ERROR; + goto err; } } break; case COMM_REQ_TO_ACTIVATOR: /* In case of activate, there is no popup */ - _pm_queue_push(*item); + err = _pm_queue_push(*item); + p = __get_position_from_pkg_type(item->pkg_type); + __set_backend_mode(p); /* Free resource */ free(item); /* g_idle_add(queue_job, NULL); */ - queue_job(NULL); + if (err == 0) + queue_job(NULL); *ret = COMM_RET_OK; break; case COMM_REQ_TO_CLEARER: - /* In case of activate, there is no popup */ - _pm_queue_push(*item); + /* In case of clearer, there is no popup */ + err = _pm_queue_push(*item); + p = __get_position_from_pkg_type(item->pkg_type); + /*the backend shows the success/failure popup + so this request is non quiet*/ + __unset_backend_mode(p); /* Free resource */ free(item); /* g_idle_add(queue_job, NULL); */ - queue_job(NULL); + if (err == 0) + queue_job(NULL); *ret = COMM_RET_OK; break; case COMM_REQ_CANCEL: ad->item = item; _pm_queue_delete(*(ad->item)); + p = __get_position_from_pkg_type(item->pkg_type); + __unset_backend_mode(p); free(item); *ret = COMM_RET_OK; break; @@ -632,42 +797,150 @@ void req_cb(void *cb_data, const char *req_id, const int req_type, *ret = COMM_RET_ERROR; break; } +err: + if (*ret == COMM_RET_ERROR) { + DBG("Failed to handle request %s %s\n",item->pkg_type, item->pkg_name); + pkgmgr_installer *pi; + gboolean ret_parse; + gint argcp; + gchar **argvp; + GError *gerr = NULL; + + pi = pkgmgr_installer_new(); + if (!pi) { + DBG("Failure in creating the pkgmgr_installer object"); + return; + } + + ret_parse = g_shell_parse_argv(args, &argcp, &argvp, &gerr); + if (FALSE == ret_parse) { + DBG("Failed to split args: %s", args); + DBG("messsage: %s", gerr->message); + pkgmgr_installer_free(pi); + return; + } + + pkgmgr_installer_receive_request(pi, argcp, argvp); + + pkgmgr_installer_send_signal(pi, item->pkg_type, + item->pkg_name, "end", + "fail"); + + pkgmgr_installer_free(pi); + } + return; +} + +static int __check_backend_mode() +{ + int i = 0; + for(i = 0; i < num_of_backends; i++) + { + if (__is_backend_mode_quiet(i)) + continue; + else + return 0; + } + return 1; +} +static int __check_backend_status_for_exit() +{ + int i = 0; + for(i = 0; i < num_of_backends; i++) + { + if (!__is_backend_busy(i)) + continue; + else + return 0; + } + return 1; +} + +static int __check_queue_status_for_exit() +{ + pm_queue_data *head[num_of_backends]; + queue_info_map *ptr = NULL; + ptr = start; + int i = 0; + int c = 0; + int slot = -1; + for(i = 0; i < entries; i++) + { + if (ptr->queue_slot <= slot) { + ptr++; + continue; + } + else { + head[c] = ptr->head; + slot = ptr->queue_slot; + c++; + ptr++; + } + } + for(i = 0; i < num_of_backends; i++) + { + if (!head[i]) + continue; + else + return 0; + } + return 1; +} +gboolean exit_server(void *data) +{ + DBG("exit_server Start\n"); + if (__check_backend_status_for_exit() && + __check_queue_status_for_exit() && + drawing_popup == 0) { + if (!getenv("PMS_STANDALONE") && ail_db_update) { + ecore_main_loop_quit(); + return FALSE; + } + } + return TRUE; } gboolean queue_job(void *data) { /* DBG("queue_job start"); */ - + pm_dbus_msg item; + backend_info *ptr = NULL; + ptr = begin; + int x = 0; /* Pop a job from queue */ - pm_dbus_msg item = _pm_queue_get_head(); - pid_t pid; +pop: + if (!__is_backend_busy(pos % num_of_backends)) { + item = _pm_queue_pop(pos % num_of_backends); + pos = (pos + 1) % num_of_backends; + } + else { + pos = (pos + 1) % num_of_backends; + goto pop; + } + int ret = 0; char *backend_cmd = NULL; - char *exe_path = NULL; - - DBG("item.req_type=(%d) backend_flag=(%d)\n", item.req_type, - backend_flag); - - /* queue is empty and backend process is not running, quit */ - if ((item.req_type == -1) && (backend_flag == 0) && - drawing_popup == 0 && ail_db_update == 1) { - if (!getenv("PMS_STANDALONE")) - ecore_main_loop_quit(); /* Quit main loop: - go to cleanup */ - return FALSE; /* Anyway, run queue_job() again. */ - } else if (backend_flag == 1) /* backend process is running */ - return FALSE; - _pm_queue_pop(); + /* queue is empty and backend process is not running */ + if (item.req_type == -1) { + goto pop; + } + __set_backend_busy((pos + num_of_backends - 1) % num_of_backends); switch (item.req_type) { case COMM_REQ_TO_INSTALLER: DBG("installer start"); _save_queue_status(item, "processing"); DBG("saved queue status. Now try fork()"); - pid = fork(); - - switch (pid) { + /*save pkg type and pkg name for future*/ + x = (pos + num_of_backends - 1) % num_of_backends; + strncpy((ptr + x)->pkgtype, item.pkg_type, MAX_PKG_TYPE_LEN); + strncpy((ptr + x)->pkgname, item.pkg_name, MAX_PKG_NAME_LEN); + strncpy((ptr + x)->args, item.args, MAX_PKG_ARGS_LEN); + (ptr + x)->pid = fork(); + DBG("child forked [%d]\n", (ptr + x)->pid); + + switch ((ptr + x)->pid) { case 0: /* child */ DBG("before run _get_backend_cmd()"); backend_cmd = _get_backend_cmd(item.pkg_type); @@ -728,12 +1001,12 @@ gboolean queue_job(void *data) if (ret == -1) { perror("fail to exec"); - exit(SIGCHLD); + exit(1); } _save_queue_status(item, "done"); if (NULL != backend_cmd) free(backend_cmd); - exit(SIGCHLD); /* exit with SIGCHLD */ + exit(0); /* exit */ break; case -1: /* error */ @@ -742,7 +1015,6 @@ gboolean queue_job(void *data) break; default: /* parent */ - backend_flag = 1; DBG("parent \n"); _save_queue_status(item, "done"); break; @@ -750,35 +1022,40 @@ gboolean queue_job(void *data) break; case COMM_REQ_TO_ACTIVATOR: DBG("activator start"); + int val = 0; _save_queue_status(item, "processing"); DBG("saved queue status. Now try fork()"); - pid = fork(); - - switch (pid) { + /*save pkg type and pkg name for future*/ + x = (pos + num_of_backends - 1) % num_of_backends; + strncpy((ptr + x)->pkgtype, item.pkg_type, MAX_PKG_TYPE_LEN); + strncpy((ptr + x)->pkgname, item.pkg_name, MAX_PKG_NAME_LEN); + strncpy((ptr + x)->args, item.args, MAX_PKG_ARGS_LEN); + (ptr + x)->pid = fork(); + DBG("child forked [%d]\n", (ptr + x)->pid); + + switch ((ptr + x)->pid) { case 0: /* child */ - /* Execute Activator !!! */ - exe_path = __get_exe_path(item.pkg_name); - if (exe_path == NULL) - break; - if (item.args[0] == '1') /* activate */ - ret = chmod(exe_path, 0755); + val = 0; else if (item.args[0] == '0') /* deactivate */ - ret = chmod(exe_path, 0000); + val = 1; else { DBG("error in args parameter:[%c]\n", item.args[0]); - exit(SIGCHLD); + exit(1); } - free(exe_path); + DBG("inactivated val %d", val); - if (ret == -1) { - perror("fail to exec"); - exit(SIGCHLD); + ret = ail_desktop_appinfo_modify_bool(item.pkg_name, + AIL_PROP_X_SLP_INACTIVATED_BOOL, + val); + if (ret != AIL_ERROR_OK) { + perror("fail to activate/deactivte package"); + exit(1); } _save_queue_status(item, "done"); - exit(SIGCHLD); /* exit with SIGCHLD */ + exit(0); /* exit with */ break; case -1: /* error */ @@ -787,7 +1064,6 @@ gboolean queue_job(void *data) break; default: /* parent */ - backend_flag = 1; DBG("parent exit\n"); _save_queue_status(item, "done"); break; @@ -797,9 +1073,15 @@ gboolean queue_job(void *data) DBG("cleaner start"); _save_queue_status(item, "processing"); DBG("saved queue status. Now try fork()"); - pid = fork(); - - switch (pid) { + /*save pkg type and pkg name for future*/ + x = (pos + num_of_backends - 1) % num_of_backends; + strncpy((ptr + x)->pkgtype, item.pkg_type, MAX_PKG_TYPE_LEN); + strncpy((ptr + x)->pkgname, item.pkg_name, MAX_PKG_NAME_LEN); + strncpy((ptr + x)->args, item.args, MAX_PKG_ARGS_LEN); + (ptr + x)->pid = fork(); + DBG("child forked [%d]\n", (ptr + x)->pid); + + switch ((ptr + x)->pid) { case 0: /* child */ DBG("before run _get_backend_cmd()"); backend_cmd = _get_backend_cmd(item.pkg_type); @@ -860,12 +1142,12 @@ gboolean queue_job(void *data) if (ret == -1) { perror("fail to exec"); - exit(SIGCHLD); + exit(1); } _save_queue_status(item, "done"); if (NULL != backend_cmd) free(backend_cmd); - exit(SIGCHLD); /* exit with SIGCHLD */ + exit(0); /* exit */ break; case -1: /* error */ @@ -874,7 +1156,6 @@ gboolean queue_job(void *data) break; default: /* parent */ - backend_flag = 1; DBG("parent \n"); _save_queue_status(item, "done"); break; @@ -1149,6 +1430,7 @@ int main(int argc, char *argv[]) pid_t pid; char *backend_cmd = NULL; char *backend_name = NULL; + backend_info *ptr = NULL; int r; ecore_init(); @@ -1201,10 +1483,24 @@ int main(int argc, char *argv[]) } } - _pm_queue_init(); + r = _pm_queue_init(); + if (r) { + DBG("Queue Initialization Failed\n"); + return -1; + } + /*Initialize inotify to monitor desktop file updates */ _pm_desktop_file_monitor_init(); + /*Allocate memory for holding pid, pkgtype and pkgname*/ + ptr = (backend_info*)calloc(num_of_backends, sizeof(backend_info)); + if (ptr == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(ptr, '\0', num_of_backends * sizeof(backend_info)); + begin = ptr; + /* init internationalization */ r = appcore_set_i18n(PACKAGE, LOCALEDIR); if (r) @@ -1230,15 +1526,17 @@ int main(int argc, char *argv[]) pkg_mgr_set_request_callback(pkg_mgr, req_cb, &ad); DBG("pkg_mgr object is created, and request callback is registered."); -/* g_timeout_add_seconds(1, queue_job, NULL); */ - DBG("queue function is added to idler. Now run main loop."); - /* g_main_loop_run(mainloop); */ appcore_efl_main(PACKAGE, &argc, &argv, &ops); DBG("Quit main loop."); _pm_desktop_file_monitor_fini(); _pm_queue_final(); + /*Free backend info */ + if (begin) { + free(begin); + begin = NULL; + } DBG("package manager server terminated."); diff --git a/server/src/pm-queue.c b/server/src/pm-queue.c index 54f4bd6..38c772a 100755 --- a/server/src/pm-queue.c +++ b/server/src/pm-queue.c @@ -28,28 +28,263 @@ #include #include #include +#include +#include +#include #include "pkgmgr-server.h" #include "pm-queue.h" -pm_queue_data *head = NULL; +#define BACKEND_INFO_DIR "/usr/etc/package-manager/backend" -void _pm_queue_init() +static pm_queue_data *__get_head_from_pkgtype(pm_dbus_msg item); +static void __update_head_from_pkgtype(pm_queue_data *data); +static int __entry_exist(char *backend); +static int __is_pkg_supported(char *pkgtype); + +queue_info_map *start = NULL; +int entries = 0; +int slot = 0; +int num_of_backends = 0; + +/*Function to check whether a particular package type +is supported or not. It parses the queue info map +to get the information. +It will prevent the accidental hanging of server. +Returns 1 if found.*/ +static int __is_pkg_supported(char *pkgtype) { - head = NULL; + queue_info_map *ptr = NULL; + ptr = start; + int i = 0; + for(i = 0; i < entries; i++) + { + if (!strncmp(ptr->pkgtype, pkgtype, MAX_PKG_TYPE_LEN)) + return 1; + else { + ptr++; + continue; + } + } + return 0; } -void _pm_queue_push(pm_dbus_msg item) +/*tells whether a particular backend exists in the +* info map or not. +* on Success it return the queue slot of the already present entry +* on Failure -1 is returned*/ +static int __entry_exist(char *backend) +{ + queue_info_map *ptr = NULL; + ptr = start; + int i = 0; + for(i = 0; i < entries; i++) + { + if(ptr->backend) { + if (!strncmp(ptr->backend, backend, MAX_PKG_NAME_LEN)) + return ptr->queue_slot; + else { + ptr++; + continue; + } + } + ptr++; + } + return -1; +} + +/*In case of first push, it updates the queue head +and copies it to all duplicate entries in queue info map*/ +static void __update_head_from_pkgtype(pm_queue_data *data) +{ + queue_info_map *ptr = NULL; + ptr = start; + int slot = -1; + int i = 0; + for(i = 0; i < entries; i++) + { + if(ptr->pkgtype && !ptr->head) { + if (!strncmp(ptr->pkgtype, data->msg->pkg_type, MAX_PKG_TYPE_LEN)) { + ptr->head = data; + slot = ptr->queue_slot; + } + else { + ptr++; + continue; + } + } + ptr++; + } + /*update head for each duplicate entry*/ + ptr = start; + for(i = 0; i < entries; i++) + { + if(ptr->queue_slot == slot && !ptr->head) { + ptr->head = data; + } + ptr++; + } + return; +} + +/*Gets the queue head based on pkg type*/ +static pm_queue_data *__get_head_from_pkgtype(pm_dbus_msg item) +{ + queue_info_map *ptr = NULL; + ptr = start; + int i = 0; + for(i = 0; i < entries; i++) + { + if(ptr->pkgtype) { + if (!strncmp(ptr->pkgtype, item.pkg_type, MAX_PKG_TYPE_LEN)) + return ptr->head; + else { + ptr++; + continue; + } + } + ptr++; + } + return NULL; + +} + +int _pm_queue_init() +{ + /*Find the num of backends currently supported and initialize + that many queues. It is dynamically determined.*/ + struct dirent **namelist; + struct stat fileinfo; + queue_info_map *ptr = NULL; + int n = 0; + int c = 0; + int i = 0; + int ret = 0; + char abs_filename[MAX_PKG_NAME_LEN] = {'\0'}; + char buf[MAX_PKG_NAME_LEN] = {'\0'}; + n = scandir(BACKEND_INFO_DIR, &namelist, NULL, alphasort); + if (n < 0) { + perror("scandir"); + return -1; + } + i = n; + /*Find number of backends (symlinks + executables) + The /usr/etc/package-manager/backend dir should not conatin + any other file except the backends.*/ + while(n--) + { + if(!strcmp(namelist[n]->d_name, ".") || + !strcmp(namelist[n]->d_name, "..")) + continue; + snprintf(abs_filename, MAX_PKG_NAME_LEN, "%s/%s", + BACKEND_INFO_DIR, namelist[n]->d_name); + if (lstat(abs_filename, &fileinfo)) { + perror("lstat"); + continue; + } + if (S_ISDIR(fileinfo.st_mode)) + continue; + c++; + memset(abs_filename, 0x00, MAX_PKG_NAME_LEN); + } + /*Add entries to info map.*/ + ptr = (queue_info_map*)calloc(c , sizeof(queue_info_map)); + memset(ptr, '\0', c * sizeof(queue_info_map)); + start = ptr; + for(n = 0; n < c ; n++) + { + ptr->backend[0] = '\0'; + ptr->head = NULL; + ptr->queue_slot = -2;/*-1 can be error return*/ + ptr->pkgtype[0] = '\0'; + ptr++; + } + n = i; + ptr = start; + while(n--) + { + if(!strcmp(namelist[n]->d_name, ".") || + !strcmp(namelist[n]->d_name, "..")) + continue; + snprintf(abs_filename, MAX_PKG_NAME_LEN, "%s/%s", + BACKEND_INFO_DIR, namelist[n]->d_name); + if (lstat(abs_filename, &fileinfo) < 0) { + perror(abs_filename); + return -1; + } + if (S_ISDIR(fileinfo.st_mode)) + continue; + /*Found backend*/ + if (S_ISLNK(fileinfo.st_mode)) { + /*found a symlink*/ + ret = readlink(abs_filename, buf, MAX_PKG_NAME_LEN - 1); + if (ret == -1) { + perror("readlink"); + return -1; + } + buf[ret] = '\0'; + } + /*executable*/ + else { + strncpy(buf, abs_filename, MAX_PKG_NAME_LEN - 1); + } + ret = __entry_exist(buf); + if (ret == -1) { + strncpy(ptr->backend, buf, MAX_PKG_NAME_LEN - 1); + strncpy(ptr->pkgtype, namelist[n]->d_name, MAX_PKG_TYPE_LEN - 1); + ptr->queue_slot = slot; + ptr->head = NULL; + entries++; + slot++; + ptr++; + } + else { + strncpy(ptr->backend, buf, MAX_PKG_NAME_LEN - 1); + strncpy(ptr->pkgtype, namelist[n]->d_name, MAX_PKG_TYPE_LEN - 1); + ptr->queue_slot = ret; + ptr->head = NULL; + entries++; + ptr++; + } + free(namelist[n]); + memset(buf, 0x00, MAX_PKG_NAME_LEN); + continue; + } + free(namelist); + num_of_backends = slot; +#ifdef DEBUG_INFO + /*Debug info*/ + printf("Queue Info Map\n"); + printf("Number of Backends is %d\n", num_of_backends); + printf("Number of Entries is %d\n", entries); + printf("Backend\tType\tSlot\tHead\n"); + ptr = start; + for(n = 0; n < entries; n++) + { + printf("%s\t%s\t%d\t%p\n", ptr->backend, ptr->pkgtype, ptr->queue_slot, ptr->head); + ptr++; + } +#endif + return 0; +} + +int _pm_queue_push(pm_dbus_msg item) { pm_queue_data *data = NULL; pm_queue_data *cur = NULL; + pm_queue_data *tmp = NULL; + int ret = 0; + ret = __is_pkg_supported(item.pkg_type); + if (ret == 0) + return -1; - cur = head; + cur = __get_head_from_pkgtype(item); + tmp = cur; data = _add_node(); if (!data) { /* fail to allocate mem */ fprintf(stderr, "Fail to allocate memory\n"); - return; + return -1; } strncpy(data->msg->req_id, item.req_id, strlen(item.req_id)); @@ -61,26 +296,39 @@ void _pm_queue_push(pm_dbus_msg item) data->next = NULL; - if (head == NULL) /* first push */ - head = data; + if (cur == NULL) { + /* first push */ + cur = data; + __update_head_from_pkgtype(data); + } else { - while (cur->next) - cur = cur->next; + while (tmp->next) + tmp = tmp->next; - cur->next = data; + tmp->next = data; } + return 0; } -pm_dbus_msg _pm_queue_pop() +/*pop request from queue slot "position" */ +pm_dbus_msg _pm_queue_pop(int position) { pm_dbus_msg ret; pm_queue_data *cur = NULL; - - cur = head; - + pm_queue_data *saveptr = NULL; + queue_info_map *ptr = start; + int i = 0; + for(i = 0; i < entries; i++) + { + if (ptr->queue_slot == position) { + cur = ptr->head; + break; + } + ptr++; + } memset(&ret, 0x00, sizeof(pm_dbus_msg)); - if (!head) { /* queue is empty */ + if (!cur) { /* queue is empty */ ret.req_type = -1; return ret; } @@ -92,15 +340,25 @@ pm_dbus_msg _pm_queue_pop() strncpy(ret.args, cur->msg->args, strlen(cur->msg->args)); strncpy(ret.cookie, cur->msg->cookie, strlen(cur->msg->cookie)); - head = cur->next; + ptr->head = cur->next; + saveptr = ptr->head; cur->next = NULL; - free(cur->msg); free(cur); - + /*update head for each duplicate queue entry*/ + ptr = start; + for(i = 0; i < entries; i++) + { + if(ptr->queue_slot == position) { + ptr->head = saveptr; + } + ptr++; + } return ret; } +/* This function is not required*/ +#if 0 pm_dbus_msg _pm_queue_get_head() { pm_dbus_msg ret; @@ -124,39 +382,70 @@ pm_dbus_msg _pm_queue_get_head() return ret; } - +#endif +/*populate an array of all queue heads and delete them one by one*/ void _pm_queue_final() { + int c = 0; + int i = 0; + int slot = -1; pm_queue_data *cur = NULL; pm_queue_data *tail = NULL; pm_queue_data *prev = NULL; - - if (!head) { /* in case of head is NULL */ - fprintf(stderr, "queue is NULL\n"); - return; + pm_queue_data *head[num_of_backends]; + queue_info_map *ptr = NULL; + ptr = start; + + for(i = 0; i < entries; i++) + { + if (ptr->queue_slot <= slot) { + ptr++; + continue; + } + else { + head[c] = ptr->head; + slot = ptr->queue_slot; + c++; + ptr++; + } } - while (head->next) { - cur = head; - - while (cur->next) { - printf(" -- [%p]\n", cur); - prev = cur; - cur = cur->next; + c = 0; + while(c < num_of_backends) { + if (!head[c]) { /* in case of head is NULL */ + fprintf(stderr, "queue is NULL\n"); + c = c + 1; + continue; } - tail = cur; - printf("%p\n", tail); + while (head[c]->next) { + cur = head[c]->next; - free(tail->msg); - free(tail); - prev->next = NULL; - } + while (cur->next) { + printf(" -- [%p]\n", cur); + prev = cur; + cur = cur->next; + } - free(head->msg); - free(head); + tail = cur; + printf("%p\n", tail); + + free(tail->msg); + free(tail); + prev->next = NULL; + } - head = NULL; + free(head[c]->msg); + free(head[c]); + + head[c] = NULL; + c = c + 1; + } + /*Free the info map*/ + if (start) { + free(start); + start = NULL; + } } pm_queue_data *_add_node() @@ -186,22 +475,19 @@ void _pm_queue_delete(pm_dbus_msg item) /* Assume that pacakge name is unique */ pm_queue_data *cur = NULL; pm_queue_data *prev = NULL; - - cur = head; + cur = __get_head_from_pkgtype(item); prev = cur; - - while (cur->next) { - if (!strcmp(item.pkg_name, cur->msg->pkg_name)) { - prev->next = cur->next; - - free(cur->msg); - free(cur); - - break; + if (cur) { + while (cur->next) { + if (!strcmp(item.pkg_name, cur->msg->pkg_name)) { + prev->next = cur->next; + free(cur->msg); + free(cur); + break; + } + prev = cur; + cur = cur->next; } - - prev = cur; - cur = cur->next; } } @@ -224,15 +510,24 @@ void _save_queue_status(pm_dbus_msg item, char *status) fclose(fp_status); } -void _print_queue() +void _print_queue(int position) { pm_queue_data *cur = NULL; + queue_info_map *ptr = start; + int i = 0; + for(i =0; i < entries; i++) + { + if (ptr->queue_slot == position) { + cur = ptr->head; + break; + } + ptr++; + } int index = 1; - - cur = head; - - if (!cur) + if (!cur) { printf(" ** queue is NULL **\n"); + return; + } while (cur) { printf(" * queue[%d]: [%s] [%d] [%s] [%s] [%s] [%s]\n", diff --git a/tool/CMakeLists.txt b/tool/CMakeLists.txt index 97752a9..adb162f 100755 --- a/tool/CMakeLists.txt +++ b/tool/CMakeLists.txt @@ -2,10 +2,10 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TEST_CFLAGS}") #Verbose -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/client/include ${CMAKE_SOURCE_DIR}/comm) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/client/include ${CMAKE_SOURCE_DIR}/parser) INCLUDE(FindPkgConfig) -pkg_check_modules(pkgs_test REQUIRED ecore dbus-1 ail) +pkg_check_modules(pkgs_test REQUIRED ecore dbus-1 ail libxml-2.0) FOREACH(flag ${pkgs_test_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) @@ -22,12 +22,25 @@ add_executable(pkgcmd target_link_libraries(pkgcmd pkgmgr-client ${pkgs_test_LDFLAGS}) INSTALL(TARGETS pkgcmd DESTINATION bin) +add_executable(pkginfo + pkg_info.c) +target_link_libraries(pkginfo pkgmgr-client ${pkgs_test_LDFLAGS}) +INSTALL(TARGETS pkginfo DESTINATION bin) + +add_executable(pkg_initdb + pkg_initdb.c) +target_link_libraries(pkg_initdb pkgmgr_parser ${pkgs_test_LDFLAGS}) +INSTALL(TARGETS pkg_initdb DESTINATION bin) + add_executable(pkgmgr-install pkgmgr-install.c) target_link_libraries(pkgmgr-install pkgmgr-client) install(TARGETS pkgmgr-install DESTINATION bin) configure_file(org.tizen.pkgmgr-install.desktop.in ${CMAKE_BINARY_DIR}/org.tizen.pkgmgr-install.desktop @ONLY) -install(FILES ${CMAKE_BINARY_DIR}/org.tizen.pkgmgr-install.desktop DESTINATION /opt/share/applications/) +install(FILES ${CMAKE_BINARY_DIR}/org.tizen.pkgmgr-install.desktop DESTINATION /usr/share/applications/) + +configure_file(org.tizen.pkgmgr-install.xml.in ${CMAKE_BINARY_DIR}/org.tizen.pkgmgr-install.xml @ONLY) +install(FILES ${CMAKE_BINARY_DIR}/org.tizen.pkgmgr-install.xml DESTINATION /usr/share/packages/) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mime.wac.xml DESTINATION /usr/share/mime/packages/) diff --git a/tool/org.tizen.pkgmgr-install.desktop.in b/tool/org.tizen.pkgmgr-install.desktop.in index a3e63e1..5d0e4cd 100755 --- a/tool/org.tizen.pkgmgr-install.desktop.in +++ b/tool/org.tizen.pkgmgr-install.desktop.in @@ -7,4 +7,4 @@ Mimetype=application/x-deb;application/x-java-archive;text/vnd.sun.j2me.app-desc X-Tizen-TaskManage=False X-Tizen-Multiple=True X-Tizen-Removable=False -X-Tizen-SVC=http://tizen.org/appsvc/operation/view|NULL|application/x-deb;http://tizen.org/appsvc/operation/view|NULL|application/x-java-archive;http://tizen.org/appsvc/operation/view|NULL|text/vnd.sun.j2me.app-descriptor;http://tizen.org/appsvc/operation/view|NULL|application/widget;http://tizen.org/appsvc/operation/view|NULL|application/vnd.wac.widget-sharing;http://tizen.org/appsvc/operation/view|NULL|application/x-rpm;http://tizen.org/appsvc/operation/view|NULL|application/x-redhat-package-manager \ No newline at end of file +X-Tizen-SVC=http://tizen.org/appsvc/operation/view|NULL|application/x-deb;http://tizen.org/appsvc/operation/view|NULL|application/x-java-archive;http://tizen.org/appsvc/operation/view|NULL|text/vnd.sun.j2me.app-descriptor;http://tizen.org/appsvc/operation/view|NULL|application/widget;http://tizen.org/appsvc/operation/view|NULL|application/vnd.wac.widget-sharing;http://tizen.org/appsvc/operation/view|NULL|application/x-rpm;http://tizen.org/appsvc/operation/view|NULL|application/x-redhat-package-manager diff --git a/tool/org.tizen.pkgmgr-install.xml.in b/tool/org.tizen.pkgmgr-install.xml.in new file mode 100755 index 0000000..3967fcc --- /dev/null +++ b/tool/org.tizen.pkgmgr-install.xml.in @@ -0,0 +1,16 @@ + + + + Sewook Park + pkgmgr-install + + + + + + + + + + + diff --git a/tool/pkg_cmd.c b/tool/pkg_cmd.c index 356f9ae..dec17a9 100755 --- a/tool/pkg_cmd.c +++ b/tool/pkg_cmd.c @@ -46,13 +46,16 @@ static int __iter_fn(const char *pkg_type, const char *pkg_name, static int __return_cb(int req_id, const char *pkg_type, const char *pkg_name, const char *key, const char *val, const void *pmsg, void *data); +static int __convert_to_absolute_path(char *path); /* Supported options */ -const char *short_options = "iuclsd:p:t:n:qh"; +const char *short_options = "iucADlsd:p:t:n:qh"; const struct option long_options[] = { {"install", 0, NULL, 'i'}, {"uninstall", 0, NULL, 'u'}, {"clear", 0, NULL, 'c'}, + {"activate", 0, NULL, 'A'}, + {"deactivate", 0, NULL, 'D'}, {"list", 0, NULL, 'l'}, {"show", 0, NULL, 's'}, {"descriptor", 1, NULL, 'd'}, @@ -68,6 +71,8 @@ enum pm_tool_request_e { INSTALL_REQ = 1, UNINSTALL_REQ, CLEAR_REQ, + ACTIVATE_REQ, + DEACTIVATE_REQ, LIST_REQ, SHOW_REQ, HELP_REQ @@ -114,6 +119,41 @@ static int __return_cb(int req_id, const char *pkg_type, return 0; } +static int __convert_to_absolute_path(char *path) +{ + char abs[PKG_NAME_STRING_LEN_MAX] = {'\0'}; + char temp[PKG_NAME_STRING_LEN_MAX] = {'\0'}; + char *ptr = NULL; + if (path == NULL) { + printf("path is NULL\n"); + return -1; + } + strncpy(temp, path, PKG_NAME_STRING_LEN_MAX - 1); + if (strchr(path, '/') == NULL) { + getcwd(abs, PKG_NAME_STRING_LEN_MAX - 1); + if (abs == NULL) { + printf("getcwd() failed\n"); + return -1; + } + memset(data.pkg_path, '\0', PKG_NAME_STRING_LEN_MAX); + snprintf(data.pkg_path, PKG_NAME_STRING_LEN_MAX - 1, "%s/%s", abs, temp); + return 0; + } + if (strncmp(path, "./", 2) == 0) { + ptr = temp; + getcwd(abs, PKG_NAME_STRING_LEN_MAX - 1); + if (abs == NULL) { + printf("getcwd() failed\n"); + return -1; + } + ptr = ptr + 2; + memset(data.pkg_path, '\0', PKG_NAME_STRING_LEN_MAX); + snprintf(data.pkg_path, PKG_NAME_STRING_LEN_MAX - 1, "%s/%s", abs, ptr); + return 0; + } + return 0; +} + static int __is_app_installed(char *pkgname) { ail_appinfo_h handle; @@ -158,7 +198,8 @@ static void __print_usage() printf("pkgcmd -s -t -n (-q)\n\n"); printf("Example:\n"); printf("pkgcmd -u -t deb -n org.tizen.calculator\n"); - printf("pkgcmd -i -t deb -p /mnt/nfs/org.tizen.calculator_0.1.2-95_armel.deb\n"); + printf + ("pkgcmd -i -t deb -p /mnt/nfs/org.tizen.calculator_0.1.2-95_armel.deb\n"); printf("pkgcmd -c -t deb -n org.tizen.hello\n"); exit(0); @@ -326,11 +367,20 @@ static int __process_request() mode = PM_DEFAULT; else mode = PM_QUIET; +#if 0 ret = __is_app_installed(data.pkg_name); if (ret == -1) { printf("package is not installed\n"); break; } +#else + pkgmgr_pkginfo_h handle; + ret = pkgmgr_get_pkginfo(data.pkg_name, &handle); + if(ret < 0) { + printf("package is not in pkgmgr_info DB\n"); + } else + pkgmgr_destroy_pkginfo(handle); +#endif ret = pkgmgr_client_uninstall(pc, data.pkg_type, data.pkg_name, mode, __return_cb, NULL); @@ -370,6 +420,51 @@ static int __process_request() ret = data.result; break; + case ACTIVATE_REQ: + if (data.pkg_type[0] == '\0' || data.pkg_name[0] == '\0') { + printf("Please provide the arguments.\n"); + printf("use -h option to see usage\n"); + ret = -1; + break; + } + + pc = pkgmgr_client_new(PC_REQUEST); + if (pc == NULL) { + printf("PkgMgr Client Creation Failed\n"); + ret = -1; + break; + } + + ret = pkgmgr_client_activate(pc, data.pkg_type, data.pkg_name); + if (ret < 0) + break; + ret = data.result; + + break; + + + case DEACTIVATE_REQ: + if (data.pkg_type[0] == '\0' || data.pkg_name[0] == '\0') { + printf("Please provide the arguments.\n"); + printf("use -h option to see usage\n"); + ret = -1; + break; + } + + pc = pkgmgr_client_new(PC_REQUEST); + if (pc == NULL) { + printf("PkgMgr Client Creation Failed\n"); + ret = -1; + break; + } + + ret = pkgmgr_client_deactivate(pc, data.pkg_type, data.pkg_name); + if (ret < 0) + break; + ret = data.result; + + break; + case LIST_REQ: ret = pkgmgr_get_pkg_list(__iter_fn, NULL); break; @@ -475,6 +570,14 @@ int main(int argc, char *argv[]) data.request = CLEAR_REQ; break; + case 'A': /* activate */ + data.request = ACTIVATE_REQ; + break; + + case 'D': /* deactivate */ + data.request = DEACTIVATE_REQ; + break; + case 'l': /* list */ data.request = LIST_REQ; break; @@ -487,6 +590,12 @@ int main(int argc, char *argv[]) if (optarg) strncpy(data.pkg_path, optarg, PKG_NAME_STRING_LEN_MAX); + ret = __convert_to_absolute_path(data.pkg_path); + if (ret == -1) { + printf("conversion of relative path to absolute path failed\n"); + return -1; + } + printf("package path is %s\n", data.pkg_path); break; case 'd': /* descriptor path */ diff --git a/tool/pkg_info.c b/tool/pkg_info.c new file mode 100755 index 0000000..4692f17 --- /dev/null +++ b/tool/pkg_info.c @@ -0,0 +1,697 @@ +/* + * slp-pkgmgr + * + * Copyright (c) 2000 - 2011 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. + * + */ + +#define _GNU_SOURCE + +#include +#include +#include +#include +#include +#include +#include "package-manager.h" +#include "package-manager-types.h" +#include "pkgmgr_parser.h" +#include "pkgmgr-dbinfo.h" + + +static void __print_usage(); +static int __get_pkg_info(char *pkgname); +static int __get_app_info(char *appid); +static int __get_app_list(char *pkgname); +static int __get_pkg_list(void); +static int __insert_manifest_in_db(char *manifest); +static int __remove_manifest_from_db(char *manifest); +static int __set_pkginfo_in_db(char *pkgname); +static int __get_integer_input_data(void); +char *__get_string_input_data(void); +static int __iter_fn(const char *pkg_type, const char *pkg_name, + const char *version, void *data); + +static int __get_integer_input_data(void) +{ + char input_str[32] = { 0, }; + int data = 0; + fflush(stdin); + + if (fgets(input_str, 1024, stdin) == NULL) { + printf("Input buffer overflow....\n"); + return -1; + } + + if (sscanf(input_str, "%d", &data) != 1) { + printf("Input only integer option....\n"); + return -1; + } + + return data; +} + + +char *__get_string_input_data(void) +{ + char *data = (char *)malloc(1024); + if (data == NULL) { + printf("Malloc Failed\n"); + return -1; + } + if (fgets(data,1024,stdin) == NULL){ + printf("Buffer overflow!!! try again\n"); + exit(-1); + } + data[strlen(data) - 1] = '\0'; + return data; +} + +static void __print_usage() +{ + printf("For Getting package|App Info\n"); + printf("\tpkginfo --[pkg|app] \n\n"); + printf("For Getting list of installed packages\n"); + printf("\tpkginfo --list \n\n"); + printf("For Getting app list for a particular package\n"); + printf("\tpkginfo --list \n\n"); + printf("To insert|remove manifest info in DB\n"); + printf("\tpkginfo --[imd|rmd] \n\n"); + printf("To set pkginfo in DB\n"); + printf("\tpkginfo --setdb \n\n"); + printf("To set manifest validation\n"); + printf("\tpkginfo --check \n\n"); +} + +static int __set_pkginfo_in_db(char *pkgname) +{ + if (pkgname == NULL) { + printf("pkgname is NULL\n"); + return -1; + } + int ret = 0; + int choice = -1; + int preload = -1; + int removable = -1; + int location = -1; + char *locale = NULL; + pkgmgr_pkgdbinfo_h handle = NULL; + ret = pkgmgr_create_pkgdbinfo(pkgname, &handle); + if (ret < 0) { + printf("pkgmgr_create_pkgdbinfo failed\n"); + return -1; + } + while (choice != 0) + { + printf("Enter the choice you want to set\n"); + printf("0 --> to set data in DB\n"); + printf("1 --> pkg type\n"); + printf("2 --> pkg version\n"); + printf("3 --> pkg instal location\n"); + printf("4 --> pkg label\n"); + printf("5 --> pkg icon\n"); + printf("6 --> pkg description\n"); + printf("7 --> pkg author\n"); + printf("8 --> pkg removable\n"); + printf("9 --> pkg preload\n"); + choice = __get_integer_input_data(); + switch(choice) { + case 0: + ret = pkgmgr_save_pkgdbinfo(handle); + if (ret < 0) { + printf("pkgmgr_save_pkgdbinfo failed\n"); + return -1; + } + ret = pkgmgr_destroy_pkgdbinfo(handle); + if (ret < 0) { + printf("pkgmgr_destroy_pkgdbinfo failed\n"); + return -1; + } + return 0; + case 1: + printf("Enter type: \n"); + char *type = __get_string_input_data(); + ret = pkgmgr_set_type_to_pkgdbinfo(handle, type); + if (ret < 0) { + printf("pkgmgr_set_type_to_pkgdbinfo failed\n"); + return -1; + } + break; + case 2: + printf("Enter version: \n"); + char *version = __get_string_input_data(); + ret = pkgmgr_set_version_to_pkgdbinfo(handle, version); + if (ret < 0) { + printf("pkgmgr_set_version_to_pkgdbinfo failed\n"); + return -1; + } + break; + case 3: + printf("Enter install location [0:internal | 1:external]: \n"); + location = __get_integer_input_data(); + ret = pkgmgr_set_install_location_to_pkgdbinfo(handle, location); + if (ret < 0) { + printf("pkgmgr_set_install_location_to_pkgdbinfo failed\n"); + return -1; + } + break; + case 4: + printf("Enter label :\n"); + char *label = __get_string_input_data(); + printf("Enter locale ['def' for default]: \n"); + locale = __get_string_input_data(); + if (strcmp(locale, "def") == 0) + ret = pkgmgr_set_label_to_pkgdbinfo(handle, label, NULL); + else + ret = pkgmgr_set_label_to_pkgdbinfo(handle, label, locale); + if (ret < 0) { + printf("pkgmgr_set_label_to_pkgdbinfo failed\n"); + return -1; + } + break; + case 5: + printf("Enter icon: \n"); + char *icon = __get_string_input_data(); + printf("Enter locale ['def' for default]: \n"); + locale = __get_string_input_data(); + if (strcmp(locale, "def") == 0) + ret = pkgmgr_set_icon_to_pkgdbinfo(handle, icon, NULL); + else + ret = pkgmgr_set_icon_to_pkgdbinfo(handle, icon, locale); + if (ret < 0) { + printf("pkgmgr_set_icon_to_pkgdbinfo failed\n"); + return -1; + } + break; + case 6: + printf("Enter description: \n"); + char *description = __get_string_input_data(); + printf("Enter locale ['def' for default]: \n"); + locale = __get_string_input_data(); + if (strcmp(locale, "def") == 0) + ret = pkgmgr_set_description_to_pkgdbinfo(handle, description, NULL); + else + ret = pkgmgr_set_description_to_pkgdbinfo(handle, description, locale); + if (ret < 0) { + printf("pkgmgr_set_description_to_pkgdbinfo failed\n"); + return -1; + } + break; + case 7: + printf("Enter author name: \n"); + char *author_name = __get_string_input_data(); + printf("Enter locale ['def' for default]: \n"); + locale = __get_string_input_data(); + printf("Enter author email: \n"); + char *author_email = __get_string_input_data(); + printf("Enter author href: \n"); + char *author_href = __get_string_input_data(); + if (strcmp(locale, "def") == 0) + ret = pkgmgr_set_author_to_pkgdbinfo(handle, author_name, author_email, author_href, NULL); + else + ret = pkgmgr_set_author_to_pkgdbinfo(handle, author_name, author_email, author_href, locale); + if (ret < 0) { + printf("pkgmgr_set_author_to_pkgdbinfo failed\n"); + return -1; + } + break; + case 8: + printf("Enter removable [0:false | 1:true]: \n"); + removable = __get_integer_input_data(); + ret = pkgmgr_set_removable_to_pkgdbinfo(handle, removable); + if (ret < 0) { + printf("pkgmgr_set_removable_to_pkgdbinfo failed\n"); + return -1; + } + break; + case 9: + printf("Enter preload [0:false | 1:true]: \n"); + preload = __get_integer_input_data(); + ret = pkgmgr_set_preload_to_pkgdbinfo(handle, preload); + if (ret < 0) { + printf("pkgmgr_set_preload_to_pkgdbinfo failed\n"); + return -1; + } + break; + default: + printf("Invalid number entered\n"); + continue; + } + } + return 0; +} + +static int __insert_manifest_in_db(char *manifest) +{ + int ret = 0; + if (manifest == NULL) { + printf("Manifest file is NULL\n"); + return -1; + } + ret = pkgmgr_parser_parse_manifest_for_installation(manifest, NULL); + if (ret < 0) { + printf("insert in db failed\n"); + return -1; + } + return 0; +} + +static int __remove_manifest_from_db(char *manifest) +{ + int ret = 0; + if (manifest == NULL) { + printf("Manifest file is NULL\n"); + return -1; + } + ret = pkgmgr_parser_parse_manifest_for_uninstallation(manifest, NULL); + if (ret < 0) { + printf("remove from db failed\n"); + return -1; + } + return 0; +} + +int app_func(const pkgmgr_appinfo_h handle, const char *appid, void *user_data) +{ + char *data = NULL; + if (user_data) { + data = (char *)user_data; + } + int ret = -1; + char *exec = NULL; + char *component = NULL; + char *apptype = NULL; + bool nodisplay = 0; + bool multiple = 0; + bool taskmanage = 0; + bool onboot = 0; + bool autorestart = 0; + if (appid) + printf("Appid: %s\n", appid); + + ret = pkgmgr_get_pkginfo_exec(handle, &exec); + if (ret < 0) { + printf("Failed to get exec\n"); + } + if (exec) + printf("Exec: %s\n", exec); + + ret = pkgmgr_get_pkginfo_component(handle, &component); + if (ret < 0) { + printf("Failed to get component\n"); + } + if (component) + printf("Component: %s\n", component); + + ret = pkgmgr_get_pkginfo_apptype(handle, &apptype); + if (ret < 0) { + printf("Failed to get apptype\n"); + } + if (apptype) + printf("Apptype: %s\n", apptype); + + if (component) { + if (strcasecmp(component, "uiapp") == 0) { + ret = pkgmgr_get_pkginfo_multiple(handle, &multiple); + if (ret < 0) { + printf("Failed to get multiple\n"); + } else { + printf("Multiple: %d\n", multiple); + } + + ret = pkgmgr_get_pkginfo_nodisplay(handle, &nodisplay); + if (ret < 0) { + printf("Failed to get nodisplay\n"); + } else { + printf("Nodisplay: %d \n", nodisplay); + } + + ret = pkgmgr_get_pkginfo_taskmanage(handle, &taskmanage); + if (ret < 0) { + printf("Failed to get taskmanage\n"); + } else { + printf("Taskmanage: %d\n", taskmanage); + } + } + if (strcasecmp(component, "svcapp") == 0) { + ret = pkgmgr_get_pkginfo_onboot(handle, &onboot); + if (ret < 0) { + printf("Failed to get onboot\n"); + } else { + printf("Onboot: %d\n", onboot); + } + + ret = pkgmgr_get_pkginfo_autorestart(handle, &autorestart); + if (ret < 0) { + printf("Failed to get autorestart\n"); + } else { + printf("Autorestart: %d \n", autorestart); + } + } + } + + printf("Userdata: %s\n\n\n", data); + return 0; +} + +static int __iter_fn(const char *pkg_type, const char *pkg_name, + const char *version, void *data) +{ + printf("pkg_type [%s]\tpkg_name [%s]\tversion [%s]\n", pkg_type, + pkg_name, version); + return 0; +} + +static int __get_pkg_list() +{ + int ret = -1; + ret = pkgmgr_get_info_list(__iter_fn, NULL); + if (ret < 0) { + printf("pkgmgr_get_info_list() failed\n"); + return -1; + } + return 0; +} +static int __get_app_list(char *pkgname) +{ + pkgmgr_pkginfo_h handle; + int ret = -1; + char *test_data = "test data"; + ret = pkgmgr_get_pkginfo(pkgname, &handle); + if (ret < 0) { + printf("Failed to get handle\n"); + return -1; + } + printf("List of Ui-Apps\n\n"); + ret = pkgmgr_get_info_app(handle, PM_UI_APP, app_func, (void *)test_data); + if (ret < 0) { + printf("pkgmgr_get_info_app() failed\n"); + } + printf("List of Svc-Apps\n\n"); + ret = pkgmgr_get_info_app(handle, PM_SVC_APP, app_func, (void *)test_data); + if (ret < 0) { + printf("pkgmgr_get_info_app() failed\n"); + } + pkgmgr_destroy_pkginfo(handle); + return 0; +} + +static int __get_pkg_info(char *pkgname) +{ + pkgmgr_pkginfo_h handle; + int ret = -1; + char *type = NULL; + char *version = NULL; + char *author_name = NULL; + char *author_email = NULL; + char *author_href = NULL; + pkgmgr_install_location location = 1; + char *icon = NULL; + char *label = NULL; + char *desc = NULL; + bool removable = 0; + bool preload = 0; + bool readonly = 0; + + printf("Get Pkg Info Called [%s]\n", pkgname); + ret = pkgmgr_get_pkginfo(pkgname, &handle); + if (ret < 0) { + printf("Failed to get handle\n"); + return -1; + } + + ret = pkgmgr_get_pkginfo_version(handle, &version); + if (ret < 0) { + printf("Failed to get version\n"); + } + if (version) + printf("Version: %s\n", version); + + ret = pkgmgr_get_pkginfo_install_location(handle, &location); + if (ret < 0) { + printf("Failed to get install location\n"); + } + printf("Install Location: %d\n", location); + + ret = pkgmgr_get_pkginfo_label(handle, &label); + if (ret < 0) { + printf("Failed to get label\n"); + } + if (label) + printf("Label: %s\n", label); + + ret = pkgmgr_get_pkginfo_icon(handle, &icon); + if (ret < 0) { + printf("Failed to get icon\n"); + } + if (icon) + printf("Icon: %s\n", icon); + + ret = pkgmgr_get_pkginfo_description(handle, &desc); + if (ret < 0) { + printf("Failed to get description\n"); + } + if (desc) + printf("Description: %s\n", desc); + + ret = pkgmgr_get_pkginfo_type(handle, &type); + if (ret < 0) { + printf("Failed to get pkg type\n"); + } + if (type) + printf("Type: %s\n", type); + + ret = pkgmgr_get_pkginfo_author_name(handle, &author_name); + if (ret < 0) { + printf("Failed to get author name\n"); + } + if (author_name) + printf("Author Name: %s\n", author_name); + + ret = pkgmgr_get_pkginfo_author_email(handle, &author_email); + if (ret < 0) { + printf("Failed to get author email\n"); + } + if (author_email) + printf("Author Email: %s\n", author_email); + + ret = pkgmgr_get_pkginfo_author_href(handle, &author_href); + if (ret < 0) { + printf("Failed to get author href\n"); + } + if (author_href) + printf("Author Href: %s\n", author_href); + + ret = pkgmgr_get_pkginfo_removable(handle, &removable); + if (ret < 0) { + printf("Failed to get removable\n"); + } + else + printf("Removable: %d\n", removable); + + ret = pkgmgr_get_pkginfo_preload(handle, &preload); + if (ret < 0) { + printf("Failed to get preload\n"); + } + else + printf("Preload: %d\n", preload); + + ret = pkgmgr_get_pkginfo_readonly(handle, &readonly); + if (ret < 0) { + printf("Failed to get readonly\n"); + } + else + printf("Readonly: %d\n", readonly); + + pkgmgr_destroy_pkginfo(handle); + return 0; +} + +static int __get_app_info(char *appid) +{ + printf("Get App Info Called [%s]\n", appid); + char *exec = NULL; + char *apptype = NULL; + char *component = NULL; + bool nodisplay = 0; + bool multiple = 0; + bool taskmanage = 0; + bool onboot = 0; + bool autorestart = 0; + pkgmgr_appinfo_h handle; + int ret = -1; + + ret = pkgmgr_get_appinfo(appid, &handle); + if (ret < 0) { + printf("Failed to get handle\n"); + return -1; + } + ret = pkgmgr_get_pkginfo_exec(handle, &exec); + if (ret < 0) { + printf("Failed to get exec\n"); + } + ret = pkgmgr_get_pkginfo_component(handle, &component); + if (ret < 0) { + printf("Failed to get component\n"); + } + ret = pkgmgr_get_pkginfo_apptype(handle, &apptype); + if (ret < 0) { + printf("Failed to get apptype\n"); + } + ret = pkgmgr_get_pkginfo_multiple(handle, &multiple); + if (ret < 0) { + printf("Failed to get multiple\n"); + } + ret = pkgmgr_get_pkginfo_nodisplay(handle, &nodisplay); + if (ret < 0) { + printf("Failed to get nodisplay\n"); + } + ret = pkgmgr_get_pkginfo_taskmanage(handle, &taskmanage); + if (ret < 0) { + printf("Failed to get taskmanage\n"); + } + ret = pkgmgr_get_pkginfo_onboot(handle, &onboot); + if (ret < 0) { + printf("Failed to get onboot\n"); + } + ret = pkgmgr_get_pkginfo_autorestart(handle, &autorestart); + if (ret < 0) { + printf("Failed to get autorestart\n"); + } + + if (exec) + printf("Exec: %s\n", exec); + if (apptype) + printf("Apptype: %s\n", apptype); + if (component) + printf("Component: %s\n", component); + if (component) { + if (strcasecmp(component, "uiapp") == 0) { + printf("Nodisplay: %d\n", nodisplay); + printf("Multiple: %d\n", multiple); + printf("Taskmanage: %d\n", taskmanage); + } else if (strcasecmp(component, "svcapp") == 0) { + printf("Autorestart: %d\n", autorestart); + printf("Onboot: %d\n", onboot); + } else { + printf("Invalid Component Type\n"); + } + } + pkgmgr_destroy_appinfo(handle); + return 0; + +} + +static int __check_manifest_validation(char *manifest) +{ + int ret = 0; + if (manifest == NULL) { + printf("Manifest file is NULL\n"); + return -1; + } + ret = pkgmgr_parser_check_manifest_validation(manifest); + if (ret < 0) { + printf("check manifest validation failed\n"); + return -1; + } + return 0; +} + +int main(int argc, char *argv[]) +{ + int ret = -1; + char *locale = NULL; + locale = vconf_get_str(VCONFKEY_LANGSET); + if (locale == NULL) { + printf("locale is NULL\n"); + return -1; + } + else + printf("Locale is %s\n", locale); + free(locale); + locale = NULL; + if (argc == 2) { + if (strcmp(argv[1], "--list") == 0) { + ret = __get_pkg_list(); + if (ret == -1) { + printf("get pkg list failed\n"); + return -1; + } else { + return 0; + } + } else { + __print_usage(); + return -1; + } + } + if (argc != 3) { + __print_usage(); + return -1; + } + if (!argv[1] || !argv[2]) { + __print_usage(); + return -1; + } + + if (strcmp(argv[1], "--pkg") == 0) { + ret = __get_pkg_info(argv[2]); + if (ret == -1) { + printf("get pkg info failed\n"); + return -1; + } + } else if (strcmp(argv[1], "--app") == 0) { + ret = __get_app_info(argv[2]); + if (ret == -1) { + printf("get app info failed\n"); + return -1; + } + } else if (strcmp(argv[1], "--list") == 0) { + ret = __get_app_list(argv[2]); + if (ret == -1) { + printf("get app list failed\n"); + return -1; + } + } else if (strcmp(argv[1], "--imd") == 0) { + ret = __insert_manifest_in_db(argv[2]); + if (ret == -1) { + printf("insert in db failed\n"); + return -1; + } + } else if (strcmp(argv[1], "--rmd") == 0) { + ret = __remove_manifest_from_db(argv[2]); + if (ret == -1) { + printf("remove from db failed\n"); + return -1; + } + } else if (strcmp(argv[1], "--setdb") == 0) { + ret = __set_pkginfo_in_db(argv[2]); + if (ret == -1) { + printf("set pkginfo in db failed\n"); + return -1; + } + } else if (strcmp(argv[1], "--check") == 0) { + ret = __check_manifest_validation(argv[2]); + if (ret == -1) { + printf("check manifest failed\n"); + return -1; + } + } else + __print_usage(); + + return 0; +} diff --git a/tool/pkg_initdb.c b/tool/pkg_initdb.c new file mode 100755 index 0000000..9a2e123 --- /dev/null +++ b/tool/pkg_initdb.c @@ -0,0 +1,226 @@ +/* + * slp-pkgmgr + * + * Copyright (c) 2000 - 2011 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. + * + */ + +#define _GNU_SOURCE + +#include +#include +#include +#include +#include +#include +#include + +#include "pkgmgr_parser.h" + +#define OWNER_ROOT 0 +#define GROUP_MENU 6010 +#define BUFSZE 1024 +#define OPT_MANIFEST_DIRECTORY "/opt/share/packages" +#define USR_MANIFEST_DIRECTORY "/usr/share/packages" +#define PACKAGE_INFO_DB_FILE "/opt/dbspace/.pkgmgr_parser.db" + +#ifdef _E +#undef _E +#endif +#define _E(fmt, arg...) fprintf(stderr, "[PKG_INITDB][E][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg); + +#ifdef _D +#undef _D +#endif +#define _D(fmt, arg...) fprintf(stderr, "[PKG_INITDB][D][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg); + +static int initdb_count_package(void) +{ + int total = 0; + + return total; +} + + + +char* _manifest_to_package(const char* manifest) +{ + char *package; + + if(manifest == NULL) + return NULL; + + package = strdup(manifest); + if(package == NULL) + return NULL; + + + if (!strstr(package, ".xml")) { + _E("%s is not a manifest file", manifest); + free(package); + return NULL; + } + + return package; +} + + + +int initdb_load_directory(const char *directory) +{ + DIR *dir; + struct dirent entry, *result; + int len, ret; + char buf[BUFSZE]; + + // desktop file + dir = opendir(directory); + if (!dir) { + if (strerror_r(errno, buf, sizeof(buf)) == 0) + _E("Failed to access the [%s] because %s\n", directory, buf); + return -1; + } + + len = strlen(directory) + 1; + _D("Loading manifest files from %s\n", directory); + + for (ret = readdir_r(dir, &entry, &result); + ret == 0 && result != NULL; + ret = readdir_r(dir, &entry, &result)) { + char *manifest; + + if (entry.d_name[0] == '.') continue; + + manifest = _manifest_to_package(entry.d_name); + if (!manifest) { + _E("Failed to convert file to package[%s]\n", entry.d_name); + continue; + } + + snprintf(buf, sizeof(buf), "%s/%s", directory, manifest); + + fprintf(stderr, "pkg_initdb : manifest file %s\n", buf); + + ret = pkgmgr_parser_check_manifest_validation(buf); + if (ret < 0) { + _E("check manifest validation failed code[%d] %s\n", ret, buf); + fprintf(stderr, "check manifest validation failed code[%d] %s\n", ret, buf); + continue; + } + + + /*temporarily fixed due to glib abort */ + // pkgmgr_parser_parse_manifest_for_installation(buf, NULL); + + char buf2[BUFSZE]; + snprintf(buf2, sizeof(buf2), "/usr/bin/pkginfo --imd %s", buf); + system(buf2); + + free(manifest); + } + + closedir(dir); + + return 0; +} + + + +static int initdb_change_perm(const char *db_file) +{ + char buf[BUFSZE]; + char journal_file[BUFSZE]; + char *files[3]; + int ret, i; + + files[0] = (char *)db_file; + files[1] = journal_file; + files[2] = NULL; + + if(db_file == NULL) + return -1; + + snprintf(journal_file, sizeof(journal_file), "%s%s", db_file, "-journal"); + + for (i = 0; files[i]; i++) { + ret = chown(files[i], OWNER_ROOT, GROUP_MENU); + if (ret == -1) { + strerror_r(errno, buf, sizeof(buf)); + _E("FAIL : chown %s %d.%d, because %s", db_file, OWNER_ROOT, GROUP_MENU, buf); + return -1; + } + + ret = chmod(files[i], S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + if (ret == -1) { + strerror_r(errno, buf, sizeof(buf)); + _E("FAIL : chmod %s 0664, because %s", db_file, buf); + return -1; + } + } + + return 0; +} + + +static int __is_authorized() +{ + /* pkg_init db should be called by as root privilege. */ + + uid_t uid = getuid(); + if ((uid_t) 0 == uid) + return 1; + else + return 0; +} + + +int main(int argc, char *argv[]) +{ + int ret; + + if (!__is_authorized()) { + _E("You are not an authorized user!\n"); + return -1; + } + + ret = initdb_count_package(); + if (ret > 0) { + _D("Some Packages in the Package Info DB."); + return 0; + } + + ret = initdb_load_directory(OPT_MANIFEST_DIRECTORY); + if (ret == -1) { + _E("cannot load opt manifest directory."); + } + + ret = initdb_load_directory(USR_MANIFEST_DIRECTORY); + if (ret == -1) { + _E("cannot load usr manifest directory."); + } + + ret = initdb_change_perm(PACKAGE_INFO_DB_FILE); + if (ret == -1) { + _E("cannot chown."); + return -1; + } + + return 0; +} + +