From 54bf18ec8417d1a9808416fe3a0148fa4a9aaa1c Mon Sep 17 00:00:00 2001 From: "jungmin76.park" Date: Sun, 10 Mar 2013 22:36:14 +0900 Subject: [PATCH] add Tizen::Shell::LockManager Change-Id: I36552f9789f03bc6fcfc1870d36ed72987c94ab6 Signed-off-by: jungmin76.park --- inc/FShellLockManager.h | 150 ++++++++++++++++++++++++++++++++++++ packaging/osp-shell.spec | 1 + src/core/CMakeLists.txt | 5 ++ src/core/FShellLockManager.cpp | 118 ++++++++++++++++++++++++++++ src/core/FShell_LockManagerImpl.cpp | 110 ++++++++++++++++++++++++++ src/inc/FShell_LockManagerImpl.h | 141 +++++++++++++++++++++++++++++++++ 6 files changed, 525 insertions(+) create mode 100755 inc/FShellLockManager.h create mode 100644 src/core/FShellLockManager.cpp create mode 100644 src/core/FShell_LockManagerImpl.cpp create mode 100755 src/inc/FShell_LockManagerImpl.h diff --git a/inc/FShellLockManager.h b/inc/FShellLockManager.h new file mode 100755 index 0000000..0cee1ed --- /dev/null +++ b/inc/FShellLockManager.h @@ -0,0 +1,150 @@ +// +// Open Service Platform +// Copyright (c) 2013 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 FShellLockManager.h + * @brief This is the header file for the LockManager class. + * + * This header file contains the declarations of the %LockManager class. + */ + +#ifndef _FSHELL_LOCK_MANAGER_H_ +#define _FSHELL_LOCK_MANAGER_H_ + +#include +#include + +namespace Tizen { namespace Shell { + +/** + * @class LockManager + * @brief Manages state of lock screen. + * + * @since 2.1 + * + * @final This class is not intended for extension. + * + * The %LockManager class manages information of lock screen. + */ +class _OSP_EXPORT_ LockManager + : public Tizen::Base::Object +{ +public: + /** + * Gets the %LockManager instance. + * + * @since 2.1 + * + * @return A pointer to the %LockManager instance, @n + * else @c null if it fails + * + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @exception E_SYSTEM The method cannot proceed due to a severe system error. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + static LockManager* GetInstance(void); + + /** + * Checks whether the screen is locked. + * + * @since 2.1 + * + * @return @c true if the screen is locked, + * else @c false + */ + bool IsLocked(void) const; + + /** + * Checks whether password lock screen is enabled by Settings. + * + * @since 2.1 + * + * @return @c true if password lock screen is enabled, + * else @c false + */ + bool IsSecureMode(void) const; + + /** + * Unlocks current lock screen. + + * @privlevel partner + * @privilege http://tizen.org/privilege/lockmanager + * + * @since 2.1 + * + * @exception E_SUCCESS The method is successful. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + * @exception E_INVALID_OPERATION Can't unlock, because secure mode is enabled. + * @exception E_SYSTEM The method cannot proceed due to a severe system error. + * + * @remark This API call has no effect while secure mode is enabled. + */ + result Unlock(void); + +private: + // + // This default constructor is intentionally declared as private to implement the %Singleton semantic. + // + // @since 2.1 + // + LockManager(void); + + // + // This destructor is intentionally declared as private to implement the %Singleton semantic. + // + // @since 2.1 + // + virtual ~LockManager(void); + + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + // @since 2.1 + // + LockManager(const LockManager& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + // @since 2.1 + // + LockManager& operator =(const LockManager& rhs); + + // + // Constructs the instance of this class. + // + // @since 2.1 + // + // @return An error code + // @exception E_SUCCESS The method is successful. + // @exception E_SYSTEM The method cannot proceed due to a severe system error. + // + result Construct(void); + + static void InitSingleton(void); + static void DestroySingleton(void); + +private: + + static LockManager* __pTheInstance; + friend struct std::default_delete< LockManager >; + class _LockManagerImpl* __pLockManagerImpl; +}; + +}} // Tizen::Shell +#endif /* _FSHELL_LOCK_MANAGER_H_ */ diff --git a/packaging/osp-shell.spec b/packaging/osp-shell.spec index ec7bcda..5a20a55 100644 --- a/packaging/osp-shell.spec +++ b/packaging/osp-shell.spec @@ -35,6 +35,7 @@ BuildRequires: pkgconfig(shortcut) BuildRequires: pkgconfig(osp-image-core) BuildRequires: pkgconfig(osp-media) BuildRequires: pkgconfig(osp-net) +BuildRequires: pkgconfig(vconf) BuildRequires: osp-image-core-internal-devel BuildRequires: osp-appfw-internal-devel BuildRequires: osp-uifw-internal-devel diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index de45c04..db04c83 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -34,7 +34,10 @@ SET (${this_target}_SOURCE_FILES FShell_NotificationRequestImpl.cpp FShell_NotificationManagerProxy.cpp FShell_NotificationManagerIpcMessages.cpp +# FShellShortcutManager.cpp FShellHomeManager.cpp + FShellLockManager.cpp + FShell_LockManagerImpl.cpp ) ## Definitions @@ -53,6 +56,7 @@ ADD_LIBRARY (${this_target} SHARED ${${this_target}_SOURCE_FILES}) ## SET LINKER FLAGS SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined -Wl,--as-needed") +TARGET_LINK_LIBRARIES(${this_target} "-lpthread" ) TARGET_LINK_LIBRARIES(${this_target} "-lchromium" ) TARGET_LINK_LIBRARIES(${this_target} "-L/usr/lib/osp -losp-appfw" ) TARGET_LINK_LIBRARIES(${this_target} "-lcapi-appfw-application" ) @@ -63,6 +67,7 @@ TARGET_LINK_LIBRARIES(${this_target} "-levas" ) TARGET_LINK_LIBRARIES(${this_target} "-leina" ) TARGET_LINK_LIBRARIES(${this_target} "-lecore_evas" ) TARGET_LINK_LIBRARIES(${this_target} "-lshortcut" ) +TARGET_LINK_LIBRARIES(${this_target} "-lvconf" ) SET_TARGET_PROPERTIES(${this_target} PROPERTIES diff --git a/src/core/FShellLockManager.cpp b/src/core/FShellLockManager.cpp new file mode 100644 index 0000000..6d09418 --- /dev/null +++ b/src/core/FShellLockManager.cpp @@ -0,0 +1,118 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 FShellLiveboxManager.cpp + * @brief This is the implementation for the LockManager class. + */ + +#include +//#include +#include + +#include +#include +#include +#include + +namespace Tizen { namespace Shell { + +LockManager* LockManager::__pTheInstance = null; + +LockManager::LockManager() + :__pLockManagerImpl(null) +{ +} + +LockManager::~LockManager() +{ +} + +void +LockManager::InitSingleton(void) +{ + SysLog(NID_APP, "Enter."); + + std::unique_ptr pInst(new (std::nothrow) LockManager()); + SysTryReturnVoidResult(NID_APP, pInst, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + + result r = pInst->Construct(); + SysTryReturnVoidResult(NID_APP, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pTheInstance = pInst.release(); + std::atexit(DestroySingleton); + + SysLog(NID_APP, "Exit."); +} + +void +LockManager::DestroySingleton(void) +{ + delete __pTheInstance; +} + +LockManager* +LockManager::GetInstance(void) +{ + static pthread_once_t onceBlock = PTHREAD_ONCE_INIT; + if (__pTheInstance == null) + { + SysLog(NID_APP, "Enter."); + ClearLastResult(); + pthread_once(&onceBlock, InitSingleton); + result r = GetLastResult(); + if (IsFailed(r)) + { + onceBlock = PTHREAD_ONCE_INIT; + } + SysLog(NID_APP, "Exit."); + } + return __pTheInstance; +} + +result +LockManager::Construct(void) +{ + SysAssert(__pLockManagerImpl == null); + + __pLockManagerImpl = _LockManagerImpl::GetInstance(); + + SysAssertf(__pLockManagerImpl, "Failed to construct _LockManagerImpl!!"); + SysLog(NID_APP, "Successed."); + return E_SUCCESS; +} + +bool +LockManager::IsLocked(void) const +{ + return __pLockManagerImpl->IsLocked(); +} + +bool +LockManager::IsSecureMode(void) const +{ + return __pLockManagerImpl->IsSecureMode(); +} + +result +LockManager::Unlock(void) +{ + return __pLockManagerImpl->Unlock(); +} + + +}} // Tizen::Shell diff --git a/src/core/FShell_LockManagerImpl.cpp b/src/core/FShell_LockManagerImpl.cpp new file mode 100644 index 0000000..1edbf67 --- /dev/null +++ b/src/core/FShell_LockManagerImpl.cpp @@ -0,0 +1,110 @@ +/* + * FShell_LockManagerImpl.cpp + * + * Created on: Feb 15, 2013 + * Author: jungmin76park + */ + +#include +#include +#include +#include + +namespace Tizen { namespace Shell { + +#define VCONFKEY_IDLE_LOCK_STATE "memory/idle_lock/state" +#define VCONFKEY_SETAPPL_PREFIX "db/setting" +#define VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT VCONFKEY_SETAPPL_PREFIX"/screen_lock_type" + +enum +{ + VCONFKEY_IDLE_UNLOCK = 0x00, + VCONFKEY_IDLE_LOCK +}; + +enum +{ + SETTING_SCREEN_LOCK_TYPE_SWIPE = 0, + SETTING_SCREEN_LOCK_TYPE_MOTION, + SETTING_SCREEN_LOCK_TYPE_FACE_AND_VOICE, + SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD, + SETTING_SCREEN_LOCK_TYPE_PASSWORD, + SETTING_SCREEN_LOCK_TYPE_OTHER, + SETTING_SCREEN_LOCK_TYPE_MAX +}; + + + + +_LockManagerImpl::_LockManagerImpl() +{ +} + +_LockManagerImpl::~_LockManagerImpl() +{ +} + +_LockManagerImpl* +_LockManagerImpl::GetInstance() +{ + static _LockManagerImpl* pLockManagerImpl = null; + if( pLockManagerImpl == null ) + { + pLockManagerImpl = new (std::nothrow) _LockManagerImpl(); + } + + return pLockManagerImpl; +} + +bool +_LockManagerImpl::IsLocked(void) const +{ + int idleLockState = 0; + vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &idleLockState); + return (idleLockState == VCONFKEY_IDLE_LOCK); +} + +bool +_LockManagerImpl::IsSecureMode(void) const +{ + int screenLockType = 0; + vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &screenLockType); + + switch(screenLockType) + { + case SETTING_SCREEN_LOCK_TYPE_SWIPE: + case SETTING_SCREEN_LOCK_TYPE_MOTION: + return false; + + case SETTING_SCREEN_LOCK_TYPE_FACE_AND_VOICE: + case SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD: + case SETTING_SCREEN_LOCK_TYPE_PASSWORD: + case SETTING_SCREEN_LOCK_TYPE_OTHER: + return true; + + default: + SysAssert(false); + } + + return false; +} + +result +_LockManagerImpl::Unlock(void) +{ + if( IsLocked() == false ) + { + return E_SUCCESS; + } + +// SysTryReturnResult(NID_APP, !IsSecureMode(), E_INVALID_OPERATION, "Secured lock screen can't be unlocked."); + + int errorCode = -1; + errorCode = vconf_set_int(VCONFKEY_IDLE_LOCK_STATE, VCONFKEY_IDLE_UNLOCK); + SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "Failed to set on VCONFKEY_REGIONFORMAT_TIME1224 vconf"); + + return E_SUCCESS; +} + + +}} // Tizen::Shell diff --git a/src/inc/FShell_LockManagerImpl.h b/src/inc/FShell_LockManagerImpl.h new file mode 100755 index 0000000..4dba0ba --- /dev/null +++ b/src/inc/FShell_LockManagerImpl.h @@ -0,0 +1,141 @@ +// +// Open Service Platform +// Copyright (c) 2013 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 FShell_LockManagerImpl.h + * @brief This is the header file for the _LockManagerImpl class. + * + * This header file contains the declarations of the %_LockManagerImpl class. + */ + +#ifndef _FSHELL_INTERNAL_LOCK_MANAGER_IMPL_H_ +#define _FSHELL_INTERNAL_LOCK_MANAGER_IMPL_H_ + +#include + +namespace Tizen { namespace Shell { + +/** + * @class _LockManagerImpl + * @brief Manages state of lock screen. + * + * @since 2.1 + * + * @final This class is not intended for extension. + * + * The %_LockManagerImpl class manages information of lock screen. + */ +class _OSP_EXPORT_ _LockManagerImpl + : public Tizen::Base::Object +{ +public: + /** + * Gets the %_LockManagerImpl instance. + * + * @since 2.1 + * + * @return A pointer to the %_LockManagerImpl instance, @n + * else @c null if it fails + * + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @exception E_SYSTEM The method cannot proceed due to a severe system error. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + static _LockManagerImpl* GetInstance(void); + + /** + * Checks whether the screen is locked. + * + * @since 2.1 + * + * @return @c true if the screen is locked, + * else @c false + */ + bool IsLocked(void) const; + + /** + * Checks whether password lock screen is enabled by Settings. + * + * @since 2.1 + * + * @return @c true if password lock screen is enabled, + * else @c false + */ + bool IsSecureMode(void) const; + + /** + * Unlocks current lock screen. + + * @privlevel partner + * @privilege http://tizen.org/privilege/lockmanager + * + * @since 2.1 + * + * @exception E_SUCCESS The method is successful. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + * @exception E_INVALID_OPERATION Can't unlock, because secure mode is enabled. + * @exception E_SYSTEM The method cannot proceed due to a severe system error. + * + * @remark This API call has no effect while secure mode is enabled. + */ + result Unlock(void); + +private: + // + // This default constructor is intentionally declared as private to implement the %Singleton semantic. + // + // @since 2.1 + // + _LockManagerImpl(void); + + // + // This destructor is intentionally declared as private to implement the %Singleton semantic. + // + // @since 2.1 + // + virtual ~_LockManagerImpl(void); + + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + // @since 2.1 + // + _LockManagerImpl(const _LockManagerImpl& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + // @since 2.1 + // + _LockManagerImpl& operator =(const _LockManagerImpl& rhs); + + // + // Constructs the instance of this class. + // + // @since 2.1 + // + // @return An error code + // @exception E_SUCCESS The method is successful. + // @exception E_SYSTEM The method cannot proceed due to a severe system error. + // + result Construct(void); +}; + +}} // Tizen::Shell + +#endif /* _FSHELL_INTERNAL_LOCK_MANAGER_IMPL_H_ */ -- 2.7.4