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 LockManager class.
23 #include <unique_ptr.h>
25 #include <FBaseSysLog.h>
26 #include <FShellLockManager.h>
27 #include <FShell_LockManagerImpl.h>
29 namespace Tizen { namespace Shell
32 LockManager* LockManager::__pTheInstance = null;
34 LockManager::LockManager()
35 :__pLockManagerImpl(null)
39 LockManager::~LockManager()
44 LockManager::InitSingleton(void)
46 SysLog(NID_SHELL, "Enter.");
48 std::unique_ptr<LockManager> pInst(new (std::nothrow) LockManager());
49 SysTryReturnVoidResult(NID_SHELL, pInst, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
51 result r = pInst->Construct();
52 SysTryReturnVoidResult(NID_SHELL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
54 __pTheInstance = pInst.release();
55 std::atexit(DestroySingleton);
57 SysLog(NID_SHELL, "Exit.");
61 LockManager::DestroySingleton(void)
63 delete __pTheInstance;
67 LockManager::GetInstance(void)
69 static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
70 if (__pTheInstance == null)
72 SysLog(NID_SHELL, "Enter.");
74 pthread_once(&onceBlock, InitSingleton);
75 result r = GetLastResult();
78 onceBlock = PTHREAD_ONCE_INIT;
80 SysLog(NID_SHELL, "Exit.");
82 return __pTheInstance;
86 LockManager::Construct(void)
88 SysAssert(__pLockManagerImpl == null);
90 __pLockManagerImpl = _LockManagerImpl::GetInstance();
91 SysTryReturnResult(NID_SHELL, __pLockManagerImpl, E_SYSTEM, "[%s] Failed to construct _LockManagerImpl!!.");
92 SysLog(NID_SHELL, "LockManager is constructed.");
97 LockManager::IsLocked(void) const
99 SysAssertf(__pLockManagerImpl != null, "[E_SYSTEM] Not yet constructed.");
101 return __pLockManagerImpl->IsLocked();
105 LockManager::IsSecureMode(void) const
107 SysAssertf(__pLockManagerImpl != null, "[E_SYSTEM] Not yet constructed.");
109 return __pLockManagerImpl->IsSecureMode();
113 LockManager::Unlock(void)
115 SysAssertf(__pLockManagerImpl != null, "[E_SYSTEM] Not yet constructed.");
117 return __pLockManagerImpl->Unlock();