tizen 2.4 release accepted/tizen_2.4_mobile accepted/tizen/2.4/mobile/20151029.033810 submit/tizen_2.4/20151028.063923 tizen_2.4_mobile_release
authorjk7744.park <jk7744.park@samsung.com>
Sat, 24 Oct 2015 07:32:42 +0000 (16:32 +0900)
committerjk7744.park <jk7744.park@samsung.com>
Sat, 24 Oct 2015 07:32:42 +0000 (16:32 +0900)
102 files changed:
710.pkgmgr.patch.sh.in [deleted file]
CMakeLists.txt
client/include/package-manager-zone.h [new file with mode: 0755]
client/include/package-manager.h
client/src/pkgmgr-internal.c
client/src/pkgmgr.c
comm/CMakeLists.txt
comm/SLP_package_manager_frontend_backend_PG.h [deleted file]
comm/build.sh [deleted file]
comm/comm_client.c [deleted file]
comm/comm_client.h
comm/comm_client_gdbus.c
comm/comm_config.h
comm/comm_internal.c [moved from comm/test/test_comm_status_broadcast_server.c with 52% similarity, mode: 0644]
comm/comm_internal.h [moved from comm/comm_socket_client.h with 81% similarity, mode: 0644]
comm/comm_pkg_mgr.xml [changed mode: 0644->0755]
comm/comm_pkg_mgr_ext.xml [new file with mode: 0755]
comm/comm_pkg_mgr_server.c
comm/comm_pkg_mgr_server.h
comm/comm_socket.c [deleted file]
comm/comm_socket.h [deleted file]
comm/comm_socket_client.c [deleted file]
comm/comm_status_broadcast_server_dbus.c
comm/comm_status_broadcast_signal_marshaller.list [deleted file]
comm/pkgmgr-installer-pkg-mgr-server.pc.in [new file with mode: 0755]
comm/pkgmgr_installer.c
comm/pkgmgr_installer.h
comm/pkgmgr_installer_config.h
comm/test/CMakeLists.txt [deleted file]
comm/test/test_comm_client.c [deleted file]
comm/test/test_comm_pkg_mgr_server.c [deleted file]
comm/test/test_comm_socket.c [deleted file]
comm/test/test_pkgmgr_installer.c [deleted file]
debian/changelog [deleted file]
debian/compat [deleted file]
debian/control [deleted file]
debian/docs [deleted file]
debian/libpkgmgr-client-0.install.in [deleted file]
debian/libpkgmgr-client-0.postinst [deleted file]
debian/libpkgmgr-client-dev.install.in [deleted file]
debian/libpkgmgr-installer-dev.install.in [deleted file]
debian/libpkgmgr-installer.install.in [deleted file]
debian/libpkgmgr-types-dev.install.in [deleted file]
debian/pkgmgr-server.install.in [deleted file]
debian/pkgmgr-server.postinst [deleted file]
debian/rules [deleted file]
include/SLP_package_manager_PG.h [deleted file]
include/junk-manager.h [deleted file]
include/package-manager-internal.h
include/package-manager-zone.h [new symlink]
installers/CMakeLists.txt [deleted file]
installers/sample/CMakeLists.txt [deleted file]
installers/sample/sample_backend.c [deleted file]
installers/sample/sample_backendlib.c [deleted file]
installers/sample/sample_parserlib.c [deleted file]
junkmgr.pc.in [deleted file]
packaging/pkgmgr.spec
packaging/pkgmgr_recovery.service [deleted file]
pkgmgr-installer.manifest [changed mode: 0644->0755]
pkgmgr-parser.manifest [deleted file]
pkgmgr-server.manifest [deleted file]
pkgmgr-soft-reset-ui.sh.in [deleted file]
pkgmgr.manifest
po/CMakeLists.txt [deleted file]
po/POTFILES.in [deleted file]
po/en_GB.po [deleted file]
po/en_US.po [deleted file]
po/ja_JP.po [deleted file]
po/ko_KR.po [deleted file]
po/package-manager.pot [deleted file]
po/update-po.sh [deleted file]
po/zh_CN.po [deleted file]
queue_status [deleted file]
server/include/pkgmgr-server.h [deleted file]
server/include/pm-queue.h [deleted file]
server/src/pkgmgr-server.c [deleted file]
server/src/pkgmgr_external_storage.c [deleted file]
server/src/pkgmgr_external_storage.h [deleted file]
server/src/pm-queue.c [deleted file]
slp-pkgmgr.service [deleted file]
test.sh [deleted file]
tool/CMakeLists.txt [deleted file]
tool/mime.tpk.xml [deleted file]
tool/mime.wac.xml [deleted file]
tool/org.tizen.pkgmgr-install.xml.in [deleted file]
tool/pkg.c [deleted file]
tool/pkg.h [deleted file]
tool/pkg_clearcache.c [deleted file]
tool/pkg_cmd.c [deleted file]
tool/pkg_fota.c [deleted file]
tool/pkg_getjunkinfo.c [deleted file]
tool/pkg_getsize.c [deleted file]
tool/pkg_info.c [deleted file]
tool/pkg_initdb.c [deleted file]
tool/pkg_magic.c [deleted file]
tool/pkg_magic.h [deleted file]
tool/pkg_mkext.c [deleted file]
tool/pkg_recovery.sh.in [deleted file]
tool/pkgmgr-install.c [deleted file]
tool/stress_test.py [deleted file]
tool/test_junk.c [deleted file]
types/include/package-manager-types.h

diff --git a/710.pkgmgr.patch.sh.in b/710.pkgmgr.patch.sh.in
deleted file mode 100644 (file)
index a507f06..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-echo "--------------------------------------"
-echo "Update package database..............."
-echo "--------------------------------------"
-/usr/bin/pkg_fota
index 8fb1429..82d436f 100755 (executable)
@@ -1,4 +1,4 @@
-# 
+#
 # Copyright (c) 2008 ~ 2010 Samsung Electronics Co., Ltd.
 # All rights reserved
 #
@@ -11,6 +11,17 @@ PROJECT(package-manager C)
 SET(VERSION 0.1.68)
 SET(VERSION_MAJOR 0)
 
+IF(_APPFW_FEATURE_EXPANSION_PKG_INSTALL)
+        ADD_DEFINITIONS("-D_APPFW_FEATURE_EXPANSION_PKG_INSTALL")
+ENDIF(_APPFW_FEATURE_EXPANSION_PKG_INSTALL)
+IF(_APPFW_FEATURE_DELTA_UPDATE)
+        ADD_DEFINITIONS("-D_APPFW_FEATURE_DELTA_UPDATE")
+ENDIF(_APPFW_FEATURE_DELTA_UPDATE)
+
+IF(_APPFW_FEATURE_MOUNT_INSTALL)
+        ADD_DEFINITIONS("-D_APPFW_FEATURE_MOUNT_INSTALL")
+ENDIF(_APPFW_FEATURE_MOUNT_INSTALL)
+
 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 SET(EXEC_PREFIX "\${prefix}")
 SET(LIBDIR "\${prefix}/lib")
@@ -23,13 +34,21 @@ set(CMAKE_SKIP_BUILD_RPATH true)
 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 ecore-file pkgmgr-info pkgmgr-parser iniparser vconf minizip xdgmime)
+IF(_APPFW_FEATURE_DRM_ENABLE)
+pkg_check_modules(pkgs REQUIRED security-server dlog pkgmgr-info pkgmgr-parser iniparser vconf minizip xdgmime drm-service-core-tizen)
+ELSE(_APPFW_FEATURE_DRM_ENABLE)
+pkg_check_modules(pkgs REQUIRED security-server dlog pkgmgr-info pkgmgr-parser iniparser vconf minizip xdgmime)
+ENDIF(_APPFW_FEATURE_DRM_ENABLE)
+
 
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
 ENDFOREACH(flag)
-
-pkg_check_modules(libpkgs REQUIRED dbus-glib-1 dlog pkgmgr-info pkgmgr-parser iniparser security-server vconf minizip xdgmime)
+IF(_APPFW_FEATURE_DRM_ENABLE)
+pkg_check_modules(libpkgs REQUIRED dbus-glib-1 dlog pkgmgr-info pkgmgr-parser iniparser security-server vconf minizip xdgmime vasum db-util drm-service-core-tizen)
+ELSE(_APPFW_FEATURE_DRM_ENABLE)
+pkg_check_modules(libpkgs REQUIRED dbus-glib-1 dlog pkgmgr-info pkgmgr-parser iniparser security-server vconf minizip xdgmime vasum db-util)
+ENDIF(_APPFW_FEATURE_DRM_ENABLE)
 
 FOREACH(flag ${libpkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
@@ -39,8 +58,6 @@ SET(pm_dir "${CMAKE_SOURCE_DIR}")
 SET(pm_inc_dir "${pm_dir}/include")
 SET(pm_c_src_dir "${pm_dir}/client/src")
 SET(pm_c_inc_dir "${pm_dir}/client/include")
-SET(pm_s_src_dir "${pm_dir}/server/src")
-SET(pm_s_inc_dir "${pm_dir}/server/include")
 SET(pm_t_inc_dir "${pm_dir}/types/include")
 
 ## About debug
@@ -51,10 +68,13 @@ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -Wall")
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
 
+IF(_APPFW_FEATURE_DRM_ENABLE)
+       ADD_DEFINITIONS("-D_APPFW_FEATURE_DRM_ENABLE")
+ENDIF(_APPFW_FEATURE_DRM_ENABLE)
+
 ##################
 ## build comm libraries
 add_subdirectory(comm)
-add_subdirectory(tool)
 add_subdirectory(types)
 
 ###################################################################################################
@@ -71,41 +91,20 @@ SET_TARGET_PROPERTIES(${PKGMGR_CLIENT} PROPERTIES COMPILE_FLAGS "${libpkgmgr-cli
 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 -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 ${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(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_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_SOURCE_DIR}/client/include/package-manager-zone.h DESTINATION include)
 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/)
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/package-manager-debug.h DESTINATION include)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/package-manager-internal.h DESTINATION include)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/types/include/package-manager-plugin.h DESTINATION include)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/types/include/package-manager-types.h DESTINATION include)
 
 ####################################################################################################
-add_subdirectory(installers)
 # i18n
-add_subdirectory(po)
diff --git a/client/include/package-manager-zone.h b/client/include/package-manager-zone.h
new file mode 100755 (executable)
index 0000000..b2980ec
--- /dev/null
@@ -0,0 +1,20 @@
+#ifndef __PACKAGE_MANAGER_ZONE_H__
+#define __PACKAGE_MANAGER_ZONE_H__
+
+#include <package-manager.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* APIs for zone-feature */
+
+int pkgmgr_client_listen_status_with_zone(pkgmgr_client *pc,
+               pkgmgr_handler_with_zone event_cb, void *data);
+
+char *_zone_get_type_from_zip(const char *filename, const char *zone);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __PACKAGE_MANAGER_ZONE_H__ */
index ca4c1d7..fb10603 100755 (executable)
@@ -88,17 +88,6 @@ extern "C" {
  */
 
 /**
- * @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 listening status type in pkgmgr.
  */
 #define PKGMGR_CLIENT_STATUS_ALL                                               0x00
@@ -109,7 +98,6 @@ extern "C" {
 #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 */
@@ -120,6 +108,7 @@ extern "C" {
 #define PKGCMD_ERR_PACKAGE_INVALID                                             2
 #define PKGCMD_ERR_PACKAGE_LOWER_VERSION                               3
 #define PKGCMD_ERR_PACKAGE_EXECUTABLE_NOT_FOUND                        4
+#define PKGCMD_ERR_PACKAGE_NOT_SUPPORTED_API_VERSION   5
 #define PKGCMD_ERR_MANIFEST_NOT_FOUND                                  11
 #define PKGCMD_ERR_MANIFEST_INVALID                                            12
 #define PKGCMD_ERR_CONFIG_NOT_FOUND                                            13
@@ -141,10 +130,21 @@ extern "C" {
 #define PKGCMD_ERR_OUT_OF_MEMORY                                               63
 #define PKGCMD_ERR_ARGUMENT_INVALID                                            64
 
+#define PKGCMD_ERR_SIGNATURE_INVALID_CERT_CHAIN                                        71
+#define PKGCMD_ERR_SIGNATURE_INVALID_DISTRIBUTOR_CERT                  72
+#define PKGCMD_ERR_SIGNATURE_INVALID_SDK_DEFAULT_AUTHOR_CERT   73
+#define PKGCMD_ERR_SIGNATURE_IN_DISTRIBUTOR_CASE_AUTHOR_CERT   74
+#define PKGCMD_ERR_SIGNATURE_INVALID_DEVICE_UNIQUE_ID                  75
+#define PKGCMD_ERR_SIGNATURE_INVALID_CERT_TIME                                 76
+#define PKGCMD_ERR_SIGNATURE_INVALID_NO_HASH_FILE                              77
+#define PKGCMD_ERR_SIGNATURE_NO_DEVICE_PROFILE                                 78
+#define PKGCMD_ERR_SIGNATURE_INVALID_HASH_SIGNATURE                            79
+
 #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_PACKAGE_NOT_SUPPORTED_API_VERSION_STR       "PACKAGE_NOT_SUPPORTED_API_VERSION"
 #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"
@@ -167,11 +167,21 @@ extern "C" {
 #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 PKGCMD_ERR_SIGNATURE_INVALID_CERT_CHAIN_STR                                    "SIGNATURE_INVALID_CERT_CHAIN"
+#define PKGCMD_ERR_SIGNATURE_INVALID_DISTRIBUTOR_CERT_STR                      "SIGNATURE_INVALID_DISTRIBUTOR_CERT"
+#define PKGCMD_ERR_SIGNATURE_INVALID_SDK_DEFAULT_AUTHOR_CERT_STR       "SIGNATURE_INVALID_SDK_DEFAULT_AUTHOR_CERT"
+#define PKGCMD_ERR_SIGNATURE_IN_DISTRIBUTOR_CASE_AUTHOR_CERT_STR       "SIGNATURE_IN_DISTRIBUTOR_CASE_AUTHOR_CERT"
+#define PKGCMD_ERR_SIGNATURE_INVALID_DEVICE_UNIQUE_ID_STR                      "SIGNATURE_INVALID_DEVICE_UNIQUE_ID"
+#define PKGCMD_ERR_SIGNATURE_INVALID_CERT_TIME_STR                                     "SIGNATURE_INVALID_CERT_TIME"
+#define PKGCMD_ERR_SIGNATURE_INVALID_NO_HASH_FILE_STR                          "SIGNATURE_INVALID_NO_HASH_FILE"
+#define PKGCMD_ERR_SIGNATURE_NO_DEVICE_PROFILE_STR                                     "SIGNATURE_NO_DEVICE_PROFILE"
+#define PKGCMD_ERR_SIGNATURE_INVALID_HASH_SIGNATURE_STR                                "SIGNATURE_INVALID_HASH_SIGNATURE"
 
-#define PKG_SIZE_INFO_TOTAL "__TOTAL__"
-#define PKG_CLEAR_ALL_CACHE "__ALL__"
+#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.
@@ -224,6 +234,8 @@ typedef struct
        long long ext_app_size;
 } pkg_size_info_t;
 
+typedef pkg_size_info_t *pkg_size_info_h;
+
 typedef int (*pkgmgr_iter_fn)(const char* pkg_type, const char* pkgid,
                                const char* version, void *data);
 
@@ -246,10 +258,15 @@ typedef void (*pkgmgr_pkg_size_info_receive_cb)(pkgmgr_client *pc, const char *p
 typedef void (*pkgmgr_total_pkg_size_info_receive_cb)(pkgmgr_client *pc,
                const pkg_size_info_t *size_info, void *user_data);
 
+typedef int (*pkgmgr_handler_with_zone)(int req_id, const char *pkg_type,
+                               const char *pkgid, const char *key, const char *val,
+                               const void *pmsg, void *data, const char *zone);
+
 typedef enum {
        PC_REQUEST = 0,
        PC_LISTENING,
        PC_BROADCAST,
+       PC_REQUEST_PRIVATE,
 } client_type;
 
 typedef enum {
@@ -303,17 +320,25 @@ typedef enum {
        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 {
+       //sync, get data, total size for one requested pkgid
        PM_GET_TOTAL_SIZE = 0,
        PM_GET_DATA_SIZE = 1,
+
+       //async, get total used storage size
        PM_GET_ALL_PKGS = 2,
+
+       //async, get a pkgid's data, total size for all installed pkg
        PM_GET_SIZE_INFO = 3,
+
+       //deprecated
        PM_GET_TOTAL_AND_DATA = 4,
        PM_GET_SIZE_FILE = 5,
+
+       //async, get data, cache, app size based on "pkg_size_info_t"
        PM_GET_PKG_SIZE_INFO = 6,
        PM_GET_TOTAL_PKG_SIZE_INFO = 7,
        PM_GET_MAX
@@ -366,6 +391,56 @@ int pkgmgr_client_install(pkgmgr_client *pc, const char *pkg_type,
                            const char *optional_file, pkgmgr_mode mode,
                            pkgmgr_handler event_cb, void *data);
 
+#ifdef _APPFW_FEATURE_EXPANSION_PKG_INSTALL
+/**
+ * @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]  tep_path                full path that tep file is located at
+ * @param[in]  tep_move                if TRUE, source file will be moved, else it will be copied
+ * @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_with_tep(pkgmgr_client * pc, const char *pkg_type,
+                             const char *descriptor_path, const char *pkg_path,
+                             const char *tep_path, bool tep_move, const char *optional_file,
+                             pkgmgr_mode mode, pkgmgr_handler event_cb, void *data);
+#endif
+
+
+#ifdef _APPFW_FEATURE_MOUNT_INSTALL
+/**
+ * @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]  pkg_path                full path that package file is located
+ * @param[in]  optional_file   optional file which is used for installation
+ * @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_mount_install(pkgmgr_client * pc, const char *pkg_type,
+                       const char *pkg_path, const char *optional_file,
+                       pkgmgr_handler event_cb, void *data);
+#endif
+
 /**
  * @brief      This API reinstalls package.
  *
@@ -502,6 +577,34 @@ int pkgmgr_client_activate_appv(pkgmgr_client * pc, const char *appid, char *con
 int pkgmgr_client_deactivate_app(pkgmgr_client *pc, const char *appid);
 
 /**
+ * @brief      This API enables application's background operation.
+ *
+ * This API is for package-manager client application.\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_enable_app_bg_operation(pkgmgr_client *pc, const char *appid);
+
+/**
+ * @brief      This API disables application's background operation.
+ *
+ * This API is for package-manager client application.\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_disable_app_bg_operation(pkgmgr_client *pc, const char *appid);
+
+/**
  * @brief      This API deletes application's private data.
  *
  * This API is for package-manager client application.\n
@@ -531,6 +634,34 @@ int pkgmgr_client_clear_user_data(pkgmgr_client *pc, const char *pkg_type,
 */
 int pkgmgr_client_set_status_type(pkgmgr_client *pc, int status_type);
 
+
+/**
+ * @brief      This API set checksum value of pkg file to be installed to prevent install hijack
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in]  pc      pkgmgr_client
+ * @param[in]  pkg_chksum checksum of package file which to be installed
+ * @return     return 0 if success, error code(<0) if fail\n
+ * @retval     PKGMGR_R_OK     success
+ * @retval     PKGMGR_R_EINVAL invalid argument
+*/
+int pkgmgr_client_set_pkg_chksum(pkgmgr_client *pc, char *pkg_chksum);
+
+/**
+ * @brief      This API set debug mode for sdk
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in]  pc      pkgmgr_client
+ * @param[in]  debug_mode      debug mode
+ * @return     return 0 if success, error code(<0) if fail\n
+ * @retval     PKGMGR_R_OK     success
+ * @retval     PKGMGR_R_EINVAL invalid argument
+*/
+int pkgmgr_client_set_debug_mode(pkgmgr_client *pc, bool debug_mode);
+
+
 /**
  * @brief      This API request to listen the pkgmgr's broadcasting
  *
@@ -666,9 +797,6 @@ int pkgmgr_client_get_package_size_info(pkgmgr_client *pc, const char *pkgid, pk
  */
 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 removes cache directories
  *
@@ -697,10 +825,6 @@ int pkgmgr_client_clear_cache_dir(const char *pkgid);
 int pkgmgr_client_clear_all_cache_dir(void);
 
 
-// API for wms on wearable
-int pkgmgr_client_reset_device(void);
-
-
 /**
  * @brief      This API provides package list
  *
index f72e4e5..e57c34c 100755 (executable)
@@ -37,6 +37,7 @@
 #include <dlfcn.h>
 #include <sys/time.h>
 #include <pkgmgr-info.h>
+#include <vasum.h>
 
 #include "package-manager.h"
 #include "package-manager-debug.h"
@@ -56,6 +57,8 @@
        ((CHAR == ' ' || CHAR == '\t' || CHAR == '\r' || CHAR == '\n') ? \
        true : false)
 
+#define ZONE_HOST "host"
+
 void _app_str_trim(char *input)
 {
        char *trim_str = input;
@@ -75,23 +78,19 @@ void _app_str_trim(char *input)
        return;
 }
 
-char *_get_backend_path(const char *input_path)
+API char *_get_backend_path(const char *pkgid)
 {
        FILE *fp = NULL;
        char buffer[1024] = { '\0', };
-       char *type = NULL;
        char installer_path[PKG_STRING_LEN_MAX] = { '\0', };
-       char pkg_path[PKG_STRING_LEN_MAX] = { '\0', };
        char backend_path[PKG_STRING_LEN_MAX] = { '\0', };
+       char *backend_installer = NULL;
+       char *tmp = NULL;
 
-       if (strrchr(input_path, '/')) {
-               strncpy(pkg_path, strrchr(input_path, '/') + 1,
-                       PKG_STRING_LEN_MAX - 1);
-       } else {
-               strncpy(pkg_path, input_path, PKG_STRING_LEN_MAX - 1);
-       }
+       int ret;
+       pkgmgrinfo_pkginfo_h handle = NULL;
 
-       _LOGD("pkg_path[%s]\n", pkg_path);
+       _LOGD("pkgid[%s]\n", pkgid);
 
        fp = fopen(PKG_CONF_PATH, "r");
        if (fp == NULL) {
@@ -120,27 +119,51 @@ char *_get_backend_path(const char *input_path)
        if (fp != NULL)
                fclose(fp);
 
-       if (path == NULL)
+       if(path == NULL)
                return NULL;
 
-/*     if(path[strlen(path)] == '/') */
+       ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+       if (ret != PMINFO_R_OK) {
+               _LOGE("pkgid is wrong");
+       } else {
+               ret = pkgmgrinfo_pkginfo_get_backend_installer(handle, &tmp);
+               if (ret) {
+                       _LOGE(" pkgmgrinfo_pkginfo_get_backend_installer error : %d", ret);
+                       backend_installer = NULL;
+                       tmp = NULL;
+               }else {
+                       backend_installer = strdup(tmp);
+               }
+       }
+       pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+       tmp = NULL;
+
+       if (!backend_installer) {
+               backend_installer = _get_backend_from_zip(pkgid);
+               if (!backend_installer) {
+                       _LOGE("Fail to get backend from zip : %s ",pkgid);
+                       char *ext = NULL;
+                       ext = strrchr(pkgid, '.');
+                       if (ext == NULL)
+                               backend_installer = strdup(pkgid);
+                       else
+                               backend_installer = strdup(++ext);
+               }
+       }
+
+       /*      if(path[strlen(path)] == '/') */
        snprintf(backend_path, PKG_STRING_LEN_MAX - 1, "%s", path);
 /*     else
-               sprintf(backend_path, "%s/", path); */
-
-       type = strrchr(pkg_path, '.');
-       if (type == NULL)
-               type = pkg_path;
-       else
-               type++;
-
-       snprintf(installer_path, PKG_STRING_LEN_MAX - 1, 
-                                       "%s%s", backend_path, type);
-
+       sprintf(backend_path, "%s/", path); */
+       snprintf(installer_path, PKG_STRING_LEN_MAX - 1, "%s%s", backend_path, backend_installer);
        _LOGD("installer_path[%s]\n", installer_path);
 
-       if (access(installer_path, F_OK) != 0)
+       if (backend_installer)
+               free(backend_installer);
+
+       if (access(installer_path, F_OK) != 0) {
                return NULL;
+       }
 
        return strdup(installer_path);
 }
@@ -152,8 +175,6 @@ char *_get_backend_path_with_type(const char *type)
        char installer_path[PKG_STRING_LEN_MAX] = { '\0', };
        char backend_path[PKG_STRING_LEN_MAX] = { '\0', };
 
-       _LOGD("type[%s]\n", type);
-
        fp = fopen(PKG_CONF_PATH, "r");
        if (fp == NULL) {
                return NULL;
@@ -167,11 +188,7 @@ char *_get_backend_path_with_type(const char *type)
                _app_str_trim(buffer);
 
                if ((path = strstr(buffer, PKG_BACKEND)) != NULL) {
-//                     _LOGD("[%s]\n", buffer);
-//                     _LOGD("[%s]\n", path);
                        path = path + strlen(PKG_BACKEND);
-//                     _LOGD("[%s]\n", path);
-
                        break;
                }
 
@@ -206,7 +223,7 @@ char *_get_backend_path_with_type(const char *type)
                }
                type = strchr(extlist, '.') + 1;
 
-               snprintf(installer_path, PKG_STRING_LEN_MAX - 1, 
+               snprintf(installer_path, PKG_STRING_LEN_MAX - 1,
                                                "%s%s", backend_path, type);
        }
 
@@ -355,7 +372,7 @@ pkg_plugin_set *_pkg_plugin_load_library(const char *pkg_type,
                return NULL;
        }
 
-       if ((on_load = dlsym(library_handle, "pkg_plugin_on_load")) == NULL || 
+       if ((on_load = dlsym(library_handle, "pkg_plugin_on_load")) == NULL ||
            dlerror() != NULL) {
                _LOGE("can not find symbol \n");
                dlclose(library_handle);
@@ -486,7 +503,7 @@ typedef struct _detail_info_map_t {
                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;  
+               time_t installed_time;
                int installed_size;
                int app_size;
                int data_size;
@@ -524,7 +541,7 @@ char *_get_info_string(const char *key,
 
        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) {
@@ -532,17 +549,17 @@ char *_get_info_string(const char *key,
                                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, 
+                               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, 
+                               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, 
+                               snprintf(temp, PKG_VALUE_STRING_LEN_MAX - 1,
                                        "%d", (int)*(time_t *) (tmp->field));
                                return strdup(temp);
                        } else
@@ -624,13 +641,281 @@ static int __is_rpm_pkg(const char *filename)
        }
 }
 
-API char *_get_type_from_zip(const char *filename)
+API int _zone_get_name_by_pid(int pid, char *zone_name, int len)
+{
+       vsm_zone_h zone;
+       vsm_context_h ctx = vsm_create_context();
+       const char *zone_name_tmp = NULL;
+       int ret = 0;
+       if (ctx == NULL) {
+                       _LOGE("vsm_create_context failed");
+                       return false;
+       }
+       zone = vsm_lookup_zone_by_pid(ctx, pid);
+
+       if (zone != NULL && !vsm_is_host_zone(zone)) {
+               zone_name_tmp = vsm_get_zone_name(zone);
+               if (zone_name_tmp == NULL) {
+                       _LOGE("failed to get zone");
+                       ret = -1;
+                       goto err;
+               }
+       } else if (vsm_is_host_zone(zone)) {
+               zone_name_tmp = ZONE_HOST;
+       } else {
+               _LOGE("could not get zone name");
+               ret = -1;
+               goto err;
+       }
+
+       snprintf(zone_name, len, "%s", zone_name_tmp);
+err:
+       if (vsm_cleanup_context(ctx) != 0)
+               _LOGE("vsm cleanup failed");
+       return ret;
+}
+
+API char *_zone_get_root_path(const char *zone)
+{
+       vsm_context_h context = NULL;
+       vsm_zone_h handle = NULL;
+       char *rootpath = NULL;
+
+       context = vsm_create_context();
+       if (context == NULL) {
+               _LOGE("Failed to create vsm context");
+               return NULL;
+       }
+
+       handle = vsm_lookup_zone_by_name(context, zone);
+       if (handle == NULL) {
+               _LOGE("Failed to lookup zone by name");
+               return NULL;
+       }
+
+       rootpath = vsm_get_zone_rootpath(handle);
+       if (rootpath == NULL) {
+               _LOGE("Failed to get rootpath");
+               return NULL;
+       }
+
+       _LOGD("rootpath : %s", rootpath);
+
+       return rootpath;
+}
+
+#ifdef _APPFW_FEATURE_EXPANSION_PKG_INSTALL
+/**
+* @brief __get_installed_pkg_type() returns the installed package type for which input tep file should belong to.
+*
+* @param filename - tep file name
+*
+* @return returns NULL if pkgid for which tep belongs doesn't exists. Else, returns pkgtype.
+*/
+static char * __get_installed_pkg_type(const char *filename)
+{
+       char *pkg_type = NULL;
+       char pkg_file[PKG_STRING_LEN_MAX] = { '\0', };
+       char *tmp = NULL;
+       char *pkgid = NULL;
+       size_t pkgid_len = 0;
+       int ret = 0;
+       char *type = NULL;
+       char *install_path = NULL;
+       char manifest_path[FILENAME_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);
+       }
+
+       /*Checking for valid tep file*/
+       pkg_type = strrchr(pkg_file, '.');
+       retvm_if(pkg_type == NULL, NULL, "pkg_type is null[%s]", filename);
+
+       pkg_type++;
+       retvm_if((pkg_type == NULL || strcmp(pkg_type, "tep") != 0), NULL, "Invalid tep file[%s]", filename);
+
+       pkg_type = NULL;
+
+       /*e.g., Input filename --> org.tizen.sample-1.0.0-arm.tep
+           e.g., Output should be --> org.tizen.sample*/
+       tmp = strchr(pkg_file, '-');
+       retvm_if((tmp == NULL || strlen(tmp) == 0), NULL, "Invalid tep file name!!!\n");
+
+       pkgid_len = tmp - pkg_file;
+       retvm_if(pkgid_len < 1, NULL, "Invalid tep file name!!!\n");
+
+       pkgid = calloc(1, pkgid_len + 1);
+       retvm_if(pkgid == NULL, NULL, "Out of Memory!!!\n");
+
+       memcpy((void *)pkgid, (const void *)pkg_file, pkgid_len);
+       trym_if((strlen(pkgid) == 0), "pkgid is NULL");
+
+       pkgmgrinfo_pkginfo_h handle = NULL;
+       ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+       trym_if(ret < 0, "pkgmgrinfo_pkginfo_get_pkginfo(%s) failed.", pkgid);
+
+       ret = pkgmgrinfo_pkginfo_get_type(handle, &type);
+       trym_if(ret < 0 || type == NULL, "pkgmgrinfo_pkginfo_get_type(%s) failed.", pkgid);
+
+       ret = pkgmgrinfo_pkginfo_get_root_path(handle, &install_path);
+       trym_if(ret < 0, "Cannot install .tep [Corresponding app is not installed], pkgmgrinfo_pkginfo_get_root_path(%s) failed.", pkgid);
+
+       if ((strcmp(type, "wgt")==0) || (strcmp(type, "rpm") == 0)){
+               pkg_type = strdup(type);
+       }else if (strcmp(type, "tpk") == 0){
+               snprintf(manifest_path, FILENAME_MAX, "%s/%s", install_path, CORE_XML_FILE);
+               if (access(manifest_path, F_OK) == 0){
+                       pkg_type = strdup("rpm");
+               }else{
+                       pkg_type = strdup("tpk");
+               }
+       }
+
+catch:
+       free(pkgid);
+       pkgid = NULL;
+       if(handle)
+               pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+       return pkg_type;
+
+}
+#endif
+
+API char *_zone_get_type_from_zip(const char *filename, const char *zone)
 {
        retvm_if(filename == NULL, NULL, "filename is NULL");
 
        char *pkg_type = NULL;
        unzFile uf = NULL;
 
+       char *_file_name = NULL;
+       int _name_len = 0;
+
+#ifdef _APPFW_FEATURE_EXPANSION_PKG_INSTALL
+               _LOGE("tep_filepath [%s]", filename);
+#endif
+
+       if (zone && strcmp(zone, ZONE_HOST) != 0) {
+               char *rootpath = NULL;
+               rootpath = _zone_get_root_path(zone);
+               retvm_if(rootpath == NULL, NULL, "rootpath is NULL");
+
+               _name_len = strlen(filename) + strlen(rootpath) + 1; /* for '\0' */
+               _file_name = calloc(1, _name_len);
+               if (_file_name) {
+                       snprintf(_file_name, _name_len, "%s%s", rootpath, filename);
+                       _LOGD("new file name is %s", _file_name);
+
+                       if (access(_file_name, F_OK) != 0) {
+                               _LOGE("can not access to [%s], retry to [%s]", _file_name, filename);
+                               free(_file_name);
+                               _file_name = NULL;
+                               _name_len = strlen(filename) + 1; /* for '\0' */
+                               _file_name = calloc(1, _name_len);
+                               if (_file_name) {
+                                       snprintf(_file_name, _name_len, "%s", filename);
+                                       if (access(_file_name, F_OK) != 0) {
+                                               _LOGE("can not access to [%s]", _file_name);
+                                               free(_file_name);
+                                               return NULL;
+                                       }
+                               }
+                       }
+               }
+       } else {
+               _name_len = strlen(filename) + 1; /* for '\0' */
+               _file_name = calloc(1, _name_len);
+               if (_file_name) {
+                       snprintf(_file_name, _name_len, "%s", filename);
+                       if (access(_file_name, F_OK) != 0) {
+                               _LOGE("can not access to [%s]", _file_name);
+                               free(_file_name);
+                               return NULL;
+                       }
+               }
+       }
+
+       if (!_file_name) {
+               _LOGE("_file_name alloc failed");
+               return NULL;
+       }
+
+       // rpm
+       if (__is_rpm_pkg(_file_name) == 0) {
+               _LOGE("%s is rpm", _file_name);
+               free(_file_name);
+               return strdup("rpm");
+       }
+
+       uf = unzOpen(_file_name);
+       retvm_if(uf == NULL, NULL, "unzOpen[%s] fail", _file_name);
+
+
+       //hybrid for web-core
+       if ((unzLocateFile(uf, HYBRID_XML_FILE, 0) == 0) && (unzLocateFile(uf, CORE_XML_FILE, 0) == 0)) {
+               _LOGE("%s is hybrid[web-core]", _file_name);
+               pkg_type = strdup("wgt");
+
+       //hybrid for web-tpk
+       } else if ((unzLocateFile(uf, HYBRID_XML_FILE, 0) == 0) && (unzLocateFile(uf, TPK_XML_FILE, 0) == 0)) {
+               _LOGE("%s is hybrid[web-tpk]", _file_name);
+               pkg_type = strdup("wgt");
+
+       //core
+       } else if (unzLocateFile(uf, CORE_XML_FILE, 0) == 0) {
+               _LOGD("%s is core", filename);
+               pkg_type = strdup("tpk");
+
+       //wgt
+       } else if (unzLocateFile(uf, WGT_XML_FILE, 0) == 0) {
+               _LOGE("%s is wgt", _file_name);
+               pkg_type = strdup("wgt");
+
+       //tpk
+       } else if (unzLocateFile(uf, TPK_XML_FILE, 0) == 0) {
+               _LOGE("%s is tpk", _file_name);
+               pkg_type = strdup("tpk");
+
+       //error case
+       } else {
+#ifdef _APPFW_FEATURE_EXPANSION_PKG_INSTALL
+               pkg_type = __get_installed_pkg_type(_file_name);
+
+               if (pkg_type != NULL){
+                       _LOGE("tep pkg type is %s\n", pkg_type);
+               } else{
+                       _LOGE("Invalid tep file name!!");
+               }
+#else
+               _LOGE("%s is not supported", _file_name);
+#endif
+
+       }
+
+       if (uf) {
+               unzCloseCurrentFile(uf);
+               unzClose(uf);
+       }
+
+       free(_file_name);
+
+       return pkg_type;
+}
+
+API char *_get_type_from_zip(const char *filename)
+{
+       return _zone_get_type_from_zip(filename, NULL);
+}
+API char *_get_backend_from_zip(const char *filename)
+{
+       retvm_if(filename == NULL, NULL, "filename is NULL");
+
+       char *backend = NULL;
+       unzFile uf = NULL;
+
        if (access(filename, F_OK) != 0) {
                _LOGE("can not access to [%s]", filename);
                return NULL;
@@ -649,31 +934,42 @@ API char *_get_type_from_zip(const char *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");
+               backend = 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");
+               backend = strdup("wgt");
 
        //core
        } else if (unzLocateFile(uf, CORE_XML_FILE, 0) == 0) {
                _LOGD("%s is core", filename);
-               pkg_type = strdup("coretpk");
+               backend = strdup("coretpk");
 
        //wgt
        } else if (unzLocateFile(uf, WGT_XML_FILE, 0) == 0) {
                _LOGD("%s is wgt", filename);
-               pkg_type = strdup("wgt");
+               backend = strdup("wgt");
 
        //tpk
        } else if (unzLocateFile(uf, TPK_XML_FILE, 0) == 0) {
                _LOGD("%s is tpk", filename);
-               pkg_type = strdup("tpk");
+               backend = strdup("tpk");
 
        //error case
        } else {
+
+#ifdef _APPFW_FEATURE_EXPANSION_PKG_INSTALL
+               backend = __get_installed_pkg_type(filename);
+
+               if (backend != NULL){
+                       LOGE("tep pkg type is %s\n", backend);
+               } else{
+                       LOGE("Invalid tep file name!!");
+               }
+#else
                _LOGD("%s is not supported", filename);
+#endif
        }
 
        if (uf) {
@@ -681,5 +977,5 @@ API char *_get_type_from_zip(const char *filename)
                unzClose(uf);
        }
 
-       return pkg_type;
+       return backend;
 }
index 6700494..3445661 100755 (executable)
@@ -45,7 +45,6 @@
 #include "package-manager-internal.h"
 #include "comm_client.h"
 #include "comm_status_broadcast_server.h"
-#include "junk-manager.h"
 #include "pkgmgr_parser.h"
 
 #undef LOG_TAG
@@ -55,8 +54,6 @@
 
 #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"
@@ -69,6 +66,7 @@
 #define PKG_DISABLED_LIST_FILE                 PKGMGR_FOTA_PATH"pkg_disabled_list.txt"
 
 #define TOKEN_PATH_STR                                         "path="
+#define TOKEN_OP_STR                                           "op="
 #define SEPERATOR_END                                          ':'
 
 #define OPT_USR_MEDIA                  "/opt/usr/media"
@@ -83,6 +81,11 @@ FILE *logfile = NULL;
        }\
 } while (0)
 
+#ifdef _APPFW_FEATURE_EXPANSION_PKG_INSTALL
+#define TEP_MOVE "tep_move"
+#define TEP_COPY "tep_copy"
+#endif
+
 static int _get_request_id()
 {
        int pid = 0;
@@ -107,6 +110,8 @@ typedef struct _req_cb_info {
 typedef struct _listen_cb_info {
        int request_id;
        pkgmgr_handler event_cb;
+       int with_zone;
+       pkgmgr_handler_with_zone event_cb_with_zone;
        void *data;
        struct _listen_cb_info *next;
 } listen_cb_info;
@@ -129,6 +134,8 @@ typedef struct _pkgmgr_client_t {
        } info;
        void* new_event_cb;
     void* extension;
+       bool debug_mode;
+       char *pkg_chksum;
 } pkgmgr_client_t;
 
 typedef struct _iter_data {
@@ -136,24 +143,6 @@ typedef struct _iter_data {
        void *data;
 } iter_data;
 
-typedef struct {
-       pkgmgr_client *pc;
-       void *junk_tb;
-       char *db_path;
-} junkmgr_s;
-
-typedef struct {
-       void *db;
-       void *db_stmt;
-} junkmgr_result_s;
-
-typedef struct
-{
-       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 char *__get_cookie_from_security_server(void)
 {
        int ret = 0;
@@ -325,8 +314,6 @@ static req_cb_info *__find_op_cbinfo(pkgmgr_client_t *pc, const char *req_key)
                return NULL;
        }
 
-       _LOGD("tmp->req_key %s, req_key %s", tmp->req_key, req_key);
-
        while (tmp) {
                if (strncmp(tmp->req_key, req_key, strlen(tmp->req_key)) == 0)
                        return tmp;
@@ -335,27 +322,39 @@ static req_cb_info *__find_op_cbinfo(pkgmgr_client_t *pc, const char *req_key)
        return NULL;
 }
 
-static void __remove_op_cbinfo(pkgmgr_client_t *pc, req_cb_info *info)
+static void __add_stat_cbinfo(pkgmgr_client_t *pc, int request_id,
+                             pkgmgr_handler event_cb, void *data)
 {
-       req_cb_info *tmp;
+       listen_cb_info *cb_info;
+       listen_cb_info *current;
+       listen_cb_info *prev;
 
-       if (pc == NULL || pc->info.request.rhead == NULL || info == NULL)
+       cb_info = (listen_cb_info *) calloc(1, sizeof(listen_cb_info));
+       if (cb_info == NULL) {
+               _LOGD("calloc failed");
                return;
+       }
+       cb_info->request_id = request_id;
+       cb_info->event_cb = event_cb;
+       cb_info->data = data;
+       cb_info->next = NULL;
 
-       tmp = pc->info.request.rhead;
-       while (tmp) {
-               if (tmp->next == info) {
-                       tmp->next = info->next;
-                       free(info);
-                       return;
+       /* TODO - check the order of callback - FIFO or LIFO => Should be changed to LIFO */
+       if (pc->info.listening.lhead == NULL)
+               pc->info.listening.lhead = cb_info;
+       else {
+               current = prev = pc->info.listening.lhead;
+               while (current) {
+                       prev = current;
+                       current = current->next;
                }
-               tmp = tmp->next;
+
+               prev->next = cb_info;
        }
 }
 
-
-static void __add_stat_cbinfo(pkgmgr_client_t *pc, int request_id,
-                             pkgmgr_handler event_cb, void *data)
+static void __add_stat_cbinfo_with_zone(pkgmgr_client_t *pc, int request_id,
+               pkgmgr_handler_with_zone event_cb, void *data)
 {
        listen_cb_info *cb_info;
        listen_cb_info *current;
@@ -367,7 +366,8 @@ static void __add_stat_cbinfo(pkgmgr_client_t *pc, int request_id,
                return;
        }
        cb_info->request_id = request_id;
-       cb_info->event_cb = event_cb;
+       cb_info->event_cb_with_zone = event_cb;
+       cb_info->with_zone = 1;
        cb_info->data = data;
        cb_info->next = NULL;
 
@@ -387,14 +387,11 @@ static void __add_stat_cbinfo(pkgmgr_client_t *pc, int request_id,
 
 static void __operation_callback(void *cb_data, const char *req_id,
                                 const char *pkg_type, const char *pkgid,
-                                const char *key, const char *val)
+                                const char *key, const char *val, const char *zone)
 {
        pkgmgr_client_t *pc;
        req_cb_info *cb_info;
 
-       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;
 
        /* find callback info */
@@ -402,8 +399,6 @@ static void __operation_callback(void *cb_data, const char *req_id,
        if (cb_info == NULL)
                return;
 
-       _LOGD("__find_op_cbinfo");
-
        /* call callback */
        if (cb_info->event_cb) {
                if (pc->new_event_cb)
@@ -416,7 +411,6 @@ static void __operation_callback(void *cb_data, const char *req_id,
                        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
@@ -431,20 +425,26 @@ static void __operation_callback(void *cb_data, const char *req_id,
 
 static void __status_callback(void *cb_data, const char *req_id,
                              const char *pkg_type, const char *pkgid,
-                             const char *key, const char *val)
+                             const char *key, const char *val, const char *zone)
 {
        pkgmgr_client_t *pc;
        listen_cb_info *tmp;
-
-       SECURE_LOGD("__status_callback() req_id[%s] pkg_type[%s] pkgid[%s]"
-             "key[%s] val[%s]\n", req_id, pkg_type, pkgid, key, val);
+       int with_zone = 0;
+       int ret = 0;
 
        pc = (pkgmgr_client_t *) cb_data;
 
        tmp = pc->info.listening.lhead;
        while (tmp) {
-               if (tmp->event_cb(tmp->request_id, pkg_type, pkgid, key, val,
-                                 NULL, tmp->data) != 0)
+               with_zone = tmp->with_zone;
+               if (with_zone && tmp->event_cb_with_zone) {
+                       _LOGD("call event_cb_with_zone");
+                       ret = tmp->event_cb_with_zone(tmp->request_id, pkg_type, pkgid, key, val, NULL, tmp->data, zone);
+               } else {
+                       ret = tmp->event_cb(tmp->request_id, pkg_type, pkgid, key, val, NULL, tmp->data);
+               }
+
+               if (ret != 0)
                        break;
                tmp = tmp->next;
        }
@@ -637,10 +637,30 @@ char *__proc_get_cmdline_bypid(int pid)
                return strdup(buf);
 }
 
+static int __is_core_type_csc(char *pkgid)
+{
+       int ret = -1;
+
+       char tizen_manifest[PKG_STRING_LEN_MAX] = {'\0', };
+       snprintf(tizen_manifest, PKG_STRING_LEN_MAX, "/opt/usr/apps/%s/tizen-manifest.xml", pkgid);
+
+       if (access(tizen_manifest, F_OK)==0) {
+               ret = 1;
+       } else {
+               snprintf(tizen_manifest, PKG_STRING_LEN_MAX, "/usr/apps/%s/tizen-manifest.xml", pkgid);
+               if (access(tizen_manifest, F_OK)==0) {
+                       ret = 1;
+               }
+       }
+
+       return ret;
+}
+
 static int __is_core_tpk_csc(char *description)
 {
        int ret = 0;
        char *path_str = NULL;
+       char *op_str = NULL;
        char *pkg_type = NULL;
        char csc_str[PKG_STRING_LEN_MAX] = {'\0'};
        snprintf(csc_str, PKG_STRING_LEN_MAX - 1, "%s:", description);
@@ -650,21 +670,30 @@ static int __is_core_tpk_csc(char *description)
        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);
+       op_str = __get_str(csc_str, TOKEN_OP_STR);
+       tryvm_if(op_str == NULL, ret = PKGMGR_R_ERROR, "op_str is NULL");
 
-       pkg_type = _get_type_from_zip(path_str);
-       if (pkg_type) {
-               if (strstr(pkg_type, "rpm"))
-                       ret = 1;
-               else
-                       ret  =-1;
-               free(pkg_type);
+       _LOGD("path_str [%s], op_str [%s]\n", path_str, op_str);
+
+       if (strcmp(op_str, "uninstall") == 0) {
+               ret = __is_core_type_csc(path_str);
+       } else {
+               pkg_type = _get_backend_from_zip(path_str);
+               if (pkg_type) {
+                       if (strstr(pkg_type, "coretpk"))
+                               ret = 1;
+                       else
+                               ret  =-1;
+                       free(pkg_type);
+               }
        }
 
 catch:
 
        if(path_str)
                free(path_str);
+       if(op_str)
+               free(op_str);
 
        return ret;
 }
@@ -829,7 +858,7 @@ static int __check_sync_process(char *req_key)
                        fp = fopen(info_file, "r");
                        if (fp == NULL){
                                _LOGD("file is not generated yet.... wait\n");
-                               usleep(10 * 1000);      /* 10ms sleep*/
+                               usleep(100 * 1000);     /* 100ms sleep*/
                                continue;
                        }
 
@@ -842,22 +871,22 @@ static int __check_sync_process(char *req_key)
                }
 
                _LOGD("file is not generated yet.... wait\n");
-               usleep(10 * 1000);      /* 10ms sleep*/
+               usleep(100 * 1000);     /* 100ms sleep*/
 
-               if (check_cnt > 6000) { /* 60s time over*/
-                       _LOGD("wait time over!!\n");
+               if (check_cnt > 6000) { /* 60s * 10 time over*/
+                       _LOGE("wait time over!!\n");
                        break;
                }
        }
 
        ret = remove(info_file);
        if (ret < 0)
-               _LOGD("file is can not remove[%s, %d]\n", info_file, ret);
+               _LOGE("file is can not remove[%s, %d]\n", info_file, ret);
 
        return result;
 }
 
-static int __disable_pkg()
+static int __enable_pkg()
 {
        int ret = 0;
        FILE *fp = NULL;
@@ -865,12 +894,34 @@ static int __disable_pkg()
        char pkgid[PKG_STRING_LEN_MAX] = {'\0',};
 
        fp = fopen(file_path, "r");
-       if (fp == NULL) {
-               _LOGE("fopen is failed.\n");
-               return -1;
+       retvm_if(fp == NULL, -1, "fopen is failed.");
+
+       while (fgets(pkgid, PKG_STRING_LEN_MAX - 1, fp) != NULL) {
+               ret = pkgmgr_parser_enable_pkg(pkgid, NULL);
+               if (ret < 0) {
+                       _LOGE("pkgmgr_parser_enable_pkg is failed. pkgid is [%s].\n", pkgid);
+                       continue;
+               }
+               _LOGD("pkgid [%s] is enabled.\n", pkgid);
        }
 
-       while (fscanf(fp, "%s", pkgid) != EOF) {
+       if (fp != NULL)
+               fclose(fp);
+
+       return ret;
+}
+
+static int __disable_pkg()
+{
+       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");
+       retvm_if(fp == NULL, -1, "fopen is failed.");
+
+       while (fgets(pkgid, PKG_STRING_LEN_MAX - 1, fp) != NULL) {
                ret = pkgmgr_parser_disable_pkg(pkgid, NULL);
                if (ret < 0) {
                        _LOGE("pkgmgr_parser_disable_pkg is failed. pkgid is [%s].\n", pkgid);
@@ -900,6 +951,10 @@ static int __csc_process(const char *csc_path, char *result_path)
        dictionary *csc = NULL;
        FILE* file = NULL;
 
+       if (__enable_pkg() < 0) {
+               _LOGE("__enable_pkg fail");
+       }
+
        csc = iniparser_load(csc_path);
        retvm_if(csc == NULL, PKGMGR_R_EINVAL, "cannot open parse file [%s]", csc_path);
 
@@ -942,7 +997,7 @@ static int __csc_process(const char *csc_path, char *result_path)
 
                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 };
+                               const char *coreinstaller_argv[] = { "/usr/bin/rpm-backend", "-c", des, NULL };
                                ret = __xsystem(coreinstaller_argv);
                        } else {
                                const char *ospinstaller_argv[] = { "/usr/bin/osp-installer", "-c", des, NULL };
@@ -1013,7 +1068,10 @@ static int __get_size_process(pkgmgr_client * pc, const char *pkgid, pkgmgr_gets
        retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST\n");
 
        req_key = __get_req_key(pkgid);
-       retvm_if(req_key == NULL, PKGMGR_R_EINVAL, "req_key is NULL");
+       if (!req_key) {
+               ret = PKGMGR_R_ENOMEM;
+               goto catch;
+       }
 
        snprintf(buf, 128, "%d", get_type);
        argv[argcnt++] = strdup(pkgid);
@@ -1028,7 +1086,7 @@ static int __get_size_process(pkgmgr_client * pc, const char *pkgid, pkgmgr_gets
        }
 
        args = (char *)calloc(len, sizeof(char));
-       tryvm_if(args == NULL, ret = PKGMGR_R_EINVAL, "installer_path fail");
+       tryvm_if(args == NULL, ret = PKGMGR_R_EINVAL, "args alloc fail");
 
        strncpy(args, argv[0], len - 1);
 
@@ -1056,12 +1114,11 @@ catch:
        for (i = 0; i < argcnt; i++)
                free(argv[i]);
 
-       if(args)
+       if (args)
                free(args);
        if (cookie)
-               free(cookie);
-
-       if(req_key)
+               g_free(cookie);
+       if (req_key)
                free(req_key);
 
        return ret;
@@ -1069,8 +1126,9 @@ catch:
 
 static int __move_pkg_process(pkgmgr_client * pc, const char *pkgid, pkgmgr_move_type move_type, pkgmgr_handler event_cb, void *data)
 {
+       _LOGE("move pkg[%s] start.", pkgid);
+
        char *req_key = NULL;
-//     int req_id = 0;
        int ret =0;
        pkgmgrinfo_pkginfo_h handle;
        char *pkgtype = NULL;
@@ -1087,25 +1145,28 @@ static int __move_pkg_process(pkgmgr_client * pc, const char *pkgid, pkgmgr_move
 
        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");
+       retvm_if(ret < 0, PKGMGR_R_ERROR, "pkgmgrinfo_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");
+       tryvm_if(ret < 0, ret = PKGMGR_R_ERROR, "pkgmgrinfo_pkginfo_get_type failed");
+
+       installer_path = _get_backend_path(pkgid);
+       tryvm_if(installer_path == NULL, ret = PKGMGR_R_ERROR, "installer_path fail");
 
-       installer_path = _get_backend_path_with_type(pkgtype);
        req_key = __get_req_key(pkgid);
+       tryvm_if(req_key == NULL, ret = PKGMGR_R_ENOMEM, "req_key is NULL");
+
 //     req_id = _get_request_id();
 
        /* generate argv */
        snprintf(buf, 128, "%d", move_type);
        /* argv[0] installer path */
-       argv[argcnt++] = installer_path;
+       argv[argcnt++] = strdup(installer_path);
        /* argv[1] */
        argv[argcnt++] = strdup("-k");
        /* argv[2] */
@@ -1129,7 +1190,7 @@ static int __move_pkg_process(pkgmgr_client * pc, const char *pkgid, pkgmgr_move
        }
 
        args = (char *)calloc(len, sizeof(char));
-       tryvm_if(args == NULL, ret = PKGMGR_R_EINVAL, "installer_path fail");
+       tryvm_if(args == NULL, ret = PKGMGR_R_EINVAL, "args alloc fail");
 
        strncpy(args, argv[0], len - 1);
 
@@ -1159,13 +1220,15 @@ catch:
        for (i = 0; i < argcnt; i++)
                free(argv[i]);
 
-       if(args)
+       if (args)
                free(args);
        if (cookie)
-               free(cookie);
+               g_free(cookie);
+       if (installer_path)
+               free(installer_path);
 
        pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
-       _LOGE("move pkg[%s] finish[%d]", pkgid, ret);
+       _LOGE("move pkg[%s] finish, ret=[%d]", pkgid, ret);
        return ret;
 }
 
@@ -1182,13 +1245,14 @@ static int __check_app_process(pkgmgr_request_service_type service_type, pkgmgr_
        retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST\n");
 
        ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
-       retvm_if(ret < 0, PKGMGR_R_ERROR, "pkgmgr_pkginfo_get_pkginfo failed");
+       retvm_if(ret < 0, PKGMGR_R_ERROR, "pkgmgrinfo_pkginfo_get_pkginfo failed");
 
        ret = pkgmgrinfo_pkginfo_get_type(handle, &pkgtype);
-       tryvm_if(ret < 0, ret = PKGMGR_R_ERROR, "pkgmgr_pkginfo_get_type failed");
+       tryvm_if(ret < 0, ret = PKGMGR_R_ERROR, "pkgmgrinfo_pkginfo_get_type failed");
 
        /* 2. generate req_key */
        req_key = __get_req_key(pkgid);
+       tryvm_if(req_key == NULL, ret = PKGMGR_R_ENOMEM, "req_key is NULL");
 
        /* 3. request activate */
        if (service_type == PM_REQUEST_KILL_APP)
@@ -1201,7 +1265,7 @@ static int __check_app_process(pkgmgr_request_service_type service_type, pkgmgr_
        * (int *) data = pid;
 
 catch:
-       if(req_key)
+       if (req_key)
                free(req_key);
 
        pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
@@ -1231,11 +1295,12 @@ static int __request_size_info(pkgmgr_client *pc)
        retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST\n");
 
        req_key = __get_req_key(pkgid);
+       retvm_if(req_key == NULL, ret = PKGMGR_R_ENOMEM, "req_key is NULL");
 
        snprintf(buf, 128, "%d", get_type);
        argv[argcnt++] = strdup(pkgid);
        argv[argcnt++] = strdup(buf);
-       argv[argcnt++] = strdup(buf);
+       argv[argcnt++] = strdup(req_key);
 
        /*** add quote in all string for special charactor like '\n'***   FIX */
        for (i = 0; i < argcnt; i++) {
@@ -1245,7 +1310,7 @@ static int __request_size_info(pkgmgr_client *pc)
        }
 
        args = (char *)calloc(len, sizeof(char));
-       tryvm_if(args == NULL, ret = PKGMGR_R_EINVAL, "installer_path fail");
+       tryvm_if(args == NULL, ret = PKGMGR_R_EINVAL, "args alloc fail");
 
        strncpy(args, argv[0], len - 1);
 
@@ -1255,7 +1320,7 @@ static int __request_size_info(pkgmgr_client *pc)
                strncat(args, temp, strlen(temp));
                g_free(temp);
        }
-       _LOGD("[args] %s [len] %d\n", args, len);
+       _LOGD("args=[%s], len=[%d]", args, len);
 
        /* get cookie from security-server */
        cookie = __get_cookie_from_security_server();
@@ -1271,39 +1336,16 @@ catch:
        for (i = 0; i < argcnt; i++)
                free(argv[i]);
 
-       if(args)
+       if (args)
                free(args);
        if (cookie)
-               free(cookie);
+               g_free(cookie);
+       if (req_key)
+               free(req_key);
 
        return ret;
 }
 
-static int __change_op_cb_for_getjunkinfo(pkgmgr_client *pc)
-{
-       int ret = -1;
-
-       retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client pc is NULL");
-       pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
-
-       /* free dbus connection */
-       ret = comm_client_free(mpc->info.request.cc);
-       retvm_if(ret < 0, PKGMGR_R_ERROR, "comm_client_free() failed - %d", ret);
-
-       /* Manage pc for seperated event */
-       mpc->ctype = PC_REQUEST;
-       mpc->status_type = PKGMGR_CLIENT_STATUS_GET_JUNK_INFO;
-
-
-       mpc->info.request.cc = comm_client_new();
-       retvm_if(mpc->info.request.cc == NULL, PKGMGR_R_ERROR, "client creation failed");
-
-       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);
-
-       return PKGMGR_R_OK;
-}
-
 static int __change_op_cb_for_getsize(pkgmgr_client *pc)
 {
        int ret = -1;
@@ -1338,229 +1380,6 @@ static int __change_op_cb_for_getsize(pkgmgr_client *pc)
        return PKGMGR_R_OK;
 }
 
-static junkmgr_result_h
-__junkmgr_create_junk_root_handle(const char *dbpath)
-{
-       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;
-       }
-
-       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;
-       }
-
-       handle = (junkmgr_result_s *)malloc(sizeof(junkmgr_result_s));
-       if (handle == NULL)
-       {
-               LOGE("out of memory");
-               goto error;
-       }
-
-       handle->db = db;
-       handle->db_stmt = db_stmt;
-
-       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 (db)
-       {
-               ret = sqlite3_close(db);
-               if (ret != SQLITE_OK)
-               {
-                   LOGE("sqlite close error, ret: %d (%s)", ret, sqlite3_errmsg(db));
-               }
-       }
-
-       return NULL;
-}
-
-static junkmgr_result_h
-__junkmgr_create_junk_file_handle(const char *dbpath, int storage, const char *junk_root)
-{
-       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;
-
-       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 = '");
-       }
-
-       strncat(stmt, junk_root, MAX_STMT_SIZE - strlen(stmt) - 2);
-       strcat(stmt, "'");
-       _LOGS("stmt: %s", stmt);
-
-       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;
-       }
-
-       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;
-       }
-
-       handle = (junkmgr_result_s *)malloc(sizeof(junkmgr_result_s));
-       if (handle == NULL)
-       {
-               LOGE("out of memory");
-               goto error;
-       }
-
-       handle->db = db;
-       handle->db_stmt = db_stmt;
-
-       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 (db)
-       {
-               ret = sqlite3_close(db);
-               if (ret != SQLITE_OK)
-               {
-                   LOGE("sqlite close error, ret: %d (%s)", ret, sqlite3_errmsg(db));
-               }
-       }
-
-       return NULL;
-}
-
-static int
-__junkmgr_destroy_junk_handle(junkmgr_result_h hnd)
-{
-       int ret = -1;
-
-    junkmgr_result_s *handle = (junkmgr_result_s *)hnd;
-
-       if (!handle || !handle->db || !handle->db_stmt)
-       {
-               return -1;
-       }
-
-       ret = sqlite3_finalize((sqlite3_stmt *)(handle->db_stmt));
-       if (ret != SQLITE_OK)
-       {
-               printf("error %d", __LINE__);
-               return -1;
-       }
-
-       ret = sqlite3_close((sqlite3 *)(handle->db));
-       if (ret != SQLITE_OK)
-       {
-               printf("error %d", __LINE__);
-               return -1;
-       }
-       return 0;
-}
-
-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)
-{
-       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;
-}
-
 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)
@@ -1569,28 +1388,29 @@ static int __get_pkg_size_info_cb(int req_id, const char *req_type,
        _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));
+       pkg_size_info_t *size_info = (pkg_size_info_t *)calloc(1, 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;
-       }
+       tryvm_if(token == NULL, -1, "token is null.");
 
        size_info->data_size = atoll(token);
        token = strtok_r(NULL, ":", &save_ptr);
-       size_info->cache_size = atoll(token);
+       if (token)
+               size_info->cache_size = atoll(token);
        token = strtok_r(NULL, ":", &save_ptr);
-       size_info->app_size = atoll(token);
+       if (token)
+               size_info->app_size = atoll(token);
        token = strtok_r(NULL, ":", &save_ptr);
-       size_info->ext_data_size = atoll(token);
+       if (token)
+               size_info->ext_data_size = atoll(token);
        token = strtok_r(NULL, ":", &save_ptr);
-       size_info->ext_cache_size = atoll(token);
+       if (token)
+               size_info->ext_cache_size = atoll(token);
        token = strtok_r(NULL, ":", &save_ptr);
-       size_info->ext_app_size = atoll(token);
+       if (token)
+               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,
@@ -1619,139 +1439,53 @@ catch:
        return ret;
 }
 
-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)
+static int __get_package_size_info(pkgmgr_client_t *mpc, char *req_key, const char *pkgid, pkgmgr_getsize_type get_type)
 {
-       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 *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;
-       char *cookie = NULL;
-       char pid_str[8] = {0,};
-       int res = 0;
+       int ret = 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");
+       snprintf(buf, 128, "%d", get_type);
+       argv[argcnt++] = strdup(pkgid);
+       argv[argcnt++] = strdup(buf);
+       argv[argcnt++] = strdup("-k");
+       argv[argcnt++] = req_key;
 
-       /* check the mpc type */
-       retvm_if(mpc->ctype != PC_REQUEST, JUNKMGR_E_SYSTEM, "mpc->ctype is not PC_REQUEST");
+       /*** 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);
+       }
 
-       /* 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");
+       args = (char *)calloc(len, sizeof(char));
+       tryvm_if(args == NULL, ret = PKGMGR_R_EINVAL, "args alloc fail");
 
-       /* add callback info - add callback info to pkgmgr_client */
-       req_id = _get_request_id();
+       strncpy(args, argv[0], len - 1);
 
-       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;
+       for (i = 1; i < argcnt; i++) {
+               strncat(args, " ", strlen(" "));
+               temp = g_shell_quote(argv[i]);
+               strncat(args, temp, strlen(temp));
+               g_free(temp);
        }
-
-       __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;
-       }
-       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;
-       }
-       argv[argcnt++] = strdup("-w");
-       argv[argcnt++] = strdup(junk_storage);
-       /* junk path */
-       argv[argcnt++] = strdup("-j");
-       if (junk_path) {
-               argv[argcnt++] = strdup(junk_path);
-       }
-       else {
-               argv[argcnt++] = strdup("ALL");
-       }
-
-       /*** 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 = 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);
-       }
-       _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;
+       _LOGD("[args] %s [len] %d\n", args, len);
 
        /* 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);
+       tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
 
-       *reqid = req_id;
+       /* 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++)
@@ -1760,169 +1494,199 @@ catch:
        if (args)
                free(args);
        if (cookie)
-               free(cookie);
+               g_free(cookie);
 
        return ret;
 }
 
-static int __remove_junk_file(const char *dbpath, const char *junk_path)
+API pkgmgr_client *pkgmgr_client_new(client_type ctype)
 {
-       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;
-       }
+       pkgmgr_client_t *pc = NULL;
+       int ret = -1;
 
-       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)
-       {
-               LOGE("unable to allocate enough memory to hold the resulting string");
-               ret = JUNKMGR_E_NOMEM;
-               goto error;
-       }
+       retvm_if(ctype != PC_REQUEST && ctype != PC_REQUEST_PRIVATE && ctype != PC_LISTENING && ctype != PC_BROADCAST, NULL, "ctype is not client_type");
 
-       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;
-       }
+       /* Allocate memory for ADT:pkgmgr_client */
+       pc = calloc(1, sizeof(pkgmgr_client_t));
+       retvm_if(pc == NULL, NULL, "No memory");
 
-       res = sqlite3_step(db_stmt);
-       if (SQLITE_ROW != res)
-       {
-               LOGE("sqlite step error, res: %d (%s)", res, sqlite3_errmsg(db));
-               goto error;
-       }
+       /* Manage pc */
+       pc->ctype = ctype;
+       pc->status_type = PKGMGR_CLIENT_STATUS_ALL;
+       pc->pkg_chksum = NULL;
 
-       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);
+       if (pc->ctype == PC_REQUEST) {
+               pc->info.request.cc = comm_client_new();
+               trym_if(pc->info.request.cc == NULL, "client creation failed");
 
-       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;
-       }
+               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");
 
-       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;
-       }
+               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");
+       } else if (pc->ctype == PC_REQUEST_PRIVATE) {
+               /* set private connection */
+               pc->info.request.cc = comm_client_new_private();
+               /* reset ctype */
+               pc->ctype = PC_REQUEST;
+               trym_if(pc->info.request.cc == NULL, "client creation failed (private request)");
 
-       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;
+               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);
        }
 
-       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;
-       }
+       return (pkgmgr_client *) pc;
 
-       ret = remove(junk_path);
-       if (ret < 0)
-       {
-               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;
-               }
-       }
+catch:
+       if (pc)
+               free(pc);
+       return NULL;
+}
 
-error:
-       if (SQLITE_OK != res)
-       {
-               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;
+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);
                }
-       }
 
-       if (query)
-       {
-               sqlite3_free(query);
-       }
-       if (error_message)
-       {
-               sqlite3_free(error_message);
-       }
-       if (db_stmt)
-       {
-               sqlite3_finalize(db_stmt);
+               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;
        }
-       if (db)
-       {
-               sqlite3_close(db);
+
+       if (mpc->pkg_chksum) {
+               free(mpc->pkg_chksum);
+               mpc->pkg_chksum = NULL;
        }
 
-       return ret;
-}
+       free(mpc);
+       mpc = NULL;
+       return PKGMGR_R_OK;
 
+ catch:
+       if (mpc) {
+               free(mpc);
+               mpc = NULL;
+       }
+       return PKGMGR_R_ERROR;
+}
 
-static int __get_package_size_info(pkgmgr_client_t *mpc, char *req_key, const char *pkgid, pkgmgr_getsize_type get_type)
+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)
 {
+       _LOGE("install pkg start.");
+
+       char *req_key = NULL;
+       int req_id = 0;
+       int i = 0;
        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;
+       char *cookie = NULL;
+       char *caller_pkgid = NULL;
 
-       snprintf(buf, 128, "%d", get_type);
-       argv[argcnt++] = strdup(pkgid);
-       argv[argcnt++] = strdup(buf);
+       /* 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) >= PATH_MAX, PKGMGR_R_EINVAL, "descriptor_path over PATH_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) >= PATH_MAX, PKGMGR_R_EINVAL, "pkg_path over PATH_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);
+       retvm_if(req_key == NULL, ret = PKGMGR_R_ENOMEM, "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++] = 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);
+       }
+       if (mpc->debug_mode) {
+               argv[argcnt++] = strdup("-G");
+       }
+       if (mpc->pkg_chksum) {
+               argv[argcnt++] = strdup("-C");
+               argv[argcnt++] = strdup(mpc->pkg_chksum);
+       }
+
 
        /*** add quote in all string for special charactor like '\n'***   FIX */
        for (i = 0; i < argcnt; i++) {
@@ -1932,7 +1696,7 @@ static int __get_package_size_info(pkgmgr_client_t *mpc, char *req_key, const ch
        }
 
        args = (char *)calloc(len, sizeof(char));
-       tryvm_if(args == NULL, ret = PKGMGR_R_EINVAL, "installer_path fail");
+       tryvm_if(args == NULL, ret = PKGMGR_R_ERROR, "calloc failed");
 
        strncpy(args, argv[0], len - 1);
 
@@ -1947,513 +1711,201 @@ static int __get_package_size_info(pkgmgr_client_t *mpc, char *req_key, const ch
        /* 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 ************************/
 
-       /* 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);
+       /* 6. request install */
+       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_INSTALL, pkg_type, pkg_path, args, cookie, 1);
+       tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "COMM_REQ_TO_INSTALL failed, ret=%d", ret);
+
+       ret = req_id;
 
 catch:
        for (i = 0; i < argcnt; i++)
                free(argv[i]);
 
-       if(args)
+       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;
-       }
+               g_free(cookie);
+       if (caller_pkgid)
+               free(caller_pkgid);
 
-       _LOGF("[pkgtype = %s,  pkgid = %s, ret = %d] uninstalled \n", pkgtype, pkgid, ret);
+       _LOGE("install pkg finish, ret=[%d]", 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)
+#ifdef _APPFW_FEATURE_EXPANSION_PKG_INSTALL
+API int pkgmgr_client_install_with_tep(pkgmgr_client * pc, const char *pkg_type,
+               const char *descriptor_path, const char *pkg_path,
+               const char *tep_path, bool tep_move, const char *optional_file,
+               pkgmgr_mode mode, pkgmgr_handler event_cb, void *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);
+       _LOGE("started tep pkg installation.");
 
-       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)
-{
+       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;
-       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");
+       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");
 
-static void __run_reset_script(void)
-{
-       DIR *dir;
-       struct dirent entry;
-       struct dirent *result;
-       int ret = 0;
+       /* 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");
 
-       _LOGF("============================================\n");
-       _LOGF("start __run_reset_script\n");
+       if (descriptor_path && strlen(descriptor_path) == 0)
+               descriptor_path = NULL;
+       if (pkg_path && strlen(pkg_path) == 0)
+               pkg_path = NULL;
+       if (tep_path && strlen(tep_path) == 0)
+               tep_path = NULL;
+       if (optional_file && strlen(optional_file) == 0)
+               optional_file = NULL;
 
-       dir = opendir(SOFT_RESET_PATH);
-       if (!dir) {
-               _LOGF("opendir(%s) failed\n", SOFT_RESET_PATH);
-               return;
+  /* 1. check argument */
+       if (descriptor_path) {
+               retvm_if(strlen(descriptor_path) >= PATH_MAX, PKGMGR_R_EINVAL, "descriptor_path over PATH_MAX");
+               retvm_if(access(descriptor_path, F_OK) != 0, PKGMGR_R_EINVAL, "descriptor_path access fail");
        }
 
-       _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;
+       if (tep_path) {
+               // if tep alone is getting installed, pkg path can be NULL
+               if (pkg_path) {
+                       retvm_if(strlen(pkg_path) >= PATH_MAX, PKGMGR_R_EINVAL, "pkg_path over PATH_MAX");
+                       retvm_if(access(pkg_path, F_OK) != 0, PKGMGR_R_EINVAL, "pkg_path access fail");
                }
-
-               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");
+               retvm_if(strlen(tep_path) >= PATH_MAX, PKGMGR_R_EINVAL, "tep_path over PATH_MAX");
+               retvm_if(access(tep_path, F_OK) != 0, PKGMGR_R_EINVAL, "tep_path access fail");
        } 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);\
+               retvm_if(pkg_path == NULL, PKGMGR_R_EINVAL, "pkg_path is NULL");
+               retvm_if(strlen(pkg_path) >= PATH_MAX, PKGMGR_R_EINVAL, "pkg_path over PATH_MAX");
+               retvm_if(access(pkg_path, F_OK) != 0, PKGMGR_R_EINVAL, "pkg_path access fail");
        }
-}
-
-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");
+       if (optional_file)
+               retvm_if(strlen(optional_file) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "optional_file over PKG_STRING_LEN_MAX");
 
-               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");
+       /* 3. generate req_key */
+       if (pkg_path)
+               req_key = __get_req_key(pkg_path);
+       else if (tep_path)
+               req_key = __get_req_key(tep_path);
+       retvm_if(req_key == NULL, ret = PKGMGR_R_ENOMEM, "req_key is NULL");
 
-               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");
-       }
+       /* 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);
 
-       return (pkgmgr_client *) pc;
+       caller_pkgid = __get_caller_pkgid();
+       if (caller_pkgid != NULL)
+               _LOGE("caller pkgid = %s\n", caller_pkgid);
 
-catch:
-       if (pc)
-               free(pc);
-       return NULL;
-}
+       /* 5. generate argv */
 
-API junkmgr_h junkmgr_create_handle(void)
-{
+       /*  argv[0] installer path */
+       argv[argcnt++] = strdup("arg-start");
+       /* argv[1] */
+       argv[argcnt++] = strdup("-k");
+       /* argv[2] */
+       argv[argcnt++] = req_key;
+       /* argv[3] */
+       if (pkg_path)
+               argv[argcnt++] = strdup("-i");
+       /* argv[(4)] if exists */
+       if (descriptor_path)
+               argv[argcnt++] = strdup(descriptor_path);
+       /* argv[4] */
+       if (pkg_path)
+               argv[argcnt++] = strdup(pkg_path);
 
-       junkmgr_s *junkmgr = (junkmgr_s *)malloc(sizeof(junkmgr_s));
-       if (!junkmgr)
-       {
-               LOGE("malloc() failed. The memory is insufficient.");
-               return NULL;
+       /* argv[(5)] if exists */
+       if(tep_path) {
+               argv[argcnt++] = strdup("-e");
+               argv[argcnt++] = strdup(tep_path);
        }
-       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;
+       if (tep_move == true){
+               argv[argcnt++] = strdup("-M");
+               argv[argcnt++] = strdup(TEP_MOVE);
+       }else{
+               argv[argcnt++] = strdup("-M");
+               argv[argcnt++] = strdup(TEP_COPY);
        }
 
-       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;
+       /* argv[(6)] if exists */
+       if (optional_file){
+               argv[argcnt++] = strdup("-o");
+               argv[argcnt++] = strdup(optional_file);
        }
-
-       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;
+       if (caller_pkgid) {
+               argv[argcnt++] = strdup("-p");
+               argv[argcnt++] = strdup(caller_pkgid);
        }
 
-    junkmgr_s *junkmgr = (junkmgr_s *)mgr;
+       /*** add quote in all string for special character like '\n'***   FIX */
+       for (i = 0; i < argcnt; i++) {
+               temp = g_shell_quote(argv[i]);
+               len += (strlen(temp) + 1);
+               g_free(temp);
+       }
 
-    pkgmgr_client_free((pkgmgr_client *)(junkmgr->pc));
-    g_hash_table_destroy(junkmgr->junk_tb);
+       args = (char *)calloc(len, sizeof(char));
+       tryvm_if(args == NULL, ret = PKGMGR_R_ERROR, "calloc failed");
 
-       if (!junkmgr->db_path)
-               free(junkmgr->db_path);
+       strncpy(args, argv[0], len - 1);
 
-       free(junkmgr);
+       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);
 
-    return JUNKMGR_E_SUCCESS;
-}
+       /* 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 ************************/
 
-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");
+       /* 6. request install */
+       ret = comm_client_request_with_tep(mpc->info.request.cc, req_key, COMM_REQ_TO_INSTALL, pkg_type, pkg_path, tep_path, args, cookie, 1);
+       trym_if(ret < 0, "COMM_REQ_TO_INSTALL failed, ret=%d", ret);
 
-       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 = req_id;
 
-               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);
-                       }
+catch:
+       for (i = 0; i < argcnt; i++)
+               free(argv[i]);
 
-                       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;
-       }
+       if (args)
+               free(args);
+       if (cookie)
+               g_free(cookie);
+       if (caller_pkgid)
+               free(caller_pkgid);
 
-       free(mpc);
-       mpc = NULL;
-       return PKGMGR_R_OK;
+       _LOGE("finished tep pkg installation, ret=[%d]", ret);
 
- catch:
-       if (mpc) {
-               free(mpc);
-               mpc = NULL;
-       }
-       return PKGMGR_R_ERROR;
+       return ret;
 }
+#endif
 
-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)
+#ifdef _APPFW_FEATURE_MOUNT_INSTALL
+API int pkgmgr_client_mount_install(pkgmgr_client * pc, const char *pkg_type,
+                       const char *pkg_path, const char *optional_file,
+                       pkgmgr_handler event_cb, void *data)
 {
+       _LOGE("install pkg start.");
+
        char *req_key = NULL;
        int req_id = 0;
        int i = 0;
@@ -2473,14 +1925,8 @@ API int pkgmgr_client_install(pkgmgr_client * pc, const char *pkg_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(strlen(pkg_path) >= PATH_MAX, PKGMGR_R_EINVAL, "pkg_path over PATH_MAX");
        retvm_if(access(pkg_path, F_OK) != 0, PKGMGR_R_EINVAL, "pkg_path access fail");
 
        if (optional_file)
@@ -2488,11 +1934,7 @@ API int pkgmgr_client_install(pkgmgr_client * pc, const char *pkg_type,
 
        /* 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;
-       }
+       retvm_if(req_key == NULL, ret = PKGMGR_R_ENOMEM, "req_key is NULL");
 
        /* 4. add callback info - add callback info to pkgmgr_client */
        req_id = _get_request_id();
@@ -2512,12 +1954,13 @@ API int pkgmgr_client_install(pkgmgr_client * pc, const char *pkg_type,
        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 */
+
+       argv[argcnt++] = strdup("-w");
+
+       /* argv[(6)] if exists */
        if (optional_file){
                argv[argcnt++] = strdup("-o");
                argv[argcnt++] = strdup(optional_file);
@@ -2528,7 +1971,6 @@ API int pkgmgr_client_install(pkgmgr_client * pc, const char *pkg_type,
        }
 
 
-
        /*** add quote in all string for special charactor like '\n'***   FIX */
        for (i = 0; i < argcnt; i++) {
                temp = g_shell_quote(argv[i]);
@@ -2555,8 +1997,8 @@ API int pkgmgr_client_install(pkgmgr_client * pc, const char *pkg_type,
        /******************* 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 = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_INSTALL, pkg_type, pkg_path, args, cookie, 1);
+       tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "COMM_REQ_TO_INSTALL failed, ret=%d", ret);
 
        ret = req_id;
 
@@ -2567,17 +2009,22 @@ catch:
        if (args)
                free(args);
        if (cookie)
-               free(cookie);
+               g_free(cookie);
        if (caller_pkgid)
                free(caller_pkgid);
 
+       _LOGE("install pkg finish, ret=[%d]", ret);
+
        return ret;
 }
+#endif
 
 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)
 {
+       _LOGE("reinstall pkg start.");
+
        char *pkgtype = NULL;
        char *installer_path = NULL;
        char *req_key = NULL;
@@ -2616,12 +2063,12 @@ API int pkgmgr_client_reinstall(pkgmgr_client * pc, const char *pkg_type, const
        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");
+       installer_path = _get_backend_path(pkgid);
+       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");
+       tryvm_if(req_key == NULL, ret = PKGMGR_R_ENOMEM, "req_key is NULL");
 
        /* 4. add callback info - add callback info to pkgmgr_client */
        req_id = _get_request_id();
@@ -2630,7 +2077,7 @@ API int pkgmgr_client_reinstall(pkgmgr_client * pc, const char *pkg_type, const
        /* 5. generate argv */
 
        /*  argv[0] installer path */
-       argv[argcnt++] = installer_path;
+       argv[argcnt++] = strdup(installer_path);
        /* argv[1] */
        argv[argcnt++] = strdup("-k");
        /* argv[2] */
@@ -2645,8 +2092,6 @@ API int pkgmgr_client_reinstall(pkgmgr_client * pc, const char *pkg_type, const
                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]);
@@ -2673,8 +2118,8 @@ API int pkgmgr_client_reinstall(pkgmgr_client * pc, const char *pkg_type, const
        /******************* 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 = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_INSTALL, pkgtype, pkgid, args, cookie, 1);
+       tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "COMM_REQ_TO_INSTALL failed, ret=%d", ret);
 
        ret = req_id;
 
@@ -2685,9 +2130,13 @@ catch:
        if (args)
                free(args);
        if (cookie)
-               free(cookie);
-       if (handle)
-               pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+               g_free(cookie);
+       if (installer_path)
+               free(installer_path);
+
+       pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+
+       _LOGE("reinstall pkg finish, ret=[%d]", ret);
 
        return ret;
 }
@@ -2696,6 +2145,8 @@ API int pkgmgr_client_uninstall(pkgmgr_client *pc, const char *pkg_type,
                                const char *pkgid, pkgmgr_mode mode,
                                pkgmgr_handler event_cb, void *data)
 {
+       _LOGE("uninstall pkg start.");
+
        char *pkgtype = NULL;
        char *installer_path = NULL;
        char *req_key = NULL;
@@ -2722,16 +2173,19 @@ API int pkgmgr_client_uninstall(pkgmgr_client *pc, const char *pkg_type,
        /* 1. check argument */
        retv_if(pkgid == NULL, PKGMGR_R_EINVAL);
 
-       pkgmgrinfo_pkginfo_h handle;
+       pkgmgrinfo_pkginfo_h handle = NULL;
        ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+       if (ret < 0) {
+               ret = pkgmgrinfo_pkginfo_get_unmounted_pkginfo(pkgid, &handle);
+       }
 
        /*check package id      */
-       tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_pkginfo_get_pkginfo fail");
+       tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgrinfo_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(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgrinfo_pkginfo_get_type fail");
        tryvm_if(pkgtype == NULL, ret = PKGMGR_R_ERROR, "pkgtype is NULL");
 
        /*check removable*/
@@ -2742,12 +2196,12 @@ API int pkgmgr_client_uninstall(pkgmgr_client *pc, const char *pkg_type,
        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);
+       installer_path = _get_backend_path(pkgid);
        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");
+       tryvm_if(req_key == NULL, ret = PKGMGR_R_ENOMEM, "req_key is NULL");
 
        /* 4. add callback info - add callback info to pkgmgr_client */
        req_id = _get_request_id();
@@ -2760,7 +2214,7 @@ API int pkgmgr_client_uninstall(pkgmgr_client *pc, const char *pkg_type,
        /* 5. generate argv */
 
        /* argv[0] installer path */
-       argv[argcnt++] = installer_path;
+       argv[argcnt++] = strdup(installer_path);
        /* argv[1] */
        argv[argcnt++] = strdup("-k");
        /* argv[2] */
@@ -2800,9 +2254,9 @@ API int pkgmgr_client_uninstall(pkgmgr_client *pc, const char *pkg_type,
        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);
+       /* 6. request uninstall */
+       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_UNINSTALL, pkgtype, pkgid, args, cookie, 1);
+       tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "COMM_REQ_TO_UNINSTALL failed, ret=%d", ret);
 
        ret = req_id;
 
@@ -2813,15 +2267,21 @@ catch:
        if (args)
                free(args);
        if (cookie)
-               free(cookie);
+               g_free(cookie);
+       if (installer_path)
+               free(installer_path);
 
        pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
-       PKGMGR_END();\
+
+       _LOGE("uninstall pkg finish, ret=[%d]", ret);
+
        return ret;
 }
 
 API int pkgmgr_client_move(pkgmgr_client *pc, const char *pkgid, pkgmgr_move_type move_type, pkgmgr_handler event_cb, void *data)
 {
+       _LOGE("move pkg[%s] start.", pkgid);
+
        char *pkgtype = NULL;
        char *installer_path= NULL;
        char *req_key = NULL;
@@ -2839,7 +2299,6 @@ API int pkgmgr_client_move(pkgmgr_client *pc, const char *pkgid, pkgmgr_move_typ
 
        /* 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;
 
@@ -2853,7 +2312,7 @@ API int pkgmgr_client_move(pkgmgr_client *pc, const char *pkgid, pkgmgr_move_typ
        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(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgrinfo_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);
@@ -2861,7 +2320,7 @@ API int pkgmgr_client_move(pkgmgr_client *pc, const char *pkgid, pkgmgr_move_typ
 
        /*check type    */
        ret = pkgmgrinfo_pkginfo_get_type(handle, &pkgtype);
-       tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_pkginfo_get_type fail");
+       tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgrinfo_pkginfo_get_type fail");
        tryvm_if(pkgtype == NULL, ret = PKGMGR_R_ERROR, "pkgtype is NULL");
 
        /*check pkgid length    */
@@ -2871,12 +2330,12 @@ API int pkgmgr_client_move(pkgmgr_client *pc, const char *pkgid, pkgmgr_move_typ
        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);
+       installer_path = _get_backend_path(pkgid);
        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");
+       tryvm_if(req_key == NULL, ret = PKGMGR_R_ENOMEM, "req_key is NULL");
 
        /* 4. add callback info - add callback info to pkgmgr_client */
        req_id = _get_request_id();
@@ -2885,7 +2344,7 @@ API int pkgmgr_client_move(pkgmgr_client *pc, const char *pkgid, pkgmgr_move_typ
        /* 5. generate argv */
        snprintf(buf, 128, "%d", move_type);
        /* argv[0] installer path */
-       argv[argcnt++] = installer_path;
+       argv[argcnt++] = strdup(installer_path);
        /* argv[1] */
        argv[argcnt++] = strdup("-k");
        /* argv[2] */
@@ -2928,7 +2387,7 @@ API int pkgmgr_client_move(pkgmgr_client *pc, const char *pkgid, pkgmgr_move_typ
 
        /* 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);
+       trym_if(ret < 0, "COMM_REQ_TO_MOVER failed, ret=%d", ret);
 
        ret = req_id;
 
@@ -2936,25 +2395,28 @@ catch:
        for (i = 0; i < argcnt; i++)
                free(argv[i]);
 
-       if(args)
+       if (args)
                free(args);
        if (cookie)
-               free(cookie);
+               g_free(cookie);
+       if (installer_path)
+               free(installer_path);
 
        pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
-       PKGMGR_END();\
 
-       _LOGE("move pkg[%s] finish[%d]", pkgid, ret);
+       _LOGE("move pkg[%s] finish, ret=[%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);
+       _LOGE("activate pkg[%s] start", pkgid);
 
        char *req_key = NULL;
        int ret = 0;
        pkgmgrinfo_pkginfo_h handle = NULL;
+       char *cookie = NULL;
 
        /* Check for NULL value of pc */
        retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
@@ -2978,10 +2440,14 @@ API int pkgmgr_client_activate(pkgmgr_client * pc, const char *pkg_type, const c
 
        /* 2. generate req_key */
        req_key = __get_req_key(pkgid);
-       retvm_if(req_key == NULL, PKGMGR_R_EINVAL, "req_key is NULL");
+       retvm_if(req_key == NULL, PKGMGR_R_ENOMEM, "req_key is NULL");
+
+       /* 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");
 
        /* 3. request activate */
-       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_ACTIVATE_PKG, "pkg", pkgid, NULL, NULL, 1);
+       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_ACTIVATE_PKG, "pkg", pkgid, NULL, cookie, 1);
        tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "COMM_REQ_ACTIVATE_PKG failed, ret=%d", ret);
 
        ret = PKGMGR_R_OK;
@@ -2989,18 +2455,21 @@ API int pkgmgr_client_activate(pkgmgr_client * pc, const char *pkg_type, const c
 catch:
        if (req_key)
                free(req_key);
-       _LOGE("pkgmgr_client_activate[%s] finish[%d]", pkgid, ret);
+       if (cookie)
+               g_free(cookie);
+       _LOGE("activate pkg finish[%d]", 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);
+       _LOGE("deactivate pkg[%s] start", pkgid);
 
        char *req_key = NULL;
        int ret = 0;
        pkgmgrinfo_pkginfo_h handle = NULL;
+       char *cookie = NULL;
 
        /* Check for NULL value of pc */
        retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
@@ -3023,10 +2492,14 @@ API int pkgmgr_client_deactivate(pkgmgr_client *pc, const char *pkg_type, const
 
        /* 2. generate req_key */
        req_key = __get_req_key(pkgid);
-       tryvm_if(req_key == NULL, ret = PKGMGR_R_ERROR, "req_key is NULL");
+       tryvm_if(req_key == NULL, ret = PKGMGR_R_ENOMEM, "req_key is NULL");
+
+       /* 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");
 
        /* 3. request activate */
-       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_DEACTIVATE_PKG, "pkg", pkgid, NULL, NULL, 1);
+       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_DEACTIVATE_PKG, "pkg", pkgid, NULL, cookie, 1);
        tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "COMM_REQ_DEACTIVATE_PKG failed, ret=%d", ret);
 
        ret = PKGMGR_R_OK;
@@ -3034,21 +2507,26 @@ API int pkgmgr_client_deactivate(pkgmgr_client *pc, const char *pkg_type, const
 catch:
        if (req_key)
                free(req_key);
-       pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
-       _LOGE("pkgmgr_client_deactivate[%s] finish[%d]", pkgid, ret);
+       if (cookie)
+               g_free(cookie);
+       if (handle)
+               pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+
+       _LOGE("deactivate pkg finish, ret=[%d]", ret);
 
        return ret;
 }
 
 API int pkgmgr_client_activate_app(pkgmgr_client * pc, const char *appid)
 {
-       _LOGE("pkgmgr_client_activate_app[%s] start", appid);
+       _LOGE("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, };
+       char *cookie = NULL;
 
        /* Check for NULL value of pc */
        retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
@@ -3064,7 +2542,7 @@ API int pkgmgr_client_activate_app(pkgmgr_client * pc, const char *appid)
 
        /* 2. generate req_key */
        req_key = __get_req_key(appid);
-       retvm_if(req_key == NULL, PKGMGR_R_EINVAL, "req_key is NULL");
+       retvm_if(req_key == NULL, PKGMGR_R_ENOMEM, "req_key is NULL");
 
        snprintf(activation_info_file, PKG_STRING_LEN_MAX, "%s/%s", PKG_DATA_PATH, appid);
        fp = fopen(activation_info_file, "w");
@@ -3075,8 +2553,12 @@ API int pkgmgr_client_activate_app(pkgmgr_client * pc, const char *appid)
        fsync(fd);
        fclose(fp);
 
+       /* 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");
+
        /* 3. request activate */
-       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_ACTIVATE_APP, "pkg", appid, NULL, NULL, 1);
+       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_ACTIVATE_APP, "pkg", appid, NULL, cookie, 1);
        tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "COMM_REQ_ACTIVATE_APP failed, ret=%d", ret);
 
        ret = PKGMGR_R_OK;
@@ -3084,24 +2566,28 @@ API int pkgmgr_client_activate_app(pkgmgr_client * pc, const char *appid)
 catch:
        if (req_key)
                free(req_key);
-       _LOGE("pkgmgr_client_activate_app[%s] finish[%d]", appid, ret);
+       if (cookie)
+               g_free(cookie);
+       _LOGE("activate app finish, ret=[%d]", 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);
+       _LOGE("activate app[%s] with label 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, };
+       char *cookie = NULL;
 
        /* Check for NULL value of pc */
        retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
+       retvm_if(argv == NULL, PKGMGR_R_EINVAL, "argv is NULL\n");
+       retvm_if(argv[0] == NULL, PKGMGR_R_EINVAL, "argv[0] is NULL\n");
 
        pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
 
@@ -3114,56 +2600,135 @@ API int pkgmgr_client_activate_appv(pkgmgr_client * pc, const char *appid, char
 
        /* 2. generate req_key */
        req_key = __get_req_key(appid);
-       retvm_if(req_key == NULL, PKGMGR_R_EINVAL, "req_key is NULL");
+       retvm_if(req_key == NULL, PKGMGR_R_ENOMEM, "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);
+       _LOGE("activate_appv label[%s]", argv[1]);
+       fwrite(argv[1], sizeof(char), strlen(argv[1]), fp);
+
+       fflush(fp);
+       fd = fileno(fp);
+       fsync(fd);
+       fclose(fp);
+
+       /* 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");
+
+       /* 3. request activate */
+       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_ACTIVATE_APP_WITH_LABEL, "pkg", appid, argv[1], cookie, 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 (req_key)
+               free(req_key);
+       if (cookie)
+               g_free(cookie);
+       _LOGE("activate app with label finish, ret=[%d]", ret);
+
+       return ret;
+}
+
+API int pkgmgr_client_deactivate_app(pkgmgr_client *pc, const char *appid)
+{
+       _LOGE("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");
+       char *cookie = NULL;
+
+       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_ENOMEM, "req_key is NULL");
+
+       /* 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");
+
+       /* 3. request activate */
+       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_DEACTIVATE_APP, "pkg", appid, NULL, cookie, 1);
+       tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "COMM_REQ_TO_DEACTIVATOR failed, ret=%d", ret);
+
+       ret = PKGMGR_R_OK;
+
+catch:
+       if (req_key)
+               free(req_key);
+       if (cookie)
+               g_free(cookie);
+       _LOGE("deactivate app finish, ret=[%d]", ret);
+
+       return ret;
+}
+
+API int pkgmgr_client_enable_app_bg_operation(pkgmgr_client *pc, const char *appid)
+{
+       _LOGE("enabe app bg operation[%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");
+       char *cookie = NULL;
+
+       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, "appid is NULL");
+       retvm_if(strlen(appid) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "appid 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");
 
-                       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;
+       /* 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");
 
        /* 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 = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_ENABLE_BG_OPERATION, "pkg", appid, NULL, cookie, 1);
+       tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "COMM_REQ_ENABLE_BG_OPERATION failed, ret=%d", ret);
 
        ret = PKGMGR_R_OK;
 
 catch:
-
-       if (args)
-               free(args);
-       if (req_key)
+       if(req_key)
                free(req_key);
-       if (fp)
-               fclose(fp);
-
-       _LOGE("pkgmgr_client_activate_appv[%s] finish[%d]", appid, ret);
-
+       if (cookie)
+               g_free(cookie);
+       _LOGE("enabling app bg operation finish, ret=[%d]", ret);
        return ret;
 }
 
-API int pkgmgr_client_deactivate_app(pkgmgr_client *pc, const char *appid)
+API int pkgmgr_client_disable_app_bg_operation(pkgmgr_client *pc, const char *appid)
 {
-       _LOGE("pkgmgr_client_deactivate_app[%s] start.", appid);
+       _LOGE("disable app bg operation[%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");
+       char *cookie = NULL;
 
        pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
 
@@ -3171,30 +2736,39 @@ API int pkgmgr_client_deactivate_app(pkgmgr_client *pc, const char *appid)
        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 ");
+       retvm_if(appid == NULL, PKGMGR_R_EINVAL, "appid is NULL");
+       retvm_if(strlen(appid) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "appid 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");
 
+       /* 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");
+
        /* 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 = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_DISABLE_BG_OPERATION, "pkg", appid, NULL, cookie, 1);
+       tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "COMM_REQ_DISABLE_BG_OPERATION failed, ret=%d", ret);
 
        ret = PKGMGR_R_OK;
 
 catch:
-       free(req_key);
-       _LOGE("pkgmgr_client_deactivate_app[%s] finish[%d]", appid, ret);
+       if(req_key)
+               free(req_key);
+       if (cookie)
+               g_free(cookie);
+       _LOGE("disabling app bg operation finish, ret=[%d]", ret);
        return ret;
 }
 
-
 API int pkgmgr_client_clear_user_data(pkgmgr_client *pc, const char *pkg_type,
                                      const char *appid, pkgmgr_mode mode)
 {
+       _LOGE("clear user data[%s] start.", appid);
+
        const char *pkgtype = NULL;
+       char *pkgid = NULL;
        char *installer_path = NULL;
        char *req_key = NULL;
        int i = 0;
@@ -3232,18 +2806,23 @@ API int pkgmgr_client_clear_user_data(pkgmgr_client *pc, const char *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);
+       /* 2. get installer path using pkg_id */
+       if(__get_pkgid_by_appid(appid, &pkgid)){
+               return PKGMGR_R_ERROR;
+       }
+
+       installer_path = _get_backend_path(pkgid);
        if (installer_path == NULL)
                return PKGMGR_R_EINVAL;
 
        /* 3. generate req_key */
        req_key = __get_req_key(appid);
+       tryvm_if(req_key == NULL, ret = PKGMGR_R_ENOMEM, "req_key is NULL");
 
        /* 4. generate argv */
 
        /* argv[0] installer path */
-       argv[argcnt++] = installer_path;
+       argv[argcnt++] = strdup(installer_path);
        /* argv[1] */
        argv[argcnt++] = strdup("-k");
        /* argv[2] */
@@ -3253,7 +2832,6 @@ API int pkgmgr_client_clear_user_data(pkgmgr_client *pc, const char *pkg_type,
        /* 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]);
@@ -3262,14 +2840,8 @@ API int pkgmgr_client_clear_user_data(pkgmgr_client *pc, const char *pkg_type,
        }
 
        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_ERROR, "calloc failed");
 
-               return PKGMGR_R_ERROR;
-       }
        strncpy(args, argv[0], len - 1);
 
        for (i = 1; i < argcnt; i++) {
@@ -3291,8 +2863,14 @@ catch:
        for (i = 0; i < argcnt; i++)
                free(argv[i]);
 
-       if(args)
+       if (args)
                free(args);
+       if (installer_path)
+               free(installer_path);
+       if(pkgid)
+               free(pkgid);
+
+       _LOGE("clear user data finish, ret=[%d]", ret);
 
        return ret;
 }
@@ -3358,6 +2936,28 @@ API int pkgmgr_client_set_status_type(pkgmgr_client *pc, int status_type)
    return PKGMGR_R_OK;
 }
 
+API int pkgmgr_client_set_pkg_chksum(pkgmgr_client *pc, char *pkg_chksum)
+{
+       retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client pc is NULL");
+       retvm_if(pkg_chksum == NULL, PKGMGR_R_EINVAL, "cert value is NULL");
+       pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+
+       mpc->pkg_chksum = strdup(pkg_chksum);
+
+       return PKGMGR_R_OK;
+}
+
+API int pkgmgr_client_set_debug_mode(pkgmgr_client *pc, bool debug_mode)
+{
+       retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client pc is NULL");
+       pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+
+       mpc->debug_mode = debug_mode;
+
+       return PKGMGR_R_OK;
+}
+
+
 API int pkgmgr_client_listen_status(pkgmgr_client *pc, pkgmgr_handler event_cb,
                                    void *data)
 {
@@ -3378,6 +2978,27 @@ API int pkgmgr_client_listen_status(pkgmgr_client *pc, pkgmgr_handler event_cb,
        return req_id;
 }
 
+API int pkgmgr_client_listen_status_with_zone(pkgmgr_client *pc,
+               pkgmgr_handler_with_zone 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_with_zone(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)
@@ -3408,7 +3029,7 @@ API int pkgmgr_client_broadcast_status(pkgmgr_client *pc, const char *pkg_type,
 API pkgmgr_info *pkgmgr_client_check_pkginfo_from_file(const char *pkg_path)
 {
        int ret = PKGMGR_R_OK;
-       char *pkgtype = NULL;
+       char *pkg_backend = NULL;
        pkg_plugin_set *plugin_set = NULL;
        package_manager_pkg_detail_info_t *pkg_detail_info = NULL;
 
@@ -3417,10 +3038,10 @@ API pkgmgr_info *pkgmgr_client_check_pkginfo_from_file(const char *pkg_path)
        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);
+       pkg_backend = _get_backend_from_zip(pkg_path);
+       tryvm_if(pkg_backend == NULL, ret = PKGMGR_R_ERROR, "type is NULL for path[%s]", pkg_path);
 
-       plugin_set = _package_manager_load_library(pkgtype);
+       plugin_set = _package_manager_load_library(pkg_backend);
        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);
@@ -3429,8 +3050,8 @@ API pkgmgr_info *pkgmgr_client_check_pkginfo_from_file(const char *pkg_path)
        ret = PKGMGR_R_OK;
 
 catch:
-       if (pkgtype)
-               free(pkgtype);
+       if (pkg_backend)
+               free(pkg_backend);
 
        if (ret < 0) {
                free(pkg_detail_info);
@@ -3450,6 +3071,9 @@ API int pkgmgr_client_free_pkginfo(pkgmgr_info * pkg_info)
        if (info->icon_buf)
                free(info->icon_buf);
 
+       if(info->pkg_optional_info)
+               free(info->pkg_optional_info);
+
        free(info);
        info = NULL;
 
@@ -3528,6 +3152,7 @@ API int pkgmgr_client_request_size_info(void) // get all package size (data, tot
        pc = pkgmgr_client_new(PC_REQUEST);
        retvm_if(pc == NULL, PKGMGR_R_EINVAL, "request pc is null\n");
 
+       _LOGD("called");
        ret = __request_size_info(pc);
        if (ret < 0) {
                _LOGE("__request_size_info fail \n");
@@ -3539,6 +3164,8 @@ API int pkgmgr_client_request_size_info(void) // get all package size (data, tot
 
 API int pkgmgr_client_clear_cache_dir(const char *pkgid)
 {
+       _LOGD("clear cache dir[%s] start", pkgid);
+
        retvm_if(pkgid == NULL, PKGMGR_R_EINVAL, "package id is null\n");
 
        int ret = 0;
@@ -3562,10 +3189,10 @@ API int pkgmgr_client_clear_cache_dir(const char *pkgid)
        }
        else
        {
-               pkg_type = (char *)malloc(strlen("rpm") + 1);
-               tryvm_if(pkg_type == NULL, ret = PKGMGR_R_ENOMEM, "out of memory");
-
-               strcpy(pkg_type, "rpm");
+               int len = strlen("rpm") + 1;
+               pkg_type = (char *)calloc(len, sizeof(char));
+               tryvm_if(pkg_type == NULL, ret = PKGMGR_R_ESYSTEM, "memory alloc failed");
+               strncpy(pkg_type, "rpm", len);
                is_type_malloced = 1;
        }
 
@@ -3578,7 +3205,7 @@ API int pkgmgr_client_clear_cache_dir(const char *pkgid)
        ret = PKGMGR_R_OK;
 catch:
        if (cookie)
-               free(cookie);
+               g_free(cookie);
 
        if (pc)
                pkgmgr_client_free(pc);
@@ -3588,6 +3215,8 @@ catch:
 
        pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
 
+       _LOGE("clear cache dir finish, ret=[%d]", ret);
+
        return ret;
 }
 
@@ -3598,6 +3227,33 @@ API int pkgmgr_client_clear_all_cache_dir(void)
        return ret;
 }
 
+char* __get_getsize_type_string(pkgmgr_getsize_type get_type)
+{
+       char *str = "NULL";
+
+       if (get_type == PM_GET_TOTAL_SIZE) {
+               str = "PM_GET_TOTAL_SIZE";
+       } else if (get_type == PM_GET_DATA_SIZE) {
+               str = "PM_GET_DATA_SIZE";
+       } else if (get_type == PM_GET_ALL_PKGS) {
+               str = "PM_GET_ALL_PKGS";
+       } else if (get_type == PM_GET_SIZE_INFO) {
+               str = "PM_GET_SIZE_INFO";
+       } else if (get_type == PM_GET_TOTAL_AND_DATA) {
+               str = "PM_GET_TOTAL_AND_DATA";
+       } else if (get_type == PM_GET_SIZE_FILE) {
+               str = "PM_GET_SIZE_FILE";
+       } else if (get_type == PM_GET_PKG_SIZE_INFO) {
+               str = "PM_GET_PKG_SIZE_INFO";
+       } else if (get_type == PM_GET_TOTAL_PKG_SIZE_INFO) {
+               str = "PM_GET_TOTAL_PKG_SIZE_INFO";
+       } else if (get_type == PM_GET_MAX) {
+               str = "PM_GET_MAX";
+       }
+
+       return str;
+}
+
 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;
@@ -3615,11 +3271,12 @@ API int pkgmgr_client_get_size(pkgmgr_client *pc, const char *pkgid, pkgmgr_gets
        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");
+       retvm_if(req_key == NULL, PKGMGR_R_ENOMEM, "req_key is NULL");
 
        req_id = _get_request_id();
        __add_op_cbinfo(mpc, req_id, req_key, event_cb, NULL, data);
 
+       _LOGD("package=[%s], get_type=[%s][%d]", pkgid, __get_getsize_type_string(get_type), (int)get_type);
        ret = __get_package_size_info(mpc, req_key, pkgid, get_type);
 
        return ret;
@@ -3627,44 +3284,40 @@ API int pkgmgr_client_get_size(pkgmgr_client *pc, const char *pkgid, pkgmgr_gets
 
 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 ret = 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
+       // total package size info
+       if (strcmp(pkgid, PKG_SIZE_INFO_TOTAL) == 0) {
                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);
-               }
+       } else {
+               pkgmgrinfo_pkginfo_h handle = NULL;
+               ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+               pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+               retvm_if(ret != PMINFO_R_OK, ret = PKGMGR_R_ENOPKG, "pkgmgr_pkginfo_get_pkginfo failed");
        }
 
        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");
+       ret = __change_op_cb_for_getsize(mpc);
+       retvm_if(ret < 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");
+       retvm_if(req_key == NULL, PKGMGR_R_ENOMEM, "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);
+       _LOGD("package=[%s], get_type=[%s][%d]", pkgid, __get_getsize_type_string(type), (int)type);
+       ret = __get_package_size_info(mpc, req_key, pkgid, type);
 
-       return res;
+       return ret;
 }
 
 API int pkgmgr_client_get_total_package_size_info(pkgmgr_client *pc, pkgmgr_total_pkg_size_info_receive_cb event_cb, void *user_data)
@@ -3672,256 +3325,6 @@ API int pkgmgr_client_get_total_package_size_info(pkgmgr_client *pc, pkgmgr_tota
        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)
 {
@@ -4088,91 +3491,3 @@ API int pkgmgr_pkginfo_destroy_certinfo(pkgmgr_certinfo_h handle)
        return ret;
 }
 
-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 junkmgr_result_cursor_get_junk_name(junkmgr_result_h hnd, char **junk_name)
-{
-    junkmgr_result_s *handle = (junkmgr_result_s *)hnd;
-
-    int size = sqlite3_column_bytes((sqlite3_stmt *)(handle->db_stmt), 0);
-    char *name = (char *)sqlite3_column_text((sqlite3_stmt *)(handle->db_stmt), 0);
-
-    *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 junkmgr_result_cursor_get_category(junkmgr_result_h hnd, junkmgr_category_e *category)
-{
-    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 junkmgr_result_cursor_get_file_type(junkmgr_result_h hnd, junkmgr_file_type_e *file_type)
-{
-    junkmgr_result_s *handle = (junkmgr_result_s *)hnd;
-
-       int type = sqlite3_column_int((sqlite3_stmt *)(handle->db_stmt), 2);
-    *file_type = (junkmgr_file_type_e)type;
-    return JUNKMGR_E_SUCCESS;
-}
-
-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;
-
-       int where = sqlite3_column_int((sqlite3_stmt *)(handle->db_stmt), 3);
-    *storage = (junkmgr_storage_type_e)where;
-    return JUNKMGR_E_SUCCESS;
-}
-
-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 junkmgr_result_cursor_get_junk_path(junkmgr_result_h hnd, char **junk_path)
-{
-    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;
-}
index e33364a..3da8738 100755 (executable)
@@ -6,9 +6,12 @@ cmake_minimum_required(VERSION 2.6)
 #set(CMAKE_SKIP_BUILD_RPATH true)
 set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
 
+IF(_APPFW_FEATURE_EXPANSION_PKG_INSTALL)
+        ADD_DEFINITIONS("-D_APPFW_FEATURE_EXPANSION_PKG_INSTALL")
+ENDIF(_APPFW_FEATURE_EXPANSION_PKG_INSTALL)
 
 ### Versioning
-if(DEFINED ${VERSION}) 
+if(DEFINED ${VERSION})
        message("VERSION: ${VERSION}")
 else()
        message("VERSION is not defined. set it as 0.1.0")
@@ -25,7 +28,7 @@ message(STATUS "version/major : ${VERSION} / ${VERSION_MAJOR}")
 ### Get required CFLAGS, LDFLAGS from pkg-config
 
 include(FindPkgConfig)
-pkg_check_modules(comm_pkgs REQUIRED dbus-1 glib-2.0 dbus-glib-1 gio-2.0 gio-unix-2.0 dlog pkgmgr-info)
+pkg_check_modules(comm_pkgs REQUIRED dbus-1 glib-2.0 dbus-glib-1 gio-2.0 gio-unix-2.0 dlog pkgmgr-info db-util)
 
 foreach(flag ${comm_pkgs_CFLAGS})
        set(comm_pkgs_CFLAGS_str "${comm_pkgs_CFLAGS_str} ${flag}")
@@ -35,35 +38,29 @@ endforeach()
 ### Set current binary dir to be included (for generated *.h files)
 include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
 
-### Create dbus-glib bindings headers (client/server) from xml by dbus-binding-tool
-
-# comm_pkg_mgr : package manger interface (client - package manager process)
-add_custom_target(comm_pkg_mgr_client_dbus_bindings.h
-       COMMAND dbus-binding-tool --prefix=pkgmgr --mode=glib-client 
-                       ${CMAKE_CURRENT_SOURCE_DIR}/comm_pkg_mgr.xml 
-                       --output=${CMAKE_CURRENT_BINARY_DIR}/comm_pkg_mgr_client_dbus_bindings.h
-       )
-add_custom_target(comm_pkg_mgr_server_dbus_bindings.h
-       COMMAND dbus-binding-tool --prefix=pkgmgr --mode=glib-server
-                       ${CMAKE_CURRENT_SOURCE_DIR}/comm_pkg_mgr.xml 
-                       --output=${CMAKE_CURRENT_BINARY_DIR}/comm_pkg_mgr_server_dbus_bindings.h
-       )
-
+IF(_APPFW_FEATURE_EXPANSION_PKG_INSTALL)
 #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
+add_custom_command(OUTPUT comm_pkg_mgr_gdbus_generated.c comm_pkg_mgr_gdbus_generated.h
+    COMMAND gdbus-codegen --generate-c-code comm_pkg_mgr_gdbus_generated
+            --interface-prefix pkgmgr ${CMAKE_CURRENT_SOURCE_DIR}/comm_pkg_mgr_ext.xml
+    )
+ELSE(_APPFW_FEATURE_EXPANSION_PKG_INSTALL)
+add_custom_command(OUTPUT comm_pkg_mgr_gdbus_generated.c comm_pkg_mgr_gdbus_generated.h
+       COMMAND gdbus-codegen --generate-c-code comm_pkg_mgr_gdbus_generated
                        --interface-prefix pkgmgr ${CMAKE_CURRENT_SOURCE_DIR}/comm_pkg_mgr.xml
        )
+ENDIF(_APPFW_FEATURE_EXPANSION_PKG_INSTALL)
+
 
 # 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 
-                       ${CMAKE_CURRENT_SOURCE_DIR}/comm_status_broadcast.xml 
+       COMMAND dbus-binding-tool --prefix=status_broadcast --mode=glib-client
+                       ${CMAKE_CURRENT_SOURCE_DIR}/comm_status_broadcast.xml
                        --output=${CMAKE_CURRENT_BINARY_DIR}/comm_status_broadcast_client_dbus_bindings.h
        )
 add_custom_target(comm_status_broadcast_server_dbus_bindings.h
        COMMAND dbus-binding-tool --prefix=status_broadcast --mode=glib-server
-                       ${CMAKE_CURRENT_SOURCE_DIR}/comm_status_broadcast.xml 
+                       ${CMAKE_CURRENT_SOURCE_DIR}/comm_status_broadcast.xml
                        --output=${CMAKE_CURRENT_BINARY_DIR}/comm_status_broadcast_server_dbus_bindings.h
        )
 
@@ -86,7 +83,8 @@ set_source_files_properties(comm_status_broadcast_signal_marshaller.c PROPERTIES
 # Send request, get status signal
 add_library(pkgmgr_installer_client SHARED
                comm_client_gdbus.c
-               comm_pkg_mgr_client_gdbus_generated.c
+               comm_pkg_mgr_gdbus_generated.c
+               comm_internal.c
                #${CMAKE_CURRENT_BINARY_DIR}/comm_status_broadcast_signal_marshaller.c
                )
 set_target_properties(pkgmgr_installer_client PROPERTIES SOVERSION ${VERSION_MAJOR})
@@ -94,23 +92,26 @@ 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_gdbus_generated.h comm_pkg_mgr_client_gdbus_generated.c)
+add_dependencies(pkgmgr_installer_client comm_pkg_mgr_gdbus_generated.h comm_pkg_mgr_gdbus_generated.c)
 
 ## pkg-mgr server for PMS
 # Get request
-add_library(pkgmgr_installer_pkg_mgr_server STATIC
+add_library(pkgmgr_installer_pkg_mgr_server SHARED
                comm_pkg_mgr_server.c
+               comm_pkg_mgr_gdbus_generated.c
+               comm_internal.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} -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)
+add_dependencies(pkgmgr_installer_pkg_mgr_server  comm_pkg_mgr_gdbus_generated.h comm_pkg_mgr_gdbus_generated.c)
 
 ## status-broadcast server for backend/downloader
 # Send signal
 add_library(pkgmgr_installer_status_broadcast_server SHARED
                comm_status_broadcast_server_dbus.c
+               comm_internal.c
        )
 set_target_properties(pkgmgr_installer_status_broadcast_server PROPERTIES SOVERSION ${VERSION_MAJOR})
 set_target_properties(pkgmgr_installer_status_broadcast_server PROPERTIES VERSION ${VERSION})
@@ -119,18 +120,12 @@ target_link_libraries(pkgmgr_installer_status_broadcast_server ${comm_pkgs_LDFLA
 add_dependencies(pkgmgr_installer_status_broadcast_server comm_status_broadcast_server_dbus_bindings.h)
 
 
-## comm_socket
-# Internal lib
-add_library(comm_socket STATIC comm_socket.c)
-set_target_properties(comm_socket PROPERTIES COMPILE_FLAGS "${comm_pkgs_CFLAGS_str}")
-#target_link_libraries(comm_socket)
-
 ## pkgmgr_installer object (by youmin.ha)
 # This library is for installer backend
 add_library(pkgmgr_installer SHARED pkgmgr_installer.c)
 set_target_properties(pkgmgr_installer PROPERTIES SOVERSION ${VERSION_MAJOR})
 set_target_properties(pkgmgr_installer PROPERTIES VERSION ${VERSION})
-set_target_properties(pkgmgr_installer PROPERTIES COMPILE_FLAGS "${comm_pkgs_CFLAGS_str}")
+set_target_properties(pkgmgr_installer PROPERTIES COMPILE_FLAGS "${comm_pkgs_CFLAGS_str} -fPIC")
 target_link_libraries(pkgmgr_installer pkgmgr_installer_status_broadcast_server ${comm_pkgs_LDFLAGS})
 
 
@@ -138,33 +133,28 @@ target_link_libraries(pkgmgr_installer pkgmgr_installer_status_broadcast_server
 configure_file(pkgmgr-installer-client.pc.in ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-installer-client.pc @ONLY)
 configure_file(pkgmgr-installer-status-broadcast-server.pc.in ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-installer-status-broadcast-server.pc @ONLY)
 configure_file(pkgmgr-installer.pc.in ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-installer.pc @ONLY)
-
+configure_file(pkgmgr-installer-pkg-mgr-server.pc.in ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-installer-pkg-mgr-server.pc @ONLY)
 
 ## Install
-INSTALL(TARGETS 
-                       pkgmgr_installer_client 
+INSTALL(TARGETS
+                       pkgmgr_installer_client
                        pkgmgr_installer_status_broadcast_server
                        pkgmgr_installer
+                       pkgmgr_installer_pkg_mgr_server
                DESTINATION lib
                COMPONENT RuntimeLibraries)
-INSTALL(FILES 
-                       comm_client.h 
+INSTALL(FILES
+                       comm_client.h
                        comm_status_broadcast_server.h
                        comm_config.h
+                       comm_pkg_mgr_server.h
                        pkgmgr_installer.h
                DESTINATION include/pkgmgr)
 
 
-INSTALL(FILES 
-               ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-installer-client.pc 
-               ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-installer-status-broadcast-server.pc 
-               ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-installer.pc 
+INSTALL(FILES
+               ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-installer-client.pc
+               ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-installer-status-broadcast-server.pc
+               ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-installer.pc
+               ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-installer-pkg-mgr-server.pc
                DESTINATION lib/pkgconfig)
-
-
-
-
-## test
-add_subdirectory(test)
-
-
diff --git a/comm/SLP_package_manager_frontend_backend_PG.h b/comm/SLP_package_manager_frontend_backend_PG.h
deleted file mode 100755 (executable)
index bc072b8..0000000
+++ /dev/null
@@ -1,470 +0,0 @@
-/*
- * 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.
- *
- */
-
-
-
-
-
-/**
- * @ingroup SLP_PG
- * @defgroup pacakge_manager_PG PackageManagerStructure
- * @brief A programming guide for deelopers who want to make a frontend/backend pair for a package type.
- * @{
-
-<h1 class="pg">Introduction</h1>
-       <h2 class="pg">Terms of use</h2>
-       <ul>
-               <li><b>frontend</b> an installer frontend process</li>
-               <li><b>backend</b> an installer backend process</li>
-               <li><b>backendlib</b> a library of backend plugin</li>
-               <li><b>PMS</b> Package manager server</li>
-       </ul>
-
-       <h2 class="pg">Structure overview</h2>
-
- When a command to install/update/delete a package to package-manager system, a frontend process receives request, and pass it to the package manager server. Package manager server will queue all requests, and runs backend one by one.<br>
-For example, <br>
-  <center>SamsungApps --(install foo.deb)--> frontend --(install foo.deb)--> PMS --(Run dpkg backend to install foo.deb)--> backend</center><br>
-
-When 'install' command is given, the package file to be installed is already downloaded by user's application (SamsungApps, ...), and these frontend/PMS/backend are only responsible for installing it.<br>
-Requests between frontend and PMS, and signal broadcasting between backend and frontend/apps are implemented by dbus.<br>
-<h2></h2><br>
-
- To get the package information, backend plugin library is used. Each backend library provides the predefined functions, and package manager client library uses it.<br>
-  <center>SamsungApps ~~> package-manager client library ~~> backend end plugin library </center>
-  <center>(link and API call)                     (dynamic loading and symbol binding)  </center><br>
-
-Detailed informations for each process are explained below.
-
-       <h2 class="pg">Frontend</h2>
-
-  A frontend is a program which shows UI to users(if needed), requests install/update/delete/recover to PMS, and shows installing status(if needed). frontend/backend programs must be exist per one package type. Again, each package type must have one frontend/backend pair.<br>
-
-  A frontend process runs with <b>user provilege</b>, executed by package-manager client API, in include/package-manager.h;
-<ul>
-       <li>package_manager_install_application()</li>
-       <li>package_manager_uninstall_application()</li>
-</ul>
-
-  Frontend process does following things;
-<ul>
-       <li>Gets arguments from argv, with one of following options;
-               <ul>
-                       <li>-i <filepath> : Install package</li>
-                       <li>-u <filepath> : Update package</li>
-                       <li>-r : Recover package system</li>
-                       <li>-d <package_name> : Delete package</li>
-               </ul>
-       </li>
-       <li>Gets cookie from security server.</li>
-       <li>Sends request to PMS, with various arguments and cookie.</li>
-       <li>Waits backend's status signals.</li>
-       <li>Updates UI accroding to backend's status signal, if necessary.</li>
-       <li>Finishes process when 'end' signal from backend comes.</li>
-</ul>
-
-A frontend has UI, so it runs in event-loop (usually ecore_loop, sometimes g_main_loop). We provide an object 'comm_client', which is integrated with g_main_loop. So, you have to program event-loop based code. Luckily the ecore_loop in SLP is integrated with g_main_loop, so you don't need to worry about using comm_client API in ecore_loop.
-
-               <h3 class="pg">Rules</h3>
-A frontend must have following features;
-<ul>
-       <li>Must be able to parse -i, -u, -r, -d, -q options.</li>
-       <li>Must be able to parse -k <req_id> option. This string is passed to backend, as a request id.
-       <li>Must have UI(at least a OK/Cancel dialog), which can be ignored by -q option.</li>
-       <li>Must be able to use g_main_loop based functions.</li>
-</ul>
-
-
-
-       <h2 class="pg">Package manager server</h2>
-Package Manager Server(PMS) is a <b>root</b> privilege process, which queues all requests from lots of frontends, and runs backends accrding to each requests. <br>
-PMS has a queue internally, which stores each request and runs one by one. <br>
-When no PMS is running yet, first frontend's request will execute PMS.
-
-  PMS process does following things;
-<ul>
-       <li>Receives requests from a frontend via dbus.</li>
-       <li>If the request has a wrong cookie, discard it.</li>
-       <li>Puts the request into the queue.</li>
-       <li>Pops a request from the queue, and sends it to corresponding backend.</li>
-       <li>When the backend finishes, run next request in the queue.</li>
-</ul>
-
-PMS is already made and installed in your system.
-
-       <h2 class="pg">Backend</h2>
-
-for a certain package type, a backend is a <b>root</b> privilege process invoked by PMS, which is doing following things;
-<ul>
-       <li>Parses input values</li>
-       <li>Checks signing of the package file, and verifies its validity (if necessary)
-       <li>Does install/update/delete a pacakge, or recovers package system, or </li>
-       <li>activate/deactivate a package</li>
-       <li>Broadcasts current status</li>
-</ul>
-
-               <h3 class="pg">Rules</h3>
-A backend must have following features;
-<ul>
-       <li>Must parse args string from frontend.</li>
-       <li>Must install/update/delete a package.</li>
-       <li>Must be able to recover package system, when it is corrupted.</li>
-       <li>Must broadcast current install/status</li>
-</ul>
-
-       <h2 class="pg">Backend library</h2>
-
-for a certain package type, a backend library  is just a <b>library</b> client process uses this library.
-Backend library does following things;
-<ul>
-       <li>Checks whether package is installed or not</li>
-       <li>Gets the list of installed package</li>
-       <li>Gets the information of installed package</li>
-       <li>Gets the information from package file</li>
-</ul>
-
-               <h3 class="pg">Rules</h3>
-A backend must have following features;
-<ul>
-       <li>Must check whether package is installed or not.</li>
-       <li>Must get the list of installed package.</li>
-       <li>Must get the information of installed package.</li>
-       <li>Must gets the information from package file</li>
-</ul>
-
-
-<h1 class="pg">Programming guide</h1>
-
-       <h2 class="pg">Requied dev package</h2>
-libpkgmgr-installer-dev package is provided to develop installer frontend/backend. <br>
-@code
-$ apt-get install libpkgmgr-installer-dev
-@endcode
-
-libpkgmgr-types-dev package is provided to develop installer backendlib. <br>
-@code
-$ apt-get install libpkgmgr-types-dev
-@endcode
-
-Three package-config files are installed; pkgmgr-installer-client.pc and pkgmgr-installer-status-broadcast-server.pc and pkgmgr-types.pc 
-The first one is for frontend, the second one is for backend, and last one if for backendlib <br>
-
-
-       <h2 class="pg">Installer frontend's programming guide</h2>
-
-comm_client module is provided for frontend programming, which can do comminucations with PMS and backend process.<br>
-
-Example code is in packages/test/frontend.c. <br>
-
-<B>NOTE:</b> This example code uses g_main_loop. If you use ecore_loop, you don't need to run g_main_loop_*() functions. <br>
-
-Every installer frontend's command arguments are like this; <br>
-@code
-$ <frontend> <cmd_opt> [<opt_val>] -k <req_id>
-@endcode
-<ul>
-       <li>frontend : An installer frontend executable file.  </li>
-       <li>cmd_opt : One of -i(install package), -u(update package), -d(delete package), -r(recover package system), -a(activate package)</li>
-       <li>opt_val : Means package file path (with -i/-u), package name (with -d, -a). When cmd_opt is -r, no opt_val is required.  </li>
-       <li>req_id : A request id, which is passed from frontend (with -k option) to backend. </li>
-</ul>
-
-
-
-               <h3 class="pg">Get a cookie from security-server</h3>
-To authenticate this frontend process, firstly you have to get a cookie from security server.<br>
-security-server.h from security-server package has cookie APIs. For more information, see security-server.h file.<br>
-@code
-
-#include <security-server.h>
-
-/* ...... */
-
-char *cookie;
-int cookie_size;
-int cookie_ret;
-
-cookie_size = security_server_get_cookie_size();
-/* If security server is down or some other error occured, raise failure */
-if(0 >= cookie_size) {
-       /* TODO: raise error */
-} else {
-       cookie = calloc(cookie_size, sizeof(char));
-       cookie_ret = security_server_request_cookie(cookie, cookie_size);
-       /* TODO: Check cookie_ret... (See security-server.h to check return code) */
-}
-
-@endcode
-This cookie string will be passed to PMS later.
-
-               <h3 class="pg">Parse argv options</h3>
-All frontends must support at least 5 options; -i, -u, -d, -r, -k, and -q. Parse each options, and do requested job. <br>
-Only one of following options must be taken. <br>
-               <ul>
-                       <li>-i <filepath> : Install package</li>
-                       <li>-u <filepath> : Update package</li>
-                       <li>-r : Recover package system</li>
-                       <li>-d <package_name> : Delete package</li>
-               </ul>
-Following options must be able to taken. <br>
-               <ul>
-                       <li>-k <request_id> : An <b>unique string</b> to identify this request. This key will be included in status broadcast signals from backend.</li>
-                       <li>-q : Quiet option. Do now show UI.</li>
-               </ul>
-
-
-The sample code uses getopt() function in unistd.h to parse argv options.<br>
-
-@code
-#include <unistd.h>
-#define BUFSIZE 256
-
-/* ...... */
-
-const char *opts_str = "i:u:d:rqk:";   
-int s = 0;
-int quite = 0;
-int mode = 0;
-char buf[BUFSIZE];
-char req_id[BUFSIZE];
-
-
-while(-1 != (s = getopt(argc, argv, opts_str))) {
-       switch(s) {
-               case 'i':
-                       if(mode) break;
-                       mode = MODE_INSTALL;
-                       strncpy(buf, optarg, BUFSIZE);
-                       break;
-               case 'u':
-                       if(mode) break;
-                       mode = MODE_UPDATE;
-                       strncpy(buf, optarg, BUFSIZE);
-                       break;
-               case 'd':
-                       if(mode) break;
-                       mode = MODE_DELETE;
-                       strncpy(buf, optarg, BUFSIZE);
-                       break;
-               case 'r':
-                       if(mode) break;
-                       mode = MODE_RECOVER;
-                       break;
-               case 'q':
-                       quite = 1;
-                       break;
-               case 'k':
-                       strncpy(req_id, optarg, BUFSIZE);
-
-               default:
-                       usage();        /* Show usage, and exit */
-       }
-}
-
-@endcode
-
-               <h3 class="pg">Do send a request to install,update,delete or recover</h3>
-After parsing argv options, now your frontend knows what command will be request to your backend. For this work, we provide APIs.
-
-               <h3 class="pg"></h3>
-               <h3 class="pg"></h3>
-               <h3 class="pg"></h3>
-
-       <h2 class="pg">Installer backend's programming guide</h2>
-
-Example code is in packages/test/backend.c. <br>
-
-       <h3 class="pg">Parse command args</h3>
-Every installer backend's command arguments are like this; <br>
-@code
-$ <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>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>
-
-Those options must be parsed and processed properly. <br>
-
-       <h3 class="pg">Broadcast installing status</h3>
-Backend must broadcast its installing status. You can broadcast your status by using following API.
-@code
-#include "comm_status_broadcast_server.h"
-
-/* ... */
-
-DBusConnection *conn;
-conn = comm_status_broadcast_server_connect(COMM_STATUS_BROADCAST_ALL);
-
-comm_status_broadcast_server_send_signal(COMM_STATUS_BROADCAST_ALL, conn, req_id, pkg_type, pkgid, "start", "0");
-/* ... */
-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(COMM_STATUS_BROADCAST_ALL, conn, req_id, pkg_type, pkgid, "end", "0");
-
-/* ... */
-@endcode
-
-Last two values are key/value pair. Following values are mandatory;
-<table>
-       <tr>
-               <th>key</th>
-               <th>value</th>
-               <th>Comment</th>
-       </tr>
-       <tr>
-               <td>start</td>
-               <td>download|install|uninstall|update|recover</td>
-               <td>Start backend process. <br>NOTE: 'download' is used only by downloader.</td>
-       </tr>
-       <tr>
-               <td>install_percent</td>
-               <td>[number between 0~100]</td>
-               <td>Install progress</td>
-       </tr>
-       <tr>
-               <td>error</td>
-               <td>[string]</td>
-               <td>Error message</td>
-       </tr>
-       <tr>
-               <td>end</td>
-               <td>ok|fail</td>
-               <td>End backend (Process termination)</td>
-       </tr>
-</table>
-
-Following values are required also. If you need any of them in downloader or installer backend, send it. <br>
-<table>
-       <tr>
-               <th>key</th>
-               <th>value</th>
-               <th>Comment</th>
-       </tr>
-       <tr>
-               <td>icon_path</td>
-               <td>path of icon file</td>
-               <td>Before icon and *.desktop files are installed, menu-screen must have temporary icon file. This option indicates temporary icon file's path.<br>If no icon_path is provided, menu-screen will use general temporary icon.</td>
-       </tr>
-       <tr>
-               <td>download_percent</td>
-               <td>[number between 0~100]</td>
-               <td>Download progress<br>NOTE: This key is used by downloader only. Installer backends don't use this.</td>
-</table>
-
-You can send any other key/val pair by this API, to send any information to your frontend or donwloader app. Any keys except above will be ignored by PMS.<br>
-
-
-
-       <h2 class="pg">Installer backendlib's programming guide</h2>
-Example code is in packages/installers/sample/sample_backendlib.c. <br>
-
-       <h3 class="pg">Plugin implementation</h3>
-Backendlib should implemented according to following Rule.
-<ul>
-       <li>Exported API : pkg_plugin_onload() is a exported symbol. This symbol is found when after loading the library. </li>
-       <li>function pointer : _pkg_plugin_set defines the structor of function pointer. Each functions are implemented. </li>
-       <li>function mapping : defined each functions are connected to function pointer when pkg_plugin_onload() is called. </li>
-</ul>
-
-@code
-#include "package-manager-plugin.h"
-
-
-static void pkg_native_plugin_unload (void)
-{
-       //ToDo
-}
-
-static int pkg_plugin_app_is_installed(const char *pkgid)
-{
-       //ToDo
-       
-       return 0;
-}
-
-static int pkg_plugin_get_installed_apps_list(package_manager_pkg_info_t **list, int *count)
-{
-       //ToDo
-       
-       return 0;
-}
-
-static int pkg_plugin_get_app_detail_info(const char *pkgid, package_manager_pkg_detail_info_t* pkg_detail_info)
-{
-       //ToDo
-       
-       return 0;
-}
-
-static int pkg_plugin_get_app_detail_info_from_package(const char *pkg_path, package_manager_pkg_detail_info_t* pkg_detail_info)
-{
-       //ToDo
-       
-       return 0;
-}
-
-
-int pkg_plugin_onload (pkg_plugin_set * set)
-{
-       if(set == NULL)
-       {
-               return -1;
-       }
-       
-       memset(set, 0x00, sizeof(pkg_plugin_set));
-
-       set->plugin_unload = pkg_native_plugin_unload;
-       set->pkg_is_installed = pkg_plugin_app_is_installed;
-       set->get_installed_pkg_list = pkg_plugin_get_installed_apps_list;
-       set->get_pkg_detail_info = pkg_plugin_get_app_detail_info;
-       set->get_pkg_detail_info_from_package = pkg_plugin_get_app_detail_info_from_package;
-
-       return 0;
-}
-@endcode
-
-
-
-       <h2 class="pg">Install frontend/backend</h2>
-Your frontend/backend binary executables have to be installed. Usually they are installed into @PREFIX@/bin/. <br>
-
-One thing you must do is that your backend binary's owner must be <b>root</b>, permission must be <b>700</b>.
-In case of backendlib, it's permission is <b>644</b>.
-
-
-       <h2 class="pg">Create symlinks for your frontend/backend binaries and backendlib library</h2>
-After installing your frontend/backend, You have to create symlinks pointing your frontend/backend binaries. <br>
-Those symlinks must be installed as following paths;
-<ul>
-       <li>frontend : @PREFIX@/etc/package-manager/frontend/<your package file's extension></li>
-       <li>backend : @PREFIX@/etc/package-manager/backend/<your package file's extension></li>
-       <li>backendlib : @PREFIX@/etc/package-manager/backendlib/lib[<your package file's extension>].so</li>
-</ul>
-For example, the debian package (*.deb) must have symlink @PREFIX@/etc/package-manager/frontend/deb, which is pointing actual frontend binary.<br>
-Client API and PMS will find actual frontend/backend binaries from those paths. <br>
-
- * @}
- */
diff --git a/comm/build.sh b/comm/build.sh
deleted file mode 100755 (executable)
index c425ead..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-
-#export CFLAGS=""
-#export LDFLAGS=""
-
-cd `dirname $0`
-
-PREFIX=/usr
-
-rm -rf cmake_tmp
-mkdir -p cmake_tmp
-cd cmake_tmp
-
-CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" cmake .. -DCMAKE_INSTALL_PREFIX=${PREFIX} &&
-make &&
-
-# test
-{
-       export LD_LIBRARY_PATH=`pwd`
-       cd test
-#      ./test_comm_client &
-#      ./test_comm_status_broadcast_server
-#      ./test_comm_socket &&
-       ./test_pkgmgr_installer 
-} 
-if [ "$?" == "0" ]; then
-       echo "Test done."
-else
-       echo "Test failed!"
-fi
-
diff --git a/comm/comm_client.c b/comm/comm_client.c
deleted file mode 100755 (executable)
index 9511249..0000000
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * 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 "comm_config.h"
-#include "comm_client.h"
-#include "comm_pkg_mgr_client_dbus_bindings.h"
-#include "comm_status_broadcast_client_dbus_bindings.h"
-#include "comm_status_broadcast_signal_marshaller.h"
-#include <stdlib.h>
-#include <string.h>
-
-struct comm_client {
-       /* Resources to be freed */
-       DBusGConnection *conn;
-       GError *err;
-       DBusGProxy *request_proxy;
-       DBusGProxy *signal_proxy;
-       char *pkgid;
-
-       status_cb signal_cb;
-       void *signal_cb_data;
-};
-
-comm_client *comm_client_new(void)
-{
-       comm_client *cc = NULL;
-
-       cc = calloc(1, sizeof(comm_client));
-       if (NULL == cc)
-               return NULL;
-
-       cc->conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &(cc->err));
-       if (NULL == cc->conn) {
-               g_printerr("Failed to open connection to dbus: %s\n",
-                          cc->err->message);
-               g_error_free(cc->err);
-               cc->err = NULL;
-               comm_client_free(cc);
-               return NULL;
-       }
-
-       cc->request_proxy = dbus_g_proxy_new_for_name(cc->conn,
-                                               COMM_PKG_MGR_DBUS_SERVICE,
-                               /* name : written in service file */
-                                               COMM_PKG_MGR_DBUS_PATH,
-                               /* path : written as a node in xml */
-                                               COMM_PKG_MGR_DBUS_INTERFACE
-                       /* interface : written as an interface in xml */
-           );
-
-       return cc;
-}
-
-int comm_client_free(comm_client *cc)
-{
-       if (NULL == cc)
-               return -1;
-
-       if (cc->err)
-               g_error_free(cc->err);
-       if (cc->conn)
-               dbus_g_connection_unref(cc->conn);
-       if (cc->request_proxy)
-               g_object_unref(cc->request_proxy);
-       if (cc->signal_proxy)
-               g_object_unref(cc->signal_proxy);
-       if (cc->pkgid)
-               free(cc->pkgid);
-
-       free(cc);
-
-       return 0;
-}
-
-static void
-status_signal_handler(DBusGProxy *proxy,
-                     const char *req_id,
-                     const char *pkg_type,
-                     const char *pkgid,
-                     const char *key, const char *val, gpointer data)
-{
-       comm_client *cc = (comm_client *) data;
-
-       SECURE_LOGD("Got signal: %s/%s/%s/%s/%s", req_id, pkg_type,
-                                pkgid, key, val);
-       if (cc->signal_cb) {
-               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,
-                                     pkgid, key, val);
-               } else {
-                       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,
-                                     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 *pkgid,
-                   const char *args, const char *cookie)
-{
-       gboolean r;
-       gint ret = COMM_RET_ERROR;
-
-       SECURE_LOGD("got request:%s/%d/%s/%s/%s/%s\n", req_id, req_type, pkg_type,
-           pkgid, args, cookie);
-
-       if (!pkgid)
-               pkgid = "";     /* NULL check */
-
-       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;
-       } else {
-               g_printerr("Failed to send request via dbus: %s\n",
-                          cc->err->message);
-               if (cc->err) {
-                       g_error_free(cc->err);
-                       cc->err = NULL;
-               }
-               return ret;
-       }
-       dbg("Request ok");
-
-       if (cc->pkgid) {
-               dbg("freeing pkgid");
-               free(cc->pkgid);
-               dbg("freed pkgid");
-       }
-       cc->pkgid = strdup(pkgid);
-
-       dbg("ret:%d", ret);
-
-       return ret;
-}
-
-int
-comm_client_set_status_callback(comm_client *cc, status_cb cb, void *cb_data)
-{
-       /* set callback */
-       if (!cc->signal_proxy) {
-               dbg("signal_proxy is NULL. Try to create a proxy for signal.");
-               cc->signal_proxy = dbus_g_proxy_new_for_name(cc->conn,
-                                    COMM_STATUS_BROADCAST_DBUS_SERVICE_PREFIX,
-                                    COMM_STATUS_BROADCAST_DBUS_PATH,
-                                    COMM_STATUS_BROADCAST_DBUS_INTERFACE);
-               if (NULL == cc->signal_proxy) {
-                       g_printerr("Failed to create proxy for signal\n", NULL);
-                       return COMM_RET_ERROR;
-               } else {
-               }
-       } else {
-               /* Proxy is existing. Do nothing. */
-       }
-
-       cc->signal_cb = cb;
-       cc->signal_cb_data = cb_data;
-
-       dbg("Register signal-type marshaller.");
-       dbus_g_object_register_marshaller(
-       g_cclosure_user_marshal_VOID__STRING_STRING_STRING_STRING_STRING,
-               /* marshaller */
-       G_TYPE_NONE, /* return type */
-       G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
-       G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);  /* termination flag */
-
-       dbg("Add signal to proxy.");
-       dbus_g_proxy_add_signal(cc->signal_proxy,
-                               COMM_STATUS_BROADCAST_SIGNAL_STATUS,
-                               G_TYPE_STRING,
-                               G_TYPE_STRING,
-                               G_TYPE_STRING,
-                               G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
-
-       dbg("Connect signal to proxy.");
-
-       dbus_g_proxy_connect_signal(cc->signal_proxy,
-                                   COMM_STATUS_BROADCAST_SIGNAL_STATUS,
-                                   G_CALLBACK(status_signal_handler),
-                                   cc, NULL);
-
-       return 0;
-}
-
index 13b62e4..89fdc73 100755 (executable)
@@ -38,9 +38,10 @@ enum {
 typedef struct comm_client comm_client;
 typedef void (*status_cb) (void *cb_data, const char *req_id,
                           const char *pkg_type, const char *pkgid,
-                          const char *key, const char *val);
+                          const char *key, const char *val, const char *zone);
 
 API comm_client *comm_client_new(void);
+API comm_client *comm_client_new_private(void);
 API int comm_client_free(comm_client *cc);
 
 API int comm_client_request(comm_client *cc, const char *req_id,
@@ -49,4 +50,12 @@ API int comm_client_request(comm_client *cc, const char *req_id,
                            const char *cookie, int is_block);
 
 API int comm_client_set_status_callback(int comm_status_type, comm_client *cc, status_cb cb, void *cb_data);
+
+#ifdef _APPFW_FEATURE_EXPANSION_PKG_INSTALL
+API int comm_client_request_with_tep(comm_client *cc, const char *req_id,
+                           const int req_type, const char *pkg_type,
+                           const char *pkgid, const char *tep_path,
+                           const char *args, const char *cookie, int is_block);
+#endif
+
 #endif                         /* __COMM_CLIENT_H__ */
index ba66b53..599a4c6 100755 (executable)
 #include <stdbool.h>
 #include <stdio.h>
 #include <string.h>
+#include <fcntl.h>
 #include "comm_config.h"
 #include "comm_client.h"
-#include "comm_pkg_mgr_client_gdbus_generated.h"
+#include "comm_internal.h"
+#include "comm_pkg_mgr_gdbus_generated.h"
+
+#define MAX_ZONE_NAME_LEN 128
+#define ZONE_HOST "host"
+
+static bool unmatched_zone_filter(const char *zone, const char *signal)
+{
+       int len_zone = 0;
+       int len_sig = strlen(signal);
+       bool filtered = true;
+       char temp[MAX_ZONE_NAME_LEN] = {0, };
+
+       if (!zone)
+               filtered = false;
+
+       if (zone && strlen(zone)) {
+               len_zone = strlen(zone);
+               if (strcmp(zone, ZONE_HOST) == 0) {
+                       filtered = false;
+               } else {
+                       if (len_sig >= len_zone) {
+                               snprintf(temp, len_zone + 1, "%s", &signal[len_sig - len_zone]);
+
+                               if (strcmp(temp, zone) == 0) {
+                                       filtered = false;
+                               }
+                       }
+               }
+       }
+
+       if (filtered && zone) {
+               dbg("filtered : (%s, %s, %d)\n", signal, zone, len_sig - len_zone);
+       }
+
+       return filtered;
+}
+
+static int get_sender_zone_name(const char *zone, const char *signal, char *sender_zone)
+{
+       int len_sig = 0;
+       int len_sig_tmp = 0;
+       int diff = 0;
+       int ret = -1;
+       char temp[MAX_ZONE_NAME_LEN] = {0, };
+
+       if (!zone || !signal)
+               return -1;
+
+       len_sig = strlen(signal);
+
+       if (strcmp(zone, ZONE_HOST)) {
+               /* skip, unless host zone */
+               return -1;
+       }
+
+       if (signal && len_sig) {
+               if (!strncmp(signal, COMM_STATUS_BROADCAST_SIGNAL_STATUS,
+                       LEN_COMM_STATUS_BROADCAST_SIGNAL_STATUS)) {
+                       len_sig_tmp = LEN_COMM_STATUS_BROADCAST_SIGNAL_STATUS;
+               } else if (!strncmp(signal, COMM_STATUS_BROADCAST_EVENT_INSTALL,
+                       LEN_COMM_STATUS_BROADCAST_EVENT_INSTALL)) {
+                       len_sig_tmp = LEN_COMM_STATUS_BROADCAST_EVENT_INSTALL;
+               } else if (!strncmp(signal, COMM_STATUS_BROADCAST_EVENT_UNINSTALL,
+                       LEN_COMM_STATUS_BROADCAST_EVENT_UNINSTALL)) {
+                       len_sig_tmp = LEN_COMM_STATUS_BROADCAST_EVENT_UNINSTALL;
+               } else if (!strncmp(signal, COMM_STATUS_BROADCAST_EVENT_UPGRADE,
+                       LEN_COMM_STATUS_BROADCAST_EVENT_UPGRADE)) {
+                       len_sig_tmp = LEN_COMM_STATUS_BROADCAST_EVENT_UPGRADE;
+               } else if (!strncmp(signal, COMM_STATUS_BROADCAST_EVENT_MOVE,
+                       LEN_COMM_STATUS_BROADCAST_EVENT_MOVE)) {
+                       len_sig_tmp = LEN_COMM_STATUS_BROADCAST_EVENT_MOVE;
+               } else if (!strncmp(signal, COMM_STATUS_BROADCAST_EVENT_GET_SIZE,
+                       LEN_COMM_STATUS_BROADCAST_EVENT_GET_SIZE)) {
+                       len_sig_tmp = LEN_COMM_STATUS_BROADCAST_EVENT_GET_SIZE;
+               } else if (!strncmp(signal, COMM_STATUS_BROADCAST_EVENT_INSTALL_PROGRESS,
+                       LEN_COMM_STATUS_BROADCAST_EVENT_INSTALL_PROGRESS)) {
+                       len_sig_tmp = LEN_COMM_STATUS_BROADCAST_EVENT_INSTALL_PROGRESS;
+               }
+
+               if (len_sig_tmp) {
+                       if (len_sig > len_sig_tmp) {
+                               len_sig_tmp += 1; /* for '_' */
+                               diff = len_sig - len_sig_tmp;
+                               snprintf(temp, diff + 1, "%s", &signal[len_sig_tmp]);
+
+                               if (strlen(temp)) {
+                                       memcpy(sender_zone, temp, strlen(temp));
+                                       dbg("temp(%s), sender_zone(%s)", temp, sender_zone);
+                                       ret = 0;
+                               }
+                       }
+               }
+       }
+
+       return ret;
+}
 
 /*******************
  * ADT description
@@ -85,6 +182,45 @@ static int __retry_request(comm_client *cc,
        return TRUE;
 }
 
+#ifdef _APPFW_FEATURE_EXPANSION_PKG_INSTALL
+static bool __retry_request_with_tep(comm_client *cc,
+       const gchar *req_id,
+       gint req_type,
+       const gchar *pkg_type,
+       const gchar *pkgid,
+       const gchar *tep_path,
+       const gchar *args,
+       const gchar *cookie,
+       gint *ret)
+{
+       OrgTizenPkgmgr *proxy;
+       GError *error = NULL;
+       int rc = 0;
+
+       ERR("tep_install request send failed, retrying...");
+
+       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;
+       }
+
+       //jungh function name should be checked
+       org_tizen_pkgmgr_call_tep_request_sync(proxy,
+                       req_id, req_type, pkg_type, pkgid, tep_path, args, cookie, ret, NULL, &error);
+#if 0
+       if (!rc) {
+               ERR("Failed to send request[rc=%d, err=%s]\n", rc, error->message);
+               return FALSE;
+       }
+#endif
+       return TRUE;
+}
+#endif
+
 static char *__get_interface(int status_type)
 {
        char *ifc = NULL;
@@ -118,10 +254,6 @@ static char *__get_interface(int status_type)
                        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;
        }
@@ -140,28 +272,66 @@ void _on_signal_handle_filter(GDBusConnection *conn,
                GVariant *parameters,
                gpointer user_data)
 {
+       char temp_name[MAX_ZONE_NAME_LEN] = {0, };
+       char *zone = NULL;
+       char *sender_zone = NULL;
+       int pid = getpid();
+
+       if(!signal_name){
+               dbg("signal_name is empty");
+               goto catch;
+       }
+
+       if (get_zone_name(pid, temp_name, MAX_ZONE_NAME_LEN) == -1) {
+               gethostname(temp_name, sizeof(temp_name));
+       }
+       if (strlen(temp_name)) {
+               zone = strdup(temp_name);
+       }
+
+       if (unmatched_zone_filter(zone, signal_name)) {
+               dbg("zone name did not match. Drop the message");
+               goto catch;
+       }
+
        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;
+               goto catch;
        }
-       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)) {
+
+       if (signal_name && strncmp(signal_name, COMM_STATUS_BROADCAST_SIGNAL_STATUS,
+                                                LEN_COMM_STATUS_BROADCAST_SIGNAL_STATUS) &&
+               strncmp(signal_name, COMM_STATUS_BROADCAST_EVENT_INSTALL,
+                                                LEN_COMM_STATUS_BROADCAST_EVENT_INSTALL) &&
+               strncmp(signal_name, COMM_STATUS_BROADCAST_EVENT_UNINSTALL,
+                                                LEN_COMM_STATUS_BROADCAST_EVENT_UNINSTALL) &&
+               strncmp(signal_name, COMM_STATUS_BROADCAST_EVENT_UPGRADE,
+                                                LEN_COMM_STATUS_BROADCAST_EVENT_UPGRADE) &&
+               strncmp(signal_name, COMM_STATUS_BROADCAST_EVENT_MOVE,
+                                                LEN_COMM_STATUS_BROADCAST_EVENT_MOVE) &&
+               strncmp(signal_name, COMM_STATUS_BROADCAST_EVENT_GET_SIZE,
+                                                LEN_COMM_STATUS_BROADCAST_EVENT_GET_SIZE) &&
+               strncmp(signal_name, COMM_STATUS_BROADCAST_EVENT_INSTALL_PROGRESS,
+                                                LEN_COMM_STATUS_BROADCAST_EVENT_INSTALL_PROGRESS)) {
                dbg("Signal name did not match. Drop the message");
-               return;
+
+               goto catch;
        }
+
+       memset(temp_name, 0, MAX_ZONE_NAME_LEN);
+
+       if (get_sender_zone_name(zone, signal_name, temp_name) == 0) {
+               if (strlen(temp_name)) {
+                       sender_zone = strdup(temp_name);
+               }
+       }
+
        /* Values to be received by signal */
        char *req_id = NULL;
        char *pkg_type = NULL;
@@ -174,21 +344,29 @@ void _on_signal_handle_filter(GDBusConnection *conn,
        if (user_data)
                sig_cb_data = (struct signal_callback_data *)user_data;
        else
-               return;
+               goto catch;
+
+       g_variant_get(parameters, "(&s&s&s&s&s)", &req_id, &pkg_type, &pkgid, &key, &val);
 
-       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);
+       SECURE_LOGD("signal_name=[%s], req_id=[%s], pkg_type=[%s], pkgid=[%s], key=[%s], value=[%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");
+               // invoke callback
+               sig_cb_data->cb(sig_cb_data->cb_data, req_id, pkg_type, pkgid, key, val, sender_zone);
+       } else {
+               ERR("signal callback is NOT invoked!!");
        }
-       dbg("Handled signal. Exit function");
+
+catch:
+       if (zone)
+               free(zone);
+
+       if (sender_zone)
+               free(sender_zone);
+
        return;
 }
 
@@ -246,6 +424,52 @@ comm_client *comm_client_new(void)
 }
 
 /**
+ * Create a new comm_client object (for private connection)
+ */
+comm_client *comm_client_new_private(void)
+{
+       GError *error = NULL;
+       comm_client *cc = NULL;
+       gchar *addr = NULL;
+
+       /* Allocate memory for ADT:comm_client */
+       g_type_init();
+       cc = calloc(1, sizeof(comm_client));
+       if (NULL == cc) {
+               ERR("No memory");
+               return NULL;
+       }
+
+       /* Connect to gdbus. Gets private BUS */
+       addr = g_dbus_address_get_for_bus_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+       if (error) {
+               ERR("gdbus connection error (%s)", error->message);
+
+               g_error_free(error);
+               goto ERROR_CLEANUP;
+       }
+
+       cc->conn = g_dbus_connection_new_for_address_sync(addr, G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT | G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION, NULL, NULL, &error);
+       if (NULL == cc->conn) {
+               ERR("gdbus connection is not set, even gdbus error isn't raised");
+               g_error_free(error);
+               free(addr);
+
+               goto ERROR_CLEANUP;
+       }
+
+       free(addr);
+
+       return cc;
+
+ ERROR_CLEANUP:
+       if (cc)
+               free(cc);
+
+       return NULL;
+}
+
+/**
  * Free comm_client object
  */
 int comm_client_free(comm_client *cc)
@@ -346,6 +570,81 @@ comm_client_request(
        return ret;
 }
 
+#ifdef _APPFW_FEATURE_EXPANSION_PKG_INSTALL
+/**
+ * Request a message
+ */
+int
+comm_client_request_with_tep(
+               comm_client *cc,
+               const char *req_id,
+               const int req_type,
+               const char *pkg_type,
+               const char *pkgid,
+               const char *tep_path,
+               const char *args,
+               const char *cookie,
+               int is_block)
+{
+       GError *error = NULL;
+       int ret = 0;
+       int rc = 0;
+       int retry_cnt = 0;
+
+       ERR("sending the tep_install request to pkgmgr-server");
+
+       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 = "";
+       if (tep_path == NULL)
+               tep_path = "";
+
+       rc = org_tizen_pkgmgr_call_tep_request_sync(proxy,
+                       req_id, req_type, pkg_type, pkgid, tep_path, 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_with_tep(cc, req_id, req_type, pkg_type, pkgid, tep_path, args, cookie, &ret);
+               if(rc == TRUE) {
+                       ERR("__retry_request is success[retry_cnt=%d]\n", retry_cnt);
+                       break;
+               }
+       }
+       return ret;
+}
+#endif
+
+
 /**
  * Set a callback for status signal
  */
index 5626282..342ea67 100755 (executable)
 #define COMM_STATUS_BROADCAST_DBUS_INTERFACE \
        "org.tizen.pkgmgr_status"
 #define COMM_STATUS_BROADCAST_SIGNAL_STATUS "status"
+#define LEN_COMM_STATUS_BROADCAST_SIGNAL_STATUS 6
 
 #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 LEN_COMM_STATUS_BROADCAST_EVENT_INSTALL 7
 
 #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 LEN_COMM_STATUS_BROADCAST_EVENT_UNINSTALL 9
 
 #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 LEN_COMM_STATUS_BROADCAST_EVENT_MOVE 4
 
 #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 LEN_COMM_STATUS_BROADCAST_EVENT_INSTALL_PROGRESS 16
 
 #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 LEN_COMM_STATUS_BROADCAST_EVENT_UPGRADE 7
 
 #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"
+#define LEN_COMM_STATUS_BROADCAST_EVENT_GET_SIZE 8
 
 /********
  * enums
 
 /* req_type */
 enum {
-       /* to installer */
-       COMM_REQ_TO_INSTALLER = 1,
+       /* to install */
+       COMM_REQ_TO_INSTALL = 1,
+
+       /* to uninstall */
+       COMM_REQ_TO_UNINSTALL,
 
        /* activate pkg */
        COMM_REQ_ACTIVATE_PKG,
@@ -146,6 +151,12 @@ enum {
        /* deactivate app */
        COMM_REQ_DEACTIVATE_APP,
 
+       /* enable app background operation */
+       COMM_REQ_ENABLE_BG_OPERATION,
+
+       /* disable app background operation */
+       COMM_REQ_DISABLE_BG_OPERATION,
+
        /* activate app with label */
        COMM_REQ_ACTIVATE_APP_WITH_LABEL,
 
@@ -173,9 +184,6 @@ enum {
        /* make external directories for app */
        COMM_REQ_MAKE_EXTERNAL_DIR,
 
-       /* get junk file information */
-       COMM_REQ_GET_JUNK_INFO,
-
        COMM_REQ_MAX_SENTINEL
 };
 
@@ -198,7 +206,6 @@ enum {
        COMM_STATUS_BROADCAST_INSTALL_PROGRESS,
        COMM_STATUS_BROADCAST_UPGRADE,
        COMM_STATUS_BROADCAST_GET_SIZE,
-       COMM_STATUS_BROADCAST_GET_JUNK_INFO,
        COMM_STATUS_BROADCAST_MAX
 };
 
old mode 100755 (executable)
new mode 100644 (file)
similarity index 52%
rename from comm/test/test_comm_status_broadcast_server.c
rename to comm/comm_internal.c
index 4d3c6eb..955104e
  *
  */
 
-#include "comm_status_broadcast_server.h"
-#include <glib.h>
-#include <unistd.h>
-#include <string.h>
+#include "comm_config.h"
 #include <stdio.h>
-static int _main_dbus(int argc, char **argv);
-static int _main_dbus(int argc, char **argv)
+#include <vasum.h>
+
+#define ZONE_HOST "host"
+
+int get_zone_name(int pid, char *zone_name, int len)
 {
-       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(COMM_STATUS_BROADCAST_ALL, conn, "test_id",
-                                                        "test", "test_pkgid",
-                                                        "test_key",
-                                                        "test_val");
-               sleep(1);
-               printf(">>> sent signal: %d\n", i);
+       vsm_zone_h zone;
+       vsm_context_h ctx = vsm_create_context();
+       const char *zone_name_tmp = NULL;
+       int ret = 0;
+       if (ctx == NULL) {
+                       ERR("vsm_create_context failed");
+                       return -1;
        }
+       zone = vsm_lookup_zone_by_pid(ctx, pid);
 
-       return 0;
-}
+       if (zone != NULL && !vsm_is_host_zone(zone)) {
+               zone_name_tmp = vsm_get_zone_name(zone);
+               if (zone_name_tmp == NULL) {
+                       ERR("failed to get zone");
+                       ret = -1;
+                       goto err;
+               }
+       } else if (vsm_is_host_zone(zone)) {
+               zone_name_tmp = ZONE_HOST;
+       } else {
+               ERR("could not get zone name");
+               ret = -1;
+               goto err;
+       }
 
-int main(int argc, char **argv)
-{
-       return _main_dbus(argc, argv);
+       snprintf(zone_name, len, "%s", zone_name_tmp);
+err:
+       if (vsm_cleanup_context(ctx) != 0)
+               ERR("vsm cleanup failed");
+       return ret;
 
 }
-
old mode 100755 (executable)
new mode 100644 (file)
similarity index 81%
rename from comm/comm_socket_client.h
rename to comm/comm_internal.h
index f996672..0b0c21b
  *
  */
 
+#ifndef __COMM_INTERNAL_H__
+#define __COMM_INTERNAL_H__
 
+int get_zone_name(int pid, char *zone_name, int len);
 
-
-
-typedef struct comm_socket_client comm_socket_client;
-
-comm_socket_client *_comm_socket_client_new(const char *server_sock_path);
-int _comm_socket_client_free(comm_socket_client *csc);
+#endif                         /* __COMM_INTERNAL_H__ */
old mode 100644 (file)
new mode 100755 (executable)
index 96dfd0e..89f1de6
@@ -4,6 +4,7 @@
        <interface name="org.tizen.pkgmgr">
                <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="pkgmgr" />
                <method name="Request">
+                       <annotation name="org.freedesktop.DBus.GLib.Async" value="yes" />
                        <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="i" name="ret" direction="out" />
                </method>
                <method name="CreateExternalDirectory">
+                       <annotation name="org.freedesktop.DBus.GLib.Async" value="yes" />
+                       <arg type="i" name="ret" direction="out" />
+               </method>
+               <method name="DrmGenerateLicenseRequest">
+                       <arg type="s" name="resp_data" direction="in" />
+                       <arg type="s" name="cookie" direction="in" />
+                       <arg type="s" name="req_data" direction="out" />
+                       <arg type="s" name="license_url" direction="out" />
+                       <arg type="i" name="ret" direction="out" />
+               </method>
+               <method name="DrmRegisterLicense">
+                       <arg type="s" name="resp_data" direction="in" />
+                       <arg type="s" name="cookie" direction="in" />
+                       <arg type="i" name="ret" direction="out" />
+               </method>
+               <method name="DrmDecryptPackage">
+                       <arg type="s" name="drm_file_path" direction="in" />
+                       <arg type="s" name="decrypted_file_path" direction="in" />
+                       <arg type="s" name="cookie" direction="in" />
                        <arg type="i" name="ret" direction="out" />
                </method>
        </interface>
diff --git a/comm/comm_pkg_mgr_ext.xml b/comm/comm_pkg_mgr_ext.xml
new file mode 100755 (executable)
index 0000000..9e4a6fd
--- /dev/null
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<node name="/org/tizen/pkgmgr">
+    <interface name="org.tizen.pkgmgr">
+        <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="pkgmgr" />
+        <method name="Request">
+            <annotation name="org.freedesktop.DBus.GLib.Async" value="yes" />
+            <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="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="tepRequest">
+           <annotation name="org.freedesktop.DBus.GLib.Async" value="yes" />
+            <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="pkgid" direction="in" />
+            <arg type="s" name="tep_path" 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">
+                               <annotation name="org.freedesktop.DBus.GLib.Async" value="yes" />
+                               <arg type="i" name="ret" direction="out" />
+                       </method>
+        <method name="DrmGenerateLicenseRequest">
+            <arg type="s" name="resp_data" direction="in" />
+            <arg type="s" name="cookie" direction="in" />
+            <arg type="s" name="req_data" direction="out" />
+            <arg type="s" name="license_url" direction="out" />
+            <arg type="i" name="ret" direction="out" />
+        </method>
+        <method name="DrmRegisterLicense">
+            <arg type="s" name="resp_data" direction="in" />
+            <arg type="s" name="cookie" direction="in" />
+            <arg type="i" name="ret" direction="out" />
+        </method>
+        <method name="DrmDecryptPackage">
+            <arg type="s" name="drm_file_path" direction="in" />
+            <arg type="s" name="decrypted_file_path" direction="in" />
+            <arg type="s" name="cookie" direction="in" />
+            <arg type="i" name="ret" direction="out" />
+        </method>
+    </interface>
+</node>
index d26d680..58cc707 100755 (executable)
 
 
 #include "comm_config.h"
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-bindings.h>
+#include "comm_internal.h"
+#include <gio/gio.h>
+#include <stdio.h>
+#include <fcntl.h>
 #include <stdlib.h>
 #include <unistd.h>
 
 #include "comm_pkg_mgr_server.h"
+#include "comm_pkg_mgr_gdbus_generated.h"
 
-/* object class def: do nothing on this */
-struct PkgMgrObjectClass {
-       GObjectClass parent_class;
-};
-
-/* object def: has connection */
-struct PkgMgrObject {
-       GObject parent;
 
-       DBusGConnection *bus;
+struct pkg_mgr_server_gdbus_s {
+       OrgTizenPkgmgr *obj;
+       GDBusConnection *connection;
+       guint owner_id;
 
        request_callback req_cb;
+#ifdef _APPFW_FEATURE_EXPANSION_PKG_INSTALL
+       request_tep_callback req_tep_cb;
+#endif
        create_directory_cb create_dir_cb;
-       void *req_cb_data;
-};
-
-#define PKG_MGR_OBJECT(object) \
-(G_TYPE_CHECK_INSTANCE_CAST((object), \
-       PKG_MGR_TYPE_OBJECT, PkgMgrObject))
-#define PKG_MGR_OBJECT_CLASS(klass) \
-       (G_TYPE_CHECK_CLASS_CAST((klass), \
-        PKG_MGR_TYPE_OBJECT, PkgMgrObjectClass))
-#define PKG_MGR_IS_OBJECT(object) \
-       (G_TYPE_CHECK_INSTANCE_TYPE((object), \
-       PKG_MGR_TYPE_OBJECT))
-#define PKG_MGR_IS_OBJECT_CLASS(klass) \
-       (G_TYPE_CHECK_CLASS_TYPE((klass), \
-        PKG_MGR_TYPE_OBJECT))
-#define PKG_MGR_OBJECT_GET_CLASS(obj) \
-       (G_TYPE_INSTANCE_GET_CLASS((obj), \
-       PKG_MGR_TYPE_OBJECT, PkgMgrObjectClass))
-
-/* Macro that creates follwoing functions automatically;
- *   - pkgmgr_object_get_type()
- *   - pkgmgr_object_parent_class
- */
-G_DEFINE_TYPE(PkgMgrObject, pkg_mgr_object, G_TYPE_OBJECT);
-
-/* Method declarations
- * Used for binding stub.
- */
-GCallback pkgmgr_request(PkgMgrObject *obj, const gchar *req_id,
-                        const gint req_type, const gchar *pkg_type,
-                        const gchar *pkgid, const gchar *args,
-                        const gchar *cookie, gint *ret, GError **err);
 
-GCallback pkgmgr_create_external_directory(PkgMgrObject *obj,
-                                          gint *ret,
-                                          GError **err);
+       drm_generate_license_request_cb gen_license_req_cb;
+       drm_register_license_cb reg_license_cb;
+       drm_decrypt_package_cb decrypt_pkg_cb;
 
-/* Include stub header */
-#include "comm_pkg_mgr_server_dbus_bindings.h"
+       void *req_cb_data;
+};
 
-static void pkg_mgr_object_finalize(GObject *self);
-static void pkg_mgr_object_init(PkgMgrObject *obj);
-static void pkg_mgr_object_class_init(PkgMgrObjectClass *klass);
-static void pkg_mgr_object_init(PkgMgrObject *obj)
+static int pkg_mgr_get_sender_pid(GDBusConnection *connection, char *sender_name)
 {
-       dbg("called");
-       g_assert(NULL != obj);
-
-       GError *err = NULL;
-
-       /* Establish dbus session  */
-       obj->bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, &err);
-       if (NULL == obj->bus) {
-               dbg("Failed to open connection to dbus: %s", err->message);
-               return;
+       guint pid = 0;
+       GError *error = NULL;
+       GVariant *ret;
+
+       ret = g_dbus_connection_call_sync(connection,
+                       "org.freedesktop.DBus",
+                       "/org/freedesktop/DBus",
+                       "org.freedesktop.DBus",
+                       "GetConnectionUnixProcessID",
+                       g_variant_new("(s)", sender_name),
+                       NULL,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       -1,
+                       NULL,
+                       &error);
+       if (ret != NULL) {
+               g_variant_get(ret, "(u)", &pid);
+               g_variant_unref(ret);
        }
 
-       /* Create a proxy to resgister, connecting dbus daemon */
-       DBusGProxy *proxy = NULL;
-       proxy = dbus_g_proxy_new_for_name(obj->bus,
-                                         DBUS_SERVICE_DBUS,
-                                         DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
-       if (NULL == proxy) {
-               dbg("Failed to get a proxy");
-               return;
-       }
-       /* Register service name
-        * NOTE: refer to
-       http://dbus.freedesktop.org/doc/dbus-specification.html
-        */
-       guint result;
-       if (!dbus_g_proxy_call(proxy, "RequestName", &err,
-                              /* input vars */
-                              G_TYPE_STRING, COMM_PKG_MGR_DBUS_SERVICE,
-                               /* service name */
-                              G_TYPE_UINT, 0,  /* default flag */
-                              G_TYPE_INVALID,
-                              /* output vars */
-                              G_TYPE_UINT, &result, G_TYPE_INVALID)) {
-               g_printerr("dbus RequestName RPC failed %s %d", err->message, TRUE);
-               return;
-       }
-       dbg("RequestName returns: %d", result);
+       dbg("zone pid : %d", pid);
 
-       dbus_g_connection_register_g_object(obj->bus,
-                                           COMM_PKG_MGR_DBUS_PATH,
-                                           G_OBJECT(obj));
-       dbg("Ready to serve requests");
+       return pid;
+}
 
-       g_object_unref(proxy);
+#define MAX_ZONE_NAME_LEN 128
+#define ZONE_HOST "host"
 
-       dbg("done");
+/**
+ * Set request callback function
+ */
+void pkg_mgr_set_request_callback(pkgmgr_server_gdbus_h handle, request_callback req_cb,
+               void *cb_data)
+{
+       handle->req_cb = req_cb;
+       handle->req_cb_data = cb_data;
 }
 
-static void pkg_mgr_object_class_init(PkgMgrObjectClass *klass)
+#ifdef _APPFW_FEATURE_EXPANSION_PKG_INSTALL
+void pkg_mgr_set_request_tep_callback(pkgmgr_server_gdbus_h handle, request_tep_callback req_tep_cb,
+               void *cb_data)
 {
-       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);
-
-       dbg("done");
+       handle->req_tep_cb = req_tep_cb;
+       handle->req_cb_data = cb_data;
 }
+#endif
 
-static void pkg_mgr_object_finalize(GObject *self)
+void pkg_mgr_set_callback_to_create_directory(pkgmgr_server_gdbus_h handle, create_directory_cb callback)
 {
-       /* PkgMgrObjectClass *klass = (PkgMgrObjectClass *) G_OBJECT_CLASS(self); */
+       handle->create_dir_cb = callback;
+       handle->req_cb_data = NULL;
+}
 
-       /* Call parent's finalize function
-        * 'server_object_parent_class' comes from G_DEFINE_TYPE() macro.
-        */
-       G_OBJECT_CLASS(pkg_mgr_object_parent_class)->finalize(self);
+void pkg_mgr_set_drm_generate_license_request_callback(pkgmgr_server_gdbus_h handle,
+               drm_generate_license_request_cb gen_license_req_cb)
+{
+       handle->gen_license_req_cb = gen_license_req_cb;
+       handle->req_cb_data = NULL;
 }
 
-/**
- * Set request callback function
- */
-void pkg_mgr_set_request_callback(PkgMgrObject *obj, request_callback req_cb,
-               void *cb_data)
+void pkg_mgr_set_drm_register_license_callback(pkgmgr_server_gdbus_h handle,
+               drm_register_license_cb reg_license_cb)
 {
-       obj->req_cb = req_cb;
-       obj->req_cb_data = cb_data;
+       handle->reg_license_cb = reg_license_cb;
+       handle->req_cb_data = NULL;
 }
 
-void pkg_mgr_set_callback_to_create_directory(PkgMgrObject *obj, create_directory_cb callback)
+void pkg_mgr_set_drm_decrypt_package_callback(pkgmgr_server_gdbus_h handle,
+               drm_decrypt_package_cb decrypt_pkg_cb)
 {
-       obj->create_dir_cb = callback;
-       obj->req_cb_data = NULL;
+       handle->decrypt_pkg_cb = decrypt_pkg_cb;
+       handle->req_cb_data = NULL;
 }
 
 /* dbus-glib methods */
 
-GCallback pkgmgr_request(PkgMgrObject *obj,
-              const gchar *req_id,
-              const gint req_type,
-              const gchar *pkg_type,
-              const gchar *pkgid,
-              const gchar *args,
-              const gchar *cookie, gint *ret, GError **err)
+static gboolean pkgmgr_request(OrgTizenPkgmgr *obj,
+               GDBusMethodInvocation *invocation,
+               const gchar *req_id,
+               const gint req_type,
+               const gchar *pkg_type,
+               const gchar *pkgid,
+               const gchar *args,
+               const gchar *cookie,
+               gpointer user_data)
 {
        dbg("Called");
-       *ret = COMM_RET_OK;     /* TODO: fix this! */
+       int ret = COMM_RET_OK;  /* TODO: fix this! */
+       int pid;
+       char *sender_name;
+       char temp_name[MAX_ZONE_NAME_LEN] = {0, };
+       char *zone = NULL;
+
+       struct pkg_mgr_server_gdbus_s *pkgmgr_server = (struct pkg_mgr_server_gdbus_s *)user_data;
+       if (pkgmgr_server == NULL) {
+               ERR("pkg_mgr_server_gdbus_s is null");
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(i)", COMM_RET_ERROR));
+               return FALSE;
+       }
 
        /* TODO: Add business logic
         * - add to queue, or remove from queue
         * */
 
-       if (obj->req_cb) {
-               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,
-                           pkgid, args, cookie, ret);
+       sender_name = g_dbus_method_invocation_get_sender(invocation);
+       dbg("sender_name: %s", sender_name);
+       pid = pkg_mgr_get_sender_pid(pkgmgr_server->connection, sender_name);
+       dbg("sender_pid: %d", pid);
+
+       get_zone_name(pid, temp_name, MAX_ZONE_NAME_LEN);
+       if (strlen(temp_name)) {
+               zone = strdup(temp_name);
+       }
+
+       if (pkgmgr_server->req_cb) {
+               SECURE_LOGD("Call request callback(obj, %s, %d, %s, %s, %s, %s)",
+                   req_id, req_type, pkg_type, pkgid, args, zone);
+               pkgmgr_server->req_cb(pkgmgr_server->req_cb_data, req_id, req_type, pkg_type,
+                           pkgid, args, cookie, zone, &ret);
        } else {
                dbg("Attempt to call request callback,"
                " but request callback is not set. Do nothing.\n"
@@ -210,26 +182,252 @@ GCallback pkgmgr_request(PkgMgrObject *obj,
                " to register your callback.");
        }
 
-       return (GCallback) TRUE;
+       if (zone)
+               free(zone);
+       g_dbus_method_invocation_return_value(invocation, g_variant_new("(i)", ret));
+
+       return TRUE;
 }
 
-GCallback pkgmgr_create_external_directory(PkgMgrObject *obj, gint *ret, GError **err)
+#ifdef _APPFW_FEATURE_EXPANSION_PKG_INSTALL
+static gboolean pkgmgr_tep_request(OrgTizenPkgmgr *obj,
+               GDBusMethodInvocation *invocation,
+               const gchar *req_id,
+               const gint req_type,
+               const gchar *pkg_type,
+               const gchar *pkgid,
+               const gchar *tep_path,
+               const gchar *args,
+               const gchar *cookie,
+               gpointer user_data)
 {
-       int res;
+       dbg("Called");
+       int ret = COMM_RET_OK;  /* TODO: fix this! */
+       int pid;
+       char *sender_name;
+       char temp_name[MAX_ZONE_NAME_LEN] = {0, };
+       char *zone = NULL;
+
+       /* TODO: Add business logic
+        * - add to queue, or remove from queue
+        * */
+
+       struct pkg_mgr_server_gdbus_s *pkgmgr_server = (struct pkg_mgr_server_gdbus_s *)user_data;
+       if (pkgmgr_server == NULL) {
+               ERR("pkg_mgr_server_gdbus_s is null");
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(i)", COMM_RET_ERROR));
+               return FALSE;
+       }
+
+       sender_name = g_dbus_method_invocation_get_sender(invocation);
+       dbg("sender_name: %s", sender_name);
+       pid = pkg_mgr_get_sender_pid(pkgmgr_server->connection, sender_name);
+       dbg("sender_pid: %d", pid);
+
+       get_zone_name(pid, temp_name, MAX_ZONE_NAME_LEN);
+       if (strlen(temp_name)) {
+               zone = strdup(temp_name);
+       }
+
+       if (pkgmgr_server->req_tep_cb) {
+               SECURE_LOGD("Call request callback(obj, %s, %d, %s, %s, %s, %s, %s)",
+                   req_id, req_type, pkg_type, pkgid, tep_path, args, zone);
+               pkgmgr_server->req_tep_cb(pkgmgr_server->req_cb_data, req_id, req_type, pkg_type,
+                           pkgid, tep_path, args, cookie, zone, &ret);
+       } else {
+               dbg("Attempt to call request_tep callback,"
+               " but request callback is not set. Do nothing.\n"
+               "Use pkg_mgr_set_request_tep_callback()"
+               " to register your callback.");
+       }
+
+       if (zone) {
+               free(zone);
+               zone = NULL;
+       }
+
+       g_dbus_method_invocation_return_value(invocation, g_variant_new("(i)", ret));
+       return TRUE;
+}
+#endif
+
+static gboolean pkgmgr_create_external_directory(OrgTizenPkgmgr *obj,
+               GDBusMethodInvocation *invocation,
+               gpointer user_data)
+{
+       int res = 0;
+       int pid;
+       char *sender_name;
+       char temp_name[MAX_ZONE_NAME_LEN] = {0, };
+       char *zone = NULL;
+
+       struct pkg_mgr_server_gdbus_s *pkgmgr_server = (struct pkg_mgr_server_gdbus_s *)user_data;
+       if (pkgmgr_server == NULL) {
+               ERR("pkg_mgr_server_gdbus_s is null");
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(i)", COMM_RET_ERROR));
+               return FALSE;
+       }
+
+       sender_name = g_dbus_method_invocation_get_sender(invocation);
+       dbg("sender_name: %s", sender_name);
+       pid = pkg_mgr_get_sender_pid(pkgmgr_server->connection, sender_name);
+       dbg("sender_pid: %d", pid);
+
+       get_zone_name(pid, temp_name, MAX_ZONE_NAME_LEN);
+       if (strlen(temp_name)) {
+               zone = strdup(temp_name);
+       }
+       dbg("zone(%s)", zone);
 
        dbg("Try to create external directories.");
-       if (obj->create_dir_cb)
+       if (pkgmgr_server->create_dir_cb)
        {
-               res = obj->create_dir_cb();
-               if (res < 0)
-               {
+               res = pkgmgr_server->create_dir_cb(zone);
+               if (res < 0) {
                        ERR("_create_external_directory() is failed. error = [%d]", res);
                }
        } else {
                res = -1;
        }
 
-       *ret = res;
+       g_dbus_method_invocation_return_value(invocation, g_variant_new("(i)", res));
+
+       if (zone) {
+               free(zone);
+               zone = NULL;
+       }
+       return TRUE;
+}
+
+static gboolean pkgmgr_drm_generate_license_request(OrgTizenPkgmgr *obj,
+               GDBusMethodInvocation *invocation,
+               const gchar *resp_data,
+               const gchar *cookie,
+               gpointer user_data)
+{
+       int res = -1;
+       gchar *req_data = NULL;
+       gchar *license_url = NULL;
+       int ret = 0;
+       struct pkg_mgr_server_gdbus_s *pkgmgr_server = (struct pkg_mgr_server_gdbus_s *)user_data;
+       dbg("Try to call package_manager_drm_generate_license_request.");
+       if (pkgmgr_server->gen_license_req_cb)
+       {
+               int res = pkgmgr_server->gen_license_req_cb(resp_data, cookie, &req_data, &license_url, &ret);
+               if (res < 0)
+               {
+                       ERR("Calling package_manager_drm_generate_license_request is failed. error = [%d]", res);
+               }
+       }
+
+       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ssi)",req_data, license_url, ret));
+       return TRUE;
+}
+
+static gboolean pkgmgr_drm_register_license(OrgTizenPkgmgr *obj,
+               GDBusMethodInvocation *invocation,
+               const gchar *resp_data,
+               const gchar *cookie,
+               gpointer user_data)
+{
+       int res = -1;
+       int ret = 0;
+       struct pkg_mgr_server_gdbus_s *pkgmgr_server = (struct pkg_mgr_server_gdbus_s *)user_data;
+       dbg("Try to call package_manager_drm_register_license.");
+       if (pkgmgr_server->reg_license_cb)
+       {
+               res = pkgmgr_server->reg_license_cb(resp_data, cookie, &ret);
+               if (res < 0)
+               {
+                       ERR("Calling package_manager_drm_register_license is failed. error = [%d]",     res);
+               }
+       }
+
+       g_dbus_method_invocation_return_value(invocation, g_variant_new("(i)", ret));
+       return TRUE;
+}
 
-       return (GCallback) TRUE;
+static gboolean pkgmgr_drm_decrypt_package(OrgTizenPkgmgr *obj,
+               GDBusMethodInvocation *invocation,
+               const gchar *drm_file_path,
+               const gchar *decrypted_file_path,
+               const gchar *cookie,
+               gpointer user_data)
+{
+       int res = -1;
+       int ret = 0;
+       struct pkg_mgr_server_gdbus_s *pkgmgr_server = (struct pkg_mgr_server_gdbus_s *)user_data;
+       dbg("Try to call package_manager_drm_decrypt_package.");
+       if (pkgmgr_server->decrypt_pkg_cb)
+       {
+               res = pkgmgr_server->decrypt_pkg_cb(drm_file_path, decrypted_file_path, cookie, &ret);
+               if (res < 0)
+               {
+                       ERR("Calling package_manager_drm_decrypt_package is failed. error = [%d]", res);
+               }
+       }
+
+       g_dbus_method_invocation_return_value(invocation, g_variant_new("(i)", ret));
+       return TRUE;
+}
+
+static void on_bus_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data)
+{
+       dbg("on_bus_acquired");
+       struct pkg_mgr_server_gdbus_s *pkgmgr_server = (struct pkg_mgr_server_gdbus_s *)user_data;
+
+       pkgmgr_server->obj = org_tizen_pkgmgr_skeleton_new();
+       if (pkgmgr_server->obj == NULL) {
+               ERR("Creating a skeleton object is failed.");
+               return;
+       }
+
+       g_signal_connect(pkgmgr_server->obj, "handle-request", G_CALLBACK(pkgmgr_request), pkgmgr_server);
+       g_signal_connect(pkgmgr_server->obj, "handle-tep-request", G_CALLBACK(pkgmgr_tep_request), pkgmgr_server);
+       g_signal_connect(pkgmgr_server->obj, "handle-create-external-directory", G_CALLBACK(pkgmgr_create_external_directory), pkgmgr_server);
+       g_signal_connect(pkgmgr_server->obj, "handle-drm-generate-license-request", G_CALLBACK(pkgmgr_drm_generate_license_request), pkgmgr_server);
+       g_signal_connect(pkgmgr_server->obj, "handle-drm-register-license", G_CALLBACK(pkgmgr_drm_register_license), pkgmgr_server);
+       g_signal_connect(pkgmgr_server->obj, "handle-drm-decrypt-package", G_CALLBACK(pkgmgr_drm_decrypt_package), pkgmgr_server);
+
+       if (!g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(pkgmgr_server->obj), connection, COMM_PKG_MGR_DBUS_PATH, NULL)) {
+               ERR("Exporting the obj is failed.");
+               g_object_unref(pkgmgr_server->obj);
+               pkgmgr_server->obj = NULL;
+               return;
+       }
+
+       pkgmgr_server->connection = connection;
+       dbg("on_bus_acquired done");
+}
+
+int pkg_mgr_server_gdbus_init(pkgmgr_server_gdbus_h *pkgmgr_server_h)
+{
+       dbg("initialize_gdbus Enter");
+       struct pkg_mgr_server_gdbus_s *pkgmgr_server;
+       pkgmgr_server = calloc(1, sizeof(struct pkg_mgr_server_gdbus_s));
+       if (pkgmgr_server == NULL) {
+               ERR("Out of memory");
+               return -1;
+       }
+
+       pkgmgr_server->owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM, COMM_PKG_MGR_DBUS_SERVICE,
+                               G_BUS_NAME_OWNER_FLAGS_NONE, on_bus_acquired, NULL, NULL, pkgmgr_server, NULL);
+
+       if (pkgmgr_server->owner_id == 0) {
+               ERR("Acquiring the own name is failed.");
+               free(pkgmgr_server);
+               return -1;
+       }
+
+       *pkgmgr_server_h = pkgmgr_server;
+       dbg("initialize_gdbus Exit");
+       return 0;
+}
+
+void pkg_mgr_server_gdbus_fini(pkgmgr_server_gdbus_h pkgmgr_server)
+{
+       g_object_unref(pkgmgr_server->obj);
+       g_object_unref(pkgmgr_server->connection);
+       free(pkgmgr_server);
+       pkgmgr_server = NULL;
 }
index ee69b24..d7c7bf6 100755 (executable)
 #define __COMM_PKG_MGR_SERVER_H__
 
 #include "comm_config.h"
-#include <glib-object.h>
 
-typedef struct PkgMgrObjectClass PkgMgrObjectClass;
-typedef struct PkgMgrObject PkgMgrObject;
-
-/* For returning server object's GType. 
- * I don't use this. Just forward declaration for G_DEFINE_TYPE() macro. */
-API GType pkg_mgr_object_get_type(void);
-#define PKG_MGR_TYPE_OBJECT (pkg_mgr_object_get_type())
+typedef struct pkg_mgr_server_gdbus_s *pkgmgr_server_gdbus_h;
 
 typedef void (*request_callback) (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);
+                                 const char *cookie, const char *zone, int *ret);
+
+#ifdef _APPFW_FEATURE_EXPANSION_PKG_INSTALL
+typedef void (*request_tep_callback) (void *cb_data, const char *req_id,
+                                 const int req_type, const char *pkg_type,
+                                 const char *pkgid, const char *tep_path,
+                                 const char *args, const char *cookie, const char *zone, int *ret);
+#endif
+
+typedef int (*create_directory_cb) (const char *zone);
+
+typedef int (*drm_generate_license_request_cb) (const char *resp_data,
+               const char *cookie, char **req_data,
+               char **license_url, int *ret);
+typedef int (*drm_register_license_cb) (const char *resp_data, const char *cookie, int *ret);
+typedef int (*drm_decrypt_package_cb) (const char *drm_file_path,
+               const char *decrypted_file_path, const char *cookie, int *ret);
 
-typedef int (*create_directory_cb) (void);
+API int pkg_mgr_server_gdbus_init(pkgmgr_server_gdbus_h *pkgmgr_server_h);
+API void pkg_mgr_server_gdbus_fini(pkgmgr_server_gdbus_h pkgmgr_server);
 
-API void pkg_mgr_set_request_callback(PkgMgrObject *obj,
+API void pkg_mgr_set_request_callback(pkgmgr_server_gdbus_h pkgmgr_server,
                request_callback req_cb, void *cb_data);
 
-API void pkg_mgr_set_callback_to_create_directory(PkgMgrObject *obj,
+#ifdef _APPFW_FEATURE_EXPANSION_PKG_INSTALL
+API void pkg_mgr_set_request_tep_callback(pkgmgr_server_gdbus_h pkgmgr_server,
+               request_tep_callback req_cb, void *cb_data);
+#endif
+
+API void pkg_mgr_set_callback_to_create_directory(pkgmgr_server_gdbus_h pkgmgr_server,
                create_directory_cb callback);
 
+API void pkg_mgr_set_drm_generate_license_request_callback(pkgmgr_server_gdbus_h pkgmgr_server,
+               drm_generate_license_request_cb gen_license_req_cb);
+
+API void pkg_mgr_set_drm_register_license_callback(pkgmgr_server_gdbus_h pkgmgr_server,
+               drm_register_license_cb reg_license_cb);
+
+API void pkg_mgr_set_drm_decrypt_package_callback(pkgmgr_server_gdbus_h pkgmgr_server,
+               drm_decrypt_package_cb decrypt_pkg_cb);
+
 #endif                         /* __COMM_PKG_MGR_SERVER_H__ */
diff --git a/comm/comm_socket.c b/comm/comm_socket.c
deleted file mode 100755 (executable)
index 2e36a95..0000000
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * 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 "comm_socket.h"
-
-#include <glib-2.0/glib.h>
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#define __USE_GNU
-#include <sys/socket.h>
-#include <linux/un.h>          /* for sockaddr_un */
-
-#define COMM_SOCKET_SERVER_SOCK_PATH_PREFIX "/tmp/comm_socket_"
-
-#define CHK_CS_RET(r) \
-       do { if (NULL == cs) return (r); } while (0)
-
-struct comm_socket {
-       int sockfd;
-};
-
-static int _get_new_socket(void)
-{
-       int fd = -1;
-       fd = socket(AF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC, 0);
-       if (fd < 0) {
-               if (EINVAL == errno) {
-                       /* Try again, without SOCK_CLOEXEC option */
-                       fd = socket(AF_LOCAL, SOCK_STREAM, 0);
-                       if (fd < 0) {
-                               return -EINVAL;
-                       }
-               } else {
-                       return -errno;
-               }
-       }
-
-       return fd;
-}
-
-static void _set_sockaddr_un(struct sockaddr_un *saddr, const char *sock_path)
-{
-       saddr->sun_family = AF_UNIX;
-       snprintf(saddr->sun_path, UNIX_PATH_MAX, sock_path);
-}
-
-static const char *_create_server_sock_path(void)
-{
-       static char sock_path[UNIX_PATH_MAX];
-
-       snprintf(sock_path, UNIX_PATH_MAX, "%s_%d",
-                COMM_SOCKET_SERVER_SOCK_PATH_PREFIX, getpid());
-       unlink(sock_path);
-       return sock_path;
-}
-
-comm_socket *_comm_socket_new(void)
-{
-       comm_socket *cs;
-
-       cs = (comm_socket *) calloc(1, sizeof(struct comm_socket));
-
-       return cs;
-}
-
-int _comm_socket_free(comm_socket *cs)
-{
-       CHK_CS_RET(-EINVAL);
-       close(cs->sockfd);
-       free(cs);
-       return 0;
-}
-
-int _comm_socket_create_server(comm_socket *cs, const char *sock_path)
-{
-       CHK_CS_RET(-EINVAL);
-       if (cs->sockfd)
-               return -EISCONN;
-
-
-       int fd = -1;
-       fd = _get_new_socket();
-       if (fd < 0)
-               return fd;
-
-       struct sockaddr_un saddr;
-       _set_sockaddr_un(&saddr, _create_server_sock_path());
-
-       /* 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;
-       }
-
-       cs->sockfd = fd;
-
-       return 0;
-}
-
-static gboolean _read_socket(GIOChannel *source, GIOCondition io)
-{
-       return FALSE;
-}
-
-int comm_socket_server_add_wait_to_thread(comm_socket *cs, void *cb, 
-                                         void *cb_data, GMainContext *context)
-{
-       CHK_CS_RET(-EINVAL);
-       if (!cs->sockfd)
-               return -ENOTCONN;
-
-       GIOChannel *channel;
-       GSource *src;
-
-       channel = g_io_channel_unix_new(cs->sockfd);
-       src = g_io_create_watch(channel, G_IO_IN);
-       g_source_set_callback(src, (GSourceFunc) _read_socket, NULL, NULL);
-       g_source_attach(src, context);
-       g_source_unref(src);
-
-       return 0;
-}
-
-int comm_socket_connect_to_server(comm_socket *cs, 
-                                 const char *server_sock_path)
-{
-       CHK_CS_RET(-EINVAL);
-       if (cs->sockfd)
-               return -EISCONN;
-
-       int r;
-
-       int fd = -1;
-       fd = _get_new_socket();
-       if (fd < 0)
-               return fd;
-
-       /* Try to connect to server_sock_path */
-       struct sockaddr_un saddr;
-       _set_sockaddr_un(&saddr, server_sock_path);
-
-       r = connect(fd, (struct sockaddr *)&saddr, sizeof(saddr));
-       if (0 != r) {
-               close(fd);
-               return -r;
-       }
-
-       /* remember sockfd */
-       cs->sockfd = fd;
-
-       return 0;
-}
-
-int _comm_socket_disconnect(comm_socket *cs)
-{
-       CHK_CS_RET(-EINVAL);
-       if (!cs->sockfd)
-               return -EBADFD;
-
-       if (close(cs->sockfd))
-               return -errno;
-
-       cs->sockfd = 0;
-
-       return 0;
-}
-
-int _comm_socket_send(comm_socket *cs, void **data, int *datasize)
-{
-       CHK_CS_RET(-EINVAL);
-       return 0;
-}
-
-int _comm_socket_recv(comm_socket *cs, void *data, int datasize)
-{
-       CHK_CS_RET(-EINVAL);
-       return 0;
-}
-
diff --git a/comm/comm_socket.h b/comm/comm_socket.h
deleted file mode 100755 (executable)
index 0d9e840..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.
- *
- */
-
-
-
-
-
-typedef struct comm_socket comm_socket;
-
-comm_socket *_comm_socket_new(void);
-int _comm_socket_free(comm_socket *csc);
-int _comm_socket_connect(comm_socket *csc, const char *server_sock_path);
-int _comm_socket_disconnect(comm_socket *csc);
-int _comm_socket_create_server(comm_socket *cs, const char *sock_path);
-int _comm_socket_send(comm_socket *csc, void **data, int *datasize);
-int _comm_socket_recv(comm_socket *csc, void *data, int datasize);
diff --git a/comm/comm_socket_client.c b/comm/comm_socket_client.c
deleted file mode 100755 (executable)
index 9423dbf..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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 "comm_socket_client.h"
-
-#include <sys/types.h>
-#include <sys/socket.h>
-
-#define CHK_CSC_RET(r) \
-       do { if (NULL == csc) return (r); } while (0)
-
-struct comm_socket_client {
-       int sockfd;
-};
-
-comm_socket_client *_comm_socket_client_new(const char *server_sock_path)
-{
-       int fd = -1;
-       fd = socket(AF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC, 0);
-       if (fd < 0) {
-               if (EINVAL == errno) {
-                       /* Try again, without SOCK_CLOEXEC option */
-                       fd = socket(AF_LOCAL, SOCK_STREAM, 0);
-                       if (fd < 0) {
-                               return NULL;
-                       }
-               } else {
-                       return NULL;
-               }
-       }
-
-       /* Try to connect to server_sock_path */
-       struct sockaddr_un saddr = { 0, };
-
-}
-
-int _comm_socket_client_free(comm_socket_client *csc)
-{
-       CHK_CSC_RET(-EINVAL);
-       free(csc);
-       return 0;
-}
-
index f3f31af..a1b8db7 100755 (executable)
 
 
 #include "comm_config.h"
+#include "comm_internal.h"
 #include "comm_status_broadcast_server.h"
 #include <dbus/dbus.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+#define MAX_ZONE_NAME_LEN 128
+#define ZONE_HOST "host"
+
+static char *__get_signal_name(char *post_name, const char *pre_name, const char *zone)
+{
+       memset(post_name, 0, MAX_ZONE_NAME_LEN);
+       if (zone && strlen(zone) && strcmp(zone, ZONE_HOST) != 0) {
+               snprintf(post_name, MAX_ZONE_NAME_LEN, "%s_", pre_name);
+               strncat(post_name, zone, MAX_ZONE_NAME_LEN - strlen(post_name) - 1);
+       } else {
+               snprintf(post_name, MAX_ZONE_NAME_LEN, "%s", pre_name);
+       }
+
+       return post_name;
+}
 
 /********************************************
  * pure dbus signal service for internal use
@@ -64,10 +84,6 @@ static char *__get_prifix(int status_type)
                        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;
        }
@@ -107,10 +123,6 @@ static char *__get_path(int status_type)
                        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;
        }
@@ -150,10 +162,6 @@ static char *__get_interface(int status_type)
                        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;
        }
@@ -193,10 +201,6 @@ static char *__get_name(int status_type)
                        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;
        }
@@ -256,9 +260,41 @@ comm_status_broadcast_server_send_signal(int comm_status_type, DBusConnection *c
                return;
        }
 
-       msg = dbus_message_new_signal(__get_path(comm_status_type), __get_interface(comm_status_type), __get_name(comm_status_type));
+       char temp_name[MAX_ZONE_NAME_LEN] = {0, };
+       char *zone = NULL;
+       int pid = getpid();
+       if (get_zone_name(pid, temp_name, MAX_ZONE_NAME_LEN) == -1) {
+               dbg("retry to get zone by gethostname");
+               gethostname(temp_name, sizeof(temp_name));
+       }
+       if (strlen(temp_name)) {
+               zone = strdup(temp_name);
+               dbg("send signal : pid(%d), zone(%s), pkg_typ(%s), pkg_id(%s), key(%s), val(%s)",
+                                pid, zone, pkg_type, pkgid, key, val);
+       }
+
+       dbg("send signal : pid(%d), pkg_typ(%s), pkg_id(%s), key(%s), val(%s)",
+                                pid, pkg_type, pkgid, key, val);
+       dbg("send signal : interface_name(%s), signal_name(%s)",
+               __get_interface(comm_status_type), __get_name(comm_status_type));
+
+       /* for new signal name */
+       char signal_name[128] = {0, };
+
+       /*
+       dbg("send signal : %s, %s", __get_signal_name(signal_name,
+               __get_name(comm_status_type), zone), __get_name(comm_status_type));
+       */
+
+       msg = dbus_message_new_signal(__get_path(comm_status_type),
+               __get_interface(comm_status_type),
+               __get_signal_name(signal_name,
+               __get_name(comm_status_type),
+               zone));
        if (NULL == msg) {
                dbg("msg NULL");
+               if (zone)
+                       free(zone);
                return;
        }
 
@@ -278,6 +314,9 @@ comm_status_broadcast_server_send_signal(int comm_status_type, DBusConnection *c
        }
        dbus_connection_flush(conn);
        dbus_message_unref(msg);
+
+       if (zone)
+               free(zone);
 }
 
 API void comm_status_broadcast_server_disconnect(DBusConnection *conn)
diff --git a/comm/comm_status_broadcast_signal_marshaller.list b/comm/comm_status_broadcast_signal_marshaller.list
deleted file mode 100644 (file)
index 1c50753..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-VOID:STRING,STRING,STRING,STRING,STRING
-
diff --git a/comm/pkgmgr-installer-pkg-mgr-server.pc.in b/comm/pkgmgr-installer-pkg-mgr-server.pc.in
new file mode 100755 (executable)
index 0000000..b91c456
--- /dev/null
@@ -0,0 +1,16 @@
+#
+# Copyright (c) 2008 ~ 2010 Samsung Electronics Co., Ltd.
+# All rights reserved.
+#
+
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: package manager installer
+Description: SLP package manager's installer library
+Version: @VERSION@
+Requires: dbus-1 dbus-glib-1
+Libs: -L${libdir} -lpkgmgr_installer_pkg_mgr_server
+Cflags: -I${includedir}/pkgmgr
index b5540b0..d956fcd 100755 (executable)
 #include "pkgmgr_installer.h"
 #include "pkgmgr_installer_config.h"
 
+#ifdef _APPFW_FEATURE_EXPANSION_PKG_INSTALL
+#include "package-manager-debug.h"
+#endif
+
 #include "comm_config.h"
-#include "comm_socket.h"
 #include "comm_status_broadcast_server.h"
 #include "error_report.h"
 
@@ -55,15 +58,29 @@ struct pkgmgr_installer {
        int request_type;
        int move_type;
        char *pkgmgr_info;
+#ifdef _APPFW_FEATURE_EXPANSION_PKG_INSTALL
+               char *tep_path;
+               int tep_move;
+#endif
        char *session_id;
        char *license_path;
        char *quiet_socket_path;
        char *optional_data;
        char *caller_pkgid;
+#ifdef _APPFW_FEATURE_EXPANSION_PKG_INSTALL
+               int is_tep_included;
+#endif
+       bool debug_mode;
+       char *pkg_chksum;
 
        DBusConnection *conn;
 };
 
+#ifdef _APPFW_FEATURE_EXPANSION_PKG_INSTALL
+#define TEP_MOVE "tep_move"
+#define TEP_COPY "tep_copy"
+#endif
+
 /* API */
 
 static int __send_signal_for_event(int comm_status_type, pkgmgr_installer *pi,
@@ -92,6 +109,8 @@ API int __send_event(pkgmgr_installer *pi,
 {
        int r = -1;
 
+       _LOGD("option is pkgid[%s] key[%s] value[%s]", pkgid, key, val );
+
        if (strcmp(key,PKGMGR_INSTALLER_START_KEY_STR) == 0) {
                if(strcmp(val,PKGMGR_INSTALLER_UPGRADE_EVENT_STR) == 0) {
                        pi->request_type = PKGMGR_REQ_UPGRADE;
@@ -101,14 +120,26 @@ API int __send_event(pkgmgr_installer *pi,
                        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);
+#ifdef _APPFW_FEATURE_MOUNT_INSTALL
+               } else if (pi->request_type == PKGMGR_REQ_MOUNT_INSTALL){
+                       r = __send_signal_for_event(COMM_STATUS_BROADCAST_INSTALL, pi, pkg_type, pkgid, key, val);
+#endif
+               } else if (pi->request_type == PKGMGR_REQ_MOVE){
+                       r = __send_signal_for_event(COMM_STATUS_BROADCAST_MOVE, 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_MOVE){
+                       r = __send_signal_for_event(COMM_STATUS_BROADCAST_MOVE, 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);
+#ifdef _APPFW_FEATURE_MOUNT_INSTALL
+               } else if (pi->request_type == PKGMGR_REQ_MOUNT_INSTALL){
+                       r = __send_signal_for_event(COMM_STATUS_BROADCAST_INSTALL, pi, pkg_type, pkgid, key, val);
+#endif
                }
        } 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);
@@ -125,6 +156,7 @@ API pkgmgr_installer *pkgmgr_installer_new(void)
                return ERR_PTR(-ENOMEM);
 
        pi->request_type = PKGMGR_REQ_INVALID;
+       pi->pkg_chksum = NULL;
 
        return pi;
 }
@@ -142,6 +174,14 @@ API int pkgmgr_installer_free(pkgmgr_installer *pi)
                free(pi->optional_data);
        if (pi->caller_pkgid)
                free(pi->caller_pkgid);
+       if(pi->license_path)
+               free(pi->license_path);
+       if(pi->quiet_socket_path)
+               free(pi->quiet_socket_path);
+#ifdef _APPFW_FEATURE_EXPANSION_PKG_INSTALL
+       if(pi->tep_path)
+               free(pi->tep_path);
+#endif
 
        if (pi->conn)
                comm_status_broadcast_server_disconnect(pi->conn);
@@ -183,6 +223,9 @@ pkgmgr_installer_receive_request(pkgmgr_installer *pi,
                        break;
 
                case 'i':       /* install */
+#ifdef _APPFW_FEATURE_EXPANSION_PKG_INSTALL
+                       _LOGE("option is [i]" );
+#endif
                        if (mode) {
                                r = -EINVAL;
                                goto RET;
@@ -192,8 +235,42 @@ pkgmgr_installer_receive_request(pkgmgr_installer *pi,
                        if (pi->pkgmgr_info)
                                free(pi->pkgmgr_info);
                        pi->pkgmgr_info = strndup(optarg, MAX_STRLEN);
+#ifdef _APPFW_FEATURE_EXPANSION_PKG_INSTALL
+                       _LOGD("option is [i] pkgid[%s]", pi->pkgmgr_info );
+                       if (pi->pkgmgr_info && strlen(pi->pkgmgr_info)==0){
+                               free(pi->pkgmgr_info);
+                       }else{
+                               mode = 'i';
+                       }
+                       break;
+
+               case 'e':       /* install */
+                       _LOGD("option is [e]" );
+                       if (!mode)
+                               pi->request_type = PKGMGR_REQ_INSTALL_TEP;
+                       if (pi->tep_path)
+                               free(pi->tep_path);
+                       pi->tep_path = strndup(optarg, MAX_STRLEN);
+                       pi->is_tep_included = 1;
+                       _LOGD("option is [e] tep_path[%s]", pi->tep_path);
+                       break;
+
+               case 'M':       /* install */
+                       _LOGD("option is [M]" );
+                       if (strncmp(optarg, TEP_MOVE, strlen(TEP_MOVE)) == 0)
+                               pi->tep_move = 1;
+                       else
+                               pi->tep_move = 0;
+                       _LOGD("option is [e] tep_move[%d]", pi->tep_move);
+#endif
                        break;
 
+#ifdef _APPFW_FEATURE_MOUNT_INSTALL
+               case 'w':       /* mount based install */
+                       _LOGD("option is [w]" );
+                       pi->request_type = PKGMGR_REQ_MOUNT_INSTALL;
+                       break;
+#endif
                case 'd':       /* uninstall */
                        if (mode) {
                                r = -EINVAL;
@@ -265,11 +342,19 @@ pkgmgr_installer_receive_request(pkgmgr_installer *pi,
                        pi->pkgmgr_info = strndup(optarg, MAX_STRLEN);
                        break;
 
+               case 'G':  /* debug mode for sdk */
+                       pi->debug_mode = true;
+                       break;
                case 'o': /* optional data*/
                        if (pi->optional_data)
                                free(pi->optional_data);
                        pi->optional_data = strndup(optarg, MAX_STRLEN);
                        break;
+               case 'C': /* pkgfile checksum for installer app */
+                       if (pi->pkg_chksum)
+                               free(pi->pkg_chksum);
+                       pi->pkg_chksum = strndup(optarg, MAX_STRLEN);
+                       break;
 
                        /* Otherwise */
                case '?':       /* Not an option */
@@ -301,6 +386,20 @@ API const char *pkgmgr_installer_get_request_info(pkgmgr_installer *pi)
        return pi->pkgmgr_info;
 }
 
+#ifdef _APPFW_FEATURE_EXPANSION_PKG_INSTALL
+API const char *pkgmgr_installer_get_tep_path(pkgmgr_installer *pi)
+{
+       CHK_PI_RET(PKGMGR_REQ_INVALID);
+       return pi->tep_path;
+}
+
+API int pkgmgr_installer_get_tep_move_type(pkgmgr_installer *pi)
+{
+       CHK_PI_RET(PKGMGR_REQ_INVALID);
+       return pi->tep_move;
+}
+#endif
+
 API const char *pkgmgr_installer_get_session_id(pkgmgr_installer *pi)
 {
        CHK_PI_RET(PKGMGR_REQ_INVALID);
@@ -329,6 +428,12 @@ API int pkgmgr_installer_is_quiet(pkgmgr_installer *pi)
 return 1;
 }
 
+API const char *pkgmgr_installer_get_pkg_chksum(pkgmgr_installer *pi)
+{
+       CHK_PI_RET(PKGMGR_REQ_INVALID);
+       return pi->pkg_chksum;
+}
+
 API int pkgmgr_installer_get_move_type(pkgmgr_installer *pi)
 {
        CHK_PI_RET(PKGMGR_REQ_INVALID);
@@ -340,6 +445,22 @@ 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_is_debug_mode(pkgmgr_installer *pi)
+{
+       CHK_PI_RET(PKGMGR_REQ_INVALID);
+       return pi->debug_mode;
+}
+
+API int pkgmgr_installer_send_app_uninstall_signal(pkgmgr_installer *pi,
+                            const char *pkg_type,
+                            const char *pkgid,
+                            const char *val)
+{
+       int ret = -1;
+
+       ret = __send_signal_for_event(COMM_STATUS_BROADCAST_UNINSTALL, pi, pkg_type, pkgid, "appid", val);
+       return ret;
+}
 
 API int
 pkgmgr_installer_send_signal(pkgmgr_installer *pi,
@@ -352,9 +473,6 @@ pkgmgr_installer_send_signal(pkgmgr_installer *pi,
        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)
index fef15f7..ab6b0b0 100755 (executable)
@@ -57,7 +57,6 @@ typedef void* pkgmgr_instcertinfo_h;
 #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"
@@ -84,7 +83,13 @@ enum {
        PKGMGR_REQ_GETSIZE = 7,
        PKGMGR_REQ_UPGRADE = 8,
        PKGMGR_REQ_SMACK = 9,
-       PKGMGR_REQ_GETJUNKINFO = 10,
+#ifdef _APPFW_FEATURE_EXPANSION_PKG_INSTALL
+       PKGMGR_REQ_INSTALL_TEP = 10,
+#endif
+#ifdef _APPFW_FEATURE_MOUNT_INSTALL
+       PKGMGR_REQ_MOUNT_INSTALL = 11,
+#endif
+
 };
 
 enum {
@@ -287,7 +292,7 @@ int main(int argc, char **argv)
 
        pkgmgr_installer_free(pi);
        return r;
-}      
+}
 @endcode
  */
 const char *pkgmgr_installer_get_session_id(pkgmgr_installer *pi);
@@ -321,7 +326,7 @@ int main(int argc, char **argv)
 
        pkgmgr_installer_free(pi);
        return r;
-}      
+}
 @endcode
  */
 const char *pkgmgr_installer_get_license_path(pkgmgr_installer *pi);
@@ -391,12 +396,45 @@ int main(int argc, char **argv)
 
        pkgmgr_installer_free(pi);
        return r;
-}      
+}
        @endcode
  */
 int pkgmgr_installer_is_quiet(pkgmgr_installer *pi);
 
 /**
+       @brief          Get checksum value of pkg file
+       @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         package checksum value
+       @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;
+       }
+       checksum_value = pkgmgr_installer_get_pkg_chksum(pi);
+
+       //Do Something
+
+       pkgmgr_installer_free(pi);
+       return r;
+}
+       @endcode
+ */
+const char *pkgmgr_installer_get_pkg_chksum(pkgmgr_installer *pi);
+
+/**
        @brief          Get move type
        @pre            pkgmgr_installer_receive_request() must be called.
        @post           None
@@ -464,7 +502,45 @@ int main(int argc, char **argv)
 const char *pkgmgr_installer_get_caller_pkgid(pkgmgr_installer *pi);
 
 /**
-       @brief          Send a process status signal 
+       @brief          Get if a request is with debug mode or not
+       @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         false if a request is not debug mode
+       @retval         true if a request is debug mode
+       @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;
+       }
+       if(pkgmgr_installer_is_debug_mode(pi)) {
+               // Do quiet mode work...
+       } else {
+               // Do normal mode work...
+       }
+
+       pkgmgr_installer_free(pi);
+       return r;
+}
+       @endcode
+ */
+int pkgmgr_installer_is_debug_mode(pkgmgr_installer *pi);
+
+
+
+/**
+       @brief          Send a process status signal
        @pre            None
        @post           None
        @see            None
@@ -499,7 +575,7 @@ int main(int argc, char **argv)
 
        pkgmgr_installer_free(pi);
        return r;
-}      
+}
        @endcode
  */
 int pkgmgr_installer_send_signal(pkgmgr_installer *pi,
@@ -508,6 +584,50 @@ int pkgmgr_installer_send_signal(pkgmgr_installer *pi,
                                 const char *val);
 
 /**
+       @brief          Send a signal which indicates application is being uninstalled
+       @pre            None
+       @post           None
+       @see            None
+       @param[in]      pi      pkgmgr_installer object
+       @param[in]      pkg_type        package type: "deb", "jar", "wgt", ...
+       @param[in]      pkgid   package id
+       @param[in]      key                     Signal key
+       @param[in]      val                     Signal value
+       @return         Operation result
+       @retval         0 on success
+       @retval         -errno on failure
+       @code
+#include <pkgmgr_installer.h>
+int main(int argc, char **argv)
+{
+       pkgmgr_installer *pi;
+       int r = 0;
+       char *session_id = NULL;
+
+       pi = pkgmgr_installer_new();
+       if(!pi) return -1;
+       if(pkgmgr_installer_receive_request(pi, argc, argv)) {
+               r = -1;
+               goto CLEANUP_RET;
+       }
+
+       // Do something...
+       pkgmgr_installer_send_app_uninstall_signal(pi,
+        "tpk", "org.tizen.foo");
+       // A sample signal
+
+       pkgmgr_installer_free(pi);
+       return r;
+}
+       @endcode
+ */
+int pkgmgr_installer_send_app_uninstall_signal(pkgmgr_installer *pi,
+                            const char *pkg_type,
+                            const char *pkgid,
+                            const char *val);
+
+
+/**
  * @brief      This API creates the certinfo handle.
  *
  *              This API is for package-manager client application.\n
@@ -558,7 +678,27 @@ int pkgmgr_installer_destroy_certinfo_set_handle(pkgmgr_instcertinfo_h handle);
  * @param[in]  pkgid                           package ID
  * @return     0 if success, error code(<0) if fail\n
 */
- int pkgmgr_installer_delete_certinfo(const char *pkgid);
+int pkgmgr_installer_delete_certinfo(const char *pkgid);
+
+#ifdef _APPFW_FEATURE_EXPANSION_PKG_INSTALL
+/**
+* @brief pkgmgr_installer_get_tep_path
+*
+* @param pi    pkgmgr_installer object
+*
+* @returns tep path on success. On failure, it returns NULL
+*/
+const char *pkgmgr_installer_get_tep_path(pkgmgr_installer *pi);
+
+/**
+* @brief pkgmgr_installer_get_tep_move_type - returns the tep move type
+*
+* @param pi    pkgmgr_installer object
+*
+* @return returns 0 if tep move type is copy, 1 if tep move type is move. On error, it returns -1
+*/
+int pkgmgr_installer_get_tep_move_type(pkgmgr_installer *pi);
+#endif
 
 #ifdef __cplusplus
 }
index b05c996..ee46066 100755 (executable)
@@ -32,11 +32,27 @@ extern "C" {
 #endif
 
 /* Supported options */
-const char *short_opts = "k:l:i:d:c:m:t:o:r:p:s:";
+#ifdef _APPFW_FEATURE_MOUNT_INSTALL
+#ifdef _APPFW_FEATURE_EXPANSION_PKG_INSTALL
+const char *short_opts = "k:l:i:d:c:m:t:o:r:p:s:e:M:C:wG";
+#else
+const char *short_opts = "k:l:i:d:c:m:t:o:r:p:s:C:wG";
+#endif
+#else
+#ifdef _APPFW_FEATURE_EXPANSION_PKG_INSTALL
+const char *short_opts = "k:l:i:d:c:m:t:o:r:p:s:e:M:C:G";
+#else
+const char *short_opts = "k:l:i:d:c:m:t:o:r:p:s:C:G";
+#endif
+#endif
+
 const struct option long_opts[] = {
        { "session-id", 1, NULL, 'k' },
        { "license-path", 1, NULL, 'l' },
        { "install", 1, NULL, 'i' },
+#ifdef _APPFW_FEATURE_MOUNT_INSTALL
+       { "mount-install", 0, NULL, 'w' },
+#endif
        { "uninstall", 1, NULL, 'd' },
        { "clear", 1, NULL, 'c' },
        { "move", 1, NULL, 'm' },
@@ -45,6 +61,12 @@ const struct option long_opts[] = {
        { "reinstall", 0, NULL, 'r' },
        { "caller-pkgid", 1, NULL, 'p' },
        { "smack", 1, NULL, 's' },
+#ifdef _APPFW_FEATURE_EXPANSION_PKG_INSTALL
+       { "extension", 1, NULL, 'e' },
+       { "tep_move", 1, NULL, 'M'},
+#endif
+       { "debug-mode", 0, NULL, 'G'},
+       { "chksum", 1, NULL, 'C'},
        { 0, 0, 0, 0 }  /* sentinel */
 };
 
diff --git a/comm/test/CMakeLists.txt b/comm/test/CMakeLists.txt
deleted file mode 100755 (executable)
index 016aca7..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-include(FindPkgConfig)
-pkg_check_modules(test_pkgs REQUIRED dbus-glib-1 glib-2.0 dlog)
-
-add_definitions(${test_pkgs_CFLAGS})
-
-
-add_executable(test_comm_pkg_mgr_server
-       test_comm_pkg_mgr_server.c)
-target_link_libraries(test_comm_pkg_mgr_server pkgmgr_installer_pkg_mgr_server)
-target_link_libraries(test_comm_pkg_mgr_server ${test_pkgs_LDFLAGS})
-
-add_executable(test_comm_status_broadcast_server
-       test_comm_status_broadcast_server.c)
-target_link_libraries(test_comm_status_broadcast_server pkgmgr_installer_status_broadcast_server)
-target_link_libraries(test_comm_status_broadcast_server ${test_pkgs_LDFLAGS})
-
-add_executable(test_comm_client
-       test_comm_client.c)
-target_link_libraries(test_comm_client pkgmgr_installer_client)
-target_link_libraries(test_comm_client ${test_pkgs_LDFLAGS})
-
-
-add_executable(test_comm_socket
-               test_comm_socket.c)
-target_link_libraries(test_comm_socket comm_socket ${test_pkgs_LDFLAGS})
-set_target_properties(test_comm_socket PROPERTIES SKIP_BUILD_RPATH true)
-
-
-add_executable(test_pkgmgr_installer
-               test_pkgmgr_installer.c)
-target_link_libraries(test_pkgmgr_installer pkgmgr_installer pkgmgr_installer_client ${test_pkgs_LDFLAGS})
-set_target_properties(test_pkgmgr_installer PROPERTIES SKIP_BUILD_RPATH true)
-
diff --git a/comm/test/test_comm_client.c b/comm/test/test_comm_client.c
deleted file mode 100755 (executable)
index c4b9a50..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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 "comm_client.h"
-#include <stdio.h>
-#include <glib.h>
-
-static GMainLoop *mainloop;
-
-void
-stat_cb(void *data, const char *req_id, const char *pkg_type,
-       const char *pkgid, const char *key, const char *val)
-{
-       printf(">>user callback>> Got: %s %s %s %s %s\n", req_id, pkg_type,
-              pkgid, key, val);
-
-       g_main_loop_quit(mainloop);
-}
-
-int main(int argc, char **argv)
-{
-
-       g_type_init();
-       mainloop = g_main_loop_new(NULL, FALSE);
-
-       comm_client *cc = comm_client_new();
-
-       gint ret;
-       ret = comm_client_request(cc, "__test__req_key", COMM_REQ_TO_INSTALLER,
-                                 "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(COMM_STATUS_BROADCAST_ALL, cc, stat_cb, NULL);
-
-       g_main_loop_run(mainloop);
-
-       comm_client_free(cc);
-
-       return 0;
-}
-
diff --git a/comm/test/test_comm_pkg_mgr_server.c b/comm/test/test_comm_pkg_mgr_server.c
deleted file mode 100755 (executable)
index b20636f..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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 "comm_pkg_mgr_server.h"
-#include <glib.h>
-#include <stdio.h>
-
-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)
-{
-       /* TODO: Do your job here */
-       printf(">> in callback >> Got request: %s %d %s %s %s (cookie:%s)\n",
-              req_id, req_type, pkg_type, pkgid, args, cookie);
-}
-
-gboolean queue_job(void *data)
-{
-       /* .i..
-
-       if (no_need_more) {
-               g_main_loop_quit(mainloop);
-               return FALSE;
-
-       */
-       return TRUE;
-}
-
-int main(int argc, char **argv) 
-{
-       g_type_init();
-
-       GMainLoop *mainloop = g_main_loop_new(NULL, FALSE);
-
-       PkgMgrObject *pkg_mgr;
-       pkg_mgr = g_object_new(PKG_MGR_TYPE_OBJECT, NULL);
-
-       pkg_mgr_set_request_callback(pkg_mgr, req_cb, NULL);
-
-       g_timeout_add_seconds(1, queue_job, NULL);
-
-       g_main_loop_run(mainloop);
-
-       /* TODO: add cleanup code */
-
-       return 0;
-}
-
diff --git a/comm/test/test_comm_socket.c b/comm/test/test_comm_socket.c
deleted file mode 100755 (executable)
index 08bd27b..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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 "comm_socket.h"
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-static void __test_comm_socket_create_server(void);
-static void __test_comm_socket_create_server(void)
-{
-       comm_socket *cs;
-       cs = _comm_socket_new();
-
-       char *tmp_file_path = "/tmp/____asjdfjlsdjlfjxcvj";
-       assert(0 == _comm_socket_create_server(cs, tmp_file_path));
-
-       _comm_socket_free(cs);
-}
-
-int main(int argc, char **argv)
-{
-       __test_comm_socket_create_server();
-
-       return 0;
-}
-
diff --git a/comm/test/test_pkgmgr_installer.c b/comm/test/test_pkgmgr_installer.c
deleted file mode 100755 (executable)
index 9557a61..0000000
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * 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 "pkgmgr_installer.h"
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "comm_client.h"
-static int _argc;
-static char **_argv;
-static GMainLoop *mainloop;
-
-static void __test_pi_new_free(void);
-static void __test_pi_receive_request_standard_mode();
-static void __test_pi_send_signal();
-static void __test_pi_receive_request_quiet_mode();
-
-static void __test_pi_new_free(void)
-{
-       pkgmgr_installer *pi = pkgmgr_installer_new();
-       assert(NULL != pi);
-
-       pkgmgr_installer_free(pi);
-}
-
-static void __test_pi_receive_request_standard_mode(void)
-{
-       pkgmgr_installer *pi;
-
-       struct test_data {
-               char *argv[1024];
-               int size_argv;
-               int desired_ret_type;
-               char *desired_pkg_info;
-               char *desired_session_id;
-       };
-
-       /* Test data collection: Add more test here, except -q */
-       struct test_data td[] = {
-               { {"a", "-i", "abc" }, 3, PKGMGR_REQ_INSTALL, "abc", NULL},
-               { {"a", "-i", "ghi", "-k", "key1" }, 5, PKGMGR_REQ_INSTALL,
-                 "ghi", "key1" },
-               { {"a", "-i", "abc", "-k", "key1", "-k", "key2" }, 7,
-                 PKGMGR_REQ_INSTALL, "abc", "key2" },
-               { { NULL }, 0, 0, NULL, NULL }  /* sentinel */
-       };
-
-       /* Run test! */
-       int i = 0;
-       struct test_data *p_td = td + i;
-       while (p_td && p_td->size_argv) {
-
-               printf(">>> %s %d %d %s\n", p_td->argv[0], p_td->size_argv,
-                      p_td->desired_ret_type, p_td->desired_pkg_info);
-
-               pi = pkgmgr_installer_new();
-               assert(NULL != pi);
-
-               assert(0 == pkgmgr_installer_receive_request(
-                                       pi, p_td->size_argv, p_td->argv));
-               assert(p_td->desired_ret_type ==
-                      pkgmgr_installer_get_request_type(pi));
-               assert(pkgmgr_installer_get_request_info(pi));  /* NULL check */
-               assert(!strcmp(p_td->desired_pkg_info,
-                              pkgmgr_installer_get_request_info(pi)));
-               if (p_td->desired_session_id) {
-                       assert(pkgmgr_installer_get_session_id(pi));
-                       assert(!strcmp(p_td->desired_session_id,
-                                      pkgmgr_installer_get_session_id(pi)));
-               } else {
-                       assert(p_td->desired_session_id ==
-                              pkgmgr_installer_get_session_id(pi));
-               }
-               pkgmgr_installer_free(pi);
-
-               /* next */
-               i++;
-               p_td = td + i;
-       }
-}
-
-struct signal_counter {
-       int start;
-       int install_percent;
-       int end;
-};
-
-static gboolean timer_stop_mainloop(void *data)
-{
-       g_main_loop_quit(mainloop);
-       return FALSE;
-}
-
-static void
-get_signal_cb(void *cb_data, const char *req_id, const char *pkg_type,
-             const char *pkgid, const char *key, const char *val)
-{
-       struct signal_counter *counter = (struct signal_counter *)cb_data;
-
-       printf("get_signal_cb() called\n");
-       if (!strcmp("start", key))
-               counter->start += 1;
-       if (!strcmp("install_percent", key))
-               counter->install_percent = atoi(val);
-       if (!strcmp("end", key))
-               counter->end += 1;
-
-       g_main_loop_quit(mainloop);
-}
-
-static gboolean timer_send_signal(void *data)
-{
-       pkgmgr_installer *pi = (pkgmgr_installer *) data;
-       printf("try to send signal\n");
-       assert(0 == pkgmgr_installer_send_signal(pi, "deb", "testpkg", "start",
-                                                "install"));
-       printf("sent signal\n");
-       return FALSE;
-}
-
-static void __test_pi_send_signal(void)
-{
-       pkgmgr_installer *pi;
-       pi = pkgmgr_installer_new();
-       assert(NULL != pi);
-
-       /* receiver */
-       struct signal_counter counter = { 0, };
-       comm_client *cc;
-       cc = comm_client_new();
-       comm_client_set_status_callback(COMM_STATUS_BROADCAST_ALL, cc, get_signal_cb, &counter);
-
-       /* sender */
-       g_timeout_add_seconds(1, timer_send_signal, pi);
-
-       /* Set timeout, and run main loop */
-       g_timeout_add_seconds(5, timer_stop_mainloop, NULL);
-
-       printf("start loop\n");
-       g_main_loop_run(mainloop);
-
-       /* find values */
-       printf("exit loop\n");
-       assert(1 == counter.start);
-
-       comm_client_free(cc);
-
-       pkgmgr_installer_free(pi);
-}
-
-void __test_pi_receive_request_quiet_mode()
-{
-       pkgmgr_installer *pi;
-
-       struct test_data {
-               char *argv[1024];
-               int size_argv;
-               int desired_ret_type;
-               char *desired_pkg_info;
-               char *desired_session_id;
-       };
-
-       /* Test data collection: Add more test here, except -q */
-       struct test_data td[] = {
-               { {"a", "-q", "-i", "abc" }, 4, PKGMGR_REQ_INSTALL, "abc", NULL},
-               { {"a", "-i", "ghi", "-k", "key1", "-q" }, 6,
-                 PKGMGR_REQ_INSTALL, "ghi", "key1"},
-               { {NULL}, 0, 0, NULL, NULL }    /* sentinel */
-       };
-
-       /* Run test! */
-       int i = 0;
-       int r;
-       struct test_data *p_td = td + i;
-       while (p_td && p_td->size_argv) {
-
-               printf(">>> %s %d %d %s\n", p_td->argv[0], p_td->size_argv,
-                      p_td->desired_ret_type, p_td->desired_pkg_info);
-
-               pi = pkgmgr_installer_new();
-               assert(NULL != pi);
-               r = pkgmgr_installer_receive_request(pi, p_td->size_argv,
-                                                    p_td->argv);
-               printf("desired=0, r=%d\n", r);
-               assert(0 == r);
-               assert(p_td->desired_ret_type ==
-                      pkgmgr_installer_get_request_type(pi));
-               assert(pkgmgr_installer_get_request_info(pi));  /* NULL check */
-               assert(!strcmp
-                      (p_td->desired_pkg_info,
-                       pkgmgr_installer_get_request_info(pi)));
-               assert(pkgmgr_installer_is_quiet(pi));
-               if (p_td->desired_session_id) {
-                       assert(pkgmgr_installer_get_session_id(pi));
-                       assert(!strcmp
-                              (p_td->desired_session_id,
-                               pkgmgr_installer_get_session_id(pi)));
-               } else {
-                       assert(p_td->desired_session_id ==
-                              pkgmgr_installer_get_session_id(pi));
-               }
-               pkgmgr_installer_free(pi);
-
-               /* next */
-               i++;
-               p_td = td + i;
-       }
-}
-
-/* Test collection */
-static void __test_pkgmgr_installer(void)
-{
-       __test_pi_new_free();
-       __test_pi_receive_request_standard_mode();
-       __test_pi_send_signal();
-       __test_pi_receive_request_quiet_mode();
-}
-
-/* main function */
-int main(int argc, char **argv)
-{
-       _argc = argc;
-       _argv = argv;
-
-       /* For event loop */
-       g_type_init();
-       mainloop = g_main_loop_new(NULL, FALSE);
-
-       __test_pkgmgr_installer();
-
-       return 0;
-}
-
diff --git a/debian/changelog b/debian/changelog
deleted file mode 100755 (executable)
index 060f11e..0000000
+++ /dev/null
@@ -1,1078 +0,0 @@
-slp-pkgmgr (0.1.122) unstable; urgency=low
-
-  * Applied manifest
-  * Git: slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.122
-
- -- Sewook Park <sewook7.park@samsung.com>  Wed, 25 Jul 2012 19:11:44 +0900
-
-slp-pkgmgr (0.1.115) unstable; urgency=low
-
-  * Fixed bug when backend installer exits with failure
-  * Git: slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.115
-
- -- Sewook Park <sewook7.park@samsung.com>  Mon, 21 May 2012 21:12:04 +0900
-
-slp-pkgmgr (0.1.114) unstable; urgency=low
-
-  * Fixed server hang issue on pressing NO in popup
-  * Git: slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.114
-
- -- Sewook Park <sewook7.park@samsung.com>  Mon, 07 May 2012 15:34:45 +0900
-
-slp-pkgmgr (0.1.113) unstable; urgency=low
-
-  * Implemented multiple queue support
-  * Git: slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.113
-
- -- Sewook Park <sewook7.park@samsung.com>  Fri, 20 Apr 2012 10:51:58 +0900
-
-slp-pkgmgr (0.1.112) unstable; urgency=low
-
-  * Fixed activate/deactivate feature
-  * Git: slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.112
-
- -- Sewook Park <sewook7.park@samsung.com>  Tue, 03 Apr 2012 20:39:45 +0900
-
-slp-pkgmgr (0.1.111) unstable; urgency=low
-
-  * Fixed pkgmgr-install desktop to support rpm
-  * Git: slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.111
-
- -- Sewook Park <sewook7.park@samsung.com>  Fri, 30 Mar 2012 11:50:01 +0900
-
-slp-pkgmgr (0.1.110) unstable; urgency=low
-
-  * Fixed popup UI bug
-  * Git: slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.110
-
- -- Sewook Park <sewook7.park@samsung.com>  Fri, 23 Mar 2012 19:06:13 +0900
-
-slp-pkgmgr (0.1.109) unstable; urgency=low
-
-  * Fixed compile warnings
-  * Git: slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.109
-
- -- Sewook Park <sewook7.park@samsung.com>  Tue, 20 Mar 2012 15:36:02 +0900
-
-slp-pkgmgr (0.1.108) unstable; urgency=low
-
-  * Fixed desktop file
-  * Git: slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.108
-
- -- Sewook Park <sewook7.park@samsung.com>  Fri, 16 Mar 2012 21:35:27 +0900
-
-slp-pkgmgr (0.1.107) unstable; urgency=low
-
-  * Fixed bug for elementary modification
-  * Git: slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.107
-
- -- Sewook Park <sewook7.park@samsung.com>  Thu, 15 Mar 2012 15:04:39 +0900
-
-slp-pkgmgr (0.1.106) unstable; urgency=low
-
-  * Fixed code for elementary 1.0 release
-  * Git: slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.106
-
- -- Sewook Park <sewook7.park@samsung.com>  Tue, 13 Mar 2012 17:52:30 +0900
-
-slp-pkgmgr (0.1.105) unstable; urgency=low
-
-  * Support Appsvc for pkgmgr-install
-  * Git: slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.105
-
- -- Sewook Park <sewook7.park@samsung.com>  Mon, 27 Feb 2012 21:34:10 +0900
-
-slp-pkgmgr (0.1.104) unstable; urgency=low
-
-  * Added clear_user_data API
-  * Git: slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.104
-
- -- Sewook Park <sewook7.park@samsung.com>  Wed, 25 Jan 2012 17:47:26 +0900
-
-slp-pkgmgr (0.1.103) unstable; urgency=low
-
-  * Added Pkgmgr TC and fixed issues
-  * Git: slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.103
-
- -- Sewook Park <sewook7.park@samsung.com>  Mon, 26 Dec 2011 19:06:00 +0900
-
-slp-pkgmgr (0.1.102) unstable; urgency=low
-
-  * Removed README file
-  * Git: slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.102
-
- -- Sewook Park <sewook7.park@samsung.com>  Thu, 22 Dec 2011 20:19:24 +0900
-
-slp-pkgmgr (0.1.101) unstable; urgency=low
-
-  * Fixed pkgmgr_info_new bug
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.101
-
- -- Sewook Park <sewook7.park@samsung.com>  Thu, 22 Dec 2011 17:27:37 +0900
-
-slp-pkgmgr (0.1.100) unstable; urgency=low
-
-  * Fixed package activate/deactivate
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.100
-
- -- Sewook Park <sewook7.park@samsung.com>  Tue, 13 Dec 2011 19:51:00 +0900
-
-slp-pkgmgr (0.1.99) unstable; urgency=low
-
-  * Added ecore_init() due to ecore internal logic change
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.99
-
- -- Sewook Park <sewook7.park@samsung.com>  Fri, 09 Dec 2011 10:17:31 +0900
-
-slp-pkgmgr (0.1.98) unstable; urgency=low
-
-  * Cleanup code
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.98
-
- -- Sewook Park <sewook7.park@samsung.com>  Tue, 06 Dec 2011 16:31:23 +0900
-
-slp-pkgmgr (0.1.97) unstable; urgency=low
-
-  * Updated changelog
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.97
-
- -- Sewook Park <sewook7.park@samsung.com>  Mon, 05 Dec 2011 16:05:30 +0900
-
-slp-pkgmgr (0.1.96) unstable; urgency=low
-
-  * Fix pkgcmd exit code according to the installation result for SDK support
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.96
-
- -- Sewook Park <sewook7.park@samsung.com>  Thu, 24 Nov 2011 15:12:31 +0900
-
-slp-pkgmgr (0.1.95) unstable; urgency=low
-
-  * Fixed gcc warnings, Klockwork issues and regression test issues
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.95
-
- -- Sewook Park <sewook7.park@samsung.com>  Wed, 09 Nov 2011 15:45:40 +0900
-
-slp-pkgmgr (0.1.94) unstable; urgency=low
-
-  * Changed Boilerplate as per the guideline
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.94 
-
- -- Sewook Park <sewook7.park@samsung.com>  Mon, 07 Nov 2011 18:30:37 +0900
-
-slp-pkgmgr (0.1.93) unstable; urgency=low
-
-  * Apply AIL update in pkgmgr
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.93
-
- -- Sewook Park <sewook7.park@samsung.com>  Mon, 31 Oct 2011 15:37:21 +0900
-
-slp-pkgmgr (0.1.92) unstable; urgency=low
-
-  * Fix prevent bug
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.92
-
- -- Sewook Park <sewook7.park@samsung.com>  Wed, 26 Oct 2011 20:54:24 +0900
-
-slp-pkgmgr (0.1.91) unstable; urgency=low
-
-  * Fix package_manager_pkg_detail_info_t
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.91 
-
- -- Sewook Park <sewook7.park@samsung.com>  Thu, 20 Oct 2011 21:26:13 +0900
-
-slp-pkgmgr (0.1.90) unstable; urgency=low
-
-  * Apply localization string
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.90
-
- -- Sewook Park <sewook7.park@samsung.com>  Tue, 18 Oct 2011 17:40:10 +0900
-
-slp-pkgmgr (0.1.89) unstable; urgency=low
-
-  * Add app_size in package_manager_pkg_detail_info_t
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.89
-
- -- Sewook Park <sewook7.park@samsung.com>  Tue, 18 Oct 2011 11:54:56 +0900
-
-slp-pkgmgr (0.1.88) unstable; urgency=low
-
-  * Fix string
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.88
-
- -- Sewook Park <sewook7.park@samsung.com>  Fri, 14 Oct 2011 10:49:17 +0900
-
-slp-pkgmgr (0.1.87) unstable; urgency=low
-
-  * set elm_scale
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.87 
-
- -- Sewook Park <sewook7.park@samsung.com>  Wed, 12 Oct 2011 13:06:20 +0900
-
-slp-pkgmgr (0.1.86) unstable; urgency=low
-
-  * Fix pkgmgr-install inteface to use bundle_import_from_argv()
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.86
-
- -- Sewook Park <sewook7.park@samsung.com>  Fri, 07 Oct 2011 16:31:00 +0900
-
-slp-pkgmgr (0.1.85) unstable; urgency=low
-
-  * Remove unnecessary define
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.85
-
- -- Sewook Park <sewook7.park@samsung.com>  Wed, 05 Oct 2011 15:47:42 +0900
-
-slp-pkgmgr (0.1.84) unstable; urgency=low
-
-  * Terminate application before uninstalling
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.84 
-
- -- Sewook Park <sewook7.park@samsung.com>  Wed, 28 Sep 2011 11:06:58 +0900
-
-slp-pkgmgr (0.1.83) unstable; urgency=low
-
-  * Fixed server bug while creating popup
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.83
-
- -- Sewook Park <sewook7.park@samsung.com>  Fri, 23 Sep 2011 14:36:43 +0900
-
-slp-pkgmgr (0.1.82) unstable; urgency=low
-
-  * Remove old API
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.82
-
- -- Sewook Park <sewook7.park@samsung.com>  Thu, 22 Sep 2011 12:25:55 +0900
-
-slp-pkgmgr (0.1.81) unstable; urgency=low
-
-  * Remove old AIL structure
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.81 
-
- -- Sewook Park <sewook7.park@samsung.com>  Wed, 21 Sep 2011 18:00:00 +0900
-
-slp-pkgmgr (0.1.80) unstable; urgency=low
-
-  * Fix callback unresistering
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.80 
-
- -- Sewook Park <sewook7.park@samsung.com>  Tue, 20 Sep 2011 20:09:45 +0900
-
-slp-pkgmgr (0.1.79) unstable; urgency=low
-
-  * Fix bug - pkgmgr-client/server
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.79 
-
- -- Sewook Park <sewook7.park@samsung.com>  Mon, 19 Sep 2011 19:05:37 +0900
-
-slp-pkgmgr (0.1.78) unstable; urgency=low
-
-  * Fix prevent defects
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.78 
-
- -- Sewook Park <sewook7.park@samsung.com>  Tue, 06 Sep 2011 11:12:54 +0900
-
-slp-pkgmgr (0.1.77) unstable; urgency=low
-
-  * Use name instead of pkg_name on uninstallation
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.77
-
- -- Sewook Park <sewook7.park@samsung.com>  Mon, 05 Sep 2011 16:15:54 +0900
-
-slp-pkgmgr (0.1.76) unstable; urgency=low
-
-  * Fix bug
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.76
-
- -- Sewook Park <sewook7.park@samsung.com>  Mon, 29 Aug 2011 15:17:47 +0900
-
-slp-pkgmgr (0.1.75) unstable; urgency=low
-
-  * Apply new API
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.75 
-
- -- Sewook Park <sewook7.park@samsung.com>  Thu, 25 Aug 2011 21:08:35 +0900
-
-slp-pkgmgr (0.1.74) unstable; urgency=low
-
-  * Fixed Prevent Issues
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.74 
-
- -- Sewook Park <sewook7.park@samsung.com>  Wed, 24 Aug 2011 20:12:30 +0900
-
-slp-pkgmgr (0.1.73) unstable; urgency=low
-
-  * Fix for AIL exception
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.73 
-
- -- Sewook Park <sewook7.park@samsung.com>  Tue, 23 Aug 2011 17:12:30 +0900
-
-slp-pkgmgr (0.1.72) unstable; urgency=low
-
-  * Cleanup code
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.72 
-
- -- Sewook Park <sewook7.park@samsung.com>  Fri, 19 Aug 2011 11:46:33 +0900
-
-slp-pkgmgr (0.1.71) unstable; urgency=low
-
-  * Add info type
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.71 
-
- -- Sewook Park <sewook7.park@samsung.com>  Thu, 18 Aug 2011 18:40:30 +0900
-
-slp-pkgmgr (0.1.70) unstable; urgency=low
-
-  * Add optional_id in package_manager_pkg_detail_info_t
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.70 
-
- -- Sewook Park <sewook7.park@samsung.com>  Wed, 10 Aug 2011 19:18:52 +0900
-
-slp-pkgmgr (0.1.69) unstable; urgency=low
-
-  * Apply new AIL API
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.69 
-
- -- Sewook Park <sewook7.park@samsung.com>  Tue, 09 Aug 2011 14:25:09 +0900
-
-slp-pkgmgr (0.1.68) unstable; urgency=low
-
-  * Apply code cleanup
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.68 
-
- -- Sewook Park <sewook7.park@samsung.com>  Mon, 01 Aug 2011 19:32:38 +0900
-
-slp-pkgmgr (0.1.67) unstable; urgency=low
-
-  * Apply Boilerplate
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.67
-
- -- Sewook Park <sewook7.park@samsung.com>  Wed, 13 Jul 2011 17:33:40 +0900
-
-slp-pkgmgr (0.1.66) unstable; urgency=low
-
-  * Cleanup code 
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.66
-
- -- Sewook Park <sewook7.park@samsung.com>  Tue, 05 Jul 2011 17:59:59 +0900
-
-slp-pkgmgr (0.1.65) unstable; urgency=low
-
-  * Cleanup control file
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.65 
-
- -- Sewook Park <sewook7.park@samsung.com>  Mon, 04 Jul 2011 20:25:20 +0900
-
-slp-pkgmgr (0.1.64) unstable; urgency=low
-
-  * Cleanup code
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.64
-
- -- Sewook Park <sewook7.park@samsung.com>  Tue, 28 Jun 2011 19:40:17 +0900
-
-slp-pkgmgr (0.1.63) unstable; urgency=low
-
-  * Cleanup code
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.63 
-
- -- Sewook Park <sewook7.park@samsung.com>  Fri, 24 Jun 2011 19:09:13 +0900
-
-slp-pkgmgr (0.1.62) unstable; urgency=low
-
-  * Fix prevent defect
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.62 
-
- -- Sewook Park <sewook7.park@samsung.com>  Mon, 20 Jun 2011 14:37:43 +0900
-
-slp-pkgmgr (0.1.61) unstable; urgency=low
-
-  * Change popup type to modal
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.61
-
- -- Sewook Park <sewook7.park@samsung.com>  Mon, 06 Jun 2011 12:59:16 +0900
-
-slp-pkgmgr (0.1.60) unstable; urgency=low
-
-  * Apply ail
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.60 
-
- -- Sewook Park <sewook7.park@samsung.com>  Wed, 18 May 2011 20:25:58 +0900
-
-slp-pkgmgr (0.1.59) unstable; urgency=low
-
-  * Fix build error - CMakeLists.txt
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.59
-
- -- Sewook Park <sewook7.park@samsung.com>  Wed, 18 May 2011 14:31:49 +0900
-
-slp-pkgmgr (0.1.58) unstable; urgency=low
-
-  * Move pkgmgr-tool pkgmgr-install to libpkgmgr-client-0
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.58
-
- -- Sewook Park <sewook7.park@samsung.com>  Tue, 17 May 2011 20:41:15 +0900
-
-slp-pkgmgr (0.1.57) unstable; urgency=low
-
-  * Fix argument handling - to include # character
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.57
-
- -- Sewook Park <sewook7.park@samsung.com>  Mon, 16 May 2011 20:56:26 +0900
-
-slp-pkgmgr (0.1.56) unstable; urgency=low
-
-  * Fix popup problem
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.56
-
- -- Sewook Park <sewook7.park@samsung.com>  Wed, 11 May 2011 16:18:05 +0900
-
-slp-pkgmgr (0.1.55) unstable; urgency=low
-
-  * Fix popup problem
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.55 
-
- -- Sewook Park <sewook7.park@samsung.com>  Wed, 11 May 2011 16:11:00 +0900
-
-slp-pkgmgr (0.1.54) unstable; urgency=low
-
-  * Fix getting type in pkgmgr-client
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.54
-
- -- Sewook Park <sewook7.park@samsung.com>  Mon, 25 Apr 2011 21:26:31 +0900
-
-slp-pkgmgr (0.1.53) unstable; urgency=low
-
-  * Fix bug in pkgmgr-client
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.53 
-
- -- Sewook Park <sewook7.park@samsung.com>  Mon, 18 Apr 2011 18:38:26 +0900
-
-slp-pkgmgr (0.1.52) unstable; urgency=low
-
-  * Fix item name in desktop file: X-SLP-PackageType
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.52
-
- -- Youmin Ha <youmin.ha@samsung.com>  Fri, 15 Apr 2011 10:50:01 +0900
-
-slp-pkgmgr (0.1.51) unstable; urgency=low
-
-  * Read pkg_type from desktop file when uninstall
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.51
-
- -- Youmin Ha <youmin.ha@samsung.com>  Thu, 14 Apr 2011 14:40:41 +0900
-
-slp-pkgmgr (0.1.50) unstable; urgency=low
-
-  * Fix pkgmgr-tool
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.50
-
- -- Sewook Park <sewook7.park@samsung.com>  Mon, 04 Apr 2011 21:35:36 +0900
-
-slp-pkgmgr (0.1.49) unstable; urgency=low
-
-  * Fix build error and popup string
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.49
-
- -- Sewook Park <sewook7.park@samsung.com>  Sat, 02 Apr 2011 17:22:23 +0900
-
-slp-pkgmgr (0.1.48) unstable; urgency=low
-
-  * Change popup handling in pkgmgr
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.48
-
- -- Sewook Park <sewook7.park@samsung.com>  Fri, 01 Apr 2011 17:05:28 +0900
-
-slp-pkgmgr (0.1.47) unstable; urgency=low
-
-  * Add function body for get_license_path()
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.47
-
- -- Youmin Ha <youmin.ha@samsung.com>  Wed, 16 Mar 2011 18:40:02 +0900
-
-slp-pkgmgr (0.1.46) unstable; urgency=low
-
-  * Add api: pkgmgr_installer_get_license_path()
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.46
-
- -- Youmin Ha <youmin.ha@samsung.com>  Mon, 14 Mar 2011 17:15:43 +0900
-
-slp-pkgmgr (0.1.45) unstable; urgency=low
-
-  * Add license parameter on package_manager_install_application_with_type()
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.45
-
- -- Sewook Park <sewook7.park@samsung.com>  Thu, 10 Mar 2011 13:54:27 +0900
-
-slp-pkgmgr (0.1.44) unstable; urgency=low
-
-  * Apply 2sec wait in pkgmgr-install
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.44
-
- -- Youmin Ha <youmin.ha@samsung.com>  Tue, 08 Mar 2011 15:14:10 +0900
-slp-pkgmgr (0.1.43) unstable; urgency=low
-
-  * Fix mime bugs
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.43
-
- -- Youmin Ha <youmin.ha@samsung.com>  Fri, 04 Mar 2011 09:20:23 +0900
-
-slp-pkgmgr (0.1.42) unstable; urgency=low
-
-  * Fix for argument which has white space
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.42 
-
- -- Sewook Park <sewook7.park@samsung.com>  Fri, 04 Mar 2011 01:42:07 +0900
-
-slp-pkgmgr (0.1.41) unstable; urgency=low
-
-  * Fix pkgmgr-server.postinst -exclude updaet-mime-database
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.41 
-
- -- Sewook Park <sewook7.park@samsung.com>  Thu, 03 Mar 2011 23:07:08 +0900
-
-slp-pkgmgr (0.1.40) unstable; urgency=low
-
-  * Fix MAX_PKG_TYPE_LEN to 128
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.40
-
- -- Sewook Park <sewook7.park@samsung.com>  Thu, 03 Mar 2011 21:54:45 +0900
-
-slp-pkgmgr (0.1.39-1) unstable; urgency=low
-
-  * Fix header to pass api review (no code change)
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.39-1
-
- -- Youmin Ha <youmin.ha@samsung.com>  Thu, 03 Mar 2011 20:27:45 +0900
-
-slp-pkgmgr (0.1.39) unstable; urgency=low
-
-  * Support wgt mime type, Fix build error
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.39
-
- -- Youmin Ha <youmin.ha@samsung.com>  Thu, 03 Mar 2011 18:53:17 +0900
-
-slp-pkgmgr (0.1.38) unstable; urgency=low
-
-  * Fix trivial bug
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.38 
-
- -- Sewook Park <sewook7.park@samsung.com>  Thu, 03 Mar 2011 16:45:07 +0900
-
-slp-pkgmgr (0.1.37) unstable; urgency=low
-
-  * Change pkgmgr architecture
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.37
-
- -- Sewook7.park <sewook7.park@samsung.com>  Thu, 03 Mar 2011 15:36:33 +0900
-
-slp-pkgmgr (0.1.36-2) unstable; urgency=low
-
-  * Rollback 
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.36-2 
-
- -- Sewook Park <sewook7.park@samsung.com>  Sat, 26 Feb 2011 16:06:20 +0900
-
-slp-pkgmgr (0.1.36) unstable; urgency=low
-
-  * Add install_with_license API
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.36 
-
- -- Sewook Park <sewook7.park@samsung.com>  Sat, 26 Feb 2011 14:48:31 +0900
-
-slp-pkgmgr (0.1.35) unstable; urgency=low
-
-  * Install pkgmgr-tool into the binary package, to be used with SDK
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.35 
-
- -- Youmin Ha <youmin.ha@samsung.com>  Tue, 22 Feb 2011 16:45:32 +0900
-
-slp-pkgmgr (0.1.34) unstable; urgency=low
-
-  * fix pkgmgr_tool
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.34 
-
- -- Sewook Park <sewook7.park@samsung.com>  Fri, 18 Feb 2011 13:40:52 +0900
-
-slp-pkgmgr (0.1.33) unstable; urgency=low
-
-  * check argument length (Found by prevent)
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.33
-
- -- Sewook Park <sewook7.park@samsung.com>  Wed, 16 Feb 2011 20:17:13 +0900
-
-slp-pkgmgr (0.1.32) unstable; urgency=low
-
-  * Add null check to pkgmgr_server (Found by prevent)
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.32
-
- -- Youmin Ha <youmin.ha@samsung.com>  Wed, 16 Feb 2011 14:36:34 +0900
-
-slp-pkgmgr (0.1.31) unstable; urgency=low
-
-  * pkgmgr_tool fix
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.31
-
- -- Sewook Park <sewook7.park@samsung.com>  Wed, 02 Feb 2011 15:29:27 +0900
-
-slp-pkgmgr (0.1.30) unstable; urgency=low
-
-  * Prevent bug fix
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.30 
-
- -- Sewook Park <sewook7.park@samsung.com>  Wed, 26 Jan 2011 10:24:51 +0900
-
-slp-pkgmgr (0.1.29) unstable; urgency=low
-
-  * fix the return value of comm_client_free()
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.29 
-
- -- Sewook Park <sewook7.park@samsung.com>  Tue, 18 Jan 2011 15:09:56 +0900
-
-slp-pkgmgr (0.1.28) unstable; urgency=low
-
-  * Change pkgmgr structure
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.28
-
- -- Sewook Park <sewook7.park@samsung.com>  Fri, 14 Jan 2011 14:05:22 +0900
-
-slp-pkgmgr (0.1.27-1) unstable; urgency=low
-
-  * upload
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.27-1
-
- -- Youmin Ha <youmin.ha@samsung.com>  Wed, 29 Dec 2010 15:21:11 +0900
-
-slp-pkgmgr (0.1.27) unstable; urgency=low
-
-  * Initialize gerror variable to NULL, to avoid error from
-    g_shell_parse_argv()
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.27 
-
- -- Youmin Ha <youmin.ha@samsung.com>  Wed, 29 Dec 2010 14:45:33 +0900
-
-slp-pkgmgr (0.1.26) unstable; urgency=low
-
-  * fix pkgmgr_tool
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.26 
-
- -- root <sewook7.park@samsung.com>  Tue, 21 Dec 2010 19:50:57 +0900
-
-slp-pkgmgr (0.1.25) unstable; urgency=low
-
-  * fix pkgmgr_client bug - resource free of result_callback
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.25
-
- -- Sewook Park <sewook7.park@samsung.com>  Mon, 20 Dec 2010 21:17:19 +0900
-
-slp-pkgmgr (0.1.24) unstable; urgency=low
-
-  * Apply new dbus-based comm_client library. (Known bugs are fixed)
-    Avoid BS fron opengl, by unsetting ELM_ENGINE environnent variable.
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.24
-
- -- Youmin Ha <youmin.ha@samsung.com>  Sat, 18 Dec 2010 16:44:23 +0900
-
-slp-pkgmgr (0.1.23-2) unstable; urgency=low
-
-  * fix control
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.23-2
-
- -- root <sewook7.park@samsung.com>  Mon, 13 Dec 2010 15:07:17 +0900
-
-slp-pkgmgr (0.1.23-1) unstable; urgency=low
-
-  * add aul on control
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.23-1
-
- -- root <sewook7.park@samsung.com>  Mon, 13 Dec 2010 13:42:50 +0900
-
-slp-pkgmgr (0.1.23) unstable; urgency=low
-
-  * add pkgmgr_client API - package_manager_install_application_with_type()
-  * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.23
-
- -- Sewook Park <sewook7.park@samsung.com>  Fri, 10 Dec 2010 17:14:31 +0900
-
-slp-pkgmgr (0.1.22) unstable; urgency=low
-
-  * fix pkgmgr_client for system package
-  * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.22
-
- -- root <sewook7.park@samsung.com>  Mon, 06 Dec 2010 12:13:00 +0900
-
-slp-pkgmgr (0.1.21) unstable; urgency=low
-
-  * fix bugs in pkgmgr_client
-  * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.21
-
- -- Sewook Park <sewook7.park@samsung.com>  Fri, 03 Dec 2010 17:48:14 +0900
-
-slp-pkgmgr (0.1.20) unstable; urgency=low
-
-  * fix bugs in comm_client
-  * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.20
-
- -- Youmin Ha <youmin.ha@samsung.com>  Fri, 03 Dec 2010 15:13:52 +0900
-
-slp-pkgmgr (0.1.19) unstable; urgency=low
-
-  * fix pkgmgr_client - bug fix, pkg_info
-  * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.19
-
- -- root <sewook7.park@samsung.com>  Wed, 01 Dec 2010 20:04:10 +0900
-
-slp-pkgmgr (0.1.18) unstable; urgency=low
-
-  * NULL check on pkg_name in comm_client_request()
-  * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.18
-
- -- Youmin Ha <youmin.ha@samsung.com>  Wed, 24 Nov 2010 21:28:17 +0900
-
-slp-pkgmgr (0.1.17) unstable; urgency=low
-
-  * fix pkgmgr_tool bug, add LOG_TAG
-  * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.17
-
- -- root <sewook7.park@samsung.com>  Wed, 24 Nov 2010 19:46:41 +0900
-
-slp-pkgmgr (0.1.16) unstable; urgency=low
-
-  * fix pkgmgr-client bug
-  * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.16
-
- -- root <sewook7.park@samsung.com>  Thu, 18 Nov 2010 14:52:42 +0900
-
-slp-pkgmgr (0.1.15) unstable; urgency=low
-
-  * remove pkgmgr_frontend_test, pkgmgr_backend_test
-  * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.15
-
- -- root <sewook7.park@samsung.com>  Fri, 12 Nov 2010 14:15:47 +0900
-
-slp-pkgmgr (0.1.14-2) unstable; urgency=low
-
-  * fix pkgmgr-client log
-  * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.14-2
-
- -- root <sewook7.park@samsung.com>  Thu, 11 Nov 2010 14:02:25 +0900
-
-slp-pkgmgr (0.1.14-1) unstable; urgency=low
-
-  * fix pkgmgr-client
-  * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.14-1
-
- -- root <sewook7.park@samsung.com>  Thu, 11 Nov 2010 11:51:15 +0900
-
-slp-pkgmgr (0.1.14) unstable; urgency=low
-
-  * fix pkgmgr-client
-  * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.14
-
- -- root <sewook7.park@samsung.com>  Wed, 10 Nov 2010 14:29:37 +0900
-
-slp-pkgmgr (0.1.13) unstable; urgency=low
-
-  * add activator facility
-  * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.13
-
- -- Kidong Kim <kd0228.kim@samsung.com>  Wed, 10 Nov 2010 10:39:59 +0900
-
-slp-pkgmgr (0.1.12) unstable; urgency=low
-
-  * fix package dependency
-  * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.12
-
- -- Youmin Ha <youmin.ha@samsung.com>  Wed, 10 Nov 2010 09:13:23 +0900
-
-slp-pkgmgr (0.1.11) unstable; urgency=low
-
-  * re-versioning
-  * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.11
-
- -- Youmin Ha <youmin.ha@samsung.com>  Tue, 09 Nov 2010 18:08:06 +0900
-
-slp-pkgmgr (0.1.10-4) unstable; urgency=low
-
-  * fix shared libs' dependencies
-  * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.10-4 
-
- -- Youmin Ha <youmin.ha@samsung.com>  Tue, 09 Nov 2010 18:03:25 +0900
-
-slp-pkgmgr (0.1.10-3) unstable; urgency=low
-
-  * Fix build error
-  * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.10-3 
-
- -- root <sewook7.park@samsung.com>  Tue, 09 Nov 2010 16:17:42 +0900
-
-slp-pkgmgr (0.1.10-2) unstable; urgency=low
-
-  * Fix pkgmgr-client & pkgmgr-server
-  * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.10-2
-
- -- root <sewook7.park@samsung.com>  Tue, 09 Nov 2010 14:15:58 +0900
-
-slp-pkgmgr (0.1.10-1) unstable; urgency=low
-
-  * Fix pc files
-  * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.10-1
-
- -- Youmin Ha <youmin.ha@samsung.com>  Tue, 09 Nov 2010 11:29:28 +0900
-
-slp-pkgmgr (0.1.10) unstable; urgency=low
-
-  * Free comm_client in libpkgmgr_client.so
-  * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.10
-
- -- root <sewook7.park@samsung.com>  Mon, 08 Nov 2010 20:30:37 +0900
-
-slp-pkgmgr (0.1.9) unstable; urgency=low
-
-  * Make comm* libs to shared libs
-  * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.9
-
- -- Youmin Ha <youmin.ha@samsung.com>  Mon, 08 Nov 2010 15:20:42 +0900
-
-slp-pkgmgr (0.1.8-1) unstable; urgency=low
-
-  * fix PG
-  * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.8-1
-
- -- Youmin Ha <youmin.ha@samsung.com>  Mon, 08 Nov 2010 10:46:06 +0900
-
-slp-pkgmgr (0.1.8) unstable; urgency=low
-
-  * fix client - get_list
-  * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.8
-
- -- root <youmin.ha@samsung.com>  Wed, 03 Nov 2010 12:03:16 +0900
-
-slp-pkgmgr (0.1.7) unstable; urgency=low
-
-  * add listen/broadcast API
-  * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.7
-
- -- Youmin Ha <youmin.ha@samsung.com>  Thu, 28 Oct 2010 17:15:11 +0900
-
-slp-pkgmgr (0.1.6) unstable; urgency=low
-
-  * fix PMS code, which generates argv for backend
-  * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.6
-
- -- Youmin Ha <youmin.ha@samsung.com>  Wed, 27 Oct 2010 19:46:57 +0900
-
-slp-pkgmgr (0.1.5) unstable; urgency=low
-
-  * if PMS_STANDALONE env_var is set, PMS doens't stop.
-  * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.5
-
- -- Youmin Ha <youmin.ha@samsung.com>  Wed, 27 Oct 2010 17:51:03 +0900
-
-slp-pkgmgr (0.1.4) unstable; urgency=low
-
-  * fix auto-activation
-  * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.4
-
- -- Youmin Ha <youmin.ha@samsung.com>  Wed, 27 Oct 2010 17:41:54 +0900
-
-slp-pkgmgr (0.1.3) unstable; urgency=low
-
-  * apply new dbus service/path/interface, fix bug
-  * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.3
-
- -- Youmin Ha <youmin.ha@samsung.com>  Tue, 26 Oct 2010 12:23:54 +0900
-
-slp-pkgmgr (0.1.2-1) unstable; urgency=low
-
-  * fix pc file
-  * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.2-1
-
- -- Youmin Ha <youmin.ha@samsung.com>  Sat, 23 Oct 2010 13:37:57 +0900
-
-slp-pkgmgr (0.1.2) unstable; urgency=low
-
-  * fix bug in pkgmgr-server
-  * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.2
-
- -- Youmin Ha <youmin.ha@samsung.com>  Wed, 20 Oct 2010 16:38:58 +0900
-
-slp-pkgmgr (0.1.1-5) unstable; urgency=low
-
-  * install comm_config.h
-  * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.1-5
-
- -- Youmin Ha <youmin.ha@samsung.com>  Mon, 18 Oct 2010 20:45:10 +0900
-
-slp-pkgmgr (0.1.1-4) unstable; urgency=low
-
-  * Fix build flags
-  * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.1-4
-
- -- Youmin Ha <youmin.ha@samsung.com>  Mon, 18 Oct 2010 20:19:57 +0900
-
-slp-pkgmgr (0.1.1-3) unstable; urgency=low
-
-  * change max pkg name length
-  * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.1-3
-
- -- Kidong Kim <kd0228.kim@samsung.com>  Mon, 18 Oct 2010 19:42:01 +0900
-
-slp-pkgmgr (0.1.1-2) unstable; urgency=low
-
-  * fix wrong version of dependent package
-  * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.1-2
-
- -- Youmin Ha <youmin.ha@samsung.com>  Mon, 18 Oct 2010 19:22:14 +0900
-
-slp-pkgmgr (0.1.1-1) unstable; urgency=low
-
-  * fix build-dependency
-  * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.1-1
-
- -- Youmin Ha <youmin.ha@samsung.com>  Mon, 18 Oct 2010 18:07:37 +0900
-
-slp-pkgmgr (0.1.1) unstable; urgency=low
-
-  * Release first version
-  * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
-  * Tag: slp-pkgmgr_0.1.1
-
- -- Youmin Ha <youmin.ha@samsung.com>  Mon, 18 Oct 2010 18:07:37 +0900
-
-slp-pkgmgr (0.1.0) unstable; urgency=low
-
-  * Initial Release.
-
- -- Kidong Kim <kd0228.kim@samsung.com>  Thu, 16 Sep 2010 09:31:11 +0900
diff --git a/debian/compat b/debian/compat
deleted file mode 100644 (file)
index 7ed6ff8..0000000
+++ /dev/null
@@ -1 +0,0 @@
-5
diff --git a/debian/control b/debian/control
deleted file mode 100755 (executable)
index 7a32791..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-Source: slp-pkgmgr
-Priority: extra
-Maintainer: Sewook Park <sewook7.park@samsung.com>, Youmin Ha <youmin.ha@samsung.com>
-Build-Depends: debhelper (>= 5), autotools-dev, libsecurity-server-client-dev, libdbus-1-dev, libdbus-glib-1-dev, libecore-dev, dlog-dev, libaul-1-dev, libail-0-dev, libappcore-efl-dev, libxml2-dev
-Standards-Version: 3.7.2
-Section: base
-
-Package: libpkgmgr-client-dev
-Section: libdevel
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends},  libpkgmgr-client-0 (= ${Source-Version}), libecore-dev, libsecurity-server-client-dev,  libaul-1-dev, libail-0-dev, libpkgmgr-types-dev(>= ${Source-Version}), libpkgmgr-installer-dev (>= ${Source-Version}), libpkgmgr-parser-dev (>= ${Source-Version})
-Description: Package Manager client library develpoment package
-
-Package: libpkgmgr-client-0
-Section: libs
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, libpkgmgr-installer (>= ${Source-Version}), libpkgmgr-parser (>= ${Source-Version}), pkgmgr-server (>= ${Source-Version})
-Description: Packager Manager client library package
-
-Package: pkgmgr-server
-Section: base
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, libpkgmgr-installer (>= ${Source-Version})
-Description: Package Manager server
-
-Package: pkgmgr-server-dbg
-Section: debug
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, pkgmgr-server
-Description: debug package of Package Manager source package
-
-Package: libpkgmgr-installer
-Section: libs
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}
-Description: Library for installer backend.
-
-Package: libpkgmgr-installer-dev
-Section: libdevel
-Architecture: any
-Depends: libpkgmgr-installer (= ${Source-Version}), 
-Description: Dev package for libpkgmgr-installer
-
-Package: libpkgmgr-parser
-Section: libs
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}
-Description: Parser Library for installer backend.
-
-Package: libpkgmgr-parser-dev
-Section: libdevel
-Architecture: any
-Depends: libpkgmgr-parser (= ${Source-Version}),
-Description: Dev package for libpkgmgr-parser
-
-Package: libpkgmgr-types-dev
-Section: libdevel
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}
-Description: Package Manager client types develpoment package
diff --git a/debian/docs b/debian/docs
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/debian/libpkgmgr-client-0.install.in b/debian/libpkgmgr-client-0.install.in
deleted file mode 100755 (executable)
index e2ebbc7..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-@PREFIX@/lib/libpkgmgr-client.so*
-@PREFIX@/etc/package-manager/pkg_path.conf
-@PREFIX@/bin/pkgcmd
-@PREFIX@/bin/pkgmgr-install
-@PREFIX@/share/applications/*.desktop
-@PREFIX@/share/mime/packages/*.xml
diff --git a/debian/libpkgmgr-client-0.postinst b/debian/libpkgmgr-client-0.postinst
deleted file mode 100755 (executable)
index ce2df9a..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-
-#if [ ${USER} == "root" ]
-#then
-#      chown root:root /usr/lib/libss-client.so
-#fi
-
-mkdir -p /usr/etc/package-manager/frontend
-mkdir -p /usr/etc/package-manager/backend
-
-# For pkgmgr-install:
-# Update mime database to support package mime types
-update-mime-database /usr/share/mime
-
-echo "Done." > /dev/null
diff --git a/debian/libpkgmgr-client-dev.install.in b/debian/libpkgmgr-client-dev.install.in
deleted file mode 100644 (file)
index f4fa680..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-@PREFIX@/include/package-manager.h
-@PREFIX@/lib/pkgconfig/pkgmgr.pc
diff --git a/debian/libpkgmgr-installer-dev.install.in b/debian/libpkgmgr-installer-dev.install.in
deleted file mode 100755 (executable)
index 66cdf89..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-@PREFIX@/include/pkgmgr/pkgmgr_installer.h
-@PREFIX@/lib/pkgconfig/pkgmgr-installer-client.pc
-@PREFIX@/lib/pkgconfig/pkgmgr-installer-status-broadcast-server.pc
-@PREFIX@/lib/pkgconfig/pkgmgr-installer.pc
diff --git a/debian/libpkgmgr-installer.install.in b/debian/libpkgmgr-installer.install.in
deleted file mode 100755 (executable)
index 6023b00..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-@PREFIX@/lib/libpkgmgr_installer_client.so*
-@PREFIX@/lib/libpkgmgr_installer_status_broadcast_server.so*
-@PREFIX@/lib/libpkgmgr_installer.so*
diff --git a/debian/libpkgmgr-types-dev.install.in b/debian/libpkgmgr-types-dev.install.in
deleted file mode 100755 (executable)
index b936405..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-@PREFIX@/include/package-manager-types.h
-@PREFIX@/include/package-manager-plugin.h
-@PREFIX@/lib/pkgconfig/pkgmgr-types.pc
diff --git a/debian/pkgmgr-server.install.in b/debian/pkgmgr-server.install.in
deleted file mode 100755 (executable)
index bb69e3e..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-@PREFIX@/bin/pkgmgr-server
-@PREFIX@/share/dbus-1/services/org.tizen.pkgmgr.service
-@PREFIX@/share/locale/*
diff --git a/debian/pkgmgr-server.postinst b/debian/pkgmgr-server.postinst
deleted file mode 100755 (executable)
index aa57a4a..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/sh
-
-#if [ ${USER} == "root" ]
-#then
-#      chown root:root /usr/bin/ss-server
-#      chown root:root /etc/rc.d/init.d/ss-serverd
-#fi
-
-#chmod 700 /usr/bin/ss-server
-#chmod 755 /etc/rc.d/init.d/ss-serverd
-mkdir -p /usr/etc/package-manager/server
-
-echo "Done." > /dev/null
diff --git a/debian/rules b/debian/rules
deleted file mode 100755 (executable)
index add47c7..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-#!/usr/bin/make -f
-# -*- makefile -*-
-# Sample debian/rules that uses debhelper.
-# This file was originally written by Joey Hess and Craig Small.
-# As a special exception, when this file is copied by dh-make into a
-# dh-make output file, you may use that output file without restriction.
-# This special exception was added by Craig Small in version 0.37 of dh-make.
-
-# Uncomment this to turn on verbose mode.
-#export DH_VERBOSE=1
-
-BUILDDIR = $(CURDIR)/cmake_tmp
-
-CFLAGS ?= -Wall -g
-CXXFLAGS ?=  -Wall -g
-LDFLAGS ?= 
-PREFIX ?= /usr
-DATADIR ?= /opt
-
-ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
-       CFLAGS += -O0
-       CXXFLAGS += -O0
-else
-       CFLAGS += -O2
-       CXXFLAGS += -O2
-endif
-
-LDFLAGS += -Wl,--rpath=$(PREFIX)/lib -Wl,--as-needed
-
-configure: configure-stamp
-configure-stamp:
-       dh_testdir
-       # Add here commands to configure the package.
-       mkdir -p $(BUILDDIR)    
-       cd $(BUILDDIR) && CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" cmake .. -DCMAKE_INSTALL_PREFIX=$(PREFIX)
-
-       touch configure-stamp
-
-build: build-stamp
-
-build-stamp: configure-stamp 
-       dh_testdir
-# Add here commands to compile the package. 
-       cd $(BUILDDIR) && $(MAKE)
-
-       #docbook-to-man debian/wavplayer.sgml > wavplayer.1
-
-       for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
-               cat $$f > $${f%.in}; \
-               sed -i -e "s#@PREFIX@#$(PREFIX)#g" $${f%.in}; \
-               sed -i -e "s#@DATADIR@#$(DATADIR)#g" $${f%.in}; \
-       done
-
-
-       touch $@
-
-clean:
-       dh_testdir
-       dh_testroot
-       rm -f build-stamp configure-stamp
-
-       # Add here commands to clean up after the build process.
-       -$(MAKE) clean
-       rm -rf CMakeCache.txt
-       rm -rf CMakeFiles
-       rm -rf cmake_install.cmake
-       rm -rf Makefile
-       rm -rf install_manifest.txt
-       rm -rf *.so
-       rm -rf *.pc
-
-       rm -rf $(BUILDDIR)
-
-       for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
-               rm -f $${f%.in}; \
-       done
-
-       dh_clean
-
-install: build
-       dh_testdir
-       dh_testroot
-       dh_clean -k 
-       dh_installdirs
-
-       # Add here commands to install the package into debian/wavplayer.
-       cd $(BUILDDIR) && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
-#      mkdir -p $(CURDIR)/debian/tmp/etc/rc.d/rc3.d/
-#      ln -s ../init.d/ss-serverd $(CURDIR)/debian/tmp/etc/rc.d/rc3.d/S40ss-server
-
-
-# Build architecture-independent files here.
-binary-indep: build install
-# We have nothing to do by default.
-
-# Build architecture-dependent files here.
-binary-arch: build install
-       dh_testdir
-       dh_testroot
-       dh_installchangelogs 
-       dh_installdocs
-       dh_installexamples
-       dh_install --sourcedir=debian/tmp
-#      dh_installmenu
-#      dh_installdebconf       
-#      dh_installlogrotate
-#      dh_installemacsen
-#      dh_installpam
-#      dh_installmime
-#      dh_python
-#      dh_installinit
-#      dh_installcron
-#      dh_installinfo
-       dh_installman
-       dh_link
-#      dh_strip
-       dh_strip --dbg-package=pkgmgr-server-dbg
-       dh_compress
-       dh_fixperms
-#      dh_perl
-       dh_makeshlibs
-       dh_installdeb
-       dh_shlibdeps
-       dh_gencontrol
-       dh_md5sums
-       dh_builddeb
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install configure
diff --git a/include/SLP_package_manager_PG.h b/include/SLP_package_manager_PG.h
deleted file mode 100755 (executable)
index 9f476a5..0000000
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- * 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.
- *
- */
-
-
-
-
-
-/**
-
- *
- * @ingroup   SLP_PG
- * @defgroup   PackageManagerClient
-
-
-@par package manager Programming Guide
-
-<h1 class="pg"> Introduction</h1>
-<h2 class="pg"> Purpose of this document</h2>
-The purpose of this document is to describe how applications can usepackage manager APIs.\n
-This document gives only programming guidelines to application engineers.
-
-<h2 class="pg"> Scope</h2>
-The scope of this document is limited to Samsung platform package manager API usage.
-
-<h1 class="pg"> Architecture</h1>
-<h2 class="pg"> Architecture overview</h2>
-package manager is responsible for installing / uninstalling / activating application. It also support getting application list API \n
-
-Dbus is used for communication between frontend and package-server / package-server and client library..\n
-Each type of packages have been implemented and these are used for each type of operation.
-
-@image html high-level.png "High-Level Architure"
-
-<h2 class="pg"> SLP Features</h2>
-package manager has the following features:\n
-
- - Install /Uninstall /Activate Application (Primitive APIs)
-       - It can install/uninstall an application
-       - It can activate/deactivate application.
-
- - Application List
-       - It provides the list of applications that are installed.
-       - It provides the API to free the list.
-
- - Listen / Broadcast status
-       - It can listen the status broadcasted by other application.
-       - It can broadcast the status to other application.
-
-<h1 class="pg"> package manager API descriptions</h1>
-<b> SEE API manual </b>
-
-<h1 class="pg"> package manager features with sample code</h1>
-<h2 class="pg"> Install /Uninstall /Activate an application</h2>
-
-Client application
-- Install request with return callback function
-
-@code
-// 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)
-{
-       pkgmgr_client *pc = (pkgmgr_client *)data;
-       
-       if( strcmp(key, "end") == 0) {
-               pkgmgr_client_free(pc);
-               exit(0);
-       }
-}
-
-void install_func()
-{      
-       int result = 0;
-       pkgmgr_client *pc = NULL;
-
-       pc = pkgmgr_client_new(PC_REQUEST);
-       if(pc == NULL) {
-               printf("pc is NULL\n");
-               return -1;
-       }
-       
-       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;
-       }
-
-}
-@endcode
-
-
-- Uninstall request with return callback function
-
-@code
-// the package type is "deb", package name is "org.tizen.hello"
-#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)
-{      
-       pkgmgr_client *pc = (pkgmgr_client *)data;
-       
-       if( strcmp(key, "end") == 0) {
-               pkgmgr_client_free(pc);
-               exit(0);
-       }
-}
-
-void uninstall_func()
-{      
-       int result = 0;
-       pkgmgr_client *pc = NULL;
-
-       pc = pkgmgr_client_new(PC_REQUEST);
-       if(pc == NULL) {
-               printf("pc is NULL\n");
-               return -1;
-       }
-       
-       result = pkgmgr_client_uninstall(pc, "deb", des, "org.tizen.hello", PM_DEFAULT, return_cb, pc);
-       if(result < 0) {
-               fprintf(stderr, "Uninstall failed! %d\n", result);
-               return -1;
-       }
-
-}
-@endcode
-
-
-- Activate request with return callback function
-
-@code
-// the package type is "deb", package name is "org.tizen.hello"
-#include <package-manager.h>
-
-
-void activate_func()
-{
-       int result = 0;
-       pkgmgr_client *pc = NULL;
-
-       pc = pkgmgr_client_new(PC_REQUEST);
-       if(pc == NULL) {
-               printf("pc is NULL\n");
-               return -1;
-       }
-       
-       result = pkgmgr_client_activate(pc, "deb", "org.tizen.hello");
-       if(result < 0) {
-               fprintf(stderr, "Activation failed! %d\n", result);
-               return -1;
-       }
-
-       pkgmgr_client_free(pc);
-
-}
-@endcode
-
-
-
-<h2 class="pg"> Get Installed Application List </h2>
-
-- Get/free application list
-- This package manager function is used to get the list of all installed applications which can be removed.
-
-@code
-#include <package-manager.h>
-
-static int __iter_fn(const char* pkg_type, const char* pkg_name, const char* version, void *data)
-{
-        printf("pkg_type %s, pkg_name %s, version %s\n", pkg_type, pkg_name, version);
-
-        return 0;
-}
-
-void getlist_func()
-{      
-       pkgmgr_get_pkg_list(__iter_fn, NULL);
-}
-@endcode
-
-
-
-<h2 class="pg"> Listen and broadcast the status </h2>
-
-- Listen / broadcast the status
-- This package manager function is used to listen the status broadcasted by other application.
-
-@code
-#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)
-{      
-       pkgmgr_client *pc = (pkgmgr_client *)data;
-       
-       if( strcmp(key, "end") == 0) {
-               pkgmgr_client_free(pc);
-               exit(0);
-       }
-}
-
-void listen_func()
-{      
-       int result = 0;
-       pkgmgr_client *pc = NULL;
-
-       pc = pkgmgr_client_new(PC_LISTENING);
-       if(pc == NULL) {
-               printf("pc is NULL\n");
-               return -1;
-       }
-       
-       result = pkgmgr_client_listen_status(pc, return_cb, pc);
-       if(result < 0)
-       {
-               fprintf(stderr, "status listen failed!\n");
-               return -1;
-       }
-}
-@endcode
-
-
-- This package manager function is used to listen the status broadcasted by other application.
-
-@code
-// the package type is "deb", package name is "org.tizen.hello", key is "key_string", val is "val_string"
-#include <package-manager.h>
-
-void broadcast_func()
-{      
-       int result = 0;
-       pkgmgr_client *pc = NULL;
-
-       pc= pkgmgr_client_new(PC_BROADCAST);
-       if(pc == NULL) {
-               printf("pc is NULL\n");
-               return -1;
-       }
-       
-       int result = pkgmgr_client_broadcast_status(pc, "deb", "org.tizen.hello", "key_string", "val_string");
-       if(result < 0) {
-               fprintf(stderr, "status broadcast failed!\n");
-               return -1;
-       }
-               
-       pkgmgr_client_free(pc);
-}
-@endcode
-
-
-*/
-
-/**
-@}
-*/
-
-
diff --git a/include/junk-manager.h b/include/junk-manager.h
deleted file mode 100644 (file)
index a19322f..0000000
+++ /dev/null
@@ -1,287 +0,0 @@
-/*
- * 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__
index 8a0681f..353a3a2 100644 (file)
@@ -73,12 +73,13 @@ time_t _get_info_time(const char *key,
                      pkg_detail_info);
 
 void _app_str_trim(char *input);
-char *_get_backend_path(const char *input_path);
+char *_get_backend_path(const char *pkgid);
 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);
+char *_get_backend_from_zip(const char *zip_name);
 
 #endif                         /* __PKG_MANAGER_INTERNAL_H__ */
diff --git a/include/package-manager-zone.h b/include/package-manager-zone.h
new file mode 120000 (symlink)
index 0000000..28c5b24
--- /dev/null
@@ -0,0 +1 @@
+../client/include/package-manager-zone.h
\ No newline at end of file
diff --git a/installers/CMakeLists.txt b/installers/CMakeLists.txt
deleted file mode 100755 (executable)
index 71dd46f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-add_subdirectory(sample)
diff --git a/installers/sample/CMakeLists.txt b/installers/sample/CMakeLists.txt
deleted file mode 100755 (executable)
index 334be60..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-include(FindPkgConfig)
-pkg_check_modules(parser_pkgs REQUIRED dlog libxml-2.0)
-
-foreach(flag ${parser_pkgs_CFLAGS})
-        set(parser_pkgs_CFLAGS_str "${parser_pkgs_CFLAGS_str} ${flag}")
-endforeach()
-
-add_executable(pkgmgr_backend_sample
-       sample_backend.c)
-target_link_libraries(pkgmgr_backend_sample pkgmgr_installer)
-
-add_library(pkgmgr_backend_lib_sample SHARED
-       sample_backendlib.c)
-
-add_library(pkgmgr_parser_lib_sample SHARED
-       sample_parserlib.c)
-set_target_properties(pkgmgr_parser_lib_sample PROPERTIES COMPILE_FLAGS "${parser_pkgs_CFLAGS_str}")
-target_link_libraries(pkgmgr_parser_lib_sample ${parser_pkgs_LDFLAGS})
-
-install(TARGETS pkgmgr_backend_sample
-       DESTINATION bin
-       PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE)
-
-install(TARGETS pkgmgr_backend_lib_sample 
-       DESTINATION lib 
-       COMPONENT RuntimeLibraries 
-       PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE)
-
-install(TARGETS pkgmgr_parser_lib_sample
-       DESTINATION lib
-       COMPONENT RuntimeLibraries
-       PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE)
diff --git a/installers/sample/sample_backend.c b/installers/sample/sample_backend.c
deleted file mode 100755 (executable)
index 7acd167..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * 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.
- *
- */
-
-
-
-
-
-/* sample_backend.c
- * test package
- */
-
-
-/* Pkgmgr installer headers */
-#include "pkgmgr_installer.h"
-
-/* GUI headers */
-
-/* glibc headers */
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-
-static int __confirm_ui(void *data, char *msg);
-static int __install_package(const char *pkg_file_path);
-static int __uninstall_package(const char *pkgid);
-static int __recover_package_system(void);
-
-static pkgmgr_installer *_pi;
-
-static int __confirm_ui(void *data, char *msg)
-{
-       /* Show confirm ui */
-
-       return 1;
-}
-
-static int __install_package(const char *pkg_file_path)
-{
-       if (__confirm_ui(NULL, "Install?")) {
-               /* Install package, and send signal */
-
-       }
-
-       int ret = 0;
-       ret = pkgmgr_installer_send_signal(_pi, "sample", "abc", "end", "ok");
-
-       return ret;
-}
-
-static int __uninstall_package(const char *pkgid)
-{
-       return 0;
-}
-
-static int __clear_package(const char *pkgid)
-{
-       return 0;
-}
-
-static int __recover_package_system(void)
-{
-       return 0;
-}
-
-int main(int argc, char **argv)
-{
-       int ret = 0;
-       pkgmgr_installer *pi = pkgmgr_installer_new();
-
-       _pi = pi;
-
-       pkgmgr_installer_receive_request(pi, argc, argv);
-
-       int req_type = pkgmgr_installer_get_request_type(pi);
-       if (PKGMGR_REQ_INVALID >= req_type)
-               return EINVAL;
-
-       const char *pkg_info = pkgmgr_installer_get_request_info(pi);
-
-       switch (req_type) {
-       case PKGMGR_REQ_INSTALL:
-               ret = __install_package(pkg_info);
-               break;
-       case PKGMGR_REQ_UNINSTALL:
-               ret = __uninstall_package(pkg_info);
-               break;
-       case PKGMGR_REQ_CLEAR:
-               ret = __clear_package(pkg_info);
-               break;
-       case PKGMGR_REQ_RECOVER:
-               ret = __recover_package_system();
-               break;
-       default:
-               ret = EINVAL;
-       }
-
-       return ret;
-}
-
diff --git a/installers/sample/sample_backendlib.c b/installers/sample/sample_backendlib.c
deleted file mode 100755 (executable)
index be1243a..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * 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.
- *
- */
-
-
-
-
-
-/* sample_backendlib.c
- * test package
- */
-
-#include <stdio.h>
-#include <string.h>
-#include "package-manager-plugin.h"
-
-static void pkg_native_plugin_on_unload(void);
-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 *pkgid,
-                                         package_manager_pkg_detail_info_t *
-                                         pkg_detail_info);
-static int pkg_plugin_get_app_detail_info_from_package(const char *pkg_path,
-                                      package_manager_pkg_detail_info_t
-                                      *pkg_detail_info);
-
-static void pkg_native_plugin_on_unload(void)
-{
-       printf("pkg_native_plugin_unload() is called\n");
-}
-
-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_installed_apps_list(const char *category,
-                                             const char *option,
-                                             package_manager_pkg_info_t **
-                                             list, int *count)
-{
-       printf("pkg_plugin_get_installed_apps_list() is called\n");
-
-       return 0;
-}
-
-static int pkg_plugin_get_app_detail_info(const char *pkgid,
-                                         package_manager_pkg_detail_info_t *
-                                         pkg_detail_info)
-{
-       printf("pkg_plugin_get_app_detail_info() is called\n");
-
-       return 0;
-}
-
-static int pkg_plugin_get_app_detail_info_from_package(const char *pkg_path,
-                                      package_manager_pkg_detail_info_t
-                                      *pkg_detail_info)
-{
-       printf("pkg_plugin_get_app_detail_info_from_package() is called\n");
-
-       return 0;
-}
-
-__attribute__ ((visibility("default")))
-int pkg_plugin_on_load(pkg_plugin_set *set)
-{
-       if (set == NULL) {
-               return -1;
-       }
-
-       memset(set, 0x00, sizeof(pkg_plugin_set));
-
-       set->plugin_on_unload = pkg_native_plugin_on_unload;
-       set->pkg_is_installed = pkg_plugin_app_is_installed;
-       set->get_installed_pkg_list = pkg_plugin_get_installed_apps_list;
-       set->get_pkg_detail_info = pkg_plugin_get_app_detail_info;
-       set->get_pkg_detail_info_from_package =
-           pkg_plugin_get_app_detail_info_from_package;
-
-       return 0;
-}
-
diff --git a/installers/sample/sample_parserlib.c b/installers/sample/sample_parserlib.c
deleted file mode 100755 (executable)
index 82a2a74..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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.
- *
- */
-
-
-
-
-
-/* sample_parserlib.c
- * test package
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <libxml/xmlreader.h>
-
-/* debug output */
-#include <dlog.h>
-#undef LOG_TAG
-#define LOG_TAG "PKGMGR_PARSER"
-
-#define DBGE(fmt, arg...) LOGE("[%s,%d] "fmt, __FUNCTION__, __LINE__, ##arg)
-#define DBGI(fmt, arg...) LOGD("[%s,%d] "fmt, __FUNCTION__, __LINE__, ##arg)
-
-
-static void
-print_element_names(xmlNode * a_node)
-{
-    xmlNode *cur_node = NULL;
-
-    for (cur_node = a_node; cur_node; cur_node = cur_node->next) {
-        if (cur_node->type == XML_ELEMENT_NODE) {
-            DBGI("node type: Element, name: %s\n", cur_node->name);
-        }
-
-        print_element_names(cur_node->children);
-    }
-}
-
-
-__attribute__ ((visibility("default")))
-int PKGMGR_PARSER_PLUGIN_INSTALL(xmlDocPtr docPtr)
-{
-       xmlNode *root_element = NULL;
-
-       xmlTextReaderPtr reader = xmlReaderWalker(docPtr);
-       if(reader != NULL) {
-               int ret = xmlTextReaderRead(reader);
-               while(ret == 1) {
-                       ret = xmlTextReaderRead(reader);
-               }
-               xmlFreeTextReader(reader);
-
-               if(ret != 0) {
-                       DBGE("failed to parse");
-               }
-       }
-
-       /*Get the root element node */
-       root_element = xmlFirstElementChild(xmlDocGetRootElement(docPtr));
-
-       print_element_names(root_element);
-
-       return 0;
-}
-
diff --git a/junkmgr.pc.in b/junkmgr.pc.in
deleted file mode 100644 (file)
index c9157b6..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# 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}
index c10244b..80b4498 100755 (executable)
@@ -5,11 +5,7 @@ Release:    1
 Group:      System/Libraries
 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)
@@ -18,21 +14,27 @@ BuildRequires:  pkgconfig(dbus-1)
 BuildRequires:  pkgconfig(dbus-glib-1)
 BuildRequires:  pkgconfig(dlog)
 BuildRequires:  pkgconfig(bundle)
-BuildRequires:  pkgconfig(appcore-efl)
 BuildRequires:  pkgconfig(pkgmgr-info)
 BuildRequires:  pkgconfig(iniparser)
 BuildRequires:  pkgconfig(minizip)
 BuildRequires:  pkgconfig(xdgmime)
+BuildRequires:  pkgconfig(vasum)
+BuildRequires:  pkgconfig(db-util)
+BuildRequires:  pkgconfig(vconf)
 BuildRequires:  pkgmgr-info-parser-devel
-BuildRequires:  pkgmgr-info-parser
-BuildRequires:  python-xml
-BuildRequires:  tizen-locale
-BuildRequires:  libfile-devel
+
+%define appfw_feature_expansion_pkg_install 1
+%define appfw_feature_delta_update 1
+%define appfw_feature_drm_enable 1
+%define appfw_feature_mount_install 0
+
+%if 0%{?appfw_feature_drm_enable}
+BuildRequires:  pkgconfig(drm-service-core-tizen)
+%endif
 
 %description
 Packager Manager client library package for packaging
 
-Requires(post): ail
 Requires(post): pkgmgr-info
 
 %package client
@@ -41,7 +43,6 @@ Group:      TO_BE/FILLED_IN
 Requires:   %{name} = %{version}-%{release}
 Requires(post): /sbin/ldconfig
 Requires(postun): /sbin/ldconfig
-Requires: shared-mime-info
 Requires(post): pkgmgr
 
 %description client
@@ -55,15 +56,6 @@ Requires:   %{name} = %{version}-%{release}
 %description client-devel
 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
-Package Manager server for packaging
-
 %package installer
 Summary:    Library for installer frontend/backend.
 Group:      TO_BE/FILLED_IN
@@ -95,15 +87,43 @@ Package Manager client types develpoment package for packaging
 %prep
 %setup -q
 
+%build
 %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}
+%if 0%{?appfw_feature_expansion_pkg_install}
+_EXPANSION_PKG_INSTALL=ON
+%else
+_EXPANSION_PKG_INSTALL=OFF
+%endif
 
-%build
+%if 0%{?appfw_feature_delta_update}
+_DELTA_UPDATE=ON
+%else
+_DELTA_UPDATE=OFF
+%endif
+
+%if 0%{?appfw_feature_drm_enable}
+_DRM_ENABLE=ON
+%else
+_DRM_ENABLE=OFF
+%endif
+
+%if 0%{?appfw_feature_mount_install}
+_MOUNT_INSTALL=ON
+%else
+_MOUNT_INSTALL=OFF
+%endif
+
+
+cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \
+               -D_APPFW_FEATURE_DRM_ENABLE:BOOL=${_DRM_ENABLE} \
+               -D_APPFW_FEATURE_EXPANSION_PKG_INSTALL:BOOL=${_EXPANSION_PKG_INSTALL} \
+               -D_APPFW_FEATURE_DELTA_UPDATE:BOOL=${_DELTA_UPDATE} \
+               -D_APPFW_FEATURE_MOUNT_INSTALL:BOOL=${_MOUNT_INSTALL}
 
 make %{?jobs:-j%jobs}
 
@@ -115,89 +135,22 @@ 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
 
+%post client
 /sbin/ldconfig
-mkdir -p /usr/etc/package-manager/server
 
-%post client -p /sbin/ldconfig
+%posttrans client
+chsmack -a '_' /usr/etc/package-manager/pkg_path.conf
 
 %postun client -p /sbin/ldconfig
 
@@ -208,33 +161,12 @@ mkdir -p /usr/etc/package-manager/server
 %files
 %manifest pkgmgr.manifest
 %defattr(-,root,root,-)
-%{_bindir}/pkgcmd
-%{_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
+%{_includedir}/package-manager-debug.h
+%{_includedir}/package-manager-internal.h
+%{_includedir}/pkgmgr/comm_pkg_mgr_server.h
+%{_includedir}/pkgmgr/comm_config.h
 %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
@@ -247,25 +179,17 @@ mkdir -p /usr/etc/package-manager/server
 %files client-devel
 %defattr(-,root,root,-)
 %{_includedir}/package-manager.h
+%{_includedir}/package-manager-zone.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.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.*
+%{_libdir}/libpkgmgr_installer_pkg_mgr_server.so.*
 /usr/share/license/%{name}-installer
 
 %files installer-devel
@@ -274,9 +198,11 @@ mkdir -p /usr/etc/package-manager/server
 %{_libdir}/pkgconfig/pkgmgr-installer-status-broadcast-server.pc
 %{_libdir}/pkgconfig/pkgmgr-installer.pc
 %{_libdir}/pkgconfig/pkgmgr-installer-client.pc
+%{_libdir}/pkgconfig/pkgmgr-installer-pkg-mgr-server.pc
 %{_libdir}/libpkgmgr_installer.so
 %{_libdir}/libpkgmgr_installer_client.so
 %{_libdir}/libpkgmgr_installer_status_broadcast_server.so
+%{_libdir}/libpkgmgr_installer_pkg_mgr_server.so
 
 
 %files types-devel
diff --git a/packaging/pkgmgr_recovery.service b/packaging/pkgmgr_recovery.service
deleted file mode 100644 (file)
index 9ef62f5..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-[Unit]
-Description=pkgmgr recovery
-Before=launchpad-preload.service
-
-[Service]
-Type=oneshot
-ExecStart=/usr/etc/package-manager/pkg_recovery.sh
-
-[Install]
-WantedBy=multi-user.target
old mode 100644 (file)
new mode 100755 (executable)
index 5424d2a..3fb26fc
@@ -12,5 +12,7 @@
                 <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="_"/>
+               <filesystem path="/usr/lib/libpkgmgr_installer_pkg_mgr_server.so.0" label="_"/>
+               <filesystem path="/usr/lib/libpkgmgr_installer_pkg_mgr_server.so.0.1.0" label="_"/>
         </assign>
 </manifest>
diff --git a/pkgmgr-parser.manifest b/pkgmgr-parser.manifest
deleted file mode 100644 (file)
index ec7caa6..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-<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>
diff --git a/pkgmgr-server.manifest b/pkgmgr-server.manifest
deleted file mode 100644 (file)
index 38baf0c..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<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>
diff --git a/pkgmgr-soft-reset-ui.sh.in b/pkgmgr-soft-reset-ui.sh.in
deleted file mode 100644 (file)
index d432508..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-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 "--------------------------------------"
index 4426f5c..230b7f9 100755 (executable)
@@ -4,20 +4,38 @@
                <provide>
                        <label name="pkgmgr::svc"/>
                        <label name="pkgmgr::info"/>
+                       <label name="pkgmgr::cache"/>
                </provide>
                <request>
+                       <smack request="_" type="rwx"/>
+                       <smack request="app-svc::db" type="rw"/>
+                       <smack request="cert-svc" type="rx"/>
+                       <smack request="ca-certificates::ssl-certs" type="rx"/>
+                       <smack request="data-provider-master::data" type="rx"/>
                        <smack request="pkgmgr::svc" type="rwx"/>
                        <smack request="pkgmgr::info" type="rwx"/>
+                       <smack request="pkgmgr::cache" type="rwx"/>
+                       <smack request="pkgmgr-parser" type="rx"/>
                        <smack request="dbus" type="rwx"/>
+                       <smack request="email-service" type="rx"/>
                        <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="pkgmgr-parser" type="rx"/>
+                       <smack request="pkgmgr-server" type="rwx"/>
+                       <smack request="privacy-manager::db" type="rw"/>
+                       <smack request="device::sys_logging" type="rw"/>
+                       <smack request="device::app_logging" type="rw"/>
+                       <smack request="rpm-backend" type="rwx"/>
                        <smack request="sdbd" type="r"/>
+                       <smack request="shortcut-service::db" type="rw"/>
+                       <smack request="security-server::label" type="w"/>
+                       <smack request="security-server::api-permissions" type="w"/>
+                       <smack request="tizen::vconf::public::r" type="rl"/>
+                       <smack request="tizen::vconf::public::r::platform::rw" type="rw"/>
+                       <smack request="tizen::vconf::setting::admin" type="rl"/>
+                       <smack request="system::ext_storage" type="rxl"/>
+                       <smack request="system::ext_storage_appdata" type="rwx"/>
                </request>
        </define>
        <request>
        </request>
        <assign>
                <filesystem path="/usr/bin/pkg_fota" exec_label="pkgmgr"/>
+               <filesystem path="/usr/bin/pkg_db_upg" 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>
diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt
deleted file mode 100644 (file)
index e3aebb4..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-# for i18n
-
-SET(POFILES en_US.po en_GB.po ja_JP.po ko_KR.po zh_CN.po)
-
-SET(MSGFMT "/usr/bin/msgfmt")
-
-FOREACH(pofile ${POFILES})
-       SET(pofile ${CMAKE_CURRENT_SOURCE_DIR}/${pofile})
-       MESSAGE("PO: ${pofile}")
-       GET_FILENAME_COMPONENT(absPofile ${pofile} ABSOLUTE)
-       GET_FILENAME_COMPONENT(lang ${absPofile} NAME_WE)
-       SET(moFile ${CMAKE_CURRENT_BINARY_DIR}/${lang}.mo)
-       ADD_CUSTOM_COMMAND(
-                       OUTPUT ${moFile}
-                       COMMAND ${MSGFMT} -o ${moFile} ${absPofile}
-                       DEPENDS ${absPofile}
-       )
-       INSTALL(FILES ${moFile}
-                       DESTINATION share/locale/${lang}/LC_MESSAGES RENAME ${PROJECT_NAME}.mo)
-       SET(moFiles ${moFiles} ${moFile})
-ENDFOREACH(pofile)
-
-MESSAGE(".mo files: ${moFiles}")
-ADD_CUSTOM_TARGET(po ALL DEPENDS ${moFiles})
diff --git a/po/POTFILES.in b/po/POTFILES.in
deleted file mode 100644 (file)
index df0ed57..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-# List of source files containing translatable strings.
-server/src/pkgmgr-server.c
diff --git a/po/en_GB.po b/po/en_GB.po
deleted file mode 100644 (file)
index af3f93a..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
-#
-#, fuzzy
-msgid ""
-msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-10-14 19:06+0900\n"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <LL@li.org>\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-
-#: server/src/pkgmgr-server.c:251
-#, c-format
-msgid "Install?"
-msgstr ""
-
-#: server/src/pkgmgr-server.c:287
-#, c-format
-msgid "Uninstall?"
-msgstr ""
-
-#: server/src/pkgmgr-server.c:290
-#, c-format
-msgid "Invalid request"
-msgstr ""
diff --git a/po/en_US.po b/po/en_US.po
deleted file mode 100644 (file)
index af3f93a..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
-#
-#, fuzzy
-msgid ""
-msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-10-14 19:06+0900\n"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <LL@li.org>\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-
-#: server/src/pkgmgr-server.c:251
-#, c-format
-msgid "Install?"
-msgstr ""
-
-#: server/src/pkgmgr-server.c:287
-#, c-format
-msgid "Uninstall?"
-msgstr ""
-
-#: server/src/pkgmgr-server.c:290
-#, c-format
-msgid "Invalid request"
-msgstr ""
diff --git a/po/ja_JP.po b/po/ja_JP.po
deleted file mode 100644 (file)
index 1d5f6e0..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
-#
-#, fuzzy
-msgid ""
-msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-10-14 19:06+0900\n"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <LL@li.org>\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-
-#: server/src/pkgmgr-server.c:251
-#, c-format
-msgid "Install?"
-msgstr "インストールしますか?"
-
-#: server/src/pkgmgr-server.c:287
-#, c-format
-msgid "Uninstall?"
-msgstr "アンインストールしますか?"
-
-#: server/src/pkgmgr-server.c:290
-#, c-format
-msgid "Invalid request"
-msgstr "無効なリクエストです"
diff --git a/po/ko_KR.po b/po/ko_KR.po
deleted file mode 100644 (file)
index 3850a70..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
-#
-#, fuzzy
-msgid ""
-msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-10-14 19:06+0900\n"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <LL@li.org>\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-
-#: server/src/pkgmgr-server.c:251
-#, c-format
-msgid "Install?"
-msgstr "설치할까요?"
-
-#: server/src/pkgmgr-server.c:287
-#, c-format
-msgid "Uninstall?"
-msgstr "삭제할까요?"
-
-#: server/src/pkgmgr-server.c:290
-#, c-format
-msgid "Invalid request"
-msgstr "요청이 바르지 않습니다"
diff --git a/po/package-manager.pot b/po/package-manager.pot
deleted file mode 100644 (file)
index e9f371b..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
-#
-#, fuzzy
-msgid ""
-msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-10-14 19:06+0900\n"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <LL@li.org>\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=CHARSET\n"
-"Content-Transfer-Encoding: 8bit\n"
-
-#: server/src/pkgmgr-server.c:251
-#, c-format
-msgid "Install?"
-msgstr ""
-
-#: server/src/pkgmgr-server.c:287
-#, c-format
-msgid "Uninstall?"
-msgstr ""
-
-#: server/src/pkgmgr-server.c:290
-#, c-format
-msgid "Invalid request"
-msgstr ""
diff --git a/po/update-po.sh b/po/update-po.sh
deleted file mode 100755 (executable)
index 16fbdc1..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/bin/sh
-
-PACKAGE=package-manager
-SRCROOT=..
-POTFILES=POTFILES.in
-
-#ALL_LINGUAS= am az be ca cs da de el en_CA en_GB es et fi fr hr hu it ja ko lv mk ml ms nb ne nl pa pl pt pt_BR ru rw sk sl sr sr@Latn sv ta tr uk vi zh_CN zh_TW
-ALL_LINGUAS="en_US en_GB ja_JP ko_KR zh_CN"
-
-XGETTEXT=/usr/bin/xgettext
-MSGMERGE=/usr/bin/msgmerge
-
-echo -n "Make ${PACKAGE}.pot  "
-if [ ! -e $POTFILES ] ; then
-       echo "$POTFILES not found"
-       exit 1
-fi
-
-$XGETTEXT --default-domain=${PACKAGE} --directory=${SRCROOT} \
-               --add-comments --keyword=_ --keyword=N_ --files-from=$POTFILES
-if [ $? -ne 0 ]; then
-       echo "xgettext error"
-       exit 1
-fi
-
-if [ ! -f ${PACKAGE}.po ]; then
-       echo "No such file: ${PACKAGE}.po"
-       exit 1
-fi
-
-rm -f ${PACKAGE}.pot && mv ${PACKAGE}.po ${PACKAGE}.pot
-echo "done"
-
-for LANG in $ALL_LINGUAS; do 
-       echo "$LANG : "
-
-       if [ ! -e $LANG.po ] ; then
-               sed 's/CHARSET/UTF-8/g' ${PACKAGE}.pot > ${LANG}.po
-               echo "${LANG}.po created"
-       else
-               if $MSGMERGE ${LANG}.po ${PACKAGE}.pot -o ${LANG}.new.po ; then
-                       if cmp ${LANG}.po ${LANG}.new.po > /dev/null 2>&1; then
-                               rm -f ${LANG}.new.po
-                       else
-                               if mv -f ${LANG}.new.po ${LANG}.po; then
-                                       echo "" 
-                               else
-                                       echo "msgmerge for $LANG.po failed: cannot move $LANG.new.po to $LANG.po" 1>&2
-                                       rm -f ${LANG}.new.po
-                                       exit 1
-                               fi
-                       fi
-               else
-                       echo "msgmerge for $LANG failed!"
-                       rm -f ${LANG}.new.po
-               fi
-       fi
-       echo ""
-done
-
diff --git a/po/zh_CN.po b/po/zh_CN.po
deleted file mode 100644 (file)
index af3f93a..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
-#
-#, fuzzy
-msgid ""
-msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-10-14 19:06+0900\n"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <LL@li.org>\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-
-#: server/src/pkgmgr-server.c:251
-#, c-format
-msgid "Install?"
-msgstr ""
-
-#: server/src/pkgmgr-server.c:287
-#, c-format
-msgid "Uninstall?"
-msgstr ""
-
-#: server/src/pkgmgr-server.c:290
-#, c-format
-msgid "Invalid request"
-msgstr ""
diff --git a/queue_status b/queue_status
deleted file mode 100644 (file)
index 5baa80c..0000000
+++ /dev/null
@@ -1 +0,0 @@
-This file is for creating required directory.
diff --git a/server/include/pkgmgr-server.h b/server/include/pkgmgr-server.h
deleted file mode 100755 (executable)
index 2d662b9..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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_SERVER_H_
-#define _PKGMGR_SERVER_H_
-
-#define CONF_FILE      "/usr/etc/package-manager/server/.config"
-#define DESKTOP_FILE_DIRS      "/usr/share/install-info/desktop.conf"
-
-#define PKG_BACKEND    "backend:"
-#define PKG_CONF_PATH  "/usr/etc/package-manager/pkg_path.conf"
-
-#define MAX_REQ_ID_LEN         256
-#define MAX_PKG_TYPE_LEN       128
-#define MAX_PKG_NAME_LEN       256
-#define MAX_PKG_ARGS_LEN       4096
-#define MAX_COOKIE_LEN         32
-#define DESKTOP_FILE_DIRS_NUM          1024
-
-typedef struct {
-       char req_id[MAX_REQ_ID_LEN];
-       int req_type;
-       char pkg_type[MAX_PKG_TYPE_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 pkgid[MAX_PKG_NAME_LEN];
-       char args[MAX_PKG_ARGS_LEN];
-}backend_info;
-
-struct pm_inotify_paths_t {
-       int wd;
-       char *path;
-};
-typedef struct pm_inotify_paths_t pm_inotify_paths;
-
-char *_get_backend_cmd(char *type);
-void _pm_desktop_file_monitor_init();
-void _pm_desktop_file_monitor_fini();
-int _pm_desktop_file_dir_search(pm_inotify_paths *paths, int number);
-
-#endif                         /*  _PKGMGR_SERVER_H_ */
diff --git a/server/include/pm-queue.h b/server/include/pm-queue.h
deleted file mode 100755 (executable)
index 64d4b2d..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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 _PM_QUEUE_H_
-#define _PM_QUEUE_H_
-
-#include "pkgmgr-server.h"
-
-#define STATUS_FILE    "/usr/etc/package-manager/server/queue_status"
-/* #define STATUS_FILE   "./queue_status" */
-
-typedef struct _pm_queue_data {
-       pm_dbus_msg *msg;
-       struct _pm_queue_data *next;
-} pm_queue_data;
-
-typedef struct queue_info_map_t {
-       char pkgtype[MAX_PKG_TYPE_LEN];
-       char backend[MAX_PKG_NAME_LEN];
-       int queue_slot;
-       pm_queue_data *head;
-} queue_info_map;
-
-#define MAX_QUEUE_NUM 128
-
-int _pm_queue_init();
-int _pm_queue_push(pm_dbus_msg *item);
-/*position specifies the queue from which to pop request*/
-pm_dbus_msg *_pm_queue_pop(int position);
-void _pm_queue_final();
-void _pm_queue_delete(pm_dbus_msg *item);
-pm_queue_data *_add_node();
-void _save_queue_status(pm_dbus_msg *item, char *status);
-void _print_queue(int position);
-
-#endif                         /* _PM_QUEUE_H_ */
diff --git a/server/src/pkgmgr-server.c b/server/src/pkgmgr-server.c
deleted file mode 100755 (executable)
index 6d12893..0000000
+++ /dev/null
@@ -1,1527 +0,0 @@
-/*
- * 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 <sys/types.h>
-#include <sys/wait.h>
-#include <sys/inotify.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 <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 "pkgmgr-server.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"
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-#define LOG_TAG "PKGMGR_SERVER"
-
-#define IS_WHITESPACE(CHAR) \
-((CHAR == ' ' || CHAR == '\t' || CHAR == '\r' || CHAR == '\n') ? TRUE : FALSE)
-
-#define PACKAGE_RECOVERY_DIR "/opt/share/packages/.recovery/pkgmgr"
-
-#define DESKTOP_W   720.0
-
-#define NO_MATCHING_FILE 11
-
-static int backend_flag = 0;   /* 0 means that backend process is not running */
-
-/*
-8 bit value to represent maximum 8 backends.
-Each bit position corresponds to a queue slot which
-is dynamically determined.
-*/
-char backend_busy = 0;
-/*
-8 bit value to represent quiet mode operation for maximum 8 backends
-1->quiet 0->non-quiet
-Each bit position corresponds to a queue slot which
-is dynamically determined.
-*/
-char backend_mode = 63; /*00111111*/
-extern int num_of_backends;
-
-backend_info *begin;
-extern queue_info_map *start;
-extern int entries;
-int pos = 0;
-/*To store info in case of backend crash*/
-char pname[MAX_PKG_NAME_LEN] = {'\0'};
-char ptype[MAX_PKG_TYPE_LEN] = {'\0'};
-char args[MAX_PKG_ARGS_LEN] = {'\0'};
-
-GMainLoop *mainloop = NULL;
-
-static int __check_backend_status_for_exit();
-static int __check_queue_status_for_exit();
-static int __is_backend_busy(int position);
-static void __set_backend_busy(int position);
-static void __set_backend_free(int position);
-static void __set_backend_mode(int position);
-static void __unset_backend_mode(int position);
-
-static void sighandler(int signo);
-gboolean queue_job(void *data);
-gboolean send_fail_signal(void *data);
-gboolean exit_server(void *data);
-
-/* To check whether a particular backend is free/busy*/
-static int __is_backend_busy(int position)
-{
-       return backend_busy & 1<<position;
-}
-/*To set a particular backend as busy*/
-static void __set_backend_busy(int position)
-{
-       backend_busy = backend_busy | 1<<position;
-}
-/*To set a particular backend as free */
-static void __set_backend_free(int position)
-{
-       backend_busy = backend_busy & ~(1<<position);
-}
-
-/*To set a particular backend mode as quiet*/
-static void __set_backend_mode(int position)
-{
-       backend_mode = backend_mode | 1<<position;
-}
-/*To unset a particular backend mode */
-static void __unset_backend_mode(int position)
-{
-       backend_mode = backend_mode & ~(1<<position);
-}
-
-static void __set_recovery_mode(char *pkgid, char *pkg_type)
-{
-       char recovery_file[MAX_PKG_NAME_LEN] = { 0, };
-       char buffer[MAX_PKG_NAME_LEN] = { 0 };
-       char *pkgid_tmp = NULL;
-       FILE *rev_file = NULL;
-
-       if (pkgid == NULL) {
-               _LOGE("pkgid is null\n");
-               return;
-       }
-
-       /*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);
-       }
-
-       rev_file = fopen(recovery_file, "w");
-       if (rev_file== NULL) {
-               _LOGD("rev_file[%s] is null\n", recovery_file);
-               return;
-       }
-
-       snprintf(buffer, MAX_PKG_NAME_LEN, "pkgid : %s\n", pkgid);
-       fwrite(buffer, sizeof(char), strlen(buffer), rev_file);
-
-       fclose(rev_file);
-}
-
-static void __unset_recovery_mode(char *pkgid, char *pkg_type)
-{
-       int ret = -1;
-       char recovery_file[MAX_PKG_NAME_LEN] = { 0, };
-       char *pkgid_tmp = NULL;
-
-       if (pkgid == NULL) {
-               _LOGE("pkgid is null\n");
-               return;
-       }
-
-       /*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);
-       }
-
-       ret = remove(recovery_file);
-       if (ret < 0)
-               _LOGD("remove recovery_file[%s] fail\n", recovery_file);
-}
-
-static int __check_privilege_by_cookie(const char *e_cookie, int req_type)
-{
-       guchar *cookie = NULL;
-       gsize size;
-       int ret = PMINFO_R_ERROR;
-
-       if (e_cookie == NULL)   {
-               _LOGE("e_cookie is NULL!!!\n");
-               return PMINFO_R_ERROR;
-       }
-
-       cookie = g_base64_decode(e_cookie, &size);
-       if (cookie == NULL)     {
-               _LOGE("Unable to decode cookie!!!\n");
-               return PMINFO_R_ERROR;
-       }
-
-       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;
-
-               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;
-
-               default:
-                       _LOGD("Check your request[%d]..\n", req_type);
-                       break;
-       }
-
-       _LOGD("security_server[req-type:%d] check cookie result = %d, \n", req_type, ret);
-
-       if (cookie){
-               g_free(cookie);
-               cookie = NULL;
-       }
-
-       return ret;
-}
-
-static int __get_position_from_pkg_type(char *pkgtype)
-{
-       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++;
-
-       }
-       return -1;
-}
-
-void __get_type_from_msg(pm_dbus_msg *item)
-{
-       char *pkgtype = NULL;
-
-       pkgtype = _get_type_from_zip(item->pkgid);
-       retm_if(pkgtype == NULL, "pkgtype is null for %s \n", item->pkgid);
-
-       _LOGD("pkg type = %s, file = %s \n", pkgtype, item->pkgid);
-
-       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)
-{
-       _LOGD("send_fail_signal start\n");
-       gboolean ret_parse;
-       gint argcp;
-       gchar **argvp;
-       GError *gerr = NULL;
-       pkgmgr_installer *pi;
-       pi = pkgmgr_installer_new();
-       if (!pi) {
-               _LOGD("Failure in creating the pkgmgr_installer object");
-               return FALSE;
-       }
-       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);
-               return FALSE;
-       }
-
-       pkgmgr_installer_receive_request(pi, argcp, argvp);
-       pkgmgr_installer_send_signal(pi, ptype, pname, "end", "fail");
-       pkgmgr_installer_free(pi);
-       return FALSE;
-}
-
-static void sighandler(int signo)
-{
-       int status;
-       pid_t cpid;
-       int i = 0;
-       backend_info *ptr = NULL;
-       ptr = begin;
-
-       while ((cpid = waitpid(-1, &status, WNOHANG)) > 0) {
-               _LOGD("child exit [%d]\n", cpid);
-               if (WIFEXITED(status)) {
-                       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)) {
-                       _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);
-                                       __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;
-                               }
-                       }
-               }
-       }
-
-}
-
-static void __register_signal_handler(void)
-{
-       static int sig_reg = 0;
-
-       if (sig_reg == 0) {
-               struct sigaction act;
-
-               act.sa_handler = sighandler;
-               sigemptyset(&act.sa_mask);
-               act.sa_flags = SA_NOCLDSTOP;
-
-               if (sigaction(SIGCHLD, &act, NULL) < 0) {
-                       _LOGD("signal: SIGCHLD failed\n");
-               } else
-                       _LOGD("signal: SIGCHLD succeed\n");
-               if (g_timeout_add_seconds(2, exit_server, NULL))
-                       _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);
-
-
-
-       switch (item->req_type) {
-       case COMM_REQ_TO_INSTALLER:
-               /* 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_ACTIVATE_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_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);
-               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);
-
-/*             g_idle_add(queue_job, NULL); */
-               if (err == 0)
-                       queue_job(NULL);
-               *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:
-               _pm_queue_delete(item);
-               p = __get_position_from_pkg_type(item->pkg_type);
-               __unset_backend_mode(p);
-               *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:
-               _LOGD("Check your request..\n");
-               *ret = PKGMGR_R_ERROR;
-               break;
-       }
-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;
-       }
-
-       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;
-       }
-
-       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);
-}
-
-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;
-       }
-
-       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;
-       }
-
-       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);
-
-       __pm_send_sub_signal(req_id, pkg_type, pkgid, key, val);
-}
-
-void __change_item_info(pm_dbus_msg *item)
-{
-       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;
-       }
-
-       memset((item->pkgid),0,MAX_PKG_NAME_LEN);
-       strncpy(item->pkgid, pkgid, sizeof(item->pkgid) - 1);
-
-       pkgmgrinfo_appinfo_destroy_appinfo(handle);
-}
-
-static char **__generate_argv(const char *args)
-{
-       /* 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)
-       {
-               _LOGE("Out of memory");
-               exit(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 void __exec_with_arg_vector(const char* cmd, char** argv)
-{
-       char *backend_cmd = strdup(cmd);
-       if (NULL == backend_cmd)
-       {
-               perror("Out of memory");
-               exit(1);
-       }
-
-       _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);
-       }
-       if (NULL != backend_cmd)
-               free(backend_cmd);
-}
-
-static int __set_activation_info(char *pkgid, int is_active, char *label)
-{
-       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)
-{
-       /* _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)) {
-               item = _pm_queue_pop(pos % num_of_backends);
-               pos = (pos + 1) % num_of_backends;
-       }
-       else {
-               pos = (pos + 1) % num_of_backends;
-               goto pop;
-       }
-
-       int ret = 0;
-       char *backend_cmd = NULL;
-
-       /* queue is empty and backend process is not running */
-       if ( (item == NULL) || (item->req_type == -1) ) {
-               if(item)
-                       free(item);
-               goto pop;
-       }
-       __set_backend_busy((pos + num_of_backends - 1) % num_of_backends);
-       __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;
-
-                       _LOGD("Try to exec [%s][%s]", item->pkg_type, backend_cmd);
-                       fprintf(stdout, "Try to exec [%s][%s]\n", item->pkg_type, backend_cmd);
-
-                       char **args_vector = __generate_argv(item->args);
-                       args_vector[0] = backend_cmd;
-
-                       /* Execute backend !!! */
-                       __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);
-
-                       __pm_send_signal(PKGMGR_INSTALLER_INSTALL_EVENT_STR, item->pkg_type, item->pkgid, PKGMGR_INSTALLER_START_KEY_STR, PKGMGR_INSTALLER_INSTALL_EVENT_STR);
-
-                       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);
-                       }
-                       __pm_send_signal(PKGMGR_INSTALLER_INSTALL_EVENT_STR, item->pkg_type, item->pkgid, PKGMGR_INSTALLER_END_KEY_STR, PKGMGR_INSTALLER_OK_EVENT_STR);
-
-                       _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);
-
-                       __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);
-
-                       _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);
-
-                       __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);
-
-                       _LOGE("ACTIVATE_APP end [pkgid = %s, ret = %d]",item->pkgid, ret);
-                       break;
-               case COMM_REQ_DEACTIVATE_APP:
-                       _LOGE("DEACTIVATE_APP [appid = %s]",item->pkgid);
-
-                       ret = __set_activation_info(item->pkgid, 0, NULL);
-
-                       __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);
-
-                       _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);
-
-                       __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);
-
-                       _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;
-
-                       _LOGD("Try to exec [%s][%s]", item->pkg_type, backend_cmd);
-                       fprintf(stdout, "Try to exec [%s][%s]\n", item->pkg_type, backend_cmd);
-
-                       char **args_vectors = __generate_argv(item->args);
-                       args_vectors[0] = backend_cmd;
-
-                       /* 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);
-                       }
-                       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 COMM_REQ_CLEAR_CACHE_DIR:
-                       __exec_with_arg_vector("/usr/bin/pkg_clearcache", __generate_argv(item->pkgid));
-                       break;
-
-               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;
-
-       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;
-}
-
-void _app_str_trim(char *input)
-{
-       char *trim_str = input;
-
-       if (input == NULL)
-               return;
-
-       while (*input != 0) {
-               if (!IS_WHITESPACE(*input)) {
-                       *trim_str = *input;
-                       trim_str++;
-               }
-               input++;
-       }
-
-       *trim_str = 0;
-       return;
-}
-
-char *_get_backend_cmd(char *type)
-{
-       FILE *fp = NULL;
-       char buffer[1024] = { 0 };
-       char *command = NULL;
-       int size = 0;
-       fp = fopen(PKG_CONF_PATH, "r");
-       if (fp == NULL) {
-               return NULL;
-       }
-
-       char *path = NULL;
-       while (fgets(buffer, 1024, fp) != NULL) {
-               if (buffer[0] == '#')
-                       continue;
-
-               _app_str_trim(buffer);
-
-               if ((path = strstr(buffer, PKG_BACKEND)) != NULL) {
-//                     _LOGD("buffer [%s]", buffer);
-                       path = path + strlen(PKG_BACKEND);
-//                     _LOGD("path [%s]", path);
-
-                       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';
-//                     _LOGD("command [%s]", command);
-
-                       if (fp != NULL)
-                               fclose(fp);
-
-                       return command;
-               }
-
-               memset(buffer, 0x00, 1024);
-       }
-
-       if (fp != NULL)
-               fclose(fp);
-
-       return NULL;            /* cannot find proper command */
-}
-
-int main(int argc, char *argv[])
-{
-       FILE *fp_status = NULL;
-       char buf[32] = { 0, };
-       pid_t pid;
-       char *backend_cmd = NULL;
-       char *backend_name = NULL;
-       backend_info *ptr = NULL;
-       int r;
-
-       _LOGD("server start");
-
-       if (argv[1]) {
-               if (strcmp(argv[1], "init") == 0) {
-                       /* 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);
-                       /* if processing <-- unintended termination */
-                       if (strcmp(buf, "processing") == 0) {
-                               pid = fork();
-
-                               if (pid == 0) { /* child */
-                                       fgets(buf, 32, fp_status);
-                                       backend_cmd = _get_backend_cmd(buf);
-                                       if (!backend_cmd) {     /* if NULL, */
-                                               _LOGD("fail to get backend command");
-                                               goto err;
-                                       }
-                                       backend_name =
-                                           strrchr(backend_cmd, '/');
-
-                                       execl(backend_cmd, backend_name, "-r",
-                                             NULL);
-                                       if (backend_cmd)
-                                               free(backend_cmd);
-                                       fprintf(fp_status, " ");
- err:
-                                       fclose(fp_status);
-                                       exit(13);
-                               } else if (pid < 0) {   /* error */
-                                       _LOGD("fork fail");
-                                       fclose(fp_status);
-                                       return 0;
-                               } else {        /* parent */
-
-                                       _LOGD("parent end\n");
-                                       fprintf(fp_status, " ");
-                                       fclose(fp_status);
-                                       return 0;
-                               }
-                       }
-               }
-       }
-
-       r = _pm_queue_init();
-       if (r) {
-               _LOGE("Queue Initialization Failed\n");
-               return -1;
-       }
-
-       /*Allocate memory for holding pid, pkgtype and pkgid*/
-       ptr = (backend_info*)calloc(num_of_backends, sizeof(backend_info));
-       if (ptr == NULL) {
-               _LOGD("Malloc Failed\n");
-               return -1;
-       }
-       memset(ptr, '\0', num_of_backends * sizeof(backend_info));
-       begin = ptr;
-
-       g_type_init();
-       mainloop = g_main_loop_new(NULL, FALSE);
-       if (!mainloop){
-               _LOGD("g_main_loop_new failed\n");
-               return -1;
-       }
-
-       _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, 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);
-
-       _LOGD("Quit main loop.");
-       _pm_queue_final();
-       /*Free backend info */
-       if (begin) {
-               free(begin);
-               begin = NULL;
-       }
-
-       _LOGD("package manager server terminated.");
-
-       return 0;
-}
diff --git a/server/src/pkgmgr_external_storage.c b/server/src/pkgmgr_external_storage.c
deleted file mode 100644 (file)
index 1ede72b..0000000
+++ /dev/null
@@ -1,228 +0,0 @@
-#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;
-}
diff --git a/server/src/pkgmgr_external_storage.h b/server/src/pkgmgr_external_storage.h
deleted file mode 100644 (file)
index f087189..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-#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);
-
-
-
-
-
-
-
-
-
-
diff --git a/server/src/pm-queue.c b/server/src/pm-queue.c
deleted file mode 100755 (executable)
index 5e6924a..0000000
+++ /dev/null
@@ -1,532 +0,0 @@
-/*
- * 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 <dirent.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include "pkgmgr-server.h"
-#include "pm-queue.h"
-
-#define BACKEND_INFO_DIR       "/usr/etc/package-manager/backend"
-
-static pm_queue_data *__get_head_from_pkgtype(pm_dbus_msg *item);
-static void __update_head_from_pkgtype(pm_queue_data *data);
-static int __entry_exist(char *backend);
-static int __is_pkg_supported(char *pkgtype);
-
-queue_info_map *start = NULL;
-int entries = 0;
-int slot = 0;
-int num_of_backends = 0;
-
-/*Function to check whether a particular package type
-is supported or not. It parses the queue info map
-to get the information.
-It will prevent the accidental hanging of server.
-Returns 1 if found.*/
-static int __is_pkg_supported(char *pkgtype)
-{
-       queue_info_map *ptr = NULL;
-       ptr = start;
-       int i = 0;
-
-       for(i = 0; i < entries; i++)
-       {
-               if (!strncmp(ptr->pkgtype, pkgtype, MAX_PKG_TYPE_LEN))
-                       return 1;
-               else {
-                       ptr++;
-                       continue;
-               }
-       }
-       return 0;
-}
-
-/*tells whether a particular backend exists in the
-* info map or not.
-* on Success it return the queue slot of the already present entry
-* on Failure -1 is returned*/
-static int __entry_exist(char *backend)
-{
-       queue_info_map *ptr = NULL;
-       ptr = start;
-       int i = 0;
-       for(i = 0; i < entries; i++)
-       {
-               if (!strncmp(ptr->backend, backend, MAX_PKG_NAME_LEN))
-                       return ptr->queue_slot;
-               else {
-                       ptr++;
-                       continue;
-               }
-       }
-       return -1;
-}
-
-/*In case of first push, it updates the queue head
-and copies it to all duplicate entries in queue info map*/
-static void __update_head_from_pkgtype(pm_queue_data *data)
-{
-       queue_info_map *ptr = NULL;
-       ptr = start;
-       int slot = -1;
-       int i = 0;
-       for(i = 0; i < entries; i++)
-       {
-               if (!strncmp(ptr->pkgtype, data->msg->pkg_type, MAX_PKG_TYPE_LEN)) {
-                       ptr->head = data;
-                       slot = ptr->queue_slot;
-               }
-               else {
-                       ptr++;
-                       continue;
-               }
-       }
-       /*update head for each duplicate entry*/
-       ptr = start;
-       for(i = 0; i < entries; i++)
-       {
-               if(ptr->queue_slot == slot && !ptr->head) {
-                       ptr->head = data;
-               }
-               ptr++;
-       }
-       return;
-}
-
-/*Gets the queue head based on pkg type*/
-static pm_queue_data *__get_head_from_pkgtype(pm_dbus_msg *item)
-{
-       queue_info_map *ptr = NULL;
-       ptr = start;
-       int i = 0;
-       for(i = 0; i < entries; i++)
-       {
-               if (!strncmp(ptr->pkgtype, item->pkg_type, MAX_PKG_TYPE_LEN))
-                       return ptr->head;
-               else {
-                       ptr++;
-                       continue;
-               }
-       }
-       return NULL;
-
-}
-
-int _pm_queue_init()
-{
-       /*Find the num of backends currently supported and initialize
-       that many queues. It is dynamically determined.*/
-       struct dirent **namelist;
-       struct stat fileinfo;
-       queue_info_map *ptr = NULL;
-       int n = 0;
-       int c = 0;
-       int i = 0;
-       int ret = 0;
-       char abs_filename[MAX_PKG_NAME_LEN] = {'\0'};
-       char buf[MAX_PKG_NAME_LEN] = {'\0'};
-       n = scandir(BACKEND_INFO_DIR, &namelist, NULL, alphasort);
-       if (n < 0) {
-               perror("scandir");
-               return -1;
-       }
-       i = n;
-       /*Find number of backends (symlinks + executables)
-       The /usr/etc/package-manager/backend dir should not conatin
-       any other file except the backends.*/
-       while(n--)
-       {
-               if(!strcmp(namelist[n]->d_name, ".") ||
-                       !strcmp(namelist[n]->d_name, ".."))
-                               continue;
-               snprintf(abs_filename, MAX_PKG_NAME_LEN, "%s/%s",
-                       BACKEND_INFO_DIR, namelist[n]->d_name);
-               if (lstat(abs_filename, &fileinfo)) {
-                       perror("lstat");
-                       continue;
-               }
-               if (S_ISDIR(fileinfo.st_mode))
-                       continue;
-               c++;
-               memset(abs_filename, 0x00, MAX_PKG_NAME_LEN);
-       }
-       /*Add entries to info map.*/
-       ptr = (queue_info_map*)calloc(c , sizeof(queue_info_map));
-       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++)
-       {
-               ptr->backend[0] = '\0';
-               ptr->head = NULL;
-               ptr->queue_slot = -2;/*-1 can be error return*/
-               ptr->pkgtype[0] = '\0';
-               ptr++;
-       }
-       n = i;
-       ptr = start;
-       while(n--)
-       {
-               if(!strcmp(namelist[n]->d_name, ".") ||
-                       !strcmp(namelist[n]->d_name, ".."))
-               {
-                       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';
-               }
-               /*executable*/
-               else {
-                       strncpy(buf, abs_filename, MAX_PKG_NAME_LEN - 1);
-               }
-               ret = __entry_exist(buf);
-               if (ret == -1) {
-                       strncpy(ptr->backend, buf, MAX_PKG_NAME_LEN - 1);
-                       strncpy(ptr->pkgtype, namelist[n]->d_name, MAX_PKG_TYPE_LEN - 1);
-                       ptr->queue_slot = slot;
-                       ptr->head = NULL;
-                       entries++;
-                       slot++;
-                       ptr++;
-               }
-               else {
-                       strncpy(ptr->backend, buf, MAX_PKG_NAME_LEN - 1);
-                       strncpy(ptr->pkgtype, namelist[n]->d_name, MAX_PKG_TYPE_LEN - 1);
-                       ptr->queue_slot = ret;
-                       ptr->head = NULL;
-                       entries++;
-                       ptr++;
-               }
-               free(namelist[n]);
-               memset(buf, 0x00, MAX_PKG_NAME_LEN);
-               continue;
-       }
-       free(namelist);
-       num_of_backends = slot;
-#ifdef DEBUG_INFO
-       /*Debug info*/
-       printf("Queue Info Map\n");
-       printf("Number of Backends is %d\n", num_of_backends);
-       printf("Number of Entries is %d\n", entries);
-       printf("Backend\tType\tSlot\tHead\n");
-       ptr = start;
-       for(n = 0; n < entries; n++)
-       {
-               printf("%s\t%s\t%d\t%p\n", ptr->backend, ptr->pkgtype, ptr->queue_slot, ptr->head);
-               ptr++;
-       }
-#endif
-       return 0;
-}
-
-int _pm_queue_push(pm_dbus_msg *item)
-{
-       pm_queue_data *data = NULL;
-       pm_queue_data *cur = NULL;
-       pm_queue_data *tmp = NULL;
-       int ret = 0;
-       ret = __is_pkg_supported(item->pkg_type);
-       if (ret == 0)
-               return -1;
-
-       cur = __get_head_from_pkgtype(item);
-       tmp = cur;
-
-       data = _add_node();
-       if (!data) {            /* fail to allocate mem */
-               fprintf(stderr, "Fail to allocate memory\n");
-               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->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;
-
-       if (cur == NULL) {
-               /* first push */
-               cur = data;
-               __update_head_from_pkgtype(data);
-       }
-       else {
-               while (tmp->next)
-                       tmp = tmp->next;
-
-               tmp->next = data;
-       }
-       return 0;
-}
-
-/*pop request from queue slot "position" */
-pm_dbus_msg *_pm_queue_pop(int position)
-{
-       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) {
-                               cur = ptr->head;
-                               break;
-               }
-               ptr++;
-       }
-
-       if (!cur) {             /* 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->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;
-       cur->next = NULL;
-       free(cur->msg);
-       free(cur);
-       /*update head for each duplicate queue entry*/
-       ptr = start;
-       for(i = 0; i < entries; i++)
-       {
-               if(ptr->queue_slot == position) {
-                       ptr->head = saveptr;
-               }
-               ptr++;
-       }
-       return ret;
-}
-
-/*populate an array of all queue heads and delete them one by one*/
-void _pm_queue_final()
-{
-       int c = 0;
-       int i = 0;
-       int slot = -1;
-       pm_queue_data *cur = NULL;
-       pm_queue_data *tail = NULL;
-       pm_queue_data *prev = NULL;
-       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) {
-                       ptr++;
-                       continue;
-               }
-               else {
-                       head[c] = ptr->head;
-                       slot = ptr->queue_slot;
-                       c++;
-                       ptr++;
-               }
-       }
-
-       c = 0;
-       while(c < num_of_backends) {
-               if (!head[c]) {         /* in case of head is NULL */
-                       fprintf(stderr, "queue is NULL\n");
-                       c = c + 1;
-                       continue;
-               }
-
-               while (head[c]->next) {
-                       cur = head[c]->next;
-
-                       while (cur->next) {
-                               prev = cur;
-                               cur = cur->next;
-                       }
-
-                       tail = cur;
-
-                       free(tail->msg);
-                       free(tail);
-                       prev->next = NULL;
-               }
-
-               free(head[c]->msg);
-               free(head[c]);
-
-               head[c] = NULL;
-               c = c + 1;
-       }
-       /*Free the info map*/
-       if (start) {
-               free(start);
-               start = NULL;
-       }
-}
-
-pm_queue_data *_add_node()
-{
-       pm_queue_data *newnode = NULL;
-
-       newnode = (pm_queue_data *) malloc(sizeof(pm_queue_data));
-       if (!newnode) {         /* if NULL */
-               fprintf(stderr, "Mem alloc error\n");
-               return NULL;
-       }
-       memset(newnode, 0x00, sizeof(pm_queue_data));
-
-       newnode->msg = (pm_dbus_msg *) malloc(sizeof(pm_dbus_msg));
-       if (!newnode->msg) {
-               fprintf(stderr, "Mem alloc error\n");
-               free(newnode);
-               return NULL;
-       }
-       memset(newnode->msg, 0x00, sizeof(pm_dbus_msg));
-
-       return newnode;
-}
-
-void _pm_queue_delete(pm_dbus_msg *item)
-{
-       /* Assume that pacakge name is unique */
-       pm_queue_data *cur = NULL;
-       pm_queue_data *prev = NULL;
-       cur = __get_head_from_pkgtype(item);
-       prev = cur;
-       if (cur) {
-               while (cur->next) {
-                       if (!strcmp(item->pkgid, cur->msg->pkgid)) {
-                               prev->next = cur->next;
-                               free(cur->msg);
-                               free(cur);
-                               break;
-                       }
-                       prev = cur;
-                       cur = cur->next;
-               }
-       }
-}
-
-void _save_queue_status(pm_dbus_msg *item, char *status)
-{
-       FILE *fp_status = NULL;
-
-       fp_status = fopen(STATUS_FILE, "w");    /* overwrite always */
-       if (!fp_status) {
-               fprintf(stderr, "Can't open status file:%s\n", STATUS_FILE);
-               return;
-       }
-
-       fprintf(fp_status, "%s\n", status);
-       fprintf(fp_status, "%s\n", item->pkg_type);
-
-       fsync(fp_status->_fileno);
-       fclose(fp_status);
-}
-
-void _print_queue(int position)
-{
-       pm_queue_data *cur = NULL;
-       queue_info_map *ptr = start;
-       int i = 0;
-       for(i =0; i < entries; i++)
-       {
-               if (ptr->queue_slot == position) {
-                               cur = ptr->head;
-                               break;
-               }
-               ptr++;
-       }
-       int index = 1;
-       if (!cur) {
-               return;
-       }
-
-       while (cur) {
-               index++;
-               cur = cur->next;
-       }
-}
diff --git a/slp-pkgmgr.service b/slp-pkgmgr.service
deleted file mode 100644 (file)
index 8ca759f..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-[Unit]
-Description=SLP Package Manager
-
-[Service]
-BusName=org.tizen.pkgmgr
-ExecStart=/usr/bin/pkgmgr-server
diff --git a/test.sh b/test.sh
deleted file mode 100755 (executable)
index d63ef99..0000000
--- a/test.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-
-#export CFLAGS=""
-#export LDFLAGS=""
-
-cd `dirname $0`
-
-PREFIX=/usr
-
-rm -rf cmake_tmp
-mkdir -p cmake_tmp
-cd cmake_tmp
-
-CFLAGS="${CFLAGS} -g" LDFLAGS="${LDFLAGS}" cmake .. -DCMAKE_INSTALL_PREFIX=${PREFIX} -DCMAKE_BUILD_TYPE=Debug &&
-make &&
-mkdir -p destdir &&
-make install DESTDIR=destdir
-
diff --git a/tool/CMakeLists.txt b/tool/CMakeLists.txt
deleted file mode 100755 (executable)
index 51e2d5f..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-# Test executables
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TEST_CFLAGS}")
-
-#Verbose
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/client/include)
-
-INCLUDE(FindPkgConfig)
-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 -pie" )
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
-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)
-target_link_libraries(pkgcmd pkgmgr-client ${pkgs_test_LDFLAGS})
-INSTALL(TARGETS pkgcmd DESTINATION bin)
-
-add_executable(pkginfo
-                pkg_info.c)
-target_link_libraries(pkginfo pkgmgr-client 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 ${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 pkgmgr-info ${toolpkgs_LDFLAGS})
-install(TARGETS pkgmgr-install DESTINATION bin)
-
-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/)
-
diff --git a/tool/mime.tpk.xml b/tool/mime.tpk.xml
deleted file mode 100644 (file)
index 3aedf49..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-<?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>
diff --git a/tool/mime.wac.xml b/tool/mime.wac.xml
deleted file mode 100644 (file)
index 099c661..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
-    <mime-type  type="application/widget">
-        <!--Created automatically by update-mime-database. DO NOT EDIT!-->
-        <comment>WAC Widget</comment>
-        <comment xml:lang="ko">WAC 위젯</comment>
-        <acronym>WGT</acronym>
-        <expanded-acronym>wac WidGeT</expanded-acronym>
-        <glob pattern="*.wgt"/>
-        <alias type="application/vnd.wac.widget-sharing"/>
-    </mime-type>
-</mime-info>
diff --git a/tool/org.tizen.pkgmgr-install.xml.in b/tool/org.tizen.pkgmgr-install.xml.in
deleted file mode 100755 (executable)
index 337eb38..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<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>
-       </ui-application>
-</manifest>
diff --git a/tool/pkg.c b/tool/pkg.c
deleted file mode 100755 (executable)
index e409301..0000000
+++ /dev/null
@@ -1,1904 +0,0 @@
-/*
- * 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;
-}
diff --git a/tool/pkg.h b/tool/pkg.h
deleted file mode 100755 (executable)
index efb2fa7..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-#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_
diff --git a/tool/pkg_clearcache.c b/tool/pkg_clearcache.c
deleted file mode 100644 (file)
index d9aa5ba..0000000
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * 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;
-}
diff --git a/tool/pkg_cmd.c b/tool/pkg_cmd.c
deleted file mode 100755 (executable)
index 6104365..0000000
+++ /dev/null
@@ -1,1196 +0,0 @@
-
-/*
- * 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 <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 <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 *pkgid);
-static void __print_pkg_info(pkgmgr_info * pkg_info);
-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 = "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,
-       GET_PKG_SIZE_INFO_REQ,
-       RESET_DEVICE_REQ
-};
-typedef enum pm_tool_request_e req_type;
-
-struct pm_tool_args_t {
-       req_type request;
-       char pkg_path[PKG_NAME_STRING_LEN_MAX];
-       char pkg_type[PKG_TYPE_STRING_LEN_MAX];
-       char pkgid[PKG_NAME_STRING_LEN_MAX];
-       char des_path[PKG_NAME_STRING_LEN_MAX];
-       char label[PKG_NAME_STRING_LEN_MAX];
-       int type;
-       int result;
-};
-typedef struct pm_tool_args_t pm_tool_args;
-pm_tool_args data;
-
-static GMainLoop *main_loop = NULL;
-
-static void __error_no_to_string(int errnumber, char **errstr)
-{
-       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 *pkgid, const char *key, const char *val,
-                      const void *pmsg, void *priv_data)
-{
-       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 ((strncmp(val, "fail", strlen("fail")) == 0) && data.result == 0){
-                       data.result = PKGCMD_ERR_FATAL_ERROR;
-               }
-               g_main_loop_quit(main_loop);
-       }
-
-       return 0;
-}
-
-static int __convert_to_absolute_path(char *path)
-{
-       char abs[PKG_NAME_STRING_LEN_MAX] = {'\0'};
-       char temp[PKG_NAME_STRING_LEN_MAX] = {'\0'};
-       char *ptr = NULL;
-       if (path == NULL) {
-               printf("path is NULL\n");
-               return -1;
-       }
-       strncpy(temp, path, PKG_NAME_STRING_LEN_MAX - 1);
-       if (strchr(path, '/') == NULL) {
-               getcwd(abs, PKG_NAME_STRING_LEN_MAX - 1);
-               if (abs[0] == '\0') {
-                       printf("getcwd() failed\n");
-                       return -1;
-               }
-               memset(data.pkg_path, '\0', PKG_NAME_STRING_LEN_MAX);
-               snprintf(data.pkg_path, PKG_NAME_STRING_LEN_MAX - 1, "%s/%s", abs, temp);
-               return 0;
-       }
-       if (strncmp(path, "./", 2) == 0) {
-               ptr = temp;
-               getcwd(abs, PKG_NAME_STRING_LEN_MAX - 1);
-               if (abs[0] == '\0') {
-                       printf("getcwd() failed\n");
-                       return -1;
-               }
-               ptr = ptr + 2;
-               memset(data.pkg_path, '\0', PKG_NAME_STRING_LEN_MAX);
-               snprintf(data.pkg_path, PKG_NAME_STRING_LEN_MAX - 1, "%s/%s", abs, ptr);
-               return 0;
-       }
-       return 0;
-}
-
-static int __is_app_installed(char *pkgid)
-{
-       return 0;
-}
-
-static void __print_usage()
-{
-       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("-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] \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 -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);
-
-}
-
-static void __print_pkg_info(pkgmgr_info *pkg_info)
-{
-       char *temp = NULL;
-
-       temp = pkgmgr_info_get_string(pkg_info, "pkg_type");
-       if (temp) {
-               printf("pkg_type : %s\n", temp);
-               free(temp);
-       }
-
-       temp = pkgmgr_info_get_string(pkg_info, "pkgid");
-       if (temp) {
-               printf("pkgid : %s\n", temp);
-               free(temp);
-       }
-
-       temp = pkgmgr_info_get_string(pkg_info, "version");
-       if (temp) {
-               printf("version : %s\n", 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);
-               free(temp);
-       }
-
-       temp = pkgmgr_info_get_string(pkg_info, "pkg_description");
-       if (temp) {
-               printf("pkg_description : %s\n", temp);
-               free(temp);
-       }
-
-       temp = pkgmgr_info_get_string(pkg_info, "pkg_mimetype");
-       if (temp) {
-               printf("pkg_mimetype : %s\n", temp);
-               free(temp);
-       }
-
-       temp = pkgmgr_info_get_string(pkg_info, "pkg_installed_path_package");
-       if (temp) {
-               printf("pkg_installed_path_package : %s\n", temp);
-               free(temp);
-       }
-
-       temp =
-           pkgmgr_info_get_string(pkg_info, "pkg_installed_path_descriptor");
-       if (temp) {
-               printf("pkg_installed_path_descriptor : %s\n", temp);
-               free(temp);
-       }
-
-       temp = pkgmgr_info_get_string(pkg_info, "category");
-       if (temp) {
-               printf("category : %s\n", temp);
-               free(temp);
-       }
-
-       temp = pkgmgr_info_get_string(pkg_info, "min_platform_version");
-       if (temp) {
-               printf("min_platform_version : %s\n", temp);
-               free(temp);
-       }
-
-       temp = pkgmgr_info_get_string(pkg_info, "visible");
-       if (temp) {
-               printf("visible : %s\n", temp);
-               free(temp);
-       }
-
-       temp = pkgmgr_info_get_string(pkg_info, "removable");
-       if (temp) {
-               printf("removable : %s\n", temp);
-               free(temp);
-       }
-
-       temp = pkgmgr_info_get_string(pkg_info, "installed_size");
-       if (temp) {
-               printf("installed_size : %s\n", temp);
-               free(temp);
-       }
-
-       temp = pkgmgr_info_get_string(pkg_info, "installed_time");
-       if (temp) {
-               printf("installed_time : %s\n", temp);
-               free(temp);
-       }
-
-       temp = pkgmgr_info_get_string(pkg_info, "data_size");
-       if (temp) {
-               printf("data_size : %s\n", temp);
-               free(temp);
-       }
-
-       temp = pkgmgr_info_get_string(pkg_info, "optional_id");
-       if (temp) {
-               printf("optional_id : %s\n", temp);
-               free(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_QUIET;
-       pkgmgr_client *pc = NULL;
-       char buf[1024] = {'\0'};
-       int pid = -1;
-       switch (data.request) {
-       case INSTALL_REQ:
-               if (data.pkg_path[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;
-               }
-
-               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,
-                                                 data.pkg_path, NULL, mode,
-                                                 __return_cb, pc);
-               else
-                       ret =
-                           pkgmgr_client_install(pc, data.pkg_type,
-                                                 data.des_path, data.pkg_path,
-                                                 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 UNINSTALL_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;
-               }
-               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 = __is_app_installed(data.pkgid);
-               if (ret == -1) {
-                       printf("package is not installed\n");
-                       break;
-               }
-
-               ret =
-                   pkgmgr_client_uninstall(pc, data.pkg_type, data.pkgid,
-                                           mode, __return_cb, NULL);
-               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.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;
-               }
-
-               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.pkgid, mode);
-               if (ret < 0)
-                       break;
-               ret = data.result;
-               break;
-
-       case ACTIVATE_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");
-                       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 ) {
-                       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.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");
-                       ret = -1;
-                       break;
-               }
-
-               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 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.pkgid[0] != '\0') {
-                       pkgmgr_info *pkg_info =
-                           pkgmgr_info_new(data.pkg_type, data.pkgid);
-                       if (pkg_info == NULL) {
-                               printf("Failed to get pkginfo handle\n");
-                               ret = -1;
-                               break;
-                       }
-                       __print_pkg_info(pkg_info);
-                       ret = pkgmgr_info_free(pkg_info);
-                       break;
-               }
-               if (data.pkg_path[0] != '\0') {
-                       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;
-                               break;
-                       }
-                       __print_pkg_info(pkg_info);
-                       ret = pkgmgr_info_free(pkg_info);
-                       break;
-               }
-               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;
-               break;
-
-       default:
-               printf("Wrong Request\n");
-               ret = -1;
-               break;
-       }
-
-       if (pc) {
-               pkgmgr_client_free(pc);
-               pc = NULL;
-       }
-       return ret;
-}
-
-static int __is_authorized()
-{
-       /* pkgcmd needs root or developer privileges.
-          If launched via fork/exec, the launching program
-          must be running as root */
-
-       uid_t uid = getuid();
-       if ((uid_t) 0 == uid || (uid_t) 5100 == uid)
-               return 1;
-       else
-               return 0;
-}
-
-int main(int argc, char *argv[])
-{
-       optind = 1;
-       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 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.pkgid, '\0', PKG_NAME_STRING_LEN_MAX);
-       memset(data.pkg_type, '\0', PKG_TYPE_STRING_LEN_MAX);
-       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);
-               if (c == -1)
-                       break;  /* Parse end */
-               switch (c) {
-               case 'i':       /* install */
-                       data.request = INSTALL_REQ;
-                       break;
-
-               case 'u':       /* uninstall */
-                       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;
-
-               case 'D':       /* deactivate */
-                       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 's':       /* show */
-                       data.request = SHOW_REQ;
-                       break;
-
-               case 'p':       /* package path */
-                       if (optarg)
-                               strncpy(data.pkg_path, optarg,
-                                       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("path is %s\n", data.pkg_path);
-                       break;
-
-               case 'd':       /* descriptor path */
-                       if (optarg)
-                               strncpy(data.des_path, optarg,
-                                       PKG_NAME_STRING_LEN_MAX - 1);
-                       break;
-
-               case 'n':       /* package name */
-                       if (optarg)
-                               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 - 1);
-                       break;
-
-               case 'T':       /* move type */
-                       data.type = atoi(optarg);
-                       break;
-
-               case 'h':       /* help */
-                       data.request = HELP_REQ;
-                       break;
-
-                       /* Otherwise */
-               case '?':       /* Not an option */
-                       __print_usage();
-                       break;
-
-               case ':':       /* */
-                       break;
-
-               default:
-                       break;
-
-               }
-       }
-       ret = __process_request();
-       if ((ret == -1) && (data.result != 0))
-               data.result = PKGCMD_ERR_ARGUMENT_INVALID;
-
-       if (ret != 0) {
-               __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);
-       }
-
-
-       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;
-}
diff --git a/tool/pkg_fota.c b/tool/pkg_fota.c
deleted file mode 100644 (file)
index deea9e0..0000000
+++ /dev/null
@@ -1,1632 +0,0 @@
-/*
- * 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;
-}
-
-
diff --git a/tool/pkg_getjunkinfo.c b/tool/pkg_getjunkinfo.c
deleted file mode 100644 (file)
index 49a3267..0000000
+++ /dev/null
@@ -1,1077 +0,0 @@
-/*
- * 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;
-}
diff --git a/tool/pkg_getsize.c b/tool/pkg_getsize.c
deleted file mode 100755 (executable)
index 313de5a..0000000
+++ /dev/null
@@ -1,996 +0,0 @@
-/*
- * 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;
-}
diff --git a/tool/pkg_info.c b/tool/pkg_info.c
deleted file mode 100755 (executable)
index e6a84df..0000000
+++ /dev/null
@@ -1,2253 +0,0 @@
-/*
- * 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 <string.h>
-#include <stdlib.h>
-#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_installer.h"
-
-static void __print_usage();
-static int __get_pkg_info(char *pkgid);
-static int __get_app_info(char *appid);
-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_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 __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;
-
-       if (fgets(input_str, sizeof(input_str), stdin) == NULL) {
-               printf("fgets() failed....\n");
-               return -1;
-       }
-
-       if (sscanf(input_str, "%4d", &data) != 1) {
-               printf("Input only integer option....\n");
-               return -1;
-       }
-
-       return data;
-}
-
-
-char *__get_string_input_data(void)
-{
-       char *data = (char *)malloc(1024);
-       if (data == NULL) {
-               printf("Malloc Failed\n");
-               return NULL;
-       }
-       if (fgets(data,1024,stdin) == NULL){
-               printf("Buffer overflow!!! try again\n");
-               exit(-1);
-       }
-       data[strlen(data) - 1] = '\0';
-       return data;
-}
-
-static void __print_usage()
-{
-       printf("For Getting package|App Info\n");
-       printf("\tpkginfo --[pkg|app] <pkgid|appid>\n\n");
-       printf("For Getting list of installed packages\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 <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 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 void __print_arg_filter_usage()
-{
-       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;
-       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 && choice != 1)
-       {
-               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) {
-               case 0:
-                       ret = pkgmgrinfo_appinfo_filter_count(handle, &count);
-                       if (ret < 0) {
-                               printf("pkgmgrinfo_appinfo_filter_count() failed\n");
-                               ret = -1;
-                               goto err;
-                       }
-                       printf("App count = %d\n", count);
-                       break;
-               case 1:
-                       ret = pkgmgrinfo_appinfo_filter_foreach_appinfo(handle, app_func, NULL);
-                       if (ret < 0) {
-                               printf("pkgmgrinfo_appinfo_filter_foreach_appinfo() failed\n");
-                               ret = -1;
-                               goto err;
-                       }
-                       break;
-               case 2:
-                       value = __get_string_input_data();
-                       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;
-                       }
-                       free(value);
-                       value = NULL;
-                       break;
-               case 3:
-                       value = __get_string_input_data();
-                       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;
-                       }
-                       free(value);
-                       value = NULL;
-                       break;
-               case 4:
-                       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:
-                       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:
-                       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:
-                       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:
-                       value = __get_string_input_data();
-                       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;
-                       }
-                       free(value);
-                       value = NULL;
-                       break;
-               case 9:
-                       value = __get_string_input_data();
-                       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:
-                       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 filter property\n");
-                               pkgmgrinfo_appinfo_filter_destroy(handle);
-                       ret = -1;
-                       goto err;
-               }
-       }
-       ret = 0;
-err:
-       pkgmgrinfo_appinfo_filter_destroy(handle);
-       if (value) {
-               free(value);
-               value = NULL;
-       }
-       return ret;
-}
-
-static int __add_pkg_filter()
-{
-       int ret = 0;
-       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 = pkgmgrinfo_appinfo_foreach_category(handle, __app_category_list_cb, NULL);
-       if (ret < 0) {
-               printf("pkgmgrinfo_appinfo_foreach_category() failed\n");
-               pkgmgrinfo_appinfo_destroy_appinfo(handle);
-               return -1;
-       }
-       pkgmgrinfo_appinfo_destroy_appinfo(handle);
-       return 0;
-}
-
-static int __get_app_metadata_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 = pkgmgrinfo_appinfo_foreach_metadata(handle, __app_metadata_list_cb, NULL);
-       if (ret < 0) {
-               printf("pkgmgrinfo_appinfo_foreach_metadata() failed\n");
-               pkgmgrinfo_appinfo_destroy_appinfo(handle);
-               return -1;
-       }
-       pkgmgrinfo_appinfo_destroy_appinfo(handle);
-       return 0;
-}
-
-static int __get_app_control_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 = pkgmgrinfo_appinfo_foreach_appcontrol(handle, __app_control_list_cb, NULL);
-       if (ret < 0) {
-               printf("pkgmgrinfo_appinfo_foreach_appcontrol() failed\n");
-               pkgmgrinfo_appinfo_destroy_appinfo(handle);
-               return -1;
-       }
-       pkgmgrinfo_appinfo_destroy_appinfo(handle);
-       return 0;
-}
-
-static int __set_app_enabled(char *appid, bool enabled)
-{
-       int ret = -1;
-       ret = pkgmgrinfo_appinfo_set_state_enabled(appid, enabled);
-       if (ret < 0) {
-               printf("Failed to get handle\n");
-               return -1;
-       }
-       return 0;
-}
-
-static int __get_app_list(char *pkgid)
-{
-       pkgmgrinfo_pkginfo_h handle;
-       int ret = -1;
-       char *test_data = "test data";
-       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 = pkgmgrinfo_appinfo_get_list(handle, PM_UI_APP, app_func, (void *)test_data);
-       if (ret < 0) {
-               printf("pkgmgrinfo_appinfo_get_list() failed\n");
-       }
-       printf("List of Svc-Apps\n\n");
-       ret = pkgmgrinfo_appinfo_get_list(handle, PM_SVC_APP, app_func, (void *)test_data);
-       if (ret < 0) {
-               printf("pkgmgrinfo_appinfo_get_list() failed\n");
-       }
-       pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
-       return 0;
-}
-
-static int __get_pkg_info(char *pkgid)
-{
-       pkgmgrinfo_pkginfo_h handle;
-       int ret = -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 *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 support_disable = 0;
-       bool system = 0;
-       char* effectimage_type = NULL;
-       pkgmgrinfo_appinfo_h handle;
-       int ret = -1;
-       int installed_time = -1;
-
-       ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle);
-       if (ret < 0) {
-               printf("Failed to get handle\n");
-               return -1;
-       }
-
-       ret = pkgmgrinfo_appinfo_get_pkgid(handle, &package);
-       if (ret < 0) {
-               printf("Failed to get package\n");
-       }
-
-       ret = pkgmgrinfo_appinfo_get_appid(handle, &app_id);
-       if (ret < 0) {
-               printf("Failed to get exec\n");
-       }
-
-       ret = pkgmgrinfo_appinfo_get_label(handle, &label);
-       if (ret < 0) {
-               printf("Failed to get label\n");
-       }
-       ret = pkgmgrinfo_appinfo_get_icon(handle, &icon);
-       if (ret < 0) {
-               printf("Failed to get icon\n");
-       }
-
-       ret = pkgmgrinfo_appinfo_get_exec(handle, &exec);
-       if (ret < 0) {
-               printf("Failed to get exec\n");
-       }
-       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");
-       }
-       ret = pkgmgrinfo_appinfo_get_pkgtype(handle, &pkgtype);
-       if (ret < 0) {
-               printf("Failed to get pkgtyp\n");
-       }
-       ret = pkgmgrinfo_appinfo_is_nodisplay(handle, &nodisplay);
-       if (ret < 0) {
-               printf("Failed to get nodisplay\n");
-       }
-       ret = pkgmgrinfo_appinfo_is_multiple(handle, &multiple);
-       if (ret < 0) {
-               printf("Failed to get multiple\n");
-       }
-       ret = pkgmgrinfo_appinfo_is_taskmanage(handle, &taskmanage);
-       if (ret < 0) {
-               printf("Failed to get taskmanage\n");
-       }
-       ret = pkgmgrinfo_appinfo_get_hwacceleration(handle, &hwacceleration);
-       if (ret < 0) {
-               printf("Failed to get hwacceleration\n");
-       }
-       ret = pkgmgrinfo_appinfo_get_screenreader(handle, &screenreader);
-       if (ret < 0) {
-               printf("Failed to get screenreader\n");
-       }
-       ret = pkgmgrinfo_appinfo_is_onboot(handle, &onboot);
-       if (ret < 0) {
-               printf("Failed to get onboot\n");
-       }
-       ret = pkgmgrinfo_appinfo_is_autorestart(handle, &autorestart);
-       if (ret < 0) {
-               printf("Failed to get autorestart\n");
-       }
-       ret = pkgmgrinfo_appinfo_is_enabled(handle, &enabled);
-       if (ret < 0) {
-               printf("Failed to get enabled\n");
-       }
-       ret = pkgmgrinfo_appinfo_is_preload(handle, &preload);
-       if (ret < 0) {
-               printf("Failed to get preload\n");
-       }
-       ret = pkgmgrinfo_appinfo_is_system(handle, &system);
-       if (ret < 0) {
-               printf("Failed to get system\n");
-       }
-       ret = pkgmgrinfo_appinfo_is_support_disable(handle, &support_disable);
-       if (ret < 0) {
-               printf("Failed to get support-disable\n");
-       }
-       ret = pkgmgrinfo_appinfo_get_effectimage_type(handle, &effectimage_type);
-       if (ret < 0) {
-               printf("Failed to get effectimage-type\n");
-       }
-       ret = pkgmgrinfo_appinfo_get_installed_time(handle, &installed_time);
-       if (ret < 0) {
-               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 (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");
-       }
-
-       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;
-
-}
-
-static int __check_manifest_validation(char *manifest)
-{
-       int ret = 0;
-       if (manifest == NULL) {
-               printf("Manifest file is NULL\n");
-               return -1;
-       }
-       ret = pkgmgr_parser_check_manifest_validation(manifest);
-       if (ret < 0) {
-               printf("check manifest validation failed\n");
-               return -1;
-       }
-       return 0;
-}
-
-int main(int argc, char *argv[])
-{
-       int ret = 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)
-               printf("locale is NULL\n");
-       else {
-               printf("Locale is %s\n", locale);
-               free(locale);
-       }
-
-       locale = NULL;
-       if (argc == 2) {
-               if (strcmp(option, "--listpkg") == 0) {
-                       ret = __get_pkg_list();
-                       if (ret == -1) {
-                               printf("get pkg list failed\n");
-                               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 {
-                               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();
-                       ret = -1;
-                       goto end;
-               }
-       }
-
-       if (argc != 3) {
-               __print_usage();
-               ret = -1;
-               goto end;
-       }
-       if (!argv[1] || !argv[2]) {
-                       __print_usage();
-                       ret = -1;
-                       goto end;
-       }
-
-       if (strcmp(option, "--pkg") == 0) {
-               ret = __get_pkg_info(argv[2]);
-               if (ret == -1) {
-                       printf("get pkg info failed\n");
-                       goto end;
-               }
-       } else if (strcmp(option, "--app") == 0) {
-               ret = __get_app_info(argv[2]);
-               if (ret == -1) {
-                       printf("get app info failed\n");
-                       goto end;
-               }
-       } else if (strcmp(option, "--list") == 0) {
-               ret = __get_app_list(argv[2]);
-               if (ret == -1) {
-                       printf("get app list failed\n");
-                       goto end;
-               }
-       } else if (strcmp(option, "--imd") == 0) {
-               ret = __check_manifest_validation(argv[2]);
-               if (ret == -1) {
-                       printf("check manifest failed\n");
-                       goto end;
-               }
-
-               ret = __insert_manifest_in_db(argv[2]);
-               if (ret == -1) {
-                       printf("insert in db failed\n");
-                       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(option, "--rmd") == 0) {
-               ret = __remove_manifest_from_db(argv[2]);
-               if (ret == -1) {
-                       printf("remove from db failed\n");
-                       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(option, "--getcert") == 0) {
-               ret = __get_certinfo_from_db(argv[2]);
-               if (ret == -1) {
-                       printf("get certinfo from db failed\n");
-                       goto end;
-               }
-       } 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");
-                       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();
-
-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;
-}
diff --git a/tool/pkg_initdb.c b/tool/pkg_initdb.c
deleted file mode 100755 (executable)
index 6efd4a9..0000000
+++ /dev/null
@@ -1,651 +0,0 @@
-/*
- * 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 <sys/types.h>
-#include <sys/wait.h>
-#include <ctype.h>
-#include <sys/time.h>
-#include <time.h>
-
-#include <pkgmgr_parser.h>
-#include <pkgmgr-info.h>
-
-#define OWNER_ROOT 0
-#define GROUP_MENU 6010
-#define BUFSZE 1024
-#define OPT_MANIFEST_DIRECTORY "/opt/share/packages"
-#define USR_MANIFEST_DIRECTORY "/usr/share/packages"
-#define PACKAGE_INFO_DB_FILE "/opt/dbspace/.pkgmgr_parser.db"
-
-#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] "fmt"\n", ##arg);
-
-#ifdef _D
-#undef _D
-#endif
-#define _D(fmt, arg...) fprintf(stderr, "[PKG_INITDB][D] "fmt"\n", ##arg);
-
-static int initdb_count_package(void)
-{
-       int total = 0;
-
-       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)
-{
-       char *package;
-
-       if(manifest == NULL)
-               return NULL;
-
-       package = strdup(manifest);
-       if(package == NULL)
-               return NULL;
-
-
-       if (!strstr(package, ".xml")) {
-               _E("%s is not a manifest file", manifest);
-               free(package);
-               return NULL;
-       }
-
-       return package;
-}
-
-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 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", directory, buf);
-               return -1;
-       }
-
-       _D("Loading manifest files from %s", directory);
-
-       for (ret = readdir_r(dir, &entry, &result);
-                       ret == 0 && result != NULL;
-                       ret = readdir_r(dir, &entry, &result)) {
-               char *manifest;
-
-               if (entry.d_name[0] == '.') continue;
-               total_cnt++;
-
-               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;
-               }
-
-               /*temporarily fixed due to glib abort */
-               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;
-}
-
-
-
-static int initdb_change_perm(const char *db_file)
-{
-       char buf[BUFSZE];
-       char journal_file[BUFSZE];
-       char *files[3];
-       int ret, i;
-
-       files[0] = (char *)db_file;
-       files[1] = journal_file;
-       files[2] = NULL;
-
-       if(db_file == NULL)
-               return -1;
-
-       snprintf(journal_file, sizeof(journal_file), "%s%s", db_file, "-journal");
-
-       for (i = 0; files[i]; i++) {
-               ret = chown(files[i], OWNER_ROOT, OWNER_ROOT);
-               if (ret == -1) {
-                       strerror_r(errno, buf, sizeof(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_IWGRP | S_IROTH);
-               if (ret == -1) {
-                       strerror_r(errno, buf, sizeof(buf));
-                       _E("FAIL : chmod %s 0664, because %s", db_file, buf);
-                       return -1;
-               }
-       }
-
-       return 0;
-}
-
-static int 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. */
-
-       uid_t uid = getuid();
-       if ((uid_t) 0 == uid)
-               return 1;
-       else
-               return 0;
-}
-
-
-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;
-       }
-
-       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 chown.");
-       }
-
-       ret = initdb_update_preload_info();
-       if (ret == -1) {
-               _E("cannot update preload info.");
-       }
-
-       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 get_list.");
-       }
-       _D("================================================================");
-
-       ret = pkgmgr_parser_insert_app_aliasid();
-       if(ret == -1){
-               _E("Insert for app-aliasID DB failed");
-       }
-
-       return 0;
-}
-
-
diff --git a/tool/pkg_magic.c b/tool/pkg_magic.c
deleted file mode 100644 (file)
index e62d599..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-#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;
-}
diff --git a/tool/pkg_magic.h b/tool/pkg_magic.h
deleted file mode 100644 (file)
index eec37a1..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#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);
diff --git a/tool/pkg_mkext.c b/tool/pkg_mkext.c
deleted file mode 100644 (file)
index 8b87257..0000000
+++ /dev/null
@@ -1,255 +0,0 @@
-#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;
-}
-
diff --git a/tool/pkg_recovery.sh.in b/tool/pkg_recovery.sh.in
deleted file mode 100644 (file)
index a7870c3..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/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
-
diff --git a/tool/pkgmgr-install.c b/tool/pkgmgr-install.c
deleted file mode 100755 (executable)
index cfb433c..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * 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 "package-manager.h"
-
-#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_CONTENT "__AUL_MIME_CONTENT__"
-
-#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);
-
-static int __parse_argv(int argc, char **argv, 
-               char **mime_type, char **file_path)
-{
-       static bundle *b = NULL;
-       if (b)
-               bundle_free(b);
-
-       b = bundle_import_from_argv(argc, argv);
-       if (b == NULL) {
-               fprintf(stderr, "bundle for bundle_import_from_argv is NULL");
-       }
-
-       errno = 0;
-
-       if(bundle_get_val(b, KEY_MIME_CONTENT_NEW)) {
-       /*      *mime_type = (char *)bundle_get_val(b, KEY_MIME_TYPE_NEW); */
-               *file_path = (char *)bundle_get_val(b, KEY_MIME_CONTENT_NEW);
-       } else {
-               *mime_type = (char *)bundle_get_val(b, KEY_MIME_TYPE);
-               *file_path = (char *)bundle_get_val(b, KEY_MIME_CONTENT);
-       }
-
-       if (errno)
-               return -1;
-
-       return 0;
-}
-
-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;
-       }
-
-       extension = __get_ext_from_file_path(file_path);
-
-       memset(&ad, 0x0, sizeof(struct appdata));
-       ops.data = &ad;
-       ad.file_path = file_path;
-       ad.extension = (char*)extension;
-
-
-       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");
-
-               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);
-}
-
diff --git a/tool/stress_test.py b/tool/stress_test.py
deleted file mode 100755 (executable)
index 66ab6ae..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-#/usr/bin/python
-import sys, subprocess
-
-num_try = 1
-frontends = {}
-
-if __name__ == "__main__":
-
-       # Run frontends
-       for i in range(num_try):
-               p = subprocess.Popen("pkgmgr_frontend_test -n 2>/dev/null 1>/dev/null".split())
-               frontends[i] = p
-               print("Run %d/%d frontend"%(i, num_try))
-
-
-       # wait frontends to be end
-       done = {}
-       seq = []
-       while True:
-               for i in frontends:
-                       if not done.has_key(i):
-                               p = frontends[i]
-                               ret = p.poll()
-                               if not None == ret:
-                                               print("Frontend #%d is terminated. Returns: %d"%(i, -ret))
-                                               done[i] = -ret
-                                               seq.append(i)
-               if num_try == len(done):
-                       break
-       
-       print("Test done.")
-       for i in frontends:
-               print("Return code of frontend #%d = %d"%(i, done[i]))
-       #print("Terminate seq:")
-       #print(seq)
-
diff --git a/tool/test_junk.c b/tool/test_junk.c
deleted file mode 100644 (file)
index ddc6f5c..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * 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;
-}
index 21e58e0..e36a1cb 100755 (executable)
@@ -61,13 +61,13 @@ extern "C" {
 
 /**
  * @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
- * 
+ *
  */
 
 /**
@@ -84,7 +84,7 @@ extern "C" {
 #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 {
@@ -112,6 +112,8 @@ typedef struct _package_manager_pkg_detail_info_t {
        char label[PKG_LABEL_STRING_LEN_MAX];
        char author[PKG_VALUE_STRING_LEN_MAX];
        char *icon_buf;
+       char *pkg_chksum;
+
        int icon_size;
        GList *privilege_list;
 } package_manager_pkg_detail_info_t;