Update GetPackageAppInfoListN() API.
[platform/framework/native/appfw.git] / src / app / package / FAppPkg_PackageManagerImpl.cpp
index 7d5aaf7..313be99 100755 (executable)
 #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"
@@ -359,7 +360,7 @@ _PackageManagerImpl::InstallPackage(const PackageId& packageId, const String& pa
 {
        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.");
@@ -704,23 +705,6 @@ _PackageManagerImpl::UninstallationEventHandler(int reqId, const char* pType, co
        return 0;
 }
 
-_PackageManagerImpl*
-_PackageManagerImpl::GetInstance(void)
-{
-       return PackageManager::GetInstance()->__pPackageManagerImpl;
-}
-
-result
-_PackageManagerImpl::Construct(void)
-{
-       ClearLastResult();
-
-       result r = __installationList.Construct();
-       SysTryReturnResult(NID_APP, r == E_SUCCESS, r, "The memory is insufficient.");
-
-       return E_SUCCESS;
-}
-
 PackageInfo*
 _PackageManagerImpl::GetPackageInfoFromFileN(const String& filePath) const
 {
@@ -736,962 +720,644 @@ _PackageManagerImpl::GetPackageInfoFromFileN(const String& filePath) const
        std::unique_ptr<char[]> pExtension(_StringConverter::CopyToCharArrayN(extension));
        SysTryReturn(NID_APP, pExtension, null, E_OUT_OF_MEMORY, "pExtension is null.");
 
-       bool res = false;
+       std::unique_ptr< PackageInfo > pPackageInfo(new (std::nothrow) PackageInfo);
+       SysTryReturn(NID_APP, pPackageInfo, null, E_OUT_OF_MEMORY, "pPackageInfo instance must not be null.");
 
-       if ((strcasecmp(pExtension.get(), "tpk") == 0) || (strcasecmp(pExtension.get(), "wgt") == 0))
+       SysLog(NID_APP, "packagePath = [%s], extension = [%s]", pPackagePath.get(), pExtension.get());
+
+       bool res = true;
+
+       if (strcasecmp(pExtension.get(), "tpk") == 0)
        {
-               SysLog(NID_APP, "packagePath = [%s], extension = [%s]", pPackagePath.get(), pExtension.get());
-               res = true;
+               _PackageParser packageParser;
+
+               res = packageParser.Construct(pPackageInfo.get());
+               SysTryReturn(NID_APP, res, null, E_PARSING_FAILED, "Construct() is failed. [%s]", pPackagePath.get());
+
+               res = packageParser.Parse(filePath);
+               SysTryReturn(NID_APP, res, null, E_PARSING_FAILED, "Parse() is failed. [%s]", pPackagePath.get());
        }
-       SysTryReturn(NID_APP, res == true, null, E_UNSUPPORTED_FORMAT, "invalid extension! - packagePath = [%s], extension = [%s]", pPackagePath.get(), pExtension.get());
+       else if (strcasecmp(pExtension.get(), "wgt") == 0)
+       {
+               pkgmgr_info* pPkgmgrInfo = null;
 
-       _PackageParser packageParser;
+               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());
 
-       PackageInfo* pPackageInfo = new (std::nothrow) PackageInfo;
-       SysTryReturn(NID_APP, pPackageInfo, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] pPackageInfo instance must not be null.");
+               _package_manager_pkg_detail_info_t* pPkgInfo = (_package_manager_pkg_detail_info_t*) pPkgmgrInfo;
+               _PackageInfoImpl* pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPackageInfo.get());
 
-       res = packageParser.Construct(pPackageInfo);
-       SysTryReturn(NID_APP, res, null, E_PARSING_FAILED, "Construct() is failed. [%s]", pPackagePath.get());
+               SysLog(NID_APP, "id(%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);
 
-       res = packageParser.Parse(filePath);
-       SysTryReturn(NID_APP, res, null, E_PARSING_FAILED, "Parse() is failed. [%s]", pPackagePath.get());
+               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);
 
-       return pPackageInfo;
-}
+               if (pPkgInfo->privilege_list)
+               {
+                       GList* pList = null;
+                       pList = g_list_first(pPkgInfo->privilege_list);
+                       while (pList)
+                       {
+                               char* pPrivilege = (char*)pList->data;
+                               if (pPrivilege)
+                               {
+                                       pPackageInfoImpl->AddPrivilege(*new (std::nothrow) String(pPrivilege));
+                                       free(pPrivilege);
+                               }
+                               pList = g_list_next(pList);
+                       }
+                       g_list_free(pPkgInfo->privilege_list);
+               }
 
-IList*
-_PackageManagerImpl::GetPackageInfoListN(const IMap& packageFilterMap) const
-{
-       SysTryReturn(NID_APP, packageFilterMap.GetCount() > 0, null, E_INVALID_ARG, "packageFilterMap.GetCount() is invalid.");
+               std::unique_ptr< PackageAppInfo > pPackageAppInfo(new (std::nothrow) PackageAppInfo);
+               SysTryReturn(NID_APP, pPackageAppInfo, null, E_OUT_OF_MEMORY, "pPackageAppInfo instance must not be null.");
 
-       return null;
-}
+               _PackageAppInfoImpl* pPackageAppInfoImpl = _PackageAppInfoImpl::GetInstance(pPackageAppInfo.get());
 
-IList*
-_PackageManagerImpl::GetPackageAppInfoListN(const IMap& packageAppFilterMap) const
-{
-       SysTryReturn(NID_APP, packageAppFilterMap.GetCount() > 0, null, E_INVALID_ARG, "packageAppFilterMap.GetCount() is invalid.");
+               pPackageAppInfoImpl->SetAppId(pPkgInfo->pkg_name);
+               pPackageAppInfoImpl->SetAppName(pPkgInfo->label);
+               pPackageAppInfoImpl->SetAppDisplayName(pPkgInfo->label);
+               pPackageAppInfoImpl->SetMainApp(true);
+               if ((pPkgInfo->icon_buf) && (pPkgInfo->icon_size > 0))
+               {
+                       String iconPath("/tmp/icon.png");
+                       File file;
+                       file.Construct(iconPath, "w+");
+                       file.Write(pPkgInfo->icon_buf, pPkgInfo->icon_size);
 
-       return null;
+                       pPackageAppInfoImpl->SetAppTempIconPath(iconPath);
+               }
+
+               pPackageInfoImpl->AddPackageAppInfo(*pPackageAppInfo.release());
+
+               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();
 }
 
 IList*
-_PackageManagerImpl::GetPackageAppInfoListN(const IMap& packageFilterMap, const IMap& packageAppFilterMap) const
+_PackageManagerImpl::GetPackageInfoListN(const IMap& packageFilterMap) const
 {
        SysTryReturn(NID_APP, packageFilterMap.GetCount() > 0, null, E_INVALID_ARG, "packageFilterMap.GetCount() is invalid.");
-       SysTryReturn(NID_APP, packageAppFilterMap.GetCount() > 0, null, E_INVALID_ARG, "packageAppFilterMap.GetCount() is invalid.");
 
-       return null;
-}
+       std::unique_ptr<IMapEnumerator> pEnum(packageFilterMap.GetMapEnumeratorN());
+       SysTryReturn(NID_APP, pEnum, null, E_INVALID_ARG, "GetMapEnumeratorN() is failed.");
 
-_PackageManagerImpl::_PackageManagerImpl(void)
-:__pRequestClient(null),
-__pListeningClient(null),
-__pDb(null)
-{
-       CreatePackageTables();
-}
+       std::unique_ptr< ArrayList > pList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_APP, pList, null, E_OUT_OF_MEMORY, "pList is null.");
 
