From: Jinkun Jang Date: Fri, 15 Mar 2013 16:12:40 +0000 (+0900) Subject: merge with master X-Git-Tag: 2.1b_release~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1dc70d16bdafa594b87f7e4478f55b3ba3606267;p=platform%2Fcore%2Fappfw%2Fpkgmgr-info.git merge with master --- diff --git a/include/pkgmgr-info-debug.h b/include/pkgmgr-info-debug.h new file mode 100644 index 0000000..30613ef --- /dev/null +++ b/include/pkgmgr-info-debug.h @@ -0,0 +1,125 @@ +/* + * pkgmgr-info-debug + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: junsuk. oh + * + * 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_INFO_DEBUG_H__ +#define __PKGMGR_INFO_DEBUG_H__ + +#include + +#define LOG_TAG "PKGMGR_INFO" +#define _LOGE(fmt, arg...) LOGE(fmt, ##arg) +#define _LOGD(fmt, arg...) LOGD(fmt, ##arg) + +#define PKGMGR_INFO_ENABLE_DLOG + +#define COLOR_RED "\033[0;31m" +#define COLOR_BLUE "\033[0;34m" +#define COLOR_END "\033[0;m" + +#ifdef PKGMGR_INFO_ENABLE_DLOG +#define PKGMGR_INFO_DEBUG(fmt, ...)\ + do\ + {\ + LOGD(fmt, ##__VA_ARGS__);\ + } while (0) + +#define PKGMGR_INFO_DEBUG_ERR(fmt, ...)\ + do\ + {\ + LOGE(COLOR_RED fmt COLOR_END, ##__VA_ARGS__);\ + }while (0) + +#define PKGMGR_INFO_BEGIN() \ + do\ + {\ + LOGD(COLOR_BLUE"BEGIN >>>>"COLOR_END);\ + } while( 0 ) + +#define PKGMGR_INFO_END() \ + do\ + {\ + LOGD(COLOR_BLUE"END <<<<"COLOR_END);\ + } \ + while( 0 ) + +#else +#define PKGMGR_INFO_DEBUG(fmt, ...) \ + do\ + {\ + printf("\n [%s: %s(): %d] " fmt"\n", rindex(__FILE__, '/')+1, __FUNCTION__, __LINE__, ##__VA_ARGS__);\ + } while (0) + +#define PKGMGR_INFO_BEGIN() \ + do\ + {\ + printf("\n [%s: %d] : BEGIN >>>> %s() \n", rindex(__FILE__, '/')+1, __LINE__ , __FUNCTION__);\ + } while( 0 ) + +#define PKGMGR_INFO_END() \ + do\ + {\ + printf("\n [%s: %d]: END <<<< %s()\n", rindex(__FILE__, '/')+1, __LINE__ , __FUNCTION__); \ + } \ + while( 0 ) +#endif + + +#define ret_if(expr) do { \ + if (expr) { \ + PKGMGR_INFO_DEBUG_ERR("(%s) ", #expr); \ + PKGMGR_INFO_END();\ + return; \ + } \ +} while (0) + +#define retm_if(expr, fmt, arg...) do { \ + if (expr) { \ + PKGMGR_INFO_DEBUG_ERR("(%s) "fmt, #expr, ##arg); \ + PKGMGR_INFO_END();\ + return; \ + } \ + } while (0) + +#define retv_if(expr, val) do { \ + if (expr) { \ + PKGMGR_INFO_DEBUG_ERR("(%s) ", #expr); \ + PKGMGR_INFO_END();\ + return (val); \ + } \ + } while (0) + +#define retvm_if(expr, val, fmt, arg...) do { \ + if (expr) { \ + PKGMGR_INFO_DEBUG_ERR("(%s) "fmt, #expr, ##arg); \ + PKGMGR_INFO_END();\ + return (val); \ + } \ +} while (0) + +#define tryvm_if(expr, val, fmt, arg...) do { \ + if (expr) { \ + PKGMGR_INFO_DEBUG_ERR("(%s) "fmt, #expr, ##arg); \ + val; \ + goto catch; \ + } \ +} while (0) + +#endif /* __PKGMGR_INFO_DEBUG_H__ */ diff --git a/include/pkgmgr-info-internal.h b/include/pkgmgr-info-internal.h index 0a18b82..bd6b10e 100755 --- a/include/pkgmgr-info-internal.h +++ b/include/pkgmgr-info-internal.h @@ -25,6 +25,7 @@ #define __PKGMGR_INFO_INTERNAL_H__ #include +#include "pkgmgr-info-debug.h" #ifndef DEPRECATED #define DEPRECATED __attribute__ ((__deprecated__)) @@ -34,11 +35,6 @@ #define API __attribute__ ((visibility("default"))) #endif -#define LOG_TAG "PKGMGR_INFO" -#define _LOGE(fmt, arg...) LOGE(fmt, ##arg) -#define _LOGD(fmt, arg...) LOGD(fmt, ##arg) - - /*String properties for filtering based on package info*/ typedef enum _pkgmgrinfo_pkginfo_filter_prop_str { E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_STR = 101, diff --git a/include/pkgmgr-info.h b/include/pkgmgr-info.h index 32c9d7f..6680502 100755 --- a/include/pkgmgr-info.h +++ b/include/pkgmgr-info.h @@ -230,6 +230,22 @@ typedef int (*pkgmgrinfo_app_category_list_cb ) (const char *category_name, void *user_data); /** + * @fn int (*pkgmgrinfo_app_metadata_list_cb ) (const char *metadata_name, const char *metadata_value, void *user_data) + * + * @brief Specifies the type of function passed to pkgmgrinfo_appinfo_foreach_metadata() + * + * @param[in] metadata_name the name of the metadata + * @param[in] metadata_value the value of the metadata + * @param[in] user_data user data passed to pkgmgrinfo_appinfo_foreach_metadata() + * + * @return 0 if success, negative value(<0) if fail. Callback is not called if return value is negative.\n + * + * @see pkgmgrinfo_appinfo_foreach_metadata() + */ +typedef int (*pkgmgrinfo_app_metadata_list_cb ) (const char *metadata_name, + const char *metadata_value, void *user_data); + +/** * @fn int (*pkgmgrinfo_app_control_list_cb ) (pkgmgrinfo_appcontrol_h handle, void *user_data) * * @brief Specifies the type of function passed to pkgmgrinfo_appinfo_foreach_appcontrol() @@ -293,6 +309,16 @@ typedef enum { INSTALL_EXTERNAL, /**< External Installation*/ } INSTALL_LOCATION; + /** + * @brief permission Types + */ + typedef enum { + PMINFO_PERMISSION_NORMAL = 0, /**< permission normal*/ + PMINFO_PERMISSION_SIGNATURE, /**< permission type is signature*/ + PMINFO_PERMISSION_PRIVILEGE, /**< permission type is privilege*/ + }pkgmgrinfo_permission_type; + + /** String property for filtering based on package info*/ #define PMINFO_PKGINFO_PROP_PACKAGE_ID "PMINFO_PKGINFO_PROP_PACKAGE_ID" /** String property for filtering based on package info*/ @@ -1166,6 +1192,43 @@ static int get_pkg_url(const char *pkgid) */ int pkgmgrinfo_pkginfo_get_url(pkgmgrinfo_pkginfo_h handle, char **url); + +/** + * @fn int pkgmgrinfo_pkginfo_get_root_path(pkgmgrinfo_pkginfo_h handle, char **path) + * @brief This API gets the root path of package + * + * @par Sync (or) Async : Synchronous API + * + * @param[in] handle pointer to package info handle + * @param[out] path pointer to hold root path of package + * @return 0 if success, error code(<0) if fail + * @retval PMINFO_R_OK success + * @retval PMINFO_R_EINVAL invalid argument + * @retval PMINFO_R_ERROR internal error + * @code +static int get_root_path(const char *pkgid) +{ + int ret = 0; + char *path = 0; + pkgmgrinfo_pkginfo_h handle; + ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle); + if (ret != PMINFO_R_OK) + return -1; + + ret = pkgmgrinfo_pkginfo_get_root_path(handle, &path); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_pkginfo_destroy_pkginfo(handle); + return -1; + } + printf("path : %s\n", path); + pkgmgrinfo_pkginfo_destroy_pkginfo(handle); + + return 0; +} + * @endcode + */ +int pkgmgrinfo_pkginfo_get_root_path(pkgmgrinfo_pkginfo_h handle, char **path); + /** * @fn int pkgmgrinfo_pkginfo_compare_pkg_cert_info(const char *lhs_package_id, const char *rhs_package_id, pkgmgrinfo_cert_compare_result_type_e *compare_result) * @brief This API compare the cert information from given package id @@ -2467,6 +2530,84 @@ static int get_app_recent_image_type(const char *appid) */ int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type); + +/** + * @fn int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img) + * @brief This API gets the preview image of application + * + * @par Sync (or) Async : Synchronous API + * + * @param[in] handle pointer to the application info handle. + * @param[out] preview_img pointer to hold preview image path + * @return 0 if success, error code(<0) if fail + * @retval PMINFO_R_OK success + * @retval PMINFO_R_EINVAL invalid argument + * @retval PMINFO_R_ERROR internal error + * @pre pkgmgrinfo_appinfo_get_appinfo() + * @post pkgmgrinfo_appinfo_destroy_appinfo() + * @see pkgmgrinfo_appinfo_get_appid() + * @code +static int get_app_previewimage(const char *appid) +{ + int ret = 0; + char *preview = NULL; + pkgmgrinfo_appinfo_h handle = NULL; + ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle); + if (ret != PMINFO_R_OK) + return -1; + ret = pkgmgrinfo_appinfo_get_preview_image(handle, &preview); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_appinfo_destroy_appinfo(handle); + return -1; + } + printf("preview image path : %s\n", preview); + pkgmgrinfo_appinfo_destroy_appinfo(handle); + return 0; +} + * @endcode + */ +int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img); + + +/** + * @fn int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission) + * @brief This API gets the package permission type of the application + * + * @par This API is for package-manager client application + * @par Sync (or) Async : Synchronous API + * + * @param[in] handle pointer to the application info handle. + * @param[out] permission pointer to hold package permission + * @return 0 if success, error code(<0) if fail + * @retval PMINFO_R_OK success + * @retval PMINFO_R_EINVAL invalid argument + * @retval PMINFO_R_ERROR internal error + * @pre pkgmgrinfo_appinfo_get_appinfo() + * @post pkgmgrinfo_appinfo_destroy_appinfo() + * @see pkgmgrinfo_appinfo_get_appid() + * @code +static int get_app_permission(const char *appid) +{ + int ret = 0; + pkgmgrinfo_permission_type permission = 0; + pkgmgrinfo_appinfo_h handle; + + ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle); + if (ret != PMINFO_R_OK) + return -1; + ret = pkgmgrinfo_appinfo_get_permission_type(handle, &permission); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_appinfo_destroy_appinfo(handle); + return -1; + } + printf("permission type: %d\n", permission); + pkgmgrinfo_appinfo_destroy_appinfo(handle); + return 0; +} + * @endcode + */ +int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission); + /** * @fn int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_category_list_cb category_func, void *user_data); @@ -2512,6 +2653,53 @@ static int list_category(const char *appid, char *category) int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_category_list_cb category_func, void *user_data); +/** + * @fn int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle, + pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data); + * @brief This API gets the list of metadata for a particular application + * + * @par This API is for package-manager client application + * @par Sync (or) Async : Synchronous API + * @param[in] handle pointer to the application info handle. + * @param[in] metadata_func callback function for list + * @param[in] user_data user data to be passed to callback function + * @return 0 if success, error code(<0) if fail + * @retval PMINFO_R_OK success + * @retval PMINFO_R_EINVAL invalid argument + * @retval PMINFO_R_ERROR internal error + * @pre pkgmgrinfo_appinfo_get_appinfo() + * @post pkgmgrinfo_appinfo_destroy_appinfo() + * @code +int metadata_func(const char *name, const char *value, void *user_data) +{ + if (strcmp(name, (char *)user_data) == 0) { + printf("Value is %s\n", value); + return -1; + } + else + return 0; +} + +static int list_metadata(const char *appid, char *name) +{ + int ret = 0; + pkgmgrinfo_appinfo_h handle; + ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle); + if (ret != PMINFO_R_OK) + return -1; + ret = pkgmgrinfo_appinfo_foreach_metadata(handle, metadata_func, (void *)name); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_appinfo_destroy_appinfo(handle); + return -1; + } + pkgmgrinfo_appinfo_destroy_appinfo(handle); + return 0; +} + * @endcode + */ +int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle, + pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data); + /** * @fn int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle, @@ -2643,6 +2831,87 @@ static int get_app_multiple(const char *appid) int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple); /** + * @fn int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp) + * @brief This API gets the application 'indicatordisplay' value. If true, indicator will be displayed during + * application launching effect. If fales, indicator will be hidden during application launching effect + * + * @par This API is for package-manager client application + * @par Sync (or) Async : Synchronous API + * + * @param[in] handle pointer to application info handle + * @param[out] indicator_disp contains indicator display status for application launching effect + * @return 0 if success, error code(<0) if fail + * @retval PMINFO_R_OK success + * @retval PMINFO_R_EINVAL invalid argument + * @retval PMINFO_R_ERROR internal error + * @pre pkgmgrinfo_appinfo_get_appinfo() + * @post pkgmgrinfo_appinfo_destroy_appinfo() + * @see pkgmgrinfo_appinfo_get_appid() + * @see pkgmgrinfo_appinfo_is_nodisplay() + * @code +static int get_app_indicator_display(const char *appid) +{ + int ret = 0; + bool indicator_disp; + pkgmgrinfo_appinfo_h handle; + ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle); + if (ret != PMINFO_R_OK) + return -1; + ret = pkgmgrinfo_appinfo_is_indicator_display_allowed(handle, &indicator_disp); + if (ret != PMINFO_R_OK){ + pkgmgrinfo_appinfo_destroy_appinfo(handle); + return -1; + } + printf("app indicator disp : %d\n", indicator_disp); + pkgmgrinfo_appinfo_destroy_appinfo(handle); + return 0; +} + * @endcode + */ +int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp); + +/** + * @fn int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img) + * @brief This API gets the application's landscape & portrait effect images + * + * @par This API is for package-manager client application + * @par Sync (or) Async : Synchronous API + * + * @param[in] handle pointer to application info handle + * @param[out] portrait_img contains portrait mode effect image + * @param[out] landscape_img contains landscape mode effect image + * @return 0 if success, error code(<0) if fail + * @retval PMINFO_R_OK success + * @retval PMINFO_R_EINVAL invalid argument + * @retval PMINFO_R_ERROR internal error + * @pre pkgmgrinfo_appinfo_get_appinfo() + * @post pkgmgrinfo_appinfo_destroy_appinfo() + * @see pkgmgrinfo_appinfo_get_appid() + * @see pkgmgrinfo_appinfo_is_nodisplay() + * @code +static int get_app_effectimages(const char *appid) +{ + int ret = 0; + char *portraitimg = NULL; + char *landscapeimg = NULL; + pkgmgrinfo_appinfo_h handle; + ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle); + if (ret != PMINFO_R_OK) + return -1; + ret = pkgmgrinfo_appinfo_get_effectimage(handle, &portraitimg, &landscapeimg); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_appinfo_destroy_appinfo(handle); + return -1; + } + printf("app effect image portrait: %s, app effect image landscape : %s\n", portraitimg, landscapeimg); + pkgmgrinfo_appinfo_destroy_appinfo(handle); + return 0; +} + * @endcode + */ +int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img); + +/** * @fn int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage) * @brief This API gets the application 'taskmanage' value from the app ID * @@ -2682,6 +2951,45 @@ static int get_app_taskmanage(const char *appid) int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage); /** + * @fn int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled) + * @brief This API gets the application 'taskmanage' value from the app ID + * + * @par This API is for package-manager client application + * @par Sync (or) Async : Synchronous API + * + * @param[in] handle pointer to application info handle + * @param[out] enabled pointer to hold package enabled value + * @return 0 if success, error code(<0) if fail + * @retval PMINFO_R_OK success + * @retval PMINFO_R_EINVAL invalid argument + * @retval PMINFO_R_ERROR internal error + * @pre pkgmgrinfo_appinfo_get_appinfo() + * @post pkgmgrinfo_appinfo_destroy_appinfo() + * @see pkgmgrinfo_appinfo_get_appid() + * @see pkgmgrinfo_appinfo_is_multiple() + * @code +static int get_app_enabled(const char *appid) +{ + int ret = 0; + bool enabled; + pkgmgrinfo_appinfo_h handle; + ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle); + if (ret != PMINFO_R_OK) + return -1; + ret = pkgmgrinfo_appinfo_is_taskmanage(handle, &enabled); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_appinfo_destroy_appinfo(handle); + return -1; + } + printf("app enabled: %d\n", enabled); + pkgmgrinfo_appinfo_destroy_appinfo(handle); + return 0; +} + * @endcode + */ +int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled); + +/** * @fn int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration) * @brief This API gets the application 'hwacceleration' value from the app ID * @@ -4127,6 +4435,83 @@ int pkgmgrinfo_destroy_certinfo_set_handle(pkgmgrinfo_instcertinfo_h handle); */ int pkgmgrinfo_datacontrol_get_info(const char *providerid, const char * type, char **appid, char **access); +/** + * @fn int pkgmgrinfo_appinfo_is_guestmode_appstatus(pkgmgrinfo_appinfo_h handle, bool *status) + * @brief This API gets the application 'guest mode visibility' value from the DB + * + * @par This API is for package-manager client application + * @par Sync (or) Async : Synchronous API + * + * @param[in] handle pointer to application info handle + * @param[out] status pointer to hold app guest mode visibility value + * @return 0 if success, error code(<0) if fail + * @retval PMINFO_R_OK success + * @retval PMINFO_R_EINVAL invalid argument + * @retval PMINFO_R_ERROR internal error + * @pre pkgmgrinfo_appinfo_get_appinfo() + * @post pkgmgrinfo_appinfo_destroy_appinfo() + * @see pkgmgrinfo_appinfo_get_appid() + * @see pkgmgrinfo_appinfo_is_multiple() + * @code +static int get_app_guestmode_visibility(const char *appid) +{ + int ret = 0; + bool status; + pkgmgrinfo_appinfo_h handle; + ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle); + if (ret != PMINFO_R_OK) + return -1; + ret = pkgmgrinfo_appinfo_is_guestmode_visibility(handle, &status); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_appinfo_destroy_appinfo(handle); + return -1; + } + printf("app guest mode visibility: %d\n", status); + pkgmgrinfo_appinfo_destroy_appinfo(handle); + return 0; +} + * @endcode + */ + int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status); + +/** + * @fn int pkgmgrinfo_appinfo_set_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool status) + * @brief This API sets the application 'guest mode visibility' value in the DB + * + * @par This API is for package-manager client application + * @par Sync (or) Async : Synchronous API + * + * @param[in] handle pointer to application info handle + * @param[out] status app guest mode visibility value + * @return 0 if success, error code(<0) if fail + * @retval PMINFO_R_OK success + * @retval PMINFO_R_EINVAL invalid argument + * @retval PMINFO_R_ERROR internal error + * @pre pkgmgrinfo_appinfo_get_appinfo() + * @post pkgmgrinfo_appinfo_destroy_appinfo() + * @see pkgmgrinfo_appinfo_get_appid() + * @see pkgmgrinfo_appinfo_is_multiple() + * @code +static int set_app_guestmode_visibility(const char *appid, bool value) +{ + int ret = 0; + pkgmgrinfo_appinfo_h handle; + ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle); + if (ret != PMINFO_R_OK) + return -1; + ret = pkgmgrinfo_appinfo_set_guestmode_visibility(handle, value); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_appinfo_destroy_appinfo(handle); + return -1; + } + pkgmgrinfo_appinfo_destroy_appinfo(handle); + return 0; +} + * @endcode + */ + int pkgmgrinfo_appinfo_set_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool status); + + /** @} */ #ifdef __cplusplus } diff --git a/packaging/pkgmgr-info.spec b/packaging/pkgmgr-info.spec index 64c2946..cee2476 100755 --- a/packaging/pkgmgr-info.spec +++ b/packaging/pkgmgr-info.spec @@ -1,7 +1,7 @@ Name: pkgmgr-info Summary: Packager Manager infomation api for package -Version: 0.0.54 -Release: 1 +Version: 0.0.83 +Release: 2 Group: System/Libraries License: Apache License, Version 2.0 Source0: %{name}-%{version}.tar.gz @@ -99,6 +99,7 @@ rm -rf %{buildroot} %files parser-devel %defattr(-,root,root,-) %{_includedir}/pkgmgr/pkgmgr_parser.h +%{_includedir}/pkgmgr/pkgmgr_parser_db.h %{_libdir}/pkgconfig/pkgmgr-parser.pc %{_libdir}/libpkgmgr_parser.so diff --git a/parser/CMakeLists.txt b/parser/CMakeLists.txt index fdcf38b..a1c02f4 100755 --- a/parser/CMakeLists.txt +++ b/parser/CMakeLists.txt @@ -64,6 +64,9 @@ INSTALL(TARGETS INSTALL(FILES pkgmgr_parser.h DESTINATION include/pkgmgr) +INSTALL(FILES + pkgmgr_parser_db.h + DESTINATION include/pkgmgr) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-parser.pc diff --git a/parser/manifest.xsd.in b/parser/manifest.xsd.in index 2271000..5a08c40 100755 --- a/parser/manifest.xsd.in +++ b/parser/manifest.xsd.in @@ -17,8 +17,8 @@ - + @@ -27,6 +27,7 @@ + @@ -93,6 +94,8 @@ + + @@ -108,9 +111,12 @@ + + + @@ -118,12 +124,17 @@ + + + + + @@ -145,10 +156,10 @@ - - + + @@ -165,10 +176,16 @@ - + + + + + + + @@ -215,6 +232,17 @@ + + + + + + + + + + + diff --git a/parser/pkgmgr_parser.c b/parser/pkgmgr_parser.c index e2fd020..c6b8dce 100755 --- a/parser/pkgmgr_parser.c +++ b/parser/pkgmgr_parser.c @@ -60,6 +60,8 @@ static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp); 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_metadata(xmlTextReaderPtr reader, metadata_x *metadata); +static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission); 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); @@ -93,6 +95,8 @@ static void __ps_free_subapp(subapp_x *subapp); 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_metadata(metadata_x *metadata); +static void __ps_free_permission(permission_x *permission); static void __ps_free_compatibility(compatibility_x *compatibility); static void __ps_free_resolution(resolution_x *resolution); static void __ps_free_request(request_x *request); @@ -600,6 +604,38 @@ static void __ps_free_category(category_x *category) category = NULL; } +static void __ps_free_metadata(metadata_x *metadata) +{ + if (metadata == NULL) + return; + if (metadata->name) { + free((void *)metadata->name); + metadata->name = NULL; + } + if (metadata->value) { + free((void *)metadata->value); + metadata->value = NULL; + } + free((void*)metadata); + metadata = NULL; +} + +static void __ps_free_permission(permission_x *permission) +{ + if (permission == NULL) + return; + if (permission->type) { + free((void *)permission->type); + permission->type = NULL; + } + if (permission->value) { + free((void *)permission->value); + permission->value = NULL; + } + free((void*)permission); + permission = NULL; +} + static void __ps_free_icon(icon_x *icon) { if (icon == NULL) @@ -632,6 +668,30 @@ static void __ps_free_icon(icon_x *icon) icon = NULL; } +static void __ps_free_image(image_x *image) +{ + if (image == NULL) + return; + if (image->text) { + free((void *)image->text); + image->text = NULL; + } + if (image->lang) { + free((void *)image->lang); + image->lang = NULL; + } + if (image->name) { + free((void *)image->name); + image->name= NULL; + } + if (image->section) { + free((void *)image->section); + image->section = NULL; + } + free((void*)image); + image = NULL; +} + static void __ps_free_operation(operation_x *operation) { if (operation == NULL) @@ -1186,6 +1246,10 @@ static void __ps_free_uiapplication(uiapplication_x *uiapplication) free((void *)uiapplication->taskmanage); uiapplication->taskmanage = NULL; } + if (uiapplication->enabled) { + free((void *)uiapplication->enabled); + uiapplication->enabled = NULL; + } if (uiapplication->hwacceleration) { free((void *)uiapplication->hwacceleration); uiapplication->hwacceleration = NULL; @@ -1220,6 +1284,17 @@ static void __ps_free_uiapplication(uiapplication_x *uiapplication) icon = tmp; } } + /*Free image*/ + if (uiapplication->image) { + image_x *image = uiapplication->image; + image_x *tmp = NULL; + while(image != NULL) + { + tmp = image->next; + __ps_free_image(image); + image = tmp; + } + } /*Free AppControl*/ if (uiapplication->appcontrol) { appcontrol_x *appcontrol = uiapplication->appcontrol; @@ -1286,6 +1361,46 @@ static void __ps_free_uiapplication(uiapplication_x *uiapplication) category = tmp; } } + /*Free Metadata*/ + if (uiapplication->metadata) { + metadata_x *metadata = uiapplication->metadata; + metadata_x *tmp = NULL; + while(metadata != NULL) + { + tmp = metadata->next; + __ps_free_metadata(metadata); + metadata = tmp; + } + } + /*Free permission*/ + if (uiapplication->permission) { + permission_x *permission = uiapplication->permission; + permission_x *tmp = NULL; + while(permission != NULL) + { + tmp = permission->next; + __ps_free_permission(permission); + permission = tmp; + } + } + /* _PRODUCT_LAUNCHING_ENHANCED_ START */ + if (uiapplication->indicatordisplay) { + free((void *)uiapplication->indicatordisplay); + uiapplication->indicatordisplay = NULL; + } + if (uiapplication->portraitimg) { + free((void *)uiapplication->portraitimg); + uiapplication->portraitimg = NULL; + } + if (uiapplication->landscapeimg) { + free((void *)uiapplication->landscapeimg); + uiapplication->landscapeimg = NULL; + } + /* _PRODUCT_LAUNCHING_ENHANCED_ END */ + if (uiapplication->guestmode_visibility) { + free((void *)uiapplication->guestmode_visibility); + uiapplication->guestmode_visibility = NULL; + } free((void*)uiapplication); uiapplication = NULL; } @@ -1413,6 +1528,28 @@ static void __ps_free_serviceapplication(serviceapplication_x *serviceapplicatio category = tmp; } } + /*Free Metadata*/ + if (serviceapplication->metadata) { + metadata_x *metadata = serviceapplication->metadata; + metadata_x *tmp = NULL; + while(metadata != NULL) + { + tmp = metadata->next; + __ps_free_metadata(metadata); + metadata = tmp; + } + } + /*Free permission*/ + if (serviceapplication->permission) { + permission_x *permission = serviceapplication->permission; + permission_x *tmp = NULL; + while(permission != NULL) + { + tmp = permission->next; + __ps_free_permission(permission); + permission = tmp; + } + } free((void*)serviceapplication); serviceapplication = NULL; } @@ -1565,6 +1702,27 @@ static int __ps_process_category(xmlTextReaderPtr reader, category_x *category) return 0; } +static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata) +{ + /*name and value both should exist. If any one attribute is missing then dont parse*/ + if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")) && xmlTextReaderGetAttribute(reader, XMLCHAR("value"))) { + metadata->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name"))); + metadata->value = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("value"))); + } + return 0; +} + +static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission) +{ + if (xmlTextReaderGetAttribute(reader, XMLCHAR("type"))) + permission->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type"))); + + xmlTextReaderRead(reader); + if (xmlTextReaderValue(reader)) + permission->value = ASCII(xmlTextReaderValue(reader)); + +} + static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility) { if (xmlTextReaderGetAttribute(reader, XMLCHAR("name"))) @@ -2038,6 +2196,26 @@ static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon) return 0; } +static int __ps_process_image(xmlTextReaderPtr reader, image_x *image) +{ + if (xmlTextReaderGetAttribute(reader, XMLCHAR("name"))) + image->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name"))); + if (xmlTextReaderConstXmlLang(reader)) { + image->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader))); + if (image->lang == NULL) + image->lang = strdup(DEFAULT_LOCALE); + } else { + image->lang = strdup(DEFAULT_LOCALE); + } + if (xmlTextReaderGetAttribute(reader, XMLCHAR("section"))) + image->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section"))); + xmlTextReaderRead(reader); + if (xmlTextReaderValue(reader)) + image->text = ASCII(xmlTextReaderValue(reader)); + + return 0; +} + static int __ps_process_label(xmlTextReaderPtr reader, label_x *label) { if (xmlTextReaderGetAttribute(reader, XMLCHAR("name"))) @@ -2210,6 +2388,9 @@ static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x * notification_x *tmp6 = NULL; datashare_x *tmp7 = NULL; category_x *tmp8 = NULL; + metadata_x *tmp9 = NULL; + image_x *tmp10 = NULL; + permission_x *tmp11 = NULL; if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) { uiapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))); @@ -2262,6 +2443,13 @@ static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x * } else { uiapplication->taskmanage = strdup("true"); } + if (xmlTextReaderGetAttribute(reader, XMLCHAR("enabled"))) { + uiapplication->enabled = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("enabled"))); + if (uiapplication->enabled == NULL) + uiapplication->enabled = strdup("true"); + } else { + uiapplication->enabled = strdup("true"); + } if (xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration"))) { uiapplication->hwacceleration = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration"))); if (uiapplication->hwacceleration == NULL) @@ -2278,6 +2466,28 @@ static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x * } else { uiapplication->mainapp = strdup("false"); } + if (xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay"))) { + uiapplication->indicatordisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay"))); + if (uiapplication->indicatordisplay == NULL) + uiapplication->indicatordisplay = strdup("true"); + } else { + uiapplication->indicatordisplay = strdup("true"); + } + if (xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage"))) + uiapplication->portraitimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage"))); + else + uiapplication->portraitimg = NULL; + if (xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage"))) + uiapplication->landscapeimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage"))); + else + uiapplication->landscapeimg = NULL; + if (xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility"))) { + uiapplication->guestmode_visibility = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility"))); + if (uiapplication->guestmode_visibility == NULL) + uiapplication->guestmode_visibility = strdup("true"); + } else { + uiapplication->guestmode_visibility = strdup("true"); + } depth = xmlTextReaderDepth(reader); while ((ret = __next_child_element(reader, depth))) { @@ -2304,6 +2514,15 @@ static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x * memset(icon, '\0', sizeof(icon_x)); LISTADD(uiapplication->icon, icon); ret = __ps_process_icon(reader, icon); + } else if (!strcmp(ASCII(node), "image")) { + image_x *image = malloc(sizeof(image_x)); + if (image == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(image, '\0', sizeof(image_x)); + LISTADD(uiapplication->image, image); + ret = __ps_process_image(reader, image); } else if (!strcmp(ASCII(node), "category")) { category_x *category = malloc(sizeof(category_x)); if (category == NULL) { @@ -2313,6 +2532,24 @@ static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x * memset(category, '\0', sizeof(category_x)); LISTADD(uiapplication->category, category); ret = __ps_process_category(reader, category); + } else if (!strcmp(ASCII(node), "metadata")) { + metadata_x *metadata = malloc(sizeof(metadata_x)); + if (metadata == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(metadata, '\0', sizeof(metadata_x)); + LISTADD(uiapplication->metadata, metadata); + ret = __ps_process_metadata(reader, metadata); + } else if (!strcmp(ASCII(node), "permission")) { + permission_x *permission = malloc(sizeof(permission_x)); + if (permission == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(permission, '\0', sizeof(permission_x)); + LISTADD(uiapplication->permission, permission); + ret = __ps_process_permission(reader, permission); } else if (!strcmp(ASCII(node), "app-control")) { appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x)); if (appcontrol == NULL) { @@ -2398,6 +2635,18 @@ static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x * LISTHEAD(uiapplication->category, tmp8); uiapplication->category = tmp8; } + if (uiapplication->metadata) { + LISTHEAD(uiapplication->metadata, tmp9); + uiapplication->metadata = tmp9; + } + if (uiapplication->image) { + LISTHEAD(uiapplication->image, tmp10); + uiapplication->image = tmp10; + } + if (uiapplication->permission) { + LISTHEAD(uiapplication->permission, tmp11); + uiapplication->permission = tmp11; + } return ret; } @@ -2417,6 +2666,8 @@ static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceappli notification_x *tmp7 = NULL; datashare_x *tmp8 = NULL; category_x *tmp9 = NULL; + metadata_x *tmp10 = NULL; + permission_x *tmp11 = NULL; if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) { serviceapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))); @@ -2494,6 +2745,24 @@ static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceappli memset(category, '\0', sizeof(category_x)); LISTADD(serviceapplication->category, category); ret = __ps_process_category(reader, category); + } else if (!strcmp(ASCII(node), "metadata")) { + metadata_x *metadata = malloc(sizeof(metadata_x)); + if (metadata == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(metadata, '\0', sizeof(metadata_x)); + LISTADD(serviceapplication->metadata, metadata); + ret = __ps_process_metadata(reader, metadata); + } else if (!strcmp(ASCII(node), "permission")) { + permission_x *permission = malloc(sizeof(permission_x)); + if (permission == NULL) { + DBG("Malloc Failed\n"); + return -1; + } + memset(permission, '\0', sizeof(permission_x)); + LISTADD(serviceapplication->permission, permission); + ret = __ps_process_permission(reader, permission); } else if (!strcmp(ASCII(node), "app-control")) { appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x)); if (appcontrol == NULL) { @@ -2592,6 +2861,14 @@ static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceappli LISTHEAD(serviceapplication->category, tmp9); serviceapplication->category = tmp9; } + if (serviceapplication->metadata) { + LISTHEAD(serviceapplication->metadata, tmp10); + serviceapplication->metadata = tmp10; + } + if (serviceapplication->permission) { + LISTHEAD(serviceapplication->permission, tmp11); + serviceapplication->permission = tmp11; + } return ret; } @@ -2775,10 +3052,10 @@ static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx) continue; } else if (!strcmp(ASCII(node), "livebox")) { continue; - } else if (!strcmp(ASCII(node), "Accounts")) { - continue; } else if (!strcmp(ASCII(node), "account")) { continue; + } else if (!strcmp(ASCII(node), "notifications")) { + continue; } else return -1; @@ -2878,6 +3155,9 @@ static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx) mfx->installlocation = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("install-location"))); if (xmlTextReaderGetAttribute(reader, XMLCHAR("type"))) mfx->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type"))); + if (xmlTextReaderGetAttribute(reader, XMLCHAR("root_path"))) + mfx->root_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("root_path"))); + /*Assign default values. If required it will be overwritten in __add_preload_info()*/ mfx->preload = strdup("False"); mfx->removable = strdup("True"); @@ -2920,11 +3200,64 @@ static char* __convert_to_system_locale(const char *mlocale) return locale; } +#define LIBAIL_PATH "/usr/lib/libail.so.0" + +/* operation_type */ +typedef enum { + AIL_INSTALL = 0, + AIL_UPDATE, + AIL_REMOVE, + AIL_MAX +} AIL_TYPE; + +static int __ail_change_info(int op, const char *appid) +{ + void *lib_handle = NULL; + int (*ail_desktop_operation) (const char *); + char *aop = NULL; + int ret = 0; + + if ((lib_handle = dlopen(LIBAIL_PATH, RTLD_LAZY)) == NULL) { + DBGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAIL_PATH); + goto END; + } + + + switch (op) { + case 0: + aop = "ail_desktop_add"; + break; + case 1: + aop = "ail_desktop_update"; + break; + case 2: + aop = "ail_desktop_remove"; + break; + default: + goto END; + break; + } + + if ((ail_desktop_operation = + dlsym(lib_handle, aop)) == NULL || dlerror() != NULL) { + DBGE("can not find symbol \n"); + goto END; + } + + ret = ail_desktop_operation(appid); + +END: + if (lib_handle) + dlclose(lib_handle); + + return ret; +} + /* desktop shoud be generated automatically based on manifest */ /* Currently removable, taskmanage, etc fields are not considerd. it will be decided soon.*/ #define BUFMAX 1024*128 -static int __ps_make_nativeapp_desktop(manifest_x * mfx) +static int __ps_make_nativeapp_desktop(manifest_x * mfx, bool is_update) { FILE* file = NULL; int fd = 0; @@ -3033,6 +3366,11 @@ static int __ps_make_nativeapp_desktop(manifest_x * mfx) fwrite(buf, 1, strlen(buf), file); } + if(mfx->uiapplication->enabled && !strcasecmp(mfx->uiapplication->enabled, "False")) { + snprintf(buf, BUFMAX, "X-TIZEN-Enabled=False\n"); + fwrite(buf, 1, strlen(buf), file); + } + if(mfx->uiapplication->hwacceleration) { snprintf(buf, BUFMAX, "Hw-Acceleration=%s\n", mfx->uiapplication->hwacceleration); fwrite(buf, 1, strlen(buf), file); @@ -3231,6 +3569,11 @@ static int __ps_make_nativeapp_desktop(manifest_x * mfx) fd = fileno(file); fsync(fd); fclose(file); + + if (!is_update) + __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid); + else + __ail_change_info(AIL_UPDATE, mfx->uiapplication->appid); } free(buf); @@ -3241,12 +3584,14 @@ static int __ps_make_nativeapp_desktop(manifest_x * mfx) static int __ps_remove_nativeapp_desktop(manifest_x *mfx) { - char filepath[PKG_STRING_LEN_MAX] = ""; + char filepath[PKG_STRING_LEN_MAX] = ""; int ret = 0; for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) { snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, mfx->uiapplication->appid); + __ail_change_info(AIL_REMOVE, mfx->uiapplication->appid); + ret = remove(filepath); if (ret <0) return -1; @@ -3356,6 +3701,10 @@ API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx) free((void *)mfx->type); mfx->type = NULL; } + if (mfx->package_size) { + free((void *)mfx->package_size); + mfx->package_size = NULL; + } if (mfx->installed_time) { free((void *)mfx->installed_time); mfx->installed_time = NULL; @@ -3372,6 +3721,10 @@ API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx) free((void *)mfx->package_url); mfx->package_url = NULL; } + if (mfx->root_path) { + free((void *)mfx->root_path); + mfx->root_path = NULL; + } /*Free Icon*/ if (mfx->icon) { @@ -3552,7 +3905,7 @@ API manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest) API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[]) { - char *temp[] = {"shortcut-list", "livebox", "Accounts", "account", NULL}; + char *temp[] = {"shortcut-list", "livebox", "account", "notifications", NULL}; if (manifest == NULL) { DBG("argument supplied is NULL\n"); return PMINFO_R_EINVAL; @@ -3575,7 +3928,7 @@ API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char else DBG("DB Insert Success\n"); - ret = __ps_make_nativeapp_desktop(mfx); + ret = __ps_make_nativeapp_desktop(mfx, 0); if (ret == -1) DBG("Creating desktop file failed\n"); else @@ -3588,9 +3941,25 @@ API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char return PMINFO_R_OK; } +API int pkgmgr_parser_create_desktop_file(manifest_x *mfx) +{ + int ret = 0; + if (mfx == NULL) { + DBG("Manifest pointer is NULL\n"); + return -1; + } + ret = __ps_make_nativeapp_desktop(mfx, 0); + if (ret == -1) + DBG("Creating desktop file failed\n"); + else + DBG("Creating desktop file Success\n"); + return ret; +} + + API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[]) { - char *temp[] = {"shortcut-list", "livebox", "Accounts", "account", NULL}; + char *temp[] = {"shortcut-list", "livebox", "account", "notifications", NULL}; if (manifest == NULL) { DBG("argument supplied is NULL\n"); return PMINFO_R_EINVAL; @@ -3613,7 +3982,7 @@ API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *con else DBG("DB Update Success\n"); - ret = __ps_make_nativeapp_desktop(mfx); + ret = __ps_make_nativeapp_desktop(mfx, 1); if (ret == -1) DBG("Creating desktop file failed\n"); else @@ -3628,7 +3997,7 @@ API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *con API int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[]) { - char *temp[] = {"shortcut-list", "livebox", "Accounts", "account", NULL}; + char *temp[] = {"shortcut-list", "livebox", "account", "notifications", NULL}; if (manifest == NULL) { DBG("argument supplied is NULL\n"); return PMINFO_R_EINVAL; diff --git a/parser/pkgmgr_parser.h b/parser/pkgmgr_parser.h index 39ea33d..a965298 100755 --- a/parser/pkgmgr_parser.h +++ b/parser/pkgmgr_parser.h @@ -107,13 +107,27 @@ extern "C" { * @brief Convinience Macro to get list head */ #define LISTHEAD(list, node) \ - for ((node) = (list); (node)->prev; (node) = (node)->prev); + for ((node) = (list); (node)->prev; (node) = (node)->prev) /** * @brief Convinience Macro to get list tail */ #define LISTTAIL(list, node) \ - for ((node) = (list); (node)->next; (node) = (node)->next); + for ((node) = (list); (node)->next; (node) = (node)->next) + +typedef struct metadata_x { + const char *name; + const char *value; + struct metadata_x *prev; + struct metadata_x *next; +} metadata_x; + +typedef struct permission_x { + const char *type; + const char *value; + struct permission_x *prev; + struct permission_x *next; +} permission_x; typedef struct icon_x { const char *name; @@ -126,6 +140,15 @@ typedef struct icon_x { struct icon_x *next; } icon_x; +typedef struct image_x { + const char *name; + const char *text; + const char *lang; + const char *section; + struct icon_x *prev; + struct icon_x *next; +} image_x; + typedef struct allowed_x { const char *name; const char *text; @@ -324,6 +347,7 @@ typedef struct uiapplication_x { const char *nodisplay; const char *multiple; const char *taskmanage; + const char *enabled; const char *type; const char *categories; const char *extraid; @@ -331,11 +355,18 @@ typedef struct uiapplication_x { const char *mainapp; const char *package; const char *recentimage; + const char *indicatordisplay; + const char *portraitimg; + const char *landscapeimg; + const char *guestmode_visibility; struct label_x *label; struct icon_x *icon; + struct image_x *image; struct appsvc_x *appsvc; struct appcontrol_x *appcontrol; struct category_x *category; + struct metadata_x *metadata; + struct permission_x *permission; struct launchconditions_x *launchconditions; struct notification_x *notification; struct datashare_x *datashare; @@ -348,6 +379,7 @@ typedef struct serviceapplication_x { const char *exec; const char *onboot; const char *autorestart; + const char *enabled; const char *type; const char *package; struct label_x *label; @@ -355,6 +387,8 @@ typedef struct serviceapplication_x { struct appsvc_x *appsvc; struct appcontrol_x *appcontrol; struct category_x *category; + struct metadata_x *metadata; + struct permission_x *permission; struct datacontrol_x *datacontrol; struct launchconditions_x *launchconditions; struct notification_x *notification; @@ -405,6 +439,7 @@ typedef struct manifest_x { const char *storeclient_id; /**< id of store client for installed package*/ const char *mainapp_id; /**< app id of main application*/ const char *package_url; /**< app id of main application*/ + const char *root_path; /**< package root path*/ struct icon_x *icon; /**< package icon*/ struct label_x *label; /**< package label*/ struct author_x *author; /**< package author*/ @@ -608,6 +643,32 @@ static int parse_manifest_file(const char *manifest) */ manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest); +/** + * @fn manifest_x *pkgmgr_parser_get_manifest_info(const char *pkigid) + * @brief This API gets the manifest info from DB and stores all the data in the manifest structure. + * + * @par This API is for package-manager installer backends. + * @par Sync (or) Async : Synchronous API + * + * @param[in] pkgid package id for package + * @return manifest pointer on success, NULL on failure + * @pre None + * @post pkgmgr_parser_free_manifest_xml() + * @code +static int get_manifest_info(const char *pkgid) +{ + manifest_x *mfx = NULL + mfx = pkgmgr_parser_get_manifest_info(pkgid); + if (mfx == NULL) + return -1; + printf("Parsing Manifest Success\n"); + pkgmgr_parser_free_manifest_xml(mfx); + return 0; +} + * @endcode + */ +manifest_x *pkgmgr_parser_get_manifest_info(const char *pkigid); + /* These APIs are intended to call parser directly */ typedef int (*ps_iter_fn) (const char *tag, int type, void *userdata); @@ -701,6 +762,36 @@ static int parse_docptr_for_uninstallation(xmlDocPtr docPtr) */ int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgid); +/** + * @fn int pkgmgr_parser_create_desktop_file(manifest_x *mfx) + * @brief This API generates the application desktop file + * + * @par This API is for package-manager installer backends. + * @par Sync (or) Async : Synchronous API + * + * @param[in] mfx manifest pointer + * @return 0 if success, error code(<0) if fail + * @retval PMINFO_R_OK success + * @retval PMINFO_R_EINVAL invalid argument + * @retval PMINFO_R_ERROR internal error + * @pre pkgmgr_parser_process_manifest_xml() + * @post pkgmgr_parser_free_manifest_xml() + * @code +static int create_desktop_file(char *manifest) +{ + int ret = 0; + manifest_x *mfx = NULL; + mfx = pkgmgr_parser_process_manifest_xml(manifest); + ret = pkgmgr_parser_create_desktop_file(mfx); + if (ret) + return -1; + pkgmgr_parser_free_manifest_xml(mfx); + return 0; +} + * @endcode + */ +int pkgmgr_parser_create_desktop_file(manifest_x *mfx); + /** @} */ #ifdef __cplusplus } diff --git a/parser/pkgmgr_parser_db.c b/parser/pkgmgr_parser_db.c index e783913..d82b290 100755 --- a/parser/pkgmgr_parser_db.c +++ b/parser/pkgmgr_parser_db.c @@ -39,6 +39,7 @@ sqlite3 *pkgmgr_cert_db; GList *pkglocale = NULL; GList *applocale = NULL; GList *appicon = NULL; +GList *appimage = NULL; char *prev = NULL; #define QUERY_CREATE_TABLE_PACKAGE_INFO "create table if not exists package_info " \ @@ -56,7 +57,8 @@ char *prev = NULL; "installed_time text," \ "storeclient_id text," \ "mainapp_id text," \ - "package_url text)" + "package_url text," \ + "root_path text)" #define QUERY_CREATE_TABLE_PACKAGE_LOCALIZED_INFO "create table if not exists package_localized_info " \ "(package text not null, " \ @@ -81,9 +83,14 @@ char *prev = NULL; "app_multiple text DEFAULT 'false', " \ "app_autorestart text DEFAULT 'false', " \ "app_taskmanage text DEFAULT 'false', " \ + "app_enabled text DEFAULT 'true', " \ "app_hwacceleration text DEFAULT 'use-system-setting', " \ "app_mainapp text, " \ "app_recentimage text, " \ + "app_indicatordisplay text DEFAULT 'true', " \ + "app_portraitimg text, " \ + "app_landscapeimg text, " \ + "app_guestmodevisibility text DEFAULT 'true', " \ "package text not null, " \ "FOREIGN KEY(package) " \ "REFERENCES package_info(package) " \ @@ -99,13 +106,22 @@ char *prev = NULL; "REFERENCES package_app_info(app_id) " \ "ON DELETE CASCADE)" -#define QUERY_CREATE_TABLE_PACKAGE_APP_ICON_LOCALIZED_INFO "create table if not exists package_app_icon_localized_info " \ +#define QUERY_CREATE_TABLE_PACKAGE_APP_ICON_SECTION_INFO "create table if not exists package_app_icon_section_info " \ "(app_id text not null, " \ - "app_locale text DEFAULT 'No Locale', " \ "app_icon text, " \ "app_icon_section text, " \ "app_icon_resolution text, " \ - "PRIMARY KEY(app_id,app_locale,app_icon_section,app_icon_resolution) " \ + "PRIMARY KEY(app_id,app_icon_section,app_icon_resolution) " \ + "FOREIGN KEY(app_id) " \ + "REFERENCES package_app_info(app_id) " \ + "ON DELETE CASCADE)" + +#define QUERY_CREATE_TABLE_PACKAGE_APP_IMAGE_INFO "create table if not exists package_app_image_info " \ + "(app_id text not null, " \ + "app_locale text DEFAULT 'No Locale', " \ + "app_image_section text, " \ + "app_image text, " \ + "PRIMARY KEY(app_id,app_image_section) " \ "FOREIGN KEY(app_id) " \ "REFERENCES package_app_info(app_id) " \ "ON DELETE CASCADE)" @@ -140,6 +156,24 @@ char *prev = NULL; "REFERENCES package_app_info(app_id) " \ "ON DELETE CASCADE)" +#define QUERY_CREATE_TABLE_PACKAGE_APP_APP_METADATA "create table if not exists package_app_app_metadata " \ + "(app_id text not null, " \ + "md_name text not null, " \ + "md_value text not null, " \ + "PRIMARY KEY(app_id, md_name) " \ + "FOREIGN KEY(app_id) " \ + "REFERENCES package_app_info(app_id) " \ + "ON DELETE CASCADE)" + +#define QUERY_CREATE_TABLE_PACKAGE_APP_APP_PERMISSION "create table if not exists package_app_app_permission " \ + "(app_id text not null, " \ + "pm_type text not null, " \ + "pm_value text not null, " \ + "PRIMARY KEY(app_id) " \ + "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, " \ @@ -180,6 +214,8 @@ static int __insert_serviceapplication_appsvc_info(manifest_x *mfx); static int __insert_uiapplication_appcategory_info(manifest_x *mfx); static int __insert_serviceapplication_appcategory_info(manifest_x *mfx); static int __insert_uiapplication_appcontrol_info(manifest_x *mfx); +static int __insert_serviceapplication_appmetadata_info(manifest_x *mfx); +static int __insert_uiapplication_appmetadata_info(manifest_x *mfx); static int __insert_serviceapplication_appcontrol_info(manifest_x *mfx); static int __insert_uiapplication_share_allowed_info(manifest_x *mfx); static int __insert_serviceapplication_share_allowed_info(manifest_x *mfx); @@ -197,10 +233,12 @@ static int __initialize_package_localized_info_db(); static int __initialize_package_app_info_db(); static int __initialize_package_cert_info_db(); static int __initialize_package_app_localized_info_db(); -static int __initialize_package_app_icon_localized_info_db(); +static int __initialize_package_app_icon_section_info_db(); +static int __initialize_package_app_image_info_db(); static int __initialize_package_app_app_svc_db(); static int __initialize_package_app_app_category_db(); static int __initialize_package_app_app_control_db(); +static int __initialize_package_app_app_metadata_db(); static int __initialize_package_app_share_allowed_db(); static int __initialize_package_app_share_request_db(); static int __exec_query(char *query); @@ -211,6 +249,62 @@ 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 void __preserve_guestmode_visibility_value(manifest_x *mfx); +static int __guestmode_visibility_cb(void *data, int ncols, char **coltxt, char **colname); + +static int __guestmode_visibility_cb(void *data, int ncols, char **coltxt, char **colname) +{ + manifest_x *mfx = (manifest_x *)data; + int i = 0; + char *appid = NULL; + char *status = NULL; + uiapplication_x *uiapp = NULL; + for(i = 0; i < ncols; i++) + { + uiapp = mfx->uiapplication; + if (strcmp(colname[i], "app_id") == 0) { + if (coltxt[i]) + appid = strdup(coltxt[i]); + } else if (strcmp(colname[i], "app_guestmodevisibility") == 0) { + if (coltxt[i]) + status = strdup(coltxt[i]); + } + } + /*update guest mode visibility*/ + for (; uiapp != NULL; uiapp = uiapp->next) { + if (strcmp(uiapp->appid, appid) == 0) { + free((void *)uiapp->guestmode_visibility); + uiapp->guestmode_visibility = strdup(status); + break; + } + } + if (appid) { + free(appid); + appid = NULL; + } + if (status) { + free(status); + status = NULL; + } + + return 0; +} + +static void __preserve_guestmode_visibility_value(manifest_x *mfx) +{ + int ret = -1; + char *error_message = NULL; + char query[MAX_QUERY_LEN] = {'\0'}; + snprintf(query, MAX_QUERY_LEN - 1, "select app_id, app_guestmodevisibility from package_app_info where package='%s'", mfx->package); + if (SQLITE_OK != + sqlite3_exec(pkgmgr_parser_db, query, + __guestmode_visibility_cb, (void *)mfx, &error_message)) { + DBG("Don't execute query = %s error message = %s\n", + query, error_message); + sqlite3_free(error_message); + } + return; +} static int __initialize_package_info_db() { @@ -327,15 +421,32 @@ static int __initialize_package_app_localized_info_db() return 0; } -static int __initialize_package_app_icon_localized_info_db() +static int __initialize_package_app_icon_section_info_db() { char *error_message = NULL; if (SQLITE_OK != sqlite3_exec(pkgmgr_parser_db, - QUERY_CREATE_TABLE_PACKAGE_APP_ICON_LOCALIZED_INFO, NULL, + QUERY_CREATE_TABLE_PACKAGE_APP_ICON_SECTION_INFO, NULL, NULL, &error_message)) { DBG("Don't execute query = %s error message = %s\n", - QUERY_CREATE_TABLE_PACKAGE_APP_ICON_LOCALIZED_INFO, + QUERY_CREATE_TABLE_PACKAGE_APP_ICON_SECTION_INFO, + error_message); + sqlite3_free(error_message); + return -1; + } + sqlite3_free(error_message); + return 0; +} + +static int __initialize_package_app_image_info_db() +{ + char *error_message = NULL; + if (SQLITE_OK != + sqlite3_exec(pkgmgr_parser_db, + QUERY_CREATE_TABLE_PACKAGE_APP_IMAGE_INFO, NULL, + NULL, &error_message)) { + DBG("Don't execute query = %s error message = %s\n", + QUERY_CREATE_TABLE_PACKAGE_APP_IMAGE_INFO, error_message); sqlite3_free(error_message); return -1; @@ -376,6 +487,38 @@ static int __initialize_package_app_app_category_db() return 0; } +static int __initialize_package_app_app_metadata_db() +{ + char *error_message = NULL; + if (SQLITE_OK != + sqlite3_exec(pkgmgr_parser_db, + QUERY_CREATE_TABLE_PACKAGE_APP_APP_METADATA, NULL, NULL, + &error_message)) { + DBG("Don't execute query = %s error message = %s\n", + QUERY_CREATE_TABLE_PACKAGE_APP_APP_METADATA, error_message); + sqlite3_free(error_message); + return -1; + } + sqlite3_free(error_message); + return 0; +} + +static int __initialize_package_app_app_permission_db() +{ + char *error_message = NULL; + if (SQLITE_OK != + sqlite3_exec(pkgmgr_parser_db, + QUERY_CREATE_TABLE_PACKAGE_APP_APP_PERMISSION, NULL, NULL, + &error_message)) { + DBG("Don't execute query = %s error message = %s\n", + QUERY_CREATE_TABLE_PACKAGE_APP_APP_PERMISSION, 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; @@ -487,6 +630,17 @@ static GList *__create_icon_list(GList *locale, icon_x *icn) return locale; } +static GList *__create_image_list(GList *locale, image_x *image) +{ + while(image != NULL) + { + if (image->section) + locale = g_list_insert_sorted_with_data(locale, (gpointer)image->section, __comparefunc, NULL); + image = image->next; + } + return locale; +} + static void __printfunc(gpointer data, gpointer userdata) { DBG("%s ", (char*)data); @@ -528,6 +682,18 @@ static void __trimfunc3(gpointer data, gpointer userdata) prev = (char *)data; } +static void __trimfunc4(gpointer data, gpointer userdata) +{ + if (prev) { + if (strcmp((char *)data, prev) == 0) { + appimage = g_list_remove(appimage, data); + } else + prev = (char *)data; + } + else + prev = (char *)data; +} + static gint __comparefunc(gconstpointer a, gconstpointer b, gpointer userdata) { if (a == NULL || b == NULL) @@ -596,13 +762,12 @@ static void __extract_data(gpointer data, label_x *lbl, license_x *lcn, icon_x * } -static void __extract_icon_data(gpointer data, icon_x *icn, char **lang, char **icon, char **resolution) +static void __extract_icon_data(gpointer data, icon_x *icn, char **icon, char **resolution) { while(icn != NULL) { if (icn->section) { if (strcmp(icn->section, (char *)data) == 0) { - *lang = (char*)icn->lang; *icon = (char*)icn->text; *resolution = (char*)icn->resolution; break; @@ -612,6 +777,21 @@ static void __extract_icon_data(gpointer data, icon_x *icn, char **lang, char ** } } +static void __extract_image_data(gpointer data, icon_x *image, char **lang, char **img) +{ + while(image != NULL) + { + if (image->section) { + if (strcmp(image->section, (char *)data) == 0) { + *lang = (char*)image->lang; + *img = (char*)image->text; + break; + } + } + image = image->next; + } +} + static void __insert_pkglocale_info(gpointer data, gpointer userdata) { int ret = -1; @@ -665,10 +845,9 @@ static void __insert_uiapplication_locale_info(gpointer data, gpointer userdata) } -static void __insert_uiapplication_icon_locale_info(gpointer data, gpointer userdata) +static void __insert_uiapplication_icon_section_info(gpointer data, gpointer userdata) { int ret = -1; - char *lang = NULL; char *icon = NULL; char *resolution = NULL; char query[MAX_QUERY_LEN] = {'\0'}; @@ -676,12 +855,12 @@ static void __insert_uiapplication_icon_locale_info(gpointer data, gpointer user uiapplication_x *up = (uiapplication_x*)userdata; icon_x *icn = up->icon; - __extract_icon_data(data, icn, &lang, &icon, &resolution); - if (!lang && !icon && !resolution) + __extract_icon_data(data, icn, &icon, &resolution); + if (!icon && !resolution) return; - sqlite3_snprintf(MAX_QUERY_LEN, query, "insert into package_app_icon_localized_info(app_id, app_locale, " \ + sqlite3_snprintf(MAX_QUERY_LEN, query, "insert into package_app_icon_section_info(app_id, " \ "app_icon, app_icon_section, app_icon_resolution) values " \ - "('%q', '%q', '%q', '%q', '%q')", up->appid, lang, + "('%q', '%q', '%q', '%q')", up->appid, icon, (char*)data, resolution); ret = __exec_query(query); @@ -690,6 +869,30 @@ static void __insert_uiapplication_icon_locale_info(gpointer data, gpointer user } +static void __insert_uiapplication_image_info(gpointer data, gpointer userdata) +{ + int ret = -1; + char *lang = NULL; + char *img = NULL; + char query[MAX_QUERY_LEN] = {'\0'}; + + uiapplication_x *up = (uiapplication_x*)userdata; + image_x *image = up->image; + + __extract_image_data(data, image, &lang, &img); + if (!lang && !img) + return; + sqlite3_snprintf(MAX_QUERY_LEN, query, "insert into package_app_image_info(app_id, app_locale, " \ + "app_image_section, app_image) values " \ + "('%q', '%q', '%q', '%q')", up->appid, lang, (char*)data, img); + + ret = __exec_query(query); + if (ret == -1) + DBG("Package UiApp image Info DB Insert failed\n"); + +} + + static void __insert_serviceapplication_locale_info(gpointer data, gpointer userdata) { int ret = -1; @@ -736,15 +939,30 @@ static int __insert_ui_mainapp_info(manifest_x *mfx) } if (mfx->mainapp_id == NULL){ - snprintf(query, MAX_QUERY_LEN, + if (mfx->uiapplication + && mfx->uiapplication->appid) { + snprintf(query, MAX_QUERY_LEN, "update package_app_info set app_mainapp='true' where app_id='%s'", mfx->uiapplication->appid); + } else if (mfx->serviceapplication + && mfx->serviceapplication->appid) { + snprintf(query, MAX_QUERY_LEN, + "update package_app_info set app_mainapp='true' where app_id='%s'", mfx->serviceapplication->appid); + } else { + DBG("Not valid appid\n"); + return -1; + } + ret = __exec_query(query); if (ret == -1) { DBG("Package UiApp Info DB Insert Failed\n"); return -1; } - mfx->mainapp_id = strdup(mfx->uiapplication->appid); - } + if (mfx->uiapplication && mfx->uiapplication->appid) + mfx->mainapp_id = strdup(mfx->uiapplication->appid); + else if (mfx->serviceapplication && mfx->serviceapplication->appid) + mfx->mainapp_id = strdup(mfx->serviceapplication->appid); + +} memset(query, '\0', MAX_QUERY_LEN); snprintf(query, MAX_QUERY_LEN, @@ -757,7 +975,9 @@ static int __insert_ui_mainapp_info(manifest_x *mfx) return 0; } - +/* _PRODUCT_LAUNCHING_ENHANCED_ +* up->indicatordisplay, up->portraitimg, up->landscapeimg, up->guestmode_appstatus +*/ static int __insert_uiapplication_info(manifest_x *mfx) { uiapplication_x *up = mfx->uiapplication; @@ -767,10 +987,10 @@ static int __insert_uiapplication_info(manifest_x *mfx) { 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, app_hwacceleration, app_mainapp , app_recentimage, package) " \ - "values('%s', '%s', '%s', '%s', '%s', '%s','%s', '%s', '%s', '%s', '%s', '%s', '%s')",\ + "app_multiple, app_autorestart, app_taskmanage, app_enabled, app_hwacceleration, app_mainapp , app_recentimage, app_indicatordisplay, app_portraitimg, app_landscapeimg, app_guestmodevisibility, package) " \ + "values('%s', '%s', '%s', '%s', '%s', '%s','%s', '%s', '%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, up->hwacceleration,up->mainapp, up->recentimage, mfx->package); + "\0", up->taskmanage, up->enabled, up->hwacceleration,up->mainapp, up->recentimage, up->indicatordisplay, up->portraitimg, up->landscapeimg, up->guestmode_visibility, mfx->package); ret = __exec_query(query); if (ret == -1) { DBG("Package UiApp Info DB Insert Failed\n"); @@ -810,6 +1030,64 @@ static int __insert_uiapplication_appcategory_info(manifest_x *mfx) return 0; } +static int __insert_uiapplication_appmetadata_info(manifest_x *mfx) +{ + uiapplication_x *up = mfx->uiapplication; + metadata_x *md = NULL; + int ret = -1; + char query[MAX_QUERY_LEN] = {'\0'}; + while(up != NULL) + { + md = up->metadata; + while (md != NULL) + { + if (md->name && md->value) { + snprintf(query, MAX_QUERY_LEN, + "insert into package_app_app_metadata(app_id, md_name, md_value) " \ + "values('%s','%s', '%s')",\ + up->appid, md->name, md->value); + ret = __exec_query(query); + if (ret == -1) { + DBG("Package UiApp Metadata Info DB Insert Failed\n"); + return -1; + } + } + md = md->next; + memset(query, '\0', MAX_QUERY_LEN); + } + up = up->next; + } + return 0; +} + +static int __insert_uiapplication_apppermission_info(manifest_x *mfx) +{ + uiapplication_x *up = mfx->uiapplication; + permission_x *pm = NULL; + int ret = -1; + char query[MAX_QUERY_LEN] = {'\0'}; + while(up != NULL) + { + pm = up->permission; + while (pm != NULL) + { + snprintf(query, MAX_QUERY_LEN, + "insert into package_app_app_permission(app_id, pm_type, pm_value) " \ + "values('%s','%s', '%s')",\ + up->appid, pm->type, pm->value); + ret = __exec_query(query); + if (ret == -1) { + DBG("Package UiApp permission Info DB Insert Failed\n"); + return -1; + } + pm = pm->next; + memset(query, '\0', MAX_QUERY_LEN); + } + up = up->next; + } + return 0; +} + static int __insert_uiapplication_appcontrol_info(manifest_x *mfx) { uiapplication_x *up = mfx->uiapplication; @@ -1040,11 +1318,11 @@ static int __insert_serviceapplication_info(manifest_x *mfx) 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) " \ + "insert into package_app_info(app_id, app_component, app_exec, app_type, app_onboot, " \ + "app_multiple, app_autorestart, app_enabled, 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); + sp->appid, "svcapp", sp->exec, sp->type, sp->onboot, "\0", + sp->autorestart, sp->enabled, mfx->package); ret = __exec_query(query); if (ret == -1) { DBG("Package ServiceApp Info DB Insert Failed\n"); @@ -1084,6 +1362,64 @@ static int __insert_serviceapplication_appcategory_info(manifest_x *mfx) return 0; } +static int __insert_serviceapplication_appmetadata_info(manifest_x *mfx) +{ + serviceapplication_x *sp = mfx->serviceapplication; + metadata_x *md = NULL; + int ret = -1; + char query[MAX_QUERY_LEN] = {'\0'}; + while(sp != NULL) + { + md = sp->metadata; + while (md != NULL) + { + if (md->name && md->value) { + snprintf(query, MAX_QUERY_LEN, + "insert into package_app_app_metadata(app_id, md_name, md_value) " \ + "values('%s','%s', '%s')",\ + sp->appid, md->name, md->value); + ret = __exec_query(query); + if (ret == -1) { + DBG("Package ServiceApp Metadata Info DB Insert Failed\n"); + return -1; + } + } + md = md->next; + memset(query, '\0', MAX_QUERY_LEN); + } + sp = sp->next; + } + return 0; +} + +static int __insert_serviceapplication_apppermission_info(manifest_x *mfx) +{ + serviceapplication_x *sp = mfx->serviceapplication; + permission_x *pm = NULL; + int ret = -1; + char query[MAX_QUERY_LEN] = {'\0'}; + while(sp != NULL) + { + pm = sp->permission; + while (pm != NULL) + { + snprintf(query, MAX_QUERY_LEN, + "insert into package_app_app_permission(app_id, pm_type, pm_value) " \ + "values('%s','%s', '%s')",\ + sp->appid, pm->type, pm->value); + ret = __exec_query(query); + if (ret == -1) { + DBG("Package ServiceApp permission Info DB Insert Failed\n"); + return -1; + } + pm = pm->next; + memset(query, '\0', MAX_QUERY_LEN); + } + sp = sp->next; + } + return 0; +} + static int __insert_serviceapplication_appcontrol_info(manifest_x *mfx) { serviceapplication_x *sp = mfx->serviceapplication; @@ -1315,10 +1651,12 @@ static int __insert_manifest_info_in_db(manifest_x *mfx) author_x *ath = mfx->author; uiapplication_x *up = mfx->uiapplication; uiapplication_x *up_icn = mfx->uiapplication; + uiapplication_x *up_image = mfx->uiapplication; serviceapplication_x *sp = mfx->serviceapplication; char query[MAX_QUERY_LEN] = { '\0' }; int ret = -1; char *type = NULL; + char *path = NULL; char *auth_name = NULL; char *auth_email = NULL; char *auth_href = NULL; @@ -1336,12 +1674,21 @@ static int __insert_manifest_info_in_db(manifest_x *mfx) type = strdup(mfx->type); else type = strdup("rpm"); + /*Insert in the package_info DB*/ + if (mfx->root_path) + path = strdup(mfx->root_path); + else{ + if (strcmp(type,"rpm")==0) + path = strdup("/usr/apps"); + else + path = strdup("/opt/usr/apps"); + } snprintf(query, MAX_QUERY_LEN, "insert into package_info(package, package_type, package_version, install_location, package_size, " \ - "package_removable, package_preload, package_readonly, author_name, author_email, author_href, installed_time, storeclient_id, mainapp_id, package_url) " \ - "values('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",\ + "package_removable, package_preload, package_readonly, author_name, author_email, author_href, installed_time, storeclient_id, mainapp_id, package_url, root_path) " \ + "values('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",\ mfx->package, type, mfx->version, mfx->installlocation, mfx->package_size, mfx->removable, mfx->preload, - mfx->readonly, auth_name, auth_email, auth_href, mfx->installed_time, mfx->storeclient_id, mfx->mainapp_id, mfx->package_url); + mfx->readonly, auth_name, auth_email, auth_href, mfx->installed_time, mfx->storeclient_id, mfx->mainapp_id, mfx->package_url, path); ret = __exec_query(query); if (ret == -1) { DBG("Package Info DB Insert Failed\n"); @@ -1349,12 +1696,20 @@ static int __insert_manifest_info_in_db(manifest_x *mfx) free(type); type = NULL; } + if (path) { + free(path); + path = NULL; + } return -1; } if (type) { free(type); type = NULL; } + if (path) { + free(path); + path = 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); @@ -1382,6 +1737,15 @@ static int __insert_manifest_info_in_db(manifest_x *mfx) g_list_foreach(appicon, __trimfunc3, NULL); prev = NULL; + /*Insert the image info */ + while(up_image != NULL) + { + appimage = __create_image_list(appimage, up_image->image); + up_image = up_image->next; + } + g_list_foreach(appimage, __trimfunc4, NULL); + prev = NULL; + /*g_list_foreach(pkglocale, __printfunc, NULL);*/ /*DBG("\n");*/ /*g_list_foreach(applocale, __printfunc, NULL);*/ @@ -1407,16 +1771,26 @@ static int __insert_manifest_info_in_db(manifest_x *mfx) up_icn = mfx->uiapplication; while(up_icn != NULL) { - g_list_foreach(appicon, __insert_uiapplication_icon_locale_info, (gpointer)up_icn); + g_list_foreach(appicon, __insert_uiapplication_icon_section_info, (gpointer)up_icn); up_icn = up_icn->next; } + /*app image info*/ + up_image = mfx->uiapplication; + while(up_image != NULL) + { + g_list_foreach(appimage, __insert_uiapplication_image_info, (gpointer)up_image); + up_image = up_image->next; + } + g_list_free(pkglocale); pkglocale = NULL; g_list_free(applocale); applocale = NULL; g_list_free(appicon); appicon = NULL; + g_list_free(appimage); + appimage = NULL; /*Insert in the package_app_info DB*/ @@ -1446,6 +1820,22 @@ static int __insert_manifest_info_in_db(manifest_x *mfx) if (ret == -1) return -1; + /*Insert in the package_app_app_metadata DB*/ + ret = __insert_uiapplication_appmetadata_info(mfx); + if (ret == -1) + return -1; + ret = __insert_serviceapplication_appmetadata_info(mfx); + if (ret == -1) + return -1; + + /*Insert in the package_app_app_permission DB*/ + ret = __insert_uiapplication_apppermission_info(mfx); + if (ret == -1) + return -1; + ret = __insert_serviceapplication_apppermission_info(mfx); + if (ret == -1) + return -1; + /*Insert in the package_app_app_svc DB*/ ret = __insert_uiapplication_appsvc_info(mfx); if (ret == -1) @@ -1613,6 +2003,36 @@ static int __delete_manifest_info_from_db(manifest_x *mfx) sp = sp->next; } + /*Delete from App icon localized Info*/ + up = mfx->uiapplication; + while(up != NULL) + { + snprintf(query, MAX_QUERY_LEN, + "delete from package_app_icon_section_info where app_id='%s'", up->appid); + ret = __exec_query(query); + if (ret == -1) { + DBG("Package App image Info DB Delete Failed\n"); + return -1; + } + memset(query, '\0', MAX_QUERY_LEN); + up = up->next; + } + + /*Delete from App image Info*/ + up = mfx->uiapplication; + while(up != NULL) + { + snprintf(query, MAX_QUERY_LEN, + "delete from package_app_image_info where app_id='%s'", up->appid); + ret = __exec_query(query); + if (ret == -1) { + DBG("Package App image Info DB Delete Failed\n"); + return -1; + } + memset(query, '\0', MAX_QUERY_LEN); + up = up->next; + } + /*Delete from Package App App-Svc*/ up = mfx->uiapplication; sp = mfx->serviceapplication; @@ -1697,6 +2117,62 @@ static int __delete_manifest_info_from_db(manifest_x *mfx) sp = sp->next; } + /*Delete from Package App App-Metadata*/ + up = mfx->uiapplication; + sp = mfx->serviceapplication; + while(up != NULL) + { + snprintf(query, MAX_QUERY_LEN, + "delete from package_app_app_metadata where app_id='%s'", up->appid); + ret = __exec_query(query); + if (ret == -1) { + DBG("Package App App-Metadata 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_metadata where app_id='%s'", sp->appid); + ret = __exec_query(query); + if (ret == -1) { + DBG("Package App App-Metadata DB Delete Failed\n"); + return -1; + } + memset(query, '\0', MAX_QUERY_LEN); + sp = sp->next; + } + + /*Delete from Package App App-permission*/ + up = mfx->uiapplication; + sp = mfx->serviceapplication; + while(up != NULL) + { + snprintf(query, MAX_QUERY_LEN, + "delete from package_app_app_permission where app_id='%s'", up->appid); + ret = __exec_query(query); + if (ret == -1) { + DBG("Package App App-permission 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_permission where app_id='%s'", sp->appid); + ret = __exec_query(query); + if (ret == -1) { + DBG("Package App App-permission 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; @@ -1784,11 +2260,16 @@ int pkgmgr_parser_initialize_db() DBG("package app localized info DB initialization failed\n"); return ret; } - ret = __initialize_package_app_icon_localized_info_db(); + ret = __initialize_package_app_icon_section_info_db(); if (ret == -1) { DBG("package app icon localized info DB initialization failed\n"); return ret; } + ret = __initialize_package_app_image_info_db(); + if (ret == -1) { + DBG("package app image info DB initialization failed\n"); + return ret; + } ret = __initialize_package_app_app_control_db(); if (ret == -1) { DBG("package app app control DB initialization failed\n"); @@ -1799,6 +2280,16 @@ int pkgmgr_parser_initialize_db() DBG("package app app category DB initialization failed\n"); return ret; } + ret = __initialize_package_app_app_metadata_db(); + if (ret == -1) { + DBG("package app app category DB initialization failed\n"); + return ret; + } + ret = __initialize_package_app_app_permission_db(); + if (ret == -1) { + DBG("package app app permission 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"); @@ -1829,6 +2320,9 @@ int pkgmgr_parser_check_and_create_db() PKGMGR_PARSER_DB_FILE); return -1; } + ret = chmod(PKGMGR_PARSER_DB_FILE, 0664); + if (ret) + DBG("Failed to change mode of manifest DB\n"); return 0; } DBG("Pkgmgr DB does not exists. Create one!!\n"); @@ -1841,6 +2335,9 @@ int pkgmgr_parser_check_and_create_db() DBG("connect db [%s] failed!\n", PKGMGR_PARSER_DB_FILE); return -1; } + ret = chmod(PKGMGR_PARSER_DB_FILE, 0664); + if (ret) + DBG("Failed to change mode of manifest DB\n"); return 0; } @@ -1902,7 +2399,8 @@ API int pkgmgr_parser_update_manifest_info_in_db(manifest_x *mfx) ret = pkgmgr_parser_initialize_db(); if (ret == -1) return ret; - + /*Preserve guest mode visibility*/ + __preserve_guestmode_visibility_value( mfx); /*Begin transaction*/ ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL); if (ret != SQLITE_OK) { diff --git a/pkgmgr-info.manifest b/pkgmgr-info.manifest index 24f0a03..6748697 100644 --- a/pkgmgr-info.manifest +++ b/pkgmgr-info.manifest @@ -6,7 +6,6 @@ - - + diff --git a/src/pkgmgr-info.c b/src/pkgmgr-info.c index ff0f7db..e12372a 100755 --- a/src/pkgmgr-info.c +++ b/src/pkgmgr-info.c @@ -86,13 +86,6 @@ "LEFT OUTER JOIN package_app_app_category " \ "ON package_app_info.app_id=package_app_app_category.app_id where " -#define retv_if(expr, val) do { \ - if(expr) { \ - _LOGE("(%s) -> %s() return\n", #expr, __FUNCTION__); \ - return (val); \ - } \ -} while (0) - #define LANGUAGE_LENGTH 2 typedef struct _pkgmgr_instcertinfo_x { @@ -134,6 +127,10 @@ typedef struct _pkgmgr_iconpath_x { char *iconpath; } pkgmgr_iconpath_x; +typedef struct _pkgmgr_image_x { + char *imagepath; +} pkgmgr_image_x; + typedef struct _pkgmgr_locale_x { char *locale; } pkgmgr_locale_x; @@ -182,16 +179,15 @@ typedef struct _pkgmgrinfo_appcontrol_x { typedef int (*sqlite_query_callback)(void *data, int ncols, char **coltxt, char **colname); char *pkgtype = "rpm"; -sqlite3 *manifest_db = NULL; -sqlite3 *datacontrol_db = NULL; -int gflag[9];/*one for each cert type*/ -char *gpkgcert[9];/*To store pkg cert values*/ +__thread sqlite3 *manifest_db = NULL; +__thread sqlite3 *datacontrol_db = NULL; +__thread int gflag[9];/*one for each cert type*/ +__thread char *gpkgcert[9];/*To store pkg cert values*/ 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 __exec_certinfo_query(char *query, void *data); -static int __exec_sqlite_query(char *query, sqlite_query_callback callback, 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 __certinfo_cb(void *data, int ncols, char **coltxt, char **colname); @@ -233,8 +229,7 @@ static int __count_cb(void *data, int ncols, char **coltxt, char **colname) static void __destroy_each_node(gpointer data, gpointer user_data) { - if (data == NULL) - return; + ret_if(data == NULL); pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)data; if (node->value) { free(node->value); @@ -347,10 +342,8 @@ static char* __convert_system_locale_to_manifest_locale(char *syslocale) return strdup(DEFAULT_LOCALE); char *locale = NULL; locale = (char *)calloc(1, 6); - if (!locale) { - _LOGE("Malloc Failed\n"); - return NULL; - } + retvm_if(!locale, NULL, "Malloc Failed\n"); + strncpy(locale, syslocale, 2); strncat(locale, "-", 1); locale[3] = syslocale[3] + 32; @@ -360,8 +353,7 @@ static char* __convert_system_locale_to_manifest_locale(char *syslocale) static void __cleanup_pkginfo(pkgmgr_pkginfo_x *data) { - if (data == NULL) - return; + ret_if(data == NULL); if (data->tmp_dup){ free((void *)data->tmp_dup); data->tmp_dup = NULL; @@ -375,8 +367,11 @@ static void __cleanup_pkginfo(pkgmgr_pkginfo_x *data) static void __cleanup_appinfo(pkgmgr_appinfo_x *data) { - if (data == NULL) - return; + ret_if(data == NULL); + if (data->package){ + free((void *)data->package); + data->package = NULL; + } manifest_x *mfx = calloc(1, sizeof(manifest_x)); if (data->app_component == PMINFO_UI_APP) @@ -396,10 +391,7 @@ static int __open_manifest_db() 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; - } + retvm_if(ret != SQLITE_OK, -1, "connect db [%s] failed!\n", MANIFEST_DB); return 0; } _LOGE("Manifest DB does not exists !!\n"); @@ -413,10 +405,7 @@ static int __open_datacontrol_db() ret = db_util_open_with_options(DATACONTROL_DB, &datacontrol_db, SQLITE_OPEN_READONLY, NULL); - if (ret != SQLITE_OK) { - _LOGE("connect db [%s] failed!\n", DATACONTROL_DB); - return -1; - } + retvm_if(ret != SQLITE_OK, -1, "connect db [%s] failed!\n", DATACONTROL_DB); return 0; } _LOGE("Datacontrol DB does not exists !!\n"); @@ -555,6 +544,26 @@ static int __uiapp_list_cb(void *data, int ncols, char **coltxt, char **colname) info->manifest_info->uiapplication->hwacceleration = strdup(coltxt[i]); else info->manifest_info->uiapplication->hwacceleration = NULL; + } else if (strcmp(colname[i], "app_indicatordisplay") == 0 ){ + if (coltxt[i]) + info->manifest_info->uiapplication->indicatordisplay = strdup(coltxt[i]); + else + info->manifest_info->uiapplication->indicatordisplay = NULL; + } else if (strcmp(colname[i], "app_portraitimg") == 0 ){ + if (coltxt[i]) + info->manifest_info->uiapplication->portraitimg = strdup(coltxt[i]); + else + info->manifest_info->uiapplication->portraitimg = NULL; + } else if (strcmp(colname[i], "app_landscapeimg") == 0 ){ + if (coltxt[i]) + info->manifest_info->uiapplication->landscapeimg = strdup(coltxt[i]); + else + info->manifest_info->uiapplication->landscapeimg = NULL; + } else if (strcmp(colname[i], "app_guestmodevisibility") == 0 ){ + if (coltxt[i]) + info->manifest_info->uiapplication->guestmode_visibility = strdup(coltxt[i]); + else + info->manifest_info->uiapplication->guestmode_visibility = NULL; } else if (strcmp(colname[i], "package") == 0 ){ if (coltxt[i]) info->manifest_info->uiapplication->package = strdup(coltxt[i]); @@ -570,6 +579,16 @@ static int __uiapp_list_cb(void *data, int ncols, char **coltxt, char **colname) info->manifest_info->uiapplication->label->text = strdup(coltxt[i]); else info->manifest_info->uiapplication->label->text = NULL; + } else if (strcmp(colname[i], "app_recentimage") == 0 ) { + if (coltxt[i]) + info->manifest_info->uiapplication->recentimage = strdup(coltxt[i]); + else + info->manifest_info->uiapplication->recentimage = NULL; + } else if (strcmp(colname[i], "app_mainapp") == 0 ) { + if (coltxt[i]) + info->manifest_info->uiapplication->mainapp = strdup(coltxt[i]); + else + info->manifest_info->uiapplication->mainapp = NULL; } else if (strcmp(colname[i], "app_locale") == 0 ) { if (coltxt[i]) { info->manifest_info->uiapplication->icon->lang = strdup(coltxt[i]); @@ -710,6 +729,26 @@ static int __allapp_list_cb(void *data, int ncols, char **coltxt, char **colname info->manifest_info->uiapplication->hwacceleration = strdup(coltxt[i]); else info->manifest_info->uiapplication->hwacceleration = NULL; + } else if (strcmp(colname[i], "app_indicatordisplay") == 0 ){ + if (coltxt[i]) + info->manifest_info->uiapplication->indicatordisplay = strdup(coltxt[i]); + else + info->manifest_info->uiapplication->indicatordisplay = NULL; + } else if (strcmp(colname[i], "app_portraitimg") == 0 ){ + if (coltxt[i]) + info->manifest_info->uiapplication->portraitimg = strdup(coltxt[i]); + else + info->manifest_info->uiapplication->portraitimg = NULL; + } else if (strcmp(colname[i], "app_landscapeimg") == 0 ){ + if (coltxt[i]) + info->manifest_info->uiapplication->landscapeimg = strdup(coltxt[i]); + else + info->manifest_info->uiapplication->landscapeimg = NULL; + } else if (strcmp(colname[i], "app_guestmodevisibility") == 0 ){ + if (coltxt[i]) + info->manifest_info->uiapplication->guestmode_visibility = strdup(coltxt[i]); + else + info->manifest_info->uiapplication->guestmode_visibility = NULL; } else if (strcmp(colname[i], "package") == 0 ){ if (coltxt[i]) info->manifest_info->uiapplication->package = strdup(coltxt[i]); @@ -725,6 +764,16 @@ static int __allapp_list_cb(void *data, int ncols, char **coltxt, char **colname info->manifest_info->uiapplication->label->text = strdup(coltxt[i]); else info->manifest_info->uiapplication->label->text = NULL; + } else if (strcmp(colname[i], "app_recentimage") == 0 ) { + if (coltxt[i]) + info->manifest_info->uiapplication->recentimage = strdup(coltxt[i]); + else + info->manifest_info->uiapplication->recentimage = NULL; + } else if (strcmp(colname[i], "app_mainapp") == 0 ) { + if (coltxt[i]) + info->manifest_info->uiapplication->mainapp= strdup(coltxt[i]); + else + info->manifest_info->uiapplication->mainapp = NULL; } else if (strcmp(colname[i], "app_locale") == 0 ) { if (coltxt[i]) { info->manifest_info->uiapplication->icon->lang = strdup(coltxt[i]); @@ -910,6 +959,11 @@ static int __pkginfo_cb(void *data, int ncols, char **coltxt, char **colname) info->manifest_info->mainapp_id = strdup(coltxt[i]); else info->manifest_info->mainapp_id = NULL; + } else if (strcmp(colname[i], "root_path") == 0 ){ + if (coltxt[i]) + info->manifest_info->root_path = strdup(coltxt[i]); + else + info->manifest_info->root_path = NULL; } else if (strcmp(colname[i], "package_locale") == 0 ){ if (coltxt[i]) { @@ -1290,6 +1344,9 @@ static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname) icon_x *icon = NULL; label_x *label = NULL; category_x *category = NULL; + metadata_x *metadata = NULL; + permission_x *permission = NULL; + image_x *image = NULL; switch (info->app_component) { case PMINFO_UI_APP: @@ -1299,6 +1356,13 @@ static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname) LISTADD(info->uiapp_info->label, label); category = calloc(1, sizeof(category_x)); LISTADD(info->uiapp_info->category, category); + metadata = calloc(1, sizeof(metadata_x)); + LISTADD(info->uiapp_info->metadata, metadata); + permission = calloc(1, sizeof(permission_x)); + LISTADD(info->uiapp_info->permission, permission); + image = calloc(1, sizeof(image_x)); + LISTADD(info->uiapp_info->image, image); + for(i = 0; i < ncols; i++) { if (strcmp(colname[i], "app_id") == 0) { @@ -1321,6 +1385,13 @@ static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname) info->uiapp_info->type = strdup(coltxt[i]); else info->uiapp_info->type = NULL; + } else if (strcmp(colname[i], "app_icon_section") == 0 ) { + if (coltxt[i]){ + info->uiapp_info->icon->section= strdup(coltxt[i]); + _LOGE("isectt == %s \n",info->uiapp_info->icon->section); + } + else + info->uiapp_info->icon->section = NULL; } else if (strcmp(colname[i], "app_icon") == 0) { if (coltxt[i]) info->uiapp_info->icon->text = strdup(coltxt[i]); @@ -1346,11 +1417,66 @@ static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname) info->uiapp_info->hwacceleration = strdup(coltxt[i]); else info->uiapp_info->hwacceleration = NULL; + } else if (strcmp(colname[i], "app_enabled") == 0 ) { + if (coltxt[i]) + info->uiapp_info->enabled= strdup(coltxt[i]); + else + info->uiapp_info->enabled = NULL; + } else if (strcmp(colname[i], "app_indicatordisplay") == 0){ + if (coltxt[i]) + info->uiapp_info->indicatordisplay = strdup(coltxt[i]); + else + info->uiapp_info->indicatordisplay = NULL; + } else if (strcmp(colname[i], "app_portraitimg") == 0){ + if (coltxt[i]) + info->uiapp_info->portraitimg = strdup(coltxt[i]); + else + info->uiapp_info->portraitimg = NULL; + } else if (strcmp(colname[i], "app_landscapeimg") == 0){ + if (coltxt[i]) + info->uiapp_info->landscapeimg = strdup(coltxt[i]); + else + info->uiapp_info->landscapeimg = NULL; + } else if (strcmp(colname[i], "app_guestmodevisibility") == 0){ + if (coltxt[i]) + info->uiapp_info->guestmode_visibility = strdup(coltxt[i]); + else + info->uiapp_info->guestmode_visibility = NULL; } else if (strcmp(colname[i], "category") == 0 ) { if (coltxt[i]) info->uiapp_info->category->name = strdup(coltxt[i]); else info->uiapp_info->category->name = NULL; + } else if (strcmp(colname[i], "md_name") == 0 ) { + if (coltxt[i]) + info->uiapp_info->metadata->name = strdup(coltxt[i]); + else + info->uiapp_info->metadata->name = NULL; + } else if (strcmp(colname[i], "md_value") == 0 ) { + if (coltxt[i]) + info->uiapp_info->metadata->value = strdup(coltxt[i]); + else + info->uiapp_info->metadata->value = NULL; + } else if (strcmp(colname[i], "pm_type") == 0 ) { + if (coltxt[i]) + info->uiapp_info->permission->type= strdup(coltxt[i]); + else + info->uiapp_info->permission->type = NULL; + } else if (strcmp(colname[i], "pm_value") == 0 ) { + if (coltxt[i]) + info->uiapp_info->permission->value = strdup(coltxt[i]); + else + info->uiapp_info->permission->value = NULL; + } else if (strcmp(colname[i], "app_recentimage") == 0 ) { + if (coltxt[i]) + info->uiapp_info->recentimage = strdup(coltxt[i]); + else + info->uiapp_info->recentimage = NULL; + } else if (strcmp(colname[i], "app_mainapp") == 0 ) { + if (coltxt[i]) + info->uiapp_info->mainapp = strdup(coltxt[i]); + else + info->uiapp_info->mainapp = NULL; } else if (strcmp(colname[i], "app_locale") == 0 ) { if (coltxt[i]) { info->uiapp_info->icon->lang = strdup(coltxt[i]); @@ -1360,6 +1486,16 @@ static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname) info->uiapp_info->icon->lang = NULL; info->uiapp_info->label->lang = NULL; } + } else if (strcmp(colname[i], "app_image") == 0) { + if (coltxt[i]) + info->uiapp_info->image->text= strdup(coltxt[i]); + else + info->uiapp_info->image->text = NULL; + } else if (strcmp(colname[i], "app_image_section") == 0) { + if (coltxt[i]) + info->uiapp_info->image->section= strdup(coltxt[i]); + else + info->uiapp_info->image->section = NULL; } else continue; } @@ -1371,6 +1507,8 @@ static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname) LISTADD(info->svcapp_info->label, label); category = calloc(1, sizeof(category_x)); LISTADD(info->svcapp_info->category, category); + metadata = calloc(1, sizeof(metadata_x)); + LISTADD(info->svcapp_info->metadata, metadata); for(i = 0; i < ncols; i++) { if (strcmp(colname[i], "app_id") == 0) { @@ -1408,11 +1546,36 @@ static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname) info->svcapp_info->autorestart = strdup(coltxt[i]); else info->svcapp_info->autorestart = NULL; + } else if (strcmp(colname[i], "app_enabled") == 0 ) { + if (coltxt[i]) + info->svcapp_info->enabled= strdup(coltxt[i]); + else + info->svcapp_info->enabled = NULL; } else if (strcmp(colname[i], "category") == 0 ) { if (coltxt[i]) info->svcapp_info->category->name = strdup(coltxt[i]); else info->svcapp_info->category->name = NULL; + } else if (strcmp(colname[i], "md_name") == 0 ) { + if (coltxt[i]) + info->svcapp_info->metadata->name = strdup(coltxt[i]); + else + info->svcapp_info->metadata->name = NULL; + } else if (strcmp(colname[i], "md_value") == 0 ) { + if (coltxt[i]) + info->svcapp_info->metadata->value = strdup(coltxt[i]); + else + info->svcapp_info->metadata->value = NULL; + } else if (strcmp(colname[i], "pm_type") == 0 ) { + if (coltxt[i]) + info->svcapp_info->permission->type= strdup(coltxt[i]); + else + info->svcapp_info->permission->type = NULL; + } else if (strcmp(colname[i], "pm_value") == 0 ) { + if (coltxt[i]) + info->svcapp_info->permission->value = strdup(coltxt[i]); + else + info->svcapp_info->permission->value = NULL; } else if (strcmp(colname[i], "app_locale") == 0 ) { if (coltxt[i]) { info->svcapp_info->icon->lang = strdup(coltxt[i]); @@ -1489,6 +1652,23 @@ static int __icon_name_cb(void *data, int ncols, char **coltxt, char **colname) return 0; } +static int __image_path_cb(void *data, int ncols, char **coltxt, char **colname) +{ + pkgmgr_image_x *image_path = (pkgmgr_image_x *)data; + int i = 0; + for(i = 0; i < ncols; i++) + { + if (strcmp(colname[i], "app_image") == 0) { + if (coltxt[i]) + image_path->imagepath = strdup(coltxt[i]); + else + image_path->imagepath = NULL; + } else + continue; + } + return 0; +} + static int __cert_cb(void *data, int ncols, char **coltxt, char **colname) { pkgmgr_cert_x *info = (pkgmgr_cert_x *)data; @@ -1582,11 +1762,11 @@ static int __exec_appinfo_query(char *query, void *data) return 0; } -static int __exec_sqlite_query(char *query, sqlite_query_callback callback, void *data) +static int __exec_db_query(sqlite3 *db, char *query, sqlite_query_callback callback, void *data) { char *error_message = NULL; if (SQLITE_OK != - sqlite3_exec(manifest_db, query, callback, data, &error_message)) { + sqlite3_exec(db, query, callback, data, &error_message)) { _LOGE("Don't execute query = %s error message = %s\n", query, error_message); sqlite3_free(error_message); @@ -1727,18 +1907,18 @@ static int __check_validation_of_qurey_cb(void *data, int ncols, char **coltxt, return 0; } -static int __check_app_locale_from_app_localized_info_by_exact(const char *appid, const char *locale) +static int __check_app_locale_from_app_localized_info_by_exact(sqlite3 *db, const char *appid, const char *locale) { int result_query = -1; char query[MAX_QUERY_LEN]; snprintf(query, MAX_QUERY_LEN, "select exists(select app_locale from package_app_localized_info where app_id='%s' and app_locale='%s')", appid, locale); - __exec_sqlite_query(query, __check_validation_of_qurey_cb, (void *)&result_query); + __exec_db_query(db, query, __check_validation_of_qurey_cb, (void *)&result_query); return result_query; } -static int __check_app_locale_from_app_localized_info_by_fallback(const char *appid, const char *locale) +static int __check_app_locale_from_app_localized_info_by_fallback(sqlite3 *db, const char *appid, const char *locale) { int result_query = -1; char wildcard[2] = {'%','\0'}; @@ -1747,12 +1927,12 @@ static int __check_app_locale_from_app_localized_info_by_fallback(const char *ap strncpy(lang, locale, LANGUAGE_LENGTH); snprintf(query, MAX_QUERY_LEN, "select exists(select app_locale from package_app_localized_info where app_id='%s' and app_locale like '%s%s')", appid, lang, wildcard); - __exec_sqlite_query(query, __check_validation_of_qurey_cb, (void *)&result_query); + __exec_db_query(db, query, __check_validation_of_qurey_cb, (void *)&result_query); return result_query; } -static char* __get_app_locale_from_app_localized_info_by_fallback(const char *appid, const char *locale) +static char* __get_app_locale_from_app_localized_info_by_fallback(sqlite3 *db, const char *appid, const char *locale) { char wildcard[2] = {'%','\0'}; char lang[3] = {'\0'}; @@ -1769,7 +1949,7 @@ static char* __get_app_locale_from_app_localized_info_by_fallback(const char *ap strncpy(lang, locale, 2); snprintf(query, MAX_QUERY_LEN, "select app_locale from package_app_localized_info where app_id='%s' and app_locale like '%s%s'", appid, lang, wildcard); - __exec_sqlite_query(query, __fallback_locale_cb, (void *)info); + __exec_db_query(db, query, __fallback_locale_cb, (void *)info); locale_new = info->locale; free(info); @@ -1788,7 +1968,7 @@ static char* __convert_syslocale_to_manifest_locale(char *syslocale) return locale; } -static char* __get_app_locale_by_fallback(const char *appid, const char *syslocale) +static char* __get_app_locale_by_fallback(sqlite3 *db, const char *appid, const char *syslocale) { assert(appid); assert(syslocale); @@ -1800,7 +1980,7 @@ static char* __get_app_locale_by_fallback(const char *appid, const char *sysloca locale = __convert_syslocale_to_manifest_locale(syslocale); /*check exact matching */ - check_result = __check_app_locale_from_app_localized_info_by_exact(appid, locale); + check_result = __check_app_locale_from_app_localized_info_by_exact(db, appid, locale); /* Exact found */ if (check_result == 1) { @@ -1809,9 +1989,9 @@ static char* __get_app_locale_by_fallback(const char *appid, const char *sysloca } /* fallback matching */ - check_result = __check_app_locale_from_app_localized_info_by_fallback(appid, locale); + check_result = __check_app_locale_from_app_localized_info_by_fallback(db, appid, locale); if(check_result == 1) { - locale_new = __get_app_locale_from_app_localized_info_by_fallback(appid, locale); + locale_new = __get_app_locale_from_app_localized_info_by_fallback(db, appid, locale); _LOGD("%s found (%s) language-locale in DB by fallback!\n", appid, locale_new); free(locale); if (locale_new == NULL) @@ -1835,10 +2015,8 @@ long long _pkgmgr_calculate_dir_size(char *dirname) struct dirent *ep = NULL; struct stat fileinfo; char abs_filename[FILENAME_MAX] = { 0, }; - if (dirname == NULL) { - _LOGE("dirname is NULL"); - return PMINFO_R_ERROR; - } + retvm_if(dirname == NULL, PMINFO_R_ERROR, "dirname is NULL"); + dp = opendir(dirname); if (dp != NULL) { while ((ep = readdir(dp)) != NULL) { @@ -2456,144 +2634,153 @@ API int pkgmgrinfo_pkginfo_get_data_size(pkgmgrinfo_pkginfo_h handle, int *size) API int pkgmgrinfo_pkginfo_get_icon(pkgmgrinfo_pkginfo_h handle, char **icon) { -#if 0 - if (handle == NULL) { - _LOGE("pkginfo handle is NULL\n"); - return PMINFO_R_EINVAL; - } - if (icon == NULL) { - _LOGE("Argument supplied to hold return value is NULL\n"); - return PMINFO_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 PMINFO_R_EINVAL; - } - locale = __convert_system_locale_to_manifest_locale(syslocale); - if (locale == NULL) { - _LOGE("manifest locale is NULL\n"); - return PMINFO_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->text; - if (strcasecmp(*icon, "(null)") == 0) { - locale = DEFAULT_LOCALE; - continue; - } else - break; - } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) { - *icon = (char *)ptr->text; - break; - } - } - } + retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL"); + retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL"); - if (syslocale) { - free(syslocale); - syslocale = NULL; - } - locale = save; - if (locale) { - free(locale); - locale = NULL; - } -#else pkgmgr_pkginfo_x *info_tmp = (pkgmgr_pkginfo_x *)handle; pkgmgrinfo_appinfo_h apphandle; + bool ismainapp = 0; + int ret = PMINFO_R_OK; + + ret = pkgmgrinfo_appinfo_get_appinfo(info_tmp->manifest_info->mainapp_id, &apphandle); + retvm_if(ret < 0, PMINFO_R_ERROR, "pkgmgrinfo_appinfo_get_appinfo fail"); + + ret = pkgmgrinfo_appinfo_is_mainapp(apphandle, &ismainapp); + tryvm_if(ret < 0, ret = PMINFO_R_ERROR, "pkgmgrinfo_appinfo_is_mainapp fail"); + + if (ismainapp){ + ret = pkgmgrinfo_appinfo_get_icon(apphandle, &info_tmp->tmp); + tryvm_if(ret < 0, ret = PMINFO_R_ERROR, "pkgmgrinfo_appinfo_get_icon fail"); + tryvm_if(info_tmp->tmp == NULL, ret = PMINFO_R_EINVAL, "icon is NULL"); - pkgmgrinfo_appinfo_get_appinfo(info_tmp->manifest_info->mainapp_id, &apphandle); - pkgmgrinfo_appinfo_get_icon(apphandle, &info_tmp->tmp); - if (info_tmp->tmp_dup){ - free((void *)info_tmp->tmp_dup); - info_tmp->tmp_dup = NULL; + if (info_tmp->tmp_dup){ + free((void *)info_tmp->tmp_dup); + info_tmp->tmp_dup = NULL; + } + + info_tmp->tmp_dup= strdup(info_tmp->tmp); + *icon = info_tmp->tmp_dup; + } else { + char *syslocale = NULL; + char *locale = NULL; + char *save = NULL; + icon_x *ptr = NULL; + syslocale = vconf_get_str(VCONFKEY_LANGSET); + tryvm_if(syslocale == NULL, ret = PMINFO_R_EINVAL, "current locale is NULL"); + + locale = __convert_system_locale_to_manifest_locale(syslocale); + tryvm_if(locale == NULL, ret = PMINFO_R_EINVAL, "manifest locale is NULL"); + + 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->text; + if (strcasecmp(*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; + } } - info_tmp->tmp_dup= strdup(info_tmp->tmp); - *icon = info_tmp->tmp_dup; + +catch: pkgmgrinfo_appinfo_destroy_appinfo(apphandle); -#endif - return PMINFO_R_OK; + return ret; } API int pkgmgrinfo_pkginfo_get_label(pkgmgrinfo_pkginfo_h handle, char **label) { -#if 0 - if (handle == NULL) { - _LOGE("pkginfo handle is NULL\n"); - return PMINFO_R_EINVAL; - } - if (label == NULL) { - _LOGE("Argument supplied to hold return value is NULL\n"); - return PMINFO_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 PMINFO_R_EINVAL; - } - locale = __convert_system_locale_to_manifest_locale(syslocale); - if (locale == NULL) { - _LOGE("manifest locale is NULL\n"); - return PMINFO_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 (strcasecmp(*label, "(null)") == 0) { - locale = DEFAULT_LOCALE; - continue; - } else - break; - } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) { - *label = (char *)ptr->text; - break; - } - } - } + retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL"); + retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL"); - if (syslocale) { - free(syslocale); - syslocale = NULL; - } - locale = save; - if (locale) { - free(locale); - locale = NULL; - } -#else pkgmgr_pkginfo_x *info_tmp = (pkgmgr_pkginfo_x *)handle; pkgmgrinfo_appinfo_h apphandle; + bool ismainapp = 0; + int ret = PMINFO_R_OK; + + ret = pkgmgrinfo_appinfo_get_appinfo(info_tmp->manifest_info->mainapp_id, &apphandle); + retvm_if(ret < 0, PMINFO_R_ERROR, "pkgmgrinfo_appinfo_get_appinfo fail"); + + ret = pkgmgrinfo_appinfo_is_mainapp(apphandle, &ismainapp); + tryvm_if(ret < 0, ret = PMINFO_R_ERROR, "pkgmgrinfo_appinfo_is_mainapp fail"); + + if (ismainapp){ + ret = pkgmgrinfo_appinfo_get_label(apphandle, &info_tmp->tmp); + tryvm_if(ret < 0, ret = PMINFO_R_ERROR, "pkgmgrinfo_appinfo_get_label fail"); + tryvm_if(info_tmp->tmp == NULL, ret = PMINFO_R_EINVAL, "label is NULL"); + + if (info_tmp->tmp_dup){ + free((void *)info_tmp->tmp_dup); + info_tmp->tmp_dup = NULL; + } + + info_tmp->tmp_dup = strdup(info_tmp->tmp); + *label = info_tmp->tmp_dup; + } else { + char *syslocale = NULL; + char *locale = NULL; + char *save = NULL; + label_x *ptr = NULL; + + syslocale = vconf_get_str(VCONFKEY_LANGSET); + tryvm_if(syslocale == NULL, ret = PMINFO_R_EINVAL, "current locale is NULL"); - pkgmgrinfo_appinfo_get_appinfo(info_tmp->manifest_info->mainapp_id, &apphandle); - pkgmgrinfo_appinfo_get_label(apphandle, &info_tmp->tmp); - if (info_tmp->tmp_dup){ - free((void *)info_tmp->tmp_dup); - info_tmp->tmp_dup = NULL; + locale = __convert_system_locale_to_manifest_locale(syslocale); + tryvm_if(locale == NULL, ret = PMINFO_R_EINVAL, "manifest locale is NULL"); + + 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 (strcasecmp(*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; + } } - info_tmp->tmp_dup = strdup(info_tmp->tmp); - *label = info_tmp->tmp_dup; + +catch: pkgmgrinfo_appinfo_destroy_appinfo(apphandle); -#endif - return PMINFO_R_OK; + return ret; } API int pkgmgrinfo_pkginfo_get_description(pkgmgrinfo_pkginfo_h handle, char **description) @@ -2976,6 +3163,28 @@ API int pkgmgrinfo_pkginfo_get_location_from_xml(const char *manifest, pkgmgrinf return PMINFO_R_OK; } + +API int pkgmgrinfo_pkginfo_get_root_path(pkgmgrinfo_pkginfo_h handle, char **path) +{ + if (handle == NULL) { + _LOGE("pkginfo handle is NULL\n"); + return PMINFO_R_EINVAL; + } + if (path == NULL) { + _LOGE("Argument supplied to hold return value is NULL\n"); + return PMINFO_R_EINVAL; + } + + pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle; + if (info->manifest_info->root_path) + *path = info->manifest_info->root_path; + else + return PMINFO_R_ERROR; + + return PMINFO_R_OK; +} + + API int pkgmgrinfo_pkginfo_compare_pkg_cert_info(const char *lhs_package_id, const char *rhs_package_id, pkgmgrinfo_cert_compare_result_type_e *compare_result) { if (lhs_package_id == NULL || rhs_package_id == NULL) @@ -3863,18 +4072,10 @@ err: API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component, pkgmgrinfo_app_list_cb app_func, void *user_data) { - if (handle == NULL) { - _LOGE("pkginfo handle is NULL\n"); - return PMINFO_R_EINVAL; - } - if (app_func == NULL) { - _LOGE("callback pointer is NULL\n"); - return PMINFO_R_EINVAL; - } - if (component != PMINFO_UI_APP && component != PMINFO_SVC_APP && component != PMINFO_ALL_APP) { - _LOGE("Invalid App Component Type\n"); - return PMINFO_R_EINVAL; - } + retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL"); + retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback pointer is NULL"); + retvm_if((component != PMINFO_UI_APP) && (component != PMINFO_SVC_APP) && (component != PMINFO_ALL_APP), PMINFO_R_EINVAL, "Invalid App Component Type"); + char *error_message = NULL; char *syslocale = NULL; char *locale = NULL; @@ -3885,51 +4086,39 @@ API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_ pkgmgr_appinfo_x *appinfo = NULL; icon_x *ptr1 = NULL; label_x *ptr2 = NULL; + sqlite3 *appinfo_db = NULL; + /*get system locale*/ syslocale = vconf_get_str(VCONFKEY_LANGSET); - if (syslocale == NULL) { - _LOGE("current locale is NULL\n"); - ret = PMINFO_R_ERROR; - goto err; - } + tryvm_if(syslocale == NULL, ret = PMINFO_R_EINVAL, "current locale is NULL"); + + /*get locale on db*/ locale = __convert_system_locale_to_manifest_locale(syslocale); - if (locale == NULL) { - _LOGE("manifest locale is NULL\n"); - ret = PMINFO_R_EINVAL; - goto err; - } + tryvm_if(locale == NULL, ret = PMINFO_R_EINVAL, "manifest locale is NULL"); + /*calloc allinfo*/ allinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x)); - if (allinfo == NULL) { - _LOGE("Failed to allocate memory for appinfo\n"); - ret = PMINFO_R_ERROR; - goto err; - } + tryvm_if(allinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo"); + + /*calloc manifest_info*/ allinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x)); - if (allinfo->manifest_info == NULL) { - _LOGE("Out of Memory!!!\n"); - ret = PMINFO_R_ERROR; - goto err; - } + tryvm_if(allinfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!"); + /*calloc appinfo*/ appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x)); - if (appinfo == NULL) { - _LOGE("Failed to allocate memory for appinfo\n"); - ret = PMINFO_R_ERROR; - goto err; - } + tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo"); + + /*set component type*/ if (component == PMINFO_UI_APP) appinfo->app_component = PMINFO_UI_APP; if (component == PMINFO_SVC_APP) appinfo->app_component = PMINFO_SVC_APP; if (component == PMINFO_ALL_APP) appinfo->app_component = PMINFO_ALL_APP; - ret = __open_manifest_db(); - if (ret == -1) { - _LOGE("Fail to open manifest DB\n"); - ret = PMINFO_R_ERROR; - goto err; - } + + /*open db */ + ret = db_util_open_with_options(MANIFEST_DB, &appinfo_db, SQLITE_OPEN_READONLY, NULL); + retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB); appinfo->package = strdup(info->manifest_info->package); snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \ @@ -3940,15 +4129,10 @@ API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_ switch(component) { case PMINFO_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); - ret = PMINFO_R_ERROR; - goto err; - } + /*Populate ui app info */ + ret = __exec_db_query(appinfo_db, query, __uiapp_list_cb, (void *)info); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed"); + uiapplication_x *tmp = NULL; if (info->manifest_info->uiapplication) { LISTHEAD(info->manifest_info->uiapplication, tmp); @@ -3959,32 +4143,35 @@ API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_ while(tmp != NULL) { appinfo->uiapp_info = tmp; - if (strcmp(appinfo->uiapp_info->type,"c++app") == 0){ if (locale) { free(locale); } - locale = __get_app_locale_by_fallback(appinfo->uiapp_info->appid, syslocale); + locale = __get_app_locale_by_fallback(appinfo_db, appinfo->uiapp_info->appid, syslocale); } memset(query, '\0', MAX_QUERY_LEN); - snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where" \ - " app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, locale); - ret = __exec_appinfo_query(query, (void *)appinfo); - if (ret == -1) { - _LOGE("App Localized Info DB Information retrieval failed\n"); - ret = PMINFO_R_ERROR; - goto err; - } + snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, locale); + ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed"); + memset(query, '\0', MAX_QUERY_LEN); - snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where" \ - " app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, DEFAULT_LOCALE); - ret = __exec_appinfo_query(query, (void *)appinfo); - if (ret == -1) { - _LOGE("App Localized Info DB Information retrieval failed\n"); - ret = PMINFO_R_ERROR; - goto err; - } + snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, DEFAULT_LOCALE); + ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed"); + + /*store setting notification icon section*/ + memset(query, '\0', MAX_QUERY_LEN); + snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appinfo->uiapp_info->appid); + ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed"); + + /*store app preview image info*/ + memset(query, '\0', MAX_QUERY_LEN); + snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appinfo->uiapp_info->appid); + ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed"); + if (appinfo->uiapp_info->label) { LISTHEAD(appinfo->uiapp_info->label, ptr2); appinfo->uiapp_info->label = ptr2; @@ -4000,15 +4187,10 @@ API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_ } break; case PMINFO_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); - ret = PMINFO_R_ERROR; - goto err; - } + /*Populate svc app info */ + ret = __exec_db_query(appinfo_db, query, __svcapp_list_cb, (void *)info); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed"); + serviceapplication_x *tmp1 = NULL; if (info->manifest_info->serviceapplication) { LISTHEAD(info->manifest_info->serviceapplication, tmp1); @@ -4020,23 +4202,15 @@ API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_ { appinfo->svcapp_info = tmp1; memset(query, '\0', MAX_QUERY_LEN); - snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where" \ - " app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, locale); - ret = __exec_appinfo_query(query, (void *)appinfo); - if (ret == -1) { - _LOGE("App Localized Info DB Information retrieval failed\n"); - ret = PMINFO_R_ERROR; - goto err; - } + snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, locale); + ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed"); + memset(query, '\0', MAX_QUERY_LEN); - snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where" \ - " app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, DEFAULT_LOCALE); - ret = __exec_appinfo_query(query, (void *)appinfo); - if (ret == -1) { - _LOGE("App Localized Info DB Information retrieval failed\n"); - ret = PMINFO_R_ERROR; - goto err; - } + snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, DEFAULT_LOCALE); + ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed"); + if (appinfo->svcapp_info->label) { LISTHEAD(appinfo->svcapp_info->label, ptr2); appinfo->svcapp_info->label = ptr2; @@ -4054,15 +4228,10 @@ API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_ case PMINFO_ALL_APP: memset(query, '\0', MAX_QUERY_LEN); snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where package='%s'", info->manifest_info->package); - if (SQLITE_OK != - sqlite3_exec(manifest_db, query, __allapp_list_cb, (void *)allinfo, &error_message)) { - _LOGE("Don't execute query = %s error message = %s\n", query, - error_message); - sqlite3_free(error_message); - sqlite3_close(manifest_db); - ret = PMINFO_R_ERROR; - goto err; - } + + /*Populate all app info */ + ret = __exec_db_query(appinfo_db, query, __allapp_list_cb, (void *)allinfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed"); /*UI Apps*/ appinfo->app_component = PMINFO_UI_APP; @@ -4077,23 +4246,27 @@ API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_ { appinfo->uiapp_info = tmp2; memset(query, '\0', MAX_QUERY_LEN); - snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where" \ - " app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, locale); - ret = __exec_appinfo_query(query, (void *)appinfo); - if (ret == -1) { - _LOGE("App Localized Info DB Information retrieval failed\n"); - ret = PMINFO_R_ERROR; - goto err; - } + snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, locale); + ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed"); + memset(query, '\0', MAX_QUERY_LEN); - snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where" \ - " app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, DEFAULT_LOCALE); - ret = __exec_appinfo_query(query, (void *)appinfo); - if (ret == -1) { - _LOGE("App Localized Info DB Information retrieval failed\n"); - ret = PMINFO_R_ERROR; - goto err; - } + snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, DEFAULT_LOCALE); + ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed"); + + /*store setting notification icon section*/ + memset(query, '\0', MAX_QUERY_LEN); + snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appinfo->uiapp_info->appid); + ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed"); + + /*store app preview image info*/ + memset(query, '\0', MAX_QUERY_LEN); + snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appinfo->uiapp_info->appid); + ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed"); + if (appinfo->uiapp_info->label) { LISTHEAD(appinfo->uiapp_info->label, ptr2); appinfo->uiapp_info->label = ptr2; @@ -4121,23 +4294,15 @@ API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_ { appinfo->svcapp_info = tmp3; memset(query, '\0', MAX_QUERY_LEN); - snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where" \ - " app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, locale); - ret = __exec_appinfo_query(query, (void *)appinfo); - if (ret == -1) { - _LOGE("App Localized Info DB Information retrieval failed\n"); - ret = PMINFO_R_ERROR; - goto err; - } + snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, locale); + ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed"); + memset(query, '\0', MAX_QUERY_LEN); - snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where" \ - " app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, DEFAULT_LOCALE); - ret = __exec_appinfo_query(query, (void *)appinfo); - if (ret == -1) { - _LOGE("App Localized Info DB Information retrieval failed\n"); - ret = PMINFO_R_ERROR; - goto err; - } + snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, DEFAULT_LOCALE); + ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed"); + if (appinfo->svcapp_info->label) { LISTHEAD(appinfo->svcapp_info->label, ptr2); appinfo->svcapp_info->label = ptr2; @@ -4157,7 +4322,7 @@ API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_ } ret = PMINFO_R_OK; -err: +catch: if (locale) { free(locale); locale = NULL; @@ -4176,16 +4341,14 @@ err: } __cleanup_pkginfo(allinfo); - sqlite3_close(manifest_db); + sqlite3_close(appinfo_db); return ret; } API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, void *user_data) { - if (app_func == NULL) { - _LOGE("callback function is NULL\n"); - return PMINFO_R_EINVAL; - } + retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback function is NULL"); + char *error_message = NULL; int ret = PMINFO_R_OK; char query[MAX_QUERY_LEN] = {'\0'}; @@ -4196,57 +4359,37 @@ API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, v serviceapplication_x *ptr2 = NULL; label_x *tmp1 = NULL; icon_x *tmp2 = NULL; + sqlite3 *appinfo_db = NULL; + /*get system locale*/ syslocale = vconf_get_str(VCONFKEY_LANGSET); - if (syslocale == NULL) { - _LOGE("current locale is NULL\n"); - ret = PMINFO_R_ERROR; - goto err; - } + tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL"); + + /*get locale on db*/ locale = __convert_system_locale_to_manifest_locale(syslocale); - if (locale == NULL) { - _LOGE("manifest locale is NULL\n"); - ret = PMINFO_R_EINVAL; - goto err; - } + tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL"); - ret = __open_manifest_db(); - if (ret == -1) { - _LOGE("Fail to open manifest DB\n"); - ret = PMINFO_R_ERROR; - goto err; - } + /*open db*/ + ret = db_util_open_with_options(MANIFEST_DB, &appinfo_db, SQLITE_OPEN_READONLY, NULL); + retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB); + + /*calloc pkginfo*/ pkgmgr_pkginfo_x *info = NULL; info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x)); - if (info == NULL) { - _LOGE("Out of Memory!!!\n"); - ret = PMINFO_R_ERROR; - goto err; - } + tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!"); + + /*calloc manifest_info*/ info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x)); - if (info->manifest_info == NULL) { - _LOGE("Out of Memory!!!\n"); - ret = PMINFO_R_ERROR; - goto err; - } + tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!"); + + /*calloc appinfo*/ appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x)); - if (appinfo == NULL) { - _LOGE("Out of Memory!!!\n"); - ret = PMINFO_R_ERROR; - goto err; - } + tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!"); snprintf(query, MAX_QUERY_LEN, "select * from package_app_info"); - if (SQLITE_OK != - sqlite3_exec(manifest_db, query, __app_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); - ret = PMINFO_R_ERROR; - goto err; - } - memset(query, '\0', MAX_QUERY_LEN); + ret = __exec_db_query(appinfo_db, query, __app_list_cb, (void *)info); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed"); + if (info->manifest_info->uiapplication) { LISTHEAD(info->manifest_info->uiapplication, ptr1); info->manifest_info->uiapplication = ptr1; @@ -4265,18 +4408,14 @@ API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, v snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \ "from package_app_info where " \ "app_id='%s'", ptr1->appid); - ret = __exec_appinfo_query(query, (void *)appinfo); - if (ret == -1) { - _LOGE("App Info DB Information retrieval failed\n"); - ret = PMINFO_R_ERROR; - goto err; - } + ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed"); if (strcmp(appinfo->uiapp_info->type,"c++app") == 0){ if (locale) { free(locale); } - locale = __get_app_locale_by_fallback(ptr1->appid, syslocale); + locale = __get_app_locale_by_fallback(appinfo_db, ptr1->appid, syslocale); } memset(query, '\0', MAX_QUERY_LEN); @@ -4284,23 +4423,30 @@ API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, v "from package_app_localized_info where " \ "app_id='%s' and app_locale='%s'", ptr1->appid, locale); - ret = __exec_appinfo_query(query, (void *)appinfo); - if (ret == -1) { - _LOGE("App Localized Info DB Information retrieval failed\n"); - ret = PMINFO_R_ERROR; - goto err; - } + ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed"); + memset(query, '\0', MAX_QUERY_LEN); snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \ "from package_app_localized_info where " \ "app_id='%s' and app_locale='%s'", ptr1->appid, DEFAULT_LOCALE); - ret = __exec_appinfo_query(query, (void *)appinfo); - if (ret == -1) { - _LOGE("App Localized Info DB Information retrieval failed\n"); - ret = PMINFO_R_ERROR; - goto err; - } + + ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed"); + + /*store setting notification icon section*/ + memset(query, '\0', MAX_QUERY_LEN); + snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", ptr1->appid); + ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed"); + + /*store app preview image info*/ + memset(query, '\0', MAX_QUERY_LEN); + snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", ptr1->appid); + ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed"); + if (appinfo->uiapp_info->label) { LISTHEAD(appinfo->uiapp_info->label, tmp1); appinfo->uiapp_info->label = tmp1; @@ -4321,37 +4467,29 @@ API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, v appinfo->app_component = PMINFO_SVC_APP; appinfo->package = strdup(ptr2->package); appinfo->svcapp_info = ptr2; + memset(query, '\0', MAX_QUERY_LEN); snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \ "from package_app_info where " \ "app_id='%s'", ptr2->appid); - ret = __exec_appinfo_query(query, (void *)appinfo); - if (ret == -1) { - _LOGE("App Info DB Information retrieval failed\n"); - ret = PMINFO_R_ERROR; - goto err; - } + ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed"); + memset(query, '\0', MAX_QUERY_LEN); snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \ "from package_app_localized_info where " \ "app_id='%s' and app_locale='%s'", ptr2->appid, locale); - ret = __exec_appinfo_query(query, (void *)appinfo); - if (ret == -1) { - _LOGE("App Localized Info DB Information retrieval failed\n"); - ret = PMINFO_R_ERROR; - goto err; - } + ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed"); + memset(query, '\0', MAX_QUERY_LEN); snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \ "from package_app_localized_info where " \ "app_id='%s' and app_locale='%s'", ptr2->appid, DEFAULT_LOCALE); - ret = __exec_appinfo_query(query, (void *)appinfo); - if (ret == -1) { - _LOGE("App Localized Info DB Information retrieval failed\n"); - ret = PMINFO_R_ERROR; - goto err; - } + ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed"); + if (appinfo->svcapp_info->label) { LISTHEAD(appinfo->svcapp_info->label, tmp1); appinfo->svcapp_info->label = tmp1; @@ -4368,7 +4506,7 @@ API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, v } ret = PMINFO_R_OK; -err: +catch: if (locale) { free(locale); locale = NULL; @@ -4377,7 +4515,7 @@ err: free(syslocale); syslocale = NULL; } - sqlite3_close(manifest_db); + sqlite3_close(appinfo_db); if (appinfo) { free(appinfo); appinfo = NULL; @@ -4388,14 +4526,9 @@ err: API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle) { - if (appid == NULL) { - _LOGE("appid is NULL\n"); - return PMINFO_R_EINVAL; - } - if (handle == NULL) { - _LOGE("Argument supplied to hold return value is NULL\n"); - return PMINFO_R_EINVAL; - } + retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL"); + retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL"); + pkgmgr_appinfo_x *appinfo = NULL; char *error_message = NULL; char *syslocale = NULL; @@ -4405,118 +4538,95 @@ API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h * label_x *tmp1 = NULL; icon_x *tmp2 = NULL; category_x *tmp3 = NULL; + metadata_x *tmp4 = NULL; + permission_x *tmp5 = NULL; char query[MAX_QUERY_LEN] = {'\0'}; + sqlite3 *appinfo_db = NULL; - /*Validate appid*/ - ret = __open_manifest_db(); - if (ret == -1) { - _LOGE("Fail to open manifest DB\n"); - ret = PMINFO_R_ERROR; - goto err; - } + /*open db*/ + ret = db_util_open_with_options(MANIFEST_DB, &appinfo_db, SQLITE_OPEN_READONLY, NULL); + retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB); + + /*check appid exist on db*/ 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 PMINFO_R_ERROR; - } - if (exist == 0) { - _LOGE("Appid not found in DB\n"); - ret = PMINFO_R_ERROR; - goto err; - } + ret = __exec_db_query(appinfo_db, query, __validate_cb, (void *)&exist); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "sqlite3_exec fail"); + tryvm_if(exist == 0, ret = PMINFO_R_ERROR, "Appid not found in DB"); + + /*get system locale*/ syslocale = vconf_get_str(VCONFKEY_LANGSET); - if (syslocale == NULL) { - _LOGE("current locale is NULL\n"); - ret = PMINFO_R_ERROR; - goto err; - } + tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL"); + + /*get locale on db*/ locale = __convert_system_locale_to_manifest_locale(syslocale); - if (locale == NULL) { - _LOGE("manifest locale is NULL\n"); - ret = PMINFO_R_ERROR; - goto err; - } + tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL"); + + /*calloc appinfo*/ appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x)); - if (appinfo == NULL) { - _LOGE("Failed to allocate memory for appinfo\n"); - ret = PMINFO_R_ERROR; - goto err; - } + tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo"); /*check app_component from DB*/ + memset(query, '\0', MAX_QUERY_LEN); snprintf(query, MAX_QUERY_LEN, "select app_component, package from package_app_info where app_id='%s' ", appid); - ret = __exec_appcomponent_query(query, (void *)appinfo); - if (ret == -1) { - _LOGE("App Info DB Information retrieval failed\n"); - ret = PMINFO_R_ERROR; - goto err; - } + ret = __exec_db_query(appinfo_db, query, __appcomponent_cb, (void *)appinfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed"); + /*calloc app_component*/ if (appinfo->app_component == PMINFO_UI_APP) { 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 = PMINFO_R_ERROR; - goto err; - } + tryvm_if(appinfo->uiapp_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for uiapp info"); } else { 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 = PMINFO_R_ERROR; - goto err; - } + tryvm_if(appinfo->svcapp_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for svcapp info"); } /*populate app_info from DB*/ + memset(query, '\0', MAX_QUERY_LEN); 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 = PMINFO_R_ERROR; - goto err; - } - - if (strcmp(appinfo->uiapp_info->type,"c++app") == 0){ - if (locale) { - free(locale); - } - locale = __get_app_locale_by_fallback(appid, syslocale); - } + ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed"); memset(query, '\0', MAX_QUERY_LEN); - snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where" \ - " app_id='%s' and app_locale='%s'", appid, locale); - ret = __exec_appinfo_query(query, (void *)appinfo); - if (ret == -1) { - _LOGE("App Localized Info DB Information retrieval failed\n"); - ret = PMINFO_R_ERROR; - goto err; - } + snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appid, locale); + ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed"); + /*Also store the values corresponding to default locales*/ memset(query, '\0', MAX_QUERY_LEN); - snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where" \ - " app_id='%s' and app_locale='%s'", appid, DEFAULT_LOCALE); - ret = __exec_appinfo_query(query, (void *)appinfo); - if (ret == -1) { - _LOGE("App Localized Info DB Information retrieval failed\n"); - ret = PMINFO_R_ERROR; - goto err; - } + snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appid, DEFAULT_LOCALE); + ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed"); + /*Populate app category*/ memset(query, '\0', MAX_QUERY_LEN); - snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_category where" \ - " app_id='%s'", appid); - ret = __exec_appinfo_query(query, (void *)appinfo); - if (ret == -1) { - _LOGE("App Category Info DB Information retrieval failed\n"); - ret = PMINFO_R_ERROR; - goto err; - } + snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_category where app_id='%s'", appid); + ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Category Info DB Information retrieval failed"); + + /*Populate app metadata*/ + memset(query, '\0', MAX_QUERY_LEN); + snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_metadata where app_id='%s'", appid); + ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Metadata Info DB Information retrieval failed"); + + /*Populate app permission*/ + memset(query, '\0', MAX_QUERY_LEN); + snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_permission where app_id='%s'", appid); + ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App permission Info DB Information retrieval failed"); + + /*store setting notification icon section*/ + memset(query, '\0', MAX_QUERY_LEN); + snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appid); + ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed"); + + /*store app preview image info*/ + memset(query, '\0', MAX_QUERY_LEN); + snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appid); + ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed"); + switch (appinfo->app_component) { case PMINFO_UI_APP: if (appinfo->uiapp_info->label) { @@ -4531,6 +4641,14 @@ API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h * LISTHEAD(appinfo->uiapp_info->category, tmp3); appinfo->uiapp_info->category = tmp3; } + if (appinfo->uiapp_info->metadata) { + LISTHEAD(appinfo->uiapp_info->metadata, tmp4); + appinfo->uiapp_info->metadata = tmp4; + } + if (appinfo->uiapp_info->permission) { + LISTHEAD(appinfo->uiapp_info->permission, tmp5); + appinfo->uiapp_info->permission = tmp5; + } break; case PMINFO_SVC_APP: if (appinfo->svcapp_info->label) { @@ -4545,26 +4663,30 @@ API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h * LISTHEAD(appinfo->svcapp_info->category, tmp3); appinfo->svcapp_info->category = tmp3; } + if (appinfo->svcapp_info->metadata) { + LISTHEAD(appinfo->svcapp_info->metadata, tmp4); + appinfo->svcapp_info->metadata = tmp4; + } + if (appinfo->svcapp_info->permission) { + LISTHEAD(appinfo->svcapp_info->permission, tmp5); + appinfo->svcapp_info->permission = tmp5; + } break; default: break; } - *handle = (void*)appinfo; - sqlite3_close(manifest_db); - if (syslocale) { - free(syslocale); - syslocale = NULL; - } - if (locale) { - free(locale); - locale = NULL; + ret = PMINFO_R_OK; + +catch: + if (ret == PMINFO_R_OK) + *handle = (void*)appinfo; + else { + *handle = NULL; + __cleanup_appinfo(appinfo); } - return PMINFO_R_OK; -err: - *handle = NULL; - __cleanup_appinfo(appinfo); - sqlite3_close(manifest_db); + + sqlite3_close(appinfo_db); if (syslocale) { free(syslocale); syslocale = NULL; @@ -4877,116 +4999,54 @@ API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle, API int pkgmgrinfo_appinfo_get_setting_icon(pkgmgrinfo_appinfo_h handle, char **icon) { - if (handle == NULL) { - _LOGE("appinfo handle is NULL\n"); - return PMINFO_R_EINVAL; - } - if (icon == NULL) { - _LOGE("Argument supplied to hold return value is NULL\n"); - return PMINFO_R_EINVAL; - } - int ret = -1; - char *error_message = NULL; - char query[MAX_QUERY_LEN] = {'\0'}; - char path_buf[PKG_STRING_LEN_MAX] = {'\0'}; - pkgmgr_iconpath_x *data = NULL; - char *icon_path; - char *readpath; - char *appid; + retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n"); + retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n"); - ret = __open_manifest_db(); - if (ret == -1) { - _LOGE("Fail to open manifest DB\n"); - return PMINFO_R_ERROR; - } - - ret = pkgmgrinfo_appinfo_get_appid(handle,&appid); - if(ret < 0 || appid == NULL) - return PMINFO_R_ERROR; - - data = (pkgmgr_iconpath_x *)calloc(1, sizeof(pkgmgr_iconpath_x)); - if (data == NULL) { - _LOGE("Failed to allocate memory for pkgmgr_datacontrol_x\n"); - sqlite3_close(manifest_db); - return PMINFO_R_ERROR; - } + char *val = NULL; + icon_x *ptr = NULL; + icon_x *start = NULL; + pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle; - snprintf(query, MAX_QUERY_LEN, "select app_icon from package_app_icon_localized_info where app_id='%s' and app_icon_section ='setting'", appid); - if (SQLITE_OK != - sqlite3_exec(manifest_db, query, __icon_name_cb, (void *)data, &error_message)) { - _LOGE("Don't execute query = %s error message = %s\n", query, - error_message); - free(data); - sqlite3_free(error_message); - sqlite3_close(manifest_db); - return PMINFO_R_ERROR; - } - icon_path = __get_icon_with_path(data->iconpath); - *icon = (char *)icon_path; + start = info->uiapp_info->icon; - if (data) { - free(data); - data = NULL; + for(ptr = start; ptr != NULL; ptr = ptr->next) + { + if (ptr->section) { + val = (char *)ptr->section; + if (strcmp(val, "setting") == 0){ + *icon = (char *)ptr->text; + break; + } + } } - sqlite3_close(manifest_db); return PMINFO_R_OK; } API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon) { - if (handle == NULL) { - _LOGE("appinfo handle is NULL\n"); - return PMINFO_R_EINVAL; - } - if (icon == NULL) { - _LOGE("Argument supplied to hold return value is NULL\n"); - return PMINFO_R_EINVAL; - } - int ret = -1; - char *error_message = NULL; - char query[MAX_QUERY_LEN] = {'\0'}; - char path_buf[PKG_STRING_LEN_MAX] = {'\0'}; - pkgmgr_iconpath_x *data = NULL; - char *icon_path; - char *readpath; - char *appid; + retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n"); + retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n"); - ret = __open_manifest_db(); - if (ret == -1) { - _LOGE("Fail to open manifest DB\n"); - return PMINFO_R_ERROR; - } - - ret = pkgmgrinfo_appinfo_get_appid(handle,&appid); - if(ret < 0 || appid == NULL) - return PMINFO_R_ERROR; - - data = (pkgmgr_iconpath_x *)calloc(1, sizeof(pkgmgr_iconpath_x)); - if (data == NULL) { - _LOGE("Failed to allocate memory for pkgmgr_datacontrol_x\n"); - sqlite3_close(manifest_db); - return PMINFO_R_ERROR; - } + char *val = NULL; + icon_x *ptr = NULL; + icon_x *start = NULL; + pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle; - snprintf(query, MAX_QUERY_LEN, "select app_icon from package_app_icon_localized_info where app_id='%s' and app_icon_section ='notification'", appid); - if (SQLITE_OK != - sqlite3_exec(manifest_db, query, __icon_name_cb, (void *)data, &error_message)) { - _LOGE("Don't execute query = %s error message = %s\n", query, - error_message); - free(data); - sqlite3_free(error_message); - sqlite3_close(manifest_db); - return PMINFO_R_ERROR; - } - icon_path = __get_icon_with_path(data->iconpath); - *icon = (char *)icon_path; + start = info->uiapp_info->icon; - if (data) { - free(data); - data = NULL; + for(ptr = start; ptr != NULL; ptr = ptr->next) + { + if (ptr->section) { + val = (char *)ptr->section; + + if (strcmp(val, "notification") == 0){ + *icon = (char *)ptr->text; + break; + } + } } - sqlite3_close(manifest_db); + return PMINFO_R_OK; } @@ -5015,6 +5075,67 @@ API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, p return PMINFO_R_OK; } +API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img) +{ + retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n"); + retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n"); + + char *val = NULL; + image_x *ptr = NULL; + image_x *start = NULL; + pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle; + + start = info->uiapp_info->image; + + for(ptr = start; ptr != NULL; ptr = ptr->next) + { + if (ptr->section) { + val = (char *)ptr->section; + + if (strcmp(val, "preview") == 0) + *preview_img = (char *)info->uiapp_info->image->text; + + break; + } + } + return PMINFO_R_OK; +} + +API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission) +{ + retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n"); + retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n"); + + char *val = NULL; + permission_x *ptr = NULL; + permission_x *start = NULL; + pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle; + + if (info->app_component == PMINFO_UI_APP) + start = info->uiapp_info->permission; + else if (info->app_component == PMINFO_SVC_APP) + start = info->svcapp_info->permission; + else + return PMINFO_R_EINVAL; + + for(ptr = start; ptr != NULL; ptr = ptr->next) + { + if (ptr->type) { + val = (char *)ptr->type; + + if (strcmp(val, "signature") == 0) + *permission = PMINFO_PERMISSION_SIGNATURE; + else if (strcmp(val, "privilege") == 0) + *permission = PMINFO_PERMISSION_PRIVILEGE; + else + *permission = PMINFO_PERMISSION_NORMAL; + + break; + } + } + return PMINFO_R_OK; +} + API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_category_list_cb category_func, void *user_data) { @@ -5043,6 +5164,34 @@ API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle, return PMINFO_R_OK; } +API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle, + pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data) +{ + if (handle == NULL) { + _LOGE("appinfo handle is NULL\n"); + return PMINFO_R_EINVAL; + } + if (metadata_func == NULL) { + _LOGE("Callback function is NULL\n"); + return PMINFO_R_EINVAL; + } + int ret = -1; + metadata_x *ptr = NULL; + pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle; + if (info->app_component == PMINFO_UI_APP) + ptr = info->uiapp_info->metadata; + else if (info->app_component == PMINFO_SVC_APP) + ptr = info->svcapp_info->metadata; + else + return PMINFO_R_EINVAL; + for (; ptr; ptr = ptr->next) { + ret = metadata_func(ptr->name, ptr->value, user_data); + if (ret < 0) + break; + } + return PMINFO_R_OK; +} + API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data) { @@ -5252,6 +5401,56 @@ API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multi return PMINFO_R_OK; } +API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp) +{ + if (handle == NULL) { + _LOGE("appinfo handle is NULL\n"); + return PMINFO_R_EINVAL; + } + if (indicator_disp == NULL) { + _LOGE("Argument supplied to hold return value is NULL\n"); + return PMINFO_R_EINVAL; + } + char *val = NULL; + pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle; + val = (char *)info->uiapp_info->indicatordisplay; + if (val) { + if (strcasecmp(val, "true") == 0){ + *indicator_disp = 1; + }else if (strcasecmp(val, "false") == 0){ + *indicator_disp = 0; + }else{ + *indicator_disp = 0; + } + } + return PMINFO_R_OK; +} + + +API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img) +{ + if (handle == NULL) { + _LOGE("appinfo handle is NULL\n"); + return PMINFO_R_EINVAL; + } + if (portrait_img == NULL) { + _LOGE("Argument supplied to hold return value is NULL\n"); + return PMINFO_R_EINVAL; + } + if (landscape_img == NULL) { + _LOGE("Argument supplied to hold return value is NULL\n"); + return PMINFO_R_EINVAL; + } + pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle; + + if (info->app_component == PMINFO_UI_APP){ + *portrait_img = (char *)info->uiapp_info->portraitimg; + *landscape_img = (char *)info->uiapp_info->landscapeimg; + } + + return PMINFO_R_OK; +} + API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage) { if (handle == NULL) { @@ -5276,6 +5475,39 @@ API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *tas return PMINFO_R_OK; } +API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled) +{ + if (handle == NULL) { + _LOGE("appinfo handle is NULL\n"); + return PMINFO_R_EINVAL; + } + if (enabled == NULL) { + _LOGE("Argument supplied to hold return value is NULL\n"); + return PMINFO_R_EINVAL; + } + char *val = NULL; + pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle; + if (info->app_component == PMINFO_UI_APP) + val = (char *)info->uiapp_info->enabled; + else if (info->app_component == PMINFO_SVC_APP) + val = (char *)info->uiapp_info->enabled; + else { + _LOGE("invalid component type\n"); + return PMINFO_R_EINVAL; + } + + if (val) { + if (strcasecmp(val, "true") == 0) + *enabled = 1; + else if (strcasecmp(val, "false") == 0) + *enabled = 0; + else + *enabled = 1; + } + return PMINFO_R_OK; + +} + API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration) { if (handle == NULL) { @@ -6615,7 +6847,7 @@ API int pkgmgrinfo_set_install_location_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h hand } manifest_x *mfx = (manifest_x *)handle; if (mfx->installlocation == NULL) { - mfx->installlocation = (char *)calloc(1, strlen("prefer-external")); + mfx->installlocation = (char *)calloc(1, strlen("prefer-external") + 1); if (mfx->installlocation == NULL) { _LOGE("Malloc Failed\n"); return PMINFO_R_ERROR; @@ -6778,7 +7010,7 @@ API int pkgmgrinfo_set_removable_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int } manifest_x *mfx = (manifest_x *)handle; if (mfx->removable == NULL) { - mfx->removable = (char *)calloc(1, strlen("false")); + mfx->removable = (char *)calloc(1, strlen("false") + 1); if (mfx->removable == NULL) { _LOGE("Malloc Failed\n"); return PMINFO_R_ERROR; @@ -6807,7 +7039,7 @@ API int pkgmgrinfo_set_preload_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int p } manifest_x *mfx = (manifest_x *)handle; if (mfx->preload == NULL) { - mfx->preload = (char *)calloc(1, strlen("false")); + mfx->preload = (char *)calloc(1, strlen("false") + 1); if (mfx->preload == NULL) { _LOGE("Malloc Failed\n"); return PMINFO_R_ERROR; @@ -6876,6 +7108,69 @@ API int pkgmgrinfo_destroy_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle) return PMINFO_R_OK; } +API int pkgmgrinfo_pkginfo_set_state_enabled(const char *pkgid, bool enabled) +{ + /* Should be implemented later */ + return 0; +} + +API int pkgmgrinfo_appinfo_set_state_enabled(const char *appid, bool enabled) +{ + if (appid == NULL) { + _LOGE("appid is NULL\n"); + return PMINFO_R_EINVAL; + } + int ret = -1; + char query[MAX_QUERY_LEN] = {'\0'}; + ret = __open_manifest_db(); + + if (access(MANIFEST_DB, F_OK) == 0) { + ret = db_util_open(MANIFEST_DB, &manifest_db, + DB_UTIL_REGISTER_HOOK_METHOD); + if (ret != SQLITE_OK) { + _LOGE("connect db [%s] failed! Manifest DB does not exists!!\n", MANIFEST_DB); + return PMINFO_R_ERROR; + } + } + + /*Begin transaction*/ + ret = sqlite3_exec(manifest_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL); + if (ret != SQLITE_OK) { + _LOGE("Failed to begin transaction\n"); + sqlite3_close(manifest_db); + return PMINFO_R_ERROR; + } + _LOGD("Transaction Begin\n"); + + memset(query, '\0', MAX_QUERY_LEN); + snprintf(query, MAX_QUERY_LEN, + "update package_app_info set app_enabled='%s' where app_id='%s'", enabled?"true":"false", appid); + + char *error_message = NULL; + if (SQLITE_OK != + sqlite3_exec(manifest_db, query, NULL, NULL, &error_message)) { + _LOGE("Don't execute query = %s error message = %s\n", query, + error_message); + sqlite3_free(error_message); + return PMINFO_R_ERROR; + } + sqlite3_free(error_message); + + /*Commit transaction*/ + ret = sqlite3_exec(manifest_db, "COMMIT", NULL, NULL, NULL); + if (ret != SQLITE_OK) { + _LOGE("Failed to commit transaction. Rollback now\n"); + sqlite3_exec(manifest_db, "ROLLBACK", NULL, NULL, NULL); + sqlite3_close(manifest_db); + return PMINFO_R_ERROR; + } + _LOGD("Transaction Commit and End\n"); + sqlite3_close(manifest_db); + + return PMINFO_R_OK; +} + + API int pkgmgrinfo_datacontrol_get_info(const char *providerid, const char * type, char **appid, char **access) { if (providerid == NULL) { @@ -6933,3 +7228,136 @@ API int pkgmgrinfo_datacontrol_get_info(const char *providerid, const char * typ return PMINFO_R_OK; } + +API int pkgmgrinfo_appinfo_set_default_label(const char *appid, const char *label) +{ + if (appid == NULL) { + _LOGE("appid is NULL\n"); + return PMINFO_R_EINVAL; + } + int ret = -1; + char query[MAX_QUERY_LEN] = {'\0'}; + char *error_message = NULL; + ret = __open_manifest_db(); + + if (access(MANIFEST_DB, F_OK) == 0) { + ret = db_util_open(MANIFEST_DB, &manifest_db, + DB_UTIL_REGISTER_HOOK_METHOD); + if (ret != SQLITE_OK) { + _LOGE("connect db [%s] failed! Manifest DB does not exists!!\n", MANIFEST_DB); + return PMINFO_R_ERROR; + } + } + + /*Begin transaction*/ + ret = sqlite3_exec(manifest_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL); + if (ret != SQLITE_OK) { + _LOGE("Failed to begin transaction\n"); + sqlite3_close(manifest_db); + return PMINFO_R_ERROR; + } + _LOGD("Transaction Begin\n"); + + memset(query, '\0', MAX_QUERY_LEN); + snprintf(query, MAX_QUERY_LEN, + "update package_app_localized_info set app_label='%s' where app_id='%s' and app_locale='No Locale'", label, appid); + + if (SQLITE_OK != + sqlite3_exec(manifest_db, query, NULL, NULL, &error_message)) { + _LOGE("Don't execute query = %s error message = %s\n", query, + error_message); + sqlite3_free(error_message); + return PMINFO_R_ERROR; + } + + /*Commit transaction*/ + ret = sqlite3_exec(manifest_db, "COMMIT", NULL, NULL, NULL); + if (ret != SQLITE_OK) { + _LOGE("Failed to commit transaction. Rollback now\n"); + sqlite3_exec(manifest_db, "ROLLBACK", NULL, NULL, NULL); + sqlite3_close(manifest_db); + return PMINFO_R_ERROR; + } + _LOGD("Transaction Commit and End\n"); + sqlite3_close(manifest_db); + + return PMINFO_R_OK; +} + +API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status) +{ + if (handle == NULL) { + _LOGE("appinfo handle is NULL\n"); + return PMINFO_R_EINVAL; + } + if (status == NULL) { + _LOGE("Argument supplied to hold return value is NULL\n"); + return PMINFO_R_EINVAL; + } + char *val = NULL; + pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle; + val = (char *)info->uiapp_info->guestmode_visibility; + if (val) { + if (strcasecmp(val, "true") == 0){ + *status = 1; + }else if (strcasecmp(val, "false") == 0){ + *status = 0; + }else{ + *status = 1; + } + } + return PMINFO_R_OK; +} + +API int pkgmgrinfo_appinfo_set_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool status) +{ + if (handle == NULL) { + _LOGE("appinfo handle is NULL\n"); + return PMINFO_R_EINVAL; + } + char *val = NULL; + int ret = 0; + char *noti_string = NULL; + int len = 0; + char query[MAX_QUERY_LEN] = {'\0'}; + char *errmsg = NULL; + sqlite3 *pkgmgr_parser_db; + + pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle; + val = (char *)info->uiapp_info->guestmode_visibility; + if (val ) { + ret = + db_util_open_with_options(MANIFEST_DB, &pkgmgr_parser_db, + SQLITE_OPEN_READWRITE, NULL); + + if (ret != SQLITE_OK) { + _LOGE("DB Open Failed\n"); + return PMINFO_R_ERROR; + } + + /*TODO: Write to DB here*/ + if (status == true) + snprintf(query, MAX_QUERY_LEN, "update package_app_info set app_guestmodevisibility = 'true' where app_id = '%s'", (char *)info->uiapp_info->appid); + else + snprintf(query, MAX_QUERY_LEN, "update package_app_info set app_guestmodevisibility = 'false' where app_id = '%s'", (char *)info->uiapp_info->appid); + + if (SQLITE_OK != sqlite3_exec(pkgmgr_parser_db, query, NULL, NULL, &errmsg)) { + _LOGE("DB update [%s] failed, error message = %s\n", query, errmsg); + free(errmsg); + sqlite3_close(pkgmgr_parser_db); + return PMINFO_R_ERROR; + }else{ + sqlite3_close(pkgmgr_parser_db); + len = strlen((char *)info->uiapp_info->appid) + 8; + noti_string = calloc(1, len); + if (noti_string == NULL){ + return PMINFO_R_ERROR; + } + snprintf(noti_string, len, "update:%s", (char *)info->uiapp_info->appid); + vconf_set_str(VCONFKEY_AIL_INFO_STATE, noti_string); + vconf_set_str(VCONFKEY_MENUSCREEN_DESKTOP, noti_string); // duplicate, will be removed + free(noti_string); + } + } + return PMINFO_R_OK; +}