//
-// Open Service Platform
// Copyright (c) 2012 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the License);
#include <FBaseSysLog.h>
#include <FIo.h>
#include <FIoRegistry.h>
+#include <FSecPrivilegeInfo.h>
#include <FSysSystemTime.h>
#include <FBase_StringConverter.h>
using namespace Tizen::Base;
using namespace Tizen::Base::Runtime;
using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
using namespace Tizen::Io;
+using namespace Tizen::Security;
using namespace Tizen::System;
namespace Tizen { namespace App { namespace Package
{
if (pArg->__install)
{
- SysLog(NID_APP, "Installation is Completed. [PackageId = %ls]", pArg->__packageId.GetPointer());
+ SysLog(NID_APP, "Installation is Completed. [Package = %ls]", pArg->__packageId.GetPointer());
pListener->OnPackageInstallationCompleted(pArg->__packageId, PACKAGE_INSTALLATION_RESULT_SUCCESS);
}
else
{
- SysLog(NID_APP, "Uninstallation is Completed. [PackageId = %ls]", pArg->__packageId.GetPointer());
+ SysLog(NID_APP, "Uninstallation is Completed. [Package = %ls]", pArg->__packageId.GetPointer());
pListener->OnPackageUninstallationCompleted(pArg->__packageId, true);
}
}
else
{
- if (pArg->__install)
+ if (pArg->__install == false)
{
- SysLog(NID_APP, "Installation is Completed(Error). [PackageId = %ls]", pArg->__packageId.GetPointer());
- pListener->OnPackageInstallationCompleted(pArg->__packageId, PACKAGE_INSTALLATION_RESULT_INVALID_PACKAGE);
+ SysLog(NID_APP, "Uninstallation is Completed(Error). [Package = %ls]", pArg->__packageId.GetPointer());
+ pListener->OnPackageUninstallationCompleted(pArg->__packageId, false);
+ }
+ }
+ }
+ else if (pArg->__eventKey == L"error")
+ {
+ if (pArg->__install)
+ {
+ if (pArg->__eventValue == L"62")
+ {
+ SysLog(NID_APP, "Installation is Completed(Error = STORAGE_FULL(62)). [Package = %ls]", pArg->__packageId.GetPointer());
+ pListener->OnPackageInstallationCompleted(pArg->__packageId, PACKAGE_INSTALLATION_RESULT_STORAGE_FULL);
}
else
{
- SysLog(NID_APP, "Uninstallation is Completed(Error). [PackageId = %ls]", pArg->__packageId.GetPointer());
- pListener->OnPackageUninstallationCompleted(pArg->__packageId, false);
+ SysLog(NID_APP, "Installation is Completed(Error). [Package = %ls]", pArg->__packageId.GetPointer());
+ pListener->OnPackageInstallationCompleted(pArg->__packageId, PACKAGE_INSTALLATION_RESULT_INVALID_PACKAGE);
}
}
}
SysTryReturn(NID_APP, pAppId, L"", E_OUT_OF_MEMORY, "pAppId is null");
result = pkgmgrinfo_appinfo_get_appinfo(pAppId.get(), &pAppInfoHandle);
- SysTryReturn(NID_APP, result == 0, L"", E_PKG_NOT_INSTALLED, "pkgmgrinfo_appinfo_get_appinfo() failed. result=[%d], appId=[%s]", result, pAppId.get());
+ SysTryReturn(NID_APP, result == 0, L"", E_PKG_NOT_INSTALLED, "pkgmgrinfo_appinfo_get_appinfo() failed. result=[%d], app=[%s]", result, pAppId.get());
result = pkgmgrinfo_appinfo_get_pkgname(pAppInfoHandle, &pPackageId);
}
}
- SysLog(NID_APP, "appId = [%ls], packageId = [%ls]", appId.GetPointer(), packageId.GetPointer());
+ SysLog(NID_APP, "app = [%ls], package = [%ls]", appId.GetPointer(), packageId.GetPointer());
return packageId;
}
_PackageInfoImpl* pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPackageInfo);
r = pPackageInfoImpl->Construct(packageId);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[E_PKG_NOT_INSTALLED] packageId (%ls) is not found.", packageId.GetPointer());
+ SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[E_PKG_NOT_INSTALLED] package (%ls) is not found.", packageId.GetPointer());
return pPackageInfo;
_PackageAppInfoImpl* pPackageAppInfoImpl = _PackageAppInfoImpl::GetInstance(pPackageAppInfo);
r = pPackageAppInfoImpl->Construct(appId);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[E_PKG_NOT_INSTALLED] appId (%ls) is not found.", appId.GetPointer());
+ SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[E_PKG_NOT_INSTALLED] app (%ls) is not found.", appId.GetPointer());
return pPackageAppInfo;
result = pkgmgrinfo_pkginfo_get_pkginfo(pPackageId.get(), &pPackageInfoHandle);
if (result != 0)
{
- SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_pkginfo() failed. result=[%d], packageId=[%s]", result, pPackageId.get());
+ SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_pkginfo() failed. result=[%d], package=[%s]", result, pPackageId.get());
return false;
}
pkgmgrinfo_pkginfo_destroy_pkginfo(pPackageInfoHandle);
}
- SysLog(NID_APP, "packageId = [%ls] is installed.", packageId.GetPointer());
+ SysLog(NID_APP, "package = [%ls] is installed.", packageId.GetPointer());
return true;
}
SysTryReturnResult(NID_APP, extension.IsEmpty() == false, E_INVALID_ARG, "extension is empty.");
std::unique_ptr<char[]> pPackagePath(_StringConverter::CopyToCharArrayN(packagePath));
- SysTryReturnResult(NID_APP, pPackagePath, E_OUT_OF_MEMORY, "pPackagePath is null");
+ SysTryReturnResult(NID_APP, pPackagePath, E_OUT_OF_MEMORY, "pPackagePath is null.");
std::unique_ptr<char[]> pExtension(_StringConverter::CopyToCharArrayN(extension));
- SysTryReturnResult(NID_APP, pExtension, E_OUT_OF_MEMORY, "pExtension is null");
+ SysTryReturnResult(NID_APP, pExtension, E_OUT_OF_MEMORY, "pExtension is null.");
if ((strcasecmp(pExtension.get(), "tpk") == 0) || (strcasecmp(pExtension.get(), "wgt") == 0))
{
- SysLog(NID_APP, "packageId = [%ls], packagePath = [%s], extension = [%s]", packageId.GetPointer(), pPackagePath.get(), pExtension.get());
+ SysLog(NID_APP, "package = [%ls], packagePath = [%s], extension = [%s]", packageId.GetPointer(), pPackagePath.get(), pExtension.get());
}
else
{
return E_SYSTEM;
}
+ // optionalData = 12345abcde
+ String optionalData;
+ optionalData.Append(packageId);
+
+ std::unique_ptr<char[]> pOptionalData(_StringConverter::CopyToCharArrayN(optionalData));
+ SysTryReturnResult(NID_APP, pOptionalData, E_OUT_OF_MEMORY, "pOptionalData is null.");
+
+ SysLog(NID_APP, "optionalData = [%s]", pOptionalData.get());
+
result r = E_SUCCESS;
_PackageManagerProxy packageManagerProxy;
r = packageManagerProxy.Construct();
SysTryReturnResult(NID_APP, __pRequestClient != null, E_SYSTEM, "pkgmgr_client_new(PC_REQUEST) failed");
}
- int res = pkgmgr_client_install(__pRequestClient, pExtension.get(), null, pPackagePath.get(), null, PM_QUIET, InstallationEventHandler, pListener);
+ int res = pkgmgr_client_install(__pRequestClient, pExtension.get(), null, pPackagePath.get(), pOptionalData.get(), PM_QUIET, InstallationEventHandler, pListener);
if (res < PKGMGR_R_OK)
{
SysTryReturnResult(NID_APP, pPackageId != null, E_OUT_OF_MEMORY, "pPackageId is null");
res = pkgmgrinfo_pkginfo_get_pkginfo(pPackageId.get(), &pPackageInfoHandle);
- SysTryReturnResult(NID_APP, res == 0, E_SYSTEM, "pkgmgrinfo_pkginfo_get_pkginfo() failed. result=[%d], packageId=[%s]", res, pPackageId.get());
+ SysTryReturnResult(NID_APP, res == 0, E_SYSTEM, "pkgmgrinfo_pkginfo_get_pkginfo() failed. result=[%d], package=[%s]", res, pPackageId.get());
res = pkgmgrinfo_pkginfo_get_type(pPackageInfoHandle, &pType);
- SysTryReturnResult(NID_APP, res == 0, E_SYSTEM, "pkgmgrinfo_pkginfo_get_type() failed. result=[%d], packageId=[%s]", res, pPackageId.get());
+ SysTryReturnResult(NID_APP, res == 0, E_SYSTEM, "pkgmgrinfo_pkginfo_get_type() failed. result=[%d], package=[%s]", res, pPackageId.get());
if (__pRequestClient == null)
{
}
res = pkgmgr_client_uninstall(__pRequestClient, pType, pPackageId.get(), PM_QUIET, UninstallationEventHandler, pListener);
- SysLog(NID_APP, "pkgmgr_client_uninstall - req_id=[%d], packageId=[%s], type=[%s]", res, pPackageId.get(), pType);
+ SysLog(NID_APP, "pkgmgr_client_uninstall - req=[%d], package=[%s], type=[%s]", res, pPackageId.get(), pType);
if(pPackageInfoHandle)
{
SysTryReturnResult(NID_APP, pPackageId != null, E_OUT_OF_MEMORY, "pPackageId is null");
res = pkgmgrinfo_pkginfo_get_pkginfo(pPackageId.get(), &packageInfoHandle);
- SysTryReturnResult(NID_APP, res == 0, E_SYSTEM, "pkgmgrinfo_pkginfo_get_pkginfo() failed. result=[%d], packageId=[%s]", res, pPackageId.get());
+ SysTryReturnResult(NID_APP, res == 0, E_SYSTEM, "pkgmgrinfo_pkginfo_get_pkginfo() failed. result=[%d], package=[%s]", res, pPackageId.get());
res = pkgmgrinfo_pkginfo_get_type(packageInfoHandle, &pType);
- SysTryReturnResult(NID_APP, res == 0, E_SYSTEM, "pkgmgrinfo_pkginfo_get_type() failed. result=[%d], packageId=[%s]", res, pPackageId.get());
+ SysTryReturnResult(NID_APP, res == 0, E_SYSTEM, "pkgmgrinfo_pkginfo_get_type() failed. result=[%d], package=[%s]", res, pPackageId.get());
res = pkgmgrinfo_pkginfo_get_installed_storage(packageInfoHandle, &storage);
- SysTryReturnResult(NID_APP, res == 0, E_SYSTEM, "pkgmgrinfo_pkginfo_get_installed_storage() failed. result=[%d], packageId=[%s]", res, pPackageId.get());
+ SysTryReturnResult(NID_APP, res == 0, E_SYSTEM, "pkgmgrinfo_pkginfo_get_installed_storage() failed. result=[%d], package=[%s]", res, pPackageId.get());
if (storage == PMINFO_EXTERNAL_STORAGE)
{
SysTryReturnResult(NID_APP, __pRequestClient != null, E_SYSTEM, "pkgmgr_client_new(PC_REQUEST) failed");
}
- res = pkgmgr_client_move(__pRequestClient, pType, pPackageId.get(), PM_MOVE_TO_SDCARD, PM_QUIET);
+ SysLog(NID_APP, "pkgmgr_client_request_service(PM_REQUEST_MOVE, 1, %s, %s)", pType, pPackageId.get());
+ res = pkgmgr_client_request_service(PM_REQUEST_MOVE, 1, __pRequestClient, pType, pPackageId.get(), null, null, null);
- if(packageInfoHandle)
+ if (packageInfoHandle)
{
pkgmgrinfo_pkginfo_destroy_pkginfo(packageInfoHandle);
}
SysTryReturnResult(NID_APP, pPackageId != null, E_OUT_OF_MEMORY, "pPackageId is null");
res = pkgmgrinfo_pkginfo_get_pkginfo(pPackageId.get(), &packageInfoHandle);
- SysTryReturnResult(NID_APP, res == 0, E_SYSTEM, "pkgmgrinfo_pkginfo_get_pkginfo() failed. result=[%d], packageId=[%s]", res, pPackageId.get());
+ SysTryReturnResult(NID_APP, res == 0, E_SYSTEM, "pkgmgrinfo_pkginfo_get_pkginfo() failed. result=[%d], package=[%s]", res, pPackageId.get());
res = pkgmgrinfo_pkginfo_get_type(packageInfoHandle, &pType);
- SysTryReturnResult(NID_APP, res == 0, E_SYSTEM, "pkgmgrinfo_pkginfo_get_type() failed. result=[%d], packageId=[%s]", res, pPackageId.get());
+ SysTryReturnResult(NID_APP, res == 0, E_SYSTEM, "pkgmgrinfo_pkginfo_get_type() failed. result=[%d], package=[%s]", res, pPackageId.get());
res = pkgmgrinfo_pkginfo_get_installed_storage(packageInfoHandle, &storage);
- SysTryReturnResult(NID_APP, res == 0, E_SYSTEM, "pkgmgrinfo_pkginfo_get_installed_storage() failed. result=[%d], packageId=[%s]", res, pPackageId.get());
+ SysTryReturnResult(NID_APP, res == 0, E_SYSTEM, "pkgmgrinfo_pkginfo_get_installed_storage() failed. result=[%d], package=[%s]", res, pPackageId.get());
if (storage == PMINFO_INTERNAL_STORAGE)
{
SysTryReturnResult(NID_APP, __pRequestClient != null, E_SYSTEM, "pkgmgr_client_new(PC_REQUEST) failed");
}
- res = pkgmgr_client_move(__pRequestClient, pType, pPackageId.get(), PM_MOVE_TO_INTERNAL, PM_QUIET);
+ SysLog(NID_APP, "pkgmgr_client_request_service(PM_REQUEST_MOVE, 0, %s, %s)", pType, pPackageId.get());
+ res = pkgmgr_client_request_service(PM_REQUEST_MOVE, 0, __pRequestClient, pType, pPackageId.get(), null, null, null);
- if(packageInfoHandle)
+ if (packageInfoHandle)
{
pkgmgrinfo_pkginfo_destroy_pkginfo(packageInfoHandle);
}
int
_PackageManagerImpl::InstallationEventHandler(int reqId, const char* pType, const char* pPackageId, const char* pKey, const char* pVal, const void* pMsg, void* pData)
{
- SysLog(NID_APP, "reqId[%d], Type[%s], PackageId[%s], Key[%s], Val[%s]", reqId, pType, pPackageId, pKey, pVal);
+ SysLog(NID_APP, "reqId[%d], Type[%s], Package[%s], Key[%s], Val[%s]", reqId, pType, pPackageId, pKey, pVal);
if (pData)
{
pListener->OnPackageInstallationResponseReceived(pPackageId, PACKAGE_INSTALLATION_RESULT_SUCCESS);
SysLog(NID_APP, "OnPackageInstallationResponseReceived(PACKAGE_INSTALLATION_RESULT_SUCCESS)");
}
+
+ delete pListener;
+ }
+ else if (strcmp(pKey, "error") == 0)
+ {
+ if (strcmp(pVal, "62") == 0)
+ {
+ pListener->OnPackageInstallationResponseReceived(pPackageId, PACKAGE_INSTALLATION_RESULT_STORAGE_FULL);
+ SysLog(NID_APP, "OnPackageInstallationResponseReceived(PACKAGE_INSTALLATION_RESULT_STORAGE_FULL)");
+ }
else
{
pListener->OnPackageInstallationResponseReceived(pPackageId, PACKAGE_INSTALLATION_RESULT_INVALID_PACKAGE);
SysLog(NID_APP, "OnPackageInstallationResponseReceived(PACKAGE_INSTALLATION_RESULT_INVALID_PACKAGE)");
}
-
- delete pListener;
}
else if (strcmp(pKey, "install_percent") == 0)
{
int
_PackageManagerImpl::UninstallationEventHandler(int reqId, const char* pType, const char* pPackageId, const char* pKey, const char* pVal, const void* pMsg, void* pData)
{
- SysLog(NID_APP, "reqId[%d], Type[%s], PackageId[%s], Key[%s], Val[%s]", reqId, pType, pPackageId, pKey, pVal);
+ SysLog(NID_APP, "reqId[%d], Type[%s], Package[%s], Key[%s], Val[%s]", reqId, pType, pPackageId, pKey, pVal);
if (pData)
{
_package_manager_pkg_detail_info_t* pPkgInfo = (_package_manager_pkg_detail_info_t*) pPkgmgrInfo;
_PackageInfoImpl* pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPackageInfo.get());
- SysLog(NID_APP, "id(%s), version(%s), label(%s), description(%s), author(%s)", pPkgInfo->pkgid, pPkgInfo->version, pPkgInfo->label, pPkgInfo->pkg_description, pPkgInfo->author);
+ SysLog(NID_APP, "package(%s), version(%s), label(%s), description(%s), author(%s), icon_size(%d), pkgname(%s)", pPkgInfo->pkgid, pPkgInfo->version, pPkgInfo->label,
+ pPkgInfo->pkg_description, pPkgInfo->author, pPkgInfo->icon_size, pPkgInfo->pkg_name);
pPackageInfoImpl->SetType(PACKAGE_TYPE_WGT);
pPackageInfoImpl->SetId(pPkgInfo->pkgid);
pPackageInfoImpl->SetDisplayName(pPkgInfo->label);
pPackageInfoImpl->SetDescription(pPkgInfo->pkg_description);
pPackageInfoImpl->SetAuthor(pPkgInfo->author);
- // icon
- // privilege
+ pPackageInfoImpl->SetMainAppId(pPkgInfo->pkg_name);
+
+ if (IsHybridPackage(filePath) == true)
+ {
+ PackageInfo hybridServiceInfo;
+ _PackageParser packageParser;
+
+ res = packageParser.Construct(&hybridServiceInfo);
+ SysTryReturn(NID_APP, res, null, E_PARSING_FAILED, "Construct() is failed. [%s]", pPackagePath.get());
+
+ res = packageParser.Parse(filePath);
+ SysTryReturn(NID_APP, res, null, E_PARSING_FAILED, "Parse() is failed. [%s]", pPackagePath.get());
+
+ IList* pList = hybridServiceInfo.GetPrivilegeListN();
+ if (pList)
+ {
+ for (int i = 0; i < pList->GetCount(); i++)
+ {
+ PrivilegeInfo* pPrivilegeInfo = dynamic_cast < PrivilegeInfo* >(pList->GetAt(i));
+ if (pPrivilegeInfo)
+ {
+ String privilege = pPrivilegeInfo->GetId();
+ pPackageInfoImpl->AddPrivilege(*new (std::nothrow) String(privilege));
+ SysLog(NID_APP, "privilege[%ls] is added for hybrid.", privilege.GetPointer());
+ }
+ }
+ }
+ }
+
+ if (pPkgInfo->privilege_list)
+ {
+ GList* pList = null;
+ pList = g_list_first(pPkgInfo->privilege_list);
+ while (pList)
+ {
+ char* pPrivilege = (char*)pList->data;
+ if (pPrivilege)
+ {
+ pPackageInfoImpl->AddPrivilege(*new (std::nothrow) String(pPrivilege));
+ free(pPrivilege);
+ }
+ pList = g_list_next(pList);
+ }
+ g_list_free(pPkgInfo->privilege_list);
+ }
+
+ std::unique_ptr< PackageAppInfo > pPackageAppInfo(new (std::nothrow) PackageAppInfo);
+ if (pPackageAppInfo)
+ {
+ _PackageAppInfoImpl* pPackageAppInfoImpl = _PackageAppInfoImpl::GetInstance(pPackageAppInfo.get());
+
+ pPackageAppInfoImpl->SetAppId(pPkgInfo->pkg_name);
+ pPackageAppInfoImpl->SetAppName(pPkgInfo->label);
+ pPackageAppInfoImpl->SetAppDisplayName(pPkgInfo->label);
+ pPackageAppInfoImpl->SetMainApp(true);
+ if ((pPkgInfo->icon_buf) && (pPkgInfo->icon_size > 0))
+ {
+ pPackageAppInfoImpl->SetAppMenuIconBuffer(pPkgInfo->icon_buf, pPkgInfo->icon_size);
+ }
+
+ pPackageInfoImpl->AddPackageAppInfo(*pPackageAppInfo.release());
+ }
+ else
+ {
+ SysLog(NID_APP, "pPackageAppInfo instance must not be null.");
+ pkgmgr_client_free_pkginfo(pPkgmgrInfo);
+ return null;
+ }
pkgmgr_client_free_pkginfo(pPkgmgrInfo);
}
std::unique_ptr<IMapEnumerator> pEnum(packageFilterMap.GetMapEnumeratorN());
SysTryReturn(NID_APP, pEnum, null, E_INVALID_ARG, "GetMapEnumeratorN() is failed.");
- int res = 0;
- ArrayList* pList = null;
+ std::unique_ptr< ArrayList > pList(new (std::nothrow) ArrayList());
+ SysTryReturn(NID_APP, pList, null, E_OUT_OF_MEMORY, "pList is null.");
+
+ pList->Construct();
+
+ int res = PMINFO_R_OK;
pkgmgrinfo_pkginfo_filter_h handle = null;
res = pkgmgrinfo_pkginfo_filter_create(&handle);
res = pkgmgrinfo_pkginfo_filter_add_bool(handle, PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING, value);
SysTryCatch(NID_APP, res == PMINFO_R_OK, , E_SYSTEM, "pkgmgrinfo_pkginfo_filter_add_bool(APPSETTING, %d) is failed. [%d]", value, res);
}
+ else if ((*pKey) == PACKAGE_FILTER_TPK)
+ {
+ SysTryCatch(NID_APP, value == true, , E_SYSTEM, "Value(false) is invalid for PACKAGE_FILTER_TPK.");
+
+ res = pkgmgrinfo_pkginfo_filter_add_string(handle, PMINFO_PKGINFO_PROP_PACKAGE_TYPE, "tpk");
+ SysTryCatch(NID_APP, res == PMINFO_R_OK, , E_SYSTEM, "pkgmgrinfo_pkginfo_filter_add_string(TYPE, tpk) is failed. [%d]", res);
+ }
else if ((*pKey) == PACKAGE_FILTER_EXTERNAL_STORAGE)
{
String installedStorage;
}
}
- pList = new (std::nothrow) ArrayList();
- SysTryCatch(NID_APP, pList, , E_OUT_OF_MEMORY, "ArrayList creation failure.");
- pList->Construct();
-
- res = pkgmgrinfo_pkginfo_filter_foreach_pkginfo(handle, PackageInfoHandler, pList);
- if (res != 0)
- {
- SysLog(NID_APP, "pkgmgrinfo_pkginfo_filter_foreach_pkginfo() is failed. result = [%d]", res);
-
- pList->RemoveAll(true);
- pList = null;
- }
+ res = pkgmgrinfo_pkginfo_filter_foreach_pkginfo(handle, PackageInfoHandler, pList.get());
+ SysTryCatch(NID_APP, res == PMINFO_R_OK, , E_SYSTEM, "pkgmgrinfo_pkginfo_filter_foreach_pkginfo() failed. [%d]", res);
CATCH:
if (handle)
pkgmgrinfo_pkginfo_filter_destroy(handle);
}
- return pList;
+ if (pList->GetCount() <= 0)
+ {
+ SysLog(NID_APP, "pList's count is 0.");
+ return null;
+ }
+
+ return pList.release();
}
IList*
{
SysTryReturn(NID_APP, packageAppFilterMap.GetCount() > 0, null, E_INVALID_ARG, "packageAppFilterMap.GetCount() is invalid.");
- std::unique_ptr<IMapEnumerator> pEnum(packageAppFilterMap.GetMapEnumeratorN());
+ std::unique_ptr< IMapEnumerator > pEnum(packageAppFilterMap.GetMapEnumeratorN());
SysTryReturn(NID_APP, pEnum, null, E_INVALID_ARG, "GetMapEnumeratorN() is failed.");
+ std::unique_ptr< ArrayList > pList(new (std::nothrow) ArrayList());
+ SysTryReturn(NID_APP, pList, null, E_OUT_OF_MEMORY, "pList is null.");
+
+ pList->Construct();
+
int res = 0;
- ArrayList* pList = null;
+ bool definedKey = false;
+ bool metadataKey = false;
+ ArrayList list;
+ ArrayList metadataList;
+ ArrayList appIdList;
pkgmgrinfo_appinfo_filter_h handle = null;
+ pkgmgrinfo_appinfo_metadata_filter_h metaHandle = null;
res = pkgmgrinfo_appinfo_filter_create(&handle);
- SysTryReturn(NID_APP, res == PMINFO_R_OK, null, E_SYSTEM, "pkgmgrinfo_appinfo_filter_create() is failed. [%d]", res);
+ SysTryCatch(NID_APP, res == PMINFO_R_OK, , E_SYSTEM, "pkgmgrinfo_appinfo_filter_create() is failed. [%d]", res);
+
+ res = pkgmgrinfo_appinfo_metadata_filter_create(&metaHandle);
+ SysTryCatch(NID_APP, res == PMINFO_R_OK, , E_SYSTEM, "pkgmgrinfo_appinfo_metadata_filter_create() is failed. [%d]", res);
while(pEnum->MoveNext() == E_SUCCESS)
{
- String* pKey = static_cast<String*>(pEnum->GetKey());
+ String* pKey = static_cast< String* >(pEnum->GetKey());
SysTryCatch(NID_APP, pKey, , E_INVALID_ARG, "GetKey() is failed.");
if ((*pKey) == PACKAGE_APP_FILTER_MENUICON_VISIBLE)
{
- Boolean* pVal = static_cast<Boolean*>(pEnum->GetValue());
+ definedKey = true;
+
+ Boolean* pVal = static_cast< Boolean* >(pEnum->GetValue());
SysTryCatch(NID_APP, pVal, , E_INVALID_ARG, "GetValue() is failed.");
bool nodisplay = !(pVal->ToBool());
res = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_NODISPLAY, nodisplay);
SysTryCatch(NID_APP, res == PMINFO_R_OK, , E_SYSTEM, "pkgmgrinfo_pkginfo_filter_add_bool(NODISPLAY, %d) is failed. [%d]", nodisplay, res);
}
- else if ((*pKey) == PACKAGE_APP_FILTER_CATEGORY)
+#if 0
+ else if ((*pKey) == PACKAGE_APP_FILTER_LAUNCH_ONBOOT)
+ {
+ definedKey = true;
+
+ Boolean* pVal = static_cast< Boolean* >(pEnum->GetValue());
+ SysTryCatch(NID_APP, pVal, , E_INVALID_ARG, "GetValue() is failed.");
+
+ bool value = pVal->ToBool();
+ SysLog(NID_APP, "Key[%ls], Value[%d]", pKey->GetPointer(), value);
+
+ res = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_ONBOOT, value);
+ SysTryCatch(NID_APP, res == PMINFO_R_OK, , E_SYSTEM, "pkgmgrinfo_pkginfo_filter_add_bool(ONBOOT, %d) is failed. [%d]", value, res);
+ }
+ else if ((*pKey) == PACKAGE_APP_FILTER_AUTO_RESTART)
+ {
+ definedKey = true;
+
+ Boolean* pVal = static_cast< Boolean* >(pEnum->GetValue());
+ SysTryCatch(NID_APP, pVal, , E_INVALID_ARG, "GetValue() is failed.");
+
+ bool value = pVal->ToBool();
+ SysLog(NID_APP, "Key[%ls], Value[%d]", pKey->GetPointer(), value);
+
+ res = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_AUTORESTART, value);
+ SysTryCatch(NID_APP, res == PMINFO_R_OK, , E_SYSTEM, "pkgmgrinfo_pkginfo_filter_add_bool(AUTORESTART, %d) is failed. [%d]", value, res);
+ }
+#endif
+ else if ((*pKey) == PACKAGE_APP_FILTER_LAUNCHING_HISTORY_VISIBLE)
+ {
+ definedKey = true;
+
+ Boolean* pVal = static_cast< Boolean* >(pEnum->GetValue());
+ SysTryCatch(NID_APP, pVal, , E_INVALID_ARG, "GetValue() is failed.");
+
+ bool value = pVal->ToBool();
+ SysLog(NID_APP, "Key[%ls], Value[%d]", pKey->GetPointer(), value);
+
+ res = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_TASKMANAGE, value);
+ SysTryCatch(NID_APP, res == PMINFO_R_OK, , E_SYSTEM, "pkgmgrinfo_pkginfo_filter_add_bool(TASKMANAGE, %d) is failed. [%d]", value, res);
+ }
+ else if ((*pKey) == PACKAGE_APP_FILTER_LAUNCH_CONDITION)
+ {
+ definedKey = true;
+
+ Boolean* pVal = static_cast< Boolean* >(pEnum->GetValue());
+ SysTryCatch(NID_APP, pVal, , E_INVALID_ARG, "GetValue() is failed.");
+
+ bool value = pVal->ToBool();
+ SysLog(NID_APP, "Key[%ls], Value[%d]", pKey->GetPointer(), value);
+
+ res = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION, value);
+ SysTryCatch(NID_APP, res == PMINFO_R_OK, , E_SYSTEM, "pkgmgrinfo_pkginfo_filter_add_bool(LAUNCHCONDITION, %d) is failed. [%d]", value, res);
+ }
+ else if ((*pKey) == PACKAGE_APP_FILTER_CATEGORY_HOMEAPP || (*pKey) == PACKAGE_APP_FILTER_CATEGORY_LOCKAPP
+ || (*pKey) == PACKAGE_APP_FILTER_CATEGORY_MENUAPP)
+ {
+ definedKey = true;
+
+ std::unique_ptr<char[]> pDefinedKey(_StringConverter::CopyToCharArrayN(*pKey));
+ SysTryCatch(NID_APP, pDefinedKey, , E_OUT_OF_MEMORY, "pDefinedKey is null.");
+
+ Boolean* pVal = static_cast< Boolean* >(pEnum->GetValue());
+ SysTryCatch(NID_APP, pVal, , E_INVALID_ARG, "GetValue() is failed.");
+
+ SysLog(NID_APP, "Key[%ls], Value[%d]", pKey->GetPointer(), pVal->ToBool());
+ SysTryCatch(NID_APP, pVal->ToBool() == true, , E_INVALID_ARG, "Value(false) is not allowed.");
+
+ res = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_CATEGORY, pDefinedKey.get());
+ SysTryCatch(NID_APP, res == PMINFO_R_OK, , E_SYSTEM, "pkgmgrinfo_appinfo_filter_add_string(CATEGORY, %s) is failed. [%d]", pDefinedKey.get(), res);
+ }
+ else
{
- String* pVal = static_cast<String*>(pEnum->GetValue());
+ metadataKey = true;
+
+ String* pVal = static_cast< String* >(pEnum->GetValue());
SysTryCatch(NID_APP, pVal, , E_INVALID_ARG, "GetValue() is failed.");
SysLog(NID_APP, "Key[%ls], Value[%ls]", pKey->GetPointer(), pVal->GetPointer());
+ std::unique_ptr<char[]> pMetaKey(_StringConverter::CopyToCharArrayN(*pKey));
+ SysTryCatch(NID_APP, pMetaKey, , E_OUT_OF_MEMORY, "pMetaKey is null.");
+
std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(*pVal));
SysTryCatch(NID_APP, pValue, , E_OUT_OF_MEMORY, "pValue is null.");
- res = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_CATEGORY, pValue.get());
- SysTryCatch(NID_APP, res == PMINFO_R_OK, , E_SYSTEM, "pkgmgrinfo_appinfo_filter_add_string(CATEGORY, %s) is failed. [%d]", pValue.get(), res);
+ if ((*pVal) == L"*")
+ {
+ res = pkgmgrinfo_appinfo_metadata_filter_add(metaHandle, pMetaKey.get(), null);
+ SysTryCatch(NID_APP, res == PMINFO_R_OK, , E_SYSTEM, "pkgmgrinfo_appinfo_metadata_filter_add(%s, null) is failed. [%d]", pMetaKey.get(), res);
+ }
+ else
+ {
+ res = pkgmgrinfo_appinfo_metadata_filter_add(metaHandle, pMetaKey.get(), pValue.get());
+ SysTryCatch(NID_APP, res == PMINFO_R_OK, , E_SYSTEM, "pkgmgrinfo_appinfo_metadata_filter_add(%s, %s) is failed. [%d]", pMetaKey.get(), pValue.get(), res);
+ }
}
- else
+ }
+
+ if ((definedKey == true) && (metadataKey == false))
+ {
+ res = pkgmgrinfo_appinfo_filter_foreach_appinfo(handle, PackageAppInfoHandler, pList.get());
+ SysTryCatch(NID_APP, res == PMINFO_R_OK, , E_SYSTEM, "pkgmgrinfo_appinfo_filter_foreach_appinfo() failed. [%d]", res);
+ }
+ else if ((definedKey == false) && (metadataKey == true))
+ {
+ res = pkgmgrinfo_appinfo_metadata_filter_foreach(metaHandle, PackageAppInfoMetadataHandler, pList.get());
+ SysTryCatch(NID_APP, res == PMINFO_R_OK, , E_SYSTEM, "pkgmgrinfo_appinfo_metadata_filter_foreach() failed. [%d]", res);
+ }
+ else
+ {
+ list.Construct();
+
+ res = pkgmgrinfo_appinfo_filter_foreach_appinfo(handle, PackageAppInfoHandler, &list);
+ if (res != PMINFO_R_OK)
{
- SysTryCatch(NID_APP, false, , E_INVALID_ARG, "Invalid key(%ls)", pKey->GetPointer());
+ SysLog(NID_APP, "pkgmgrinfo_appinfo_filter_foreach_appinfo() is failed. result = [%d]", res);
+ goto CATCH;
}
- }
- pList = new (std::nothrow) ArrayList();
- SysTryCatch(NID_APP, pList, , E_OUT_OF_MEMORY, "ArrayList creation failure.");
- pList->Construct();
+ metadataList.Construct();
- res = pkgmgrinfo_appinfo_filter_foreach_appinfo(handle, PackageAppInfoHandler, pList);
- if (res != 0)
- {
- SysLog(NID_APP, "pkgmgrinfo_appinfo_filter_foreach_appinfo() is failed. result = [%d]", res);
+ res = pkgmgrinfo_appinfo_metadata_filter_foreach(metaHandle, PackageAppInfoMetadataHandler, &metadataList);
+ if (res != PMINFO_R_OK)
+ {
+ SysLog(NID_APP, "pkgmgrinfo_appinfo_metadata_filter_foreach() is failed. result = [%d]", res);
+ goto CATCH;
+ }
- pList->RemoveAll(true);
- pList = null;
+ for (int i = 0; i < list.GetCount(); i++)
+ {
+ PackageAppInfo* pPackageAppInfo = dynamic_cast < PackageAppInfo* >(list.GetAt(i));
+ if (pPackageAppInfo)
+ {
+ SysLog(NID_APP, "PackageAppFilter - App [%ls]", pPackageAppInfo->GetAppId().GetPointer());
+
+ std::unique_ptr< AppId > pAppId(new (std::nothrow) AppId(pPackageAppInfo->GetAppId()));
+ appIdList.Add(pAppId.release());
+ }
+ }
+
+ for (int j = 0; j < metadataList.GetCount(); j++)
+ {
+ PackageAppInfo* pPackageAppInfo = dynamic_cast < PackageAppInfo* >(metadataList.GetAt(j));
+ if (pPackageAppInfo)
+ {
+ AppId appId = pPackageAppInfo->GetAppId();
+
+ if (appIdList.Contains(appId) == true)
+ {
+ SysLog(NID_APP, "App [%ls] is matched.", appId.GetPointer());
+
+ std::unique_ptr< PackageAppInfo > pAppInfo(new (std::nothrow) PackageAppInfo);
+ SysTryCatch(NID_APP, pAppInfo, , E_OUT_OF_MEMORY, "pAppInfo is null.");
+
+ _PackageAppInfoImpl* pPackageAppInfoImpl = _PackageAppInfoImpl::GetInstance(pAppInfo.get());
+ pPackageAppInfoImpl->Construct(appId);
+
+ pList->Add(pAppInfo.release());
+ }
+ else
+ {
+ SysLog(NID_APP, "App [%ls] is not matched.", pPackageAppInfo->GetAppId().GetPointer());
+ }
+ }
+ }
}
CATCH:
pkgmgrinfo_appinfo_filter_destroy(handle);
}
- return pList;
+ if (metaHandle)
+ {
+ pkgmgrinfo_appinfo_metadata_filter_destroy(metaHandle);
+ }
+
+ if (pList->GetCount() <= 0)
+ {
+ SysLog(NID_APP, "pList's count is 0.");
+ return null;
+ }
+
+ return pList.release();
}
IList*
_PackageManagerImpl::GetPackageAppInfoListN(const IMap& packageFilterMap, const IMap& packageAppFilterMap) const
{
- SysTryReturn(NID_APP, packageFilterMap.GetCount() > 0, null, E_INVALID_ARG, "packageFilterMap.GetCount() is invalid.");
- SysTryReturn(NID_APP, packageAppFilterMap.GetCount() > 0, null, E_INVALID_ARG, "packageAppFilterMap.GetCount() is invalid.");
+ SysTryReturn(NID_APP, packageFilterMap.GetCount() > 0, null, E_INVALID_ARG, "packageFilterMap Count is invalid.");
+ SysTryReturn(NID_APP, packageAppFilterMap.GetCount() > 0, null, E_INVALID_ARG, "packageAppFilterMap Count is invalid.");
- return null;
+ ArrayList appIdList;
+
+ std::unique_ptr< IList > pPackageFilterList(GetPackageInfoListN(packageFilterMap));
+ if (pPackageFilterList == null)
+ {
+ SysLog(NID_APP, "GetPackageInfoListN(packageFilterMap) is null.");
+ return null;
+ }
+
+ for (int i = 0; i < pPackageFilterList->GetCount(); i++)
+ {
+ PackageInfo* pPackageInfo = dynamic_cast < PackageInfo* >(pPackageFilterList->GetAt(i));
+ if (pPackageInfo)
+ {
+ std::unique_ptr< IList > pPackageAppInfoList(pPackageInfo->GetPackageAppInfoListN());
+ if (pPackageAppInfoList)
+ {
+ for (int j = 0; j < pPackageAppInfoList->GetCount(); j++)
+ {
+ PackageAppInfo* pPackageAppInfo = dynamic_cast < PackageAppInfo* >(pPackageAppInfoList->GetAt(j));
+ if (pPackageAppInfo)
+ {
+ SysLog(NID_APP, "PackageFilter - App [%ls]", pPackageAppInfo->GetAppId().GetPointer());
+
+ std::unique_ptr< AppId > pAppId(new (std::nothrow) AppId(pPackageAppInfo->GetAppId()));
+ appIdList.Add(pAppId.release());
+ }
+ }
+ }
+ }
+ }
+
+ std::unique_ptr< ArrayList > pList(new (std::nothrow) ArrayList);
+ SysTryReturn(NID_APP, pList, null, E_OUT_OF_MEMORY, "pList is null.");
+
+ std::unique_ptr< IList > pAppFilterList(GetPackageAppInfoListN(packageAppFilterMap));
+ if (pAppFilterList == null)
+ {
+ SysLog(NID_APP, "GetPackageAppInfoListN(packageAppFilterMap) is null.");
+ return null;
+ }
+
+ for (int k = 0; k < pAppFilterList->GetCount(); k++)
+ {
+ PackageAppInfo* pPackageAppInfo = dynamic_cast < PackageAppInfo* >(pAppFilterList->GetAt(k));
+ if (pPackageAppInfo)
+ {
+ AppId appId = pPackageAppInfo->GetAppId();
+ SysLog(NID_APP, "AppFilter - App [%ls]", appId.GetPointer());
+
+ if (appIdList.Contains(appId) == true)
+ {
+ SysLog(NID_APP, "App [%ls] is matched.", appId.GetPointer());
+
+ std::unique_ptr< PackageAppInfo > pPackageAppInfo(new (std::nothrow) PackageAppInfo);
+ SysTryReturn(NID_APP, pPackageAppInfo, null, E_OUT_OF_MEMORY, "PackageAppInfo is null.");
+
+ _PackageAppInfoImpl* pPackageAppInfoImpl = _PackageAppInfoImpl::GetInstance(pPackageAppInfo.get());
+ pPackageAppInfoImpl->Construct(appId);
+
+ pList->Add(pPackageAppInfo.release());
+ }
+ else
+ {
+ SysLog(NID_APP, "App [%ls] is not matched.", pPackageAppInfo->GetAppId().GetPointer());
+ }
+ }
+ }
+
+ if (pList->GetCount() <= 0)
+ {
+ SysLog(NID_APP, "pList's count is 0.");
+ return null;
+ }
+
+ return pList.release();
}
int
res = pkgmgrinfo_appinfo_get_appid(handle, &pAppId);
SysTryReturn(NID_APP, res == PMINFO_R_OK, 0, E_SYSTEM, "pkgmgrinfo_appinfo_get_appid is failed. [%d]", res);
+ SysLog(NID_APP, "app = [%s]", pAppId);
+
std::unique_ptr<PackageAppInfo> pPackageAppInfo(new (std::nothrow) PackageAppInfo);
SysTryReturn(NID_APP, pPackageAppInfo, 0, E_OUT_OF_MEMORY, "pPackageAppInfo instance must not be null.");
return 0;
}
+int
+_PackageManagerImpl::PackageAppInfoMetadataHandler(const pkgmgrinfo_appinfo_h handle, void* pUserData)
+{
+ SysTryReturn(NID_APP, handle, 0, E_SYSTEM, "handle must not be null.");
+ SysTryReturn(NID_APP, pUserData, 0, E_SYSTEM, "pUserData must not be null.");
+
+ result r = E_SUCCESS;
+ int res = PMINFO_R_OK;
+ char* pAppId = null;
+ ArrayList* pList = (ArrayList*)pUserData;
+
+ res = pkgmgrinfo_appinfo_get_appid(handle, &pAppId);
+ SysTryReturn(NID_APP, res == PMINFO_R_OK, 0, E_SYSTEM, "pkgmgrinfo_appinfo_get_appid is failed. [%d]", res);
+
+ SysLog(NID_APP, "app = [%s]", pAppId);
+
+ std::unique_ptr< PackageAppInfo > pPackageAppInfo(new (std::nothrow) PackageAppInfo);
+ SysTryReturn(NID_APP, pPackageAppInfo, 0, E_OUT_OF_MEMORY, "pPackageAppInfo instance must not be null.");
+
+ _PackageAppInfoImpl* pPackageAppInfoImpl = _PackageAppInfoImpl::GetInstance(pPackageAppInfo.get());
+ r = pPackageAppInfoImpl->Construct(pAppId);
+ SysTryReturn(NID_APP, r == E_SUCCESS, 0, E_SYSTEM, "Construct(%s) is failed.", pAppId);
+
+ pList->Add(*pPackageAppInfo.release());
+
+ return 0;
+}
+
+bool
+_PackageManagerImpl::IsHybridPackage(const String& filePath) const
+{
+ SysTryReturn(NID_APP, filePath.IsEmpty() == false, false, E_INVALID_ARG, "filePath is empty.");
+
+ bool res = true;
+ FileUnzipper unzipper;
+ ZipEntry zipEntry;
+
+ result r = unzipper.Construct(filePath);
+ SysTryReturn(NID_APP, !IsFailed(r), false, E_SYSTEM, "unzipper.Construct() failed.");
+
+ r = unzipper.GetEntry(L"info/manifest.xml", zipEntry);
+ if (!IsFailed(r))
+ {
+ SysLog(NID_APP, "It's hybrid package. [%ls]", filePath.GetPointer());
+ res = true;
+ }
+ else
+ {
+ SysLog(NID_APP, "It's not hybrid package. [%ls]", filePath.GetPointer());
+ res = false;
+ }
+
+ return res;
+}
+
_PackageManagerImpl*
_PackageManagerImpl::GetInstance(void)
{
_PackageManagerImpl::_PackageManagerImpl(void)
:__pRequestClient(null),
-__pListeningClient(null),
-__pDb(null)
+__pListeningClient(null)
{
- CreatePackageTables();
}
_PackageManagerImpl::~_PackageManagerImpl(void)
SysLog(NID_APP, "pEvent->Fire(*pEventArg) failed. [%s]", GetErrorMessage(r));
}
- SysLog(NID_APP, "PackageId = [%ls], Key = [%ls], Value = [%ls], install = [%d]", pEventArg->__packageId.GetPointer(), pEventArg->__eventKey.GetPointer(), pEventArg->__eventValue.GetPointer(), pEventArg->__install);
+ SysLog(NID_APP, "Package = [%ls], Key = [%ls], Value = [%ls], install = [%d]", pEventArg->__packageId.GetPointer(), pEventArg->__eventKey.GetPointer(), pEventArg->__eventValue.GetPointer(), pEventArg->__install);
}
else
{
{
SysTryReturn(NID_APP, handle != null, 0, E_SYSTEM, "[E_SYSTEM] handle must not be null.");
+ result r = E_SUCCESS;
int result = 0;
char* pPackage = null;
ArrayList* pList = (ArrayList*)pUserData;
- PackageInfo *pPackageInfo = new (std::nothrow) PackageInfo;
- SysTryReturn(NID_APP, pPackageInfo != null, 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] pPackageInfo instance must not be null.");
+ std::unique_ptr< PackageInfo > pPackageInfo(new (std::nothrow) PackageInfo);
+ SysTryReturn(NID_APP, pPackageInfo, null, E_OUT_OF_MEMORY, "pPackageInfo instance must not be null.");
- _PackageInfoImpl* pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPackageInfo);
+ _PackageInfoImpl* pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPackageInfo.get());
result = pkgmgrinfo_pkginfo_get_pkgname(handle, &pPackage);
if (result == 0)
SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_pkgname() is failed. result = [%d]", result);
}
- pPackageInfoImpl->Construct(pPackage);
- pList->Add(*pPackageInfo);
+ r = pPackageInfoImpl->Construct(pPackage);
+ SysTryReturn(NID_APP, r == E_SUCCESS, -1, E_SYSTEM, "pPackageInfoImpl->Construct() failed.");
+
+ r = pList->Add(*pPackageInfo.release());
+ SysTryReturn(NID_APP, r == E_SUCCESS, -1, E_SYSTEM, "pList->Add() failed.");
return result;
}
SysTryReturn(NID_APP, pPackageId, false, E_OUT_OF_MEMORY, "pPackageId is null");
result = pkgmgrinfo_pkginfo_get_pkginfo(pPackageId.get(), &pPackageInfoHandle);
- SysTryReturn(NID_APP, result == 0, false, E_APP_NOT_INSTALLED, "pkgmgrinfo_pkginfo_get_pkginfo() failed. result=[%d], packageId=[%s]", result, pPackageId.get());
+ SysTryReturn(NID_APP, result == 0, false, E_APP_NOT_INSTALLED, "pkgmgrinfo_pkginfo_get_pkginfo() failed. result=[%d], package=[%s]", result, pPackageId.get());
if(pPackageInfoHandle)
{
_PackageManagerImpl::PackageEventHandler(int req_id, const char* pkg_type, const char* pkg_name,
const char* key, const char* val, const void* pmsg, void* data)
{
- SysLog(NID_APP, "PackageEventHandler - req_id: %d, pkg_type: %s, pkg_name: %s, key: %s, val: %s", req_id, pkg_type,
+ SysLog(NID_APP, "PackageEventHandler - req: %d, pkg_type: %s, pkg_name: %s, key: %s, val: %s", req_id, pkg_type,
pkg_name, key, val);
PackageType type = PACKAGE_TYPE_TPK;
String query;
String* pAppId = null;
- query.Format(1024, L"SELECT PkgInfo.PKG_ID FROM PkgInfo, AppInfo, DataControl WHERE DataControl.PROVIDER_ID = '%ls' and DataControl.ID = AppInfo.UNIQUE_ID and AppInfo.ID = PkgInfo.UNIQUE_ID",
+ query.Format(1024, L"SELECT AppInfo.PACKAGE_NAME FROM AppInfo, DataControl WHERE DataControl.PROVIDER_ID = '%ls' and DataControl.ID = AppInfo.UNIQUE_ID",
providerId.GetPointer());
r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
return pAppId;
}
-result
-_PackageManagerImpl::CreatePackageTables(void)
+PackageInfo*
+_PackageManagerImpl::GetPackageInfoN(const String& providerId, const String& operationId) const
{
result r = E_SUCCESS;
+ PackageInfo* pPkgInfo = null;
Database db;
- String createQuery;
-
- if (File::IsFileExist(PACKAGE_DATABASE_FILE_NAME) == true)
- {
- SysLog(NID_APP, ".app-package.db is already existed!");
- return r;
- }
-
- r = db.Construct(PACKAGE_DATABASE_FILE_NAME, true);
- SysTryReturn(NID_APP, r == E_SUCCESS, r, r, "MakePackageDb: db.Construct is failed. [%s]", GetErrorMessage(r));
-
- // PkgInfo
- createQuery.Format(1024, L"CREATE TABLE IF NOT EXISTS PkgInfo"
- "( UNIQUE_ID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,"
- "PKG_ID TEXT,"
- "PKG_SECRET TEXT,"
- "PKG_VERSION TEXT,"
- "PKG_TYPE TEXT,"
- "PKG_MIMETYPE TEXT,"
- "PKG_APIVERSION TEXT,"
- "PKG_NAME TEXT,"
- "PKG_VENDOR TEXT,"
- "PKG_DESCRIPTION TEXT,"
- "PKG_URL TEXT,"
- "PKG_CID TEXT,"
- "PKG_READONLY_SIZE INTEGER,"
- "PKG_DATA_SIZE INTEGER,"
- "PKG_PARENT_ID TEXT,"
- "PKG_ATTRIBUTE INTEGER,"
- "PKG_ROOTPATH TEXT,"
- "PKG_STORAGE_TYPE INTEGER,"
- "PKG_INSTALLATION_DATE TEXT,"
- "PKG_STATE INTEGER,"
- "PKG_INITIATOR INTEGER )");
- r = db.ExecuteSql(createQuery, true);
- SysTryReturn(NID_APP, r == E_SUCCESS, r, r, "MakePackageDb: db.ExecuteSql is failed. [%s]", GetErrorMessage(r));
- createQuery.Clear();
-
- // PkgPrivileges
- createQuery.Format(1024, L"CREATE TABLE IF NOT EXISTS PkgPrivileges"
- "( ID INTEGER,"
- "PRIVILEGES TEXT,"
- "HMAC_PPRIVILEGES TEXT,"
- "CERTIFICATE_TYPE INTEGER,"
- "STR_PRIVILEGES TEXT )");
- r = db.ExecuteSql(createQuery, true);
- SysTryReturn(NID_APP, r == E_SUCCESS, r, r, "MakePackageDb: db.ExecuteSql is failed. [%s]", GetErrorMessage(r));
- createQuery.Clear();
-
- // PkgIntegrity
- createQuery.Format(1024, L"CREATE TABLE IF NOT EXISTS PkgIntegrity"
- "( ID INTEGER,"
- "HMAC_APPID TEXT,"
- "HMAC_APPSECRET TEXT,"
- "HMAC_HTB TEXT,"
- "SLOT_NUM INTEGER )");
- r = db.ExecuteSql(createQuery, true);
- SysTryReturn(NID_APP, r == E_SUCCESS, r, r, "MakePackageDb: db.ExecuteSql is failed. [%s]", GetErrorMessage(r));
- createQuery.Clear();
-
- // AppInfo
- createQuery.Format(1024, L"CREATE TABLE IF NOT EXISTS AppInfo"
- "( UNIQUE_ID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,"
- "ID INTEGER,"
- "APP_NAME TEXT,"
- "APP_TYPE TEXT,"
- "APP_DEFAULT TEXT,"
- "APP_MAINMENU_ICON TEXT,"
- "APP_SETTING_ICON TEXT,"
- "APP_TICKER_ICON TEXT,"
- "APP_QUICKPANEL_ICON TEXT,"
- "APP_LAUNCHIMAGE_ICON TEXT,"
- "APP_FEATURE INTEGER,"
- "PACKAGE_NAME TEXT )");
- r = db.ExecuteSql(createQuery, true);
- SysTryReturn(NID_APP, r == E_SUCCESS, r, r, "MakePackageDb: db.ExecuteSql is failed. [%s]", GetErrorMessage(r));
- createQuery.Clear();
-
- // Notification
- createQuery.Format(1024, L"CREATE TABLE IF NOT EXISTS Notification"
- "( ID INTEGER,"
- "NAME TEXT,"
- "VALUE TEXT )");
- r = db.ExecuteSql(createQuery, true);
- SysTryReturn(NID_APP, r == E_SUCCESS, r, r, "MakePackageDb: db.ExecuteSql is failed. [%s]", GetErrorMessage(r));
- createQuery.Clear();
-
- // AppFeature
- createQuery.Format(1024, L"CREATE TABLE IF NOT EXISTS AppFeature"
- "( ID INTEGER,"
- "NAME TEXT,"
- "VALUE TEXT )");
- r = db.ExecuteSql(createQuery, true);
- SysTryReturn(NID_APP, r == E_SUCCESS, r, r, "MakePackageDb: db.ExecuteSql is failed. [%s]", GetErrorMessage(r));
- createQuery.Clear();
-
- // LaunchCondition
- createQuery.Format(1024, L"CREATE TABLE IF NOT EXISTS LaunchCondition"
- "( ID INTEGER,"
- "NAME TEXT,"
- "VALUE TEXT )");
- r = db.ExecuteSql(createQuery, true);
- SysTryReturn(NID_APP, r == E_SUCCESS, r, r, "MakePackageDb: db.ExecuteSql is failed. [%s]", GetErrorMessage(r));
- createQuery.Clear();
-
- // DataControl
- createQuery.Format(1024, L"CREATE TABLE IF NOT EXISTS DataControl"
- "( ID INTEGER,"
- "PROVIDER_ID TEXT,"
- "TYPE TEXT,"
- "ACCESS TEXT )");
- r = db.ExecuteSql(createQuery, true);
- SysTryReturn(NID_APP, r == E_SUCCESS, r, r, "MakePackageDb: db.ExecuteSql is failed. [%s]", GetErrorMessage(r));
- createQuery.Clear();
-
- // Capability
- createQuery.Format(1024, L"CREATE TABLE IF NOT EXISTS Capability"
- "( ID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,"
- "OPERATION_ID TEXT )");
- r = db.ExecuteSql(createQuery, true);
- SysTryReturn(NID_APP, r == E_SUCCESS, r, r, "MakePackageDb: db.ExecuteSql is failed. [%s]", GetErrorMessage(r));
- createQuery.Clear();
-
- // ResolutionUriScheme
- createQuery.Format(1024, L"CREATE TABLE IF NOT EXISTS ResolutionUriScheme"
- "( ID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,"
- "URI_SCHEME TEXT )");
- r = db.ExecuteSql(createQuery, true);
- SysTryReturn(NID_APP, r == E_SUCCESS, r, r, "MakePackageDb: db.ExecuteSql is failed. [%s]", GetErrorMessage(r));
- createQuery.Clear();
-
- // ResolutionMimeType
- createQuery.Format(1024, L"CREATE TABLE IF NOT EXISTS ResolutionMimeType"
- "( ID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,"
- "MIME_TYPE TEXT )");
- r = db.ExecuteSql(createQuery, true);
- SysTryReturn(NID_APP, r == E_SUCCESS, r, r, "MakePackageDb: db.ExecuteSql is failed. [%s]", GetErrorMessage(r));
- createQuery.Clear();
-
- // AppControl
- createQuery.Format(1024, L"CREATE TABLE IF NOT EXISTS AppControl"
- "( ID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,"
- "PROVIDER_ID TEXT,"
- "CATEGORY TEXT )");
- r = db.ExecuteSql(createQuery, true);
- SysTryReturn(NID_APP, r == E_SUCCESS, r, r, "MakePackageDb: db.ExecuteSql is failed. [%s]", GetErrorMessage(r));
- createQuery.Clear();
-
- // AppInfoLookup
- createQuery.Format(1024, L"CREATE TABLE IF NOT EXISTS AppInfoLookup"
- "( AppInfoID INTEGER,"
- "CapabilityID INTEGER,"
- "ResolutionUriSchemeID INTEGER,"
- "ResolutionMimeTypeID INTEGER,"
- "AppControlID INTEGER )");
- r = db.ExecuteSql(createQuery, true);
- SysTryReturn(NID_APP, r == E_SUCCESS, r, r, "MakePackageDb: db.ExecuteSql is failed. [%s]", GetErrorMessage(r));
- createQuery.Clear();
-
- return r;
-}
-
-result
-_PackageManagerImpl::RegisterPackageInfo(_PackageInfoImpl& pkgInfoImpl)
-{
- result r = E_SUCCESS;
- Database db;
- DbStatement* pStmt = null;
- DbEnumerator* pEnum = null;
- String query;
- String privileges;
- String hmacPrivileges;
- PackageInfo packageInfo;
- int uniqueId = 0;
-
- SysLog(NID_APP, "_PackageManagerImpl::RegisterPackageInfo()");
-
- query.Format(
- 1024, L"INSERT INTO PkgInfo "
- "(PKG_ID, PKG_SECRET, PKG_VERSION, PKG_TYPE, PKG_MIMETYPE, PKG_APIVERSION, PKG_NAME, PKG_VENDOR, PKG_DESCRIPTION, PKG_URL, PKG_CID, PKG_READONLY_SIZE, PKG_DATA_SIZE, PKG_PARENT_ID,"
- " PKG_ATTRIBUTE, PKG_ROOTPATH, PKG_STORAGE_TYPE, PKG_INSTALLATION_DATE, PKG_STATE, PKG_INITIATOR) "
- "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
-
- r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
- //SysTryCatch(NID_APP, r == E_SUCCESS, r, r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
-
- pStmt = CreateStatementN(db, query);
- //SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
-
- PackageId packageId = pkgInfoImpl.GetAppId();
- String appVersion = pkgInfoImpl.GetAppVersion();
- String type = pkgInfoImpl.GetAppType();
- String appMimeType = pkgInfoImpl.GetAppMimeType();
- String appApiVersion = pkgInfoImpl.GetAppApiVersion();
- String appName = pkgInfoImpl.GetAppName();
- String appVendor = pkgInfoImpl.GetAppVendor();
- String appDescription = pkgInfoImpl.GetAppDescription();
- String appUrl = pkgInfoImpl.GetAppUrl();
- String appCid = pkgInfoImpl.GetAppCid();
-
- pkgInfoImpl.GetPrivilegesValue(privileges, hmacPrivileges);
- String appRootPath = pkgInfoImpl.GetAppRootPath();
- int appStorageType = pkgInfoImpl.GetAppStorageType();
- int certType = pkgInfoImpl.GetCertType();
- ArrayList* pAppInfoImplList = pkgInfoImpl.GetAppInfoList();
-
- DateTime time;
- r = SystemTime::GetCurrentTime(time);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "An error occurs while getting a current time.");
-
- if (!packageId.IsEmpty())
- {
- r = pStmt->BindString(0, packageId);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!appVersion.IsEmpty())
- {
- r = pStmt->BindString(2, appVersion);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!type.IsEmpty())
- {
- r = pStmt->BindString(3, type);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!appMimeType.IsEmpty())
- {
- r = pStmt->BindString(4, appMimeType);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!appApiVersion.IsEmpty())
- {
- r = pStmt->BindString(5, appApiVersion);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!appName.IsEmpty())
- {
- r = pStmt->BindString(6, appName);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!appVendor.IsEmpty())
- {
- r = pStmt->BindString(7, appVendor);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!appDescription.IsEmpty())
- {
- r = pStmt->BindString(8, appDescription);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!appUrl.IsEmpty())
- {
- r = pStmt->BindString(9, appUrl);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!appCid.IsEmpty())
- {
- r = pStmt->BindString(10, appCid);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!appRootPath.IsEmpty())
- {
- r = pStmt->BindString(15, appRootPath);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (appStorageType != 0)
- {
- r = pStmt->BindInt(16, appStorageType);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- r = pStmt->BindDateTime(17, time);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
-
- pEnum = ExecuteStatementN(db, pStmt);
-
- r = GetLastResult();
-
- uniqueId = pkgInfoImpl.GetUniqueId();
-
- SysLog(NID_APP, "_PackageManagerImpl::RegisterPackageInfo()-GetUniqueId(%d)", uniqueId);
-
- __pDb = &db;
-
- // AppInfo
- RegisterAppInfoList(uniqueId, pAppInfoImplList);
-
- // PkgPrivileges
- RegisterPrivileges(uniqueId, privileges, hmacPrivileges, certType);
-
-CATCH:
- __pDb = null;
- delete pEnum;
- delete pStmt;
- return r;
-}
-
-result
-_PackageManagerImpl::UnregisterPackageInfo(const PackageId& packageId)
-{
- SysLog(NID_APP, "packageId = [%ls]", packageId.GetPointer());
-
- result r = E_SUCCESS;
- Database db;
- String query;
- int id = 0;
- PackageInfo* pPkgInfo;
- _PackageInfoImpl* pPackageInfoImpl = null;
- ArrayList* pList = null;
-
- pPkgInfo = GetPackageInfoN(packageId);
- SysTryReturn(NID_APP, pPkgInfo != null, r, r, "UnregisterPackageInfo: GetUniqueId() is invalid. [%d]", id);
-
- pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPkgInfo);
- pPackageInfoImpl->SetAppId(packageId);
- id = pPackageInfoImpl->GetUniqueId();
- SysTryReturn(NID_APP, id > 0, r, r, "UnregisterPackageInfo: GetUniqueId() is invalid. [%d]", id);
-
- r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
- SysTryReturn(NID_APP, r == E_SUCCESS, r, r, "UnregisterPackageInfo: db.Construct is failed. [%s]", GetErrorMessage(r));
-
- // AppInfoLookup
- pList = pPackageInfoImpl->GetAppInfoListN();
- if (pList != null)
- {
- for (int i = 0; i < pList->GetCount(); i++)
- {
- _PackageAppInfoImpl* pAppInfoImpl = dynamic_cast <_PackageAppInfoImpl*>(pList->GetAt(i));
-
- if (pAppInfoImpl != null)
- {
- int uniqueId = 0;
- uniqueId = pAppInfoImpl->GetUniqueId();
-
- query.Format(1024, L"DELETE FROM AppInfoLookup WHERE AppInfoID = %d", uniqueId);
- r = db.ExecuteSql(query, true);
- SysTryReturn(NID_APP, r == E_SUCCESS, r, r, "UnregisterPackageInfo: db.ExecuteSql is failed. [%s]", GetErrorMessage(r));
- query.Clear();
- }
- }
- delete pList;
- }
-
- // PkgInfo
- query.Format(1024, L"DELETE FROM PkgInfo WHERE PKG_ID = '%ls'", packageId.GetPointer());
- r = db.ExecuteSql(query, true);
- SysTryReturn(NID_APP, r == E_SUCCESS, r, r, "UnregisterPackageInfo: db.ExecuteSql is failed. [%s]", GetErrorMessage(r));
- query.Clear();
-
- // AppInfo
- query.Format(1024, L"DELETE FROM AppInfo WHERE ID = %d", id);
- r = db.ExecuteSql(query, true);
- SysTryReturn(NID_APP, r == E_SUCCESS, r, r, "UnregisterPackageInfo: db.ExecuteSql is failed. [%s]", GetErrorMessage(r));
- query.Clear();
-
- // PkgPrivileges
- query.Format(1024, L"DELETE FROM PkgPrivileges WHERE ID = %d", id);
- r = db.ExecuteSql(query, true);
- SysTryReturn(NID_APP, r == E_SUCCESS, r, r, "UnregisterPackageInfo: db.ExecuteSql is failed. [%s]", GetErrorMessage(r));
- query.Clear();
-
- // DataControl
- query.Format(1024, L"DELETE FROM DataControl WHERE ID = %d", id);
- r = db.ExecuteSql(query, true);
- SysTryReturn(NID_APP, r == E_SUCCESS, r, r, "UnregisterPackageInfo: db.ExecuteSql is failed. [%s]", GetErrorMessage(r));
- query.Clear();
-
- delete pPkgInfo;
- return r;
-}
-
-PackageInfo*
-_PackageManagerImpl::GetPackageInfoN(const String& providerId, const String& operationId) const
-{
- result r = E_SUCCESS;
- PackageInfo* pPkgInfo = null;
- Database db;
- DbStatement* pStmt = null;
- DbEnumerator* pEnum = null;
- String query;
+ DbStatement* pStmt = null;
+ DbEnumerator* pEnum = null;
+ String query;
query.Format(1024, L"SELECT PkgInfo.PKG_ID FROM PkgInfo, AppInfo, AppInfoLookup, AppControl, Capability "
"WHERE AppControl.PROVIDER_ID ='%ls' and Capability.OPERATION_ID ='%ls' and AppControl.ID = AppInfoLookup.AppControlID "
return pPkgInfo;
}
-result
-_PackageManagerImpl::GetAppInfo(int uniqueId, _PackageAppInfoImpl& appInfo) const
-{
- result r = E_SUCCESS;
- Database db;
- DbStatement* pStmt = null;
- DbEnumerator* pEnum = null;
- String query;
-
- query.Format(1024, L"SELECT * FROM AppInfo WHERE UNIQUE_ID = %d", uniqueId);
-
- r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
-
- pStmt = CreateStatementN(db, query);
- SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
-
- pEnum = ExecuteStatementN(db, pStmt);
- if (pEnum != null)
- {
- if (pEnum->MoveNext() == E_SUCCESS)
- {
- int uniqueId = 0;
- int pkgId = 0;
- String name;
- String defaultapp;
- String mainmenuIcon;
- String settingIcon;
- String tickerIcon;
- String quickpanelIcon;
- String launchImageIcon;
- int appFeature = 0;
- String packageName;
-
- pEnum->GetIntAt(0, uniqueId);
- pEnum->GetIntAt(1, pkgId);
- pEnum->GetStringAt(2, name);
- pEnum->GetStringAt(3, defaultapp);
- pEnum->GetStringAt(4, mainmenuIcon);
- pEnum->GetStringAt(5, settingIcon);
- pEnum->GetStringAt(7, quickpanelIcon);
- pEnum->GetIntAt(9, appFeature);
- pEnum->GetStringAt(10, packageName);
-
- appInfo.SetUniqueId(uniqueId);
- appInfo.SetPkgId(pkgId);
- appInfo.SetName(name);
- appInfo.SetDefault(defaultapp);
- appInfo.SetMainmenuIcon(mainmenuIcon);
- appInfo.SetSettingIcon(settingIcon);
- appInfo.SetQuickpanelIcon(quickpanelIcon);
- appInfo.SetAppFeature(appFeature);
- appInfo.SetPackageName(packageName);
- }
-
- delete pEnum;
- }
- else
- {
- r = E_OBJ_NOT_FOUND;
- }
-
-CATCH:
- delete pStmt;
- return r;
-}
-
ArrayList*
_PackageManagerImpl::GetPackageAppInfoImplListN(const String& packageId) const
{
}
result
-_PackageManagerImpl::RegisterAppInfoList(int id, ArrayList* pList)
-{
- SysTryReturnResult(NID_APP, __pDb != null, E_SYSTEM, "__pDb is null");
-
- result r = E_SUCCESS;
- String query;
- DbStatement* pStmt = null;
-
- if (pList != null)
- {
- for (int i = 0; i < pList->GetCount(); i++)
- {
- _PackageAppInfoImpl* pAppInfoImpl = dynamic_cast <_PackageAppInfoImpl*>(pList->GetAt(i));
-
- if (pAppInfoImpl != null)
- {
- DbEnumerator* pEnum = null;
- int uniqueId = 0;
-
- String name = pAppInfoImpl->GetName();
- String defaultapp = pAppInfoImpl->GetDefault();
- String mainmenuIcon = pAppInfoImpl->GetMainmenuIcon();
- String settingIcon = pAppInfoImpl->GetSettingIcon();
- String quickpanelIcon = pAppInfoImpl->GetQuickpanelIcon();
- int appFeature = pAppInfoImpl->GetAppFeature();
- String packageName = pAppInfoImpl->GetPackageName();
- String type = pAppInfoImpl->GetType();
-
- ArrayList* pLaunchConditionImplList = pAppInfoImpl->GetLaunchConditionList();
- ArrayList* pNotificationImplList = pAppInfoImpl->GetNotificationList();
- ArrayList* pAppFeatureImplList = pAppInfoImpl->GetAppFeatureList();
- ArrayList* pDataControlImplList = pAppInfoImpl->GetDataControlList();
-
- query.Format(
- 1024, L"INSERT INTO AppInfo "
- "(ID, APP_NAME, APP_DEFAULT, APP_MAINMENU_ICON, APP_SETTING_ICON, APP_TICKER_ICON, APP_QUICKPANEL_ICON, APP_LAUNCHIMAGE_ICON, APP_FEATURE, PACKAGE_NAME, APP_TYPE) "
- "VALUES (?,?,?,?,?,?,?,?,?,?,?)");
-
- pStmt = CreateStatementN(*__pDb, query);
- //SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
-
- if (id != 0)
- {
- r = pStmt->BindInt(0, id);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!name.IsEmpty())
- {
- r = pStmt->BindString(1, name);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!defaultapp.IsEmpty())
- {
- r = pStmt->BindString(2, defaultapp);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!mainmenuIcon.IsEmpty())
- {
- r = pStmt->BindString(3, mainmenuIcon);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!settingIcon.IsEmpty())
- {
- r = pStmt->BindString(4, settingIcon);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!quickpanelIcon.IsEmpty())
- {
- r = pStmt->BindString(6, quickpanelIcon);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (appFeature != 0)
- {
- r = pStmt->BindInt(8, appFeature);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!packageName.IsEmpty())
- {
- r = pStmt->BindString(9, packageName);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!type.IsEmpty())
- {
- r = pStmt->BindString(10, type);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- pEnum = ExecuteStatementN(*__pDb, pStmt);
-
- query.Clear();
- delete pStmt;
- pStmt = null;
- delete pEnum;
-
- pAppInfoImpl->SetPkgId(id);
- uniqueId = pAppInfoImpl->GetUniqueId();
- RegisterLaunchConditionList(uniqueId, pLaunchConditionImplList);
- RegisterNotificationList(uniqueId, pNotificationImplList);
- RegisterAppFeatureList(uniqueId, pAppFeatureImplList);
- RegisterDataControlList(uniqueId, pDataControlImplList);
- //RegisterAppControlList(uniqueId, pAppControlImplList);
- }
- }
- }
-
- r = GetLastResult();
-
-CATCH:
- delete pStmt;
-
- return r;
-}
-
-result
-_PackageManagerImpl::RegisterLaunchConditionList(int id, ArrayList* pList)
-{
- SysTryReturnResult(NID_APP, __pDb != null, E_SYSTEM, "__pDb is null");
-
- result r = E_SUCCESS;
- String query;
- DbStatement* pStmt = null;
-
- if (pList != null)
- {
- for (int i = 0; i < pList->GetCount(); i++)
- {
- _LaunchConditionInfoImpl* pLaunchCondition = dynamic_cast<_LaunchConditionInfoImpl*>(pList->GetAt(i));
-
- if (pLaunchCondition != null)
- {
- DbEnumerator* pEnum = null;
-
- String name = pLaunchCondition->GetName();
- String value = pLaunchCondition->GetValue();
-
- query.Format(1024, L"INSERT INTO LaunchCondition (ID, NAME, VALUE) VALUES (?,?,?)");
-
- pStmt = CreateStatementN(*__pDb, query);
- //SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
-
- if (id != 0)
- {
- r = pStmt->BindInt(0, id);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!name.IsEmpty())
- {
- r = pStmt->BindString(1, name);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!value.IsEmpty())
- {
- r = pStmt->BindString(2, value);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- pEnum = ExecuteStatementN(*__pDb, pStmt);
-
- query.Clear();
- delete pStmt;
- pStmt = null;
- delete pEnum;
- }
- }
- }
-
- r = GetLastResult();
-
-CATCH:
- delete pStmt;
-
- return r;
-}
-
-result
-_PackageManagerImpl::RegisterNotificationList(int id, ArrayList* pList)
-{
- SysTryReturnResult(NID_APP, __pDb != null, E_SYSTEM, "__pDb is null");
-
- result r = E_SUCCESS;
- String query;
- DbStatement* pStmt = null;
-
- if (pList != null)
- {
- for (int i = 0; i < pList->GetCount(); i++)
- {
- _NotificationInfoImpl* pNotification = dynamic_cast<_NotificationInfoImpl*>(pList->GetAt(i));
-
- if (pNotification != null)
- {
- DbEnumerator* pEnum = null;
-
- String name = pNotification->GetName();
- String value = pNotification->GetValue();
-
- query.Format(1024, L"INSERT INTO Notification (ID, NAME, VALUE) VALUES (?,?,?)");
-
- pStmt = CreateStatementN(*__pDb, query);
- //SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
-
- if (id != 0)
- {
- r = pStmt->BindInt(0, id);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!name.IsEmpty())
- {
- r = pStmt->BindString(1, name);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!value.IsEmpty())
- {
- r = pStmt->BindString(2, value);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- pEnum = ExecuteStatementN(*__pDb, pStmt);
-
- query.Clear();
- delete pStmt;
- pStmt = null;
- delete pEnum;
- }
- }
- }
-
- r = GetLastResult();
-
-CATCH:
- delete pStmt;
-
- return r;
-}
-
-result
-_PackageManagerImpl::RegisterAppFeatureList(int id, ArrayList* pList)
-{
- SysTryReturnResult(NID_APP, __pDb != null, E_SYSTEM, "__pDb is null");
-
- result r = E_SUCCESS;
- String query;
- DbStatement* pStmt = null;
-
- if (pList != null)
- {
- for (int i = 0; i < pList->GetCount(); i++)
- {
- _AppFeatureInfoImpl* pAppFeature = dynamic_cast<_AppFeatureInfoImpl*>(pList->GetAt(i));
-
- if (pAppFeature != null)
- {
- DbEnumerator* pEnum = null;
-
- String name = pAppFeature->GetName();
- String value = pAppFeature->GetValue();
-
- query.Format(1024, L"INSERT INTO AppFeature (ID, NAME, VALUE) VALUES (?,?,?)");
-
- pStmt = CreateStatementN(*__pDb, query);
- //SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
-
- if (id != 0)
- {
- r = pStmt->BindInt(0, id);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!name.IsEmpty())
- {
- r = pStmt->BindString(1, name);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!value.IsEmpty())
- {
- r = pStmt->BindString(2, value);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- pEnum = ExecuteStatementN(*__pDb, pStmt);
-
- query.Clear();
- delete pStmt;
- pStmt = null;
- delete pEnum;
- }
- }
- }
-
- r = GetLastResult();
-
-CATCH:
- delete pStmt;
-
- return r;
-}
-
-result
-_PackageManagerImpl::RegisterDataControlList(int id, ArrayList* pList)
-{
- SysTryReturnResult(NID_APP, __pDb != null, E_SYSTEM, "__pDb is null");
-
- result r = E_SUCCESS;
- String query;
- DbStatement* pStmt = null;
-
- if (pList != null)
- {
- for (int i = 0; i < pList->GetCount(); i++)
- {
- _DataControlInfoImpl* pDataControl = dynamic_cast<_DataControlInfoImpl*>(pList->GetAt(i));
-
- if (pDataControl != null)
- {
- DbEnumerator* pEnum = null;
-
- String providerId = pDataControl->GetProviderId();
- ArrayList* pTypeList = pDataControl->GetControlTypeList();
-
- if (pTypeList != null)
- {
- for (int j = 0; j < pTypeList->GetCount(); j++)
- {
- _DataControlTypeImpl* pControlType = dynamic_cast<_DataControlTypeImpl*>(pTypeList->GetAt(j));
-
- if (pControlType != null)
- {
- String access = pControlType->GetAccess();
- String type = pControlType->GetType();
-
- query.Format(1024, L"INSERT INTO DataControl (ID, PROVIDER_ID, TYPE, ACCESS) VALUES (?,?,?,?)");
-
- pStmt = CreateStatementN(*__pDb, query);
- //SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
-
- if (id != 0)
- {
- r = pStmt->BindInt(0, id);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!providerId.IsEmpty())
- {
- r = pStmt->BindString(1, providerId);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!type.IsEmpty())
- {
- r = pStmt->BindString(2, type);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!access.IsEmpty())
- {
- r = pStmt->BindString(3, access);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- pEnum = ExecuteStatementN(*__pDb, pStmt);
-
- query.Clear();
- delete pStmt;
- pStmt = null;
- delete pEnum;
- }
- }
- }
- }
- }
- }
-
- r = GetLastResult();
-
-CATCH:
- delete pStmt;
-
- return r;
-}
-
-int
-_PackageManagerImpl::FindRecord(const String& tableName, const String& columnName, const String& value) const
-{
-
- result r = E_SUCCESS;
- Database db;
- String query;
- DbStatement* pStmt = null;
- DbEnumerator* pEnum = null;
- int uniqueId = 0;
-
- r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
- //SysTryCatch(NID_APP, r == E_SUCCESS, r, r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
-
- query.Format(1024, L"SELECT * FROM %ls WHERE %ls = '%ls'", tableName.GetPointer(), columnName.GetPointer(), value.GetPointer());
-
- pStmt = CreateStatementN(db, query);
- //SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
-
- pEnum = ExecuteStatementN(db, pStmt);
-
- if (pEnum != null)
- {
- if (pEnum->MoveNext() == E_SUCCESS)
- {
- pEnum->GetIntAt(0, uniqueId);
- }
-
- delete pEnum;
- }
-
-//CATCH:
- delete pStmt;
-
- return uniqueId;
-}
-
-result
-_PackageManagerImpl::GetRecord(const String& tableName, int uniqueId, const String& columnName, String& value) const
-{
- result r = E_SUCCESS;
- Database db;
- String query;
- DbStatement* pStmt = null;
- DbEnumerator* pEnum = null;
-
- r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
- //SysTryCatch(NID_APP, r == E_SUCCESS, r, r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
-
- query.Format(1024, L"SELECT %ls FROM %ls WHERE UNIQUE_ID = %d", columnName.GetPointer(), tableName.GetPointer(), uniqueId);
-
- pStmt = CreateStatementN(db, query);
- //SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
-
- pEnum = ExecuteStatementN(db, pStmt);
-
- if (pEnum != null)
- {
- if (pEnum->MoveNext() == E_SUCCESS)
- {
- pEnum->GetStringAt(0, value);
- }
-
- delete pEnum;
- }
-
-//CATCH:
- delete pStmt;
-
- return r;
-}
-
-result
-_PackageManagerImpl::RegisterPrivileges(int id, const String& privileges, const String& hmacPrivileges, int certType)
-{
- SysTryReturnResult(NID_APP, __pDb != null, E_SYSTEM, "__pDb is null");
-
- result r = E_SUCCESS;
- String query;
- DbStatement* pStmt = null;
- DbEnumerator* pEnum = null;
-
- query.Format(1024, L"INSERT INTO PkgPrivileges (ID, PRIVILEGES, HMAC_PPRIVILEGES, CERTIFICATE_TYPE) VALUES (?,?,?,?)");
-
- pStmt = CreateStatementN(*__pDb, query);
- SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
-
- if (id != 0)
- {
- r = pStmt->BindInt(0, id);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!privileges.IsEmpty())
- {
- r = pStmt->BindString(1, privileges);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!hmacPrivileges.IsEmpty())
- {
- r = pStmt->BindString(2, hmacPrivileges);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (certType != 0)
- {
- r = pStmt->BindInt(3, certType);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- pEnum = ExecuteStatementN(*__pDb, pStmt);
-
- delete pStmt;
- pStmt = null;
- delete pEnum;
- pEnum = null;
-
- r = GetLastResult();
-
-CATCH:
- delete pStmt;
- return r;
-}
-
-result
_PackageManagerImpl::GetPackageName(const PackageId& packageId, const String* pName, char* pPackageName, int bufferSize)
{
result r = E_SUCCESS;