-_PackageManagerImpl::~_PackageManagerImpl(void)
-{
-}
+       pList->Construct();
 
-void
-_PackageManagerImpl::SendPackageEvent(PackageType type, const PackageId& packageId, const char* pEventKey, const char* pEventValue)
-{
-       result r = E_SUCCESS;
-       bool install = true;
+       int res = PMINFO_R_OK;
+       pkgmgrinfo_pkginfo_filter_h handle = null;
 
-       if (strcmp(pEventKey, "start") == 0)
+       res = pkgmgrinfo_pkginfo_filter_create(&handle);
+       SysTryReturn(NID_APP, res == PMINFO_R_OK, null, E_SYSTEM, "pkgmgrinfo_pkginfo_filter_create() is failed. [%d]", res);
+
+       while(pEnum->MoveNext() == E_SUCCESS)
        {
-               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.");
+               String* pKey = static_cast< String* >(pEnum->GetKey());
+               SysTryCatch(NID_APP, pKey, , E_INVALID_ARG, "GetKey() is failed.");
 
-                       String* pOperation = new (std::nothrow) String(pEventValue);
-                       SysTryReturnVoidResult(NID_APP, pOperation != null, E_OUT_OF_MEMORY, "pOperation instance must not be null.");
+               Boolean* pVal = static_cast< Boolean* >(pEnum->GetValue());
+               SysTryCatch(NID_APP, pVal, , E_INVALID_ARG, "GetValue() is failed.");
 
-                       r = __installationList.Add(*pAppId, *pOperation);
-                       if (IsFailed(r))
-                       {
-                               delete pAppId;
-                               delete pOperation;
-                               SysLog(NID_APP, "Failed to add installation condition.");
-                               SetLastResult(E_SYSTEM);
-                               return;
-                       }
+               bool value = pVal->ToBool();
+
+               SysLog(NID_APP, "Key[%ls], Value[%d]", pKey->GetPointer(), value);
+
+               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 (strcmp(pEventKey, "end") == 0)
-       {
-               String* pOperation = static_cast <String*>(__installationList.GetValue(packageId));
-               if (pOperation)
+               else if ((*pKey) == PACKAGE_FILTER_DOWNLOADED)
                {
-                       if (pOperation->Equals("uninstall", true) == true)
+                       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_EXTERNAL_STORAGE)
+               {
+                       String installedStorage;
+                       if (value == true)
                        {
-                               install = false;
+                               installedStorage = L"installed_external";
                        }
-
-                       r = __installationList.Remove(packageId, true);
-                       if (IsFailed(r))
+                       else
                        {
-                               SysLogException(NID_APP, r, "[%s] Remove Element [%ls] is failed from installing list.", GetErrorMessage(r), packageId.GetPointer());
+                               installedStorage = L"installed_internal";
                        }
-               }
-       }
-
-       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)
-               {
-                       _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;
+                       std::unique_ptr<char[]> pInstalledStorage(_StringConverter::CopyToCharArrayN(installedStorage));
+                       SysTryCatch(NID_APP, pInstalledStorage, , E_OUT_OF_MEMORY, "pInstalledStorage is null.");
 
-                       r = pEvent->Fire(*pEventArg);
-                       if (r != E_SUCCESS)
-                       {
-                               SysLog(NID_APP, "pEvent->Fire(*pEventArg) failed. [%s]", GetErrorMessage(r));
-                       }
+                       SysLog(NID_APP, "Value[%d]->[%s]", value, pInstalledStorage.get());
 
-                       SysLog(NID_APP, "PackageId = [%ls], Key = [%ls], Value = [%ls], install = [%d]", pEventArg->__packageId.GetPointer(), pEventArg->__eventKey.GetPointer(), pEventArg->__eventValue.GetPointer(), pEventArg->__install);
+                       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
                {
-                       SysLog(NID_APP, "pEvent is null.");
+                       SysTryCatch(NID_APP, false, , E_INVALID_ARG, "Invalid key(%ls)", pKey->GetPointer());
                }
        }
+
+       res = pkgmgrinfo_pkginfo_filter_foreach_pkginfo(handle, PackageInfoHandler, pList.get());
+       SysTryCatch(NID_APP, res == PMINFO_R_OK, , E_SYSTEM, "pkgmgrinfo_pkginfo_filter_foreach_pkginfo() failed. [%d]", res);
+
+CATCH:
+       if (handle)
+       {
+               pkgmgrinfo_pkginfo_filter_destroy(handle);
+       }
+
+       if (pList->GetCount() <= 0)
+       {
+               AppLog("pList's count is 0.");
+               return null;
+       }
+
+       return pList.release();
 }
 
-PackageInfo*
-_PackageManagerImpl::GetPackageInfoN(PackageType packageType, const String& packageName) const
+IList*
+_PackageManagerImpl::GetPackageAppInfoListN(const IMap& packageAppFilterMap) const
 {
-       SysTryReturn(NID_APP, packageName.IsEmpty() == false, null, E_INVALID_ARG, "[E_INVALID_ARG] packageName is empty.");
+       SysTryReturn(NID_APP, packageAppFilterMap.GetCount() > 0, null, E_INVALID_ARG, "packageAppFilterMap.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(packageAppFilterMap.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, "r");
-       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 = 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;
 
-       SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
+       res = pkgmgrinfo_appinfo_filter_create(&handle);
+       SysTryReturn(NID_APP, res == PMINFO_R_OK, null, E_SYSTEM, "pkgmgrinfo_appinfo_filter_create() is failed. [%d]", res);
 
-       pEnum = ExecuteStatementN(db, pStmt);
-       if (pEnum != null)
+       res = pkgmgrinfo_appinfo_metadata_filter_create(&metaHandle);
+       SysTryReturn(NID_APP, res == PMINFO_R_OK, null, E_SYSTEM, "pkgmgrinfo_appinfo_metadata_filter_create() is failed. [%d]", res);
+
+       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);
+               if ((*pKey) == PACKAGE_APP_FILTER_MENUICON_VISIBLE)
+               {
+                       definedKey = true;
 
-                       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;
+                       Boolean* pVal = static_cast< Boolean* >(pEnum->GetValue());
+                       SysTryCatch(NID_APP, pVal, , E_INVALID_ARG, "GetValue() is failed.");
 
-                       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);
+                       bool nodisplay = !(pVal->ToBool());
+                       SysLog(NID_APP, "Key[%ls], Value[%d]", pKey->GetPointer(), nodisplay);
 
-                       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);
+                       res = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_NODISPLAY, nodisplay);
+                       SysTryCatch(NID_APP, res == PMINFO_R_OK, , E_SYSTEM, "pkgmgrinfo_pkginfo_filter_add_bool(NODISPLAY, %d) is failed. [%d]", nodisplay, res);
                }
