--- /dev/null
+build_log
+*.log
+*.pyc
+usr
+opt
+*.o
+*.os
+*.exe
+binaries
+*.ipk
+*~
+cmake_tmp
+*-stamp
+doxygen_output
--- /dev/null
+echo "--------------------------------------"
+echo "Update package database..............."
+echo "--------------------------------------"
+/usr/bin/pkg_fota
set(CMAKE_SKIP_BUILD_RPATH true)
#Verbose
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/comm ${CMAKE_SOURCE_DIR}/parser)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/comm )
INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED security-server dlog elementary evas ecore appcore-efl ecore-x ail ecore-file libxml-2.0)
+pkg_check_modules(pkgs REQUIRED security-server dlog elementary evas ecore appcore-efl ecore-x ecore-file pkgmgr-info pkgmgr-parser iniparser vconf minizip xdgmime)
FOREACH(flag ${pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
-pkg_check_modules(libpkgs REQUIRED dbus-glib-1 dlog aul ail)
+pkg_check_modules(libpkgs REQUIRED dbus-glib-1 dlog pkgmgr-info pkgmgr-parser iniparser security-server vconf minizip xdgmime)
FOREACH(flag ${libpkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
##################
## build comm libraries
add_subdirectory(comm)
-add_subdirectory(parser)
add_subdirectory(tool)
add_subdirectory(types)
###################################################################################################
## for libpkgmgr-client.so (library)
SET(PKGMGR_CLIENT "pkgmgr-client")
-SET(libpkgmgr-client_SOURCES ${pm_c_src_dir}/pkgmgr-info.c ${pm_c_src_dir}/pkgmgr-dbinfo.c ${pm_c_src_dir}/pkgmgr-internal.c ${pm_c_src_dir}/pkgmgr.c)
+SET(libpkgmgr-client_SOURCES ${pm_c_src_dir}/pkgmgr-internal.c ${pm_c_src_dir}/pkgmgr.c)
SET(libpkgmgr-client_LDFLAGS " -module -avoid-version ")
SET(libpkgmgr-client_CFLAGS " ${CFLAGS} -fPIC -I${pm_c_inc_dir} -I${pm_inc_dir} -I${pm_t_inc_dir} ${debug_type}")
SET_TARGET_PROPERTIES(${PKGMGR_CLIENT} PROPERTIES SOVERSION ${VERSION_MAJOR})
SET_TARGET_PROPERTIES(${PKGMGR_CLIENT} PROPERTIES VERSION ${VERSION})
SET_TARGET_PROPERTIES(${PKGMGR_CLIENT} PROPERTIES COMPILE_FLAGS "${libpkgmgr-client_CFLAGS}")
-TARGET_LINK_LIBRARIES(${PKGMGR_CLIENT} pkgmgr_installer_client pkgmgr_installer_status_broadcast_server pkgmgr_parser ${libpkgs_LDFLAGS})
+TARGET_LINK_LIBRARIES(${PKGMGR_CLIENT} pkgmgr_installer_client pkgmgr_installer_status_broadcast_server pkgmgr-info ${libpkgs_LDFLAGS})
###################################################################################################
###################################################################################################
## for pkgmgr-server (binary)
SET(pkgmgr-server_SOURCES ${pm_s_src_dir}/pkgmgr-server.c ${pm_s_src_dir}/pm-queue.c)
-SET(pkgmgr-server_CFLAGS " -I. -I${pm_inc_dir} -I${pm_s_inc_dir} -I${pm_dir}/comm ${debug_type} -D_GNU_SOURCE ")
+SET(pkgmgr-server_CFLAGS " -I. -I${pm_inc_dir} -I${pm_s_inc_dir} -I${pm_dir}/comm ${debug_type} -D_GNU_SOURCE -fPIE")
SET(pkgmgr-server_LDFLAGS ${pkgs_LDFLAGS})
ADD_EXECUTABLE(pkgmgr-server ${pkgmgr-server_SOURCES})
TARGET_LINK_LIBRARIES(pkgmgr-server pkgmgr_installer pkgmgr_installer_pkg_mgr_server)
-TARGET_LINK_LIBRARIES(pkgmgr-server ${pkgs_LDFLAGS})
+TARGET_LINK_LIBRARIES(pkgmgr-server ${PKGMGR_CLIENT} ${pkgs_LDFLAGS})
SET_TARGET_PROPERTIES(pkgmgr-server PROPERTIES COMPILE_FLAGS "${pkgmgr-server_CFLAGS}")
+SET_TARGET_PROPERTIES(pkgmgr-server PROPERTIES LINK_FLAGS "-pie")
####################################################################################################
CONFIGURE_FILE(pkgmgr.pc.in pkgmgr.pc @ONLY)
-configure_file(org.tizen.slp.pkgmgr.service.in org.tizen.slp.pkgmgr.service @ONLY)
+CONFIGURE_FILE(junkmgr.pc.in junkmgr.pc @ONLY)
+configure_file(org.tizen.pkgmgr.service.in org.tizen.pkgmgr.service @ONLY)
configure_file(pkg_path.conf.in pkg_path.conf @ONLY)
+configure_file(710.pkgmgr.patch.sh.in 710.pkgmgr.patch.sh @ONLY)
+configure_file(pkgmgr-soft-reset-ui.sh.in pkgmgr-soft-reset-ui.sh @ONLY)
#INSTALL(FILES ${CMAKE_BINARY_DIR}/libpkgmgr-client.so DESTINATION lib)
INSTALL(TARGETS ${PKGMGR_CLIENT} DESTINATION lib COMPONENT RuntimeLibraries)
INSTALL(FILES ${CMAKE_BINARY_DIR}/pkgmgr-server DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr.pc DESTINATION lib/pkgconfig)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/junkmgr.pc DESTINATION lib/pkgconfig)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/client/include/package-manager.h DESTINATION include)
-INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.tizen.slp.pkgmgr.service DESTINATION ${PREFIX}/share/dbus-1/services/)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/junk-manager.h DESTINATION include)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.tizen.pkgmgr.service DESTINATION ${PREFIX}/share/dbus-1/services/)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/slp-pkgmgr.service DESTINATION ${PREFIX}/lib/systemd/system/)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkg_path.conf DESTINATION ${PREFIX}/etc/package-manager/)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/queue_status DESTINATION etc/package-manager/server/)
+install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/710.pkgmgr.patch.sh DESTINATION /etc/opt/upgrade/)
+install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/pkgmgr-soft-reset-ui.sh DESTINATION ${PREFIX}/etc/package-manager/)
####################################################################################################
add_subdirectory(installers)
/**
* @mainpage
- *
+ *
* This is package manager
*
* Packaeg manager is used to install/uninstall the packages.\n
* package includes dpkg, java, widget, etc. and it can be added\n
* Security is considered on current package manager\n
- *
+ *
*/
/**
*/
/**
- * @brief pkgmgr info types.
+ * @brief pkgmgr info types.
*/
#define PKGMGR_INFO_STR_PKGTYPE "pkg_type"
#define PKGMGR_INFO_STR_PKGNAME "pkg_name"
#define PKGMGR_INFO_STR_DATA_SIZE "data_size"
#define PKGMGR_INFO_STR_APP_SIZE "app_size"
#define PKGMGR_INFO_STR_INSTALLED_TIME "installed_time"
-/** @} */
-
/**
- * @brief Return values in pkgmgr.
+ * @brief listening status type in pkgmgr.
+ */
+#define PKGMGR_CLIENT_STATUS_ALL 0x00
+#define PKGMGR_CLIENT_STATUS_INSTALL 0x01
+#define PKGMGR_CLIENT_STATUS_UNINSTALL 0x02
+#define PKGMGR_CLIENT_STATUS_UPGRADE 0x04
+#define PKGMGR_CLIENT_STATUS_MOVE 0x08
+#define PKGMGR_CLIENT_STATUS_CLEAR_DATA 0x10
+#define PKGMGR_CLIENT_STATUS_INSTALL_PROGRESS 0x20
+#define PKGMGR_CLIENT_STATUS_GET_SIZE 0x40
+#define PKGMGR_CLIENT_STATUS_GET_JUNK_INFO 0x80
+/** @} */
+
+/* 1 -100 : Package command errors */
+/* 101-120 : reserved for Core installer */
+/* 121-140 : reserved for Web installer */
+/* 141-160 : reserved for Native installer */
+#define PKGCMD_ERR_PACKAGE_NOT_FOUND 1
+#define PKGCMD_ERR_PACKAGE_INVALID 2
+#define PKGCMD_ERR_PACKAGE_LOWER_VERSION 3
+#define PKGCMD_ERR_PACKAGE_EXECUTABLE_NOT_FOUND 4
+#define PKGCMD_ERR_MANIFEST_NOT_FOUND 11
+#define PKGCMD_ERR_MANIFEST_INVALID 12
+#define PKGCMD_ERR_CONFIG_NOT_FOUND 13
+#define PKGCMD_ERR_CONFIG_INVALID 14
+#define PKGCMD_ERR_SIGNATURE_NOT_FOUND 21
+#define PKGCMD_ERR_SIGNATURE_INVALID 22
+#define PKGCMD_ERR_SIGNATURE_VERIFICATION_FAILED 23
+#define PKGCMD_ERR_ROOT_CERTIFICATE_NOT_FOUND 31
+#define PKGCMD_ERR_CERTIFICATE_INVALID 32
+#define PKGCMD_ERR_CERTIFICATE_CHAIN_VERIFICATION_FAILED 33
+#define PKGCMD_ERR_CERTIFICATE_EXPIRED 34
+#define PKGCMD_ERR_INVALID_PRIVILEGE 41
+#define PKGCMD_ERR_PRIVILEGE_UNAUTHORIZED_FAILED 43
+#define PKGCMD_ERR_PRIVILEGE_UNKNOWN_FAILED 44
+#define PKGCMD_ERR_PRIVILEGE_USING_LEGACY_FAILED 45
+#define PKGCMD_ERR_MENU_ICON_NOT_FOUND 51
+#define PKGCMD_ERR_FATAL_ERROR 61
+#define PKGCMD_ERR_OUT_OF_STORAGE 62
+#define PKGCMD_ERR_OUT_OF_MEMORY 63
+#define PKGCMD_ERR_ARGUMENT_INVALID 64
+
+#define PKGCMD_ERR_PACKAGE_NOT_FOUND_STR "PACKAGE_NOT_FOUND"
+#define PKGCMD_ERR_PACKAGE_INVALID_STR "PACKAGE_INVALID"
+#define PKGCMD_ERR_PACKAGE_LOWER_VERSION_STR "PACKAGE_LOWER_VERSION"
+#define PKGCMD_ERR_PACKAGE_EXECUTABLE_NOT_FOUND_STR "PACKAGE_EXECUTABLE_NOT_FOUND"
+#define PKGCMD_ERR_MANIFEST_NOT_FOUND_STR "MANIFEST_NOT_FOUND"
+#define PKGCMD_ERR_MANIFEST_INVALID_STR "MANIFEST_INVALID"
+#define PKGCMD_ERR_CONFIG_NOT_FOUND_STR "CONFIG_NOT_FOUND"
+#define PKGCMD_ERR_CONFIG_INVALID_STR "CONFIG_INVALID"
+#define PKGCMD_ERR_SIGNATURE_NOT_FOUND_STR "SIGNATURE_NOT_FOUND"
+#define PKGCMD_ERR_SIGNATURE_INVALID_STR "SIGNATURE_INVALID"
+#define PKGCMD_ERR_SIGNATURE_VERIFICATION_FAILED_STR "SIGNATURE_VERIFICATION_FAILED"
+#define PKGCMD_ERR_ROOT_CERTIFICATE_NOT_FOUND_STR "ROOT_CERTIFICATE_NOT_FOUND"
+#define PKGCMD_ERR_CERTIFICATE_INVALID_STR "CERTIFICATE_INVALID"
+#define PKGCMD_ERR_CERTIFICATE_CHAIN_VERIFICATION_FAILED_STR "CERTIFICATE_CHAIN_VERIFICATION_FAILED"
+#define PKGCMD_ERR_CERTIFICATE_EXPIRED_STR "CERTIFICATE_EXPIRED"
+#define PKGCMD_ERR_INVALID_PRIVILEGE_STR "INVALID_PRIVILEGE"
+#define PKGCMD_ERR_MENU_ICON_NOT_FOUND_STR "MENU_ICON_NOT_FOUND"
+#define PKGCMD_ERR_FATAL_ERROR_STR "FATAL_ERROR"
+#define PKGCMD_ERR_OUT_OF_STORAGE_STR "OUT_OF_STORAGE"
+#define PKGCMD_ERR_OUT_OF_MEMORY_STR "OUT_OF_MEMORY"
+#define PKGCMD_ERR_ARGUMENT_INVALID_STR "ARGUMENT_INVALID"
+#define PKGCMD_ERR_UNKNOWN_STR "Unknown Error"
+#define PKGCMD_ERR_PRIVILEGE_UNAUTHORIZED_FAILED_STR "UNAUTHORIZED PRIVILEGE"
+#define PKGCMD_ERR_PRIVILEGE_UNKNOWN_FAILED_STR "UNKNOWN PRIVILEGE FAILED"
+#define PKGCMD_ERR_PRIVILEGE_USING_LEGACY_FAILED_STR "PRIVILEGE USING LEGACY FAILED"
+
+#define PKG_SIZE_INFO_FILE "/tmp/pkgmgr_size_info.txt"
+#define PKG_SIZE_INFO_PATH "/tmp"
+
+#define PKG_SIZE_INFO_TOTAL "__TOTAL__"
+#define PKG_CLEAR_ALL_CACHE "__ALL__"
+
+/**
+ * @brief Return values in pkgmgr.
*/
typedef enum _pkgmgr_return_val {
+ PKGMGR_R_ESYSTEM = -9, /**< Severe system error */
+ PKGMGR_R_EIO = -8, /**< IO error */
+ PKGMGR_R_ENOMEM = -7, /**< Out of memory */
+ PKGMGR_R_ENOPKG = -6, /**< No such package */
+ PKGMGR_R_EPRIV = -5, /**< Privilege denied */
PKGMGR_R_ETIMEOUT = -4, /**< Timeout */
PKGMGR_R_EINVAL = -3, /**< Invalid argument */
- PKGMGR_R_ECOMM = -2, /**< Comunication Error */
+ PKGMGR_R_ECOMM = -2, /**< Comunication error */
PKGMGR_R_ERROR = -1, /**< General error */
PKGMGR_R_OK = 0 /**< General success */
} pkgmgr_return_val;
* @defgroup pkg_operate APIs to install /uninstall / activate application
* @ingroup pkgmgr
* @brief
- * APIs to install /uninstall / activate application
+ * APIs to install /uninstall / activate application
* - Install application using application package filepath
* - Uninstall application using application package name
* - Activate application using application package name
typedef void* pkgmgr_pkginfo_h;
typedef void* pkgmgr_appinfo_h;
+typedef void* pkgmgr_certinfo_h;
+
+typedef void pkgmgr_client;
+typedef void pkgmgr_info;
-typedef int (*pkgmgr_iter_fn)(const char* pkg_type, const char* pkg_name,
+typedef struct
+{
+ long long data_size;
+ long long cache_size;
+ long long app_size;
+ long long ext_data_size;
+ long long ext_cache_size;
+ long long ext_app_size;
+} pkg_size_info_t;
+
+typedef int (*pkgmgr_iter_fn)(const char* pkg_type, const char* pkgid,
const char* version, void *data);
typedef int (*pkgmgr_handler)(int req_id, const char *pkg_type,
- const char *pkg_name, const char *key,
+ const char *pkgid, const char *key,
const char *val, const void *pmsg, void *data);
+typedef int (*pkgmgr_info_pkg_list_cb ) (const pkgmgr_pkginfo_h handle,
+ void *user_data);
+
typedef int (*pkgmgr_info_app_list_cb ) (const pkgmgr_appinfo_h handle,
- const char *appid, void *user_data);
+ void *user_data);
+typedef int (*pkgmgr_info_app_category_list_cb ) (const char *category_name,
+ void *user_data);
-typedef void pkgmgr_client;
+typedef void (*pkgmgr_pkg_size_info_receive_cb)(pkgmgr_client *pc, const char *pkgid,
+ const pkg_size_info_t *size_info, void *user_data);
+
+typedef void (*pkgmgr_total_pkg_size_info_receive_cb)(pkgmgr_client *pc,
+ const pkg_size_info_t *size_info, void *user_data);
typedef enum {
PC_REQUEST = 0,
PC_LISTENING,
PC_BROADCAST,
-}client_type;
+} client_type;
typedef enum {
PM_DEFAULT,
}pkgmgr_mode;
typedef enum {
- PM_LOCATION_INTERNAL = 0,
- PM_LOCATION_EXTERNAL
+ PM_INSTALL_LOCATION_AUTO = 0,
+ PM_INSTALL_LOCATION_INTERNAL_ONLY,
+ PM_INSTALL_LOCATION_PREFER_EXTERNAL,
}pkgmgr_install_location;
typedef enum {
+ PM_HWACCELERATION_NOT_USE_GL = 0,
+ PM_HWACCELERATION_USE_GL = 1,
+ PM_HWACCELERATION_USE_SYSTEM_SETTING = 2,
+}pkgmgr_hwacceleration_type;
+
+typedef enum {
+ PM_ALL_APP = 0,
PM_UI_APP,
PM_SVC_APP
}pkgmgr_app_component;
+typedef enum {
+ PM_MOVE_TO_INTERNAL = 0,
+ PM_MOVE_TO_SDCARD = 1,
+}pkgmgr_move_type;
+
+typedef enum {
+ PM_INTERNAL_STORAGE = 0,
+ PM_EXTERNAL_STORAGE = 1,
+}pkgmgr_installed_storage;
+
+typedef enum {
+ PM_AUTHOR_ROOT_CERT = 0,
+ PM_AUTHOR_INTERMEDIATE_CERT = 1,
+ PM_AUTHOR_SIGNER_CERT = 2,
+ PM_DISTRIBUTOR_ROOT_CERT = 3,
+ PM_DISTRIBUTOR_INTERMEDIATE_CERT = 4,
+ PM_DISTRIBUTOR_SIGNER_CERT = 5,
+ PM_DISTRIBUTOR2_ROOT_CERT = 6,
+ PM_DISTRIBUTOR2_INTERMEDIATE_CERT = 7,
+ PM_DISTRIBUTOR2_SIGNER_CERT = 8,
+}pkgmgr_cert_type;
+
+typedef enum {
+ PM_REQUEST_CSC = 0,
+ PM_REQUEST_MOVE = 1,
+ PM_REQUEST_GET_SIZE = 2,
+ PM_REQUEST_KILL_APP = 3,
+ PM_REQUEST_CHECK_APP = 4,
+ PM_REQUEST_GET_JUNK_INFO = 5,
+ PM_REQUEST_MAX
+}pkgmgr_request_service_type;
+
+typedef enum {
+ PM_GET_TOTAL_SIZE = 0,
+ PM_GET_DATA_SIZE = 1,
+ PM_GET_ALL_PKGS = 2,
+ PM_GET_SIZE_INFO = 3,
+ PM_GET_TOTAL_AND_DATA = 4,
+ PM_GET_SIZE_FILE = 5,
+ PM_GET_PKG_SIZE_INFO = 6,
+ PM_GET_TOTAL_PKG_SIZE_INFO = 7,
+ PM_GET_MAX
+} pkgmgr_getsize_type;
+
/**
* @brief This API creates pkgmgr client.
*
* This API is for package-manager client application.\n
- *
- * @param[in] ctype client type - PC_REQUEST, PC_LISTENING, PC_BROADCAST
+ *
+ * @param[in] ctype client type - PC_REQUEST, PC_LISTENING, PC_BROADCAST
* @return pkgmgr_client object
* @retval NULL on failure creating an object
*/
* @brief This API deletes pkgmgr client.
*
* This API is for package-manager client application.\n
- *
+ *
* @param[in] pc pkgmgr_client
* @return Operation result;
* @retval PKGMGR_R_OK success
* @brief This API installs package.
*
* This API is for package-manager client application.\n
- *
- * @param[in] pc pkgmgr_client
- * @param[in] pkg_type package type
+ *
+ * @param[in] pc pkgmgr_client
+ * @param[in] pkg_type package type
* @param[in] descriptor_path full path that descriptor is located
* @param[in] pkg_path full path that package file is located
* @param[in] optional_file optional file which is used for installation
pkgmgr_handler event_cb, void *data);
/**
+ * @brief This API reinstalls package.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] pc pkgmgr_client
+ * @param[in] pkg_type package type
+ * @param[in] pkg_path full path that package file is located
+ * @param[in] optional_file optional file which is used for installation
+ * @param[in] mode installation mode - PM_DEFAULT, PM_QUIET
+ * @param[in] event_cb user callback
+ * @param[in] data user data
+ * @return request_id (>0) if success, error code(<0) if fail\n
+ * @retval PKGMGR_R_OK success
+ * @retval PKGMGR_R_EINVAL invalid argument
+ * @retval PKGMGR_R_ECOMM communication error
+*/
+int pkgmgr_client_reinstall(pkgmgr_client *pc, const char *pkg_type, const char *pkgid,
+ const char *optional_file, pkgmgr_mode mode,
+ pkgmgr_handler event_cb, void *data);
+
+/**
* @brief This API uninstalls package.
*
* This API is for package-manager client application.\n
- *
- * @param[in] pc pkgmgr_client
- * @param[in] pkg_type package type
- * @param[in] pkg_name package name
+ *
+ * @param[in] pc pkgmgr_client
+ * @param[in] pkg_type package type
+ * @param[in] pkgid package id
* @param[in] mode installation mode - PM_DEFAULT, PM_QUIET
* @param[in] event_cb user callback
* @param[in] data user data
* @retval PKGMGR_R_ECOMM communication error
*/
int pkgmgr_client_uninstall(pkgmgr_client *pc, const char *pkg_type,
- const char *pkg_name, pkgmgr_mode mode,
+ const char *pkgid, pkgmgr_mode mode,
pkgmgr_handler event_cb, void *data);
/**
+ * @brief This API moves installed package to SD card or vice versa.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] pc pkgmgr_client
+ * @param[in] pkg_type package type
+ * @param[in] pkgid application package id
+ * @param[in] move_type PM_MOVE_TO_INTERNAL or PM_MOVE_TO_SDCARD
+ * @param[in] mode installation mode - PM_DEFAULT, PM_QUIET
+ * @param[in] event_cb user callback
+ * @param[in] data user data
+ * @retval PKGMGR_R_OK success
+ * @retval PKGMGR_R_EINVAL invalid argument
+ * @retval PKGMGR_R_ERROR general error
+*/
+int pkgmgr_client_move(pkgmgr_client *pc, const char *pkgid, pkgmgr_move_type move_type,
+ pkgmgr_handler event_cb, void *data);
+
+/**
* @brief This API activates package.
*
* This API is for package-manager client application.\n
- *
- * @param[in] pc pkgmgr_client
- * @param[in] pkg_type package type
- * @param[in] pkg_name package name
+ *
+ * @param[in] pc pkgmgr_client
+ * @param[in] pkg_type package type
+ * @param[in] pkgid package id
* @return request_id (>0) if success, error code(<0) if fail\n
* @retval PKGMGR_R_OK success
* @retval PKGMGR_R_EINVAL invalid argument
* @retval PKGMGR_R_ECOMM communication error
*/
int pkgmgr_client_activate(pkgmgr_client *pc, const char *pkg_type,
- const char *pkg_name);
+ const char *pkgid);
/**
* @brief This API deactivates package.
*
* This API is for package-manager client application.\n
- *
- * @param[in] pc pkgmgr_client
- * @param[in] pkg_type package type
- * @param[in] pkg_name package name
+ *
+ * @param[in] pc pkgmgr_client
+ * @param[in] pkg_type package type
+ * @param[in] pkgid package id
* @return request_id (>0) if success, error code(<0) if fail\n
* @retval PKGMGR_R_OK success
* @retval PKGMGR_R_EINVAL invalid argument
* @retval PKGMGR_R_ECOMM communication error
*/
int pkgmgr_client_deactivate(pkgmgr_client *pc, const char *pkg_type,
- const char *pkg_name);
+ const char *pkgid);
/**
- * @brief This API deletes application's private data.
+ * @brief This API activates package.
*
* This API is for package-manager client application.\n
*
* @param[in] pc pkgmgr_client
- * @param[in] pkg_type package type
- * @param[in] pkg_name package name
- * @param[in] mode installation mode - PM_DEFAULT, PM_QUIET
+ * @param[in] appid applicaiton id
* @return request_id (>0) if success, error code(<0) if fail\n
* @retval PKGMGR_R_OK success
* @retval PKGMGR_R_EINVAL invalid argument
* @retval PKGMGR_R_ECOMM communication error
*/
-int pkgmgr_client_clear_user_data(pkgmgr_client *pc, const char *pkg_type,
- const char *pkg_name, pkgmgr_mode mode);
+int pkgmgr_client_activate_app(pkgmgr_client *pc, const char *appid);
/**
- * @brief This API request to listen the pkgmgr's broadcasting
+ * @brief This API activates package.
*
* This API is for package-manager client application.\n
- *
- * @param[in] pc pkgmgr_client
- * @param[in] event_cb user callback
- * @param[in] data user data
+ *
+ * @param[in] pc pkgmgr_client
+ * @param[in] appid applicaiton id
+ * @param[in] argv argument vector
* @return request_id (>0) if success, error code(<0) if fail\n
* @retval PKGMGR_R_OK success
* @retval PKGMGR_R_EINVAL invalid argument
+ * @retval PKGMGR_R_ECOMM communication error
*/
-int pkgmgr_client_listen_status(pkgmgr_client *pc, pkgmgr_handler event_cb,
- void *data);
+int pkgmgr_client_activate_appv(pkgmgr_client * pc, const char *appid, char *const argv[]);
/**
- * @brief This API broadcasts pkgmgr's status
+ * @brief This API deactivates package.
*
* This API is for package-manager client application.\n
- *
- * @param[in] pc pkgmgr_client
- * @param[in] pkg_type package type
- * @param[in] pkg_name package name
- * @param[in] key key to broadcast
- * @param[in] val value to broadcast
- * @return 0 if success, error code(<0) if fail\n
+ *
+ * @param[in] pc pkgmgr_client
+ * @param[in] appid applicaiton id
+ * @return request_id (>0) if success, error code(<0) if fail\n
* @retval PKGMGR_R_OK success
* @retval PKGMGR_R_EINVAL invalid argument
+ * @retval PKGMGR_R_ECOMM communication error
*/
-int pkgmgr_client_broadcast_status(pkgmgr_client *pc, const char *pkg_type,
- const char *pkg_name, const char *key,
- const char *val);
+int pkgmgr_client_deactivate_app(pkgmgr_client *pc, const char *appid);
/**
- * @brief This API provides package list
+ * @brief This API deletes application's private data.
*
* This API is for package-manager client application.\n
- *
- * @param[in] iter_fn iteration function for list
- * @param[in] data user data
- * @return 0 if success, error code(<0) if fail\n
+ *
+ * @param[in] pc pkgmgr_client
+ * @param[in] pkg_type package type
+ * @param[in] pkgid package id
+ * @param[in] mode installation mode - PM_DEFAULT, PM_QUIET
+ * @return request_id (>0) if success, error code(<0) if fail\n
* @retval PKGMGR_R_OK success
* @retval PKGMGR_R_EINVAL invalid argument
- * @retval PKGMGR_R_ERROR internal error
+ * @retval PKGMGR_R_ECOMM communication error
*/
-int pkgmgr_get_pkg_list(pkgmgr_iter_fn iter_fn, void *data);
-/** @} */
+int pkgmgr_client_clear_user_data(pkgmgr_client *pc, const char *pkg_type,
+ const char *appid, pkgmgr_mode mode);
/**
- * @defgroup pkg_list APIs to get package information
- * @ingroup pkgmgr
- * @brief
- * API to get package information
+ * @brief This API set status type to listen for the pkgmgr's broadcasting
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] pc pkgmgr_client
+ * @param[in] status_type status type to listen
+ * @return request_id (>0) if success, error code(<0) if fail\n
+ * @retval PKGMGR_R_OK success
+ * @retval PKGMGR_R_EINVAL invalid argument
*/
+int pkgmgr_client_set_status_type(pkgmgr_client *pc, int status_type);
/**
- * @addtogroup pkg_list
- * @{
- */
-
-typedef void pkgmgr_info;
+ * @brief This API request to listen the pkgmgr's broadcasting
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] pc pkgmgr_client
+ * @param[in] event_cb user callback
+ * @param[in] data user data
+ * @return request_id (>0) if success, error code(<0) if fail\n
+ * @retval PKGMGR_R_OK success
+ * @retval PKGMGR_R_EINVAL invalid argument
+*/
+int pkgmgr_client_listen_status(pkgmgr_client *pc, pkgmgr_handler event_cb,
+ void *data);
/**
- * @brief This API gets the package's information.
+ * @brief This API broadcasts pkgmgr's status
*
- * This API is for package-manager client application.\n
- *
- * @param[in] pkg_type package type for the package to get infomation
- * @param[in] pkg_name package name for the package to get infomation
- * @return package entry pointer if success, NULL if fail\n
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] pc pkgmgr_client
+ * @param[in] pkg_type package type
+ * @param[in] pkgid package id
+ * @param[in] key key to broadcast
+ * @param[in] val value to broadcast
+ * @return 0 if success, error code(<0) if fail\n
+ * @retval PKGMGR_R_OK success
+ * @retval PKGMGR_R_EINVAL invalid argument
*/
-pkgmgr_info * pkgmgr_info_new(const char *pkg_type, const char *pkg_name);
+int pkgmgr_client_broadcast_status(pkgmgr_client *pc, const char *pkg_type,
+ const char *pkgid, const char *key,
+ const char *val);
/**
* @brief This API gets the package's information.
*
* This API is for package-manager client application.\n
- *
- * @param[in] pkg_type package type for the package to get infomation
+ *
* @param[in] pkg_path package file path to get infomation
* @return package entry pointer if success, NULL if fail\n
*/
-pkgmgr_info * pkgmgr_info_new_from_file(const char *pkg_type,
- const char *pkg_path);
+pkgmgr_info *pkgmgr_client_check_pkginfo_from_file(const char *pkg_path);
/**
* @brief This API get package information value
*
* This API is for package-manager client application.\n
- *
- * @param[in] pkg_info pointer for package info entry
- * @param[in] key key for package info field
- * @return string value if success, NULL if fail\n
-*/
-char * pkgmgr_info_get_string(pkgmgr_info * pkg_info, const char *key);
-
-/**
- * @brief This API get package information value
*
- * This API is for package-manager client application.\n
- *
* @param[in] pkg_info pointer for package info entry
* @return 0 if success, error code(<0) if fail\n
*/
-int pkgmgr_info_free(pkgmgr_info * pkg_info);
+int pkgmgr_client_free_pkginfo(pkgmgr_info * pkg_info);
/**
- * @brief This API get package info entry from db
+ * @brief This API requests service
*
- * This API is for package-manager client application.\n
+ * This API is for package-manager client application.\n
*
- * @param[in] pkg_name pointer to package name
- * @param[out] handle pointer to the package info handle.
- * @return 0 if success, error code(<0) if fail\n
+ * @param[in] service_type pkgmgr_request_service_type
+ * @param[in] service_mode mode which is used for addtional mode selection
+ * @param[in] pc pkgmgr_client
+ * @param[in] pkg_type package type
+ * @param[in] pkgid package id
+ * @param[in] custom_info custom information which is used for addtional information
+ * @param[in] event_cb user callback
+ * @param[in] data user data
+ * @return request_id (>0) if success, error code(<0) if fail\n
+ * @retval PKGMGR_R_OK success
+ * @retval PKGMGR_R_EINVAL invalid argument
+ * @retval PKGMGR_R_ECOMM communication error
*/
-int pkgmgr_get_pkginfo(const char *pkg_name, pkgmgr_pkginfo_h *handle);
+int pkgmgr_client_request_service(pkgmgr_request_service_type service_type, int service_mode,
+ pkgmgr_client * pc, const char *pkg_type, const char *pkgid,
+ const char *custom_info, pkgmgr_handler event_cb, void *data);
/**
- * @brief This API gets type of the given package.
+ * @brief This API requests service
*
- * This API is for package-manager client application.\n
+ * This API is for package-manager client application.\n
*
- * @param[in] handle pointer to package info handle
- * @param[out] type to hold package type.
- * @return 0 if success, error code(<0) if fail\n
+ * @return request_id (>0) if success, error code(<0) if fail\n
+ * @retval PKGMGR_R_OK success
+ * @retval PKGMGR_R_EINVAL invalid argument
+ * @retval PKGMGR_R_ECOMM communication error
*/
-int pkgmgr_get_pkginfo_type(pkgmgr_pkginfo_h handle, char **type);
+int pkgmgr_client_request_size_info(void);
/**
- * @brief This API gets version of the given package.
+ * @brief This API get package size
*
- * This API is for package-manager client application.\n
+ * This API is for package-manager client application.\n
*
- * @param[in] handle pointer to package info handle
- * @param[out] version to hold package version.
- * @return 0 if success, error code(<0) if fail\n
+ * @param[in] pc pkgmgr_client
+ * @param[in] pkgid package id
+ * @param[in] get_type type for pkgmgr client request to get package size
+ * @param[in] event_cb user callback
+ * @param[in] data user data
+ * @return request_id (>0) if success, error code(<0) if fail\n
+ * @retval PKGMGR_R_OK success
+ * @retval PKGMGR_R_EINVAL invalid argument
+ * @retval PKGMGR_R_ECOMM communication error
*/
-int pkgmgr_get_pkginfo_version(pkgmgr_pkginfo_h handle, char **version);
+int pkgmgr_client_get_size(pkgmgr_client *pc, const char *pkgid, pkgmgr_getsize_type get_type, pkgmgr_handler event_cb, void *data);
/**
- * @brief This API gets install location of the given package.
+ * @brief Gets the package size information.
+ * @details The package size info is asynchronously obtained by the specified callback function.
*
- * This API is for package-manager client application.\n
+ * @param[in] pc The pointer to pkgmgr_client instance
+ * @param[in] pkgid The package ID
+ * @param[in] result_cb The asynchronous callback function to get the package size information
+ * @param[in] user_data User data to be passed to the callback function
*
- * @param[in] handle pointer to package info handle
- * @param[out] location to hold install location.
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_get_pkginfo_install_location(pkgmgr_pkginfo_h handle, pkgmgr_install_location *location);
+ * @return 0 on success, otherwise a negative error value
+ * @retval #PKGMGR_R_OK Successful
+ * @retval #PKGMGR_R_EINVAL Invalid parameter
+ * @retval #PKGMGR_R_ERROR Internal error
+ */
+int pkgmgr_client_get_package_size_info(pkgmgr_client *pc, const char *pkgid, pkgmgr_pkg_size_info_receive_cb result_cb, void *user_data);
/**
- * @brief This API gets label of the given package.
+ * @brief Gets the sum of the entire package size information.
+ * @details The package size info is asynchronously obtained by the specified callback function.
*
- * This API is for package-manager client application.\n
+ * @param[in] pc The pointer to pkgmgr_client instance
+ * @param[in] result_cb The asynchronous callback function to get the total package size information
+ * @param[in] user_data User data to be passed to the callback function
*
- * @param[in] handle pointer to package info handle
- * @param[out] label to hold package label.
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_get_pkginfo_label(pkgmgr_pkginfo_h handle, char **label);
+ * @return 0 on success, otherwise a negative error value
+ * @retval #PKGMGR_R_OK Successful
+ * @retval #PKGMGR_R_EINVAL Invalid parameter
+ * @retval #PKGMGR_R_ERROR Internal error
+ */
+int pkgmgr_client_get_total_package_size_info(pkgmgr_client *pc, pkgmgr_total_pkg_size_info_receive_cb result_cb, void *user_data);
+
+int pkgmgr_client_enable_pkg(const char *pkgid);
+int pkgmgr_client_disable_pkg(const char *pkgid);
/**
- * @brief This API gets icon of the given package.
+ * @brief This API removes cache directories
*
- * This API is for package-manager client application.\n
+ * This API is for package-manager client application.\n
*
- * @param[in] handle pointer to package info handle
- * @param[out] icon to hold package icon.
+ * @param[in] pkgid package id
* @return 0 if success, error code(<0) if fail\n
+ * @retval PKGMGR_R_OK success
+ * @retval PKGMGR_R_EINVAL invalid argument
+ * @retval PKGMGR_R_EPRIV privilege denied
+ * @retval PKGMGR_R_ERROR internal error
*/
-int pkgmgr_get_pkginfo_icon(pkgmgr_pkginfo_h handle, char **icon);
+int pkgmgr_client_clear_cache_dir(const char *pkgid);
/**
- * @brief This API gets desription of the given package.
+ * @brief This API removes all cache directories
*
- * This API is for package-manager client application.\n
+ * This API is for package-manager client application.\n
*
- * @param[in] handle pointer to package info handle
- * @param[out] description to hold package description.
* @return 0 if success, error code(<0) if fail\n
+ * @retval PKGMGR_R_OK success
+ * @retval PKGMGR_R_EINVAL invalid argument
+ * @retval PKGMGR_R_EPRIV privilege denied
+ * @retval PKGMGR_R_ERROR internal error
*/
-int pkgmgr_get_pkginfo_descriptioon(pkgmgr_pkginfo_h handle, char **description);
+int pkgmgr_client_clear_all_cache_dir(void);
+
+
+// API for wms on wearable
+int pkgmgr_client_reset_device(void);
+
/**
- * @brief This API gets author's name of the given package.
+ * @brief This API provides package list
*
- * This API is for package-manager client application.\n
+ * This API is for package-manager client application.\n
*
- * @param[in] handle pointer to package info handle
- * @param[out] author_name to hold author's name.
+ * @param[in] iter_fn iteration function for list
+ * @param[in] data user data
* @return 0 if success, error code(<0) if fail\n
+ * @retval PKGMGR_R_OK success
+ * @retval PKGMGR_R_EINVAL invalid argument
+ * @retval PKGMGR_R_ERROR internal error
*/
-int pkgmgr_get_pkginfo_author_name(pkgmgr_pkginfo_h handle, char **author_name);
+int pkgmgr_get_pkg_list(pkgmgr_iter_fn iter_fn, void *data) DEPRECATED;
+/** @} */
/**
- * @brief This API gets author's email of the given package.
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] handle pointer to package info handle
- * @param[out] author_email to hold author's email id.
- * @return 0 if success, error code(<0) if fail\n
+ * @defgroup pkg_list APIs to get package information
+ * @ingroup pkgmgr
+ * @brief
+ * API to get package information
*/
-int pkgmgr_get_pkginfo_author_email(pkgmgr_pkginfo_h handle, char **author_email);
/**
- * @brief This API gets author's href of the given package.
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] handle pointer to package info handle
- * @param[out] author_href to hold author's href.
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_get_pkginfo_author_href(pkgmgr_pkginfo_h handle, char **author_href);
+ * @addtogroup pkg_list
+ * @{
+ */
+
/**
- * @brief This API gets removable of the given package.
+ * @brief This API gets the package's information.
*
* This API is for package-manager client application.\n
*
- * @param[in] handle pointer to package info handle
- * @param[out] removable to hold removable value.
- * @return 0 if success, error code(<0) if fail\n
+ * @param[in] pkg_type package type for the package to get infomation
+ * @param[in] pkgid package id for the package to get infomation
+ * @return package entry pointer if success, NULL if fail\n
*/
-int pkgmgr_get_pkginfo_removable(pkgmgr_pkginfo_h handle, bool *removable);
+pkgmgr_info * pkgmgr_info_new(const char *pkg_type, const char *pkgid);
/**
- * @brief This API gets preload of the given package.
+ * @brief This API get package information value
*
* This API is for package-manager client application.\n
*
- * @param[in] handle pointer to package info handle
- * @param[out] preload to hold preload value
- * @return 0 if success, error code(<0) if fail\n
+ * @param[in] pkg_info pointer for package info entry
+ * @param[in] key key for package info field
+ * @return string value if success, NULL if fail\n
*/
-int pkgmgr_get_pkginfo_preload(pkgmgr_pkginfo_h handle, bool *preload);
+char * pkgmgr_info_get_string(pkgmgr_info * pkg_info, const char *key);
/**
- * @brief This API gets readonly value of the given package.
+ * @brief This API get package information value
*
* This API is for package-manager client application.\n
*
- * @param[in] handle pointer to package info handle
- * @param[out] readonly to hold readonly value
+ * @param[in] pkg_info pointer for package info entry
* @return 0 if success, error code(<0) if fail\n
*/
-int pkgmgr_get_pkginfo_readonly(pkgmgr_pkginfo_h handle, bool *readonly);
+int pkgmgr_info_free(pkgmgr_info * pkg_info);
/**
- * @brief This API gets list of ui-application/service application of the given package.
+ * @brief This API get package info entry from db
*
* This API is for package-manager client application.\n
*
- * @param[in] handle pointer to package info handle
- * @param[in] component application component type.
- * @param[in] app_func application's callback function.
- * @param[in] user_data user data to be passed to callback function
+ * @param[in] pkgid pointer to package id
+ * @param[out] handle pointer to the package info handle.
* @return 0 if success, error code(<0) if fail\n
*/
-int pkgmgr_get_info_app(pkgmgr_pkginfo_h handle, pkgmgr_app_component component,
- pkgmgr_info_app_list_cb app_func, void *user_data);
+int pkgmgr_pkginfo_get_pkginfo(const char *pkgid, pkgmgr_pkginfo_h *handle) DEPRECATED;
/**
- * @brief This API gets list of installed applications.
+ * @brief This API gets label of the given package.
*
* This API is for package-manager client application.\n
*
- * @param[in] iter_fn iteration function for list
- * @param[in] user_data user data to be passed to callback function
+ * @param[in] handle pointer to package info handle
+ * @param[out] label to hold package label.
* @return 0 if success, error code(<0) if fail\n
*/
-int pkgmgr_get_info_list(pkgmgr_iter_fn iter_fn, void *user_data);
-
+int pkgmgr_pkginfo_get_label(pkgmgr_pkginfo_h handle, char **label) DEPRECATED;
/**
* @brief This API destroy the pacakge info handle
* @param[in] handle pointer to package info handle
* @return 0 if success, error code(<0) if fail\n
*/
-int pkgmgr_destroy_pkginfo(pkgmgr_pkginfo_h handle);
+int pkgmgr_pkginfo_destroy_pkginfo(pkgmgr_pkginfo_h handle) DEPRECATED;
/**
- * @brief This API gets application info entry from db.
+ * @brief This API gets installed storage of the given package.
*
* This API is for package-manager client application.\n
*
- * @param[in] appid application id
- * @param[out] handle pointer to app info handle
+ * @param[in] pkgid id of package
+ * @param[out] storage storage of package
* @return 0 if success, error code(<0) if fail\n
*/
-int pkgmgr_get_appinfo(const char *appid, pkgmgr_appinfo_h *handle);
+int pkgmgr_pkginfo_get_installed_storage(pkgmgr_pkginfo_h handle, pkgmgr_installed_storage *storage) DEPRECATED;
/**
- * @brief This API gets exec of the given appid.
+ * @brief This API gets list of ui-application/service application of the given package.
*
* This API is for package-manager client application.\n
*
- * @param[in] handle pointer to app info handle
- * @param[out] exec to hold exec value
+ * @param[in] handle pointer to package info handle
+ * @param[in] component application component type.
+ * @param[in] app_func application's callback function.
+ * @param[in] user_data user data to be passed to callback function
* @return 0 if success, error code(<0) if fail\n
*/
-int pkgmgr_get_pkginfo_exec(pkgmgr_appinfo_h handle, char **exec);
+int pkgmgr_appinfo_get_list(pkgmgr_pkginfo_h handle, pkgmgr_app_component component,
+ pkgmgr_info_app_list_cb app_func, void *user_data) DEPRECATED;
/**
- * @brief This API gets component type of the given appid.
+ * @brief This API gets application info entry from db.
*
* This API is for package-manager client application.\n
*
- * @param[in] handle pointer to app info handle
- * @param[out] component to hold component value
+ * @param[in] appid application id
+ * @param[out] handle pointer to app info handle
* @return 0 if success, error code(<0) if fail\n
*/
-int pkgmgr_get_pkginfo_component(pkgmgr_appinfo_h handle, char **component);
+int pkgmgr_appinfo_get_appinfo(const char *appid, pkgmgr_appinfo_h *handle) DEPRECATED;
/**
- * @brief This API gets app type of the given appid.
+ * @brief This API gets appid of the given appid.
*
* This API is for package-manager client application.\n
*
* @param[in] handle pointer to app info handle
- * @param[out] app_type to hold the apptype.
+ * @param[out] appid to hold appid value
* @return 0 if success, error code(<0) if fail\n
*/
-int pkgmgr_get_pkginfo_apptype(pkgmgr_appinfo_h handle, char **app_type);
+int pkgmgr_appinfo_get_appid(pkgmgr_appinfo_h handle, char **appid) DEPRECATED;
/**
- * @brief This API gets nodisplay value of the given appid.
+ * @brief This API gets pkgid of the given appid.
*
* This API is for package-manager client application.\n
*
* @param[in] handle pointer to app info handle
- * @param[out] nodisplay to hold the nodisplay value
+ * @param[out]pkg_name to hold pkgid value
* @return 0 if success, error code(<0) if fail\n
*/
-int pkgmgr_get_pkginfo_nodisplay(pkgmgr_appinfo_h handle, bool *nodisplay);
+int pkgmgr_appinfo_get_pkgname(pkgmgr_appinfo_h handle, char **pkg_name) DEPRECATED;
/**
- * @brief This API gets multiple value of the given appid.
+ * @brief This API destroy the appinfo handle.
*
* This API is for package-manager client application.\n
*
* @param[in] handle pointer to app info handle
- * @param[out] multiple to hold the multiple value
* @return 0 if success, error code(<0) if fail\n
*/
-int pkgmgr_get_pkginfo_multiple(pkgmgr_appinfo_h handle, bool *multiple);
+int pkgmgr_appinfo_destroy_appinfo(pkgmgr_appinfo_h handle) DEPRECATED;
/**
- * @brief This API gets taskmanage value of the given appid.
+ * @brief This API creates the certinfo handle.
*
* This API is for package-manager client application.\n
*
- * @param[in] handle pointer to app info handle
- * @param[out] taskmanage to hold the taskmanage value
+ * @param[out] handle pointer to cert info handle
* @return 0 if success, error code(<0) if fail\n
*/
-int pkgmgr_get_pkginfo_taskmanage(pkgmgr_appinfo_h handle, bool *taskmanage);
+int pkgmgr_pkginfo_create_certinfo(pkgmgr_certinfo_h *handle) DEPRECATED;
/**
- * @brief This API gets onboot value of the given appid.
+ * @brief This API loads cert info in the handle.
*
* This API is for package-manager client application.\n
*
- * @param[in] handle pointer to app info handle
- * @param[out] onboot to hold the onboot value
+ * @param[in] handle pointer to cert info handle
+ * @param[in] pkgid package ID
* @return 0 if success, error code(<0) if fail\n
*/
-int pkgmgr_get_pkginfo_onboot(pkgmgr_appinfo_h handle, bool *onboot);
+int pkgmgr_pkginfo_load_certinfo(const char *pkgid, pkgmgr_certinfo_h handle) DEPRECATED;
/**
- * @brief This API gets autorestart value of the given appid.
+ * @brief This API gets cert value for corresponding cert type.
*
* This API is for package-manager client application.\n
*
- * @param[in] handle pointer to app info handle
- * @param[out] autorestart to hold the autorestart value
+ * @param[in] handle pointer to cert info handle
+ * @param[in] cert_type enum value for certificate type
+ * @param[out] cert_value pointer to store cert value
* @return 0 if success, error code(<0) if fail\n
*/
-int pkgmgr_get_pkginfo_autorestart(pkgmgr_appinfo_h handle, bool *autorestart);
+int pkgmgr_pkginfo_get_cert_value(pkgmgr_certinfo_h handle, pkgmgr_cert_type cert_type, const char **cert_value) DEPRECATED;
/**
- * @brief This API destroy the appinfo handle.
+ * @brief This API destroys cert info handle freeing all resources.
*
* This API is for package-manager client application.\n
*
- * @param[in] handle pointer to app info handle
+ * @param[in] handle pointer to cert info handle
* @return 0 if success, error code(<0) if fail\n
*/
-int pkgmgr_destroy_appinfo(pkgmgr_appinfo_h handle);
-/** @} */
+int pkgmgr_pkginfo_destroy_certinfo(pkgmgr_certinfo_h handle) DEPRECATED;
#ifdef __cplusplus
}
+++ /dev/null
-/*
- * slp-pkgmgr
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
- * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
- *
- * 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 API
-#define API __attribute__ ((visibility("default")))
-#endif
#endif
typedef enum {
- INSTALL_INTERNAL = 0,
- INSTALL_EXTERNAL,
-} INSTALL_LOCATION;
+ PM_INSTALL_INTERNAL = 0,
+ PM_INSTALL_EXTERNAL,
+} PM_INSTALL_LOCATION;
typedef void* pkgmgr_pkgdbinfo_h;
*
* This API is for backend installers.\n
*
- * @param[in] pkg_name package name.
+ * @param[in] pkgid package id.
* @param[out] handle package info handle.
* @return 0 if success, error code(<0) if fail\n
*/
-int pkgmgr_create_pkgdbinfo(const char *pkg_name, pkgmgr_pkgdbinfo_h *handle);
+int pkgmgr_create_pkgdbinfo(const char *pkgid, pkgmgr_pkgdbinfo_h *handle);
/**
* @brief This API sets the package type in DB.
* @param[in] location install location.
* @return 0 if success, error code(<0) if fail\n
*/
-int pkgmgr_set_install_location_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, INSTALL_LOCATION location);
+int pkgmgr_set_install_location_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, PM_INSTALL_LOCATION location);
+
+/**
+ * @brief This API sets package size in DB
+ *
+ * This API is for backend installers.\n
+ *
+ * @param[in] handle package info handle.
+ * @param[in] size package size.
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_set_size_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *size);
/**
* @brief This API sets label in DB.
+++ /dev/null
-/*
- * slp-pkgmgr
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
- * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-
-
-
-#ifndef __PKG_MANAGER_INTERNAL_H__
-#define __PKG_MANAGER_INTERNAL_H__
-
-#include <unistd.h>
-#include <ctype.h>
-#include <dlog.h>
-
-#undef LOG_TAG
-#ifndef LOG_TAG
-#define LOG_TAG "PKGMGR"
-#endif /* LOG_TAG */
-
-#define PKG_FRONTEND "frontend:"
-#define PKG_BACKEND "backend:"
-#define PKG_BACKENDLIB "backendlib:"
-#define PKG_PARSERLIB "parserlib:"
-#define PKG_CONF_PATH "/usr/etc/package-manager/pkg_path.conf"
-
-#define PKG_STATUS "STATUS"
-
-#define PKG_STRING_LEN_MAX 1024
-#define PKG_EXT_LEN_MAX 20
-#define PKG_ARGC_MAX 16
-
-#define _LOGE(fmt, arg...) LOGE("[%s,%d] "fmt, __FUNCTION__, __LINE__, ##arg)
-#define _LOGD(fmt, arg...) LOGD("[%s,%d] "fmt, __FUNCTION__, __LINE__, ##arg)
-
-#define retvm_if(expr, val, fmt, arg...) do { \
- if (expr) { \
- _LOGE(fmt, ##arg); \
- _LOGE("(%s) -> %s() return", #expr, __FUNCTION__); \
- return (val); \
- } \
-} while (0)
-
-#define retv_if(expr, val) do { \
- if (expr) { \
- _LOGE("(%s) -> %s() return", #expr, __FUNCTION__); \
- return (val); \
- } \
-} while (0)
-
-void _app_str_trim(char *input);
-char *_get_backend_path(const char *input_path);
-char *_get_backend_path_with_type(const char *type);
-
-#endif /* __PKG_MANAGER_INTERNAL_H__ */
+++ /dev/null
-/*
- * slp-pkgmgr
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
- * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <dlfcn.h>
-#include <malloc.h>
-#include <sys/time.h>
-
-#include "package-manager.h"
-#include "package-manager-types.h"
-#include "pkgmgr-internal.h"
-#include "pkgmgr-api.h"
-#include "pkgmgr_parser.h"
-#include "pkgmgr-dbinfo.h"
-
-API int pkgmgr_create_pkgdbinfo(const char *pkg_name, pkgmgr_pkgdbinfo_h *handle)
-{
- if (!pkg_name || !handle) {
- _LOGE("Argument supplied is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- manifest_x *mfx = NULL;
- mfx = calloc(1, sizeof(manifest_x));
- if (!mfx) {
- _LOGE("Malloc Failed\n");
- return PKGMGR_R_ERROR;
- }
- mfx->package = strdup(pkg_name);
- *handle = (void *)mfx;
- return PKGMGR_R_OK;
-}
-
-API int pkgmgr_set_type_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *type)
-{
- if (!type || !handle) {
- _LOGE("Argument supplied is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- int len = strlen(type);
- manifest_x *mfx = (manifest_x *)handle;
- if (len > PKG_TYPE_STRING_LEN_MAX) {
- _LOGE("pkg type length exceeds the max limit\n");
- return PKGMGR_R_EINVAL;
- }
- if (mfx->type == NULL)
- mfx->type = strndup(type, PKG_TYPE_STRING_LEN_MAX);
- else
- mfx->type = type;
-
- return PKGMGR_R_OK;
-}
-
-API int pkgmgr_set_version_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *version)
-{
- if (!version || !handle) {
- _LOGE("Argument supplied is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- int len = strlen(version);
- manifest_x *mfx = (manifest_x *)handle;
- if (len > PKG_VERSION_STRING_LEN_MAX) {
- _LOGE("pkg version length exceeds the max limit\n");
- return PKGMGR_R_EINVAL;
- }
- if (mfx->version == NULL)
- mfx->version = strndup(version, PKG_VERSION_STRING_LEN_MAX);
- else
- mfx->version = version;
-
- return PKGMGR_R_OK;
-}
-
-API int pkgmgr_set_install_location_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, INSTALL_LOCATION location)
-{
- if (!handle) {
- _LOGE("Argument supplied is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- if (location < 0 || location > 1) {
- _LOGE("Argument supplied is invalid\n");
- return PKGMGR_R_EINVAL;
- }
- manifest_x *mfx = (manifest_x *)handle;
- if (mfx->installlocation == NULL) {
- mfx->installlocation = (char *)calloc(1, strlen("prefer-external"));
- if (mfx->installlocation == NULL) {
- _LOGE("Malloc Failed\n");
- return PKGMGR_R_ERROR;
- }
- }
- if (location == INSTALL_INTERNAL) {
- strcpy(mfx->installlocation, "internal-only");
- } else if (location == INSTALL_EXTERNAL) {
- strcpy(mfx->installlocation, "prefer-external");
- } else {
- _LOGE("Invalid location type\n");
- return PKGMGR_R_ERROR;
- }
- return PKGMGR_R_OK;
-}
-
-API int pkgmgr_set_label_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *label_txt, const char *locale)
-{
- if (!handle || !label_txt) {
- _LOGE("Argument supplied is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- int len = strlen(label_txt);
- manifest_x *mfx = (manifest_x *)handle;
- if (len > PKG_VALUE_STRING_LEN_MAX) {
- _LOGE("label length exceeds the max limit\n");
- return PKGMGR_R_EINVAL;
- }
- label_x *label = calloc(1, sizeof(label_x));
- if (label == NULL) {
- _LOGE("Malloc Failed\n");
- return PKGMGR_R_ERROR;
- }
- LISTADD(mfx->label, label);
- if (locale)
- mfx->label->lang = strdup(locale);
- else
- mfx->label->lang = strdup(DEFAULT_LOCALE);
- mfx->label->text = strdup(label_txt);
-
- return PKGMGR_R_OK;
-}
-
-API int pkgmgr_set_icon_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *icon_txt, const char *locale)
-{
- if (!handle || !icon_txt) {
- _LOGE("Argument supplied is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- int len = strlen(icon_txt);
- manifest_x *mfx = (manifest_x *)handle;
- if (len > PKG_VALUE_STRING_LEN_MAX) {
- _LOGE("icon length exceeds the max limit\n");
- return PKGMGR_R_EINVAL;
- }
- icon_x *icon = calloc(1, sizeof(icon_x));
- if (icon == NULL) {
- _LOGE("Malloc Failed\n");
- return PKGMGR_R_ERROR;
- }
- LISTADD(mfx->icon, icon);
- if (locale)
- mfx->icon->lang = strdup(locale);
- else
- mfx->icon->lang = strdup(DEFAULT_LOCALE);
- mfx->icon->text = strdup(icon_txt);
-
- return PKGMGR_R_OK;
-}
-
-API int pkgmgr_set_description_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *desc_txt, const char *locale)
-{
- if (!handle || !desc_txt) {
- _LOGE("Argument supplied is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- int len = strlen(desc_txt);
- manifest_x *mfx = (manifest_x *)handle;
- if (len > PKG_VALUE_STRING_LEN_MAX) {
- _LOGE("description length exceeds the max limit\n");
- return PKGMGR_R_EINVAL;
- }
- description_x *description = calloc(1, sizeof(description_x));
- if (description == NULL) {
- _LOGE("Malloc Failed\n");
- return PKGMGR_R_ERROR;
- }
- LISTADD(mfx->description, description);
- if (locale)
- mfx->description->lang = strdup(locale);
- else
- mfx->description->lang = strdup(DEFAULT_LOCALE);
- mfx->description->text = strdup(desc_txt);
-
- return PKGMGR_R_OK;
-}
-
-API int pkgmgr_set_author_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *author_name,
- const char *author_email, const char *author_href, const char *locale)
-{
- if (!handle) {
- _LOGE("Argument supplied is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- manifest_x *mfx = (manifest_x *)handle;
- author_x *author = calloc(1, sizeof(author_x));
- if (author == NULL) {
- _LOGE("Malloc Failed\n");
- return PKGMGR_R_ERROR;
- }
- LISTADD(mfx->author, author);
- if (author_name)
- mfx->author->text = strdup(author_name);
- if (author_email)
- mfx->author->email = strdup(author_email);
- if (author_href)
- mfx->author->href = strdup(author_href);
- if (locale)
- mfx->author->lang = strdup(locale);
- else
- mfx->author->lang = strdup(DEFAULT_LOCALE);
- return PKGMGR_R_OK;
-}
-
-API int pkgmgr_set_removable_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, int removable)
-{
- if (!handle) {
- _LOGE("Argument supplied is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- if (removable < 0 || removable > 1) {
- _LOGE("Argument supplied is invalid\n");
- return PKGMGR_R_EINVAL;
- }
- manifest_x *mfx = (manifest_x *)handle;
- if (mfx->removable == NULL) {
- mfx->removable = (char *)calloc(1, strlen("false"));
- if (mfx->removable == NULL) {
- _LOGE("Malloc Failed\n");
- return PKGMGR_R_ERROR;
- }
- }
- if (removable == 0) {
- strcpy(mfx->removable, "false");
- } else if (removable == 1) {
- strcpy(mfx->removable, "true");
- } else {
- _LOGE("Invalid removable type\n");
- return PKGMGR_R_ERROR;
- }
- PKGMGR_R_OK;
-}
-
-API int pkgmgr_set_preload_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, int preload)
-{
- if (!handle) {
- _LOGE("Argument supplied is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- if (preload < 0 || preload > 1) {
- _LOGE("Argument supplied is invalid\n");
- return PKGMGR_R_EINVAL;
- }
- manifest_x *mfx = (manifest_x *)handle;
- if (mfx->preload == NULL) {
- mfx->preload = (char *)calloc(1, strlen("false"));
- if (mfx->preload == NULL) {
- _LOGE("Malloc Failed\n");
- return PKGMGR_R_ERROR;
- }
- }
- if (preload == 0) {
- strcpy(mfx->preload, "false");
- } else if (preload == 1) {
- strcpy(mfx->preload, "true");
- } else {
- _LOGE("Invalid preload type\n");
- return PKGMGR_R_ERROR;
- }
- PKGMGR_R_OK;
-}
-
-API int pkgmgr_save_pkgdbinfo(pkgmgr_pkgdbinfo_h handle)
-{
- if (!handle) {
- _LOGE("Argument supplied is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- int ret = 0;
- manifest_x *mfx = NULL;
- label_x *tmp1 = NULL;
- icon_x *tmp2 = NULL;
- description_x *tmp3 = NULL;
- author_x *tmp4 = NULL;
- mfx = (manifest_x *)handle;
- /*First move to head of all list pointers*/
- if (mfx->label) {
- LISTHEAD(mfx->label, tmp1);
- mfx->label = tmp1;
- }
- if (mfx->icon) {
- LISTHEAD(mfx->icon, tmp2);
- mfx->icon = tmp2;
- }
- if (mfx->description) {
- LISTHEAD(mfx->description, tmp3);
- mfx->description= tmp3;
- }
- if (mfx->author) {
- LISTHEAD(mfx->author, tmp4);
- mfx->author = tmp4;
- }
- ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
- if (ret == 0) {
- _LOGE("Successfully stored info in DB\n");
- return PKGMGR_R_OK;
- } else {
- _LOGE("Failed to store info in DB\n");
- return PKGMGR_R_ERROR;
- }
-}
-
-API int pkgmgr_destroy_pkgdbinfo(pkgmgr_pkgdbinfo_h handle)
-{
- if (!handle) {
- _LOGE("Argument supplied is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- manifest_x *mfx = NULL;
- mfx = (manifest_x *)handle;
- pkgmgr_parser_free_manifest_xml(mfx);
- return PKGMGR_R_OK;
-}
-
+++ /dev/null
-/*
- * slp-pkgmgr
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
- * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <dlfcn.h>
-#include <sys/time.h>
-#include <ail.h>
-#include <aul.h>
-
-#include "package-manager.h"
-#include "pkgmgr-internal.h"
-#include "pkgmgr-info.h"
-
-char *_get_pkg_type_from_desktop_file(const char *pkg_name)
-{
- static char pkg_type[PKG_EXT_LEN_MAX];
-
- ail_appinfo_h handle;
- ail_error_e ret;
- char *str;
-
- ret = ail_package_get_appinfo(pkg_name, &handle);
- if (ret != AIL_ERROR_OK) {
- return NULL;
- }
-
- ret = ail_appinfo_get_str(handle, AIL_PROP_X_SLP_PACKAGETYPE_STR, &str);
- if (ret != AIL_ERROR_OK) {
- ail_package_destroy_appinfo(handle);
- return NULL;
- }
- snprintf(pkg_type, sizeof(pkg_type) - 1, str);
-
- ret = ail_package_destroy_appinfo(handle);
- if (ret != AIL_ERROR_OK) {
- return NULL;
- }
-
- return pkg_type;
-}
-
-package_manager_pkg_info_t *_pkg_malloc_appinfo(int num)
-{
- package_manager_app_info_t *app_info = NULL;
- package_manager_app_info_t *first = NULL;
- package_manager_app_info_t *last = NULL;
- int i = 0;
-
- for (i = 0; i < num; i++) {
- app_info = (package_manager_app_info_t *)
- malloc(sizeof(package_manager_app_info_t));
- if (app_info == NULL) {
- package_manager_app_info_t *temp_info;
- package_manager_app_info_t *next;
-
- for (temp_info = first; temp_info != NULL;
- temp_info = next) {
- next = temp_info->next;
- free(temp_info);
- temp_info = NULL;
- }
-
- return NULL;
- }
-
- memset(app_info, 0x00, sizeof(package_manager_app_info_t));
-
- if (first == NULL)
- first = app_info;
-
- if (last == NULL)
- last = app_info;
- else {
- last->next = app_info;
- last = app_info;
- }
- }
-
- return first;
-
-}
-
-static pkg_plugin_set *plugin_set_list[24] = { 0, };
-
-pkg_plugin_set *_pkg_plugin_load_library(const char *pkg_type,
- const char *library_path)
-{
- void *library_handle = NULL;
- int i = 0;
-
- /* _pkg_plugin_on_load onload = NULL; */
- bool(*on_load) (pkg_plugin_set *plugin);
-
- if (library_path == NULL) {
- _LOGE("pkg library path = [%s] \n", library_path);
- return NULL;
- }
-
- if ((library_handle = dlopen(library_path, RTLD_LAZY)) == NULL) {
- _LOGE("dlopen is failed library_path[%s]\n", library_path);
- return NULL;
- }
-
- if ((on_load = dlsym(library_handle, "pkg_plugin_on_load")) == NULL ||
- dlerror() != NULL) {
- _LOGE("can not find symbol \n");
- dlclose(library_handle);
- return NULL;
- }
-
- for (i = 0; plugin_set_list[i]; i++) {
- if (strcmp(plugin_set_list[i]->pkg_type, pkg_type) == 0) {
- _LOGD("already loaded [%s] is done well \n",
- library_path);
- goto END;
- }
- }
-
- plugin_set_list[i] = (pkg_plugin_set *) malloc(sizeof(pkg_plugin_set));
- if (plugin_set_list[i] == NULL) {
- _LOGE("malloc of the plugin_set_list element is failed \n");
- dlclose(library_handle);
- return NULL;
- }
-
- memset(plugin_set_list[i], 0x0, sizeof(pkg_plugin_set));
-
- if (on_load(plugin_set_list[i]) != 0) {
- _LOGE("on_load is failed \n");
-
- dlclose(library_handle);
-
- free(plugin_set_list[i]);
- plugin_set_list[i] = NULL;
-
- return NULL;
- }
-
- plugin_set_list[i]->plugin_handle = library_handle;
- strncpy(plugin_set_list[i]->pkg_type, pkg_type,
- PKG_TYPE_STRING_LEN_MAX - 1);
-
- _LOGD("load library [%s] is done well \n", library_path);
-
- END:
- return plugin_set_list[i];
-
-}
-
-int _pkg_plugin_get_library_path(const char *pkg_type, char *library_path)
-{
- FILE *fp = NULL;
- char buffer[1024] = { 0 };
-
- if (pkg_type == NULL || library_path == NULL) {
- _LOGE("invalid argument\n");
- return -1;
- }
-
- fp = fopen(PKG_CONF_PATH, "r");
- if (fp == NULL) {
- _LOGE("no matching backendlib\n");
- return PKGMGR_R_ERROR;
- }
-
- char *path = NULL;
- while (fgets(buffer, 1024, fp) != NULL) {
- if (buffer[0] == '#')
- continue;
-
- _app_str_trim(buffer);
-
- if ((path = strstr(buffer, PKG_BACKENDLIB)) != NULL) {
- _LOGD("[%s]\n", buffer);
- _LOGD("[%s]\n", path);
- path = path + strlen(PKG_BACKENDLIB);
- _LOGD("[%s]\n", path);
-
- break;
- }
-
- memset(buffer, 0x00, 1024);
- }
-
- if (fp != NULL)
- fclose(fp);
-
- if (path == NULL) {
- _LOGE("no matching backendlib\n");
- return PKGMGR_R_ERROR;
- }
-
- snprintf(library_path, 1024, "%slib%s.so", path, pkg_type);
-
- return PKGMGR_R_OK;
-
-}
-
-pkg_plugin_set *_package_manager_load_library(const char *pkg_type)
-{
- char package_path[1024] = { 0 };
- pkg_plugin_set *plugin_set = NULL;
-
- if (pkg_type == NULL) {
- _LOGE("can not load library - pkg_type is null\n");
- return NULL;
- }
-
- if (_pkg_plugin_get_library_path(pkg_type, package_path) ==
- PKGMGR_R_OK) {
- plugin_set = _pkg_plugin_load_library(pkg_type, package_path);
- if (plugin_set == NULL) {
- _LOGE("can not load library \n");
- return NULL;
- }
- } else {
- _LOGE("can not find path \n");
- return NULL;
- }
-
- return plugin_set;
-}
-
-typedef struct _detail_info_map_t {
- char *name;
- void *field;
- char *type;
-} detail_info_map_t;
-
-/*
- typedef struct _package_manager_pkg_detail_info_t {
- char pkg_type[PKG_TYPE_STRING_LEN_MAX];
- char pkg_name[PKG_NAME_STRING_LEN_MAX];
- char version[PKG_VERSION_STRING_LEN_MAX];
- char pkg_description[PKG_VALUE_STRING_LEN_MAX];
- char min_platform_version[PKG_VERSION_STRING_LEN_MAX];
- time_t installed_time;
- int installed_size;
- int app_size;
- int data_size;
- char optional_id[PKG_NAME_STRING_LEN_MAX];
- void *pkg_optional_info;
- } package_manager_pkg_detail_info_t;
-*/
-
-static package_manager_pkg_detail_info_t tmp_pkg_detail_info;
-
-static detail_info_map_t info_map[] = {
- {"pkg_type", tmp_pkg_detail_info.pkg_type, "string"},
- {"pkg_name", tmp_pkg_detail_info.pkg_name, "string"},
- {"version", tmp_pkg_detail_info.version, "string"},
- {"pkg_description", tmp_pkg_detail_info.pkg_description, "string"},
- {"min_platform_version", tmp_pkg_detail_info.min_platform_version,
- "string"},
- {"installed_time", &tmp_pkg_detail_info.installed_time, "time_t"},
- {"installed_size", &tmp_pkg_detail_info.installed_size, "int"},
- {"app_size", &tmp_pkg_detail_info.app_size, "int"},
- {"data_size", &tmp_pkg_detail_info.data_size, "int"},
- {"optional_id", tmp_pkg_detail_info.optional_id, "string"}
-};
-
-char *_get_info_string(const char *key,
- const package_manager_pkg_detail_info_t *
- pkg_detail_info)
-{
- detail_info_map_t *tmp;
- int i = 0;
-
- if (pkg_detail_info == NULL)
- return NULL;
-
- memcpy(&tmp_pkg_detail_info, pkg_detail_info,
- sizeof(package_manager_pkg_detail_info_t));
-
- for (i = 0; i < sizeof(info_map) / sizeof(detail_info_map_t); i++) {
- tmp = &info_map[i];
- if (strcmp(key, tmp->name) == 0) {
- if (strcmp(tmp->type, "string") == 0) {
- return strdup((char *)(tmp->field));
- } else if (strcmp(tmp->type, "bool") == 0) {
- char temp[PKG_VALUE_STRING_LEN_MAX];
- snprintf(temp, PKG_VALUE_STRING_LEN_MAX - 1,
- "%d", (int)*(bool *) (tmp->field));
- return strdup(temp);
- } else if (strcmp(tmp->type, "int") == 0) {
- char temp[PKG_VALUE_STRING_LEN_MAX];
- snprintf(temp, PKG_VALUE_STRING_LEN_MAX - 1,
- "%d", (int)*(int *)(tmp->field));
- return strdup(temp);
- } else if (strcmp(tmp->type, "time_t") == 0) {
- char temp[PKG_VALUE_STRING_LEN_MAX];
- snprintf(temp, PKG_VALUE_STRING_LEN_MAX - 1,
- "%d", (int)*(time_t *) (tmp->field));
- return strdup(temp);
- } else
- return NULL;
- }
- }
- return NULL;
-}
-
-int _get_info_int(const char *key,
- const package_manager_pkg_detail_info_t *pkg_detail_info)
-{
- detail_info_map_t *tmp;
- int i = 0;
-
- if (pkg_detail_info == NULL)
- return -1;
-
- memcpy(&tmp_pkg_detail_info, pkg_detail_info,
- sizeof(package_manager_pkg_detail_info_t));
- for (i = 0; i < sizeof(info_map) / sizeof(detail_info_map_t); i++) {
- tmp = &info_map[i];
- if (strcmp(key, tmp->name) == 0) {
- if (strcmp(tmp->type, "int") == 0) {
- return (int)*(int *)(tmp->field);
- } else
- return -1;
- }
- }
- return -1;
-}
-
-time_t _get_info_time(const char *key,
- const package_manager_pkg_detail_info_t *pkg_detail_info)
-{
- detail_info_map_t *tmp;
- int i = 0;
-
- if (pkg_detail_info == NULL)
- return -1;
-
- memcpy(&tmp_pkg_detail_info, pkg_detail_info,
- sizeof(package_manager_pkg_detail_info_t));
- for (i = 0; i < sizeof(info_map) / sizeof(detail_info_map_t); i++) {
- tmp = &info_map[i];
- if (strcmp(key, tmp->name) == 0) {
- if (strcmp(tmp->type, "time_t") == 0) {
- return (time_t) *(time_t *) (tmp->field);
- } else
- return (time_t) -1;
- }
- }
- return (time_t) -1;
-}
-
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
-#include <aul.h>
-
-#include "pkgmgr-internal.h"
+#include <xdgmime.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <minizip/unzip.h>
+
+#include <unistd.h>
+#include <dlfcn.h>
+#include <sys/time.h>
+#include <pkgmgr-info.h>
+
+#include "package-manager.h"
+#include "package-manager-debug.h"
+#include "package-manager-internal.h"
+
+#undef LOG_TAG
+#ifndef LOG_TAG
+#define LOG_TAG "PKGMGR"
+#endif /* LOG_TAG */
+
+#define WGT_XML_FILE "config.xml"
+#define TPK_XML_FILE "info/manifest.xml"
+#define CORE_XML_FILE "tizen-manifest.xml"
+#define HYBRID_XML_FILE "res/wgt/config.xml"
#define IS_WHITESPACE(CHAR) \
((CHAR == ' ' || CHAR == '\t' || CHAR == '\r' || CHAR == '\n') ? \
_app_str_trim(buffer);
if ((path = strstr(buffer, PKG_BACKEND)) != NULL) {
- _LOGD("[%s]\n", buffer);
- _LOGD("[%s]\n", path);
+// _LOGD("[%s]\n", buffer);
+// _LOGD("[%s]\n", path);
path = path + strlen(PKG_BACKEND);
- _LOGD("[%s]\n", path);
+// _LOGD("[%s]\n", path);
break;
}
snprintf(backend_path, PKG_STRING_LEN_MAX - 1, "%s", path);
/* else
sprintf(backend_path, "%s/", path); */
-
- snprintf(installer_path, PKG_STRING_LEN_MAX - 1,
- "%s%s", backend_path, type);
+ snprintf(installer_path, PKG_STRING_LEN_MAX - 1, "%s%s", backend_path, type);
_LOGD("installer_path[%s]\n", installer_path);
+
if (access(installer_path, F_OK) != 0) {
char extlist[256] = { '\0', };
- aul_get_mime_extension(type, extlist, sizeof(extlist));
+ _get_mime_extension(type, extlist, sizeof(extlist));
_LOGD("extlist[%s]\n", extlist);
if (strlen(extlist) == 0)
return strdup(installer_path);
}
+int _get_mime_from_file(const char *filename, char *mimetype, int len)
+{
+ const char *mime;
+ if (filename == NULL)
+ return -1;
+
+ if (access(filename, F_OK) != 0)
+ return -1;
+
+ mime = xdg_mime_get_mime_type_for_file(filename, 0);
+ if (strcmp(mime, "application/octet-stream") == 0) {
+ mime = xdg_mime_get_mime_type_from_file_name(filename);
+ }
+
+ snprintf(mimetype, len, "%s", mime);
+ return 0;
+}
+
+int _get_mime_extension(const char *mimetype, char *ext, int len)
+{
+ const char **extlist;
+ int totlen = 0;
+ const char *unaliased_mimetype;
+
+ if (mimetype == NULL || ext == NULL || len <= 0)
+ return -1;
+
+ unaliased_mimetype = xdg_mime_unalias_mime_type(mimetype);
+ if (unaliased_mimetype == NULL)
+ return -1;
+
+ extlist = xdg_mime_get_file_names_from_mime_type(unaliased_mimetype);
+ if (extlist == NULL)
+ return -1;
+
+ if (extlist[0] == NULL)
+ return -1;
+
+ ext[0] = 0;
+ while (*extlist != NULL) {
+ if (*(extlist + 1) == NULL) {
+ snprintf(&ext[totlen], len - totlen, "%s", *extlist);
+ break;
+ } else {
+ snprintf(&ext[totlen], len - totlen, "%s,", *extlist);
+ if (strlen(*extlist) > len - totlen - 1)
+ break;
+ totlen += strlen(*extlist) + 1;
+ extlist++;
+ }
+ }
+
+ return 0;
+}
+
+char *_get_pkg_type_from_desktop_file(const char *pkgid)
+{
+ static char pkg_type[PKG_EXT_LEN_MAX];
+
+ int ret = 0;
+ char *type = NULL;
+ pkgmgrinfo_pkginfo_h handle = NULL;
+
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+ if (ret != PMINFO_R_OK)
+ return NULL;
+
+ ret = pkgmgrinfo_pkginfo_get_type(handle, &type);
+ if (ret != PMINFO_R_OK) {
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ return NULL;
+ }
+
+ snprintf(pkg_type, sizeof(pkg_type) - 1, type);
+ _LOGD("pkgid = [%s], pkg type = [%s] \n", pkgid, pkg_type);
+
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ return pkg_type;
+}
+
+package_manager_pkg_info_t *_pkg_malloc_appinfo(int num)
+{
+ package_manager_app_info_t *app_info = NULL;
+ package_manager_app_info_t *first = NULL;
+ package_manager_app_info_t *last = NULL;
+ int i = 0;
+
+ for (i = 0; i < num; i++) {
+ app_info = (package_manager_app_info_t *)
+ malloc(sizeof(package_manager_app_info_t));
+ if (app_info == NULL) {
+ package_manager_app_info_t *temp_info;
+ package_manager_app_info_t *next;
+
+ for (temp_info = first; temp_info != NULL;
+ temp_info = next) {
+ next = temp_info->next;
+ free(temp_info);
+ temp_info = NULL;
+ }
+
+ return NULL;
+ }
+
+ memset(app_info, 0x00, sizeof(package_manager_app_info_t));
+
+ if (first == NULL)
+ first = app_info;
+
+ if (last == NULL)
+ last = app_info;
+ else {
+ last->next = app_info;
+ last = app_info;
+ }
+ }
+
+ return first;
+
+}
+
+static pkg_plugin_set *plugin_set_list[24] = { 0, };
+
+pkg_plugin_set *_pkg_plugin_load_library(const char *pkg_type,
+ const char *library_path)
+{
+ void *library_handle = NULL;
+ int i = 0;
+
+ /* _pkg_plugin_on_load onload = NULL; */
+ bool(*on_load) (pkg_plugin_set *plugin);
+
+ if (library_path == NULL) {
+ _LOGE("pkg library path = [%s] \n", library_path);
+ return NULL;
+ }
+
+ if ((library_handle = dlopen(library_path, RTLD_LAZY)) == NULL) {
+ _LOGE("dlopen is failed library_path[%s]\n", library_path);
+ return NULL;
+ }
+
+ if ((on_load = dlsym(library_handle, "pkg_plugin_on_load")) == NULL ||
+ dlerror() != NULL) {
+ _LOGE("can not find symbol \n");
+ dlclose(library_handle);
+ return NULL;
+ }
+
+ for (i = 0; plugin_set_list[i]; i++) {
+ if (strcmp(plugin_set_list[i]->pkg_type, pkg_type) == 0) {
+ _LOGD("already loaded [%s] is done well \n", library_path);
+ dlclose(library_handle);
+ goto END;
+ }
+ }
+
+ plugin_set_list[i] = (pkg_plugin_set *) malloc(sizeof(pkg_plugin_set));
+ if (plugin_set_list[i] == NULL) {
+ _LOGE("malloc of the plugin_set_list element is failed \n");
+ dlclose(library_handle);
+ return NULL;
+ }
+
+ memset(plugin_set_list[i], 0x0, sizeof(pkg_plugin_set));
+
+ if (on_load(plugin_set_list[i]) != 0) {
+ _LOGE("on_load is failed \n");
+
+ dlclose(library_handle);
+
+ free(plugin_set_list[i]);
+ plugin_set_list[i] = NULL;
+
+ return NULL;
+ }
+
+ plugin_set_list[i]->plugin_handle = library_handle;
+ strncpy(plugin_set_list[i]->pkg_type, pkg_type,
+ PKG_TYPE_STRING_LEN_MAX - 1);
+
+ _LOGD("load library [%s] is done well \n", library_path);
+
+ END:
+ return plugin_set_list[i];
+
+}
+
+int _pkg_plugin_get_library_path(const char *pkg_type, char *library_path)
+{
+ FILE *fp = NULL;
+ char buffer[1024] = { 0 };
+
+ if (pkg_type == NULL || library_path == NULL) {
+ _LOGE("invalid argument\n");
+ return -1;
+ }
+
+ fp = fopen(PKG_CONF_PATH, "r");
+ if (fp == NULL) {
+ _LOGE("no matching backendlib\n");
+ return PKGMGR_R_ERROR;
+ }
+
+ char *path = NULL;
+ while (fgets(buffer, 1024, fp) != NULL) {
+ if (buffer[0] == '#')
+ continue;
+
+ _app_str_trim(buffer);
+
+ if ((path = strstr(buffer, PKG_BACKENDLIB)) != NULL) {
+ path = path + strlen(PKG_BACKENDLIB);
+ _LOGD("[%s]\n", path);
+
+ break;
+ }
+
+ memset(buffer, 0x00, 1024);
+ }
+
+ if (fp != NULL)
+ fclose(fp);
+
+ if (path == NULL) {
+ _LOGE("no matching backendlib\n");
+ return PKGMGR_R_ERROR;
+ }
+
+ snprintf(library_path, 1024, "%slib%s.so", path, pkg_type);
+
+ return PKGMGR_R_OK;
+
+}
+
+pkg_plugin_set *_package_manager_load_library(const char *pkg_type)
+{
+ char package_path[1024] = { 0 };
+ pkg_plugin_set *plugin_set = NULL;
+
+ if (pkg_type == NULL) {
+ _LOGE("can not load library - pkg_type is null\n");
+ return NULL;
+ }
+
+ if (_pkg_plugin_get_library_path(pkg_type, package_path) ==
+ PKGMGR_R_OK) {
+ plugin_set = _pkg_plugin_load_library(pkg_type, package_path);
+ if (plugin_set == NULL) {
+ _LOGE("can not load library \n");
+ return NULL;
+ }
+ } else {
+ _LOGE("can not find path \n");
+ return NULL;
+ }
+
+ return plugin_set;
+}
+
+typedef struct _detail_info_map_t {
+ char *name;
+ void *field;
+ char *type;
+} detail_info_map_t;
+
+/*
+ typedef struct _package_manager_pkg_detail_info_t {
+ char pkg_type[PKG_TYPE_STRING_LEN_MAX];
+ char pkgid[PKG_NAME_STRING_LEN_MAX];
+ char version[PKG_VERSION_STRING_LEN_MAX];
+ char pkg_description[PKG_VALUE_STRING_LEN_MAX];
+ char min_platform_version[PKG_VERSION_STRING_LEN_MAX];
+ time_t installed_time;
+ int installed_size;
+ int app_size;
+ int data_size;
+ char optional_id[PKG_NAME_STRING_LEN_MAX];
+ void *pkg_optional_info;
+ } package_manager_pkg_detail_info_t;
+*/
+
+static package_manager_pkg_detail_info_t tmp_pkg_detail_info;
+
+static detail_info_map_t info_map[] = {
+ {"pkg_type", tmp_pkg_detail_info.pkg_type, "string"},
+ {"pkgid", tmp_pkg_detail_info.pkgid, "string"},
+ {"version", tmp_pkg_detail_info.version, "string"},
+ {"api_version", tmp_pkg_detail_info.api_version, "string"},
+ {"pkg_description", tmp_pkg_detail_info.pkg_description, "string"},
+ {"min_platform_version", tmp_pkg_detail_info.min_platform_version,
+ "string"},
+ {"installed_time", &tmp_pkg_detail_info.installed_time, "time_t"},
+ {"installed_size", &tmp_pkg_detail_info.installed_size, "int"},
+ {"app_size", &tmp_pkg_detail_info.app_size, "int"},
+ {"data_size", &tmp_pkg_detail_info.data_size, "int"},
+ {"optional_id", tmp_pkg_detail_info.optional_id, "string"}
+};
+
+char *_get_info_string(const char *key,
+ const package_manager_pkg_detail_info_t *
+ pkg_detail_info)
+{
+ detail_info_map_t *tmp;
+ int i = 0;
+
+ if (pkg_detail_info == NULL)
+ return NULL;
+
+ memcpy(&tmp_pkg_detail_info, pkg_detail_info,
+ sizeof(package_manager_pkg_detail_info_t));
+
+ for (i = 0; i < sizeof(info_map) / sizeof(detail_info_map_t); i++) {
+ tmp = &info_map[i];
+ if (strcmp(key, tmp->name) == 0) {
+ if (strcmp(tmp->type, "string") == 0) {
+ return strdup((char *)(tmp->field));
+ } else if (strcmp(tmp->type, "bool") == 0) {
+ char temp[PKG_VALUE_STRING_LEN_MAX];
+ snprintf(temp, PKG_VALUE_STRING_LEN_MAX - 1,
+ "%d", (int)*(bool *) (tmp->field));
+ return strdup(temp);
+ } else if (strcmp(tmp->type, "int") == 0) {
+ char temp[PKG_VALUE_STRING_LEN_MAX];
+ snprintf(temp, PKG_VALUE_STRING_LEN_MAX - 1,
+ "%d", (int)*(int *)(tmp->field));
+ return strdup(temp);
+ } else if (strcmp(tmp->type, "time_t") == 0) {
+ char temp[PKG_VALUE_STRING_LEN_MAX];
+ snprintf(temp, PKG_VALUE_STRING_LEN_MAX - 1,
+ "%d", (int)*(time_t *) (tmp->field));
+ return strdup(temp);
+ } else
+ return NULL;
+ }
+ }
+ return NULL;
+}
+
+int _get_info_int(const char *key,
+ const package_manager_pkg_detail_info_t *pkg_detail_info)
+{
+ detail_info_map_t *tmp;
+ int i = 0;
+
+ if (pkg_detail_info == NULL)
+ return -1;
+
+ memcpy(&tmp_pkg_detail_info, pkg_detail_info,
+ sizeof(package_manager_pkg_detail_info_t));
+ for (i = 0; i < sizeof(info_map) / sizeof(detail_info_map_t); i++) {
+ tmp = &info_map[i];
+ if (strcmp(key, tmp->name) == 0) {
+ if (strcmp(tmp->type, "int") == 0) {
+ return (int)*(int *)(tmp->field);
+ } else
+ return -1;
+ }
+ }
+ return -1;
+}
+
+time_t _get_info_time(const char *key,
+ const package_manager_pkg_detail_info_t *pkg_detail_info)
+{
+ detail_info_map_t *tmp;
+ int i = 0;
+
+ if (pkg_detail_info == NULL)
+ return -1;
+
+ memcpy(&tmp_pkg_detail_info, pkg_detail_info,
+ sizeof(package_manager_pkg_detail_info_t));
+ for (i = 0; i < sizeof(info_map) / sizeof(detail_info_map_t); i++) {
+ tmp = &info_map[i];
+ if (strcmp(key, tmp->name) == 0) {
+ if (strcmp(tmp->type, "time_t") == 0) {
+ return (time_t) *(time_t *) (tmp->field);
+ } else
+ return (time_t) -1;
+ }
+ }
+ return (time_t) -1;
+}
+
+static int __is_rpm_pkg(const char *filename)
+{
+ char *pkg_type = NULL;
+ char pkg_file[PKG_STRING_LEN_MAX] = { '\0', };
+
+ if (strrchr(filename, '/')) {
+ strncpy(pkg_file, strrchr(filename, '/') + 1, PKG_STRING_LEN_MAX - 1);
+ } else {
+ strncpy(pkg_file, filename, PKG_STRING_LEN_MAX - 1);
+ }
+
+ pkg_type = strrchr(pkg_file, '.');
+ if (pkg_type == NULL) {
+ _LOGE("pkg_type is null[%s]", filename);
+ return -1;
+ } else {
+ pkg_type++;
+ }
+
+ if (strcmp(pkg_type, "rpm") == 0) {
+ return 0;
+ } else {
+ return -1;
+ }
+}
+
+API char *_get_type_from_zip(const char *filename)
+{
+ retvm_if(filename == NULL, NULL, "filename is NULL");
+
+ char *pkg_type = NULL;
+ unzFile uf = NULL;
+
+ if (access(filename, F_OK) != 0) {
+ _LOGE("can not access to [%s]", filename);
+ return NULL;
+ }
+
+ // rpm
+ if (__is_rpm_pkg(filename) == 0) {
+ _LOGD("%s is rpm", filename);
+ return strdup("rpm");
+ }
+
+ uf = unzOpen(filename);
+ retvm_if(uf == NULL, NULL, "unzOpen[%s] fail", filename);
+
+
+ //hybrid for web-core
+ if ((unzLocateFile(uf, HYBRID_XML_FILE, 0) == 0) && (unzLocateFile(uf, CORE_XML_FILE, 0) == 0)) {
+ _LOGD("%s is hybrid[web-core]", filename);
+ pkg_type = strdup("wgt");
+
+ //hybrid for web-tpk
+ } else if ((unzLocateFile(uf, HYBRID_XML_FILE, 0) == 0) && (unzLocateFile(uf, TPK_XML_FILE, 0) == 0)) {
+ _LOGD("%s is hybrid[web-tpk]", filename);
+ pkg_type = strdup("wgt");
+
+ //core
+ } else if (unzLocateFile(uf, CORE_XML_FILE, 0) == 0) {
+ _LOGD("%s is core", filename);
+ pkg_type = strdup("coretpk");
+
+ //wgt
+ } else if (unzLocateFile(uf, WGT_XML_FILE, 0) == 0) {
+ _LOGD("%s is wgt", filename);
+ pkg_type = strdup("wgt");
+
+ //tpk
+ } else if (unzLocateFile(uf, TPK_XML_FILE, 0) == 0) {
+ _LOGD("%s is tpk", filename);
+ pkg_type = strdup("tpk");
+
+ //error case
+ } else {
+ _LOGD("%s is not supported", filename);
+ }
+
+ if (uf) {
+ unzCloseCurrentFile(uf);
+ unzClose(uf);
+ }
+
+ return pkg_type;
+}
#include <string.h>
#include <unistd.h>
#include <dlfcn.h>
+#include <dirent.h>
+#include <fcntl.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <dbus/dbus.h>
#include <dbus/dbus-glib-lowlevel.h>
-#include <ail.h>
-#include <aul.h>
#include <vconf.h>
#include <db-util.h>
+#include <pkgmgr-info.h>
+#include <iniparser.h>
+#include <security-server.h>
+#include <sys/xattr.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#include "package-manager.h"
-#include "pkgmgr-internal.h"
-#include "pkgmgr-info.h"
-#include "pkgmgr-api.h"
+#include "package-manager-debug.h"
+#include "package-manager-internal.h"
#include "comm_client.h"
-#include "pkgmgr_parser.h"
#include "comm_status_broadcast_server.h"
+#include "junk-manager.h"
+#include "pkgmgr_parser.h"
-#define MANIFEST_DB "/opt/dbspace/.pkgmgr_parser.db"
-#define MAX_QUERY_LEN 4096
+#undef LOG_TAG
+#ifndef LOG_TAG
+#define LOG_TAG "PKGMGR"
+#endif /* LOG_TAG */
+
+#define BINSH_NAME "/bin/sh"
+#define BINSH_SIZE 7
+#define MAX_STMT_SIZE 512
+#define MAX_FILENAME_SIZE 256
+
+#define PKG_INFO_DB_LABEL "pkgmgr::db"
+#define PKG_PARSER_DB_FILE "/opt/dbspace/.pkgmgr_parser.db"
+#define PKG_PARSER_DB_FILE_JOURNAL "/opt/dbspace/.pkgmgr_parser.db-journal"
+
+#define FACTORY_RESET_BACKUP_FILE "/usr/system/RestoreDir/opt.zip"
+#define OPT_USR_APPS "/opt/usr/apps"
+#define SOFT_RESET_PATH "/usr/etc/package-manager/soft-reset"
+#define PKGMGR_FOTA_PATH "/opt/usr/data/pkgmgr/fota/"
+#define PKG_DISABLED_LIST_FILE PKGMGR_FOTA_PATH"pkg_disabled_list.txt"
+
+#define TOKEN_PATH_STR "path="
+#define SEPERATOR_END ':'
+
+#define OPT_USR_MEDIA "/opt/usr/media"
+#define SOFT_RESET_TEST_FLAG OPT_USR_MEDIA"/.soft_reset_test"
+FILE *logfile = NULL;
+
+#define _LOGF(fmt, arg...) do { \
+ _LOGE(fmt, ##arg);\
+ if (logfile != NULL) {\
+ fprintf(logfile, ""fmt"", ##arg); \
+ fflush(logfile);\
+ }\
+} while (0)
static int _get_request_id()
{
+ int pid = 0;
static int internal_req_id = 1;
- return internal_req_id++;
+ internal_req_id++;
+ pid = getpid();
+
+ pid = pid * 10000 + internal_req_id;
+
+ return pid;
}
typedef struct _req_cb_info {
typedef struct _pkgmgr_client_t {
client_type ctype;
+ int status_type;
union {
struct _request {
comm_client *cc;
DBusConnection *bc;
} broadcast;
} info;
+ void* new_event_cb;
+ void* extension;
} pkgmgr_client_t;
typedef struct _iter_data {
void *data;
} iter_data;
-typedef struct _pkgmgr_pkginfo_x {
- int pkg_handle_id;
- manifest_x *manifest_info;
-} pkgmgr_pkginfo_x;
-
-typedef struct _pkgmgr_appinfo_x {
- int app_handle_id;
- char *app_component;
- uiapplication_x *uiapp_info;
- serviceapplication_x *svcapp_info;
-} pkgmgr_appinfo_x;
-
-char *pkgtype = "rpm";
-sqlite3 *manifest_db = NULL;
-
-static int __open_manifest_db();
-static int __exec_pkginfo_query(char *query, void *data);
-static int __exec_appinfo_query(char *query, void *data);
-static int __pkginfo_cb(void *data, int ncols, char **coltxt, char **colname);
-static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname);
-static int __validate_cb(void *data, int ncols, char **coltxt, char **colname);
-static int __uiapp_list_cb(void *data, int ncols, char **coltxt, char **colname);
-static int __svcapp_list_cb(void *data, int ncols, char **coltxt, char **colname);
-static int __pkg_list_cb(void *data, int ncols, char **coltxt, char **colname);
-static int __pkgmgr_appinfo_new_handle_id();
-static int __pkgmgr_pkginfo_new_handle_id();
-static void __cleanup_pkginfo(pkgmgr_pkginfo_x *data);
-static void __cleanup_appinfo(pkgmgr_appinfo_x *data);
-static char* __convert_system_locale_to_manifest_locale(char *syslocale);
-
-static int __pkgmgr_pkginfo_new_handle_id()
-{
- static int pkginfo_handle_id = 0;
- return pkginfo_handle_id++;
-}
+typedef struct {
+ pkgmgr_client *pc;
+ void *junk_tb;
+ char *db_path;
+} junkmgr_s;
-static int __pkgmgr_appinfo_new_handle_id()
-{
- static int appinfo_handle_id = 0;
- return appinfo_handle_id++;
-}
+typedef struct {
+ void *db;
+ void *db_stmt;
+} junkmgr_result_s;
-static char* __convert_system_locale_to_manifest_locale(char *syslocale)
+typedef struct
{
- if (syslocale == NULL)
- return strdup(DEFAULT_LOCALE);
- char *locale = NULL;
- locale = (char *)calloc(1, 6);
- if (!locale) {
- _LOGE("Malloc Failed\n");
- return NULL;
- }
- strncpy(locale, syslocale, 2);
- strncat(locale, "-", 1);
- locale[3] = syslocale[3] + 32;
- locale[4] = syslocale[4] + 32;
- return locale;
-}
+ int junk_req_type; //0: API for getting root junk dir, 1: API for getting junk files, 2: API for clearing all junk files
+ int junk_storage; //0: internal, 1: external, 2: all
+ char *junk_root; //root junk dir name
+} junkmgr_info_s;
-static void __cleanup_pkginfo(pkgmgr_pkginfo_x *data)
+static char *__get_cookie_from_security_server(void)
{
- if (data == NULL)
- return;
- pkgmgr_parser_free_manifest_xml(data->manifest_info);
- free((void *)data);
- data = NULL;
- return;
-}
+ int ret = 0;
+ size_t cookie_size = 0;
+ char *e_cookie = NULL;
-static void __cleanup_appinfo(pkgmgr_appinfo_x *data)
-{
- if (data == NULL)
- return;
- if (data->app_component) {
- free((void *)data->app_component);
- data->app_component = NULL;
- }
- manifest_x *mfx = calloc(1, sizeof(manifest_x));
- mfx->uiapplication = data->uiapp_info;
- mfx->serviceapplication = data->svcapp_info;
- pkgmgr_parser_free_manifest_xml(mfx);
- free((void *)data);
- data = NULL;
- return;
-}
+ //calculage cookie size
+ cookie_size = security_server_get_cookie_size();
+ retvm_if(cookie_size <= 0, NULL, "security_server_get_cookie_size : cookie_size is %d", cookie_size);
-static int __open_manifest_db()
-{
- int ret = -1;
- if (access(MANIFEST_DB, F_OK) == 0) {
- ret =
- db_util_open_with_options(MANIFEST_DB, &manifest_db,
- SQLITE_OPEN_READONLY, NULL);
- if (ret != SQLITE_OK) {
- _LOGE("connect db [%s] failed!\n", MANIFEST_DB);
- return -1;
- }
- return 0;
- }
- _LOGE("Manifest DB does not exists !!\n");
- return -1;
-}
+ //get cookie from security server
+ char cookie[cookie_size];
+ cookie[0] = '\0';
+ ret = security_server_request_cookie(cookie, cookie_size);
+ retvm_if(ret < 0, NULL, "security_server_request_cookie fail (%d)", ret);
-static int __pkg_list_cb(void *data, int ncols, char **coltxt, char **colname)
-{
- char *pkg_name = NULL;
- char *pkg_type = NULL;
- char *pkg_version = NULL;
- int i = 0;
- iter_data *udata = (iter_data *)data;
- for(i = 0; i < ncols; i++)
- {
- if (strcmp(colname[i], "package") == 0) {
- if (coltxt[i])
- pkg_name = strdup(coltxt[i]);
- } else if (strcmp(colname[i], "package_type") == 0) {
- if (coltxt[i])
- pkg_type = strdup(coltxt[i]);
- } else if (strcmp(colname[i], "package_version") == 0 ){
- if (coltxt[i])
- pkg_version = strdup(coltxt[i]);
- } else
- continue;
- }
- udata->iter_fn(pkg_type, pkg_name, pkg_version, udata->data);
- if (pkg_name) {
- free(pkg_name);
- pkg_name = NULL;
- }
- if (pkg_type) {
- free(pkg_type);
- pkg_type = NULL;
- }
- if (pkg_version) {
- free(pkg_version);
- pkg_version = NULL;
- }
- return 0;
-}
+ //encode cookie
+ e_cookie = g_base64_encode((const guchar *)cookie, cookie_size);
+ retvm_if(e_cookie == NULL, NULL, "g_base64_encode e_cookie is NULL");
-static int __uiapp_list_cb(void *data, int ncols, char **coltxt, char **colname)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
- int i = 0;
- uiapplication_x *uiapp = NULL;
- uiapp = calloc(1, sizeof(uiapplication_x));
- LISTADD(info->manifest_info->uiapplication, uiapp);
- for(i = 0; i < ncols; i++)
- {
- if (strcmp(colname[i], "app_id") == 0) {
- if (coltxt[i])
- info->manifest_info->uiapplication->appid = strdup(coltxt[i]);
- else
- info->manifest_info->uiapplication->appid = NULL;
- } else if (strcmp(colname[i], "app_exec") == 0) {
- if (coltxt[i])
- info->manifest_info->uiapplication->exec = strdup(coltxt[i]);
- else
- info->manifest_info->uiapplication->exec = NULL;
- } else if (strcmp(colname[i], "app_type") == 0 ){
- if (coltxt[i])
- info->manifest_info->uiapplication->type = strdup(coltxt[i]);
- else
- info->manifest_info->uiapplication->type = NULL;
- } else if (strcmp(colname[i], "app_nodisplay") == 0 ){
- if (coltxt[i])
- info->manifest_info->uiapplication->nodisplay = strdup(coltxt[i]);
- else
- info->manifest_info->uiapplication->nodisplay = NULL;
- } else if (strcmp(colname[i], "app_multiple") == 0 ){
- if (coltxt[i])
- info->manifest_info->uiapplication->multiple = strdup(coltxt[i]);
- else
- info->manifest_info->uiapplication->multiple = NULL;
- } else if (strcmp(colname[i], "app_taskmanage") == 0 ){
- if (coltxt[i])
- info->manifest_info->uiapplication->taskmanage = strdup(coltxt[i]);
- else
- info->manifest_info->uiapplication->taskmanage = NULL;
- } else
- continue;
- }
- return 0;
+ return e_cookie;
}
-static int __svcapp_list_cb(void *data, int ncols, char **coltxt, char **colname)
+static int __xsystem(const char *argv[])
{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
- int i = 0;
- serviceapplication_x *svcapp = NULL;
- svcapp = calloc(1, sizeof(serviceapplication_x));
- LISTADD(info->manifest_info->serviceapplication, svcapp);
- for(i = 0; i < ncols; i++)
- {
- if (strcmp(colname[i], "app_id") == 0) {
- if (coltxt[i])
- info->manifest_info->serviceapplication->appid = strdup(coltxt[i]);
- else
- info->manifest_info->serviceapplication->appid = NULL;
- } else if (strcmp(colname[i], "app_exec") == 0) {
- if (coltxt[i])
- info->manifest_info->serviceapplication->exec = strdup(coltxt[i]);
- else
- info->manifest_info->serviceapplication->exec = NULL;
- } else if (strcmp(colname[i], "app_type") == 0 ){
- if (coltxt[i])
- info->manifest_info->serviceapplication->type = strdup(coltxt[i]);
- else
- info->manifest_info->serviceapplication->type = NULL;
- } else if (strcmp(colname[i], "app_onboot") == 0 ){
- if (coltxt[i])
- info->manifest_info->serviceapplication->onboot = strdup(coltxt[i]);
- else
- info->manifest_info->serviceapplication->onboot = NULL;
- } else if (strcmp(colname[i], "app_autorestart") == 0 ){
- if (coltxt[i])
- info->manifest_info->serviceapplication->autorestart = strdup(coltxt[i]);
- else
- info->manifest_info->serviceapplication->autorestart = NULL;
- } else
- continue;
+ int status = 0;
+ pid_t pid;
+ pid = fork();
+ switch (pid) {
+ case -1:
+ perror("fork failed");
+ return -1;
+ case 0:
+ /* child */
+ execvp(argv[0], (char *const *)argv);
+ _exit(-1);
+ default:
+ /* parent */
+ break;
}
- return 0;
-}
-
-static int __validate_cb(void *data, int ncols, char **coltxt, char **colname)
-{
- int *p = (int*)data;
- *p = atoi(coltxt[0]);
- _LOGE("exist value is %d\n", *p);
- return 0;
-}
-
-static int __pkginfo_cb(void *data, int ncols, char **coltxt, char **colname)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
- int i = 0;
- author_x *author = NULL;
- icon_x *icon = NULL;
- label_x *label = NULL;
- description_x *description = NULL;
-
- author = calloc(1, sizeof(author_x));
- LISTADD(info->manifest_info->author, author);
- icon = calloc(1, sizeof(icon_x));
- LISTADD(info->manifest_info->icon, icon);
- label = calloc(1, sizeof(label_x));
- LISTADD(info->manifest_info->label, label);
- description = calloc(1, sizeof(description_x));
- LISTADD(info->manifest_info->description, description);
- for(i = 0; i < ncols; i++)
- {
- if (strcmp(colname[i], "package_version") == 0) {
- if (coltxt[i])
- info->manifest_info->version = strdup(coltxt[i]);
- else
- info->manifest_info->version = NULL;
- } else if (strcmp(colname[i], "package_type") == 0) {
- if (coltxt[i])
- info->manifest_info->type = strdup(coltxt[i]);
- else
- info->manifest_info->type = NULL;
- } else if (strcmp(colname[i], "install_location") == 0) {
- if (coltxt[i])
- info->manifest_info->installlocation = strdup(coltxt[i]);
- else
- info->manifest_info->installlocation = NULL;
- } else if (strcmp(colname[i], "author_email") == 0 ){
- if (coltxt[i])
- info->manifest_info->author->email = strdup(coltxt[i]);
- else
- info->manifest_info->author->email = NULL;
- } else if (strcmp(colname[i], "author_href") == 0 ){
- if (coltxt[i])
- info->manifest_info->author->href = strdup(coltxt[i]);
- else
- info->manifest_info->author->href = NULL;
- } else if (strcmp(colname[i], "package_label") == 0 ){
- if (coltxt[i])
- info->manifest_info->label->text = strdup(coltxt[i]);
- else
- info->manifest_info->label->text = NULL;
- } else if (strcmp(colname[i], "package_icon") == 0 ){
- if (coltxt[i])
- info->manifest_info->icon->name = strdup(coltxt[i]);
- else
- info->manifest_info->icon->name = NULL;
- } else if (strcmp(colname[i], "package_description") == 0 ){
- if (coltxt[i])
- info->manifest_info->description->text = strdup(coltxt[i]);
- else
- info->manifest_info->description->text = NULL;
- } else if (strcmp(colname[i], "package_author") == 0 ){
- if (coltxt[i])
- info->manifest_info->author->text = strdup(coltxt[i]);
- else
- info->manifest_info->author->text = NULL;
- } else if (strcmp(colname[i], "package_removable") == 0 ){
- if (coltxt[i])
- info->manifest_info->removable = strdup(coltxt[i]);
- else
- info->manifest_info->removable = NULL;
- } else if (strcmp(colname[i], "package_preload") == 0 ){
- if (coltxt[i])
- info->manifest_info->preload = strdup(coltxt[i]);
- else
- info->manifest_info->preload = NULL;
- } else if (strcmp(colname[i], "package_readonly") == 0 ){
- if (coltxt[i])
- info->manifest_info->readonly = strdup(coltxt[i]);
- else
- info->manifest_info->readonly = NULL;
- } else if (strcmp(colname[i], "package_locale") == 0 ){
- if (coltxt[i]) {
- info->manifest_info->author->lang = strdup(coltxt[i]);
- info->manifest_info->icon->lang = strdup(coltxt[i]);
- info->manifest_info->label->lang = strdup(coltxt[i]);
- info->manifest_info->description->lang = strdup(coltxt[i]);
- }
- else {
- info->manifest_info->author->lang = NULL;
- info->manifest_info->icon->lang = NULL;
- info->manifest_info->label->lang = NULL;
- info->manifest_info->description->lang = NULL;
- }
- } else
- continue;
+ if (waitpid(pid, &status, 0) == -1) {
+ perror("waitpid failed");
+ return -1;
}
- return 0;
-}
-
-static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname)
-{
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)data;
- int i = 0;
- for(i = 0; i < ncols; i++)
- {
- if (strcmp(colname[i], "app_exec") == 0) {
- if (coltxt[i])
- info->uiapp_info->exec = strdup(coltxt[i]);
- else
- info->uiapp_info->exec = NULL;
- } else if (strcmp(colname[i], "app_component") == 0) {
- if (coltxt[i])
- info->app_component = strdup(coltxt[i]);
- else
- info->app_component = NULL;
- } else if (strcmp(colname[i], "app_nodisplay") == 0) {
- if (coltxt[i])
- info->uiapp_info->nodisplay = strdup(coltxt[i]);
- else
- info->uiapp_info->nodisplay = NULL;
- } else if (strcmp(colname[i], "app_type") == 0 ){
- if (coltxt[i])
- info->uiapp_info->type = strdup(coltxt[i]);
- else
- info->uiapp_info->type = NULL;
- } else if (strcmp(colname[i], "app_multiple") == 0 ){
- if (coltxt[i])
- info->uiapp_info->multiple = strdup(coltxt[i]);
- else
- info->uiapp_info->multiple = NULL;
- } else if (strcmp(colname[i], "app_onboot") == 0 ){
- if (coltxt[i])
- info->svcapp_info->onboot = strdup(coltxt[i]);
- else
- info->svcapp_info->onboot = NULL;
- } else if (strcmp(colname[i], "app_autorestart") == 0 ){
- if (coltxt[i])
- info->svcapp_info->autorestart = strdup(coltxt[i]);
- else
- info->svcapp_info->autorestart = NULL;
- } else if (strcmp(colname[i], "app_taskmanage") == 0 ){
- if (coltxt[i])
- info->uiapp_info->taskmanage = strdup(coltxt[i]);
- else
- info->uiapp_info->taskmanage = NULL;
- } else
- continue;
+ if (WIFSIGNALED(status)) {
+ perror("signal");
+ return -1;
}
- return 0;
-}
-
-static int __exec_pkginfo_query(char *query, void *data)
-{
- char *error_message = NULL;
- if (SQLITE_OK !=
- sqlite3_exec(manifest_db, query, __pkginfo_cb, data, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
+ if (!WIFEXITED(status)) {
+ /* shouldn't happen */
+ perror("should not happen");
return -1;
}
- sqlite3_free(error_message);
- return 0;
+ return WEXITSTATUS(status);
}
-static int __exec_appinfo_query(char *query, void *data)
+static void __error_to_string(int errnumber, char **errstr)
{
- char *error_message = NULL;
- if (SQLITE_OK !=
- sqlite3_exec(manifest_db, query, __appinfo_cb, data, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- return -1;
+ if (errstr == NULL)
+ return;
+ switch (errnumber) {
+ case PKGCMD_ERR_PACKAGE_NOT_FOUND:
+ *errstr = PKGCMD_ERR_PACKAGE_NOT_FOUND_STR;
+ break;
+ case PKGCMD_ERR_PACKAGE_INVALID:
+ *errstr = PKGCMD_ERR_PACKAGE_INVALID_STR;
+ break;
+ case PKGCMD_ERR_PACKAGE_LOWER_VERSION:
+ *errstr = PKGCMD_ERR_PACKAGE_LOWER_VERSION_STR;
+ break;
+ case PKGCMD_ERR_PACKAGE_EXECUTABLE_NOT_FOUND:
+ *errstr = PKGCMD_ERR_PACKAGE_EXECUTABLE_NOT_FOUND_STR;
+ break;
+ case PKGCMD_ERR_MANIFEST_INVALID:
+ *errstr = PKGCMD_ERR_MANIFEST_INVALID_STR;
+ break;
+ case PKGCMD_ERR_CONFIG_NOT_FOUND:
+ *errstr = PKGCMD_ERR_CONFIG_NOT_FOUND_STR;
+ break;
+ case PKGCMD_ERR_CONFIG_INVALID:
+ *errstr = PKGCMD_ERR_CONFIG_INVALID_STR;
+ break;
+ case PKGCMD_ERR_SIGNATURE_NOT_FOUND:
+ *errstr = PKGCMD_ERR_SIGNATURE_NOT_FOUND_STR;
+ break;
+ case PKGCMD_ERR_SIGNATURE_INVALID:
+ *errstr = PKGCMD_ERR_SIGNATURE_INVALID_STR;
+ break;
+ case PKGCMD_ERR_SIGNATURE_VERIFICATION_FAILED:
+ *errstr = PKGCMD_ERR_SIGNATURE_VERIFICATION_FAILED_STR;
+ break;
+ case PKGCMD_ERR_ROOT_CERTIFICATE_NOT_FOUND:
+ *errstr = PKGCMD_ERR_ROOT_CERTIFICATE_NOT_FOUND_STR;
+ break;
+ case PKGCMD_ERR_CERTIFICATE_INVALID:
+ *errstr = PKGCMD_ERR_CERTIFICATE_INVALID_STR;
+ break;
+ case PKGCMD_ERR_CERTIFICATE_CHAIN_VERIFICATION_FAILED:
+ *errstr = PKGCMD_ERR_CERTIFICATE_CHAIN_VERIFICATION_FAILED_STR;
+ break;
+ case PKGCMD_ERR_CERTIFICATE_EXPIRED:
+ *errstr = PKGCMD_ERR_CERTIFICATE_EXPIRED_STR;
+ break;
+ case PKGCMD_ERR_INVALID_PRIVILEGE:
+ *errstr = PKGCMD_ERR_INVALID_PRIVILEGE_STR;
+ break;
+ case PKGCMD_ERR_MENU_ICON_NOT_FOUND:
+ *errstr = PKGCMD_ERR_MENU_ICON_NOT_FOUND_STR;
+ break;
+ case PKGCMD_ERR_FATAL_ERROR:
+ *errstr = PKGCMD_ERR_FATAL_ERROR_STR;
+ break;
+ case PKGCMD_ERR_OUT_OF_STORAGE:
+ *errstr = PKGCMD_ERR_OUT_OF_STORAGE_STR;
+ break;
+ case PKGCMD_ERR_OUT_OF_MEMORY:
+ *errstr = PKGCMD_ERR_OUT_OF_MEMORY_STR;
+ break;
+ case PKGCMD_ERR_ARGUMENT_INVALID:
+ *errstr = PKGCMD_ERR_ARGUMENT_INVALID_STR;
+ break;
+ default:
+ *errstr = PKGCMD_ERR_UNKNOWN_STR;
+ break;
}
- sqlite3_free(error_message);
- return 0;
}
-static void __add_op_cbinfo(pkgmgr_client_t * pc, int request_id,
- const char *req_key, pkgmgr_handler event_cb,
- void *data)
+static void __add_op_cbinfo(pkgmgr_client_t *pc, int request_id,
+ const char *req_key, pkgmgr_handler event_cb, void* new_event_cb,
+ void *data)
{
req_cb_info *cb_info;
req_cb_info *current;
cb_info->event_cb = event_cb;
cb_info->data = data;
cb_info->next = NULL;
+ pc->new_event_cb = new_event_cb;
if (pc->info.request.rhead == NULL)
pc->info.request.rhead = cb_info;
}
}
-static listen_cb_info *__find_stat_cbinfo(pkgmgr_client_t *pc, int request_id)
-{
- listen_cb_info *tmp;
-
- tmp = pc->info.listening.lhead;
-
- _LOGD("tmp->request_id %d, request_id %d", tmp->request_id, request_id);
-
- while (tmp) {
- if (tmp->request_id == request_id)
- return tmp;
- tmp = tmp->next;
- }
- return NULL;
-}
-
-static void __remove_stat_cbinfo(pkgmgr_client_t *pc, listen_cb_info *info)
-{
- listen_cb_info *tmp;
-
- if (pc == NULL || pc->info.listening.lhead == NULL || info == NULL)
- return;
-
- tmp = pc->info.listening.lhead;
- while (tmp) {
- if (tmp->next == info) {
- tmp->next = info->next;
- free(info);
- return;
- }
- tmp = tmp->next;
- }
-}
-
static void __operation_callback(void *cb_data, const char *req_id,
- const char *pkg_type, const char *pkg_name,
+ const char *pkg_type, const char *pkgid,
const char *key, const char *val)
{
pkgmgr_client_t *pc;
req_cb_info *cb_info;
- _LOGD("__operation_callback() req_id[%s] pkg_type[%s] pkg_name[%s]"
- "key[%s] val[%s]\n", req_id, pkg_type, pkg_name, key, val);
+ SECURE_LOGD("__operation_callback() req_id[%s] pkg_type[%s] pkgid[%s]"
+ "key[%s] val[%s]\n", req_id, pkg_type, pkgid, key, val);
pc = (pkgmgr_client_t *) cb_data;
/* call callback */
if (cb_info->event_cb) {
- cb_info->event_cb(cb_info->request_id, pkg_type, pkg_name, key,
- val, NULL, cb_info->data);
+ if (pc->new_event_cb)
+ {
+ cb_info->event_cb(cb_info->request_id, pkg_type, pkgid, key,
+ val, pc, cb_info->data);
+ }
+ else
+ {
+ cb_info->event_cb(cb_info->request_id, pkg_type, pkgid, key,
+ val, NULL, cb_info->data);
+ }
_LOGD("event_cb is called");
}
- /*remove callback for last call
+ /*remove callback for last call
if (strcmp(key, "end") == 0) {
__remove_op_cbinfo(pc, cb_info);
_LOGD("__remove_op_cbinfo");
}
static void __status_callback(void *cb_data, const char *req_id,
- const char *pkg_type, const char *pkg_name,
+ const char *pkg_type, const char *pkgid,
const char *key, const char *val)
{
pkgmgr_client_t *pc;
listen_cb_info *tmp;
- _LOGD("__status_callback() req_id[%s] pkg_type[%s] pkg_name[%s]"
- "key[%s] val[%s]\n", req_id, pkg_type, pkg_name, key, val);
+ SECURE_LOGD("__status_callback() req_id[%s] pkg_type[%s] pkgid[%s]"
+ "key[%s] val[%s]\n", req_id, pkg_type, pkgid, key, val);
pc = (pkgmgr_client_t *) cb_data;
tmp = pc->info.listening.lhead;
while (tmp) {
- if (tmp->event_cb(tmp->request_id, pkg_type, pkg_name, key, val,
+ if (tmp->event_cb(tmp->request_id, pkg_type, pkgid, key, val,
NULL, tmp->data) != 0)
break;
tmp = tmp->next;
return;
}
-API pkgmgr_client *pkgmgr_client_new(client_type ctype)
+static char *__get_str(const char* str, const char* pKey)
{
- pkgmgr_client_t *pc = NULL;
- int ret = -1;
+ const char* p = NULL;
+ const char* pStart = NULL;
+ const char* pEnd = NULL;
- if (ctype != PC_REQUEST && ctype != PC_LISTENING
- && ctype != PC_BROADCAST)
+ if (str == NULL)
return NULL;
- /* Allocate memory for ADT:pkgmgr_client */
- pc = calloc(1, sizeof(pkgmgr_client_t));
- if (pc == NULL) {
- _LOGE("No memory");
+ char *pBuf = strdup(str);
+ if(!pBuf){
+ _LOGE("Malloc failed!");
return NULL;
}
- /* Manage pc */
- pc->ctype = ctype;
-
- if (pc->ctype == PC_REQUEST) {
- pc->info.request.cc = comm_client_new();
- if (pc->info.request.cc == NULL) {
- _LOGE("client creation failed");
- goto err;
- }
- ret = comm_client_set_status_callback(pc->info.request.cc,
- __operation_callback, pc);
- if (ret < 0) {
- _LOGE("comm_client_set_status_callback() failed - %d",
- ret);
- goto err;
- }
- } else if (pc->ctype == PC_LISTENING) {
- pc->info.listening.cc = comm_client_new();
- if (pc->info.listening.cc == NULL) {
- _LOGE("client creation failed");
- goto err;
- }
- ret = comm_client_set_status_callback(pc->info.request.cc,
- __status_callback, pc);
- if (ret < 0) {
- _LOGE("comm_client_set_status_callback() failed - %d",
- ret);
- goto err;
- }
- } else if (pc->ctype == PC_BROADCAST) {
- pc->info.broadcast.bc = comm_status_broadcast_server_connect();
- if (pc->info.broadcast.bc == NULL) {
- _LOGE("client creation failed");
- goto err;
+ p = strstr(pBuf, pKey);
+ if (p == NULL){
+ if(pBuf){
+ free(pBuf);
+ pBuf = NULL;
}
- ret = 0;
- }
-
- return (pkgmgr_client *) pc;
-
- err:
- if (pc)
- free(pc);
- return NULL;
-}
-
-API int pkgmgr_client_free(pkgmgr_client *pc)
-{
- int ret = -1;
- pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
-
- if (mpc == NULL) {
- _LOGE("Invalid argument");
- return PKGMGR_R_EINVAL;
+ return NULL;
}
- if (mpc->ctype == PC_REQUEST) {
- req_cb_info *tmp;
- req_cb_info *prev;
- for (tmp = mpc->info.request.rhead; tmp;) {
- prev = tmp;
- tmp = tmp->next;
- free(prev);
- }
-
- ret = comm_client_free(mpc->info.request.cc);
- if (ret < 0) {
- _LOGE("comm_client_free() failed - %d", ret);
- goto err;
+ pStart = p + strlen(pKey);
+ pEnd = strchr(pStart, SEPERATOR_END);
+ if (pEnd == NULL){
+ if(pBuf){
+ free(pBuf);
+ pBuf = NULL;
}
- } else if (mpc->ctype == PC_LISTENING) {
- listen_cb_info *tmp;
- listen_cb_info *prev;
- for (tmp = mpc->info.listening.lhead; tmp;) {
- prev = tmp;
- tmp = tmp->next;
- free(prev);
+ return NULL;
+ }
+ size_t len = pEnd - pStart;
+ if (len <= 0){
+ if(pBuf){
+ free(pBuf);
+ pBuf = NULL;
}
-
- ret = comm_client_free(mpc->info.listening.cc);
- if (ret < 0) {
- _LOGE("comm_client_free() failed - %d", ret);
- goto err;
+ return NULL;
+ }
+ char *pRes = (char*)malloc(len + 1);
+ if(!pRes){
+ if(pBuf){
+ free(pBuf);
+ pBuf = NULL;
}
- } else if (mpc->ctype == PC_BROADCAST) {
- comm_status_broadcast_server_disconnect(mpc->info.broadcast.bc);
- ret = 0;
- } else {
- _LOGE("Invalid client type\n");
- return PKGMGR_R_EINVAL;
+ _LOGE("Malloc failed!");
+ return NULL;
}
+ strncpy(pRes, pStart, len);
+ pRes[len] = 0;
- free(mpc);
- mpc = NULL;
- return PKGMGR_R_OK;
-
- err:
- if (mpc) {
- free(mpc);
- mpc = NULL;
+ if(pBuf){
+ free(pBuf);
+ pBuf = NULL;
}
- return PKGMGR_R_ERROR;
+
+ return pRes;
}
static char *__get_req_key(const char *pkg_path)
return str_req_key;
}
-static char *__get_type_from_path(const char *pkg_path)
+static int __get_pkgid_by_appid(const char *appid, char **pkgid)
{
- int ret;
- char mimetype[255] = { '\0', };
- char extlist[256] = { '\0', };
- char *pkg_type;
-
- ret = aul_get_mime_from_file(pkg_path, mimetype, sizeof(mimetype));
- if (ret) {
- _LOGE("aul_get_mime_from_file() failed - error code[%d]\n",
- ret);
- return NULL;
- }
+ pkgmgrinfo_appinfo_h appinfo_h = NULL;
+ int ret = -1;
+ char *pkg_id = NULL;
+ char *pkg_id_dup = NULL;
- ret = aul_get_mime_extension(mimetype, extlist, sizeof(extlist));
- if (ret) {
- _LOGE("aul_get_mime_extension() failed - error code[%d]\n",
- ret);
- return NULL;
- }
+ if (pkgmgrinfo_appinfo_get_appinfo(appid, &appinfo_h) != PMINFO_R_OK)
+ return -1;
- if (strlen(extlist) == 0)
- return NULL;
+ if (pkgmgrinfo_appinfo_get_pkgid(appinfo_h, &pkg_id) != PMINFO_R_OK)
+ goto err;
- if (strchr(extlist, ',')) {
- extlist[strlen(extlist) - strlen(strchr(extlist, ','))] = '\0';
- }
- pkg_type = strchr(extlist, '.') + 1;
- return strdup(pkg_type);
+ pkg_id_dup = strdup(pkg_id);
+ if (pkg_id_dup == NULL)
+ goto err;
+
+ *pkgid = pkg_id_dup;
+ ret = PMINFO_R_OK;
+
+err:
+ pkgmgrinfo_appinfo_destroy_appinfo(appinfo_h);
+
+ return ret;
}
-API int pkgmgr_client_install(pkgmgr_client * pc, const char *pkg_type,
- const char *descriptor_path, const char *pkg_path,
- const char *optional_file, pkgmgr_mode mode,
- pkgmgr_handler event_cb, void *data)
+int __appinfo_cb(pkgmgrinfo_appinfo_h handle, void *user_data)
{
- char *pkgtype;
- char *installer_path;
- char *req_key;
- int req_id;
- int i = 0;
- char *argv[PKG_ARGC_MAX] = { NULL, };
- char *args = NULL;
- int argcnt = 0;
- int len = 0;
- char *temp = NULL;
- int ret;
- char *cookie = NULL;
+ int ret = 0;
+ char *appid = NULL;
- /* Check for NULL value of pc */
- if (pc == NULL) {
- _LOGD("package manager client handle is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+ ret = pkgmgrinfo_appinfo_get_appid(handle, &appid);
+ retvm_if(ret != PMINFO_R_OK, PKGMGR_R_ERROR, "pkgmgrinfo_appinfo_get_appid fail");
- /* 0. check the pc type */
- if (mpc->ctype != PC_REQUEST)
- return PKGMGR_R_EINVAL;
+ (* (char **) user_data) = strdup(appid);
- /* 1. check argument */
- if (descriptor_path) {
- if (strlen(descriptor_path) >= PKG_STRING_LEN_MAX)
- return PKGMGR_R_EINVAL;
+ return PMINFO_R_OK;
+}
- if (access(descriptor_path, F_OK) != 0)
- return PKGMGR_R_EINVAL;
- }
+static char *__get_app_info_from_db_by_apppath(const char *apppath)
+{
+ int ret = 0;
+ char *caller_appid = NULL;
+ pkgmgrinfo_appinfo_filter_h appinfo_filter_h= NULL;
- if (pkg_path == NULL)
- return PKGMGR_R_EINVAL;
- else {
- if (strlen(pkg_path) >= PKG_STRING_LEN_MAX)
- return PKGMGR_R_EINVAL;
+ ret = pkgmgrinfo_appinfo_filter_create(&appinfo_filter_h);
+ retvm_if(ret != PMINFO_R_OK, NULL, "pkgmgrinfo_appinfo_filter_create fail");
- if (access(pkg_path, F_OK) != 0)
- return PKGMGR_R_EINVAL;
- }
+ ret = pkgmgrinfo_appinfo_filter_add_string(appinfo_filter_h, PMINFO_APPINFO_PROP_APP_EXEC, apppath);
+ tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "PMINFO_APPINFO_PROP_APP_EXEC failed, ret=%d", ret);
- if (optional_file) {
- if (strlen(optional_file) >= PKG_STRING_LEN_MAX)
- return PKGMGR_R_EINVAL;
+ ret = pkgmgrinfo_appinfo_filter_foreach_appinfo(appinfo_filter_h, __appinfo_cb, &caller_appid);
+ tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "foreach_appinfo failed, ret=%d", ret);
- if (access(optional_file, F_OK) != 0)
- return PKGMGR_R_EINVAL;
- }
+catch:
- /* 2. get installer path using pkg_path */
- if (pkg_type) {
- installer_path = _get_backend_path_with_type(pkg_type);
- pkgtype = strdup(pkg_type);
- } else {
- installer_path = _get_backend_path(pkg_path);
- pkgtype = __get_type_from_path(pkg_path);
- }
+ pkgmgrinfo_appinfo_filter_destroy(appinfo_filter_h);
+ return caller_appid;
+}
- if (installer_path == NULL) {
- free(pkgtype);
- return PKGMGR_R_EINVAL;
- }
+static inline int __read_proc(const char *path, char *buf, int size)
+{
+ int fd = 0;
+ int ret = 0;
- /* 3. generate req_key */
- req_key = __get_req_key(pkg_path);
+ if (buf == NULL || path == NULL)
+ return -1;
- /* 4. add callback info - add callback info to pkgmgr_client */
- req_id = _get_request_id();
- __add_op_cbinfo(mpc, req_id, req_key, event_cb, data);
+ fd = open(path, O_RDONLY);
+ if (fd < 0)
+ return -1;
- /* 5. generate argv */
+ ret = read(fd, buf, size - 1);
+ if (ret <= 0) {
+ close(fd);
+ return -1;
+ } else
+ buf[ret] = 0;
- /* argv[0] installer path */
- argv[argcnt++] = installer_path;
- /* argv[1] */
- argv[argcnt++] = strdup("-k");
- /* argv[2] */
- argv[argcnt++] = req_key;
- /* argv[3] */
- argv[argcnt++] = strdup("-i");
- /* argv[(4)] if exists */
- if (descriptor_path)
- argv[argcnt++] = strdup(descriptor_path);
- /* argv[4] */
- argv[argcnt++] = strdup(pkg_path);
- /* argv[5] -q option should be located at the end of command !! */
- if (mode == PM_QUIET)
- argv[argcnt++] = strdup("-q");
+ close(fd);
- /*** add quote in all string for special charactor like '\n'*** FIX */
- for (i = 0; i < argcnt; i++) {
- temp = g_shell_quote(argv[i]);
- len += (strlen(temp) + 1);
- g_free(temp);
- }
+ return ret;
+}
- args = (char *)calloc(len, sizeof(char));
- if (args == NULL) {
- _LOGD("calloc failed");
+char *__proc_get_cmdline_bypid(int pid)
+{
+ char buf[PKG_STRING_LEN_MAX] = {'\0', };
+ int ret = 0;
- for (i = 0; i < argcnt; i++)
- free(argv[i]);
+ snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid);
+ ret = __read_proc(buf, buf, sizeof(buf));
+ if (ret <= 0)
+ return NULL;
- free(pkgtype);
- return PKGMGR_R_ERROR;
- }
- strncpy(args, argv[0], len - 1);
+ /* support app launched by shell script*/
+ if (strncmp(buf, BINSH_NAME, BINSH_SIZE) == 0)
+ return strdup(&buf[BINSH_SIZE + 1]);
+ else
+ return strdup(buf);
+}
- for (i = 1; i < argcnt; i++) {
- strncat(args, " ", strlen(" "));
- temp = g_shell_quote(argv[i]);
- strncat(args, temp, strlen(temp));
- g_free(temp);
- }
- _LOGD("[args] %s [len] %d\n", args, len);
- /******************* end of quote ************************/
+static int __is_core_tpk_csc(char *description)
+{
+ int ret = 0;
+ char *path_str = NULL;
+ char *pkg_type = NULL;
+ char csc_str[PKG_STRING_LEN_MAX] = {'\0'};
+ snprintf(csc_str, PKG_STRING_LEN_MAX - 1, "%s:", description);
- /* 6. request install */
- ret = comm_client_request(mpc->info.request.cc, req_key,
- COMM_REQ_TO_INSTALLER, pkgtype, pkg_path,
- args, cookie, 1);
- if (ret < 0) {
- _LOGE("request failed, ret=%d\n", ret);
+ _LOGD("csc_str [%s]\n", csc_str);
- for (i = 0; i < argcnt; i++)
- free(argv[i]);
- free(args);
- free(pkgtype);
- return PKGMGR_R_ECOMM;
+ path_str = __get_str(csc_str, TOKEN_PATH_STR);
+ tryvm_if(path_str == NULL, ret = PKGMGR_R_ERROR, "path_str is NULL");
+
+ _LOGD("path_str [%s]\n", path_str);
+
+ pkg_type = _get_type_from_zip(path_str);
+ if (pkg_type) {
+ if (strstr(pkg_type, "rpm"))
+ ret = 1;
+ else
+ ret =-1;
+ free(pkg_type);
}
- for (i = 0; i < argcnt; i++)
- free(argv[i]);
+catch:
- free(args);
- free(pkgtype);
+ if(path_str)
+ free(path_str);
- return req_id;
+ return ret;
}
-int __iterfunc(const aul_app_info *info, void *data)
+static int __get_appid_bypid(int pid, char *pkgname, int len)
{
- char pkgname[PKG_STRING_LEN_MAX];
- const char *pkg_name;
+ char *cmdline = NULL;
+ char *caller_appid = NULL;
- pkg_name = (const char *)data;
+ cmdline = __proc_get_cmdline_bypid(pid);
+ if (cmdline == NULL)
+ return -1;
- aul_app_get_pkgname_bypid(info->pid, pkgname, sizeof(pkgname));
+ caller_appid = __get_app_info_from_db_by_apppath(cmdline);
+ snprintf(pkgname, len, "%s", caller_appid);
- if (strncmp(pkg_name, pkgname, strlen(pkg_name)) == 0) {
- if (aul_terminate_pid(info->pid) < 0)
- kill(info->pid, SIGKILL);
- }
+ free(cmdline);
+ free(caller_appid);
return 0;
}
-API int pkgmgr_client_uninstall(pkgmgr_client *pc, const char *pkg_type,
- const char *pkg_name, pkgmgr_mode mode,
- pkgmgr_handler event_cb, void *data)
+static char *__get_caller_pkgid()
{
- const char *pkgtype;
- char *installer_path;
- char *req_key;
- int req_id;
- int i = 0;
- char *argv[PKG_ARGC_MAX] = { NULL, };
- char *args = NULL;
- int argcnt = 0;
- int len = 0;
- char *temp = NULL;
- int ret;
- char *cookie = NULL;
+ char caller_appid[PKG_STRING_LEN_MAX] = {0, };
+ char *caller_pkgid = NULL;
- /* Check for NULL value of pc */
- if (pc == NULL) {
- _LOGD("package manager client handle is NULL\n");
- return PKGMGR_R_EINVAL;
+ if (__get_appid_bypid(getpid(), caller_appid, sizeof(caller_appid)) < 0) {
+ return NULL;
+ }
+ if (__get_pkgid_by_appid((const char*)caller_appid, &caller_pkgid) < 0){
+ return NULL;
}
- pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
- /* 0. check the pc type */
- if (mpc->ctype != PC_REQUEST)
- return PKGMGR_R_EINVAL;
+ return caller_pkgid;
+}
- /* 1. check argument */
- if (pkg_name == NULL)
- return PKGMGR_R_EINVAL;
+static inline int __pkgmgr_read_proc(const char *path, char *buf, int size)
+{
+ int fd;
+ int ret;
- if (aul_app_is_running(pkg_name)) {
- ret =
- aul_app_get_running_app_info(__iterfunc, (void *)pkg_name);
- if (ret < 0)
- return PKGMGR_R_ERROR;
- }
+ if (buf == NULL || path == NULL)
+ return -1;
- if (pkg_type == NULL) {
- pkgtype = _get_pkg_type_from_desktop_file(pkg_name);
- if (pkgtype == NULL)
- return PKGMGR_R_EINVAL;
+ fd = open(path, O_RDONLY);
+ if (fd < 0)
+ return -1;
+
+ ret = read(fd, buf, size - 1);
+ if (ret <= 0) {
+ close(fd);
+ return -1;
} else
- pkgtype = pkg_type;
+ buf[ret] = 0;
- if (strlen(pkg_name) >= PKG_STRING_LEN_MAX)
- return PKGMGR_R_EINVAL;
+ close(fd);
- /* 2. get installer path using pkg_path */
- installer_path = _get_backend_path_with_type(pkgtype);
- if (installer_path == NULL)
- return PKGMGR_R_EINVAL;
+ return ret;
+}
- /* 3. generate req_key */
- req_key = __get_req_key(pkg_name);
+static inline int __pkgmgr_find_pid_by_cmdline(const char *dname,
+ const char *cmdline, const char *apppath)
+{
+ int pid = 0;
- /* 4. add callback info - add callback info to pkgmgr_client */
- req_id = _get_request_id();
- __add_op_cbinfo(mpc, req_id, req_key, event_cb, data);
+ if (strncmp(cmdline, apppath, PKG_STRING_LEN_MAX-1) == 0) {
+ pid = atoi(dname);
+ if (pid != getpgid(pid))
+ pid = 0;
+ }
- /* 5. generate argv */
+ return pid;
+}
- /* argv[0] installer path */
- argv[argcnt++] = installer_path;
- /* argv[1] */
- argv[argcnt++] = strdup("-k");
- /* argv[2] */
- argv[argcnt++] = req_key;
- /* argv[3] */
- argv[argcnt++] = strdup("-d");
- /* argv[4] */
- argv[argcnt++] = strdup(pkg_name);
- /* argv[5] -q option should be located at the end of command !! */
- if (mode == PM_QUIET)
- argv[argcnt++] = strdup("-q");
+void __make_sizeinfo_file(char *description)
+{
+ FILE* file = NULL;
+ int fd = 0;
- /*** add quote in all string for special charactor like '\n'*** FIX */
- for (i = 0; i < argcnt; i++) {
- temp = g_shell_quote(argv[i]);
- len += (strlen(temp) + 1);
- g_free(temp);
+ if(description == NULL)
+ return;
+
+ file = fopen(PKG_SIZE_INFO_FILE, "w");
+ if (file == NULL) {
+ _LOGE("Couldn't open the file %s \n", PKG_SIZE_INFO_FILE);
+ return;
}
- args = (char *)calloc(len, sizeof(char));
- if (args == NULL) {
- _LOGD("calloc failed");
+ fwrite(description, 1, strlen(description), file);
+ fflush(file);
+ fd = fileno(file);
+ fsync(fd);
+ fclose(file);
+}
- for (i = 0; i < argcnt; i++)
- free(argv[i]);
+static int __check_sync_condition(char *req_key)
+{
+ int ret = 0;
+ ssize_t r;
+ char *buf;
+ size_t len;
- return PKGMGR_R_ERROR;
- }
- strncpy(args, argv[0], len - 1);
+ char info_file[PKG_STRING_LEN_MAX] = {'\0', };
- for (i = 1; i < argcnt; i++) {
- strncat(args, " ", strlen(" "));
- temp = g_shell_quote(argv[i]);
- strncat(args, temp, strlen(temp));
- g_free(temp);
- }
- _LOGD("[args] %s [len] %d\n", args, len);
- /******************* end of quote ************************/
+ snprintf(info_file, PKG_STRING_LEN_MAX, "%s/%s", PKG_SIZE_INFO_PATH, req_key);
+ if (access(info_file, F_OK)==0) {
+ _LOGE("sync check file[%s] exist !!! it is need to delete\n",info_file);
- /* 6. request install */
- ret = comm_client_request(mpc->info.request.cc, req_key,
- COMM_REQ_TO_INSTALLER, pkgtype, pkg_name,
- args, cookie, 1);
- if (ret < 0) {
- _LOGE("request failed, ret=%d\n", ret);
+ r = lgetxattr (info_file, "security.SMACK64", NULL, 0);
+ if (r == -1) {
+ _LOGE("get smack attr len error(%d)\n", errno);
+ return -1;
+ }
- for (i = 0; i < argcnt; i++)
- free(argv[i]);
+ len = r;
+ buf = malloc(len);
+ if (buf == NULL) {
+ _LOGE("malloc fail");
+ return -1;
+ }
- free(args);
- return PKGMGR_R_ECOMM;
- }
+ r = lgetxattr (info_file, "security.SMACK64", buf, len);
+ if (r == -1) {
+ _LOGE("get smack attr error(%d)\n", errno);
+ free(buf);
+ return -1;
+ }
- for (i = 0; i < argcnt; i++)
- free(argv[i]);
+ if (len != (size_t) r) {
+ _LOGE("unexpected size(%zu/%zd)\n", len, r);
+ free(buf);
+ return -1;
+ }
- free(args);
+ _LOGE("file[%s] has smack[%s]\n", info_file, buf);
- return req_id;
-}
+ free(buf);
-API int pkgmgr_client_activate(pkgmgr_client * pc, const char *pkg_type,
- const char *pkg_name)
-{
- const char *pkgtype;
- char *req_key;
- char *cookie = NULL;
- int ret;
- /* Check for NULL value of pc */
- if (pc == NULL) {
- _LOGD("package manager client handle is NULL\n");
- return PKGMGR_R_EINVAL;
+ ret = remove(info_file);
+ if (ret < 0)
+ _LOGD("file is can not remove[%s, %d]\n", info_file, ret);
}
- pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
-
- /* 0. check the pc type */
- if (mpc->ctype != PC_REQUEST)
- return PKGMGR_R_EINVAL;
+ return ret;
+}
- /* 1. check argument */
- if (pkg_name == NULL)
- return PKGMGR_R_EINVAL;
+static int __check_sync_process(char *req_key)
+{
+ int ret = 0;
+ char info_file[PKG_STRING_LEN_MAX] = {'\0', };
+ int result = -1;
+ int check_cnt = 0;
+ FILE *fp;
+ char buf[PKG_STRING_LEN_MAX] = {0};
+
+ snprintf(info_file, PKG_STRING_LEN_MAX, "%s/%s", PKG_SIZE_INFO_PATH, req_key);
+ while(1)
+ {
+ check_cnt ++;
+
+ if (access(info_file, F_OK)==0) {
+ fp = fopen(info_file, "r");
+ if (fp == NULL){
+ _LOGD("file is not generated yet.... wait\n");
+ usleep(10 * 1000); /* 10ms sleep*/
+ continue;
+ }
- if (pkg_type == NULL) {
- pkgtype = _get_pkg_type_from_desktop_file(pkg_name);
- if (pkgtype == NULL)
- return PKGMGR_R_EINVAL;
- } else
- pkgtype = pkg_type;
+ fgets(buf, PKG_STRING_LEN_MAX, fp);
+ fclose(fp);
- if (strlen(pkg_name) >= PKG_STRING_LEN_MAX)
- return PKGMGR_R_EINVAL;
+ _LOGD("info_file file is generated, result = %s. \n", buf);
+ result = atoi(buf);
+ break;
+ }
- /* 2. generate req_key */
- req_key = __get_req_key(pkg_name);
+ _LOGD("file is not generated yet.... wait\n");
+ usleep(10 * 1000); /* 10ms sleep*/
- /* 3. request activate */
- ret = comm_client_request(mpc->info.request.cc, req_key,
- COMM_REQ_TO_ACTIVATOR, pkgtype,
- pkg_name, "1", cookie, 1);
- if (ret < 0) {
- _LOGE("request failed, ret=%d\n", ret);
- free(req_key);
- return PKGMGR_R_ECOMM;
+ if (check_cnt > 6000) { /* 60s time over*/
+ _LOGD("wait time over!!\n");
+ break;
+ }
}
- free(req_key);
+ ret = remove(info_file);
+ if (ret < 0)
+ _LOGD("file is can not remove[%s, %d]\n", info_file, ret);
- return PKGMGR_R_OK;
+ return result;
}
-API int pkgmgr_client_deactivate(pkgmgr_client *pc, const char *pkg_type,
- const char *pkg_name)
+static int __disable_pkg()
{
- const char *pkgtype;
- char *req_key;
- char *cookie = NULL;
- int ret;
- /* Check for NULL value of pc */
- if (pc == NULL) {
- _LOGD("package manager client handle is NULL\n");
- return PKGMGR_R_EINVAL;
+ int ret = 0;
+ FILE *fp = NULL;
+ char *file_path = PKG_DISABLED_LIST_FILE;
+ char pkgid[PKG_STRING_LEN_MAX] = {'\0',};
+
+ fp = fopen(file_path, "r");
+ if (fp == NULL) {
+ _LOGE("fopen is failed.\n");
+ return -1;
}
- pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
- /* 0. check the pc type */
- if (mpc->ctype != PC_REQUEST)
- return PKGMGR_R_EINVAL;
+ while (fscanf(fp, "%s", pkgid) != EOF) {
+ ret = pkgmgr_parser_disable_pkg(pkgid, NULL);
+ if (ret < 0) {
+ _LOGE("pkgmgr_parser_disable_pkg is failed. pkgid is [%s].\n", pkgid);
+ continue;
+ }
+ _LOGD("pkgid [%s] is disabled.\n", pkgid);
+ }
- /* 1. check argument */
- if (pkg_name == NULL)
- return PKGMGR_R_EINVAL;
+ if (fp != NULL)
+ fclose(fp);
- if (pkg_type == NULL) {
- pkgtype = _get_pkg_type_from_desktop_file(pkg_name);
- if (pkgtype == NULL)
- return PKGMGR_R_EINVAL;
- } else
- pkgtype = pkg_type;
+ return ret;
+}
- if (strlen(pkg_name) >= PKG_STRING_LEN_MAX)
- return PKGMGR_R_EINVAL;
+static int __csc_process(const char *csc_path, char *result_path)
+{
+ int ret = 0;
+ int cnt = 0;
+ int count = 0;
+ int csc_fail = 0;
+ int fd = 0;
+ char *pkgtype = NULL;
+ char *des = NULL;
+ char buf[PKG_STRING_LEN_MAX] = {0,};
+ char type_buf[1024] = { 0 };
+ char des_buf[1024] = { 0 };
+ dictionary *csc = NULL;
+ FILE* file = NULL;
+
+ csc = iniparser_load(csc_path);
+ retvm_if(csc == NULL, PKGMGR_R_EINVAL, "cannot open parse file [%s]", csc_path);
+
+ file = fopen(result_path, "w");
+ tryvm_if(file == NULL, ret = PKGMGR_R_EINVAL, "cannot open result file [%s]", result_path);
+
+ count = iniparser_getint(csc, "csc packages:count", -1);
+ tryvm_if(count == 0, ret = PKGMGR_R_ERROR, "csc [%s] dont have packages", csc_path);
+
+ snprintf(buf, PKG_STRING_LEN_MAX, "[result]\n");
+ fwrite(buf, 1, strlen(buf), file);
+ snprintf(buf, PKG_STRING_LEN_MAX, "count = %d\n", count);
+ fwrite(buf, 1, strlen(buf), file);
+
+ for(cnt = 1 ; cnt <= count ; cnt++)
+ {
+ snprintf(type_buf, PKG_STRING_LEN_MAX - 1, "csc packages:type_%03d", cnt);
+ snprintf(des_buf, PKG_STRING_LEN_MAX - 1, "csc packages:description_%03d", cnt);
- /* 2. generate req_key */
- req_key = __get_req_key(pkg_name);
+ pkgtype = iniparser_getstr(csc, type_buf);
+ des = iniparser_getstr(csc, des_buf);
+ ret = 0;
- /* 3. request activate */
- ret = comm_client_request(mpc->info.request.cc, req_key,
- COMM_REQ_TO_ACTIVATOR, pkgtype,
- pkg_name, "0", cookie, 1);
- if (ret < 0) {
- _LOGE("request failed, ret=%d\n", ret);
- free(req_key);
- return PKGMGR_R_ECOMM;
+ if (pkgtype == NULL) {
+ csc_fail++;
+ snprintf(buf, PKG_STRING_LEN_MAX, "%s = Fail to get pkgtype\n", type_buf);
+ fwrite(buf, 1, strlen(buf), file);
+ continue;
+ } else if (des == NULL) {
+ csc_fail++;
+ snprintf(buf, PKG_STRING_LEN_MAX, "%s = Fail to get description\n", des_buf);
+ fwrite(buf, 1, strlen(buf), file);
+ continue;
+ }
+
+ snprintf(buf, PKG_STRING_LEN_MAX, "type_%03d = %s\n", cnt, pkgtype);
+ fwrite(buf, 1, strlen(buf), file);
+ snprintf(buf, PKG_STRING_LEN_MAX, "description_%03d = %s\n", cnt, des);
+ fwrite(buf, 1, strlen(buf), file);
+
+ if (strcmp(pkgtype, "tpk") == 0) {
+ if (__is_core_tpk_csc(des) == 1) {
+ const char *coreinstaller_argv[] = { "/usr/bin/rpm-backend", "-k", "csc-core", "-s", des, NULL };
+ ret = __xsystem(coreinstaller_argv);
+ } else {
+ const char *ospinstaller_argv[] = { "/usr/bin/osp-installer", "-c", des, NULL };
+ ret = __xsystem(ospinstaller_argv);
+ }
+ } else if (strcmp(pkgtype, "wgt")== 0) {
+ const char *wrtinstaller_argv[] = { "/usr/bin/wrt-installer", "-c", des, NULL };
+ ret = __xsystem(wrtinstaller_argv);
+ } else if (strcmp(pkgtype, "xml")== 0) {
+ const char *rpminstaller_argv[] = { "/usr/bin/rpm-backend", "-k", "csc-xml", "-s", des, NULL };
+ ret = __xsystem(rpminstaller_argv);
+ } else {
+ csc_fail++;
+ ret = -1;
+ }
+
+ if (ret != 0) {
+ char *errstr = NULL;
+ __error_to_string(ret, &errstr);
+ snprintf(buf, PKG_STRING_LEN_MAX, "result_%03d = fail[%s]\n", cnt, errstr);
+ }
+ else
+ snprintf(buf, PKG_STRING_LEN_MAX, "result_%03d = success\n", cnt);
+
+ fwrite(buf, 1, strlen(buf), file);
}
- free(req_key);
+catch:
+ iniparser_freedict(csc);
+ if (file != NULL) {
+ fflush(file);
+ fd = fileno(file);
+ fsync(fd);
+ fclose(file);
+ }
- return PKGMGR_R_OK;
+ if (__disable_pkg() < 0) {
+ _LOGE("__disable_pkg fail");
+ }
+
+ if (pkgmgr_parser_update_app_aliasid() < 0) {
+ _LOGE("pkgmgr_parser_update_app_aliasid fail");
+ }
+
+ const char *argv_parser[] = { "/usr/bin/chsmack", "-a", PKG_INFO_DB_LABEL, PKG_PARSER_DB_FILE, NULL };
+ __xsystem(argv_parser);
+ const char *argv_parserjn[] = { "/usr/bin/chsmack", "-a", PKG_INFO_DB_LABEL, PKG_PARSER_DB_FILE_JOURNAL, NULL };
+ __xsystem(argv_parserjn);
+
+ return ret;
}
-API int pkgmgr_client_clear_user_data(pkgmgr_client *pc, const char *pkg_type,
- const char *pkg_name, pkgmgr_mode mode)
+static int __get_size_process(pkgmgr_client * pc, const char *pkgid, pkgmgr_getsize_type get_type, pkgmgr_handler event_cb, void *data)
{
- const char *pkgtype;
- char *installer_path;
- char *req_key;
- int i = 0;
+ char *req_key = NULL;
+ int ret =0;
+ char *pkgtype = "getsize";
char *argv[PKG_ARGC_MAX] = { NULL, };
char *args = NULL;
int argcnt = 0;
int len = 0;
char *temp = NULL;
- int ret;
+ int i = 0;
+ char buf[128] = {'\0'};
char *cookie = NULL;
- /* Check for NULL value of pc */
- if (pc == NULL) {
- _LOGD("package manager client handle is NULL\n");
- return PKGMGR_R_EINVAL;
- }
pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+ retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST\n");
- /* 0. check the pc type */
- if (mpc->ctype != PC_REQUEST)
- return PKGMGR_R_EINVAL;
+ req_key = __get_req_key(pkgid);
+ retvm_if(req_key == NULL, PKGMGR_R_EINVAL, "req_key is NULL");
- /* 1. check argument */
- if (pkg_name == NULL)
- return PKGMGR_R_EINVAL;
+ snprintf(buf, 128, "%d", get_type);
+ argv[argcnt++] = strdup(pkgid);
+ argv[argcnt++] = strdup(buf);
+ argv[argcnt++] = strdup(req_key);
-/*
- if( aul_app_is_running(pkg_name) ) {
- ret = aul_app_get_running_app_info(__iterfunc, (void *) pkg_name);
- if(ret < 0)
- return PKGMGR_R_ERROR;
+ /*** add quote in all string for special charactor like '\n'*** FIX */
+ for (i = 0; i < argcnt; i++) {
+ temp = g_shell_quote(argv[i]);
+ len += (strlen(temp) + 1);
+ g_free(temp);
}
-*/
- if (pkg_type == NULL) {
- pkgtype = _get_pkg_type_from_desktop_file(pkg_name);
- if (pkgtype == NULL)
- return PKGMGR_R_EINVAL;
- } else
- pkgtype = pkg_type;
+ args = (char *)calloc(len, sizeof(char));
+ tryvm_if(args == NULL, ret = PKGMGR_R_EINVAL, "installer_path fail");
- if (strlen(pkg_name) >= PKG_STRING_LEN_MAX)
- return PKGMGR_R_EINVAL;
+ strncpy(args, argv[0], len - 1);
- /* 2. get installer path using pkg_path */
- installer_path = _get_backend_path_with_type(pkgtype);
- if (installer_path == NULL)
- return PKGMGR_R_EINVAL;
+ for (i = 1; i < argcnt; i++) {
+ strncat(args, " ", strlen(" "));
+ temp = g_shell_quote(argv[i]);
+ strncat(args, temp, strlen(temp));
+ g_free(temp);
+ }
+ _LOGD("[args] %s [len] %d\n", args, len);
- /* 3. generate req_key */
- req_key = __get_req_key(pkg_name);
+ /* get cookie from security-server */
+ cookie = __get_cookie_from_security_server();
+ tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
- /* 4. generate argv */
+ /* request */
+ ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_GET_SIZE, pkgtype, pkgid, args, cookie, 1);
+ tryvm_if(ret < 0, ret = PKGMGR_R_ERROR, "COMM_REQ_GET_SIZE failed, ret=%d\n", ret);
+
+ ret = __check_sync_process(req_key);
+ if (ret < 0)
+ _LOGE("get size failed, ret=%d\n", ret);
+
+catch:
+ for (i = 0; i < argcnt; i++)
+ free(argv[i]);
+
+ if(args)
+ free(args);
+ if (cookie)
+ free(cookie);
+
+ if(req_key)
+ free(req_key);
+
+ return ret;
+}
+
+static int __move_pkg_process(pkgmgr_client * pc, const char *pkgid, pkgmgr_move_type move_type, pkgmgr_handler event_cb, void *data)
+{
+ char *req_key = NULL;
+// int req_id = 0;
+ int ret =0;
+ pkgmgrinfo_pkginfo_h handle;
+ char *pkgtype = NULL;
+ char *installer_path = NULL;
+ char *argv[PKG_ARGC_MAX] = { NULL, };
+ char *args = NULL;
+ int argcnt = 0;
+ int len = 0;
+ char *temp = NULL;
+ int i = 0;
+ char buf[128] = {'\0'};
+ char *cookie = NULL;
+ pkgmgrinfo_install_location location = 0;
+
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+ retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST\n");
+ _LOGE("move pkg[%s] start", pkgid);
+
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+ retvm_if(ret < 0, PKGMGR_R_ERROR, "pkgmgr_pkginfo_get_pkginfo failed");
+
+ pkgmgrinfo_pkginfo_get_install_location(handle, &location);
+ tryvm_if(location == PMINFO_INSTALL_LOCATION_INTERNAL_ONLY, ret = PKGMGR_R_ERROR, "package[%s] is internal-only, can not be moved", pkgid);
+
+ ret = pkgmgrinfo_pkginfo_get_type(handle, &pkgtype);
+ tryvm_if(ret < 0, ret = PKGMGR_R_ERROR, "pkgmgr_pkginfo_get_type failed");
+ installer_path = _get_backend_path_with_type(pkgtype);
+ req_key = __get_req_key(pkgid);
+// req_id = _get_request_id();
+
+ /* generate argv */
+ snprintf(buf, 128, "%d", move_type);
/* argv[0] installer path */
argv[argcnt++] = installer_path;
/* argv[1] */
/* argv[2] */
argv[argcnt++] = req_key;
/* argv[3] */
- argv[argcnt++] = strdup("-c");
+ argv[argcnt++] = strdup("-m");
/* argv[4] */
- argv[argcnt++] = strdup(pkg_name);
- /* argv[5] -q option should be located at the end of command !! */
- if (mode == PM_QUIET)
- argv[argcnt++] = strdup("-q");
+ argv[argcnt++] = strdup(pkgid);
+ /* argv[5] */
+ argv[argcnt++] = strdup("-t");
+ /* argv[6] */
+ argv[argcnt++] = strdup(buf);
+ /* argv[7] */
+ argv[argcnt++] = strdup("-q");
/*** add quote in all string for special charactor like '\n'*** FIX */
for (i = 0; i < argcnt; i++) {
}
args = (char *)calloc(len, sizeof(char));
- if (args == NULL) {
- _LOGD("calloc failed");
-
- for (i = 0; i < argcnt; i++)
- free(argv[i]);
+ tryvm_if(args == NULL, ret = PKGMGR_R_EINVAL, "installer_path fail");
- return PKGMGR_R_ERROR;
- }
strncpy(args, argv[0], len - 1);
for (i = 1; i < argcnt; i++) {
g_free(temp);
}
_LOGD("[args] %s [len] %d\n", args, len);
- /******************* end of quote ************************/
- /* 6. request clear */
- ret = comm_client_request(mpc->info.request.cc, req_key,
- COMM_REQ_TO_CLEARER, pkgtype, pkg_name,
- args, cookie, 1);
- if (ret < 0) {
- _LOGE("request failed, ret=%d\n", ret);
+ /* get cookie from security-server */
+ cookie = __get_cookie_from_security_server();
+ tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
- for (i = 0; i < argcnt; i++)
- free(argv[i]);
+ ret = __check_sync_condition((char*)pkgid);
- free(args);
- return PKGMGR_R_ECOMM;
- }
+ /* 6. request */
+ ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_MOVER, pkgtype, pkgid, args, cookie, 1);
+ tryvm_if(ret < 0, ret = PKGMGR_R_ERROR, "COMM_REQ_TO_MOVER failed, ret=%d\n", ret);
+ ret = __check_sync_process((char*)pkgid);
+ if (ret != 0)
+ _LOGE("move pkg failed, ret=%d\n", ret);
+
+catch:
for (i = 0; i < argcnt; i++)
free(argv[i]);
- free(args);
+ if(args)
+ free(args);
+ if (cookie)
+ free(cookie);
- return PKGMGR_R_OK;
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ _LOGE("move pkg[%s] finish[%d]", pkgid, ret);
+ return ret;
}
-API int pkgmgr_client_listen_status(pkgmgr_client *pc, pkgmgr_handler event_cb,
- void *data)
+static int __check_app_process(pkgmgr_request_service_type service_type, pkgmgr_client * pc, const char *pkgid, void *data)
{
- int req_id;
+ char *pkgtype = NULL;
+ char *req_key = NULL;
+ int ret = 0;
+ pkgmgrinfo_pkginfo_h handle = NULL;
+ int pid = -1;
+
/* Check for NULL value of pc */
- if (pc == NULL) {
- _LOGD("package manager client handle is NULL\n");
- return PKGMGR_R_EINVAL;
- }
pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+ retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST\n");
- /* 0. check the pc type */
- if (mpc->ctype != PC_LISTENING)
- return PKGMGR_R_EINVAL;
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+ retvm_if(ret < 0, PKGMGR_R_ERROR, "pkgmgr_pkginfo_get_pkginfo failed");
- /* 1. check argument */
- if (event_cb == NULL)
- return PKGMGR_R_EINVAL;
+ ret = pkgmgrinfo_pkginfo_get_type(handle, &pkgtype);
+ tryvm_if(ret < 0, ret = PKGMGR_R_ERROR, "pkgmgr_pkginfo_get_type failed");
- /* 2. add callback info to pkgmgr_client */
- req_id = _get_request_id();
- __add_stat_cbinfo(mpc, req_id, event_cb, data);
+ /* 2. generate req_key */
+ req_key = __get_req_key(pkgid);
+
+ /* 3. request activate */
+ if (service_type == PM_REQUEST_KILL_APP)
+ ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_KILL_APP, pkgtype, pkgid, NULL, NULL, 1);
+ else if (service_type == PM_REQUEST_CHECK_APP)
+ ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_CHECK_APP, pkgtype, pkgid, NULL, NULL, 1);
+ tryvm_if(ret < 0, ret = PKGMGR_R_ERROR, "comm_client_request[type %d] failed, ret=%d\n", service_type, ret);
+
+ pid = __check_sync_process((char*)pkgid);
+ * (int *) data = pid;
+
+catch:
+ if(req_key)
+ free(req_key);
+
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+
+ return ret;
- return req_id;
}
-API int pkgmgr_client_broadcast_status(pkgmgr_client *pc, const char *pkg_type,
- const char *pkg_name, const char *key,
- const char *val)
+static int __request_size_info(pkgmgr_client *pc)
{
- /* Check for NULL value of pc */
- if (pc == NULL) {
- _LOGD("package manager client handle is NULL\n");
- return PKGMGR_R_EINVAL;
+ char *req_key = NULL;
+ int ret =0;
+ char *pkgtype = "getsize";
+ char *pkgid = "size_info";
+ pkgmgr_getsize_type get_type = PM_GET_SIZE_INFO;
+
+ char *argv[PKG_ARGC_MAX] = { NULL, };
+ char *args = NULL;
+ int argcnt = 0;
+ int len = 0;
+ char *temp = NULL;
+ int i = 0;
+ char buf[128] = {'\0'};
+ char *cookie = NULL;
+
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+ retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST\n");
+
+ req_key = __get_req_key(pkgid);
+
+ snprintf(buf, 128, "%d", get_type);
+ argv[argcnt++] = strdup(pkgid);
+ argv[argcnt++] = strdup(buf);
+ argv[argcnt++] = strdup(buf);
+
+ /*** add quote in all string for special charactor like '\n'*** FIX */
+ for (i = 0; i < argcnt; i++) {
+ temp = g_shell_quote(argv[i]);
+ len += (strlen(temp) + 1);
+ g_free(temp);
}
- /* Check for valid arguments. NULL parameter causes DBUS to abort */
- if (pkg_name == NULL || pkg_type == NULL || key == NULL || val == NULL) {
- _LOGD("Argument supplied is NULL\n");
- return PKGMGR_R_EINVAL;
+
+ args = (char *)calloc(len, sizeof(char));
+ tryvm_if(args == NULL, ret = PKGMGR_R_EINVAL, "installer_path fail");
+
+ strncpy(args, argv[0], len - 1);
+
+ for (i = 1; i < argcnt; i++) {
+ strncat(args, " ", strlen(" "));
+ temp = g_shell_quote(argv[i]);
+ strncat(args, temp, strlen(temp));
+ g_free(temp);
}
- pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+ _LOGD("[args] %s [len] %d\n", args, len);
- /* 0. check the pc type */
- if (mpc->ctype != PC_BROADCAST)
- return PKGMGR_R_EINVAL;
+ /* get cookie from security-server */
+ cookie = __get_cookie_from_security_server();
+ tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
- comm_status_broadcast_server_send_signal(mpc->info.broadcast.bc,
- PKG_STATUS, pkg_type,
- pkg_name, key, val);
+ /* request */
+ ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_GET_SIZE, pkgtype, pkgid, args, cookie, 1);
+ if (ret < 0) {
+ _LOGE("COMM_REQ_GET_SIZE failed, ret=%d\n", ret);
+ }
- return PKGMGR_R_OK;
+catch:
+ for (i = 0; i < argcnt; i++)
+ free(argv[i]);
+
+ if(args)
+ free(args);
+ if (cookie)
+ free(cookie);
+
+ return ret;
}
-ail_cb_ret_e __appinfo_func(const ail_appinfo_h appinfo, void *user_data)
+static int __change_op_cb_for_getjunkinfo(pkgmgr_client *pc)
{
- char *type;
- char *package;
- char *version;
+ int ret = -1;
- iter_data *udata = (iter_data *) user_data;
+ retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client pc is NULL");
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
- ail_appinfo_get_str(appinfo, AIL_PROP_X_SLP_PACKAGETYPE_STR, &type);
- if (type == NULL)
- type = "";
- ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &package);
- if (package == NULL)
- package = "";
- ail_appinfo_get_str(appinfo, AIL_PROP_VERSION_STR, &version);
- if (version == NULL)
- version = "";
+ /* free dbus connection */
+ ret = comm_client_free(mpc->info.request.cc);
+ retvm_if(ret < 0, PKGMGR_R_ERROR, "comm_client_free() failed - %d", ret);
- if (udata->iter_fn(type, package, version, udata->data) != 0)
- return AIL_CB_RET_CANCEL;
+ /* Manage pc for seperated event */
+ mpc->ctype = PC_REQUEST;
+ mpc->status_type = PKGMGR_CLIENT_STATUS_GET_JUNK_INFO;
- return AIL_CB_RET_CONTINUE;
-}
-API int pkgmgr_get_pkg_list(pkgmgr_iter_fn iter_fn, void *data)
-{
- int cnt = -1;
- ail_filter_h filter;
- ail_error_e ret;
+ mpc->info.request.cc = comm_client_new();
+ retvm_if(mpc->info.request.cc == NULL, PKGMGR_R_ERROR, "client creation failed");
- if (iter_fn == NULL)
- return PKGMGR_R_EINVAL;
+ ret = comm_client_set_status_callback(COMM_STATUS_BROADCAST_GET_JUNK_INFO, mpc->info.request.cc, __operation_callback, pc);
+ retvm_if(ret < 0, PKGMGR_R_ERROR, "set_status_callback() failed - %d", ret);
- ret = ail_filter_new(&filter);
- if (ret != AIL_ERROR_OK) {
- return PKGMGR_R_ERROR;
- }
+ return PKGMGR_R_OK;
+}
- ret = ail_filter_add_str(filter, AIL_PROP_TYPE_STR, "Application");
- if (ret != AIL_ERROR_OK) {
- ail_filter_destroy(filter);
- return PKGMGR_R_ERROR;
- }
+static int __change_op_cb_for_getsize(pkgmgr_client *pc)
+{
+ int ret = -1;
- ret = ail_filter_add_bool(filter, AIL_PROP_X_SLP_REMOVABLE_BOOL, true);
- if (ret != AIL_ERROR_OK) {
- ail_filter_destroy(filter);
- return PKGMGR_R_ERROR;
- }
+ retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client pc is NULL");
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
- ret = ail_filter_count_appinfo(filter, &cnt);
- if (ret != AIL_ERROR_OK) {
- ail_filter_destroy(filter);
- return PKGMGR_R_ERROR;
+ /* free listening head */
+ req_cb_info *tmp = NULL;
+ req_cb_info *prev = NULL;
+ for (tmp = mpc->info.request.rhead; tmp;) {
+ prev = tmp;
+ tmp = tmp->next;
+ free(prev);
}
- iter_data *udata = calloc(1, sizeof(iter_data));
- if (udata == NULL) {
- _LOGE("calloc failed");
- ail_filter_destroy(filter);
+ /* free dbus connection */
+ ret = comm_client_free(mpc->info.request.cc);
+ retvm_if(ret < 0, PKGMGR_R_ERROR, "comm_client_free() failed - %d", ret);
- return PKGMGR_R_ERROR;
- }
- udata->iter_fn = iter_fn;
- udata->data = data;
+ /* Manage pc for seperated event */
+ mpc->ctype = PC_REQUEST;
+ mpc->status_type = PKGMGR_CLIENT_STATUS_GET_SIZE;
- ail_filter_list_appinfo_foreach(filter, __appinfo_func, udata);
- free(udata);
+ mpc->info.request.cc = comm_client_new();
+ retvm_if(mpc->info.request.cc == NULL, PKGMGR_R_ERROR, "client creation failed");
- ret = ail_filter_destroy(filter);
- if (ret != AIL_ERROR_OK) {
- return PKGMGR_R_ERROR;
- }
+ ret = comm_client_set_status_callback(COMM_STATUS_BROADCAST_GET_SIZE, mpc->info.request.cc, __operation_callback, pc);
+ retvm_if(ret < 0, PKGMGR_R_ERROR, "set_status_callback() failed - %d", ret);
return PKGMGR_R_OK;
}
-API pkgmgr_info *pkgmgr_info_new(const char *pkg_type, const char *pkg_name)
+static junkmgr_result_h
+__junkmgr_create_junk_root_handle(const char *dbpath)
{
- const char *pkgtype;
- pkg_plugin_set *plugin_set = NULL;
- package_manager_pkg_detail_info_t *pkg_detail_info = NULL;
+ sqlite3 *db = NULL;
+ sqlite3_stmt *db_stmt = NULL;
+ char stmt[MAX_STMT_SIZE] = "SELECT root_name, category, root_file_type, storage_type, junk_total_size, root_path FROM junk_root";
+ junkmgr_result_s *handle = NULL;
+ int ret = 0;
+
+ ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL);
+ if (ret != SQLITE_OK)
+ {
+ LOGE("sqlite open error, ret: %d (%s)", ret, sqlite3_errmsg(db));
+ goto error;
+ }
- /* 1. check argument */
- if (pkg_name == NULL)
- return NULL;
+ ret = sqlite3_prepare_v2(db, stmt, strlen(stmt), &db_stmt, NULL);
+ if (ret != SQLITE_OK)
+ {
+ LOGE("sqlite prepare error, ret: %d (%s)", ret, sqlite3_errmsg(db));
+ goto error;
+ }
- if (pkg_type == NULL) {
- pkgtype = _get_pkg_type_from_desktop_file(pkg_name);
- if (pkgtype == NULL)
- return NULL;
- } else
- pkgtype = pkg_type;
+ handle = (junkmgr_result_s *)malloc(sizeof(junkmgr_result_s));
+ if (handle == NULL)
+ {
+ LOGE("out of memory");
+ goto error;
+ }
- if (strlen(pkg_name) >= PKG_STRING_LEN_MAX)
- return NULL;
+ handle->db = db;
+ handle->db_stmt = db_stmt;
- pkg_detail_info = calloc(1, sizeof(package_manager_pkg_detail_info_t));
- if (pkg_detail_info == NULL) {
- _LOGE("*** Failed to alloc package_handler_info.\n");
- return NULL;
+ return handle;
+
+error:
+ if (db_stmt)
+ {
+ ret = sqlite3_finalize(db_stmt);
+ if (ret != SQLITE_OK)
+ {
+ LOGE("sqlite finalize error, ret: %d (%s)", ret, sqlite3_errmsg(db));
+ }
}
- plugin_set = _package_manager_load_library(pkgtype);
- if (plugin_set == NULL) {
- _LOGE("*** Failed to load library");
- free(pkg_detail_info);
- return NULL;
- }
-
- if (plugin_set->pkg_is_installed) {
- if (plugin_set->pkg_is_installed(pkg_name) != 0) {
- _LOGE("*** Failed to call pkg_is_installed()");
- free(pkg_detail_info);
- return NULL;
- }
-
- if (plugin_set->get_pkg_detail_info) {
- if (plugin_set->get_pkg_detail_info(pkg_name,
- pkg_detail_info) != 0) {
- _LOGE("*** Failed to call get_pkg_detail_info()");
- free(pkg_detail_info);
- return NULL;
- }
+ if (db)
+ {
+ ret = sqlite3_close(db);
+ if (ret != SQLITE_OK)
+ {
+ LOGE("sqlite close error, ret: %d (%s)", ret, sqlite3_errmsg(db));
}
}
- return (pkgmgr_info *) pkg_detail_info;
+ return NULL;
}
-API char * pkgmgr_info_get_string(pkgmgr_info * pkg_info, const char *key)
+static junkmgr_result_h
+__junkmgr_create_junk_file_handle(const char *dbpath, int storage, const char *junk_root)
{
- package_manager_pkg_detail_info_t *pkg_detail_info;
-
- if (pkg_info == NULL)
- return NULL;
- if (key == NULL)
- return NULL;
+ sqlite3 *db = NULL;
+ sqlite3_stmt *db_stmt = NULL;
+ char stmt[MAX_STMT_SIZE] = "SELECT junk_file.file_name, junk_root.category, junk_file.file_type, junk_root.storage_type, junk_file.junk_file_size, junk_file.file_path FROM junk_root INNER JOIN junk_file ON junk_root.root_name = junk_file.root_name WHERE junk_root.storage_type = \0";
+ junkmgr_result_s *handle = NULL;
+ int ret = 0;
- pkg_detail_info = (package_manager_pkg_detail_info_t *) pkg_info;
+ if (storage == 0) // internal
+ {
+ strcat(stmt, "0 AND junk_root.root_name = '");
+ }
+ else if (storage == 1) // external
+ {
+ strcat(stmt, "1 AND junk_root.root_name = '");
+ }
- return _get_info_string(key, pkg_detail_info);
-}
+ strncat(stmt, junk_root, MAX_STMT_SIZE - strlen(stmt) - 2);
+ strcat(stmt, "'");
+ _LOGS("stmt: %s", stmt);
-API pkgmgr_info *pkgmgr_info_new_from_file(const char *pkg_type,
- const char *pkg_path)
-{
- pkg_plugin_set *plugin_set = NULL;
- package_manager_pkg_detail_info_t *pkg_detail_info = NULL;
- char *pkgtype;
- if (pkg_path == NULL) {
- _LOGE("pkg_path is NULL\n");
- return NULL;
+ ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL);
+ if (ret != SQLITE_OK)
+ {
+ LOGE("sqlite open error, ret: %d (%s)", ret, sqlite3_errmsg(db));
+ goto error;
}
- if (strlen(pkg_path) > PKG_URL_STRING_LEN_MAX) {
- _LOGE("length of pkg_path is too long - %d.\n",
- strlen(pkg_path));
- return NULL;
+ ret = sqlite3_prepare_v2(db, stmt, strlen(stmt), &db_stmt, NULL);
+ if (ret != SQLITE_OK)
+ {
+ LOGE("sqlite prepare error, ret: %d (%s)", ret, sqlite3_errmsg(db));
+ goto error;
}
- pkg_detail_info = calloc(1, sizeof(package_manager_pkg_detail_info_t));
- if (pkg_detail_info == NULL) {
- _LOGE("*** Failed to alloc package_handler_info.\n");
- return NULL;
+ handle = (junkmgr_result_s *)malloc(sizeof(junkmgr_result_s));
+ if (handle == NULL)
+ {
+ LOGE("out of memory");
+ goto error;
}
- if (pkg_type == NULL)
- pkgtype = __get_type_from_path(pkg_path);
- else
- pkgtype = strdup(pkg_type);
+ handle->db = db;
+ handle->db_stmt = db_stmt;
- plugin_set = _package_manager_load_library(pkgtype);
- if (plugin_set == NULL) {
- free(pkg_detail_info);
- free(pkgtype);
- return NULL;
+ return handle;
+
+error:
+ if (db_stmt)
+ {
+ ret = sqlite3_finalize(db_stmt);
+ if (ret != SQLITE_OK)
+ {
+ LOGE("sqlite finalize error, ret: %d (%s)", ret, sqlite3_errmsg(db));
+ }
}
- if (plugin_set->get_pkg_detail_info_from_package) {
- if (plugin_set->get_pkg_detail_info_from_package(pkg_path,
- pkg_detail_info) != 0) {
- free(pkg_detail_info);
- free(pkgtype);
- return NULL;
+ if (db)
+ {
+ ret = sqlite3_close(db);
+ if (ret != SQLITE_OK)
+ {
+ LOGE("sqlite close error, ret: %d (%s)", ret, sqlite3_errmsg(db));
}
}
- free(pkgtype);
- return (pkgmgr_info *) pkg_detail_info;
+ return NULL;
}
-API int pkgmgr_info_free(pkgmgr_info * pkg_info)
+static int
+__junkmgr_destroy_junk_handle(junkmgr_result_h hnd)
{
- if (pkg_info == NULL)
- return PKGMGR_R_EINVAL;
+ int ret = -1;
- free(pkg_info);
- pkg_info = NULL;
+ junkmgr_result_s *handle = (junkmgr_result_s *)hnd;
- return 0;
-}
+ if (!handle || !handle->db || !handle->db_stmt)
+ {
+ return -1;
+ }
-API int pkgmgr_get_pkginfo_type(pkgmgr_pkginfo_h handle, char **type)
-{
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PKGMGR_R_EINVAL;
+ ret = sqlite3_finalize((sqlite3_stmt *)(handle->db_stmt));
+ if (ret != SQLITE_OK)
+ {
+ printf("error %d", __LINE__);
+ return -1;
}
- if (type == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PKGMGR_R_EINVAL;
+
+ ret = sqlite3_close((sqlite3 *)(handle->db));
+ if (ret != SQLITE_OK)
+ {
+ printf("error %d", __LINE__);
+ return -1;
}
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
- if (info->manifest_info->type)
- *type = info->manifest_info->type;
- else
- *type = pkgtype;
- return PKGMGR_R_OK;
+ return 0;
}
-API int pkgmgr_get_pkginfo_version(pkgmgr_pkginfo_h handle, char **version)
+static int __get_junk_info_cb(int req_id, const char *req_type,
+ const char *pkgid, const char *key,
+ const char *value, const void *pc, void *user_data)
{
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- if (version == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
- *version = (char *)info->manifest_info->version;
- return PKGMGR_R_OK;
+ int ret = 0;
+ const char *caller = pkgid;
+ const char *dbpath = value;
+ junkmgr_result_s *handle = NULL;
+ char tb_key[16] = { 0, };
+
+ _LOGS("req_id: %d, caller: %s, dbpath: %s", req_id, caller, dbpath);
+
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *)pc;
+
+ junkmgr_s *junkmgr = (junkmgr_s *)(mpc->extension);
+ if (junkmgr && junkmgr->junk_tb)
+ {
+ snprintf(tb_key, 16, "%d", req_id);
+ junkmgr_info_s *junk_info = (junkmgr_info_s *)g_hash_table_lookup(junkmgr->junk_tb, tb_key);
+ if (junk_info)
+ {
+ if (junkmgr->db_path == NULL)
+ {
+ junkmgr->db_path = strdup(dbpath);
+ }
+
+ if (junk_info->junk_req_type == 0)
+ {
+ junkmgr_result_receive_cb callback = (junkmgr_result_receive_cb)(mpc->new_event_cb);
+ handle = __junkmgr_create_junk_root_handle(dbpath);
+
+ callback(req_id, handle, user_data);
+ }
+ else if (junk_info->junk_req_type == 1)
+ {
+ junkmgr_result_receive_cb callback = (junkmgr_result_receive_cb)(mpc->new_event_cb);
+ handle = __junkmgr_create_junk_file_handle(dbpath, junk_info->junk_storage, junk_info->junk_root);
+
+ callback(req_id, handle, user_data);
+ }
+ else if (junk_info->junk_req_type == 2)
+ {
+ junkmgr_clear_completed_cb callback = (junkmgr_clear_completed_cb)(mpc->new_event_cb);
+ callback(req_id, user_data);
+ }
+
+ if (junk_info->junk_root)
+ free(junk_info->junk_root);
+ g_hash_table_remove(junkmgr->junk_tb, tb_key);
+
+ if (handle)
+ {
+ __junkmgr_destroy_junk_handle(handle);
+ }
+ }
+ else
+ {
+ LOGD("junk_info null");
+ }
+ }
+ else
+ {
+ LOGD("junkmgr null");
+ }
+
+ return ret;
}
-API int pkgmgr_get_pkginfo_install_location(pkgmgr_pkginfo_h handle, pkgmgr_install_location *location)
+static int __get_pkg_size_info_cb(int req_id, const char *req_type,
+ const char *pkgid, const char *key,
+ const char *value, const void *pc, void *user_data)
{
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PKGMGR_R_EINVAL;
+ int ret = 0;
+ _LOGS("reqid: %d, req type: %s, pkgid: %s, unused key: %s, size info: %s",
+ req_id, req_type, pkgid, key, value);
+
+ pkg_size_info_t *size_info = (pkg_size_info_t *)malloc(sizeof(pkg_size_info_t));
+ retvm_if(size_info == NULL, -1, "The memory is insufficient.");
+
+ char *save_ptr = NULL;
+ char *token = strtok_r((char*)value, ":", &save_ptr);
+ if (token == NULL) {
+ _LOGE("token is NULL");
+ ret = -1;
+ goto catch;
+ }
+
+ size_info->data_size = atoll(token);
+ token = strtok_r(NULL, ":", &save_ptr);
+ size_info->cache_size = atoll(token);
+ token = strtok_r(NULL, ":", &save_ptr);
+ size_info->app_size = atoll(token);
+ token = strtok_r(NULL, ":", &save_ptr);
+ size_info->ext_data_size = atoll(token);
+ token = strtok_r(NULL, ":", &save_ptr);
+ size_info->ext_cache_size = atoll(token);
+ token = strtok_r(NULL, ":", &save_ptr);
+ size_info->ext_app_size = atoll(token);
+
+ _LOGS("data: %lld, cache: %lld, app: %lld, ext_data: %lld, ext_cache: %lld, ext_app: %lld",
+ size_info->data_size, size_info->cache_size, size_info->app_size,
+ size_info->ext_data_size, size_info->ext_cache_size, size_info->ext_app_size);
+
+ pkgmgr_client_t *pmc = (pkgmgr_client_t *)pc;
+ tryvm_if(pmc == NULL, ret = -1, "pkgmgr_client instance is null.");
+
+ if (strcmp(pkgid, PKG_SIZE_INFO_TOTAL) == 0)
+ { // total package size info
+ pkgmgr_total_pkg_size_info_receive_cb callback = (pkgmgr_total_pkg_size_info_receive_cb)(pmc->new_event_cb);
+ callback((pkgmgr_client *)pc, size_info, user_data);
}
- if (location == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PKGMGR_R_EINVAL;
+ else
+ {
+ pkgmgr_pkg_size_info_receive_cb callback = (pkgmgr_pkg_size_info_receive_cb)(pmc->new_event_cb);
+ callback((pkgmgr_client *)pc, pkgid, size_info, user_data);
}
- char *val = NULL;
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
- val = (char *)info->manifest_info->installlocation;
- if (val) {
- if (strcmp(val, "internal-only") == 0)
- *location = 0;
- else if (strcmp(val, "prefer-external") == 0)
- *location = 1;
- else
- *location = 1;
+
+catch:
+
+ if(size_info){
+ free(size_info);
+ size_info = NULL;
}
- return PKGMGR_R_OK;
+ return ret;
}
-API int pkgmgr_get_pkginfo_icon(pkgmgr_pkginfo_h handle, char **icon)
+static int __get_junk_info(junkmgr_s *junkmgr, const char *junk_path, junkmgr_info_s *junk_info, void *event_cb, void *user_data, int *reqid)
{
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PKGMGR_R_EINVAL;
+ int ret = 0;
+ int req_id = 0;
+ char *req_key = NULL;
+ char *pkg_type = "junk";
+ char junk_req_type[4] = { 0, };
+ char junk_storage[4] = { 0, };
+ char *argv[PKG_ARGC_MAX] = {0,};
+ char *args = NULL;
+ int argcnt = 0;
+ int len = 0;
+ char *temp = NULL;
+ int i = 0;
+ char *cookie = NULL;
+ char pid_str[8] = {0,};
+ int res = 0;
+
+ /* Check for NULL value of pc */
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *)(junkmgr->pc);
+ retvm_if(mpc == NULL, JUNKMGR_E_INVALID, "package manager client handle is NULL");
+
+ /* check the mpc type */
+ retvm_if(mpc->ctype != PC_REQUEST, JUNKMGR_E_SYSTEM, "mpc->ctype is not PC_REQUEST");
+
+ /* generate req_key by pid */
+ snprintf(pid_str, sizeof(pid_str), "%d", getpid());
+ req_key = __get_req_key(pid_str);
+ retvm_if(req_key == NULL, JUNKMGR_E_INVALID, "req_key is NULL");
+
+ /* add callback info - add callback info to pkgmgr_client */
+ req_id = _get_request_id();
+
+ ret = __change_op_cb_for_getjunkinfo(mpc);
+ if (ret < 0)
+ {
+ LOGE("__change_op_cb_for_getjunkinfo is fail");
+ free(req_key);
+ return JUNKMGR_E_SYSTEM;
}
- if (icon == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PKGMGR_R_EINVAL;
+
+ __add_op_cbinfo(mpc, req_id, req_key, __get_junk_info_cb, event_cb, user_data);
+
+ /* generate argv */
+
+ /* exec path */
+ argv[argcnt++] = strdup("pkg_getjunkinfo");
+ /* argv[1] pid */
+ argv[argcnt++] = strdup("-p");
+ argv[argcnt++] = strdup(pid_str);
+ /* pid+timestamp */
+ argv[argcnt++] = strdup("-k");
+ argv[argcnt++] = strdup(req_key);
+ /* request type */
+ switch (junk_info->junk_req_type) {
+ case 0:
+ strncpy(junk_req_type, "0", 1);
+ break;
+ case 1:
+ strncpy(junk_req_type, "1", 1);
+ break;
+ case 2:
+ strncpy(junk_req_type, "2", 1);
+ break;
+ default:
+ LOGE("Junk request type is invalid.");
+ break;
}
- char *syslocale = NULL;
- char *locale = NULL;
- char *save = NULL;
- icon_x *ptr = NULL;
- syslocale = vconf_get_str(VCONFKEY_LANGSET);
- if (syslocale == NULL) {
- _LOGE("current locale is NULL\n");
- return PKGMGR_R_EINVAL;
+ argv[argcnt++] = strdup("-t");
+ argv[argcnt++] = strdup(junk_req_type);
+ /* request storage */
+ switch (junk_info->junk_storage) {
+ case 0:
+ strncpy(junk_storage, "INT", 3);
+ break;
+ case 1:
+ strncpy(junk_storage, "EXT", 3);
+ break;
+ case 2:
+ strncpy(junk_storage, "ALL", 3);
+ break;
+ default:
+ LOGE("Storage type is invalid.");
+ break;
}
- locale = __convert_system_locale_to_manifest_locale(syslocale);
- if (locale == NULL) {
- _LOGE("manifest locale is NULL\n");
- return PKGMGR_R_EINVAL;
+ argv[argcnt++] = strdup("-w");
+ argv[argcnt++] = strdup(junk_storage);
+ /* junk path */
+ argv[argcnt++] = strdup("-j");
+ if (junk_path) {
+ argv[argcnt++] = strdup(junk_path);
}
- save = locale;
- *icon = NULL;
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
- for(ptr = info->manifest_info->icon; ptr != NULL; ptr = ptr->next)
- {
- if (ptr->lang) {
- if (strcmp(ptr->lang, locale) == 0) {
- *icon = (char *)ptr->name;
- if (strcmp(*icon, "(null)") == 0) {
- locale = DEFAULT_LOCALE;
- continue;
- } else
- break;
- } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
- *icon = (char *)ptr->text;
- break;
- }
- }
+ else {
+ argv[argcnt++] = strdup("ALL");
}
- if (syslocale) {
- free(syslocale);
- syslocale = NULL;
+
+ /*** add quote in all string for special charactor like '\n'*** FIX */
+ for (i = 0; i < argcnt; i++) {
+ temp = g_shell_quote(argv[i]);
+ len += (strlen(temp) + 1);
+ g_free(temp);
}
- locale = save;
- if (locale) {
- free(locale);
- locale = NULL;
+
+ args = (char *)calloc(len, sizeof(char));
+ tryvm_if(args == NULL, ret = JUNKMGR_E_NOMEM, "calloc failed");
+
+ strncpy(args, argv[0], len - 1);
+
+ for (i = 1; i < argcnt; i++) {
+ strncat(args, " ", strlen(" "));
+ temp = g_shell_quote(argv[i]);
+ strncat(args, temp, strlen(temp));
+ g_free(temp);
}
- return PKGMGR_R_OK;
+ _LOGD("[args] %s [len] %d\n", args, len);
+
+ char *tb_key = (char *)malloc(16);
+ tryvm_if(tb_key == NULL, ret = JUNKMGR_E_NOMEM, "out of memory");
+
+ snprintf(tb_key, 16, "%d", req_id);
+ g_hash_table_insert(junkmgr->junk_tb, tb_key, junk_info);
+ mpc->extension = junkmgr;
+
+ /* get cookie from security-server */
+ cookie = __get_cookie_from_security_server();
+ tryvm_if(cookie == NULL, ret = JUNKMGR_E_SYSTEM, "__get_cookie_from_security_server is NULL");
+ /******************* end of quote ************************/
+
+ /* 6. request install */
+ res = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_GET_JUNK_INFO, pkg_type, pid_str, args, cookie, 1);
+ trym_if(res < 0, "COMM_REQ_GET_JUNK_INFO failed, ret=%d", res);
+
+ *reqid = req_id;
+
+catch:
+ for (i = 0; i < argcnt; i++)
+ free(argv[i]);
+
+ if (args)
+ free(args);
+ if (cookie)
+ free(cookie);
+
+ return ret;
}
-API int pkgmgr_get_pkginfo_label(pkgmgr_pkginfo_h handle, char **label)
+static int __remove_junk_file(const char *dbpath, const char *junk_path)
{
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- if (label == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- char *syslocale = NULL;
- char *locale = NULL;
- char *save = NULL;
- label_x *ptr = NULL;
- syslocale = vconf_get_str(VCONFKEY_LANGSET);
- if (syslocale == NULL) {
- _LOGE("current locale is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- locale = __convert_system_locale_to_manifest_locale(syslocale);
- if (locale == NULL) {
- _LOGE("manifest locale is NULL\n");
- return PKGMGR_R_EINVAL;
+ sqlite3 *db = NULL;
+ sqlite3_stmt *db_stmt = NULL;
+ long long junk_file_size = 0;
+ long long junk_total_size = 0;
+ int res = 0;
+ int ret = JUNKMGR_E_SUCCESS;
+ char *query = NULL;
+ char *root_name = NULL;
+ char *error_message = NULL;
+
+ res = sqlite3_open(dbpath, &db);
+ if (SQLITE_OK != res)
+ {
+ LOGE("sqlite open error, res: %d (%s)", res, sqlite3_errmsg(db));
+ goto error;
}
- save = locale;
- *label = NULL;
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
- for(ptr = info->manifest_info->label; ptr != NULL; ptr = ptr->next)
+
+ query = sqlite3_mprintf("SELECT junk_file.root_name, junk_file.junk_file_size, junk_root.junk_total_size, junk_file.file_path FROM junk_root INNER JOIN junk_file ON junk_root.root_name = junk_file.root_name WHERE junk_file.file_path='%q'", junk_path);
+ if (query == NULL)
{
- if (ptr->lang) {
- if (strcmp(ptr->lang, locale) == 0) {
- *label = (char *)ptr->text;
- if (strcmp(*label, "(null)") == 0) {
- locale = DEFAULT_LOCALE;
- continue;
- } else
- break;
- } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
- *label = (char *)ptr->text;
- break;
- }
- }
+ LOGE("unable to allocate enough memory to hold the resulting string");
+ ret = JUNKMGR_E_NOMEM;
+ goto error;
}
- if (syslocale) {
- free(syslocale);
- syslocale = NULL;
+
+ res = sqlite3_prepare_v2(db, query, strlen(query), &db_stmt, NULL);
+ if (SQLITE_OK != res)
+ {
+ LOGE("sqlite prepare error, res: %d (%s)", res, sqlite3_errmsg(db));
+ goto error;
}
- locale = save;
- if (locale) {
- free(locale);
- locale = NULL;
+
+ res = sqlite3_step(db_stmt);
+ if (SQLITE_ROW != res)
+ {
+ LOGE("sqlite step error, res: %d (%s)", res, sqlite3_errmsg(db));
+ goto error;
}
- return PKGMGR_R_OK;
-}
-API int pkgmgr_get_pkginfo_description(pkgmgr_pkginfo_h handle, char **description)
-{
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PKGMGR_R_EINVAL;
+ root_name = (char*)sqlite3_column_text(db_stmt, 0);
+ junk_file_size = sqlite3_column_int64(db_stmt, 1);
+ junk_total_size = sqlite3_column_int64(db_stmt, 2);
+
+ sqlite3_free(query);
+ query = sqlite3_mprintf("DELETE FROM junk_file WHERE file_path='%q'", junk_path);
+ if (query == NULL)
+ {
+ LOGE("unable to allocate enough memory to hold the resulting string");
+ ret = JUNKMGR_E_NOMEM;
+ goto error;
}
- if (description == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PKGMGR_R_EINVAL;
+
+ res = sqlite3_exec(db, query, NULL, NULL, &error_message);
+ if (SQLITE_OK != res)
+ {
+ LOGE("Don't execute query = %s error massage = %s", query, error_message);
+ goto error;
}
- char *syslocale = NULL;
- char *locale = NULL;
- char *save = NULL;
- description_x *ptr = NULL;
- syslocale = vconf_get_str(VCONFKEY_LANGSET);
- if (syslocale == NULL) {
- _LOGE("current locale is NULL\n");
- return PKGMGR_R_EINVAL;
+
+ junk_total_size -= junk_file_size;
+ sqlite3_free(query);
+ query = sqlite3_mprintf("UPDATE junk_root SET junk_total_size = %lld where root_name='%q'", junk_total_size, root_name);
+ if (query == NULL)
+ {
+ LOGE("unable to allocate enough memory to hold the resulting string");
+ ret = JUNKMGR_E_NOMEM;
+ goto error;
}
- locale = __convert_system_locale_to_manifest_locale(syslocale);
- if (locale == NULL) {
- _LOGE("manifest locale is NULL\n");
- return PKGMGR_R_EINVAL;
+
+ res = sqlite3_exec(db, query, NULL, NULL, &error_message);
+ if (SQLITE_OK != res)
+ {
+ LOGE("Don't execute query = %s error massage = %s", query, error_message);
+ goto error;
}
- save = locale;
- *description = NULL;
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
- for(ptr = info->manifest_info->description; ptr != NULL; ptr = ptr->next)
+
+ ret = remove(junk_path);
+ if (ret < 0)
{
- if (ptr->lang) {
- if (strcmp(ptr->lang, locale) == 0) {
- *description = (char *)ptr->text;
- if (strcmp(*description, "(null)") == 0) {
- locale = DEFAULT_LOCALE;
- continue;
- } else
- break;
- } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
- *description = (char *)ptr->text;
+ LOGE("remove() failed. path: %s, errno %d (%s)", junk_path, errno, strerror(errno));
+ switch (errno)
+ {
+ case EACCES:
+ ret = JUNKMGR_E_ACCESS;
+ break;
+ case EIO:
+ ret = JUNKMGR_E_IO;
+ break;
+ case ENOMEM:
+ ret = JUNKMGR_E_NOMEM;
+ break;
+ default:
+ ret = JUNKMGR_E_SYSTEM;
break;
- }
}
}
- if (syslocale) {
- free(syslocale);
- syslocale = NULL;
- }
- locale = save;
- if (locale) {
- free(locale);
- locale = NULL;
- }
- return PKGMGR_R_OK;
-}
-API int pkgmgr_get_pkginfo_author_name(pkgmgr_pkginfo_h handle, char **author_name)
-{
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- if (author_name == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- char *syslocale = NULL;
- char *locale = NULL;
- char *save = NULL;
- author_x *ptr = NULL;
- syslocale = vconf_get_str(VCONFKEY_LANGSET);
- if (syslocale == NULL) {
- _LOGE("current locale is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- locale = __convert_system_locale_to_manifest_locale(syslocale);
- if (locale == NULL) {
- _LOGE("manifest locale is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- save = locale;
- *author_name = NULL;
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
- for(ptr = info->manifest_info->author; ptr != NULL; ptr = ptr->next)
+error:
+ if (SQLITE_OK != res)
{
- if (ptr->lang) {
- if (strcmp(ptr->lang, locale) == 0) {
- *author_name = (char *)ptr->text;
- if (strcmp(*author_name, "(null)") == 0) {
- locale = DEFAULT_LOCALE;
- continue;
- } else
- break;
- } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
- *author_name = (char *)ptr->text;
+ switch (res)
+ {
+ case SQLITE_DONE:
+ ret = JUNKMGR_E_NOT_FOUND;
+ break;
+ case SQLITE_BUSY:
+ ret = JUNKMGR_E_OBJECT_LOCKED;
+ break;
+ case SQLITE_CANTOPEN:
+ ret = JUNKMGR_E_PRIV;
+ break;
+ default:
+ ret = JUNKMGR_E_SYSTEM;
break;
- }
}
}
- if (syslocale) {
- free(syslocale);
- syslocale = NULL;
- }
- locale = save;
- if (locale) {
- free(locale);
- locale = NULL;
- }
- return PKGMGR_R_OK;
-}
-API int pkgmgr_get_pkginfo_author_email(pkgmgr_pkginfo_h handle, char **author_email)
-{
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PKGMGR_R_EINVAL;
+ if (query)
+ {
+ sqlite3_free(query);
}
- if (author_email == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PKGMGR_R_EINVAL;
+ if (error_message)
+ {
+ sqlite3_free(error_message);
}
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
- *author_email = (char *)info->manifest_info->author->email;
- return PKGMGR_R_OK;
-}
-
-API int pkgmgr_get_pkginfo_author_href(pkgmgr_pkginfo_h handle, char **author_href)
-{
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PKGMGR_R_EINVAL;
+ if (db_stmt)
+ {
+ sqlite3_finalize(db_stmt);
}
- if (author_href == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PKGMGR_R_EINVAL;
+ if (db)
+ {
+ sqlite3_close(db);
}
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
- *author_href = (char *)info->manifest_info->author->href;
- return PKGMGR_R_OK;
+
+ return ret;
}
-API int pkgmgr_get_pkginfo_removable(pkgmgr_pkginfo_h handle, bool *removable)
+
+static int __get_package_size_info(pkgmgr_client_t *mpc, char *req_key, const char *pkgid, pkgmgr_getsize_type get_type)
{
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- if (removable == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- char *val = NULL;
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
- val = (char *)info->manifest_info->removable;
- if (val) {
- if (strcasecmp(val, "true") == 0)
- *removable = 1;
- else if (strcasecmp(val, "false") == 0)
- *removable = 0;
- else
- *removable = 1;
- }
+ char *argv[PKG_ARGC_MAX] = { NULL, };
+ char *args = NULL;
+ int argcnt = 0;
+ char *pkgtype = "getsize"; //unused
+ char buf[128] = { 0, };
+ int len = 0;
+ char *cookie = NULL;
+ char *temp = NULL;
+ int i = 0;
+ int ret = 0;
+
+ snprintf(buf, 128, "%d", get_type);
+ argv[argcnt++] = strdup(pkgid);
+ argv[argcnt++] = strdup(buf);
+ argv[argcnt++] = strdup("-k");
+ argv[argcnt++] = req_key;
+
+ /*** add quote in all string for special charactor like '\n'*** FIX */
+ for (i = 0; i < argcnt; i++) {
+ temp = g_shell_quote(argv[i]);
+ len += (strlen(temp) + 1);
+ g_free(temp);
+ }
+
+ args = (char *)calloc(len, sizeof(char));
+ tryvm_if(args == NULL, ret = PKGMGR_R_EINVAL, "installer_path fail");
+
+ strncpy(args, argv[0], len - 1);
+
+ for (i = 1; i < argcnt; i++) {
+ strncat(args, " ", strlen(" "));
+ temp = g_shell_quote(argv[i]);
+ strncat(args, temp, strlen(temp));
+ g_free(temp);
+ }
+ _LOGD("[args] %s [len] %d\n", args, len);
+
+ /* get cookie from security-server */
+ cookie = __get_cookie_from_security_server();
+ tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
+
+ /* request */
+ ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_GET_SIZE, pkgtype, pkgid, args, cookie, 1);
+ if (ret < 0)
+ _LOGE("COMM_REQ_GET_SIZE failed, ret=%d\n", ret);
+
+catch:
+ for (i = 0; i < argcnt; i++)
+ free(argv[i]);
+
+ if(args)
+ free(args);
+ if (cookie)
+ free(cookie);
+
+ return ret;
+}
+
+static int __uninstall_pkg_cb (const pkgmgrinfo_pkginfo_h handle, void *user_data)
+{
+ int ret = -1;
+ char *pkgid = NULL;
+ char *pkgtype = NULL;
+
+ ret = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
+ retvm_if(ret != PMINFO_R_OK, PKGMGR_R_ERROR, "pkgmgrinfo_pkginfo_get_pkgid failed\n");
+
+ ret = pkgmgrinfo_pkginfo_get_type(handle, &pkgtype);
+ retvm_if(ret != PMINFO_R_OK, PKGMGR_R_ERROR, "pkgmgrinfo_pkginfo_get_type failed\n");
+
+ if (strcmp(pkgtype, "tpk") == 0) {
+ const char *ospinstaller_argv[] = { "/usr/bin/osp-installer", "-u", pkgid, NULL };
+ ret = __xsystem(ospinstaller_argv);
+ } else if (strcmp(pkgtype, "wgt")== 0) {
+ const char *wrtinstaller_argv[] = { "/usr/bin/wrt-installer", "-un", pkgid, NULL };
+ ret = __xsystem(wrtinstaller_argv);
+ } else if (strcmp(pkgtype, "rpm")== 0) {
+ const char *rpminstaller_argv[] = { "/usr/bin/rpm-backend", "-k", "uninstall", "-d", pkgid, NULL };
+ ret = __xsystem(rpminstaller_argv);
+ } else {
+ ret = -1;
+ }
+
+ _LOGF("[pkgtype = %s, pkgid = %s, ret = %d] uninstalled \n", pkgtype, pkgid, ret);
+
+ return ret;
+}
+
+static void __uninstall_downloaded_packages(void)
+{
+ int ret = 0;
+ pkgmgrinfo_pkginfo_filter_h handle = NULL;
+
+ _LOGF("============================================\n");
+ _LOGF("start __uninstall_downloaded_packages\n");
+
+ ret = pkgmgrinfo_pkginfo_filter_create(&handle);
+ retm_if(ret != PMINFO_R_OK, "pkginfo filter handle create failed\n");
+
+ _LOGF("success create handle\n");
+
+ ret = pkgmgrinfo_pkginfo_filter_add_bool(handle, PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD, 0);
+ trym_if(ret != PMINFO_R_OK, "PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD add_bool failed");
+
+ _LOGF("success set PRELOAD value\n");
+
+ ret = pkgmgrinfo_pkginfo_filter_add_bool(handle, PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE, 1);
+ trym_if(ret != PMINFO_R_OK, "PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE add_bool failed");
+
+ _LOGF("success set REMOVABLE value, call foreach cb!\n");
+
+ pkgmgrinfo_pkginfo_filter_foreach_pkginfo(handle, __uninstall_pkg_cb, NULL);
+
+catch :
+ pkgmgrinfo_pkginfo_filter_destroy(handle);
+
+ _LOGF("finish __uninstall_downloaded_packages\n");
+ _LOGF("============================================\n");
+}
+
+static void __recovery_pkgmgr_db(void)
+{
+ int ret = 0;
+
+ _LOGF("============================================\n");
+ _LOGF("start __recovery_pkgmgr_db\n");
+
+ /*unzip pkgmgr db from factoryrest data*/
+ const char *unzip_argv[] = { "/usr/bin/unzip", "-o", FACTORY_RESET_BACKUP_FILE, "opt/dbspace/.pkgmgr_parser.db", "-d", "/", NULL };
+ ret = __xsystem(unzip_argv);
+ retm_if(ret != PMINFO_R_OK, "unzip_argv failed\n");
+
+ _LOGF("success unzip PKG_PARSER_DB_FILE \n");
+
+ const char *unzipjn_argv[] = { "/usr/bin/unzip", "-o", FACTORY_RESET_BACKUP_FILE, "opt/dbspace/.pkgmgr_parser.db-journal", "-d", "/", NULL };
+ ret = __xsystem(unzipjn_argv);
+ retm_if(ret != PMINFO_R_OK, "unzipjn_argv failed\n");
+
+ _LOGF("success unzip PKG_PARSER_DB_FILE_JOURNAL \n");
+
+ const char *argv_parser[] = { "/usr/bin/chsmack", "-a", PKG_INFO_DB_LABEL, PKG_PARSER_DB_FILE, NULL };
+ ret = __xsystem(argv_parser);
+ retm_if(ret != PMINFO_R_OK, "chsmack PKG_PARSER_DB_FILE failed\n");
+
+ _LOGF("success chsmack PKG_PARSER_DB_FILE \n");
+
+ const char *argv_parserjn[] = { "/usr/bin/chsmack", "-a", PKG_INFO_DB_LABEL, PKG_PARSER_DB_FILE_JOURNAL, NULL };
+ ret = __xsystem(argv_parserjn);
+ retm_if(ret != PMINFO_R_OK, "chsmack PKG_PARSER_DB_FILE_JOURNAL failed\n");
+
+ _LOGF("success chsmack PKG_PARSER_DB_FILE_JOURNAL \n");
+
+ _LOGF("finish __recovery_pkgmgr_db\n");
+ _LOGF("============================================\n");
+}
+
+static void __rm_and_unzip_pkg(char *pkgid)
+{
+ int ret = 0;
+ char dirpath[PKG_STRING_LEN_MAX] = {'\0'};
+
+ //root path
+ snprintf(dirpath, PKG_STRING_LEN_MAX, "%s/%s", OPT_USR_APPS, pkgid);
+
+ if (access(dirpath, F_OK)==0) {
+ const char *deldata_argv[] = { "/bin/rm", "-rf", dirpath, NULL };
+ __xsystem(deldata_argv);
+
+ _LOGF("pkgpath = %s deleted \n", dirpath);
+
+ //unzip data from factoryrest data
+ memset(dirpath,'\0',PKG_STRING_LEN_MAX);
+ snprintf(dirpath, PKG_STRING_LEN_MAX, "opt/usr/apps/%s\*", pkgid);
+ const char *unzipdata_argv[] = { "/usr/bin/unzip", "-oX", FACTORY_RESET_BACKUP_FILE, dirpath, "-d", "/", NULL };
+ __xsystem(unzipdata_argv);
+
+ _LOGF("pkgpath = %s made \n", dirpath);
+
+ const char *rpmsmack_argv[] = { "/usr/bin/rpm-backend", "-k", "soft-reset", "-s", pkgid, NULL };
+ __xsystem(rpmsmack_argv);
+
+ _LOGF("pkgid = %s smack \n", pkgid);
+ } else {
+ _LOGF("pkgid = %s dont have data directory \n", pkgid);
+ }
+
+}
+
+static int __soft_reset_pkg_cb (const pkgmgrinfo_pkginfo_h handle, void *user_data)
+{
+ int ret = -1;
+ char *pkgid = NULL;
+ char *pkgtype = NULL;
+
+ ret = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
+ retvm_if(ret != PMINFO_R_OK, PKGMGR_R_ERROR, "pkgmgrinfo_pkginfo_get_pkgid failed\n");
+
+ ret = pkgmgrinfo_pkginfo_get_type(handle, &pkgtype);
+ retvm_if(ret != PMINFO_R_OK, PKGMGR_R_ERROR, "pkgmgrinfo_pkginfo_get_type failed\n");
+
+ if (strstr(pkgtype, "wgt")) {
+ _LOGF("[pkgid = %s] is wgt, it need skip\n", pkgid);
+ return PMINFO_R_OK;
+ }
+
+ _LOGF("[pkgid = %s] found as soft reset pkg\n", pkgid);
+
+ __rm_and_unzip_pkg(pkgid);
+
+ return PMINFO_R_OK;
+}
+
+static void __soft_reset_pkg(void)
+{
+ int ret = 0;
+ pkgmgrinfo_pkginfo_filter_h handle = NULL;
+
+ _LOGF("============================================\n");
+ _LOGF("start NO 'support-reset' tag on xml \n");
+
+ ret = pkgmgrinfo_pkginfo_filter_create(&handle);
+ retm_if(ret != PMINFO_R_OK, "pkginfo filter handle create failed\n");
+
+ ret = pkgmgrinfo_pkginfo_filter_add_bool(handle, PMINFO_PKGINFO_PROP_PACKAGE_USE_RESET, 1);
+ trym_if(ret != PMINFO_R_OK, "PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD add_bool failed");
+
+ pkgmgrinfo_pkginfo_filter_foreach_pkginfo(handle, __soft_reset_pkg_cb, NULL);
+
+catch :
+ pkgmgrinfo_pkginfo_filter_destroy(handle);
+
+ _LOGF("finish soft reset pkg\n");
+ _LOGF("============================================\n");
+
+}
+
+static int __none_reset_pkg_cb (const pkgmgrinfo_pkginfo_h handle, void *user_data)
+{
+ int ret = -1;
+ char *pkgid = NULL;
+ char *pkgtype = NULL;
+ char *root_path = NULL;
+ char *support_reset = NULL;
+ char script_path[PKG_STRING_LEN_MAX] = {'\0'};
+
+ ret = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
+ retvm_if(ret != PMINFO_R_OK, PKGMGR_R_ERROR, "pkgmgrinfo_pkginfo_get_pkgid failed\n");
+
+ ret = pkgmgrinfo_pkginfo_get_root_path(handle, &root_path);
+ retvm_if(ret != PMINFO_R_OK, PKGMGR_R_ERROR, "pkgmgrinfo_pkginfo_get_root_path failed\n");
+
+ ret = pkgmgrinfo_pkginfo_get_support_reset(handle, &support_reset);
+ retvm_if(ret != PMINFO_R_OK, PKGMGR_R_ERROR, "pkgmgrinfo_pkginfo_get_support_reset failed\n");
+
+ ret = pkgmgrinfo_pkginfo_get_type(handle, &pkgtype);
+ retvm_if(ret != PMINFO_R_OK, PKGMGR_R_ERROR, "pkgmgrinfo_pkginfo_get_type failed\n");
+
+ if (strstr(pkgtype, "wgt")) {
+ _LOGF("[pkgid = %s] is wgt, it need skip\n", pkgid);
+ return PMINFO_R_OK;
+ }
+
+ _LOGF("pkgid = %s, support_reset = %s \n", pkgid, support_reset);
+
+ snprintf(script_path, PKG_STRING_LEN_MAX, "%s/%s", root_path, support_reset);
+
+ if (access(script_path, F_OK)==0) {
+ const char *scriptt_argv[] = {script_path, NULL };
+ __xsystem(scriptt_argv);
+ _LOGF("success [script = %s]\n", script_path);
+ } else {
+ if (strcasestr(support_reset, "true")) {
+ __rm_and_unzip_pkg(pkgid);
+
+ char *save_ptr = NULL;
+ char *token = strtok_r((char*)support_reset, "|", &save_ptr);
+ if (token != NULL) {
+ memset(script_path,'\0',PKG_STRING_LEN_MAX);
+ snprintf(script_path, PKG_STRING_LEN_MAX, "%s/%s", root_path, save_ptr);
+ if (access(script_path, F_OK)==0) {
+ const char *srt_argv[] = {script_path, NULL };
+ __xsystem(srt_argv);
+ _LOGF("success [script = %s]\n", script_path);
+ }
+ }
+ } else {
+ _LOGF("can not access [script file = %s]\n", script_path);
+ }
+ }
+
+ return ret;
+}
+
+static void __none_reset_pkg(void)
+{
+ int ret = 0;
+ pkgmgrinfo_pkginfo_filter_h handle = NULL;
+
+ _LOGF("============================================\n");
+ _LOGF("start 'support-reset' tag on xml \n");
+
+ ret = pkgmgrinfo_pkginfo_filter_create(&handle);
+ retm_if(ret != PMINFO_R_OK, "pkginfo filter handle create failed\n");
+
+ ret = pkgmgrinfo_pkginfo_filter_add_bool(handle, PMINFO_PKGINFO_PROP_PACKAGE_USE_RESET, 0);
+ trym_if(ret != PMINFO_R_OK, "PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD add_bool failed");
+
+ pkgmgrinfo_pkginfo_filter_foreach_pkginfo(handle, __none_reset_pkg_cb, NULL);
+
+catch :
+ pkgmgrinfo_pkginfo_filter_destroy(handle);
+
+ _LOGF("finish 'support-reset' \n");
+ _LOGF("============================================\n");
+
+}
+
+static void __run_reset_script(void)
+{
+ DIR *dir;
+ struct dirent entry;
+ struct dirent *result;
+ int ret = 0;
+
+ _LOGF("============================================\n");
+ _LOGF("start __run_reset_script\n");
+
+ dir = opendir(SOFT_RESET_PATH);
+ if (!dir) {
+ _LOGF("opendir(%s) failed\n", SOFT_RESET_PATH);
+ return;
+ }
+
+ _LOGF("loading script files from %s\n", SOFT_RESET_PATH);
+
+ for (ret = readdir_r(dir, &entry, &result);
+ ret == 0 && result != NULL;
+ ret = readdir_r(dir, &entry, &result)) {
+
+ char script_path[PKG_STRING_LEN_MAX] = {'\0'};
+
+ if (!strcmp(entry.d_name, ".") ||
+ !strcmp(entry.d_name, "..")) {
+ continue;
+ }
+
+ snprintf(script_path, PKG_STRING_LEN_MAX, "%s/%s", SOFT_RESET_PATH, entry.d_name);
+
+ const char *script_argv[] = { script_path, NULL };
+ ret = __xsystem(script_argv);
+
+ _LOGF("reset script = [%s], ret = %d\n", entry.d_name, ret);
+ }
+
+ closedir(dir);
+
+ _LOGF("finish __run_reset_script\n");
+ _LOGF("============================================\n");
+}
+
+static void __pkgmgr_log_init()
+{
+ char *req_key = NULL;
+ char log_path[PKG_STRING_LEN_MAX] = {'\0'};
+
+ if (access(SOFT_RESET_TEST_FLAG, F_OK) != 0) {
+ return;
+ }
+
+ req_key = __get_req_key("soft-reset");
+ retm_if(req_key == NULL, "can not make log file\n");
+
+ snprintf(log_path, PKG_STRING_LEN_MAX, "%s/%s", OPT_USR_MEDIA, req_key);
+
+ logfile = fopen(log_path, "w");
+ if (logfile == NULL) {
+ _LOGF("fail pkgmgr logging\n");
+ } else {
+ _LOGF("============================================\n");
+ _LOGF("start pkgmgr logging [%s] \n", req_key);
+ }
+ free(req_key);
+}
+
+static void __pkgmgr_log_deinit()
+{
+ int fd = 0;
+ if (logfile != NULL) {
+ _LOGF("finish pkgmgr logging \n");
+ _LOGF("============================================\n");
+
+ fd = fileno(logfile);\
+ fsync(fd);\
+ fclose(logfile);\
+ }
+}
+
+API pkgmgr_client *pkgmgr_client_new(client_type ctype)
+{
+ pkgmgr_client_t *pc = NULL;
+ int ret = -1;
+
+ retvm_if(ctype != PC_REQUEST && ctype != PC_LISTENING && ctype != PC_BROADCAST, NULL, "ctype is not client_type");
+
+ /* Allocate memory for ADT:pkgmgr_client */
+ pc = calloc(1, sizeof(pkgmgr_client_t));
+ retvm_if(pc == NULL, NULL, "No memory");
+
+ /* Manage pc */
+ pc->ctype = ctype;
+ pc->status_type = PKGMGR_CLIENT_STATUS_ALL;
+
+ if (pc->ctype == PC_REQUEST) {
+ pc->info.request.cc = comm_client_new();
+ trym_if(pc->info.request.cc == NULL, "client creation failed");
+
+ ret = comm_client_set_status_callback(COMM_STATUS_BROADCAST_ALL, pc->info.request.cc, __operation_callback, pc);
+ trym_if(ret < 0L, "comm_client_set_status_callback() failed - %d", ret);
+ } else if (pc->ctype == PC_LISTENING) {
+ pc->info.listening.cc = comm_client_new();
+ trym_if(pc->info.listening.cc == NULL, "client creation failed");
+
+ ret = comm_client_set_status_callback(COMM_STATUS_BROADCAST_ALL, pc->info.listening.cc, __status_callback, pc);
+ trym_if(ret < 0L, "comm_client_set_status_callback() failed - %d", ret);
+ } else if (pc->ctype == PC_BROADCAST) {
+ pc->info.broadcast.bc = comm_status_broadcast_server_connect(COMM_STATUS_BROADCAST_ALL);
+ trym_if(pc->info.broadcast.bc == NULL, "client creation failed");
+ }
+
+ return (pkgmgr_client *) pc;
+
+catch:
+ if (pc)
+ free(pc);
+ return NULL;
+}
+
+API junkmgr_h junkmgr_create_handle(void)
+{
+
+ junkmgr_s *junkmgr = (junkmgr_s *)malloc(sizeof(junkmgr_s));
+ if (!junkmgr)
+ {
+ LOGE("malloc() failed. The memory is insufficient.");
+ return NULL;
+ }
+ junkmgr->pc = NULL;
+ junkmgr->junk_tb = NULL;
+ junkmgr->db_path = NULL;
+
+ pkgmgr_client *pc = pkgmgr_client_new(PC_REQUEST);
+ if (!pc)
+ {
+ free(junkmgr);
+ return NULL;
+ }
+
+ GHashTable *table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
+ if (!table)
+ {
+ free(junkmgr);
+ pkgmgr_client_free(pc);
+ return NULL;
+ }
+
+ junkmgr->pc = pc;
+ junkmgr->junk_tb = table;
+
+ return junkmgr;
+}
+
+API int junkmgr_destroy_handle(junkmgr_h mgr)
+{
+ if (!mgr)
+ {
+ LOGE("junkmgr handle is null.");
+ return JUNKMGR_E_INVALID;
+ }
+
+ junkmgr_s *junkmgr = (junkmgr_s *)mgr;
+
+ pkgmgr_client_free((pkgmgr_client *)(junkmgr->pc));
+ g_hash_table_destroy(junkmgr->junk_tb);
+
+ if (!junkmgr->db_path)
+ free(junkmgr->db_path);
+
+ free(junkmgr);
+
+ return JUNKMGR_E_SUCCESS;
+}
+
+API int pkgmgr_client_free(pkgmgr_client *pc)
+{
+ int ret = -1;
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+ retvm_if(mpc == NULL, PKGMGR_R_EINVAL, "Invalid argument");
+
+ if (mpc->ctype == PC_REQUEST) {
+ req_cb_info *tmp;
+ req_cb_info *prev;
+ for (tmp = mpc->info.request.rhead; tmp;) {
+ prev = tmp;
+ if(prev->req_key)
+ free(prev->req_key);
+ tmp = tmp->next;
+ free(prev);
+ }
+
+ ret = comm_client_free(mpc->info.request.cc);
+ tryvm_if(ret < 0, ret = PKGMGR_R_ERROR, "comm_client_free() failed");
+ } else if (mpc->ctype == PC_LISTENING) {
+ listen_cb_info *tmp;
+ listen_cb_info *prev;
+ for (tmp = mpc->info.listening.lhead; tmp;) {
+ prev = tmp;
+ tmp = tmp->next;
+ free(prev);
+ }
+
+ ret = comm_client_free(mpc->info.listening.cc);
+ tryvm_if(ret < 0, ret = PKGMGR_R_ERROR, "comm_client_free() failed");
+ } else if (mpc->ctype == PC_BROADCAST) {
+ comm_status_broadcast_server_disconnect(mpc->info.broadcast.bc);
+ ret = 0;
+ } else {
+ _LOGE("Invalid client type\n");
+ return PKGMGR_R_EINVAL;
+ }
+
+ free(mpc);
+ mpc = NULL;
+ return PKGMGR_R_OK;
+
+ catch:
+ if (mpc) {
+ free(mpc);
+ mpc = NULL;
+ }
+ return PKGMGR_R_ERROR;
+}
+
+API int pkgmgr_client_install(pkgmgr_client * pc, const char *pkg_type,
+ const char *descriptor_path, const char *pkg_path,
+ const char *optional_file, pkgmgr_mode mode,
+ pkgmgr_handler event_cb, void *data)
+{
+ char *req_key = NULL;
+ int req_id = 0;
+ int i = 0;
+ char *argv[PKG_ARGC_MAX] = { NULL, };
+ char *args = NULL;
+ int argcnt = 0;
+ int len = 0;
+ char *temp = NULL;
+ int ret = 0;
+ char *cookie = NULL;
+ char *caller_pkgid = NULL;
+
+ /* Check for NULL value of pc */
+ retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL");
+
+ /* 0. check the pc type */
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+ retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST");
+
+ /* 1. check argument */
+ if (descriptor_path) {
+ retvm_if(strlen(descriptor_path) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "descriptor_path over PKG_STRING_LEN_MAX");
+ retvm_if(access(descriptor_path, F_OK) != 0, PKGMGR_R_EINVAL, "descriptor_path access fail");
+ }
+
+ retvm_if(pkg_path == NULL, PKGMGR_R_EINVAL, "pkg_path is NULL");
+ retvm_if(strlen(pkg_path) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "pkg_path over PKG_STRING_LEN_MAX");
+ retvm_if(access(pkg_path, F_OK) != 0, PKGMGR_R_EINVAL, "pkg_path access fail");
+
+ if (optional_file)
+ retvm_if(strlen(optional_file) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "optional_file over PKG_STRING_LEN_MAX");
+
+ /* 3. generate req_key */
+ req_key = __get_req_key(pkg_path);
+ if (req_key == NULL) {
+ _LOGE("req_key is NULL");
+ ret = PKGMGR_R_EINVAL;
+ goto catch;
+ }
+
+ /* 4. add callback info - add callback info to pkgmgr_client */
+ req_id = _get_request_id();
+ __add_op_cbinfo(mpc, req_id, req_key, event_cb, NULL, data);
+
+ caller_pkgid = __get_caller_pkgid();
+ if (caller_pkgid != NULL)
+ _LOGE("caller pkgid = %s\n", caller_pkgid);
+
+ /* 5. generate argv */
+
+ /* argv[0] installer path */
+ argv[argcnt++] = strdup("arg-start");
+ /* argv[1] */
+ argv[argcnt++] = strdup("-k");
+ /* argv[2] */
+ argv[argcnt++] = req_key;
+ /* argv[3] */
+ argv[argcnt++] = strdup("-i");
+ /* argv[(4)] if exists */
+ if (descriptor_path)
+ argv[argcnt++] = strdup(descriptor_path);
+ /* argv[4] */
+ argv[argcnt++] = strdup(pkg_path);
+ /* argv[(5)] if exists */
+ if (optional_file){
+ argv[argcnt++] = strdup("-o");
+ argv[argcnt++] = strdup(optional_file);
+ }
+ if (caller_pkgid) {
+ argv[argcnt++] = strdup("-p");
+ argv[argcnt++] = strdup(caller_pkgid);
+ }
+
+
+
+ /*** add quote in all string for special charactor like '\n'*** FIX */
+ for (i = 0; i < argcnt; i++) {
+ temp = g_shell_quote(argv[i]);
+ len += (strlen(temp) + 1);
+ g_free(temp);
+ }
+
+ args = (char *)calloc(len, sizeof(char));
+ tryvm_if(args == NULL, ret = PKGMGR_R_ERROR, "calloc failed");
+
+ strncpy(args, argv[0], len - 1);
+
+ for (i = 1; i < argcnt; i++) {
+ strncat(args, " ", strlen(" "));
+ temp = g_shell_quote(argv[i]);
+ strncat(args, temp, strlen(temp));
+ g_free(temp);
+ }
+ _LOGD("[args] %s [len] %d\n", args, len);
+
+ /* get cookie from security-server */
+ cookie = __get_cookie_from_security_server();
+ tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
+ /******************* end of quote ************************/
+
+ /* 6. request install */
+ ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_INSTALLER, pkg_type, pkg_path, args, cookie, 1);
+ tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "COMM_REQ_TO_INSTALLER failed, ret=%d", ret);
+
+ ret = req_id;
+
+catch:
+ for (i = 0; i < argcnt; i++)
+ free(argv[i]);
+
+ if (args)
+ free(args);
+ if (cookie)
+ free(cookie);
+ if (caller_pkgid)
+ free(caller_pkgid);
+
+ return ret;
+}
+
+API int pkgmgr_client_reinstall(pkgmgr_client * pc, const char *pkg_type, const char *pkgid,
+ const char *optional_file, pkgmgr_mode mode,
+ pkgmgr_handler event_cb, void *data)
+{
+ char *pkgtype = NULL;
+ char *installer_path = NULL;
+ char *req_key = NULL;
+ int req_id = 0;
+ int i = 0;
+ char *argv[PKG_ARGC_MAX] = { NULL, };
+ char *args = NULL;
+ int argcnt = 0;
+ int len = 0;
+ char *temp = NULL;
+ int ret = 0;
+ char *cookie = NULL;
+ pkgmgrinfo_pkginfo_h handle = NULL;
+
+ /* Check for NULL value of pc */
+ retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
+
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+
+ /* 0. check the pc type */
+ retv_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL);
+
+
+ /* 1. check argument */
+ retv_if(pkgid == NULL, PKGMGR_R_EINVAL);
+ retv_if(strlen(pkgid) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL);
+ if (optional_file) {
+ if (strlen(optional_file) >= PKG_STRING_LEN_MAX)
+ return PKGMGR_R_EINVAL;
+ }
+
+ /* 2. get installer path using pkg_path */
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+ tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgrinfo_pkginfo_get_pkginfo fail");
+
+ ret = pkgmgrinfo_pkginfo_get_type(handle, &pkgtype);
+ tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgrinfo_pkginfo_get_type fail");
+
+ installer_path = _get_backend_path_with_type(pkgtype);
+ tryvm_if(installer_path == NULL, ret = PKGMGR_R_EINVAL, "installer_path is null");
+
+ /* 3. generate req_key */
+ req_key = __get_req_key(pkgid);
+ tryvm_if(req_key == NULL, ret = PKGMGR_R_EINVAL, "req_key is NULL");
+
+ /* 4. add callback info - add callback info to pkgmgr_client */
+ req_id = _get_request_id();
+ __add_op_cbinfo(mpc, req_id, req_key, event_cb, NULL, data);
+
+ /* 5. generate argv */
+
+ /* argv[0] installer path */
+ argv[argcnt++] = installer_path;
+ /* argv[1] */
+ argv[argcnt++] = strdup("-k");
+ /* argv[2] */
+ argv[argcnt++] = req_key;
+ /* argv[3] */
+ argv[argcnt++] = strdup("-r");
+ /* argv[4] */
+ argv[argcnt++] = strdup(pkgid);
+ /* argv[(5)] if exists */
+ if (optional_file){
+ argv[argcnt++] = strdup("-o");
+ argv[argcnt++] = strdup(optional_file);
+ }
+
+
+
+ /*** add quote in all string for special charactor like '\n'*** FIX */
+ for (i = 0; i < argcnt; i++) {
+ temp = g_shell_quote(argv[i]);
+ len += (strlen(temp) + 1);
+ g_free(temp);
+ }
+
+ args = (char *)calloc(len, sizeof(char));
+ tryvm_if(args == NULL, ret = PKGMGR_R_ERROR, "calloc failed");
+
+ strncpy(args, argv[0], len - 1);
+
+ for (i = 1; i < argcnt; i++) {
+ strncat(args, " ", strlen(" "));
+ temp = g_shell_quote(argv[i]);
+ strncat(args, temp, strlen(temp));
+ g_free(temp);
+ }
+ _LOGD("[args] %s [len] %d\n", args, len);
+
+ /* get cookie from security-server */
+ cookie = __get_cookie_from_security_server();
+ tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
+ /******************* end of quote ************************/
+
+ /* 6. request install */
+ ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_INSTALLER, pkgtype, pkgid, args, cookie, 1);
+ tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "COMM_REQ_TO_INSTALLER failed, ret=%d", ret);
+
+ ret = req_id;
+
+catch:
+ for (i = 0; i < argcnt; i++)
+ free(argv[i]);
+
+ if (args)
+ free(args);
+ if (cookie)
+ free(cookie);
+ if (handle)
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+
+ return ret;
+}
+
+API int pkgmgr_client_uninstall(pkgmgr_client *pc, const char *pkg_type,
+ const char *pkgid, pkgmgr_mode mode,
+ pkgmgr_handler event_cb, void *data)
+{
+ char *pkgtype = NULL;
+ char *installer_path = NULL;
+ char *req_key = NULL;
+ int req_id = 0;
+ int i = 0;
+ char *argv[PKG_ARGC_MAX] = { NULL, };
+ char *args = NULL;
+ int argcnt = 0;
+ int len = 0;
+ char *temp = NULL;
+ int ret = -1;
+ char *cookie = NULL;
+ bool removable = false;
+ char *caller_pkgid = NULL;
+
+ /* Check for NULL value of pc */
+ retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
+
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+
+ /* 0. check the pc type */
+ retv_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL);
+
+ /* 1. check argument */
+ retv_if(pkgid == NULL, PKGMGR_R_EINVAL);
+
+ pkgmgrinfo_pkginfo_h handle;
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+
+ /*check package id */
+ tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_pkginfo_get_pkginfo fail");
+ tryvm_if(handle == NULL, ret = PKGMGR_R_EINVAL, "Pkgid(%s) can not find in installed pkg DB! \n", pkgid);
+
+ /*check type */
+ ret = pkgmgrinfo_pkginfo_get_type(handle, &pkgtype);
+ tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_pkginfo_get_type fail");
+ tryvm_if(pkgtype == NULL, ret = PKGMGR_R_ERROR, "pkgtype is NULL");
+
+ /*check removable*/
+ pkgmgrinfo_pkginfo_is_removable(handle, &removable);
+ tryvm_if(removable == false, ret = PKGMGR_R_ERROR, "Pkgid(%s) can not be removed, This is non-removalbe package...\n", pkgid);
+
+ /*check pkgid length */
+ tryvm_if(strlen(pkgid) >= PKG_STRING_LEN_MAX, ret = PKGMGR_R_EINVAL, "pkgid is too long");
+
+ /* 2. get installer path using pkgtype */
+ installer_path = _get_backend_path_with_type(pkgtype);
+ tryvm_if(installer_path == NULL, ret = PKGMGR_R_EINVAL, "installer_path fail");
+
+ /* 3. generate req_key */
+ req_key = __get_req_key(pkgid);
+ tryvm_if(req_key == NULL, ret = PKGMGR_R_EINVAL, "req_key is NULL");
+
+ /* 4. add callback info - add callback info to pkgmgr_client */
+ req_id = _get_request_id();
+ __add_op_cbinfo(mpc, req_id, req_key, event_cb, NULL, data);
+
+ caller_pkgid = __get_caller_pkgid();
+ if (caller_pkgid != NULL)
+ _LOGE("caller pkgid = %s\n", caller_pkgid);
+
+ /* 5. generate argv */
+
+ /* argv[0] installer path */
+ argv[argcnt++] = installer_path;
+ /* argv[1] */
+ argv[argcnt++] = strdup("-k");
+ /* argv[2] */
+ argv[argcnt++] = req_key;
+ /* argv[3] */
+ argv[argcnt++] = strdup("-d");
+ /* argv[4] */
+ argv[argcnt++] = strdup(pkgid);
+ if (caller_pkgid) {
+ argv[argcnt++] = strdup("-p");
+ argv[argcnt++] = caller_pkgid;
+ }
+
+
+ /*** add quote in all string for special charactor like '\n'*** FIX */
+ for (i = 0; i < argcnt; i++) {
+ temp = g_shell_quote(argv[i]);
+ len += (strlen(temp) + 1);
+ g_free(temp);
+ }
+
+ args = (char *)calloc(len, sizeof(char));
+ tryvm_if(args == NULL, ret = PKGMGR_R_ERROR, "calloc failed");
+
+ strncpy(args, argv[0], len - 1);
+
+ for (i = 1; i < argcnt; i++) {
+ strncat(args, " ", strlen(" "));
+ temp = g_shell_quote(argv[i]);
+ strncat(args, temp, strlen(temp));
+ g_free(temp);
+ }
+ _LOGD("[args] %s [len] %d\n", args, len);
+
+ /* get cookie from security-server */
+ cookie = __get_cookie_from_security_server();
+ tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
+ /******************* end of quote ************************/
+
+ /* 6. request install */
+ ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_INSTALLER, pkgtype, pkgid, args, cookie, 1);
+ tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "COMM_REQ_TO_INSTALLER failed, ret=%d", ret);
+
+ ret = req_id;
+
+catch:
+ for (i = 0; i < argcnt; i++)
+ free(argv[i]);
+
+ if (args)
+ free(args);
+ if (cookie)
+ free(cookie);
+
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ PKGMGR_END();\
+ return ret;
+}
+
+API int pkgmgr_client_move(pkgmgr_client *pc, const char *pkgid, pkgmgr_move_type move_type, pkgmgr_handler event_cb, void *data)
+{
+ char *pkgtype = NULL;
+ char *installer_path= NULL;
+ char *req_key = NULL;
+ int req_id = 0;
+ int i = 0;
+ char *argv[PKG_ARGC_MAX] = { NULL, };
+ char *args = NULL;
+ int argcnt = 0;
+ int len = 0;
+ char *temp = NULL;
+ int ret = -1;
+ char *cookie = NULL;
+ char buf[128] = {'\0'};
+ pkgmgrinfo_install_location location = 0;
+
+ /* Check for NULL value of pc */
+ retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
+ _LOGE("move pkg[%s] start", pkgid);
+
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+
+ /* 0. check the pc type */
+ retv_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL);
+
+ /* 1. check argument */
+ retv_if(pkgid == NULL, PKGMGR_R_EINVAL);
+
+ pkgmgrinfo_pkginfo_h handle;
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+
+ /*check package id */
+ tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_pkginfo_get_pkginfo fail");
+ tryvm_if(handle == NULL, ret = PKGMGR_R_EINVAL, "Pkgid(%s) can not find in installed pkg DB! \n", pkgid);
+
+ pkgmgrinfo_pkginfo_get_install_location(handle, &location);
+ tryvm_if(location == PMINFO_INSTALL_LOCATION_INTERNAL_ONLY, ret = PKGMGR_R_ERROR, "package[%s] is internal-only, can not be moved", pkgid);
+
+ /*check type */
+ ret = pkgmgrinfo_pkginfo_get_type(handle, &pkgtype);
+ tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_pkginfo_get_type fail");
+ tryvm_if(pkgtype == NULL, ret = PKGMGR_R_ERROR, "pkgtype is NULL");
+
+ /*check pkgid length */
+ tryvm_if(strlen(pkgid) >= PKG_STRING_LEN_MAX, ret = PKGMGR_R_EINVAL, "pkgid is too long");
+
+ /*check move_type */
+ tryvm_if((move_type < PM_MOVE_TO_INTERNAL) || (move_type > PM_MOVE_TO_SDCARD), ret = PKGMGR_R_EINVAL, "move_type is not supported");
+
+ /* 2. get installer path using pkgtype */
+ installer_path = _get_backend_path_with_type(pkgtype);
+ tryvm_if(installer_path == NULL, ret = PKGMGR_R_EINVAL, "installer_path fail");
+
+ /* 3. generate req_key */
+ req_key = __get_req_key(pkgid);
+ tryvm_if(req_key == NULL, ret = PKGMGR_R_EINVAL, "failed to get req_key");
+
+ /* 4. add callback info - add callback info to pkgmgr_client */
+ req_id = _get_request_id();
+ __add_op_cbinfo(mpc, req_id, req_key, event_cb, NULL, data);
+
+ /* 5. generate argv */
+ snprintf(buf, 128, "%d", move_type);
+ /* argv[0] installer path */
+ argv[argcnt++] = installer_path;
+ /* argv[1] */
+ argv[argcnt++] = strdup("-k");
+ /* argv[2] */
+ argv[argcnt++] = req_key;
+ /* argv[3] */
+ argv[argcnt++] = strdup("-m");
+ /* argv[4] */
+ argv[argcnt++] = strdup(pkgid);
+ /* argv[5] */
+ argv[argcnt++] = strdup("-t");
+ /* argv[6] */
+ argv[argcnt++] = strdup(buf);
+ /* argv[5] -q option should be located at the end of command !! */
+ argv[argcnt++] = strdup("-q");
+
+ /*** add quote in all string for special charactor like '\n'*** FIX */
+ for (i = 0; i < argcnt; i++) {
+ temp = g_shell_quote(argv[i]);
+ len += (strlen(temp) + 1);
+ g_free(temp);
+ }
+
+ args = (char *)calloc(len, sizeof(char));
+ tryvm_if(args == NULL, ret = PKGMGR_R_ERROR, "calloc failed");
+
+ strncpy(args, argv[0], len - 1);
+
+ for (i = 1; i < argcnt; i++) {
+ strncat(args, " ", strlen(" "));
+ temp = g_shell_quote(argv[i]);
+ strncat(args, temp, strlen(temp));
+ g_free(temp);
+ }
+ _LOGD("[args] %s [len] %d\n", args, len);
+
+ /* get cookie from security-server */
+ cookie = __get_cookie_from_security_server();
+ tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
+ /******************* end of quote ************************/
+
+ /* 6. request install */
+ ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_MOVER, pkgtype, pkgid, args, cookie, 1);
+ tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "COMM_REQ_TO_MOVER failed, ret=%d", ret);
+
+ ret = req_id;
+
+catch:
+ for (i = 0; i < argcnt; i++)
+ free(argv[i]);
+
+ if(args)
+ free(args);
+ if (cookie)
+ free(cookie);
+
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ PKGMGR_END();\
+
+ _LOGE("move pkg[%s] finish[%d]", pkgid, ret);
+ return ret;
+}
+
+API int pkgmgr_client_activate(pkgmgr_client * pc, const char *pkg_type, const char *pkgid)
+{
+ _LOGE("pkgmgr_client_activate[%s] start", pkgid);
+
+ char *req_key = NULL;
+ int ret = 0;
+ pkgmgrinfo_pkginfo_h handle = NULL;
+
+ /* Check for NULL value of pc */
+ retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
+
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+
+ /* 0. check the pc type */
+ retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST");
+
+ /* 1. check argument */
+ retvm_if(pkgid == NULL, PKGMGR_R_EINVAL, "pkgid is NULL");
+ retvm_if(strlen(pkgid) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "pkgid length over PKG_STRING_LEN_MAX ");
+
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+ if ((ret == 0) && (handle != NULL)) {
+ SECURE_LOGD("pkg[%s] is already installed.", pkgid);
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ // This package is already installed. skip the activation event.
+ return PKGMGR_R_OK;
+ }
+
+ /* 2. generate req_key */
+ req_key = __get_req_key(pkgid);
+ retvm_if(req_key == NULL, PKGMGR_R_EINVAL, "req_key is NULL");
+
+ /* 3. request activate */
+ ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_ACTIVATE_PKG, "pkg", pkgid, NULL, NULL, 1);
+ tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "COMM_REQ_ACTIVATE_PKG failed, ret=%d", ret);
+
+ ret = PKGMGR_R_OK;
+
+catch:
+ if (req_key)
+ free(req_key);
+ _LOGE("pkgmgr_client_activate[%s] finish[%d]", pkgid, ret);
+
+ return ret;
+}
+
+API int pkgmgr_client_deactivate(pkgmgr_client *pc, const char *pkg_type, const char *pkgid)
+{
+ _LOGE("pkgmgr_client_deactivate[%s] start", pkgid);
+
+ char *req_key = NULL;
+ int ret = 0;
+ pkgmgrinfo_pkginfo_h handle = NULL;
+
+ /* Check for NULL value of pc */
+ retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
+
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+
+ /* 0. check the pc type */
+ retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST");
+
+ /* 1. check argument */
+ retvm_if(pkgid == NULL, PKGMGR_R_EINVAL, "pkgid is NULL");
+ retvm_if(strlen(pkgid) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "pkgid length over PKG_STRING_LEN_MAX ");
+
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+ // This package is not installed. skip the deactivation event.
+ if ((ret < 0) || (handle == NULL)) {
+ SECURE_LOGD("pkg[%s] is not installed.", pkgid);
+ return PKGMGR_R_OK;
+ }
+
+ /* 2. generate req_key */
+ req_key = __get_req_key(pkgid);
+ tryvm_if(req_key == NULL, ret = PKGMGR_R_ERROR, "req_key is NULL");
+
+ /* 3. request activate */
+ ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_DEACTIVATE_PKG, "pkg", pkgid, NULL, NULL, 1);
+ tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "COMM_REQ_DEACTIVATE_PKG failed, ret=%d", ret);
+
+ ret = PKGMGR_R_OK;
+
+catch:
+ if (req_key)
+ free(req_key);
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ _LOGE("pkgmgr_client_deactivate[%s] finish[%d]", pkgid, ret);
+
+ return ret;
+}
+
+API int pkgmgr_client_activate_app(pkgmgr_client * pc, const char *appid)
+{
+ _LOGE("pkgmgr_client_activate_app[%s] start", appid);
+
+ char *req_key = NULL;
+ int ret = 0;
+ int fd = 0;
+ FILE *fp = NULL;
+ char activation_info_file[PKG_STRING_LEN_MAX] = { 0, };
+
+ /* Check for NULL value of pc */
+ retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
+
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+
+ /* 0. check the pc type */
+ retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST");
+
+ /* 1. check argument */
+ retvm_if(appid == NULL, PKGMGR_R_EINVAL, "pkgid is NULL");
+ retvm_if(strlen(appid) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "pkgid length over PKG_STRING_LEN_MAX ");
+
+ /* 2. generate req_key */
+ req_key = __get_req_key(appid);
+ retvm_if(req_key == NULL, PKGMGR_R_EINVAL, "req_key is NULL");
+
+ snprintf(activation_info_file, PKG_STRING_LEN_MAX, "%s/%s", PKG_DATA_PATH, appid);
+ fp = fopen(activation_info_file, "w");
+ tryvm_if(fp == NULL, ret = PMINFO_R_ERROR, "rev_file[%s] is null\n", activation_info_file);
+
+ fflush(fp);
+ fd = fileno(fp);
+ fsync(fd);
+ fclose(fp);
+
+ /* 3. request activate */
+ ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_ACTIVATE_APP, "pkg", appid, NULL, NULL, 1);
+ tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "COMM_REQ_ACTIVATE_APP failed, ret=%d", ret);
+
+ ret = PKGMGR_R_OK;
+
+catch:
+ if (req_key)
+ free(req_key);
+ _LOGE("pkgmgr_client_activate_app[%s] finish[%d]", appid, ret);
+
+ return ret;
+}
+
+API int pkgmgr_client_activate_appv(pkgmgr_client * pc, const char *appid, char *const argv[])
+{
+ _LOGE("pkgmgr_client_activate_appv[%s] start.", appid);
+
+ char *req_key = NULL;
+ char *args = NULL;
+ int ret = 0;
+ int fd = 0;
+ FILE *fp = NULL;
+ char activation_info_file[PKG_STRING_LEN_MAX] = { 0, };
+
+ /* Check for NULL value of pc */
+ retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
+
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+
+ /* 0. check the pc type */
+ retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST");
+
+ /* 1. check argument */
+ retvm_if(appid == NULL, PKGMGR_R_EINVAL, "pkgid is NULL");
+ retvm_if(strlen(appid) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "pkgid length over PKG_STRING_LEN_MAX ");
+
+ /* 2. generate req_key */
+ req_key = __get_req_key(appid);
+ retvm_if(req_key == NULL, PKGMGR_R_EINVAL, "req_key is NULL");
+
+ snprintf(activation_info_file, PKG_STRING_LEN_MAX, "%s/%s", PKG_DATA_PATH, appid);
+ fp = fopen(activation_info_file, "w");
+ tryvm_if(fp == NULL, ret = PKGMGR_R_ERROR, "fopen failed");
+
+ if(argv) {
+ if (argv[1]) {
+ _LOGE("activate_appv label[%s]", argv[1]);
+ fwrite(argv[1], sizeof(char), strlen(argv[1]), fp);
+
+ args = (char *)calloc(strlen(argv[1]) + 1, sizeof(char));
+ tryvm_if(args == NULL, ret = PKGMGR_R_ERROR, "calloc failed");
+ strncpy(args, argv[1], strlen(argv[1]));
+ }
+ }
+ fflush(fp);
+ fd = fileno(fp);
+ fsync(fd);
+ fclose(fp);
+ fp = NULL;
+
+ /* 3. request activate */
+ ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_ACTIVATE_APP_WITH_LABEL, "pkg", appid, args, NULL, 1);
+ tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "COMM_REQ_ACTIVATE_APP_WITH_LABEL failed, ret=%d", ret);
+
+ ret = PKGMGR_R_OK;
+
+catch:
+
+ if (args)
+ free(args);
+ if (req_key)
+ free(req_key);
+ if (fp)
+ fclose(fp);
+
+ _LOGE("pkgmgr_client_activate_appv[%s] finish[%d]", appid, ret);
+
+ return ret;
+}
+
+API int pkgmgr_client_deactivate_app(pkgmgr_client *pc, const char *appid)
+{
+ _LOGE("pkgmgr_client_deactivate_app[%s] start.", appid);
+
+ char *req_key = NULL;
+ int ret = 0;
+ /* Check for NULL value of pc */
+ retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
+
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+
+ /* 0. check the pc type */
+ retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST");
+
+ /* 1. check argument */
+ retvm_if(appid == NULL, PKGMGR_R_EINVAL, "pkgid is NULL");
+ retvm_if(strlen(appid) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "pkgid length over PKG_STRING_LEN_MAX ");
+
+ /* 2. generate req_key */
+ req_key = __get_req_key(appid);
+ retvm_if(req_key == NULL, PKGMGR_R_EINVAL, "req_key is NULL");
+
+ /* 3. request activate */
+ ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_DEACTIVATE_APP, "pkg", appid, NULL, NULL, 1);
+ tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "COMM_REQ_TO_DEACTIVATOR failed, ret=%d", ret);
+
+ ret = PKGMGR_R_OK;
+
+catch:
+ free(req_key);
+ _LOGE("pkgmgr_client_deactivate_app[%s] finish[%d]", appid, ret);
+ return ret;
+}
+
+
+API int pkgmgr_client_clear_user_data(pkgmgr_client *pc, const char *pkg_type,
+ const char *appid, pkgmgr_mode mode)
+{
+ const char *pkgtype = NULL;
+ char *installer_path = NULL;
+ char *req_key = NULL;
+ int i = 0;
+ char *argv[PKG_ARGC_MAX] = { NULL, };
+ char *args = NULL;
+ int argcnt = 0;
+ int len = 0;
+ char *temp = NULL;
+ int ret = 0;
+ char *cookie = NULL;
+
+ /* Check for NULL value of pc */
+ if (pc == NULL) {
+ _LOGD("package manager client handle is NULL\n");
+ return PKGMGR_R_EINVAL;
+ }
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+
+ /* 0. check the pc type */
+ if (mpc->ctype != PC_REQUEST)
+ return PKGMGR_R_EINVAL;
+
+ /* 1. check argument */
+ if (appid == NULL)
+ return PKGMGR_R_EINVAL;
+
+
+ if (pkg_type == NULL) {
+ pkgtype = _get_pkg_type_from_desktop_file(appid);
+ if (pkgtype == NULL)
+ return PKGMGR_R_EINVAL;
+ } else
+ pkgtype = pkg_type;
+
+ if (strlen(appid) >= PKG_STRING_LEN_MAX)
+ return PKGMGR_R_EINVAL;
+
+ /* 2. get installer path using pkg_path */
+ installer_path = _get_backend_path_with_type(pkgtype);
+ if (installer_path == NULL)
+ return PKGMGR_R_EINVAL;
+
+ /* 3. generate req_key */
+ req_key = __get_req_key(appid);
+
+ /* 4. generate argv */
+
+ /* argv[0] installer path */
+ argv[argcnt++] = installer_path;
+ /* argv[1] */
+ argv[argcnt++] = strdup("-k");
+ /* argv[2] */
+ argv[argcnt++] = req_key;
+ /* argv[3] */
+ argv[argcnt++] = strdup("-c");
+ /* argv[4] */
+ argv[argcnt++] = strdup(appid);
+
+
+ /*** add quote in all string for special charactor like '\n'*** FIX */
+ for (i = 0; i < argcnt; i++) {
+ temp = g_shell_quote(argv[i]);
+ len += (strlen(temp) + 1);
+ g_free(temp);
+ }
+
+ args = (char *)calloc(len, sizeof(char));
+ if (args == NULL) {
+ _LOGD("calloc failed");
+
+ for (i = 0; i < argcnt; i++)
+ free(argv[i]);
+
+ return PKGMGR_R_ERROR;
+ }
+ strncpy(args, argv[0], len - 1);
+
+ for (i = 1; i < argcnt; i++) {
+ strncat(args, " ", strlen(" "));
+ temp = g_shell_quote(argv[i]);
+ strncat(args, temp, strlen(temp));
+ g_free(temp);
+ }
+ _LOGD("[args] %s [len] %d\n", args, len);
+ /******************* end of quote ************************/
+
+ /* 6. request clear */
+ ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_CLEARER, pkgtype, appid, args, cookie, 1);
+ tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "COMM_REQ_TO_CLEARER failed[%d]", ret);
+
+ ret = PKGMGR_R_OK;
+
+catch:
+ for (i = 0; i < argcnt; i++)
+ free(argv[i]);
+
+ if(args)
+ free(args);
+
+ return ret;
+}
+
+API int pkgmgr_client_set_status_type(pkgmgr_client *pc, int status_type)
+{
+ int ret = -1;
+
+ retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client pc is NULL");
+ retvm_if(status_type == PKGMGR_CLIENT_STATUS_ALL, PKGMGR_R_OK, "status_type is PKGMGR_CLIENT_STATUS_ALL");
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+
+ /* free listening head */
+ listen_cb_info *tmp = NULL;
+ listen_cb_info *prev = NULL;
+ for (tmp = mpc->info.listening.lhead; tmp;) {
+ prev = tmp;
+ tmp = tmp->next;
+ free(prev);
+ }
+
+ /* free dbus connection */
+ ret = comm_client_free(mpc->info.listening.cc);
+ retvm_if(ret < 0, PKGMGR_R_ERROR, "comm_client_free() failed - %d", ret);
+
+ /* Manage pc for seperated event */
+ mpc->ctype = PC_LISTENING;
+ mpc->status_type = status_type;
+
+ mpc->info.listening.cc = comm_client_new();
+ retvm_if(mpc->info.listening.cc == NULL, PKGMGR_R_EINVAL, "client creation failed");
+
+ if ((mpc->status_type & PKGMGR_CLIENT_STATUS_INSTALL) == PKGMGR_CLIENT_STATUS_INSTALL) {
+ ret = comm_client_set_status_callback(COMM_STATUS_BROADCAST_INSTALL, mpc->info.listening.cc, __status_callback, pc);
+ retvm_if(ret < 0, PKGMGR_R_ECOMM, "PKGMGR_CLIENT_STATUS_INSTALL failed - %d", ret);
+ }
+
+ if ((mpc->status_type & PKGMGR_CLIENT_STATUS_UNINSTALL) == PKGMGR_CLIENT_STATUS_UNINSTALL) {
+ ret = comm_client_set_status_callback(COMM_STATUS_BROADCAST_UNINSTALL, mpc->info.listening.cc, __status_callback, pc);
+ retvm_if(ret < 0, PKGMGR_R_ECOMM, "COMM_STATUS_BROADCAST_UNINSTALL failed - %d", ret);
+ }
+
+ if ((mpc->status_type & PKGMGR_CLIENT_STATUS_MOVE) == PKGMGR_CLIENT_STATUS_MOVE) {
+ ret = comm_client_set_status_callback(COMM_STATUS_BROADCAST_MOVE, mpc->info.listening.cc, __status_callback, pc);
+ retvm_if(ret < 0, PKGMGR_R_ECOMM, "COMM_STATUS_BROADCAST_MOVE failed - %d", ret);
+ }
+
+ if ((mpc->status_type & PKGMGR_CLIENT_STATUS_INSTALL_PROGRESS) == PKGMGR_CLIENT_STATUS_INSTALL_PROGRESS) {
+ ret = comm_client_set_status_callback(COMM_STATUS_BROADCAST_INSTALL_PROGRESS, mpc->info.listening.cc, __status_callback, pc);
+ retvm_if(ret < 0, PKGMGR_R_ECOMM, "COMM_STATUS_BROADCAST_INSTALL_PROGRESS failed - %d", ret);
+ }
+
+ if ((mpc->status_type & PKGMGR_CLIENT_STATUS_UPGRADE) == PKGMGR_CLIENT_STATUS_UPGRADE) {
+ ret = comm_client_set_status_callback(COMM_STATUS_BROADCAST_UPGRADE, mpc->info.listening.cc, __status_callback, pc);
+ retvm_if(ret < 0, PKGMGR_R_ECOMM, "COMM_STATUS_BROADCAST_UPGRADE failed - %d", ret);
+ }
+
+ if ((mpc->status_type & PKGMGR_CLIENT_STATUS_GET_SIZE) == PKGMGR_CLIENT_STATUS_GET_SIZE) {
+ ret = comm_client_set_status_callback(COMM_STATUS_BROADCAST_GET_SIZE, mpc->info.listening.cc, __status_callback, pc);
+ retvm_if(ret < 0, PKGMGR_R_ECOMM, "COMM_STATUS_BROADCAST_GET_SIZE failed - %d", ret);
+ }
+
+ return PKGMGR_R_OK;
+}
+
+API int pkgmgr_client_listen_status(pkgmgr_client *pc, pkgmgr_handler event_cb,
+ void *data)
+{
+ int req_id;
+ /* Check for NULL value of pc */
+ retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client pc is NULL");
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+
+ /* 0. check input */
+ retvm_if(mpc->ctype != PC_LISTENING, PKGMGR_R_EINVAL, "ctype is not PC_LISTENING");
+ retvm_if(event_cb == NULL, PKGMGR_R_EINVAL, "event_cb is NULL");
+
+ /* 1. get id */
+ req_id = _get_request_id();
+
+ /* 2. add callback info to pkgmgr_client */
+ __add_stat_cbinfo(mpc, req_id, event_cb, data);
+ return req_id;
+}
+
+API int pkgmgr_client_broadcast_status(pkgmgr_client *pc, const char *pkg_type,
+ const char *pkgid, const char *key,
+ const char *val)
+{
+ /* Check for NULL value of pc */
+ if (pc == NULL) {
+ _LOGD("package manager client handle is NULL\n");
+ return PKGMGR_R_EINVAL;
+ }
+ /* Check for valid arguments. NULL parameter causes DBUS to abort */
+ if (pkgid == NULL || pkg_type == NULL || key == NULL || val == NULL) {
+ _LOGD("Argument supplied is NULL\n");
+ return PKGMGR_R_EINVAL;
+ }
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+
+ /* 0. check the pc type */
+ if (mpc->ctype != PC_BROADCAST)
+ return PKGMGR_R_EINVAL;
+
+ comm_status_broadcast_server_send_signal(COMM_STATUS_BROADCAST_ALL, mpc->info.broadcast.bc,
+ PKG_STATUS, pkg_type,
+ pkgid, key, val);
+
+ return PKGMGR_R_OK;
+}
+
+API pkgmgr_info *pkgmgr_client_check_pkginfo_from_file(const char *pkg_path)
+{
+ int ret = PKGMGR_R_OK;
+ char *pkgtype = NULL;
+ pkg_plugin_set *plugin_set = NULL;
+ package_manager_pkg_detail_info_t *pkg_detail_info = NULL;
+
+ retvm_if(pkg_path == NULL, NULL, "pkg_path is NULL");
+
+ pkg_detail_info = calloc(1, sizeof(package_manager_pkg_detail_info_t));
+ retvm_if(pkg_detail_info == NULL, NULL, "pkg_detail_info calloc failed for path[%s]", pkg_path);
+
+ pkgtype = _get_type_from_zip(pkg_path);
+ tryvm_if(pkgtype == NULL, ret = PKGMGR_R_ERROR, "type is NULL for path[%s]", pkg_path);
+
+ plugin_set = _package_manager_load_library(pkgtype);
+ tryvm_if(plugin_set == NULL, ret = PKGMGR_R_ERROR, "load_library failed for path[%s]", pkg_path);
+
+ ret = plugin_set->get_pkg_detail_info_from_package(pkg_path, pkg_detail_info);
+ tryvm_if(ret != 0, ret = PKGMGR_R_ERROR, "get_pkg_detail_info_from_package failed for path[%s]", pkg_path);
+
+ ret = PKGMGR_R_OK;
+
+catch:
+ if (pkgtype)
+ free(pkgtype);
+
+ if (ret < 0) {
+ free(pkg_detail_info);
+ return NULL;
+ } else {
+ return (pkgmgr_info *) pkg_detail_info;
+ }
+}
+
+API int pkgmgr_client_free_pkginfo(pkgmgr_info * pkg_info)
+{
+ if (pkg_info == NULL)
+ return PKGMGR_R_EINVAL;
+
+ package_manager_pkg_detail_info_t *info = (package_manager_pkg_detail_info_t *)pkg_info;
+
+ if (info->icon_buf)
+ free(info->icon_buf);
+
+ free(info);
+ info = NULL;
+
return PKGMGR_R_OK;
}
-API int pkgmgr_get_pkginfo_preload(pkgmgr_pkginfo_h handle, bool *preload)
-{
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PKGMGR_R_EINVAL;
+API int pkgmgr_client_request_service(pkgmgr_request_service_type service_type, int service_mode,
+ pkgmgr_client * pc, const char *pkg_type, const char *pkgid,
+ const char *custom_info, pkgmgr_handler event_cb, void *data)
+{
+ int ret =0;
+
+ /* Check for NULL value of service type */
+ retvm_if(service_type > PM_REQUEST_MAX, PKGMGR_R_EINVAL, "service type is not defined\n");
+ retvm_if(service_type < 0, PKGMGR_R_EINVAL, "service type is error\n");
+
+ switch (service_type) {
+ case PM_REQUEST_CSC:
+ tryvm_if(custom_info == NULL, ret = PKGMGR_R_EINVAL, "custom_info is NULL\n");
+ tryvm_if(strlen(custom_info) >= PKG_STRING_LEN_MAX, ret = PKGMGR_R_EINVAL, "optional_file over PKG_STRING_LEN_MAX");
+ tryvm_if(data == NULL, ret = PKGMGR_R_EINVAL, "data is NULL\n");
+
+ ret = __csc_process(custom_info, (char *)data);
+ if (ret < 0)
+ _LOGE("__csc_process fail \n");
+ else
+ ret = PKGMGR_R_OK;
+
+ break;
+
+ case PM_REQUEST_MOVE:
+ tryvm_if(pkgid == NULL, ret = PKGMGR_R_EINVAL, "pkgid is NULL\n");
+ tryvm_if(pc == NULL, ret = PKGMGR_R_EINVAL, "pc is NULL\n");
+ tryvm_if((service_mode < PM_MOVE_TO_INTERNAL) || (service_mode > PM_MOVE_TO_SDCARD), ret = PKGMGR_R_EINVAL, "service_mode[%d] is wrong\n", service_mode);
+
+ ret = __move_pkg_process(pc, pkgid, (pkgmgr_move_type)service_mode, event_cb, data);
+ break;
+
+ case PM_REQUEST_GET_SIZE:
+ tryvm_if(pkgid == NULL, ret = PKGMGR_R_EINVAL, "pkgid is NULL\n");
+ tryvm_if(pc == NULL, ret = PKGMGR_R_EINVAL, "pc is NULL\n");
+ tryvm_if((service_mode < PM_GET_TOTAL_SIZE) || (service_mode >= PM_GET_MAX), ret = PKGMGR_R_EINVAL, "service_mode[%d] is wrong\n", service_mode);
+
+ ret = __get_size_process(pc, pkgid, (pkgmgr_getsize_type)service_mode, event_cb, data);
+ break;
+
+ case PM_REQUEST_KILL_APP:
+ case PM_REQUEST_CHECK_APP:
+ tryvm_if(pkgid == NULL, ret = PKGMGR_R_EINVAL, "pkgid is NULL\n");
+ tryvm_if(pc == NULL, ret = PKGMGR_R_EINVAL, "pc is NULL\n");
+
+ ret = __check_app_process(service_type, pc, pkgid, data);
+ if (ret < 0)
+ _LOGE("__check_app_process fail \n");
+ else
+ ret = PKGMGR_R_OK;
+
+ break;
+
+ default:
+ _LOGE("Wrong Request\n");
+ ret = -1;
+ break;
+ }
+
+catch:
+
+ return ret;
+}
+
+API int pkgmgr_client_request_size_info(void) // get all package size (data, total)
+{
+ int ret = 0;
+ pkgmgr_client *pc = NULL;
+
+ pc = pkgmgr_client_new(PC_REQUEST);
+ retvm_if(pc == NULL, PKGMGR_R_EINVAL, "request pc is null\n");
+
+ ret = __request_size_info(pc);
+ if (ret < 0) {
+ _LOGE("__request_size_info fail \n");
+ }
+
+ pkgmgr_client_free(pc);
+ return ret;
+}
+
+API int pkgmgr_client_clear_cache_dir(const char *pkgid)
+{
+ retvm_if(pkgid == NULL, PKGMGR_R_EINVAL, "package id is null\n");
+
+ int ret = 0;
+ pkgmgr_client_t *pc = NULL;
+ char *pkg_type = NULL;
+ char *cookie = NULL;
+ int is_type_malloced = 0;
+
+ pkgmgrinfo_pkginfo_h handle = NULL;
+
+ pc = pkgmgr_client_new(PC_REQUEST);
+ retvm_if(pc == NULL, PKGMGR_R_ESYSTEM, "request pc is null\n");
+
+ if (strcmp(pkgid, PKG_CLEAR_ALL_CACHE) != 0)
+ {
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+ tryvm_if(ret < 0, ret = PKGMGR_R_ENOPKG, "pkgmgr_pkginfo_get_pkginfo failed");
+
+ ret = pkgmgrinfo_pkginfo_get_type(handle, &pkg_type);
+ tryvm_if(ret < 0, ret = PKGMGR_R_ESYSTEM, "pkgmgr_pkginfo_get_type failed");
+ }
+ else
+ {
+ pkg_type = (char *)malloc(strlen("rpm") + 1);
+ tryvm_if(pkg_type == NULL, ret = PKGMGR_R_ENOMEM, "out of memory");
+
+ strcpy(pkg_type, "rpm");
+ is_type_malloced = 1;
+ }
+
+ cookie = __get_cookie_from_security_server();
+ tryvm_if(cookie == NULL, ret = PKGMGR_R_ESYSTEM, "__get_cookie_from_security_server is NULL");
+
+ ret = comm_client_request(pc->info.request.cc, NULL, COMM_REQ_CLEAR_CACHE_DIR, pkg_type, pkgid, NULL, cookie, 0);
+ tryvm_if(ret < 0, ret = PKGMGR_R_ERROR, "COMM_REQ_CLEAR_CACHE_DIR failed, ret=%d\n", ret);
+
+ ret = PKGMGR_R_OK;
+catch:
+ if (cookie)
+ free(cookie);
+
+ if (pc)
+ pkgmgr_client_free(pc);
+
+ if(is_type_malloced)
+ free(pkg_type);
+
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+
+ return ret;
+}
+
+API int pkgmgr_client_clear_all_cache_dir(void)
+{
+ int ret = 0;
+ ret = pkgmgr_client_clear_cache_dir(PKG_CLEAR_ALL_CACHE);
+ return ret;
+}
+
+API int pkgmgr_client_get_size(pkgmgr_client *pc, const char *pkgid, pkgmgr_getsize_type get_type, pkgmgr_handler event_cb, void *data)
+{
+ char *req_key = NULL;
+ int req_id = 0;
+ int ret = 0;
+
+ retvm_if(pc == NULL, PKGMGR_R_EINVAL, "The specified pc is NULL.");
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+
+ retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST\n");
+ retvm_if(event_cb == NULL, PKGMGR_R_EINVAL, "event_cb is NULL\n");
+ retvm_if(pkgid == NULL, PKGMGR_R_EINVAL, "pkgid is NULL\n");
+
+ ret = __change_op_cb_for_getsize(mpc);
+ retvm_if(ret < 0 , PKGMGR_R_EINVAL, "__change_op_cb_for_getsize is fail");
+
+ req_key = __get_req_key(pkgid);
+ retvm_if(req_key == NULL, PKGMGR_R_EINVAL, "req_key is NULL");
+
+ req_id = _get_request_id();
+ __add_op_cbinfo(mpc, req_id, req_key, event_cb, NULL, data);
+
+ ret = __get_package_size_info(mpc, req_key, pkgid, get_type);
+
+ return ret;
+}
+
+API int pkgmgr_client_get_package_size_info(pkgmgr_client *pc, const char *pkgid, pkgmgr_pkg_size_info_receive_cb event_cb, void *user_data)
+{
+ pkgmgrinfo_pkginfo_h pkginfo = NULL;
+ char *req_key = NULL;
+ int req_id = 0;
+ int res = 0;
+ int type = PM_GET_PKG_SIZE_INFO;
+
+ retvm_if(pc == NULL, PKGMGR_R_EINVAL, "The specified pc is NULL.");
+ retvm_if(pkgid == NULL, PKGMGR_R_EINVAL, "The package id is NULL.");
+
+ if (strcmp(pkgid, PKG_SIZE_INFO_TOTAL) == 0)
+ { // total package size info
+ type = PM_GET_TOTAL_PKG_SIZE_INFO;
+ }
+ else
+ {
+ res = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &pkginfo);
+ retvm_if(res != 0, PKGMGR_R_ENOPKG, "The package id is not installed.");
+
+ if (pkginfo) {
+ pkgmgrinfo_pkginfo_destroy_pkginfo(pkginfo);
+ }
+ }
+
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *)pc;
+ retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST");
+
+ res = __change_op_cb_for_getsize(mpc);
+ retvm_if(res < 0 , PKGMGR_R_ESYSTEM, "__change_op_cb_for_getsize is fail");
+
+ req_key = __get_req_key(pkgid);
+ retvm_if(req_key == NULL, PKGMGR_R_ESYSTEM, "req_key is NULL");
+
+ req_id = _get_request_id();
+ __add_op_cbinfo(mpc, req_id, req_key, __get_pkg_size_info_cb, event_cb, user_data);
+
+ res = __get_package_size_info(mpc, req_key, pkgid, type);
+
+ return res;
+}
+
+API int pkgmgr_client_get_total_package_size_info(pkgmgr_client *pc, pkgmgr_total_pkg_size_info_receive_cb event_cb, void *user_data)
+{ // total package size info
+ return pkgmgr_client_get_package_size_info(pc, PKG_SIZE_INFO_TOTAL, (pkgmgr_pkg_size_info_receive_cb)event_cb, user_data);
+}
+
+API int junkmgr_get_junk_root_dirs(junkmgr_h junkmgr, junkmgr_result_receive_cb result_cb, void *user_data, int *reqid)
+{
+ if (!junkmgr)
+ {
+ LOGE("Invalid argument");
+ return JUNKMGR_E_INVALID;
+ }
+
+ junkmgr_info_s *junk_info = (junkmgr_info_s *)malloc(sizeof(junkmgr_info_s));
+ if (junk_info == NULL)
+ {
+ LOGE("out of memory");
+ return JUNKMGR_E_NOMEM;
+ }
+
+ junk_info->junk_req_type = 0;
+ junk_info->junk_storage = 2;
+ junk_info->junk_root = NULL;
+
+ return __get_junk_info((junkmgr_s *)junkmgr, NULL, junk_info, (void *)result_cb, user_data, reqid);
+}
+
+API int junkmgr_get_junk_files(junkmgr_h junkmgr, char const *junk_path, junkmgr_result_receive_cb result_cb, void *user_data, int *reqid)
+{
+ char *entry = NULL;
+ struct stat st;
+ int storage = -1; //0: internal, 1: external, 2: all
+ char *name = NULL;
+ char filename[MAX_FILENAME_SIZE] = { 0, };
+ int delimiter = 0;
+
+ if (!junkmgr || !junk_path)
+ {
+ LOGE("Invalid argument");
+ return JUNKMGR_E_INVALID;
+ }
+
+ entry = strstr(junk_path, "/opt/usr/media/");
+ if (entry)
+ {
+ LOGD("junk entry: %s", entry);
+ storage = 0;
+ }
+ else
+ {
+ entry = strstr(junk_path, "/opt/storage/sdcard/");
+ if (entry)
+ {
+ LOGD("junk entry: %s", entry);
+ storage = 1;
+ }
+ else
+ {
+ LOGE("Invalid junk file path");
+ return JUNKMGR_E_INVALID;
+ }
+ }
+
+ stat(junk_path, &st);
+ if (!S_ISDIR(st.st_mode))
+ {
+ LOGE("This is not directory.");
+ return JUNKMGR_E_INVALID;
+ }
+
+ name = (char *)g_strrstr(junk_path, "/");
+ if (name && strlen(name) == 1)
+ {
+ name = (char *)g_strrstr(entry, "/");
+ delimiter = 1;
+ }
+
+ if (NULL == name + 1)
+ {
+ LOGE("Invalid name.");
+ return JUNKMGR_E_INVALID;
+ }
+
+ strncpy(filename, name + 1, MAX_FILENAME_SIZE);
+ if (delimiter) {
+ filename[strlen(filename) - 1] = '\0';
+ }
+
+ junkmgr_info_s *junk_info = (junkmgr_info_s *)malloc(sizeof(junkmgr_info_s));
+ if (junk_info == NULL)
+ {
+ LOGE("out of memory");
+ return JUNKMGR_E_NOMEM;
+ }
+
+ junk_info->junk_req_type = 1;
+ junk_info->junk_storage = storage;
+ junk_info->junk_root = strdup(filename);
+
+ return __get_junk_info((junkmgr_s *)junkmgr, junk_path, junk_info, (void *)result_cb, user_data, reqid);
+}
+
+API int junkmgr_remove_junk_file(junkmgr_h junkmgr, char const *junk_path)
+{
+ struct stat st;
+
+ if (!junkmgr)
+ {
+ LOGE("Invalid argument");
+ return JUNKMGR_E_INVALID;
+ }
+
+ junkmgr_s *junk_mgr = (junkmgr_s *)junkmgr;
+ if (!junk_mgr->db_path)
+ {
+ LOGE("Invalid argument");
+ return JUNKMGR_E_INVALID;
+ }
+
+ stat(junk_path, &st);
+ if (S_ISDIR(st.st_mode))
+ {
+ LOGE("This is directory.");
+ return JUNKMGR_E_INVALID;
+ }
+
+ return __remove_junk_file(junk_mgr->db_path, junk_path);
+}
+
+static int __clear_all_junk_files(junkmgr_s *junkmgr, junkmgr_clear_completed_cb result_cb, void *user_data, int *reqid)
+{
+ junkmgr_info_s *junk_info = (junkmgr_info_s *)malloc(sizeof(junkmgr_info_s));
+ if (junk_info == NULL)
+ {
+ LOGE("out of memory");
+ return JUNKMGR_E_NOMEM;
+ }
+
+ junk_info->junk_req_type = 2;
+ junk_info->junk_storage = 2;
+ junk_info->junk_root = NULL;
+
+ return __get_junk_info((junkmgr_s *)junkmgr, NULL/*all*/, junk_info, (void *)result_cb, user_data, reqid);
+}
+
+API int junkmgr_clear_all_junk_files(junkmgr_h junkmgr, junkmgr_clear_completed_cb result_cb, void *user_data, int *reqid)
+{
+ if (!junkmgr)
+ {
+ LOGE("Invalid argument");
+ return JUNKMGR_E_INVALID;
+ }
+
+ junkmgr_s *junk_mgr = (junkmgr_s *)junkmgr;
+ if (!junk_mgr->db_path)
+ {
+ LOGE("Invalid argument");
+ return JUNKMGR_E_INVALID;
+ }
+
+ return __clear_all_junk_files((junkmgr_s *)junkmgr, result_cb, user_data, reqid);
+}
+
+API int pkgmgr_client_enable_pkg(const char *pkgid)
+{
+ retvm_if(pkgid == NULL, PKGMGR_R_EINVAL, "pkgid is NULL");
+
+ int ret = 0;
+ pkgmgrinfo_pkginfo_h handle = NULL;
+
+ if (strstr(pkgid,":")==NULL) {
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+ if ((ret == 0) && (handle != NULL)) {
+ SECURE_LOGD("pkg[%s] is already installed.", pkgid);
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ // This package is already installed. skip the activation event.
+ return PKGMGR_R_OK;
+ }
+ }
+
+ const char *enable_argv[] = { "/usr/bin/rpm-backend", "-k", "change-state", "-i", pkgid, NULL };
+ ret = __xsystem(enable_argv);
+ if (ret < 0)
+ SECURE_LOGD("enable pkg[%s] failed\n", pkgid);
+ else
+ SECURE_LOGD("enable pkg[%s] success\n", pkgid);
+ return ret;
+}
+
+API int pkgmgr_client_disable_pkg(const char *pkgid)
+{
+ retvm_if(pkgid == NULL, PKGMGR_R_EINVAL, "pkgid is NULL");
+
+ int ret = 0;
+ pkgmgrinfo_pkginfo_h handle = NULL;
+
+ if (strstr(pkgid,":")==NULL) {
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+ // This package is not installed. skip the deactivation event.
+ if ((ret < 0) || (handle == NULL)) {
+ SECURE_LOGD("pkg[%s] is not installed.", pkgid);
+ return PKGMGR_R_OK;
+ }
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ }
+
+ const char *disable_argv[] = { "/usr/bin/rpm-backend", "-k", "change-state", "-d", pkgid, NULL };
+ ret = __xsystem(disable_argv);
+ if (ret < 0)
+ SECURE_LOGD("disable pkg[%s] failed\n", pkgid);
+ else
+ SECURE_LOGD("disable pkg[%s] success\n", pkgid);
+ return ret;
+}
+
+API int pkgmgr_client_reset_device(void)
+{
+ int ret = 0;
+ PKGMGR_BEGIN();
+
+ __pkgmgr_log_init();
+
+ //0. check authorized
+ uid_t uid = getuid();
+ retvm_if(uid != (uid_t)0, PKGMGR_R_ERROR, "You are not an authorized user!!!\n");
+
+ // display ui
+ const char *displayui_argv[] = { "/usr/etc/package-manager/pkgmgr-soft-reset-ui.sh", NULL };
+ __xsystem(displayui_argv);
+
+ //1. uninstall download package
+ __uninstall_downloaded_packages();
+
+ //2. pkg db rollback form opt.zip
+// __recovery_pkgmgr_db();
+
+ //3. delete pkg directory, data and make new
+ __soft_reset_pkg();
+
+ //4. apply support reset script
+ __none_reset_pkg();
+
+ //5. run pkg's script
+ __run_reset_script();
+
+ __pkgmgr_log_deinit();
+
+ PKGMGR_END();
+
+ const char *reboot_cmd[] = {"/usr/sbin/reboot", NULL, NULL};
+ __xsystem(reboot_cmd);
+
+ return ret;
+}
+
+#define __START_OF_OLD_API
+API pkgmgr_info *pkgmgr_info_new(const char *pkg_type, const char *pkgid)
+{
+ const char *pkgtype;
+ pkg_plugin_set *plugin_set = NULL;
+ package_manager_pkg_detail_info_t *pkg_detail_info = NULL;
+
+ /* 1. check argument */
+ if (pkgid == NULL)
+ return NULL;
+
+ if (pkg_type == NULL) {
+ pkgtype = _get_pkg_type_from_desktop_file(pkgid);
+ if (pkgtype == NULL)
+ return NULL;
+ } else
+ pkgtype = pkg_type;
+
+ if (strlen(pkgid) >= PKG_STRING_LEN_MAX)
+ return NULL;
+
+ pkg_detail_info = calloc(1, sizeof(package_manager_pkg_detail_info_t));
+ if (pkg_detail_info == NULL) {
+ _LOGE("*** Failed to alloc package_handler_info.\n");
+ return NULL;
}
- if (preload == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PKGMGR_R_EINVAL;
+
+ plugin_set = _package_manager_load_library(pkgtype);
+ if (plugin_set == NULL) {
+ _LOGE("*** Failed to load library");
+ free(pkg_detail_info);
+ return NULL;
}
- char *val = NULL;
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
- val = (char *)info->manifest_info->preload;
- if (val) {
- if (strcasecmp(val, "true") == 0)
- *preload = 1;
- else if (strcasecmp(val, "false") == 0)
- *preload = 0;
- else
- *preload = 0;
+
+ if (plugin_set->pkg_is_installed) {
+ if (plugin_set->pkg_is_installed(pkgid) != 0) {
+ _LOGE("*** Failed to call pkg_is_installed()");
+ free(pkg_detail_info);
+ return NULL;
+ }
+
+ if (plugin_set->get_pkg_detail_info) {
+ if (plugin_set->get_pkg_detail_info(pkgid,
+ pkg_detail_info) != 0) {
+ _LOGE("*** Failed to call get_pkg_detail_info()");
+ free(pkg_detail_info);
+ return NULL;
+ }
+ }
}
- return PKGMGR_R_OK;
+
+ return (pkgmgr_info *) pkg_detail_info;
}
-API int pkgmgr_get_pkginfo_readonly(pkgmgr_pkginfo_h handle, bool *readonly)
+API char * pkgmgr_info_get_string(pkgmgr_info * pkg_info, const char *key)
{
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- if (readonly == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
+ package_manager_pkg_detail_info_t *pkg_detail_info;
+
+ if (pkg_info == NULL)
+ return NULL;
+ if (key == NULL)
+ return NULL;
+
+ pkg_detail_info = (package_manager_pkg_detail_info_t *) pkg_info;
+
+ return _get_info_string(key, pkg_detail_info);
+}
+
+API int pkgmgr_info_free(pkgmgr_info * pkg_info)
+{
+ if (pkg_info == NULL)
return PKGMGR_R_EINVAL;
- }
- char *val = NULL;
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
- val = (char *)info->manifest_info->readonly;
- if (val) {
- if (strcasecmp(val, "true") == 0)
- *readonly = 1;
- else if (strcasecmp(val, "false") == 0)
- *readonly = 0;
- else
- *readonly = 0;
- }
- return PKGMGR_R_OK;
+
+ free(pkg_info);
+ pkg_info = NULL;
+
+ return 0;
}
+#define __END_OF_OLD_API
-API int pkgmgr_get_pkginfo_exec(pkgmgr_appinfo_h handle, char **exec)
+API int pkgmgr_pkginfo_get_pkginfo(const char *pkgid, pkgmgr_pkginfo_h *handle)
{
- if (handle == NULL) {
- _LOGE("appinfo handle is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- if (exec == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
- if (info->app_component) {
- if (strcasecmp(info->app_component, "uiapp") == 0)
- *exec = (char *)info->uiapp_info->exec;
- if (strcasecmp(info->app_component, "svcapp") == 0)
- *exec = (char *)info->svcapp_info->exec;
- }
- return PKGMGR_R_OK;
+ int ret = 0;
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, handle);
+ return ret;
}
-API int pkgmgr_get_pkginfo_component(pkgmgr_appinfo_h handle, char **component)
+API int pkgmgr_pkginfo_get_label(pkgmgr_pkginfo_h handle, char **label)
{
- if (handle == NULL) {
- _LOGE("appinfo handle is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- if (component == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
- *component = (char *)info->app_component;
- return PKGMGR_R_OK;
+ int ret = 0;
+ ret = pkgmgrinfo_pkginfo_get_label(handle, label);
+ return ret;
}
-API int pkgmgr_get_pkginfo_apptype(pkgmgr_appinfo_h handle, char **app_type)
+API int pkgmgr_pkginfo_destroy_pkginfo(pkgmgr_pkginfo_h handle)
{
- if (handle == NULL) {
- _LOGE("appinfo handle is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- if (app_type == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
- if (info->app_component) {
- if (strcasecmp(info->app_component, "uiapp") == 0)
- *app_type = (char *)info->uiapp_info->type;
- if (strcasecmp(info->app_component, "svcapp") == 0)
- *app_type = (char *)info->svcapp_info->type;
- }
- return PKGMGR_R_OK;
+ int ret = 0;
+ ret = pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ return ret;
}
-API int pkgmgr_get_pkginfo_nodisplay(pkgmgr_appinfo_h handle, bool *nodisplay)
+API int pkgmgr_appinfo_get_list(pkgmgr_pkginfo_h handle, pkgmgr_app_component component,
+ pkgmgr_info_app_list_cb app_func, void *user_data)
{
- if (handle == NULL) {
- _LOGE("appinfo handle is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- if (nodisplay == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- char *val = NULL;
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
- val = (char *)info->uiapp_info->nodisplay;
- if (val) {
- if (strcasecmp(val, "true") == 0)
- *nodisplay = 1;
- else if (strcasecmp(val, "false") == 0)
- *nodisplay = 0;
- else
- *nodisplay = 0;
- }
- return PKGMGR_R_OK;
+ int ret = 0;
+ ret = pkgmgrinfo_appinfo_get_list(handle, component, app_func, user_data);
+ return ret;
}
-API int pkgmgr_get_pkginfo_multiple(pkgmgr_appinfo_h handle, bool *multiple)
+API int pkgmgr_appinfo_get_appinfo(const char *appid, pkgmgr_appinfo_h *handle)
{
- if (handle == NULL) {
- _LOGE("appinfo handle is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- if (multiple == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- char *val = NULL;
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
- val = (char *)info->uiapp_info->multiple;
- if (val) {
- if (strcasecmp(val, "true") == 0)
- *multiple = 1;
- else if (strcasecmp(val, "false") == 0)
- *multiple = 0;
- else
- *multiple = 0;
- }
- return PKGMGR_R_OK;
+ int ret = 0;
+ ret = pkgmgrinfo_appinfo_get_appinfo(appid, handle);
+ return ret;
}
-API int pkgmgr_get_pkginfo_onboot(pkgmgr_appinfo_h handle, bool *onboot)
+API int pkgmgr_appinfo_get_appid(pkgmgr_appinfo_h handle, char **appid)
{
- if (handle == NULL) {
- _LOGE("appinfo handle is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- if (onboot == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- char *val = NULL;
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
- val = (char *)info->svcapp_info->onboot;
- if (val) {
- if (strcasecmp(val, "true") == 0)
- *onboot = 1;
- else if (strcasecmp(val, "false") == 0)
- *onboot = 0;
- else
- *onboot = 0;
- }
- return PKGMGR_R_OK;
+ int ret = 0;
+ ret = pkgmgrinfo_appinfo_get_appid(handle, appid);
+ return ret;
}
-API int pkgmgr_get_pkginfo_autorestart(pkgmgr_appinfo_h handle, bool *autorestart)
+API int pkgmgr_appinfo_get_pkgname(pkgmgr_appinfo_h handle, char **pkg_name)
{
- if (handle == NULL) {
- _LOGE("appinfo handle is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- if (autorestart == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- char *val = NULL;
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
- val = (char *)info->svcapp_info->autorestart;
- if (val) {
- if (strcasecmp(val, "true") == 0)
- *autorestart = 1;
- else if (strcasecmp(val, "false") == 0)
- *autorestart = 0;
- else
- *autorestart = 0;
- }
- return PKGMGR_R_OK;
+ int ret = 0;
+ ret = pkgmgrinfo_appinfo_get_pkgname(handle, pkg_name);
+ return ret;
}
-API int pkgmgr_get_pkginfo_taskmanage(pkgmgr_appinfo_h handle, bool *taskmanage)
+API int pkgmgr_appinfo_destroy_appinfo(pkgmgr_appinfo_h handle)
{
- if (handle == NULL) {
- _LOGE("appinfo handle is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- if (taskmanage == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- char *val = NULL;
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
- val = (char *)info->uiapp_info->taskmanage;
- if (val) {
- if (strcasecmp(val, "true") == 0)
- *taskmanage = 1;
- else if (strcasecmp(val, "false") == 0)
- *taskmanage = 0;
- else
- *taskmanage = 0;
- }
- return PKGMGR_R_OK;
+ int ret = 0;
+ ret = pkgmgrinfo_appinfo_destroy_appinfo(handle);
+ return ret;
}
-API int pkgmgr_get_pkginfo(const char *pkg_name, pkgmgr_pkginfo_h *handle)
+API int pkgmgr_pkginfo_create_certinfo(pkgmgr_certinfo_h *handle)
{
- if (pkg_name == NULL) {
- _LOGE("package name is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- if (handle == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- pkgmgr_pkginfo_x *pkginfo = NULL;
- char *error_message = NULL;
- int ret = PKGMGR_R_OK;
- char query[MAX_QUERY_LEN] = {'\0'};
- char *syslocale = NULL;
- char *locale = NULL;
- int exist = 0;
- label_x *tmp1 = NULL;
- icon_x *tmp2 = NULL;
- description_x *tmp3 = NULL;
- author_x *tmp4 = NULL;
-
- /*validate pkgname*/
- ret = __open_manifest_db();
- if (ret == -1) {
- _LOGE("Fail to open manifest DB\n");
- ret = PKGMGR_R_ERROR;
- goto err;
- }
- snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_info where package='%s')", pkg_name);
- if (SQLITE_OK !=
- sqlite3_exec(manifest_db, query, __validate_cb, (void *)&exist, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- sqlite3_close(manifest_db);
- return PKGMGR_R_ERROR;
- }
- if (exist == 0) {
- _LOGE("Package not found in DB\n");
- ret = PKGMGR_R_ERROR;
- goto err;
- }
+ int ret = 0;
+ ret = pkgmgrinfo_pkginfo_create_certinfo(handle);
+ return ret;
+}
- syslocale = vconf_get_str(VCONFKEY_LANGSET);
- if (syslocale == NULL) {
- _LOGE("current locale is NULL\n");
- ret = PKGMGR_R_ERROR;
- goto err;
- }
- locale = __convert_system_locale_to_manifest_locale(syslocale);
- if (locale == NULL) {
- _LOGE("manifest locale is NULL\n");
- ret = PKGMGR_R_EINVAL;
- goto err;
- }
- pkginfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
- if (pkginfo == NULL) {
- _LOGE("Failed to allocate memory for pkginfo\n");
- return PKGMGR_R_ERROR;
- }
- pkginfo->pkg_handle_id = __pkgmgr_pkginfo_new_handle_id();
- pkginfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
- if (pkginfo->manifest_info == NULL) {
- _LOGE("Failed to allocate memory for manifest info\n");
- ret = PKGMGR_R_ERROR;
- goto err;
- }
- pkginfo->manifest_info->package = strdup(pkg_name);
- /*populate manifest_info from DB*/
- snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkg_name);
- ret = __exec_pkginfo_query(query, (void *)pkginfo);
- if (ret == -1) {
- _LOGE("Package Info DB Information retrieval failed\n");
- ret = PKGMGR_R_ERROR;
- goto err;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
- " package='%s' and package_locale='%s'", pkg_name, locale);
- ret = __exec_pkginfo_query(query, (void *)pkginfo);
- if (ret == -1) {
- _LOGE("Package Info DB Information retrieval failed\n");
- ret = PKGMGR_R_ERROR;
- goto err;
- }
- /*Also store the values corresponding to default locales*/
- memset(query, '\0', MAX_QUERY_LEN);
- snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
- " package='%s' and package_locale='%s'", pkg_name, DEFAULT_LOCALE);
- ret = __exec_pkginfo_query(query, (void *)pkginfo);
- if (ret == -1) {
- _LOGE("Package Info DB Information retrieval failed\n");
- ret = PKGMGR_R_ERROR;
- goto err;
- }
- if (pkginfo->manifest_info->label) {
- LISTHEAD(pkginfo->manifest_info->label, tmp1);
- pkginfo->manifest_info->label = tmp1;
- }
- if (pkginfo->manifest_info->icon) {
- LISTHEAD(pkginfo->manifest_info->icon, tmp2);
- pkginfo->manifest_info->icon = tmp2;
- }
- if (pkginfo->manifest_info->description) {
- LISTHEAD(pkginfo->manifest_info->description, tmp3);
- pkginfo->manifest_info->description = tmp3;
- }
- if (pkginfo->manifest_info->author) {
- LISTHEAD(pkginfo->manifest_info->author, tmp4);
- pkginfo->manifest_info->author = tmp4;
- }
- *handle = (void *)pkginfo;
- sqlite3_close(manifest_db);
- if (syslocale) {
- free(syslocale);
- syslocale = NULL;
- }
- if (locale) {
- free(locale);
- locale = NULL;
- }
- return PKGMGR_R_OK;
+API int pkgmgr_pkginfo_load_certinfo(const char *pkgid, pkgmgr_certinfo_h handle)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_pkginfo_load_certinfo(pkgid, handle);
+ return ret;
+}
-err:
- *handle = NULL;
- __cleanup_pkginfo(pkginfo);
- sqlite3_close(manifest_db);
- if (syslocale) {
- free(syslocale);
- syslocale = NULL;
- }
- if (locale) {
- free(locale);
- locale = NULL;
- }
+API int pkgmgr_pkginfo_get_cert_value(pkgmgr_certinfo_h handle, pkgmgr_cert_type cert_type, const char **cert_value)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_pkginfo_get_cert_value(handle, cert_type, cert_value);
return ret;
}
-API int pkgmgr_get_info_list(pkgmgr_iter_fn iter_fn, void *user_data)
+API int pkgmgr_pkginfo_destroy_certinfo(pkgmgr_certinfo_h handle)
{
- if (iter_fn == NULL) {
- _LOGE("callback function is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- char *error_message = NULL;
- int ret = -1;
- char query[MAX_QUERY_LEN] = {'\0'};
+ int ret = 0;
+ ret = pkgmgrinfo_pkginfo_destroy_certinfo(handle);
+ return ret;
+}
- ret = __open_manifest_db();
- if (ret == -1) {
- _LOGE("Fail to open manifest DB\n");
- return PKGMGR_R_ERROR;
- }
- iter_data *udata = calloc(1, sizeof(iter_data));
- if (udata == NULL) {
- _LOGE("calloc failed");
- sqlite3_close(manifest_db);
- return PKGMGR_R_ERROR;
- }
- udata->iter_fn = iter_fn;
- udata->data = user_data;
- snprintf(query, MAX_QUERY_LEN, "select * from package_info");
- if (SQLITE_OK !=
- sqlite3_exec(manifest_db, query, __pkg_list_cb, (void *)udata, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- sqlite3_close(manifest_db);
- return PKGMGR_R_ERROR;
- }
- sqlite3_close(manifest_db);
- return PKGMGR_R_OK;
+API int junkmgr_result_cursor_step_next(junkmgr_result_h hnd)
+{
+ junkmgr_result_s *handle = (junkmgr_result_s *)hnd;
+
+ int ret = sqlite3_step((sqlite3_stmt *)(handle->db_stmt));
+ switch (ret)
+ {
+ case SQLITE_ROW:
+ return JUNKMGR_E_SUCCESS;
+ case SQLITE_DONE:
+ return JUNKMGR_E_END_OF_RESULT;
+ case SQLITE_BUSY:
+ return JUNKMGR_E_OBJECT_LOCKED;
+ default:
+ return JUNKMGR_E_SYSTEM;
+ }
+
+ return JUNKMGR_E_SYSTEM;
}
-API int pkgmgr_get_info_app(pkgmgr_pkginfo_h handle, pkgmgr_app_component component,
- pkgmgr_info_app_list_cb app_func, void *user_data)
+API int junkmgr_result_cursor_get_junk_name(junkmgr_result_h hnd, char **junk_name)
{
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- if (app_func == NULL) {
- _LOGE("callback pointer is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- if (component != PM_UI_APP && component != PM_SVC_APP) {
- _LOGE("Invalid App Component Type\n");
- return PKGMGR_R_EINVAL;
- }
- char *error_message = NULL;
- int ret = -1;
- char query[MAX_QUERY_LEN] = {'\0'};
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
- pkgmgr_appinfo_x *appinfo = NULL;
+ junkmgr_result_s *handle = (junkmgr_result_s *)hnd;
- appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
- if (appinfo == NULL) {
- _LOGE("Failed to allocate memory for appinfo\n");
- return PKGMGR_R_ERROR;
- }
- if (component == PM_UI_APP)
- appinfo->app_component = strdup("uiapp");
- if (component == PM_SVC_APP)
- appinfo->app_component = strdup("svcapp");
- ret = __open_manifest_db();
- if (ret == -1) {
- _LOGE("Fail to open manifest DB\n");
- return PKGMGR_R_ERROR;
- }
- snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where package='%s' and app_component='%s'", info->manifest_info->package, appinfo->app_component);
- switch(component) {
- case PM_UI_APP:
- if (SQLITE_OK !=
- sqlite3_exec(manifest_db, query, __uiapp_list_cb, (void *)info, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- sqlite3_close(manifest_db);
- return PKGMGR_R_ERROR;
- }
- uiapplication_x *tmp = NULL;
- if (info->manifest_info->uiapplication) {
- LISTHEAD(info->manifest_info->uiapplication, tmp);
- info->manifest_info->uiapplication = tmp;
- }
- /*If the callback func return < 0 we break and no more call back is called*/
- while(tmp != NULL)
- {
- appinfo->uiapp_info = tmp;
- ret = app_func((void *)appinfo, tmp->appid, user_data);
- if (ret < 0)
- break;
- tmp = tmp->next;
- }
- break;
- case PM_SVC_APP:
- if (SQLITE_OK !=
- sqlite3_exec(manifest_db, query, __svcapp_list_cb, (void *)info, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- sqlite3_close(manifest_db);
- return PKGMGR_R_ERROR;
- }
- serviceapplication_x *tmp1 = NULL;
- if (info->manifest_info->serviceapplication) {
- LISTHEAD(info->manifest_info->serviceapplication, tmp1);
- info->manifest_info->serviceapplication = tmp1;
- }
- /*If the callback func return < 0 we break and no more call back is called*/
- while(tmp1 != NULL)
- {
- appinfo->svcapp_info = tmp1;
- ret = app_func((void *)appinfo, tmp1->appid, user_data);
- if (ret < 0)
- break;
- tmp1 = tmp1->next;
- }
- break;
- default:
- _LOGE("Invalid App Component Type\n");
- break;
- }
+ int size = sqlite3_column_bytes((sqlite3_stmt *)(handle->db_stmt), 0);
+ char *name = (char *)sqlite3_column_text((sqlite3_stmt *)(handle->db_stmt), 0);
- if (appinfo->app_component) {
- free(appinfo->app_component);
- appinfo->app_component = NULL;
- }
- if (appinfo) {
- free(appinfo);
- appinfo = NULL;
- }
- sqlite3_close(manifest_db);
- return PKGMGR_R_OK;
+ *junk_name = (char *)malloc(size + 1);
+ if (*junk_name == NULL)
+ return JUNKMGR_E_NOMEM;
+
+ strncpy(*junk_name, name, size);
+ (*junk_name)[size] = '\0';
+
+ return JUNKMGR_E_SUCCESS;
}
-API int pkgmgr_destroy_pkginfo(pkgmgr_pkginfo_h handle)
+API int junkmgr_result_cursor_get_category(junkmgr_result_h hnd, junkmgr_category_e *category)
{
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
- __cleanup_pkginfo(info);
- return PKGMGR_R_OK;
+ junkmgr_result_s *handle = (junkmgr_result_s *)hnd;
+
+ int media_subdir = sqlite3_column_int((sqlite3_stmt *)(handle->db_stmt), 1);
+ *category = (junkmgr_category_e)media_subdir;
+ return JUNKMGR_E_SUCCESS;
}
-API int pkgmgr_get_appinfo(const char *appid, pkgmgr_appinfo_h *handle)
+API int junkmgr_result_cursor_get_file_type(junkmgr_result_h hnd, junkmgr_file_type_e *file_type)
{
- if (appid == NULL) {
- _LOGE("appid is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- if (handle == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- pkgmgr_appinfo_x *appinfo = NULL;
- char *error_message = NULL;
- int ret = -1;
- int exist = 0;
- char query[MAX_QUERY_LEN] = {'\0'};
-
- /*Validate appid*/
- ret = __open_manifest_db();
- if (ret == -1) {
- _LOGE("Fail to open manifest DB\n");
- ret = PKGMGR_R_ERROR;
- goto err;
- }
- snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", appid);
- if (SQLITE_OK !=
- sqlite3_exec(manifest_db, query, __validate_cb, (void *)&exist, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- sqlite3_close(manifest_db);
- return PKGMGR_R_ERROR;
- }
- if (exist == 0) {
- _LOGE("Appid not found in DB\n");
- ret = PKGMGR_R_ERROR;
- goto err;
- }
+ junkmgr_result_s *handle = (junkmgr_result_s *)hnd;
- appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
- if (appinfo == NULL) {
- _LOGE("Failed to allocate memory for appinfo\n");
- return PKGMGR_R_ERROR;
- }
- appinfo->app_handle_id = __pkgmgr_appinfo_new_handle_id();
- appinfo->uiapp_info = (uiapplication_x *)calloc(1, sizeof(uiapplication_x));
- if (appinfo->uiapp_info == NULL) {
- _LOGE("Failed to allocate memory for uiapp info\n");
- ret = PKGMGR_R_ERROR;
- goto err;
- }
+ int type = sqlite3_column_int((sqlite3_stmt *)(handle->db_stmt), 2);
+ *file_type = (junkmgr_file_type_e)type;
+ return JUNKMGR_E_SUCCESS;
+}
- appinfo->svcapp_info = (serviceapplication_x *)calloc(1, sizeof(serviceapplication_x));
- if (appinfo->svcapp_info == NULL) {
- _LOGE("Failed to allocate memory for svcapp info\n");
- ret = PKGMGR_R_ERROR;
- goto err;
- }
+API int junkmgr_result_cursor_get_storage_type(junkmgr_result_h hnd, junkmgr_storage_type_e *storage)
+{
+ junkmgr_result_s *handle = (junkmgr_result_s *)hnd;
- /*populate uiapp_info from DB*/
- snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' ", appid);
- ret = __exec_appinfo_query(query, (void *)appinfo);
- if (ret == -1) {
- _LOGE("App Info DB Information retrieval failed\n");
- ret = PKGMGR_R_ERROR;
- goto err;
- }
+ int where = sqlite3_column_int((sqlite3_stmt *)(handle->db_stmt), 3);
+ *storage = (junkmgr_storage_type_e)where;
+ return JUNKMGR_E_SUCCESS;
+}
- *handle = (void*)appinfo;
- sqlite3_close(manifest_db);
- return PKGMGR_R_OK;
-err:
- *handle = NULL;
- __cleanup_appinfo(appinfo);
- sqlite3_close(manifest_db);
- return ret;
+API int junkmgr_result_cursor_get_junk_size(junkmgr_result_h hnd, long long *junk_size)
+{
+ junkmgr_result_s *handle = (junkmgr_result_s *)hnd;
+
+ *junk_size = sqlite3_column_int64((sqlite3_stmt *)(handle->db_stmt), 4);
+ return JUNKMGR_E_SUCCESS;
}
-API int pkgmgr_destroy_appinfo(pkgmgr_appinfo_h handle)
+API int junkmgr_result_cursor_get_junk_path(junkmgr_result_h hnd, char **junk_path)
{
- if (handle == NULL) {
- _LOGE("appinfo handle is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
- __cleanup_appinfo(info);
- return PKGMGR_R_OK;
+ junkmgr_result_s *handle = (junkmgr_result_s *)hnd;
+
+ int size = sqlite3_column_bytes((sqlite3_stmt *)(handle->db_stmt), 5);
+ char *path = (char *)sqlite3_column_text((sqlite3_stmt *)(handle->db_stmt), 5);
+
+ *junk_path = (char *)malloc(size + 1);
+ if (*junk_path == NULL)
+ return JUNKMGR_E_NOMEM;
+
+ strncpy(*junk_path, path, size);
+ (*junk_path)[size] = '\0';
+
+ return JUNKMGR_E_SUCCESS;
}
### Get required CFLAGS, LDFLAGS from pkg-config
include(FindPkgConfig)
-pkg_check_modules(comm_pkgs REQUIRED dbus-1 dbus-glib-1 dlog)
+pkg_check_modules(comm_pkgs REQUIRED dbus-1 glib-2.0 dbus-glib-1 gio-2.0 gio-unix-2.0 dlog pkgmgr-info)
foreach(flag ${comm_pkgs_CFLAGS})
set(comm_pkgs_CFLAGS_str "${comm_pkgs_CFLAGS_str} ${flag}")
--output=${CMAKE_CURRENT_BINARY_DIR}/comm_pkg_mgr_server_dbus_bindings.h
)
+#GDBUS specific code
+add_custom_command(OUTPUT comm_pkg_mgr_client_gdbus_generated.c comm_pkg_mgr_client_gdbus_generated.h
+ COMMAND gdbus-codegen --generate-c-code comm_pkg_mgr_client_gdbus_generated
+ --interface-prefix pkgmgr ${CMAKE_CURRENT_SOURCE_DIR}/comm_pkg_mgr.xml
+ )
+
# comm_status_broadcast : status broadcast interface (client - backend process)
add_custom_target(comm_status_broadcast_client_dbus_bindings.h
COMMAND dbus-binding-tool --prefix=status_broadcast --mode=glib-client
## client for apps
# Send request, get status signal
add_library(pkgmgr_installer_client SHARED
- comm_client_dbus.c
+ comm_client_gdbus.c
+ comm_pkg_mgr_client_gdbus_generated.c
#${CMAKE_CURRENT_BINARY_DIR}/comm_status_broadcast_signal_marshaller.c
)
set_target_properties(pkgmgr_installer_client PROPERTIES SOVERSION ${VERSION_MAJOR})
set_target_properties(pkgmgr_installer_client PROPERTIES VERSION ${VERSION})
set_target_properties(pkgmgr_installer_client PROPERTIES COMPILE_FLAGS "${comm_pkgs_CFLAGS_str}")
target_link_libraries(pkgmgr_installer_client ${comm_pkgs_LDFLAGS})
-add_dependencies(pkgmgr_installer_client comm_pkg_mgr_client_dbus_bindings.h comm_status_broadcast_client_dbus_bindings.h comm_status_broadcast_signal_marshaller.h comm_status_broadcast_signal_marshaller.c)
+#add_dependencies(pkgmgr_installer_client comm_pkg_mgr_client_dbus_bindings.h comm_status_broadcast_client_dbus_bindings.h comm_status_broadcast_signal_marshaller.h comm_status_broadcast_signal_marshaller.c)
+add_dependencies(pkgmgr_installer_client comm_pkg_mgr_client_gdbus_generated.h comm_pkg_mgr_client_gdbus_generated.c)
## pkg-mgr server for PMS
# Get request
add_library(pkgmgr_installer_pkg_mgr_server STATIC
- comm_pkg_mgr_server.c)
+ comm_pkg_mgr_server.c
+ )
set_target_properties(pkgmgr_installer_pkg_mgr_server PROPERTIES SOVERSION ${VERSION_MAJOR})
set_target_properties(pkgmgr_installer_pkg_mgr_server PROPERTIES VERSION ${VERSION})
-set_target_properties(pkgmgr_installer_pkg_mgr_server PROPERTIES COMPILE_FLAGS "${comm_pkgs_CFLAGS_str}")
+set_target_properties(pkgmgr_installer_pkg_mgr_server PROPERTIES COMPILE_FLAGS "${comm_pkgs_CFLAGS_str} -fPIC")
target_link_libraries(pkgmgr_installer_pkg_mgr_server ${comm_pkgs_LDFLAGS})
add_dependencies(pkgmgr_installer_pkg_mgr_server comm_pkg_mgr_server_dbus_bindings.h)
<h3 class="pg">Parse command args</h3>
Every installer backend's command arguments are like this; <br>
@code
-$ <backend> <req_id> <pkg_name> [<arg1> <arg2> <arg3> ...]
+$ <backend> <req_id> <pkgid> [<arg1> <arg2> <arg3> ...]
@endcode
<ul>
<li>backend : An installer backend executable file. </li>
<li>req_id : A request id, which is passed from frontend (with -k option). This is broadcasted with all signals from this backend. </li>
- <li>pkg_name : package name</li>
+ <li>pkgid : package name</li>
<li>arg1, arg2, ... : Separated arguments from frontend. You can use anything. This is a rule just between frontend and backend. </li>
</ul>
/* ... */
DBusConnection *conn;
-conn = comm_status_broadcast_server_connect();
+conn = comm_status_broadcast_server_connect(COMM_STATUS_BROADCAST_ALL);
-comm_status_broadcast_server_send_signal(conn, req_id, pkg_type, pkg_name, "start", "0");
+comm_status_broadcast_server_send_signal(COMM_STATUS_BROADCAST_ALL, conn, req_id, pkg_type, pkgid, "start", "0");
/* ... */
-comm_status_broadcast_server_send_signal(conn, req_id, pkg_type, pkg_name, "install_percent", "60");
+comm_status_broadcast_server_send_signal(COMM_STATUS_BROADCAST_ALL,conn, req_id, pkg_type, pkgid, "install_percent", "60");
/* ... */
-comm_status_broadcast_server_send_signal(conn, req_id, pkg_type, pkg_name, "end", "0");
+comm_status_broadcast_server_send_signal(COMM_STATUS_BROADCAST_ALL, conn, req_id, pkg_type, pkgid, "end", "0");
/* ... */
@endcode
//ToDo
}
-static int pkg_plugin_app_is_installed(const char *pkg_name)
+static int pkg_plugin_app_is_installed(const char *pkgid)
{
//ToDo
return 0;
}
-static int pkg_plugin_get_app_detail_info(const char *pkg_name, package_manager_pkg_detail_info_t* pkg_detail_info)
+static int pkg_plugin_get_app_detail_info(const char *pkgid, package_manager_pkg_detail_info_t* pkg_detail_info)
{
//ToDo
GError *err;
DBusGProxy *request_proxy;
DBusGProxy *signal_proxy;
- char *pkg_name;
+ char *pkgid;
status_cb signal_cb;
void *signal_cb_data;
g_object_unref(cc->request_proxy);
if (cc->signal_proxy)
g_object_unref(cc->signal_proxy);
- if (cc->pkg_name)
- free(cc->pkg_name);
+ if (cc->pkgid)
+ free(cc->pkgid);
free(cc);
status_signal_handler(DBusGProxy *proxy,
const char *req_id,
const char *pkg_type,
- const char *pkg_name,
+ const char *pkgid,
const char *key, const char *val, gpointer data)
{
comm_client *cc = (comm_client *) data;
- dbg("Got signal: %s/%s/%s/%s/%s", req_id, pkg_type,
- pkg_name, key, val);
+ SECURE_LOGD("Got signal: %s/%s/%s/%s/%s", req_id, pkg_type,
+ pkgid, key, val);
if (cc->signal_cb) {
- if (cc->pkg_name && pkg_name &&
- 0 == strncmp(cc->pkg_name, pkg_name,
- strlen(cc->pkg_name))) {
+ if (cc->pkgid && pkgid &&
+ 0 == strncmp(cc->pkgid, pkgid,
+ strlen(cc->pkgid))) {
dbg("Run signal handler");
cc->signal_cb(cc->signal_cb_data, req_id, pkg_type,
- pkg_name, key, val);
+ pkgid, key, val);
} else {
- dbg("pkg_name is different. (My pkg_name:%s)"
- " Though pass signal to user callback.", cc->pkg_name);
+ dbg("pkgid is different. (My pkgid:%s)"
+ " Though pass signal to user callback.", cc->pkgid);
cc->signal_cb(cc->signal_cb_data, req_id, pkg_type,
- pkg_name, key, val);
+ pkgid, key, val);
}
} else {
dbg("No signal handler is set. Do nothing.");
int
comm_client_request(comm_client *cc, const char *req_id, const int req_type,
- const char *pkg_type, const char *pkg_name,
+ const char *pkg_type, const char *pkgid,
const char *args, const char *cookie)
{
gboolean r;
gint ret = COMM_RET_ERROR;
- dbg("got request:%s/%d/%s/%s/%s/%s\n", req_id, req_type, pkg_type,
- pkg_name, args, cookie);
+ SECURE_LOGD("got request:%s/%d/%s/%s/%s/%s\n", req_id, req_type, pkg_type,
+ pkgid, args, cookie);
- if (!pkg_name)
- pkg_name = ""; /* NULL check */
+ if (!pkgid)
+ pkgid = ""; /* NULL check */
- r = org_tizen_slp_pkgmgr_request(cc->request_proxy, req_id, req_type,
- pkg_type, pkg_name, args, cookie,
+ r = org_tizen_pkgmgr_request(cc->request_proxy, req_id, req_type,
+ pkg_type, pkgid, args, cookie,
&ret, &(cc->err));
if (TRUE == r) {
- ret = COMM_RET_OK;
+ //ret = COMM_RET_OK;
} else {
g_printerr("Failed to send request via dbus: %s\n",
cc->err->message);
}
return ret;
}
- dbg("request sent");
+ dbg("Request ok");
- if (cc->pkg_name) {
- dbg("freeing pkg_name");
- free(cc->pkg_name);
- dbg("freed pkg_name");
+ if (cc->pkgid) {
+ dbg("freeing pkgid");
+ free(cc->pkgid);
+ dbg("freed pkgid");
}
- cc->pkg_name = strdup(pkg_name);
+ cc->pkgid = strdup(pkgid);
dbg("ret:%d", ret);
typedef struct comm_client comm_client;
typedef void (*status_cb) (void *cb_data, const char *req_id,
- const char *pkg_type, const char *pkg_name,
+ const char *pkg_type, const char *pkgid,
const char *key, const char *val);
API comm_client *comm_client_new(void);
API int comm_client_request(comm_client *cc, const char *req_id,
const int req_type, const char *pkg_type,
- const char *pkg_name, const char *args,
+ const char *pkgid, const char *args,
const char *cookie, int is_block);
-API int comm_client_set_status_callback(comm_client *cc, status_cb cb,
- void *cb_data);
-
+API int comm_client_set_status_callback(int comm_status_type, comm_client *cc, status_cb cb, void *cb_data);
#endif /* __COMM_CLIENT_H__ */
#include <dbus/dbus-glib-lowlevel.h>
#include <stdbool.h>
#include <stdio.h>
+#include <dirent.h>
+#include <fcntl.h>
/*******************
* ADT description
* Internal function description
*/
+static inline int __comm_read_proc(const char *path, char *buf, int size)
+{
+ int fd;
+ int ret;
+
+ if (buf == NULL || path == NULL)
+ return -1;
+
+ fd = open(path, O_RDONLY);
+ if (fd < 0)
+ return -1;
+
+ ret = read(fd, buf, size - 1);
+ if (ret <= 0) {
+ close(fd);
+ return -1;
+ } else
+ buf[ret] = 0;
+
+ close(fd);
+
+ return ret;
+}
+static inline int __comm_find_pid_by_cmdline(const char *dname,
+ const char *cmdline, const char *apppath)
+{
+ int pid = 0;
+
+ if (strncmp(cmdline, apppath, 1024-1) == 0) {
+ pid = atoi(dname);
+ if (pid != getpgid(pid))
+ pid = 0;
+ }
+
+ return pid;
+}
+
+static int __comm_proc_iter_kill_cmdline(const char *apppath)
+{
+ DIR *dp;
+ struct dirent *dentry;
+ int pid;
+ int ret;
+ char buf[1024];
+
+ dp = opendir("/proc");
+ if (dp == NULL) {
+ return -1;
+ }
+
+ while ((dentry = readdir(dp)) != NULL) {
+ if (!isdigit(dentry->d_name[0]))
+ continue;
+
+ snprintf(buf, sizeof(buf), "/proc/%s/cmdline", dentry->d_name);
+ ret = __comm_read_proc(buf, buf, sizeof(buf));
+ if (ret <= 0)
+ continue;
+
+ pid = __comm_find_pid_by_cmdline(dentry->d_name, buf, apppath);
+ if (pid > 0) {
+ int pgid;
+
+ pgid = getpgid(pid);
+ if (pgid <= 1) {
+ closedir(dp);
+ return -1;
+ }
+
+ if (killpg(pgid, SIGKILL) < 0) {
+ closedir(dp);
+ return -1;
+ }
+ }
+ }
+
+ closedir(dp);
+ return 0;
+}
+static char *__get_interface(int status_type)
+{
+ char *interface = NULL;
+
+ switch (status_type) {
+ case COMM_STATUS_BROADCAST_ALL:
+ interface = COMM_STATUS_BROADCAST_DBUS_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_INSTALL:
+ interface = COMM_STATUS_BROADCAST_DBUS_INSTALL_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_UNINSTALL:
+ interface = COMM_STATUS_BROADCAST_DBUS_UNINSTALL_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_MOVE:
+ interface = COMM_STATUS_BROADCAST_DBUS_MOVE_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_INSTALL_PROGRESS:
+ interface = COMM_STATUS_BROADCAST_DBUS_INSTALL_PROGRESS_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_UPGRADE:
+ interface = COMM_STATUS_BROADCAST_DBUS_UPGRADE_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_GET_SIZE:
+ interface = COMM_STATUS_BROADCAST_DBUS_GET_SIZE_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_GET_JUNK_INFO:
+ interface = COMM_STATUS_BROADCAST_DBUS_GET_JUNK_INFO_INTERFACE;
+ break;
+
+ default:
+ interface = NULL;
+ }
+ return interface;
+}
+
/**
* signal handler filter
* Filter signal, and run user callback
/* Values to be received by signal */
char *req_id = NULL;
char *pkg_type = NULL;
- char *pkg_name = NULL;
+ char *pkgid = NULL;
char *key = NULL;
char *val = NULL;
sig_cb_data = (struct signal_callback_data *)user_data;
/* Signal check */
- if (dbus_message_is_signal(msg,
- COMM_STATUS_BROADCAST_DBUS_INTERFACE,
- COMM_STATUS_BROADCAST_SIGNAL_STATUS)) {
+ if ((dbus_message_is_signal(msg, COMM_STATUS_BROADCAST_DBUS_INTERFACE, COMM_STATUS_BROADCAST_SIGNAL_STATUS)) ||
+ (dbus_message_is_signal(msg, COMM_STATUS_BROADCAST_DBUS_INSTALL_INTERFACE, COMM_STATUS_BROADCAST_EVENT_INSTALL)) ||
+ (dbus_message_is_signal(msg, COMM_STATUS_BROADCAST_DBUS_UNINSTALL_INTERFACE, COMM_STATUS_BROADCAST_EVENT_UNINSTALL)) ||
+ (dbus_message_is_signal(msg, COMM_STATUS_BROADCAST_DBUS_MOVE_INTERFACE, COMM_STATUS_BROADCAST_EVENT_MOVE)) ||
+ (dbus_message_is_signal(msg, COMM_STATUS_BROADCAST_DBUS_UPGRADE_INTERFACE, COMM_STATUS_BROADCAST_EVENT_UPGRADE)) ||
+ (dbus_message_is_signal(msg, COMM_STATUS_BROADCAST_DBUS_GET_SIZE_INTERFACE, COMM_STATUS_BROADCAST_EVENT_GET_SIZE)) ||
+ (dbus_message_is_signal(msg, COMM_STATUS_BROADCAST_DBUS_GET_JUNK_INFO_INTERFACE, COMM_STATUS_BROADCAST_EVENT_GET_JUNK_INFO)) ||
+ (dbus_message_is_signal(msg, COMM_STATUS_BROADCAST_DBUS_INSTALL_PROGRESS_INTERFACE, COMM_STATUS_BROADCAST_EVENT_INSTALL_PROGRESS))) {
/* Signal type check */
if (dbus_message_get_args(msg, &err,
DBUS_TYPE_STRING, &req_id,
DBUS_TYPE_STRING, &pkg_type,
- DBUS_TYPE_STRING, &pkg_name,
+ DBUS_TYPE_STRING, &pkgid,
DBUS_TYPE_STRING, &key,
DBUS_TYPE_STRING, &val,
DBUS_TYPE_INVALID)) {
/* Got signal! */
- dbg("Got signal: %s / %s / %s / %s / %s", req_id,
- pkg_type, pkg_name, key, val);
+ SECURE_LOGD("Got signal: %s / %s / %s / %s / %s", req_id,
+ pkg_type, pkgid, key, val);
/* Run signal callback if exist */
if (sig_cb_data && sig_cb_data->cb) {
sig_cb_data->cb(sig_cb_data->cb_data, req_id,
- pkg_type, pkg_name, key, val);
+ pkg_type, pkgid, key, val);
dbg("callback function is end");
}
return -2;
}
- /* Cleanup ADT */
- /* flush remaining buffer: blocking mode */
- dbus_connection_flush(cc->conn);
-
/* Free signal filter if signal callback is exist */
if (cc->sig_cb_data) {
dbus_connection_remove_filter(cc->conn,
const char *req_id,
const int req_type,
const char *pkg_type,
- const char *pkg_name,
+ const char *pkgid,
const char *args,
const char *cookie,
int is_block)
{
+ DBusError err;
DBusMessage *msg = NULL;
int r = COMM_RET_ERROR; /* Default return */
- if (!cc)
+ if (!cc){
+ ERR("Invalid dbus input");
return COMM_RET_ERROR;
+ }
/* Create a dbus message */
msg = dbus_message_new_method_call(COMM_PKG_MGR_DBUS_SERVICE,
COMM_PKG_MGR_METHOD_REQUEST);
if (NULL == msg) {
r = COMM_RET_NOMEM;
+ ERR("dbus_message_new_method_call fail : msg is NULL");
goto ERROR_CLEANUP;
}
req_id = "tmp_reqid";
if (NULL == pkg_type)
pkg_type = "none";
- if (NULL == pkg_name)
- pkg_name = "";
+ if (NULL == pkgid)
+ pkgid = "";
if (NULL == args)
args = "";
if (NULL == cookie)
cookie = "";
+ dbus_error_init(&err);
+
/* Append arguments */
if (!dbus_message_append_args(msg,
DBUS_TYPE_STRING, &req_id,
DBUS_TYPE_INT32, &req_type,
DBUS_TYPE_STRING, &pkg_type,
- DBUS_TYPE_STRING, &pkg_name,
+ DBUS_TYPE_STRING, &pkgid,
DBUS_TYPE_STRING, &args,
DBUS_TYPE_STRING, &cookie,
DBUS_TYPE_INVALID)) {
- r = COMM_RET_NOMEM;
+ r = -3;
+ ERR("dbus_message_append_args fail");
goto ERROR_CLEANUP;
}
- /* Send message */
+ /* Send message , timeout -1 = _DBUS_DEFAULT_TIMEOUT_VALUE (25 * 1000) 25 seconds*/
if (is_block == 1){
if(!dbus_connection_send_with_reply_and_block(cc->conn, msg,
- 5000, NULL)) {
- r = COMM_RET_NOMEM;
- goto ERROR_CLEANUP;
+ -1, NULL)) {
+ ERR("try send msg to dbus by timeout");
+ sleep(1);
+ if(!dbus_connection_send_with_reply_and_block(cc->conn, msg,
+ -1, &err)) {
+ r = -4;
+ ERR("dbus_connection_send_with_reply_and_block fail");
+
+ __comm_proc_iter_kill_cmdline("pkgmgr-server");
+
+ if (dbus_error_is_set(&err))
+ ERR("dbus error:%s", err.message);
+ goto ERROR_CLEANUP;
+ }
}
} else {
if (!dbus_connection_send(cc->conn, msg, NULL)) {
- r = COMM_RET_NOMEM;
+ r = -5;
+ ERR("dbus_connection_send fail");
goto ERROR_CLEANUP;
}
}
if (msg)
dbus_message_unref(msg);
+ dbus_error_free(&err);
+
return r;
}
* Set a callback for status signal
*/
int
-comm_client_set_status_callback(comm_client *cc, status_cb cb, void *cb_data)
+comm_client_set_status_callback(int comm_status_type, comm_client *cc, status_cb cb, void *cb_data)
{
DBusError err;
char buf[256] = { 0, };
goto ERROR_CLEANUP;
/* Add a rule for signal */
- snprintf(buf, 255, "type='signal',interface='%s'",
- COMM_STATUS_BROADCAST_DBUS_INTERFACE);
+ snprintf(buf, 255, "type='signal',interface='%s'", __get_interface(comm_status_type));
dbus_bus_add_match(cc->conn, buf, &err);
if (dbus_error_is_set(&err)) {
ERR("dbus error:%s", err.message);
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * 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.
+ *
+ */
+
+
+/*
+ * comm_client_gdbus.c
+ * comm_client library using gdbus
+ */
+
+#include <glib.h>
+#include <gio/gio.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+#include "comm_config.h"
+#include "comm_client.h"
+#include "comm_pkg_mgr_client_gdbus_generated.h"
+
+/*******************
+ * ADT description
+ */
+
+/* Storing status_cb */
+struct signal_callback_data {
+ status_cb cb;
+ void *cb_data;
+};
+
+/* comm_client ADT */
+struct comm_client {
+ guint subscription_id;
+ GDBusConnection *conn;
+ struct signal_callback_data *sig_cb_data;
+};
+
+#define COMM_CLIENT_RETRY_MAX 5
+
+static int __retry_request(comm_client *cc,
+ const gchar *req_id,
+ gint req_type,
+ const gchar *pkg_type,
+ const gchar *pkgid,
+ const gchar *args,
+ const gchar *cookie,
+ gint *ret)
+{
+ OrgTizenPkgmgr *proxy;
+ GError *error = NULL;
+ int rc = 0;
+
+ proxy = org_tizen_pkgmgr_proxy_new_sync(cc->conn,
+ G_DBUS_PROXY_FLAGS_NONE, COMM_PKG_MGR_DBUS_SERVICE,
+ COMM_PKG_MGR_DBUS_PATH,
+ NULL, &error);
+ if (proxy == NULL) {
+ ERR("Unable to create proxy[rc=%d, err=%s]\n", rc, error->message);
+ return FALSE;
+ }
+
+ rc = org_tizen_pkgmgr_call_request_sync(proxy,
+ req_id, req_type, pkg_type, pkgid, args, cookie, ret, NULL, &error);
+ if (!rc) {
+ ERR("Failed to send request[rc=%d, err=%s]\n", rc, error->message);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static char *__get_interface(int status_type)
+{
+ char *ifc = NULL;
+
+ switch (status_type) {
+ case COMM_STATUS_BROADCAST_ALL:
+ ifc = COMM_STATUS_BROADCAST_DBUS_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_INSTALL:
+ ifc = COMM_STATUS_BROADCAST_DBUS_INSTALL_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_UNINSTALL:
+ ifc = COMM_STATUS_BROADCAST_DBUS_UNINSTALL_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_MOVE:
+ ifc = COMM_STATUS_BROADCAST_DBUS_MOVE_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_INSTALL_PROGRESS:
+ ifc = COMM_STATUS_BROADCAST_DBUS_INSTALL_PROGRESS_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_UPGRADE:
+ ifc = COMM_STATUS_BROADCAST_DBUS_UPGRADE_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_GET_SIZE:
+ ifc = COMM_STATUS_BROADCAST_DBUS_GET_SIZE_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_GET_JUNK_INFO:
+ ifc = COMM_STATUS_BROADCAST_DBUS_GET_JUNK_INFO_INTERFACE;
+ break;
+
+ default:
+ break;
+ }
+ return ifc;
+}
+
+/**
+ * signal handler filter
+ * Filter signal, and run user callback
+ */
+void _on_signal_handle_filter(GDBusConnection *conn,
+ const gchar *sender_name,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *signal_name,
+ GVariant *parameters,
+ gpointer user_data)
+{
+ if (interface_name && strcmp(interface_name, COMM_STATUS_BROADCAST_DBUS_INTERFACE) &&
+ strcmp(interface_name, COMM_STATUS_BROADCAST_DBUS_INSTALL_INTERFACE) &&
+ strcmp(interface_name, COMM_STATUS_BROADCAST_DBUS_UNINSTALL_INTERFACE) &&
+ strcmp(interface_name, COMM_STATUS_BROADCAST_DBUS_UPGRADE_INTERFACE) &&
+ strcmp(interface_name, COMM_STATUS_BROADCAST_DBUS_MOVE_INTERFACE) &&
+ strcmp(interface_name, COMM_STATUS_BROADCAST_DBUS_GET_SIZE_INTERFACE) &&
+ strcmp(interface_name, COMM_STATUS_BROADCAST_DBUS_GET_JUNK_INFO_INTERFACE) &&
+ strcmp(interface_name, COMM_STATUS_BROADCAST_DBUS_INSTALL_PROGRESS_INTERFACE)) {
+ dbg("Interface name did not match. Drop the message");
+ return;
+ }
+ if (signal_name && strcmp(signal_name, COMM_STATUS_BROADCAST_SIGNAL_STATUS) &&
+ strcmp(signal_name, COMM_STATUS_BROADCAST_EVENT_INSTALL) &&
+ strcmp(signal_name, COMM_STATUS_BROADCAST_EVENT_UNINSTALL) &&
+ strcmp(signal_name, COMM_STATUS_BROADCAST_EVENT_UPGRADE) &&
+ strcmp(signal_name, COMM_STATUS_BROADCAST_EVENT_MOVE) &&
+ strcmp(signal_name, COMM_STATUS_BROADCAST_EVENT_GET_SIZE) &&
+ strcmp(signal_name, COMM_STATUS_BROADCAST_EVENT_GET_JUNK_INFO) &&
+ strcmp(signal_name, COMM_STATUS_BROADCAST_EVENT_INSTALL_PROGRESS)) {
+ dbg("Signal name did not match. Drop the message");
+ return;
+ }
+ /* Values to be received by signal */
+ char *req_id = NULL;
+ char *pkg_type = NULL;
+ char *pkgid = NULL;
+ char *key = NULL;
+ char *val = NULL;
+
+ /* User's signal handler */
+ struct signal_callback_data *sig_cb_data;
+ if (user_data)
+ sig_cb_data = (struct signal_callback_data *)user_data;
+ else
+ return;
+
+ g_variant_get(parameters, "(&s&s&s&s&s)",
+ &req_id, &pkg_type, &pkgid, &key, &val);
+ /* Got signal! */
+ SECURE_LOGD("Got signal: [%s] %s / %s / %s / %s / %s", signal_name, req_id,
+ pkg_type, pkgid, key, val);
+
+ /* Run signal callback if exist */
+ if (sig_cb_data && sig_cb_data->cb) {
+ sig_cb_data->cb(sig_cb_data->cb_data, req_id,
+ pkg_type, pkgid, key, val);
+ dbg("callback function is end");
+ }
+ dbg("Handled signal. Exit function");
+ return;
+}
+
+/**
+ * signal_callback_data free function
+ * Just free it!
+ */
+void _free_sig_cb_data(void *data)
+{
+ struct signal_callback_data *sig_cb_data = NULL;
+ if (data)
+ sig_cb_data = (struct signal_callback_data *)data;
+ if (!sig_cb_data)
+ return;
+ free(sig_cb_data);
+}
+
+/*******************
+ * API description
+ */
+
+/**
+ * Create a new comm_client object
+ */
+comm_client *comm_client_new(void)
+{
+ GError *error = NULL;
+ comm_client *cc = NULL;
+
+ /* Allocate memory for ADT:comm_client */
+ g_type_init();
+ cc = calloc(1, sizeof(comm_client));
+ if (NULL == cc) {
+ ERR("No memory");
+ goto ERROR_CLEANUP;
+ }
+
+ /* Connect to gdbus. Gets shared BUS */
+ cc->conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+ if (error) {
+ ERR("gdbus connection error (%s)", error->message);
+ g_error_free(error);
+ goto ERROR_CLEANUP;
+ }
+ if (NULL == cc->conn) {
+ ERR("gdbus connection is not set, even gdbus error isn't raised");
+ goto ERROR_CLEANUP;
+ }
+ return cc;
+
+ ERROR_CLEANUP:
+ if (cc)
+ free(cc);
+ return NULL;
+}
+
+/**
+ * Free comm_client object
+ */
+int comm_client_free(comm_client *cc)
+{
+ if (!cc)
+ return -1;
+ if (!(cc->conn) || g_dbus_connection_is_closed(cc->conn)) {
+ ERR("Invalid gdbus connection");
+ return -2;
+ }
+
+ /* Cleanup ADT */
+ /* flush remaining buffer: blocking mode */
+ g_dbus_connection_flush_sync(cc->conn, NULL, NULL);
+
+ /* Free signal filter if signal callback is exist */
+ if (cc->sig_cb_data) {
+ g_dbus_connection_signal_unsubscribe(cc->conn, cc->subscription_id);
+ /* TODO: Is it needed to free cc->sig_cb_data here? */
+ /* _free_sig_cb_data(cc->sig_cb_data); */
+ }
+ /* just unref because it is shared BUS.
+ If ref count is 0 it will get free'd automatically
+ */
+ g_object_unref(cc->conn);
+
+ if(cc)
+ free(cc);
+
+ return 0;
+}
+
+/**
+ * Request a message
+ */
+int
+comm_client_request(
+ comm_client *cc,
+ const char *req_id,
+ const int req_type,
+ const char *pkg_type,
+ const char *pkgid,
+ const char *args,
+ const char *cookie,
+ int is_block)
+{
+ GError *error = NULL;
+ int ret = 0;
+ int rc = 0;
+ int retry_cnt = 0;
+
+ OrgTizenPkgmgr *proxy;
+ if (!cc){
+ ERR("Invalid gdbus input");
+ return COMM_RET_ERROR;
+ }
+ proxy = org_tizen_pkgmgr_proxy_new_sync(cc->conn,
+ G_DBUS_PROXY_FLAGS_NONE, COMM_PKG_MGR_DBUS_SERVICE,
+ COMM_PKG_MGR_DBUS_PATH,
+ NULL, &error);
+ if (proxy == NULL) {
+ ERR("Unable to create proxy[rc=%d, err=%s]\n", rc, error->message);
+ return COMM_RET_ERROR;
+ }
+
+ /* Assign default values if NULL (NULL is not allowed) */
+ if (req_id == NULL)
+ req_id = "tmp_reqid";
+ if (pkg_type == NULL)
+ pkg_type = "none";
+ if (pkgid == NULL)
+ pkgid = "";
+ if (args == NULL)
+ args = "";
+ if (cookie == NULL)
+ cookie = "";
+
+ rc = org_tizen_pkgmgr_call_request_sync(proxy,
+ req_id, req_type, pkg_type, pkgid, args, cookie, &ret, NULL, &error);
+
+ while (rc == FALSE) {
+ ERR("Failed to send request, sleep and retry[rc=%d, err=%s]\n", rc, error->message);
+ sleep(1);
+
+ if(retry_cnt == COMM_CLIENT_RETRY_MAX) {
+ ERR("retry_cnt is max, stop retry\n");
+ return COMM_RET_ERROR;
+ }
+ retry_cnt++;
+
+ rc = __retry_request(cc, req_id, req_type, pkg_type, pkgid, args, cookie, &ret);
+ if(rc == TRUE) {
+ ERR("__retry_request is success[retry_cnt=%d]\n", retry_cnt);
+ break;
+ }
+ }
+
+ return ret;
+}
+
+/**
+ * Set a callback for status signal
+ */
+int
+comm_client_set_status_callback(int comm_status_type, comm_client *cc, status_cb cb, void *cb_data)
+{
+ int r = COMM_RET_ERROR;
+ char *ifc = NULL;
+
+ if (NULL == cc)
+ goto ERROR_CLEANUP;
+
+ ifc = __get_interface(comm_status_type);
+ if (ifc == NULL) {
+ ERR("Invalid interface name\n");
+ return COMM_RET_ERROR;
+ }
+
+ /* Create new sig_cb_data */
+ cc->sig_cb_data = calloc(1, sizeof(struct signal_callback_data));
+ if(cc->sig_cb_data == NULL){
+ ERR("calloc failed!!");
+ return COMM_RET_ERROR;
+ }
+ (cc->sig_cb_data)->cb = cb;
+ (cc->sig_cb_data)->cb_data = cb_data;
+
+ /* Add a filter for signal */
+ cc->subscription_id = g_dbus_connection_signal_subscribe(cc->conn, NULL, ifc,
+ NULL, NULL, NULL, G_DBUS_SIGNAL_FLAGS_NONE,
+ _on_signal_handle_filter, (gpointer)cc->sig_cb_data, _free_sig_cb_data);
+ if (!cc->subscription_id) {
+ ERR("Failed to add filter\n");
+ r = COMM_RET_ERROR;
+ goto ERROR_CLEANUP;
+ }
+
+ return COMM_RET_OK;
+
+ ERROR_CLEANUP:
+ ERR("General error");
+ return r;
+}
+
#ifndef NDEBUG
#ifdef USE_DLOG
+#undef LOG_TAG
+#ifndef LOG_TAG
#define LOG_TAG "PKGMGR"
+#endif /* LOG_TAG */
#include <dlog.h>
-#define dbg(fmtstr, args...) \
- do { SLOGI("[comm]%s:%d:%s(): " \
- fmtstr "\n", basename(__FILE__), __LINE__, __func__, ##args); } \
- while (0)
-#define ERR(fmtstr, args...) \
- do { SLOGE("[comm]%s:%d:%s(): " \
- fmtstr "\n", basename(__FILE__), __LINE__, __func__, ##args); } \
- while (0)
+
+#define dbg(fmt, arg...) LOGD(fmt, ##arg)
+#define ERR(fmt, arg...) LOGE(fmt, ##arg)
+
#else
#include <stdio.h>
#include <sys/types.h>
/* from comm_pkg_mgr.xml
*/
-#define COMM_PKG_MGR_DBUS_SERVICE "org.tizen.slp.pkgmgr"
-#define COMM_PKG_MGR_DBUS_PATH "/org/tizen/slp/pkgmgr"
-#define COMM_PKG_MGR_DBUS_INTERFACE "org.tizen.slp.pkgmgr"
+#define COMM_PKG_MGR_DBUS_SERVICE "org.tizen.pkgmgr"
+#define COMM_PKG_MGR_DBUS_PATH "/org/tizen/pkgmgr"
+#define COMM_PKG_MGR_DBUS_INTERFACE "org.tizen.pkgmgr"
#define COMM_PKG_MGR_METHOD_REQUEST "Request"
#define COMM_PKG_MGR_METHOD_ECHO_STRING "EchoString"
+#define COMM_PKG_MGR_METHOD_CREATE_EXTERNAL_DIRECTORY "CreateExternalDirectory"
/* from comm_status_broadcast
*/
#define COMM_STATUS_BROADCAST_DBUS_SERVICE_PREFIX \
- "org.tizen.slp.pkgmgr_status"
+ "org.tizen.pkgmgr_status"
#define COMM_STATUS_BROADCAST_DBUS_PATH \
- "/org/tizen/slp/pkgmgr_status"
+ "/org/tizen/pkgmgr_status"
#define COMM_STATUS_BROADCAST_DBUS_INTERFACE \
- "org.tizen.slp.pkgmgr_status"
+ "org.tizen.pkgmgr_status"
#define COMM_STATUS_BROADCAST_SIGNAL_STATUS "status"
+#define COMM_STATUS_BROADCAST_DBUS_INSTALL_SERVICE_PREFIX "org.tizen.pkgmgr.install"
+#define COMM_STATUS_BROADCAST_DBUS_INSTALL_PATH "/org/tizen/pkgmgr/install"
+#define COMM_STATUS_BROADCAST_DBUS_INSTALL_INTERFACE "org.tizen.pkgmgr.install"
+#define COMM_STATUS_BROADCAST_EVENT_INSTALL "install"
+
+#define COMM_STATUS_BROADCAST_DBUS_UNINSTALL_SERVICE_PREFIX "org.tizen.pkgmgr.uninstall"
+#define COMM_STATUS_BROADCAST_DBUS_UNINSTALL_PATH "/org/tizen/pkgmgr/uninstall"
+#define COMM_STATUS_BROADCAST_DBUS_UNINSTALL_INTERFACE "org.tizen.pkgmgr.uninstall"
+#define COMM_STATUS_BROADCAST_EVENT_UNINSTALL "uninstall"
+
+#define COMM_STATUS_BROADCAST_DBUS_MOVE_SERVICE_PREFIX "org.tizen.pkgmgr.move"
+#define COMM_STATUS_BROADCAST_DBUS_MOVE_PATH "/org/tizen/pkgmgr/move"
+#define COMM_STATUS_BROADCAST_DBUS_MOVE_INTERFACE "org.tizen.pkgmgr.move"
+#define COMM_STATUS_BROADCAST_EVENT_MOVE "move"
+
+#define COMM_STATUS_BROADCAST_DBUS_INSTALL_PROGRESS_SERVICE_PREFIX "org.tizen.pkgmgr.install.progress"
+#define COMM_STATUS_BROADCAST_DBUS_INSTALL_PROGRESS_PATH "/org/tizen/pkgmgr/install/progress"
+#define COMM_STATUS_BROADCAST_DBUS_INSTALL_PROGRESS_INTERFACE "org.tizen.pkgmgr.install.progress"
+#define COMM_STATUS_BROADCAST_EVENT_INSTALL_PROGRESS "install_progress"
+
+#define COMM_STATUS_BROADCAST_DBUS_UPGRADE_SERVICE_PREFIX "org.tizen.pkgmgr.upgrade"
+#define COMM_STATUS_BROADCAST_DBUS_UPGRADE_PATH "/org/tizen/pkgmgr/upgrade"
+#define COMM_STATUS_BROADCAST_DBUS_UPGRADE_INTERFACE "org.tizen.pkgmgr.upgrade"
+#define COMM_STATUS_BROADCAST_EVENT_UPGRADE "upgrade"
+
+#define COMM_STATUS_BROADCAST_DBUS_GET_SIZE_SERVICE_PREFIX "org.tizen.pkgmgr.get.size"
+#define COMM_STATUS_BROADCAST_DBUS_GET_SIZE_PATH "/org/tizen/pkgmgr/get/size"
+#define COMM_STATUS_BROADCAST_DBUS_GET_SIZE_INTERFACE "org.tizen.pkgmgr.get.size"
+#define COMM_STATUS_BROADCAST_EVENT_GET_SIZE "get_size"
+
+#define COMM_STATUS_BROADCAST_DBUS_GET_JUNK_INFO_SERVICE_PREFIX "org.tizen.pkgmgr.get.junkinfo"
+#define COMM_STATUS_BROADCAST_DBUS_GET_JUNK_INFO_PATH "/org/tizen/pkgmgr/get/junkinfo"
+#define COMM_STATUS_BROADCAST_DBUS_GET_JUNK_INFO_INTERFACE "org.tizen.pkgmgr.get.junkinfo"
+#define COMM_STATUS_BROADCAST_EVENT_GET_JUNK_INFO "get_junkinfo"
+
/********
* enums
********/
/* to installer */
COMM_REQ_TO_INSTALLER = 1,
- /* to activator */
- COMM_REQ_TO_ACTIVATOR,
+ /* activate pkg */
+ COMM_REQ_ACTIVATE_PKG,
+
+ /* deactivate pkg */
+ COMM_REQ_DEACTIVATE_PKG,
+
+ /* activate app */
+ COMM_REQ_ACTIVATE_APP,
+
+ /* deactivate app */
+ COMM_REQ_DEACTIVATE_APP,
+
+ /* activate app with label */
+ COMM_REQ_ACTIVATE_APP_WITH_LABEL,
/* to clearer */
COMM_REQ_TO_CLEARER,
+ /* to mover*/
+ COMM_REQ_TO_MOVER,
+
/* cancel job */
COMM_REQ_CANCEL,
+ /*get package size */
+ COMM_REQ_GET_SIZE,
+
+ /*kill app */
+ COMM_REQ_KILL_APP,
+
+ /*check app */
+ COMM_REQ_CHECK_APP,
+
+ /* to cache clearer */
+ COMM_REQ_CLEAR_CACHE_DIR,
+
+ /* make external directories for app */
+ COMM_REQ_MAKE_EXTERNAL_DIR,
+
+ /* get junk file information */
+ COMM_REQ_GET_JUNK_INFO,
+
COMM_REQ_MAX_SENTINEL
};
COMM_RET_MAX_SENTINEL
};
+/* broadcast type */
+enum {
+ COMM_STATUS_BROADCAST_ALL = 1,
+ COMM_STATUS_BROADCAST_INSTALL,
+ COMM_STATUS_BROADCAST_UNINSTALL,
+ COMM_STATUS_BROADCAST_MOVE,
+ COMM_STATUS_BROADCAST_INSTALL_PROGRESS,
+ COMM_STATUS_BROADCAST_UPGRADE,
+ COMM_STATUS_BROADCAST_GET_SIZE,
+ COMM_STATUS_BROADCAST_GET_JUNK_INFO,
+ COMM_STATUS_BROADCAST_MAX
+};
+
#endif /* __COMM_CONFIG_H__ */
<?xml version="1.0" encoding="UTF-8"?>
-<node name="/org/tizen/slp/pkgmgr">
- <interface name="org.tizen.slp.pkgmgr">
+<node name="/org/tizen/pkgmgr">
+ <interface name="org.tizen.pkgmgr">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="pkgmgr" />
<method name="Request">
<arg type="s" name="req_id" direction="in" />
<arg type="i" name="req_type" direction="in" />
<arg type="s" name="pkg_type" direction="in" />
- <arg type="s" name="pkg_name" direction="in" />
+ <arg type="s" name="pkgid" direction="in" />
<arg type="s" name="args" direction="in" />
<arg type="s" name="cookie" direction="in" />
<arg type="i" name="ret" direction="out" />
</method>
+ <method name="CreateExternalDirectory">
+ <arg type="i" name="ret" direction="out" />
+ </method>
</interface>
</node>
DBusGConnection *bus;
request_callback req_cb;
+ create_directory_cb create_dir_cb;
void *req_cb_data;
};
*/
GCallback pkgmgr_request(PkgMgrObject *obj, const gchar *req_id,
const gint req_type, const gchar *pkg_type,
- const gchar *pkg_name, const gchar *args,
- const gchar *cookie, gint *ret, GError *err);
+ const gchar *pkgid, const gchar *args,
+ const gchar *cookie, gint *ret, GError **err);
+
+GCallback pkgmgr_create_external_directory(PkgMgrObject *obj,
+ gint *ret,
+ GError **err);
/* Include stub header */
#include "comm_pkg_mgr_server_dbus_bindings.h"
return;
}
/* Register service name
- * NOTE: refer to
- http://dbus.freedesktop.org/doc/dbus-specification.html
+ * NOTE: refer to
+ http://dbus.freedesktop.org/doc/dbus-specification.html
*/
guint result;
if (!dbus_g_proxy_call(proxy, "RequestName", &err,
static void pkg_mgr_object_class_init(PkgMgrObjectClass *klass)
{
dbg("called");
+ GObjectClass *gobject_class;
g_assert(NULL != klass);
+ gobject_class = (GObjectClass *)klass;
+ gobject_class->finalize = pkg_mgr_object_finalize;
+
dbus_g_object_type_install_info(PKG_MGR_TYPE_OBJECT,
&dbus_glib_pkgmgr_object_info);
/* PkgMgrObjectClass *klass = (PkgMgrObjectClass *) G_OBJECT_CLASS(self); */
/* Call parent's finalize function
- * 'server_object_parent_class' comes from G_DEFINE_TYPE() macro.
+ * 'server_object_parent_class' comes from G_DEFINE_TYPE() macro.
*/
G_OBJECT_CLASS(pkg_mgr_object_parent_class)->finalize(self);
}
+/**
+ * Set request callback function
+ */
+void pkg_mgr_set_request_callback(PkgMgrObject *obj, request_callback req_cb,
+ void *cb_data)
+{
+ obj->req_cb = req_cb;
+ obj->req_cb_data = cb_data;
+}
+
+void pkg_mgr_set_callback_to_create_directory(PkgMgrObject *obj, create_directory_cb callback)
+{
+ obj->create_dir_cb = callback;
+ obj->req_cb_data = NULL;
+}
+
/* dbus-glib methods */
-GCallback
-pkgmgr_request(PkgMgrObject *obj,
+GCallback pkgmgr_request(PkgMgrObject *obj,
const gchar *req_id,
const gint req_type,
const gchar *pkg_type,
- const gchar *pkg_name,
+ const gchar *pkgid,
const gchar *args,
- const gchar *cookie, gint *ret, GError *err)
+ const gchar *cookie, gint *ret, GError **err)
{
dbg("Called");
*ret = COMM_RET_OK; /* TODO: fix this! */
- /* TODO: Add business logic
+ /* TODO: Add business logic
* - add to queue, or remove from queue
* */
if (obj->req_cb) {
- dbg("Call request callback(obj, %s, %d, %s, %s, %s, *ret)",
- req_id, req_type, pkg_type, pkg_name, args);
+ SECURE_LOGD("Call request callback(obj, %s, %d, %s, %s, %s, *ret)",
+ req_id, req_type, pkg_type, pkgid, args);
obj->req_cb(obj->req_cb_data, req_id, req_type, pkg_type,
- pkg_name, args, cookie, ret);
+ pkgid, args, cookie, ret);
} else {
dbg("Attempt to call request callback,"
" but request callback is not set. Do nothing.\n"
return (GCallback) TRUE;
}
-/* Other APIs
- */
-
-/**
- * Set request callback function
- */
-void pkg_mgr_set_request_callback(PkgMgrObject *obj, request_callback req_cb,
- void *cb_data)
+GCallback pkgmgr_create_external_directory(PkgMgrObject *obj, gint *ret, GError **err)
{
- obj->req_cb = req_cb;
- obj->req_cb_data = cb_data;
+ int res;
+
+ dbg("Try to create external directories.");
+ if (obj->create_dir_cb)
+ {
+ res = obj->create_dir_cb();
+ if (res < 0)
+ {
+ ERR("_create_external_directory() is failed. error = [%d]", res);
+ }
+ } else {
+ res = -1;
+ }
+
+ *ret = res;
+
+ return (GCallback) TRUE;
}
typedef void (*request_callback) (void *cb_data, const char *req_id,
const int req_type, const char *pkg_type,
- const char *pkg_name, const char *args,
+ const char *pkgid, const char *args,
const char *cookie, int *ret);
+typedef int (*create_directory_cb) (void);
+
API void pkg_mgr_set_request_callback(PkgMgrObject *obj,
- request_callback req_cb, void *cb_data);
+ request_callback req_cb, void *cb_data);
+
+API void pkg_mgr_set_callback_to_create_directory(PkgMgrObject *obj,
+ create_directory_cb callback);
#endif /* __COMM_PKG_MGR_SERVER_H__ */
int _comm_socket_free(comm_socket *cs)
{
CHK_CS_RET(-EINVAL);
+ close(cs->sockfd);
free(cs);
return 0;
}
/* bind */
if (bind(fd, (struct sockaddr *)&saddr, sizeof(saddr))) {
+ close(fd);
return -errno;
}
/* chmod */
if (chmod(saddr.sun_path, (S_IRWXU | S_IRWXG | S_IRWXO)) < 0) {
+ close(fd);
return -errno;
}
/* listen */
if (-1 == listen(fd, 10)) {
+ close(fd);
return -errno;
}
<?xml version="1.0" encoding="UTF-8"?>
-<node name="/org/tizen/slp/pkgmgr_status">
- <interface name="org.tizen.slp.pkgmgr_status">
+<node name="/org/tizen/pkgmgr_status">
+ <interface name="org.tizen.pkgmgr_status">
<signal name="status">
<arg type="s" name="req_id" direction="out" />
<arg type="s" name="pkgtype" direction="out" />
- <arg type="s" name="pkgname" direction="out" />
+ <arg type="s" name="pkgid" direction="out" />
<arg type="s" name="key" direction="out" />
<arg type="s" name="val" direction="out" />
</signal>
#include <dbus/dbus.h>
/* pure dbus api */
-API DBusConnection *comm_status_broadcast_server_connect(void);
-API void comm_status_broadcast_server_send_signal(DBusConnection *conn,
+API DBusConnection *comm_status_broadcast_server_connect(int comm_status_type);
+API void comm_status_broadcast_server_send_signal(int comm_status_type, DBusConnection *conn,
const char *req_id,
const char *pkg_type,
- const char *pkg_name,
+ const char *pkgid,
const char *key,
const char *val);
API void comm_status_broadcast_server_disconnect(DBusConnection *conn);
/********************************************
* pure dbus signal service for internal use
********************************************/
+static char *__get_prifix(int status_type)
+{
+ char *prifix = NULL;
+
+ switch (status_type) {
+ case COMM_STATUS_BROADCAST_ALL:
+ prifix = COMM_STATUS_BROADCAST_DBUS_SERVICE_PREFIX;
+ break;
+
+ case COMM_STATUS_BROADCAST_INSTALL:
+ prifix = COMM_STATUS_BROADCAST_DBUS_INSTALL_SERVICE_PREFIX;
+ break;
+
+ case COMM_STATUS_BROADCAST_UNINSTALL:
+ prifix = COMM_STATUS_BROADCAST_DBUS_UNINSTALL_SERVICE_PREFIX;
+ break;
+
+ case COMM_STATUS_BROADCAST_MOVE:
+ prifix = COMM_STATUS_BROADCAST_DBUS_MOVE_SERVICE_PREFIX;
+ break;
+
+ case COMM_STATUS_BROADCAST_INSTALL_PROGRESS:
+ prifix = COMM_STATUS_BROADCAST_DBUS_INSTALL_PROGRESS_SERVICE_PREFIX;
+ break;
+
+ case COMM_STATUS_BROADCAST_UPGRADE:
+ prifix = COMM_STATUS_BROADCAST_DBUS_UPGRADE_SERVICE_PREFIX;
+ break;
+
+ case COMM_STATUS_BROADCAST_GET_SIZE:
+ prifix = COMM_STATUS_BROADCAST_DBUS_GET_SIZE_SERVICE_PREFIX;
+ break;
+
+ case COMM_STATUS_BROADCAST_GET_JUNK_INFO:
+ prifix = COMM_STATUS_BROADCAST_DBUS_GET_JUNK_INFO_SERVICE_PREFIX;
+ break;
+
+ default:
+ prifix = NULL;
+ }
+ return prifix;
+}
+
+static char *__get_path(int status_type)
+{
+ char *path = NULL;
+
+ switch (status_type) {
+ case COMM_STATUS_BROADCAST_ALL:
+ path = COMM_STATUS_BROADCAST_DBUS_PATH;
+ break;
-API DBusConnection *comm_status_broadcast_server_connect(void)
+ case COMM_STATUS_BROADCAST_INSTALL:
+ path = COMM_STATUS_BROADCAST_DBUS_INSTALL_PATH;
+ break;
+
+ case COMM_STATUS_BROADCAST_UNINSTALL:
+ path = COMM_STATUS_BROADCAST_DBUS_UNINSTALL_PATH;
+ break;
+
+ case COMM_STATUS_BROADCAST_MOVE:
+ path = COMM_STATUS_BROADCAST_DBUS_MOVE_PATH;
+ break;
+
+ case COMM_STATUS_BROADCAST_INSTALL_PROGRESS:
+ path = COMM_STATUS_BROADCAST_DBUS_INSTALL_PROGRESS_PATH;
+ break;
+
+ case COMM_STATUS_BROADCAST_UPGRADE:
+ path = COMM_STATUS_BROADCAST_DBUS_UPGRADE_PATH;
+ break;
+
+ case COMM_STATUS_BROADCAST_GET_SIZE:
+ path = COMM_STATUS_BROADCAST_DBUS_GET_SIZE_PATH;
+ break;
+
+ case COMM_STATUS_BROADCAST_GET_JUNK_INFO:
+ path = COMM_STATUS_BROADCAST_DBUS_GET_JUNK_INFO_PATH;
+ break;
+
+ default:
+ path = NULL;
+ }
+ return path;
+}
+
+static char *__get_interface(int status_type)
+{
+ char *interface = NULL;
+
+ switch (status_type) {
+ case COMM_STATUS_BROADCAST_ALL:
+ interface = COMM_STATUS_BROADCAST_DBUS_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_INSTALL:
+ interface = COMM_STATUS_BROADCAST_DBUS_INSTALL_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_UNINSTALL:
+ interface = COMM_STATUS_BROADCAST_DBUS_UNINSTALL_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_MOVE:
+ interface = COMM_STATUS_BROADCAST_DBUS_MOVE_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_INSTALL_PROGRESS:
+ interface = COMM_STATUS_BROADCAST_DBUS_INSTALL_PROGRESS_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_UPGRADE:
+ interface = COMM_STATUS_BROADCAST_DBUS_UPGRADE_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_GET_SIZE:
+ interface = COMM_STATUS_BROADCAST_DBUS_GET_SIZE_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_GET_JUNK_INFO:
+ interface = COMM_STATUS_BROADCAST_DBUS_GET_JUNK_INFO_INTERFACE;
+ break;
+
+ default:
+ interface = NULL;
+ }
+ return interface;
+}
+
+static char *__get_name(int status_type)
+{
+ char *name = NULL;
+
+ switch (status_type) {
+ case COMM_STATUS_BROADCAST_ALL:
+ name = COMM_STATUS_BROADCAST_SIGNAL_STATUS;
+ break;
+
+ case COMM_STATUS_BROADCAST_INSTALL:
+ name = COMM_STATUS_BROADCAST_EVENT_INSTALL;
+ break;
+
+ case COMM_STATUS_BROADCAST_UNINSTALL:
+ name = COMM_STATUS_BROADCAST_EVENT_UNINSTALL;
+ break;
+
+ case COMM_STATUS_BROADCAST_MOVE:
+ name = COMM_STATUS_BROADCAST_EVENT_MOVE;
+ break;
+
+ case COMM_STATUS_BROADCAST_INSTALL_PROGRESS:
+ name = COMM_STATUS_BROADCAST_EVENT_INSTALL_PROGRESS;
+ break;
+
+ case COMM_STATUS_BROADCAST_UPGRADE:
+ name = COMM_STATUS_BROADCAST_EVENT_UPGRADE;
+ break;
+
+ case COMM_STATUS_BROADCAST_GET_SIZE:
+ name = COMM_STATUS_BROADCAST_EVENT_GET_SIZE;
+ break;
+
+ case COMM_STATUS_BROADCAST_GET_JUNK_INFO:
+ name = COMM_STATUS_BROADCAST_EVENT_GET_JUNK_INFO;
+ break;
+
+ default:
+ name = NULL;
+ }
+ return name;
+}
+
+API DBusConnection *comm_status_broadcast_server_connect(int status_type)
{
DBusError err;
DBusConnection *conn;
dbus_error_free(&err);
}
dbus_error_free(&err);
- if (NULL == conn)
- exit(1);
- dbus_bus_request_name(conn,
- COMM_STATUS_BROADCAST_DBUS_SERVICE_PREFIX,
- DBUS_NAME_FLAG_ALLOW_REPLACEMENT, &err);
+ if (NULL == conn) {
+ dbg("conn is NULL");
+ return NULL;
+ }
+
+ dbus_bus_request_name(conn, __get_prifix(status_type), DBUS_NAME_FLAG_ALLOW_REPLACEMENT, &err);
if (dbus_error_is_set(&err)) {
- dbg("Failed to request name: %s", err.message);
+ SECURE_LOGD("Failed to request name: %s", err.message);
dbus_error_free(&err);
- exit(1);
+ return NULL;
}
return conn;
}
API void
-comm_status_broadcast_server_send_signal(DBusConnection *conn,
+comm_status_broadcast_server_send_signal(int comm_status_type, DBusConnection *conn,
const char *req_id,
const char *pkg_type,
- const char *pkg_name, const char *key,
+ const char *pkgid, const char *key,
const char *val)
{
dbus_uint32_t serial = 0;
const char *values[] = {
req_id,
pkg_type,
- pkg_name,
+ pkgid,
key,
val
};
int i;
- msg = dbus_message_new_signal(COMM_STATUS_BROADCAST_DBUS_PATH,
- COMM_STATUS_BROADCAST_DBUS_INTERFACE,
- COMM_STATUS_BROADCAST_SIGNAL_STATUS);
+ if (conn == NULL) {
+ dbg("dbus conn is NULL");
+ return;
+ }
+
+ msg = dbus_message_new_signal(__get_path(comm_status_type), __get_interface(comm_status_type), __get_name(comm_status_type));
if (NULL == msg) {
dbg("msg NULL");
- exit(1);
+ return;
}
dbus_message_iter_init_append(msg, &args);
(&args, DBUS_TYPE_STRING, &(values[i]))) {
dbg("dbus_message_iter_append_basic failed:"
" Out of memory");
- exit(1);
+ return;
}
}
if (!dbus_connection_send(conn, msg, &serial)) {
dbg("dbus_connection_send failed: Out of memory");
- exit(1);
+ return;
}
dbus_connection_flush(conn);
dbus_message_unref(msg);
return;
dbus_connection_unref(conn);
}
-
#include <unistd.h>
#include <string.h>
#include <getopt.h>
+#include <db-util.h>
+#include <pkgmgr-info.h>
+
+
+#undef LOG_TAG
+#ifndef LOG_TAG
+#define LOG_TAG "PKGMGR_INSTALLER"
+#endif /* LOG_TAG */
+
+#define MAX_STRLEN 1024
+#define MAX_QUERY_LEN 4096
-#define MAX_STRLEN 512
#define CHK_PI_RET(r) \
do { if (NULL == pi) return (r); } while (0)
/* ADT */
struct pkgmgr_installer {
int request_type;
- int quiet;
+ int move_type;
char *pkgmgr_info;
char *session_id;
char *license_path;
char *quiet_socket_path;
+ char *optional_data;
+ char *caller_pkgid;
DBusConnection *conn;
};
-
/* API */
+static int __send_signal_for_event(int comm_status_type, pkgmgr_installer *pi,
+ const char *pkg_type,
+ const char *pkgid,
+ const char *key, const char *val)
+{
+ if (!pi)
+ return -1;
+
+ if (!pi->conn)
+ pi->conn = comm_status_broadcast_server_connect(comm_status_type);
+
+ char *sid = pi->session_id;
+ if (!sid)
+ sid = "";
+ comm_status_broadcast_server_send_signal(comm_status_type, pi->conn, sid, pkg_type, pkgid, key, val);
+
+ return 0;
+}
+
+API int __send_event(pkgmgr_installer *pi,
+ const char *pkg_type,
+ const char *pkgid,
+ const char *key, const char *val)
+{
+ int r = -1;
+
+ if (strcmp(key,PKGMGR_INSTALLER_START_KEY_STR) == 0) {
+ if(strcmp(val,PKGMGR_INSTALLER_UPGRADE_EVENT_STR) == 0) {
+ pi->request_type = PKGMGR_REQ_UPGRADE;
+ r = __send_signal_for_event(COMM_STATUS_BROADCAST_UPGRADE, pi, pkg_type, pkgid, key, val);
+ }
+ if(pi->request_type == PKGMGR_REQ_INSTALL) {
+ r = __send_signal_for_event(COMM_STATUS_BROADCAST_INSTALL, pi, pkg_type, pkgid, key, val);
+ } else if (pi->request_type == PKGMGR_REQ_UNINSTALL){
+ r = __send_signal_for_event(COMM_STATUS_BROADCAST_UNINSTALL, pi, pkg_type, pkgid, key, val);
+ }
+ } else if (strcmp(key,PKGMGR_INSTALLER_END_KEY_STR) == 0) {
+ if(pi->request_type == PKGMGR_REQ_INSTALL) {
+ r = __send_signal_for_event(COMM_STATUS_BROADCAST_INSTALL, pi, pkg_type, pkgid, key, val);
+ } else if (pi->request_type == PKGMGR_REQ_UNINSTALL){
+ r = __send_signal_for_event(COMM_STATUS_BROADCAST_UNINSTALL, pi, pkg_type, pkgid, key, val);
+ } else if (pi->request_type == PKGMGR_REQ_UPGRADE){
+ r = __send_signal_for_event(COMM_STATUS_BROADCAST_UPGRADE, pi, pkg_type, pkgid, key, val);
+ }
+ } else if (strcmp(key,PKGMGR_INSTALLER_INSTALL_PERCENT_KEY_STR) == 0) {
+ r = __send_signal_for_event(COMM_STATUS_BROADCAST_INSTALL_PROGRESS, pi, pkg_type, pkgid, key, val);
+ }
+
+ return r;
+}
+
API pkgmgr_installer *pkgmgr_installer_new(void)
{
pkgmgr_installer *pi = NULL;
free(pi->pkgmgr_info);
if (pi->session_id)
free(pi->session_id);
+ if (pi->optional_data)
+ free(pi->optional_data);
+ if (pi->caller_pkgid)
+ free(pi->caller_pkgid);
if (pi->conn)
comm_status_broadcast_server_disconnect(pi->conn);
pi->pkgmgr_info = strndup(optarg, MAX_STRLEN);
break;
- case 'r': /* recover */
+ case 'm': /* move */
+ if (mode) {
+ r = -EINVAL;
+ goto RET;
+ }
+ mode = 'm';
+ pi->request_type = PKGMGR_REQ_MOVE;
+ if (pi->pkgmgr_info)
+ free(pi->pkgmgr_info);
+ pi->pkgmgr_info = strndup(optarg, MAX_STRLEN);
+ break;
+
+ case 'r': /* reinstall */
if (mode) {
r = -EINVAL;
goto RET;
}
mode = 'r';
+ pi->request_type = PKGMGR_REQ_REINSTALL;
+ if (pi->pkgmgr_info)
+ free(pi->pkgmgr_info);
+ pi->pkgmgr_info = strndup(optarg, MAX_STRLEN);
break;
- case 'q': /* quiet mode */
- /* if(mode) { r = -EINVAL; goto RET; }
- mode = 'q'; */
- pi->quiet = 1;
- /* pi->quiet_socket_path = strndup(optarg, MAX_STRLEN);
- maximum 255 bytes
- return
- */
+ case 't': /* move type*/
+ pi->move_type = atoi(optarg);
+ break;
+ case 'p': /* caller pkgid*/
+ if (pi->caller_pkgid)
+ free(pi->caller_pkgid);
+ pi->caller_pkgid = strndup(optarg, MAX_STRLEN);
break;
+ case 's': /* smack */
+ if (mode) {
+ r = -EINVAL;
+ goto RET;
+ }
+ mode = 's';
+ pi->request_type = PKGMGR_REQ_SMACK;
+ if (pi->pkgmgr_info)
+ free(pi->pkgmgr_info);
+ pi->pkgmgr_info = strndup(optarg, MAX_STRLEN);
+ break;
+
+ case 'o': /* optional data*/
+ if (pi->optional_data)
+ free(pi->optional_data);
+ pi->optional_data = strndup(optarg, MAX_STRLEN);
+ break;
+
/* Otherwise */
case '?': /* Not an option */
break;
return pi->license_path;
}
+API const char *pkgmgr_installer_get_optional_data(pkgmgr_installer *pi)
+{
+ CHK_PI_RET(PKGMGR_REQ_INVALID);
+ return pi->optional_data;
+}
+
API int pkgmgr_installer_is_quiet(pkgmgr_installer *pi)
{
+/*TODO: need to discuss with HQ to delete this API*/
+#if 0
CHK_PI_RET(PKGMGR_REQ_INVALID);
return pi->quiet;
+#endif
+return 1;
+}
+
+API int pkgmgr_installer_get_move_type(pkgmgr_installer *pi)
+{
+ CHK_PI_RET(PKGMGR_REQ_INVALID);
+ return pi->move_type;
+}
+
+API const char *pkgmgr_installer_get_caller_pkgid(pkgmgr_installer *pi)
+{
+ CHK_PI_RET(PKGMGR_REQ_INVALID);
+ return pi->caller_pkgid;
}
API int
pkgmgr_installer_send_signal(pkgmgr_installer *pi,
const char *pkg_type,
- const char *pkg_name,
+ const char *pkgid,
const char *key, const char *val)
{
int r = 0;
+ if (strcmp(pkg_type,PKGMGR_INSTALLER_GET_SIZE_KEY_STR) == 0) {
+ r = __send_signal_for_event(COMM_STATUS_BROADCAST_GET_SIZE, pi, pkg_type, pkgid, key, val);
+ return r;
+ } else if (strcmp(pkg_type,PKGMGR_INSTALLER_GET_JUNK_INFO_KEY_STR) == 0) {
+ r = __send_signal_for_event(COMM_STATUS_BROADCAST_GET_JUNK_INFO, pi, pkg_type, pkgid, key, val);
+ return r;
+ }
+
if (!pi->conn)
- pi->conn = comm_status_broadcast_server_connect();
+ pi->conn = comm_status_broadcast_server_connect(COMM_STATUS_BROADCAST_ALL);
char *sid = pi->session_id;
if (!sid)
sid = "";
- comm_status_broadcast_server_send_signal(pi->conn, sid, pkg_type,
- pkg_name, key, val);
+ comm_status_broadcast_server_send_signal(COMM_STATUS_BROADCAST_ALL, pi->conn, sid, pkg_type,
+ pkgid, key, val);
+
+ __send_event(pi, pkg_type, pkgid, key, val);
return r;
}
+
+API int pkgmgr_installer_create_certinfo_set_handle(pkgmgr_instcertinfo_h *handle)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_create_certinfo_set_handle(handle);
+ return ret;
+}
+
+API int pkgmgr_installer_set_cert_value(pkgmgr_instcertinfo_h handle, pkgmgr_instcert_type cert_type, char *cert_value)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_set_cert_value(handle, cert_type, cert_value);
+ return ret;
+}
+
+API int pkgmgr_installer_save_certinfo(const char *pkgid, pkgmgr_instcertinfo_h handle)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_save_certinfo(pkgid, handle);
+ return ret;
+}
+
+API int pkgmgr_installer_destroy_certinfo_set_handle(pkgmgr_instcertinfo_h handle)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_destroy_certinfo_set_handle(handle);
+ return ret;
+}
+
+API int pkgmgr_installer_delete_certinfo(const char *pkgid)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_delete_certinfo(pkgid);
+ return ret;
+}
#include <stdlib.h>
#include <getopt.h>
+#include <dlog.h>
+
+
/**
* pkgmgr_installer is an opaque type for an object
*/
typedef struct pkgmgr_installer pkgmgr_installer;
+typedef void* pkgmgr_instcertinfo_h;
+
+/**
+ * @brief listening event type in pkgmgr.
+ */
+#define PKGMGR_INSTALLER_START_KEY_STR "start"
+#define PKGMGR_INSTALLER_END_KEY_STR "end"
+#define PKGMGR_INSTALLER_INSTALL_PERCENT_KEY_STR "install_percent"
+#define PKGMGR_INSTALLER_GET_SIZE_KEY_STR "get_size"
+#define PKGMGR_INSTALLER_GET_JUNK_INFO_KEY_STR "get_junkinfo"
+
+#define PKGMGR_INSTALLER_INSTALL_EVENT_STR "install"
+#define PKGMGR_INSTALLER_UNINSTALL_EVENT_STR "uninstall"
+#define PKGMGR_INSTALLER_MOVE_EVENT_STR "move"
+#define PKGMGR_INSTALLER_UPGRADE_EVENT_STR "update"
+#define PKGMGR_INSTALLER_OK_EVENT_STR "ok"
+#define PKGMGR_INSTALLER_FAIL_EVENT_STR "fail"
+
+
+
/**
* Request type.
PKGMGR_REQ_INSTALL = 1,
PKGMGR_REQ_UNINSTALL = 2,
PKGMGR_REQ_CLEAR = 3,
- PKGMGR_REQ_RECOVER = 4
+ PKGMGR_REQ_MOVE = 4,
+ PKGMGR_REQ_RECOVER = 5,
+ PKGMGR_REQ_REINSTALL = 6,
+ PKGMGR_REQ_GETSIZE = 7,
+ PKGMGR_REQ_UPGRADE = 8,
+ PKGMGR_REQ_SMACK = 9,
+ PKGMGR_REQ_GETJUNKINFO = 10,
+};
+
+enum {
+ PKGMGR_INSTALLER_EINVAL = -2, /**< Invalid argument */
+ PKGMGR_INSTALLER_ERROR = -1, /**< General error */
+ PKGMGR_INSTALLER_EOK = 0 /**< General success */
};
+
+typedef enum {
+ PM_SET_AUTHOR_ROOT_CERT = 0,
+ PM_SET_AUTHOR_INTERMEDIATE_CERT = 1,
+ PM_SET_AUTHOR_SIGNER_CERT = 2,
+ PM_SET_DISTRIBUTOR_ROOT_CERT = 3,
+ PM_SET_DISTRIBUTOR_INTERMEDIATE_CERT = 4,
+ PM_SET_DISTRIBUTOR_SIGNER_CERT = 5,
+ PM_SET_DISTRIBUTOR2_ROOT_CERT = 6,
+ PM_SET_DISTRIBUTOR2_INTERMEDIATE_CERT = 7,
+ PM_SET_DISTRIBUTOR2_SIGNER_CERT = 8,
+}pkgmgr_instcert_type;
+
+
/**
* @brief Create a pkgmgr_installer object.
* @pre None
case PKGMGR_REQ_RECOVER:
// Do recovere processing
break;
+ case PKGMGR_REQ_REINSTALL:
+ // Do reinstall processing
+ break;
default:
goto CLEANUP_END;
}
const char *pkgmgr_installer_get_license_path(pkgmgr_installer *pi);
/**
+ @brief Get a optional data
+ @pre pkgmgr_installer_receive_request() must be called.
+ @post None
+ @see pkgmgr_installer_receive_request
+ @param[in] pi pkgmgr_installer object
+ @return optional data
+ @retval NULL on function failure
+ @remark Returned string must not be modified.
+ @code
+#include <pkgmgr_installer.h>
+int main(int argc, char **argv)
+{
+ pkgmgr_installer *pi;
+ int r = 0;
+ char *optional_data = NULL;
+
+ pi = pkgmgr_installer_new();
+ if(!pi) return -1;
+ if(pkgmgr_installer_receive_request(pi, argc, argv)) {
+ r = -1;
+ goto CLEANUP_RET;
+ }
+ optional_data = (char *) pkgmgr_installer_get_optional_data(pi);
+
+ // Do something...
+
+ pkgmgr_installer_free(pi);
+ return r;
+}
+@endcode
+ */
+const char *pkgmgr_installer_get_optional_data(pkgmgr_installer *pi);
+
+/**
@brief Get if a request is with quite mode or not
@pre pkgmgr_installer_receive_request() must be called.
@post None
int pkgmgr_installer_is_quiet(pkgmgr_installer *pi);
/**
+ @brief Get move type
+ @pre pkgmgr_installer_receive_request() must be called.
+ @post None
+ @see pkgmgr_installer_receive_request
+ @param[in] pi pkgmgr_installer object
+ @return Operation result
+ @retval enum value of move type
+ @remark None
+ @code
+#include <pkgmgr_installer.h>
+int main(int argc, char **argv)
+{
+ pkgmgr_installer *pi;
+ int r = 0;
+
+ pi = pkgmgr_installer_new();
+ if(!pi) return -1;
+ if(pkgmgr_installer_receive_request(pi, argc, argv)) {
+ r = -1;
+ goto CLEANUP_RET;
+ }
+ move_type = pkgmgr_installer_get_move_type(pi);
+
+ //Do Something
+
+ pkgmgr_installer_free(pi);
+ return r;
+}
+ @endcode
+ */
+int pkgmgr_installer_get_move_type(pkgmgr_installer *pi);
+
+/**
+ @brief Get caller package id
+ @pre pkgmgr_installer_receive_request() must be called.
+ @post None
+ @see pkgmgr_installer_receive_request
+ @param[in] pi pkgmgr_installer object
+ @return Operation result
+ @retval enum value of move type
+ @remark None
+ @code
+#include <pkgmgr_installer.h>
+int main(int argc, char **argv)
+{
+ pkgmgr_installer *pi;
+ int r = 0;
+ char *pkgid = NULL;
+
+ pi = pkgmgr_installer_new();
+ if(!pi) return -1;
+ if(pkgmgr_installer_receive_request(pi, argc, argv)) {
+ r = -1;
+ goto CLEANUP_RET;
+ }
+ pkgid = (char *) pkgmgr_installer_get_caller_pkgid(pi);
+
+ // Do something...
+
+ pkgmgr_installer_free(pi);
+ return r;
+}
+ @endcode
+ */
+const char *pkgmgr_installer_get_caller_pkgid(pkgmgr_installer *pi);
+
+/**
@brief Send a process status signal
@pre None
@post None
@see None
@param[in] pi pkgmgr_installer object
@param[in] pkg_type package type: "deb", "jar", "wgt", ...
- @param[in] pkg_name package name
+ @param[in] pkgid package id
@param[in] key Signal key
@param[in] val Signal value
@return Operation result
*/
int pkgmgr_installer_send_signal(pkgmgr_installer *pi,
const char *pkg_type,
- const char *pkg_name, const char *key,
+ const char *pkgid, const char *key,
const char *val);
+/**
+ * @brief This API creates the certinfo handle.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[out] handle pointer to cert info handle
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_installer_create_certinfo_set_handle(pkgmgr_instcertinfo_h *handle);
+
+/**
+ * @brief This API sets cert value for corresponding cert type.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to cert info handle
+ * @param[in] cert_type enum value for certificate type
+ * @param[in] cert_value certificate value
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_installer_set_cert_value(pkgmgr_instcertinfo_h handle, pkgmgr_instcert_type cert_type, char *cert_value);
+
+/**
+ * @brief This API saves cert info in DB.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] pkgid package ID
+ * @param[in] handle pointer to cert info handle
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_installer_save_certinfo(const char *pkgid, pkgmgr_instcertinfo_h handle);
+
+/**
+ * @brief This API destroys cert info handle freeing all resources.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to cert info handle
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_installer_destroy_certinfo_set_handle(pkgmgr_instcertinfo_h handle);
+
+/**
+ * @brief This API deletes cert info from DB. To be used to cleanup info upon pkg uninstallation
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] pkgid package ID
+ * @return 0 if success, error code(<0) if fail\n
+*/
+ int pkgmgr_installer_delete_certinfo(const char *pkgid);
+
#ifdef __cplusplus
}
#endif
#endif
/* Supported options */
-const char *short_opts = "k:l:i:d:c:rq";
+const char *short_opts = "k:l:i:d:c:m:t:o:r:p:s:";
const struct option long_opts[] = {
{ "session-id", 1, NULL, 'k' },
{ "license-path", 1, NULL, 'l' },
{ "install", 1, NULL, 'i' },
{ "uninstall", 1, NULL, 'd' },
{ "clear", 1, NULL, 'c' },
- { "recover", 0, NULL, 'r' },
- { "quiet", 1, NULL, 'q' },
+ { "move", 1, NULL, 'm' },
+ { "move-type", 1, NULL, 't' },
+ { "optional-data", 0, NULL, 'o' },
+ { "reinstall", 0, NULL, 'r' },
+ { "caller-pkgid", 1, NULL, 'p' },
+ { "smack", 1, NULL, 's' },
{ 0, 0, 0, 0 } /* sentinel */
};
void
stat_cb(void *data, const char *req_id, const char *pkg_type,
- const char *pkg_name, const char *key, const char *val)
+ const char *pkgid, const char *key, const char *val)
{
printf(">>user callback>> Got: %s %s %s %s %s\n", req_id, pkg_type,
- pkg_name, key, val);
+ pkgid, key, val);
g_main_loop_quit(mainloop);
}
"dpkg", "test_pkg", "arg1 arg2 arg3",
"this_is_a_cookie", 0);
+ printf("comm_client_request returns [%d]\n",ret);
printf("client: waiting signal...\n");
- comm_client_set_status_callback(cc, stat_cb, NULL);
+ comm_client_set_status_callback(COMM_STATUS_BROADCAST_ALL, cc, stat_cb, NULL);
g_main_loop_run(mainloop);
void
req_cb(void *cb_data, const char *req_id, const int req_type,
- const char *pkg_type, const char *pkg_name, const char *args,
+ const char *pkg_type, const char *pkgid, const char *args,
const char *cookie, int *ret)
{
/* TODO: Do your job here */
printf(">> in callback >> Got request: %s %d %s %s %s (cookie:%s)\n",
- req_id, req_type, pkg_type, pkg_name, args, cookie);
+ req_id, req_type, pkg_type, pkgid, args, cookie);
}
gboolean queue_job(void *data)
static int _main_dbus(int argc, char **argv);
static int _main_dbus(int argc, char **argv)
{
- DBusConnection *conn = comm_status_broadcast_server_connect();
+ DBusConnection *conn = comm_status_broadcast_server_connect(COMM_STATUS_BROADCAST_ALL);
int i;
for (i = 0; i < 100; i++) {
- comm_status_broadcast_server_send_signal(conn, "test_id",
- "test", "test_pkgname",
+ comm_status_broadcast_server_send_signal(COMM_STATUS_BROADCAST_ALL, conn, "test_id",
+ "test", "test_pkgid",
"test_key",
"test_val");
sleep(1);
static void
get_signal_cb(void *cb_data, const char *req_id, const char *pkg_type,
- const char *pkg_name, const char *key, const char *val)
+ const char *pkgid, const char *key, const char *val)
{
struct signal_counter *counter = (struct signal_counter *)cb_data;
struct signal_counter counter = { 0, };
comm_client *cc;
cc = comm_client_new();
- comm_client_set_status_callback(cc, get_signal_cb, &counter);
+ comm_client_set_status_callback(COMM_STATUS_BROADCAST_ALL, cc, get_signal_cb, &counter);
/* sender */
g_timeout_add_seconds(1, timer_send_signal, pi);
@PREFIX@/bin/pkgmgr-server
-@PREFIX@/share/dbus-1/services/org.tizen.slp.pkgmgr.service
+@PREFIX@/share/dbus-1/services/org.tizen.pkgmgr.service
@PREFIX@/share/locale/*
- Install request with return callback function
@code
-// the package path is "/opt/apps/org.tizen.hello.deb"
+// the package path is "/opt/usr/apps/org.tizen.hello.deb"
#include <package-manager.h>
int static return_cb(pkg_request_id req_id, const char *pkg_type, const char *pkg_name, const char *key, const char *val, const void *pmsg, void *data)
return -1;
}
- result = pkgmgr_client_install(pc, NULL, des, "/opt/apps/org.tizen.hello.deb", NULL, PM_DEFAULT, return_cb, pc);
+ result = pkgmgr_client_install(pc, NULL, des, "/opt/usr/apps/org.tizen.hello.deb", NULL, PM_DEFAULT, return_cb, pc);
if(result < 0) {
fprintf(stderr, "Install failed! %d\n", result);
return -1;
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 __JUNK_MANAGER_H__
+#define __JUNK_MANAGER_H__
+
+#include <package-manager.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void *junkmgr_h; /** junkmgr handle */
+typedef void *junkmgr_result_h; /** junkmgr result handle */
+
+typedef enum {
+ JUNKMGR_CATEGORY_IMAGES = 0, /** Images directory */
+ JUNKMGR_CATEGORY_SOUNDS = 1, /** Sounds directory */
+ JUNKMGR_CATEGORY_VIDEOS = 2, /** Videos directory */
+ JUNKMGR_CATEGORY_CAMERA = 3, /** Camera directory */
+ JUNKMGR_CATEGORY_DOWNLOADS = 4, /** Downloads directory */
+ JUNKMGR_CATEGORY_MUSIC = 5, /** Music directory */
+ JUNKMGR_CATEGORY_DOCUMENTS = 6, /** Documents directory */
+ JUNKMGR_CATEGORY_OTHERS = 7, /** Othres directory */
+ JUNKMGR_CATEGORY_SYSTEM_RINGTONES = 8, /** System ringtones directory */
+ JUNKMGR_CATEGORY_DCIM = 9, /** DCIM directory */
+ JUNKMGR_CATEGORY_MISC = 10 /** Directories not belonging to the category above */
+} junkmgr_category_e;
+
+typedef enum {
+ JUNKMGR_FILE_TYPE_FILE = 0, /** File */
+ JUNKMGR_FILE_TYPE_DIR = 1 /** Directory */
+} junkmgr_file_type_e;
+
+typedef enum {
+ JUNKMGR_STORAGE_TYPE_INTERNAL = 0, /** Internal storage */
+ JUNKMGR_STORAGE_TYPE_EXTERNAL = 1 /** External storage */
+} junkmgr_storage_type_e;
+
+typedef enum {
+ JUNKMGR_E_SUCCESS = 0,
+ JUNKMGR_E_INVALID = -1,
+ JUNKMGR_E_PRIV = -2,
+ JUNKMGR_E_ACCESS = -3,
+ JUNKMGR_E_NOMEM = -4,
+ JUNKMGR_E_NOT_FOUND = -5,
+ JUNKMGR_E_END_OF_RESULT = -6,
+ JUNKMGR_E_OBJECT_LOCKED = -7,
+ JUNKMGR_E_IO = -8,
+ JUNKMGR_E_SYSTEM = -9
+} junkmgr_error_e;
+
+/**
+ * @brief Creates the junkmgr instance.
+ *
+ * @return junkmgr handle on success, otherwise NULL
+*/
+junkmgr_h junkmgr_create_handle(void);
+
+/**
+ * @brief Destroys the junkmgr instance.
+ *
+ * @param[in] junkmgr junkmgr handle
+ *
+ * @retval #JUNKMGR_E_SUCCESS Successful
+ * @retval #JUNKMGR_E_INVALID Invalid parameter
+ * @retval #JUNKMGR_E_SYSTEM Internal error
+ */
+int junkmgr_destroy_handle(junkmgr_h junkmgr);
+
+/**
+ * @brief Called when searching the junk entries is completed.
+ * @details The specified handle is used to get information of junk files such as size.
+ * @see junkmgr_result_cursor_step_next()
+ */
+typedef void (*junkmgr_result_receive_cb)(int reqid, const junkmgr_result_h handle, void *user_data);
+
+/**
+ * @brief Called when clearing the junk files are completed.
+ */
+typedef void (*junkmgr_clear_completed_cb)(int reqid, void *user_data);
+
+/**
+ * @brief Gets the topmost directories including junk files.
+ * @details The root directories including junk files are asynchronously obtained by the specified callback function.
+ *
+ * @param[in] junkmgr junkmgr handle
+ * @param[in] result_cb The asynchronous callback function to get the topmost directories including junk files
+ * @param[in] user_data User data to be passed to the callback function
+ * @param[out] reqid Request ID
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #JUNKMGR_E_SUCCESS Successful
+ * @retval #JUNKMGR_E_INVALID Invalid parameter
+ * @retval #JUNKMGR_E_PRIV Privilege denied
+ * @retval #JUNKMGR_E_NOMEM Insufficient memory
+ * @retval #JUNKMGR_E_SYSTEM Internal error
+ */
+int junkmgr_get_junk_root_dirs(junkmgr_h junkmgr, junkmgr_result_receive_cb result_cb, void *user_data, int *reqid);
+
+/**
+ * @brief Gets the junk files.
+ * @details The junk files are asynchronously obtained by the specified callback function.
+ *
+ * @param[in] junkmgr junkmgr handle
+ * @param[in] junk_path The root directory including junk files
+ * @param[in] result_cb The asynchronous callback function to get the junk files
+ * @param[in] user_data User data to be passed to the callback function
+ * @param[out] reqid Request ID
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #JUNKMGR_E_SUCCESS Successful
+ * @retval #JUNKMGR_E_INVALID Invalid parameter
+ * @retval #JUNKMGR_E_PRIV Privilege denied
+ * @retval #JUNKMGR_E_NOMEM Insufficient memory
+ * @retval #JUNKMGR_E_SYSTEM Internal error
+ */
+int junkmgr_get_junk_files(junkmgr_h junkmgr, char const *junk_path, junkmgr_result_receive_cb result_cb, void *user_data, int *reqid);
+
+/**
+ * @brief Moves the cursor to the next position.
+ *
+ * @param[in] handle The pointer handling the result information for junk files
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #JUNKMGR_E_SUCCESS Successful
+ * @retval #JUNKMGR_E_INVALID Invalid parameter
+ * @retval #JUNKMGR_E_END_OF_RESULT The cursor has reached out of the result set.
+ * @retval #JUNKMGR_E_OBJECT_LOCKED The cursor is locked.
+ * @retval #JUNKMGR_E_NOMEM Insufficient memory
+ * @retval #JUNKMGR_E_IO I/O error
+ * @retval #JUNKMGR_E_SYSTEM Internal error
+ */
+int junkmgr_result_cursor_step_next(junkmgr_result_h handle);
+
+/**
+ * @brief Gets the junk file name.
+ * @remarks The returned junk name should be released.
+ *
+ * @param[in] handle The pointer handling the result information for junk files
+ * @param[out] junk_name The junk file name
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #JUNKMGR_E_SUCCESS Successful
+ * @retval #JUNKMGR_E_INVALID Invalid parameter
+ * @retval #JUNKMGR_E_OBJECT_LOCKED The cursor is locked.
+ * @retval #JUNKMGR_E_NOMEM Insufficient memory
+ * @retval #JUNKMGR_E_IO I/O error
+ * @retval #JUNKMGR_E_SYSTEM Internal error
+ */
+int junkmgr_result_cursor_get_junk_name(junkmgr_result_h handle, char **junk_name);
+
+/**
+ * @brief Gets the category.
+ *
+ * @param[in] handle The pointer handling the result information for junk files
+ * @param[out] category The junk file name
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #JUNKMGR_E_SUCCESS Successful
+ * @retval #JUNKMGR_E_INVALID Invalid parameter
+ * @retval #JUNKMGR_E_OBJECT_LOCKED The cursor is locked.
+ * @retval #JUNKMGR_E_NOMEM Insufficient memory
+ * @retval #JUNKMGR_E_IO I/O error
+ * @retval #JUNKMGR_E_SYSTEM Internal error
+ */
+int junkmgr_result_cursor_get_category(junkmgr_result_h handle, junkmgr_category_e *category);
+
+/**
+ * @brief Gets the file type.
+ *
+ * @param[in] handle The pointer handling the result information for junk files
+ * @param[out] file_type The type is file or directory.
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #JUNKMGR_E_SUCCESS Successful
+ * @retval #JUNKMGR_E_INVALID Invalid parameter
+ * @retval #JUNKMGR_E_OBJECT_LOCKED The cursor is locked.
+ * @retval #JUNKMGR_E_NOMEM Insufficient memory
+ * @retval #JUNKMGR_E_IO I/O error
+ * @retval #JUNKMGR_E_SYSTEM Internal error
+ */
+int junkmgr_result_cursor_get_file_type(junkmgr_result_h handle, junkmgr_file_type_e *file_type);
+
+/**
+ * @brief Gets the storage type.
+ *
+ * @param[in] handle The pointer handling the result information for junk files
+ * @param[out] storage The storage where junk files are stored
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #JUNKMGR_E_SUCCESS Successful
+ * @retval #JUNKMGR_E_INVALID Invalid parameter
+ * @retval #JUNKMGR_E_OBJECT_LOCKED The cursor is locked.
+ * @retval #JUNKMGR_E_NOMEM Insufficient memory
+ * @retval #JUNKMGR_E_IO I/O error
+ * @retval #JUNKMGR_E_SYSTEM Internal error
+ */
+int junkmgr_result_cursor_get_storage_type(junkmgr_result_h handle, junkmgr_storage_type_e *storage);
+
+/**
+ * @brief Gets the size of the junk file.
+ *
+ * @param[in] handle The pointer handling the result information for junk files
+ * @param[out] junk_size The file size of the junk file
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #JUNKMGR_E_SUCCESS Successful
+ * @retval #JUNKMGR_E_INVALID Invalid parameter
+ * @retval #JUNKMGR_E_OBJECT_LOCKED The cursor is locked.
+ * @retval #JUNKMGR_E_NOMEM Insufficient memory
+ * @retval #JUNKMGR_E_IO I/O error
+ * @retval #JUNKMGR_E_SYSTEM Internal error
+ */
+int junkmgr_result_cursor_get_junk_size(junkmgr_result_h handle, long long *junk_size);
+
+/**
+ * @brief Gets the path of the junk file.
+ * @remarks The returned junk path should be released.
+ *
+ * @param[in] handle The pointer handling the result information for junk files
+ * @param[out] junk_path The path of the junk file
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #JUNKMGR_E_SUCCESS Successful
+ * @retval #JUNKMGR_E_INVALID Invalid parameter
+ * @retval #JUNKMGR_E_OBJECT_LOCKED The cursor is locked.
+ * @retval #JUNKMGR_E_NOMEM Insufficient memory
+ * @retval #JUNKMGR_E_IO I/O error
+ * @retval #JUNKMGR_E_SYSTEM Internal error
+ */
+int junkmgr_result_cursor_get_junk_path(junkmgr_result_h handle, char **junk_path);
+
+/**
+ *
+ * @brief Removes the specified junk file
+ *
+ * @param[in] junkmgr junkmgr handle
+ * @param[in] junk_path The path of the specified junk file
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #JUNKMGR_E_SUCCESS Successful
+ * @retval #JUNKMGR_E_INVALID Invalid parameter
+ * @retval #JUNKMGR_E_PRIV Privilege denied
+ * @retval #JUNKMGR_E_ACCESS Access denied
+ * @retval #JUNKMGR_E_OBJECT_LOCKED The cursor is locked.
+ * @retval #JUNKMGR_E_NOMEM Insufficient memory
+ * @retval #JUNKMGR_E_NOT_FOUND Junk not found
+ * @retval #JUNKMGR_E_SYSTEM Internal error
+ */
+int junkmgr_remove_junk_file(junkmgr_h junkmgr, const char *junk_path);
+
+/**
+ * @brief Remove all the junk files.
+ *
+ * @param[in] junkmgr junkmgr handle
+ * @param[in] result_cb The asynchronous callback function called when clearing the junk files are completed.
+ * @param[in] user_data User data to be passed to the callback function
+ * @param[out] reqid Request ID
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #JUNKMGR_E_SUCCESS Successful
+ * @retval #JUNKMGR_E_INVALID Invalid parameter
+ * @retval #JUNKMGR_E_PRIV Privilege denied
+ * @retval #JUNKMGR_E_NOMEM Insufficient memory
+ * @retval #JUNKMGR_E_SYSTEM Internal error
+ */
+int junkmgr_clear_all_junk_files(junkmgr_h junkmgr, junkmgr_clear_completed_cb result_cb, void *user_data, int *reqid);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__JUNK_MANAGER_H__
--- /dev/null
+/*
+ * pkgmgr-debug
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: junsuk. oh <junsuk77.oh@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __PKG_MANAGER_DEBUG_H__
+#define __PKG_MANAGER_DEBUG_H__
+
+#include <dlog.h>
+
+#define _LOGE(fmt, arg...) LOGE(fmt, ##arg)
+#define _LOGD(fmt, arg...) LOGD(fmt, ##arg)
+#define _LOGS(fmt, arg...) SECURE_LOGD(fmt, ##arg)
+
+
+#define COLOR_RED "\033[0;31m"
+#define COLOR_BLUE "\033[0;34m"
+#define COLOR_END "\033[0;m"
+
+#define PKGMGR_DEBUG(fmt, ...)\
+ do\
+ {\
+ LOGD("[%s(): %d]" fmt, __FUNCTION__, __LINE__,##__VA_ARGS__);\
+ } while (0)
+
+#define PKGMGR_DEBUG_ERR(fmt, ...)\
+ do\
+ {\
+ LOGE(COLOR_RED"[%s(): %d]" fmt COLOR_END, __FUNCTION__, __LINE__,##__VA_ARGS__);\
+ }while (0)
+
+#define PKGMGR_BEGIN() \
+ do\
+ {\
+ LOGD(COLOR_BLUE"[%s(): %d] BEGIN >>>>"COLOR_END, __FUNCTION__ ,__LINE__);\
+ } while( 0 )
+
+#define PKGMGR_END() \
+ do\
+ {\
+ LOGD(COLOR_BLUE"[%s(): %d] END <<<<"COLOR_END, __FUNCTION__,__LINE__ );\
+ } \
+ while( 0 )
+
+#define ret_if(expr) do { \
+ if (expr) { \
+ PKGMGR_DEBUG_ERR("(%s) ", #expr); \
+ PKGMGR_END();\
+ return; \
+ } \
+} while (0)
+
+#define retm_if(expr, fmt, arg...) do { \
+ if (expr) { \
+ PKGMGR_DEBUG_ERR("(%s) "fmt, #expr, ##arg); \
+ PKGMGR_END();\
+ return; \
+ } \
+ } while (0)
+
+#define retv_if(expr, val) do { \
+ if (expr) { \
+ PKGMGR_DEBUG_ERR("(%s) ", #expr); \
+ PKGMGR_END();\
+ return (val); \
+ } \
+ } while (0)
+
+#define retvm_if(expr, val, fmt, arg...) do { \
+ if (expr) { \
+ PKGMGR_DEBUG_ERR("(%s) "fmt, #expr, ##arg); \
+ PKGMGR_END();\
+ return (val); \
+ } \
+} while (0)
+
+#define trym_if(expr, fmt, arg...) do { \
+ if (expr) { \
+ PKGMGR_DEBUG_ERR("(%s) "fmt, #expr, ##arg); \
+ goto catch; \
+ } \
+ } while (0)
+
+#define tryvm_if(expr, val, fmt, arg...) do { \
+ if (expr) { \
+ PKGMGR_DEBUG_ERR("(%s) "fmt, #expr, ##arg); \
+ val; \
+ goto catch; \
+ } \
+ } while (0)
+
+#endif /* __PKG_MANAGER_DEBUG_H__ */
-#ifndef __PKG_MANAGER_INFO_H__
-#define __PKG_MANAGER_INFO_H__
+#ifndef __PKG_MANAGER_INTERNAL_H__
+#define __PKG_MANAGER_INTERNAL_H__
+
+#include <unistd.h>
+#include <ctype.h>
-//#include "package-manager.h"
#include "package-manager-plugin.h"
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#define PKG_BACKEND "backend:"
+#define PKG_BACKENDLIB "backendlib:"
+#define PKG_CONF_PATH "/usr/etc/package-manager/pkg_path.conf"
+#define PKG_DATA_PATH "/opt/usr/data/pkgmgr"
+
+#define PKG_STATUS "STATUS"
+
+#define PKG_STRING_LEN_MAX 1024
+#define PKG_EXT_LEN_MAX 20
+#define PKG_ARGC_MAX 16
+
typedef package_manager_pkg_info_t package_manager_app_info_t;
-char *_get_pkg_type_from_desktop_file(const char *pkg_name);
+char *_get_pkg_type_from_desktop_file(const char *pkgid);
package_manager_pkg_info_t *_pkg_malloc_appinfo(int num);
const package_manager_pkg_detail_info_t *
pkg_detail_info);
-#endif /* __PKG_MANAGER_INFO_H__ */
+void _app_str_trim(char *input);
+char *_get_backend_path(const char *input_path);
+char *_get_backend_path_with_type(const char *type);
+
+int _get_mime_from_file(const char *filename, char *mimetype, int len);
+int _get_mime_extension(const char *mimetype, char *ext, int len);
+
+char *_get_type_from_zip(const char *zip_name);
+
+#endif /* __PKG_MANAGER_INTERNAL_H__ */
+++ /dev/null
-/*
- * slp-pkgmgr
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
- * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-
-
-
-
-
-
-
-#ifndef __PKG_MANAGER_PLUGIN_H__
-#define __PKG_MANAGER_PLUGIN_H__
-
-#include "package-manager-types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef void (*_pkg_plugin_unload) (void);
-typedef int (*_pkg_plugin_pkg_is_installed) (const char *pkg_name);
-typedef int (*_pkg_plugin_get_installed_pkg_list) (const char *category,
- const char *option,
- package_manager_pkg_info_t
- **list, int *count);
-typedef int (*_pkg_plugin_get_pkg_detail_info) (const char *pkg_name,
- package_manager_pkg_detail_info_t
- *pkg_detail_info);
-typedef int (*_pkg_plugin_get_pkg_detail_info_from_package) (const char
- *pkg_path,
- package_manager_pkg_detail_info_t
- *pkg_detail_info);
-
-typedef struct _pkg_plugin_set {
-char pkg_type[PKG_TYPE_STRING_LEN_MAX];
-void *plugin_handle;
-_pkg_plugin_unload plugin_on_unload;
-_pkg_plugin_pkg_is_installed pkg_is_installed;
-_pkg_plugin_get_installed_pkg_list get_installed_pkg_list;
-_pkg_plugin_get_pkg_detail_info get_pkg_detail_info;
-_pkg_plugin_get_pkg_detail_info_from_package
-get_pkg_detail_info_from_package;
-} pkg_plugin_set;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __PKG_MANAGER_PLUGIN_H__ */
--- /dev/null
+../types/include/package-manager-plugin.h
\ No newline at end of file
+++ /dev/null
-/*
- * slp-pkgmgr
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
- * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-
-
-
-
-
-
-
-/**
- * @file package-manager-types.h
- * @author Sewook Park <sewook7.park@samsung.com>
- * @version 0.1
- * @brief This file declares slp-pkgmgr-types
- *
- * @addtogroup APPLICATION_FRAMEWORK
- * @{
- *
- * @defgroup pacakge_manager_type
- * @section Header to use them:
- * @code
- * #include "package-manager-types.h"
- * @endcode
- *
- * @addtogroup pacakge_manager_type
- * @{
- */
-
-#ifndef __PKG_MANAGER_TYPES_H__
-#define __PKG_MANAGER_TYPES_H__
-
-#include <errno.h>
-#include <stdbool.h>
-#include <time.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @mainpage
- *
- * This is package manager
- *
- * Packaeg manager is used to install/uninstall the packages.\n
- * package includes dpkg, java, widget, etc. and it can be added\n
- * Security is considered on current package manager\n
- *
- */
-
-/**
- * @file package-manager.h
- * @brief Package Manager header
- *
- * Generated by Sewook Park <sewook7.park@samsung.com>
- */
-
-#define PKG_TYPE_STRING_LEN_MAX 128
-#define PKG_NAME_STRING_LEN_MAX 128
-#define PKG_VERSION_STRING_LEN_MAX 128
-#define PKG_VALUE_STRING_LEN_MAX 512
-#define PKG_URL_STRING_LEN_MAX 1024
-
-/**
- *@brief application's structure retrieved by package-manager
- */
-typedef struct _package_manager_pkg_info_t {
- char pkg_type[PKG_TYPE_STRING_LEN_MAX];
- char pkg_name[PKG_NAME_STRING_LEN_MAX];
- char version[PKG_VERSION_STRING_LEN_MAX];
- struct _package_manager_pkg_info_t *next;
-} package_manager_pkg_info_t;
-
-typedef struct _package_manager_pkg_detail_info_t {
- char pkg_type[PKG_TYPE_STRING_LEN_MAX];
- char pkg_name[PKG_NAME_STRING_LEN_MAX];
- char version[PKG_VERSION_STRING_LEN_MAX];
- char pkg_description[PKG_VALUE_STRING_LEN_MAX];
- char min_platform_version[PKG_VERSION_STRING_LEN_MAX];
- time_t installed_time; /* installed time it must be GMT+0 time */
- int installed_size; /* installed total size */
- int app_size; /* installed app size */
- int data_size; /* data size which is made on run time */
- char optional_id[PKG_NAME_STRING_LEN_MAX]; /*package ID if exists */
- void *pkg_optional_info;
-} package_manager_pkg_detail_info_t;
-
-/** @} */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __PKG_MANAGER_TYPES_H__ */
-/**
- * @}
- * @}
- */
-
--- /dev/null
+../types/include/package-manager-types.h
\ No newline at end of file
+++ /dev/null
-/*
- * slp-pkgmgr
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
- * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-
-
-
-
-
-
-
-/**
- * @file package-manager.h
- * @author Sewook Park <sewook7.park@samsung.com>
- * @version 0.1
- * @brief This file declares API of slp-pkgmgr library
- *
- * @addtogroup APPLICATION_FRAMEWORK
- * @{
- *
- * @defgroup PackageManager
- * @section Header to use them:
- * @code
- * #include "package-manager.h"
- * @endcode
- *
- * @addtogroup PackageManager
- * @{
- */
-
-#ifndef __PKG_MANAGER_H__
-#define __PKG_MANAGER_H__
-
-#include <errno.h>
-#include <stdbool.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef DEPRECATED
-#define DEPRECATED __attribute__ ((__deprecated__))
-#endif
-
-/**
- * @mainpage
- *
- * This is package manager
- *
- * Packaeg manager is used to install/uninstall the packages.\n
- * package includes dpkg, java, widget, etc. and it can be added\n
- * Security is considered on current package manager\n
- *
- */
-
-/**
- * @file package-manager.h
- * @brief Package Manager header
- *
- * Generated by Sewook Park <sewook7.park@samsung.com>
- */
-
-
-
-/**
- * @addtogroup PackageManager
- * @{
- */
-
-/**
- * @brief pkgmgr info types.
- */
-#define PKGMGR_INFO_STR_PKGTYPE "pkg_type"
-#define PKGMGR_INFO_STR_PKGNAME "pkg_name"
-#define PKGMGR_INFO_STR_VERSION "version"
-#define PKGMGR_INFO_STR_INSTALLED_SIZE "installed_size"
-#define PKGMGR_INFO_STR_DATA_SIZE "data_size"
-#define PKGMGR_INFO_STR_APP_SIZE "app_size"
-#define PKGMGR_INFO_STR_INSTALLED_TIME "installed_time"
-/** @} */
-
-
-/**
- * @brief Return values in pkgmgr.
- */
-typedef enum _pkgmgr_return_val {
- PKGMGR_R_ETIMEOUT = -4, /**< Timeout */
- PKGMGR_R_EINVAL = -3, /**< Invalid argument */
- PKGMGR_R_ECOMM = -2, /**< Comunication Error */
- PKGMGR_R_ERROR = -1, /**< General error */
- PKGMGR_R_OK = 0 /**< General success */
-} pkgmgr_return_val;
-/** @} */
-
-/**
- * @defgroup pkg_operate APIs to install /uninstall / activate application
- * @ingroup pkgmgr
- * @brief
- * APIs to install /uninstall / activate application
- * - Install application using application package filepath
- * - Uninstall application using application package name
- * - Activate application using application package name
- *
- */
-
-
-/**
- * @addtogroup pkg_operate
- * @{
- */
-
-typedef void* pkgmgr_pkginfo_h;
-typedef void* pkgmgr_appinfo_h;
-
-typedef int (*pkgmgr_iter_fn)(const char* pkg_type, const char* pkg_name,
- const char* version, void *data);
-
-typedef int (*pkgmgr_handler)(int req_id, const char *pkg_type,
- const char *pkg_name, const char *key,
- const char *val, const void *pmsg, void *data);
-
-typedef int (*pkgmgr_info_app_list_cb ) (const pkgmgr_appinfo_h handle,
- const char *appid, void *user_data);
-
-
-typedef void pkgmgr_client;
-
-typedef enum {
- PC_REQUEST = 0,
- PC_LISTENING,
- PC_BROADCAST,
-}client_type;
-
-typedef enum {
- PM_DEFAULT,
- PM_QUIET
-}pkgmgr_mode;
-
-typedef enum {
- PM_LOCATION_INTERNAL = 0,
- PM_LOCATION_EXTERNAL
-}pkgmgr_install_location;
-
-typedef enum {
- PM_UI_APP,
- PM_SVC_APP
-}pkgmgr_app_component;
-
-/**
- * @brief This API creates pkgmgr client.
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] ctype client type - PC_REQUEST, PC_LISTENING, PC_BROADCAST
- * @return pkgmgr_client object
- * @retval NULL on failure creating an object
-*/
-pkgmgr_client *pkgmgr_client_new(client_type ctype);
-
-/**
- * @brief This API deletes pkgmgr client.
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] pc pkgmgr_client
- * @return Operation result;
- * @retval PKGMGR_R_OK success
- * @retval PKGMGR_R_EINVAL invalid argument
- * @retval PKGMGR_R_ERROR internal error
-*/
-int pkgmgr_client_free(pkgmgr_client *pc);
-
-/**
- * @brief This API installs package.
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] pc pkgmgr_client
- * @param[in] pkg_type package type
- * @param[in] descriptor_path full path that descriptor is located
- * @param[in] pkg_path full path that package file is located
- * @param[in] optional_file optional file which is used for installation
- * @param[in] mode installation mode - PM_DEFAULT, PM_QUIET
- * @param[in] event_cb user callback
- * @param[in] data user data
- * @return request_id (>0) if success, error code(<0) if fail\n
- * @retval PKGMGR_R_OK success
- * @retval PKGMGR_R_EINVAL invalid argument
- * @retval PKGMGR_R_ECOMM communication error
-*/
-int pkgmgr_client_install(pkgmgr_client *pc, const char *pkg_type,
- const char *descriptor_path, const char *pkg_path,
- const char *optional_file, pkgmgr_mode mode,
- pkgmgr_handler event_cb, void *data);
-
-/**
- * @brief This API uninstalls package.
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] pc pkgmgr_client
- * @param[in] pkg_type package type
- * @param[in] pkg_name package name
- * @param[in] mode installation mode - PM_DEFAULT, PM_QUIET
- * @param[in] event_cb user callback
- * @param[in] data user data
- * @return request_id (>0), error code(<0) if fail\n
- * @retval PKGMGR_R_OK success
- * @retval PKGMGR_R_EINVAL invalid argument
- * @retval PKGMGR_R_ECOMM communication error
-*/
-int pkgmgr_client_uninstall(pkgmgr_client *pc, const char *pkg_type,
- const char *pkg_name, pkgmgr_mode mode,
- pkgmgr_handler event_cb, void *data);
-
-/**
- * @brief This API activates package.
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] pc pkgmgr_client
- * @param[in] pkg_type package type
- * @param[in] pkg_name package name
- * @return request_id (>0) if success, error code(<0) if fail\n
- * @retval PKGMGR_R_OK success
- * @retval PKGMGR_R_EINVAL invalid argument
- * @retval PKGMGR_R_ECOMM communication error
-*/
-int pkgmgr_client_activate(pkgmgr_client *pc, const char *pkg_type,
- const char *pkg_name);
-
-/**
- * @brief This API deactivates package.
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] pc pkgmgr_client
- * @param[in] pkg_type package type
- * @param[in] pkg_name package name
- * @return request_id (>0) if success, error code(<0) if fail\n
- * @retval PKGMGR_R_OK success
- * @retval PKGMGR_R_EINVAL invalid argument
- * @retval PKGMGR_R_ECOMM communication error
-*/
-int pkgmgr_client_deactivate(pkgmgr_client *pc, const char *pkg_type,
- const char *pkg_name);
-
-/**
- * @brief This API deletes application's private data.
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] pc pkgmgr_client
- * @param[in] pkg_type package type
- * @param[in] pkg_name package name
- * @param[in] mode installation mode - PM_DEFAULT, PM_QUIET
- * @return request_id (>0) if success, error code(<0) if fail\n
- * @retval PKGMGR_R_OK success
- * @retval PKGMGR_R_EINVAL invalid argument
- * @retval PKGMGR_R_ECOMM communication error
-*/
-int pkgmgr_client_clear_user_data(pkgmgr_client *pc, const char *pkg_type,
- const char *pkg_name, pkgmgr_mode mode);
-
-/**
- * @brief This API request to listen the pkgmgr's broadcasting
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] pc pkgmgr_client
- * @param[in] event_cb user callback
- * @param[in] data user data
- * @return request_id (>0) if success, error code(<0) if fail\n
- * @retval PKGMGR_R_OK success
- * @retval PKGMGR_R_EINVAL invalid argument
-*/
-int pkgmgr_client_listen_status(pkgmgr_client *pc, pkgmgr_handler event_cb,
- void *data);
-
-/**
- * @brief This API broadcasts pkgmgr's status
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] pc pkgmgr_client
- * @param[in] pkg_type package type
- * @param[in] pkg_name package name
- * @param[in] key key to broadcast
- * @param[in] val value to broadcast
- * @return 0 if success, error code(<0) if fail\n
- * @retval PKGMGR_R_OK success
- * @retval PKGMGR_R_EINVAL invalid argument
-*/
-int pkgmgr_client_broadcast_status(pkgmgr_client *pc, const char *pkg_type,
- const char *pkg_name, const char *key,
- const char *val);
-
-/**
- * @brief This API provides package list
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] iter_fn iteration function for list
- * @param[in] data user data
- * @return 0 if success, error code(<0) if fail\n
- * @retval PKGMGR_R_OK success
- * @retval PKGMGR_R_EINVAL invalid argument
- * @retval PKGMGR_R_ERROR internal error
-*/
-int pkgmgr_get_pkg_list(pkgmgr_iter_fn iter_fn, void *data);
-/** @} */
-
-/**
- * @defgroup pkg_list APIs to get package information
- * @ingroup pkgmgr
- * @brief
- * API to get package information
-*/
-
-/**
- * @addtogroup pkg_list
- * @{
- */
-
-typedef void pkgmgr_info;
-
-/**
- * @brief This API gets the package's information.
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] pkg_type package type for the package to get infomation
- * @param[in] pkg_name package name for the package to get infomation
- * @return package entry pointer if success, NULL if fail\n
-*/
-pkgmgr_info * pkgmgr_info_new(const char *pkg_type, const char *pkg_name);
-
-/**
- * @brief This API gets the package's information.
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] pkg_type package type for the package to get infomation
- * @param[in] pkg_path package file path to get infomation
- * @return package entry pointer if success, NULL if fail\n
-*/
-pkgmgr_info * pkgmgr_info_new_from_file(const char *pkg_type,
- const char *pkg_path);
-
-/**
- * @brief This API get package information value
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] pkg_info pointer for package info entry
- * @param[in] key key for package info field
- * @return string value if success, NULL if fail\n
-*/
-char * pkgmgr_info_get_string(pkgmgr_info * pkg_info, const char *key);
-
-/**
- * @brief This API get package information value
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] pkg_info pointer for package info entry
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_info_free(pkgmgr_info * pkg_info);
-
-/**
- * @brief This API get package info entry from db
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] pkg_name pointer to package name
- * @param[out] handle pointer to the package info handle.
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_get_pkginfo(const char *pkg_name, pkgmgr_pkginfo_h *handle);
-
-/**
- * @brief This API gets type of the given package.
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] handle pointer to package info handle
- * @param[out] type to hold package type.
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_get_pkginfo_type(pkgmgr_pkginfo_h handle, char **type);
-
-/**
- * @brief This API gets version of the given package.
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] handle pointer to package info handle
- * @param[out] version to hold package version.
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_get_pkginfo_version(pkgmgr_pkginfo_h handle, char **version);
-
-/**
- * @brief This API gets install location of the given package.
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] handle pointer to package info handle
- * @param[out] location to hold install location.
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_get_pkginfo_install_location(pkgmgr_pkginfo_h handle, pkgmgr_install_location *location);
-
-/**
- * @brief This API gets label of the given package.
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] handle pointer to package info handle
- * @param[out] label to hold package label.
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_get_pkginfo_label(pkgmgr_pkginfo_h handle, char **label);
-
-/**
- * @brief This API gets icon of the given package.
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] handle pointer to package info handle
- * @param[out] icon to hold package icon.
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_get_pkginfo_icon(pkgmgr_pkginfo_h handle, char **icon);
-
-/**
- * @brief This API gets desription of the given package.
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] handle pointer to package info handle
- * @param[out] description to hold package description.
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_get_pkginfo_descriptioon(pkgmgr_pkginfo_h handle, char **description);
-
-/**
- * @brief This API gets author's name of the given package.
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] handle pointer to package info handle
- * @param[out] author_name to hold author's name.
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_get_pkginfo_author_name(pkgmgr_pkginfo_h handle, char **author_name);
-
-/**
- * @brief This API gets author's email of the given package.
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] handle pointer to package info handle
- * @param[out] author_email to hold author's email id.
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_get_pkginfo_author_email(pkgmgr_pkginfo_h handle, char **author_email);
-
-/**
- * @brief This API gets author's href of the given package.
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] handle pointer to package info handle
- * @param[out] author_href to hold author's href.
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_get_pkginfo_author_href(pkgmgr_pkginfo_h handle, char **author_href);
-
-/**
- * @brief This API gets removable of the given package.
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] handle pointer to package info handle
- * @param[out] removable to hold removable value.
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_get_pkginfo_removable(pkgmgr_pkginfo_h handle, bool *removable);
-
-/**
- * @brief This API gets preload of the given package.
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] handle pointer to package info handle
- * @param[out] preload to hold preload value
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_get_pkginfo_preload(pkgmgr_pkginfo_h handle, bool *preload);
-
-/**
- * @brief This API gets readonly value of the given package.
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] handle pointer to package info handle
- * @param[out] readonly to hold readonly value
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_get_pkginfo_readonly(pkgmgr_pkginfo_h handle, bool *readonly);
-
-/**
- * @brief This API gets list of ui-application/service application of the given package.
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] handle pointer to package info handle
- * @param[in] component application component type.
- * @param[in] app_func application's callback function.
- * @param[in] user_data user data to be passed to callback function
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_get_info_app(pkgmgr_pkginfo_h handle, pkgmgr_app_component component,
- pkgmgr_info_app_list_cb app_func, void *user_data);
-
-/**
- * @brief This API gets list of installed applications.
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] iter_fn iteration function for list
- * @param[in] user_data user data to be passed to callback function
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_get_info_list(pkgmgr_iter_fn iter_fn, void *user_data);
-
-
-/**
- * @brief This API destroy the pacakge info handle
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] handle pointer to package info handle
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_destroy_pkginfo(pkgmgr_pkginfo_h handle);
-
-/**
- * @brief This API gets application info entry from db.
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] appid application id
- * @param[out] handle pointer to app info handle
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_get_appinfo(const char *appid, pkgmgr_appinfo_h *handle);
-
-/**
- * @brief This API gets exec of the given appid.
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] handle pointer to app info handle
- * @param[out] exec to hold exec value
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_get_pkginfo_exec(pkgmgr_appinfo_h handle, char **exec);
-
-/**
- * @brief This API gets component type of the given appid.
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] handle pointer to app info handle
- * @param[out] component to hold component value
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_get_pkginfo_component(pkgmgr_appinfo_h handle, char **component);
-
-/**
- * @brief This API gets app type of the given appid.
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] handle pointer to app info handle
- * @param[out] app_type to hold the apptype.
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_get_pkginfo_apptype(pkgmgr_appinfo_h handle, char **app_type);
-
-/**
- * @brief This API gets nodisplay value of the given appid.
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] handle pointer to app info handle
- * @param[out] nodisplay to hold the nodisplay value
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_get_pkginfo_nodisplay(pkgmgr_appinfo_h handle, bool *nodisplay);
-
-/**
- * @brief This API gets multiple value of the given appid.
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] handle pointer to app info handle
- * @param[out] multiple to hold the multiple value
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_get_pkginfo_multiple(pkgmgr_appinfo_h handle, bool *multiple);
-
-/**
- * @brief This API gets taskmanage value of the given appid.
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] handle pointer to app info handle
- * @param[out] taskmanage to hold the taskmanage value
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_get_pkginfo_taskmanage(pkgmgr_appinfo_h handle, bool *taskmanage);
-
-/**
- * @brief This API gets onboot value of the given appid.
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] handle pointer to app info handle
- * @param[out] onboot to hold the onboot value
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_get_pkginfo_onboot(pkgmgr_appinfo_h handle, bool *onboot);
-
-/**
- * @brief This API gets autorestart value of the given appid.
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] handle pointer to app info handle
- * @param[out] autorestart to hold the autorestart value
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_get_pkginfo_autorestart(pkgmgr_appinfo_h handle, bool *autorestart);
-
-/**
- * @brief This API destroy the appinfo handle.
- *
- * This API is for package-manager client application.\n
- *
- * @param[in] handle pointer to app info handle
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_destroy_appinfo(pkgmgr_appinfo_h handle);
-/** @} */
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* __PKG_MANAGER_H__ */
-/**
- * @}
- * @}
- */
-
--- /dev/null
+../client/include/package-manager.h
\ No newline at end of file
+++ /dev/null
-/*
- * slp-pkgmgr
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
- * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-/**
- * @file pkgmgr-dbinfo.h
- * @author Shobhit Srivastava <shobhit.s@samsung.com>
- * @version 0.1
- * @brief This file declares db set API for backend installers
- *
- * @addtogroup APPLICATION_FRAMEWORK
- * @{
- *
- * @defgroup PackageManager
- * @section Header to use them:
- * @code
- * #include "pkgmgr-dbinfo.h"
- * @endcode
- *
- * @addtogroup PackageManager
- * @{
- */
-
-#ifndef __PKGMGR_DBINFO_H__
-#define __PKGMGR_DBINFO_H__
-
-#include <stdbool.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef DEPRECATED
-#define DEPRECATED __attribute__ ((__deprecated__))
-#endif
-
-typedef enum {
- INSTALL_INTERNAL = 0,
- INSTALL_EXTERNAL,
-} INSTALL_LOCATION;
-
-typedef void* pkgmgr_pkgdbinfo_h;
-
-/**
- * @brief This API creates package info handle to set info in the db.
- *
- * This API is for backend installers.\n
- *
- * @param[in] pkg_name package name.
- * @param[out] handle package info handle.
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_create_pkgdbinfo(const char *pkg_name, pkgmgr_pkgdbinfo_h *handle);
-
-/**
- * @brief This API sets the package type in DB.
- *
- * This API is for backend installers.\n
- *
- * @param[in] handle package info handle.
- * @param[in] type package type.
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_set_type_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *type);
-
-/**
- * @brief This API sets the package version in DB.
- *
- * This API is for backend installers.\n
- *
- * @param[in] handle package info handle.
- * @param[in] version package version.
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_set_version_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *version);
-
-/**
- * @brief This API sets install location in DB
- *
- * This API is for backend installers.\n
- *
- * @param[in] handle package info handle.
- * @param[in] location install location.
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_set_install_location_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, INSTALL_LOCATION location);
-
-/**
- * @brief This API sets label in DB.
- *
- * This API is for backend installers.\n
- *
- * @param[in] handle package info handle.
- * @param[in] label label text.
- * @param[in] locale locale (NULL for default).
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_set_label_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *label, const char *locale);
-
-/**
- * @brief This API sets icon in DB.
- *
- * This API is for backend installers.\n
- *
- * @param[in] handle package info handle.
- * @param[in] icon icon name.
- * @param[in] locale locale (NULL for default).
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_set_icon_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *icon, const char *locale);
-
-/**
- * @brief This API sets description in DB.
- *
- * This API is for backend installers.\n
- *
- * @param[in] handle package info handle.
- * @param[in] description description of the package.
- * @param[in] locale locale (NULL for default).
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_set_description_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *description, const char *locale);
-
-/**
- * @brief This API sets author's name, email, href in DB.
- *
- * This API is for backend installers.\n
- *
- * @param[in] handle package info handle.
- * @param[in] author_name author' name.
- * @param[in] author_email author's email.
- * @param[in] author_href author's href.
- * @param[in] locale locale (NULL for default).
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_set_author_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *author_name,
- const char *author_email, const char *author_href, const char *locale);
-
-/**
- * @brief This API sets removable in DB.
- *
- * This API is for backend installers.\n
- *
- * @param[in] handle package info handle.
- * @param[in] removable removable (0 | 1)
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_set_removable_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, int removable);
-
-/**
- * @brief This API sets preload in DB.
- *
- * This API is for backend installers.\n
- *
- * @param[in] handle package info handle.
- * @param[in] preload preload (0 | 1)
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_set_preload_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, int preload);
-
-/**
- * @brief This API save pakage info entry into the db.
- *
- * This API is for backend installers.\n
- *
- * @param[in] handle package info handle.
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_save_pkgdbinfo(pkgmgr_pkgdbinfo_h handle);
-
-/**
- * @brief This API destroy pakage info handle and free the resources.
- *
- * This API is for backend installers.\n
- *
- * @param[in] handle package info handle.
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_destroy_pkgdbinfo(pkgmgr_pkgdbinfo_h handle);
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* __PKGMGR_DBINFO_H__ */
-/**
- * @}
- * @}
- */
-
static int __confirm_ui(void *data, char *msg);
static int __install_package(const char *pkg_file_path);
-static int __uninstall_package(const char *pkg_name);
+static int __uninstall_package(const char *pkgid);
static int __recover_package_system(void);
static pkgmgr_installer *_pi;
int ret = 0;
ret = pkgmgr_installer_send_signal(_pi, "sample", "abc", "end", "ok");
- if (ret == 0) {
- system("touch /opt/etc/install_complete");
- }
- return 0;
+ return ret;
}
-static int __uninstall_package(const char *pkg_name)
+static int __uninstall_package(const char *pkgid)
{
return 0;
}
-static int __clear_package(const char *pkg_name)
+static int __clear_package(const char *pkgid)
{
return 0;
}
#include "package-manager-plugin.h"
static void pkg_native_plugin_on_unload(void);
-static int pkg_plugin_app_is_installed(const char *pkg_name);
+static int pkg_plugin_app_is_installed(const char *pkgid);
static int pkg_plugin_get_installed_apps_list(const char *category,
const char *option,
package_manager_pkg_info_t **
list, int *count);
-static int pkg_plugin_get_app_detail_info(const char *pkg_name,
+static int pkg_plugin_get_app_detail_info(const char *pkgid,
package_manager_pkg_detail_info_t *
pkg_detail_info);
static int pkg_plugin_get_app_detail_info_from_package(const char *pkg_path,
printf("pkg_native_plugin_unload() is called\n");
}
-static int pkg_plugin_app_is_installed(const char *pkg_name)
+static int pkg_plugin_app_is_installed(const char *pkgid)
{
printf("pkg_plugin_app_is_installed() is called\n");
return 0;
}
-static int pkg_plugin_get_app_detail_info(const char *pkg_name,
+static int pkg_plugin_get_app_detail_info(const char *pkgid,
package_manager_pkg_detail_info_t *
pkg_detail_info)
{
if(reader != NULL) {
int ret = xmlTextReaderRead(reader);
while(ret == 1) {
- const xmlChar *name;
- name = xmlTextReaderConstName(reader);
- DBGI("name %s", name?name:"NULL");
ret = xmlTextReaderRead(reader);
}
xmlFreeTextReader(reader);
--- /dev/null
+#
+# Copyright (c) 2008 ~ 2010 Samsung Electronics Co., Ltd.
+# All rights reserved.
+#
+
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: package manager
+Description: SLP Package Manager Package
+Version: @VERSION@
+Requires: security-server dlog pkgmgr-types pkgmgr-installer-client pkgmgr-installer-status-broadcast-server
+Libs: -L${libdir} -L${libdir}/pkgmgr -lpkgmgr-client
+Cflags: -I${includedir}
--- /dev/null
+[D-BUS Service]
+Name=org.tizen.pkgmgr
+Exec=/bin/false
+SystemdService=slp-pkgmgr.service
+User=root
+++ /dev/null
-[D-BUS Service]
-Name=org.tizen.slp.pkgmgr
-Exec=@PREFIX@/bin/pkgmgr-server
-#sbs-git:slp/pkgs/s/slp-pkgmgr pkgmgr 0.1.103 29b53909a5d6e8728429f0a188177eac691cb6ce
Name: pkgmgr
Summary: Packager Manager client library package
-Version: 0.1.136
+Version: 0.3.37
Release: 1
Group: System/Libraries
-License: Apache License, Version 2.0
+License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
+Source1: pkgmgr_recovery.service
BuildRequires: cmake
+BuildRequires: unzip
BuildRequires: gettext-tools
BuildRequires: pkgconfig(ecore)
BuildRequires: pkgconfig(security-server)
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(gio-unix-2.0)
+BuildRequires: pkgconfig(gio-2.0)
BuildRequires: pkgconfig(dbus-1)
BuildRequires: pkgconfig(dbus-glib-1)
BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(aul)
-BuildRequires: pkgconfig(ail)
+BuildRequires: pkgconfig(bundle)
BuildRequires: pkgconfig(appcore-efl)
-BuildRequires: pkgconfig(libxml-2.0)
-
+BuildRequires: pkgconfig(pkgmgr-info)
+BuildRequires: pkgconfig(iniparser)
+BuildRequires: pkgconfig(minizip)
+BuildRequires: pkgconfig(xdgmime)
+BuildRequires: pkgmgr-info-parser-devel
+BuildRequires: pkgmgr-info-parser
+BuildRequires: python-xml
+BuildRequires: tizen-locale
+BuildRequires: libfile-devel
%description
Packager Manager client library package for packaging
+Requires(post): ail
+Requires(post): pkgmgr-info
%package client
Summary: Package Manager client library develpoment package
Requires: %{name} = %{version}-%{release}
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
+Requires: shared-mime-info
+Requires(post): pkgmgr
%description client
Package Manager client library develpoment package for packaging
%package server
Summary: Package Manager server
Group: TO_BE/FILLED_IN
+BuildRequires: pkgconfig(libsmack)
Requires: %{name} = %{version}-%{release}
%description server
%description installer-devel
Dev package for libpkgmgr-installer for packaging.
-%package parser
-Summary: Library for manifest parser
-Group: TO_BE/FILLED_IN
-Requires: %{name} = %{version}-%{release}
-Requires(post): /sbin/ldconfig
-Requires(postun): /sbin/ldconfig
-
-%description parser
-Library for manifest parser
-
-%package parser-devel
-Summary: Dev package for libpkgmgr-parser
-Group: TO_BE/FILLED_IN
-Requires: %{name} = %{version}-%{release}
-%description parser-devel
-Dev package for libpkgmgr-parser
%package types-devel
Summary: Package Manager manifest parser develpoment package
Group: TO_BE/FILLED_IN
%prep
%setup -q
+%if 0%{?tizen_build_binary_release_type_eng}
+export CFLAGS="$CFLAGS -DTIZEN_ENGINEER_MODE"
+export CXXFLAGS="$CXXFLAGS ?DTIZEN_ENGINEER_MODE"
+export FFLAGS="$FFLAGS -DTIZEN_ENGINEER_MODE"
+%endif
+
cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
%build
make %{?jobs:-j%jobs}
+
%install
rm -rf %{buildroot}
%make_install
+mkdir -p %{buildroot}/usr/share/license
+cp LICENSE %{buildroot}/usr/share/license/%{name}
+cp LICENSE %{buildroot}/usr/share/license/%{name}-client
+cp LICENSE %{buildroot}/usr/share/license/%{name}-installer
+cp LICENSE %{buildroot}/usr/share/license/%{name}-server
+
+mkdir -p %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants
+install -m 0644 %SOURCE1 %{buildroot}%{_libdir}/systemd/system/pkgmgr_recovery.service
+ln -s ../pkgmgr_recovery.service %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/pkgmgr_recovery.service
%post
/sbin/ldconfig
mkdir -p /usr/etc/package-manager/backend
mkdir -p /usr/etc/package-manager/backendlib
+mkdir -p /usr/etc/package-manager/soft-reset
+mkdir -p /etc/opt/upgrade
+
+vconftool set -t int memory/pkgmgr/status "0" -f -s system::vconf_inhouse
+
+touch /usr/etc/package-manager/backend/junk
+chmod 755 /usr/etc/package-manager/backend/junk
+touch /usr/etc/package-manager/backend/pkg
+chmod 755 /usr/etc/package-manager/backend/pkg
+touch /usr/etc/package-manager/backend/getsize
+chmod 755 /usr/etc/package-manager/backend/getsize
+
+touch /usr/etc/package-manager/backend/clearcache
+chmod 755 /usr/etc/package-manager/backend/clearcache
+
# For pkgmgr-install:
# Update mime database to support package mime types
update-mime-database /usr/share/mime
+%posttrans
+#init DB
+mkdir -p /usr/share/packages
+mkdir -p /opt/share/packages
+mkdir -p /opt/share/packages/.recovery/pkgmgr
+mkdir -p /opt/share/packages/.recovery/tpk
+mkdir -p /opt/share/packages/.recovery/wgt
+
+#log directory for pkgmr
+mkdir -p /opt/usr/data/pkgmgr/fota
+chown -R 5000:5000 /opt/usr/data/pkgmgr
+
+mkdir -p /usr/share/applications
+mkdir -p /opt/share/applications
+mkdir -p /opt/dbspace/
+
+#signing. find-auto-sign.sh is installed when signing-client git is installed.
+#checks app's sign in /usr/apps, if not signature file, call singing client.
+#/usr/bin/signing-client/find-auto-sign.sh
+
+pkg_initdb
+
+chsmack -a 'pkgmgr::db' /opt/dbspace/.pkgmgr_parser.db*
+chsmack -a 'pkgmgr::db' /opt/dbspace/.pkgmgr_cert.db*
+chsmack -a 'ail::db' /opt/dbspace/.app_info.db*
+chsmack -a '_' /usr/etc/package-manager/pkg_path.conf
+
+rm -rf /opt/usr/apps/tmp/pkgmgr_tmp.txt
+
+# Remove locales not supported
+LOCALE_DIR_LIST=/tmp/LC_MESSAGES.lst
+SUPPORTED_LOCALE_LIST=`locale -a | sed -ne "/\w*_\w*/{s/@.*//;s/\..*//p}"`
+REMOVED_FILE_LIST=/usr/share/removed-file.lst
+find / -type d -name "LC_MESSAGES" > $LOCALE_DIR_LIST
+for SUPPORTED_LOCALE in $SUPPORTED_LOCALE_LIST
+do
+ sed -i "/\/${SUPPORTED_LOCALE}\/LC_MESSAGES/d" $LOCALE_DIR_LIST
+ sed -i "/\/${SUPPORTED_LOCALE%%_*}\/LC_MESSAGES/d" $LOCALE_DIR_LIST
+done
+for LOCALE_DIR in `cat $LOCALE_DIR_LIST | sed "s/LC_MESSAGES//"`
+do
+ find $LOCALE_DIR >> $REMOVED_FILE_LIST && rm -rf $LOCALE_DIR
+done
+echo "The list of removed files has saved at $REMOVED_FILE_LIST"
+rm -f $LOCALE_DIR_LIST
+
%post server
/sbin/ldconfig
%postun installer -p /sbin/ldconfig
%files
+%manifest pkgmgr.manifest
%defattr(-,root,root,-)
%{_bindir}/pkgcmd
-%{_bindir}/pkginfo
%{_bindir}/pkg_initdb
+%{_bindir}/pkg_fota
+%{_bindir}/pkg_getsize
+%{_bindir}/pkg_getjunkinfo
+%{_bindir}/pkg_clearcache
+%{_bindir}/test_junk
+%{_bindir}/pkg_mkext
+%{_bindir}/pkginfo
+%{_bindir}/pkg
+%{_bindir}/pkgmgr-install
+%{_datadir}/packages/org.tizen.pkgmgr-install.xml
+%{_datadir}/mime/packages/mime.wac.xml
+%{_datadir}/mime/packages/mime.tpk.xml
+%{_libdir}/libpkgmgr_parser_lib_sample.so
%exclude %{_bindir}/pkgmgr_backend_sample
%exclude %{_includedir}/pkgmgr/comm_client.h
%exclude %{_includedir}/pkgmgr/comm_config.h
%exclude %{_includedir}/pkgmgr/comm_status_broadcast_server.h
+%{_includedir}/junk-manager.h
%exclude %{_libdir}/libpkgmgr_backend_lib_sample.so
%exclude /usr/etc/package-manager/server/queue_status
+%attr(0700,root,root) /etc/opt/upgrade/710.pkgmgr.patch.sh
+%attr(0700,root,root) /usr/etc/package-manager/pkg_recovery.sh
+%attr(0700,root,root) /usr/etc/package-manager/pkgmgr-soft-reset-ui.sh
+%{_libdir}/systemd/system/multi-user.target.wants/pkgmgr_recovery.service
+%{_libdir}/systemd/system/pkgmgr_recovery.service
+/usr/share/license/%{name}
%files client
+%manifest pkgmgr-client.manifest
%defattr(-,root,root,-)
%{_prefix}/etc/package-manager/pkg_path.conf
-%{_datadir}/mime/packages/mime.wac.xml
-%{_bindir}/pkgmgr-install
%{_libdir}/libpkgmgr-client.so.*
-%{_datadir}/applications/org.tizen.pkgmgr-install.desktop
-%{_datadir}/packages/org.tizen.pkgmgr-install.xml
+/usr/share/license/%{name}-client
%files client-devel
%defattr(-,root,root,-)
%{_includedir}/package-manager.h
%{_libdir}/pkgconfig/pkgmgr.pc
+%{_libdir}/pkgconfig/junkmgr.pc
%{_libdir}/libpkgmgr-client.so
%files server
+%manifest pkgmgr-server.manifest
%defattr(-,root,root,-)
-%{_datadir}/dbus-1/services/org.tizen.slp.pkgmgr.service
+%{_datadir}/dbus-1/services/org.tizen.pkgmgr.service
+%{_libdir}/systemd/system/slp-pkgmgr.service
%{_bindir}/pkgmgr-server
%{_datadir}/locale/*/LC_MESSAGES/*.mo
+/usr/share/license/%{name}-server
%files installer
+%manifest pkgmgr-installer.manifest
%defattr(-,root,root,-)
%{_libdir}/libpkgmgr_installer.so.*
%{_libdir}/libpkgmgr_installer_status_broadcast_server.so.*
%{_libdir}/libpkgmgr_installer_client.so.*
+/usr/share/license/%{name}-installer
%files installer-devel
%defattr(-,root,root,-)
%{_libdir}/libpkgmgr_installer_client.so
%{_libdir}/libpkgmgr_installer_status_broadcast_server.so
-%files parser
-%defattr(-,root,root,-)
-%{_libdir}/libpkgmgr_parser.so.*
-%{_prefix}/etc/package-manager/preload/preload_list.txt
-%{_prefix}/etc/package-manager/preload/manifest.xsd
-%{_prefix}/etc/package-manager/preload/xml.xsd
-%{_libdir}/libpkgmgr_parser_lib_sample.so
-
-%files parser-devel
-%defattr(-,root,root,-)
-%{_includedir}/pkgmgr/pkgmgr_parser.h
-%{_libdir}/pkgconfig/pkgmgr-parser.pc
-%{_libdir}/libpkgmgr_parser.so
-
-
%files types-devel
%defattr(-,root,root,-)
--- /dev/null
+[Unit]
+Description=pkgmgr recovery
+Before=launchpad-preload.service
+
+[Service]
+Type=oneshot
+ExecStart=/usr/etc/package-manager/pkg_recovery.sh
+
+[Install]
+WantedBy=multi-user.target
+++ /dev/null
-### Description
-# Communication modules for pkg-mgr client lib and server process
-# By Youmin Ha <youmin.ha@samsung.com>
-
-cmake_minimum_required(VERSION 2.6)
-#set(CMAKE_SKIP_BUILD_RPATH true)
-set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
-
-
-### Versioning
-if(DEFINED ${VERSION})
- message("VERSION: ${VERSION}")
-else()
- message("VERSION is not defined. set it as 0.1.0")
- set(VERSION 0.1.0)
-endif()
-if(DEFINED ${VERSION_MAJOR})
- message("VERSION_MAJOR: ${VERSION_MAJOR}")
-else()
- message( "VERSION_MAJOR is not defined. set it as 0")
- set(VERSION_MAJOR 0)
-endif()
-message(STATUS "version/major : ${VERSION} / ${VERSION_MAJOR}")
-
-### Get required CFLAGS, LDFLAGS from pkg-config
-
-include(FindPkgConfig)
-pkg_check_modules(parser_pkgs REQUIRED dlog libxml-2.0 glib-2.0 sqlite3 db-util)
-
-foreach(flag ${parser_pkgs_CFLAGS})
- set(parser_pkgs_CFLAGS_str "${parser_pkgs_CFLAGS_str} ${flag}")
-endforeach()
-
-## Additional flag
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -Wall")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-
-### Set current binary dir to be included (for generated *.h files)
-include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/client/include)
-
-### Build modules
-
-## pkgmgr_parser object (by sewook.park)
-# This library is for installer backend
-add_library(pkgmgr_parser SHARED pkgmgr_parser.c pkgmgr_parser_db.c)
-#add_library(pkgmgr_parser SHARED pkgmgr_parser.c)
-set_target_properties(pkgmgr_parser PROPERTIES SOVERSION ${VERSION_MAJOR})
-set_target_properties(pkgmgr_parser PROPERTIES VERSION ${VERSION})
-set_target_properties(pkgmgr_parser PROPERTIES COMPILE_FLAGS "${parser_pkgs_CFLAGS_str}")
-target_link_libraries(pkgmgr_parser ${parser_pkgs_LDFLAGS})
-
-### Create pc file
-configure_file(pkgmgr-parser.pc.in ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-parser.pc @ONLY)
-configure_file(preload_list.txt.in preload_list.txt @ONLY)
-configure_file(manifest.xsd.in manifest.xsd @ONLY)
-configure_file(xml.xsd.in xml.xsd @ONLY)
-
-## Install
-INSTALL(TARGETS
- pkgmgr_parser
- DESTINATION lib
- COMPONENT RuntimeLibraries)
-INSTALL(FILES
- pkgmgr_parser.h
- DESTINATION include/pkgmgr)
-
-INSTALL(FILES
- ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-parser.pc
- DESTINATION lib/pkgconfig)
-
-INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/preload_list.txt DESTINATION ${PREFIX}/etc/package-manager/preload/)
-INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/manifest.xsd DESTINATION ${PREFIX}/etc/package-manager/preload/)
-INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/xml.xsd DESTINATION ${PREFIX}/etc/package-manager/preload/)
+++ /dev/null
-
-#export CFLAGS=""
-#export LDFLAGS=""
-
-cd `dirname $0`
-
-PREFIX=/usr
-
-rm -rf cmake_tmp
-mkdir -p cmake_tmp
-cd cmake_tmp
-
-CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" cmake .. -DCMAKE_INSTALL_PREFIX=${PREFIX} &&
-make &&
-
-# test
-{
- export LD_LIBRARY_PATH=`pwd`
- cd test
-# ./test_comm_client &
-# ./test_comm_status_broadcast_server
-# ./test_comm_socket &&
- ./test_pkgmgr_installer
-}
-if [ "$?" == "0" ]; then
- echo "Test done."
-else
- echo "Test failed!"
-fi
-
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://tizen.org/ns/packages" xmlns:packages="http://tizen.org/ns/packages">
- <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd"/>
-
- <xs:element name="manifest">
- <xs:complexType>
- <xs:sequence>
- <xs:choice maxOccurs="unbounded">
- <xs:element ref="packages:label"/>
- <xs:element ref="packages:icon"/>
- <xs:element ref="packages:author"/>
- <xs:element ref="packages:description"/>
- <xs:element ref="packages:compatibility"/>
- <xs:element ref="packages:device-profile"/>
- <xs:element ref="packages:service-application"/>
- <xs:element ref="packages:ui-application"/>
- <xs:element ref="packages:ime-application"/>
- <xs:element ref="packages:font"/>
- <xs:element ref="packages:livebox"/>
- </xs:choice>
- </xs:sequence>
- <xs:attribute name="install-location" type="packages:InstallLocationType"/>
- <xs:attribute name="package" use="required" type="xs:NCName"/>
- <xs:attribute name="type" type="packages:PackageType"/>
- <xs:attribute name="version" use="required" type="xs:NMTOKEN"/>
- </xs:complexType>
- </xs:element>
-
- <xs:simpleType name="InstallLocationType">
- <xs:restriction base="xs:string">
- <xs:enumeration value="auto"/>
- <xs:enumeration value="internal-only"/>
- <xs:enumeration value="prefer-external"/>
- </xs:restriction>
- </xs:simpleType>
- <xs:simpleType name="PackageType">
- <xs:restriction base="xs:string">
- <xs:enumeration value="rpm"/>
- <xs:enumeration value="tpk"/>
- <xs:enumeration value="wgt"/>
- </xs:restriction>
- </xs:simpleType>
- <xs:simpleType name="TypeType">
- <xs:restriction base="xs:string">
- <xs:enumeration value="capp"/>
- <xs:enumeration value="c++app"/>
- <xs:enumeration value="webapp"/>
- </xs:restriction>
- </xs:simpleType>
-
- <xs:element name="author">
- <xs:complexType mixed="true">
- <xs:attribute name="email"/>
- <xs:attribute name="href"/>
- <xs:attribute ref="xml:lang"/>
- </xs:complexType>
- </xs:element>
- <xs:element name="description">
- <xs:complexType mixed="true">
- <xs:attribute ref="xml:lang"/>
- </xs:complexType>
- </xs:element>
- <xs:element name="compatibility">
- <xs:complexType/>
- </xs:element>
- <xs:element name="device-profile">
- <xs:complexType/>
- </xs:element>
- <xs:element name="service-application">
- <xs:complexType>
- <xs:sequence>
- <xs:choice maxOccurs="unbounded">
- <xs:element ref="packages:label"/>
- <xs:element ref="packages:icon"/>
- <xs:element ref="packages:application-service"/>
- </xs:choice>
- </xs:sequence>
- <xs:attribute name="appid" use="required" type="xs:string"/>
- <xs:attribute name="auto-restart" use="required" type="xs:boolean"/>
- <xs:attribute name="exec" use="required"/>
- <xs:attribute name="on-boot" use="required" type="xs:boolean"/>
- <xs:attribute name="type" use="required" type="packages:TypeType"/>
- </xs:complexType>
- </xs:element>
- <xs:element name="ui-application">
- <xs:complexType>
- <xs:sequence>
- <xs:choice maxOccurs="unbounded">
- <xs:element ref="packages:label"/>
- <xs:element ref="packages:icon"/>
- <xs:element ref="packages:application-service"/>
- </xs:choice>
- </xs:sequence>
- <xs:attribute name="appid" use="required" type="xs:string"/>
- <xs:attribute name="exec" use="required"/>
- <xs:attribute name="multiple" type="xs:boolean"/>
- <xs:attribute name="nodisplay" type="xs:boolean"/>
- <xs:attribute name="taskmanage" type="xs:boolean"/>
- <xs:attribute name="type" use="required" type="packages:TypeType"/>
- <xs:attribute name="categories" type="xs:NCName"/>
- <xs:attribute name="extraid"/>
- </xs:complexType>
- </xs:element>
- <xs:element name="ime-application">
- <xs:complexType>
- <xs:sequence>
- <xs:choice maxOccurs="unbounded">
- <xs:element ref="packages:label"/>
- <xs:element ref="packages:icon"/>
- </xs:choice>
- </xs:sequence>
- <xs:attribute name="appid" use="required" type="xs:string"/>
- <xs:attribute name="exec" use="required" type="xs:NCName"/>
- <xs:attribute name="multiple" type="xs:boolean"/>
- <xs:attribute name="nodisplay" type="xs:boolean"/>
- <xs:attribute name="type" use="required" type="packages:TypeType"/>
- </xs:complexType>
- </xs:element>
- <xs:element name="font">
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="packages:label"/>
- <xs:element ref="packages:icon"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- <xs:element name="livebox">
- <xs:complexType/>
- </xs:element>
- <xs:element name="label">
- <xs:complexType mixed="true">
- <xs:attribute ref="xml:lang"/>
- </xs:complexType>
- </xs:element>
- <xs:element name="icon">
- <xs:complexType>
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute ref="xml:lang"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="application-service">
- <xs:complexType>
- <xs:sequence>
- <xs:choice maxOccurs="unbounded">
- <xs:element ref="packages:operation"/>
- <xs:element ref="packages:uri"/>
- <xs:element ref="packages:mime"/>
- </xs:choice>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- <xs:element name="operation">
- <xs:complexType>
- <xs:attribute name="name" use="required"/>
- </xs:complexType>
- </xs:element>
- <xs:element name="uri">
- <xs:complexType>
- <xs:attribute name="name" use="required"/>
- </xs:complexType>
- </xs:element>
- <xs:element name="mime">
- <xs:complexType>
- <xs:attribute name="name" use="required"/>
- </xs:complexType>
- </xs:element>
-</xs:schema>
+++ /dev/null
-#
-# Copyright (c) 2008 ~ 2010 Samsung Electronics Co., Ltd.
-# All rights reserved.
-#
-
-prefix=@PREFIX@
-exec_prefix=@EXEC_PREFIX@
-libdir=@LIBDIR@
-includedir=@INCLUDEDIR@
-
-Name: package manager parser library
-Description: SLP package manager's installer lib for each backends
-Version: @VERSION@
-Requires: libxml-2.0
-Libs: -L${libdir} -lpkgmgr_parser
-Cflags: -I${includedir}/pkgmgr
+++ /dev/null
-/*
- * slp-pkgmgr
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
- * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <dlfcn.h>
-#include <string.h>
-#include <errno.h>
-#include <libxml/parser.h>
-#include <libxml/xmlreader.h>
-#include <libxml/xmlschemas.h>
-
-
-#include "pkgmgr-internal.h"
-#include "pkgmgr_parser.h"
-#include "pkgmgr_parser_internal.h"
-#include "pkgmgr_parser_db.h"
-#include "package-manager.h"
-
-#define MANIFEST_RW_DIRECTORY "/opt/share/packages"
-#define MANIFEST_RO_DIRECTORY "/usr/share/packages"
-#define ASCII(s) (const char *)s
-#define XMLCHAR(s) (const xmlChar *)s
-
-/* operation_type */
-typedef enum {
- ACTION_INSTALL = 0,
- ACTION_UPGRADE,
- ACTION_UNINSTALL,
- ACTION_MAX
-} ACTION_TYPE;
-
-char *package;
-
-static int __ps_process_content(xmlTextReaderPtr reader, content_x *content);
-static int __ps_process_control(xmlTextReaderPtr reader, control_x *control);
-static int __ps_process_group(xmlTextReaderPtr reader, group_x *group);
-static int __ps_process_livebox(xmlTextReaderPtr reader, livebox_x *livebox);
-static int __ps_process_pd(xmlTextReaderPtr reader, pd_x *pd);
-static int __ps_process_label(xmlTextReaderPtr reader, label_x *label);
-static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile);
-static int __ps_process_timeout(xmlTextReaderPtr reader, timeout_x *timeout);
-static int __ps_process_network(xmlTextReaderPtr reader, network_x *network);
-static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed);
-static int __ps_process_period(xmlTextReaderPtr reader, period_x *period);
-static int __ps_process_autolaunch(xmlTextReaderPtr reader, autolaunch_x *autolaunch);
-static int __ps_process_file(xmlTextReaderPtr reader, file_x *file);
-static int __ps_process_size(xmlTextReaderPtr reader, size_x *size);
-static int __ps_process_grp(xmlTextReaderPtr reader, grp_x *grp);
-static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation);
-static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri);
-static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime);
-static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition);
-static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notifiation);
-static int __ps_process_category(xmlTextReaderPtr reader, category_x *category);
-static int __ps_process_security(xmlTextReaderPtr reader, security_x *security);
-static int __ps_process_libexec(xmlTextReaderPtr reader, libexec_x *libexec);
-static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility);
-static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution);
-static int __ps_process_request(xmlTextReaderPtr reader, request_x *request);
-static int __ps_process_define(xmlTextReaderPtr reader, define_x *define);
-static int __ps_process_registry(xmlTextReaderPtr reader, registry_x *registry);
-static int __ps_process_database(xmlTextReaderPtr reader, database_x *database);
-static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc);
-static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions);
-static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare);
-static int __ps_process_layout(xmlTextReaderPtr reader, layout_x *layout);
-static int __ps_process_cluster(xmlTextReaderPtr reader, cluster_x *cluster);
-static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon);
-static int __ps_process_lbox(xmlTextReaderPtr reader, lbox_x *lbox);
-static int __ps_process_author(xmlTextReaderPtr reader, author_x *author);
-static int __ps_process_description(xmlTextReaderPtr reader, description_x *description);
-static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability);
-static int __ps_process_license(xmlTextReaderPtr reader, license_x *license);
-static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol);
-static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol);
-static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication);
-static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication);
-static int __ps_process_font(xmlTextReaderPtr reader, font_x *font);
-static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme);
-static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon);
-static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime);
-static void __ps_free_content(content_x *content);
-static void __ps_free_control(control_x *control);
-static void __ps_free_group(group_x *group);
-static void __ps_free_livebox(livebox_x *livebox);
-static void __ps_free_pd(pd_x *pd);
-static void __ps_free_label(label_x *label);
-static void __ps_free_deviceprofile(deviceprofile_x * deviceprofile);
-static void __ps_free_timeout(timeout_x *timeout);
-static void __ps_free_network(network_x *network);
-static void __ps_free_allowed(allowed_x *allowed);
-static void __ps_free_period(period_x *period);
-static void __ps_free_autolaunch(autolaunch_x *autolaunch);
-static void __ps_free_file(file_x *file);
-static void __ps_free_size(size_x *size);
-static void __ps_free_grp(grp_x *grp);
-static void __ps_free_operation(operation_x *operation);
-static void __ps_free_uri(uri_x *uri);
-static void __ps_free_mime(mime_x *mime);
-static void __ps_free_condition(condition_x *condition);
-static void __ps_free_notification(notification_x *notifiation);
-static void __ps_free_category(category_x *category);
-static void __ps_free_security(security_x *security);
-static void __ps_free_libexec(libexec_x *libexec);
-static void __ps_free_compatibility(compatibility_x *compatibility);
-static void __ps_free_resolution(resolution_x *resolution);
-static void __ps_free_request(request_x *request);
-static void __ps_free_define(define_x *define);
-static void __ps_free_registry(registry_x *registry);
-static void __ps_free_database(database_x *database);
-static void __ps_free_appsvc(appsvc_x *appsvc);
-static void __ps_free_launchconditions(launchconditions_x *launchconditions);
-static void __ps_free_datashare(datashare_x *datashare);
-static void __ps_free_layout(layout_x *layout);
-static void __ps_free_cluster(cluster_x *cluster);
-static void __ps_free_icon(icon_x *icon);
-static void __ps_free_lbox(lbox_x *lbox);
-static void __ps_free_author(author_x *author);
-static void __ps_free_description(description_x *description);
-static void __ps_free_capability(capability_x *capability);
-static void __ps_free_license(license_x *license);
-static void __ps_free_appcontrol(appcontrol_x *appcontrol);
-static void __ps_free_datacontrol(datacontrol_x *datacontrol);
-static void __ps_free_uiapplication(uiapplication_x *uiapplication);
-static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication);
-static void __ps_free_font(font_x *font);
-static void __ps_free_theme(theme_x *theme);
-static void __ps_free_daemon(daemon_x *daemon);
-static void __ps_free_ime(ime_x *ime);
-static char *__pkgname_to_manifest(const char *pkgname);
-static int __next_child_element(xmlTextReaderPtr reader, int depth);
-static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx);
-static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx);
-static void __str_trim(char *input);
-static char *__get_parser_plugin(const char *type);
-static int __ps_run_parser(xmlDocPtr docPtr, const char *tag, ACTION_TYPE action, const char *pkgname);
-static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgname);
-static void __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgname);
-static void __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgname);
-static int __validate_appid(const char *pkgname, const char *appid, char **newappid);
-
-static void __str_trim(char *input)
-{
- char *trim_str = input;
-
- if (input == NULL)
- return;
-
- while (*input != 0) {
- if (!isspace(*input)) {
- *trim_str = *input;
- trim_str++;
- }
- input++;
- }
-
- *trim_str = 0;
- return;
-}
-
-static int __validate_appid(const char *pkgname, const char *appid, char **newappid)
-{
- if (!pkgname || !appid || !newappid) {
- DBG("Arg supplied is NULL\n");
- return -1;
- }
- int pkglen = strlen(pkgname);
- int applen = strlen(appid);
- char *ptr = NULL;
- char *newapp = NULL;
- int len = 0;
- if (strncmp(appid, ".", 1) == 0) {
- len = pkglen + applen + 1;
- newapp = calloc(1,len);
- if (newapp == NULL) {
- DBG("Malloc failed\n");
- return -1;
- }
- strncpy(newapp, pkgname, pkglen);
- strncat(newapp, appid, applen);
- DBG("new appid is %s\n", newapp);
- *newappid = newapp;
- return 0;
- }
- if (applen < pkglen) {
- DBG("app id is not proper\n");
- *newappid = NULL;
-#ifdef _VALIDATE_APPID_
- return -1;
-#else
- return 0;
-#endif
- }
- if (!strcmp(appid, pkgname)) {
- DBG("appid is proper\n");
- *newappid = NULL;
- return 0;
- }
- else if (strncmp(appid, pkgname, pkglen) == 0) {
- ptr = strstr(appid, pkgname);
- ptr = ptr + pkglen;
- if (strncmp(ptr, ".", 1) == 0) {
- DBG("appid is proper\n");
- *newappid = NULL;
- return 0;
- }
- else {
- DBG("appid is not proper\n");
- *newappid = NULL;
-#ifdef _VALIDATE_APPID_
- return -1;
-#else
- return 0;
-#endif
- }
- } else {
- DBG("appid is not proper\n");
- *newappid = NULL;
-#ifdef _VALIDATE_APPID_
- return -1;
-#else
- return 0;
-#endif
- }
- return 0;
-}
-
-
-static char *__get_parser_plugin(const char *type)
-{
- FILE *fp = NULL;
- char buffer[1024] = { 0 };
- char temp_path[1024] = { 0 };
- char *lib_path = NULL;
- char *path = NULL;
-
- if (type == NULL) {
- _LOGE("invalid argument\n");
- return NULL;
- }
-
- fp = fopen(PKG_CONF_PATH, "r");
- if (fp == NULL) {
- _LOGE("no matching backendlib\n");
- return NULL;
- }
-
- while (fgets(buffer, sizeof(buffer), fp) != NULL) {
- if (buffer[0] == '#')
- continue;
-
- __str_trim(buffer);
-
- if ((path = strstr(buffer, PKG_PARSERLIB)) != NULL) {
- _LOGD("[%s]\n", path);
- path = path + strlen(PKG_PARSERLIB);
- _LOGD("[%s]\n", path);
-
- break;
- }
-
- memset(buffer, 0x00, 1024);
- }
-
- if (fp != NULL)
- fclose(fp);
-
- if (path == NULL) {
- _LOGE("no matching backendlib\n");
- return NULL;
- }
-
- snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
-
- return strdup(temp_path);
-}
-
-static int __ps_run_parser(xmlDocPtr docPtr, const char *tag,
- ACTION_TYPE action, const char *pkgname)
-{
- char *lib_path = NULL;
- void *lib_handle = NULL;
- int (*plugin_install) (xmlDocPtr, const char *);
- int ret = -1;
- char *ac;
-
- switch (action) {
- case ACTION_INSTALL:
- ac = "PKGMGR_PARSER_PLUGIN_INSTALL";
- break;
- case ACTION_UPGRADE:
- ac = "PKGMGR_PARSER_PLUGIN_UPGRADE";
- break;
- case ACTION_UNINSTALL:
- ac = "PKGMGR_PARSER_PLUGIN_UNINSTALL";
- break;
- default:
- goto END;
- }
-
- lib_path = __get_parser_plugin(tag);
- if (!lib_path) {
- goto END;
- }
-
- if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
- _LOGE("dlopen is failed lib_path[%s]\n", lib_path);
- goto END;
- }
-
- if ((plugin_install =
- dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
- _LOGE("can not find symbol \n");
- goto END;
- }
-
- ret = plugin_install(docPtr, pkgname);
-
- END:
- if (lib_path)
- free(lib_path);
- if (lib_handle)
- dlclose(lib_handle);
- return ret;
-}
-
-static char *__pkgname_to_manifest(const char *pkgname)
-{
- char *manifest;
- int size;
-
- if (pkgname == NULL) {
- DBGE("pkgname is NULL");
- return NULL;
- }
-
- size = strlen(MANIFEST_RW_DIRECTORY) + strlen(pkgname) + 10;
- manifest = malloc(size);
- if (manifest == NULL) {
- DBGE("No memory");
- return NULL;
- }
-
- snprintf(manifest, size, MANIFEST_RW_DIRECTORY "/%s.xml", pkgname);
-
- if (access(manifest, F_OK)) {
- snprintf(manifest, size, MANIFEST_RO_DIRECTORY "/%s.xml", pkgname);
- }
-
- return manifest;
-}
-
-static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgname)
-{
- int nLoop = 0;
- int pid = 0;
- char *parser_cmd = NULL;
- int ret = -1;
- const xmlChar *name;
- char *lib_path = NULL;
- void *lib_handle = NULL;
- int (*plugin_install) (xmlDocPtr);
-
- DBG("__run_parser_prestep");
-
- if (xmlTextReaderDepth(reader) != 1) {
- DBGE("Node depth is not 1");
- goto END;
- }
-
- if (!xmlTextReaderHasAttributes(reader)) {
- DBGE("No attributes");
- goto END;
- }
-
- if (xmlTextReaderNodeType(reader) != 1) {
- DBGE("Node type is not 1");
- goto END;
- }
-
- const xmlChar *value;
- name = xmlTextReaderConstName(reader);
- if (name == NULL) {
- DBGE("TEST TEST TES\n");
- name = BAD_CAST "--";
- }
-
- value = xmlTextReaderConstValue(reader);
- DBG("%d %d %s %d %d",
- xmlTextReaderDepth(reader),
- xmlTextReaderNodeType(reader),
- name,
- xmlTextReaderIsEmptyElement(reader), xmlTextReaderHasValue(reader));
-
- if (value == NULL) {
- DBG("ConstValue NULL");
- } else {
- if (xmlStrlen(value) > 40) {
- DBG(" %.40s...", value);
- } else {
- DBG(" %s", value);
- }
- }
-
- name = xmlTextReaderConstName(reader);
- if (name == NULL) {
- DBGE("TEST TEST TES\n");
- name = BAD_CAST "--";
- }
-
- xmlDocPtr docPtr = xmlTextReaderCurrentDoc(reader);
- DBG("docPtr->URL %s\n", (char *)docPtr->URL);
- xmlDocPtr copyDocPtr = xmlCopyDoc(docPtr, 1);
- if (copyDocPtr == NULL)
- return -1;
- xmlNode *rootElement = xmlDocGetRootElement(copyDocPtr);
- if (rootElement == NULL)
- return -1;
- xmlNode *cur_node = xmlFirstElementChild(rootElement);
- if (cur_node == NULL)
- return -1;
- xmlNode *next_node = NULL;
- next_node = xmlNextElementSibling(cur_node);
- if (next_node) {
- cur_node->next = NULL;
- next_node->prev = NULL;
- xmlFreeNodeList(next_node);
- xmlSetTreeDoc(cur_node, copyDocPtr);
- } else
- xmlSetTreeDoc(cur_node, copyDocPtr);
-
-#ifdef __DEBUG__
-
-//#else
- DBG("node type: %d, name: %s children->name: %s last->name: %s\n"
- "parent->name: %s next->name: %s prev->name: %s\n",
- cur_node->type, cur_node->name,
- cur_node->children ? cur_node->children->name : "NULL",
- cur_node->last ? cur_node->last->name : "NULL",
- cur_node->parent ? cur_node->parent->name : "NULL",
- cur_node->next ? cur_node->next->name : "NULL",
- cur_node->prev ? cur_node->prev->name : "NULL");
-
- FILE *fp = fopen("/opt/share/test.xml", "a");
- xmlDocDump(fp, copyDocPtr);
- fprintf(fp, "\n");
- fclose(fp);
-#endif
-
- ret = __ps_run_parser(copyDocPtr, name, action, pkgname);
-
- END:
-
- return ret;
-}
-
-static void
-__processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgname)
-{
- char *tag = NULL;
- int i = 0;
-
- switch (xmlTextReaderNodeType(reader)) {
- case XML_READER_TYPE_END_ELEMENT:
- {
- // DBG("XML_READER_TYPE_END_ELEMENT");
- break;
- }
-
- case XML_READER_TYPE_ELEMENT:
- {
- // Elements without closing tag don't receive
- // XML_READER_TYPE_END_ELEMENT event.
-
- const xmlChar *elementName =
- xmlTextReaderLocalName(reader);
- if (elementName) {
-// DBG("elementName %s\n", (char *)elementName);
- }
-
- const xmlChar *nameSpace =
- xmlTextReaderConstNamespaceUri(reader);
- if (nameSpace) {
-// DBG("nameSpace %s\n", (char *)nameSpace);
- }
-/*
- DBG("XML_READER_TYPE_ELEMENT %s, %s\n",
- elementName ? elementName : "NULL",
- nameSpace ? nameSpace : "NULL");
-*/
- if (tagv == NULL) {
- DBG("__run_parser_prestep pkgname[%s]\n", pkgname);
- __run_parser_prestep(reader, action, pkgname);
- }
- else {
- i = 0;
- for (tag = tagv[0]; tag; tag = tagv[++i])
- if (strcmp(tag, elementName) == 0) {
- DBG("__run_parser_prestep tag[%s] pkgname[%s]\n", tag, pkgname);
- __run_parser_prestep(reader,
- action, pkgname);
- break;
- }
- }
-
- break;
- }
- case XML_READER_TYPE_TEXT:
- case XML_READER_TYPE_CDATA:
- {
- const xmlChar *value = xmlTextReaderConstValue(reader);
- if (value) {
-// DBG("value %s\n", value);
- }
-
- const xmlChar *lang = xmlTextReaderConstXmlLang(reader);
- if (lang) {
-// DBG("lang\n", lang);
- }
-
-/* DBG("XML_READER_TYPE_TEXT %s, %s\n",
- value ? value : "NULL", lang ? lang : "NULL");
-*/
- break;
- }
- default:
-// DBG("Ignoring Node of Type: %d", xmlTextReaderNodeType(reader));
- break;
- }
-}
-
-static void
-__streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgname)
-{
- xmlTextReaderPtr reader;
- int ret;
-
- reader = xmlReaderForFile(filename, NULL, 0);
- if (reader != NULL) {
- ret = xmlTextReaderRead(reader);
- while (ret == 1) {
- __processNode(reader, action, tagv, pkgname);
- ret = xmlTextReaderRead(reader);
- }
- xmlFreeTextReader(reader);
-
- if (ret != 0) {
- DBGE("%s : failed to parse", filename);
- }
- } else {
- DBGE("Unable to open %s", filename);
- }
-}
-
-static int __next_child_element(xmlTextReaderPtr reader, int depth)
-{
- int ret = xmlTextReaderRead(reader);
- int cur = xmlTextReaderDepth(reader);
- while (ret == 1) {
-
- switch (xmlTextReaderNodeType(reader)) {
- case XML_READER_TYPE_ELEMENT:
- if (cur == depth + 1)
- return 1;
- break;
- case XML_READER_TYPE_TEXT:
- /*text is handled by each function separately*/
- if (cur == depth + 1)
- return 0;
- break;
- case XML_READER_TYPE_END_ELEMENT:
- if (cur == depth)
- return 0;
- break;
- default:
- if (cur <= depth)
- return 0;
- break;
- }
- ret = xmlTextReaderRead(reader);
- cur = xmlTextReaderDepth(reader);
- }
- return ret;
-}
-
-static void __ps_free_timeout(timeout_x *timeout)
-{
- if (timeout == NULL)
- return;
- if (timeout->text) {
- free((void *)timeout->text);
- timeout->text = NULL;
- }
- free((void*)timeout);
- timeout = NULL;
-}
-
-static void __ps_free_network(network_x *network)
-{
- if (network == NULL)
- return;
- if (network->text) {
- free((void *)network->text);
- network->text = NULL;
- }
- free((void*)network);
- network = NULL;
-}
-
-static void __ps_free_period(period_x *period)
-{
- if (period == NULL)
- return;
- if (period->text) {
- free((void *)period->text);
- period->text = NULL;
- }
- free((void*)period);
- period = NULL;
-}
-
-static void __ps_free_autolaunch(autolaunch_x *autolaunch)
-{
- if (autolaunch == NULL)
- return;
- if (autolaunch->text) {
- free((void *)autolaunch->text);
- autolaunch->text = NULL;
- }
- free((void*)autolaunch);
- autolaunch = NULL;
-}
-
-static void __ps_free_category(category_x *category)
-{
- if (category == NULL)
- return;
- if (category->name) {
- free((void *)category->name);
- category->name = NULL;
- }
- free((void*)category);
- category = NULL;
-}
-
-static void __ps_free_security(security_x *security)
-{
- if (security == NULL)
- return;
- if (security->isolate) {
- free((void *)security->isolate);
- security->isolate = NULL;
- }
- free((void*)security);
- security = NULL;
-}
-
-static void __ps_free_libexec(libexec_x *libexec)
-{
- if (libexec == NULL)
- return;
- if (libexec->text) {
- free((void *)libexec->text);
- libexec->text = NULL;
- }
- free((void*)libexec);
- libexec = NULL;
-}
-
-static void __ps_free_file(file_x *file)
-{
- if (file == NULL)
- return;
- if (file->text) {
- free((void *)file->text);
- file->text = NULL;
- }
- free((void*)file);
- file = NULL;
-}
-
-static void __ps_free_size(size_x *size)
-{
- if (size == NULL)
- return;
- if (size->text) {
- free((void *)size->text);
- size->text = NULL;
- }
- free((void*)size);
- size = NULL;
-}
-
-static void __ps_free_grp(grp_x *grp)
-{
- if (grp == NULL)
- return;
- if (grp->text) {
- free((void *)grp->text);
- grp->text = NULL;
- }
- free((void*)grp);
- grp = NULL;
-}
-
-static void __ps_free_icon(icon_x *icon)
-{
- if (icon == NULL)
- return;
- if (icon->text) {
- free((void *)icon->text);
- icon->text = NULL;
- }
- if (icon->lang) {
- free((void *)icon->lang);
- icon->lang = NULL;
- }
- if (icon->name) {
- free((void *)icon->name);
- icon->name= NULL;
- }
- if (icon->section) {
- free((void *)icon->section);
- icon->section = NULL;
- }
- if (icon->size) {
- free((void *)icon->size);
- icon->size = NULL;
- }
- free((void*)icon);
- icon = NULL;
-}
-
-static void __ps_free_operation(operation_x *operation)
-{
- if (operation == NULL)
- return;
- if (operation->text) {
- free((void *)operation->text);
- operation->text = NULL;
- }
- free((void*)operation);
- operation = NULL;
-}
-
-static void __ps_free_uri(uri_x *uri)
-{
- if (uri == NULL)
- return;
- if (uri->text) {
- free((void *)uri->text);
- uri->text = NULL;
- }
- free((void*)uri);
- uri = NULL;
-}
-
-static void __ps_free_mime(mime_x *mime)
-{
- if (mime == NULL)
- return;
- if (mime->text) {
- free((void *)mime->text);
- mime->text = NULL;
- }
- free((void*)mime);
- mime = NULL;
-}
-
-static void __ps_free_condition(condition_x *condition)
-{
- if (condition == NULL)
- return;
- if (condition->text) {
- free((void *)condition->text);
- condition->text = NULL;
- }
- if (condition->name) {
- free((void *)condition->name);
- condition->name = NULL;
- }
- free((void*)condition);
- condition = NULL;
-}
-
-static void __ps_free_notification(notification_x *notification)
-{
- if (notification == NULL)
- return;
- if (notification->text) {
- free((void *)notification->text);
- notification->text = NULL;
- }
- if (notification->name) {
- free((void *)notification->name);
- notification->name = NULL;
- }
- free((void*)notification);
- notification = NULL;
-}
-
-static void __ps_free_compatibility(compatibility_x *compatibility)
-{
- if (compatibility == NULL)
- return;
- if (compatibility->text) {
- free((void *)compatibility->text);
- compatibility->text = NULL;
- }
- if (compatibility->name) {
- free((void *)compatibility->name);
- compatibility->name = NULL;
- }
- free((void*)compatibility);
- compatibility = NULL;
-}
-
-static void __ps_free_resolution(resolution_x *resolution)
-{
- if (resolution == NULL)
- return;
- if (resolution->mimetype) {
- free((void *)resolution->mimetype);
- resolution->mimetype = NULL;
- }
- if (resolution->urischeme) {
- free((void *)resolution->urischeme);
- resolution->urischeme = NULL;
- }
- free((void*)resolution);
- resolution = NULL;
-}
-
-static void __ps_free_capability(capability_x *capability)
-{
- if (capability == NULL)
- return;
- if (capability->operationid) {
- free((void *)capability->operationid);
- capability->operationid = NULL;
- }
- /*Free Resolution*/
- if (capability->resolution) {
- resolution_x *resolution = capability->resolution;
- resolution_x *tmp = NULL;
- while(resolution != NULL)
- {
- tmp = resolution->next;
- __ps_free_resolution(resolution);
- resolution = tmp;
- }
- }
- free((void*)capability);
- capability = NULL;
-}
-
-static void __ps_free_allowed(allowed_x *allowed)
-{
- if (allowed == NULL)
- return;
- if (allowed->name) {
- free((void *)allowed->name);
- allowed->name = NULL;
- }
- if (allowed->text) {
- free((void *)allowed->text);
- allowed->text = NULL;
- }
- free((void*)allowed);
- allowed = NULL;
-}
-
-static void __ps_free_request(request_x *request)
-{
- if (request == NULL)
- return;
- if (request->text) {
- free((void *)request->text);
- request->text = NULL;
- }
- free((void*)request);
- request = NULL;
-}
-
-static void __ps_free_cluster(cluster_x *cluster)
-{
- if (cluster == NULL)
- return;
- if (cluster->name) {
- free((void *)cluster->name);
- cluster->name = NULL;
- }
- /*Free Category*/
- if (cluster->category) {
- category_x *category = cluster->category;
- category_x *tmp = NULL;
- while(category != NULL)
- {
- tmp = category->next;
- __ps_free_category(category);
- category = tmp;
- }
- }
- free((void*)cluster);
- cluster = NULL;
-}
-
-static void __ps_free_appcontrol(appcontrol_x *appcontrol)
-{
- if (appcontrol == NULL)
- return;
- if (appcontrol->providerid) {
- free((void *)appcontrol->providerid);
- appcontrol->providerid = NULL;
- }
- if (appcontrol->category) {
- free((void *)appcontrol->category);
- appcontrol->category = NULL;
- }
- /*Free Capability*/
- if (appcontrol->capability) {
- capability_x *capability = appcontrol->capability;
- capability_x *tmp = NULL;
- while(capability != NULL)
- {
- tmp = capability->next;
- __ps_free_capability(capability);
- capability = tmp;
- }
- }
- free((void*)appcontrol);
- appcontrol = NULL;
-}
-
-static void __ps_free_datacontrol(datacontrol_x *datacontrol)
-{
- if (datacontrol == NULL)
- return;
- if (datacontrol->providerid) {
- free((void *)datacontrol->providerid);
- datacontrol->providerid = NULL;
- }
- /*Free Capability*/
- if (datacontrol->capability) {
- capability_x *capability = datacontrol->capability;
- capability_x *tmp = NULL;
- while(capability != NULL)
- {
- tmp = capability->next;
- __ps_free_capability(capability);
- capability = tmp;
- }
- }
- free((void*)datacontrol);
- datacontrol = NULL;
-}
-
-static void __ps_free_launchconditions(launchconditions_x *launchconditions)
-{
- if (launchconditions == NULL)
- return;
- if (launchconditions->text) {
- free((void *)launchconditions->text);
- launchconditions->text = NULL;
- }
- /*Free Condition*/
- if (launchconditions->condition) {
- condition_x *condition = launchconditions->condition;
- condition_x *tmp = NULL;
- while(condition != NULL)
- {
- tmp = condition->next;
- __ps_free_condition(condition);
- condition = tmp;
- }
- }
- free((void*)launchconditions);
- launchconditions = NULL;
-}
-
-static void __ps_free_appsvc(appsvc_x *appsvc)
-{
- if (appsvc == NULL)
- return;
- if (appsvc->text) {
- free((void *)appsvc->text);
- appsvc->text = NULL;
- }
- /*Free Operation*/
- if (appsvc->operation) {
- operation_x *operation = appsvc->operation;
- operation_x *tmp = NULL;
- while(operation != NULL)
- {
- tmp = operation->next;
- __ps_free_operation(operation);
- operation = tmp;
- }
- }
- /*Free Uri*/
- if (appsvc->uri) {
- uri_x *uri = appsvc->uri;
- uri_x *tmp = NULL;
- while(uri != NULL)
- {
- tmp = uri->next;
- __ps_free_uri(uri);
- uri = tmp;
- }
- }
- /*Free Mime*/
- if (appsvc->mime) {
- mime_x *mime = appsvc->mime;
- mime_x *tmp = NULL;
- while(mime != NULL)
- {
- tmp = mime->next;
- __ps_free_mime(mime);
- mime = tmp;
- }
- }
- free((void*)appsvc);
- appsvc = NULL;
-}
-
-static void __ps_free_deviceprofile(deviceprofile_x *deviceprofile)
-{
- return;
-}
-
-
-
-static void __ps_free_define(define_x *define)
-{
- if (define == NULL)
- return;
- if (define->path) {
- free((void *)define->path);
- define->path = NULL;
- }
- /*Free Request*/
- if (define->request) {
- request_x *request = define->request;
- request_x *tmp = NULL;
- while(request != NULL)
- {
- tmp = request->next;
- __ps_free_request(request);
- request = tmp;
- }
- }
- /*Free Allowed*/
- if (define->allowed) {
- allowed_x *allowed = define->allowed;
- allowed_x *tmp = NULL;
- while(allowed != NULL)
- {
- tmp = allowed->next;
- __ps_free_allowed(allowed);
- allowed = tmp;
- }
- }
- free((void*)define);
- define = NULL;
-}
-
-static void __ps_free_registry(registry_x *registry)
-{
- if (registry == NULL)
- return;
- if (registry->name) {
- free((void *)registry->name);
- registry->name = NULL;
- }
- if (registry->text) {
- free((void *)registry->text);
- registry->text = NULL;
- }
- free((void*)registry);
- registry = NULL;
-}
-
-static void __ps_free_database(database_x *database)
-{
- if (database == NULL)
- return;
- if (database->name) {
- free((void *)database->name);
- database->name = NULL;
- }
- if (database->text) {
- free((void *)database->text);
- database->text = NULL;
- }
- free((void*)database);
- database = NULL;
-}
-
-static void __ps_free_datashare(datashare_x *datashare)
-{
- if (datashare == NULL)
- return;
- /*Free Define*/
- if (datashare->define) {
- define_x *define = datashare->define;
- define_x *tmp = NULL;
- while(define != NULL)
- {
- tmp = define->next;
- __ps_free_define(define);
- define = tmp;
- }
- }
- /*Free Request*/
- if (datashare->request) {
- request_x *request = datashare->request;
- request_x *tmp = NULL;
- while(request != NULL)
- {
- tmp = request->next;
- __ps_free_request(request);
- request = tmp;
- }
- }
- free((void*)datashare);
- datashare = NULL;
-}
-
-static void __ps_free_layout(layout_x *layout)
-{
- if (layout == NULL)
- return;
- if (layout->name) {
- free((void *)layout->name);
- layout->name = NULL;
- }
- if (layout->text) {
- free((void *)layout->text);
- layout->text = NULL;
- }
- free((void*)layout);
- layout = NULL;
-}
-
-static void __ps_free_control(control_x *control)
-{
- if (control == NULL)
- return;
- /*Free Timeout*/
- if (control->timeout) {
- timeout_x *timeout = control->timeout;
- timeout_x *tmp = NULL;
- while(timeout != NULL)
- {
- tmp = timeout->next;
- __ps_free_timeout(timeout);
- timeout = tmp;
- }
- }
- /*Free Period*/
- if (control->period) {
- period_x *period = control->period;
- period_x *tmp = NULL;
- while(period != NULL)
- {
- tmp = period->next;
- __ps_free_period(period);
- period = tmp;
- }
- }
- /*Free Network*/
- if (control->network) {
- network_x *network = control->network;
- network_x *tmp = NULL;
- while(network != NULL)
- {
- tmp = network->next;
- __ps_free_network(network);
- network = tmp;
- }
- }
- /*Free Autolaunch*/
- if (control->autolaunch) {
- autolaunch_x *autolaunch = control->autolaunch;
- autolaunch_x *tmp = NULL;
- while(autolaunch != NULL)
- {
- tmp = autolaunch->next;
- __ps_free_autolaunch(autolaunch);
- autolaunch = tmp;
- }
- }
- free((void*)control);
- control = NULL;
-}
-
-static void __ps_free_pd(pd_x *pd)
-{
- if (pd == NULL)
- return;
- if (pd->type) {
- free((void *)pd->type);
- pd->type = NULL;
- }
- if (pd->language) {
- free((void *)pd->language);
- pd->language = NULL;
- }
- /*Free File*/
- if (pd->file) {
- file_x *file = pd->file;
- file_x *tmp = NULL;
- while(file != NULL)
- {
- tmp = file->next;
- __ps_free_file(file);
- file = tmp;
- }
- }
- /*Free Group*/
- if (pd->grp) {
- grp_x *grp = pd->grp;
- grp_x *tmp = NULL;
- while(grp != NULL)
- {
- tmp = grp->next;
- __ps_free_grp(grp);
- grp = tmp;
- }
- }
- /*Free Size*/
- if (pd->size) {
- size_x *size = pd->size;
- size_x *tmp = NULL;
- while(size != NULL)
- {
- tmp = size->next;
- __ps_free_size(size);
- size = tmp;
- }
- }
- free((void*)pd);
- pd = NULL;
-}
-
-static void __ps_free_lbox(lbox_x *lbox)
-{
- if (lbox == NULL)
- return;
- if (lbox->type) {
- free((void*)lbox->type);
- lbox->type = NULL;
- }
- /*Free Size*/
- if (lbox->size) {
- size_x *size = lbox->size;
- size_x *tmp = NULL;
- while(size != NULL)
- {
- tmp = size->next;
- __ps_free_size(size);
- size = tmp;
- }
- }
- free((void*)lbox);
- lbox = NULL;
-}
-
-static void __ps_free_content(content_x *content)
-{
- if (content == NULL)
- return;
- /*Free Livebox*/
- if (content->lbox) {
- lbox_x *lbox = content->lbox;
- lbox_x *tmp = NULL;
- while(lbox != NULL)
- {
- tmp = lbox->next;
- __ps_free_lbox(lbox);
- lbox = tmp;
- }
- }
- /*Free Pd*/
- if (content->pd) {
- pd_x *pd = content->pd;
- pd_x *tmp = NULL;
- while(pd != NULL)
- {
- tmp = pd->next;
- __ps_free_pd(pd);
- pd = tmp;
- }
- }
- free((void*)content);
- content = NULL;
-}
-
-static void __ps_free_group(group_x *group)
-{
- if (group == NULL)
- return;
- /*Free Cluster*/
- if (group->cluster) {
- cluster_x *cluster = group->cluster;
- cluster_x *tmp = NULL;
- while(cluster != NULL)
- {
- tmp = cluster->next;
- __ps_free_cluster(cluster);
- cluster = tmp;
- }
- }
- free((void*)group);
- group = NULL;
-}
-
-static void __ps_free_livebox(livebox_x *livebox)
-{
- if (livebox == NULL)
- return;
- if (livebox->abi) {
- free((void *)livebox->abi);
- livebox->abi= NULL;
- }
- if (livebox->application) {
- free((void *)livebox->application);
- livebox->application = NULL;
- }
- if (livebox->type) {
- free((void *)livebox->type);
- livebox->type = NULL;
- }
- /*Free Icon*/
- if (livebox->icon) {
- icon_x *icon = livebox->icon;
- icon_x *tmp = NULL;
- while(icon != NULL)
- {
- tmp = icon->next;
- __ps_free_icon(icon);
- icon = tmp;
- }
- }
- /*Free Label*/
- if (livebox->label) {
- label_x *label = livebox->label;
- label_x *tmp = NULL;
- while(label != NULL)
- {
- tmp = label->next;
- __ps_free_label(label);
- label = tmp;
- }
- }
- /*Free Libexec*/
- if (livebox->libexec) {
- libexec_x *libexec = livebox->libexec;
- libexec_x *tmp = NULL;
- while(libexec != NULL)
- {
- tmp = libexec->next;
- __ps_free_libexec(libexec);
- libexec = tmp;
- }
- }
- /*Free Control*/
- if (livebox->control) {
- control_x *control = livebox->control;
- control_x *tmp = NULL;
- while(control != NULL)
- {
- tmp = control->next;
- __ps_free_control(control);
- control = tmp;
- }
- }
- /*Free Content*/
- if (livebox->content) {
- content_x *content = livebox->content;
- content_x *tmp = NULL;
- while(content != NULL)
- {
- tmp = content->next;
- __ps_free_content(content);
- content = tmp;
- }
- }
- /*Free Group*/
- if (livebox->group) {
- group_x *group = livebox->group;
- group_x *tmp = NULL;
- while(group != NULL)
- {
- tmp = group->next;
- __ps_free_group(group);
- group = tmp;
- }
- }
- /*Free Security*/
- if (livebox->security) {
- security_x *security = livebox->security;
- security_x *tmp = NULL;
- while(security != NULL)
- {
- tmp = security->next;
- __ps_free_security(security);
- security = tmp;
- }
- }
- /*Free Size*/
- if (livebox->size) {
- size_x *size = livebox->size;
- size_x *tmp = NULL;
- while(size != NULL)
- {
- tmp = size->next;
- __ps_free_size(size);
- size = tmp;
- }
- }
- free((void*)livebox);
- livebox = NULL;
-}
-
-static void __ps_free_label(label_x *label)
-{
- if (label == NULL)
- return;
- if (label->name) {
- free((void *)label->name);
- label->name = NULL;
- }
- if (label->text) {
- free((void *)label->text);
- label->text = NULL;
- }
- if (label->lang) {
- free((void *)label->lang);
- label->lang= NULL;
- }
- free((void*)label);
- label = NULL;
-}
-
-static void __ps_free_author(author_x *author)
-{
- if (author == NULL)
- return;
- if (author->email) {
- free((void *)author->email);
- author->email = NULL;
- }
- if (author->text) {
- free((void *)author->text);
- author->text = NULL;
- }
- if (author->href) {
- free((void *)author->href);
- author->href = NULL;
- }
- if (author->lang) {
- free((void *)author->lang);
- author->lang = NULL;
- }
- free((void*)author);
- author = NULL;
-}
-
-static void __ps_free_description(description_x *description)
-{
- if (description == NULL)
- return;
- if (description->name) {
- free((void *)description->name);
- description->name = NULL;
- }
- if (description->text) {
- free((void *)description->text);
- description->text = NULL;
- }
- if (description->lang) {
- free((void *)description->lang);
- description->lang = NULL;
- }
- free((void*)description);
- description = NULL;
-}
-
-static void __ps_free_license(license_x *license)
-{
- if (license == NULL)
- return;
- if (license->text) {
- free((void *)license->text);
- license->text = NULL;
- }
- if (license->lang) {
- free((void *)license->lang);
- license->lang = NULL;
- }
- free((void*)license);
- license = NULL;
-}
-
-static void __ps_free_uiapplication(uiapplication_x *uiapplication)
-{
- if (uiapplication == NULL)
- return;
- if (uiapplication->exec) {
- free((void *)uiapplication->exec);
- uiapplication->exec = NULL;
- }
- if (uiapplication->appid) {
- free((void *)uiapplication->appid);
- uiapplication->appid = NULL;
- }
- if (uiapplication->nodisplay) {
- free((void *)uiapplication->nodisplay);
- uiapplication->nodisplay = NULL;
- }
- if (uiapplication->multiple) {
- free((void *)uiapplication->multiple);
- uiapplication->multiple = NULL;
- }
- if (uiapplication->type) {
- free((void *)uiapplication->type);
- uiapplication->type = NULL;
- }
- if (uiapplication->categories) {
- free((void *)uiapplication->categories);
- uiapplication->categories = NULL;
- }
- if (uiapplication->extraid) {
- free((void *)uiapplication->extraid);
- uiapplication->extraid = NULL;
- }
- if (uiapplication->taskmanage) {
- free((void *)uiapplication->taskmanage);
- uiapplication->taskmanage = NULL;
- }
- /*Free Label*/
- if (uiapplication->label) {
- label_x *label = uiapplication->label;
- label_x *tmp = NULL;
- while(label != NULL)
- {
- tmp = label->next;
- __ps_free_label(label);
- label = tmp;
- }
- }
- /*Free Icon*/
- if (uiapplication->icon) {
- icon_x *icon = uiapplication->icon;
- icon_x *tmp = NULL;
- while(icon != NULL)
- {
- tmp = icon->next;
- __ps_free_icon(icon);
- icon = tmp;
- }
- }
- /*Free AppControl*/
- if (uiapplication->appcontrol) {
- appcontrol_x *appcontrol = uiapplication->appcontrol;
- appcontrol_x *tmp = NULL;
- while(appcontrol != NULL)
- {
- tmp = appcontrol->next;
- __ps_free_appcontrol(appcontrol);
- appcontrol = tmp;
- }
- }
- /*Free LaunchConditions*/
- if (uiapplication->launchconditions) {
- launchconditions_x *launchconditions = uiapplication->launchconditions;
- launchconditions_x *tmp = NULL;
- while(launchconditions != NULL)
- {
- tmp = launchconditions->next;
- __ps_free_launchconditions(launchconditions);
- launchconditions = tmp;
- }
- }
- /*Free Notification*/
- if (uiapplication->notification) {
- notification_x *notification = uiapplication->notification;
- notification_x *tmp = NULL;
- while(notification != NULL)
- {
- tmp = notification->next;
- __ps_free_notification(notification);
- notification = tmp;
- }
- }
- /*Free DataShare*/
- if (uiapplication->datashare) {
- datashare_x *datashare = uiapplication->datashare;
- datashare_x *tmp = NULL;
- while(datashare != NULL)
- {
- tmp = datashare->next;
- __ps_free_datashare(datashare);
- datashare = tmp;
- }
- }
- /*Free AppSvc*/
- if (uiapplication->appsvc) {
- appsvc_x *appsvc = uiapplication->appsvc;
- appsvc_x *tmp = NULL;
- while(appsvc != NULL)
- {
- tmp = appsvc->next;
- __ps_free_appsvc(appsvc);
- appsvc = tmp;
- }
- }
- free((void*)uiapplication);
- uiapplication = NULL;
-}
-
-static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication)
-{
- if (serviceapplication == NULL)
- return;
- if (serviceapplication->exec) {
- free((void *)serviceapplication->exec);
- serviceapplication->exec = NULL;
- }
- if (serviceapplication->appid) {
- free((void *)serviceapplication->appid);
- serviceapplication->appid = NULL;
- }
- if (serviceapplication->onboot) {
- free((void *)serviceapplication->onboot);
- serviceapplication->onboot = NULL;
- }
- if (serviceapplication->autorestart) {
- free((void *)serviceapplication->autorestart);
- serviceapplication->autorestart = NULL;
- }
- if (serviceapplication->type) {
- free((void *)serviceapplication->type);
- serviceapplication->type = NULL;
- }
- /*Free Label*/
- if (serviceapplication->label) {
- label_x *label = serviceapplication->label;
- label_x *tmp = NULL;
- while(label != NULL)
- {
- tmp = label->next;
- __ps_free_label(label);
- label = tmp;
- }
- }
- /*Free Icon*/
- if (serviceapplication->icon) {
- icon_x *icon = serviceapplication->icon;
- icon_x *tmp = NULL;
- while(icon != NULL)
- {
- tmp = icon->next;
- __ps_free_icon(icon);
- icon = tmp;
- }
- }
- /*Free AppControl*/
- if (serviceapplication->appcontrol) {
- appcontrol_x *appcontrol = serviceapplication->appcontrol;
- appcontrol_x *tmp = NULL;
- while(appcontrol != NULL)
- {
- tmp = appcontrol->next;
- __ps_free_appcontrol(appcontrol);
- appcontrol = tmp;
- }
- }
- /*Free DataControl*/
- if (serviceapplication->datacontrol) {
- datacontrol_x *datacontrol = serviceapplication->datacontrol;
- datacontrol_x *tmp = NULL;
- while(datacontrol != NULL)
- {
- tmp = datacontrol->next;
- __ps_free_datacontrol(datacontrol);
- datacontrol = tmp;
- }
- }
- /*Free LaunchConditions*/
- if (serviceapplication->launchconditions) {
- launchconditions_x *launchconditions = serviceapplication->launchconditions;
- launchconditions_x *tmp = NULL;
- while(launchconditions != NULL)
- {
- tmp = launchconditions->next;
- __ps_free_launchconditions(launchconditions);
- launchconditions = tmp;
- }
- }
- /*Free Notification*/
- if (serviceapplication->notification) {
- notification_x *notification = serviceapplication->notification;
- notification_x *tmp = NULL;
- while(notification != NULL)
- {
- tmp = notification->next;
- __ps_free_notification(notification);
- notification = tmp;
- }
- }
- /*Free DataShare*/
- if (serviceapplication->datashare) {
- datashare_x *datashare = serviceapplication->datashare;
- datashare_x *tmp = NULL;
- while(datashare != NULL)
- {
- tmp = datashare->next;
- __ps_free_datashare(datashare);
- datashare = tmp;
- }
- }
- /*Free AppSvc*/
- if (serviceapplication->appsvc) {
- appsvc_x *appsvc = serviceapplication->appsvc;
- appsvc_x *tmp = NULL;
- while(appsvc != NULL)
- {
- tmp = appsvc->next;
- __ps_free_appsvc(appsvc);
- appsvc = tmp;
- }
- }
- free((void*)serviceapplication);
- serviceapplication = NULL;
-}
-
-static void __ps_free_font(font_x *font)
-{
- if (font == NULL)
- return;
- if (font->name) {
- free((void *)font->name);
- font->name = NULL;
- }
- if (font->text) {
- free((void *)font->text);
- font->text = NULL;
- }
- free((void*)font);
- font = NULL;
-}
-
-static void __ps_free_theme(theme_x *theme)
-{
- if (theme == NULL)
- return;
- if (theme->name) {
- free((void *)theme->name);
- theme->name = NULL;
- }
- if (theme->text) {
- free((void *)theme->text);
- theme->text = NULL;
- }
- free((void*)theme);
- theme = NULL;
-}
-
-static void __ps_free_daemon(daemon_x *daemon)
-{
- if (daemon == NULL)
- return;
- if (daemon->name) {
- free((void *)daemon->name);
- daemon->name = NULL;
- }
- if (daemon->text) {
- free((void *)daemon->text);
- daemon->text = NULL;
- }
- free((void*)daemon);
- daemon = NULL;
-}
-
-static void __ps_free_ime(ime_x *ime)
-{
- if (ime == NULL)
- return;
- if (ime->name) {
- free((void *)ime->name);
- ime->name = NULL;
- }
- if (ime->text) {
- free((void *)ime->text);
- ime->text = NULL;
- }
- free((void*)ime);
- ime = NULL;
-}
-
-
-static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed)
-{
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- allowed->text = ASCII(xmlTextReaderValue(reader));
- return 0;
-}
-
-static int __ps_process_timeout(xmlTextReaderPtr reader, timeout_x *timeout)
-{
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- timeout->text = ASCII(xmlTextReaderValue(reader));
- return 0;
-}
-
-static int __ps_process_network(xmlTextReaderPtr reader, network_x *network)
-{
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- network->text = ASCII(xmlTextReaderValue(reader));
- return 0;
-}
-
-static int __ps_process_period(xmlTextReaderPtr reader, period_x *period)
-{
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- period->text = ASCII(xmlTextReaderValue(reader));
- return 0;
-}
-
-static int __ps_process_autolaunch(xmlTextReaderPtr reader, autolaunch_x *autolaunch)
-{
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- autolaunch->text = ASCII(xmlTextReaderValue(reader));
- return 0;
-}
-
-static int __ps_process_file(xmlTextReaderPtr reader, file_x *file)
-{
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- file->text = ASCII(xmlTextReaderValue(reader));
- return 0;
-}
-
-static int __ps_process_size(xmlTextReaderPtr reader, size_x *size)
-{
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- size->text = ASCII(xmlTextReaderValue(reader));
- return 0;
-}
-
-static int __ps_process_grp(xmlTextReaderPtr reader, grp_x *grp)
-{
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- grp->text = ASCII(xmlTextReaderValue(reader));
- return 0;
-}
-
-static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation)
-{
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
- operation->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- operation->text = ASCII(xmlTextReaderValue(reader));
- return 0;
-}
-
-static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri)
-{
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
- uri->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- uri->text = ASCII(xmlTextReaderValue(reader));
- return 0;
-}
-
-static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime)
-{
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
- mime->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- mime->text = ASCII(xmlTextReaderValue(reader));
- return 0;
-}
-
-static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition)
-{
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
- condition->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- condition->text = ASCII(xmlTextReaderValue(reader));
- return 0;
-}
-
-static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notification)
-{
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
- notification->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- notification->text = ASCII(xmlTextReaderValue(reader));
- return 0;
-}
-
-static int __ps_process_category(xmlTextReaderPtr reader, category_x *category)
-{
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
- category->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
- return 0;
-}
-
-static int __ps_process_security(xmlTextReaderPtr reader, security_x *security)
-{
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("isolate")))
- security->isolate = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("isolate")));
- return 0;
-}
-
-static int __ps_process_libexec(xmlTextReaderPtr reader, libexec_x *libexec)
-{
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- libexec->text = ASCII(xmlTextReaderValue(reader));
- return 0;
-}
-
-static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility)
-{
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
- compatibility->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- compatibility->text = ASCII(xmlTextReaderValue(reader));
- return 0;
-}
-
-static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution)
-{
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")))
- resolution->mimetype = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")));
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")))
- resolution->urischeme = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")));
- return 0;
-}
-
-static int __ps_process_request(xmlTextReaderPtr reader, request_x *request)
-{
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- request->text = ASCII(xmlTextReaderValue(reader));
- return 0;
-}
-
-static int __ps_process_define(xmlTextReaderPtr reader, define_x *define)
-{
- const xmlChar *node;
- int ret = -1;
- int depth = -1;
- allowed_x *tmp1 = NULL;
- request_x *tmp2 = NULL;
-
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("path")))
- define->path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("path")));
-
- depth = xmlTextReaderDepth(reader);
- while ((ret = __next_child_element(reader, depth))) {
- node = xmlTextReaderConstName(reader);
- if (!node) {
- DBG("xmlTextReaderConstName value is NULL\n");
- return -1;
- }
-
- if (!strcmp(ASCII(node), "allowed")) {
- allowed_x *allowed= malloc(sizeof(allowed_x));
- if (allowed == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(allowed, '\0', sizeof(allowed_x));
- if (allowed) {
- LISTADD(define->allowed, allowed);
- ret =
- __ps_process_allowed(reader, allowed);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "request")) {
- request_x *request = malloc(sizeof(request_x));
- if (request == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(request, '\0', sizeof(request_x));
- if (request) {
- LISTADD(define->request, request);
- ret =
- __ps_process_request(reader, request);
- } else
- return -1;
- } else
- return -1;
- if (ret < 0) {
- DBG("Processing define failed\n");
- return ret;
- }
- }
- if (define->allowed) {
- LISTHEAD(define->allowed, tmp1);
- define->allowed = tmp1;
- }
- if (define->request) {
- LISTHEAD(define->request, tmp2);
- define->request = tmp2;
- }
- return ret;
-}
-
-static int __ps_process_registry(xmlTextReaderPtr reader, registry_x *registry)
-{
- /*TODO: once policy is set*/
- return 0;
-}
-
-static int __ps_process_database(xmlTextReaderPtr reader, database_x *database)
-{
- /*TODO: once policy is set*/
- return 0;
-}
-
-static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc)
-{
- const xmlChar *node;
- int ret = -1;
- int depth = -1;
- operation_x *tmp1 = NULL;
- uri_x *tmp2 = NULL;
- mime_x *tmp3 = NULL;
-
- depth = xmlTextReaderDepth(reader);
- while ((ret = __next_child_element(reader, depth))) {
- node = xmlTextReaderConstName(reader);
- if (!node) {
- DBG("xmlTextReaderConstName value is NULL\n");
- return -1;
- }
-
- if (!strcmp(ASCII(node), "operation")) {
- operation_x *operation = malloc(sizeof(operation_x));
- if (operation == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(operation, '\0', sizeof(operation_x));
- if (operation) {
- LISTADD(appsvc->operation, operation);
- ret =
- __ps_process_operation(reader, operation);
-
- DBG("operation processing\n");
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "uri")) {
- uri_x *uri= malloc(sizeof(uri_x));
- if (uri == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(uri, '\0', sizeof(uri_x));
- if (uri) {
- LISTADD(appsvc->uri, uri);
- ret =
- __ps_process_uri(reader, uri);
-
- DBG("uri processing\n");
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "mime")) {
- mime_x *mime = malloc(sizeof(mime_x));
- if (mime == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(mime, '\0', sizeof(mime_x));
- if (mime) {
- LISTADD(appsvc->mime, mime);
- ret =
- __ps_process_mime(reader, mime);
-
- DBG("mime processing\n");
- } else
- return -1;
- } else
- return -1;
- if (ret < 0) {
- DBG("Processing appsvc failed\n");
- return ret;
- }
- }
- if (appsvc->operation) {
- LISTHEAD(appsvc->operation, tmp1);
- appsvc->operation = tmp1;
- }
- if (appsvc->uri) {
- LISTHEAD(appsvc->uri, tmp2);
- appsvc->uri = tmp2;
- }
- if (appsvc->mime) {
- LISTHEAD(appsvc->mime, tmp3);
- appsvc->mime = tmp3;
- }
-
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- appsvc->text = ASCII(xmlTextReaderValue(reader));
-
- return ret;
-}
-
-static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions)
-{
- const xmlChar *node;
- int ret = -1;
- int depth = -1;
- condition_x *tmp1 = NULL;
-
- depth = xmlTextReaderDepth(reader);
- while ((ret = __next_child_element(reader, depth))) {
- node = xmlTextReaderConstName(reader);
- if (!node) {
- DBG("xmlTextReaderConstName value is NULL\n");
- return -1;
- }
-
- if (strcmp(ASCII(node), "condition") == 0) {
- condition_x *condition = malloc(sizeof(condition_x));
- if (condition == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(condition, '\0', sizeof(condition_x));
- if (condition) {
- LISTADD(launchconditions->condition, condition);
- ret =
- __ps_process_condition(reader, condition);
- } else
- return -1;
- } else
- return -1;
- if (ret < 0) {
- DBG("Processing launchconditions failed\n");
- return ret;
- }
- }
- if (launchconditions->condition) {
- LISTHEAD(launchconditions->condition, tmp1);
- launchconditions->condition = tmp1;
- }
-
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- launchconditions->text = ASCII(xmlTextReaderValue(reader));
-
- return ret;
-}
-
-static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare)
-{
- const xmlChar *node;
- int ret = -1;
- int depth = -1;
- define_x *tmp1 = NULL;
- request_x *tmp2 = NULL;
- depth = xmlTextReaderDepth(reader);
- while ((ret = __next_child_element(reader, depth))) {
- node = xmlTextReaderConstName(reader);
- if (!node) {
- DBG("xmlTextReaderConstName value is NULL\n");
- return -1;
- }
-
- if (!strcmp(ASCII(node), "define")) {
- define_x *define= malloc(sizeof(define_x));
- if (define == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(define, '\0', sizeof(define_x));
- if (define) {
- LISTADD(datashare->define, define);
- ret =
- __ps_process_define(reader, define);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "request")) {
- request_x *request= malloc(sizeof(request_x));
- if (request == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(request, '\0', sizeof(request_x));
- if (request) {
- LISTADD(datashare->request, request);
- ret =
- __ps_process_request(reader, request);
- } else
- return -1;
- } else
- return -1;
- if (ret < 0) {
- DBG("Processing data-share failed\n");
- return ret;
- }
- }
- if (datashare->define) {
- LISTHEAD(datashare->define, tmp1);
- datashare->define = tmp1;
- }
- if (datashare->request) {
- LISTHEAD(datashare->request, tmp2);
- datashare->request = tmp2;
- }
- return ret;
-}
-
-static int __ps_process_layout(xmlTextReaderPtr reader, layout_x *layout)
-{
- /*TODO: once policy is set*/
- return 0;
-}
-
-static int __ps_process_cluster(xmlTextReaderPtr reader, cluster_x *cluster)
-{
- const xmlChar *node;
- int ret = -1;
- int depth = -1;
- category_x *tmp1 = NULL;
-
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
- cluster->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
-
- depth = xmlTextReaderDepth(reader);
- while ((ret = __next_child_element(reader, depth))) {
- node = xmlTextReaderConstName(reader);
- if (!node) {
- DBG("xmlTextReaderConstName value is NULL\n");
- return -1;
- }
-
- if (!strcmp(ASCII(node), "category")) {
- category_x *category = malloc(sizeof(category_x));
- if (category == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(category, '\0', sizeof(category_x));
- if (category) {
- LISTADD(cluster->category, category);
- ret =
- __ps_process_category(reader, category);
- } else
- return -1;
- } else
- return -1;
- if (ret < 0) {
- DBG("Processing category failed\n");
- return ret;
- }
- }
- if (cluster->category) {
- LISTHEAD(cluster->category, tmp1);
- cluster->category = tmp1;
- }
-
- return ret;
-}
-
-static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon)
-{
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
- icon->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
- if (xmlTextReaderConstXmlLang(reader)) {
- icon->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
- if (icon->lang == NULL)
- icon->lang = strdup(DEFAULT_LOCALE);
- } else {
- icon->lang = strdup(DEFAULT_LOCALE);
- }
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
- icon->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
- icon->size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- icon->text = ASCII(xmlTextReaderValue(reader));
-
- return 0;
-}
-
-static int __ps_process_lbox(xmlTextReaderPtr reader, lbox_x *lbox)
-{
- const xmlChar *node;
- int ret = -1;
- int depth = -1;
- size_x *tmp1 = NULL;
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
- lbox->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
-
- depth = xmlTextReaderDepth(reader);
- while ((ret = __next_child_element(reader, depth))) {
- node = xmlTextReaderConstName(reader);
- if (!node) {
- DBG("xmlTextReaderConstName value is NULL\n");
- return -1;
- }
- if (!strcmp(ASCII(node), "size")) {
- size_x *size= malloc(sizeof(size_x));
- if (size == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(size, '\0', sizeof(size_x));
- if (size) {
- LISTADD(lbox->size, size);
- ret =
- __ps_process_size(reader, size);
- } else
- return -1;
- } else
- return -1;
- if (ret < 0) {
- DBG("Processing lbox failed\n");
- return ret;
- }
- }
-
- if (lbox->size) {
- LISTHEAD(lbox->size, tmp1);
- lbox->size = tmp1;
- }
-
- return ret;
-}
-
-static int __ps_process_pd(xmlTextReaderPtr reader, pd_x *pd)
-{
- const xmlChar *node;
- int ret = -1;
- int depth = -1;
- file_x *tmp1 = NULL;
- grp_x *tmp2 = NULL;
- size_x *tmp3 = NULL;
-
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
- pd->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("language")))
- pd->language = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("language")));
-
- depth = xmlTextReaderDepth(reader);
- while ((ret = __next_child_element(reader, depth))) {
- node = xmlTextReaderConstName(reader);
- if (!node) {
- DBG("xmlTextReaderConstName value is NULL\n");
- return -1;
- }
- if (!strcmp(ASCII(node), "file")) {
- file_x *file = malloc(sizeof(file_x));
- if (file == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(file, '\0', sizeof(file_x));
- if (file) {
- LISTADD(pd->file, file);
- ret =
- __ps_process_file(reader, file);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "group")) {
- grp_x *grp = malloc(sizeof(grp_x));
- if (grp == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(grp, '\0', sizeof(grp_x));
- if (grp) {
- LISTADD(pd->grp, grp);
- ret =
- __ps_process_grp(reader, grp);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "size")) {
- size_x *size = malloc(sizeof(size_x));
- if (size == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(size, '\0', sizeof(size_x));
- if (size) {
- LISTADD(pd->size, size);
- ret =
- __ps_process_size(reader, size);
- } else
- return -1;
- } else
- return -1;
- if (ret < 0) {
- DBG("Processing pd failed\n");
- return ret;
- }
- }
-
- if (pd->file) {
- LISTHEAD(pd->file, tmp1);
- pd->file = tmp1;
- }
- if (pd->grp) {
- LISTHEAD(pd->grp, tmp2);
- pd->grp = tmp2;
- }
- if (pd->size) {
- LISTHEAD(pd->size , tmp3);
- pd->size = tmp3;
- }
-
- return ret;
-}
-
-static int __ps_process_content(xmlTextReaderPtr reader, content_x *content)
-{
- DBG("CONTENT\n");
- const xmlChar *node;
- int ret = -1;
- int depth = -1;
- lbox_x *tmp1 = NULL;
- pd_x *tmp2 = NULL;
-
- depth = xmlTextReaderDepth(reader);
- while ((ret = __next_child_element(reader, depth))) {
- node = xmlTextReaderConstName(reader);
- if (!node) {
- DBG("xmlTextReaderConstName value is NULL\n");
- return -1;
- }
-
- if (!strcmp(ASCII(node), "livebox")) {
- lbox_x *lbox = malloc(sizeof(lbox_x));
- if (lbox == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(lbox, '\0', sizeof(lbox_x));
- if (lbox) {
- LISTADD(content->lbox, lbox);
- ret =
- __ps_process_lbox(reader, lbox);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "pd")) {
- pd_x *pd = malloc(sizeof(pd_x));
- if (pd == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(pd, '\0', sizeof(pd_x));
- if (pd) {
- LISTADD(content->pd, pd);
- ret =
- __ps_process_pd(reader, pd);
- } else
- return -1;
- } else
- return -1;
- if (ret < 0) {
- DBG("Processing content failed\n");
- return ret;
- }
- }
-
- if (content->lbox) {
- LISTHEAD(content->lbox, tmp1);
- content->lbox = tmp1;
- }
- if (content->pd) {
- LISTHEAD(content->pd, tmp2);
- content->pd = tmp2;
- }
-
- return ret;
-
-}
-
-static int __ps_process_control(xmlTextReaderPtr reader, control_x *control)
-{
- const xmlChar *node;
- int ret = -1;
- int depth = -1;
- timeout_x *tmp1 = NULL;
- network_x *tmp2 = NULL;
- period_x *tmp3 = NULL;
- autolaunch_x *tmp4 = NULL;
-
- depth = xmlTextReaderDepth(reader);
- while ((ret = __next_child_element(reader, depth))) {
- node = xmlTextReaderConstName(reader);
- if (!node) {
- DBG("xmlTextReaderConstName value is NULL\n");
- return -1;
- }
-
- if (!strcmp(ASCII(node), "timeout")) {
- timeout_x *timeout = malloc(sizeof(timeout_x));
- if (timeout == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(timeout, '\0', sizeof(timeout_x));
- if (timeout) {
- LISTADD(control->timeout, timeout);
- ret =
- __ps_process_timeout(reader, timeout);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "network")) {
- network_x *network = malloc(sizeof(network_x));
- if (network == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(network, '\0', sizeof(network_x));
- if (network) {
- LISTADD(control->network, network);
- ret =
- __ps_process_network(reader, network);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "period")) {
- period_x *period = malloc(sizeof(period_x));
- if (period == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(period, '\0', sizeof(period_x));
- if (period) {
- LISTADD(control->period, period);
- ret =
- __ps_process_period(reader, period);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "autolaunch")) {
- autolaunch_x *autolaunch = malloc(sizeof(autolaunch_x));
- if (autolaunch == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(autolaunch, '\0', sizeof(autolaunch_x));
- if (autolaunch) {
- LISTADD(control->autolaunch, autolaunch);
- ret =
- __ps_process_autolaunch(reader, autolaunch);
- } else
- return -1;
- } else
- return -1;
- if (ret < 0) {
- DBG("Processing control failed\n");
- return ret;
- }
- }
-
- if (control->timeout) {
- LISTHEAD(control->timeout, tmp1);
- control->timeout = tmp1;
- }
- if (control->network) {
- LISTHEAD(control->network, tmp2);
- control->network = tmp2;
- }
- if (control->period) {
- LISTHEAD(control->period, tmp3);
- control->period = tmp3;
- }
- if (control->autolaunch) {
- LISTHEAD(control->autolaunch, tmp4);
- control->autolaunch = tmp4;
- }
-
- return ret;
-}
-
-static int __ps_process_group(xmlTextReaderPtr reader, group_x *group)
-{
- const xmlChar *node;
- int ret = -1;
- int depth = -1;
- cluster_x *tmp1 = NULL;
- depth = xmlTextReaderDepth(reader);
- while ((ret = __next_child_element(reader, depth))) {
- node = xmlTextReaderConstName(reader);
- if (!node) {
- DBG("xmlTextReaderConstName value is NULL\n");
- return -1;
- }
-
- if (!strcmp(ASCII(node), "cluster")) {
- cluster_x *cluster = malloc(sizeof(cluster_x));
- if (cluster == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(cluster, '\0', sizeof(cluster_x));
- if (cluster) {
- LISTADD(group->cluster, cluster);
- ret =
- __ps_process_cluster(reader, cluster);
- } else
- return -1;
- } else
- return -1;
- if (ret < 0) {
- DBG("Processing group failed\n");
- return ret;
- }
- }
-
- if (group->cluster) {
- LISTHEAD(group->cluster, tmp1);
- group->cluster = tmp1;
- }
-
- return ret;
-}
-
-static int __ps_process_livebox(xmlTextReaderPtr reader, livebox_x *livebox)
-{
- const xmlChar *node;
- int ret = -1;
- int depth = -1;
- icon_x *tmp1 = NULL;
- label_x *tmp2 = NULL;
- libexec_x *tmp3 = NULL;
- control_x *tmp4 = NULL;
- content_x *tmp5 = NULL;
- group_x *tmp6 = NULL;
- security_x *tmp7 = NULL;
- size_x *tmp8 = NULL;
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("application")))
- livebox->application = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("application")));
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("abi")))
- livebox->abi = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("abi")));
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
- livebox->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
-
- depth = xmlTextReaderDepth(reader);
- while ((ret = __next_child_element(reader, depth))) {
- node = xmlTextReaderConstName(reader);
- if (!node) {
- DBG("xmlTextReaderConstName value is NULL\n");
- return -1;
- }
-
- if (!strcmp(ASCII(node), "label")) {
- label_x *label = malloc(sizeof(label_x));
- if (label == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(label, '\0', sizeof(label_x));
- if (label) {
- LISTADD(livebox->label, label);
- ret =
- __ps_process_label(reader, label);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "icon")) {
- icon_x *icon = malloc(sizeof(icon_x));
- if (icon == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(icon, '\0', sizeof(icon_x));
- if (icon) {
- LISTADD(livebox->icon, icon);
- ret =
- __ps_process_icon(reader, icon);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "libexec")) {
- libexec_x *libexec = malloc(sizeof(libexec_x));
- if (libexec == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(libexec, '\0', sizeof(libexec_x));
- if (libexec) {
- LISTADD(livebox->libexec, libexec);
- ret =
- __ps_process_libexec(reader, libexec);
- } else
- return -1;
- }else if (!strcmp(ASCII(node), "control")) {
- control_x *control = malloc(sizeof(control_x));
- if (control == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(control, '\0', sizeof(control_x));
- if (control) {
- LISTADD(livebox->control, control);
- ret =
- __ps_process_control(reader, control);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "content")) {
- content_x *content= malloc(sizeof(content_x));
- if (content == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(content, '\0', sizeof(content_x));
- if (content) {
- LISTADD(livebox->content, content);
- ret =
- __ps_process_content(reader, content);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "group")) {
- group_x *group= malloc(sizeof(group_x));
- if (group == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(group, '\0', sizeof(group_x));
- if (group) {
- LISTADD(livebox->group, group);
- ret =
- __ps_process_group(reader, group);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "security")) {
- security_x *security= malloc(sizeof(security_x));
- if (security == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(security, '\0', sizeof(security_x));
- if (security) {
- LISTADD(livebox->security, security);
- ret =
- __ps_process_security(reader, security);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "size")) {
- size_x *size= malloc(sizeof(size_x));
- if (size == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(size, '\0', sizeof(size_x));
- if (size) {
- LISTADD(livebox->size, size);
- ret =
- __ps_process_size(reader, size);
- } else
- return -1;
- } else
- return -1;
- if (ret < 0) {
- DBG("Processing livebox failed\n");
- return ret;
- }
- }
-
- if (livebox->icon) {
- LISTHEAD(livebox->icon, tmp1);
- livebox->icon = tmp1;
- }
- if (livebox->label) {
- LISTHEAD(livebox->label, tmp2);
- livebox->label = tmp2;
- }
- if (livebox->libexec) {
- LISTHEAD(livebox->libexec, tmp3);
- livebox->libexec = tmp3;
- }
- if (livebox->control) {
- LISTHEAD(livebox->control, tmp4);
- livebox->control = tmp4;
- }
- if (livebox->content) {
- LISTHEAD(livebox->content, tmp5);
- livebox->content = tmp5;
- }
- if (livebox->group) {
- LISTHEAD(livebox->group, tmp6);
- livebox->group = tmp6;
- }
- if (livebox->security) {
- LISTHEAD(livebox->security, tmp7);
- livebox->security = tmp7;
- }
- if (livebox->size) {
- LISTHEAD(livebox->size, tmp8);
- livebox->size = tmp8;
- }
-
- return ret;
-}
-
-static int __ps_process_label(xmlTextReaderPtr reader, label_x *label)
-{
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
- label->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
- if (xmlTextReaderConstXmlLang(reader)) {
- label->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
- if (label->lang == NULL)
- label->lang = strdup(DEFAULT_LOCALE);
- } else {
- label->lang = strdup(DEFAULT_LOCALE);
- }
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- label->text = ASCII(xmlTextReaderValue(reader));
-
-/* DBG("lable name %s\n", label->name);
- DBG("lable lang %s\n", label->lang);
- DBG("lable text %s\n", label->text);
-*/
- return 0;
-
-}
-
-static int __ps_process_author(xmlTextReaderPtr reader, author_x *author)
-{
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("email")))
- author->email = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("email")));
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("href")))
- author->href = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("href")));
- if (xmlTextReaderConstXmlLang(reader)) {
- author->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
- if (author->lang == NULL)
- author->lang = strdup(DEFAULT_LOCALE);
- } else {
- author->lang = strdup(DEFAULT_LOCALE);
- }
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- author->text = ASCII(xmlTextReaderValue(reader));
- return 0;
-}
-
-static int __ps_process_description(xmlTextReaderPtr reader, description_x *description)
-{
- if (xmlTextReaderConstXmlLang(reader)) {
- description->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
- if (description->lang == NULL)
- description->lang = strdup(DEFAULT_LOCALE);
- } else {
- description->lang = strdup(DEFAULT_LOCALE);
- }
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- description->text = ASCII(xmlTextReaderValue(reader));
- return 0;
-}
-
-static int __ps_process_license(xmlTextReaderPtr reader, license_x *license)
-{
- if (xmlTextReaderConstXmlLang(reader)) {
- license->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
- if (license->lang == NULL)
- license->lang = strdup(DEFAULT_LOCALE);
- } else {
- license->lang = strdup(DEFAULT_LOCALE);
- }
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- license->text = ASCII(xmlTextReaderValue(reader));
- return 0;
-}
-
-static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability)
-{
- const xmlChar *node;
- int ret = -1;
- int depth = -1;
- resolution_x *tmp1 = NULL;
-
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")))
- capability->operationid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")));
-
- depth = xmlTextReaderDepth(reader);
- while ((ret = __next_child_element(reader, depth))) {
- node = xmlTextReaderConstName(reader);
- if (!node) {
- DBG("xmlTextReaderConstName value is NULL\n");
- return -1;
- }
-
- if (!strcmp(ASCII(node), "resolution")) {
- resolution_x *resolution = malloc(sizeof(resolution_x));
- if (resolution == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(resolution, '\0', sizeof(resolution_x));
- if (resolution) {
- LISTADD(capability->resolution, resolution);
- ret =
- __ps_process_resolution(reader, resolution);
- } else
- return -1;
- } else
- return -1;
- if (ret < 0) {
- DBG("Processing capability failed\n");
- return ret;
- }
- }
-
- if (capability->resolution) {
- LISTHEAD(capability->resolution, tmp1);
- capability->resolution = tmp1;
- }
-
- return ret;
-}
-
-static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol)
-{
- const xmlChar *node;
- int ret = -1;
- int depth = -1;
- capability_x *tmp1 = NULL;
-
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")))
- appcontrol->providerid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")));
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("category")))
- appcontrol->category = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("category")));
-
- depth = xmlTextReaderDepth(reader);
- while ((ret = __next_child_element(reader, depth))) {
- node = xmlTextReaderConstName(reader);
- if (!node) {
- DBG("xmlTextReaderConstName value is NULL\n");
- return -1;
- }
-
- if (!strcmp(ASCII(node), "capability")) {
- capability_x *capability = malloc(sizeof(capability_x));
- if (capability == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(capability, '\0', sizeof(capability_x));
- if (capability) {
- LISTADD(appcontrol->capability, capability);
- ret =
- __ps_process_capability(reader, capability);
- } else
- return -1;
- } else
- return -1;
- if (ret < 0) {
- DBG("Processing appcontrol failed\n");
- return ret;
- }
- }
-
- if (appcontrol->capability) {
- LISTHEAD(appcontrol->capability, tmp1);
- appcontrol->capability = tmp1;
- }
-
- return ret;
-}
-
-static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol)
-{
- const xmlChar *node;
- int ret = -1;
- int depth = -1;
- capability_x *tmp1 = NULL;
-
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")))
- datacontrol->providerid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")));
-
- depth = xmlTextReaderDepth(reader);
- while ((ret = __next_child_element(reader, depth))) {
- node = xmlTextReaderConstName(reader);
- if (!node) {
- DBG("xmlTextReaderConstName value is NULL\n");
- return -1;
- }
-
- if (!strcmp(ASCII(node), "capability")) {
- capability_x *capability = malloc(sizeof(capability_x));
- if (capability == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(capability, '\0', sizeof(capability_x));
- if (capability) {
- LISTADD(datacontrol->capability, capability);
- ret =
- __ps_process_capability(reader, capability);
- } else
- return -1;
- } else
- return -1;
- if (ret < 0) {
- DBG("Processing datacontrol failed\n");
- return ret;
- }
- }
-
- if (datacontrol->capability) {
- LISTHEAD(datacontrol->capability, tmp1);
- datacontrol->capability = tmp1;
- }
-
- return ret;
-}
-
-static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication)
-{
- const xmlChar *node;
- int ret = -1;
- int depth = -1;
- char *newappid = NULL;
- label_x *tmp1 = NULL;
- icon_x *tmp2 = NULL;
- appsvc_x *tmp3 = NULL;
- appcontrol_x *tmp4 = NULL;
- launchconditions_x *tmp5 = NULL;
- notification_x *tmp6 = NULL;
- datashare_x *tmp7 = NULL;
-
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
- uiapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
- if (uiapplication->appid == NULL) {
- DBG("appid cant be NULL\n");
- return -1;
- }
- } else {
- DBG("appid is mandatory\n");
- return -1;
- }
- /*check appid*/
- ret = __validate_appid(package, uiapplication->appid, &newappid);
- if (ret == -1) {
- DBG("appid is not proper\n");
- return -1;
- } else {
- if (newappid) {
- if (uiapplication->appid)
- free((void *)uiapplication->appid);
- uiapplication->appid = newappid;
- }
- }
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
- uiapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay"))) {
- uiapplication->nodisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay")));
- if (uiapplication->nodisplay == NULL)
- uiapplication->nodisplay = strdup("false");
- } else {
- uiapplication->nodisplay = strdup("false");
- }
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("multiple"))) {
- uiapplication->multiple = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("multiple")));
- if (uiapplication->multiple == NULL)
- uiapplication->multiple = strdup("false");
- } else {
- uiapplication->multiple = strdup("false");
- }
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
- uiapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("categories")))
- uiapplication->categories = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("categories")));
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")))
- uiapplication->extraid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")));
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage"))) {
- uiapplication->taskmanage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage")));
- if (uiapplication->taskmanage == NULL)
- uiapplication->taskmanage = strdup("true");
- } else {
- uiapplication->taskmanage = strdup("true");
- }
-
- depth = xmlTextReaderDepth(reader);
- while ((ret = __next_child_element(reader, depth))) {
- node = xmlTextReaderConstName(reader);
- if (!node) {
- DBG("xmlTextReaderConstName value is NULL\n");
- return -1;
- }
- if (!strcmp(ASCII(node), "label")) {
- label_x *label = malloc(sizeof(label_x));
- if (label == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(label, '\0', sizeof(label_x));
- if (label) {
- LISTADD(uiapplication->label, label);
- ret =
- __ps_process_label(reader, label);
-
- DBG("label processing\n");
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "icon")) {
- icon_x *icon = malloc(sizeof(icon_x));
- if (icon == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(icon, '\0', sizeof(icon_x));
- if (icon) {
- LISTADD(uiapplication->icon, icon);
- ret =
- __ps_process_icon(reader, icon);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "app-control")) {
- appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
- if (appcontrol == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(appcontrol, '\0', sizeof(appcontrol_x));
- if (appcontrol) {
- LISTADD(uiapplication->appcontrol, appcontrol);
- ret =
- __ps_process_appcontrol(reader, appcontrol);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "application-service")) {
- DBG("appsvc processing start\n");
-
- appsvc_x *appsvc = malloc(sizeof(appsvc_x));
- if (appsvc == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(appsvc, '\0', sizeof(appsvc_x));
- if (appsvc) {
- LISTADD(uiapplication->appsvc, appsvc);
- ret =
- __ps_process_appsvc(reader, appsvc);
-
- DBG("appsvc processing end\n");
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "data-share")) {
- datashare_x *datashare = malloc(sizeof(datashare_x));
- if (datashare == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(datashare, '\0', sizeof(datashare_x));
- if (datashare) {
- LISTADD(uiapplication->datashare, datashare);
- ret =
- __ps_process_datashare(reader, datashare);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "launch-conditions")) {
- launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
- if (launchconditions == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(launchconditions, '\0', sizeof(launchconditions_x));
- if (launchconditions) {
- LISTADD(uiapplication->launchconditions, launchconditions);
- ret =
- __ps_process_launchconditions(reader, launchconditions);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "notification")) {
- notification_x *notification = malloc(sizeof(notification_x));
- if (notification == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(notification, '\0', sizeof(notification_x));
- if (notification) {
- LISTADD(uiapplication->notification, notification);
- ret =
- __ps_process_notification(reader, notification);
- } else
- return -1;
- } else
- return -1;
- if (ret < 0) {
- DBG("Processing uiapplication failed\n");
- return ret;
- }
- }
-
- if (uiapplication->label) {
- LISTHEAD(uiapplication->label, tmp1);
- uiapplication->label = tmp1;
- }
- if (uiapplication->icon) {
- LISTHEAD(uiapplication->icon, tmp2);
- uiapplication->icon = tmp2;
- }
- if (uiapplication->appsvc) {
- LISTHEAD(uiapplication->appsvc, tmp3);
- uiapplication->appsvc = tmp3;
- }
- if (uiapplication->appcontrol) {
- LISTHEAD(uiapplication->appcontrol, tmp4);
- uiapplication->appcontrol = tmp4;
- }
- if (uiapplication->launchconditions) {
- LISTHEAD(uiapplication->launchconditions, tmp5);
- uiapplication->launchconditions = tmp5;
- }
- if (uiapplication->notification) {
- LISTHEAD(uiapplication->notification, tmp6);
- uiapplication->notification = tmp6;
- }
- if (uiapplication->datashare) {
- LISTHEAD(uiapplication->datashare, tmp7);
- uiapplication->datashare = tmp7;
- }
-
- return ret;
-}
-
-static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication)
-{
- const xmlChar *node;
- int ret = -1;
- int depth = -1;
- char *newappid = NULL;
- label_x *tmp1 = NULL;
- icon_x *tmp2 = NULL;
- appsvc_x *tmp3 = NULL;
- appcontrol_x *tmp4 = NULL;
- datacontrol_x *tmp5 = NULL;
- launchconditions_x *tmp6 = NULL;
- notification_x *tmp7 = NULL;
- datashare_x *tmp8 = NULL;
-
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
- serviceapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
- if (serviceapplication->appid == NULL) {
- DBG("appid cant be NULL\n");
- return -1;
- }
- } else {
- DBG("appid is mandatory\n");
- return -1;
- }
- /*check appid*/
- ret = __validate_appid(package, serviceapplication->appid, &newappid);
- if (ret == -1) {
- DBG("appid is not proper\n");
- return -1;
- } else {
- if (newappid) {
- if (serviceapplication->appid)
- free((void *)serviceapplication->appid);
- serviceapplication->appid = newappid;
- }
- }
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
- serviceapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
- serviceapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot"))) {
- serviceapplication->onboot = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot")));
- if (serviceapplication->onboot == NULL)
- serviceapplication->onboot = strdup("false");
- } else {
- serviceapplication->onboot = strdup("false");
- }
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart"))) {
- serviceapplication->autorestart = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart")));
- if (serviceapplication->autorestart == NULL)
- serviceapplication->autorestart = strdup("false");
- } else {
- serviceapplication->autorestart = strdup("false");
- }
-
- depth = xmlTextReaderDepth(reader);
- while ((ret = __next_child_element(reader, depth))) {
- node = xmlTextReaderConstName(reader);
- if (!node) {
- DBG("xmlTextReaderConstName value is NULL\n");
- return -1;
- }
-
- if (!strcmp(ASCII(node), "label")) {
- label_x *label = malloc(sizeof(label_x));
- if (label == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(label, '\0', sizeof(label_x));
- if (label) {
- LISTADD(serviceapplication->label, label);
- ret =
- __ps_process_label(reader, label);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "icon")) {
- icon_x *icon = malloc(sizeof(icon_x));
- if (icon == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(icon, '\0', sizeof(icon_x));
- if (icon) {
- LISTADD(serviceapplication->icon, icon);
- ret =
- __ps_process_icon(reader, icon);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "app-control")) {
- appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
- if (appcontrol == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(appcontrol, '\0', sizeof(appcontrol_x));
- if (appcontrol) {
- LISTADD(serviceapplication->appcontrol, appcontrol);
- ret =
- __ps_process_appcontrol(reader, appcontrol);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "application-service")) {
- appsvc_x *appsvc = malloc(sizeof(appsvc_x));
- if (appsvc == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(appsvc, '\0', sizeof(appsvc_x));
- if (appsvc) {
- LISTADD(serviceapplication->appsvc, appsvc);
- ret =
- __ps_process_appsvc(reader, appsvc);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "data-share")) {
- datashare_x *datashare = malloc(sizeof(datashare_x));
- if (datashare == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(datashare, '\0', sizeof(datashare_x));
- if (datashare) {
- LISTADD(serviceapplication->datashare, datashare);
- ret =
- __ps_process_datashare(reader, datashare);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "launch-conditions")) {
- launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
- if (launchconditions == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(launchconditions, '\0', sizeof(launchconditions_x));
- if (launchconditions) {
- LISTADD(serviceapplication->launchconditions, launchconditions);
- ret =
- __ps_process_launchconditions(reader, launchconditions);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "notification")) {
- notification_x *notification = malloc(sizeof(notification_x));
- if (notification == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(notification, '\0', sizeof(notification_x));
- if (notification) {
- LISTADD(serviceapplication->notification, notification);
- ret =
- __ps_process_notification(reader, notification);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "data-control")) {
- datacontrol_x *datacontrol = malloc(sizeof(datacontrol_x));
- if (datacontrol == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(datacontrol, '\0', sizeof(datacontrol_x));
- if (datacontrol) {
- LISTADD(serviceapplication->datacontrol, datacontrol);
- ret =
- __ps_process_datacontrol(reader, datacontrol);
- } else
- return -1;
- } else
- return -1;
- if (ret < 0) {
- DBG("Processing serviceapplication failed\n");
- return ret;
- }
- }
-
- if (serviceapplication->label) {
- LISTHEAD(serviceapplication->label, tmp1);
- serviceapplication->label = tmp1;
- }
- if (serviceapplication->icon) {
- LISTHEAD(serviceapplication->icon, tmp2);
- serviceapplication->icon = tmp2;
- }
- if (serviceapplication->appsvc) {
- LISTHEAD(serviceapplication->appsvc, tmp3);
- serviceapplication->appsvc = tmp3;
- }
- if (serviceapplication->appcontrol) {
- LISTHEAD(serviceapplication->appcontrol, tmp4);
- serviceapplication->appcontrol = tmp4;
- }
- if (serviceapplication->datacontrol) {
- LISTHEAD(serviceapplication->datacontrol, tmp5);
- serviceapplication->datacontrol = tmp5;
- }
- if (serviceapplication->launchconditions) {
- LISTHEAD(serviceapplication->launchconditions, tmp6);
- serviceapplication->launchconditions = tmp6;
- }
- if (serviceapplication->notification) {
- LISTHEAD(serviceapplication->notification, tmp7);
- serviceapplication->notification = tmp7;
- }
- if (serviceapplication->datashare) {
- LISTHEAD(serviceapplication->datashare, tmp8);
- serviceapplication->datashare = tmp8;
- }
-
- return ret;
-}
-
-static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile)
-{
- /*TODO: once policy is set*/
- return 0;
-}
-
-static int __ps_process_font(xmlTextReaderPtr reader, font_x *font)
-{
- /*TODO: once policy is set*/
- return 0;
-}
-
-static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme)
-{
- /*TODO: once policy is set*/
- return 0;
-}
-
-static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon)
-{
- /*TODO: once policy is set*/
- return 0;
-}
-
-static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime)
-{
- /*TODO: once policy is set*/
- return 0;
-}
-
-static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx)
-{
- DBG("__start_process\n");
- const xmlChar *node;
- int ret = -1;
- int depth = -1;
- label_x *tmp1 = NULL;
- author_x *tmp2 = NULL;
- description_x *tmp3 = NULL;
- license_x *tmp4 = NULL;
- uiapplication_x *tmp5 = NULL;
- serviceapplication_x *tmp6 = NULL;
- daemon_x *tmp7 = NULL;
- theme_x *tmp8 = NULL;
- font_x *tmp9 = NULL;
- ime_x *tmp10 = NULL;
- livebox_x *tmp11 = NULL;
- icon_x *tmp12 = NULL;
- compatibility_x *tmp13 = NULL;
- deviceprofile_x *tmp14 = NULL;
-
- depth = xmlTextReaderDepth(reader);
- while ((ret = __next_child_element(reader, depth))) {
- node = xmlTextReaderConstName(reader);
- if (!node) {
- DBG("xmlTextReaderConstName value is NULL\n");
- return -1;
- }
-
- if (!strcmp(ASCII(node), "label")) {
- label_x *label = malloc(sizeof(label_x));
- if (label == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(label, '\0', sizeof(label_x));
- if (label) {
- LISTADD(mfx->label, label);
- ret =
- __ps_process_label(reader, label);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "author")) {
- author_x *author = malloc(sizeof(author_x));
- if (author == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(author, '\0', sizeof(author_x));
- if (author) {
- LISTADD(mfx->author, author);
- ret =
- __ps_process_author(reader, author);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "description")) {
- description_x *description = malloc(sizeof(description_x));
- if (description == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(description, '\0', sizeof(description_x));
- if (description) {
- LISTADD(mfx->description, description);
- ret =
- __ps_process_description(reader, description);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "license")) {
- license_x *license = malloc(sizeof(license_x));
- if (license == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(license, '\0', sizeof(license_x));
- if (license) {
- LISTADD(mfx->license, license);
- ret =
- __ps_process_license(reader, license);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "ui-application")) {
- uiapplication_x *uiapplication = malloc(sizeof(uiapplication_x));
- if (uiapplication == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(uiapplication, '\0', sizeof(uiapplication_x));
- if (uiapplication) {
- LISTADD(mfx->uiapplication, uiapplication);
- ret =
- __ps_process_uiapplication(reader, uiapplication);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "service-application")) {
- serviceapplication_x *serviceapplication = malloc(sizeof(serviceapplication_x));
- if (serviceapplication == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(serviceapplication, '\0', sizeof(serviceapplication_x));
- if (serviceapplication) {
- LISTADD(mfx->serviceapplication, serviceapplication);
- ret =
- __ps_process_serviceapplication(reader, serviceapplication);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "daemon")) {
- daemon_x *daemon = malloc(sizeof(daemon_x));
- if (daemon == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(daemon, '\0', sizeof(daemon_x));
- if (daemon) {
- LISTADD(mfx->daemon, daemon);
- ret =
- __ps_process_daemon(reader, daemon);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "theme")) {
- theme_x *theme = malloc(sizeof(theme_x));
- if (theme == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(theme, '\0', sizeof(theme_x));
- if (theme) {
- LISTADD(mfx->theme, theme);
- ret =
- __ps_process_theme(reader, theme);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "font")) {
- font_x *font = malloc(sizeof(font_x));
- if (font == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(font, '\0', sizeof(font_x));
- if (font) {
- LISTADD(mfx->font, font);
- ret =
- __ps_process_font(reader, font);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "ime")) {
- ime_x *ime = malloc(sizeof(ime_x));
- if (ime == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(ime, '\0', sizeof(ime_x));
- if (ime) {
- LISTADD(mfx->ime, ime);
- ret =
- __ps_process_ime(reader, ime);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "livebox")) {
- livebox_x *livebox = malloc(sizeof(livebox_x));
- if (livebox == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(livebox, '\0', sizeof(livebox_x));
- if (livebox) {
- LISTADD(mfx->livebox, livebox);
- ret =
- __ps_process_livebox(reader, livebox);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "icon")) {
- icon_x *icon = malloc(sizeof(icon_x));
- if (icon == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(icon, '\0', sizeof(icon_x));
- if (icon) {
- LISTADD(mfx->icon, icon);
- ret =
- __ps_process_icon(reader, icon);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "device-profile")) {
- deviceprofile_x *deviceprofile = malloc(sizeof(deviceprofile_x));
- if (deviceprofile == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(deviceprofile, '\0', sizeof(deviceprofile_x));
- if (deviceprofile) {
- LISTADD(mfx->deviceprofile, deviceprofile);
- ret =
- __ps_process_deviceprofile(reader, deviceprofile);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "compatibility")) {
- compatibility_x *compatibility = malloc(sizeof(compatibility_x));
- if (compatibility == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(compatibility, '\0', sizeof(compatibility_x));
- if (compatibility) {
- LISTADD(mfx->compatibility, compatibility);
- ret =
- __ps_process_compatibility(reader, compatibility);
- } else
- return -1;
- } else if (!strcmp(ASCII(node), "shortcuts")) {
- return 0;
- } else
- return -1;
-
- if (ret < 0) {
- DBG("Processing manifest failed\n");
- return ret;
- }
- }
- if (mfx->label) {
- LISTHEAD(mfx->label, tmp1);
- mfx->label = tmp1;
- }
- if (mfx->author) {
- LISTHEAD(mfx->author, tmp2);
- mfx->author = tmp2;
- }
- if (mfx->description) {
- LISTHEAD(mfx->description, tmp3);
- mfx->description= tmp3;
- }
- if (mfx->license) {
- LISTHEAD(mfx->license, tmp4);
- mfx->license= tmp4;
- }
- if (mfx->uiapplication) {
- LISTHEAD(mfx->uiapplication, tmp5);
- mfx->uiapplication = tmp5;
- }
- if (mfx->serviceapplication) {
- LISTHEAD(mfx->serviceapplication, tmp6);
- mfx->serviceapplication = tmp6;
- }
- if (mfx->daemon) {
- LISTHEAD(mfx->daemon, tmp7);
- mfx->daemon= tmp7;
- }
- if (mfx->theme) {
- LISTHEAD(mfx->theme, tmp8);
- mfx->theme= tmp8;
- }
- if (mfx->font) {
- LISTHEAD(mfx->font, tmp9);
- mfx->font= tmp9;
- }
- if (mfx->ime) {
- LISTHEAD(mfx->ime, tmp10);
- mfx->ime= tmp10;
- }
- if (mfx->livebox) {
- LISTHEAD(mfx->livebox, tmp11);
- mfx->livebox= tmp11;
- }
- if (mfx->icon) {
- LISTHEAD(mfx->icon, tmp12);
- mfx->icon= tmp12;
- }
- if (mfx->compatibility) {
- LISTHEAD(mfx->compatibility, tmp13);
- mfx->compatibility= tmp13;
- }
- if (mfx->deviceprofile) {
- LISTHEAD(mfx->deviceprofile, tmp14);
- mfx->deviceprofile= tmp14;
- }
-
- return ret;
-}
-
-static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx)
-{
- const xmlChar *node;
- int ret = -1;
-
- if ((ret = __next_child_element(reader, -1))) {
- node = xmlTextReaderConstName(reader);
- if (!node) {
- DBG("xmlTextReaderConstName value is NULL\n");
- return -1;
- }
-
- if (!strcmp(ASCII(node), "manifest")) {
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")))
- mfx->ns = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")));
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("package"))) {
- mfx->package= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("package")));
- if (mfx->package == NULL) {
- DBG("package cant be NULL\n");
- return -1;
- }
- } else {
- DBG("package field is mandatory\n");
- return -1;
- }
- package = mfx->package;
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("version")))
- mfx->version= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("version")));
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")))
- mfx->installlocation = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")));
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
- mfx->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
- /*Assign default values. If required it will be overwritten in __add_preload_info()*/
- mfx->preload = strdup("False");
- mfx->removable = strdup("True");
- mfx->readonly = strdup("False");
-
- ret = __start_process(reader, mfx);
- } else {
- DBG("No Manifest element found\n");
- return -1;
- }
- }
- return ret;
-}
-
-#define DESKTOP_RW_PATH "/opt/share/applications/"
-#define DESKTOP_RO_PATH "/usr/share/applications/"
-
-static char* __convert_to_system_locale(const char *mlocale)
-{
- if (mlocale == NULL)
- return NULL;
- char *locale = NULL;
- locale = (char *)calloc(1, 6);
- if (!locale) {
- _LOGE("Malloc Failed\n");
- return NULL;
- }
-
- strncpy(locale, mlocale, 2);
- strncat(locale, "_", 1);
- locale[3] = toupper(mlocale[3]);
- locale[4] = toupper(mlocale[4]);
- return locale;
-}
-
-
-/* desktop shoud be generated automatically based on manifest */
-/* Currently removable, taskmanage, etc fields are not considerd. it will be decided soon.*/
-static int __ps_make_nativeapp_desktop(manifest_x * mfx)
-{
- FILE* file = NULL;
- int fd = 0;
- char filepath[PKG_STRING_LEN_MAX] = "";
- char buf[4096*2] = "";
- char buftemp[4096*2] = "";
-
- for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) {
-
- if(mfx->readonly && !strcasecmp(mfx->readonly, "True"))
- snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RO_PATH, mfx->uiapplication->appid);
- else
- snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, mfx->uiapplication->appid);
-
- /* skip if desktop exists
- if (access(filepath, R_OK) == 0)
- continue;
- */
-
- file = fopen(filepath, "w");
- if(file == NULL)
- {
- _LOGE("Can't open %s", filepath);
- return -1;
- }
-
- snprintf(buf, sizeof(buf), "[Desktop Entry]\n");
- fwrite(buf, 1, strlen(buf), file);
-
- for( ; mfx->uiapplication->label ; mfx->uiapplication->label = mfx->uiapplication->label->next) {
- if(!strcmp(mfx->uiapplication->label->lang, DEFAULT_LOCALE)) {
- snprintf(buf, sizeof(buf), "Name=%s\n", mfx->uiapplication->label->text);
- } else {
- snprintf(buf, sizeof(buf), "Name[%s]=%s\n",
- __convert_to_system_locale(mfx->uiapplication->label->lang),
- mfx->uiapplication->label->text);
- }
- fwrite(buf, 1, strlen(buf), file);
- }
-
- if(mfx->uiapplication->label && mfx->uiapplication->label->text) {
- snprintf(buf, sizeof(buf), "Name=%s\n", mfx->uiapplication->label->text);
- fwrite(buf, 1, strlen(buf), file);
- }
-/*
- else if(mfx->label && mfx->label->text) {
- snprintf(buf, sizeof(buf), "Name=%s\n", mfx->label->text);
- fwrite(buf, 1, strlen(buf), file);
- } else {
- snprintf(buf, sizeof(buf), "Name=%s\n", mfx->package);
- fwrite(buf, 1, strlen(buf), file);
- }
-*/
-
-
- snprintf(buf, sizeof(buf), "Type=Application\n");
- fwrite(buf, 1, strlen(buf), file);
-
- if(mfx->uiapplication->exec) {
- snprintf(buf, sizeof(buf), "Exec=%s\n", mfx->uiapplication->exec);
- fwrite(buf, 1, strlen(buf), file);
- }
-
- if(mfx->uiapplication->icon && mfx->uiapplication->icon->text) {
- snprintf(buf, sizeof(buf), "Icon=%s\n", mfx->uiapplication->icon->text);
- fwrite(buf, 1, strlen(buf), file);
- } else if(mfx->icon && mfx->icon->text) {
- snprintf(buf, sizeof(buf), "Icon=%s\n", mfx->icon->text);
- fwrite(buf, 1, strlen(buf), file);
- }
-
- if(mfx->version) {
- snprintf(buf, sizeof(buf), "Version=%s\n", mfx->version);
- fwrite(buf, 1, strlen(buf), file);
- }
-
- if(mfx->uiapplication->nodisplay) {
- snprintf(buf, sizeof(buf), "NoDisplay=%s\n", mfx->uiapplication->nodisplay);
- fwrite(buf, 1, strlen(buf), file);
- }
-
- if(mfx->uiapplication->categories) {
- snprintf(buf, sizeof(buf), "Categories=%s\n", mfx->uiapplication->categories);
- fwrite(buf, 1, strlen(buf), file);
- }
-
- if(mfx->uiapplication->taskmanage && !strcasecmp(mfx->uiapplication->taskmanage, "False")) {
- snprintf(buf, sizeof(buf), "X-TIZEN-TaskManage=False\n");
- fwrite(buf, 1, strlen(buf), file);
- }
-
- if(mfx->uiapplication->multiple && !strcasecmp(mfx->uiapplication->multiple, "True")) {
- snprintf(buf, sizeof(buf), "X-TIZEN-Multiple=True\n");
- fwrite(buf, 1, strlen(buf), file);
- }
-
- if(mfx->uiapplication->extraid) {
- snprintf(buf, sizeof(buf), "X-TIZEN-PackageID=%s\n", mfx->uiapplication->extraid);
- fwrite(buf, 1, strlen(buf), file);
- }
-
- if(mfx->removable && !strcasecmp(mfx->removable, "False")) {
- snprintf(buf, sizeof(buf), "X-TIZEN-Removable=False\n");
- fwrite(buf, 1, strlen(buf), file);
- }
-
- if(mfx->type) {
- snprintf(buf, sizeof(buf), "X-TIZEN-PackageType=%s\n", mfx->type);
- fwrite(buf, 1, strlen(buf), file);
- }
-
-// snprintf(buf, sizeof(buf), "X-TIZEN-PackageType=rpm\n");
-// fwrite(buf, 1, strlen(buf), file);
-
-
- if(mfx->uiapplication->appsvc) {
- snprintf(buf, sizeof(buf), "X-TIZEN-Svc=");
- DBG("buf[%s]\n", buf);
-
-
- uiapplication_x *up = mfx->uiapplication;
- appsvc_x *asvc = NULL;
- operation_x *op = NULL;
- mime_x *mi = NULL;
- uri_x *ui = NULL;
- int ret = -1;
- char query[PKG_STRING_LEN_MAX] = {'\0'};
- char *operation = NULL;
- char *mime = NULL;
- char *uri = NULL;
- int i = 0;
-
-
- asvc = up->appsvc;
- while(asvc != NULL)
- {
- op = asvc->operation;
- while(op != NULL)
- {
- if (op)
- operation = op->name;
- mi = asvc->mime;
-
- do
- {
- if (mi)
- mime = mi->name;
- ui = asvc->uri;
- do
- {
- if (ui)
- uri = ui->name;
-
- if(i++ > 0) {
- strncpy(buftemp, buf, sizeof(buftemp));
- snprintf(buf, sizeof(buf), "%s;", buftemp);
- }
-
- strncpy(buftemp, buf, sizeof(buftemp));
- snprintf(buf, sizeof(buf), "%s%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL");
- DBG("buf[%s]\n", buf);
-
- if (ui)
- ui = ui->next;
- uri = NULL;
- } while(ui != NULL);
- if (mi)
- mi = mi->next;
- mime = NULL;
- }while(mi != NULL);
- if (op)
- op = op->next;
- operation = NULL;
- }
- asvc = asvc->next;
- }
-
-
- fwrite(buf, 1, strlen(buf), file);
-
-// strncpy(buftemp, buf, sizeof(buftemp));
-// snprintf(buf, sizeof(buf), "%s\n", buftemp);
-// fwrite(buf, 1, strlen(buf), file);
- }
-
- fd = fileno(file);
- fdatasync(fd);
- fclose(file);
- }
-
- return 0;
-}
-
-static int __ps_remove_nativeapp_desktop(manifest_x *mfx)
-{
- char filepath[PKG_STRING_LEN_MAX] = "";
-
- for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) {
- snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, mfx->uiapplication->appid);
-
- remove(filepath);
- }
-
- return 0;
-}
-
-#define MANIFEST_RO_PREFIX "/usr/share/packages/"
-#define PRELOAD_PACKAGE_LIST "/usr/etc/package-manager/preload/preload_list.txt"
-static int __add_preload_info(manifest_x * mfx, const char *manifest)
-{
- FILE *fp = NULL;
- char buffer[1024] = { 0 };
- int state = 0;
-
- if(strstr(manifest, MANIFEST_RO_PREFIX)) {
- free(mfx->readonly);
- mfx->readonly = strdup("True");
-
- free(mfx->preload);
- mfx->preload = strdup("True");
-
- free(mfx->removable);
- mfx->removable = strdup("False");
-
- return 0;
- }
-
- fp = fopen(PRELOAD_PACKAGE_LIST, "r");
- if (fp == NULL) {
- _LOGE("no preload list\n");
- return -1;
- }
-
- while (fgets(buffer, sizeof(buffer), fp) != NULL) {
- if (buffer[0] == '#') {
- if(strcasestr(buffer, "RW_NORM"))
- state = 2;
- else if(strcasestr(buffer, "RW_RM"))
- state = 3;
- else
- continue;
- }
-
- __str_trim(buffer);
-
- if(!strcmp(mfx->package, buffer)) {
- free(mfx->preload);
- mfx->preload = strdup("True");
- if(state == 2){
- free(mfx->readonly);
- mfx->readonly = strdup("False");
- free(mfx->removable);
- mfx->removable = strdup("False");
- } else if(state == 3){
- free(mfx->readonly);
- mfx->readonly = strdup("False");
- free(mfx->removable);
- mfx->removable = strdup("True");
- }
- }
-
- memset(buffer, 0x00, sizeof(buffer));
- }
-
- if (fp != NULL)
- fclose(fp);
-
- return 0;
-}
-
-
-API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
-{
- if (mfx == NULL)
- return;
- if (mfx->ns) {
- free((void *)mfx->ns);
- mfx->ns = NULL;
- }
- if (mfx->package) {
- free((void *)mfx->package);
- mfx->package = NULL;
- }
- if (mfx->version) {
- free((void *)mfx->version);
- mfx->version = NULL;
- }
- if (mfx->installlocation) {
- free((void *)mfx->installlocation);
- mfx->installlocation = NULL;
- }
- if (mfx->preload) {
- free((void *)mfx->preload);
- mfx->preload = NULL;
- }
- if (mfx->readonly) {
- free((void *)mfx->readonly);
- mfx->readonly = NULL;
- }
- if (mfx->removable) {
- free((void *)mfx->removable);
- mfx->removable = NULL;
- }
- if (mfx->type) {
- free((void *)mfx->type);
- mfx->type = NULL;
- }
-
- /*Free Icon*/
- if (mfx->icon) {
- icon_x *icon = mfx->icon;
- icon_x *tmp = NULL;
- while(icon != NULL)
- {
- tmp = icon->next;
- __ps_free_icon(icon);
- icon = tmp;
- }
- }
- /*Free Label*/
- if (mfx->label) {
- label_x *label = mfx->label;
- label_x *tmp = NULL;
- while(label != NULL)
- {
- tmp = label->next;
- __ps_free_label(label);
- label = tmp;
- }
- }
- /*Free Author*/
- if (mfx->author) {
- author_x *author = mfx->author;
- author_x *tmp = NULL;
- while(author != NULL)
- {
- tmp = author->next;
- __ps_free_author(author);
- author = tmp;
- }
- }
- /*Free Description*/
- if (mfx->description) {
- description_x *description = mfx->description;
- description_x *tmp = NULL;
- while(description != NULL)
- {
- tmp = description->next;
- __ps_free_description(description);
- description = tmp;
- }
- }
- /*Free License*/
- if (mfx->license) {
- license_x *license = mfx->license;
- license_x *tmp = NULL;
- while(license != NULL)
- {
- tmp = license->next;
- __ps_free_license(license);
- license = tmp;
- }
- }
- /*Free UiApplication*/
- if (mfx->uiapplication) {
- uiapplication_x *uiapplication = mfx->uiapplication;
- uiapplication_x *tmp = NULL;
- while(uiapplication != NULL)
- {
- tmp = uiapplication->next;
- __ps_free_uiapplication(uiapplication);
- uiapplication = tmp;
- }
- }
- /*Free ServiceApplication*/
- if (mfx->serviceapplication) {
- serviceapplication_x *serviceapplication = mfx->serviceapplication;
- serviceapplication_x *tmp = NULL;
- while(serviceapplication != NULL)
- {
- tmp = serviceapplication->next;
- __ps_free_serviceapplication(serviceapplication);
- serviceapplication = tmp;
- }
- }
- /*Free Daemon*/
- if (mfx->daemon) {
- daemon_x *daemon = mfx->daemon;
- daemon_x *tmp = NULL;
- while(daemon != NULL)
- {
- tmp = daemon->next;
- __ps_free_daemon(daemon);
- daemon = tmp;
- }
- }
- /*Free Theme*/
- if (mfx->theme) {
- theme_x *theme = mfx->theme;
- theme_x *tmp = NULL;
- while(theme != NULL)
- {
- tmp = theme->next;
- __ps_free_theme(theme);
- theme = tmp;
- }
- }
- /*Free Font*/
- if (mfx->font) {
- font_x *font = mfx->font;
- font_x *tmp = NULL;
- while(font != NULL)
- {
- tmp = font->next;
- __ps_free_font(font);
- font = tmp;
- }
- }
- /*Free Ime*/
- if (mfx->ime) {
- ime_x *ime = mfx->ime;
- ime_x *tmp = NULL;
- while(ime != NULL)
- {
- tmp = ime->next;
- __ps_free_ime(ime);
- ime = tmp;
- }
- }
- /*Free Livebox*/
- if (mfx->livebox) {
- livebox_x *livebox = mfx->livebox;
- livebox_x *tmp = NULL;
- while(livebox != NULL)
- {
- tmp = livebox->next;
- __ps_free_livebox(livebox);
- livebox = tmp;
- }
- }
- /*Free Compatibility*/
- if (mfx->compatibility) {
- compatibility_x *compatibility = mfx->compatibility;
- compatibility_x *tmp = NULL;
- while(compatibility != NULL)
- {
- tmp = compatibility->next;
- __ps_free_compatibility(compatibility);
- compatibility = tmp;
- }
- }
- /*Free DeviceProfile*/
- if (mfx->deviceprofile) {
- deviceprofile_x *deviceprofile = mfx->deviceprofile;
- deviceprofile_x *tmp = NULL;
- while(deviceprofile != NULL)
- {
- tmp = deviceprofile->next;
- __ps_free_deviceprofile(deviceprofile);
- deviceprofile = tmp;
- }
- }
- free((void*)mfx);
- mfx = NULL;
- return;
-}
-
-manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest)
-{
- DBG("parsing start\n");
- xmlTextReaderPtr reader;
- manifest_x *mfx = NULL;
-
- reader = xmlReaderForFile(manifest, NULL, 0);
- if (reader) {
- mfx = malloc(sizeof(manifest_x));
- if (mfx) {
- memset(mfx, '\0', sizeof(manifest_x));
- if (__process_manifest(reader, mfx) < 0) {
- DBG("Parsing Failed\n");
- pkgmgr_parser_free_manifest_xml(mfx);
- mfx = NULL;
- } else
- DBG("Parsing Success\n");
- } else {
- DBG("Memory allocation error\n");
- }
- xmlFreeTextReader(reader);
- } else {
- DBG("Unable to create xml reader\n");
- }
- return mfx;
-}
-
-/* These APIs are intended to call parser directly */
-
-API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
-{
- char *temp[] = {"shortcuts", NULL};
- if (manifest == NULL) {
- DBG("argument supplied is NULL\n");
- return -1;
- }
- DBG("parsing manifest for installation: %s\n", manifest);
- manifest_x *mfx = NULL;
- int ret = -1;
- xmlInitParser();
- mfx = pkgmgr_parser_process_manifest_xml(manifest);
- DBG("Parsing Finished\n");
- if (mfx) {
- __streamFile(manifest, ACTION_INSTALL, temp, mfx->package);
- __add_preload_info(mfx, manifest);
- DBG("Added preload infomation\n");
- ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
- if (ret == -1)
- DBG("DB Insert failed\n");
- else
- DBG("DB Insert Success\n");
-
- ret = __ps_make_nativeapp_desktop(mfx);
- if (ret == -1)
- DBG("Creating desktop file failed\n");
- else
- DBG("Creating desktop file Success\n");
- } else
- DBG("mfx is NULL\n");
-
- pkgmgr_parser_free_manifest_xml(mfx);
- DBG("Free Done\n");
- xmlCleanupParser();
-
- return 0;
-}
-
-API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
-{
- char *temp[] = {"shortcuts", NULL};
- if (manifest == NULL) {
- DBG("argument supplied is NULL\n");
- return -1;
- }
- DBG("parsing manifest for upgradation: %s\n", manifest);
- manifest_x *mfx = NULL;
- int ret = -1;
- xmlInitParser();
- mfx = pkgmgr_parser_process_manifest_xml(manifest);
- DBG("Parsing Finished\n");
-
- if (mfx) {
- __streamFile(manifest, ACTION_UPGRADE, temp, mfx->package);
- __add_preload_info(mfx, manifest);
- DBG("Added preload infomation\n");
- ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
- if (ret == -1)
- DBG("DB Update failed\n");
- else
- DBG("DB Update Success\n");
-
- ret = __ps_make_nativeapp_desktop(mfx);
- if (ret == -1)
- DBG("Creating desktop file failed\n");
- else
- DBG("Creating desktop file Success\n");
- }
- pkgmgr_parser_free_manifest_xml(mfx);
- DBG("Free Done\n");
- xmlCleanupParser();
-
- return 0;
-}
-
-API int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[])
-{
- char *temp[] = {"shortcuts", NULL};
- if (manifest == NULL) {
- DBG("argument supplied is NULL\n");
- return -1;
- }
- DBG("parsing manifest for uninstallation: %s\n", manifest);
- manifest_x *mfx = NULL;
- int ret = -1;
- xmlInitParser();
- mfx = pkgmgr_parser_process_manifest_xml(manifest);
- DBG("Parsing Finished\n");
-
- if (mfx) {
- __streamFile(manifest, ACTION_UNINSTALL, temp, mfx->package);
- __add_preload_info(mfx, manifest);
- DBG("Added preload infomation\n");
-
- ret = pkgmgr_parser_delete_manifest_info_from_db(mfx);
- if (ret == -1)
- DBG("DB Delete failed\n");
- else
- DBG("DB Delete Success\n");
-
- ret = __ps_remove_nativeapp_desktop(mfx);
- if (ret == -1)
- DBG("Removing desktop file failed\n");
- else
- DBG("Removing desktop file Success\n");
- }
- pkgmgr_parser_free_manifest_xml(mfx);
- DBG("Free Done\n");
- xmlCleanupParser();
-
- return 0;
-}
-
-API char *pkgmgr_parser_get_manifest_file(const char *pkgname)
-{
- return __pkgname_to_manifest(pkgname);
-}
-
-API int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgname)
-{
- return __ps_run_parser(docPtr, tag, ACTION_INSTALL, pkgname);
-}
-
-API int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgname)
-{
- return __ps_run_parser(docPtr, tag, ACTION_UPGRADE, pkgname);
-}
-
-API int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgname)
-{
- return __ps_run_parser(docPtr, tag, ACTION_UNINSTALL, pkgname);
-}
-
-#define SCHEMA_FILE "/usr/etc/package-manager/preload/manifest.xsd"
-#if 1
-API int pkgmgr_parser_check_manifest_validation(const char *manifest)
-{
- if (manifest == NULL) {
- DBGE("manifest file is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- int ret = -1;
- xmlSchemaParserCtxtPtr ctx;
- xmlSchemaValidCtxtPtr vctx;
- xmlSchemaPtr xschema;
- ctx = xmlSchemaNewParserCtxt(SCHEMA_FILE);
- if (ctx == NULL) {
- DBGE("xmlSchemaNewParserCtxt() Failed\n");
- return PKGMGR_R_ERROR;
- }
- xschema = xmlSchemaParse(ctx);
- if (xschema == NULL) {
- DBGE("xmlSchemaParse() Failed\n");
- return PKGMGR_R_ERROR;
- }
- vctx = xmlSchemaNewValidCtxt(xschema);
- if (vctx == NULL) {
- DBGE("xmlSchemaNewValidCtxt() Failed\n");
- return PKGMGR_R_ERROR;
- }
- xmlSchemaSetValidErrors(vctx, (xmlSchemaValidityErrorFunc) fprintf, (xmlSchemaValidityWarningFunc) fprintf, stderr);
- ret = xmlSchemaValidateFile(vctx, manifest, 0);
- if (ret == -1) {
- DBGE("xmlSchemaValidateFile() failed\n");
- return PKGMGR_R_ERROR;
- } else if (ret == 0) {
- DBGE("Manifest is Valid\n");
- return PKGMGR_R_OK;
- } else {
- DBGE("Manifest Validation Failed with error code %d\n", ret);
- return PKGMGR_R_ERROR;
- }
- return PKGMGR_R_OK;
-}
-
-#else
-API int pkgmgr_parser_check_manifest_validation(const char *manifest)
-{
- int err = 0;
- int status = 0;
- pid_t pid;
-
- pid = fork();
-
- switch (pid) {
- case -1:
- DBGE("fork failed\n");
- return -1;
- case 0:
- /* child */
- {
- int dev_null_fd = open ("/dev/null", O_RDWR);
- if (dev_null_fd >= 0)
- {
- dup2 (dev_null_fd, 0);/*stdin*/
- dup2 (dev_null_fd, 1);/*stdout*/
- dup2 (dev_null_fd, 2);/*stderr*/
- }
-
- if (execl("/usr/bin/xmllint", "xmllint", manifest, "--schema",
- SCHEMA_FILE, NULL) < 0) {
- DBGE("execl error\n");
- }
-
- _exit(100);
- }
- default:
- /* parent */
- break;
- }
-
- while ((err = waitpid(pid, &status, WNOHANG)) != pid) {
- if (err < 0) {
- if (errno == EINTR)
- continue;
- DBGE("waitpid failed\n");
- return -1;
- }
- }
-
-
- if(WIFEXITED(status) && !WEXITSTATUS(status))
- return 0;
- else
- return -1;
-}
-#endif
+++ /dev/null
-/*
- * slp-pkgmgr
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
- * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef __PKGMGR_PARSER_H__
-#define __PKGMGR_PARSER_H__
-
-/**
- * @file pkgmgr_parser.h
- * @author Sewook Park <sewook7.park@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
- * @version 0.1
- * @brief This file declares API of pkgmgr_parser
- */
-
-#include <libxml/xmlreader.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-#define DEFAULT_LOCALE "No Locale"
-/**
- * List definitions.
- * All lists are doubly-linked, the last element is stored to list pointer,
- * which means that lists must be looped using the prev pointer, or by
- * calling LISTHEAD first to go to start in order to use the next pointer.
- */
-#define LISTADD(list, node) \
- do { \
- (node)->prev = (list); \
- if (list) (node)->next = (list)->next; \
- else (node)->next = NULL; \
- if (list) (list)->next = (node); \
- (list) = (node); \
- } while (0);
-
-#define NODEADD(node1, node2) \
- do { \
- (node2)->prev = (node1); \
- (node2)->next = (node1)->next; \
- if ((node1)->next) (node1)->next->prev = (node2); \
- (node1)->next = (node2); \
- } while (0);
-
-#define LISTCAT(list, first, last) \
- if ((first) && (last)) { \
- (first)->prev = (list); \
- (list) = (last); \
- }
-
-#define LISTDEL(list, node) \
- do { \
- if ((node)->prev) (node)->prev->next = (node)->next; \
- if ((node)->next) (node)->next->prev = (node)->prev; \
- if (!((node)->prev) && !((node)->next)) (list) = NULL; \
- } while (0);
-
-#define LISTHEAD(list, node) \
- for ((node) = (list); (node)->prev; (node) = (node)->prev);
-#define LISTTAIL(list, node) \
- for ((node) = (list); (node)->next; (node) = (node)->next);
-
-typedef struct icon_x {
- const char *name;
- const char *text;
- const char *lang;
- const char *section;
- const char *size;
- struct icon_x *prev;
- struct icon_x *next;
-} icon_x;
-
-typedef struct allowed_x {
- const char *name;
- const char *text;
- struct allowed_x *prev;
- struct allowed_x *next;
-} allowed_x;
-
-typedef struct request_x {
- const char *text;
- struct request_x *prev;
- struct request_x *next;
-} request_x;
-
-typedef struct define_x {
- const char *path;
- struct allowed_x *allowed;
- struct request_x *request;
- struct define_x *prev;
- struct define_x *next;
-} define_x;
-
-typedef struct timeout_x {
- const char *text;
- struct timeout_x *prev;
- struct timeout_x *next;
-} timeout_x;
-
-typedef struct network_x {
- const char *text;
- struct network_x *prev;
- struct network_x *next;
-} network_x;
-
-typedef struct period_x {
- const char *text;
- struct period_x *prev;
- struct period_x *next;
-} period_x;
-
-typedef struct autolaunch_x {
- const char *text;
- struct autolaunch_x *prev;
- struct autolaunch_x *next;
-} autolaunch_x;
-
-typedef struct file_x {
- const char *text;
- struct file_x *prev;
- struct file_x *next;
-} file_x;
-
-typedef struct size_x {
- const char *text;
- struct size_x *prev;
- struct size_x *next;
-} size_x;
-
-
-typedef struct datashare_x {
- struct define_x *define;
- struct request_x *request;
- struct datashare_x *prev;
- struct datashare_x *next;
-} datashare_x;
-
-typedef struct description_x {
- const char *name;
- const char *text;
- const char *lang;
- struct description_x *prev;
- struct description_x *next;
-} description_x;
-
-typedef struct registry_x {
- const char *name;
- const char *text;
- struct registry_x *prev;
- struct registry_x *next;
-} registry_x;
-
-typedef struct database_x {
- const char *name;
- const char *text;
- struct database_x *prev;
- struct database_x *next;
-} database_x;
-
-typedef struct layout_x {
- const char *name;
- const char *text;
- struct layout_x *prev;
- struct layout_x *next;
-} layout_x;
-
-typedef struct label_x {
- const char *name;
- const char *text;
- const char *lang;
- struct label_x *prev;
- struct label_x *next;
-} label_x;
-
-typedef struct author_x {
- const char *email;
- const char *href;
- const char *text;
- const char *lang;
- struct author_x *prev;
- struct author_x *next;
-} author_x;
-
-typedef struct license_x {
- const char *text;
- const char *lang;
- struct license_x *prev;
- struct license_x *next;
-} license_x;
-
-typedef struct operation_x {
- const char *name;
- const char *text;
- struct operation_x *prev;
- struct operation_x *next;
-} operation_x;
-
-typedef struct uri_x {
- const char *name;
- const char *text;
- struct uri_x *prev;
- struct uri_x *next;
-} uri_x;
-
-typedef struct mime_x {
- const char *name;
- const char *text;
- struct mime_x *prev;
- struct mime_x *next;
-} mime_x;
-
-typedef struct condition_x {
- const char *name;
- const char *text;
- struct condition_x *prev;
- struct condition_x *next;
-} condition_x;
-
-typedef struct notification_x {
- const char *name;
- const char *text;
- struct notification_x *prev;
- struct notification_x *next;
-} notification_x;
-
-typedef struct appsvc_x {
- const char *text;
- struct operation_x *operation;
- struct uri_x *uri;
- struct mime_x *mime;
- struct appsvc_x *prev;
- struct appsvc_x *next;
-} appsvc_x;
-
-typedef struct launchconditions_x {
- const char *text;
- struct condition_x *condition;
- struct launchconditions_x *prev;
- struct launchconditions_x *next;
-} launchconditions_x;
-
-
-typedef struct compatibility_x {
- const char *name;
- const char *text;
- struct compatibility_x *prev;
- struct compatibility_x *next;
-}compatibility_x;
-
-typedef struct deviceprofile_x {
- const char *name;
- const char *text;
- struct deviceprofile_x *prev;
- struct deviceprofile_x *next;
-}deviceprofile_x;
-
-typedef struct resolution_x {
- const char *mimetype;
- const char *urischeme;
- struct resolution_x *prev;
- struct resolution_x *next;
-} resolution_x;
-
-typedef struct capability_x {
- const char *operationid;
- const char *access;
- struct resolution_x *resolution;
- struct capability_x *prev;
- struct capability_x *next;
-} capability_x;
-
-typedef struct appcontrol_x {
- const char *providerid;
- const char *category;
- struct capability_x *capability;
- struct appcontrol_x *prev;
- struct appcontrol_x *next;
-} appcontrol_x;
-
-typedef struct datacontrol_x {
- const char *providerid;
- struct capability_x *capability;
- struct datacontrol_x *prev;
- struct datacontrol_x *next;
-} datacontrol_x;
-
-typedef struct uiapplication_x {
- const char *appid;
- const char *exec;
- const char *nodisplay;
- const char *multiple;
- const char *taskmanage;
- const char *type;
- const char *categories;
- const char *extraid;
- struct label_x *label;
- struct icon_x *icon;
- struct appsvc_x *appsvc;
- struct appcontrol_x *appcontrol;
- struct launchconditions_x *launchconditions;
- struct notification_x *notification;
- struct datashare_x *datashare;
- struct uiapplication_x *prev;
- struct uiapplication_x *next;
-} uiapplication_x;
-
-typedef struct serviceapplication_x {
- const char *appid;
- const char *exec;
- const char *onboot;
- const char *autorestart;
- const char *type;
- struct label_x *label;
- struct icon_x *icon;
- struct appsvc_x *appsvc;
- struct appcontrol_x *appcontrol;
- struct datacontrol_x *datacontrol;
- struct launchconditions_x *launchconditions;
- struct notification_x *notification;
- struct datashare_x *datashare;
- struct serviceapplication_x *prev;
- struct serviceapplication_x *next;
-} serviceapplication_x;
-
-typedef struct daemon_x {
- const char *name;
- const char *text;
- struct daemon_x *prev;
- struct daemon_x *next;
-} daemon_x;
-
-typedef struct theme_x {
- const char *name;
- const char *text;
- struct theme_x *prev;
- struct theme_x *next;
-} theme_x;
-
-typedef struct font_x {
- const char *name;
- const char *text;
- struct font_x *prev;
- struct font_x *next;
-} font_x;
-
-typedef struct ime_x {
- const char *name;
- const char *text;
- struct ime_x *prev;
- struct ime_x *next;
-} ime_x;
-
-typedef struct category_x{
- const char *name;
- struct category_x *prev;
- struct category_x *next;
-} category_x;
-
-typedef struct cluster_x{
- const char *name;
- struct category_x *category;
- struct cluster_x *prev;
- struct cluster_x *next;
-} cluster_x;
-
-typedef struct group_x{
- struct cluster_x *cluster;
- struct group_x *prev;
- struct group_x *next;
-} group_x;
-
-typedef struct grp_x{
- const char *text;
- struct grp_x *prev;
- struct grp_x *next;
-} grp_x;
-
-typedef struct security_x{
- const char *isolate;
- struct security_x *prev;
- struct security_x *next;
-} security_x;
-
-typedef struct libexec_x{
- const char *text;
- struct libexec_x *prev;
- struct libexec_x *next;
-} libexec_x;
-
-typedef struct lbox_x{
- const char *type;
- struct size_x *size;
- struct lbox_x *prev;
- struct lbox_x *next;
-} lbox_x;
-
-typedef struct pd_x {
- const char *type;
- const char *language;
- struct file_x *file;
- struct grp_x *grp;
- struct size_x *size;
- struct pd_x *prev;
- struct pd_x *next;
-} pd_x;
-
-typedef struct control_x {
- struct timeout_x *timeout;
- struct period_x *period;
- struct network_x *network;
- struct autolaunch_x *autolaunch;
- struct control_x *prev;
- struct control_x *next;
-} control_x;
-
-typedef struct content_x {
- struct lbox_x *lbox;
- struct pd_x *pd;
- struct content_x *prev;
- struct content_x *next;
-} content_x;
-
-
-typedef struct livebox_x {
- const char *application;
- const char *abi;
- const char *type;
- struct icon_x *icon;
- struct label_x *label;
- struct libexec_x *libexec;
- struct control_x *control;
- struct content_x *content;
- struct group_x *group;
- struct security_x *security;
- struct size_x *size;
- struct livebox_x *prev;
- struct livebox_x *next;
-} livebox_x;
-
-typedef struct manifest_x {
- const char *package;
- const char *version;
- const char *installlocation;;
- const char *ns;
- const char *removable;
- const char *preload;
- const char *readonly;
- const char *type;
- struct icon_x *icon;
- struct label_x *label;
- struct author_x *author;
- struct description_x *description;
- struct license_x *license;
- struct uiapplication_x *uiapplication;
- struct serviceapplication_x *serviceapplication;
- struct daemon_x *daemon;
- struct theme_x *theme;
- struct font_x *font;
- struct ime_x *ime;
- struct livebox_x *livebox;
- struct compatibility_x *compatibility;
- struct deviceprofile_x *deviceprofile;
-} manifest_x;
-
-/* These APIs are for installer backends */
-
-/**
- * @brief routine to get the manifest file from pkgname.
- * @param[in] pkgname, the application package name
- * @return: on sucess it returns the manifest file path, on failure it returns NULL
- */
-char *pkgmgr_parser_get_manifest_file(const char *pkgname);
-
-/**
- * @brief routine to parse the manifest file after installation
- * @param[in] manifest, the application manifest file path
- * @return: on sucess it returns 0, on failure it returns -1
- */
-int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[]);
-
-/**
- * @brief routine to parse the manifest file after upgradation
- * @param[in] manifest, the application manifest file path
- * @return: on sucess it returns 0, on failure it returns -1
- */
-int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[]);
-
-/**
- * @brief routine to parse the manifest file after uninstallation
- * @param[in] manifest, the application manifest file path
- * @return: on sucess it returns 0, on failure it returns -1
- */
-int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[]);
-
-/**
- * @check validation for manifest
- * @param[in] manifest, the application manifest file path
- * @return: on sucess it returns 0, on failure it returns -1
- */
-int pkgmgr_parser_check_manifest_validation(const char *manifest);
-
-/**
- * @brief routine to free the manifest pointer obtained after parsing
- * @param[in] mfx, the pointer to manifest structure
- */
-void pkgmgr_parser_free_manifest_xml(manifest_x *mfx);
-manifest_x *pkgmr_parser_process_manifest_xml(const char *manifest);
-
-/* These APIs are intended to call parser directly */
-typedef int (*ps_iter_fn) (const char *tag, int type, void *userdata);
-
-int pkgmgr_parser_has_parser(const char *tag, int *type);
-int pkgmgr_parser_get_list(ps_iter_fn iter_fn, void *data);
-int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgname);
-int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgname);
-int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgname);
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* __PKGMGR_PARSER_H__ */
+++ /dev/null
-/*
- * slp-pkgmgr
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
- * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <db-util.h>
-#include <glib.h>
-#include "pkgmgr_parser_internal.h"
-#include "pkgmgr_parser_db.h"
-#include "pkgmgr-api.h"
-
-#define PKGMGR_PARSER_DB_FILE "/opt/dbspace/.pkgmgr_parser.db"
-#define MAX_QUERY_LEN 4096
-sqlite3 *pkgmgr_parser_db;
-GList *pkglocale = NULL;
-GList *applocale = NULL;
-char *prev = NULL;
-
-#define QUERY_CREATE_TABLE_PACKAGE_INFO "create table if not exists package_info " \
- "(package text primary key not null, " \
- "package_type text DEFAULT 'rpm', " \
- "package_version text, " \
- "install_location text, " \
- "package_removable text DEFAULT 'true', " \
- "package_preload text DEFAULT 'false', " \
- "package_readonly text DEFAULT 'false', " \
- "author_name text, " \
- "author_email text, " \
- "author_href text)"
-
-#define QUERY_CREATE_TABLE_PACKAGE_LOCALIZED_INFO "create table if not exists package_localized_info " \
- "(package text not null, " \
- "package_locale text DEFAULT 'No Locale', " \
- "package_label text, " \
- "package_icon text, " \
- "package_description text, " \
- "package_license text, " \
- "package_author, " \
- "PRIMARY KEY(package, package_locale), " \
- "FOREIGN KEY(package) " \
- "REFERENCES package_info(package) " \
- "ON DELETE CASCADE)"
-
-#define QUERY_CREATE_TABLE_PACKAGE_APP_INFO "create table if not exists package_app_info " \
- "(app_id text primary key not null, " \
- "app_component text, " \
- "app_exec text, " \
- "app_nodisplay text DEFAULT 'false', " \
- "app_type text, " \
- "app_onboot text DEFAULT 'false', " \
- "app_multiple text DEFAULT 'false', " \
- "app_autorestart text DEFAULT 'false', " \
- "app_taskmanage text DEFAULT 'false', " \
- "package text not null, " \
- "FOREIGN KEY(package) " \
- "REFERENCES package_info(package) " \
- "ON DELETE CASCADE)"
-
-#define QUERY_CREATE_TABLE_PACKAGE_APP_LOCALIZED_INFO "create table if not exists package_app_localized_info " \
- "(app_id text not null, " \
- "app_locale text DEFAULT 'No Locale', " \
- "app_label text, " \
- "app_icon text, " \
- "PRIMARY KEY(app_id,app_locale) " \
- "FOREIGN KEY(app_id) " \
- "REFERENCES package_app_info(app_id) " \
- "ON DELETE CASCADE)"
-
-#define QUERY_CREATE_TABLE_PACKAGE_APP_APP_SVC "create table if not exists package_app_app_svc " \
- "(app_id text not null, " \
- "operation text not null, " \
- "uri_scheme text, " \
- "mime_type text, " \
- "PRIMARY KEY(app_id,operation,uri_scheme,mime_type) " \
- "FOREIGN KEY(app_id) " \
- "REFERENCES package_app_info(app_id) " \
- "ON DELETE CASCADE)"
-
-#define QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_ALLOWED "create table if not exists package_app_share_allowed " \
- "(app_id text not null, " \
- "data_share_path text not null, " \
- "data_share_allowed text not null, " \
- "PRIMARY KEY(app_id,data_share_path,data_share_allowed) " \
- "FOREIGN KEY(app_id) " \
- "REFERENCES package_app_info(app_id) " \
- "ON DELETE CASCADE)"
-
-#define QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_REQUEST "create table if not exists package_app_share_request " \
- "(app_id text not null, " \
- "data_share_request text not null, " \
- "PRIMARY KEY(app_id,data_share_request) " \
- "FOREIGN KEY(app_id) " \
- "REFERENCES package_app_info(app_id) " \
- "ON DELETE CASCADE)"
-
-static int __insert_uiapplication_info(manifest_x *mfx);
-static int __insert_serviceapplication_info(manifest_x *mfx);
-static int __insert_uiapplication_appsvc_info(manifest_x *mfx);
-static int __insert_serviceapplication_appsvc_info(manifest_x *mfx);
-static int __insert_uiapplication_share_allowed_info(manifest_x *mfx);
-static int __insert_serviceapplication_share_allowed_info(manifest_x *mfx);
-static int __insert_uiapplication_share_request_info(manifest_x *mfx);
-static int __insert_serviceapplication_share_request_info(manifest_x *mfx);
-static void __insert_serviceapplication_locale_info(gpointer data, gpointer userdata);
-static void __insert_uiapplication_locale_info(gpointer data, gpointer userdata);
-static void __insert_pkglocale_info(gpointer data, gpointer userdata);
-static int __insert_manifest_info_in_db(manifest_x *mfx);
-static int __update_manifest_info_in_db(manifest_x *mfx);
-static int __delete_manifest_info_from_db(manifest_x *mfx);
-static int __initialize_package_info_db();
-static int __initialize_package_localized_info_db();
-static int __initialize_package_app_info_db();
-static int __initialize_package_app_localized_info_db();
-static int __initialize_package_app_app_svc_db();
-static int __initialize_package_app_share_allowed_db();
-static int __initialize_package_app_share_request_db();
-static int __exec_query(char *query);
-static void __extract_data(gpointer data, label_x *lbl, license_x *lcn, icon_x *icn, description_x *dcn, author_x *ath,
- char **label, char **license, char **icon, char **description, char **author);
-
-static gint __comparefunc(gconstpointer a, gconstpointer b, gpointer userdata);
-static void __trimfunc1(gpointer data, gpointer userdata);
-static void __trimfunc2(gpointer data, gpointer userdata);
-static GList *__create_locale_list(GList *locale, label_x *lbl, license_x *lcn, icon_x *icn, description_x *dcn, author_x *ath);
-
-static int __initialize_package_info_db()
-{
- char *error_message = NULL;
- if (SQLITE_OK !=
- sqlite3_exec(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_INFO,
- NULL, NULL, &error_message)) {
- DBG("Don't execute query = %s error message = %s\n",
- QUERY_CREATE_TABLE_PACKAGE_INFO, error_message);
- sqlite3_free(error_message);
- return -1;
- }
- sqlite3_free(error_message);
- return 0;
-}
-
-static int __initialize_package_localized_info_db()
-{
- char *error_message = NULL;
- if (SQLITE_OK !=
- sqlite3_exec(pkgmgr_parser_db,
- QUERY_CREATE_TABLE_PACKAGE_LOCALIZED_INFO, NULL, NULL,
- &error_message)) {
- DBG("Don't execute query = %s error message = %s\n",
- QUERY_CREATE_TABLE_PACKAGE_LOCALIZED_INFO,
- error_message);
- sqlite3_free(error_message);
- return -1;
- }
- sqlite3_free(error_message);
- return 0;
-}
-
-static int __initialize_package_app_info_db()
-{
- char *error_message = NULL;
- if (SQLITE_OK !=
- sqlite3_exec(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_INFO,
- NULL, NULL, &error_message)) {
- DBG("Don't execute query = %s error message = %s\n",
- QUERY_CREATE_TABLE_PACKAGE_APP_INFO, error_message);
- sqlite3_free(error_message);
- return -1;
- }
- sqlite3_free(error_message);
- return 0;
-}
-
-static int __initialize_package_app_localized_info_db()
-{
- char *error_message = NULL;
- if (SQLITE_OK !=
- sqlite3_exec(pkgmgr_parser_db,
- QUERY_CREATE_TABLE_PACKAGE_APP_LOCALIZED_INFO, NULL,
- NULL, &error_message)) {
- DBG("Don't execute query = %s error message = %s\n",
- QUERY_CREATE_TABLE_PACKAGE_APP_LOCALIZED_INFO,
- error_message);
- sqlite3_free(error_message);
- return -1;
- }
- sqlite3_free(error_message);
- return 0;
-}
-
-static int __initialize_package_app_app_svc_db()
-{
- char *error_message = NULL;
- if (SQLITE_OK !=
- sqlite3_exec(pkgmgr_parser_db,
- QUERY_CREATE_TABLE_PACKAGE_APP_APP_SVC, NULL, NULL,
- &error_message)) {
- DBG("Don't execute query = %s error message = %s\n",
- QUERY_CREATE_TABLE_PACKAGE_APP_APP_SVC, error_message);
- sqlite3_free(error_message);
- return -1;
- }
- sqlite3_free(error_message);
- return 0;
-}
-
-static int __initialize_package_app_share_allowed_db()
-{
- char *error_message = NULL;
- if (SQLITE_OK !=
- sqlite3_exec(pkgmgr_parser_db,
- QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_ALLOWED, NULL,
- NULL, &error_message)) {
- DBG("Don't execute query = %s error message = %s\n",
- QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_ALLOWED,
- error_message);
- sqlite3_free(error_message);
- return -1;
- }
- sqlite3_free(error_message);
- return 0;
-}
-
-static int __initialize_package_app_share_request_db()
-{
- char *error_message = NULL;
- if (SQLITE_OK !=
- sqlite3_exec(pkgmgr_parser_db,
- QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_REQUEST, NULL,
- NULL, &error_message)) {
- DBG("Don't execute query = %s error message = %s\n",
- QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_REQUEST,
- error_message);
- sqlite3_free(error_message);
- return -1;
- }
- sqlite3_free(error_message);
- return 0;
-}
-
-static int __exec_query(char *query)
-{
- char *error_message = NULL;
- if (SQLITE_OK !=
- sqlite3_exec(pkgmgr_parser_db, query, NULL, NULL, &error_message)) {
- DBG("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- return -1;
- }
- sqlite3_free(error_message);
- return 0;
-}
-static GList *__create_locale_list(GList *locale, label_x *lbl, license_x *lcn, icon_x *icn, description_x *dcn, author_x *ath)
-{
-
- while(lbl != NULL)
- {
- if (lbl->lang)
- locale = g_list_insert_sorted_with_data(locale, (gpointer)lbl->lang, __comparefunc, NULL);
- lbl = lbl->next;
- }
- while(lcn != NULL)
- {
- if (lcn->lang)
- locale = g_list_insert_sorted_with_data(locale, (gpointer)lcn->lang, __comparefunc, NULL);
- lcn = lcn->next;
- }
- while(icn != NULL)
- {
- if (icn->lang)
- locale = g_list_insert_sorted_with_data(locale, (gpointer)icn->lang, __comparefunc, NULL);
- icn = icn->next;
- }
- while(dcn != NULL)
- {
- if (dcn->lang)
- locale = g_list_insert_sorted_with_data(locale, (gpointer)dcn->lang, __comparefunc, NULL);
- dcn = dcn->next;
- }
- while(ath != NULL)
- {
- if (ath->lang)
- locale = g_list_insert_sorted_with_data(locale, (gpointer)ath->lang, __comparefunc, NULL);
- ath = ath->next;
- }
- return locale;
-
-}
-
-static void __printfunc(gpointer data, gpointer userdata)
-{
- DBG("%s ", (char*)data);
-}
-
-static void __trimfunc1(gpointer data, gpointer userdata)
-{
- if (prev) {
- if (strcmp((char *)data, prev) == 0) {
- pkglocale = g_list_remove(pkglocale, data);
- } else
- prev = (char *)data;
- }
- else
- prev = (char *)data;
-}
-
-static void __trimfunc2(gpointer data, gpointer userdata)
-{
- if (prev) {
- if (strcmp((char *)data, prev) == 0) {
- applocale = g_list_remove(applocale, data);
- } else
- prev = (char *)data;
- }
- else
- prev = (char *)data;
-}
-
-static gint __comparefunc(gconstpointer a, gconstpointer b, gpointer userdata)
-{
- if (a == NULL || b == NULL)
- return 0;
- if (strcmp((char*)a, (char*)b) == 0)
- return 0;
- if (strcmp((char*)a, (char*)b) < 0)
- return -1;
- if (strcmp((char*)a, (char*)b) > 0)
- return 1;
-}
-
-static void __extract_data(gpointer data, label_x *lbl, license_x *lcn, icon_x *icn, description_x *dcn, author_x *ath,
- char **label, char **license, char **icon, char **description, char **author)
-{
- while(lbl != NULL)
- {
- if (lbl->lang) {
- if (strcmp(lbl->lang, (char *)data) == 0) {
- *label = (char*)lbl->text;
- break;
- }
- }
- lbl = lbl->next;
- }
- while(lcn != NULL)
- {
- if (lcn->lang) {
- if (strcmp(lcn->lang, (char *)data) == 0) {
- *license = (char*)lcn->text;
- break;
- }
- }
- lcn = lcn->next;
- }
- while(icn != NULL)
- {
- if (icn->lang) {
- if (strcmp(icn->lang, (char *)data) == 0) {
- *icon = (char*)icn->text;
- break;
- }
- }
- icn = icn->next;
- }
- while(dcn != NULL)
- {
- if (dcn->lang) {
- if (strcmp(dcn->lang, (char *)data) == 0) {
- *description = (char*)dcn->text;
- break;
- }
- }
- dcn = dcn->next;
- }
- while(ath != NULL)
- {
- if (ath->lang) {
- if (strcmp(ath->lang, (char *)data) == 0) {
- *author = (char*)ath->text;
- break;
- }
- }
- ath = ath->next;
- }
-
-}
-
-static void __insert_pkglocale_info(gpointer data, gpointer userdata)
-{
- int ret = -1;
- char *label = NULL;
- char *icon = NULL;
- char *description = NULL;
- char *license = NULL;
- char *author = NULL;
- char query[MAX_QUERY_LEN] = {'\0'};
-
- manifest_x *mfx = (manifest_x *)userdata;
- label_x *lbl = mfx->label;
- license_x *lcn = mfx->license;
- icon_x *icn = mfx->icon;
- description_x *dcn = mfx->description;
- author_x *ath = mfx->author;
-
- __extract_data(data, lbl, lcn, icn, dcn, ath, &label, &license, &icon, &description, &author);
- if (!label && !description && !icon && !license && !author)
- return;
- snprintf(query, MAX_QUERY_LEN, "insert into package_localized_info(package, package_locale, " \
- "package_label, package_icon, package_description, package_license, package_author) values " \
- "('%s', '%s', '%s', '%s', '%s', '%s', '%s')", mfx->package, (char*)data,
- label, icon, description, license, author);
- ret = __exec_query(query);
- if (ret == -1)
- DBG("Package Localized Info DB Insert failed\n");
-}
-
-static void __insert_uiapplication_locale_info(gpointer data, gpointer userdata)
-{
- int ret = -1;
- char *label = NULL;
- char *icon = NULL;
- char query[MAX_QUERY_LEN] = {'\0'};
-
- uiapplication_x *up = (uiapplication_x*)userdata;
- label_x *lbl = up->label;
- icon_x *icn = up->icon;
-
- __extract_data(data, lbl, NULL, icn, NULL, NULL, &label, NULL, &icon, NULL, NULL);
- if (!label && !icon)
- return;
- snprintf(query, MAX_QUERY_LEN, "insert into package_app_localized_info(app_id, app_locale, " \
- "app_label, app_icon) values " \
- "('%s', '%s', '%s', '%s')", up->appid, (char*)data,
- label, icon);
- ret = __exec_query(query);
- if (ret == -1)
- DBG("Package UiApp Localized Info DB Insert failed\n");
-
-}
-
-static void __insert_serviceapplication_locale_info(gpointer data, gpointer userdata)
-{
- int ret = -1;
- char *icon = NULL;
- char *label = NULL;
- char query[MAX_QUERY_LEN] = {'\0'};
-
- serviceapplication_x *sp = (serviceapplication_x*)userdata;
- label_x *lbl = sp->label;
- icon_x *icn = sp->icon;
-
- __extract_data(data, lbl, NULL, icn, NULL, NULL, &label, NULL, &icon, NULL, NULL);
- if (!icon && !label)
- return;
- snprintf(query, MAX_QUERY_LEN, "insert into package_app_localized_info(app_id, app_locale, " \
- "app_label, app_icon) values " \
- "('%s', '%s', '%s', '%s')", sp->appid, (char*)data,
- label, icon);
- ret = __exec_query(query);
- if (ret == -1)
- DBG("Package ServiceApp Localized Info DB Insert failed\n");
-}
-
-static int __insert_uiapplication_info(manifest_x *mfx)
-{
- uiapplication_x *up = mfx->uiapplication;
- int ret = -1;
- char query[MAX_QUERY_LEN] = {'\0'};
- while(up != NULL)
- {
- snprintf(query, MAX_QUERY_LEN,
- "insert into package_app_info(app_id, app_component, app_exec, app_nodisplay, app_type, app_onboot, " \
- "app_multiple, app_autorestart, app_taskmanage, package) " \
- "values('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",\
- up->appid, "uiapp", up->exec, up->nodisplay, up->type, "\0", up->multiple,
- "\0", up->taskmanage, mfx->package);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package UiApp Info DB Insert Failed\n");
- return -1;
- }
- up = up->next;
- memset(query, '\0', MAX_QUERY_LEN);
- }
- return 0;
-}
-
-static int __insert_uiapplication_appsvc_info(manifest_x *mfx)
-{
- uiapplication_x *up = mfx->uiapplication;
- appsvc_x *asvc = NULL;
- operation_x *op = NULL;
- mime_x *mi = NULL;
- uri_x *ui = NULL;
- int ret = -1;
- char query[MAX_QUERY_LEN] = {'\0'};
- char *operation = NULL;
- char *mime = NULL;
- char *uri = NULL;
- while(up != NULL)
- {
- asvc = up->appsvc;
- while(asvc != NULL)
- {
- op = asvc->operation;
- while(op != NULL)
- {
- if (op)
- operation = op->name;
- mi = asvc->mime;
-
- do
- {
- if (mi)
- mime = mi->name;
- ui = asvc->uri;
- do
- {
- if (ui)
- uri = ui->name;
- snprintf(query, MAX_QUERY_LEN,
- "insert into package_app_app_svc(app_id, operation, uri_scheme, mime_type) " \
- "values('%s', '%s', '%s', '%s')",\
- up->appid, operation, uri, mime);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package UiApp AppSvc DB Insert Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- if (ui)
- ui = ui->next;
- uri = NULL;
- } while(ui != NULL);
- if (mi)
- mi = mi->next;
- mime = NULL;
- }while(mi != NULL);
- if (op)
- op = op->next;
- operation = NULL;
- }
- asvc = asvc->next;
- }
- up = up->next;
- }
- return 0;
-}
-
-static int __insert_uiapplication_share_request_info(manifest_x *mfx)
-{
- uiapplication_x *up = mfx->uiapplication;
- datashare_x *ds = NULL;
- request_x *rq = NULL;
- int ret = -1;
- char query[MAX_QUERY_LEN] = {'\0'};
- while(up != NULL)
- {
- ds = up->datashare;
- while(ds != NULL)
- {
- rq = ds->request;
- while(rq != NULL)
- {
- snprintf(query, MAX_QUERY_LEN,
- "insert into package_app_share_request(app_id, data_share_request) " \
- "values('%s', '%s')",\
- up->appid, rq->text);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package UiApp Share Request DB Insert Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- rq = rq->next;
- }
- ds = ds->next;
- }
- up = up->next;
- }
- return 0;
-}
-
-static int __insert_uiapplication_share_allowed_info(manifest_x *mfx)
-{
- uiapplication_x *up = mfx->uiapplication;
- datashare_x *ds = NULL;
- define_x *df = NULL;
- allowed_x *al = NULL;
- int ret = -1;
- char query[MAX_QUERY_LEN] = {'\0'};
- while(up != NULL)
- {
- ds = up->datashare;
- while(ds != NULL)
- {
- df = ds->define;
- while(df != NULL)
- {
- al = df->allowed;
- while(al != NULL)
- {
- snprintf(query, MAX_QUERY_LEN,
- "insert into package_app_share_allowed(app_id, data_share_path, data_share_allowed) " \
- "values('%s', '%s', '%s')",\
- up->appid, df->path, al->text);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package UiApp Share Allowed DB Insert Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- al = al->next;
- }
- df = df->next;
- }
- ds = ds->next;
- }
- up = up->next;
- }
- return 0;
-}
-
-static int __insert_serviceapplication_info(manifest_x *mfx)
-{
- serviceapplication_x *sp = mfx->serviceapplication;
- int ret = -1;
- char query[MAX_QUERY_LEN] = {'\0'};
- while(sp != NULL)
- {
- snprintf(query, MAX_QUERY_LEN,
- "insert into package_app_info(app_id, app_component, app_exec, app_nodisplay, app_type, app_onboot, " \
- "app_multiple, app_autorestart, package) " \
- "values('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",\
- sp->appid, "svcapp", sp->exec, "\0", sp->type, sp->onboot, "\0",
- sp->autorestart, mfx->package);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package ServiceApp Info DB Insert Failed\n");
- return -1;
- }
- sp = sp->next;
- memset(query, '\0', MAX_QUERY_LEN);
- }
- return 0;
-}
-
-static int __insert_serviceapplication_appsvc_info(manifest_x *mfx)
-{
- serviceapplication_x *sp = mfx->serviceapplication;
- appsvc_x *asvc = NULL;
- int ret = -1;
- char query[MAX_QUERY_LEN] = {'\0'};
- operation_x *op = NULL;
- mime_x *mi = NULL;
- uri_x *ui = NULL;
- char *operation = NULL;
- char *mime = NULL;
- char *uri = NULL;
- while(sp != NULL)
- {
- asvc = sp->appsvc;
- while(asvc != NULL)
- {
- op = asvc->operation;
- while(op != NULL)
- {
- if (op)
- operation = op->name;
- mi = asvc->mime;
- do
- {
- if (mi)
- mime = mi->name;
- ui = asvc->uri;
- do
- {
- if (ui)
- uri = ui->name;
- snprintf(query, MAX_QUERY_LEN,
- "insert into package_app_app_svc(app_id, operation, uri_scheme, mime_type) " \
- "values('%s', '%s', '%s', '%s')",\
- sp->appid, operation, uri, mime);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package UiApp AppSvc DB Insert Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- if (ui)
- ui = ui->next;
- uri = NULL;
- } while(ui != NULL);
- if (mi)
- mi = mi->next;
- mime = NULL;
- }while(mi != NULL);
- if (op)
- op = op->next;
- operation = NULL;
- }
- asvc = asvc->next;
- }
- sp = sp->next;
- }
- return 0;
-}
-
-
-
-static int __insert_serviceapplication_share_request_info(manifest_x *mfx)
-{
- serviceapplication_x *sp = mfx->serviceapplication;
- datashare_x *ds = NULL;
- request_x *rq = NULL;
- int ret = -1;
- char query[MAX_QUERY_LEN] = {'\0'};
- while(sp != NULL)
- {
- ds = sp->datashare;
- while(ds != NULL)
- {
- rq = ds->request;
- while(rq != NULL)
- {
- snprintf(query, MAX_QUERY_LEN,
- "insert into package_app_share_request(app_id, data_share_request) " \
- "values('%s', '%s')",\
- sp->appid, rq->text);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package ServiceApp Share Request DB Insert Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- rq = rq->next;
- }
- ds = ds->next;
- }
- sp = sp->next;
- }
- return 0;
-}
-
-
-
-static int __insert_serviceapplication_share_allowed_info(manifest_x *mfx)
-{
- serviceapplication_x *sp = mfx->serviceapplication;
- datashare_x *ds = NULL;
- define_x *df = NULL;
- allowed_x *al = NULL;
- int ret = -1;
- char query[MAX_QUERY_LEN] = {'\0'};
- while(sp != NULL)
- {
- ds = sp->datashare;
- while(ds != NULL)
- {
- df = ds->define;
- while(df != NULL)
- {
- al = df->allowed;
- while(al != NULL)
- {
- snprintf(query, MAX_QUERY_LEN,
- "insert into package_app_share_allowed(app_id, data_share_path, data_share_allowed) " \
- "values('%s', '%s', '%s')",\
- sp->appid, df->path, al->text);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package App Share Allowed DB Insert Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- al = al->next;
- }
- df = df->next;
- }
- ds = ds->next;
- }
- sp = sp->next;
- }
- return 0;
-}
-
-static int __insert_manifest_info_in_db(manifest_x *mfx)
-{
- label_x *lbl = mfx->label;
- license_x *lcn = mfx->license;
- icon_x *icn = mfx->icon;
- description_x *dcn = mfx->description;
- author_x *ath = mfx->author;
- uiapplication_x *up = mfx->uiapplication;
- serviceapplication_x *sp = mfx->serviceapplication;
- char query[MAX_QUERY_LEN] = { '\0' };
- int ret = -1;
- char *type = NULL;
- char *auth_name = NULL;
- char *auth_email = NULL;
- char *auth_href = NULL;
- if (ath) {
- if (ath->text)
- auth_name = ath->text;
- if (ath->email)
- auth_email = ath->email;
- if (ath->href)
- auth_href = ath->href;
- }
-
- /*Insert in the package_info DB*/
- if (mfx->type)
- type = strdup(mfx->type);
- else
- type = strdup("rpm");
- snprintf(query, MAX_QUERY_LEN,
- "insert into package_info(package, package_type, package_version, install_location, " \
- "package_removable, package_preload, package_readonly, author_name, author_email, author_href) " \
- "values('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",\
- mfx->package, type, mfx->version, mfx->installlocation, mfx->removable, mfx->preload,
- mfx->readonly, auth_name, auth_email, auth_href);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package Info DB Insert Failed\n");
- if (type) {
- free(type);
- type = NULL;
- }
- return -1;
- }
- if (type) {
- free(type);
- type = NULL;
- }
- /*Insert the package locale and app locale info */
- pkglocale = __create_locale_list(pkglocale, lbl, lcn, icn, dcn, ath);
- g_list_foreach(pkglocale, __trimfunc1, NULL);
- prev = NULL;
-
- while(up != NULL)
- {
- applocale = __create_locale_list(applocale, up->label, NULL, up->icon, NULL, NULL);
- up = up->next;
- }
- while(sp != NULL)
- {
- applocale = __create_locale_list(applocale, sp->label, NULL, sp->icon, NULL, NULL);
- sp = sp->next;
- }
- g_list_foreach(applocale, __trimfunc2, NULL);
- prev = NULL;
-
- /*g_list_foreach(pkglocale, __printfunc, NULL);*/
- /*DBG("\n");*/
- /*g_list_foreach(applocale, __printfunc, NULL);*/
-
- /*package locale info*/
- g_list_foreach(pkglocale, __insert_pkglocale_info, (gpointer)mfx);
- /*native app locale info*/
- up = mfx->uiapplication;
- while(up != NULL)
- {
- g_list_foreach(applocale, __insert_uiapplication_locale_info, (gpointer)up);
- up = up->next;
- }
- /*agent app locale info*/
- sp = mfx->serviceapplication;
- while(sp != NULL)
- {
- g_list_foreach(applocale, __insert_serviceapplication_locale_info, (gpointer)sp);
- sp = sp->next;
- }
-
- g_list_free(pkglocale);
- pkglocale = NULL;
- g_list_free(applocale);
- applocale = NULL;
-
-
- /*Insert in the package_app_info DB*/
- ret = __insert_uiapplication_info(mfx);
- if (ret == -1)
- return -1;
- ret = __insert_serviceapplication_info(mfx);
- if (ret == -1)
- return -1;
-
- /*Insert in the package_app_app_svc DB*/
- ret = __insert_uiapplication_appsvc_info(mfx);
- if (ret == -1)
- return -1;
- ret = __insert_serviceapplication_appsvc_info(mfx);
- if (ret == -1)
- return -1;
-
- /*Insert in the package_app_share_allowed DB*/
- ret = __insert_uiapplication_share_allowed_info(mfx);
- if (ret == -1)
- return -1;
- ret = __insert_serviceapplication_share_allowed_info(mfx);
- if (ret == -1)
- return -1;
-
- /*Insert in the package_app_share_request DB*/
- ret = __insert_uiapplication_share_request_info(mfx);
- if (ret == -1)
- return -1;
- ret = __insert_serviceapplication_share_request_info(mfx);
- if (ret == -1)
- return -1;
-
- return 0;
-
-}
-
-static int __delete_manifest_info_from_db(manifest_x *mfx)
-{
- char query[MAX_QUERY_LEN] = { '\0' };
- int ret = -1;
- uiapplication_x *up = mfx->uiapplication;
- serviceapplication_x *sp = mfx->serviceapplication;
-
- /*Delete from Package Info DB*/
- snprintf(query, MAX_QUERY_LEN,
- "delete from package_info where package='%s'", mfx->package);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package Info DB Delete Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
-
- /*Delete from Package Localized Info*/
- snprintf(query, MAX_QUERY_LEN,
- "delete from package_localized_info where package='%s'", mfx->package);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package Localized Info DB Delete Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
-
- /*Delete from Package App Info*/
- while(up != NULL)
- {
- snprintf(query, MAX_QUERY_LEN,
- "delete from package_app_info where app_id='%s'", up->appid);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package App Info DB Delete Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- up = up->next;
- }
- while(sp != NULL)
- {
- snprintf(query, MAX_QUERY_LEN,
- "delete from package_app_info where app_id='%s'", sp->appid);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package App Info DB Delete Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- sp = sp->next;
- }
-
- /*Delete from Package App Localized Info*/
- up = mfx->uiapplication;
- sp = mfx->serviceapplication;
- while(up != NULL)
- {
- snprintf(query, MAX_QUERY_LEN,
- "delete from package_app_localized_info where app_id='%s'", up->appid);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package App Localized Info DB Delete Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- up = up->next;
- }
- while(sp != NULL)
- {
- snprintf(query, MAX_QUERY_LEN,
- "delete from package_app_localized_info where app_id='%s'", sp->appid);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package App Localized Info DB Delete Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- sp = sp->next;
- }
-
- /*Delete from Package App App-Svc*/
- up = mfx->uiapplication;
- sp = mfx->serviceapplication;
- while(up != NULL)
- {
- snprintf(query, MAX_QUERY_LEN,
- "delete from package_app_app_svc where app_id='%s'", up->appid);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package App App-Svc DB Delete Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- up = up->next;
- }
- while(sp != NULL)
- {
- snprintf(query, MAX_QUERY_LEN,
- "delete from package_app_app_svc where app_id='%s'", sp->appid);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package App App-Svc DB Delete Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- sp = sp->next;
- }
-
- /*Delete from Package App Share Allowed*/
- up = mfx->uiapplication;
- sp = mfx->serviceapplication;
- while(up != NULL)
- {
- snprintf(query, MAX_QUERY_LEN,
- "delete from package_app_share_allowed where app_id='%s'", up->appid);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package App Share Allowed DB Delete Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- up = up->next;
- }
- while(sp != NULL)
- {
- snprintf(query, MAX_QUERY_LEN,
- "delete from package_app_share_allowed where app_id='%s'", sp->appid);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package App Share Allowed DB Delete Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- sp = sp->next;
- }
-
- /*Delete from Package App Share Request*/
- up = mfx->uiapplication;
- sp = mfx->serviceapplication;
- while(up != NULL)
- {
- snprintf(query, MAX_QUERY_LEN,
- "delete from package_app_share_request where app_id='%s'", up->appid);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package App Share Request DB Delete Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- up = up->next;
- }
- while(sp != NULL)
- {
- snprintf(query, MAX_QUERY_LEN,
- "delete from package_app_share_request where app_id='%s'", sp->appid);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package App Share Request DB Delete Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- sp = sp->next;
- }
- return 0;
-}
-
-
-int pkgmgr_parser_initialize_db()
-{
- int ret = -1;
- ret = __initialize_package_info_db();
- if (ret == -1) {
- DBG("package info DB initialization failed\n");
- return ret;
- }
- ret = __initialize_package_localized_info_db();
- if (ret == -1) {
- DBG("package localized info DB initialization failed\n");
- return ret;
- }
- ret = __initialize_package_app_info_db();
- if (ret == -1) {
- DBG("package app info DB initialization failed\n");
- return ret;
- }
- ret = __initialize_package_app_localized_info_db();
- if (ret == -1) {
- DBG("package app localized info DB initialization failed\n");
- return ret;
- }
- ret = __initialize_package_app_app_svc_db();
- if (ret == -1) {
- DBG("package app app svc DB initialization failed\n");
- return ret;
- }
- ret = __initialize_package_app_share_allowed_db();
- if (ret == -1) {
- DBG("package app share allowed DB initialization failed\n");
- return ret;
- }
- ret = __initialize_package_app_share_request_db();
- if (ret == -1) {
- DBG("package app share request DB initialization failed\n");
- return ret;
- }
- return 0;
-}
-
-int pkgmgr_parser_check_and_create_db()
-{
- int ret = -1;
- if (access(PKGMGR_PARSER_DB_FILE, F_OK) == 0) {
- ret =
- db_util_open(PKGMGR_PARSER_DB_FILE, &pkgmgr_parser_db,
- DB_UTIL_REGISTER_HOOK_METHOD);
- if (ret != SQLITE_OK) {
- DBG("connect db [%s] failed!\n",
- PKGMGR_PARSER_DB_FILE);
- return -1;
- }
- return 0;
- }
- DBG("Pkgmgr DB does not exists. Create one!!\n");
-
- ret =
- db_util_open(PKGMGR_PARSER_DB_FILE, &pkgmgr_parser_db,
- DB_UTIL_REGISTER_HOOK_METHOD);
-
- if (ret != SQLITE_OK) {
- DBG("connect db [%s] failed!\n", PKGMGR_PARSER_DB_FILE);
- return -1;
- }
- return 0;
-}
-
-API int pkgmgr_parser_insert_manifest_info_in_db(manifest_x *mfx)
-{
- if (mfx == NULL) {
- DBG("manifest pointer is NULL\n");
- return -1;
- }
- int ret = -1;
- ret = pkgmgr_parser_check_and_create_db();
- if (ret == -1) {
- DBG("Failed to open DB\n");
- return ret;
- }
- ret = pkgmgr_parser_initialize_db();
- if (ret == -1)
- return ret;
- /*Begin transaction*/
- ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
- if (ret != SQLITE_OK) {
- DBG("Failed to begin transaction\n");
- sqlite3_close(pkgmgr_parser_db);
- return -1;
- }
- DBG("Transaction Begin\n");
- ret = __insert_manifest_info_in_db(mfx);
- if (ret == -1) {
- DBG("Insert into DB failed. Rollback now\n");
- sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
- sqlite3_close(pkgmgr_parser_db);
- return -1;
- }
- /*Commit transaction*/
- ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL);
- if (ret != SQLITE_OK) {
- DBG("Failed to commit transaction. Rollback now\n");
- sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
- sqlite3_close(pkgmgr_parser_db);
- return -1;
- }
- DBG("Transaction Commit and End\n");
- sqlite3_close(pkgmgr_parser_db);
- return 0;
-}
-
-API int pkgmgr_parser_update_manifest_info_in_db(manifest_x *mfx)
-{
- if (mfx == NULL) {
- DBG("manifest pointer is NULL\n");
- return -1;
- }
- int ret = -1;
- ret = pkgmgr_parser_check_and_create_db();
- if (ret == -1) {
- DBG("Failed to open DB\n");
- return ret;
- }
- ret = pkgmgr_parser_initialize_db();
- if (ret == -1)
- return ret;
-
- /*Begin transaction*/
- ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
- if (ret != SQLITE_OK) {
- DBG("Failed to begin transaction\n");
- sqlite3_close(pkgmgr_parser_db);
- return -1;
- }
- DBG("Transaction Begin\n");
- ret = __delete_manifest_info_from_db(mfx);
- if (ret == -1) {
- DBG("Delete from DB failed. Rollback now\n");
- sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
- sqlite3_close(pkgmgr_parser_db);
- return -1;
- }
- ret = __insert_manifest_info_in_db(mfx);
- if (ret == -1) {
- DBG("Insert into DB failed. Rollback now\n");
- sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
- sqlite3_close(pkgmgr_parser_db);
- return -1;
- }
-
- /*Commit transaction*/
- ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL);
- if (ret != SQLITE_OK) {
- DBG("Failed to commit transaction. Rollback now\n");
- sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
- sqlite3_close(pkgmgr_parser_db);
- return -1;
- }
- DBG("Transaction Commit and End\n");
- sqlite3_close(pkgmgr_parser_db);
- return 0;
-}
-
-API int pkgmgr_parser_delete_manifest_info_from_db(manifest_x *mfx)
-{
- if (mfx == NULL) {
- DBG("manifest pointer is NULL\n");
- return -1;
- }
- int ret = -1;
- ret = pkgmgr_parser_check_and_create_db();
- if (ret == -1) {
- DBG("Failed to open DB\n");
- return ret;
- }
- /*Begin transaction*/
- ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
- if (ret != SQLITE_OK) {
- DBG("Failed to begin transaction\n");
- sqlite3_close(pkgmgr_parser_db);
- return -1;
- }
- DBG("Transaction Begin\n");
- ret = __delete_manifest_info_from_db(mfx);
- if (ret == -1) {
- DBG("Delete from DB failed. Rollback now\n");
- sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
- sqlite3_close(pkgmgr_parser_db);
- return -1;
- }
- /*Commit transaction*/
- ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL);
- if (ret != SQLITE_OK) {
- DBG("Failed to commit transaction, Rollback now\n");
- sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
- sqlite3_close(pkgmgr_parser_db);
- return -1;
- }
- DBG("Transaction Commit and End\n");
- sqlite3_close(pkgmgr_parser_db);
- return 0;
-}
+++ /dev/null
-/*
- * slp-pkgmgr
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
- * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-/**
- * @file pkgmgr_parser_db.h
- * @author Shobhit Srivastava <shobhit.s@samsung.com>
- * @version 0.1
- * @brief This file declares API to store/retrieve manifest data in DB
- *
- * @addtogroup APPLICATION_FRAMEWORK
- * @{
- *
- * @defgroup PackageManager
- * @section Header to use them:
- * @code
- * #include "pkgmgr_parser_db.h"
- * @endcode
- *
- * @addtogroup PackageManager
- * @{
- */
-
-#ifndef __PKGMGR_PARSER_DB_H__
-#define __PKGMGR_PARSER_DB_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-#include "pkgmgr_parser.h"
-
-/**
- * @brief This API insert the parsed manifest info in db.
- *
- * @param[in] mfx pointer to manifest info.
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_parser_insert_manifest_info_in_db(manifest_x *mfx);
-
-/**
- * @brief This API update the parsed manifest info in db.
- *
- * @param[in] mfx pointer to manifest info.
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_parser_update_manifest_info_in_db(manifest_x *mfx);
-
-/**
- * @brief This API delete the parsed manifest info from db.
- *
- * @param[in] mfx pointer to manifest info.
- * @return 0 if success, error code(<0) if fail\n
-*/
-int pkgmgr_parser_delete_manifest_info_from_db(manifest_x *mfx);
-/** @} */
-
-int pkgmgr_parser_check_and_create_db();
-int pkgmgr_parser_initialize_db();
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* __PKGMGR_PARSER_DB_H__ */
-/**
- * @}
- * @}
- */
+++ /dev/null
-/*
- * slp-pkgmgr
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
- * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-
-
-
-#ifndef __PKGMGR_PARSER_INTERNAL_H__
-#define __PKGMGR_PARSER_INTERNAL_H__
-
-
-/* debug output */
-#if defined(NDEBUG)
-#define DBG(fmt, args...)
-#define __SET_DBG_OUTPUT(fp)
-#elif defined(PRINT)
-#include <stdio.h>
-FILE *___log = NULL;
-#define DBG(fmt, args...) \
- {if (!___log) ___log = stderr; \
- fprintf(___log, "[DBG:PMS]%s:%d:%s(): " fmt "\n",\
- basename(__FILE__), __LINE__, __func__, ##args); fflush(___log); }
-#define __SET_DBG_OUTPUT(fp) \
- (___log = fp)
-#else
-#include <dlog.h>
-#undef LOG_TAG
-#define LOG_TAG "PKGMGR_PARSER"
-
-#define DBGE(fmt, arg...) LOGE("[%s,%d] "fmt, __FUNCTION__, __LINE__, ##arg)
-#define DBG(fmt, arg...) LOGD("[%s,%d] "fmt, __FUNCTION__, __LINE__, ##arg)
-#endif
-
-
-#ifndef API
-#define API __attribute__ ((visibility("default")))
-#endif
-
-
-#endif /* __PKGMGR_PARSER_INTERNAL_H__ */
+++ /dev/null
-#RW_NORM
-org.tizen.ag-hello
-org.tizen.app-tray
-org.tizen.bluetooth-share-ui
-org.tizen.bluetooth
-org.tizen.browser
-org.tizen.bt-appsvc
-org.tizen.bt-syspopup
-org.tizen.calculator
-org.tizen.calendar-viewer
-org.tizen.calendar
-org.tizen.call-eq-analyzer
-org.tizen.call
-org.tizen.camera-app
-org.tizen.ciss
-org.tizen.clock
-org.tizen.cluster-home
-org.tizen.contacts-viewer
-org.tizen.contacts
-org.tizen.dailybriefing-accuweather
-org.tizen.dailybriefing-agent
-org.tizen.dailybriefing-apnews
-org.tizen.dailybriefing-yfinance
-org.tizen.data-provider-slave
-org.tizen.download-provider
-org.tizen.draglock
-org.tizen.eas-appsvc
-org.tizen.email
-org.tizen.ereader
-org.tizen.facebook-service
-org.tizen.facebook
-org.tizen.fileshare-service
-org.tizen.fm-radio
-org.tizen.gallery
-org.tizen.idle-lock
-org.tizen.image-editor
-org.tizen.image-viewer
-org.tizen.keystrings
-org.tizen.kies-via-wifi
-org.tizen.livebox-3d-lock
-org.tizen.lowbat-syspopup
-org.tizen.lowmem-syspopup
-org.tizen.mdm-app
-org.tizen.mdm-syspopup
-org.tizen.memo
-org.tizen.menu-screen
-org.tizen.message
-org.tizen.mobileprint
-org.tizen.msg-ui-class0
-org.tizen.music-player
-org.tizen.myfile
-org.tizen.nfc-app
-org.tizen.phone-lock
-org.tizen.phone
-org.tizen.picasa
-org.tizen.poweroff-syspopup
-org.tizen.pwlock
-org.tizen.ring
-org.tizen.setting
-org.tizen.smartsearch
-org.tizen.sound-player
-org.tizen.system-panel
-org.tizen.taskmgr
-org.tizen.tethering
-org.tizen.tickernoti-syspopup
-org.tizen.usb-printer-detector
-org.tizen.usbotg-syspopup
-org.tizen.voicerecorder
-org.tizen.volume
-org.tizen.vtmain
-org.tizen.wifi-direct-popup
-org.tizen.wifi-direct-ugapp
-org.tizen.youtube
-activesync-ui
-org.tizen.aospd00043
-org.tizen.cp7ipabg4k
-org.tizen.57r43275q7
-org.tizen.q7097a278m
-org.tizen.800ij447xl
-org.tizen.70lsyzhkse
-org.tizen.nas9xepmna
-
-#RW_RM
-org.tizen.video-player
-org.tizen.spotify
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://www.w3.org/XML/1998/namespace" xmlns:packages="http://tizen.org/ns/packages">
- <xs:import namespace="http://tizen.org/ns/packages" schemaLocation="manifest.xsd"/>
- <xs:attribute name="lang" type="xs:NCName"/>
-</xs:schema>
# usage
# backend:directory_path
# backendlib:directory_path
-# parserlib:directory_path
+
backend:/usr/etc/package-manager/backend/
backendlib:/usr/etc/package-manager/backendlib/
-parserlib:/usr/etc/package-manager/parserlib/
--- /dev/null
+<manifest>
+ <define>
+ <domain name="pkgmgr-client"/>
+ <provide>
+ <label name="pkgmgr-client::db"/>
+ </provide>
+ <permit>
+ <smack permit="pkgmgr" type="rwx"/>
+ </permit>
+ </define>
+ <request>
+ <domain name="pkgmgr-client"/>
+ </request>
+ <assign>
+ <filesystem path="/usr/lib/libpkgmgr-client.so.0" label="_"/>
+ <filesystem path="/usr/lib/libpkgmgr-client.so.0.1.68" label="_"/>
+ </assign>
+</manifest>
--- /dev/null
+<manifest>
+ <define>
+ <domain name="pkgmgr-installer"/>
+ </define>
+ <request>
+ <domain name="pkgmgr-installer"/>
+ </request>
+ <assign>
+ <filesystem path="/usr/lib/libpkgmgr_installer.so.0" label="_"/>
+ <filesystem path="/usr/lib/libpkgmgr_installer.so.0.1.0" label="_"/>
+ <filesystem path="/usr/lib/libpkgmgr_installer_client.so.0" label="_"/>
+ <filesystem path="/usr/lib/libpkgmgr_installer_client.so.0.1.0" label="_"/>
+ <filesystem path="/usr/lib/libpkgmgr_installer_status_broadcast_server.so.0" label="_"/>
+ <filesystem path="/usr/lib/libpkgmgr_installer_status_broadcast_server.so.0.1.0" label="_"/>
+ </assign>
+</manifest>
--- /dev/null
+<manifest>
+ <define>
+ <domain name="pkgmgr-parser"/>
+ </define>
+ <request>
+ <domain name="pkgmgr-parser"/>
+ </request>
+ <assign>
+ <filesystem path="/usr/lib/libpkgmgr_parser.so.0" label="_"/>
+ <filesystem path="/usr/lib/libpkgmgr_parser.so.0.1.0" label="_"/>
+ <filesystem path="/usr/lib/libpkgmgr_parser_lib_sample.so" label="_"/>
+ </assign>
+</manifest>
--- /dev/null
+<manifest>
+ <define>
+ <domain name="pkgmgr-server"/>
+ <request>
+ <smack request="system::homedir" type="rwxat"/>
+ <smack request="security-server::api-cookie-check" type="w"/>
+ <smack request="system::use_internet" type="w"/>
+ <smack request="deviced::display" type="rw"/>
+ </request>
+ <permit>
+ <smack permit="system::use_internet" type="w"/>
+ </permit>
+ </define>
+ <request>
+ <domain name="pkgmgr-server"/>
+ </request>
+ <assign>
+ <filesystem path="/usr/bin/pkgmgr-server" exec_label="pkgmgr-server"/>
+ <filesystem path="/usr/share/dbus-1/services/org.tizen.pkgmgr.service" label="_" exec_label="none"/>
+ </assign>
+</manifest>
--- /dev/null
+echo "--------------------------------------"
+echo "Soft Reset ..............."
+echo "--------------------------------------"
+
+# avoid crash popup
+ /usr/bin/killall -STOP deviced
+
+
+disable_keys() {
+ key_dir=`/bin/ls -1d /sys/devices/gpio_keys*`
+ if [ "z$key_dir" != "z" ]; then
+ key_code=`/bin/cat $key_dir/keys`
+ echo $key_code > $key_dir/disabled_keys
+ fi
+ # If cannot disabled keys by sysfs, kill apps about key operations
+ # systemctl stop starter
+ # /usr/bin/killall volume
+ # /usr/bin/killall cluster-home
+}
+
+
+## display ui
+HOME=/home/app /usr/bin/factory-reset-util --displayui &
+
+
+## stop lcd on-off and turn lcd on
+ss_ready=`/bin/ps -ef | /bin/grep -e "deviced\|system_server" | /bin/grep -v grep`
+if [ "z$ss_ready" != "z" ]; then
+ /usr/bin/dbus-send --system --type=method_call --print-reply --reply-timeout=10000 \
+ --dest=org.tizen.system.deviced /Org/Tizen/System/DeviceD/Display \
+ org.tizen.system.deviced.display.stop
+fi
+
+# reset audio - If not, some targets make noise when rebooting.
+/usr/bin/sound_server --soundreset
+
+
+echo "--------------------------------------"
+echo "Soft Reset ..............."
+echo "--------------------------------------"
--- /dev/null
+<manifest>
+ <define>
+ <domain name="pkgmgr"/>
+ <provide>
+ <label name="pkgmgr::svc"/>
+ <label name="pkgmgr::info"/>
+ </provide>
+ <request>
+ <smack request="pkgmgr::svc" type="rwx"/>
+ <smack request="pkgmgr::info" type="rwx"/>
+ <smack request="dbus" type="rwx"/>
+ <smack request="system::homedir" type="rwxat"/>
+ <smack request="system::media" type="rwxat"/>
+ <smack request="ail::db" type="rwx"/>
+ <smack request="system::vconf" type="rwxat"/>
+ <smack request="system::vconf_inhouse" type="rwxat"/>
+ <smack request="pkgmgr::db" type="rwx"/>
+ <smack request="device::sys_logging" type="w"/>
+ <smack request="device::app_logging" type="w"/>
+ <smack request="sdbd" type="r"/>
+ </request>
+ </define>
+ <request>
+ <domain name="pkgmgr"/>
+ </request>
+ <assign>
+ <filesystem path="/usr/bin/pkg_fota" exec_label="pkgmgr"/>
+ <filesystem path="/usr/bin/pkg_initdb" exec_label="pkgmgr"/>
+ <filesystem path="/usr/bin/pkgcmd" exec_label="pkgmgr"/>
+ <filesystem path="/usr/bin/pkginfo" exec_label="pkgmgr"/>
+ <filesystem path="/usr/bin/pkg_getsize" exec_label="pkgmgr"/>
+ <filesystem path="/usr/bin/pkg" exec_label="pkgmgr"/>
+ <filesystem path="/usr/lib/libpkgmgr_parser_lib_sample.so" label="_"/>
+ </assign>
+</manifest>
Name: package manager
Description: SLP Package Manager Package
Version: @VERSION@
-Requires: security-server dlog pkgmgr-types pkgmgr-installer-client pkgmgr-installer-status-broadcast-server aul
+Requires: security-server dlog pkgmgr-types pkgmgr-installer-client pkgmgr-installer-status-broadcast-server
Libs: -L${libdir} -L${libdir}/pkgmgr -lpkgmgr-client
Cflags: -I${includedir}
char req_id[MAX_REQ_ID_LEN];
int req_type;
char pkg_type[MAX_PKG_TYPE_LEN];
- char pkg_name[MAX_PKG_NAME_LEN];
+ char pkgid[MAX_PKG_NAME_LEN];
char args[MAX_PKG_ARGS_LEN];
char cookie[MAX_COOKIE_LEN];
} pm_dbus_msg;
typedef struct backend_info_t {
int pid;
char pkgtype[MAX_PKG_TYPE_LEN];
- char pkgname[MAX_PKG_NAME_LEN];
+ char pkgid[MAX_PKG_NAME_LEN];
char args[MAX_PKG_ARGS_LEN];
}backend_info;
pm_queue_data *head;
} queue_info_map;
+#define MAX_QUEUE_NUM 128
+
int _pm_queue_init();
-int _pm_queue_push(pm_dbus_msg item);
+int _pm_queue_push(pm_dbus_msg *item);
/*position specifies the queue from which to pop request*/
-pm_dbus_msg _pm_queue_pop(int position);
-pm_dbus_msg _pm_queue_get_head();
+pm_dbus_msg *_pm_queue_pop(int position);
void _pm_queue_final();
-void _pm_queue_delete(pm_dbus_msg item);
+void _pm_queue_delete(pm_dbus_msg *item);
pm_queue_data *_add_node();
-void _save_queue_status(pm_dbus_msg item, char *status);
+void _save_queue_status(pm_dbus_msg *item, char *status);
void _print_queue(int position);
#endif /* _PM_QUEUE_H_ */
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <fcntl.h>
+#include <dirent.h>
+#include <ctype.h>
#include <glib.h>
#include <signal.h>
-#include <Elementary.h>
-#include <appcore-efl.h>
-#include <Ecore_X.h>
-#include <Ecore_File.h>
-#include <ail.h>
+#include <dbus/dbus.h>
+#include <security-server.h>
+#include <vconf.h>
+#include <pkgmgr-info.h>
+#include <pkgmgr_parser.h>
+#include "pm-queue.h"
#include "pkgmgr_installer.h"
-#include "comm_pkg_mgr_server.h"
#include "pkgmgr-server.h"
-#include "pm-queue.h"
+#include "comm_pkg_mgr_server.h"
#include "comm_config.h"
+#include "package-manager.h"
+#include "package-manager-debug.h"
+#include "package-manager-internal.h"
-/* debug output */
-#if defined(NDEBUG)
-#define DBG(fmt, args...)
-#define __SET_DBG_OUTPUT(fp)
-#elif defined(PRINT)
-#include <stdio.h>
-FILE *___log = NULL;
-#define DBG(fmt, args...) \
- {if (!___log) ___log = stderr; \
- fprintf(___log, "[DBG:PMS]%s:%d:%s(): " fmt "\n",\
- basename(__FILE__), __LINE__, __func__, ##args); fflush(___log); }
-#define __SET_DBG_OUTPUT(fp) \
- (___log = fp)
-#else
-#include <dlog.h>
+#ifdef LOG_TAG
#undef LOG_TAG
-#define LOG_TAG "PKGMGR_SERVER"
-
-#define DBGE(fmt, arg...) LOGE("[%s,%d] "fmt, __FUNCTION__, __LINE__, ##arg)
-#define DBG(fmt, arg...) LOGD("[%s,%d] "fmt, __FUNCTION__, __LINE__, ##arg)
#endif
+#define LOG_TAG "PKGMGR_SERVER"
-#if !defined(PACKAGE)
-#define PACKAGE "package-manager"
-#endif
+#define IS_WHITESPACE(CHAR) \
+((CHAR == ' ' || CHAR == '\t' || CHAR == '\r' || CHAR == '\n') ? TRUE : FALSE)
-#if !defined(LOCALEDIR)
-#define LOCALEDIR "/usr/share/locale"
-#endif
+#define PACKAGE_RECOVERY_DIR "/opt/share/packages/.recovery/pkgmgr"
#define DESKTOP_W 720.0
-static int backend_flag = 0; /* 0 means that backend process is not running */
-static int drawing_popup = 0; /* 0 means that pkgmgr-server has no popup now */
+#define NO_MATCHING_FILE 11
-/* For pkgs with no desktop file, inotify callback wont be called.
-* To handle that case ail_db_update is initialized as 1
-* This flag will be used to ensure that pkgmgr server does not exit
-* before the db is updated. */
-int ail_db_update = 1;
+static int backend_flag = 0; /* 0 means that backend process is not running */
/*
8 bit value to represent maximum 8 backends.
GMainLoop *mainloop = NULL;
-
-/* operation_type */
-typedef enum {
- OPERATION_INSTALL = 0,
- OPERATION_UNINSTALL,
- OPERATION_ACTIVATE,
- OPERATION_MAX
-} OPERATION_TYPE;
-
-struct appdata {
- Evas_Object *win;
- Evas_Object *notify;
- pm_dbus_msg *item;
- OPERATION_TYPE op_type;
-};
-
-struct pm_desktop_notifier_t {
- int ifd;
- Ecore_Fd_Handler *handler;
-};
-typedef struct pm_desktop_notifier_t pm_desktop_notifier;
-
-pm_desktop_notifier desktop_notifier;
-pm_inotify_paths paths[DESKTOP_FILE_DIRS_NUM];
static int __check_backend_status_for_exit();
static int __check_queue_status_for_exit();
-static int __check_backend_mode();
static int __is_backend_busy(int position);
static void __set_backend_busy(int position);
static void __set_backend_free(int position);
-static int __is_backend_mode_quiet(int position);
static void __set_backend_mode(int position);
static void __unset_backend_mode(int position);
-static void response_cb1(void *data, Evas_Object *notify, void *event_info);
-static void response_cb2(void *data, Evas_Object *notify, void *event_info);
-static int create_popup(struct appdata *ad);
+
static void sighandler(int signo);
-static int __get_position_from_pkg_type(char *pkgtype);
gboolean queue_job(void *data);
gboolean send_fail_signal(void *data);
gboolean exit_server(void *data);
-static Eina_Bool __directory_notify(void *data, Ecore_Fd_Handler *fd_handler);
/* To check whether a particular backend is free/busy*/
static int __is_backend_busy(int position)
{
backend_busy = backend_busy & ~(1<<position);
}
-/* To check whether a particular backend is running in quiet mode*/
-static int __is_backend_mode_quiet(int position)
-{
- return backend_mode & 1<<position;
-}
+
/*To set a particular backend mode as quiet*/
static void __set_backend_mode(int position)
{
backend_mode = backend_mode & ~(1<<position);
}
-static int __get_position_from_pkg_type(char *pkgtype)
+static void __set_recovery_mode(char *pkgid, char *pkg_type)
{
- int i = 0;
- queue_info_map *ptr;
- ptr = start;
- for(i = 0; i < entries; i++)
- {
- if (!strncmp(ptr->pkgtype, pkgtype, MAX_PKG_TYPE_LEN))
- return ptr->queue_slot;
- else
- ptr++;
+ char recovery_file[MAX_PKG_NAME_LEN] = { 0, };
+ char buffer[MAX_PKG_NAME_LEN] = { 0 };
+ char *pkgid_tmp = NULL;
+ FILE *rev_file = NULL;
- }
-}
-
-static Eina_Bool __directory_notify(void *data, Ecore_Fd_Handler *fd_handler)
-{
- ail_db_update = 0;
- char *buf = NULL;
- ssize_t read_size = 0;
- ssize_t len = 0;
- ssize_t i = 0;
- int fd = -1;
-
- fd = ecore_main_fd_handler_fd_get(fd_handler);
- DBG("ifd [%d]\n", fd);
-
- if (ioctl(fd, FIONREAD, &read_size) < 0) {
- DBG("Failed to get byte size\n");
- ail_db_update = 1;
- return ECORE_CALLBACK_CANCEL;
- }
-
- if (read_size <= 0) {
- DBG("Buffer is not ready!!!\n");
- ail_db_update = 1;
- return ECORE_CALLBACK_RENEW;
+ if (pkgid == NULL) {
+ _LOGE("pkgid is null\n");
+ return;
}
- buf = malloc(read_size);
- if (!buf) {
- DBG("Failed to allocate memory for event handling\n");
- ail_db_update = 1;
- return ECORE_CALLBACK_RENEW;
+ /*if pkgid has a "/"charactor, that is a path name for installation, then extract pkgid from absolute path*/
+ if (strstr(pkgid, "/")) {
+ pkgid_tmp = strrchr(pkgid, '/') + 1;
+ if (pkgid_tmp == NULL) {
+ _LOGD("pkgid_tmp[%s] is null\n", pkgid);
+ return;
+ }
+ snprintf(recovery_file, MAX_PKG_NAME_LEN, "%s/%s", PACKAGE_RECOVERY_DIR, pkgid_tmp);
+ } else {
+ snprintf(recovery_file, MAX_PKG_NAME_LEN, "%s/%s", PACKAGE_RECOVERY_DIR, pkgid);
}
- len = read(fd, buf, read_size);
- if (len < 0) {
- free(buf);
- /*Stop monitoring about this invalid file descriptor */
- ail_db_update = 1;
- return ECORE_CALLBACK_CANCEL;
+ rev_file = fopen(recovery_file, "w");
+ if (rev_file== NULL) {
+ _LOGD("rev_file[%s] is null\n", recovery_file);
+ return;
}
- while (i < len) {
- struct inotify_event *event = (struct inotify_event*) &buf[i];
- char *str_potksed = "potksed.";
- char *cut;
- char *package = NULL;
- ssize_t idx;
- int nev_name;
-
- /* 1. check the extension of a file */
- nev_name = strlen(event->name) - 1;
- for (idx = 0; nev_name >= 0 && str_potksed[idx]; idx++) {
- if (event->name[nev_name] != str_potksed[idx]) {
- break;
- }
- nev_name --;
- }
-
- if (str_potksed[idx] != '\0') {
- DBG("This is not a desktop file : %s\n", event->name);
- i += sizeof(struct inotify_event) + event->len;
- continue;
- }
-
- package = strdup(event->name);
- if (package == NULL)
- continue;
-
- cut = strstr(package, ".desktop");
- if (cut)
- *cut = '\0';
- DBG("Package : %s\n", package);
-
- /* add & update */
- if (event->mask & IN_CLOSE_WRITE || event->mask & IN_MOVED_TO) {
- ail_appinfo_h ai = NULL;
- ail_error_e ret;
+ snprintf(buffer, MAX_PKG_NAME_LEN, "pkgid : %s\n", pkgid);
+ fwrite(buffer, sizeof(char), strlen(buffer), rev_file);
- ret = ail_package_get_appinfo(package, &ai);
- if (ai)
- ail_package_destroy_appinfo(ai);
-
- if (AIL_ERROR_NO_DATA == ret) {
- if (ail_desktop_add(package) < 0) {
- DBG("Failed to add a new package (%s)\n", event->name);
- }
- } else if (AIL_ERROR_OK == ret) {
- if (ail_desktop_update(package) < 0) {
- DBG("Failed to add a new package (%s)\n", event->name);
- }
- } else;
- /* delete */
- } else if (event->mask & IN_DELETE) {
- if (ail_desktop_remove(package) < 0)
- DBG("Failed to remove a package (%s)\n",
- event->name);
- } else {
- DBG("this event is not dealt with inotify\n");
- }
-
- free(package);
-
- i += sizeof(struct inotify_event) + event->len;
- }
-
- free(buf);
- ail_db_update = 1;
- return ECORE_CALLBACK_RENEW;
+ fclose(rev_file);
}
-static
-void response_cb1(void *data, Evas_Object *notify, void *event_info)
+static void __unset_recovery_mode(char *pkgid, char *pkg_type)
{
- struct appdata *ad = (struct appdata *)data;
- int p = 0;
- int ret = 0;
- DBG("start of response_cb()\n");
-
- /* YES */
- DBG("Uninstalling... [%s]\n", ad->item->pkg_name);
-
- if (strlen(ad->item->pkg_name) == 0) {
- DBG("package_name is empty\n");
- }
-
- if (strlen(ad->item->pkg_type) == 0) {
- DBG("Fail : Uninstalling... [%s]\n",
- ad->item->pkg_name);
- free(ad->item);
- evas_object_del(ad->notify);
- evas_object_del(ad->win);
- drawing_popup = 0;
+ int ret = -1;
+ char recovery_file[MAX_PKG_NAME_LEN] = { 0, };
+ char *pkgid_tmp = NULL;
+ if (pkgid == NULL) {
+ _LOGE("pkgid is null\n");
return;
}
- DBG("pkg_type = [%s]\n", ad->item->pkg_type);
-
- ret = _pm_queue_push(*(ad->item));
- p = __get_position_from_pkg_type(ad->item->pkg_type);
- __unset_backend_mode(p);
-
- /* Free resource */
- free(ad->item);
- evas_object_del(ad->notify);
- evas_object_del(ad->win);
- /***************/
- if (ret == 0)
- g_idle_add(queue_job, NULL);
-
- DBG("end of response_cb()\n");
-
- drawing_popup = 0;
+ /*if pkgid has a "/"charactor, that is a path name for installation, then extract pkgid from absolute path*/
+ if (strstr(pkgid, "/")) {
+ pkgid_tmp = strrchr(pkgid, '/') + 1;
+ if (pkgid_tmp == NULL) {
+ _LOGD("pkgid_tmp[%s] is null\n", pkgid);
+ return;
+ }
+ snprintf(recovery_file, MAX_PKG_NAME_LEN, "%s/%s", PACKAGE_RECOVERY_DIR, pkgid_tmp);
+ } else {
+ snprintf(recovery_file, MAX_PKG_NAME_LEN, "%s/%s", PACKAGE_RECOVERY_DIR, pkgid);
+ }
- return;
+ ret = remove(recovery_file);
+ if (ret < 0)
+ _LOGD("remove recovery_file[%s] fail\n", recovery_file);
}
-static
-void response_cb2(void *data, Evas_Object *notify, void *event_info)
+static int __check_privilege_by_cookie(const char *e_cookie, int req_type)
{
- int p = 0;
- struct appdata *ad = (struct appdata *)data;
-
- DBG("start of response_cb()\n");
-
- /* NO */
- pkgmgr_installer *pi;
- gboolean ret_parse;
- gint argcp;
- gchar **argvp;
- GError *gerr = NULL;
+ guchar *cookie = NULL;
+ gsize size;
+ int ret = PMINFO_R_ERROR;
- pi = pkgmgr_installer_new();
- if (!pi) {
- DBG("Failure in creating the pkgmgr_installer object");
- return;
+ if (e_cookie == NULL) {
+ _LOGE("e_cookie is NULL!!!\n");
+ return PMINFO_R_ERROR;
}
- ret_parse = g_shell_parse_argv(ad->item->args,
- &argcp, &argvp, &gerr);
- if (FALSE == ret_parse) {
- DBG("Failed to split args: %s", ad->item->args);
- DBG("messsage: %s", gerr->message);
- pkgmgr_installer_free(pi);
- return;
+ cookie = g_base64_decode(e_cookie, &size);
+ if (cookie == NULL) {
+ _LOGE("Unable to decode cookie!!!\n");
+ return PMINFO_R_ERROR;
}
- pkgmgr_installer_receive_request(pi, argcp, argvp);
-
- pkgmgr_installer_send_signal(pi, ad->item->pkg_type,
- ad->item->pkg_name, "end",
- "cancel");
-
- pkgmgr_installer_free(pi);
- p = __get_position_from_pkg_type(ad->item->pkg_type);
- __set_backend_mode(p);
-
- /* Free resource */
- free(ad->item);
- evas_object_del(ad->notify);
- evas_object_del(ad->win);
- /***************/
- /* queue_job should be called for every request that is pushed
- into queue. In "NO" case, request is not pushed so no need of
- calling queue_job*/
-
- DBG("end of response_cb()\n");
-
- drawing_popup = 0;
-
- return;
-}
+ switch (req_type) {
+ case COMM_REQ_TO_INSTALLER:
+ ret = security_server_check_privilege_by_cookie((const char*)cookie, "pkgmgr::svc", "r");
+ if (SECURITY_SERVER_API_SUCCESS == ret)
+ ret = PMINFO_R_OK;
+ break;
+ case COMM_REQ_TO_MOVER:
+ ret = security_server_check_privilege_by_cookie((const char*)cookie, "pkgmgr::svc", "x");
+ if (SECURITY_SERVER_API_SUCCESS == ret)
+ ret = PMINFO_R_OK;
+ break;
+ case COMM_REQ_GET_JUNK_INFO:
+ ret = security_server_check_privilege_by_cookie((const char*)cookie, "junkmgr::scan", "x");
+ if (SECURITY_SERVER_API_SUCCESS == ret)
+ ret = PMINFO_R_OK;
+ break;
+ case COMM_REQ_GET_SIZE:
+ ret = security_server_check_privilege_by_cookie((const char*)cookie, "pkgmgr::info", "r");
+ if (SECURITY_SERVER_API_SUCCESS == ret)
+ ret = PMINFO_R_OK;
+ break;
-static char *__get_exe_path(const char *pkg_name)
-{
- ail_appinfo_h handle;
- ail_error_e ret;
- char *str;
- char *exe_path;
-
- ret = ail_package_get_appinfo(pkg_name, &handle);
- if (ret != AIL_ERROR_OK) {
- DBGE("ail_package_get_appinfo() failed");
- return NULL;
- }
+ case COMM_REQ_CLEAR_CACHE_DIR:
+ ret = security_server_check_privilege_by_cookie((const char*)cookie, "pkgmgr::svc", "x");
+ if (SECURITY_SERVER_API_SUCCESS == ret)
+ ret = PMINFO_R_OK;
+ break;
- ret = ail_appinfo_get_str(handle, AIL_PROP_X_SLP_EXE_PATH, &str);
- if (ret != AIL_ERROR_OK) {
- DBGE("ail_appinfo_get_str() failed");
- ail_package_destroy_appinfo(handle);
- return NULL;
+ default:
+ _LOGD("Check your request[%d]..\n", req_type);
+ break;
}
- exe_path = strdup(str);
- if (exe_path == NULL) {
- DBGE("strdup() failed");
- ail_package_destroy_appinfo(handle);
- return NULL;
- }
+ _LOGD("security_server[req-type:%d] check cookie result = %d, \n", req_type, ret);
- ret = ail_package_destroy_appinfo(handle);
- if (ret != AIL_ERROR_OK) {
- DBGE("ail_package_destroy_appinfo() failed");
- return NULL;
+ if (cookie){
+ g_free(cookie);
+ cookie = NULL;
}
- return exe_path;
+ return ret;
}
-static
-int create_popup(struct appdata *ad)
+static int __get_position_from_pkg_type(char *pkgtype)
{
- DBG("start of create_popup()\n");
-
- drawing_popup = 1;
-
- char sentence[MAX_PKG_ARGS_LEN] = { '\0' };
- char *pkg_name = NULL;
- char app_name[MAX_PKG_NAME_LEN] = { '\0' };
-
- ad->win = elm_win_add(NULL, PACKAGE, ELM_WIN_DIALOG_BASIC);
- if (!ad->win) {
- DBG("Failed to create a new window\n");
- drawing_popup = 0;
- return -1;
- }
+ int i = 0;
+ queue_info_map *ptr;
+ ptr = start;
+ for(i = 0; i < entries; i++)
+ {
+ if (!strncmp(ptr->pkgtype, pkgtype, MAX_PKG_TYPE_LEN))
+ return ptr->queue_slot;
+ else
+ ptr++;
- elm_win_alpha_set(ad->win, EINA_TRUE);
- elm_win_title_set(ad->win, "test");
- elm_win_borderless_set(ad->win, EINA_TRUE);
- elm_win_raise(ad->win);
-
- int rotation = 0;
- int w;
- int h;
- int x;
- int y;
- unsigned char *prop_data = NULL;
- int count;
- ecore_x_window_geometry_get(ecore_x_window_root_get(
- ecore_x_window_focus_get()),
- &x, &y, &w, &h);
- int ret =
- ecore_x_window_prop_property_get(ecore_x_window_root_get
- (ecore_x_window_focus_get()),
- ECORE_X_ATOM_E_ILLUME_ROTATE_ROOT_ANGLE,
- ECORE_X_ATOM_CARDINAL,
- 32, &prop_data, &count);
- if (ret && prop_data)
- memcpy(&rotation, prop_data, sizeof(int));
- if (prop_data)
- free(prop_data);
- evas_object_resize(ad->win, w, h);
- evas_object_move(ad->win, x, y);
- if (rotation != -1)
- elm_win_rotation_with_resize_set(ad->win, rotation);
-
- double s;
- s = w / DESKTOP_W;
- elm_config_scale_set(s);
-
- evas_object_show(ad->win);
-
- ad->notify = elm_popup_add(ad->win);
- if (!ad->notify) {
- DBG("failed to create notify object\n");
- evas_object_del(ad->win);
- drawing_popup = 0;
- return -1;
}
+ return -1;
+}
- /* Sentence of popup */
- pkg_name = strrchr(ad->item->pkg_name, '/') == NULL ?
- ad->item->pkg_name : strrchr(ad->item->pkg_name, '/') + 1;
-
- if (ad->op_type == OPERATION_INSTALL) {
- snprintf(sentence, sizeof(sentence) - 1, _("Install?"));
- } else if (ad->op_type == OPERATION_UNINSTALL) {
-
- ail_appinfo_h handle;
- ail_error_e ret;
- char *str;
- ret = ail_package_get_appinfo(pkg_name, &handle);
- if (ret != AIL_ERROR_OK) {
- drawing_popup = 0;
- evas_object_del(ad->notify);
- evas_object_del(ad->win);
- return -1;
- }
-
- ret = ail_appinfo_get_str(handle, AIL_PROP_NAME_STR, &str);
- if (ret != AIL_ERROR_OK) {
- ail_package_destroy_appinfo(handle);
- drawing_popup = 0;
- evas_object_del(ad->notify);
- evas_object_del(ad->win);
- return -1;
- }
-
- snprintf(app_name, sizeof(app_name) - 1, str);
-
- ret = ail_package_destroy_appinfo(handle);
- if (ret != AIL_ERROR_OK) {
- drawing_popup = 0;
- evas_object_del(ad->notify);
- evas_object_del(ad->win);
- return -1;
- }
-
- pkg_name = app_name;
-
- snprintf(sentence, sizeof(sentence) - 1, _("Uninstall?"));
- } else
- snprintf(sentence, sizeof(sentence) - 1, _("Invalid request"));
-
- elm_object_part_text_set(ad->notify, "title,text", pkg_name);
- evas_object_size_hint_weight_set(ad->notify, EVAS_HINT_EXPAND,
- EVAS_HINT_EXPAND);
-
- evas_object_show(ad->notify);
- /***********************************/
-
- elm_object_text_set(ad->notify, sentence);
-
- Evas_Object *button1 = NULL;
- Evas_Object *button2 = NULL;
-
- button1 = elm_button_add(ad->notify);
- elm_object_text_set(button1, dgettext("sys_string", "IDS_COM_SK_YES"));
- elm_object_part_content_set(ad->notify, "button1", button1);
- evas_object_smart_callback_add(button1, "clicked", response_cb1, ad);
+void __get_type_from_msg(pm_dbus_msg *item)
+{
+ char *pkgtype = NULL;
- button2 = elm_button_add(ad->notify);
- elm_object_text_set(button2, dgettext("sys_string", "IDS_COM_SK_NO"));
- elm_object_part_content_set(ad->notify, "button2", button2);
- evas_object_smart_callback_add(button2, "clicked", response_cb2, ad);
+ pkgtype = _get_type_from_zip(item->pkgid);
+ retm_if(pkgtype == NULL, "pkgtype is null for %s \n", item->pkgid);
- evas_object_show(ad->notify);
+ _LOGD("pkg type = %s, file = %s \n", pkgtype, item->pkgid);
- DBG("end of create_popup()\n");
- return 0;
+ memset((item->pkg_type),0,MAX_PKG_TYPE_LEN);
+ strncpy(item->pkg_type, pkgtype, sizeof(item->pkg_type) - 1);
+ free(pkgtype);
}
gboolean send_fail_signal(void *data)
{
- DBG("send_fail_signal start\n");
+ _LOGD("send_fail_signal start\n");
gboolean ret_parse;
gint argcp;
gchar **argvp;
pkgmgr_installer *pi;
pi = pkgmgr_installer_new();
if (!pi) {
- DBG("Failure in creating the pkgmgr_installer object");
+ _LOGD("Failure in creating the pkgmgr_installer object");
return FALSE;
}
ret_parse = g_shell_parse_argv(args,
&argcp, &argvp, &gerr);
if (FALSE == ret_parse) {
- DBG("Failed to split args: %s", args);
- DBG("messsage: %s", gerr->message);
+ _LOGD("Failed to split args: %s", args);
+ _LOGD("messsage: %s", gerr->message);
pkgmgr_installer_free(pi);
return FALSE;
}
ptr = begin;
while ((cpid = waitpid(-1, &status, WNOHANG)) > 0) {
- DBG("child exit [%d]\n", cpid);
+ _LOGD("child exit [%d]\n", cpid);
if (WIFEXITED(status)) {
- DBG("child NORMAL exit [%d]\n", cpid);
for(i = 0; i < num_of_backends; i++)
{
if (cpid == (ptr + i)->pid) {
__set_backend_free(i);
__set_backend_mode(i);
+ __unset_recovery_mode((ptr + i)->pkgid, (ptr + i)->pkgtype);
+ if (WEXITSTATUS(status)) {
+ strncpy(pname, (ptr + i)->pkgid, MAX_PKG_NAME_LEN-1);
+ strncpy(ptype, (ptr + i)->pkgtype, MAX_PKG_TYPE_LEN-1);
+ strncpy(args, (ptr + i)->args, MAX_PKG_ARGS_LEN-1);
+ g_idle_add(send_fail_signal, NULL);
+ _LOGD("child exit [%d] with error code:%d\n", cpid, WEXITSTATUS(status));
+ } else {
+ _LOGD("child NORMAL exit [%d]\n", cpid);
+ }
break;
}
}
}
else if (WIFSIGNALED(status)) {
- DBG("child SIGNALED exit [%d]\n", cpid);
- /*get the pkgname and pkgtype to send fail signal*/
+ _LOGD("child SIGNALED exit [%d]\n", cpid);
+ /*get the pkgid and pkgtype to send fail signal*/
for(i = 0; i < num_of_backends; i++)
{
if (cpid == (ptr + i)->pid) {
__set_backend_free(i);
__set_backend_mode(i);
- strncpy(pname, (ptr + i)->pkgname, MAX_PKG_NAME_LEN);
- strncpy(ptype, (ptr + i)->pkgtype, MAX_PKG_TYPE_LEN);
- strncpy(args, (ptr + i)->args, MAX_PKG_ARGS_LEN);
+ __unset_recovery_mode((ptr + i)->pkgid, (ptr + i)->pkgtype);
+ strncpy(pname, (ptr + i)->pkgid, MAX_PKG_NAME_LEN-1);
+ strncpy(ptype, (ptr + i)->pkgtype, MAX_PKG_TYPE_LEN-1);
+ strncpy(args, (ptr + i)->args, MAX_PKG_ARGS_LEN-1);
g_idle_add(send_fail_signal, NULL);
break;
}
}
-void req_cb(void *cb_data, const char *req_id, const int req_type,
- const char *pkg_type, const char *pkg_name, const char *args,
- const char *cookie, int *ret)
+static void __register_signal_handler(void)
{
static int sig_reg = 0;
- int err = -1;
- int p = 0;
-
- DBG(">> in callback >> Got request: [%s] [%d] [%s] [%s] [%s] [%s]",
- req_id, req_type, pkg_type, pkg_name, args, cookie);
-
- struct appdata *ad = (struct appdata *)cb_data;
-
- pm_dbus_msg *item = calloc(1, sizeof(pm_dbus_msg));
- memset(item, 0x00, sizeof(pm_dbus_msg));
-
- strncpy(item->req_id, req_id, sizeof(item->req_id) - 1);
- item->req_type = req_type;
- strncpy(item->pkg_type, pkg_type, sizeof(item->pkg_type) - 1);
- strncpy(item->pkg_name, pkg_name, sizeof(item->pkg_name) - 1);
- strncpy(item->args, args, sizeof(item->args) - 1);
- strncpy(item->cookie, cookie, sizeof(item->cookie) - 1);
if (sig_reg == 0) {
struct sigaction act;
act.sa_flags = SA_NOCLDSTOP;
if (sigaction(SIGCHLD, &act, NULL) < 0) {
- DBG("signal: SIGCHLD failed\n");
+ _LOGD("signal: SIGCHLD failed\n");
} else
- DBG("signal: SIGCHLD succeed\n");
+ _LOGD("signal: SIGCHLD succeed\n");
if (g_timeout_add_seconds(2, exit_server, NULL))
- DBG("g_timeout_add_seconds() Added to Main Loop");
+ _LOGD("g_timeout_add_seconds() Added to Main Loop");
sig_reg = 1;
}
+}
+
+int create_external_dir_cb(void)
+{
+ int err = -1;
+ int p = 0;
+
+ SECURE_LOGD(">> in callback >> External storage has been mounted");
+
+ __register_signal_handler();
+
+ pm_dbus_msg *item = calloc(1, sizeof(pm_dbus_msg));
+ if (item == NULL)
+ {
+ _LOGE("Out of memory");
+ return err;
+ }
+
+ item->req_type = COMM_REQ_MAKE_EXTERNAL_DIR;
+ strcpy(item->pkg_type, "rpm");
+
+ err = _pm_queue_push(item);
+ p = __get_position_from_pkg_type(item->pkg_type);
+ __set_backend_mode(p);
+ if (err == 0)
+ {
+ g_idle_add(queue_job, NULL);
+ }
+
+ free(item);
+
+ return err;
+}
+
+void req_cb(void *cb_data, const char *req_id, const int req_type,
+ const char *pkg_type, const char *pkgid, const char *args,
+ const char *cookie, int *ret)
+{
+ int err = -1;
+ int p = 0;
+ int cookie_result = 0;
+
+ SECURE_LOGD(">> in callback >> Got request: [%s] [%d] [%s] [%s] [%s] [%s]",
+ req_id, req_type, pkg_type, pkgid, args, cookie);
+
+ __register_signal_handler();
+
+ pm_dbus_msg *item = calloc(1, sizeof(pm_dbus_msg));
+ if (item == NULL)
+ {
+ _LOGE("Out of memory");
+ return;
+ }
+
+ strncpy(item->req_id, req_id, sizeof(item->req_id) - 1);
+ item->req_type = req_type;
+ strncpy(item->pkg_type, pkg_type, sizeof(item->pkg_type) - 1);
+
+ strncpy(item->pkgid, pkgid, sizeof(item->pkgid) - 1);
+ strncpy(item->args, args, sizeof(item->args) - 1);
+ strncpy(item->cookie, cookie, sizeof(item->cookie) - 1);
+
+ _LOGD("req_type=(%d) backend_flag=(%d)\n", req_type,backend_flag);
- DBG("req_type=(%d) drawing_popup=(%d) backend_flag=(%d)\n", req_type,
- drawing_popup, backend_flag);
- char *quiet = NULL;
switch (item->req_type) {
case COMM_REQ_TO_INSTALLER:
- /* -q option should be located at the end of command !! */
- if (((quiet = strstr(args, " -q")) &&
- (quiet[strlen(quiet)] == '\0')) ||
- ((quiet = strstr(args, " '-q'")) &&
- (quiet[strlen(quiet)] == '\0'))) {
- /* quiet mode */
- err = _pm_queue_push(*item);
- p = __get_position_from_pkg_type(item->pkg_type);
- __set_backend_mode(p);
- /* Free resource */
- free(item);
- if (err == 0)
- g_idle_add(queue_job, NULL);
- *ret = COMM_RET_OK;
- } else {
- /* non quiet mode */
- p = __get_position_from_pkg_type(item->pkg_type);
- if (drawing_popup == 0 &&
- !__is_backend_busy(p) &&
- __check_backend_mode()) {
- /* if there is no popup */
- ad->item = item;
-
- if (strstr(args, " -i ")
- || strstr(args, " '-i' "))
- ad->op_type = OPERATION_INSTALL;
- else if (strstr(args, " -d ")
- || strstr(args, " '-d' ")) {
- ad->op_type = OPERATION_UNINSTALL;
-
- /* 2011-04-01
- Change the mode temporarily. This should be removed */
- /*strncat(item->args, " -q",
- strlen(" -q"));*/
- } else
- ad->op_type = OPERATION_MAX;
-
- err = create_popup(ad);
- if (err != 0) {
- *ret = COMM_RET_ERROR;
- DBG("create popup failed\n");
- /*queue_job(NULL);*/
- goto err;
- } else {
- *ret = COMM_RET_OK;
- }
- } else {
- DBG("info drawing_popup:%d, __is_backend_busy(p):%d, __check_backend_mode():%d\n",
- drawing_popup, __is_backend_busy(p), __check_backend_mode());
- /* if popup is already being drawn */
- free(item);
- *ret = COMM_RET_ERROR;
- goto err;
- }
+ /* check caller privilege */
+ cookie_result = __check_privilege_by_cookie(cookie, item->req_type);
+ if (cookie_result < 0){
+ _LOGD("__check_privilege_by_cookie result fail[%d]\n", cookie_result);
+ *ret = PKGMGR_R_EPRIV;
+ goto err;
+ }
+
+ /* get pkgtype from msg-args */
+ __get_type_from_msg(item);
+
+ /* quiet mode */
+ err = _pm_queue_push(item);
+ p = __get_position_from_pkg_type(item->pkg_type);
+ if (p < 0) {
+ _LOGE("invalid or unsupported package");
+ *ret = PKGMGR_R_ERROR;
+ break;
}
+ __set_backend_mode(p);
+ if (err == 0)
+ g_idle_add(queue_job, NULL);
+ *ret = PKGMGR_R_OK;
break;
- case COMM_REQ_TO_ACTIVATOR:
- /* In case of activate, there is no popup */
- err = _pm_queue_push(*item);
+ case COMM_REQ_ACTIVATE_PKG:
+ err = _pm_queue_push(item);
p = __get_position_from_pkg_type(item->pkg_type);
__set_backend_mode(p);
- /* Free resource */
- free(item);
-
-/* g_idle_add(queue_job, NULL); */
if (err == 0)
- queue_job(NULL);
- *ret = COMM_RET_OK;
+ g_idle_add(queue_job, NULL);
+ *ret = PKGMGR_R_OK;
+ break;
+ case COMM_REQ_DEACTIVATE_PKG:
+ err = _pm_queue_push(item);
+ p = __get_position_from_pkg_type(item->pkg_type);
+ __set_backend_mode(p);
+ if (err == 0)
+ g_idle_add(queue_job, NULL);
+ *ret = PKGMGR_R_OK;
+ break;
+ case COMM_REQ_ACTIVATE_APP:
+ err = _pm_queue_push(item);
+ p = __get_position_from_pkg_type(item->pkg_type);
+ __set_backend_mode(p);
+ if (err == 0)
+ g_idle_add(queue_job, NULL);
+ *ret = PKGMGR_R_OK;
+ break;
+ case COMM_REQ_DEACTIVATE_APP:
+ err = _pm_queue_push(item);
+ p = __get_position_from_pkg_type(item->pkg_type);
+ __set_backend_mode(p);
+ if (err == 0)
+ g_idle_add(queue_job, NULL);
+ *ret = PKGMGR_R_OK;
+ break;
+ case COMM_REQ_ACTIVATE_APP_WITH_LABEL:
+ err = _pm_queue_push(item);
+ p = __get_position_from_pkg_type(item->pkg_type);
+ __set_backend_mode(p);
+ if (err == 0)
+ g_idle_add(queue_job, NULL);
+ *ret = PKGMGR_R_OK;
break;
case COMM_REQ_TO_CLEARER:
/* In case of clearer, there is no popup */
- err = _pm_queue_push(*item);
+ err = _pm_queue_push(item);
p = __get_position_from_pkg_type(item->pkg_type);
/*the backend shows the success/failure popup
so this request is non quiet*/
__unset_backend_mode(p);
- /* Free resource */
- free(item);
/* g_idle_add(queue_job, NULL); */
if (err == 0)
queue_job(NULL);
- *ret = COMM_RET_OK;
+ *ret = PKGMGR_R_OK;
+ break;
+ case COMM_REQ_TO_MOVER:
+ /* check caller privilege */
+ cookie_result = __check_privilege_by_cookie(cookie, item->req_type);
+ if (cookie_result < 0){
+ _LOGD("__check_privilege_by_cookie result fail[%d]\n", cookie_result);
+ *ret = PKGMGR_R_EPRIV;
+ goto err;
+ }
+
+ /* In case of mover, there is no popup */
+ err = _pm_queue_push(item);
+ p = __get_position_from_pkg_type(item->pkg_type);
+ /*the backend shows the success/failure popup
+ so this request is non quiet*/
+ __unset_backend_mode(p);
+ if (err == 0)
+ queue_job(NULL);
+ *ret = PKGMGR_R_OK;
break;
case COMM_REQ_CANCEL:
- ad->item = item;
- _pm_queue_delete(*(ad->item));
+ _pm_queue_delete(item);
p = __get_position_from_pkg_type(item->pkg_type);
__unset_backend_mode(p);
- free(item);
- *ret = COMM_RET_OK;
+ *ret = PKGMGR_R_OK;
+ break;
+ case COMM_REQ_GET_JUNK_INFO:
+ /* check caller privilege */
+#ifdef _APPFW_PKGMGR_PRIV_SUPPORT //XXX: Temporary define
+ cookie_result = __check_privilege_by_cookie(cookie, item->req_type);
+ if (cookie_result < 0){
+ _LOGE("__check_privilege_by_cookie result fail[%d]\n", cookie_result);
+ *ret = PKGMGR_R_EPRIV;
+ goto err;
+ }
+#endif
+ err = _pm_queue_push(item);
+ p = __get_position_from_pkg_type(item->pkg_type);
+ __set_backend_mode(p);
+ if (err == 0)
+ g_idle_add(queue_job, NULL);
+ *ret = PKGMGR_R_OK;
+ break;
+ case COMM_REQ_GET_SIZE:
+ /* check caller privilege */
+#ifdef _APPFW_PKGMGR_PRIV_SUPPORT //XXX: Temporary define
+ cookie_result = __check_privilege_by_cookie(cookie, item->req_type);
+ if (cookie_result < 0){
+ _LOGE("__check_privilege_by_cookie result fail[%d]\n", cookie_result);
+ *ret = PKGMGR_R_EPRIV;
+ goto err;
+ }
+#endif
+ err = _pm_queue_push(item);
+ p = __get_position_from_pkg_type(item->pkg_type);
+ __set_backend_mode(p);
+ if (err == 0)
+ g_idle_add(queue_job, NULL);
+ *ret = PKGMGR_R_OK;
break;
+
+ case COMM_REQ_CHECK_APP:
+ case COMM_REQ_KILL_APP:
+ /* In case of activate, there is no popup */
+ err = _pm_queue_push(item);
+ p = __get_position_from_pkg_type(item->pkg_type);
+ __set_backend_mode(p);
+
+/* g_idle_add(queue_job, NULL); */
+ if (err == 0)
+ queue_job(NULL);
+ *ret = PKGMGR_R_OK;
+ break;
+
+ case COMM_REQ_CLEAR_CACHE_DIR:
+ /* check caller privilege */
+#ifdef _APPFW_PKGMGR_PRIV_SUPPORT //XXX: Temporary define
+ cookie_result = __check_privilege_by_cookie(cookie, item->req_type);
+ if (cookie_result < 0){
+ _LOGE("__check_privilege_by_cookie result fail[%d]\n", cookie_result);
+ *ret = PKGMGR_R_EPRIV;
+ goto err;
+ }
+#endif
+ err = _pm_queue_push(item);
+ p = __get_position_from_pkg_type(item->pkg_type);
+ __set_backend_mode(p);
+
+ if (err == 0)
+ g_idle_add(queue_job, NULL);
+ *ret = PKGMGR_R_OK;
+ break;
+
default:
- DBG("Check your request..\n");
- free(item);
- *ret = COMM_RET_ERROR;
+ _LOGD("Check your request..\n");
+ *ret = PKGMGR_R_ERROR;
break;
}
-err:
- if (*ret == COMM_RET_ERROR) {
- DBG("Failed to handle request %s %s\n",item->pkg_type, item->pkg_name);
- pkgmgr_installer *pi;
- gboolean ret_parse;
- gint argcp;
- gchar **argvp;
- GError *gerr = NULL;
+err:
+ if (*ret != PKGMGR_R_OK) {
+ _LOGD("Failed to handle request %s %s\n",item->pkg_type, item->pkgid);
+ pkgmgr_installer *pi;
+ gboolean ret_parse;
+ gint argcp;
+ gchar **argvp;
+ GError *gerr = NULL;
+
+ pi = pkgmgr_installer_new();
+ if (!pi) {
+ _LOGD("Failure in creating the pkgmgr_installer object");
+ if(item){
+ free(item);
+ item = NULL;
+ }
+ return;
+ }
+
+ ret_parse = g_shell_parse_argv(args, &argcp, &argvp, &gerr);
+ if (FALSE == ret_parse) {
+ _LOGD("Failed to split args: %s", args);
+ _LOGD("messsage: %s", gerr->message);
+ pkgmgr_installer_free(pi);
+ if(item){
+ free(item);
+ item = NULL;
+ }
+ return;
+ }
+
+ pkgmgr_installer_receive_request(pi, argcp, argvp);
+
+ pkgmgr_installer_send_signal(pi, item->pkg_type,
+ item->pkgid, "end",
+ "fail");
+
+ pkgmgr_installer_free(pi);
+
+ }
+
+ if(item){
+ free(item);
+ item = NULL;
+ }
+ return;
+}
+
+static int __check_backend_status_for_exit()
+{
+ int i = 0;
+ for(i = 0; i < num_of_backends; i++)
+ {
+ if (!__is_backend_busy(i))
+ continue;
+ else
+ return 0;
+ }
+ return 1;
+}
+
+static int __check_queue_status_for_exit()
+{
+ pm_queue_data *head[MAX_QUEUE_NUM] = {NULL,};
+ queue_info_map *ptr = NULL;
+ ptr = start;
+ int i = 0;
+ int c = 0;
+ int slot = -1;
+ for(i = 0; i < entries; i++)
+ {
+ if (ptr->queue_slot <= slot) {
+ ptr++;
+ continue;
+ }
+ else {
+ head[c] = ptr->head;
+ slot = ptr->queue_slot;
+ c++;
+ ptr++;
+ }
+ }
+ for(i = 0; i < num_of_backends; i++)
+ {
+ if (!head[i])
+ continue;
+ else
+ return 0;
+ }
+ return 1;
+}
+
+gboolean exit_server(void *data)
+{
+ _LOGD("exit_server Start\n");
+ if (__check_backend_status_for_exit() && __check_queue_status_for_exit()) {
+ if (!getenv("PMS_STANDALONE")) {
+ g_main_loop_quit(mainloop);
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+static int __pkgcmd_read_proc(const char *path, char *buf, int size)
+{
+ int fd;
+ int ret;
+ if (buf == NULL || path == NULL)
+ return -1;
+ fd = open(path, O_RDONLY);
+ if (fd < 0)
+ return -1;
+ ret = read(fd, buf, size - 1);
+ if (ret <= 0) {
+ close(fd);
+ return -1;
+ } else
+ buf[ret] = 0;
+ close(fd);
+ return ret;
+}
+
+static int __pkgcmd_find_pid_by_cmdline(const char *dname,
+ const char *cmdline, const char *apppath)
+{
+ int pid = 0;
+
+ if (strcmp(cmdline, apppath) == 0) {
+ pid = atoi(dname);
+ if (pid != getpgid(pid))
+ pid = 0;
+ }
+ return pid;
+}
+
+static int __pkgcmd_proc_iter_kill_cmdline(const char *apppath, int option)
+{
+ DIR *dp;
+ struct dirent *dentry;
+ int pid;
+ int ret;
+ char buf[1024] = {'\0'};
+ int pgid;
+
+ dp = opendir("/proc");
+ if (dp == NULL) {
+ return -1;
+ }
+
+ while ((dentry = readdir(dp)) != NULL) {
+ if (!isdigit(dentry->d_name[0]))
+ continue;
+
+ snprintf(buf, sizeof(buf), "/proc/%s/cmdline", dentry->d_name);
+ ret = __pkgcmd_read_proc(buf, buf, sizeof(buf));
+ if (ret <= 0)
+ continue;
+
+ pid = __pkgcmd_find_pid_by_cmdline(dentry->d_name, buf, apppath);
+ if (pid > 0) {
+ if (option == 0) {
+ closedir(dp);
+ return pid;
+ }
+ pgid = getpgid(pid);
+ if (pgid <= 1) {
+ closedir(dp);
+ return -1;
+ }
+ if (killpg(pgid, SIGKILL) < 0) {
+ closedir(dp);
+ return -1;
+ }
+ closedir(dp);
+ return pid;
+ }
+ }
+ closedir(dp);
+ return 0;
+}
+
+static void __make_pid_info_file(char *req_key, int size)
+{
+ int ret = 0;
+ FILE* file = NULL;
+ int fd = 0;
+ char buf[MAX_PKG_TYPE_LEN] = {0};
+ const char* app_info_label = "*";
+ char info_file[MAX_PKG_TYPE_LEN] = {'\0', };
+
+ if(req_key == NULL)
+ return;
+
+ snprintf(info_file, MAX_PKG_TYPE_LEN, "/tmp/%s", req_key);
+ _LOGD("File path = %s\n", info_file);
+
+ file = fopen(info_file, "w");
+ if (file == NULL) {
+ _LOGE("Couldn't open the file %s \n", info_file);
+ return;
+ }
+
+ snprintf(buf, 128, "%d\n", size);
+ fwrite(buf, 1, strlen(buf), file);
+
+ fflush(file);
+ fd = fileno(file);
+ fsync(fd);
+ fclose(file);
+
+ if(lsetxattr(info_file, "security.SMACK64", app_info_label, strlen(app_info_label), 0)) {
+ _LOGE("error(%d) in setting smack label",errno);
+ }
+ ret = chmod(info_file, 0777);
+ if(ret < 0)
+ return;
+ ret = chown(info_file, 5000, 5000);
+ if(ret < 0)
+ return;
+}
+
+static int __pkgcmd_app_cb(const pkgmgrinfo_appinfo_h handle, void *user_data)
+{
+ char *pkgid = NULL;
+ char *exec = NULL;
+ int ret = 0;
+ int pid = -1;
+ if (handle == NULL) {
+ perror("appinfo handle is NULL\n");
+ exit(1);
+ }
+ ret = pkgmgrinfo_appinfo_get_exec(handle, &exec);
+ if (ret) {
+ perror("Failed to get app exec path\n");
+ exit(1);
+ }
+ ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
+ if (ret) {
+ perror("Failed to get appid\n");
+ exit(1);
+ }
+
+ if (strcmp(user_data, "kill") == 0)
+ pid = __pkgcmd_proc_iter_kill_cmdline(exec, 1);
+ else if(strcmp(user_data, "check") == 0)
+ pid = __pkgcmd_proc_iter_kill_cmdline(exec, 0);
+
+// vconf_set_int(VCONFKEY_PKGMGR_STATUS, pid);
+ __make_pid_info_file(pkgid, pid);
+
+ return 0;
+}
+
+void __pm_send_sub_signal(const char *req_id, const char *pkg_type, const char *pkgid, const char *key, const char *val)
+{
+ dbus_uint32_t serial = 0;
+ DBusMessage *msg = NULL;
+ DBusMessageIter args;
+ DBusError err;
+ DBusConnection *conn = NULL;
+ const char *values[] = {
+ req_id,
+ pkg_type,
+ pkgid,
+ key,
+ val
+ };
+ int i;
+
+ dbus_error_init(&err);
+
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
+ if (dbus_error_is_set(&err)) {
+ _LOGE("Connection error: %s", err.message);
+ dbus_error_free(&err);
+ }
+ dbus_error_free(&err);
+ if (NULL == conn) {
+ _LOGE("conn is NULL");
+ return;
+ }
- pi = pkgmgr_installer_new();
- if (!pi) {
- DBG("Failure in creating the pkgmgr_installer object");
- return;
+ if (strcmp(key,PKGMGR_INSTALLER_START_KEY_STR) == 0) {
+ if (strcmp(val,PKGMGR_INSTALLER_INSTALL_EVENT_STR) == 0) {
+ msg = dbus_message_new_signal(COMM_STATUS_BROADCAST_DBUS_INSTALL_PATH, COMM_STATUS_BROADCAST_DBUS_INSTALL_INTERFACE, COMM_STATUS_BROADCAST_EVENT_INSTALL);
+ } else if (strcmp(val,PKGMGR_INSTALLER_UNINSTALL_EVENT_STR) == 0) {
+ msg = dbus_message_new_signal(COMM_STATUS_BROADCAST_DBUS_UNINSTALL_PATH, COMM_STATUS_BROADCAST_DBUS_UNINSTALL_INTERFACE, COMM_STATUS_BROADCAST_EVENT_UNINSTALL);
+ } else if (strcmp(val,PKGMGR_INSTALLER_UPGRADE_EVENT_STR) == 0) {
+ msg = dbus_message_new_signal(COMM_STATUS_BROADCAST_DBUS_UPGRADE_PATH, COMM_STATUS_BROADCAST_DBUS_UPGRADE_INTERFACE, COMM_STATUS_BROADCAST_EVENT_UPGRADE);
+ }
+ } else if (strcmp(key,PKGMGR_INSTALLER_END_KEY_STR) == 0) {
+ if (strcmp(req_id,PKGMGR_INSTALLER_INSTALL_EVENT_STR) == 0) {
+ msg = dbus_message_new_signal(COMM_STATUS_BROADCAST_DBUS_INSTALL_PATH, COMM_STATUS_BROADCAST_DBUS_INSTALL_INTERFACE, COMM_STATUS_BROADCAST_EVENT_INSTALL);
+ } else if (strcmp(req_id,PKGMGR_INSTALLER_UNINSTALL_EVENT_STR) == 0) {
+ msg = dbus_message_new_signal(COMM_STATUS_BROADCAST_DBUS_UNINSTALL_PATH, COMM_STATUS_BROADCAST_DBUS_UNINSTALL_INTERFACE, COMM_STATUS_BROADCAST_EVENT_UNINSTALL);
+ } else if (strcmp(req_id,PKGMGR_INSTALLER_UPGRADE_EVENT_STR) == 0) {
+ msg = dbus_message_new_signal(COMM_STATUS_BROADCAST_DBUS_UPGRADE_PATH, COMM_STATUS_BROADCAST_DBUS_UPGRADE_INTERFACE, COMM_STATUS_BROADCAST_EVENT_UPGRADE);
}
+ }
+ if (NULL == msg) {
+ _LOGE("msg NULL");
+ return;
+ }
- ret_parse = g_shell_parse_argv(args, &argcp, &argvp, &gerr);
- if (FALSE == ret_parse) {
- DBG("Failed to split args: %s", args);
- DBG("messsage: %s", gerr->message);
- pkgmgr_installer_free(pi);
+ dbus_message_iter_init_append(msg, &args);
+
+ for (i = 0; i < 5; i++) {
+ if (!dbus_message_iter_append_basic
+ (&args, DBUS_TYPE_STRING, &(values[i]))) {
+ _LOGE("dbus_message_iter_append_basic failed:"
+ " Out of memory");
return;
}
+ }
+ if (!dbus_connection_send(conn, msg, &serial)) {
+ _LOGE("dbus_connection_send failed: Out of memory");
+ return;
+ }
+ dbus_connection_flush(conn);
+ dbus_message_unref(msg);
+}
- pkgmgr_installer_receive_request(pi, argcp, argvp);
+void __pm_send_signal(const char *req_id, const char *pkg_type, const char *pkgid, const char *key, const char *val)
+{
+ dbus_uint32_t serial = 0;
+ DBusMessage *msg;
+ DBusMessageIter args;
+ DBusError err;
+ DBusConnection *conn;
+ const char *values[] = {
+ req_id,
+ pkg_type,
+ pkgid,
+ key,
+ val
+ };
+ int i;
+
+ dbus_error_init(&err);
+
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
+ if (dbus_error_is_set(&err)) {
+ _LOGE("Connection error: %s", err.message);
+ dbus_error_free(&err);
+ }
+ dbus_error_free(&err);
+ if (NULL == conn) {
+ _LOGE("conn is NULL");
+ return;
+ }
- pkgmgr_installer_send_signal(pi, item->pkg_type,
- item->pkg_name, "end",
- "fail");
+ msg = dbus_message_new_signal(COMM_STATUS_BROADCAST_DBUS_PATH, COMM_STATUS_BROADCAST_DBUS_INTERFACE, COMM_STATUS_BROADCAST_SIGNAL_STATUS);
+ if (NULL == msg) {
+ _LOGE("msg NULL");
+ return;
+ }
- pkgmgr_installer_free(pi);
+ dbus_message_iter_init_append(msg, &args);
+
+ for (i = 0; i < 5; i++) {
+ if (!dbus_message_iter_append_basic
+ (&args, DBUS_TYPE_STRING, &(values[i]))) {
+ _LOGE("dbus_message_iter_append_basic failed: Out of memory");
+ return;
+ }
}
- return;
+ if (!dbus_connection_send(conn, msg, &serial)) {
+ _LOGE("dbus_connection_send failed: Out of memory");
+ return;
+ }
+ dbus_connection_flush(conn);
+ dbus_message_unref(msg);
+
+ __pm_send_sub_signal(req_id, pkg_type, pkgid, key, val);
}
-static int __check_backend_mode()
+void __change_item_info(pm_dbus_msg *item)
{
- int i = 0;
- for(i = 0; i < num_of_backends; i++)
- {
- if (__is_backend_mode_quiet(i))
- continue;
- else
- return 0;
+ int ret = 0;
+ char *pkgid = NULL;
+ pkgmgrinfo_appinfo_h handle = NULL;
+
+ ret = pkgmgrinfo_appinfo_get_appinfo(item->pkgid, &handle);
+ if (ret != PMINFO_R_OK)
+ return;
+
+ ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
+ if (ret != PMINFO_R_OK) {
+ pkgmgrinfo_appinfo_destroy_appinfo(handle);
+ return;
}
- return 1;
+
+ memset((item->pkgid),0,MAX_PKG_NAME_LEN);
+ strncpy(item->pkgid, pkgid, sizeof(item->pkgid) - 1);
+
+ pkgmgrinfo_appinfo_destroy_appinfo(handle);
}
-static int __check_backend_status_for_exit()
+
+static char **__generate_argv(const char *args)
{
- int i = 0;
- for(i = 0; i < num_of_backends; i++)
+ /* Create args vector
+ * req_id + pkgid + args
+ *
+ * vector size = # of args +
+ *(req_id + pkgid + NULL termination = 3)
+ * Last value must be NULL for execv.
+ */
+ gboolean ret_parse;
+ gint argcp;
+ gchar **argvp;
+ GError *gerr = NULL;
+ ret_parse = g_shell_parse_argv(args,
+ &argcp, &argvp, &gerr);
+ if (FALSE == ret_parse) {
+ _LOGD("Failed to split args: %s", args);
+ _LOGD("messsage: %s", gerr->message);
+ exit(1);
+ }
+
+ /* Setup argument !!! */
+ /*char **args_vector =
+ calloc(argcp + 4, sizeof(char *)); */
+ char **args_vector = calloc(argcp + 1, sizeof(char *));
+ if (args_vector == NULL)
{
- if (!__is_backend_busy(i))
- continue;
- else
- return 0;
+ _LOGE("Out of memory");
+ exit(1);
}
- return 1;
+ /*args_vector[0] = strdup(backend_cmd);
+ args_vector[1] = strdup(item->req_id);
+ args_vector[2] = strdup(item->pkgid); */
+ int arg_idx;
+ for (arg_idx = 0; arg_idx < argcp; arg_idx++) {
+ /* args_vector[arg_idx+3] = argvp[arg_idx]; */
+ args_vector[arg_idx] = argvp[arg_idx];
+ }
+
+ /* dbg */
+ /*for(arg_idx = 0; arg_idx < argcp+3; arg_idx++) { */
+ for (arg_idx = 0; arg_idx < argcp + 1; arg_idx++) {
+ _LOGD(">>>>>> args_vector[%d]=%s", arg_idx, args_vector[arg_idx]);
+ }
+
+ return args_vector;
}
-static int __check_queue_status_for_exit()
+static void __exec_with_arg_vector(const char* cmd, char** argv)
{
- pm_queue_data *head[num_of_backends];
- queue_info_map *ptr = NULL;
- ptr = start;
- int i = 0;
- int c = 0;
- int slot = -1;
- for(i = 0; i < entries; i++)
+ char *backend_cmd = strdup(cmd);
+ if (NULL == backend_cmd)
{
- if (ptr->queue_slot <= slot) {
- ptr++;
- continue;
- }
- else {
- head[c] = ptr->head;
- slot = ptr->queue_slot;
- c++;
- ptr++;
- }
+ perror("Out of memory");
+ exit(1);
}
- for(i = 0; i < num_of_backends; i++)
- {
- if (!head[i])
- continue;
- else
- return 0;
+
+ _LOGD("Try to exec [%s]", backend_cmd);
+ fprintf(stdout, "Try to exec [%s]\n", backend_cmd);
+
+ /* Execute backend !!! */
+ int ret = execv(backend_cmd, argv);
+
+ /* Code below: exec failure. Should not be happened! */
+ _LOGD(">>>>>> OOPS 2!!!");
+
+ /* g_strfreev(args_vector); *//* FIXME: causes error */
+
+ if (ret == -1) {
+ perror("fail to exec");
+ exit(1);
}
- return 1;
+ if (NULL != backend_cmd)
+ free(backend_cmd);
}
-gboolean exit_server(void *data)
+
+static int __set_activation_info(char *pkgid, int is_active, char *label)
{
- DBG("exit_server Start\n");
- if (__check_backend_status_for_exit() &&
- __check_queue_status_for_exit() &&
- drawing_popup == 0) {
- if (!getenv("PMS_STANDALONE") && ail_db_update) {
- ecore_main_loop_quit();
- return FALSE;
- }
- }
- return TRUE;
+ char activation_info_file[MAX_PKG_NAME_LEN] = { 0, };
+ snprintf(activation_info_file, MAX_PKG_NAME_LEN, "%s/%s", PKG_DATA_PATH, pkgid);
+
+ if (is_active) {
+ int ret = 0;
+ const char* app_info_label = "_";
+
+ if(lsetxattr(activation_info_file, "security.SMACK64", app_info_label, strlen(app_info_label), 0)) {
+ _LOGE("error(%d) in setting smack label",errno);
+ return PMINFO_R_ERROR;
+ }
+ ret = chmod(activation_info_file, 0755);
+ if(ret < 0) {
+ _LOGE("chmod[%s] fail",activation_info_file);
+ return PMINFO_R_ERROR;
+ }
+ ret = chown(activation_info_file, 5000, 5000);
+ if(ret < 0) {
+ _LOGE("chmod[%s] fail",activation_info_file);
+ return PMINFO_R_ERROR;
+ }
+ } else {
+ (void)remove(activation_info_file);
+ }
+ return PMINFO_R_OK;
}
gboolean queue_job(void *data)
{
- /* DBG("queue_job start"); */
- pm_dbus_msg item;
+ /* _LOGD("queue_job start"); */
+ pm_dbus_msg *item;
backend_info *ptr = NULL;
ptr = begin;
int x = 0;
+ pkgmgrinfo_pkginfo_h handle;
+
/* Pop a job from queue */
pop:
if (!__is_backend_busy(pos % num_of_backends)) {
char *backend_cmd = NULL;
/* queue is empty and backend process is not running */
- if (item.req_type == -1) {
+ if ( (item == NULL) || (item->req_type == -1) ) {
+ if(item)
+ free(item);
goto pop;
}
__set_backend_busy((pos + num_of_backends - 1) % num_of_backends);
-
- switch (item.req_type) {
- case COMM_REQ_TO_INSTALLER:
- DBG("installer start");
- _save_queue_status(item, "processing");
- DBG("saved queue status. Now try fork()");
- /*save pkg type and pkg name for future*/
- x = (pos + num_of_backends - 1) % num_of_backends;
- strncpy((ptr + x)->pkgtype, item.pkg_type, MAX_PKG_TYPE_LEN);
- strncpy((ptr + x)->pkgname, item.pkg_name, MAX_PKG_NAME_LEN);
- strncpy((ptr + x)->args, item.args, MAX_PKG_ARGS_LEN);
- (ptr + x)->pid = fork();
- DBG("child forked [%d]\n", (ptr + x)->pid);
-
- switch ((ptr + x)->pid) {
- case 0: /* child */
- DBG("before run _get_backend_cmd()");
- backend_cmd = _get_backend_cmd(item.pkg_type);
+ __set_recovery_mode(item->pkgid, item->pkg_type);
+
+ /* fork */
+ _save_queue_status(item, "processing");
+ _LOGD("saved queue status. Now try fork()");
+ /*save pkg type and pkg name for future*/
+ x = (pos + num_of_backends - 1) % num_of_backends;
+ strncpy((ptr + x)->pkgtype, item->pkg_type, MAX_PKG_TYPE_LEN-1);
+ strncpy((ptr + x)->pkgid, item->pkgid, MAX_PKG_NAME_LEN-1);
+ strncpy((ptr + x)->args, item->args, MAX_PKG_ARGS_LEN-1);
+ (ptr + x)->pid = fork();
+ _LOGD("child forked [%d] for request type [%d]", (ptr + x)->pid, item->req_type);
+
+ switch ((ptr + x)->pid) {
+ case 0: /* child */
+ switch (item->req_type) {
+ case COMM_REQ_TO_INSTALLER:
+ _LOGD("before run _get_backend_cmd()");
+ backend_cmd = _get_backend_cmd(item->pkg_type);
if (NULL == backend_cmd)
break;
- DBG("Try to exec [%s][%s]", item.pkg_type,
- backend_cmd);
- fprintf(stdout, "Try to exec [%s][%s]\n",
- item.pkg_type, backend_cmd);
-
- /* Create args vector
- * req_id + pkg_name + args
- *
- * vector size = # of args +
- *(req_id + pkg_name + NULL termination = 3)
- * Last value must be NULL for execv.
- */
- gboolean ret_parse;
- gint argcp;
- gchar **argvp;
- GError *gerr = NULL;
- ret_parse = g_shell_parse_argv(item.args,
- &argcp, &argvp, &gerr);
- if (FALSE == ret_parse) {
- DBG("Failed to split args: %s", item.args);
- DBG("messsage: %s", gerr->message);
- exit(1);
- }
-
- /* Setup argument !!! */
- /*char **args_vector =
- calloc(argcp + 4, sizeof(char *)); */
- char **args_vector = calloc(argcp + 1, sizeof(char *));
- /*args_vector[0] = strdup(backend_cmd);
- args_vector[1] = strdup(item.req_id);
- args_vector[2] = strdup(item.pkg_name); */
- int arg_idx;
- for (arg_idx = 0; arg_idx < argcp; arg_idx++) {
- /* args_vector[arg_idx+3] = argvp[arg_idx]; */
- args_vector[arg_idx] = argvp[arg_idx];
- }
+ _LOGD("Try to exec [%s][%s]", item->pkg_type, backend_cmd);
+ fprintf(stdout, "Try to exec [%s][%s]\n", item->pkg_type, backend_cmd);
- /* dbg */
- /*for(arg_idx = 0; arg_idx < argcp+3; arg_idx++) { */
- for (arg_idx = 0; arg_idx < argcp + 1; arg_idx++) {
- DBG(">>>>>> args_vector[%d]=%s",
- arg_idx, args_vector[arg_idx]);
- }
+ char **args_vector = __generate_argv(item->args);
+ args_vector[0] = backend_cmd;
/* Execute backend !!! */
- ret = execv(backend_cmd, args_vector);
-
- /* Code below: exec failure. Should not be happened! */
- DBG(">>>>>> OOPS 2!!!");
+ __exec_with_arg_vector(backend_cmd, args_vector);
+ free(backend_cmd);
+ break;
+ case COMM_REQ_ACTIVATE_PKG:
+ _LOGE("ACTIVATE_PKG start [pkgid = %s]",item->pkgid);
- /* g_strfreev(args_vector); *//* FIXME: causes error */
+ __pm_send_signal(PKGMGR_INSTALLER_INSTALL_EVENT_STR, item->pkg_type, item->pkgid, PKGMGR_INSTALLER_START_KEY_STR, PKGMGR_INSTALLER_INSTALL_EVENT_STR);
- if (ret == -1) {
- perror("fail to exec");
+ ret = pkgmgr_parser_enable_pkg(item->pkgid, NULL);
+ if (ret < 0) {
+ __pm_send_signal(PKGMGR_INSTALLER_INSTALL_EVENT_STR, item->pkg_type, item->pkgid, PKGMGR_INSTALLER_END_KEY_STR, PKGMGR_INSTALLER_FAIL_EVENT_STR);
+ _LOGE("COMM_REQ_TO_ACTIVATOR failed\n");
exit(1);
}
- _save_queue_status(item, "done");
- if (NULL != backend_cmd)
- free(backend_cmd);
- exit(0); /* exit */
- break;
+ __pm_send_signal(PKGMGR_INSTALLER_INSTALL_EVENT_STR, item->pkg_type, item->pkgid, PKGMGR_INSTALLER_END_KEY_STR, PKGMGR_INSTALLER_OK_EVENT_STR);
- case -1: /* error */
- fprintf(stderr, "Fail to execute fork()\n");
- exit(1);
+ _LOGE("ACTIVATE_PKG end [pkgid = %s, ret = %d]",item->pkgid, ret);
break;
+ case COMM_REQ_DEACTIVATE_PKG:
+ _LOGE("DEACTIVATE_PKG start [pkgid = %s]",item->pkgid);
- default: /* parent */
- DBG("parent \n");
- _save_queue_status(item, "done");
- break;
- }
- break;
- case COMM_REQ_TO_ACTIVATOR:
- DBG("activator start");
- int val = 0;
- _save_queue_status(item, "processing");
- DBG("saved queue status. Now try fork()");
- /*save pkg type and pkg name for future*/
- x = (pos + num_of_backends - 1) % num_of_backends;
- strncpy((ptr + x)->pkgtype, item.pkg_type, MAX_PKG_TYPE_LEN);
- strncpy((ptr + x)->pkgname, item.pkg_name, MAX_PKG_NAME_LEN);
- strncpy((ptr + x)->args, item.args, MAX_PKG_ARGS_LEN);
- (ptr + x)->pid = fork();
- DBG("child forked [%d]\n", (ptr + x)->pid);
-
- switch ((ptr + x)->pid) {
- case 0: /* child */
- if (item.args[0] == '1') /* activate */
- val = 0;
- else if (item.args[0] == '0') /* deactivate */
- val = 1;
- else {
- DBG("error in args parameter:[%c]\n",
- item.args[0]);
+ __pm_send_signal(PKGMGR_INSTALLER_UNINSTALL_EVENT_STR, item->pkg_type, item->pkgid, PKGMGR_INSTALLER_START_KEY_STR, PKGMGR_INSTALLER_UNINSTALL_EVENT_STR);
+
+ /*listener need 100ms sleep to get pkginfo */
+ usleep(100 * 1000);
+ ret = pkgmgr_parser_disable_pkg(item->pkgid, NULL);
+ if (ret < 0) {
+ __pm_send_signal(PKGMGR_INSTALLER_UNINSTALL_EVENT_STR, item->pkg_type, item->pkgid, PKGMGR_INSTALLER_END_KEY_STR, PKGMGR_INSTALLER_FAIL_EVENT_STR);
+ _LOGE("COMM_REQ_DEACTIVATE_PKG failed\n");
exit(1);
}
+ __pm_send_signal(PKGMGR_INSTALLER_UNINSTALL_EVENT_STR, item->pkg_type, item->pkgid, PKGMGR_INSTALLER_END_KEY_STR, PKGMGR_INSTALLER_OK_EVENT_STR);
- DBG("inactivated val %d", val);
+ _LOGE("DEACTIVATE_PKG end [pkgid = %s, ret = %d]",item->pkgid, ret);
+ break;
+ case COMM_REQ_ACTIVATE_APP:
+ _LOGE("ACTIVATE_APP [appid = %s]",item->pkgid);
+
+ ret = __set_activation_info(item->pkgid, 1, NULL);
- ret = ail_desktop_appinfo_modify_bool(item.pkg_name,
- AIL_PROP_X_SLP_INACTIVATED_BOOL,
- val);
- if (ret != AIL_ERROR_OK) {
- perror("fail to activate/deactivte package");
+ __change_item_info(item);
+
+ __pm_send_signal(PKGMGR_INSTALLER_UPGRADE_EVENT_STR, item->pkg_type, item->pkgid, PKGMGR_INSTALLER_START_KEY_STR, PKGMGR_INSTALLER_UPGRADE_EVENT_STR);
+ if (ret != PMINFO_R_OK) {
+ __pm_send_signal(PKGMGR_INSTALLER_UPGRADE_EVENT_STR, item->pkg_type, item->pkgid, PKGMGR_INSTALLER_END_KEY_STR, PKGMGR_INSTALLER_FAIL_EVENT_STR);
+ _LOGE("COMM_REQ_ACTIVATE_APP failed\n");
exit(1);
}
- _save_queue_status(item, "done");
- exit(0); /* exit with */
- break;
+ __pm_send_signal(PKGMGR_INSTALLER_UPGRADE_EVENT_STR, item->pkg_type, item->pkgid, PKGMGR_INSTALLER_END_KEY_STR, PKGMGR_INSTALLER_OK_EVENT_STR);
- case -1: /* error */
- fprintf(stderr, "Fail to execute fork()\n");
- exit(1);
+ _LOGE("ACTIVATE_APP end [pkgid = %s, ret = %d]",item->pkgid, ret);
break;
+ case COMM_REQ_DEACTIVATE_APP:
+ _LOGE("DEACTIVATE_APP [appid = %s]",item->pkgid);
- default: /* parent */
- DBG("parent exit\n");
- _save_queue_status(item, "done");
- break;
- }
- break;
- case COMM_REQ_TO_CLEARER:
- DBG("cleaner start");
- _save_queue_status(item, "processing");
- DBG("saved queue status. Now try fork()");
- /*save pkg type and pkg name for future*/
- x = (pos + num_of_backends - 1) % num_of_backends;
- strncpy((ptr + x)->pkgtype, item.pkg_type, MAX_PKG_TYPE_LEN);
- strncpy((ptr + x)->pkgname, item.pkg_name, MAX_PKG_NAME_LEN);
- strncpy((ptr + x)->args, item.args, MAX_PKG_ARGS_LEN);
- (ptr + x)->pid = fork();
- DBG("child forked [%d]\n", (ptr + x)->pid);
-
- switch ((ptr + x)->pid) {
- case 0: /* child */
- DBG("before run _get_backend_cmd()");
- backend_cmd = _get_backend_cmd(item.pkg_type);
- if (NULL == backend_cmd)
- break;
+ ret = __set_activation_info(item->pkgid, 0, NULL);
- DBG("Try to exec [%s][%s]", item.pkg_type,
- backend_cmd);
- fprintf(stdout, "Try to exec [%s][%s]\n",
- item.pkg_type, backend_cmd);
-
- /* Create args vector
- * req_id + pkg_name + args
- *
- * vector size = # of args +
- *(req_id + pkg_name + NULL termination = 3)
- * Last value must be NULL for execv.
- */
- gboolean ret_parse;
- gint argcp;
- gchar **argvp;
- GError *gerr = NULL;
- ret_parse = g_shell_parse_argv(item.args,
- &argcp, &argvp, &gerr);
- if (FALSE == ret_parse) {
- DBG("Failed to split args: %s", item.args);
- DBG("messsage: %s", gerr->message);
+ __change_item_info(item);
+
+ __pm_send_signal(PKGMGR_INSTALLER_UPGRADE_EVENT_STR, item->pkg_type, item->pkgid, PKGMGR_INSTALLER_START_KEY_STR, PKGMGR_INSTALLER_UPGRADE_EVENT_STR);
+ if (ret != PMINFO_R_OK) {
+ __pm_send_signal(PKGMGR_INSTALLER_UPGRADE_EVENT_STR, item->pkg_type, item->pkgid, PKGMGR_INSTALLER_END_KEY_STR, PKGMGR_INSTALLER_FAIL_EVENT_STR);
+ _LOGE("COMM_REQ_ACTIVATE_APP failed\n");
exit(1);
}
+ __pm_send_signal(PKGMGR_INSTALLER_UPGRADE_EVENT_STR, item->pkg_type, item->pkgid, PKGMGR_INSTALLER_END_KEY_STR, PKGMGR_INSTALLER_OK_EVENT_STR);
- /* Setup argument !!! */
- /*char **args_vector =
- calloc(argcp + 4, sizeof(char *)); */
- char **args_vector = calloc(argcp + 1, sizeof(char *));
- /*args_vector[0] = strdup(backend_cmd);
- args_vector[1] = strdup(item.req_id);
- args_vector[2] = strdup(item.pkg_name); */
- int arg_idx;
- for (arg_idx = 0; arg_idx < argcp; arg_idx++) {
- /* args_vector[arg_idx+3] = argvp[arg_idx]; */
- args_vector[arg_idx] = argvp[arg_idx];
- }
+ _LOGE("DEACTIVATE_APP end [pkgid = %s, ret = %d]",item->pkgid, ret);
+ break;
+ case COMM_REQ_ACTIVATE_APP_WITH_LABEL:
+ _LOGE("ACTIVATE_APP_WITH_LABEL [appid = %s, label = %s]",item->pkgid, item->args);
+
+ ret = __set_activation_info(item->pkgid, 1, item->args);
- /* dbg */
- /*for(arg_idx = 0; arg_idx < argcp+3; arg_idx++) { */
- for (arg_idx = 0; arg_idx < argcp + 1; arg_idx++) {
- DBG(">>>>>> args_vector[%d]=%s",
- arg_idx, args_vector[arg_idx]);
+ __change_item_info(item);
+
+ __pm_send_signal(PKGMGR_INSTALLER_UPGRADE_EVENT_STR, item->pkg_type, item->pkgid, PKGMGR_INSTALLER_START_KEY_STR, PKGMGR_INSTALLER_UPGRADE_EVENT_STR);
+ if (ret != PMINFO_R_OK) {
+ __pm_send_signal(PKGMGR_INSTALLER_UPGRADE_EVENT_STR, item->pkg_type, item->pkgid, PKGMGR_INSTALLER_END_KEY_STR, PKGMGR_INSTALLER_FAIL_EVENT_STR);
+ _LOGE("COMM_REQ_TO_ACTIVATOR failed\n");
+ exit(1);
}
+ __pm_send_signal(PKGMGR_INSTALLER_UPGRADE_EVENT_STR, item->pkg_type, item->pkgid, PKGMGR_INSTALLER_END_KEY_STR, PKGMGR_INSTALLER_OK_EVENT_STR);
- /* Execute backend !!! */
- ret = execv(backend_cmd, args_vector);
+ _LOGE("ACTIVATE_APP_WITH_LABEL end [pkgid = %s, ret = %d]",item->pkgid, ret);
+ break;
+ case COMM_REQ_TO_MOVER:
+ case COMM_REQ_TO_CLEARER:
+ _LOGD("before run _get_backend_cmd()");
+ backend_cmd = _get_backend_cmd(item->pkg_type);
+ if (NULL == backend_cmd)
+ break;
- /* Code below: exec failure. Should not be happened! */
- DBG(">>>>>> OOPS 2!!!");
+ _LOGD("Try to exec [%s][%s]", item->pkg_type, backend_cmd);
+ fprintf(stdout, "Try to exec [%s][%s]\n", item->pkg_type, backend_cmd);
- /* g_strfreev(args_vector); *//* FIXME: causes error */
+ char **args_vectors = __generate_argv(item->args);
+ args_vectors[0] = backend_cmd;
- if (ret == -1) {
- perror("fail to exec");
+ /* Execute backend !!! */
+ __exec_with_arg_vector(backend_cmd, args_vectors);
+ free(backend_cmd);
+ break;
+ case COMM_REQ_GET_JUNK_INFO:
+ __exec_with_arg_vector("usr/bin/pkg_getjunkinfo", __generate_argv(item->args));
+ break;
+ case COMM_REQ_GET_SIZE:
+ __exec_with_arg_vector("usr/bin/pkg_getsize", __generate_argv(item->args));
+ break;
+
+ case COMM_REQ_KILL_APP:
+ case COMM_REQ_CHECK_APP:
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(item->pkgid, &handle);
+ if (ret < 0) {
+ _LOGD("Failed to get handle\n");
exit(1);
}
- _save_queue_status(item, "done");
- if (NULL != backend_cmd)
- free(backend_cmd);
- exit(0); /* exit */
+ if (item->req_type == COMM_REQ_KILL_APP) {
+ ret = pkgmgrinfo_appinfo_get_list(handle, PMINFO_UI_APP, __pkgcmd_app_cb, "kill");
+ if (ret < 0) {
+ _LOGD("pkgmgrinfo_appinfo_get_list() failed\n");
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ exit(1);
+ }
+ } else if (item->req_type == COMM_REQ_CHECK_APP) {
+ ret = pkgmgrinfo_appinfo_get_list(handle, PMINFO_UI_APP, __pkgcmd_app_cb, "check");
+ if (ret < 0) {
+ _LOGD("pkgmgrinfo_appinfo_get_list() failed\n");
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ exit(1);
+ }
+ }
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
break;
- case -1: /* error */
- fprintf(stderr, "Fail to execute fork()\n");
- exit(1);
+ case COMM_REQ_CLEAR_CACHE_DIR:
+ __exec_with_arg_vector("/usr/bin/pkg_clearcache", __generate_argv(item->pkgid));
break;
- default: /* parent */
- DBG("parent \n");
- _save_queue_status(item, "done");
+ case COMM_REQ_MAKE_EXTERNAL_DIR:
+ __exec_with_arg_vector("/usr/bin/pkg_mkext", NULL);
break;
}
+ /* exit child */
+ _save_queue_status(item, "done");
+ exit(0);
break;
- default:
+
+ case -1: /* error */
+ fprintf(stderr, "Fail to execute fork()\n");
+ exit(1);
+ break;
+
+ default: /* parent */
+ _LOGD("parent exit\n");
+ _save_queue_status(item, "done");
break;
}
+ free(item);
+
return FALSE;
}
-#define IS_WHITESPACE(CHAR) \
-((CHAR == ' ' || CHAR == '\t' || CHAR == '\r' || CHAR == '\n') ? TRUE : FALSE)
-
void _app_str_trim(char *input)
{
char *trim_str = input;
_app_str_trim(buffer);
if ((path = strstr(buffer, PKG_BACKEND)) != NULL) {
- DBG("buffer [%s]", buffer);
+// _LOGD("buffer [%s]", buffer);
path = path + strlen(PKG_BACKEND);
- DBG("path [%s]", path);
+// _LOGD("path [%s]", path);
- command =
- (char *)malloc(sizeof(char) * strlen(path) +
- strlen(type) + 1);
+ command = (char *)malloc(sizeof(char) * strlen(path) + strlen(type) + 1);
if (command == NULL) {
fclose(fp);
+ _LOGE("command is null for [path=%s, type=%s]", path, type);
return NULL;
}
size = strlen(path) + strlen(type) + 1;
snprintf(command, size, "%s%s", path, type);
command[strlen(path) + strlen(type)] = '\0';
- DBG("command [%s]", command);
+// _LOGD("command [%s]", command);
if (fp != NULL)
fclose(fp);
return NULL; /* cannot find proper command */
}
-void _pm_desktop_file_monitor_init()
-{
- int wd = 0;
- int i = 0;
- int ret = 0;
-
- desktop_notifier.ifd = inotify_init();
- if (desktop_notifier.ifd == -1) {
- DBG("inotify_init error: %s\n", strerror(errno));
- return;
- }
-
- ret = _pm_desktop_file_dir_search(paths, DESKTOP_FILE_DIRS_NUM);
- if (ret) {
- DBG("desktop file dir search failed\n");
- return;
- }
-
- for (i = 0; i < DESKTOP_FILE_DIRS_NUM && paths[i].path; i++) {
- DBG("Configuration file for desktop file monitoring [%s] is added\n", paths[i].path);
- if (access(paths[i].path, R_OK) != 0) {
- ecore_file_mkpath(paths[i].path);
- if (chmod(paths[i].path, 0777) == -1) {
- DBG("cannot chmod %s\n", paths[i].path);
- }
- }
-
- wd = inotify_add_watch(desktop_notifier.ifd, paths[i].path,
- IN_CLOSE_WRITE | IN_MOVED_TO | IN_DELETE);
- if (wd == -1) {
- DBG("inotify_add_watch error: %s\n", strerror(errno));
- close(desktop_notifier.ifd);
- return;
- }
-
- paths[i].wd = wd;
- }
-
- desktop_notifier.handler =
- ecore_main_fd_handler_add(desktop_notifier.ifd, ECORE_FD_READ,
- __directory_notify, NULL, NULL, NULL);
- if (!desktop_notifier.handler) {
- /* TODO: Handle me.. EXCEPTION!! */
- DBG("cannot add handler for inotify\n");
- }
-}
-
-void _pm_desktop_file_monitor_fini()
-{
- register int i;
-
- if (desktop_notifier.handler) {
- ecore_main_fd_handler_del(desktop_notifier.handler);
- desktop_notifier.handler = NULL;
- }
-
- for (i = 0; i < DESKTOP_FILE_DIRS_NUM; i++) {
- if (paths[i].wd) {
- if (inotify_rm_watch(desktop_notifier.ifd, paths[i].wd)
- < 0) {
- DBG("inotify remove watch failed\n");
- }
- paths[i].wd = 0;
- }
- }
-
- if (desktop_notifier.ifd) {
- close(desktop_notifier.ifd);
- desktop_notifier.ifd = -1;
- }
-}
-
-
-int _pm_desktop_file_dir_search(pm_inotify_paths *paths, int number)
-{
- char *buf = NULL;
- char *noti_dir = NULL;
- char *saveptr = NULL;
- int len = 0;
- int i = 0;
- int fd = -1;
- int read_size = 0;
-
- fd = open(DESKTOP_FILE_DIRS, O_RDONLY);
- if (fd < 0) {
- DBG("Failed to open %s\n", DESKTOP_FILE_DIRS);
- return -EFAULT;
- }
-
- if (ioctl(fd, FIONREAD, &read_size) < 0) {
- DBG("Failed to get a size of %s file.\n", DESKTOP_FILE_DIRS);
- return -EFAULT;
- }
-
- if (read_size <= 0) {
- DBG("Buffer is not ready.\n");
- return -EFAULT;
- }
-
- buf = malloc(read_size);
- if (!buf) {
- DBG("Failed to allocate heap.\n");
- return -EFAULT;
- }
-
- len = read(fd, buf, read_size);
- if (len < 0) {
- DBG("Failed to read.\n");
- free(buf);
- return -EFAULT;
- }
-
- noti_dir = strtok_r(buf, "\n", &saveptr);
- if (!noti_dir) {
- DBG("Failed to strtok for %s.\n", buf);
- free(buf);
- return -EFAULT;
- }
-
- do {
- char *begin;
-
- begin = noti_dir;
- while (*begin != 0) {
- if (isspace(*begin))
- begin++;
- else
- break;
- }
- if (*begin == '#' || *begin == 0) {
- noti_dir = strtok_r(NULL, "\n", &saveptr);
- continue;
- }
-
- paths[i].path = strdup(begin);
- noti_dir = strtok_r(NULL, "\n", &saveptr);
- i++;
- } while (number > i && noti_dir);
-
- paths[i].path = NULL;
- close(fd);
- free(buf);
-
- return EXIT_SUCCESS;
-}
-
-/**< Called before main loop */
-int app_create(void *user_data)
-{
- /* printf("called app_create\n"); */
- return 0;
-}
-
-/**< Called after main loop */
-int app_terminate(void *user_data)
-{
- /* printf("called app_terminate\n"); */
- return 0;
-}
-
-/**< Called when every window goes back */
-int app_pause(void *user_data)
-{
- /* printf("called app_pause\n"); */
- return 0;
-}
-
-/**< Called when any window comes on top */
-int app_resume(void *user_data)
-{
- /* printf("called app_resume\n"); */
- return 0;
-}
-
-/**< Called at the first idler*/
-int app_reset(bundle *b, void *user_data)
-{
- /* printf("called app_reset\n"); */
- return 0;
-}
-
int main(int argc, char *argv[])
{
FILE *fp_status = NULL;
backend_info *ptr = NULL;
int r;
- ecore_init();
-
- DBG("server start");
+ _LOGD("server start");
if (argv[1]) {
if (strcmp(argv[1], "init") == 0) {
- /* if current status is "processing",
+ /* if current status is "processing",
execute related backend with '-r' option */
if (!(fp_status = fopen(STATUS_FILE, "r")))
return 0; /*if file is not exist, terminated. */
fgets(buf, 32, fp_status);
backend_cmd = _get_backend_cmd(buf);
if (!backend_cmd) { /* if NULL, */
- DBG("fail to get"
- " backend command");
+ _LOGD("fail to get backend command");
goto err;
}
backend_name =
fclose(fp_status);
exit(13);
} else if (pid < 0) { /* error */
- DBG("fork fail");
+ _LOGD("fork fail");
fclose(fp_status);
return 0;
} else { /* parent */
- DBG("parent end\n");
+ _LOGD("parent end\n");
fprintf(fp_status, " ");
fclose(fp_status);
return 0;
r = _pm_queue_init();
if (r) {
- DBG("Queue Initialization Failed\n");
+ _LOGE("Queue Initialization Failed\n");
return -1;
}
- /*Initialize inotify to monitor desktop file updates */
- _pm_desktop_file_monitor_init();
-
- /*Allocate memory for holding pid, pkgtype and pkgname*/
+ /*Allocate memory for holding pid, pkgtype and pkgid*/
ptr = (backend_info*)calloc(num_of_backends, sizeof(backend_info));
if (ptr == NULL) {
- DBG("Malloc Failed\n");
+ _LOGD("Malloc Failed\n");
return -1;
}
memset(ptr, '\0', num_of_backends * sizeof(backend_info));
begin = ptr;
- /* init internationalization */
- r = appcore_set_i18n(PACKAGE, LOCALEDIR);
- if (r)
- return -1;
-
g_type_init();
mainloop = g_main_loop_new(NULL, FALSE);
- ecore_main_loop_glib_integrate();
-
- struct appdata ad;
- struct appcore_ops ops;
- ops.create = app_create;
- ops.terminate = app_terminate;
- ops.pause = app_pause;
- ops.resume = app_resume;
- ops.reset = app_reset;
- ops.data = &ad;
+ if (!mainloop){
+ _LOGD("g_main_loop_new failed\n");
+ return -1;
+ }
- DBG("Main loop is created.");
+ _LOGD("Main loop is created.");
PkgMgrObject *pkg_mgr;
pkg_mgr = g_object_new(PKG_MGR_TYPE_OBJECT, NULL);
- pkg_mgr_set_request_callback(pkg_mgr, req_cb, &ad);
- DBG("pkg_mgr object is created, and request callback is registered.");
+ pkg_mgr_set_request_callback(pkg_mgr, req_cb, NULL);
+ _LOGD("pkg_mgr object is created, and request callback is registered.");
+
+ pkg_mgr_set_callback_to_create_directory(pkg_mgr, create_external_dir_cb);
-/* g_main_loop_run(mainloop); */
- appcore_efl_main(PACKAGE, &argc, &argv, &ops);
+ g_main_loop_run(mainloop);
- DBG("Quit main loop.");
- _pm_desktop_file_monitor_fini();
+ _LOGD("Quit main loop.");
_pm_queue_final();
/*Free backend info */
if (begin) {
begin = NULL;
}
- DBG("package manager server terminated.");
+ _LOGD("package manager server terminated.");
return 0;
}
--- /dev/null
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/smack.h>
+#include <unistd.h>
+#include <errno.h>
+#include <stdio.h>
+
+#include "pkgmgr_external_storage.h"
+#include "comm_config.h"
+
+static const char _PRIVILEGE_NAME[] = "http://tizen.org/privilege/externalstorage.appdata";
+
+static int __package_list_cb(const pkgmgrinfo_pkginfo_h handle, void *user_data);
+static int __create_external_directory(const char *pkgid);
+static int __set_smack_label_access(const char *path, const char *label);
+static int __get_smack_label_access(const char *path, char **label);
+static int __set_smack_label_transmute(const char *path, const char *flag);
+
+int _create_external_directory(void)
+{
+ char ext_base_path[MAX_PATH_LENGTH] = {0, };
+ int res = 0;
+
+ strcpy(ext_base_path, EXTERNAL_STORAGE_APP_SPECIFIC_PATH);
+ res = mkdir(ext_base_path, 0500);
+ if (res == -1 && errno != EEXIST)
+ {
+ ERR("mkdir() is failed. error = [%d] strerror = [%s]", errno, strerror(errno));
+ return -1;
+ }
+
+ res = __set_smack_label_access(ext_base_path, "_");
+ if (res != 0)
+ {
+ ERR("__set_smack_label_access() is failed.");
+ return -1;
+ }
+
+ res = pkgmgrinfo_pkginfo_privilege_filter_foreach(_PRIVILEGE_NAME, __package_list_cb, NULL);
+ if (res != PMINFO_R_OK)
+ {
+ ERR("pkgmgrinfo_pkginfo_privilege_filter_foreach() is failed. error = [%d]", res);
+ return -1;
+ }
+
+ return 0;
+}
+
+static int __package_list_cb(const pkgmgrinfo_pkginfo_h handle, void *user_data)
+{
+ char *pkgid = NULL;
+ int res = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
+
+ if (res != PMINFO_R_OK)
+ {
+ ERR("pkgmgrinfo_pkginfo_get_pkgid() is failed. error = [%d]", res);
+ return -1;
+ }
+
+ dbg("Create external directory. package_id = [%s] privilge_name = [%s]", pkgid, _PRIVILEGE_NAME);
+ res = __create_external_directory(pkgid);
+ if (res != 0)
+ {
+ ERR("__create_external_directory() is failed. error = [%d]", res);
+ return -1;
+ }
+
+ return 0;
+}
+
+static int __create_external_directory(const char *pkgid)
+{
+ char ext_pkg_base_path[MAX_PATH_LENGTH] = {0, };
+ char temp_path[MAX_PATH_LENGTH] = {0, };
+ char pkg_shared_data_path[MAX_PATH_LENGTH] = {0, };
+ char *shared_data_label = NULL;
+ int res = 0;
+
+ /* Create directories */
+ snprintf(ext_pkg_base_path, MAX_PATH_LENGTH, "%s/%s", EXTERNAL_STORAGE_APP_SPECIFIC_PATH, pkgid);
+ res = mkdir(ext_pkg_base_path, 0500);
+ if (res == -1 && errno != EEXIST)
+ {
+ ERR("mkdir() is failed. error = [%d] strerror = [%s]", errno, strerror(errno));
+ return -1;
+ }
+
+ res = __set_smack_label_access(ext_pkg_base_path, "_");
+ if (res != 0)
+ {
+ ERR("__set_smack_label_access() is failed.");
+ return -1;
+ }
+
+ memset(temp_path, 0, MAX_PATH_LENGTH);
+ strcpy(temp_path, ext_pkg_base_path);
+ strncat(temp_path, "/data", strlen("/data"));
+ res = mkdir(temp_path, 0700);
+ if (res == -1 && errno != EEXIST)
+ {
+ ERR("mkdir() is failed. error = [%d] strerror = [%s]", errno, strerror(errno));
+ return -1;
+ }
+
+ res = __set_smack_label_access(temp_path, pkgid);
+ if (res != 0)
+ {
+ ERR("__set_smack_label_access() is failed.");
+ return -1;
+ }
+
+ memset(temp_path, 0, MAX_PATH_LENGTH);
+ strcpy(temp_path, ext_pkg_base_path);
+ strncat(temp_path, "/cache", strlen("/cache"));
+ res = mkdir(temp_path, 0700);
+ if (res == -1 && errno != EEXIST)
+ {
+ ERR("mkdir() is failed. error = [%d] strerror = [%s]", errno, strerror(errno));
+ return -1;
+ }
+
+ res = __set_smack_label_access(temp_path, pkgid);
+ if (res != 0)
+ {
+ ERR("__set_smack_label_access() is failed.");
+ return -1;
+ }
+
+ memset(temp_path, 0, MAX_PATH_LENGTH);
+ strcpy(temp_path, ext_pkg_base_path);
+ strncat(temp_path, "/shared", strlen("/shared"));
+ res = mkdir(temp_path, 0500);
+ if (res == -1 && errno != EEXIST)
+ {
+ ERR("mkdir() is failed. error = [%d] strerror = [%s]", errno, strerror(errno));
+ return -1;
+ }
+
+ res = __set_smack_label_access(temp_path, "_");
+ if (res != 0)
+ {
+ ERR("__set_smack_label_access() is failed.");
+ return -1;
+ }
+
+ snprintf(pkg_shared_data_path, MAX_PATH_LENGTH, "%s/%s/%s", APP_ROOT_RW_PATH, pkgid , "shared/data");
+
+ res = access(pkg_shared_data_path, F_OK);
+ if (res == 0)
+ {
+ dbg("Exist shared/data folder (path:[%s])", pkg_shared_data_path);
+ res = __get_smack_label_access(pkg_shared_data_path, &shared_data_label);
+ if (res != 0)
+ {
+ ERR("__get_smack_label_access() is failed.");
+ return -1;
+ }
+
+ strncat(temp_path, "/data", strlen("/data"));
+ res = mkdir(temp_path, 0705);
+ if (res == -1 && errno != EEXIST)
+ {
+ ERR("mkdir() is failed. error = [%d] strerror = [%s]", errno, strerror(errno));
+ return -1;
+ }
+
+ res = __set_smack_label_access(temp_path, shared_data_label);
+ if (res != 0)
+ {
+ ERR("__set_smack_label_access() is failed.");
+ return -1;
+ }
+
+ res = __set_smack_label_transmute(temp_path, "1");
+ if (res != 0)
+ {
+ ERR("__set_smack_label_transmute() is failed.");
+ return -1;
+ }
+ }
+ else if (res == -1 && errno == ENOENT)
+ {
+ dbg("Directory dose not exist. path: %s, errno: %d (%s)",
+ pkg_shared_data_path, errno, strerror(errno));
+ return 0;
+ }
+ else
+ {
+ ERR("access() failed. path: %s, errno: %d (%s)",
+ pkg_shared_data_path, errno, strerror(errno));
+ return -1;
+ }
+
+ return 0;
+}
+
+static int __set_smack_label_access(const char *path, const char *label)
+{
+ int res = smack_lsetlabel(path, label, SMACK_LABEL_ACCESS);
+ if (res != 0)
+ {
+ ERR("smack set label(%s) failed[%d] (path:[%s]))", label, res, path);
+ return -1;
+ }
+ return 0;
+}
+
+static int __get_smack_label_access(const char *path, char **label)
+{
+ int res = smack_lgetlabel(path, label, SMACK_LABEL_ACCESS);
+ if (res != 0)
+ {
+ ERR("smack get label(%s) failed[%d] (path:[%s]))", label, res, path);
+ return -1;
+ }
+ return 0;
+}
+
+static int __set_smack_label_transmute(const char *path, const char *flag)
+{
+ int res = smack_lsetlabel(path, flag, SMACK_LABEL_TRANSMUTE);
+ if (res != 0)
+ {
+ ERR("smack set label(%s) failed[%d] (path:[%s]))", flag, res, path);
+ return -1;
+ }
+ return 0;
+}
--- /dev/null
+#include <pkgmgr-info.h>
+
+#define MAX_PATH_LENGTH 512
+#define APP_ROOT_RW_PATH "/opt/usr/apps"
+#define EXTERNAL_STORAGE_APP_SPECIFIC_PATH "/opt/storage/sdcard/apps"
+
+int _create_external_directory(void);
+
+
+
+
+
+
+
+
+
+
#define BACKEND_INFO_DIR "/usr/etc/package-manager/backend"
-static pm_queue_data *__get_head_from_pkgtype(pm_dbus_msg item);
+static pm_queue_data *__get_head_from_pkgtype(pm_dbus_msg *item);
static void __update_head_from_pkgtype(pm_queue_data *data);
static int __entry_exist(char *backend);
static int __is_pkg_supported(char *pkgtype);
queue_info_map *ptr = NULL;
ptr = start;
int i = 0;
+
for(i = 0; i < entries; i++)
{
if (!strncmp(ptr->pkgtype, pkgtype, MAX_PKG_TYPE_LEN))
int i = 0;
for(i = 0; i < entries; i++)
{
- if(ptr->backend) {
- if (!strncmp(ptr->backend, backend, MAX_PKG_NAME_LEN))
- return ptr->queue_slot;
- else {
- ptr++;
- continue;
- }
+ if (!strncmp(ptr->backend, backend, MAX_PKG_NAME_LEN))
+ return ptr->queue_slot;
+ else {
+ ptr++;
+ continue;
}
- ptr++;
}
return -1;
}
int i = 0;
for(i = 0; i < entries; i++)
{
- if(ptr->pkgtype && !ptr->head) {
- if (!strncmp(ptr->pkgtype, data->msg->pkg_type, MAX_PKG_TYPE_LEN)) {
- ptr->head = data;
- slot = ptr->queue_slot;
- }
- else {
- ptr++;
- continue;
- }
+ if (!strncmp(ptr->pkgtype, data->msg->pkg_type, MAX_PKG_TYPE_LEN)) {
+ ptr->head = data;
+ slot = ptr->queue_slot;
+ }
+ else {
+ ptr++;
+ continue;
}
- ptr++;
}
/*update head for each duplicate entry*/
ptr = start;
}
/*Gets the queue head based on pkg type*/
-static pm_queue_data *__get_head_from_pkgtype(pm_dbus_msg item)
+static pm_queue_data *__get_head_from_pkgtype(pm_dbus_msg *item)
{
queue_info_map *ptr = NULL;
ptr = start;
int i = 0;
for(i = 0; i < entries; i++)
{
- if(ptr->pkgtype) {
- if (!strncmp(ptr->pkgtype, item.pkg_type, MAX_PKG_TYPE_LEN))
- return ptr->head;
- else {
- ptr++;
- continue;
- }
+ if (!strncmp(ptr->pkgtype, item->pkg_type, MAX_PKG_TYPE_LEN))
+ return ptr->head;
+ else {
+ ptr++;
+ continue;
}
- ptr++;
}
return NULL;
}
/*Add entries to info map.*/
ptr = (queue_info_map*)calloc(c , sizeof(queue_info_map));
+ if(ptr == NULL){
+ fprintf(stderr,"calloc failed!!");
+ n = i;
+ while(n--){
+ if(namelist[n]){
+ free(namelist[n]);
+ namelist[n] = NULL;
+ }
+ }
+ if(namelist){
+ free(namelist);
+ namelist = NULL;
+ }
+ return -1;
+ }
memset(ptr, '\0', c * sizeof(queue_info_map));
start = ptr;
for(n = 0; n < c ; n++)
{
if(!strcmp(namelist[n]->d_name, ".") ||
!strcmp(namelist[n]->d_name, ".."))
- continue;
+ {
+ free(namelist[n]);
+ continue;
+ }
snprintf(abs_filename, MAX_PKG_NAME_LEN, "%s/%s",
BACKEND_INFO_DIR, namelist[n]->d_name);
if (lstat(abs_filename, &fileinfo) < 0) {
perror(abs_filename);
+ free(namelist);
return -1;
}
if (S_ISDIR(fileinfo.st_mode))
+ {
+ free(namelist[n]);
continue;
+ }
/*Found backend*/
if (S_ISLNK(fileinfo.st_mode)) {
/*found a symlink*/
ret = readlink(abs_filename, buf, MAX_PKG_NAME_LEN - 1);
if (ret == -1) {
perror("readlink");
+ free(namelist);
return -1;
}
buf[ret] = '\0';
return 0;
}
-int _pm_queue_push(pm_dbus_msg item)
+int _pm_queue_push(pm_dbus_msg *item)
{
pm_queue_data *data = NULL;
pm_queue_data *cur = NULL;
pm_queue_data *tmp = NULL;
int ret = 0;
- ret = __is_pkg_supported(item.pkg_type);
+ ret = __is_pkg_supported(item->pkg_type);
if (ret == 0)
return -1;
data = _add_node();
if (!data) { /* fail to allocate mem */
fprintf(stderr, "Fail to allocate memory\n");
- return -1;
+ return -2;
}
- strncpy(data->msg->req_id, item.req_id, strlen(item.req_id));
- data->msg->req_type = item.req_type;
- strncpy(data->msg->pkg_type, item.pkg_type, strlen(item.pkg_type));
- strncpy(data->msg->pkg_name, item.pkg_name, strlen(item.pkg_name));
- strncpy(data->msg->args, item.args, strlen(item.args));
- strncpy(data->msg->cookie, item.cookie, strlen(item.cookie));
+ strncpy(data->msg->req_id, item->req_id, strlen(item->req_id));
+ data->msg->req_type = item->req_type;
+ strncpy(data->msg->pkg_type, item->pkg_type, strlen(item->pkg_type));
+ strncpy(data->msg->pkgid, item->pkgid, strlen(item->pkgid));
+ strncpy(data->msg->args, item->args, strlen(item->args));
+ strncpy(data->msg->cookie, item->cookie, strlen(item->cookie));
data->next = NULL;
}
/*pop request from queue slot "position" */
-pm_dbus_msg _pm_queue_pop(int position)
+pm_dbus_msg *_pm_queue_pop(int position)
{
- pm_dbus_msg ret;
+ pm_dbus_msg *ret;
pm_queue_data *cur = NULL;
pm_queue_data *saveptr = NULL;
queue_info_map *ptr = start;
int i = 0;
+
+ ret = (pm_dbus_msg *) malloc(sizeof(pm_dbus_msg));
+ if (!ret) {
+ fprintf(stderr, "Mem alloc error\n");
+ return NULL;
+ }
+ memset(ret, 0x00, sizeof(pm_dbus_msg));
+
for(i = 0; i < entries; i++)
{
if (ptr->queue_slot == position) {
}
ptr++;
}
- memset(&ret, 0x00, sizeof(pm_dbus_msg));
if (!cur) { /* queue is empty */
- ret.req_type = -1;
+ ret->req_type = -1;
return ret;
}
- strncpy(ret.req_id, cur->msg->req_id, strlen(cur->msg->req_id));
- ret.req_type = cur->msg->req_type;
- strncpy(ret.pkg_type, cur->msg->pkg_type, strlen(cur->msg->pkg_type));
- strncpy(ret.pkg_name, cur->msg->pkg_name, strlen(cur->msg->pkg_name));
- strncpy(ret.args, cur->msg->args, strlen(cur->msg->args));
- strncpy(ret.cookie, cur->msg->cookie, strlen(cur->msg->cookie));
+ strncpy(ret->req_id, cur->msg->req_id, strlen(cur->msg->req_id));
+ ret->req_type = cur->msg->req_type;
+ strncpy(ret->pkg_type, cur->msg->pkg_type, strlen(cur->msg->pkg_type));
+ strncpy(ret->pkgid, cur->msg->pkgid, strlen(cur->msg->pkgid));
+ strncpy(ret->args, cur->msg->args, strlen(cur->msg->args));
+ strncpy(ret->cookie, cur->msg->cookie, strlen(cur->msg->cookie));
ptr->head = cur->next;
saveptr = ptr->head;
return ret;
}
-/* This function is not required*/
-#if 0
-pm_dbus_msg _pm_queue_get_head()
-{
- pm_dbus_msg ret;
- pm_queue_data *cur = NULL;
-
- cur = head;
-
- memset(&ret, 0x00, sizeof(pm_dbus_msg));
-
- if (!head) { /* queue is empty */
- ret.req_type = -1;
- return ret;
- }
-
- strncpy(ret.req_id, cur->msg->req_id, strlen(cur->msg->req_id));
- ret.req_type = cur->msg->req_type;
- strncpy(ret.pkg_type, cur->msg->pkg_type, strlen(cur->msg->pkg_type));
- strncpy(ret.pkg_name, cur->msg->pkg_name, strlen(cur->msg->pkg_name));
- strncpy(ret.args, cur->msg->args, strlen(cur->msg->args));
- strncpy(ret.cookie, cur->msg->cookie, strlen(cur->msg->cookie));
-
- return ret;
-}
-#endif
/*populate an array of all queue heads and delete them one by one*/
void _pm_queue_final()
{
pm_queue_data *cur = NULL;
pm_queue_data *tail = NULL;
pm_queue_data *prev = NULL;
- pm_queue_data *head[num_of_backends];
+ pm_queue_data *head[MAX_QUEUE_NUM] = {NULL,};
queue_info_map *ptr = NULL;
ptr = start;
+ for(i = 0; i < num_of_backends; i++)
+ {
+ head[i] = NULL;
+ }
+
for(i = 0; i < entries; i++)
{
if (ptr->queue_slot <= slot) {
cur = head[c]->next;
while (cur->next) {
- printf(" -- [%p]\n", cur);
prev = cur;
cur = cur->next;
}
tail = cur;
- printf("%p\n", tail);
free(tail->msg);
free(tail);
return newnode;
}
-void _pm_queue_delete(pm_dbus_msg item)
+void _pm_queue_delete(pm_dbus_msg *item)
{
/* Assume that pacakge name is unique */
pm_queue_data *cur = NULL;
prev = cur;
if (cur) {
while (cur->next) {
- if (!strcmp(item.pkg_name, cur->msg->pkg_name)) {
+ if (!strcmp(item->pkgid, cur->msg->pkgid)) {
prev->next = cur->next;
free(cur->msg);
free(cur);
}
}
-void _save_queue_status(pm_dbus_msg item, char *status)
+void _save_queue_status(pm_dbus_msg *item, char *status)
{
FILE *fp_status = NULL;
}
fprintf(fp_status, "%s\n", status);
- printf("[%s]\n", status);
- fprintf(fp_status, "%s\n", item.pkg_type);
- printf("[%s]\n", item.pkg_type);
+ fprintf(fp_status, "%s\n", item->pkg_type);
fsync(fp_status->_fileno);
fclose(fp_status);
}
int index = 1;
if (!cur) {
- printf(" ** queue is NULL **\n");
return;
}
while (cur) {
- printf(" * queue[%d]: [%s] [%d] [%s] [%s] [%s] [%s]\n",
- index,
- cur->msg->req_id,
- cur->msg->req_type,
- cur->msg->pkg_type,
- cur->msg->pkg_name, cur->msg->args, cur->msg->cookie);
-
index++;
cur = cur->next;
}
--- /dev/null
+[Unit]
+Description=SLP Package Manager
+
+[Service]
+BusName=org.tizen.pkgmgr
+ExecStart=/usr/bin/pkgmgr-server
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TEST_CFLAGS}")
#Verbose
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/client/include ${CMAKE_SOURCE_DIR}/parser)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/client/include)
INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs_test REQUIRED ecore dbus-1 ail libxml-2.0)
+pkg_check_modules(pkgs_test REQUIRED ecore dbus-1 dlog libxml-2.0 bundle pkgmgr-info pkgmgr-parser vconf iniparser sqlite3 db-util libsmack)
FOREACH(flag ${pkgs_test_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
+pkg_check_modules(toolpkgs REQUIRED appcore-efl dlog bundle glib-2.0 pkgmgr-info pkgmgr-parser vconf iniparser)
+FOREACH(flag ${libpkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+pkg_check_modules(mkext REQUIRED dlog pkgmgr-info libsmack)
+FOREACH(flag ${mkext_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wl,-zdefs" )
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wl,-zdefs -pie" )
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
-SET(CMAKE_C_FLAGS_RELEASE "-O2")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -fPIE")
+SET(CMAKE_C_FLAGS_RELEASE "-O2 -fPIE")
add_executable(pkgcmd
pkg_cmd.c)
INSTALL(TARGETS pkgcmd DESTINATION bin)
add_executable(pkginfo
- pkg_info.c)
-target_link_libraries(pkginfo pkgmgr-client ${pkgs_test_LDFLAGS})
+ pkg_info.c)
+target_link_libraries(pkginfo pkgmgr-client pkgmgr_installer ${pkgs_test_LDFLAGS})
INSTALL(TARGETS pkginfo DESTINATION bin)
+add_executable(pkg_getsize
+ pkg_getsize.c)
+target_link_libraries(pkg_getsize pkgmgr_installer ${pkgs_test_LDFLAGS})
+INSTALL(TARGETS pkg_getsize DESTINATION bin)
+
+add_executable(pkg_getjunkinfo
+ pkg_getjunkinfo.c
+ pkg_magic.c)
+target_link_libraries(pkg_getjunkinfo pkgmgr_installer ${pkgs_test_LDFLAGS} -lmagic)
+INSTALL(TARGETS pkg_getjunkinfo DESTINATION bin)
+
+add_executable(test_junk
+ test_junk.c)
+target_link_libraries(test_junk pkgmgr-client pkgmgr_installer ${pkgs_test_LDFLAGS})
+INSTALL(TARGETS test_junk DESTINATION bin)
+
+add_executable(pkg_clearcache
+ pkg_clearcache.c)
+target_link_libraries(pkg_clearcache ${pkgs_test_LDFLAGS})
+INSTALL(TARGETS pkg_clearcache DESTINATION bin)
+
+add_executable(pkg_mkext
+ pkg_mkext.c)
+target_link_libraries(pkg_mkext ${mkext_LDFLAGS})
+INSTALL(TARGETS pkg_mkext DESTINATION bin)
+
add_executable(pkg_initdb
- pkg_initdb.c)
-target_link_libraries(pkg_initdb pkgmgr_parser ${pkgs_test_LDFLAGS})
+ pkg_initdb.c)
+target_link_libraries(pkg_initdb ${pkgs_test_LDFLAGS})
INSTALL(TARGETS pkg_initdb DESTINATION bin)
+add_executable(pkg_fota
+ pkg_fota.c)
+target_link_libraries(pkg_fota ${pkgs_test_LDFLAGS})
+INSTALL(TARGETS pkg_fota DESTINATION bin)
+
+add_executable(pkg
+ pkg.c)
+target_link_libraries(pkg pkgmgr-client ${pkgs_test_LDFLAGS})
+INSTALL(TARGETS pkg DESTINATION bin)
+
add_executable(pkgmgr-install pkgmgr-install.c)
-target_link_libraries(pkgmgr-install pkgmgr-client)
+target_link_libraries(pkgmgr-install pkgmgr-client pkgmgr-info ${toolpkgs_LDFLAGS})
install(TARGETS pkgmgr-install DESTINATION bin)
-configure_file(org.tizen.pkgmgr-install.desktop.in ${CMAKE_BINARY_DIR}/org.tizen.pkgmgr-install.desktop @ONLY)
-install(FILES ${CMAKE_BINARY_DIR}/org.tizen.pkgmgr-install.desktop DESTINATION /usr/share/applications/)
-
configure_file(org.tizen.pkgmgr-install.xml.in ${CMAKE_BINARY_DIR}/org.tizen.pkgmgr-install.xml @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/org.tizen.pkgmgr-install.xml DESTINATION /usr/share/packages/)
+configure_file(pkg_recovery.sh.in pkg_recovery.sh @ONLY)
+install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/pkg_recovery.sh DESTINATION /usr/etc/package-manager/)
+
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mime.wac.xml DESTINATION /usr/share/mime/packages/)
+install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mime.tpk.xml DESTINATION /usr/share/mime/packages/)
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
+ <mime-type type="application/vnd.tizen.package">
+ <!--Created automatically by update-mime-database. DO NOT EDIT!-->
+ <comment>Tizen Package</comment>
+ <acronym>TPK</acronym>
+ <expanded-acronym>Tizen PacKage</expanded-acronym>
+ <glob pattern="*.tpk"/>
+ </mime-type>
+</mime-info>
+++ /dev/null
-Name=pkgmgr-install
-Type=Application
-Exec=/usr/bin/pkgmgr-install
-NoDisplay=True
-Version=0.1
-Mimetype=application/x-deb;application/x-java-archive;text/vnd.sun.j2me.app-descriptor;application/widget;application/vnd.wac.widget-sharing;application/x-rpm;application/x-redhat-package-manager
-X-Tizen-TaskManage=False
-X-Tizen-Multiple=True
-X-Tizen-Removable=False
-X-Tizen-SVC=http://tizen.org/appcontrol/operation/view|NULL|application/x-deb;http://tizen.org/appcontrol/operation/view|NULL|application/x-java-archive;http://tizen.org/appcontrol/operation/view|NULL|text/vnd.sun.j2me.app-descriptor;http://tizen.org/appcontrol/operation/view|NULL|application/widget;http://tizen.org/appcontrol/operation/view|NULL|application/vnd.wac.widget-sharing;http://tizen.org/appcontrol/operation/view|NULL|application/x-rpm;http://tizen.org/appcontrol/operation/view|NULL|application/x-redhat-package-manager
<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns="http://tizen.org/ns/packages" package="org.tizen.pkgmgr-install" version="0.1" install-location="internal-only">
+<manifest xmlns="http://tizen.org/ns/packages" package="org.tizen.pkgmgr-install" version="0.0.2" install-location="internal-only" nodisplay-setting="true">
<label>pkgmgr-install</label>
<author email="sewook7.park@samsung.com" href="www.samsung.com">Sewook Park</author>
<description>pkgmgr-install</description>
<ui-application appid="org.tizen.pkgmgr-install" exec="/usr/bin/pkgmgr-install" nodisplay="true" multiple="false" type="capp" taskmanage="false">
<label>pkgmgr-install</label>
- <application-service>
- <operation name="http://tizen.org/appcontrol/operation/view"/>
- <mime name="application/widget"/>
- <mime name="application/vnd.wac.widget-sharing"/>
- <mime name="application/x-rpm"/>
- <mime name="application/x-redhat-package-manager"/>
- </application-service>
</ui-application>
</manifest>
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#define _GNU_SOURCE
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <ctype.h>
+#include <string.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <glib-object.h>
+#include <glib.h>
+#include <sys/types.h>
+#include <db-util.h>
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib-lowlevel.h>
+#include "comm_config.h"
+
+#include <pkgmgr-info.h>
+#include "pkg.h"
+#include "package-manager.h"
+#include "package-manager-types.h"
+#include "package-manager-debug.h"
+
+static int __xsystem(const char *argv[]);
+static void __do_print_usage();
+static void __do_print_usage_api_test();
+static int __do_list(pkg_tool_args *pkg_args);
+static int __do_install(pkg_tool_args *pkg_args);
+static int __do_uninstall(pkg_tool_args *pkg_args);
+static int __do_enable(pkg_tool_args *pkg_args);
+static int __do_disable(pkg_tool_args *pkg_args);
+static int __do_move_to_internal(pkg_tool_args *pkg_args);
+static int __do_move_to_external(pkg_tool_args *pkg_args);
+static int __do_launch(pkg_tool_args *pkg_args);
+static int __do_info(pkg_tool_args *pkg_args);
+static int __pkgmgr_list_cb(pkgmgrinfo_pkginfo_h handle, void *user_data);
+static int __pkgmgr_app_list_cb(pkgmgrinfo_appinfo_h handle, void *user_data);
+static int __return_cb(int req_id, const char *pkg_type, const char *pkgid, const char *key, const char *val, const void *pmsg, void *priv_data);
+static int __do_info_by_pkgid(const char* pkgid);
+static int __do_info_by_appid(const char* appid);
+static int __do_info_app_func(const pkgmgrinfo_appinfo_h handle, void *user_data);
+static int __do_api_test(pkg_tool_args *pkg_args);
+
+static GMainLoop *main_loop = NULL;
+
+
+#define ZIP_PKGMGR_DB PKGMGR_FOTA_PATH".pkgmgr_parser.db"
+#define PKGID_LIST_FILE PKGMGR_FOTA_PATH"pkgid_list.txt"
+#define APPID_LIST_FILE PKGMGR_FOTA_PATH"appid_list.txt"
+
+#define TEST_PKGID "org.tizen.message-lite"
+#define TEST_APPID "org.tizen.message-lite"
+
+struct option long_options[] = {
+ {"list", no_argument, 0, 'l'},
+ {"install", required_argument, 0, 'i'},
+ {"uninstall", required_argument, 0, 'u'},
+ {"enable", required_argument, 0, 'e'},
+ {"disable", required_argument, 0, 'd'},
+ {"move-to-internal", required_argument, 0, 0},
+ {"move-to-external", required_argument, 0, 0},
+ {"launch", required_argument, 0, 0},
+ {"info", no_argument, 0, 'q'},
+ {"pkgid", required_argument, 0, 'x'},
+ {"appid", required_argument, 0, 'y'},
+ {"all", no_argument, 0, 'a'},
+ {"api-test", no_argument, 0, 't'},
+ {0, 0, 0, 0},
+};
+
+cmdinfo cmds[] =
+{
+ {__do_list},
+ {__do_install},
+ {__do_uninstall},
+ {__do_enable},
+ {__do_disable},
+ {__do_move_to_internal},
+ {__do_move_to_external},
+ {__do_launch},
+ {__do_info},
+ {__do_api_test},
+ {NULL}
+};
+
+int main(int argc, char *argv[])
+{
+ int opt_idx = 0;
+ int c = -1;
+ long starttime;
+ long endtime;
+ struct timeval tv;
+ pkg_tool_args pkg_args = {0};
+
+ uid_t uid = getuid();
+ if ((uid_t) 0 != uid) {
+ printf("You are not an authorized user!\n");
+ exit(0);
+ }
+
+ if (argc == 1)
+ {
+ __do_print_usage();
+ exit(0);
+ }
+
+ gettimeofday(&tv, NULL);
+ starttime = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
+ pkg_args.req = NONE_REQ;
+
+ while (1)
+ {
+ c = getopt_long(argc, argv, "i:u:e:d:lat:x:y:q", long_options, &opt_idx); // 3rd param is short option.
+ if (c == -1)
+ break;
+
+ switch (c)
+ {
+ case 0:
+ printf("option %s", long_options[opt_idx].name);
+ if (optarg)
+ printf(" with arg %s", optarg);
+ printf("\n");
+ break;
+
+ case 'l':
+ pkg_args.req = LIST_REQ;
+ break;
+
+ case 'a':
+ pkg_args.isListAll = true;
+ break;
+
+ case 'i':
+ pkg_args.req = INSTALL_REQ;
+ realpath(optarg, pkg_args.path);
+ break;
+
+ case 'u':
+ pkg_args.req = UNINSTALL_REQ;
+ sprintf(pkg_args.pkgid, optarg);
+ break;
+
+ case 'e':
+ pkg_args.req = ENABLE_REQ;
+ sprintf(pkg_args.pkgid, optarg);
+ break;
+
+ case 'd':
+ pkg_args.req = DISABLE_REQ;
+ sprintf(pkg_args.pkgid, optarg);
+ break;
+
+ case 'q':
+ pkg_args.req = INFO_REQ;
+ break;
+
+ case 'x':
+ sprintf(pkg_args.pkgid, optarg);
+ printf("pkg_args.pkgid=%s\n", pkg_args.pkgid);
+ break;
+
+ case 'y':
+ sprintf(pkg_args.appid, optarg);
+ printf("pkg_args.appid=%s\n", pkg_args.appid);
+ break;
+
+ case 't':
+ pkg_args.req = API_TEST_REQ;
+ sprintf(pkg_args.pkgid, optarg);
+ break;
+
+ default:
+ printf("?? getopt returned character code 0%o ??\n", c);
+ }
+ }
+
+ if (optind < argc) {
+ printf("non-option ARGV-elements: ");
+ while (optind < argc)
+ printf("%s ", argv[optind++]);
+ printf("\n");
+ }
+
+ // call each function
+ if (pkg_args.req != NONE_REQ)
+ {
+ printf("req=%d, path=%s, pkgid=%s, appid=%s, des_path=%s, lable=%s, result=%d, isListAll=%d\n",
+ (int)pkg_args.req, pkg_args.path, pkg_args.pkgid, pkg_args.appid, pkg_args.des_path,
+ pkg_args.label, pkg_args.result, (int)pkg_args.isListAll);
+ cmds[pkg_args.req].func(&pkg_args);
+ }
+ else
+ {
+ printf("no operation\n");
+ }
+
+ gettimeofday(&tv, NULL);
+ endtime = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
+ printf("spend time is [%d]ms\n", (int)(endtime - starttime));
+
+ exit(EXIT_SUCCESS);
+}
+
+int __xsystem(const char *argv[])
+{
+ int status = 0;
+ pid_t pid;
+ pid = fork();
+ switch (pid) {
+ case -1:
+ perror("fork failed");
+ return -1;
+ case 0:
+ /* child */
+ execvp(argv[0], (char *const *)argv);
+ _exit(-1);
+ default:
+ /* parent */
+ break;
+ }
+ if (waitpid(pid, &status, 0) == -1) {
+ perror("waitpid failed");
+ return -1;
+ }
+ if (WIFSIGNALED(status)) {
+ perror("signal");
+ return -1;
+ }
+ if (!WIFEXITED(status)) {
+ /* shouldn't happen */
+ perror("should not happen");
+ return -1;
+ }
+ return WEXITSTATUS(status);
+}
+
+void __do_print_usage()
+{
+ printf("Package manager tool version: %s\n", PKG_TOOL_VERSION);
+ printf("Copyright (C) 2013-2014 - Application framework team\n");
+ printf("\n");
+ printf("Usage:\n");
+ printf("pkg [-l|--list]\n");
+ printf(" [-i|--install <path>]\n");
+ printf(" [-u|--uninstall <pkgid>]\n");
+ printf(" [-e|--enable <pkgid>]\n");
+ printf(" [-d|--disable <pkgid>]\n");
+ printf(" [-t|--clear-cache <pkgid> | __ALL__]\n");
+ printf(" [--move-to-internal <pkgid>]\n");
+ printf(" [--move-to-external <pkgid>]\n");
+ printf(" [--launch <appid>]\n");
+ printf("\n");
+ printf("Example:\n");
+ printf("pkg -l\n");
+ printf("pkg -i /opt/usr/media/org.tizen.hello_0.1.2_armv7l.tpk\n");
+ printf("pkg -u org.tizen.hello\n");
+ printf("pkg -e org.tizen.hello\n");
+ printf("pkg -d org.tizen.hello\n");
+ printf("pkg -t org.tizen.hello\n");
+ printf("pkg -t __ALL__\n");
+ printf("pkg --move-to-internal org.tizen.hello\n");
+ printf("pkg --move-to-external org.tizen.hello\n");
+ printf("\n");
+}
+
+void __do_print_usage_api_test()
+{
+ printf("Package manager tool version: %s\n", PKG_TOOL_VERSION);
+ printf("Copyright (C) 2013-2014 - Application framework team\n");
+ printf("\n");
+ printf("Usage:\n");
+ printf("pkg -t [option]\n");
+ printf("\n");
+ printf("Option\n");
+ printf("1 --> check fota's result\n");
+ printf("2 --> send signal to make external data directory\n");
+ printf("3 --> clear cache directory\n");
+ printf("4 --> API performance test\n");
+ printf("\n");
+}
+
+int __do_list(pkg_tool_args *pkg_args)
+{
+ int ret = -1;
+
+ printf("%-40s%-30s%-10s%-5s%-10s\n", "PKGID", "NAME", "VER", "EXT", "TYPE");
+ ret = pkgmgrinfo_pkginfo_get_list(__pkgmgr_list_cb, pkg_args);
+ trym_if(ret != 0, "__do_list: pkgmgrinfo_pkginfo_get_list() is failed, ret=%d\n", ret);
+
+catch:
+ return 0;
+}
+
+int __pkgmgr_list_cb(pkgmgrinfo_pkginfo_h handle, void *user_data)
+{
+ int ret = -1;
+ char *pkgid = NULL;
+ char *pkg_type = NULL;
+ char *pkg_version = NULL;
+ char *pkg_label = NULL;
+ bool is_core_pkg = false;
+ bool is_osp_pkg = false;
+ bool is_web_pkg = false;
+ char buf[1024] = {0};
+ pkg_tool_args *pkg_args = (pkg_tool_args *)user_data;
+
+ ret = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
+ if (ret == -1) {
+ printf("Failed to get pkgmgr_pkginfo_get_pkgid\n");
+ return ret;
+ }
+ ret = pkgmgrinfo_pkginfo_get_type(handle, &pkg_type);
+ if (ret == -1) {
+ printf("Failed to get pkgmgr_pkginfo_get_type\n");
+ return ret;
+ }
+ ret = pkgmgrinfo_pkginfo_get_version(handle, &pkg_version);
+ if (ret == -1) {
+ printf("Failed to get pkgmgr_pkginfo_get_version\n");
+ return ret;
+ }
+ ret = pkgmgrinfo_pkginfo_get_label(handle, &pkg_label);
+ if (ret == -1) {
+ printf("Failed to get pkgmgr_pkginfo_get_label\n");
+ return ret;
+ }
+
+ if (pkg_type && strcmp(pkg_type, "wgt") == 0)
+ {
+ snprintf(buf, 1023, "/opt/usr/apps/%s/tizen-manifest.xml", pkgid);
+ if (access(buf, F_OK) == 0)
+ {
+ is_core_pkg = true;
+ }
+
+ snprintf(buf, 1023, "/usr/apps/%s/tizen-manifest.xml", pkgid);
+ if (access(buf, F_OK) == 0)
+ {
+ is_core_pkg = true;
+ }
+
+ snprintf(buf, 1023, "/opt/usr/apps/%s/info/manifest.xml", pkgid);
+ if (access(buf, F_OK) == 0)
+ {
+ is_osp_pkg = true;
+ }
+
+ snprintf(buf, 1023, "/usr/apps/%s/info/manifest.xml", pkgid);
+ if (access(buf, F_OK) == 0)
+ {
+ is_osp_pkg = true;
+ }
+
+ is_web_pkg = true;
+ }
+ else if(pkg_type && strcmp(pkg_type, "rpm") == 0)
+ {
+ snprintf(buf, 1023, "/opt/usr/apps/%s/tizen-manifest.xml", pkgid);
+ if (access(buf, F_OK) == 0)
+ {
+ is_core_pkg = true;
+ }
+
+ snprintf(buf, 1023, "/usr/apps/%s/tizen-manifest.xml", pkgid);
+ if (access(buf, F_OK) == 0)
+ {
+ is_core_pkg = true;
+ }
+ }
+ else if(pkg_type && strcmp(pkg_type, "tpk") == 0)
+ {
+ snprintf(buf, 1023, "/opt/usr/apps/%s/tizen-manifest.xml", pkgid);
+ if (access(buf, F_OK) == 0)
+ {
+ is_core_pkg = true;
+ }
+
+ snprintf(buf, 1023, "/usr/apps/%s/tizen-manifest.xml", pkgid);
+ if (access(buf, F_OK) == 0)
+ {
+ is_core_pkg = true;
+ }
+
+ snprintf(buf, 1023, "/opt/usr/apps/%s/info/manifest.xml", pkgid);
+ if (access(buf, F_OK) == 0)
+ {
+ is_osp_pkg = true;
+ }
+
+ snprintf(buf, 1023, "/usr/apps/%s/info/manifest.xml", pkgid);
+ if (access(buf, F_OK) == 0)
+ {
+ is_osp_pkg = true;
+ }
+ }
+
+ printf("%-40.40s%-30.29s%-10.10s", pkgid, pkg_label, pkg_version);
+ printf("%-5.3s", pkg_type);
+ if (is_web_pkg == true)
+ {
+ printf("%-10s", "web");
+ }
+ if (is_core_pkg == true)
+ {
+ printf("%-10s", "core");
+ }
+ if (is_osp_pkg == true)
+ {
+ printf("%-10s", "osp");
+ }
+ printf("\n");
+
+ if (pkg_args->isListAll == true)
+ {
+ ret = pkgmgrinfo_appinfo_get_list(handle, PM_ALL_APP, __pkgmgr_app_list_cb, user_data);
+ if (ret == -1) {
+ printf("Failed to get pkgmgr_pkginfo_get_type\n");
+ return ret;
+ }
+ }
+
+ return ret;
+}
+
+int __pkgmgr_app_list_cb(pkgmgrinfo_appinfo_h handle, void *user_data)
+{
+ int ret = -1;
+ char *appid = NULL;
+
+ ret = pkgmgrinfo_appinfo_get_appid(handle, &appid);
+ if (ret == -1) {
+ printf("Failed to get pkgmgr_pkginfo_get_pkgid\n");
+ return ret;
+ }
+
+ printf(" \\_ %s\n", appid);
+
+ return 0;
+}
+
+
+int __do_install(pkg_tool_args *args)
+{
+ int ret = -1;
+ pkgmgr_client *pc = NULL;
+
+ g_type_init();
+ main_loop = g_main_loop_new(NULL, FALSE);
+ pc = pkgmgr_client_new(PC_REQUEST);
+ tryvm_if(pc == NULL, ret = PKGCMD_ERR_FATAL_ERROR, "__do_install: pkgmgr client creation failed, ret=%d\n", ret);
+
+ ret = pkgmgr_client_install(pc, NULL, NULL, args->path, NULL, 0, __return_cb, pc);
+ if (ret < 0)
+ {
+ if (access(args->path, F_OK) != 0)
+ {
+ tryvm_if(ret != 0, ret = PKGCMD_ERR_PACKAGE_NOT_FOUND, "__do_install: package not found, ret=%d\n", ret);
+ }
+ else
+ {
+ tryvm_if(ret != 0, ret = PKGCMD_ERR_FATAL_ERROR, "__do_install: fatal error, ret=%d\n", ret);
+ }
+ }
+ g_main_loop_run(main_loop);
+
+ ret = 0;
+catch:
+ return ret;
+}
+
+int __return_cb(int req_id, const char *pkg_type,
+ const char *pkgid, const char *key, const char *val,
+ const void *pmsg, void *priv_data)
+{
+ int ret = -1;
+
+ if (strncmp(key, "error", strlen("error")) == 0)
+ {
+ int ret_val;
+ char delims[] = ":";
+ char *extra_str = NULL;
+ char *ret_result = NULL;
+
+ ret_val = atoi(val);
+ ret = ret_val;
+
+ strtok((char*)val, delims);
+ ret_result = strtok(NULL, delims);
+ if (ret_result)
+ {
+ extra_str = strdup(ret_result);
+ printf(" response:req_id=[%d]:[%s]:[%s]:[%s]:[%d]:[%s]\n", req_id, pkg_type, pkgid, key, ret_val, extra_str);
+ free(extra_str);
+ }
+ else
+ {
+ printf(" response:req_id=[%d]:[%s]:[%s]:[%s]:[%d]\n", req_id, pkg_type, pkgid, key, ret_val);
+ }
+ }
+ else
+ {
+ printf(" response:req_id=[%d]:[%s]:[%s]:[%s]:[%s]\n", req_id, pkg_type, pkgid, key, val);
+ }
+
+ if (strncmp(key, "end", strlen("end")) == 0)
+ {
+ if ((strncmp(val, "fail", strlen("fail")) == 0) && ret == 0)
+ {
+ ret = PKGCMD_ERR_FATAL_ERROR;
+ }
+ g_main_loop_quit(main_loop);
+ }
+
+ return ret;
+}
+
+int __do_uninstall(pkg_tool_args *args)
+{
+ int ret = -1;
+ pkgmgr_client *pc = NULL;
+
+ g_type_init();
+ main_loop = g_main_loop_new(NULL, FALSE);
+
+ pc = pkgmgr_client_new(PC_REQUEST);
+ tryvm_if(pc == NULL, ret = PKGCMD_ERR_FATAL_ERROR, "__do_uninstall: pkgmgr client creation failed, ret=%d\n", ret);
+
+ ret = pkgmgr_client_uninstall(pc, NULL/*data.pkg_type*/, args->pkgid, 0/*mode*/, __return_cb, NULL);
+ tryvm_if(ret < 0, ret = PKGCMD_ERR_FATAL_ERROR, "__do_uninstall: fatal error, ret=%d\n", ret);
+
+ g_main_loop_run(main_loop);
+
+ ret = 0;
+catch:
+ return ret;
+}
+
+int __do_enable(pkg_tool_args *args)
+{
+ int ret = -1;
+ pkgmgr_client *pc = NULL;
+ pkgmgrinfo_pkginfo_h handle = NULL;
+
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(args->pkgid, &handle);
+ tryvm_if(ret == 0, ret = PKGCMD_ERR_FATAL_ERROR, "__do_enable: already enabled, pkgid=%s\n", args->pkgid);
+
+ pc = pkgmgr_client_new(PC_REQUEST);
+ tryvm_if(pc == NULL, ret = PKGCMD_ERR_FATAL_ERROR, "__do_enable: pkgmgr client creation failed, ret=%d\n", ret);
+
+ ret = pkgmgr_client_activate(pc, NULL, args->pkgid);
+ tryvm_if(ret < 0, ret = PKGCMD_ERR_FATAL_ERROR, "__do_enable: fatal error, ret=%d\n", ret);
+
+ sleep(1);
+
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(args->pkgid, &handle);
+ tryvm_if(ret < 0, ret = PKGCMD_ERR_FATAL_ERROR, "__do_enable: fail to enable, pkgid=%s\n", args->pkgid);
+
+ printf("success\n");
+ __pkgmgr_list_cb(handle, args);
+
+ ret = 0;
+catch:
+ return ret;
+}
+
+int __do_disable(pkg_tool_args *args)
+{
+ int ret = -1;
+ pkgmgr_client *pc = NULL;
+ pkgmgrinfo_pkginfo_h handle = NULL;
+
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(args->pkgid, &handle);
+ tryvm_if(ret < 0, ret = PKGCMD_ERR_FATAL_ERROR, "__do_disable: not installed, pkgid=%s\n", args->pkgid);
+
+ pc = pkgmgr_client_new(PC_REQUEST);
+ tryvm_if(pc == NULL, ret = PKGCMD_ERR_FATAL_ERROR, "__do_disable: pkgmgr client creation failed, ret=%d\n", ret);
+
+ ret = pkgmgr_client_deactivate(pc, NULL, args->pkgid);
+ tryvm_if(ret < 0, ret = PKGCMD_ERR_FATAL_ERROR, "__do_disable: fatal error, ret=%d\n", ret);
+
+ sleep(1);
+
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(args->pkgid, &handle);
+ tryvm_if(ret == 0, ret = PKGCMD_ERR_FATAL_ERROR, "__do_disable: fail to disable, pkgid=%s\n", args->pkgid);
+ printf("success\n");
+
+ ret = 0;
+catch:
+ return ret;
+}
+
+int __do_move_to_internal(pkg_tool_args *args)
+{
+ printf("__do_move_to_internal\n");
+ return 0;
+}
+
+int __do_move_to_external(pkg_tool_args *args)
+{
+ printf("__do_move_to_external\n");
+ return 0;
+}
+
+int __do_launch(pkg_tool_args *args)
+{
+ printf("__do_launch\n");
+ return 0;
+}
+
+int __do_info(pkg_tool_args *args)
+{
+ printf("__do_info\n");
+
+ if (args->pkgid[0])
+ {
+ printf("__do_info_by_pkgid\n");
+ __do_info_by_pkgid(args->pkgid);
+ }
+ else if (args->appid[0])
+ {
+ printf("__do_info_by_appid\n");
+ __do_info_by_appid(args->appid);
+ }
+
+ return 0;
+}
+
+int __do_info_by_pkgid(const char* pkgid)
+{
+ int ret = -1;
+ pkgmgrinfo_pkginfo_h handle = NULL;
+
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+ tryvm_if(ret < 0, ret = PKGCMD_ERR_FATAL_ERROR, "__do_info_by_pkgid: failed to get handle, pkgid=%s\n", pkgid);
+
+ ret = pkgmgrinfo_appinfo_get_list(handle, PM_ALL_APP, __do_info_app_func, (void*)pkgid);
+ tryvm_if(ret < 0, ret = PKGCMD_ERR_FATAL_ERROR, "__do_info_by_pkgid: pkgmgrinfo_appinfo_get_list() failed, pkgid=%s\n", pkgid);
+
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ handle = NULL;
+
+ ret = 0;
+catch:
+ if (handle)
+ {
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ }
+
+ return ret;
+}
+
+int __do_info_app_func(pkgmgrinfo_appinfo_h handle, void *user_data)
+{
+ char *appid = NULL;
+ char *data = NULL;
+ if (user_data) {
+ data = (char *)user_data;
+ }
+ int ret = -1;
+ char *exec = NULL;
+ char *icon = NULL;
+ char *label = NULL;
+ pkgmgrinfo_app_component component = 0;
+ char *apptype = NULL;
+ bool nodisplay = 0;
+ bool multiple = 0;
+ bool taskmanage = 0;
+ pkgmgrinfo_app_hwacceleration hwacceleration;
+ pkgmgrinfo_app_screenreader screenreader;
+ bool support_disable = 0;
+ bool onboot = 0;
+ bool autorestart = 0;
+ char *package = NULL;
+
+ ret = pkgmgrinfo_appinfo_get_appid(handle, &appid);
+ if (ret < 0) {
+ printf("Failed to get appid\n");
+ }
+ if (appid)
+ printf("Appid: %s\n", appid);
+
+ ret = pkgmgrinfo_appinfo_get_pkgid(handle, &package);
+ if (ret < 0) {
+ printf("Failed to get package\n");
+ }
+ if (package)
+ printf("Package: %s\n", package);
+
+ ret = pkgmgrinfo_appinfo_get_exec(handle, &exec);
+ if (ret < 0) {
+ printf("Failed to get exec\n");
+ }
+ if (exec)
+ printf("Exec: %s\n", exec);
+
+ ret = pkgmgrinfo_appinfo_get_icon(handle, &icon);
+ if (ret < 0) {
+ printf("Failed to get icon\n");
+ }
+ if (icon)
+ printf("Icon: %s\n", icon);
+
+ ret = pkgmgrinfo_appinfo_get_label(handle, &label);
+ if (ret < 0) {
+ printf("Failed to get label\n");
+ }
+ if (label)
+ printf("Label: %s\n", label);
+
+ ret = pkgmgrinfo_appinfo_get_component(handle, &component);
+ if (ret < 0) {
+ printf("Failed to get component\n");
+ }
+
+ ret = pkgmgrinfo_appinfo_get_apptype(handle, &apptype);
+ if (ret < 0) {
+ printf("Failed to get apptype\n");
+ }
+ if (apptype)
+ printf("Apptype: %s\n", apptype);
+
+ if (component == PMINFO_UI_APP) {
+ printf("component: uiapp\n");
+ ret = pkgmgrinfo_appinfo_is_multiple(handle, &multiple);
+ if (ret < 0) {
+ printf("Failed to get multiple\n");
+ } else {
+ printf("Multiple: %d\n", multiple);
+ }
+
+ ret = pkgmgrinfo_appinfo_is_nodisplay(handle, &nodisplay);
+ if (ret < 0) {
+ printf("Failed to get nodisplay\n");
+ } else {
+ printf("Nodisplay: %d \n", nodisplay);
+ }
+
+ ret = pkgmgrinfo_appinfo_is_taskmanage(handle, &taskmanage);
+ if (ret < 0) {
+ printf("Failed to get taskmanage\n");
+ } else {
+ printf("Taskmanage: %d\n", taskmanage);
+ }
+
+ ret = pkgmgrinfo_appinfo_get_hwacceleration(handle, &hwacceleration);
+ if (ret < 0) {
+ printf("Failed to get hwacceleration\n");
+ } else {
+ printf("hw-acceleration: %d\n", hwacceleration);
+ }
+
+ ret = pkgmgrinfo_appinfo_get_screenreader(handle, &screenreader);
+ if (ret < 0) {
+ printf("Failed to get screenreader\n");
+ } else {
+ printf("screenreader: %d\n", screenreader);
+ }
+
+ ret = pkgmgrinfo_appinfo_is_support_disable(handle, &support_disable);
+ if (ret < 0) {
+ printf("Failed to get support-disable\n");
+ } else {
+ printf("support-disable: %d\n", support_disable);
+ }
+ }
+ if (component == PMINFO_SVC_APP) {
+ printf("component: svcapp\n");
+ ret = pkgmgrinfo_appinfo_is_onboot(handle, &onboot);
+ if (ret < 0) {
+ printf("Failed to get onboot\n");
+ } else {
+ printf("Onboot: %d\n", onboot);
+ }
+
+ ret = pkgmgrinfo_appinfo_is_autorestart(handle, &autorestart);
+ if (ret < 0) {
+ printf("Failed to get autorestart\n");
+ } else {
+ printf("Autorestart: %d \n", autorestart);
+ }
+ }
+ if (data)
+ printf("user_data : %s\n\n", data);
+
+ return 0;
+}
+
+int __do_info_by_appid(const char* appid)
+{
+ return 0;
+}
+
+static void __run_query(sqlite3 *database, char *query, sqlite3_stmt *stmt, FILE *fp)
+{
+ int col = 0;
+ int cols = 0;
+ int ret = 0;
+ char *colname = NULL;
+ char *coltxt = NULL;
+
+ ret = sqlite3_prepare_v2(database, query, strlen(query), &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ printf("[%s]sqlite3_prepare_v2 error!!\n", query);
+ return;
+ }
+
+ cols = sqlite3_column_count(stmt);
+ while(1)
+ {
+ ret = sqlite3_step(stmt);
+ if(ret == SQLITE_ROW) {
+ for(col = 0; col < cols; col++)
+ {
+ colname = (char *)sqlite3_column_name(stmt, col);
+ if (strcmp(colname, "installed_time")==0) {
+ continue;
+ }
+ coltxt = (char *)sqlite3_column_text(stmt, col);
+ fprintf(fp, "%s-%s\n", colname, coltxt);
+// printf("%s-%s\n", colname, coltxt);
+ }
+ ret = 0;
+ } else {
+ break;
+ }
+ }
+
+}
+
+static void __make_pkginfo_file(char *db_file, char *file_path, char *pkgid)
+{
+ int ret = 0;
+ char *query = NULL;
+ sqlite3 *info_db = NULL;
+ sqlite3_stmt *stmt = NULL;
+ FILE *fp;
+
+ fp = fopen(file_path, "w");
+ if (fp == NULL) {
+ printf("[%s]fopen error!!\n", PKGID_LIST_FILE);
+ return;
+ }
+
+ ret = db_util_open(db_file, &info_db, 0);
+ if (ret != SQLITE_OK) {
+ printf("[%s]db_util_open error!!\n", db_file);
+ fclose(fp);
+ return;
+ }
+
+ query = sqlite3_mprintf("select * from package_info "\
+ "LEFT OUTER JOIN package_privilege_info ON package_info.package=package_privilege_info.package "\
+ "LEFT OUTER JOIN package_plugin_info ON package_info.package=package_plugin_info.pkgid "\
+ "where package_info.package=%Q", pkgid);
+
+ __run_query(info_db, query, stmt, fp);
+
+ fclose(fp);
+ sqlite3_free(query);
+ sqlite3_finalize(stmt);
+ sqlite3_close(info_db);
+}
+
+
+static void __make_appinfo_file(char *db_file, char *file_path, char *appid)
+{
+ int ret = 0;
+ char *query = NULL;
+ sqlite3 *info_db = NULL;
+ sqlite3_stmt *stmt = NULL;
+ FILE *fp;
+
+ fp = fopen(file_path, "w");
+ if (fp == NULL) {
+ printf("[%s]fopen error!!\n", PKGID_LIST_FILE);
+ return;
+ }
+
+ ret = db_util_open(db_file, &info_db, 0);
+ if (ret != SQLITE_OK) {
+ printf("[%s]db_util_open error!!\n", db_file);
+ fclose(fp);
+ return;
+ }
+
+ query = sqlite3_mprintf("select * from package_app_info where app_id=%Q", appid);
+ __run_query(info_db, query, stmt, fp);
+ sqlite3_free(query);
+ sqlite3_finalize(stmt);
+
+ query = sqlite3_mprintf("select * from package_app_app_category where app_id=%Q", appid);
+ __run_query(info_db, query, stmt, fp);
+ sqlite3_free(query);
+ sqlite3_finalize(stmt);
+
+ query = sqlite3_mprintf("select * from package_app_app_metadata where app_id=%Q", appid);
+ __run_query(info_db, query, stmt, fp);
+ sqlite3_free(query);
+ sqlite3_finalize(stmt);
+
+ query = sqlite3_mprintf("select * from package_app_app_control where app_id=%Q", appid);
+ __run_query(info_db, query, stmt, fp);
+ sqlite3_free(query);
+ sqlite3_finalize(stmt);
+
+ query = sqlite3_mprintf("select * from package_app_localized_info where app_id=%Q", appid);
+ __run_query(info_db, query, stmt, fp);
+
+ fclose(fp);
+ sqlite3_free(query);
+ sqlite3_finalize(stmt);
+ sqlite3_close(info_db);
+}
+
+static void __make_pkgid_list()
+{
+ int ret = 0;
+ char *query = NULL;
+ sqlite3 *info_db = NULL;
+ sqlite3_stmt *stmt = NULL;
+ FILE *fp;
+
+ fp = fopen(PKGID_LIST_FILE, "w");
+ if (fp == NULL) {
+ printf("[%s]fopen error!!\n", PKGID_LIST_FILE);
+ return;
+ }
+
+ ret = db_util_open(PKGMGR_DB, &info_db, 0);
+ if (ret != SQLITE_OK) {
+ printf("[%s]db_util_open error!!\n", PKGMGR_DB);
+ fclose(fp);
+ return;
+ }
+ query = sqlite3_mprintf("select package from package_info where package_system like 'true' order by package asc");
+
+ ret = sqlite3_prepare_v2(info_db, query, strlen(query), &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ printf("[%s]sqlite3_prepare_v2 error!!\n", query);
+ goto end;
+ }
+
+ while(1) {
+ ret = sqlite3_step(stmt);
+ if(ret == SQLITE_ROW) {
+ fprintf(fp, "%s\n", (const char *)sqlite3_column_text(stmt, 0));
+// printf("pkgid == %s\n" ,(const char *)sqlite3_column_text(stmt, 0));
+ } else {
+ break;
+ }
+ }
+
+end:
+
+ fclose(fp);
+ sqlite3_free(query);
+ sqlite3_finalize(stmt);
+ sqlite3_close(info_db);
+}
+
+static void __make_appid_list()
+{
+ int ret = 0;
+ char *query = NULL;
+ sqlite3 *info_db = NULL;
+ sqlite3_stmt *stmt = NULL;
+ FILE *fp;
+
+ fp = fopen(APPID_LIST_FILE, "w");
+ if (fp == NULL) {
+ printf("[%s]fopen error!!\n", APPID_LIST_FILE);
+ return;
+ }
+
+ ret = db_util_open(PKGMGR_DB, &info_db, 0);
+ if (ret != SQLITE_OK) {
+ printf("[%s]db_util_open error!!\n", PKGMGR_DB);
+ fclose(fp);
+ return;
+ }
+ query = sqlite3_mprintf("select app_id from package_app_info where app_preload like 'true' order by app_id asc");
+
+ ret = sqlite3_prepare_v2(info_db, query, strlen(query), &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ printf("[%s]sqlite3_prepare_v2 error!!\n", query);
+ goto end;
+ }
+
+ while(1) {
+ ret = sqlite3_step(stmt);
+ if(ret == SQLITE_ROW) {
+ fprintf(fp, "%s\n", (const char *)sqlite3_column_text(stmt, 0));
+// printf("pkgid == %s\n" ,(const char *)sqlite3_column_text(stmt, 0));
+ } else {
+ break;
+ }
+ }
+
+end:
+
+ fclose(fp);
+ sqlite3_free(query);
+ sqlite3_finalize(stmt);
+ sqlite3_close(info_db);
+}
+
+static int __compare_files(char *ori_file, char *zip_file)
+{
+ int ret = 0;
+ FILE *ori_fp = NULL;
+ FILE *zip_fp = NULL;
+ char ori_buf[BUF_SIZE] = {0};
+ char zip_buf[BUF_SIZE] = {0};
+
+ ori_fp = fopen(ori_file, "r");
+ if (ori_fp == NULL) {
+ printf("Fail get : %s\n", PKGID_LIST_FILE);
+ return -1;
+ }
+
+ zip_fp = fopen(zip_file, "r");
+ if (zip_fp == NULL) {
+ printf("Fail get : %s\n", PKGID_LIST_FILE);
+ fclose(ori_fp);
+ return -1;
+ }
+
+ while ((fgets(ori_buf, BUF_SIZE, ori_fp) != NULL) && (fgets(zip_buf, BUF_SIZE, zip_fp) != NULL)) {
+ ori_buf[strlen(ori_buf) - 1] = '\0';
+ zip_buf[strlen(zip_buf) - 1] = '\0';
+
+ if(strcasecmp(ori_buf, zip_buf) != 0) {
+ printf("-----------------------------------------------------------------------------\n");
+ printf("different value == %s , %s\n", ori_buf, zip_buf);
+ ret = -1;
+ break;
+ }
+
+ memset(zip_buf, 0x00, BUF_SIZE);
+ memset(ori_buf, 0x00, BUF_SIZE);
+ }
+ fclose(zip_fp);
+ fclose(ori_fp);
+
+ return ret;
+}
+
+static int __check_time(long privous_time)
+{
+ long current_time;
+ struct timeval tv;
+
+ gettimeofday(&tv, NULL);
+ current_time = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
+
+ return (int)(current_time - privous_time);
+}
+
+static void __check_fota_prepare()
+{
+ int ret = 0;
+
+ __make_pkgid_list();
+ __make_appid_list();
+
+ const char *unzip_argv[] = { "/usr/bin/unzip", "-jo", FACTORYRESET_BACKUP_FILE, "opt/dbspace/.pkgmgr_parser.db", "-d", PKGMGR_FOTA_PATH, NULL };
+ ret = __xsystem(unzip_argv);
+ if (ret < 0) {
+ printf("unzip pkgmgr db from factoryrest data fail.\n");
+ }
+}
+
+static void __check_fota_process_pkg()
+{
+ int ret = 0;
+ FILE *fp = NULL;
+ char buf[BUF_SIZE] = {0};
+ char ori_file[BUF_SIZE] = {0};
+ char zip_file[BUF_SIZE] = {0};
+
+ fp = fopen(PKGID_LIST_FILE, "r");
+ if (fp == NULL) {
+ printf("Fail get : %s\n", PKGID_LIST_FILE);
+ return;
+ }
+ printf("=============================================================================\n");
+ printf("%-70s%-60s\n", "PKGID", "RESULT");
+ printf("=============================================================================\n");
+
+ while (fgets(buf, BUF_SIZE, fp) != NULL) {
+ buf[strlen(buf) - 1] = '\0';
+
+ snprintf(ori_file, sizeof(ori_file), "%s%s-ori", PKGMGR_FOTA_PATH, buf);
+ __make_pkginfo_file(PKGMGR_DB, ori_file, buf);
+
+ snprintf(zip_file, sizeof(zip_file), "%s%s-zip", PKGMGR_FOTA_PATH, buf);
+ __make_pkginfo_file(ZIP_PKGMGR_DB, zip_file, buf);
+
+ ret = __compare_files(ori_file, zip_file);
+ if (ret < 0) {
+ printf("%-70s%-60s\n", buf, "different");
+ printf("-----------------------------------------------------------------------------\n");
+ } else {
+ printf("%-70s%-60s\n", buf, "same");
+
+ const char *delete_argv[] = { "/bin/rm", ori_file, zip_file, NULL };
+ ret = __xsystem(delete_argv);
+ if (ret < 0) {
+ printf("delete fail.\n");
+ }
+ }
+
+ memset(ori_file, 0x00, BUF_SIZE);
+ memset(zip_file, 0x00, BUF_SIZE);
+ }
+
+ if (fp != NULL)
+ fclose(fp);
+}
+
+static void __check_fota_process_app()
+{
+ int ret = 0;
+ FILE *fp = NULL;
+ char buf[BUF_SIZE] = {0};
+ char ori_file[BUF_SIZE] = {0};
+ char zip_file[BUF_SIZE] = {0};
+
+ fp = fopen(APPID_LIST_FILE, "r");
+ if (fp == NULL) {
+ printf("Fail get : %s\n", APPID_LIST_FILE);
+ return;
+ }
+ printf("=============================================================================\n");
+ printf("%-70s%-60s\n", "APPID", "RESULT");
+ printf("=============================================================================\n");
+
+ while (fgets(buf, BUF_SIZE, fp) != NULL) {
+ buf[strlen(buf) - 1] = '\0';
+
+ snprintf(ori_file, sizeof(ori_file), "%s%s-appori", PKGMGR_FOTA_PATH, buf);
+ __make_appinfo_file(PKGMGR_DB, ori_file, buf);
+
+ snprintf(zip_file, sizeof(zip_file), "%s%s-appzip", PKGMGR_FOTA_PATH, buf);
+ __make_appinfo_file(ZIP_PKGMGR_DB, zip_file, buf);
+
+ ret = __compare_files(ori_file, zip_file);
+ if (ret < 0) {
+ printf("%-70s%-60s\n", buf, "different");
+ printf("-----------------------------------------------------------------------------\n");
+ } else {
+ printf("%-70s%-60s\n", buf, "same");
+
+ const char *delete_argv[] = { "/bin/rm", ori_file, zip_file, NULL };
+ ret = __xsystem(delete_argv);
+ if (ret < 0) {
+ printf("delete fail.\n");
+ }
+ }
+
+ memset(ori_file, 0x00, BUF_SIZE);
+ memset(zip_file, 0x00, BUF_SIZE);
+ }
+
+ if (fp != NULL)
+ fclose(fp);
+}
+
+static void __check_fota_post()
+{
+ const char *delete_argv[] = { "/bin/rm", ZIP_PKGMGR_DB, PKGID_LIST_FILE, APPID_LIST_FILE, NULL };
+ if (__xsystem(delete_argv) < 0) {
+ printf("delete fail.\n");
+ }
+
+ printf("==========================================================================\n");
+ printf("\t\t\t\t finish\n");
+ printf("==========================================================================\n");
+}
+
+static void __check_fota_result()
+{
+ __check_fota_prepare();
+ __check_fota_process_pkg();
+ __check_fota_process_app();
+ __check_fota_post();
+}
+
+static void __clear_cache_dir()
+{
+ int ret = 0;
+ printf("========================================================\n");
+ printf("\t\t clear cache directory\n");
+
+ ret = pkgmgr_client_clear_all_cache_dir();
+ if (ret < 0)
+ printf("pkgmgr_client_clear_all_cache_dir fail\n");
+ printf("========================================================\n");
+}
+
+static void __send_event_make_exdir()
+{
+ DBusConnection *bus = NULL;
+ DBusMessage *message = NULL;
+
+ printf("========================================================\n");
+
+ printf("\t\t send event to pkgmgr server\n");
+ printf("\t\t Method = %s\n", COMM_PKG_MGR_METHOD_CREATE_EXTERNAL_DIRECTORY);
+
+ bus = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ retm_if(bus == NULL, "dbus_bus_get() failed.\n");
+
+ message = dbus_message_new_method_call(COMM_PKG_MGR_DBUS_SERVICE,
+ COMM_PKG_MGR_DBUS_PATH, COMM_PKG_MGR_DBUS_INTERFACE,
+ COMM_PKG_MGR_METHOD_CREATE_EXTERNAL_DIRECTORY);
+ retm_if(message == NULL, "dbus_message_new_method_call() failed.\n");
+
+ if(dbus_connection_send_with_reply_and_block(bus, message, -1, NULL) == NULL){
+ printf("DBUS msg send error!!\n");
+ }
+
+ dbus_connection_flush(bus);
+ dbus_message_unref(message);
+
+ printf("========================================================\n");
+}
+
+static int __pkg_list_cb(pkgmgrinfo_pkginfo_h handle, void *user_data)
+{
+ int ret = 0;
+ char *pkgid = NULL;
+
+ ret = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
+ if (ret != PMINFO_R_OK) {
+ return -1;
+ }
+
+ if (pkgid != NULL) {
+ if (strcmp(pkgid, TEST_PKGID) == 0) {
+ printf("success - find matched pkgid!!\n");
+ } else {
+// _LOG("test log : %s", pkgid);
+ }
+ }
+ return 0;
+}
+
+static int __app_list_cb(pkgmgrinfo_appinfo_h handle, void *user_data)
+{
+ int ret = 0;
+ char *appid = NULL;
+ ret = pkgmgrinfo_appinfo_get_appid(handle, &appid);
+ if (ret != PMINFO_R_OK) {
+ return -1;
+ }
+
+ if (appid != NULL) {
+ if (strcmp(appid, TEST_APPID) == 0) {
+ printf("success - find matched appid!!\n");
+ } else {
+// _LOG("test log : %s", appid);
+ }
+ }
+ return 0;
+}
+
+static int __tc_01()
+{
+ int ret = 0;
+ char *type = NULL;
+ char *version = NULL;
+ pkgmgrinfo_pkginfo_h handle = NULL;
+
+ long check_time = 0;;
+ int spend_time = 0;
+ struct timeval tv;
+
+
+ printf("--------------------------------------------------------\n");
+ printf("TC 01 : pkgmgrinfo_pkginfo_get_pkginfo\n");
+ printf("### Access DB table list ###\n");
+ printf("package_info\n");
+ printf("package_privilege_info\n");
+ printf("package_localized_info\n");
+
+ gettimeofday(&tv, NULL);
+ check_time = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
+
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(TEST_PKGID, &handle);
+ if (ret != PMINFO_R_OK) {
+ printf("pkgmgrinfo_pkginfo_get_pkginfo : fail\n");
+ goto end;
+ }
+
+ printf("pkgid : %s\n", TEST_PKGID);
+
+ ret = pkgmgrinfo_pkginfo_get_type(handle, &type);
+ if (ret != PMINFO_R_OK) {
+ printf("pkgmgrinfo_pkginfo_get_type : fail\n");
+ goto end;
+ }
+ printf("type : %s\n", type);
+
+ ret = pkgmgrinfo_pkginfo_get_version(handle, &version);
+ if (ret != PMINFO_R_OK) {
+ printf("pkgmgrinfo_pkginfo_get_version : fail\n");
+ goto end;
+ }
+ printf("version : %s\n", version);
+
+end:
+ if(handle)
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+
+ if (ret == PMINFO_R_OK) {
+ printf("TC 01 result :: OK\n");
+ } else {
+ printf("TC 01 result :: fail\n");
+ }
+
+ spend_time = __check_time(check_time);
+ return spend_time;
+}
+
+static int __tc_02()
+{
+ int ret = 0;
+
+ long check_time = 0;
+ int spend_time = 0;
+ struct timeval tv;
+
+ printf("--------------------------------------------------------\n");
+ printf("TC 02 : pkgmgrinfo_pkginfo_get_list\n");
+ printf("### Access DB table list ###\n");
+ printf("package_info\n");
+ printf("package_privilege_info\n");
+ printf("package_localized_info\n");
+
+ gettimeofday(&tv, NULL);
+ check_time = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
+
+ ret = pkgmgrinfo_pkginfo_get_list(__pkg_list_cb, NULL);
+ if (ret != PMINFO_R_OK) {
+ printf("pkgmgrinfo_pkginfo_get_list : fail\n");
+ goto end;
+ }
+
+end:
+
+ if (ret == PMINFO_R_OK) {
+ printf("TC 02 result :: OK\n");
+ } else {
+ printf("TC 02 result :: fail\n");
+ }
+
+ spend_time = __check_time(check_time);
+ return spend_time;
+}
+
+static int __tc_03()
+{
+ int ret = 0;
+ long check_time = 0;
+ int spend_time = 0;
+ struct timeval tv;
+
+ pkgmgrinfo_pkginfo_filter_h handle ;
+
+ printf("--------------------------------------------------------\n");
+ printf("TC 03 : pkgmgrinfo_pkginfo_filter_foreach_pkginfo\n");
+ printf("### Access DB table list ###\n");
+ printf("package_info\n");
+ printf("package_localized_info\n");
+
+ gettimeofday(&tv, NULL);
+ check_time = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
+
+ ret = pkgmgrinfo_pkginfo_filter_create(&handle);
+ if (ret != PMINFO_R_OK) {
+ printf("pkgmgrinfo_pkginfo_filter_create : fail\n");
+ goto end;
+ }
+
+ ret = pkgmgrinfo_pkginfo_filter_add_string(handle, PMINFO_PKGINFO_PROP_PACKAGE_TYPE, "rpm\n");
+ if (ret != PMINFO_R_OK) {
+ printf("pkgmgrinfo_pkginfo_filter_add_string : fail\n");
+ goto end;
+ }
+
+ ret = pkgmgrinfo_pkginfo_filter_foreach_pkginfo(handle, __pkg_list_cb, NULL);
+ if (ret != PMINFO_R_OK) {
+ printf("pkgmgrinfo_pkginfo_filter_foreach_pkginfo : fail\n");
+ goto end;
+ }
+
+end:
+ if (ret == PMINFO_R_OK) {
+ printf("TC 03 result :: OK\n");
+ } else {
+ printf("TC 03 result :: fail\n");
+ }
+
+ if(handle)
+ pkgmgrinfo_pkginfo_filter_destroy(handle);
+
+ spend_time = __check_time(check_time);
+ return spend_time;
+}
+
+static int __tc_04()
+{
+ int ret = 0;
+ long check_time = 0;
+ int spend_time = 0;
+ struct timeval tv;
+ pkgmgrinfo_pkginfo_h handle;
+
+ printf("--------------------------------------------------------\n");
+ printf("TC 04 : pkgmgrinfo_appinfo_get_list\n");
+ printf("### Access DB table list ###\n");
+ printf("package_app_info\n");
+ printf("package_app_localized_info\n");
+ printf("package_app_icon_section_info\n");
+ printf("package_app_image_info\n");
+ printf("package_app_app_catogory\n");
+ printf("package_app_app_metadata\n");
+
+ gettimeofday(&tv, NULL);
+ check_time = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
+
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(TEST_PKGID, &handle);
+ if (ret != PMINFO_R_OK) {
+ printf("pkgmgrinfo_pkginfo_get_pkginfo : fail\n");
+ goto end;
+ }
+
+ ret = pkgmgrinfo_appinfo_get_list(handle, PMINFO_UI_APP, __app_list_cb, NULL);
+ if (ret != PMINFO_R_OK) {
+ printf("pkgmgrinfo_appinfo_get_list : fail\n");
+ goto end;
+ }
+
+end:
+ if(handle)
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+
+ if (ret == PMINFO_R_OK) {
+ printf("TC 04 result :: OK\n");
+ } else {
+ printf("TC 04 result :: fail\n");
+ }
+
+ spend_time = __check_time(check_time);
+ return spend_time;
+}
+
+static int __tc_05()
+{
+ int ret = 0;
+ char *label = NULL;
+ char *icon = NULL;
+
+ long check_time = 0;
+ int spend_time = 0;
+ struct timeval tv;
+
+ pkgmgrinfo_appinfo_h handle = NULL;
+
+ printf("--------------------------------------------------------\n");
+ printf("TC 05 : pkgmgrinfo_appinfo_get_appinfo\n");
+ printf("### Access DB table list ###\n");
+ printf("package_app_info\n");
+ printf("package_app_localized_info\n");
+ printf("package_app_app_category\n");
+ printf("package_app_app_metadata\n");
+ printf("package_app_app_permission\n");
+ printf("package_app_icon_section_info\n");
+ printf("package_app_image_info\n");
+
+ gettimeofday(&tv, NULL);
+ check_time = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
+
+ ret = pkgmgrinfo_appinfo_get_appinfo(TEST_APPID, &handle);
+ if (ret != PMINFO_R_OK) {
+ printf("pkgmgrinfo_appinfo_get_appinfo : fail\n");
+ goto end;
+ }
+
+ printf("appid : %s\n", TEST_APPID);
+
+ ret = pkgmgrinfo_appinfo_get_label(handle, &label);
+ if (ret != PMINFO_R_OK) {
+ printf("pkgmgrinfo_appinfo_get_label : fail\n");
+ goto end;
+ }
+ printf("label : %s\n", label);
+
+ ret = pkgmgrinfo_appinfo_get_icon(handle, &icon);
+ if (ret != PMINFO_R_OK) {
+ printf("pkgmgrinfo_appinfo_get_icon : fail\n");
+ goto end;
+ }
+ printf("icon : %s\n", icon);
+
+end:
+ if(handle)
+ pkgmgrinfo_appinfo_destroy_appinfo(handle);
+
+ if (ret == PMINFO_R_OK) {
+ printf("TC 05 result :: OK\n");
+ } else {
+ printf("TC 05 result :: fail\n");
+ }
+
+ spend_time = __check_time(check_time);
+ return spend_time;
+}
+
+static int __tc_06()
+{
+ int ret = 0;
+ long check_time = 0;;
+ int spend_time = 0;
+ struct timeval tv;
+
+ printf("--------------------------------------------------------\n");
+ printf("TC 06 : pkgmgrinfo_appinfo_get_install_list\n");
+ printf("### Access DB table list ###\n");
+ printf("package_app_info\n");
+
+ gettimeofday(&tv, NULL);
+ check_time = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
+
+ ret = pkgmgrinfo_appinfo_get_install_list(__app_list_cb, NULL);
+ if (ret != PMINFO_R_OK) {
+ printf("pkgmgrinfo_appinfo_get_install_list : fail\n");
+ goto end;
+ }
+
+end:
+ if (ret == PMINFO_R_OK) {
+ printf("TC 06 result :: OK\n");
+ } else {
+ printf("TC 06 result :: fail\n");
+ }
+
+ spend_time = __check_time(check_time);
+ return spend_time;
+}
+
+static int __tc_07()
+{
+ int ret = 0;
+ long check_time = 0;
+ int spend_time = 0;
+ struct timeval tv;
+
+ printf("--------------------------------------------------------\n");
+ printf("TC 07 : pkgmgrinfo_appinfo_get_installed_list\n");
+ printf("### Access DB table list ###\n");
+ printf("package_app_info\n");
+ printf("package_app_localized_info\n");
+ printf("package_app_icon_section_info\n");
+ printf("package_app_image_info\n");
+
+ gettimeofday(&tv, NULL);
+ check_time = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
+
+ ret = pkgmgrinfo_appinfo_get_installed_list(__app_list_cb, NULL);
+ if (ret != PMINFO_R_OK) {
+ printf("pkgmgrinfo_appinfo_get_install_list : fail\n");
+ goto end;
+ }
+
+end:
+ if (ret == PMINFO_R_OK) {
+ printf("TC 07 result :: OK\n");
+ } else {
+ printf("TC 07 result :: fail\n");
+ }
+
+ spend_time = __check_time(check_time);
+ return spend_time;
+}
+
+static int __tc_08()
+{
+ int ret = 0;
+
+ long check_time = 0;
+ int spend_time = 0;
+ struct timeval tv;
+
+ pkgmgrinfo_appinfo_filter_h handle = NULL;
+
+ printf("--------------------------------------------------------\n");
+ printf("TC 08 : pkgmgrinfo_appinfo_filter_foreach_appinfo\n");
+ printf("### Access DB table list ###\n");
+ printf("package_app_info\n");
+
+ gettimeofday(&tv, NULL);
+ check_time = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
+
+ ret = pkgmgrinfo_appinfo_filter_create(&handle);
+ if (ret != PMINFO_R_OK) {
+ printf("pkgmgrinfo_appinfo_filter_create : fail\n");
+ goto end;
+ }
+
+ ret = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_NODISPLAY, 1);
+ if (ret != PMINFO_R_OK) {
+ printf("pkgmgrinfo_appinfo_filter_add_string : fail\n");
+ goto end;
+ }
+
+ ret = pkgmgrinfo_appinfo_filter_foreach_appinfo(handle, __app_list_cb, NULL);
+ if (ret != PMINFO_R_OK) {
+ printf("pkgmgrinfo_appinfo_filter_foreach_appinfo : fail\n");
+ goto end;
+ }
+
+end:
+ if(handle)
+ pkgmgrinfo_appinfo_filter_destroy(handle);
+
+ if (ret == PMINFO_R_OK) {
+ printf("TC 08 result :: OK\n");
+ } else {
+ printf("TC 08 result :: fail\n");
+ }
+
+ spend_time = __check_time(check_time);
+ return spend_time;
+}
+
+static int __tc_09()
+{
+ int ret = 0;
+
+ long check_time;
+ int spend_time = 0;
+ struct timeval tv;
+
+ pkgmgrinfo_appinfo_metadata_filter_h handle = NULL;
+
+ printf("--------------------------------------------------------\n");
+ printf("TC 09 : pkgmgrinfo_appinfo_metadata_filter_foreach\n");
+ printf("### Access DB table list ###\n");
+ printf("package_app_info\n");
+
+ gettimeofday(&tv, NULL);
+ check_time = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
+
+ ret = pkgmgrinfo_appinfo_metadata_filter_create(&handle);
+ if (ret != PMINFO_R_OK) {
+ printf("pkgmgrinfo_appinfo_metadata_filter_create : fail\n");
+ goto end;
+ }
+
+ ret = pkgmgrinfo_appinfo_metadata_filter_add(handle, "http://developer.samsung.com/tizen/metadata/splash", NULL);
+ if (ret != PMINFO_R_OK) {
+ printf("pkgmgrinfo_appinfo_metadata_filter_add : fail\n");
+ goto end;
+ }
+
+ ret = pkgmgrinfo_appinfo_metadata_filter_foreach(handle, __app_list_cb, NULL);
+ if (ret != PMINFO_R_OK) {
+ printf("pkgmgrinfo_appinfo_filter_foreach : fail\n");
+ goto end;
+ }
+
+end:
+ if(handle)
+ pkgmgrinfo_appinfo_metadata_filter_destroy(handle);
+
+ if (ret == PMINFO_R_OK) {
+ printf("TC 09 result :: OK\n");
+ } else {
+ printf("TC 09 result :: fail\n");
+ }
+
+ spend_time = __check_time(check_time);
+ return spend_time;
+}
+
+static int __tc_10()
+{
+ int ret = 0;
+ long check_time = 0;
+ int spend_time = 0;
+ struct timeval tv;
+ int count = 0;
+
+ pkgmgrinfo_pkginfo_filter_h handle = NULL;
+
+ printf("--------------------------------------------------------\n");
+ printf("TC 10 : pkgmgrinfo_pkginfo_filter_count\n");
+ printf("### Access DB table list ###\n");
+ printf("package_info\n");
+ printf("package_localized_info\n");
+
+ gettimeofday(&tv, NULL);
+ check_time = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
+
+ ret = pkgmgrinfo_pkginfo_filter_create(&handle);
+ if (ret != PMINFO_R_OK) {
+ printf("pkgmgrinfo_pkginfo_filter_create : fail\n");
+ goto end;
+ }
+
+ ret = pkgmgrinfo_pkginfo_filter_add_string(handle, PMINFO_PKGINFO_PROP_PACKAGE_TYPE, "rpm\n");
+ if (ret != PMINFO_R_OK) {
+ printf("pkgmgrinfo_pkginfo_filter_add_string : fail\n");
+ goto end;
+ }
+
+ ret = pkgmgrinfo_pkginfo_filter_count(handle, &count);
+ if (ret != PMINFO_R_OK) {
+ printf("pkgmgrinfo_pkginfo_filter_count : fail\n");
+ goto end;
+ }
+ printf("count : %d\n", count);
+
+end:
+ if(handle)
+ pkgmgrinfo_pkginfo_filter_destroy(handle);
+
+ if (ret == PMINFO_R_OK) {
+ printf("TC 10 result :: OK\n");
+ } else {
+ printf("TC 10 result :: fail\n");
+ }
+
+ spend_time = __check_time(check_time);
+ return spend_time;
+}
+
+static int __tc_11()
+{
+ int ret = 0;
+ long check_time = 0;
+ int spend_time = 0;
+ struct timeval tv;
+ int count = 0;
+
+ pkgmgrinfo_appinfo_filter_h handle = NULL;
+
+ printf("--------------------------------------------------------\n");
+ printf("TC 11 : pkgmgrinfo_appinfo_filter_count\n");
+ printf("### Access DB table list ###\n");
+ printf("package_app_info\n");
+
+ gettimeofday(&tv, NULL);
+ check_time = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
+
+ ret = pkgmgrinfo_appinfo_filter_create(&handle);
+ if (ret != PMINFO_R_OK) {
+ printf("pkgmgrinfo_appinfo_filter_create : fail\n");
+ goto end;
+ }
+
+ ret = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_NODISPLAY, 1);
+ if (ret != PMINFO_R_OK) {
+ printf("pkgmgrinfo_appinfo_filter_add_bool : fail\n");
+ goto end;
+ }
+
+ ret = pkgmgrinfo_appinfo_filter_count(handle, &count);
+ if (ret != PMINFO_R_OK) {
+ printf("pkgmgrinfo_appinfo_filter_count : fail\n");
+ goto end;
+ }
+ printf("count : %d\n", count);
+
+end:
+ if(handle)
+ pkgmgrinfo_appinfo_filter_destroy(handle);
+
+ if (ret == PMINFO_R_OK) {
+ printf("TC 11 result :: OK\n");
+ } else {
+ printf("TC 11 result :: fail\n");
+ }
+
+ spend_time = __check_time(check_time);
+ return spend_time;
+}
+
+static void __api_performance_test()
+{
+ int spend_time_tc_01 = 0;
+ int spend_time_tc_02 = 0;
+ int spend_time_tc_03 = 0;
+ int spend_time_tc_04 = 0;
+ int spend_time_tc_05 = 0;
+ int spend_time_tc_06 = 0;
+ int spend_time_tc_07 = 0;
+ int spend_time_tc_08 = 0;
+ int spend_time_tc_09 = 0;
+ int spend_time_tc_10 = 0;
+ int spend_time_tc_11 = 0;
+
+ printf("========================================================\n");
+ printf("\t\t\t Start API perf\n");
+ printf("========================================================\n");
+
+ spend_time_tc_01 = __tc_01();
+ spend_time_tc_02 = __tc_02();
+ spend_time_tc_03 = __tc_03();
+ spend_time_tc_04 = __tc_04();
+ spend_time_tc_05 = __tc_05();
+ spend_time_tc_06 = __tc_06();
+ spend_time_tc_07 = __tc_07();
+ spend_time_tc_08 = __tc_08();
+ spend_time_tc_09 = __tc_09();
+ spend_time_tc_10 = __tc_10();
+ spend_time_tc_11 = __tc_11();
+
+
+ printf("========================================================\n");
+ printf("\t\t\t Test Result\n");
+ printf("========================================================\n");
+ if(spend_time_tc_01)
+ printf("TC 01 - get pkginfo : %d ms\n", spend_time_tc_01);
+ if(spend_time_tc_02)
+ printf("TC 02 - get installed pkg list : %d ms\n", spend_time_tc_02);
+ if(spend_time_tc_03)
+ printf("TC 03 - pkg filter : %d ms\n", spend_time_tc_03);
+ if(spend_time_tc_04)
+ printf("TC 04 - get appinfo from pkgid : %d ms\n", spend_time_tc_04);
+ if(spend_time_tc_05)
+ printf("TC 05 - get appinfo : %d ms\n", spend_time_tc_05);
+ if(spend_time_tc_06)
+ printf("TC 06 - get app list with basic : %d ms\n", spend_time_tc_06);
+ if(spend_time_tc_07)
+ printf("TC 07 - get app list with full : %d ms\n", spend_time_tc_07);
+ if(spend_time_tc_08)
+ printf("TC 08 - app filter : %d ms\n", spend_time_tc_08);
+ if(spend_time_tc_09)
+ printf("TC 09 - app metadata filter : %d ms\n", spend_time_tc_09);
+ if(spend_time_tc_10)
+ printf("TC 10 - pkg filter count : %d ms\n", spend_time_tc_10);
+ if(spend_time_tc_11)
+ printf("TC 11 - app filter count : %d ms\n", spend_time_tc_11);
+ printf("========================================================\n");
+ printf("\t\t\t Finish test perf\n");
+ printf("========================================================\n");
+}
+
+int __do_api_test(pkg_tool_args *pkg_args)
+{
+ int ret = PMINFO_R_OK;
+ int option = -1;
+
+ option = atoi(pkg_args->pkgid);
+
+ switch (option) {
+
+ case 1:
+ __check_fota_result();
+ break;
+
+ case 2:
+ __send_event_make_exdir();
+ break;
+
+ case 3:
+ __clear_cache_dir();
+ break;
+
+ case 4:
+ __api_performance_test();
+ break;
+
+ default:
+ __do_print_usage_api_test();
+ ret = -1;
+ }
+
+ return ret;
+}
--- /dev/null
+#ifndef _PKG_H_
+#define _PKG_H_
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "package-manager-types.h"
+
+#define PKG_TOOL_VERSION "1.0.0"
+
+#define BUF_SIZE 1024
+
+#define OPT_DBSPACE_PATH "/opt/dbspace/"
+#define PKGMGR_DB OPT_DBSPACE_PATH".pkgmgr_parser.db"
+#define PKGMGR_DB_BACKUP OPT_DBSPACE_PATH".pkgmgr_parser_b.db"
+#define PKGMGR_DB_JOURNAL OPT_DBSPACE_PATH".pkgmgr_parser.db-journal"
+#define PKGMGR_DB_JOURNAL_BACKUP OPT_DBSPACE_PATH".pkgmgr_parser_b.db-journal"
+
+#define PKGMGR_FOTA_PATH "/opt/usr/data/pkgmgr/fota/"
+#define FACTORYRESET_BACKUP_FILE "/usr/system/RestoreDir/opt.zip"
+
+typedef enum
+{
+ LIST_REQ,
+ INSTALL_REQ,
+ UNINSTALL_REQ,
+ ENABLE_REQ,
+ DISABLE_REQ,
+ MOVE_TO_INTERNAL_REQ,
+ MOVE_TO_EXTERNAL_REQ,
+ LAUNCH_REQ,
+ INFO_REQ,
+ API_TEST_REQ,
+ NONE_REQ,
+} pkg_operation_req;
+
+typedef struct pkg_tool_args_t
+{
+ pkg_operation_req req;
+
+ char path[PKG_NAME_STRING_LEN_MAX];
+ char pkgid[PKG_NAME_STRING_LEN_MAX];
+ char appid[PKG_NAME_STRING_LEN_MAX];
+ char des_path[PKG_NAME_STRING_LEN_MAX];
+ char label[PKG_NAME_STRING_LEN_MAX];
+ int result;
+ bool isListAll;
+
+} pkg_tool_args;
+
+typedef struct {
+ int (*func)(pkg_tool_args *args);
+} cmdinfo;
+
+#endif // _PKG_H_
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#define _GNU_SOURCE
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <dirent.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include <pkgmgr-info.h>
+#include <package-manager.h>
+#include <package-manager-debug.h>
+
+#define MAX_PKG_NAME_LEN 256
+#define INTERNAL_CACHE_PATH_PREFIX "/opt/usr/apps/"
+#define EXTERNAL_CACHE_PATH_PREFIX "/opt/storage/sdcard/apps/"
+#define CACHE_PATH_POSTFIX "/cache"
+#define SHARED_PATH_POSTFIX "/shared/cache"
+
+
+#undef LOG_TAG
+#ifndef LOG_TAG
+#define LOG_TAG "PKGMGR_CLEARCACHE"
+#endif /* LOG_TAG */
+
+static int __clear_dir(const char *dirname)
+{
+ int ret = 0;
+ DIR *dp = NULL;
+ struct dirent *ep = NULL;
+ char *abs_filename = NULL;
+ struct stat stFileInfo;
+
+ _LOGD("Cache directory name to clear [%s]\n", dirname);
+
+ abs_filename = (char *)malloc(sizeof(char) * PATH_MAX);
+ if (abs_filename == NULL) {
+ _LOGE("Memory allocation failed\n");
+ goto err;
+ }
+
+ dp = opendir(dirname);
+ if (dp != NULL) {
+ while ((ep = readdir(dp))) {
+ snprintf(abs_filename, PATH_MAX - 1, "%s/%s", dirname, ep->d_name);
+ if (lstat(abs_filename, &stFileInfo) < 0) {
+ perror(abs_filename);
+ }
+ if (S_ISDIR(stFileInfo.st_mode)) {
+ if (strcmp(ep->d_name, ".") && strcmp(ep->d_name, "..")) {
+ ret = __clear_dir(abs_filename);
+ if (ret != 0) {
+ _LOGE("Couldn't remove the directory. errno : %d (%s)\n", errno, strerror(errno));
+ }
+
+ ret = remove(abs_filename);
+ if (ret != 0) {
+ _LOGE("Couldn't remove the directory. errno : %d (%s)\n", errno, strerror(errno));
+ goto err;
+ }
+ }
+ } else {
+ ret = remove(abs_filename);
+ if (ret != 0) {
+ _LOGE("Couldn't remove the directory. errno : %d (%s)\n", errno, strerror(errno));
+ goto err;
+ }
+ }
+ }
+ (void)closedir(dp);
+ } else {
+ _LOGE("Couldn't open the directory. errno : %d (%s)\n", errno, strerror(errno));
+ goto err;
+ }
+
+ free(abs_filename);
+ return 0;
+
+err:
+ if (abs_filename) {
+ free(abs_filename);
+ }
+ if(dp){
+ (void)closedir(dp);
+ dp = NULL;
+ }
+ return -1;
+}
+
+static int __clear_cache_dir(const char *pkgid)
+{
+ int ret = 0;
+ char dirname[PATH_MAX] = {0,};
+
+ if(pkgid == NULL) {
+ _LOGE("pkgid is NULL\n");
+ return -1;
+ }
+
+ int internal_prefix_len = sizeof(INTERNAL_CACHE_PATH_PREFIX);
+ int external_prefix_len = sizeof(EXTERNAL_CACHE_PATH_PREFIX);
+ int cache_postfix_len = sizeof(CACHE_PATH_POSTFIX);
+ int shared_postfix_len = sizeof(SHARED_PATH_POSTFIX);
+
+ // cache internal
+ strcat(dirname, INTERNAL_CACHE_PATH_PREFIX);
+ strncat(dirname, pkgid, PATH_MAX - internal_prefix_len - cache_postfix_len - 1);
+ strcat(dirname, CACHE_PATH_POSTFIX);
+
+ ret = __clear_dir(dirname);
+ if (ret < 0) {
+ _LOGE("Failed to clear internal cache dir.");
+ }
+
+ // cache external
+ memset(dirname, 0x00, PATH_MAX);
+ strcat(dirname, EXTERNAL_CACHE_PATH_PREFIX);
+ strncat(dirname, pkgid, PATH_MAX - external_prefix_len - cache_postfix_len - 1);
+ strcat(dirname, CACHE_PATH_POSTFIX);
+
+ ret = __clear_dir(dirname);
+ if (ret < 0) {
+ _LOGE("Failed to clear external cache dir.");
+ }
+
+ // shared/cache internal
+ memset(dirname, 0x00, PATH_MAX);
+ strcat(dirname, INTERNAL_CACHE_PATH_PREFIX);
+ strncat(dirname, pkgid, PATH_MAX - internal_prefix_len - shared_postfix_len - 1);
+ strcat(dirname, SHARED_PATH_POSTFIX);
+
+ ret = __clear_dir(dirname);
+ if (ret < 0) {
+ _LOGE("Failed to clear external shared cache dir.");
+ }
+
+ // shared/cache external
+ memset(dirname, 0x00, PATH_MAX);
+ strcat(dirname, EXTERNAL_CACHE_PATH_PREFIX);
+ strncat(dirname, pkgid, PATH_MAX - external_prefix_len - shared_postfix_len - 1);
+ strcat(dirname, SHARED_PATH_POSTFIX);
+
+ ret = __clear_dir(dirname);
+ if (ret < 0) {
+ _LOGE("Failed to clear external shared cache dir.");
+ }
+
+ return 0;
+}
+
+static int __clear_all_cache_dir_cb(const pkgmgrinfo_pkginfo_h handle, void *user_data)
+{
+ int res = 0;
+ char *pkgid;
+ int *err_cnt = (int *)user_data;
+
+ res = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
+ if(res != PMINFO_R_OK) {
+ _LOGE("pkgmgr_pkginfo_get_pkgid() failed");
+ --(*err_cnt);
+ return 0;
+ }
+
+ res = __clear_cache_dir(pkgid);
+ if (res != 0)
+ { // error flag
+ _LOGE("Failed to clear cache dir of %s", pkgid);
+ --(*err_cnt);
+ return 0;
+ }
+
+ return 0;
+}
+
+static int __clear_all_cache_dir(void)
+{
+ int err_cnt = 0;
+
+ int res = pkgmgrinfo_pkginfo_get_list(__clear_all_cache_dir_cb, &err_cnt);
+ if (res != PMINFO_R_OK)
+ {
+ _LOGE("Failed to get pkg list. (%d)", res);
+ return -1;
+ }
+ else if (err_cnt != 0)
+ {
+ _LOGE("Error occured in %d packages.", err_cnt);
+ return -1;
+ }
+
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ int ret = 0;
+
+ if(argv[0] == NULL) {
+ _LOGE("pkgid is NULL\n");
+ return -1;
+ }
+
+ char pkgid[MAX_PKG_NAME_LEN]={0};
+
+ snprintf(pkgid,MAX_PKG_NAME_LEN,"%s",argv[0]);
+
+ if (strcmp(pkgid, PKG_CLEAR_ALL_CACHE) == 0)
+ { // clear all
+ ret = __clear_all_cache_dir();
+ }
+ else
+ {
+ ret = __clear_cache_dir(pkgid);
+ }
+
+
+ return ret;
+}
+
/*
* slp-pkgmgr
*
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
+#include <ctype.h>
#include <getopt.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <dlfcn.h>
#include <sys/types.h>
#include <glib.h>
-#include <ail.h>
#include <glib-object.h>
+#include <pkgmgr-info.h>
#include "package-manager.h"
#include "package-manager-types.h"
#define PKG_TOOL_VERSION "0.1"
+#define APP_INSTALLATION_PATH_RW "/opt/usr/apps"
+
+static pkgmgr_client *gpc = NULL;
static int __process_request();
static void __print_usage();
static int __is_authorized();
-static int __is_app_installed(char *pkgname);
+static int __is_app_installed(char *pkgid);
static void __print_pkg_info(pkgmgr_info * pkg_info);
-static int __iter_fn(const char *pkg_type, const char *pkg_name,
- const char *version, void *data);
-static int __return_cb(int req_id, const char *pkg_type, const char *pkg_name,
+static int __return_cb(int req_id, const char *pkg_type, const char *pkgid,
const char *key, const char *val, const void *pmsg,
void *data);
static int __convert_to_absolute_path(char *path);
/* Supported options */
-const char *short_options = "iucADlsd:p:t:n:qh";
+const char *short_options = "iurmcgxCkaADL:Rlsd:p:t:n:T:S:qh";
const struct option long_options[] = {
{"install", 0, NULL, 'i'},
{"uninstall", 0, NULL, 'u'},
+ {"reinstall", 0, NULL, 'r'},
+ {"move", 0, NULL, 'm'},
{"clear", 0, NULL, 'c'},
+ {"getsize", 0, NULL, 'g'},
{"activate", 0, NULL, 'A'},
{"deactivate", 0, NULL, 'D'},
+ {"activate with Label", 1, NULL, 'L'},
+ {"reset device", 1, NULL, 'R'},
+ {"check", 0, NULL, 'C'},
+ {"kill", 0, NULL, 'k'},
+ {"app-path", 0, NULL, 'a'},
{"list", 0, NULL, 'l'},
{"show", 0, NULL, 's'},
{"descriptor", 1, NULL, 'd'},
{"package-path", 1, NULL, 'p'},
{"package-type", 1, NULL, 't'},
{"package-name", 1, NULL, 'n'},
+ {"move-type", 1, NULL, 'T'},
+ {"getsize-type", 1, NULL, 'T'},
+ {"csc", 1, NULL, 'S'},
{"quiet", 0, NULL, 'q'},
{"help", 0, NULL, 'h'},
+ {"get_pkg_size_info", 0, NULL, 'x'},
{0, 0, 0, 0} /* sentinel */
};
enum pm_tool_request_e {
INSTALL_REQ = 1,
UNINSTALL_REQ,
+ REINSTALL_REQ,
+ CSC_REQ,
+ GETSIZE_REQ,
CLEAR_REQ,
+ MOVE_REQ,
ACTIVATE_REQ,
DEACTIVATE_REQ,
+ APPPATH_REQ,
+ CHECKAPP_REQ,
+ KILLAPP_REQ,
LIST_REQ,
SHOW_REQ,
- HELP_REQ
+ HELP_REQ,
+ GET_PKG_SIZE_INFO_REQ,
+ RESET_DEVICE_REQ
};
typedef enum pm_tool_request_e req_type;
req_type request;
char pkg_path[PKG_NAME_STRING_LEN_MAX];
char pkg_type[PKG_TYPE_STRING_LEN_MAX];
- char pkg_name[PKG_NAME_STRING_LEN_MAX];
+ char pkgid[PKG_NAME_STRING_LEN_MAX];
char des_path[PKG_NAME_STRING_LEN_MAX];
- int quiet;
+ char label[PKG_NAME_STRING_LEN_MAX];
+ int type;
int result;
};
typedef struct pm_tool_args_t pm_tool_args;
static GMainLoop *main_loop = NULL;
-static int __iter_fn(const char *pkg_type, const char *pkg_name,
- const char *version, void *data)
+static void __error_no_to_string(int errnumber, char **errstr)
{
- printf("pkg_type [%s]\tpkg_name [%s]\tversion [%s]\n", pkg_type,
- pkg_name, version);
- return 0;
+ if (errstr == NULL)
+ return;
+ switch (errnumber) {
+ case PKGCMD_ERR_PACKAGE_NOT_FOUND:
+ *errstr = PKGCMD_ERR_PACKAGE_NOT_FOUND_STR;
+ break;
+ case PKGCMD_ERR_PACKAGE_INVALID:
+ *errstr = PKGCMD_ERR_PACKAGE_INVALID_STR;
+ break;
+ case PKGCMD_ERR_PACKAGE_LOWER_VERSION:
+ *errstr = PKGCMD_ERR_PACKAGE_LOWER_VERSION_STR;
+ break;
+ case PKGCMD_ERR_PACKAGE_EXECUTABLE_NOT_FOUND:
+ *errstr = PKGCMD_ERR_PACKAGE_EXECUTABLE_NOT_FOUND_STR;
+ break;
+ case PKGCMD_ERR_MANIFEST_INVALID:
+ *errstr = PKGCMD_ERR_MANIFEST_INVALID_STR;
+ break;
+ case PKGCMD_ERR_CONFIG_NOT_FOUND:
+ *errstr = PKGCMD_ERR_CONFIG_NOT_FOUND_STR;
+ break;
+ case PKGCMD_ERR_CONFIG_INVALID:
+ *errstr = PKGCMD_ERR_CONFIG_INVALID_STR;
+ break;
+ case PKGCMD_ERR_SIGNATURE_NOT_FOUND:
+ *errstr = PKGCMD_ERR_SIGNATURE_NOT_FOUND_STR;
+ break;
+ case PKGCMD_ERR_SIGNATURE_INVALID:
+ *errstr = PKGCMD_ERR_SIGNATURE_INVALID_STR;
+ break;
+ case PKGCMD_ERR_SIGNATURE_VERIFICATION_FAILED:
+ *errstr = PKGCMD_ERR_SIGNATURE_VERIFICATION_FAILED_STR;
+ break;
+ case PKGCMD_ERR_ROOT_CERTIFICATE_NOT_FOUND:
+ *errstr = PKGCMD_ERR_ROOT_CERTIFICATE_NOT_FOUND_STR;
+ break;
+ case PKGCMD_ERR_CERTIFICATE_INVALID:
+ *errstr = PKGCMD_ERR_CERTIFICATE_INVALID_STR;
+ break;
+ case PKGCMD_ERR_CERTIFICATE_CHAIN_VERIFICATION_FAILED:
+ *errstr = PKGCMD_ERR_CERTIFICATE_CHAIN_VERIFICATION_FAILED_STR;
+ break;
+ case PKGCMD_ERR_CERTIFICATE_EXPIRED:
+ *errstr = PKGCMD_ERR_CERTIFICATE_EXPIRED_STR;
+ break;
+ case PKGCMD_ERR_INVALID_PRIVILEGE:
+ *errstr = PKGCMD_ERR_INVALID_PRIVILEGE_STR;
+ break;
+ case PKGCMD_ERR_PRIVILEGE_UNAUTHORIZED_FAILED:
+ *errstr = PKGCMD_ERR_PRIVILEGE_UNAUTHORIZED_FAILED_STR;
+ break;
+ case PKGCMD_ERR_PRIVILEGE_UNKNOWN_FAILED:
+ *errstr = PKGCMD_ERR_PRIVILEGE_UNKNOWN_FAILED_STR;
+ break;
+ case PKGCMD_ERR_PRIVILEGE_USING_LEGACY_FAILED:
+ *errstr = PKGCMD_ERR_PRIVILEGE_USING_LEGACY_FAILED_STR;
+ break;
+ case PKGCMD_ERR_MENU_ICON_NOT_FOUND:
+ *errstr = PKGCMD_ERR_MENU_ICON_NOT_FOUND_STR;
+ break;
+ case PKGCMD_ERR_FATAL_ERROR:
+ *errstr = PKGCMD_ERR_FATAL_ERROR_STR;
+ break;
+ case PKGCMD_ERR_OUT_OF_STORAGE:
+ *errstr = PKGCMD_ERR_OUT_OF_STORAGE_STR;
+ break;
+ case PKGCMD_ERR_OUT_OF_MEMORY:
+ *errstr = PKGCMD_ERR_OUT_OF_MEMORY_STR;
+ break;
+ case PKGCMD_ERR_ARGUMENT_INVALID:
+ *errstr = PKGCMD_ERR_ARGUMENT_INVALID_STR;
+ break;
+ default:
+ *errstr = PKGCMD_ERR_UNKNOWN_STR;
+ break;
+ }
}
static int __return_cb(int req_id, const char *pkg_type,
- const char *pkg_name, const char *key, const char *val,
+ const char *pkgid, const char *key, const char *val,
const void *pmsg, void *priv_data)
{
- printf("__return_cb req_id[%d] pkg_type[%s] "
- "pkg_name[%s] key[%s] val[%s]\n",
- req_id, pkg_type, pkg_name, key, val);
+ if (strncmp(key, "error", strlen("error")) == 0) {
+ int ret_val;
+ char delims[] = ":";
+ char *extra_str = NULL;
+ char *ret_result = NULL;
+
+ ret_val = atoi(val);
+ data.result = ret_val;
+
+ strtok((char*)val, delims);
+ ret_result = strtok(NULL, delims);
+ if (ret_result){
+ extra_str = strdup(ret_result);
+ printf("__return_cb req_id[%d] pkg_type[%s] pkgid[%s] key[%s] val[%d] error message: %s\n",
+ req_id, pkg_type, pkgid, key, ret_val, extra_str);
+ free(extra_str);
+ }
+ else
+ printf("__return_cb req_id[%d] pkg_type[%s] pkgid[%s] key[%s] val[%d]\n",
+ req_id, pkg_type, pkgid, key, ret_val);
+ } else
+ printf("__return_cb req_id[%d] pkg_type[%s] "
+ "pkgid[%s] key[%s] val[%s]\n",
+ req_id, pkg_type, pkgid, key, val);
if (strncmp(key, "end", strlen("end")) == 0) {
- if (strncasecmp(val, "ok", strlen("ok")) != 0)
- data.result = EXIT_FAILURE; //error_code
-
+ if ((strncmp(val, "fail", strlen("fail")) == 0) && data.result == 0){
+ data.result = PKGCMD_ERR_FATAL_ERROR;
+ }
g_main_loop_quit(main_loop);
}
strncpy(temp, path, PKG_NAME_STRING_LEN_MAX - 1);
if (strchr(path, '/') == NULL) {
getcwd(abs, PKG_NAME_STRING_LEN_MAX - 1);
- if (abs == NULL) {
+ if (abs[0] == '\0') {
printf("getcwd() failed\n");
return -1;
}
if (strncmp(path, "./", 2) == 0) {
ptr = temp;
getcwd(abs, PKG_NAME_STRING_LEN_MAX - 1);
- if (abs == NULL) {
+ if (abs[0] == '\0') {
printf("getcwd() failed\n");
return -1;
}
return 0;
}
-static int __is_app_installed(char *pkgname)
+static int __is_app_installed(char *pkgid)
{
- ail_appinfo_h handle;
- ail_error_e ret;
- char *str = NULL;
- ret = ail_package_get_appinfo(pkgname, &handle);
- if (ret != AIL_ERROR_OK) {
- return -1;
- }
- ret = ail_appinfo_get_str(handle, AIL_PROP_NAME_STR, &str);
- if (ret != AIL_ERROR_OK) {
- return -1;
- }
- ret = ail_package_destroy_appinfo(handle);
- if (ret != AIL_ERROR_OK) {
- return -1;
- }
-
return 0;
}
printf("\nPackage Manager Tool Version: %s\n\n", PKG_TOOL_VERSION);
printf("-i, --install install the package\n");
printf("-u, --uninstall uninstall the package\n");
+ printf("-r, --reinstall reinstall the package\n");
printf("-c, --clear clear user data\n");
+ printf("-m, --move move package\n");
+ printf("-g, --getsize get size of given package\n");
+ printf("-T, --getsize-type get type [0 : total size /1: data size]\n");
printf("-l, --list display list of installed packages\n");
printf("-s, --show show detail package info\n");
+ printf("-a, --app-path show app installation path\n");
+ printf("-C, --check check if applications belonging to a package are running or not\n");
+ printf("-k, --kill terminate applications belonging to a package\n");
printf("-d, --descriptor provide descriptor path\n");
printf("-p, --package-path provide package path\n");
printf("-n, --package-name provide package name\n");
printf("-t, --package-type provide package type\n");
- printf("-q, --quiet quiet mode operation\n");
+ printf("-T, --move-type provide move type [0 : move to internal /1: move to external]\n");
printf("-h, --help print this help\n\n");
- printf("Usage: pkgcmd [options] (--quiet)\n");
- printf
- ("pkgcmd -i -t <pkg type> (-d <descriptor path>) -p <pkg path> (-q)\n");
- printf("pkgcmd -u -t <pkg type> -n <pkg name> (-q)\n");
- printf("pkgcmd -l \n");
- printf("pkgcmd -s -t <pkg type> -p <pkg path> (-q)\n");
- printf("pkgcmd -s -t <pkg type> -n <pkg name> (-q)\n\n");
+
+ printf("Usage: pkgcmd [options] \n");
+ printf("pkgcmd -i -t <pkg type> (-d <descriptor path>) -p <pkg path> \n");
+ printf("pkgcmd -u -n <pkgid> \n");
+ printf("pkgcmd -r -t <pkg type> -n <pkgid> \n");
+ printf("pkgcmd -l (-t <pkg type>) \n");
+ printf("pkgcmd -s -t <pkg type> -p <pkg path> \n");
+ printf("pkgcmd -s -t <pkg type> -n <pkg name> \n");
+ printf("pkgcmd -m -T <move type> -n <pkg name>\n\n");
+ printf("pkgcmd -g -T <getsize type> -n <pkgid> \n");
+ printf("pkgcmd -C -n <pkgid> \n");
+ printf("pkgcmd -k -n <pkgid> \n");
+
printf("Example:\n");
- printf("pkgcmd -u -t deb -n org.tizen.calculator\n");
- printf
- ("pkgcmd -i -t deb -p /mnt/nfs/org.tizen.calculator_0.1.2-95_armel.deb\n");
- printf("pkgcmd -c -t deb -n org.tizen.hello\n");
+ printf("pkgcmd -u -n org.tizen.calculator\n");
+ printf("pkgcmd -i -t rpm -p /mnt/nfs/org.tizen.calculator_0.1.2-95_armel.rpm\n");
+ printf("pkgcmd -r -t rpm -n org.tizen.calculator\n");
+ printf("pkgcmd -c -t rpm -n org.tizen.hello\n");
+ printf("pkgcmd -m -T 1 -n org.tizen.hello\n");
+ printf("pkgcmd -C -n org.tizen.hello\n");
+ printf("pkgcmd -k -n org.tizen.hello\n");
+ printf("pkgcmd -a\n");
+ printf("pkgcmd -a -t rpm -n org.tizen.hello\n");
+ printf("pkgcmd -l\n");
+ printf("pkgcmd -l -t tpk\n");
+ printf("pkgcmd -g -T 0 -n org.tizen.calculator\n");
+
exit(0);
}
free(temp);
}
- temp = pkgmgr_info_get_string(pkg_info, "pkg_name");
+ temp = pkgmgr_info_get_string(pkg_info, "pkgid");
if (temp) {
- printf("pkg_name : %s\n", temp);
+ printf("pkgid : %s\n", temp);
free(temp);
}
free(temp);
}
+ temp = pkgmgr_info_get_string(pkg_info, "api_version");
+ if (temp) {
+ printf("api_version : %s\n", temp);
+ free(temp);
+ }
+
temp = pkgmgr_info_get_string(pkg_info, "pkg_vendor");
if (temp) {
printf("pkg_vendor : %s\n", temp);
}
}
+static int __pkgmgr_list_cb (const pkgmgrinfo_pkginfo_h handle, void *user_data)
+{
+ int ret = -1;
+ char *pkgid = NULL;
+ char *pkg_type = NULL;
+ char *pkg_version = NULL;
+ char *pkg_label = NULL;
+ char *pkg_rootpath = NULL;
+
+ ret = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
+ if (ret == -1) {
+ printf("Failed to get pkgmgr_pkginfo_get_pkgid\n");
+ return ret;
+ }
+ ret = pkgmgrinfo_pkginfo_get_type(handle, &pkg_type);
+ if (ret == -1) {
+ printf("Failed to get pkgmgr_pkginfo_get_type\n");
+ return ret;
+ }
+ ret = pkgmgrinfo_pkginfo_get_version(handle, &pkg_version);
+ if (ret == -1) {
+ printf("Failed to get pkgmgr_pkginfo_get_version\n");
+ return ret;
+ }
+ ret = pkgmgrinfo_pkginfo_get_label(handle, &pkg_label);
+ if (ret == -1) {
+ printf("Failed to get pkgmgr_pkginfo_get_label\n");
+ return ret;
+ }
+ if (pkg_type && strcmp(pkg_type, "wgt") == 0)
+ {
+ char buf[1024] = {0};
+ ret = pkgmgrinfo_pkginfo_get_root_path(handle, &pkg_rootpath);
+ if (ret == -1) {
+ printf("pkgmgrinfo_pkginfo_get_root_path\n");
+ return ret;
+ }
+
+ snprintf(buf, 1023, "%s/author-signature.xml", pkg_rootpath);
+
+ if (access(buf, F_OK) == 0)
+ {
+ printf("pkg_type [%s]\tpkgid [%s]\tname [%s]\tversion [%s]\tpkg_subtype [%s]\n", pkg_type, pkgid, pkg_label, pkg_version, "hybrid");
+ return ret;
+ }
+ }
+
+ printf("pkg_type [%s]\tpkgid [%s]\tname [%s]\tversion [%s]\n", pkg_type, pkgid, pkg_label, pkg_version);
+
+ return ret;
+}
+
+static int __pkg_list_cb (const pkgmgrinfo_pkginfo_h handle, void *user_data)
+{
+ int ret = -1;
+ char *pkgid;
+
+ ret = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
+ if(ret < 0) {
+ printf("pkgmgr_pkginfo_get_pkgid() failed\n");
+ }
+
+ ret = pkgmgr_client_request_service(PM_REQUEST_GET_SIZE, PM_GET_TOTAL_SIZE, (pkgmgr_client *)user_data, NULL, pkgid, NULL, NULL, NULL);
+ if (ret < 0){
+ printf("pkgmgr_client_request_service Failed\n");
+ return -1;
+ }
+
+ printf("pkg[%s] size = %d\n", pkgid, ret);
+
+ return 0;
+}
+
+static void __pkg_size_info_recv_cb(pkgmgr_client *pc, const char *pkgid, const pkg_size_info_t *size_info, void *user_data)
+{
+ printf("User get_package_size_info callback called.\n");
+ printf("Internal > data size: %lld, cache size: %lld, app size: %lld\n",
+ size_info->data_size, size_info->cache_size, size_info->app_size);
+ printf("External > data size: %lld, cache size: %lld, app size: %lld\n",
+ size_info->ext_data_size, size_info->ext_cache_size, size_info->ext_app_size);
+
+ pkgmgr_client_free(pc);
+ g_main_loop_quit(main_loop);
+}
+
+static void __total_pkg_size_info_recv_cb(pkgmgr_client *pc, const pkg_size_info_t *size_info, void *user_data)
+{
+ printf("User get_total_package_size_info callback called.\n");
+ printf("Internal > data size: %lld, cache size: %lld, app size: %lld\n",
+ size_info->data_size, size_info->cache_size, size_info->app_size);
+ printf("External > data size: %lld, cache size: %lld, app size: %lld\n",
+ size_info->ext_data_size, size_info->ext_cache_size, size_info->ext_app_size);
+
+ pkgmgr_client_free(pc);
+ g_main_loop_quit(main_loop);
+}
+
static int __process_request()
{
int ret = -1;
- int mode = PM_DEFAULT;
+ int mode = PM_QUIET;
pkgmgr_client *pc = NULL;
+ char buf[1024] = {'\0'};
+ int pid = -1;
switch (data.request) {
case INSTALL_REQ:
- if (data.pkg_type[0] == '\0' || data.pkg_path[0] == '\0') {
+ if (data.pkg_path[0] == '\0') {
printf("Please provide the arguments.\n");
printf("use -h option to see usage\n");
- ret = -1;
+ data.result = PKGCMD_ERR_ARGUMENT_INVALID;
break;
}
g_type_init();
pc = pkgmgr_client_new(PC_REQUEST);
if (pc == NULL) {
printf("PkgMgr Client Creation Failed\n");
- ret = -1;
+ data.result = PKGCMD_ERR_FATAL_ERROR;
break;
}
- if (data.quiet == 0)
- mode = PM_DEFAULT;
- else
- mode = PM_QUIET;
+
+ if (data.pkg_type[0] == '\0') {
+ strncpy(data.pkg_type, "rpm", PKG_TYPE_STRING_LEN_MAX - 1);
+ }
+
if (data.des_path[0] == '\0')
ret =
pkgmgr_client_install(pc, data.pkg_type, NULL,
pkgmgr_client_install(pc, data.pkg_type,
data.des_path, data.pkg_path,
NULL, mode, __return_cb, pc);
- if (ret < 0)
+ if (ret < 0){
+ data.result = PKGCMD_ERR_FATAL_ERROR;
+ if (access(data.pkg_path, F_OK) != 0)
+ data.result = PKGCMD_ERR_PACKAGE_NOT_FOUND;
break;
+ }
g_main_loop_run(main_loop);
ret = data.result;
break;
case UNINSTALL_REQ:
- if (data.pkg_type[0] == '\0' || data.pkg_name[0] == '\0') {
+ if (data.pkgid[0] == '\0') {
printf("Please provide the arguments.\n");
printf("use -h option to see usage\n");
- ret = -1;
+ data.result = PKGCMD_ERR_ARGUMENT_INVALID;
break;
}
g_type_init();
pc = pkgmgr_client_new(PC_REQUEST);
if (pc == NULL) {
printf("PkgMgr Client Creation Failed\n");
- ret = -1;
+ data.result = PKGCMD_ERR_FATAL_ERROR;
break;
}
- if (data.quiet == 0)
- mode = PM_DEFAULT;
- else
- mode = PM_QUIET;
-#if 0
- ret = __is_app_installed(data.pkg_name);
+
+
+ ret = __is_app_installed(data.pkgid);
if (ret == -1) {
printf("package is not installed\n");
break;
}
-#else
- pkgmgr_pkginfo_h handle;
- ret = pkgmgr_get_pkginfo(data.pkg_name, &handle);
- if(ret < 0) {
- printf("package is not in pkgmgr_info DB\n");
- } else
- pkgmgr_destroy_pkginfo(handle);
-#endif
+
ret =
- pkgmgr_client_uninstall(pc, data.pkg_type, data.pkg_name,
+ pkgmgr_client_uninstall(pc, data.pkg_type, data.pkgid,
mode, __return_cb, NULL);
- if (ret < 0)
+ if (ret < 0){
+ data.result = PKGCMD_ERR_FATAL_ERROR;
+ if (access(data.pkg_path, F_OK) != 0)
+ data.result = PKGCMD_ERR_PACKAGE_NOT_FOUND;
break;
+ }
+ g_main_loop_run(main_loop);
+ ret = data.result;
+ break;
+
+ case REINSTALL_REQ:
+ if (data.pkg_type[0] == '\0' || data.pkgid[0] == '\0') {
+ printf("Please provide the arguments.\n");
+ printf("use -h option to see usage\n");
+ data.result = PKGCMD_ERR_ARGUMENT_INVALID;
+ break;
+ }
+ g_type_init();
+ main_loop = g_main_loop_new(NULL, FALSE);
+ pc = pkgmgr_client_new(PC_REQUEST);
+ if (pc == NULL) {
+ printf("PkgMgr Client Creation Failed\n");
+ data.result = PKGCMD_ERR_FATAL_ERROR;
+ break;
+ }
+
+
+ ret = pkgmgr_client_reinstall(pc, data.pkg_type, data.pkgid, NULL, mode, __return_cb, pc);
+ if (ret < 0){
+ data.result = PKGCMD_ERR_FATAL_ERROR;
+ if (access(data.pkg_path, F_OK) != 0)
+ data.result = PKGCMD_ERR_PACKAGE_NOT_FOUND;
+ break;
+ }
g_main_loop_run(main_loop);
ret = data.result;
break;
case CLEAR_REQ:
- if (data.pkg_type[0] == '\0' || data.pkg_name[0] == '\0') {
+ if (data.pkg_type[0] == '\0' || data.pkgid[0] == '\0') {
printf("Please provide the arguments.\n");
printf("use -h option to see usage\n");
ret = -1;
ret = -1;
break;
}
- if (data.quiet == 0)
- mode = PM_DEFAULT;
- else
- mode = PM_QUIET;
- ret = __is_app_installed(data.pkg_name);
+
+ ret = __is_app_installed(data.pkgid);
if (ret == -1) {
printf("package is not installed\n");
break;
}
ret = pkgmgr_client_clear_user_data(pc, data.pkg_type,
- data.pkg_name, mode);
+ data.pkgid, mode);
if (ret < 0)
break;
ret = data.result;
break;
case ACTIVATE_REQ:
- if (data.pkg_type[0] == '\0' || data.pkg_name[0] == '\0') {
+ if (data.pkg_type[0] == '\0' || data.pkgid[0] == '\0') {
printf("Please provide the arguments.\n");
printf("use -h option to see usage\n");
ret = -1;
break;
}
- ret = pkgmgr_client_activate(pc, data.pkg_type, data.pkg_name);
- if (ret < 0)
- break;
+ if ( strcmp(data.pkg_type, "app") == 0 ) {
+ if (strlen(data.label) == 0) {
+ ret = pkgmgr_client_activate_app(pc, data.pkgid);
+ if (ret < 0)
+ break;
+ } else {
+ printf("label [%s]\n", data.label);
+ char *largv[3] = {NULL, };
+ largv[0] = "-l";
+ largv[1] = data.label;
+ ret = pkgmgr_client_activate_appv(pc, data.pkgid, largv);
+ if (ret < 0)
+ break;
+ }
+ } else {
+ ret = pkgmgr_client_activate(pc, data.pkg_type, data.pkgid);
+ if (ret < 0)
+ break;
+ }
ret = data.result;
break;
case DEACTIVATE_REQ:
- if (data.pkg_type[0] == '\0' || data.pkg_name[0] == '\0') {
+ if (data.pkg_type[0] == '\0' || data.pkgid[0] == '\0') {
+ printf("Please provide the arguments.\n");
+ printf("use -h option to see usage\n");
+ ret = -1;
+ break;
+ }
+
+ pc = pkgmgr_client_new(PC_REQUEST);
+ if (pc == NULL) {
+ printf("PkgMgr Client Creation Failed\n");
+ ret = -1;
+ break;
+ }
+
+ if ( strcmp(data.pkg_type, "app") == 0 ) {
+ ret = pkgmgr_client_deactivate_app(pc, data.pkgid);
+ if (ret < 0)
+ break;
+ } else {
+ ret = pkgmgr_client_deactivate(pc, data.pkg_type, data.pkgid);
+ if (ret < 0)
+ break;
+ }
+ ret = data.result;
+
+ break;
+
+ case MOVE_REQ:
+ if (data.pkgid[0] == '\0') {
printf("Please provide the arguments.\n");
printf("use -h option to see usage\n");
ret = -1;
break;
}
+ g_type_init();
+ main_loop = g_main_loop_new(NULL, FALSE);
+
pc = pkgmgr_client_new(PC_REQUEST);
if (pc == NULL) {
printf("PkgMgr Client Creation Failed\n");
break;
}
- ret = pkgmgr_client_deactivate(pc, data.pkg_type, data.pkg_name);
+ ret = __is_app_installed(data.pkgid);
+ if (ret == -1) {
+ printf("package is not installed\n");
+ break;
+ }
+
+ ret = pkgmgr_client_move(pc, data.pkgid, data.type, __return_cb, NULL);
+
+ printf("pkg[%s] move result = %d\n", data.pkgid, ret);
+
if (ret < 0)
break;
+
+ g_main_loop_run(main_loop);
+
ret = data.result;
+ break;
+ case APPPATH_REQ:
+ if (data.pkg_type[0] == '\0' && data.pkgid[0] == '\0') {
+ printf("Tizen Application Installation Path: %s\n", APP_INSTALLATION_PATH_RW);
+ ret = 0;
+ break;
+ }
+ if ((data.pkg_type[0] == '\0') || (data.pkgid[0] == '\0')) {
+ printf("Use -h option to see usage\n");
+ ret = -1;
+ break;
+ }
+ if (strncmp(data.pkg_type, "rpm", PKG_TYPE_STRING_LEN_MAX - 1) == 0) {
+ snprintf(buf, 1023, "%s/%s", APP_INSTALLATION_PATH_RW, data.pkgid);
+ printf("Tizen Application Installation Path: %s\n", buf);
+ ret = 0;
+ break;
+ } else if (strncmp(data.pkg_type, "wgt", PKG_TYPE_STRING_LEN_MAX - 1) == 0) {
+ snprintf(buf, 1023, "%s/%s/res/wgt", APP_INSTALLATION_PATH_RW, data.pkgid);
+ printf("Tizen Application Installation Path: %s\n", buf);
+ ret = 0;
+ break;
+ } else if (strncmp(data.pkg_type, "tpk", PKG_TYPE_STRING_LEN_MAX - 1) == 0) {
+ snprintf(buf, 1023, "%s/%s", APP_INSTALLATION_PATH_RW, data.pkgid);
+ printf("Tizen Application Installation Path: %s\n", buf);
+ ret = 0;
+ break;
+ } else {
+ printf("Invalid package type.\n");
+ printf("use -h option to see usage\n");
+ ret = -1;
+ break;
+ }
break;
- case LIST_REQ:
- ret = pkgmgr_get_pkg_list(__iter_fn, NULL);
+ case KILLAPP_REQ:
+ case CHECKAPP_REQ:
+ if (data.pkgid[0] == '\0') {
+ printf("Please provide the arguments.\n");
+ printf("use -h option to see usage\n");
+ data.result = PKGCMD_ERR_ARGUMENT_INVALID;
+ break;
+ }
+
+ pc = pkgmgr_client_new(PC_REQUEST);
+ if (pc == NULL) {
+ printf("PkgMgr Client Creation Failed\n");
+ data.result = PKGCMD_ERR_FATAL_ERROR;
+ break;
+ }
+
+ if (data.request == KILLAPP_REQ) {
+ ret = pkgmgr_client_request_service(PM_REQUEST_KILL_APP, 0, pc, NULL, data.pkgid, NULL, NULL, &pid);
+ if (ret < 0){
+ data.result = PKGCMD_ERR_FATAL_ERROR;
+ break;
+ }
+ if (pid)
+ printf("Pkgid: %s is Terminated\n", data.pkgid);
+ else
+ printf("Pkgid: %s is already Terminated\n", data.pkgid);
+
+ } else if (data.request == CHECKAPP_REQ) {
+ ret = pkgmgr_client_request_service(PM_REQUEST_CHECK_APP, 0, pc, NULL, data.pkgid, NULL, NULL, &pid);
+ if (ret < 0){
+ data.result = PKGCMD_ERR_FATAL_ERROR;
+ break;
+ }
+
+ if (pid)
+ printf("Pkgid: %s is Running\n", data.pkgid);
+ else
+ printf("Pkgid: %s is Not Running\n", data.pkgid);
+ }
+ ret = data.result;
break;
+ case LIST_REQ:
+ if (data.pkg_type[0] == '\0') {
+ ret = pkgmgrinfo_pkginfo_get_list(__pkgmgr_list_cb, NULL);
+ if (ret == -1) {
+ printf("Failed to get package list\n");
+ break;
+ }
+ break;
+ } else {
+ pkgmgrinfo_pkginfo_filter_h handle;
+ ret = pkgmgrinfo_pkginfo_filter_create(&handle);
+ if (ret == -1) {
+ printf("Failed to get package filter handle\n");
+ break;
+ }
+ ret = pkgmgrinfo_pkginfo_filter_add_string(handle, PMINFO_PKGINFO_PROP_PACKAGE_TYPE, data.pkg_type);
+ if (ret == -1) {
+ printf("Failed to add package type filter\n");
+ pkgmgrinfo_pkginfo_filter_destroy(handle);
+ break;
+ }
+ ret = pkgmgrinfo_pkginfo_filter_foreach_pkginfo(handle, __pkgmgr_list_cb, NULL);
+ if (ret == -1) {
+ printf("Failed to get package filter list\n");
+ pkgmgrinfo_pkginfo_filter_destroy(handle);
+ break;
+ }
+ pkgmgrinfo_pkginfo_filter_destroy(handle);
+ break;
+ }
+
case SHOW_REQ:
- if (data.pkg_name[0] != '\0') {
+ if (data.pkgid[0] != '\0') {
pkgmgr_info *pkg_info =
- pkgmgr_info_new(data.pkg_type, data.pkg_name);
+ pkgmgr_info_new(data.pkg_type, data.pkgid);
if (pkg_info == NULL) {
printf("Failed to get pkginfo handle\n");
ret = -1;
break;
}
if (data.pkg_path[0] != '\0') {
- pkgmgr_info *pkg_info =
- pkgmgr_info_new_from_file(data.pkg_type,
- data.pkg_path);
+ pkgmgr_info *pkg_info = pkgmgr_client_check_pkginfo_from_file(data.pkg_path);
if (pkg_info == NULL) {
printf("Failed to get pkginfo handle\n");
ret = -1;
ret = pkgmgr_info_free(pkg_info);
break;
}
- printf("Either pkgname or pkgpath should be supplied\n");
+ printf("Either pkgid or pkgpath should be supplied\n");
ret = -1;
break;
+ case CSC_REQ:
+ ret = pkgmgr_client_request_service(PM_REQUEST_CSC, 0, NULL, NULL, NULL, data.des_path, NULL, (void *)data.pkg_path);
+ if (ret < 0)
+ data.result = PKGCMD_ERR_FATAL_ERROR;
+ break;
+
+ case GETSIZE_REQ:
+ if (data.pkgid[0] == '\0') {
+ printf("Please provide the arguments.\n");
+ printf("use -h option to see usage\n");
+ ret = -1;
+ break;
+ }
+
+ pc = pkgmgr_client_new(PC_REQUEST);
+ if (pc == NULL) {
+ printf("PkgMgr Client Creation Failed\n");
+ data.result = PKGCMD_ERR_FATAL_ERROR;
+ break;
+ }
+
+ if (data.type == 9) {
+ ret = pkgmgrinfo_pkginfo_get_list(__pkg_list_cb, (void *)pc);
+ break;
+ }
+
+ ret = pkgmgr_client_request_service(PM_REQUEST_GET_SIZE, data.type, pc, NULL, data.pkgid, NULL, NULL, NULL);
+ if (ret < 0){
+ data.result = PKGCMD_ERR_FATAL_ERROR;
+ break;
+ }
+
+ printf("pkg[%s] size = %d\n", data.pkgid, ret);
+ ret = data.result;
+ break;
+
+ case GET_PKG_SIZE_INFO_REQ:
+ main_loop = g_main_loop_new(NULL, FALSE);
+ gpc = pkgmgr_client_new(PC_REQUEST);
+ if (gpc == NULL) {
+ printf("PkgMgr Client Creation Failed\n");
+ data.result = PKGCMD_ERR_FATAL_ERROR;
+ break;
+ }
+
+ if (strcmp(data.pkgid, PKG_SIZE_INFO_TOTAL) == 0)
+ {
+ ret = pkgmgr_client_get_total_package_size_info(gpc, __total_pkg_size_info_recv_cb, NULL);
+
+ }
+ else
+ {
+ ret = pkgmgr_client_get_package_size_info(gpc, data.pkgid, __pkg_size_info_recv_cb, NULL);
+ }
+ if (ret < 0){
+ data.result = PKGCMD_ERR_FATAL_ERROR;
+ break;
+ }
+
+ printf("pkg[%s] ret: %d\n", data.pkgid, ret);
+ ret = data.result;
+
+ g_main_loop_run(main_loop);
+ break;
+
+ case RESET_DEVICE_REQ:
+ ret = pkgmgr_client_reset_device();
+ break;
+
case HELP_REQ:
__print_usage();
ret = 0;
static int __is_authorized()
{
/* pkgcmd needs root or developer privileges.
- If launched via fork/exec, the launching program
+ If launched via fork/exec, the launching program
must be running as root */
uid_t uid = getuid();
int opt_idx = 0;
int c = -1;
int ret = -1;
+ char *errstr = NULL;
+ long starttime;
+ long endtime;
+ struct timeval tv;
if (!__is_authorized()) {
printf("You are not an authorized user!\n");
- return -1;
+ return PKGCMD_ERR_FATAL_ERROR;
}
if (argc == 1)
__print_usage();
+ gettimeofday(&tv, NULL);
+ starttime = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
+
data.request = -1;
memset(data.des_path, '\0', PKG_NAME_STRING_LEN_MAX);
memset(data.pkg_path, '\0', PKG_NAME_STRING_LEN_MAX);
- memset(data.pkg_name, '\0', PKG_NAME_STRING_LEN_MAX);
+ memset(data.pkgid, '\0', PKG_NAME_STRING_LEN_MAX);
memset(data.pkg_type, '\0', PKG_TYPE_STRING_LEN_MAX);
- data.quiet = 0;
+ memset(data.label, '\0', PKG_TYPE_STRING_LEN_MAX);
data.result = 0;
+ data.type = -1;
while (1) {
c = getopt_long(argc, argv, short_options, long_options,
&opt_idx);
data.request = UNINSTALL_REQ;
break;
+ case 'r': /* reinstall */
+ data.request = REINSTALL_REQ;
+ break;
+
case 'c': /* clear */
data.request = CLEAR_REQ;
break;
+ case 'g': /* get pkg size */
+ data.request = GETSIZE_REQ;
+ break;
+
+ case 'x': /* get pkg size info */
+ data.request = GET_PKG_SIZE_INFO_REQ;
+ break;
+
+ case 'm': /* move */
+ data.request = MOVE_REQ;
+ break;
+
+ case 'S': /* csc packages */
+ data.request = CSC_REQ;
+ if (optarg)
+ strncpy(data.des_path, optarg, PKG_NAME_STRING_LEN_MAX - 1);
+ printf("csc file is %s\n", data.des_path);
+ break;
+
case 'A': /* activate */
data.request = ACTIVATE_REQ;
break;
data.request = DEACTIVATE_REQ;
break;
+ case 'L': /* activate with Label */
+ data.request = ACTIVATE_REQ;
+ if (optarg)
+ strncpy(data.label, optarg,
+ PKG_NAME_STRING_LEN_MAX - 1);
+ break;
+
+ case 'R': /* device reset */
+ data.request = RESET_DEVICE_REQ;
+ break;
+
+ case 'a': /* app installation path */
+ data.request = APPPATH_REQ;
+ break;
+
+ case 'k': /* Terminate applications of a package */
+ data.request = KILLAPP_REQ;
+ break;
+
+ case 'C': /* Check running status of applications of a package */
+ data.request = CHECKAPP_REQ;
+ break;
+
case 'l': /* list */
data.request = LIST_REQ;
break;
case 'p': /* package path */
if (optarg)
strncpy(data.pkg_path, optarg,
- PKG_NAME_STRING_LEN_MAX);
+ PKG_NAME_STRING_LEN_MAX - 1);
ret = __convert_to_absolute_path(data.pkg_path);
if (ret == -1) {
printf("conversion of relative path to absolute path failed\n");
return -1;
}
- printf("package path is %s\n", data.pkg_path);
+ printf("path is %s\n", data.pkg_path);
break;
case 'd': /* descriptor path */
if (optarg)
strncpy(data.des_path, optarg,
- PKG_NAME_STRING_LEN_MAX);
+ PKG_NAME_STRING_LEN_MAX - 1);
break;
case 'n': /* package name */
if (optarg)
- strncpy(data.pkg_name, optarg,
- PKG_NAME_STRING_LEN_MAX);
+ strncpy(data.pkgid, optarg,
+ PKG_NAME_STRING_LEN_MAX - 1);
break;
case 't': /* package type */
if (optarg)
strncpy(data.pkg_type, optarg,
- PKG_TYPE_STRING_LEN_MAX);
+ PKG_TYPE_STRING_LEN_MAX - 1);
break;
- case 'h': /* help */
- data.request = HELP_REQ;
+ case 'T': /* move type */
+ data.type = atoi(optarg);
break;
- case 'q': /* quiet mode */
- data.quiet = 1;
+ case 'h': /* help */
+ data.request = HELP_REQ;
break;
/* Otherwise */
}
}
ret = __process_request();
+ if ((ret == -1) && (data.result != 0))
+ data.result = PKGCMD_ERR_ARGUMENT_INVALID;
+
if (ret != 0) {
- printf("processing request %d failed\n", data.request);
+ __error_no_to_string(data.result, &errstr);
+ printf("processing result : %s [%d] failed\n", errstr, data.result);
+ } else {
+ if (data.request == INSTALL_REQ)
+ sleep(2);
}
- return ret;
+
+
+ gettimeofday(&tv, NULL);
+ endtime = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
+ printf("spend time for pkgcmd is [%d]ms\n", (int)(endtime - starttime));
+
+ return data.result;
}
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#define _GNU_SOURCE
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <iniparser.h>
+#include <ctype.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/time.h>
+
+#include <pkgmgr_parser.h>
+#include <pkgmgr-info.h>
+
+#include "pkg.h"
+
+#define CSC_APPLIST_INI_FILE "/opt/system/csc-default/app/applist.ini"
+
+#define FOTA_PKGMGR_DB_FILE PKGMGR_FOTA_PATH".pkgmgr_parser.db"
+#define CSC_PKGID_LIST_FILE PKGMGR_FOTA_PATH"csc_pkgid_list.txt"
+#define RO_PKGID_LIST_FILE PKGMGR_FOTA_PATH"ro_pkgid_list.txt"
+#define RW_PKGID_LIST_FILE PKGMGR_FOTA_PATH"rw_pkgid_list.txt"
+#define RO_FOTA_PKGID_LIST_FILE PKGMGR_FOTA_PATH"ro_fota_pkgid_list.txt"
+#define RW_FOTA_PKGID_LIST_FILE PKGMGR_FOTA_PATH"rw_fota_pkgid_list.txt"
+#define FOTA_RESULT_FILE PKGMGR_FOTA_PATH"result.txt"
+#define TPK_MANIFEST_FILE PKGMGR_FOTA_PATH"manifest.xml"
+#define PKG_DISABLED_LIST_FILE PKGMGR_FOTA_PATH"pkg_disabled_list.txt"
+
+#define PKG_INFO_DB_LABEL "pkgmgr::db"
+
+#define OPT_MANIFEST_DIRECTORY "/opt/share/packages"
+#define USR_MANIFEST_DIRECTORY "/usr/share/packages"
+
+#define TOKEN_MANEFEST_STR "manifest"
+#define TOKEN_PKGID_STR "package="
+#define TOKEN_VERSION_STR "version="
+#define TOKEN_TYPE_STR "type="
+#define TOKEN_HASH_STR "hash="
+#define TOKEN_PATH_STR "path"
+#define TOKEN_TPK_PKGID_STR "<Id>"
+
+#define SEPERATOR_START '"'
+#define SEPERATOR_END '"'
+#define SEPERATOR_MID ':'
+
+#define ASCII(s) (const char *)s
+#define XMLCHAR(s) (const xmlChar *)s
+
+#define _LOG(fmt, arg...) do { \
+ int fd = 0;\
+ FILE* file = NULL;\
+ file = fopen(FOTA_RESULT_FILE, "a");\
+ if (file == NULL) break;\
+ fprintf(file, "[PKG_FOTA] "fmt"", ##arg); \
+ fflush(file);\
+ fd = fileno(file);\
+ fsync(fd);\
+ fclose(file);\
+ fprintf(stderr, "[PKG_FOTA] "fmt"", ##arg);\
+} while (0)
+
+typedef enum {
+ PKG_IS_NOT_EXIST = 0,
+ PKG_IS_SAME,
+ PKG_IS_UPDATED,
+ PKG_IS_INSERTED,
+ PKG_IS_REMOVED
+} COMPARE_RESULT;
+
+static int _child_element(xmlTextReaderPtr reader, int depth)
+{
+ int ret = xmlTextReaderRead(reader);
+ int cur = xmlTextReaderDepth(reader);
+ while (ret == 1) {
+
+ switch (xmlTextReaderNodeType(reader)) {
+ case XML_READER_TYPE_ELEMENT:
+ if (cur == depth + 1)
+ return 1;
+ break;
+ case XML_READER_TYPE_TEXT:
+ /*text is handled by each function separately*/
+ if (cur == depth + 1)
+ return 0;
+ break;
+ case XML_READER_TYPE_END_ELEMENT:
+ if (cur == depth)
+ return 0;
+ break;
+ default:
+ if (cur <= depth)
+ return 0;
+ break;
+ }
+
+ ret = xmlTextReaderRead(reader);
+ cur = xmlTextReaderDepth(reader);
+ }
+ return ret;
+}
+static char *__find_info_from_xml(const char *manifest, const char *find_info)
+{
+ const xmlChar *node;
+ xmlTextReaderPtr reader;
+ char *info_val = NULL;
+ xmlChar *tmp = NULL;
+
+ if(manifest == NULL) {
+ _LOG("Input argument is NULL\n");
+ return NULL;
+ }
+
+ if(find_info == NULL) {
+ _LOG("find_info is NULL\n");
+ return NULL;
+ }
+
+ reader = xmlReaderForFile(manifest, NULL, 0);
+
+ if (reader) {
+ if (_child_element(reader, -1)) {
+ node = xmlTextReaderConstName(reader);
+ if (!node) {
+ _LOG("xmlTextReaderConstName value is NULL\n");
+ goto end;
+ }
+
+ if (!strcmp(ASCII(node), "manifest")) {
+ tmp = xmlTextReaderGetAttribute(reader, XMLCHAR(find_info));
+ if (tmp) {
+ FREE_AND_STRDUP(ASCII(tmp),info_val);
+ if(info_val == NULL)
+ _LOG("Malloc Failed");
+ FREE_AND_NULL(tmp);
+ }
+ } else {
+ _LOG("Manifest Node is not found\n");
+ }
+ }
+ } else {
+ _LOG("xmlReaderForFile value is NULL\n");
+ }
+
+end:
+ if (reader) {
+ xmlFreeTextReader(reader);
+ }
+
+ return info_val;
+}
+
+static int initdb_xsystem(const char *argv[])
+{
+ int status = 0;
+ pid_t pid;
+ pid = fork();
+ switch (pid) {
+ case -1:
+ perror("fork failed");
+ return -1;
+ case 0:
+ /* child */
+ execvp(argv[0], (char *const *)argv);
+ _exit(-1);
+ default:
+ /* parent */
+ break;
+ }
+ if (waitpid(pid, &status, 0) == -1) {
+ perror("waitpid failed");
+ return -1;
+ }
+ if (WIFSIGNALED(status)) {
+ perror("signal");
+ return -1;
+ }
+ if (!WIFEXITED(status)) {
+ /* shouldn't happen */
+ perror("should not happen");
+ return -1;
+ }
+ return WEXITSTATUS(status);
+}
+
+static void __remove_pkgid_list()
+{
+ if (access(FOTA_RESULT_FILE, R_OK) == 0){
+ (void)remove(FOTA_RESULT_FILE);
+ }
+
+ if (access(RO_PKGID_LIST_FILE, R_OK) == 0){
+ (void)remove(RO_PKGID_LIST_FILE);
+ }
+
+ if (access(RO_FOTA_PKGID_LIST_FILE, R_OK) == 0){
+ (void)remove(RO_FOTA_PKGID_LIST_FILE);
+ }
+
+ if (access(CSC_PKGID_LIST_FILE, R_OK) == 0){
+ (void)remove(CSC_PKGID_LIST_FILE);
+ }
+
+ if (access(TPK_MANIFEST_FILE, R_OK) == 0){
+ (void)remove(TPK_MANIFEST_FILE);
+ }
+
+ if (access(RW_PKGID_LIST_FILE, R_OK) == 0){
+ (void)remove(RW_PKGID_LIST_FILE);
+ }
+
+ if (access(RW_FOTA_PKGID_LIST_FILE, R_OK) == 0){
+ (void)remove(RW_FOTA_PKGID_LIST_FILE);
+ }
+
+ if (access(PKG_DISABLED_LIST_FILE, R_OK) == 0){
+ (void)remove(PKG_DISABLED_LIST_FILE);
+ }
+}
+
+static int __make_pkgid_list(char *file_path, char *pkgid, char *compare_data, char *type)
+{
+ FILE *fp;\
+
+ if (NULL == pkgid)
+ return 0;
+
+ fp = fopen(file_path, "a+");
+ if (NULL == fp)
+ return -1;
+ /* compare_data variable hold hash value if Hash comparsion is enabled, otherwise it holds version */
+ fprintf(fp, "%s\"%s\" %s\"%s\" %s\"%s\":\n", TOKEN_PKGID_STR, pkgid, TOKEN_HASH_STR, compare_data, TOKEN_TYPE_STR, type);
+
+ fclose(fp);\
+
+ return 0;
+}
+
+static int __pkgid_list_cb (const pkgmgrinfo_pkginfo_h handle, void *user_data)
+{
+ int ret = -1;
+ char *pkgid = NULL;
+ char *compare_data = NULL;
+ char *type = NULL;
+
+ ret = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
+ if(ret < 0) {
+ _LOG("pkgmgrinfo_pkginfo_get_pkgid() failed\n");
+ }
+
+ ret = pkgmgrinfo_pkginfo_get_type(handle, &type);
+ if(ret < 0) {
+ _LOG("pkgmgrinfo_pkginfo_get_type() failed\n");
+ }
+
+ ret = pkgmgrinfo_pkginfo_get_hash(handle, &compare_data);
+ if(ret < 0) {
+ _LOG("pkgmgrinfo_pkginfo_get_hash() failed\n");
+ }
+
+ ret = __make_pkgid_list((char *)user_data, pkgid, compare_data, type);
+
+ return ret;
+}
+
+static void __str_trim(char *input)
+{
+ char *trim_str = input;
+
+ if (input == NULL)
+ return;
+
+ while (*input != 0) {
+ if (!isspace(*input)) {
+ *trim_str = *input;
+ trim_str++;
+ }
+ input++;
+ }
+
+ *trim_str = 0;
+ return;
+}
+
+static char * __getvalue(const char* pBuf, const char* pKey)
+{
+ const char* p = NULL;
+ const char* pStart = NULL;
+ const char* pEnd = NULL;
+
+ p = strstr(pBuf, pKey);
+ if (p == NULL)
+ return NULL;
+
+ pStart = p + strlen(pKey) + 1;
+ pEnd = strchr(pStart, SEPERATOR_END);
+ if (pEnd == NULL) {
+ pEnd = strchr(pStart, SEPERATOR_MID);
+ if (pEnd == NULL)
+ return NULL;
+ }
+
+ size_t len = pEnd - pStart;
+ if (len <= 0)
+ return NULL;
+
+ char *pRes = (char*)malloc(len + 1);
+ if (pRes == NULL) {
+ _LOG("out of memory");
+ return NULL;
+ }
+
+ strncpy(pRes, pStart, len);
+ pRes[len] = 0;
+
+ return pRes;
+}
+
+#ifdef _FOTA_INIT_DB
+
+static char * __find_str(const char* manifest, const char *str)
+{
+ FILE *fp = NULL;
+ char buf[BUF_SIZE] = {0};
+ char *get_str = NULL;
+
+ fp = fopen(manifest, "r");
+ if (fp == NULL) {
+ _LOG("Fail get : %s\n", manifest);
+ return NULL;
+ }
+
+ while (fgets(buf, BUF_SIZE, fp) != NULL) {
+ __str_trim(buf);
+
+ if (strstr(buf, TOKEN_MANEFEST_STR) != NULL) {
+ get_str = __getvalue(buf, str);
+ if (get_str != NULL) {
+ fclose(fp);
+ return get_str;
+ }
+ }
+ memset(buf, 0x00, BUF_SIZE);
+ }
+
+ if (fp != NULL)
+ fclose(fp);
+
+ return NULL;
+}
+
+static int __compare_version(char *orig_version, char *fota_version)
+{
+ int i = 1;
+ char* orig_str[4]= {0, };
+ char* fota_str[4]= {0, };
+
+ char orig_ver[BUF_SIZE] = {0};
+ char fota_ver[BUF_SIZE] = {0};
+
+ if ((orig_version == NULL) || (fota_version == NULL)) {
+ _LOG("Version is null \n");
+ return PKG_IS_SAME;
+ }
+
+ snprintf(orig_ver, BUF_SIZE-1, "%s", orig_version);
+ snprintf(fota_ver, BUF_SIZE-1, "%s", fota_version);
+
+ orig_str[0] = strtok(orig_ver,".");
+ while(1)
+ {
+ orig_str[i] = strtok(NULL,".");
+ if(orig_str[i] == NULL)
+ break;
+ i++;
+ }
+
+ i = 1;
+ fota_str[0] = strtok(fota_ver,".");
+ while(1)
+ {
+ fota_str[i] = strtok(NULL,".");
+ if(fota_str[i] == NULL)
+ break;
+ i++;
+ }
+
+ if((orig_str[0] == NULL) || (orig_str[1] == NULL) || (orig_str[2] == NULL))
+ return PKG_IS_SAME;
+
+ /*check first number*/
+ if (atoi(orig_str[0]) < atoi(fota_str[0])) {
+ return PKG_IS_UPDATED;
+ } else if (atoi(orig_str[0]) == atoi(fota_str[0])) {
+ /*check 2nd number*/
+ if (atoi(orig_str[1]) < atoi(fota_str[1])) {
+ return PKG_IS_UPDATED;
+ } else if (atoi(orig_str[1]) == atoi(fota_str[1])) {
+ /*check 3rd number*/
+ if (atoi(orig_str[2]) < atoi(fota_str[2])) {
+ return PKG_IS_UPDATED;
+ }
+ }
+ }
+
+ /*other case is same*/
+ return PKG_IS_SAME;
+}
+
+#endif
+
+static int __compare_hash(char *orig_hash, char* fota_hash)
+{
+ int ret = PKG_IS_SAME;
+ if(strcmp(orig_hash,"(null)") && strcmp(fota_hash,"(null)")){
+ if(strcmp(orig_hash,fota_hash))
+ ret = PKG_IS_UPDATED;
+ }
+
+ return ret;
+}
+static int __compare_pkgid(char *file_path, char *fota_pkgid, char *fota_compare_data)
+{
+ int ret = PKG_IS_NOT_EXIST;
+ FILE *fp = NULL;
+ char buf[BUF_SIZE] = {0};
+ char *pkgid = NULL;
+ char *compare_data = NULL;
+
+ if((file_path == NULL) || (fota_pkgid == NULL) || (fota_compare_data == NULL)){
+ _LOG("input is null\n");
+ return -1;
+ }
+
+ fp = fopen(file_path, "r");
+ if (fp == NULL) {
+ _LOG("Fail get : %s\n", file_path);
+ return -1;
+ }
+
+ while (fgets(buf, BUF_SIZE, fp) != NULL) {
+ __str_trim(buf);
+
+ pkgid = __getvalue(buf, TOKEN_PKGID_STR);
+ if(pkgid == NULL) {
+ _LOG("pkgid is null\n");
+ continue;
+ }
+
+ compare_data = __getvalue(buf,TOKEN_HASH_STR);
+
+ if(compare_data == NULL) {
+ free(pkgid);
+ _LOG("compare_data is null\n");
+ continue;
+ }
+
+ if(strcmp(pkgid, fota_pkgid) == 0) {
+ if(__compare_hash(compare_data,fota_compare_data) == PKG_IS_UPDATED){
+ ret = PKG_IS_UPDATED;
+ free(pkgid);
+ free(compare_data);
+ break;
+ }
+
+ free(pkgid);
+ free(compare_data);
+ ret = PKG_IS_SAME;
+ break;
+ }
+
+ free(pkgid);
+ free(compare_data);
+ memset(buf, 0x00, BUF_SIZE);
+ }
+
+ if (fp != NULL)
+ fclose(fp);
+
+ return ret;
+}
+
+static int __compare_csc_pkgid(const char *pkgid)
+{
+ int ret = 0;
+ FILE *fp = NULL;
+ char buf[BUF_SIZE] = {0};
+ char *csc_pkgid = NULL;
+
+ if(pkgid == NULL) {
+ _LOG("pkgid is null\n");
+ return ret;
+ }
+
+ fp = fopen(CSC_PKGID_LIST_FILE, "r");
+ if (fp == NULL) {
+// _LOG("Fail get : %s\n", CSC_PKGID_LIST_FILE);
+ return ret;
+ }
+
+ while (fgets(buf, BUF_SIZE, fp) != NULL) {
+ __str_trim(buf);
+
+ csc_pkgid = __getvalue(buf, TOKEN_PKGID_STR);
+ if(csc_pkgid == NULL) {
+ _LOG("pkgid is null\n");
+ memset(buf, 0x00, BUF_SIZE);
+ continue;
+ }
+
+ if(strcmp(csc_pkgid, pkgid) == 0) {
+ _LOG("pkgid[%s] is already processed by csc \n", pkgid);
+ free(csc_pkgid);
+ ret = -1;
+ break;
+ }
+
+ free(csc_pkgid);
+ memset(buf, 0x00, BUF_SIZE);
+ }
+
+ if (fp != NULL)
+ fclose(fp);
+
+ return ret;
+}
+
+static char *__get_pkgid_from_tpk_manifest(const char* manifest)
+{
+ FILE *fp = NULL;
+ char buf[BUF_SIZE] = {0};
+
+ fp = fopen(manifest, "r");
+ if (fp == NULL) {
+ _LOG("Fail get : %s \n", manifest);
+ return NULL;
+ }
+
+ while (fgets(buf, BUF_SIZE, fp) != NULL) {
+ __str_trim(buf);
+
+ const char* p = NULL;
+ const char* pStart = NULL;
+
+ p = strstr(buf, TOKEN_TPK_PKGID_STR);
+ if (p != NULL) {
+ pStart = p + strlen(TOKEN_TPK_PKGID_STR);
+ char *pRes = (char*)malloc(11);
+ if (pRes == NULL) {
+ _LOG("out of memory");
+ fclose(fp);
+ return NULL;
+ }
+
+ strncpy(pRes, pStart, 10);
+ pRes[10] = 0;
+ fclose(fp);
+ return pRes;
+ }
+ memset(buf, 0x00, BUF_SIZE);
+ }
+
+ if (fp != NULL)
+ fclose(fp);
+
+ return NULL;
+}
+
+char* __manifest_to_package(const char* manifest)
+{
+ char *package;
+
+ if(manifest == NULL)
+ return NULL;
+
+ package = strdup(manifest);
+ if(package == NULL)
+ return NULL;
+
+ if (!strstr(package, ".xml")) {
+ _LOG("%s is not a manifest file \n", manifest);
+ free(package);
+ return NULL;
+ }
+
+ return package;
+}
+
+static void __send_args_to_backend(char *pkgid, char *type, int compare_result)
+{
+ int ret = 0;
+ char *op = NULL;
+ char buf[BUF_SIZE] = {0};
+
+ long starttime;
+ long endtime;
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ starttime = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
+
+ if (compare_result == PKG_IS_SAME) {
+// _LOG("Pkgid[%s] - [%s] is same\n", pkgid, type);
+ return;
+ }
+
+ if (__compare_csc_pkgid(pkgid) < 0) {
+ return;
+ }
+
+ switch (compare_result) {
+ case 2:
+ op = "update";
+// _LOG("pkgid[%s] is update, it is already exist\n", pkgid);
+ break;
+
+ case 3:
+ op = "install";
+// _LOG("pkgid[%s] is install, it is new\n", pkgid);
+ break;
+
+ case 4:
+ op = "uninstall";
+// _LOG("pkgid[%s] is uninstall, it is deleted\n", pkgid);
+ break;
+
+ default:
+ break;
+ }
+
+ snprintf(buf, sizeof(buf), "path=%s:op=%s", pkgid, op);
+
+ if (strcmp(type,"rpm") == 0) {
+ const char *rpm_argv[] = { "/usr/bin/rpm-backend", "-k", "rpm-fota", "-s", buf, NULL };
+ ret = initdb_xsystem(rpm_argv);
+ } else if(strcmp(type,"tpk") == 0) {
+ const char *osp_argv[] = { "/usr/bin/osp-installer", "-f", buf, NULL };
+ ret = initdb_xsystem(osp_argv);
+ } else if(strcmp(type,"wgt") == 0) {
+ const char *wrt_argv[] = { "/usr/bin/wrt-installer", "-f", buf, NULL };
+ ret = initdb_xsystem(wrt_argv);
+ } else {
+ _LOG("Pkgid[%s] - [%s] is not supported\n", pkgid, type);
+ return;
+ }
+
+ gettimeofday(&tv, NULL);
+ endtime = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
+
+ _LOG("operation[%s - %s] \t result[%d ms, %d] \t Pkgid[%s] \n", op, type, (int)(endtime - starttime), ret, pkgid);
+}
+
+
+static void __send_args_to_backend_for_rw_fota(char *pkgid, char *type, int compare_result)
+{
+ int ret = 0;
+ char *op = NULL;
+ char buf[BUF_SIZE] = {0};
+
+ long starttime;
+ long endtime;
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ starttime = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
+
+ if(pkgid == NULL || type == NULL){
+ _LOG("input is null\n");
+ return;
+ }
+
+ if (compare_result == PKG_IS_SAME) {
+// _LOG("Pkgid[%s] - [%s] is same\n", pkgid, type);
+ return;
+ }
+
+ if (__compare_csc_pkgid(pkgid) < 0) {
+ return;
+ }
+
+ switch (compare_result) {
+ case 2:
+ op = "update";
+// _LOG("pkgid[%s] is update, it is already exist\n", pkgid);
+ break;
+ case 3:
+ op = "install";
+// _LOG("pkgid[%s] is install, it is new\n", pkgid);
+ break;
+ case 4:
+ op = "uninstall";
+// _LOG("pkgid[%s] is uninstall, it is deleted\n", pkgid);
+ break;
+ default:
+ break;
+ }
+
+ snprintf(buf, sizeof(buf), "path=%s:op=%s", pkgid, op);
+
+ if (strcmp(type,"rpm") == 0) {
+ const char *rpm_argv[] = { "/usr/bin/rpm-backend", "-k", "rpm-rw-fota", "-s", buf, NULL };
+ ret = initdb_xsystem(rpm_argv);
+ } else if(strcmp(type,"tpk") == 0) {
+ const char *osp_argv[] = { "/usr/bin/osp-installer", "-F", buf, NULL };
+ ret = initdb_xsystem(osp_argv);
+ } else if(strcmp(type,"wgt") == 0) {
+ const char *wrt_argv[] = { "/usr/bin/wrt-installer", "-F", buf, NULL };
+ ret = initdb_xsystem(wrt_argv);
+ } else {
+ _LOG("Pkgid[%s] - [%s] is not supported\n", pkgid, type);
+ return;
+ }
+
+ gettimeofday(&tv, NULL);
+ endtime = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
+
+ _LOG("operation[%s - %s] \t result[%d ms, %d] \t Pkgid[%s] \n", op, type, (int)(endtime - starttime), ret, pkgid);
+}
+
+static int __find_preload_pkgid_from_xml(const char *file_path)
+{
+ int ret = 0;
+ char buf[BUF_SIZE] = {0};
+ DIR *dir;
+ struct dirent entry, *result;
+
+ dir = opendir(USR_MANIFEST_DIRECTORY);
+ if (!dir) {
+ if (strerror_r(errno, buf, sizeof(buf)) == 0)
+ _LOG("Failed to access the [%s] because %s\n", USR_MANIFEST_DIRECTORY, buf);
+ return -1;
+ }
+
+ for (ret = readdir_r(dir, &entry, &result);
+ ret == 0 && result != NULL;
+ ret = readdir_r(dir, &entry, &result)) {
+ char *manifest;
+ char *pkgid;
+ // compare_data variable holds hash value if hash comparsion is enabled, otherwise it holds version.
+ char *compare_data;
+ char *type;
+
+ if (entry.d_name[0] == '.') continue;
+
+ manifest = __manifest_to_package(entry.d_name);
+ if (!manifest) {
+ _LOG("Failed to convert file to xml[%s]\n", entry.d_name);
+ continue;
+ }
+
+ snprintf(buf, sizeof(buf), "%s/%s", USR_MANIFEST_DIRECTORY, manifest);
+
+ /*Get the package name from manifest file*/
+ pkgid = __find_info_from_xml(buf,"package");
+ if(pkgid == NULL) {
+ free(manifest);
+ continue;
+ }
+
+ /*Get the type of the package from manifest file*/
+ type = __find_info_from_xml(buf,"type");
+ if(type == NULL)
+ type = strdup("rpm");
+
+ compare_data = pkgmgrinfo_basic_generate_hash_for_file(buf);
+
+ ret = __make_pkgid_list((char*)file_path, pkgid, compare_data, type);
+ if (ret < 0)
+ _LOG("Make file Fail : %s => %s, %s\n", buf, pkgid, compare_data);
+
+ FREE_AND_NULL(pkgid);
+ FREE_AND_NULL(compare_data);
+ FREE_AND_NULL(type);
+ FREE_AND_NULL(manifest);
+ }
+
+ closedir(dir);
+
+ return 0;
+}
+
+static int __find_preload_pkgid_from_db(const char *file_path, int is_readonly)
+{
+ int ret = 0;
+ pkgmgrinfo_pkginfo_filter_h handle = NULL;
+
+ ret = pkgmgrinfo_pkginfo_filter_create(&handle);
+ if (ret > 0) {
+ _LOG("pkginfo filter handle create failed\n");
+ return -1;
+ }
+
+ ret = pkgmgrinfo_pkginfo_filter_add_bool(handle, PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD, 1);
+ if (ret < 0) {
+ _LOG("pkgmgrinfo_pkginfo_filter_add_bool() failed\n");
+ ret = -1;
+ }
+
+ if (is_readonly == 1) {
+ ret = pkgmgrinfo_pkginfo_filter_add_bool(handle, PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE, 0);
+ if (ret < 0) {
+ _LOG("pkgmgrinfo_pkginfo_filter_add_bool() failed\n");
+ ret = -1;
+ }
+
+ ret = pkgmgrinfo_pkginfo_filter_add_bool(handle, PMINFO_PKGINFO_PROP_PACKAGE_READONLY, 1);
+ if (ret < 0) {
+ _LOG("pkgmgrinfo_pkginfo_filter_add_bool() failed\n");
+ ret = -1;
+ }
+ } else {
+ ret = pkgmgrinfo_pkginfo_filter_add_bool(handle, PMINFO_PKGINFO_PROP_PACKAGE_READONLY, 0);
+ if (ret < 0) {
+ _LOG("pkgmgrinfo_pkginfo_filter_add_bool() failed\n");
+ }
+ }
+
+ ret = pkgmgrinfo_pkginfo_filter_foreach_pkginfo(handle, __pkgid_list_cb, (void *)file_path);
+ if (ret < 0) {
+ _LOG("pkgmgrinfo_pkginfo_filter_foreach_pkginfo() failed\n");
+ ret = -1;
+ }
+
+ pkgmgrinfo_pkginfo_filter_destroy(handle);
+ return ret;
+}
+
+static int __find_matched_pkgid_from_list(const char *source_file, const char *target_file, int rw_fota_enabled)
+{
+ FILE *fp = NULL;
+ char buf[BUF_SIZE] = {0};
+ char *pkgid = NULL;
+ char *compare_data = NULL;
+ char *type = NULL;
+
+ int same_pkg_cnt = 0;
+ int update_pkg_cnt = 0;
+ int insert_pkg_cnt = 0;
+ int total_pkg_cnt = 0;
+
+ int compare_result = 0;
+
+ fp = fopen(source_file, "r");
+ if (fp == NULL) {
+ _LOG("Fail get : %s\n", source_file);
+ return -1;
+ }
+
+ _LOG("Searching...... inserted or Updated package \n");
+
+ while (fgets(buf, BUF_SIZE, fp) != NULL) {
+ __str_trim(buf);
+
+ pkgid = __getvalue(buf, TOKEN_PKGID_STR);
+ if(pkgid == NULL) {
+ continue;
+ }
+
+ compare_data = __getvalue(buf,TOKEN_HASH_STR);
+
+ type = __getvalue(buf, TOKEN_TYPE_STR);
+
+ compare_result = __compare_pkgid((char*)target_file, pkgid, compare_data);
+ if(compare_result == PKG_IS_NOT_EXIST) {
+ compare_result = PKG_IS_INSERTED;
+ insert_pkg_cnt++;
+ } else if (compare_result == PKG_IS_SAME) {
+ same_pkg_cnt++;
+ } else if (compare_result == PKG_IS_UPDATED) {
+ update_pkg_cnt++;
+ }
+
+ total_pkg_cnt++;
+ if (rw_fota_enabled == 1)
+ __send_args_to_backend_for_rw_fota(pkgid, type, compare_result);
+ else
+ __send_args_to_backend(pkgid, type, compare_result);
+
+ memset(buf, 0x00, BUF_SIZE);
+ FREE_AND_NULL(pkgid);
+ FREE_AND_NULL(type);
+ FREE_AND_NULL(compare_data);
+ }
+
+ _LOG("-------------------------------------------------------\n");
+ _LOG("[Total pkg=%d, same pkg=%d, updated pkg=%d, inserted package=%d]\n", total_pkg_cnt, same_pkg_cnt, update_pkg_cnt, insert_pkg_cnt);
+ _LOG("-------------------------------------------------------\n");
+
+ if (fp != NULL)
+ fclose(fp);
+
+ return 0;
+}
+
+static int __find_deleted_pkgid_from_list(const char *source_file, const char *target_file, int rw_fota_enabled)
+{
+ FILE *fp = NULL;
+ char buf[BUF_SIZE] = {0};
+ char *pkgid = NULL;
+ char *compare_data = NULL;
+ char *type = NULL;
+
+ int deleted_pkg_cnt = 0;
+ int total_pkg_cnt = 0;
+
+ int compare_result = 0;
+
+ fp = fopen(source_file, "r");
+ if (fp == NULL) {
+ _LOG("Fail get : %s\n", source_file);
+ return -1;
+ }
+
+ _LOG("Searching...... deleted package \n");
+
+ while (fgets(buf, BUF_SIZE, fp) != NULL) {
+ __str_trim(buf);
+
+ pkgid = __getvalue(buf, TOKEN_PKGID_STR);
+ if(pkgid == NULL) {
+ continue;
+ }
+
+ type = __getvalue(buf, TOKEN_TYPE_STR);
+
+ compare_data = __getvalue(buf,TOKEN_HASH_STR);
+
+ compare_result = __compare_pkgid((char*)target_file, pkgid, compare_data);
+ if(compare_result == PKG_IS_NOT_EXIST) {
+ compare_result = PKG_IS_REMOVED;
+
+ if (rw_fota_enabled == 1)
+ __send_args_to_backend_for_rw_fota(pkgid, type, compare_result);
+ else
+ __send_args_to_backend(pkgid, type, compare_result);
+
+ deleted_pkg_cnt++;
+ }
+ total_pkg_cnt++;
+
+ memset(buf, 0x00, BUF_SIZE);
+ FREE_AND_NULL(pkgid);
+ FREE_AND_NULL(compare_data);
+ FREE_AND_NULL(type);
+ }
+
+ _LOG("-------------------------------------------------------\n");
+ _LOG("[Total pkg=%d, deleted package=%d]\n", total_pkg_cnt, deleted_pkg_cnt);
+ _LOG("-------------------------------------------------------\n");
+
+ if (fp != NULL)
+ fclose(fp);
+
+ return 0;
+
+}
+
+static void __find_tpk_pkgid_from_csc(const char *tpk_path, char *result_path)
+{
+ int ret = 0;
+ char *pkgid = NULL;
+
+ /*check : input param is pkgid or tpk file*/
+ if (strstr(tpk_path, ".tpk") == NULL) {
+ __make_pkgid_list(result_path, (char*)tpk_path, NULL, NULL);
+ return;
+ }
+
+ /*unzip manifest from tpk*/
+ const char *unzip_argv[] = { "/usr/bin/unzip", "-j", tpk_path, "info/manifest.xml", "-d", PKGMGR_FOTA_PATH, NULL };
+ ret = initdb_xsystem(unzip_argv);
+ if (ret < 0) {
+ _LOG("unzip_argv fail[%s]", tpk_path);
+ return;
+ }
+
+ /*open manifest and get pkgid*/
+ pkgid = __get_pkgid_from_tpk_manifest(TPK_MANIFEST_FILE);
+ if (pkgid == NULL) {
+ _LOG("pkgid is null[%s]", tpk_path);
+ return;
+ }
+
+ /*make csc pkgid list*/
+ __make_pkgid_list(result_path, pkgid, NULL, NULL);
+
+ /*free variable*/
+ free(pkgid);
+
+ (void)remove(TPK_MANIFEST_FILE);
+}
+
+static void __find_xml_pkgid_from_csc(const char *xml_path, char *result_path)
+{
+ char *pkgid = NULL;
+ char buf[BUF_SIZE] = {0,};
+
+ if (strstr(xml_path, ".xml") == NULL) {
+ __make_pkgid_list(result_path, (char*)xml_path, NULL, NULL);
+ return;
+ }
+
+ pkgid = __find_info_from_xml(xml_path,"package");
+ if (pkgid != NULL) {
+ /*make csc pkgid list*/
+ __make_pkgid_list(result_path, pkgid, NULL, NULL);
+ free(pkgid);
+ return;
+ }
+ memset(buf, 0x00, BUF_SIZE);
+
+}
+
+static int __find_uninstalled_pkg(const char *xml_name)
+{
+ int ret = 0;
+ FILE *fp = NULL;
+ char buf[BUF_SIZE] = {0};
+ char *csc_pkgid = NULL;
+
+ if(xml_name == NULL) {
+ _LOG("xml_name is null\n");
+ return ret;
+ }
+
+ fp = fopen(CSC_PKGID_LIST_FILE, "r");
+ if (fp == NULL) {
+// _LOG("Fail get : %s\n", CSC_PKGID_LIST_FILE);
+ return ret;
+ }
+
+ while (fgets(buf, BUF_SIZE, fp) != NULL) {
+ __str_trim(buf);
+
+ csc_pkgid = __getvalue(buf, TOKEN_PKGID_STR);
+ if(csc_pkgid == NULL) {
+ _LOG("pkgid is null\n");
+ memset(buf, 0x00, BUF_SIZE);
+ continue;
+ }
+
+ if(strstr(xml_name, csc_pkgid) != NULL) {
+ _LOG("xml_name[%s] is already processed by csc \n", xml_name);
+ free(csc_pkgid);
+ ret = -1;
+ break;
+ }
+
+ free(csc_pkgid);
+ memset(buf, 0x00, BUF_SIZE);
+ }
+
+ if (fp != NULL)
+ fclose(fp);
+
+ return ret;
+}
+
+static void __get_pkgid_list_from_db_and_xml()
+{
+ int ret = 0;
+ int is_readonly = 1;
+
+ /*get pkgid of old version */
+ ret = __find_preload_pkgid_from_db(RO_PKGID_LIST_FILE, is_readonly);
+ if (ret < 0) {
+ _LOG("__find_preload_pkgid_from_db fail.\n");
+ } else {
+ _LOG("Make original pkgid success!! \n");
+ }
+
+ /*get pkgid of updated version by fota*/
+ ret = __find_preload_pkgid_from_xml(RO_FOTA_PKGID_LIST_FILE);
+ if (ret < 0) {
+ _LOG("__find_preload_pkgid_from_xml fail.\n");
+ } else {
+ _LOG("Make fota pkgid success!! \n");
+ }
+}
+
+static void __get_pkgid_list_from_db_and_zip()
+{
+ int ret = 0;
+ int is_readonly = 0;
+
+ /*get pkgid from orginal pkgmgr db*/
+ ret = __find_preload_pkgid_from_db(RW_PKGID_LIST_FILE, is_readonly);
+ if (ret < 0) {
+ _LOG("__find_preload_pkgid_from_db fail.\n");
+ } else {
+ _LOG("Make original pkgid success!! \n");
+ }
+
+ /*move orginal pkgmgr db to backup*/
+ const char *db_mv_argv[] = { "/bin/mv", PKGMGR_DB, PKGMGR_DB_BACKUP, NULL };
+ ret = initdb_xsystem(db_mv_argv);
+ if (ret < 0) {
+ _LOG("move orginal pkgmgr db to backup fail.\n");
+ }
+ const char *jn_mv_argv[] = { "/bin/mv", PKGMGR_DB_JOURNAL, PKGMGR_DB_JOURNAL_BACKUP, NULL };
+ ret = initdb_xsystem(jn_mv_argv);
+ if (ret < 0) {
+ _LOG("move orginal pkgmgr db to backup fail.\n");
+ }
+
+ /*unzip pkgmgr db from factoryrest data*/
+ const char *unzip_argv[] = { "/usr/bin/unzip", "-j", FACTORYRESET_BACKUP_FILE, "opt/dbspace/.pkgmgr_parser.db", "-d", PKGMGR_FOTA_PATH, NULL };
+ ret = initdb_xsystem(unzip_argv);
+ if (ret < 0) {
+ _LOG("unzip pkgmgr db from factoryrest data fail.\n");
+ }
+
+ /*move fota pkgmgr db to dbspace*/
+ const char *fota__mv_argv[] = { "/bin/mv", FOTA_PKGMGR_DB_FILE, OPT_DBSPACE_PATH, NULL };
+ ret = initdb_xsystem(fota__mv_argv);
+ if (ret < 0) {
+ _LOG("move fota pkgmgr db to dbspace fail.\n");
+ }
+
+ /*get pkgid from fota pkgmgr db*/
+ ret = __find_preload_pkgid_from_db(RW_FOTA_PKGID_LIST_FILE, is_readonly);
+ if (ret < 0) {
+ _LOG("__find_preload_pkgid_from_db fail.\n");
+ } else {
+ _LOG("Make fota pkgid success!! \n");
+ }
+
+ /*del pkgmgr db and recover orginal pkgmgr db from backup*/
+ const char *db_rm_argv[] = { "/bin/rm", "-f", PKGMGR_DB, NULL };
+ ret = initdb_xsystem(db_rm_argv);
+ if (ret < 0) {
+ _LOG("del pkgmgr db fail.\n");
+ }
+ const char *jn_rm_argv[] = { "/bin/rm", "-f", PKGMGR_DB_JOURNAL, NULL };
+ ret = initdb_xsystem(jn_rm_argv);
+ if (ret < 0) {
+ _LOG("del pkgmgr db fail.\n");
+ }
+
+ const char *db_recover_argv[] = { "/bin/mv", PKGMGR_DB_BACKUP, PKGMGR_DB, NULL };
+ ret = initdb_xsystem(db_recover_argv);
+ if (ret < 0) {
+ _LOG("recover orginal pkgmgr db fail.\n");
+ }
+ const char *jn_recover_argv[] = { "/bin/mv", PKGMGR_DB_JOURNAL_BACKUP, PKGMGR_DB_JOURNAL, NULL };
+ ret = initdb_xsystem(jn_recover_argv);
+ if (ret < 0) {
+ _LOG("recover orginal pkgmgr db fail.\n");
+ }
+
+ const char *argv_parser[] = { "/usr/bin/chsmack", "-a", PKG_INFO_DB_LABEL, PKGMGR_DB, NULL };
+ initdb_xsystem(argv_parser);
+ const char *argv_parserjn[] = { "/usr/bin/chsmack", "-a", PKG_INFO_DB_LABEL, PKGMGR_DB_JOURNAL, NULL };
+ initdb_xsystem(argv_parserjn);
+}
+
+static void __get_pkgid_list_from_csc()
+{
+ int cnt = 0;
+ int count = 0;
+
+ char *pkgtype = NULL;
+ char *des = NULL;
+ char *path = NULL;
+
+ char type_buf[BUF_SIZE] = { 0 };
+ char des_buf[BUF_SIZE] = { 0 };
+ dictionary *csc = NULL;
+
+ csc = iniparser_load(CSC_APPLIST_INI_FILE);
+ if (csc == NULL) {
+ _LOG("Dont have csc applist file\n\n");
+ return;
+ }
+
+ count = iniparser_getint(csc, "csc packages:count", -1);
+ if (count == 0) {
+ _LOG("csc [%s] dont have packages \n", CSC_APPLIST_INI_FILE);
+ goto end;
+ }
+
+ for(cnt = 1 ; cnt <= count ; cnt++)
+ {
+ snprintf(type_buf, BUF_SIZE - 1, "csc packages:type_%03d", cnt);
+ snprintf(des_buf, BUF_SIZE - 1, "csc packages:description_%03d", cnt);
+
+ /*parse csc description and type*/
+ pkgtype = iniparser_getstr(csc, type_buf);
+ des = iniparser_getstr(csc, des_buf);
+
+ if ((pkgtype == NULL) || (des == NULL)) {
+ continue;
+ }
+
+ /*get tpk path from csc description*/
+ path = __getvalue(des, TOKEN_PATH_STR);
+ if (path == NULL) {
+ _LOG("description[%s] has error", des);
+ continue;
+ }
+
+ if (strcmp(pkgtype, "tpk") == 0) {
+ __find_tpk_pkgid_from_csc(path, CSC_PKGID_LIST_FILE);
+ } else if (strcmp(pkgtype, "wgt")== 0) {
+// __find_wgt_pkgid_from_csc(path, CSC_PKGID_LIST_FILE);
+ } else if (strcmp(pkgtype, "xml")== 0) {
+ __find_xml_pkgid_from_csc(path, CSC_PKGID_LIST_FILE);
+ }
+
+ free(path);
+ }
+
+end:
+ iniparser_freedict(csc);
+}
+
+#ifdef _FOTA_INIT_DB
+
+static void __get_uninstalled_pkgid_list_from_csc()
+{
+ int cnt = 0;
+ int count = 0;
+
+ char *pkgtype = NULL;
+ char *des = NULL;
+ char *path = NULL;
+
+ char type_buf[BUF_SIZE] = { 0 };
+ char des_buf[BUF_SIZE] = { 0 };
+ dictionary *csc = NULL;
+
+ csc = iniparser_load(CSC_APPLIST_INI_FILE);
+ if (csc == NULL) {
+ _LOG("Dont have csc applist file\n\n");
+ return;
+ }
+
+ count = iniparser_getint(csc, "csc packages:count", -1);
+ if (count == 0) {
+ _LOG("csc [%s] dont have packages \n", CSC_APPLIST_INI_FILE);
+ goto end;
+ }
+
+ for(cnt = 1 ; cnt <= count ; cnt++)
+ {
+ snprintf(type_buf, BUF_SIZE - 1, "csc packages:type_%03d", cnt);
+ snprintf(des_buf, BUF_SIZE - 1, "csc packages:description_%03d", cnt);
+
+ /*parse csc description and type*/
+ pkgtype = iniparser_getstr(csc, type_buf);
+ des = iniparser_getstr(csc, des_buf);
+
+ if ((pkgtype == NULL) || (des == NULL)) {
+ continue;
+ }
+
+ if (strstr(des, "op=uninstall") != NULL) {
+ /*get tpk path from csc description*/
+ path = __getvalue(des, TOKEN_PATH_STR);
+ if (path == NULL) {
+ _LOG("description[%s] has error", des);
+ continue;
+ }
+
+ if (strcmp(pkgtype, "tpk") == 0) {
+ __find_tpk_pkgid_from_csc(path, CSC_PKGID_LIST_FILE);
+ } else if (strcmp(pkgtype, "wgt")== 0) {
+ // __find_wgt_pkgid_from_csc(path, CSC_PKGID_LIST_FILE);
+ } else if (strcmp(pkgtype, "xml")== 0) {
+ __find_xml_pkgid_from_csc(path, CSC_PKGID_LIST_FILE);
+ }
+
+ free(path);
+ }
+ }
+ __make_pkgid_list(CSC_PKGID_LIST_FILE, "org.tizen.joyn", NULL, NULL);
+
+end:
+ iniparser_freedict(csc);
+}
+
+static void __initdb_load_directory(const char *directory)
+{
+ DIR *dir;
+ struct dirent entry, *result;
+ int ret;
+ char buf[BUF_SIZE];
+
+ dir = opendir(directory);
+ if (!dir) {
+ if (strerror_r(errno, buf, sizeof(buf)) == 0)
+ _LOG("Failed to access the [%s] because %s \n", directory, buf);
+ return;
+ }
+
+ for (ret = readdir_r(dir, &entry, &result);
+ ret == 0 && result != NULL;
+ ret = readdir_r(dir, &entry, &result)) {
+
+ if (!strcmp(entry.d_name, ".") || !strcmp(entry.d_name, "..")) {
+ continue;
+ }
+
+ if (!strstr(entry.d_name, ".xml")) {
+ continue;
+ }
+
+ if (__find_uninstalled_pkg(entry.d_name) < 0) {
+ continue;
+ }
+
+ snprintf(buf, sizeof(buf), "%s/%s", directory, entry.d_name);
+
+ const char *pkginfo_argv[] = { "/usr/bin/pkginfo", "--imd", buf, NULL };
+ initdb_xsystem(pkginfo_argv);
+ }
+
+ closedir(dir);
+}
+
+static void __change_preload_attribute(const char *file_path)
+{
+ int ret = 0;
+ FILE *fp = NULL;
+ char buf[BUF_SIZE] = {0};
+ char *pkgid = NULL;
+
+ fp = fopen(file_path, "r");
+ if (fp == NULL) {
+ return;
+ }
+
+ while (fgets(buf, BUF_SIZE, fp) != NULL) {
+ __str_trim(buf);
+
+ pkgid = __getvalue(buf, TOKEN_PKGID_STR);
+ if(pkgid == NULL) {
+ _LOG("pkgid is null\n");
+ memset(buf, 0x00, BUF_SIZE);
+ continue;
+ }
+
+ ret = pkgmgrinfo_pkginfo_set_preload(pkgid, 1);
+ if (ret < 0) {
+ _LOG("pkgmgrinfo_pkginfo_set_preload[%s] fail.. \n", pkgid);
+ } else {
+ _LOG("pkgid[%s] set db as preload\n", pkgid);
+ }
+
+ free(pkgid);
+ memset(buf, 0x00, BUF_SIZE);
+ }
+
+ if (fp != NULL)
+ fclose(fp);
+
+ return;
+
+}
+
+#endif
+
+static int __make_disabled_list(char *file_path, char *pkgid)
+{
+ FILE *fp = NULL;
+
+ if ((file_path == NULL) || (pkgid == NULL)) {
+ _LOG("invalid argument.\n");
+ return -1;
+ }
+
+ fp = fopen(file_path, "a+");
+ if (fp == NULL) {
+ _LOG("fopen is failed.\n");
+ return -1;
+ }
+
+ fprintf(fp, "%s\n", pkgid);
+ fclose(fp);
+
+ return 0;
+}
+
+static int __pkg_disabled_list_cb(const pkgmgrinfo_pkginfo_h handle, void *file_path)
+{
+ int ret = 0;
+ char *pkgid = NULL;
+
+ ret = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
+ if (ret < 0) {
+ _LOG("pkgmgrinfo_pkginfo_get_pkgid is failed. pkgid is [%s].\n", pkgid);
+ return -1;
+ }
+
+ ret = __make_disabled_list((char *)file_path, pkgid);
+ if (ret < 0) {
+ _LOG("__make_disabled_list is failed. pkgid is [%s].\n", pkgid);
+ return -1;
+ }
+
+ ret = pkgmgr_parser_enable_pkg(pkgid, NULL);
+ if (ret < 0) {
+ _LOG("pkgmgr_parser_enable_pkg is failed. pkgid is [%s].\n", pkgid);
+ return -1;
+ }
+
+ _LOG("pkgid [%s] is enabled.\n", pkgid);
+
+ return ret;
+}
+
+static int __get_disabled_list_and_enable()
+{
+ int ret = 0;
+ char *file_path = PKG_DISABLED_LIST_FILE;
+ pkgmgrinfo_pkginfo_filter_h handle = NULL;
+
+ ret = pkgmgrinfo_pkginfo_filter_create(&handle);
+ if (ret < 0) {
+ _LOG("pkgmgrinfo_pkginfo_filter_create is failed.\n");
+ return -1;
+ }
+
+ ret = pkgmgrinfo_pkginfo_filter_add_bool(handle, PMINFO_PKGINFO_PROP_PACKAGE_DISABLE, 1);
+ if (ret < 0) {
+ _LOG("pkgmgrinfo_pkginfo_filter_add_bool is failed.\n");
+ free(handle);
+ return -1;
+ }
+
+ ret = pkgmgrinfo_pkginfo_filter_foreach_pkginfo(handle, __pkg_disabled_list_cb, (void*)file_path);
+ if (ret < 0) {
+ _LOG("pkgmgrinfo_pkginfo_filter_foreach_pkginfo is failed.\n");
+ }
+
+ free(handle);
+
+ return ret;
+}
+
+static int __disable_pkg()
+{
+ int ret = 0;
+ FILE *fp = NULL;
+ char *file_path = PKG_DISABLED_LIST_FILE;
+ char pkgid[BUF_SIZE] = {'\0',};
+
+ fp = fopen(file_path, "r");
+ if (fp == NULL) {
+ _LOG("fopen is failed.\n");
+ return -1;
+ }
+
+ while (fscanf(fp, "%s", pkgid) != EOF) {
+ ret = pkgmgr_parser_disable_pkg(pkgid, NULL);
+ if (ret < 0) {
+ _LOG("pkgmgr_parser_disable_pkg is failed. pkgid is [%s].\n", pkgid);
+ continue;
+ }
+ _LOG("pkgid [%s] is disabled.\n", pkgid);
+ }
+
+ if (fp != NULL)
+ fclose(fp);
+
+ return ret;
+}
+
+int main(int argc, char *argv[])
+{
+ int ret;
+ int rw_fota_enabled = 0;
+
+ long starttime;
+ long endtime;
+ struct timeval tv;
+
+ xmlInitParser();
+
+ gettimeofday(&tv, NULL);
+ starttime = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
+
+#ifdef _FOTA_INIT_DB
+ int is_readonly = 0;
+
+ /*clean pkgid list file, if it is exit*/
+ __remove_pkgid_list();
+
+ _LOG("=======================================================\n");
+ _LOG(" package manager fota\n");
+ _LOG("=======================================================\n");
+
+ __find_preload_pkgid_from_db(RW_PKGID_LIST_FILE, is_readonly);
+
+ (void)remove(PKGMGR_DB);
+
+ __get_uninstalled_pkgid_list_from_csc();
+
+ __initdb_load_directory(USR_MANIFEST_DIRECTORY);
+ __initdb_load_directory(OPT_MANIFEST_DIRECTORY);
+
+ __change_preload_attribute(RW_PKGID_LIST_FILE);
+
+ const char *argv_parser[] = { "/usr/bin/chsmack", "-a", PKG_INFO_DB_LABEL, PKGMGR_DB, NULL };
+ initdb_xsystem(argv_parser);
+ const char *argv_parserjn[] = { "/usr/bin/chsmack", "-a", PKG_INFO_DB_LABEL, PKGMGR_DB_JOURNAL, NULL };
+ initdb_xsystem(argv_parserjn);
+
+#else
+ /*clean pkgid list file, if it is exit*/
+ __remove_pkgid_list();
+
+ _LOG("=======================================================\n");
+ _LOG(" Get disabled list and enable\n");
+ _LOG("=======================================================\n");
+
+ ret = __get_disabled_list_and_enable();
+ if (ret < 0) {
+ _LOG("__get_disabled_list_and_enable is failed.\n");
+ }
+
+ _LOG("=======================================================\n");
+ _LOG(" RO preload package fota\n");
+ _LOG("=======================================================\n");
+
+ /*get pkgid from orginal pkgmgr db*/
+ __get_pkgid_list_from_db_and_xml();
+
+ /*get pkgid from csc applist*/
+ __get_pkgid_list_from_csc();
+
+ _LOG("Ready RO pkgid list for compare\n");
+
+ /*find deleted pkgid*/
+ ret = __find_deleted_pkgid_from_list(RO_PKGID_LIST_FILE, RO_FOTA_PKGID_LIST_FILE, rw_fota_enabled);
+ if (ret < 0) {
+ _LOG("__find_deleted_pkgid_from_list fail.\n");
+ }
+
+ /*find updated, inserted pkgid*/
+ ret = __find_matched_pkgid_from_list(RO_FOTA_PKGID_LIST_FILE, RO_PKGID_LIST_FILE, rw_fota_enabled);
+ if (ret < 0) {
+ _LOG("__find_matched_pkgid_from_list fail.\n");
+ }
+
+ _LOG("End RO pkgid list for compare\n");
+
+ if (access(FACTORYRESET_BACKUP_FILE, R_OK) == 0) {
+ _LOG("=======================================================\n");
+ _LOG(" RW preload package fota\n");
+ _LOG("=======================================================\n");
+
+ rw_fota_enabled = 1;
+
+ /*get pkgid from orginal pkgmgr db*/
+ __get_pkgid_list_from_db_and_zip();
+
+ if (access(RW_FOTA_PKGID_LIST_FILE, R_OK) != 0){
+ _LOG(" !!! Dont have preload downloaded package in /opt/usr/apps !!!\n\n");
+ goto end;
+ }
+
+ _LOG("Ready RW pkgid list for compare\n");
+
+ /*find updated, inserted pkgid*/
+ ret = __find_matched_pkgid_from_list(RW_FOTA_PKGID_LIST_FILE, RW_PKGID_LIST_FILE, rw_fota_enabled);
+ if (ret < 0) {
+ _LOG("__find_matched_pkgid_from_list fail.\n");
+ }
+
+ _LOG("End RW pkgid list for compare\n");
+ }
+
+ /*clean pkgid list file, if it is exit*/
+ // __remove_pkgid_list();
+
+ ret = pkgmgr_parser_insert_app_aliasid();
+ if(ret == -1){
+ _LOG("Insert for app-aliasID DB failed");
+ }
+
+end:
+#endif
+
+ _LOG("=======================================================\n");
+ _LOG(" disabled pkg list\n");
+ _LOG("=======================================================\n");
+
+ if (access(PKG_DISABLED_LIST_FILE, R_OK) == 0) {
+ ret = __disable_pkg();
+ if (ret < 0) {
+ _LOG("__disable_pkg is failed.\n");
+ }
+ } else {
+ _LOG("no package to disable.\n");
+ }
+
+ gettimeofday(&tv, NULL);
+ endtime = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
+
+ _LOG("=======================================================\n");
+ _LOG("\t\t End fota process[time : %d ms]\n", (int)(endtime - starttime));
+ _LOG("=======================================================\n");
+
+ xmlCleanupParser();
+ return 0;
+}
+
+
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#define _GNU_SOURCE
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <pkgmgr-info.h>
+#include <vconf.h>
+#include <dirent.h>
+#include <sys/stat.h>
+#include <sys/smack.h>
+#include <unistd.h>
+
+#include <sys/types.h>
+#include <fcntl.h>
+#include <dbus/dbus.h>
+
+#include "package-manager.h"
+#include "package-manager-debug.h"
+#include "pkgmgr_installer.h"
+#include "comm_config.h"
+#include "junk-manager.h"
+#include <sys/xattr.h>
+
+#include <sqlite3.h>
+#include <time.h>
+#include "pkg_magic.h"
+
+#undef LOG_TAG
+#ifndef LOG_TAG
+#define LOG_TAG "PKGMGR_JUNKINFO"
+#endif /* LOG_TAG */
+
+#define MAX_PATH_LENGTH 1024
+#define MAX_PROCESS_NAME 512
+#define MAX_QUERY_LEN 4096
+#define DB_UTIL_REGISTER_HOOK_METHOD 0x00000001
+
+
+#define QUERY_CREATE_TABLE_JUNK_ROOT "CREATE TABLE junk_root " \
+ "(root_name text, "\
+ "category integer, "\
+ "root_file_type integer, "\
+ "storage_type integer, "\
+ "junk_total_size integer, "\
+ "root_path text)"
+
+#define QUERY_CREATE_TABLE_JUNK_FILES "CREATE TABLE junk_file "\
+ "(root_name text, "\
+ "file_name text, "\
+ "file_type integer, "\
+ "storage_type integer, "\
+ "junk_file_size integer, "\
+ "file_path text)"
+
+const char *category_list[12] = {
+ "Images", "Sounds", "Videos", "Camera", "Downloads",
+ "Music", "Documents", "Others", "System", "DCIM", "MISC", NULL
+};
+
+const char INTERNAL_STORAGE_PATH[256] = "/opt/usr/media";
+const char EXTERNAL_STORAGE_PATH[256] = "/opt/storage/sdcard";
+
+typedef struct __junk_root_info_t{
+ char *root_name;
+ char *root_path;
+ int category;
+ int root_file_type;
+ int storage_type;
+ long long junk_total_size;
+} junk_root_info_t;
+
+typedef struct __junk_file_info_t{
+ char *file_path;
+ char *root_name;
+ char *file_name;
+ int file_type;
+ int storage_type;
+ long long junk_file_size;
+} junk_file_info_t;
+
+
+int storage_path_length;
+
+static void __print_usage()
+{
+ // TODO: print usage
+ exit(0);
+}
+
+static void __send_signal(int argc, char *argv[], const char *pid_str, const char *key, const char *value)
+{
+ LOGD("Enter");
+ pkgmgr_installer *pi = pkgmgr_installer_new();
+ if (pi == NULL) {
+ _LOGE("Failed to create the pkgmgr_installer instance.");
+ return;
+ }
+ pkgmgr_installer_receive_request(pi, argc, argv);
+ pkgmgr_installer_send_signal(pi, PKGMGR_INSTALLER_GET_JUNK_INFO_KEY_STR, pid_str, key, value);
+ pkgmgr_installer_free(pi);
+}
+
+static int __db_open(const char *db_file_path, sqlite3 **ppDB, int option)
+{
+ if ((db_file_path == NULL) || (ppDB == NULL))
+ {
+ LOGE("%s Invalid input param error", __func__);
+ return -1;
+ }
+
+ if ((geteuid() != 0) && (access(db_file_path, R_OK)))
+ {
+ if (errno == EACCES)
+ {
+ LOGE("%s file access permission error", __func__);
+ return -1;
+ }
+ }
+
+ int res = sqlite3_open(db_file_path, ppDB);
+ if (SQLITE_OK != res)
+ {
+ LOGE("%s sqlite3_open() failed.(%d)", __func__, res);
+ return res;
+ }
+
+ return res;
+}
+
+static int __exec_query(const sqlite3 *db, char *query)
+{
+ char *error_message = NULL;
+ if (SQLITE_OK !=
+ sqlite3_exec((sqlite3 *)db, query, NULL, NULL, &error_message))
+ {
+ LOGE("Don't execute query = %s error message = %s", query, error_message);
+ sqlite3_free(error_message);
+ return -1;
+ }
+ sqlite3_free(error_message);
+ return 0;
+}
+
+static int __category_name_to_category_number(const char *category)
+{
+ int i = 0;
+ for (i=0; category_list[i]; i++)
+ {
+ if (strncmp(category, category_list[i], 3) == 0)
+ {
+ return i;
+ }
+ }
+ return 10;
+}
+
+static int __insert_junk_to_junk_root_info_db(const sqlite3 *db, junk_root_info_t *junk_root_info)
+{
+ int res = 0;
+ char *query = NULL;
+ sqlite3_stmt *db_stmt = NULL;
+
+ query = sqlite3_mprintf("SELECT junk_total_size, root_path FROM junk_root WHERE root_path='%q'", junk_root_info->root_path);
+ if (query == NULL)
+ {
+ LOGE("unable to allocate enough memory to hold the resulting string");
+ return -1;
+ }
+
+ res = sqlite3_prepare_v2((sqlite3 *)db, query, strlen(query), &db_stmt, NULL);
+ if (SQLITE_OK != res)
+ {
+ LOGE("sqlite prepare error, res: %d (%s)", res, sqlite3_errmsg((sqlite3 *)db));
+ return -1;
+ }
+ sqlite3_free(query);
+
+ res = sqlite3_step(db_stmt);
+ if (SQLITE_ROW == res)
+ {
+ // update junk_info in junk_root table.
+ long long junk_total_size = 0;
+
+ junk_total_size = sqlite3_column_int64(db_stmt, 0);
+ junk_total_size += junk_root_info->junk_total_size;
+
+ query = sqlite3_mprintf("UPDATE junk_root SET junk_total_size = %lld WHERE root_path='%s'", junk_total_size, junk_root_info->root_path);
+ if (query == NULL)
+ {
+ LOGE("unable to allocate enough memory to hold the resulting string");
+ return -1;
+ }
+ }
+ else if (SQLITE_DONE == res)
+ {
+ // insert junk_info to junk_root table.
+ query = sqlite3_mprintf("INSERT INTO junk_root VALUES('%q', %d, %d, %d, %lld, '%q')",
+ junk_root_info->root_name,
+ junk_root_info->category,
+ junk_root_info->root_file_type,
+ junk_root_info->storage_type,
+ junk_root_info->junk_total_size,
+ junk_root_info->root_path
+ );
+ if (query == NULL)
+ {
+ LOGE("unable to allocate enough memory to hold the resulting string");
+ return -1;
+ }
+ }
+ else
+ {
+ LOGE("sqlite step error, res: %d (%s)", res, sqlite3_errmsg((sqlite3 *)db));
+ return -1;
+ }
+
+ res = __exec_query(db, query);
+ if (res < 0)
+ {
+ LOGE("%s __exec_query() failed.(%d)", __func__, res);
+ return -1;
+ }
+
+ if (query)
+ sqlite3_free(query);
+
+ if (db_stmt)
+ sqlite3_finalize(db_stmt);
+
+ return 0;
+}
+
+static int __insert_junk_to_junk_files_info_db(const sqlite3 *db, junk_file_info_t *junk_file_info)
+{
+ int res = 0;
+ char query[MAX_QUERY_LEN] = {0,};
+ snprintf(query, MAX_QUERY_LEN,
+ "insert into junk_file " \
+ "values('%s', '%s', %d, %d, %lld, '%s')",
+ junk_file_info->root_name,
+ junk_file_info->file_name,
+ junk_file_info->file_type,
+ junk_file_info->storage_type,
+ junk_file_info->junk_file_size,
+ junk_file_info->file_path
+ );
+
+ res = __exec_query(db, query);
+ if (res < 0)
+ {
+ LOGE("%s __exec_query() failed.(%d)", __func__, res);
+ return -1;
+ }
+
+ return 0;
+}
+
+
+static long long __stat_size(struct stat *s)
+{
+ long long blksize = s->st_blksize;
+ long long size = s->st_blocks * 512;
+
+ if (blksize)
+ {
+ size = (size + blksize - 1) & (~(blksize - 1));
+ }
+
+ return size;
+}
+
+static int __get_category_number(const char *file_path)
+{
+ char *category_name = NULL;
+ category_name = (char*)file_path + storage_path_length + 1;
+
+ return __category_name_to_category_number(category_name);
+}
+
+static bool __is_junk_file(const char *file_path)
+{
+ int category_number = 0;
+ int mime_number = 0;
+ bool ret = false;
+
+ category_number = __get_category_number(file_path);
+ mime_number = get_mime_type(file_path);
+
+
+ switch(category_number)
+ {
+ case JUNKMGR_CATEGORY_IMAGES:
+ if (mime_number != _MIME_IMAGE)
+ {
+ ret = true;
+ }
+ break;
+
+ case JUNKMGR_CATEGORY_SOUNDS:
+ if (mime_number != _MIME_AUDIO)
+ {
+ ret = true;
+ }
+ break;
+
+ case JUNKMGR_CATEGORY_VIDEOS:
+ if (mime_number != _MIME_VIDEO)
+ {
+ ret = true;
+ }
+ break;
+
+ case JUNKMGR_CATEGORY_CAMERA:
+ if ((mime_number != _MIME_IMAGE) && (mime_number != _MIME_VIDEO))
+ {
+ ret = true;
+ }
+ break;
+
+ case JUNKMGR_CATEGORY_DOWNLOADS:
+ if ((mime_number != _MIME_AUDIO) && (mime_number != _MIME_IMAGE) && (mime_number != _MIME_VIDEO))
+ {
+ ret = true;
+ }
+ break;
+
+ case JUNKMGR_CATEGORY_MUSIC:
+ if (mime_number != _MIME_AUDIO)
+ {
+ ret = true;
+ }
+ break;
+
+ case JUNKMGR_CATEGORY_DOCUMENTS:
+ if ((mime_number != _MIME_APPLICATION) && (mime_number != _MIME_TEXT))
+ {
+ ret = true;
+ }
+ break;
+
+ case JUNKMGR_CATEGORY_OTHERS:
+ ret = true;
+ break;
+
+ case JUNKMGR_CATEGORY_SYSTEM_RINGTONES:
+ if (mime_number != _MIME_AUDIO)
+ {
+ ret = true;
+ }
+ break;
+
+ case JUNKMGR_CATEGORY_DCIM:
+ if ((mime_number != _MIME_IMAGE) && (mime_number != _MIME_VIDEO))
+ {
+ ret = true;
+ }
+ break;
+
+ case JUNKMGR_CATEGORY_MISC:
+ ret = false;
+ break;
+ }
+ if (ret)
+ SECURE_LOGI("file_path:%s category_number:%d mime_number:%d", file_path, category_number, mime_number);
+
+ return ret;
+}
+
+static char * __get_root_path(junkmgr_storage_type_e storage_type, const char *file_path)
+{
+ char *temp = NULL;
+ char *root_name = NULL;
+ char *category_name = NULL;
+ char *ptr = NULL;
+ int i = 0;
+
+ temp = strdup(file_path + storage_path_length + 1);
+ if (temp == NULL) {
+ LOGE("temp is NULL");
+ return NULL;
+ }
+
+ ptr = strtok(temp, "/");
+
+ while (ptr != NULL)
+ {
+ if (i == 0)
+ {
+ category_name = strdup(temp);
+ }
+ else if (i == 1)
+ {
+ root_name = strdup(ptr);
+ }
+ else
+ {
+ break;
+ }
+ i++;
+ ptr = strtok(NULL, "/");
+ }
+
+ if (category_name == NULL)
+ {
+ LOGI("category is null. file_path is %s", file_path);
+ free(temp);
+ return NULL;
+ }
+
+ char root_path[MAX_PATH_LENGTH] = {0,};
+ if (root_name == NULL)
+ {
+ if (storage_type == JUNKMGR_STORAGE_TYPE_INTERNAL)
+ {
+ sprintf(root_path, "%s/%s", INTERNAL_STORAGE_PATH, category_name);
+ }
+ else
+ {
+ sprintf(root_path, "%s/%s", EXTERNAL_STORAGE_PATH, category_name);
+ }
+ }
+ else
+ {
+ if (storage_type == JUNKMGR_STORAGE_TYPE_INTERNAL)
+ {
+ sprintf(root_path, "%s/%s/%s", INTERNAL_STORAGE_PATH, category_name, root_name);
+ }
+ else
+ {
+ sprintf(root_path, "%s/%s/%s", EXTERNAL_STORAGE_PATH, category_name, root_name);
+ }
+ }
+
+ free(temp);
+ free(root_name);
+ free(category_name);
+
+ return strdup(root_path);
+}
+
+static char * __search_root_name(const char *file_path)
+{
+ char *temp = NULL;
+ char *root_name = NULL;
+ char *category_name = NULL;
+ char *ptr = NULL;
+ int i = 0;
+
+ temp = strdup(file_path + storage_path_length + 1);
+ if (temp == NULL)
+ {
+ LOGE("temp is NULL");
+ return NULL;
+ }
+
+ ptr = strtok(temp, "/");
+
+ while (ptr != NULL)
+ {
+ if (i == 0)
+ {
+ category_name = strdup(temp);
+ }
+ else if (i == 1)
+ {
+ root_name = strdup(ptr);
+ }
+ else
+ {
+ break;
+ }
+ i++;
+ ptr = strtok(NULL, "/");
+ }
+
+ if (category_name == NULL)
+ {
+ LOGI("category is null. file_path is %s", file_path);
+ free(temp);
+ return NULL;
+ }
+ if (root_name == NULL)
+ {
+ root_name = strdup(category_name);
+ }
+
+ LOGI("category: %s, root_name: %s", category_name, root_name);
+
+ free(category_name);
+ free(temp);
+
+ return root_name;
+}
+
+static int __search_junk_file(const sqlite3 *db, const char *path, int depth, junkmgr_storage_type_e storage_type)
+{
+ bool exist_junk = false;
+ long long junk_size = 0;
+
+ depth++;
+
+ if (depth == 1)
+ {
+ storage_path_length = strlen(path);
+ }
+
+ DIR *dir = opendir(path);
+ if (dir == NULL)
+ {
+ LOGE("opendir() failed. path: %s, errno: %d (%s)", dir, errno, strerror(errno));
+ return -1;
+ }
+
+ int dfd = dirfd(dir);
+
+ struct stat st;
+ int res = fstat(dfd, &st);
+ if (res < 0)
+ {
+ LOGE("fstat() failed. path: %s, errno: %d (%s)", dir, errno, strerror(errno));
+ if (dir)
+ closedir(dir);
+ return -1;
+ }
+
+ struct dirent *dent = NULL;
+ while ((dent = readdir(dir)))
+ {
+ const char *entry = dent->d_name;
+ if (entry[0] == '.')
+ {
+ continue;
+ }
+
+ if (dent->d_type == DT_DIR)
+ {
+ char sub_dir_path[MAX_PATH_LENGTH];
+ long long junk_dir_size = 0;
+ snprintf(sub_dir_path, MAX_PATH_LENGTH, "%s/%s", path, entry);
+ junk_dir_size = __search_junk_file(db, sub_dir_path, depth, storage_type);
+ if (junk_dir_size > 0)
+ {
+ int category_number = 0;
+ char *category_name = NULL;
+ char *temp = NULL;
+ char *root_path = NULL;
+ char *root_name = NULL;
+
+ root_path = __get_root_path(storage_type, sub_dir_path);
+ if (root_path == NULL)
+ continue;
+
+ root_name = __search_root_name(sub_dir_path);
+ if (root_name == NULL) {
+ free(root_path);
+ continue;
+ }
+
+ temp = sub_dir_path + storage_path_length + 1;
+ category_name = strdup(temp);
+ if (category_name == NULL) {
+ free(root_name);
+ free(root_path);
+ continue;
+ }
+
+ category_number = __category_name_to_category_number(category_name);
+
+ if (category_number == 10)
+ {
+ free(category_name);
+ free(root_name);
+ free(root_path);
+ continue;
+ }
+
+ junk_root_info_t junk_root_info;
+ junk_root_info.root_name = strdup(root_name);
+ junk_root_info.root_path = strdup(root_path);
+ junk_root_info.category = category_number;
+ junk_root_info.root_file_type = 1;
+ junk_root_info.storage_type = storage_type;
+ junk_root_info.junk_total_size = junk_dir_size;
+
+ SECURE_LOGD("junk_root root_name(%s) root_path(%s) category(%d) root_file_type(%d) storage_type(%d) total_size(%lld)",
+ junk_root_info.root_name, junk_root_info.root_path, junk_root_info.category,
+ junk_root_info.root_file_type, junk_root_info.storage_type, junk_root_info.junk_total_size);
+
+ __insert_junk_to_junk_root_info_db(db, &junk_root_info);
+
+ exist_junk = true;
+
+ free(category_name);
+ free(root_name);
+ free(root_path);
+ free(junk_root_info.root_name);
+ free(junk_root_info.root_path);
+ }
+ }
+ else
+ {
+ int res = fstatat(dfd, entry, &st, AT_SYMLINK_NOFOLLOW);
+ if (res < 0)
+ {
+ LOGE("fstatat() failed. path: %s, errno: %d (%s)", dir, errno, strerror(errno));
+ if (dir)
+ {
+ closedir(dir);
+ }
+ return -1;
+ }
+
+ char junk_file_path[MAX_PATH_LENGTH];
+ char *root_name = NULL;
+ snprintf(junk_file_path, MAX_PATH_LENGTH, "%s/%s", path, entry);
+
+ long long size = 0;
+ size = __stat_size(&st);
+
+ if ((size < 8192) || (__is_junk_file(junk_file_path)))
+ {
+ if (depth == 1)
+ {
+ root_name = strdup(entry);
+ if (root_name == NULL)
+ continue;;
+
+ junk_root_info_t junk_root_info = {0,};
+ junk_root_info.root_name = strdup(root_name);
+ junk_root_info.root_path = strdup(junk_file_path);
+ junk_root_info.category = 10;
+ junk_root_info.root_file_type = 0;
+ junk_root_info.storage_type = storage_type;
+ junk_root_info.junk_total_size = size;
+
+ SECURE_LOGD("junk_root root_name(%s) root_path(%s) category(%d) root_file_type(%d) storage_type(%d) total_size(%lld)",
+ junk_root_info.root_name, junk_root_info.root_path, junk_root_info.category,
+ junk_root_info.root_file_type, junk_root_info.storage_type, junk_root_info.junk_total_size);
+
+ __insert_junk_to_junk_root_info_db(db, &junk_root_info);
+
+ free(junk_root_info.root_name);
+ free(junk_root_info.root_path);
+ }
+ else
+ {
+ root_name = __search_root_name(path);
+ if (root_name == NULL)
+ continue;
+ }
+
+ junk_file_info_t junk_file = {0,};
+ junk_file.root_name = strdup(root_name);
+ junk_file.file_name = strdup(entry);
+ junk_file.file_type = 0;
+ junk_file.storage_type = storage_type;
+ junk_file.junk_file_size = size;
+ junk_file.file_path = strdup(junk_file_path);
+
+ SECURE_LOGD("junk_file root_name(%s) file_name(%s) file_type(%d) storage_type(%d) total_size(%lld) file_path(%s)",
+ junk_file.root_name, junk_file.file_name, junk_file.file_type,
+ junk_file.storage_type, junk_file.junk_file_size, junk_file.file_path);
+
+ junk_size += size;
+ __insert_junk_to_junk_files_info_db(db, &junk_file);
+
+ exist_junk = true;
+
+ free(root_name);
+ free(junk_file.root_name);
+ free(junk_file.file_name);
+ free(junk_file.file_path);
+ }
+ }
+ }
+ closedir(dir);
+
+ if (exist_junk)
+ return junk_size;
+ return 0;
+}
+
+
+static bool __is_exist_process_at_process_list(int pid)
+{
+ char name[MAX_PROCESS_NAME] = {0,};
+
+ sprintf(name, "/proc/%d/cmdline", pid);
+ FILE* fp = fopen(name, "r");
+ if (!fp)
+ {
+ LOGE("%s fopen() failed. ENOPROC", __func__);
+ return false;
+ }
+
+ fclose(fp);
+ return true;
+}
+
+static bool __is_exist_junk_cache_file(const char *file_path)
+{
+ int res = access(file_path, F_OK);
+ if (res < 0)
+ {
+ switch (errno)
+ {
+ case ENOENT:
+ SECURE_LOGI("%s access() failed. file is not existed.(%s)", __func__, file_path);
+ return false;
+
+ default:
+ LOGE("%s access() failed. path: %s, errno: %d (%s)",__func__, file_path, errno, strerror(errno));
+ break;
+ }
+ }
+ return true;
+}
+
+static bool __is_valid_junk_cache_file(const char *file_path)
+{
+ struct stat st = {0,};
+ int res = stat(file_path, &st);
+ if (res < 0)
+ {
+ LOGI("stat() failed. path: %s, errno: %d (%s)", file_path, errno, strerror(errno));
+ return -1;
+ }
+
+ time_t current_time = time(NULL);
+ if (current_time == ((time_t)-1))
+ {
+ LOGD("time() failed. path: %s, errno: %d (%s)", file_path, errno, strerror(errno));
+ }
+
+ double diff = difftime(current_time, st.st_mtime);
+ LOGD("st_mtime: %d, current_time: %d, diff: %lf", st.st_mtime, current_time, diff);
+ if (diff > (60 * 5))
+ {
+ LOGI("OLD FILE!! DELETE!!");
+ return false;
+ }
+
+ LOGI("GOOD FILE!! PASS!!");
+ return true;
+}
+
+static int __set_smack_label_access(const char *file_path, const char *label)
+{
+ int res = smack_lsetlabel(file_path, label, SMACK_LABEL_ACCESS);
+ if (res != 0)
+ {
+ LOGE("smack set label(%s) failed[%d] (path:[%s]))", label, res, file_path);
+ }
+ return res;
+}
+
+static bool is_need_junk_cache_file(const char *file_path)
+{
+ int res = 0;
+ bool ret = false;
+
+ if (__is_exist_junk_cache_file(file_path))
+ {
+ if (__is_exist_process_at_process_list(atoi(file_path)))
+ {
+ if (!__is_valid_junk_cache_file(file_path))
+ {
+ res = remove(file_path);
+ if (res < 0)
+ {
+ LOGE("%s remove() failed. path: %s, errno: %d (%s)", file_path, errno, strerror(errno));
+ return -1;
+ }
+ ret = true;
+ }
+ }
+ else
+ {
+ res = remove(file_path);
+ if (res < 0)
+ {
+ LOGE("%s remove() failed. path: %s, errno: %d (%s)", file_path, errno, strerror(errno));
+ return -1;
+ }
+ ret = true;
+ }
+ }
+ else
+ {
+ ret = true;
+ }
+
+ return ret;
+}
+
+int create_junk_cache_file(const sqlite3 *db)
+{
+ int res = __search_junk_file(db, INTERNAL_STORAGE_PATH, 0, JUNKMGR_STORAGE_TYPE_INTERNAL);
+ if (res < 0)
+ {
+ LOGE("%s __serch_junk_file() failed.(%d)", __func__, res);
+ return -1;
+ }
+
+ res = __search_junk_file(db, EXTERNAL_STORAGE_PATH, 0, JUNKMGR_STORAGE_TYPE_EXTERNAL);
+ if (res < 0)
+ {
+ LOGE("%s __serch_junk_file() failed.(%d)", __func__, res);
+ return -1;
+ }
+
+ return 0;
+}
+
+int clear_all_junk_files(const sqlite3 *db, const char *junk_db_path)
+{
+ int res = 0;
+ int ret = 0;
+ char query[512] = "SELECT file_path FROM junk_file";
+ sqlite3_stmt *db_stmt = NULL;
+
+ res = sqlite3_prepare_v2((sqlite3 *)db, query, strlen(query), &db_stmt, NULL);
+ if (SQLITE_OK != res)
+ {
+ LOGE("sqlite prepare error, res: %d (%s)", res, sqlite3_errmsg((sqlite3 *)db));
+ return -1;
+ }
+
+ res = sqlite3_step(db_stmt);
+ if (SQLITE_DONE == res)
+ {
+ LOGI("Not exist junk file");
+ if (db_stmt)
+ sqlite3_finalize(db_stmt);
+ }
+ else if (SQLITE_ROW == res)
+ {
+ // delete junk file.
+ char *junk_path = NULL;
+ while(SQLITE_ROW == res)
+ {
+ junk_path = (char*)sqlite3_column_text(db_stmt, 0);
+ ret = remove(junk_path);
+ if (ret < 0)
+ {
+ LOGE("remove() failed. path: %s, errno %d (%s)", junk_path, errno, strerror(errno));
+ free(junk_path);
+ if (db_stmt)
+ sqlite3_finalize(db_stmt);
+
+ return ret;
+ }
+ SECURE_LOGI("Delete junk file :%s", junk_path);
+ res = sqlite3_step(db_stmt);
+ }
+
+ if (db_stmt)
+ sqlite3_finalize(db_stmt);
+
+ // delete junk db file.
+ ret = remove(junk_db_path);
+ if (ret < 0)
+ {
+ LOGE("remove() failed. path: %s, errno %d (%s)", junk_db_path, errno, strerror(errno));
+ return ret;
+ }
+ }
+ else
+ {
+ LOGE("sqlite3_step() error, res: %d (%s)", res, sqlite3_errmsg((sqlite3 *)db));
+ return -1;
+ }
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ LOGD("Enter");
+
+ int c = 0;
+ char req_str[256] = {0,};
+ char pid_str[7] = {0,};
+ char junk_req_type[4] = { 0, };
+ char junk_storage[4] = { 0, };
+ char junk_path[PATH_MAX] = { 0, };
+
+ while (1) {
+ c = getopt(argc, argv, "p:k:t:w:j:");
+ if (c == -1)
+ break; /* Parse end */
+ switch (c) {
+ case 'p':
+ if (optarg) strncpy(pid_str, optarg, sizeof(pid_str));
+ break;
+ case 'k':
+ if (optarg) strncpy(req_str, optarg, sizeof(req_str));
+ break;
+ case 't':
+ if (optarg) strncpy(junk_req_type, optarg, sizeof(junk_req_type));
+ break;
+ case 'w':
+ if (optarg) strncpy(junk_storage, optarg, sizeof(junk_storage));
+ break;
+ case 'j':
+ if (optarg) strncpy(junk_path, optarg, sizeof(junk_path));
+ break;
+ case '?':
+ __print_usage();
+ break;
+ default:
+ break;
+ }
+ }
+
+ int res = 0;
+
+ char *junk_db_path = (char *)calloc(1, MAX_PATH_LENGTH);
+ if (junk_db_path == NULL)
+ {
+ LOGE("out of memory");
+ return -1;
+ }
+
+ sprintf(junk_db_path, "/tmp/.cache%s.db", pid_str);
+
+ char *junk_db_journal_path = (char *)malloc(PATH_MAX);
+ if (junk_db_journal_path == NULL)
+ {
+ LOGE("out of memory");
+ free(junk_db_path);
+ return -1;
+ }
+
+ strncpy(junk_db_journal_path, junk_db_path, PATH_MAX - 1);
+ strcat(junk_db_journal_path , "-journal");
+
+ if (atoi(junk_req_type) == 2)
+ {
+ sqlite3 *junk_db;
+
+ res = __db_open(junk_db_path, &junk_db, DB_UTIL_REGISTER_HOOK_METHOD);
+ if (res < 0)
+ {
+ LOGE("%s __db_open() failed.(%d)", __func__, res);
+ return -1;
+ }
+
+ res = clear_all_junk_files(junk_db, junk_db_path);
+ if (res < 0)
+ {
+ LOGE("%s clear_all_junk_files() failed.(%d)", __func__, res);
+ free(junk_db_journal_path);
+ sqlite3_close(junk_db);
+ return -1;
+ }
+
+ if (junk_db)
+ {
+ sqlite3_close(junk_db);
+ }
+ free(junk_db_journal_path);
+
+ SECURE_LOGI("return db path: %s", junk_db_path);
+ __send_signal(argc, argv, pid_str, "dbpath", junk_db_path);
+ return 0;
+ }
+
+ if (is_need_junk_cache_file(junk_db_path))
+ {
+ sqlite3 *junk_db;
+
+ res = __db_open(junk_db_path, &junk_db, DB_UTIL_REGISTER_HOOK_METHOD);
+ if (res < 0)
+ {
+ LOGE("%s __db_open() failed.(%d)", __func__, res);
+ return -1;
+ }
+
+ res = __exec_query(junk_db, QUERY_CREATE_TABLE_JUNK_ROOT);
+ if (res < 0)
+ {
+ LOGE("%s __exec_query() failed.(%d)", __func__, res);
+ sqlite3_close(junk_db);
+ return -1;
+ }
+ __exec_query(junk_db, QUERY_CREATE_TABLE_JUNK_FILES);
+ if (res < 0)
+ {
+ LOGE("%s __exec_query() failed.(%d)", __func__, res);
+ sqlite3_close(junk_db);
+ return -1;
+ }
+
+ res = create_junk_cache_file(junk_db);
+ if (res < 0)
+ {
+ LOGE("%s create_junk_cache_file() failed.(%d)", __func__, res);
+ sqlite3_close(junk_db);
+ return -1;
+ }
+ if (junk_db)
+ {
+ sqlite3_close(junk_db);
+ }
+
+ res = chmod(junk_db_path, 0644);
+ if (res < 0)
+ {
+ LOGE("chmod() failed. path: %s, errno: %d (%s)", junk_db_path, errno, strerror(errno));
+ return -1;
+ }
+
+ res = chmod(junk_db_journal_path, 0644);
+ if (res < 0)
+ {
+ LOGE("chmod() failed. path: %s, errno: %d (%s)", junk_db_journal_path, errno, strerror(errno));
+ return -1;
+ }
+
+ res = chown(junk_db_path, 5000, 5000);
+ if (res < 0)
+ {
+ LOGE("chown() failed. path: %s, errno: %d (%s)", junk_db_path, errno, strerror(errno));
+ return -1;
+ }
+
+ res = chown(junk_db_journal_path, 5000, 5000);
+ if (res < 0)
+ {
+ LOGE("chown() failed. path: %s, errno: %d (%s)", junk_db_journal_path, errno, strerror(errno));
+ return -1;
+ }
+
+ res = __set_smack_label_access(junk_db_path, "junkmgr::db");
+ if (res < 0)
+ {
+ LOGE("%s __set_smack_label_access() failed.(%d)", __func__, res);
+ return -1;
+ }
+
+ res = __set_smack_label_access(junk_db_journal_path, "junkmgr::db");
+ if (res < 0)
+ {
+ LOGE("%s __set_smack_label_access() failed.(%d)", __func__, res);
+ return -1;
+ }
+ }
+
+ free(junk_db_journal_path);
+
+ SECURE_LOGI("return db path: %s", junk_db_path);
+ __send_signal(argc, argv, pid_str, "dbpath", junk_db_path);
+ return 0;
+}
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#define _GNU_SOURCE
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <pkgmgr-info.h>
+#include <vconf.h>
+#include <dirent.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include <sys/types.h>
+#include <fcntl.h>
+#include <dbus/dbus.h>
+
+#include "package-manager.h"
+#include "package-manager-debug.h"
+#include "pkgmgr_installer.h"
+#include "comm_config.h"
+
+
+#undef LOG_TAG
+#ifndef LOG_TAG
+#define LOG_TAG "PKGMGR_GETSIZE"
+#endif /* LOG_TAG */
+
+#define MAX_PKG_INFO_LEN 10
+#define MAX_PKG_BUF_LEN 1024
+#define BLOCK_SIZE 4096 /*in bytes*/
+
+#define PKG_RW_PATH "/opt/usr/apps/"
+#define MAX_PATH_LENGTH 512
+#define MAX_LONGLONG_LENGTH 32
+#define MAX_SIZE_INFO_SIZE 128
+
+const char* directory_list[4][10] = {
+ { "bin", "info", "res", "info", "data", "shared", "setting", "lib", NULL },
+ { "bin", "info", "res", "info", "shared", "setting", "lib", NULL },
+ { "data", NULL },
+ {NULL},
+};
+
+void __getsize_send_signal(const char *req_id, const char *pkg_type, const char *pkgid, const char *key, const char *val);
+
+long long __stat_size(struct stat *s)
+{
+ long long blksize = s->st_blksize;
+ long long size = s->st_blocks * 512;
+
+ if (blksize) {
+ size = (size + blksize - 1) & (~(blksize - 1));
+ }
+
+ return size;
+}
+
+long long __calculate_dir_size(int dfd, int depth, int type)
+{
+ long long size = 0;
+ struct stat s;
+ DIR *d = NULL;
+ struct dirent *de = NULL;
+ int i = 0;
+
+ ++depth;
+
+ d = fdopendir(dfd);
+ if (d == NULL) {
+ close(dfd);
+ return 0;
+ }
+
+ while ((de = readdir(d))) {
+ int skip = 0;
+ const char *name = de->d_name;
+ if (name[0] == '.') {
+ if (name[1] == 0)
+ continue;
+ if ((name[1] == '.') && (name[2] == 0))
+ continue;
+ }
+
+ if (depth == 1 && de->d_type == DT_DIR) {
+ for (i = 0; directory_list[type][i]; i++) {
+ if (strcmp(name, directory_list[type][i]) == 0) {
+ skip = -1;
+ break;
+ }
+ }
+
+ if (skip == 0)
+ continue;
+ }
+
+ if (fstatat(dfd, name, &s, AT_SYMLINK_NOFOLLOW) == 0) {
+ size += __stat_size(&s);
+ }
+
+ if (de->d_type == DT_DIR) {
+ int subfd = openat(dfd, name, O_RDONLY | O_DIRECTORY);
+ if (subfd >= 0) {
+ size += __calculate_dir_size(subfd, depth, type);
+ }
+ close(subfd);
+ }
+ }
+
+ closedir(d);
+ return size;
+}
+
+int __set_attr_info_file()
+{
+ const char* app_info_label = "*";
+
+ if(lsetxattr(PKG_SIZE_INFO_FILE, "security.SMACK64", app_info_label, strlen(app_info_label), 0)) {
+ _LOGE("error(%d) in setting smack label",errno);
+ return -1;
+ }
+
+ return 0;
+}
+
+void __make_sizeinfo_file(char *package_size_info)
+{
+ FILE* file = NULL;
+ int fd = 0;
+
+ if(package_size_info == NULL)
+ return;
+
+ file = fopen(PKG_SIZE_INFO_FILE, "w");
+ if (file == NULL) {
+ _LOGE("Couldn't open the file %s \n", PKG_SIZE_INFO_FILE);
+ return;
+ }
+
+ fwrite(package_size_info, 1, strlen(package_size_info), file);
+ fflush(file);
+ fd = fileno(file);
+ fsync(fd);
+ fclose(file);
+
+ if (__set_attr_info_file() < 0)
+ _LOGE("Fail set label file %s \n", PKG_SIZE_INFO_FILE);
+}
+
+int __get_size_info(char *pkgid, int *pkg_data_size, int *pkg_total_size)
+{
+ DIR *dir = NULL;
+ int dfd = 0;
+ struct stat f_stat;
+ struct dirent *de = NULL;
+
+ dir = opendir(PKG_RW_PATH);
+ if (dir == NULL) {
+ _LOGE("Couldn't open the directory %s \n", PKG_RW_PATH);
+ return -1;
+ }
+
+ while ((de = readdir(dir)))
+ {
+ int total_size = 0;
+ int others_size = 0;
+ int data_size = 0;
+
+ const char *name = de->d_name;
+ if (name[0] == '.') {
+ if (name[1] == 0)
+ continue;
+ if ((name[1] == '.') && (name[2] == 0))
+ continue;
+ }
+
+ if (strcmp(name, pkgid) != 0){
+ continue;
+ }
+
+ dfd = dirfd(dir);
+ if (de->d_type == DT_DIR) {
+ int subfd = 0;
+
+ subfd = openat(dfd, name, O_RDONLY | O_DIRECTORY);
+ if (subfd >= 0) {
+ if (fstat(subfd, &f_stat) == 0) // pkgid
+ {
+ others_size += __stat_size(&f_stat);
+ }
+ others_size += __calculate_dir_size(subfd, 0, 1);
+ }
+ subfd = openat(dfd, name, O_RDONLY | O_DIRECTORY);
+ if (subfd >= 0) {
+ int datafd = 0;
+ datafd = openat(subfd, "data", O_RDONLY | O_DIRECTORY);
+ if (datafd >= 0) {
+ if (fstat(datafd, &f_stat) == 0) // data
+ {
+ others_size += __stat_size(&f_stat);
+ }
+ data_size = __calculate_dir_size(datafd, 1, 2);
+ }
+ }
+ }
+
+ total_size = others_size + data_size;
+ *pkg_total_size = total_size;
+ *pkg_data_size = data_size;
+ }
+ closedir(dir);
+ return 0;
+}
+
+typedef enum
+{
+ STORAGE_TYPE_INTERNAL,
+ STORAGE_TYPE_EXTERNAL,
+ STORAGE_TYPE_MAX = 255,
+} STORAGE_TYPE;
+
+#define APP_BASE_INTERNAL_PATH "/opt/usr/apps/"
+#define APP_BASE_EXTERNAL_PATH "/opt/storage/sdcard/apps/"
+
+static long long __calculate_directory_size(int dfd, bool include_itself)
+{
+ long long size = 0;
+ struct stat st;
+ int subfd = -1;
+ int res = 0;
+
+ if (include_itself)
+ {
+ res = fstat(dfd, &st);
+ if (res < 0)
+ {
+ _LOGE("fstat() failed, entry: ., errno: %d (%s)", errno, strerror(errno));
+ return -1;
+ }
+ size += __stat_size(&st);
+ }
+
+ DIR *dir = fdopendir(dfd);
+ if (dir == NULL) {
+ _LOGE("fdopendir() failed, errno: %d (%s)", errno, strerror(errno));
+ return -1;
+ }
+
+ struct dirent *dent = NULL;
+ while ((dent = readdir(dir)))
+ {
+ const char *entry = dent->d_name;
+ if (entry[0] == '.')
+ {
+ if (entry[1] == '\0')
+ {
+ continue;
+ }
+ if ((entry[1] == '.') && (entry[2] == '\0'))
+ {
+ continue;
+ }
+ }
+
+ if (dent->d_type == DT_DIR)
+ {
+ subfd = openat(dfd, entry, O_RDONLY | O_DIRECTORY);
+ if (subfd < 0)
+ {
+ _LOGE("openat() failed, entry: %s, errno: %d (%s)", entry, errno, strerror(errno));
+ goto error;
+ }
+
+ _LOGS("traverse entry: %s", entry);
+ size += __calculate_directory_size(subfd, true);
+ close(subfd);
+ }
+ else
+ {
+ res = fstatat(dfd, entry, &st, AT_SYMLINK_NOFOLLOW);
+ if (res < 0)
+ {
+ _LOGE("fstatat() failed, entry: %s, errno: %d (%s)",entry, errno, strerror(errno));
+ goto error;
+ }
+ size += __stat_size(&st);
+ }
+ }
+
+ return size;
+
+error:
+
+ return -1;
+}
+
+static long long __calculate_shared_dir_size(int dfd, const char *app_root_dir, long long *data_size, long long *app_size)
+{
+ int fd = -1;
+ int subfd = -1;
+ long long size = 0;
+
+ _LOGS("traverse path: %sshared", app_root_dir);
+
+ fd = openat(dfd, "shared", O_RDONLY | O_DIRECTORY);
+ if (fd < 0)
+ {
+ _LOGE("openat() failed, path: %sshared, errno: %d (%s)", app_root_dir, errno, strerror(errno));
+ return -1;
+ }
+
+ struct stat st;
+ int res = fstat(fd, &st);
+ if (res < 0)
+ {
+ _LOGE("fstat() failed, path: %sshared, errno: %d (%s)", app_root_dir, errno, strerror(errno));
+ goto error;
+ }
+ *app_size += __stat_size(&st); // shared directory
+ _LOGS("app_size: %lld", *app_size);
+
+ _LOGS("traverse path: %sshared/data", app_root_dir);
+
+ subfd = openat(fd, "data", O_RDONLY | O_DIRECTORY);
+ if (subfd >= 0)
+ {
+ size = __calculate_directory_size(subfd, true);
+ if (size < 0)
+ {
+ _LOGE("Calculating shared/data directory failed.");
+ goto error;
+ }
+ *data_size += size;
+ _LOGS("data_size: %lld", *data_size);
+ close(subfd);
+ }
+ else if (subfd < 0 && errno != ENOENT)
+ {
+ _LOGE("openat() failed, entry: data, errno: %d (%s)", errno, strerror(errno));
+ goto error;
+ }
+
+ _LOGS("traverse path: %sshared/trusted", app_root_dir);
+
+ subfd = openat(fd, "trusted", O_RDONLY | O_DIRECTORY);
+ if (subfd >= 0)
+ {
+ size = __calculate_directory_size(subfd, true);
+ if (size < 0)
+ {
+ _LOGE("Calculating shared/trusted directory failed.");
+ goto error;
+ }
+ *data_size += size;
+ _LOGS("data_size: %lld", *data_size);
+ close(subfd);
+ }
+ else if (subfd < 0 && errno != ENOENT)
+ {
+ _LOGE("openat() failed, entry: trusted, errno: %d (%s)", errno, strerror(errno));
+ goto error;
+ }
+
+ _LOGS("traverse path: %sshared/res", app_root_dir);
+
+ subfd = openat(fd, "res", O_RDONLY | O_DIRECTORY);
+ if (subfd >= 0)
+ {
+ size = __calculate_directory_size(subfd, true);
+ if (size < 0)
+ {
+ _LOGE("Calculating shared/res directory failed.");
+ goto error;
+ }
+ *app_size += size;
+ _LOGS("app_size: %lld", *app_size);
+ close(subfd);
+ }
+ else if (subfd < 0 && errno != ENOENT)
+ {
+ _LOGE("openat() failed, entry: res, errno: %d (%s)", errno, strerror(errno));
+ goto error;
+ }
+
+ close(fd);
+ return 0;
+
+error:
+ if (fd != -1)
+ {
+ close(fd);
+ }
+ if (subfd != -1)
+ {
+ close(subfd);
+ }
+
+ return -1;
+}
+
+static int __calculate_pkg_size_info(STORAGE_TYPE type, const char *pkgid, long long *data_size, long long *cache_size, long long *app_size)
+{
+ char app_root_dir[MAX_PATH_LENGTH] = { 0, };
+ if (type == STORAGE_TYPE_INTERNAL)
+ {
+ snprintf(app_root_dir, MAX_PATH_LENGTH, "%s%s/", APP_BASE_INTERNAL_PATH, pkgid);
+ }
+ else if (type == STORAGE_TYPE_EXTERNAL)
+ {
+ snprintf(app_root_dir, MAX_PATH_LENGTH, "%s%s/", APP_BASE_EXTERNAL_PATH, pkgid);
+ }
+ else
+ {
+ _LOGE("Invalid STORAGE_TYPE");
+ return -1;
+ }
+
+ DIR *dir = opendir(app_root_dir);
+ if (dir == NULL)
+ {
+ _LOGE("opendir() failed, path: %s, errno: %d (%s)", app_root_dir, errno, strerror(errno));
+ return -1;
+ }
+
+ int dfd = dirfd(dir);
+ int subfd = -1;
+ struct stat st;
+ int res = fstat(dfd, &st);
+ if (res < 0)
+ {
+ _LOGE("fstat() failed, path: %s, errno: %d (%s)", app_root_dir, errno, strerror(errno));
+ goto error;
+ }
+ *app_size += __stat_size(&st);
+
+ struct dirent *ent = NULL;
+ long long size = 0;
+ while ((ent = readdir(dir)))
+ {
+ const char *name = ent->d_name;
+ if (name[0] == '.')
+ {
+ if (name[1] == '\0')
+ {
+ continue;
+ }
+ if ((name[1] == '.') && (name[2] == '\0'))
+ {
+ continue;
+ }
+ }
+
+ if (ent->d_type == DT_DIR)
+ {
+ subfd = openat(dfd, name, O_RDONLY | O_DIRECTORY);
+ if (subfd >= 0)
+ {
+ if (strncmp(name, "data", strlen("data")) == 0)
+ {
+ _LOGS("traverse path: %s%s", app_root_dir, name);
+ size = __calculate_directory_size(subfd, false);
+ if (size < 0)
+ {
+ _LOGE("Calculating data directory failed.");
+ goto error;
+ }
+ *data_size += size;
+ _LOGS("data_size: %lld", *data_size);
+ }
+ else if (strncmp(name, "cache", strlen("cache")) == 0)
+ {
+ _LOGS("traverse path: %s%s", app_root_dir, name);
+ size = __calculate_directory_size(subfd, false);
+ if (size < 0)
+ {
+ _LOGE("Calculating cache directory failed.");
+ goto error;
+ }
+ *cache_size += size;
+ _LOGS("cache_size: %lld", *cache_size);
+ }
+ else if (strncmp(name, "shared", strlen("shared")) == 0)
+ {
+ size = __calculate_shared_dir_size(dfd, app_root_dir, data_size, app_size);
+ if (size < 0)
+ {
+ _LOGE("Calculating shared directory failed.");
+ goto error;
+ }
+ *app_size += size;
+ _LOGS("app_size: %lld", *app_size);
+ }
+ else
+ {
+ _LOGS("traverse path: %s%s", app_root_dir, name);
+ size = __calculate_directory_size(subfd, true);
+ if (size < 0)
+ {
+ _LOGE("Calculating %s directory failed.", name);
+ goto error;
+ }
+ *app_size += size;
+ _LOGS("app_size: %lld", *app_size);
+ }
+ }
+ else if (subfd < 0 && errno != ENOENT)
+ {
+ _LOGE("openat() failed, entry: res, errno: %d (%s)", errno, strerror(errno));
+ goto error;
+ }
+ close(subfd);
+ }
+ }
+ closedir(dir);
+ return 0;
+
+error:
+ if (dir)
+ {
+ closedir(dir);
+ }
+ if (subfd != -1)
+ {
+ close(subfd);
+ }
+
+ return -1;
+}
+
+static char *__get_pkg_size_info_str(const pkg_size_info_t* pkg_size_info)
+{
+ char *size_info_str = (char *)malloc(MAX_SIZE_INFO_SIZE);
+ if (size_info_str == NULL)
+ {
+ _LOGE("Out of memory.");
+ return NULL;
+ }
+
+ snprintf(size_info_str, MAX_LONGLONG_LENGTH, "%lld", pkg_size_info->data_size);
+ strcat(size_info_str, ":");
+ snprintf(size_info_str + strlen(size_info_str), MAX_LONGLONG_LENGTH, "%lld", pkg_size_info->cache_size);
+ strcat(size_info_str, ":");
+ snprintf(size_info_str + strlen(size_info_str), MAX_LONGLONG_LENGTH, "%lld", pkg_size_info->app_size);
+ strcat(size_info_str, ":");
+ snprintf(size_info_str + strlen(size_info_str), MAX_LONGLONG_LENGTH, "%lld", pkg_size_info->ext_data_size);
+ strcat(size_info_str, ":");
+ snprintf(size_info_str + strlen(size_info_str), MAX_LONGLONG_LENGTH, "%lld", pkg_size_info->ext_cache_size);
+ strcat(size_info_str, ":");
+ snprintf(size_info_str + strlen(size_info_str), MAX_LONGLONG_LENGTH, "%lld", pkg_size_info->ext_app_size);
+ strcat(size_info_str, ":");
+
+ _LOGS("size_info_str: %s", size_info_str);
+
+ return size_info_str;
+}
+
+static void __get_pkg_size_info(const char *pkgid, pkg_size_info_t* pkg_size_info)
+{
+ int res = __calculate_pkg_size_info(STORAGE_TYPE_INTERNAL, pkgid, &pkg_size_info->data_size, &pkg_size_info->cache_size, &pkg_size_info->app_size);
+ if (res < 0)
+ {
+ _LOGD("Calculating internal package size info failed. res: %d", res);
+ }
+ _LOGS("size_info: %lld %lld %lld", pkg_size_info->data_size, pkg_size_info->cache_size, pkg_size_info->app_size);
+
+ res = __calculate_pkg_size_info(STORAGE_TYPE_EXTERNAL, pkgid, &pkg_size_info->ext_data_size, &pkg_size_info->ext_cache_size, &pkg_size_info->ext_app_size);
+ if (res < 0)
+ {
+ _LOGD("Calculating external package size info failed. res: %d", res);
+ }
+ _LOGS("size_info(external): %lld %lld %lld", pkg_size_info->ext_data_size, pkg_size_info->ext_cache_size, pkg_size_info->ext_app_size);
+}
+
+static int __get_total_pkg_size_info_cb(const pkgmgrinfo_pkginfo_h handle, void *user_data)
+{
+ int ret = 0;
+ char *pkgid;
+ pkg_size_info_t temp_pkg_size_info = {0,};
+ pkg_size_info_t *pkg_size_info = (void *)user_data;
+
+ ret = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
+ if(ret != PMINFO_R_OK) {
+ _LOGE("pkgmgr_pkginfo_get_pkgid() failed");
+ return -1;
+ }
+
+ __get_pkg_size_info(pkgid, &temp_pkg_size_info);
+
+ pkg_size_info->app_size += temp_pkg_size_info.app_size;
+ pkg_size_info->data_size += temp_pkg_size_info.data_size;
+ pkg_size_info->cache_size += temp_pkg_size_info.cache_size;
+ pkg_size_info->ext_app_size += temp_pkg_size_info.ext_app_size;
+ pkg_size_info->ext_data_size += temp_pkg_size_info.ext_data_size;
+ pkg_size_info->ext_cache_size += temp_pkg_size_info.ext_cache_size;
+
+ return 0;
+}
+
+static int __get_total_pkg_size_info(pkg_size_info_t* pkg_size_info)
+{
+ int res = pkgmgrinfo_pkginfo_get_list(__get_total_pkg_size_info_cb, pkg_size_info);
+ if (res != PMINFO_R_OK)
+ {
+ return -1;
+ }
+ return 0;
+}
+
+static void __send_signal(const char *pkgid, int argc, char *argv[], char *size_info)
+{
+ pkgmgr_installer *pi = pkgmgr_installer_new();
+ if (pi == NULL)
+ {
+ _LOGD("Creating the pkgmgr_installer instance failed.");
+ }
+ else
+ {
+ pkgmgr_installer_receive_request(pi, argc, argv);
+ pkgmgr_installer_send_signal(pi, PKGMGR_INSTALLER_GET_SIZE_KEY_STR, pkgid, "-1", size_info);
+ pkgmgr_installer_free(pi);
+ }
+}
+
+static int __send_signal_for_pkg_size_info(const char *pkgid, int argc, char *argv[])
+{
+ pkg_size_info_t pkg_size_info = {0,};
+ __get_pkg_size_info(pkgid, &pkg_size_info);
+ char *size_info = __get_pkg_size_info_str(&pkg_size_info);
+ if (size_info == NULL)
+ {
+ return -1;
+ }
+ __send_signal(pkgid, argc, argv, size_info);
+ free(size_info);
+ return 0;
+}
+
+static int __send_signal_for_total_pkg_size_info(int argc, char *argv[])
+{
+ pkg_size_info_t pkg_size_info = {0,};
+ __get_total_pkg_size_info(&pkg_size_info);
+ char *size_info = __get_pkg_size_info_str(&pkg_size_info);
+ if (size_info == NULL)
+ {
+ return -1;
+ }
+ __send_signal(PKG_SIZE_INFO_TOTAL, argc, argv, size_info);
+ free(size_info);
+ return 0;
+}
+
+int __create_size_info(int argc, char *argv[])
+{
+ char *package_size_info = NULL;
+ int info_len = MAX_PKG_BUF_LEN * MAX_PKG_INFO_LEN;
+ pkgmgr_installer *pi;
+ char total_buf[MAX_PKG_BUF_LEN] = {'\0'};
+ char data_buf[MAX_PKG_BUF_LEN] = {'\0'};
+
+ DIR *dir = NULL;
+ int dfd = 0;
+ struct stat f_stat;
+ struct dirent *de = NULL;
+
+ dir = opendir(PKG_RW_PATH);
+ if (dir == NULL)
+ {
+ _LOGE("Couldn't open the directory %s \n", PKG_RW_PATH);
+ return -1;
+ }
+
+ package_size_info = (char*)malloc(info_len);
+ if (package_size_info == NULL)
+ {
+ _LOGE("out of memory");
+ closedir(dir);
+ return -1;
+ }
+
+ memset(package_size_info, 0, info_len);
+
+ pi = pkgmgr_installer_new();
+ if (!pi) {
+ _LOGD("Failure in creating the pkgmgr_installer object");
+ return -1;
+ }
+
+ while ((de = readdir(dir)))
+ {
+ int total_size = 0;
+ int others_size = 0;
+ int data_size = 0;
+
+ char size_string[128] = {0};
+ const char *name = de->d_name;
+ if (name[0] == '.') {
+ if (name[1] == 0)
+ continue;
+ if ((name[1] == '.') && (name[2] == 0))
+ continue;
+ }
+
+ dfd = dirfd(dir);
+ if (de->d_type == DT_DIR) {
+ int subfd = 0;
+
+ subfd = openat(dfd, name, O_RDONLY | O_DIRECTORY);
+ if (subfd >= 0) {
+ if (fstat(subfd, &f_stat) == 0) // root
+ {
+ others_size += __stat_size(&f_stat);
+ }
+ others_size += __calculate_dir_size(subfd, 0, 1);
+ }
+ subfd = openat(dfd, name, O_RDONLY | O_DIRECTORY);
+ if (subfd >= 0) {
+ int datafd = 0;
+ datafd = openat(subfd, "data", O_RDONLY | O_DIRECTORY);
+ if (datafd >= 0) {
+ if (fstat(datafd, &f_stat) == 0) // data
+ {
+ others_size += __stat_size(&f_stat);
+ }
+ data_size = __calculate_dir_size(datafd, 1, 2);
+ }
+ }
+ }
+
+ total_size = others_size + data_size;
+
+ /*send size info to client*/
+ snprintf(total_buf, MAX_PKG_BUF_LEN - 1, "%d", total_size);
+ snprintf(data_buf, MAX_PKG_BUF_LEN - 1, "%d", data_size);
+
+ pkgmgr_installer_receive_request(pi, argc, argv);
+ pkgmgr_installer_send_signal(pi, PKGMGR_INSTALLER_GET_SIZE_KEY_STR, name, data_buf, total_buf);
+
+ sprintf(size_string, "%s=%d/%d:", name, total_size, data_size);
+ strncat(package_size_info, size_string, info_len);
+ }
+ closedir(dir);
+
+ pkgmgr_installer_send_signal(pi, PKGMGR_INSTALLER_GET_SIZE_KEY_STR, "get_size", "get_size", "end");
+ pkgmgr_installer_free(pi);
+
+ __make_sizeinfo_file(package_size_info);
+ if(package_size_info)
+ free(package_size_info);
+
+ return 0;
+}
+
+static int __pkg_list_cb (const pkgmgrinfo_pkginfo_h handle, void *user_data)
+{
+ int ret = -1;
+ char *pkgid;
+ int data_size = 0;
+ int total_size = 0;
+
+ ret = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
+ if(ret < 0) {
+ _LOGE("pkgmgr_pkginfo_get_pkgid() failed\n");
+ }
+
+ ret = __get_size_info(pkgid, &data_size, &total_size);
+ if ((ret < 0) || (total_size < 0))
+ return -1;
+
+ * (int *) user_data += total_size;
+ return 0;
+}
+
+void __make_size_info_file(char *req_key, int size)
+{
+ int ret = 0;
+ FILE* file = NULL;
+ int fd = 0;
+ char buf[MAX_PKG_BUF_LEN] = {0};
+ const char* app_info_label = "*";
+ char info_file[MAX_PKG_BUF_LEN] = {'\0', };
+
+ if(req_key == NULL)
+ return;
+
+ snprintf(info_file, MAX_PKG_BUF_LEN, "%s/%s", PKG_SIZE_INFO_PATH, req_key);
+ _LOGE("File path = %s\n", info_file);
+
+ file = fopen(info_file, "w");
+ if (file == NULL) {
+ _LOGE("Couldn't open the file %s \n", info_file);
+ return;
+ }
+
+ snprintf(buf, 128, "%d\n", size);
+ fwrite(buf, 1, strlen(buf), file);
+
+ fflush(file);
+ fd = fileno(file);
+ fsync(fd);
+ fclose(file);
+
+ if(lsetxattr(info_file, "security.SMACK64", app_info_label, strlen(app_info_label), 0)) {
+ _LOGE("error(%d) in setting smack label",errno);
+ }
+ ret = chmod(info_file, 0777);
+ if(ret < 0)
+ return;
+
+ ret = chown(info_file, 5000, 5000);
+ if(ret < 0)
+ return;
+}
+
+void __getsize_send_signal(const char *req_id, const char *pkg_type, const char *pkgid, const char *key, const char *val)
+{
+ dbus_uint32_t serial = 0;
+ DBusMessage *msg;
+ DBusMessageIter args;
+ DBusError err;
+ DBusConnection *conn;
+ const char *values[] = {
+ req_id,
+ pkg_type,
+ pkgid,
+ key,
+ val
+ };
+ int i;
+
+ dbus_error_init(&err);
+
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
+ if (dbus_error_is_set(&err)) {
+ _LOGE("Connection error: %s", err.message);
+ }
+ if (NULL == conn) {
+ _LOGE("conn is NULL");
+ return;
+ }
+
+ msg = dbus_message_new_signal(COMM_STATUS_BROADCAST_DBUS_GET_SIZE_PATH, COMM_STATUS_BROADCAST_DBUS_GET_SIZE_INTERFACE, COMM_STATUS_BROADCAST_EVENT_GET_SIZE);
+ if (NULL == msg) {
+ _LOGE("msg is NULL");
+ return;
+ }
+
+ dbus_message_iter_init_append(msg, &args);
+
+ for (i = 0; i < 5; i++) {
+ if (!dbus_message_iter_append_basic
+ (&args, DBUS_TYPE_STRING, &(values[i]))) {
+ _LOGE("dbus_message_iter_append_basic failed:"
+ " Out of memory");
+ return;
+ }
+ }
+ if (!dbus_connection_send(conn, msg, &serial)) {
+ _LOGE("dbus_connection_send failed: Out of memory");
+ return;
+ }
+ dbus_connection_flush(conn);
+ dbus_message_unref(msg);
+}
+
+static int __send_sizeinfo_cb(const pkgmgrinfo_pkginfo_h handle, void *user_data)
+{
+ int ret = -1;
+ char *pkgid;
+ int data_size = 0;
+ int total_size = 0;
+
+ char total_buf[MAX_PKG_BUF_LEN] = {'\0'};
+ char data_buf[MAX_PKG_BUF_LEN] = {'\0'};
+
+ ret = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
+ if(ret < 0) {
+ _LOGE("pkgmgr_pkginfo_get_pkgid() failed\n");
+ }
+
+ ret = __get_size_info(pkgid, &data_size, &total_size);
+
+ /*send size info to client*/
+ snprintf(total_buf, MAX_PKG_BUF_LEN - 1, "%d", total_size);
+ snprintf(data_buf, MAX_PKG_BUF_LEN - 1, "%d", data_size);
+
+ __getsize_send_signal(PKGMGR_INSTALLER_GET_SIZE_KEY_STR, PKGMGR_INSTALLER_GET_SIZE_KEY_STR, pkgid, data_buf, total_buf);
+
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ int ret = -1;
+ int data_size = 0;
+ int total_size = 0;
+ int get_type = 0;
+ char *pkgid = NULL;
+ char *req_key = NULL;
+
+ char data_buf[MAX_PKG_BUF_LEN] = {'\0'};
+ char total_buf[MAX_PKG_BUF_LEN] = {'\0'};
+ pkgmgr_installer *pi = NULL;
+
+ // argv has bellowed meaning
+ // argv[0] = pkgid
+ // argv[1] = get type
+ // argv[2] = req_key
+
+ if(argv[0] == NULL) {
+ _LOGE("pkgid is NULL\n");
+ return -1;
+ }
+
+ pkgid = argv[0];
+ get_type = atoi(argv[1]);
+
+ _LOGD("start get size : [pkgid = %s, request type = %d] \n", pkgid, get_type);
+
+ if (get_type == PM_GET_SIZE_INFO) {
+ ret = pkgmgrinfo_pkginfo_get_list(__send_sizeinfo_cb, NULL);
+ __getsize_send_signal(PKGMGR_INSTALLER_GET_SIZE_KEY_STR, PKGMGR_INSTALLER_GET_SIZE_KEY_STR, "get_size", "get_size", "end");
+ } else if (get_type == PM_GET_ALL_PKGS) {
+ ret = pkgmgrinfo_pkginfo_get_list(__pkg_list_cb, &total_size);
+ } else if (get_type == PM_GET_SIZE_FILE) {
+ ret = __create_size_info(argc, argv);
+ } else if (get_type == PM_GET_PKG_SIZE_INFO) {
+ int res = __send_signal_for_pkg_size_info(pkgid, argc, argv);
+ if (res < 0) {
+ _LOGE("Sending signal for package size info failed.");
+ return -1;
+ }
+ } else if (get_type == PM_GET_TOTAL_PKG_SIZE_INFO) {
+ int res = __send_signal_for_total_pkg_size_info(argc, argv);
+ if (res < 0) {
+ _LOGE("Failed to get the total size information of all the pacakges.");
+ return -1;
+ }
+ } else {
+ ret = __get_size_info(pkgid, &data_size, &total_size);
+ }
+
+ if (get_type != PM_GET_SIZE_INFO && get_type != PM_GET_PKG_SIZE_INFO) {
+ pi = pkgmgr_installer_new();
+ if (!pi) {
+ _LOGD("Failure in creating the pkgmgr_installer object");
+ } else {
+ snprintf(data_buf, MAX_PKG_BUF_LEN - 1, "%d", data_size);
+ snprintf(total_buf, MAX_PKG_BUF_LEN - 1, "%d", total_size);
+ pkgmgr_installer_receive_request(pi, argc, argv);
+ pkgmgr_installer_send_signal(pi, PKGMGR_INSTALLER_GET_SIZE_KEY_STR, pkgid, data_buf, total_buf);
+ pkgmgr_installer_free(pi);
+ }
+// __getsize_send_signal(PKGMGR_INSTALLER_GET_SIZE_KEY_STR, PKGMGR_INSTALLER_GET_SIZE_KEY_STR, pkgid, data_buf, total_buf);
+ }
+
+ req_key = (char *)calloc(strlen(argv[2])+1, sizeof(char));
+ if(req_key == NULL)
+ return -1;
+ strncpy(req_key, argv[2], strlen(argv[2]));
+
+ if (strncmp(req_key, pkgid, strlen(pkgid)) == 0) {
+ _LOGD("make a file for sync request [pkgid = %s] \n", pkgid);
+ if (get_type == PM_GET_TOTAL_SIZE)
+ __make_size_info_file(req_key , total_size);
+ else if (get_type == PM_GET_DATA_SIZE)
+ __make_size_info_file(req_key , data_size);
+ else
+ __make_size_info_file(req_key , total_size);
+ }
+
+ _LOGD("finish get size : [result = %d] \n", ret);
+
+ free(req_key);
+ return 0;
+}
#include <unistd.h>
#include <sys/types.h>
#include <vconf.h>
+#include <pkgmgr_parser.h>
+#include <pkgmgr-info.h>
#include "package-manager.h"
#include "package-manager-types.h"
-#include "pkgmgr_parser.h"
-#include "pkgmgr-dbinfo.h"
-
+#include "pkgmgr_installer.h"
static void __print_usage();
-static int __get_pkg_info(char *pkgname);
+static int __get_pkg_info(char *pkgid);
static int __get_app_info(char *appid);
-static int __get_app_list(char *pkgname);
+static int __get_app_list(char *pkgid);
+static int __get_app_category_list(char *appid);
+static int __get_app_metadata_list(char *appid);
+static int __get_app_control_list(char *appid);
static int __get_pkg_list(void);
+static int __get_installed_app_list();
+static int __add_app_filter(void);
+static int __add_pkg_filter(void);
static int __insert_manifest_in_db(char *manifest);
static int __remove_manifest_from_db(char *manifest);
-static int __set_pkginfo_in_db(char *pkgname);
+static int __set_certinfo_in_db(char *pkgid);
+static int __get_certinfo_from_db(char *pkgid);
+static int __del_certinfo_from_db(char *pkgid);
static int __get_integer_input_data(void);
char *__get_string_input_data(void);
-static int __iter_fn(const char *pkg_type, const char *pkg_name,
- const char *version, void *data);
+static int __pkg_list_cb (const pkgmgrinfo_pkginfo_h handle, void *user_data);
+static int __app_category_list_cb(const char *category_name, void *user_data);
+static int __app_control_list_cb(pkgmgrinfo_appcontrol_h handle, void *user_data);
+static int __app_metadata_list_cb(const char *metadata_name, const char *metadata_value, void *user_data);
+int app_func(const pkgmgrinfo_appinfo_h handle, void *user_data);
+
+static void __get_pkgmgrinfo_pkginfo(const pkgmgrinfo_pkginfo_h handle, void *user_data)
+{
+ int ret = -1;
+ char *type = NULL;
+ char *version = NULL;
+ char *author_name = NULL;
+ char *author_email = NULL;
+ char *author_href = NULL;
+ char *root_path = NULL;
+ char *mainappid = NULL;
+ pkgmgrinfo_install_location location = 0;
+ char *icon = NULL;
+ char *label = NULL;
+ char *desc = NULL;
+ bool removable = 0;
+ bool preload = 0;
+ bool readonly = 0;
+ bool update = 0;
+ bool system = 0;
+ bool support_disable = 0;
+ int installed_time = -1;
+
+ ret = pkgmgrinfo_pkginfo_get_type(handle, &type);
+ if (ret < 0) {
+ printf("Failed to get pkg type\n");
+ }
+ if (type)
+ printf("Type: %s\n", type);
+
+ ret = pkgmgrinfo_pkginfo_get_version(handle, &version);
+ if (ret < 0) {
+ printf("Failed to get version\n");
+ }
+ if (version)
+ printf("Version: %s\n", version);
+
+ ret = pkgmgrinfo_pkginfo_get_install_location(handle, &location);
+ if (ret < 0) {
+ printf("Failed to get install location\n");
+ }
+ printf("Install Location: %d\n", location);
+
+ ret = pkgmgrinfo_pkginfo_get_icon(handle, &icon);
+ if (ret < 0) {
+ printf("Failed to get icon\n");
+ }
+ if (icon)
+ printf("Icon: %s\n", icon);
+
+ ret = pkgmgrinfo_pkginfo_get_label(handle, &label);
+ if (ret < 0) {
+ printf("Failed to get label\n");
+ }
+ if (label)
+ printf("Label: %s\n", label);
+
+ ret = pkgmgrinfo_pkginfo_get_description(handle, &desc);
+ if (ret < 0) {
+ printf("Failed to get description\n");
+ }
+ if (desc)
+ printf("Description: %s\n", desc);
+
+ ret = pkgmgrinfo_pkginfo_get_author_name(handle, &author_name);
+ if (ret < 0) {
+ printf("Failed to get author name\n");
+ }
+ if (author_name)
+ printf("Author Name: %s\n", author_name);
+
+ ret = pkgmgrinfo_pkginfo_get_author_email(handle, &author_email);
+ if (ret < 0) {
+ printf("Failed to get author email\n");
+ }
+ if (author_email)
+ printf("Author Email: %s\n", author_email);
+
+ ret = pkgmgrinfo_pkginfo_get_author_href(handle, &author_href);
+ if (ret < 0) {
+ printf("Failed to get author href\n");
+ }
+ if (author_href)
+ printf("Author Href: %s\n", author_href);
+
+ ret = pkgmgrinfo_pkginfo_get_root_path(handle, &root_path);
+ if (ret < 0) {
+ printf("Failed to get root_path\n");
+ }
+ if (author_href)
+ printf("root_path : %s\n", root_path);
+
+ ret = pkgmgrinfo_pkginfo_get_mainappid(handle, &mainappid);
+ if (ret < 0) {
+ printf("Failed to get mainappid\n");
+ }
+ if (author_href)
+ printf("mainappid : %s\n", mainappid);
+
+ ret = pkgmgrinfo_pkginfo_get_installed_time(handle, &installed_time);
+ if (ret < 0) {
+ printf("Failed to get install time\n");
+ }
+ printf("Install time: %d\n", installed_time);
+
+ ret = pkgmgrinfo_pkginfo_is_removable(handle, &removable);
+ if (ret < 0) {
+ printf("Failed to get removable\n");
+ }
+ else
+ printf("Removable: %d\n", removable);
+
+ ret = pkgmgrinfo_pkginfo_is_preload(handle, &preload);
+ if (ret < 0) {
+ printf("Failed to get preload\n");
+ }
+ else
+ printf("Preload: %d\n", preload);
+
+ ret = pkgmgrinfo_pkginfo_is_readonly(handle, &readonly);
+ if (ret < 0) {
+ printf("Failed to get readonly\n");
+ }
+ else
+ printf("Readonly: %d\n", readonly);
+
+ ret = pkgmgrinfo_pkginfo_is_update(handle, &update);
+ if (ret < 0) {
+ printf("Failed to get update\n");
+ }
+ else
+ printf("update: %d\n", update);
+
+ ret = pkgmgrinfo_pkginfo_is_system(handle, &system);
+ if (ret < 0) {
+ printf("Failed to get system\n");
+ }
+ else
+ printf("system: %d\n", system);
+
+ ret = pkgmgrinfo_pkginfo_is_support_disable(handle, &support_disable);
+ if (ret < 0) {
+ printf("Failed to get support-disable\n");
+ }
+ else
+ printf("Support-Disable: %d\n", support_disable);
+
+ return ;
+}
+int __get_app_id(const pkgmgrinfo_appinfo_h handle, void *user_data)
+{
+ char *appid = NULL;
+ char *apptype = NULL;
+ int ret = -1;
+
+ ret = pkgmgrinfo_appinfo_get_appid(handle, &appid);
+ if (ret < 0) {
+ printf("Failed to get appid\n");
+ }
+
+ ret = pkgmgrinfo_appinfo_get_apptype(handle, &apptype);
+ if (ret < 0) {
+ printf("Failed to get package\n");
+ }
+ printf("apptype [%s]\t appid [%s]\n", apptype, appid);
+
+ return 0;
+}
static int __get_integer_input_data(void)
{
char input_str[32] = { 0, };
int data = 0;
- fflush(stdin);
- if (fgets(input_str, 1024, stdin) == NULL) {
- printf("Input buffer overflow....\n");
+ if (fgets(input_str, sizeof(input_str), stdin) == NULL) {
+ printf("fgets() failed....\n");
return -1;
}
- if (sscanf(input_str, "%d", &data) != 1) {
+ if (sscanf(input_str, "%4d", &data) != 1) {
printf("Input only integer option....\n");
return -1;
}
char *data = (char *)malloc(1024);
if (data == NULL) {
printf("Malloc Failed\n");
- return -1;
+ return NULL;
}
if (fgets(data,1024,stdin) == NULL){
printf("Buffer overflow!!! try again\n");
static void __print_usage()
{
printf("For Getting package|App Info\n");
- printf("\tpkginfo --[pkg|app] <pkgname|appid>\n\n");
+ printf("\tpkginfo --[pkg|app] <pkgid|appid>\n\n");
printf("For Getting list of installed packages\n");
- printf("\tpkginfo --list \n\n");
+ printf("\tpkginfo --listpkg \n\n");
+ printf("For Getting list of installed applications\n");
+ printf("\tpkginfo --listapp \n\n");
printf("For Getting app list for a particular package\n");
- printf("\tpkginfo --list <pkgname>\n\n");
+ printf("\tpkginfo --list <pkgid>\n\n");
+ printf("For Getting app category list for a particular application\n");
+ printf("\tpkginfo --category <appid>\n\n");
+ printf("For Getting app metadata list for a particular application\n");
+ printf("\tpkginfo --metadata <appid>\n\n");
+ printf("For Getting app control list for a particular application\n");
+ printf("\tpkginfo --appcontrol <appid>\n\n");
printf("To insert|remove manifest info in DB\n");
printf("\tpkginfo --[imd|rmd] <manifest file name>\n\n");
- printf("To set pkginfo in DB\n");
- printf("\tpkginfo --setdb <pkgname>\n\n");
printf("To set manifest validation\n");
printf("\tpkginfo --check <manifest file name>\n\n");
+ printf("To set cert info in DB\n");
+ printf("\tpkginfo --setcert <pkgid>\n\n");
+ printf("To get cert info from DB\n");
+ printf("\tpkginfo --getcert <pkgid>\n\n");
+ printf("To compare pkg cert info from DB\n");
+ printf("\tpkginfo --cmp-pkgcert <lhs_pkgid> <rhs_pkgid>\n\n");
+ printf("To compare app cert info from DB\n");
+ printf("\tpkginfo --cmp-appcert <lhs_appid> <rhs_appid>\n\n");
+ printf("To delete all cert info from DB\n");
+ printf("\tpkginfo --delcert <pkgid>\n\n");
+ printf("To add application filter values [Multiple values can be added]\n");
+ printf("\tpkginfo --app-flt\n\n");
+ printf("To add package filter values [Multiple values can be added]\n");
+ printf("\tpkginfo --pkg-flt\n\n");
+ printf("To add metadata filter values\n");
+ printf("\tpkginfo --metadata-flt\n\n");
}
-static int __set_pkginfo_in_db(char *pkgname)
+static void __print_arg_filter_usage()
{
- if (pkgname == NULL) {
- printf("pkgname is NULL\n");
- return -1;
+ printf("=========================================\n");
+ printf("pkginfo --arg-flt key value\n");
+ printf("ex : pkginfo --arg-flt 6 webapp\n");
+ printf("key list is bellowed\n");
+ printf("2 --> filter by app ID\n");
+ printf("3 --> filter by app component\n");
+ printf("4 --> filter by app exec\n");
+ printf("5 --> filter by app icon\n");
+ printf("6 --> filter by app type\n");
+ printf("7 --> filter by app operation\n");
+ printf("8 --> filter by app uri\n");
+ printf("9 --> filter by app mime\n");
+ printf("10 --> filter by app category\n");
+ printf("11 --> filter by app nodisplay [0|1]\n");
+ printf("12 --> filter by app multiple [0|1]\n");
+ printf("13 --> filter by app onboot [0|1]\n");
+ printf("14 --> filter by app autorestart [0|1]\n");
+ printf("15 --> filter by app taskmanage [0|1]\n");
+ printf("16 --> filter by app hwacceleration\n");
+ printf("17 --> filter by app screenreader\n");
+ printf("=========================================\n");
+}
+
+static int __app_list_cb(pkgmgrinfo_appinfo_h handle, void *user_data)
+{
+ char *appid = NULL;
+ pkgmgrinfo_appinfo_get_appid(handle, &appid);
+ printf("appid : %s\n", appid);
+ return 0;
+}
+
+static int __add_metadata_filter()
+{
+ int ret = 0;
+ pkgmgrinfo_appinfo_metadata_filter_h handle;
+ char *key = NULL;
+ char *value = NULL;
+
+ ret = pkgmgrinfo_appinfo_metadata_filter_create(&handle);
+ if (ret != PMINFO_R_OK){
+ printf("pkgmgrinfo_appinfo_metadata_filter_create() failed\n");
+ return ret;
+ }
+
+ printf("enter metadata - key\n");
+ key = __get_string_input_data();
+ printf("enter metadata - value\n");
+ value = __get_string_input_data();
+
+ printf("filter condition : key=[%s], value=[%s]\n", key, value);
+
+ ret = pkgmgrinfo_appinfo_metadata_filter_add(handle, key, value);
+ if (ret != PMINFO_R_OK){
+ printf("pkgmgrinfo_appinfo_metadata_filter_add() failed\n");
+ goto err;
+ }
+
+ ret = pkgmgrinfo_appinfo_metadata_filter_foreach(handle, __app_list_cb, NULL);
+ if (ret != PMINFO_R_OK){
+ printf("pkgmgrinfo_appinfo_metadata_filter_add() failed\n");
+ goto err;
}
+
+err:
+ pkgmgrinfo_appinfo_metadata_filter_destroy(handle);
+ if (key) {
+ free(key);
+ key = NULL;
+ }
+ if (value) {
+ free(value);
+ value = NULL;
+ }
+ return ret;
+}
+
+static int __add_app_filter()
+{
int ret = 0;
int choice = -1;
- int preload = -1;
- int removable = -1;
- int location = -1;
- char *locale = NULL;
- pkgmgr_pkgdbinfo_h handle = NULL;
- ret = pkgmgr_create_pkgdbinfo(pkgname, &handle);
- if (ret < 0) {
- printf("pkgmgr_create_pkgdbinfo failed\n");
+ char *value = NULL;
+ int val = -1;
+ int count = 0;
+ pkgmgrinfo_appinfo_filter_h handle;
+ ret = pkgmgrinfo_appinfo_filter_create(&handle);
+ if (ret > 0) {
+ printf("appinfo filter handle create failed\n");
return -1;
}
- while (choice != 0)
+ while (choice != 0 && choice != 1)
{
- printf("Enter the choice you want to set\n");
- printf("0 --> to set data in DB\n");
- printf("1 --> pkg type\n");
- printf("2 --> pkg version\n");
- printf("3 --> pkg instal location\n");
- printf("4 --> pkg label\n");
- printf("5 --> pkg icon\n");
- printf("6 --> pkg description\n");
- printf("7 --> pkg author\n");
- printf("8 --> pkg removable\n");
- printf("9 --> pkg preload\n");
+ printf("Enter Choice\n");
+ printf("0 --> Finalize filter and get count of apps\n");
+ printf("1 --> Finalize filter and get list of apps\n");
+ printf("2 --> filter by app ID\n");
+ printf("3 --> filter by app component\n");
+ printf("4 --> filter by app exec\n");
+ printf("5 --> filter by app icon\n");
+ printf("6 --> filter by app type\n");
+ printf("7 --> filter by app operation\n");
+ printf("8 --> filter by app uri\n");
+ printf("9 --> filter by app mime\n");
+ printf("10 --> filter by app category\n");
+ printf("11 --> filter by app nodisplay [0|1]\n");
+ printf("12 --> filter by app multiple [0|1]\n");
+ printf("13 --> filter by app onboot [0|1]\n");
+ printf("14 --> filter by app autorestart [0|1]\n");
+ printf("15 --> filter by app taskmanage [0|1]\n");
+ printf("16 --> filter by app support-disable [0|1]\n");
+ printf("17 --> filter by app hwacceleration\n");
+ printf("18 --> filter by app screenreader\n");
+ printf("19 --> filter by app disable [0|1]\n");
choice = __get_integer_input_data();
- switch(choice) {
+ switch (choice) {
case 0:
- ret = pkgmgr_save_pkgdbinfo(handle);
- if (ret < 0) {
- printf("pkgmgr_save_pkgdbinfo failed\n");
- return -1;
- }
- ret = pkgmgr_destroy_pkgdbinfo(handle);
+ ret = pkgmgrinfo_appinfo_filter_count(handle, &count);
if (ret < 0) {
- printf("pkgmgr_destroy_pkgdbinfo failed\n");
- return -1;
+ printf("pkgmgrinfo_appinfo_filter_count() failed\n");
+ ret = -1;
+ goto err;
}
- return 0;
+ printf("App count = %d\n", count);
+ break;
case 1:
- printf("Enter type: \n");
- char *type = __get_string_input_data();
- ret = pkgmgr_set_type_to_pkgdbinfo(handle, type);
+ ret = pkgmgrinfo_appinfo_filter_foreach_appinfo(handle, app_func, NULL);
if (ret < 0) {
- printf("pkgmgr_set_type_to_pkgdbinfo failed\n");
- return -1;
+ printf("pkgmgrinfo_appinfo_filter_foreach_appinfo() failed\n");
+ ret = -1;
+ goto err;
}
break;
case 2:
- printf("Enter version: \n");
- char *version = __get_string_input_data();
- ret = pkgmgr_set_version_to_pkgdbinfo(handle, version);
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle,
+ PMINFO_APPINFO_PROP_APP_ID, value);
if (ret < 0) {
- printf("pkgmgr_set_version_to_pkgdbinfo failed\n");
- return -1;
+ printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
}
+ free(value);
+ value = NULL;
break;
case 3:
- printf("Enter install location [0:internal | 1:external]: \n");
- location = __get_integer_input_data();
- ret = pkgmgr_set_install_location_to_pkgdbinfo(handle, location);
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle,
+ PMINFO_APPINFO_PROP_APP_COMPONENT, value);
if (ret < 0) {
- printf("pkgmgr_set_install_location_to_pkgdbinfo failed\n");
- return -1;
+ printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
}
+ free(value);
+ value = NULL;
break;
case 4:
- printf("Enter label :\n");
- char *label = __get_string_input_data();
- printf("Enter locale ['def' for default]: \n");
- locale = __get_string_input_data();
- if (strcmp(locale, "def") == 0)
- ret = pkgmgr_set_label_to_pkgdbinfo(handle, label, NULL);
- else
- ret = pkgmgr_set_label_to_pkgdbinfo(handle, label, locale);
- if (ret < 0) {
- printf("pkgmgr_set_label_to_pkgdbinfo failed\n");
- return -1;
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle,
+ PMINFO_APPINFO_PROP_APP_EXEC, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
}
+ free(value);
+ value = NULL;
break;
case 5:
- printf("Enter icon: \n");
- char *icon = __get_string_input_data();
- printf("Enter locale ['def' for default]: \n");
- locale = __get_string_input_data();
- if (strcmp(locale, "def") == 0)
- ret = pkgmgr_set_icon_to_pkgdbinfo(handle, icon, NULL);
- else
- ret = pkgmgr_set_icon_to_pkgdbinfo(handle, icon, locale);
- if (ret < 0) {
- printf("pkgmgr_set_icon_to_pkgdbinfo failed\n");
- return -1;
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle,
+ PMINFO_APPINFO_PROP_APP_ICON, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
}
+ free(value);
+ value = NULL;
break;
case 6:
- printf("Enter description: \n");
- char *description = __get_string_input_data();
- printf("Enter locale ['def' for default]: \n");
- locale = __get_string_input_data();
- if (strcmp(locale, "def") == 0)
- ret = pkgmgr_set_description_to_pkgdbinfo(handle, description, NULL);
- else
- ret = pkgmgr_set_description_to_pkgdbinfo(handle, description, locale);
- if (ret < 0) {
- printf("pkgmgr_set_description_to_pkgdbinfo failed\n");
- return -1;
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle,
+ PMINFO_APPINFO_PROP_APP_TYPE, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
}
+ free(value);
+ value = NULL;
break;
case 7:
- printf("Enter author name: \n");
- char *author_name = __get_string_input_data();
- printf("Enter locale ['def' for default]: \n");
- locale = __get_string_input_data();
- printf("Enter author email: \n");
- char *author_email = __get_string_input_data();
- printf("Enter author href: \n");
- char *author_href = __get_string_input_data();
- if (strcmp(locale, "def") == 0)
- ret = pkgmgr_set_author_to_pkgdbinfo(handle, author_name, author_email, author_href, NULL);
- else
- ret = pkgmgr_set_author_to_pkgdbinfo(handle, author_name, author_email, author_href, locale);
- if (ret < 0) {
- printf("pkgmgr_set_author_to_pkgdbinfo failed\n");
- return -1;
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle,
+ PMINFO_APPINFO_PROP_APP_OPERATION, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
}
+ free(value);
+ value = NULL;
break;
case 8:
- printf("Enter removable [0:false | 1:true]: \n");
- removable = __get_integer_input_data();
- ret = pkgmgr_set_removable_to_pkgdbinfo(handle, removable);
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle,
+ PMINFO_APPINFO_PROP_APP_URI, value);
if (ret < 0) {
- printf("pkgmgr_set_removable_to_pkgdbinfo failed\n");
- return -1;
+ printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
}
+ free(value);
+ value = NULL;
break;
case 9:
- printf("Enter preload [0:false | 1:true]: \n");
- preload = __get_integer_input_data();
- ret = pkgmgr_set_preload_to_pkgdbinfo(handle, preload);
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle,
+ PMINFO_APPINFO_PROP_APP_MIME, value);
if (ret < 0) {
- printf("pkgmgr_set_preload_to_pkgdbinfo failed\n");
- return -1;
+ printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 10:
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle,
+ PMINFO_APPINFO_PROP_APP_CATEGORY, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 11:
+ val = __get_integer_input_data();
+ ret = pkgmgrinfo_appinfo_filter_add_bool(handle,
+ PMINFO_APPINFO_PROP_APP_NODISPLAY, val);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 12:
+ val = __get_integer_input_data();
+ ret = pkgmgrinfo_appinfo_filter_add_bool(handle,
+ PMINFO_APPINFO_PROP_APP_MULTIPLE, val);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 13:
+ val = __get_integer_input_data();
+ ret = pkgmgrinfo_appinfo_filter_add_bool(handle,
+ PMINFO_APPINFO_PROP_APP_ONBOOT, val);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 14:
+ val = __get_integer_input_data();
+ ret = pkgmgrinfo_appinfo_filter_add_bool(handle,
+ PMINFO_APPINFO_PROP_APP_AUTORESTART, val);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 15:
+ val = __get_integer_input_data();
+ ret = pkgmgrinfo_appinfo_filter_add_bool(handle,
+ PMINFO_APPINFO_PROP_APP_TASKMANAGE, val);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 16:
+ val = __get_integer_input_data();
+ ret = pkgmgrinfo_appinfo_filter_add_bool(handle,
+ PMINFO_APPINFO_PROP_APP_SUPPORT_DISABLE, val);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 17:
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle,
+ PMINFO_APPINFO_PROP_APP_HWACCELERATION, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 18:
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle,
+ PMINFO_APPINFO_PROP_APP_SCREENREADER, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 19:
+ val = __get_integer_input_data();
+ ret = pkgmgrinfo_appinfo_filter_add_bool(handle,
+ PMINFO_APPINFO_PROP_APP_DISABLE, val);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
}
break;
default:
- printf("Invalid number entered\n");
- continue;
+ printf("Invalid filter property\n");
+ pkgmgrinfo_appinfo_filter_destroy(handle);
+ ret = -1;
+ goto err;
}
}
- return 0;
+ ret = 0;
+err:
+ pkgmgrinfo_appinfo_filter_destroy(handle);
+ if (value) {
+ free(value);
+ value = NULL;
+ }
+ return ret;
}
-static int __insert_manifest_in_db(char *manifest)
+static int __add_pkg_filter()
{
int ret = 0;
- if (manifest == NULL) {
- printf("Manifest file is NULL\n");
+ int choice = -1;
+ char *value = NULL;
+ int val = -1;
+ int count = 0;
+ pkgmgrinfo_pkginfo_filter_h handle;
+ ret = pkgmgrinfo_pkginfo_filter_create(&handle);
+ if (ret > 0) {
+ printf("pkginfo filter handle create failed\n");
+ return -1;
+ }
+ while (choice != 0 && choice !=1)
+ {
+ printf("Enter Choice\n");
+ printf("0 --> Finalize filter and get count of packages\n");
+ printf("1 --> Finalize filter and get list of packages\n");
+ printf("2 --> filter by package ID\n");
+ printf("3 --> filter by package version\n");
+ printf("4 --> filter by package type\n");
+ printf("5 --> filter by package install location\n");
+ printf("6 --> filter by author name\n");
+ printf("7 --> filter by author email\n");
+ printf("8 --> filter by author href\n");
+ printf("9 --> filter by package removable [0|1]\n");
+ printf("10 --> filter by package readonly [0|1]\n");
+ printf("11 --> filter by package preload [0|1]\n");
+ printf("12 --> filter by package update [0|1]\n");
+ printf("13 --> filter by package appsetting [0|1]\n");
+ printf("14 --> filter by package support-disable [0|1]\n");
+ printf("15 --> filter by package size\n");
+ printf("16 --> filter by package installed storage[installed_internal | installed_external]\n");
+ printf("17 --> filter by package disable [0|1]\n");
+
+ choice = __get_integer_input_data();
+ switch (choice) {
+ case 0:
+ ret = pkgmgrinfo_pkginfo_filter_count(handle, &count);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_filter_count() failed\n");
+ ret = -1;
+ goto err;
+ }
+ printf("Package count = %d\n", count);
+ break;
+ case 1:
+ ret = pkgmgrinfo_pkginfo_filter_foreach_pkginfo(handle, __pkg_list_cb, NULL);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_filter_foreach_pkginfo() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 2:
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
+ PMINFO_PKGINFO_PROP_PACKAGE_ID, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 3:
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
+ PMINFO_PKGINFO_PROP_PACKAGE_VERSION, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 4:
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
+ PMINFO_PKGINFO_PROP_PACKAGE_TYPE, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 5:
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
+ PMINFO_PKGINFO_PROP_PACKAGE_INSTALL_LOCATION, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 6:
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
+ PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_NAME, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 7:
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
+ PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_EMAIL, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 8:
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
+ PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_HREF, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 9:
+ val = __get_integer_input_data();
+ ret = pkgmgrinfo_pkginfo_filter_add_bool(handle,
+ PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE, val);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 10:
+ val = __get_integer_input_data();
+ ret = pkgmgrinfo_pkginfo_filter_add_bool(handle,
+ PMINFO_PKGINFO_PROP_PACKAGE_READONLY, val);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 11:
+ val = __get_integer_input_data();
+ ret = pkgmgrinfo_pkginfo_filter_add_bool(handle,
+ PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD, val);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 12:
+ val = __get_integer_input_data();
+ ret = pkgmgrinfo_pkginfo_filter_add_bool(handle,
+ PMINFO_PKGINFO_PROP_PACKAGE_UPDATE, val);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 13:
+ val = __get_integer_input_data();
+ ret = pkgmgrinfo_pkginfo_filter_add_bool(handle,
+ PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING, val);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 14:
+ val = __get_integer_input_data();
+ ret = pkgmgrinfo_pkginfo_filter_add_bool(handle,
+ PMINFO_PKGINFO_PROP_PACKAGE_SUPPORT_DISABLE, val);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 15:
+ val = __get_integer_input_data();
+ ret = pkgmgrinfo_pkginfo_filter_add_int(handle,
+ PMINFO_PKGINFO_PROP_PACKAGE_SIZE, val);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_filter_add_int() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 16:
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
+ PMINFO_PKGINFO_PROP_PACKAGE_INSTALLED_STORAGE, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 17:
+ val = __get_integer_input_data();
+ ret = pkgmgrinfo_pkginfo_filter_add_bool(handle,
+ PMINFO_PKGINFO_PROP_PACKAGE_DISABLE, val);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+
+ default:
+ printf("Invalid filter property\n");
+ pkgmgrinfo_pkginfo_filter_destroy(handle);
+ ret = -1;
+ goto err;
+ }
+ }
+ ret = 0;
+err:
+ pkgmgrinfo_pkginfo_filter_destroy(handle);
+ if (value) {
+ free(value);
+ value = NULL;
+ }
+ return ret;
+}
+
+static int __add_arg_filter(char *key, char *value)
+{
+ int ret = 0;
+ int choice = -1;
+ int val = -1;
+ pkgmgrinfo_appinfo_filter_h handle;
+ ret = pkgmgrinfo_appinfo_filter_create(&handle);
+ if (ret > 0) {
+ printf("appinfo filter handle create failed\n");
+ return -1;
+ }
+ choice = atoi(key);
+
+ switch (choice) {
+ case 2:
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_ID, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 3:
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_COMPONENT, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 4:
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_EXEC, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 5:
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_ICON, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 6:
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_TYPE, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 7:
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_OPERATION, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 8:
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_URI, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 9:
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_MIME, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 10:
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_CATEGORY, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 11:
+ val = atoi(value);
+ ret = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_NODISPLAY, val);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 12:
+ val = atoi(value);
+ ret = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_MULTIPLE, val);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 13:
+ val = atoi(value);
+ ret = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_ONBOOT, val);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 14:
+ val = atoi(value);
+ ret = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_AUTORESTART, val);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 15:
+ val = atoi(value);
+ ret = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_TASKMANAGE, val);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 16:
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_HWACCELERATION, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 17:
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_SCREENREADER, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+
+ default:
+ __print_arg_filter_usage();
+ goto err;
+ }
+
+ ret = pkgmgrinfo_appinfo_filter_foreach_appinfo(handle, __get_app_id, NULL);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_foreach_appinfo() failed\n");
+ ret = -1;
+ goto err;
+ }
+
+err:
+ pkgmgrinfo_appinfo_filter_destroy(handle);
+ return ret;
+}
+static int __del_certinfo_from_db(char *pkgid)
+{
+ int ret = 0;
+ if (pkgid == NULL) {
+ printf("pkgid is NULL\n");
+ return -1;
+ }
+ ret = pkgmgr_installer_delete_certinfo(pkgid);
+ if (ret < 0) {
+ printf("pkgmgr_installer_delete_certinfo failed\n");
+ return -1;
+ }
+ return 0;
+}
+
+static int __get_certinfo_from_db(char *pkgid)
+{
+ if (pkgid == NULL) {
+ printf("pkgid is NULL\n");
+ return -1;
+ }
+ int ret = 0;
+ int choice = -1;
+ int i = 0;
+ const char *value = NULL;
+ pkgmgrinfo_certinfo_h handle = NULL;
+ ret = pkgmgrinfo_pkginfo_create_certinfo(&handle);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_create_certinfo failed\n");
+ return -1;
+ }
+ ret = pkgmgrinfo_pkginfo_load_certinfo(pkgid, handle);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_load_certinfo failed\n");
+ if (handle)
+ pkgmgr_pkginfo_destroy_certinfo(handle);
+ return -1;
+ }
+ while (choice != 0)
+ {
+ printf("Enter the choice to get\n");
+ printf("0 --> to get all cert values\n");
+ printf("1 --> author root certificate\n");
+ printf("2 --> author intermediate certificate\n");
+ printf("3 --> author signer certificate\n");
+ printf("4 --> distributor root certificate\n");
+ printf("5 --> distributor intermediate certificate\n");
+ printf("6 --> distributor signer certificate\n");
+ printf("7 --> distributor2 root certificate\n");
+ printf("8 --> distributor2 intermediate certificate\n");
+ printf("9 --> distributor2 signer certificate\n");
+ printf("10 --> exit\n");
+ choice = __get_integer_input_data();
+ switch (choice) {
+ case 0:
+ for (i = 0; i < 9; i++)
+ {
+ pkgmgrinfo_pkginfo_get_cert_value(handle, i, &value);
+ if (value)
+ printf("cert type[%d] value = %s\n", i, value);
+ }
+ ret = pkgmgrinfo_pkginfo_destroy_certinfo(handle);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_destroy_certinfo failed\n");
+ ret = -1;
+ goto end;
+ }
+ ret = 0;
+ goto end;
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ case 9:
+ ret = pkgmgrinfo_pkginfo_get_cert_value(handle, choice - 1, &value);
+ if (value)
+ printf("cert type[%d] value = %s\n", choice - 1, value);
+ break;
+ case 10:
+ ret = pkgmgrinfo_pkginfo_destroy_certinfo(handle);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_destroy_certinfo failed\n");
+ return -1;
+ }
+ ret = 0;
+ goto end;
+ default:
+ printf("Invalid choice entered\n");
+ ret = -1;
+ break;
+ }
+ }
+
+end:
+ return ret;
+}
+
+static int __compare_pkg_certinfo_from_db(char *lhs_pkgid, char *rhs_pkgid)
+{
+ if (lhs_pkgid == NULL || rhs_pkgid == NULL) {
+ printf("pkgid is NULL\n");
+ return -1;
+ }
+
+ int ret = 0;
+ pkgmgrinfo_cert_compare_result_type_e result;
+ ret = pkgmgrinfo_pkginfo_compare_pkg_cert_info(lhs_pkgid, rhs_pkgid, &result);
+ if (ret != PMINFO_R_OK) {
+ return -1;
+ }
+
+ printf("Compare [match=0, mismatch=1, lhs_no=2, rhs_no=3, both_no=4]\n");
+ printf("pkgid =[%s] and [%s] compare result = [%d] \n", lhs_pkgid, rhs_pkgid, result);
+ return 0;
+}
+
+static int __compare_app_certinfo_from_db(char *lhs_appid, char *rhs_appid)
+{
+ if (lhs_appid == NULL || rhs_appid == NULL) {
+ printf("appid is NULL\n");
+ return -1;
+ }
+
+ int ret = 0;
+ pkgmgrinfo_cert_compare_result_type_e result;
+ ret = pkgmgrinfo_pkginfo_compare_app_cert_info(lhs_appid, rhs_appid, &result);
+ if (ret != PMINFO_R_OK) {
+ return -1;
+ }
+
+ printf("Compare [match=0, mismatch=1, lhs_no=2, rhs_no=3, both_no=4]\n");
+ printf("appid =[%s] and [%s] compare result = [%d] \n", lhs_appid, rhs_appid, result);
+ return 0;
+}
+
+static int __set_certinfo_in_db(char *pkgid)
+{
+ if (pkgid == NULL) {
+ printf("pkgid is NULL\n");
+ return -1;
+ }
+ int ret = 0;
+ int choice = -1;
+ char *value = NULL;
+ pkgmgr_instcertinfo_h handle = NULL;
+ ret = pkgmgr_installer_create_certinfo_set_handle(&handle);
+ if (ret < 0) {
+ printf("pkgmgr_installer_create_certinfo_set_handle failed\n");
+ return -1;
+ }
+ while (choice != 0)
+ {
+ printf("Enter the choice you want to set\n");
+ printf("0 --> to set data in DB\n");
+ printf("1 --> author root certificate\n");
+ printf("2 --> author intermediate certificate\n");
+ printf("3 --> author signer certificate\n");
+ printf("4 --> distributor root certificate\n");
+ printf("5 --> distributor intermediate certificate\n");
+ printf("6 --> distributor signer certificate\n");
+ printf("7 --> distributor2 root certificate\n");
+ printf("8 --> distributor2 intermediate certificate\n");
+ printf("9 --> distributor2 signer certificate\n");
+ choice = __get_integer_input_data();
+ switch (choice) {
+ case 0:
+ ret = pkgmgr_installer_save_certinfo(pkgid, handle);
+ if (ret < 0) {
+ printf("pkgmgr_installer_save_certinfo failed\n");
+ pkgmgr_installer_destroy_certinfo_set_handle(handle);
+ return -1;
+ }
+ ret = pkgmgr_installer_destroy_certinfo_set_handle(handle);
+ if (ret < 0) {
+ printf("pkgmgr_installer_destroy_certinfo_set_handle failed\n");
+ return -1;
+ }
+ return 0;
+ case 1:
+ printf("Enter Author Root Certificate Value: \n");
+ value = __get_string_input_data();
+ ret = pkgmgr_installer_set_cert_value(handle, 0, value);
+ if (ret < 0) {
+ printf("pkgmgr_installer_set_cert_value failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 2:
+ printf("Enter Author Intermediate Certificate Value: \n");
+ value = __get_string_input_data();
+ ret = pkgmgr_installer_set_cert_value(handle, 1, value);
+ if (ret < 0) {
+ printf("pkgmgr_installer_set_cert_value failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 3:
+ printf("Enter Author Signer Certificate Value: \n");
+ value = __get_string_input_data();
+ ret = pkgmgr_installer_set_cert_value(handle, 2, value);
+ if (ret < 0) {
+ printf("pkgmgr_installer_set_cert_value failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 4:
+ printf("Enter Distributor Root Certificate Value: \n");
+ value = __get_string_input_data();
+ ret = pkgmgr_installer_set_cert_value(handle, 3, value);
+ if (ret < 0) {
+ printf("pkgmgr_installer_set_cert_value failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 5:
+ printf("Enter Distributor Intermediate Certificate Value: \n");
+ value = __get_string_input_data();
+ ret = pkgmgr_installer_set_cert_value(handle, 4, value);
+ if (ret < 0) {
+ printf("pkgmgr_installer_set_cert_value failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 6:
+ printf("Enter Distributor Signer Certificate Value: \n");
+ value = __get_string_input_data();
+ ret = pkgmgr_installer_set_cert_value(handle, 5, value);
+ if (ret < 0) {
+ printf("pkgmgr_installer_set_cert_value failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 7:
+ printf("Enter Distributor2 Root Certificate Value: \n");
+ value = __get_string_input_data();
+ ret = pkgmgr_installer_set_cert_value(handle, 6, value);
+ if (ret < 0) {
+ printf("pkgmgr_installer_set_cert_value failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 8:
+ printf("Enter Distributor2 Intermediate Certificate Value: \n");
+ value = __get_string_input_data();
+ ret = pkgmgr_installer_set_cert_value(handle, 7, value);
+ if (ret < 0) {
+ printf("pkgmgr_installer_set_cert_value failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 9:
+ printf("Enter Distributor2 Signer Certificate Value: \n");
+ value = __get_string_input_data();
+ ret = pkgmgr_installer_set_cert_value(handle, 8, value);
+ if (ret < 0) {
+ printf("pkgmgr_installer_set_cert_value failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ default:
+ printf("Invalid Number Entered\n");
+ choice = 0;
+ ret = pkgmgr_installer_destroy_certinfo_set_handle(handle);
+ if (ret < 0) {
+ printf("pkgmgr_installer_destroy_certinfo_set_handle failed\n");
+ return -1;
+ }
+ break;
+ }
+ }
+err:
+ if (value) {
+ free(value);
+ value = NULL;
+ }
+ pkgmgr_installer_destroy_certinfo_set_handle(handle);
+ return ret;
+}
+
+static int __insert_manifest_in_db(char *manifest)
+{
+ int ret = 0;
+ if (manifest == NULL) {
+ printf("Manifest file is NULL\n");
+ return -1;
+ }
+ ret = pkgmgr_parser_parse_manifest_for_installation(manifest, NULL);
+ if (ret < 0) {
+ printf("insert in db failed\n");
+ return -1;
+ }
+ return 0;
+}
+
+static int __fota_insert_manifest_in_db(char *manifest)
+{
+ int ret = 0;
+ char *temp[] = {"fota=true", NULL};
+
+ if (manifest == NULL) {
+ printf("Manifest file is NULL\n");
+ return -1;
+ }
+ ret = pkgmgr_parser_parse_manifest_for_installation(manifest, temp);
+ if (ret < 0) {
+ printf("insert in db failed\n");
+ return -1;
+ }
+ return 0;
+}
+
+static int __remove_manifest_from_db(char *manifest)
+{
+ int ret = 0;
+ if (manifest == NULL) {
+ printf("Manifest file is NULL\n");
+ return -1;
+ }
+ ret = pkgmgr_parser_parse_manifest_for_uninstallation(manifest, NULL);
+ if (ret < 0) {
+ printf("remove from db failed\n");
+ return -1;
+ }
+ return 0;
+}
+
+int app_func(const pkgmgrinfo_appinfo_h handle, void *user_data)
+{
+ char *appid;
+ char *data = NULL;
+ if (user_data) {
+ data = (char *)user_data;
+ }
+ int ret = -1;
+ char *exec = NULL;
+ char *icon = NULL;
+ char *label = NULL;
+ pkgmgrinfo_app_component component = 0;
+ char *apptype = NULL;
+ bool nodisplay = 0;
+ bool multiple = 0;
+ bool taskmanage = 0;
+ pkgmgrinfo_app_hwacceleration hwacceleration;
+ pkgmgrinfo_app_screenreader screenreader;
+ bool support_disable = 0;
+ bool onboot = 0;
+ bool autorestart = 0;
+ char *package = NULL;
+
+ ret = pkgmgrinfo_appinfo_get_appid(handle, &appid);
+ if (ret < 0) {
+ printf("Failed to get appid\n");
+ }
+ if (appid)
+ printf("Appid: %s\n", appid);
+
+ ret = pkgmgrinfo_appinfo_get_pkgid(handle, &package);
+ if (ret < 0) {
+ printf("Failed to get package\n");
+ }
+ if (package)
+ printf("Package: %s\n", package);
+
+ ret = pkgmgrinfo_appinfo_get_exec(handle, &exec);
+ if (ret < 0) {
+ printf("Failed to get exec\n");
+ }
+ if (exec)
+ printf("Exec: %s\n", exec);
+
+ ret = pkgmgrinfo_appinfo_get_icon(handle, &icon);
+ if (ret < 0) {
+ printf("Failed to get icon\n");
+ }
+ if (icon)
+ printf("Icon: %s\n", icon);
+
+ ret = pkgmgrinfo_appinfo_get_label(handle, &label);
+ if (ret < 0) {
+ printf("Failed to get label\n");
+ }
+ if (label)
+ printf("Label: %s\n", label);
+
+ ret = pkgmgrinfo_appinfo_get_component(handle, &component);
+ if (ret < 0) {
+ printf("Failed to get component\n");
+ }
+
+ ret = pkgmgrinfo_appinfo_get_apptype(handle, &apptype);
+ if (ret < 0) {
+ printf("Failed to get apptype\n");
+ }
+ if (apptype)
+ printf("Apptype: %s\n", apptype);
+
+ if (component == PMINFO_UI_APP) {
+ printf("component: uiapp\n");
+ ret = pkgmgrinfo_appinfo_is_multiple(handle, &multiple);
+ if (ret < 0) {
+ printf("Failed to get multiple\n");
+ } else {
+ printf("Multiple: %d\n", multiple);
+ }
+
+ ret = pkgmgrinfo_appinfo_is_nodisplay(handle, &nodisplay);
+ if (ret < 0) {
+ printf("Failed to get nodisplay\n");
+ } else {
+ printf("Nodisplay: %d \n", nodisplay);
+ }
+
+ ret = pkgmgrinfo_appinfo_is_taskmanage(handle, &taskmanage);
+ if (ret < 0) {
+ printf("Failed to get taskmanage\n");
+ } else {
+ printf("Taskmanage: %d\n", taskmanage);
+ }
+
+ ret = pkgmgrinfo_appinfo_get_hwacceleration(handle, &hwacceleration);
+ if (ret < 0) {
+ printf("Failed to get hwacceleration\n");
+ } else {
+ printf("hw-acceleration: %d\n", hwacceleration);
+ }
+
+ ret = pkgmgrinfo_appinfo_get_screenreader(handle, &screenreader);
+ if (ret < 0) {
+ printf("Failed to get screenreader\n");
+ } else {
+ printf("screenreader: %d\n", screenreader);
+ }
+
+ ret = pkgmgrinfo_appinfo_is_support_disable(handle, &support_disable);
+ if (ret < 0) {
+ printf("Failed to get support-disable\n");
+ } else {
+ printf("support-disable: %d\n", support_disable);
+ }
+ }
+ if (component == PMINFO_SVC_APP) {
+ printf("component: svcapp\n");
+ ret = pkgmgrinfo_appinfo_is_onboot(handle, &onboot);
+ if (ret < 0) {
+ printf("Failed to get onboot\n");
+ } else {
+ printf("Onboot: %d\n", onboot);
+ }
+
+ ret = pkgmgrinfo_appinfo_is_autorestart(handle, &autorestart);
+ if (ret < 0) {
+ printf("Failed to get autorestart\n");
+ } else {
+ printf("Autorestart: %d \n", autorestart);
+ }
+ }
+ if (data)
+ printf("user_data : %s\n\n", data);
+
+ return 0;
+}
+
+
+static int __pkg_list_cb (const pkgmgrinfo_pkginfo_h handle, void *user_data)
+{
+ char *test_data = "test data";
+ int ret = -1;
+ char *pkgid;
+ char *pkg_type;
+ char *pkg_version;
+ bool preload = 0;
+ bool support_disable = 0;
+ int installed_time = -1;
+
+ ret = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
+ if(ret < 0) {
+ printf("pkgmgrinfo_pkginfo_get_pkgid() failed\n");
+ }
+ ret = pkgmgrinfo_pkginfo_get_type(handle, &pkg_type);
+ if(ret < 0) {
+ printf("pkgmgrinfo_pkginfo_get_type() failed\n");
+ }
+ ret = pkgmgrinfo_pkginfo_get_version(handle, &pkg_version);
+ if(ret < 0) {
+ printf("pkgmgrinfo_pkginfo_get_version() failed\n");
+ }
+ ret = pkgmgrinfo_pkginfo_is_preload(handle, &preload);
+ if(ret < 0) {
+ printf("pkgmgrinfo_pkginfo_is_preload() failed\n");
+ }
+ ret = pkgmgrinfo_pkginfo_is_support_disable(handle, &support_disable);
+ if(ret < 0) {
+ printf("pkgmgrinfo_pkginfo_is_support_disable() failed\n");
+ }
+ ret = pkgmgrinfo_pkginfo_get_installed_time(handle, &installed_time);
+ if(ret < 0) {
+ printf("pkgmgrinfo_pkginfo_get_installed_time() failed\n");
+ }
+
+
+ printf("---------------------------------------\n");
+ printf("pkg_type [%s]\tpkgid [%s]\tversion [%s]\tpreload [%d]\tsupport-disable [%d]\tinstalled_time [%d]\n", pkg_type,
+ pkgid, pkg_version, preload, support_disable, installed_time);
+
+ printf("**List of Ui-Apps**\n");
+ ret = pkgmgrinfo_appinfo_get_list(handle, PM_UI_APP, app_func, (void *)test_data);
+ if (ret < 0) {
+ printf("pkgmgrinfo_get_info_app() failed\n");
+ }
+ printf("**List of Svc-Apps**\n");
+ ret = pkgmgrinfo_appinfo_get_list(handle, PM_SVC_APP, app_func, (void *)test_data);
+ if (ret < 0) {
+ printf("pkgmgrinfo_get_info_app() failed\n");
+ }
+
+ printf("---------------------------------------\n");
+
+ return 0;
+}
+
+static int __get_pkg_list()
+{
+ int ret = -1;
+ ret = pkgmgrinfo_pkginfo_get_list(__pkg_list_cb, NULL);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_get_list() failed\n");
+ return -1;
+ }
+ return 0;
+}
+
+static int __get_installed_app_list()
+{
+ int ret = -1;
+ ret = pkgmgrinfo_appinfo_get_installed_list(app_func, NULL);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_get_installed_list() failed\n");
+ return -1;
+ }
+ return 0;
+}
+
+static int __app_category_list_cb(const char *category_name, void *user_data)
+{
+ if (category_name)
+ printf("Category: %s\n", category_name);
+ return 0;
+}
+
+static int __app_metadata_list_cb(const char *metadata_name, const char *metadata_value, void *user_data)
+{
+ if (metadata_name && metadata_value) {
+ printf("Name: %s\n", metadata_name);
+ printf("Value: %s\n", metadata_value);
+ printf("\n");
+ }
+ return 0;
+}
+
+static int __app_control_list_cb(pkgmgrinfo_appcontrol_h handle, void *user_data)
+{
+ printf("-------------------------------------------------------\n");
+ int i = 0;
+ int ret = 0;
+ int oc = 0;
+ int mc = 0;
+ int uc = 0;
+ int sc = 0;
+ char **operation = NULL;
+ char **uri = NULL;
+ char **mime = NULL;
+ char **subapp = NULL;
+
+ ret = pkgmgrinfo_appinfo_get_operation(handle, &oc, &operation);
+ if (ret < 0) {
+ printf("Get Operation Failed\n");
+ return -1;
+ }
+ ret = pkgmgrinfo_appinfo_get_uri(handle, &uc, &uri);
+ if (ret < 0) {
+ printf("Get Uri Failed\n");
+ return -1;
+ }
+ ret = pkgmgrinfo_appinfo_get_mime(handle, &mc, &mime);
+ if (ret < 0) {
+ printf("Get Mime Failed\n");
+ return -1;
+ }
+ ret = pkgmgrinfo_appinfo_get_subapp(handle, &sc, &subapp);
+ if (ret < 0) {
+ printf("Get subapp Failed\n");
+ return -1;
+ }
+
+ for (i = 0; i < oc; i++) {
+ if (operation && operation[i])
+ printf("Operation: %s\n", operation[i]);
+ }
+ for (i = 0; i < uc; i++) {
+ if (uri && uri[i])
+ printf("Uri: %s\n", uri[i]);
+ }
+ for (i = 0; i < mc; i++) {
+ if (mime && mime[i])
+ printf("Mime: %s\n", mime[i]);
+ }
+ for (i = 0; i < sc; i++) {
+ if (subapp && subapp[i])
+ printf("subapp: %s\n", subapp[i]);
+ }
+
+ printf("-------------------------------------------------------\n\n");
+ return 0;
+}
+
+
+static int __get_app_category_list(char *appid)
+{
+ int ret = -1;
+ pkgmgrinfo_appinfo_h handle;
+ ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle);
+ if (ret < 0) {
+ printf("Failed to get handle\n");
return -1;
}
- ret = pkgmgr_parser_parse_manifest_for_installation(manifest, NULL);
+ ret = pkgmgrinfo_appinfo_foreach_category(handle, __app_category_list_cb, NULL);
if (ret < 0) {
- printf("insert in db failed\n");
+ printf("pkgmgrinfo_appinfo_foreach_category() failed\n");
+ pkgmgrinfo_appinfo_destroy_appinfo(handle);
return -1;
}
+ pkgmgrinfo_appinfo_destroy_appinfo(handle);
return 0;
}
-static int __remove_manifest_from_db(char *manifest)
+static int __get_app_metadata_list(char *appid)
{
- int ret = 0;
- if (manifest == NULL) {
- printf("Manifest file is NULL\n");
+ int ret = -1;
+ pkgmgrinfo_appinfo_h handle;
+ ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle);
+ if (ret < 0) {
+ printf("Failed to get handle\n");
return -1;
}
- ret = pkgmgr_parser_parse_manifest_for_uninstallation(manifest, NULL);
+ ret = pkgmgrinfo_appinfo_foreach_metadata(handle, __app_metadata_list_cb, NULL);
if (ret < 0) {
- printf("remove from db failed\n");
+ printf("pkgmgrinfo_appinfo_foreach_metadata() failed\n");
+ pkgmgrinfo_appinfo_destroy_appinfo(handle);
return -1;
}
+ pkgmgrinfo_appinfo_destroy_appinfo(handle);
return 0;
}
-int app_func(const pkgmgr_appinfo_h handle, const char *appid, void *user_data)
+static int __get_app_control_list(char *appid)
{
- char *data = NULL;
- if (user_data) {
- data = (char *)user_data;
- }
int ret = -1;
- char *exec = NULL;
- char *component = NULL;
- char *apptype = NULL;
- bool nodisplay = 0;
- bool multiple = 0;
- bool taskmanage = 0;
- bool onboot = 0;
- bool autorestart = 0;
- if (appid)
- printf("Appid: %s\n", appid);
-
- ret = pkgmgr_get_pkginfo_exec(handle, &exec);
- if (ret < 0) {
- printf("Failed to get exec\n");
- }
- if (exec)
- printf("Exec: %s\n", exec);
-
- ret = pkgmgr_get_pkginfo_component(handle, &component);
+ pkgmgrinfo_appinfo_h handle;
+ ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle);
if (ret < 0) {
- printf("Failed to get component\n");
+ printf("Failed to get handle\n");
+ return -1;
}
- if (component)
- printf("Component: %s\n", component);
-
- ret = pkgmgr_get_pkginfo_apptype(handle, &apptype);
+ ret = pkgmgrinfo_appinfo_foreach_appcontrol(handle, __app_control_list_cb, NULL);
if (ret < 0) {
- printf("Failed to get apptype\n");
- }
- if (apptype)
- printf("Apptype: %s\n", apptype);
-
- if (component) {
- if (strcasecmp(component, "uiapp") == 0) {
- ret = pkgmgr_get_pkginfo_multiple(handle, &multiple);
- if (ret < 0) {
- printf("Failed to get multiple\n");
- } else {
- printf("Multiple: %d\n", multiple);
- }
-
- ret = pkgmgr_get_pkginfo_nodisplay(handle, &nodisplay);
- if (ret < 0) {
- printf("Failed to get nodisplay\n");
- } else {
- printf("Nodisplay: %d \n", nodisplay);
- }
-
- ret = pkgmgr_get_pkginfo_taskmanage(handle, &taskmanage);
- if (ret < 0) {
- printf("Failed to get taskmanage\n");
- } else {
- printf("Taskmanage: %d\n", taskmanage);
- }
- }
- if (strcasecmp(component, "svcapp") == 0) {
- ret = pkgmgr_get_pkginfo_onboot(handle, &onboot);
- if (ret < 0) {
- printf("Failed to get onboot\n");
- } else {
- printf("Onboot: %d\n", onboot);
- }
-
- ret = pkgmgr_get_pkginfo_autorestart(handle, &autorestart);
- if (ret < 0) {
- printf("Failed to get autorestart\n");
- } else {
- printf("Autorestart: %d \n", autorestart);
- }
- }
+ printf("pkgmgrinfo_appinfo_foreach_appcontrol() failed\n");
+ pkgmgrinfo_appinfo_destroy_appinfo(handle);
+ return -1;
}
-
- printf("Userdata: %s\n\n\n", data);
- return 0;
-}
-
-static int __iter_fn(const char *pkg_type, const char *pkg_name,
- const char *version, void *data)
-{
- printf("pkg_type [%s]\tpkg_name [%s]\tversion [%s]\n", pkg_type,
- pkg_name, version);
+ pkgmgrinfo_appinfo_destroy_appinfo(handle);
return 0;
}
-static int __get_pkg_list()
+static int __set_app_enabled(char *appid, bool enabled)
{
int ret = -1;
- ret = pkgmgr_get_info_list(__iter_fn, NULL);
+ ret = pkgmgrinfo_appinfo_set_state_enabled(appid, enabled);
if (ret < 0) {
- printf("pkgmgr_get_info_list() failed\n");
+ printf("Failed to get handle\n");
return -1;
}
return 0;
}
-static int __get_app_list(char *pkgname)
+
+static int __get_app_list(char *pkgid)
{
- pkgmgr_pkginfo_h handle;
+ pkgmgrinfo_pkginfo_h handle;
int ret = -1;
char *test_data = "test data";
- ret = pkgmgr_get_pkginfo(pkgname, &handle);
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
if (ret < 0) {
printf("Failed to get handle\n");
return -1;
}
printf("List of Ui-Apps\n\n");
- ret = pkgmgr_get_info_app(handle, PM_UI_APP, app_func, (void *)test_data);
+ ret = pkgmgrinfo_appinfo_get_list(handle, PM_UI_APP, app_func, (void *)test_data);
if (ret < 0) {
- printf("pkgmgr_get_info_app() failed\n");
+ printf("pkgmgrinfo_appinfo_get_list() failed\n");
}
printf("List of Svc-Apps\n\n");
- ret = pkgmgr_get_info_app(handle, PM_SVC_APP, app_func, (void *)test_data);
+ ret = pkgmgrinfo_appinfo_get_list(handle, PM_SVC_APP, app_func, (void *)test_data);
if (ret < 0) {
- printf("pkgmgr_get_info_app() failed\n");
+ printf("pkgmgrinfo_appinfo_get_list() failed\n");
}
- pkgmgr_destroy_pkginfo(handle);
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
return 0;
}
-static int __get_pkg_info(char *pkgname)
+static int __get_pkg_info(char *pkgid)
{
- pkgmgr_pkginfo_h handle;
+ pkgmgrinfo_pkginfo_h handle;
int ret = -1;
- char *type = NULL;
- char *version = NULL;
- char *author_name = NULL;
- char *author_email = NULL;
- char *author_href = NULL;
- pkgmgr_install_location location = 1;
+
+ printf("Get Pkg Info Called [%s]\n", pkgid);
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+ if (ret < 0) {
+ printf("Failed to get handle\n");
+ return -1;
+ }
+
+ __get_pkgmgrinfo_pkginfo(handle, NULL);
+
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ return 0;
+}
+
+static int __get_app_info(char *appid)
+{
+ printf("Get App Info Called [%s]\n", appid);
+ char *exec = NULL;
+ char *app_id = NULL;
+ char *apptype = NULL;
+ char *pkgtype = NULL;
char *icon = NULL;
char *label = NULL;
- char *desc = NULL;
- bool removable = 0;
+ char *package = NULL;
+ pkgmgrinfo_app_component component = 0;
+ bool nodisplay = 0;
+ bool multiple = 0;
+ bool taskmanage = 0;
+ pkgmgrinfo_app_hwacceleration hwacceleration;
+ pkgmgrinfo_app_screenreader screenreader;
+ bool onboot = 0;
+ bool autorestart = 0;
+ bool enabled = 0;
bool preload = 0;
- bool readonly = 0;
+ bool support_disable = 0;
+ bool system = 0;
+ char* effectimage_type = NULL;
+ pkgmgrinfo_appinfo_h handle;
+ int ret = -1;
+ int installed_time = -1;
- printf("Get Pkg Info Called [%s]\n", pkgname);
- ret = pkgmgr_get_pkginfo(pkgname, &handle);
+ ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle);
if (ret < 0) {
printf("Failed to get handle\n");
return -1;
}
- ret = pkgmgr_get_pkginfo_version(handle, &version);
+ ret = pkgmgrinfo_appinfo_get_pkgid(handle, &package);
if (ret < 0) {
- printf("Failed to get version\n");
+ printf("Failed to get package\n");
}
- if (version)
- printf("Version: %s\n", version);
- ret = pkgmgr_get_pkginfo_install_location(handle, &location);
+ ret = pkgmgrinfo_appinfo_get_appid(handle, &app_id);
if (ret < 0) {
- printf("Failed to get install location\n");
+ printf("Failed to get exec\n");
}
- printf("Install Location: %d\n", location);
- ret = pkgmgr_get_pkginfo_label(handle, &label);
+ ret = pkgmgrinfo_appinfo_get_label(handle, &label);
if (ret < 0) {
printf("Failed to get label\n");
}
- if (label)
- printf("Label: %s\n", label);
-
- ret = pkgmgr_get_pkginfo_icon(handle, &icon);
+ ret = pkgmgrinfo_appinfo_get_icon(handle, &icon);
if (ret < 0) {
printf("Failed to get icon\n");
}
- if (icon)
- printf("Icon: %s\n", icon);
- ret = pkgmgr_get_pkginfo_description(handle, &desc);
+ ret = pkgmgrinfo_appinfo_get_exec(handle, &exec);
if (ret < 0) {
- printf("Failed to get description\n");
+ printf("Failed to get exec\n");
}
- if (desc)
- printf("Description: %s\n", desc);
-
- ret = pkgmgr_get_pkginfo_type(handle, &type);
+ ret = pkgmgrinfo_appinfo_get_component(handle, &component);
if (ret < 0) {
- printf("Failed to get pkg type\n");
+ printf("Failed to get component\n");
}
- if (type)
- printf("Type: %s\n", type);
-
- ret = pkgmgr_get_pkginfo_author_name(handle, &author_name);
+ ret = pkgmgrinfo_appinfo_get_apptype(handle, &apptype);
if (ret < 0) {
- printf("Failed to get author name\n");
+ printf("Failed to get apptype\n");
}
- if (author_name)
- printf("Author Name: %s\n", author_name);
-
- ret = pkgmgr_get_pkginfo_author_email(handle, &author_email);
+ ret = pkgmgrinfo_appinfo_get_pkgtype(handle, &pkgtype);
if (ret < 0) {
- printf("Failed to get author email\n");
+ printf("Failed to get pkgtyp\n");
}
- if (author_email)
- printf("Author Email: %s\n", author_email);
-
- ret = pkgmgr_get_pkginfo_author_href(handle, &author_href);
+ ret = pkgmgrinfo_appinfo_is_nodisplay(handle, &nodisplay);
if (ret < 0) {
- printf("Failed to get author href\n");
+ printf("Failed to get nodisplay\n");
}
- if (author_href)
- printf("Author Href: %s\n", author_href);
-
- ret = pkgmgr_get_pkginfo_removable(handle, &removable);
+ ret = pkgmgrinfo_appinfo_is_multiple(handle, &multiple);
if (ret < 0) {
- printf("Failed to get removable\n");
+ printf("Failed to get multiple\n");
}
- else
- printf("Removable: %d\n", removable);
-
- ret = pkgmgr_get_pkginfo_preload(handle, &preload);
+ ret = pkgmgrinfo_appinfo_is_taskmanage(handle, &taskmanage);
if (ret < 0) {
- printf("Failed to get preload\n");
+ printf("Failed to get taskmanage\n");
}
- else
- printf("Preload: %d\n", preload);
-
- ret = pkgmgr_get_pkginfo_readonly(handle, &readonly);
+ ret = pkgmgrinfo_appinfo_get_hwacceleration(handle, &hwacceleration);
if (ret < 0) {
- printf("Failed to get readonly\n");
+ printf("Failed to get hwacceleration\n");
}
- else
- printf("Readonly: %d\n", readonly);
-
- pkgmgr_destroy_pkginfo(handle);
- return 0;
-}
-
-static int __get_app_info(char *appid)
-{
- printf("Get App Info Called [%s]\n", appid);
- char *exec = NULL;
- char *apptype = NULL;
- char *component = NULL;
- bool nodisplay = 0;
- bool multiple = 0;
- bool taskmanage = 0;
- bool onboot = 0;
- bool autorestart = 0;
- pkgmgr_appinfo_h handle;
- int ret = -1;
-
- ret = pkgmgr_get_appinfo(appid, &handle);
+ ret = pkgmgrinfo_appinfo_get_screenreader(handle, &screenreader);
if (ret < 0) {
- printf("Failed to get handle\n");
- return -1;
+ printf("Failed to get screenreader\n");
}
- ret = pkgmgr_get_pkginfo_exec(handle, &exec);
+ ret = pkgmgrinfo_appinfo_is_onboot(handle, &onboot);
if (ret < 0) {
- printf("Failed to get exec\n");
+ printf("Failed to get onboot\n");
}
- ret = pkgmgr_get_pkginfo_component(handle, &component);
+ ret = pkgmgrinfo_appinfo_is_autorestart(handle, &autorestart);
if (ret < 0) {
- printf("Failed to get component\n");
+ printf("Failed to get autorestart\n");
}
- ret = pkgmgr_get_pkginfo_apptype(handle, &apptype);
+ ret = pkgmgrinfo_appinfo_is_enabled(handle, &enabled);
if (ret < 0) {
- printf("Failed to get apptype\n");
+ printf("Failed to get enabled\n");
}
- ret = pkgmgr_get_pkginfo_multiple(handle, &multiple);
+ ret = pkgmgrinfo_appinfo_is_preload(handle, &preload);
if (ret < 0) {
- printf("Failed to get multiple\n");
+ printf("Failed to get preload\n");
}
- ret = pkgmgr_get_pkginfo_nodisplay(handle, &nodisplay);
+ ret = pkgmgrinfo_appinfo_is_system(handle, &system);
if (ret < 0) {
- printf("Failed to get nodisplay\n");
+ printf("Failed to get system\n");
}
- ret = pkgmgr_get_pkginfo_taskmanage(handle, &taskmanage);
+ ret = pkgmgrinfo_appinfo_is_support_disable(handle, &support_disable);
if (ret < 0) {
- printf("Failed to get taskmanage\n");
+ printf("Failed to get support-disable\n");
}
- ret = pkgmgr_get_pkginfo_onboot(handle, &onboot);
+ ret = pkgmgrinfo_appinfo_get_effectimage_type(handle, &effectimage_type);
if (ret < 0) {
- printf("Failed to get onboot\n");
+ printf("Failed to get effectimage-type\n");
}
- ret = pkgmgr_get_pkginfo_autorestart(handle, &autorestart);
+ ret = pkgmgrinfo_appinfo_get_installed_time(handle, &installed_time);
if (ret < 0) {
- printf("Failed to get autorestart\n");
+ printf("Failed to get effectimage-type\n");
}
+ if (app_id)
+ printf("Appid: %s\n", app_id);
+
+ if (package)
+ printf("Package: %s\n", package);
+
if (exec)
printf("Exec: %s\n", exec);
+
if (apptype)
printf("Apptype: %s\n", apptype);
- if (component)
- printf("Component: %s\n", component);
- if (component) {
- if (strcasecmp(component, "uiapp") == 0) {
- printf("Nodisplay: %d\n", nodisplay);
- printf("Multiple: %d\n", multiple);
- printf("Taskmanage: %d\n", taskmanage);
- } else if (strcasecmp(component, "svcapp") == 0) {
- printf("Autorestart: %d\n", autorestart);
- printf("Onboot: %d\n", onboot);
- } else {
- printf("Invalid Component Type\n");
- }
+
+ if (pkgtype)
+ printf("Pkgtype: %s\n", pkgtype);
+
+ if (component == PMINFO_UI_APP) {
+ printf("component: uiapp\n");
+
+ if (icon)
+ printf("Icon: %s\n", icon);
+ if (label)
+ printf("Label: %s\n", label);
+
+ printf("Nodisplay: %d\n", nodisplay);
+ printf("Multiple: %d\n", multiple);
+ printf("Taskmanage: %d\n", taskmanage);
+ printf("Hw-Acceleration: %d\n", hwacceleration);
+ printf("Screenreader: %d\n", screenreader);
+ } else if (component == PMINFO_SVC_APP) {
+ printf("component: svcapp\n");
+
+ if (icon)
+ printf("Icon: %s\n", icon);
+ if (label)
+ printf("Label: %s\n", label);
+
+ printf("Autorestart: %d\n", autorestart);
+ printf("Onboot: %d\n", onboot);
+ } else {
+ printf("Invalid Component Type\n");
}
- pkgmgr_destroy_appinfo(handle);
+
+ printf("Enabled: %d\n", enabled);
+ printf("Preload: %d\n", preload);
+ printf("System: %d\n", system);
+ printf("Support-Disable: %d\n", support_disable);
+ printf("Installed-Time: %d\n", installed_time);
+
+ if (effectimage_type)
+ printf("Effectimage-Type: %s\n", effectimage_type);
+
+ pkgmgrinfo_appinfo_destroy_appinfo(handle);
return 0;
}
int main(int argc, char *argv[])
{
- int ret = -1;
+ int ret = 0;
char *locale = NULL;
+ long starttime;
+ long endtime;
+ struct timeval tv;
+ char option[PKG_VALUE_STRING_LEN_MAX + 1] = {0,};
+
+ gettimeofday(&tv, NULL);
+ starttime = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
+
+ snprintf(option, PKG_VALUE_STRING_LEN_MAX, "%s", argv[1]);
+
locale = vconf_get_str(VCONFKEY_LANGSET);
- if (locale == NULL) {
+ if (locale == NULL)
printf("locale is NULL\n");
- return -1;
- }
- else
+ else {
printf("Locale is %s\n", locale);
- free(locale);
+ free(locale);
+ }
+
locale = NULL;
if (argc == 2) {
- if (strcmp(argv[1], "--list") == 0) {
+ if (strcmp(option, "--listpkg") == 0) {
ret = __get_pkg_list();
if (ret == -1) {
printf("get pkg list failed\n");
- return -1;
+ goto end;
+ } else {
+ goto end;
+ }
+ } else if (strcmp(option, "--app-flt") == 0) {
+ ret = __add_app_filter();
+ if (ret == -1) {
+ printf("Adding app filter failed\n");
+ goto end;
+ } else {
+ goto end;
+ }
+ } else if (strcmp(option, "--pkg-flt") == 0) {
+ ret = __add_pkg_filter();
+ if (ret == -1) {
+ printf("Adding pkg filter failed\n");
+ goto end;
+ } else {
+ goto end;
+ }
+ } else if (strcmp(option, "--metadata-flt") == 0) {
+ ret = __add_metadata_filter();
+ if (ret == -1) {
+ printf("Adding pkg filter failed\n");
+ goto end;
} else {
- return 0;
+ goto end;
+ }
+ } else if (strcmp(option, "--listapp") == 0) {
+ ret = __get_installed_app_list();
+ if (ret == -1) {
+ printf("get installed app list failed\n");
+ goto end;
+ } else {
+ goto end;
+ }
+ } else {
+ __print_usage();
+ ret = -1;
+ goto end;
+ }
+ }else if (argc == 4) {
+ if (strcmp(option, "--setappenabled") == 0) {
+ ret = __set_app_enabled(argv[2], (strcmp(argv[3], "0")==0)?false:true);
+ if (ret == -1) {
+ printf("set app enabled failed\n");
+ goto end;
+ }
+ goto end;
+ } else if(strcmp(option, "--setpkgenabled") == 0) {
+ ret = __set_app_enabled(argv[2], (strcmp(argv[3], "0")==0)?false:true);
+ if (ret == -1) {
+ printf("set pkg enabled failed\n");
+ goto end;
+ }
+ goto end;
+ } else if (strcmp(option, "--cmp-pkgcert") == 0) {
+ int len = 0;
+ char *r_pkgid = NULL;
+ char *l_pkgid = NULL;
+
+ len = (strlen(argv[2]) + 1);
+ r_pkgid = (char *)calloc(len, sizeof(char));
+ if(r_pkgid == NULL)
+ goto end;
+ strncpy(r_pkgid, argv[2], len - 1);
+
+ len = (strlen(argv[3]) + 1);
+ l_pkgid = (char *)calloc(len, sizeof(char));
+ if(l_pkgid == NULL) {
+ free(r_pkgid);
+ goto end;
+ }
+ strncpy(l_pkgid, argv[3], len - 1);
+
+ ret = __compare_pkg_certinfo_from_db(r_pkgid, l_pkgid);
+ if (ret == -1) {
+ printf("compare certinfo from db failed\n");
+ }
+ free(l_pkgid);
+ free(r_pkgid);
+ goto end;
+ } else if (strcmp(option, "--cmp-appcert") == 0) {
+ ret = __compare_app_certinfo_from_db(argv[2], argv[3]);
+ if (ret == -1) {
+ printf("compare certinfo from db failed\n");
+ goto end;
+ }
+ goto end;
+ } else if (strcmp(option, "--arg-flt") == 0) {
+ ret = __add_arg_filter(argv[2], argv[3]);
+ if (ret == -1) {
+ printf("compare certinfo from db failed\n");
+ goto end;
}
+ goto end;
} else {
__print_usage();
- return -1;
+ ret = -1;
+ goto end;
}
}
+
if (argc != 3) {
__print_usage();
- return -1;
+ ret = -1;
+ goto end;
}
if (!argv[1] || !argv[2]) {
__print_usage();
- return -1;
+ ret = -1;
+ goto end;
}
- if (strcmp(argv[1], "--pkg") == 0) {
+ if (strcmp(option, "--pkg") == 0) {
ret = __get_pkg_info(argv[2]);
if (ret == -1) {
printf("get pkg info failed\n");
- return -1;
+ goto end;
}
- } else if (strcmp(argv[1], "--app") == 0) {
+ } else if (strcmp(option, "--app") == 0) {
ret = __get_app_info(argv[2]);
if (ret == -1) {
printf("get app info failed\n");
- return -1;
+ goto end;
}
- } else if (strcmp(argv[1], "--list") == 0) {
+ } else if (strcmp(option, "--list") == 0) {
ret = __get_app_list(argv[2]);
if (ret == -1) {
printf("get app list failed\n");
- return -1;
+ goto end;
+ }
+ } else if (strcmp(option, "--imd") == 0) {
+ ret = __check_manifest_validation(argv[2]);
+ if (ret == -1) {
+ printf("check manifest failed\n");
+ goto end;
}
- } else if (strcmp(argv[1], "--imd") == 0) {
+
ret = __insert_manifest_in_db(argv[2]);
if (ret == -1) {
printf("insert in db failed\n");
- return -1;
+ goto end;
+ }
+ } else if (strcmp(option, "--fota") == 0) {
+ ret = __fota_insert_manifest_in_db(argv[2]);
+ if (ret == -1) {
+ printf("insert in db failed\n");
+ goto end;
}
- } else if (strcmp(argv[1], "--rmd") == 0) {
+ } else if (strcmp(option, "--rmd") == 0) {
ret = __remove_manifest_from_db(argv[2]);
if (ret == -1) {
printf("remove from db failed\n");
- return -1;
+ goto end;
+ }
+ } else if (strcmp(option, "--setcert") == 0) {
+ ret = __set_certinfo_in_db(argv[2]);
+ if (ret == -1) {
+ printf("set certinfo in db failed\n");
+ goto end;
}
- } else if (strcmp(argv[1], "--setdb") == 0) {
- ret = __set_pkginfo_in_db(argv[2]);
+ } else if (strcmp(option, "--getcert") == 0) {
+ ret = __get_certinfo_from_db(argv[2]);
if (ret == -1) {
- printf("set pkginfo in db failed\n");
- return -1;
+ printf("get certinfo from db failed\n");
+ goto end;
}
- } else if (strcmp(argv[1], "--check") == 0) {
+ } else if (strcmp(option, "--delcert") == 0) {
+ ret = __del_certinfo_from_db(argv[2]);
+ if (ret == -1) {
+ printf("del certinfo from db failed\n");
+ goto end;
+ }
+ } else if (strcmp(option, "--check") == 0) {
ret = __check_manifest_validation(argv[2]);
if (ret == -1) {
printf("check manifest failed\n");
- return -1;
+ goto end;
+ }
+ } else if (strcmp(option, "--category") == 0) {
+ ret = __get_app_category_list(argv[2]);
+ if (ret == -1) {
+ printf("get app category list failed\n");
+ goto end;
+ }
+ } else if (strcmp(option, "--metadata") == 0) {
+ ret = __get_app_metadata_list(argv[2]);
+ if (ret == -1) {
+ printf("get app metadata list failed\n");
+ goto end;
+ }
+ } else if (strcmp(option, "--appcontrol") == 0) {
+ ret = __get_app_control_list(argv[2]);
+ if (ret == -1) {
+ printf("get app control list failed\n");
+ goto end;
}
} else
__print_usage();
- return 0;
+end:
+
+ gettimeofday(&tv, NULL);
+ endtime = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
+
+ printf("spend time for pkginfo is [%d]ms\n", (int)(endtime - starttime));
+
+ return ret;
}
#include <unistd.h>
#include <sys/stat.h>
#include <errno.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <ctype.h>
+#include <sys/time.h>
+#include <time.h>
-#include "pkgmgr_parser.h"
+#include <pkgmgr_parser.h>
+#include <pkgmgr-info.h>
#define OWNER_ROOT 0
#define GROUP_MENU 6010
#define USR_MANIFEST_DIRECTORY "/usr/share/packages"
#define PACKAGE_INFO_DB_FILE "/opt/dbspace/.pkgmgr_parser.db"
+#define PKG_PARSER_DB_FILE "/opt/dbspace/.pkgmgr_parser.db"
+#define PKG_PARSER_DB_FILE_JOURNAL "/opt/dbspace/.pkgmgr_parser.db-journal"
+#define PKG_CERT_DB_FILE "/opt/dbspace/.pkgmgr_cert.db"
+#define PKG_CERT_DB_FILE_JOURNAL "/opt/dbspace/.pkgmgr_cert.db-journal"
+#define PKG_INFO_DB_LABEL "pkgmgr::db"
+
+#define TOKEN_TYPE_STR "type="
+#define TOKEN_PKGID_STR "package="
+
+#define SEPERATOR_START '"'
+#define SEPERATOR_END '"'
+
#ifdef _E
#undef _E
#endif
-#define _E(fmt, arg...) fprintf(stderr, "[PKG_INITDB][E][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg);
+#define _E(fmt, arg...) fprintf(stderr, "[PKG_INITDB][E] "fmt"\n", ##arg);
#ifdef _D
#undef _D
#endif
-#define _D(fmt, arg...) fprintf(stderr, "[PKG_INITDB][D][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg);
+#define _D(fmt, arg...) fprintf(stderr, "[PKG_INITDB][D] "fmt"\n", ##arg);
static int initdb_count_package(void)
{
return total;
}
+static int initdb_xsystem(const char *argv[])
+{
+ int status = 0;
+ pid_t pid;
+ pid = fork();
+ switch (pid) {
+ case -1:
+ perror("fork failed");
+ return -1;
+ case 0:
+ /* child */
+ execvp(argv[0], (char *const *)argv);
+ _exit(-1);
+ default:
+ /* parent */
+ break;
+ }
+ if (waitpid(pid, &status, 0) == -1) {
+ perror("waitpid failed");
+ return -1;
+ }
+ if (WIFSIGNALED(status)) {
+ perror("signal");
+ return -1;
+ }
+ if (!WIFEXITED(status)) {
+ /* shouldn't happen */
+ perror("should not happen");
+ return -1;
+ }
+ return WEXITSTATUS(status);
+}
char* _manifest_to_package(const char* manifest)
return package;
}
+static void __str_trim(char *input)
+{
+ char *trim_str = input;
+
+ if (input == NULL)
+ return;
+
+ while (*input != 0) {
+ if (!isspace(*input)) {
+ *trim_str = *input;
+ trim_str++;
+ }
+ input++;
+ }
+
+ *trim_str = 0;
+ return;
+}
+
+static char * getvalue(const char* pBuf, const char* pKey)
+{
+ const char* p = NULL;
+ const char* pStart = NULL;
+ const char* pEnd = NULL;
+
+ p = strstr(pBuf, pKey);
+ if (p == NULL)
+ return NULL;
+
+ pStart = p + strlen(pKey) + 1;
+ pEnd = strchr(pStart, SEPERATOR_END);
+ if (pEnd == NULL)
+ return false;
+
+ size_t len = pEnd - pStart;
+ if (len <= 0)
+ return false;
+
+ char *pRes = (char*)malloc(len + 1);
+ if (pRes == NULL) {
+ _E("out of memory");
+ return NULL;
+ }
+
+ strncpy(pRes, pStart, len);
+ pRes[len] = 0;
+
+ return pRes;
+}
+
+static int __find_rpm_manifest(const char* manifest)
+{
+ FILE *fp = NULL;
+ char buf[BUFSZE] = {0};
+ char *pkgtype = NULL;
+
+ fp = fopen(manifest, "r");
+ if (fp == NULL) {
+ _D("Fail get : %s", manifest);
+ return -1;
+ }
+ while (fgets(buf, BUFSZE, fp) != NULL) {
+ __str_trim(buf);
+
+ pkgtype = getvalue(buf, TOKEN_TYPE_STR);
+ if (pkgtype != NULL) {
+ if ((strcmp(pkgtype,"tpk") == 0) || (strcmp(pkgtype,"wgt") == 0)) {
+ fclose(fp);
+ free(pkgtype);
+ return -1;
+ }
+ free(pkgtype);
+ }
+ memset(buf, 0x00, BUFSZE);
+ }
+
+ if (fp != NULL)
+ fclose(fp);
+
+ return 0;
+}
+
+static char *__find_rpm_pkgid(const char* manifest)
+{
+ FILE *fp = NULL;
+ char buf[BUFSZE] = {0};
+ char *pkgid = NULL;
+
+ fp = fopen(manifest, "r");
+ if (fp == NULL) {
+ _D("Fail get : %s", manifest);
+ return NULL;
+ }
+
+ while (fgets(buf, BUFSZE, fp) != NULL) {
+ __str_trim(buf);
+
+ pkgid = getvalue(buf, TOKEN_PKGID_STR);
+ if (pkgid != NULL) {
+ fclose(fp);
+ return pkgid;
+ }
+ memset(buf, 0x00, BUFSZE);
+ }
+
+ if (fp != NULL)
+ fclose(fp);
+
+ return NULL;
+}
+
+static void __apply_smack_for_additional_pkgid(void)
+{
+ char *ug_pkgid = "ui-gadget::client";
+ _D("apply smack pkgid : %s", ug_pkgid);
+ const char *ug_argv[] = { "/usr/bin/rpm-backend", "-k", "ug-smack", "-s", ug_pkgid, NULL };
+ initdb_xsystem(ug_argv);
+
+ char *e17_pkgid = "e17";
+ _D("apply smack pkgid : %s", e17_pkgid);
+ const char *e17_argv[] = { "/usr/bin/rpm-backend", "-k", "ug-smack", "-s", e17_pkgid, NULL };
+ initdb_xsystem(e17_argv);
+}
+
+static int __check_time(long privous_time)
+{
+ long current_time;
+ struct timeval tv;
+
+ gettimeofday(&tv, NULL);
+ current_time = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
+
+ return (int)(current_time - privous_time);
+}
+
+static int __pkg_list_cb (const pkgmgrinfo_pkginfo_h handle, void *user_data)
+{
+ int ret = -1;
+ char *pkgid = NULL;
+ char *pkg_type = NULL;
+ char *pkg_version = NULL;
+ char *pkg_label = NULL;
+ char *pkg_rootpath = NULL;
+
+ ret = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
+ if (ret == -1) {
+ _E("Failed to get pkgmgrinfo_pkginfo_get_pkgid\n");
+ return ret;
+ }
+ ret = pkgmgrinfo_pkginfo_get_type(handle, &pkg_type);
+ if (ret == -1) {
+ _E("Failed to get pkgmgrinfo_pkginfo_get_type\n");
+ return ret;
+ }
+ ret = pkgmgrinfo_pkginfo_get_version(handle, &pkg_version);
+ if (ret == -1) {
+ _E("Failed to get pkgmgrinfo_pkginfo_get_version\n");
+ return ret;
+ }
+ ret = pkgmgrinfo_pkginfo_get_label(handle, &pkg_label);
+ if (ret == -1) {
+ _E("Failed to get pkgmgrinfo_pkginfo_get_label\n");
+ return ret;
+ }
+ if (pkg_type && strcmp(pkg_type, "wgt") == 0)
+ {
+ char buf[1024] = {0};
+ ret = pkgmgrinfo_pkginfo_get_root_path(handle, &pkg_rootpath);
+ if (ret == -1) {
+ _E("pkgmgrinfo_pkginfo_get_root_path\n");
+ return ret;
+ }
+
+ snprintf(buf, 1023, "%s/author-signature.xml", pkg_rootpath);
+
+ if (access(buf, F_OK) == 0)
+ {
+ _D("pkg_type [%s]\tpkgid [%s]\tname [%s]\tversion [%s]\tpkg_subtype [%s]", pkg_type, pkgid, pkg_label, pkg_version, "hybrid");
+ return ret;
+ }
+ }
+
+ _D("pkg_type [%s]\tpkgid [%s]\tname [%s]\tversion [%s]", pkg_type, pkgid, pkg_label, pkg_version);
+
+ return ret;
+}
+
+int initdb_install_corexml(const char *directory)
+{
+ DIR *dir;
+ struct dirent entry, *result;
+ int ret;
+ char buf[BUFSZE];
+
+ int spend_time = 0;
+ int corexml_time = 0;
+ int smack_time = 0;
+ int prlivielge_time = 0;
+ int per_pkg_time = 0;
+ int pkg_cnt = 0;
+
+ long check_time;
+ struct timeval tv;
+
+ dir = opendir(directory);
+ if (!dir) {
+ if (strerror_r(errno, buf, sizeof(buf)) == 0)
+ _E("Failed to access the [%s] because %s", directory, buf);
+ return -1;
+ }
+
+ for (ret = readdir_r(dir, &entry, &result);
+ ret == 0 && result != NULL;
+ ret = readdir_r(dir, &entry, &result)) {
+ char *manifest;
+ char *pkgid;
+
+ if (entry.d_name[0] == '.') continue;
+
+ manifest = _manifest_to_package(entry.d_name);
+ if (!manifest) {
+ _E("Failed to convert file to xml[%s]", entry.d_name);
+ continue;
+ }
+
+ snprintf(buf, sizeof(buf), "%s/%s", directory, manifest);
+
+ ret = pkgmgr_parser_check_manifest_validation(buf);
+ if (ret < 0) {
+ _E("manifest validation failed : %s", buf);
+ free(manifest);
+ continue;
+ }
+
+ ret = __find_rpm_manifest(buf);
+ if (ret < 0) {
+ free(manifest);
+ continue;
+ }
+
+ pkg_cnt++;
+
+ gettimeofday(&tv, NULL);
+ check_time = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
+ per_pkg_time = 0;
+
+ _D("=========================================================================");
+ _D("install manifest=[%s]", buf);
+ const char *corexml_argv[] = { "/usr/bin/rpm-backend", "-k", "core-xml", "-s", buf, NULL };
+ initdb_xsystem(corexml_argv);
+
+ spend_time = __check_time(check_time);
+ _D("corexml is installed, time=[%d]ms", spend_time);
+ corexml_time += spend_time;
+ per_pkg_time += spend_time;
+
+ free(manifest);
+
+ pkgid = __find_rpm_pkgid(buf);
+ if(pkgid == NULL) {
+ _D("pkgid is NULL in %s", buf);
+ continue;
+ }
+
+ gettimeofday(&tv, NULL);
+ check_time = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
+
+ _D("try to apply smack");
+ const char *rpmsmack_argv[] = { "/usr/bin/rpm-backend", "-k", "rpm-smack", "-s", pkgid, NULL };
+ initdb_xsystem(rpmsmack_argv);
+
+ spend_time = __check_time(check_time);
+ _D("smack is applied, time=[%d]ms", spend_time);
+ smack_time += spend_time;
+ per_pkg_time += spend_time;
+
+ gettimeofday(&tv, NULL);
+ check_time = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
+
+ _D("try to apply privileges");
+ const char *rpmperm_argv[] = { "/usr/bin/rpm-backend", "-k", "rpm-perm", "-s", pkgid, NULL };
+ initdb_xsystem(rpmperm_argv);
+
+ spend_time = __check_time(check_time);
+ _D("privileges are applied, time=[%d]ms", spend_time);
+ prlivielge_time += spend_time;
+ per_pkg_time += spend_time;
+
+ _D("------------------------------------------------------");
+ _D("done");
+ _D("------------------------------------------------------");
+ _D("manifest xml=[%s]", buf);
+ _D("package id=[%s]", pkgid);
+ _D("time=[%d]ms", per_pkg_time);
+ free(pkgid);
+ }
+
+ closedir(dir);
+
+ _D("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
+ _D("package manager db init for manifest xml, directory=[%s]", directory);
+ _D("package total count : %d", pkg_cnt);
+ _D("Time for db init : %d sec", corexml_time / 1000);
+ _D("time for smack : %d sec", smack_time / 1000);
+ _D("time for privilege : %d sec", prlivielge_time / 1000);
+ _D("time for total process : %d sec", (corexml_time+smack_time+prlivielge_time) / 1000);
+ _D("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
+
+ return 0;
+}
int initdb_load_directory(const char *directory)
{
DIR *dir;
struct dirent entry, *result;
- int len, ret;
+ int ret;
char buf[BUFSZE];
+ int total_cnt = 0;
+// int ok_cnt = 0;
// desktop file
dir = opendir(directory);
if (!dir) {
if (strerror_r(errno, buf, sizeof(buf)) == 0)
- _E("Failed to access the [%s] because %s\n", directory, buf);
+ _E("Failed to access the [%s] because %s", directory, buf);
return -1;
}
- len = strlen(directory) + 1;
- _D("Loading manifest files from %s\n", directory);
+ _D("Loading manifest files from %s", directory);
for (ret = readdir_r(dir, &entry, &result);
ret == 0 && result != NULL;
char *manifest;
if (entry.d_name[0] == '.') continue;
+ total_cnt++;
manifest = _manifest_to_package(entry.d_name);
if (!manifest) {
- _E("Failed to convert file to package[%s]\n", entry.d_name);
+ _E("Failed to convert file to xml[%s]", entry.d_name);
continue;
}
snprintf(buf, sizeof(buf), "%s/%s", directory, manifest);
- fprintf(stderr, "pkg_initdb : manifest file %s\n", buf);
-
ret = pkgmgr_parser_check_manifest_validation(buf);
if (ret < 0) {
- _E("check manifest validation failed code[%d] %s\n", ret, buf);
- fprintf(stderr, "check manifest validation failed code[%d] %s\n", ret, buf);
+ _E("manifest validation failed : %s", buf);
+ free(manifest);
continue;
}
-
/*temporarily fixed due to glib abort */
- // pkgmgr_parser_parse_manifest_for_installation(buf, NULL);
-
- char buf2[BUFSZE];
- snprintf(buf2, sizeof(buf2), "/usr/bin/pkginfo --imd %s", buf);
- system(buf2);
+ const char *pkginfo_argv[] = { "/usr/bin/pkginfo", "--imd", buf, NULL };
+ initdb_xsystem(pkginfo_argv);
+#if 0
+ ret = pkgmgr_parser_parse_manifest_for_installation(buf, NULL);
+ if (ret < 0) {
+ _E("Failed to add a xml[%s]", buf);
+ } else {
+ ok_cnt++;
+ }
+#endif
free(manifest);
}
+// _D("Package-XML process : Success [%d], fail[%d], total[%d] \n", ok_cnt, total_cnt-ok_cnt, total_cnt);
closedir(dir);
return 0;
snprintf(journal_file, sizeof(journal_file), "%s%s", db_file, "-journal");
for (i = 0; files[i]; i++) {
- ret = chown(files[i], OWNER_ROOT, GROUP_MENU);
+ ret = chown(files[i], OWNER_ROOT, OWNER_ROOT);
if (ret == -1) {
strerror_r(errno, buf, sizeof(buf));
- _E("FAIL : chown %s %d.%d, because %s", db_file, OWNER_ROOT, GROUP_MENU, buf);
+ _E("FAIL : chown %s %d.%d, because %s", db_file, OWNER_ROOT, OWNER_ROOT, buf);
return -1;
}
- ret = chmod(files[i], S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+ ret = chmod(files[i], S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
if (ret == -1) {
strerror_r(errno, buf, sizeof(buf));
_E("FAIL : chmod %s 0664, because %s", db_file, buf);
return 0;
}
-
+static int initdb_update_preload_info()
+{
+ if (pkgmgr_parser_parse_manifest_for_preload() == -1) {
+ _E("pkgmgr_parser_parse_manifest_for_preload fail.");
+ return -1;
+ }
+ return 0;
+}
static int __is_authorized()
{
/* pkg_init db should be called by as root privilege. */
int main(int argc, char *argv[])
{
int ret;
+ time_t start_time;
+ time_t end_time;
if (!__is_authorized()) {
_E("You are not an authorized user!\n");
return -1;
}
+ time(&start_time);
+
ret = initdb_count_package();
if (ret > 0) {
_D("Some Packages in the Package Info DB.");
return 0;
}
- ret = initdb_load_directory(OPT_MANIFEST_DIRECTORY);
+ if (argv[1] == NULL) {
+ ret = initdb_install_corexml(USR_MANIFEST_DIRECTORY);
+ if (ret == -1) {
+ _E("cannot load usr manifest directory.");
+ }
+ ret = initdb_install_corexml(OPT_MANIFEST_DIRECTORY);
+ if (ret == -1) {
+ _E("cannot load opt manifest directory.");
+ }
+ } else if (strcmp(argv[1],"all") == 0) {
+ ret = initdb_load_directory(USR_MANIFEST_DIRECTORY);
+ if (ret == -1) {
+ _E("cannot load usr manifest directory for all ");
+ }
+
+ ret = initdb_load_directory(OPT_MANIFEST_DIRECTORY);
+ if (ret == -1) {
+ _E("cannot load opt manifest directory for all ");
+ }
+ } else {
+ _E("Wrong pkg_initdb cmd args");
+ return 0;
+ }
+
+ /*ui_gadget dont have xml, give a smack label manually*/
+ __apply_smack_for_additional_pkgid();
+
+ ret = initdb_change_perm(PACKAGE_INFO_DB_FILE);
if (ret == -1) {
- _E("cannot load opt manifest directory.");
+ _E("cannot chown.");
}
- ret = initdb_load_directory(USR_MANIFEST_DIRECTORY);
+ ret = initdb_update_preload_info();
if (ret == -1) {
- _E("cannot load usr manifest directory.");
+ _E("cannot update preload info.");
}
- ret = initdb_change_perm(PACKAGE_INFO_DB_FILE);
+ const char *argv_parser[] = { "/usr/bin/chsmack", "-a", PKG_INFO_DB_LABEL, PKG_PARSER_DB_FILE, NULL };
+ initdb_xsystem(argv_parser);
+ const char *argv_parserjn[] = { "/usr/bin/chsmack", "-a", PKG_INFO_DB_LABEL, PKG_PARSER_DB_FILE_JOURNAL, NULL };
+ initdb_xsystem(argv_parserjn);
+ const char *argv_cert[] = { "/usr/bin/chsmack", "-a", PKG_INFO_DB_LABEL, PKG_CERT_DB_FILE, NULL };
+ initdb_xsystem(argv_cert);
+ const char *argv_certjn[] = { "/usr/bin/chsmack", "-a", PKG_INFO_DB_LABEL, PKG_CERT_DB_FILE_JOURNAL, NULL };
+ initdb_xsystem(argv_certjn);
+
+ time(&end_time);
+
+ _D("================================================================");
+ fprintf(stderr, "[PKG_INITDB][D] Package-Manager initializing start : %s", ctime(&start_time));
+ fprintf(stderr, "[PKG_INITDB][D] Package-Manager initializing end : %s", ctime(&end_time));
+ _D("================================================================");
+
+ _D("================== Installed package list =====================");
+ ret = pkgmgrinfo_pkginfo_get_list(__pkg_list_cb, NULL);
if (ret == -1) {
- _E("cannot chown.");
- return -1;
+ _E("cannot get_list.");
+ }
+ _D("================================================================");
+
+ ret = pkgmgr_parser_insert_app_aliasid();
+ if(ret == -1){
+ _E("Insert for app-aliasID DB failed");
}
return 0;
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include <magic.h>
+
+#include "pkg_magic.h"
+
+static const char const __mime_table[_MIME_MAX][12] = {"application", "audio", "image", "message", "model", "multipart", "text", "video"};
+
+int get_mime_type(const char *file_path);
+
+
+static magic_t __magic_cookie = NULL;
+
+void __magic_finalize(void)
+{
+ if (__magic_cookie) {
+ magic_close(__magic_cookie);
+ }
+ return ;
+}
+
+int __magic_init(void)
+{
+ if (__magic_cookie != NULL) {
+ return 0;
+ }
+ __magic_cookie = magic_open(MAGIC_MIME);
+ if (__magic_cookie == NULL) {
+ LOGE("unable to initialize magic library");
+ return -1;
+ }
+ if (magic_load(__magic_cookie, NULL) != 0) {
+ LOGE("cannot load magic database - %s", magic_error(__magic_cookie));
+ magic_close(__magic_cookie);
+ __magic_cookie = NULL;
+ return -1;
+ }
+ atexit(__magic_finalize);
+ return 0;
+}
+
+int get_mime_type(const char *file_path)
+{
+ int i = 0;
+
+ if (__magic_init() < 0){
+ LOGE("failed to initialize magic library");
+ return -1;
+ }
+
+ const char *mime_str = magic_file(__magic_cookie, file_path);
+ if (mime_str == NULL) {
+ LOGE("failed to get mime type");
+ return -1;
+ }
+
+ for (i = 0; i < _MIME_MAX; ++i) {
+ if (strncmp(mime_str, __mime_table[i], 2) == 0) {
+ return i;
+ }
+ }
+ LOGE("failed to find mime type");
+ return -1;
+}
--- /dev/null
+#include <dlog.h>
+
+#undef LOG_TAG
+#ifndef LOG_TAG
+#define LOG_TAG "PKGMGR_JUNKINFO"
+#endif /* LOG_TAG */
+
+enum _mime_type {
+ _MIME_APPLICATION = 0,
+ _MIME_AUDIO = 1,
+ _MIME_IMAGE = 2,
+ _MIME_MESSAGE = 3,
+ _MIME_MODEL = 4,
+ _MIME_MULTIPART = 5,
+ _MIME_TEXT = 6,
+ _MIME_VIDEO = 7,
+ _MIME_MAX = 8
+};
+
+
+int get_mime_type(const char *file_path);
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/smack.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include <pkgmgr-info.h>
+#include "comm_config.h"
+
+#define MAX_PATH_LENGTH 512
+#define APP_ROOT_RW_PATH "/opt/usr/apps"
+#define EXTERNAL_STORAGE_APP_SPECIFIC_PATH "/opt/storage/sdcard/apps"
+
+static const char _PRIVILEGE_NAME[] = "http://tizen.org/privilege/externalstorage.appdata";
+
+static int __package_list_cb(const pkgmgrinfo_pkginfo_h handle, void *user_data);
+static int __create_external_directory(const char *pkgid);
+static int __set_smack_label_access(const char *path, const char *label);
+static int __get_smack_label_access(const char *path, char **label);
+static int __set_smack_label_transmute(const char *path, const char *flag);
+
+static int __package_list_cb(const pkgmgrinfo_pkginfo_h handle, void *user_data)
+{
+ char *pkgid = NULL;
+ int res = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
+
+ if (res != PMINFO_R_OK)
+ {
+ ERR("pkgmgrinfo_pkginfo_get_pkgid() is failed. error = [%d]", res);
+ return -1;
+ }
+
+ dbg("Create external directory. package_id = [%s] privilge_name = [%s]", pkgid, _PRIVILEGE_NAME);
+ res = __create_external_directory(pkgid);
+ if (res != 0)
+ {
+ ERR("__create_external_directory() is failed. error = [%d]", res);
+ return -1;
+ }
+
+ return 0;
+}
+
+static int __create_external_directory(const char *pkgid)
+{
+ char ext_pkg_base_path[MAX_PATH_LENGTH] = {0, };
+ char temp_path[MAX_PATH_LENGTH] = {0, };
+ char pkg_shared_data_path[MAX_PATH_LENGTH] = {0, };
+ char *shared_data_label = NULL;
+ int res = 0;
+
+ /* Create directories */
+ snprintf(ext_pkg_base_path, MAX_PATH_LENGTH, "%s/%s", EXTERNAL_STORAGE_APP_SPECIFIC_PATH, pkgid);
+ res = mkdir(ext_pkg_base_path, 0500);
+ if (res == -1 && errno != EEXIST)
+ {
+ ERR("mkdir() is failed. error = [%d] strerror = [%s]", errno, strerror(errno));
+ return -1;
+ }
+
+ res = __set_smack_label_access(ext_pkg_base_path, "_");
+ if (res != 0)
+ {
+ ERR("__set_smack_label_access() is failed.");
+ return -1;
+ }
+
+ //data
+ memset(temp_path, 0, MAX_PATH_LENGTH);
+ strcpy(temp_path, ext_pkg_base_path);
+ strncat(temp_path, "/data", strlen("/data"));
+ res = mkdir(temp_path, 0700);
+ if (res == -1 && errno != EEXIST)
+ {
+ ERR("mkdir() is failed. error = [%d] strerror = [%s]", errno, strerror(errno));
+ return -1;
+ }
+ res = __set_smack_label_access(temp_path, pkgid);
+ if (res != 0)
+ {
+ ERR("__set_smack_label_access() is failed.");
+ return -1;
+ }
+
+ //cache
+ memset(temp_path, 0, MAX_PATH_LENGTH);
+ strcpy(temp_path, ext_pkg_base_path);
+ strncat(temp_path, "/cache", strlen("/cache"));
+ res = mkdir(temp_path, 0700);
+ if (res == -1 && errno != EEXIST)
+ {
+ ERR("mkdir() is failed. error = [%d] strerror = [%s]", errno, strerror(errno));
+ return -1;
+ }
+ res = __set_smack_label_access(temp_path, pkgid);
+ if (res != 0)
+ {
+ ERR("__set_smack_label_access() is failed.");
+ return -1;
+ }
+
+ //shared
+ memset(temp_path, 0, MAX_PATH_LENGTH);
+ strcpy(temp_path, ext_pkg_base_path);
+ strncat(temp_path, "/shared", strlen("/shared"));
+ res = mkdir(temp_path, 0500);
+ if (res == -1 && errno != EEXIST)
+ {
+ ERR("mkdir() is failed. error = [%d] strerror = [%s]", errno, strerror(errno));
+ return -1;
+ }
+ res = __set_smack_label_access(temp_path, "_");
+ if (res != 0)
+ {
+ ERR("__set_smack_label_access() is failed.");
+ return -1;
+ }
+
+ snprintf(pkg_shared_data_path, MAX_PATH_LENGTH, "%s/%s/%s", APP_ROOT_RW_PATH, pkgid , "shared/data");
+
+ res = access(pkg_shared_data_path, F_OK);
+ if (res == 0)
+ {
+ dbg("Exist shared/data folder (path:[%s])", pkg_shared_data_path);
+ res = __get_smack_label_access(pkg_shared_data_path, &shared_data_label);
+ if (res != 0)
+ {
+ ERR("__get_smack_label_access() is failed.");
+ return -1;
+ }
+
+ //shared/data
+ strncat(temp_path, "/data", strlen("/data"));
+ res = mkdir(temp_path, 0705);
+ if (res == -1 && errno != EEXIST)
+ {
+ ERR("mkdir() is failed. error = [%d] strerror = [%s]", errno, strerror(errno));
+ return -1;
+ }
+ res = __set_smack_label_access(temp_path, shared_data_label);
+ if (res != 0)
+ {
+ ERR("__set_smack_label_access() is failed.");
+ return -1;
+ }
+ res = __set_smack_label_transmute(temp_path, "1");
+ if (res != 0)
+ {
+ ERR("__set_smack_label_transmute() is failed.");
+ return -1;
+ }
+
+ //shared/cache
+ memset(temp_path, 0, MAX_PATH_LENGTH);
+ strcpy(temp_path, ext_pkg_base_path);
+ strncat(temp_path, "/shared", strlen("/shared"));
+ strncat(temp_path, "/cache", strlen("/cache"));
+ res = mkdir(temp_path, 0700);
+ if (res == -1 && errno != EEXIST)
+ {
+ ERR("mkdir() is failed. error = [%d] strerror = [%s]", errno, strerror(errno));
+ return -1;
+ }
+ res = __set_smack_label_access(temp_path, shared_data_label);
+ if (res != 0)
+ {
+ ERR("__set_smack_label_access() is failed.");
+ return -1;
+ }
+ res = __set_smack_label_transmute(temp_path, "1");
+ if (res != 0)
+ {
+ ERR("__set_smack_label_transmute() is failed.");
+ return -1;
+ }}
+ else if (res == -1 && errno == ENOENT)
+ {
+ dbg("Directory dose not exist. path: %s, errno: %d (%s)",
+ pkg_shared_data_path, errno, strerror(errno));
+ return 0;
+ }
+ else
+ {
+ ERR("access() failed. path: %s, errno: %d (%s)",
+ pkg_shared_data_path, errno, strerror(errno));
+ return -1;
+ }
+
+ return 0;
+}
+
+static int __set_smack_label_access(const char *path, const char *label)
+{
+ int res = smack_lsetlabel(path, label, SMACK_LABEL_ACCESS);
+ if (res != 0)
+ {
+ ERR("smack set label(%s) failed[%d] (path:[%s]))", label, res, path);
+ return -1;
+ }
+ return 0;
+}
+
+static int __get_smack_label_access(const char *path, char **label)
+{
+ int res = smack_lgetlabel(path, label, SMACK_LABEL_ACCESS);
+ if (res != 0)
+ {
+ ERR("smack get label(%s) failed[%d] (path:[%s]))", label, res, path);
+ return -1;
+ }
+ return 0;
+}
+
+static int __set_smack_label_transmute(const char *path, const char *flag)
+{
+ int res = smack_lsetlabel(path, flag, SMACK_LABEL_TRANSMUTE);
+ if (res != 0)
+ {
+ ERR("smack set label(%s) failed[%d] (path:[%s]))", flag, res, path);
+ return -1;
+ }
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ char ext_base_path[MAX_PATH_LENGTH] = {0, };
+ int res = 0;
+
+ strcpy(ext_base_path, EXTERNAL_STORAGE_APP_SPECIFIC_PATH);
+ res = mkdir(ext_base_path, 0555);
+ if (res == -1 && errno != EEXIST)
+ {
+ ERR("mkdir() is failed. error = [%d] strerror = [%s]", errno, strerror(errno));
+ return -1;
+ }
+
+ res = __set_smack_label_access(ext_base_path, "system::ext_storage_appdata");
+ if (res != 0)
+ {
+ ERR("__set_smack_label_access() is failed.");
+ return -1;
+ }
+
+ res = pkgmgrinfo_pkginfo_privilege_filter_foreach(_PRIVILEGE_NAME, __package_list_cb, NULL);
+ if (res != PMINFO_R_OK)
+ {
+ ERR("pkgmgrinfo_pkginfo_privilege_filter_foreach() is failed. error = [%d]", res);
+ return -1;
+ }
+
+ return 0;
+}
+
--- /dev/null
+#!/bin/sh
+#
+
+_pkg_recovery_path="/opt/share/packages/.recovery/pkgmgr"
+_pkg_recovery_file="/opt/share/packages/.recovery/pkgmgr/*"
+
+FILE_LIST=`ls $_pkg_recovery_path`
+if [ -n "$FILE_LIST" ]; then
+ echo "There are packages to recovery"
+ /usr/bin/wrt-installer -b
+ /usr/bin/osp-installer -b
+
+ echo "delete recovery files"
+ rm $_pkg_recovery_file
+else
+ echo "There is no packages to recovery."
+fi
+
#include <bundle.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <Ecore.h> /* for ecore_main_loop_quit() */
+
+#include <appcore-efl.h>
+#include <glib.h>
#define KEY_MIME_TYPE "__AUL_MIME_TYPE__"
#define KEY_MIME_TYPE_NEW "__APP_SVC_MIME_TYPE__"
#define KEY_MIME_CONTENT_NEW "__APP_SVC_URI__"
+
+#if !defined(PACKAGE)
+#define PACKAGE "org.tizen.pkgmgr-install"
+#endif
+
+
char *supported_mime_type_list[] = {
NULL /* sentinel */
};
+struct appdata {
+ char *file_path;
+ char *extension;
+};
+
+
static int __parse_argv(int argc, char **argv,
char **mime_type, char **file_path);
static const char *__get_ext_from_file_path(const char *file_path);
return strrchr(file_path, '.') + 1;
}
+gboolean __term(void *data)
+{
+ ecore_main_loop_quit();
+
+ return FALSE;
+}
+
int main(int argc, char **argv)
{
+ struct appdata ad;
+ struct appcore_ops ops = {
+ .create = NULL,
+ .terminate = NULL,
+ .pause = NULL,
+ .resume = NULL,
+ .reset = NULL,
+ };
+
char *mime_type;
char *file_path;
+ const char *extension;
+ int request_id = 0;
if (__parse_argv(argc, argv, &mime_type, &file_path)) {
fprintf(stderr, "Failed to parse argv!\n");
return -1;
}
- const char *extension = __get_ext_from_file_path(file_path);
+ extension = __get_ext_from_file_path(file_path);
- int req_id;
+ memset(&ad, 0x0, sizeof(struct appdata));
+ ops.data = &ad;
+ ad.file_path = file_path;
+ ad.extension = (char*)extension;
- pkgmgr_client *pc = pkgmgr_client_new(PC_REQUEST);
- req_id = pkgmgr_client_install(pc, extension, NULL, file_path, NULL,
- PM_DEFAULT, NULL, NULL);
- pkgmgr_client_free(pc);
- sleep(2);
- /* Wait until AULD(launchpad) retrives info of this process.
- Its timeout is 1.2s. */
+ int pid = fork();
+ if (pid == 0) {
+ pkgmgr_client *pc = pkgmgr_client_new(PC_REQUEST);
+ request_id = pkgmgr_client_install(pc, extension, NULL, file_path, NULL,
+ PM_QUIET, NULL, NULL);
+ if (request_id < 0)
+ fprintf(stderr, "pkgmgr_client_install fail!\n");
- return 0;
+ request_id = pkgmgr_client_free(pc);
+ if (request_id < 0)
+ fprintf(stderr, "pkgmgr_client_free fail\n");
+
+ exit(0);
+ }
+
+ g_timeout_add(1000, __term, &ad);
+
+// sleep(2);
+ /* Wait until AULD(launchpad) retrives info of this process.
+ Its timeout is 1.2s. */
+
+ return appcore_efl_main(PACKAGE, &argc, &argv, &ops);
}
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#define _GNU_SOURCE
+
+#include <stdio.h>
+#include <dlog.h>
+#include <string.h>
+#include <glib.h>
+#include <stdlib.h>
+#include <glib-object.h>
+
+#include "junk-manager.h"
+
+#undef LOG_TAG
+#ifndef LOG_TAG
+#define LOG_TAG "JUNK_TEST"
+#endif
+
+void junk_result_test(junkmgr_result_h handle)
+{
+ int cnt = 0;
+ while (junkmgr_result_cursor_step_next(handle) == JUNKMGR_E_SUCCESS)
+ {
+ printf(">>>>> loop count: %d\n", cnt);
+
+ char *junk_name = NULL;
+ junkmgr_result_cursor_get_junk_name(handle, &junk_name);
+ printf("junk name: %s\n", junk_name);
+ free(junk_name);
+
+ junkmgr_category_e category;
+ junkmgr_result_cursor_get_category(handle, &category);
+ printf("category: %d\n", category);
+
+ junkmgr_file_type_e file_type = -1;
+ junkmgr_result_cursor_get_file_type(handle, &file_type);
+ printf("file type: %d\n", file_type);
+
+ junkmgr_storage_type_e storage_type = -1;
+ junkmgr_result_cursor_get_storage_type(handle, &storage_type);
+ printf("storage type: %d\n", storage_type);
+
+ long long junk_size = -1;
+ junkmgr_result_cursor_get_junk_size(handle, &junk_size);
+ printf("junk size: %lld\n", junk_size);
+
+ char *junk_path = NULL;
+ junkmgr_result_cursor_get_junk_path(handle, &junk_path);
+ printf("junk path: %s\n", junk_path);
+ free(junk_path);
+
+ cnt++;
+ printf("<<<<< end\n");
+ }
+
+ return;
+}
+
+void __junk_cb(int reqid, junkmgr_result_h handle, void *user_data)
+{
+ LOGD("reqid: %d, junkmgr_result_h: 0x%x, user_data: 0x%x", reqid, handle, user_data);
+
+ junk_result_test(handle);
+
+ g_main_loop_quit((GMainLoop *)user_data);
+}
+
+int main(int argc, char *argv[])
+{
+ LOGD("Test start!");
+
+ g_type_init();
+ GMainLoop *main_loop = g_main_loop_new(NULL, FALSE);
+
+
+ junkmgr_h junkmgr = junkmgr_create_handle();
+ if (junkmgr == NULL) {
+ LOGE("Failed to get pkgmgr_client instance!");
+ return 1;
+ }
+
+ int ret = 0;
+ int reqid = 0;
+#if 1
+ ret = junkmgr_get_junk_root_dirs(junkmgr, __junk_cb, main_loop, &reqid);
+ LOGD("result(req_id): %d", ret);
+#else
+ ret = junkmgr_get_junk_files(junkmgr, "/opt/storage/sdcard/Others/__@@bada_applications@@__", __junk_cb, main_loop, &reqid);
+ LOGD("result(req_id): %d", ret);
+#endif
+ g_main_loop_run(main_loop);
+
+ junkmgr_destroy_handle(junkmgr);
+
+ return 0;
+}
#endif
typedef void (*_pkg_plugin_unload) (void);
-typedef int (*_pkg_plugin_pkg_is_installed) (const char *pkg_name);
+typedef int (*_pkg_plugin_pkg_is_installed) (const char *pkgid);
typedef int (*_pkg_plugin_get_installed_pkg_list) (const char *category,
const char *option,
package_manager_pkg_info_t
**list, int *count);
-typedef int (*_pkg_plugin_get_pkg_detail_info) (const char *pkg_name,
+typedef int (*_pkg_plugin_get_pkg_detail_info) (const char *pkgid,
package_manager_pkg_detail_info_t
*pkg_detail_info);
typedef int (*_pkg_plugin_get_pkg_detail_info_from_package) (const char
#include <errno.h>
#include <stdbool.h>
#include <time.h>
+#include <glib.h>
#ifdef __cplusplus
extern "C" {
#define PKG_VERSION_STRING_LEN_MAX 128
#define PKG_VALUE_STRING_LEN_MAX 512
#define PKG_URL_STRING_LEN_MAX 1024
+#define PKG_LABEL_STRING_LEN_MAX 128
/**
*@brief application's structure retrieved by package-manager
typedef struct _package_manager_pkg_info_t {
char pkg_type[PKG_TYPE_STRING_LEN_MAX];
char pkg_name[PKG_NAME_STRING_LEN_MAX];
+ char pkgid[PKG_NAME_STRING_LEN_MAX];
char version[PKG_VERSION_STRING_LEN_MAX];
struct _package_manager_pkg_info_t *next;
} package_manager_pkg_info_t;
typedef struct _package_manager_pkg_detail_info_t {
char pkg_type[PKG_TYPE_STRING_LEN_MAX];
char pkg_name[PKG_NAME_STRING_LEN_MAX];
+ char pkgid[PKG_NAME_STRING_LEN_MAX];
char version[PKG_VERSION_STRING_LEN_MAX];
+ char api_version[PKG_VERSION_STRING_LEN_MAX];
char pkg_description[PKG_VALUE_STRING_LEN_MAX];
char min_platform_version[PKG_VERSION_STRING_LEN_MAX];
time_t installed_time; /* installed time it must be GMT+0 time */
int data_size; /* data size which is made on run time */
char optional_id[PKG_NAME_STRING_LEN_MAX]; /*package ID if exists */
void *pkg_optional_info;
+ char label[PKG_LABEL_STRING_LEN_MAX];
+ char author[PKG_VALUE_STRING_LEN_MAX];
+ char *icon_buf;
+ int icon_size;
+ GList *privilege_list;
} package_manager_pkg_detail_info_t;
/** @} */