//
-// Open Service Platform
// Copyright (c) 2012 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the License);
#include <dlog.h>
#include <unique_ptr.h>
-#include <FSysSystemTime.h>
+#include <package-manager-types.h>
+
#include <FAppPkgPackageManager.h>
#include <FAppPkgPackageAppInfo.h>
#include <FAppPkgPackageInfo.h>
#include <FAppPkgIPackageInstallationEventListener.h>
#include <FAppPkgIPackageInstallationResponseListener.h>
#include <FAppPkgIPackageUninstallationResponseListener.h>
+#include <FBaseSysLog.h>
#include <FIo.h>
#include <FIoRegistry.h>
-
-#include <FBaseSysLog.h>
+#include <FSysSystemTime.h>
#include <FBase_StringConverter.h>
#include "FAppPkg_PackageManagerImpl.h"
#include "FAppPkg_PackageInfoImpl.h"
#include "FAppPkg_PackageAppInfoImpl.h"
+#include "FAppPkg_PackageParser.h"
#include "FApp_AppInfo.h"
#include "FApp_PackageManagerProxy.h"
Tizen::Base::Collection::HashMap _PackageManagerImpl::__installationList;
-const wchar_t PACKAGE_DATABASE_FILE_NAME[] = L"/opt/usr/dbspace/.app-package.db";
-
void
_PackageManagerEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
{
{
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);
}
}
{
if (pArg->__install)
{
- SysLog(NID_APP, "Installation is Completed(Error). [PackageId = %ls]", pArg->__packageId.GetPointer());
+ SysLog(NID_APP, "Installation is Completed(Error). [Package = %ls]", pArg->__packageId.GetPointer());
pListener->OnPackageInstallationCompleted(pArg->__packageId, PACKAGE_INSTALLATION_RESULT_INVALID_PACKAGE);
}
else
{
- SysLog(NID_APP, "Uninstallation is Completed(Error). [PackageId = %ls]", pArg->__packageId.GetPointer());
+ SysLog(NID_APP, "Uninstallation is Completed(Error). [Package = %ls]", pArg->__packageId.GetPointer());
pListener->OnPackageUninstallationCompleted(pArg->__packageId, false);
}
}
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, packageId.IsEmpty() == false, E_INVALID_ARG, "packageId is empty.");
SysTryReturnResult(NID_APP, packagePath.IsEmpty() == false, E_INVALID_ARG, "packagePath is empty.");
- SysTryReturnResult(NID_APP, File::IsFileExist(packagePath) == true, E_FILE_NOT_FOUND, "packagePath is not existed.");
+ SysTryReturnResult(NID_APP, File::IsFileExist(packagePath) == true, E_INVALID_ARG, "packagePath is not existed.");
String extension = File::GetFileExtension(packagePath);
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:StoreClientId=XXXXX12345
+ PackageId StoreClientId = _AppInfo::GetPackageId();
+ String optionalData;
+ optionalData.Append(packageId);
+ optionalData.Append(":StoreClientId=");
+ optionalData.Append(StoreClientId);
+
+ 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, packageId.IsEmpty() == false, E_INVALID_ARG, "packageId is empty");
SysTryReturnResult(NID_APP, IsPackageInstalled(packageId) == true, E_PKG_NOT_INSTALLED, "package is not installed.");
-#if defined(_OSP_EMUL_)
- SysLog(NID_APP, "MoveToExternalStorage() is unavailable on the emulator.");
- return E_SYSTEM;
-#else
int res = 0;
char* pType = null;
pkgmgrinfo_installed_storage storage = PMINFO_INTERNAL_STORAGE;
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);
}
}
return E_SUCCESS;
-#endif
}
result
SysTryReturnResult(NID_APP, packageId.IsEmpty() == false, E_INVALID_ARG, "packageId is empty");
SysTryReturnResult(NID_APP, IsPackageInstalled(packageId) == true, E_PKG_NOT_INSTALLED, "package is not installed.");
-#if defined(_OSP_EMUL_)
- SysLog(NID_APP, "MoveToInternalStorage() is unavailable on the emulator.");
- return E_SYSTEM;
-#else
int res = 0;
char* pType = null;
pkgmgrinfo_installed_storage storage = PMINFO_INTERNAL_STORAGE;
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);
}
}
return E_SUCCESS;
-#endif
}
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)
{
+ IPackageInstallationResponseListener* pListener = (IPackageInstallationResponseListener*) pData;
+
if (strcmp(pKey, "end") == 0)
{
- IPackageInstallationResponseListener* pListener = (IPackageInstallationResponseListener*) pData;
-
if (strcmp(pVal, "ok") == 0)
{
pListener->OnPackageInstallationResponseReceived(pPackageId, PACKAGE_INSTALLATION_RESULT_SUCCESS);
delete pListener;
}
+ else if (strcmp(pKey, "install_percent") == 0)
+ {
+ int progress = 0;
+ sscanf(pVal, "%d", &progress);
+
+ pListener->OnPackageInstallationInProgressResponseReceived(pPackageId, progress);
+ SysLog(NID_APP, "OnPackageInstallationInProgressResponseReceived(%s, %d)", pPackageId, progress);
+ }
}
return 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)
{
return 0;
}
-_PackageManagerImpl*
-_PackageManagerImpl::GetInstance(void)
+PackageInfo*
+_PackageManagerImpl::GetPackageInfoFromFileN(const String& filePath) const
{
- return PackageManager::GetInstance()->__pPackageManagerImpl;
-}
+ SysTryReturn(NID_APP, filePath.IsEmpty() == false, null, E_INVALID_ARG, "filePath is empty.");
+ SysTryReturn(NID_APP, File::IsFileExist(filePath) == true, null, E_FILE_NOT_FOUND, "package is not existed.");
-result
-_PackageManagerImpl::Construct(void)
-{
- ClearLastResult();
+ String extension = File::GetFileExtension(filePath);
+ SysTryReturn(NID_APP, extension.IsEmpty() == false, null, E_INVALID_ARG, "extension is empty.");
- result r = __installationList.Construct();
- SysTryReturnResult(NID_APP, r == E_SUCCESS, r, "The memory is insufficient.");
+ std::unique_ptr<char[]> pPackagePath(_StringConverter::CopyToCharArrayN(filePath));
+ SysTryReturn(NID_APP, pPackagePath, null, E_OUT_OF_MEMORY, "pPackagePath is null.");
- return E_SUCCESS;
-}
+ std::unique_ptr<char[]> pExtension(_StringConverter::CopyToCharArrayN(extension));
+ SysTryReturn(NID_APP, pExtension, null, E_OUT_OF_MEMORY, "pExtension is null.");
-_PackageManagerImpl::_PackageManagerImpl(void)
-:__pRequestClient(null),
-__pListeningClient(null),
-__pDb(null)
-{
- CreatePackageTables();
-}
+ std::unique_ptr< PackageInfo > pPackageInfo(new (std::nothrow) PackageInfo);
+ SysTryReturn(NID_APP, pPackageInfo, null, E_OUT_OF_MEMORY, "pPackageInfo instance must not be null.");
-_PackageManagerImpl::~_PackageManagerImpl(void)
-{
-}
+ SysLog(NID_APP, "packagePath = [%s], extension = [%s]", pPackagePath.get(), pExtension.get());
-void
-_PackageManagerImpl::SendPackageEvent(PackageType type, const PackageId& packageId, const char* pEventKey, const char* pEventValue)
-{
- result r = E_SUCCESS;
- bool install = true;
+ bool res = true;
- if (strcmp(pEventKey, "start") == 0)
+ if (strcasecmp(pExtension.get(), "tpk") == 0)
{
- if ((strcmp(pEventValue, "install") == 0) || (strcmp(pEventValue, "uninstall") == 0))
- {
- String* pAppId = new (std::nothrow) String(packageId);
- SysTryReturnVoidResult(NID_APP, pAppId != null, E_OUT_OF_MEMORY, "pAppId instance must not be null.");
+ _PackageParser packageParser;
- String* pOperation = new (std::nothrow) String(pEventValue);
- SysTryReturnVoidResult(NID_APP, pOperation != null, E_OUT_OF_MEMORY, "pOperation instance must not be null.");
+ res = packageParser.Construct(pPackageInfo.get());
+ SysTryReturn(NID_APP, res, null, E_PARSING_FAILED, "Construct() is failed. [%s]", pPackagePath.get());
- r = __installationList.Add(*pAppId, *pOperation);
- if (IsFailed(r))
- {
- delete pAppId;
- delete pOperation;
- SysLog(NID_APP, "Failed to add installation condition.");
- SetLastResult(E_SYSTEM);
- return;
- }
- }
+ res = packageParser.Parse(filePath);
+ SysTryReturn(NID_APP, res, null, E_PARSING_FAILED, "Parse() is failed. [%s]", pPackagePath.get());
}
- else if (strcmp(pEventKey, "end") == 0)
+ else if (strcasecmp(pExtension.get(), "wgt") == 0)
{
- String* pOperation = static_cast <String*>(__installationList.GetValue(packageId));
- if (pOperation)
- {
- if (pOperation->Equals("uninstall", true) == true)
- {
- install = false;
- }
+ pkgmgr_info* pPkgmgrInfo = null;
- r = __installationList.Remove(packageId, true);
- if (IsFailed(r))
+ pPkgmgrInfo = pkgmgr_client_check_pkginfo_from_file(pPackagePath.get());
+ SysTryReturn(NID_APP, pPkgmgrInfo, null, E_PARSING_FAILED, "pkgmgr_client_check_pkginfo_from_file(%s) is failed.", pPackagePath.get());
+
+ _package_manager_pkg_detail_info_t* pPkgInfo = (_package_manager_pkg_detail_info_t*) pPkgmgrInfo;
+ _PackageInfoImpl* pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPackageInfo.get());
+
+ 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->SetVersion(pPkgInfo->version);
+ pPackageInfoImpl->SetDisplayName(pPkgInfo->label);
+ pPackageInfoImpl->SetDescription(pPkgInfo->pkg_description);
+ pPackageInfoImpl->SetAuthor(pPkgInfo->author);
+ pPackageInfoImpl->SetMainAppId(pPkgInfo->pkg_name);
+
+ if (pPkgInfo->privilege_list)
+ {
+ GList* pList = null;
+ pList = g_list_first(pPkgInfo->privilege_list);
+ while (pList)
{
- SysLogException(NID_APP, r, "[%s] Remove Element [%ls] is failed from installing list.", GetErrorMessage(r), packageId.GetPointer());
+ 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< IEnumeratorT<_PackageManagerEvent*> > pEnum(__packageEventListenerList.GetEnumeratorN());
- SysTryReturnVoidResult(NID_APP, pEnum, E_OUT_OF_MEMORY, "The memory is insufficient.");
- while (pEnum->MoveNext() == E_SUCCESS)
- {
- _PackageManagerEvent* pEvent = null;
- pEnum->GetCurrent(pEvent);
- if (pEvent)
+ std::unique_ptr< PackageAppInfo > pPackageAppInfo(new (std::nothrow) PackageAppInfo);
+ if (pPackageAppInfo)
{
- _PackageManagerEventArg* pEventArg= new (std::nothrow) _PackageManagerEventArg();
- SysTryReturnVoidResult(NID_APP, pEventArg, E_OUT_OF_MEMORY, "The memory is insufficient.");
-
- String eventKey(pEventKey);
- String eventValue(pEventValue);
-
- pEventArg->__packageId = packageId;
- pEventArg->__eventKey = eventKey;
- pEventArg->__eventValue = eventValue;
- pEventArg->__install = install;
+ _PackageAppInfoImpl* pPackageAppInfoImpl = _PackageAppInfoImpl::GetInstance(pPackageAppInfo.get());
- r = pEvent->Fire(*pEventArg);
- if (r != E_SUCCESS)
+ pPackageAppInfoImpl->SetAppId(pPkgInfo->pkg_name);
+ pPackageAppInfoImpl->SetAppName(pPkgInfo->label);
+ pPackageAppInfoImpl->SetAppDisplayName(pPkgInfo->label);
+ pPackageAppInfoImpl->SetMainApp(true);
+ if ((pPkgInfo->icon_buf) && (pPkgInfo->icon_size > 0))
{
- SysLog(NID_APP, "pEvent->Fire(*pEventArg) failed. [%s]", GetErrorMessage(r));
+ pPackageAppInfoImpl->SetAppMenuIconBuffer(pPkgInfo->icon_buf, pPkgInfo->icon_size);
}
- SysLog(NID_APP, "PackageId = [%ls], Key = [%ls], Value = [%ls], install = [%d]", pEventArg->__packageId.GetPointer(), pEventArg->__eventKey.GetPointer(), pEventArg->__eventValue.GetPointer(), pEventArg->__install);
+ pPackageInfoImpl->AddPackageAppInfo(*pPackageAppInfo.release());
}
else
{
- SysLog(NID_APP, "pEvent is null.");
+ SysLog(NID_APP, "pPackageAppInfo instance must not be null.");
+ pkgmgr_client_free_pkginfo(pPkgmgrInfo);
+ return null;
}
+
+ pkgmgr_client_free_pkginfo(pPkgmgrInfo);
+ }
+ else
+ {
+ SysTryReturn(NID_APP, false, null, E_UNSUPPORTED_FORMAT, "invalid extension! - packagePath = [%s], extension = [%s]", pPackagePath.get(), pExtension.get());
}
+
+ return pPackageInfo.release();
}
-PackageInfo*
-_PackageManagerImpl::GetPackageInfoN(PackageType packageType, const String& packageName) const
+IList*
+_PackageManagerImpl::GetPackageInfoListN(const IMap& packageFilterMap) const
{
- SysTryReturn(NID_APP, packageName.IsEmpty() == false, null, E_INVALID_ARG, "[E_INVALID_ARG] packageName is empty.");
+ SysTryReturn(NID_APP, packageFilterMap.GetCount() > 0, null, E_INVALID_ARG, "packageFilterMap.GetCount() is invalid.");
- result r = E_SUCCESS;
- Database db;
- DbStatement* pStmt = null;
- DbEnumerator* pEnum = null;
- String query;
- PackageInfo *pPackageInfo = null;
+ std::unique_ptr<IMapEnumerator> pEnum(packageFilterMap.GetMapEnumeratorN());
+ SysTryReturn(NID_APP, pEnum, null, E_INVALID_ARG, "GetMapEnumeratorN() is failed.");
- query.Format( 1024, L"SELECT PkgInfo.*, AppInfo.APP_MAINMENU_ICON FROM AppInfo, PkgInfo WHERE AppInfo.ID = PkgInfo.UNIQUE_ID and AppInfo.PACKAGE_NAME = '%ls'", packageName.GetPointer());
+ std::unique_ptr< ArrayList > pList(new (std::nothrow) ArrayList());
+ SysTryReturn(NID_APP, pList, null, E_OUT_OF_MEMORY, "pList is null.");
- r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
+ pList->Construct();
- pStmt = CreateStatementN(db, query);
+ int res = PMINFO_R_OK;
+ pkgmgrinfo_pkginfo_filter_h handle = null;
- SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
+ res = pkgmgrinfo_pkginfo_filter_create(&handle);
+ SysTryReturn(NID_APP, res == PMINFO_R_OK, null, E_SYSTEM, "pkgmgrinfo_pkginfo_filter_create() is failed. [%d]", res);
- pEnum = ExecuteStatementN(db, pStmt);
- if (pEnum != null)
+ while(pEnum->MoveNext() == E_SUCCESS)
{
- if (pEnum->MoveNext() == E_SUCCESS)
- {
- pPackageInfo = new (std::nothrow) PackageInfo;
- SysTryReturn(NID_APP, pPackageInfo != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] pPackageInfo instance must not be null.");
+ String* pKey = static_cast< String* >(pEnum->GetKey());
+ SysTryCatch(NID_APP, pKey, , E_INVALID_ARG, "GetKey() is failed.");
- _PackageInfoImpl* pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPackageInfo);
+ Boolean* pVal = static_cast< Boolean* >(pEnum->GetValue());
+ SysTryCatch(NID_APP, pVal, , E_INVALID_ARG, "GetValue() is failed.");
- String id;
- String appVersion;
- String appType;
- String appMimeType;
- String appApiVersion;
- String appName;
- String appVendor;
- String appDescription;
- String appUrl;
- String appCid;
- String appRootPath;
- int appStorageType = 0;
- DateTime appInstallationTime;
- String appIconPath;
+ bool value = pVal->ToBool();
- pEnum->GetStringAt(1, id);
- pEnum->GetStringAt(3, appVersion);
- pEnum->GetStringAt(4, appType);
- pEnum->GetStringAt(5, appMimeType);
- pEnum->GetStringAt(6, appApiVersion);
- pEnum->GetStringAt(7, appName);
- pEnum->GetStringAt(8, appVendor);
- pEnum->GetStringAt(9, appDescription);
- pEnum->GetStringAt(10, appUrl);
- pEnum->GetStringAt(11, appCid);
- pEnum->GetStringAt(16, appRootPath);
- pEnum->GetIntAt(17, appStorageType);
- pEnum->GetDateTimeAt(18, appInstallationTime);
- pEnum->GetStringAt(21, appIconPath);
+ SysLog(NID_APP, "Key[%ls], Value[%d]", pKey->GetPointer(), value);
- pPackageInfoImpl->SetAppId(id);
- pPackageInfoImpl->SetAppVersion(appVersion);
- pPackageInfoImpl->SetAppMimeType(appMimeType);
- pPackageInfoImpl->SetAppApiVersion(appApiVersion);
- pPackageInfoImpl->SetAppName(appName);
- pPackageInfoImpl->SetAppVendor(appVendor);
- pPackageInfoImpl->SetAppDescription(appDescription);
- pPackageInfoImpl->SetAppUrl(appUrl);
- pPackageInfoImpl->SetAppCid(appCid);
- pPackageInfoImpl->SetAppRootPath(appRootPath);
- pPackageInfoImpl->SetAppStorageType(appStorageType);
- pPackageInfoImpl->SetAppInstallationTime(appInstallationTime);
- pPackageInfoImpl->SetAppIconPath(appIconPath);
+ if ((*pKey) == PACKAGE_FILTER_UNINSTALLABLE)
+ {
+ res = pkgmgrinfo_pkginfo_filter_add_bool(handle, PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE, value);
+ SysTryCatch(NID_APP, res == PMINFO_R_OK, , E_SYSTEM, "pkgmgrinfo_pkginfo_filter_add_bool(REMOVABLE, %d) is failed. [%d]", value, res);
}
+ else if ((*pKey) == PACKAGE_FILTER_DOWNLOADED)
+ {
+ res = pkgmgrinfo_pkginfo_filter_add_bool(handle, PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD, !value);
+ SysTryCatch(NID_APP, res == PMINFO_R_OK, , E_SYSTEM, "pkgmgrinfo_pkginfo_filter_add_bool(PRELOAD, %d) is failed. [%d]", !value, res);
+ }
+ else if ((*pKey) == PACKAGE_FILTER_APP_SETTING)
+ {
+ 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.");
- delete pEnum;
- }
- else
- {
- r = E_OBJ_NOT_FOUND;
- }
-
-CATCH:
- delete pStmt;
- return pPackageInfo;
-}
+ 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;
+ if (value == true)
+ {
+ installedStorage = L"installed_external";
+ }
+ else
+ {
+ installedStorage = L"installed_internal";
+ }
-int
-_PackageManagerImpl::PackageInfoEventHandler(const pkgmgrinfo_pkginfo_h handle, void* pUserData)
-{
- SysTryReturn(NID_APP, handle != null, 0, E_SYSTEM, "[E_SYSTEM] handle must not be null.");
+ std::unique_ptr<char[]> pInstalledStorage(_StringConverter::CopyToCharArrayN(installedStorage));
+ SysTryCatch(NID_APP, pInstalledStorage, , E_OUT_OF_MEMORY, "pInstalledStorage is null.");
- int result = 0;
- char* pPackage = null;
- ArrayList* pList = (ArrayList*)pUserData;
+ SysLog(NID_APP, "Value[%d]->[%s]", value, pInstalledStorage.get());
- 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.");
+ res = pkgmgrinfo_pkginfo_filter_add_string(handle, PMINFO_PKGINFO_PROP_PACKAGE_INSTALLED_STORAGE, pInstalledStorage.get());
+ SysTryCatch(NID_APP, res == PMINFO_R_OK, , E_SYSTEM, "pkgmgrinfo_pkginfo_filter_add_string(STORAGE, %s) is failed. [%d]", pInstalledStorage.get(), res);
+ }
+ else
+ {
+ SysTryCatch(NID_APP, false, , E_INVALID_ARG, "Invalid key(%ls)", pKey->GetPointer());
+ }
+ }
- _PackageInfoImpl* pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPackageInfo);
+ 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);
- result = pkgmgrinfo_pkginfo_get_pkgname(handle, &pPackage);
- if (result == 0)
+CATCH:
+ if (handle)
{
- SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_pkgname(): package = [%s]", pPackage);
+ pkgmgrinfo_pkginfo_filter_destroy(handle);
}
- else
+
+ if (pList->GetCount() <= 0)
{
- SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_pkgname() is failed. result = [%d]", result);
+ SysLog(NID_APP, "pList's count is 0.");
+ return null;
}
- pPackageInfoImpl->Construct(pPackage);
- pList->Add(*pPackageInfo);
-
- return result;
+ return pList.release();
}
IList*
-_PackageManagerImpl::GetFilteredAppIdListN(const String& feature, const String& value) const
+_PackageManagerImpl::GetPackageAppInfoListN(const IMap& packageAppFilterMap) const
{
- result r = E_SUCCESS;
- Database db;
- DbStatement* pStmt = null;
- DbEnumerator* pEnum = null;
- String query;
- ArrayList* pList = null;
+ SysTryReturn(NID_APP, packageAppFilterMap.GetCount() > 0, null, E_INVALID_ARG, "packageAppFilterMap.GetCount() is invalid.");
- query.Format(1024, L"SELECT AppInfo.PACKAGE_NAME FROM AppInfo, AppFeature WHERE AppFeature.ID = AppInfo.UNIQUE_ID and AppFeature.NAME = '%ls' and AppFeature.VALUE = '%ls' COLLATE NOCASE", feature.GetPointer(), value.GetPointer());
+ std::unique_ptr< IMapEnumerator > pEnum(packageAppFilterMap.GetMapEnumeratorN());
+ SysTryReturn(NID_APP, pEnum, null, E_INVALID_ARG, "GetMapEnumeratorN() is failed.");
- r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
+ std::unique_ptr< ArrayList > pList(new (std::nothrow) ArrayList());
+ SysTryReturn(NID_APP, pList, null, E_OUT_OF_MEMORY, "pList is null.");
- pStmt = CreateStatementN(db, query);
- SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
+ pList->Construct();
- pEnum = ExecuteStatementN(db, pStmt);
+ int res = 0;
+ 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;
- if (pEnum != null)
+ res = pkgmgrinfo_appinfo_filter_create(&handle);
+ 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)
{
- pList = new (std::nothrow) ArrayList();
- SysTryReturn(NID_APP, pList != null, null, E_OUT_OF_MEMORY, "ArrayList creation failure.");
- pList->Construct();
+ String* pKey = static_cast< String* >(pEnum->GetKey());
+ SysTryCatch(NID_APP, pKey, , E_INVALID_ARG, "GetKey() is failed.");
- while (pEnum->MoveNext() == E_SUCCESS)
+ if ((*pKey) == PACKAGE_APP_FILTER_MENUICON_VISIBLE)
{
- String* pPackageName = new (std::nothrow) String;
- SysTryReturn(NID_APP, pPackageName != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] pPackageName instance must not be null.");
+ definedKey = true;
- pEnum->GetStringAt(0, *pPackageName);
+ Boolean* pVal = static_cast< Boolean* >(pEnum->GetValue());
+ SysTryCatch(NID_APP, pVal, , E_INVALID_ARG, "GetValue() is failed.");
- pList->Add(*pPackageName);
+ bool nodisplay = !(pVal->ToBool());
+ SysLog(NID_APP, "Key[%ls], Value[%d]", pKey->GetPointer(), nodisplay);
+
+ 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);
}
+#if 0
+ else if ((*pKey) == PACKAGE_APP_FILTER_LAUNCH_ONBOOT)
+ {
+ definedKey = true;
- delete pEnum;
+ Boolean* pVal = static_cast< Boolean* >(pEnum->GetValue());
+ SysTryCatch(NID_APP, pVal, , E_INVALID_ARG, "GetValue() is failed.");
- }
- else
- {
- r = E_OBJ_NOT_FOUND;
- }
+ bool value = pVal->ToBool();
+ SysLog(NID_APP, "Key[%ls], Value[%d]", pKey->GetPointer(), value);
-CATCH:
- delete pStmt;
- return pList;
-}
+ 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;
-IList*
-_PackageManagerImpl::GetDataControlInfoN(const String& providerId, const String& type) const
-{
- result r = E_SUCCESS;
- Database db;
- DbStatement* pStmt = null;
- DbEnumerator* pEnum = null;
- String query;
- ArrayList* pList = null;
-
- query.Format(1024, L"SELECT AppInfo.PACKAGE_NAME, DataControl.ACCESS FROM AppInfo, DataControl WHERE DataControl.ID = AppInfo.UNIQUE_ID and DataControl.PROVIDER_ID = '%ls' and DataControl.TYPE = '%ls' COLLATE NOCASE", providerId.GetPointer(), type.GetPointer());
+ Boolean* pVal = static_cast< Boolean* >(pEnum->GetValue());
+ SysTryCatch(NID_APP, pVal, , E_INVALID_ARG, "GetValue() is failed.");
- r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
+ bool value = pVal->ToBool();
+ SysLog(NID_APP, "Key[%ls], Value[%d]", pKey->GetPointer(), value);
- pStmt = CreateStatementN(db, query);
- SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
+ 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;
- pEnum = ExecuteStatementN(db, pStmt);
+ Boolean* pVal = static_cast< Boolean* >(pEnum->GetValue());
+ SysTryCatch(NID_APP, pVal, , E_INVALID_ARG, "GetValue() is failed.");
- if (pEnum != null)
- {
- pList = new (std::nothrow) ArrayList();
- SysTryReturn(NID_APP, pList != null, null, E_OUT_OF_MEMORY, "ArrayList creation failure.");
- pList->Construct();
+ bool value = pVal->ToBool();
+ SysLog(NID_APP, "Key[%ls], Value[%d]", pKey->GetPointer(), value);
- while (pEnum->MoveNext() == E_SUCCESS)
+ 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)
{
- String* pPackageName = new (std::nothrow) String;
- SysTryReturn(NID_APP, pPackageName != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] pPackageName instance must not be null.");
+ definedKey = true;
- String* pAccess = new (std::nothrow) String;
- SysTryReturn(NID_APP, pAccess != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] pAccess instance must not be null.");
+ Boolean* pVal = static_cast< Boolean* >(pEnum->GetValue());
+ SysTryCatch(NID_APP, pVal, , E_INVALID_ARG, "GetValue() is failed.");
- pEnum->GetStringAt(0, *pPackageName);
- pList->Add(*pPackageName);
+ bool value = pVal->ToBool();
+ SysLog(NID_APP, "Key[%ls], Value[%d]", pKey->GetPointer(), value);
- pEnum->GetStringAt(1, *pAccess);
- pList->Add(*pAccess);
+ 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;
- delete pEnum;
+ std::unique_ptr<char[]> pDefinedKey(_StringConverter::CopyToCharArrayN(*pKey));
+ SysTryCatch(NID_APP, pDefinedKey, , E_OUT_OF_MEMORY, "pDefinedKey is null.");
- }
- else
- {
- r = E_OBJ_NOT_FOUND;
- }
+ Boolean* pVal = static_cast< Boolean* >(pEnum->GetValue());
+ SysTryCatch(NID_APP, pVal, , E_INVALID_ARG, "GetValue() is failed.");
-CATCH:
- delete pStmt;
- return pList;
-}
+ 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.");
-IMap*
-_PackageManagerImpl::GetUiThemeListN(const PackageId& packageId) const
-{
- result r = E_SUCCESS;
- Database db;
- DbStatement* pStmt = null;
- DbEnumerator* pEnum = null;
- String query;
- HashMap* pList = null;
+ 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
+ {
+ metadataKey = true;
- query.Format(1024, L"SELECT AppFeature.NAME, AppFeature.VALUE FROM PkgInfo, AppInfo, AppFeature WHERE (AppFeature.ID = AppInfo.UNIQUE_ID and AppInfo.ID = PkgInfo.UNIQUE_ID and PkgInfo.PKG_ID = '%ls') and (AppFeature.NAME = 'SystemTheme' or AppFeature.NAME = 'UserDefinedTheme')"
- , packageId.GetPointer());
+ String* pVal = static_cast< String* >(pEnum->GetValue());
+ SysTryCatch(NID_APP, pVal, , E_INVALID_ARG, "GetValue() is failed.");
- r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
+ SysLog(NID_APP, "Key[%ls], Value[%ls]", pKey->GetPointer(), pVal->GetPointer());
- pStmt = CreateStatementN(db, query);
- SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
+ std::unique_ptr<char[]> pMetaKey(_StringConverter::CopyToCharArrayN(*pKey));
+ SysTryCatch(NID_APP, pMetaKey, , E_OUT_OF_MEMORY, "pMetaKey is null.");
- pEnum = ExecuteStatementN(db, pStmt);
+ std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(*pVal));
+ SysTryCatch(NID_APP, pValue, , E_OUT_OF_MEMORY, "pValue is null.");
- if (pEnum != null)
+ 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);
+ }
+ }
+ }
+
+ if ((definedKey == true) && (metadataKey == false))
{
- pList = new (std::nothrow) HashMap();
- SysTryReturn(NID_APP, pList != null, null, E_OUT_OF_MEMORY, "HashMap creation failure.");
- pList->Construct();
+ 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();
- while (pEnum->MoveNext() == E_SUCCESS)
+ res = pkgmgrinfo_appinfo_filter_foreach_appinfo(handle, PackageAppInfoHandler, &list);
+ if (res != PMINFO_R_OK)
{
- String* pName = new (std::nothrow) String;
- SysTryCatch(NID_APP, pName != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] pName instance must not be null.");
+ SysLog(NID_APP, "pkgmgrinfo_appinfo_filter_foreach_appinfo() is failed. result = [%d]", res);
+ goto CATCH;
+ }
- String* pValue = new (std::nothrow) String;
- SysTryCatch(NID_APP, pValue != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] pValue instance must not be null.");
+ metadataList.Construct();
- pEnum->GetStringAt(0, *pName);
- pEnum->GetStringAt(1, *pValue);
+ 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->Add(*pName, *pValue);
+ 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());
+ }
}
- delete pEnum;
+ for (int j = 0; j < metadataList.GetCount(); j++)
+ {
+ PackageAppInfo* pPackageAppInfo = dynamic_cast < PackageAppInfo* >(metadataList.GetAt(j));
+ if (pPackageAppInfo)
+ {
+ AppId appId = pPackageAppInfo->GetAppId();
- }
- else
- {
- r = E_OBJ_NOT_FOUND;
+ 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:
- delete pStmt;
- return pList;
-}
-
-bool
-_PackageManagerImpl::IsAppInstalled(const AppId& appId)
-{
- if (appId == _AppInfo::GetPackageId())
+ if (handle)
{
- return true;
+ pkgmgrinfo_appinfo_filter_destroy(handle);
}
- int result = 0;
- pkgmgrinfo_pkginfo_h pPackageInfoHandle = null;
-
- std::unique_ptr<char[]> pPackageId(_StringConverter::CopyToCharArrayN(appId));
- 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());
+ if (metaHandle)
+ {
+ pkgmgrinfo_appinfo_metadata_filter_destroy(metaHandle);
+ }
- if(pPackageInfoHandle)
+ if (pList->GetCount() <= 0)
{
- pkgmgrinfo_pkginfo_destroy_pkginfo(pPackageInfoHandle);
+ SysLog(NID_APP, "pList's count is 0.");
+ return null;
}
- return true;
+ return pList.release();
}
-int
-_PackageManagerImpl::PackageEventHandler(int req_id, const char* pkg_type, const char* pkg_name,
- const char* key, const char* val, const void* pmsg, void* data)
+IList*
+_PackageManagerImpl::GetPackageAppInfoListN(const IMap& packageFilterMap, const IMap& packageAppFilterMap) const
{
- SysLog(NID_APP, "PackageEventHandler - req_id: %d, pkg_type: %s, pkg_name: %s, key: %s, val: %s", req_id, pkg_type,
- pkg_name, key, val);
+ 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.");
- PackageType type = PACKAGE_TYPE_TPK;
- PackageId packageId(pkg_name);
+ ArrayList appIdList;
- if (strcmp(pkg_type, "tpk") == 0)
- {
- type = PACKAGE_TYPE_TPK;
- }
- else if (strcmp(pkg_type, "wgt") == 0)
- {
- type = PACKAGE_TYPE_WGT;
- }
- else
+ std::unique_ptr< IList > pPackageFilterList(GetPackageInfoListN(packageFilterMap));
+ if (pPackageFilterList == null)
{
- SysLog(NID_APP, "Invalid type - pkg_type: %s", pkg_type);
- return 0;
+ SysLog(NID_APP, "GetPackageInfoListN(packageFilterMap) is null.");
+ return null;
}
- _PackageManagerImpl* pThis = _PackageManagerImpl::GetInstance();
- pThis->SendPackageEvent(type, packageId, key, val);
+ 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());
- return 0;
-}
+ std::unique_ptr< AppId > pAppId(new (std::nothrow) AppId(pPackageAppInfo->GetAppId()));
+ appIdList.Add(pAppId.release());
+ }
+ }
+ }
+ }
+ }
-String*
-_PackageManagerImpl::GetAppIdOfDataControlN(const String& providerId)
-{
- result r = E_SUCCESS;
- Database db;
- DbStatement* pStmt = null;
- DbEnumerator* pEnum = null;
- String query;
- String* pAppId = null;
+ std::unique_ptr< ArrayList > pList(new (std::nothrow) ArrayList);
+ SysTryReturn(NID_APP, pList, null, E_OUT_OF_MEMORY, "pList is 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",
- providerId.GetPointer());
+ std::unique_ptr< IList > pAppFilterList(GetPackageAppInfoListN(packageAppFilterMap));
+ if (pAppFilterList == null)
+ {
+ SysLog(NID_APP, "GetPackageAppInfoListN(packageAppFilterMap) is null.");
+ return null;
+ }
- r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
+ 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());
- pStmt = CreateStatementN(db, query);
- SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
+ if (appIdList.Contains(appId) == true)
+ {
+ SysLog(NID_APP, "App [%ls] is matched.", appId.GetPointer());
- pEnum = ExecuteStatementN(db, pStmt);
+ std::unique_ptr< PackageAppInfo > pPackageAppInfo(new (std::nothrow) PackageAppInfo);
+ SysTryReturn(NID_APP, pPackageAppInfo, null, E_OUT_OF_MEMORY, "PackageAppInfo is null.");
- if (pEnum != null)
- {
- if (pEnum->MoveNext() == E_SUCCESS)
- {
- pAppId = new (std::nothrow) String;
- SysTryReturn(NID_APP, pAppId != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory");
+ _PackageAppInfoImpl* pPackageAppInfoImpl = _PackageAppInfoImpl::GetInstance(pPackageAppInfo.get());
+ pPackageAppInfoImpl->Construct(appId);
- pEnum->GetStringAt(0, *pAppId);
+ pList->Add(pPackageAppInfo.release());
+ }
+ else
+ {
+ SysLog(NID_APP, "App [%ls] is not matched.", pPackageAppInfo->GetAppId().GetPointer());
+ }
}
+ }
- delete pEnum;
+ if (pList->GetCount() <= 0)
+ {
+ SysLog(NID_APP, "pList's count is 0.");
+ return null;
}
-CATCH:
- delete pStmt;
- return pAppId;
+ return pList.release();
}
-result
-_PackageManagerImpl::CreatePackageTables(void)
+int
+_PackageManagerImpl::PackageInfoHandler(const pkgmgrinfo_pkginfo_h handle, void* pUserData)
{
- result r = E_SUCCESS;
- 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 )");
- 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;
-}
+ 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
-_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()));
+ int res = PMINFO_R_OK;
+ char* pPackageId = null;
+ ArrayList* pList = (ArrayList*)pUserData;
- 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();
+ res = pkgmgrinfo_pkginfo_get_pkgname(handle, &pPackageId);
+ SysTryReturn(NID_APP, res == PMINFO_R_OK, 0, E_SYSTEM, "pkgmgrinfo_pkginfo_get_pkgname() is failed. [%d]", res);
- pkgInfoImpl.GetPrivilegesValue(privileges, hmacPrivileges);
- String appRootPath = pkgInfoImpl.GetAppRootPath();
- int appStorageType = pkgInfoImpl.GetAppStorageType();
- int certType = pkgInfoImpl.GetCertType();
- ArrayList* pAppInfoImplList = pkgInfoImpl.GetAppInfoList();
+ std::unique_ptr<PackageInfo> pPackageInfo(new (std::nothrow) PackageInfo);
+ SysTryReturn(NID_APP, pPackageInfo, 0, E_OUT_OF_MEMORY, "pPackageInfo instance must not be null.");
- DateTime time;
- r = SystemTime::GetCurrentTime(time);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "An error occurs while getting a current time.");
+ _PackageInfoImpl* pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPackageInfo.get());
+ r = pPackageInfoImpl->Construct(pPackageId);
+ SysTryReturn(NID_APP, r == E_SUCCESS, 0, E_SYSTEM, "Construct(%s) is failed.", pPackageId);
- 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));
- }
+ pList->Add(*pPackageInfo.release());
- 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));
- }
+ return 0;
+}
- 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));
- }
+int
+_PackageManagerImpl::PackageAppInfoHandler(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.");
- 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));
- }
+ result r = E_SUCCESS;
+ int res = PMINFO_R_OK;
+ char* pAppId = null;
+ ArrayList* pList = (ArrayList*)pUserData;
- 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));
- }
+ 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);
- 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));
- }
+ SysLog(NID_APP, "app = [%s]", pAppId);
- 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));
- }
+ std::unique_ptr<PackageAppInfo> pPackageAppInfo(new (std::nothrow) PackageAppInfo);
+ SysTryReturn(NID_APP, pPackageAppInfo, 0, E_OUT_OF_MEMORY, "pPackageAppInfo instance must not be null.");
- 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));
- }
+ _PackageAppInfoImpl* pPackageAppInfoImpl = _PackageAppInfoImpl::GetInstance(pPackageAppInfo.get());
+ r = pPackageAppInfoImpl->Construct(pAppId);
+ SysTryReturn(NID_APP, r == E_SUCCESS, 0, E_SYSTEM, "Construct(%s) is failed.", pAppId);
- 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));
- }
+ pList->Add(*pPackageAppInfo.release());
- 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));
- }
+ return 0;
+}
- 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));
- }
+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.");
- 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));
- }
+ result r = E_SUCCESS;
+ int res = PMINFO_R_OK;
+ char* pAppId = null;
+ ArrayList* pList = (ArrayList*)pUserData;
- r = pStmt->BindDateTime(17, time);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
+ 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);
- pEnum = ExecuteStatementN(db, pStmt);
+ SysLog(NID_APP, "app = [%s]", pAppId);
- r = GetLastResult();
+ std::unique_ptr< PackageAppInfo > pPackageAppInfo(new (std::nothrow) PackageAppInfo);
+ SysTryReturn(NID_APP, pPackageAppInfo, 0, E_OUT_OF_MEMORY, "pPackageAppInfo instance must not be null.");
- uniqueId = pkgInfoImpl.GetUniqueId();
+ _PackageAppInfoImpl* pPackageAppInfoImpl = _PackageAppInfoImpl::GetInstance(pPackageAppInfo.get());
+ r = pPackageAppInfoImpl->Construct(pAppId);
+ SysTryReturn(NID_APP, r == E_SUCCESS, 0, E_SYSTEM, "Construct(%s) is failed.", pAppId);
- SysLog(NID_APP, "_PackageManagerImpl::RegisterPackageInfo()-GetUniqueId(%d)", uniqueId);
+ pList->Add(*pPackageAppInfo.release());
- __pDb = &db;
+ return 0;
+}
- // AppInfo
- RegisterAppInfoList(uniqueId, pAppInfoImplList);
-
- // PkgPrivileges
- RegisterPrivileges(uniqueId, privileges, hmacPrivileges, certType);
-
-CATCH:
- __pDb = null;
- delete pEnum;
- delete pStmt;
- return r;
+_PackageManagerImpl*
+_PackageManagerImpl::GetInstance(void)
+{
+ return PackageManager::GetInstance()->__pPackageManagerImpl;
}
result
-_PackageManagerImpl::UnregisterPackageInfo(const PackageId& packageId)
+_PackageManagerImpl::Construct(void)
{
- SysLog(NID_APP, "packageId = [%ls]", packageId.GetPointer());
+ ClearLastResult();
- result r = E_SUCCESS;
- Database db;
- String query;
- int id = 0;
- PackageInfo* pPkgInfo;
- _PackageInfoImpl* pPackageInfoImpl = null;
- ArrayList* pList = null;
+ result r = __installationList.Construct();
+ SysTryReturnResult(NID_APP, r == E_SUCCESS, r, "The memory is insufficient.");
- pPkgInfo = GetPackageInfoN(packageId);
- SysTryReturn(NID_APP, pPkgInfo != null, r, r, "UnregisterPackageInfo: GetUniqueId() is invalid. [%d]", id);
+ return E_SUCCESS;
+}
- pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPkgInfo);
- pPackageInfoImpl->SetAppId(packageId);
- id = pPackageInfoImpl->GetUniqueId();
- SysTryReturn(NID_APP, id > 0, r, r, "UnregisterPackageInfo: GetUniqueId() is invalid. [%d]", id);
+_PackageManagerImpl::_PackageManagerImpl(void)
+:__pRequestClient(null),
+__pListeningClient(null)
+{
+}
- r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
- SysTryReturn(NID_APP, r == E_SUCCESS, r, r, "UnregisterPackageInfo: db.Construct is failed. [%s]", GetErrorMessage(r));
+_PackageManagerImpl::~_PackageManagerImpl(void)
+{
+}
- // AppInfoLookup
- pList = pPackageInfoImpl->GetAppInfoListN();
- if (pList != null)
+void
+_PackageManagerImpl::SendPackageEvent(PackageType type, const PackageId& packageId, const char* pEventKey, const char* pEventValue)
+{
+ result r = E_SUCCESS;
+ bool install = true;
+
+ if (strcmp(pEventKey, "start") == 0)
{
- for (int i = 0; i < pList->GetCount(); i++)
+ if ((strcmp(pEventValue, "install") == 0) || (strcmp(pEventValue, "uninstall") == 0))
{
- _PackageAppInfoImpl* pAppInfoImpl = dynamic_cast <_PackageAppInfoImpl*>(pList->GetAt(i));
+ String* pAppId = new (std::nothrow) String(packageId);
+ SysTryReturnVoidResult(NID_APP, pAppId != null, E_OUT_OF_MEMORY, "pAppId instance must not be null.");
- if (pAppInfoImpl != null)
- {
- int uniqueId = 0;
- uniqueId = pAppInfoImpl->GetUniqueId();
+ String* pOperation = new (std::nothrow) String(pEventValue);
+ SysTryReturnVoidResult(NID_APP, pOperation != null, E_OUT_OF_MEMORY, "pOperation instance must not be null.");
- 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();
+ r = __installationList.Add(*pAppId, *pOperation);
+ if (IsFailed(r))
+ {
+ delete pAppId;
+ delete pOperation;
+ SysLog(NID_APP, "Failed to add installation condition.");
+ SetLastResult(E_SYSTEM);
+ return;
}
}
- 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;
-
- 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 "
- "and Capability.ID = AppInfoLookup.CapabilityID and AppInfoLookup.AppInfoID = AppInfo.UNIQUE_ID and AppInfo.ID = PkgInfo.UNIQUE_ID "
- "GROUP BY AppInfoID"
- , providerId.GetPointer(), operationId.GetPointer());
-
- r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
- 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)
+ else if (strcmp(pEventKey, "end") == 0)
{
- if (pEnum->MoveNext() == E_SUCCESS)
+ String* pOperation = static_cast <String*>(__installationList.GetValue(packageId));
+ if (pOperation)
{
- PackageId packageId;
- pEnum->GetStringAt(0, packageId);
+ if (pOperation->Equals("uninstall", true) == true)
+ {
+ install = false;
+ }
- pPkgInfo = GetPackageInfoN(packageId);
+ r = __installationList.Remove(packageId, true);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_APP, r, "[%s] Remove Element [%ls] is failed from installing list.", GetErrorMessage(r), packageId.GetPointer());
+ }
}
-
- delete pEnum;
- }
- else
- {
- r = E_OBJ_NOT_FOUND;
}
-CATCH:
- delete pStmt;
- return pPkgInfo;
-}
+ std::unique_ptr< IEnumeratorT<_PackageManagerEvent*> > pEnum(__packageEventListenerList.GetEnumeratorN());
+ SysTryReturnVoidResult(NID_APP, pEnum, E_OUT_OF_MEMORY, "The memory is insufficient.");
-result
-_PackageManagerImpl::GetAppInfo(int uniqueId, _PackageAppInfoImpl& appInfo) const
-{
- result r = E_SUCCESS;
- Database db;
- DbStatement* pStmt = null;
- DbEnumerator* pEnum = null;
- String query;
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ _PackageManagerEvent* pEvent = null;
+ pEnum->GetCurrent(pEvent);
+ if (pEvent)
+ {
+ _PackageManagerEventArg* pEventArg= new (std::nothrow) _PackageManagerEventArg();
+ SysTryReturnVoidResult(NID_APP, pEventArg, E_OUT_OF_MEMORY, "The memory is insufficient.");
- query.Format(1024, L"SELECT * FROM AppInfo WHERE UNIQUE_ID = %d", uniqueId);
+ String eventKey(pEventKey);
+ String eventValue(pEventValue);
- r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
+ pEventArg->__packageId = packageId;
+ pEventArg->__eventKey = eventKey;
+ pEventArg->__eventValue = eventValue;
+ pEventArg->__install = install;
- pStmt = CreateStatementN(db, query);
- SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
+ r = pEvent->Fire(*pEventArg);
+ if (r != E_SUCCESS)
+ {
+ SysLog(NID_APP, "pEvent->Fire(*pEventArg) failed. [%s]", GetErrorMessage(r));
+ }
- pEnum = ExecuteStatementN(db, pStmt);
- if (pEnum != null)
- {
- if (pEnum->MoveNext() == E_SUCCESS)
+ SysLog(NID_APP, "Package = [%ls], Key = [%ls], Value = [%ls], install = [%d]", pEventArg->__packageId.GetPointer(), pEventArg->__eventKey.GetPointer(), pEventArg->__eventValue.GetPointer(), pEventArg->__install);
+ }
+ else
{
- 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);
+ SysLog(NID_APP, "pEvent is null.");
}
-
- delete pEnum;
- }
- else
- {
- r = E_OBJ_NOT_FOUND;
}
-
-CATCH:
- delete pStmt;
- return r;
}
-ArrayList*
-_PackageManagerImpl::GetPackageAppInfoImplListN(const String& packageId) const
+PackageInfo*
+_PackageManagerImpl::GetPackageInfoN(PackageType packageType, const String& packageName) const
{
+ SysTryReturn(NID_APP, packageName.IsEmpty() == false, null, E_INVALID_ARG, "[E_INVALID_ARG] packageName is empty.");
+
result r = E_SUCCESS;
Database db;
DbStatement* pStmt = null;
DbEnumerator* pEnum = null;
String query;
- //int id = 0;
- PackageInfo* pPkgInfo = null;
- _PackageInfoImpl* pPackageInfoImpl = null;
- ArrayList* pList = null;
-
- pPkgInfo = GetPackageInfoN(packageId);
- SysTryCatch(NID_APP, pPkgInfo != null, , r, "[%s] GetPackageInfoN() is failed", GetErrorMessage(r));
+ PackageInfo *pPackageInfo = null;
- pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPkgInfo);
- query.Format(1024, L"SELECT * FROM AppInfo WHERE ID = %d", pPackageInfoImpl->GetUniqueId());
+ query.Format( 1024, L"SELECT PkgInfo.*, AppInfo.APP_MAINMENU_ICON FROM AppInfo, PkgInfo WHERE AppInfo.ID = PkgInfo.UNIQUE_ID and AppInfo.PACKAGE_NAME = '%ls'", packageName.GetPointer());
- r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
+ 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);
+ 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)
{
- pList = new (std::nothrow) ArrayList;
- SysTryReturn(NID_APP, pList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Container allocation failure.");
-
- pList->Construct();
-
- while (pEnum->MoveNext() == E_SUCCESS)
+ if (pEnum->MoveNext() == E_SUCCESS)
{
- _PackageAppInfoImpl* pPackageAppInfoImpl = new (std::nothrow) _PackageAppInfoImpl;
- SysTryReturn(NID_APP, pPackageAppInfoImpl != null, null, E_OUT_OF_MEMORY, "pPackageAppInfoImpl instance must not be null.");
+ pPackageInfo = new (std::nothrow) PackageInfo;
+ SysTryReturn(NID_APP, pPackageInfo != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] pPackageInfo instance must not be null.");
- int uniqueId = 0;
- int pkgId = 0;
- String name;
- String defaultapp;
- String mainmenuIcon;
- String settingIcon;
- String quickpanelIcon;
- int appFeature = 0;
- String packageName;
+ _PackageInfoImpl* pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPackageInfo);
- 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);
+ String id;
+ String appVersion;
+ String appType;
+ String appMimeType;
+ String appApiVersion;
+ String appName;
+ String appVendor;
+ String appDescription;
+ String appUrl;
+ String appCid;
+ String appRootPath;
+ int appStorageType = 0;
+ DateTime appInstallationTime;
+ String appIconPath;
- pPackageAppInfoImpl->SetUniqueId(uniqueId);
- pPackageAppInfoImpl->SetPkgId(pkgId);
- pPackageAppInfoImpl->SetName(name);
- pPackageAppInfoImpl->SetDefault(defaultapp);
- pPackageAppInfoImpl->SetMainmenuIcon(mainmenuIcon);
- pPackageAppInfoImpl->SetSettingIcon(settingIcon);
- pPackageAppInfoImpl->SetQuickpanelIcon(quickpanelIcon);
- pPackageAppInfoImpl->SetAppFeature(appFeature);
- pPackageAppInfoImpl->SetPackageName(packageName);
+ pEnum->GetStringAt(1, id);
+ pEnum->GetStringAt(3, appVersion);
+ pEnum->GetStringAt(4, appType);
+ pEnum->GetStringAt(5, appMimeType);
+ pEnum->GetStringAt(6, appApiVersion);
+ pEnum->GetStringAt(7, appName);
+ pEnum->GetStringAt(8, appVendor);
+ pEnum->GetStringAt(9, appDescription);
+ pEnum->GetStringAt(10, appUrl);
+ pEnum->GetStringAt(11, appCid);
+ pEnum->GetStringAt(16, appRootPath);
+ pEnum->GetIntAt(17, appStorageType);
+ pEnum->GetDateTimeAt(18, appInstallationTime);
+ pEnum->GetStringAt(21, appIconPath);
- pList->Add(*pPackageAppInfoImpl);
+ pPackageInfoImpl->SetAppId(id);
+ pPackageInfoImpl->SetAppVersion(appVersion);
+ pPackageInfoImpl->SetAppMimeType(appMimeType);
+ pPackageInfoImpl->SetAppApiVersion(appApiVersion);
+ pPackageInfoImpl->SetAppName(appName);
+ pPackageInfoImpl->SetAppVendor(appVendor);
+ pPackageInfoImpl->SetAppDescription(appDescription);
+ pPackageInfoImpl->SetAppUrl(appUrl);
+ pPackageInfoImpl->SetAppCid(appCid);
+ pPackageInfoImpl->SetAppRootPath(appRootPath);
+ pPackageInfoImpl->SetAppStorageType(appStorageType);
+ pPackageInfoImpl->SetAppInstallationTime(appInstallationTime);
+ pPackageInfoImpl->SetAppIconPath(appIconPath);
}
delete pEnum;
}
-
-CATCH:
- delete pPkgInfo;
- delete pStmt;
- return pList;
-}
-
-ArrayList*
-_PackageManagerImpl::GetPackageAppFeatureListN(const PackageId& packageId, const Tizen::Base::String& appExecutableName) const
-{
- ArrayList* pAppInfoList = GetPackageAppInfoImplListN(packageId);
- SysTryReturn(NID_APP, pAppInfoList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] AppInfo list instance must not be null.");
-
- ArrayList* pResult = null;
-
- for (int i = 0; i < pAppInfoList->GetCount(); i++)
+ else
{
- const _PackageAppInfoImpl* pAppInfoImpl = static_cast<const _PackageAppInfoImpl*>(pAppInfoList->GetAt(i));
- if (pAppInfoImpl == null)
- {
- continue;
- }
-
- if (pAppInfoImpl->GetName() == appExecutableName)
- {
- pResult = pAppInfoImpl->GetAppFeatureListN();
- goto OUT;
- }
+ r = E_OBJ_NOT_FOUND;
}
-OUT:
- pAppInfoList->RemoveAll(true);
- delete pAppInfoList;
-
- return pResult;
+CATCH:
+ delete pStmt;
+ return pPackageInfo;
}
-HashMapT<String, _AppFeatureInfoImpl*>*
-_PackageManagerImpl::GetPackageAppFeatureMapN(const PackageId& packageId, const Tizen::Base::String& appExecutableName) const
+int
+_PackageManagerImpl::PackageInfoEventHandler(const pkgmgrinfo_pkginfo_h handle, void* pUserData)
{
- ArrayList* pAppInfoList = GetPackageAppInfoImplListN(packageId);
- SysTryReturn(NID_APP, pAppInfoList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] AppInfo list instance must not be null.");
+ SysTryReturn(NID_APP, handle != null, 0, E_SYSTEM, "[E_SYSTEM] handle must not be null.");
- HashMapT<String, _AppFeatureInfoImpl*>* pResult = null;
+ result r = E_SUCCESS;
+ int result = 0;
+ char* pPackage = null;
+ ArrayList* pList = (ArrayList*)pUserData;
- std::auto_ptr<IEnumerator> pEnum(pAppInfoList->GetEnumeratorN());
+ std::unique_ptr< PackageInfo > pPackageInfo(new (std::nothrow) PackageInfo);
+ SysTryReturn(NID_APP, pPackageInfo, null, E_OUT_OF_MEMORY, "pPackageInfo instance must not be null.");
- while (pEnum->MoveNext() == E_SUCCESS)
- {
- const _PackageAppInfoImpl* pAppInfoImpl = static_cast<const _PackageAppInfoImpl*>(pEnum->GetCurrent());
- if (pAppInfoImpl == null)
- {
- continue;
- }
+ _PackageInfoImpl* pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPackageInfo.get());
- if (pAppInfoImpl->GetName() == appExecutableName)
- {
- pResult = pAppInfoImpl->GetAppFeatureMapN();
- goto OUT;
- }
+ result = pkgmgrinfo_pkginfo_get_pkgname(handle, &pPackage);
+ if (result == 0)
+ {
+ SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_pkgname(): package = [%s]", pPackage);
+ }
+ else
+ {
+ SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_pkgname() is failed. result = [%d]", result);
}
-OUT:
- pAppInfoList->RemoveAll(true);
- delete pAppInfoList;
+ r = pPackageInfoImpl->Construct(pPackage);
+ SysTryReturn(NID_APP, r == E_SUCCESS, -1, E_SYSTEM, "pPackageInfoImpl->Construct() failed.");
- return pResult;
+ r = pList->Add(*pPackageInfo.release());
+ SysTryReturn(NID_APP, r == E_SUCCESS, -1, E_SYSTEM, "pList->Add() failed.");
+
+ return result;
}
-ArrayList*
-_PackageManagerImpl::GetAppLaunchConditionListN(const String& packageName) const
+IList*
+_PackageManagerImpl::GetFilteredAppIdListN(const String& feature, const String& value) const
{
result r = E_SUCCESS;
Database db;
String query;
ArrayList* pList = null;
- query.Format(1024, L"SELECT LaunchCondition.* FROM LaunchCondition, AppInfo WHERE AppInfo.UNIQUE_ID = LaunchCondition.ID and AppInfo.PACKAGE_NAME = '%ls'", packageName.GetPointer());
+ query.Format(1024, L"SELECT AppInfo.PACKAGE_NAME FROM AppInfo, AppFeature WHERE AppFeature.ID = AppInfo.UNIQUE_ID and AppFeature.NAME = '%ls' and AppFeature.VALUE = '%ls' COLLATE NOCASE", feature.GetPointer(), value.GetPointer());
- r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
+ 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()));
+ 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)
{
- pList = new (std::nothrow) ArrayList;
- SysTryReturn(NID_APP, pList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Container allocation failure.");
-
+ pList = new (std::nothrow) ArrayList();
+ SysTryReturn(NID_APP, pList != null, null, E_OUT_OF_MEMORY, "ArrayList creation failure.");
pList->Construct();
while (pEnum->MoveNext() == E_SUCCESS)
{
- _LaunchConditionInfoImpl* pLaunchCondtion = new (std::nothrow) _LaunchConditionInfoImpl;
- SysTryReturn(NID_APP, pLaunchCondtion != null, null, E_OUT_OF_MEMORY, "pLaunchCondtion instance must not be null.");
-
- String name;
- String value;
-
- pEnum->GetStringAt(1, name);
- pEnum->GetStringAt(2, value);
-
- pLaunchCondtion->SetName(name);
- pLaunchCondtion->SetValue(value);
+ String* pPackageName = new (std::nothrow) String;
+ SysTryReturn(NID_APP, pPackageName != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] pPackageName instance must not be null.");
- pList->Add(*pLaunchCondtion);
+ pEnum->GetStringAt(0, *pPackageName);
- SysLog(NID_APP, "Name[%ls], Value[%ls]", name.GetPointer(), value.GetPointer());
+ pList->Add(*pPackageName);
}
delete pEnum;
+
+ }
+ else
+ {
+ r = E_OBJ_NOT_FOUND;
}
CATCH:
return pList;
}
-result
-_PackageManagerImpl::RegisterAppInfoList(int id, ArrayList* pList)
+IList*
+_PackageManagerImpl::GetDataControlInfoN(const String& providerId, const String& type) const
{
- SysTryReturnResult(NID_APP, __pDb != null, E_SYSTEM, "__pDb is null");
-
result r = E_SUCCESS;
- String query;
+ Database db;
DbStatement* pStmt = null;
+ DbEnumerator* pEnum = null;
+ String query;
+ ArrayList* pList = 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));
- }
+ query.Format(1024, L"SELECT AppInfo.PACKAGE_NAME, DataControl.ACCESS FROM AppInfo, DataControl WHERE DataControl.ID = AppInfo.UNIQUE_ID and DataControl.PROVIDER_ID = '%ls' and DataControl.TYPE = '%ls' COLLATE NOCASE", providerId.GetPointer(), type.GetPointer());
- 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));
- }
+ 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));
- 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));
- }
+ pStmt = CreateStatementN(db, query);
+ SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
- 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));
- }
+ pEnum = ExecuteStatementN(db, pStmt);
- 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 (pEnum != null)
+ {
+ pList = new (std::nothrow) ArrayList();
+ SysTryReturn(NID_APP, pList != null, null, E_OUT_OF_MEMORY, "ArrayList creation failure.");
+ pList->Construct();
- 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));
- }
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ String* pPackageName = new (std::nothrow) String;
+ SysTryReturn(NID_APP, pPackageName != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] pPackageName instance must not be null.");
- 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));
- }
+ String* pAccess = new (std::nothrow) String;
+ SysTryReturn(NID_APP, pAccess != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] pAccess instance must not be null.");
- 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->GetStringAt(0, *pPackageName);
+ pList->Add(*pPackageName);
- pEnum = ExecuteStatementN(*__pDb, pStmt);
+ pEnum->GetStringAt(1, *pAccess);
+ pList->Add(*pAccess);
+ }
- query.Clear();
- delete pStmt;
- pStmt = null;
- delete pEnum;
+ 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();
+ else
+ {
+ r = E_OBJ_NOT_FOUND;
+ }
CATCH:
delete pStmt;
-
- return r;
+ return pList;
}
-result
-_PackageManagerImpl::RegisterLaunchConditionList(int id, ArrayList* pList)
+IMap*
+_PackageManagerImpl::GetUiThemeListN(const PackageId& packageId) const
{
- SysTryReturnResult(NID_APP, __pDb != null, E_SYSTEM, "__pDb is null");
-
result r = E_SUCCESS;
- String query;
+ Database db;
DbStatement* pStmt = null;
+ DbEnumerator* pEnum = null;
+ String query;
+ HashMap* pList = 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;
+ query.Format(1024, L"SELECT AppFeature.NAME, AppFeature.VALUE FROM PkgInfo, AppInfo, AppFeature WHERE (AppFeature.ID = AppInfo.UNIQUE_ID and AppInfo.ID = PkgInfo.UNIQUE_ID and PkgInfo.PKG_ID = '%ls') and (AppFeature.NAME = 'SystemTheme' or AppFeature.NAME = 'UserDefinedTheme')"
+ , packageId.GetPointer());
- String name = pLaunchCondition->GetName();
- String value = pLaunchCondition->GetValue();
+ 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));
- query.Format(1024, L"INSERT INTO LaunchCondition (ID, NAME, VALUE) VALUES (?,?,?)");
+ pStmt = CreateStatementN(db, query);
+ SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
- pStmt = CreateStatementN(*__pDb, query);
- //SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
+ pEnum = ExecuteStatementN(db, pStmt);
- 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 (pEnum != null)
+ {
+ pList = new (std::nothrow) HashMap();
+ SysTryReturn(NID_APP, pList != null, null, E_OUT_OF_MEMORY, "HashMap creation failure.");
+ pList->Construct();
- 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));
- }
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ String* pName = new (std::nothrow) String;
+ SysTryCatch(NID_APP, pName != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] pName instance must not be null.");
- 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));
- }
+ String* pValue = new (std::nothrow) String;
+ SysTryCatch(NID_APP, pValue != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] pValue instance must not be null.");
- pEnum = ExecuteStatementN(*__pDb, pStmt);
+ pEnum->GetStringAt(0, *pName);
+ pEnum->GetStringAt(1, *pValue);
- query.Clear();
- delete pStmt;
- pStmt = null;
- delete pEnum;
- }
+ pList->Add(*pName, *pValue);
}
- }
- r = GetLastResult();
+ delete pEnum;
+
+ }
+ else
+ {
+ r = E_OBJ_NOT_FOUND;
+ }
CATCH:
delete pStmt;
-
- return r;
+ return pList;
}
-result
-_PackageManagerImpl::RegisterNotificationList(int id, ArrayList* pList)
+bool
+_PackageManagerImpl::IsAppInstalled(const AppId& appId)
{
- SysTryReturnResult(NID_APP, __pDb != null, E_SYSTEM, "__pDb is null");
-
- result r = E_SUCCESS;
- String query;
- DbStatement* pStmt = null;
-
- if (pList != null)
+ if (appId == _AppInfo::GetPackageId())
{
- for (int i = 0; i < pList->GetCount(); i++)
- {
- _NotificationInfoImpl* pNotification = dynamic_cast<_NotificationInfoImpl*>(pList->GetAt(i));
-
- if (pNotification != null)
- {
- DbEnumerator* pEnum = null;
+ return true;
+ }
- String name = pNotification->GetName();
- String value = pNotification->GetValue();
+ int result = 0;
+ pkgmgrinfo_pkginfo_h pPackageInfoHandle = null;
- query.Format(1024, L"INSERT INTO Notification (ID, NAME, VALUE) VALUES (?,?,?)");
+ std::unique_ptr<char[]> pPackageId(_StringConverter::CopyToCharArrayN(appId));
+ SysTryReturn(NID_APP, pPackageId, false, E_OUT_OF_MEMORY, "pPackageId is null");
- pStmt = CreateStatementN(*__pDb, query);
- //SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
+ 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], package=[%s]", result, pPackageId.get());
- 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(pPackageInfoHandle)
+ {
+ pkgmgrinfo_pkginfo_destroy_pkginfo(pPackageInfoHandle);
+ }
- 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));
- }
+ return true;
+}
- 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));
- }
+int
+_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: %d, pkg_type: %s, pkg_name: %s, key: %s, val: %s", req_id, pkg_type,
+ pkg_name, key, val);
- pEnum = ExecuteStatementN(*__pDb, pStmt);
+ PackageType type = PACKAGE_TYPE_TPK;
+ PackageId packageId(pkg_name);
- query.Clear();
- delete pStmt;
- pStmt = null;
- delete pEnum;
- }
- }
+ if (strcmp(pkg_type, "tpk") == 0)
+ {
+ type = PACKAGE_TYPE_TPK;
+ }
+ else if (strcmp(pkg_type, "wgt") == 0)
+ {
+ type = PACKAGE_TYPE_WGT;
+ }
+ else
+ {
+ SysLog(NID_APP, "Invalid type - pkg_type: %s", pkg_type);
+ return 0;
}
- r = GetLastResult();
-
-CATCH:
- delete pStmt;
+ _PackageManagerImpl* pThis = _PackageManagerImpl::GetInstance();
+ pThis->SendPackageEvent(type, packageId, key, val);
- return r;
+ return 0;
}
-result
-_PackageManagerImpl::RegisterAppFeatureList(int id, ArrayList* pList)
+String*
+_PackageManagerImpl::GetAppIdOfDataControlN(const String& providerId)
{
- SysTryReturnResult(NID_APP, __pDb != null, E_SYSTEM, "__pDb is null");
-
result r = E_SUCCESS;
- String query;
+ Database db;
DbStatement* pStmt = null;
+ DbEnumerator* pEnum = null;
+ String query;
+ String* pAppId = 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()));
+ query.Format(1024, L"SELECT AppInfo.PACKAGE_NAME FROM AppInfo, DataControl WHERE DataControl.PROVIDER_ID = '%ls' and DataControl.ID = AppInfo.UNIQUE_ID",
+ providerId.GetPointer());
- 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));
- }
+ 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));
- 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));
- }
+ pStmt = CreateStatementN(db, query);
+ SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
- 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(db, pStmt);
- pEnum = ExecuteStatementN(*__pDb, pStmt);
+ if (pEnum != null)
+ {
+ if (pEnum->MoveNext() == E_SUCCESS)
+ {
+ pAppId = new (std::nothrow) String;
+ SysTryReturn(NID_APP, pAppId != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory");
- query.Clear();
- delete pStmt;
- pStmt = null;
- delete pEnum;
- }
+ pEnum->GetStringAt(0, *pAppId);
}
- }
- r = GetLastResult();
+ delete pEnum;
+ }
CATCH:
delete pStmt;
-
- return r;
+ return pAppId;
}
-result
-_PackageManagerImpl::RegisterDataControlList(int id, ArrayList* pList)
+PackageInfo*
+_PackageManagerImpl::GetPackageInfoN(const String& providerId, const String& operationId) const
{
- SysTryReturnResult(NID_APP, __pDb != null, E_SYSTEM, "__pDb is null");
-
result r = E_SUCCESS;
- String query;
+ PackageInfo* pPkgInfo = null;
+ Database db;
DbStatement* pStmt = null;
+ DbEnumerator* pEnum = null;
+ String query;
- if (pList != null)
- {
- for (int i = 0; i < pList->GetCount(); i++)
- {
- _DataControlInfoImpl* pDataControl = dynamic_cast<_DataControlInfoImpl*>(pList->GetAt(i));
+ 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 "
+ "and Capability.ID = AppInfoLookup.CapabilityID and AppInfoLookup.AppInfoID = AppInfo.UNIQUE_ID and AppInfo.ID = PkgInfo.UNIQUE_ID "
+ "GROUP BY AppInfoID"
+ , providerId.GetPointer(), operationId.GetPointer());
- if (pDataControl != null)
- {
- DbEnumerator* pEnum = null;
+ 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));
- String providerId = pDataControl->GetProviderId();
- ArrayList* pTypeList = pDataControl->GetControlTypeList();
+ pStmt = CreateStatementN(db, query);
+ SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
- 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;
- }
- }
- }
- }
+ pEnum = ExecuteStatementN(db, pStmt);
+ if (pEnum != null)
+ {
+ if (pEnum->MoveNext() == E_SUCCESS)
+ {
+ PackageId packageId;
+ pEnum->GetStringAt(0, packageId);
+
+ pPkgInfo = GetPackageInfoN(packageId);
}
- }
- r = GetLastResult();
+ delete pEnum;
+ }
+ else
+ {
+ r = E_OBJ_NOT_FOUND;
+ }
CATCH:
delete pStmt;
-
- return r;
+ return pPkgInfo;
}
-int
-_PackageManagerImpl::FindRecord(const String& tableName, const String& columnName, const String& value) const
+ArrayList*
+_PackageManagerImpl::GetPackageAppInfoImplListN(const String& packageId) const
{
-
result r = E_SUCCESS;
Database db;
- String query;
DbStatement* pStmt = null;
DbEnumerator* pEnum = null;
- int uniqueId = 0;
+ String query;
+ //int id = 0;
+ PackageInfo* pPkgInfo = null;
+ _PackageInfoImpl* pPackageInfoImpl = null;
+ ArrayList* pList = null;
+
+ pPkgInfo = GetPackageInfoN(packageId);
+ SysTryCatch(NID_APP, pPkgInfo != null, , r, "[%s] GetPackageInfoN() is failed", GetErrorMessage(r));
- 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));
+ pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPkgInfo);
+ query.Format(1024, L"SELECT * FROM AppInfo WHERE ID = %d", pPackageInfoImpl->GetUniqueId());
- query.Format(1024, L"SELECT * FROM %ls WHERE %ls = '%ls'", tableName.GetPointer(), columnName.GetPointer(), value.GetPointer());
+ 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()));
+ 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)
+ pList = new (std::nothrow) ArrayList;
+ SysTryReturn(NID_APP, pList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Container allocation failure.");
+
+ pList->Construct();
+
+ while (pEnum->MoveNext() == E_SUCCESS)
{
+ _PackageAppInfoImpl* pPackageAppInfoImpl = new (std::nothrow) _PackageAppInfoImpl;
+ SysTryReturn(NID_APP, pPackageAppInfoImpl != null, null, E_OUT_OF_MEMORY, "pPackageAppInfoImpl instance must not be null.");
+
+ int uniqueId = 0;
+ int pkgId = 0;
+ String name;
+ String defaultapp;
+ String mainmenuIcon;
+ String settingIcon;
+ String quickpanelIcon;
+ 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);
+
+ pPackageAppInfoImpl->SetUniqueId(uniqueId);
+ pPackageAppInfoImpl->SetPkgId(pkgId);
+ pPackageAppInfoImpl->SetName(name);
+ pPackageAppInfoImpl->SetDefault(defaultapp);
+ pPackageAppInfoImpl->SetMainmenuIcon(mainmenuIcon);
+ pPackageAppInfoImpl->SetSettingIcon(settingIcon);
+ pPackageAppInfoImpl->SetQuickpanelIcon(quickpanelIcon);
+ pPackageAppInfoImpl->SetAppFeature(appFeature);
+ pPackageAppInfoImpl->SetPackageName(packageName);
+
+ pList->Add(*pPackageAppInfoImpl);
}
delete pEnum;
}
-//CATCH:
+CATCH:
+ delete pPkgInfo;
delete pStmt;
-
- return uniqueId;
+ return pList;
}
-result
-_PackageManagerImpl::GetRecord(const String& tableName, int uniqueId, const String& columnName, String& value) const
+ArrayList*
+_PackageManagerImpl::GetPackageAppFeatureListN(const PackageId& packageId, const Tizen::Base::String& appExecutableName) const
{
- result r = E_SUCCESS;
- Database db;
- String query;
- DbStatement* pStmt = null;
- DbEnumerator* pEnum = null;
+ ArrayList* pAppInfoList = GetPackageAppInfoImplListN(packageId);
+ SysTryReturn(NID_APP, pAppInfoList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] AppInfo list instance must not be null.");
+
+ ArrayList* pResult = null;
- 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));
+ for (int i = 0; i < pAppInfoList->GetCount(); i++)
+ {
+ const _PackageAppInfoImpl* pAppInfoImpl = static_cast<const _PackageAppInfoImpl*>(pAppInfoList->GetAt(i));
+ if (pAppInfoImpl == null)
+ {
+ continue;
+ }
- query.Format(1024, L"SELECT %ls FROM %ls WHERE UNIQUE_ID = %d", columnName.GetPointer(), tableName.GetPointer(), uniqueId);
+ if (pAppInfoImpl->GetName() == appExecutableName)
+ {
+ pResult = pAppInfoImpl->GetAppFeatureListN();
+ goto OUT;
+ }
+ }
- pStmt = CreateStatementN(db, query);
- //SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
+OUT:
+ pAppInfoList->RemoveAll(true);
+ delete pAppInfoList;
- pEnum = ExecuteStatementN(db, pStmt);
+ return pResult;
+}
- if (pEnum != null)
+HashMapT<String, _AppFeatureInfoImpl*>*
+_PackageManagerImpl::GetPackageAppFeatureMapN(const PackageId& packageId, const Tizen::Base::String& appExecutableName) const
+{
+ ArrayList* pAppInfoList = GetPackageAppInfoImplListN(packageId);
+ SysTryReturn(NID_APP, pAppInfoList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] AppInfo list instance must not be null.");
+
+ HashMapT<String, _AppFeatureInfoImpl*>* pResult = null;
+
+ std::auto_ptr<IEnumerator> pEnum(pAppInfoList->GetEnumeratorN());
+
+ while (pEnum->MoveNext() == E_SUCCESS)
{
- if (pEnum->MoveNext() == E_SUCCESS)
+ const _PackageAppInfoImpl* pAppInfoImpl = static_cast<const _PackageAppInfoImpl*>(pEnum->GetCurrent());
+ if (pAppInfoImpl == null)
{
- pEnum->GetStringAt(0, value);
+ continue;
}
- delete pEnum;
+ if (pAppInfoImpl->GetName() == appExecutableName)
+ {
+ pResult = pAppInfoImpl->GetAppFeatureMapN();
+ goto OUT;
+ }
}
-//CATCH:
- delete pStmt;
+OUT:
+ pAppInfoList->RemoveAll(true);
+ delete pAppInfoList;
- return r;
+ return pResult;
}
-result
-_PackageManagerImpl::RegisterPrivileges(int id, const String& privileges, const String& hmacPrivileges, int certType)
+ArrayList*
+_PackageManagerImpl::GetAppLaunchConditionListN(const String& packageName) const
{
- SysTryReturnResult(NID_APP, __pDb != null, E_SYSTEM, "__pDb is null");
-
result r = E_SUCCESS;
- String query;
+ Database db;
DbStatement* pStmt = null;
DbEnumerator* pEnum = null;
+ String query;
+ ArrayList* pList = null;
- query.Format(1024, L"INSERT INTO PkgPrivileges (ID, PRIVILEGES, HMAC_PPRIVILEGES, CERTIFICATE_TYPE) VALUES (?,?,?,?)");
+ query.Format(1024, L"SELECT LaunchCondition.* FROM LaunchCondition, AppInfo WHERE AppInfo.UNIQUE_ID = LaunchCondition.ID and AppInfo.PACKAGE_NAME = '%ls'", packageName.GetPointer());
- pStmt = CreateStatementN(*__pDb, query);
- SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
+ 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));
- 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));
- }
+ pStmt = CreateStatementN(db, query);
+ SysTryCatch(NID_APP, pStmt != null, GetLastResult(),
+ GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
- if (!privileges.IsEmpty())
+ pEnum = ExecuteStatementN(db, pStmt);
+ if (pEnum != null)
{
- r = pStmt->BindString(1, privileges);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
+ pList = new (std::nothrow) ArrayList;
+ SysTryReturn(NID_APP, pList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Container allocation failure.");
- 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));
- }
+ pList->Construct();
- 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));
- }
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ _LaunchConditionInfoImpl* pLaunchCondtion = new (std::nothrow) _LaunchConditionInfoImpl;
+ SysTryReturn(NID_APP, pLaunchCondtion != null, null, E_OUT_OF_MEMORY, "pLaunchCondtion instance must not be null.");
+
+ String name;
+ String value;
+
+ pEnum->GetStringAt(1, name);
+ pEnum->GetStringAt(2, value);
- pEnum = ExecuteStatementN(*__pDb, pStmt);
+ pLaunchCondtion->SetName(name);
+ pLaunchCondtion->SetValue(value);
- delete pStmt;
- pStmt = null;
- delete pEnum;
- pEnum = null;
+ pList->Add(*pLaunchCondtion);
+
+ SysLog(NID_APP, "Name[%ls], Value[%ls]", name.GetPointer(), value.GetPointer());
+ }
- r = GetLastResult();
+ delete pEnum;
+ }
CATCH:
delete pStmt;
- return r;
+ return pList;
}
result
pName->GetPointer(), packageId.GetPointer());
}
- r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
+ 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);
L"SELECT AppInfo.APP_NAME FROM AppInfo, PkgInfo WHERE AppInfo.ID = PkgInfo.UNIQUE_ID and AppInfo.APP_DEFAULT = '%s' and PkgInfo.PKG_ID = '%ls'",
"True", packageId.GetPointer());
- r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
+ 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);