+               else if ((*pKey) == PACKAGE_APP_FILTER_CATEGORY)
+               {
+                       definedKey = true;
 
-               delete pEnum;
-       }
-       else
-       {
-               r = E_OBJ_NOT_FOUND;
-       }
+                       String* pVal = static_cast< String* >(pEnum->GetValue());
+                       SysTryCatch(NID_APP, pVal, , E_INVALID_ARG, "GetValue() is failed.");
 
-CATCH:
-       delete pStmt;
-       return pPackageInfo;
-}
+                       SysLog(NID_APP, "Key[%ls], Value[%ls]", pKey->GetPointer(), pVal->GetPointer());
 
-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[]> pValue(_StringConverter::CopyToCharArrayN(*pVal));
+                       SysTryCatch(NID_APP, pValue, , E_OUT_OF_MEMORY, "pValue is null.");
 
-       int result = 0;
-       char* pPackage = null;
-       ArrayList* pList = (ArrayList*)pUserData;
+                       res = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_CATEGORY, pValue.get());
+                       SysTryCatch(NID_APP, res == PMINFO_R_OK, , E_SYSTEM, "pkgmgrinfo_appinfo_filter_add_string(CATEGORY, %s) is failed. [%d]", pValue.get(), res);
+               }
+               else
+               {
+                       metadataKey = true;
 
-       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.");
+                       String* pVal = static_cast< String* >(pEnum->GetValue());
+                       SysTryCatch(NID_APP, pVal, , E_INVALID_ARG, "GetValue() is failed.");
 
-       _PackageInfoImpl* pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPackageInfo);
+                       SysLog(NID_APP, "Key[%ls], Value[%ls]", pKey->GetPointer(), pVal->GetPointer());
 
-       result = pkgmgrinfo_pkginfo_get_pkgname(handle, &pPackage);
-       if (result == 0)
+                       std::unique_ptr<char[]> pMetaKey(_StringConverter::CopyToCharArrayN(*pKey));
+                       SysTryCatch(NID_APP, pMetaKey, , E_OUT_OF_MEMORY, "pMetaKey is null.");
+
+                       std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(*pVal));
+                       SysTryCatch(NID_APP, pValue, , E_OUT_OF_MEMORY, "pValue is null.");
+
+                       res = pkgmgrinfo_appinfo_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))
        {
-               SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_pkgname(): package = [%s]", pPackage);
+               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
+       else if ((definedKey == false) && (metadataKey == true))
        {
-               SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_pkgname() is failed. result = [%d]", result);
+               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();
 
-       pPackageInfoImpl->Construct(pPackage);
-       pList->Add(*pPackageInfo);
-
-       return result;
-}
+               res = pkgmgrinfo_appinfo_filter_foreach_appinfo(handle, PackageAppInfoHandler, &list);
+               if (res != PMINFO_R_OK)
+               {
+                       SysLog(NID_APP, "pkgmgrinfo_appinfo_filter_foreach_appinfo() is failed. result = [%d]", res);
+                       goto CATCH;
+               }
 
-IList*
-_PackageManagerImpl::GetFilteredAppIdListN(const String& feature, const String& value) const
-{
-       result r = E_SUCCESS;
-       Database db;
-       DbStatement* pStmt = null;
-       DbEnumerator* pEnum = null;
-       String query;
-       ArrayList* pList = null;
+               metadataList.Construct();
 
-       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());
+               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;
+               }
 
-       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));
+               for (int i = 0; i < list.GetCount(); i++)
+               {
+                       PackageAppInfo* pPackageAppInfo = dynamic_cast < PackageAppInfo* >(list.GetAt(i));
+                       if (pPackageAppInfo)
+                       {
+                               AppLog("PackageAppFilter - AppId [%ls]", pPackageAppInfo->GetAppId().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< AppId > pAppId(new (std::nothrow) AppId(pPackageAppInfo->GetAppId()));
+                               appIdList.Add(pAppId.release());
+                       }
+               }
 
-       pEnum = ExecuteStatementN(db, pStmt);
+               for (int j = 0; j < metadataList.GetCount(); j++)
+               {
+                       PackageAppInfo* pPackageAppInfo = dynamic_cast < PackageAppInfo* >(metadataList.GetAt(j));
+                       if (pPackageAppInfo)
+                       {
+                               AppId appId = pPackageAppInfo->GetAppId();
 
-       if (pEnum != null)
-       {
-               pList = new (std::nothrow) ArrayList();
-               SysTryReturn(NID_APP, pList != null, null, E_OUT_OF_MEMORY, "ArrayList creation failure.");
-               pList->Construct();
+                               if (appIdList.Contains(appId) == true)
+                               {
+                                       AppLog("AppId [%ls] is matched.", appId.GetPointer());
 
-               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.");
+                                       std::unique_ptr< PackageAppInfo > pAppInfo(new (std::nothrow) PackageAppInfo);
+                                       SysTryCatch(NID_APP, pAppInfo, , E_OUT_OF_MEMORY, "pAppInfo is null.");
 
-                       pEnum->GetStringAt(0, *pPackageName);
+                                       _PackageAppInfoImpl* pPackageAppInfoImpl = _PackageAppInfoImpl::GetInstance(pAppInfo.get());
+                                       pPackageAppInfoImpl->Construct(appId);
 
-                       pList->Add(*pPackageName);
+                                       pList->Add(pAppInfo.release());
+                               }
+                               else
+                               {
+                                       AppLog("AppId [%ls] is not matched.", pPackageAppInfo->GetAppId().GetPointer());
+                               }
+                       }
                }
+       }
 
-               delete pEnum;
+CATCH:
+       if (handle)
+       {
+               pkgmgrinfo_appinfo_filter_destroy(handle);
+       }
 
+       if (metaHandle)
+       {
+               pkgmgrinfo_appinfo_metadata_filter_destroy(metaHandle);
        }
-       else
+
+       if (pList->GetCount() <= 0)
        {
-               r = E_OBJ_NOT_FOUND;
+               AppLog("pList's count is 0.");
+               return null;
        }
 
-CATCH:
-       delete pStmt;
-       return pList;
+       return pList.release();
 }
 
 IList*
-_PackageManagerImpl::GetDataControlInfoN(const String& providerId, const String& type) const
+_PackageManagerImpl::GetPackageAppInfoListN(const IMap& packageFilterMap, const IMap& packageAppFilterMap) 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());
-
-       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));
+       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.");
 
