2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @file FApp_ImeAppImpl.cpp
20 * @brief This is the implementation for the _ImeAppImpl class.
29 #define Uses_SCIM_HELPER
30 #define Uses_SCIM_TYPES
31 #define Uses_SCIM_CONFIG_BASE
36 #include <FAppAppRegistry.h>
37 #include <FBaseColArrayList.h>
38 #include <FUiCtrlFrame.h>
40 #include <FBaseSysLog.h>
41 #include <FUi_ControlManager.h>
42 #include <FUi_ControlImplManager.h>
43 #include <FUi_KeyEventManager.h>
44 #include <FUi_WindowImpl.h>
45 #include <FUi_EcoreEvasMgr.h>
46 #include <FUi_EcoreEvas.h>
47 #include <FSys_PowerManagerImpl.h>
49 #include "FApp_AppFrame.h"
50 #include "FApp_AppInfo.h"
51 #include "FApp_AppImpl.h"
52 #include "FApp_ImeAppImpl.h"
53 #include "FAppPkg_PackageManagerImpl.h"
55 //#include "FUiIme_ScimDataConverter.h"
57 using namespace Tizen::App;
58 using namespace Tizen::App::Package;
59 using namespace Tizen::Base;
60 using namespace Tizen::Base::Collection;
61 using namespace Tizen::Ui;
62 using namespace Tizen::Ui::Controls;
63 using namespace Tizen::Ui::Ime;
64 using namespace Tizen::System;
65 using namespace Tizen::Graphics;
68 const char GLINFO_FILE_PATH[] = "info/webservice.info";
71 namespace Tizen { namespace App
74 _ImeAppImpl* _ImeAppImpl::__pImeAppImpl = null;
77 _ImeAppImpl::_ImeAppImpl(UiApp* pUiApp)
79 , __pAppImpl(_AppImpl::GetInstance())
80 , __appUiState(APP_UI_STATE_BACKGROUND)
84 SysTryReturnVoidResult(NID_APP, __pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting internal instance failed.");
88 _ImeAppImpl::~_ImeAppImpl(void)
95 _ImeAppImpl::OnCreate(void)
97 SysLog(NID_APP, "Platform creation event.");
99 _AppInfo::SetAppState(INITIALIZING);
106 _ImeAppImpl::OnService(service_s* service)
112 _ImeAppImpl::OnTerminate(void)
114 SysLog(NID_APP, "Termination event 0x%x state", _AppInfo::GetAppState());
116 if (OnImeAppImplTerminating() != true)
118 SysLog(NID_APP, "[E_SYSTEM] The Termination of application failed.");
124 _ImeAppImpl::OnResume(void)
126 SysLog(NID_APP, "System resume event on 0x%x state", _AppInfo::GetAppState());
128 if (_AppInfo::GetAppState() == RUNNING)
136 _ImeAppImpl::OnPause(void)
138 SysLog(NID_APP, "System pause event on 0x%x state", _AppInfo::GetAppState());
140 if (_AppInfo::GetAppState() == RUNNING)
148 _ImeAppImpl::OnDeviceOrientationChanged(app_device_orientation_e orientation)
150 SysLog(NID_APP, "System device orientation event.");
152 _ControlImplManager* pControlImplManager = _ControlImplManager::GetInstance();
153 if (pControlImplManager == null)
155 SysLog(NID_APP, "Device orientation event arrived too early.");
159 pControlImplManager->OnScreenRotated(orientation);
164 _ImeAppImpl::OnWindowHandleRequest(void)
166 const _EcoreEvas* const pEvas = GetEcoreEvasMgr()->GetEcoreEvas();
167 return (pEvas) ? static_cast<long>(pEvas->GetXWindow()) : -1;
172 _ImeAppImpl::OnAppInitializing(void)
174 // [FIXME] Temporary code for enabling opengl
176 // to reduce package manager overhead, _AppInfo::GetAppRootPath() is not used
178 if (faccessat(_AppInfo::GetAppRootDirFd(), GLINFO_FILE_PATH, F_OK, 0) == 0)
180 SysLog(NID_APP, "Setting opengl engine for WEB_SERVICE privilege.");
181 elm_config_preferred_engine_set("opengl_x11");
184 // Do Ui related initializing for UiApp
185 result r = InitializeUiFramework();
188 SysLogException(NID_APP, E_SYSTEM, "Getting resolution information failure. Application may not be installed correctly.");
192 _KeyEventManager::GetInstance()->AddKeyEventListener(*this);
194 SysTryReturn(NID_APP, __pUiApp != null, false, E_INVALID_STATE, "[E_INVALID_STATE] Getting UiApp instance failed.");
195 return __pUiApp->OnAppInitializing(*(AppRegistry::GetInstance()));
200 _ImeAppImpl::OnAppInitialized(void)
202 SysTryReturn(NID_APP, __pUiApp != null, false, E_INVALID_STATE, "[E_INVALID_STATE] Getting UiApp instance failed.");
204 __pUiApp->OnAppInitialized();
210 _ImeAppImpl::OnImeAppImplTerminating(void)
214 if (_AppInfo::GetAppState() != TERMINATED)
216 result = __pUiApp->OnAppTerminating(*(AppRegistry::GetInstance()), __pAppImpl->IsForcedTermination());
217 _AppInfo::SetAppState(TERMINATED);
220 // Do Ui related finalizing for UiApp
221 FinalizeUiFramework();
228 _ImeAppImpl::OnForeground(void)
230 result r = E_SUCCESS;
232 __appUiState = APP_UI_STATE_FOREGROUND;
233 __pUiApp->OnForeground();
235 r = _PowerManagerImpl::OnForeground();
237 SysTryLog(NID_APP, !IsFailed(r), "Failed to send foreground event to powermanager");
242 _ImeAppImpl::OnBackground(void)
244 result r = E_SUCCESS;
246 __appUiState = APP_UI_STATE_BACKGROUND;
247 __pUiApp->OnBackground();
249 r = _PowerManagerImpl::OnBackground();
251 SysTryLog(NID_APP, !IsFailed(r), "Failed to send background event to powermanager");
256 _ImeAppImpl::GetAppUiState(void) const
263 _ImeAppImpl::GetInstance(void)
265 return __pImeAppImpl;
270 _ImeAppImpl::GetUiAppInstance(void)
278 #define MAX_BUFFER 100
283 #endif // __cplusplus
285 extern int OspImeInfo(char* uuid, char* name, char* language) __attribute__((weak));
287 unsigned int _OSP_EXPORT_
288 scim_helper_module_number_of_helpers (void)
290 LOG(LOG_DEBUG, "IME", "IME : scim_helper_module_number_of_helpers");
295 scim_helper_module_get_helper_info (unsigned int idx, scim::HelperInfo& info)
297 char uuid[MAX_BUFFER];
298 char name[MAX_BUFFER];
299 memset(uuid, '\0', MAX_BUFFER);
300 memset(name, '\0', MAX_BUFFER);
302 LOG(LOG_DEBUG, "IME", "IME : scim_helper_module_get_helper_info enter");
304 if (dlsym(null, "OspImeInfo") != null)
306 LOG(LOG_DEBUG, "IME", "IME : OspImeInfo found");
307 OspImeInfo(uuid, name, null);
310 LOG(LOG_DEBUG, "IME", "IME : scim_helper_module_get_helper_info 2 %ls %ls", uuid, name);
312 if (strlen(uuid) == 0)
314 LOG(LOG_DEBUG, "IME", "IME : OspImeInfo no uuid return");
315 strncpy(uuid, "723191f0-cfb3-11e1-9ea3-e811323afc30", strlen("723191f0-cfb3-11e1-9ea3-e811323afc30"));
318 if (strlen(name) == 0)
320 LOG(LOG_DEBUG, "IME", "IME : OspImeInfo no name return");
321 strncpy(name, "Keyboard", strlen("Keyboard"));
327 LOG(LOG_DEBUG, "IME", "IME : scim_helper_module_get_helper_info %ls %ls", Uuid.GetPointer(), Name.GetPointer());
329 Tizen::Ui::Ime::_ScimDataConverter dataConverter;
330 scim::String scimUuid;
331 scim::String scimName;
333 dataConverter.ConvertString(Uuid, scimUuid);
334 dataConverter.ConvertString(Name, scimName);
338 info = scim::HelperInfo(scimUuid, scimName, "", "",
339 scim::SCIM_HELPER_STAND_ALONE | scim::SCIM_HELPER_NEED_SCREEN_INFO | scim::SCIM_HELPER_AUTO_RESTART);
346 scim::String _OSP_EXPORT_
347 scim_helper_module_get_helper_language (unsigned int idx)
349 // get ImeApplicationInfo
350 char uuid[MAX_BUFFER];
351 char language[MAX_BUFFER];
352 memset(uuid, '\0', MAX_BUFFER);
353 memset(language, '\0', MAX_BUFFER);
355 LOG(LOG_DEBUG, "IME", "IME : scim_helper_module_get_helper_language enter");
357 if (dlsym(null, "OspImeInfo") != null)
359 LOG(LOG_DEBUG, "IME", "IME : OspImeInfo found");
360 OspImeInfo(uuid, null, language);
363 if (strlen(language) == 0)
365 LOG(LOG_DEBUG, "IME", "IME : OspImeInfo no language return");
366 strncpy(language, "fr_FR", strlen("fr_FR"));
369 String Language(language);
371 LOG(LOG_DEBUG, "IME", "IME : scim_helper_module_get_helper_language %ls", Language.GetPointer());
374 Tizen::Ui::Ime::_ScimDataConverter dataConverter;
375 scim::String scimLanguage;
377 dataConverter.ConvertString(Language, scimLanguage);
383 scim_module_init (void)
385 LOG(LOG_DEBUG, "IME", "IME : scim_module_init");
389 scim_module_exit (void)
391 LOG(LOG_DEBUG, "IME", "IME : scim_module_exit");
396 #endif // __cplusplus