Implementation for ACR [add appwidget feature...]
authorkyeongwoo.lee <kyeongwoo.lee@samsung.com>
Wed, 15 May 2013 08:00:27 +0000 (17:00 +0900)
committerkyeongwoo.lee <kyeongwoo.lee@samsung.com>
Wed, 15 May 2013 08:00:27 +0000 (17:00 +0900)
Change-Id: I3e0092f71a5b2b811648b55b267191e31f3bf711

inc/FShellTypes.h [new file with mode: 0644]
src/FShellAppWidgetFrame.cpp
src/FShellAppWidgetManager.cpp
src/FShellAppWidgetPopup.cpp
src/FShellAppWidgetProviderManager.cpp
src/FShellAppWidgetView.cpp

diff --git a/inc/FShellTypes.h b/inc/FShellTypes.h
new file mode 100644 (file)
index 0000000..7d1ef4f
--- /dev/null
@@ -0,0 +1,33 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file                       FShellTypes.h
+ * @brief              This is the header file for the definitions of constants and enumerators in the %Shell namespace.
+ *
+ * This header file contains definitions for the constants and enumerators in the %Shell namespace.
+ */
+
+#ifndef _FSHELL_TYPES_H_
+#define _FSHELL_TYPES_H_
+
+namespace Tizen { namespace Shell
+{
+
+_OSP_EXPORT_ extern const wchar_t FEATURE_STRING[];
+
+}} // Tizen::Shell
+
+#endif  // _FSHELL_TYPES_H_
index a7afaf4..0883d76 100644 (file)
 #include <unique_ptr.h>
 #include <FBaseSysLog.h>
 #include <FShellAppWidgetFrame.h>
+#include <FSysSystemInfo.h>
+#include <FShellTypes.h>
 #include "FShell_AppWidgetFrameImpl.h"
 
 using namespace std;
 using namespace Tizen::Base;
 using namespace Tizen::Graphics;
 using namespace Tizen::Ui;
+using namespace Tizen::System;
 
 namespace Tizen { namespace Shell
 {
@@ -43,13 +46,17 @@ 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.");
+
        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));
-       result r = GetLastResult();
-       SysTryReturn(NID_SHELL, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       r = GetLastResult();
+       SysTryReturnResult(NID_SHELL, pImpl, r, "Propagating.");
 
        r = pImpl->Initialize(size);
-       SysTryReturn(NID_SHELL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryReturnResult(NID_SHELL, r == E_SUCCESS, r, "Propagating.");
 
        _pControlImpl = pImpl.release();
 
@@ -59,14 +66,18 @@ 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.");
+
        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));
-       result r = GetLastResult();
-       SysTryReturn(NID_SHELL, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       r = GetLastResult();
+       SysTryReturnResult(NID_SHELL, pImpl, r, "Propagating.");
 
        r = pImpl->Initialize(size);
-       SysTryReturn(NID_SHELL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryReturnResult(NID_SHELL, r == E_SUCCESS, r, "Propagating.");
 
        _pControlImpl = pImpl.release();
 
index 5d43f62..319e681 100644 (file)
 
 #include <cstdlib>
 #include <unique_ptr.h>
-
 #include <shortcut.h>
 #include <livebox-service/livebox-service.h>
-
 #include <FBaseSysLog.h>
 #include <FBaseCol.h>
 #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>
 #include <FShellAppWidgetProviderInfo.h>
 #include <FShellIAppWidgetRequestListener.h>
@@ -45,7 +43,7 @@ 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,12 +82,17 @@ AppWidgetManager::DestroySingleton(void)
 AppWidgetManager*
 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.");
+
        static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
        if (__pTheInstance == null)
        {
-               ClearLastResult();
                pthread_once(&onceBlock, InitSingleton);
-               result r = GetLastResult();
+               r = GetLastResult();
                if (IsFailed(r))
                {
                        onceBlock = PTHREAD_ONCE_INIT;
index abcc6d6..c4dbab2 100644 (file)
 #include <unique_ptr.h>
 #include <FBaseSysLog.h>
 #include <FShellAppWidgetPopup.h>
+#include <FSysSystemInfo.h>
+#include <FShellTypes.h>
 #include "FShell_AppWidgetPopupImpl.h"
 
 using namespace std;
 using namespace Tizen::Base;
 using namespace Tizen::Graphics;
 using namespace Tizen::Ui;
+using namespace Tizen::System;
 
 namespace Tizen { namespace Shell
 {
@@ -43,14 +46,18 @@ 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.");
+
        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));
-       result r = GetLastResult();
-       SysTryReturn(NID_SHELL, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       r = GetLastResult();
+       SysTryReturnResult(NID_SHELL, pImpl, r, "Propagating.");
 
        r = pImpl->Initialize(size);
-       SysTryReturn(NID_SHELL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryReturnResult(NID_SHELL, r == E_SUCCESS, r, "Propagating.");
 
        _pControlImpl = pImpl.release();
 
@@ -60,14 +67,18 @@ 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.");
+
        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));
-       result r = GetLastResult();
-       SysTryReturn(NID_SHELL, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       r = GetLastResult();
+       SysTryReturnResult(NID_SHELL, pImpl, r, "Propagating.");
 
        r = pImpl->Initialize(size);
-       SysTryReturn(NID_SHELL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryReturnResult(NID_SHELL, r == E_SUCCESS, r, "Propagating.");
 
        _pControlImpl = pImpl.release();
 
index 50736e7..449ba71 100644 (file)
  */
 
 #include <unique_ptr.h>
-
 #include <shortcut.h>
 #include <livebox-service/livebox-service.h>
-
 #include <FBaseSysLog.h>
 #include <FBaseCol.h>
 #include <FGraphics.h>
 #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"
 
 using namespace std;
@@ -47,11 +44,13 @@ 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()
@@ -87,12 +86,17 @@ AppWidgetProviderManager::DestroySingleton(void)
 AppWidgetProviderManager*
 AppWidgetProviderManager::GetInstance()
 {
-       static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+       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.");
+
+    static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
        if (__pTheInstance == null)
        {
-               ClearLastResult();
                pthread_once(&onceBlock, InitSingleton);
-               result r = GetLastResult();
+               r = GetLastResult();
                if (IsFailed(r))
                {
                        onceBlock = PTHREAD_ONCE_INIT;
index caf2970..d9241ce 100644 (file)
@@ -24,6 +24,8 @@
 #include <FBaseString.h>
 #include <FGrpPoint.h>
 #include <FShellAppWidgetView.h>
+#include <FShellTypes.h>
+#include <FSysSystemInfo.h>
 #include <FApp_Aul.h>
 #include "FShell_AppWidgetViewImpl.h"
 
@@ -31,6 +33,7 @@ using namespace std;
 using namespace Tizen::App;
 using namespace Tizen::Base;
 using namespace Tizen::Graphics;
+using namespace Tizen::System;
 
 namespace Tizen { namespace Shell
 {
@@ -46,22 +49,30 @@ 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.");
+
        return Construct(appId, providerName, rect, L"");
 }
 
 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, _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));
-       result r = GetLastResult();
-       SysTryReturn(NID_SHELL, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       r = GetLastResult();
+       SysTryReturnResult(NID_SHELL, pImpl, r, "Propagating.");
 
        r = pImpl->Initialize(appId, providerName, rect, userInfo);
-       SysTryReturn(NID_SHELL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryReturnResult(NID_SHELL, r == E_SUCCESS, r, "Propagating.");
 
        _pControlImpl = pImpl.release();