-       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);
+       ArrayList appIdList;
 
-       if (pEnum != null)
+       std::unique_ptr< IList > pPackageFilterList(GetPackageInfoListN(packageFilterMap));
+       if (pPackageFilterList == null)
        {
-               pList = new (std::nothrow) ArrayList();
-               SysTryReturn(NID_APP, pList != null, null, E_OUT_OF_MEMORY, "ArrayList creation failure.");
-               pList->Construct();
+               SysLog(NID_APP, "GetPackageInfoListN(packageFilterMap) is null.");
+               return null;
+       }
 
-               while (pEnum->MoveNext() == E_SUCCESS)
+       for (int i = 0; i < pPackageFilterList->GetCount(); i++)
+       {
+               PackageInfo* pPackageInfo = dynamic_cast < PackageInfo* >(pPackageFilterList->GetAt(i));
+               if (pPackageInfo)
                {
-                       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.");
-
-                       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.");
-
-                       pEnum->GetStringAt(0, *pPackageName);
-                       pList->Add(*pPackageName);
+                       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)
+                                       {
+                                               AppLog("PackageFilter - AppId [%ls]", pPackageAppInfo->GetAppId().GetPointer());
 
-                       pEnum->GetStringAt(1, *pAccess);
-                       pList->Add(*pAccess);
+                                               std::unique_ptr< AppId > pAppId(new (std::nothrow) AppId(pPackageAppInfo->GetAppId()));
+                                               appIdList.Add(pAppId.release());
+                                       }
+                               }
+                       }
                }
+       }
 
-               delete pEnum;
+       std::unique_ptr< ArrayList > pList(new (std::nothrow) ArrayList);
+       SysTryReturn(NID_APP, pList, null, E_OUT_OF_MEMORY, "pList is null.");
 
-       }
-       else
+       std::unique_ptr< IList > pAppFilterList(GetPackageAppInfoListN(packageAppFilterMap));
+       if (pAppFilterList == null)
        {
-               r = E_OBJ_NOT_FOUND;
+               SysLog(NID_APP, "GetPackageAppInfoListN(packageAppFilterMap) is null.");
+               return null;
        }
 
-CATCH:
-       delete pStmt;
-       return pList;
-}
-
-IMap*
-_PackageManagerImpl::GetUiThemeListN(const PackageId& packageId) const
-{
-       result r = E_SUCCESS;
-       Database db;
-       DbStatement* pStmt = null;
-       DbEnumerator* pEnum = null;
-       String query;
-       HashMap* pList = 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());
-
-       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
-       SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
-
-       pStmt = CreateStatementN(db, query);
-       SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
-
-       pEnum = ExecuteStatementN(db, pStmt);
-
-       if (pEnum != null)
+       for (int k = 0; k < pAppFilterList->GetCount(); k++)
        {
-               pList = new (std::nothrow) HashMap();
-               SysTryReturn(NID_APP, pList != null, null, E_OUT_OF_MEMORY, "HashMap creation failure.");
-               pList->Construct();
-
-               while (pEnum->MoveNext() == E_SUCCESS)
+               PackageAppInfo* pPackageAppInfo = dynamic_cast < PackageAppInfo* >(pAppFilterList->GetAt(k));
+               if (pPackageAppInfo)
                {
-                       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.");
-
-                       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.");
+                       AppId appId = pPackageAppInfo->GetAppId();
+                       AppLog("AppFilter - AppId [%ls]", appId.GetPointer());
 
-                       pEnum->GetStringAt(0, *pName);
-                       pEnum->GetStringAt(1, *pValue);
+                       if (appIdList.Contains(appId) == true)
+                       {
+                               AppLog("AppId [%ls] is matched.", appId.GetPointer());
 
-                       pList->Add(*pName, *pValue);
-               }
+                               std::unique_ptr< PackageAppInfo > pPackageAppInfo(new (std::nothrow) PackageAppInfo);
+                               SysTryReturn(NID_APP, pPackageAppInfo, null, E_OUT_OF_MEMORY, "PackageAppInfo is null.");
 
-               delete pEnum;
+                               _PackageAppInfoImpl* pPackageAppInfoImpl = _PackageAppInfoImpl::GetInstance(pPackageAppInfo.get());
+                               pPackageAppInfoImpl->Construct(appId);
 
+                               pList->Add(pPackageAppInfo.release());
+                       }
+                       else
+                       {
+                               AppLog("AppId [%ls] is not matched.", pPackageAppInfo->GetAppId().GetPointer());
+                       }
+               }
        }
-       else
+
+       if (pList->GetCount() <= 0)
        {
-               r = E_OBJ_NOT_FOUND;
+               AppLog("pList's count is 0.");
+               return null;
        }
 
-CATCH:
-       delete pStmt;
-       return pList;
+       return pList.release();
 }
 
-bool
-_PackageManagerImpl::IsAppInstalled(const AppId& appId)
+int
+_PackageManagerImpl::PackageInfoHandler(const pkgmgrinfo_pkginfo_h handle, void* pUserData)
 {
-       if (appId == _AppInfo::GetPackageId())
-       {
-               return true;
-       }
+       SysTryReturn(NID_APP, handle, 0, E_SYSTEM, "handle must not be null.");
+       SysTryReturn(NID_APP, pUserData, 0, E_SYSTEM, "pUserData must not be null.");
 
-       int result = 0;
-       pkgmgrinfo_pkginfo_h pPackageInfoHandle = null;
+       result r = E_SUCCESS;
+       int res = PMINFO_R_OK;
+       char* pPackageId = null;
+       ArrayList* pList = (ArrayList*)pUserData;
 
-       std::unique_ptr<char[]> pPackageId(_StringConverter::CopyToCharArrayN(appId));
-       SysTryReturn(NID_APP, pPackageId, false, E_OUT_OF_MEMORY, "pPackageId is null");
+       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);
 
-       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());
+       std::unique_ptr<PackageInfo> pPackageInfo(new (std::nothrow) PackageInfo);
+       SysTryReturn(NID_APP, pPackageInfo, 0, E_OUT_OF_MEMORY, "pPackageInfo instance must not be null.");
 
-       if(pPackageInfoHandle)
-       {
-               pkgmgrinfo_pkginfo_destroy_pkginfo(pPackageInfoHandle);
-       }
+       _PackageInfoImpl* pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPackageInfo.get());
+       r = pPackageInfoImpl->Construct(pPackageId);
+       SysTryReturn(NID_APP, r == E_SUCCESS, 0, E_SYSTEM, "Construct(%s) is failed.", pPackageId);
 
-       return true;
+       pList->Add(*pPackageInfo.release());
+
+       return 0;
 }
 
 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)
