#include <FIoDatabase.h>
#include <FIoDbEnumerator.h>
#include <FIoDbStatement.h>
+#include <FIoFile.h>
#include <FBase_StringConverter.h>
#include "FAppPkg_PackageManagerImpl.h"
+#include "FApp_AppResourceImpl.h"
#include "FApp_TemplateUtil.h"
using namespace Tizen::Base;
return E_SUCCESS;
}
+const String&
+_PackageAppInfoImpl::GetAppTempIconPath(void) const
+{
+ return __appTempIconPath;
+}
+
+result
+_PackageAppInfoImpl::SetAppTempIconPath(const String& tempIconPath)
+{
+ __appTempIconPath = tempIconPath;
+ return E_SUCCESS;
+}
+
Bitmap*
_PackageAppInfoImpl::GetAppMenuIconN(void) const
{
- SysTryReturn(NID_APP, __appIconPath.IsEmpty() == false, null, E_FILE_NOT_FOUND, "appIconPath() is empty.");
+ Bitmap* pBitmap = null;
+ String iconPath;
- return null;
+ if (__fromDatabase)
+ {
+ SysTryReturn(NID_APP, __appIconPath.IsEmpty() == false, null, E_FILE_NOT_FOUND, "appIconPath() is empty.");
+
+ iconPath = __appIconPath;
+ }
+ else
+ {
+ SysTryReturn(NID_APP, __appTempIconPath.IsEmpty() == false, null, E_FILE_NOT_FOUND, "__appTempIconPath() is empty.");
+
+ iconPath = __appTempIconPath;
+ }
+
+ SysLog(NID_APP, "iconPath = [%ls]", iconPath.GetPointer());
+
+ pBitmap = _AppResourceImpl::GetNonScalingBitmapN(iconPath);
+
+ return pBitmap;
}
HashMap*
_PackageAppInfoImpl::GetAppMetadataListN(void) const
{
- HashMap* pMap = null;
-
if (__fromDatabase)
{
SysTryReturn(NID_APP, __pAppInfoHandle, null, E_SYSTEM, "__pAppInfoHandle is null.");
- result r = E_SUCCESS;
int res = PMINFO_R_OK;
- pMap = new (std::nothrow) HashMap();
+ std::unique_ptr< HashMap > pMap(new (std::nothrow) HashMap());
SysTryReturn(NID_APP, pMap, null, E_OUT_OF_MEMORY, "ArrayList creation failure.");
pMap->Construct();
- res = pkgmgrinfo_appinfo_foreach_metadata(__pAppInfoHandle, MetadataHandler, pMap);
- if (res != PMINFO_R_OK)
- {
- SysLog(NID_APP, "pkgmgrinfo_appinfo_foreach_metadata() is failed. result = [%d]", res);
- r = E_SYSTEM;
+ res = pkgmgrinfo_appinfo_foreach_metadata(__pAppInfoHandle, MetadataHandler, pMap.get());
+ SysTryReturn(NID_APP, res == PMINFO_R_OK, null, E_SYSTEM, "pkgmgrinfo_appinfo_foreach_metadata() failed. [%d]", res);
- pMap->RemoveAll(true);
- pMap = null;
+ if (pMap->GetCount() <= 0)
+ {
+ return null;
}
- SetLastResult(r);
+ return pMap.release();
}
else
{
SysLog(NID_APP, "GetAppMetadataListN() is not available.");
+ return null;
}
-
- return pMap;
}
ArrayList*
_PackageAppInfoImpl::GetAppCategoryListN(void) const
{
- ArrayList* pList = null;
-
if (__fromDatabase)
{
SysTryReturn(NID_APP, __pAppInfoHandle, null, E_SYSTEM, "[E_SYSTEM] __pAppInfoHandle is null.");
- result r = E_SUCCESS;
int res = PMINFO_R_OK;
- pList = new (std::nothrow) ArrayList();
+ std::unique_ptr< ArrayList > pList(new (std::nothrow) ArrayList());
SysTryReturn(NID_APP, pList, null, E_OUT_OF_MEMORY, "ArrayList creation failure.");
pList->Construct();
- res = pkgmgrinfo_appinfo_foreach_category(__pAppInfoHandle, CategoryHandler, pList);
- if (res != PMINFO_R_OK)
- {
- SysLog(NID_APP, "pkgmgrinfo_appinfo_foreach_category() is failed. result = [%d]", res);
- r = E_SYSTEM;
+ res = pkgmgrinfo_appinfo_foreach_category(__pAppInfoHandle, CategoryHandler, pList.get());
+ SysTryReturn(NID_APP, res == PMINFO_R_OK, null, E_SYSTEM, "pkgmgrinfo_appinfo_foreach_category() failed. [%d]", res);
- pList->RemoveAll(true);
- pList = null;
+ if (pList->GetCount() <= 0)
+ {
+ return null;
}
- SetLastResult(r);
-
+ return pList.release();
}
else
{
SysLog(NID_APP, "GetAppCategoryListN() is not available.");
+ return null;
}
-
- return pList;
}
bool
return r;
}
+String
+_PackageAppInfoImpl::GetAppFeature(const String& key) const
+{
+ SysTryReturn(NID_APP, __appId.IsEmpty() == false, L"", E_SYSTEM, "__appId is empty.");
+
+ String value;
+ Database db;
+ String query;
+
+ query.Format(1024, L"SELECT AppFeature.VALUE FROM AppInfo, AppFeature WHERE AppFeature.ID = AppInfo.UNIQUE_ID and AppFeature.NAME = '%ls' and AppInfo.PACKAGE_NAME = '%ls'",
+ key.GetPointer(), __appId.GetPointer());
+
+ SysLog(NID_APP, "query = [%ls]", query.GetPointer());
+
+ result r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
+ SysTryReturn(NID_APP, r == E_SUCCESS, L"", E_SYSTEM, "db.Construct() failed. [%s]", GetErrorMessage(r));
+
+ std::unique_ptr< DbStatement > pStmt(_PackageManagerImpl::CreateStatementN(db, query));
+ SysTryReturn(NID_APP, pStmt, L"", E_SYSTEM, "CreateStatementN(%ls) failed. [%s]", query.GetPointer(), GetErrorMessage(GetLastResult()));
+
+ std::unique_ptr< DbEnumerator > pEnum(_PackageManagerImpl::ExecuteStatementN(db, pStmt.get()));
+ SysTryReturn(NID_APP, pEnum, L"", E_SYSTEM, "ExecuteStatementN() failed. [%s]", GetErrorMessage(GetLastResult()));
+
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ pEnum->GetStringAt(0, value);
+ }
+
+ SysLog(NID_APP, "value = [%ls]", value.GetPointer());
+
+ return value;
+}
+
_PackageAppInfoImpl*
_PackageAppInfoImpl::GetInstance(PackageAppInfo* pPackageAppInfo)
{
result
_PackageAppInfoImpl::Construct(const AppId& appId)
{
+ SysTryReturnResult(NID_APP, appId.IsEmpty() == false, E_INVALID_ARG, "appId is empty.");
+
int res = PMINFO_R_OK;
char* pExePath = null;
char* pDisplayName = null;
SysTryReturnResult(NID_APP, pAppId, E_OUT_OF_MEMORY, "pAppId is null");
res = pkgmgrinfo_appinfo_get_appinfo(pAppId.get(), &__pAppInfoHandle);
- SysTryReturnResult(NID_APP, res == 0, E_SYSTEM, "pkgmgrinfo_appinfo_get_appinfo failed, res = [%d]", res);
+ SysTryReturnResult(NID_APP, res == 0, E_SYSTEM, "pkgmgrinfo_appinfo_get_appinfo failed, res = [%d], app = [%s]", res, pAppId.get());
__fromDatabase = true;
SysLog(NID_APP, "Key = [%s], Value = [%s]", pKey, pValue);
MultiHashMap* pMultiMap = (MultiHashMap*) pUserData;
- pMultiMap->Add(*(new (std::nothrow) String(pKey)), *(new (std::nothrow) String(pValue)));
+ result r = pMultiMap->Add(*(new (std::nothrow) String(pKey)), *(new (std::nothrow) String(pValue)));
+ SysTryReturn(NID_APP, r == E_SUCCESS, -1, E_SYSTEM, "pMultiMap->Add() failed. [%s]", GetErrorMessage(GetLastResult()));
return 0;
}
{
pkgmgrinfo_appinfo_destroy_appinfo(__pAppInfoHandle);
}
+
+ if (File::IsFileExist(__appTempIconPath) == true)
+ {
+ File::Remove(__appTempIconPath);
+ }
}
const String&