GetAppFeature() is added.
authorDuyoung Jang <duyoung.jang@samsung.com>
Wed, 27 Mar 2013 02:20:37 +0000 (11:20 +0900)
committerDuyoung Jang <duyoung.jang@samsung.com>
Wed, 27 Mar 2013 02:20:37 +0000 (11:20 +0900)
Change-Id: I896211ff16771094e0a038ac396789d98ab8ab27
Signed-off-by: Duyoung Jang <duyoung.jang@samsung.com>
src/app/inc/FAppPkg_PackageAppInfoImpl.h
src/app/package/FAppPkg_PackageAppInfoImpl.cpp
src/app/package/FAppPkg_PackageInfoImpl.cpp

index 2ef78e2..ee150b5 100755 (executable)
@@ -82,6 +82,8 @@ public:
 
        result AddCategory(Tizen::Base::String* pCategory);
 
+       Tizen::Base::String GetAppFeature(const Tizen::Base::String& key) const;
+
        static _PackageAppInfoImpl* GetInstance(PackageAppInfo* pPackageAppInfo);
 
        result Construct(const AppId& appId);
index d372654..9aa0d9a 100755 (executable)
@@ -240,6 +240,39 @@ _PackageAppInfoImpl::AddCategory(String* pCategory)
        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)
 {
index 4843be0..47478e4 100755 (executable)
@@ -977,16 +977,11 @@ _PackageInfoImpl::Construct(const PackageId& packageId)
        char* pUrl = null;
        char* pMainAppId = null;
        char* pStoreClientId = null;
+       char* pRootPath = null;
        int installedTime = 0;
        pkgmgrinfo_installed_storage storage = PMINFO_INTERNAL_STORAGE;
        bool removable = true;
 
-       // temp
-       Database db;
-       DbStatement* pStmt = null;
-       DbEnumerator* pEnum = null;
-       String query;
-
        std::unique_ptr<char[]> pPackageId(_StringConverter::CopyToCharArrayN(packageId));
        SysTryReturnResult(NID_APP, pPackageId, E_OUT_OF_MEMORY, "pPackageId is null");
 
@@ -1166,41 +1161,18 @@ _PackageInfoImpl::Construct(const PackageId& packageId)
                SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_storeclientid() is failed. result = [%d]", result);
        }
 
-       // temp
-       query.Format(1024, L"SELECT PkgInfo.*, AppInfo.APP_MAINMENU_ICON FROM AppInfo, PkgInfo WHERE AppInfo.ID = PkgInfo.UNIQUE_ID and AppInfo.APP_DEFAULT = 'True' and PkgInfo.PKG_ID = '%ls'", 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 = _PackageManagerImpl::CreateStatementN(db, query);
-       SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
-
-       pEnum = _PackageManagerImpl::ExecuteStatementN(db, pStmt);
-       if (pEnum != null)
+       result = pkgmgrinfo_pkginfo_get_root_path(__packageInfoHandle, &pRootPath);
+       if (result == PMINFO_R_OK)
        {
-               if (pEnum->MoveNext() == E_SUCCESS)
-               {
-                       String rootPath;
-                       int storageType = 0;
-
-                       if (pEnum->GetColumnType(16) != DB_COLUMNTYPE_NULL)
-                       {
-                               pEnum->GetStringAt(16, rootPath);
-                       }
-                       if (pEnum->GetColumnType(17) != DB_COLUMNTYPE_NULL)
-                       {
-                               pEnum->GetIntAt(17, storageType);
-                       }
-
-                       SetAppRootPath(rootPath);
-                       SetAppStorageType(storageType);
-               }
-
-               delete pEnum;
+               SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_root_path(): rootPath = [%s]", pRootPath);
+               String rootPath(pRootPath);
+               __appRootPath = rootPath;
+       }
+       else
+       {
+               SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_root_path() is failed. result = [%d]", result);
        }
 
-CATCH:
-       delete pStmt;
        return r;
 }