+_PackageManagerImpl::PackageAppInfoHandler(const pkgmgrinfo_appinfo_h handle, void* pUserData)
 {
-       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, handle, 0, E_SYSTEM, "handle must not be null.");
+       SysTryReturn(NID_APP, pUserData, 0, E_SYSTEM, "pUserData must not be null.");
 
-       PackageType type = PACKAGE_TYPE_TPK;
-       PackageId packageId(pkg_name);
+       result r = E_SUCCESS;
+       int res = PMINFO_R_OK;
+       char* pAppId = null;
+       ArrayList* pList = (ArrayList*)pUserData;
 
-       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;
-       }
+       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);
 
-       _PackageManagerImpl* pThis = _PackageManagerImpl::GetInstance();
-       pThis->SendPackageEvent(type, packageId, key, val);
+       SysLog(NID_APP, "appId = [%s]", pAppId);
+
+       std::unique_ptr<PackageAppInfo> pPackageAppInfo(new (std::nothrow) PackageAppInfo);
+       SysTryReturn(NID_APP, pPackageAppInfo, 0, E_OUT_OF_MEMORY, "pPackageAppInfo instance must not be null.");
+
+       _PackageAppInfoImpl* pPackageAppInfoImpl = _PackageAppInfoImpl::GetInstance(pPackageAppInfo.get());
+       r = pPackageAppInfoImpl->Construct(pAppId);
+       SysTryReturn(NID_APP, r == E_SUCCESS, 0, E_SYSTEM, "Construct(%s) is failed.", pAppId);
+
+       pList->Add(*pPackageAppInfo.release());
 
        return 0;
 }
 
-String*
-_PackageManagerImpl::GetAppIdOfDataControlN(const String& providerId)
+int
+_PackageManagerImpl::PackageAppInfoMetadataHandler(const pkgmgrinfo_appinfo_h handle, void* pUserData)
 {
-       result r = E_SUCCESS;
-       Database db;
-       DbStatement* pStmt = null;
-       DbEnumerator* pEnum = null;
-       String query;
-       String* pAppId = null;
-
-       query.Format(1024, L"SELECT PkgInfo.PKG_ID FROM PkgInfo, AppInfo, DataControl WHERE DataControl.PROVIDER_ID = '%ls' and DataControl.ID = AppInfo.UNIQUE_ID and AppInfo.ID = PkgInfo.UNIQUE_ID",
-                       providerId.GetPointer());
+       SysTryReturn(NID_APP, handle, 0, E_SYSTEM, "handle must not be null.");
+       SysTryReturn(NID_APP, pUserData, 0, E_SYSTEM, "pUserData must not be 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));
+       result r = E_SUCCESS;
+       int res = PMINFO_R_OK;
+       char* pAppId = null;
+       ArrayList* pList = (ArrayList*)pUserData;
 
-       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_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, "appId = [%s]", pAppId);
 
-       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");
+       std::unique_ptr< PackageAppInfo > pPackageAppInfo(new (std::nothrow) PackageAppInfo);
+       SysTryReturn(NID_APP, pPackageAppInfo, 0, E_OUT_OF_MEMORY, "pPackageAppInfo instance must not be null.");
 
-                       pEnum->GetStringAt(0, *pAppId);
-               }
+       _PackageAppInfoImpl* pPackageAppInfoImpl = _PackageAppInfoImpl::GetInstance(pPackageAppInfo.get());
+       r = pPackageAppInfoImpl->Construct(pAppId);
+       SysTryReturn(NID_APP, r == E_SUCCESS, 0, E_SYSTEM, "Construct(%s) is failed.", pAppId);
 
-               delete pEnum;
-       }
+       pList->Add(*pPackageAppInfo.release());
 
-CATCH:
-       delete pStmt;
-       return pAppId;
+       return 0;
 }
 
