modify license, permission and remove ^M char
[platform/framework/native/uifw.git] / src / ui / FUiKeyEventManager.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an ”AS IS” BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 /**
18 * @file             FUiKeyEventManager.cpp
19 * @brief                This is the implementation file for KeyEventManager class.
20 * @version              2.0
21 * @see                  Tizen::Ui::KeyEventManager
22 *
23 */
24
25 // includes
26 #include <FBaseSysLog.h>
27 #include <FUiControl.h>
28 #include <FUiKeyEventManager.h>
29 #include "FUi_KeyEventManagerImpl.h"
30 #include "FUi_ControlImpl.h"
31
32 using namespace Tizen::Ui;
33
34 namespace Tizen { namespace Ui
35 {
36 KeyEventManager* pKeyEventManagerInstance = null;
37
38 ////////////////////////////////////////////////////////////////////////////////
39 /// KeyEventManager class Lifecycle
40
41 KeyEventManager::KeyEventManager(void)
42 {
43 }
44
45 KeyEventManager::~KeyEventManager(void)
46 {
47 }
48
49 result
50 KeyEventManager::Construct(void)
51 {
52         return E_SUCCESS;
53 }
54
55 KeyEventManager*
56 KeyEventManager::GetInstance(void)
57 {
58         static pthread_once_t once_block = PTHREAD_ONCE_INIT;
59
60         pthread_once(&once_block, InitializeInstance);
61
62         _KeyEventManagerImpl* pEventImpl = _KeyEventManagerImpl::GetInstance();
63         if (!pEventImpl)
64         {
65                 return null;
66         }
67
68         return pKeyEventManagerInstance;
69 }
70
71 void
72 KeyEventManager::InitializeInstance(void)
73 {
74         static KeyEventManager instance;
75         pKeyEventManagerInstance = &instance;
76
77 }
78
79 ////////////////////////////////////////////////////////////////////////////////
80 /// KeyEventManager class Operation
81
82 void
83 KeyEventManager::AddKeyEventListener(IKeyEventListener& listener)
84 {
85         _KeyEventManagerImpl* pEventImpl = _KeyEventManagerImpl::GetInstance();
86         SysAssertf(pEventImpl != null, "Not yet constructed. Construct() should be called before use.");
87
88         pEventImpl->AddKeyEventListener(listener);
89 }
90
91 void
92 KeyEventManager::RemoveKeyEventListener(IKeyEventListener& listener)
93 {
94         _KeyEventManagerImpl* pEventImpl = _KeyEventManagerImpl::GetInstance();
95         SysAssertf(pEventImpl != null, "Not yet constructed. Construct() should be called before use.");
96
97         pEventImpl->RemoveKeyEventListener(listener);
98 }
99
100 } } //Tizen::Ui