Implementation for ACR [add appwidget feature...]
authorkyeongwoo.lee <kyeongwoo.lee@samsung.com>
Wed, 15 May 2013 11:18:00 +0000 (20:18 +0900)
committerGerrit Code Review <gerrit2@kim11>
Wed, 15 May 2013 11:23:28 +0000 (20:23 +0900)
Change-Id: Ib8b0911ad6cdb9cdcd654d839d04c9a6ef08bed2

src/FShellAppWidgetFrame.cpp
src/FShellAppWidgetManager.cpp
src/FShellAppWidgetPopup.cpp
src/FShellAppWidgetProviderManager.cpp
src/FShellAppWidgetView.cpp
src/FShell_AppWidgetManagerImpl.cpp
src/inc/FShell_AppWidgetManagerImpl.h

index 0883d76..601bb6a 100644 (file)
 #include <unique_ptr.h>
 #include <FBaseSysLog.h>
 #include <FShellAppWidgetFrame.h>
-#include <FSysSystemInfo.h>
-#include <FShellTypes.h>
 #include "FShell_AppWidgetFrameImpl.h"
+#include "FShell_AppWidgetManagerImpl.h"
 
 using namespace std;
 using namespace Tizen::Base;
 using namespace Tizen::Graphics;
 using namespace Tizen::Ui;