-result
-_PackageManagerImpl::CreatePackageTables(void)
+_PackageManagerImpl*
+_PackageManagerImpl::GetInstance(void)
 {
-       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,"
-                                                    "STR_PRIVILEGES            TEXT )");
-       r = db.ExecuteSql(createQuery, true);
-       SysTryReturn(NID_APP, r == E_SUCCESS, r, r, "MakePackageDb: db.ExecuteSql is failed. [%s]", GetErrorMessage(r));
-       createQuery.Clear();
-
-       // PkgIntegrity
-       createQuery.Format(1024, L"CREATE TABLE IF NOT EXISTS PkgIntegrity"
-                                                        "( ID                          INTEGER,"
-                                                        "HMAC_APPID                                    TEXT,"
-                                                        "HMAC_APPSECRET                                TEXT,"
-                                                        "HMAC_HTB                                              TEXT,"
-                                                        "SLOT_NUM                              INTEGER )");
-       r = db.ExecuteSql(createQuery, true);
-       SysTryReturn(NID_APP, r == E_SUCCESS, r, r, "MakePackageDb: db.ExecuteSql is failed. [%s]", GetErrorMessage(r));
-       createQuery.Clear();
-
-       // AppInfo
-       createQuery.Format(1024, L"CREATE TABLE IF NOT EXISTS AppInfo"
-                                                        "( UNIQUE_ID                                   INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,"
-                                                        "ID                            INTEGER,"
-                                                        "APP_NAME                  TEXT,"
-                                                        "APP_TYPE                  TEXT,"
-                                                        "APP_DEFAULT                   TEXT,"
-                                                        "APP_MAINMENU_ICON             TEXT,"
-                                                        "APP_SETTING_ICON          TEXT,"
-                                                        "APP_TICKER_ICON                               TEXT,"
-                                                        "APP_QUICKPANEL_ICON                   TEXT,"
-                                                        "APP_LAUNCHIMAGE_ICON      TEXT,"
-                                                        "APP_FEATURE               INTEGER,"
-                                                        "PACKAGE_NAME              TEXT )");
-       r = db.ExecuteSql(createQuery, true);
-       SysTryReturn(NID_APP, r == E_SUCCESS, r, r, "MakePackageDb: db.ExecuteSql is failed. [%s]", GetErrorMessage(r));
-       createQuery.Clear();
-
-       // Notification
-       createQuery.Format(1024, L"CREATE TABLE IF NOT EXISTS Notification"
-                                                        "( ID                          INTEGER,"
-                                                        "NAME                      TEXT,"
-                                                        "VALUE                     TEXT )");
-       r = db.ExecuteSql(createQuery, true);
-       SysTryReturn(NID_APP, r == E_SUCCESS, r, r, "MakePackageDb: db.ExecuteSql is failed. [%s]", GetErrorMessage(r));
-       createQuery.Clear();
-
-       // AppFeature
-       createQuery.Format(1024, L"CREATE TABLE IF NOT EXISTS AppFeature"
-                                                        "( ID                          INTEGER,"
-                                                        "NAME                      TEXT,"
-                                                        "VALUE                     TEXT )");
-       r = db.ExecuteSql(createQuery, true);
-       SysTryReturn(NID_APP, r == E_SUCCESS, r, r, "MakePackageDb: db.ExecuteSql is failed. [%s]", GetErrorMessage(r));
-       createQuery.Clear();
-
-       // LaunchCondition
-       createQuery.Format(1024, L"CREATE TABLE IF NOT EXISTS LaunchCondition"
-                                                        "( ID                          INTEGER,"
-                                                        "NAME                      TEXT,"
-                                                        "VALUE                     TEXT )");
-       r = db.ExecuteSql(createQuery, true);
-       SysTryReturn(NID_APP, r == E_SUCCESS, r, r, "MakePackageDb: db.ExecuteSql is failed. [%s]", GetErrorMessage(r));
-       createQuery.Clear();
-
-       // DataControl
-       createQuery.Format(1024, L"CREATE TABLE IF NOT EXISTS DataControl"
-                                                        "( ID INTEGER,"
-                                                        "PROVIDER_ID TEXT,"
-                                                        "TYPE TEXT,"
-                                                        "ACCESS TEXT )");
-       r = db.ExecuteSql(createQuery, true);
-       SysTryReturn(NID_APP, r == E_SUCCESS, r, r, "MakePackageDb: db.ExecuteSql is failed. [%s]", GetErrorMessage(r));
-       createQuery.Clear();
-
-       // Capability
-       createQuery.Format(1024, L"CREATE TABLE IF NOT EXISTS Capability"
-                                                        "( ID                          INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,"
-                                                        "OPERATION_ID                          TEXT )");
-       r = db.ExecuteSql(createQuery, true);
-       SysTryReturn(NID_APP, r == E_SUCCESS, r, r, "MakePackageDb: db.ExecuteSql is failed. [%s]", GetErrorMessage(r));
-       createQuery.Clear();
-
-       // ResolutionUriScheme
-       createQuery.Format(1024, L"CREATE TABLE IF NOT EXISTS ResolutionUriScheme"
-                                                        "( ID                          INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,"
-                                                        "URI_SCHEME                            TEXT )");
-       r = db.ExecuteSql(createQuery, true);
-       SysTryReturn(NID_APP, r == E_SUCCESS, r, r, "MakePackageDb: db.ExecuteSql is failed. [%s]", GetErrorMessage(r));
-       createQuery.Clear();
-
-       // ResolutionMimeType
-       createQuery.Format(1024, L"CREATE TABLE IF NOT EXISTS ResolutionMimeType"
-                                                        "( ID                          INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,"
-                                                        "MIME_TYPE                             TEXT )");
-       r = db.ExecuteSql(createQuery, true);
-       SysTryReturn(NID_APP, r == E_SUCCESS, r, r, "MakePackageDb: db.ExecuteSql is failed. [%s]", GetErrorMessage(r));
-       createQuery.Clear();
-
-       // AppControl
-       createQuery.Format(1024, L"CREATE TABLE IF NOT EXISTS AppControl"
-                                                        "( ID                          INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,"
-                                                        "PROVIDER_ID                   TEXT,"
-                                                        "CATEGORY                                      TEXT )");
-       r = db.ExecuteSql(createQuery, true);
-       SysTryReturn(NID_APP, r == E_SUCCESS, r, r, "MakePackageDb: db.ExecuteSql is failed. [%s]", GetErrorMessage(r));
-       createQuery.Clear();
-
-       // AppInfoLookup
-       createQuery.Format(1024, L"CREATE TABLE IF NOT EXISTS AppInfoLookup"
-                                                        "( AppInfoID                   INTEGER,"
-                                                        "CapabilityID              INTEGER,"
-                                                        "ResolutionUriSchemeID         INTEGER,"
-                                                        "ResolutionMimeTypeID      INTEGER,"
-                                                        "AppControlID                              INTEGER )");
-       r = db.ExecuteSql(createQuery, true);
-       SysTryReturn(NID_APP, r == E_SUCCESS, r, r, "MakePackageDb: db.ExecuteSql is failed. [%s]", GetErrorMessage(r));
-       createQuery.Clear();
-
-       return r;
+       return PackageManager::GetInstance()->__pPackageManagerImpl;
 }
 
 result
-_PackageManagerImpl::RegisterPackageInfo(_PackageInfoImpl& pkgInfoImpl)
+_PackageManagerImpl::Construct(void)
 {
-       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()");
+       ClearLastResult();
 
-       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 (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
+       result r = __installationList.Construct();
+       SysTryReturnResult(NID_APP, r == E_SUCCESS, r, "The memory is insufficient.");
 
-       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));
+       return E_SUCCESS;
+}
 
-       pStmt = CreateStatementN(db, query);
-       //SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
-
-       PackageId packageId = pkgInfoImpl.GetAppId();
-       String appVersion = pkgInfoImpl.GetAppVersion();
-       String type = pkgInfoImpl.GetAppType();
-       String appMimeType = pkgInfoImpl.GetAppMimeType();
-       String appApiVersion = pkgInfoImpl.GetAppApiVersion();
-       String appName = pkgInfoImpl.GetAppName();
-       String appVendor = pkgInfoImpl.GetAppVendor();
-       String appDescription = pkgInfoImpl.GetAppDescription();
-       String appUrl = pkgInfoImpl.GetAppUrl();
-       String appCid = pkgInfoImpl.GetAppCid();
-
-       pkgInfoImpl.GetPrivilegesValue(privileges, hmacPrivileges);
-       String appRootPath = pkgInfoImpl.GetAppRootPath();
-       int appStorageType = pkgInfoImpl.GetAppStorageType();
-       int certType = pkgInfoImpl.GetCertType();
-       ArrayList* pAppInfoImplList = pkgInfoImpl.GetAppInfoList();
-
-       DateTime time;
-       r = SystemTime::GetCurrentTime(time);
-       SysTryCatch(NID_APP, r == E_SUCCESS, , r, "An error occurs while getting a current time.");
-
-       if (!packageId.IsEmpty())
-       {
-               r = pStmt->BindString(0, packageId);
-               SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
-       }
-
-       if (!appVersion.IsEmpty())
-       {
-               r = pStmt->BindString(2, appVersion);
-               SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
-       }
-
-       if (!type.IsEmpty())
-       {
-               r = pStmt->BindString(3, type);
-               SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
-       }
-
-       if (!appMimeType.IsEmpty())
-       {
-               r = pStmt->BindString(4, appMimeType);
-               SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
-       }
-
-       if (!appApiVersion.IsEmpty())
-       {
-               r = pStmt->BindString(5, appApiVersion);
-               SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
-       }
-
-       if (!appName.IsEmpty())
-       {
-               r = pStmt->BindString(6, appName);
-               SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
-       }
-
-       if (!appVendor.IsEmpty())
-       {
-               r = pStmt->BindString(7, appVendor);
-               SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
-       }
-
-       if (!appDescription.IsEmpty())
-       {
-               r = pStmt->BindString(8, appDescription);
-               SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
-       }
-
-       if (!appUrl.IsEmpty())
-       {
-               r = pStmt->BindString(9, appUrl);
-               SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
-       }
-
-       if (!appCid.IsEmpty())
-       {
-               r = pStmt->BindString(10, appCid);
-               SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
-       }
-
-       if (!appRootPath.IsEmpty())
-       {
-               r = pStmt->BindString(15, appRootPath);
-               SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
-       }
-
-       if (appStorageType != 0)
-       {
-               r = pStmt->BindInt(16, appStorageType);
-               SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
-       }
-
-       r = pStmt->BindDateTime(17, time);
-       SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
-
-       pEnum = ExecuteStatementN(db, pStmt);
-
-       r = GetLastResult();
-
-       uniqueId = pkgInfoImpl.GetUniqueId();
-
-       SysLog(NID_APP, "_PackageManagerImpl::RegisterPackageInfo()-GetUniqueId(%d)", uniqueId);
-
-       __pDb = &db;
-
-       // AppInfo
-       RegisterAppInfoList(uniqueId, pAppInfoImplList);
-
-       // PkgPrivileges
-       RegisterPrivileges(uniqueId, privileges, hmacPrivileges, certType);
-
-CATCH:
-       __pDb = null;
-       delete pEnum;
-       delete pStmt;
-       return r;
+_PackageManagerImpl::_PackageManagerImpl(void)
+:__pRequestClient(null),
+__pListeningClient(null)
+{
 }
 
