Change APIs to get the application feature
authorkyeongwoo.lee <kyeongwoo.lee@samsung.com>
Tue, 24 Sep 2013 03:25:26 +0000 (12:25 +0900)
committerkyeongwoo.lee <kyeongwoo.lee@samsung.com>
Tue, 24 Sep 2013 03:25:26 +0000 (12:25 +0900)
Change-Id: Iafd911e7de1a5135b472f965a0a519087c869dfd

src/FShell_AppWidgetProviderManagerImpl.cpp

index 3725747..fa4202d 100644 (file)
@@ -56,7 +56,6 @@
 #include "FShell_AppWidgetProviderManagerImpl.h"
 #include "FShell_AppWidgetProviderInfoImpl.h"
 
-
 namespace Tizen { namespace Shell
 {
 using namespace std;
@@ -636,49 +635,38 @@ _AppWidgetProviderManagerImpl::ValidateAppAttribute(void)
 //     const int LIFE_DURATION_MIN = 30000;
 
        static result res = E_UNKNOWN;
-       if(res != E_UNKNOWN )
+       if (res != E_UNKNOWN)
        {
                return res;
        }
 
        res = E_SYSTEM;
-       unique_ptr<HashMapT<String, _AppFeatureInfoImpl*> > pInfo(_PackageManagerImpl::GetInstance()->GetPackageAppFeatureMapN(_AppInfo::GetPackageId(), _AppInfo::GetAppExecutableName()) );
-       SysTryReturnResult(NID_SHELL, pInfo.get(), E_SYSTEM, "Failed to invoke _PackageManagerImpl::GetPackageAppFeatureMapN()");
+       const AppId& appId = _AppInfo::GetApplicationId();
+       unique_ptr<PackageAppInfo> pInfo(_PackageManagerImpl::GetInstance()->GetPackageAppInfoN(appId));
+       SysTryReturnResult(NID_SHELL, pInfo.get(), E_SYSTEM, "Failed to invoke _PackageManagerImpl::GetPackageAppInfoN()");
 
-       _AppFeatureInfoImpl* pFeature = null;
+       const _PackageAppInfoImpl* pInfoImpl = _PackageAppInfoImpl::GetInstance(pInfo.get());
+       SysTryReturnResult(NID_SHELL, pInfoImpl, E_SYSTEM, "Failed to get the instance.");
 
        res = E_INVALID_OPERATION;
        // UseUi
-       result r = pInfo->GetValue(USE_UI_KEY, pFeature);
-       SysTryReturnResult(NID_SHELL, !IsFailed(r), E_INVALID_OPERATION, "Can't find '%ls' attribute for the ServiceApp in package information.", USE_UI_KEY );
-
-       const String& useUi = pFeature->GetValue();
+       const String& useUi = pInfoImpl->GetAppFeature(USE_UI_KEY);
        SysTryReturnResult(NID_SHELL, useUi == USE_UI_VAL_TRUE, E_INVALID_OPERATION, "'%ls' attribute value should be '%ls' to be an application that providing AppWidget, but value is %ls", USE_UI_KEY, USE_UI_VAL_TRUE, useUi.GetPointer() );
 
        // LifeDuration
-       r = pInfo->GetValue(LIFE_DURATION_KEY, pFeature);
-       SysTryReturnResult(NID_SHELL, !IsFailed(r), E_INVALID_OPERATION, "Can't find '%ls' attribute for the ServiceApp in package information.", LIFE_DURATION_KEY );
-
-       const String& lifeDurationValue = pFeature->GetValue();
+       const String& lifeDurationValue = pInfoImpl->GetAppFeature(LIFE_DURATION_KEY);
        int lifeDuration = 0;
-       r = Integer::Parse(lifeDurationValue, lifeDuration);
-       SysTryReturnResult(NID_SHELL, !IsFailed(r), E_INVALID_OPERATION, "Failed to parse '%ls' attribute for the ServiceApp in package information.", LIFE_DURATION_KEY );
+       result r = Integer::Parse(lifeDurationValue, lifeDuration);
+       SysTryReturnResult(NID_SHELL, !IsFailed(r), E_INVALID_OPERATION, "Failed to parse '%ls' attribute for the ServiceApp in package information.", LIFE_DURATION_KEY);
        //SysTryReturnResult(NID_SHELL, lifeDuration <= LIFE_DURATION_MIN, E_INVALID_OPERATION, "%ls attribute value should be less than '%d' to be an application that providing AppWidget, but value is %d", LIFE_DURATION_KEY, LIFE_DURATION_MIN, lifeDuration );
 
        // AutoRestart
-       r = pInfo->GetValue(AUTO_RESTART_KEY, pFeature);
-       if (!IsFailed(r))
-       {
-               String autoRestart = pFeature->GetValue();
-               autoRestart.ToLowerCase();
-               SysTryReturnResult(NID_SHELL, autoRestart != "true", E_INVALID_OPERATION, "It's not allowed that declaring '%ls' attribute for AppWidget.", AUTO_RESTART_KEY);
-       }
-
-       _DeleteCollectionMapValue<String, _AppFeatureInfoImpl>(*pInfo);
+       String autoRestart = pInfoImpl->GetAppFeature(AUTO_RESTART_KEY);
+       autoRestart.ToLowerCase();
+       SysTryReturnResult(NID_SHELL, autoRestart != "true", E_INVALID_OPERATION, "It's not allowed that declaring '%ls' attribute for AppWidget.", AUTO_RESTART_KEY);
 
        res = E_SUCCESS;
        return res;
 }
 
-
 }} // Tizen::Shell