2 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file FShellAppWidgetManager.cpp
19 * @brief This is the implementation for the AppWidgetManager class.
23 #include <unique_ptr.h>
25 #include <livebox-service/livebox-service.h>
26 #include <FBaseSysLog.h>
28 #include <FGraphics.h>
30 #include <FApp_Types.h>
31 #include <FApp_AppInfo.h>
32 #include <FShellAppWidgetManager.h>
33 #include <FShellAppWidgetProviderInfo.h>
34 #include <FShellIAppWidgetRequestListener.h>
35 #include "FShell_AppWidgetManagerImpl.h"
38 using namespace Tizen::App;
39 using namespace Tizen::App::Package;
40 using namespace Tizen::Base;
41 using namespace Tizen::Base::Collection;
42 using namespace Tizen::Graphics;
44 namespace Tizen { namespace Shell
47 AppWidgetManager* AppWidgetManager::__pTheInstance = null;
49 AppWidgetManager::AppWidgetManager()
50 :__pAppWidgetManagerImpl(null)
55 AppWidgetManager::~AppWidgetManager()
60 AppWidgetManager::InitSingleton(void)
62 std::unique_ptr<AppWidgetManager> pInst(new (std::nothrow) AppWidgetManager());
63 SysTryReturnVoidResult(NID_SHELL, pInst, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
65 result r = pInst->Construct();
66 SysTryReturnVoidResult(NID_SHELL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
68 __pTheInstance = pInst.release();
69 std::atexit(DestroySingleton);
73 AppWidgetManager::DestroySingleton(void)
75 delete __pTheInstance;
79 AppWidgetManager::GetInstance(void)
82 SysTryReturn(NID_SHELL, _AppWidgetManagerImpl::HasFeature(), null, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] This operation is not supported.");
84 static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
85 if (__pTheInstance == null)
87 pthread_once(&onceBlock, InitSingleton);
88 result r = GetLastResult();
91 onceBlock = PTHREAD_ONCE_INIT;
94 return __pTheInstance;
98 AppWidgetManager::Construct(void)
100 SysAssert(__pAppWidgetManagerImpl == null);
102 SysLog(NID_SHELL, "Enter.");
103 __pAppWidgetManagerImpl = _AppWidgetManagerImpl::GetInstance();
104 SysAssertf(__pAppWidgetManagerImpl, "Failed to construct _AppWidgetManagerImpl!!");
106 SysLog(NID_SHELL, "Exit.");
115 AppWidgetManager::GetAppWidgetProviderInfoListN(void) const
118 IList* pIList = __pAppWidgetManagerImpl->GetAppWidgetProviderInfoListN();
119 SysTryReturn(NID_SHELL, pIList, null, E_SYSTEM, "[E_SYSTEM] Failed to get the provider information.");
125 // E_APP_NOT_INSTALLED
129 AppWidgetProviderInfo*
130 AppWidgetManager::GetAppWidgetProviderInfoN(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName) const
133 return __pAppWidgetManagerImpl->GetAppWidgetProviderInfoN(appId, providerName);
137 // E_APP_NOT_INSTALLED
140 AppWidgetProviderInfo*
141 AppWidgetManager::GetDefaultAppWidgetProviderInfoN(const Tizen::App::PackageId& packageId) const
144 return __pAppWidgetManagerImpl->GetDefaultAppWidgetProviderInfoN(packageId);
151 AppWidgetManager::SetAppWidgetRequestListener(IAppWidgetRequestListener* pListener)
153 return __pAppWidgetManagerImpl->SetAppWidgetRequestListener(pListener);