-result
-_PackageManagerImpl::UnregisterPackageInfo(const PackageId& packageId)
+_PackageManagerImpl::~_PackageManagerImpl(void)
 {
-       SysLog(NID_APP, "packageId = [%ls]", packageId.GetPointer());
+}
 
+void
+_PackageManagerImpl::SendPackageEvent(PackageType type, const PackageId& packageId, const char* pEventKey, const char* pEventValue)
+{
        result r = E_SUCCESS;
-       Database db;
-       String query;
-       int id = 0;
-       PackageInfo* pPkgInfo;
-       _PackageInfoImpl* pPackageInfoImpl = null;
-       ArrayList* pList = null;
-
-       pPkgInfo = GetPackageInfoN(packageId);
-       SysTryReturn(NID_APP, pPkgInfo != null, r, r, "UnregisterPackageInfo: GetUniqueId() is invalid. [%d]", id);
+       bool install = true;
 
-       pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPkgInfo);
-       pPackageInfoImpl->SetAppId(packageId);
-       id = pPackageInfoImpl->GetUniqueId();
-       SysTryReturn(NID_APP, id > 0, r, r, "UnregisterPackageInfo: GetUniqueId() is invalid. [%d]", id);
+       if (strcmp(pEventKey, "start") == 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.");
 
-       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
-       SysTryReturn(NID_APP, r == E_SUCCESS, r, r, "UnregisterPackageInfo: db.Construct is failed. [%s]", GetErrorMessage(r));
+                       String* pOperation = new (std::nothrow) String(pEventValue);
+                       SysTryReturnVoidResult(NID_APP, pOperation != null, E_OUT_OF_MEMORY, "pOperation instance must not be null.");
 
-       // AppInfoLookup
-       pList = pPackageInfoImpl->GetAppInfoListN();
-       if (pList != null)
+                       r = __installationList.Add(*pAppId, *pOperation);
+                       if (IsFailed(r))
+                       {
+                               delete pAppId;
+                               delete pOperation;
+                               SysLog(NID_APP, "Failed to add installation condition.");
+                               SetLastResult(E_SYSTEM);
+                               return;
+                       }
+               }
+       }
+       else if (strcmp(pEventKey, "end") == 0)
        {
-               for (int i = 0; i < pList->GetCount(); i++)
+               String* pOperation = static_cast <String*>(__installationList.GetValue(packageId));
+               if (pOperation)
                {
-                       _PackageAppInfoImpl* pAppInfoImpl = dynamic_cast <_PackageAppInfoImpl*>(pList->GetAt(i));
-
-                       if (pAppInfoImpl != null)
+                       if (pOperation->Equals("uninstall", true) == true)
                        {
-                               int uniqueId = 0;
-                               uniqueId = pAppInfoImpl->GetUniqueId();
+                               install = false;
+                       }
 
-                               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.Remove(packageId, true);
+                       if (IsFailed(r))
+                       {
+                               SysLogException(NID_APP, r, "[%s] Remove Element [%ls] is failed from installing list.", GetErrorMessage(r), packageId.GetPointer());
                        }
                }
-               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;
-}
+       std::unique_ptr< IEnumeratorT<_PackageManagerEvent*> > pEnum(__packageEventListenerList.GetEnumeratorN());
+       SysTryReturnVoidResult(NID_APP, pEnum, E_OUT_OF_MEMORY, "The memory is insufficient.");
 
-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;
+       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 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());
+                       String eventKey(pEventKey);
+                       String eventValue(pEventValue);
 
-       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));
+                       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, "PackageId = [%ls], Key = [%ls], Value = [%ls], install = [%d]", pEventArg->__packageId.GetPointer(), pEventArg->__eventKey.GetPointer(), pEventArg->__eventValue.GetPointer(), pEventArg->__install);
+               }
+               else
                {
-                       PackageId packageId;
-                       pEnum->GetStringAt(0, packageId);
-
-                       pPkgInfo = GetPackageInfoN(packageId);
+                       SysLog(NID_APP, "pEvent is null.");
                }
-
-               delete pEnum;
-       }
-       else
-       {
-               r = E_OBJ_NOT_FOUND;
        }
-
-CATCH:
-       delete pStmt;
-       return pPkgInfo;
 }
 
-result
-_PackageManagerImpl::GetAppInfo(int uniqueId, _PackageAppInfoImpl& appInfo) 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;
+       PackageInfo *pPackageInfo = null;
 
-       query.Format(1024, L"SELECT * FROM AppInfo WHERE UNIQUE_ID = %d", uniqueId);
+       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, "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);
@@ -1699,37 +1365,54 @@ _PackageManagerImpl::GetAppInfo(int uniqueId, _PackageAppInfoImpl& appInfo) cons
        {
                if (pEnum->MoveNext() == E_SUCCESS)
                {
-                       int uniqueId = 0;
-                       int pkgId = 0;
-                       String name;
-                       String defaultapp;
-                       String mainmenuIcon;
-                       String settingIcon;
-                       String tickerIcon;
-                       String quickpanelIcon;
-                       String launchImageIcon;
-                       int appFeature = 0;
-                       String packageName;
+                       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.");
 
-                       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);
+                       _PackageInfoImpl* pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPackageInfo);
+
+                       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;
+
+                       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);
 
-                       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);
+                       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;
@@ -1741,155 +1424,41 @@ _PackageManagerImpl::GetAppInfo(int uniqueId, _PackageAppInfoImpl& appInfo) cons
 
 CATCH:
        delete pStmt;
