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::Base;
40 using namespace Tizen::Base::Collection;
41 using namespace Tizen::Graphics;
43 namespace Tizen { namespace Shell
46 AppWidgetManager* AppWidgetManager::__pTheInstance = null;
48 AppWidgetManager::AppWidgetManager()
49 :__pAppWidgetManagerImpl(null)
54 AppWidgetManager::~AppWidgetManager()
59 AppWidgetManager::InitSingleton(void)
61 std::unique_ptr<AppWidgetManager> pInst(new (std::nothrow) AppWidgetManager());
62 SysTryReturnVoidResult(NID_SHELL, pInst, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
64 result r = pInst->Construct();
65 SysTryReturnVoidResult(NID_SHELL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
67 __pTheInstance = pInst.release();
68 std::atexit(DestroySingleton);
72 AppWidgetManager::DestroySingleton(void)
74 delete __pTheInstance;
78 AppWidgetManager::GetInstance(void)
81 SysTryReturn(NID_SHELL, _AppWidgetManagerImpl::HasFeature(), null, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] This operation is not supported.");
83 static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
84 if (__pTheInstance == null)
86 pthread_once(&onceBlock, InitSingleton);
87 result r = GetLastResult();
90 onceBlock = PTHREAD_ONCE_INIT;
93 return __pTheInstance;
97 AppWidgetManager::Construct(void)
99 SysAssert(__pAppWidgetManagerImpl == null);
101 SysLog(NID_SHELL, "Enter.");
102 __pAppWidgetManagerImpl = _AppWidgetManagerImpl::GetInstance();
103 SysAssertf(__pAppWidgetManagerImpl, "Failed to construct _AppWidgetManagerImpl!!");
105 SysLog(NID_SHELL, "Exit.");
114 AppWidgetManager::GetAppWidgetProviderInfoListN(void) const
117 IList* pIList = __pAppWidgetManagerImpl->GetAppWidgetProviderInfoListN();
118 SysTryReturn(NID_SHELL, pIList, null, E_SYSTEM, "[E_SYSTEM] Failed to get the provider information.");
124 // E_APP_NOT_INSTALLED
128 AppWidgetProviderInfo*
129 AppWidgetManager::GetAppWidgetProviderInfoN(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName) const
132 return __pAppWidgetManagerImpl->GetAppWidgetProviderInfoN(appId, providerName);
136 // E_APP_NOT_INSTALLED
139 AppWidgetProviderInfo*
140 AppWidgetManager::GetDefaultAppWidgetProviderInfoN(const Tizen::App::PackageId& packageId) const
143 return __pAppWidgetManagerImpl->GetDefaultAppWidgetProviderInfoN(packageId);
150 AppWidgetManager::SetAppWidgetRequestListener(IAppWidgetRequestListener* pListener)
152 return __pAppWidgetManagerImpl->SetAppWidgetRequestListener(pListener);