diff options
Diffstat (limited to 'plugin/osp-installer-plugin.cpp')
-rw-r--r-- | plugin/osp-installer-plugin.cpp | 45 |
1 files changed, 16 insertions, 29 deletions
diff --git a/plugin/osp-installer-plugin.cpp b/plugin/osp-installer-plugin.cpp index 9f5388d..14e7130 100644 --- a/plugin/osp-installer-plugin.cpp +++ b/plugin/osp-installer-plugin.cpp @@ -26,17 +26,16 @@ #include <package-manager-plugin.h> #include <FBaseString.h> -#include <FAppPackageInfo.h> #include <FIoDirectory.h> -#include <FApp_PackageInfoImpl.h> -#include <FApp_PackageManagerImpl.h> +#include <FAppPkg_PackageInfoImpl.h> +#include <FAppPkg_PackageManagerImpl.h> #include <FBase_StringConverter.h> #include "InstallerDefs.h" using namespace Tizen::Base; using namespace Tizen::Io; -using namespace Tizen::App; +using namespace Tizen::App::Package; #ifdef __cplusplus extern "C" @@ -58,10 +57,8 @@ static int pkg_plugin_pkg_is_installed(const char *pkg_name) { int err = PKG_SUCCESS; String packageName(pkg_name); - String appId; - _PackageManagerImpl *pManager = null; - PackageInfo pkgInfo; - result r = E_SUCCESS; + String packageId; + bool installed = true; AppLogTag(OSP_INSTALLER, "[libtpk] pkg_plugin_pkg_is_installed() is called"); AppLogTag(OSP_INSTALLER, "[libtpk] pkg_name=[%s]", pkg_name); @@ -71,19 +68,17 @@ static int pkg_plugin_pkg_is_installed(const char *pkg_name) if (packageName.Contains(PACKAGE_NAME_PREFIX_ORG) == true) { String prefixPackage(PACKAGE_NAME_PREFIX_ORG); - packageName.SubString(prefixPackage.GetLength(), APPID_LENGTH, appId); + packageName.SubString(prefixPackage.GetLength(), APPID_LENGTH, packageId); } else { - packageName.SubString(0, APPID_LENGTH, appId); + packageName.SubString(0, APPID_LENGTH, packageId); } - pManager = _PackageManagerImpl::GetInstance(); - TryCatch(pManager, err = PKG_ERROR, "[osp-installer][libtpk] pManager is null"); - - r = pManager->GetPackageInfo(appId, pkgInfo); - TryCatch(!IsFailed(r), err = PKG_ERROR, "[osp-installer][libtpk] GetPackageInfo is failed"); + installed = _PackageManagerImpl::GetInstance()->IsPackageInstalled(packageId); + TryCatch(installed == true, err = PKG_ERROR, "[osp-installer][libtpk] IsPackageInstalled() is failed"); + AppLogTag(OSP_INSTALLER, "[libtpk] IsPackageInstalled=[%d]", installed); err = PKG_SUCCESS; CATCH: @@ -105,9 +100,7 @@ static int pkg_plugin_get_pkg_detail_info(const char *pkg_name, String packageName(pkg_name); String appId; char* pVersion = null; - _PackageManagerImpl *pManager = null; - PackageInfo pkgInfo; - _PackageInfoImpl* pPkgInfoImpl = null; + _PackageInfoImpl pkgInfoImpl; result r = E_SUCCESS; AppLogTag(OSP_INSTALLER, "[libtpk] pkg_plugin_get_pkg_detail_info() is called"); @@ -127,27 +120,21 @@ static int pkg_plugin_get_pkg_detail_info(const char *pkg_name, packageName.SubString(0, APPID_LENGTH, appId); } - pManager = _PackageManagerImpl::GetInstance(); - TryCatch(pManager, err = PKG_ERROR, "[osp-installer][libtpk] pManager is null"); - - r = pManager->GetPackageInfo(appId, pkgInfo); - TryCatch(!IsFailed(r), err = PKG_ERROR, "[osp-installer][libtpk] GetPackageInfo is failed"); + r = pkgInfoImpl.Construct(appId); + TryCatch(!IsFailed(r), err = PKG_ERROR, "[osp-installer][libtpk] pkgInfoImpl.Construct is failed"); strncpy(pkg_detail_info->pkg_type, "tpk", PKG_TYPE_STRING_LEN_MAX); strncpy(pkg_detail_info->pkg_name, pkg_name, PKG_NAME_STRING_LEN_MAX-1); - pVersion = _StringConverter::CopyToCharArrayN(pkgInfo.GetAppVersion()); + pVersion = _StringConverter::CopyToCharArrayN(pkgInfoImpl.GetVersion()); TryCatch(pVersion, err = PKG_ERROR, "[osp-installer][libtpk] pVersion is null"); strncpy(pkg_detail_info->version, pVersion, PKG_VERSION_STRING_LEN_MAX-1); delete [] pVersion; pVersion = null; - pPkgInfoImpl = _PackageInfoImpl::GetInstance(&pkgInfo); - TryCatch(pPkgInfoImpl, err = PKG_ERROR, "[osp-installer][libtpk] pPkgInfoImpl is null"); - - pkg_detail_info->installed_size = pkg_get_installed_size(pPkgInfoImpl->GetAppRootPath()); - pkg_detail_info->data_size = pkg_get_data_size(pPkgInfoImpl->GetAppRootPath()); + pkg_detail_info->installed_size = pkg_get_installed_size(pkgInfoImpl.GetAppRootPath()); + pkg_detail_info->data_size = pkg_get_data_size(pkgInfoImpl.GetAppRootPath()); pkg_detail_info->app_size = pkg_detail_info->installed_size - pkg_detail_info->data_size; err = PKG_SUCCESS; |