-       return r;
-}
-
-ArrayList*
-_PackageManagerImpl::GetPackageAppInfoImplListN(const String& packageId) const
-{
-       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));
-
-       pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPkgInfo);
-       query.Format(1024, L"SELECT * FROM AppInfo WHERE ID = %d", pPackageInfoImpl->GetUniqueId());
-
-       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
-       SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
-
-       pStmt = CreateStatementN(db, query);
-       SysTryCatch(NID_APP, pStmt != null, GetLastResult(),
-                          GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
-
-       pEnum = ExecuteStatementN(db, pStmt);
-
-       if (pEnum != null)
-       {
-               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:
-       delete pPkgInfo;
-       delete pStmt;
-       return pList;
+       return pPackageInfo;
 }
 
-ArrayList*
-_PackageManagerImpl::GetPackageAppFeatureListN(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.");
-
-       ArrayList* pResult = null;
-
-       for (int i = 0; i < pAppInfoList->GetCount(); i++)
-       {
-               const _PackageAppInfoImpl* pAppInfoImpl = static_cast<const _PackageAppInfoImpl*>(pAppInfoList->GetAt(i));
-               if (pAppInfoImpl == null)
-               {
-                       continue;
-               }
-
-               if (pAppInfoImpl->GetName() == appExecutableName)
-               {
-                       pResult = pAppInfoImpl->GetAppFeatureListN();
-                       goto OUT;
-               }
-       }
-
-OUT:
-       pAppInfoList->RemoveAll(true);
-       delete pAppInfoList;
-
-       return pResult;
-}
+       SysTryReturn(NID_APP, handle != null, 0, E_SYSTEM, "[E_SYSTEM] handle must not be 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.");
+       int result = 0;
+       char* pPackage = null;
+       ArrayList* pList = (ArrayList*)pUserData;
 
-       HashMapT<String, _AppFeatureInfoImpl*>* pResult = null;
+       PackageInfo *pPackageInfo = new (std::nothrow) PackageInfo;
+       SysTryReturn(NID_APP, pPackageInfo != null, 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] pPackageInfo instance must not be null.");
 
-       std::auto_ptr<IEnumerator> pEnum(pAppInfoList->GetEnumeratorN());
+       _PackageInfoImpl* pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPackageInfo);
 
-       while (pEnum->MoveNext() == E_SUCCESS)
+       result = pkgmgrinfo_pkginfo_get_pkgname(handle, &pPackage);
+       if (result == 0)
        {
-               const _PackageAppInfoImpl* pAppInfoImpl = static_cast<const _PackageAppInfoImpl*>(pEnum->GetCurrent());
-               if (pAppInfoImpl == null)
-               {
-                       continue;
-               }
-
-               if (pAppInfoImpl->GetName() == appExecutableName)
-               {
-                       pResult = pAppInfoImpl->GetAppFeatureMapN();
-                       goto OUT;
-               }
+               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;
+       pPackageInfoImpl->Construct(pPackage);
+       pList->Add(*pPackageInfo);
 
-       return pResult;
+       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;
@@ -1898,43 +1467,38 @@ _PackageManagerImpl::GetAppLaunchConditionListN(const String& packageName) const
        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, "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:
@@ -1942,523 +1506,449 @@ 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;
-
-                               String name = pNotification->GetName();
-                               String value = pNotification->GetValue();
-
-                               query.Format(1024, L"INSERT INTO Notification (ID, NAME, VALUE) VALUES (?,?,?)");
-
-                               pStmt = CreateStatementN(*__pDb, query);
-                               //SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
-
-                               if (id != 0)
-                               {
-                                       r = pStmt->BindInt(0, id);
-                                       SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
-                               }
+               return true;
+       }
 
-                               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));
-                               }
+       int result = 0;
+       pkgmgrinfo_pkginfo_h pPackageInfoHandle = 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));
-                               }
+       std::unique_ptr<char[]> pPackageId(_StringConverter::CopyToCharArrayN(appId));
+       SysTryReturn(NID_APP, pPackageId, false, E_OUT_OF_MEMORY, "pPackageId is null");
 
-                               pEnum = ExecuteStatementN(*__pDb, pStmt);
+       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());
 
-                               query.Clear();
-                               delete pStmt;
-                               pStmt = null;
-                               delete pEnum;
-                       }
-               }
+       if(pPackageInfoHandle)
+       {
+               pkgmgrinfo_pkginfo_destroy_pkginfo(pPackageInfoHandle);
        }
 
-       r = GetLastResult();
-
-CATCH:
-       delete pStmt;
-
-       return r;
+       return true;
 }
 
-result
-_PackageManagerImpl::RegisterAppFeatureList(int id, ArrayList* pList)
+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)
 {
-       SysTryReturnResult(NID_APP, __pDb != null, E_SYSTEM, "__pDb is null");
+       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);
 
-       result r = E_SUCCESS;
-       String query;
-       DbStatement* pStmt = null;
+       PackageType type = PACKAGE_TYPE_TPK;
+       PackageId packageId(pkg_name);
 
-       if (pList != null)
+       if (strcmp(pkg_type, "tpk") == 0)
        {
-               for (int i = 0; i < pList->GetCount(); i++)
-               {
-                       _AppFeatureInfoImpl* pAppFeature = dynamic_cast<_AppFeatureInfoImpl*>(pList->GetAt(i));
+               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;
+       }
 
-                       if (pAppFeature != null)
-                       {
-                               DbEnumerator* pEnum = null;
+       _PackageManagerImpl* pThis = _PackageManagerImpl::GetInstance();
+       pThis->SendPackageEvent(type, packageId, key, val);
 
-                               String name = pAppFeature->GetName();
-                               String value = pAppFeature->GetValue();
+       return 0;
+}
 
-                               query.Format(1024, L"INSERT INTO AppFeature (ID, NAME, VALUE) VALUES (?,?,?)");
+String*
+_PackageManagerImpl::GetAppIdOfDataControlN(const String& providerId)
+{
+       result r = E_SUCCESS;
+       Database db;
+       DbStatement* pStmt = null;
+       DbEnumerator* pEnum = null;
+       String query;
+       String* pAppId = null;
 
-                               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 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());
 
-                               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;
 
-       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
-       //SysTryCatch(NID_APP, r == E_SUCCESS, r, r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
+       pPkgInfo = GetPackageInfoN(packageId);
+       SysTryCatch(NID_APP, pPkgInfo != null, , r, "[%s] GetPackageInfoN() is failed", GetErrorMessage(r));
 
-       query.Format(1024, L"SELECT * FROM %ls WHERE %ls = '%ls'", tableName.GetPointer(), columnName.GetPointer(), value.GetPointer());
+       pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPkgInfo);
+       query.Format(1024, L"SELECT * FROM AppInfo WHERE ID = %d", pPackageInfoImpl->GetUniqueId());
+
+       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.");
 
-       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
-       //SysTryCatch(NID_APP, r == E_SUCCESS, r, r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
+       ArrayList* pResult = null;
+
+       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