From: HyungKyu Song Date: Fri, 15 Feb 2013 06:09:27 +0000 (+0900) Subject: Tizen 2.0 Release X-Git-Tag: 2.0_release^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a984dd64ecba3b51721654a5dbd576fe9c9fc946;p=platform%2Fframework%2Fnative%2Fime.git Tizen 2.0 Release --- diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..e49c74c --- /dev/null +++ b/AUTHORS @@ -0,0 +1,2 @@ +Bumsung Cho +Jonghyun Yoon \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..ea1fa96 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,111 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) + +SET (this_target osp-ime) + +SET(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/cmake_build_tmp/output) + +INCLUDE_DIRECTORIES( + inc + src + /usr/include/chromium + /usr/include/dlog + /usr/include/dbus-1.0 + /usr/lib/dbus-1.0/include + /usr/include/e_dbus-1 + /usr/include/elementary-1 + /usr/include/efreet-1 + /usr/include/ecore-1 + /usr/include/edje-1 + /usr/include/evas-1 + /usr/include/eet-1 + /usr/include/eina-1 + /usr/include/eina-1/eina + /usr/include/ethumb-1 + /usr/include/libxml2 + /usr/include/media + /usr/include/osp + /usr/include/osp/base + /usr/include/osp/app + /usr/include/osp/net + /usr/include/osp/security + /usr/include/osp/io + /usr/include/osp/ui + /usr/include/scim-1.0 + ) + +SET (${this_target}_SOURCE_FILES + src/app/FApp_ImeEntry.cpp + src/FUiImeInputMethod.cpp + src/FUiImeInputMethodInfo.cpp + src/FUiImeInputMethodManager.cpp + src/FUiIme_EcoreFdHandler.cpp + src/FUiIme_ImeInfo.cpp + src/FUiIme_InputMethodImpl.cpp + src/FUiIme_InputMethodInfoImpl.cpp + src/FUiIme_InputMethodManagerImpl.cpp + src/FUiIme_InputServiceBinder.cpp + src/FUiIme_InputServiceSignalListener.cpp + src/FUiIme_Key.cpp + src/FUiIme_ScimDataConverter.cpp +) + +## Definitions +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall" ) + +## SET C COMPILER FLAGS +SET(CMAKE_C_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}") + +## SET CPP COMPILER FLAGS +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") +SET(CMAKE_CXX_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}") + +## Create Library +ADD_LIBRARY (${this_target} SHARED ${${this_target}_SOURCE_FILES}) + +## SET LINKER FLAGS +SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined -Wl,--as-needed") + +TARGET_LINK_LIBRARIES(${this_target} "-L/usr/lib/osp -losp-appfw") +TARGET_LINK_LIBRARIES(${this_target} "-losp-uifw") +TARGET_LINK_LIBRARIES(${this_target} "-ldlog") +TARGET_LINK_LIBRARIES(${this_target} "-ldl") +TARGET_LINK_LIBRARIES(${this_target} "-lecore") +TARGET_LINK_LIBRARIES(${this_target} "-lecore_x") +TARGET_LINK_LIBRARIES(${this_target} "-lelementary") +TARGET_LINK_LIBRARIES(${this_target} "-levas" ) +TARGET_LINK_LIBRARIES(${this_target} "-lpkgmgr-info" ) +TARGET_LINK_LIBRARIES(${this_target} "-lscim-1.0") +TARGET_LINK_LIBRARIES(${this_target} "-lxml2" ) + +SET_TARGET_PROPERTIES(${this_target} + PROPERTIES + VERSION ${FULLVER} + SOVERSION ${MAJORVER} + CLEAN_DIRECT_OUTPUT 1 + ) + +ADD_CUSTOM_COMMAND(TARGET ${this_target} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${LIBRARY_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX} ${LIBRARY_OUTPUT_PATH}/debug/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${FULLVER} + COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${FULLVER} ${LIBRARY_OUTPUT_PATH}/debug/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${MAJORVER} + COMMAND ${CMAKE_STRIP} --strip-unneeded ${LIBRARY_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX} + COMMENT "strip ${this_target}" + ) + +INSTALL(DIRECTORY ${LIBRARY_OUTPUT_PATH}/ DESTINATION lib/osp + FILES_MATCHING PATTERN "*.so*" + PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ + GROUP_EXECUTE GROUP_READ + WORLD_EXECUTE WORLD_READ) +INSTALL(DIRECTORY ${LIBRARY_OUTPUT_PATH}/debug/ DESTINATION lib/osp/debug + FILES_MATCHING PATTERN "*" + PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ + GROUP_EXECUTE GROUP_READ + WORLD_EXECUTE WORLD_READ) + +INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/inc/ DESTINATION include/osp FILES_MATCHING PATTERN "*.h") +INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/src/inc/ DESTINATION include/osp/media FILES_MATCHING PATTERN "*.h") + +# pkgconfig file +CONFIGURE_FILE(${this_target}.pc.in ${CMAKE_SOURCE_DIR}/${this_target}.pc @ONLY) +INSTALL(FILES ${CMAKE_SOURCE_DIR}/${this_target}.pc DESTINATION lib/pkgconfig) diff --git a/LICENSE.APLv2.0 b/LICENSE.APLv2.0 new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/LICENSE.APLv2.0 @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..1f506a2 --- /dev/null +++ b/NOTICE @@ -0,0 +1,3 @@ +Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved. +Except as noted, this software is licensed under Apache License, Version 2. +Please, see the LICENSE.APLv2 file for Apache License terms and conditions. \ No newline at end of file diff --git a/inc/FUiIme.h b/inc/FUiIme.h new file mode 100644 index 0000000..19dd845 --- /dev/null +++ b/inc/FUiIme.h @@ -0,0 +1,54 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 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 FUiIme.h + * @brief This is the header file for the %Tizen::Ui::Ime namespace. + * + * This header file contains the declarations and descriptions of the %Tizen::Ui::Ime namespace. + */ + +#ifndef _FUI_IME_H_ +#define _FUI_IME_H_ + +#include +#include +#include +#include +#include + +/** + * @namespace Tizen::Ui::Ime + * @brief This namespace contains the classes and interfaces for an input method. + * @since 2.0 + * + * @remarks @b Header @b %file: @b \#include @b @n + * @b Library : @b osp-ime + * + * The %Ui::Ime namespace provides a way to input a language in the associated text input UI control. + * + * For more information on the %Ui::Ime namespace features, see Input Guide. + * + * The following diagram illustrates the relationships between the classes belonging to the %Ime namespace. + * + * @image html ui_ime_namespace_classdiagram.png + */ +namespace Tizen { namespace Ui { namespace Ime { + +}}} // Tizen::Ui::Ime + +#endif // _FUI_IME_H_ diff --git a/inc/FUiImeIInputMethodListener.h b/inc/FUiImeIInputMethodListener.h new file mode 100644 index 0000000..3b6e3de --- /dev/null +++ b/inc/FUiImeIInputMethodListener.h @@ -0,0 +1,169 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 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 FUiImeIInputMethodListener.h + * @brief This is the header file for the %IInputMethodListener interface. + * + * This header file contains the declarations of the %IInputMethodListener interface. + */ + +#ifndef _FUI_IME_IINPUT_METHOD_LISTENER_H_ +#define _FUI_IME_IINPUT_METHOD_LISTENER_H_ + +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Ime { + +/** + * @if VISPARTNER + * @interface IInputMethodListener + * @brief This interface provides a listener for the InputMethod class to receive asynchronous callbacks from the input service. + * @since 2.0 + * + * @remarks IME application developers can implement a class that is derived from %IInputMethodListener and use it to receive asynchronous callbacks + * from the input service. + * + * @visibility partner + * @privilege http://tizen.org/privilege/ime + * + * The %IInputMethodListener provides a listener for the %InputMethod class to receive asynchronous callbacks from the input service. + * + * The following example demonstrates how to use the %IInputMethodListener interface. + * @code + * #include + * + * class MyListener + * : public IInputMethodListener + * { + * ... + * virtual void OnCursorPositionChanged(int position); + * ... + * }; + * @endcode + * + * @endif + */ +class _OSP_EXPORT_ IInputMethodListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * @if VISPARTNER + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this + * interface is called. + * + * @since 2.0 + * @visibility partner + * @privilege http://tizen.org/privilege/ime + * @endif + */ + virtual ~IInputMethodListener(void) {} + + /** + * @if VISPARTNER + * Called when the position of the cursor in an associated text input UI control changes. + * + * @since 2.0 + * @visibility partner + * @privilege http://tizen.org/privilege/ime + * + * @param[in] position The position of the cursor + * @endif + */ + virtual void OnCursorPositionChanged(int position) {} + + /** + * @if VISPARTNER + * Called when an associated text input UI control responds to a request with the surrounding text. + * + * @since 2.0 + * @visibility partner + * @privilege http://tizen.org/privilege/ime + * + * @param[in] text The surrounding text + * @param[in] cursorPosition The position of the cursor + * @remarks The surrounding text can be requested by the Tizen::Ui::Ime::InputMethod::RequestSurroundingText() method. The length of the + * surrounding text can be less than that requested by the user. + * @endif + */ + virtual void OnSurroundingTextReceived(const Tizen::Base::String& text, int cursorPosition) {} + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IInputMethodListener_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IInputMethodListener_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IInputMethodListener_Reserved3(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IInputMethodListener_Reserved4(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IInputMethodListener_Reserved5(void) {} +}; + +}}} // Tizen::Ui::Ime + +#endif // _FUI_IME_IINPUT_METHOD_LISTENER_H_ diff --git a/inc/FUiImeIInputMethodProvider.h b/inc/FUiImeIInputMethodProvider.h new file mode 100644 index 0000000..b2d6ac6 --- /dev/null +++ b/inc/FUiImeIInputMethodProvider.h @@ -0,0 +1,271 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 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 FUiImeIInputMethodProvider.h + * @brief This is the header file for the %IInputMethodProvider interface. + * + * This header file contains the declarations of the %IInputMethodProvider interface. + */ + +#ifndef _FUI_IME_IINPUT_METHOD_PROVIDER_H_ +#define _FUI_IME_IINPUT_METHOD_PROVIDER_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Ime { + +/** + * @if VISPARTNER + * @interface IInputMethodProvider + * @brief This is an interface for the InputMethod class that interacts with the associated text input UI control. + * @since 2.0 + * + * @remarks The IME application developers can implement a class derived from %IInputMethodProvider and set it as the provider of the InputMethod class. + * The IME application can then provide attributes for the soft input panel and operate according to the commands of the associated text input UI control. For + * example, when ShowInputPanel() or HideInputPanel() are called, the IME application's frame should either be hidden or made visible. + * + * @visibility partner + * @privilege http://tizen.org/privilege/ime + * + * The %IInputMethodProvider interface is an interface for the InputMethod class that interacts with the associated text input UI control. + * + * The following example demonstrates how to use the %IInputMethodProvider interface. + * @code + * #include + * + * class MyProvider + * : public IInputMethodProvider + * { + * ... + * virtual Tizen::Ui::InputPanelAction GetEnterKeyAction(void); + * virtual Tizen::Graphics::Rectangle GetInputPanelBounds(void); + * ... + * }; + * @endcode + * + * @endif + */ +class _OSP_EXPORT_ IInputMethodProvider +{ +public: + /** + * @if VISPARTNER + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this + * interface is called. + * + * @since 2.0 + * @visibility partner + * @privilege http://tizen.org/privilege/ime + * @endif + */ + virtual ~IInputMethodProvider(void) {} + + /** + * @if VISPARTNER + * Called when the associated text input UI control requests the enter key action of the input panel. + * + * @since 2.0 + * @visibility partner + * @privilege http://tizen.org/privilege/ime + * + * @return The enter key action of the input panel + * @endif + */ + virtual Tizen::Ui::InputPanelAction GetEnterKeyAction(void) {return Tizen::Ui::INPUT_PANEL_ACTION_ENTER;} + + /** + * @if VISPARTNER + * Called when the associated text input UI control requests the position and size of the input panel. + * + * @since 2.0 + * @visibility partner + * @privilege http://tizen.org/privilege/ime + * + * @return The position and size of the input panel + * @remarks The associated text input UI control can change its position on the screen to avoid becoming positioned behind the input panel. + * @endif + */ + virtual Tizen::Graphics::Rectangle GetInputPanelBounds(void) = 0; + + /** + * @if VISPARTNER + * Called when the associated text input UI control requests the style of the input panel. + * + * @since 2.0 + * @visibility partner + * @privilege http://tizen.org/privilege/ime + * + * @return A style of the input panel + * @endif + */ + virtual Tizen::Ui::InputPanelStyle GetInputPanelStyle(void) {return Tizen::Ui::INPUT_PANEL_STYLE_NORMAL;} + + /** + * @if VISPARTNER + * Called when the associated text input UI control requests the input panel to enable or disable the caps mode. + * + * @since 2.0 + * @visibility partner + * @privilege http://tizen.org/privilege/ime + * + * @param[in] enable The state of the caps mode + * @endif + */ + virtual void SetCapsModeEnabled(bool enable) {} + + /** + * @if VISPARTNER + * Called when the associated text input UI control requests the input panel to set the enter key action. + * + * @since 2.0 + * @visibility partner + * @privilege http://tizen.org/privilege/ime + * + * @param[in] action The enter key action + * @remarks The input panel can show text on the enter button according to the enter key action. + * @endif + */ + virtual void SetEnterKeyAction(Tizen::Ui::InputPanelAction action) {} + + /** + * @if VISPARTNER + * Called when the associated text input UI control requests the input panel to enable or disable the enter key action. + * + * @since 2.0 + * @visibility partner + * @privilege http://tizen.org/privilege/ime + * + * @param[in] enable The state of the enter key action + * @endif + */ + virtual void SetEnterKeyActionEnabled(bool enable) {} + + /** + * @if VISPARTNER + * Called when the associated text input UI control requests the input panel to set its style. + * + * @since 2.0 + * @visibility partner + * @privilege http://tizen.org/privilege/ime + * + * @param[in] style The style of the input panel + * @endif + */ + virtual void SetInputPanelStyle(Tizen::Ui::InputPanelStyle style) {} + + /** + * @if VISPARTNER + * Called when the associated text input UI control requests the input panel to hide itself. + * + * @since 2.0 + * @visibility partner + * @privilege http://tizen.org/privilege/ime + * + * @remarks The IME application developer should implement this interface. + * @endif + */ + virtual void HideInputPanel(void) = 0; + + /** + * @if VISPARTNER + * Called when the associated text input UI control checks whether the enter key action is enabled or not. + * + * @since 2.0 + * @visibility partner + * @privilege http://tizen.org/privilege/ime + * + * @return The state of the enter key action + * @endif + */ + virtual bool IsEnterKeyActionEnabled(void) {return false;} + + /** + * @if VISPARTNER + * Called when the associated text input UI control requests the input panel to show itself. + * + * @since 2.0 + * @visibility partner + * @privilege http://tizen.org/privilege/ime + * + * @remarks The IME application developer should implement this interface. + * @endif + */ + virtual void ShowInputPanel(void) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IInputMethodProvider_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IInputMethodProvider_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IInputMethodProvider_Reserved3(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IInputMethodProvider_Reserved4(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IInputMethodProvider_Reserved5(void) {} +}; + +}}} // Tizen::Ui::Ime + +#endif // _FUI_IME_IINPUT_METHOD_PROVIDER_H_ diff --git a/inc/FUiImeInputMethod.h b/inc/FUiImeInputMethod.h new file mode 100644 index 0000000..bfdefe5 --- /dev/null +++ b/inc/FUiImeInputMethod.h @@ -0,0 +1,313 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 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 FUiImeInputMethod.h + * @brief This is the header file for the %InputMethod class. + * + * This header file contains the declarations of the %InputMethod class. + */ + +#ifndef _FUI_IME_INPUT_METHOD_H_ +#define _FUI_IME_INPUT_METHOD_H_ + +#include +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Ime { + +class _InputMethodImpl; + +/** + * @if VISPARTNER + * @class InputMethod + * @brief This class provides a standard implementation of the %InputMethod. + * @since 2.0 + * + * @final This class is not intended for extension. + * @remarks IME application developers can use the %InputMethod to communicate with the associated text input UI control. First, set the provider which + * provides attributes of the soft input panel. Next, set the listener which lets the IME application receive asynchronous callbacks from the input service. These + * allow the IME application to interact with the associated text input UI control properly. After that, request the %InputMethod to send a text or a key event + * which is to be displayed in the associated text input UI control. + * + * @visibility partner + * @privilege http://tizen.org/privilege/ime + * + * The %InputMethod provides a standard implementation of the %InputMethod. + * + * The following example demonstrates how to use the %InputMethod class. + * @code + * #include + * #include + * + * using namespace Tizen::Ui::Ime; + * + * class MyProvider + * : public IInputMethodProvider + * { + * ... + * }; + * + * class MyListener + * : public IInputMethodListener + * { + * ... + * }; + * + * class MyImeApp + * { + * public: + * ... + * void Construct(); + * }; + * + * void + * MyImeApp::Construct() + * { + * // Gets an instance of InputMethod + * InputMethod* pInputMethod = InputMethod::GetInstance(); + * + * // Creates an instance of MyProvider and sets it as a provider + * MyProvider* pMyProvider = new(std::nothrow) MyProvider(); + * pInputMethod->SetInputMethodProvider(pMyProvider); + * + * // Creates an instance of MyListener and adds it to the input method + * MyListener* pMyListener = new(std::nothrow) MyListener(); + * pInputMethod->SetInputMethodListener(pMyListener); + * } + * @endcode + * + * @endif + */ + +class _OSP_EXPORT_ InputMethod + : public Tizen::Base::Object +{ +public: + /** + * @if VISPARTNER + * Gets an instance of the %InputMethod. + * + * @since 2.0 + * @visibility partner + * @privilege http://tizen.org/privilege/ime + * + * @return An instance of the %InputMethod + * @exception E_SUCCESS The method is successful. + * @exception E_CONNECTION_FAILED The connection to the input service fails. + * @exception E_SYSTEM A failure occurs from the underlying system. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + * @remarks The specific error code can be accessed using the GetLastResult() method and OOM might be thrown by this method. + * @endif + */ + static InputMethod* GetInstance(void); + + /** + * @if VISPARTNER + * Sets an instance of the IInputMethodProvider. + * + * @since 2.0 + * @visibility partner + * @privilege http://tizen.org/privilege/ime + * + * @param[in] pProvider An instance of the IInputMethodProvider + * @exception E_SUCCESS The method is successful. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + * @remarks The %InputMethod accepts only one provider. So users should unregister the provider by setting @c pProvider as @c null before + * deallocating an instance of the provider. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @endif + */ + void SetInputMethodProvider(IInputMethodProvider* pProvider); + + /** + * @if VISPARTNER + * Sets an instance of the IInputMethodListener. + * + * @since 2.0 + * @visibility partner + * @privilege http://tizen.org/privilege/ime + * + * @param[in] pListener An instance of the IInputMethodListener + * @exception E_SUCCESS The method is successful. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + * @remarks The %InputMethod accepts only one listener. So users should unregister the listener by setting @c pListener as @c null before + * deallocating an instance of the listener. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @endif + */ + void SetInputMethodListener(IInputMethodListener* pListener); + + /** + * @if VISPARTNER + * Deletes text at the position of the cursor. + * + * @since 2.0 + * @visibility partner + * @privilege http://tizen.org/privilege/ime + * + * @return An error code + * @param[in] cursorOffset The offset value from the cursor position + * @param[in] length The length of the text to delete + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The @c length is less than or equal to @c 0. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + * @endif + */ + result DeleteText(int cursorOffset, int length); + + /** + * @if VISPARTNER + * Notifies the state of the input panel to the associated text input UI control when the state of an input panel changes. + * + * @since 2.0 + * @visibility partner + * @privilege http://tizen.org/privilege/ime + * + * @return An error code + * @param[in] state The state of the input panel + * @exception E_SUCCESS The method is successful. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + * @endif + */ + result NotifyInputPanelState(Tizen::Ui::InputPanelShowState state); + + /** + * @if VISPARTNER + * Requests the surrounding text from the position of the cursor. + * + * @since 2.0 + * @visibility partner + * @privilege http://tizen.org/privilege/ime + * + * @return An error code + * @param[in] lengthBeforeCursor The length of the surrounding text before the cursor + * @param[in] lengthAfterCursor The length of the surrounding text after the cursor + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The arguments are less than @c 0. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + * @remarks The requested surrounding text can be received using the Tizen::Ui::Ime::IInputMethodListener::OnSurroundingTextReceived() method. + * @endif + */ + result RequestSurroundingText(int lengthBeforeCursor, int lengthAfterCursor); + + /** + * @if VISPARTNER + * Sends a composite text to the associated text input UI control. + * + * @since 2.0 + * @visibility partner + * @privilege http://tizen.org/privilege/ime + * + * @return An error code + * @param[in] text The composite text to send + * @exception E_SUCCESS The method is successful. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + * @remarks The composite text means a text which is being modified. + * @endif + */ + result SendCompositeText(const Tizen::Base::String& text); + + /** + * @if VISPARTNER + * Sends a key event directly to the associated text input UI control. + * + * @since 2.0 + * @visibility partner + * @privilege http://tizen.org/privilege/ime + * + * @return An error code + * @param[in] code The key code + * @param[in] state The key state + * @exception E_SUCCESS The method is successful. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + * @endif + */ + result SendKeyEvent(Tizen::Ui::KeyCode code, Tizen::Ui::KeyState state); + + /** + * @if VISPARTNER + * Sends text to the associated text input UI control. + * + * @since 2.0 + * @visibility partner + * @privilege http://tizen.org/privilege/ime + * + * @return An error code + * @param[in] text The text to send + * @exception E_SUCCESS The method is successful. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + * @endif + */ + result SendText(const Tizen::Base::String& text); + +private: + // + // This Construct() is intentionally declared as private so that only the platform can create an instance. + // + // @since 2.0 + // + // @return An error code + // @exception E_SUCCESS The method is successful. + // @exception E_CONNECTION_FAILED The connection to the input service fails. + // @exception E_SYSTEM A failure occurs from the underlying system. + // @remarks OOM might be thrown by this method. + // + result Construct(void); + + // + // This default constructor is intentionally declared as private to implement the Singleton semantic. + // + // @since 2.0 + // + InputMethod(void); + + // + // This destructor is intentionally declared as private to implement the Singleton semantic. + // + // @since 2.0 + // + virtual ~InputMethod(void); + + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + // @since 2.0 + // + InputMethod(const InputMethod& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + // @since 2.0 + // + InputMethod& operator=(const InputMethod& rhs); + +private: + friend class _InputMethodImpl; + + _InputMethodImpl* __pInputMethodImpl; +}; + +}}} // Tizen::Ui::Ime + +#endif // _FUI_IME_INPUT_METHOD_H_ diff --git a/inc/FUiImeInputMethodInfo.h b/inc/FUiImeInputMethodInfo.h new file mode 100644 index 0000000..d253a64 --- /dev/null +++ b/inc/FUiImeInputMethodInfo.h @@ -0,0 +1,162 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 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 FUiImeInputMethodInfo.h + * @brief This is the header file for the %InputMethodInfo class. + * + * This header file contains the declarations of the %InputMethodInfo class. + */ + +#ifndef _FUI_IME_INPUT_METHOD_INFO_H_ +#define _FUI_IME_INPUT_METHOD_INFO_H_ + +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Ime { + +class _InputMethodInfoImpl; + +/** + * @if VISPARTNER + * @class InputMethodInfo + * @brief This class provides a standard implementation of the %InputMethodInfo. + * @since 2.0 + * + * @final This class is not intended for extension. + * @remarks A user can get the general information of the input method. + * + * @visibility partner-manufacturer + * @privilege http://tizen.org/privilege/imemanager + * + * The %InputMethodInfo class provides a standard implementation of the %InputMethodInfo. + * + * @endif + */ +class _OSP_EXPORT_ InputMethodInfo + : public Tizen::Base::Object +{ +public: + /** + * @if VISPARTNER + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + * @visibility partner-manufacturer + * @privilege http://tizen.org/privilege/imemanager + * @endif + */ + virtual ~InputMethodInfo(void); + + /** + * @if VISPARTNER + * Gets the application ID of an input method. + * + * @since 2.0 + * @visibility partner-manufacturer + * @privilege http://tizen.org/privilege/imemanager + * + * @return The application ID + * @exception E_SUCCESS The method is successful. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + * @endif + */ + Tizen::App::AppId GetAppId(void) const; + + /** + * @if VISPARTNER + * Gets the language list that an input method supports. + * + * @since 2.0 + * @visibility partner-manufacturer + * @privilege http://tizen.org/privilege/imemanager + * + * @return An instance of the language list that consists of the Locale instances + * @exception E_SUCCESS The method is successful. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + * @remarks The %InputMethodInfo automatically deallocates the memory of the language list when it is destroyed. Therefore a user should not + * manually deallocate the memory of the language list. + * @endif + */ + const Tizen::Base::Collection::IList* GetLanguageList(void) const; + + /** + * @if VISPARTNER + * Gets the name of an input method. + * + * @since 2.0 + * @visibility partner-manufacturer + * @privilege http://tizen.org/privilege/imemanager + * + * @return The name + * @exception E_SUCCESS The method is successful. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + * @endif + */ + Tizen::Base::String GetName(void) const; + +private: + // + // This Equals() is intentionally declared as private so that only the platform can compare the object received as an input parameter with this object. + // + // @since 2.0 + // + // @return @c true if the object received as an input parameter equals this object, @n + // else @c false + // @param[in] object A reference to the %InputMethodInfo + // + virtual bool Equals(const Object& object) const; + + // + // This default constructor is intentionally declared as private so that only the platform can create an instance. + // + // @since 2.0 + // + InputMethodInfo(void); + + // + // This copy constructor is intentionally declared as private so that only the platform can copy objects. + // + // @since 2.0 + // + // @param[in] info A reference to the %InputMethodInfo + // + InputMethodInfo(const InputMethodInfo& info); + + // + // This copy assignment operator is intentionally declared as private so that only the platform can copy objects. + // + // @since 2.0 + // + // @param[in] info A reference to the %InputMethodInfo + // + InputMethodInfo& operator=(const InputMethodInfo& info); + +private: + friend class _InputMethodInfoImpl; + friend class _InputMethodManagerImpl; + + _InputMethodInfoImpl* __pInputMethodInfoImpl; +}; + +}}} // Tizen::Ui::Ime + +#endif // _FUI_IME_INPUT_METHOD_INFO_H_ diff --git a/inc/FUiImeInputMethodManager.h b/inc/FUiImeInputMethodManager.h new file mode 100644 index 0000000..cd0bc6d --- /dev/null +++ b/inc/FUiImeInputMethodManager.h @@ -0,0 +1,144 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 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 FUiImeInputMethodManager.h + * @brief This is the header file for the %InputMethodManager class. + * + * This header file contains the declarations of the %InputMethodManager class. + */ + +#ifndef _FUI_IME_INPUT_METHOD_MANAGER_H_ +#define _FUI_IME_INPUT_METHOD_MANAGER_H_ + +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Ime { + +class _InputMethodManagerImpl; + +/** + * @if VISPARTNER + * @class InputMethodManager + * @brief This class provides a standard implementation of the %InputMethodManager. + * @since 2.0 + * + * @final This class is not intended for extension. + * @remarks A user can manage input methods installed in the system. + * + * @visibility partner-manufacturer + * @privilege http://tizen.org/privilege/imemanager + * + * The %InputMethodManager provides a standard implementation of the %InputMethodManager. + * + * @endif + */ +class _OSP_EXPORT_ InputMethodManager + : public Tizen::Base::Object +{ +public: + /** + * @if VISPARTNER + * Gets an instance of the %InputMethodManager. + * + * @since 2.0 + * @visibility partner-manufacturer + * @privilege http://tizen.org/privilege/imemanager + * + * @return An instance of the %InputMethodManager + * @exception E_SUCCESS The method is successful. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + * @remarks The specific error code can be accessed using the GetLastResult() method and OOM might be thrown by this method. + * @endif + */ + static InputMethodManager* GetInstance(void); + + /** + * @if VISPARTNER + * Gets the list of the %InputMethodInfo of the input methods installed in the system. + * + * @since 2.0 + * @visibility partner-manufacturer + * @privilege http://tizen.org/privilege/imemanager + * + * @return An instance of the list that consists of the InputMethodInfo instances + * @exception E_SUCCESS The method is successful. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @endif + */ + Tizen::Base::Collection::IList* GetInputMethodInfoListN(void) const; + + /** + * @if VISPARTNER + * Sets an input method. + * + * @since 2.0 + * @visibility partner-manufacturer + * @privilege http://tizen.org/privilege/imemanager + * + * @return An error code + * @param[in] id An application ID + * @exception E_SUCCESS The method is successful. + * @exception E_APP_NOT_INSTALLED The specified ID doesn't match with any of the application ID for the input method installed in the system. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + * @endif + */ + result SetInputMethod(Tizen::App::AppId id); + +private: + // + // This default constructor is intentionally declared as private to implement the Singleton semantic. + // + // @since 2.0 + // + InputMethodManager(void); + + // + // This destructor is intentionally declared as private to implement the Singleton semantic. + // + // @since 2.0 + // + virtual ~InputMethodManager(void); + + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + // @since 2.0 + // + InputMethodManager(const InputMethodManager& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + // @since 2.0 + // + InputMethodManager& operator=(const InputMethodManager& rhs); + +private: + friend class _InputMethodManagerImpl; + + _InputMethodManagerImpl* __pInputMethodManagerImpl; +}; + +}}} // Tizen::Ui::Ime + +#endif // _FUI_IME_INPUT_METHOD_MANAGER_H_ diff --git a/osp-ime.manifest b/osp-ime.manifest new file mode 100644 index 0000000..ae3e6f7 --- /dev/null +++ b/osp-ime.manifest @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/osp-ime.pc.in b/osp-ime.pc.in new file mode 100755 index 0000000..c064287 --- /dev/null +++ b/osp-ime.pc.in @@ -0,0 +1,13 @@ +# Package Information for pkg-config + +prefix=@PREFIX@ +exec_prefix=/usr +libdir=/usr/lib/osp +includedir=/usr/include/osp + +Name: @PC_NAME@ +Description: @PACKAGE_DESCRIPTION@ +Version: @VERSION@ +Requires: @PC_REQUIRED@ +Libs: -L${libdir} @PC_LDFLAGS@ +Cflags: -I${includedir} \ No newline at end of file diff --git a/packaging/osp-ime.spec b/packaging/osp-ime.spec new file mode 100644 index 0000000..e873a18 --- /dev/null +++ b/packaging/osp-ime.spec @@ -0,0 +1,88 @@ +%define debug_package %{nil} +%define __strip /bin/true + +Name: osp-ime +Summary: The IME library of OSP +Version: 1.2.1.0 +Release: 1 +Group: TO_BE/FILLED_IN +License: TO BE FILLED IN +Source0: %{name}-%{version}.tar.gz +BuildRequires: cmake +BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(ecore) +BuildRequires: pkgconfig(elementary) +BuildRequires: pkgconfig(isf) +BuildRequires: pkgconfig(libwbxml2) +BuildRequires: pkgconfig(osp-appfw) +BuildRequires: pkgconfig(pkgmgr) +BuildRequires: osp-appfw-internal-devel +BuildRequires: pkgconfig(osp-uifw) +BuildRequires: osp-uifw-internal-devel +BuildRequires: pkgconfig(libprivilege-control) + +# runtime requires +Requires: osp-appfw +Requires: osp-uifw + +Provides: libosp-ime.so.1 + +Requires(post): /sbin/ldconfig +Requires(postun): /sbin/ldconfig + +%description +The IME library of OSP + +%package devel +Summary: The IME library of OSP (Development) +Group: TO_BE/FILLED_IN +Requires: %{name} = %{version}-%{release} + +%description devel +The IME library of OSP (DEV) + +%package debug +Summary: The IME library of OSP (Development) +Group: TO_BE/FILLED_IN +Requires: %{name} = %{version}-%{release} + +%description debug +The IME library of OSP (DEV) + +%prep +%setup -q + +%build +MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` +%ifarch %{ix86} +CXXFLAGS="$CXXFLAGS -D_OSP_DEBUG_ -D_OSP_X86_ -D_OSP_EMUL_" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DOBS=1 -DFULLVER=%{version} -DMAJORVER=${MAJORVER} -DARCH=x86 +%else +CXXFLAGS="-O2 -g -pipe -Wall -fno-exceptions -Wformat -Wformat-security -Wl,--as-needed -fmessage-length=0 -march=armv7-a -mtune=cortex-a8 -mlittle-endian -mfpu=neon -mfloat-abi=softfp -D__SOFTFP__ -mthumb -Wa,-mimplicit-it=thumb -funwind-tables -D_OSP_DEBUG_ -D_OSP_ARMEL_" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DOBS=1 -DFULLVER=%{version} -DMAJORVER=${MAJORVER} -DARCH=arm +%endif + +# Call make instruction with smp support +make %{?jobs:-j%jobs} + +%install +rm -rf %{buildroot} +mkdir -p %{buildroot}/usr/share/license +cp %{_builddir}/%{name}-%{version}/LICENSE.APLv2.0 %{buildroot}/usr/share/license/%{name} + +%make_install + +%post -p /sbin/ldconfig + +%postun -p /sbin/ldconfig + +%files +%manifest osp-ime.manifest +/usr/share/license/%{name} +%{_libdir}/osp/libosp-ime.so* + +%files devel +%{_includedir}/osp/*.h +%{_libdir}/pkgconfig/osp-ime.pc + +%files debug +%{_libdir}/osp/debug/*.so* + diff --git a/src/FUiImeInputMethod.cpp b/src/FUiImeInputMethod.cpp new file mode 100644 index 0000000..b65f00a --- /dev/null +++ b/src/FUiImeInputMethod.cpp @@ -0,0 +1,147 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 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 FUiImeInputMethod.cpp + * @brief This is the implementation file for the %InputMethod class. + * + * This implementation file contains definition of the %InputMethod class. + */ + +#include + +#include +#include + +#include +#include "FUiIme_InputMethodImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Security; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui { namespace Ime { + +static InputMethod* __pInputMethod = null; + +InputMethod::InputMethod(void) + :__pInputMethodImpl(null) +{ +} + +InputMethod::~InputMethod(void) +{ + __pInputMethod = null; + __pInputMethodImpl = null; +} + +result +InputMethod::Construct(void) +{ + result r = E_SUCCESS; + + __pInputMethodImpl = new(std::nothrow) _InputMethodImpl(); + SysTryReturnResult(NID_UI_IME, __pInputMethodImpl, E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = __pInputMethodImpl->Construct(); + SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "Propagating."); + + return r; + +CATCH: + delete __pInputMethodImpl; + __pInputMethodImpl = null; + + return r; +} + +InputMethod* +InputMethod::GetInstance(void) +{ + result r = E_SUCCESS; + + r = _AccessController::CheckUserPrivilege(_PRV_IME); + 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."); + + if (__pInputMethod == null) + { + __pInputMethod = new(std::nothrow) InputMethod(); + SysTryReturn(NID_UI_IME, __pInputMethod, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pInputMethod->Construct(); + r = ((r == E_SUCCESS) || (r == E_CONNECTION_FAILED) || (r == E_SYSTEM)) ? r : E_SYSTEM; + SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return __pInputMethod; + +CATCH: + delete __pInputMethod; + __pInputMethod = null; + + return null; +} + +void +InputMethod::SetInputMethodProvider(IInputMethodProvider* pProvider) +{ + __pInputMethodImpl->SetInputMethodProvider(pProvider); +} + +void +InputMethod::SetInputMethodListener(IInputMethodListener* pListener) +{ + __pInputMethodImpl->SetInputMethodListener(pListener); +} + +result +InputMethod::DeleteText(int cursorOffset, int length) +{ + return __pInputMethodImpl->DeleteText(cursorOffset, length); +} + +result +InputMethod::NotifyInputPanelState(InputPanelShowState state) +{ + return __pInputMethodImpl->NotifyInputPanelState(state); +} + +result +InputMethod::RequestSurroundingText(int lengthBeforeCursor, int lengthAfterCursor) +{ + return __pInputMethodImpl->RequestSurroundingText(lengthBeforeCursor, lengthAfterCursor); +} + +result +InputMethod::SendCompositeText(const String& text) +{ + return __pInputMethodImpl->SendCompositeText(text); +} + +result +InputMethod::SendKeyEvent(KeyCode code, KeyState state) +{ + return __pInputMethodImpl->SendKeyEvent(code, state); +} + +result +InputMethod::SendText(const String& text) +{ + return __pInputMethodImpl->SendText(text); +} + +}}} // Tizen::Ui::Ime diff --git a/src/FUiImeInputMethodInfo.cpp b/src/FUiImeInputMethodInfo.cpp new file mode 100644 index 0000000..5c6c566 --- /dev/null +++ b/src/FUiImeInputMethodInfo.cpp @@ -0,0 +1,106 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 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 FUiImeInputMethodInfo.cpp + * @brief This is the implementation file for the %InputMethodInfo class. + * + * This implementation file contains definition of the %InputMethodInfo class. + */ + +#include +#include + +#include +#include "FUiIme_InputMethodInfoImpl.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Security; + +namespace Tizen { namespace Ui { namespace Ime { + +InputMethodInfo::InputMethodInfo(void) +{ + __pInputMethodInfoImpl = new(std::nothrow) _InputMethodInfoImpl(); + SysTryReturnVoidResult(NID_UI_IME, __pInputMethodInfoImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); +} + +InputMethodInfo::~InputMethodInfo(void) +{ + delete __pInputMethodInfoImpl; + __pInputMethodInfoImpl = null; +} + +InputMethodInfo::InputMethodInfo(const InputMethodInfo& info) +{ + __pInputMethodInfoImpl = new(std::nothrow) _InputMethodInfoImpl(*(info.__pInputMethodInfoImpl)); + SysTryReturnVoidResult(NID_UI_IME, __pInputMethodInfoImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); +} + +InputMethodInfo& +InputMethodInfo::operator=(const InputMethodInfo& info) +{ + *__pInputMethodInfoImpl = *(info.__pInputMethodInfoImpl); + + return *this; +} + +bool +InputMethodInfo::Equals(const Object& object) const +{ + const InputMethodInfo* pInputMethodInfo = static_cast(&object); + SysTryReturn(NID_UI_IME, pInputMethodInfo, false, E_INVALID_ARG, "Invalid argument(s) is used. The object is not the InputMethodInfo."); + + return __pInputMethodInfoImpl->Equals(*(pInputMethodInfo->__pInputMethodInfoImpl)); +} + +AppId +InputMethodInfo::GetAppId(void) const +{ + result r = E_SUCCESS; + + r = _AccessController::CheckUserPrivilege(_PRV_IMEMANAGER); + SysTryReturn(NID_UI_IME, r == E_SUCCESS, "", E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."); + + return __pInputMethodInfoImpl->GetAppId(); +} + +const IList* +InputMethodInfo::GetLanguageList(void) const +{ + result r = E_SUCCESS; + + r = _AccessController::CheckUserPrivilege(_PRV_IMEMANAGER); + 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."); + + return __pInputMethodInfoImpl->GetLanguageList(); +} + +String +InputMethodInfo::GetName(void) const +{ + result r = E_SUCCESS; + + r = _AccessController::CheckUserPrivilege(_PRV_IMEMANAGER); + SysTryReturn(NID_UI_IME, r == E_SUCCESS, "", E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."); + + return __pInputMethodInfoImpl->GetName(); +} + +}}} // Tizen::Ui::Ime diff --git a/src/FUiImeInputMethodManager.cpp b/src/FUiImeInputMethodManager.cpp new file mode 100644 index 0000000..8ef6706 --- /dev/null +++ b/src/FUiImeInputMethodManager.cpp @@ -0,0 +1,109 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 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 FUiImeInputMethodManager.cpp + * @brief This is the implementation file for the %InputMethodManager class. + * + * This implementation file contains definition of the %InputMethodManager class. + */ + +#include + +#include +#include + +#include +#include "FUiIme_InputMethodManagerImpl.h" + +using namespace Tizen::App; +using namespace Tizen::Base::Collection; +using namespace Tizen::Security; + +namespace Tizen { namespace Ui { namespace Ime { + +static InputMethodManager* __pInputMethodManager = null; + +InputMethodManager::InputMethodManager(void) + :__pInputMethodManagerImpl(null) +{ +} + +InputMethodManager::~InputMethodManager(void) +{ + __pInputMethodManager = null; + __pInputMethodManagerImpl = null; +} + +InputMethodManager* +InputMethodManager::GetInstance(void) +{ + result r = E_SUCCESS; + + r = _AccessController::CheckUserPrivilege(_PRV_IMEMANAGER); + 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."); + + _InputMethodManagerImpl* pImpl = null; + + if (__pInputMethodManager == null) + { + __pInputMethodManager = new(std::nothrow) InputMethodManager(); + SysTryReturn(NID_UI_IME, __pInputMethodManager, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pImpl = new(std::nothrow) _InputMethodManagerImpl(); + SysTryCatch(NID_UI_IME, pImpl, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pImpl->Construct(); + SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pInputMethodManager->__pInputMethodManagerImpl = pImpl; + } + + return __pInputMethodManager; + +CATCH: + delete __pInputMethodManager; + __pInputMethodManager = null; + + delete pImpl; + + return null; +} + +IList* +InputMethodManager::GetInputMethodInfoListN(void) const +{ + result r = E_SUCCESS; + + r = _AccessController::CheckUserPrivilege(_PRV_IMEMANAGER); + 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."); + + return __pInputMethodManagerImpl->GetInputMethodInfoListN(); +} + +result +InputMethodManager::SetInputMethod(AppId id) +{ + result r = E_SUCCESS; + + r = _AccessController::CheckUserPrivilege(_PRV_IMEMANAGER); + SysTryReturnResult(NID_UI_IME, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method."); + + return __pInputMethodManagerImpl->SetInputMethod(id); +} + +}}} // Tizen::Ui::Ime diff --git a/src/FUiIme_EcoreFdHandler.cpp b/src/FUiIme_EcoreFdHandler.cpp new file mode 100644 index 0000000..e3bedad --- /dev/null +++ b/src/FUiIme_EcoreFdHandler.cpp @@ -0,0 +1,163 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 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 FUiIme_EcoreFdHandler.cpp + * @brief This is the implementation file for the %_EcoreFdHandler class. + * + * This implementation file contains definition of the %_EcoreFdHandler class. + */ + +#include + +#include + +#include "FUiIme_EcoreFdHandler.h" + +namespace Tizen { namespace Ui { namespace Ime { + +_EcoreFdHandler* _EcoreFdHandler::__pEcoreFdHandler = null; + +_EcoreFdHandler::_EcoreFdHandler(void) + :__fd(-1) + ,__pHelperAgent(null) + ,__pFdHandler(null) +{ +} + +_EcoreFdHandler::~_EcoreFdHandler(void) +{ + __fd = -1; + __pHelperAgent = null; + + if (__pFdHandler) + { + ecore_main_fd_handler_del(__pFdHandler); + __pFdHandler = null; + } +} + +result +_EcoreFdHandler::Construct(int fd, scim::HelperAgent& helperAgent) +{ + SysTryReturnResult(NID_UI_IME, fd > -1, E_INVALID_ARG, "Invalid argument(s) is used. The fd is not greater than -1."); + + result r = E_SUCCESS; + + __fd = fd; + __pHelperAgent = &helperAgent; + + return r; +} + +_EcoreFdHandler* +_EcoreFdHandler::GetInstance(int fd, scim::HelperAgent& helperAgent) +{ + SysTryReturn(NID_UI_IME, fd > -1, null, E_INVALID_ARG, "Invalid argument(s) is used. The fd is not greater than -1."); + + result r = E_SUCCESS; + + if (__pEcoreFdHandler == null) + { + __pEcoreFdHandler = new(std::nothrow) _EcoreFdHandler(); + SysTryReturn(NID_UI_IME, __pEcoreFdHandler, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pEcoreFdHandler->Construct(fd, helperAgent); + SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + SysTryReturn(NID_UI_IME, (__pEcoreFdHandler->__fd == fd) && (__pEcoreFdHandler->__pHelperAgent == &helperAgent), null, E_INVALID_ARG, + "Invalid argument(s) is used. The instance of the _EcoreFdHandler is already occupied."); + } + + return __pEcoreFdHandler; + +CATCH: + delete __pEcoreFdHandler; + __pEcoreFdHandler = null; + + return null; +} + +result +_EcoreFdHandler::Activate(void) +{ + result r = E_SUCCESS; + + r = Deactivate(); + SysTryReturnResult(NID_UI_IME, r == E_SUCCESS, r, "Propagating."); + + __pFdHandler = ecore_main_fd_handler_add(__fd, ECORE_FD_READ, FdHandler, null, null, null); + SysTryReturnResult(NID_UI_IME, __pFdHandler, E_SYSTEM, "A failure occurs from the underlying system."); + + return r; +} + +result +_EcoreFdHandler::Deactivate(void) +{ + result r = E_SUCCESS; + + if (__pFdHandler) + { + void* data = null; + data = ecore_main_fd_handler_del(__pFdHandler); + SysTryReturnResult(NID_UI_IME, data, E_SYSTEM, "A failure occurs from the underlying system."); + + __pFdHandler = null; + } + + return r; +} + +Eina_Bool +_EcoreFdHandler::FdHandler(void *data, Ecore_Fd_Handler *handler) +{ + if (!__pEcoreFdHandler) + { + return EINA_FALSE; + } + + if (__pEcoreFdHandler->HasPendingEvent()) + { + __pEcoreFdHandler->ProcessEvent(); + } + + return ECORE_CALLBACK_RENEW; +} + +bool +_EcoreFdHandler::HasPendingEvent(void) const +{ + return __pHelperAgent->has_pending_event(); +} + +result +_EcoreFdHandler::ProcessEvent(void) +{ + result r = E_SUCCESS; + + bool connected = false; + + connected = __pHelperAgent->filter_event(); + SysTryReturnResult(NID_UI_IME, connected, E_HOST_NOT_FOUND, "The destination host is not found."); + + return r; +} + +}}} // Tizen::Ui::Ime diff --git a/src/FUiIme_EcoreFdHandler.h b/src/FUiIme_EcoreFdHandler.h new file mode 100644 index 0000000..aca42be --- /dev/null +++ b/src/FUiIme_EcoreFdHandler.h @@ -0,0 +1,82 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 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 FUiIme_EcoreFdHander.h + * @brief This is the header file for the %_EcoreFdHander class. + * + * This header file contains the declarations of the %_EcoreFdHander class. + */ + +#ifndef _FUI_IME_INTERNAL_ECORE_FD_HANDLER_H_ +#define _FUI_IME_INTERNAL_ECORE_FD_HANDLER_H_ + +#include // Ecore_Fd_Handler +#include // Eina_Bool + +#define Uses_SCIM_HELPER +#define Uses_SCIM_TYPES +#undef null +#include +#define null 0 + +#include +#include + +namespace Tizen { namespace Ui { namespace Ime { + +/** +* @class _EcoreFdHander +* @brief This class is a concrete class of the %_EcoreFdHander class. +* @since 2.0 +* +*/ +class _EcoreFdHandler + : public Tizen::Base::Object +{ +public: + static _EcoreFdHandler* GetInstance(int fd, scim::HelperAgent& helperAgent); + + result Activate(void); + result Deactivate(void); + +private: + _EcoreFdHandler(); + virtual ~_EcoreFdHandler(void); + + _EcoreFdHandler(const _EcoreFdHandler& rhs); + _EcoreFdHandler& operator=(const _EcoreFdHandler& rhs); + + result Construct(int fd, scim::HelperAgent& helperAgent); + + static Eina_Bool FdHandler(void *data, Ecore_Fd_Handler *fdHandler); + + bool HasPendingEvent(void) const; + result ProcessEvent(void); + +private: + static _EcoreFdHandler* __pEcoreFdHandler; + + int __fd; + scim::HelperAgent* __pHelperAgent; + + Ecore_Fd_Handler* __pFdHandler; +}; + +}}} // Tizen::Ui::Ime + +#endif // _FUI_IME_INTERNAL_ECORE_FD_HANDLER_H_ diff --git a/src/FUiIme_ImeInfo.cpp b/src/FUiIme_ImeInfo.cpp new file mode 100644 index 0000000..9b45dbd --- /dev/null +++ b/src/FUiIme_ImeInfo.cpp @@ -0,0 +1,102 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 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 FUiIme_ImeInfo.cpp + * @brief This is the implementation file for the %_ImeInfo class. + * + * This implementation file contains definition of the %_ImeInfo class. + */ + +#include + +#include "FUiIme_ImeInfo.h" + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + + void + InitImeInfo(const char* uuid, const char* name, const char* language) + { + result r = E_SUCCESS; + + r = Tizen::Ui::Ime::_ImeInfo::GetInstance()->Construct(uuid, name, language); + SysTryLog(NID_UI_IME, r == E_SUCCESS, "Initializing _ImeInfo has failed."); + } + +#ifdef __cplusplus +} +#endif // __cplusplus + +namespace Tizen { namespace Ui { namespace Ime { + +_ImeInfo::_ImeInfo(void) + :__uuid("") + ,__name("") + ,__language("") +{ + +} + +_ImeInfo::~_ImeInfo(void) +{ + +} + +_ImeInfo* +_ImeInfo::GetInstance(void) +{ + static _ImeInfo imeInfo; + + return &imeInfo; +} + +result +_ImeInfo::Construct(const char* uuid, const char* name, const char* language) +{ + result r = E_SUCCESS; + + __uuid = uuid; + __name = name; + __language = language; + + SysLog(NID_UI_IME, "The _ImeInfo has been constructed. The uuid is %s, the name is %s, and the language is %s.", uuid, name, language); + + return r; +} + +scim::String +_ImeInfo::GetUuid(void) const +{ + return __uuid; +} + +scim::String +_ImeInfo::GetName(void) const +{ + return __name; +} + +scim::String +_ImeInfo::GetLanguage(void) const +{ + return __language; +} + +}}} // Tizen::Ui::Ime diff --git a/src/FUiIme_ImeInfo.h b/src/FUiIme_ImeInfo.h new file mode 100644 index 0000000..ce3cd2a --- /dev/null +++ b/src/FUiIme_ImeInfo.h @@ -0,0 +1,70 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 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 FUiIme_ImeInfo.h + * @brief This is the header file for the %_ImeInfo class. + * + * This header file contains the declarations of the %_ImeInfo class. + */ + +#ifndef _FUI_IME_INTERNAL_IME_INFO_H_ +#define _FUI_IME_INTERNAL_IME_INFO_H_ + +#define Uses_SCIM_TYPES +#undef null +#include +#define null 0 + +#include + +namespace Tizen { namespace Ui { namespace Ime { + +/** +* @class _ImeInfo +* @brief This class is a concrete class of the %_ImeInfo class. +* @since 2.0 +* +*/ +class _ImeInfo +{ +public: + ~_ImeInfo(void); + + static _ImeInfo* GetInstance(void); + + result Construct(const char* uuid, const char* name, const char* language); + + scim::String GetUuid(void) const; + scim::String GetName(void) const; + scim::String GetLanguage(void) const; + +private: + _ImeInfo(void); + + _ImeInfo(const _ImeInfo& rhs); + _ImeInfo& operator=(const _ImeInfo& rhs); + +private: + scim::String __uuid; + scim::String __name; + scim::String __language; +}; + +}}} // Tizen::Ui::Ime + +#endif // _FUI_IME_INTERNAL_IME_INFO_H_ diff --git a/src/FUiIme_InputMethodImpl.cpp b/src/FUiIme_InputMethodImpl.cpp new file mode 100644 index 0000000..1f2b52e --- /dev/null +++ b/src/FUiIme_InputMethodImpl.cpp @@ -0,0 +1,357 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 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 FUiIme_InputMethodImpl.cpp + * @brief This is the implementation file for the %_InputMethodImpl class. + * + * This implementation file contains definition of the %_InputMethodImpl class. + */ + +#include +#include + +#include +#include // ecore_x_icccm_hints_get +#include // elm_win_keyboard_win_set + +#include +#include + +#include "FUi_EcoreEvas.h" +#include "FUi_EcoreEvasMgr.h" + +#include "FUiIme_EcoreFdHandler.h" +#include "FUiIme_ImeInfo.h" +#include "FUiIme_InputMethodImpl.h" +#include "FUiIme_InputServiceSignalListener.h" +#include "FUiIme_ScimDataConverter.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Locales; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui { namespace Ime { + +_InputMethodImpl::_InputMethodImpl(void) + :__pHelperAgent(null) + ,__pEcoreFdHandler(null) + ,__pInputServiceBinder(null) +{ +} + +_InputMethodImpl::~_InputMethodImpl(void) +{ + __pHelperAgent = null; + + if (__pEcoreFdHandler) + { + __pEcoreFdHandler->Deactivate(); + __pEcoreFdHandler = null; + } + + if (__pInputServiceBinder) + { + __pInputServiceBinder->Unbind(); + __pInputServiceBinder = null; + } +} + +result +_InputMethodImpl::Construct(void) +{ + result r = E_SUCCESS; + + __pInputServiceBinder = _InputServiceBinder::GetInstance(); + r = GetLastResult(); + SysTryReturnResult(NID_UI_IME, __pInputServiceBinder, r, "Propagating."); + + BindingId bindingId = -1; + bindingId = __pInputServiceBinder->Bind(); + r = GetLastResult(); + SysTryCatch(NID_UI_IME, bindingId > -1, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pHelperAgent = __pInputServiceBinder->GetHelperAgent(); + + SetInputServiceSignalCallback(); + + r = SetEcoreEvasAttribute(); + SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pEcoreFdHandler = _EcoreFdHandler::GetInstance(bindingId, *__pHelperAgent); + r = GetLastResult(); + SysTryCatch(NID_UI_IME, __pEcoreFdHandler, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pEcoreFdHandler->Activate(); + SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + +CATCH: + __pInputServiceBinder->Unbind(); + __pInputServiceBinder = null; + + __pHelperAgent = null; + + if (__pEcoreFdHandler) + { + __pEcoreFdHandler->Deactivate(); + __pEcoreFdHandler = null; + } + + return r; +} + +_InputMethodImpl* +_InputMethodImpl::GetInstance(InputMethod& inputMethod) +{ + return inputMethod.__pInputMethodImpl; +} + +void +_InputMethodImpl::SetInputMethodProvider(IInputMethodProvider* pProvider) +{ + _InputServiceSignalListener::SetInputMethodProvider(pProvider); +} + +void +_InputMethodImpl::SetInputMethodListener(IInputMethodListener* pListener) +{ + _InputServiceSignalListener::SetInputMethodListener(pListener); +} + +result +_InputMethodImpl::DeleteText(int cursorOffset, int length) +{ + SysTryReturnResult(NID_UI_IME, length > 0, E_INVALID_ARG, "Invalid argument(s) is used. The length is not greater than 0."); + + result r = E_SUCCESS; + + __pHelperAgent->delete_surrounding_text(cursorOffset, length); + + return r; +} + +result +_InputMethodImpl::NotifyInputPanelState(InputPanelShowState state) +{ + SysTryReturnResult(NID_UI_IME, (state == INPUT_PANEL_SHOW_STATE_SHOW) || (state == INPUT_PANEL_SHOW_STATE_HIDE), E_INVALID_ARG, + "Invalid argument(s) is used. The state is beyond the scope."); + + result r = E_SUCCESS; + + Ecore_IMF_Input_Panel_State inputPanelState; + + switch (state) + { + case INPUT_PANEL_SHOW_STATE_SHOW: + inputPanelState = ECORE_IMF_INPUT_PANEL_STATE_SHOW; + break; + case INPUT_PANEL_SHOW_STATE_HIDE: + inputPanelState = ECORE_IMF_INPUT_PANEL_STATE_HIDE; + break; + default: + break; + } + + __pHelperAgent->update_input_context(ECORE_IMF_INPUT_PANEL_STATE_EVENT, inputPanelState); + + return r; +} + +result +_InputMethodImpl::RequestSurroundingText(int lengthBeforeCursor, int lengthAfterCursor) +{ + SysTryReturnResult(NID_UI_IME, (lengthBeforeCursor >= 0) && (lengthAfterCursor >= 0), E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument(s) is used. The length is not greater than or equal to 0."); + + result r = E_SUCCESS; + + _ImeInfo* pImeInfo = _ImeInfo::GetInstance(); + scim::String uuid = pImeInfo->GetUuid(); + + __pHelperAgent->get_surrounding_text(uuid, lengthBeforeCursor, lengthAfterCursor); + + return r; +} + +result +_InputMethodImpl::SendCompositeText(const String& text) +{ + result r = E_SUCCESS; + + scim::WideString compositeText; + r = _ScimDataConverter::ConvertString(text, compositeText); + SysTryReturnResult(NID_UI_IME, r == E_SUCCESS, r, "Propagating."); + + scim::AttributeList attributeList; + __pHelperAgent->update_preedit_string(-1, "", compositeText, attributeList); + + return r; +} + +result +_InputMethodImpl::SendKeyEvent(KeyCode code, KeyState state) +{ + SysTryReturnResult(NID_UI_IME, (code > KEY_INVALID) && (code < KEY_HARDWARE_MAX), E_INVALID_ARG, + "Invalid argument(s) is used. The key code is beyond the scope."); + SysTryReturnResult(NID_UI_IME, (state >= KEY_PRESSED) && (state <= KEY_LONGPRESSED), E_INVALID_ARG, + "Invalid argument(s) is used. The key state is beyond the scope."); + + result r = E_SUCCESS; + + scim::KeyEvent keyEvent; + _ScimDataConverter::ConvertKey(code, state, keyEvent); + __pHelperAgent->forward_key_event(-1, "", keyEvent); + + return r; +} + +result +_InputMethodImpl::SendText(const String& text) +{ + result r = E_SUCCESS; + + scim::String scimText; + r = _ScimDataConverter::ConvertString(text, scimText); + SysTryReturnResult(NID_UI_IME, r == E_SUCCESS, r, "Propagating."); + + scim::WideString wideString = scim::utf8_mbstowcs(scimText); + + __pHelperAgent->commit_string(-1, "", wideString); + + return r; +} + +bool +_InputMethodImpl::HasPendingEvent(void) const +{ + return __pHelperAgent->has_pending_event(); +} + +result +_InputMethodImpl::ProcessPendingEvent(void) +{ + result r = E_SUCCESS; + + bool bound = false; + + bound = __pHelperAgent->filter_event(); + SysTryReturnResult(NID_UI_IME, bound, E_HOST_NOT_FOUND, "The destination host is not found."); + + return r; +} + +result +_InputMethodImpl::SetEcoreEvasAttribute(void) +{ + result r = E_SUCCESS; + + _EcoreEvasMgr* pEcoreEvasMgr = null; + pEcoreEvasMgr = GetEcoreEvasMgr(); + r = GetLastResult(); + SysTryReturnResult(NID_UI_IME, pEcoreEvasMgr, r, "Propagating."); + + _EcoreEvas* pEcoreEvas = null; + pEcoreEvas = pEcoreEvasMgr->GetEcoreEvas(); + r = GetLastResult(); + SysTryReturnResult(NID_UI_IME, pEcoreEvas, r, "Propagating."); + + elm_win_keyboard_win_set(pEcoreEvas->GetWindowObject(), EINA_TRUE); + + Eina_Bool accepts_focus = EINA_TRUE; + Ecore_X_Window_State_Hint initial_state = ECORE_X_WINDOW_STATE_HINT_NONE; + Ecore_X_Pixmap icon_pixmap = 0; + Ecore_X_Pixmap icon_mask = 0; + Ecore_X_Window icon_window = 0; + Ecore_X_Window window_group = 0; + Eina_Bool is_urgent = EINA_FALSE; + + Eina_Bool result = EINA_FALSE; + result = ecore_x_icccm_hints_get(pEcoreEvas->GetXWindow(), &accepts_focus, &initial_state, &icon_pixmap, &icon_mask, &icon_window, &window_group, &is_urgent); + SysTryReturnResult(NID_UI_IME, result == EINA_TRUE, E_SYSTEM, "A failure occurs from the underlying system."); + + ecore_x_icccm_hints_set(pEcoreEvas->GetXWindow(), EINA_FALSE, initial_state, icon_pixmap, icon_mask, icon_window, window_group, is_urgent); + + return r; +} + +void +_InputMethodImpl::SetInputServiceSignalCallback(void) +{ + __pHelperAgent->signal_connect_exit(scim::slot(_InputServiceSignalListener::OnTerminate)); + __pHelperAgent->signal_connect_get_geometry(scim::slot(_InputServiceSignalListener::GetInputPanelBounds)); + __pHelperAgent->signal_connect_ise_hide(scim::slot(_InputServiceSignalListener::HideInputPanel)); + __pHelperAgent->signal_connect_ise_show(scim::slot(_InputServiceSignalListener::ShowInputPanel)); + __pHelperAgent->signal_connect_update_cursor_position(scim::slot(_InputServiceSignalListener::OnCursorPositionChanged)); + __pHelperAgent->signal_connect_update_surrounding_text(scim::slot(_InputServiceSignalListener::OnSurroundingTextReceived)); + __pHelperAgent->signal_connect_set_language(scim::slot(_InputServiceSignalListener::SetLanguage)); + __pHelperAgent->signal_connect_set_return_key_type(scim::slot(_InputServiceSignalListener::SetEnterKeyAction)); + __pHelperAgent->signal_connect_get_return_key_type(scim::slot(_InputServiceSignalListener::GetEnterKeyAction)); + __pHelperAgent->signal_connect_set_return_key_disable(scim::slot(_InputServiceSignalListener::SetEnterKeyActionEnabled)); + __pHelperAgent->signal_connect_get_return_key_disable(scim::slot(_InputServiceSignalListener::IsEnterKeyActionEnabled)); + __pHelperAgent->signal_connect_get_layout(scim::slot(_InputServiceSignalListener::GetInputPanelStyle)); + __pHelperAgent->signal_connect_set_layout(scim::slot(_InputServiceSignalListener::SetInputPanelStyle)); + __pHelperAgent->signal_connect_set_caps_mode(scim::slot(_InputServiceSignalListener::SetCapsModeEnabled)); + + SysLog(NID_UI_IME, "The signal callback functions of the input service have been set"); +} + +void +_InputMethodImpl::HideInputPanel(void) +{ + _EcoreEvasMgr* pEcoreEvasMgr = null; + pEcoreEvasMgr = GetEcoreEvasMgr(); + SysTryReturnVoidResult(NID_UI_IME, pEcoreEvasMgr, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist."); + + _EcoreEvas* pEcoreEvas = null; + pEcoreEvas = pEcoreEvasMgr->GetEcoreEvas(); + SysTryReturnVoidResult(NID_UI_IME, pEcoreEvas, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist."); + + Evas_Object* pEvasObject = null; + pEvasObject = pEcoreEvas->GetWindowObject(); + SysTryReturnVoidResult(NID_UI_IME, pEvasObject, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist."); + + if (evas_object_visible_get(pEvasObject)) + { + evas_object_hide(pEvasObject); + } +} + +void +_InputMethodImpl::ShowInputPanel(void) +{ + _EcoreEvasMgr* pEcoreEvasMgr = null; + pEcoreEvasMgr = GetEcoreEvasMgr(); + SysTryReturnVoidResult(NID_UI_IME, pEcoreEvasMgr, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist."); + + _EcoreEvas* pEcoreEvas = null; + pEcoreEvas = pEcoreEvasMgr->GetEcoreEvas(); + SysTryReturnVoidResult(NID_UI_IME, pEcoreEvas, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist."); + + Evas_Object* pEvasObject = null; + pEvasObject = pEcoreEvas->GetWindowObject(); + SysTryReturnVoidResult(NID_UI_IME, pEvasObject, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist."); + + if (evas_object_visible_get(pEvasObject) == false) + { + evas_object_show(pEvasObject); + } +} + +}}} // Tizen::Ui::Ime diff --git a/src/FUiIme_InputMethodImpl.h b/src/FUiIme_InputMethodImpl.h new file mode 100644 index 0000000..4365616 --- /dev/null +++ b/src/FUiIme_InputMethodImpl.h @@ -0,0 +1,103 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 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 FUiIme_InputMethodImpl.h + * @brief This is the header file for the %_InputMethodImpl class. + * + * This header file contains the declarations of the %_InputMethodImpl class. + */ + +#ifndef _FUI_IME_INTERNAL_INPUT_METHOD_IMPL_H_ +#define _FUI_IME_INTERNAL_INPUT_METHOD_IMPL_H_ + +#include // Ecore_Fd_Handler +#include // Eina_Bool + +#define Uses_SCIM_HELPER +#define Uses_SCIM_TYPES +#undef null +#include +#define null 0 + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "FUiIme_InputServiceBinder.h" + +namespace Tizen { namespace Ui { namespace Ime { + +class _EcoreFdHandler; + +/** +* @class _InputMethodImpl +* @brief This class is a concrete class of the %_InputMethodImpl class. +* @since 2.0 +* +*/ +class _InputMethodImpl + : public Tizen::Base::Object +{ +public: + static _InputMethodImpl* GetInstance(InputMethod& inputMethod); + + void SetInputMethodProvider(IInputMethodProvider* pProvider); + void SetInputMethodListener(IInputMethodListener* pListener); + + result DeleteText(int cursorOffset, int length); + result NotifyInputPanelState(Tizen::Ui::InputPanelShowState state); + result RequestSurroundingText(int lengthBeforeCursor, int lengthAfterCursor); + result SendCompositeText(const Tizen::Base::String& text); + result SendKeyEvent(Tizen::Ui::KeyCode code, Tizen::Ui::KeyState state); + result SendText(const Tizen::Base::String& text); + +private: + _InputMethodImpl(void); + virtual ~_InputMethodImpl(void); + + _InputMethodImpl(const _InputMethodImpl& rhs); + _InputMethodImpl& operator=(const _InputMethodImpl& rhs); + + result Construct(void); + + bool HasPendingEvent(void) const; + result ProcessPendingEvent(void); + result SetEcoreEvasAttribute(void); + void SetInputServiceSignalCallback(void); + + void HideInputPanel(void); + void ShowInputPanel(void); + +private: + friend class InputMethod; + + scim::HelperAgent* __pHelperAgent; + + _EcoreFdHandler* __pEcoreFdHandler; + _InputServiceBinder* __pInputServiceBinder; +}; + +}}} // Tizen::Ui::Ime + +#endif // _FUI_IME_INTERNAL_INPUT_METHOD_IMPL_H_ diff --git a/src/FUiIme_InputMethodInfoImpl.cpp b/src/FUiIme_InputMethodInfoImpl.cpp new file mode 100644 index 0000000..37120ff --- /dev/null +++ b/src/FUiIme_InputMethodInfoImpl.cpp @@ -0,0 +1,275 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 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 FUiIme_InputMethodInfoImpl.cpp + * @brief This is the implementation file for the %_InputMethodInfoImpl class. + * + * This implementation file contains definition of the %_InputMethodInfoImpl class. + */ + +#include +#include +#include + +#include +#include + +#include + +#include "FUiIme_InputMethodInfoImpl.h" +#include "FUiIme_ScimDataConverter.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Locales; + +namespace Tizen { namespace Ui { namespace Ime { + +_InputMethodInfoImpl::_InputMethodInfoImpl(void) + :__pUuid(null) +{ + result r = E_SUCCESS; + + std::unique_ptr pLanguageList(new(std::nothrow) ArrayList(SingleObjectDeleter)); + SysTryReturnVoidResult(NID_UI_IME, pLanguageList, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pLanguageList->Construct(); + SysTryReturnVoidResult(NID_UI_IME, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pLanguageList = pLanguageList.release(); +} + +_InputMethodInfoImpl::_InputMethodInfoImpl(const _InputMethodInfoImpl& impl) +{ + result r = E_SUCCESS; + + __appId = impl.__appId; + __name = impl.__name; + + std::unique_ptr pLanguageList(new(std::nothrow) ArrayList(SingleObjectDeleter)); + SysTryReturnVoidResult(NID_UI_IME, pLanguageList, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pLanguageList->Construct(); + SysTryReturnVoidResult(NID_UI_IME, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pLanguageList = pLanguageList.release(); + + r = SetLanguageList(*(impl.__pLanguageList)); + SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pUuid = _StringConverter::CopyToCharArrayN(impl.__uuid); + + return; + +CATCH: + delete __pLanguageList; + __pLanguageList = null; + + return; +} + +_InputMethodInfoImpl::~_InputMethodInfoImpl(void) +{ + delete __pLanguageList; + __pLanguageList = null; + + delete[] __pUuid; + __pUuid = null; +} + +_InputMethodInfoImpl* +_InputMethodInfoImpl::GetInstance(InputMethodInfo& inputMethodInfo) +{ + return inputMethodInfo.__pInputMethodInfoImpl; +} + +_InputMethodInfoImpl& +_InputMethodInfoImpl::operator=(const _InputMethodInfoImpl& impl) +{ + result r = E_SUCCESS; + + if (&impl != this) + { + __appId = impl.__appId; + __name = impl.__name; + + r = SetLanguageList(*(impl.__pLanguageList)); + SysTryReturn(NID_UI_IME, r == E_SUCCESS, *this, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__pUuid) + { + delete[] __pUuid; + } + __pUuid = _StringConverter::CopyToCharArrayN(impl.__uuid); + } + + return *this; +} + +bool +_InputMethodInfoImpl::Equals(const Object& object) const +{ + const _InputMethodInfoImpl* pInputMethodInfoImpl = static_cast(&object); + SysTryReturn(NID_UI_IME, pInputMethodInfoImpl, false, E_INVALID_ARG, "Invalid argument(s) is used. The object is not the _InputMethodInfoImpl."); + + return __appId.Equals(pInputMethodInfoImpl->__appId, true); +} + +AppId +_InputMethodInfoImpl::GetAppId(void) const +{ + return __appId; +} + +const IList* +_InputMethodInfoImpl::GetLanguageList(void) const +{ + return __pLanguageList; +} + +String +_InputMethodInfoImpl::GetName(void) const +{ + return __name; +} + +const char* +_InputMethodInfoImpl::GetUuid(void) const +{ + return __pUuid; +} + +void +_InputMethodInfoImpl::SetAppId(AppId id) +{ + __appId = id; +} + +void +_InputMethodInfoImpl::SetUuid(String id) +{ + __uuid = id; + + if (__pUuid) + { + delete[] __pUuid; + } + __pUuid = _StringConverter::CopyToCharArrayN(id); +} + +result +_InputMethodInfoImpl::SetLanguageList(const IList& list) +{ + result r = E_SUCCESS; + + __pLanguageList->RemoveAll(); + + const ArrayList* pLanguageList = static_cast(&list); + int languageCount = pLanguageList->GetCount(); + + r = __pLanguageList->SetCapacity(languageCount); + SysTryReturnResult(NID_UI_IME, r == E_SUCCESS, r, "Propagating."); + + Locale* pDestLanguage = null; + for (int i = 0; i < languageCount; i++) + { + const Locale* pLanguage = static_cast(pLanguageList->GetAt(i)); + r = GetLastResult(); + SysTryCatch(NID_UI_IME, pLanguage, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pDestLanguage = new(std::nothrow) Locale(*pLanguage); + SysTryCatch(NID_UI_IME, pDestLanguage, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pLanguageList->Add(pDestLanguage); + SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return r; + +CATCH: + __pLanguageList->RemoveAll(); + + delete pDestLanguage; + + return r; +} + +void +_InputMethodInfoImpl::SetName(const String& name) +{ + __name = name; +} + +void +_InputMethodInfoImpl::SetName(const scim::String& name) +{ + _ScimDataConverter::ConvertString(name, __name); +} + +result +_InputMethodInfoImpl::AddLanguage(const char* language) +{ + result r = E_SUCCESS; + + // verify the input parameter + const int _ISO_639_2_LENGTH = 6; + const int _ISO_639_2_LANGUAGE_CODE_LENGTH = 3; + const int _COUNTRY_CODE_LENGTH = 2; + + int length = strlen(language); + SysTryReturnResult(NID_UI_IME, (length == _ISO_639_2_LENGTH), E_INVALID_ARG, + "Invalid argument(s) is used. The language is not a type of ISO 639-2 and is %s.", language); + + LanguageCode languageCode = LANGUAGE_INVALID; + CountryCode countryCode = COUNTRY_INVALID; + + // LanguageCode + char srcLanguage[_ISO_639_2_LANGUAGE_CODE_LENGTH + 1]; + strncpy(srcLanguage, language, _ISO_639_2_LANGUAGE_CODE_LENGTH); + srcLanguage[_ISO_639_2_LANGUAGE_CODE_LENGTH] = '\0'; + + languageCode = Locale::StringToLanguageCode(srcLanguage); + SysTryReturnResult(NID_UI_IME, languageCode != LANGUAGE_INVALID, E_INVALID_ARG, + "Invalid argument(s) is used. The srcLanguage is %s.", srcLanguage); + + // CountryCode + char srcCountry[_COUNTRY_CODE_LENGTH + 1]; + strncpy(srcCountry, language + _ISO_639_2_LANGUAGE_CODE_LENGTH + 1, _COUNTRY_CODE_LENGTH); + srcCountry[_COUNTRY_CODE_LENGTH] = '\0'; + + countryCode = Locale::StringToCountryCode(srcCountry); + SysTryReturnResult(NID_UI_IME, countryCode != COUNTRY_INVALID, E_INVALID_ARG, + "Invalid argument(s) is used. The srcCountry is %s.", srcCountry); + + // add the language + Locale* pLanguage = new(std::nothrow) Locale(languageCode, countryCode); + SysTryReturnResult(NID_UI_IME, pLanguage, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pLanguageList->Add(pLanguage); + SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + +CATCH: + delete pLanguage; + + return r; +} + +}}} // Tizen::Ui::Ime diff --git a/src/FUiIme_InputMethodInfoImpl.h b/src/FUiIme_InputMethodInfoImpl.h new file mode 100644 index 0000000..1a461ed --- /dev/null +++ b/src/FUiIme_InputMethodInfoImpl.h @@ -0,0 +1,91 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 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 FUiIme_InputMethodInfoImpl.h + * @brief This is the header file for the %_InputMethodInfoImpl class. + * + * This header file contains the declarations of the %_InputMethodInfoImpl class. + */ + +#ifndef _FUI_IME_INTERNAL_INPUT_METHOD_INFO_IMPL_H_ +#define _FUI_IME_INTERNAL_INPUT_METHOD_INFO_IMPL_H_ + +#define Uses_SCIM_TYPES +#undef null +#include +#define null 0 + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Ime { + +/** +* @class _InputMethodInfoImpl +* @brief This class is a concrete class of the %_InputMethodInfoImpl class. +* @since 2.0 +* +*/ +class _InputMethodInfoImpl + : public Tizen::Base::Object +{ +public: + static _InputMethodInfoImpl* GetInstance(InputMethodInfo& inputMethodInfo); + + _InputMethodInfoImpl& operator=(const _InputMethodInfoImpl& impl); + virtual bool Equals(const Object& object) const; + + Tizen::App::AppId GetAppId(void) const; + const Tizen::Base::Collection::IList* GetLanguageList(void) const; + Tizen::Base::String GetName(void) const; + const char* GetUuid(void) const; + + void SetAppId(Tizen::App::AppId id); + void SetUuid(Tizen::Base::String id); + result SetLanguageList(const Tizen::Base::Collection::IList& list); + void SetName(const Tizen::Base::String& name); + void SetName(const scim::String& name); + + result AddLanguage(const char* language); + +private: + _InputMethodInfoImpl(void); + _InputMethodInfoImpl(const _InputMethodInfoImpl& impl); + virtual ~_InputMethodInfoImpl(void); + +private: + friend class InputMethodInfo; + + Tizen::App::AppId __appId; + Tizen::Base::String __uuid; + Tizen::Base::String __name; + + Tizen::Base::Collection::ArrayList* __pLanguageList; + + char* __pUuid; +}; + +}}} // Tizen::Ui::Ime + +#endif // _FUI_IME_INTERNAL_INPUT_METHOD_INFO_IMPL_H_ diff --git a/src/FUiIme_InputMethodManagerImpl.cpp b/src/FUiIme_InputMethodManagerImpl.cpp new file mode 100644 index 0000000..e0f57c6 --- /dev/null +++ b/src/FUiIme_InputMethodManagerImpl.cpp @@ -0,0 +1,572 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 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 FUiIme_InputMethodManagerImpl.cpp + * @brief This is the implementation file for the %_InputMethodManagerImpl class. + * + * This implementation file contains definition of the %_InputMethodManagerImpl class. + */ + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "FUiIme_InputMethodInfoImpl.h" +#include "FUiIme_InputMethodManagerImpl.h" + +using namespace Tizen::App; +using namespace Tizen::App::Package; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Locales; + +static const AppId PRELOADED_IME_APPID = "sja4pgHCvq.Tizen"; +static const char* PRELOADED_IME_UUID = "12aa3425-f88d-45f4-a509-cee8dfe904e3"; + +namespace Tizen { namespace Ui { namespace Ime { + +_InputMethodManagerImpl::_InputMethodManagerImpl(void) + :__pInputMethodAppIdList(null) +{ +} + +_InputMethodManagerImpl::~_InputMethodManagerImpl(void) +{ + delete __pInputMethodAppIdList; + __pInputMethodAppIdList = null; +} + +result +_InputMethodManagerImpl::Construct(void) +{ + result r = E_SUCCESS; + + std::unique_ptr pInputMethodAppIdList(new(std::nothrow) ArrayList(SingleObjectDeleter)); + SysTryReturnResult(NID_UI_IME, pInputMethodAppIdList, E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = pInputMethodAppIdList->Construct(); + SysTryReturnResult(NID_UI_IME, r == E_SUCCESS, r, "Propagating."); + + __pInputMethodAppIdList = pInputMethodAppIdList.release(); + + return r; +} + +_InputMethodManagerImpl* +_InputMethodManagerImpl::GetInstance(InputMethodManager& inputMethodManager) +{ + return inputMethodManager.__pInputMethodManagerImpl; +} + +InputMethodInfo* +_InputMethodManagerImpl::GetInputMethodInfoN(const char* pAppRootPath) +{ + SysLog(NID_UI_IME, "The root path of the application is %s.", pAppRootPath); + + result r = E_SUCCESS; + + // declare variables + xmlDocPtr pXmlDoc = null; + xmlNodePtr pXmlRootElement = null; + + // get the manifest file path + const char* _MANIFEST_FILE_PATH = "/info/manifest.xml"; + + int length = strlen(pAppRootPath) + strlen(_MANIFEST_FILE_PATH) + 1; + char manifestFilePath[length]; + memset(manifestFilePath, '\0', length); + + strncpy(manifestFilePath, pAppRootPath, strlen(pAppRootPath)); + strcat(manifestFilePath, _MANIFEST_FILE_PATH); + + // get InputMethodInfo + std::unique_ptr pInputMethodInfo(new(std::nothrow) InputMethodInfo()); + SysTryReturn(NID_UI_IME, pInputMethodInfo, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pXmlDoc = xmlParseFile(manifestFilePath); + SysTryReturn(NID_UI_IME, pXmlDoc, null, E_SYSTEM, "[E_SYSTEM] A failure occurs from the underlying system."); + + pXmlRootElement = xmlDocGetRootElement(pXmlDoc); + SysTryCatch(NID_UI_IME, pXmlRootElement, , E_SYSTEM, "[E_SYSTEM] A failure occurs from the underlying system."); + + r = ParseInputMethodInfo(pXmlRootElement, pInputMethodInfo.get()); + SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + if (pXmlDoc) + { + xmlFreeDoc(pXmlDoc); + pXmlDoc = null; + } + + xmlCleanupParser(); + + return pInputMethodInfo.release(); + +CATCH: + if (pXmlDoc) + { + xmlFreeDoc(pXmlDoc); + pXmlDoc = null; + } + + xmlCleanupParser(); + + return null; +} + +result +_InputMethodManagerImpl::ParseInputMethodInfo(const xmlNodePtr pXmlRootElement, InputMethodInfo* pInfo) +{ + SysTryReturnResult(NID_UI_IME, pXmlRootElement && pInfo, E_INVALID_ARG, "Invalid argument(s) is used. The pXmlRootElement or the pInfo is null."); + + result r = E_SUCCESS; + + _InputMethodInfoImpl* pInputMethodInfoImpl = _InputMethodInfoImpl::GetInstance(*pInfo); + + xmlNodePtr pItorNode = null; + + for (pItorNode = pXmlRootElement; pItorNode != null; pItorNode = pItorNode->next) + { + if (pItorNode->type == XML_ELEMENT_NODE) + { + if (!xmlStrcmp(pItorNode->name, reinterpret_cast("Id"))) + { + xmlChar* pXmlChar = xmlNodeGetContent(pItorNode); + if (pXmlChar) + { + pInputMethodInfoImpl->SetAppId(reinterpret_cast(pXmlChar)); + SysLog(NID_UI_IME, "The package ID is %s.", reinterpret_cast(pXmlChar)); + xmlFree(pXmlChar); + } + } + else if (!xmlStrcmp(pItorNode->name, reinterpret_cast("Uuid"))) + { + xmlChar* pXmlChar = xmlNodeGetContent(pItorNode); + if (pXmlChar) + { + pInputMethodInfoImpl->SetUuid(reinterpret_cast(pXmlChar)); + SysLog(NID_UI_IME, "The UUID is %s.", reinterpret_cast(pXmlChar)); + xmlFree(pXmlChar); + } + } + else if (!xmlStrcmp(pItorNode->name, reinterpret_cast("DisplayName"))) + { + xmlChar* pXmlChar = xmlNodeGetContent(pItorNode); + if (pXmlChar) + { + AppId appId = pInputMethodInfoImpl->GetAppId(); + appId += String("."); + appId += String(reinterpret_cast(pXmlChar)); + pInputMethodInfoImpl->SetAppId(appId); + + pInputMethodInfoImpl->SetName(String(reinterpret_cast(pXmlChar))); + SysLog(NID_UI_IME, "The name is %s.", reinterpret_cast(pXmlChar)); + xmlFree(pXmlChar); + } + } + else if (!xmlStrcmp(pItorNode->name, reinterpret_cast("Language"))) + { + xmlChar* pXmlChar = xmlNodeGetContent(pItorNode); + if (pXmlChar) + { + pInputMethodInfoImpl->AddLanguage(reinterpret_cast(pXmlChar)); + SysLog(NID_UI_IME, "The language is %s.", reinterpret_cast(pXmlChar)); + xmlFree(pXmlChar); + } + } + + if (pItorNode->children) + { + ParseInputMethodInfo(pItorNode->children, pInfo); + } + } + } + + return r; +} + +int +_InputMethodManagerImpl::PackageManagerAppIdHandler(pkgmgrinfo_appinfo_h handle, void* pUserData) +{ + result r = E_SUCCESS; + + char* appId = NULL; + pkgmgrinfo_appinfo_get_appid(handle, &appId); + + _InputMethodManagerImpl* pImpl = null; + ArrayList* pInputMethodAppIdList = null; + + AppId* pAppId = new(std::nothrow) AppId(appId); + SysTryReturn(NID_UI_IME, pAppId, 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + InputMethodManager* pInputMethodManager = InputMethodManager::GetInstance(); + r = GetLastResult(); + SysTryCatch(NID_UI_IME, pInputMethodManager, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pImpl = pInputMethodManager->__pInputMethodManagerImpl; + + pInputMethodAppIdList = static_cast(pImpl->GetInputMethodAppIdList()); + r = pInputMethodAppIdList->Add(pAppId); + SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SysLog(NID_UI_IME, "The application ID of the input method installed in the system is %s.", appId); + + return 0; + +CATCH: + delete pAppId; + + return 0; +} + +InputMethodInfo* +_InputMethodManagerImpl::GetCurrentInputMethodInfoN(void) const +{ + result r = E_SUCCESS; + + char* pUuid = null; + int length = scim::isf_control_get_active_ise(&pUuid); + SysTryReturn(NID_UI_IME, (length != -1) && pUuid, null, E_SYSTEM, + "[E_SYSTEM] A failure occurs from the underlying system. The uuid length of the current input method is %d", length); + + InputMethodInfo* pCurrentInputMethodInfo = null; + + std::unique_ptr pInputMethodInfoList(null); + std::unique_ptr pItor(null); + + pInputMethodInfoList.reset(GetInputMethodInfoListN()); + r = GetLastResult(); + SysTryCatch(NID_UI_IME, pInputMethodInfoList, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pItor.reset(pInputMethodInfoList->GetBidirectionalEnumeratorN()); + r = GetLastResult(); + SysTryCatch(NID_UI_IME, pItor, , r, "[%s] Propagating.", GetErrorMessage(r)); + + while (pItor->MoveNext() != E_OUT_OF_RANGE) + { + InputMethodInfo* pInputMethodInfo = static_cast(pItor->GetCurrent()); + r = GetLastResult(); + SysTryCatch(NID_UI_IME, pInputMethodInfo, , r, "[%s] Propagating.", GetErrorMessage(r)); + + _InputMethodInfoImpl* pInputMethodInfoImpl = _InputMethodInfoImpl::GetInstance(*pInputMethodInfo); + r = GetLastResult(); + SysTryCatch(NID_UI_IME, pInputMethodInfoImpl, , r, "[%s] Propagating.", GetErrorMessage(r)); + + if (strcmp(pInputMethodInfoImpl->GetUuid(), pUuid) == 0) + { + pCurrentInputMethodInfo = new(std::nothrow) InputMethodInfo(); + SysTryCatch(NID_UI_IME, pCurrentInputMethodInfo, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + _InputMethodInfoImpl* pCurrentInputMethodInfoImpl = _InputMethodInfoImpl::GetInstance(*pCurrentInputMethodInfo); + r = GetLastResult(); + SysTryCatch(NID_UI_IME, pCurrentInputMethodInfoImpl, , r, "[%s] Propagating.", GetErrorMessage(r)); + + *pCurrentInputMethodInfoImpl = *pInputMethodInfoImpl; + break; + } + } + + free(pUuid); + + return pCurrentInputMethodInfo; + +CATCH: + free(pUuid); + + delete pCurrentInputMethodInfo; + + return null; +} + +IList* +_InputMethodManagerImpl::GetInputMethodAppIdList(void) const +{ + return __pInputMethodAppIdList; +} + +IList* +_InputMethodManagerImpl::GetInputMethodInfoListN(void) const +{ + result r = E_SUCCESS; + + int ospImeCount = 0; + + InputMethodInfo* pInputMethodInfo = null; + _InputMethodInfoImpl* pInputMethodInfoImpl = null; + + std::unique_ptr pLanguageList(null); + + std::unique_ptr pInputMethodInfoList(new(std::nothrow) ArrayList(SingleObjectDeleter)); + SysTryReturn(NID_UI_IME, pInputMethodInfoList, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pInputMethodInfoList->Construct(); + SysTryReturn(NID_UI_IME, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + char* pAppRootPath = null; + + // get preloaded IME info + char** dpList = null; + int preloadedImeCount = scim::isf_control_get_ise_list(&dpList); + SysTryReturn(NID_UI_IME, (dpList != null) && (preloadedImeCount > 0), null, E_SYSTEM, "[E_SYSTEM] A failure occurs from the underlying system."); + + int ret = -1; + char* pName = null; + char* pLanguage = null; + scim::ISE_TYPE_T type; + int option = 0; + + int preloadedImeIndex = -1; + + for (int i = 0; i < preloadedImeCount; i++) + { + if (!strcmp(dpList[i], PRELOADED_IME_UUID)) + { + ret = scim::isf_control_get_ise_info(dpList[i], &pName, &pLanguage, type, option); + SysTryCatch(NID_UI_IME, ret == 0, , E_SYSTEM, "[E_SYSTEM] A failure occurs from the underlying system."); + + preloadedImeCount = 1; + preloadedImeIndex = i; + break; + } + } + + // get osp IME info + r = RequestInputMethodAppIdList(); + SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + // add preloaded IME info + pInputMethodInfo = new(std::nothrow) InputMethodInfo(); + SysTryCatch(NID_UI_IME, pInputMethodInfo, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pInputMethodInfoImpl = _InputMethodInfoImpl::GetInstance(*pInputMethodInfo); + r = GetLastResult(); + SysTryCatch(NID_UI_IME, pInputMethodInfoImpl, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pInputMethodInfoImpl->SetAppId(PRELOADED_IME_APPID); + pInputMethodInfoImpl->SetUuid(dpList[preloadedImeIndex]); + pInputMethodInfoImpl->SetName(String(pName)); + pLanguageList.reset(GetInputMethodLanguageListN(pLanguage)); + r = GetLastResult(); + SysTryCatch(NID_UI_IME, pLanguageList, , r, "[%s] Propagating.", GetErrorMessage(r)); + r = pInputMethodInfoImpl->SetLanguageList(*(pLanguageList.get())); + SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SysLog(NID_UI_IME, "The UUID of the preloaded IME application is %s.", dpList[preloadedImeIndex]); + + r = pInputMethodInfoList->Add(pInputMethodInfo); + SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + pInputMethodInfo = null; + + free(dpList); + free(pName); + free(pLanguage); + + // add osp IME info + ospImeCount = __pInputMethodAppIdList->GetCount(); + + for (int i = 0; i < ospImeCount; i++) + { + AppId* pAppId = static_cast(__pInputMethodAppIdList->GetAt(i)); + r = GetLastResult(); + SysTryCatch(NID_UI_IME, pAppId, , r, "[%s] Propagating.", GetErrorMessage(r)); + + String appRootPath; + r = _AppManagerImpl::GetAppRootPath(*pAppId, appRootPath); + SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pAppRootPath = _StringConverter::CopyToCharArrayN(appRootPath.GetPointer()); + r = GetLastResult(); + SysTryCatch(NID_UI_IME, pAppRootPath, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pInputMethodInfo = GetInputMethodInfoN(pAppRootPath); + r = GetLastResult(); + SysTryCatch(NID_UI_IME, pInputMethodInfo, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pInputMethodInfoList->Add(pInputMethodInfo); + SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + delete[] pAppRootPath; + } + + return pInputMethodInfoList.release(); + +CATCH: + free(dpList); + free(pName); + free(pLanguage); + + delete pInputMethodInfo; + delete[] pAppRootPath; + + return null; +} + +result +_InputMethodManagerImpl::SetInputMethod(AppId id) +{ + result r = E_SUCCESS; + + std::unique_ptr pLog(_StringConverter::CopyToCharArrayN(id.GetPointer())); + SysLog(NID_UI_IME, "The application ID is %s.", pLog.get()); + + if (id == PRELOADED_IME_APPID) + { + char** dpList = null; + int preloadedImeCount = scim::isf_control_get_ise_list(&dpList); + SysTryReturnResult(NID_UI_IME, (dpList != null) && (preloadedImeCount > 0), E_SYSTEM, "A failure occurs from the underlying system."); + + for (int i = 0; i < preloadedImeCount; i++) + { + if (!strcmp(dpList[i], PRELOADED_IME_UUID)) + { + scim::isf_control_set_active_ise_by_uuid(dpList[i]); + break; + } + } + + free(dpList); + + return r; + } + + String appRootPath; + r = _AppManagerImpl::GetAppRootPath(id, appRootPath); + SysTryReturnResult(NID_UI_IME, r == E_SUCCESS, r, "Propagating."); + + std::unique_ptr pAppRootPath(_StringConverter::CopyToCharArrayN(appRootPath.GetPointer())); + r = GetLastResult(); + SysTryReturnResult(NID_UI_IME, pAppRootPath, r, "Propagating."); + + std::unique_ptr pInputMethodInfo(GetInputMethodInfoN(pAppRootPath.get())); + r = GetLastResult(); + SysTryReturnResult(NID_UI_IME, pInputMethodInfo, r, "Propagating."); + + _InputMethodInfoImpl* pInputMethodInfoImpl = _InputMethodInfoImpl::GetInstance(*(pInputMethodInfo.get())); + scim::isf_control_set_active_ise_by_uuid(pInputMethodInfoImpl->GetUuid()); + + return r; +} + +IList* +_InputMethodManagerImpl::GetInputMethodLanguageListN(const char* pLanguageList) const +{ + SysTryReturn(NID_UI_IME, pLanguageList, null, E_INVALID_ARG, "Invalid argument(s) is used. The pLanguageList is null."); + + result r = E_SUCCESS; + + const char* pItor = pLanguageList; + + const int _ISO_639_1_CODE_LENGTH = 5; + char arrayLanguage[_ISO_639_1_CODE_LENGTH + 1]; + memset(arrayLanguage, '\0', sizeof(arrayLanguage)); + + const int _LANGUAGE_CODE_LENGTH = 2; + char arrayLanguageCode[_LANGUAGE_CODE_LENGTH + 1]; + memset(arrayLanguageCode, '\0', sizeof(arrayLanguageCode)); + + const int _COUNTRY_CODE_LENGTH = 2; + char arrayCountryCode[_COUNTRY_CODE_LENGTH + 1]; + memset(arrayCountryCode, '\0', sizeof(arrayCountryCode)); + + Locale* pLanguage = null; + + std::unique_ptr pInputMethodLanguageList(new(std::nothrow) ArrayList(SingleObjectDeleter)); + SysTryReturn(NID_UI_IME, pInputMethodLanguageList, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pInputMethodLanguageList->Construct(); + SysTryReturn(NID_UI_IME, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + while ( pItor != null) + { + strncpy(arrayLanguage, pItor, _ISO_639_1_CODE_LENGTH); + + strncpy(arrayLanguageCode, arrayLanguage, _LANGUAGE_CODE_LENGTH); + strncpy(arrayCountryCode, arrayLanguage + _LANGUAGE_CODE_LENGTH + 1, _COUNTRY_CODE_LENGTH); + + LanguageCode languageCode = Locale::TwoLetterLanguageCodeStringToLanguageCode(String(arrayLanguageCode)); + r = GetLastResult(); + SysTryReturn(NID_UI_IME, languageCode < LANGUAGE_MAX, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + CountryCode countryCode = Locale::StringToCountryCode(String(arrayCountryCode)); + r = GetLastResult(); + SysTryReturn(NID_UI_IME, countryCode < COUNTRY_MAX, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + pLanguage = new(std::nothrow) Locale(languageCode, countryCode); + SysTryReturn(NID_UI_IME, pLanguage, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pInputMethodLanguageList->Add(pLanguage); + SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + memset(arrayLanguage, '\0', sizeof(arrayLanguage)); + memset(arrayLanguageCode, '\0', sizeof(arrayLanguageCode)); + memset(arrayCountryCode, '\0', sizeof(arrayCountryCode)); + + int ch = ','; + pItor = strchr(pItor, ch); + if (pItor) + { + pItor++; + } + } + + return pInputMethodLanguageList.release(); + +CATCH: + delete pLanguage; + + return null; +} + +result +_InputMethodManagerImpl::RequestInputMethodAppIdList(void) const +{ + result r = E_SUCCESS; + + __pInputMethodAppIdList->RemoveAll(); + + int ret = 0; + pkgmgrinfo_appinfo_filter_h handle; + ret = pkgmgrinfo_appinfo_filter_create(&handle); + SysTryReturnResult(NID_UI_IME, ret == PMINFO_R_OK, E_SYSTEM, "A failure occurs from the underlying system."); + + ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_CATEGORY, "http://tizen.org/category/ime"); + SysTryCatch(NID_UI_IME, ret == PMINFO_R_OK, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A failure occurs from the underlying system."); + + ret = pkgmgrinfo_appinfo_filter_foreach_appinfo(handle, PackageManagerAppIdHandler, NULL); + SysTryCatch(NID_UI_IME, ret == PMINFO_R_OK, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A failure occurs from the underlying system."); + + // Fall through +CATCH: + pkgmgrinfo_appinfo_filter_destroy(handle); + + return r; +} + +}}} // Tizen::Ui::Ime diff --git a/src/FUiIme_InputMethodManagerImpl.h b/src/FUiIme_InputMethodManagerImpl.h new file mode 100644 index 0000000..c47f72f --- /dev/null +++ b/src/FUiIme_InputMethodManagerImpl.h @@ -0,0 +1,88 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 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 FUiIme_InputMethodManagerImpl.h + * @brief This is the header file for the %_InputMethodManagerImpl class. + * + * This header file contains the declarations of the %_InputMethodManagerImpl class. + */ + +#ifndef _FUI_IME_INTERNAL_INPUT_METHOD_MANAGER_IMPL_H_ +#define _FUI_IME_INTERNAL_INPUT_METHOD_MANAGER_IMPL_H_ + +#include +#include + +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Base { namespace Collection { + +class ArrayList; + +}}} // Tizen::Base::Collection + +namespace Tizen { namespace Ui { namespace Ime { + +/** +* @class _InputMethodManagerImpl +* @brief This class is a concrete class of the %_InputMethodManagerImpl class. +* @since 2.0 +* +*/ +class _InputMethodManagerImpl + : public Tizen::Base::Object +{ +public: + static _InputMethodManagerImpl* GetInstance(InputMethodManager& inputMethodManager); + + static InputMethodInfo* GetInputMethodInfoN(const char* pAppRootPath); + static result ParseInputMethodInfo(const xmlNodePtr pXmlRootElement, InputMethodInfo* pInfo); + static int PackageManagerAppIdHandler(pkgmgrinfo_appinfo_h handle, void* pUserData); + + InputMethodInfo* GetCurrentInputMethodInfoN(void) const; + Tizen::Base::Collection::IList* GetInputMethodAppIdList(void) const; + Tizen::Base::Collection::IList* GetInputMethodInfoListN(void) const; + + result SetInputMethod(Tizen::App::AppId id); + +private: + _InputMethodManagerImpl(void); + virtual ~_InputMethodManagerImpl(void); + + _InputMethodManagerImpl(const _InputMethodManagerImpl& rhs); + _InputMethodManagerImpl& operator=(const _InputMethodManagerImpl& rhs); + + result Construct(void); + + Tizen::Base::Collection::IList* GetInputMethodLanguageListN(const char* pLanguageList) const; + result RequestInputMethodAppIdList(void) const; + +private: + friend class InputMethodManager; + + Tizen::Base::Collection::ArrayList* __pInputMethodAppIdList; +}; + +}}} // Tizen::Ui::Ime + +#endif // _FUI_IME_INTERNAL_INPUT_METHOD_MANAGER_IMPL_H_ diff --git a/src/FUiIme_InputServiceBinder.cpp b/src/FUiIme_InputServiceBinder.cpp new file mode 100644 index 0000000..86cd77b --- /dev/null +++ b/src/FUiIme_InputServiceBinder.cpp @@ -0,0 +1,153 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 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 FUiIme_InputServiceBinder.cpp + * @brief This is the implementation file for the %_InputServiceBinder class. + * + * This implementation file contains definition of the %_InputServiceBinder class. + */ + +#include +#include + +#include + +#include "FUiIme_ImeInfo.h" +#include "FUiIme_InputServiceBinder.h" + +using namespace Tizen::Base; + +namespace Tizen { namespace Ui { namespace Ime { + +_InputServiceBinder* _InputServiceBinder::__pInputServiceBinder = null; + +_InputServiceBinder::_InputServiceBinder(void) + :__pHelperAgent(null) +{ +} + +_InputServiceBinder::~_InputServiceBinder(void) +{ + if (IsBound()) + { + Unbind(); + } + + delete __pHelperAgent; + __pHelperAgent = null; +} + +result +_InputServiceBinder::Construct(void) +{ + result r = E_SUCCESS; + + std::unique_ptr pHelperAgent(new(std::nothrow) scim::HelperAgent()); + SysTryReturnResult(NID_UI_IME, pHelperAgent, E_OUT_OF_MEMORY, "Memory allocation failed."); + + __pHelperAgent = pHelperAgent.release(); + + return r; +} + +_InputServiceBinder* +_InputServiceBinder::GetInstance(void) +{ + result r = E_SUCCESS; + + if (!__pInputServiceBinder) + { + __pInputServiceBinder = new(std::nothrow) _InputServiceBinder(); + SysTryReturn(NID_UI_IME, __pInputServiceBinder, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pInputServiceBinder->Construct(); + SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return __pInputServiceBinder; + +CATCH: + delete __pInputServiceBinder; + __pInputServiceBinder = null; + + return null; +} + +scim::HelperAgent* +_InputServiceBinder::GetHelperAgent(void) const +{ + return __pHelperAgent; +} + +BindingId +_InputServiceBinder::Bind(void) +{ + result r = E_SUCCESS; + + int bindingId = -1; + + _ImeInfo* pImeInfo = _ImeInfo::GetInstance(); + + scim::String uuid = pImeInfo->GetUuid(); + scim::String name = pImeInfo->GetName(); + + scim::HelperInfo helperInfo(uuid, name, "", "", + scim::SCIM_HELPER_STAND_ALONE | scim::SCIM_HELPER_NEED_SCREEN_INFO | scim::SCIM_HELPER_AUTO_RESTART); + + if (IsBound()) + { + r = Unbind(); + SysTryReturn(NID_UI_IME, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + bindingId = __pHelperAgent->open_connection(helperInfo, ":0"); + SysTryReturn(NID_UI_IME, bindingId > -1, bindingId, E_CONNECTION_FAILED, "[E_CONNECTION_FAILED] The connection to the specific destination fails."); + + SysLog(NID_UI_IME, "The binding ID is %d.", bindingId); + + return bindingId; +} + +result +_InputServiceBinder::Unbind(void) +{ + result r = E_SUCCESS; + + SysTryReturnResult(NID_UI_IME, IsBound(), E_HOST_NOT_FOUND, "The destination host is not found."); + + __pHelperAgent->close_connection(); + + return r; +} + +bool +_InputServiceBinder::IsBound(void) const +{ + return __pHelperAgent->is_connected(); +} + +BindingId +_InputServiceBinder::GetBindingId(void) const +{ + int bindingId = __pHelperAgent->get_connection_number(); + SysTryReturn(NID_UI_IME, bindingId > -1, bindingId, E_HOST_NOT_FOUND, "[E_HOST_NOT_FOUND] The destination host is not found."); + + return bindingId; +} + +}}} // Tizen::Ui::Ime diff --git a/src/FUiIme_InputServiceBinder.h b/src/FUiIme_InputServiceBinder.h new file mode 100644 index 0000000..24ce9a8 --- /dev/null +++ b/src/FUiIme_InputServiceBinder.h @@ -0,0 +1,82 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 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 FUiIme_InputServiceBinder.h + * @brief This is the header file for the %_InputServiceBinder class. + * + * This header file contains the declarations of the %_InputServiceBinder class. + */ + +#ifndef _FUI_IME_INTERNAL_INPUT_SERVICE_BINDER_H_ +#define _FUI_IME_INTERNAL_INPUT_SERVICE_BINDER_H_ + +#define Uses_SCIM_HELPER +#define Uses_SCIM_TYPES +#undef null +#include +#define null 0 + +#include +#include + +namespace Tizen { namespace Ui { namespace Ime { + +/** + * ID of a binding with the input service + * + * @since 2.0 + */ +typedef int BindingId; + +/** +* @class _InputServiceBinder +* @brief This class is a concrete class of the %_InputServiceBinder class. +* @since 2.0 +* +*/ +class _InputServiceBinder + : public Tizen::Base::Object +{ +public: + static _InputServiceBinder* GetInstance(void); + + scim::HelperAgent* GetHelperAgent(void) const; + + BindingId Bind(void); + result Unbind(void); + bool IsBound(void) const; + BindingId GetBindingId(void) const; + +private: + _InputServiceBinder(void); + virtual ~_InputServiceBinder(void); + + _InputServiceBinder(const _InputServiceBinder& rhs); + _InputServiceBinder& operator=(const _InputServiceBinder& rhs); + + result Construct(void); + +private: + static _InputServiceBinder* __pInputServiceBinder; + + scim::HelperAgent* __pHelperAgent; +}; + +}}} // Tizen::Ui::Ime + +#endif // _FUI_IME_INTERNAL_INPUT_SERVICE_BINDER_H_ diff --git a/src/FUiIme_InputServiceSignalListener.cpp b/src/FUiIme_InputServiceSignalListener.cpp new file mode 100644 index 0000000..68203ef --- /dev/null +++ b/src/FUiIme_InputServiceSignalListener.cpp @@ -0,0 +1,324 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 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 FUiIme_InputServiceSignalListener.cpp + * @brief This is the implementation file for the %_InputServiceSignalListener class. + * + * This implementation file contains definition of the %_InputServiceSignalListener class. + */ + +#include + +#include +#include +#include +#include +#include + +#include "FUiIme_InputMethodImpl.h" +#include "FUiIme_InputServiceSignalListener.h" +#include "FUiIme_ScimDataConverter.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Locales; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui { namespace Ime { + +IInputMethodProvider* _InputServiceSignalListener::__pIInputMethodProvider = null; +IInputMethodListener* _InputServiceSignalListener::__pIInputMethodListener = null; + +_InputServiceSignalListener::_InputServiceSignalListener() +{ +} + +_InputServiceSignalListener::~_InputServiceSignalListener() +{ + __pIInputMethodProvider = null; + __pIInputMethodListener = null; +} + +void +_InputServiceSignalListener::SetInputMethodProvider(IInputMethodProvider* pProvider) +{ + __pIInputMethodProvider = pProvider; +} + +void +_InputServiceSignalListener::SetInputMethodListener(IInputMethodListener* pListener) +{ + __pIInputMethodListener = pListener; +} + +void +_InputServiceSignalListener::GetEnterKeyAction(const scim::HelperAgent* pHelperAgent, scim::uint32& action) +{ + SysTryReturnVoidResult(NID_UI_IME, __pIInputMethodProvider, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist."); + + InputPanelAction inputPanelAction = __pIInputMethodProvider->GetEnterKeyAction(); + SysTryReturnVoidResult(NID_UI_IME, (inputPanelAction >= INPUT_PANEL_ACTION_ENTER) && (inputPanelAction <= INPUT_PANEL_ACTION_DONE), E_INVALID_DATA, "[E_INVALID_DATA] A requested data is invalid."); + + switch (inputPanelAction) + { + case INPUT_PANEL_ACTION_ENTER: + action = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT; + break; + case INPUT_PANEL_ACTION_DONE: + action = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE; + break; + case INPUT_PANEL_ACTION_GO: + action = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_GO; + break; + case INPUT_PANEL_ACTION_JOIN: + action = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_JOIN; + break; + case INPUT_PANEL_ACTION_LOGIN: + action = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_LOGIN; + break; + case INPUT_PANEL_ACTION_NEXT: + action = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT; + break; + case INPUT_PANEL_ACTION_SEARCH: + action = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH; + break; + case INPUT_PANEL_ACTION_SEND: + action = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEND; + break; + default: + action = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT; + break; + } +} + +void +_InputServiceSignalListener::GetInputPanelBounds(const scim::HelperAgent* pHelperAgent, struct scim::rectinfo& bounds) +{ + SysTryReturnVoidResult(NID_UI_IME, __pIInputMethodProvider, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist."); + + SysLog(NID_UI_IME, "The bounds of the input panel have been requested."); + + Rectangle inputPanelBounds = __pIInputMethodProvider->GetInputPanelBounds(); + + _ScimDataConverter::ConvertRectangle(inputPanelBounds, bounds); +} + +void +_InputServiceSignalListener::GetInputPanelStyle(const scim::HelperAgent* pHelperAgent, scim::uint32& style) +{ + SysTryReturnVoidResult(NID_UI_IME, __pIInputMethodProvider, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist."); + + InputPanelStyle inputPanelStyle = __pIInputMethodProvider->GetInputPanelStyle(); + SysTryReturnVoidResult(NID_UI_IME, (inputPanelStyle >= INPUT_PANEL_STYLE_NORMAL) && (inputPanelStyle <= INPUT_PANEL_STYLE_IP), E_INVALID_DATA, "[E_INVALID_DATA] A requested data is invalid."); + + switch (inputPanelStyle) + { + case INPUT_PANEL_STYLE_NORMAL: + style = ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL; + break; + case INPUT_PANEL_STYLE_EMAIL: + style = ECORE_IMF_INPUT_PANEL_LAYOUT_EMAIL; + break; + case INPUT_PANEL_STYLE_IP: + style = ECORE_IMF_INPUT_PANEL_LAYOUT_IP; + break; + case INPUT_PANEL_STYLE_NUMBER: + style = ECORE_IMF_INPUT_PANEL_LAYOUT_NUMBERONLY; + break; + case INPUT_PANEL_STYLE_PHONE_NUMBER: + style = ECORE_IMF_INPUT_PANEL_LAYOUT_PHONENUMBER; + break; + case INPUT_PANEL_STYLE_URL: + style = ECORE_IMF_INPUT_PANEL_LAYOUT_URL; + break; + default: + style = ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL; + break; + } +} + +void +_InputServiceSignalListener::SetCapsModeEnabled(const scim::HelperAgent* pHelperAgent, scim::uint32& mode) +{ + SysTryReturnVoidResult(NID_UI_IME, __pIInputMethodProvider, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist."); + + bool enable = (mode != 0 ? true : false); + + __pIInputMethodProvider->SetCapsModeEnabled(enable); +} + +void +_InputServiceSignalListener::SetEnterKeyAction(const scim::HelperAgent* pHelperAgent, scim::uint32& action) +{ + SysTryReturnVoidResult(NID_UI_IME, __pIInputMethodProvider, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist."); + SysTryReturnVoidResult(NID_UI_IME, action <= ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEND, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument(s) is used. The enter key action is beyond the scope."); + + InputPanelAction inputPanelAction; + + switch (action) + { + case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT: + inputPanelAction = INPUT_PANEL_ACTION_ENTER; + break; + case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE: + inputPanelAction = INPUT_PANEL_ACTION_DONE; + break; + case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_GO: + inputPanelAction = INPUT_PANEL_ACTION_GO; + break; + case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_JOIN: + inputPanelAction = INPUT_PANEL_ACTION_JOIN; + break; + case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_LOGIN: + inputPanelAction = INPUT_PANEL_ACTION_LOGIN; + break; + case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT: + inputPanelAction = INPUT_PANEL_ACTION_NEXT; + break; + case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH: + inputPanelAction = INPUT_PANEL_ACTION_SEARCH; + break; + case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEND: + inputPanelAction = INPUT_PANEL_ACTION_SEND; + break; + default: + inputPanelAction = INPUT_PANEL_ACTION_ENTER; + break; + } + + __pIInputMethodProvider->SetEnterKeyAction(inputPanelAction); +} + +void +_InputServiceSignalListener::SetEnterKeyActionEnabled(const scim::HelperAgent* pHelperAgent, scim::uint32& disable) +{ + SysTryReturnVoidResult(NID_UI_IME, __pIInputMethodProvider, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist."); + + bool enable = (disable != 0 ? false : true); + + __pIInputMethodProvider->SetEnterKeyActionEnabled(enable); +} + +void +_InputServiceSignalListener::SetInputPanelStyle(const scim::HelperAgent* pHelperAgent, scim::uint32& style) +{ + SysTryReturnVoidResult(NID_UI_IME, __pIInputMethodProvider, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist."); + SysTryReturnVoidResult(NID_UI_IME, style < ECORE_IMF_INPUT_PANEL_LAYOUT_INVALID, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument(s) is used. The input panel style is beyond the scope."); + + InputPanelStyle inputPanelStyle; + + switch (style) + { + case ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL: + inputPanelStyle = INPUT_PANEL_STYLE_NORMAL; + break; + case ECORE_IMF_INPUT_PANEL_LAYOUT_EMAIL: + inputPanelStyle = INPUT_PANEL_STYLE_EMAIL; + break; + case ECORE_IMF_INPUT_PANEL_LAYOUT_IP: + inputPanelStyle = INPUT_PANEL_STYLE_IP; + break; + case ECORE_IMF_INPUT_PANEL_LAYOUT_NUMBERONLY: + inputPanelStyle = INPUT_PANEL_STYLE_NUMBER; + break; + case ECORE_IMF_INPUT_PANEL_LAYOUT_PHONENUMBER: + inputPanelStyle = INPUT_PANEL_STYLE_PHONE_NUMBER; + break; + case ECORE_IMF_INPUT_PANEL_LAYOUT_URL: + inputPanelStyle = INPUT_PANEL_STYLE_URL; + break; + default: + inputPanelStyle = INPUT_PANEL_STYLE_NORMAL; + break; + } + + __pIInputMethodProvider->SetInputPanelStyle(inputPanelStyle); +} + +void +_InputServiceSignalListener::SetLanguage(const scim::HelperAgent* pHelperAgent, scim::uint32& language) +{ + SysTryReturnVoidResult(NID_UI_IME, __pIInputMethodProvider, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist."); + + LanguageCode languageCode = (language == ECORE_IMF_INPUT_PANEL_LANG_ALPHABET ? LANGUAGE_ENG : LANGUAGE_INVALID); + + if (languageCode == LANGUAGE_INVALID) + { + return; + } + + //__pIInputMethodProvider->SetLanguage(languageCode); +} + +void +_InputServiceSignalListener::HideInputPanel(const scim::HelperAgent* pHelperAgent, int inputContext, const scim::String& uuid) +{ + SysTryReturnVoidResult(NID_UI_IME, __pIInputMethodProvider, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist."); + + SysLog(NID_UI_IME, "Hiding the input panel has been requested."); + + __pIInputMethodProvider->HideInputPanel(); +} + +void +_InputServiceSignalListener::IsEnterKeyActionEnabled(const scim::HelperAgent* pHelperAgent, scim::uint32& enable) +{ + SysTryReturnVoidResult(NID_UI_IME, __pIInputMethodProvider, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist."); + + enable = static_cast(__pIInputMethodProvider->IsEnterKeyActionEnabled()); +} + +void +_InputServiceSignalListener::ShowInputPanel(const scim::HelperAgent* pHelperAgent, int inputContext, char* pBuffer, size_t& length) +{ + SysTryReturnVoidResult(NID_UI_IME, __pIInputMethodProvider, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist."); + + SysLog(NID_UI_IME, "Showing the input panel has been requested."); + + __pIInputMethodProvider->ShowInputPanel(); +} + +void +_InputServiceSignalListener::OnCursorPositionChanged(const scim::HelperAgent* pHelperAgent, int inputContext, const scim::String& uuid, int position) +{ + SysTryReturnVoidResult(NID_UI_IME, __pIInputMethodListener, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist."); + + __pIInputMethodListener->OnCursorPositionChanged(position); +} + +void +_InputServiceSignalListener::OnSurroundingTextReceived(const scim::HelperAgent* pHelperAgent, int inputContext, const scim::String& text, int cursorPosition) +{ + SysTryReturnVoidResult(NID_UI_IME, __pIInputMethodListener, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist."); + + String ospText; + + _ScimDataConverter::ConvertString(text, ospText); + + __pIInputMethodListener->OnSurroundingTextReceived(ospText, cursorPosition); +} + +void +_InputServiceSignalListener::OnTerminate (const scim::HelperAgent* pHelperAgent, int inputContext, const scim::String& uuid) +{ + Tizen::App::App::GetInstance()->Terminate(); +} + +}}} // Tizen::Ui::Ime diff --git a/src/FUiIme_InputServiceSignalListener.h b/src/FUiIme_InputServiceSignalListener.h new file mode 100644 index 0000000..ff3df42 --- /dev/null +++ b/src/FUiIme_InputServiceSignalListener.h @@ -0,0 +1,85 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 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 FUiIme_InputServiceSignalListener.h + * @brief This is the header file for the %_InputServiceSignalListener class. + * + * This header file contains the declarations of the %_InputServiceSignalListener class. + */ + +#ifndef _FUI_IME_INPUT_SERVICE_SIGNAL_LISTENER_H_ +#define _FUI_IME_INPUT_SERVICE_SIGNAL_LISTENER_H_ + +#define Uses_SCIM_HELPER +#define Uses_SCIM_TYPES +#undef null +#include +#define null 0 + +#include +#include + +namespace Tizen { namespace Ui { namespace Ime { + +/** +* @class _InputServiceSignalListener +* @brief This class is a concrete class of the %_InputServiceSignalListener class. +* @since 2.0 +* +*/ +class _InputServiceSignalListener +{ +public: + static void SetInputMethodProvider(IInputMethodProvider* pProvider); + static void SetInputMethodListener(IInputMethodListener* pListener); + + static void GetEnterKeyAction(const scim::HelperAgent* pHelperAgent, scim::uint32& action); + static void GetInputPanelBounds(const scim::HelperAgent* pHelperAgent, scim::rectinfo& bounds); + static void GetInputPanelStyle(const scim::HelperAgent* pHelperAgent, scim::uint32& style); + + static void SetCapsModeEnabled(const scim::HelperAgent* pHelperAgent, scim::uint32& mode); + static void SetEnterKeyAction(const scim::HelperAgent* pHelperAgent, scim::uint32& action); + static void SetEnterKeyActionEnabled(const scim::HelperAgent* pHelperAgent, scim::uint32& disable); + static void SetInputPanelStyle(const scim::HelperAgent* pHelperAgent, scim::uint32& style); + static void SetLanguage(const scim::HelperAgent* pHelperAgent, scim::uint32& language); + + static void HideInputPanel(const scim::HelperAgent* pHelperAgent, int inputContext, const scim::String& uuid); + static void IsEnterKeyActionEnabled(const scim::HelperAgent* pHelperAgent, scim::uint32& enable); + static void ShowInputPanel(const scim::HelperAgent* pHelperAgent, int inputContext, char* pBuffer, size_t& length); + + static void OnCursorPositionChanged(const scim::HelperAgent* pHelperAgent, int inputContext, const scim::String& uuid, + int position); + static void OnSurroundingTextReceived(const scim::HelperAgent* pHelperAgent, int inputContext, + const scim::String& text, int cursorPosition); + static void OnTerminate(const scim::HelperAgent* pHelperAgent, int inputContext, const scim::String& uuid); + +private: + _InputServiceSignalListener(); + ~_InputServiceSignalListener(); + + _InputServiceSignalListener(const _InputServiceSignalListener& rhs); + _InputServiceSignalListener& operator=(const _InputServiceSignalListener& rhs); + +private: + static IInputMethodProvider* __pIInputMethodProvider; + static IInputMethodListener* __pIInputMethodListener; +}; + +}}} // Tizen::Ui::Ime + +#endif // _FUI_IME_INPUT_SERVICE_SIGNAL_LISTENER_H_ diff --git a/src/FUiIme_Key.cpp b/src/FUiIme_Key.cpp new file mode 100644 index 0000000..bf4959e --- /dev/null +++ b/src/FUiIme_Key.cpp @@ -0,0 +1,87 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 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 FUiIme_Key.cpp + * @brief This is the implementation file for the types related to the key. + * + * This implementation file contains definition of the types related to the key. + */ + +#include "FUiIme_Key.h" + +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui { namespace Ime { + +extern const _KeyCode _KEY_CODE_MAP[] = { + {KEY_CLEAR, scim::SCIM_KEY_Clear}, + {KEY_0, scim::SCIM_KEY_0}, + {KEY_1, scim::SCIM_KEY_1}, + {KEY_2, scim::SCIM_KEY_2}, + {KEY_3, scim::SCIM_KEY_3}, + {KEY_4, scim::SCIM_KEY_4}, + {KEY_5, scim::SCIM_KEY_5}, + {KEY_6, scim::SCIM_KEY_6}, + {KEY_7, scim::SCIM_KEY_7}, + {KEY_8, scim::SCIM_KEY_8}, + {KEY_9, scim::SCIM_KEY_9}, + {KEY_ASTERISK, scim::SCIM_KEY_asterisk}, + {KEY_SHARP, scim::SCIM_KEY_ssharp}, + {KEY_LEFT, scim::SCIM_KEY_Left}, + {KEY_UP, scim::SCIM_KEY_Up}, + {KEY_DOWN, scim::SCIM_KEY_Down}, + {KEY_RIGHT, scim::SCIM_KEY_Right}, + {KEY_A, scim::SCIM_KEY_A}, + {KEY_B, scim::SCIM_KEY_B}, + {KEY_C, scim::SCIM_KEY_C}, + {KEY_D, scim::SCIM_KEY_D}, + {KEY_E, scim::SCIM_KEY_E}, + {KEY_F, scim::SCIM_KEY_F}, + {KEY_G, scim::SCIM_KEY_G}, + {KEY_H, scim::SCIM_KEY_H}, + {KEY_I, scim::SCIM_KEY_I}, + {KEY_J, scim::SCIM_KEY_J}, + {KEY_K, scim::SCIM_KEY_K}, + {KEY_L, scim::SCIM_KEY_L}, + {KEY_M, scim::SCIM_KEY_M}, + {KEY_N, scim::SCIM_KEY_N}, + {KEY_O, scim::SCIM_KEY_O}, + {KEY_P, scim::SCIM_KEY_P}, + {KEY_Q, scim::SCIM_KEY_Q}, + {KEY_R, scim::SCIM_KEY_R}, + {KEY_S, scim::SCIM_KEY_S}, + {KEY_T, scim::SCIM_KEY_T}, + {KEY_U, scim::SCIM_KEY_U}, + {KEY_V, scim::SCIM_KEY_V}, + {KEY_W, scim::SCIM_KEY_W}, + {KEY_X, scim::SCIM_KEY_X}, + {KEY_Y, scim::SCIM_KEY_Y}, + {KEY_Z, scim::SCIM_KEY_Z}, + {KEY_BACKSPACE,scim::SCIM_KEY_BackSpace}, + {KEY_COMMA, scim::SCIM_KEY_comma}, + {KEY_ENTER, scim::SCIM_KEY_Return}, + {KEY_CAPSLOCK, scim::SCIM_KEY_Caps_Lock}, + {KEY_QUESTION, scim::SCIM_KEY_question}, + {KEY_ALT, scim::SCIM_KEY_Alt_L}, + {KEY_SPACE, scim::SCIM_KEY_space}, + {KEY_DOT, scim::SCIM_KEY_period} +}; + +extern const int _MAX_KEY_CODE = sizeof(_KEY_CODE_MAP) / sizeof(_KEY_CODE_MAP[0]); + +}}} // Tizen::Ui::Ime diff --git a/src/FUiIme_Key.h b/src/FUiIme_Key.h new file mode 100644 index 0000000..0bff12c --- /dev/null +++ b/src/FUiIme_Key.h @@ -0,0 +1,57 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 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 FUiIme_Key.h + * @brief This is the header file for types related to the key which are used in the Tizen::Ui::Ime namespace. + * + * This header file contains types related to the key and the key map in both OSP and SCIM. + */ + +#ifndef _FUI_IME_INTERNAL_KEY_H_ +#define _FUI_IME_INTERNAL_KEY_H_ + +#define Uses_SCIM_EVENT +#include + +#include + +namespace Tizen { namespace Ui { namespace Ime { + +/** +* @struct _KeyCode +* Structure to hold the information of the input method key. +* @since 2.0 +*/ +struct _KeyCode +{ + Tizen::Ui::KeyCode keyCode; + scim::KeyCode scimKeyCode; +}; + +/** +* @brief _KEY_CODE_MAP +* Table to map osp keys and scim keys. +* @since 2.0 +*/ +extern const _KeyCode _KEY_CODE_MAP[]; + +extern const int _MAX_KEY_CODE; + +}}} // Tizen::Ui::Ime + +#endif // _FUI_IME_INTERNAL_KEY_H_ diff --git a/src/FUiIme_ScimDataConverter.cpp b/src/FUiIme_ScimDataConverter.cpp new file mode 100644 index 0000000..7de257b --- /dev/null +++ b/src/FUiIme_ScimDataConverter.cpp @@ -0,0 +1,149 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 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 FUiIme_ScimDataConverter.cpp + * @brief This is the implementation file for the %_ScimDataConverter class. + * + * This implementation file contains definition of the %_ScimDataConverter class. + */ + +#include +#include // vector in scim_event.h + +#define Uses_SCIM_EVENT +#define Uses_SCIM_UTILITY +#undef null +#include // SCIM_KEY_NullKey, SCIM_KEY_NullMask, SCIM_KEY_ReleaseMask +#define null 0 + +#include +#include +#include + +#include "FUiIme_Key.h" +#include "FUiIme_ScimDataConverter.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Locales; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui { namespace Ime { + +_ScimDataConverter::_ScimDataConverter() +{ + +} + +_ScimDataConverter::~_ScimDataConverter() +{ + +} + +result +_ScimDataConverter::ConvertKey(KeyCode code, KeyState state, scim::KeyEvent& event) +{ + result r = E_SUCCESS; + + event.code = scim::SCIM_KEY_NullKey; + event.mask = scim::SCIM_KEY_NullMask; + event.layout = scim::SCIM_KEYBOARD_Default; + + // event.code + for (int i = 0; i < _MAX_KEY_CODE; i++) + { + if (code == _KEY_CODE_MAP[i].keyCode) + { + event.code = _KEY_CODE_MAP[i].scimKeyCode; + break; + } + } + + // event.mask + switch (state) + { + case KEY_PRESSED: + event.mask = scim::SCIM_KEY_NullMask; // The NullMask means the PressMask. + break; + case KEY_RELEASED: + event.mask = scim::SCIM_KEY_ReleaseMask; + break; + case KEY_LONGPRESSED: + // Fall through + default: + break; + } + + return r; +} + +void +_ScimDataConverter::ConvertRectangle(const Rectangle& src, scim::rectinfo& dest) +{ + dest.pos_x = src.x; + dest.pos_y = src.y; + dest.width = src.width; + dest.height = src.height; +} + +result +_ScimDataConverter::ConvertString(const String& src, scim::String& dest) +{ + result r = E_SUCCESS; + + std::unique_ptr pCharSrc(_StringConverter::CopyToCharArrayN(src)); + r = GetLastResult(); + SysTryReturnResult(NID_UI_IME, pCharSrc, r, "Propagating."); + + dest = pCharSrc.get(); + + return r; +} + +result +_ScimDataConverter::ConvertString(const String& src, scim::WideString& dest) +{ + result r = E_SUCCESS; + + std::unique_ptr pCharSrc(_StringConverter::CopyToCharArrayN(src)); + r = GetLastResult(); + SysTryReturnResult(NID_UI_IME, pCharSrc, r, "Propagating."); + + dest = scim::utf8_mbstowcs(pCharSrc.get(), strlen(pCharSrc.get())); + + return r; +} + +result +_ScimDataConverter::ConvertString(const scim::String& src, String& dest) +{ + result r = E_SUCCESS; + + const char* pCharSrc = null; + + pCharSrc = src.c_str(); + SysTryReturnResult(NID_UI_IME, pCharSrc, E_INVALID_ARG, "Invalid argument(s) is used. The source is invalid."); + + String destString(pCharSrc); + + dest = destString; + + return r; +} + +}}} // Tizen::Ui::Ime diff --git a/src/FUiIme_ScimDataConverter.h b/src/FUiIme_ScimDataConverter.h new file mode 100644 index 0000000..85d8609 --- /dev/null +++ b/src/FUiIme_ScimDataConverter.h @@ -0,0 +1,79 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 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 FUiIme_ScimDataConverter.h + * @brief This is the header file for the %_ScimDataConverter class. + * + * This header file contains the declarations of the %_ScimDataConverter class. + */ + +#ifndef _FUI_IME_INTERNAL_SCIM_DATA_CONVERTER_H_ +#define _FUI_IME_INTERNAL_SCIM_DATA_CONVERTER_H_ + +#include // basic_string in scim_types.h + +#define Uses_SCIM_TYPES +#undef null +#include +#define null 0 + +#include +#include +#include +#include + +namespace scim +{ +struct KeyEvent; +} // scim + +namespace Tizen { namespace Base +{ +class String; +}} // Tizen::Base + +namespace Tizen { namespace Ui { namespace Ime { + +/** +* @class _ScimDataConverter +* @brief This class is a concrete class of the %_ScimDataConverter class. +* @since 2.0 +* +*/ +class _ScimDataConverter +{ +public: + static result ConvertKey(Tizen::Ui::KeyCode keyCode, Tizen::Ui::KeyState keyState, scim::KeyEvent& keyEvent); + + static void ConvertRectangle(const Tizen::Graphics::Rectangle& src, scim::rectinfo& dest); + + static result ConvertString(const Tizen::Base::String& src, scim::String& dest); + static result ConvertString(const Tizen::Base::String& src, scim::WideString& dest); + static result ConvertString(const scim::String& src, Tizen::Base::String& dest); + +private: + _ScimDataConverter(); + ~_ScimDataConverter(); + + _ScimDataConverter(const _ScimDataConverter&); + _ScimDataConverter& operator=(const _ScimDataConverter&); +}; + +}}} // Tizen::Ui::Ime + +#endif//_FUI_IME_INTERNAL_SCIM_DATA_CONVERTER_H_ diff --git a/src/app/FApp_ImeEntry.cpp b/src/app/FApp_ImeEntry.cpp new file mode 100644 index 0000000..95b5312 --- /dev/null +++ b/src/app/FApp_ImeEntry.cpp @@ -0,0 +1,517 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 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 FApp_ImeEntry.cpp + * @brief This is the entry point for the IME application. + */ + +#include +#include // LOG() +#include // open() +#include +#include // PATH_MAX +#include +#include +#include +#include +#include // readlink() + +#define Uses_SCIM_CONFIG_BASE +#define Uses_SCIM_HELPER +#define Uses_SCIM_TYPES +#undef null +#include +#define null 0 + +#include +#include +#include + +#include + +static const char* _LOG_TAG_IME = "IME"; + +static const int _MAX_LANGUAGE_BUFFER_SIZE = 371; // 53*7 +static const int _MAX_BUFFER_SIZE = 256; +static const int _MAX_PACKAGE_NAME = 100; +static const char* _MANIFEST_FILE_PATH = "info/manifest.xml"; + +static int __argc = 0; +static char** __pArgv = NULL; + +static char __appId[_MAX_BUFFER_SIZE]; +static char __uuid[_MAX_BUFFER_SIZE]; +static char __name[_MAX_BUFFER_SIZE]; +static char __language[_MAX_LANGUAGE_BUFFER_SIZE]; + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +extern void InitAppInfo(const char* appId, const char* exeName, int argc, char* pArgv[], int fd); +extern void InitImeInfo(const char* uuid, const char* name, const char* language); +extern int OspMain(int argc, char* pArgv[]) __attribute__((weak)); + +static void +AdjustPrivilege(const char* pkgname) +{ + void* handle = dlopen("libprivilege-control.so.0", RTLD_LAZY | RTLD_LOCAL); + if (!handle) + { + fprintf(stderr, "Cannot open libprivilege-control.so.0\n"); + return; + } + + char* msg = 0; + dlerror(); + + int (* ppriv_func)(const char*) = NULL; + + ppriv_func = reinterpret_cast (dlsym(handle, "set_privilege")); + msg = dlerror(); + if (msg != NULL) + { + fprintf(stderr, "Dlsym error: %s\n", msg); + + dlclose(handle); + return; + } + + int ret = (*ppriv_func)(pkgname); + if (ret < 0) + { + fprintf(stderr, "set_privilege() returned %d\n", ret); + } + + dlclose(handle); +} + +extern "C" int capset(cap_user_header_t hdrp, const cap_user_data_t datap); + +static int +AdjustCapability(void) +{ + cap_user_header_t head = 0; + cap_user_data_t data = 0; + + head = static_cast(malloc(sizeof(*head))); + if (head == NULL) + { + fprintf(stderr, "Memory allocation failure.\n"); + return -1; + } + + head->version = _LINUX_CAPABILITY_VERSION; + head->pid = getpid(); + + data = static_cast(calloc(sizeof(*data), _LINUX_CAPABILITY_U32S)); + if (data == NULL) + { + fprintf(stderr, "Memory allocation failure.\n"); + + free(head); + return -1; + } + + data[CAP_TO_INDEX(CAP_NET_RAW)].effective |= CAP_TO_MASK(CAP_NET_RAW); + data[CAP_TO_INDEX(CAP_NET_RAW)].permitted |= CAP_TO_MASK(CAP_NET_RAW); + + if (capset(head, data) < 0) + { + fprintf(stderr, "Capability setting error\n"); + + free(data); + free(head); + return -1; + } + + free(data); + free(head); + + return 0; +} + +static int +DoPreExec(const char* bin_path) +{ + void* handle = NULL; + char* errormsg = 0; + int (* DoPreExecFunc)(const char*, const char*) = NULL; + int ret = 0; + + handle = dlopen("libosp-env-config.so", RTLD_LAZY | RTLD_GLOBAL); + if (!handle) + { + LOG(LOG_DEBUG, _LOG_TAG_IME, "IME > Failed to dlopen libosp-env-config.so (%s)", dlerror()); + return -1; + } + LOG(LOG_DEBUG, _LOG_TAG_IME, "IME > dlopen() ok"); + + DoPreExecFunc = reinterpret_cast (dlsym(handle, "do_pre_exec")); + errormsg = dlerror(); + if (errormsg != NULL) + { + LOG(LOG_DEBUG, _LOG_TAG_IME, "IME > Failed to dlsym() (%s)", errormsg); + dlclose(handle); + return -1; + } + LOG(LOG_DEBUG, _LOG_TAG_IME, "IME > dlsym() ok"); + + ret = DoPreExecFunc(NULL, bin_path); + if (ret < 0) + { + LOG(LOG_DEBUG, _LOG_TAG_IME, "IME > Failed to do_pre_exe() (%d)", ret); + } + LOG(LOG_DEBUG, _LOG_TAG_IME, "IME > do_pre_exe() ok"); + + dlclose(handle); + + return 0; +} + +static int +GetDirFdFromPath(const char* pPath) +{ + int count = 0; + const int len = strlen(pPath); + char dname[PATH_MAX]; + memset(dname, 0, PATH_MAX); + + const char* p = pPath + len; + for (int i = 0; i < len; i++, p--) + { + if (*p == '/') + { + count++; + + if (count == 2) + { + goto OUT; + } + } + } + + LOG(LOG_DEBUG, _LOG_TAG_IME, "%s {%d) > wrong path format: %s.", __func__, __LINE__, pPath); + + return -1; + +OUT: + strncpy(dname, pPath, p - pPath); + + const int fd = open(dname, O_RDONLY | O_CLOEXEC | O_DIRECTORY); + + LOG(LOG_DEBUG, _LOG_TAG_IME, "%s {%d) > directory path: %s, fd: %d", __func__, __LINE__, dname, fd); + + return fd; +} + +static bool +GetPackageNameFromAppIdAppExecutableName(const char appId[], const char exeName[], char* pkgName, int maxPkgName) +{ + // package name is "[appid].[executable]" + + snprintf(pkgName, maxPkgName, "%s.%s", appId, exeName); + + LOG(LOG_DEBUG, _LOG_TAG_IME, "IME, packageName is %s", pkgName); + + return true; +} + +static void +PrintArgs(int argc, char* argv[]) +{ + const char* value = NULL; + int i = 0; + + do + { + value = argv[i]; + LOG(LOG_DEBUG, _LOG_TAG_IME, "%s {%d) > %dth arg: [%s]", __func__, __LINE__, i, value); + i++; + } + while (value); +} + +static void +ParseXmlNode(const xmlNodePtr pXmlNode) +{ + xmlNodePtr pItorNode = null; + + for (pItorNode = pXmlNode; pItorNode != null; pItorNode = pItorNode->next) + { + if (pItorNode->type == XML_ELEMENT_NODE) + { + if (!xmlStrcmp(pItorNode->name, reinterpret_cast("Id"))) + { + xmlChar* pXmlChar = null; + pXmlChar = xmlNodeGetContent(pItorNode); + + if (pXmlChar) + { + strncpy(__appId, reinterpret_cast(pXmlChar), strlen(reinterpret_cast(pXmlChar))); + xmlFree(pXmlChar); + } + + LOG(LOG_DEBUG, _LOG_TAG_IME, "%s {%d) > __appId is %s.", __func__, __LINE__, __appId); + } + else if (!xmlStrcmp(pItorNode->name, reinterpret_cast("Uuid"))) + { + xmlChar* pXmlChar = null; + pXmlChar = xmlNodeGetContent(pItorNode); + + if (pXmlChar) + { + strncpy(__uuid, reinterpret_cast(pXmlChar), strlen(reinterpret_cast(pXmlChar))); + xmlFree(pXmlChar); + } + + LOG(LOG_DEBUG, _LOG_TAG_IME, "%s {%d) > __uuid is %s.", __func__, __LINE__, __uuid); + } + else if (!xmlStrcmp(pItorNode->name, reinterpret_cast("DisplayName"))) + { + xmlChar* pXmlChar = null; + pXmlChar = xmlNodeGetContent(pItorNode); + + if (pXmlChar) + { + strncpy(__name, reinterpret_cast(pXmlChar), strlen(reinterpret_cast(pXmlChar))); + xmlFree(pXmlChar); + } + + LOG(LOG_DEBUG, _LOG_TAG_IME, "%s {%d) > __name is %s.", __func__, __LINE__, __name); + } + else if (!xmlStrcmp(pItorNode->name, reinterpret_cast("Language"))) + { + const int _LANGUAGE_CODE_LENGTH = 3; + + xmlChar* pXmlChar = null; + pXmlChar = xmlNodeGetContent(pItorNode); + + if (pXmlChar) + { + if (strlen(__language) != 0) + { + strcat(__language, ","); + } + + char languageCode[_LANGUAGE_CODE_LENGTH + 1]; + memset(languageCode, '\0', _LANGUAGE_CODE_LENGTH + 1); + strncpy(languageCode, reinterpret_cast(pXmlChar), _LANGUAGE_CODE_LENGTH); + Tizen::Base::String twoLetterLanguageCode = Tizen::Locales::Locale::LanguageCodeToTwoLetterLanguageCodeString(Tizen::Locales::Locale::StringToLanguageCode(languageCode)); + + // append language code + std::unique_ptr pLanguageCode(Tizen::Base::_StringConverter::CopyToCharArrayN(twoLetterLanguageCode.GetPointer())); + if (pLanguageCode) + { + strcat(__language, pLanguageCode.get()); + } + + // append country code + strcat(__language, reinterpret_cast(pXmlChar + _LANGUAGE_CODE_LENGTH)); + + xmlFree(pXmlChar); + } + + LOG(LOG_DEBUG, _LOG_TAG_IME, "%s {%d) > __language is %s.", __func__, __LINE__, __language); + } + + if (pItorNode->children) + { + ParseXmlNode(pItorNode->children); + } + } + } +} + +static void +ParseImeInfo(const char* filePath) +{ + LOG(LOG_DEBUG, _LOG_TAG_IME, "%s {%d) > The filePath is %s.", __func__, __LINE__, filePath); + + xmlDocPtr pXmlDoc = null; + xmlNodePtr pRootElement = null; + + pXmlDoc = xmlParseFile(filePath); + if (pXmlDoc == null) + { + LOG(LOG_DEBUG, _LOG_TAG_IME, "%s {%d) > xmlParseFile() has failed.", __func__, __LINE__); + goto CATCH; + } + + pRootElement = xmlDocGetRootElement(pXmlDoc); + if (pRootElement == null) + { + LOG(LOG_DEBUG, _LOG_TAG_IME, "%s {%d) > xmlDocGetRootElement() has falied.", __func__, __LINE__); + goto CATCH; + } + + ParseXmlNode(pRootElement); + + // Fall through +CATCH: + if (pXmlDoc) + { + xmlFreeDoc(pXmlDoc); + } + + xmlCleanupParser(); +} + +void _OSP_EXPORT_ +scim_module_init (void) +{ + LOG(LOG_DEBUG, _LOG_TAG_IME, "%s {%d) > scim_module_init() has been called.", __func__, __LINE__); +} + +void _OSP_EXPORT_ +scim_module_exit (void) +{ + LOG(LOG_DEBUG, _LOG_TAG_IME, "%s {%d) > scim_module_exit() has been called.", __func__, __LINE__); +} + +void _OSP_EXPORT_ +scim_helper_module_set_path_info(const char* path) +{ + LOG(LOG_DEBUG, _LOG_TAG_IME, "%s {%d) > The path is %s.", __func__, __LINE__, path); + + memset(__appId, '\0', _MAX_BUFFER_SIZE); + memset(__uuid, '\0', _MAX_BUFFER_SIZE); + memset(__name, '\0', _MAX_BUFFER_SIZE); + memset(__language, '\0', _MAX_LANGUAGE_BUFFER_SIZE); + + char symbolicLinkPath[_MAX_BUFFER_SIZE]; + memset(symbolicLinkPath, '\0', _MAX_BUFFER_SIZE); + ssize_t byteCount = -1; + byteCount = readlink(path, symbolicLinkPath, _MAX_BUFFER_SIZE); + LOG(LOG_DEBUG, _LOG_TAG_IME, "%s {%d) > The byteCount is %d.", __func__, __LINE__, byteCount); + + // parse ime info + const char* pSeparator = strstr(symbolicLinkPath, "/bin"); + + char manifestFilePath[_MAX_BUFFER_SIZE]; + memset(manifestFilePath, '\0', _MAX_BUFFER_SIZE); + + strncpy(manifestFilePath, symbolicLinkPath, pSeparator - symbolicLinkPath + 1); + strcat(manifestFilePath, _MANIFEST_FILE_PATH); + + ParseImeInfo(manifestFilePath); + + // initialize ime info + InitImeInfo(__uuid, __name, __language); +} + +bool _OSP_EXPORT_ +scim_helper_module_get_helper_info (unsigned int idx, scim::HelperInfo& info) +{ + LOG(LOG_DEBUG, _LOG_TAG_IME, "%s {%d) > scim_helper_module_get_helper_info() has been called.", __func__, __LINE__); + + if (idx == 0) + { + info = scim::HelperInfo(__uuid, __name, "", "", + scim::SCIM_HELPER_STAND_ALONE | scim::SCIM_HELPER_NEED_SCREEN_INFO | scim::SCIM_HELPER_AUTO_RESTART); + + LOG(LOG_DEBUG, _LOG_TAG_IME, "%s {%d) > __uuid is %s and __name is %s.", __func__, __LINE__, __uuid, __name); + + return true; + } + + return false; +} + +scim::String _OSP_EXPORT_ +scim_helper_module_get_helper_language (unsigned int idx) +{ + LOG(LOG_DEBUG, _LOG_TAG_IME, "%s {%d) > __language is %s.", __func__, __LINE__, __language); + + return __language; +} + +unsigned int _OSP_EXPORT_ +scim_helper_module_number_of_helpers (void) +{ + LOG(LOG_DEBUG, _LOG_TAG_IME, "%s {%d) > scim_helper_module_number_of_helpers() has been called.", __func__, __LINE__); + + return 1; +} + +void _OSP_EXPORT_ +scim_helper_module_set_arg_info(int argc, char* argv[]) +{ + __argc = argc; + __pArgv = argv; +} + +void _OSP_EXPORT_ +scim_helper_module_run_helper(const scim::String& uuid, const scim::ConfigPointer& config, const scim::String& display) +{ + LOG(LOG_DEBUG, _LOG_TAG_IME, "%s {%d) > scim_helper_module_run_helper() has been called.", __func__, __LINE__); + + // get binaryPath + char binaryPath[_MAX_BUFFER_SIZE]; + memset(binaryPath, '\0', _MAX_BUFFER_SIZE); + + snprintf(binaryPath, _MAX_BUFFER_SIZE - 1, "/opt/apps/%s/bin/%s", __appId, __name); + LOG(LOG_DEBUG, _LOG_TAG_IME, "%s {%d) > The binary path is %s.", __func__, __LINE__, binaryPath); + + // set __pArgv + int argvCount = strlen(__pArgv[0]); + LOG(LOG_DEBUG, _LOG_TAG_IME, "%s {%d) > __pArgv[0] is %s and the length of __pArgv[0] is %d.", __func__, __LINE__, __pArgv[0], argvCount); + + memset(__pArgv[0], '\0', argvCount); + snprintf(__pArgv[0], strlen(binaryPath) + 1, "%s", binaryPath); + PrintArgs(__argc, __pArgv); + + LOG(LOG_DEBUG, _LOG_TAG_IME, "%s {%d) > uid is %d and euid is %d.", __func__, __LINE__, getuid(), geteuid()); + + if (getuid() == 0) + { + // self caging + DoPreExec(binaryPath); + + // adjust privilege + char packageName[_MAX_PACKAGE_NAME]; + memset(packageName, '\0', _MAX_PACKAGE_NAME); + + GetPackageNameFromAppIdAppExecutableName(__appId, __name, packageName, _MAX_PACKAGE_NAME); + AdjustPrivilege(packageName); + } + + AdjustCapability(); + + // InitAppInfo + int fd = GetDirFdFromPath(__pArgv[0]); + if (fd == -1) + { + LOG(LOG_DEBUG, _LOG_TAG_IME, "%s {%d) > Openning a executable binary in the designated path has failed." + , __func__, __LINE__); + return; + } + + InitAppInfo(__appId, __name, __argc, __pArgv, fd); + + // + OspMain(__argc, __pArgv); + + LOG(LOG_DEBUG, _LOG_TAG_IME, "%s {%d) > scim_helper_module_run_helper() has been terminated.", __func__, __LINE__); + LOG(LOG_DEBUG, _LOG_TAG_IME, "%s {%d) > uid is %d and euid is %d.", __func__, __LINE__, getuid(), geteuid()); +} + +#ifdef __cplusplus +} +#endif // __cplusplus