-using namespace Tizen::System;
 
 namespace Tizen { namespace Shell
 {
@@ -46,13 +44,11 @@ AppWidgetFrame::~AppWidgetFrame(void)
 result
 AppWidgetFrame::Construct(const FloatDimension& size)
 {
-       bool isSupported = false;
-       result r = SystemInfo::GetValue(FEATURE_STRING, isSupported);
-       SysTryReturnResult(NID_SHELL, !IsFailed(r) && isSupported, E_UNSUPPORTED_OPERATION, "This operation is not supported.");
+       SysTryReturnResult(NID_SHELL, _AppWidgetManagerImpl::HasFeature(), E_UNSUPPORTED_OPERATION, "This operation is not supported.");
 
        SysAssertf(_pControlImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
        unique_ptr<_AppWidgetFrameImpl> pImpl(_AppWidgetFrameImpl::CreateAppWidgetFrameImplN(*this, null, null));
-       r = GetLastResult();
+       result r = GetLastResult();
        SysTryReturnResult(NID_SHELL, pImpl, r, "Propagating.");
 
        r = pImpl->Initialize(size);
@@ -66,14 +62,12 @@ AppWidgetFrame::Construct(const FloatDimension& size)
 result
 AppWidgetFrame::Construct(const Layout& layout, const FloatDimension& size)
 {
-       bool isSupported = false;
-       result r = SystemInfo::GetValue(FEATURE_STRING, isSupported);
-       SysTryReturnResult(NID_SHELL, !IsFailed(r) && isSupported, E_UNSUPPORTED_OPERATION, "This operation is not supported.");
+       SysTryReturnResult(NID_SHELL, _AppWidgetManagerImpl::HasFeature(), E_UNSUPPORTED_OPERATION, "This operation is not supported.");
 
        SysAssertf(_pControlImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
 
        unique_ptr<_AppWidgetFrameImpl> pImpl(_AppWidgetFrameImpl::CreateAppWidgetFrameImplN(*this, &layout, &layout));
-       r = GetLastResult();
+       result r = GetLastResult();
        SysTryReturnResult(NID_SHELL, pImpl, r, "Propagating.");
 
        r = pImpl->Initialize(size);
index 319e681..3b289fe 100644 (file)
@@ -28,8 +28,6 @@
 #include <FGraphics.h>
 #include <FApp.h>
 #include <FAppPkgPackageInfo.h>
-#include <FSysSystemInfo.h>
-#include <FShellTypes.h>
 #include <FApp_Types.h>
 #include <FApp_AppInfo.h>
 #include <FShellAppWidgetManager.h>
@@ -43,7 +41,6 @@ using namespace Tizen::App::Package;
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
 using namespace Tizen::Graphics;
-using namespace Tizen::System;
 
 namespace Tizen { namespace Shell
 {
@@ -84,15 +81,13 @@ AppWidgetManager::GetInstance(void)
 {
        ClearLastResult();
 
-       bool isSupported = false;
-       result r = SystemInfo::GetValue(FEATURE_STRING, isSupported);
-       SysTryReturn(NID_SHELL, !IsFailed(r) && isSupported, null, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] This operation is not supported.");
+       SysTryReturn(NID_SHELL, _AppWidgetManagerImpl::HasFeature(), null, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] This operation is not supported.");
 
        static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
        if (__pTheInstance == null)
        {
                pthread_once(&onceBlock, InitSingleton);
-               r = GetLastResult();
+               result r = GetLastResult();
                if (IsFailed(r))
                {
                        onceBlock = PTHREAD_ONCE_INIT;
index c4dbab2..8ae132e 100644 (file)
 #include <unique_ptr.h>
 #include <FBaseSysLog.h>
 #include <FShellAppWidgetPopup.h>
-#include <FSysSystemInfo.h>
-#include <FShellTypes.h>
 #include "FShell_AppWidgetPopupImpl.h"
+#include "FShell_AppWidgetManagerImpl.h"
 
 using namespace std;
 using namespace Tizen::Base;
 using namespace Tizen::Graphics;
 using namespace Tizen::Ui;
-using namespace Tizen::System;
 
 namespace Tizen { namespace Shell
 {
@@ -46,14 +44,12 @@ AppWidgetPopup::~AppWidgetPopup(void)
 result
 AppWidgetPopup::Construct(const FloatDimension& size)
 {
-       bool isSupported = false;
-       result r = SystemInfo::GetValue(FEATURE_STRING, isSupported);
-       SysTryReturnResult(NID_SHELL, !IsFailed(r) && isSupported, E_UNSUPPORTED_OPERATION, "This operation is not supported.");
+       SysTryReturnResult(NID_SHELL, _AppWidgetManagerImpl::HasFeature(), E_UNSUPPORTED_OPERATION, "This operation is not supported.");
 
        SysAssertf(_pControlImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
 
        unique_ptr<_AppWidgetPopupImpl> pImpl(_AppWidgetPopupImpl::CreateAppWidgetPopupImplN(*this, null, null));
-       r = GetLastResult();
+       result r = GetLastResult();
        SysTryReturnResult(NID_SHELL, pImpl, r, "Propagating.");
 
        r = pImpl->Initialize(size);
@@ -67,14 +63,12 @@ AppWidgetPopup::Construct(const FloatDimension& size)
 result
 AppWidgetPopup::Construct(const Layout& layout, const FloatDimension& size)
 {
-       bool isSupported = false;
-       result r = SystemInfo::GetValue(FEATURE_STRING, isSupported);
-       SysTryReturnResult(NID_SHELL, !IsFailed(r) && isSupported, E_UNSUPPORTED_OPERATION, "This operation is not supported.");
+       SysTryReturnResult(NID_SHELL, _AppWidgetManagerImpl::HasFeature(), E_UNSUPPORTED_OPERATION, "This operation is not supported.");
 
        SysAssertf(_pControlImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
 
        unique_ptr<_AppWidgetPopupImpl> pImpl(_AppWidgetPopupImpl::CreateAppWidgetPopupImplN(*this, &layout, &layout));
-       r = GetLastResult();
+       result r = GetLastResult();
        SysTryReturnResult(NID_SHELL, pImpl, r, "Propagating.");
 
        r = pImpl->Initialize(size);
index 449ba71..45faade 100644 (file)
 #include <FShellAppWidgetProviderInfo.h>
 #include <FShellIAppWidgetProviderFactory.h>
 #include <FShellIAppWidgetPopupProviderFactory.h>
-#include <FSysSystemInfo.h>
 #include <FApp_Types.h>
 #include <FApp_AppInfo.h>
 #include <FAppPkg_PackageManagerImpl.h>
 #include <FBase_StringConverter.h>
 #include "FShell_AppWidgetProviderManagerImpl.h"
+#include "FShell_AppWidgetManagerImpl.h"
 
 using namespace std;
 using namespace Tizen::App;
@@ -44,13 +44,10 @@ using namespace Tizen::App::Package;
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
 using namespace Tizen::Graphics;
-using namespace Tizen::System;
 
 namespace Tizen { namespace Shell
 {
 
-extern const wchar_t FEATURE_STRING[] = L"http://tizen.org/feature/shell.appwidget";
-
 AppWidgetProviderManager* AppWidgetProviderManager::__pTheInstance = null;
 
 AppWidgetProviderManager::AppWidgetProviderManager()
@@ -88,15 +85,13 @@ AppWidgetProviderManager::GetInstance()
 {
        ClearLastResult();
 
-       bool isSupported = false;
-       result r = SystemInfo::GetValue(FEATURE_STRING, isSupported);
-       SysTryReturn(NID_SHELL, !IsFailed(r) && isSupported, null, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] This operation is not supported.");
+       SysTryReturn(NID_SHELL, _AppWidgetManagerImpl::HasFeature(), null, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] This operation is not supported.");
 
     static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
        if (__pTheInstance == null)
        {
                pthread_once(&onceBlock, InitSingleton);
-               r = GetLastResult();
+               result r = GetLastResult();
                if (IsFailed(r))
                {
                        onceBlock = PTHREAD_ONCE_INIT;
index d9241ce..417f182 100644 (file)
 #include <FBaseString.h>
 #include <FGrpPoint.h>
 #include <FShellAppWidgetView.h>
-#include <FShellTypes.h>
-#include <FSysSystemInfo.h>
 #include <FApp_Aul.h>
 #include "FShell_AppWidgetViewImpl.h"
+#include "FShell_AppWidgetManagerImpl.h"
 
 using namespace std;
 using namespace Tizen::App;
 using namespace Tizen::Base;
 using namespace Tizen::Graphics;
-using namespace Tizen::System;
 
 namespace Tizen { namespace Shell
 {
@@ -49,9 +47,7 @@ AppWidgetView::~AppWidgetView(void)
 result
 AppWidgetView::Construct(const AppId& appId, const String& providerName, const FloatRectangle& rect)
 {
-       bool isSupported = false;
-       result r = SystemInfo::GetValue(FEATURE_STRING, isSupported);
-       SysTryReturnResult(NID_SHELL, !IsFailed(r) && isSupported, E_UNSUPPORTED_OPERATION, "This operation is not supported.");
+       SysTryReturnResult(NID_SHELL, _AppWidgetManagerImpl::HasFeature(), E_UNSUPPORTED_OPERATION, "This operation is not supported.");
 
        return Construct(appId, providerName, rect, L"");
 }
@@ -59,16 +55,13 @@ AppWidgetView::Construct(const AppId& appId, const String& providerName, const F
 result
 AppWidgetView::Construct(const AppId& appId, const String& providerName, const FloatRectangle& rect, const String& userInfo)
 {
-       bool isSupported = false;
-       result r = SystemInfo::GetValue(FEATURE_STRING, isSupported);
-       SysTryReturnResult(NID_SHELL, !IsFailed(r) && isSupported, E_UNSUPPORTED_OPERATION, "This operation is not supported.");
-
+       SysTryReturnResult(NID_SHELL, _AppWidgetManagerImpl::HasFeature(), E_UNSUPPORTED_OPERATION, "This operation is not supported.");
        SysTryReturnResult(NID_SHELL, _Aul::IsInstalled(appId) == true, E_APP_NOT_INSTALLED, "The application is not installed.");
 
        SysAssertf(_pControlImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
 
        unique_ptr<_AppWidgetViewImpl> pImpl(_AppWidgetViewImpl::CreateAppWidgetViewImplN(*this));
-       r = GetLastResult();
+       result r = GetLastResult();
        SysTryReturnResult(NID_SHELL, pImpl, r, "Propagating.");
 
        r = pImpl->Initialize(appId, providerName, rect, userInfo);
index 7cab8de..a00fb5c 100644 (file)
@@ -28,6 +28,8 @@
 #include <FBase.h>
 #include <FApp.h>
 #include <FGrpDimension.h>
+#include <FSysSystemInfo.h>
+#include <FShellTypes.h>
 #include <FApp_AppImpl.h>
 #include <FBase_StringConverter.h>
 #include <FAppPkg_PackageManagerImpl.h>
@@ -57,6 +59,9 @@ using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
 using namespace Tizen::App;
 using namespace Tizen::Graphics;
+using namespace Tizen::System;
+
+extern const wchar_t FEATURE_STRING[] = L"http://tizen.org/feature/shell.appwidget";
 
 _AppWidgetManagerImpl::_AppWidgetManagerImpl()
        :__pAppWidgetRequestEventListener(null)
@@ -252,4 +257,23 @@ _AppWidgetManagerImpl::MakeProviderName(const Tizen::App::AppId& appId, const Ti
        return providerId;
 }
 
+bool
+_AppWidgetManagerImpl::HasFeature(void)
+{
+       static bool isChecked = false;
+       static bool isSupported = false;
+
+       if (!isChecked)
+       {
+               result r = SystemInfo::GetValue(FEATURE_STRING, isSupported);
+               SysTryReturn(NID_SHELL, !IsFailed(r), false, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] This operation is not supported.");
+
+               isChecked = true;
+               SysLog(NID_SHELL, "HasFeature is called[%d]", isChecked);
+       }
+
+       return isSupported;
+}
+
+
 }} // Tizen::Shell
index 1b44994..dc6551a 100644 (file)
@@ -57,6 +57,8 @@ public:
        static result ExtractAppIdAndProviderName(const Tizen::Base::String& providerId, Tizen::App::AppId& appId, Tizen::Base::String& providerName);
        static Tizen::Base::String MakeProviderName(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName);
 
+       static bool HasFeature(void);
+
 private:
        _AppWidgetManagerImpl();
        virtual ~_AppWidgetManagerImpl();