2 // Open Service Platform
\r
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
\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
9 // http://www.apache.org/licenses/LICENSE-2.0
\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
19 * @file FUiIme_InputServiceBinder.cpp
\r
20 * @brief This is the implementation file for the %_InputServiceBinder class.
\r
22 * This implementation file contains definition of the %_InputServiceBinder class.
\r
27 #include <FBaseSysLog.h>
\r
29 #include "FUiIme_ImeInfo.h"
\r
30 #include "FUiIme_InputServiceBinder.h"
\r
31 #include "FUiIme_ScimDataConverter.h"
\r
33 using namespace Tizen::Base;
\r
35 namespace Tizen { namespace Ui { namespace Ime {
\r
37 _InputServiceBinder* _InputServiceBinder::__pInputServiceBinder = null;
\r
39 _InputServiceBinder::_InputServiceBinder(void)
\r
40 :__pHelperAgent(null)
\r
41 ,__pScimDataConverter(null)
\r
45 _InputServiceBinder::~_InputServiceBinder(void)
\r
47 if (IsBound() == true)
\r
52 delete __pHelperAgent;
\r
53 __pHelperAgent = null;
\r
55 delete __pScimDataConverter;
\r
56 __pScimDataConverter = null;
\r
60 _InputServiceBinder::Construct(void)
\r
62 result r = E_SUCCESS;
\r
64 __pHelperAgent = new(std::nothrow) scim::HelperAgent();
\r
65 SysTryReturnResult(NID_UI_IME, __pHelperAgent, E_OUT_OF_MEMORY, "Memory allocation failed.");
\r
67 __pScimDataConverter = new(std::nothrow) _ScimDataConverter();
\r
68 SysTryCatch(NID_UI_IME, __pScimDataConverter, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
\r
73 delete __pHelperAgent;
\r
74 __pHelperAgent = null;
\r
79 _InputServiceBinder*
\r
80 _InputServiceBinder::GetInstance(void)
\r
82 result r = E_SUCCESS;
\r
84 if (!__pInputServiceBinder)
\r
86 __pInputServiceBinder = new(std::nothrow) _InputServiceBinder();
\r
87 SysTryReturn(NID_UI_IME, __pInputServiceBinder, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
\r
89 r = __pInputServiceBinder->Construct();
\r
90 SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
\r
93 return __pInputServiceBinder;
\r
96 delete __pInputServiceBinder;
\r
97 __pInputServiceBinder = null;
\r
103 _InputServiceBinder::GetHelperAgent(void) const
\r
105 return __pHelperAgent;
\r
109 _InputServiceBinder::Bind(void)
\r
111 result r = E_SUCCESS;
\r
113 int bindingId = -1;
\r
115 _ImeInfo* pImeInfo = _ImeInfo::GetInstance();
\r
117 scim::String uuid = pImeInfo->GetUuid();
\r
118 scim::String name = pImeInfo->GetName();
\r
120 scim::HelperInfo helperInfo(uuid, name, "", "",
\r
121 scim::SCIM_HELPER_STAND_ALONE | scim::SCIM_HELPER_NEED_SCREEN_INFO | scim::SCIM_HELPER_AUTO_RESTART);
\r
123 if (IsBound() == true)
\r
126 SysTryReturn(NID_UI_IME, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
\r
129 bindingId = __pHelperAgent->open_connection(helperInfo, ":0");
\r
130 SysTryReturn(NID_UI_IME, bindingId > -1, bindingId, E_CONNECTION_FAILED, "[E_CONNECTION_FAILED] The connection to the specific destination fails.");
\r
132 SysLog(NID_UI_IME, "The binding ID is %d.", bindingId);
\r
138 _InputServiceBinder::Unbind(void)
\r
140 result r = E_SUCCESS;
\r
142 SysTryReturnResult(NID_UI_IME, IsBound() == true, E_HOST_NOT_FOUND, "The destination host is not found.");
\r
144 __pHelperAgent->close_connection();
\r
150 _InputServiceBinder::IsBound(void) const
\r
152 return __pHelperAgent->is_connected();
\r
156 _InputServiceBinder::GetBindingId(void) const
\r
158 int bindingId = __pHelperAgent->get_connection_number();
\r
159 SysTryReturn(NID_UI_IME, bindingId > -1, bindingId, E_HOST_NOT_FOUND, "[E_HOST_NOT_FOUND] The destination host is not found.");
\r
164 }}} // Tizen::Ui::Ime
\r