implementation of LockManager::Unlock() API
authorJiban Prakash <p.jiban@samsung.com>
Tue, 16 Apr 2013 09:28:42 +0000 (14:58 +0530)
committerJiban Prakash <p.jiban@samsung.com>
Tue, 16 Apr 2013 12:38:03 +0000 (18:08 +0530)
Change-Id: I8e4ad93c1a8552310462b28d2518be7edd9ebb08
Signed-off-by: Jiban Prakash <p.jiban@samsung.com>
src/core/CMakeLists.txt
src/core/FShell_LockManagerImpl.cpp
src/core/FShell_LockManagerIpcMessages.cpp [new file with mode: 0644]
src/core/FShell_LockManagerProxy.cpp [new file with mode: 0644]
src/inc/FShell_LockManagerImpl.h
src/inc/FShell_LockManagerIpcMessages.h [new file with mode: 0644]
src/inc/FShell_LockManagerProxy.h [new file with mode: 0644]

index 45cfae4..a41de92 100644 (file)
@@ -4,6 +4,7 @@ INCLUDE_DIRECTORIES(
        ${CMAKE_SOURCE_DIR}/inc
        ${CMAKE_SOURCE_DIR}/src/inc
        ${CMAKE_SOURCE_DIR}/src/core
+       /usr/include/chromium
        /usr/include/osp
        /usr/include/osp/app
        /usr/include/osp/base
@@ -15,6 +16,8 @@ INCLUDE_DIRECTORIES(
        /usr/include/shortcut
        /usr/include/vconf
        /usr/include/badge
+       /usr/include/glib-2.0
+       /usr/lib/glib-2.0/include
 )
 
 SET (${this_target}_SOURCE_FILES
@@ -26,6 +29,8 @@ SET (${this_target}_SOURCE_FILES
        FShell_NotificationManagerImpl.cpp
        FShell_NotificationRequestImpl.cpp
        FShell_ShortcutManagerImpl.cpp
+       FShell_LockManagerProxy.cpp
+       FShell_LockManagerIpcMessages.cpp
 )
 
 ## Definitions
@@ -45,6 +50,7 @@ ADD_LIBRARY (${this_target} SHARED ${${this_target}_SOURCE_FILES})
 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" )
 TARGET_LINK_LIBRARIES(${this_target} "-lcapi-appfw-app-manager" )
index 7f6be4d..5425ecb 100644 (file)
  * @brief      This is the implementation for the _LockManagerImpl class.
  */
 
+#include <unique_ptr.h>
 #include <vconf.h>
 #include <FBaseLog.h>
 #include <FBaseSysLog.h>
 #include <FShell_LockManagerImpl.h>
+#include <FShell_LockManagerProxy.h>
 
 namespace Tizen { namespace Shell
 {
@@ -67,11 +69,31 @@ _LockManagerImpl::GetInstance()
        if( pLockManagerImpl == null )
        {
                pLockManagerImpl = new (std::nothrow) _LockManagerImpl();
+               SysTryReturn(NID_APP, pLockManagerImpl, null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+               result r = pLockManagerImpl->Construct();
+               SysTryReturn(NID_APP, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
        }
 
        return pLockManagerImpl;
 }
 
+result
+_LockManagerImpl::Construct(void)
+{
+       result r = E_SUCCESS;
+
+       std::unique_ptr< _LockManagerProxy > pLockManager(new (std::nothrow) _LockManagerProxy);
+       SysTryReturnResult(NID_APP, pLockManager, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+       r = pLockManager->Construct();
+       SysTryReturnResult(NID_APP, !IsFailed(r), r, "Propagating.");
+
+       __pLockManager = pLockManager.release();
+
+       return E_SUCCESS;
+}
+
 bool
 _LockManagerImpl::IsLocked(void) const
 {
@@ -112,14 +134,8 @@ _LockManagerImpl::Unlock(void)
        {
                return E_SUCCESS;
        }
-
-//     SysTryReturnResult(NID_SHELL, !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;
+       return __pLockManager->Unlock();
 }
 
+
 }} // Tizen::Shell
diff --git a/src/core/FShell_LockManagerIpcMessages.cpp b/src/core/FShell_LockManagerIpcMessages.cpp
new file mode 100644 (file)
index 0000000..1d7cd83
--- /dev/null
@@ -0,0 +1,46 @@
+//
+// Open Service Platform
+// 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       FShell_LockManagerIpcMessages.cpp
+ * @brief      This file contains IPC message class generated by macros.
+ */
+
+#define IPC_MESSAGE_IMPL
+#include "FShell_LockManagerIpcMessages.h"
+
+// Generate constructors.
+#include "ipc/struct_constructor_macros.h"
+#include "FShell_LockManagerIpcMessages.h"
+// Generate destructors.
+
+#include "ipc/struct_destructor_macros.h"
+#include "FShell_LockManagerIpcMessages.h"
+
+// Generate param traits write methods.
+#include "ipc/param_traits_write_macros.h"
+namespace IPC
+{
+#include "FShell_LockManagerIpcMessages.h"
+}  // namespace IPC
+
+// Generate param traits read methods.
+#include "ipc/param_traits_read_macros.h"
+namespace IPC
+{
+#include "FShell_LockManagerIpcMessages.h"
+}  // namespace IPC
diff --git a/src/core/FShell_LockManagerProxy.cpp b/src/core/FShell_LockManagerProxy.cpp
new file mode 100644 (file)
index 0000000..2c705b8
--- /dev/null
@@ -0,0 +1,74 @@
+//
+// Open Service Platform
+// 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        FShell_LockManagerProxy.cpp
+ * @brief      This is the implementation for the _LockManagerProxy.cpp class.
+ */
+
+#include <new>
+#include <memory>
+#include <unique_ptr.h>
+#include <FBaseErrors.h>
+#include <FBaseSysLog.h>
+#include <FIo_IpcClient.h>
+
+#include "FShell_LockManagerIpcMessages.h"
+#include "FShell_LockManagerProxy.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Shell;
+
+namespace Tizen { namespace Shell
+{
+
+_LockManagerProxy::_LockManagerProxy(void)
+       : __pIpcClient(null)
+{
+}
+
+_LockManagerProxy::~_LockManagerProxy(void)
+{
+}
+
+result
+_LockManagerProxy::Construct()
+{
+       __pIpcClient = new (std::nothrow) Tizen::Io::_IpcClient();
+       SysTryReturnResult(NID_APP, __pIpcClient != null, E_OUT_OF_MEMORY, "The memory is not sufficient.");
+
+       result r = __pIpcClient->Construct("osp.shell.ipcserver.lockmanager");
+       SysTryReturnResult(NID_APP, !IsFailed(r), r, "_IpcClient constructing failed.");
+
+       return E_SUCCESS;
+}
+
+result
+_LockManagerProxy::Unlock()
+{
+      SysTryReturnResult(NID_APP, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null.");
+
+      result response = E_SUCCESS;
+
+      std::auto_ptr<IPC::Message> pMsg (new (std::nothrow) LockManager_Unlock(&response));
+      result r = __pIpcClient->SendRequest(*pMsg.get());
+      SysTryReturnResult(NID_APP, !IsFailed(r), r, "SendRequest is failed.");
+
+      return response;
+}
+
+} } // Tizen::Shell
index 4dba0ba..6ef710c 100755 (executable)
@@ -29,6 +29,7 @@
 
 namespace Tizen { namespace Shell {
 
+class _LockManagerProxy;
 /**
  * @class              _LockManagerImpl
  * @brief              Manages state of lock screen.
@@ -134,6 +135,9 @@ private:
        // @exception   E_SYSTEM        The method cannot proceed due to a severe system error.
        //
        result Construct(void);
+
+private:
+       _LockManagerProxy* __pLockManager;
 };
 
 }} // Tizen::Shell
diff --git a/src/inc/FShell_LockManagerIpcMessages.h b/src/inc/FShell_LockManagerIpcMessages.h
new file mode 100644 (file)
index 0000000..5b08a7c
--- /dev/null
@@ -0,0 +1,32 @@
+//
+// Open Service Platform
+// 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        FShell_LockManagerIpcMessages.h
+ * @brief      This is the header file for the LockManager Ipc message types.
+ */
+
+#include <FAppTypes.h>
+
+#include <ipc/ipc_message_macros.h>
+#include <FIo_IpcCommonParamTraits.h>
+#include <FIo_IpcMessageStart.h>
+
+#define IPC_MESSAGE_START LockManagerServiceStart
+
+IPC_SYNC_MESSAGE_CONTROL0_1(LockManager_Unlock, result)
+
diff --git a/src/inc/FShell_LockManagerProxy.h b/src/inc/FShell_LockManagerProxy.h
new file mode 100644 (file)
index 0000000..022fae7
--- /dev/null
@@ -0,0 +1,61 @@
+//
+// Open Service Platform
+// 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       FShell_LockManagerProxy.h
+ * @brief      This is the header file of the _LockManagerProxy class.
+ */
+
+#ifndef _FSHELL_INTERNAL_LOCK_MANAGER_PROXY_H_
+#define _FSHELL_INTERNAL_LOCK_MANAGER_PROXY_H_
+
+#include <FBaseObject.h>
+
+namespace Tizen { namespace Io { class _IpcClient; } }
+
+namespace Tizen { namespace Shell
+{
+
+/**
+ * @class       _LockManagerProxy
+ * @brief
+ * @since 2.1
+ */
+class _LockManagerProxy
+       : public Tizen::Base::Object
+{
+public:
+       _LockManagerProxy(void);
+       virtual ~_LockManagerProxy(void);
+
+       result Construct(void);
+
+       result Unlock();
+
+private:
+       _LockManagerProxy(const _LockManagerProxy& rhs);
+
+       _LockManagerProxy& operator =(const _LockManagerProxy& rhs);
+
+private:
+       Tizen::Io::_IpcClient* __pIpcClient;
+
+}; // _LockManagerProxy
+
+} } // Tizen::Shell
+
+#endif // _FSHELL_INTERNAL_LOCK_MANAGER_PROXY_H_