IME rotation sync related works.
[framework/osp/ime.git] / src / FUiImeInputMethod.cpp
1 //\r
2 // Open Service Platform\r
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.\r
4 //\r
5 // Licensed under the Apache License, Version 2.0 (the License);\r
6 // you may not use this file except in compliance with the License.\r
7 // You may obtain a copy of the License at\r
8 //\r
9 //     http://www.apache.org/licenses/LICENSE-2.0\r
10 //\r
11 // Unless required by applicable law or agreed to in writing, software\r
12 // distributed under the License is distributed on an "AS IS" BASIS,\r
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
14 // See the License for the specific language governing permissions and\r
15 // limitations under the License.\r
16 //\r
17 \r
18 /**\r
19  * @file        FUiImeInputMethod.cpp\r
20  * @brief       This is the implementation file for the %InputMethod class.\r
21  *\r
22  * This implementation file contains definition of the %InputMethod class.\r
23  */\r
24 \r
25 #include <new>\r
26 \r
27 #include <FBaseSysLog.h>\r
28 #include <FUiImeInputMethod.h>\r
29 \r
30 #include <FSec_AccessController.h>\r
31 #include "FUiIme_InputMethodImpl.h"\r
32 \r
33 using namespace Tizen::Base;\r
34 using namespace Tizen::Graphics;\r
35 using namespace Tizen::Security;\r
36 using namespace Tizen::Ui;\r
37 \r
38 namespace Tizen { namespace Ui { namespace Ime {\r
39 \r
40 static InputMethod* __pInputMethod = null;\r
41 \r
42 InputMethod::InputMethod(void)\r
43         :__pInputMethodImpl(null)\r
44 {\r
45 }\r
46 \r
47 InputMethod::~InputMethod(void)\r
48 {\r
49         __pInputMethod = null;\r
50         __pInputMethodImpl = null;\r
51 }\r
52 \r
53 result\r
54 InputMethod::Construct(void)\r
55 {\r
56         result r = E_SUCCESS;\r
57 \r
58         __pInputMethodImpl = new(std::nothrow) _InputMethodImpl();\r
59         SysTryReturnResult(NID_UI_IME, __pInputMethodImpl, E_OUT_OF_MEMORY, "Memory allocation failed.");\r
60 \r
61         r = __pInputMethodImpl->Construct();\r
62         SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "Propagating.");\r
63 \r
64         return r;\r
65 \r
66 CATCH:\r
67         delete __pInputMethodImpl;\r
68         __pInputMethodImpl = null;\r
69 \r
70         return r;\r
71 }\r
72 \r
73 InputMethod*\r
74 InputMethod::GetInstance(void)\r
75 {\r
76         result r = E_SUCCESS;\r
77 \r
78         r = _AccessController::CheckUserPrivilege(_PRV_IME);\r
79         SysTryReturn(NID_UI_IME, r == E_SUCCESS, null, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");\r
80 \r
81         if (__pInputMethod == null)\r
82         {\r
83                 __pInputMethod = new(std::nothrow) InputMethod();\r
84                 SysTryReturn(NID_UI_IME, __pInputMethod, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");\r
85 \r
86                 r = __pInputMethod->Construct();\r
87                 r = ((r == E_SUCCESS) || (r == E_CONNECTION_FAILED) || (r == E_SYSTEM)) ? r : E_SYSTEM;\r
88                 SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));\r
89         }\r
90 \r
91         return __pInputMethod;\r
92 \r
93 CATCH:\r
94         delete __pInputMethod;\r
95         __pInputMethod = null;\r
96 \r
97         return null;\r
98 }\r
99 \r
100 void\r
101 InputMethod::SetInputMethodProvider(IInputMethodProvider* pProvider)\r
102 {\r
103         __pInputMethodImpl->SetInputMethodProvider(pProvider);\r
104 }\r
105 \r
106 void\r
107 InputMethod::SetInputMethodProviderF(IInputMethodProviderF* pProvider)\r
108 {\r
109         __pInputMethodImpl->SetInputMethodProviderF(pProvider);\r
110 }\r
111 \r
112 void\r
113 InputMethod::SetInputMethodListener(IInputMethodListener* pListener)\r
114 {\r
115         __pInputMethodImpl->SetInputMethodListener(pListener);\r
116 }\r
117 \r
118 result\r
119 InputMethod::DeleteText(int cursorOffset, int length)\r
120 {\r
121         return __pInputMethodImpl->DeleteText(cursorOffset, length);\r
122 }\r
123 \r
124 result\r
125 InputMethod::NotifyInputPanelBounds(const FloatRectangle& portraitBounds, const FloatRectangle& landscapeBounds)\r
126 {\r
127         return __pInputMethodImpl->NotifyInputPanelBounds(portraitBounds, landscapeBounds);\r
128 }\r
129 \r
130 result\r
131 InputMethod::NotifyInputPanelState(InputPanelShowState state)\r
132 {\r
133         return __pInputMethodImpl->NotifyInputPanelState(state);\r
134 }\r
135 \r
136 result\r
137 InputMethod::NotifyLanguageChanged(void)\r
138 {\r
139         return __pInputMethodImpl->NotifyLanguageChanged();\r
140 }\r
141 \r
142 result\r
143 InputMethod::RequestSurroundingText(int lengthBeforeCursor, int lengthAfterCursor)\r
144 {\r
145         return __pInputMethodImpl->RequestSurroundingText(lengthBeforeCursor, lengthAfterCursor);\r
146 }\r
147 \r
148 result\r
149 InputMethod::SendCompositeText(const String& text)\r
150 {\r
151         return __pInputMethodImpl->SendCompositeText(text);\r
152 }\r
153 \r
154 result\r
155 InputMethod::SendKeyEvent(KeyCode code, KeyState state)\r
156 {\r
157         return __pInputMethodImpl->SendKeyEvent(code, state);\r
158 }\r
159 \r
160 result\r
161 InputMethod::SendText(const String& text)\r
162 {\r
163         return __pInputMethodImpl->SendText(text);\r
164 }\r
165 \r
166 }}} // Tizen::Ui::Ime\r